Remove _mesa_strcmp in favor of plain strcmp.
[mesa.git] / src / mesa / main / imports.h
index 7d4012a85609b1addab2e0e2793d661f1a8d2802..867bce763ccaa3b4530fd435d703f68e4f909540 100644 (file)
@@ -405,6 +405,60 @@ _mesa_is_pow_two(int x)
    return !(x & (x - 1));
 }
 
+/**
+ * Round given integer to next higer power of two
+ * If X is zero result is undefined.
+ *
+ * Source for the fallback implementation is
+ * Sean Eron Anderson's webpage "Bit Twiddling Hacks"
+ * http://graphics.stanford.edu/~seander/bithacks.html
+ *
+ * When using builtin function have to do some work
+ * for case when passed values 1 to prevent hiting
+ * undefined result from __builtin_clz. Undefined
+ * results would be different depending on optimization
+ * level used for build.
+ */
+static INLINE int32_t
+_mesa_next_pow_two_32(uint32_t x)
+{
+#ifdef __GNUC__
+       uint32_t y = (x != 1);
+       return (1 + y) << ((__builtin_clz(x - y) ^ 31) );
+#else
+       x--;
+       x |= x >> 1;
+       x |= x >> 2;
+       x |= x >> 4;
+       x |= x >> 8;
+       x |= x >> 16;
+       x++;
+       return x;
+#endif
+}
+
+static INLINE int64_t
+_mesa_next_pow_two_64(uint64_t x)
+{
+#ifdef __GNUC__
+       uint64_t y = (x != 1);
+       if (sizeof(x) == sizeof(long))
+               return (1 + y) << ((__builtin_clzl(x - y) ^ 63));
+       else
+               return (1 + y) << ((__builtin_clzll(x - y) ^ 63));
+#else
+       x--;
+       x |= x >> 1;
+       x |= x >> 2;
+       x |= x >> 4;
+       x |= x >> 8;
+       x |= x >> 16;
+       x |= x >> 32;
+       x++;
+       return x;
+#endif
+}
+
 
 /***
  *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
@@ -557,24 +611,6 @@ _mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
 extern char *
 _mesa_getenv( const char *var );
 
-extern char *
-_mesa_strstr( const char *haystack, const char *needle );
-
-extern char *
-_mesa_strncat( char *dest, const char *src, size_t n );
-
-extern char *
-_mesa_strcpy( char *dest, const char *src );
-
-extern char *
-_mesa_strncpy( char *dest, const char *src, size_t n );
-
-extern size_t
-_mesa_strlen( const char *s );
-
-extern int
-_mesa_strcmp( const char *s1, const char *s2 );
-
 extern int
 _mesa_strncmp( const char *s1, const char *s2, size_t n );
 
@@ -618,10 +654,6 @@ _mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
 extern void
 _mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
 
-extern void 
-_mesa_exit( int status );
-
-
 #ifdef __cplusplus
 }
 #endif