我必须在 Haiku 开源项目的 pthread.h 中的 struct _pthread_rwlock 中找到一个未命名的联合。我以一些 C++ 知识(过去的继承、多态性和类)开始这项作业,但我发现我学到的东西对我的情况毫无帮助。我打开了头文件和一个名为 pthread_rwlock.cpp 的源文件,并试图寻找未命名的联合,但两个文件中似乎都没有联合。找到问题的正确方法是什么?
问问题
69 次
1 回答
0
在pthreads.h
中,您要查找的结构名为pthread_rwlock_t
。如果您向后跟踪包含文件,您将在 中看到以下内容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;
};
我假设这里的工会是您要寻找的工会。从我正在查看的版本(d06f5808)开始,工会不再是匿名的。
于 2013-02-26T02:00:34.797 回答