2 * Invoke a socket syscall, either directly or via __NR_socketcall.
4 * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <asm/unistd.h>
16 * Invoke a socket syscall, either directly or via __NR_socketcall.
17 * if nr == -1, no direct syscall invocation will be made.
20 socketcall(const int nr, const int call,
21 long a1, long a2, long a3, long a4, long a5)
26 # ifdef __NR_socketcall
27 static int have_socketcall = -1;
29 if (have_socketcall < 0) {
30 if (syscall(__NR_socketcall, 0L, 0L, 0L, 0L, 0L) < 0
38 if (have_socketcall) {
39 const long args[] = { a1, a2, a3, a4, a5 };
40 rc = syscall(__NR_socketcall, call, args);
45 rc = syscall(nr, a1, a2, a3, a4, a5);