summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/imports.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-09-19 20:12:32 +0000
committerBrian Paul <[email protected]>2005-09-19 20:12:32 +0000
commitb3aefd1cfb6aacd1695c52911dd39da50d893ece (patch)
tree247125551b41cc22dec6f1f03bb1d6709c804bba /src/mesa/main/imports.c
parenta01cb26a90aaa8f631c94d741617715dff89168c (diff)
additional wrapper updates, bug 4468
Diffstat (limited to 'src/mesa/main/imports.c')
-rw-r--r--src/mesa/main/imports.c81
1 files changed, 80 insertions, 1 deletions
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.
*/
@@ -685,6 +712,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
+}
+
/*@}*/
@@ -1036,6 +1095,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 */
/*@{*/