OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [inet/] [socketcalls.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#define __FORCE_GLIBC
2
#include <features.h>
3
#include <errno.h>
4
#include <syscall.h>
5
#include <sys/socket.h>
6
 
7
#ifdef __NR_socketcall
8
extern int __socketcall(int call, unsigned long *args);
9
 
10
/* Various socketcall numbers */
11
#define SYS_SOCKET      1
12
#define SYS_BIND        2
13
#define SYS_CONNECT     3
14
#define SYS_LISTEN      4
15
#define SYS_ACCEPT      5
16
#define SYS_GETSOCKNAME 6
17
#define SYS_GETPEERNAME 7
18
#define SYS_SOCKETPAIR  8
19
#define SYS_SEND        9
20
#define SYS_RECV        10
21
#define SYS_SENDTO      11
22
#define SYS_RECVFROM    12
23
#define SYS_SHUTDOWN    13
24
#define SYS_SETSOCKOPT  14
25
#define SYS_GETSOCKOPT  15
26
#define SYS_SENDMSG     16
27
#define SYS_RECVMSG     17
28
#endif
29
 
30
 
31
#ifdef L_accept
32
#ifdef __NR_accept
33
#define __NR___libc_accept  __NR_accept
34
_syscall3(int, __libc_accept, int, call, struct sockaddr *, addr, socklen_t *,addrlen);
35
#else
36
int __libc_accept(int s, struct sockaddr *addr, socklen_t * addrlen)
37
{
38
        unsigned long args[3];
39
 
40
        args[0] = s;
41
        args[1] = (unsigned long) addr;
42
        args[2] = (unsigned long) addrlen;
43
        return __socketcall(SYS_ACCEPT, args);
44
}
45
#endif
46
weak_alias(__libc_accept, accept);
47
#endif
48
 
49
#ifdef L_bind
50
#ifdef __NR_bind
51
_syscall3(int, bind, int, sockfd, const struct sockaddr *, myaddr, socklen_t, addrlen);
52
#else
53
int bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen)
54
{
55
        unsigned long args[3];
56
 
57
        args[0] = sockfd;
58
        args[1] = (unsigned long) myaddr;
59
        args[2] = addrlen;
60
        return __socketcall(SYS_BIND, args);
61
}
62
#endif
63
#endif
64
 
65
#ifdef L_connect
66
#ifdef __NR_connect
67
#define __NR___libc_connect __NR_connect
68
_syscall3(int, __libc_connect, int, sockfd, const struct sockaddr *, saddr, socklen_t, addrlen);
69
#else
70
int __libc_connect(int sockfd, const struct sockaddr *saddr, socklen_t addrlen)
71
{
72
        unsigned long args[3];
73
 
74
        args[0] = sockfd;
75
        args[1] = (unsigned long) saddr;
76
        args[2] = addrlen;
77
        return __socketcall(SYS_CONNECT, args);
78
}
79
#endif
80
weak_alias(__libc_connect, connect);
81
#endif
82
 
