3 * Copyright (C) 2000-2002 Simone Piccardi
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * Endianess conversion for int and short types
22 #define BE32_TO_LE32(val) ({typeof (val) v= (val); \
23 (v>>24) | ((v>>8)&0xFF00) | (v<<24) | ((v<<8)&0xFF0000); } )
24 #define BE16_TO_LE16(val) ({typeof (val) v= (val); (v>>8) | (v<<8); } )
26 * Define a protected, right typed, no side effects macro for min and max
28 #define min(x, y) ({typeof (x) x_ = (x); typeof (y) y_ = (y); \
30 #define max(x, y) ({typeof (x) x_ = (x); typeof (y) y_ = (y); \
33 * debugging print definition
36 #define report(fmt, args...) UserNotify(fmt,##args)
38 #define report(fmt, args...) printf(fmt,##args)
39 #endif /* IS_DAEMON */
41 #ifdef DEBUG /* done only on debugging */
44 #define debug(fmt, arg...)
49 * Just to print an hex dump of a buffer,
50 * ptr is the address, m is how many word per line
51 * and l how many lines
53 #define PRINT_BUF(ptr, l, m) ({ \
55 unsigned short *_ptr= (unsigned short *)(ptr); \
56 for (_i = 0; _i< (int) l; _i++) { \
57 printf("Val[%d]=", m * _i); \
58 for (_j = 0; _j < (int) m; _j++) { \
59 printf("%x ", *_ptr);\