* - scanf
* - qsort
* - rand and RAND_MAX
- *
- * \note When compiled into a XFree86 module these functions wrap around
- * XFree86 own wrappers.
*/
/*
#endif
#endif
-/* If we don't actually want to use the libcwrapper junk (even though we're
- * building an Xorg server module), then just undef IN_MODULE to signal that to
- * the following code. It's left around for now to allow compiling of newish
- * Mesa with older servers, but this whole mess should go away at some point.
- */
-#ifdef NO_LIBCWRAPPER
-#undef IN_MODULE
-#endif
-
/**********************************************************************/
/** \name Memory */
/*@{*/
-/** Wrapper around either malloc() or xf86malloc() */
+/** Wrapper around malloc() */
void *
_mesa_malloc(size_t bytes)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86malloc(bytes);
-#else
return malloc(bytes);
-#endif
}
-/** Wrapper around either calloc() or xf86calloc() */
+/** Wrapper around calloc() */
void *
_mesa_calloc(size_t bytes)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86calloc(1, bytes);
-#else
return calloc(1, bytes);
-#endif
}
-/** Wrapper around either free() or xf86free() */
+/** Wrapper around free() */
void
_mesa_free(void *ptr)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86free(ptr);
-#else
free(ptr);
-#endif
}
/**
void *
_mesa_align_malloc(size_t bytes, unsigned long alignment)
{
-#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
+#if defined(HAVE_POSIX_MEMALIGN)
void *mem;
(void) posix_memalign(& mem, alignment, bytes);
#endif
return (void *) buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
+#endif /* defined(HAVE_POSIX_MEMALIGN) */
}
/**
void *
_mesa_align_calloc(size_t bytes, unsigned long alignment)
{
-#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
+#if defined(HAVE_POSIX_MEMALIGN)
void *mem;
mem = _mesa_align_malloc(bytes, alignment);
#endif
return (void *)buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
+#endif /* defined(HAVE_POSIX_MEMALIGN) */
}
/**
void
_mesa_align_free(void *ptr)
{
-#if defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE))
+#if defined(HAVE_POSIX_MEMALIGN)
free(ptr);
#else
void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
void *realAddr = *cubbyHole;
_mesa_free(realAddr);
-#endif /* defined(HAVE_POSIX_MEMALIGN) && !(defined(XFree86LOADER) && defined(IN_MODULE)) */
+#endif /* defined(HAVE_POSIX_MEMALIGN) */
}
/**
void *
_mesa_memcpy(void *dest, const void *src, size_t n)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86memcpy(dest, src, n);
-#elif defined(SUNOS4)
+#if defined(SUNOS4)
return memcpy((char *) dest, (char *) src, (int) n);
#else
return memcpy(dest, src, n);
#endif
}
-/** Wrapper around either memset() or xf86memset() */
+/** Wrapper around memset() */
void
_mesa_memset( void *dst, int val, size_t n )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86memset( dst, val, n );
-#elif defined(SUNOS4)
+#if defined(SUNOS4)
memset( (char *) dst, (int) val, (int) n );
#else
memset(dst, val, n);
*dst++ = val;
}
-/** Wrapper around either memcpy() or xf86memcpy() or bzero() */
+/** Wrapper around either memcpy() or bzero() */
void
_mesa_bzero( void *dst, size_t n )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86memset( dst, 0, n );
-#elif defined(__FreeBSD__)
+#if defined(__FreeBSD__)
bzero( dst, n );
#else
memset( dst, 0, n );
#endif
}
-/** Wrapper around either memcmp() or xf86memcmp() */
+/** Wrapper around memcmp() */
int
_mesa_memcmp( const void *s1, const void *s2, size_t n )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86memcmp( s1, s2, n );
-#elif defined(SUNOS4)
+#if defined(SUNOS4)
return memcmp( (char *) s1, (char *) s2, (int) n );
#else
return memcmp(s1, s2, n);
/** \name Math */
/*@{*/
-/** Wrapper around either sin() or xf86sin() */
+/** Wrapper around sin() */
double
_mesa_sin(double a)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86sin(a);
-#else
return sin(a);
-#endif
}
-/** Single precision wrapper around either sin() or xf86sin() */
+/** Single precision wrapper around sin() */
float
_mesa_sinf(float a)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return (float) xf86sin((double) a);
-#else
return (float) sin((double) a);
-#endif
}
-/** Wrapper around either cos() or xf86cos() */
+/** Wrapper around cos() */
double
_mesa_cos(double a)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86cos(a);
-#else
return cos(a);
-#endif
}
-/** Single precision wrapper around either asin() or xf86asin() */
+/** Single precision wrapper around asin() */
float
_mesa_asinf(float x)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return (float) xf86asin((double) x);
-#else
return (float) asin((double) x);
-#endif
}
-/** Single precision wrapper around either atan() or xf86atan() */
+/** Single precision wrapper around atan() */
float
_mesa_atanf(float x)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return (float) xf86atan((double) x);
-#else
return (float) atan((double) x);
-#endif
}
-/** Wrapper around either sqrt() or xf86sqrt() */
+/** Wrapper around sqrt() */
double
_mesa_sqrtd(double x)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86sqrt(x);
-#else
return sqrt(x);
-#endif
}
return x3 * r3;
#endif
-#elif defined(XFree86LOADER) && defined(IN_MODULE)
- return 1.0F / xf86sqrt(n);
#else
return (float) (1.0 / sqrt(n));
#endif
}
-/**
- * Wrapper around either pow() or xf86pow().
- */
+/** Wrapper around pow() */
double
_mesa_pow(double x, double y)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86pow(x, y);
-#else
return pow(x, y);
-#endif
}
}
}
return bit;
-#elif defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86ffs(i);
#else
return ffs(i);
#endif
_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *) )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86bsearch(key, base, nmemb, size, compar);
-#else
return bsearch(key, base, nmemb, size, compar);
-#endif
}
/*@}*/
char *
_mesa_getenv( const char *var )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86getenv(var);
-#elif defined(_XBOX)
+#if defined(_XBOX)
return NULL;
#else
return getenv(var);
/** \name String */
/*@{*/
-/** Wrapper around either strstr() or xf86strstr() */
+/** Wrapper around strstr() */
char *
_mesa_strstr( const char *haystack, const char *needle )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strstr(haystack, needle);
-#else
return strstr(haystack, needle);
-#endif
}
-/** Wrapper around either strncat() or xf86strncat() */
+/** Wrapper around strncat() */
char *
_mesa_strncat( char *dest, const char *src, size_t n )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strncat(dest, src, n);
-#else
return strncat(dest, src, n);
-#endif
}
-/** Wrapper around either strcpy() or xf86strcpy() */
+/** Wrapper around strcpy() */
char *
_mesa_strcpy( char *dest, const char *src )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strcpy(dest, src);
-#else
return strcpy(dest, src);
-#endif
}
-/** Wrapper around either strncpy() or xf86strncpy() */
+/** Wrapper around strncpy() */
char *
_mesa_strncpy( char *dest, const char *src, size_t n )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strncpy(dest, src, n);
-#else
return strncpy(dest, src, n);
-#endif
}
-/** Wrapper around either strlen() or xf86strlen() */
+/** Wrapper around strlen() */
size_t
_mesa_strlen( const char *s )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strlen(s);
-#else
return strlen(s);
-#endif
}
-/** Wrapper around either strcmp() or xf86strcmp() */
+/** Wrapper around strcmp() */
int
_mesa_strcmp( const char *s1, const char *s2 )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strcmp(s1, s2);
-#else
return strcmp(s1, s2);
-#endif
}
-/** Wrapper around either strncmp() or xf86strncmp() */
+/** Wrapper around strncmp() */
int
_mesa_strncmp( const char *s1, const char *s2, size_t n )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strncmp(s1, s2, n);
-#else
return strncmp(s1, s2, n);
-#endif
}
/** Implemented using _mesa_malloc() and _mesa_strcpy */
return s2;
}
-/** Wrapper around either atoi() or xf86atoi() */
+/** Wrapper around atoi() */
int
_mesa_atoi(const char *s)
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86atoi(s);
-#else
return atoi(s);
-#endif
}
-/** Wrapper around either strtod() or xf86strtod() */
+/** Wrapper around strtod() */
double
_mesa_strtod( const char *s, char **end )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strtod(s, end);
-#else
return strtod(s, end);
-#endif
}
/*@}*/
/** \name I/O */
/*@{*/
-/** Wrapper around either vsprintf() or xf86vsprintf() */
+/** Wrapper around vsprintf() */
int
_mesa_sprintf( char *str, const char *fmt, ... )
{
int r;
va_list args;
va_start( args, fmt );
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- r = xf86vsprintf( str, fmt, args );
-#else
r = vsprintf( str, fmt, args );
-#endif
va_end( args );
return r;
}
-/** Wrapper around either printf() or xf86printf(), using vsprintf() for
- * the formatting. */
+/** Wrapper around printf(), using vsprintf() for the formatting. */
void
_mesa_printf( const char *fmtString, ... )
{
va_start( args, fmtString );
vsnprintf(s, MAXSTRING, fmtString, args);
va_end( args );
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86printf("%s", s);
-#else
fprintf(stderr,"%s", s);
-#endif
}
-/** Wrapper around either vsprintf() or xf86vsprintf() */
+/** Wrapper around vsprintf() */
int
_mesa_vsprintf( char *str, const char *fmt, va_list args )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86vsprintf( str, fmt, args );
-#else
return vsprintf( str, fmt, args );
-#endif
}
/*@}*/
*
* If debugging is enabled (either at compile-time via the DEBUG macro, or
* run-time via the MESA_DEBUG environment variable), prints the warning to
- * stderr, either via fprintf() or xf86printf().
+ * stderr via fprintf().
*/
void
_mesa_warning( GLcontext *ctx, const char *fmtString, ... )
debug = _mesa_getenv("MESA_DEBUG") ? GL_TRUE : GL_FALSE;
#endif
if (debug) {
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86fprintf(stderr, "Mesa warning: %s\n", str);
-#else
fprintf(stderr, "Mesa warning: %s\n", str);
-#endif
}
}
* \param ctx GL context.
* \param s problem description string.
*
- * Prints the message to stderr, either via fprintf() or xf86fprintf().
+ * Prints the message to stderr via fprintf().
*/
void
_mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
vsnprintf( str, MAXSTRING, fmtString, args );
va_end( args );
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
- xf86fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
-#else
fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
-#endif
}
/**
* \param ctx GL context.
* \param fmtString printf() alike format string.
*
- * Prints the message to stderr, either via fprintf() or xf86printf().
+ * Prints the message to stderr via fprintf().
*/
void
_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
va_start(args, fmtString);
vsnprintf(s, MAXSTRING, fmtString, args);
va_end(args);
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86fprintf(stderr, "Mesa: %s", s);
-#else
fprintf(stderr, "Mesa: %s", s);
-#endif
#endif /* DEBUG */
(void) ctx;
(void) fmtString;
void
_mesa_exit( int status )
{
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- xf86exit(status);
-#else
exit(status);
-#endif
}
/*@}*/
return _mesa_calloc(numElem * elemSize);
}
-/** Wrapper around either realloc() or xf86realloc() */
+/** Wrapper around realloc() */
static void *
default_realloc(__GLcontext *gc, void *oldAddr, size_t newSize)
{
(void) gc;
-#if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86realloc(oldAddr, newSize);
-#else
return realloc(oldAddr, newSize);
-#endif
}
/** Wrapper around _mesa_free() */