83
#ifdef L_getpeername
84
#ifdef __NR_getpeername
85
_syscall3(int, getpeername, int, sockfd, struct sockaddr *, addr, socklen_t *,paddrlen);
86
#else
87
int getpeername(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
88
{
89
        unsigned long args[3];
90
 
91
        args[0] = sockfd;
92
        args[1] = (unsigned long) addr;
93
        args[2] = (unsigned long) paddrlen;
94
        return __socketcall(SYS_GETPEERNAME, args);
95
}
96
#endif
97
#endif
98
 
99
#ifdef L_getsockname
100
#ifdef __NR_getsockname
101
_syscall3(int, getsockname, int, sockfd, struct sockaddr *, addr, socklen_t *,paddrlen);
102
#else
103
int getsockname(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
104
{
105
        unsigned long args[3];
106
 
107
        args[0] = sockfd;
108
        args[1] = (unsigned long) addr;
109
        args[2] = (unsigned long) paddrlen;
110
        return __socketcall(SYS_GETSOCKNAME, args);
111
}
112
#endif
113
#endif
114
 
115
#ifdef L_getsockopt
116
#ifdef __NR_getsockopt
117
_syscall5(int, getsockopt, int, fd, int, level, int, optname, __ptr_t, optval, socklen_t *, optlen);
118
#else
119
int getsockopt(int fd, int level, int optname, __ptr_t optval,
120
                   socklen_t * optlen)
121
{
122
        unsigned long args[5];
123
 
124
        args[0] = fd;
125
        args[1] = level;
126
        args[2] = optname;
127
        args[3] = (unsigned long) optval;
128
        args[4] = (unsigned long) optlen;
129
        return (__socketcall(SYS_GETSOCKOPT, args));
130
}
131
#endif
132
#endif
133
 
134
#ifdef L_listen
135
#ifdef __NR_listen
136
_syscall2(int, listen, int, sockfd, int, backlog);
137
#else
138
int listen(int sockfd, int backlog)
139
{
140
        unsigned long args[2];
141
 
142
        args[0] = sockfd;
143
        args[1] = backlog;
144
        return __socketcall(SYS_LISTEN, args);
145
}
146
#endif
147
#endif
148
 
149
#ifdef L_recv
150
#ifdef __NR_recv
151
#define __NR___libc_recv __NR_recv
152
_syscall4(ssize_t, __libc_recv, int, sockfd, __ptr_t, buffer, size_t, len, int, flags);
153
#else
154
/* recv, recvfrom added by bir7@leland.stanford.edu */
155
ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags)
156
{
157
        unsigned long args[4];
158
 
159
        args[0] = sockfd;
160
        args[1] = (unsigned long) buffer;
161
        args[2] = len;
162
        args[3] = flags;
163
        return (__socketcall(SYS_RECV, args));
164
}
165
#endif
166
weak_alias(__libc_recv, recv);
167
#endif
168
 
169
#ifdef L_recvfrom
170
#ifdef __NR_recvfrom
171
#define __NR___libc_recvfrom __NR_recvfrom
172
_syscall6(ssize_t, __libc_recvfrom, int, sockfd, __ptr_t, buffer, size_t, len, int, flags,
173
        struct sockaddr *, to, socklen_t *, tolen);
174
#else
175
/* recv, recvfrom added by bir7@leland.stanford.edu */
176
ssize_t __libc_recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags,
177
                 struct sockaddr *to, socklen_t * tolen)
178
{
179
        unsigned long args[6];
180
 
181
        args[0] = sockfd;
182
        args[1] = (unsigned long) buffer;
183
        args[2] = len;
184
        args[3] = flags;
185
        args[4] = (unsigned long) to;
186
        args[5] = (unsigned long) tolen;
187
        return (__socketcall(SYS_RECVFROM, args));
188
}
189
#endif
190
weak_alias(__libc_recvfrom, recvfrom);
191
#endif
192
 
193
#ifdef L_recvmsg
194
#ifdef __NR_recvmsg
195
#define __NR___libc_recvmsg __NR_recvmsg
196
_syscall3(ssize_t, __libc_recvmsg, int, sockfd, struct msghdr *, msg, int, flags);
197
#else
198
ssize_t __libc_recvmsg(int sockfd, struct msghdr *msg, int flags)
199
{
200
        unsigned long args[3];
201
 
202
        args[0] = sockfd;
203
        args[1] = (unsigned long) msg;
204
        args[2] = flags;
205
        return (__socketcall(SYS_RECVMSG, args));
206
}
207
#endif
208
weak_alias(__libc_recvmsg, recvmsg);
209
#endif
210
 
211
#ifdef L_send
212
#ifdef __NR_send
213
#define __NR___libc_send    __NR_send
214
_syscall4(ssize_t, __libc_send, int, sockfd, const void *, buffer, size_t, len, int, flags);
215
#else
216
/* send, sendto added by bir7@leland.stanford.edu */
217
ssize_t __libc_send(int sockfd, const void *buffer, size_t len, int flags)
218
{
219
        unsigned long args[4];
220
 
221
        args[0] = sockfd;
222
        args[1] = (unsigned long) buffer;
223
        args[2] = len;
224
        args[3] = flags;
225
        return (__socketcall(SYS_SEND, args));
226
}
227
#endif
228
weak_alias(__libc_send, send);
229
#endif
230
 
