2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20010724-1.c
blob8ff7d0f44a0ed7c0a2fcc68ed2ee2fde3bc218bf
1 /* Verify that the workarounds in config/mips/irix6-libc-compat.c are still
2 needed. */
4 /* IRIX 6, unlike other Unix systems, defines union semun in <sys/sem.h>.
5 Inhibit this definition to be able to run this test on other platforms. */
6 #define _XOPEN_SOURCE
8 #include <sys/types.h>
9 #include <netinet/in.h>
10 #include <arpa/inet.h>
11 #include <sys/ipc.h>
12 #include <sys/sem.h>
14 union semun {
15 int val;
16 struct semid_ds *buf;
17 ushort_t *array;
20 int
21 main (void)
23 struct in_addr ia;
24 int semid;
25 union semun su;
27 ia.s_addr = INADDR_BROADCAST;
29 if (strcmp (inet_ntoa (ia), "255.255.255.255") != 0)
30 abort ();
32 ia.s_addr = INADDR_LOOPBACK;
34 if (inet_lnaof (ia) != 1)
35 abort ();
37 if (inet_netof (ia) != IN_LOOPBACKNET)
38 abort ();
40 ia = inet_makeaddr (IN_LOOPBACKNET, 1);
41 if (ia.s_addr != INADDR_LOOPBACK)
42 abort ();
44 if ((semid = semget (IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | SEM_R | SEM_A)) < 0)
45 abort ();
47 su.val = 10;
49 if (semctl (semid, 0, SETVAL, su) != 0)
50 abort ();
52 if (semctl (semid, 0, GETVAL) != 10)
53 abort ();
55 if (semctl (semid, 0, IPC_RMID) != 0)
56 abort ();
58 return 0;