Browse Source

simplify some expressions

master
Felix von Leitner 15 years ago
parent
commit
8d995360a6
  1. 6
      rangecheck.h

6
rangecheck.h

@ -75,13 +75,9 @@ int range_str4inbuf(const void* buf,size_t len,const void* stringstart);
#define __MIN_UNSIGNED(type) ((type)0)
#define __MIN_SIGNED(type) (((type)-1)<<(sizeof(type)*8-1))
#define __MAX_UNSIGNED(type) (((type)-1))
#define __MAX_SIGNED_TEMP(type) (((type)1)<<(sizeof(type)*8-2))
#define __MAX_SIGNED(type) (__MAX_SIGNED_TEMP(type)+(__MAX_SIGNED_TEMP(type)-1))
/* we use <1 and not <0 to avoid a gcc warning */
#define __MAX(type) ((type)-1 < 1?__MAX_SIGNED(type):__MAX_UNSIGNED(type))
#define __MIN(type) ((type)-1 < 1?__MIN_SIGNED(type):__MIN_UNSIGNED(type))
#define __MAX(type) ((type)~__MIN(type))
#define assign(dest,src) ({ typeof(src) __x=(src); typeof(dest) __y=__x; (__x==__y && ((__x<1) == (__y<1))?(int)((dest)=__y),0:1); })

Loading…
Cancel
Save