1 extern int printf(const char *, ...);
2 typedef unsigned short          ushort;
3 struct sembuf {
4   ushort  sem_num;
5   short   sem_op;
6   short   sem_flg;
7 };
8 union semun {
9   int val;
10   struct semid_ds *buf;
11   ushort *array;
12   struct seminfo *__buf;
13   void *__pad;
14 };
15 static union semun semctl_arg;
16 static int semid;
17 int semop(int semid, struct sembuf *sops, unsigned nsops);
18 void error (const char *);
19 int semctl(int semid, int semnum, int cmd, ...);
up(int sem)20 static void up(int sem){
21   struct sembuf sb;
22   sb.sem_num = (unsigned short) sem;
23   sb.sem_op  = 1;
24   sb.sem_flg = 0x1000 ;
25   if(semop(semid, &sb, 1) == -1) error("up failure");
26   if(semctl(semid, sb.sem_num, 12 , semctl_arg) == 0)
27     printf("%s had processes sleeping on it!\n",
28     ({ "MUTEX     ", "BARB_SEM 1", "BARB_SEM 2", "CUST_SEM 1",
29        "CUST_SEM 2", "WAIT_SEM 1", "WAIT_SEM 2", "WAIT_SEM 3",
30        "WAIT_SEM 4"}	 /* { dg-error "expected" } */
31 	[( sb.sem_num )]) );
32 }
33