1 #ifndef _INTERNAL_SYSCALL_H 2 #define _INTERNAL_SYSCALL_H 3 4 #include <features.h> 5 #include <sys/syscall.h> 6 #include "syscall_arch.h" 7 8 #ifndef SYSCALL_RLIM_INFINITY 9 #define SYSCALL_RLIM_INFINITY (~0ULL) 10 #endif 11 12 #ifndef SYSCALL_MMAP2_UNIT 13 #define SYSCALL_MMAP2_UNIT 4096ULL 14 #endif 15 16 #ifndef __SYSCALL_LL_PRW 17 #define __SYSCALL_LL_PRW(x) __SYSCALL_LL_O(x) 18 #endif 19 20 #ifndef __scc 21 #define __scc(X) ((long) (X)) 22 typedef long syscall_arg_t; 23 #endif 24 25 hidden long __syscall_ret(unsigned long), 26 __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t, 27 syscall_arg_t, syscall_arg_t, syscall_arg_t); 28 29 #define __syscall1(n,a) __syscall1(n,__scc(a)) 30 #define __syscall2(n,a,b) __syscall2(n,__scc(a),__scc(b)) 31 #define __syscall3(n,a,b,c) __syscall3(n,__scc(a),__scc(b),__scc(c)) 32 #define __syscall4(n,a,b,c,d) __syscall4(n,__scc(a),__scc(b),__scc(c),__scc(d)) 33 #define __syscall5(n,a,b,c,d,e) __syscall5(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e)) 34 #define __syscall6(n,a,b,c,d,e,f) __syscall6(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f)) 35 #define __syscall7(n,a,b,c,d,e,f,g) __syscall7(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g)) 36 37 #define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n 38 #define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,) 39 #define __SYSCALL_CONCAT_X(a,b) a##b 40 #define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b) 41 #define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__) 42 43 #define __syscall(...) __SYSCALL_DISP(__syscall,__VA_ARGS__) 44 #define syscall(...) __syscall_ret(__syscall(__VA_ARGS__)) 45 46 #define socketcall(nm,a,b,c,d,e,f) __syscall_ret(__socketcall(nm,a,b,c,d,e,f)) 47 #define socketcall_cp(nm,a,b,c,d,e,f) __syscall_ret(__socketcall_cp(nm,a,b,c,d,e,f)) 48 49 #define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0) 50 #define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0) 51 #define __syscall_cp2(n,a,b) (__syscall_cp)(n,__scc(a),__scc(b),0,0,0,0) 52 #define __syscall_cp3(n,a,b,c) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),0,0,0) 53 #define __syscall_cp4(n,a,b,c,d) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),0,0) 54 #define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),0) 55 #define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f)) 56 57 #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) 58 #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) 59 60 #ifndef SYSCALL_USE_SOCKETCALL 61 #define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_##nm, a, b, c, d, e, f) 62 #define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_##nm, a, b, c, d, e, f) 63 #else 64 #define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_socketcall, __SC_##nm, \ 65 ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) 66 #define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_socketcall, __SC_##nm, \ 67 ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) 68 #endif 69 70 /* fixup legacy 16-bit junk */ 71 72 #ifdef SYS_getuid32 73 #undef SYS_lchown 74 #undef SYS_getuid 75 #undef SYS_getgid 76 #undef SYS_geteuid 77 #undef SYS_getegid 78 #undef SYS_setreuid 79 #undef SYS_setregid 80 #undef SYS_getgroups 81 #undef SYS_setgroups 82 #undef SYS_fchown 83 #undef SYS_setresuid 84 #undef SYS_getresuid 85 #undef SYS_setresgid 86 #undef SYS_getresgid 87 #undef SYS_chown 88 #undef SYS_setuid 89 #undef SYS_setgid 90 #undef SYS_setfsuid 91 #undef SYS_setfsgid 92 #define SYS_lchown SYS_lchown32 93 #define SYS_getuid SYS_getuid32 94 #define SYS_getgid SYS_getgid32 95 #define SYS_geteuid SYS_geteuid32 96 #define SYS_getegid SYS_getegid32 97 #define SYS_setreuid SYS_setreuid32 98 #define SYS_setregid SYS_setregid32 99 #define SYS_getgroups SYS_getgroups32 100 #define SYS_setgroups SYS_setgroups32 101 #define SYS_fchown SYS_fchown32 102 #define SYS_setresuid SYS_setresuid32 103 #define SYS_getresuid SYS_getresuid32 104 #define SYS_setresgid SYS_setresgid32 105 #define SYS_getresgid SYS_getresgid32 106 #define SYS_chown SYS_chown32 107 #define SYS_setuid SYS_setuid32 108 #define SYS_setgid SYS_setgid32 109 #define SYS_setfsuid SYS_setfsuid32 110 #define SYS_setfsgid SYS_setfsgid32 111 #endif 112 113 114 /* fixup legacy 32-bit-vs-lfs64 junk */ 115 116 #ifdef SYS_fcntl64 117 #undef SYS_fcntl 118 #define SYS_fcntl SYS_fcntl64 119 #endif 120 121 #ifdef SYS_getdents64 122 #undef SYS_getdents 123 #define SYS_getdents SYS_getdents64 124 #endif 125 126 #ifdef SYS_ftruncate64 127 #undef SYS_ftruncate 128 #undef SYS_truncate 129 #define SYS_ftruncate SYS_ftruncate64 130 #define SYS_truncate SYS_truncate64 131 #endif 132 133 #ifdef SYS_stat64 134 #undef SYS_stat 135 #define SYS_stat SYS_stat64 136 #endif 137 138 #ifdef SYS_fstat64 139 #undef SYS_fstat 140 #define SYS_fstat SYS_fstat64 141 #endif 142 143 #ifdef SYS_lstat64 144 #undef SYS_lstat 145 #define SYS_lstat SYS_lstat64 146 #endif 147 148 #ifdef SYS_statfs64 149 #undef SYS_statfs 150 #define SYS_statfs SYS_statfs64 151 #endif 152 153 #ifdef SYS_fstatfs64 154 #undef SYS_fstatfs 155 #define SYS_fstatfs SYS_fstatfs64 156 #endif 157 158 #if defined(SYS_newfstatat) 159 #undef SYS_fstatat 160 #define SYS_fstatat SYS_newfstatat 161 #elif defined(SYS_fstatat64) 162 #undef SYS_fstatat 163 #define SYS_fstatat SYS_fstatat64 164 #endif 165 166 #ifdef SYS_ugetrlimit 167 #undef SYS_getrlimit 168 #define SYS_getrlimit SYS_ugetrlimit 169 #endif 170 171 #ifdef SYS__newselect 172 #undef SYS_select 173 #define SYS_select SYS__newselect 174 #endif 175 176 #ifdef SYS_pread64 177 #undef SYS_pread 178 #undef SYS_pwrite 179 #define SYS_pread SYS_pread64 180 #define SYS_pwrite SYS_pwrite64 181 #endif 182 183 #ifdef SYS_fadvise64_64 184 #undef SYS_fadvise 185 #define SYS_fadvise SYS_fadvise64_64 186 #elif defined(SYS_fadvise64) 187 #undef SYS_fadvise 188 #define SYS_fadvise SYS_fadvise64 189 #endif 190 191 #ifdef SYS_sendfile64 192 #undef SYS_sendfile 193 #define SYS_sendfile SYS_sendfile64 194 #endif 195 196 #ifndef SYS_timer_settime 197 #define SYS_timer_settime SYS_timer_settime32 198 #endif 199 200 #ifndef SYS_timer_gettime 201 #define SYS_timer_gettime SYS_timer_gettime32 202 #endif 203 204 #ifndef SYS_timerfd_settime 205 #define SYS_timerfd_settime SYS_timerfd_settime32 206 #endif 207 208 #ifndef SYS_timerfd_gettime 209 #define SYS_timerfd_gettime SYS_timerfd_gettime32 210 #endif 211 212 #ifndef SYS_clock_settime 213 #define SYS_clock_settime SYS_clock_settime32 214 #endif 215 216 #ifndef SYS_clock_gettime 217 #define SYS_clock_gettime SYS_clock_gettime32 218 #endif 219 220 #ifndef SYS_clock_getres 221 #define SYS_clock_getres SYS_clock_getres_time32 222 #endif 223 224 #ifndef SYS_clock_nanosleep 225 #define SYS_clock_nanosleep SYS_clock_nanosleep_time32 226 #endif 227 228 #ifndef SYS_gettimeofday 229 #define SYS_gettimeofday SYS_gettimeofday_time32 230 #endif 231 232 #ifndef SYS_settimeofday 233 #define SYS_settimeofday SYS_settimeofday_time32 234 #endif 235 236 /* Ensure that the plain syscall names are defined even for "time64-only" 237 * archs. These facilitate callers passing null time arguments, and make 238 * tests for establishing which to use/fallback-to more consistent when 239 * they do need to be called with time arguments. */ 240 241 #ifndef SYS_clock_gettime 242 #define SYS_clock_gettime SYS_clock_gettime64 243 #endif 244 245 #ifndef SYS_clock_settime 246 #define SYS_clock_settime SYS_clock_settime64 247 #endif 248 249 #ifndef SYS_clock_adjtime 250 #define SYS_clock_adjtime SYS_clock_adjtime64 251 #endif 252 253 #ifndef SYS_clock_getres 254 #define SYS_clock_getres SYS_clock_getres_time64 255 #endif 256 257 #ifndef SYS_clock_nanosleep 258 #define SYS_clock_nanosleep SYS_clock_nanosleep_time64 259 #endif 260 261 #ifndef SYS_timer_gettime 262 #define SYS_timer_gettime SYS_timer_gettime64 263 #endif 264 265 #ifndef SYS_timer_settime 266 #define SYS_timer_settime SYS_timer_settime64 267 #endif 268 269 #ifndef SYS_timerfd_gettime 270 #define SYS_timerfd_gettime SYS_timerfd_gettime64 271 #endif 272 273 #ifndef SYS_timerfd_settime 274 #define SYS_timerfd_settime SYS_timerfd_settime64 275 #endif 276 277 #ifndef SYS_utimensat 278 #define SYS_utimensat SYS_utimensat_time64 279 #endif 280 281 #ifndef SYS_pselect6 282 #define SYS_pselect6 SYS_pselect6_time64 283 #endif 284 285 #ifndef SYS_ppoll 286 #define SYS_ppoll SYS_ppoll_time64 287 #endif 288 289 #ifndef SYS_recvmmsg 290 #define SYS_recvmmsg SYS_recvmmsg_time64 291 #endif 292 293 #ifndef SYS_mq_timedsend 294 #define SYS_mq_timedsend SYS_mq_timedsend_time64 295 #endif 296 297 #ifndef SYS_mq_timedreceive 298 #define SYS_mq_timedreceive SYS_mq_timedreceive_time64 299 #endif 300 301 /* SYS_semtimedop omitted because SYS_ipc may provide it */ 302 303 #ifndef SYS_rt_sigtimedwait 304 #define SYS_rt_sigtimedwait SYS_rt_sigtimedwait_time64 305 #endif 306 307 #ifndef SYS_futex 308 #define SYS_futex SYS_futex_time64 309 #endif 310 311 #ifndef SYS_sched_rr_get_interval 312 #define SYS_sched_rr_get_interval SYS_sched_rr_get_interval_time64 313 #endif 314 315 316 317 318 /* socketcall calls */ 319 320 #define __SC_socket 1 321 #define __SC_bind 2 322 #define __SC_connect 3 323 #define __SC_listen 4 324 #define __SC_accept 5 325 #define __SC_getsockname 6 326 #define __SC_getpeername 7 327 #define __SC_socketpair 8 328 #define __SC_send 9 329 #define __SC_recv 10 330 #define __SC_sendto 11 331 #define __SC_recvfrom 12 332 #define __SC_shutdown 13 333 #define __SC_setsockopt 14 334 #define __SC_getsockopt 15 335 #define __SC_sendmsg 16 336 #define __SC_recvmsg 17 337 #define __SC_accept4 18 338 #define __SC_recvmmsg 19 339 #define __SC_sendmmsg 20 340 341 #ifndef SO_RCVTIMEO_OLD 342 #define SO_RCVTIMEO_OLD 20 343 #endif 344 #ifndef SO_SNDTIMEO_OLD 345 #define SO_SNDTIMEO_OLD 21 346 #endif 347 348 #define SO_TIMESTAMP_OLD 29 349 #define SO_TIMESTAMPNS_OLD 35 350 #define SO_TIMESTAMPING_OLD 37 351 #define SCM_TIMESTAMP_OLD SO_TIMESTAMP_OLD 352 #define SCM_TIMESTAMPNS_OLD SO_TIMESTAMPNS_OLD 353 #define SCM_TIMESTAMPING_OLD SO_TIMESTAMPING_OLD 354 355 #ifndef SIOCGSTAMP_OLD 356 #define SIOCGSTAMP_OLD 0x8906 357 #endif 358 #ifndef SIOCGSTAMPNS_OLD 359 #define SIOCGSTAMPNS_OLD 0x8907 360 #endif 361 362 #ifdef SYS_open 363 #define __sys_open2(x,pn,fl) __syscall2(SYS_open, pn, (fl)|O_LARGEFILE) 364 #define __sys_open3(x,pn,fl,mo) __syscall3(SYS_open, pn, (fl)|O_LARGEFILE, mo) 365 #define __sys_open_cp2(x,pn,fl) __syscall_cp2(SYS_open, pn, (fl)|O_LARGEFILE) 366 #define __sys_open_cp3(x,pn,fl,mo) __syscall_cp3(SYS_open, pn, (fl)|O_LARGEFILE, mo) 367 #else 368 #define __sys_open2(x,pn,fl) __syscall3(SYS_openat, AT_FDCWD, pn, (fl)|O_LARGEFILE) 369 #define __sys_open3(x,pn,fl,mo) __syscall4(SYS_openat, AT_FDCWD, pn, (fl)|O_LARGEFILE, mo) 370 #define __sys_open_cp2(x,pn,fl) __syscall_cp3(SYS_openat, AT_FDCWD, pn, (fl)|O_LARGEFILE) 371 #define __sys_open_cp3(x,pn,fl,mo) __syscall_cp4(SYS_openat, AT_FDCWD, pn, (fl)|O_LARGEFILE, mo) 372 #endif 373 374 #define __sys_open(...) __SYSCALL_DISP(__sys_open,,__VA_ARGS__) 375 #define sys_open(...) __syscall_ret(__sys_open(__VA_ARGS__)) 376 377 #define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp,,__VA_ARGS__) 378 #define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__)) 379 380 hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned); 381 382 hidden void *__vdsosym(const char *, const char *); 383 384 #endif 385