Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 56058 - definiton of sem_t in glibc-2.3.3.20040420 changed to union from struct
Summary: definiton of sem_t in glibc-2.3.3.20040420 changed to union from struct
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High major
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-04 07:54 UTC by Ákos Maróy
Modified: 2004-11-23 22:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ákos Maróy 2004-07-04 07:54:46 UTC
the definition of the type sem_t in /usr/include/semaphore.h was in glibc-2.3.2 a struct:

/* System specific semaphore definition.  */
typedef struct
{
  struct _pthread_fastlock __sem_lock;
  int __sem_value;
  _pthread_descr __sem_waiting;
} sem_t;


and now it's a union (now it's actually in /usr/include/bist/semaphore.h, included from /usr/include/semaphore.h):

typedef union
{
  char __size[__SIZEOF_SEM_T];
  long int __align;
} sem_t;


whereas this might not seem a big deal, some code fails to compile after this change. for example, I'm having problem with the helix community source code at https://helixcommunity.org/ , where they are subclassing sem_t:

struct HXsem_t : public sem_t
{
    char padding[64]; /* Flawfinder: ignore */ // different linux versions have different binary reps blechhhh!
}; 

which works with sem_t being a struct, but does not work with sem_t being a union.

Reproducible: Always
Steps to Reproduce:
1. emerge glibc-2.3.3
2. try to compile helix sources (or just the class HXsem_t listed above)
3. see the error message:

error: base type `sem_t' fails to be a struct or class type 

Actual Results:  
the code fails to compile, which compiled fine with glic-2.3.2

Expected Results:  
the code should compile

I don't really know whos fault is this. I looked at the GNU libc documentation
at http://www.gnu.org/software/libc/manual/html_mono/libc.html , and it does not
say anything about sem_t, other than lists it as a parameter type for semaphore
calls. OTOH, glibc-2.3.3 is still not officially out, and there may be a reason
for that. this it's strange that it's already x86, not ~x86.
Comment 1 Ákos Maróy 2004-07-04 12:38:31 UTC
it seems that the difference in the semaphore.h header file is not related to the glibc version, but it's related to the nptl USE flag - if nptl is set, the union declaration is used, if not set, the old one is used.

still, it's an issue that causes compilation problems.
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2004-07-04 13:20:59 UTC
I cannot see that that is going to change soon - get the helix people to
fix their code for nptl.
Comment 3 Ákos Maróy 2004-07-09 01:14:30 UTC
the question is: is there a macro or any other compile-time method the tell if the glibc was compiled with NPTL support? in this case, it would be fairly easy to fix the helix code, with #ifdefs, for example.
Comment 4 SpanKY gentoo-dev 2004-11-23 22:14:35 UTC
yeah, the way sem_t is defined should not affect compilation of code

if it does, that code is wrong

linuxthreads made sem_t a struct, nptl uses union

in terms of checking NPTL vs linuxthreads, i dont believe any official thing exists since the two should be drop-in replacements for each other