diff --git a/make-linux.mk b/make-linux.mk index cdfb52bab..eb77326ed 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -66,9 +66,9 @@ node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CXXFLAGS=-Wall -O2 - else override DEFS+=-D_FORTIFY_SOURCE=2 CFLAGS?=-O3 -fstack-protector - override CFLAGS+=-Wall -Wno-deprecated -Werror -fPIE -pthread $(INCLUDES) -DNDEBUG $(DEFS) + override CFLAGS+=-Wall -Wno-deprecated -fPIE -pthread $(INCLUDES) -DNDEBUG $(DEFS) CXXFLAGS?=-O3 -fstack-protector - override CXXFLAGS+=-Wall -Wno-deprecated -Werror -Wno-unused-result -Wreorder -fPIE -std=c++11 -pthread $(INCLUDES) -DNDEBUG $(DEFS) + override CXXFLAGS+=-Wall -Wno-deprecated -Wno-unused-result -Wreorder -fPIE -std=c++11 -pthread $(INCLUDES) -DNDEBUG $(DEFS) override LDFLAGS+=-pie -Wl,-z,relro,-z,now STRIP?=strip STRIP+=--strip-all @@ -211,10 +211,10 @@ endif all: one #ext/x64-salsa2012-asm/salsa2012.o: -# $(CC) $(CFLAGS) -c ext/x64-salsa2012-asm/salsa2012.s -o ext/x64-salsa2012-asm/salsa2012.o +# $(CC) -c ext/x64-salsa2012-asm/salsa2012.s -o ext/x64-salsa2012-asm/salsa2012.o #ext/arm32-neon-salsa2012-asm/salsa2012.o: -# $(CC) $(CFLAGS) -c ext/arm32-neon-salsa2012-asm/salsa2012.s -o ext/arm32-neon-salsa2012-asm/salsa2012.o +# $(CC) -c ext/arm32-neon-salsa2012-asm/salsa2012.s -o ext/arm32-neon-salsa2012-asm/salsa2012.o one: $(CORE_OBJS) $(ONE_OBJS) one.o $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LDLIBS) diff --git a/osdep/OSUtils.hpp b/osdep/OSUtils.hpp index 4b9ee8936..dff7df868 100644 --- a/osdep/OSUtils.hpp +++ b/osdep/OSUtils.hpp @@ -51,6 +51,9 @@ #include #include #include +#ifdef __LINUX__ +#include +#endif #endif #include "../ext/json/json.hpp" @@ -185,7 +188,6 @@ public: * @return Current time in milliseconds since epoch */ static inline uint64_t now() - throw() { #ifdef __WINDOWS__ FILETIME ft; @@ -198,33 +200,15 @@ public: return ( ((tmp.QuadPart - 116444736000000000ULL) / 10000L) + st.wMilliseconds ); #else struct timeval tv; +#ifdef __LINUX__ + syscall(SYS_gettimeofday,&tv,0); /* fix for musl libc broken gettimeofday bug */ +#else gettimeofday(&tv,(struct timezone *)0); +#endif return ( (1000ULL * (uint64_t)tv.tv_sec) + (uint64_t)(tv.tv_usec / 1000) ); #endif }; - /** - * @return Current time in seconds since epoch, to the highest available resolution - */ - static inline double nowf() - throw() - { -#ifdef __WINDOWS__ - FILETIME ft; - SYSTEMTIME st; - ULARGE_INTEGER tmp; - GetSystemTime(&st); - SystemTimeToFileTime(&st,&ft); - tmp.LowPart = ft.dwLowDateTime; - tmp.HighPart = ft.dwHighDateTime; - return (((double)(tmp.QuadPart - 116444736000000000ULL)) / 10000000.0); -#else - struct timeval tv; - gettimeofday(&tv,(struct timezone *)0); - return ( ((double)tv.tv_sec) + (((double)tv.tv_usec) / 1000000.0) ); -#endif - } - /** * Read the full contents of a file into a string buffer * diff --git a/selftest.cpp b/selftest.cpp index 209fe2034..759f39c13 100644 --- a/selftest.cpp +++ b/selftest.cpp @@ -1077,6 +1077,7 @@ int main(int argc,char **argv) */ std::cout << "[info] sizeof(void *) == " << sizeof(void *) << std::endl; + std::cout << "[info] OSUtils::now() == " << OSUtils::now() << std::endl; std::cout << "[info] hardware concurrency == " << std::thread::hardware_concurrency() << std::endl; std::cout << "[info] sizeof(NetworkConfig) == " << sizeof(ZeroTier::NetworkConfig) << std::endl;