From 17935c0191b4c5adb68dd59df23282caef869875 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 27 Sep 2010 00:19:43 +0800 Subject: android: Fix build with bionic. --- src/gallium/auxiliary/os/os_thread.h | 2 +- src/gallium/auxiliary/util/u_math.h | 10 ++++++++++ src/gallium/include/pipe/p_compiler.h | 2 ++ src/gallium/include/pipe/p_config.h | 8 ++++++++ src/glsl/ir_reader.cpp | 2 +- src/glsl/link_functions.cpp | 2 +- src/glsl/linker.cpp | 2 +- src/mesa/main/imports.c | 2 +- src/mesa/main/imports.h | 7 +++++++ src/mesa/main/querymatrix.c | 3 ++- src/talloc/talloc.c | 2 +- 11 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index a084310d4f..64e3869a74 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -306,7 +306,7 @@ typedef int64_t pipe_condvar; * pipe_barrier */ -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) +#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)) && !defined(PIPE_OS_ANDROID) typedef pthread_barrier_t pipe_barrier; diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 37294b7203..cfcb9cd857 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -187,6 +187,16 @@ static INLINE double log2( double x ) #endif /* _MSC_VER */ +#ifdef PIPE_OS_ANDROID + +static INLINE +double log2(double d) +{ + return log(d) / M_LN2; +} + +#endif + diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index 3d6b5b5c81..a842d541eb 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -67,7 +67,9 @@ extern "C" { #if !defined(__HAIKU__) && !defined(__USE_MISC) +#if !defined(PIPE_OS_ANDROID) typedef unsigned int uint; +#endif typedef unsigned short ushort; #endif typedef unsigned char ubyte; diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h index 74a1fa2978..988430c11d 100644 --- a/src/gallium/include/pipe/p_config.h +++ b/src/gallium/include/pipe/p_config.h @@ -133,6 +133,14 @@ #define PIPE_OS_UNIX #endif +/* + * Android defines __linux__ so PIPE_OS_LINUX and PIPE_OS_UNIX will also be + * defined. + */ +#if defined(ANDROID) +#define PIPE_OS_ANDROID +#endif + #if defined(__FreeBSD__) #define PIPE_OS_FREEBSD #define PIPE_OS_BSD diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 5a718d3b75..b9d9d8639f 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -21,9 +21,9 @@ * DEALINGS IN THE SOFTWARE. */ -#include extern "C" { +#include #include } diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 05930edb80..c6339abf23 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -23,9 +23,9 @@ #include #include -#include extern "C" { +#include #include } diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e62fe6d7e9..a219ab7e66 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -65,10 +65,10 @@ */ #include #include -#include #include extern "C" { +#include #include } diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index cefbf4d8c9..d662e055b2 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -757,7 +757,7 @@ _mesa_strdup( const char *s ) float _mesa_strtof( const char *s, char **end ) { -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && !defined(ANDROID) static locale_t loc = NULL; if (!loc) { loc = newlocale(LC_CTYPE_MASK, "C", NULL); diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 5ea647ad8d..c0686efed2 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -116,6 +116,7 @@ typedef union { GLfloat f; GLint i; } fi_type; #endif + /** * \name Work-arounds for platforms that lack C99 math functions */ @@ -134,7 +135,13 @@ typedef union { GLfloat f; GLint i; } fi_type; #define exp2f(f) ((float) exp2(f)) #define floorf(f) ((float) floor(f)) #define logf(f) ((float) log(f)) + +#ifdef ANDROID +#define log2f(f) ((float) (log(f) / M_LN2)) +#else #define log2f(f) ((float) log2(f)) +#endif + #define powf(x,y) ((float) pow(x,y)) #define sinf(f) ((float) sin(f)) #define sinhf(f) ((float) sinh(f)) diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c index 944ad435f7..11c7b0669d 100644 --- a/src/mesa/main/querymatrix.c +++ b/src/mesa/main/querymatrix.c @@ -73,7 +73,8 @@ fpclassify(double x) #elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \ - (defined(__sun) && defined(__GNUC__)) + (defined(__sun) && defined(__GNUC__)) || \ + defined(ANDROID) /* fpclassify is available. */ diff --git a/src/talloc/talloc.c b/src/talloc/talloc.c index cc01346a7f..ea77684f7b 100644 --- a/src/talloc/talloc.c +++ b/src/talloc/talloc.c @@ -56,7 +56,7 @@ static size_t strnlen (const char* s, size_t n) #endif /* Visual C++ 2008 & Xcode/gcc4.0 compatibility */ -#if !defined(_cplusplus) && (defined(WIN32) || defined(__APPLE__)) +#if !defined(_cplusplus) && (defined(WIN32) || defined(__APPLE__) || defined(ANDROID)) typedef int bool; #define false 0 #define true 1 -- cgit v1.2.3