|
32 | 32 | #include "php_sysvsem.h"
|
33 | 33 | #include "ext/standard/info.h"
|
34 | 34 |
|
35 |
| -#if !HAVE_SEMUN |
36 |
| - |
| 35 | +#ifndef HAVE_UNION_SEMUN |
37 | 36 | union semun {
|
38 | 37 | int val; /* value for SETVAL */
|
39 | 38 | struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
|
40 | 39 | unsigned short int *array; /* array for GETALL, SETALL */
|
41 | 40 | struct seminfo *__buf; /* buffer for IPC_INFO */
|
42 | 41 | };
|
43 |
| - |
44 |
| -#undef HAVE_SEMUN |
45 |
| -#define HAVE_SEMUN 1 |
46 |
| - |
47 | 42 | #endif
|
48 | 43 |
|
49 | 44 | /* {{{ sysvsem_module_entry */
|
@@ -173,12 +168,6 @@ PHP_MINFO_FUNCTION(sysvsem)
|
173 | 168 | }
|
174 | 169 | /* }}} */
|
175 | 170 |
|
176 |
| -#define SETVAL_WANTS_PTR |
177 |
| - |
178 |
| -#if defined(_AIX) |
179 |
| -#undef SETVAL_WANTS_PTR |
180 |
| -#endif |
181 |
| - |
182 | 171 | /* {{{ Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously */
|
183 | 172 | PHP_FUNCTION(sem_get)
|
184 | 173 | {
|
@@ -247,24 +236,11 @@ PHP_FUNCTION(sem_get)
|
247 | 236 | /* If we are the only user, then take this opportunity to set the max. */
|
248 | 237 |
|
249 | 238 | if (count == 1) {
|
250 |
| -#if HAVE_SEMUN |
251 |
| - /* This is correct for Linux which has union semun. */ |
252 | 239 | union semun semarg;
|
253 | 240 | semarg.val = max_acquire;
|
254 | 241 | if (semctl(semid, SYSVSEM_SEM, SETVAL, semarg) == -1) {
|
255 | 242 | php_error_docref(NULL, E_WARNING, "Failed for key 0x" ZEND_XLONG_FMT ": %s", key, strerror(errno));
|
256 | 243 | }
|
257 |
| -#elif defined(SETVAL_WANTS_PTR) |
258 |
| - /* This is correct for Solaris 2.6 which does not have union semun. */ |
259 |
| - if (semctl(semid, SYSVSEM_SEM, SETVAL, &max_acquire) == -1) { |
260 |
| - php_error_docref(NULL, E_WARNING, "Failed for key 0x%lx: %s", key, strerror(errno)); |
261 |
| - } |
262 |
| -#else |
263 |
| - /* This works for i.e. AIX */ |
264 |
| - if (semctl(semid, SYSVSEM_SEM, SETVAL, max_acquire) == -1) { |
265 |
| - php_error_docref(NULL, E_WARNING, "Failed for key 0x%lx: %s", key, strerror(errno)); |
266 |
| - } |
267 |
| -#endif |
268 | 244 | }
|
269 | 245 |
|
270 | 246 | /* Set semaphore 1 back to zero. */
|
@@ -357,32 +333,22 @@ PHP_FUNCTION(sem_remove)
|
357 | 333 | {
|
358 | 334 | zval *arg_id;
|
359 | 335 | sysvsem_sem *sem_ptr;
|
360 |
| -#if HAVE_SEMUN |
361 | 336 | union semun un;
|
362 | 337 | struct semid_ds buf;
|
363 |
| -#endif |
364 | 338 |
|
365 | 339 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &arg_id, sysvsem_ce) == FAILURE) {
|
366 | 340 | RETURN_THROWS();
|
367 | 341 | }
|
368 | 342 |
|
369 | 343 | sem_ptr = Z_SYSVSEM_P(arg_id);
|
370 | 344 |
|
371 |
| -#if HAVE_SEMUN |
372 | 345 | un.buf = &buf;
|
373 | 346 | if (semctl(sem_ptr->semid, 0, IPC_STAT, un) < 0) {
|
374 |
| -#else |
375 |
| - if (semctl(sem_ptr->semid, 0, IPC_STAT, NULL) < 0) { |
376 |
| -#endif |
377 | 347 | php_error_docref(NULL, E_WARNING, "SysV semaphore for key 0x%x does not (any longer) exist", sem_ptr->key);
|
378 | 348 | RETURN_FALSE;
|
379 | 349 | }
|
380 | 350 |
|
381 |
| -#if HAVE_SEMUN |
382 | 351 | if (semctl(sem_ptr->semid, 0, IPC_RMID, un) < 0) {
|
383 |
| -#else |
384 |
| - if (semctl(sem_ptr->semid, 0, IPC_RMID, NULL) < 0) { |
385 |
| -#endif |
386 | 352 | php_error_docref(NULL, E_WARNING, "Failed for SysV semaphore for key 0x%x: %s", sem_ptr->key, strerror(errno));
|
387 | 353 | RETURN_FALSE;
|
388 | 354 | }
|
|
0 commit comments