[haiku-gsoc] Re: Xsi semaphorses: patch #1

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Sun, 13 Jul 2008 20:51:42 +0200

Hi,

Salvatore Benedetto wrote:
> the attached is a first implementation of the xsi semaphore. Althought 
> not complete, it has everything it needs to get bonnie++ up and running 
> (which by they way I already ran and it already corrupted my haiku 
> partition on vmware).

I have a question about the patch:

+#define RETURN_AND_SET_ERRNO(status) \
+{ \
+       if (status < 0) { \
+               errno = status; \
+               return -1; \
+       } \
+       return status; \
+}

[...]

+int
+semget(key_t key, int num_sems, int sem_flags)
+{
+       RETURN_AND_SET_ERRNO(_kern_xsi_semget(key, num_sems, sem_flags));
+}
+
+
+int
+semctl(int semId, int sem_num, int command, ...)
+{
+       union semun arg;
+       va_list args;
+
+       switch (command) {
+               case GETVAL:
+               case GETPID:
+               case GETNCNT:
+               case GETZCNT:
+               case IPC_RMID:
+                       RETURN_AND_SET_ERRNO(_kern_xsi_semctl(semId, sem_num, 
command, 0));

[...]

With how the macro "RETURN_AND_SET_ERRNO" is defined, wouldn't it result in 
the function that you pass to the marco being called twice?

Best regards,
-Stephan

Other related posts: