Update platform macros in platform.h, and use them instead of compiler-defined OS macros.

This commit is contained in:
Brian Cox 2016-06-23 23:12:22 -07:00
parent 9be78c1d1c
commit 207189dafd
24 changed files with 88 additions and 57 deletions

View File

@ -90,7 +90,7 @@ bool cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur,
} }
else else
{ {
#ifndef __AROS__ #if !IS_AROS
mblen (NULL, 0); mblen (NULL, 0);
int len = mblen(&*cur, MB_CUR_MAX); int len = mblen(&*cur, MB_CUR_MAX);
if (len < 0) //invalid multibyte sequence, but let's not blow up. if (len < 0) //invalid multibyte sequence, but let's not blow up.

View File

@ -61,7 +61,7 @@
#define TSS_USE_UCS2_CCONV16 (!(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 && WCHAR_IS_16_BITS) #define TSS_USE_UCS2_CCONV16 (!(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 && WCHAR_IS_16_BITS)
#define TSS_USE_UCS2_CCONV32 (!(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 && WCHAR_IS_32_BITS) #define TSS_USE_UCS2_CCONV32 (!(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 && WCHAR_IS_32_BITS)
#ifdef __minix__ #if ICONV_CONST_SOURCE
# define ICONV_SOURCE_TYPE const char # define ICONV_SOURCE_TYPE const char
#else #else
# define ICONV_SOURCE_TYPE char # define ICONV_SOURCE_TYPE char

View File

@ -47,7 +47,7 @@
#include "fileerror.h" #include "fileerror.h"
#endif #endif
#ifdef __MINT__ // for off_t #if IS_MINT // for off_t
#include <sys/types.h> #include <sys/types.h>
#endif #endif
@ -143,7 +143,7 @@ public:
}; };
#ifdef __AROS__ #if IS_AROS
class cArosPath class cArosPath
{ {
public: public:

View File

@ -34,7 +34,7 @@
/* On GNU/Hurd, need to define _GNU_SOURCE in order to use O_NOATIME /* On GNU/Hurd, need to define _GNU_SOURCE in order to use O_NOATIME
which technically is still a nonstandard extension to open() */ which technically is still a nonstandard extension to open() */
#ifdef __gnu_hurd__ #if IS_HURD
# define _GNU_SOURCE # define _GNU_SOURCE
#endif #endif
@ -53,7 +53,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef __hpux__ #if IS_HPUX
# include <sys/fs/vx_ioctl.h> # include <sys/fs/vx_ioctl.h>
#endif #endif
@ -104,7 +104,7 @@ cFile_i::~cFile_i()
fclose( mpCurrStream ); fclose( mpCurrStream );
mpCurrStream = NULL; mpCurrStream = NULL;
#ifdef __AROS__ #if IS_AROS
if( mFlags & cFile::OPEN_LOCKED_TEMP ) if( mFlags & cFile::OPEN_LOCKED_TEMP )
{ {
// unlink this file // unlink this file
@ -219,7 +219,7 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) ); throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
} }
#ifndef __AROS__ #if !IS_AROS
if( flags & OPEN_LOCKED_TEMP ) if( flags & OPEN_LOCKED_TEMP )
{ {
// unlink this file // unlink this file
@ -246,13 +246,11 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
fcntl(fh, F_NOCACHE, 1); fcntl(fh, F_NOCACHE, 1);
#endif #endif
#ifdef __sun #if IS_SOLARIS
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING)) if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
directio(fh, DIRECTIO_ON); directio(fh, DIRECTIO_ON);
#endif
#elif IS_HPUX
#ifdef __hpux__
if (flags & OPEN_SCANNING) if (flags & OPEN_SCANNING)
{ {
if (flags & OPEN_DIRECT) if (flags & OPEN_DIRECT)
@ -460,7 +458,7 @@ void cFile::Truncate( File_t offset ) // throw(eFile)
} }
#ifdef __AROS__ #if IS_AROS
TSTRING cArosPath::AsPosix( const TSTRING& in ) TSTRING cArosPath::AsPosix( const TSTRING& in )
{ {
if (in[0] == '/') if (in[0] == '/')

View File

@ -74,7 +74,7 @@
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef _SORTIX_SOURCE #if !IS_SORTIX
# include <sys/file.h> # include <sys/file.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -871,7 +871,7 @@ FILE *fp[];
return(mfpclose(indx, fp)); return(mfpclose(indx, fp));
} }
#ifdef __AROS__ #if IS_AROS
#define fork() vfork() #define fork() vfork()
#endif #endif

