-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a fix for old game that use sem_timewait in an incorrect way
- Loading branch information
Showing
4 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c65c514
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.
The function
sem_timedwait
is defined as:int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
The second parameter is
const
so you shoudn't be modifying it (when__USE_TIME64_REDIRECTS
is not defined).c65c514
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 agree, but I don't see a case were that parameter is in a RO section, as it needs to be dynamic. Also, the function is just there to make the settings correct. Technicaly, it's the same timespec. It's done like that to avoid a copy in the likely case the timespec is correctly formed.
Did you see any issue with that hack that would require the use of a temporary timespec value?
c65c514
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 haven't seen any issue with the hack, but the calling program might be using the parameter after the call and making (reasonable) assumption that the function doesn't change the value.
If you want to avoid a copy, you could do something like this:
c65c514
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.
Sure, I can do that.
c65c514
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.
Ok, done with 7b8a6aa