2 libcore: library for basic data structures and algorithms.
3 Copyright (C) 2005 IPD Goos, Universit"at Karlsruhe, Germany
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * Some common defines.
23 * @author Sebastian Hack
27 #ifndef _LIBCORE_DEFINES_H
28 #define _LIBCORE_DEFINES_H
30 #define LC_ARRSIZE(x) (sizeof(x) / sizeof(x[0]))
32 #define LC_MIN(x,y) ((x) < (y) ? (x) : (y))
33 #define LC_MAX(x,y) ((x) > (y) ? (x) : (y))
35 /** define a readable fourcc code */
36 #define LC_FOURCC(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
37 #define LC_FOURCC_STR(str) LC_FOURCC(str[0], str[1], str[2], str[3])
39 #define LC_OFFSETOF(type,memb) ((char *) &((type *) 0)->memb - (char *) 0)
42 #define LC_ALIGNOF(type) __alignof__(type)
44 #define LC_ALIGNOF(type) LC_OFFSETOF(struct { char c; type d; }, d)
47 #define LC_PTR2INT(x) (((char *)(x)) - (char *)0)
48 #define LC_INT2PTR(x) (((char *)(x)) + (char *)0)