Loading...
sys/semctl.c Libc-583 Libc-498
--- Libc/Libc-583/sys/semctl.c
+++ Libc/Libc-498/sys/semctl.c
@@ -24,6 +24,7 @@
 #include <stdarg.h>
 #include <sys/sem.h>
 
+#if !__DARWIN_UNIX03
 #include <errno.h>
 /*
  * Because KERNEL is defined, including errno.h doesn't define errno, so
@@ -31,9 +32,10 @@
  */
 extern int * __error(void);
 #define errno (*__error())
+#endif /* !__DARWIN_UNIX03 */
 
 /*
- * Legacy stub to account for the differences in the ipc_perm structure,
+ * Stub function to account for the differences in the ipc_perm structure,
  * while maintaining binary backward compatibility.
  */
 extern int __semctl(int semid, int semnum, int cmd, void *);
@@ -44,6 +46,21 @@
 	va_list			ap;
 	int			rv;
 	int			val = 0;
+#if __DARWIN_UNIX03
+	struct __semid_ds_new	*ds;
+
+	va_start(ap, cmd);
+	if (cmd == SETVAL) {
+		val = va_arg(ap, int);
+		rv = __semctl(semid, semnum, cmd, (void *)val);
+	} else {
+		ds = va_arg(ap, struct __semid_ds_new *);
+		rv = __semctl(semid, semnum, cmd, (void *)ds);
+	}
+	va_end(ap);
+
+	return rv;
+#else	/* !__DARWIN_UNIX03 */
 	struct __semid_ds_new	ds;
 	struct __semid_ds_new	*ds_new = &ds;
 	struct __semid_ds_old   *ds_old = NULL;
@@ -119,4 +136,5 @@
 	}
 
 	return (rv);
+#endif	/* !__DARWIN_UNIX03 */
 }