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

libfaketime.c: wrap timespec_get in TIME_UTC macro #415

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

usertam
Copy link
Contributor

@usertam usertam commented Dec 19, 2022

Function timespec_get is not guaranteed to be declared in MacOS since its standard library is non-conformance to modern standards. Therefore, skip patching timespec_get if it is undeclared by the standard library.

The detection of timespec_get is based on the conjecture that the macro TIME_UTC is only defined when timespec_get is declared.


This PR is motivated by errors I faced when building on x86_64-darwin:

libfaketime.c:2345:29: error: use of undeclared identifier 'timespec_get'
  DONT_FAKE_TIME(result = (*timespec_get)(ts, base));
                            ^
libfaketime.c:4022:38: error: use of undeclared identifier 'timespec_get'
  DYLD_INTERPOSE(macos_timespec_get, timespec_get);
                                     ^

Typing the error into google yielded this: 1, then I got more information and came up with this by looking at others' bits. 2 3 4

Function `timespec_get` is not guaranteed to be declared in MacOS
since its standard library is non-conformance to modern standards.
Therefore, skip patching `timespec_get` if it is undeclared by the
standard library.

The detection of `timespec_get` is based on the conjecture that the
macro `TIME_UTC` is only defined when `timespec_get` is declared.
@wolfcw
Copy link
Owner

wolfcw commented Dec 20, 2022

Thanks for catching this and the PR!

@wolfcw wolfcw merged commit de37190 into wolfcw:master Dec 20, 2022
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