/* -*- C++ -*- */ // $Id$ // ============================================================================ // // = LIBRARY // ace // // = FILENAME // OS.h // // = DESCRIPTION // This file and its associated OS.i and OS.cpp files are the primary // point of portability for ACE. Once you get this file ported to a // new platform, then pretty much everything else comes for "free." // // = AUTHOR // Doug Schmidt , Jesper S. M|ller // , and a cast of thousands... // // ============================================================================ #if !defined (ACE_OS_H) # define ACE_OS_H // This file should be a link to the platform/compiler-specific // configuration file (e.g., config-sunos5-sunc++-4.x.h). # include "ace/inc_user_config.h" # if defined (ACE_HAS_MOSTLY_UNICODE_APIS) && !defined (UNICODE) # error UNICODE must be defined when using ACE_HAS_MOSTLY_UNICODE_APIS, check your compiler document on how to enable UNICODE. # endif /* ACE_HAS_MOSTLY_UNICODE_APIS && !UNICODE */ # if defined (ACE_LACKS_INLINE_FUNCTIONS) # define ACE_NO_INLINE # endif # if defined (ACE_HAS_ANSI_CASTS) # define ACE_static_cast(TYPE, EXPR) static_cast (EXPR) # define ACE_const_cast(TYPE, EXPR) const_cast (EXPR) # define ACE_reinterpret_cast(TYPE, EXPR) reinterpret_cast (EXPR) # if defined (__SUNPRO_CC) && !defined (ACE_HAS_RTTI) // Sun C++ with castop but without rtti converts dynamic_cast to // static cast. We do it here, to avoid the warning. # define ACE_dynamic_cast(TYPE, EXPR) static_cast (EXPR) # else /* ! __SUNPRO_CC || ACE_ACE_RTTI */ # define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast (EXPR) # endif /* ! __SUNPRO_CC || ACE_ACE_RTTI */ # else # define ACE_static_cast(TYPE, EXPR) ((TYPE) (EXPR)) # define ACE_const_cast(TYPE, EXPR) ((TYPE) (EXPR)) # define ACE_reinterpret_cast(TYPE, EXPR) ((TYPE) (EXPR)) # define ACE_dynamic_cast(TYPE, EXPR) ((TYPE) (EXPR)) # endif /* ACE_HAS_ANSI_CASTS */ # if !defined (ACE_CAST_CONST) // Sun CC 4.2, for example, requires const in reinterpret casts of // data members in const member functions. But, other compilers // complain about the useless const. This keeps everyone happy. # if defined (__SUNPRO_CC) # define ACE_CAST_CONST const # else /* ! __SUNPRO_CC */ # define ACE_CAST_CONST # endif /* ! __SUNPRO_CC */ # endif /* ! ACE_CAST_CONST */ // Deal with MSVC++ insanity for CORBA... # if defined (ACE_HAS_BROKEN_NAMESPACES) # define ACE_CORBA_1(NAME) CORBA_##NAME # define ACE_CORBA_2(TYPE, NAME) CORBA_##TYPE##_##NAME # define ACE_CORBA_3(TYPE, NAME) CORBA_##TYPE::NAME # define ACE_NESTED_CLASS(TYPE, NAME) NAME # else /* ! ACE_HAS_BROKEN_NAMESPACES */ # define ACE_CORBA_1(NAME) CORBA::NAME # define ACE_CORBA_2(TYPE, NAME) CORBA::TYPE::NAME # define ACE_CORBA_3(TYPE, NAME) CORBA::TYPE::NAME # define ACE_NESTED_CLASS(TYPE, NAME) TYPE::NAME # endif /* ! ACE_HAS_BROKEN_NAMESPACES */ // Define some helpful macros. # define ACE_ONE_SECOND_IN_MSECS 1000L # define ACE_ONE_SECOND_IN_USECS 1000000L # define ACE_ONE_SECOND_IN_NSECS 1000000000L # if defined (ACE_NO_INLINE) // ACE inlining has been explicitly disabled. Implement // internally within ACE by undefining __ACE_INLINE__. # undef __ACE_INLINE__ # endif /* ! ACE_NO_INLINE */ # if !defined (ACE_DEFAULT_CLOSE_ALL_HANDLES) # define ACE_DEFAULT_CLOSE_ALL_HANDLES 1 # endif /* ACE_DEFAULT_CLOSE_ALL_HANDLES */ // The maximum length for a fully qualified Internet name. # if !defined(ACE_MAX_FULLY_QUALIFIED_NAME_LEN) # define ACE_MAX_FULLY_QUALIFIED_NAME_LEN 256 # endif /* ACE_MAX_FULLY_QUALIFIED_NAME_LEN */ # if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) // control message size to pass a file descriptor # define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE) # endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ // Define the default constants for ACE. Many of these are used for // the ACE tests and applications. You can change these values by // defining the macros in your config.h file. # if !defined (ACE_DEFAULT_TIMEOUT) # define ACE_DEFAULT_TIMEOUT 5 # endif /* ACE_DEFAULT_TIMEOUT */ # if !defined (ACE_DEFAULT_THREADS) # define ACE_DEFAULT_THREADS 1 # endif /* ACE_DEFAULT_THREADS */ // The following 3 defines are used in the IP multicast and broadcast tests. # if !defined (ACE_DEFAULT_BROADCAST_PORT) # define ACE_DEFAULT_BROADCAST_PORT 10000 # endif /* ACE_DEFAULT_BROADCAST_PORT */ # if !defined (ACE_DEFAULT_MULTICAST_PORT) # define ACE_DEFAULT_MULTICAST_PORT 10001 # endif /* ACE_DEFAULT_MULTICAST_PORT */ # if !defined (ACE_DEFAULT_MULTICAST_ADDR) # define ACE_DEFAULT_MULTICAST_ADDR "224.9.9.2" # endif /* ACE_DEFAULT_MULTICAST_ADDR */ // Default port number for HTTP. # if !defined (ACE_DEFAULT_HTTP_SERVER_PORT) # define ACE_DEFAULT_HTTP_SERVER_PORT 80 # endif /* ACE_DEFAULT_HTTP_SERVER_PORT */ // Used in many IPC_SAP tests # if !defined (ACE_DEFAULT_SERVER_PORT) # define ACE_DEFAULT_SERVER_PORT 10002 # endif /* ACE_DEFAULT_SERVER_PORT */ # if !defined (ACE_DEFAULT_MAX_SOCKET_BUFSIZ) # define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 65536 # endif /* ACE_DEFAULT_MAX_SOCKET_BUFSIZ */ # if !defined (ACE_DEFAULT_SERVER_PORT_STR) # define ACE_DEFAULT_SERVER_PORT_STR "10002" # endif /* ACE_DEFAULT_SERVER_PORT_STR */ // Used for the Service_Directory test # if !defined (ACE_DEFAULT_SERVICE_PORT) # define ACE_DEFAULT_SERVICE_PORT 10003 # endif /* ACE_DEFAULT_SERVICE_PORT */ // Used for the ACE_Thread_Spawn test # if !defined (ACE_DEFAULT_THR_PORT ) # define ACE_DEFAULT_THR_PORT 10004 # endif /* ACE_DEFAULT_THR_PORT */ // Used for SOCK_Connect::connect() tests # if !defined (ACE_DEFAULT_LOCAL_PORT) # define ACE_DEFAULT_LOCAL_PORT 10005 # endif /* ACE_DEFAULT_LOCAL_PORT */ // Used for Connector tests # if !defined (ACE_DEFAULT_LOCAL_PORT_STR) # define ACE_DEFAULT_LOCAL_PORT_STR "10005" # endif /* ACE_DEFAULT_LOCAL_PORT_STR */ // Used for the name server. # if !defined (ACE_DEFAULT_NAME_SERVER_PORT) # define ACE_DEFAULT_NAME_SERVER_PORT 10006 # endif /* ACE_DEFAULT_NAME_SERVER_PORT */ # if !defined (ACE_DEFAULT_NAME_SERVER_PORT_STR) # define ACE_DEFAULT_NAME_SERVER_PORT_STR "10006" # endif /* ACE_DEFAULT_NAME_SERVER_PORT_STR */ // Used for the token server. # if !defined (ACE_DEFAULT_TOKEN_SERVER_PORT) # define ACE_DEFAULT_TOKEN_SERVER_PORT 10007 # endif /* ACE_DEFAULT_TOKEN_SERVER_PORT */ # if !defined (ACE_DEFAULT_TOKEN_SERVER_PORT_STR) # define ACE_DEFAULT_TOKEN_SERVER_PORT_STR "10007" # endif /* ACE_DEFAULT_TOKEN_SERVER_PORT_STR */ // Used for the logging server. # if !defined (ACE_DEFAULT_LOGGING_SERVER_PORT) # define ACE_DEFAULT_LOGGING_SERVER_PORT 10008 # endif /* ACE_DEFAULT_LOGGING_SERVER_PORT */ # if !defined (ACE_DEFAULT_LOGGING_SERVER_PORT_STR) # define ACE_DEFAULT_LOGGING_SERVER_PORT_STR "10008" # endif /* ACE_DEFAULT_LOGGING_SERVER_PORT_STR */ // Used for the logging server. # if !defined (ACE_DEFAULT_THR_LOGGING_SERVER_PORT) # define ACE_DEFAULT_THR_LOGGING_SERVER_PORT 10008 # endif /* ACE_DEFAULT_THR_LOGGING_SERVER_PORT */ # if !defined (ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR) # define ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR "10008" # endif /* ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR */ // Used for the time server. # if !defined (ACE_DEFAULT_TIME_SERVER_PORT) # define ACE_DEFAULT_TIME_SERVER_PORT 10009 # endif /* ACE_DEFAULT_TIME_SERVER_PORT */ # if !defined (ACE_DEFAULT_TIME_SERVER_PORT_STR) # define ACE_DEFAULT_TIME_SERVER_PORT_STR "10009" # endif /* ACE_DEFAULT_TIME_SERVER_PORT_STR */ # if !defined (ACE_DEFAULT_TIME_SERVER_STR) # define ACE_DEFAULT_TIME_SERVER_STR "ACE_TS_TIME" # endif /* ACE_DEFAULT_TIME_SERVER_STR */ // Used by the FIFO tests and the Client_Logging_Handler netsvc. # if !defined (ACE_DEFAULT_RENDEZVOUS) # if defined (ACE_HAS_STREAM_PIPES) # define ACE_DEFAULT_RENDEZVOUS "/tmp/fifo.ace" # else # define ACE_DEFAULT_RENDEZVOUS "localhost:10010" # endif /* ACE_LACKS_FIFO */ # endif /* ACE_DEFAULT_RENDEZVOUS */ # if !defined (ACE_DEFAULT_LOGGER_KEY) # if defined (ACE_HAS_UNICODE) && defined (UNICODE) # if defined (ACE_HAS_STREAM_PIPES) # define ACE_DEFAULT_LOGGER_KEY L"/tmp/server_daemon" # else # define ACE_DEFAULT_LOGGER_KEY L"localhost:10012" # endif /* ACE_HAS_STREAM_PIPES */ # else /* ACE_HAS_UNICODE */ # if defined (ACE_HAS_STREAM_PIPES) # define ACE_DEFAULT_LOGGER_KEY "/tmp/server_daemon" # else # define ACE_DEFAULT_LOGGER_KEY "localhost:10012" # endif /* ACE_HAS_STREAM_PIPES */ # endif /* ACE_HAS_UNICODE && UNICODE */ # endif /* ACE_DEFAULT_LOGGER_KEY */ # if !defined (ACE_DEFAULT_SERVER_HOST) # define ACE_DEFAULT_SERVER_HOST "localhost" # endif /* ACE_DEFAULT_SERVER_HOST */ // Default shared memory key # if !defined (ACE_DEFAULT_SHM_KEY) # define ACE_DEFAULT_SHM_KEY 1234 # endif /* ACE_DEFAULT_SHM_KEY */ // Default segment size used by SYSV shared memory (128 K) # if !defined (ACE_DEFAULT_SEGMENT_SIZE) # define ACE_DEFAULT_SEGMENT_SIZE 1024 * 128 # endif /* ACE_DEFAULT_SEGMENT_SIZE */ // Maximum number of SYSV shared memory segments // (does anyone know how to figure out the right values?!) # if !defined (ACE_DEFAULT_MAX_SEGMENTS) # define ACE_DEFAULT_MAX_SEGMENTS 6 # endif /* ACE_DEFAULT_MAX_SEGMENTS */ // Name of the map that's stored in shared memory. # if !defined (ACE_NAME_SERVER_MAP) # define ACE_NAME_SERVER_MAP "Name Server Map" # endif /* ACE_NAME_SERVER_MAP */ // Default file permissions. # if !defined (ACE_DEFAULT_FILE_PERMS) # define ACE_DEFAULT_FILE_PERMS 0666 # endif /* ACE_DEFAULT_FILE_PERMS */ // Default directory permissions. # if !defined (ACE_DEFAULT_DIR_PERMS) # define ACE_DEFAULT_DIR_PERMS 0777 # endif /* ACE_DEFAULT_DIR_PERMS */ // Default size of the ACE Reactor. # if !defined (ACE_DEFAULT_SELECT_REACTOR_SIZE) # define ACE_DEFAULT_SELECT_REACTOR_SIZE FD_SETSIZE # endif /* ACE_DEFAULT_SELECT_REACTOR_SIZE */ // Default size of the ACE Map_Manager. # if !defined (ACE_DEFAULT_MAP_SIZE) # define ACE_DEFAULT_MAP_SIZE 1024 # endif /* ACE_DEFAULT_MAP_SIZE */ // Defaults for ACE Timer Wheel # if !defined (ACE_DEFAULT_TIMER_WHEEL_SIZE) # define ACE_DEFAULT_TIMER_WHEEL_SIZE 1024 # endif /* ACE_DEFAULT_TIMER_WHEEL_SIZE */ # if !defined (ACE_DEFAULT_TIMER_WHEEL_RESOLUTION) # define ACE_DEFAULT_TIMER_WHEEL_RESOLUTION 100 # endif /* ACE_DEFAULT_TIMER_WHEEL_RESOLUTION */ // Default size for ACE Timer Hash table # if !defined (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE) # define ACE_DEFAULT_TIMER_HASH_TABLE_SIZE 1024 # endif /* ACE_DEFAULT_TIMER_HASH_TABLE_SIZE */ // Defaults for the ACE Free List # if !defined (ACE_DEFAULT_FREE_LIST_PREALLOC) # define ACE_DEFAULT_FREE_LIST_PREALLOC 0 # endif /* ACE_DEFAULT_FREE_LIST_PREALLOC */ # if !defined (ACE_DEFAULT_FREE_LIST_LWM) # define ACE_DEFAULT_FREE_LIST_LWM 0 # endif /* ACE_DEFAULT_FREE_LIST_LWM */ # if !defined (ACE_DEFAULT_FREE_LIST_HWM) # define ACE_DEFAULT_FREE_LIST_HWM 25000 # endif /* ACE_DEFAULT_FREE_LIST_HWM */ # if !defined (ACE_DEFAULT_FREE_LIST_INC) # define ACE_DEFAULT_FREE_LIST_INC 100 # endif /* ACE_DEFAULT_FREE_LIST_INC */ # if !defined (ACE_UNIQUE_NAME_LEN) # define ACE_UNIQUE_NAME_LEN 100 # endif /* ACE_UNIQUE_NAME_LEN */ # if !defined (ACE_MAX_DGRAM_SIZE) // This is just a guess. 8k is the normal limit on // most machines because that's what NFS expects. # define ACE_MAX_DGRAM_SIZE 8192 # endif /* ACE_MAX_DGRAM_SIZE */ // Because most WinCE APIs use wchar strings, many of ACE functions // must adapt to this change also. For backward compatibility (most // platforms still use ASCII char APIs even if they support UNICODE,) // these new macros are introduced to avoid code bloating. // // ASYS stands for ACE SYSTEM something. # if defined (ACE_HAS_MOSTLY_UNICODE_APIS) # define ASYS_TCHAR wchar_t # define ASYS_TEXT(STRING) _TEXT(STRING) # else # define ASYS_TCHAR char # define ASYS_TEXT(STRING) STRING # endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ // Here are all ACE-specific global declarations needed throughout // ACE. // Helpful dump macros. # define ACE_BEGIN_DUMP ASYS_TEXT ("\n====\n(%P|%t|%x)") # define ACE_END_DUMP ASYS_TEXT ("====\n") // A free list which create more elements when there aren't enough // elements. # define ACE_FREE_LIST_WITH_POOL 1 // A simple free list which doen't allocate/deallocate elements. # define ACE_PURE_FREE_LIST 2 # if defined (ACE_NDEBUG) # define ACE_DB(X) # else # define ACE_DB(X) X # endif /* ACE_NDEBUG */ // Nasty macro stuff to account for Microsoft Win32 DLL nonsense. We // use these macros so that we don't end up with ACE software // hard-coded to Microsoft proprietary extensions to C++. // First, we define how to properly export/import objects. # if defined (ACE_WIN32) // Only Win32 needs special treatment. # if defined(_MSC_VER) || defined(__BORLANDC__) /* Microsoft, Borland: */ # define ACE_Proper_Export_Flag __declspec (dllexport) # define ACE_Proper_Import_Flag __declspec (dllimport) # define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T # define ACE_IMPORT_SINGLETON_DECLARATION(T) extern template class T # else /* defined(_MSC_VER) || defined(__BORLANDC__) */ /* Non-Microsoft, non-Borland: */ # define ACE_Proper_Export_Flag _export # define ACE_Proper_Import_Flag _import # define ACE_EXPORT_SINGLETON_DECLARATION(T) # define ACE_IMPORT_SINGLETON_DECLARATION(T) # endif /* defined(_MSC_VER) || defined(__BORLANDC__) */ # else /* ! ACE_WIN32 */ # define ACE_Proper_Export_Flag # define ACE_Proper_Import_Flag # define ACE_EXPORT_SINGLETON_DECLARATION(T) # define ACE_IMPORT_SINGLETON_DECLARATION(T) # endif /* ACE_WIN32 */ // Here are definition for ACE library. # if defined (ACE_HAS_DLL) && (ACE_HAS_DLL == 1) # if defined (ACE_BUILD_DLL) # define ACE_Export ACE_Proper_Export_Flag # define ACE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) # else # define ACE_Export ACE_Proper_Import_Flag # define ACE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) # endif /* ACE_BUILD_DLL */ # else /* ! ACE_HAS_DLL */ # define ACE_Export # define ACE_SINGLETON_DECLARATION(T) # endif /* ACE_HAS_DLL */ // Here are definition for ACE_Svc library. # if defined (ACE_HAS_SVC_DLL) && (ACE_HAS_SVC_DLL == 1) # if defined (ACE_BUILD_SVC_DLL) # define ACE_Svc_Export ACE_Proper_Export_Flag # define ACE_SVC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) # else # define ACE_Svc_Export ACE_Proper_Import_Flag # define ACE_SVC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) # endif /* ACE_BUILD_SVC_DLL */ # else /* ACE_HAS_SVC_DLL */ # define ACE_Svc_Export # define ACE_SVC_SINGLETON_DECLARATION(T) # endif /* ACE_HAS_SVC_DLL */ // This is a whim of mine -- that instead of annotating a class with // ACE_Export in its declaration, we make the declaration near the TOP // of the file with ACE_DECLARE_EXPORT. # define ACE_DECLARE_EXPORT(TS,ID) TS ACE_Export ID // TS = type specifier (e.g., class, struct, int, etc.) // ID = identifier // So, how do you use it? Most of the time, just use ... // ACE_DECLARE_EXPORT(class, someobject); // If there are global functions to be exported, then use ... // ACE_DECLARE_EXPORT(void, globalfunction) (int, ...); // Someday, when template libraries are supported, we made need ... // ACE_DECLARE_EXPORT(template class, sometemplate) ; // ACE_NO_HEAP_CHECK macro can be used to suppress false report of // memory leaks. It turns off the built-in heap checking until the // block is left. The old state will then be restored Only used for // Win32 (in the moment). # if defined (ACE_WIN32) // This is necessary to work around bugs with Win32 non-blocking // connects... # if !defined (ACE_NON_BLOCKING_BUG_DELAY) # define ACE_NON_BLOCKING_BUG_DELAY 35000 # endif /* ACE_NON_BLOCKING_BUG_DELAY */ # if defined (_DEBUG) && !defined (ACE_HAS_WINCE) class ACE_Export ACE_No_Heap_Check { public: ACE_No_Heap_Check (void) : old_state (_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG)) { _CrtSetDbgFlag (old_state & ~_CRTDBG_ALLOC_MEM_DF);} ~ACE_No_Heap_Check (void) { _CrtSetDbgFlag (old_state);} private: int old_state; }; # define ACE_NO_HEAP_CHECK ACE_No_Heap_Check ____no_heap; # else /* !_DEBUG */ # define ACE_NO_HEAP_CHECK # endif /* _DEBUG */ # else /* !ACE_WIN32 */ # define ACE_NO_HEAP_CHECK # endif /* ACE_WIN32 */ // Turn a number into a string. # define ACE_ITOA(X) #X // Create a string of a server address with a "host:port" format. # define ACE_SERVER_ADDRESS(H,P) H":"P // A couple useful inline functions for checking whether bits are // enabled or disabled. // Efficiently returns the least power of two >= X... # define ACE_POW(X) (((X) == 0)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X))) # define ACE_EVEN(NUM) (((NUM) & 1) == 0) # define ACE_ODD(NUM) (((NUM) & 1) == 1) # define ACE_BIT_ENABLED(WORD, BIT) (((WORD) & (BIT)) != 0) # define ACE_BIT_DISABLED(WORD, BIT) (((WORD) & (BIT)) == 0) # define ACE_BIT_CMP_MASK(WORD, BIT, MASK) (((WORD) & (BIT)) == MASK) # define ACE_SET_BITS(WORD, BITS) (WORD |= (BITS)) # define ACE_CLR_BITS(WORD, BITS) (WORD &= ~(BITS)) # define ACE_MAX(x,y) (((x)>(y))?(x):(y)) # define ACE_MIN(x,y) (((x)<(y))?(x):(y)) // Keep the compiler from complaining about parameters which are not used. # if defined (ghs) || defined (__GNUC__) || defined (__hpux) || defined (__sgi) || defined (DEC_CXX) || defined (__KCC) || defined (__rational__) // Some compilers complain about "statement with no effect" with (a). // This eliminates the warnings, and no code is generated for the null // conditional statement. NOTE: that may only be true if -O is enabled, // such as with GreenHills (ghs) 1.8.8. # define ACE_UNUSED_ARG(a) {if (&a) /* null */ ;} # else # define ACE_UNUSED_ARG(a) (a) # endif /* ghs */ # if defined (__sgi) || defined (ghs) || defined (DEC_CXX) || defined(__BORLANDC__) # define ACE_NOTREACHED(a) # else # define ACE_NOTREACHED(a) a # endif /* defined (__sgi) || defined (ghs) || defined (DEC_CXX) || defined(__BORLANDC__) */ # if defined (ACE_REQUIRES_FUNC_DEFINITIONS) // It just evaporated ;-) Not pleasant. # define ACE_UNIMPLEMENTED_FUNC(f) # else # define ACE_UNIMPLEMENTED_FUNC(f) f; # endif /* ACE_REQUIRES_FUNC_DEFINITIONS */ // Easy way to designate that a class is used as a pseudo-namespace. // Insures that g++ "friendship" anamolies are properly handled. # define ACE_CLASS_IS_NAMESPACE(CLASSNAME) \ private: \ CLASSNAME (void); \ CLASSNAME (const CLASSNAME&); \ friend class ace_dewarn_gplusplus // These hooks enable ACE to have all dynamic memory management // automatically handled on a per-object basis. # if defined (ACE_HAS_ALLOC_HOOKS) # define ACE_ALLOC_HOOK_DECLARE \ void *operator new (size_t bytes); \ void operator delete (void *ptr); // Note that these are just place holders for now. They'll // be replaced by the ACE_Malloc stuff shortly... # define ACE_ALLOC_HOOK_DEFINE(CLASS) \ void *CLASS::operator new (size_t bytes) { return ::new char[bytes]; } \ void CLASS::operator delete (void *ptr) { delete (ptr); } # else # define ACE_ALLOC_HOOK_DECLARE struct __Ace {} /* Just need a dummy... */ # define ACE_ALLOC_HOOK_DEFINE(CLASS) # endif /* ACE_HAS_ALLOC_HOOKS */ # if defined (ACE_LACKS_KEY_T) # if defined (ACE_WIN32) // Win32 doesn't use numeric values to name its semaphores, it uses // strings! typedef char *key_t; # else typedef int key_t; # endif /* ACE_WIN32 */ # endif /* ACE_LACKS_KEY_T */ # if defined (VXWORKS) # if defined (ghs) // GreenHills 1.8.8 needs the stdarg.h #include before the #include of // vxWorks.h. // Also, be sure that these #includes come _after_ the key_t typedef, and // before the #include of time.h. # include /**/ # endif /* ghs */ # include /**/ # endif /* VXWORKS */ /////////////////////////////////////////// // // // NOTE: Please do not add any #includes // // before this point. On VxWorks, // // vxWorks.h must be #included // // first! // // // /////////////////////////////////////////// # if defined (ACE_PSOS) # include /* system configuration file */ # include /**/ /* pSOS+ system calls */ # include /**/ /* pNA+ TCP/IP Network Manager calls */ # if defined (ACE_PSOSIM) /* In the *simulator* environment, use unsigned int for size_t */ # define size_t unsigned int // #include /**/ /* pREPC+ ANSI C Standard Library calls */ /* include pRPC+ Remote Procedure Call Library calls */ /* are not supported by pSOSim */ /* */ /* include pHILE+ file system calls are not supported */ /* by pSOSim *so*, for the time being, we make */ /* use of UNIX file system headers and then */ /* when we have time, we wrap UNIX file system */ /* calls w/ pHILE+ wrappers, and modify ACE to */ /* use the wrappers under pSOSim */ /* put includes for necessary UNIX file system calls here */ # include /**/ # include /**/ # include /**/ # include /**/ // remap missing error numbers for system functions # define EPERM 1 /* Not super-user */ # define ENOENT 2 /* No such file or directory */ # define ESRCH 3 /* No such process */ # define EINTR 4 /* interrupted system call */ # define EBADF 9 /* Bad file number */ # define EAGAIN 11 /* Resource temporarily unavailable */ # define EWOULDBLOCK EAGAIN /* Blocking resource request would block */ # define ENOMEM 12 /* Not enough core */ # define EACCES 13 /* Permission denied */ # define EEXIST 17 /* File exists */ # define ENOSPC 28 /* No space left on device */ # define EPIPE 32 /* Broken pipe */ # define ETIME 62 /* timer expired */ # define ENAMETOOLONG 78 /* path name is too long */ # define ENOSYS 89 /* Unsupported file system operation */ # define EADDRINUSE 125 /* Address already in use */ # define ENETUNREACH 128 /* Network is unreachable */ # define EISCONN 133 /* Socket is already connected */ # define ESHUTDOWN 143 /* Can't send after socket shutdown */ # define ECONNREFUSED 146 /* Connection refused */ # define EINPROGRESS 150 /* operation now in progress */ # define ERRMAX 151 /* Last error number */ # define TCP_ # if ! defined (BUFSIZ) # define BUFSIZ 1024 # endif /* ! defined (BUFSIZ) */ # else # include /**/ /* pRPC+ Remote Procedure Call Library calls */ # include /**/ /* pHILE+ file system calls */ # endif /* defined (ACE_PSOSIM) */ // For general purpose portability // Use pSOS semaphores, wrapped . . . typedef struct { u_long sema_; // Semaphore handle. This is allocated by pSOS. char name_[4]; // Name of the semaphore: really a 32 bit number to pSOS } ACE_sema_t; // Used for ACE_MMAP_Memory_Pool # if !defined (ACE_DEFAULT_BACKING_STORE) # define ACE_DEFAULT_BACKING_STORE "/tmp/ace-malloc-XXXXXX" # endif /* ACE_DEFAULT_BACKING_STORE */ // Used for logging # if !defined (ACE_DEFAULT_LOGFILE) # define ACE_DEFAULT_LOGFILE "/tmp/logfile" # endif /* ACE_DEFAULT_LOGFILE */ // Used for dynamic linking. # if !defined (ACE_DEFAULT_SVC_CONF) # define ACE_DEFAULT_SVC_CONF "./svc.conf" # endif /* ACE_DEFAULT_SVC_CONF */ # if !defined (ACE_DEFAULT_SEM_KEY) # define ACE_DEFAULT_SEM_KEY "ACE_SEM_KEY" # endif /* ACE_DEFAULT_SEM_KEY */ # define ACE_STDIN 0 # define ACE_STDOUT 1 # define ACE_STDERR 2 # define ACE_DIRECTORY_SEPARATOR_STR_A "/" # define ACE_DIRECTORY_SEPARATOR_CHAR_A '/' # define ACE_DLL_SUFFIX ".so" # define ACE_DLL_PREFIX "lib" # define ACE_LD_SEARCH_PATH "LD_LIBRARY_PATH" # define ACE_LD_SEARCH_PATH_SEPARATOR_STR ":" # define ACE_LOGGER_KEY "/tmp/server_daemon" # define ACE_PLATFORM_A "pSOS" # define ACE_PLATFORM_EXE_SUFFIX_A "" # if defined (ACE_HAS_UNICODE) # define ACE_DIRECTORY_SEPARATOR_STR_W L"/" # define ACE_DIRECTORY_SEPARATOR_CHAR_W L'/' # define ACE_PLATFORM_W L"pSOS" # define ACE_PLATFORM_EXE_SUFFIX_W L"" # else # define ACE_DIRECTORY_SEPARATOR_STR_W "/" # define ACE_DIRECTORY_SEPARATOR_CHAR_W '/' # define ACE_PLATFORM_W "pSOS" # define ACE_PLATFORM_EXE_SUFFIX_W "" # endif /* ACE_HAS_UNICODE */ # define ACE_MAX_DEFAULT_PORT 65535 # if ! defined(MAXPATHLEN) # define MAXPATHLEN 1024 # endif /* MAXPATHLEN */ # if ! defined(MAXNAMLEN) # define MAXNAMLEN 255 # endif /* MAXNAMLEN */ # if ! defined(MAXHOSTNAMELEN) # define MAXHOSTNAMELEN 256 # endif /* MAXHOSTNAMELEN */ # if defined (ACE_LACKS_MMAP) # define PROT_READ 0 # define PROT_WRITE 0 # define PROT_EXEC 0 # define PROT_NONE 0 # define PROT_RDWR 0 # define MAP_PRIVATE 0 # define MAP_SHARED 0 # define MAP_FIXED 0 # endif /* ACE_LACKS_MMAP */ // The following 3 defines are used by the ACE Name Server... # if !defined (ACE_DEFAULT_NAMESPACE_DIR_A) # define ACE_DEFAULT_NAMESPACE_DIR_A "/tmp" # endif /* ACE_DEFAULT_NAMESPACE_DIR_A */ # if !defined (ACE_DEFAULT_LOCALNAME_A) # define ACE_DEFAULT_LOCALNAME_A "localnames" # endif /* ACE_DEFAULT_LOCALNAME_A */ # if !defined (ACE_DEFAULT_GLOBALNAME_A) # define ACE_DEFAULT_GLOBALNAME_A "globalnames" # endif /* ACE_DEFAULT_GLOBALNAME_A */ # if defined (ACE_HAS_UNICODE) # if !defined (ACE_DEFAULT_NAMESPACE_DIR_W) # define ACE_DEFAULT_NAMESPACE_DIR_W L"/tmp" # endif /* ACE_DEFAULT_NAMESPACE_DIR_W */ # if !defined (ACE_DEFAULT_LOCALNAME_W) # define ACE_DEFAULT_LOCALNAME_W L"localnames" # endif /* ACE_DEFAULT_LOCALNAME_W */ # if !defined (ACE_DEFAULT_GLOBALNAME_W) # define ACE_DEFAULT_GLOBALNAME_W L"globalnames" # endif /* ACE_DEFAULT_GLOBALNAME_W */ # else # if !defined (ACE_DEFAULT_NAMESPACE_DIR_W) # define ACE_DEFAULT_NAMESPACE_DIR_W "/tmp" # endif /* ACE_DEFAULT_NAMESPACE_DIR_W */ # if !defined (ACE_DEFAULT_LOCALNAME_W) # define ACE_DEFAULT_LOCALNAME_W "localnames" # endif /* ACE_DEFAULT_LOCALNAME_W */ # if !defined (ACE_DEFAULT_GLOBALNAME_W) # define ACE_DEFAULT_GLOBALNAME_W "globalnames" # endif /* ACE_DEFAULT_GLOBALNAME_W */ # endif /* ACE_HAS_UNICODE */ # if !defined (__TEXT) # if (defined (ACE_HAS_UNICODE) && (defined (UNICODE))) # define __TEXT(STRING) L##STRING # else # define __TEXT(STRING) STRING # endif /* UNICODE && ACE_HAS_UNICODE */ # endif /* !defined __TEXT */ typedef int ACE_HANDLE; typedef ACE_HANDLE ACE_SOCKET; # define ACE_INVALID_HANDLE -1 typedef ACE_HANDLE ACE_SHLIB_HANDLE; const int ACE_DEFAULT_SHLIB_MODE = 0; # define ACE_INVALID_SEM_KEY -1 struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* address length */ char **h_addr_list; /* (first, only) address from name server */ # define h_addr h_addr_list[0] /* the first address */ }; struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port # */ char *s_proto; /* protocol to use */ }; // For Win32 compatibility. typedef const char *LPCTSTR; typedef char *LPTSTR; typedef char TCHAR; # define ACE_SEH_TRY if (1) # define ACE_SEH_EXCEPT(X) while (0) # define ACE_SEH_FINALLY if (1) # if !defined (LPSECURITY_ATTRIBUTES) # define LPSECURITY_ATTRIBUTES int # endif /* !defined LPSECURITY_ATTRIBUTES */ # if !defined (GENERIC_READ) # define GENERIC_READ 0 # endif /* !defined GENERIC_READ */ # if !defined (FILE_SHARE_READ) # define FILE_SHARE_READ 0 # endif /* !defined FILE_SHARE_READ */ # if !defined (OPEN_EXISTING) # define OPEN_EXISTING 0 # endif /* !defined OPEN_EXISTING */ # if !defined (FILE_ATTRIBUTE_NORMAL) # define FILE_ATTRIBUTE_NORMAL 0 # endif /* !defined FILE_ATTRIBUTE_NORMAL */ # if !defined (MAXIMUM_WAIT_OBJECTS) # define MAXIMUM_WAIT_OBJECTS 0 # endif /* !defined MAXIMUM_WAIT_OBJECTS */ # if !defined (FILE_FLAG_OVERLAPPED) # define FILE_FLAG_OVERLAPPED 0 # endif /* !defined FILE_FLAG_OVERLAPPED */ # if !defined (FILE_FLAG_SEQUENTIAL_SCAN) # define FILE_FLAG_SEQUENTIAL_SCAN 0 # endif /* !defined FILE_FLAG_SEQUENTIAL_SCAN */ struct ACE_OVERLAPPED { u_long Internal; u_long InternalHigh; u_long Offset; u_long OffsetHigh; ACE_HANDLE hEvent; }; // Use pSOS time, wrapped . . . class ACE_Export ACE_PSOS_Time_t { public: ACE_PSOS_Time_t (); // default ctor: date, time, and ticks all zeroed ACE_PSOS_Time_t (const timespec_t& t); // ctor from a timespec_t operator timespec_t (); // type cast operator (to a timespec_t) static u_long get_system_time (ACE_PSOS_Time_t& t); // static member function to get current system time static u_long set_system_time (const ACE_PSOS_Time_t& t); // static member function to set current system time # if defined (ACE_PSOSIM) static u_long init_simulator_time (); // static member function to initialize system time, using UNIX calls # endif /* ACE_PSOSIM */ static const u_long max_ticks; // max number of ticks supported in a single system call private: // constants for prying info out of the pSOS time encoding static const u_long year_mask; static const u_long month_mask; static const u_long day_mask; static const u_long hour_mask; static const u_long minute_mask; static const u_long second_mask; static const int year_shift; static const int month_shift; static const int hour_shift; static const int minute_shift; static const int year_origin; static const int month_origin; // error codes static const u_long err_notime; // system time not set static const u_long err_illdate; // date out of range static const u_long err_illtime; // time out of range static const u_long err_illticks; // ticks out of range u_long date_; // date : year in bits 31-16, month in bits 15-8, day in bits 7-0 u_long time_; // time : hour in bits 31-16, minutes in bits 15-8, seconds in bits 7-0 u_long ticks_; // ticks: number of system clock ticks (KC_TICKS2SEC-1 max) } ; # endif /* defined (ACE_PSOS) */ # if defined (ACE_HAS_CHARPTR_SPRINTF) # define ACE_SPRINTF_ADAPTER(X) ::strlen (X) # else # define ACE_SPRINTF_ADAPTER(X) X # endif /* ACE_HAS_CHARPTR_SPRINTF */ # if defined (__ACE_INLINE__) # define ACE_INLINE inline # if !defined (ACE_HAS_INLINED_OSCALLS) # define ACE_HAS_INLINED_OSCALLS # endif /* !ACE_HAS_INLINED_OSCALLS */ # else # define ACE_INLINE # endif /* __ACE_INLINE__ */ // Default address for shared memory mapped files and SYSV shared memory // (defaults to 64 M). # if !defined (ACE_DEFAULT_BASE_ADDR) # define ACE_DEFAULT_BASE_ADDR ((char *) (64 * 1024 * 1024)) # endif /* ACE_DEFAULT_BASE_ADDR */ // This fudge factor can be overriden for timers that need it, such as on // Solaris, by defining the ACE_TIMER_SKEW symbol in the appropriate config // header. # if !defined (ACE_TIMER_SKEW) # define ACE_TIMER_SKEW 0 # endif /* ACE_TIMER_SKEW */ // This needs to go here *first* to avoid problems with AIX. // Just to be safe we'll do it with pthreads, too -- jwr # if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) extern "C" { # include /**/ # if defined (DIGITAL_UNIX) # define pthread_self __pthread_self extern "C" pthread_t pthread_self (void); # endif /* DIGITAL_UNIX */ } # endif /* ACE_HAS_DCETHREADS */ // There are a lot of threads-related macro definitions in the config files. // They came in at different times and from different places and platform // requirements as threads evolved. They are probably not all needed - some // overlap or are otherwise confused. This is an attempt to start // straightening them out. # if defined (ACE_HAS_PTHREADS_1003_DOT_1C) /* POSIX.1C threads (pthreads) */ // POSIX.1C threads implies pthread_sigmask() # if !defined (ACE_HAS_PTHREAD_SIGMASK) && !defined (__Lynx__) # define ACE_HAS_PTHREAD_SIGMASK # endif /* ! ACE_HAS_PTHREAD_SIGMASK && ! __Lynx__ */ // ... and 2-parameter asctime_r and ctime_r # ifndef ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R # define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R # endif # endif /* ACE_HAS_PTHREADS_1003_DOT_1C */ # if (ACE_NTRACE == 1) # define ACE_TRACE(X) # else # define ACE_TRACE(X) ACE_Trace ____ (ASYS_TEXT (X), __LINE__, ASYS_TEXT (__FILE__)) # endif /* ACE_NTRACE */ # if !defined (ACE_HAS_WINCE) # include /**/ # if defined (__Lynx__) # include /**/ # include /**/ # endif /* __Lynx__ */ # endif /* ACE_HAS_WINCE */ # if defined (ACE_NEEDS_SYSTIME_H) // Some platforms may need to include this, but I suspect that most // will get it from # if defined (VXWORKS) # include /**/ # else # include /**/ # endif /* VXWORKS */ # endif /* ACE_NEEDS_SYSTIME_H */ # if !defined (ACE_HAS_POSIX_TIME) // Definition per POSIX. typedef struct timespec { time_t tv_sec; // Seconds long tv_nsec; // Nanoseconds } timespec_t; # elif defined (ACE_HAS_BROKEN_POSIX_TIME) // OSF/1 defines struct timespec in - Tom Marrs # include /**/ # endif /* !ACE_HAS_POSIX_TIME */ # if defined(ACE_LACKS_TIMESPEC_T) typedef struct timespec timespec_t; # endif /* ACE_LACKS_TIMESPEC_T */ # if !defined (ACE_HAS_CLOCK_GETTIME) && !defined (_CLOCKID_T) typedef int clockid_t; # if !defined (CLOCK_REALTIME) # define CLOCK_REALTIME 0 # endif /* CLOCK_REALTIME */ # endif /* ! ACE_HAS_CLOCK_GETTIME && ! _CLOCKID_T */ class ACE_Export ACE_Time_Value { // = TITLE // Operations on "timeval" structures. // // = DESCRIPTION // This class centralizes all the time-related processing in // ACE. These timers are typically used in conjunction with // lower-level OS mechanisms like