diff options
author | Tim Terriberry <tterribe@xiph.org> | 2010-06-10 13:42:06 +0000 |
---|---|---|
committer | Tim Terriberry <tterribe@xiph.org> | 2010-06-10 13:42:06 +0000 |
commit | 5644fd0258d84381ed336ab4aec7a22599f152df (patch) | |
tree | 6933d1671a8404beac3d0de139c92f3a87fa72c3 | |
parent | 9d7706432a5045b77813f2573378b68de099194e (diff) | |
download | ogg-5644fd0258d84381ed336ab4aec7a22599f152df.tar.gz |
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.
git-svn-id: http://svn.xiph.org/trunk/ogg@17287 0101bb08-14d6-0310-b084-bc0e0c8e3800
-rw-r--r-- | include/ogg/os_types.h | 13 | ||||
-rw-r--r-- | src/bitwise.c | 5 |
2 files changed, 3 insertions, 15 deletions
diff --git a/include/ogg/os_types.h b/include/ogg/os_types.h index cefd04f..4d4315d 100644 --- a/include/ogg/os_types.h +++ b/include/ogg/os_types.h @@ -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__) diff --git a/src/bitwise.c b/src/bitwise.c index 7a57f55..a3593e4 100644 --- a/src/bitwise.c +++ b/src/bitwise.c @@ -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 @@ void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){ 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 @@ void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){ 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; |