Proposed doc update for Explicit Reg Vars 1/3
[official-gcc.git] / libgo / runtime / go-varargs.c
blob7a2006fbab22f282cdc539f83067b7c0f14b9f6e
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>
14 /* The syscall package calls C functions. The Go compiler can not
15 represent a C varargs functions. On some systems it's important
16 that the declaration of a function match the call. This function
17 holds non-varargs C functions that the Go code can call. */
19 int
20 __go_open (char *path, int mode, mode_t perm)
22 return open (path, mode, perm);
25 int
26 __go_fcntl (int fd, int cmd, int arg)
28 return fcntl (fd, cmd, arg);
31 int
32 __go_fcntl_flock (int fd, int cmd, struct flock *arg)
34 return fcntl (fd, cmd, arg);
37 // This is for the net package. We use uintptr_t to make sure that
38 // the types match, since the Go and C "int" types are not the same.
39 struct go_fcntl_ret {
40 uintptr_t r;
41 uintptr_t err;
44 struct go_fcntl_ret
45 __go_fcntl_uintptr (uintptr_t fd, uintptr_t cmd, uintptr_t arg)
47 int r;
48 struct go_fcntl_ret ret;
50 r = fcntl ((int) fd, (int) cmd, (int) arg);
51 ret.r = (uintptr_t) r;
52 if (r < 0)
53 ret.err = (uintptr_t) errno;
54 else
55 ret.err = 0;
56 return ret;
59 #ifdef HAVE_OPEN64
61 int
62 __go_open64 (char *path, int mode, mode_t perm)
64 return open64 (path, mode, perm);
67 #endif
69 #ifdef HAVE_OPENAT
71 int
72 __go_openat (int fd, char *path, int flags, mode_t mode)
74 return openat (fd, path, flags, mode);
77 #endif