aboutsummaryrefslogtreecommitdiffstats
path: root/include/internal.h
blob: ee420ad39dd12ae3507e59a56cdd4d947809029c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef INTERNAL_H
#define INTERNAL_H

/* low level operations, not intended for API use */

#define check(str)	 \
	if (ret == -1) { \
		perror(str); \
		fprintf(stderr,	\
			"Warning: Could not initialize LITMUS^RT, " \
			"%s failed.\n",	str			    \
			); \
	}


/* taken from the kernel */

#define likely(x)   __builtin_expect((x), 1)
#define unlikely(x) __builtin_expect((x), 0)

#define offsetof(s, x) __builtin_offsetof(s, x)

#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))

/* I/O convenience function */
ssize_t read_file(const char* fname, void* buf, size_t maxlen);

long litmus_syscall(litmus_syscall_id_t syscall, unsigned long arg);

#endif