Importing Upstream version 4.8.2
[platform/upstream/gcc48.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/socket.h>
20 #include <sys/stat.h>
21 #include <sys/time.h>
22 #include <time.h>
23 #include <unistd.h>
24
25 #ifndef HAVE_OFF64_T
26 typedef signed int off64_t __attribute__ ((mode (DI)));
27 #endif
28
29 #ifndef HAVE_LOFF_T
30 typedef off64_t loff_t;
31 #endif
32
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)))
40 {
41   errno = ENOSYS;
42   return -1;
43 }
44 #endif
45
46 #ifndef HAVE_EPOLL_CREATE1
47 int
48 epoll_create1 (int flags __attribute__ ((unused)))
49 {
50   errno = ENOSYS;
51   return -1;
52 }
53 #endif
54
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)))
61 {
62   errno = ENOSYS;
63   return -1;
64 }
65 #endif
66
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)))
73 {
74   errno = ENOSYS;
75   return -1;
76 }
77 #endif
78
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)))
85 {
86   errno = ENOSYS;
87   return -1;
88 }
89 #endif
90
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)))
98 {
99   errno = ENOSYS;
100   return -1;
101 }
102 #endif
103
104 #ifndef HAVE_FUTIMESAT
105 int
106 futimesat (int dirfd __attribute__ ((unused)),
107            const char *pathname __attribute__ ((unused)),
108            const struct timeval times[2] __attribute__ ((unused)))
109 {
110   errno = ENOSYS;
111   return -1;
112 }
113 #endif
114
115 #ifndef HAVE_INOTIFY_ADD_WATCH
116 int
117 inotify_add_watch (int fd __attribute__ ((unused)),
118                    const char* pathname __attribute__ ((unused)),
119                    uint32_t mask __attribute__ ((unused)))
120 {
121   errno = ENOSYS;
122   return -1;
123 }
124 #endif
125
126 #ifndef HAVE_INOTIFY_INIT
127 int
128 inotify_init (void)
129 {
130   errno = ENOSYS;
131   return -1;
132 }
133 #endif
134
135 #ifndef HAVE_INOTIFY_INIT1
136 int
137 inotify_init1 (int flags __attribute__ ((unused)))
138 {
139   errno = ENOSYS;
140   return -1;
141 }
142 #endif
143
144 #ifndef HAVE_INOTIFY_RM_WATCH
145 int
146 inotify_rm_watch (int fd __attribute__ ((unused)),
147                   uint32_t wd __attribute__ ((unused)))
148 {
149   errno = ENOSYS;
150   return -1;
151 }
152 #endif
153
154 #ifndef HAVE_MKDIRAT
155 int
156 mkdirat (int dirfd __attribute__ ((unused)),
157          const char *pathname __attribute__ ((unused)),
158          mode_t mode __attribute__ ((unused)))
159 {
160   errno = ENOSYS;
161   return -1;
162 }
163 #endif
164
165 #ifndef HAVE_MKNODAT
166 int
167 mknodat (int dirfd __attribute__ ((unused)),
168          const char *pathname __attribute__ ((unused)),
169          mode_t mode __attribute__ ((unused)),
170          dev_t dev __attribute__ ((unused)))
171 {
172   errno = ENOSYS;
173   return -1;
174 }
175 #endif
176
177 #ifndef HAVE_OPENAT
178 int
179 openat (int dirfd __attribute__ ((unused)),
180         const char *pathname __attribute__ ((unused)),
181         int oflag __attribute__ ((unused)),
182         ...)
183 {
184   errno = ENOSYS;
185   return -1;
186 }
187 #endif
188
189 #ifndef HAVE_PIPE2
190 int
191 pipe2 (int pipefd[2] __attribute__ ((unused)),
192        int flags __attribute__ ((unused)))
193 {
194   errno = ENOSYS;
195   return -1;
196 }
197 #endif
198
199 #ifndef HAVE_RENAMEAT
200 int
201 renameat (int olddirfd __attribute__ ((unused)),
202           const char *oldpath __attribute__ ((unused)),
203           int newdirfd __attribute__ ((unused)),
204           const char *newpath __attribute__ ((unused)))
205 {
206   errno = ENOSYS;
207   return -1;
208 }
209 #endif
210
211 #ifndef HAVE_SPLICE
212 int
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)))
219 {
220   errno = ENOSYS;
221   return -1;
222 }
223 #endif
224
225 #ifndef HAVE_SYNC_FILE_RANGE
226 int
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)))
231 {
232   errno = ENOSYS;
233   return -1;
234 }
235 #endif
236
237 #ifndef HAVE_TEE
238 int
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)))
243 {
244   errno = ENOSYS;
245   return -1;
246 }
247 #endif
248
249 #ifndef HAVE_UNLINKAT
250 int
251 unlinkat (int dirfd __attribute__ ((unused)),
252           const char *pathname __attribute__ ((unused)),
253           int flags __attribute__ ((unused)))
254 {
255   errno = ENOSYS;
256   return -1;
257 }
258 #endif
259
260 #ifndef HAVE_UNSHARE
261 int
262 unshare (int flags __attribute__ ((unused)))
263 {
264   errno = ENOSYS;
265   return -1;
266 }
267 #endif
268
269 #ifndef HAVE_UTIMENSAT
270 struct timespec;
271 int
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)))
276 {
277   errno = ENOSYS;
278   return -1;
279 }
280 #endif
281
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.  */
290
291 #ifndef HAVE_COSL
292 long double
293 cosl (long double a)
294 {
295   return (long double) cos ((double) a);
296 }
297 #endif
298
299 #ifndef HAVE_EXPL
300 long double
301 expl (long double a)
302 {
303   return (long double) exp ((double) a);
304 }
305 #endif
306
307 #ifndef HAVE_LOGL
308 long double
309 logl (long double a)
310 {
311   return (long double) log ((double) a);
312 }
313 #endif
314
315 #ifndef HAVE_SINL
316 long double
317 sinl (long double a)
318 {
319   return (long double) sin ((double) a);
320 }
321 #endif
322
323 #ifndef HAVE_TANL
324 long double
325 tanl (long double a)
326 {
327   return (long double) tan ((double) a);
328 }
329 #endif
330
331 #ifndef HAVE_ACOSL
332 long double
333 acosl (long double a)
334 {
335   return (long double) acos ((double) a);
336 }
337 #endif
338
339 #ifndef HAVE_ASINL
340 long double
341 asinl (long double a)
342 {
343   return (long double) asin ((double) a);
344 }
345 #endif
346
347 #ifndef HAVE_ATANL
348 long double
349 atanl (long double a)
350 {
351   return (long double) atan ((double) a);
352 }
353 #endif
354
355 #ifndef HAVE_ATAN2L
356 long double
357 atan2l (long double a, long double b)
358 {
359   return (long double) atan2 ((double) a, (double) b);
360 }
361 #endif
362
363 #ifndef HAVE_EXPM1L
364 long double
365 expm1l (long double a)
366 {
367   return (long double) expm1 ((double) a);
368 }
369 #endif
370
371 #ifndef HAVE_LDEXPL
372 long double
373 ldexpl (long double a, int exp)
374 {
375   return (long double) ldexp ((double) a, exp);
376 }
377 #endif
378
379 #ifndef HAVE_LOG10L
380 long double
381 log10l (long double a)
382 {
383   return (long double) log10 ((double) a);
384 }
385 #endif
386
387 #ifndef HAVE_LOG1PL
388 long double
389 log1pl (long double a)
390 {
391   return (long double) log1p ((double) a);
392 }
393 #endif