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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libpthread/] [linuxthreads/] [wrapsyscall.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
/* 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
#define __FORCE_GLIBC
22
#include <features.h>
23
#include <fcntl.h>
24
#include <sys/mman.h>
25
#include <pthread.h>
26
#include <unistd.h>
27
#include <stdarg.h>
28
#include <stddef.h>
29
#include <stdlib.h>
30
#include <termios.h>
31
#include <sys/resource.h>
32
#include <sys/wait.h>
33
#include <sys/socket.h>
34
#include <sys/syscall.h>
35
 
36
 
37
#ifndef __PIC__
38
/* We need a hook to force this file to be linked in when static
39
   libpthread is used.  */
40
const int __pthread_provide_wrappers = 0;
41
#endif
42
 
43
 
44
#define CANCELABLE_SYSCALL(res_type, name, param_list, params) \
45
res_type __libc_##name param_list;                                            \
46
res_type                                                                      \
47
__attribute__ ((weak))                                                        \
48
name param_list                                                               \
49
{                                                                             \
50
  res_type result;                                                            \
51
  int oldtype;                                                                \
52
  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);              \
53
  result = __libc_##name params;                                              \
54
  pthread_setcanceltype (oldtype, NULL);                                      \
55
  return result;                                                              \
56
}
57
 
58
#define CANCELABLE_SYSCALL_VA(res_type, name, param_list, params, last_arg) \
59
res_type __libc_##name param_list;                                            \
60
res_type                                                                      \
61
__attribute__ ((weak))                                                        \
62
name param_list                                                               \
63
{                                                                             \
64
  res_type result;                                                            \
65
  int oldtype;                                                                \
66
  va_list ap;                                                                 \
67
  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);              \
68
  va_start (ap, last_arg);                                                    \
69
  result = __libc_##name params;                                              \
70
  va_end (ap);                                                                \
71
  pthread_setcanceltype (oldtype, NULL);                                      \
72
  return result;                                                              \
73
}
74
 
75
 
76
/* close(2).  */
77
CANCELABLE_SYSCALL (int, close, (int fd), (fd))
78
 
79
 
80
/* fcntl(2).  */
81
CANCELABLE_SYSCALL_VA (int, fcntl, (int fd, int cmd, ...),
82
                       (fd, cmd, va_arg (ap, long int)), cmd)
83
 
84
 
85
/* fsync(2).  */
86
CANCELABLE_SYSCALL (int, fsync, (int fd), (fd))
87
 
88
 
89
/* lseek(2).  */
90
CANCELABLE_SYSCALL (off_t, lseek, (int fd, off_t offset, int whence),
91
                    (fd, offset, whence))
92
 
93
#ifdef __UCLIBC_HAS_LFS__
94
/* lseek64(2).  */
95
CANCELABLE_SYSCALL (off64_t, lseek64, (int fd, off64_t offset, int whence),
96
                    (fd, offset, whence))
97
#endif
98
 
99
/* msync(2).  */
100
CANCELABLE_SYSCALL (int, msync, (__ptr_t addr, size_t length, int flags),
101
                    (addr, length, flags))
102
 
103
 
104
/* nanosleep(2).  */
105
CANCELABLE_SYSCALL (int, nanosleep, (const struct timespec *requested_time,
106
                                     struct timespec *remaining),
107
                    (requested_time, remaining))
108
 
109
 
110
/* open(2).  */
111
CANCELABLE_SYSCALL_VA (int, open, (const char *pathname, int flags, ...),
112
                       (pathname, flags, va_arg (ap, mode_t)), flags)
113
 
114
 
115
#ifdef __UCLIBC_HAS_LFS__
116
/* open64(3).  */
117
CANCELABLE_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...),
118
                       (pathname, flags, va_arg (ap, mode_t)), flags)
119
#endif
120
 
121
/* pause(2).  */
122
CANCELABLE_SYSCALL (int, pause, (void), ())
123
 
124
 
125
/* Enable this if enabling these in syscalls.c */
126
/* pread(3).  */
127
CANCELABLE_SYSCALL (ssize_t, pread, (int fd, void *buf, size_t count,
128
                                     off_t offset),
129
                    (fd, buf, count, offset))
