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

Fix the -DTHREADSAFE=OFF build #5690

Merged
merged 1 commit into from
Nov 21, 2020

Conversation

lhchavez
Copy link
Contributor

@lhchavez lhchavez commented Oct 31, 2020

This change avoids using the (void)0 construct for some of the mutex
#defines, since that makes the "return type" of those "functions" to
be void instead of int.

@lhchavez
Copy link
Contributor Author

oops!

@ethomson
Copy link
Member

ethomson commented Nov 2, 2020

It should be returning an int? Is there a platform where it's not?

our win32 function returns an int

posix is just a define for pthread which returns an int

and the no-thread version should be 0

@lhchavez
Copy link
Contributor Author

lhchavez commented Nov 2, 2020

It should be returning an int? Is there a platform where it's not?

[...]

and the no-thread version should be 0

the no-thread version! that's a void, not an int. i think the solution is to avoid using the (void)0 construct and instead use a real inline function that returns 0.

This change avoids using the `(void)0` construct for some of the mutex
`#define`s, since that makes the "return type" of those "functions" to
be `void` instead of `int`.
@lhchavez lhchavez force-pushed the fix-filelimit-compile-error branch from e78908e to aa532e2 Compare November 2, 2020 13:29
@lhchavez lhchavez changed the title Avoid checking the result of git_mutex_unlock() Fix the -DTHREADSAFE=OFF build Nov 2, 2020
@ethomson
Copy link
Member

ethomson commented Nov 2, 2020

the no-thread version! that's a void, not an int. i think the solution is to avoid using the (void)0 construct and instead use a real inline function that returns 0.

ah so it is. i focused on the 0 and didn't think about the cast in front of it. i think an inline function that returns 0 makes sense. certainly it's easier to reason about than what's there. 😢

@@ -235,37 +235,38 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)

#else

GIT_INLINE(int) git_threads_global_init(void) { return 0; }
GIT_INLINE(int) git___noop(void) { return 0; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

couldn't think of a better name. also, lmk if we need to do something clever to explicitly mark the arguments as unused (right now it's a non-issue on my machine).

@ethomson
Copy link
Member

Thanks for this!

@ethomson ethomson merged commit a6d151b into libgit2:master Nov 21, 2020
@ethomson ethomson mentioned this pull request Jun 20, 2021
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