xref: /third_party/musl/src/network/accept4.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/network/
1570af302Sopenharmony_ci#define _GNU_SOURCE
2570af302Sopenharmony_ci#include <sys/socket.h>
3570af302Sopenharmony_ci#include <errno.h>
4570af302Sopenharmony_ci#include <fcntl.h>
5570af302Sopenharmony_ci#include "syscall.h"
6570af302Sopenharmony_ci
7570af302Sopenharmony_ciint accept4(int fd, struct sockaddr *restrict addr, socklen_t *restrict len, int flg)
8570af302Sopenharmony_ci{
9570af302Sopenharmony_ci	if (!flg) return accept(fd, addr, len);
10570af302Sopenharmony_ci	int ret = socketcall_cp(accept4, fd, addr, len, flg, 0, 0);
11570af302Sopenharmony_ci	if (ret>=0 || (errno != ENOSYS && errno != EINVAL)) return ret;
12570af302Sopenharmony_ci	ret = accept(fd, addr, len);
13570af302Sopenharmony_ci	if (ret<0) return ret;
14570af302Sopenharmony_ci	if (flg & SOCK_CLOEXEC)
15570af302Sopenharmony_ci		__syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
16570af302Sopenharmony_ci	if (flg & SOCK_NONBLOCK)
17570af302Sopenharmony_ci		__syscall(SYS_fcntl, ret, F_SETFL, O_NONBLOCK);
18570af302Sopenharmony_ci	return ret;
19570af302Sopenharmony_ci}
20

Indexes created Thu Nov 07 10:32:03 CST 2024