Cope with case that SEM_FAILED is not defined (assume failure code is -1)
authorTom Lane <[email protected]>
Sun, 5 May 2002 16:01:50 +0000 (16:01 +0000)
committerTom Lane <[email protected]>
Sun, 5 May 2002 16:01:50 +0000 (16:01 +0000)
src/backend/port/posix_sema.c

index 74e6f7e9142fecd9d945e000de118ae7c8c1ccd2..c40585be2ce3a18f3aa48ca8fd5738bc667d7fe9 100644 (file)
@@ -72,8 +72,14 @@ PosixSemaphoreCreate(void)
 
                mySem = sem_open(semname, O_CREAT | O_EXCL,
                                                 (mode_t) IPCProtection, (unsigned) 1);
+
+#ifdef SEM_FAILED
                if (mySem != (sem_t *) SEM_FAILED)
                        break;
+#else
+               if (mySem != (sem_t *) (-1))
+                       break;
+#endif
 
                /* Loop if error indicates a collision */
                if (errno == EEXIST || errno == EACCES || errno == EINTR)
@@ -82,7 +88,7 @@ PosixSemaphoreCreate(void)
                /*
                 * Else complain and abort
                 */
-               fprintf(stderr, "PosixSemaphoreCreate: sem_open(%s) failed: %s\n",
+               fprintf(stderr, "PosixSemaphoreCreate: sem_open(\"%s\") failed: %s\n",
                                semname, strerror(errno));
                proc_exit(1);
        }