Add unused attribute to declaration for mips16 builds.
[glibc.git] / include / sys / socket.h
blob2f4bfd3a9377d6dea299c44e6a6f08ea99ea8aa4
1 #ifndef _SYS_SOCKET_H
2 #include <socket/sys/socket.h>
4 #ifndef _ISOMAC
5 /* Now define the internal interfaces. */
7 /* Create a new socket of type TYPE in domain DOMAIN, using
8 protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
9 Returns a file descriptor for the new socket, or -1 for errors. */
10 extern int __socket (int __domain, int __type,
11 int __protocol);
12 libc_hidden_proto (__socket)
14 /* Create two new sockets, of type TYPE in domain DOMAIN and using
15 protocol PROTOCOL, which are connected to each other, and put file
16 descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
17 one will be chosen automatically. Returns 0 on success, -1 for errors. */
18 extern int __socketpair (int __domain, int __type, int __protocol,
19 int __fds[2]) attribute_hidden;
21 /* Return a socket of any type. The socket can be used in subsequent
22 ioctl calls to talk to the kernel. */
23 extern int __opensock (void) internal_function attribute_hidden;
25 /* Put the address of the peer connected to socket FD into *ADDR
26 (which is *LEN bytes long), and its actual length into *LEN. */
27 extern int __getpeername (int __fd, __SOCKADDR_ARG __addr,
28 socklen_t *__len) attribute_hidden;
30 /* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
31 extern ssize_t __libc_send (int __fd, const void *__buf, size_t __n,
32 int __flags);
33 extern ssize_t __send (int __fd, const void *__buf, size_t __n, int __flags);
34 libc_hidden_proto (__send)
36 /* Read N bytes into BUF from socket FD.
37 Returns the number read or -1 for errors. */
38 extern ssize_t __libc_recv (int __fd, void *__buf, size_t __n, int __flags);
40 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
41 ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
42 extern ssize_t __libc_sendto (int __fd, const void *__buf, size_t __n,
43 int __flags, __CONST_SOCKADDR_ARG __addr,
44 socklen_t __addr_len);
46 /* Read N bytes into BUF through socket FD.
47 If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
48 the sender, and store the actual size of the address in *ADDR_LEN.
49 Returns the number of bytes read or -1 for errors. */
50 extern ssize_t __libc_recvfrom (int __fd, void *__restrict __buf, size_t __n,
51 int __flags, __SOCKADDR_ARG __addr,
52 socklen_t *__restrict __addr_len);
54 /* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
55 For connectionless socket types, just set the default address to send to
56 and the only address from which to accept transmissions.
57 Return 0 on success, -1 for errors. */
58 extern int __libc_connect (int __fd, __CONST_SOCKADDR_ARG __addr,
59 socklen_t __len);
60 extern int __connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
61 libc_hidden_proto (__connect)
63 /* Read N bytes into BUF from socket FD.
64 Returns the number read or -1 for errors.
66 This function is a cancellation point and therefore not marked with
67 __THROW. */
68 extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags);
69 libc_hidden_proto (__recv)
71 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
72 ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
73 extern ssize_t __libc_sendto (int __fd, const void *__buf, size_t __n,
74 int __flags, __CONST_SOCKADDR_ARG __addr,
75 socklen_t __addr_len);
76 extern ssize_t __sendto (int __fd, const void *__buf, size_t __n,
77 int __flags, __CONST_SOCKADDR_ARG __addr,
78 socklen_t __addr_len) attribute_hidden;
80 /* Read N bytes into BUF through socket FD.
81 If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
82 the sender, and store the actual size of the address in *ADDR_LEN.
83 Returns the number of bytes read or -1 for errors. */
84 extern ssize_t __recvfrom (int __fd, void *__restrict __buf, size_t __n,
85 int __flags, __SOCKADDR_ARG __addr,
86 socklen_t *__restrict __addr_len) attribute_hidden;
88 /* Send a message described MESSAGE on socket FD.
89 Returns the number of bytes sent, or -1 for errors. */
90 extern ssize_t __libc_sendmsg (int __fd, const struct msghdr *__message,
91 int __flags);
92 extern ssize_t __sendmsg (int __fd, const struct msghdr *__message,
93 int __flags) attribute_hidden;
95 #ifdef __USE_GNU
96 extern int __sendmmsg (int __fd, struct mmsghdr *__vmessages,
97 unsigned int __vlen, int __flags);
98 libc_hidden_proto (__sendmmsg)
99 #endif
101 /* Receive a message as described by MESSAGE from socket FD.
102 Returns the number of bytes read or -1 for errors. */
103 extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message,
104 int __flags);
105 extern ssize_t __recvmsg (int __fd, struct msghdr *__message,
106 int __flags) attribute_hidden;
108 /* Set socket FD's option OPTNAME at protocol level LEVEL
109 to *OPTVAL (which is OPTLEN bytes long).
110 Returns 0 on success, -1 for errors. */
111 extern int __setsockopt (int __fd, int __level, int __optname,
112 const void *__optval,
113 socklen_t __optlen) attribute_hidden;
115 /* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
116 into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
117 actual length. Returns 0 on success, -1 for errors. */
118 extern int __getsockopt (int __fd, int __level, int __optname,
119 void *__restrict __optval,
120 socklen_t *__restrict __optlen) attribute_hidden;
122 /* Put the local address of FD into *ADDR and its length in *LEN. */
123 extern int __getsockname (int __fd, __SOCKADDR_ARG __addr,
124 socklen_t *__restrict __len) attribute_hidden;
126 /* Give the socket FD the local address ADDR (which is LEN bytes long). */
127 extern int __bind (int __fd, __CONST_SOCKADDR_ARG __addr,
128 socklen_t __len) attribute_hidden;
130 /* Prepare to accept connections on socket FD.
131 N connection requests will be queued before further requests are refused.
132 Returns 0 on success, -1 for errors. */
133 extern int __listen (int __fd, int __n) attribute_hidden;
135 /* Await a connection on socket FD.
136 When a connection arrives, open a new socket to communicate with it,
137 set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
138 peer and *ADDR_LEN to the address's actual length, and return the
139 new socket's descriptor, or -1 for errors. */
140 extern int __libc_accept (int __fd, __SOCKADDR_ARG __addr,
141 socklen_t *__restrict __addr_len)
142 __THROW attribute_hidden;
143 libc_hidden_proto (accept)
144 extern int __libc_accept4 (int __fd, __SOCKADDR_ARG __addr,
145 socklen_t *__restrict __addr_len, int __flags)
146 __THROW attribute_hidden;
148 /* Return the length of a `sockaddr' structure. */
149 #ifdef _HAVE_SA_LEN
150 # define SA_LEN(_x) (_x)->sa_len
151 #else
152 extern int __libc_sa_len (sa_family_t __af);
153 libc_hidden_proto (__libc_sa_len)
154 # define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
155 #endif
157 #ifdef SOCK_CLOEXEC
158 extern int __have_sock_cloexec attribute_hidden;
159 /* At lot of other functionality became available at the same time as
160 SOCK_CLOEXEC. Avoid defining separate variables for all of them
161 unless it is really necessary. */
162 # define __have_paccept __have_sock_cloexec
163 #endif
165 #endif
166 #endif