Merged revisions 195034,195219,195245,195357,195374,195428,195599,195673,195809 via...
[official-gcc.git] / main / libgo / runtime / go-nosys.c
blob3ab5ea235f23bba5f6067f784af95897a42bb8c0
1 /* go-nosys.c -- functions missing from system.
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. */
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. */
12 #include "config.h"
14 #include <errno.h>
15 #include <fcntl.h>
16 #include <math.h>
17 #include <stdint.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <sys/stat.h>
21 #include <sys/time.h>
22 #include <time.h>
23 #include <unistd.h>
25 #ifndef HAVE_OFF64_T
26 typedef signed int off64_t __attribute__ ((mode (DI)));
27 #endif
29 #ifndef HAVE_LOFF_T
30 typedef off64_t loff_t;
31 #endif
33 #ifndef HAVE_ACCEPT4
34 struct sockaddr;
35 int
36 accept4 (int sockfd __attribute__ ((unused)),
37 struct sockaddr *addr __attribute__ ((unused)),
38 socklen_t *addrlen __attribute__ ((unused)),
39 int flags __attribute__ ((unused)))
41 errno = ENOSYS;
42 return -1;
44 #endif
46 #ifndef HAVE_EPOLL_CREATE1
47 int
48 epoll_create1 (int flags __attribute__ ((unused)))
50 errno = ENOSYS;
51 return -1;
53 #endif
55 #ifndef HAVE_FACCESSAT
56 int
57 faccessat (int fd __attribute__ ((unused)),
58 const char *pathname __attribute__ ((unused)),
59 int mode __attribute__ ((unused)),
60 int flags __attribute__ ((unused)))
62 errno = ENOSYS;
63 return -1;
65 #endif
67 #ifndef HAVE_FALLOCATE
68 int
69 fallocate (int fd __attribute__ ((unused)),
70 int mode __attribute__ ((unused)),
71 off_t offset __attribute__ ((unused)),
72 off_t len __attribute__ ((unused)))
74 errno = ENOSYS;
75 return -1;
77 #endif
79 #ifndef HAVE_FCHMODAT
80 int
81 fchmodat (int dirfd __attribute__ ((unused)),
82 const char *pathname __attribute__ ((unused)),
83 mode_t mode __attribute__ ((unused)),
84 int flags __attribute__ ((unused)))
86 errno = ENOSYS;
87 return -1;
89 #endif
91 #ifndef HAVE_FCHOWNAT
92 int
93 fchownat (int dirfd __attribute__ ((unused)),
94 const char *pathname __attribute__ ((unused)),
95 uid_t owner __attribute__ ((unused)),
96 gid_t group __attribute__ ((unused)),
97 int flags __attribute__ ((unused)))
99 errno = ENOSYS;
100 return -1;
102 #endif
104 #ifndef HAVE_FUTIMESAT
106 futimesat (int dirfd __attribute__ ((unused)),
107 const char *pathname __attribute__ ((unused)),
108 const struct timeval times[2] __attribute__ ((unused)))
110 errno = ENOSYS;
111 return -1;
113 #endif
115 #ifndef HAVE_INOTIFY_ADD_WATCH
117 inotify_add_watch (int fd __attribute__ ((unused)),
118 const char* pathname __attribute__ ((unused)),
119 uint32_t mask __attribute__ ((unused)))
121 errno = ENOSYS;
122 return -1;
124 #endif
126 #ifndef HAVE_INOTIFY_INIT
128 inotify_init (void)
130 errno = ENOSYS;
131 return -1;
133 #endif
135 #ifndef HAVE_INOTIFY_INIT1
137 inotify_init1 (int flags __attribute__ ((unused)))
139 errno = ENOSYS;
140 return -1;
142 #endif
144 #ifndef HAVE_INOTIFY_RM_WATCH
146 inotify_rm_watch (int fd __attribute__ ((unused)),
147 uint32_t wd __attribute__ ((unused)))
149 errno = ENOSYS;
150 return -1;
152 #endif
154 #ifndef HAVE_MKDIRAT
156 mkdirat (int dirfd __attribute__ ((unused)),
157 const char *pathname __attribute__ ((unused)),
158 mode_t mode __attribute__ ((unused)))
160 errno = ENOSYS;
161 return -1;
163 #endif
165 #ifndef HAVE_MKNODAT
167 mknodat (int dirfd __attribute__ ((unused)),
168 const char *pathname __attribute__ ((unused)),
169 mode_t mode __attribute__ ((unused)),
170 dev_t dev __attribute__ ((unused)))
172 errno = ENOSYS;
173 return -1;
175 #endif
177 #ifndef HAVE_OPENAT
179 openat (int dirfd __attribute__ ((unused)),
180 const char *pathname __attribute__ ((unused)),
181 int oflag __attribute__ ((unused)),
182 ...)
184 errno = ENOSYS;
185 return -1;
187 #endif
189 #ifndef HAVE_PIPE2
191 pipe2 (int pipefd[2] __attribute__ ((unused)),
192 int flags __attribute__ ((unused)))
194 errno = ENOSYS;
195 return -1;
197 #endif
199 #ifndef HAVE_RENAMEAT
201 renameat (int olddirfd __attribute__ ((unused)),
202 const char *oldpath __attribute__ ((unused)),
203 int newdirfd __attribute__ ((unused)),
204 const char *newpath __attribute__ ((unused)))
206 errno = ENOSYS;
207 return -1;
209 #endif
211 #ifndef HAVE_SPLICE
213 splice (int fd __attribute__ ((unused)),
214 loff_t *off_in __attribute__ ((unused)),
215 int fd_out __attribute__ ((unused)),
216 loff_t *off_out __attribute__ ((unused)),
217 size_t len __attribute__ ((unused)),
218 unsigned int flags __attribute__ ((unused)))
220 errno = ENOSYS;
221 return -1;
223 #endif
225 #ifndef HAVE_SYNC_FILE_RANGE
227 sync_file_range (int fd __attribute__ ((unused)),
228 off64_t offset __attribute__ ((unused)),
229 off64_t nbytes __attribute__ ((unused)),
230 unsigned int flags __attribute__ ((unused)))
232 errno = ENOSYS;
233 return -1;
235 #endif
237 #ifndef HAVE_TEE
239 tee (int fd_in __attribute__ ((unused)),
240 int fd_out __attribute__ ((unused)),
241 size_t len __attribute__ ((unused)),
242 unsigned int flags __attribute__ ((unused)))
244 errno = ENOSYS;
245 return -1;
247 #endif
249 #ifndef HAVE_UNLINKAT
251 unlinkat (int dirfd __attribute__ ((unused)),
252 const char *pathname __attribute__ ((unused)),
253 int flags __attribute__ ((unused)))
255 errno = ENOSYS;
256 return -1;
258 #endif
260 #ifndef HAVE_UNSHARE
262 unshare (int flags __attribute__ ((unused)))
264 errno = ENOSYS;
265 return -1;
267 #endif
269 #ifndef HAVE_UTIMENSAT
270 struct timespec;
272 utimensat(int dirfd __attribute__ ((unused)),
273 const char *pathname __attribute__ ((unused)),
274 const struct timespec times[2] __attribute__ ((unused)),
275 int flags __attribute__ ((unused)))
277 errno = ENOSYS;
278 return -1;
280 #endif
282 /* Long double math functions. These are needed on old i386 systems
283 that don't have them in libm. The compiler translates calls to
284 these functions on float64 to call an 80-bit floating point
285 function instead, because when optimizing that function can be
286 executed as an x87 instructure. However, when not optimizing, this
287 translates into a call to the math function. So on systems that
288 don't provide these functions, we provide a version that just calls
289 the float64 version. */
291 #ifndef HAVE_COSL
292 long double
293 cosl (long double a)
295 return (long double) cos ((double) a);
297 #endif
299 #ifndef HAVE_EXPL
300 long double
301 expl (long double a)
303 return (long double) exp ((double) a);
305 #endif
307 #ifndef HAVE_LOGL
308 long double
309 logl (long double a)
311 return (long double) log ((double) a);
313 #endif
315 #ifndef HAVE_SINL
316 long double
317 sinl (long double a)
319 return (long double) sin ((double) a);
321 #endif
323 #ifndef HAVE_TANL
324 long double
325 tanl (long double a)
327 return (long double) tan ((double) a);
329 #endif
331 #ifndef HAVE_ACOSL
332 long double
333 acosl (long double a)
335 return (long double) acos ((double) a);
337 #endif
339 #ifndef HAVE_ASINL
340 long double
341 asinl (long double a)
343 return (long double) asin ((double) a);
345 #endif
347 #ifndef HAVE_ATANL
348 long double
349 atanl (long double a)
351 return (long double) atan ((double) a);
353 #endif
355 #ifndef HAVE_ATAN2L
356 long double
357 atan2l (long double a, long double b)
359 return (long double) atan2 ((double) a, (double) b);
361 #endif
363 #ifndef HAVE_EXPM1L
364 long double
365 expm1l (long double a)
367 return (long double) expm1 ((double) a);
369 #endif
371 #ifndef HAVE_LDEXPL
372 long double
373 ldexpl (long double a, int exp)
375 return (long double) ldexp ((double) a, exp);
377 #endif
379 #ifndef HAVE_LOG10L
380 long double
381 log10l (long double a)
383 return (long double) log10 ((double) a);
385 #endif
387 #ifndef HAVE_LOG1PL
388 long double
389 log1pl (long double a)
391 return (long double) log1p ((double) a);
393 #endif