X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fimports.c;h=8f097195922e590a2fafc209c5cdc138bf8f9f1c;hb=7a80c1bbc56b61525634f2b699f995e863dfade2;hp=bcca4edc1aa77dd3b898a1c5ea355f93672adba0;hpb=dbf3a15313eed930a3d8fdde12e457259c43651b;p=mesa.git diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index bcca4edc1aa..8f097195922 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -46,6 +46,7 @@ #include "imports.h" #include "context.h" +#include "mtypes.h" #include "version.h" #ifdef _GNU_SOURCE @@ -88,7 +89,8 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment) #if defined(HAVE_POSIX_MEMALIGN) void *mem; int err = posix_memalign(& mem, alignment, bytes); - (void) err; + if (err) + return NULL; return mem; #elif defined(_WIN32) && defined(_MSC_VER) return _aligned_malloc(bytes, alignment); @@ -451,6 +453,7 @@ _mesa_inv_sqrtf(float n) #endif } +#ifndef __GNUC__ /** * Find the first bit set in a word. */ @@ -494,9 +497,6 @@ _mesa_ffs(int32_t i) int _mesa_ffsll(int64_t val) { -#ifdef ffsll - return ffsll(val); -#else int bit; assert(sizeof(val) == 8); @@ -510,27 +510,24 @@ _mesa_ffsll(int64_t val) return 32 + bit; return 0; -#endif } +#endif - +#if !defined(__GNUC__) ||\ + ((_GNUC__ == 3 && __GNUC_MINOR__ < 4) && __GNUC__ < 4) /** * Return number of bits set in given GLuint. */ unsigned int _mesa_bitcount(unsigned int n) { -#if defined(__GNUC__) && \ - ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - return __builtin_popcount(n); -#else unsigned int bits; for (bits = 0; n > 0; n = n >> 1) { bits += (n & 1); } return bits; -#endif } +#endif /** @@ -756,7 +753,8 @@ _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); @@ -933,14 +931,20 @@ _mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) { va_list args; char str[MAXSTRING]; + static int numCalls = 0; + (void) ctx; - va_start( args, fmtString ); - vsnprintf( str, MAXSTRING, fmtString, args ); - va_end( args ); + if (numCalls < 50) { + numCalls++; - fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str); - fprintf(stderr, "Please report at bugzilla.freedesktop.org\n"); + va_start( args, fmtString ); + vsnprintf( str, MAXSTRING, fmtString, args ); + va_end( args ); + fprintf(stderr, "Mesa %s implementation error: %s\n", + MESA_VERSION_STRING, str); + fprintf(stderr, "Please report at bugs.freedesktop.org\n"); + } }