From: <gn...@us...> - 2011-02-22 18:56:30
|
Revision: 134 http://ptpd.svn.sourceforge.net/ptpd/?rev=134&view=rev Author: gnn Date: 2011-02-22 18:56:24 +0000 (Tue, 22 Feb 2011) Log Message: ----------- Add support for Mac OS X (Snow Leopard) Modified Paths: -------------- trunk/INSTALL trunk/src/dep/constants_dep.h trunk/src/dep/net.c trunk/src/dep/ptpd_dep.h trunk/src/dep/servo.c trunk/src/dep/sys.c trunk/src/ptpd.h Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/INSTALL 2011-02-22 18:56:24 UTC (rev 134) @@ -1,12 +1,12 @@ PTP Daemon Installation Instructions -11 October 2010 +22 February 2011 George V. Neville-Neil -The PTP Daemon is known to work on FreeBSD and Linux systems. +The PTP Daemon is known to work on FreeBSD, Mac, and Linux systems. -*) Building on FreeBSD +*) Building on FreeBSD and Mac OS X (Snow Leopard) 1) cd into the src/ directory 2) Un comment the #-DBSD_INTERFACE_FUNCTIONS option: Modified: trunk/src/dep/constants_dep.h =================================================================== --- trunk/src/dep/constants_dep.h 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/src/dep/constants_dep.h 2011-02-22 18:56:24 UTC (rev 134) @@ -12,7 +12,8 @@ #include <limits.h> -#if !defined(linux) && !defined(__NetBSD__) && !defined(__FreeBSD__) +#if !defined(linux) && !defined(__NetBSD__) && !defined(__FreeBSD__) && \ + !defined(__APPLE__) #error Not ported to this architecture, please update. #endif @@ -34,14 +35,14 @@ #endif /* linux */ -#if defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__) #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_types.h> -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__APPLE__) #include <net/ethernet.h> #include <sys/uio.h> #else Modified: trunk/src/dep/net.c =================================================================== --- trunk/src/dep/net.c 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/src/dep/net.c 2011-02-22 18:56:24 UTC (rev 134) @@ -364,7 +364,7 @@ /* make timestamps available through recvmsg() */ temp = 1; -#if defined(linux) +#if defined(linux) || defined(__APPLE__) if (setsockopt(netPath->eventSock, SOL_SOCKET, SO_TIMESTAMP, &temp, sizeof(int)) < 0 || setsockopt(netPath->generalSock, SOL_SOCKET, SO_TIMESTAMP, &temp, sizeof(int)) < 0) { #else /* BSD */ @@ -450,7 +450,7 @@ char control[CMSG_SPACE(sizeof(struct timeval))]; } cmsg_un; struct cmsghdr *cmsg; -#if defined(linux) +#if defined(linux) || defined(__APPLE__) struct timeval *tv; #else /* FreeBSD */ struct timespec ts; @@ -499,7 +499,7 @@ return 0; } -#if defined(linux) +#if defined(linux) || defined(__APPLE__) tv = 0; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) Modified: trunk/src/dep/ptpd_dep.h =================================================================== --- trunk/src/dep/ptpd_dep.h 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/src/dep/ptpd_dep.h 2011-02-22 18:56:24 UTC (rev 134) @@ -132,6 +132,10 @@ UInteger16 getRand(UInteger32 *); Boolean adjFreq(Integer32); +#if defined(__APPLE__) +void adjTime(Integer32); +#endif /* __APPLE__ */ + /* timer.c */ void initTimer(void); void timerUpdate(IntervalTimer *); Modified: trunk/src/dep/servo.c =================================================================== --- trunk/src/dep/servo.c 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/src/dep/servo.c 2011-02-22 18:56:24 UTC (rev 134) @@ -54,8 +54,10 @@ rtOpts->halfEpoch = 0; /* level clock */ +#if !defined(__APPLE__) if (!rtOpts->noAdjust) adjFreq(0); +#endif /* __APPLE__ */ } void @@ -205,8 +207,10 @@ setTime(&timeTmp); initClock(rtOpts, ptpClock); } else { +#if !defined(__APPLE__) adj = ptpClock->offset_from_master.nanoseconds > 0 ? ADJ_FREQ_MAX : -ADJ_FREQ_MAX; adjFreq(-adj); +#endif /* __APPLE__ */ } } } else { @@ -231,7 +235,11 @@ /* apply controller output as a clock tick rate adjustment */ if (!rtOpts->noAdjust) +#if defined(__APPLE__) + adjTime(ptpClock->offset_from_master.nanoseconds); +#else adjFreq(-adj); +#endif /* __APPLE__ */ } display: Modified: trunk/src/dep/sys.c =================================================================== --- trunk/src/dep/sys.c 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/src/dep/sys.c 2011-02-22 18:56:24 UTC (rev 134) @@ -256,7 +256,7 @@ void getTime(TimeInternal * time) { -#if defined(linux) +#if defined(linux) || defined(__APPLE__) struct timeval tv; gettimeofday(&tv, 0); @@ -294,6 +294,7 @@ return rand_r((unsigned int *)seed); } +#if !defined(__APPLE__) Boolean adjFreq(Integer32 adj) { @@ -309,3 +310,21 @@ return !adjtimex(&t); } + +#else + +void +adjTime(Integer32 nanoseconds) +{ + + struct timeval t; + + t.tv_sec = 0; + t.tv_usec = nanoseconds / 1000; + + if (adjtime(&t, NULL) < 0) + PERROR("failed to ajdtime"); + +} + +#endif /* __APPLE__ */ Modified: trunk/src/ptpd.h =================================================================== --- trunk/src/ptpd.h 2011-02-22 18:18:30 UTC (rev 133) +++ trunk/src/ptpd.h 2011-02-22 18:56:24 UTC (rev 134) @@ -23,7 +23,9 @@ #include <time.h> #include <netdb.h> #include <sys/time.h> +#ifndef __APPLE__ #include <sys/timex.h> +#endif #include <sys/socket.h> #include <sys/select.h> #include <sys/ioctl.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |