[xiph-commits] r17287 - in trunk/ogg: include/ogg src

tterribe at svn.xiph.org tterribe at svn.xiph.org
Thu Jun 10 06:42:06 PDT 2010


Author: tterribe
Date: 2010-06-10 06:42:06 -0700 (Thu, 10 Jun 2010)
New Revision: 17287

Modified:
   trunk/ogg/include/ogg/os_types.h
   trunk/ogg/src/bitwise.c
Log:
The generic TYPE_MAX macros introduced in r17270 require the gcc typeof
 extension, which is not supported by MSVC.
We don't actually need that generality, though, so revert to simply using
 LONG_MAX instead.


Modified: trunk/ogg/include/ogg/os_types.h
===================================================================
--- trunk/ogg/include/ogg/os_types.h	2010-06-08 22:35:48 UTC (rev 17286)
+++ trunk/ogg/include/ogg/os_types.h	2010-06-10 13:42:06 UTC (rev 17287)
@@ -24,19 +24,6 @@
 #define _ogg_realloc realloc
 #define _ogg_free    free
 
-/* get non-brittle portable type-based MIN/MAX. Assumes 2's-complement
-   math */
-#define TYPE_HALF_MAX_SIGNED(type) \
-  ((typeof(type))1 << (sizeof(type)*8-2))
-#define TYPE_MAX_SIGNED(type) \
-  (TYPE_HALF_MAX_SIGNED(type) - 1 + TYPE_HALF_MAX_SIGNED(type))
-#define TYPE_MIN_SIGNED(type) \
-  (-1 - TYPE_MAX_SIGNED(type))
-#define TYPE_MIN(type) \
-  ((typeof(type))-1 < 1?TYPE_MIN_SIGNED(type):(typeof(type))0)
-#define TYPE_MAX(type) \
-  ((typeof(type))~TYPE_MIN(type))
-
 #if defined(_WIN32) 
 
 #  if defined(__CYGWIN__)

Modified: trunk/ogg/src/bitwise.c
===================================================================
--- trunk/ogg/src/bitwise.c	2010-06-08 22:35:48 UTC (rev 17286)
+++ trunk/ogg/src/bitwise.c	2010-06-10 13:42:06 UTC (rev 17287)
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <limits.h>
 #include <ogg/ogg.h>
 
 #define BUFFER_INCREMENT 256
@@ -84,7 +85,7 @@
   if(b->endbyte>=b->storage-4){
     void *ret;
     if(!b->ptr)return;
-    if(b->storage>TYPE_MAX(b->storage)-BUFFER_INCREMENT) goto err;
+    if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
     ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
     if(!ret) goto err;
     b->buffer=ret;
@@ -127,7 +128,7 @@
   if(b->endbyte>=b->storage-4){
     void *ret;
     if(!b->ptr)return;
-    if(b->storage>TYPE_MAX(b->storage)-BUFFER_INCREMENT) goto err;
+    if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
     ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
     if(!ret) goto err;
     b->buffer=ret;



More information about the commits mailing list