- Timestamp:
- Apr 5, 2017, 9:51:43 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_sem.c
r481 r522 44 44 } sh_estat; 45 45 46 #if 0 46 47 47 /* FreeBSD 6.1 defines this in <sys/sem.h> too... */ 48 48 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) 49 49 /* union semun is defined by including <sys/sem.h> */ 50 50 #else 51 #if !defined(HAVE_UNION_SEMUN) 51 52 /* according to X/OPEN we have to define it ourselves */ 52 53 union semun { … … 58 59 #endif 59 60 61 60 62 #define SH_SEMVMX 32767 61 63 … … 75 77 static void sem_purge(int sem_id) 76 78 { 79 union semun tmp; 80 81 tmp.val = 0; 82 77 83 if (sem_id != -1) 78 semctl(sem_id, 0, IPC_RMID, (int)0);84 semctl(sem_id, 0, IPC_RMID, tmp); 79 85 return; 80 86 } … … 103 109 int semid; 104 110 int errnum; 111 union semun tmp; 105 112 key_t key = ftok(DEFAULT_DATAROOT, '#'); 106 113 … … 112 119 errnum = errno; 113 120 umask(mask); 121 122 tmp.val = 1; 114 123 115 124 if (semid < 0) 116 125 return report_err(errnum, FIL__, __LINE__, _("semget")); 117 126 for (i=0; i<nsems; ++i) 118 if (semctl (semid, i, SETVAL, (int) 1) == -1)127 if (semctl (semid, i, SETVAL, tmp) == -1) 119 128 return report_err(errnum, FIL__, __LINE__, _("semclt")); 120 129 return semid; … … 124 133 static int sem_set(int semid, int sem_no, int val) 125 134 { 135 union semun tmp; 136 137 tmp.val = val; 138 126 139 if (semid < 0) 127 140 return -1; 128 if (semctl (semid, sem_no, SETVAL, val) == -1)141 if (semctl (semid, sem_no, SETVAL, tmp) == -1) 129 142 return -1; 130 143 return 0; … … 133 146 static int sem_get(int semid, int sem_no) 134 147 { 148 union semun tmp; 135 149 if (semid < 0) 136 150 return -1; 137 return semctl (semid, sem_no, GETVAL, (int) 0); 151 tmp.val = 0; 152 return semctl (semid, sem_no, GETVAL, tmp); 138 153 } 139 154
Note:
See TracChangeset
for help on using the changeset viewer.