Forum: CFEngine Help
Subject: Missing clockid_t on Mac OS 10.6.7
Author: sigurd.teigen
Link to topic: https://cfengine.com/forum/read.php?3,22711,22711#msg-22711
Hi,
$uname -a
Darwin kendall.local 10.7.4 Darwin Kernel Version 10.7.4: Mon Apr 18 21:24:17
PDT 2011; root:xnu-1504.14.12~3/RELEASE_X86_64 x86_64
Just tried to compile cfengine core trunk on snow leopard. ./configure's
clock_gettime check fails, causing the file pub/clock_gettime.c to be compiled.
Here's the contents of that file
01 #include
02
03 int clock_gettime(clockid_t clock_id, struct timespec *tp)
04 {
05 tp->tv_sec = time(NULL);
06 tv->tv_nsec = 0;
07 return 0;
08 }
This file doesn't compile for two reasons. First, in line 6, the pointer tv
does not exist. More interestingly, the ./configure clockid_t check fails. This
is taken care of by src/cf.defs.h where clockid_t is typedef'ed to an int. But
this file is not included by pub/clock_gettime, and root Makefile.am wants to
build pub before src, so it doesn't even work by accident.
Simply including "../src/cf.defs.h" works, but seems like a bad hack, running
the risk of circular dependencies in the future. Inlining
#ifndef HAVE_CLOCKID_T
typedef int clockid_t;
#endif
#if !HAVE_DECL_CLOCK_GETTIME
int clock_gettime(clockid_t clock_id,struct timespec *tp);
#endif
in pub/clock_gettime.c from src/cf.defs.h works without generating any warnings
in gcc or clang, which i take to mean that re-typedefing doesn't generate
warnings.
btw, I also ran into what I think is the same as this issue
https://cfengine.org/pipermail/help-cfengine/2010-January/007105.html
It was caused by configure failing to find snprintf and some related functions,
despite these being present in /usr/include, so the problem seemed to have been
redeclaration as a result of a false negative from autoconf. For some reason,
my autoconf now finds the functions and I can't reproduce the issue.
Thanks,
Sigurd
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine