Merge branch 'master' of https://github.com/resetius/elliptics
[elliptics.git] / include / elliptics / core.h
blob39c7f6a2e9c9a0e049e9115064221cb8e32d485e
1 /*
2 * 2008+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
3 * All rights reserved.
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
8 * (at your option) any later version.
10 * This program 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
13 * GNU General Public License for more details.
16 #ifndef __DNET_CORE_H
17 #define __DNET_CORE_H
19 #define DNET_HISTORY_SUFFIX ".history"
20 #define DNET_META_SUFFIX "\0meta"
22 #ifdef CONFIG_ID_SIZE
23 #define DNET_ID_SIZE CONFIG_ID_SIZE
24 #else
25 #define DNET_ID_SIZE 64
26 #endif
27 #define DNET_MAX_NAME_LEN 64
30 * Each read transaction reply is being split into
31 * chunks of this bytes max, thus reading transaction
32 * callback will be invoked multiple times.
34 #define DNET_MAX_TRANS_SIZE (1024*1024*10)
37 * When IO request is less than this constant,
38 * system copies data into contiguous block with headers
39 * and sends it using single syscall.
41 #define DNET_COPY_IO_SIZE 512
43 #ifndef HAVE_LARGEFILE_SUPPORT
44 #define O_LARGEFILE 0
45 #endif
47 #ifdef __GNUC__
48 #define DNET_LOG_CHECK __attribute__ ((format(printf, 3, 4)))
49 #else
50 #define DNET_LOG_CHECK
51 #endif
53 #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
54 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
57 * Default notify hash table size.
59 #define DNET_DEFAULT_NOTIFY_HASH_SIZE 256
62 * Default check timeout in seconds.
64 #define DNET_DEFAULT_CHECK_TIMEOUT_SEC 60
66 #define DNET_DEFAULT_STALL_TRANSACTIONS 5
68 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
70 #undef offsetof
71 #ifdef __compiler_offsetof
72 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
73 #else
74 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
75 #endif
77 /* checksum size, must be enough to store sha512 hash */
78 #define DNET_CSUM_SIZE 64
80 /* kernel (pohmelfs) provides own defines for byteorder changes */
81 #ifndef __KERNEL__
82 #ifdef WORDS_BIGENDIAN
84 #define dnet_bswap16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
86 #define dnet_bswap32(x) \
87 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
88 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
90 #define dnet_bswap64(x) \
91 ((((x) & 0xff00000000000000ull) >> 56) \
92 | (((x) & 0x00ff000000000000ull) >> 40) \
93 | (((x) & 0x0000ff0000000000ull) >> 24) \
94 | (((x) & 0x000000ff00000000ull) >> 8) \
95 | (((x) & 0x00000000ff000000ull) << 8) \
96 | (((x) & 0x0000000000ff0000ull) << 24) \
97 | (((x) & 0x000000000000ff00ull) << 40) \
98 | (((x) & 0x00000000000000ffull) << 56))
99 #else
100 #define dnet_bswap16(x) (x)
101 #define dnet_bswap32(x) (x)
102 #define dnet_bswap64(x) (x)
103 #endif
104 #endif
106 #endif /* __DNET_CORE_H */