mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
Preliminary 'log2()' and 'log2f()' implementation
The 'log2()' and 'log2f()' functions have been added in FreeBSD's libc version 9.0.0, but they are missing in version 8.2.0, which is used in Genode. This patch provides preliminary implementations of these functions until the Genode libc gets updated to version 9.0.0 or above. Fixes #143.
This commit is contained in:
parent
0bf6a24d61
commit
2d290c0898
@ -19,9 +19,6 @@ SRC_C += u_format_access.c u_format_table.c
|
||||
# remove non-needed files from list
|
||||
SRC_C := $(filter-out u_indices.c u_unfilled_indices.c u_debug_memory.c,$(SRC_C))
|
||||
|
||||
# definition of 'log2' that is missing in FreeBSD's libc
|
||||
CC_OPT_u_math = -D'log2(x)=(log(x)/log(2))'
|
||||
|
||||
# dim build noise
|
||||
CC_OPT_draw_vertex += -Wno-unused-but-set-variable
|
||||
CC_OPT_draw_vs_varient += -Wno-enum-compare
|
||||
|
@ -67,6 +67,9 @@ SRC_C = $(wildcard $(LIBM_DIR)/src/*.c) \
|
||||
$(wildcard $(LIBM_DIR)/bsdsrc/*.c)
|
||||
SRC_C := $(filter-out $(FILTER_OUT),$(notdir $(SRC_C)))
|
||||
|
||||
# remove on update to version 9
|
||||
SRC_C += log2.c
|
||||
|
||||
#
|
||||
# 'e_rem_pio2.c' uses '__inline'
|
||||
#
|
||||
@ -76,4 +79,7 @@ vpath %.c $(LIBM_DIR)/src
|
||||
vpath %.c $(LIBM_DIR)/ld80
|
||||
vpath %.c $(LIBM_DIR)/bsdsrc
|
||||
|
||||
# remove on update to version 9
|
||||
vpath log2.c $(REP_DIR)/src/lib/libc
|
||||
|
||||
SHARED_LIB = yes
|
||||
|
26
libports/src/lib/libc/log2.c
Normal file
26
libports/src/lib/libc/log2.c
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* \brief Preliminary 'log2()' and 'log2f()' implementations
|
||||
* \author Christian Prochaska
|
||||
* \date 2012-03-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2012 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
double log2(double x)
|
||||
{
|
||||
return log(x) / log(2);
|
||||
}
|
||||
|
||||
|
||||
float log2f(float x)
|
||||
{
|
||||
return logf(x) / logf(2);
|
||||
}
|
22
libports/src/lib/libc/patches/log2.patch
Normal file
22
libports/src/lib/libc/patches/log2.patch
Normal file
@ -0,0 +1,22 @@
|
||||
- add 'log2()' and 'log2f()' declarations
|
||||
- this patch is only needed for FreeBSD libc versions < 9
|
||||
|
||||
diff --git a/msun/src/math.h b/msun/src/math.h
|
||||
--- msun/src/math.h
|
||||
+++ msun/src/math.h
|
||||
@@ -204,6 +204,7 @@
|
||||
double ldexp(double, int);
|
||||
double log(double);
|
||||
double log10(double);
|
||||
+double log2(double);
|
||||
double modf(double, double *); /* fundamentally !__pure2 */
|
||||
|
||||
double pow(double, double);
|
||||
@@ -317,6 +318,7 @@
|
||||
int ilogbf(float) __pure2;
|
||||
float ldexpf(float, int);
|
||||
float log10f(float);
|
||||
+float log2f(float);
|
||||
float log1pf(float);
|
||||
float logf(float);
|
||||
float modff(float, float *); /* fundamentally !__pure2 */
|
Loading…
Reference in New Issue
Block a user