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
21 #include <sys/types.h>
22 #include <sys/resource.h>
23 #include <sys/socket.h>
31 typedef signed int off64_t
__attribute__ ((mode (DI
)));
35 typedef off64_t loff_t
;
41 accept4 (int sockfd
__attribute__ ((unused
)),
42 struct sockaddr
*addr
__attribute__ ((unused
)),
43 socklen_t
*addrlen
__attribute__ ((unused
)),
44 int flags
__attribute__ ((unused
)))
53 dup3 (int oldfd
__attribute__ ((unused
)),
54 int newfd
__attribute__ ((unused
)),
55 int flags
__attribute__ ((unused
)))
62 #ifndef HAVE_EPOLL_CREATE1
64 epoll_create1 (int flags
__attribute__ ((unused
)))
71 #ifndef HAVE_FACCESSAT
73 faccessat (int fd
__attribute__ ((unused
)),
74 const char *pathname
__attribute__ ((unused
)),
75 int mode
__attribute__ ((unused
)),
76 int flags
__attribute__ ((unused
)))
83 #ifndef HAVE_FALLOCATE
85 fallocate (int fd
__attribute__ ((unused
)),
86 int mode
__attribute__ ((unused
)),
87 off_t offset
__attribute__ ((unused
)),
88 off_t len
__attribute__ ((unused
)))
97 fchmodat (int dirfd
__attribute__ ((unused
)),
98 const char *pathname
__attribute__ ((unused
)),
99 mode_t mode
__attribute__ ((unused
)),
100 int flags
__attribute__ ((unused
)))
107 #ifndef HAVE_FCHOWNAT
109 fchownat (int dirfd
__attribute__ ((unused
)),
110 const char *pathname
__attribute__ ((unused
)),
111 uid_t owner
__attribute__ ((unused
)),
112 gid_t group
__attribute__ ((unused
)),
113 int flags
__attribute__ ((unused
)))
120 #ifndef HAVE_FUTIMESAT
122 futimesat (int dirfd
__attribute__ ((unused
)),
123 const char *pathname
__attribute__ ((unused
)),
124 const struct timeval times
[2] __attribute__ ((unused
)))
131 #ifndef HAVE_GETXATTR
133 getxattr (const char *path
__attribute__ ((unused
)),
134 const char *name
__attribute__ ((unused
)),
135 void *value
__attribute__ ((unused
)),
136 size_t size
__attribute__ ((unused
)))
143 #ifndef HAVE_INOTIFY_ADD_WATCH
145 inotify_add_watch (int fd
__attribute__ ((unused
)),
146 const char* pathname
__attribute__ ((unused
)),
147 uint32_t mask
__attribute__ ((unused
)))
154 #ifndef HAVE_INOTIFY_INIT
163 #ifndef HAVE_INOTIFY_INIT1
165 inotify_init1 (int flags
__attribute__ ((unused
)))
172 #ifndef HAVE_INOTIFY_RM_WATCH
174 inotify_rm_watch (int fd
__attribute__ ((unused
)),
175 uint32_t wd
__attribute__ ((unused
)))
182 #ifndef HAVE_LISTXATTR
184 listxattr (const char *path
__attribute__ ((unused
)),
185 char *list
__attribute__ ((unused
)),
186 size_t size
__attribute__ ((unused
)))
195 mkdirat (int dirfd
__attribute__ ((unused
)),
196 const char *pathname
__attribute__ ((unused
)),
197 mode_t mode
__attribute__ ((unused
)))
206 mknodat (int dirfd
__attribute__ ((unused
)),
207 const char *pathname
__attribute__ ((unused
)),
208 mode_t mode
__attribute__ ((unused
)),
209 dev_t dev
__attribute__ ((unused
)))
218 openat (int dirfd
__attribute__ ((unused
)),
219 const char *pathname
__attribute__ ((unused
)),
220 int oflag
__attribute__ ((unused
)),
230 pipe2 (int pipefd
[2] __attribute__ ((unused
)),
231 int flags
__attribute__ ((unused
)))
238 #ifndef HAVE_REMOVEXATTR
240 removexattr (const char *path
__attribute__ ((unused
)),
241 const char *name
__attribute__ ((unused
)))
248 #ifndef HAVE_RENAMEAT
250 renameat (int olddirfd
__attribute__ ((unused
)),
251 const char *oldpath
__attribute__ ((unused
)),
252 int newdirfd
__attribute__ ((unused
)),
253 const char *newpath
__attribute__ ((unused
)))
260 #ifndef HAVE_SETXATTR
262 setxattr (const char *path
__attribute__ ((unused
)),
263 const char *name
__attribute__ ((unused
)),
264 const void *value
__attribute__ ((unused
)),
265 size_t size
__attribute__ ((unused
)),
266 int flags
__attribute__ ((unused
)))
275 splice (int fd
__attribute__ ((unused
)),
276 loff_t
*off_in
__attribute__ ((unused
)),
277 int fd_out
__attribute__ ((unused
)),
278 loff_t
*off_out
__attribute__ ((unused
)),
279 size_t len
__attribute__ ((unused
)),
280 unsigned int flags
__attribute__ ((unused
)))
287 #ifndef HAVE_SYNC_FILE_RANGE
289 sync_file_range (int fd
__attribute__ ((unused
)),
290 off64_t offset
__attribute__ ((unused
)),
291 off64_t nbytes
__attribute__ ((unused
)),
292 unsigned int flags
__attribute__ ((unused
)))
301 tee (int fd_in
__attribute__ ((unused
)),
302 int fd_out
__attribute__ ((unused
)),
303 size_t len
__attribute__ ((unused
)),
304 unsigned int flags
__attribute__ ((unused
)))
311 #ifndef HAVE_UNLINKAT
313 unlinkat (int dirfd
__attribute__ ((unused
)),
314 const char *pathname
__attribute__ ((unused
)),
315 int flags
__attribute__ ((unused
)))
324 unshare (int flags
__attribute__ ((unused
)))
331 #ifndef HAVE_UTIMENSAT
334 utimensat(int dirfd
__attribute__ ((unused
)),
335 const char *pathname
__attribute__ ((unused
)),
336 const struct timespec times
[2] __attribute__ ((unused
)),
337 int flags
__attribute__ ((unused
)))
344 /* Long double math functions. These are needed on old i386 systems
345 that don't have them in libm. The compiler translates calls to
346 these functions on float64 to call an 80-bit floating point
347 function instead, because when optimizing that function can be
348 executed as an x87 instructure. However, when not optimizing, this
349 translates into a call to the math function. So on systems that
350 don't provide these functions, we provide a version that just calls
351 the float64 version. */
357 return (long double) cos ((double) a
);
365 return (long double) exp ((double) a
);
373 return (long double) log ((double) a
);
381 return (long double) sin ((double) a
);
389 return (long double) tan ((double) a
);
395 acosl (long double a
)
397 return (long double) acos ((double) a
);
403 asinl (long double a
)
405 return (long double) asin ((double) a
);
411 atanl (long double a
)
413 return (long double) atan ((double) a
);
419 atan2l (long double a
, long double b
)
421 return (long double) atan2 ((double) a
, (double) b
);
427 expm1l (long double a
)
429 return (long double) expm1 ((double) a
);
435 ldexpl (long double a
, int exp
)
437 return (long double) ldexp ((double) a
, exp
);
443 log10l (long double a
)
445 return (long double) log10 ((double) a
);
451 log1pl (long double a
)
453 return (long double) log1p ((double) a
);
457 #ifndef HAVE_STRERROR_R
459 /* Some old systems do not have strerror_r. This is a replacement.
460 It assumes that nothing else in the program calls strerror. */
462 static pthread_mutex_t strerror_lock
= PTHREAD_MUTEX_INITIALIZER
;
465 strerror_r (int errnum
, char *buf
, size_t buflen
)
472 i
= pthread_mutex_lock (&strerror_lock
);
476 errmsg
= strerror (errnum
);
477 len
= strlen (errmsg
);
482 memcpy (buf
, errmsg
, len
+ 1);
486 i
= pthread_mutex_unlock (&strerror_lock
);
493 #endif /* ! HAVE_STRERROR_R */
497 /* Some old systems do not have wait4. This is a replacement that
501 wait4 (pid_t pid
, int *status
, int options
, struct rusage
*rusage
__attribute__ ((unused
)))
503 return waitpid (pid
, status
, options
);