1 #include <sys/socket.h>
6 int socket(int domain
, int type
, int protocol
)
8 int s
= __socketcall(socket
, domain
, type
, protocol
, 0, 0, 0);
9 if ((s
==-EINVAL
|| s
==-EPROTONOSUPPORT
)
10 && (type
&(SOCK_CLOEXEC
|SOCK_NONBLOCK
))) {
11 s
= __socketcall(socket
, domain
,
12 type
& ~(SOCK_CLOEXEC
|SOCK_NONBLOCK
),
14 if (s
< 0) return __syscall_ret(s
);
15 if (type
& SOCK_CLOEXEC
)
16 __syscall(SYS_fcntl
, s
, F_SETFD
, FD_CLOEXEC
);
17 if (type
& SOCK_NONBLOCK
)
18 __syscall(SYS_fcntl
, s
, F_SETFL
, O_NONBLOCK
);
20 return __syscall_ret(s
);