OSDN Git Service

PR go/52358
[pf3gnuchains/gcc-fork.git] / libgo / runtime / go-nosys.c
1 /* go-nosys.c -- functions missing from system.
2
3    Copyright 2012 The Go Authors. All rights reserved.
4    Use of this source code is governed by a BSD-style
5    license that can be found in the LICENSE file.  */
6
7 /* This file exists to provide definitions for functions that are
8    missing from libc, according to the configure script.  This permits
9    the Go syscall package to not worry about whether the functions
10    exist or not.  */
11
12 #include "config.h"
13
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <math.h>
17 #include <stdint.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <sys/time.h>
21 #include <unistd.h>
22
23 #ifndef HAVE_OFF64_T
24 typedef signed int off64_t __attribute__ ((mode (DI)));
25 #endif
26
27 #ifndef HAVE_LOFF_T
28 typedef off64_t loff_t;
29 #endif
30
31 #ifndef HAVE_EPOLL_CREATE1
32 int
33 epoll_create1 (int flags __attribute__ ((unused)))
34 {
35   errno = ENOSYS;
36   return -1;
37 }
38 #endif
39
40 #ifndef HAVE_FACCESSAT
41 int
42 faccessat (int fd __attribute__ ((unused)),
43            const char *pathname __attribute__ ((unused)),
44            int mode __attribute__ ((unused)),
45            int flags __attribute__ ((unused)))
46 {
47   errno = ENOSYS;
48   return -1;
49 }
50 #endif
51
52 #ifndef HAVE_FALLOCATE
53 int
54 fallocate (int fd __attribute__ ((unused)),
55            int mode __attribute__ ((unused)),
56            off_t offset __attribute__ ((unused)),
57            off_t len __attribute__ ((unused)))
58 {
59   errno = ENOSYS;
60   return -1;
61 }
62 #endif
63
64 #ifndef HAVE_FCHMODAT
65 int
66 fchmodat (int dirfd __attribute__ ((unused)),
67           const char *pathname __attribute__ ((unused)),
68           mode_t mode __attribute__ ((unused)),
69           int flags __attribute__ ((unused)))
70 {
71   errno = ENOSYS;
72   return -1;
73 }
74 #endif
75
76 #ifndef HAVE_FCHOWNAT
77 int
78 fchownat (int dirfd __attribute__ ((unused)),
79           const char *pathname __attribute__ ((unused)),
80           uid_t owner __attribute__ ((unused)),
81           gid_t group __attribute__ ((unused)),
82           int flags __attribute__ ((unused)))
83 {
84   errno = ENOSYS;
85   return -1;
86 }
87 #endif
88
89 #ifndef HAVE_FUTIMESAT
90 int
91 futimesat (int dirfd __attribute__ ((unused)),
92            const char *pathname __attribute__ ((unused)),
93            const struct timeval times[2] __attribute__ ((unused)))
94 {
95   errno = ENOSYS;
96   return -1;
97 }
98 #endif
99
100 #ifndef HAVE_INOTIFY_ADD_WATCH
101 int
102 inotify_add_watch (int fd __attribute__ ((unused)),
103                    const char* pathname __attribute__ ((unused)),
104                    uint32_t mask __attribute__ ((unused)))
105 {
106   errno = ENOSYS;
107   return -1;
108 }
109 #endif
110
111 #ifndef HAVE_INOTIFY_INIT
112 int
113 inotify_init (void)
114 {
115   errno = ENOSYS;
116   return -1;
117 }
118 #endif
119
120 #ifndef HAVE_INOTIFY_INIT1
121 int
122 inotify_init1 (int flags __attribute__ ((unused)))
123 {
124   errno = ENOSYS;
125   return -1;
126 }
127 #endif
128
129 #ifndef HAVE_INOTIFY_RM_WATCH
130 int
131 inotify_rm_watch (int fd __attribute__ ((unused)),
132                   uint32_t wd __attribute__ ((unused)))
133 {
134   errno = ENOSYS;
135   return -1;
136 }
137 #endif
138
139 #ifndef HAVE_MKDIRAT
140 int
141 mkdirat (int dirfd __attribute__ ((unused)),
142          const char *pathname __attribute__ ((unused)),
143          mode_t mode __attribute__ ((unused)))
144 {
145   errno = ENOSYS;
146   return -1;
147 }
148 #endif
149
150 #ifndef HAVE_MKNODAT
151 int
152 mknodat (int dirfd __attribute__ ((unused)),
153          const char *pathname __attribute__ ((unused)),
154          mode_t mode __attribute__ ((unused)),
155          dev_t dev __attribute__ ((unused)))
156 {
157   errno = ENOSYS;
158   return -1;
159 }
160 #endif
161
162 #ifndef HAVE_OPENAT
163 int
164 openat (int dirfd __attribute__ ((unused)),
165         const char *pathname __attribute__ ((unused)),
166         int oflag __attribute__ ((unused)),
167         ...)
168 {
169   errno = ENOSYS;
170   return -1;
171 }
172 #endif
173
174 #ifndef HAVE_RENAMEAT
175 int
176 renameat (int olddirfd __attribute__ ((unused)),
177           const char *oldpath __attribute__ ((unused)),
178           int newdirfd __attribute__ ((unused)),
179           const char *newpath __attribute__ ((unused)))
180 {
181   errno = ENOSYS;
182   return -1;
183 }
184 #endif
185
186 #ifndef HAVE_SPLICE
187 int
188 splice (int fd __attribute__ ((unused)),
189         loff_t *off_in __attribute__ ((unused)),
190         int fd_out __attribute__ ((unused)),
191         loff_t *off_out __attribute__ ((unused)),
192         size_t len __attribute__ ((unused)),
193         unsigned int flags __attribute__ ((unused)))
194 {
195   errno = ENOSYS;
196   return -1;
197 }
198 #endif
199
200 #ifndef HAVE_SYNC_FILE_RANGE
201 int
202 sync_file_range (int fd __attribute__ ((unused)),
203                  off64_t offset __attribute__ ((unused)),
204                  off64_t nbytes __attribute__ ((unused)),
205                  unsigned int flags __attribute__ ((unused)))
206 {
207   errno = ENOSYS;
208   return -1;
209 }
210 #endif
211
212 #ifndef HAVE_TEE
213 int
214 tee (int fd_in __attribute__ ((unused)),
215      int fd_out __attribute__ ((unused)),
216      size_t len __attribute__ ((unused)),
217      unsigned int flags __attribute__ ((unused)))
218 {
219   errno = ENOSYS;
220   return -1;
221 }
222 #endif
223
224 #ifndef HAVE_UNLINKAT
225 int
226 unlinkat (int dirfd __attribute__ ((unused)),
227           const char *pathname __attribute__ ((unused)),
228           int flags __attribute__ ((unused)))
229 {
230   errno = ENOSYS;
231   return -1;
232 }
233 #endif
234
235 #ifndef HAVE_UNSHARE
236 int
237 unshare (int flags __attribute__ ((unused)))
238 {
239   errno = ENOSYS;
240   return -1;
241 }
242 #endif
243
244 /* Long double math functions.  These are needed on old i386 systems
245    that don't have them in libm.  The compiler translates calls to
246    these functions on float64 to call an 80-bit floating point
247    function instead, because when optimizing that function can be
248    executed as an x87 instructure.  However, when not optimizing, this
249    translates into a call to the math function.  So on systems that
250    don't provide these functions, we provide a version that just calls
251    the float64 version.  */
252
253 #ifndef HAVE_COSL
254 long double
255 cosl (long double a)
256 {
257   return (long double) cos ((double) a);
258 }
259 #endif
260
261 #ifndef HAVE_EXPL
262 long double
263 expl (long double a)
264 {
265   return (long double) exp ((double) a);
266 }
267 #endif
268
269 #ifndef HAVE_LOGL
270 long double
271 logl (long double a)
272 {
273   return (long double) log ((double) a);
274 }
275 #endif
276
277 #ifndef HAVE_SINL
278 long double
279 sinl (long double a)
280 {
281   return (long double) sin ((double) a);
282 }
283 #endif
284
285 #ifndef HAVE_TANL
286 long double
287 tanl (long double a)
288 {
289   return (long double) tan ((double) a);
290 }
291 #endif
292
293 #ifndef HAVE_ACOSL
294 long double
295 acosl (long double a)
296 {
297   return (long double) acos ((double) a);
298 }
299 #endif
300
301 #ifndef HAVE_ASINL
302 long double
303 asinl (long double a)
304 {
305   return (long double) asin ((double) a);
306 }
307 #endif
308
309 #ifndef HAVE_ATANL
310 long double
311 atanl (long double a)
312 {
313   return (long double) atan ((double) a);
314 }
315 #endif
316
317 #ifndef HAVE_ATAN2L
318 long double
319 atan2l (long double a, long double b)
320 {
321   return (long double) atan2 ((double) a, (double) b);
322 }
323 #endif
324
325 #ifndef HAVE_EXPM1L
326 long double
327 expm1l (long double a)
328 {
329   return (long double) expm1 ((double) a);
330 }
331 #endif
332
333 #ifndef HAVE_LDEXPL
334 long double
335 ldexpl (long double a, int exp)
336 {
337   return (long double) ldexp ((double) a, exp);
338 }
339 #endif
340
341 #ifndef HAVE_LOG10L
342 long double
343 log10l (long double a)
344 {
345   return (long double) log10 ((double) a);
346 }
347 #endif
348
349 #ifndef HAVE_LOG1PL
350 long double
351 log1pl (long double a)
352 {
353   return (long double) log1p ((double) a);
354 }
355 #endif