View File

@ -54,6 +54,9 @@
/* /*
* forward declarations * forward declarations
*/ */
#include "platform.h"
#ifdef __STDC__ #ifdef __STDC__
void le_clobber(void); void le_clobber(void);
int le_set(const char*); int le_set(const char*);
@ -114,7 +117,7 @@ int echild();
# define GID_RESET -2 /* reset EGID to RGID */ # define GID_RESET -2 /* reset EGID to RGID */
#endif #endif
#ifndef DEF_PATH #ifndef DEF_PATH
# ifdef __FreeBSD_cc_version # if IS_FREEBSD
# define DEF_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" /* default search path */ # define DEF_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" /* default search path */
# else # else
# define DEF_PATH "PATH=/bin:/usr/bin:/usr/ucb" /* default search path */ # define DEF_PATH "PATH=/bin:/usr/bin:/usr/ucb" /* default search path */

View File

@ -64,7 +64,6 @@
#define OS_DARWIN 0x0304 #define OS_DARWIN 0x0304
#define OS_DRAGONFLYBSD 0x0305 #define OS_DRAGONFLYBSD 0x0305
#define OS_MIDNIGHTBSD 0x0306 #define OS_MIDNIGHTBSD 0x0306
#define OS_HARDENEDBSD 0x0307
#define OS_SOLARIS 0x0400 #define OS_SOLARIS 0x0400
#define OS_AIX 0x0401 #define OS_AIX 0x0401
@ -137,14 +136,28 @@
#define OS OS_FREEBSD #define OS OS_FREEBSD
#define IS_FREEBSD 1 #define IS_FREEBSD 1
// add NetBSD, OpenBSD, other BSDs #elif defined(__NetBSD__)
#define OS OS_NETBSD
#define IS_NETBSD 1
#elif defined(__OpenBSD__)
#define OS OS_OPENBSD
#define IS_OPENBSD 1
#elif defined(_OSX) #elif defined(_OSX)
#define OS OS_DARWIN #define OS OS_DARWIN
#define IS_DARWIN 1 #define IS_DARWIN 1
#elif defined(_SOLARIS) #elif defined(__DragonFly__)
#define OS OS_DRAGONFLYBSD
#define IS_DRAGONFLYBSD 1
#elif defined(__MidnightBSD__)
#define OS OS_MIDNIGHTBSD
#define IS_MIDNIGHTBSD 1
#elif defined(_SOLARIS) || defined(__sun)
#define OS OS_SOLARIS #define OS OS_SOLARIS
#define IS_SOLARIS 1 #define IS_SOLARIS 1
@ -164,13 +177,19 @@
#define OS OS_OSF1 #define OS OS_OSF1
#define IS_OSF1 1 #define IS_OSF1 1
// need Minix, Haiku #elif defined(__minix__)
#define OS OS_MINIX
#define IS_MINIX 1
#elif defined(__gnu_hurd__) #elif defined(__gnu_hurd__)
#define OS OS_HURD #define OS OS_HURD
#define IS_HURD 1 #define IS_HURD 1
#elif defined(__HAIKU__)
#define OS OS_HAIKU
#define IS_HAIKU 1
#elif defined(__SYLLABLE__) #elif defined(__SYLLABLE__)
#define OS OS_SYLLABLE #define OS OS_SYLLABLE
#define IS_SYLLABLE 1 #define IS_SYLLABLE 1
@ -274,6 +293,16 @@
#define SUPPORTS_MEMBER_TEMPLATES ( ! IS_SUNPRO ) #define SUPPORTS_MEMBER_TEMPLATES ( ! IS_SUNPRO )
#define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST ( ! IS_SUNPRO ) #define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST ( ! IS_SUNPRO )
#define SUPPORTS_ST_BLOCKS (!IS_DOS_DJGPP)
#define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP)
#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP)
#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS)
#define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
#define USES_MBLEN (!IS_ANDROID && !IS_AROS)
#define ICONV_CONST_SOURCE (IS_MINIX)
//============================================================================= //=============================================================================
// Miscellaneous // Miscellaneous
// //

View File

@ -137,7 +137,7 @@ inline bool tss_find_in_hash( const wc16_string& lhs, TSTRING& rhs )
std::string::const_iterator std::string::const_iterator
cStringUtil::Convert( std::string& nbs, const wc16_string& dbs ) cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
{ {
#ifdef __AROS__ #if IS_AROS
nbs.resize(dbs.length()); nbs.resize(dbs.length());
for (int x=0; x<dbs.length(); ++x) for (int x=0; x<dbs.length(); ++x)
nbs[x] = (unsigned char)dbs[x]; nbs[x] = (unsigned char)dbs[x];
@ -192,7 +192,7 @@ cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
wc16_string::const_iterator wc16_string::const_iterator
cStringUtil::Convert( wc16_string& dbs, const std::string& nbs ) cStringUtil::Convert( wc16_string& dbs, const std::string& nbs )
{ {
#ifdef __AROS__ #if IS_AROS
dbs.resize(nbs.length()); dbs.resize(nbs.length());
for (int x=0; x<nbs.length(); x++) for (int x=0; x<nbs.length(); x++)
dbs[x] = (unsigned short)nbs[x]; dbs[x] = (unsigned short)nbs[x];

View File

@ -54,7 +54,7 @@
#define TIME_MAX 2147483647L // largest signed 32 bit number #define TIME_MAX 2147483647L // largest signed 32 bit number
#ifdef __AROS__ #if IS_AROS
#define tzset() #define tzset()
#endif #endif

View File

@ -68,7 +68,7 @@ static TSTRING& util_FormatTimeCPlusPlus( struct tm* ptm, TSTRING& strBuf );
// PUBLIC METHOD CODE // PUBLIC METHOD CODE
//========================================================================= //=========================================================================
#ifdef __AROS__ #if IS_AROS
#define tzset() #define tzset()
#endif #endif

View File

@ -178,7 +178,7 @@ TCHAR cUnixFSServices::GetPathSeparator() const
return '/'; return '/';
} }
#ifndef __AROS__ #if !IS_AROS
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const throw(eFSServices) void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const throw(eFSServices)
{ {
#else #else
@ -326,7 +326,7 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) {
} }
#ifndef __AROS__ #if !IS_AROS
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices) void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices)
{ {
#else #else
@ -369,7 +369,7 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const th
stat.size = statbuf.st_size; stat.size = statbuf.st_size;
stat.uid = statbuf.st_uid; stat.uid = statbuf.st_uid;
stat.blksize = statbuf.st_blksize; stat.blksize = statbuf.st_blksize;
#ifndef __DJGPP__ #if SUPPORTS_ST_BLOCKS
stat.blocks = statbuf.st_blocks; stat.blocks = statbuf.st_blocks;
#else #else
stat.blocks = 0; stat.blocks = 0;
@ -409,7 +409,7 @@ void cUnixFSServices::GetMachineNameFullyQualified( TSTRING& strName ) const
char buf[256]; char buf[256];
if (gethostname(buf, 256) != 0) if (gethostname(buf, 256) != 0)
{ {
#if defined(SOLARIS_NO_GETHOSTBYNAME) || defined(_SORTIX_SOURCE) || defined(__DJGPP__) #if defined(SOLARIS_NO_GETHOSTBYNAME) || !SUPPORTS_NETWORKING
strName = buf; strName = buf;
return; return;
#else #else
@ -464,7 +464,7 @@ bool cUnixFSServices::GetIPAddress( uint32& uiIPAddress )
bool fGotAddress = false; bool fGotAddress = false;
cDebug d( _T("cUnixFSServices::GetIPAddress") ); cDebug d( _T("cUnixFSServices::GetIPAddress") );
#if !defined(_SORTIX_SOURCE) && !defined(__DJGPP__) #if SUPPORTS_NETWORKING
struct utsname utsnameBuf; struct utsname utsnameBuf;
if( EFAULT != uname( &utsnameBuf) ) if( EFAULT != uname( &utsnameBuf) )
{ {

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#endif #endif
#if defined(__MINT__) || defined(__MSDOS__) // has memory.h, but memset defined in string.h anyway. #if IS_MINT || IS_DOS_DJGPP // has memory.h, but memset defined in string.h anyway.
#include <string.h> #include <string.h>
#endif #endif

View File

@ -137,7 +137,7 @@ void cFSParserUtil::InterpretFCOName( const std::list<TSTRING>& l, cFCOName& nam
for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); i++ ) for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); i++ )
strT += *i; strT += *i;
#ifdef __AROS__ #if IS_AROS
strT = cArosPath::AsPosix(strT); strT = cArosPath::AsPosix(strT);
#endif #endif

View File

@ -42,7 +42,7 @@
#include "stdsiggen.h" #include "stdsiggen.h"
#include "siggenstrings.h" #include "siggenstrings.h"
#ifdef __AROS__ #if IS_AROS
# define VERSION_PREFIX "$VER: " # define VERSION_PREFIX "$VER: "
#else #else
# define VERSION_PREFIX "@(#)" # define VERSION_PREFIX "@(#)"

View File

@ -56,7 +56,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#ifdef _SORTIX_SOURCE #if !IS_SORTIX
# include <sys/select.h> # include <sys/select.h>
#endif #endif
@ -72,7 +72,7 @@
#define INVALID_SOCKET -1 #define INVALID_SOCKET -1
#ifdef __AROS__ #if IS_AROS
#ifndef HAVE_GETHOSTNAME #ifndef HAVE_GETHOSTNAME
#define HAVE_GETHOSTNAME 1 #define HAVE_GETHOSTNAME 1
#endif #endif
@ -177,7 +177,7 @@ long cSMTPMailMessage::GetServerAddress()
} }
else else
{ {
#if defined(_SORTIX_SOURCE) || !defined(HAVE_SYS_SOCKET_H) #if IS_SORTIX || !defined(HAVE_SYS_SOCKET_H)
return INADDR_NONE; return INADDR_NONE;
#else #else
// do a DNS lookup of the hostname and get the long // do a DNS lookup of the hostname and get the long

View File

@ -49,7 +49,7 @@
#include "tw/twerrors.h" #include "tw/twerrors.h"
#include "tw/twstrings.h" #include "tw/twstrings.h"
#ifdef __AROS__ #if IS_AROS
#include <proto/bsdsocket.h> #include <proto/bsdsocket.h>
#define openlog(a,b,c) #define openlog(a,b,c)
#define closelog() #define closelog()
@ -60,8 +60,9 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void cSyslog::Log(const TCHAR* programName, cSyslog::LogType logType, const TCHAR* message) void cSyslog::Log(const TCHAR* programName, cSyslog::LogType logType, const TCHAR* message)
{ {
#if HAVE_SYSLOG_H && !defined(SKYOS) // Handle an oddball OS that has syslog.h but doesn't implement the calls. // SkyOS has syslog.h but doesn't actually implement the calls.
#if SUPPORTS_SYSLOG
(void)logType; // logType is not used for Unix syslog (void)logType; // logType is not used for Unix syslog
ASSERT(sizeof(TCHAR) == sizeof(char)); ASSERT(sizeof(TCHAR) == sizeof(char));

View File

@ -34,7 +34,7 @@
#include "stdtripwire.h" #include "stdtripwire.h"
#include "tripwirestrings.h" #include "tripwirestrings.h"
#ifdef __AROS__ #if IS_AROS
# define VERSION_PREFIX "$VER: " # define VERSION_PREFIX "$VER: "
#else #else
# define VERSION_PREFIX "@(#)" # define VERSION_PREFIX "@(#)"

View File

@ -296,7 +296,7 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory); cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory);
if (temp_directory.length() == 0) { if (temp_directory.length() == 0) {
#ifdef __AROS__ #if IS_AROS
temp_directory = "T:"; temp_directory = "T:";
#else #else
temp_directory = "/tmp/"; temp_directory = "/tmp/";
@ -311,7 +311,7 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
// make sure it exists... // make sure it exists...
// //
#ifdef __AROS__ #if IS_AROS
temp_directory = cArosPath::AsNative(temp_directory); temp_directory = cArosPath::AsNative(temp_directory);
#endif #endif

View File

@ -79,7 +79,7 @@
#include "core/tw_signal.h" // to ignore SIGPIPE #include "core/tw_signal.h" // to ignore SIGPIPE
#endif #endif
#ifdef __AROS__ #if IS_AROS
#include <errno.h> #include <errno.h>
#include <proto/exec.h> #include <proto/exec.h>
#include <proto/bsdsocket.h> #include <proto/bsdsocket.h>
@ -246,7 +246,7 @@ void cTWInit::Init( const TSTRING& strArgv0 )
// END:RAD // END:RAD
// ------------------------------------------------------------ // ------------------------------------------------------------
#ifdef __AROS__ #if IS_AROS
aros_socketbase_init(); aros_socketbase_init();
#endif #endif
// //
@ -284,7 +284,7 @@ void cTWInit::Init( const TSTRING& strArgv0 )
mpData->et.SetChild( &mpData->er ); mpData->et.SetChild( &mpData->er );
errorQueue.SetChild( &mpData->et ); errorQueue.SetChild( &mpData->et );
#if IS_UNIX && !defined(__DJGPP__) #if SUPPORTS_POSIX_SIGNALS
// ignore SIGPIPE // ignore SIGPIPE
tw_sigign(SIGPIPE); //TODO: somebody add comment here! tw_sigign(SIGPIPE); //TODO: somebody add comment here!
@ -316,7 +316,7 @@ void cTWInit::Init( const TSTRING& strArgv0 )
} }
#ifdef __AROS__ #if IS_AROS
struct Library* SocketBase=0; struct Library* SocketBase=0;
bool aros_socketbase_init() bool aros_socketbase_init()

View File

@ -1141,7 +1141,7 @@ void cTWUtil::GetString(wc16_string& ret)
#endif #endif
// tcsetattr doesn't seem to work on AROS, so tweak ANSI terminal settings to hide passphrases. // tcsetattr doesn't seem to work on AROS, so tweak ANSI terminal settings to hide passphrases.
#ifdef __AROS__ #if IS_AROS
printf("\e[8m"); // set the 'concealed' flag printf("\e[8m"); // set the 'concealed' flag
fflush(stdout); fflush(stdout);
#endif #endif
@ -1154,7 +1154,7 @@ void cTWUtil::GetString(wc16_string& ret)
TCOUT.flush(); TCOUT.flush();
len = read( 0, buf, MAX_STRING ); len = read( 0, buf, MAX_STRING );
#ifdef __AROS__ #if IS_AROS
printf("\e[0m"); // reset back to normal text printf("\e[0m"); // reset back to normal text
fflush(stdout); fflush(stdout);
#endif #endif

View File

@ -63,7 +63,7 @@
#include "core/displayencoder.h" #include "core/displayencoder.h"
//Provide a swab() impl. from glibc, for platforms that don't have one //Provide a swab() impl. from glibc, for platforms that don't have one
#if defined(__SYLLABLE__) || defined(__ANDROID_API__) || defined(_SORTIX_SOURCE) #if NEEDS_SWAB_IMPL
void swab (const void *bfrom, void *bto, ssize_t n) void swab (const void *bfrom, void *bto, ssize_t n)
{ {
const char *from = (const char *) bfrom; const char *from = (const char *) bfrom;

View File

@ -39,7 +39,7 @@
#include "twadmin.h" #include "twadmin.h"
#include "twadminstrings.h" #include "twadminstrings.h"
#ifdef __AROS__ #if IS_AROS
# define VERSION_PREFIX "$VER: " # define VERSION_PREFIX "$VER: "
#else #else
# define VERSION_PREFIX "@(#)" # define VERSION_PREFIX "@(#)"

View File

@ -209,7 +209,7 @@ std::string convert_to_encoded_hex( char ch )
std::string util_ConvertMB( const std::string& sIn ) std::string util_ConvertMB( const std::string& sIn )
{ {
#if defined(__ANDROID_API__) || defined(__AROS__) #if !USES_MBLEN
return sIn; return sIn;
#else #else
cDebug d( "cPolicyParser::util_ConvertMB" ); cDebug d( "cPolicyParser::util_ConvertMB" );

View File

@ -39,7 +39,7 @@
#include "twprint.h" #include "twprint.h"
#include "twprintstrings.h" #include "twprintstrings.h"
#ifdef __AROS__ #if IS_AROS
# define VERSION_PREFIX "$VER: " # define VERSION_PREFIX "$VER: "
#else #else
# define VERSION_PREFIX "@(#)" # define VERSION_PREFIX "@(#)"