From b3aefd1cfb6aacd1695c52911dd39da50d893ece Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 19 Sep 2005 20:12:32 +0000 Subject: additional wrapper updates, bug 4468 --- src/mesa/main/imports.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (limited to 'src/mesa/main/imports.c') diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 8d39f77b410..f7d9de36697 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -23,7 +23,6 @@ * \todo Functions still needed: * - scanf * - qsort - * - bsearch * - rand and RAND_MAX * * \note When compiled into a XFree86 module these functions wrap around @@ -529,6 +528,34 @@ _mesa_pow(double x, double y) } +/* Windows does not have the ffs() function */ +#if defined(_WIN32) && !defined(__MINGW32__) +int INLINE ffs(int value) +{ + int bit; + if (value == 0) + return 0; + for (bit=1; !(value & 1); bit++) + value >>= 1; + return bit; +} +#endif + + +/** + * Wrapper around either ffs() or xf86ffs(). + */ +int +_mesa_ffs(int i) +{ +#if defined(XFree86LOADER) && defined(IN_MODULE) + return xf86ffs(i); +#else + return ffs(i); +#endif +} + + /** * Return number of bits set in given GLuint. */ @@ -684,6 +711,27 @@ _mesa_half_to_float(GLhalfARB val) /*@}*/ +/**********************************************************************/ +/** \name Sort & Search */ +/*@{*/ + +/** + * Wrapper for bsearch(). + */ +void * +_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 +} + +/*@}*/ + + /**********************************************************************/ /** \name Environment vars */ /*@{*/ @@ -860,6 +908,17 @@ _mesa_printf( const char *fmtString, ... ) #endif } +/** Wrapper around either vsprintf() or xf86vsprintf() */ +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 +} + /*@}*/ @@ -1035,6 +1094,26 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... ) /*@}*/ +/**********************************************************************/ +/** \name Exit */ +/*@{*/ + +/** + * Wrapper for exit(). + */ +void +_mesa_exit( int status ) +{ +#if defined(XFree86LOADER) && defined(IN_MODULE) + xf86exit(status); +#else + exit(status); +#endif +} + +/*@}*/ + + /**********************************************************************/ /** \name Default Imports Wrapper */ /*@{*/ -- cgit v1.2.3