From 65c5e984e7974771d93e76bc723e31c35d2f4d07 Mon Sep 17 00:00:00 2001 From: Ren RenJuan Date: Wed, 15 Jan 2014 00:52:58 +0000 Subject: [PATCH] osx --- ACTK1_0/Makefile | 16 ++++++++-------- ACTK1_0/session/Timer.cpp | 28 ++++++++++++++++++++++++++-- ACTK1_0/session/Timer.hpp | 8 +++++++- AusRegCliever/Makefile | 26 +++++++++++++++++++++----- 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/ACTK1_0/Makefile b/ACTK1_0/Makefile index 1541904..9ca3ecb 100644 --- a/ACTK1_0/Makefile +++ b/ACTK1_0/Makefile @@ -1,9 +1,9 @@ ################################################## # Makefile for building lib and main test routine# ################################################## -LOCATION=debian7 -#LOCATION=debian6 -#LOCATION=osx10.8 +LOCATION=DEBIAN_7 +#LOCATION=DEBIAN_6 +#LOCATION=OSX_10_8 SYSTEM = $(shell uname -s) @@ -14,10 +14,10 @@ CC = gcc PRODORDEV += -ggdb3 CXXFLAGS = $(PRODORDEV) -Wall -Wpointer-arith -Wcast-qual -D_REENTRANT -fPIC -CPPFLAGS = -fPIC -D_GNU_SOURCE -DACLOC=$(LOCATION) -CXXFLAGS += -D_GNU_SOURCE -O0 -DACLOC=$(LOCATION) +CPPFLAGS = -fPIC -D_GNU_SOURCE -D$(LOCATION) +CXXFLAGS += -D_GNU_SOURCE -O0 -D$(LOCATION) -ifeq ($(LOCATION),debian7) +ifeq ($(LOCATION),DEBIAN_7) XALAN_LIB_DIR = /usr/local/lib/ XALAN_LIB = xalan-c XALAN_INC_DIR = /usr/local/include/xalanc @@ -25,7 +25,7 @@ XERCES_LIB_DIR = /usr/local/lib/ XERCES_LIB = xerces-c XERCES_INC_DIR = /usr/local/include/xercesc endif -ifeq ($(LOCATION),debian6) +ifeq ($(LOCATION),DEBIAN_6) XALAN_LIB_DIR = /usr/lib/ XALAN_LIB = xalan-c XALAN_INC_DIR = /usr/include/xalanc @@ -33,7 +33,7 @@ XERCES_LIB_DIR = /usr/lib/ XERCES_LIB = xerces-c XERCES_INC_DIR = /usr/include/xercesc endif -ifeq ($(LOCATION),osx10.8) +ifeq ($(LOCATION),OSX_10_8) XALAN_LIB_DIR = /opt/local/lib/ XALAN_LIB = xalan-c XALAN_INC_DIR = /opt/local/include/ diff --git a/ACTK1_0/session/Timer.cpp b/ACTK1_0/session/Timer.cpp index d049f60..35c9e94 100644 --- a/ACTK1_0/session/Timer.cpp +++ b/ACTK1_0/session/Timer.cpp @@ -11,14 +11,36 @@ long long Timer::now() { if (!useRealTime) return fixedTime; struct timespec ts; +#ifndef OSX_10_8 clock_gettime(Timer::getClock(), &ts); +#else + clock_get_time(Timer::getClock(), &ts); +#endif return static_cast(ts.tv_sec) * 1000 + static_cast(ts.tv_nsec) / 1000000; } - +#ifndef OSX_10_8 clockid_t Timer::getClock() { return CLOCK_REALTIME; } +#else +clock_t Timer::getClock() +{ + clock_t value; + struct timespec ts; + + #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time + clock_serv_t cclock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + ts.tv_sec = mts.tv_sec; + ts.tv_nsec = mts.tv_nsec; + return value; + #endif +} +#endif long long Timer::msDiff(long long compareTime) { @@ -64,10 +86,12 @@ struct timespec Timer::msOffset2abs(long long msOffset) struct timespec now; struct timespec until; - +#ifndef OSX_10_8 clock_gettime(Timer::getClock(), &now); until.tv_sec = now.tv_sec + msOffset / ms_per_sec; until.tv_nsec = now.tv_nsec + msOffset * ns_per_ms; +#else +#endif return until; } diff --git a/ACTK1_0/session/Timer.hpp b/ACTK1_0/session/Timer.hpp index 4aff21b..08d6540 100644 --- a/ACTK1_0/session/Timer.hpp +++ b/ACTK1_0/session/Timer.hpp @@ -4,6 +4,11 @@ #include "common/ParameterSyntaxException.hpp" #include +#ifdef __MACH__ +#include +#include +#endif + class Timer { public: @@ -29,7 +34,8 @@ public: static struct timespec msOffset2abs(long long msOffset); private: -#if ACLOC != osx10.8 + +#ifndef OSX_10_8 static clockid_t getClock(); #else static clock_t getClock(); diff --git a/AusRegCliever/Makefile b/AusRegCliever/Makefile index 60afbeb..9994791 100644 --- a/AusRegCliever/Makefile +++ b/AusRegCliever/Makefile @@ -1,4 +1,6 @@ -LOCATION=debian7 +LOCATION=DEBIAN_7 +#LOCATION=DEBIAN_6 +#LOCATION=OSX_10_8 # # Add other locations and move target differences into the macros as needed, # setup for my primary development and testing hosts. @@ -11,20 +13,25 @@ Cc=gcc LOG4LIB=-L/usr/lib CLIENT=drde -ifeq ($(LOCATION),debian7) +ifeq ($(LOCATION),DEBIAN_7) ARTKLIB=-L/home/jdaugherty/clients/reg.de/git/ACTK1_0/lib ARTKINCL=-I/home/jdaugherty/clients/reg.de/git/ACTK1_0 -else +endif +ifeq ($(LOCATION),DEBIAN_6) ARTKLIB=-L/home/jdaugherty/dnseppus/ACTK1_0/lib ARTKINCL=-I/home/jdaugherty/dnseppus/ACTK1_0 endif +ifeq ($(LOCATION),OSX_10_8) + ARTKLIB=-L/Users/juand/dnseppus/ACTK1_0/lib + ARTKINCL=-I/Users/juand/dnseppus/ACTK1_0 +endif SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) $(ARTKLIB) -l boost_system -l boost_thread -l log4cpp -l ACTK1_0 SINCL= -I include -I /usr/include/log4cpp $(BOSINCL) CFLAGS= -DCURRENT_DEBUG=1000 -ggdb3 -ifeq ($(LOCATION),debian7) +ifeq ($(LOCATION),DEBIAN_7) #XALAN_LIB_DIR = /usr/lib/x86_64-linux-gnu/ XALAN_LIB_DIR = /usr/local/lib XALAN_LIB = xalan-c @@ -32,7 +39,8 @@ XALAN_INC_DIR = /usr/local/include/xalanc XERCES_LIB_DIR = /usr/local/lib/ XERCES_LIB = xerces-c XERCES_INC_DIR = /usr/local/include/xercesc/ -else +endif +ifeq ($(LOCATION),DEBIAN_6) XALAN_LIB_DIR = /usr/lib/ XALAN_LIB = xalan-c XALAN_INC_DIR = /usr/include/xalanc/ @@ -40,6 +48,14 @@ XERCES_LIB_DIR = /usr/lib/ XERCES_LIB = xerces-c XERCES_INC_DIR = /usr/include/xercesc/ endif +ifeq ($(LOCATION),OSX_10_8) +XALAN_LIB_DIR = /opt/local/lib/ +XALAN_LIB = xalan-c +XALAN_INC_DIR = /opt/local/include/xalanc/ +XERCES_LIB_DIR = /opt/local/lib/ +XERCES_LIB = xerces-c +XERCES_INC_DIR = /opt/local/include/xercesc/ +endif # # ---------- Should not need to change below