I have to find an unnamed union in struct _pthread_rwlock in pthread.h in the Haiku open source project. I began this assignment with some knowledge of c++ (past inheritance, polymorphism, and classes), but I find that what I learned do not help at all in my situation. I've opened the header file, and a source file named pthread_rwlock.cpp, and tried to look for the unnamed union, but there seems to be no unions in either file. What would be the correct way to find the problem?
Asked
Active
Viewed 76 times
1 Answers
0
In pthreads.h
, the structure you are looking for goes by the name of pthread_rwlock_t
. If you follow the include files backwards, you'll see the following in sys/types.h
:
typedef struct _pthread_rwlock pthread_rwlock_t;
...
struct _pthread_rwlock {
__haiku_std_uint32 flags;
__haiku_std_int32 owner;
union {
struct {
__haiku_std_int32 sem;
} shared;
struct {
__haiku_std_int32 lock_sem;
__haiku_std_int32 lock_count;
__haiku_std_int32 reader_count;
__haiku_std_int32 writer_count;
void* waiters[2];
} local;
} u;
};
I'm assuming that the union in here is the one that you are looking for. As of the version I'm looking at (d06f5808), the union is no longer anonymous.

bta
- 43,959
- 6
- 69
- 99