OS-dependent files for Mac OS X (Darwin).
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author: Eric Norum
|
||||
*/
|
||||
|
||||
#ifndef _OSD_READLINE_H_
|
||||
#define _OSD_READLINE_H_
|
||||
|
||||
/*
|
||||
* If you don't have the fink readline package installed, uncomment
|
||||
* the `FAKE' line and comment out the `REAL' line.
|
||||
*/
|
||||
/* #define IOCSH_FAKE_READLINE */
|
||||
#define IOCSH_REAL_READLINE
|
||||
|
||||
#endif /* _OSD_READLINE_H_ */
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author: Eric Norum
|
||||
*/
|
||||
|
||||
#ifndef osdSockH
|
||||
#define osdSockH
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h> /* for MAXHOSTNAMELEN */
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
/*#include <sys/filio.h>
|
||||
#include <sys/sockio.h>*/
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h> /* close() and others */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET (-1)
|
||||
#define SOCKERRNO errno
|
||||
#define socket_close(S) close(S)
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef int osiSocklen_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE)
|
||||
|
||||
#define SOCKERRSTR(ERRNO_IN) (strerror(ERRNO_IN))
|
||||
|
||||
#define SOCK_EWOULDBLOCK EWOULDBLOCK
|
||||
#define SOCK_ENOBUFS ENOBUFS
|
||||
#define SOCK_ECONNRESET ECONNRESET
|
||||
#define SOCK_ETIMEDOUT ETIMEDOUT
|
||||
#define SOCK_EADDRINUSE EADDRINUSE
|
||||
#define SOCK_ECONNREFUSED ECONNREFUSED
|
||||
#define SOCK_ECONNABORTED ECONNABORTED
|
||||
#define SOCK_EINPROGRESS EINPROGRESS
|
||||
#define SOCK_EISCONN EISCONN
|
||||
#define SOCK_EALREADY EALREADY
|
||||
#define SOCK_EINVAL EINVAL
|
||||
#define SOCK_EINTR EINTR
|
||||
#define SOCK_EPIPE EPIPE
|
||||
#define SOCK_EMFILE EMFILE
|
||||
#define SOCK_SHUTDOWN ESHUTDOWN
|
||||
#define SOCK_ENOTSOCK ENOTSOCK
|
||||
#define SOCK_EBADF EBADF
|
||||
|
||||
#ifndef SD_BOTH
|
||||
#define SD_BOTH 2
|
||||
#endif
|
||||
|
||||
#define ifreq_size(pifreq) (sizeof(pifreq->ifr_name))
|
||||
|
||||
#endif /*osdSockH*/
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author: Eric Norum
|
||||
*/
|
||||
|
||||
#include "osiSock.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsTime.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsMutex.h"
|
||||
|
||||
//
|
||||
// epicsTime::osdGetCurrent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
# ifdef _POSIX_TIMERS
|
||||
struct timespec ts;
|
||||
int status;
|
||||
|
||||
status = clock_gettime (CLOCK_REALTIME, &ts);
|
||||
if (status) {
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
*pDest = epicsTime (ts);
|
||||
return epicsTimeOK;
|
||||
# else
|
||||
int status;
|
||||
struct timeval tv;
|
||||
|
||||
status = gettimeofday (&tv, NULL);
|
||||
if (status) {
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
*pDest = epicsTime (tv);
|
||||
return epicsTimeOK;
|
||||
# endif
|
||||
}
|
||||
|
||||
//
|
||||
// epicsTimeGetEvent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetEvent (epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if (eventNumber==epicsTimeEventCurrentTime) {
|
||||
return epicsTimeGetCurrent (pDest);
|
||||
}
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Darwin provides neither gmtime_r nor localtime_r and I can't confirm
|
||||
* the gmtime and localtime are thread-safe, so protect calls to these
|
||||
* functions with a mutex.
|
||||
*/
|
||||
static epicsMutexId timeLock;
|
||||
static epicsThreadOnceId osdTimeOnceFlag = EPICS_THREAD_ONCE_INIT;
|
||||
static void osdTimeInit ( void * )
|
||||
{
|
||||
timeLock = epicsMutexMustCreate();
|
||||
}
|
||||
|
||||
int epicsTime_gmtime ( const time_t *pAnsiTime, // X aCC 361
|
||||
struct tm *pTM )
|
||||
{
|
||||
struct tm * pRet;
|
||||
epicsThreadOnce ( &osdTimeOnceFlag, osdTimeInit, 0 );
|
||||
epicsMutexLock(timeLock);
|
||||
pRet = gmtime ( pAnsiTime );
|
||||
if ( pRet ) {
|
||||
*pTM = *pRet;
|
||||
epicsMutexUnlock(timeLock);
|
||||
return epicsTimeOK;
|
||||
}
|
||||
else {
|
||||
epicsMutexUnlock(timeLock);
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
int epicsTime_localtime ( const time_t *clock, // X aCC 361
|
||||
struct tm *result )
|
||||
{
|
||||
struct tm * pRet;
|
||||
epicsThreadOnce ( &osdTimeOnceFlag, osdTimeInit, 0 );
|
||||
epicsMutexLock(timeLock);
|
||||
pRet = localtime ( clock );
|
||||
if ( pRet ) {
|
||||
*result = *pRet;
|
||||
epicsMutexUnlock(timeLock);
|
||||
return epicsTimeOK;
|
||||
}
|
||||
else {
|
||||
epicsMutexUnlock(timeLock);
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author: Eric Norum
|
||||
*/
|
||||
|
||||
#ifndef osdTimeh
|
||||
#define osdTimeh
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#endif /* ifndef osdTimeh */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author: Eric Norum
|
||||
*/
|
||||
|
||||
#ifndef osiFileNameH
|
||||
#define osiFileNameH
|
||||
|
||||
#include "unixFileName.h"
|
||||
|
||||
#endif /* osiFileNameH */
|
||||
Reference in New Issue
Block a user