mesa: remove MSVC warning pragmas
[mesa.git] / src / mesa / main / imports.c
index 2c5f20d02ec70c339ef1544c81f321055887a659..ac8deeb97c983674c7cd5f14133efd41e53a1a1a 100644 (file)
@@ -42,8 +42,9 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-
-
+#include <stdio.h>
+#include <stdarg.h>
+#include "c99_math.h"
 #include "imports.h"
 #include "context.h"
 #include "mtypes.h"
@@ -92,7 +93,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
 #else
    uintptr_t ptr, buf;
 
-   ASSERT( alignment > 0 );
+   assert( alignment > 0 );
 
    ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *));
    if (!ptr)
@@ -141,7 +142,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
 #else
    uintptr_t ptr, buf;
 
-   ASSERT( alignment > 0 );
+   assert( alignment > 0 );
 
    ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *));
    if (!ptr)
@@ -217,7 +218,7 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
 /*@{*/
 
 
-#ifndef __GNUC__
+#ifndef HAVE___BUILTIN_FFS
 /**
  * Find the first bit set in a word.
  */
@@ -246,8 +247,9 @@ ffs(int i)
    }
    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!
@@ -271,11 +273,10 @@ ffsll(long long int val)
 
    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.
  */
@@ -288,7 +289,9 @@ _mesa_bitcount(unsigned int n)
    }
    return bits;
 }
+#endif
 
+#ifndef HAVE___BUILTIN_POPCOUNTLL
 /**
  * Return number of bits set in given 64-bit uint.
  */
@@ -474,63 +477,10 @@ _mesa_half_to_float(GLhalfARB val)
 /*@}*/
 
 
-/**********************************************************************/
-/** \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