2 * wrapping of libc features and kernel interfaces
4 * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef _UDEV_SYSDEPS_H_
22 #define _UDEV_SYSDEPS_H_
28 /* needed until Inotify! syscalls reach glibc */
29 #include <sys/syscall.h>
30 #ifndef __NR_inotify_init
32 # define __NR_inotify_init 291
33 # define __NR_inotify_add_watch 292
34 # define __NR_inotify_rm_watch 293
35 #elif defined(__x86_64__)
36 # define __NR_inotify_init 253
37 # define __NR_inotify_add_watch 254
38 # define __NR_inotify_rm_watch 255
39 #elif defined(__powerpc__) || defined(__powerpc64__)
40 # define __NR_inotify_init 275
41 # define __NR_inotify_add_watch 276
42 # define __NR_inotify_rm_watch 277
43 #elif defined (__ia64__)
44 # define __NR_inotify_init 1277
45 # define __NR_inotify_add_watch 1278
46 # define __NR_inotify_rm_watch 1279
47 #elif defined (__s390__)
48 # define __NR_inotify_init 284
49 # define __NR_inotify_add_watch 285
50 # define __NR_inotify_rm_watch 286
51 #elif defined (__alpha__)
52 # define __NR_inotify_init 444
53 # define __NR_inotify_add_watch 445
54 # define __NR_inotify_rm_watch 446
55 #elif defined (__sparc__) || defined (__sparc64__)
56 # define __NR_inotify_init 151
57 # define __NR_inotify_add_watch 152
58 # define __NR_inotify_rm_watch 156
59 #elif defined (__arm__)
60 # define __NR_inotify_init __NR_SYSCALL_BASE+316
61 # define __NR_inotify_add_watch __NR_SYSCALL_BASE+317
62 # define __NR_inotify_rm_watch __NR_SYSCALL_BASE+318
63 #elif defined (__sh__)
64 # define __NR_inotify_init 290
65 # define __NR_inotify_add_watch 291
66 # define __NR_inotify_rm_watch 292
67 #elif defined (__m32r__)
68 # define __NR_inotify_init 290
69 # define __NR_inotify_add_watch 291
70 # define __NR_inotify_rm_watch 292
71 #elif defined (__hppa__)
72 # define __NR_inotify_init 269
73 # define __NR_inotify_add_watch 270
74 # define __NR_inotify_rm_watch 271
75 #elif defined (__mips__)
77 # if _MIPS_SIM == _MIPS_SIM_ABI32
78 # define __NR_Linux 4000
79 # define __NR_inotify_init (__NR_Linux + 284)
80 # define __NR_inotify_add_watch (__NR_Linux + 285)
81 # define __NR_inotify_rm_watch (__NR_Linux + 286)
82 # elif _MIPS_SIM == _MIPS_SIM_ABI64
83 # define __NR_Linux 5000
84 # define __NR_inotify_init (__NR_Linux + 243)
85 # define __NR_inotify_add_watch (__NR_Linux + 244)
86 # define __NR_inotify_rm_watch (__NR_Linux + 245)
87 # elif _MIPS_SIM == _MIPS_SIM_NABI32
88 # define __NR_Linux 6000
89 # define __NR_inotify_init (__NR_Linux + 247)
90 # define __NR_inotify_add_watch (__NR_Linux + 248)
91 # define __NR_inotify_rm_watch (__NR_Linux + 249)
94 #warning "inotify unsupported on this architecture!"
96 #endif /* __NR_inotify_init */
98 /* dummy if we don't have the syscalls defined */
99 #ifndef __NR_inotify_init
100 static inline int inotify_init(void)
105 static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
110 /* needed until /usr/include/sys/inotify.h is working */
112 #include <sys/inotify.h>
114 static inline int inotify_init(void)
116 return syscall(__NR_inotify_init);
119 static inline int inotify_add_watch(int fd, const char *name, uint32_t mask)
121 return syscall(__NR_inotify_add_watch, fd, name, mask);
123 #endif /* __GLIBC__ */
124 #endif /* __NR_inotify_init */
127 #define IN_CREATE 0x00000100 /* Subfile was created */
128 #define IN_MOVED_FROM 0x00000040 /* File was moved from X */
129 #define IN_MOVED_TO 0x00000080 /* File was moved to Y */
130 #define IN_DELETE 0x00000200 /* Subfile was deleted */
131 #define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
132 #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
133 #endif /* IN_CREATE */
135 /* needed for our signal handlers to work */
138 #define asmlinkage __attribute__((regparm(0)))
141 #endif /* __i386__ */
143 /* headers are broken on some architectures */
145 #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
148 #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
151 #define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0)
154 #define __FD_ZERO(set) ((void) memset ((void*) (set), 0, sizeof (fd_set)))
157 #ifndef NETLINK_KOBJECT_UEVENT
158 #define NETLINK_KOBJECT_UEVENT 15
161 #ifndef SO_RCVBUFFORCE
162 #if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || defined(__sparc_v9__)
163 #define SO_RCVBUFFORCE 0x100b
165 #define SO_RCVBUFFORCE 33
169 extern size_t strlcpy(char *dst, const char *src, size_t size);
170 extern size_t strlcat(char *dst, const char *src, size_t size);