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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-newlib/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [linuxthreads/] [wrapsyscall.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
/* Wrapper arpund system calls to provide cancelation points.
2
   Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
5
 
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Library General Public License as
8
   published by the Free Software Foundation; either version 2 of the
9
   License, or (at your option) any later version.
10
 
11
   The GNU C Library is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Library General Public License for more details.
15
 
16
   You should have received a copy of the GNU Library General Public
17
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
18
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
#include <fcntl.h>
22
#include <sys/mman.h>
23
#include <pthread.h>
24
#include <unistd.h>
25
#include <stdarg.h>
26
#include <stddef.h>
27
#include <stdlib.h>
28
#include <termios.h>
29
#include <sys/resource.h>
30
#include <sys/wait.h>
31
#include <sys/socket.h>
32
#include "libc-symbols.h"
33
 
34
 
35
#ifndef SHARED
36
/* We need a hook to force this file to be linked in when static
37
   libpthread is used.  */
38
const int __pthread_provide_wrappers = 0;
39
#endif
40
 
41
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2
42
#define ELIX_2_PLUS
43
#endif
44
 
45
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 3
46
#define ELIX_3_PLUS
47
#endif
48
 
49
#define CANCELABLE_SYSCALL(res_type, name, param_list, params) \
50
res_type __libc_##name param_list;                                            \
51
res_type                                                                      \
52
__attribute__ ((weak))                                                        \
53
name param_list                                                               \
54
{                                                                             \
55
  res_type result;                                                            \
56
  int oldtype;                                                                \
57
  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);              \
58
  result = __libc_##name params;                                              \
59
  pthread_setcanceltype (oldtype, NULL);                                      \
60
  return result;                                                              \
61
}
62
 
63
#define CANCELABLE_SYSCALL_VA(res_type, name, param_list, params, last_arg) \
64
res_type __libc_##name param_list;                                            \
65
res_type                                                                      \
66
__attribute__ ((weak))                                                        \
67
name param_list                                                               \
68
{                                                                             \
69
  res_type result;                                                            \
70
  int oldtype;                                                                \
71
  va_list ap;                                                                 \
72
  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);              \
73
  va_start (ap, last_arg);                                                    \
74
  result = __libc_##name params;                                              \
75
  va_end (ap);                                                                \
76
  pthread_setcanceltype (oldtype, NULL);                                      \
77
  return result;                                                              \
78
}
79
 
80
 
81
/* close(2).  */
82
CANCELABLE_SYSCALL (int, close, (int fd), (fd))
83
strong_alias (close, __close)
84
 
85
 
86
/* fcntl(2).  */
87
CANCELABLE_SYSCALL_VA (int, fcntl, (int fd, int cmd, ...),
88
                       (fd, cmd, va_arg (ap, long int)), cmd)
89
strong_alias (fcntl, __fcntl)
90
 
91
 
92
/* fsync(2).  */
93
CANCELABLE_SYSCALL (int, fsync, (int fd), (fd))
94
 
95
 
96
/* lseek(2).  */
97
CANCELABLE_SYSCALL (off_t, lseek, (int fd, off_t offset, int whence),
98
                    (fd, offset, whence))
99
strong_alias (lseek, __lseek)
100
 
101
 
102
#ifdef ELIX_2_PLUS
103
/* lseek64(2).  */
104
CANCELABLE_SYSCALL (loff_t, lseek64, (int fd, loff_t offset, int whence),
105
                    (fd, offset, whence))
106
#endif
107
 
108
 
109
/* msync(2).  */
110
CANCELABLE_SYSCALL (int, msync, (__ptr_t addr, size_t length, int flags),
111
                    (addr, length, flags))
112
 
113
 
114
/* nanosleep(2).  */
115
CANCELABLE_SYSCALL (int, nanosleep, (const struct timespec *requested_time,
116
                                     struct timespec *remaining),
117
                    (requested_time, remaining))
118
 
119
 
120
/* open(2).  */
121
CANCELABLE_SYSCALL_VA (int, open, (const char *pathname, int flags, ...),
122
                       (pathname, flags, va_arg (ap, int)), flags)
123
strong_alias (open, __open)
124
 
125
 
126
#ifdef ELIX_2_PLUS
127
/* open64(3).  */
128
CANCELABLE_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...),
129
                       (pathname, flags, va_arg (ap, int)), flags)
130
strong_alias (open64, __open64)
131
#endif
132
 
133
 
134
/* pause(2).  */
135
CANCELABLE_SYSCALL (int, pause, (void), ())
136
 
137
 
138
/* pread(3).  */
139
CANCELABLE_SYSCALL (ssize_t, pread, (int fd, void *buf, size_t count,
140
                                     off_t offset),
141
                    (fd, buf, count, offset))
142
 
143
 
144
#ifdef ELIX_2_PLUS
145
/* pread64(3).  */
146
CANCELABLE_SYSCALL (ssize_t, pread64, (int fd, void *buf, size_t count,
147
                                       loff_t offset),
148
                    (fd, buf, count, offset))
149
strong_alias (pread64, __pread64)
150
#endif
151
 
152
 
153
/* pwrite(3).  */
154
CANCELABLE_SYSCALL (ssize_t, pwrite, (int fd, const void *buf, size_t n,
155
                                      off_t offset),
156
                    (fd, buf, n, offset))
157
 
158
 
159
#ifdef ELIX_2_PLUS
160
/* pwrite64(3).  */
161
CANCELABLE_SYSCALL (ssize_t, pwrite64, (int fd, const void *buf, size_t n,
162
                                        loff_t offset),
163
                    (fd, buf, n, offset))
164
strong_alias (pwrite64, __pwrite64)
165
#endif
166
 
167
 
168
/* read(2).  */
169
CANCELABLE_SYSCALL (ssize_t, read, (int fd, void *buf, size_t count),
170
                    (fd, buf, count))
171
strong_alias (read, __read)
172
 
173
 
174
#ifdef ELIX_3_PLUS
175
/* system(3).  */
176
CANCELABLE_SYSCALL (int, system, (const char *line), (line))
177
#endif
178
 
179
 
180
/* tcdrain(2).  */
181
CANCELABLE_SYSCALL (int, tcdrain, (int fd), (fd))
182
 
183
 
184
#ifdef ELIX_3_PLUS
185
/* wait(2).  */
186
CANCELABLE_SYSCALL (__pid_t, wait, (int *stat_loc), (stat_loc))
187
strong_alias (wait, __wait)
188
#endif
189
 
190
 
191
#ifdef ELIX_3_PLUS
192
/* waitpid(2).  */
193
CANCELABLE_SYSCALL (__pid_t, waitpid, (__pid_t pid, int *stat_loc,
194
                                       int options),
195
                    (pid, stat_loc, options))
196
#endif
197
 
198
/* for libpthread usage */
199
CANCELABLE_SYSCALL (__pid_t, __waitpid, (__pid_t pid, int *stat_loc,
200
                                       int options),
201
                    (pid, stat_loc, options))
202
 
203
/* write(2).  */
204
CANCELABLE_SYSCALL (ssize_t, write, (int fd, const void *buf, size_t n),
205
                    (fd, buf, n))
206
strong_alias (write, __write)
207
 
208
 
209
/* The following system calls are thread cancellation points specified
210
   in XNS.  */
211
 
212
/* accept(2).  */
213
CANCELABLE_SYSCALL (int, accept, (int fd, __SOCKADDR_ARG addr,
214
                                  socklen_t *addr_len),
215
                    (fd, addr, addr_len))
216
 
217
/* connect(2).  */
218
CANCELABLE_SYSCALL (int, connect, (int fd, __CONST_SOCKADDR_ARG addr,
219
                                     socklen_t len),
220
                    (fd, addr, len))
221
strong_alias (connect, __connect)
222
 
223
/* recv(2).  */
224
CANCELABLE_SYSCALL (ssize_t, recv, (int fd, __ptr_t buf, size_t n, int flags),
225
                    (fd, buf, n, flags))
226
 
227
/* recvfrom(2).  */
228
CANCELABLE_SYSCALL (ssize_t, recvfrom, (int fd, __ptr_t buf, size_t n, int flags,
229
                                        __SOCKADDR_ARG addr, socklen_t *addr_len),
230
                    (fd, buf, n, flags, addr, addr_len))
231
 
232
/* recvmsg(2).  */
233
CANCELABLE_SYSCALL (ssize_t, recvmsg, (int fd, struct msghdr *message, int flags),
234
                    (fd, message, flags))
235
 
236
/* send(2).  */
237
CANCELABLE_SYSCALL (ssize_t, send, (int fd, const __ptr_t buf, size_t n,
238
                                    int flags),
239
                    (fd, buf, n, flags))
240
strong_alias (send, __send)
241
 
242
/* sendmsg(2).  */
243
CANCELABLE_SYSCALL (ssize_t, sendmsg, (int fd, const struct msghdr *message,
244
                                       int flags),
245
                    (fd, message, flags))
246
 
247
/* sendto(2).  */
248
CANCELABLE_SYSCALL (ssize_t, sendto, (int fd, const __ptr_t buf, size_t n,
249
                                      int flags, __CONST_SOCKADDR_ARG addr,
250
                                      socklen_t addr_len),
251
                    (fd, buf, n, flags, addr, addr_len))

powered by: WebSVN 2.1.0

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