summaryrefslogtreecommitdiff
path: root/source3/tests/sgi_sysv_hack.c
blob: 0fb16f11f86b7dc0ac18560360f847370365146f (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
39
40
41
42
43
44
45
46
/* this tests if we need to define SGI_SEMUN_HACK
   if we're using gcc on IRIX 6.5.x. */

#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>

#ifndef HAVE_UNION_SEMUN
union semun {
	int val;
	struct semid_ds *buf;
	unsigned short *array;
};
#endif

union semun_hack {
 int val;
 struct semid_ds *buf;
 unsigned short *array;
 char __dummy[5];
};

main() {
  struct semid_ds sem_ds;
  union semun_hack suh;
  union semun su;
  int sem_id, ret;

  ret = 1;
  sem_id = semget(0xdead6666,1,IPC_CREAT|IPC_EXCL|0777);
  su.buf = &sem_ds;
  suh.buf = &sem_ds;
  if (sem_id != -1) {
    if ((semctl(sem_id, 0, IPC_STAT, su) == -1) &&
        (semctl(sem_id, 0, IPC_STAT, suh) != -1)) {
      ret = 0;
    }
  }
  semctl(sem_id, 0, IPC_RMID, 0);
  return ret;
}