]> mj.ucw.cz Git - libucw.git/blob - lib/config.h
f0ca96327ebba0fa89f16f837090d0cc8ff54b11
[libucw.git] / lib / config.h
1 /*
2  *      Sherlock -- Configuration-Dependent Definitions
3  *
4  *      (c) 1997--2004 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _SHERLOCK_CONFIG_H
11 #define _SHERLOCK_CONFIG_H
12
13 /* Configuration switches */
14
15 #include "lib/autoconf.h"
16
17 #ifdef CONFIG_MAX_CONTEXTS
18 #define CONFIG_CONTEXTS
19 #endif
20
21 /* Version */
22
23 #define SHER_VER SHERLOCK_VERSION SHERLOCK_VERSION_SUFFIX
24
25 /* Types */
26
27 typedef unsigned char byte;             /* exactly 8 bits, unsigned */
28 typedef signed char sbyte;              /* exactly 8 bits, signed */
29 typedef unsigned short word;            /* exactly 16 bits, unsigned */
30 typedef short sword;                    /* exactly 16 bits, signed */
31 typedef unsigned short u16;             /* exactly 16 bits, unsigned */
32 typedef short s16;                      /* exactly 16 bits, signed */
33 typedef unsigned int u32;               /* exactly 32 bits, unsigned */
34 typedef int s32;                        /* exactly 32 bits, signed */
35 typedef unsigned int uns;               /* at least 32 bits */
36 typedef unsigned long long int u64;     /* exactly 64 bits, unsigned */
37 typedef long long int s64;              /* exactly 64 bits, signed */
38 typedef unsigned long addr_int_t;       /* Both integer and address */
39 typedef unsigned int sh_time_t;         /* Timestamp */
40
41 #ifndef NULL
42 #define NULL (void *)0
43 #endif
44
45 typedef u32 oid_t;                      /* Object ID */
46
47 /* Data types and functions for accessing file positions */
48
49 #ifdef CONFIG_LARGE_DB
50 typedef s64 sh_off_t;
51 #define BYTES_PER_O 5
52 #define BYTES_PER_P 8
53 #define bgeto(f) bget5(f)
54 #define bputo(f,l) bput5(f,l)
55 #define bgetp(f) bgetq(f)
56 #define bputp(f,l) bputq(f,l)
57 #define GET_O(p) GET_U40(p)
58 #define GET_P(p) GET_U64(p)
59 #define PUT_O(p,x) PUT_U40(p,x)
60 #define PUT_P(p,x) PUT_U64(p,x)
61 #else
62 typedef s32 sh_off_t;
63 #define BYTES_PER_O 4
64 #define BYTES_PER_P 4
65 #define bgeto(f) bgetl(f)
66 #define bputo(f,l) bputl(f,l)
67 #define bgetp(f) bgetl(f)
68 #define bputp(f,l) bputl(f,l)
69 #define GET_O(p) GET_U32(p)
70 #define GET_P(p) GET_U32(p)
71 #define PUT_O(p,x) PUT_U32(p,x)
72 #define PUT_P(p,x) PUT_U32(p,x)
73 #endif
74
75 /* Data type for area ID's */
76
77 #ifdef CONFIG_AREAS
78 typedef u32 area_t;
79 #define AREA_NONE 0
80 #define AREA_ANY ~0U
81 #else
82 typedef struct { } area_t;
83 #define AREA_NONE (area_t){}
84 #define AREA_ANY (area_t){}
85 #endif
86
87 /* Misc */
88
89 #ifdef __GNUC__
90
91 #undef inline
92 #define NONRET __attribute__((noreturn))
93 #define UNUSED __attribute__((unused))
94 #define CONSTRUCTOR __attribute__((constructor))
95 #define PACKED __attribute__((packed))
96 #define CONST __attribute__((const))
97 #define PURE __attribute__((const))
98 #define likely(x) __builtin_expect((x),1)
99 #define unlikely(x) __builtin_expect((x),0)
100
101 #else
102 #error This program requires the GNU C compiler.
103 #endif
104
105 #endif