edit
[c11concurrency-benchmarks.git] / iris / include / define.h
1 #ifndef IRIS_DEFINE_H_
2 #define IRIS_DEFINE_H_
3 #include <sys/uio.h>
4
5 namespace iris {
6
7 #define iris_likely(x) __builtin_expect(!!(long)(x), 1)
8 #define iris_unlikely(x) __builtin_expect(!!(long)(x), 0)
9
10 struct loglet_t {
11     // @pbuffer holds formatter function address and arguments
12     char                                  * rbuf_ptr;
13     size_t                                  rbuf_alloc_size;
14     loglet_t(char * ptr = nullptr, size_t alloc_size = 0):rbuf_ptr(ptr), rbuf_alloc_size(alloc_size) {}
15 };
16
17 #if defined(IOV_MAX) /* Linux x86 (glibc-2.3.6-3) */
18     #define MAX_IOVECS IOV_MAX
19 #elif defined(MAX_IOVEC) /* Linux ia64 (glibc-2.3.3-98.28) */
20     #define MAX_IOVECS MAX_IOVEC
21 #elif defined(UIO_MAXIOV) /* Linux x86 (glibc-2.2.5-233) */
22     #define MAX_IOVECS UIO_MAXIOV
23 #elif (defined(__FreeBSD__) && __FreeBSD_version < 500000) || defined(__DragonFly__) || defined(__APPLE__) 
24     /* - FreeBSD 4.x
25      * - MacOS X 10.3.x
26      *   (covered in -DKERNEL)
27      *  */
28     #define MAX_IOVECS 1024
29 #else
30     #error "can't deduce the maximum number of iovec in a readv/writev syscall"
31 #endif
32 }
33 #endif