strace/tests/accept_compat.h
Eugene Syromyatnikov 46c6c7d776 tests: add compatibility layer for accept call
Recent glibc (since version 2.26) uses accept4 syscall for implementing
accept call on sparc.  Unfortunately, it's impossible to simply fall
back on raw syscall as it had not been wired up until linux commit
v4.4-rc8~4^2~1.

* tests/accept_compat.h: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/net-y-unix.c: Include accept_compat.h, use do_accept()
instead of accept() calls.
* tests/net-yy-inet.c: Likewise.
* tests/net-yy-unix.c: Likewise.
* tests/net.expected: Allow accept4.
2018-02-13 03:12:29 +00:00

26 lines
661 B
C

#ifndef _STRACE_TESTS_ACCEPT_COMPAT_H_
#define _STRACE_TESTS_ACCEPT_COMPAT_H_
#include <unistd.h>
#include <sys/socket.h>
#include <asm/unistd.h>
#if defined __NR_socketcall && defined __sparc__
/*
* Work around the fact that
* - glibc >= 2.26 uses accept4 syscall to implement accept() call on sparc;
* - accept syscall had not been wired up on sparc until v4.4-rc8~4^2~1.
*/
static inline int
do_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
const long args[] = { sockfd, (long) addr, (long) addrlen };
return syscall(__NR_socketcall, 5, args);
}
#else
# define do_accept accept
#endif
#endif /* !_STRACE_TESTS_ACCEPT_COMPAT_H_ */