* OTHER DEALINGS IN THE SOFTWARE.
*/
-
-
+#include <stdio.h>
+#include <stdarg.h>
+#include "c99_math.h"
#include "imports.h"
#include "context.h"
#include "mtypes.h"
#else
uintptr_t ptr, buf;
- ASSERT( alignment > 0 );
+ assert( alignment > 0 );
ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *));
if (!ptr)
#else
uintptr_t ptr, buf;
- ASSERT( alignment > 0 );
+ assert( alignment > 0 );
ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *));
if (!ptr)
/*@{*/
-#ifndef __GNUC__
+#ifndef HAVE___BUILTIN_FFS
/**
* Find the first bit set in a word.
*/
}
return bit;
}
+#endif
-
+#ifndef HAVE___BUILTIN_FFSLL
/**
* Find position of first bit set in given value.
* XXX Warning: this function can only be used on 64-bit systems!
return 0;
}
-#endif /* __GNUC__ */
+#endif
-#if !defined(__GNUC__) ||\
- ((__GNUC__ * 100 + __GNUC_MINOR__) < 304) /* Not gcc 3.4 or later */
+#ifndef HAVE___BUILTIN_POPCOUNT
/**
* Return number of bits set in given GLuint.
*/
}
return bits;
}
+#endif
+#ifndef HAVE___BUILTIN_POPCOUNTLL
/**
* Return number of bits set in given 64-bit uint.
*/
/*@}*/
-/**********************************************************************/
-/** \name Environment vars */
-/*@{*/
-
-/**
- * Wrapper for getenv().
- */
-char *
-_mesa_getenv( const char *var )
-{
- return getenv(var);
-}
-
-/*@}*/
-
-
/**********************************************************************/
/** \name String */
/*@{*/
-/**
- * Implemented using malloc() and strcpy.
- * Note that NULL is handled accordingly.
- */
-char *
-_mesa_strdup( const char *s )
-{
- if (s) {
- size_t l = strlen(s);
- char *s2 = malloc(l + 1);
- if (s2)
- strcpy(s2, s);
- return s2;
- }
- else {
- return NULL;
- }
-}
-
-/** Wrapper around strtof() */
-float
-_mesa_strtof( const char *s, char **end )
-{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \
- !defined(__NetBSD__)
- static locale_t loc = NULL;
- if (!loc) {
- loc = newlocale(LC_CTYPE_MASK, "C", NULL);
- }
- return strtof_l(s, end, loc);
-#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
- return strtof(s, end);
-#else
- return (float)strtod(s, end);
-#endif
-}
/** Compute simple checksum/hash for a string */
unsigned int