Fix warnings.
[mono/afaerber.git] / support / sys-utsname.c
blobdeccad5a07b82dfbfb569181710febd339ff0e99
1 /*
2 * <sys/sendfile.h> wrapper functions.
4 * Authors:
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004 Jonathan Pryor
8 */
10 #include <sys/types.h>
11 #include <errno.h>
12 #include <stdlib.h>
14 #include "map.h"
15 #include "mph.h"
17 #include <sys/utsname.h>
19 G_BEGIN_DECLS
21 static const mph_string_offset_t
22 utsname_offsets[] = {
23 MPH_STRING_OFFSET(struct utsname, sysname, MPH_STRING_OFFSET_ARRAY),
24 MPH_STRING_OFFSET(struct utsname, nodename, MPH_STRING_OFFSET_ARRAY),
25 MPH_STRING_OFFSET(struct utsname, release, MPH_STRING_OFFSET_ARRAY),
26 MPH_STRING_OFFSET(struct utsname, version, MPH_STRING_OFFSET_ARRAY),
27 MPH_STRING_OFFSET(struct utsname, machine, MPH_STRING_OFFSET_ARRAY)
30 static const mph_string_offset_t
31 mph_utsname_offsets[] = {
32 MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, sysname, MPH_STRING_OFFSET_PTR),
33 MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, nodename, MPH_STRING_OFFSET_PTR),
34 MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, release, MPH_STRING_OFFSET_PTR),
35 MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, version, MPH_STRING_OFFSET_PTR),
36 MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, machine, MPH_STRING_OFFSET_PTR)
39 int
40 Mono_Posix_Syscall_uname (struct Mono_Posix_Syscall__Utsname *buf)
42 struct utsname _buf;
43 int r;
45 if (!buf) {
46 errno = EFAULT;
47 return -1;
50 r = uname (&_buf);
51 if (r == 0) {
52 buf->_buf_ = _mph_copy_structure_strings (buf, mph_utsname_offsets,
53 &_buf, utsname_offsets, sizeof(utsname_offsets)/sizeof(utsname_offsets[0]));
54 buf->domainname = NULL;
55 if (!buf->_buf_) {
56 errno = ENOMEM;
57 return -1;
60 return r;
63 G_END_DECLS
66 * vim: noexpandtab