You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

bits.h 1.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * $Id: bits.h,v 1.4 2005/06/14 22:41:51 mclark Exp $
  3. *
  4. * Copyright Metaparadigm Pte. Ltd. 2004.
  5. * Michael Clark <michael@metaparadigm.com>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public (LGPL)
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details: http://www.gnu.org/
  16. *
  17. */
  18. #ifndef _bits_h_
  19. #define _bits_h_
  20. #include "config.h"
  21. #if STDC_HEADERS
  22. # include <stddef.h>
  23. #endif /* STDC_HEADERS */
  24. /* CAW: wrapped in ifndef's to make win32 compliant
  25. ** this fails to take over GCC specifics, but this
  26. ** seems to be unimportant.
  27. */
  28. #ifndef min
  29. #define min(x,y) ({ \
  30. typeof(x) _x = (x); \
  31. typeof(y) _y = (y); \
  32. (void) (&_x == &_y); \
  33. _x < _y ? _x : _y; })
  34. #endif
  35. #ifndef max
  36. #define max(x,y) ({ \
  37. typeof(x) _x = (x); \
  38. typeof(y) _y = (y); \
  39. (void) (&_x == &_y); \
  40. _x > _y ? _x : _y; })
  41. #endif
  42. #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
  43. #define error_ptr(error) ((void*)error)
  44. #define is_error(ptr) ((ptrdiff_t)ptr < (ptrdiff_t)-4000L)
  45. #endif

No Description

Contributors (1)