summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-05-09 21:21:56 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-05-09 21:21:56 -0700
commitd297d8fe2eccf8ca001d28a950152fc3bec992b5 (patch)
treec19542a8fea9bb0d6cdaa1398cee11a316196a23
parentf479b76772ecefde3e01fd5c2933ed0536922fd6 (diff)
downloadinfinitytier-d297d8fe2eccf8ca001d28a950152fc3bec992b5.tar.gz
infinitytier-d297d8fe2eccf8ca001d28a950152fc3bec992b5.zip
Musl fix
-rw-r--r--make-linux.mk8
-rw-r--r--osdep/OSUtils.hpp30
-rw-r--r--selftest.cpp1
3 files changed, 12 insertions, 27 deletions
diff --git a/make-linux.mk b/make-linux.mk
index cdfb52ba..eb77326e 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 4b9ee893..dff7df86 100644
--- a/osdep/OSUtils.hpp
+++ b/osdep/OSUtils.hpp
@@ -51,6 +51,9 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <arpa/inet.h>
+#ifdef __LINUX__
+#include <sys/syscall.h>
+#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,34 +200,16 @@ 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
*
* The buffer isn't cleared, so if it already contains data the file's data will
diff --git a/selftest.cpp b/selftest.cpp
index 209fe203..759f39c1 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;