Skip to contentSkip to conversation

semctl: wrong type on semid_ds

DISCUSSION Simone Piccardi 2 participants 2 messages May 4, 2013 – Jun 3, 2013 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

Hi,

in the semctl(2) man page (2012-05-31 version) I found a definitions of semid_ds with:

...
unsigned short sem_nsems; /* No. of semaphores in set */
...

but that's defined as:

unsigned long int sem_nsems; /* number of semaphores in set */

in /usr/include/bits/sem.h (at least in my debian)

I also found it defined as:

int sem_nsems; /* no. of semaphores in array */

in /usr/src/linux-3.7.6/include/linux/sem.h

Regards
Simone

Signature · 8 lines
Simone Piccardi - KeyID:2A972F9D - JabberID:[email protected]
http://piccardi.gnulinux.it - http://www.fountainpen.it
Prima ti ignorano, poi ti deridono, poi ti combattono.  Poi vinci.
                                                 M. K. Ghandi
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 13 lines · Simone Piccardi

Hi,

in the semctl(2) man page (2012-05-31 version) I found a definitions of semid_ds with:

...
unsigned short sem_nsems; /* No. of semaphores in set */
...

but that's defined as:

unsigned long int sem_nsems; /* number of semaphores in set */

Quoted 8 lines

in /usr/include/bits/sem.h (at least in my debian)

I also found it defined as:

int sem_nsems; /* no. of semaphores in array */

in /usr/src/linux-3.7.6/include/linux/sem.h

Thanks Simone. You're right. I applied the patch below.

Cheers,

Michael

man2/semctl.2 +12 -1
index d1bc542..c9124d7 100644
@@ -88,7 +88,7 @@ struct semid_ds {
     struct ipc_perm sem_perm;  /* Ownership and permissions */
     time_t          sem_otime; /* Last semop time */
     time_t          sem_ctime; /* Last change time */
-    unsigned short  sem_nsems; /* No. of semaphores in set */
+    unsigned long   sem_nsems; /* No. of semaphores in set */
 };
 .in
 .fi
@@ -462,6 +462,17 @@ or greater than the implementation limit
 .SH CONFORMING TO
 SVr4, POSIX.1-2001.
 .\" SVr4 documents more error conditions EINVAL and EOVERFLOW.
+
+POSIX.1-2001 specifies the
+.I sem_nsems
+field of the
+.I semid_ds
+structure as having the type
+.IR "unsigned\ short" ,
+and the field is so defined on most other systems.
+It was also so defined on Linux 2.2 and earlier,
+but, since Linux 2.4, the field has the type
+.IR "unsigned\ long" .
 .SH NOTES
 The inclusion of
 .I <sys/types.h>

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html