130
 
131
 
132
#if defined __UCLIBC_HAS_LFS__ && defined __NR_pread64
133
/* pread64(3).  */
134
CANCELABLE_SYSCALL (ssize_t, pread64, (int fd, void *buf, size_t count,
135
                                       off64_t offset),
136
                    (fd, buf, count, offset))
137
#endif
138
 
139
/* pwrite(3).  */
140
CANCELABLE_SYSCALL (ssize_t, pwrite, (int fd, const void *buf, size_t n,
141
                                      off_t offset),
142
                    (fd, buf, n, offset))
143
 
144
 
145
#if defined __UCLIBC_HAS_LFS__ && defined __NR_pwrited64
146
/* pwrite64(3).  */
147
CANCELABLE_SYSCALL (ssize_t, pwrite64, (int fd, const void *buf, size_t n,
148
                                        off64_t offset),
149
                    (fd, buf, n, offset))
150
#endif
151
 
152
/* read(2).  */
153
CANCELABLE_SYSCALL (ssize_t, read, (int fd, void *buf, size_t count),
154
                    (fd, buf, count))
155
 
156
 
157
/* system(3).  */
158
CANCELABLE_SYSCALL (int, system, (const char *line), (line))
159
 
160
 
161
/* tcdrain(2).  */
162
CANCELABLE_SYSCALL (int, tcdrain, (int fd), (fd))
163
 
164
 
165
/* wait(2).  */
166
CANCELABLE_SYSCALL (__pid_t, wait, (__WAIT_STATUS_DEFN stat_loc), (stat_loc))
167
 
168
 
169
/* waitpid(2).  */
170
CANCELABLE_SYSCALL (__pid_t, waitpid, (__pid_t pid, int *stat_loc,
171
                                       int options),
172
                    (pid, stat_loc, options))
173
 
174
 
175
/* write(2).  */
176
CANCELABLE_SYSCALL (ssize_t, write, (int fd, const void *buf, size_t n),
177
                    (fd, buf, n))
178
 
179
 
180
/* The following system calls are thread cancellation points specified
181
   in XNS.  */
182
 
183
/* accept(2).  */
184
CANCELABLE_SYSCALL (int, accept, (int fd, __SOCKADDR_ARG addr,
185
                                  socklen_t *addr_len),
186
                    (fd, addr, addr_len))
187
 
188
/* connect(2).  */
189
CANCELABLE_SYSCALL (int, connect, (int fd, __CONST_SOCKADDR_ARG addr,
190
                                     socklen_t len),
191
                    (fd, addr, len))
192
 
193
/* recv(2).  */
194
CANCELABLE_SYSCALL (ssize_t, recv, (int fd, __ptr_t buf, size_t n, int flags),
195
                    (fd, buf, n, flags))
196
 
197
/* recvfrom(2).  */
198
CANCELABLE_SYSCALL (ssize_t, recvfrom, (int fd, __ptr_t buf, size_t n, int flags,
199
                                        __SOCKADDR_ARG addr, socklen_t *addr_len),
200
                    (fd, buf, n, flags, addr, addr_len))
201
 
202
/* recvmsg(2).  */
203
CANCELABLE_SYSCALL (ssize_t, recvmsg, (int fd, struct msghdr *message, int flags),
204
                    (fd, message, flags))
205
 
206
/* send(2).  */
207
CANCELABLE_SYSCALL (ssize_t, send, (int fd, const __ptr_t buf, size_t n,
208
                                    int flags),
209
                    (fd, buf, n, flags))
210
 
211
/* sendmsg(2).  */
212
CANCELABLE_SYSCALL (ssize_t, sendmsg, (int fd, const struct msghdr *message,
213
                                       int flags),
214
                    (fd, message, flags))
215
 
216
/* sendto(2).  */
217
CANCELABLE_SYSCALL (ssize_t, sendto, (int fd, const __ptr_t buf, size_t n,
218
                                      int flags, __CONST_SOCKADDR_ARG addr,
219
                                      socklen_t addr_len),
220
                    (fd, buf, n, flags, addr, addr_len))

powered by: WebSVN 2.1.0

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