Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phtread_ T different definitions exist on different platforms #715

Closed
wants to merge 2 commits into from

Conversation

ljx0305
Copy link

@ljx0305 ljx0305 commented Oct 29, 2021

linux posix pthread_t Variable type:
typedef unsigned long int pthread_t;

window posix pthread_t Variable type:
/*

  • 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;

Will cause compilation to occur:
librabbitmq\amqp_openssl.c:605: error: aggregate value used where an integer was expected

由于window平台pthread_win32下的 pthread_t与posix的pthread_t的不同。
你看到的这个文章来自于http://www.cnblogs.com/ayanmw
我以为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个字节了。

不知道还有没有其他的不同之处。至少暂时 还是非常好的。
编译出现
error: aggregate value used where an integer was expected
修正之前改错的地方
@@ -583,8 +583,8 @@ void amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize) {
CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex));
}

static unsigned long ssl_threadid_callback(void) {
return (unsigned long)pthread_self();
static pthread_t ssl_threadid_callback(void) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clang-format check is failing on this, please run clang-format on this changed file.

@@ -30,7 +30,7 @@
static int initialize_ssl_and_increment_connections(void);
static int decrement_ssl_connections(void);

static unsigned long ssl_threadid_callback(void);
static pthread_t ssl_threadid_callback(void);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about this declaration is causing the win32 build to fail (see checks).

Please resolve that issue.

@alanxz
Copy link
Owner

alanxz commented Feb 2, 2023

As of #753, the code affected by this PR no longer exists, as such this should not be needed.

@alanxz alanxz closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants