Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 1 | /* |
Michael Clark | f6a6e48 | 2007-03-13 08:26:23 +0000 | [diff] [blame^] | 2 | * $Id: bits.h,v 1.9 2006/01/26 02:16:28 mclark Exp $ |
Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 3 | * |
Michael Clark | f6a6e48 | 2007-03-13 08:26:23 +0000 | [diff] [blame^] | 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. |
Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 5 | * Michael Clark <michael@metaparadigm.com> |
| 6 | * |
Michael Clark | f6a6e48 | 2007-03-13 08:26:23 +0000 | [diff] [blame^] | 7 | * This library is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the MIT license. See COPYING for details. |
Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef _bits_h_ |
| 13 | #define _bits_h_ |
| 14 | |
Michael Clark | 4504df7 | 2007-03-13 08:26:20 +0000 | [diff] [blame] | 15 | #include "config.h" |
| 16 | |
| 17 | #if STDC_HEADERS |
| 18 | # include <stddef.h> |
| 19 | #endif /* STDC_HEADERS */ |
| 20 | |
| 21 | /* CAW: wrapped in ifndef's to make win32 compliant |
| 22 | ** this fails to take over GCC specifics, but this |
| 23 | ** seems to be unimportant. |
| 24 | */ |
| 25 | |
| 26 | #ifndef min |
Michael Clark | f6a6e48 | 2007-03-13 08:26:23 +0000 | [diff] [blame^] | 27 | #define min(a,b) ((a) < (b) ? (a) : (b)) |
Michael Clark | 4504df7 | 2007-03-13 08:26:20 +0000 | [diff] [blame] | 28 | #endif |
Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 29 | |
Michael Clark | 4504df7 | 2007-03-13 08:26:20 +0000 | [diff] [blame] | 30 | #ifndef max |
Michael Clark | f6a6e48 | 2007-03-13 08:26:23 +0000 | [diff] [blame^] | 31 | #define max(a,b) ((a) > (b) ? (a) : (b)) |
Michael Clark | 4504df7 | 2007-03-13 08:26:20 +0000 | [diff] [blame] | 32 | #endif |
Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 33 | |
| 34 | #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) |
| 35 | #define error_ptr(error) ((void*)error) |
Michael Clark | 7b899b6 | 2007-03-13 08:26:21 +0000 | [diff] [blame] | 36 | #define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L) |
Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame] | 37 | |
| 38 | #endif |