blob: 31070abdff0ab300120b596703d71c9b88ef3fd4 [file] [log] [blame]
Willy Tarreau43d8fb22011-08-22 17:12:02 +02001/*
2 * include/common/syscall.h
3 * Redefinition of some missing OS-specific system calls.
4 *
Willy Tarreau1bc4aab2012-10-08 20:11:03 +02005 * Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
Willy Tarreau43d8fb22011-08-22 17:12:02 +02006 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23
24#ifndef _COMMON_SYSCALL_H
25#define _COMMON_SYSCALL_H
26
27#ifdef __linux__
28
29#include <errno.h>
30#include <unistd.h>
31#include <sys/syscall.h>
32
33/* On Linux, _syscall macros were removed after 2.6.18, but we still prefer
34 * them because syscall() is buggy on old libcs. If _syscall is not defined,
35 * we're on a recent kernel with a recent libc and we should be safe, so we
36 * emulate is using syscall().
37 */
38#ifndef _syscall1
39#define _syscall1(tr, nr, t1, n1) \
Willy Tarreaucefad672014-05-08 22:36:29 +020040 tr nr(t1 n1) { \
Willy Tarreau43d8fb22011-08-22 17:12:02 +020041 return syscall(__NR_##nr, n1); \
42 }
43#endif
44
45#ifndef _syscall2
46#define _syscall2(tr, nr, t1, n1, t2, n2) \
Willy Tarreaucefad672014-05-08 22:36:29 +020047 tr nr(t1 n1, t2 n2) { \
Willy Tarreau43d8fb22011-08-22 17:12:02 +020048 return syscall(__NR_##nr, n1, n2); \
49 }
50#endif
51
52#ifndef _syscall3
53#define _syscall3(tr, nr, t1, n1, t2, n2, t3, n3) \
Willy Tarreaucefad672014-05-08 22:36:29 +020054 tr nr(t1 n1, t2 n2, t3 n3) { \
Willy Tarreau43d8fb22011-08-22 17:12:02 +020055 return syscall(__NR_##nr, n1, n2, n3); \
56 }
57#endif
58
59#ifndef _syscall4
60#define _syscall4(tr, nr, t1, n1, t2, n2, t3, n3, t4, n4) \
Willy Tarreaucefad672014-05-08 22:36:29 +020061 tr nr(t1 n1, t2 n2, t3 n3, t4 n4) { \
Willy Tarreau43d8fb22011-08-22 17:12:02 +020062 return syscall(__NR_##nr, n1, n2, n3, n4); \
63 }
64#endif
65
66#ifndef _syscall5
67#define _syscall5(tr, nr, t1, n1, t2, n2, t3, n3, t4, n4, t5, n5) \
Willy Tarreaucefad672014-05-08 22:36:29 +020068 tr nr(t1 n1, t2 n2, t3 n3, t4 n4, t5 n5) { \
Willy Tarreau43d8fb22011-08-22 17:12:02 +020069 return syscall(__NR_##nr, n1, n2, n3, n4, n5); \
70 }
71#endif
72
73#ifndef _syscall6
74#define _syscall6(tr, nr, t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6) \
Willy Tarreaucefad672014-05-08 22:36:29 +020075 tr nr(t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6) { \
Willy Tarreau43d8fb22011-08-22 17:12:02 +020076 return syscall(__NR_##nr, n1, n2, n3, n4, n5, n6); \
77 }
78#endif
79
80
81/* Define some syscall numbers that are sometimes needed */
82
Willy Tarreau43d8fb22011-08-22 17:12:02 +020083#endif /* __linux__ */
84#endif /* _COMMON_SYSCALL_H */
85
86/*
87 * Local variables:
88 * c-indent-level: 8
89 * c-basic-offset: 8
90 * End:
91 */