|
From: | James Aspinwall |
Subject: | [libmicrohttpd] Problems compiling in OSX with CLOCK_MONOTONIC. |
Date: | Mon, 23 Sep 2013 14:18:53 -0400 |
I am having problems compiling in OSX because CLOCK_MONOTONIC is missing. I get the following error: gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/include/plibc -I../.. -I../../src/include -I../../src/applicationlayer -DDATA_DIR=\"../../src/datadir/\" -no-cpp-precomp -fno-common -fno-strict-aliasing -g -O2 -MT proxy.o -MD -MP -MF .deps/proxy.Tpo -c -o proxy.o proxy.c proxy.c: In function ‘parse_uri’: proxy.c:247: warning: field precision should have type ‘int’, but argument 3 has type ‘regoff_t’ proxy.c:248: warning: field precision should have type ‘int’, but argument 3 has type ‘regoff_t’ proxy.c:249: warning: field precision should have type ‘int’, but argument 3 has type ‘regoff_t’ proxy.c:250: warning: field precision should have type ‘int’, but argument 3 has type ‘regoff_t’ proxy.c:251: warning: field precision should have type ‘int’, but argument 3 has type ‘regoff_t’ proxy.c:252: warning: field precision should have type ‘int’, but argument 3 has type ‘regoff_t’ proxy.c: In function ‘run’: proxy.c:1165: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function) proxy.c:1165: error: (Each undeclared identifier is reported only once proxy.c:1165: error: for each function it appears in.) make[4]: *** [proxy.o] Error 1 make[3]: *** [all-recursive] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 I googled the problem and I saw the following comment: ---------------------------------------------------------------------------------------------------------------- CLOCK_MONOTONIC is not available on OS X. Also, isn't CLOCK_MONOTONIC_RAW fetching the counter from rdtsc instruction on x86? (And therefore can go backwards in time if your process is migrated to another CPU). Keep in mind, also, that the CLOCK_MONOTONIC is not part of the core POSIX standard, so OS X is technically "compliant" even though they didn't implement it. Add this to a list of annoyances, such as no pthread_cond_timed_wait(). You can, however, get a monotonic clock by getting access to the clock service on mach. By audidude 23 days ago No CLOCK_MONOTONIC in OS X? In a David Tennant voice: Wait, what?? What?! ~$ grep CLOCK_MONOTONIC /usr/include -rn ~$ Ahh, it's in the POSIX realtime extension... Dammit. Apparently [1] one solution would be to #IFDEF DARWIN the following, as on Darwin SYSTEM_CLOCK is supposed to be a monotonic boot clock. #include <mach/clock.h> #include <mach/mach.h> ... clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); clock_get_time(cclock, &mts); mach_port_deallocate(mach_task_self(), cclock); Not sure if processor affinity would affect that code (don't have time right now to do the in depth reading on it), but you could always set affinity to CPU0. Though then you'd have to make sure to run the sudo'd command as a child process and appropriately reset affinity to default before a call to exec... By benjamincburns 23 days ago On OS X, use mach_absolute_time() to get a monotonic clock. A lot of APIs in OS X use the monotonic clock, e.g. CoreAnimation wraps mach_absolute_time() as CACurrentMediaTime() and uses that to calculate animation start times and delays. By simscitizen 23 days ago ---------------------------------------------------------------------------------------------------------------- Configure output is: ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... ./install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gawk... (cached) awk checking whether ln -s works... yes checking whether make sets $(MAKE)... (cached) yes checking build system type... x86_64-apple-darwin12.5.0 checking host system type... x86_64-apple-darwin12.5.0 checking for style of include used by make... GNU checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking dependency style of gcc... gcc3 checking whether gcc and cc understand -c and -o together... yes checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld checking if the linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) is GNU ld... no checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm checking the name lister (/usr/bin/nm) interface... BSD nm checking the maximum length of command line arguments... 196608 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert x86_64-apple-darwin12.5.0 file names to x86_64-apple-darwin12.5.0 format... func_convert_file_noop checking how to convert x86_64-apple-darwin12.5.0 file names to toolchain format... func_convert_file_noop checking for /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... dlltool checking how to associate runtime and link libraries... printf %s\n checking for ar... ar checking for archiver @FILE support... no checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm output from gcc object... ok checking for sysroot... no checking for mt... no checking if : is a manifest tool... no checking for dsymutil... dsymutil checking for nmedit... nmedit checking for lipo... lipo checking for otool... otool checking for otool64... no checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking for -force_load linker flag... yes checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin12.5.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking whether byte ordering is bigendian... no checking for struct sockaddr_in.sin_len... yes checking for curl... true yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking math.h usability... yes checking math.h presence... yes checking for math.h... yes checking errno.h usability... yes checking errno.h presence... yes checking for errno.h... yes checking limits.h usability... yes checking limits.h presence... yes checking for limits.h... yes checking stdio.h usability... yes checking stdio.h presence... yes checking for stdio.h... yes checking locale.h usability... yes checking locale.h presence... yes checking for locale.h... yes checking for sys/stat.h... (cached) yes checking for sys/types.h... (cached) yes checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes checking for sys/types.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking sys/msg.h usability... yes checking sys/msg.h presence... yes checking for sys/msg.h... yes checking netdb.h usability... yes checking netdb.h presence... yes checking for netdb.h... yes checking netinet/in.h usability... yes checking netinet/in.h presence... yes checking for netinet/in.h... yes checking netinet/tcp.h usability... yes checking netinet/tcp.h presence... yes checking for netinet/tcp.h... yes checking time.h usability... yes checking time.h presence... yes checking for time.h... yes checking sys/socket.h usability... yes checking sys/socket.h presence... yes checking for sys/socket.h... yes checking sys/mman.h usability... yes checking sys/mman.h presence... yes checking for sys/mman.h... yes checking arpa/inet.h usability... yes checking arpa/inet.h presence... yes checking for arpa/inet.h... yes checking sys/select.h usability... yes checking sys/select.h presence... yes checking for sys/select.h... yes checking poll.h usability... yes checking poll.h presence... yes checking for poll.h... yes checking winsock2.h usability... no checking winsock2.h presence... no checking for winsock2.h... no checking ws2tcpip.h usability... no checking ws2tcpip.h presence... no checking for ws2tcpip.h... no checking search.h usability... yes checking search.h presence... yes checking for search.h... yes checking plibc.h usability... no checking plibc.h presence... no checking for plibc.h... no checking for memmem... yes checking for accept4... no checking for library containing clock_gettime... no checking for IPv6... yes checking whether TCP_CORK is declared... no checking whether TCP_NOPUSH is declared... yes checking whether to use libcurl for testing... yes checking for gawk... (cached) awk checking for curl-config... /usr/bin/curl-config checking for the version of libcurl... 7.24.0 checking whether libcurl is usable... yes checking for curl_free... yes checking for magic_open -lmagic... checking for magic_open in -lmagic... no checking whether to support libmicrospdy... yes checking openssl/err.h usability... yes checking openssl/err.h presence... yes checking for openssl/err.h... yes checking whether we have OpenSSL and thus can support libmicrospdy... yes checking openssl/evp.h usability... yes checking openssl/evp.h presence... yes checking for openssl/evp.h... yes checking openssl/rsa.h usability... yes checking openssl/rsa.h presence... yes checking for openssl/rsa.h... yes checking openssl/rand.h usability... yes checking openssl/rand.h presence... yes checking for openssl/rand.h... yes checking for openssl/err.h... (cached) yes checking openssl/sha.h usability... yes checking openssl/sha.h presence... yes checking for openssl/sha.h... yes checking openssl/pem.h usability... yes checking openssl/pem.h presence... yes checking for openssl/pem.h... yes checking openssl/engine.h usability... yes checking openssl/engine.h presence... yes checking for openssl/engine.h... yes checking for SHA1_Init in -lcrypto... yes checking for dlopen... yes checking for SSL_library_init... no checking for SSL_library_init in -lssl... yes checking spdylay/spdylay.h usability... no checking spdylay/spdylay.h presence... no checking for spdylay/spdylay.h... no checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... no checking for _LARGEFILE_SOURCE value needed for large files... no checking whether to generate error messages... yes checking whether to enable postprocessor... checking for zzuf... 0 checking for socat... 0 checking for libgcrypt-config... no checking for LIBGCRYPT - version >= 1.2.2... no checking for gnutls... --with-gnutls not specified checking gnutls/gnutls.h usability... no checking gnutls/gnutls.h presence... no checking for gnutls/gnutls.h... no checking whether to support HTTPS... no (lacking libgcrypt or libgnutls) checking whether to support HTTP basic authentication... yes checking whether to support HTTP digest authentication... yes checking whether -export-symbols-regex works... yes checking whether to compile with support for code coverage analysis... no configure: creating ./config.status config.status: creating libmicrohttpd.pc config.status: creating Makefile config.status: creating contrib/Makefile config.status: creating doc/Makefile config.status: creating doc/doxygen/Makefile config.status: creating doc/examples/Makefile config.status: creating m4/Makefile config.status: creating src/Makefile config.status: creating src/include/Makefile config.status: creating src/include/plibc/Makefile config.status: creating src/microhttpd/Makefile config.status: creating src/microspdy/Makefile config.status: creating src/spdy2http/Makefile config.status: creating src/examples/Makefile config.status: creating src/testcurl/Makefile config.status: creating src/testcurl/https/Makefile config.status: creating src/testspdy/Makefile config.status: creating src/testzzuf/Makefile config.status: creating MHD_config.h config.status: executing depfiles commands config.status: executing libtool commands configure: Configuration Summary: Operating System: darwin12.5.0 libgcrypt: no, HTTPS will not be built libcurl (testing): yes Target directory: /usr/local Messages: yes Basic auth.: yes Digest auth.: yes Postproc: yes HTTPS support: no (lacking libgcrypt or libgnutls) epoll support: libmicrospdy: yes spdylay (testing): no configure: License : LGPL or eCos Thanks for any help. James |
[Prev in Thread] | Current Thread | [Next in Thread] |