PR target/60017
[official-gcc.git] / libgo / runtime / go-nosys.c
blob0a94de0523e1bf8500db316657ecfbce24260ef8
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_DUP3
47 int
48 dup3 (int oldfd __attribute__ ((unused)),
49 int newfd __attribute__ ((unused)),
50 int flags __attribute__ ((unused)))
52 errno = ENOSYS;
53 return -1;
55 #endif
57 #ifndef HAVE_EPOLL_CREATE1
58 int
59 epoll_create1 (int flags __attribute__ ((unused)))
61 errno = ENOSYS;
62 return -1;
64 #endif
66 #ifndef HAVE_FACCESSAT
67 int
68 faccessat (int fd __attribute__ ((unused)),
69 const char *pathname __attribute__ ((unused)),
70 int mode __attribute__ ((unused)),
71 int flags __attribute__ ((unused)))
73 errno = ENOSYS;
74 return -1;
76 #endif
78 #ifndef HAVE_FALLOCATE
79 int
80 fallocate (int fd __attribute__ ((unused)),
81 int mode __attribute__ ((unused)),
82 off_t offset __attribute__ ((unused)),
83 off_t len __attribute__ ((unused)))
85 errno = ENOSYS;
86 return -1;
88 #endif
90 #ifndef HAVE_FCHMODAT
91 int
92 fchmodat (int dirfd __attribute__ ((unused)),
93 const char *pathname __attribute__ ((unused)),
94 mode_t mode __attribute__ ((unused)),
95 int flags __attribute__ ((unused)))
97 errno = ENOSYS;
98 return -1;
100 #endif
102 #ifndef HAVE_FCHOWNAT
104 fchownat (int dirfd __attribute__ ((unused)),
105 const char *pathname __attribute__ ((unused)),
106 uid_t owner __attribute__ ((unused)),
107 gid_t group __attribute__ ((unused)),
108 int flags __attribute__ ((unused)))
110 errno = ENOSYS;
111 return -1;
113 #endif
115 #ifndef HAVE_FUTIMESAT
117 futimesat (int dirfd __attribute__ ((unused)),
118 const char *pathname __attribute__ ((unused)),
119 const struct timeval times[2] __attribute__ ((unused)))
121 errno = ENOSYS;
122 return -1;
124 #endif
126 #ifndef HAVE_GETXATTR
127 ssize_t
128 getxattr (const char *path __attribute__ ((unused)),
129 const char *name __attribute__ ((unused)),
130 void *value __attribute__ ((unused)),
131 size_t size __attribute__ ((unused)))
133 errno = ENOSYS;
134 return -1;
136 #endif
138 #ifndef HAVE_INOTIFY_ADD_WATCH
140 inotify_add_watch (int fd __attribute__ ((unused)),
141 const char* pathname __attribute__ ((unused)),
142 uint32_t mask __attribute__ ((unused)))
144 errno = ENOSYS;
145 return -1;
147 #endif
149 #ifndef HAVE_INOTIFY_INIT
151 inotify_init (void)
153 errno = ENOSYS;
154 return -1;
156 #endif
158 #ifndef HAVE_INOTIFY_INIT1
160 inotify_init1 (int flags __attribute__ ((unused)))
162 errno = ENOSYS;
163 return -1;
165 #endif
167 #ifndef HAVE_INOTIFY_RM_WATCH
169 inotify_rm_watch (int fd __attribute__ ((unused)),
170 uint32_t wd __attribute__ ((unused)))
172 errno = ENOSYS;
173 return -1;
175 #endif
177 #ifndef HAVE_LISTXATTR
178 ssize_t
179 listxattr (const char *path __attribute__ ((unused)),
180 char *list __attribute__ ((unused)),
181 size_t size __attribute__ ((unused)))
183 errno = ENOSYS;
184 return -1;
186 #endif
188 #ifndef HAVE_MKDIRAT
190 mkdirat (int dirfd __attribute__ ((unused)),
191 const char *pathname __attribute__ ((unused)),
192 mode_t mode __attribute__ ((unused)))
194 errno = ENOSYS;
195 return -1;
197 #endif
199 #ifndef HAVE_MKNODAT
201 mknodat (int dirfd __attribute__ ((unused)),
202 const char *pathname __attribute__ ((unused)),
203 mode_t mode __attribute__ ((unused)),
204 dev_t dev __attribute__ ((unused)))
206 errno = ENOSYS;
207 return -1;
209 #endif
211 #ifndef HAVE_OPENAT
213 openat (int dirfd __attribute__ ((unused)),
214 const char *pathname __attribute__ ((unused)),
215 int oflag __attribute__ ((unused)),
216 ...)
218 errno = ENOSYS;
219 return -1;
221 #endif
223 #ifndef HAVE_PIPE2
225 pipe2 (int pipefd[2] __attribute__ ((unused)),
226 int flags __attribute__ ((unused)))
228 errno = ENOSYS;
229 return -1;
231 #endif
233 #ifndef HAVE_REMOVEXATTR
235 removexattr (const char *path __attribute__ ((unused)),
236 const char *name __attribute__ ((unused)))
238 errno = ENOSYS;
239 return -1;
241 #endif
243 #ifndef HAVE_RENAMEAT
245 renameat (int olddirfd __attribute__ ((unused)),
246 const char *oldpath __attribute__ ((unused)),
247 int newdirfd __attribute__ ((unused)),
248 const char *newpath __attribute__ ((unused)))
250 errno = ENOSYS;
251 return -1;
253 #endif
255 #ifndef HAVE_SETXATTR
257 setxattr (const char *path __attribute__ ((unused)),
258 const char *name __attribute__ ((unused)),
259 const void *value __attribute__ ((unused)),
260 size_t size __attribute__ ((unused)),
261 int flags __attribute__ ((unused)))
263 errno = ENOSYS;
264 return -1;
266 #endif
268 #ifndef HAVE_SPLICE
270 splice (int fd __attribute__ ((unused)),
271 loff_t *off_in __attribute__ ((unused)),
272 int fd_out __attribute__ ((unused)),
273 loff_t *off_out __attribute__ ((unused)),
274 size_t len __attribute__ ((unused)),
275 unsigned int flags __attribute__ ((unused)))
277 errno = ENOSYS;
278 return -1;
280 #endif
282 #ifndef HAVE_SYNC_FILE_RANGE
284 sync_file_range (int fd __attribute__ ((unused)),
285 off64_t offset __attribute__ ((unused)),
286 off64_t nbytes __attribute__ ((unused)),
287 unsigned int flags __attribute__ ((unused)))
289 errno = ENOSYS;
290 return -1;
292 #endif
294 #ifndef HAVE_TEE
296 tee (int fd_in __attribute__ ((unused)),
297 int fd_out __attribute__ ((unused)),
298 size_t len __attribute__ ((unused)),
299 unsigned int flags __attribute__ ((unused)))
301 errno = ENOSYS;
302 return -1;
304 #endif
306 #ifndef HAVE_UNLINKAT
308 unlinkat (int dirfd __attribute__ ((unused)),
309 const char *pathname __attribute__ ((unused)),
310 int flags __attribute__ ((unused)))
312 errno = ENOSYS;
313 return -1;
315 #endif
317 #ifndef HAVE_UNSHARE
319 unshare (int flags __attribute__ ((unused)))
321 errno = ENOSYS;
322 return -1;
324 #endif
326 #ifndef HAVE_UTIMENSAT
327 struct timespec;
329 utimensat(int dirfd __attribute__ ((unused)),
330 const char *pathname __attribute__ ((unused)),
331 const struct timespec times[2] __attribute__ ((unused)),
332 int flags __attribute__ ((unused)))
334 errno = ENOSYS;
335 return -1;
337 #endif
339 /* Long double math functions. These are needed on old i386 systems
340 that don't have them in libm. The compiler translates calls to
341 these functions on float64 to call an 80-bit floating point
342 function instead, because when optimizing that function can be
343 executed as an x87 instructure. However, when not optimizing, this
344 translates into a call to the math function. So on systems that
345 don't provide these functions, we provide a version that just calls
346 the float64 version. */
348 #ifndef HAVE_COSL
349 long double
350 cosl (long double a)
352 return (long double) cos ((double) a);
354 #endif
356 #ifndef HAVE_EXPL
357 long double
358 expl (long double a)
360 return (long double) exp ((double) a);
362 #endif
364 #ifndef HAVE_LOGL
365 long double
366 logl (long double a)
368 return (long double) log ((double) a);
370 #endif
372 #ifndef HAVE_SINL
373 long double
374 sinl (long double a)
376 return (long double) sin ((double) a);
378 #endif
380 #ifndef HAVE_TANL
381 long double
382 tanl (long double a)
384 return (long double) tan ((double) a);
386 #endif
388 #ifndef HAVE_ACOSL
389 long double
390 acosl (long double a)
392 return (long double) acos ((double) a);
394 #endif
396 #ifndef HAVE_ASINL
397 long double
398 asinl (long double a)
400 return (long double) asin ((double) a);
402 #endif
404 #ifndef HAVE_ATANL
405 long double
406 atanl (long double a)
408 return (long double) atan ((double) a);
410 #endif
412 #ifndef HAVE_ATAN2L
413 long double
414 atan2l (long double a, long double b)
416 return (long double) atan2 ((double) a, (double) b);
418 #endif
420 #ifndef HAVE_EXPM1L
421 long double
422 expm1l (long double a)
424 return (long double) expm1 ((double) a);
426 #endif
428 #ifndef HAVE_LDEXPL
429 long double
430 ldexpl (long double a, int exp)
432 return (long double) ldexp ((double) a, exp);
434 #endif
436 #ifndef HAVE_LOG10L
437 long double
438 log10l (long double a)
440 return (long double) log10 ((double) a);
442 #endif
444 #ifndef HAVE_LOG1PL
445 long double
446 log1pl (long double a)
448 return (long double) log1p ((double) a);
450 #endif