summaryrefslogtreecommitdiff
path: root/sim/testsuite/cris/c/sysctl1.c
blob: 6646faca678028516ac27000aff8f8d390378b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
#notarget: cris*-*-elf
*/

#include <unistd.h>
#include <sys/syscall.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

/* I can't seem to include the right things, so we do it brute force.  */
int main (void)
{
  static int sysctl_args[] = { 1, 4 };
  size_t x = 8;

  struct __sysctl_args {
    int *name;
    int nlen;
    void *oldval;
    size_t *oldlenp;
    void *newval;
    size_t newlen;
    unsigned long __unused[4];
  } scargs
      =
    {
     sysctl_args,
     sizeof (sysctl_args) / sizeof (sysctl_args[0]),
     (void *) -1, &x, NULL, 0
    };

  if (syscall (SYS__sysctl, &scargs) != -1
      || errno != EFAULT)
    abort ();
  printf ("pass\n");
  exit (0);
}