231
#ifdef L_sendmsg
232
#ifdef __NR_sendmsg
233
#define __NR___libc_sendmsg __NR_sendmsg
234
_syscall3(ssize_t, __libc_sendmsg, int, sockfd, const struct msghdr *, msg, int, flags);
235
#else
236
ssize_t __libc_sendmsg(int sockfd, const struct msghdr *msg, int flags)
237
{
238
        unsigned long args[3];
239
 
240
        args[0] = sockfd;
241
        args[1] = (unsigned long) msg;
242
        args[2] = flags;
243
        return (__socketcall(SYS_SENDMSG, args));
244
}
245
#endif
246
weak_alias(__libc_sendmsg, sendmsg);
247
#endif
248
 
249
#ifdef L_sendto
250
#ifdef __NR_sendto
251
#define __NR___libc_sendto  __NR_sendto
252
_syscall6(ssize_t, __libc_sendto, int, sockfd, const void *, buffer, size_t, len,
253
        int, flags, const struct sockaddr *, to, socklen_t, tolen);
254
#else
255
/* send, sendto added by bir7@leland.stanford.edu */
256
ssize_t __libc_sendto(int sockfd, const void *buffer, size_t len, int flags,
257
           const struct sockaddr *to, socklen_t tolen)
258
{
259
        unsigned long args[6];
260
 
261
        args[0] = sockfd;
262
        args[1] = (unsigned long) buffer;
263
        args[2] = len;
264
        args[3] = flags;
265
        args[4] = (unsigned long) to;
266
        args[5] = tolen;
267
        return (__socketcall(SYS_SENDTO, args));
268
}
269
#endif
270
weak_alias(__libc_sendto, sendto);
271
#endif
272
 
273
#ifdef L_setsockopt
274
#ifdef __NR_setsockopt
275
_syscall5(int, setsockopt, int, fd, int, level, int, optname, const void *, optval, socklen_t, optlen);
276
#else
277
/* [sg]etsockoptions by bir7@leland.stanford.edu */
278
int setsockopt(int fd, int level, int optname, const void *optval,
279
                   socklen_t optlen)
280
{
281
        unsigned long args[5];
282
 
283
        args[0] = fd;
284
        args[1] = level;
285
        args[2] = optname;
286
        args[3] = (unsigned long) optval;
287
        args[4] = optlen;
288
        return (__socketcall(SYS_SETSOCKOPT, args));
289
}
290
#endif
291
#endif
292
 
293
#ifdef L_shutdown
294
#ifdef __NR_shutdown
295
_syscall2(int, shutdown, int, sockfd, int, how);
296
#else
297
/* shutdown by bir7@leland.stanford.edu */
298
int shutdown(int sockfd, int how)
299
{
300
        unsigned long args[2];
301
 
302
        args[0] = sockfd;
303
        args[1] = how;
304
        return (__socketcall(SYS_SHUTDOWN, args));
305
}
306
#endif
307
#endif
308
 
309
#ifdef L_socket
310
#ifdef __NR_socket
311
_syscall3(int, socket, int, family, int, type, int, protocol);
312
#else
313
int socket(int family, int type, int protocol)
314
{
315
        unsigned long args[3];
316
 
317
        args[0] = family;
318
        args[1] = type;
319
        args[2] = (unsigned long) protocol;
320
        return __socketcall(SYS_SOCKET, args);
321
}
322
#endif
323
#endif
324
 
325
#ifdef L_socketpair
326
#ifdef __NR_socketpair
327
_syscall4(int, socketpair, int, family, int, type, int, protocol, int *, sockvec);
328
#else
329
int socketpair(int family, int type, int protocol, int sockvec[2])
330
{
331
        unsigned long args[4];
332
 
333
        args[0] = family;
334
        args[1] = type;
335
        args[2] = protocol;
336
        args[3] = (unsigned long) sockvec;
337
        return __socketcall(SYS_SOCKETPAIR, args);
338
}
339
#endif
340
#endif
341
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.