pthread_win32下的 pthread_t与posix的pthread_t的不同。

我以为pthread_win32 完全兼容posix 的pthread呢,结果发现,至少有一个地方不同,pthread_t的类型。

posix下pthread_t的类型是:

typedef unsigned long int pthread_t;
//come from /usr/include/bits/pthread.h
//用途:pthread_t用于声明线程ID。
//sizeof (pthread_t) =4;

而pthread_win32 是:

/*
 * Generic handle type - intended to extend uniqueness beyond
 * that available with a simple pointer. It should scale for either
 * IA-32 or IA-64.
 */
typedef struct {
    void * p;                   /* Pointer to actual object */
    unsigned int x;             /* Extra information - reuse count etc */
} ptw32_handle_t;

typedef ptw32_handle_t pthread_t;

这样就存在一点不兼容的问题了。

void * p 可以看做是posix的pthread_t 的 类型,但是多了一个 x,额外的信息,重用计数器。其大小就是4个字节了。

不知道还有没有其他的不同之处。至少暂时 还是非常好的。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值