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

freebsd gettimeofday is not defined #184

Closed
gperciva opened this issue Aug 15, 2016 · 1 comment
Closed

freebsd gettimeofday is not defined #184

gperciva opened this issue Aug 15, 2016 · 1 comment

Comments

@gperciva
Copy link
Member

Nitpicky build failure on freebsd 10.3-RELEASE-p4. A normal make works just fine; doing clang -Weverything -Werror -Wno-a-bunch-of-specific-warnings produces this:

../libcperciva/util/monoclock.c:41:6: error: implicit declaration of function
      'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if (gettimeofday(tv, NULL)) {

gettimeofday() is hidden inside #if __XSI_VISIBLE in /usr/include/sys/time.h. This isn't necessarily a huge problem since:

Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html

and monoclock.c tries to use clock_gettime() first. However, in order to work around OSX failing:

All implementations shall support a clock_id of CLOCK_REALTIME as defined in <time.h>
http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html

We defined -DPOSIXFAIL_CLOCK_REALTIME in Makefile.am in 00bf976.

There's obviously a few solutions we could use here:

  • enable XSI stuff in the Tarsnap build.
  • use more intelligent checking to see whether we need -DPOSIXFAIL_CLOCK_REALTIME or not.
  • fancier code in monoclock.c. For example, scrypt selects clocktouse by going through CLOCK_VIRTUAL, CLOCK_MONOTONIC, CLOCK_REALTIME, and if all those fail, it bails. If that works on OSX, maybe we could do a similar thing in monoclock.c?
  • stop testing with -Weverything -Werror. :)
@gperciva
Copy link
Member Author

gperciva commented Apr 1, 2017

Fixed in d890938, when we enabled XSI stuff.

@gperciva gperciva closed this as completed Apr 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant