Daily bump.
[official-gcc.git] / libgo / runtime / go-varargs.c
blob691ee56582d015efc0764ec7c195073be4f84295
1 /* go-varargs.c -- functions for calling C varargs functions.
3 Copyright 2013 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 #include "config.h"
9 #include <errno.h>
10 #include <stdint.h>
11 #include <unistd.h>
12 #include <sys/types.h>
13 #include <fcntl.h>
14 #include <sys/ioctl.h>
16 /* The syscall package calls C functions. The Go compiler can not
17 represent a C varargs functions. On some systems it's important
18 that the declaration of a function match the call. This function
19 holds non-varargs C functions that the Go code can call. */
21 int
22 __go_open (char *path, int mode, mode_t perm)
24 return open (path, mode, perm);
27 int
28 __go_fcntl (int fd, int cmd, int arg)
30 return fcntl (fd, cmd, arg);
33 int
34 __go_fcntl_flock (int fd, int cmd, struct flock *arg)
36 return fcntl (fd, cmd, arg);
39 // This is for the net package. We use uintptr_t to make sure that
40 // the types match, since the Go and C "int" types are not the same.
41 struct go_fcntl_ret {
42 uintptr_t r;
43 uintptr_t err;
46 struct go_fcntl_ret
47 __go_fcntl_uintptr (uintptr_t fd, uintptr_t cmd, uintptr_t arg)
49 int r;
50 struct go_fcntl_ret ret;
52 r = fcntl ((int) fd, (int) cmd, (int) arg);
53 ret.r = (uintptr_t) r;
54 if (r < 0)
55 ret.err = (uintptr_t) errno;
56 else
57 ret.err = 0;
58 return ret;
61 int
62 __go_ioctl (int d, int request, int arg)
64 return ioctl (d, request, arg);
67 int
68 __go_ioctl_ptr (int d, int request, void *arg)
70 return ioctl (d, request, arg);
73 #ifdef HAVE_OPEN64
75 int
76 __go_open64 (char *path, int mode, mode_t perm)
78 return open64 (path, mode, perm);
81 #endif
83 #ifdef HAVE_OPENAT
85 int
86 __go_openat (int fd, char *path, int flags, mode_t mode)
88 return openat (fd, path, flags, mode);
91 #endif