Skip to content

Fix the -DTHREADSAFE=OFF build - #5690

Merged
ethomson merged 1 commit into
libgit2:masterfrom
lhchavez:fix-filelimit-compile-error
Nov 21, 2020
Merged

Fix the -DTHREADSAFE=OFF build#5690
ethomson merged 1 commit into
libgit2:masterfrom
lhchavez:fix-filelimit-compile-error

Conversation

@lhchavez

@lhchavez lhchavez commented Oct 31, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

oops!

@ethomson

ethomson commented Nov 2, 2020

Copy link
Copy Markdown
Member

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

lhchavez commented Nov 2, 2020

Copy link
Copy Markdown
Contributor Author

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

ethomson commented Nov 2, 2020

Copy link
Copy Markdown
Member

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. 😢

Comment thread src/thread-utils.h
#else

GIT_INLINE(int) git_threads_global_init(void) { return 0; }
GIT_INLINE(int) git___noop(void) { return 0; }

Copy link
Copy Markdown
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
Copy Markdown
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