-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Thread namespacing #3830
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
Thread namespacing #3830
Conversation
a94fc26
to
5c6c053
Compare
} native; | ||
} git_rwlock; | ||
|
||
#define PTHREAD_MUTEX_INITIALIZER {(void*)-1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest we rename this, but I think it's wholly unused so perhaps we should just remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will remove.
Thanks for taking care of this. I made a couple of quite trivial comments, but this is great. 😀 |
The function pthread_num_processors_np is currently unused and superseded by the function `git_online_cpus`. Remove the function.
The old pthread-file did re-implement the pthreads API with exact symbol matching. As the thread-abstraction has now been split up between Unix- and Windows-specific files within the `git_` namespace to avoid symbol-clashes between libgit2 and pthreads, the rewritten wrappers have nothing to do with pthreads anymore. Rename the Windows-specific pthread-files to honor this change.
5c6c053
to
aab266c
Compare
New version fixes comments by @ethomson. Thanks for your reviews |
Thanks again, this is great. |
This PR aims to fix the namespacing-issue in issue #3825. The Windows-specific pthreads.c source file tries to re-implement the API exposed by pthreads by implementing many of the pthread-symbols with Windows-specific threading code. This unfortunately results in runtime errors when a user links his application to both libgit2 and winpthreads, causing one of both libraries to override symbols of the other library, causing inconsistencies.
Fix the issue by introducing proper namespacing to our threading API. Instead of trying to re-implement all functions, implement functions inside the
git_
namespace and adjust the#define
s in Unix-specific code.This solves the part where linking against both libraries causes runtime errors. What is still missing is to allow Windows-users to link libgit2 not against the internal thread API but against winpthread provided by MinGW/MSYS2. This will follow later either by updating this PR or creating a new one if this one got merged already.