From 902e19212dc53b52a5ff2544df17c871d424ec7a Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Mon, 28 Jan 2008 19:13:06 +0000 Subject: [PATCH] compat header for SEMS on Solaris contributed by Richard Newman rnewman at twinql dot com git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@635 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/compat/solaris.h | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 core/compat/solaris.h diff --git a/core/compat/solaris.h b/core/compat/solaris.h new file mode 100644 index 00000000..a2fcc1b4 --- /dev/null +++ b/core/compat/solaris.h @@ -0,0 +1,60 @@ +#ifndef __SOLARIS_H__ +#define __SOLARIS_H__ +/* + * New compatibility code for Solaris. + */ + +#ifndef timeradd +#define timeradd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif +#ifndef timersub +#define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + +// Work around use of deprecated definitions in Solaris system headers. +#include +#include +#define u_int16_t u_short +#define u_int32_t u_int + +// For FIONBIO. +// Apparently it's better form to use +// fcntl( sd, F_SETFL, FNONBLOCK | FASYNC ) +// instead of +// ioctl( sd, FIONBIO, ... ) +// but I didn't write the code... +#include + +// Solaris doesn't have bcopy/bcmp/bzero. Reimplement them with more common routines. +// Use memmove rather than memcpy to behave correctly with overlapping sequences. +#define bzero(b,n) memset(b,0,n) +#define bcopy(b1,b2,n) memmove(b2,b1,n) +#define bcmp(b1,b2,n) memmove(b1,b2,n) + +// Assume that we're going to be running on Solaris 10, which *does* have +// setenv, even though we might be compiling on Solaris 9 (which does not). +// extern "C" int setenv(const char *name, const char *value, int overwrite); + +// Solaris doesn't define AF_LOCAL, PF_LOCAL, etc. +#define AF_LOCAL AF_UNIX +#define PF_LOCAL PF_UNIX +#define MSG_NOSIGNAL 0 + +#endif