diff options
Diffstat (limited to 'ace')
46 files changed, 6000 insertions, 0 deletions
diff --git a/ace/Main_Macros.h b/ace/Main_Macros.h new file mode 100644 index 00000000000..0d035901fd1 --- /dev/null +++ b/ace/Main_Macros.h @@ -0,0 +1,246 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Main_Macros.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + */ +//============================================================================= + + +// These are separate since they may include Object_Mananager.h (thus OS.h) depending +// on whether or not ACE_HAS_NONSTATIC_OBJECT_MANAGER is defined. + +#if !defined (ACE_MAIN_MACROS_H) +#define ACE_MAIN_MACROS_H + +#include "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_MAIN) +# define ACE_MAIN main +# endif /* ! ACE_MAIN */ + +# if !defined (ACE_WMAIN) +# define ACE_WMAIN wmain +# endif /* ! ACE_WMAIN */ + +# if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) +# define ACE_TMAIN wmain +# else +# define ACE_TMAIN main +# endif + +# if defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) +# if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) +# define ACE_HAS_NONSTATIC_OBJECT_MANAGER +# endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */ +# endif /* ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ + +# if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) + +# if !defined (ACE_HAS_MINIMAL_ACE_OS) +# include "ace/Object_Manager.h" +# endif /* ! ACE_HAS_MINIMAL_ACE_OS */ + +// Rename "main ()" on platforms that don't allow it to be called "main ()". + +// Also, create ACE_Object_Manager static instance(s) in "main ()". +// ACE_MAIN_OBJECT_MANAGER defines the ACE_Object_Manager(s) that will +// be instantiated on the stack of main (). Note that it is only used +// when compiling main (): its value does not affect the contents of +// ace/OS.o. +# if !defined (ACE_MAIN_OBJECT_MANAGER) +# define ACE_MAIN_OBJECT_MANAGER \ + ACE_OS_Object_Manager ace_os_object_manager; \ + ACE_Object_Manager ace_object_manager; +# endif /* ! ACE_MAIN_OBJECT_MANAGER */ + +# if defined (ACE_PSOSIM) +// PSOSIM root lacks the standard argc, argv command line parameters, +// create dummy argc and argv in the "real" main and pass to "user" main. +// NOTE: ACE_MAIN must be defined to give the return type as well as the +// name of the entry point. +# define main \ +ace_main_i (int, char *[]); /* forward declaration */ \ +ACE_MAIN () /* user's entry point, e.g., "main" w/out argc, argv */ \ +{ \ + int argc = 1; /* dummy arg count */ \ + char *argv[] = {"psosim"}; /* dummy arg list */ \ + ACE_MAIN_OBJECT_MANAGER \ + int ret_val = -1; /* assume the worst */ \ + if (ACE_PSOS_Time_t::init_simulator_time ()) /* init simulator time */ \ + { \ + ACE_ERROR((LM_ERROR, "init_simulator_time failed\n")); /* report */ \ + } \ + else \ + { \ + ret_val = ace_main_i (argc, argv); /* call user main, save result */ \ + } \ + ACE_OS::exit (ret_val); /* pass code to simulator exit */ \ +} \ +int \ +ace_main_i +# elif defined (ACE_PSOS) && defined (ACE_PSOS_LACKS_ARGC_ARGV) +// PSOS root lacks the standard argc, argv command line parameters, +// create dummy argc and argv in the "real" main and pass to "user" main. +// Ignore return value from user main as well. NOTE: ACE_MAIN must be +// defined to give the return type as well as the name of the entry point +# define main \ +ace_main_i (int, char *[]); /* forward declaration */ \ +ACE_MAIN () /* user's entry point, e.g., "main" w/out argc, argv */ \ +{ \ + int argc = 1; /* dummy arg count */ \ + char *argv[] = {"root"}; /* dummy arg list */ \ + ACE_MAIN_OBJECT_MANAGER \ + ace_main_i (argc, argv); /* call user main, ignore result */ \ +} \ +int \ +ace_main_i +# elif defined (ACE_HAS_WINCE) +/** + * @class ACE_CE_ARGV + * + * @brief This class is to hash input parameters, argc and argv, for WinCE platform. + * + * Since WinCE only supports wchar_t as an input from OS, some implementation detail, + * especially for CORBA spec, will not support ACE_TCHAR (wchar_t) type parameter. + * Moreover, WinCE's input parameter type is totally different than any other OS; + * all command line parameters will be stored in a single wide-character string with + * each unit parameter divided by blank space, and it does not provide the name of + * executable (generally known as argv[0]). + * This class is to convert CE's command line parameters and simulate as in the same + * manner as other general platforms, adding 'root' as a first argc, which is for the + * name of executable in other OS. + */ +class ACE_OS_Export ACE_CE_ARGV +{ +public: + /** + * Ctor accepts CE command line as a paramter. + */ + ACE_CE_ARGV(ACE_TCHAR* cmdLine); + + /** + * Default Dtor that deletes any memory allocated for the converted string. + */ + ~ACE_CE_ARGV(void); + + /** + * Returns the number of command line paramters, same as argc on Unix. + */ + int argc(void); + + /** + * Returns the 'char**' that contains the converted command line parameters. + */ + ACE_TCHAR** const argv(void); + +private: + /** + * Copy Ctor is not allowed. + */ + ACE_CE_ARGV(void); + + /** + * Copy Ctor is not allowed. + */ + ACE_CE_ARGV(ACE_CE_ARGV&); + + /** + * Pointer of converted command line paramters. + */ + ACE_TCHAR** ce_argv_; + + /** + * Integer that is same as argc on other OS's. + */ + int ce_argc_; +}; +# if defined (ACE_TMAIN) // Use WinMain on CE; others give warning/error. +# undef ACE_TMAIN +# endif // ACE_TMAIN + +// Support for ACE_TMAIN, which is a recommended way. +# define ACE_TMAIN \ +ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ +{ \ + ACE_CE_ARGV ce_argv(lpCmdLine); \ + ACE::init(); \ + ACE_MAIN_OBJECT_MANAGER \ + int i = ace_main_i (ce_argv.argc(), ce_argv.argv()); \ + ACE::fini(); \ + return i; \ +} \ +int ace_main_i + +// Support for wchar_t but still can't fit to CE because of the command line parameters. +# define wmain \ +ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ +{ \ + ACE_CE_ARGV ce_argv(lpCmdLine); \ + ACE::init(); \ + ACE_MAIN_OBJECT_MANAGER \ + int i = ace_main_i (ce_argv.argc(), ce_argv.argv()); \ + ACE::fini(); \ + return i; \ +} \ +int ace_main_i + +// Supporting legacy 'main' is A LOT easier for users than changing existing code on WinCE. +# define main \ +ace_main_i (int, char *[]); /* forward declaration */ \ +#include <ace/Argv_Type_Converter.h> \ +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ +{ \ + ACE_CE_ARGV ce_argv(lpCmdLine); \ + ACE::init(); \ + ACE_MAIN_OBJECT_MANAGER \ + ACE_Argv_Type_Converter command_line(ce_argv.argc(), ce_argv.argv()); \ + int i = ace_main_i (command_line.get_argc(), command_line.get_ASCII_argv()); \ + ACE::fini(); \ + return i; \ +} \ +int ace_main_i + +# else +# define main \ +ace_main_i (int, char *[]); /* forward declaration */ \ +int \ +ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \ +{ \ + ACE_MAIN_OBJECT_MANAGER \ + return ace_main_i (argc, argv); /* what the user calls "main" */ \ +} \ +int \ +ace_main_i +# if defined (ACE_WIN32) +# define wmain \ +ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ +int \ +ACE_WMAIN (int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., main */ \ +{ \ + ACE_MAIN_OBJECT_MANAGER \ + return ace_main_i (argc, argv); /* what the user calls "main" */ \ +} \ +int \ +ace_main_i +# endif /* ACE_WIN32 && UNICODE */ +# endif /* ACE_PSOSIM */ +# endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ + + +#endif /* ACE_MAIN_MACROS_H */ + diff --git a/ace/Object_Manager_Base.cpp b/ace/Object_Manager_Base.cpp new file mode 100644 index 00000000000..872cbfa7997 --- /dev/null +++ b/ace/Object_Manager_Base.cpp @@ -0,0 +1,643 @@ +// $Id$ + +#include "ace/Object_Manager_Base.h" + +#include "ace/OS_Errno.h" +#include "ace/os_include/threads.h" +#include "ace/OS.h" + + +ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0; + +ACE_Cleanup_Info::ACE_Cleanup_Info (void) + : object_ (0), + cleanup_hook_ (0), + param_ (0) +{ +} + +int +ACE_Cleanup_Info::operator== (const ACE_Cleanup_Info &o) const +{ + return o.object_ == this->object_ + && o.cleanup_hook_ == this->cleanup_hook_ + && o.param_ == this->param_; +} + +int +ACE_Cleanup_Info::operator!= (const ACE_Cleanup_Info &o) const +{ + return !(*this == o); +} + +class ACE_Cleanup_Info_Node +{ + // = TITLE + // For maintaining a list of ACE_Cleanup_Info items. + // + // = DESCRIPTION + // For internal use by ACE_Object_Manager. +public: + ACE_Cleanup_Info_Node (void); + ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, + ACE_Cleanup_Info_Node *next); + ~ACE_Cleanup_Info_Node (void); + ACE_Cleanup_Info_Node *insert (const ACE_Cleanup_Info &); +private: + ACE_Cleanup_Info cleanup_info_; + ACE_Cleanup_Info_Node *next_; + + friend class ACE_OS_Exit_Info; +}; + +ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void) + : cleanup_info_ (), + next_ (0) +{ +} + +ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, + ACE_Cleanup_Info_Node *next) + : cleanup_info_ (new_info), + next_ (next) +{ +} + +ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void) +{ + delete next_; +} + +ACE_Cleanup_Info_Node * +ACE_Cleanup_Info_Node::insert (const ACE_Cleanup_Info &new_info) +{ + ACE_Cleanup_Info_Node *new_node; + + ACE_NEW_RETURN (new_node, + ACE_Cleanup_Info_Node (new_info, this), + 0); + + return new_node; +} + +ACE_OS_Exit_Info::ACE_OS_Exit_Info (void) +{ + ACE_NEW (registered_objects_, ACE_Cleanup_Info_Node); +} + +ACE_OS_Exit_Info::~ACE_OS_Exit_Info (void) +{ + delete registered_objects_; + registered_objects_ = 0; +} + +int +ACE_OS_Exit_Info::at_exit_i (void *object, + ACE_CLEANUP_FUNC cleanup_hook, + void *param) +{ + ACE_Cleanup_Info new_info; + new_info.object_ = object; + new_info.cleanup_hook_ = cleanup_hook; + new_info.param_ = param; + + // Return -1 and sets errno if unable to allocate storage. Enqueue + // at the head and dequeue from the head to get LIFO ordering. + + ACE_Cleanup_Info_Node *new_node; + + if ((new_node = registered_objects_->insert (new_info)) == 0) + return -1; + else + { + registered_objects_ = new_node; + return 0; + } +} + +int +ACE_OS_Exit_Info::find (void *object) +{ + // Check for already in queue, and return 1 if so. + for (ACE_Cleanup_Info_Node *iter = registered_objects_; + iter && iter->next_ != 0; + iter = iter->next_) + { + if (iter->cleanup_info_.object_ == object) + { + // The object has already been registered. + return 1; + } + } + + return 0; +} + +void +ACE_OS_Exit_Info::call_hooks () +{ + // Call all registered cleanup hooks, in reverse order of + // registration. + for (ACE_Cleanup_Info_Node *iter = registered_objects_; + iter && iter->next_ != 0; + iter = iter->next_) + { + ACE_Cleanup_Info &info = iter->cleanup_info_; + if (info.cleanup_hook_ == ACE_reinterpret_cast (ACE_CLEANUP_FUNC, + ace_cleanup_destroyer)) + // The object is an ACE_Cleanup. + ace_cleanup_destroyer (ACE_reinterpret_cast (ACE_Cleanup *, + info.object_), + info.param_); + else if (info.object_ == &ace_exit_hook_marker) + // The hook is an ACE_EXIT_HOOK. + (* ACE_reinterpret_cast (ACE_EXIT_HOOK, info.cleanup_hook_)) (); + else + (*info.cleanup_hook_) (info.object_, info.param_); + } +} + +extern "C" void +ace_cleanup_destroyer (ACE_Cleanup *object, void *param) +{ + object->cleanup (param); +} + +void +ACE_Cleanup::cleanup (void *) +{ + delete this; +} + +//ACE_INLINE +ACE_Cleanup::ACE_Cleanup (void) +{ +} + +ACE_Cleanup::~ACE_Cleanup (void) +{ +} + +#define ACE_OS_PREALLOCATE_OBJECT(TYPE, ID)\ + {\ + TYPE *obj_p = 0;\ + ACE_NEW_RETURN (obj_p, TYPE, -1);\ + preallocated_object[ID] = (void *) obj_p;\ + } +#define ACE_OS_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\ + delete (TYPE *) preallocated_object[ID];\ + preallocated_object[ID] = 0; + +ACE_Object_Manager_Base::ACE_Object_Manager_Base (void) + : object_manager_state_ (OBJ_MAN_UNINITIALIZED) + , dynamically_allocated_ (0) + , next_ (0) +{ +} + +ACE_Object_Manager_Base::~ACE_Object_Manager_Base (void) +{ +#if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) + // Clear the flag so that fini () doesn't delete again. + dynamically_allocated_ = 0; +#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */ +} + +int +ACE_Object_Manager_Base::starting_up_i () +{ + return object_manager_state_ < OBJ_MAN_INITIALIZED; +} + +int +ACE_Object_Manager_Base::shutting_down_i () +{ + return object_manager_state_ > OBJ_MAN_INITIALIZED; +} + +extern "C" +void +ACE_OS_Object_Manager_Internal_Exit_Hook (void) +{ + if (ACE_OS_Object_Manager::instance_) + ACE_OS_Object_Manager::instance ()->fini (); +} + +ACE_OS_Object_Manager *ACE_OS_Object_Manager::instance_ = 0; + +void *ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_OS_PREALLOCATED_OBJECTS] = { 0 }; + +ACE_OS_Object_Manager::ACE_OS_Object_Manager (void) + // default_mask_ isn't initialized, because it's defined by <init>. + : thread_hook_ (0) + , exit_info_ () +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , seh_except_selector_ (ACE_SEH_Default_Exception_Selector) + , seh_except_handler_ (ACE_SEH_Default_Exception_Handler) +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +{ + // If instance_ was not 0, then another ACE_OS_Object_Manager has + // already been instantiated (it is likely to be one initialized by + // way of library/DLL loading). Let this one go through + // construction in case there really is a good reason for it (like, + // ACE is a static/archive library, and this one is the non-static + // instance (with ACE_HAS_NONSTATIC_OBJECT_MANAGER, or the user has + // a good reason for creating a separate one) but the original one + // will be the one retrieved from calls to + // ACE_Object_Manager::instance(). + + // Be sure that no further instances are created via instance (). + if (instance_ == 0) + instance_ = this; + + init (); +} + +ACE_OS_Object_Manager::~ACE_OS_Object_Manager (void) +{ + dynamically_allocated_ = 0; // Don't delete this again in fini() + fini (); +} + +sigset_t * +ACE_OS_Object_Manager::default_mask (void) +{ + return ACE_OS_Object_Manager::instance ()->default_mask_; +} + +ACE_Thread_Hook * +ACE_OS_Object_Manager::thread_hook (void) +{ + return ACE_OS_Object_Manager::instance ()->thread_hook_; +} + +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +ACE_SEH_EXCEPT_HANDLER +ACE_OS_Object_Manager::seh_except_selector (void) +{ + return ACE_OS_Object_Manager::instance ()->seh_except_selector_; +} + +ACE_SEH_EXCEPT_HANDLER +ACE_OS_Object_Manager::seh_except_selector (ACE_SEH_EXCEPT_HANDLER n) +{ + ACE_OS_Object_Manager *instance = + ACE_OS_Object_Manager::instance (); + + ACE_SEH_EXCEPT_HANDLER retv = instance->seh_except_selector_; + instance->seh_except_selector_ = n; + return retv; +} + +ACE_SEH_EXCEPT_HANDLER +ACE_OS_Object_Manager::seh_except_handler (void) +{ + return ACE_OS_Object_Manager::instance ()->seh_except_handler_; +} + +ACE_SEH_EXCEPT_HANDLER +ACE_OS_Object_Manager::seh_except_handler (ACE_SEH_EXCEPT_HANDLER n) +{ + ACE_OS_Object_Manager *instance = + ACE_OS_Object_Manager::instance (); + + ACE_SEH_EXCEPT_HANDLER retv = instance->seh_except_handler_; + instance->seh_except_handler_ = n; + return retv; +} +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + +ACE_Thread_Hook * +ACE_OS_Object_Manager::thread_hook (ACE_Thread_Hook *new_thread_hook) +{ + ACE_OS_Object_Manager *os_om = ACE_OS_Object_Manager::instance (); + ACE_Thread_Hook *old_hook = os_om->thread_hook_; + os_om->thread_hook_ = new_thread_hook; + return old_hook; +} + +ACE_OS_Object_Manager * +ACE_OS_Object_Manager::instance (void) +{ + // This function should be called during construction of static + // instances, or before any other threads have been created in the + // process. So, it's not thread safe. + + if (instance_ == 0) + { + ACE_OS_Object_Manager *instance_pointer; + + ACE_NEW_RETURN (instance_pointer, + ACE_OS_Object_Manager, + 0); + // I (coryan) removed it, using asserts in the OS layer + // brings down the Log msg stuff + // ACE_ASSERT (instance_pointer == instance_); + + instance_pointer->dynamically_allocated_ = 1; + + } + + return instance_; +} + +int +ACE_OS_Object_Manager::init (void) +{ + if (starting_up_i ()) + { + // First, indicate that this ACE_OS_Object_Manager instance is being + // initialized. + object_manager_state_ = OBJ_MAN_INITIALIZING; + + if (this == instance_) + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# if defined (ACE_HAS_WINCE_BROKEN_ERRNO) + ACE_CE_Errno::init (); +# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */ + ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t, ACE_OS_MONITOR_LOCK) + if (ACE_OS::thread_mutex_init + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_OS_MONITOR_LOCK")); + ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t, + ACE_TSS_CLEANUP_LOCK) + if (ACE_OS::recursive_mutex_init + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_TSS_CLEANUP_LOCK")); + ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t, + ACE_LOG_MSG_INSTANCE_LOCK) + if (ACE_OS::thread_mutex_init + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_LOG_MSG_INSTANCE_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK")); +# if defined (ACE_HAS_TSS_EMULATION) + ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t, + ACE_TSS_KEY_LOCK) + if (ACE_OS::recursive_mutex_init + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_TSS_KEY_LOCK")); +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t, + ACE_TSS_BASE_LOCK) + if (ACE_OS::recursive_mutex_init + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_TSS_BASE_LOCK")); +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ +# endif /* ACE_HAS_TSS_EMULATION */ +#endif /* ACE_MT_SAFE */ + + // Open Winsock (no-op on other platforms). + ACE_OS::socket_init (ACE_WSOCK_VERSION); + + // Register the exit hook, for use by ACE_OS::exit (). + ACE_OS::set_exit_hook (&ACE_OS_Object_Manager_Internal_Exit_Hook); + } + + ACE_NEW_RETURN (default_mask_, sigset_t, -1); + ACE_OS::sigfillset (default_mask_); + + // Finally, indicate that the ACE_OS_Object_Manager instance has + // been initialized. + object_manager_state_ = OBJ_MAN_INITIALIZED; + +#if defined (ACE_WIN32) + ACE_OS::win32_versioninfo_.dwOSVersionInfoSize = + sizeof (OSVERSIONINFO); + ::GetVersionEx (&ACE_OS::win32_versioninfo_); +#endif /* ACE_WIN32 */ + return 0; + } else { + // Had already initialized. + return 1; + } +} + +// Clean up an ACE_OS_Object_Manager. There can be instances of this object +// other than The Instance. This can happen if a user creates one for some +// reason. All objects clean up their per-object information and managed +// objects, but only The Instance cleans up the static preallocated objects. +int +ACE_OS_Object_Manager::fini (void) +{ + if (instance_ == 0 || shutting_down_i ()) + // Too late. Or, maybe too early. Either fini () has already + // been called, or init () was never called. + return object_manager_state_ == OBJ_MAN_SHUT_DOWN ? 1 : -1; + + // No mutex here. Only the main thread should destroy the singleton + // ACE_OS_Object_Manager instance. + + // Indicate that the ACE_OS_Object_Manager instance is being shut + // down. This object manager should be the last one to be shut + // down. + object_manager_state_ = OBJ_MAN_SHUTTING_DOWN; + + // If another Object_Manager has registered for termination, do it. + if (next_) + { + next_->fini (); + next_ = 0; // Protect against recursive calls. + } + + // Call all registered cleanup hooks, in reverse order of + // registration. + exit_info_.call_hooks (); + + // Only clean up preallocated objects when the singleton Instance is being + // destroyed. + if (this == instance_) + { + // Close down Winsock (no-op on other platforms). + ACE_OS::socket_fini (); + +#if ! defined (ACE_HAS_STATIC_PREALLOCATION) + // Cleanup the dynamically preallocated objects. +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK) + if (ACE_OS::thread_mutex_destroy + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_OS_MONITOR_LOCK")); +# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ + ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t, + ACE_OS_MONITOR_LOCK) +# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK) + if (ACE_OS::recursive_mutex_destroy + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_TSS_CLEANUP_LOCK")); +# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ + ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t, + ACE_TSS_CLEANUP_LOCK) +# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK) + if (ACE_OS::thread_mutex_destroy + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object [ACE_LOG_MSG_INSTANCE_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK ")); +# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ + ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t, + ACE_LOG_MSG_INSTANCE_LOCK) +# if defined (ACE_HAS_TSS_EMULATION) +# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK) + if (ACE_OS::recursive_mutex_destroy + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_TSS_KEY_LOCK")); +# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ + ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t, + ACE_TSS_KEY_LOCK) +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) +# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK) + if (ACE_OS::recursive_mutex_destroy + // This line must not be broken to avoid tickling a bug with SunC++'s preprocessor. + (ACE_reinterpret_cast (ACE_recursive_thread_mutex_t *, ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0) + ACE_OS_Object_Manager::print_error_message ( + __LINE__, ACE_LIB_TEXT ("ACE_TSS_BASE_LOCK")); +# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */ + ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t, + ACE_TSS_BASE_LOCK) +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ +# endif /* ACE_HAS_TSS_EMULATION */ +# if defined (ACE_HAS_WINCE_BROKEN_ERRNO) + ACE_CE_Errno::fini (); +# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */ +# endif /* ACE_MT_SAFE */ +#endif /* ! ACE_HAS_STATIC_PREALLOCATION */ + } + + delete default_mask_; + default_mask_ = 0; + + // Indicate that this ACE_OS_Object_Manager instance has been shut down. + object_manager_state_ = OBJ_MAN_SHUT_DOWN; + + if (dynamically_allocated_) + { + delete this; + } + + if (this == instance_) + instance_ = 0; + + return 0; +} + +int ace_exit_hook_marker = 0; + +int +ACE_OS_Object_Manager::at_exit (ACE_EXIT_HOOK func) +{ + return exit_info_.at_exit_i (&ace_exit_hook_marker, + ACE_reinterpret_cast (ACE_CLEANUP_FUNC, func), + 0); +} + +void +ACE_OS_Object_Manager::print_error_message (u_int line_number, + const ACE_TCHAR *message) +{ + // To avoid duplication of these const strings in OS.o. +#if !defined (ACE_HAS_WINCE) + fprintf (stderr, "ace/OS.cpp, line %u: %s ", + line_number, + message); + perror ("failed"); +#else + // @@ Need to use the following information. + ACE_UNUSED_ARG (line_number); + ACE_UNUSED_ARG (message); + + ACE_TCHAR *lpMsgBuf = 0; + ::FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + ::GetLastError (), + MAKELANGID (LANG_NEUTRAL, + SUBLANG_DEFAULT), + // Default language + (ACE_TCHAR *) &lpMsgBuf, + 0, + NULL); + ::MessageBox (NULL, + lpMsgBuf, + ACE_LIB_TEXT ("ACE_OS error"), + MB_OK); +#endif +} + +int +ACE_OS_Object_Manager::starting_up (void) +{ + return ACE_OS_Object_Manager::instance_ + ? instance_->starting_up_i () + : 1; +} + +int +ACE_OS_Object_Manager::shutting_down (void) +{ + return ACE_OS_Object_Manager::instance_ + ? instance_->shutting_down_i () + : 1; +} + +#if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) +class ACE_OS_Object_Manager_Manager + // = TITLE + // Ensure that the <ACE_OS_Object_Manager> gets initialized at + // program startup, and destroyed at program termination. + // + // = DESCRIPTION + // Without ACE_HAS_NONSTATIC_OBJECT_MANAGER, a static instance of this + // class is created. Therefore, it gets created before main () + // is called. And it gets destroyed after main () returns. +{ +public: + ACE_OS_Object_Manager_Manager (void); + ~ACE_OS_Object_Manager_Manager (void); + +private: + ACE_thread_t saved_main_thread_id_; + // Save the main thread ID, so that destruction can be suppressed. +}; + +ACE_OS_Object_Manager_Manager::ACE_OS_Object_Manager_Manager (void) + : saved_main_thread_id_ (ACE_OS::thr_self ()) +{ + // Ensure that the Object_Manager gets initialized before any + // application threads have been spawned. Because this will be called + // during construction of static objects, that should always be the + // case. + (void) ACE_OS_Object_Manager::instance (); +} + +ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager (void) +{ + if (ACE_OS::thr_equal (ACE_OS::thr_self (), + saved_main_thread_id_)) + { + delete ACE_OS_Object_Manager::instance_; + ACE_OS_Object_Manager::instance_ = 0; + } + // else if this destructor is not called by the main thread, then do + // not delete the ACE_OS_Object_Manager. That causes problems, on + // WIN32 at least. +} + +static ACE_OS_Object_Manager_Manager ACE_OS_Object_Manager_Manager_instance; +#endif /* ! ACE_HAS_NONSTATIC_OBJECT_MANAGER */ diff --git a/ace/Object_Manager_Base.h b/ace/Object_Manager_Base.h new file mode 100644 index 00000000000..c1eea9722a6 --- /dev/null +++ b/ace/Object_Manager_Base.h @@ -0,0 +1,363 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Object_Manager_Base.h + * + * $Id$ + * + * @author David L. Levine <levine@cs.wustl.edu> + * @author Matthias Kerkhoff + * @author and Per Andersson + */ +//============================================================================= + +#ifndef ACE_OBJECT_MANAGER_BASE_H +#define ACE_OBJECT_MANAGER_BASE_H +#include "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/types.h" +#include "ace/os_include/signal.h" +#include "ace/OS_Export.h" +#include "ace/Global_Macros.h" + +////////////////////////////////////////////////////////// +// This is used by Object Manager and classes scheduled for +// cleanup. So you have to see both to use it (i.e. all singletons) + +// Signature for registering a cleanup function that is used by the +// <ACE_Object_Manager> and the <ACE_Thread_Manager>. +# if defined (ACE_HAS_SIG_C_FUNC) +extern "C" { +# endif /* ACE_HAS_SIG_C_FUNC */ +typedef void (*ACE_CLEANUP_FUNC)(void *object, void *param) /* throw () */; +# if defined (ACE_HAS_SIG_C_FUNC) +} +# endif /* ACE_HAS_SIG_C_FUNC */ + +/** + * @class ACE_Cleanup + * + * @brief Base class for objects that are cleaned by ACE_Object_Manager. + */ +class ACE_OS_Export ACE_Cleanup +{ +public: + /// No-op constructor. + ACE_Cleanup (void); + + /// Destructor. + virtual ~ACE_Cleanup (void); + + /// Cleanup method that, by default, simply deletes itself. + virtual void cleanup (void *param = 0); +}; + +// Adapter for cleanup, used by ACE_Object_Manager. +extern "C" ACE_OS_Export +void ace_cleanup_destroyer (ACE_Cleanup *, void *param = 0); + +/** + * @class ACE_Cleanup_Info + * + * @brief Hold cleanup information for thread/process + */ +class ACE_OS_Export ACE_Cleanup_Info +{ +public: + /// Default constructor. + ACE_Cleanup_Info (void); + + /// Equality operator. + int operator== (const ACE_Cleanup_Info &o) const; + + /// Inequality operator. + int operator!= (const ACE_Cleanup_Info &o) const; + + /// Point to object that gets passed into the <cleanup_hook_>. + void *object_; + + /// Cleanup hook that gets called back. + ACE_CLEANUP_FUNC cleanup_hook_; + + /// Parameter passed to the <cleanup_hook_>. + void *param_; +}; + +class ACE_Cleanup_Info_Node; + +/** + * @class ACE_OS_Exit_Info + * + * @brief Hold Object Manager cleanup (exit) information. + * + * For internal use by the ACE library, only. + */ +class ACE_OS_Export ACE_OS_Exit_Info +{ +public: + /// Default constructor. + ACE_OS_Exit_Info (void); + + /// Destructor. + ~ACE_OS_Exit_Info (void); + + /// Use to register a cleanup hook. + int at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param); + + /// Look for a registered cleanup hook object. Returns 1 if already + /// registered, 0 if not. + int find (void *object); + + /// Call all registered cleanup hooks, in reverse order of + /// registration. + void call_hooks (); + +private: + /** + * Keeps track of all registered objects. The last node is only + * used to terminate the list (it doesn't contain a valid + * ACE_Cleanup_Info). + */ + ACE_Cleanup_Info_Node *registered_objects_; +}; +////////////////////////////////////////////////////////////////// + + + + + +/** + * @class ACE_Object_Manager_Base + * + * @brief Base class for ACE_Object_Manager(s). + * + * Encapsulates the most useful ACE_Object_Manager data structures. + */ +class ACE_OS_Export ACE_Object_Manager_Base +{ +# if (defined (ACE_PSOS) && defined (__DIAB)) || \ + (defined (__DECCXX_VER) && __DECCXX_VER < 60000000) + // The Diab compiler got confused and complained about access rights + // if this section was protected (changing this to public makes it happy). + // Similarly, DEC CXX 5.6 needs the methods to be public. +public: +# else /* ! (ACE_PSOS && __DIAB) || ! __DECCXX_VER < 60000000 */ +protected: +# endif /* ! (ACE_PSOS && __DIAB) || ! __DECCXX_VER < 60000000 */ + /// Default constructor. + ACE_Object_Manager_Base (void); + + /// Destructor. + virtual ~ACE_Object_Manager_Base (void); + +public: + /** + * Explicitly initialize. Returns 0 on success, -1 on failure due + * to dynamic allocation failure (in which case errno is set to + * ENOMEM), or 1 if it had already been called. + */ + virtual int init (void) = 0; + + /** + * Explicitly destroy. Returns 0 on success, -1 on failure because + * the number of fini () calls hasn't reached the number of init () + * calls, or 1 if it had already been called. + */ + virtual int fini (void) = 0; + + enum Object_Manager_State + { + OBJ_MAN_UNINITIALIZED = 0, + OBJ_MAN_INITIALIZING, + OBJ_MAN_INITIALIZED, + OBJ_MAN_SHUTTING_DOWN, + OBJ_MAN_SHUT_DOWN + }; + +protected: + /** + * Returns 1 before ACE_Object_Manager_Base has been constructed. + * This flag can be used to determine if the program is constructing + * static objects. If no static object spawns any threads, the + * program will be single-threaded when this flag returns 1. (Note + * that the program still might construct some static objects when + * this flag returns 0, if ACE_HAS_NONSTATIC_OBJECT_MANAGER is not + * defined.) + */ + int starting_up_i (void); + + /** + * Returns 1 after ACE_Object_Manager_Base has been destroyed. This + * flag can be used to determine if the program is in the midst of + * destroying static objects. (Note that the program might destroy + * some static objects before this flag can return 1, if + * ACE_HAS_NONSTATIC_OBJECT_MANAGER is not defined.) + */ + int shutting_down_i (void); + + /// State of the Object_Manager; + Object_Manager_State object_manager_state_; + + /** + * Flag indicating whether the ACE_Object_Manager was dynamically + * allocated by ACE. (If is was dynamically allocated by the + * application, then the application is responsible for destroying + * it.) + */ + u_int dynamically_allocated_; + + /// Link to next Object_Manager, for chaining. + ACE_Object_Manager_Base *next_; +private: + // Disallow copying by not implementing the following . . . + ACE_Object_Manager_Base (const ACE_Object_Manager_Base &); + ACE_Object_Manager_Base &operator= (const ACE_Object_Manager_Base &); +}; + + +// @@ This forward declaration should go away. +class ACE_Log_Msg; +class ACE_OS; +class ACE_Object_Manager; +class ACE_OS_Object_Manager_Manager; +class ACE_TSS_Cleanup; +class ACE_TSS_Emulation; +class ACE_Log_Msg; +class ACE_Thread_Hook; +//void ACE_OS_Object_Manager_Internal_Exit_Hook (); + +extern "C" +void +ACE_OS_Object_Manager_Internal_Exit_Hook (void); + + + +class ACE_OS_Export ACE_OS_Object_Manager : public ACE_Object_Manager_Base +{ +public: + /// Explicitly initialize. + virtual int init (void); + + /// Explicitly destroy. + virtual int fini (void); + + /** + * Returns 1 before the <ACE_OS_Object_Manager> has been + * constructed. See <ACE_Object_Manager::starting_up> for more + * information. + */ + static int starting_up (void); + + /// Returns 1 after the <ACE_OS_Object_Manager> has been destroyed. + /// See <ACE_Object_Manager::shutting_down> for more information. + static int shutting_down (void); + + /// Unique identifiers for preallocated objects. + enum Preallocated_Object + { +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + ACE_OS_MONITOR_LOCK, + ACE_TSS_CLEANUP_LOCK, + ACE_LOG_MSG_INSTANCE_LOCK, +# if defined (ACE_HAS_TSS_EMULATION) + ACE_TSS_KEY_LOCK, +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + ACE_TSS_BASE_LOCK, +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ +# endif /* ACE_HAS_TSS_EMULATION */ +# else + // Without ACE_MT_SAFE, There are no preallocated objects. Make + // sure that the preallocated_array size is at least one by + // declaring this dummy . . . + ACE_OS_EMPTY_PREALLOCATED_OBJECT, +# endif /* ACE_MT_SAFE */ + + /// This enum value must be last! + ACE_OS_PREALLOCATED_OBJECTS + }; + + /// Accesses a default signal set used, for example, in + /// <ACE_Sig_Guard> methods. + static sigset_t *default_mask (void); + + /// Returns the current thread hook for the process. + static ACE_Thread_Hook *thread_hook (void); + + /// Returns the existing thread hook and assign a <new_thread_hook>. + static ACE_Thread_Hook *thread_hook (ACE_Thread_Hook *new_thread_hook); + +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + /// Get/Set TSS exception action. + static ACE_SEH_EXCEPT_HANDLER seh_except_selector (void); + static ACE_SEH_EXCEPT_HANDLER seh_except_selector (ACE_SEH_EXCEPT_HANDLER); + + static ACE_SEH_EXCEPT_HANDLER seh_except_handler (void); + static ACE_SEH_EXCEPT_HANDLER seh_except_handler (ACE_SEH_EXCEPT_HANDLER); +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + +public: + // = Applications shouldn't use these so they're hidden here. + + // They're public so that the <ACE_Object_Manager> can be + // constructed/destructed in <main> with + // <ACE_HAS_NONSTATIC_OBJECT_MANAGER>. + /// Constructor. + ACE_OS_Object_Manager (void); + + /// Destructor. + ~ACE_OS_Object_Manager (void); + +private: + /// Accessor to singleton instance. + static ACE_OS_Object_Manager *instance (void); + + /// Singleton instance pointer. + static ACE_OS_Object_Manager *instance_; + + /// Table of preallocated objects. + static void *preallocated_object[ACE_OS_PREALLOCATED_OBJECTS]; + + /// Default signal set used, for example, in ACE_Sig_Guard. + sigset_t *default_mask_; + + /// Thread hook that's used by this process. + ACE_Thread_Hook *thread_hook_; + + /// For at_exit support. + ACE_OS_Exit_Info exit_info_; + +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + /// These handlers determine how a thread handles win32 structured + /// exception. + ACE_SEH_EXCEPT_HANDLER seh_except_selector_; + ACE_SEH_EXCEPT_HANDLER seh_except_handler_; +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + + /// For <ACE_OS::atexit> support. + int at_exit (ACE_EXIT_HOOK func); + + /// For use by init () and fini (), to consolidate error reporting. + static void print_error_message (u_int line_number, const ACE_TCHAR *message); + + /// This class is for internal use by ACE_OS, etc., only. + friend class ACE_OS; + friend class ACE_Object_Manager; + friend class ACE_OS_Object_Manager_Manager; + friend class ACE_TSS_Cleanup; + friend class ACE_TSS_Emulation; + friend class ACE_Log_Msg; + friend void ACE_OS_Object_Manager_Internal_Exit_Hook (); +}; +//////////////////////////////////////////////////////////////////////////////// + + + +#include "ace/post.h" +#endif /* ACE_OBJECT_MANAGER_BASE_H */ diff --git a/ace/os_include/aio.h b/ace/os_include/aio.h new file mode 100644 index 00000000000..f2902ba3c67 --- /dev/null +++ b/ace/os_include/aio.h @@ -0,0 +1,32 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file aio.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_AIO_H +# define ACE_OS_INCLUDE_AIO_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_AIO_H) +# include /**/ <aio.h> +# endif /* ACE_LACKS_AIO_H */ + +# if !defined (_SC_AIO_MAX) +# define _SC_AIO_MAX 1 +# endif /* _SC_AIO_MAX */ + +# endif /* ACE_OS_INCLUDE_AIO_H */ diff --git a/ace/os_include/assert.h b/ace/os_include/assert.h new file mode 100644 index 00000000000..1e071a0267c --- /dev/null +++ b/ace/os_include/assert.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file assert.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_ASSERT_H +# define ACE_OS_INCLUDE_ASSERT_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_ASSERT_H) +# include /**/ <assert.h> +# endif /* !ACE_LACKS_ASSERT_H */ + +#endif /* ACE_OS_INCLUDE_ASSERT_H */ diff --git a/ace/os_include/ctype.h b/ace/os_include/ctype.h new file mode 100644 index 00000000000..e9ca875ac2a --- /dev/null +++ b/ace/os_include/ctype.h @@ -0,0 +1,28 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file ctype.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_CTYPE_H +# define ACE_OS_INCLUDE_CTYPE_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_CTYPE_H) +# include /**/ <ctype.h> +# endif /* !ACE_LACKS_CTYPE_H */ + +#endif /* ACE_OS_INCLUDE_CTYPE_H */ diff --git a/ace/os_include/dirent.h b/ace/os_include/dirent.h new file mode 100644 index 00000000000..ade5e2fe778 --- /dev/null +++ b/ace/os_include/dirent.h @@ -0,0 +1,38 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file dirent.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_DIRENT_H +# define ACE_OS_INCLUDE_DIRENT_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/types.h" +#include "ace/os_include/unistd.h" + +# if !defined (ACE_LACKS_DIRENT_H) +# include /**/ <dirent.h> +# endif /* ACE_LACKS_DIRENT_H */ + +# if !defined (MAXNAMLEN) +# if !defined (ACE_MAXNAMLEN) +# define ACE_MAXNAMLEN 255 +# endif /* !ACE_MAXNAMELEN */ +# define MAXNAMLEN ACE_MAXNAMLEN +# endif /* !MAXNAMLEN */ + +#endif /* ACE_OS_INCLUDE_DIRENT_H */ diff --git a/ace/os_include/dlfcn.h b/ace/os_include/dlfcn.h new file mode 100644 index 00000000000..a23135905ce --- /dev/null +++ b/ace/os_include/dlfcn.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file dlfcn.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_DLFCN_H +# define ACE_OS_INCLUDE_DLFCN_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +/* Set the proper handle type for dynamically-loaded libraries. */ +/* Also define a default 'mode' for loading a library - the names and values */ +/* differ between OSes, so if you write code that uses the mode, be careful */ +/* of the platform differences. */ +# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) + +# if defined (ACE_HAS_DLFCN_H_BROKEN_EXTERN_C) +extern "C" { +# endif /* ACE_HAS_DLFCN_H_BROKEN_EXTERN_C */ +# include /**/ <dlfcn.h> +# if defined (ACE_HAS_DLFCN_H_BROKEN_EXTERN_C) +} +# endif /* ACE_HAS_DLFCN_H_BROKEN_EXTERN_C */ + typedef void *ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# if defined (__KCC) && defined(RTLD_GROUP) && defined(RTLD_NODELETE) +# define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY | RTLD_GROUP | RTLD_NODELETE +# else +# define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY +# endif /* KCC */ + +# elif defined (__hpux) +# if defined(__GNUC__) || __cplusplus >= 199707L +# include /**/ <dl.h> +# else +# include /**/ <cxxdl.h> +# endif /* (g++ || HP aC++) vs. HP C++ */ + typedef shl_t ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# define ACE_DEFAULT_SHLIB_MODE BIND_DEFERRED + +# elif defined (ACE_WIN32) + // Dynamic loading-related types - used for dlopen and family. + typedef HINSTANCE ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# define ACE_DEFAULT_SHLIB_MODE 0 + +# else + typedef void *ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY + +# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ + + +# if !defined (RTLD_LAZY) +# define RTLD_LAZY 1 +# endif /* !RTLD_LAZY */ + +# if !defined (RTLD_NOW) +# define RTLD_NOW 2 +# endif /* !RTLD_NOW */ + +# if !defined (RTLD_GLOBAL) +# define RTLD_GLOBAL 3 +# endif /* !RTLD_GLOBAL */ + +#endif /* ACE_OS_INCLUDE_DLFCN_H */ diff --git a/ace/os_include/errno.h b/ace/os_include/errno.h new file mode 100644 index 00000000000..7316b9b8497 --- /dev/null +++ b/ace/os_include/errno.h @@ -0,0 +1,93 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file errno.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_ERRNO_H +# define ACE_OS_INCLUDE_ERRNO_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_ERRNO_H) +# include /**/ <errno.h> +# endif /* ACE_HAS_WINCE */ + +// This only seems to be defined in config-aix-4.x.h, and is never used. +# if defined (ACE_HAS_H_ERRNO) +void herror (const char *str); +# endif /* ACE_HAS_H_ERRNO */ + +# if defined (ACE_LACKS_T_ERRNO) +extern int t_errno; +# endif /* ACE_LACKS_T_ERRNO */ + +# if ! (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) \ + && !defined(__MINGW32__) +# if defined (__FreeBSD__) || defined(__QNX__) +extern const int sys_nerr; +# elif defined (__CYGWIN32__) || defined (ACE_WIN32) +# define sys_nerr _sys_nerr +# else +extern int sys_nerr; +# endif /* !__FreeBSD__ && !__QNX__ */ +# endif /* ! (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) */ + +# if !defined (ENOSYS) +# define ENOSYS EFAULT /* Operation not supported or unknown error. */ +# endif /* !ENOSYS */ + +# if !defined (ENOTSUP) +# define ENOTSUP ENOSYS /* Operation not supported. */ +# endif /* !ENOTSUP */ + +# if !defined (ESUCCESS) +# define ESUCCESS 0 +# endif /* !ESUCCESS */ + +# if !defined (EIDRM) +# define EIDRM 0 +# endif /* !EIDRM */ + +# if !defined (ENFILE) +# define ENFILE EMFILE /* No more socket descriptors are available. */ +# endif /* !ENOSYS */ + +# if !defined (ECOMM) + // Not the same, but ECONNABORTED is provided on NT. +# define ECOMM ECONNABORTED +# endif /* ECOMM */ + +# if !defined (WNOHANG) +# define WNOHANG 0100 +# endif /* !WNOHANG */ + +# if !defined (EDEADLK) +# define EDEADLK 1000 /* Some large number.... */ +# endif /* !EDEADLK */ + +# if !defined (ETIMEDOUT) && defined (ETIME) +# define ETIMEDOUT ETIME +# endif /* ETIMEDOUT */ + +# if !defined (ETIME) && defined (ETIMEDOUT) +# define ETIME ETIMEDOUT +# endif /* ETIMED */ + +# if !defined (EBUSY) +# define EBUSY ETIME +# endif /* EBUSY */ + +#endif /* ACE_OS_INCLUDE_ERRNO_H */ diff --git a/ace/os_include/fcntl.h b/ace/os_include/fcntl.h new file mode 100644 index 00000000000..1a3a5d0d9d9 --- /dev/null +++ b/ace/os_include/fcntl.h @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file fctnl.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_FCNTL_H +# define ACE_OS_INCLUDE_FCNTL_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/os_include/sys/types.h" + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_FCNTL_H) +# include /**/ <fcntl.h> +# endif /* !ACE_LACKS_FCNTL_H */ + +// Include additional/alternate headers for certain platfor/compiler combinations. +# if defined (ACE_NEEDS_SYS_FCNTL_H) +# include /**/ <sys/fcntl.h> +# endif /* ACE_NEEDS_SYS_FCNTL_H) */ + +// defined Win32 specific macros for UNIX platforms +# if !defined (O_BINARY) +# define O_BINARY 0 +# endif /* O_BINARY */ +# if !defined (_O_BINARY) +# define _O_BINARY O_BINARY +# endif /* _O_BINARY */ +# if !defined (O_TEXT) +# define O_TEXT 0 +# endif /* O_TEXT */ +# if !defined (_O_TEXT) +# define _O_TEXT O_TEXT +# endif /* _O_TEXT */ +# if !defined (O_RAW) +# define O_RAW 0 +# endif /* O_RAW */ +# if !defined (_O_RAW) +# define _O_RAW O_RAW +# endif /* _O_RAW */ + +# if !defined (O_NONBLOCK) +# define O_NONBLOCK 1 +# endif /* O_NONBLOCK */ + +# if defined (ACE_HAS_POSIX_NONBLOCK) +# define ACE_NONBLOCK O_NONBLOCK +# else +# define ACE_NONBLOCK O_NDELAY +# endif /* ACE_HAS_POSIX_NONBLOCK */ + +# if defined (ACE_LACKS_FILELOCKS) +# if ! defined (VXWORKS) && ! defined (ACE_PSOS) && ! defined (__rtems__) +// VxWorks defines struct flock in sys/fcntlcom.h. But it doesn't +// appear to support flock (). RTEMS defines struct flock but +// currently does not support locking. +struct flock +{ + short l_type; + short l_whence; + off_t l_start; + off_t l_len; /* len == 0 means until end of file */ + long l_sysid; + pid_t l_pid; + long l_pad[4]; /* reserve area */ +}; +# endif /* ! VXWORKS */ +# endif /* ACE_LACKS_FILELOCKS */ + + +struct ace_flock_t +{ +# if defined (ACE_WIN32) + ACE_OVERLAPPED overlapped_; +# else + struct flock lock_; +# endif /* ACE_WIN32 */ + + /// Name of this filelock. + const ACE_TCHAR *lockname_; + + /// Handle to the underlying file. + ACE_HANDLE handle_; + +# if defined (CHORUS) + /// This is the mutex that's stored in shared memory. It can only + /// be destroyed by the actor that initialized it. + ACE_mutex_t *process_lock_; +# endif /* CHORUS */ +}; + +#endif /* ACE_OS_INCLUDE_FCNTL_H */ diff --git a/ace/os_include/limits.h b/ace/os_include/limits.h new file mode 100644 index 00000000000..4f71ba0992a --- /dev/null +++ b/ace/os_include/limits.h @@ -0,0 +1,60 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file limits.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_LIMITS_H +# define ACE_OS_INCLUDE_LIMITS_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_LIMITS_H) +# include /**/ <limits.h> +# endif /* ACE_LACKS_LIMITS_H */ + +// If we still have a problem with this, it can be put in a new +// file, e.g., ace_xopen_lim.h, that can be included by both ace_stdio.h +// and ace_limits.h +// This is defined by XOPEN to be a minimum of 16. POSIX.1g +// also defines this value. platform-specific config.h can +// override this if need be. +# if !defined (IOV_MAX) +# define IOV_MAX 16 +# endif /* IOV_MAX */ + +# if !defined (ACE_IOV_MAX) +# define ACE_IOV_MAX IOV_MAX +# endif /* ACE_IOV_MAX */ + +// Need this before MAXNAMELEN--does it belong here? +#include "ace/os_include/sys/param.h" + +# if !defined (MAXNAMELEN) +# if !defined (ACE_MAXNAMELEN) +# if defined (FILENAME_MAX) +# define ACE_MAXNAMELEN FILENAME_MAX +# else +# define ACE_MAXNAMELEN 256 +# endif /* FILENAME_MAX */ +# endif /* ACE_MAXNAMELEN */ +# define MAXNAMELEN ACE_MAXNAMELEN +# endif /* MAXNAMELEN */ + +# if !defined (PIPE_BUF) +# define PIPE_BUF 5120 +# endif /* PIPE_BUF */ + +#endif /* ACE_OS_INCLUDELIMITS_H */ diff --git a/ace/os_include/netinet/in.h b/ace/os_include/netinet/in.h new file mode 100644 index 00000000000..fbb65e46377 --- /dev/null +++ b/ace/os_include/netinet/in.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file in.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_NETINET_IN_H +# define ACE_OS_INCLUDE_NETINET_IN_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_NETINET_IN_H) +# include /**/ <netinet/in.h> +# endif /* !ACE_LACKS_NETINET_IN_H */ + +# if !defined (IP_DROP_MEMBERSHIP) +# define IP_DROP_MEMBERSHIP 0 +# endif /* IP_DROP_MEMBERSHIP */ + +# if !defined (IP_ADD_MEMBERSHIP) +# define IP_ADD_MEMBERSHIP 0 +# define ACE_LACKS_IP_ADD_MEMBERSHIP +# endif /* IP_ADD_MEMBERSHIP */ + +# if !defined (IP_DEFAULT_MULTICAST_TTL) +# define IP_DEFAULT_MULTICAST_TTL 0 +# endif /* IP_DEFAULT_MULTICAST_TTL */ + +# if !defined (IP_DEFAULT_MULTICAST_LOOP) +# define IP_DEFAULT_MULTICAST_LOOP 0 +# endif /* IP_DEFAULT_MULTICAST_LOOP */ + +# if !defined (IP_MULTICAST_IF) +# define IP_MULTICAST_IF 0 +# endif /* IP_MULTICAST_IF */ + +# if !defined (IP_MULTICAST_TTL) +# define IP_MULTICAST_TTL 1 +# endif /* IP_MULTICAST_TTL */ + +# if !defined (IP_MAX_MEMBERSHIPS) +# define IP_MAX_MEMBERSHIPS 0 +# endif /* IP_MAX_MEMBERSHIP */ + +# if !defined (SIOCGIFBRDADDR) +# define SIOCGIFBRDADDR 0 +# endif /* SIOCGIFBRDADDR */ + +# if !defined (SIOCGIFADDR) +# define SIOCGIFADDR 0 +# endif /* SIOCGIFADDR */ + +#endif /* ACE_OS_INCLUDE_NETINET_IN_H */ diff --git a/ace/os_include/new.h b/ace/os_include/new.h new file mode 100644 index 00000000000..dd6349ff4e4 --- /dev/null +++ b/ace/os_include/new.h @@ -0,0 +1,32 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file new.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_NEW_H +# define ACE_OS_INCLUDE_NEW_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_NEW_H) +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# include /**/ <new> +# else +# include /**/ <new.h> +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ +# endif /* ! ACE_LACKS_NEW_H */ + +#endif /* ACE_OS_INCLUDE_NEW_H */ diff --git a/ace/os_include/poll.h b/ace/os_include/poll.h new file mode 100644 index 00000000000..a4485d28099 --- /dev/null +++ b/ace/os_include/poll.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file poll.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_POLL_H +# define ACE_OS_INCLUDE_POLL_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_POLL_H) +# include /**/ <poll.h> +# endif /* !ACE_LACKS_POLL_H */ + +#endif /* ACE_OS_INCLUDE_POLL_H */ diff --git a/ace/os_include/psos.h b/ace/os_include/psos.h new file mode 100644 index 00000000000..97c398436e7 --- /dev/null +++ b/ace/os_include/psos.h @@ -0,0 +1,567 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file psos.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_PSOS_H +# define ACE_OS_INCLUDE_PSOS_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// @todo: Integrate all this into the regular system include wrappers +// and get rid of this file.. + +# if defined (ACE_PSOS_SNARFS_HEADER_INFO) + // Header information snarfed from compiler provided header files + // that are not included because there is already an identically + // named file provided with pSOS, which does not have this info + // from compiler supplied stdio.h + extern FILE *fdopen(int, const char *); + extern int getopt(int, char *const *, const char *); + extern char *tempnam(const char *, const char *); + extern "C" int fileno(FILE *); + +// #define fileno(stream) ((stream)->_file) + + // from compiler supplied string.h + extern char *strdup (const char *); + + // from compiler supplied stat.h + extern mode_t umask (mode_t); + extern int mkfifo (const char *, mode_t); + extern int mkdir (const char *, mode_t); + + // from compiler supplied stdlib.h + extern int putenv (char *); + + int isatty (int h); + +# endif /* ACE_PSOS_SNARFS_HEADER_INFO */ + + +# if defined (ACE_PSOS) +// Some versions of pSOS do not define error numbers, but newer +// versions do. So, include errno.h and then see which ones are not +// yet defined. +# if !defined (EPERM) +# define EPERM 1 /* Not super-user */ +# endif /* EPERM */ +# if !defined (ENOENT) +# define ENOENT 2 /* No such file or directory */ +# endif /* ENOENT */ +# if !defined (ESRCH) +# define ESRCH 3 /* No such process */ +# endif /* ESRCH */ +# if ! defined (EINTR) +# define EINTR 4 /* interrupted system call */ +# endif /* EINTR */ +# if !defined (EBADF) +# define EBADF 9 /* Bad file number */ +# endif /* EBADF */ +# if !defined (EAGAIN) +# define EAGAIN 11 /* Resource temporarily unavailable */ +# endif /* EAGAIN */ +# if !defined (EWOULDBLOCK) +# define EWOULDBLOCK EAGAIN /* Blocking resource request would block */ +# endif /* EWOULDBLOCK */ +# if !defined (ENOMEM) +# define ENOMEM 12 /* Not enough core */ +# endif /* ENOMEM */ +# if !defined (EACCESS) +# define EACCESS 13 /* Permission denied */ +# endif /* EACCESS */ +# if !defined (EFAULT) +# define EFAULT 14 /* Bad access */ +# endif /* EFAULT */ +# if !defined (EEXIST) +# define EEXIST 17 /* File exists */ +# endif /* EEXIST */ +# if !defined (ENOSPC) +# define ENOSPC 28 /* No space left on device */ +# endif /* ENOSPC */ +# if !defined (EPIPE) +# define EPIPE 32 /* Broken pipe */ +# endif /* EPIPE */ +# if !defined (ETIME) +# define ETIME 62 /* timer expired */ +# endif /* ETIME */ +# if !defined (ENAMETOOLONG) +# define ENAMETOOLONG 78 /* path name is too long */ +# endif /* ENAMETOOLONG */ +# if !defined (ENOSYS) +# define ENOSYS 89 /* Unsupported file system operation */ +# endif /* ENOSYS */ +# if !defined (EADDRINUSE) +# define EADDRINUSE 125 /* Address already in use */ +# endif /* EADDRINUSE */ +# if !defined (ENETUNREACH) +# define ENETUNREACH 128 /* Network is unreachable */ +# endif /* ENETUNREACH */ +# if !defined (EISCONN) +# define EISCONN 133 /* Socket is already connected */ +# endif /* EISCONN */ +# if !defined (ESHUTDOWN) +# define ESHUTDOWN 143 /* Can't send after socket shutdown */ +# endif /* ESHUTDOWN */ +# if !defined (ECONNREFUSED) +# define ECONNREFUSED 146 /* Connection refused */ +# endif /* ECONNREFUSED */ +# if !defined (EINPROGRESS) +# define EINPROGRESS 150 /* operation now in progress */ +# endif /* EINPROGRESS */ +# if !defined (ERRMAX) +# define ERRMAX 151 /* Last error number */ +# endif /* ERRMAX */ +# endif /* ACE_PSOS */ + + + +# if defined (ACE_PSOS) + +// Wrapper for NT events on pSOS. +class ACE_OS_Export ACE_event_t +{ + friend class ACE_OS; + +protected: + + /// Protect critical section. + ACE_mutex_t lock_; + + /// Keeps track of waiters. + ACE_cond_t condition_; + + /// Specifies if this is an auto- or manual-reset event. + int manual_reset_; + + /// "True" if signaled. + int is_signaled_; + + /// Number of waiting threads. + u_long waiting_threads_; +}; + +# endif /* ACE_PSOS */ + + + +# if defined (ACE_PSOS) + +# if defined (ACE_PSOSIM) + +# include /**/ "ace/sys_conf.h" /* system configuration file */ +# include /**/ <psos.h> /* pSOS+ system calls */ +# include /**/ <pna.h> /* pNA+ TCP/IP Network Manager calls */ + + /* In the *simulator* environment, use unsigned int for size_t */ +# define size_t unsigned int + + + /* include <rpc.h> pRPC+ Remote Procedure Call Library calls */ + /* are not supported by pSOSim */ + /* */ + /* include <phile.h> 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 /**/ <sys/stat.h> +# include /**/ <sys/ioctl.h> +# include /**/ <sys/sockio.h> +# include /**/ <netinet/tcp.h> + +# define TCP_ +# if ! defined (BUFSIZ) +# define BUFSIZ 1024 +# endif /* ! defined (BUFSIZ) */ + + +# else + +# if defined (ACE_PSOS_CANT_USE_SYS_TYPES) + // these are missing from the pSOS types.h file, and the compiler + // supplied types.h file collides with the pSOS version. +# if !defined (ACE_SHOULD_NOT_DEFINE_SYS_TYPES) + typedef unsigned char u_char; + typedef unsigned short u_short; +# endif /* ACE_SHOULD_NOT_DEFINE_SYS_TYPES */ + typedef unsigned int u_int; +# if !defined (ACE_SHOULD_NOT_DEFINE_SYS_TYPES) + typedef unsigned long u_long; +# endif /* ACE_SHOULD_NOT_DEFINE_SYS_TYPES */ + + // These are defined in types.h included by (among others) pna.h +# if 0 + typedef unsigned char uchar_t; + typedef unsigned short ushort_t; + typedef unsigned int uint_t; + typedef unsigned long ulong_t; +# endif /* 0 */ + typedef char * caddr_t; + +# if defined (ACE_PSOS_DIAB_PPC) + // pid_t is defined in sys/types.h +# if 0 + typedef unsigned long pid_t; +# endif /* 0 */ +# define ACE_INVALID_PID ((pid_t) ~0) +# else /* !defined (ACE_PSOS_DIAB_PPC) */ + typedef long pid_t; +# define ACE_INVALID_PID ((pid_t) -1) +# endif /* defined (ACE_PSOS_DIAB_PPC) */ + +// typedef unsigned char wchar_t; +# endif /* ACE_PSOS_CANT_USE_SYS_TYPES */ + +# include /**/ "ace/sys_conf.h" /* system configuration file */ +# include /**/ <configs.h> /* includes all pSOS headers */ +// #include /**/ <psos.h> /* pSOS system calls */ +# include /**/ <pna.h> /* pNA+ TCP/IP Network Manager calls */ +# include /**/ <phile.h> /* pHILE+ file system calls */ +// #include /**/ <prepccfg.h> /* pREPC+ file system calls */ +# if defined (ACE_PSOS_DIAB_MIPS) +# if defined (ACE_PSOS_USES_DIAB_SYS_CALLS) +# include /**/ <unistd.h> /* Diab Data supplied file system calls */ +# else +# include /**/ <prepc.h> +# endif /* ACE_PSOS_USES_DIAB_SYS_CALLS */ +# include /**/ <sys/wait.h> /* Diab Data supplied header file */ +# endif /* ACE_PSOS_DIAB_MIPS */ + +// This collides with phile.h +// #include /**/ <sys/stat.h> /* Diab Data supplied header file */ + +// Some versions have missing preprocessor definitions +# if !defined (AF_UNIX) +# define AF_UNIX 0x1 +# endif /* AF_UNIX */ +# define PF_UNIX AF_UNIX +# define PF_INET AF_INET +# if !defined (AF_MAX) +# define AF_MAX AF_INET +# endif /* AF_MAX */ +# if !defined (IFF_LOOPBACK) +# define IFF_LOOPBACK IFF_EXTLOOPBACK +# endif /* IFF_LOOPBACK */ + + typedef long fd_mask; +# define IPPORT_RESERVED 1024 +# define IPPORT_USERRESERVED 5000 + + extern "C" + { + typedef void (* ACE_SignalHandler) (void); + typedef void (* ACE_SignalHandlerV) (void); + } + +# if !defined(SIG_DFL) +# define SIG_DFL (ACE_SignalHandler) 0 +# endif /* philabs */ + +# endif /* defined (ACE_PSOSIM) */ + + +# if ! defined (NSIG) +# define NSIG 32 +# endif /* NSIG */ + +# if ! defined (TCP_NODELAY) +# define TCP_NODELAY 1 +# endif /* TCP_NODELAY */ + +// For general purpose portability + +# define ACE_BITS_PER_ULONG (8 * sizeof (u_long)) + +typedef u_long ACE_idtype_t; +typedef u_long ACE_id_t; +# define ACE_SELF (0) +typedef u_long ACE_pri_t; + +// pHILE+ calls the DIR struct XDIR instead +# if !defined (ACE_PSOS_DIAB_PPC) +typedef XDIR ACE_DIR; +# endif /* !defined (ACE_PSOS_DIAB_PPC) */ + +// 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 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 1234 +# 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_PLATFORM_A "pSOS" +# define ACE_PLATFORM_EXE_SUFFIX_A "" + +# define ACE_DLL_SUFFIX ACE_LIB_TEXT (".so") +# define ACE_DLL_PREFIX ACE_LIB_TEXT ("lib") +# define ACE_LD_SEARCH_PATH ACE_LIB_TEXT ("LD_LIBRARY_PATH") +# define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_LIB_TEXT (":") +# define ACE_LOGGER_KEY ACE_LIB_TEXT ("/tmp/server_daemon") + +# define ACE_MAX_DEFAULT_PORT 65535 + +# if ! defined(MAXPATHLEN) +# define MAXPATHLEN 1024 +# endif /* MAXPATHLEN */ + +# if ! defined(MAXNAMLEN) +# define MAXNAMLEN 255 +# endif /* MAXNAMLEN */ + +# 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 */ + + +typedef int ACE_exitcode; + +typedef ACE_HANDLE ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE ACE_INVALID_HANDLE +# define 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 */ +}; + +# 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; +}; + +# if !defined (USER_INCLUDE_SYS_TIME_TM) +# if defined (ACE_PSOS_DIAB_PPC) +typedef struct timespec timespec_t; +# else /* ! defined (ACE_PSOS_DIAB_PPC) */ +typedef struct timespec +{ + time_t tv_sec; // Seconds + long tv_nsec; // Nanoseconds +} timespec_t; +# endif /* defined (ACE_PSOS_DIAB_PPC) */ +# endif /* !defined (USER_INCLUDE_SYS_TIME_TM) */ + +# if defined (ACE_PSOS_HAS_TIME) + +// Use pSOS time, wrapped . . . +class ACE_OS_Export ACE_PSOS_Time_t +{ +public: + /// default ctor: date, time, and ticks all zeroed. + ACE_PSOS_Time_t (void); + + /// ctor from a timespec_t + ACE_PSOS_Time_t (const timespec_t& t); + + /// type cast operator (to a timespec_t) + operator timespec_t (); + + /// static member function to get current system time + static u_long get_system_time (ACE_PSOS_Time_t& t); + + /// static member function to set current system time + static u_long set_system_time (const ACE_PSOS_Time_t& t); + +# if defined (ACE_PSOSIM) + /// static member function to initialize system time, using UNIX calls + static u_long init_simulator_time (void); +# endif /* ACE_PSOSIM */ + + /// max number of ticks supported in a single system call + static const u_long max_ticks; +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 + + /// date : year in bits 31-16, month in bits 15-8, day in bits 7-0 + u_long date_; + + /// time : hour in bits 31-16, minutes in bits 15-8, seconds in bits 7-0 + u_long time_; + + /// ticks: number of system clock ticks (KC_TICKS2SEC-1 max) + u_long ticks_; +} ; +# endif /* ACE_PSOS_HAS_TIME */ + +# endif /* defined (ACE_PSOS) */ + +# if defined (ACE_HAS_THREADS) + +// Some versions of pSOS provide native mutex support. For others, +// implement ACE_thread_mutex_t and ACE_mutex_t using pSOS semaphores. +// Either way, the types are all u_longs. +typedef u_long ACE_mutex_t; +typedef u_long ACE_thread_mutex_t; +typedef u_long ACE_thread_t; +typedef u_long ACE_hthread_t; + +# if defined (ACE_PSOS_HAS_COND_T) +typedef u_long ACE_cond_t; +typedef u_long ACE_condattr_t; +struct ACE_OS_Export ACE_mutexattr_t +{ + int type; +}; +# endif /* ACE_PSOS_HAS_COND_T */ + + +// TCB registers 0-7 are for application use +# define PSOS_TASK_REG_TSS 0 +# define PSOS_TASK_REG_MAX 7 + +# define PSOS_TASK_MIN_PRIORITY 1 +# define PSOS_TASK_MAX_PRIORITY 239 + +// Key type: the ACE TSS emulation requires the key type be unsigned, +// for efficiency. Current POSIX and Solaris TSS implementations also +// use unsigned int, so the ACE TSS emulation is compatible with them. +// Native pSOS TSD, where available, uses unsigned long as the key type. +# if defined (ACE_PSOS_HAS_TSS) +typedef u_long ACE_thread_key_t; +# else +typedef u_int ACE_thread_key_t; +# endif /* ACE_PSOS_HAS_TSS */ + +# define THR_CANCEL_DISABLE 0 /* thread can never be cancelled */ +# define THR_CANCEL_ENABLE 0 /* thread can be cancelled */ +# define THR_CANCEL_DEFERRED 0 /* cancellation deferred to cancellation point */ +# define THR_CANCEL_ASYNCHRONOUS 0 /* cancellation occurs immediately */ + +# define THR_BOUND 0 +# define THR_NEW_LWP 0 +# define THR_DETACHED 0 +# define THR_SUSPENDED 0 +# define THR_DAEMON 0 +# define THR_JOINABLE 0 + +# define THR_SCHED_FIFO 0 +# define THR_SCHED_RR 0 +# define THR_SCHED_DEFAULT 0 +# define USYNC_THREAD T_LOCAL +# define USYNC_PROCESS T_GLOBAL + +/* from psos.h */ +/* #define T_NOPREEMPT 0x00000001 Not preemptible bit */ +/* #define T_PREEMPT 0x00000000 Preemptible */ +/* #define T_TSLICE 0x00000002 Time-slicing enabled bit */ +/* #define T_NOTSLICE 0x00000000 No Time-slicing */ +/* #define T_NOASR 0x00000004 ASRs disabled bit */ +/* #define T_ASR 0x00000000 ASRs enabled */ + +/* #define SM_GLOBAL 0x00000001 1 = Global */ +/* #define SM_LOCAL 0x00000000 0 = Local */ +/* #define SM_PRIOR 0x00000002 Queue by priority */ +/* #define SM_FIFO 0x00000000 Queue by FIFO order */ + +/* #define T_NOFPU 0x00000000 Not using FPU */ +/* #define T_FPU 0x00000002 Using FPU bit */ +# endif /* ACE_HAS_THREADS */ + + +#endif /* ACE_OS_INCLUDE_PSOS_H */ diff --git a/ace/os_include/pwd.h b/ace/os_include/pwd.h new file mode 100644 index 00000000000..73c9fe55755 --- /dev/null +++ b/ace/os_include/pwd.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file pwd.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_PWD_H +# define ACE_OS_INCLUDE_PWD_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_PWD_H) +# include /**/ <pwd.h> +# endif /* !ACE_LACKS_PWD_H */ + +#endif /* ACE_OS_INCLUDE_PWD_H */ diff --git a/ace/os_include/sched.h b/ace/os_include/sched.h new file mode 100644 index 00000000000..f337c56cb15 --- /dev/null +++ b/ace/os_include/sched.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file sched.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SCHED_H +# define ACE_OS_INCLUDE_SCHED_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_SCHED_H) +# include /**/ <sched.h> +# endif /* !ACE_LACKS_SCHED_H */ + +#endif /* ACE_OS_INCLUDE_SCHED_H */ diff --git a/ace/os_include/semaphore.h b/ace/os_include/semaphore.h new file mode 100644 index 00000000000..e7c99bfed56 --- /dev/null +++ b/ace/os_include/semaphore.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file semaphore.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SEMAPHORE_H +# define ACE_OS_INCLUDE_SEMAPHORE_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// is this used? + + +#endif /* ACE_OS_INCLUDE_SEMAPHORE_H */ + + diff --git a/ace/os_include/signal.h b/ace/os_include/signal.h new file mode 100644 index 00000000000..09252e66538 --- /dev/null +++ b/ace/os_include/signal.h @@ -0,0 +1,299 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file signal.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SIGNAL_H +# define ACE_OS_INCLUDE_SIGNAL_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/os_include/sys/types.h" + +# if !defined (ACE_LACKS_SIGNAL_H) +# include /**/ <signal.h> +# endif /* !ACE_LACKS_SIGNAL_H */ + +// Defining POSIX4 real-time signal range. +# if defined ACE_HAS_AIO_CALLS +# define ACE_SIGRTMIN SIGRTMIN +# define ACE_SIGRTMAX SIGRTMAX +# else /* !ACE_HAS_AIO_CALLS */ +# define ACE_SIGRTMIN 0 +# define ACE_SIGRTMAX 0 +# endif /* ACE_HAS_AIO_CALLS */ + +# if defined (ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES) +// Prototypes for both signal() and struct sigaction are consistent.. +# if defined (ACE_HAS_SIG_C_FUNC) +extern "C" { +# endif /* ACE_HAS_SIG_C_FUNC */ +# if !defined (ACE_PSOS) +typedef void (*ACE_SignalHandler)(int); +typedef void (*ACE_SignalHandlerV)(int); +# endif /* !defined (ACE_PSOS) */ +# if defined (ACE_HAS_SIG_C_FUNC) +} +# endif /* ACE_HAS_SIG_C_FUNC */ +# elif defined (ACE_HAS_LYNXOS_SIGNALS) +typedef void (*ACE_SignalHandler)(...); +typedef void (*ACE_SignalHandlerV)(...); +# elif defined (ACE_HAS_TANDEM_SIGNALS) +typedef void (*ACE_SignalHandler)(...); +typedef void (*ACE_SignalHandlerV)(...); +# elif defined (ACE_HAS_IRIX_53_SIGNALS) +typedef void (*ACE_SignalHandler)(...); +typedef void (*ACE_SignalHandlerV)(...); +# elif defined (ACE_HAS_SPARCWORKS_401_SIGNALS) +typedef void (*ACE_SignalHandler)(int, ...); +typedef void (*ACE_SignalHandlerV)(int,...); +# elif defined (ACE_HAS_SUNOS4_SIGNAL_T) +typedef void (*ACE_SignalHandler)(...); +typedef void (*ACE_SignalHandlerV)(...); +# elif defined (ACE_HAS_SVR4_SIGNAL_T) +// SVR4 Signals are inconsistent (e.g., see struct sigaction).. +typedef void (*ACE_SignalHandler)(int); +# if !defined (m88k) /* with SVR4_SIGNAL_T */ +typedef void (*ACE_SignalHandlerV)(void); +# else +typedef void (*ACE_SignalHandlerV)(int); +# endif /* m88k */ /* with SVR4_SIGNAL_T */ +# elif defined (ACE_WIN32) +typedef void (__cdecl *ACE_SignalHandler)(int); +typedef void (__cdecl *ACE_SignalHandlerV)(int); +# elif defined (ACE_HAS_UNIXWARE_SVR4_SIGNAL_T) +typedef void (*ACE_SignalHandler)(int); +typedef void (*ACE_SignalHandlerV)(...); +# else /* This is necessary for some older broken version of cfront */ +# if defined (SIG_PF) +# define ACE_SignalHandler SIG_PF +# else +typedef void (*ACE_SignalHandler)(int); +# endif /* SIG_PF */ +typedef void (*ACE_SignalHandlerV)(...); +# endif /* ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES */ + +// This must come after signal.h is #included. +# if defined (SCO) +# define SIGIO SIGPOLL +# include /**/ <sys/regset.h> +# endif /* SCO */ + +# if defined (ACE_HAS_SIGINFO_T) +# if !defined (ACE_LACKS_SIGINFO_H) +# if defined (__QNX__) +# include /**/ <sys/siginfo.h> +# else /* ! __QNX__ */ +# include /**/ <siginfo.h> +# endif /* ! __QNX__ */ +# endif /* ACE_LACKS_SIGINFO_H */ +# if !defined (ACE_LACKS_UCONTEXT_H) +# include /**/ <ucontext.h> +# endif /* ACE_LACKS_UCONTEXT_H */ +# else +# include "ace/OS_Export.h" +struct ACE_OS_Export siginfo_t +{ + siginfo_t (ACE_HANDLE handle); + siginfo_t (ACE_HANDLE *handles); // JCEJ 12/23/96 + + ACE_HANDLE si_handle_; + // Win32 HANDLE that has become signaled. + + ACE_HANDLE *si_handles_; + // Array of Win32 HANDLEs all of which have become signaled. +}; +# endif /* ACE_HAS_SIGINFO_T */ + +// Typedef for the null handler func. +extern "C" +{ + typedef void (*ACE_SIGNAL_C_FUNC)(int,siginfo_t*,void*); +} + +# if !defined (ACE_HAS_UCONTEXT_T) +typedef int ucontext_t; +# endif /* ACE_HAS_UCONTEXT_T */ + +# if !defined (SA_SIGINFO) +# define SA_SIGINFO 0 +# endif /* SA_SIGINFO */ + +# if !defined (SA_RESTART) +# define SA_RESTART 0 +# endif /* SA_RESTART */ + +# if defined (ACE_HAS_TIMOD_H) +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# define queue _Queue_ +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +# include /**/ <sys/timod.h> +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# undef queue +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +# elif defined (ACE_HAS_OSF_TIMOD_H) +# include /**/ <tli/timod.h> +# endif /* ACE_HAS_TIMOD_H */ + +# if defined (ACE_LACKS_SIGSET_T) +typedef u_int sigset_t; +# endif /* ACE_LACKS_SIGSET_T */ + +# if defined (ACE_HAS_SIG_C_FUNC) +extern "C" { +# endif /* ACE_HAS_SIG_C_FUNC */ +// Type of the extended signal handler. +typedef void (*ACE_Sig_Handler_Ex) (int, siginfo_t *siginfo, ucontext_t *ucontext); +# if defined (ACE_HAS_SIG_C_FUNC) +} +# endif /* ACE_HAS_SIG_C_FUNC */ + +# if defined (DIGITAL_UNIX) + // sigwait is yet another macro on Digital UNIX 4.0, just causing + // trouble when introducing member functions with the same name. + // Thanks to Thilo Kielmann" <kielmann@informatik.uni-siegen.de> for + // this fix. +# if defined (__DECCXX_VER) +# undef sigwait + // cxx on Digital Unix 4.0 needs this declaration. With it, + // <::_Psigwait> works with cxx -pthread. g++ does _not_ need + // it. + extern "C" int _Psigwait __((const sigset_t *set, int *sig)); +# elif defined (__KCC) +# undef sigwait + inline int sigwait (const sigset_t* set, int* sig) + { return _Psigwait (set, sig); } +# endif /* __DECCXX_VER */ +# elif !defined (ACE_HAS_SIGWAIT) +# if defined(__rtems__) + extern "C" int sigwait (const sigset_t *set, int *sig); +# else + extern "C" int sigwait (sigset_t *set); +# endif /* __rtems__ */ +# endif /* ! DIGITAL_UNIX && ! ACE_HAS_SIGWAIT */ + +# if defined (ACE_LACKS_SIGACTION_T) +struct sigaction +{ + int sa_flags; + ACE_SignalHandlerV sa_handler; + sigset_t sa_mask; +}; +# endif /* ACE_LACKS_SIGACTION_T */ + +# if !defined (SIGHUP) +# define SIGHUP 0 +# endif /* SIGHUP */ + +# if !defined (SIGINT) +# define SIGINT 0 +# endif /* SIGINT */ + +# if !defined (SIGSEGV) +# define SIGSEGV 0 +# endif /* SIGSEGV */ + +# if !defined (SIGIO) +# define SIGIO 0 +# endif /* SIGSEGV */ + +# if !defined (SIGUSR1) +# define SIGUSR1 0 +# endif /* SIGUSR1 */ + +# if !defined (SIGUSR2) +# define SIGUSR2 0 +# endif /* SIGUSR2 */ + +# if !defined (SIGCHLD) +# define SIGCHLD 0 +# endif /* SIGCHLD */ + +# if !defined (SIGCLD) +# define SIGCLD SIGCHLD +# endif /* SIGCLD */ + +# if !defined (SIGQUIT) +# define SIGQUIT 0 +# endif /* SIGQUIT */ + +# if !defined (SIGPIPE) +# define SIGPIPE 0 +# endif /* SIGPIPE */ + +# if !defined (SIGALRM) +# define SIGALRM 0 +# endif /* SIGALRM */ + +# if !defined (SIG_DFL) +# if defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC) +# define SIG_DFL ((void *) 0) +# else +# define SIG_DFL ((__sighandler_t) 0) +# endif +# endif /* SIG_DFL */ + +# if !defined (SIG_IGN) +# if defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC) +# define SIG_IGN ((void *) 1) /* ignore signal */ +# else +# define SIG_IGN ((__sighandler_t) 1) /* ignore signal */ +# endif +# endif /* SIG_IGN */ + +# if !defined (SIG_ERR) +# if defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC) +# define SIG_ERR ((void *) -1) /* error return from signal */ +# else +# define SIG_ERR ((__sighandler_t) -1) /* error return from signal */ +# endif +# endif /* SIG_ERR */ + +# if !defined (SIG_BLOCK) +# define SIG_BLOCK 1 +# endif /* SIG_BLOCK */ + +# if !defined (SIG_UNBLOCK) +# define SIG_UNBLOCK 2 +# endif /* SIG_UNBLOCK */ + +# if !defined (SIG_SETMASK) +# define SIG_SETMASK 3 +# endif /* SIG_SETMASK */ + +# if defined (__Lynx__) + // LynxOS Neutrino sets NSIG to the highest-numbered signal. +# define ACE_NSIG (NSIG + 1) +# elif defined (__rtems__) +# define ACE_NSIG (SIGRTMAX) +# else + // All other platforms set NSIG to one greater than the + // highest-numbered signal. +# define ACE_NSIG NSIG +# endif /* __Lynx__ */ + +// These are used by the <ACE_IPC_SAP::enable> and +// <ACE_IPC_SAP::disable> methods. They must be unique and cannot +// conflict with the value of <ACE_NONBLOCK>. We make the numbers +// negative here so they won't conflict with other values like SIGIO, +// etc. +# define ACE_SIGIO -1 +# define ACE_SIGURG -2 +# define ACE_CLOEXEC -3 + +typedef const char **SYS_SIGLIST; + +#endif /* ACE_OS_INCLUDE_SIGNAL_H */ diff --git a/ace/os_include/stddef.h b/ace/os_include/stddef.h new file mode 100644 index 00000000000..819bb2663c4 --- /dev/null +++ b/ace/os_include/stddef.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file stddef.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_STDDEF_H +# define ACE_OS_INCLUDE_STDDEF_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_STDDEF_H) +# include /**/ <stddef.h> +# endif /* !ACE_LACKS_STDDEF_H */ + +#endif /* ACE_OS_INCLUDE_STDDEF_H */ diff --git a/ace/os_include/stdio.h b/ace/os_include/stdio.h new file mode 100644 index 00000000000..ec04b94e2c4 --- /dev/null +++ b/ace/os_include/stdio.h @@ -0,0 +1,127 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file stdio.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_STDIO_H +# define ACE_OS_INCLUDE_STDIO_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_STDARG_H) +# include /**/ <stdarg.h> // LynxOS requires this before stdio.h +# endif /* !ACE_LACKS_STDARG_H */ + +#if 0 +// turn this off for now. it came from config-all.h when ACE_HAS_VERBOSE_NOTSUP +// turned on. +# if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) +# include /**/ <cstdio> +# else +# if !defined (ACE_LACKS_STDIO_H) +# include /**/ <stdio.h> +# endif /* !ACE_LACKS_STDIO_H */ +# endif +#else /* 0 */ +# if !defined (ACE_LACKS_STDIO_H) +# include /**/ <stdio.h> +# endif /* !ACE_LACKS_STDIO_H */ +#endif /* 0 */ + +# 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 (L_cuserid) +# if !defined (ACE_L_CUSERID) +# define ACE_L_CUSERID 9 + // 8 character user ID + NULL +# endif /* !ACE_L_CUSERID */ +# define L_cuserid ACE_L_CUSERID +# endif /* L_cuserid */ + +// need to fix this? +# if !defined ACE_MAX_USERID +# define ACE_MAX_USERID L_cuserid +# endif /* !ACE_MAX_USERID */ + +#if !defined (ACE_WIN32) +// Honestly don't know where these should go. +// Add some typedefs and macros to enhance Win32 conformance... +# 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 /* FILE_FLAG_SEQUENTIAL_SCAN */ +#endif + +# if !defined (ACE_OSTREAM_TYPE) +# if defined (ACE_LACKS_IOSTREAM_TOTALLY) +# define ACE_OSTREAM_TYPE FILE +# else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +# define ACE_OSTREAM_TYPE ostream +# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +# endif /* ! ACE_OSTREAM_TYPE */ + +# if !defined (ACE_DEFAULT_LOG_STREAM) +# if defined (ACE_LACKS_IOSTREAM_TOTALLY) +# define ACE_DEFAULT_LOG_STREAM 0 +# else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +# define ACE_DEFAULT_LOG_STREAM (&cerr) +# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +# endif /* ! ACE_DEFAULT_LOG_STREAM */ + + + +// this is a nasty hack to get around problems with the +// pSOS definition of BUFSIZ as the config table entry +// (which is valued using the LC_BUFSIZ value anyway) +# if defined (ACE_PSOS) +# if defined (BUFSIZ) +# undef BUFSIZ +# endif /* defined (BUFSIZ) */ +# define BUFSIZ LC_BUFSIZ +# endif /* defined (ACE_PSOS) */ + +# if defined (BUFSIZ) +# define ACE_STREAMBUF_SIZE BUFSIZ +# else +# define ACE_STREAMBUF_SIZE 1024 +# endif /* BUFSIZ */ + +#endif /* ACE_OS_INCLUDE_STDIO_H */ + diff --git a/ace/os_include/stdlib.h b/ace/os_include/stdlib.h new file mode 100644 index 00000000000..61ac33288f8 --- /dev/null +++ b/ace/os_include/stdlib.h @@ -0,0 +1,46 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file stdlib.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_STDLIB_H +# define ACE_OS_INCLUDE_STDLIB_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_STDLIB_H) +# include /**/ <stdlib.h> +# endif /* ACE_LACKS_STDLIB_H */ + +# if defined (ACE_HAS_BROKEN_RANDR) +// The SunOS 5.4.X version of rand_r is inconsistent with the header +// files... +typedef u_int ACE_RANDR_TYPE; +extern "C" int rand_r (ACE_RANDR_TYPE seed); +# else +# if defined (HPUX_10) +// HP-UX 10.x's stdlib.h (long *) doesn't match that man page (u_int *) +typedef long ACE_RANDR_TYPE; +# else +typedef u_int ACE_RANDR_TYPE; +# endif /* HPUX_10 */ +# endif /* ACE_HAS_BROKEN_RANDR */ + +# if defined (ACE_LACKS_MKTEMP) +extern "C" char *mktemp (char *); +# endif /* ACE_LACKS_MKTEMP */ + +#endif /* ACE_OS_INCLUDE_STDLIB_H */ diff --git a/ace/os_include/string.h b/ace/os_include/string.h new file mode 100644 index 00000000000..542d3677c59 --- /dev/null +++ b/ace/os_include/string.h @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file string.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_STRING_H +# define ACE_OS_INCLUDE_STRING_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Matthew Stevens 7-10-95 Fix GNU GCC 2.7 for memchr() problem. +# if defined (ACE_HAS_GNU_CSTRING_H) +// Define this file to keep /usr/include/memory.h from being included. +# include /**/ <cstring> +# else +# if !defined (ACE_LACKS_MEMORY_H) +# include /**/ <memory.h> +# endif /* !ACE_LACKS_MEMORY_H */ +# endif /* ACE_HAS_GNU_CSTRING_H */ + +// why was this included here? +//# include "ace/ace_stdlib.h" + +# if !defined (ACE_LACKS_STRING_H) +# include /**/ <string.h> +# endif /* !ACE_LACKS_STRING_H */ + +// IRIX5 defines bzero() in this odd file... +# if defined (ACE_HAS_BSTRING) +# include /**/ <bstring.h> +# endif /* ACE_HAS_BSTRING */ + +// We need strings.h on some platforms (qnx-neutrino, for example) +// to get the declaration for strcasecmp. And bzero() for AIX. +# if defined (ACE_HAS_STRINGS) +# include /**/ <strings.h> +# endif /* ACE_HAS_STRINGS */ + +# if defined (ACE_LACKS_STRTOK_R_PROTOTYPE) && !defined (_POSIX_SOURCE) +extern "C" char *strtok_r (char *s, const char *delim, char **save_ptr); +# endif /* ACE_LACKS_STRTOK_R_PROTOTYPE */ + +#endif /* ACE_OS_INCLUDE_STRING_H */ + diff --git a/ace/os_include/stropts.h b/ace/os_include/stropts.h new file mode 100644 index 00000000000..eb48065161b --- /dev/null +++ b/ace/os_include/stropts.h @@ -0,0 +1,83 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file stropts.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_STROPTS_H +# define ACE_OS_INCLUDE_STROPTS_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_STROPTS_H) +# if defined (ACE_HAS_STREAMS) +# if defined (AIX) +# if !defined (_XOPEN_EXTENDED_SOURCE) +# define _XOPEN_EXTENDED_SOURCE +# endif /* !_XOPEN_EXTENDED_SOURCE */ +# include /**/ <stropts.h> +# undef _XOPEN_EXTENDED_SOURCE +# endif /* AIX */ +//# else +//# include /**/ <stropts.h> +# endif /* ACE_HAS_STREAMS */ +# include /**/ <stropts.h> +# endif /* ACE_LACKS_STROPTS_H */ + +# if defined (ACE_LACKS_STRRECVFD) +struct strrecvfd {}; +# endif /* ACE_LACKS_STRRECVFD */ + +# if !defined (ACE_HAS_STRBUF_T) +struct strbuf +{ + int maxlen; // no. of bytes in buffer. + int len; // no. of bytes returned. + void *buf; // pointer to data. +}; +# endif /* ACE_HAS_STRBUF_T */ + +extern "C" int isastream (int); + +// should find a better place for this, but not +// OS.h!!! +# include "ace/OS_Export.h" // and this is why! +/** + * @class ACE_Str_Buf + * + * @brief Simple wrapper for STREAM pipes strbuf. + */ +class ACE_OS_Export ACE_Str_Buf : public strbuf +{ +public: + // = Initialization method + /// Constructor. + ACE_Str_Buf (void *b = 0, int l = 0, int max = 0)//; + { + this->maxlen = max; + this->len = l; + this->buf = (char *) b; + } + + /// Constructor. + ACE_Str_Buf (strbuf &sb)//; + { + this->maxlen = sb.maxlen; + this->len = sb.len; + this->buf = sb.buf; + } +}; + +#endif /* ACE_OS_INCLUDE_STROPTS_H */ diff --git a/ace/os_include/sys/ioctl.h b/ace/os_include/sys/ioctl.h new file mode 100644 index 00000000000..b25aff91f01 --- /dev/null +++ b/ace/os_include/sys/ioctl.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file ioctl.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_IOCTL_H +# define ACE_OS_INCLUDE_SYS_IOCTL_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_SYS_IOCTL_H) +# include /**/ <sys/ioctl.h> +# endif /* !ACE_LACKS_SYS_IOCTL_H */ + +#endif /* ACE_OS_INCLUDE_SYS_IOCTL_H */ diff --git a/ace/os_include/sys/ipc.h b/ace/os_include/sys/ipc.h new file mode 100644 index 00000000000..e0e1fd48081 --- /dev/null +++ b/ace/os_include/sys/ipc.h @@ -0,0 +1,53 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file ipc.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_IPC_H +# define ACE_OS_INCLUDE_SYS_IPC_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_SYS_IPC_H) +# include /**/ <sys/ipc.h> +# endif /* !ACE_LACKS_SYS_IPC_H */ + +# if !defined (IPC_CREAT) +# define IPC_CREAT 0 +# endif /* IPC_CREAT */ + +# if !defined (IPC_NOWAIT) +# define IPC_NOWAIT 0 +# endif /* IPC_NOWAIT */ + +# if !defined (IPC_RMID) +# define IPC_RMID 0 +# endif /* IPC_RMID */ + +# if !defined (IPC_EXCL) +# define IPC_EXCL 0 +# endif /* IPC_EXCL */ + +# if !defined (IPC_PRIVATE) +# define IPC_PRIVATE ACE_INVALID_SEM_KEY +# endif /* IPC_PRIVATE */ + +# if !defined (IPC_STAT) +# define IPC_STAT 0 +# endif /* IPC_STAT */ + +#endif /* ACE_OS_INCLUDE_SYS_IPC_H */ diff --git a/ace/os_include/sys/mman.h b/ace/os_include/sys/mman.h new file mode 100644 index 00000000000..b757649f1b5 --- /dev/null +++ b/ace/os_include/sys/mman.h @@ -0,0 +1,90 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file mman.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_MMAN_H +# define ACE_OS_INCLUDE_SYS_MMAN_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Fixes a problem with HP/UX. +# if defined (ACE_HAS_BROKEN_MMAP_H) +extern "C" +{ +# include /**/ <sys/mman.h> +} +# elif !defined (ACE_LACKS_SYS_MMAN_H) +# include /**/ <sys/mman.h> +# endif /* !ACE_HAS_BROKEN_MMAP_H */ + + +// These need to be moved at some point, and replaced by ifdef'd defines for each. +# if defined (ACE_WIN32) +// MMAP flags +# define PROT_READ PAGE_READONLY +# define PROT_WRITE PAGE_READWRITE +# define PROT_RDWR PAGE_READWRITE +/* If we can find suitable use for these flags, here they are: +PAGE_WRITECOPY +PAGE_EXECUTE +PAGE_EXECUTE_READ +PAGE_EXECUTE_READWRITE +PAGE_EXECUTE_WRITECOPY +PAGE_GUARD +PAGE_NOACCESS +PAGE_NOCACHE */ +# elif defined (ACE_LACKS_SYS_MMAP_H) +# 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_SYS_MMAP_H */ + +# if !defined (PROT_RDWR) +# define PROT_RDWR (PROT_READ|PROT_WRITE) +# endif /* PROT_RDWR */ + + +# if !defined (ACE_MAP_PRIVATE) +# define ACE_MAP_PRIVATE MAP_PRIVATE +# endif /* ! ACE_MAP_PRIVATE */ + +# if !defined (ACE_MAP_SHARED) +# define ACE_MAP_SHARED MAP_SHARED +# endif /* ! ACE_MAP_SHARED */ + +# if !defined (ACE_MAP_FIXED) +# define ACE_MAP_FIXED MAP_FIXED +# endif /* ! ACE_MAP_FIXED */ + +# if !defined (MS_SYNC) +# define MS_SYNC 0x0 +# endif /* !MS_SYNC */ + +# if !defined (MAP_FAILED) || defined (ACE_HAS_BROKEN_MAP_FAILED) +# undef MAP_FAILED +# define MAP_FAILED ((void *) -1) +# elif defined (ACE_HAS_LONG_MAP_FAILED) +# undef MAP_FAILED +# define MAP_FAILED ((void *) -1L) +# endif /* !MAP_FAILED || ACE_HAS_BROKEN_MAP_FAILED */ + +#endif /* ACE_OS_INCLUDE_SYS_MMAN_H */ diff --git a/ace/os_include/sys/msg.h b/ace/os_include/sys/msg.h new file mode 100644 index 00000000000..459f53b6b51 --- /dev/null +++ b/ace/os_include/sys/msg.h @@ -0,0 +1,51 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file msg.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_MSG_H +# define ACE_OS_INCLUDE_SYS_MSG_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if defined (ACE_HAS_BROKEN_MSG_H) +# define _KERNEL +# endif /* ACE_HAS_BROKEN_MSG_H */ + +# if !defined (ACE_LACKS_SYSV_MSG_H) +# include /**/ <sys/msg.h> +# endif /* ACE_LACKS_SYSV_MSG_H */ + +# if defined (ACE_HAS_BROKEN_MSG_H) +# undef _KERNEL +# endif /* ACE_HAS_BROKEN_MSG_H */ + + +# if defined (ACE_LACKS_MSGBUF_T) +struct msgbuf {}; +# endif /* ACE_LACKS_MSGBUF_T */ + +# if defined (ACE_LACKS_SYSV_MSQ_PROTOS) +extern "C" +{ + int msgget (key_t, int); + int msgrcv (int, void *, size_t, long, int); + int msgsnd (int, const void *, size_t, int); + int msgctl (int, int, struct msqid_ds *); +} +# endif /* ACE_LACKS_SYSV_MSQ_PROTOS */ + +#endif /* ACE_OS_INCLUDE_SYS_MSG_H */ diff --git a/ace/os_include/sys/param.h b/ace/os_include/sys/param.h new file mode 100644 index 00000000000..6ac0730dd5f --- /dev/null +++ b/ace/os_include/sys/param.h @@ -0,0 +1,44 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file param.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_PARAM_H +# define ACE_OS_INCLUDE_SYS_PARAM_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_PARAM_H) +# include /**/ <sys/param.h> +# endif /* !ACE_LACKS_SYS_PARAM_H */ + +// Need to note why this is included. +//# include "ace/os_include/limits.h" + +// _MAX_PATH is in stdlib.h on windows... +# include "ace/os_include/stdlib.h" + +# if !defined (MAXPATHLEN) +# if defined (ACE_WIN32) +# define MAXPATHLEN _MAX_PATH +# elif defined (_POSIX_PATH_MAX) +# define MAXPATHLEN _POSIX_PATH_MAX +# else +# define MAXPATHLEN 1024 +# endif /* ACE_WIN32 */ +# endif /* MAXPATHLEN */ + +#endif /* ACE_OS_INCLUDE_SYS_PARAM_H */ diff --git a/ace/os_include/sys/resource.h b/ace/os_include/sys/resource.h new file mode 100644 index 00000000000..1e2c78e54b8 --- /dev/null +++ b/ace/os_include/sys/resource.h @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file resource.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_RESOURCE_H +# define ACE_OS_INCLUDE_SYS_RESOURCE_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_RESOURCE_H) +# include /**/ <sys/resource.h> +# endif /* !ACE_LACKS_SYS_RESOURCE_H */ + +# if defined (ACE_HAS_BROKEN_SETRLIMIT) +typedef struct rlimit ACE_SETRLIMIT_TYPE; +# else +typedef const struct rlimit ACE_SETRLIMIT_TYPE; +# endif /* ACE_HAS_BROKEN_SETRLIMIT */ + +# if defined (ACE_HAS_PRUSAGE_T) + typedef prusage_t ACE_Rusage; +# elif defined (ACE_HAS_GETRUSAGE) + typedef rusage ACE_Rusage; +# else + typedef int ACE_Rusage; +# endif /* ACE_HAS_PRUSAGE_T */ + +# if !defined (ACE_HAS_GETRUSAGE_PROTO) +extern "C" int getrusage (int who, struct rusage *rusage); +# endif /* ! ACE_HAS_GETRUSAGE_PROTO */ + +// There must be a better way to do this... +# if !defined (RLIMIT_NOFILE) +# if defined (linux) || defined (AIX) || defined (SCO) +# if defined (RLIMIT_OFILE) +# define RLIMIT_NOFILE RLIMIT_OFILE +# else +# define RLIMIT_NOFILE 200 +# endif /* RLIMIT_OFILE */ +# endif /* defined (linux) || defined (AIX) || defined (SCO) */ +# endif /* RLIMIT_NOFILE */ + +#endif /* ACE_OS_INCLUDE_SYS_RESOURCE_H */ diff --git a/ace/os_include/sys/select.h b/ace/os_include/sys/select.h new file mode 100644 index 00000000000..4aabe050967 --- /dev/null +++ b/ace/os_include/sys/select.h @@ -0,0 +1,41 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file selct.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_SELECT_H +# define ACE_OS_INCLUDE_SYS_SELECT_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_SYS_SELECT_H) +# include /**/ <sys/select.h> +# endif /* !ACE_LACKS_SYS_SELECT_H */ + +# if defined (ACE_NEEDS_SELECT_T) // __rtems__ +extern "C" +{ + int select (int n, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct timeval *timeout); +}; +# endif /* ACE_NEEDS_SELECT_T */ + +# if !defined (NFDBITS) +# define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +# endif /* ! NFDBITS */ + +#endif /* ACE_OS_INCLUDE_SYS_SELECT_H */ diff --git a/ace/os_include/sys/sem.h b/ace/os_include/sys/sem.h new file mode 100644 index 00000000000..b4ac253c72d --- /dev/null +++ b/ace/os_include/sys/sem.h @@ -0,0 +1,70 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file sem.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_SEM_H +# define ACE_OS_INCLUDE_SYS_SEM_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_SEM_H) +# include /**/ <sys/sem.h> +# endif /* !ACE_LACKS_SYS_SEM_H */ + +# if defined (ACE_LACKS_SEMBUF_T) +struct sembuf +{ + unsigned short sem_num; // semaphore # + short sem_op; // semaphore operation + short sem_flg; // operation flags +}; +# endif /* ACE_LACKS_SEMBUF_T */ + +# if !defined (GETVAL) +# define GETVAL 0 +# endif /* GETVAL */ + +# if !defined (F_GETFL) +# define F_GETFL 0 +# endif /* F_GETFL */ + +# if !defined (SETVAL) +# define SETVAL 0 +# endif /* SETVAL */ + +# if !defined (GETALL) +# define GETALL 0 +# endif /* GETALL */ + +# if !defined (SETALL) +# define SETALL 0 +# endif /* SETALL */ + +# if !defined (SEM_UNDO) +# define SEM_UNDO 0 +# endif /* SEM_UNDO */ + +# if !defined (ACE_HAS_SEMUN) || (defined (__GLIBC__) && defined (_SEM_SEMUN_UNDEFINED)) +union semun +{ + int val; // value for SETVAL + struct semid_ds *buf; // buffer for IPC_STAT & IPC_SET + u_short *array; // array for GETALL & SETALL +}; +# endif /* !ACE_HAS_SEMUN || (defined (__GLIBC__) && defined (_SEM_SEMUN_UNDEFINED)) */ + +#endif /* ACE_OS_INCLUDE_SYS_SEM_H */ diff --git a/ace/os_include/sys/shm.h b/ace/os_include/sys/shm.h new file mode 100644 index 00000000000..af7ee716791 --- /dev/null +++ b/ace/os_include/sys/shm.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file shm.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_SHM_H +# define ACE_OS_INCLUDE_SYS_SHM_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_SYS_SHM_H) +# include /**/ <sys/shm.h> +# endif /* !ACE_LACKS_SYS_SHM_H */ + +#endif /* ACE_OS_INCLUDE_SYS_SHM_H */ diff --git a/ace/os_include/sys/socket.h b/ace/os_include/sys/socket.h new file mode 100644 index 00000000000..8ef881f7540 --- /dev/null +++ b/ace/os_include/sys/socket.h @@ -0,0 +1,307 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file socket.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_SOCKET_H +# define ACE_OS_INCLUDE_SYS_SOCKET_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/os_include/stdio.h" +# include "ace/os_include/sys/types.h" + +# if !defined (ACE_LACKS_SYS_SOCKET_H) && !defined (ACE_LACKS_UNIX_SYS_HEADERS) +# if defined (ACE_HAS_AIX_BROKEN_SOCKET_HEADER) +# undef __cplusplus +# include /**/ <sys/socket.h> +# define __cplusplus +# else +# include /**/ <sys/socket.h> +# endif /* ACE_HAS_AIX_BROKEN_SOCKET_HEADER */ +# endif /* !ACE_LACKS_SYS_SOCKET_H && !ACE_LACKS_UNIX_SYS_HEADERS */ + +# if defined (ACE_HAS_SOCKIO_H) +# include /**/ <sys/sockio.h> +# endif /* ACE_HAS_SOCKIO_ */ + +extern "C" +{ +# if defined (VXWORKS) + struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* aliases: not used on VxWorks */ + 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 */ + }; +# elif defined (ACE_HAS_CYGWIN32_SOCKET_H) +# include /**/ <cygwin32/socket.h> +# elif !defined (ACE_WIN32) +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# define queue _Queue_ +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +# include /**/ <netdb.h> +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# undef queue +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +# endif /* VXWORKS */ +} + +extern "C" +{ +# if defined (VXWORKS) + // Work around a lack of ANSI prototypes for these functions on VxWorks. + unsigned long inet_addr (const char *); + char *inet_ntoa (const struct in_addr); + struct in_addr inet_makeaddr (const int, const int); + unsigned long inet_network (const char *); +# elif !defined (ACE_WIN32) +# include /**/ <arpa/inet.h> +# endif /* ! VXWORKS */ +} + +// not sure where this should go... +#if !defined (ACE_WIN32) && !defined (ACE_PSOS) +// This part if to avoid STL name conflict with the map structure +// in net/if.h. +# if defined (ACE_HAS_STL_MAP_CONFLICT) +# define map _Resource_Allocation_Map_ +# endif /* ACE_HAS_STL_MAP_CONFLICT */ +# include /**/ <net/if.h> +# if defined (ACE_HAS_STL_MAP_CONFLICT) +# undef map +# endif /* ACE_HAS_STL_MAP_CONFLICT */ + +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# define queue _Queue_ +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +//# include /**/ <netinet/in.h> +# include "ace/os_include/netinet/in.h" +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# undef queue +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ + +# if !defined (ACE_LACKS_TCP_H) +# if defined(ACE_HAS_CONFLICTING_XTI_MACROS) +# if defined(TCP_NODELAY) +# undef TCP_NODELAY +# endif +# if defined(TCP_MAXSEG) +# undef TCP_MAXSEG +# endif +# endif +# include /**/ <netinet/tcp.h> +# endif /* ACE_LACKS_TCP_H */ +#endif /* !ACE_WIN32 && !ACE_PSOS */ + +# if defined (SD_RECEIVE) +# define ACE_SHUTDOWN_READ SD_RECEIVE +# elif defined (SHUT_RD) +# define ACE_SHUTDOWN_READ SHUT_RD +# else +# define ACE_SHUTDOWN_READ 0 +# endif /* SD_RECEIVE */ + +# if defined (SD_SEND) +# define ACE_SHUTDOWN_WRITE SD_SEND +# elif defined (SHUT_WR) +# define ACE_SHUTDOWN_WRITE SHUT_WR +# else +# define ACE_SHUTDOWN_WRITE 1 +# endif /* SD_RECEIVE */ + +# if defined (SD_BOTH) +# define ACE_SHUTDOWN_BOTH SD_BOTH +# elif defined (SHUT_RDWR) +# define ACE_SHUTDOWN_BOTH SHUT_RDWR +# else +# define ACE_SHUTDOWN_BOTH 2 +# endif /* SD_RECEIVE */ + +# if defined (ACE_HAS_PHARLAP_RT) +# define ACE_IPPROTO_TCP SOL_SOCKET +# else +# define ACE_IPPROTO_TCP IPPROTO_TCP +# endif /* ACE_HAS_PHARLAP_RT */ + +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) +typedef WSAPROTOCOL_INFO ACE_Protocol_Info; + +// Callback function that's used by the QoS-enabled <ACE_OS::ioctl> +// method. +typedef LPWSAOVERLAPPED_COMPLETION_ROUTINE ACE_OVERLAPPED_COMPLETION_FUNC; +typedef GROUP ACE_SOCK_GROUP; +# else /* (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ + +struct ACE_OVERLAPPED +{ + u_long Internal; + u_long InternalHigh; + u_long Offset; + u_long OffsetHigh; + ACE_HANDLE hEvent; +}; + +struct ACE_Protocol_Info +{ + u_long dwServiceFlags1; + int iAddressFamily; + int iProtocol; + char szProtocol[255+1]; +}; + +// Callback function that's used by the QoS-enabled <ACE_OS::ioctl> +// method. +typedef void (*ACE_OVERLAPPED_COMPLETION_FUNC) (u_long error, + u_long bytes_transferred, + ACE_OVERLAPPED *overlapped, + u_long flags); +typedef u_long ACE_SOCK_GROUP; + +# endif /* (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ + + +// For Win32 compatibility... +# if !defined (ACE_WSOCK_VERSION) +# define ACE_WSOCK_VERSION 0, 0 +# endif /* ACE_WSOCK_VERSION */ + + +// Increase the range of "address families". Please note that this +// must appear _after_ the include of sys/socket.h, for the AF_FILE +// definition on Linux/glibc2. +# if !defined (AF_ANY) +# define AF_ANY (-1) +# endif /* AF_ANY */ + +# define AF_SPIPE (AF_MAX + 1) +# if !defined (AF_FILE) +# define AF_FILE (AF_MAX + 2) +# endif /* ! AF_FILE */ +# define AF_DEV (AF_MAX + 3) +# define AF_UPIPE (AF_SPIPE) + +# if !defined(MAXHOSTNAMELEN) +# define MAXHOSTNAMELEN 256 +# endif /* MAXHOSTNAMELEN */ + +// Define INET loopback address constant if it hasn't been defined +// Dotted Decimal 127.0.0.1 == Hexidecimal 0x7f000001 +# if !defined (INADDR_LOOPBACK) +# define INADDR_LOOPBACK ((ACE_UINT32) 0x7f000001) +# endif /* INADDR_LOOPBACK */ + +// The INADDR_NONE address is generally 255.255.255.255. +# if !defined (INADDR_NONE) +# define INADDR_NONE ((ACE_UINT32) 0xffffffff) +# endif /* INADDR_NONE */ + +// Define INET string length constants if they haven't been defined +// +// for IPv4 dotted-decimal +# if !defined (INET_ADDRSTRLEN) +# define INET_ADDRSTRLEN 16 +# endif /* INET_ADDRSTRLEN */ +// +// for IPv6 hex string +# if !defined (INET6_ADDRSTRLEN) +# define INET6_ADDRSTRLEN 46 +# endif /* INET6_ADDRSTRLEN */ + +# if defined (ACE_HAS_IPV6) + +# if defined (ACE_USES_IPV4_IPV6_MIGRATION) +# define ACE_ADDRESS_FAMILY_INET AF_UNSPEC +# define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC +# else +# define ACE_ADDRESS_FAMILY_INET AF_INET6 +# define ACE_PROTOCOL_FAMILY_INET PF_INET6 +# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ + +# else +# define ACE_ADDRESS_FAMILY_INET AF_INET +# define ACE_PROTOCOL_FAMILY_INET PF_INET +# endif + + +# if defined (ACE_HAS_BROKEN_SENDMSG) +typedef struct msghdr ACE_SENDMSG_TYPE; +# else +typedef const struct msghdr ACE_SENDMSG_TYPE; +# endif /* ACE_HAS_BROKEN_SENDMSG */ + +# if !defined (ACE_HAS_MSG) && !defined (SCO) +struct msghdr {}; +# endif /* ACE_HAS_MSG */ + +# if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS) +# if !defined (msg_accrights) +# undef msg_control +# define msg_accrights msg_control +# endif /* ! msg_accrights */ + +# if !defined (msg_accrightslen) +# undef msg_controllen +# define msg_accrightslen msg_controllen +# endif /* ! msg_accrightslen */ +# endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */ + +# if defined (ACE_WIN32) +# include "ace/os_include/sys/uio.h" // needed for iovec +struct msghdr +{ + sockaddr * msg_name; + // optional address + + int msg_namelen; + // size of address + + iovec *msg_iov; + /* scatter/gather array */ + + int msg_iovlen; + // # elements in msg_iov + + caddr_t msg_accrights; + // access rights sent/received + + int msg_accrightslen; +}; +# endif /* ACE_WIN32 */ + +// this stuff is normally in <netdb.h> +# if defined (ACE_HAS_STRUCT_NETDB_DATA) +typedef char ACE_HOSTENT_DATA[sizeof(struct hostent_data)]; +typedef char ACE_SERVENT_DATA[sizeof(struct servent_data)]; +typedef char ACE_PROTOENT_DATA[sizeof(struct protoent_data)]; +# else +# if !defined ACE_HOSTENT_DATA_SIZE +# define ACE_HOSTENT_DATA_SIZE (4*1024) +# endif /*ACE_HOSTENT_DATA_SIZE */ +# if !defined ACE_SERVENT_DATA_SIZE +# define ACE_SERVENT_DATA_SIZE (4*1024) +# endif /*ACE_SERVENT_DATA_SIZE */ +# if !defined ACE_PROTOENT_DATA_SIZE +# define ACE_PROTOENT_DATA_SIZE (2*1024) +# endif /*ACE_PROTOENT_DATA_SIZE */ +typedef char ACE_HOSTENT_DATA[ACE_HOSTENT_DATA_SIZE]; +typedef char ACE_SERVENT_DATA[ACE_SERVENT_DATA_SIZE]; +typedef char ACE_PROTOENT_DATA[ACE_PROTOENT_DATA_SIZE]; +# endif /* ACE_HAS_STRUCT_NETDB_DATA */ + +#endif /* ACE_OS_INCLUDE_SYS_SOCKET_H */ diff --git a/ace/os_include/sys/stat.h b/ace/os_include/sys/stat.h new file mode 100644 index 00000000000..e97275dc2e5 --- /dev/null +++ b/ace/os_include/sys/stat.h @@ -0,0 +1,80 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file stat.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_STAT_H +# define ACE_OS_INCLUDE_SYS_STAT_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_STAT_H) && !defined (ACE_LACKS_UNIX_SYS_HEADERS) +# include /**/ <sys/stat.h> +# endif /* !ACE_LACKS_SYS_STAT_H && !ACE_LACKS_UNIX_SYS_HEADERS */ + +# if defined (ACE_LACKS_MODE_MASKS) +// MODE MASKS + +// the following macros are for POSIX conformance. + +# if !defined (ACE_HAS_USER_MODE_MASKS) +# define S_IRWXU 00700 /* read, write, execute: owner. */ +# define S_IRUSR 00400 /* read permission: owner. */ +# define S_IWUSR 00200 /* write permission: owner. */ +# define S_IXUSR 00100 /* execute permission: owner. */ +# endif /* ACE_HAS_USER_MODE_MASKS */ +# define S_IRWXG 00070 /* read, write, execute: group. */ +# define S_IRGRP 00040 /* read permission: group. */ +# define S_IWGRP 00020 /* write permission: group. */ +# define S_IXGRP 00010 /* execute permission: group. */ +# define S_IRWXO 00007 /* read, write, execute: other. */ +# define S_IROTH 00004 /* read permission: other. */ +# define S_IWOTH 00002 /* write permission: other. */ +# define S_IXOTH 00001 /* execute permission: other. */ + +# endif /* ACE_LACKS_MODE_MASKS */ + +# if defined (ACE_WINCE) +// ACE_WINCE thing... +// CE's add-on for c-style fstat/stat functionalities. This struct is +// by no mean complete compared to what you usually find in UNIX +// platforms. Only members that have direct conversion using Win32's +// BY_HANDLE_FILE_INFORMATION are defined so that users can discover +// non-supported members at compile time. Time values are of type +// ACE_Time_Value for easy comparison. + +// Since CE does not have _stat by default as NT/2000 does, the 'stat' +// struct defined here will be used. Also note that CE file system +// struct is only for the CE 3.0 or later. +// Refer to the WCHAR.H from Visual C++ and WIBASE.H from eVC 3.0. +struct stat +{ + dev_t st_dev; // always 0 on Windows platforms + dev_t st_rdev; // always 0 on Windows platforms + unsigned short st_mode; // file attribute + short st_nlink; // number of hard links + ACE_Time_Value st_atime; // time of last access + ACE_Time_Value st_mtime; // time of last data modification + ACE_Time_Value st_ctime; // time of creation + off_t st_size; // file size, in bytes + + // Following members do not have direct conversion in Window platforms. +// u_long st_blksize; // optimal blocksize for I/O +// u_long st_flags; // user defined flags for file +}; +# endif /* ACE_WINCE */ + +#endif /* ACE_OS_INCLUDE_SYS_STAT_H */ diff --git a/ace/os_include/sys/times.h b/ace/os_include/sys/times.h new file mode 100644 index 00000000000..2a21b3a2974 --- /dev/null +++ b/ace/os_include/sys/times.h @@ -0,0 +1,28 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file times.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_TIMES_H +# define ACE_OS_INCLUDE_SYS_TIMES_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_TIMES_H) +# include /**/ <sys/times.h> +# endif /* ACE_LACKS_SYS_TIMES_H */ + +#endif /* ACE_OS_INCLUDE_SYS_TIMES_H */ diff --git a/ace/os_include/sys/types.h b/ace/os_include/sys/types.h new file mode 100644 index 00000000000..a7927bdf260 --- /dev/null +++ b/ace/os_include/sys/types.h @@ -0,0 +1,192 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file types.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_TYPES_H +# define ACE_OS_INCLUDE_SYS_TYPES_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_TYPES_H) +# include /**/ <sys/types.h> +# else /* !ACE_LACKS_SYS_TYPES_H */ +// For right now, assume that if you don't have sys/types, you +// don't have these either. +// Might need to add 1 0 to these if we have problems. +# define ACE_LACKS_U_CHAR +# define ACE_LACKS_UCHAR_T +# define ACE_LACKS_U_SHORT +# define ACE_LACKS_USHORT_T +# define ACE_LACKS_U_INT +# define ACE_LACKS_UINT_T +# define ACE_LACKS_U_LONG +# define ACE_LACKS_ULONG_T +# endif /* !ACE_LACKS_SYS_TYPES_H && !ACE_LACKS_UNIX_SYS_HEADERS */ + +# if defined (ACE_HAS_TYPES_H) +# include /**/ <types.h> +# endif /* ACE_HAS_TYPES_H */ + +# if defined (ACE_LACKS_U_CHAR) + typedef unsigned char u_char; +# endif /* ACE_LACKS_U_CHAR */ + +# if defined (ACE_LACKS_UCHAR_T) + typedef u_char uchar_t; +# endif /* ACE_LACKS_UCHAR_T */ + +# if defined (ACE_LACKS_U_SHORT) + typedef unsigned short u_short; +# endif /* ACE_LACKS_U_CHAR */ + +# if defined (ACE_LACKS_USHORT_T) + typedef u_short ushort_t; +# endif /* ACE_LACKS_UCHAR_T */ + +# if defined (ACE_LACKS_U_INT) + typedef unsigned int u_int; +# endif /* ACE_LACKS_U_INT */ + +# if defined (ACE_LACKS_UINT_T) + typedef u_int uint_t; +# endif /* ACE_LACKS_UINT_T */ + +# if defined (ACE_LACKS_U_LONG) + typedef unsigned long u_long; +# endif /* ACE_LACKS_U_LONG */ + +# if defined (ACE_LACKS_ULONG_T) + typedef u_long ulong_t; +# endif /* ACE_LACKS_ULONG_T */ + +# if defined (ACE_LACKS_CADDR_T) +typedef char* caddr_t; +# endif /* ACE_LACKS_CDDR_T */ + +# if defined (ACE_LACKS_CLOCK_T) +typedef long int clock_t; +# endif /* ACE_LACKS_CLOCK_T */ + +# if defined (ACE_LACKS_COMP_T) +typedef u_short comp_t; +# endif /* ACE_LACKS_COMP_T */ + +# if defined (ACE_LACKS_DEV_T) +typedef u_int dev_t; +# endif /* ACE_LACKS_DEV_T */ + +# if defined (ACE_LACKS_FD_SET_T) || defined (ACE_FD_SET_TYPE) +# if !defined (ACE_FD_SET_TYPE) +# define ACE_FD_SET_TYPE fd_set +# endif /* ACE_FD_SET_TYPE */ +typedef ACE_FD_SET_TYPE fd_set; +# endif /* ACE_LACKS_FD_SET_T */ + +// This is for select calls, set to int in your config-*.h file if +// your os doesn't use fd_set in select calls. +# if !defined (ACE_SELECT_FD_SET_TYPE) +# define ACE_SELECT_FD_SET_TYPE fd_set +# endif /* ACE_FD_SET_TYPE */ + +# if defined (ACE_LACKS_FPOS_T) +// another struct +//typedef int fpos_t; +# endif /* ACE_LACKS_FPOS_T */ + +# if defined (ACE_LACKS_GID_T) || defined (ACE_GUID_T_TYPE) +# if !defined (ACE_GID_T_TYPE) +# define ACE_GID_T_TYPE u_int +# endif /* !ACE_GID_T_TYPE */ +typedef ACE_GID_T_TYPE gid_t; +# endif /* ACE_LACKS_GID_T */ + +# if defined (ACE_LACKS_INO_T) +typedef u_long ino_t; +# endif /* ACE_LACKS_INO_T */ + +# if defined (ACE_LACKS_KEY_T) || defined (ACE_KEY_T_TYPE) +# if !defined (ACE_KEY_T_TYPE) +# define ACE_KEY_T_TYPE long int +# endif /* ACE_KEY_T_TYPE */ +typedef ACE_KEY_T_TYPE key_t; +# endif /* ACE_LACKS_KEY_T */ + +# if defined (ACE_LACKS_MODE_T) || defined (ACE_MODE_T_TYPE) +# if !defined (ACE_MODE_T_TYPE) +# define ACE_MODE_T_TYPE u_int +# endif /* !ACE_MODE_T_TYPE */ +typedef ACE_MODE_T_TYPE mode_t; +# endif /* ACE_LACKS_MODE_T */ + +# if defined (ACE_LACKS_NLINK_T) || defined (ACE_NLINK_T_TYPE) +# if !defined (ACE_NLINK_T_TYPE) +# define ACE_NLINK_T_TYPE u_int +# endif /* !ACE_NLINK_T_TYPE */ +typedef ACE_NLINK_T_TYPE nlink_t; +# endif /* ACE_LACKS_NLINK_T */ + +# if defined (ACE_LACKS_OFF_T) +typedef long int off_t; +# endif /* ACE_LACKS_OFF_T */ + +# if defined (ACE_LACKS_OFF_T) +typedef long long int loff_t; +# endif /* ACE_LACKS_OFF_T */ + +# if defined (ACE_LACKS_PID_T) || defined (ACE_PID_T_TYPE) +# if !defined (ACE_PID_T_TYPE) +# define ACE_PID_T_TYPE int +# endif /* !ACE_PID_T_TYPE */ +typedef ACE_PID_T_TYPE pid_t; +# endif /* ACE_LACKS_PID_T */ + +# if defined (ACE_LACKS_PTRDIFF_T) +typedef int ptrdiff_t; +# endif /* ACE_LACKS_PTRDIFF_T */ + +# if defined (ACE_LACKS_RLIM_T) +typedef u_long rlim_t; +# endif /* ACE_LACKS_RLIM_T */ + +# if defined (ACE_LACKS_SIG_ATOMIC_T) +typedef int sig_atomic_t; +# endif /* ACE_LACKS_SIG_ATOMIC_T */ + +# if defined (ACE_LACKS_SIZE_T) +typedef u_int size_t; +# endif /* ACE_LACKS_SIZE_T */ + +# if defined (ACE_LACKS_SSIZE_T) +typedef int ssize_t; +# endif /* ACE_LACKS_SSIZE_T */ + +# if defined (ACE_LACKS_TIME_T) +typedef long int time_t; +# endif /* ACE_LACKS_TIME_T */ + +# if defined (ACE_LACKS_UID_T) || defined (ACE_UID_T_TYPE) +# if !defined (ACE_UID_T_TYPE) +# define ACE_UID_T_TYPE u_int +# endif /* !ACE_UID_T_TYPE */ +typedef ACE_UID_T_TYPE uid_t; +# endif /* ACE_LACKS_UID_T */ + +# if defined (ACE_LACKS_WCHAR_T) +typedef u_long wchar_t; +# endif /* ACE_LACKS_WCHAR_T */ + +#endif /* ACE_OS_INCLUDE_SYS_TYPES_H */ diff --git a/ace/os_include/sys/uio.h b/ace/os_include/sys/uio.h new file mode 100644 index 00000000000..3a309f3e545 --- /dev/null +++ b/ace/os_include/sys/uio.h @@ -0,0 +1,47 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file uio.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_UIO_H +# define ACE_OS_INCLUDE_SYS_UIO_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_UIO_H) && !defined (ACE_LACKS_UNIX_SYS_HEADERS) +# include /**/ <sys/uio.h> +# endif /* !ACE_LACKS_SYS_UIO_H && !ACE_LACKS_UNIX_SYS_HEADERS */ + +# if defined(__rtems__) +struct iovec { + char *iov_base; // Base address. + size_t iov_len; // Length. +}; +# endif + +# if defined (ACE_HAS_BROKEN_WRITEV) +typedef struct iovec ACE_WRITEV_TYPE; +# else +typedef const struct iovec ACE_WRITEV_TYPE; +# endif /* ACE_HAS_BROKEN_WRITEV */ + +# if defined (ACE_HAS_BROKEN_READV) +typedef const struct iovec ACE_READV_TYPE; +# else +typedef struct iovec ACE_READV_TYPE; +# endif /* ACE_HAS_BROKEN_READV */ + +#endif /* ACE_OS_INCLUDE_SYS_UIO_H */ diff --git a/ace/os_include/sys/utsname.h b/ace/os_include/sys/utsname.h new file mode 100644 index 00000000000..702fda99380 --- /dev/null +++ b/ace/os_include/sys/utsname.h @@ -0,0 +1,49 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file utsname.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_UTSNAME_H +# define ACE_OS_INCLUDE_SYS_UTSNAME_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_SYS_UTSNAME_H) +# include /**/ <sys/utsname.h> +# endif /* !ACE_LACKS_SYS_UTSNAME_H */ + + +# if defined (ACE_LACKS_UTSNAME_T) +# if !defined (SYS_NMLN) +# define SYS_NMLN 257 +# endif /* SYS_NMLN */ +# if !defined (_SYS_NMLN) +# define _SYS_NMLN SYS_NMLN +# endif /* _SYS_NMLN */ +struct ACE_utsname +{ + ACE_TCHAR sysname[_SYS_NMLN]; + ACE_TCHAR nodename[_SYS_NMLN]; + ACE_TCHAR release[_SYS_NMLN]; + ACE_TCHAR version[_SYS_NMLN]; + ACE_TCHAR machine[_SYS_NMLN]; +}; +# else +typedef struct utsname ACE_utsname; +# endif /* ACE_LACKS_UTSNAME_T */ + +#endif /* ACE_OS_INCLUDE_SYS_UTSNAME_H */ diff --git a/ace/os_include/sys/wait.h b/ace/os_include/sys/wait.h new file mode 100644 index 00000000000..55ba9d6e2d9 --- /dev/null +++ b/ace/os_include/sys/wait.h @@ -0,0 +1,121 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file wait.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_WAIT_H +# define ACE_OS_INCLUDE_SYS_WAIT_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_SYS_WAIT_H) +# include <sys/wait.h> +# endif /* ACE_LACKS_SYS_WAIT_H */ + + + // Wrapping around wait status <wstat> macros for platforms that + // lack them. + + // Evaluates to a non-zero value if status was returned for a child + // process that terminated normally. 0 means status wasn't + // returned. +# if !defined (WIFEXITED) +# define WIFEXITED(stat) 1 +# endif /* WIFEXITED */ + + // If the value of WIFEXITED(stat) is non-zero, this macro evaluates + // to the exit code that the child process exit(3C), or the value + // that the child process returned from main. Peaceful exit code is + // 0. +# if !defined (WEXITSTATUS) +# define WEXITSTATUS(stat) stat +# endif /* WEXITSTATUS */ + + // Evaluates to a non-zero value if status was returned for a child + // process that terminated due to the receipt of a signal. 0 means + // status wasnt returned. +# if !defined (WIFSIGNALED) +# define WIFSIGNALED(stat) 0 +# endif /* WIFSIGNALED */ + + // If the value of WIFSIGNALED(stat) is non-zero, this macro + // evaluates to the number of the signal that caused the + // termination of the child process. +# if !defined (WTERMSIG) +# define WTERMSIG(stat) 0 +# endif /* WTERMSIG */ + +# if !defined (WIFSTOPPED) +# define WIFSTOPPED(stat) 0 +# endif /* WIFSTOPPED */ + +# if !defined (WSTOPSIG) +# define WSTOPSIG(stat) 0 +# endif /* WSTOPSIG */ + +# if !defined (WIFCONTINUED) +# define WIFCONTINUED(stat) 0 +# endif /* WIFCONTINUED */ + +# if !defined (WCOREDUMP) +# define WCOREDUMP(stat) 0 +# endif /* WCOREDUMP */ +# if defined (ACE_HAS_IDTYPE_T) && !defined (ACE_IDTYPE_T_TYPE) +// typedef idtype_t ACE_idtype_t; +# define ACE_IDTYPE_T_TYPE idtype_t +# else +// typedef int ACE_idtype_t; +# define ACE_IDTYPE_T_TYPE int +# endif /* ACE_HAS_IDTYPE_T */ + +# if defined (ACE_HAS_STHREADS) || defined (DIGITAL_UNIX) +# if defined (ACE_LACKS_PRI_T) +// typedef int pri_t; +# if !defined (ACE_PRI_T_TYPE) +# define ACE_PRI_T_TYPE int +# endif /* !ACE_PRI_T_TYPE */ +# endif /* ACE_LACKS_PRI_T */ +# if !defined (ACE_ID_T_TYPE) +// typedef id_t ACE_id_t; +# define ACE_ID_T_TYPE id_t +# endif /* !ACE_ID_T_TYPE */ +# if !defined (ACE_SELF) +# define ACE_SELF P_MYID +# endif /* ACE_SELF */ +# if !defined (ACE_PRI_T_TYPE) +# define ACE_PRI_T_TYPE pri_t +// typedef pri_t ACE_pri_t; +# endif /* !ACE_PRI_T_TYPE */ +# else /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */ +# if !defined (ACE_ID_T_TYPE) +# define ACE_ID_T_TYPE long +// typedef long ACE_id_t; +# endif /* !ACE_ID_T_TYPE */ +# if !defined (ACE_SELF) +# define ACE_SELF (-1) +# endif /* !ACE_SELF */ +# if !defined (ACE_PRI_T_TYPE) +# define ACE_PRI_T_TYPE short +// typedef short ACE_pri_t; +# endif /* !ACE_PRI_T_TYPE */ +# endif /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */ + + +typedef ACE_IDTYPE_T_TYPE ACE_idtype_t; +typedef ACE_ID_T_TYPE ACE_id_t; +typedef ACE_PRI_T_TYPE ACE_pri_t; + +#endif /* ACE_OS_INCLUDE_SYS_WAIT_H */ diff --git a/ace/os_include/termios.h b/ace/os_include/termios.h new file mode 100644 index 00000000000..09a8760deb3 --- /dev/null +++ b/ace/os_include/termios.h @@ -0,0 +1,50 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file termios.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_TERMIOS_H +# define ACE_OS_INCLUDE_TERMIOS_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_TERMIOS_H) +# include /**/ <termios.h> +# endif /* !ACE_LACKS_TERMIOS_H */ + +// This is sorta interesting. but termios.h not sys/termios.h should be correct. +# if defined (ACE_NEEDS_TERMIOS_H) // __QNX__ +# include /**/ <termios.h> +# endif /* ACE_NEEDS_TERMIOS_H) */ + +# if defined (ACE_NEEDS_SYS_MODEM_H) // HPUX +# include /**/ <sys/modem.h> +# endif /* ACE_NEEDS_SYS_MODEM_H */ + +# if !defined (VMIN) +# define ACE_VMIN 4 +# else +# define ACE_VMIN VMIN +# endif /* VMIN */ + +# if !defined (VTIME) +# define ACE_VTIME 5 +# else +# define ACE_VTIME VTIME +# endif /* VTIME */ + +#endif /* ACE_OS_INCLUDE_TERMIOS_H */ diff --git a/ace/os_include/threads.h b/ace/os_include/threads.h new file mode 100644 index 00000000000..8ae7ff19863 --- /dev/null +++ b/ace/os_include/threads.h @@ -0,0 +1,1204 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file threads.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_THREADS_H +# define ACE_OS_INCLUDE_THREADS_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/os_include/sys/types.h" +# include "ace/OS_Export.h" + +# if !defined (ACE_DEFAULT_SYNCH_TYPE) +# define ACE_DEFAULT_SYNCH_TYPE USYNC_THREAD +# endif /* ! ACE_DEFAULT_SYNCH_TYPE */ + +// This is for C++ static methods. +# if defined (VXWORKS) +typedef int ACE_THR_FUNC_INTERNAL_RETURN_TYPE; +typedef FUNCPTR ACE_THR_FUNC_INTERNAL; // where typedef int (*FUNCPTR) (...) +# elif defined (ACE_PSOS) +typedef void (*ACE_THR_FUNC_INTERNAL)(void *); +# else +typedef ACE_THR_FUNC ACE_THR_FUNC_INTERNAL; +# endif /* VXWORKS */ + +extern "C" { +typedef void (*ACE_THR_C_DEST)(void *); +} +typedef void (*ACE_THR_DEST)(void *); + + +// Since Linux doesn't define this, I'm not sure how it should be handled. +// Need to look into it... +# if defined (ACE_HAS_PRIOCNTL) +# include /**/ <sys/priocntl.h> +# endif /* ACE_HAS_PRIOCNTL */ + +# if defined (ACE_HAS_PRIOCNTL) + // Need to #include thread.h before #defining THR_BOUND, etc., + // when building without threads on SunOS 5.x. +# if defined (sun) +# include /**/ <thread.h> +# endif /* sun */ + + // Need to #include these before #defining USYNC_PROCESS on SunOS 5.x. +# include /**/ <sys/rtpriocntl.h> +# include /**/ <sys/tspriocntl.h> +# endif /* ACE_HAS_PRIOCNTL */ + +// This needs to go here *first* to avoid problems with AIX. +# if defined (ACE_HAS_PTHREADS) +extern "C" { +# define ACE_DONT_INCLUDE_ACE_SIGNAL_H +# include "ace/os_include/signal.h" +# undef ACE_DONT_INCLUDE_ACE_SIGNAL_H +# include /**/ <pthread.h> +# if defined (DIGITAL_UNIX) +# define pthread_self __pthread_self +extern "C" pthread_t pthread_self (void); +# endif /* DIGITAL_UNIX */ +} +# if defined (HPUX_10) +// HP-UX 10 needs to see cma_sigwait, and since _CMA_NOWRAPPERS_ is defined, +// this header does not get included from pthreads.h. +# include /**/ <dce/cma_sigwait.h> +# endif /* HPUX_10 */ +# endif /* ACE_HAS_PTHREADS */ + +// 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_STD) /* POSIX.1c threads (pthreads) */ + // ... and 2-parameter asctime_r and ctime_r +# if !defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) && \ + !defined (ACE_HAS_STHREADS) +# define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +# endif +# endif /* ACE_HAS_PTHREADS_STD */ + + +# if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) +# define ACE_TSS_TYPE(T) ACE_TSS< T > +# if defined (ACE_HAS_BROKEN_CONVERSIONS) +# define ACE_TSS_GET(I, T) (*(I)) +# else +# define ACE_TSS_GET(I, T) ((I)->operator T * ()) +# endif /* ACE_HAS_BROKEN_CONVERSIONS */ +# else +# define ACE_TSS_TYPE(T) T +# define ACE_TSS_GET(I, T) (I) +# endif /* ACE_HAS_THREADS && (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATIOND) */ + +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# define ACE_MT(X) X +# if !defined (_REENTRANT) +# define _REENTRANT +# endif /* _REENTRANT */ +# else +# define ACE_MT(X) +# endif /* ACE_MT_SAFE */ + +# if !defined (ACE_DEFAULT_THREAD_PRIORITY) +# define ACE_DEFAULT_THREAD_PRIORITY (-0x7fffffffL - 1L) +# endif /* ACE_DEFAULT_THREAD_PRIORITY */ + + +# if defined (ACE_HAS_POSIX_SEM) +# include /**/ <semaphore.h> +# if !defined (SEM_FAILED) && !defined (ACE_LACKS_NAMED_POSIX_SEM) +# define SEM_FAILED ((sem_t *) -1) +# endif /* !SEM_FAILED */ + +// look familiar? +// looks like this is only used with posix sem +# if !defined (SEM_FAILED) +# define SEM_FAILED ((sem_t *) -1) +# endif /* !SEM_FAILED */ + +typedef struct +{ + sem_t *sema_; + // Pointer to semaphore handle. This is allocated by ACE if we are + // working with an unnamed POSIX semaphore or by the OS if we are + // working with a named POSIX semaphore. + + char *name_; + // Name of the semaphore (if this is non-NULL then this is a named + // POSIX semaphore, else its an unnamed POSIX semaphore). + +# if defined (ACE_LACKS_NAMED_POSIX_SEM) + int new_sema_; + // this->sema_ doesn't always get created dynamically if a platform + // doesn't support named posix semaphores. We use this flag to + // remember if we need to delete <sema_> or not. +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ +} ACE_sema_t; +# endif /* ACE_HAS_POSIX_SEM */ + +# if defined (ACE_HAS_THREADS) + +# if defined (ACE_HAS_STHREADS) +# include /**/ <synch.h> +# include /**/ <thread.h> +# define ACE_SCOPE_PROCESS P_PID +# define ACE_SCOPE_LWP P_LWPID +# define ACE_SCOPE_THREAD (ACE_SCOPE_LWP + 1) +# else +# define ACE_SCOPE_PROCESS 0 +# define ACE_SCOPE_LWP 1 +# define ACE_SCOPE_THREAD 2 +# endif /* ACE_HAS_STHREADS */ + +# if !defined (ACE_HAS_PTHREADS) +# define ACE_SCHED_OTHER 0 +# define ACE_SCHED_FIFO 1 +# define ACE_SCHED_RR 2 +# endif /* ! ACE_HAS_PTHREADS */ + + + +////////////////////////////////////////////////// +////////////////////////////////////////////////// +////////////////////////////////////////////////// +# if defined (ACE_HAS_PTHREADS) +# define ACE_SCHED_OTHER SCHED_OTHER +# define ACE_SCHED_FIFO SCHED_FIFO +# define ACE_SCHED_RR SCHED_RR + + +# if defined(__GLIBC__) +# if !defined (_XOPEN_SOURCE) \ + || (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) < 600) +// pthread_mutex_timedlock() prototype is not visible if _XOPEN_SOURCE +// is not >= 600 (i.e. for XPG6). +extern "C" int pthread_mutex_timedlock (pthread_mutex_t *mutex, + const struct timespec * abstime); +# endif /* _XOPEN_SOURCE && _XOPEN_SOURCE < 600 */ +# endif /* __GLIBC__ */ + + +// Definitions for mapping POSIX pthreads draft 6 into 1003.1c names + +# if defined (ACE_HAS_PTHREADS_DRAFT6) +# define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL +# define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL +# define PTHREAD_CREATE_UNDETACHED 0 +# define PTHREAD_CREATE_DETACHED 1 +# define PTHREAD_CREATE_JOINABLE 0 +# define PTHREAD_EXPLICIT_SCHED 0 +# define PTHREAD_MIN_PRIORITY 0 +# define PTHREAD_MAX_PRIORITY 126 +# endif /* ACE_HAS_PTHREADS_DRAFT6 */ + +// Definitions for THREAD- and PROCESS-LEVEL priorities...some +// implementations define these while others don't. In order to +// further complicate matters, we don't redefine the default (*_DEF) +// values if they've already been defined, which allows individual +// programs to have their own ACE-wide "default". + +// PROCESS-level values +# if defined (_POSIX_PRIORITY_SCHEDULING) && \ + !defined(_UNICOS) && !defined(UNIXWARE_7_1) +# define ACE_PROC_PRI_FIFO_MIN (sched_get_priority_min(SCHED_FIFO)) +# define ACE_PROC_PRI_RR_MIN (sched_get_priority_min(SCHED_RR)) +# if defined (HPUX) + // HP-UX's other is the SCHED_HPUX class, which uses historical + // values that have reverse semantics from POSIX (low value is + // more important priority). To use these in pthreads calls, + // the values need to be converted. The other scheduling classes + // don't need this special treatment. +# define ACE_PROC_PRI_OTHER_MIN \ + (sched_get_priority_min(SCHED_OTHER)) +# else +# define ACE_PROC_PRI_OTHER_MIN (sched_get_priority_min(SCHED_OTHER)) +# endif /* HPUX */ +# else /* UNICOS is missing a sched_get_priority_min() implementation, + SCO too */ +# define ACE_PROC_PRI_FIFO_MIN 0 +# define ACE_PROC_PRI_RR_MIN 0 +# define ACE_PROC_PRI_OTHER_MIN 0 +# endif + +# if defined (_POSIX_PRIORITY_SCHEDULING) && !defined(UNIXWARE_7_1) +# define ACE_PROC_PRI_FIFO_MAX (sched_get_priority_max(SCHED_FIFO)) +# define ACE_PROC_PRI_RR_MAX (sched_get_priority_max(SCHED_RR)) +# if defined (HPUX) +# define ACE_PROC_PRI_OTHER_MAX \ + (sched_get_priority_max(SCHED_OTHER)) +# else +# define ACE_PROC_PRI_OTHER_MAX (sched_get_priority_max(SCHED_OTHER)) +# endif /* HPUX */ +# else /* SCO missing sched_get_priority_max() implementation */ +# define ACE_PROC_PRI_FIFO_MAX 59 +# define ACE_PROC_PRI_RR_MAX 59 +# define ACE_PROC_PRI_OTHER_MAX 59 +# endif + +# if !defined(ACE_PROC_PRI_FIFO_DEF) +# define ACE_PROC_PRI_FIFO_DEF (ACE_PROC_PRI_FIFO_MIN + (ACE_PROC_PRI_FIFO_MAX - ACE_PROC_PRI_FIFO_MIN)/2) +# endif +# if !defined(ACE_PROC_PRI_RR_DEF) +# define ACE_PROC_PRI_RR_DEF (ACE_PROC_PRI_RR_MIN + (ACE_PROC_PRI_RR_MAX - ACE_PROC_PRI_RR_MIN)/2) +# endif +# if !defined(ACE_PROC_PRI_OTHER_DEF) +# define ACE_PROC_PRI_OTHER_DEF (ACE_PROC_PRI_OTHER_MIN + (ACE_PROC_PRI_OTHER_MAX - ACE_PROC_PRI_OTHER_MIN)/2) +# endif + +// THREAD-level values +# if defined(PRI_FIFO_MIN) && defined(PRI_FIFO_MAX) && defined(PRI_RR_MIN) && defined(PRI_RR_MAX) && defined(PRI_OTHER_MIN) && defined(PRI_OTHER_MAX) +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) PRI_FIFO_MIN +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) PRI_FIFO_MAX +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) PRI_RR_MIN +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) PRI_RR_MAX +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) PRI_OTHER_MIN +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) PRI_OTHER_MAX +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# elif defined (AIX) + // AIX's priority range is 1 (low) to 127 (high). There aren't + // any preprocessor macros I can find. PRIORITY_MIN is for + // process priorities, as far as I can see, and does not apply + // to thread priority. The 1 to 127 range is from the + // pthread_attr_setschedparam man page (Steve Huston, 18-May-2001). +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) 1 +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) 127 +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) 1 +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) 127 +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) 1 +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) 127 +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# elif defined (sun) +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) 0 +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) 59 +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) 0 +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) 59 +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) 0 +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) 127 +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# else +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) ACE_PROC_PRI_FIFO_MIN +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) ACE_PROC_PRI_FIFO_MAX +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) ACE_PROC_PRI_RR_MIN +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) ACE_PROC_PRI_RR_MAX +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) ACE_PROC_PRI_OTHER_MIN +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) ACE_PROC_PRI_OTHER_MAX +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# endif +# if !defined(ACE_THR_PRI_FIFO_DEF) +# define ACE_THR_PRI_FIFO_DEF ((ACE_THR_PRI_FIFO_MIN + ACE_THR_PRI_FIFO_MAX)/2) +# endif +# if !defined(ACE_THR_PRI_RR_DEF) +# define ACE_THR_PRI_RR_DEF ((ACE_THR_PRI_RR_MIN + ACE_THR_PRI_RR_MAX)/2) +# endif +# if !defined(ACE_THR_PRI_OTHER_DEF) +# define ACE_THR_PRI_OTHER_DEF ((ACE_THR_PRI_OTHER_MIN + ACE_THR_PRI_OTHER_MAX)/2) +# endif + +// Typedefs to help compatibility with Windows NT and Pthreads. +typedef pthread_t ACE_hthread_t; +typedef pthread_t ACE_thread_t; + +# if defined (ACE_HAS_TSS_EMULATION) + typedef pthread_key_t ACE_OS_thread_key_t; + typedef u_long ACE_thread_key_t; +# else /* ! ACE_HAS_TSS_EMULATION */ + typedef pthread_key_t ACE_thread_key_t; +# endif /* ! ACE_HAS_TSS_EMULATION */ + +# if !defined (ACE_LACKS_COND_T) +typedef pthread_mutex_t ACE_mutex_t; +typedef pthread_cond_t ACE_cond_t; +typedef pthread_condattr_t ACE_condattr_t; +typedef pthread_mutexattr_t ACE_mutexattr_t; +# endif /* ! ACE_LACKS_COND_T */ +typedef pthread_mutex_t ACE_thread_mutex_t; + +# if !defined (PTHREAD_CANCEL_DISABLE) +# define PTHREAD_CANCEL_DISABLE 0 +# endif /* PTHREAD_CANCEL_DISABLE */ + +# if !defined (PTHREAD_CANCEL_ENABLE) +# define PTHREAD_CANCEL_ENABLE 0 +# endif /* PTHREAD_CANCEL_ENABLE */ + +# if !defined (PTHREAD_CANCEL_DEFERRED) +# define PTHREAD_CANCEL_DEFERRED 0 +# endif /* PTHREAD_CANCEL_DEFERRED */ + +# if !defined (PTHREAD_CANCEL_ASYNCHRONOUS) +# define PTHREAD_CANCEL_ASYNCHRONOUS 0 +# endif /* PTHREAD_CANCEL_ASYNCHRONOUS */ + +# define THR_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +# define THR_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE +# define THR_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED +# define THR_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS + +# if !defined (PTHREAD_CREATE_JOINABLE) +# if defined (PTHREAD_CREATE_UNDETACHED) +# define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED +# else +# define PTHREAD_CREATE_JOINABLE 0 +# endif /* PTHREAD_CREATE_UNDETACHED */ +# endif /* PTHREAD_CREATE_JOINABLE */ + +# if !defined (PTHREAD_CREATE_DETACHED) +# define PTHREAD_CREATE_DETACHED 1 +# endif /* PTHREAD_CREATE_DETACHED */ + +# if !defined (PTHREAD_PROCESS_PRIVATE) && !defined (ACE_HAS_PTHREAD_PROCESS_ENUM) +# if defined (PTHREAD_MUTEXTYPE_FAST) +# define PTHREAD_PROCESS_PRIVATE PTHREAD_MUTEXTYPE_FAST +# else +# define PTHREAD_PROCESS_PRIVATE 0 +# endif /* PTHREAD_MUTEXTYPE_FAST */ +# endif /* PTHREAD_PROCESS_PRIVATE */ + +# if !defined (PTHREAD_PROCESS_SHARED) && !defined (ACE_HAS_PTHREAD_PROCESS_ENUM) +# if defined (PTHREAD_MUTEXTYPE_FAST) +# define PTHREAD_PROCESS_SHARED PTHREAD_MUTEXTYPE_FAST +# else +# define PTHREAD_PROCESS_SHARED 1 +# endif /* PTHREAD_MUTEXTYPE_FAST */ +# endif /* PTHREAD_PROCESS_SHARED */ + +# if defined (ACE_HAS_PTHREADS_DRAFT4) +# if defined (PTHREAD_PROCESS_PRIVATE) +# if !defined (USYNC_THREAD) +# define USYNC_THREAD PTHREAD_PROCESS_PRIVATE +# endif /* ! USYNC_THREAD */ +# else +# if !defined (USYNC_THREAD) +# define USYNC_THREAD MUTEX_NONRECURSIVE_NP +# endif /* ! USYNC_THREAD */ +# endif /* PTHREAD_PROCESS_PRIVATE */ + +# if defined (PTHREAD_PROCESS_SHARED) +# if !defined (USYNC_PROCESS) +# define USYNC_PROCESS PTHREAD_PROCESS_SHARED +# endif /* ! USYNC_PROCESS */ +# else +# if !defined (USYNC_PROCESS) +# define USYNC_PROCESS MUTEX_NONRECURSIVE_NP +# endif /* ! USYNC_PROCESS */ +# endif /* PTHREAD_PROCESS_SHARED */ +# elif !defined (ACE_HAS_STHREADS) +# if !defined (USYNC_THREAD) +# define USYNC_THREAD PTHREAD_PROCESS_PRIVATE +# endif /* ! USYNC_THREAD */ +# if !defined (USYNC_PROCESS) +# define USYNC_PROCESS PTHREAD_PROCESS_SHARED +# endif /* ! USYNC_PROCESS */ +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + +/* MM-Graz: prevent warnings */ +# undef THR_BOUND +# undef THR_NEW_LWP +# undef THR_DETACHED +# undef THR_SUSPENDED +# undef THR_DAEMON + +# define THR_BOUND 0x00000001 +# if defined (CHORUS) +# define THR_NEW_LWP 0x00000000 +# else +# define THR_NEW_LWP 0x00000002 +# endif /* CHORUS */ +# define THR_DETACHED 0x00000040 +# define THR_SUSPENDED 0x00000080 +# define THR_DAEMON 0x00000100 +# define THR_JOINABLE 0x00010000 +# define THR_SCHED_FIFO 0x00020000 +# define THR_SCHED_RR 0x00040000 +# define THR_SCHED_DEFAULT 0x00080000 + +# if defined (ACE_HAS_IRIX62_THREADS) +# define THR_SCOPE_SYSTEM 0x00100000 +# else +# define THR_SCOPE_SYSTEM THR_BOUND +# endif /*ACE_HAS_IRIX62_THREADS*/ + +# define THR_SCOPE_PROCESS 0x00200000 +# define THR_INHERIT_SCHED 0x00400000 +# define THR_EXPLICIT_SCHED 0x00800000 +# define THR_SCHED_IO 0x01000000 + +// still in pthreads +//////////////////////////////////////////////// +# if !defined (ACE_HAS_STHREADS) +# if !defined (ACE_HAS_POSIX_SEM) +/** + * @class ACE_sema_t + * + * @brief This is used to implement semaphores for platforms that support + * POSIX pthreads, but do *not* support POSIX semaphores, i.e., + * it's a different type than the POSIX <sem_t>. + */ + +class ACE_OS; + +// this is used by linux +class ACE_OS_Export ACE_sema_t +{ +friend class ACE_OS; +protected: + /// Serialize access to internal state. + ACE_mutex_t lock_; + + /// Block until there are no waiters. + ACE_cond_t count_nonzero_; + + /// Count of the semaphore. + u_long count_; + + /// Number of threads that have called <ACE_OS::sema_wait>. + u_long waiters_; +}; +# endif /* !ACE_HAS_POSIX_SEM */ + +# if defined (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) +// looks like sun with pthreads and sthreads + + // If we are on Solaris we can just reuse the existing + // implementations of these synchronization types. +# if !defined (ACE_LACKS_RWLOCK_T) +# include /**/ <synch.h> +typedef rwlock_t ACE_rwlock_t; +# endif /* !ACE_LACKS_RWLOCK_T */ +# include /**/ <thread.h> +# endif /* (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) */ +# else /* !ACE_HAS_STHREADS */ +//sthreads w/ posix threads +# if !defined (ACE_HAS_POSIX_SEM) +// must be the sun sema_t +typedef sema_t ACE_sema_t; +# endif /* !ACE_HAS_POSIX_SEM */ +# endif /* !ACE_HAS_STHREADS */ + + + +////////////////////////////////////////// +////////////////////////////////////////// +////////////////////////////////////////// +# elif defined (ACE_HAS_STHREADS) +// Solaris threads, without PTHREADS. +// Typedefs to help compatibility with Windows NT and Pthreads. +typedef thread_t ACE_thread_t; +typedef thread_key_t ACE_thread_key_t; +typedef mutex_t ACE_mutex_t; +# if !defined (ACE_LACKS_RWLOCK_T) +typedef rwlock_t ACE_rwlock_t; +# endif /* !ACE_LACKS_RWLOCK_T */ +# if !defined (ACE_HAS_POSIX_SEM) +typedef sema_t ACE_sema_t; +# endif /* !ACE_HAS_POSIX_SEM */ + +typedef cond_t ACE_cond_t; +struct ACE_OS_Export ACE_condattr_t +{ + int type; +}; +struct ACE_OS_Export ACE_mutexattr_t +{ + int type; +}; +typedef ACE_thread_t ACE_hthread_t; +typedef ACE_mutex_t ACE_thread_mutex_t; + +# define THR_CANCEL_DISABLE 0 +# define THR_CANCEL_ENABLE 0 +# define THR_CANCEL_DEFERRED 0 +# define THR_CANCEL_ASYNCHRONOUS 0 +# define THR_JOINABLE 0 +# define THR_SCHED_FIFO 0 +# define THR_SCHED_RR 0 +# define THR_SCHED_DEFAULT 0 + +# elif defined (ACE_PSOS) + +// Some versions of pSOS provide native mutex support. For others, +// implement ACE_thread_mutex_t and ACE_mutex_t using pSOS semaphores. +// Either way, the types are all u_longs. +typedef u_long ACE_mutex_t; +typedef u_long ACE_thread_mutex_t; +typedef u_long ACE_thread_t; +typedef u_long ACE_hthread_t; + +# if defined (ACE_PSOS_HAS_COND_T) +typedef u_long ACE_cond_t; +typedef u_long ACE_condattr_t; +struct ACE_OS_Export ACE_mutexattr_t +{ + int type; +}; +# endif /* ACE_PSOS_HAS_COND_T */ + + +// TCB registers 0-7 are for application use +# define PSOS_TASK_REG_TSS 0 +# define PSOS_TASK_REG_MAX 7 + +# define PSOS_TASK_MIN_PRIORITY 1 +# define PSOS_TASK_MAX_PRIORITY 239 + +// Key type: the ACE TSS emulation requires the key type be unsigned, +// for efficiency. Current POSIX and Solaris TSS implementations also +// use unsigned int, so the ACE TSS emulation is compatible with them. +// Native pSOS TSD, where available, uses unsigned long as the key type. +# if defined (ACE_PSOS_HAS_TSS) +typedef u_long ACE_thread_key_t; +# else +typedef u_int ACE_thread_key_t; +# endif /* ACE_PSOS_HAS_TSS */ + +# define THR_CANCEL_DISABLE 0 /* thread can never be cancelled */ +# define THR_CANCEL_ENABLE 0 /* thread can be cancelled */ +# define THR_CANCEL_DEFERRED 0 /* cancellation deferred to cancellation point */ +# define THR_CANCEL_ASYNCHRONOUS 0 /* cancellation occurs immediately */ + +# define THR_BOUND 0 +# define THR_NEW_LWP 0 +# define THR_DETACHED 0 +# define THR_SUSPENDED 0 +# define THR_DAEMON 0 +# define THR_JOINABLE 0 + +# define THR_SCHED_FIFO 0 +# define THR_SCHED_RR 0 +# define THR_SCHED_DEFAULT 0 +# define USYNC_THREAD T_LOCAL +# define USYNC_PROCESS T_GLOBAL + +/* from psos.h */ +/* #define T_NOPREEMPT 0x00000001 Not preemptible bit */ +/* #define T_PREEMPT 0x00000000 Preemptible */ +/* #define T_TSLICE 0x00000002 Time-slicing enabled bit */ +/* #define T_NOTSLICE 0x00000000 No Time-slicing */ +/* #define T_NOASR 0x00000004 ASRs disabled bit */ +/* #define T_ASR 0x00000000 ASRs enabled */ + +/* #define SM_GLOBAL 0x00000001 1 = Global */ +/* #define SM_LOCAL 0x00000000 0 = Local */ +/* #define SM_PRIOR 0x00000002 Queue by priority */ +/* #define SM_FIFO 0x00000000 Queue by FIFO order */ + +/* #define T_NOFPU 0x00000000 Not using FPU */ +/* #define T_FPU 0x00000002 Using FPU bit */ + +# elif defined (VXWORKS) +// For mutex implementation using mutual-exclusion semaphores (which +// can be taken recursively). +# include /**/ <semLib.h> + +# include /**/ <envLib.h> +# include /**/ <hostLib.h> +# include /**/ <ioLib.h> +# include /**/ <remLib.h> +# include /**/ <selectLib.h> +# include /**/ <sigLib.h> +# include /**/ <sockLib.h> +# include /**/ <sysLib.h> +# include /**/ <taskLib.h> +# include /**/ <taskHookLib.h> + +extern "C" +struct sockaddr_un { + short sun_family; // AF_UNIX. + char sun_path[108]; // path name. +}; + +//# define MAXPATHLEN 1024 +//# define MAXNAMLEN 255 +# define NSIG (_NSIGS + 1) + +// task options: the other options are either obsolete, internal, or for +// Fortran or Ada support +# define VX_UNBREAKABLE 0x0002 /* breakpoints ignored */ +# define VX_FP_TASK 0x0008 /* floating point coprocessor */ +# define VX_PRIVATE_ENV 0x0080 /* private environment support */ +# define VX_NO_STACK_FILL 0x0100 /* do not stack fill for + checkstack () */ + +# define THR_CANCEL_DISABLE 0 +# define THR_CANCEL_ENABLE 0 +# define THR_CANCEL_DEFERRED 0 +# define THR_CANCEL_ASYNCHRONOUS 0 +# define THR_BOUND 0 +# define THR_NEW_LWP 0 +# define THR_DETACHED 0 +# define THR_SUSPENDED 0 +# define THR_DAEMON 0 +# define THR_JOINABLE 0 +# define THR_SCHED_FIFO 0 +# define THR_SCHED_RR 0 +# define THR_SCHED_DEFAULT 0 +# define THR_INHERIT_SCHED 0 +# define THR_EXPLICIT_SCHED 0 +# define THR_SCHED_IO 0 +# define THR_SCOPE_SYSTEM 0 +# define THR_SCOPE_PROCESS 0 +# define USYNC_THREAD 0 +# define USYNC_PROCESS 1 /* It's all global on VxWorks + (without MMU option). */ + +# if !defined (ACE_DEFAULT_SYNCH_TYPE) + // Types include these options: SEM_Q_PRIORITY, SEM_Q_FIFO, + // SEM_DELETE_SAFE, and SEM_INVERSION_SAFE. SEM_Q_FIFO is + // used as the default because that is VxWorks' default. +# define ACE_DEFAULT_SYNCH_TYPE SEM_Q_FIFO +# endif /* ! ACE_DEFAULT_SYNCH_TYPE */ + +typedef SEM_ID ACE_mutex_t; +// Implement ACE_thread_mutex_t with ACE_mutex_t because there's just +// one process . . . +typedef ACE_mutex_t ACE_thread_mutex_t; +# if !defined (ACE_HAS_POSIX_SEM) +// Use VxWorks semaphores, wrapped ... +typedef struct +{ + SEM_ID sema_; + // Semaphore handle. This is allocated by VxWorks. + + char *name_; + // Name of the semaphore: always NULL with VxWorks. +} ACE_sema_t; +# endif /* !ACE_HAS_POSIX_SEM */ + +typedef char * ACE_thread_t; +typedef int ACE_hthread_t; +// Key type: the ACE TSS emulation requires the key type be unsigned, +// for efficiency. (Current POSIX and Solaris TSS implementations also +// use u_int, so the ACE TSS emulation is compatible with them.) +typedef u_int ACE_thread_key_t; + + // Marker for ACE_Thread_Manager to indicate that it allocated + // an ACE_thread_t. It is placed at the beginning of the ID. +# define ACE_THR_ID_ALLOCATED '\022' + + +//////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////// +# elif defined (ACE_HAS_WTHREADS) + +typedef DWORD ACE_thread_t; +typedef HANDLE ACE_hthread_t; + +//# define ACE_INVALID_PID ((pid_t) -1) +# if defined (ACE_HAS_TSS_EMULATION) + typedef DWORD ACE_OS_thread_key_t; + typedef u_int ACE_thread_key_t; +# else /* ! ACE_HAS_TSS_EMULATION */ + typedef DWORD ACE_thread_key_t; +# endif /* ! ACE_HAS_TSS_EMULATION */ + +typedef CRITICAL_SECTION ACE_thread_mutex_t; + +typedef struct +{ + int type_; // Either USYNC_THREAD or USYNC_PROCESS + union + { + HANDLE proc_mutex_; + CRITICAL_SECTION thr_mutex_; + }; +} ACE_mutex_t; + +// Wrapper for NT Events. +typedef HANDLE ACE_event_t; +#define ACE_EVENT_T_DEFINED + +//@@ ACE_USES_WINCE_SEMA_SIMULATION is used to debug +// semaphore simulation on WinNT. It should be +// changed to ACE_USES_HAS_WINCE at some later point. +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) +typedef HANDLE ACE_sema_t; +# else +/** + * @class ACE_sema_t + * + * @brief Semaphore simulation for Windows CE. + */ +class ACE_OS_Export ACE_sema_t +{ +public: + /// Serializes access to <count_>. + ACE_thread_mutex_t lock_; + + /// This event is signaled whenever the count becomes non-zero. + ACE_event_t count_nonzero_; + + /// Current count of the semaphore. + u_int count_; +}; + +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ + +// These need to be different values, neither of which can be 0... +# define USYNC_THREAD 1 +# define USYNC_PROCESS 2 + +# define THR_CANCEL_DISABLE 0 +# define THR_CANCEL_ENABLE 0 +# define THR_CANCEL_DEFERRED 0 +# define THR_CANCEL_ASYNCHRONOUS 0 +# define THR_DETACHED 0x02000000 /* ignore in most places */ +# define THR_BOUND 0 /* ignore in most places */ +# define THR_NEW_LWP 0 /* ignore in most places */ +# define THR_DAEMON 0 /* ignore in most places */ +# define THR_JOINABLE 0 /* ignore in most places */ +# define THR_SUSPENDED CREATE_SUSPENDED +# define THR_USE_AFX 0x01000000 +# define THR_SCHED_FIFO 0 +# define THR_SCHED_RR 0 +# define THR_SCHED_DEFAULT 0 +# define THR_SCOPE_PROCESS 0 +# define THR_SCOPE_SYSTEM 0 +# endif /* ACE_HAS_PTHREADS / STHREADS / PSOS / VXWORKS / WTHREADS */ + +# if defined (ACE_LACKS_COND_T) && defined (ACE_WIN32) +/** + * @class ACE_cond_t + * + * @brief This structure is used to implement condition variables on + * platforms that lack it natively, such as VxWorks, pSoS, and + * Win32. + * + * At the current time, this stuff only works for threads + * within the same process. + */ +class ACE_OS_Export ACE_cond_t +{ +public: + friend class ACE_OS; + + /// Returns the number of waiters. + long waiters (void) const; + +protected: + /// Number of waiting threads. + long waiters_; + + /// Serialize access to the waiters count. + ACE_thread_mutex_t waiters_lock_; + + /// Queue up threads waiting for the condition to become signaled. + ACE_sema_t sema_; + +# if defined (VXWORKS) || defined (ACE_PSOS) + /** + * A semaphore used by the broadcast/signal thread to wait for all + * the waiting thread(s) to wake up and be released from the + * semaphore. + */ + ACE_sema_t waiters_done_; +# elif defined (ACE_WIN32) + /** + * An auto reset event used by the broadcast/signal thread to wait + * for the waiting thread(s) to wake up and get a chance at the + * semaphore. + */ + HANDLE waiters_done_; +# else +# error "Please implement this feature or check your config.h file!" +# endif /* VXWORKS || ACE_PSOS */ + + /// Keeps track of whether we were broadcasting or just signaling. + size_t was_broadcast_; +}; + +struct ACE_OS_Export ACE_condattr_t +{ + int type; +}; + +struct ACE_OS_Export ACE_mutexattr_t +{ + int type; +}; + +# endif /* ACE_LACKS_COND_T */ + +# if defined (ACE_LACKS_RWLOCK_T) && !defined (ACE_HAS_PTHREADS_UNIX98_EXT) + +/** + * @class ACE_rwlock_t + * + * @brief This is used to implement readers/writer locks on NT, + * VxWorks, and POSIX pthreads. + * + * At the current time, this stuff only works for threads + * within the same process. + */ +struct ACE_OS_Export ACE_rwlock_t +{ +protected: + friend class ACE_OS; + + ACE_mutex_t lock_; + // Serialize access to internal state. + + ACE_cond_t waiting_readers_; + // Reader threads waiting to acquire the lock. + + int num_waiting_readers_; + // Number of waiting readers. + + ACE_cond_t waiting_writers_; + // Writer threads waiting to acquire the lock. + + int num_waiting_writers_; + // Number of waiting writers. + + int ref_count_; + // Value is -1 if writer has the lock, else this keeps track of the + // number of readers holding the lock. + + int important_writer_; + // indicate that a reader is trying to upgrade + + ACE_cond_t waiting_important_writer_; + // condition for the upgrading reader +}; +# elif defined (ACE_HAS_PTHREADS_UNIX98_EXT) +typedef pthread_rwlock_t ACE_rwlock_t; +# elif defined (ACE_HAS_STHREADS) +# include /**/ <synch.h> +typedef rwlock_t ACE_rwlock_t; +# endif /* ACE_LACKS_RWLOCK_T */ + +// Define some default thread priorities on all threaded platforms, if +// not defined above or in the individual platform config file. +// ACE_THR_PRI_FIFO_DEF should be used by applications for default +// real-time thread priority. ACE_THR_PRI_OTHER_DEF should be used +// for non-real-time priority. +# if !defined(ACE_THR_PRI_FIFO_DEF) +# if defined (ACE_WTHREADS) + // It would be more in spirit to use THREAD_PRIORITY_NORMAL. But, + // using THREAD_PRIORITY_ABOVE_NORMAL should give preference to the + // threads in this process, even if the process is not in the + // REALTIME_PRIORITY_CLASS. +# define ACE_THR_PRI_FIFO_DEF THREAD_PRIORITY_ABOVE_NORMAL +# else /* ! ACE_WTHREADS */ +# define ACE_THR_PRI_FIFO_DEF 0 +# endif /* ! ACE_WTHREADS */ +# endif /* ! ACE_THR_PRI_FIFO_DEF */ + +# if !defined(ACE_THR_PRI_OTHER_DEF) +# if defined (ACE_WTHREADS) + // It would be more in spirit to use THREAD_PRIORITY_NORMAL. But, + // using THREAD_PRIORITY_ABOVE_NORMAL should give preference to the + // threads in this process, even if the process is not in the + // REALTIME_PRIORITY_CLASS. +# define ACE_THR_PRI_OTHER_DEF THREAD_PRIORITY_NORMAL +# else /* ! ACE_WTHREADS */ +# define ACE_THR_PRI_OTHER_DEF 0 +# endif /* ! ACE_WTHREADS */ +# endif /* ! ACE_THR_PRI_OTHER_DEF */ + +# if defined (ACE_HAS_RECURSIVE_MUTEXES) +typedef ACE_thread_mutex_t ACE_recursive_thread_mutex_t; +# else +/** + * @class ACE_recursive_thread_mutex_t + * + * @brief Implement a thin C++ wrapper that allows nested acquisition + * and release of a mutex that occurs in the same thread. + * + * This implementation is based on an algorithm sketched by Dave + * Butenhof <butenhof@zko.dec.com>. Naturally, I take the + * credit for any mistakes ;-) + */ +class ACE_recursive_thread_mutex_t +{ +public: + /// Guards the state of the nesting level and thread id. + ACE_thread_mutex_t nesting_mutex_; + + /// This condition variable suspends other waiting threads until the + /// mutex is available. + ACE_cond_t lock_available_; + + /// Current nesting level of the recursion. + int nesting_level_; + + /// Current owner of the lock. + ACE_thread_t owner_id_; +}; +# endif /* ACE_WIN32 */ + +#else /* !ACE_HAS_THREADS, i.e., the OS/platform doesn't support threading. */ + +// Give these things some reasonable value... +# define ACE_SCOPE_PROCESS 0 +# define ACE_SCOPE_LWP 1 +# define ACE_SCOPE_THREAD 2 +# define ACE_SCHED_OTHER 0 +# define ACE_SCHED_FIFO 1 +# define ACE_SCHED_RR 2 +# if !defined (THR_CANCEL_DISABLE) +# define THR_CANCEL_DISABLE 0 +# endif /* ! THR_CANCEL_DISABLE */ +# if !defined (THR_CANCEL_ENABLE) +# define THR_CANCEL_ENABLE 0 +# endif /* ! THR_CANCEL_ENABLE */ +# if !defined (THR_CANCEL_DEFERRED) +# define THR_CANCEL_DEFERRED 0 +# endif /* ! THR_CANCEL_DEFERRED */ +# if !defined (THR_CANCEL_ASYNCHRONOUS) +# define THR_CANCEL_ASYNCHRONOUS 0 +# endif /* ! THR_CANCEL_ASYNCHRONOUS */ +# if !defined (THR_JOINABLE) +# define THR_JOINABLE 0 /* ignore in most places */ +# endif /* ! THR_JOINABLE */ +# if !defined (THR_DETACHED) +# define THR_DETACHED 0 /* ignore in most places */ +# endif /* ! THR_DETACHED */ +# if !defined (THR_DAEMON) +# define THR_DAEMON 0 /* ignore in most places */ +# endif /* ! THR_DAEMON */ +# if !defined (THR_BOUND) +# define THR_BOUND 0 /* ignore in most places */ +# endif /* ! THR_BOUND */ +# if !defined (THR_NEW_LWP) +# define THR_NEW_LWP 0 /* ignore in most places */ +# endif /* ! THR_NEW_LWP */ +# if !defined (THR_SUSPENDED) +# define THR_SUSPENDED 0 /* ignore in most places */ +# endif /* ! THR_SUSPENDED */ +# if !defined (THR_SCHED_FIFO) +# define THR_SCHED_FIFO 0 +# endif /* ! THR_SCHED_FIFO */ +# if !defined (THR_SCHED_RR) +# define THR_SCHED_RR 0 +# endif /* ! THR_SCHED_RR */ +# if !defined (THR_SCHED_DEFAULT) +# define THR_SCHED_DEFAULT 0 +# endif /* ! THR_SCHED_DEFAULT */ +# if !defined (USYNC_THREAD) +# define USYNC_THREAD 0 +# endif /* ! USYNC_THREAD */ +# if !defined (USYNC_PROCESS) +# define USYNC_PROCESS 0 +# endif /* ! USYNC_PROCESS */ +# if !defined (THR_SCOPE_PROCESS) +# define THR_SCOPE_PROCESS 0 +# endif /* ! THR_SCOPE_PROCESS */ +# if !defined (THR_SCOPE_SYSTEM) +# define THR_SCOPE_SYSTEM 0 +# endif /* ! THR_SCOPE_SYSTEM */ + +// These are dummies needed for class OS.h +typedef int ACE_cond_t; +struct ACE_OS_Export ACE_condattr_t +{ + int type; +}; +struct ACE_OS_Export ACE_mutexattr_t +{ + int type; +}; +typedef int ACE_mutex_t; +typedef int ACE_thread_mutex_t; +typedef int ACE_recursive_thread_mutex_t; +# if !defined (ACE_HAS_POSIX_SEM) && !defined (ACE_PSOS) +typedef int ACE_sema_t; +# endif /* !ACE_HAS_POSIX_SEM && !ACE_PSOS */ +typedef int ACE_rwlock_t; +typedef int ACE_thread_t; +typedef int ACE_hthread_t; +typedef u_int ACE_thread_key_t; + +// Ensure that ACE_THR_PRI_FIFO_DEF and ACE_THR_PRI_OTHER_DEF are +// defined on non-threaded platforms, to support application source +// code compatibility. ACE_THR_PRI_FIFO_DEF should be used by +// applications for default real-time thread priority. +// ACE_THR_PRI_OTHER_DEF should be used for non-real-time priority. +# if !defined(ACE_THR_PRI_FIFO_DEF) +# define ACE_THR_PRI_FIFO_DEF 0 +# endif /* ! ACE_THR_PRI_FIFO_DEF */ +# if !defined(ACE_THR_PRI_OTHER_DEF) +# define ACE_THR_PRI_OTHER_DEF 0 +# endif /* ! ACE_THR_PRI_OTHER_DEF */ + +#endif /* ACE_HAS_THREADS */ + + + + +#if !defined (ACE_EVENT_T_DEFINED) +// Wrapper for NT events on UNIX. +class ACE_OS_Export ACE_event_t +{ + friend class ACE_OS; +protected: + /// Protect critical section. + ACE_mutex_t lock_; + + /// Keeps track of waiters. + ACE_cond_t condition_; + + /// Specifies if this is an auto- or manual-reset event. + int manual_reset_; + + /// "True" if signaled. + int is_signaled_; + + /// Number of waiting threads. + u_long waiting_threads_; +}; +#define ACE_EVENT_T_DEFINED +#endif /* ACE_EVENT_T_DEFINED */ + +/** + * @class ACE_Thread_ID + * + * @brief Defines a platform-independent thread ID. + */ +class ACE_OS_Export ACE_Thread_ID +{ +public: + // = Initialization method. + ACE_Thread_ID (ACE_thread_t, ACE_hthread_t); + ACE_Thread_ID (const ACE_Thread_ID &id); + + // = Set/Get the Thread ID. + ACE_thread_t id (void); + void id (ACE_thread_t); + + // = Set/Get the Thread handle. + ACE_hthread_t handle (void); + void handle (ACE_hthread_t); + + // != Comparison operator. + int operator== (const ACE_Thread_ID &) const; + int operator!= (const ACE_Thread_ID &) const; + +private: + /// Identify the thread. + ACE_thread_t thread_id_; + + /// Handle to the thread (typically used to "wait" on Win32). + ACE_hthread_t thread_handle_; +}; + + + + + +// mit pthread stuff +#if defined (ACE_HAS_RECV_TIMEDWAIT) && defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) +extern "C" ssize_t recv_timedwait (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct timespec *timeout); +extern "C" ssize_t read_timedwait (ACE_HANDLE handle, + char *buf, + size_t n, + struct timespec *timeout); +extern "C" ssize_t recvmsg_timedwait (ACE_HANDLE handle, + struct msghdr *msg, + int flags, + struct timespec *timeout); +extern "C" ssize_t recvfrom_timedwait (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct sockaddr *addr, + int + *addrlen, + struct timespec *timeout); +extern "C" ssize_t readv_timedwait (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + struct timespec* timeout); +extern "C" ssize_t send_timedwait (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + struct timespec *timeout); +extern "C" ssize_t write_timedwait (ACE_HANDLE handle, + const void *buf, + size_t n, + struct timespec *timeout); +extern "C" ssize_t sendmsg_timedwait (ACE_HANDLE handle, + ACE_SENDMSG_TYPE *msg, + int flags, + struct timespec *timeout); +extern "C" ssize_t sendto_timedwait (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + const struct sockaddr *addr, + int addrlen, + struct timespec *timeout); +extern "C" ssize_t writev_timedwait (ACE_HANDLE handle, + ACE_WRITEV_TYPE *iov, + int iovcnt, + struct timespec *timeout); +#endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + + +#endif /* ACE_OS_INCLUDE_THREADS_H */ diff --git a/ace/os_include/time.h b/ace/os_include/time.h new file mode 100644 index 00000000000..c3e36288c58 --- /dev/null +++ b/ace/os_include/time.h @@ -0,0 +1,65 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file time.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_TIME_H +# define ACE_OS_INCLUDE_TIME_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (ACE_LACKS_TIME_H) +# include /**/ <time.h> +# endif /* ACE_LACKS_TIME_H */ + +# if defined (ACE_NEEDS_SYS_TIMES_H) + include /**/ <sys/times.h> +# endif /* ACE_NEEDS_SYS_TIMES_H) */ + +# if defined (ACE_NEEDS_SYS_TIME_H) +# include /**/ <sys/time.h> +# endif /* ACE_NEEDS_SYS_TIME_H */ + +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) +using std::time_t; +using std::tm; +# if defined (ACE_WIN32) +using std::_timezone; +# else +using std::timezone; +# endif +using std::difftime; +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ + +# if !defined (ACE_HAS_CLOCK_GETTIME) && !(defined (_CLOCKID_T_) || 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_ */ + +// does this belong here? +# if defined (ACE_HAS_BROKEN_CTIME) +# undef ctime +# endif /* ACE_HAS_BROKEN_CTIME */ + +# if defined (ACE_LACKS_STRPTIME_PROTOTYPE) && !defined (_XOPEN_SOURCE) +extern "C" char *strptime (const char *s, const char *fmt, struct tm *tp); +# endif /* ACE_LACKS_STRPTIME_PROTOTYPE */ + +#endif /* ACE_OS_INCLUDE_TIME_H */ + diff --git a/ace/os_include/unistd.h b/ace/os_include/unistd.h new file mode 100644 index 00000000000..5d1cbb3d6df --- /dev/null +++ b/ace/os_include/unistd.h @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file unistd.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_ACE_UNISTD_H +# define ACE_ACE_UNISTD_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/os_include/sys/types.h" +// got to move the llseek stuff out of basic_types.h... +# include "ace/Basic_Types.h" + +# if !defined (ACE_LACKS_UNISTD_H) +# include /**/ <unistd.h> +# endif /* ACE_LACKS_UNISTD_H */ + +# if defined (ACE_LACKS_GETPGID_PROTOTYPE) && \ + !defined (_XOPEN_SOURCE) && !defined (_XOPEN_SOURCE_EXTENDED) +extern "C" pid_t getpgid (pid_t pid); +# endif /* ACE_LACKS_GETPGID_PROTOTYPE && + !_XOPEN_SOURCE && !_XOPEN_SOURCE_EXTENDED */ + + +# if !defined (_LARGEFILE64_SOURCE) +# if defined (ACE_LACKS_LSEEK64_PROTOTYPE) && \ + defined (ACE_LACKS_LLSEEK_PROTOTYPE) +# error Define either ACE_LACKS_LSEEK64_PROTOTYPE or ACE_LACKS_LLSEEK_PROTOTYPE, not both! +# elif defined (ACE_LACKS_LSEEK64_PROTOTYPE) +extern "C" ACE_LOFF_T lseek64 (int fd, ACE_LOFF_T offset, int whence); +# elif defined (ACE_LACKS_LLSEEK_PROTOTYPE) +extern "C" ACE_LOFF_T llseek (int fd, ACE_LOFF_T offset, int whence); +# endif +# endif /* _LARGEFILE64_SOURCE */ + +# if defined (ACE_LACKS_PREAD_PROTOTYPE) && (_XOPEN_SOURCE - 0) < 500 +// _XOPEN_SOURCE == 500 Single Unix conformance +// It seems that _XOPEN_SOURCE == 500 means that the prototypes are +// already defined in the system headers. +extern "C" ssize_t pread (int fd, + void *buf, + size_t nbytes, + off_t offset); + +extern "C" ssize_t pwrite (int fd, + const void *buf, + size_t n, + off_t offset); +# endif /* ACE_LACKS_PREAD_PROTOTYPE && (_XOPEN_SOURCE - 0) < 500 */ + + +# if defined (ACE_LACKS_UALARM_PROTOTYPE) +extern "C" u_int ualarm (u_int usecs, u_int interval); +# endif /* ACE_LACKS_UALARM_PROTOTYPE */ + +# if defined (m88k) && !defined (RUSAGE_SELF) +# define RUSAGE_SELF 1 +# endif /* m88k */ + +# if defined (ACE_LACKS_SYSCALL) +extern "C" int syscall (int, ACE_HANDLE, struct rusage *); +# endif /* ACE_LACKS_SYSCALL */ + +# if !defined (R_OK) +# define R_OK 04 /* Test for Read permission. */ +# endif /* R_OK */ + +# if !defined (W_OK) +# define W_OK 02 /* Test for Write permission. */ +# endif /* W_OK */ + +# if !defined (X_OK) +# define X_OK 01 /* Test for eXecute permission. */ +# endif /* X_OK */ + +# if !defined (F_OK) +# define F_OK 0 /* Test for existence of File. */ +# endif /* F_OK */ + + +# if !defined (_SC_TIMER_MAX) +# define _SC_TIMER_MAX 44 +# endif /* _SC_TIMER_MAX */ + + +// Default number of <ACE_Event_Handler>s supported by +// <ACE_Timer_Heap>. +# if !defined (ACE_DEFAULT_TIMERS) +# define ACE_DEFAULT_TIMERS _SC_TIMER_MAX +# endif /* ACE_DEFAULT_TIMERS */ + +#endif /* ACE_OS_INCLUDE_UNISTD_H */ diff --git a/ace/os_include/utime.h b/ace/os_include/utime.h new file mode 100644 index 00000000000..6e33ec0a26f --- /dev/null +++ b/ace/os_include/utime.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file utime.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_UTIME_H +# define ACE_OS_INCLUDE_UTIME_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Only include if platform/compiler provide the header. +# if !defined (ACE_LACKS_UTIME_H) +# include /**/ <utime.h> +# endif /* !ACE_LACKS_UTIME_H */ + +#endif /* ACE_OS_INCLUDE_UTIME_H */ diff --git a/ace/os_include/vxworks.h b/ace/os_include/vxworks.h new file mode 100644 index 00000000000..9fece194ef8 --- /dev/null +++ b/ace/os_include/vxworks.h @@ -0,0 +1,117 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file vxworks.h + * + * $Id$ + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author etc + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_VXWORKS_H +# define ACE_OS_INCLUDE_VXWORKS_H +# include "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// this one is still broken! ;-( + + + +# if defined (VXWORKS) +// For mutex implementation using mutual-exclusion semaphores (which +// can be taken recursively). +# include /**/ <semLib.h> + +# include /**/ <envLib.h> +# include /**/ <hostLib.h> +# include /**/ <ioLib.h> +# include /**/ <remLib.h> +# include /**/ <selectLib.h> +# include /**/ <sigLib.h> +# include /**/ <sockLib.h> +# include /**/ <sysLib.h> +# include /**/ <taskLib.h> +# include /**/ <taskHookLib.h> + +extern "C" +struct sockaddr_un { + short sun_family; // AF_UNIX. + char sun_path[108]; // path name. +}; + +# define MAXPATHLEN 1024 +# define MAXNAMLEN 255 +# define NSIG (_NSIGS + 1) + +// task options: the other options are either obsolete, internal, or for +// Fortran or Ada support +# define VX_UNBREAKABLE 0x0002 /* breakpoints ignored */ +# define VX_FP_TASK 0x0008 /* floating point coprocessor */ +# define VX_PRIVATE_ENV 0x0080 /* private environment support */ +# define VX_NO_STACK_FILL 0x0100 /* do not stack fill for + checkstack () */ + +# define THR_CANCEL_DISABLE 0 +# define THR_CANCEL_ENABLE 0 +# define THR_CANCEL_DEFERRED 0 +# define THR_CANCEL_ASYNCHRONOUS 0 +# define THR_BOUND 0 +# define THR_NEW_LWP 0 +# define THR_DETACHED 0 +# define THR_SUSPENDED 0 +# define THR_DAEMON 0 +# define THR_JOINABLE 0 +# define THR_SCHED_FIFO 0 +# define THR_SCHED_RR 0 +# define THR_SCHED_DEFAULT 0 +# define THR_INHERIT_SCHED 0 +# define THR_EXPLICIT_SCHED 0 +# define THR_SCHED_IO 0 +# define THR_SCOPE_SYSTEM 0 +# define THR_SCOPE_PROCESS 0 +# define USYNC_THREAD 0 +# define USYNC_PROCESS 1 /* It's all global on VxWorks + (without MMU option). */ +# if !defined (ACE_DEFAULT_SYNCH_TYPE) + // Types include these options: SEM_Q_PRIORITY, SEM_Q_FIFO, + // SEM_DELETE_SAFE, and SEM_INVERSION_SAFE. SEM_Q_FIFO is + // used as the default because that is VxWorks' default. +# define ACE_DEFAULT_SYNCH_TYPE SEM_Q_FIFO +# endif /* ! ACE_DEFAULT_SYNCH_TYPE */ + +typedef SEM_ID ACE_mutex_t; +// Implement ACE_thread_mutex_t with ACE_mutex_t because there's just +// one process . . . +typedef ACE_mutex_t ACE_thread_mutex_t; +# if !defined (ACE_HAS_POSIX_SEM) +// Use VxWorks semaphores, wrapped ... +typedef struct +{ + SEM_ID sema_; + // Semaphore handle. This is allocated by VxWorks. + + char *name_; + // Name of the semaphore: always NULL with VxWorks. +} ACE_sema_t; +# endif /* !ACE_HAS_POSIX_SEM */ +typedef char * ACE_thread_t; +typedef int ACE_hthread_t; +// Key type: the ACE TSS emulation requires the key type be unsigned, +// for efficiency. (Current POSIX and Solaris TSS implementations also +// use u_int, so the ACE TSS emulation is compatible with them.) +typedef u_int ACE_thread_key_t; + + // Marker for ACE_Thread_Manager to indicate that it allocated + // an ACE_thread_t. It is placed at the beginning of the ID. +# define ACE_THR_ID_ALLOCATED '\022' +# endif /* VXWORKS */ + +#endif /* ACE_OS_INCLUDE_VXWORKS_H */ |