Remove ChangeLog entry unintentionally duplicated in the top level
[official-gcc.git] / libgo / runtime / go-varargs.c
blob534c0db94fa61f9f494671fc312a3b443a5bb4a9
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 <sys/types.h>
12 #include <fcntl.h>
13 #include <sys/ioctl.h>
15 /* The syscall package calls C functions. The Go compiler can not
16 represent a C varargs functions. On some systems it's important
17 that the declaration of a function match the call. This function
18 holds non-varargs C functions that the Go code can call. */
20 int
21 __go_open (char *path, int mode, mode_t perm)
23 return open (path, mode, perm);
26 int
27 __go_fcntl (int fd, int cmd, int arg)
29 return fcntl (fd, cmd, arg);
32 int
33 __go_fcntl_flock (int fd, int cmd, struct flock *arg)
35 return fcntl (fd, cmd, arg);
38 // This is for the net package. We use uintptr_t to make sure that
39 // the types match, since the Go and C "int" types are not the same.
40 struct go_fcntl_ret {
41 uintptr_t r;
42 uintptr_t err;
45 struct go_fcntl_ret
46 __go_fcntl_uintptr (uintptr_t fd, uintptr_t cmd, uintptr_t arg)
48 int r;
49 struct go_fcntl_ret ret;
51 r = fcntl ((int) fd, (int) cmd, (int) arg);
52 ret.r = (uintptr_t) r;
53 if (r < 0)
54 ret.err = (uintptr_t) errno;
55 else
56 ret.err = 0;
57 return ret;
60 int
61 __go_ioctl (int d, int request, int arg)
63 return ioctl (d, request, arg);
66 int
67 __go_ioctl_ptr (int d, int request, void *arg)
69 return ioctl (d, request, arg);
72 #ifdef HAVE_OPEN64
74 int
75 __go_open64 (char *path, int mode, mode_t perm)
77 return open64 (path, mode, perm);
80 #endif
82 #ifdef HAVE_OPENAT
84 int
85 __go_openat (int fd, char *path, int flags, mode_t mode)
87 return openat (fd, path, flags, mode);
90 #endif