| Michael Clark | f0d0888 | 2007-03-13 08:26:18 +0000 | [diff] [blame^] | 1 | /* | 
|  | 2 | * $Id: bits.h,v 1.3 2004/07/21 10:10:22 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 |  | 
|  | 19 | #ifndef _bits_h_ | 
|  | 20 | #define _bits_h_ | 
|  | 21 |  | 
|  | 22 | #define min(x,y) ({             \ | 
|  | 23 | typeof(x) _x = (x);     \ | 
|  | 24 | typeof(y) _y = (y);     \ | 
|  | 25 | (void) (&_x == &_y);    \ | 
|  | 26 | _x < _y ? _x : _y; }) | 
|  | 27 |  | 
|  | 28 | #define max(x,y) ({             \ | 
|  | 29 | typeof(x) _x = (x);     \ | 
|  | 30 | typeof(y) _y = (y);     \ | 
|  | 31 | (void) (&_x == &_y);    \ | 
|  | 32 | _x > _y ? _x : _y; }) | 
|  | 33 |  | 
|  | 34 | #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) | 
|  | 35 | #define error_ptr(error) ((void*)error) | 
|  | 36 | #define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L) | 
|  | 37 |  | 
|  | 38 | #endif |