1 /* ID for functions called via socketcall system call. 2 Copyright (C) 1995-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <https://www.gnu.org/licenses/>. */ 18 19 #ifndef _SYS_SOCKETCALL_H 20 #define _SYS_SOCKETCALL_H 1 21 22 #include <sysdep.h> 23 24 /* Define unique numbers for the operations permitted on socket. Linux 25 uses a single system call for all these functions. The relevant code 26 file is /usr/include/linux/net.h. 27 We cannot use an enum here because the values are used in assembler 28 code. */ 29 30 #define SOCKOP_invalid -1 31 #define SOCKOP_socket 1 32 #define SOCKOP_bind 2 33 #define SOCKOP_connect 3 34 #define SOCKOP_listen 4 35 #define SOCKOP_accept 5 36 #define SOCKOP_getsockname 6 37 #define SOCKOP_getpeername 7 38 #define SOCKOP_socketpair 8 39 #define SOCKOP_send 9 40 #define SOCKOP_recv 10 41 #define SOCKOP_sendto 11 42 #define SOCKOP_recvfrom 12 43 #define SOCKOP_shutdown 13 44 #define SOCKOP_setsockopt 14 45 #define SOCKOP_getsockopt 15 46 #define SOCKOP_sendmsg 16 47 #define SOCKOP_recvmsg 17 48 #define SOCKOP_accept4 18 49 #define SOCKOP_recvmmsg 19 50 #define SOCKOP_sendmmsg 20 51 52 #define __SOCKETCALL1(name, a1) \ 53 INLINE_SYSCALL (socketcall, 2, name, \ 54 ((long int [1]) { (long int) (a1) })) 55 #define __SOCKETCALL2(name, a1, a2) \ 56 INLINE_SYSCALL (socketcall, 2, name, \ 57 ((long int [2]) { (long int) (a1), (long int) (a2) })) 58 #define __SOCKETCALL3(name, a1, a2, a3) \ 59 INLINE_SYSCALL (socketcall, 2, name, \ 60 ((long int [3]) { (long int) (a1), (long int) (a2), (long int) (a3) })) 61 #define __SOCKETCALL4(name, a1, a2, a3, a4) \ 62 INLINE_SYSCALL (socketcall, 2, name, \ 63 ((long int [4]) { (long int) (a1), (long int) (a2), (long int) (a3), \ 64 (long int) (a4) })) 65 #define __SOCKETCALL5(name, a1, a2, a3, a4, a5) \ 66 INLINE_SYSCALL (socketcall, 2, name, \ 67 ((long int [5]) { (long int) (a1), (long int) (a2), (long int) (a3), \ 68 (long int) (a4), (long int) (a5) })) 69 #define __SOCKETCALL6(name, a1, a2, a3, a4, a5, a6) \ 70 INLINE_SYSCALL (socketcall, 2, name, \ 71 ((long int [6]) { (long int) (a1), (long int) (a2), (long int) (a3), \ 72 (long int) (a4), (long int) (a5), (long int) (a6) })) 73 74 #define __SOCKETCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n 75 #define __SOCKETCALL_NARGS(...) \ 76 __SOCKETCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,) 77 #define __SOCKETCALL_CONCAT_X(a,b) a##b 78 #define __SOCKETCALL_CONCAT(a,b) __SOCKETCALL_CONCAT_X (a, b) 79 #define __SOCKETCALL_DISP(b,...) \ 80 __SOCKETCALL_CONCAT (b,__SOCKETCALL_NARGS(__VA_ARGS__))(__VA_ARGS__) 81 82 #define __SOCKETCALL(...) __SOCKETCALL_DISP (__SOCKETCALL, __VA_ARGS__) 83 84 85 #define SOCKETCALL(name, args...) \ 86 ({ \ 87 long int sc_ret = __SOCKETCALL (SOCKOP_##name, args); \ 88 sc_ret; \ 89 }) 90 91 92 #define SOCKETCALL_CANCEL(name, args...) \ 93 ({ \ 94 int oldtype = LIBC_CANCEL_ASYNC (); \ 95 long int sc_ret = __SOCKETCALL (SOCKOP_##name, args); \ 96 LIBC_CANCEL_RESET (oldtype); \ 97 sc_ret; \ 98 }) 99 100 101 #endif /* sys/socketcall.h */ 102