diff options
author | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-01 11:15:26 +0000 |
---|---|---|
committer | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-01 11:15:26 +0000 |
commit | 746f4ee6169d6cd8d8e5f8d6b3b368d3ac128ac6 (patch) | |
tree | 9a2cd7fff6f9e796968703bf3bb2cb7ca5c5bf82 | |
parent | a288d4fc55907205181362fee9979dc5cd9b9d07 (diff) | |
download | ATCD-746f4ee6169d6cd8d8e5f8d6b3b368d3ac128ac6.tar.gz |
ChangeLogTag:Sat Nov 1 05:40:21 UTC 2003 Don Hinton <dhinton@dresystems.com>
1091 files changed, 31837 insertions, 27418 deletions
diff --git a/ACEXML/apps/svcconf/Svcconf_Handler.cpp b/ACEXML/apps/svcconf/Svcconf_Handler.cpp index 5f335c42821..a37b8ed220f 100644 --- a/ACEXML/apps/svcconf/Svcconf_Handler.cpp +++ b/ACEXML/apps/svcconf/Svcconf_Handler.cpp @@ -52,7 +52,7 @@ ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, const ACEXML_Char *qName ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXException)) { - if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0) + if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0) { ACE_Parsed_Info *active_info = (this->in_stream_def_ == 0 ? &this->parsed_info_ : @@ -158,7 +158,7 @@ ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, this->parsed_info_.reset (); } } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0) { if (this->in_stream_def_) { @@ -188,11 +188,11 @@ ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, this->parsed_info_.reset (); } } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0) { this->in_module_ = 0; } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"), // this->stream_info_.name (), @@ -204,7 +204,7 @@ ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, this->stream_svc_type_ = 0; this->stream_ = 0; } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"), // this->stream_info_.name (), @@ -267,20 +267,20 @@ ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXException)) { - if (ACE_OS_String::strcmp (qName, ACE_TEXT ("dynamic")) == 0) + if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0) { this->get_dynamic_attrs (alist ACEXML_ENV_ARG_PARAMETER); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("initializer")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("initializer")) == 0) { this->get_initializer_attrs (alist ACEXML_ENV_ARG_PARAMETER); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("static")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0) { this->get_static_attrs (alist ACEXML_ENV_ARG_PARAMETER); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("stream")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0) { this->get_stream_id (alist ACEXML_ENV_ARG_PARAMETER); @@ -299,17 +299,17 @@ ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"), // this->stream_info_.name ())); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("streamdef")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0) { this->in_stream_def_ = 1; // @@ Set up stream service object } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("module")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0) { this->in_stream_def_ = 0; this->in_module_ = 1; } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("resume")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("resume")) == 0) { this->get_id (alist ACEXML_ENV_ARG_PARAMETER); if (this->in_module_) @@ -339,7 +339,7 @@ ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, } this->parsed_info_.reset (); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("suspend")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("suspend")) == 0) { this->get_id (alist ACEXML_ENV_ARG_PARAMETER); if (this->in_module_) @@ -369,7 +369,7 @@ ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, } this->parsed_info_.reset (); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("remove")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("remove")) == 0) { this->get_id (alist ACEXML_ENV_ARG_PARAMETER); if (this->in_module_) @@ -399,7 +399,7 @@ ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, } this->parsed_info_.reset (); } - else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0) + else if (ACE_OS::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0) { // Main document tag. no-op. // ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n"))); @@ -493,7 +493,7 @@ ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_D if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { - if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) + if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { this->stream_info_.name (alist->getValue (i)); } @@ -512,7 +512,7 @@ ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL) if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { - if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) + if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { this->parsed_info_.name (alist->getValue (i)); } @@ -534,17 +534,17 @@ ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_A &this->stream_info_); for (size_t i = 0; i < alist->getLength (); ++i) { - if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) + if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { info->name (alist->getValue (i)); } - else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0) + else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0) { - if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0) + if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0) { info->active (0); } - else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0) + else if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0) { info->active (1); } @@ -553,17 +553,17 @@ ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_A ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid attribute value, expecting 'active' or 'inactive'\n")), -1); } } - else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0) + else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0) { - if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0) + if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0) { info->service_type (ACE_Service_Type::SERVICE_OBJECT); } - else if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0) + else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0) { info->service_type (ACE_Service_Type::STREAM); } - else if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0) + else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0) { info->service_type (ACE_Service_Type::MODULE); } @@ -591,15 +591,15 @@ ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist ACEXML_E &this->stream_info_); for (size_t i = 0; i < alist->getLength (); ++i) { - if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0) + if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0) { info->init_func (alist->getValue (i)); } - else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0) + else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0) { info->path (alist->getValue (i)); } - else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0) + else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0) { info->init_params (alist->getValue (i)); } @@ -622,11 +622,11 @@ ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist ACEXML_ENV_AR &this->stream_info_); for (size_t i = 0; i < alist->getLength (); ++i) { - if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) + if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { info->name (alist->getValue (i)); } - else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0) + else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0) { info->init_params (alist->getValue (i)); } diff --git a/ACEXML/common/FileCharStream.cpp b/ACEXML/common/FileCharStream.cpp index cbee8018571..3a5694f120b 100644 --- a/ACEXML/common/FileCharStream.cpp +++ b/ACEXML/common/FileCharStream.cpp @@ -3,6 +3,8 @@ #include "ACEXML/common/FileCharStream.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_stat.h" ACEXML_FileCharStream::ACEXML_FileCharStream (void) : filename_ (0), encoding_ (0), size_ (0), infile_ (0), peek_ (0) diff --git a/ACEXML/common/NamespaceSupport.cpp b/ACEXML/common/NamespaceSupport.cpp index ba4ff11eccf..04fdf6bfdfc 100644 --- a/ACEXML/common/NamespaceSupport.cpp +++ b/ACEXML/common/NamespaceSupport.cpp @@ -2,6 +2,10 @@ #include "ACEXML/common/NamespaceSupport.h" +#if !defined (__ACEXML_INLINE__) +# include "ACEXML/common/NamespaceSupport.i" +#endif /* __ACEXML_INLINE__ */ + static const ACEXML_Char ACEXML_XMLNS_PREFIX_name[] = ACE_TEXT ("xmlns"); const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS_PREFIX = ACEXML_XMLNS_PREFIX_name; @@ -13,10 +17,6 @@ static const ACEXML_Char ACEXML_TABOO_NS_PREFIX[] = ACE_TEXT ("xml"); static const ACEXML_Char ACEXML_XMLNS_URI_name[] = ACE_TEXT ("http://www.w3.org/XML/1998/namespace"); const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS = ACEXML_XMLNS_URI_name; -#if !defined (__ACEXML_INLINE__) -# include "ACEXML/common/NamespaceSupport.i" -#endif /* __ACEXML_INLINE__ */ - ACEXML_Namespace_Context_Stack::ACEXML_Namespace_Context_Stack (void) : head_ (0) { @@ -87,7 +87,7 @@ ACEXML_NamespaceSupport::declarePrefix (const ACEXML_Char *prefix, // Unless predefined by w3.org(?) NS prefix can never start with // "xml". - if (ACE_OS_String::strcmp (ACEXML_TABOO_NS_PREFIX, prefix) == 0) + if (ACE_OS::strcmp (ACEXML_TABOO_NS_PREFIX, prefix) == 0) return -1; ACEXML_String ns_prefix (prefix, 0, 0); @@ -220,7 +220,7 @@ ACEXML_NamespaceSupport::processName (const ACEXML_Char *qName, const ACEXML_Char *&name, int is_attribute) const { - int qlen = ACE_static_cast (int, ACE_OS_String::strlen (qName)); + int qlen = ACE_static_cast (int, ACE_OS::strlen (qName)); int len = -1; for (int i = 0; i < qlen; ++i) if (qName [i] == ':') diff --git a/ACEXML/common/NamespaceSupport.h b/ACEXML/common/NamespaceSupport.h index 04177308b63..3b906c37c44 100644 --- a/ACEXML/common/NamespaceSupport.h +++ b/ACEXML/common/NamespaceSupport.h @@ -25,7 +25,8 @@ #include "ace/Functor.h" #include "ace/Hash_Map_Manager.h" #include "ace/Containers_T.h" -#include "ace/Synch.h" +#include "ace/Null_Mutex.h" + typedef ACE_Hash_Map_Entry<ACEXML_String, ACEXML_String> ACEXML_NS_CONTEXT_ENTRY; diff --git a/ACEXML/common/StrCharStream.cpp b/ACEXML/common/StrCharStream.cpp index db0c2c7761a..e37bbb4f6d8 100644 --- a/ACEXML/common/StrCharStream.cpp +++ b/ACEXML/common/StrCharStream.cpp @@ -25,7 +25,7 @@ ACEXML_StrCharStream::open (const ACEXML_Char *str, const ACEXML_Char* name) && (this->name_ = ACE::strnew (name)) != 0) { this->ptr_ = this->start_; - this->end_ = this->start_ + ACE_OS_String::strlen (this->start_); + this->end_ = this->start_ + ACE_OS::strlen (this->start_); return this->determine_encoding(); } return -1; // Invalid string passed. @@ -97,7 +97,7 @@ ACEXML_StrCharStream::read (ACEXML_Char *str, size_t len) { if (len * sizeof (ACEXML_Char) > (size_t) (this->end_ - this->ptr_)) len = this->end_ - this->ptr_; - ACE_OS_String::strncpy (str, this->ptr_, len); + ACE_OS::strncpy (str, this->ptr_, len); this->ptr_ += len; return ACE_static_cast (int, len); } diff --git a/ACEXML/common/URL_Addr.cpp b/ACEXML/common/URL_Addr.cpp index 3f06e15f7be..a1a9ea7aa40 100644 --- a/ACEXML/common/URL_Addr.cpp +++ b/ACEXML/common/URL_Addr.cpp @@ -1,16 +1,17 @@ // $Id$ -#include "ace/Log_Msg.h" -#include "ace/Auto_Ptr.h" #include "ACEXML/common/URL_Addr.h" - ACE_RCSID(common, ACEXML_URL_Addr, "$Id$") #if !defined (__ACEXML_INLINE__) #include "ACEXML/common/URL_Addr.inl" #endif /* __ACEXML_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/Auto_Ptr.h" +#include "ace/OS_NS_stdio.h" + ACEXML_URL_Addr::ACEXML_URL_Addr (void) : path_name_ (0), addr_string_ (0), diff --git a/ACEXML/common/XML_Types.h b/ACEXML/common/XML_Types.h index 3cfb62efd99..7ed578366ff 100644 --- a/ACEXML/common/XML_Types.h +++ b/ACEXML/common/XML_Types.h @@ -17,7 +17,7 @@ #define _ACEXML_XML_TYPES_H_ #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once diff --git a/ACEXML/examples/SAXPrint/main.cpp b/ACEXML/examples/SAXPrint/main.cpp index 1b6cc2932fa..9a7b7930acd 100644 --- a/ACEXML/examples/SAXPrint/main.cpp +++ b/ACEXML/examples/SAXPrint/main.cpp @@ -10,6 +10,7 @@ #include "ace/Get_Opt.h" #include "ace/Auto_Ptr.h" #include "ace/Log_Msg.h" +#include "ace/OS_main.h" static const ACEXML_Char *test_string = ACE_TEXT ("<?xml version='1.0'?> <ACE_Svc_Conf> <static id=\"ACE_Service_Manager\" params='-d -p 4911'/> <dynamic id=\"Test_Task\" type=\"service_object\"> A " <initializer path=\"CCM_App\" init='_make_Test_Task' params='-p 3000'/> </dynamic> </ACE_Svc_Conf>"); diff --git a/ACEXML/parser/parser/Entity_Manager.h b/ACEXML/parser/parser/Entity_Manager.h index e86f7747f03..5eec188a184 100644 --- a/ACEXML/parser/parser/Entity_Manager.h +++ b/ACEXML/parser/parser/Entity_Manager.h @@ -23,7 +23,7 @@ #include "ACEXML/common/XML_Types.h" #include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" +#include "ace/Null_Mutex.h" typedef ACE_Hash_Map_Entry<ACEXML_String, ACEXML_String> ACEXML_ENTITY_ENTRY; diff --git a/ACEXML/parser/parser/Parser.cpp b/ACEXML/parser/parser/Parser.cpp index 65d4723b91a..213b4beaae8 100644 --- a/ACEXML/parser/parser/Parser.cpp +++ b/ACEXML/parser/parser/Parser.cpp @@ -1,16 +1,18 @@ // $Id$ +#include "ACEXML/parser/parser/Parser.h" + +#if !defined (__ACEXML_INLINE__) +# include "ACEXML/parser/parser/Parser.i" +#endif /* __ACEXML_INLINE__ */ + #include "ace/ACE.h" #include "ACEXML/common/Transcode.h" #include "ACEXML/common/AttributesImpl.h" #include "ACEXML/common/StrCharStream.h" #include "ACEXML/common/StreamFactory.h" -#include "ACEXML/parser/parser/Parser.h" #include "ACEXML/parser/parser/ParserInternals.h" - -#if !defined (__ACEXML_INLINE__) -# include "ACEXML/parser/parser/Parser.i" -#endif /* __ACEXML_INLINE__ */ +#include "ace/OS_NS_strings.h" static const ACEXML_Char default_attribute_type[] = ACE_TEXT ("CDATA"); static const ACEXML_Char empty_string[] = { 0 }; diff --git a/ACEXML/parser/parser/ParserContext.cpp b/ACEXML/parser/parser/ParserContext.cpp index fd0792677fb..77592dc13cb 100644 --- a/ACEXML/parser/parser/ParserContext.cpp +++ b/ACEXML/parser/parser/ParserContext.cpp @@ -13,3 +13,12 @@ ACEXML_Parser_Context::~ACEXML_Parser_Context() delete this->locator_; this->locator_ = 0; } + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Swap <ACEXML_InputSource*>; +template class ACE_Swap <ACEXML_LocatorImpl*>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +# pragma instantiate ACE_Swap <ACEXML_InputSource*> +# pragma instantiate ACE_Swap <ACEXML_LocatorImpl*> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/ACEXML/tests/ContentHandler_Test.cpp b/ACEXML/tests/ContentHandler_Test.cpp index c1d9f765dfd..23eb3f96e23 100644 --- a/ACEXML/tests/ContentHandler_Test.cpp +++ b/ACEXML/tests/ContentHandler_Test.cpp @@ -12,6 +12,7 @@ #include "ACEXML/common/InputSource.h" #include "ACEXML/common/StrCharStream.h" #include "ACEXML/parser/parser/Parser.h" +#include "ace/OS_main.h" class Basic_Content_Tester : public ACEXML_DefaultHandler { diff --git a/ACEXML/tests/HttpCharStream_Test.cpp b/ACEXML/tests/HttpCharStream_Test.cpp index b30dc7fa55a..fd0bdc107c5 100644 --- a/ACEXML/tests/HttpCharStream_Test.cpp +++ b/ACEXML/tests/HttpCharStream_Test.cpp @@ -1,6 +1,7 @@ // $Id$ #include "ACEXML/common/HttpCharStream.h" +#include "ace/OS_main.h" int ACE_TMAIN (int, ACE_TCHAR *[]) { diff --git a/ACEXML/tests/NamespaceSupport_Test.cpp b/ACEXML/tests/NamespaceSupport_Test.cpp index 418969d9c91..2632c6dc571 100644 --- a/ACEXML/tests/NamespaceSupport_Test.cpp +++ b/ACEXML/tests/NamespaceSupport_Test.cpp @@ -1,6 +1,7 @@ // $Id$ #include "ACEXML/common/NamespaceSupport.h" +#include "ace/OS_main.h" int ACE_TMAIN (int, ACE_TCHAR *[]) { diff --git a/ACEXML/tests/Transcoder_Test.cpp b/ACEXML/tests/Transcoder_Test.cpp index 2e87a52a7e7..746d4442e89 100644 --- a/ACEXML/tests/Transcoder_Test.cpp +++ b/ACEXML/tests/Transcoder_Test.cpp @@ -2,6 +2,7 @@ #include "ACEXML/common/Transcode.h" #include "ace/Log_Msg.h" +#include "ace/OS_main.h" void dump_utf16 (const ACEXML_UTF16 *data, size_t len) diff --git a/ASNMP/asnmp/address.cpp b/ASNMP/asnmp/address.cpp index eea41707a15..72a910ddb07 100644 --- a/ASNMP/asnmp/address.cpp +++ b/ASNMP/asnmp/address.cpp @@ -37,6 +37,13 @@ =====================================================================*/ #include "asnmp/address.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_stdio.h" +#include "ace/os_include/os_ctype.h" +#include "ace/OS_Memory.h" ACE_RCSID(asnmp, address, "$Id$") @@ -88,7 +95,7 @@ unsigned char& Address::operator[]( const int position) // overloaded equivlence operator, are two addresses equal? int operator==( const Address &lhs, const Address &rhs) { - if ( strcmp( (const char*) lhs, (const char*)rhs)==0) + if ( ACE_OS::strcmp( (const char*) lhs, (const char*)rhs)==0) return 1; else return 0; @@ -106,7 +113,7 @@ int operator!=( const Address &lhs, const Address &rhs) // overloaded > operator, is a1 > a2 int operator>( const Address &lhs, const Address &rhs) { - if ( strcmp( (const char*) lhs, (const char*)rhs)>0) + if (ACE_OS::strcmp( (const char*) lhs, (const char*)rhs)>0) return 1; else return 0; @@ -136,7 +143,7 @@ int operator<=( const Address &lhs,const Address &rhs) // overloaded < operator, is a1 < a2 int operator<( const Address &lhs, const Address &rhs) { - if ( strcmp( (const char*) lhs, (const char*)rhs)<0) + if (ACE_OS::strcmp( (const char*) lhs, (const char*)rhs)<0) return 1; else return 0; @@ -148,7 +155,7 @@ int operator==( const Address &lhs,const char *rhs) { if (!rhs && !lhs.valid()) return 1; - if (strcmp( (const char *) lhs, rhs)== 0) + if (ACE_OS::strcmp( (const char *) lhs, rhs)== 0) return 1; else return 0; @@ -167,7 +174,7 @@ int operator>( const Address &lhs,const char *rhs) { if (!rhs) return lhs.valid(); // if lhs valid then > 0, else invalid !> 0 - if (strcmp( (const char *) lhs, rhs)> 0) + if (ACE_OS::strcmp( (const char *) lhs, rhs)> 0) return 1; else return 0; @@ -179,7 +186,7 @@ int operator>=( const Address &lhs,const char *rhs) { if (!rhs) return 1; // always >= 0 - if (strcmp( (const char *) lhs, rhs)>= 0) + if (ACE_OS::strcmp( (const char *) lhs, rhs)>= 0) return 1; else return 0; @@ -191,7 +198,7 @@ int operator<( const Address &lhs,const char *rhs) { if (!rhs) return 0; // always >= 0 - if (strcmp( (const char *) lhs, rhs)< 0) + if (ACE_OS::strcmp( (const char *) lhs, rhs)< 0) return 1; else return 0; @@ -203,7 +210,7 @@ int operator<=( const Address &lhs,const char *rhs) { if (!rhs) return !lhs.valid(); // invalid == 0, else valid > 0 - if (strcmp( (const char *) lhs, rhs)<= 0) + if (ACE_OS::strcmp( (const char *) lhs, rhs)<= 0) return 1; else return 0; @@ -451,7 +458,7 @@ int IpAddress::parse_dotted_ipstring( const char *inaddr) return 0; // look for dot token separator - ip_token = strtok( (char *) temp,"."); + ip_token = ACE_OS::strtok( (char *) temp,"."); // while more tokens.. while ( ip_token != 0) { @@ -467,12 +474,12 @@ int IpAddress::parse_dotted_ipstring( const char *inaddr) if (( value > 0)&& ( value <=255)) address_buffer[token_count] = (unsigned char) value; else - if ( strcmp(ip_token,"0")==0) + if (ACE_OS::strcmp(ip_token,"0")==0) address_buffer[token_count]= (unsigned char) 0; else error_status = 1; token_count++; - ip_token = strtok( 0, "."); + ip_token = ACE_OS::strtok( 0, "."); } // gota be four in len diff --git a/ASNMP/asnmp/address.h b/ASNMP/asnmp/address.h index 21257d7737e..e6d89fedfd0 100644 --- a/ASNMP/asnmp/address.h +++ b/ASNMP/asnmp/address.h @@ -37,7 +37,8 @@ //----[ includes ]----------------------------------------------------- // ACE OS Adaption layer -#include "ace/OS.h" +#include "ace/os_include/netinet/os_in.h" +#include "ace/os_include/os_netdb.h" #include "ace/Log_Msg.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) diff --git a/ASNMP/asnmp/asn1.cpp b/ASNMP/asnmp/asn1.cpp index 77dc9baa5ec..ccb2e699456 100644 --- a/ASNMP/asnmp/asn1.cpp +++ b/ASNMP/asnmp/asn1.cpp @@ -52,6 +52,7 @@ #include "asnmp/asn1.h" #include "asnmp/snmp.h" +#include "ace/OS_NS_string.h" ACE_RCSID(asnmp, asn1, "$Id$") diff --git a/ASNMP/asnmp/asn1.h b/ASNMP/asnmp/asn1.h index c01b34e65a7..0c141c188d2 100644 --- a/ASNMP/asnmp/asn1.h +++ b/ASNMP/asnmp/asn1.h @@ -43,7 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ASNMP/asnmp/ctr64.cpp b/ASNMP/asnmp/ctr64.cpp index 45d12cca277..e11b7cd613b 100644 --- a/ASNMP/asnmp/ctr64.cpp +++ b/ASNMP/asnmp/ctr64.cpp @@ -32,6 +32,7 @@ =====================================================================*/ #include "asnmp/ctr64.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(asnmp, ctr64, "$Id$") diff --git a/ASNMP/asnmp/integer.cpp b/ASNMP/asnmp/integer.cpp index ca399336053..d732e0f3ff9 100644 --- a/ASNMP/asnmp/integer.cpp +++ b/ASNMP/asnmp/integer.cpp @@ -33,11 +33,12 @@ =====================================================================*/ #include "asnmp/integer.h" // header file for gauge class +#include "ace/OS_NS_stdio.h" ACE_RCSID(asnmp, integer, "$Id$") // constructor with value -SnmpUInt32::SnmpUInt32 (const u_long i) +SnmpUInt32::SnmpUInt32 (const unsigned long i) { smival.value.uNumber=i; smival.syntax = sNMP_SYNTAX_UINT32; diff --git a/ASNMP/asnmp/octet.cpp b/ASNMP/asnmp/octet.cpp index b75a5186178..7c9db8ca405 100644 --- a/ASNMP/asnmp/octet.cpp +++ b/ASNMP/asnmp/octet.cpp @@ -33,8 +33,12 @@ derivatives based upon this software code base. =====================================================================*/ -#include "ace/OS.h" #include "asnmp/octet.h" // include definition for octet class +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_ctype.h" +#include "ace/os_include/os_ctype.h" ACE_RCSID(asnmp, octet, "$Id$") @@ -477,7 +481,7 @@ const char * OctetStr::to_string() for ( unsigned long i=0; i < smival.value.string.len; i++) { if (( smival.value.string.ptr[i] != '\r')&& ( smival.value.string.ptr[i] != '\n')&& - (isprint((int) (smival.value.string.ptr[i]))==0)) + (ACE_OS::ace_isprint((int) (smival.value.string.ptr[i]))==0)) return(to_string_hex()); } @@ -587,7 +591,7 @@ const char *OctetStr::to_string_hex() #endif // _WIN32 ACE_OS::sprintf(line_ptr, fmt, char_buf); - line_ptr += 3 + strlen(char_buf); + line_ptr += 3 + ACE_OS::strlen(char_buf); } return output_buffer; diff --git a/ASNMP/asnmp/oid.cpp b/ASNMP/asnmp/oid.cpp index 03e65410a4a..71c5caa8835 100644 --- a/ASNMP/asnmp/oid.cpp +++ b/ASNMP/asnmp/oid.cpp @@ -36,6 +36,10 @@ //---------[ external C libaries used ]-------------------------------- #include "asnmp/oid.h" // include def for oid class +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_Memory.h" +#include "ace/os_include/os_ctype.h" ACE_RCSID(asnmp, oid, "$Id$") diff --git a/ASNMP/asnmp/oid.h b/ASNMP/asnmp/oid.h index c0de425a144..8ef171317f3 100644 --- a/ASNMP/asnmp/oid.h +++ b/ASNMP/asnmp/oid.h @@ -39,7 +39,7 @@ =====================================================================*/ //----------[ extern C libraries Needed ]--------------------------------- -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ASNMP/asnmp/pdu.cpp b/ASNMP/asnmp/pdu.cpp index 49c14861af6..ddd43a292ad 100644 --- a/ASNMP/asnmp/pdu.cpp +++ b/ASNMP/asnmp/pdu.cpp @@ -34,6 +34,8 @@ #include "asnmp/snmp.h" #include "asnmp/pdu.h" // include Pdu class definition +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(asnmp, pdu, "$Id$") diff --git a/ASNMP/asnmp/smi.h b/ASNMP/asnmp/smi.h index 09b3927b220..4fac7f8c1bc 100644 --- a/ASNMP/asnmp/smi.h +++ b/ASNMP/asnmp/smi.h @@ -35,7 +35,7 @@ =====================================================================*/ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ASNMP/asnmp/snmp.cpp b/ASNMP/asnmp/snmp.cpp index 9c3b0d40af2..cc2e1dd4179 100644 --- a/ASNMP/asnmp/snmp.cpp +++ b/ASNMP/asnmp/snmp.cpp @@ -43,6 +43,9 @@ #include "asnmp/address.h" // class def for addresses #include "asnmp/wpdu.h" // adapter to cmu_library / wire protocol #include "asnmp/transaction.h" // synchronous transaction processor +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_time.h" ACE_RCSID(asnmp, snmp, "$Id$") diff --git a/ASNMP/asnmp/timetick.cpp b/ASNMP/asnmp/timetick.cpp index aeb8427c43e..e6b2d0d2231 100644 --- a/ASNMP/asnmp/timetick.cpp +++ b/ASNMP/asnmp/timetick.cpp @@ -32,6 +32,7 @@ =====================================================================*/ #include "asnmp/timetick.h" // include header file for timetick class +#include "ace/OS_NS_stdio.h" ACE_RCSID(asnmp, timetick, "$Id$") diff --git a/ASNMP/asnmp/transaction.cpp b/ASNMP/asnmp/transaction.cpp index 5eccd735879..e7c703aa865 100644 --- a/ASNMP/asnmp/transaction.cpp +++ b/ASNMP/asnmp/transaction.cpp @@ -18,6 +18,7 @@ #include "ace/Reactor.h" #include "asnmp/transaction.h" +#include "ace/OS_NS_string.h" ACE_RCSID(asnmp, transaction, "$Id$") diff --git a/ASNMP/asnmp/vb.cpp b/ASNMP/asnmp/vb.cpp index ab32e9639bb..ee80d7e68ec 100644 --- a/ASNMP/asnmp/vb.cpp +++ b/ASNMP/asnmp/vb.cpp @@ -39,6 +39,9 @@ #include "asnmp/oid.h" // include oid class defs #include "asnmp/vb.h" // include vb class defs #include "asnmp/snmperrs.h" // error codes +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" ACE_RCSID(asnmp, vb, "$Id$") @@ -385,7 +388,7 @@ int operator==( const Vb &lhs, const Vb &rhs) return 0; if (lhs.iv_vb_value_ != 0 && rhs.iv_vb_value_ != 0) { - int val = strcmp(lhs.iv_vb_value_->to_string(), + int val = ACE_OS::strcmp(lhs.iv_vb_value_->to_string(), rhs.iv_vb_value_->to_string()); return !val; } diff --git a/ASNMP/asnmp/vb.h b/ASNMP/asnmp/vb.h index f20b58cca2a..5a2b778748d 100644 --- a/ASNMP/asnmp/vb.h +++ b/ASNMP/asnmp/vb.h @@ -37,7 +37,7 @@ =====================================================================*/ //----[ external calls ]---------------------------------------------- -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ASNMP/asnmp/wpdu.cpp b/ASNMP/asnmp/wpdu.cpp index f4ac111fe0e..d05a750970f 100644 --- a/ASNMP/asnmp/wpdu.cpp +++ b/ASNMP/asnmp/wpdu.cpp @@ -19,6 +19,7 @@ #include "asnmp/wpdu.h" #include <ace/Log_Msg.h> +#include "ace/OS_NS_string.h" #define DEFINE_TRAP_CONSTANTS_ #include "asnmp/enttraps.h" diff --git a/ASNMP/asnmp/wpdu.h b/ASNMP/asnmp/wpdu.h index 4d56c73ada6..1485560baeb 100644 --- a/ASNMP/asnmp/wpdu.h +++ b/ASNMP/asnmp/wpdu.h @@ -20,7 +20,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ASNMP/tests/Counter64_Test.cpp b/ASNMP/tests/Counter64_Test.cpp index f60c3c3a64d..210fe3fc1d6 100644 --- a/ASNMP/tests/Counter64_Test.cpp +++ b/ASNMP/tests/Counter64_Test.cpp @@ -39,7 +39,6 @@ DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/ctr64.h" #include "test_config.h" diff --git a/ASNMP/tests/Counter_Test.cpp b/ASNMP/tests/Counter_Test.cpp index 0538261cb8d..f85d0f47656 100644 --- a/ASNMP/tests/Counter_Test.cpp +++ b/ASNMP/tests/Counter_Test.cpp @@ -38,7 +38,6 @@ DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/counter.h" #include "test_config.h" diff --git a/ASNMP/tests/Gauge_Test.cpp b/ASNMP/tests/Gauge_Test.cpp index a607d58c1b7..c4cbdfcbdf8 100644 --- a/ASNMP/tests/Gauge_Test.cpp +++ b/ASNMP/tests/Gauge_Test.cpp @@ -37,7 +37,6 @@ SOFTWARE INCLUDING WITHOUT LIMITATION, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/gauge.h" #include "test_config.h" diff --git a/ASNMP/tests/Integer_Test.cpp b/ASNMP/tests/Integer_Test.cpp index c289425d8ea..e8b82352d92 100644 --- a/ASNMP/tests/Integer_Test.cpp +++ b/ASNMP/tests/Integer_Test.cpp @@ -39,7 +39,6 @@ DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/integer.h" #include "test_config.h" diff --git a/ASNMP/tests/Octet_Test.cpp b/ASNMP/tests/Octet_Test.cpp index 45dd9bc10b6..09e03f32614 100644 --- a/ASNMP/tests/Octet_Test.cpp +++ b/ASNMP/tests/Octet_Test.cpp @@ -40,7 +40,6 @@ DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/octet.h" #include "test_config.h" diff --git a/ASNMP/tests/Oid_Test.cpp b/ASNMP/tests/Oid_Test.cpp index c195b0a7105..9343dc2575e 100644 --- a/ASNMP/tests/Oid_Test.cpp +++ b/ASNMP/tests/Oid_Test.cpp @@ -38,7 +38,6 @@ SOFTWARE INCLUDING WITHOUT LIMITATION, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/oid.h" #include "test_config.h" diff --git a/ASNMP/tests/Target_Test.cpp b/ASNMP/tests/Target_Test.cpp index 30f002b03ad..0e3548cf826 100644 --- a/ASNMP/tests/Target_Test.cpp +++ b/ASNMP/tests/Target_Test.cpp @@ -40,7 +40,6 @@ DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/octet.h" #include "asnmp/target.h" #include "test_config.h" diff --git a/ASNMP/tests/Varbind_Test.cpp b/ASNMP/tests/Varbind_Test.cpp index 0491543f0e7..3340259341a 100644 --- a/ASNMP/tests/Varbind_Test.cpp +++ b/ASNMP/tests/Varbind_Test.cpp @@ -40,7 +40,6 @@ DAMAGES. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -#include "ace/OS.h" #include "asnmp/oid.h" #include "asnmp/vb.h" #include "test_config.h" diff --git a/ASNMP/tests/test_config.h b/ASNMP/tests/test_config.h index 42c4230453d..f94674ed504 100644 --- a/ASNMP/tests/test_config.h +++ b/ASNMP/tests/test_config.h @@ -16,6 +16,10 @@ #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_sys_stat.h" #include "ace/streams.h" diff --git a/ChangeLog b/ChangeLog index 927795b065e..b93beeb48af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,851 @@ +Sat Nov 1 05:40:21 UTC 2003 Don Hinton <dhinton@dresystems.com> + + * ace/Cleanup.{h,inl,cpp}: + * ace/OS_main.h: + * ace/OS_NS_arpa_inet.{h,inl,cpp}: + * ace/OS_NS_ctype.{h,inl,cpp}: + * ace/OS_NS_dirent.{h,inl,cpp}: + * ace/OS_NS_dlfcn.{h,inl,cpp}: + * ace/OS_NS_errno.{h,inl,cpp}: + * ace/OS_NS_fcntl.{h,inl,cpp}: + * ace/OS_NS_macros.h: + * ace/OS_NS_math.{h,inl,cpp}: + * ace/OS_NS_netdb.{h,inl,cpp}: + * ace/OS_NS_poll.{h,inl,cpp}: + * ace/OS_NS_pwd.{h,inl,cpp}: + * ace/OS_NS_regex.{h,inl,cpp}: + * ace/OS_NS_signal.{h,inl,cpp}: + * ace/OS_NS_stdio.{h,inl,cpp}: + * ace/OS_NS_stdlib.{h,inl,cpp}: + * ace/OS_NS_string.{h,inl,cpp}: + * ace/OS_NS_strings.{h,inl,cpp}: + * ace/OS_NS_stropts.{h,inl,cpp}: + * ace/OS_NS_sys_mman.{h,inl,cpp}: + * ace/OS_NS_sys_msg.{h,inl,cpp}: + * ace/OS_NS_sys_resource.{h,inl,cpp}: + * ace/OS_NS_sys_select.{h,inl,cpp}: + * ace/OS_NS_sys_shm.{h,inl,cpp}: + * ace/OS_NS_sys_socket.{h,inl,cpp}: + * ace/OS_NS_sys_stat.{h,inl,cpp}: + * ace/OS_NS_sys_time.{h,inl,cpp}: + * ace/OS_NS_sys_uio.{h,inl,cpp}: + * ace/OS_NS_sys_utsname.{h,inl,cpp}: + * ace/OS_NS_sys_wait.{h,inl,cpp}: + * ace/OS_NS_Thread.{h,inl,cpp}: + * ace/OS_NS_time.{h,inl,cpp}: + * ace/OS_NS_unistd.{h,inl,cpp}: + * ace/OS_NS_wchar.{h,inl,cpp}: + * ace/Object_Manager_Base.{h,inl,cpp}: + Added new files. + + * ace/OS.{h,i,cpp}: + * ace/OS_Dirent.{h,i,cpp}: + * ace/OS_String.{h,i,cpp}: + * ace/OS_Memory.{h,inl,cpp}: + * ace/OS_TLI.{h,inl}: + Converted ACE_OS* classes to ACE_OS namespace and moved all the + code to the new files above based on the Single Unix Spec. + + * ace/ace.mpc: + Added new files and removed OS.cpp, OS_String.cpp, + OS_Dirent.cpp, and OS_Memory.cpp. Also removed Synch.cpp and + added the individual concurrency files that had already been + added to the repo a while back.. + + * ace/OS.h: + * ace/Synch.h: + Added DO_NOT_INCLUDE #ifdef to make it easy to remove the entire + contents of these files for testing purposes. + + * ace/OS_main.h: + Moved the ACE_TMAIN macros here. + + * ace/Object_Manager_Base.{h,inl,cpp}: + Moved the ACE_Object_Manager_Base, ACE_OS_Object_Manager, and + ACE_OS_Object_Manager_Manager classes here. + + * ace/config-all.h: + MOved ACE_OS_TRACE macro here. + + * ace/config-vxworks5.x.h: + Added ACE_LACKS_ARPA_INET_H. + + * ace/config-win32-msvc.h: + Added ACE_LACKS_SEMAPHORE_H, ACE_LACKS_STRINGS_H, + ACE_LACKS_PWD_H, ACE_LACKS_POLL_H, ACE_LACKS_SYS_SHM_H, + ACE_LACKS_SYS_MSG_H, ACE_LACKS_NETINET_TCP_H, + ACE_LACKS_TERMIOS_H, and ACE_LACKS_REGEX_H. + + * ace/Time_Value.{h,cpp}: + Moved ACE_Countdown_Time here. + + * ace/TTY_IO.h: + Moved ACE_VMIN and ACE_VTIME macros here. + + * ace/SOCK.h: + Moved ACE_SHUTDOWN* macros here. + + * ace/Mutex.h: + Moved ACE_DEFAULT_MUTEX macros here. + + * ace/Log_Msg.cpp: + Moved sys_siglist define here. + + * ace/Handle_Set.cpp: + Moved ACE_MSB_MASK macro here. + + * ace/Global_Macros.h: + Moved PIPE_TYPE_*, NEW_MALLOC*, ACE_SEH*, template typedef + macros here. + + * ace/Default_Constants.h: + ACE_MAX_USERID out, ACE_DEV_NULL and ACE_SYSCALL_FAILED in. + + * ace/Cleanup.{h,inl,cpp}: + Added new file and moved ACE_Cleanup* and ACE_OS_Exit_Info + classes here. + + * ace/Basic_Types.h: + Moved ACE_HTONL and ACE_NTOHL macros here. + + * ace/os_include/os_dirent.h: + Moved ACE_DIR typedef here: + + * ace/os_include/os_dlfcn.h: + Moved _dl* function prototypes here. + + * ace/os_include/os_fcntl.h: + Moved O_NONBLOCK and F_GETFL defines here. + + * ace/os_include/os_limits.h: + Moved ACE_RTSIG_MAX define here. + + * ace/os_include/os_pthread.h: + Moved the sun priocntl includes here. + + * ace/os_include/os_regex.h: + Moved the regexpr.h include here. + + * ace/os_include/os_signal.h: + Moved the rest of the signal defines and includes here. + + * ace/os_include/os_stdio.h: + Moved the ACE_MAX_USERID define here. + + * ace/os_include/os_stdlib.h: + Moved the mktemp() prototype here. + + * ace/os_include/os_string.h: + * ace/OS_NS_stdio.inl: + Moved additional string related includes and strerror define + to os_string.h. Moved ACE_SPRINTF_ADAPTER to OS_NS_stdio.inl. + + * ace/os_include/os_strings.h: + Removed ACE_HAS_STRINGS hack. + + * ace/os_include/os_stropts.h: + Moved _XOPEN_EXTENDED_SOURCE, SIOCGIFBRDADDR, and SIOCGIFADDR + defines, strbuf type, and isastream() prototype here. + + * ace/os_include/os_time.h: + Moved timespec typedef and time related std using declaration + here. + + * ace/os_include/os_ucontext.h: + Moved ucontext_t typedef here. + + * ace/os_include/os_unistd.h: + Moved the id related prototypes, *_OK macros, and the + read_timedwait() and write_timedwait() prototypes here. + + * ace/os_include/arpa/os_inet.h: + Moved the inet_*() prototypes here. + + * ace/os_include/netinet/os_in.h: + Moved the multicast types and IP_* defines here. + + * ace/os_include/netinet/os_tcp.h: + Moved the TCP_NODELAY and TCP_MAXSEG defines here. + + * ace/os_include/sys/os_mman.h: + Moved the MAP_* defines here. + + * ace/os_include/sys/os_resource.h: + Moved the usage and limit defines and prototypes here. + + * ace/os_include/sys/os_select.h: + Moved NFDBITS and select() prototype here. + + * ace/os_include/sys/os_sem.h: + Moved the GETVAL, SETVAL, GETALL, SETALL, and SEM_UNDO defines + here. + + * ace/os_include/sys/os_socket.h: + Moved the socket related *_timedwait() prototypes and + ACE_SOCKET_LEN typedef here. + + * ace/os_include/sys/os_stat.h: + Added /**/ for system include. + + * ace/os_include/sys/os_time.h: + Moved gettimeofday() prototype here. + + * ace/os_include/sys/os_times.h: + Fixed typo. + + * ace/os_include/sys/os_types.h: + Moved ACE_timer_t typedef and types related std using + declarations here. + + * ace/os_include/sys/os_uio.h: + Moved readv_timedwait() writev_timedwait() prototypes here. + + * ace/os_include/sys/os_wait.h: + Moved wait macros, WIFEXITED, etc.., here. + + * ACEXML/apps/svcconf/Svcconf_Handler.cpp: + * ACEXML/common/FileCharStream.cpp: + * ACEXML/common/NamespaceSupport.{h,cpp}: + * ACEXML/common/StrCharStream.cpp: + * ACEXML/common/URL_Addr.cpp: + * ACEXML/common/XML_Types.h: + * ACEXML/examples/SAXPrint/main.cpp: + * ACEXML/parser/parser/Entity_Manager.h: + * ACEXML/parser/parser/Parser.cpp: + * ACEXML/tests/ContentHandler_Test.cpp: + * ACEXML/tests/HttpCharStream_Test.cpp: + * ACEXML/tests/NamespaceSupport_Test.cpp: + * ACEXML/tests/Transcoder_Test.cpp: + * ASNMP/asnmp/address.{h,cpp}: + * ASNMP/asnmp/asn1.{h,cpp}: + * ASNMP/asnmp/ctr64.cpp: + * ASNMP/asnmp/integer.cpp: + * ASNMP/asnmp/octet.cpp: + * ASNMP/asnmp/oid.{h,cpp}: + * ASNMP/asnmp/pdu.cpp: + * ASNMP/asnmp/smi.h: + * ASNMP/asnmp/snmp.cpp: + * ASNMP/asnmp/timetick.cpp: + * ASNMP/asnmp/transaction.cpp: + * ASNMP/asnmp/vb.{h,cpp}: + * ASNMP/asnmp/wpdu.{h,cpp}:, + * ASNMP/tests/Counter64_Test.cpp: + * ASNMP/tests/Counter_Test.cpp: + * ASNMP/tests/Gauge_Test.cpp: + * ASNMP/tests/Integer_Test.cpp: + * ASNMP/tests/Octet_Test.cpp: + * ASNMP/tests/Oid_Test.cpp: + * ASNMP/tests/Target_Test.cpp: + * ASNMP/tests/Varbind_Test.cpp: + * ASNMP/tests/test_config.h: + * Kokyu/Dispatcher_Task.cpp: + * Kokyu/tests/DSRT_MIF/MIF.cpp: + * Kokyu/tests/EDF/test.cpp: + * Kokyu/tests/FIFO/test.cpp: + * ace/ACE.{i,cpp}: + * ace/ARGV.cpp: + * ace/Acceptor.cpp: + * ace/Active_Map_Manager.{h,i}: + * ace/Addr.cpp: + * ace/Arg_Shifter.cpp: + * ace/Argv_Type_Converter.cpp: + * ace/Asynch_Acceptor.cpp: + * ace/Asynch_IO_Impl.cpp: + * ace/Asynch_Pseudo_Task.cpp: + * ace/Atomic_Op.cpp: + * ace/Auto_Event.cpp: + * ace/Barrier.cpp: + * ace/Base_Thread_Adapter.cpp: + * ace/Basic_Types.cpp: + * ace/CDR_Base.cpp: + * ace/CDR_Stream.i: + * ace/CE_Screen_Output.h: + * ace/Capabilities.cpp: + * ace/Codecs.cpp: + * ace/Condition_Thread_Mutex.cpp: + * ace/Configuration.cpp: + * ace/Configuration_Import_Export.cpp: + * ace/DEV.cpp: + * ace/DEV_IO.{i,h}: + * ace/DLL.cpp: + * ace/DLL_Manager.cpp: + * ace/Date_Time.i: + * ace/Dirent.{i,h}: + * ace/Dirent_Selector.{h,cpp}: + * ace/Env_Value_T.h: + * ace/Event.{h,cpp}: + * ace/FIFO.{h,cpp}: + * ace/FIFO_Recv.i: + * ace/FIFO_Recv_Msg.{i,cpp}: + * ace/FIFO_Send.i: + * ace/FIFO_Send_Msg.cpp: + * ace/FILE.cpp: + * ace/FILE_IO.{i,cpp}: + * ace/File_Lock.h: + * ace/Filecache.{h,cpp}: + * ace/Flag_Manip.{h,i,cpp}: + * ace/Framework_Component.cpp: + * ace/Functor.i: + * ace/Future.h: + * ace/Guard_T.{h,inl}: + * ace/Handle_Gobbler.h: + * ace/Handle_Ops.cpp: + * ace/Handle_Set.cpp: + * ace/High_Res_Timer.{h,i,cpp}: + * ace/INET_Addr.{i,cpp}: + * ace/IOStream.{h,cpp}: + * ace/IOStream_T.h: + * ace/IO_Cntl_Msg.h: + * ace/IO_SAP.cpp: + * ace/IO_SAP.i: + * ace/IPC_SAP.{i,cpp}: + * ace/LOCK_SOCK_Acceptor.cpp: + * ace/Lib_Find.cpp: + * ace/Local_Name_Space_T.cpp: + * ace/Lock_Adapter_T.cpp: + * ace/Log_Msg.cpp: + * ace/Log_Msg_NT_Event_Log.cpp: + * ace/Log_Msg_UNIX_Syslog.cpp: + * ace/Log_Record.cpp: + * ace/Log_Record.i: + * ace/Logging_Strategy.cpp: + * ace/MEM_Acceptor.cpp: + * ace/MEM_Addr.{i,cpp}: + * ace/MEM_IO.i: + * ace/Malloc.{h,cpp}: + * ace/Malloc_Allocator.i: + * ace/Malloc_T.{h,cpp}: + * ace/Manual_Event.cpp: + * ace/Mem_Map.{h,i,cpp}: + * ace/Memory_Pool.cpp: + * ace/Message_Block.cpp: + * ace/Message_Queue_T.cpp: + * ace/Metrics_Cache.{h,cpp}: + * ace/Metrics_Cache_T.h: + * ace/Module.h: + * ace/Mutex.{h,inl,cpp}: + * ace/NT_Service.cpp: + * ace/Name_Request_Reply.cpp: + * ace/Naming_Context.{h,cpp}: + * ace/OS_QoS.{h,cpp}: + * ace/OS_Thread_Adapter.cpp: + * ace/Object_Manager.h: + * ace/PI_Malloc.cpp: + * ace/POSIX_Asynch_IO.{h,cpp}: + * ace/POSIX_Proactor.cpp: + * ace/Pipe.{h,i}: + * ace/Proactor.h: + * ace/Proactor_Impl.h: + * ace/Process.{i,cpp}: + * ace/Process_Manager.cpp: + * ace/Profile_Timer.{h,i,cpp}: + * ace/RW_Mutex.{h,cpp}: + * ace/RW_Process_Mutex.h: + * ace/Reactor_Timer_Interface.h: + * ace/Read_Buffer.cpp: + * ace/Recursive_Thread_Mutex.{h,cpp}: + * ace/Refcounted_Auto_Ptr.h: + * ace/Registry.{h,cpp}: + * ace/Registry_Name_Space.h: + * ace/Remote_Name_Space.cpp: + * ace/SOCK.{h,i}: + * ace/SOCK_Acceptor.cpp: + * ace/SOCK_Dgram.{h,cpp}: + * ace/SOCK_Dgram_Bcast.cpp: + * ace/SOCK_Dgram_Mcast.cpp: + * ace/SOCK_IO.cpp: + * ace/SOCK_SEQPACK_Acceptor.cpp: + * ace/SOCK_SEQPACK_Association.cpp: + * ace/SPIPE.cpp: + * ace/SPIPE_Acceptor.cpp: + * ace/SPIPE_Addr.cpp: + * ace/SPIPE_Addr.h: + * ace/SPIPE_Connector.cpp: + * ace/SPIPE_Stream.i: + * ace/SString.{h,cpp}: + * ace/SV_Message.{h,i}: + * ace/SV_Message_Queue.{h,i}: + * ace/SV_Semaphore_Simple.{h,i}: + * ace/SV_Shared_Memory.{h,i}: + * ace/Sample_History.cpp: + * ace/Sched_Params.{h,cpp}: + * ace/Select_Reactor_T.cpp: + * ace/Semaphore.{h,inl,cpp}: + * ace/Service_Config.cpp: + * ace/Service_Manager.cpp: + * ace/Service_Repository.cpp: + * ace/Service_Types.cpp: + * ace/Shared_Memory.h: + * ace/Shared_Memory_SV.i: + * ace/Signal.{h,i}: + * ace/Singleton.h: + * ace/Sock_Connect.cpp: + * ace/Stats.{h,cpp}: + * ace/Stream_Modules.cpp: + * ace/String_Base.{h,i,cpp}: + * ace/System_Time.{h,cpp}: + * ace/TLI.{h,cpp}: + * ace/TLI_Acceptor.{h,cpp}: + * ace/TLI_Connector.cpp: + * ace/TLI_Stream.h: + * ace/TSS_T.cpp: + * ace/TTY_IO.{h.cpp}: + * ace/Task_T.i: + * ace/Thread.{h,i}: + * ace/Thread_Adapter.cpp: + * ace/Thread_Control.h: + * ace/Thread_Hook.cpp: + * ace/Thread_Manager.h: + * ace/Thread_Mutex.{h,cpp}: + * ace/Time_Value.inl: + * ace/Timeprobe.{h,cpp}: + * ace/Timeprobe_T.{h,cpp}: + * ace/Timer_Heap_T.cpp: + * ace/Timer_Queue_Adapters.cpp: + * ace/Timer_Queue_T.cpp: + * ace/Token.{h,i}: + * ace/Trace.cpp: + * ace/UNIX_Addr.i: + * ace/UUID.{h,cpp}: + * ace/Unbounded_Set.h: + * ace/WFMO_Reactor.cpp: + * ace/WIN32_Asynch_IO.cpp: + * ace/WIN32_Asynch_IO.h: + * ace/WIN32_Proactor.{h,cpp}: + * ace/gethrtime.cpp: + * ace/RMCast/RMCast.h: + * ace/RMCast/RMCast_Copy_On_Write.{h,i}}: + * ace/RMCast/RMCast_IO_UDP.{h,cpp}: + * ace/RMCast/RMCast_Membership.{h,cpp}: + * ace/RMCast/RMCast_Reassembly.h: + * ace/RMCast/RMCast_Reordering.h: + * ace/RMCast/RMCast_Sequencer.{h,cpp}: + * ace/RMCast/RMCast_UDP_Proxy.cpp: + * apps/Gateway/Gateway/Connection_Handler_Connector.cpp: + * apps/Gateway/Gateway/Event.h: + * apps/Gateway/Gateway/Event_Channel.cpp: + * apps/Gateway/Gateway/Event_Forwarding_Discriminator.h: + * apps/Gateway/Gateway/File_Parser.{h,cpp}: + * apps/Gateway/Gateway/Gateway.h: + * apps/Gateway/Gateway/Options.{h,cpp}: + * apps/Gateway/Peer/Options.cpp: + * apps/JAWS/clients/Blobby/Blob.{h,cpp}: + * apps/JAWS/clients/Blobby/Blob_Handler.{h,cpp}: + * apps/JAWS/clients/Blobby/blobby.cpp: + * apps/JAWS/clients/Caching/URL_Properties.cpp: + * apps/JAWS/server/HTTP_Config.cpp: + * apps/JAWS/server/HTTP_Handler.cpp: + * apps/JAWS/server/HTTP_Helpers.cpp: + * apps/JAWS/server/HTTP_Helpers.h: + * apps/JAWS/server/HTTP_Request.cpp: + * apps/JAWS/server/HTTP_Request.h: + * apps/JAWS/server/HTTP_Response.cpp: + * apps/JAWS/server/HTTP_Server.h: + * apps/JAWS/server/IO.cpp: + * apps/JAWS/server/Parse_Headers.{h,cpp}: + * apps/JAWS/server/main.cpp: + * apps/JAWS/stress_testing/global.h: + * apps/JAWS2/HTTP_10_Write.cpp: + * apps/JAWS2/HTTPU/http_export.h: + * apps/JAWS2/HTTPU/parse_http_request.h: + * apps/JAWS2/HTTPU/parse_http_response.cpp: + * apps/JAWS2/HTTPU/parse_http_response.h: + * apps/JAWS2/HTTPU/parse_url.cpp: + * apps/JAWS2/JAWS/Cache_Hash_T.h: + * apps/JAWS2/JAWS/Cache_Manager.cpp: + * apps/JAWS2/JAWS/Cache_Manager.h: + * apps/JAWS2/JAWS/Cache_Object.{h,cpp}: + * apps/JAWS2/JAWS/Export.h: + * apps/JAWS2/JAWS/FILE.{h,cpp}: + * apps/JAWS2/JAWS/Filecache.{h,cpp}: + * apps/JAWS2/JAWS/Headers.cpp: + * apps/drwho/BS_Client.cpp: + * apps/drwho/BS_Server.cpp: + * apps/drwho/Binary_Search.cpp: + * apps/drwho/CM_Client.{h,cpp}: + * apps/drwho/CM_Server.cpp: + * apps/drwho/Comm_Manager.h: + * apps/drwho/File_Manager.cpp: + * apps/drwho/HT_Client.cpp: + * apps/drwho/HT_Server.cpp: + * apps/drwho/Hash_Table.cpp: + * apps/drwho/Multicast_Manager.{h,cpp}: + * apps/drwho/Options.h: + * apps/drwho/PMC_All.cpp: + * apps/drwho/PMC_Flo.cpp: + * apps/drwho/PMC_Ruser.cpp: + * apps/drwho/PMC_Usr.cpp: + * apps/drwho/PMS_All.cpp: + * apps/drwho/PMS_Flo.cpp: + * apps/drwho/PMS_Ruser.cpp: + * apps/drwho/PMS_Usr.cpp: + * apps/drwho/PM_Client.cpp: + * apps/drwho/PM_Server.cpp: + * apps/drwho/Protocol_Manager.{h,cpp}: + * apps/drwho/Rwho_DB_Manager.cpp: + * apps/drwho/SL_Server.cpp: + * apps/drwho/SM_Client.cpp: + * apps/drwho/SM_Server.cpp: + * apps/drwho/client.cpp: + * apps/drwho/global.h: + * apps/drwho/server.cpp: + * apps/gperf/src/Bool_Array.cpp: + * apps/gperf/src/Gen_Perf.cpp: + * apps/gperf/src/Hash_Table.cpp: + * apps/gperf/src/Hash_Table.h: + * apps/gperf/src/Iterator.cpp: + * apps/gperf/src/Key_List.cpp: + * apps/gperf/src/List_Node.cpp: + * apps/gperf/src/Options.cpp: + * apps/gperf/src/Options.h: + * apps/gperf/src/Vectors.h: + * apps/gperf/src/gperf.cpp: + * apps/gperf/tests/test.cpp: + * apps/mkcsregdb/mkcsregdb.cpp: + * apps/soreduce/Library.cpp: + * apps/soreduce/Obj_Module.cpp: + * apps/soreduce/SO_Group.cpp: + * examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp: + * examples/ASX/Event_Server/Event_Server/Options.{h,cpp}: + * examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp: + * examples/ASX/Message_Queue/bounded_buffer.cpp: + * examples/ASX/Message_Queue/buffer_stream.cpp: + * examples/ASX/UPIPE_Event_Server/Options.{h,cpp}: + * examples/C++NPv1/Logging_Client.cpp: + * examples/C++NPv1/Logging_Handler.cpp: + * examples/C++NPv1/Logging_Server.cpp: + * examples/C++NPv1/Reactive_Logging_Server_Ex.h: + * examples/C++NPv2/AC_Client_Logging_Daemon.cpp: + * examples/C++NPv2/AIO_Client_Logging_Daemon.cpp: + * examples/C++NPv2/Client_Logging_Daemon.cpp: + * examples/C++NPv2/Configurable_Logging_Server.cpp: + * examples/C++NPv2/Logging_Event_Handler.cpp: + * examples/C++NPv2/Logging_Handler.cpp: + * examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp: + * examples/C++NPv2/SR_Configurable_Logging_Server.cpp: + * examples/C++NPv2/Select_Reactor_Logging_Server.cpp: + * examples/C++NPv2/Server_Shutdown.cpp: + * examples/C++NPv2/Service_Reporter.cpp: + * examples/C++NPv2/TPC_Logging_Server.cpp: + * examples/C++NPv2/TP_Logging_Server.cpp: + * examples/C++NPv2/TP_Logging_Server.h: + * examples/C++NPv2/TP_Reactor_Logging_Server.cpp: + * examples/C++NPv2/WFMO_Reactor_Logging_Server.cpp: + * examples/C++NPv2/display_logfile.cpp: + * examples/DLL/Newsweek.{h,cpp}: + * examples/DLL/Today.{h,cpp}: + * examples/IPC_SAP/ATM_SAP/CPP-client.cpp: + * examples/IPC_SAP/ATM_SAP/CPP-server.cpp: + * examples/IPC_SAP/DEV_SAP/reader/reader.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp: + * examples/IPC_SAP/FILE_SAP/client.cpp: + * examples/IPC_SAP/SOCK_SAP/C-inclient.cpp: + * examples/IPC_SAP/SOCK_SAP/C-inserver.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-inclient.h: + * examples/IPC_SAP/SOCK_SAP/CPP-inserver-fancy.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp: + * examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp: + * examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp: + * examples/IPC_SAP/SPIPE_SAP/NPClient.cpp: + * examples/IPC_SAP/SPIPE_SAP/NPServer.cpp: + * examples/IPC_SAP/SPIPE_SAP/client.cpp: + * examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp: + * examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp: + * examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp: + * examples/IPC_SAP/SPIPE_SAP/producer_read.cpp: + * examples/IPC_SAP/SPIPE_SAP/server.cpp: + * examples/IPC_SAP/SPIPE_SAP/shared.h: + * examples/IPC_SAP/SSL_SAP/SSL-client-simple.h: + * examples/IPC_SAP/SSL_SAP/SSL-client.h: + * examples/IPC_SAP/TLI_SAP/CPP-client.cpp: + * examples/IPC_SAP/TLI_SAP/CPP-server.cpp: + * examples/IPC_SAP/TLI_SAP/db-client.cpp: + * examples/IPC_SAP/TLI_SAP/ftp-client.cpp: + * examples/IPC_SAP/UPIPE_SAP/ex1.cpp: + * examples/IPC_SAP/UPIPE_SAP/ex2.cpp: + * examples/IPC_SAP/UPIPE_SAP/ex3.cpp: + * examples/Log_Msg/test_callback.cpp: + * examples/Log_Msg/test_log_msg.cpp: + * examples/Log_Msg/test_ostream.cpp: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.cpp: + * examples/Logger/Acceptor-server/server_loggerd.h: + * examples/Logger/client/logging_app.cpp: + * examples/Logger/simple-server/Logging_Handler.h: + * examples/Map_Manager/test_hash_map_manager.cpp: + * examples/Mem_Map/IO-tests/IO_Test.cpp: + * examples/Mem_Map/IO-tests/test_io.cpp: + * examples/Mem_Map/file-reverse/file-reverse.cpp: + * examples/Misc/test_XtReactor1.cpp,: + * examples/Misc/test_XtReactor2.cpp: + * examples/Misc/test_dump.{h,cpp}: + * examples/Misc/test_get_opt.cpp: + * examples/Misc/test_profile_timer.cpp: + * examples/Misc/test_read_buffer.cpp: + * examples/Misc/test_set.cpp: + * examples/Misc/test_sstring.cpp: + * examples/Misc/test_trace.cpp: + * examples/NT_Service/ntsvc.cpp: + * examples/Naming/test_multiple_contexts.cpp: + * examples/Naming/test_non_existent.cpp: + * examples/Naming/test_open.cpp: + * examples/Naming/test_writers.cpp: + * examples/OS/Process/imore.cpp: + * examples/OS/Process/process.cpp: + * examples/QOS/Change_Receiver_FlowSpec/Fill_ACE_QoS.h: + * examples/QOS/Change_Receiver_FlowSpec/QoS_Util.cpp: + * examples/QOS/Change_Receiver_FlowSpec/Sender_QoS_Event_Handler.cpp: + * examples/QOS/Change_Receiver_FlowSpec/receiver.cpp: + * examples/QOS/Change_Receiver_FlowSpec/sender.cpp: + * examples/QOS/Change_Sender_TSpec/Fill_ACE_QoS.h: + * examples/QOS/Change_Sender_TSpec/QoS_Util.cpp: + * examples/QOS/Change_Sender_TSpec/Sender_QoS_Event_Handler.cpp: + * examples/QOS/Change_Sender_TSpec/receiver.cpp: + * examples/QOS/Change_Sender_TSpec/sender.cpp: + * examples/QOS/Simple/Fill_ACE_QoS.h: + * examples/QOS/Simple/QoS_Util.cpp: + * examples/QOS/Simple/Sender_QoS_Event_Handler.cpp: + * examples/QOS/Simple/receiver.cpp: + * examples/QOS/Simple/sender.cpp: + * examples/RMCast/Send_File/Receiver.cpp: + * examples/RMCast/Send_File/Sender.cpp: + * examples/Reactor/Dgram/CODgram.cpp: + * examples/Reactor/Dgram/Dgram.cpp: + * examples/Reactor/Misc/pingpong.cpp: + * examples/Reactor/Misc/test_early_timeouts.cpp: + * examples/Reactor/Misc/test_time_value.cpp: + * examples/Reactor/Multicast/Log_Wrapper.cpp: + * examples/Reactor/Multicast/client.cpp: + * examples/Reactor/Multicast/server.cpp: + * examples/Reactor/Ntalker/ntalker.cpp: + * examples/Reactor/Proactor/post_completions.cpp: + * examples/Reactor/Proactor/test_aiocb_ace.cpp: + * examples/Reactor/Proactor/test_cancel.cpp: + * examples/Reactor/Proactor/test_end_event_loop.cpp: + * examples/Reactor/Proactor/test_proactor.cpp: + * examples/Reactor/Proactor/test_timeout.cpp: + * examples/Reactor/Proactor/test_udp_proactor.cpp: + * examples/Reactor/WFMO_Reactor/APC.cpp: + * examples/Reactor/WFMO_Reactor/Abandoned.cpp: + * examples/Reactor/WFMO_Reactor/Directory_Changes.cpp: + * examples/Reactor/WFMO_Reactor/Exceptions.cpp: + * examples/Reactor/WFMO_Reactor/Multithreading.cpp: + * examples/Reactor/WFMO_Reactor/Registration.cpp: + * examples/Reactor/WFMO_Reactor/Registry_Changes.cpp: + * examples/Reactor/WFMO_Reactor/Removals.cpp: + * examples/Reactor/WFMO_Reactor/Suspended_Removals.cpp: + * examples/Reactor/WFMO_Reactor/Talker.cpp: + * examples/Reactor/WFMO_Reactor/Timeouts.cpp: + * examples/Reactor/WFMO_Reactor/Window_Messages.cpp: + * examples/Registry/test_registry_iterator.cpp: + * examples/Registry/test_registry_update.cpp: + * examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp: + * examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i: + * examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i: + * examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i: + * examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i: + * examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i: + * examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i: + * examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i: + * examples/Service_Configurator/Misc/main.cpp: + * examples/Shared_Malloc/Options.cpp: + * examples/Shared_Malloc/Options.h: + * examples/Shared_Malloc/test_malloc.cpp: + * examples/Shared_Memory/test_MM.cpp: + * examples/Shared_Memory/test_SV.cpp: + * examples/Smart_Pointers/Widget_Part_Impl.cpp: + * examples/Smart_Pointers/gadget_test.cpp: + * examples/Smart_Pointers/widget_test.cpp: + * examples/Synch/proc_sema.cpp: + * examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp: + * examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp: + * examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp: + * examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp: + * examples/System_V_IPC/SV_Message_Queues/test.h: + * examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp: + * examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h: + * examples/Threads/auto_event.cpp: + * examples/Threads/barrier1.cpp: + * examples/Threads/barrier2.cpp: + * examples/Threads/cancel.cpp: + * examples/Threads/future1.cpp: + * examples/Threads/future2.cpp: + * examples/Threads/manual_event.cpp: + * examples/Threads/process_manager.cpp: + * examples/Threads/process_mutex.cpp: + * examples/Threads/process_semaphore.cpp: + * examples/Threads/reader_writer.cpp: + * examples/Threads/recursive_mutex.cpp: + * examples/Threads/task_five.cpp: + * examples/Threads/task_four.cpp: + * examples/Threads/task_one.cpp: + * examples/Threads/task_three.cpp: + * examples/Threads/task_two.cpp: + * examples/Threads/thread_manager.cpp: + * examples/Threads/thread_pool.cpp: + * examples/Threads/thread_specific.cpp: + * examples/Threads/token.cpp: + * examples/Threads/tss1.cpp: + * examples/Threads/tss2.cpp:: + * examples/Timer_Queue/main_async.cpp: + * examples/Timer_Queue/main_reactor.cpp: + * examples/Timer_Queue/main_thread.cpp: + * examples/Web_Crawler/Options.cpp: + * examples/Web_Crawler/Options.h: + * examples/Web_Crawler/URL_Addr.cpp: + * examples/Web_Crawler/URL_Status.h: + * netsvcs/clients/Logger/direct_logging.cpp: + * netsvcs/clients/Logger/indirect_logging.cpp: + * netsvcs/clients/Naming/Client/Client_Test.cpp: + * netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp: + * netsvcs/clients/Tokens/collection/collection.cpp: + * netsvcs/clients/Tokens/collection/rw_locks.cpp: + * netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp: + * netsvcs/clients/Tokens/invariant/invariant.cpp: + * netsvcs/clients/Tokens/manual/manual.cpp: + * netsvcs/clients/Tokens/mutex/test_mutex.cpp: + * netsvcs/clients/Tokens/rw_lock/rw_locks.cpp: + * netsvcs/lib/Base_Optimizer.h: + * netsvcs/lib/Log_Message_Receiver.h: + * netsvcs/lib/Server_Logging_Handler.h: + * netsvcs/lib/Server_Logging_Handler_T.cpp: + * netsvcs/lib/TS_Clerk_Handler.cpp: + * netsvcs/lib/TS_Server_Handler.cpp: + * performance-tests/Misc/basic_perf.cpp: + * performance-tests/Misc/childbirth_time.cpp: + * performance-tests/Misc/context_switch_time.cpp: + * performance-tests/Misc/preempt.cpp: + * performance-tests/Misc/test_mutex.cpp: + * performance-tests/Misc/test_naming.cpp: + * performance-tests/Misc/test_singleton.cpp: + * performance-tests/SCTP/Options_Manager.cpp: + * performance-tests/SCTP/SOCK_SEQPACK_Association_Test.cpp: + * performance-tests/SCTP/SOCK_SEQPACK_clt.cpp: + * performance-tests/SCTP/SOCK_SEQPACK_srv.cpp: + * performance-tests/SCTP/SOCK_STREAM_clt.cpp: + * performance-tests/SCTP/SOCK_STREAM_srv.cpp: + * performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.cpp: + * performance-tests/Server_Concurrency/Leader_Follower/leader_follower.cpp: + * performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.cpp: + * performance-tests/Server_Concurrency/Queue_Based_Workers/workers.cpp: + * performance-tests/Synch-Benchmarks/Perf_Test/Performance_Test_Options.h: + * performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h: + * performance-tests/TCP/tcp_test.cpp: + * performance-tests/UDP/udp_test.cpp: + * tests/Aio_Platform_Test.cpp: + * tests/Auto_IncDec_Test.cpp: + * tests/Barrier_Test.cpp: + * tests/Basic_Types_Test.cpp: + * tests/Buffer_Stream_Test.cpp: + * tests/CE_fostream.h: + * tests/Cache_Map_Manager_Test.cpp: + * tests/Config_Test.cpp: + * tests/Conn_Test.cpp: + * tests/DLL_Test.cpp: + * tests/DLL_Test_Impl.cpp: + * tests/DLL_Test_Impl.h: + * tests/Dirent_Test.cpp: + * tests/Enum_Interfaces_Test.cpp: + * tests/Env_Value_Test.cpp: + * tests/FIFO_Test.cpp: + * tests/Framework_Component_DLL.cpp: + * tests/Hash_Map_Bucket_Iterator_Test.cpp: + * tests/Hash_Map_Manager_Test.cpp: + * tests/High_Res_Timer_Test.cpp: + * tests/INET_Addr_Test.cpp: + * tests/Logging_Strategy_Test.cpp: + * tests/MEM_Stream_Test.cpp: + * tests/MEM_Stream_Test.h: + * tests/MM_Shared_Memory_Test.cpp: + * tests/MT_Reactor_Upcall_Test.cpp: + * tests/MT_Reference_Counted_Event_Handler_Test.cpp: + * tests/MT_SOCK_Test.cpp: + * tests/Main.cpp: + * tests/Map_Test.{h,cpp}: + * tests/Max_Default_Port_Test.cpp: + * tests/Mem_Map_Test.cpp: + * tests/Message_Queue_Notifications_Test.cpp: + * tests/Message_Queue_Test.cpp: + * tests/Message_Queue_Test_Ex.{h,cpp}: + * tests/Multicast_Test.cpp: + * tests/Multihomed_INET_Addr_Test.cpp: + * tests/Naming_Test.cpp: + * tests/New_Fail_Test.cpp: + * tests/OS_Test.cpp: + * tests/Obstack_Test.cpp: + * tests/Pipe_Test.cpp: + * tests/Priority_Task_Test.cpp: + * tests/Proactor_Test.cpp: + * tests/Process_Mutex_Test.cpp: + * tests/Process_Strategy_Test.cpp: + * tests/RB_Tree_Test.cpp: + * tests/Reactor_Notify_Test.cpp: + * tests/Reader_Writer_Test.cpp: + * tests/Reverse_Lock_Test.cpp: + * tests/SOCK_Connector_Test.cpp: + * tests/SOCK_Send_Recv_Test.cpp: + * tests/SOCK_Test.cpp: + * tests/SPIPE_Test.cpp: + * tests/Semaphore_Test.cpp: + * tests/Signal_Test.cpp: + * tests/Sigset_Ops_Test.cpp: + * tests/Simple_Message_Block_Test.cpp: + * tests/TP_Reactor_Test.{h,cpp}: + * tests/TSS_Test.cpp: + * tests/Test_Output.cpp: + * tests/Thread_Manager_Test.cpp: + * tests/Thread_Mutex_Test.cpp: + * tests/Thread_Pool_Reactor_Resume_Test.cpp: + * tests/Thread_Pool_Reactor_Test.cpp: + * tests/Thread_Pool_Test.cpp: + * tests/Time_Service_Test.cpp: + * tests/Timeprobe_Test.cpp: + * tests/Timer_Queue_Reference_Counting_Test.cpp: + * tests/Timer_Queue_Test.cpp: + * tests/Upgradable_RW_Test.h: + * tests/RMCast/Main.cpp: + * tests/RMCast/RMCast_Fragment_Test.cpp: + * tests/RMCast/RMCast_Membership_Test.cpp: + * tests/RMCast/RMCast_Reassembly_Test.cpp: + * tests/RMCast/RMCast_Reordering_Test.cpp: + * tests/RMCast/RMCast_Retransmission_Test.cpp: + * tests/SSL/Main.cpp: + * websvcs/lib/URL_Addr.cpp: + * websvcs/lib/URL_Addr.i + Removed OS.h and refactored #includes due to above subsetting; + changed occurances of ACE_OS_String and ACE_OS_Dirent to + ACE_OS; changes u_long, etc., to unsigned long to reduce + dependencies; reordered includes in *.cpp's to come after the + inline file include, reducing the difference between inlined and + non-inlined builds. + + * ace/CLASSIX/CLASSIX_OS.h: + * ace/CLASSIX/CLASSIX_Port_Core.h: + Removed #include OS.h from these files, but didn't add new + headers since it isn't regularly compiled. + + * ACEXML/parser/parser/ParserContext.cpp: + Added template instantiation for ACE_Swap. + Fri Oct 31 14:29:07 2003 Edward R. Mulholland <emulholl@atl.lmco.com> * performance-tests/SCTP/run_spectrum.pl: @@ -199,7 +1047,7 @@ Mon Oct 27 11:17:03 2003 Gautam Thaker <gthaker@atl.lmco.com> Fixed a previously made change that was using sizes for tests as n**2 rather than 2**n! -Sat Oct 25 10:51:23 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl> +Fat Oct 25 10:51:23 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl> * ace/config-win32-common.h: Fixed compile problem in this file diff --git a/Kokyu/Dispatcher_Task.cpp b/Kokyu/Dispatcher_Task.cpp index 8002d3a581d..e6d86711865 100644 --- a/Kokyu/Dispatcher_Task.cpp +++ b/Kokyu/Dispatcher_Task.cpp @@ -4,6 +4,7 @@ #include "ace/Malloc_T.h" #include "ace/Synch_T.h" +#include "ace/OS_NS_errno.h" #if ! defined (__ACE_INLINE__) #include "Dispatcher_Task.i" diff --git a/Kokyu/tests/DSRT_MIF/MIF.cpp b/Kokyu/tests/DSRT_MIF/MIF.cpp index 276271d3b62..18f96b54af4 100644 --- a/Kokyu/tests/DSRT_MIF/MIF.cpp +++ b/Kokyu/tests/DSRT_MIF/MIF.cpp @@ -6,6 +6,7 @@ #include "ace/Atomic_Op.h" #include "ace/Synch.h" #include "ace/High_Res_Timer.h" +#include "ace/Barrier.h" #include "Kokyu_dsrt.h" diff --git a/Kokyu/tests/EDF/test.cpp b/Kokyu/tests/EDF/test.cpp index 7844f4cbf4a..239b0e2dcbb 100644 --- a/Kokyu/tests/EDF/test.cpp +++ b/Kokyu/tests/EDF/test.cpp @@ -7,6 +7,7 @@ #include "ace/Sched_Params.h" #include "ace/SString.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_strings.h" ACE_CString sched_policy_str = "fifo"; diff --git a/Kokyu/tests/FIFO/test.cpp b/Kokyu/tests/FIFO/test.cpp index c61f14fdcfd..6669062ff33 100644 --- a/Kokyu/tests/FIFO/test.cpp +++ b/Kokyu/tests/FIFO/test.cpp @@ -6,6 +6,7 @@ #include "ace/Task.h" #include "ace/SString.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_strings.h" ACE_CString sched_policy_str = "fifo"; diff --git a/TAO/CIAO/tools/XML_Helpers/main.cpp b/TAO/CIAO/tools/XML_Helpers/main.cpp index 46fda5db00c..bf9208865ce 100644 --- a/TAO/CIAO/tools/XML_Helpers/main.cpp +++ b/TAO/CIAO/tools/XML_Helpers/main.cpp @@ -3,6 +3,7 @@ #include "XML_Utils.h" #include "ace/Get_Opt.h" #include "ace/Auto_Ptr.h" +#include "ace/OS_main.h" int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index bbb3ae6ff4c..8e975428907 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,202 @@ +Sat Nov 1 05:40:21 UTC 2003 Don Hinton <dhinton@dresystems.com> + + * examples/Buffered_Oneways/server.cpp: + * examples/Content_Server/AMI_Iterator/Iterator_Factory_i.{h,cpp}: + * examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.{h,cpp}: + * examples/Content_Server/SMI_Iterator/Iterator_Factory_i.{h,cpp}: + * examples/Load_Balancing/Identity_Server.cpp: + * examples/Load_Balancing/Load_Balancer_i.cpp: + * examples/Load_Balancing_persistent/Identity_Server.cpp: + * examples/POA/Adapter_Activator/server.cpp: + * examples/POA/DSI/client.cpp: + * examples/POA/Default_Servant/File_i.cpp: + * examples/POA/Default_Servant/server.cpp: + * examples/POA/Explicit_Activation/server.cpp: + * examples/POA/Forwarding/server.cpp: + * examples/POA/Loader/Server_Manager.cpp: + * examples/POA/On_Demand_Activation/server.cpp: + * examples/POA/Reference_Counted_Servant/server.cpp: + * examples/POA/TIE/server.cpp: + * examples/Persistent_Grid/Simple_util.cpp: + * examples/Simple/Simple_util.cpp: + * examples/Simple/chat/Server_i.cpp: + * examples/Simple/time/Time_Client_i.cpp: + * examples/Simple/time/Time_i.cpp: + * examples/Simple/time-date/Time_Date_i.cpp: + * orbsvcs/Concurrency_Service/Concurrency_Service.cpp: + * orbsvcs/CosEvent_Service/CosEvent_Service.cpp: + * orbsvcs/Dump_Schedule/Dump_Schedule.cpp: + * orbsvcs/Event_Service/Event_Service.cpp: + * orbsvcs/FTRT_Event_Service/Event_Service/FT_EventService.cpp: + * orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp: + * orbsvcs/ImplRepo_Service/Repository_Configuration.cpp: + * orbsvcs/ImplRepo_Service/tao_imr.cpp: + * orbsvcs/ImplRepo_Service/tao_imr_i.cpp: + * orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp: + * orbsvcs/LoadBalancer/LoadManager.cpp: + * orbsvcs/LoadBalancer/LoadMonitor.cpp: + * orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp: + * orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp: + * orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp: + * orbsvcs/Logging_Service/RTEvent_Logging_Service/RTEvent_Logging_Service.cpp: + * orbsvcs/Notify_Service/Notify_Server.cpp: + * orbsvcs/Time_Service/Clerk_i.cpp: + * orbsvcs/Scheduling_Service/Scheduling_Service.cpp: + * orbsvcs/Time_Service/Server_i.cpp: + * orbsvcs/Time_Service/Time_Service_Clerk.cpp: + * orbsvcs/Time_Service/Time_Service_Server.cpp: + * orbsvcs/Trading_Service/Trading_Server.cpp: + * orbsvcs/examples/CosEC/Simple/Service.cpp: + * orbsvcs/examples/Log/Basic/main.cpp: + * orbsvcs/examples/Log/Event/Event_Consumer.cpp: + * orbsvcs/examples/Log/Event/Event_Supplier.cpp: + * orbsvcs/examples/Log/Notify/Notify_Consumer.cpp: + * orbsvcs/examples/Log/Notify/Notify_Supplier.cpp: + * orbsvcs/examples/Log/RTEvent/RTEvent_Consumer.cpp: + * orbsvcs/examples/Log/RTEvent/RTEvent_Supplier.cpp: + * orbsvcs/examples/Notify/ThreadPool/Consumer.cpp: + * orbsvcs/examples/Notify/ThreadPool/Consumer.h: + * orbsvcs/examples/ORT/gateway_server.cpp: + * orbsvcs/examples/ORT/server.cpp: + * orbsvcs/examples/RtEC/Simple/Service.cpp: + * orbsvcs/orbsvcs/Time_Utilities.h: + * orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp: + * orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp: + * orbsvcs/orbsvcs/LoadBalancing/LB_Random.cpp: + * orbsvcs/orbsvcs/Naming/Flat_File_Persistence.cpp: + * orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp: + * orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp: + * orbsvcs/orbsvcs/PortableGroup/UIPMC_Endpoint.cpp: + * orbsvcs/orbsvcs/Trader/Offer_Database.cpp: + * orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp: + * orbsvcs/tests/Concurrency/CC_client.cpp: + * orbsvcs/tests/Concurrency/CC_command.tab.cpp: + * orbsvcs/tests/EC_Custom_Marshal/ECM_Consumer.h: + * orbsvcs/tests/EC_Throughput/ECT_Consumer.h: + * orbsvcs/tests/Event/lib/Consumer.h: + * orbsvcs/tests/Event/lib/Supplier.h: + * orbsvcs/tests/FaultTolerance/GroupRef_Manipulation/server.cpp: + * orbsvcs/tests/FaultTolerance/IOGR/Manager.cpp: + * orbsvcs/tests/FaultTolerance/IOGR/server.cpp: + * orbsvcs/tests/ImplRepo/airplane_i.cpp: + * orbsvcs/tests/ImplRepo/airplane_server_i.cpp: + * orbsvcs/tests/ImplRepo/nestea_i.cpp: + * orbsvcs/tests/ImplRepo/nestea_server_i.cpp: + * orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp: + * orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp: + * orbsvcs/tests/Log/Basic_Log_Test/client.cpp: + * orbsvcs/tests/Miop/McastHello/server.cpp: + * orbsvcs/tests/Notify/Blocking/common.cpp: + * orbsvcs/tests/Notify/Discarding/common.cpp: + * orbsvcs/tests/Notify/Driver/main.cpp: + * orbsvcs/tests/Notify/Ordering/Sequence_Consumer.cpp: + * orbsvcs/tests/Notify/Ordering/Structured_Consumer.cpp: + * orbsvcs/tests/Notify/Ordering/common.cpp: + * orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/common.cpp: + * orbsvcs/tests/Notify/Sequence_Multi_Filter/common.cpp: + * orbsvcs/tests/Notify/performance-tests/Filter/common.cpp: + * orbsvcs/tests/RTCosScheduling/client.cpp: + * orbsvcs/tests/Redundant_Naming/client.cpp: + * orbsvcs/tests/Trading/Offer_Exporter.cpp: + * orbsvcs/tests/Trading/TT_Info.cpp: + * performance-tests/Callback/Callback_i.cpp: + * performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Client.cpp: + * performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Server.cpp: + * performance-tests/Latency/AMI/Roundtrip_Handler.cpp: + * performance-tests/Latency/Thread_Per_Connection/Client_Task.cpp: + * performance-tests/Latency/Thread_Pool/Client_Task.cpp: + * performance-tests/Memory/IORsize/server.cpp: + * performance-tests/Memory/Single_Threaded/server.cpp: + * performance-tests/POA/Create_Reference/create_reference.cpp: + * performance-tests/POA/Demux/demux_test_client.cpp: + * performance-tests/POA/Demux/demux_test_server.cpp: + * performance-tests/POA/Implicit_Activation/server.cpp: + * performance-tests/Pluggable/PP_Test_Client.cpp: + * performance-tests/Pluggable/PP_Test_Server.cpp: + * performance-tests/RTCorba/Multiple_Endpoints/Single_Endpoint/server.cpp: + * performance-tests/RTCorba/Oneways/Reliable/server.cpp: + * performance-tests/Sequence_Latency/AMI/Roundtrip_Handler.cpp: + * performance-tests/Sequence_Latency/Thread_Per_Connection/Client_Task.cpp: + * performance-tests/Sequence_Latency/Thread_Pool/Client_Task.cpp: + * performance-tests/Throughput/Receiver.h: + * tao/Exception.cpp: + * tao/FILE_Parser.cpp: + * tao/IIOP_Connection_Handler.cpp: + * tao/IIOP_Endpoint.cpp: + * tao/Synch_Refcountable.inl: + * tao/default_client.cpp: + * tao/default_server.cpp: + * tao/PortableServer/Operation_Table.h: + * tao/Strategies/SHMIOP_Connection_Handler.cpp: + * tests/BiDirectional/server.cpp: + * tests/BiDirectional_NestedUpcall/server.cpp: + * tests/Big_Oneways/server.cpp: + * tests/Big_Reply/server.cpp: + * tests/Big_Request_Muxing/server.cpp: + * tests/Big_Twoways/server.cpp: + * tests/Blocking_Sync_None/server.cpp: + * tests/CDR/growth.cpp: + * tests/Cache_Growth_Test/server.cpp: + * tests/Connect_Strategy_Test/server.cpp: + * tests/Explicit_Event_Loop/server.cpp: + * tests/Exposed_Policies/Policy_Tester.cpp: + * tests/Faults/middle.cpp: + * tests/Faults/ping.cpp: + * tests/Faults/server.cpp: + * tests/File_IO/File_i.cpp: + * tests/Forwarding/server.cpp: + * tests/Hello/server.cpp: + * tests/InterOp-Naming/Server_i.cpp: + * tests/MProfile/server.cpp: + * tests/MProfile_Connection_Timeout/server.cpp: + * tests/MProfile_Forwarding/Manager.cpp: + * tests/MProfile_Forwarding/server.cpp: + * tests/MT_Client/server.cpp: + * tests/Multiple/server.cpp: + * tests/Multiple_Inheritance/client.cpp: + * tests/Multiple_Inheritance/server.cpp: + * tests/Native_Exceptions/server.cpp: + * tests/NestedUpcall/MT_Client_Test/server.cpp: + * tests/NestedUpcall/Triangle_Test/initiator.cpp: + * tests/NestedUpcall/Triangle_Test/server_A.cpp: + * tests/NestedUpcall/Triangle_Test/server_B.cpp: + * tests/No_Server_MT_Connect_Test/server.cpp: + * tests/ORT/server.cpp: + * tests/Object_Loader/driver.cpp: + * tests/Objref_Sequence_Test/server.cpp: + * tests/OctetSeq/client.cpp: + * tests/OctetSeq/server.cpp: + * tests/Oneway_Buffering/admin.cpp: + * tests/Oneway_Buffering/server.cpp: + * tests/POA/Persistent_ID/server.cpp: + * tests/Param_Test/param_test_i.cpp: + * tests/Param_Test/server.cpp: + * tests/Policies/Manipulation.cpp: + * tests/Portable_Interceptors/Benchmark/server.cpp: + * tests/Portable_Interceptors/Dynamic/server.cpp: + * tests/Portable_Interceptors/ForwardRequest/server.cpp: + * tests/Portable_Interceptors/IORInterceptor/server.cpp: + * tests/Portable_Interceptors/PICurrent/server.cpp: + * tests/Portable_Interceptors/Request_Interceptor_Flow/server.cpp: + * tests/Portable_Interceptors/Service_Context_Manipulation/server.cpp: + * tests/Queued_Message_Test/Queued_Message_Test.cpp: + * tests/RTCORBA/common_args.cpp: + * tests/RTCORBA/ORB_init/ORB_init.cpp: + * tests/RTCORBA/Persistent_IOR/server.cpp: + * tests/RTCORBA/Private_Connection/server.cpp: + * tests/Reliable_Oneways/server.cpp,: + * tests/Server_Connection_Purging/server.cpp: + * tests/Server_Leaks/server.cpp: + * tests/Single_Read/server.cpp: + * tests/Timed_Buffered_Oneways/server.cpp: + * tests/Timeout/server.cpp: + * utils/nslist/nslist.cpp: + Added #includes needed due to subsetting in ACE, e.g., + ace/OS_NS_stdio.h, ace/OS_NS_time.h, ace/OS_NS_sys_stat.h, + ace/OS_NS_fcntl.h, ace/OS_main.h, ace/OS_NS_netdb.h, + ace/os_include/netinet/os_tcp.h, ace/Guard_T.h, + ace/OS_NS_strings.h, ace/Synch_Traits.h, ace/Null_Mutex.h, + Fri Oct 31 14:42:09 2003 Edward R. Mulholland <emulholl@atl.lmco.com> * tao/Strategies/SCIOP_Acceptor.cpp: diff --git a/TAO/examples/Buffered_Oneways/server.cpp b/TAO/examples/Buffered_Oneways/server.cpp index 31d6a5a42af..3b900d8f8a3 100644 --- a/TAO/examples/Buffered_Oneways/server.cpp +++ b/TAO/examples/Buffered_Oneways/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Buffered_Oneways, server, "$Id$") diff --git a/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.cpp b/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.cpp index 50062c1baf1..4f9795c38e5 100644 --- a/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.cpp +++ b/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.cpp @@ -5,6 +5,7 @@ #include "Content_Iterator_i.h" #include "Iterator_Factory_i.h" +#include "ace/OS_NS_time.h" ACE_RCSID (AMI_Iterator, Iterator_Factory_i, "$Id$") diff --git a/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.h b/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.h index 93584967c63..9d8feb6e748 100644 --- a/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.h +++ b/TAO/examples/Content_Server/AMI_Iterator/Iterator_Factory_i.h @@ -26,6 +26,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/OS_NS_sys_stat.h" // Forward declarations class Content_Iterator_i; diff --git a/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.cpp b/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.cpp index ba648843736..e3bb8bce499 100644 --- a/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.cpp +++ b/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.cpp @@ -5,6 +5,7 @@ #include "Push_Iterator_Factory_i.h" #include "Callback_Handler.h" +#include "ace/OS_NS_time.h" ACE_RCSID (AMI_Observer, Push_Iterator_Factory_i, "$Id$") diff --git a/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.h b/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.h index b966aa4f110..684d13f8011 100644 --- a/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.h +++ b/TAO/examples/Content_Server/AMI_Observer/Push_Iterator_Factory_i.h @@ -26,6 +26,7 @@ #include "ace/FILE_Addr.h" #include "ace/FILE_IO.h" #include "Push_Web_ServerS.h" +#include "ace/OS_NS_sys_stat.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.cpp b/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.cpp index 9fc9c724f24..fb24de1b112 100644 --- a/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.cpp +++ b/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.cpp @@ -5,6 +5,7 @@ #include "Content_Iterator_i.h" #include "Iterator_Factory_i.h" +#include "ace/OS_NS_time.h" ACE_RCSID (SMI_Iterator, Iterator_Factory_i, "$Id$") diff --git a/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.h b/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.h index 5b879e0dd85..3e049f08fe3 100644 --- a/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.h +++ b/TAO/examples/Content_Server/SMI_Iterator/Iterator_Factory_i.h @@ -27,6 +27,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/OS_NS_sys_stat.h" // Forward declarations class Content_Iterator_i; diff --git a/TAO/examples/Load_Balancing/Identity_Server.cpp b/TAO/examples/Load_Balancing/Identity_Server.cpp index dfc94035395..638dd1e245b 100644 --- a/TAO/examples/Load_Balancing/Identity_Server.cpp +++ b/TAO/examples/Load_Balancing/Identity_Server.cpp @@ -16,6 +16,7 @@ #include "Identity_i.h" #include "tao/debug.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" Identity_Server::Identity_Server (void) : group_factory_ior_ (0), diff --git a/TAO/examples/Load_Balancing/Load_Balancer_i.cpp b/TAO/examples/Load_Balancing/Load_Balancer_i.cpp index b20bfd84af6..a0deab600c4 100644 --- a/TAO/examples/Load_Balancing/Load_Balancer_i.cpp +++ b/TAO/examples/Load_Balancing/Load_Balancer_i.cpp @@ -11,6 +11,7 @@ #include "Load_Balancer_i.h" #include "ace/Auto_Ptr.h" +#include "ace/OS_NS_time.h" Object_Group_Factory_i::Object_Group_Factory_i (void) { diff --git a/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp b/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp index 5b2aa19c32a..772a2092ada 100755 --- a/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp +++ b/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp @@ -4,6 +4,7 @@ #include "Identity_i.h" #include "tao/debug.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" Identity_Server::Identity_Server (void) : group_factory_ior_ (0), diff --git a/TAO/examples/POA/Adapter_Activator/server.cpp b/TAO/examples/POA/Adapter_Activator/server.cpp index e23b5baf027..32ec81d5659 100644 --- a/TAO/examples/POA/Adapter_Activator/server.cpp +++ b/TAO/examples/POA/Adapter_Activator/server.cpp @@ -24,6 +24,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Adapter_Activator, server, "$Id$") diff --git a/TAO/examples/POA/DSI/client.cpp b/TAO/examples/POA/DSI/client.cpp index dd15e2008f5..ca986a5d0ee 100644 --- a/TAO/examples/POA/DSI/client.cpp +++ b/TAO/examples/POA/DSI/client.cpp @@ -18,6 +18,7 @@ #include "ace/Get_Opt.h" #include "ace/Read_Buffer.h" #include "DatabaseC.h" +#include "ace/OS_NS_fcntl.h" ACE_RCSID(DSI, client, "$Id$") diff --git a/TAO/examples/POA/Default_Servant/File_i.cpp b/TAO/examples/POA/Default_Servant/File_i.cpp index 4cda27db3ba..739fb8a09a7 100644 --- a/TAO/examples/POA/Default_Servant/File_i.cpp +++ b/TAO/examples/POA/Default_Servant/File_i.cpp @@ -15,6 +15,8 @@ //==================================================================== #include "File_i.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_fcntl.h" ACE_RCSID(Default_Servant, File_i, "$Id$") diff --git a/TAO/examples/POA/Default_Servant/server.cpp b/TAO/examples/POA/Default_Servant/server.cpp index 3ff513b123c..be45c3a1297 100644 --- a/TAO/examples/POA/Default_Servant/server.cpp +++ b/TAO/examples/POA/Default_Servant/server.cpp @@ -20,6 +20,7 @@ #include "ace/streams.h" #include "ace/Get_Opt.h" #include "ace/SString.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Default_Servant, server, "$Id$") diff --git a/TAO/examples/POA/Explicit_Activation/server.cpp b/TAO/examples/POA/Explicit_Activation/server.cpp index 4a9e4b3ffdb..924ce3bd0f1 100644 --- a/TAO/examples/POA/Explicit_Activation/server.cpp +++ b/TAO/examples/POA/Explicit_Activation/server.cpp @@ -19,6 +19,7 @@ #include "ace/Get_Opt.h" #include "ace/SString.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Explicit_Activation, server, "$Id$") diff --git a/TAO/examples/POA/Forwarding/server.cpp b/TAO/examples/POA/Forwarding/server.cpp index c66591695a0..d51d2b542ac 100644 --- a/TAO/examples/POA/Forwarding/server.cpp +++ b/TAO/examples/POA/Forwarding/server.cpp @@ -20,6 +20,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" #include "Servant_Activator.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Forwarding, server, "$Id$") diff --git a/TAO/examples/POA/Loader/Server_Manager.cpp b/TAO/examples/POA/Loader/Server_Manager.cpp index 9b2b73623b0..295234488f7 100644 --- a/TAO/examples/POA/Loader/Server_Manager.cpp +++ b/TAO/examples/POA/Loader/Server_Manager.cpp @@ -2,6 +2,7 @@ #include "Server_Manager.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Loader, Server_Manager, "$Id$") diff --git a/TAO/examples/POA/On_Demand_Activation/server.cpp b/TAO/examples/POA/On_Demand_Activation/server.cpp index 760ae0a86e5..5f23837b0ca 100644 --- a/TAO/examples/POA/On_Demand_Activation/server.cpp +++ b/TAO/examples/POA/On_Demand_Activation/server.cpp @@ -18,6 +18,7 @@ #include "ace/SString.h" #include "Servant_Activator.h" #include "Servant_Locator.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(On_Demand_Activation, server, "$Id$") diff --git a/TAO/examples/POA/Reference_Counted_Servant/server.cpp b/TAO/examples/POA/Reference_Counted_Servant/server.cpp index 46e5d9857bb..95738b227c1 100644 --- a/TAO/examples/POA/Reference_Counted_Servant/server.cpp +++ b/TAO/examples/POA/Reference_Counted_Servant/server.cpp @@ -21,6 +21,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Reference_Counted_Servant, server, "$Id$") diff --git a/TAO/examples/POA/TIE/server.cpp b/TAO/examples/POA/TIE/server.cpp index 3405c25d5be..a0962ce6d95 100644 --- a/TAO/examples/POA/TIE/server.cpp +++ b/TAO/examples/POA/TIE/server.cpp @@ -17,6 +17,7 @@ #include "ace/streams.h" #include "ace/SString.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(TIE, server, "$Id$") diff --git a/TAO/examples/Persistent_Grid/Simple_util.cpp b/TAO/examples/Persistent_Grid/Simple_util.cpp index 02eacbebccd..8e2d65339b9 100644 --- a/TAO/examples/Persistent_Grid/Simple_util.cpp +++ b/TAO/examples/Persistent_Grid/Simple_util.cpp @@ -4,6 +4,7 @@ #define SIMPLE_UTIL_C # include "Simple_util.h" # include "tao/debug.h" +# include "ace/OS_NS_fcntl.h" // Constructor. diff --git a/TAO/examples/Simple/Simple_util.cpp b/TAO/examples/Simple/Simple_util.cpp index a7a8d5c6d63..d1bf5ed328e 100644 --- a/TAO/examples/Simple/Simple_util.cpp +++ b/TAO/examples/Simple/Simple_util.cpp @@ -6,6 +6,7 @@ #include "Simple_util.h" #include "tao/IORTable/IORTable.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" // Constructor. diff --git a/TAO/examples/Simple/chat/Server_i.cpp b/TAO/examples/Simple/chat/Server_i.cpp index 19552c68eac..208a440ad86 100644 --- a/TAO/examples/Simple/chat/Server_i.cpp +++ b/TAO/examples/Simple/chat/Server_i.cpp @@ -19,6 +19,7 @@ #include "Server_i.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" Server_i::Server_i () : ior_file_name_ ("chat.ior") diff --git a/TAO/examples/Simple/time-date/Time_Date_i.cpp b/TAO/examples/Simple/time-date/Time_Date_i.cpp index 2e30652be49..c960f5bccdb 100644 --- a/TAO/examples/Simple/time-date/Time_Date_i.cpp +++ b/TAO/examples/Simple/time-date/Time_Date_i.cpp @@ -2,6 +2,7 @@ // $Id$ #include "Time_Date_i.h" +#include "ace/OS_NS_time.h" // Default constructor. diff --git a/TAO/examples/Simple/time/Time_Client_i.cpp b/TAO/examples/Simple/time/Time_Client_i.cpp index 0c42b8d1cdd..4eb31acd0d3 100644 --- a/TAO/examples/Simple/time/Time_Client_i.cpp +++ b/TAO/examples/Simple/time/Time_Client_i.cpp @@ -1,6 +1,7 @@ //$Id$ #include "Time_Client_i.h" +#include "ace/OS_NS_time.h" // This is the interface program that accesses the remote object diff --git a/TAO/examples/Simple/time/Time_i.cpp b/TAO/examples/Simple/time/Time_i.cpp index aeb172c1600..c9905bef9b7 100644 --- a/TAO/examples/Simple/time/Time_i.cpp +++ b/TAO/examples/Simple/time/Time_i.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Time_i.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Time, Time_i, "$Id$") diff --git a/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp b/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp index a9799dc51e7..d91467ed51d 100644 --- a/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp +++ b/TAO/orbsvcs/Concurrency_Service/Concurrency_Service.cpp @@ -20,6 +20,8 @@ #include "ace/Argv_Type_Converter.h" #include "tao/debug.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Concurrency_Service, Concurrency_Service, "$Id$") diff --git a/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp b/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp index 7c7b2d891c3..1f2ace518e1 100644 --- a/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp +++ b/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.cpp @@ -6,6 +6,7 @@ #include "orbsvcs/CosEvent/CEC_Event_Loader.h" #include "ace/Get_Opt.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_main.h" ACE_RCSID(CosEvent_Service, CosEvent_Service, "$Id$") diff --git a/TAO/orbsvcs/Dump_Schedule/Dump_Schedule.cpp b/TAO/orbsvcs/Dump_Schedule/Dump_Schedule.cpp index b4fadf4fd0b..39909650b17 100644 --- a/TAO/orbsvcs/Dump_Schedule/Dump_Schedule.cpp +++ b/TAO/orbsvcs/Dump_Schedule/Dump_Schedule.cpp @@ -4,6 +4,7 @@ #include "ace/Sched_Params.h" #include "ace/Get_Opt.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_main.h" #include "orbsvcs/CosNamingC.h" #include "orbsvcs/Scheduler_Factory.h" diff --git a/TAO/orbsvcs/Event_Service/Event_Service.cpp b/TAO/orbsvcs/Event_Service/Event_Service.cpp index e19dd722b2d..09846e7afd8 100644 --- a/TAO/orbsvcs/Event_Service/Event_Service.cpp +++ b/TAO/orbsvcs/Event_Service/Event_Service.cpp @@ -5,6 +5,7 @@ #include "ace/Get_Opt.h" #include "ace/Auto_Ptr.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_main.h" #include "orbsvcs/CosNamingC.h" #include "orbsvcs/Event_Utilities.h" diff --git a/TAO/orbsvcs/FTRT_Event_Service/Event_Service/FT_EventService.cpp b/TAO/orbsvcs/FTRT_Event_Service/Event_Service/FT_EventService.cpp index a1e796ee001..c87145e7ad0 100644 --- a/TAO/orbsvcs/FTRT_Event_Service/Event_Service/FT_EventService.cpp +++ b/TAO/orbsvcs/FTRT_Event_Service/Event_Service/FT_EventService.cpp @@ -10,6 +10,7 @@ #include "orbsvcs/Sched/Config_Scheduler.h" #include "orbsvcs/Scheduler_Factory.h" #include "orbsvcs/FtRtEvent/EventChannel/FTRTEC_ServiceActivate.h" +#include "ace/OS_main.h" ACE_RCSID (Event_Service, FT_EventService, diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp index 310cfd16b29..dd549c8d307 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp @@ -17,6 +17,7 @@ #include "tao/default_ports.h" #include "ace/Auto_Ptr.h" +#include "ace/OS_NS_netdb.h" ACE_RCSID (ImplRepo_Service, diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp index 8061aa7f4bd..cbdaddf7b42 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp @@ -2,6 +2,7 @@ #include "NT_Service.h" #include "ace/Configuration.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (ImplRepo_Service, diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_imr.cpp index 86714efa558..c10c54d5445 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_imr.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr.cpp @@ -2,6 +2,7 @@ // $Id$ #include "tao_imr_i.h" +#include "ace/OS_main.h" int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp index acf58d9d3f5..bc60d0548e4 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp @@ -7,6 +7,8 @@ #include "ace/Get_Opt.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_netdb.h" // How many servers should we get at once? const size_t IR_LIST_CHUNK = 10; diff --git a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp index edd6553faf8..3e25082579f 100644 --- a/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp +++ b/TAO/orbsvcs/LifeCycle_Service/LifeCycle_Service.cpp @@ -16,6 +16,7 @@ #include "LifeCycle_Service.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_main.h" ACE_RCSID (LifeCycle_Service, LifeCycle_Service, diff --git a/TAO/orbsvcs/LoadBalancer/LoadManager.cpp b/TAO/orbsvcs/LoadBalancer/LoadManager.cpp index 7f1cc70d690..d2157681d22 100644 --- a/TAO/orbsvcs/LoadBalancer/LoadManager.cpp +++ b/TAO/orbsvcs/LoadBalancer/LoadManager.cpp @@ -5,6 +5,7 @@ #include "tao/ORB_Core.h" #include "ace/Get_Opt.h" +#include "ace/OS_main.h" #if defined (linux) && defined (ACE_HAS_THREADS) # include "ace/Signal.h" diff --git a/TAO/orbsvcs/LoadBalancer/LoadMonitor.cpp b/TAO/orbsvcs/LoadBalancer/LoadMonitor.cpp index 45a1685ec94..89a4b3e0af1 100644 --- a/TAO/orbsvcs/LoadBalancer/LoadMonitor.cpp +++ b/TAO/orbsvcs/LoadBalancer/LoadMonitor.cpp @@ -7,6 +7,7 @@ #include "tao/ORB_Core.h" #include "ace/Get_Opt.h" +#include "ace/OS_main.h" ACE_RCSID (LoadBalancer, diff --git a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp index 8b10e119b61..84e7dac2baf 100644 --- a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp @@ -1,6 +1,7 @@ #include "Basic_Logging_Service.h" #include "ace/Get_Opt.h" #include "orbsvcs/Log/BasicLogFactory_i.h" +#include "ace/OS_main.h" ACE_RCSID (Basic_Logging_Service, Basic_Logging_Service, diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp index bee3c93890b..e804956eca5 100644 --- a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp @@ -2,6 +2,7 @@ #include "Event_Logging_Service.h" #include "orbsvcs/Log/EventLogFactory_i.h" #include "orbsvcs/CosEvent/CEC_Default_Factory.h" +#include "ace/OS_main.h" ACE_RCSID (Event_Logging_Service, Event_Logging_Service, diff --git a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp index 3f5ff1294db..45faecd1019 100644 --- a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp +++ b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp @@ -1,5 +1,6 @@ //$Id$ #include "Notify_Logging_Service.h" +#include "ace/OS_main.h" ACE_RCSID (Notify_Logging_Service, Notify_Logging_Server, diff --git a/TAO/orbsvcs/Logging_Service/RTEvent_Logging_Service/RTEvent_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/RTEvent_Logging_Service/RTEvent_Logging_Service.cpp index 6936cb13dd1..21a28c9e63f 100644 --- a/TAO/orbsvcs/Logging_Service/RTEvent_Logging_Service/RTEvent_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/RTEvent_Logging_Service/RTEvent_Logging_Service.cpp @@ -8,6 +8,7 @@ #include "orbsvcs/Event/Event_Channel.h" #include "orbsvcs/Event/EC_Default_Factory.h" #include "orbsvcs/Event/EC_Event_Channel.h" +#include "ace/OS_main.h" ACE_RCSID (RTEvent_Logging_Service, RTEvent_Logging_Service, diff --git a/TAO/orbsvcs/Naming_Service/Naming_Server.cpp b/TAO/orbsvcs/Naming_Service/Naming_Server.cpp index 7664f8d26bc..a16d6d434dc 100644 --- a/TAO/orbsvcs/Naming_Service/Naming_Server.cpp +++ b/TAO/orbsvcs/Naming_Service/Naming_Server.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Naming_Service.h" +#include "ace/OS_main.h" // Driver function for the TAO Naming Service. diff --git a/TAO/orbsvcs/Notify_Service/Notify_Server.cpp b/TAO/orbsvcs/Notify_Service/Notify_Server.cpp index c52349f2212..d28633e6d52 100644 --- a/TAO/orbsvcs/Notify_Service/Notify_Server.cpp +++ b/TAO/orbsvcs/Notify_Service/Notify_Server.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Notify_Service.h" +#include "ace/OS_main.h" TAO_Notify_Service_Driver notify_service; diff --git a/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp b/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp index bfe7bbc8d9f..88cd01f829b 100644 --- a/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp +++ b/TAO/orbsvcs/Scheduling_Service/Scheduling_Service.cpp @@ -6,6 +6,7 @@ #include "ace/Auto_Ptr.h" #include "ace/Argv_Type_Converter.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_main.h" ACE_RCSID(Scheduling_Service, Scheduling_Service, "$Id$") diff --git a/TAO/orbsvcs/Time_Service/Clerk_i.cpp b/TAO/orbsvcs/Time_Service/Clerk_i.cpp index f303c31aa34..bd18e558644 100644 --- a/TAO/orbsvcs/Time_Service/Clerk_i.cpp +++ b/TAO/orbsvcs/Time_Service/Clerk_i.cpp @@ -5,6 +5,7 @@ #include "ace/Read_Buffer.h" #include "ace/Get_Opt.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Time_Service, Clerk_i, "$Id$") diff --git a/TAO/orbsvcs/Time_Service/Server_i.cpp b/TAO/orbsvcs/Time_Service/Server_i.cpp index 51bee46ab22..f829164d05f 100644 --- a/TAO/orbsvcs/Time_Service/Server_i.cpp +++ b/TAO/orbsvcs/Time_Service/Server_i.cpp @@ -4,6 +4,7 @@ #include "tao/debug.h" #include "ace/Get_Opt.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Time_Service, Server_i, "$Id$") diff --git a/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp b/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp index 82b5acf84ec..97d8d30a3db 100644 --- a/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp +++ b/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Clerk_i.h" +#include "ace/OS_main.h" ACE_RCSID(TimeService, Time_Service_Clerk, "$Id$") diff --git a/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp b/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp index 3aa7829b917..a265a39ed35 100644 --- a/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp +++ b/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Server_i.h" +#include "ace/OS_main.h" ACE_RCSID(TimeService, Time_Service_Server, "$Id$") diff --git a/TAO/orbsvcs/Trading_Service/Trading_Server.cpp b/TAO/orbsvcs/Trading_Service/Trading_Server.cpp index 6b1de0c7f47..21bbeee0fa2 100644 --- a/TAO/orbsvcs/Trading_Service/Trading_Server.cpp +++ b/TAO/orbsvcs/Trading_Service/Trading_Server.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Trading_Service.h" +#include "ace/OS_main.h" // Driver function for the TAO Trading Service. diff --git a/TAO/orbsvcs/examples/CosEC/Simple/Service.cpp b/TAO/orbsvcs/examples/CosEC/Simple/Service.cpp index 3681b6f67d5..b8af55e6e0c 100644 --- a/TAO/orbsvcs/examples/CosEC/Simple/Service.cpp +++ b/TAO/orbsvcs/examples/CosEC/Simple/Service.cpp @@ -3,6 +3,7 @@ #include "orbsvcs/CosEvent/CEC_EventChannel.h" #include "orbsvcs/CosEvent/CEC_Default_Factory.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(CosEC_Simple, Service, "$Id$") diff --git a/TAO/orbsvcs/examples/Log/Basic/main.cpp b/TAO/orbsvcs/examples/Log/Basic/main.cpp index 94bb1e1d774..3b5098b43ad 100644 --- a/TAO/orbsvcs/examples/Log/Basic/main.cpp +++ b/TAO/orbsvcs/examples/Log/Basic/main.cpp @@ -1,4 +1,5 @@ #include "TLS_Client.h" +#include "ace/OS_main.h" ACE_RCSID (Basic, main, diff --git a/TAO/orbsvcs/examples/Log/Event/Event_Consumer.cpp b/TAO/orbsvcs/examples/Log/Event/Event_Consumer.cpp index 37467571ae1..48617c8262d 100644 --- a/TAO/orbsvcs/examples/Log/Event/Event_Consumer.cpp +++ b/TAO/orbsvcs/examples/Log/Event/Event_Consumer.cpp @@ -1,5 +1,6 @@ #include "Event_Consumer.h" #include "orbsvcs/CosEventChannelAdminS.h" +#include "ace/OS_main.h" ACE_RCSID (Event, Event_Consumer, diff --git a/TAO/orbsvcs/examples/Log/Event/Event_Supplier.cpp b/TAO/orbsvcs/examples/Log/Event/Event_Supplier.cpp index c1bbde1dc88..20d8ba4d47c 100644 --- a/TAO/orbsvcs/examples/Log/Event/Event_Supplier.cpp +++ b/TAO/orbsvcs/examples/Log/Event/Event_Supplier.cpp @@ -1,5 +1,6 @@ #include "Event_Supplier.h" #include "orbsvcs/CosEventChannelAdminS.h" +#include "ace/OS_main.h" ACE_RCSID (Event, Event_Supplier, diff --git a/TAO/orbsvcs/examples/Log/Notify/Notify_Consumer.cpp b/TAO/orbsvcs/examples/Log/Notify/Notify_Consumer.cpp index d8c6e7ea1aa..4da08b137c3 100644 --- a/TAO/orbsvcs/examples/Log/Notify/Notify_Consumer.cpp +++ b/TAO/orbsvcs/examples/Log/Notify/Notify_Consumer.cpp @@ -1,6 +1,7 @@ #include "Notify_Consumer.h" #include "orbsvcs/CosEventChannelAdminS.h" #include "orbsvcs/CosNotifyChannelAdminS.h" +#include "ace/OS_main.h" ACE_RCSID (Notify, Notify_Consumer, diff --git a/TAO/orbsvcs/examples/Log/Notify/Notify_Supplier.cpp b/TAO/orbsvcs/examples/Log/Notify/Notify_Supplier.cpp index 00d7a947267..9f368d24888 100644 --- a/TAO/orbsvcs/examples/Log/Notify/Notify_Supplier.cpp +++ b/TAO/orbsvcs/examples/Log/Notify/Notify_Supplier.cpp @@ -1,5 +1,6 @@ #include "Notify_Supplier.h" #include "orbsvcs/CosNotifyChannelAdminS.h" +#include "ace/OS_main.h" ACE_RCSID (Notify, Notify_Supplier, diff --git a/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Consumer.cpp b/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Consumer.cpp index 9495604c853..e5bb5b49a76 100644 --- a/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Consumer.cpp +++ b/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Consumer.cpp @@ -1,6 +1,7 @@ #include "RTEvent_Consumer.h" #include "orbsvcs/RtecEventChannelAdminC.h" #include "orbsvcs/Event_Service_Constants.h" +#include "ace/OS_main.h" ACE_RCSID (RTEvent, RTEvent_Consumer, diff --git a/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Supplier.cpp b/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Supplier.cpp index e2d9727fd94..aefa1693c0a 100644 --- a/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Supplier.cpp +++ b/TAO/orbsvcs/examples/Log/RTEvent/RTEvent_Supplier.cpp @@ -1,6 +1,7 @@ #include "RTEvent_Supplier.h" #include "orbsvcs/RtecEventChannelAdminC.h" #include "orbsvcs/Event_Service_Constants.h" +#include "ace/OS_main.h" ACE_RCSID (RTEvent, RTEvent_Supplier, diff --git a/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.cpp b/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.cpp index 605490eadf2..51b5f1485e1 100644 --- a/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.cpp +++ b/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.cpp @@ -10,6 +10,7 @@ ACE_RCSID (Notify, #include "ace/High_Res_Timer.h" #include "ace/Stats.h" +#include "ace/OS_NS_stdio.h" TAO_Notify_ThreadPool_Consumer::TAO_Notify_ThreadPool_Consumer (TAO_Notify_ORB_Objects& orb_objects) : orb_objects_ (orb_objects) diff --git a/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.h b/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.h index 2f68ee8ffc6..614bc45268f 100644 --- a/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.h +++ b/TAO/orbsvcs/examples/Notify/ThreadPool/Consumer.h @@ -19,6 +19,7 @@ #include "orbsvcs/orbsvcs/CosNotifyChannelAdminS.h" #include "orbsvcs/orbsvcs/CosNotifyCommC.h" #include "ace/SString.h" +#include "ace/OS_NS_time.h" /** * @class TAO_Notify_ThreadPool_Consumer diff --git a/TAO/orbsvcs/examples/ORT/gateway_server.cpp b/TAO/orbsvcs/examples/ORT/gateway_server.cpp index 135d9c710d5..d52bc63f0f2 100644 --- a/TAO/orbsvcs/examples/ORT/gateway_server.cpp +++ b/TAO/orbsvcs/examples/ORT/gateway_server.cpp @@ -4,6 +4,7 @@ #include "Gateway_i.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" const char *ior_output_file = 0; diff --git a/TAO/orbsvcs/examples/ORT/server.cpp b/TAO/orbsvcs/examples/ORT/server.cpp index acf377ce2b0..1b76cecb393 100644 --- a/TAO/orbsvcs/examples/ORT/server.cpp +++ b/TAO/orbsvcs/examples/ORT/server.cpp @@ -5,6 +5,7 @@ #include "tao/ORBInitializer_Registry.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" const char *ior_output_file = 0; diff --git a/TAO/orbsvcs/examples/RtEC/Simple/Service.cpp b/TAO/orbsvcs/examples/RtEC/Simple/Service.cpp index beb024502bd..2d6f2eb5e97 100644 --- a/TAO/orbsvcs/examples/RtEC/Simple/Service.cpp +++ b/TAO/orbsvcs/examples/RtEC/Simple/Service.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/Event/EC_Default_Factory.h" #include "ace/Get_Opt.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(EC_Examples, Service, "$Id$") diff --git a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp index 32a1b305e00..1b45ad1f9d9 100644 --- a/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp +++ b/TAO/orbsvcs/orbsvcs/CosEvent/CEC_Event_Loader.cpp @@ -24,6 +24,7 @@ #include "ace/Get_Opt.h" #include "ace/Argv_Type_Converter.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (CosEvent, Event_Loader, "$Id$") diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp index 051ea87bae5..680d49991b8 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp @@ -1,6 +1,7 @@ #include "LB_CPU_Monitor.h" #include "tao/ORB_Constants.h" +#include "ace/OS_NS_time.h" #if defined (ACE_HAS_SYS_LOADAVG_H) # include <sys/loadavg.h> diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Random.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Random.cpp index 0bfa37a6520..9a32a9d03c3 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Random.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Random.cpp @@ -3,6 +3,7 @@ #include "LB_Random.h" #include "tao/ORB_Constants.h" +#include "ace/OS_NS_time.h" ACE_RCSID (LoadBalancing, LB_Random, diff --git a/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.cpp b/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.cpp index 2b984aa7031..ac51e6a2c79 100644 --- a/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.cpp +++ b/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.cpp @@ -6,6 +6,7 @@ #include "Flat_File_Persistence.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_stat.h" TAO_NS_FlatFileStream::TAO_NS_FlatFileStream (const ACE_CString & file, const char * mode) diff --git a/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.h b/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.h index be420e7fac9..242a49d531d 100644 --- a/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.h +++ b/TAO/orbsvcs/orbsvcs/Naming/Flat_File_Persistence.h @@ -13,6 +13,7 @@ #define TAO_FLAT_FILE_PERSISTENCE_H #include "Storable.h" +#include "ace/OS_NS_stdio.h" //------------------------------------------------------------------------ // The Flat File concrete classes diff --git a/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp index f932965cb29..2d6aff6f15f 100644 --- a/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp +++ b/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp @@ -1,6 +1,7 @@ #include "Persistent_Naming_Context.h" #include "Persistent_Context_Index.h" #include "Bindings_Iterator_T.h" +#include "ace/OS_NS_stdio.h" // The following #pragma is needed to disable a warning that occurs // in MSVC 6 due to the overly long debugging symbols generated for diff --git a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp index 465eefa1b32..560419812ca 100644 --- a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp +++ b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp @@ -12,6 +12,7 @@ #endif /* _MSC_VER */ #include "ace/Auto_Ptr.h" +#include "ace/OS_NS_stdio.h" const char * TAO_Storable_Naming_Context::root_name_; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Endpoint.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Endpoint.cpp index f43c3a770ea..dcbd6482768 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Endpoint.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Endpoint.cpp @@ -6,6 +6,7 @@ #include "tao/debug.h" #include "tao/ORB_Constants.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (tao, UIPMC_Endpoint, diff --git a/TAO/orbsvcs/orbsvcs/Time_Utilities.h b/TAO/orbsvcs/orbsvcs/Time_Utilities.h index 81927d3bdfb..86759d4ae66 100644 --- a/TAO/orbsvcs/orbsvcs/Time_Utilities.h +++ b/TAO/orbsvcs/orbsvcs/Time_Utilities.h @@ -20,6 +20,7 @@ #include "orbsvcs/TimeBaseC.h" #include "orbsvcs/svc_utils_export.h" +#include "ace/OS_NS_time.h" class TAO_Svc_Utils_Export ORBSVCS_Time { diff --git a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp b/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp index b0604813a3b..a38206f4855 100644 --- a/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp +++ b/TAO/orbsvcs/orbsvcs/Trader/Offer_Database.cpp @@ -4,6 +4,7 @@ #define TAO_OFFER_DATABASE_C #include "Offer_Database.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Trader, Offer_Database, "$Id$") diff --git a/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp b/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp index 81e1566c9e9..90103e44f1d 100644 --- a/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp +++ b/TAO/orbsvcs/orbsvcs/Trader/Trader_Interfaces.cpp @@ -7,6 +7,7 @@ #include "Trader_T.h" #include "ace/INET_Addr.h" #include "Trader_Constraint_Visitors.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Trader, Trader_Interfaces, "$Id$") diff --git a/TAO/orbsvcs/tests/Concurrency/CC_client.cpp b/TAO/orbsvcs/tests/Concurrency/CC_client.cpp index b32702bca24..c67ba4310fc 100644 --- a/TAO/orbsvcs/tests/Concurrency/CC_client.cpp +++ b/TAO/orbsvcs/tests/Concurrency/CC_client.cpp @@ -23,6 +23,7 @@ #include "tao/debug.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Concurrency, CC_client, "$Id$") diff --git a/TAO/orbsvcs/tests/Concurrency/CC_command.tab.cpp b/TAO/orbsvcs/tests/Concurrency/CC_command.tab.cpp index 0d78f498554..8a67df0eb67 100644 --- a/TAO/orbsvcs/tests/Concurrency/CC_command.tab.cpp +++ b/TAO/orbsvcs/tests/Concurrency/CC_command.tab.cpp @@ -31,6 +31,7 @@ #include "CC_command.h" #include "ace/ACE.h" #include "orbsvcs/CosConcurrencyControlC.h" +#include "ace/OS_NS_stdio.h" void ace_cc_yyerror (const char* s); int ace_cc_yylex(void); diff --git a/TAO/orbsvcs/tests/EC_Custom_Marshal/ECM_Consumer.h b/TAO/orbsvcs/tests/EC_Custom_Marshal/ECM_Consumer.h index 41a90adaf34..1d0adde39fd 100644 --- a/TAO/orbsvcs/tests/EC_Custom_Marshal/ECM_Consumer.h +++ b/TAO/orbsvcs/tests/EC_Custom_Marshal/ECM_Consumer.h @@ -19,6 +19,7 @@ #include "orbsvcs/Channel_Clients_T.h" #include "orbsvcs/RtecEventChannelAdminC.h" +#include "ace/OS_NS_time.h" class Driver; diff --git a/TAO/orbsvcs/tests/EC_Throughput/ECT_Consumer.h b/TAO/orbsvcs/tests/EC_Throughput/ECT_Consumer.h index d384a8bea82..6a086b38087 100644 --- a/TAO/orbsvcs/tests/EC_Throughput/ECT_Consumer.h +++ b/TAO/orbsvcs/tests/EC_Throughput/ECT_Consumer.h @@ -23,6 +23,7 @@ #include "orbsvcs/RtecSchedulerC.h" #include "orbsvcs/RtecEventChannelAdminC.h" #include "ace/Task.h" +#include "ace/OS_NS_time.h" class Test_Consumer : public POA_RtecEventComm::PushConsumer { diff --git a/TAO/orbsvcs/tests/Event/lib/Consumer.h b/TAO/orbsvcs/tests/Event/lib/Consumer.h index fa280630a3d..439b95f9747 100644 --- a/TAO/orbsvcs/tests/Event/lib/Consumer.h +++ b/TAO/orbsvcs/tests/Event/lib/Consumer.h @@ -21,6 +21,7 @@ #include "orbsvcs/RtecEventCommS.h" #include "orbsvcs/RtecEventChannelAdminC.h" +#include "ace/OS_NS_time.h" /** * @class EC_Consumer diff --git a/TAO/orbsvcs/tests/Event/lib/Supplier.h b/TAO/orbsvcs/tests/Event/lib/Supplier.h index 8a135fb2c72..065a20a15aa 100644 --- a/TAO/orbsvcs/tests/Event/lib/Supplier.h +++ b/TAO/orbsvcs/tests/Event/lib/Supplier.h @@ -22,6 +22,7 @@ #include "orbsvcs/RtecEventCommS.h" #include "orbsvcs/RtecEventChannelAdminC.h" #include "ace/Task.h" +#include "ace/OS_NS_time.h" /** * @class EC_Supplier diff --git a/TAO/orbsvcs/tests/FaultTolerance/GroupRef_Manipulation/server.cpp b/TAO/orbsvcs/tests/FaultTolerance/GroupRef_Manipulation/server.cpp index 7ce0c918352..4522cdf4f60 100644 --- a/TAO/orbsvcs/tests/FaultTolerance/GroupRef_Manipulation/server.cpp +++ b/TAO/orbsvcs/tests/FaultTolerance/GroupRef_Manipulation/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" #if TAO_HAS_INTERCEPTORS diff --git a/TAO/orbsvcs/tests/FaultTolerance/IOGR/Manager.cpp b/TAO/orbsvcs/tests/FaultTolerance/IOGR/Manager.cpp index 645a345aff1..4e175275ae1 100644 --- a/TAO/orbsvcs/tests/FaultTolerance/IOGR/Manager.cpp +++ b/TAO/orbsvcs/tests/FaultTolerance/IOGR/Manager.cpp @@ -8,6 +8,7 @@ #include "tao/PortableServer/PortableServer.h" #include "orbsvcs/FaultTolerance/FT_Service_Activate.h" #include "orbsvcs/FaultTolerance/FT_IOGR_Property.h" +#include "ace/OS_NS_stdio.h" diff --git a/TAO/orbsvcs/tests/FaultTolerance/IOGR/server.cpp b/TAO/orbsvcs/tests/FaultTolerance/IOGR/server.cpp index 22953a7b8c5..ade1a560f4d 100644 --- a/TAO/orbsvcs/tests/FaultTolerance/IOGR/server.cpp +++ b/TAO/orbsvcs/tests/FaultTolerance/IOGR/server.cpp @@ -2,6 +2,7 @@ #include "test_i.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" const char *ior_output_file = 0; int diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_i.cpp b/TAO/orbsvcs/tests/ImplRepo/airplane_i.cpp index ce56c4ef87d..90f93c31e54 100644 --- a/TAO/orbsvcs/tests/ImplRepo/airplane_i.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/airplane_i.cpp @@ -3,6 +3,7 @@ #include "airplane_i.h" #include "tao/debug.h" +#include "ace/OS_NS_time.h" ACE_RCSID (ImplRepo, airplane_i, diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp index 3c4bf901e4d..e70eb8b8afb 100644 --- a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp @@ -7,6 +7,7 @@ #include "ace/Get_Opt.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (ImplRepo, airplane_server_i, diff --git a/TAO/orbsvcs/tests/ImplRepo/nestea_i.cpp b/TAO/orbsvcs/tests/ImplRepo/nestea_i.cpp index ba668c66555..d04825e267d 100644 --- a/TAO/orbsvcs/tests/ImplRepo/nestea_i.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/nestea_i.cpp @@ -5,6 +5,7 @@ #include "ace/FILE_Addr.h" #include "ace/FILE_Connector.h" #include "ace/FILE_IO.h" +#include "ace/OS_NS_stdio.h" const size_t MAX_UINT32_STR_LEN = 11; // Largest UINT32 is 8589934591 + NUL is 11 characters diff --git a/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp b/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp index d1e1b5d6aea..5917f657b78 100644 --- a/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp @@ -5,6 +5,7 @@ #include "tao/debug.h" #include "ace/Get_Opt.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(ImplRepo, nestea_server_i, "$Id$") diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp index 3d8196ba859..3bfc171f83a 100644 --- a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp @@ -2,6 +2,7 @@ // $Id$ #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Application_Test, server, "$Id$") diff --git a/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp b/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp index af68e92e5d7..5180073acf4 100644 --- a/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp +++ b/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp @@ -7,6 +7,7 @@ #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #include "ace/SString.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Basic_Log_Test, diff --git a/TAO/orbsvcs/tests/Log/Basic_Log_Test/client.cpp b/TAO/orbsvcs/tests/Log/Basic_Log_Test/client.cpp index a66d8cabe08..b906b2fb1e5 100644 --- a/TAO/orbsvcs/tests/Log/Basic_Log_Test/client.cpp +++ b/TAO/orbsvcs/tests/Log/Basic_Log_Test/client.cpp @@ -1,5 +1,6 @@ #include "Basic_Log_Test.h" #include "ace/Log_Msg.h" +#include "ace/OS_main.h" ACE_RCSID (Basic_Log_Test, client, diff --git a/TAO/orbsvcs/tests/Miop/McastHello/server.cpp b/TAO/orbsvcs/tests/Miop/McastHello/server.cpp index 9ccfe1f5259..25b10fd2e5c 100644 --- a/TAO/orbsvcs/tests/Miop/McastHello/server.cpp +++ b/TAO/orbsvcs/tests/Miop/McastHello/server.cpp @@ -2,6 +2,7 @@ #include "McastHello.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (McastHello, server, diff --git a/TAO/orbsvcs/tests/Notify/Blocking/common.cpp b/TAO/orbsvcs/tests/Notify/Blocking/common.cpp index cc2294c2dd5..1caccdbb3df 100644 --- a/TAO/orbsvcs/tests/Notify/Blocking/common.cpp +++ b/TAO/orbsvcs/tests/Notify/Blocking/common.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" const char* diff --git a/TAO/orbsvcs/tests/Notify/Destroy/main.cpp b/TAO/orbsvcs/tests/Notify/Destroy/main.cpp index 9e4cb3362d4..c829b8efa06 100644 --- a/TAO/orbsvcs/tests/Notify/Destroy/main.cpp +++ b/TAO/orbsvcs/tests/Notify/Destroy/main.cpp @@ -2,6 +2,7 @@ #include "../lib/Notify_Test_Client.h" #include "orbsvcs/orbsvcs/NotifyExtC.h" +#include "ace/OS_main.h" int ACE_TMAIN (int argc, char *argv[]) diff --git a/TAO/orbsvcs/tests/Notify/Discarding/common.cpp b/TAO/orbsvcs/tests/Notify/Discarding/common.cpp index cc2294c2dd5..1caccdbb3df 100644 --- a/TAO/orbsvcs/tests/Notify/Discarding/common.cpp +++ b/TAO/orbsvcs/tests/Notify/Discarding/common.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" const char* diff --git a/TAO/orbsvcs/tests/Notify/Driver/main.cpp b/TAO/orbsvcs/tests/Notify/Driver/main.cpp index 5528afc167a..d50b5365653 100644 --- a/TAO/orbsvcs/tests/Notify/Driver/main.cpp +++ b/TAO/orbsvcs/tests/Notify/Driver/main.cpp @@ -1,6 +1,7 @@ //$Id$ #include "../lib/Driver.h" +#include "ace/OS_main.h" int ACE_TMAIN (int argc, char *argv[]) diff --git a/TAO/orbsvcs/tests/Notify/Ordering/Sequence_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Ordering/Sequence_Consumer.cpp index 4a875155f0d..aff5df0cad2 100644 --- a/TAO/orbsvcs/tests/Notify/Ordering/Sequence_Consumer.cpp +++ b/TAO/orbsvcs/tests/Notify/Ordering/Sequence_Consumer.cpp @@ -12,6 +12,7 @@ #include "goC.h" #include "Notify_Test_Client.h" +#include "ace/OS_NS_sys_stat.h" #if !defined (PATH_MAX) #define PATH_MAX 1024 diff --git a/TAO/orbsvcs/tests/Notify/Ordering/Structured_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Ordering/Structured_Consumer.cpp index 935bb554722..0ab02f6757a 100644 --- a/TAO/orbsvcs/tests/Notify/Ordering/Structured_Consumer.cpp +++ b/TAO/orbsvcs/tests/Notify/Ordering/Structured_Consumer.cpp @@ -12,6 +12,7 @@ #include "goC.h" #include "Notify_Test_Client.h" +#include "ace/OS_NS_sys_stat.h" #if !defined (PATH_MAX) #define PATH_MAX 1024 diff --git a/TAO/orbsvcs/tests/Notify/Ordering/common.cpp b/TAO/orbsvcs/tests/Notify/Ordering/common.cpp index cc2294c2dd5..1caccdbb3df 100644 --- a/TAO/orbsvcs/tests/Notify/Ordering/common.cpp +++ b/TAO/orbsvcs/tests/Notify/Ordering/common.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" const char* diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/common.cpp b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/common.cpp index cc2294c2dd5..1caccdbb3df 100644 --- a/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/common.cpp +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_ETCL_Filter/common.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" const char* diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/common.cpp b/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/common.cpp index cc2294c2dd5..1caccdbb3df 100644 --- a/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/common.cpp +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/common.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" const char* diff --git a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/common.cpp b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/common.cpp index cc2294c2dd5..1caccdbb3df 100644 --- a/TAO/orbsvcs/tests/Notify/performance-tests/Filter/common.cpp +++ b/TAO/orbsvcs/tests/Notify/performance-tests/Filter/common.cpp @@ -4,6 +4,7 @@ #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/CosNamingC.h" +#include "ace/OS_NS_stdio.h" const char* diff --git a/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp b/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp index 37e7e7fa8a1..83d4b3f516d 100644 --- a/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp +++ b/TAO/orbsvcs/tests/RTCosScheduling/Object1_i.cpp @@ -12,6 +12,7 @@ #include "Object1_i.h" #include "ace/ACE.h" +#include "ace/OS_NS_stdio.h" //#include "tao/RTCORBA/RTCORBA.h" ////##include "ace/Task.h" // diff --git a/TAO/orbsvcs/tests/RTCosScheduling/client.cpp b/TAO/orbsvcs/tests/RTCosScheduling/client.cpp index 9c10482157c..0f89c467e59 100644 --- a/TAO/orbsvcs/tests/RTCosScheduling/client.cpp +++ b/TAO/orbsvcs/tests/RTCosScheduling/client.cpp @@ -15,6 +15,7 @@ #include <orbsvcs/RTCosScheduling/RTCosScheduling_ClientScheduler_i.h> #include "ace/Get_Opt.h" #include "tao/debug.h" +#include "ace/OS_main.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once diff --git a/TAO/orbsvcs/tests/RTCosScheduling/server.cpp b/TAO/orbsvcs/tests/RTCosScheduling/server.cpp index ea7889f141f..69f2a464fc9 100644 --- a/TAO/orbsvcs/tests/RTCosScheduling/server.cpp +++ b/TAO/orbsvcs/tests/RTCosScheduling/server.cpp @@ -20,6 +20,7 @@ #include "ace/Task.h" #include "ace/Get_Opt.h" #include "tao/ORB_Core.h" +#include "ace/OS_main.h" char *node_ = NULL; diff --git a/TAO/orbsvcs/tests/Redundant_Naming/client.cpp b/TAO/orbsvcs/tests/Redundant_Naming/client.cpp index 8e72be4103b..8ae380b8bec 100644 --- a/TAO/orbsvcs/tests/Redundant_Naming/client.cpp +++ b/TAO/orbsvcs/tests/Redundant_Naming/client.cpp @@ -22,6 +22,7 @@ #include "tao/PortableServer/ORB_Manager.h" #include "tao/debug.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Simple_Naming, client, "$Id$") diff --git a/TAO/orbsvcs/tests/Trading/Offer_Exporter.cpp b/TAO/orbsvcs/tests/Trading/Offer_Exporter.cpp index e4fa0e39cba..a17974c2d1c 100644 --- a/TAO/orbsvcs/tests/Trading/Offer_Exporter.cpp +++ b/TAO/orbsvcs/tests/Trading/Offer_Exporter.cpp @@ -2,6 +2,7 @@ #include "Offer_Exporter.h" #include "ace/INET_Addr.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Trading, Offer_Exporter, "$Id$") diff --git a/TAO/orbsvcs/tests/Trading/TT_Info.cpp b/TAO/orbsvcs/tests/Trading/TT_Info.cpp index 66b252093c2..bdeb8faaaae 100644 --- a/TAO/orbsvcs/tests/Trading/TT_Info.cpp +++ b/TAO/orbsvcs/tests/Trading/TT_Info.cpp @@ -2,6 +2,7 @@ #include "TT_Info.h" #include "orbsvcs/Trader/Trader_Utils.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Trading, TT_Info, "$Id$") diff --git a/TAO/performance-tests/Callback/Callback_i.cpp b/TAO/performance-tests/Callback/Callback_i.cpp index 83e357965ce..2ca187a393b 100644 --- a/TAO/performance-tests/Callback/Callback_i.cpp +++ b/TAO/performance-tests/Callback/Callback_i.cpp @@ -6,6 +6,8 @@ #include "Callback_i.inl" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_time.h" + ACE_RCSID(Callback, Callback_i, "$Id$") int diff --git a/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Client.cpp b/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Client.cpp index f10d8f83ccf..bebfe8c6f0b 100644 --- a/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Client.cpp +++ b/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Client.cpp @@ -9,6 +9,8 @@ #include "ace/Env_Value_T.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(IDL_Cubit, Cubit_Client, "Cubit_Client.cpp,v 1.31 1999/08/04 07:15:14 nanbor Exp") diff --git a/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Server.cpp b/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Server.cpp index 539f14720cb..2d7ef27249d 100644 --- a/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Server.cpp +++ b/TAO/performance-tests/Cubit/TAO/IDL_Cubit/Cubit_Server.cpp @@ -3,6 +3,7 @@ #include "Cubit_Server.h" #include "tao/TAO_Internal.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(IDL_Cubit, Cubit_Server, "$Id$") diff --git a/TAO/performance-tests/Latency/AMI/Roundtrip_Handler.cpp b/TAO/performance-tests/Latency/AMI/Roundtrip_Handler.cpp index 5f0061601e4..62d29914e6c 100644 --- a/TAO/performance-tests/Latency/AMI/Roundtrip_Handler.cpp +++ b/TAO/performance-tests/Latency/AMI/Roundtrip_Handler.cpp @@ -2,6 +2,7 @@ // $Id$ // #include "Roundtrip_Handler.h" +#include "ace/OS_NS_time.h" ACE_RCSID(AMI_Latency, Roundtrip, "$Id$") diff --git a/TAO/performance-tests/Latency/Thread_Per_Connection/Client_Task.cpp b/TAO/performance-tests/Latency/Thread_Per_Connection/Client_Task.cpp index 09d15331436..9f9cd0db5bb 100644 --- a/TAO/performance-tests/Latency/Thread_Per_Connection/Client_Task.cpp +++ b/TAO/performance-tests/Latency/Thread_Per_Connection/Client_Task.cpp @@ -2,6 +2,7 @@ // $Id$ // #include "Client_Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Thread_Per_Connection_Latency, Client_Task, "$Id$") diff --git a/TAO/performance-tests/Latency/Thread_Pool/Client_Task.cpp b/TAO/performance-tests/Latency/Thread_Pool/Client_Task.cpp index efb544633b2..e7f6c70d900 100644 --- a/TAO/performance-tests/Latency/Thread_Pool/Client_Task.cpp +++ b/TAO/performance-tests/Latency/Thread_Pool/Client_Task.cpp @@ -2,6 +2,7 @@ // $Id$ // #include "Client_Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Thread_Pool_Latency, Client_Task, "$Id$") diff --git a/TAO/performance-tests/Memory/IORsize/server.cpp b/TAO/performance-tests/Memory/IORsize/server.cpp index 04b608cd209..712dafdf097 100644 --- a/TAO/performance-tests/Memory/IORsize/server.cpp +++ b/TAO/performance-tests/Memory/IORsize/server.cpp @@ -2,6 +2,7 @@ #include "Memory_Growth.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Hello, server, diff --git a/TAO/performance-tests/Memory/Single_Threaded/server.cpp b/TAO/performance-tests/Memory/Single_Threaded/server.cpp index 04b608cd209..712dafdf097 100644 --- a/TAO/performance-tests/Memory/Single_Threaded/server.cpp +++ b/TAO/performance-tests/Memory/Single_Threaded/server.cpp @@ -2,6 +2,7 @@ #include "Memory_Growth.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Hello, server, diff --git a/TAO/performance-tests/POA/Create_Reference/create_reference.cpp b/TAO/performance-tests/POA/Create_Reference/create_reference.cpp index 0e128102277..cb325ec6204 100644 --- a/TAO/performance-tests/POA/Create_Reference/create_reference.cpp +++ b/TAO/performance-tests/POA/Create_Reference/create_reference.cpp @@ -9,6 +9,7 @@ #include "ace/Sched_Params.h" #include "ace/Stats.h" #include "ace/Sample_History.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Activation, server, "$Id$") diff --git a/TAO/performance-tests/POA/Demux/demux_test_client.cpp b/TAO/performance-tests/POA/Demux/demux_test_client.cpp index 5ff3035ce57..e8ef7906d04 100644 --- a/TAO/performance-tests/POA/Demux/demux_test_client.cpp +++ b/TAO/performance-tests/POA/Demux/demux_test_client.cpp @@ -15,6 +15,8 @@ #include "demux_test_client.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_time.h" // Constructor Demux_Test_Client::Demux_Test_Client (void) diff --git a/TAO/performance-tests/POA/Demux/demux_test_server.cpp b/TAO/performance-tests/POA/Demux/demux_test_server.cpp index 52c2607319b..f8c88d91079 100644 --- a/TAO/performance-tests/POA/Demux/demux_test_server.cpp +++ b/TAO/performance-tests/POA/Demux/demux_test_server.cpp @@ -15,6 +15,7 @@ #include "demux_test_server.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(CodeGen, demux_test_server, "$Id$") diff --git a/TAO/performance-tests/POA/Implicit_Activation/server.cpp b/TAO/performance-tests/POA/Implicit_Activation/server.cpp index 89252e82dbd..cceb22c2bd8 100644 --- a/TAO/performance-tests/POA/Implicit_Activation/server.cpp +++ b/TAO/performance-tests/POA/Implicit_Activation/server.cpp @@ -3,6 +3,7 @@ #include "Factory.h" #include "ace/Get_Opt.h" #include "ace/Sched_Params.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Activation, server, "$Id$") diff --git a/TAO/performance-tests/Pluggable/PP_Test_Client.cpp b/TAO/performance-tests/Pluggable/PP_Test_Client.cpp index 3f5332de63a..b477c99a771 100644 --- a/TAO/performance-tests/Pluggable/PP_Test_Client.cpp +++ b/TAO/performance-tests/Pluggable/PP_Test_Client.cpp @@ -7,6 +7,7 @@ #include "tao/debug.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(IDL_Cubit, Cubit_Client, "$Id$") diff --git a/TAO/performance-tests/Pluggable/PP_Test_Server.cpp b/TAO/performance-tests/Pluggable/PP_Test_Server.cpp index a9cb9133e53..593a4d3bdb7 100644 --- a/TAO/performance-tests/Pluggable/PP_Test_Server.cpp +++ b/TAO/performance-tests/Pluggable/PP_Test_Server.cpp @@ -3,6 +3,7 @@ #include "PP_Test_Server.h" #include "tao/TAO_Internal.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(IDL_Cubit, Cubit_Server, "$Id$") diff --git a/TAO/performance-tests/RTCorba/Multiple_Endpoints/Single_Endpoint/server.cpp b/TAO/performance-tests/RTCorba/Multiple_Endpoints/Single_Endpoint/server.cpp index 7b623eadc7e..9b86e20661a 100644 --- a/TAO/performance-tests/RTCorba/Multiple_Endpoints/Single_Endpoint/server.cpp +++ b/TAO/performance-tests/RTCorba/Multiple_Endpoints/Single_Endpoint/server.cpp @@ -3,6 +3,7 @@ #include "test_i.h" #include "ace/Get_Opt.h" #include "ace/Sched_Params.h" +#include "ace/OS_NS_stdio.h" const char *ior_output_file = "test.ior"; diff --git a/TAO/performance-tests/RTCorba/Oneways/Reliable/server.cpp b/TAO/performance-tests/RTCorba/Oneways/Reliable/server.cpp index b23da7d1bb9..619d4f53936 100644 --- a/TAO/performance-tests/RTCorba/Oneways/Reliable/server.cpp +++ b/TAO/performance-tests/RTCorba/Oneways/Reliable/server.cpp @@ -3,6 +3,7 @@ #include "test_i.h" #include "ace/Get_Opt.h" #include "ace/Sched_Params.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Reliable, server, "$Id$") diff --git a/TAO/performance-tests/Sequence_Latency/AMI/Roundtrip_Handler.cpp b/TAO/performance-tests/Sequence_Latency/AMI/Roundtrip_Handler.cpp index a75558e0660..4ebe5921394 100644 --- a/TAO/performance-tests/Sequence_Latency/AMI/Roundtrip_Handler.cpp +++ b/TAO/performance-tests/Sequence_Latency/AMI/Roundtrip_Handler.cpp @@ -2,6 +2,7 @@ // $Id$ // #include "Roundtrip_Handler.h" +#include "ace/OS_NS_time.h" ACE_RCSID(AMI_Latency, Roundtrip, "$Id$") diff --git a/TAO/performance-tests/Sequence_Latency/Thread_Per_Connection/Client_Task.cpp b/TAO/performance-tests/Sequence_Latency/Thread_Per_Connection/Client_Task.cpp index 0188ca0990b..072b7a2888a 100644 --- a/TAO/performance-tests/Sequence_Latency/Thread_Per_Connection/Client_Task.cpp +++ b/TAO/performance-tests/Sequence_Latency/Thread_Per_Connection/Client_Task.cpp @@ -2,6 +2,7 @@ // $Id$ // #include "Client_Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Thread_Per_Connection_Latency, Client_Task, "$Id$") diff --git a/TAO/performance-tests/Sequence_Latency/Thread_Pool/Client_Task.cpp b/TAO/performance-tests/Sequence_Latency/Thread_Pool/Client_Task.cpp index c00d98bec8e..052e68f890e 100644 --- a/TAO/performance-tests/Sequence_Latency/Thread_Pool/Client_Task.cpp +++ b/TAO/performance-tests/Sequence_Latency/Thread_Pool/Client_Task.cpp @@ -2,6 +2,7 @@ // $Id$ // #include "Client_Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Thread_Pool_Latency, Client_Task, "$Id$") diff --git a/TAO/performance-tests/Throughput/Receiver.h b/TAO/performance-tests/Throughput/Receiver.h index 343c3eef1fe..55ed066e6bc 100644 --- a/TAO/performance-tests/Throughput/Receiver.h +++ b/TAO/performance-tests/Throughput/Receiver.h @@ -7,6 +7,7 @@ #include /**/ "ace/pre.h" #include "TestS.h" +#include "ace/OS_NS_time.h" #if defined (_MSC_VER) # if (_MSC_VER >= 1200) diff --git a/TAO/tao/Exception.cpp b/TAO/tao/Exception.cpp index 028560c671f..63c2c86e7ce 100644 --- a/TAO/tao/Exception.cpp +++ b/TAO/tao/Exception.cpp @@ -19,6 +19,8 @@ # include "tao/Exception.i" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_stdio.h" + ACE_RCSID (TAO, Exception, "$Id$") diff --git a/TAO/tao/FILE_Parser.cpp b/TAO/tao/FILE_Parser.cpp index dec7dee9db7..028ccd3eba8 100644 --- a/TAO/tao/FILE_Parser.cpp +++ b/TAO/tao/FILE_Parser.cpp @@ -10,6 +10,8 @@ #include "FILE_Parser.i" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_stdio.h" + ACE_RCSID (tao, FILE_Parser, "$Id$") diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp index f7f8b53bde6..6e85b2ab323 100644 --- a/TAO/tao/IIOP_Connection_Handler.cpp +++ b/TAO/tao/IIOP_Connection_Handler.cpp @@ -13,6 +13,8 @@ # include "tao/IIOP_Connection_Handler.i" #endif /* ! __ACE_INLINE__ */ +#include "ace/os_include/netinet/os_tcp.h" + ACE_RCSID (tao, IIOP_Connection_Handler, "$Id$") diff --git a/TAO/tao/IIOP_Endpoint.cpp b/TAO/tao/IIOP_Endpoint.cpp index b0faeb2cc31..2d21999d7f0 100644 --- a/TAO/tao/IIOP_Endpoint.cpp +++ b/TAO/tao/IIOP_Endpoint.cpp @@ -13,6 +13,8 @@ ACE_RCSID (tao, # include "tao/IIOP_Endpoint.i" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_stdio.h" + TAO_IIOP_Endpoint::TAO_IIOP_Endpoint (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) : TAO_Endpoint (IOP::TAG_INTERNET_IOP) diff --git a/TAO/tao/PortableServer/Operation_Table.h b/TAO/tao/PortableServer/Operation_Table.h index 78e7b7360ed..38dd2abe38b 100644 --- a/TAO/tao/PortableServer/Operation_Table.h +++ b/TAO/tao/PortableServer/Operation_Table.h @@ -24,7 +24,8 @@ #include "tao/Object.h" #include "tao/TAO_Singleton.h" #include "tao/Collocation_Strategy.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" #include "ace/Hash_Map_Manager.h" class TAO_ServerRequest; diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp index 826317a92c9..d4cefc4518e 100644 --- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp @@ -20,6 +20,8 @@ # include "SHMIOP_Connection_Handler.inl" #endif /* ! __ACE_INLINE__ */ +#include "ace/os_include/netinet/os_tcp.h" + ACE_RCSID(Strategies, SHMIOP_Connection_Handler, "$Id$") TAO_SHMIOP_Connection_Handler::TAO_SHMIOP_Connection_Handler (ACE_Thread_Manager *t) diff --git a/TAO/tao/Synch_Refcountable.inl b/TAO/tao/Synch_Refcountable.inl index f933f1fd5ff..2f4cc32778d 100644 --- a/TAO/tao/Synch_Refcountable.inl +++ b/TAO/tao/Synch_Refcountable.inl @@ -1,5 +1,8 @@ // -*- C++ -*- //$Id$ + +#include "ace/Guard_T.h" + ACE_INLINE int TAO_Synch_Refcountable::increment (void) { diff --git a/TAO/tao/default_client.cpp b/TAO/tao/default_client.cpp index 2ef39c156fc..0af1359c670 100644 --- a/TAO/tao/default_client.cpp +++ b/TAO/tao/default_client.cpp @@ -18,6 +18,8 @@ # include "tao/default_client.i" #endif /* ! __ACE_INLINE__ */ +#include "ace/OS_NS_strings.h" + ACE_RCSID (tao, default_client, "$Id$") diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp index bb6a4f1ccb4..18d4f850382 100644 --- a/TAO/tao/default_server.cpp +++ b/TAO/tao/default_server.cpp @@ -6,6 +6,8 @@ # include "tao/default_client.i" #endif /* ! __ACE_INLINE__ */ +#include "ace/OS_NS_strings.h" + ACE_RCSID (tao, default_server, "$Id$") diff --git a/TAO/tests/BiDirectional/server.cpp b/TAO/tests/BiDirectional/server.cpp index 5feeadfd930..f1a6ae7508a 100644 --- a/TAO/tests/BiDirectional/server.cpp +++ b/TAO/tests/BiDirectional/server.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" #include "tao/BiDir_GIOP/BiDirGIOP.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(BiDirectional, server, "$Id$") diff --git a/TAO/tests/BiDirectional_NestedUpcall/server.cpp b/TAO/tests/BiDirectional_NestedUpcall/server.cpp index 046e54367a1..0f419ec54fb 100644 --- a/TAO/tests/BiDirectional_NestedUpcall/server.cpp +++ b/TAO/tests/BiDirectional_NestedUpcall/server.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" #include "tao/BiDir_GIOP/BiDirGIOP.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(BiDirectional, server, "$Id$") diff --git a/TAO/tests/Big_Oneways/server.cpp b/TAO/tests/Big_Oneways/server.cpp index 4fe130c1c11..ff763eeff67 100644 --- a/TAO/tests/Big_Oneways/server.cpp +++ b/TAO/tests/Big_Oneways/server.cpp @@ -3,6 +3,7 @@ #include "Coordinator.h" #include "Session_Control.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Big_Oneways, server, "$Id$") diff --git a/TAO/tests/Big_Reply/server.cpp b/TAO/tests/Big_Reply/server.cpp index 9aa133ddf4f..fbaa60dad4b 100644 --- a/TAO/tests/Big_Reply/server.cpp +++ b/TAO/tests/Big_Reply/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "Big_Reply_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Big_Reply, server, "$Id$") diff --git a/TAO/tests/Big_Request_Muxing/server.cpp b/TAO/tests/Big_Request_Muxing/server.cpp index 065d1ae1e2f..3937c3da4a3 100644 --- a/TAO/tests/Big_Request_Muxing/server.cpp +++ b/TAO/tests/Big_Request_Muxing/server.cpp @@ -2,6 +2,7 @@ #include "Payload_Receiver.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Big_Request_Muxing, server, "$Id$") diff --git a/TAO/tests/Big_Twoways/server.cpp b/TAO/tests/Big_Twoways/server.cpp index b6b78cb8c27..cc0329273eb 100644 --- a/TAO/tests/Big_Twoways/server.cpp +++ b/TAO/tests/Big_Twoways/server.cpp @@ -3,6 +3,7 @@ #include "Coordinator.h" #include "Session_Control.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Big_Oneways, server, "$Id$") diff --git a/TAO/tests/Blocking_Sync_None/server.cpp b/TAO/tests/Blocking_Sync_None/server.cpp index 8ab148a2db0..a774b6cdf83 100644 --- a/TAO/tests/Blocking_Sync_None/server.cpp +++ b/TAO/tests/Blocking_Sync_None/server.cpp @@ -2,6 +2,7 @@ #include "Blocking_Sync_None.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Blocking_Sync_None, server, "$Id$") diff --git a/TAO/tests/CDR/growth.cpp b/TAO/tests/CDR/growth.cpp index 71fcc058658..953c9b37ef7 100644 --- a/TAO/tests/CDR/growth.cpp +++ b/TAO/tests/CDR/growth.cpp @@ -22,6 +22,7 @@ #include "tao/ORB.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(CDR, growth, "$Id$") diff --git a/TAO/tests/Cache_Growth_Test/server.cpp b/TAO/tests/Cache_Growth_Test/server.cpp index 0a3a75b9185..ef867fc77aa 100644 --- a/TAO/tests/Cache_Growth_Test/server.cpp +++ b/TAO/tests/Cache_Growth_Test/server.cpp @@ -2,6 +2,7 @@ #include "Hello.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Hello, server, "$Id$") diff --git a/TAO/tests/Connect_Strategy_Test/server.cpp b/TAO/tests/Connect_Strategy_Test/server.cpp index 34d58609a74..acd62195b16 100644 --- a/TAO/tests/Connect_Strategy_Test/server.cpp +++ b/TAO/tests/Connect_Strategy_Test/server.cpp @@ -2,6 +2,7 @@ #include "Hello.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Connect_Strategy_Test, server, diff --git a/TAO/tests/Explicit_Event_Loop/server.cpp b/TAO/tests/Explicit_Event_Loop/server.cpp index 5c25f97887d..573fc514553 100644 --- a/TAO/tests/Explicit_Event_Loop/server.cpp +++ b/TAO/tests/Explicit_Event_Loop/server.cpp @@ -22,6 +22,7 @@ #include "server.h" #include "tao/debug.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" const char *ior_output_file = "server.ior"; int done = 0; diff --git a/TAO/tests/Exposed_Policies/Policy_Tester.cpp b/TAO/tests/Exposed_Policies/Policy_Tester.cpp index ffbbef12d45..68dd909d017 100644 --- a/TAO/tests/Exposed_Policies/Policy_Tester.cpp +++ b/TAO/tests/Exposed_Policies/Policy_Tester.cpp @@ -7,6 +7,7 @@ // -- ACE Include -- #include "ace/Arg_Shifter.h" +#include "ace/OS_NS_stdio.h" // -- RTCORBA Include -- #include "tao/RTCORBA/RT_Policy_i.h" diff --git a/TAO/tests/Faults/middle.cpp b/TAO/tests/Faults/middle.cpp index a51a7a0dac8..ef468b2c87b 100644 --- a/TAO/tests/Faults/middle.cpp +++ b/TAO/tests/Faults/middle.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Failure, middle, "$Id$") diff --git a/TAO/tests/Faults/ping.cpp b/TAO/tests/Faults/ping.cpp index 0ba63169c19..e630ffec6c7 100644 --- a/TAO/tests/Faults/ping.cpp +++ b/TAO/tests/Faults/ping.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "ping_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Faults, server, "$Id$") diff --git a/TAO/tests/Faults/server.cpp b/TAO/tests/Faults/server.cpp index 847423380a6..b0c343886d4 100644 --- a/TAO/tests/Faults/server.cpp +++ b/TAO/tests/Faults/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Failure, server, "$Id$") diff --git a/TAO/tests/File_IO/File_i.cpp b/TAO/tests/File_IO/File_i.cpp index 7b96483a04a..5e974639532 100644 --- a/TAO/tests/File_IO/File_i.cpp +++ b/TAO/tests/File_IO/File_i.cpp @@ -15,6 +15,8 @@ //==================================================================== #include "File_i.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_fcntl.h" ACE_RCSID(Default_Servant, File_i, "File_i.cpp,v 1.14 2001/03/04 19:27:53 irfan Exp") diff --git a/TAO/tests/Forwarding/server.cpp b/TAO/tests/Forwarding/server.cpp index 20260593cf9..788a56c975a 100644 --- a/TAO/tests/Forwarding/server.cpp +++ b/TAO/tests/Forwarding/server.cpp @@ -3,6 +3,7 @@ #include "test_i.h" #include "tao/IORTable/IORTable.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Forwarding, server, "$Id$") diff --git a/TAO/tests/Hello/server.cpp b/TAO/tests/Hello/server.cpp index 0b56e777eb6..177aad4d1d8 100644 --- a/TAO/tests/Hello/server.cpp +++ b/TAO/tests/Hello/server.cpp @@ -2,6 +2,7 @@ #include "Hello.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Hello, server, diff --git a/TAO/tests/InterOp-Naming/Server_i.cpp b/TAO/tests/InterOp-Naming/Server_i.cpp index 3e0c31ad32b..55abc5841f5 100644 --- a/TAO/tests/InterOp-Naming/Server_i.cpp +++ b/TAO/tests/InterOp-Naming/Server_i.cpp @@ -3,6 +3,7 @@ #include "Server_i.h" #include "tao/debug.h" #include "tao/IORTable/IORTable.h" +#include "ace/OS_NS_stdio.h" // Constructor. diff --git a/TAO/tests/MProfile/server.cpp b/TAO/tests/MProfile/server.cpp index c2481225b94..9bad4d5c876 100644 --- a/TAO/tests/MProfile/server.cpp +++ b/TAO/tests/MProfile/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(MT_Client, server, "$Id$") diff --git a/TAO/tests/MProfile_Connection_Timeout/server.cpp b/TAO/tests/MProfile_Connection_Timeout/server.cpp index d5ef93472a2..9daac4d75f7 100644 --- a/TAO/tests/MProfile_Connection_Timeout/server.cpp +++ b/TAO/tests/MProfile_Connection_Timeout/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(MProfile_Connection_Timeout, server, diff --git a/TAO/tests/MProfile_Forwarding/Manager.cpp b/TAO/tests/MProfile_Forwarding/Manager.cpp index 95a72fc52ca..89e223c7cd9 100644 --- a/TAO/tests/MProfile_Forwarding/Manager.cpp +++ b/TAO/tests/MProfile_Forwarding/Manager.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "Manager.h" #include "tao/IORManipulation/IORManip_Loader.h" +#include "ace/OS_NS_stdio.h" const char *first_ior = 0; const char *second_ior = 0; diff --git a/TAO/tests/MProfile_Forwarding/server.cpp b/TAO/tests/MProfile_Forwarding/server.cpp index 7d9ace8d48f..36750cdc485 100755 --- a/TAO/tests/MProfile_Forwarding/server.cpp +++ b/TAO/tests/MProfile_Forwarding/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(MT_Client, server, "$Id$") diff --git a/TAO/tests/MT_Client/server.cpp b/TAO/tests/MT_Client/server.cpp index 0718edf84e0..bf5e6312642 100644 --- a/TAO/tests/MT_Client/server.cpp +++ b/TAO/tests/MT_Client/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(MT_Client, server, "$Id$") diff --git a/TAO/tests/Multiple/server.cpp b/TAO/tests/Multiple/server.cpp index 4bbaa563fac..fcaa75221f3 100644 --- a/TAO/tests/Multiple/server.cpp +++ b/TAO/tests/Multiple/server.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Multiple_Impl.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (tests, server, "$Id$") diff --git a/TAO/tests/Multiple_Inheritance/client.cpp b/TAO/tests/Multiple_Inheritance/client.cpp index 3041b64478e..c1a8eb6e0a7 100644 --- a/TAO/tests/Multiple_Inheritance/client.cpp +++ b/TAO/tests/Multiple_Inheritance/client.cpp @@ -19,6 +19,7 @@ #include "ace/Get_Opt.h" #include "ace/Read_Buffer.h" #include "Multiple_InheritanceC.h" +#include "ace/OS_NS_fcntl.h" ACE_RCSID(Multiple_Inheritance, client, "$Id$") diff --git a/TAO/tests/Multiple_Inheritance/server.cpp b/TAO/tests/Multiple_Inheritance/server.cpp index e970bcd85c8..82275fda3db 100644 --- a/TAO/tests/Multiple_Inheritance/server.cpp +++ b/TAO/tests/Multiple_Inheritance/server.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "Multiple_Inheritance_i.h" #include "tao/PortableServer/ORB_Manager.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Multiple_Inheritance, server, "$Id$") diff --git a/TAO/tests/Native_Exceptions/server.cpp b/TAO/tests/Native_Exceptions/server.cpp index 1ee0e319c74..6e41137344e 100644 --- a/TAO/tests/Native_Exceptions/server.cpp +++ b/TAO/tests/Native_Exceptions/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Native_Exceptions, server, "$Id$") diff --git a/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp b/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp index 33b40082253..cfaf28db75d 100644 --- a/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp +++ b/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp @@ -19,6 +19,7 @@ #include "server.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(MT_Client_Test, server, "$Id$") diff --git a/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp b/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp index 608118538d5..cb1cbdabe68 100644 --- a/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp +++ b/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp @@ -20,6 +20,7 @@ #include "initiator.h" #include "tao/debug.h" #include "ace/Read_Buffer.h" +#include "ace/OS_NS_fcntl.h" ACE_RCSID(Triangle_Test, initiator, "$Id$") diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp b/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp index 4bf4e7d0b24..8ab9fe10dfe 100644 --- a/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp @@ -19,6 +19,7 @@ #include "server_A.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Triangle_Test, server_A, "$Id$") diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp b/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp index ac2905fef60..1f0c79519aa 100644 --- a/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp @@ -19,6 +19,7 @@ #include "server_B.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Triangle_Test, server_B, "$Id$") diff --git a/TAO/tests/No_Server_MT_Connect_Test/server.cpp b/TAO/tests/No_Server_MT_Connect_Test/server.cpp index 0718edf84e0..bf5e6312642 100644 --- a/TAO/tests/No_Server_MT_Connect_Test/server.cpp +++ b/TAO/tests/No_Server_MT_Connect_Test/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(MT_Client, server, "$Id$") diff --git a/TAO/tests/ORT/server.cpp b/TAO/tests/ORT/server.cpp index d8a3c7dfeca..d8656cc7c94 100644 --- a/TAO/tests/ORT/server.cpp +++ b/TAO/tests/ORT/server.cpp @@ -4,7 +4,7 @@ #include "tao/ORBInitializer_Registry.h" #include "ace/Get_Opt.h" - +#include "ace/OS_NS_stdio.h" ACE_RCSID (ORT, server, diff --git a/TAO/tests/Object_Loader/driver.cpp b/TAO/tests/Object_Loader/driver.cpp index 09bfb389156..e7e9b391e0d 100644 --- a/TAO/tests/Object_Loader/driver.cpp +++ b/TAO/tests/Object_Loader/driver.cpp @@ -6,6 +6,7 @@ #include "tao/PortableServer/PortableServer.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" int main (int, char *[]) diff --git a/TAO/tests/Objref_Sequence_Test/server.cpp b/TAO/tests/Objref_Sequence_Test/server.cpp index 011522b63e6..77116586026 100644 --- a/TAO/tests/Objref_Sequence_Test/server.cpp +++ b/TAO/tests/Objref_Sequence_Test/server.cpp @@ -1,6 +1,7 @@ //$Id$ #include "TestS.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" /// Implement the Server Interface class ServerServant : diff --git a/TAO/tests/OctetSeq/client.cpp b/TAO/tests/OctetSeq/client.cpp index ee318e32589..b7ca3e5baf4 100644 --- a/TAO/tests/OctetSeq/client.cpp +++ b/TAO/tests/OctetSeq/client.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "ace/ACE.h" #include "testC.h" +#include "ace/OS_NS_time.h" ACE_RCSID(OctetSeq, client, "$Id$") diff --git a/TAO/tests/OctetSeq/server.cpp b/TAO/tests/OctetSeq/server.cpp index 321b30c8ca0..59e56b30f2d 100644 --- a/TAO/tests/OctetSeq/server.cpp +++ b/TAO/tests/OctetSeq/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (OctetSeq, server, diff --git a/TAO/tests/Oneway_Buffering/admin.cpp b/TAO/tests/Oneway_Buffering/admin.cpp index 58bf8444817..fae4e0193ff 100644 --- a/TAO/tests/Oneway_Buffering/admin.cpp +++ b/TAO/tests/Oneway_Buffering/admin.cpp @@ -2,6 +2,7 @@ #include "Oneway_Buffering_Admin.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Oneway_Buffering, admin, "$Id$") diff --git a/TAO/tests/Oneway_Buffering/server.cpp b/TAO/tests/Oneway_Buffering/server.cpp index c13787ce522..f25cfe7e532 100644 --- a/TAO/tests/Oneway_Buffering/server.cpp +++ b/TAO/tests/Oneway_Buffering/server.cpp @@ -2,6 +2,7 @@ #include "Oneway_Buffering.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Oneway_Buffering, server, "$Id$") diff --git a/TAO/tests/POA/Persistent_ID/server.cpp b/TAO/tests/POA/Persistent_ID/server.cpp index af1142da262..febe4a98a27 100644 --- a/TAO/tests/POA/Persistent_ID/server.cpp +++ b/TAO/tests/POA/Persistent_ID/server.cpp @@ -19,6 +19,7 @@ #include "ace/Get_Opt.h" #include "ace/SString.h" #include "testS.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Explicit_Activation, server, "$Id$") diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 64322419c79..a8ed5b88db3 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -16,6 +16,7 @@ #include "param_test_i.h" #include "tao/debug.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Param_Test, param_test_i, diff --git a/TAO/tests/Param_Test/server.cpp b/TAO/tests/Param_Test/server.cpp index f143b1f8848..d72a3003a37 100644 --- a/TAO/tests/Param_Test/server.cpp +++ b/TAO/tests/Param_Test/server.cpp @@ -17,6 +17,7 @@ #include "tao/debug.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Param_Test, server, diff --git a/TAO/tests/Policies/Manipulation.cpp b/TAO/tests/Policies/Manipulation.cpp index f2d9f2a742c..ac76f622273 100644 --- a/TAO/tests/Policies/Manipulation.cpp +++ b/TAO/tests/Policies/Manipulation.cpp @@ -7,6 +7,7 @@ #include "tao/Object_T.h" #include "ace/Get_Opt.h" #include "ace/Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Policies, Manipulation, "$Id$") diff --git a/TAO/tests/Portable_Interceptors/Benchmark/server.cpp b/TAO/tests/Portable_Interceptors/Benchmark/server.cpp index b63b2b96958..35bec9b15a9 100644 --- a/TAO/tests/Portable_Interceptors/Benchmark/server.cpp +++ b/TAO/tests/Portable_Interceptors/Benchmark/server.cpp @@ -8,6 +8,7 @@ #include "tao/ORBInitializer_Registry.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Benchmark, server, "$Id$") diff --git a/TAO/tests/Portable_Interceptors/Dynamic/server.cpp b/TAO/tests/Portable_Interceptors/Dynamic/server.cpp index 64748e9cd5a..b34e8d99fda 100644 --- a/TAO/tests/Portable_Interceptors/Dynamic/server.cpp +++ b/TAO/tests/Portable_Interceptors/Dynamic/server.cpp @@ -4,6 +4,7 @@ #include "test_i.h" #include "interceptors.h" #include "Echo_Server_ORBInitializer.h" +#include "ace/OS_NS_stdio.h" #include "tao/ORBInitializer_Registry.h" diff --git a/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp b/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp index af543165313..cad7955ec59 100644 --- a/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp +++ b/TAO/tests/Portable_Interceptors/ForwardRequest/server.cpp @@ -7,6 +7,7 @@ #include "Server_Request_Interceptor.h" #include "tao/ORBInitializer_Registry.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (ForwardRequest, server, diff --git a/TAO/tests/Portable_Interceptors/IORInterceptor/server.cpp b/TAO/tests/Portable_Interceptors/IORInterceptor/server.cpp index d34e10b1e8e..50c7de084f5 100644 --- a/TAO/tests/Portable_Interceptors/IORInterceptor/server.cpp +++ b/TAO/tests/Portable_Interceptors/IORInterceptor/server.cpp @@ -6,6 +6,7 @@ #include "FOO_IORInterceptor_ORBInitializer.h" #include "tao/ORBInitializer_Registry.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (IORInterceptor, server, diff --git a/TAO/tests/Portable_Interceptors/PICurrent/server.cpp b/TAO/tests/Portable_Interceptors/PICurrent/server.cpp index 4e6ae27cb3c..65241466d17 100644 --- a/TAO/tests/Portable_Interceptors/PICurrent/server.cpp +++ b/TAO/tests/Portable_Interceptors/PICurrent/server.cpp @@ -6,6 +6,7 @@ #include "ServerORBInitializer.h" #include "tao/ORBInitializer_Registry.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (PICurrent, server, diff --git a/TAO/tests/Portable_Interceptors/Request_Interceptor_Flow/server.cpp b/TAO/tests/Portable_Interceptors/Request_Interceptor_Flow/server.cpp index 9b257a0d6d2..6e4fa0d21d3 100644 --- a/TAO/tests/Portable_Interceptors/Request_Interceptor_Flow/server.cpp +++ b/TAO/tests/Portable_Interceptors/Request_Interceptor_Flow/server.cpp @@ -5,6 +5,7 @@ #include "Server_ORBInitializer.h" #include "tao/ORBInitializer_Registry.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Request_Interceptor_Flow, server, diff --git a/TAO/tests/Portable_Interceptors/Service_Context_Manipulation/server.cpp b/TAO/tests/Portable_Interceptors/Service_Context_Manipulation/server.cpp index fbdcbbf59d2..de1c0c7a340 100644 --- a/TAO/tests/Portable_Interceptors/Service_Context_Manipulation/server.cpp +++ b/TAO/tests/Portable_Interceptors/Service_Context_Manipulation/server.cpp @@ -6,6 +6,7 @@ #include "Server_ORBInitializer.h" #include "tao/ORBInitializer_Registry.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID (Service_Context_Manipulation, server, diff --git a/TAO/tests/Queued_Message_Test/Queued_Message_Test.cpp b/TAO/tests/Queued_Message_Test/Queued_Message_Test.cpp index b32c896cfb1..fdab05f2291 100644 --- a/TAO/tests/Queued_Message_Test/Queued_Message_Test.cpp +++ b/TAO/tests/Queued_Message_Test/Queued_Message_Test.cpp @@ -12,6 +12,8 @@ #include "ace/Log_Msg.h" #include "ace/Message_Block.h" #include "ace/ACE.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_time.h" ACE_RCSID (tests, Queued_Message_Test, diff --git a/TAO/tests/RTCORBA/ORB_init/ORB_init.cpp b/TAO/tests/RTCORBA/ORB_init/ORB_init.cpp index 91599546107..9277febd56e 100644 --- a/TAO/tests/RTCORBA/ORB_init/ORB_init.cpp +++ b/TAO/tests/RTCORBA/ORB_init/ORB_init.cpp @@ -3,6 +3,7 @@ #include "tao/RTCORBA/RTCORBA.h" #include "tao/ORB.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" int test_multiple_orbs (const char *test_name, diff --git a/TAO/tests/RTCORBA/Persistent_IOR/server.cpp b/TAO/tests/RTCORBA/Persistent_IOR/server.cpp index 8b4269ac9e7..0072fcc22a2 100644 --- a/TAO/tests/RTCORBA/Persistent_IOR/server.cpp +++ b/TAO/tests/RTCORBA/Persistent_IOR/server.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "testS.h" #include "tao/RTPortableServer/RTPortableServer.h" +#include "ace/OS_NS_stdio.h" class test_i : public POA_test, diff --git a/TAO/tests/RTCORBA/Private_Connection/server.cpp b/TAO/tests/RTCORBA/Private_Connection/server.cpp index 5d33dca1dfd..07a844b3abb 100644 --- a/TAO/tests/RTCORBA/Private_Connection/server.cpp +++ b/TAO/tests/RTCORBA/Private_Connection/server.cpp @@ -4,6 +4,7 @@ #include "tao/RTCORBA/RTCORBA.h" #include "tao/RTPortableServer/RTPortableServer.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" class Test_i : public POA_Test { diff --git a/TAO/tests/RTCORBA/common_args.cpp b/TAO/tests/RTCORBA/common_args.cpp index 27127bdbb06..44a898cb176 100644 --- a/TAO/tests/RTCORBA/common_args.cpp +++ b/TAO/tests/RTCORBA/common_args.cpp @@ -2,6 +2,8 @@ #include "ace/Read_Buffer.h" #include "ace/Array_Base.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_math.h" typedef ACE_Array_Base<CORBA::ULong> ULong_Array; diff --git a/TAO/tests/Reliable_Oneways/server.cpp b/TAO/tests/Reliable_Oneways/server.cpp index a198c55d3b5..a278c9a515b 100644 --- a/TAO/tests/Reliable_Oneways/server.cpp +++ b/TAO/tests/Reliable_Oneways/server.cpp @@ -2,6 +2,7 @@ #include "Oneway_Receiver.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Reliable_Oneways, server, "$Id$") diff --git a/TAO/tests/Server_Connection_Purging/server.cpp b/TAO/tests/Server_Connection_Purging/server.cpp index fb86ff9db55..52c7b5e6395 100644 --- a/TAO/tests/Server_Connection_Purging/server.cpp +++ b/TAO/tests/Server_Connection_Purging/server.cpp @@ -2,7 +2,7 @@ #include "Test_i.h" #include "ace/Get_Opt.h" - +#include "ace/OS_NS_stdio.h" const char *ior_output_file = "server.ior"; diff --git a/TAO/tests/Server_Leaks/server.cpp b/TAO/tests/Server_Leaks/server.cpp index 7ba0ae00538..0a037cdb95d 100644 --- a/TAO/tests/Server_Leaks/server.cpp +++ b/TAO/tests/Server_Leaks/server.cpp @@ -2,6 +2,7 @@ #include "Ping_Service.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Server_Leaks, server, "$Id$") diff --git a/TAO/tests/Single_Read/server.cpp b/TAO/tests/Single_Read/server.cpp index 13f7c855cfd..20af40930ea 100644 --- a/TAO/tests/Single_Read/server.cpp +++ b/TAO/tests/Single_Read/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Timed_Buffered_Oneways, server, "$Id$") diff --git a/TAO/tests/Timed_Buffered_Oneways/server.cpp b/TAO/tests/Timed_Buffered_Oneways/server.cpp index 13f7c855cfd..20af40930ea 100644 --- a/TAO/tests/Timed_Buffered_Oneways/server.cpp +++ b/TAO/tests/Timed_Buffered_Oneways/server.cpp @@ -2,6 +2,7 @@ #include "ace/Get_Opt.h" #include "test_i.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Timed_Buffered_Oneways, server, "$Id$") diff --git a/TAO/tests/Timeout/server.cpp b/TAO/tests/Timeout/server.cpp index 3d3109929b8..3fd05a6c9db 100644 --- a/TAO/tests/Timeout/server.cpp +++ b/TAO/tests/Timeout/server.cpp @@ -2,6 +2,7 @@ #include "test_i.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Timeout, server, "$Id$") diff --git a/TAO/utils/nslist/nslist.cpp b/TAO/utils/nslist/nslist.cpp index 4fa824a9fc3..c5693ea2710 100644 --- a/TAO/utils/nslist/nslist.cpp +++ b/TAO/utils/nslist/nslist.cpp @@ -21,6 +21,7 @@ #include "tao/Stub.h" #include "tao/ORB_Constants.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" CORBA::ORB_var orb; int showIOR = 0; diff --git a/ace/ACE.cpp b/ace/ACE.cpp index f1c924305a4..5499517e9ce 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -1,6 +1,11 @@ // $Id$ #include "ace/ACE.h" + +#if defined (ACE_LACKS_INLINE_FUNCTIONS) +#include "ace/ACE.i" +#endif /* ACE_LACKS_INLINE_FUNCTIONS */ + #include "ace/Basic_Types.h" #include "ace/Handle_Set.h" #include "ace/Auto_Ptr.h" @@ -8,10 +13,18 @@ #include "ace/Version.h" #include "ace/Message_Block.h" #include "ace/Log_Msg.h" - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "ace/ACE.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_resource.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_sys_uio.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_TLI.h" ACE_RCSID(ace, ACE, "$Id$") @@ -3469,7 +3482,7 @@ ACE::strnew (const wchar_t *s) return 0; wchar_t *t = 0; ACE_NEW_RETURN (t, - wchar_t[ACE_OS_String::strlen (s) + 1], + wchar_t[ACE_OS::strlen (s) + 1], 0); if (t == 0) return 0; diff --git a/ace/ACE.i b/ace/ACE.i index 189aa5d437d..dfc0b666a1e 100644 --- a/ace/ACE.i +++ b/ace/ACE.i @@ -1,6 +1,11 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_Thread.h" +#include "ace/os_include/os_ctype.h" +#include "ace/OS_NS_sys_socket.h" + // Wrappers for methods that have been moved to ACE_OS. ASYS_INLINE ssize_t diff --git a/ace/ARGV.cpp b/ace/ARGV.cpp index 0a833c6040d..448fa0a753f 100644 --- a/ace/ARGV.cpp +++ b/ace/ARGV.cpp @@ -10,7 +10,9 @@ #endif /* __ACE_INLINE__ */ #include "ace/Log_Msg.h" -#include "ace/OS.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" ACE_RCSID(ace, ARGV, "$Id$") diff --git a/ace/Acceptor.cpp b/ace/Acceptor.cpp index ceb657608f2..d7d2a9dea3b 100644 --- a/ace/Acceptor.cpp +++ b/ace/Acceptor.cpp @@ -11,7 +11,7 @@ #include "ace/Handle_Set.h" #include "ace/Svc_Handler.h" #include "ace/WFMO_Reactor.h" - +#include "ace/OS_NS_sys_select.h" ACE_RCSID (ace, Acceptor, diff --git a/ace/Active_Map_Manager.h b/ace/Active_Map_Manager.h index 52108cada96..b91fd261932 100644 --- a/ace/Active_Map_Manager.h +++ b/ace/Active_Map_Manager.h @@ -15,12 +15,14 @@ #define ACE_ACTIVE_MAP_MANAGER_H #include /**/ "ace/pre.h" -#include "ace/OS_String.h" +#include "ace/ACE_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Basic_Types.h" + /** * @class ACE_Active_Map_Manager_Key * diff --git a/ace/Active_Map_Manager.i b/ace/Active_Map_Manager.i index 0e73f7e50ec..05c29fd2069 100644 --- a/ace/Active_Map_Manager.i +++ b/ace/Active_Map_Manager.i @@ -2,6 +2,8 @@ // // $Id$ +#include "ace/OS_NS_string.h" + ACE_INLINE ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (void) { @@ -74,16 +76,16 @@ ACE_INLINE void ACE_Active_Map_Manager_Key::decode (const void *data) { // Copy the information from the user buffer into the key. - ACE_OS_String::memcpy (&this->key_data_, - data, - sizeof this->key_data_); + ACE_OS::memcpy (&this->key_data_, + data, + sizeof this->key_data_); } ACE_INLINE void ACE_Active_Map_Manager_Key::encode (void *data) const { // Copy the key data to the user buffer. - ACE_OS_String::memcpy (data, - &this->key_data_, - sizeof this->key_data_); + ACE_OS::memcpy (data, + &this->key_data_, + sizeof this->key_data_); } diff --git a/ace/Addr.cpp b/ace/Addr.cpp index b87f440caed..0c31a45170b 100644 --- a/ace/Addr.cpp +++ b/ace/Addr.cpp @@ -2,19 +2,19 @@ // $Id$ #include "ace/Addr.h" -#include "ace/Log_Msg.h" -#include "ace/OS.h" - ACE_RCSID(ace, Addr, "$Id$") -// Note: this object requires static construction and destruction. -/* static */ -const ACE_Addr ACE_Addr::sap_any (AF_ANY, -1); - #if !defined (__ACE_INLINE__) #include "ace/Addr.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/os_include/sys/os_socket.h" + +// Note: this object requires static construction and destruction. +/* static */ +const ACE_Addr ACE_Addr::sap_any (AF_ANY, -1); + ACE_ALLOC_HOOK_DEFINE(ACE_Addr) void diff --git a/ace/Arg_Shifter.cpp b/ace/Arg_Shifter.cpp index d174b4b0ef7..d179c5870c8 100644 --- a/ace/Arg_Shifter.cpp +++ b/ace/Arg_Shifter.cpp @@ -1,5 +1,6 @@ #include "ace/Arg_Shifter.h" -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" #include "ace/OS_Errno.h" #include "ace/OS_Memory.h" @@ -113,14 +114,14 @@ ACE_Arg_Shifter::cur_arg_strncasecmp (const ACE_TCHAR *flag) // Check for a current argument if (this->is_anything_left()) { - size_t flag_length = ACE_OS_String::strlen (flag); + size_t flag_length = ACE_OS::strlen (flag); // Check for presence of the flag - if (ACE_OS_String::strncasecmp(this->temp_[current_index_], - flag, - flag_length) == 0) + if (ACE_OS::strncasecmp(this->temp_[current_index_], + flag, + flag_length) == 0) { - if (ACE_OS_String::strlen(temp_[current_index_]) == + if (ACE_OS::strlen(temp_[current_index_]) == flag_length) { // match and lengths are equal @@ -129,7 +130,7 @@ ACE_Arg_Shifter::cur_arg_strncasecmp (const ACE_TCHAR *flag) else { // matches, with more info to boot! - size_t remaining = ACE_OS_String::strspn + size_t remaining = ACE_OS::strspn (this->temp_[current_index_] + flag_length, ACE_LIB_TEXT (" ")) + flag_length; return ACE_static_cast (int, remaining); diff --git a/ace/Argv_Type_Converter.cpp b/ace/Argv_Type_Converter.cpp index 23ea5dd90ef..8d96ee77659 100644 --- a/ace/Argv_Type_Converter.cpp +++ b/ace/Argv_Type_Converter.cpp @@ -10,7 +10,7 @@ ACE_RCSID (ace, Argv_Type_Converter, "$Id$") -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" #include "ace/OS_Errno.h" #if defined (ACE_USES_WCHAR) @@ -28,7 +28,7 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter(int &argc, wchar_t** argv) for (int i = 0; i < argc; ++i) { this->char_argv_[i] = - ACE_OS_String::strdup (ACE_TEXT_ALWAYS_CHAR (argv[i])); + ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (argv[i])); } } #endif // ACE_USES_WCHAR @@ -49,7 +49,7 @@ ACE_Argv_Type_Converter::ACE_Argv_Type_Converter(int &argc, char** argv) for (int i = 0; i < argc; ++i) { this->wchar_argv_[i] = - ACE_OS_String::strdup (ACE_TEXT_ANTI_TO_TCHAR (argv[i])); + ACE_OS::strdup (ACE_TEXT_ANTI_TO_TCHAR (argv[i])); } } #else @@ -117,14 +117,14 @@ ACE_Argv_Type_Converter::align_char_with_wchar (void) while (wchar_argv_index < this->saved_argc_) { // if n'th entries of both argv lists are different - if (ACE_OS_String::strcmp(this->char_argv_[wchar_argv_index], + if (ACE_OS::strcmp(this->char_argv_[wchar_argv_index], ACE_TEXT_ALWAYS_CHAR (match_argv)) != 0) { // loop through the wchar argv list entries that are after // wchar_argv_index for (int i = wchar_argv_index + 1; i < before_pass_argc_; ++i) { - if (ACE_OS_String::strcmp (this->char_argv_[i], + if (ACE_OS::strcmp (this->char_argv_[i], ACE_TEXT_ALWAYS_CHAR (match_argv)) == 0) { @@ -153,7 +153,7 @@ ACE_Argv_Type_Converter::align_wchar_with_char (void) while (char_argv_index < saved_argc_) { // if n'th entries of both argv lists are different - if (ACE_OS_String::strcmp ( + if (ACE_OS::strcmp ( ACE_TEXT_ALWAYS_CHAR (this->wchar_argv_[char_argv_index]), match_argv) != 0) { @@ -161,7 +161,7 @@ ACE_Argv_Type_Converter::align_wchar_with_char (void) // wchar_argv_index for (int i = char_argv_index + 1; i < this->before_pass_argc_; ++i) { - if (ACE_OS_String::strcmp ( + if (ACE_OS::strcmp ( ACE_TEXT_ALWAYS_CHAR(this->wchar_argv_[i]), match_argv) == 0) { // swap the pointers in the char argv list diff --git a/ace/Asynch_Acceptor.cpp b/ace/Asynch_Acceptor.cpp index 5070e55aa60..ace690bf0ce 100644 --- a/ace/Asynch_Acceptor.cpp +++ b/ace/Asynch_Acceptor.cpp @@ -15,7 +15,6 @@ ACE_RCSID(ace, Asynch_Acceptor, "$Id$") #if defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS) // This only works on platforms that support async i/o. -#include "ace/OS.h" #include "ace/Log_Msg.h" #include "ace/Message_Block.h" #include "ace/INET_Addr.h" diff --git a/ace/Asynch_IO_Impl.cpp b/ace/Asynch_IO_Impl.cpp index 8f26d82ae4b..b8cd305a2b9 100644 --- a/ace/Asynch_IO_Impl.cpp +++ b/ace/Asynch_IO_Impl.cpp @@ -5,7 +5,6 @@ #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)) // This only works on Win32 platforms and on Unix platforms supporting // aio calls. -#include "ace/OS.h" #if !defined (__ACE_INLINE__) #include "ace/Asynch_IO_Impl.i" diff --git a/ace/Asynch_Pseudo_Task.cpp b/ace/Asynch_Pseudo_Task.cpp index 1e795b8c7e9..9996497475a 100644 --- a/ace/Asynch_Pseudo_Task.cpp +++ b/ace/Asynch_Pseudo_Task.cpp @@ -2,6 +2,8 @@ #include "ace/Asynch_Pseudo_Task.h" +#include "ace/OS_NS_signal.h" + ACE_RCSID(ace, Asynch_Pseudo_Task, "$Id$") ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task() diff --git a/ace/Atomic_Op.cpp b/ace/Atomic_Op.cpp index caec772adf8..daa6f93e98a 100644 --- a/ace/Atomic_Op.cpp +++ b/ace/Atomic_Op.cpp @@ -1,7 +1,7 @@ // $Id$ #include "ace/Atomic_Op.h" -#include "ace/OS.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(ace, Atomic_Op, "$Id$") diff --git a/ace/Auto_Event.cpp b/ace/Auto_Event.cpp index ee217091021..2c29a7dd24e 100644 --- a/ace/Auto_Event.cpp +++ b/ace/Auto_Event.cpp @@ -9,6 +9,18 @@ ACE_RCSID(ace, Auto_Event, "$Id$") +ACE_Auto_Event::ACE_Auto_Event (int initial_state, + int type, + const char *name, + void *arg) + : ACE_Event (0, + initial_state, + type, + ACE_TEXT_CHAR_TO_TCHAR (name), + arg) +{ +} + #if defined (ACE_HAS_WCHAR) ACE_Auto_Event::ACE_Auto_Event (int initial_state, int type, diff --git a/ace/Barrier.cpp b/ace/Barrier.cpp index d9763395ee4..54d35411410 100644 --- a/ace/Barrier.cpp +++ b/ace/Barrier.cpp @@ -8,6 +8,8 @@ #include "ace/Barrier.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Guard_T.h" + ACE_RCSID(ace, Barrier, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Sub_Barrier) diff --git a/ace/Base_Thread_Adapter.cpp b/ace/Base_Thread_Adapter.cpp index b2f1326cf00..b6fcbb8f9eb 100644 --- a/ace/Base_Thread_Adapter.cpp +++ b/ace/Base_Thread_Adapter.cpp @@ -1,7 +1,6 @@ // $Id$ #include "ace/Base_Thread_Adapter.h" -#include "ace/OS.h" ACE_RCSID(ace, Base_Thread_Adapter, "$Id$") diff --git a/ace/Basic_Types.cpp b/ace/Basic_Types.cpp index f58419f09e8..eef8d0e18eb 100644 --- a/ace/Basic_Types.cpp +++ b/ace/Basic_Types.cpp @@ -1,4 +1,4 @@ -#include "ace/OS.h" +#include "ace/Basic_Types.h" #if !defined (__ACE_INLINE__) # include "ace/Basic_Types.i" diff --git a/ace/Basic_Types.h b/ace/Basic_Types.h index 988bc3c2db8..12fab11d78d 100644 --- a/ace/Basic_Types.h +++ b/ace/Basic_Types.h @@ -303,6 +303,33 @@ typedef ptrdiff_t ptr_arith_t; # endif # endif /* ! BYTE_ORDER && ! __BYTE_ORDER */ +// Byte swapping macros to deal with differences between little endian +// and big endian machines. Note that "long" here refers to 32 bit +// quantities. +# define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \ + | ACE_SWAP_WORD(((L) >> 16) & 0xFFFF)) +# define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8)) + +# if defined (ACE_LITTLE_ENDIAN) +# define ACE_HTONL(X) ACE_SWAP_LONG (X) +# define ACE_NTOHL(X) ACE_SWAP_LONG (X) +# define ACE_IDL_NCTOHL(X) (X) +# define ACE_IDL_NSTOHL(X) (X) +# else +# define ACE_HTONL(X) X +# define ACE_NTOHL(X) X +# define ACE_IDL_NCTOHL(X) (X << 24) +# define ACE_IDL_NSTOHL(X) ((X) << 16) +# endif /* ACE_LITTLE_ENDIAN */ + +# if defined (ACE_LITTLE_ENDIAN) +# define ACE_HTONS(x) ACE_SWAP_WORD(x) +# define ACE_NTOHS(x) ACE_SWAP_WORD(x) +# else +# define ACE_HTONS(x) x +# define ACE_NTOHS(x) x +# endif /* ACE_LITTLE_ENDIAN */ + #if defined (ACE_LACKS_LONGLONG_T) // This throws away the high 32 bits. It's very unlikely that a // pointer will be more than 32 bits wide if the platform does not diff --git a/ace/CDR_Base.cpp b/ace/CDR_Base.cpp index 402d3b2d139..50fda0659c5 100644 --- a/ace/CDR_Base.cpp +++ b/ace/CDR_Base.cpp @@ -1,11 +1,13 @@ #include "ace/CDR_Base.h" -#include "ace/Message_Block.h" -#include "ace/OS.h" #if !defined (__ACE_INLINE__) # include "ace/CDR_Base.inl" #endif /* ! __ACE_INLINE__ */ +#include "ace/Message_Block.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" + ACE_RCSID (ace, CDR_Base, "$Id$") diff --git a/ace/CDR_Stream.i b/ace/CDR_Stream.i index 867a32983f7..48014ecbe43 100644 --- a/ace/CDR_Stream.i +++ b/ace/CDR_Stream.i @@ -249,7 +249,7 @@ ACE_OutputCDR::write_string (const ACE_CDR::Char *x) if (x != 0) { ACE_CDR::ULong len = - ACE_static_cast (ACE_CDR::ULong, ACE_OS_String::strlen (x)); + ACE_static_cast (ACE_CDR::ULong, ACE_OS::strlen (x)); return this->write_string (len, x); } return this->write_string (0, 0); @@ -259,7 +259,7 @@ ACE_INLINE ACE_CDR::Boolean ACE_OutputCDR::write_wstring (const ACE_CDR::WChar *x) { if (x != 0) - return this->write_wstring (ACE_OS_String::strlen (x), x); + return this->write_wstring (ACE_OS::strlen (x), x); return this->write_wstring (0, 0); } @@ -1125,7 +1125,7 @@ operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_string x) { ACE_CDR::ULong len = 0; if (x.val_ != 0) - len = ACE_static_cast (ACE_CDR::ULong, ACE_OS_String::strlen (x.val_)); + len = ACE_static_cast (ACE_CDR::ULong, ACE_OS::strlen (x.val_)); os.write_string (len, x.val_); return os.good_bit () && (!x.bound_ || len <= x.bound_); } @@ -1135,7 +1135,7 @@ operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wstring x) { ACE_CDR::ULong len = 0;; if (x.val_ != 0) - len = ACE_OS_String::strlen (x.val_); + len = ACE_OS::strlen (x.val_); os.write_wstring (len, x.val_); return os.good_bit () && (!x.bound_ || len <= x.bound_); } @@ -1261,7 +1261,7 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_string x) is.read_string (ACE_const_cast (char *&, x.val_)); // check if the bounds are satisfied return (is.good_bit () - && (!x.bound_ || ACE_OS_String::strlen (x.val_) <= x.bound_)); + && (!x.bound_ || ACE_OS::strlen (x.val_) <= x.bound_)); } ACE_INLINE ACE_CDR::Boolean @@ -1270,7 +1270,7 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x) is.read_wstring (ACE_const_cast (ACE_CDR::WChar *&, x.val_)); // check if the bounds are satisfied return (is.good_bit () - && (!x.bound_ || ACE_OS_String::strlen (x.val_) <= x.bound_)); + && (!x.bound_ || ACE_OS::strlen (x.val_) <= x.bound_)); } // *************************************************************************** diff --git a/ace/CE_Screen_Output.h b/ace/CE_Screen_Output.h index 0571fe39b88..5252b810fb1 100644 --- a/ace/CE_Screen_Output.h +++ b/ace/CE_Screen_Output.h @@ -21,7 +21,6 @@ #if defined (ACE_HAS_WINCE) -#include "ace/OS.h" #include "ace/Log_Msg_Callback.h" #include "ace/Log_Record.h" diff --git a/ace/CLASSIX/CLASSIX_OS.h b/ace/CLASSIX/CLASSIX_OS.h index aa2d213b655..83025d49d74 100644 --- a/ace/CLASSIX/CLASSIX_OS.h +++ b/ace/CLASSIX/CLASSIX_OS.h @@ -19,7 +19,7 @@ #define ACE_CLASSIX_OS_H /* ------------------------------------------------------------------------- */ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/CLASSIX/CLASSIX_Port_Core.h b/ace/CLASSIX/CLASSIX_Port_Core.h index d0a409ae68d..75be7023f16 100644 --- a/ace/CLASSIX/CLASSIX_Port_Core.h +++ b/ace/CLASSIX/CLASSIX_Port_Core.h @@ -19,7 +19,7 @@ #define ACE_CLASSIX_PORT_CORE_H /* ------------------------------------------------------------------------- */ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Capabilities.cpp b/ace/Capabilities.cpp index 9f5db74fc7d..80c8eb9ced6 100644 --- a/ace/Capabilities.cpp +++ b/ace/Capabilities.cpp @@ -1,10 +1,10 @@ #include "ace/Capabilities.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) #include "ace/Capabilities.i" #endif /* !__ACE_INLINE__ */ +#include "ace/OS_NS_stdio.h" ACE_RCSID (ace, Capabilities, diff --git a/ace/Cleanup.cpp b/ace/Cleanup.cpp index fc532b41367..bd3480d5f3b 100644 --- a/ace/Cleanup.cpp +++ b/ace/Cleanup.cpp @@ -1,4 +1,189 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/Cleanup.h" + +ACE_RCSID(ace, Cleanup, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Cleanup.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/OS_Memory.h" + +void +ACE_Cleanup::cleanup (void *) +{ + delete this; +} + + +ACE_Cleanup::~ACE_Cleanup (void) +{ +} + +/*****************************************************************************/ + +extern "C" void +ace_cleanup_destroyer (ACE_Cleanup *object, void *param) +{ + object->cleanup (param); +} + +/*****************************************************************************/ + +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 + * + * @brief For maintaining a list of ACE_Cleanup_Info items. + * + * For internal use by ACE_Object_Manager. + */ +class ACE_Cleanup_Info_Node +{ +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_); + } +} + + diff --git a/ace/Cleanup.h b/ace/Cleanup.h index fc532b41367..953b6ae5fb1 100644 --- a/ace/Cleanup.h +++ b/ace/Cleanup.h @@ -1,4 +1,125 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file Cleanup.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_CLEANUP_H +# define ACE_CLEANUP_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_Export.h" +/** + * @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_; +}; + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/Cleanup.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_CLEANUP_H */ diff --git a/ace/Cleanup.inl b/ace/Cleanup.inl index fc532b41367..841c715bf1a 100644 --- a/ace/Cleanup.inl +++ b/ace/Cleanup.inl @@ -1,4 +1,7 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE +ACE_Cleanup::ACE_Cleanup (void) +{ +} diff --git a/ace/Codecs.cpp b/ace/Codecs.cpp index 8d0aad7555d..872393086d6 100644 --- a/ace/Codecs.cpp +++ b/ace/Codecs.cpp @@ -1,6 +1,7 @@ -#include "ace/OS.h" #include "ace/Codecs.h" #include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_ctype.h" ACE_RCSID (ace, Codecs, @@ -99,7 +100,7 @@ ACE_Base64::length (const ACE_Byte* input) ACE_Byte* ptr = ACE_const_cast (ACE_Byte*, input); while (*ptr != 0 && (member_[*(ptr)] == 1 || *ptr == pad_ - || ACE_OS_String::ace_isspace (*ptr))) + || ACE_OS::ace_isspace (*ptr))) ptr++; size_t len = ptr - input; len = ((len + 3) / 4) * 3 + 1 ; @@ -122,7 +123,7 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) ACE_Byte* ptr = ACE_const_cast (ACE_Byte*, input); while (*ptr != 0 && (member_[*(ptr)] == 1 || *ptr == pad_ - || ACE_OS_String::ace_isspace (*ptr))) + || ACE_OS::ace_isspace (*ptr))) ptr++; size_t input_len = ptr - input; diff --git a/ace/Condition_Thread_Mutex.cpp b/ace/Condition_Thread_Mutex.cpp index d9fc98250f5..0c50c0c0373 100644 --- a/ace/Condition_Thread_Mutex.cpp +++ b/ace/Condition_Thread_Mutex.cpp @@ -17,6 +17,8 @@ #include "ace/Condition_Thread_Mutex.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" + ACE_RCSID(ace, Condition_Thread_Mutex, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex) diff --git a/ace/Configuration.cpp b/ace/Configuration.cpp index 10a3af85a6e..413d3f3c44e 100644 --- a/ace/Configuration.cpp +++ b/ace/Configuration.cpp @@ -216,7 +216,7 @@ ACE_Configuration::validate_name (const ACE_TCHAR* name, int allow_path) allow_path ? ACE_LIB_TEXT ("][") : ACE_LIB_TEXT ("\\]["); // Position of the first invalid character or terminating null. - size_t pos = ACE_OS_String::strcspn (name, reject); + size_t pos = ACE_OS::strcspn (name, reject); // Check if it is an invalid character. if (name[pos] != ACE_LIB_TEXT ('\0')) @@ -1634,7 +1634,7 @@ ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, result = base; for (const ACE_TCHAR* separator; - (separator = ACE_OS_String::strchr (sub_section, ACE_TEXT ('\\'))) != 0; + (separator = ACE_OS::strchr (sub_section, ACE_TEXT ('\\'))) != 0; ) { ACE_TString simple_section (sub_section, separator - sub_section); diff --git a/ace/Configuration_Import_Export.cpp b/ace/Configuration_Import_Export.cpp index 079bcda19e3..19913d4e00b 100644 --- a/ace/Configuration_Import_Export.cpp +++ b/ace/Configuration_Import_Export.cpp @@ -1,6 +1,9 @@ // $Id$ #include "ace/Configuration_Import_Export.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_ctype.h" + ACE_Config_ImpExp_Base::ACE_Config_ImpExp_Base (ACE_Configuration& config) : config_ (config) @@ -306,7 +309,7 @@ ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer, ACE_Configuration_Section_Key& section) { // Chop any cr/lf at the end of the line. - ACE_TCHAR *endp = ACE_OS_String::strpbrk (buffer, ACE_LIB_TEXT ("\r\n")); + ACE_TCHAR *endp = ACE_OS::strpbrk (buffer, ACE_LIB_TEXT ("\r\n")); if (endp != 0) *endp = '\0'; @@ -597,15 +600,15 @@ ACE_Ini_ImpExp::squish (ACE_TCHAR *src) return 0; // Start at the end and work backwards over all whitespace. - for (cp = src + ACE_OS_String::strlen (src) - 1; + for (cp = src + ACE_OS::strlen (src) - 1; cp != src; --cp) - if (!ACE_OS_String::ace_isspace (*cp)) + if (!ACE_OS::ace_isspace (*cp)) break; cp[1] = '\0'; // Chop trailing whitespace // Now start at the beginning and move over all whitespace. - for (cp = src; ACE_OS_String::ace_isspace (*cp); ++cp) + for (cp = src; ACE_OS::ace_isspace (*cp); ++cp) continue; return cp; diff --git a/ace/DEV.cpp b/ace/DEV.cpp index 79f70a4e52d..613b47c0ebc 100644 --- a/ace/DEV.cpp +++ b/ace/DEV.cpp @@ -8,7 +8,7 @@ #include "ace/DEV.i" #endif -#include "ace/OS.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(ace, DEV, "$Id$") diff --git a/ace/DEV_IO.h b/ace/DEV_IO.h index 1c2bbee6c31..8db9b31d54f 100644 --- a/ace/DEV_IO.h +++ b/ace/DEV_IO.h @@ -25,6 +25,8 @@ #include "ace/os_include/os_stdio.h" #include "ace/os_include/sys/os_uio.h" +class ACE_Time_Value; + /** * @class ACE_DEV_IO * diff --git a/ace/DEV_IO.i b/ace/DEV_IO.i index a890cc96024..b491d130e80 100644 --- a/ace/DEV_IO.i +++ b/ace/DEV_IO.i @@ -3,6 +3,8 @@ // DEV_IO.i +#include "ace/OS_NS_sys_uio.h" + #include "ace/ACE.h" // Send exactly N bytes from BUF to this device. Keeping trying until diff --git a/ace/DLL.cpp b/ace/DLL.cpp index 2ec87488aa3..e42db1f700a 100644 --- a/ace/DLL.cpp +++ b/ace/DLL.cpp @@ -6,6 +6,8 @@ #include "ace/Log_Msg.h" #include "ace/ACE.h" #include "ace/DLL_Manager.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_dlfcn.h" ACE_RCSID(ace, DLL, "$Id$") @@ -119,7 +121,7 @@ ACE_DLL::open_i (const ACE_TCHAR *dll_filename, if (this->dll_handle_) { // If we have a good handle and its the same name, just return. - if (ACE_OS_String::strcmp (this->dll_name_, dll_filename) == 0) + if (ACE_OS::strcmp (this->dll_name_, dll_filename) == 0) return 0; else this->close (); diff --git a/ace/DLL_Manager.cpp b/ace/DLL_Manager.cpp index 02986399cfc..7d308fbf10e 100644 --- a/ace/DLL_Manager.cpp +++ b/ace/DLL_Manager.cpp @@ -7,12 +7,12 @@ #include "ace/ACE.h" #include "ace/Framework_Component.h" -#include "ace/OS.h" #include "ace/Lib_Find.h" #include "ace/Object_Manager.h" #include "ace/SString.h" #include "ace/Recursive_Thread_Mutex.h" #include "ace/Guard_T.h" +#include "ace/OS_NS_dlfcn.h" ACE_RCSID (ace, DLL_Manager, @@ -59,7 +59,7 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, if (this->dll_name_) { // Once dll_name_ has been set, it can't be changed.. - if (ACE_OS_String::strcmp (this->dll_name_, dll_name) != 0) + if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0) { if (ACE::debug ()) ACE_ERROR ((LM_ERROR, @@ -106,9 +106,9 @@ ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, // AIX often puts the shared library file (most often named shr.o) // inside an archive library. If this is an archive library // name, then try appending [shr.o] and retry. - if (0 != ACE_OS_String::strstr (dll_pathname, ACE_LIB_TEXT (".a"))) + if (0 != ACE_OS::strstr (dll_pathname, ACE_LIB_TEXT (".a"))) { - ACE_OS_String::strcat (dll_pathname, ACE_LIB_TEXT ("(shr.o)")); + ACE_OS::strcat (dll_pathname, ACE_LIB_TEXT ("(shr.o)")); open_mode |= RTLD_MEMBER; this->handle_ = ACE_OS::dlopen (dll_pathname, open_mode); } @@ -471,7 +471,7 @@ ACE_DLL_Manager::find_dll (const ACE_TCHAR *dll_name) const int i; for (i = 0; i < this->current_size_; i++) if (this->handle_vector_[i] && - ACE_OS_String::strcmp (this->handle_vector_[i]->dll_name (), dll_name) == 0) + ACE_OS::strcmp (this->handle_vector_[i]->dll_name (), dll_name) == 0) { return this->handle_vector_[i]; } diff --git a/ace/Date_Time.i b/ace/Date_Time.i index a3b26d21360..1e7768fca0d 100644 --- a/ace/Date_Time.i +++ b/ace/Date_Time.i @@ -3,8 +3,10 @@ // Date_Time.i -#include "ace/OS.h" +#include "ace/Global_Macros.h" #include "ace/Time_Value.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" ASYS_INLINE void ACE_Date_Time::update (void) diff --git a/ace/Default_Constants.h b/ace/Default_Constants.h index bf50f37b98b..c095ed94964 100644 --- a/ace/Default_Constants.h +++ b/ace/Default_Constants.h @@ -326,14 +326,8 @@ // A simple free list which doen't allocate/deallocate elements. # define ACE_PURE_FREE_LIST 2 -# if defined (INTEGRITY) -# define ACE_MAX_USERID 32 -# endif - # if defined (ACE_WIN32) -#define ACE_MAX_USERID 32 - // This is necessary to work around bugs with Win32 non-blocking // connects... # if !defined (ACE_NON_BLOCKING_BUG_DELAY) @@ -523,5 +517,15 @@ const unsigned int ACE_CONNECTOR_HANDLER_MAP_SIZE = 16; #define ACE_DEFAULT_LOCALNAME ACE_LIB_TEXT (ACE_DEFAULT_LOCALNAME_A) #define ACE_DEFAULT_GLOBALNAME ACE_LIB_TEXT (ACE_DEFAULT_GLOBALNAME_A) +# if defined (ACE_WIN32) + // The "null" device on Win32. +# define ACE_DEV_NULL "nul" +# define ACE_SYSCALL_FAILED 0xFFFFFFFF +# else /* !ACE_WIN32 */ + // The "null" device on UNIX. +# define ACE_DEV_NULL "/dev/null" +# define ACE_SYSCALL_FAILED -1 +# endif /* ACE_WIN32 */ + #include /**/ "ace/post.h" #endif /*ACE_DEFAULT_CONSTANTS_H*/ diff --git a/ace/Dirent.h b/ace/Dirent.h index bf3732361ba..8a0792d3153 100644 --- a/ace/Dirent.h +++ b/ace/Dirent.h @@ -23,7 +23,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS_Dirent.h" +#include "ace/OS_NS_dirent.h" /** * @class ACE_Dirent diff --git a/ace/Dirent.i b/ace/Dirent.i index 4c731311c29..59b0969fa2d 100644 --- a/ace/Dirent.i +++ b/ace/Dirent.i @@ -11,11 +11,11 @@ ACE_Dirent::open (const ACE_TCHAR *dirname) if (this->dirp_ != 0) { - ACE_OS_Dirent::closedir (this->dirp_); + ACE_OS::closedir (this->dirp_); this->dirp_ = 0; } - this->dirp_ = ACE_OS_Dirent::opendir (dirname); + this->dirp_ = ACE_OS::opendir (dirname); if (this->dirp_ == 0) return -1; @@ -43,13 +43,13 @@ ACE_INLINE ACE_Dirent::~ACE_Dirent (void) { if (this->dirp_ != 0) - ACE_OS_Dirent::closedir (this->dirp_); + ACE_OS::closedir (this->dirp_); } ACE_INLINE dirent * ACE_Dirent::read (void) { - return this->dirp_ ? ACE_OS_Dirent::readdir (this->dirp_) : 0; + return this->dirp_ ? ACE_OS::readdir (this->dirp_) : 0; } ACE_INLINE int @@ -57,7 +57,7 @@ ACE_Dirent::read (struct dirent *entry, struct dirent **result) { return this->dirp_ - ? ACE_OS_Dirent::readdir_r (this->dirp_, entry, result) + ? ACE_OS::readdir_r (this->dirp_, entry, result) : 0; } @@ -66,7 +66,7 @@ ACE_Dirent::close (void) { if (this->dirp_ != 0) { - ACE_OS_Dirent::closedir (this->dirp_); + ACE_OS::closedir (this->dirp_); // Prevent double closure this->dirp_ = 0; @@ -77,19 +77,19 @@ ACE_INLINE void ACE_Dirent::rewind (void) { if (this->dirp_) - ACE_OS_Dirent::rewinddir (this->dirp_); + ACE_OS::rewinddir (this->dirp_); } ACE_INLINE void ACE_Dirent::seek (long loc) { if (this->dirp_) - ACE_OS_Dirent::seekdir (this->dirp_, loc); + ACE_OS::seekdir (this->dirp_, loc); } ACE_INLINE long ACE_Dirent::tell (void) { - return this->dirp_ ? ACE_OS_Dirent::telldir (this->dirp_) : 0; + return this->dirp_ ? ACE_OS::telldir (this->dirp_) : 0; } diff --git a/ace/Dirent_Selector.cpp b/ace/Dirent_Selector.cpp index bef6c40a8d1..213db98f4a2 100644 --- a/ace/Dirent_Selector.cpp +++ b/ace/Dirent_Selector.cpp @@ -1,12 +1,14 @@ // $Id$ -#include "ace/OS.h" #include "ace/Dirent_Selector.h" #if !defined (__ACE_INLINE__) #include "ace/Dirent_Selector.inl" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_dirent.h" +#include "ace/OS_NS_stdlib.h" + ACE_RCSID (ace, Dirent_Selector, "$Id$") diff --git a/ace/Dirent_Selector.h b/ace/Dirent_Selector.h index c2b73c5906c..8985e4a930a 100644 --- a/ace/Dirent_Selector.h +++ b/ace/Dirent_Selector.h @@ -16,11 +16,13 @@ #define ACE_DIRENT_SELECTOR_H #include /**/ "ace/pre.h" +#include "ace/ACE_export.h" + #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/ACE_export.h" +#include "ace/os_include/os_dirent.h" /** * @class ACE_Dirent_Selector diff --git a/ace/Env_Value_T.h b/ace/Env_Value_T.h index fc816597cca..e344e325486 100644 --- a/ace/Env_Value_T.h +++ b/ace/Env_Value_T.h @@ -25,8 +25,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" - /** * @class ACE_Env_Value * diff --git a/ace/Event.cpp b/ace/Event.cpp index 7656e51eeeb..06c14937acd 100644 --- a/ace/Event.cpp +++ b/ace/Event.cpp @@ -6,6 +6,8 @@ #include "ace/Event.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" + ACE_RCSID(ace, Event, "$Id$") ACE_Event::ACE_Event (int manual_reset, diff --git a/ace/Event.h b/ace/Event.h index 7d9326a4be9..b160b14b3ac 100644 --- a/ace/Event.h +++ b/ace/Event.h @@ -22,7 +22,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/OS_NS_Thread.h" /** * @class ACE_Event diff --git a/ace/FIFO.cpp b/ace/FIFO.cpp index 50bae5e33a5..3a24e81d6e8 100644 --- a/ace/FIFO.cpp +++ b/ace/FIFO.cpp @@ -2,12 +2,16 @@ // $Id$ #include "ace/FIFO.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) #include "ace/FIFO.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_sys_stat.h" + ACE_RCSID(ace, FIFO, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_FIFO) diff --git a/ace/FIFO.i b/ace/FIFO.i index d640bb8141f..0c91ceaca3f 100644 --- a/ace/FIFO.i +++ b/ace/FIFO.i @@ -3,6 +3,8 @@ // FIFO.i +#include "ace/OS_NS_unistd.h" + ACE_INLINE int ACE_FIFO::get_local_addr (const ACE_TCHAR *&r) const { diff --git a/ace/FIFO_Recv.i b/ace/FIFO_Recv.i index 82f1317d013..29d951b044d 100644 --- a/ace/FIFO_Recv.i +++ b/ace/FIFO_Recv.i @@ -3,7 +3,6 @@ // FIFO_Recv.i -#include "ace/OS.h" #include "ace/ACE.h" ASYS_INLINE ssize_t diff --git a/ace/FIFO_Recv_Msg.cpp b/ace/FIFO_Recv_Msg.cpp index 6de0d35cd72..2c01f948e54 100644 --- a/ace/FIFO_Recv_Msg.cpp +++ b/ace/FIFO_Recv_Msg.cpp @@ -2,12 +2,13 @@ // $Id$ #include "ace/FIFO_Recv_Msg.h" -#include "ace/Log_Msg.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/FIFO_Recv_Msg.i" #endif +#include "ace/Log_Msg.h" + ACE_RCSID(ace, FIFO_Recv_Msg, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv_Msg) diff --git a/ace/FIFO_Recv_Msg.i b/ace/FIFO_Recv_Msg.i index 8ba99042003..a29d8f345fc 100644 --- a/ace/FIFO_Recv_Msg.i +++ b/ace/FIFO_Recv_Msg.i @@ -3,6 +3,8 @@ // FIFO_Recv_Msg.i +#include "ace/Min_Max.h" + ASYS_INLINE ssize_t ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg) { diff --git a/ace/FIFO_Send.i b/ace/FIFO_Send.i index bcc7abecb93..9b85feb9902 100644 --- a/ace/FIFO_Send.i +++ b/ace/FIFO_Send.i @@ -3,7 +3,6 @@ // FIFO_Send.i -#include "ace/OS.h" #include "ace/ACE.h" ASYS_INLINE ssize_t diff --git a/ace/FIFO_Send_Msg.cpp b/ace/FIFO_Send_Msg.cpp index bddba5baf38..c5173781581 100644 --- a/ace/FIFO_Send_Msg.cpp +++ b/ace/FIFO_Send_Msg.cpp @@ -1,12 +1,14 @@ // $Id$ #include "ace/FIFO_Send_Msg.h" -#include "ace/Log_Msg.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/FIFO_Send_Msg.i" #endif +#include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_uio.h" + ACE_RCSID(ace, FIFO_Send_Msg, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send_Msg) diff --git a/ace/FILE.cpp b/ace/FILE.cpp index 70e6f437b1d..a2734680901 100644 --- a/ace/FILE.cpp +++ b/ace/FILE.cpp @@ -10,7 +10,8 @@ #include "ace/FILE.i" #endif -#include "ace/OS.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_stat.h" ACE_RCSID(ace, FILE, "$Id$") diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp index 366ffde711a..4f6226151e5 100644 --- a/ace/FILE_IO.cpp +++ b/ace/FILE_IO.cpp @@ -2,12 +2,14 @@ // $Id$ #include "ace/FILE_IO.h" -#include "ace/Log_Msg.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/FILE_IO.i" #endif +#include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_stat.h" + ACE_RCSID(ace, FILE_IO, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_FILE_IO) diff --git a/ace/FILE_IO.i b/ace/FILE_IO.i index fd9a634a1be..7100c980032 100644 --- a/ace/FILE_IO.i +++ b/ace/FILE_IO.i @@ -4,6 +4,7 @@ // FILE_IO.i #include "ace/ACE.h" +#include "ace/OS_NS_sys_uio.h" ASYS_INLINE ssize_t ACE_FILE_IO::sendv_n (const iovec iov[], int n) const diff --git a/ace/File_Lock.h b/ace/File_Lock.h index 5d7b578ef8e..90bd40dedfa 100644 --- a/ace/File_Lock.h +++ b/ace/File_Lock.h @@ -14,12 +14,14 @@ #define ACE_FILE_LOCK_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/ACE_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/OS_NS_stdio.h" + /** * @class ACE_File_Lock * diff --git a/ace/Filecache.cpp b/ace/Filecache.cpp index 68ab4bf6ce0..065e84bf651 100644 --- a/ace/Filecache.cpp +++ b/ace/Filecache.cpp @@ -4,6 +4,7 @@ #include "ace/Object_Manager.h" #include "ace/Log_Msg.h" #include "ace/ACE.h" +#include "ace/OS_NS_time.h" ACE_RCSID(ace, Filecache, "$Id$") diff --git a/ace/Filecache.h b/ace/Filecache.h index 9a6702356fc..036468b7f14 100644 --- a/ace/Filecache.h +++ b/ace/Filecache.h @@ -27,6 +27,7 @@ #include "ace/Null_Mutex.h" #include "ace/Synch_Traits.h" #include "ace/RW_Thread_Mutex.h" +#include "ace/OS_NS_sys_stat.h" enum ACE_Filecache_Flag { diff --git a/ace/Flag_Manip.cpp b/ace/Flag_Manip.cpp index 0b644d88f9d..34dc109cf50 100644 --- a/ace/Flag_Manip.cpp +++ b/ace/Flag_Manip.cpp @@ -6,6 +6,11 @@ #include "ace/Flag_Manip.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_LACKS_FCNTL) +# include "ace/OS_NS_stropts.h" +# include "ace/OS_NS_errno.h" +#endif /* ACE_WIN32 || VXWORKS || ACE_LACKS_FCNTL */ + ACE_RCSID(ace, Flag_Manip, "$Id$") // Flags are file status flags to turn on. diff --git a/ace/Flag_Manip.i b/ace/Flag_Manip.i index 57f6aad2fbb..4207cebb6be 100644 --- a/ace/Flag_Manip.i +++ b/ace/Flag_Manip.i @@ -3,7 +3,7 @@ // Return flags currently associated with handle. -#include "ace/OS.h" +#include "ace/OS_NS_fcntl.h" ASYS_INLINE int ACE_Flag_Manip::get_flags (ACE_HANDLE handle) diff --git a/ace/Framework_Component.cpp b/ace/Framework_Component.cpp index e5786d341f9..148601186b8 100644 --- a/ace/Framework_Component.cpp +++ b/ace/Framework_Component.cpp @@ -11,6 +11,7 @@ #include "ace/Log_Msg.h" #include "ace/DLL_Manager.h" #include "ace/Recursive_Thread_Mutex.h" +#include "ace/OS_NS_string.h" ACE_RCSID(ace, Framework_Component, "$Id$") @@ -158,7 +159,7 @@ ACE_Framework_Repository::remove_component (const ACE_TCHAR *name) for (i = 0; i < this->current_size_; i++) if (this->component_vector_[i] && - ACE_OS_String::strcmp (this->component_vector_[i]->name_, name) == 0) + ACE_OS::strcmp (this->component_vector_[i]->name_, name) == 0) { delete this->component_vector_[i]; this->component_vector_[i] = 0; @@ -191,7 +192,7 @@ ACE_Framework_Repository::remove_dll_components_i (const ACE_TCHAR *dll_name) for (i = 0; i < this->current_size_; i++) if (this->component_vector_[i] && - ACE_OS_String::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0) + ACE_OS::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0) { if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, diff --git a/ace/Functor.i b/ace/Functor.i index 25dedd00d6b..d008cb61285 100644 --- a/ace/Functor.i +++ b/ace/Functor.i @@ -30,7 +30,7 @@ // ============================================================================ #include "ace/ACE.h" -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" ////////////////////////////////////////////////////////////// // GOF Command Pattern Classes and Template Specializations // @@ -137,14 +137,14 @@ ACE_Hash<void *>::operator () (const void *t) const ACE_INLINE int ACE_Equal_To<const ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *rhs) const { - return !ACE_OS_String::strcmp (lhs, rhs); + return !ACE_OS::strcmp (lhs, rhs); } //ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Equal_To<ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *rhs) const { - return !ACE_OS_String::strcmp (lhs, rhs); + return !ACE_OS::strcmp (lhs, rhs); } ACE_INLINE int @@ -186,14 +186,14 @@ ACE_Equal_To<ACE_UINT64>::operator () (const ACE_UINT64 lhs, const ACE_UINT64 rh ACE_INLINE int ACE_Less_Than<const ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *rhs) const { - return (ACE_OS_String::strcmp (lhs, rhs) < 0) ? 1 : 0; + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; } //ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Less_Than<ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *rhs) const { - return (ACE_OS_String::strcmp (lhs, rhs) < 0) ? 1 : 0; + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; } @@ -217,28 +217,28 @@ ACE_Hash<ACE_ANTI_TCHAR *>::operator () (const ACE_ANTI_TCHAR *t) const ACE_INLINE int ACE_Equal_To<const ACE_ANTI_TCHAR *>::operator () (const ACE_ANTI_TCHAR *lhs, const ACE_ANTI_TCHAR *rhs) const { - return !ACE_OS_String::strcmp (lhs, rhs); + return !ACE_OS::strcmp (lhs, rhs); } //ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Equal_To<ACE_ANTI_TCHAR *>::operator () (const ACE_ANTI_TCHAR *lhs, const ACE_ANTI_TCHAR *rhs) const { - return !ACE_OS_String::strcmp (lhs, rhs); + return !ACE_OS::strcmp (lhs, rhs); } //ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Less_Than<const ACE_ANTI_TCHAR *>::operator () (const ACE_ANTI_TCHAR *lhs, const ACE_ANTI_TCHAR *rhs) const { - return (ACE_OS_String::strcmp (lhs, rhs) < 0) ? 1 : 0; + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; } //ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Less_Than<ACE_ANTI_TCHAR *>::operator () (const ACE_ANTI_TCHAR *lhs, const ACE_ANTI_TCHAR *rhs) const { - return (ACE_OS_String::strcmp (lhs, rhs) < 0) ? 1 : 0; + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; } #endif // ACE_USES_WCHAR diff --git a/ace/Future.h b/ace/Future.h index 572a667ad9d..cf361e61f0f 100644 --- a/ace/Future.h +++ b/ace/Future.h @@ -26,6 +26,9 @@ #if defined (ACE_HAS_THREADS) +#include "ace/Recursive_Thread_Mutex.h" +#include "ace/Condition_Recursive_Thread_Mutex.h" + // Forward decl. template <class T> class ACE_Future_Holder; template <class T> class ACE_Future_Observer; diff --git a/ace/Global_Macros.h b/ace/Global_Macros.h index 8eb9ca8a47b..ab7e01185e3 100644 --- a/ace/Global_Macros.h +++ b/ace/Global_Macros.h @@ -645,7 +645,20 @@ _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \ # define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X) //@} -#if !defined (ACE_WIN32) +#if defined (ACE_WIN32) +// These are used in SPIPE_Acceptor/Connector, but are ignored at runtime. +# if defined (ACE_HAS_WINCE) +# if !defined (PIPE_TYPE_MESSAGE) +# define PIPE_TYPE_MESSAGE 0 +# endif +# if !defined (PIPE_READMODE_MESSAGE) +# define PIPE_READMODE_MESSAGE 0 +# endif +# if !defined (PIPE_WAIT) +# define PIPE_WAIT 0 +# endif +# endif /* ACE_HAS_WINCE */ +#else /* !ACE_WIN32 */ // Add some typedefs and macros to enhance Win32 conformance... # if !defined (LPSECURITY_ATTRIBUTES) # define LPSECURITY_ATTRIBUTES int @@ -692,7 +705,8 @@ _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \ # if !defined(PIPE_TYPE_MESSAGE) # define PIPE_TYPE_MESSAGE 0 # endif /* !defined PIPE_TYPE_MESSAGE */ -#endif /* !ACE_WIN32 */ +#endif /* ACE_WIN32 */ + // Some useful abstrations for expressions involving // ACE_Allocator.malloc (). The difference between ACE_NEW_MALLOC* @@ -727,6 +741,35 @@ _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \ else { new (POINTER) CONSTRUCTOR; } \ } while (0) +/* ACE_Metrics */ +#if defined ACE_LACKS_ARRAY_PLACEMENT_NEW +# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ + else { for (u_int i = 0; i < COUNT; ++i) \ + {new (POINTER) CONSTRUCTOR; ++POINTER;} \ + POINTER -= COUNT;} \ + } while (0) +# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return;} \ + else { for (u_int i = 0; i < COUNT; ++i) \ + {new (POINTER) CONSTRUCTOR; ++POINTER;} \ + POINTER -= COUNT;} \ + } while (0) +#else /* ! defined ACE_LACKS_ARRAY_PLACEMENT_NEW */ +# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ + else { new (POINTER) CONSTRUCTOR [COUNT]; } \ + } while (0) +# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return;} \ + else { new (POINTER) CONSTRUCTOR [COUNT]; } \ + } while (0) +#endif /* defined ACE_LACKS_ARRAY_PLACEMENT_NEW */ + // This is being placed here temporarily to help stablelize the builds, but will // be moved out along with the above macros as part of the subsetting. dhinton # if !defined (ACE_HAS_WINCE) @@ -741,6 +784,238 @@ _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \ # define ACE_NOOP(x) +#if defined (ACE_PSOS) +# define ACE_SEH_TRY if (1) +# define ACE_SEH_EXCEPT(X) while (0) +# define ACE_SEH_FINALLY if (1) +#elif defined (ACE_WIN32) +# if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +# define ACE_SEH_TRY if (1) +# define ACE_SEH_EXCEPT(X) while (0) +# define ACE_SEH_FINALLY if (1) +# elif defined(__BORLANDC__) +# if (__BORLANDC__ >= 0x0530) /* Borland C++ Builder 3.0 */ +# define ACE_SEH_TRY try +# define ACE_SEH_EXCEPT(X) __except(X) +# define ACE_SEH_FINALLY __finally +# else +# define ACE_SEH_TRY if (1) +# define ACE_SEH_EXCEPT(X) while (0) +# define ACE_SEH_FINALLY if (1) +# endif +# elif defined (__IBMCPP__) && (__IBMCPP__ >= 400) +# define ACE_SEH_TRY if (1) +# define ACE_SEH_EXCEPT(X) while (0) +# define ACE_SEH_FINALLY if (1) +# else +# define ACE_SEH_TRY __try +# define ACE_SEH_EXCEPT(X) __except(X) +# define ACE_SEH_FINALLY __finally +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ +# else /* !ACE_WIN32 && ACE_PSOS */ +# define ACE_SEH_TRY if (1) +# define ACE_SEH_EXCEPT(X) while (0) +# define ACE_SEH_FINALLY if (1) +#endif /* ACE_WIN32 && ACE_PSOS */ + + +// These should probably be put into a seperate header. + +// The following is necessary since many C++ compilers don't support +// typedef'd types inside of classes used as formal template +// arguments... ;-(. Luckily, using the C++ preprocessor I can hide +// most of this nastiness! + +# if defined (ACE_HAS_TEMPLATE_TYPEDEFS) + +// Handle ACE_Message_Queue. +# define ACE_SYNCH_DECL class _ACE_SYNCH +# define ACE_SYNCH_USE _ACE_SYNCH +# define ACE_SYNCH_MUTEX_T ACE_TYPENAME _ACE_SYNCH::MUTEX +# define ACE_SYNCH_CONDITION_T ACE_TYPENAME _ACE_SYNCH::CONDITION +# define ACE_SYNCH_SEMAPHORE_T ACE_TYPENAME _ACE_SYNCH::SEMAPHORE + +// Handle ACE_Malloc* +# define ACE_MEM_POOL_1 class _ACE_MEM_POOL +# define ACE_MEM_POOL_2 _ACE_MEM_POOL +# define ACE_MEM_POOL _ACE_MEM_POOL +# define ACE_MEM_POOL_OPTIONS ACE_TYPENAME _ACE_MEM_POOL::OPTIONS + +// Handle ACE_Svc_Handler +# define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM +# define ACE_PEER_STREAM_2 _ACE_PEER_STREAM +# define ACE_PEER_STREAM _ACE_PEER_STREAM +# define ACE_PEER_STREAM_ADDR ACE_TYPENAME _ACE_PEER_STREAM::PEER_ADDR + +// Handle ACE_Acceptor +# define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR_ADDR ACE_TYPENAME _ACE_PEER_ACCEPTOR::PEER_ADDR + +// Handle ACE_Connector +# define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR_ADDR ACE_TYPENAME _ACE_PEER_CONNECTOR::PEER_ADDR +# if !defined(ACE_HAS_TYPENAME_KEYWORD) +# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any +# else + // + // If the compiler supports 'typename' we cannot use + // + // PEER_CONNECTOR::PEER_ADDR::sap_any + // + // because PEER_CONNECTOR::PEER_ADDR is not considered a type. But: + // + // typename PEER_CONNECTOR::PEER_ADDR::sap_any + // + // will not work either, because now we are declaring sap_any a + // type, further: + // + // (typename PEER_CONNECTOR::PEER_ADDR)::sap_any + // + // is considered a casting expression. All I can think of is using a + // typedef, I tried PEER_ADDR but that was a source of trouble on + // some platforms. I will try: + // +# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_ADDR_TYPEDEF::sap_any +# endif /* ACE_HAS_TYPENAME_KEYWORD */ + +// Handle ACE_SOCK_* +# define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor +# define ACE_SOCK_CONNECTOR ACE_SOCK_Connector +# define ACE_SOCK_STREAM ACE_SOCK_Stream + +// Handle ACE_SOCK_SEQPACK_* +# define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor +# define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector +# define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association + +// Handle ACE_MEM_* +# define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor +# define ACE_MEM_CONNECTOR ACE_MEM_Connector +# define ACE_MEM_STREAM ACE_MEM_Stream + +// Handle ACE_LSOCK_* +# define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor +# define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector +# define ACE_LSOCK_STREAM ACE_LSOCK_Stream + +// Handle ACE_TLI_* +# define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor +# define ACE_TLI_CONNECTOR ACE_TLI_Connector +# define ACE_TLI_STREAM ACE_TLI_Stream + +// Handle ACE_SPIPE_* +# define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor +# define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector +# define ACE_SPIPE_STREAM ACE_SPIPE_Stream + +// Handle ACE_UPIPE_* +# define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor +# define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector +# define ACE_UPIPE_STREAM ACE_UPIPE_Stream + +// Handle ACE_FILE_* +# define ACE_FILE_CONNECTOR ACE_FILE_Connector +# define ACE_FILE_STREAM ACE_FILE_IO + +// Handle ACE_*_Memory_Pool. +# define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool +# define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool +# define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool +# define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool +# define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool +# define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool + +# else /* TEMPLATES are broken in some form or another (i.e., most C++ compilers) */ + +// Handle ACE_Message_Queue. +# if defined (ACE_HAS_OPTIMIZED_MESSAGE_QUEUE) +# define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T, class _ACE_SYNCH_SEMAPHORE_T +# define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T, _ACE_SYNCH_SEMAPHORE_T +# else +# define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T +# define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T +# endif /* ACE_HAS_OPTIMIZED_MESSAGE_QUEUE */ +# define ACE_SYNCH_MUTEX_T _ACE_SYNCH_MUTEX_T +# define ACE_SYNCH_CONDITION_T _ACE_SYNCH_CONDITION_T +# define ACE_SYNCH_SEMAPHORE_T _ACE_SYNCH_SEMAPHORE_T + +// Handle ACE_Malloc* +# define ACE_MEM_POOL_1 class _ACE_MEM_POOL, class _ACE_MEM_POOL_OPTIONS +# define ACE_MEM_POOL_2 _ACE_MEM_POOL, _ACE_MEM_POOL_OPTIONS +# define ACE_MEM_POOL _ACE_MEM_POOL +# define ACE_MEM_POOL_OPTIONS _ACE_MEM_POOL_OPTIONS + +// Handle ACE_Svc_Handler +# define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM, class _ACE_PEER_ADDR +# define ACE_PEER_STREAM_2 _ACE_PEER_STREAM, _ACE_PEER_ADDR +# define ACE_PEER_STREAM _ACE_PEER_STREAM +# define ACE_PEER_STREAM_ADDR _ACE_PEER_ADDR + +// Handle ACE_Acceptor +# define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR, class _ACE_PEER_ADDR +# define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR, _ACE_PEER_ADDR +# define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR_ADDR _ACE_PEER_ADDR + +// Handle ACE_Connector +# define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR, class _ACE_PEER_ADDR +# define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR, _ACE_PEER_ADDR +# define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR_ADDR _ACE_PEER_ADDR +# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any + +// Handle ACE_SOCK_* +# define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor, ACE_INET_Addr +# define ACE_SOCK_CONNECTOR ACE_SOCK_Connector, ACE_INET_Addr +# define ACE_SOCK_STREAM ACE_SOCK_Stream, ACE_INET_Addr + +// Handle ACE_SOCK_SEQPACK_* +# define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor, ACE_Multihomed_INET_Addr +# define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector, ACE_Multihomed_INET_Addr +# define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association, ACE_Multihomed_INET_Addr + +// Handle ACE_MEM_* +# define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor, ACE_MEM_Addr +# define ACE_MEM_CONNECTOR ACE_MEM_Connector, ACE_INET_Addr +# define ACE_MEM_STREAM ACE_MEM_Stream, ACE_INET_Addr + +// Handle ACE_LSOCK_* +# define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor, ACE_UNIX_Addr +# define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector, ACE_UNIX_Addr +# define ACE_LSOCK_STREAM ACE_LSOCK_Stream, ACE_UNIX_Addr + +// Handle ACE_TLI_* +# define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor, ACE_INET_Addr +# define ACE_TLI_CONNECTOR ACE_TLI_Connector, ACE_INET_Addr +# define ACE_TLI_STREAM ACE_TLI_Stream, ACE_INET_Addr + +// Handle ACE_SPIPE_* +# define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor, ACE_SPIPE_Addr +# define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector, ACE_SPIPE_Addr +# define ACE_SPIPE_STREAM ACE_SPIPE_Stream, ACE_SPIPE_Addr + +// Handle ACE_UPIPE_* +# define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor, ACE_SPIPE_Addr +# define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector, ACE_SPIPE_Addr +# define ACE_UPIPE_STREAM ACE_UPIPE_Stream, ACE_SPIPE_Addr + +// Handle ACE_FILE_* +# define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr +# define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr + +// Handle ACE_*_Memory_Pool. +# define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options +# define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options +# define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool, ACE_Sbrk_Memory_Pool_Options +# define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool, ACE_Shared_Memory_Pool_Options +# define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool, ACE_Local_Memory_Pool_Options +# define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool, ACE_Pagefile_Memory_Pool_Options +# endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ + #include /**/ "ace/post.h" #endif /*ACE_GLOBAL_MACROS_H*/ diff --git a/ace/Guard_T.h b/ace/Guard_T.h index 1638e7c6071..552385b298e 100644 --- a/ace/Guard_T.h +++ b/ace/Guard_T.h @@ -23,7 +23,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Global_Macros.h" -#include "ace/OS.h" // for ACE_thread_key_t +#include "ace/OS_NS_Thread.h" /** * @class ACE_Guard diff --git a/ace/Guard_T.inl b/ace/Guard_T.inl index d80d7e26e65..0ce34431d2c 100644 --- a/ace/Guard_T.inl +++ b/ace/Guard_T.inl @@ -1,6 +1,8 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/RW_Thread_Mutex.h" + template <class ACE_LOCK> ACE_INLINE int ACE_Guard<ACE_LOCK>::acquire (void) { diff --git a/ace/Handle_Gobbler.h b/ace/Handle_Gobbler.h index 7b3528f6af3..e506e0c1f75 100644 --- a/ace/Handle_Gobbler.h +++ b/ace/Handle_Gobbler.h @@ -15,14 +15,12 @@ #define ACE_HANDLE_GOBBLER_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/Unbounded_Set.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Unbounded_Set.h" - /** * @class ACE_Handle_Gobbler * diff --git a/ace/Handle_Ops.cpp b/ace/Handle_Ops.cpp index 80b58ec7e15..f2fbefa9177 100644 --- a/ace/Handle_Ops.cpp +++ b/ace/Handle_Ops.cpp @@ -6,7 +6,9 @@ #include "ace/Handle_Ops.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ -#include "ace/OS.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/Time_Value.h" ACE_RCSID(ace, Handle_Ops, "$Id$") diff --git a/ace/Handle_Set.cpp b/ace/Handle_Set.cpp index 1456a351faf..5b65dbf9fd4 100644 --- a/ace/Handle_Set.cpp +++ b/ace/Handle_Set.cpp @@ -7,12 +7,28 @@ #include "ace/Handle_Set.i" #endif /* __ACE_INLINE__ */ -#include "ace/OS.h" +#include "ace/OS_NS_string.h" ACE_RCSID(ace, Handle_Set, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set) + // ACE_MSB_MASK is only used here. +# if defined (ACE_HAS_BROKEN_BITSHIFT) + // This might not be necessary any more: it was added prior to the + // (fd_mask) cast being added to the version below. Maybe that cast + // will fix the problem on tandems. Fri Dec 12 1997 David L. Levine +# define ACE_MSB_MASK (~(ACE_UINT32 (1) << ACE_UINT32 (NFDBITS - 1))) +# else + // This needs to go here to avoid overflow problems on some compilers. +# if defined (ACE_WIN32) + // Does ACE_WIN32 have an fd_mask? +# define ACE_MSB_MASK (~(1 << (NFDBITS - 1))) +# else /* ! ACE_WIN32 */ +# define ACE_MSB_MASK (~((fd_mask) 1 << (NFDBITS - 1))) +# endif /* ! ACE_WIN32 */ +# endif /* ACE_HAS_BROKEN_BITSHIFT */ + #if defined (__BORLANDC__) && !defined (ACE_WIN32) // The Borland C++ compiler on Linux also doesn't have fds_bits, but has __fds_bits. #define fds_bits __fds_bits diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp index 87e2bf136b3..4767d6c6636 100644 --- a/ace/High_Res_Timer.cpp +++ b/ace/High_Res_Timer.cpp @@ -14,6 +14,12 @@ #endif /* __ACE_INLINE__ */ #include "ace/Stats.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" ACE_RCSID(ace, High_Res_Timer, "$Id$") diff --git a/ace/High_Res_Timer.h b/ace/High_Res_Timer.h index ee948fb962c..94b883dab7d 100644 --- a/ace/High_Res_Timer.h +++ b/ace/High_Res_Timer.h @@ -20,7 +20,9 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/Basic_Types.h" +#include "ace/OS_NS_time.h" +#include "ace/Time_Value.h" /** * @class ACE_High_Res_Timer diff --git a/ace/High_Res_Timer.i b/ace/High_Res_Timer.i index 34c494dce16..8b9e72b828e 100644 --- a/ace/High_Res_Timer.i +++ b/ace/High_Res_Timer.i @@ -1,6 +1,12 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/Global_Macros.h" + +#if defined (ACE_WIN32) +# include "ace/OS_NS_sys_time.h" +#endif /* ACE_WIN32 */ + // Be very carefull before changing the calculations inside // ACE_High_Res_Timer. The precision matters and we are using integer // calculations not floating point. Also look good at the emulated 64 diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp index a2e6d696829..bd10c7ba7c5 100644 --- a/ace/INET_Addr.cpp +++ b/ace/INET_Addr.cpp @@ -3,12 +3,20 @@ // Defines the Internet domain address family address format. #include "ace/INET_Addr.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) #include "ace/INET_Addr.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_unistd.h" + ACE_RCSID (ace, INET_Addr, "$Id$") @@ -136,7 +144,7 @@ ACE_INET_Addr::string_to_addr (const char s[]) { char *endp = 0; u_short port = ACE_static_cast (u_short, - ACE_OS_String::strtol (ip_addr, &endp, 10)); + ACE_OS::strtol (ip_addr, &endp, 10)); if (port > 0 && *endp == '\0') result = this->set (port, ACE_UINT32 (INADDR_ANY)); else // port name @@ -148,7 +156,7 @@ ACE_INET_Addr::string_to_addr (const char s[]) char *endp = 0; u_short port = ACE_static_cast (u_short, - ACE_OS_String::strtol (port_p, &endp, 10)); + ACE_OS::strtol (port_p, &endp, 10)); if (port > 0 && *endp == '\0') result = this->set (port, ip_addr); else @@ -231,14 +239,14 @@ ACE_INET_Addr::set (u_short port_number, return -1; } - ACE_OS_String::memset ((void *) &this->inet_addr_, - 0, - sizeof this->inet_addr_); + ACE_OS::memset ((void *) &this->inet_addr_, + 0, + sizeof this->inet_addr_); #if defined (ACE_HAS_IPV6) struct addrinfo hints, *res, *res0; int error; - ACE_OS_String::memset (&hints, 0, sizeof (hints)); + ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = address_family; @@ -292,9 +300,9 @@ ACE_INET_Addr::set (u_short port_number, } else { - (void) ACE_OS_String::memcpy ((void *) &addrv4.s_addr, - hp->h_addr, - hp->h_length); + (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, + hp->h_addr, + hp->h_length); return this->set (port_number, encode ? ntohl (addrv4.s_addr) : addrv4.s_addr, encode); @@ -313,7 +321,7 @@ static int get_port_number_from_name (const char port_name[], // Maybe port_name is directly a port number? char *endp = 0; port_number = ACE_static_cast (int, - ACE_OS_String::strtol (port_name, &endp, 10)); + ACE_OS::strtol (port_name, &endp, 10)); if (port_number > 0 && *endp == '\0') { // Ok, port_name was really a number, and nothing else. We @@ -364,7 +372,7 @@ ACE_INET_Addr::set (const char port_name[], int address_family = PF_UNSPEC; # if defined (ACE_HAS_IPV6) - if (ACE_OS_String::strcmp (protocol, ACE_LIB_TEXT ("tcp6")) == 0) + if (ACE_OS::strcmp (protocol, ACE_LIB_TEXT ("tcp6")) == 0) address_family = AF_INET6; # endif /* ACE_HAS_IPV6 */ @@ -641,8 +649,8 @@ ACE_INET_Addr::get_host_name (wchar_t hostname[], // And copy it over, if successful if (result == 0) - ACE_OS_String::strcpy (hostname, - ACE_Ascii_To_Wide (char_hostname).wchar_rep ()); + ACE_OS::strcpy (hostname, + ACE_Ascii_To_Wide (char_hostname).wchar_rep ()); return result; } @@ -686,9 +694,9 @@ ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const #if defined (ACE_HAS_IPV6) if ((this->get_type () == PF_INET6 && - 0 == ACE_OS_String::memcmp (&this->inet_addr_.in6_.sin6_addr, - &in6addr_any, - sizeof (this->inet_addr_.in6_.sin6_addr))) + 0 == ACE_OS::memcmp (&this->inet_addr_.in6_.sin6_addr, + &in6addr_any, + sizeof (this->inet_addr_.in6_.sin6_addr))) || (this->get_type () == PF_INET && this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY)) @@ -781,9 +789,9 @@ int ACE_INET_Addr::set_address (const char *ip_addr, this->base_set (AF_INET, sizeof (this->inet_addr_.in4_)); this->inet_addr_.in4_.sin_family = AF_INET; this->set_size (sizeof (this->inet_addr_.in4_)); - ACE_OS_String::memcpy (&this->inet_addr_.in4_.sin_addr, - &ip4, - len); + ACE_OS::memcpy (&this->inet_addr_.in4_.sin_addr, + &ip4, + len); } #if defined (ACE_HAS_IPV6) // If given an IPv4 address to copy to an IPv6 object, map it to @@ -796,17 +804,17 @@ int ACE_INET_Addr::set_address (const char *ip_addr, if (ip4 == INADDR_ANY) { in6_addr ip6 = in6addr_any; - ACE_OS_String::memcpy (&this->inet_addr_.in6_.sin6_addr, - &ip6, - sizeof (ip6)); + ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, + &ip6, + sizeof (ip6)); return 0; } if (ip4 == INADDR_LOOPBACK) { in6_addr ip6 = in6addr_loopback; - ACE_OS_String::memcpy (&this->inet_addr_.in6_.sin6_addr, - &ip6, - sizeof (ip6)); + ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, + &ip6, + sizeof (ip6)); return 0; } @@ -823,9 +831,9 @@ int ACE_INET_Addr::set_address (const char *ip_addr, ip4 }; - ACE_OS_String::memcpy (&this->inet_addr_.in6_.sin6_addr, - &newaddress, - sizeof (newaddress)); + ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, + &newaddress, + sizeof (newaddress)); } #endif /* ACE_HAS_IPV6 */ @@ -842,7 +850,7 @@ int ACE_INET_Addr::set_address (const char *ip_addr, // We protect ourselves up above so IPv6 must be possible here. this->base_set (AF_INET6, sizeof (this->inet_addr_.in6_)); this->inet_addr_.in6_.sin6_family = AF_INET6; - ACE_OS_String::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); + ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); return 0; } /* end len == 16 */ @@ -932,7 +940,7 @@ ACE_INET_Addr::get_ip_address (void) const // Return the last 32 bits of the address char *thisaddrptr = (char*)this->ip_addr_pointer (); thisaddrptr += 128/8 - 32/8; - ACE_OS_String::memcpy (&addr, thisaddrptr, sizeof (addr)); + ACE_OS::memcpy (&addr, thisaddrptr, sizeof (addr)); return ACE_NTOHL (addr); } diff --git a/ace/INET_Addr.i b/ace/INET_Addr.i index 04164870c02..6f05f0c79d9 100644 --- a/ace/INET_Addr.i +++ b/ace/INET_Addr.i @@ -3,7 +3,8 @@ // INET_Addr.i -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/Global_Macros.h" // Default dtor. ACE_INLINE diff --git a/ace/IOStream.cpp b/ace/IOStream.cpp index 6e6f3d59063..1ad5c0f3aca 100644 --- a/ace/IOStream.cpp +++ b/ace/IOStream.cpp @@ -9,6 +9,9 @@ ACE_RCSID(ace, IOStream, "$Id$") #if !defined (ACE_LACKS_ACE_IOSTREAM) +# include "ace/OS_NS_errno.h" +# include "ace/OS_Memory.h" + /////////////////////////////////////////////////////////////////////////// /* Here's a simple example of how iostream's non-virtual operators can diff --git a/ace/IOStream.h b/ace/IOStream.h index 8dae6b38859..e15fcc55afb 100644 --- a/ace/IOStream.h +++ b/ace/IOStream.h @@ -15,7 +15,7 @@ #define ACE_IOSTREAM_H #include /**/ "ace/pre.h" -#include "ace/config-all.h" +#include "ace/ACE_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -34,34 +34,33 @@ #if !defined (ACE_LACKS_ACE_IOSTREAM) -#include "ace/OS.h" #include "ace/streams.h" -#if defined (ACE_HAS_STRING_CLASS) -#if defined (ACE_WIN32) && defined (_MSC_VER) +# if defined (ACE_HAS_STRING_CLASS) +# if defined (ACE_WIN32) && defined (_MSC_VER) typedef CString ACE_IOStream_String; -#else -#if !defined (ACE_HAS_STDCPP_STL_INCLUDES) +# else +# if !defined (ACE_HAS_STDCPP_STL_INCLUDES) #include /**/ <String.h> typedef String ACE_IOStream_String; -#else -#include /**/ <string> +# else +# include /**/ <string> -#if defined(ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# if defined(ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) typedef std::string ACE_IOStream_String; -#else +# else typedef string ACE_IOStream_String; -#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ -#endif /* ! ACE_HAS_STDCPP_STL_INCLUDES */ -#endif /* ACE_WIN32 && defined (_MSC_VER) */ - -#if defined (__DECCXX_VER) -# if __DECCXX_VER < 50700000 -# include /**/ <stl_macros> -# else -# include /**/ <stdcomp> -# endif /* __DECCXX_VER < 50700000 */ -#endif /* __DECCXX_VER */ +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ +# endif /* ! ACE_HAS_STDCPP_STL_INCLUDES */ +# endif /* ACE_WIN32 && defined (_MSC_VER) */ + +# if defined (__DECCXX_VER) +# if __DECCXX_VER < 50700000 +# include /**/ <stl_macros> +# else +# include /**/ <stdcomp> +# endif /* __DECCXX_VER < 50700000 */ +# endif /* __DECCXX_VER */ class ACE_Export ACE_Quoted_String : public ACE_IOStream_String { @@ -82,12 +81,15 @@ public: inline int operator < (const ACE_Quoted_String &s) const { return *(ACE_IOStream_String *) this < (ACE_IOStream_String) s; } -#if defined (ACE_WIN32) && defined (_MSC_VER) +# if defined (ACE_WIN32) && defined (_MSC_VER) inline int length (void) { return this->GetLength (); } -#endif /* ACE_WIN32 && defined (_MSC_VER) */ +# endif /* ACE_WIN32 && defined (_MSC_VER) */ }; -#endif /* ACE_HAS_STRING_CLASS */ +# endif /* ACE_HAS_STRING_CLASS */ + +# include "ace/Time_Value.h" +# include "ace/os_include/sys/os_types.h" /** * @class ACE_Streambuf @@ -309,7 +311,7 @@ protected: virtual ACE_HANDLE get_handle (void); -#if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) && !defined (ACE_USES_OLD_IOSTREAMS) +# if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) && !defined (ACE_USES_OLD_IOSTREAMS) char *base (void) const { return cur_mode_ == get_mode_ ? eback_saved_ @@ -335,7 +337,7 @@ protected: { return pptr () - pbase (); } -#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ +# endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ }; /////////////////////////////////////////////////////////////////////////// @@ -358,7 +360,7 @@ typedef ostream& (*__omanip_)(ostream&); // operators. Notice how the <ipfx> and <isfx> functions are used. #define GET_SIG(MT,DT) inline virtual MT& operator>> (DT v) -#if defined (__KCC) || (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510) +# if defined (__KCC) || (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510) #define GET_CODE { \ if (ipfx (0)) \ { \ @@ -367,7 +369,7 @@ typedef ostream& (*__omanip_)(ostream&); isfx (); \ return *this; \ } -#else +# else #define GET_CODE { \ if (ipfx (0)) \ { \ @@ -376,7 +378,7 @@ typedef ostream& (*__omanip_)(ostream&); isfx (); \ return *this; \ } -#endif /* __KCC */ +# endif /* __KCC */ #define GET_PROT(MT,DT,CODE) GET_SIG(MT,DT) CODE #define GET_FUNC(MT,DT) GET_PROT(MT,DT,GET_CODE) @@ -385,7 +387,7 @@ typedef ostream& (*__omanip_)(ostream&); // operators. Notice how the <opfx> and <osfx> functions are used. #define PUT_SIG(MT,DT) inline virtual MT& operator<< (DT v) -#if defined (__KCC) || (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510) +# if defined (__KCC) || (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510) #define PUT_CODE { \ if (opfx ()) \ { \ @@ -394,7 +396,7 @@ typedef ostream& (*__omanip_)(ostream&); osfx (); \ return *this; \ } -#else +# else #define PUT_CODE { \ if (opfx ()) \ { \ @@ -403,7 +405,7 @@ typedef ostream& (*__omanip_)(ostream&); osfx (); \ return *this; \ } -#endif /* __KCC */ +# endif /* __KCC */ #define PUT_PROT(MT,DT,CODE) PUT_SIG(MT,DT) CODE #define PUT_FUNC(MT,DT) PUT_PROT(MT,DT,PUT_CODE) @@ -411,7 +413,7 @@ typedef ostream& (*__omanip_)(ostream&); // These are necessary in case somebody wants to derive from us and // override one of these with a custom approach. -#if defined (ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS) +# if defined (ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS) #define GET_FUNC_SET0(MT,CODE,CODE2) \ GET_PROT(MT,short &,CODE) \ GET_PROT(MT,u_short &,CODE) \ @@ -426,7 +428,7 @@ typedef ostream& (*__omanip_)(ostream&); GET_PROT(MT,char *,CODE) \ inline virtual MT& operator>>(__omanip_ func) CODE2 \ inline virtual MT& operator>>(__manip_ func) CODE2 -#elif defined (ACE_LACKS_CHAR_RIGHT_SHIFTS) +# elif defined (ACE_LACKS_CHAR_RIGHT_SHIFTS) #define GET_FUNC_SET0(MT,CODE,CODE2) \ GET_PROT(MT,short &,CODE) \ GET_PROT(MT,u_short &,CODE) \ @@ -438,7 +440,7 @@ typedef ostream& (*__omanip_)(ostream&); GET_PROT(MT,double &,CODE) \ inline virtual MT& operator>>(__omanip_ func) CODE2 \ inline virtual MT& operator>>(__manip_ func) CODE2 -#else +# else #define GET_FUNC_SET0(MT,CODE,CODE2) \ GET_PROT(MT,short &,CODE) \ GET_PROT(MT,u_short &,CODE) \ @@ -454,7 +456,7 @@ typedef ostream& (*__omanip_)(ostream&); GET_PROT(MT,u_char *,CODE) \ inline virtual MT& operator>>(__omanip_ func) CODE2 \ inline virtual MT& operator>>(__manip_ func) CODE2 -#endif +# endif #define PUT_FUNC_SET0(MT,CODE,CODE2) \ PUT_PROT(MT,short,CODE) \ @@ -473,26 +475,26 @@ typedef ostream& (*__omanip_)(ostream&); inline virtual MT& operator<<(__omanip_ func) CODE2 \ inline virtual MT& operator<<(__manip_ func) CODE2 -#if defined (ACE_LACKS_SIGNED_CHAR) +# if defined (ACE_LACKS_SIGNED_CHAR) #define GET_FUNC_SET1(MT,CODE,CODE2) GET_FUNC_SET0(MT,CODE,CODE2) #define PUT_FUNC_SET1(MT,CODE,CODE2) PUT_FUNC_SET0(MT,CODE,CODE2) -#else -#if defined (ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS) +# else +# if defined (ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS) #define GET_FUNC_SET1(MT,CODE,CODE2) \ GET_PROT(MT,signed char &,CODE) \ GET_FUNC_SET0(MT,CODE,CODE2) -#else +# else #define GET_FUNC_SET1(MT,CODE,CODE2) \ GET_PROT(MT,signed char &,CODE) \ GET_PROT(MT,signed char *,CODE) \ GET_FUNC_SET0(MT,CODE,CODE2) -#endif +# endif #define PUT_FUNC_SET1(MT,CODE,CODE2) \ PUT_FUNC(MT,signed char) \ PUT_FUNC(MT,const signed char *) \ PUT_FUNC_SET0(MT,CODE,CODE2) -#endif /* ACE_LACKS_SIGNED_CHAR */ +# endif /* ACE_LACKS_SIGNED_CHAR */ #define GET_MANIP_CODE { if (ipfx ()) { (*func) (*this); } isfx (); return *this; } #define PUT_MANIP_CODE { if (opfx ()) { (*func) (*this); } osfx (); return *this; } @@ -506,7 +508,7 @@ typedef ostream& (*__omanip_)(ostream&); #define GETPUT_SIG_SET(MT) GET_SIG_SET(MT) PUT_SIG_SET(MT) // Include the templates here. -#include "ace/IOStream_T.h" +# include "ace/IOStream_T.h" #endif /* !ACE_LACKS_ACE_IOSTREAM && ACE_USES_OLD_IOSTREAMS */ #include /**/ "ace/post.h" diff --git a/ace/IOStream_T.h b/ace/IOStream_T.h index a0d02b5ecbb..a1caf38c2a9 100644 --- a/ace/IOStream_T.h +++ b/ace/IOStream_T.h @@ -27,13 +27,14 @@ #if !defined (ACE_LACKS_ACE_IOSTREAM) -#include "ace/INET_Addr.h" -#include "ace/Handle_Set.h" +# include "ace/INET_Addr.h" +# include "ace/Handle_Set.h" +# include "ace/Global_Macros.h" -#if defined (ACE_HAS_STRING_CLASS) +# if defined (ACE_HAS_STRING_CLASS) template <class STREAM> STREAM & operator>> (STREAM &stream, ACE_Quoted_String &str); template <class STREAM> STREAM & operator<< (STREAM &stream, ACE_Quoted_String &str); -#endif /* defined (ACE_HAS_STRING_CLASS) */ +# endif /* defined (ACE_HAS_STRING_CLASS) */ template <class STREAM> class ACE_Streambuf_T : public ACE_Streambuf @@ -134,7 +135,7 @@ public: */ int eof (void) const; -#if defined (ACE_HAS_STRING_CLASS) +# if defined (ACE_HAS_STRING_CLASS) /** * A simple string operator. The base <iostream> has them for char* * but that isn't always the best thing for a <String>. If we don't @@ -145,11 +146,11 @@ public: /// The converse of the <String::put> operator. virtual ACE_IOStream<STREAM> &operator<< (ACE_IOStream_String &v); -#endif /* ACE_HAS_STRING_CLASS */ +# endif /* ACE_HAS_STRING_CLASS */ // = Using the macros to provide get/set operators. GETPUT_FUNC_SET (ACE_IOStream<STREAM>) -#if defined (ACE_LACKS_IOSTREAM_FX) +# if defined (ACE_LACKS_IOSTREAM_FX) virtual int ipfx (int noskip = 0) { if (good ()) @@ -167,10 +168,10 @@ public: if (good ()) return 1; } -#if !defined (ACE_WIN32) +# if !defined (ACE_WIN32) // MS VC++ 5.0 doesn't declare setstate. setstate (failbit); -#endif /* !ACE_WIN32 */ +# endif /* !ACE_WIN32 */ return (0); } virtual int ipfx0 (void) { return ipfx (0); } // Optimized ipfx(0) @@ -183,10 +184,10 @@ public: if (good ()) return 1; } -#if !defined (ACE_WIN32) +# if !defined (ACE_WIN32) // MS VC++ 5.0 doesn't declare setstate. setstate (failbit); -#endif /* !ACE_WIN32 */ +# endif /* !ACE_WIN32 */ return (0); } virtual void isfx (void) { return; } @@ -197,19 +198,19 @@ public: return good (); } virtual void osfx (void) { if (flags () & unitbuf) flush (); } -#else -#if defined (__GNUC__) +# else +# if defined (__GNUC__) virtual int ipfx0 (void) { return iostream::ipfx0 (); } // Optimized ipfx(0) virtual int ipfx1 (void) { return iostream::ipfx1 (); } // Optimized ipfx(1) -#else +# else virtual int ipfx0 (void) { return iostream::ipfx (0); } virtual int ipfx1 (void) { return iostream::ipfx (1); } -#endif /* __GNUC__ */ +# endif /* __GNUC__ */ virtual int ipfx (int need = 0) { return iostream::ipfx (need); } virtual void isfx (void) { iostream::isfx (); } virtual int opfx (void) { return iostream::opfx (); } virtual void osfx (void) { iostream::osfx (); } -#endif /* ACE_LACKS_IOSTREAM_FX */ +# endif /* ACE_LACKS_IOSTREAM_FX */ /// Allow the programmer to provide a timeout for read operations. /// Give it a pointer to NULL to block forever. @@ -272,17 +273,18 @@ protected: ACE_INET_Addr peer_; }; -#if defined (__ACE_INLINE__) -#include "ace/IOStream_T.i" -#endif /* __ACE_INLINE__ */ +# if defined (__ACE_INLINE__) +# include "ace/IOStream_T.i" +# endif /* __ACE_INLINE__ */ -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/IOStream_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +# if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +# include "ace/IOStream_T.cpp" +# endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("IOStream_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ +# if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +# pragma implementation ("IOStream_T.cpp") +# endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* ACE_LACKS_ACE_IOSTREAM */ + #include /**/ "ace/post.h" #endif /* ACE_IOSTREAM_T_H */ diff --git a/ace/IO_Cntl_Msg.h b/ace/IO_Cntl_Msg.h index 5882c4d0f3e..441206cf184 100644 --- a/ace/IO_Cntl_Msg.h +++ b/ace/IO_Cntl_Msg.h @@ -22,8 +22,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" - /** * @class ACE_IO_Cntl_Msg * @@ -48,7 +46,7 @@ public: MOD_UNLINK = 6 }; - typedef u_short ACE_IO_Cntl_Cmds; + typedef unsigned short ACE_IO_Cntl_Cmds; // = Initialization method. /// Initialize the control message. diff --git a/ace/IO_SAP.cpp b/ace/IO_SAP.cpp index 272894102a2..3dbdb650b1f 100644 --- a/ace/IO_SAP.cpp +++ b/ace/IO_SAP.cpp @@ -2,12 +2,16 @@ // $Id$ #include "ace/IO_SAP.h" -#include "ace/Log_Msg.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/IO_SAP.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_errno.h" +#include "ace/os_include/os_signal.h" + ACE_RCSID(ace, IO_SAP, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_IO_SAP) diff --git a/ace/IO_SAP.i b/ace/IO_SAP.i index 5bb805d48f4..e6b1dfd9dd5 100644 --- a/ace/IO_SAP.i +++ b/ace/IO_SAP.i @@ -3,6 +3,8 @@ // IO_SAP.i +#include "ace/OS_NS_stropts.h" + ASYS_INLINE ACE_IO_SAP::~ACE_IO_SAP (void) { diff --git a/ace/IPC_SAP.cpp b/ace/IPC_SAP.cpp index d50d0580073..24152f87ad2 100644 --- a/ace/IPC_SAP.cpp +++ b/ace/IPC_SAP.cpp @@ -1,12 +1,16 @@ // $Id$ #include "ace/IPC_SAP.h" -#include "ace/Log_Msg.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/IPC_SAP.i" #endif +#include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" +#include "ace/os_include/os_signal.h" +#include "ace/OS_NS_errno.h" + ACE_RCSID(ace, IPC_SAP, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP) diff --git a/ace/IPC_SAP.i b/ace/IPC_SAP.i index 63ccc967711..1d2c53b2783 100644 --- a/ace/IPC_SAP.i +++ b/ace/IPC_SAP.i @@ -3,6 +3,8 @@ // IPC_SAP.i +#include "ace/OS_NS_stropts.h" + // Used to return the underlying handle_. ASYS_INLINE diff --git a/ace/LOCK_SOCK_Acceptor.cpp b/ace/LOCK_SOCK_Acceptor.cpp index 931216750ae..7c3f1763f14 100644 --- a/ace/LOCK_SOCK_Acceptor.cpp +++ b/ace/LOCK_SOCK_Acceptor.cpp @@ -3,7 +3,7 @@ #ifndef ACE_LOCK_SOCK_ACCEPTOR_CPP #define ACE_LOCK_SOCK_ACCEPTOR_CPP -#include "ace/Synch.h" +#include "ace/Guard_T.h" #include "ace/LOCK_SOCK_Acceptor.h" ACE_RCSID(ace, LOCK_SOCK_Acceptor, "$Id$") diff --git a/ace/Lib_Find.cpp b/ace/Lib_Find.cpp index d5ad37134e7..30bb8640587 100644 --- a/ace/Lib_Find.cpp +++ b/ace/Lib_Find.cpp @@ -2,7 +2,17 @@ #include "ace/Lib_Find.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_fcntl.h" + +#if defined (ACE_WIN32) +# include "ace/OS_NS_strings.h" +#endif /* ACE_WIN32 */ ACE_RCSID(ace, Lib_Find, "$Id$") @@ -112,7 +122,7 @@ ACE_Lib_Find::ldfind (const ACE_TCHAR* filename, #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) size_t len_searchfilename = ACE_OS::strlen (searchfilename); if (! got_suffix) - ACE_OS_String::strcpy (searchfilename + len_searchfilename, + ACE_OS::strcpy (searchfilename + len_searchfilename, decorator); for (int tag = 1; tag >= 0; tag --) diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp index c1cb753ee9f..59feaacdbfc 100644 --- a/ace/Local_Name_Space_T.cpp +++ b/ace/Local_Name_Space_T.cpp @@ -9,7 +9,7 @@ #include "ace/Local_Name_Space.h" #include "ace/Auto_Ptr.h" - +#include "ace/OS_NS_regex.h" ACE_RCSID (ace, Local_Name_Space_T, diff --git a/ace/Lock_Adapter_T.cpp b/ace/Lock_Adapter_T.cpp index 792c1bf9e1e..ab69d2387bb 100644 --- a/ace/Lock_Adapter_T.cpp +++ b/ace/Lock_Adapter_T.cpp @@ -4,6 +4,7 @@ #define ACE_LOCK_ADAPTER_T_C #include "ace/Lock_Adapter_T.h" +#include "ace/OS_Memory.h" // for ACE_NEW #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 2ed4b844043..a4a33298aca 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -11,7 +11,11 @@ #include "ace/ACE.h" #include "ace/Thread_Manager.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_wchar.h" +#include "ace/OS_NS_signal.h" #if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE == 0) # include "ace/Object_Manager.h" @@ -33,6 +37,14 @@ ACE_RCSID(ace, Log_Msg, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg) +// only used here... dhinton +#if defined (ACE_HAS_SYS_SIGLIST) +# if !defined (_sys_siglist) +# define _sys_siglist sys_siglist +# endif /* !defined (sys_siglist) */ +//extern char **_sys_siglist; +#endif /* ACE_HAS_SYS_SIGLIST */ + #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) int ACE_Log_Msg::key_created_ = 0; # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ @@ -1165,11 +1177,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, va_arg (argp, ACE_TCHAR *), - ACE_TEXT_CHAR_TO_TCHAR (ACE_OS_String::strerror (errno))); + ACE_TEXT_CHAR_TO_TCHAR (ACE_OS::strerror (errno))); else this_len = ACE_OS::sprintf (bp, format, va_arg (argp, ACE_TCHAR *), - ACE_TEXT_CHAR_TO_TCHAR (ACE_OS_String::strerror (errno))); + ACE_TEXT_CHAR_TO_TCHAR (ACE_OS::strerror (errno))); } else #endif /* !ACE_HAS_WINCE */ @@ -1275,10 +1287,10 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, - ACE_OS_String::strerror (errno)); + ACE_OS::strerror (errno)); else this_len = ACE_OS::sprintf - (bp, format, ACE_OS_String::strerror (errno)); + (bp, format, ACE_OS::strerror (errno)); } else { @@ -2059,7 +2071,7 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority, // 58 for the HEXDUMP header; ACE_TCHAR *msg_buf; - const size_t text_sz = text ? ACE_OS_String::strlen(text) : 0; + const size_t text_sz = text ? ACE_OS::strlen(text) : 0; ACE_NEW_RETURN (msg_buf, ACE_TCHAR[text_sz + 58], -1); diff --git a/ace/Log_Msg_NT_Event_Log.cpp b/ace/Log_Msg_NT_Event_Log.cpp index d00e23ee475..9965b099b0c 100644 --- a/ace/Log_Msg_NT_Event_Log.cpp +++ b/ace/Log_Msg_NT_Event_Log.cpp @@ -7,6 +7,7 @@ #include "ace/Log_Msg_NT_Event_Log.h" #include "ace/Log_Msg.h" #include "ace/Log_Record.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(ace, Log_Msg_NT_Event_Log, "$Id$") @@ -32,7 +33,7 @@ ACE_Log_Msg_NT_Event_Log::open (const ACE_TCHAR *logger_key) MAXPATHLEN)) return -1; DWORD msg_file_length = ACE_static_cast (DWORD, - ACE_OS_String::strlen (msg_file)); + ACE_OS::strlen (msg_file)); // If a logger_key has been supplied then we use that as the event // source name, otherwise we default to the program name. diff --git a/ace/Log_Msg_UNIX_Syslog.cpp b/ace/Log_Msg_UNIX_Syslog.cpp index 7c7af9bbeb5..b48e002660e 100644 --- a/ace/Log_Msg_UNIX_Syslog.cpp +++ b/ace/Log_Msg_UNIX_Syslog.cpp @@ -8,6 +8,7 @@ #include "ace/Log_Msg.h" #include "ace/Log_Msg_UNIX_Syslog.h" #include "ace/Log_Record.h" +#include "ace/os_include/os_syslog.h" // NOTE: // The ACE_Log_Msg_UNIX_Syslog class can use the openlog(), @@ -83,13 +84,13 @@ ACE_Log_Msg_UNIX_Syslog::log (ACE_Log_Record &log_record) ACE_OS::strcpy (message, log_record.msg_data ()); ACE_TCHAR *strtokp; - for (ACE_TCHAR *line = ACE_OS_String::strtok_r (message, - ACE_LIB_TEXT ("\n"), - &strtokp); + for (ACE_TCHAR *line = ACE_OS::strtok_r (message, + ACE_LIB_TEXT ("\n"), + &strtokp); line != 0; - line = ACE_OS_String::strtok_r (0, - ACE_LIB_TEXT ("\n"), - &strtokp)) + line = ACE_OS::strtok_r (0, + ACE_LIB_TEXT ("\n"), + &strtokp)) { // Format the message line. Note that the processing for // VERBOSE is the same as for VERBOSE_LITE, since syslog() diff --git a/ace/Log_Record.cpp b/ace/Log_Record.cpp index 635dfb9224e..056050b55cc 100644 --- a/ace/Log_Record.cpp +++ b/ace/Log_Record.cpp @@ -1,17 +1,20 @@ // $Id$ #include "ace/Log_Record.h" + +#if defined (ACE_LACKS_INLINE_FUNCTIONS) +# include "ace/Log_Record.i" +#endif + #include "ace/Log_Msg.h" #include "ace/ACE.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_time.h" #if !defined (ACE_LACKS_IOSTREAM_TOTALLY) # include "ace/streams.h" #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -# include "ace/Log_Record.i" -#endif - ACE_RCSID(ace, Log_Record, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Log_Record) diff --git a/ace/Log_Record.i b/ace/Log_Record.i index 6720391a9a8..a61bc5415e0 100644 --- a/ace/Log_Record.i +++ b/ace/Log_Record.i @@ -5,7 +5,7 @@ #include "ace/Global_Macros.h" #include "ace/os_include/arpa/os_inet.h" #include "ace/Time_Value.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" ASYS_INLINE ACE_Log_Record::~ACE_Log_Record (void) diff --git a/ace/Logging_Strategy.cpp b/ace/Logging_Strategy.cpp index 9834c7ee5f3..472d7226622 100644 --- a/ace/Logging_Strategy.cpp +++ b/ace/Logging_Strategy.cpp @@ -1,12 +1,14 @@ // $Id$ +#include "ace/Logging_Strategy.h" #include "ace/ACE.h" #include "ace/Get_Opt.h" #include "ace/streams.h" #include "ace/Lib_Find.h" #include "ace/Log_Msg.h" #include "ace/Reactor.h" -#include "ace/Logging_Strategy.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(lib, Logging_Strategy, "$Id$") @@ -30,13 +32,13 @@ ACE_Logging_Strategy::priorities (ACE_TCHAR *priority_string, // Parse string and alternate priority mask. - for (ACE_TCHAR *priority = ACE_OS_String::strtok_r (priority_string, - ACE_LIB_TEXT ("|"), - &strtokp); + for (ACE_TCHAR *priority = ACE_OS::strtok_r (priority_string, + ACE_LIB_TEXT ("|"), + &strtokp); priority != 0; - priority = ACE_OS_String::strtok_r (0, - ACE_LIB_TEXT ("|"), - &strtokp)) + priority = ACE_OS::strtok_r (0, + ACE_LIB_TEXT ("|"), + &strtokp)) { if (ACE_OS::strcmp (priority, ACE_LIB_TEXT ("SHUTDOWN")) == 0) ACE_SET_BITS (priority_mask, LM_SHUTDOWN); diff --git a/ace/MEM_Acceptor.cpp b/ace/MEM_Acceptor.cpp index 57d4dc3fa1c..2a458aedbb3 100644 --- a/ace/MEM_Acceptor.cpp +++ b/ace/MEM_Acceptor.cpp @@ -9,6 +9,8 @@ #include "ace/MEM_Acceptor.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#include "ace/OS_NS_stdio.h" + ACE_RCSID(ace, MEM_Acceptor, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_MEM_Acceptor) diff --git a/ace/MEM_Addr.cpp b/ace/MEM_Addr.cpp index ed8bfa3e07e..2711aa0da06 100644 --- a/ace/MEM_Addr.cpp +++ b/ace/MEM_Addr.cpp @@ -6,13 +6,15 @@ #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) -#include "ace/Log_Msg.h" -#include "ace/OS.h" - #if !defined (__ACE_INLINE__) #include "ace/MEM_Addr.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" +#include "ace/os_include/os_netdb.h" + ACE_RCSID (ace, MEM_Addr, "$Id$") diff --git a/ace/MEM_Addr.i b/ace/MEM_Addr.i index e2cb980a34b..d5b42015724 100644 --- a/ace/MEM_Addr.i +++ b/ace/MEM_Addr.i @@ -3,6 +3,8 @@ // MEM_Addr.i +#include "ace/Global_Macros.h" + // Default dtor. ACE_INLINE ACE_MEM_Addr::~ACE_MEM_Addr (void) diff --git a/ace/MEM_IO.i b/ace/MEM_IO.i index 796121a6c6e..3d80a0f8840 100644 --- a/ace/MEM_IO.i +++ b/ace/MEM_IO.i @@ -3,6 +3,8 @@ // MEM_IO.i +#include "ace/OS_NS_string.h" + ASYS_INLINE ACE_Reactive_MEM_IO::ACE_Reactive_MEM_IO () { diff --git a/ace/Malloc.cpp b/ace/Malloc.cpp index 1a3224dbe76..1c35a3064a6 100644 --- a/ace/Malloc.cpp +++ b/ace/Malloc.cpp @@ -4,12 +4,14 @@ #define ACE_MALLOC_CPP #include "ace/Malloc.h" -#include "ace/Object_Manager.h" #if !defined (__ACE_INLINE__) #include "ace/Malloc.i" #endif /* __ACE_INLINE__ */ +#include "ace/Object_Manager.h" +#include "ace/OS_NS_string.h" + ACE_RCSID(ace, Malloc, "$Id$") // Process-wide ACE_Allocator. diff --git a/ace/Malloc.h b/ace/Malloc.h index a2f4eb87ee4..4e4a38e4865 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -21,7 +21,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" #include "ace/Log_Msg.h" #if defined (ACE_HAS_MALLOC_STATS) diff --git a/ace/Malloc_Allocator.i b/ace/Malloc_Allocator.i index 752860b0d1e..e360750f9aa 100644 --- a/ace/Malloc_Allocator.i +++ b/ace/Malloc_Allocator.i @@ -1,9 +1,9 @@ /* -*- C++ -*- */ // $Id$ -#include "ace/OS.h" #include "ace/os_include/os_errno.h" #include "ace/Log_Msg.h" // for ACE_ASSERT +#include "ace/OS_NS_string.h" ACE_INLINE void * ACE_New_Allocator::calloc (size_t n_elem, size_t elem_size, char initial_value) diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp index e163c8b648e..1812aa676f0 100644 --- a/ace/Malloc_T.cpp +++ b/ace/Malloc_T.cpp @@ -15,6 +15,7 @@ #endif /* __ACE_INLINE__ */ #include "ace/ACE.h" +#include "ace/OS_NS_string.h" ACE_RCSID(ace, Malloc_T, "$Id$") diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index a1688439c8a..ef577bee87c 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -15,13 +15,12 @@ #define ACE_MALLOC_T_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/Malloc.h" /* Need ACE_Control_Block */ #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Malloc.h" /* Need ACE_Control_Block */ #include "ace/Malloc_Allocator.h" #include "ace/Free_List.h" diff --git a/ace/Manual_Event.cpp b/ace/Manual_Event.cpp index 1bfafe0b815..e6eaca44ec6 100644 --- a/ace/Manual_Event.cpp +++ b/ace/Manual_Event.cpp @@ -43,14 +43,3 @@ ACE_Manual_Event::dump (void) const #endif /* ACE_HAS_DUMP */ } -ACE_Auto_Event::ACE_Auto_Event (int initial_state, - int type, - const char *name, - void *arg) - : ACE_Event (0, - initial_state, - type, - ACE_TEXT_CHAR_TO_TCHAR (name), - arg) -{ -} diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp index c0d066f3980..0d37ecbc10e 100644 --- a/ace/Mem_Map.cpp +++ b/ace/Mem_Map.cpp @@ -3,6 +3,13 @@ // Defines the member functions for the memory mapping facility. #include "ace/Mem_Map.h" +#if !defined (__ACE_INLINE__) +#include "ace/Mem_Map.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_string.h" #include "ace/Log_Msg.h" #if defined (ACE_WIN32) \ @@ -14,10 +21,6 @@ #include "ace/SString.h" #endif /* ACE_USE_MAPPING_NAME */ -#if !defined (__ACE_INLINE__) -#include "ace/Mem_Map.i" -#endif /* __ACE_INLINE__ */ - ACE_RCSID(ace, Mem_Map, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Mem_Map) diff --git a/ace/Mem_Map.h b/ace/Mem_Map.h index c55a5836b3f..4522e2070a2 100644 --- a/ace/Mem_Map.h +++ b/ace/Mem_Map.h @@ -21,7 +21,11 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/Global_Macros.h" +#include "ace/os_include/sys/os_mman.h" +#include "ace/os_include/os_limits.h" +#include "ace/os_include/os_fcntl.h" +#include "ace/Default_Constants.h" /** * @class ACE_Mem_Map diff --git a/ace/Mem_Map.i b/ace/Mem_Map.i index 85495a13dd5..99d3a45cfbf 100644 --- a/ace/Mem_Map.i +++ b/ace/Mem_Map.i @@ -1,6 +1,9 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_mman.h" + ACE_INLINE ACE_HANDLE ACE_Mem_Map::handle (void) const { diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index 9a44b4277fa..963c5189249 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -2,14 +2,18 @@ // Memory_Pool.cpp #include "ace/Memory_Pool.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) #include "ace/Memory_Pool.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" #include "ace/Auto_Ptr.h" #include "ace/RW_Thread_Mutex.h" +#include "ace/OS_NS_sys_mman.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_sys_shm.h" #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) #include "ace/Based_Pointer_T.h" diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp index d36f00e8935..aad8d35eee0 100644 --- a/ace/Message_Block.cpp +++ b/ace/Message_Block.cpp @@ -1,15 +1,17 @@ #include "ace/Message_Block.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Message_Block.i" +#endif /* __ACE_INLINE__ */ + #include "ace/Log_Msg.h" #include "ace/Malloc_Base.h" #include "ace/Guard_T.h" +#include "ace/OS_NS_string.h" //#define ACE_ENABLE_TIMEPROBES #include "ace/Timeprobe.h" -#if !defined (__ACE_INLINE__) -#include "ace/Message_Block.i" -#endif /* __ACE_INLINE__ */ - ACE_RCSID (ace, Message_Block, "$Id$") diff --git a/ace/Message_Queue_T.cpp b/ace/Message_Queue_T.cpp index 475aa6580fe..55616ed75a2 100644 --- a/ace/Message_Queue_T.cpp +++ b/ace/Message_Queue_T.cpp @@ -7,6 +7,7 @@ // circular include problems. #include "ace/Message_Queue.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_time.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Metrics_Cache.cpp b/ace/Metrics_Cache.cpp index 6ea24ce19e0..a901fa53bb5 100644 --- a/ace/Metrics_Cache.cpp +++ b/ace/Metrics_Cache.cpp @@ -4,14 +4,12 @@ //#define ACE_BUILD_DLL -#include "ace/OS.h" +#include "ace/Metrics_Cache.h" ACE_RCSID(ace, Metrics_Cache, "Metrics_Cache.cpp,v 4.18 1998/07/11 08:53:56 gonzo Exp") #if defined (ACE_COMPILE_TIMEPROBES) -#include "ace/Metrics_Cache.h" - #if !defined (__ACE_INLINE__) #include "ace/Metrics_Cache.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/Metrics_Cache.h b/ace/Metrics_Cache.h index 26c6881f6b8..5ef4208421f 100644 --- a/ace/Metrics_Cache.h +++ b/ace/Metrics_Cache.h @@ -14,7 +14,7 @@ #ifndef ACE_METRICS_CACHE_H #define ACE_METRICS_CACHE_H -#include "ace/OS.h" +#include "ace/Timeprobe.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Metrics_Cache_T.h b/ace/Metrics_Cache_T.h index b2685ca95a8..9f3fef943b2 100644 --- a/ace/Metrics_Cache_T.h +++ b/ace/Metrics_Cache_T.h @@ -12,7 +12,7 @@ #ifndef METRICS_CACHE_T_H #define METRICS_CACHE_T_H -#include "ace/OS.h" +#include "ace/config-all.h" // helpful macro definitions #if !defined (ACE_LACKS_PRAGMA_ONCE) diff --git a/ace/Module.h b/ace/Module.h index 1490da2095c..7efe337bef5 100644 --- a/ace/Module.h +++ b/ace/Module.h @@ -22,6 +22,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Task_T.h" +#include "ace/os_include/os_dirent.h" /** * @class ACE_Module_Base diff --git a/ace/Mutex.cpp b/ace/Mutex.cpp index 597509e37f0..a4085942583 100644 --- a/ace/Mutex.cpp +++ b/ace/Mutex.cpp @@ -6,7 +6,8 @@ #include "ace/Mutex.inl" #endif /* __ACE_INLINE__ */ -//#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/sys/os_mman.h" ACE_RCSID(ace, Mutex, "$Id$") diff --git a/ace/Mutex.h b/ace/Mutex.h index 610b1880bbe..67545cc10d7 100644 --- a/ace/Mutex.h +++ b/ace/Mutex.h @@ -22,7 +22,20 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_Thread.h" +#include "ace/OS_NS_unistd.h" +#include "ace/os_include/os_fcntl.h" + +# if !defined (ACE_DEFAULT_MUTEX_A) +# define ACE_DEFAULT_MUTEX_A "ACE_MUTEX" +# endif /* ACE_DEFAULT_MUTEX_A */ + +# if defined (ACE_HAS_WCHAR) +# define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE(ACE_DEFAULT_MUTEX_A) +# endif /* ACE_HAS_WCHAR */ + +# define ACE_DEFAULT_MUTEX ACE_LIB_TEXT (ACE_DEFAULT_MUTEX_A) class ACE_Time_Value; diff --git a/ace/Mutex.inl b/ace/Mutex.inl index 33022dd651e..08b6ee9d33d 100644 --- a/ace/Mutex.inl +++ b/ace/Mutex.inl @@ -1,6 +1,8 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/OS_NS_sys_mman.h" + ACE_INLINE int ACE_Mutex::acquire_read (void) { diff --git a/ace/NT_Service.cpp b/ace/NT_Service.cpp index 417cccff528..1dbd9eee0ea 100644 --- a/ace/NT_Service.cpp +++ b/ace/NT_Service.cpp @@ -7,13 +7,15 @@ !defined (ACE_HAS_PHARLAP) && !defined (ACE_HAS_WINCE) #include "ace/NT_Service.h" -#include "ace/Log_Msg.h" -#include "ace/Service_Object.h" #if !defined (__ACE_INLINE__) #include "ace/NT_Service.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/Service_Object.h" +#include "ace/OS_NS_errno.h" + ACE_ALLOC_HOOK_DEFINE(ACE_NT_Service) // ACE_NT_Service destructor. diff --git a/ace/Name_Request_Reply.cpp b/ace/Name_Request_Reply.cpp index 509b8f806d0..de76953a384 100644 --- a/ace/Name_Request_Reply.cpp +++ b/ace/Name_Request_Reply.cpp @@ -1,7 +1,8 @@ #include "ace/Name_Request_Reply.h" #include "ace/Log_Msg.h" #include "ace/Time_Value.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/arpa/os_inet.h" ACE_RCSID (ace, Name_Request_Reply, diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index feb671f6322..3a8dae76c1b 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -45,11 +45,11 @@ ACE_Naming_Context::info (ACE_TCHAR **strp, ACE_LIB_TEXT ("ACE_Naming_Context"), ACE_LIB_TEXT ("Proxy for making calls to a Name Server")); - if (*strp == 0 && (*strp = ACE_OS_String::strdup (buf)) == 0) + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; else - ACE_OS_String::strsncpy (*strp, buf, length); - return ACE_static_cast (int, ACE_OS_String::strlen (buf)); + ACE_OS::strsncpy (*strp, buf, length); + return ACE_static_cast (int, ACE_OS::strlen (buf)); } int diff --git a/ace/Naming_Context.h b/ace/Naming_Context.h index f34ee7d6f5e..91690ffcb94 100644 --- a/ace/Naming_Context.h +++ b/ace/Naming_Context.h @@ -27,6 +27,7 @@ #include "ace/Service_Object.h" #include "ace/Name_Proxy.h" #include "ace/Name_Space.h" +#include "ace/os_include/os_netdb.h" // Forward decl class ACE_Name_Options; diff --git a/ace/OS.cpp b/ace/OS.cpp index d2c1ec2af99..b26d3dc3579 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -1,12 +1,11 @@ // $Id$ - #include "ace/OS.h" -#include "ace/Sched_Params.h" -#include "ace/OS_Thread_Adapter.h" +//#include "ace/Sched_Params.h" +//#include "ace/OS_Thread_Adapter.h" #if !defined (ACE_HAS_WINCE) -#include "ace/OS_QoS.h" +# include "ace/OS_QoS.h" #endif // ACE_HAS_WINCE // Perhaps we should *always* include ace/OS.i in order to make sure @@ -15,7861 +14,52 @@ # include "ace/OS.i" #endif /* ACE_HAS_INLINED_OS_CALLS */ -#if defined(INTEGRITY) && defined(ACE_HAS_SHM_OPEN) -char* shm_area_name = "ACE_Area"; -char* shm_area_password = "******"; -#endif - ACE_RCSID(ace, OS, "$Id$") -#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# if defined (ACE_HAS_WINCE) -const wchar_t *ACE_OS::day_of_week_name[] = {ACE_LIB_TEXT ("Sun"), ACE_LIB_TEXT ("Mon"), - ACE_LIB_TEXT ("Tue"), ACE_LIB_TEXT ("Wed"), - ACE_LIB_TEXT ("Thu"), ACE_LIB_TEXT ("Fri"), - ACE_LIB_TEXT ("Sat")}; -const wchar_t *ACE_OS::month_name[] = {ACE_LIB_TEXT ("Jan"), ACE_LIB_TEXT ("Feb"), - ACE_LIB_TEXT ("Mar"), ACE_LIB_TEXT ("Apr"), - ACE_LIB_TEXT ("May"), ACE_LIB_TEXT ("Jun"), - ACE_LIB_TEXT ("Jul"), ACE_LIB_TEXT ("Aug"), - ACE_LIB_TEXT ("Sep"), ACE_LIB_TEXT ("Oct"), - ACE_LIB_TEXT ("Nov"), ACE_LIB_TEXT ("Dec") }; - -static const ACE_TCHAR *ACE_OS_CTIME_R_FMTSTR = ACE_LIB_TEXT ("%3s %3s %02d %02d:%02d:%02d %04d\n"); -# endif /* ACE_HAS_WINCE */ - -# if defined (ACE_WIN32) -OSVERSIONINFO ACE_OS::win32_versioninfo_; -// Cached win32 version information. - -HINSTANCE ACE_OS::win32_resource_module_; - -# if defined (ACE_OS_HAS_DLL) && (ACE_OS_HAS_DLL == 1) && !defined (ACE_HAS_WINCE) -// This function is called by the OS when the ACE DLL is loaded. We -// use it to determine the default module containing ACE's resources. -BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID) -{ - if (reason == DLL_PROCESS_ATTACH) - { -#if defined (ACE_DISABLES_THREAD_LIBRARY_CALLS) && (ACE_DISABLES_THREAD_LIBRARY_CALLS == 1) - ::DisableThreadLibraryCalls (instance); -#endif /* ACE_DISABLES_THREAD_LIBRARY_CALLS */ - ACE_OS::set_win32_resource_module(instance); - } - return TRUE; -} -# endif /* ACE_OS_HAS_DLL && ACE_OS_HAS_DLL == 1 */ -# endif /* ACE_WIN32 */ - -/** - * @class ACE_OS_Thread_Mutex_Guard - * - * This data structure is meant to be used within an ACE_OS - * function. It performs automatic aquisition and release of - * an ACE_thread_mutex_t. - * - * For internal use only by ACE_OS. - */ -class ACE_OS_Thread_Mutex_Guard -{ -public: - /// Implicitly and automatically acquire the lock. - ACE_OS_Thread_Mutex_Guard (ACE_thread_mutex_t &m); - - /// Implicitly release the lock. - ~ACE_OS_Thread_Mutex_Guard (void); - - /// Explicitly acquire the lock. - int acquire (void); - - /// Explicitly release the lock. - int release (void); - -protected: - /// Reference to the mutex. - ACE_thread_mutex_t &lock_; - - /// Keeps track of whether we acquired the lock or failed. - int owner_; - - // = Prevent assignment and initialization. - ACE_OS_Thread_Mutex_Guard &operator= (const ACE_OS_Thread_Mutex_Guard &); - ACE_OS_Thread_Mutex_Guard (const ACE_OS_Thread_Mutex_Guard &); -}; - -#if defined (ACE_IS_SPLITTING) -# define ACE_SPECIAL_INLINE -#else -# define ACE_SPECIAL_INLINE inline -#endif - -ACE_SPECIAL_INLINE -int -ACE_OS_Thread_Mutex_Guard::acquire (void) -{ - return owner_ = ACE_OS::thread_mutex_lock (&lock_); -} - -ACE_SPECIAL_INLINE -int -ACE_OS_Thread_Mutex_Guard::release (void) -{ - if (owner_ == -1) - return 0; - else - { - owner_ = -1; - return ACE_OS::thread_mutex_unlock (&lock_); - } -} - -ACE_SPECIAL_INLINE -ACE_OS_Thread_Mutex_Guard::ACE_OS_Thread_Mutex_Guard (ACE_thread_mutex_t &m) - : lock_ (m) -{ - acquire (); -} - -ACE_OS_Thread_Mutex_Guard::~ACE_OS_Thread_Mutex_Guard () -{ - release (); -} - -/** - * @class ACE_OS_Recursive_Thread_Mutex_Guard - * - * @brief For internal use only by ACE_OS. - * - * This data structure is meant to be used within an ACE_OS - * function. It performs automatic aquisition and release of - * an ACE_recursive_thread_mutex_t. - */ -class ACE_OS_Recursive_Thread_Mutex_Guard -{ -public: - /// Implicitly and automatically acquire the lock. - ACE_OS_Recursive_Thread_Mutex_Guard (ACE_recursive_thread_mutex_t &m); - - /// Implicitly release the lock. - ~ACE_OS_Recursive_Thread_Mutex_Guard (void); - - /// Explicitly acquire the lock. - int acquire (void); - - /// Explicitly release the lock. - int release (void); - -protected: - /// Reference to the mutex. - ACE_recursive_thread_mutex_t &lock_; - - /// Keeps track of whether we acquired the lock or failed. - int owner_; - - // = Prevent assignment and initialization. - ACE_OS_Recursive_Thread_Mutex_Guard &operator= ( - const ACE_OS_Recursive_Thread_Mutex_Guard &); - ACE_OS_Recursive_Thread_Mutex_Guard ( - const ACE_OS_Recursive_Thread_Mutex_Guard &); -}; - -ACE_SPECIAL_INLINE -int -ACE_OS_Recursive_Thread_Mutex_Guard::acquire (void) -{ - return owner_ = ACE_OS::recursive_mutex_lock (&lock_); -} - -ACE_SPECIAL_INLINE -int -ACE_OS_Recursive_Thread_Mutex_Guard::release (void) -{ - if (owner_ == -1) - return 0; - else - { - owner_ = -1; - return ACE_OS::recursive_mutex_unlock (&lock_); - } -} - -ACE_SPECIAL_INLINE -ACE_OS_Recursive_Thread_Mutex_Guard::ACE_OS_Recursive_Thread_Mutex_Guard ( - ACE_recursive_thread_mutex_t &m) - : lock_ (m), - owner_ (-1) -{ - acquire (); -} - -ACE_OS_Recursive_Thread_Mutex_Guard::~ACE_OS_Recursive_Thread_Mutex_Guard () -{ - release (); -} - -#define ACE_OS_GUARD \ - ACE_OS_Thread_Mutex_Guard ace_os_guard__ (*(ACE_thread_mutex_t *) \ - ACE_OS_Object_Manager::preallocated_object[ \ - ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); - -#define ACE_TSS_CLEANUP_GUARD \ - ACE_OS_Recursive_Thread_Mutex_Guard ace_tss_cleanup_guard__ (*(ACE_recursive_thread_mutex_t *) \ - ACE_OS_Object_Manager::preallocated_object[ \ - ACE_OS_Object_Manager::ACE_TSS_CLEANUP_LOCK]); - -#define ACE_TSS_BASE_GUARD \ - ACE_OS_Recursive_Thread_Mutex_Guard ace_tss_base_guard__ (*(ACE_recursive_thread_mutex_t *) \ - ACE_OS_Object_Manager::preallocated_object[ \ - ACE_OS_Object_Manager::ACE_TSS_BASE_LOCK]); - - -# if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) -int -ACE_OS::netdb_acquire (void) -{ - return ACE_OS::thread_mutex_lock ((ACE_thread_mutex_t *) - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); -} - -int -ACE_OS::netdb_release (void) -{ - return ACE_OS::thread_mutex_unlock ((ACE_thread_mutex_t *) - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); -} -# endif /* defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) */ -#else /* ! ACE_MT_SAFE */ -# define ACE_OS_GUARD -# define ACE_TSS_CLEANUP_GUARD -# define ACE_TSS_BASE_GUARD -#endif /* ! ACE_MT_SAFE */ - -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 - * - * @brief For maintaining a list of ACE_Cleanup_Info items. - * - * For internal use by ACE_Object_Manager. - */ -class ACE_Cleanup_Info_Node -{ -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_); - } -} - -ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time) - : max_wait_time_ (max_wait_time), - stopped_ (0) -{ - this->start (); -} - -ACE_Countdown_Time::~ACE_Countdown_Time (void) -{ - this->stop (); -} - -#if defined (ACE_HAS_POWERPC_TIMER) && defined (ghs) -void -ACE_OS::readPPCTimeBase (u_long &most, u_long &least) -{ - ACE_OS_TRACE ("ACE_OS::readPPCTimeBase"); - - // This function can't be inline because it depends on the arguments - // being in particular registers (r3 and r4), in conformance with the - // EABI standard. It would be nice if we knew how to put the variable - // names directly into the assembler instructions . . . - asm("aclock:"); - asm("mftb r5,TBU"); - asm("mftb r6,TBL"); - asm("mftb r7,TBU"); - asm("cmpw r5,r7"); - asm("bne aclock"); - - asm("stw r5, 0(r3)"); - asm("stw r6, 0(r4)"); -} -#elif defined (ACE_HAS_POWERPC_TIMER) && defined (__GNUG__) -void -ACE_OS::readPPCTimeBase (u_long &most, u_long &least) -{ - ACE_OS_TRACE ("ACE_OS::readPPCTimeBase"); - - // This function can't be inline because it defines a symbol, - // aclock. If there are multiple calls to the function in a - // compilation unit, then that symbol would be multiply defined if - // the function was inline. - asm volatile ("aclock:\n" - "mftbu 5\n" /* upper time base register */ - "mftb 6\n" /* lower time base register */ - "mftbu 7\n" /* upper time base register */ - "cmpw 5,7\n" /* check for rollover of upper */ - "bne aclock\n" - "stw 5,%0\n" /* most */ - "stw 6,%1" /* least */ - : "=m" (most), "=m" (least) /* outputs */ - : /* no inputs */ - : "5", "6", "7", "memory" /* constraints */); -} -#endif /* ACE_HAS_POWERPC_TIMER && (ghs or __GNUG__) */ - -#if defined (ACE_WIN32) || defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) -// Don't inline on those platforms because this function contains -// string literals, and some compilers, e.g., g++, don't handle those -// efficiently in unused inline functions. -int -ACE_OS::uname (ACE_utsname *name) -{ - ACE_OS_TRACE ("ACE_OS::uname"); -# if defined (ACE_WIN32) - size_t maxnamelen = sizeof name->nodename; - ACE_OS::strcpy (name->sysname, - ACE_LIB_TEXT ("Win32")); - - OSVERSIONINFO vinfo; - vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - ::GetVersionEx (&vinfo); - - SYSTEM_INFO sinfo; -# if defined (ACE_HAS_PHARLAP) - // PharLap doesn't do GetSystemInfo. What's really wanted is the - // CPU architecture, so we can get that with EtsGetSystemInfo. Fill - // in what's wanted in the SYSTEM_INFO structure, and carry on. Note - // that the CPU type values in EK_KERNELINFO have the same values - // are the ones defined for SYSTEM_INFO. - EK_KERNELINFO ets_kern; - EK_SYSTEMINFO ets_sys; - EtsGetSystemInfo (&ets_kern, &ets_sys); - sinfo.wProcessorLevel = ACE_static_cast (WORD, ets_kern.CpuType); - sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL; - sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86; -# else - ::GetSystemInfo(&sinfo); - - ACE_OS::strcpy (name->sysname, ACE_LIB_TEXT ("Win32")); -# endif /* ACE_HAS_PHARLAP */ - - const ACE_TCHAR* unknown = ACE_LIB_TEXT ("???"); - - if ( - vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT -# if defined (VER_PLATFORM_WIN32_CE) - || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE -# endif - ) - { - // Get information from the two structures - const ACE_TCHAR *os; - if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) - os = ACE_LIB_TEXT ("Windows NT %d.%d"); - else - os = ACE_LIB_TEXT ("Windows CE %d.%d"); - ACE_OS::sprintf (name->release, - os, - (int) vinfo.dwMajorVersion, - (int) vinfo.dwMinorVersion); - ACE_OS::sprintf (name->version, - ACE_LIB_TEXT ("Build %d %s"), - (int) vinfo.dwBuildNumber, - vinfo.szCSDVersion); - - // We have to make sure that the size of (processor + subtype) - // is not greater than the size of name->machine. So we give - // half the space to the processor and half the space to - // subtype. The -1 is necessary for because of the space - // between processor and subtype in the machine name. - const int bufsize = ((sizeof (name->machine) / sizeof (ACE_TCHAR)) / 2) - 1; - ACE_TCHAR processor[bufsize] = ACE_LIB_TEXT ("Unknown"); - ACE_TCHAR subtype[bufsize] = ACE_LIB_TEXT ("Unknown"); - -# if defined (ghs) - WORD arch = sinfo.u.s.wProcessorArchitecture; -# else - WORD arch = sinfo.wProcessorArchitecture; -# endif - - switch (arch) - { - case PROCESSOR_ARCHITECTURE_INTEL: - ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Intel")); - if (sinfo.wProcessorLevel == 3) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80386")); - else if (sinfo.wProcessorLevel == 4) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80486")); - else if (sinfo.wProcessorLevel == 5) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium")); - else if (sinfo.wProcessorLevel == 6) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium Pro")); - else if (sinfo.wProcessorLevel == 7) // I'm guessing here - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium II")); - break; - case PROCESSOR_ARCHITECTURE_MIPS: - ACE_OS::strcpy (processor, ACE_LIB_TEXT ("MIPS")); - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("R4000")); - break; - case PROCESSOR_ARCHITECTURE_ALPHA: - ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Alpha")); - ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), sinfo.wProcessorLevel); - break; - case PROCESSOR_ARCHITECTURE_PPC: - ACE_OS::strcpy (processor, ACE_LIB_TEXT ("PPC")); - if (sinfo.wProcessorLevel == 1) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("601")); - else if (sinfo.wProcessorLevel == 3) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603")); - else if (sinfo.wProcessorLevel == 4) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("604")); - else if (sinfo.wProcessorLevel == 6) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603+")); - else if (sinfo.wProcessorLevel == 9) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("804+")); - else if (sinfo.wProcessorLevel == 20) - ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("620")); - break; -# if defined PROCESSOR_ARCHITECTURE_IA64 - case PROCESSOR_ARCHITECTURE_IA64: - ACE_OS_String::strcpy (processor, ACE_LIB_TEXT ("Itanium")); - ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), - sinfo.wProcessorLevel); - break; -# endif -# if defined PROCESSOR_ARCHITECTURE_ARM - case PROCESSOR_ARCHITECTURE_ARM: - ACE_OS_String::strcpy (processor, ACE_LIB_TEXT ("ARM")); - ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), - sinfo.wProcessorLevel); - break; -# endif - case PROCESSOR_ARCHITECTURE_UNKNOWN: - default: - // @@ We could provide WinCE specific info here. But let's - // defer that to some later point. - ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Unknown")); - break; - } - ACE_OS::sprintf (name->machine, - ACE_LIB_TEXT ("%s %s"), - processor, subtype); - } - else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - { - if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0) - { - ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 95")); - if (vinfo.szCSDVersion[1] == 'C') - ACE_OS::strcat (name->release, ACE_LIB_TEXT (" OSR2")); - } - else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10) - { - ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 98")); - if (vinfo.szCSDVersion[1] == 'A') - ACE_OS::strcat (name->release, ACE_LIB_TEXT (" SE")); - } - else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90) - { - ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows Me")); - } - else - { - ACE_OS::strcpy (name->release, unknown); - } - - ACE_OS::sprintf (name->version, ACE_LIB_TEXT ("%d"), - LOWORD (vinfo.dwBuildNumber)); - if (sinfo.dwProcessorType == PROCESSOR_INTEL_386) - ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80386")); - else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486) - ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80486")); - else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM) - ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel Pentium")); - else - ACE_OS::strcpy (name->machine, unknown); - } - else - { - // We don't know what this is! - - ACE_OS::strcpy (name->release, unknown); - ACE_OS::strcpy (name->version, unknown); - ACE_OS::strcpy (name->machine, unknown); - } - -# if defined (ACE_LACKS_HOSTNAME) - return 0; -# else /* ACE_LACKS_HOSTNAME */ - return ACE_OS::hostname (name->nodename, maxnamelen); -# endif /* ACE_LACKS_HOSTNAME */ - -# elif defined (VXWORKS) - size_t maxnamelen = sizeof name->nodename; - ACE_OS::strcpy (name->sysname, "VxWorks"); - ACE_OS::strcpy (name->release, "???"); - ACE_OS::strcpy (name->version, sysBspRev ()); - ACE_OS::strcpy (name->machine, sysModel ()); - - return ACE_OS::hostname (name->nodename, maxnamelen); -# elif defined (CHORUS) - size_t maxnamelen = sizeof name->nodename; - ACE_OS::strcpy (name->sysname, "CHORUS/ClassiX"); - ACE_OS::strcpy (name->release, "???"); - ACE_OS::strcpy (name->version, "???"); - ACE_OS::strcpy (name->machine, "???"); - - return ACE_OS::hostname (name->nodename, maxnamelen); -#elif defined (ACE_PSOS) - const unsigned long buflen(64); - char buf[buflen]; - unsigned long len; - sys_info(PSOS_VERSION,(void *)buf,buflen,&len); - ACE_OS::strcpy (name->sysname, "pSOS"); - ACE_OS::strcpy (name->release, "???"); - ACE_OS::strcpy (name->version, buf); - ACE_OS::strcpy (name->machine, "PPC 405"); // a bit of a hack - -#endif /* ACE_WIN32 */ -} -#endif /* ACE_WIN32 || VXWORKS */ - - -#if defined (VXWORKS) -struct hostent * -ACE_OS::gethostbyname (const char *name) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyname"); - - // not thread safe! - static hostent ret; - static int first_addr; - static char *hostaddr[2]; - static char *aliases[1]; - - ACE_OSCALL (::hostGetByName ((char *) name), int, -1, first_addr); - if (first_addr == -1) - return 0; - - hostaddr[0] = (char *) &first_addr; - hostaddr[1] = 0; - aliases[0] = 0; - - // Might not be official: just echo input arg. - ret.h_name = (char *) name; - ret.h_addrtype = AF_INET; - ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; - ret.h_addr_list = hostaddr; - ret.h_aliases = aliases; - - return &ret; -} - -struct hostent * -ACE_OS::gethostbyaddr (const char *addr, int length, int type) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyaddr"); - - if (length != 4 || type != AF_INET) - { - errno = EINVAL; - return 0; - } - - // not thread safe! - static hostent ret; - static char name [MAXNAMELEN + 1]; - static char *hostaddr[2]; - static char *aliases[1]; - - if (::hostGetByAddr (*(int *) addr, name) != 0) - { - // errno will have been set to S_hostLib_UNKNOWN_HOST. - return 0; - } - - // Might not be official: just echo input arg. - hostaddr[0] = (char *) addr; - hostaddr[1] = 0; - aliases[0] = 0; - - ret.h_name = name; - ret.h_addrtype = AF_INET; - ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; - ret.h_addr_list = hostaddr; - ret.h_aliases = aliases; - - return &ret; -} - -struct hostent * -ACE_OS::gethostbyaddr_r (const char *addr, int length, int type, - hostent *result, ACE_HOSTENT_DATA buffer, - int *h_errnop) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r"); - if (length != 4 || type != AF_INET) - { - errno = EINVAL; - return 0; - } - - if (ACE_OS::netdb_acquire ()) - return 0; - else - { - // buffer layout: - // buffer[0-3]: h_addr_list[0], the first (and only) addr. - // buffer[4-7]: h_addr_list[1], the null terminator for the h_addr_list. - // buffer[8]: the name of the host, null terminated. - - // Call ::hostGetByAddr (), which puts the (one) hostname into - // buffer. - if (::hostGetByAddr (*(int *) addr, &buffer[8]) == 0) - { - // Store the return values in result. - result->h_name = &buffer[8]; // null-terminated host name - result->h_addrtype = AF_INET; - result->h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN. - - result->h_addr_list = (char **) buffer; - // Might not be official: just echo input arg. - result->h_addr_list[0] = (char *) addr; - // Null-terminate the list of addresses. - result->h_addr_list[1] = 0; - // And no aliases, so null-terminate h_aliases. - result->h_aliases = &result->h_addr_list[1]; - } - else - { - // errno will have been set to S_hostLib_UNKNOWN_HOST. - result = 0; - } - } - - ACE_OS::netdb_release (); - *h_errnop = errno; - return result; -} - -struct hostent * -ACE_OS::gethostbyname_r (const char *name, hostent *result, - ACE_HOSTENT_DATA buffer, - int *h_errnop) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyname_r"); - - if (ACE_OS::netdb_acquire ()) - return 0; - else - { - int addr; - ACE_OSCALL (::hostGetByName ((char *) name), int, -1, addr); - - if (addr == -1) - { - // errno will have been set to S_hostLib_UNKNOWN_HOST - result = 0; - } - else - { - // Might not be official: just echo input arg. - result->h_name = (char *) name; - result->h_addrtype = AF_INET; - result->h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; - - // buffer layout: - // buffer[0-3]: h_addr_list[0], pointer to the addr. - // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list. - // buffer[8-11]: the first (and only) addr. - - // Store the address list in buffer. - result->h_addr_list = (char **) buffer; - // Store the actual address _after_ the address list. - result->h_addr_list[0] = (char *) &result->h_addr_list[2]; - result->h_addr_list[2] = (char *) addr; - // Null-terminate the list of addresses. - result->h_addr_list[1] = 0; - // And no aliases, so null-terminate h_aliases. - result->h_aliases = &result->h_addr_list[1]; - } - } - - ACE_OS::netdb_release (); - *h_errnop = errno; - return result; -} - -// Leave this in the global scope to allow -// users to adjust the delay value. -int ACE_THR_JOIN_DELAY = 5; - -int -ACE_OS::thr_join (ACE_hthread_t thr_handle, - ACE_THR_FUNC_RETURN *status) -{ - // We can't get the status of the thread - if (status != 0) - { - *status = 0; - } - - // This method can not support joining all threads - if (ACE_OS::thr_cmp (thr_handle, ACE_OS::NULL_hthread)) - { - ACE_NOTSUP_RETURN (-1); - } - - int retval = ESRCH; - ACE_hthread_t current; - ACE_OS::thr_self (current); - - // Make sure we are not joining ourself - if (ACE_OS::thr_cmp (thr_handle, current)) - { - retval = EDEADLK; - } - else - { - // Whether the task exists or not - // we will return a successful value - retval = 0; - - // Verify that the task id still exists - while (taskIdVerify (thr_handle) == OK) - { - // Wait a bit to see if the task is still active. - ACE_OS::sleep (ACE_THR_JOIN_DELAY); - } - } - - // Adapt the return value into errno and return value. - // The ACE_ADAPT_RETVAL macro doesn't exactly do what - // we need to do here, so we do it manually. - if (retval != 0) - { - errno = retval; - retval = -1; - } - - return retval; -} - -int -ACE_OS::thr_join (ACE_thread_t waiter_id, - ACE_thread_t *thr_id, - ACE_THR_FUNC_RETURN *status) -{ - thr_id = 0; - return ACE_OS::thr_join (taskNameToId (waiter_id), status); -} -#endif /* VXWORKS */ - -void -ACE_OS::ace_flock_t::dump (void) const -{ -#if defined (ACE_HAS_DUMP) - ACE_OS_TRACE ("ACE_OS::ace_flock_t::dump"); - #if 0 - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("handle_ = %u"), this->handle_)); -#if defined (ACE_WIN32) - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nInternal = %d"), this->overlapped_.Internal)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nInternalHigh = %d"), this->overlapped_.InternalHigh)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nOffsetHigh = %d"), this->overlapped_.OffsetHigh)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nhEvent = %d"), this->overlapped_.hEvent)); -#elif !defined (CHORUS) - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_whence = %d"), this->lock_.l_whence)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_start = %d"), this->lock_.l_start)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_len = %d"), this->lock_.l_len)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_type = %d"), this->lock_.l_type)); -#endif /* ACE_WIN32 */ - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* 0 */ -#endif /* ACE_HAS_DUMP */ -} - -void -ACE_OS::mutex_lock_cleanup (void *mutex) -{ - ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex; - ACE_OS::mutex_unlock (p_lock); -# else - ACE_UNUSED_ARG (mutex); -# endif /* ACE_HAS_PTHREADS */ -# else - ACE_UNUSED_ARG (mutex); -# endif /* ACE_HAS_THREADS */ -} - -#if defined (ACE_USES_WCHAR) -void ACE_OS::checkUnicodeFormat (FILE* fp) -{ - if (fp != 0) - { - // Due to the ACE_TCHAR definition, all default input files, such as - // svc.conf, have to be in Unicode format (small endian) on WinCE - // because ACE has all 'char' converted into ACE_TCHAR. - // However, for TAO, ASCII files, such as IOR file, can still be read and - // be written without any error since given buffers are all in 'char' type - // instead of ACE_TCHAR. Therefore, it is user's reponsibility to select - // correct buffer type. - - // At this point, check if the file is Unicode or not. - WORD first_two_bytes; - int numRead = ACE_OS::fread(&first_two_bytes, sizeof(WORD), 1, fp); - - if (numRead == 1) - { - if ((first_two_bytes != 0xFFFE) && // not a small endian Unicode file - (first_two_bytes != 0xFEFF)) // not a big endian Unicode file - { - ACE_OS::fseek(fp, 0, FILE_BEGIN); // set file pointer back to the beginning - } - } - // if it is a Unicode file, file pointer will be right next to the first two-bytes - } -} -#endif // ACE_USES_WCHAR #if defined (ACE_WIN32) -FILE * -ACE_OS::fopen (const ACE_TCHAR *filename, - const ACE_TCHAR *mode) -{ - ACE_OS_TRACE ("ACE_OS::fopen"); - int hmode = _O_TEXT; - - for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++) - ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode); - - ACE_HANDLE handle = ACE_OS::open (filename, hmode); - if (handle != ACE_INVALID_HANDLE) - { -# if defined (ACE_HAS_WINCE) - FILE *fp = ::_wfdopen (handle, mode); - if (fp != 0) - { - checkUnicodeFormat(fp); - return fp; - } -# else - hmode &= _O_TEXT | _O_RDONLY | _O_APPEND; -# if defined (ACE_WIN64) - int fd = _open_osfhandle (intptr_t (handle), hmode); -# else - int fd = _open_osfhandle (long (handle), hmode); -# endif /* ACE_WIN64 */ - if (fd != -1) - { -# if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR) - FILE *fp = ::_fdopen (fd, ACE_const_cast (char *, mode)); -# elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR) - FILE *fp = ::_wfdopen (fd, ACE_const_cast (wchar_t *, mode)); -# elif defined (ACE_USES_WCHAR) - FILE *fp = ::_wfdopen (fd, mode); -# else - FILE *fp = ::fdopen (fd, mode); -# endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */ - if (fp != 0) - { -# if defined (ACE_USES_WCHAR) - checkUnicodeFormat(fp); -# endif // ACE_USES_WCHAR - return fp; - } - _close (fd); - } -# endif // ACE_HAS_WINCE - - ACE_OS::close (handle); - } - return 0; -} -#endif /* ACE_WIN32 */ - -// The following *printf functions aren't inline because -// they use varargs. - -int -ACE_OS::fprintf (FILE *fp, const char *format, ...) -{ - ACE_OS_TRACE ("ACE_OS::fprintf"); - int result = 0; - va_list ap; - va_start (ap, format); - ACE_OSCALL (::vfprintf (fp, format, ap), int, -1, result); - va_end (ap); - return result; -} - -#if defined (ACE_HAS_WCHAR) -int -ACE_OS::fprintf (FILE *fp, const wchar_t *format, ...) -{ - ACE_OS_TRACE ("ACE_OS::fprintf"); - -# if !defined (ACE_HAS_VFWPRINTF) - ACE_UNUSED_ARG (fp); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); - -# else - int result = 0; - va_list ap; - va_start (ap, format); - ACE_OSCALL (::vfwprintf (fp, format, ap), int, -1, result); - va_end (ap); - return result; - -# endif /* ACE_HAS_VFWPRINTF */ -} -#endif /* ACE_HAS_WCHAR */ - -int -ACE_OS::printf (const char *format, ...) -{ - ACE_OS_TRACE ("ACE_OS::printf"); - int result; - va_list ap; - va_start (ap, format); - ACE_OSCALL (::vprintf (format, ap), int, -1, result); - va_end (ap); - return result; -} - -int -ACE_OS::sprintf (char *buf, const char *format, ...) -{ - // ACE_OS_TRACE ("ACE_OS::sprintf"); - - int result; - va_list ap; - va_start (ap, format); - ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsprintf (buf, format, ap)), int, -1, result); - va_end (ap); - return result; -} - -#if defined (ACE_HAS_WCHAR) -int -ACE_OS::sprintf (wchar_t *buf, const wchar_t *format, ...) -{ - ACE_OS_TRACE ("ACE_OS::sprintf"); - -# if defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) - - // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a - // maxlen argument. Since this method doesn't supply one, pass in - // the max possible length. If this isn't ok, use ACE_OS::snprintf(). - int result; - va_list ap; - va_start (ap, format); - ACE_OSCALL (::vswprintf (buf, ULONG_MAX, format, ap), int, -1, result); - va_end (ap); - return result; - -# elif defined (ACE_WIN32) - // Windows has vswprintf, but the signature is from the older ISO C - // standard. Also see ACE_OS::snprintf() for more info on this. - - int result; - va_list ap; - va_start (ap, format); - ACE_OSCALL (::vswprintf (buf, format, ap), int, -1, result); - va_end (ap); - return result; - -# else - - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); - -# endif /* ACE_HAS_VSWPRINTF */ -} -#endif /* ACE_HAS_WCHAR */ - -int -ACE_OS::snprintf (char *buf, size_t maxlen, const char *format, ...) -{ - // ACE_OS_TRACE ("ACE_OS::snprintf"); -#if defined (ACE_HAS_SNPRINTF) - int result; - va_list ap; - va_start (ap, format); -# if defined (ACE_WIN32) - ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnprintf (buf, maxlen, format, ap)), - int, -1, result); - // Win32 doesn't 0-terminate the string if it overruns maxlen. - if (result == -1) - buf[maxlen-1] = '\0'; -# else - ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsnprintf (buf, maxlen, format, ap)), - int, -1, result); -# endif /* ACE_WIN32 */ - va_end (ap); - // In out-of-range conditions, C99 defines vsnprintf to return the number - // of characters that would have been written if enough space was available. - // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return - // -1. This method follows the C99 standard, but needs to guess at the - // value; uses maxlen + 1. - if (result == -1) - result = ACE_static_cast (int, (maxlen + 1)); - return result; - -#else - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (maxlen); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SNPRINTF */ -} - -#if defined (ACE_HAS_WCHAR) -int -ACE_OS::snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...) -{ - // ACE_OS_TRACE ("ACE_OS::snprintf"); -#if (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) || defined (ACE_WIN32) - int result; - va_list ap; - va_start (ap, format); -# if defined (ACE_WIN32) - // Microsoft's vswprintf() doesn't have the maxlen argument that - // XPG4/UNIX98 define. They do, however, recommend use of _vsnwprintf() - // as a substitute, which does have the same signature as the UNIX98 one. - ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnwprintf (buf, maxlen, format, ap)), - int, -1, result); - // Win32 doesn't 0-terminate the string if it overruns maxlen. - if (result == -1) - buf[maxlen-1] = '\0'; -# else - ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vswprintf (buf, maxlen, format, ap)), - int, -1, result); -# endif /* ACE_WIN32 */ - va_end (ap); - // In out-of-range conditions, C99 defines vsnprintf to return the number - // of characters that would have been written if enough space was available. - // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return - // -1. This method follows the C99 standard, but needs to guess at the - // value; uses maxlen + 1. - if (result == -1) - result = ACE_static_cast (int, (maxlen + 1)); - return result; - -#else - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (maxlen); - ACE_UNUSED_ARG (format); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SNPRINTF */ -} -#endif /* ACE_HAS_WCHAR */ - -char * -ACE_OS::gets (char *str, int n) -{ - ACE_OS_TRACE ("ACE_OS::gets"); - int c; - char *s = str; - - if (str == 0 || n < 0) n = 0; - if (n == 0) str = 0; - else n--; - - while ((c = getchar ()) != '\n') - { - - if (c == EOF && errno == EINTR) - { -# if defined (ACE_HAS_SIGNAL_SAFE_OS_CALLS) - continue; -# else - break; -# endif /* ACE_HAS_SIGNAL_SAFE_OS_CALLS */ - } - - if (c == EOF) - break; - - if (n > 0) - n--, *s++ = c; - } - if (s) *s = '\0'; - - return (c == EOF) ? 0 : str; -} - -int -ACE_OS::execl (const char * /* path */, const char * /* arg0 */, ...) -{ - ACE_OS_TRACE ("ACE_OS::execl"); -#if defined (ACE_WIN32) || defined (VXWORKS) - ACE_NOTSUP_RETURN (-1); -#else - ACE_NOTSUP_RETURN (-1); - // Need to write this code. - // ACE_OSCALL_RETURN (::execv (path, argv), int, -1); -#endif /* ACE_WIN32 */ -} - -int -ACE_OS::execle (const char * /* path */, const char * /* arg0 */, ...) -{ - ACE_OS_TRACE ("ACE_OS::execle"); -#if defined (ACE_WIN32) || defined (VXWORKS) - ACE_NOTSUP_RETURN (-1); -#else - ACE_NOTSUP_RETURN (-1); - // Need to write this code. - // ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); -#endif /* ACE_WIN32 */ -} - -int -ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...) -{ - ACE_OS_TRACE ("ACE_OS::execlp"); -#if defined (ACE_WIN32) || defined (VXWORKS) - ACE_NOTSUP_RETURN (-1); -#else - ACE_NOTSUP_RETURN (-1); - // Need to write this code. - // ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); -#endif /* ACE_WIN32 */ -} - -int -ACE_OS::scheduling_class (const char *class_name, ACE_id_t &id) -{ -#if defined (ACE_HAS_PRIOCNTL) - // Get the priority class ID. - pcinfo_t pcinfo; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); - - ACE_OS::strcpy (pcinfo.pc_clname, class_name); - if (ACE_OS::priority_control (P_ALL /* ignored */, - P_MYID /* ignored */, - PC_GETCID, - (char *) &pcinfo) == -1) - { - return -1; - } - else - { - id = pcinfo.pc_cid; - return 0; - } -#else /* ! ACE_HAS_PRIOCNTL */ - ACE_UNUSED_ARG (class_name); - ACE_UNUSED_ARG (id); - ACE_NOTSUP_RETURN (-1); -#endif /* ! ACE_HAS_PRIOCNTL */ -} - -int -ACE_OS::set_scheduling_params (const ACE_Sched_Params &sched_params, - ACE_id_t id) -{ -#if defined (ACE_HAS_PRIOCNTL) - // Set priority class, priority, and quantum of this LWP or process as - // specified in sched_params. - - // Get the priority class ID. - ACE_id_t class_id; - if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER ? - "TS" : - "RT", class_id) == -1) - { - return -1; - } - - pcparms_t pcparms; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&pcparms, 0, sizeof pcparms); - - pcparms.pc_cid = class_id; - - if (sched_params.policy () == ACE_SCHED_OTHER && - sched_params.quantum () == ACE_Time_Value::zero) - // SunOS doesn't support non-zero quantums in time-sharing class: use - // real-time class instead. - { - tsparms_t tsparms; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&tsparms, 0, sizeof tsparms); - - // Don't change ts_uprilim (user priority limit) - tsparms.ts_uprilim = TS_NOCHANGE; - tsparms.ts_upri = sched_params.priority (); - - // Package up the TS class ID and parameters for the - // priority_control () call. - ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms); - } - else if (sched_params.policy () == ACE_SCHED_FIFO || - (sched_params.policy () == ACE_SCHED_RR && - sched_params.quantum () != ACE_Time_Value::zero)) - // must have non-zero quantum for RR, to make it meaningful - // A zero quantum with FIFO has special significance: it actually - // means infinite time quantum, i.e., run-to-completion. - { - rtparms_t rtparms; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&rtparms, 0, sizeof rtparms); - - rtparms.rt_pri = sched_params.priority (); - - if (sched_params.quantum () == ACE_Time_Value::zero) - { - // rtparms.rt_tqsecs is ignored with RT_TQINF - rtparms.rt_tqnsecs = RT_TQINF; - } - else - { - rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec (); - rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000; - } - - // Package up the RT class ID and parameters for the - // priority_control () call. - ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms); - } - else - { - errno = EINVAL; - return -1; - } - - if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD - ? ACE_SCOPE_PROCESS - : sched_params.scope ()), - id, - PC_SETPARMS, - (char *) &pcparms) < 0) - { - return ACE_OS::last_error (); - } - - return 0; -#else /* ! ACE_HAS_PRIOCNTL */ - ACE_UNUSED_ARG (sched_params); - ACE_UNUSED_ARG (id); - ACE_NOTSUP_RETURN (-1); -#endif /* ! ACE_HAS_PRIOCNTL */ -} - -int -ACE_OS::thr_setprio (const ACE_Sched_Priority prio) -{ - // Set the thread priority on the current thread. - ACE_hthread_t my_thread_id; - ACE_OS::thr_self (my_thread_id); - - int status = ACE_OS::thr_setprio (my_thread_id, prio); - -# if defined (ACE_NEEDS_LWP_PRIO_SET) - // If the thread is in the RT class, then set the priority on its - // LWP. (Instead of doing this if the thread is in the RT class, it - // should be done for all bound threads. But, there doesn't appear - // to be an easy way to determine if the thread is bound.) - - if (status == 0) - { - // Find what scheduling class the thread's LWP is in. - ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0); - if (ACE_OS::lwp_getparams (sched_params) == -1) - { - return -1; - } - else if (sched_params.policy () == ACE_SCHED_FIFO || - sched_params.policy () == ACE_SCHED_RR) - { - // This thread's LWP is in the RT class, so we need to set - // its priority. - sched_params.priority (prio); - return ACE_OS::lwp_setparams (sched_params); - } - // else this is not an RT thread. Nothing more needs to be - // done. - } -# endif /* ACE_NEEDS_LWP_PRIO_SET */ - - return status; -} - -int -ACE_OS::sched_params (const ACE_Sched_Params &sched_params, - ACE_id_t id) -{ - ACE_OS_TRACE ("ACE_OS::sched_params"); -# if defined (CHORUS) - ACE_UNUSED_ARG (id); - int result; - struct sched_param param; - ACE_thread_t thr_id = ACE_OS::thr_self (); - - param.sched_priority = sched_params.priority (); - - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, - sched_params.policy (), - ¶m), - result), - int, -1); -# elif defined (ACE_HAS_STHREADS) - return ACE_OS::set_scheduling_params (sched_params, id); -# elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED) - ACE_UNUSED_ARG (id); - if (sched_params.quantum () != ACE_Time_Value::zero) - { - // quantums not supported - errno = EINVAL; - return -1; - } - - // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for - // providing this code for 1003.1c PThreads. Please note that this - // has only been tested for POSIX 1003.1c threads, and may cause - // problems with other PThreads flavors! - - struct sched_param param; - param.sched_priority = sched_params.priority (); - - if (sched_params.scope () == ACE_SCOPE_PROCESS) - { - int result = ::sched_setscheduler (0, // this process - sched_params.policy (), - ¶m) == -1 ? -1 : 0; -# if defined (DIGITAL_UNIX) - return result == 0 - ? // Use priocntl (2) to set the process in the RT class, - // if using an RT policy. - ACE_OS::set_scheduling_params (sched_params) - : result; -# else /* ! DIGITAL_UNIX */ - return result; -# endif /* ! DIGITAL_UNIX */ - } - else if (sched_params.scope () == ACE_SCOPE_THREAD) - { - ACE_thread_t thr_id = ACE_OS::thr_self (); - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - return (::pthread_setscheduler (thr_id, - sched_params.policy (), - sched_params.priority()) == -1 ? -1 : 0); -# else - int result; - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, - sched_params.policy (), - ¶m), - result), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - } -# if defined (sun) - // We need to be able to set LWP priorities on Suns, even without - // ACE_HAS_STHREADS, to obtain preemption. - else if (sched_params.scope () == ACE_SCOPE_LWP) - return ACE_OS::set_scheduling_params (sched_params, id); -# endif /* sun */ - else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX - { - errno = EINVAL; - return -1; - } - -# elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - - // PharLap ETS can act on the current thread - it can set the - // quantum also, unlike Win32. All this only works on the RT - // version. -# if defined (ACE_HAS_PHARLAP_RT) - if (id != ACE_SELF) - ACE_NOTSUP_RETURN (-1); - - if (sched_params.quantum() != ACE_Time_Value::zero) - EtsSetTimeSlice (sched_params.quantum().msec()); - -# else - ACE_UNUSED_ARG (id); - - if (sched_params.scope () != ACE_SCOPE_PROCESS - || sched_params.quantum () != ACE_Time_Value::zero) - { - // Win32 only allows setting priority class (therefore, policy) - // at the process level. I don't know of a way to set the - // quantum. - errno = EINVAL; - return -1; - } - - // Set the priority class of this process to the REALTIME process class - // _if_ the policy is ACE_SCHED_FIFO. Otherwise, set to NORMAL. - if (!::SetPriorityClass (::GetCurrentProcess (), - (sched_params.policy () == ACE_SCHED_FIFO || - sched_params.policy () == ACE_SCHED_RR) - ? REALTIME_PRIORITY_CLASS - : NORMAL_PRIORITY_CLASS)) - { - ACE_OS::set_errno_to_last_error (); - return -1; - } -# endif /* ACE_HAS_PHARLAP_RT */ - - // Set the thread priority on the current thread. - return ACE_OS::thr_setprio (sched_params.priority ()); - -# elif defined (VXWORKS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (id); - - // There is only one class of priorities on VxWorks, and no time - // quanta. So, just set the current thread's priority. - - if (sched_params.policy () != ACE_SCHED_FIFO - || sched_params.scope () != ACE_SCOPE_PROCESS - || sched_params.quantum () != ACE_Time_Value::zero) - { - errno = EINVAL; - return -1; - } - - // Set the thread priority on the current thread. - return ACE_OS::thr_setprio (sched_params.priority ()); -# else - ACE_UNUSED_ARG (sched_params); - ACE_UNUSED_ARG (id); - ACE_NOTSUP_RETURN (-1); -# endif /* CHORUS */ -} // = Static initialization. -// This is necessary to deal with POSIX pthreads insanity. This -// guarantees that we've got a "zero'd" thread id even when -// ACE_thread_t, ACE_hthread_t, and ACE_thread_key_t are implemented -// as structures... Under no circumstances should these be given -// initial values. -// Note: these three objects require static construction. -ACE_thread_t ACE_OS::NULL_thread; -ACE_hthread_t ACE_OS::NULL_hthread; -#if defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - ACE_thread_key_t ACE_OS::NULL_key = ACE_static_cast (ACE_thread_key_t, -1); -#else /* ! ACE_HAS_TSS_EMULATION */ - ACE_thread_key_t ACE_OS::NULL_key; -#endif /* ! ACE_HAS_TSS_EMULATION */ - -#if defined (CHORUS) -KnCap ACE_OS::actorcaps_[ACE_CHORUS_MAX_ACTORS]; -// This is used to map an actor's id into a KnCap for killing and -// waiting actors. -#endif /* CHORUS */ - -#if defined (ACE_WIN32) - -// = Static initialization. - -// Keeps track of whether we've initialized the WinSock DLL. -int ACE_OS::socket_initialized_; #endif /* WIN32 */ -#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - -// Moved class ACE_TSS_Ref declaration to OS.h so it can be visible to -// the single file of template instantiations. - -ACE_TSS_Ref::ACE_TSS_Ref (ACE_thread_t id) - : tid_(id) -{ - ACE_OS_TRACE ("ACE_TSS_Ref::ACE_TSS_Ref"); -} - -ACE_TSS_Ref::ACE_TSS_Ref (void) -{ - ACE_OS_TRACE ("ACE_TSS_Ref::ACE_TSS_Ref"); -} - -// Check for equality. -int -ACE_TSS_Ref::operator== (const ACE_TSS_Ref &info) const -{ - ACE_OS_TRACE ("ACE_TSS_Ref::operator=="); - - return this->tid_ == info.tid_; -} - -// Check for inequality. -ACE_SPECIAL_INLINE -int -ACE_TSS_Ref::operator != (const ACE_TSS_Ref &tss_ref) const -{ - ACE_OS_TRACE ("ACE_TSS_Ref::operator !="); - - return !(*this == tss_ref); -} - -// moved class ACE_TSS_Info declaration -// to OS.h so it can be visible to the -// single file of template instantiations - -ACE_TSS_Info::ACE_TSS_Info (ACE_thread_key_t key, - void (*dest)(void *), - void *tss_inst) - : key_ (key), - destructor_ (dest), - tss_obj_ (tss_inst), - thread_count_ (-1) -{ - ACE_OS_TRACE ("ACE_TSS_Info::ACE_TSS_Info"); -} - -ACE_TSS_Info::ACE_TSS_Info (void) - : key_ (ACE_OS::NULL_key), - destructor_ (0), - tss_obj_ (0), - thread_count_ (-1) -{ - ACE_OS_TRACE ("ACE_TSS_Info::ACE_TSS_Info"); -} - -# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T) -static inline int operator== (const ACE_thread_key_t &lhs, - const ACE_thread_key_t &rhs) -{ - return ! ACE_OS::memcmp (&lhs, &rhs, sizeof (ACE_thread_key_t)); -} - -static inline int operator!= (const ACE_thread_key_t &lhs, - const ACE_thread_key_t &rhs) -{ - return ! (lhs == rhs); -} -# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ - -// Check for equality. -int -ACE_TSS_Info::operator== (const ACE_TSS_Info &info) const -{ - ACE_OS_TRACE ("ACE_TSS_Info::operator=="); - - return this->key_ == info.key_; -} - -// Check for inequality. -int -ACE_TSS_Info::operator != (const ACE_TSS_Info &info) const -{ - ACE_OS_TRACE ("ACE_TSS_Info::operator !="); - - return !(*this == info); -} - -void -ACE_TSS_Info::dump (void) -{ -#if defined (ACE_HAS_DUMP) - // ACE_OS_TRACE ("ACE_TSS_Info::dump"); - -#if 0 - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("key_ = %u\n"), this->key_)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("destructor_ = %u\n"), this->destructor_)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("tss_obj_ = %u\n"), this->tss_obj_)); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -#endif /* 0 */ -#endif /* ACE_HAS_DUMP */ -} - -// Moved class ACE_TSS_Keys declaration to OS.h so it can be visible -// to the single file of template instantiations. - -ACE_TSS_Keys::ACE_TSS_Keys (void) -{ - for (u_int i = 0; i < ACE_WORDS; ++i) - { - key_bit_words_[i] = 0; - } -} - -ACE_SPECIAL_INLINE -void -ACE_TSS_Keys::find (const u_int key, u_int &word, u_int &bit) -{ - word = key / ACE_BITS_PER_WORD; - bit = key % ACE_BITS_PER_WORD; -} - -int -ACE_TSS_Keys::test_and_set (const ACE_thread_key_t key) -{ - ACE_KEY_INDEX (key_index, key); - u_int word, bit; - find (key_index, word, bit); - - if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit)) - { - return 1; - } - else - { - ACE_SET_BITS (key_bit_words_[word], 1 << bit); - return 0; - } -} - -int -ACE_TSS_Keys::test_and_clear (const ACE_thread_key_t key) -{ - ACE_KEY_INDEX (key_index, key); - u_int word, bit; - find (key_index, word, bit); - - if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit)) - { - ACE_CLR_BITS (key_bit_words_[word], 1 << bit); - return 0; - } - else - { - return 1; - } -} - -int -ACE_TSS_Keys::is_set (const ACE_thread_key_t key) const -{ - ACE_KEY_INDEX (key_index, key); - u_int word, bit; - find (key_index, word, bit); - - return ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit); -} - - -/** - * @class ACE_TSS_Cleanup - * - * @brief Singleton that knows how to clean up all the thread-specific - * resources for Win32. - * - * All this nonsense is required since Win32 doesn't - * automatically cleanup thread-specific storage on thread exit, - * unlike real operating systems... ;-) - */ -class ACE_TSS_Cleanup -{ -public: - static ACE_TSS_Cleanup *instance (void); - - ~ACE_TSS_Cleanup (void); - - /// Cleanup the thread-specific objects. Does _NOT_ exit the thread. - void exit (void *status); - - /// Insert a <key, destructor> tuple into the table. - int insert (ACE_thread_key_t key, void (*destructor)(void *), void *inst); - - /// Remove a <key, destructor> tuple from the table. - int remove (ACE_thread_key_t key); - - /// Detaches a tss_instance from its key. - int detach (void *inst); - - /// Mark a key as being used by this thread. - void key_used (ACE_thread_key_t key); - - /// Free all keys left in the table before destruction. - int free_all_keys_left (void); - - /// Indication of whether the ACE_TSS_CLEANUP_LOCK is usable, and - /// therefore whether we are in static constructor/destructor phase - /// or not. - static int lockable () { return instance_ != 0; } - -protected: - void dump (void); - - /// Ensure singleton. - ACE_TSS_Cleanup (void); - -private: - // Array of <ACE_TSS_Info> objects. - typedef ACE_TSS_Info ACE_TSS_TABLE[ACE_DEFAULT_THREAD_KEYS]; - typedef ACE_TSS_Info *ACE_TSS_TABLE_ITERATOR; - - /// Table of <ACE_TSS_Info>'s. - ACE_TSS_TABLE table_; - - /// Key for the thread-specific array of whether each TSS key is in use. - ACE_thread_key_t in_use_; - - /// Accessor for this threads ACE_TSS_Keys instance. - ACE_TSS_Keys *tss_keys (); - -#if defined (ACE_HAS_TSS_EMULATION) - /// Key that is used by in_use_. We save this key so that we know - /// not to call its destructor in free_all_keys_left (). - ACE_thread_key_t in_use_key_; -#endif /* ACE_HAS_TSS_EMULATION */ - - // = Static data. - /// Pointer to the singleton instance. - static ACE_TSS_Cleanup *instance_; -}; - -// = Static object initialization. - -// Pointer to the singleton instance. -ACE_TSS_Cleanup *ACE_TSS_Cleanup::instance_ = 0; - -ACE_TSS_Cleanup::~ACE_TSS_Cleanup (void) -{ - // Zero out the instance pointer to support lockable () accessor. - ACE_TSS_Cleanup::instance_ = 0; -} - -void -ACE_TSS_Cleanup::exit (void * /* status */) -{ - ACE_OS_TRACE ("ACE_TSS_Cleanup::exit"); - - ACE_TSS_TABLE_ITERATOR key_info = table_; - ACE_TSS_Info info_arr[ACE_DEFAULT_THREAD_KEYS]; - int info_ix = 0; - - // While holding the lock, we only collect the ACE_TSS_Info objects - // in an array without invoking the according destructors. - { - ACE_TSS_CLEANUP_GUARD - - // Iterate through all the thread-specific items and free them all - // up. - - for (unsigned int i = 0; - i < ACE_DEFAULT_THREAD_KEYS; - ++key_info, ++i) - { - if (key_info->key_ == ACE_OS::NULL_key || - ! key_info->key_in_use ()) continue; - - // If the key's ACE_TSS_Info in-use bit for this thread was set, - // unset it and decrement the key's thread_count_. - if (! tss_keys ()->test_and_clear (key_info->key_)) - { - --key_info->thread_count_; - } - - void *tss_info = 0; - - if (key_info->destructor_ - && ACE_OS::thr_getspecific (key_info->key_, &tss_info) == 0 - && tss_info) - { - info_arr[info_ix].key_ = key_info->key_; - info_arr[info_ix].destructor_ = key_info->destructor_; - info_arr[info_ix++].tss_obj_ = key_info->tss_obj_; - } - } - } - - // Now we have given up the ACE_TSS_Cleanup::lock_ and we start - // invoking destructors, in the reverse order of creation. - for (int i = info_ix - 1; i >= 0; --i) - { - void *tss_info = 0; - - ACE_OS::thr_getspecific (info_arr[i].key_, &tss_info); - - if (tss_info != 0) - { - // Only call the destructor if the value is non-zero for this - // thread. - (*info_arr[i].destructor_)(tss_info); - } - } - - // Acquire the ACE_TSS_CLEANUP_LOCK, then free TLS keys and remove - // entries from ACE_TSS_Info table. - { - ACE_TSS_CLEANUP_GUARD - -# if 0 - // We shouldn't free the key and remove it from the table here - // because if we do and some thread ends before other threads - // even get started (or their TSS object haven't been created yet,) - // it's entry will be removed from the table and we are in big chaos. - // For TSS object, these have been done in ACE_TSS_Cleanup::detach. - // Two other use cases will be user managed TSS'es and system wide - // TSS, ones are users responsibilities and the others should be - // persistant system wide. - for (int i = 0; i < index; i++) - { -# if defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - // Calling thr_keyfree here ensure the key - // gets removed appropriately. Notice that - // a key should be removed before freeing it. - ACE_OS::thr_keyfree (key_info->key_); -# else - // don't bother to free the key - this->remove (key_info->key_); -# endif /* ACE_WIN32 */ - } -# endif /* 0 */ - } -} - -int -ACE_TSS_Cleanup::free_all_keys_left (void) - // This is called from ACE_OS::cleanup_tss (). When this gets - // called, all threads should have exited except the main thread. - // No key should be freed from this routine. It there's any, - // something might be wrong. -{ - ACE_thread_key_t key_arr[ACE_DEFAULT_THREAD_KEYS]; - ACE_TSS_TABLE_ITERATOR key_info = table_; - unsigned int idx = 0; - unsigned int i; - - for (i = 0; - i < ACE_DEFAULT_THREAD_KEYS; - ++key_info, ++i) -#if defined (ACE_HAS_TSS_EMULATION) - if (key_info->key_ != in_use_key_) -#endif /* ACE_HAS_TSS_EMULATION */ - // Don't call ACE_OS::thr_keyfree () on ACE_TSS_Cleanup's own - // key. See the comments in ACE_OS::thr_key_detach (): the key - // doesn't get detached, so it will be in the table here. - // However, there's no resource associated with it, so we don't - // need to keyfree it. The dynamic memory associated with it - // was already deleted by ACE_TSS_Cleanup::exit (), so we don't - // want to access it again. - key_arr [idx++] = key_info->key_; - - for (i = 0; i < idx; i++) - if (key_arr[i] != ACE_OS::NULL_key) -#if defined (ACE_HAS_TSS_EMULATION) - ACE_OS::thr_keyfree (key_arr[i]); -#elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - // Don't call ACE_OS::thr_keyfree here. It will try to use - // <in_use_> which has already been cleaned up here. - ::tsd_delete (key_arr[i]); -#else /* ACE_WIN32 */ - // Don't call ACE_OS::thr_keyfree here. It will try to use - // <in_use_> which has already been cleaned up here. - TlsFree (key_arr[i]); -#endif /* ACE_HAS_TSS_EMULATION */ - - return 0; -} - -extern "C" void -ACE_TSS_Cleanup_keys_destroyer (void *tss_keys) -{ - delete ACE_reinterpret_cast (ACE_TSS_Keys *, tss_keys); -} - -ACE_TSS_Cleanup::ACE_TSS_Cleanup (void) - : in_use_ (ACE_OS::NULL_key) -#if defined (ACE_HAS_TSS_EMULATION) - // ACE_TSS_Emulation::total_keys () provides the value of the next - // key to be created. - , in_use_key_ (ACE_TSS_Emulation::total_keys ()) -#endif /* ACE_HAS_TSS_EMULATION */ -{ - ACE_OS_TRACE ("ACE_TSS_Cleanup::ACE_TSS_Cleanup"); -} - -ACE_TSS_Cleanup * -ACE_TSS_Cleanup::instance (void) -{ - ACE_OS_TRACE ("ACE_TSS_Cleanup::instance"); - - // Create and initialize thread-specific key. - if (ACE_TSS_Cleanup::instance_ == 0) - { - // Insure that we are serialized! - ACE_TSS_CLEANUP_GUARD - - // Now, use the Double-Checked Locking pattern to make sure we - // only create the ACE_TSS_Cleanup instance once. - if (ACE_TSS_Cleanup::instance_ == 0) - ACE_NEW_RETURN (ACE_TSS_Cleanup::instance_, - ACE_TSS_Cleanup, - 0); - } - - return ACE_TSS_Cleanup::instance_; -} - -int -ACE_TSS_Cleanup::insert (ACE_thread_key_t key, - void (*destructor)(void *), - void *inst) -{ - ACE_OS_TRACE ("ACE_TSS_Cleanup::insert"); - ACE_TSS_CLEANUP_GUARD - - ACE_KEY_INDEX (key_index, key); - if (key_index < ACE_DEFAULT_THREAD_KEYS) - { - table_[key_index] = ACE_TSS_Info (key, destructor, inst); - return 0; - } - else - { - return -1; - } -} - -int -ACE_TSS_Cleanup::remove (ACE_thread_key_t key) -{ - ACE_OS_TRACE ("ACE_TSS_Cleanup::remove"); - ACE_TSS_CLEANUP_GUARD - - ACE_KEY_INDEX (key_index, key); - if (key_index < ACE_DEFAULT_THREAD_KEYS) - { - // "Remove" the TSS_Info table entry by zeroing out its key_ and - // destructor_ fields. Also, keep track of the number threads - // using the key. - ACE_TSS_Info &info = this->table_ [key_index]; - - // Don't bother to test/clear the in "use bit" if the program is - // shutting down. Doing so will cause a new ACE_TSS object to be - // created again. - if (!ACE_OS_Object_Manager::shutting_down ()) - tss_keys ()->test_and_clear (info.key_); - info.key_in_use (0); - info.key_ = ACE_OS::NULL_key; - info.destructor_ = 0; - return 0; - } - else - return -1; -} - -int -ACE_TSS_Cleanup::detach (void *inst) -{ - ACE_TSS_CLEANUP_GUARD - - ACE_TSS_TABLE_ITERATOR key_info = table_; - int success = 0; - int ref_cnt = 0; - - // Mark the key as detached in the TSS_Info table. - // It only works for the first key that "inst" owns. - // I don't know why. - for (unsigned int i = 0; - i < ACE_DEFAULT_THREAD_KEYS; - ++key_info, ++i) - { - if (key_info->tss_obj_ == inst) - { - key_info->tss_obj_ = 0; - ref_cnt = --key_info->thread_count_; - success = 1; - break; - } - } - - if (success == 0) - return -1; - else if (ref_cnt == 0) - { - // Mark the key as no longer being used. - key_info->key_in_use (0); -# if defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - ACE_thread_key_t temp_key = key_info->key_; -# endif /* ACE_WIN32 */ - int retv = this->remove (key_info->key_); - -# if defined (ACE_WIN32) - ::TlsFree (temp_key); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - ::tsd_delete (temp_key); -# endif /* ACE_WIN32 */ - return retv; - } - - return 0; -} - -void -ACE_TSS_Cleanup::key_used (ACE_thread_key_t key) -{ - // If the key's ACE_TSS_Info in-use bit for this thread is not set, - // set it and increment the key's thread_count_. - if (! tss_keys ()->test_and_set (key)) - { - ACE_TSS_CLEANUP_GUARD - - // Retrieve the key's ACE_TSS_Info and increment its thread_count_. - ACE_KEY_INDEX (key_index, key); - ACE_TSS_Info &key_info = this->table_ [key_index]; - if (!key_info.key_in_use ()) - key_info.key_in_use (1); - else - ++key_info.thread_count_; - } -} - -void -ACE_TSS_Cleanup::dump (void) -{ -#if defined (ACE_HAS_DUMP) - // Iterate through all the thread-specific items and dump them all. - - ACE_TSS_TABLE_ITERATOR key_info = table_; - for (unsigned int i = 0; - i < ACE_DEFAULT_THREAD_KEYS; - ++key_info, ++i) - key_info->dump (); -#endif /* ACE_HAS_DUMP */ -} - -ACE_TSS_Keys * -ACE_TSS_Cleanup::tss_keys () -{ - if (in_use_ == ACE_OS::NULL_key) - { - ACE_TSS_CLEANUP_GUARD - // Double-check; - if (in_use_ == ACE_OS::NULL_key) - { - // Initialize in_use_ with a new key. - if (ACE_OS::thr_keycreate (&in_use_, - &ACE_TSS_Cleanup_keys_destroyer)) - return 0; // Major problems, this should *never* happen! - } - } - - ACE_TSS_Keys *ts_keys = 0; - if (ACE_OS::thr_getspecific (in_use_, - ACE_reinterpret_cast (void **, &ts_keys)) == -1) - return 0; // This should not happen! - - if (ts_keys == 0) - { - ACE_NEW_RETURN (ts_keys, - ACE_TSS_Keys, - 0); - // Store the dynamically allocated pointer in thread-specific - // storage. - if (ACE_OS::thr_setspecific (in_use_, - ACE_reinterpret_cast (void *, - ts_keys)) == -1) - { - delete ts_keys; - return 0; // Major problems, this should *never* happen! - } - } - - return ts_keys; -} - -# if defined (ACE_HAS_TSS_EMULATION) -u_int ACE_TSS_Emulation::total_keys_ = 0; - -ACE_TSS_Keys ACE_TSS_Emulation::tss_keys_used_; - -ACE_TSS_Emulation::ACE_TSS_DESTRUCTOR -ACE_TSS_Emulation::tss_destructor_[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX] - = { 0 }; - -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - -int ACE_TSS_Emulation::key_created_ = 0; - -ACE_OS_thread_key_t ACE_TSS_Emulation::native_tss_key_; - -/* static */ -# if defined (ACE_HAS_THR_C_FUNC) -extern "C" -void -ACE_TSS_Emulation_cleanup (void *ptr) -{ - ACE_UNUSED_ARG (ptr); - // Really this must be used for ACE_TSS_Emulation code to make the TSS - // cleanup -} -#else -void -ACE_TSS_Emulation_cleanup (void *ptr) -{ - ACE_UNUSED_ARG (ptr); - // Really this must be used for ACE_TSS_Emulation code to make the TSS - // cleanup -} -# endif /* ACE_HAS_THR_C_FUNC */ - -void ** -ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created) -{ - // TSS Singleton implementation. - - // Create the one native TSS key, if necessary. - if (key_created_ == 0) - { - // Double-checked lock . . . - ACE_TSS_BASE_GUARD - - if (key_created_ == 0) - { - ACE_NO_HEAP_CHECK; - if (ACE_OS::thr_keycreate (&native_tss_key_, - &ACE_TSS_Emulation_cleanup) != 0) - { - return 0; // Major problems, this should *never* happen! - } - key_created_ = 1; - } - } - - void **old_ts_storage = 0; - - // Get the tss_storage from thread-OS specific storage. - if (ACE_OS::thr_getspecific (native_tss_key_, - (void **) &old_ts_storage) == -1) - return 0; // This should not happen! - - // Check to see if this is the first time in for this thread. - // This block can also be entered after a fork () in the child process, - // at least on Pthreads Draft 4 platforms. - if (old_ts_storage == 0) - { - if (ts_created) - *ts_created = 1u; - - // Use the ts_storage passed as argument, if non-zero. It is - // possible that this has been implemented in the stack. At the - // moment, this is unknown. The cleanup must not do nothing. - // If ts_storage is zero, allocate (and eventually leak) the - // storage array. - if (ts_storage == 0) - { - ACE_NO_HEAP_CHECK; - - ACE_NEW_RETURN (ts_storage, - void*[ACE_TSS_THREAD_KEYS_MAX], - 0); - - // Zero the entire TSS array. Do it manually instead of - // using memset, for optimum speed. Though, memset may be - // faster :-) - void **tss_base_p = ts_storage; - - for (u_int i = 0; - i < ACE_TSS_THREAD_KEYS_MAX; - ++i) - *tss_base_p++ = 0; - } - - // Store the pointer in thread-specific storage. It gets - // deleted via the ACE_TSS_Emulation_cleanup function when the - // thread terminates. - if (ACE_OS::thr_setspecific (native_tss_key_, - (void *) ts_storage) != 0) - return 0; // Major problems, this should *never* happen! - } - else - if (ts_created) - ts_created = 0; - - return ts_storage ? ts_storage : old_ts_storage; -} -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ - -u_int -ACE_TSS_Emulation::total_keys () -{ - ACE_OS_Recursive_Thread_Mutex_Guard ( - *ACE_static_cast (ACE_recursive_thread_mutex_t *, - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); - - return total_keys_; -} - -int -ACE_TSS_Emulation::next_key (ACE_thread_key_t &key) -{ - ACE_OS_Recursive_Thread_Mutex_Guard ( - *ACE_static_cast (ACE_recursive_thread_mutex_t *, - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); - - if (total_keys_ < ACE_TSS_THREAD_KEYS_MAX) - { - u_int counter = 0; - // Loop through all possible keys and check whether a key is free - for ( ;counter < ACE_TSS_THREAD_KEYS_MAX; counter++) - { - ACE_thread_key_t localkey; -# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T) - ACE_OS::memset (&localkey, 0, sizeof (ACE_thread_key_t)); - ACE_OS::memcpy (&localkey, &counter_, sizeof (u_int)); -# else - localkey = counter; -# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ - // If the key is not set as used, we can give out this key, if not - // we have to search further - if (tss_keys_used_.is_set(localkey) == 0) - { - tss_keys_used_.test_and_set(localkey); - key = localkey; - break; - } - } - - ++total_keys_; - return 0; - } - else - { - key = ACE_OS::NULL_key; - return -1; - } -} - -int -ACE_TSS_Emulation::release_key (ACE_thread_key_t key) -{ - ACE_OS_Recursive_Thread_Mutex_Guard ( - *ACE_static_cast (ACE_recursive_thread_mutex_t *, - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); - - if (tss_keys_used_.test_and_clear (key) == 0) - { - --total_keys_; - return 0; - } - return 1; -} - -void * -ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]) -{ -# if defined (ACE_PSOS) - u_long tss_base; - - // Use the supplied array for this thread's TSS. - tss_base = (u_long) ts_storage; - t_setreg (0, PSOS_TASK_REG_TSS, tss_base); - - // Zero the entire TSS array. - void **tss_base_p = ts_storage; - for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) - { - *tss_base_p = 0; - } - - return (void *) tss_base; -# else /* ! ACE_PSOS */ -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - // On VxWorks, in particular, don't check to see if the field - // is 0. It isn't always, specifically, when a program is run - // directly by the shell (without spawning a new task) after - // another program has been run. - - u_int ts_created = 0; - tss_base (ts_storage, &ts_created); - if (ts_created) - { -# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ - tss_base () = ts_storage; -# endif - - // Zero the entire TSS array. Do it manually instead of using - // memset, for optimum speed. Though, memset may be faster :-) - void **tss_base_p = tss_base (); - for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) - { - *tss_base_p = 0; - } - - return tss_base (); -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - } - else - { - return 0; - } -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ -# endif /* ! ACE_PSOS */ -} - -void -ACE_TSS_Emulation::tss_close () -{ -#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - // Free native_tss_key_ here. -#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ -} - -# endif /* ACE_HAS_TSS_EMULATION */ - -#endif /* WIN32 || ACE_HAS_TSS_EMULATION */ - -void -ACE_OS::cleanup_tss (const u_int main_thread) -{ -#if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - // Call TSS destructors for current thread. - ACE_TSS_Cleanup::instance ()->exit (0); -#endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 || ACE_PSOS_HAS_TSS */ - - if (main_thread) - { -#if !defined (ACE_HAS_TSS_EMULATION) && !defined (ACE_HAS_MINIMAL_ACE_OS) - // Just close the ACE_Log_Msg for the current (which should be - // main) thread. We don't have TSS emulation; if there's native - // TSS, it should call its destructors when the main thread - // exits. - ACE_Base_Thread_Adapter::close_log_msg (); -#endif /* ! ACE_HAS_TSS_EMULATION && ! ACE_HAS_MINIMAL_ACE_OS */ - -#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) -#if ! defined (ACE_HAS_TSS_EMULATION) - // Don't do this with TSS_Emulation, because the the - // ACE_TSS_Cleanup::instance () has already exited (). We can't - // safely access the TSS values that were created by the main - // thread. - - // Remove all TSS_Info table entries. - ACE_TSS_Cleanup::instance ()->free_all_keys_left (); -#endif /* ! ACE_HAS_TSS_EMULATION */ - - // Finally, free up the ACE_TSS_Cleanup instance. This method gets - // called by the ACE_Object_Manager. - delete ACE_TSS_Cleanup::instance (); -#endif /* WIN32 || ACE_HAS_TSS_EMULATION || ACE_PSOS_HAS_TSS */ - -#if defined (ACE_HAS_TSS_EMULATION) - ACE_TSS_Emulation::tss_close (); -#endif /* ACE_HAS_TSS_EMULATION */ - } -} - -#if !defined(ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) -#define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ - (*THR_ID = ::_beginthreadex ((void(_Optlink*)(void*))ENTRY_POINT, STACK, STACKSIZE, ARGS), *THR_ID) -#elif defined(ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) - -struct __IBMCPP__thread_params { - __IBMCPP__thread_params(ACE_THR_C_FUNC e, LPVOID a) - :entry_point(e),args(a) {} - ACE_THR_C_FUNC entry_point; - LPVOID args; -}; - -#pragma handler(initThread) -extern "C" DWORD __stdcall __IBMCPP__initThread(void *arg) -{ - // Must reset 387 since using CreateThread - _fpreset(); - - // Dispatch user function... - auto_ptr<__IBMCPP__thread_params> parms((__IBMCPP__thread_params *)arg); - (*parms->entry_point)(parms->args); - _endthread(); - return 0; -} - -HANDLE WINAPI __IBMCPP__beginthreadex(void *stack, - DWORD stacksize, - ACE_THR_C_FUNC entry_point, - LPVOID args, - DWORD flags, - LPDWORD thr_id) -{ - return CreateThread(0, - stacksize, - (LPTHREAD_START_ROUTINE)__IBMCPP__initThread, - new __IBMCPP__thread_params(entry_point, args), - flags, - thr_id); -} - -#define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ - __IBMCPP__beginthreadex(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) - -#elif defined (ACE_HAS_WINCE) && defined (UNDER_CE) && (UNDER_CE >= 211) -#define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ - CreateThread (0, STACKSIZE, (unsigned long (__stdcall *) (void *)) ENTRY_POINT, ARGS, (FLAGS) & CREATE_SUSPENDED, (unsigned long *) THR_ID) -#elif defined(ACE_HAS_WTHREADS) - // Green Hills compiler gets confused when __stdcall is imbedded in - // parameter list, so we define the type ACE_WIN32THRFUNC_T and use it - // instead. - typedef unsigned (__stdcall *ACE_WIN32THRFUNC_T)(void*); -#define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ - ::_beginthreadex (STACK, STACKSIZE, (ACE_WIN32THRFUNC_T) ENTRY_POINT, ARGS, FLAGS, (unsigned int *) THR_ID) -#endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */ - -#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) -int ACE_SEH_Default_Exception_Selector (void *) -{ -#if 0 - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%t) Win32 structured exception exiting thread\n"))); -#endif /* 0 */ - return (DWORD) ACE_SEH_DEFAULT_EXCEPTION_HANDLING_ACTION; -} - -int ACE_SEH_Default_Exception_Handler (void *) -{ - return 0; -} -#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - -extern "C" void -ace_cleanup_destroyer (ACE_Cleanup *object, void *param) -{ - object->cleanup (param); -} - -int -ACE_OS::thr_create (ACE_THR_FUNC func, - void *args, - long flags, - ACE_thread_t *thr_id, - ACE_hthread_t *thr_handle, - long priority, - void *stack, - size_t stacksize, - ACE_Base_Thread_Adapter *thread_adapter) -{ - ACE_OS_TRACE ("ACE_OS::thr_create"); - - if (ACE_BIT_DISABLED (flags, THR_DETACHED) && - ACE_BIT_DISABLED (flags, THR_JOINABLE)) - ACE_SET_BITS (flags, THR_JOINABLE); - -# if defined (ACE_NO_THREAD_ADAPTER) -# define ACE_THREAD_FUNCTION func -# define ACE_THREAD_ARGUMENT args -# else /* ! defined (ACE_NO_THREAD_ADAPTER) */ -# if defined (ACE_PSOS) -# define ACE_THREAD_FUNCTION (PSOS_TASK_ENTRY_POINT) thread_args->entry_point () -# else -# define ACE_THREAD_FUNCTION thread_args->entry_point () -# endif /* defined (ACE_PSOS) */ -# define ACE_THREAD_ARGUMENT thread_args -# endif /* ! defined (ACE_NO_THREAD_ADAPTER) */ - - - ACE_Base_Thread_Adapter *thread_args; - if (thread_adapter == 0) - -# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) - ACE_NEW_RETURN (thread_args, - ACE_OS_Thread_Adapter (func, args, - (ACE_THR_C_FUNC) ace_thread_adapter, - ACE_OS_Object_Manager::seh_except_selector(), - ACE_OS_Object_Manager::seh_except_handler()), - -1); -# else - ACE_NEW_RETURN (thread_args, - ACE_OS_Thread_Adapter (func, args, - (ACE_THR_C_FUNC) ace_thread_adapter), - -1); - -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - else - thread_args = thread_adapter; - -# if defined (ACE_HAS_THREADS) - - // *** Set Stack Size -# if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) - if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE) - stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE; -# endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ - -# if !defined (VXWORKS) - // On VxWorks, the OS will provide a task name if the user doesn't. - // So, we don't need to create a tmp_thr. If the caller of this - // member function is the Thread_Manager, than thr_id will be non-zero - // anyways. - ACE_thread_t tmp_thr; - - if (thr_id == 0) - thr_id = &tmp_thr; -# endif /* ! VXWORKS */ - - ACE_hthread_t tmp_handle; - if (thr_handle == 0) - thr_handle = &tmp_handle; - -# if defined (ACE_HAS_PTHREADS) - - int result; - pthread_attr_t attr; -# if defined (ACE_HAS_PTHREADS_DRAFT4) - if (::pthread_attr_create (&attr) != 0) -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - if (::pthread_attr_init (&attr) != 0) -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - -# if defined (CHORUS) - // If it is a super actor, we can't set stacksize. But for the time - // being we are all non-super actors. Should be fixed to take care - // of super actors!!! - if (stacksize == 0) - stacksize = ACE_CHORUS_DEFAULT_MIN_STACK_SIZE; - else if (stacksize < ACE_CHORUS_DEFAULT_MIN_STACK_SIZE) - stacksize = ACE_CHORUS_DEFAULT_MIN_STACK_SIZE; -# endif /*CHORUS */ - -# if defined (ACE_HAS_PTHREAD_SETSTACK) - if ((stacksize != 0) && (stack != 0)) -# else - if (stacksize != 0) -# endif /* ACE_HAS_PTHREAD_SETSTACK */ - { - size_t size = stacksize; - -# if defined (PTHREAD_STACK_MIN) - if (size < ACE_static_cast (size_t, PTHREAD_STACK_MIN)) - size = PTHREAD_STACK_MIN; -# endif /* PTHREAD_STACK_MIN */ - -# if !defined (ACE_LACKS_THREAD_STACK_SIZE) // JCEJ 12/17/96 -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - if (::pthread_attr_setstacksize (&attr, size) != 0) -# else -# if defined (ACE_HAS_PTHREAD_SETSTACK) - if (ACE_ADAPT_RETVAL(pthread_attr_setstack (&attr, stack, size), result) == -1) -# else - if (ACE_ADAPT_RETVAL(pthread_attr_setstacksize (&attr, size), result) == -1) -# endif /* ACE_HAS_PTHREAD_SETSTACK */ -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } -# else - ACE_UNUSED_ARG (size); -# endif /* !ACE_LACKS_THREAD_STACK_SIZE */ - } - - // *** Set Stack Address -# if !defined (ACE_HAS_PTHREAD_SETSTACK) -# if !defined (ACE_LACKS_THREAD_STACK_ADDR) - if (stack != 0) - { - if (::pthread_attr_setstackaddr (&attr, stack) != 0) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } - } -# else - ACE_UNUSED_ARG (stack); -# endif /* !ACE_LACKS_THREAD_STACK_ADDR */ -# endif /* ACE_HAS_PTHREAD_SETSTACK */ - - // *** Deal with various attributes - if (flags != 0) - { - // *** Set Detach state -# if !defined (ACE_LACKS_SETDETACH) - if (ACE_BIT_ENABLED (flags, THR_DETACHED) - || ACE_BIT_ENABLED (flags, THR_JOINABLE)) - { - int dstate = PTHREAD_CREATE_JOINABLE; - - if (ACE_BIT_ENABLED (flags, THR_DETACHED)) - dstate = PTHREAD_CREATE_DETACHED; - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - if (::pthread_attr_setdetach_np (&attr, dstate) != 0) -# else /* ACE_HAS_PTHREADS_DRAFT4 */ -# if defined (ACE_HAS_PTHREADS_DRAFT6) - if (::pthread_attr_setdetachstate (&attr, &dstate) != 0) -# else - if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate), - result) != 0) -# endif /* ACE_HAS_PTHREADS_DRAFT6 */ -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } - } - - // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we - // call ::pthread_detach () below. If THR_DETACHED is not - // enabled, we call ::pthread_detach () in the Thread_Manager, - // after joining with the thread. -# endif /* ACE_LACKS_SETDETACH */ - - // *** Set Policy -# if !defined (ACE_LACKS_SETSCHED) - // If we wish to set the priority explicitly, we have to enable - // explicit scheduling, and a policy, too. - if (priority != ACE_DEFAULT_THREAD_PRIORITY) - { - ACE_SET_BITS (flags, THR_EXPLICIT_SCHED); - if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO) - && ACE_BIT_DISABLED (flags, THR_SCHED_RR) - && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT)) - ACE_SET_BITS (flags, THR_SCHED_DEFAULT); - } - - if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) - || ACE_BIT_ENABLED (flags, THR_SCHED_RR) - || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) - { - int spolicy; - -# if defined (ACE_HAS_ONLY_SCHED_OTHER) - // SunOS, thru version 5.6, only supports SCHED_OTHER. - spolicy = SCHED_OTHER; -# else - // Make sure to enable explicit scheduling, in case we didn't - // enable it above (for non-default priority). - ACE_SET_BITS (flags, THR_EXPLICIT_SCHED); - - if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) - spolicy = SCHED_OTHER; - else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) - spolicy = SCHED_FIFO; -# if defined (SCHED_IO) - else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO)) - spolicy = SCHED_IO; -# else - else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO)) - { - errno = ENOSYS; - return -1; - } -# endif /* SCHED_IO */ - else - spolicy = SCHED_RR; - -# if defined (ACE_HAS_FSU_PTHREADS) - int ret; - switch (spolicy) - { - case SCHED_FIFO: - case SCHED_RR: - ret = 0; - break; - default: - ret = 22; - break; - } - if (ret != 0) - { - ::pthread_attr_destroy (&attr); - return -1; - } -# endif /* ACE_HAS_FSU_PTHREADS */ - -# endif /* ACE_HAS_ONLY_SCHED_OTHER */ - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - result = ::pthread_attr_setsched (&attr, spolicy); -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - result = ::pthread_attr_setschedpolicy (&attr, spolicy); -# else /* draft 7 or std */ - ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy), - result); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - if (result != 0) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } - } - - // *** Set Priority (use reasonable default priorities) -# if defined(ACE_HAS_PTHREADS_STD) - // If we wish to explicitly set a scheduling policy, we also - // have to specify a priority. We choose a "middle" priority as - // default. Maybe this is also necessary on other POSIX'ish - // implementations? - if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) - || ACE_BIT_ENABLED (flags, THR_SCHED_RR) - || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) - && priority == ACE_DEFAULT_THREAD_PRIORITY) - { - if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) - priority = ACE_THR_PRI_FIFO_DEF; - else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR)) - priority = ACE_THR_PRI_RR_DEF; - else // THR_SCHED_DEFAULT - priority = ACE_THR_PRI_OTHER_DEF; - } -# endif /* ACE_HAS_PTHREADS_STD */ - if (priority != ACE_DEFAULT_THREAD_PRIORITY) - { - struct sched_param sparam; - ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); - -# if defined (ACE_HAS_IRIX62_THREADS) - sparam.sched_priority = ACE_MIN (priority, - (long) PTHREAD_MAX_PRIORITY); -# elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS_STD) - /* For MIT pthreads... */ - sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY); -# elif defined(ACE_HAS_PTHREADS_STD) && !defined (ACE_HAS_STHREADS) - // The following code forces priority into range. - if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) - sparam.sched_priority = - ACE_MIN (ACE_THR_PRI_FIFO_MAX, - ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority)); - else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR)) - sparam.sched_priority = - ACE_MIN (ACE_THR_PRI_RR_MAX, - ACE_MAX (ACE_THR_PRI_RR_MIN, priority)); - else // Default policy, whether set or not - sparam.sched_priority = - ACE_MIN (ACE_THR_PRI_OTHER_MAX, - ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority)); -# elif defined (PRIORITY_MAX) - sparam.sched_priority = ACE_MIN (priority, - (long) PRIORITY_MAX); -# else - sparam.sched_priority = priority; -# endif /* ACE_HAS_IRIX62_THREADS */ - -# if defined (ACE_HAS_FSU_PTHREADS) - if (sparam.sched_priority >= PTHREAD_MIN_PRIORITY - && sparam.sched_priority <= PTHREAD_MAX_PRIORITY) - attr.prio = sparam.sched_priority; - else - { - pthread_attr_destroy (&attr); - errno = EINVAL; - return -1; - } -# else - { -# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER) - // SunOS, through 5.6, POSIX only allows priorities > 0 to - // ::pthread_attr_setschedparam. If a priority of 0 was - // requested, set the thread priority after creating it, below. - if (priority > 0) -# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */ - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - result = ::pthread_attr_setprio (&attr, - sparam.sched_priority); -# else /* this is draft 7 or std */ - ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam), - result); -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ - if (result != 0) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } - } - } -# endif /* ACE_HAS_FSU_PTHREADS */ - } - - // *** Set scheduling explicit or inherited - if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED) - || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED)) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - int sched = PTHREAD_DEFAULT_SCHED; -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - int sched = PTHREAD_EXPLICIT_SCHED; -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)) - sched = PTHREAD_INHERIT_SCHED; - if (::pthread_attr_setinheritsched (&attr, sched) != 0) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } - } -# else /* ACE_LACKS_SETSCHED */ - ACE_UNUSED_ARG (priority); -# endif /* ACE_LACKS_SETSCHED */ - - // *** Set Scope -# if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING) - if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM) - || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS)) - { -# if defined (ACE_CONFIG_LINUX_H) || defined (HPUX) - // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS. - // Neither does HPUX (up to HP-UX 11.00, as far as I know). - int scope = PTHREAD_SCOPE_SYSTEM; -# else /* ACE_CONFIG_LINUX_H */ - int scope = PTHREAD_SCOPE_PROCESS; -# endif /* ACE_CONFIG_LINUX_H */ - if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)) - scope = PTHREAD_SCOPE_SYSTEM; - - if (::pthread_attr_setscope (&attr, scope) != 0) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_attr_delete (&attr); -# else /* ACE_HAS_PTHREADS_DRAFT4 */ - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - return -1; - } - } -# endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */ - - if (ACE_BIT_ENABLED (flags, THR_NEW_LWP)) - { - // Increment the number of LWPs by one to emulate the - // SunOS semantics. - int lwps = ACE_OS::thr_getconcurrency (); - if (lwps == -1) - { - if (errno == ENOTSUP) - // Suppress the ENOTSUP because it's harmless. - errno = 0; - else - // This should never happen on SunOS: - // ::thr_getconcurrency () should always succeed. - return -1; - } - else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1) - { - if (errno == ENOTSUP) - { - // Unlikely: ::thr_getconcurrency () is supported but - // ::thr_setconcurrency () is not? - } - else - return -1; - } - } - } - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ACE_OSCALL (::pthread_create (thr_id, attr, - thread_args->entry_point (), - thread_args), - int, -1, result); - -# if defined (ACE_LACKS_SETDETACH) - if (ACE_BIT_ENABLED (flags, THR_DETACHED)) - { -# if defined (HPUX_10) - // HP-UX DCE threads' pthread_detach will smash thr_id if it's - // just given as an argument. This will cause - // ACE_Thread_Manager (if it's doing this create) to lose track - // of the new thread since the ID will be passed back equal to - // 0. So give pthread_detach a junker to scribble on. - ACE_thread_t junker; - cma_handle_assign(thr_id, &junker); - ::pthread_detach (&junker); -# else - ::pthread_detach (thr_id); -# endif /* HPUX_10 */ - } -# endif /* ACE_LACKS_SETDETACH */ - - ::pthread_attr_delete (&attr); - -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL (::pthread_create (thr_id, &attr, - thread_args->entry_point (), - thread_args), - int, -1, result); - ::pthread_attr_destroy (&attr); - -# else /* this is draft 7 or std */ - ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id, - &attr, - thread_args->entry_point (), - thread_args), - result), - int, -1, result); - ::pthread_attr_destroy (&attr); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - - // This is a SunOS or POSIX implementation of pthreads, where we - // assume that ACE_thread_t and ACE_hthread_t are the same. If this - // *isn't* correct on some platform, please let us know. - if (result != -1) - *thr_handle = *thr_id; - -# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER) - // SunOS prior to 5.7: - - // If the priority is 0, then we might have to set it now because we - // couldn't set it with ::pthread_attr_setschedparam, as noted - // above. This doesn't provide strictly correct behavior, because - // the thread was created (above) with the priority of its parent. - // (That applies regardless of the inherit_sched attribute: if it - // was PTHREAD_INHERIT_SCHED, then it certainly inherited its - // parent's priority. If it was PTHREAD_EXPLICIT_SCHED, then "attr" - // was initialized by the SunOS ::pthread_attr_init () to contain - // NULL for the priority, which indicated to SunOS ::pthread_create - // () to inherit the parent priority.) - if (priority == 0) - { - // Check the priority of this thread, which is the parent - // of the newly created thread. If it is 0, then the - // newly created thread will have inherited the priority - // of 0, so there's no need to explicitly set it. - struct sched_param sparam; - int policy = 0; - ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (), - &policy, - &sparam), - result), int, - -1, result); - - // The only policy supported by by SunOS, thru version 5.6, - // is SCHED_OTHER, so that's hard-coded here. - policy = ACE_SCHED_OTHER; - - if (sparam.sched_priority != 0) - { - ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); - // The memset to 0 sets the priority to 0, so we don't need - // to explicitly set sparam.sched_priority. - - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id, - policy, - &sparam), - result), - int, -1); - } - } - -# if defined (ACE_NEEDS_LWP_PRIO_SET) -# if 0 - // It would be useful if we could make this work. But, it requires - // a mechanism for determining the ID of an LWP to which another - // thread is bound. Is there a way to do that? Instead, just rely - // on the code in ACE_Thread_Adapter::invoke () to set the LWP - // priority. - - // If the thread is bound, then set the priority on its LWP. - if (ACE_BIT_ENABLED (flags, THR_BOUND)) - { - ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) || - ACE_BIT_ENABLED (flags, THR_SCHED_RR) ? - ACE_SCHED_FIFO : - ACE_SCHED_OTHER, - priority); - result = ACE_OS::lwp_setparams (sched_params, - /* ? How do we find the ID of the LWP - to which *thr_id is bound? */); - } -# endif /* 0 */ -# endif /* ACE_NEEDS_LWP_PRIO_SET */ - -# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */ - return result; -# elif defined (ACE_HAS_STHREADS) - int result; - int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED); - - if (priority != ACE_DEFAULT_THREAD_PRIORITY) - // If we need to set the priority, then we need to start the - // thread in a suspended mode. - ACE_SET_BITS (flags, THR_SUSPENDED); - - ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize, - thread_args->entry_point (), - thread_args, - flags, thr_id), result), - int, -1, result); - - if (result != -1) - { - // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same. - *thr_handle = *thr_id; - - if (priority != ACE_DEFAULT_THREAD_PRIORITY) - { - // Set the priority of the new thread and then let it - // continue, but only if the user didn't start it suspended - // in the first place! - if ((result = ACE_OS::thr_setprio (*thr_id, priority)) != 0) - { - errno = result; - return -1; - } - - if (start_suspended == 0) - { - if ((result = ACE_OS::thr_continue (*thr_id)) != 0) - { - errno = result; - return -1; - } - } - } - } - return result; -# elif defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (stack); -# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) - if (ACE_BIT_ENABLED (flags, THR_USE_AFX)) - { - CWinThread *cwin_thread = - ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (), - thread_args, - priority, - 0, - flags | THR_SUSPENDED); - // Have to duplicate the handle because - // CWinThread::~CWinThread() closes the original handle. -# if !defined (ACE_HAS_WINCE) - (void) ::DuplicateHandle (::GetCurrentProcess (), - cwin_thread->m_hThread, - ::GetCurrentProcess (), - thr_handle, - 0, - TRUE, - DUPLICATE_SAME_ACCESS); -# endif /* ! ACE_HAS_WINCE */ - *thr_id = cwin_thread->m_nThreadID; - - if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0) - cwin_thread->ResumeThread (); - // cwin_thread will be deleted in AfxThreadExit() - // Warning: If AfxThreadExit() is called from within the - // thread, ACE_TSS_Cleanup->exit() never gets called ! - } - else -# endif /* ACE_HAS_MFC */ - { - int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED); - - if (priority != ACE_DEFAULT_THREAD_PRIORITY) - // If we need to set the priority, then we need to start the - // thread in a suspended mode. - ACE_SET_BITS (flags, THR_SUSPENDED); - - *thr_handle = (void *) ACE_BEGINTHREADEX (0, - ACE_static_cast - (u_int, stacksize), - thread_args->entry_point (), - thread_args, - flags, - thr_id); - - if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0) - { - // Set the priority of the new thread and then let it - // continue, but only if the user didn't start it suspended - // in the first place! - ACE_OS::thr_setprio (*thr_handle, priority); - - if (start_suspended == 0) - ACE_OS::thr_continue (*thr_handle); - } - } -# if 0 - *thr_handle = ::CreateThread - (0, - stacksize, - LPTHREAD_START_ROUTINE (thread_args->entry_point ()), - thread_args, - flags, - thr_id); -# endif /* 0 */ - - // Close down the handle if no one wants to use it. - if (thr_handle == &tmp_handle) - ::CloseHandle (tmp_handle); - - if (*thr_handle != 0) - return 0; - else - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ - -# elif defined (ACE_PSOS) - - // stack is created in the task's memory region 0 - ACE_UNUSED_ARG (stack); - - // task creation and start flags are fixed - ACE_UNUSED_ARG (flags); - - // lowest priority is reserved for the IDLE pSOS+ system daemon, - // highest are reserved for high priority pSOS+ system daemons - if (priority < PSOS_TASK_MIN_PRIORITY) - { - priority = PSOS_TASK_MIN_PRIORITY; - } - else if (priority > PSOS_TASK_MAX_PRIORITY) - { - priority = PSOS_TASK_MAX_PRIORITY; - } - - // set the stacksize to a default value if no size is specified - if (stacksize == 0) - stacksize = ACE_PSOS_DEFAULT_STACK_SIZE; - - ACE_hthread_t tid; - *thr_handle = 0; - - // create the thread - if (t_create ((char *) thr_id, // task name - priority, // (possibly adjusted) task priority - stacksize, // passed stack size is used for supervisor stack - 0, // no user stack: tasks run strictly in supervisor mode - T_LOCAL, // local to the pSOS+ node (does not support pSOS+m) - &tid) // receives task id - != 0) - { - return -1; - } - - // pSOS tasks are passed an array of 4 u_longs - u_long targs[4]; - targs[0] = (u_long) ACE_THREAD_ARGUMENT; - targs[1] = 0; - targs[2] = 0; - targs[3] = 0; - - // start the thread - if (t_start (tid, - T_PREEMPT | // Task can be preempted - // T_NOTSLICE | // Task is not timesliced with other tasks at same priority - T_TSLICE | // Task is timesliced with other tasks at same priority - T_NOASR | // Task level signals disabled - T_SUPV | // Task runs strictly in supervisor mode - T_ISR, // Hardware interrupts are enabled - ACE_THREAD_FUNCTION, // Task entry point - targs) // Task argument(s) - != 0) - { - return -1; - } - - // store the task id in the handle and return success - *thr_handle = tid; - return 0; - -# elif defined (VXWORKS) - // The hard-coded values below are what ::sp () would use. (::sp () - // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to - // 20,000.) stacksize should be an even integer. If a stack is not - // specified, ::taskSpawn () is used so that we can set the - // priority, flags, and stacksize. If a stack is specified, - // ::taskInit ()/::taskActivate() are used. - - // If called with thr_create() defaults, use same default values as ::sp (): - if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100; - // Assumes that there is a floating point coprocessor. As noted - // above, ::sp () hardcodes this, so we should be safe with it. - if (flags == 0) flags = VX_FP_TASK; - if (stacksize == 0) stacksize = 20000; - - const u_int thr_id_provided = - thr_id && *thr_id && (*thr_id)[0] != ACE_THR_ID_ALLOCATED; - - ACE_hthread_t tid; -# if 0 /* Don't support setting of stack, because it doesn't seem to work. */ - if (stack == 0) - { -# else - ACE_UNUSED_ARG (stack); -# endif /* 0 */ - // The call below to ::taskSpawn () causes VxWorks to assign a - // unique task name of the form: "t" + an integer, because the - // first argument is 0. - tid = ::taskSpawn (thr_id_provided ? *thr_id : 0, - priority, - (int) flags, - (int) stacksize, - thread_args->entry_point (), - (int) thread_args, - 0, 0, 0, 0, 0, 0, 0, 0, 0); -# if 0 /* Don't support setting of stack, because it doesn't seem to work. */ - } - else - { - // If a task name (thr_id) was not supplied, then the task will - // not have a unique name. That's VxWorks' behavior. - - // Carve out a TCB at the beginning of the stack space. The TCB - // occupies 400 bytes with VxWorks 5.3.1/I386. - WIND_TCB *tcb = (WIND_TCB *) stack; - - // The TID is defined to be the address of the TCB. - int status = ::taskInit (tcb, - thr_id_provided ? *thr_id : 0, - priority, - (int) flags, - (char *) stack + sizeof (WIND_TCB), - (int) (stacksize - sizeof (WIND_TCB)), - thread_args->entry_point (), - (int) thread_args, - 0, 0, 0, 0, 0, 0, 0, 0, 0); - - if (status == OK) - { - // The task was successfully initialized, now activate it. - status = ::taskActivate ((ACE_hthread_t) tcb); - } - - tid = status == OK ? (ACE_hthread_t) tcb : ERROR; - } -# endif /* 0 */ - - if (tid == ERROR) - return -1; - else - { - if (! thr_id_provided && thr_id) - { - if (*thr_id && (*thr_id)[0] == ACE_THR_ID_ALLOCATED) - // *thr_id was allocated by the Thread_Manager. ::taskTcb - // (int tid) returns the address of the WIND_TCB (task - // control block). According to the ::taskSpawn() - // documentation, the name of the new task is stored at - // pStackBase, but is that of the current task? If so, it - // might be a bit quicker than this extraction of the tcb - // . . . - ACE_OS::strsncpy (*thr_id + 1, ::taskTcb (tid)->name, 10); - else - // *thr_id was not allocated by the Thread_Manager. - // Pass back the task name in the location pointed to - // by thr_id. - *thr_id = ::taskTcb (tid)->name; - } - // else if the thr_id was provided, there's no need to overwrite - // it with the same value (string). If thr_id is 0, then we can't - // pass the task name back. - - if (thr_handle) - *thr_handle = tid; - - return 0; - } - -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (func); - ACE_UNUSED_ARG (args); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (thr_handle); - ACE_UNUSED_ARG (priority); - ACE_UNUSED_ARG (stack); - ACE_UNUSED_ARG (stacksize); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -void -ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status) -{ - ACE_OS_TRACE ("ACE_OS::thr_exit"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - ::pthread_exit (status); -# elif defined (ACE_HAS_STHREADS) - ::thr_exit (status); -# elif defined (ACE_HAS_WTHREADS) - // Can't call it here because on NT, the thread is exited - // directly by ACE_Thread_Adapter::invoke (). - // ACE_TSS_Cleanup::instance ()->exit (status); - -# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) - int using_afx = -1; - // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor. - // But without #including ace/Thread_Manager.h, we don't know that. - ACE_OS_Thread_Descriptor *td = - ACE_Base_Thread_Adapter::thr_desc_log_msg (); - if (td) - using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX); -# endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */ - - // Call TSS destructors. - ACE_OS::cleanup_tss (0 /* not main thread */); - - // Exit the thread. - // Allow CWinThread-destructor to be invoked from AfxEndThread. - // _endthreadex will be called from AfxEndThread so don't exit the - // thread now if we are running an MFC thread. -# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) - if (using_afx != -1) - { - if (using_afx) - ::AfxEndThread (status); - else - ACE_ENDTHREADEX (status); - } - else - { - // Not spawned by ACE_Thread_Manager, use the old buggy - // version. You should seriously consider using - // ACE_Thread_Manager to spawn threads. The following code is - // know to cause some problem. - CWinThread *pThread = ::AfxGetThread (); - if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ()) - ACE_ENDTHREADEX (status); - else - ::AfxEndThread (status); - } -# else - ACE_ENDTHREADEX (status); -# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/ - -# elif defined (VXWORKS) - ACE_hthread_t tid; - ACE_OS::thr_self (tid); - *((int *) status) = ::taskDelete (tid); -# elif defined (ACE_PSOS) - ACE_hthread_t tid; - ACE_OS::thr_self (tid); - -# if defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - // Call TSS destructors. - ACE_OS::cleanup_tss (0 /* not main thread */); -# endif /* ACE_PSOS && ACE_PSOS_HAS_TSS */ - - *((u_long *) status) = ::t_delete (tid); -# endif /* ACE_HAS_PTHREADS */ -# else - ACE_UNUSED_ARG (status); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::lwp_getparams (ACE_Sched_Params &sched_params) -{ -# if defined (ACE_HAS_STHREADS) || defined (sun) - // Get the class TS and RT class IDs. - ACE_id_t rt_id; - ACE_id_t ts_id; - if (ACE_OS::scheduling_class ("RT", rt_id) == -1 - || ACE_OS::scheduling_class ("TS", ts_id) == -1) - return -1; - - // Get this LWP's scheduling parameters. - pcparms_t pcparms; - // The following is just to avoid Purify warnings about unitialized - // memory reads. - ACE_OS::memset (&pcparms, 0, sizeof pcparms); - pcparms.pc_cid = PC_CLNULL; - - if (ACE_OS::priority_control (P_LWPID, - P_MYID, - PC_GETPARMS, - (char *) &pcparms) == -1) - return -1; - else if (pcparms.pc_cid == rt_id) - { - // RT class. - rtparms_t rtparms; - ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms); - - sched_params.policy (ACE_SCHED_FIFO); - sched_params.priority (rtparms.rt_pri); - sched_params.scope (ACE_SCOPE_THREAD); - ACE_Time_Value quantum (rtparms.rt_tqsecs, - rtparms.rt_tqnsecs == RT_TQINF - ? 0 : rtparms.rt_tqnsecs * 1000); - sched_params.quantum (quantum); - return 0; - } - else if (pcparms.pc_cid == ts_id) - { - /* TS class */ - tsparms_t tsparms; - ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms); - - sched_params.policy (ACE_SCHED_OTHER); - sched_params.priority (tsparms.ts_upri); - sched_params.scope (ACE_SCOPE_THREAD); - return 0; - } - else - return -1; - -# else /* ! ACE_HAS_STHREADS && ! sun */ - ACE_UNUSED_ARG (sched_params); - ACE_NOTSUP_RETURN (-1); -# endif /* ! ACE_HAS_STHREADS && ! sun */ -} - -int -ACE_OS::lwp_setparams (const ACE_Sched_Params &sched_params) -{ -# if defined (ACE_HAS_STHREADS) || defined (sun) - ACE_Sched_Params lwp_params (sched_params); - lwp_params.scope (ACE_SCOPE_LWP); - return ACE_OS::sched_params (lwp_params); -# else /* ! ACE_HAS_STHREADS && ! sun */ - ACE_UNUSED_ARG (sched_params); - ACE_NOTSUP_RETURN (-1); -# endif /* ! ACE_HAS_STHREADS && ! sun */ -} - -# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) -int -ACE_OS::thr_setspecific (ACE_OS_thread_key_t key, void *data) -{ - // ACE_OS_TRACE ("ACE_OS::thr_setspecific"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_FSU_PTHREADS) - // Call pthread_init() here to initialize threads package. FSU - // threads need an initialization before the first thread constructor. - // This seems to be the one; however, a segmentation fault may - // indicate that another pthread_init() is necessary, perhaps in - // Synch.cpp or Synch_T.cpp. FSU threads will not reinit if called - // more than once, so another call to pthread_init will not adversely - // affect existing threads. - pthread_init (); -# endif /* ACE_HAS_FSU_PTHREADS */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setspecific (key, data), ace_result_), int, -1); -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setspecific (key, data), ace_result_), int, -1); -# elif defined (ACE_HAS_WTHREADS) - ::TlsSetValue (key, data); - return 0; -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (data); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ - -int -ACE_OS::thr_setspecific (ACE_thread_key_t key, void *data) -{ - // ACE_OS_TRACE ("ACE_OS::thr_setspecific"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_TSS_EMULATION) - ACE_KEY_INDEX (key_index, key); - - if (key_index >= ACE_TSS_Emulation::total_keys ()) - { - errno = EINVAL; - data = 0; - return -1; - } - else - { - ACE_TSS_Emulation::ts_object (key) = data; - ACE_TSS_Cleanup::instance ()->key_used (key); - - return 0; - } -# elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_FSU_PTHREADS) - // Call pthread_init() here to initialize threads package. FSU - // threads need an initialization before the first thread constructor. - // This seems to be the one; however, a segmentation fault may - // indicate that another pthread_init() is necessary, perhaps in - // Synch.cpp or Synch_T.cpp. FSU threads will not reinit if called - // more than once, so another call to pthread_init will not adversely - // affect existing threads. - pthread_init (); -# endif /* ACE_HAS_FSU_PTHREADS */ - -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_setspecific (key, data), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setspecific (key, data), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ - -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setspecific (key, data), ace_result_), int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - ACE_hthread_t tid; - ACE_OS::thr_self (tid); - if (::tsd_setval (key, tid, data) != 0) - return -1; - ACE_TSS_Cleanup::instance ()->key_used (key); - return 0; -# elif defined (ACE_HAS_WTHREADS) - ::TlsSetValue (key, data); - ACE_TSS_Cleanup::instance ()->key_used (key); - return 0; -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (data); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (data); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::thr_keyfree (ACE_thread_key_t key) -{ - ACE_OS_TRACE ("ACE_OS::thr_keyfree"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_TSS_EMULATION) - // Release the key in the TSS_Emulation administration - ACE_TSS_Emulation::release_key (key); - return ACE_TSS_Cleanup::instance ()->remove (key); -# elif defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_UNUSED_ARG (key); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_PTHREADS) - return ::pthread_key_delete (key); -# elif defined (ACE_HAS_THR_KEYDELETE) - return ::thr_keydelete (key); -# elif defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (key); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WTHREADS) - // Extract out the thread-specific table instance and free up - // the key and destructor. - ACE_TSS_Cleanup::instance ()->remove (key); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::TlsFree (key), ace_result_), int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - // Extract out the thread-specific table instance and free up - // the key and destructor. - ACE_TSS_Cleanup::instance ()->remove (key); - return (::tsd_delete (key) == 0) ? 0 : -1; -# else - ACE_UNUSED_ARG (key); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_TSS_EMULATION */ -# else - ACE_UNUSED_ARG (key); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) -int -ACE_OS::thr_keycreate (ACE_OS_thread_key_t *key, -# if defined (ACE_HAS_THR_C_DEST) - ACE_THR_C_DEST dest, -# else - ACE_THR_DEST dest, -# endif /* ACE_HAS_THR_C_DEST */ - void *inst) -{ - // ACE_OS_TRACE ("ACE_OS::thr_keycreate"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (inst); - - -# if defined (ACE_HAS_PTHREADS_DRAFT4) -# if defined (ACE_HAS_STDARG_THR_DEST) - ACE_OSCALL_RETURN (::pthread_keycreate (key, (void (*)(...)) dest), int, -1); -# else /* ! ACE_HAS_STDARG_THR_DEST */ - ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1); -# endif /* ! ACE_HAS_STDARG_THR_DEST */ -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_key_create (key, dest), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ -# elif defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (inst); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_keycreate (key, dest), - ace_result_), - int, -1); -# elif defined (ACE_HAS_WTHREADS) - *key = ::TlsAlloc (); - - if (*key != ACE_SYSCALL_FAILED) - { - // Extract out the thread-specific table instance and stash away - // the key and destructor so that we can free it up later on... - return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); - } - else - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (dest); - ACE_UNUSED_ARG (inst); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ - -int -ACE_OS::thr_keycreate (ACE_thread_key_t *key, -# if defined (ACE_HAS_THR_C_DEST) - ACE_THR_C_DEST dest, -# else - ACE_THR_DEST dest, -# endif /* ACE_HAS_THR_C_DEST */ - void *inst) -{ - // ACE_OS_TRACE ("ACE_OS::thr_keycreate"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_TSS_EMULATION) - if (ACE_TSS_Emulation::next_key (*key) == 0) - { - ACE_TSS_Emulation::tss_destructor (*key, dest); - - // Extract out the thread-specific table instance and stash away - // the key and destructor so that we can free it up later on... - return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); - } - else - { - errno = EAGAIN; - return -1; - } -# elif defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (inst); - -# if defined (ACE_HAS_PTHREADS_DRAFT4) -# if defined (ACE_HAS_STDARG_THR_DEST) - ACE_OSCALL_RETURN (::pthread_keycreate (key, (void (*)(...)) dest), int, -1); -# else /* ! ACE_HAS_STDARG_THR_DEST */ - ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1); -# endif /* ! ACE_HAS_STDARG_THR_DEST */ -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_key_create (key, dest), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - -# elif defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (inst); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_keycreate (key, dest), - ace_result_), - int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - - static u_long unique_name = 0; - void *tsdanchor; - - ++unique_name; - if (::tsd_create (ACE_reinterpret_cast (char *, &unique_name), - 0, - TSD_NOALLOC, - (void ****) &tsdanchor, - key) != 0) - { - return -1; - } - - return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); -# elif defined (ACE_HAS_WTHREADS) - *key = ::TlsAlloc (); - - if (*key != ACE_SYSCALL_FAILED) - { - // Extract out the thread-specific table instance and stash away - // the key and destructor so that we can free it up later on... - return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); - } - else - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (dest); - ACE_UNUSED_ARG (inst); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_TSS_EMULATION */ -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (dest); - ACE_UNUSED_ARG (inst); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::thr_key_used (ACE_thread_key_t key) -{ -# if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - ACE_TSS_Cleanup::instance ()->key_used (key); - return 0; -# else - ACE_UNUSED_ARG (key); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION || ACE_PSOS_HAS_TSS */ -} - -int -ACE_OS::thr_key_detach (void *inst) -{ -# if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) - if (ACE_TSS_Cleanup::lockable ()) - return ACE_TSS_Cleanup::instance()->detach (inst); - else - // We're in static constructor/destructor phase. Don't - // try to use the ACE_TSS_Cleanup instance because its lock - // might not have been constructed yet, or might have been - // destroyed already. Just leak the key . . . - return -1; -# else - ACE_UNUSED_ARG (inst); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */ -} - -void -ACE_OS::unique_name (const void *object, - ACE_TCHAR *name, - size_t length) -{ - // The process ID will provide uniqueness between processes on the - // same machine. The "this" pointer of the <object> will provide - // uniqueness between other "live" objects in the same process. The - // uniqueness of this name is therefore only valid for the life of - // <object>. - ACE_TCHAR temp_name[ACE_UNIQUE_NAME_LEN]; - ACE_OS::sprintf (temp_name, - ACE_LIB_TEXT ("%p%d"), - object, - ACE_static_cast (int, ACE_OS::getpid ())); - ACE_OS::strsncpy (name, - temp_name, - length); -} - -int -ACE_OS::argv_to_string (ACE_TCHAR **argv, - ACE_TCHAR *&buf, - int substitute_env_args) -{ - if (argv == 0 || argv[0] == 0) - return 0; - - size_t buf_len = 0; - - // Determine the length of the buffer. - - for (int i = 0; argv[i] != 0; i++) - { - ACE_TCHAR *temp = 0; - -#if !defined (ACE_LACKS_ENV) - // Account for environment variables. - if (substitute_env_args - && (argv[i][0] == '$' - && (temp = ACE_OS::getenv (&argv[i][1])) != 0)) - buf_len += ACE_OS_String::strlen (temp); - else -#endif /* ACE_LACKS_ENV */ - buf_len += ACE_OS_String::strlen (argv[i]); - - // Add one for the extra space between each string. - buf_len++; - } - - // Step through all argv params and copy each one into buf; separate - // each param with white space. - - ACE_NEW_RETURN (buf, - ACE_TCHAR[buf_len + 1], - 0); - - // Initial null charater to make it a null string. - buf[0] = '\0'; - ACE_TCHAR *end = buf; - int j; - - for (j = 0; argv[j] != 0; j++) - { - ACE_TCHAR *temp = 0; - -# if !defined (ACE_LACKS_ENV) - // Account for environment variables. - if (substitute_env_args - && (argv[j][0] == '$' - && (temp = ACE_OS::getenv (&argv[j][1])) != 0)) - end = ACE_OS::strecpy (end, temp); - else -#endif /* ACE_LACKS_ENV */ - end = ACE_OS::strecpy (end, argv[j]); - - // Replace the null char that strecpy put there with white - // space. - end[-1] = ' '; - } - - // Null terminate the string. - *end = '\0'; - // The number of arguments. - return j; -} - -int -ACE_OS::string_to_argv (ACE_TCHAR *buf, - int &argc, - ACE_TCHAR **&argv, - int substitute_env_args) -{ - // Reset the number of arguments - argc = 0; - - if (buf == 0) - return -1; - - ACE_TCHAR *cp = buf; - - // First pass: count arguments. - - // '#' is the start-comment token.. - while (*cp != ACE_LIB_TEXT ('\0') && *cp != ACE_LIB_TEXT ('#')) - { - // Skip whitespace.. - while (ACE_OS::ace_isspace (*cp)) - cp++; - - // Increment count and move to next whitespace.. - if (*cp != ACE_LIB_TEXT ('\0')) - argc++; - - while (*cp != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*cp)) - { - // Grok quotes.... - if (*cp == ACE_LIB_TEXT ('\'') || *cp == ACE_LIB_TEXT ('"')) - { - ACE_TCHAR quote = *cp; - - // Scan past the string.. - for (cp++; *cp != ACE_LIB_TEXT ('\0') && *cp != quote; cp++) - continue; - - // '\0' implies unmatched quote.. - if (*cp == ACE_LIB_TEXT ('\0')) - { - argc--; - break; - } - else - cp++; - } - else - cp++; - } - } - - // Second pass: copy arguments. - ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ]; - ACE_TCHAR *argp = arg; - - // Make sure that the buffer we're copying into is always large - // enough. - if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ) - ACE_NEW_RETURN (argp, - ACE_TCHAR[cp - buf + 1], - -1); - - // Make a new argv vector of argc + 1 elements. - ACE_NEW_RETURN (argv, - ACE_TCHAR *[argc + 1], - -1); - - ACE_TCHAR *ptr = buf; - - for (int i = 0; i < argc; i++) - { - // Skip whitespace.. - while (ACE_OS::ace_isspace (*ptr)) - ptr++; - - // Copy next argument and move to next whitespace.. - cp = argp; - while (*ptr != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr)) - if (*ptr == ACE_LIB_TEXT ('\'') || *ptr == ACE_LIB_TEXT ('"')) - { - ACE_TCHAR quote = *ptr++; - - while (*ptr != ACE_LIB_TEXT ('\0') && *ptr != quote) - *cp++ = *ptr++; - - if (*ptr == quote) - ptr++; - } - else - *cp++ = *ptr++; - - *cp = ACE_LIB_TEXT ('\0'); - -#if !defined (ACE_LACKS_ENV) - // Check for environment variable substitution here. - if (substitute_env_args) { - argv[i] = ACE_OS::strenvdup(argp); - - if (argv[i] == 0) - { - if (argp != arg) - delete [] argp; - errno = ENOMEM; - return -1; - } - } - else -#endif /* ACE_LACKS_ENV */ - { - argv[i] = ACE_OS::strdup(argp); - - if (argv[i] == 0) - { - if (argp != arg) - delete [] argp; - errno = ENOMEM; - return -1; - } - } - } - - if (argp != arg) - delete [] argp; - - argv[argc] = 0; - return 0; -} - -// Create a contiguous command-line argument buffer with each arg -// separated by spaces. - -pid_t -ACE_OS::fork_exec (ACE_TCHAR *argv[]) -{ -# if defined (ACE_WIN32) - ACE_TCHAR *buf; - - if (ACE_OS::argv_to_string (argv, buf) != -1) - { - PROCESS_INFORMATION process_info; -# if !defined (ACE_HAS_WINCE) - ACE_TEXT_STARTUPINFO startup_info; - ACE_OS::memset ((void *) &startup_info, - 0, - sizeof startup_info); - startup_info.cb = sizeof startup_info; - - if (ACE_TEXT_CreateProcess (0, - buf, - 0, // No process attributes. - 0, // No thread attributes. - TRUE, // Allow handle inheritance. - 0, // Don't create a new console window. - 0, // No environment. - 0, // No current directory. - &startup_info, - &process_info)) -# else - if (ACE_TEXT_CreateProcess (0, - buf, - 0, // No process attributes. - 0, // No thread attributes. - FALSE, // Can's inherit handles on CE - 0, // Don't create a new console window. - 0, // No environment. - 0, // No current directory. - 0, // Can't use startup info on CE - &process_info)) -# endif /* ! ACE_HAS_WINCE */ - { - // Free resources allocated in kernel. - ACE_OS::close (process_info.hThread); - ACE_OS::close (process_info.hProcess); - // Return new process id. - delete [] buf; - return process_info.dwProcessId; - } - } - - // CreateProcess failed. - return -1; -# elif defined (CHORUS) - return ACE_OS::execv (argv[0], argv); -# else - pid_t result = ACE_OS::fork (); - - switch (result) - { - case -1: - // Error. - return -1; - case 0: - // Child process. - if (ACE_OS::execv (argv[0], argv) == -1) - { - // The OS layer should not print stuff out - // ACE_ERROR ((LM_ERROR, - // "%p Exec failed\n")); - - // If the execv fails, this child needs to exit. - ACE_OS::exit (errno); - } - default: - // Server process. The fork succeeded. - return result; - } -# endif /* ACE_WIN32 */ -} - -ssize_t -ACE_OS::read_n (ACE_HANDLE handle, - void *buf, - size_t len, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - n = ACE_OS::read (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred); - - if (n == -1 || n == 0) - return n; - } - return bytes_transferred; -} - -// Write <len> bytes from <buf> to <handle> (uses the <write> -// system call on UNIX and the <WriteFile> call on Win32). - -ssize_t -ACE_OS::write_n (ACE_HANDLE handle, - const void *buf, - size_t len, - size_t *bt) -{ - size_t temp; - size_t &bytes_transferred = bt == 0 ? temp : *bt; - ssize_t n; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - n = ACE_OS::write (handle, - (char *) buf + bytes_transferred, - len - bytes_transferred); - - if (n == -1 || n == 0) - return n; - } - - return bytes_transferred; -} - -# if defined (ACE_LACKS_WRITEV) - -// "Fake" writev for operating systems without it. Note that this is -// thread-safe. - -int -ACE_OS::writev_emulation (ACE_HANDLE handle, ACE_WRITEV_TYPE iov[], int n) -{ - ACE_OS_TRACE ("ACE_OS::writev_emulation"); - - size_t length = 0; - int i; - - // Determine the total length of all the buffers in <iov>. - for (i = 0; i < n; i++) - if (ACE_static_cast (int, iov[i].iov_len) < 0) - return -1; - else - length += iov[i].iov_len; - - char *buf; - -# if defined (ACE_HAS_ALLOCA) - buf = (char *) alloca (length); -# else - ACE_NEW_RETURN (buf, - char[length], - -1); -# endif /* !defined (ACE_HAS_ALLOCA) */ - - char *ptr = buf; - - for (i = 0; i < n; i++) - { - ACE_OS::memcpy (ptr, iov[i].iov_base, iov[i].iov_len); - ptr += iov[i].iov_len; - } - - ssize_t result = ACE_OS::write (handle, buf, length); -# if !defined (ACE_HAS_ALLOCA) - delete [] buf; -# endif /* !defined (ACE_HAS_ALLOCA) */ - return result; -} -# endif /* ACE_LACKS_WRITEV */ - -# if defined (ACE_LACKS_READV) - -// "Fake" readv for operating systems without it. Note that this is -// thread-safe. - -ssize_t -ACE_OS::readv_emulation (ACE_HANDLE handle, - ACE_READV_TYPE *iov, - int n) -{ - ACE_OS_TRACE ("ACE_OS::readv_emulation"); - - ssize_t length = 0; - int i; - - for (i = 0; i < n; i++) - if (ACE_static_cast (int, iov[i].iov_len) < 0) - return -1; - else - length += iov[i].iov_len; - - char *buf; -# if defined (ACE_HAS_ALLOCA) - buf = (char *) alloca (length); -# else - ACE_NEW_RETURN (buf, - char[length], - -1); -# endif /* !defined (ACE_HAS_ALLOCA) */ - - length = ACE_OS::read (handle, buf, length); - - if (length != -1) - { - char *ptr = buf; - ssize_t copyn = length; - - for (i = 0; - i < n && copyn > 0; - i++) - { - ACE_OS::memcpy (iov[i].iov_base, ptr, - // iov_len is int on some platforms, size_t on others - copyn > (int) iov[i].iov_len - ? (size_t) iov[i].iov_len - : (size_t) copyn); - ptr += iov[i].iov_len; - copyn -= iov[i].iov_len; - } - } - -# if !defined (ACE_HAS_ALLOCA) - delete [] buf; -# endif /* !defined (ACE_HAS_ALLOCA) */ - return length; -} -# endif /* ACE_LACKS_READV */ - -# if defined (ACE_NEEDS_FTRUNCATE) -extern "C" int -ftruncate (ACE_HANDLE handle, long len) -{ - struct flock fl; - fl.l_whence = 0; - fl.l_len = 0; - fl.l_start = len; - fl.l_type = F_WRLCK; - - return ACE_OS::fcntl (handle, F_FREESP, ACE_reinterpret_cast (long, &fl)); -} -# endif /* ACE_NEEDS_FTRUNCATE */ - -# if defined (ACE_LACKS_MKTEMP) -ACE_TCHAR * -ACE_OS::mktemp (ACE_TCHAR *s) -{ - ACE_OS_TRACE ("ACE_OS::mktemp"); - if (s == 0) - // check for null template string failed! - return 0; - else - { - ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_LIB_TEXT ("XXXXXX")); - - if (xxxxxx == 0) - // the template string doesn't contain "XXXXXX"! - return s; - else - { - ACE_TCHAR unique_letter = ACE_LIB_TEXT ('a'); - ACE_stat sb; - - // Find an unused filename for this process. It is assumed - // that the user will open the file immediately after - // getting this filename back (so, yes, there is a race - // condition if multiple threads in a process use the same - // template). This appears to match the behavior of the - // SunOS 5.5 mktemp(). - ACE_OS::sprintf (xxxxxx, - ACE_LIB_TEXT ("%05d%c"), - ACE_OS::getpid (), - unique_letter); - while (ACE_OS::stat (s, &sb) >= 0) - { - if (++unique_letter <= ACE_LIB_TEXT ('z')) - ACE_OS::sprintf (xxxxxx, - ACE_LIB_TEXT ("%05d%c"), - ACE_OS::getpid (), - unique_letter); - else - { - // maximum of 26 unique files per template, per process - ACE_OS::sprintf (xxxxxx, ACE_LIB_TEXT ("%s"), ACE_LIB_TEXT ("")); - return s; - } - } - } - return s; - } -} -# endif /* ACE_LACKS_MKTEMP */ - -int -ACE_OS::socket_init (int version_high, int version_low) -{ -# if defined (ACE_WIN32) - if (ACE_OS::socket_initialized_ == 0) - { - WORD version_requested = MAKEWORD (version_high, version_low); - WSADATA wsa_data; - int error = WSAStartup (version_requested, &wsa_data); - - if (error != 0) -# if defined (ACE_HAS_WINCE) - { - wchar_t fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d"); - wchar_t buf[80]; // @@ Eliminate magic number. - ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSAStartup"), error); - ::MessageBox (0, buf, ACE_LIB_TEXT ("WSAStartup failed!"), MB_OK); - } -# else - ACE_OS::fprintf (stderr, - "ACE_OS::socket_init; WSAStartup failed, " - "WSAGetLastError returned %d\n", - error); -# endif /* ACE_HAS_WINCE */ - - ACE_OS::socket_initialized_ = 1; - } -# else - ACE_UNUSED_ARG (version_high); - ACE_UNUSED_ARG (version_low); -# endif /* ACE_WIN32 */ - return 0; -} - -int -ACE_OS::socket_fini (void) -{ -# if defined (ACE_WIN32) - if (ACE_OS::socket_initialized_ != 0) - { - if (WSACleanup () != 0) - { - int error = ::WSAGetLastError (); -# if defined (ACE_HAS_WINCE) - wchar_t fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d"); - wchar_t buf[80]; // @@ Eliminate magic number. - ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSACleanup"), error); - ::MessageBox (0, buf , ACE_LIB_TEXT ("WSACleanup failed!"), MB_OK); -# else - ACE_OS::fprintf (stderr, - "ACE_OS::socket_fini; WSACleanup failed, " - "WSAGetLastError returned %d\n", - error); -# endif /* ACE_HAS_WINCE */ - } - ACE_OS::socket_initialized_ = 0; - } -# endif /* ACE_WIN32 */ - return 0; -} - -# if defined (ACE_LACKS_SYS_NERR) -# if defined (__rtems__) -int sys_nerr = EWOULDBLOCK + 1; // definitely a hack. -# else - int sys_nerr = ERRMAX + 1; -# endif /* __rtems__ */ -# endif /* ACE_LACKS_SYS_NERR */ - -# if defined (VXWORKS) -# include /**/ <usrLib.h> /* for ::sp() */ - -// This global function can be used from the VxWorks shell to pass -// arguments to a C main () function. -// -// usage: -> spa main, "arg1", "arg2" -// -// All arguments must be quoted, even numbers. -int -spa (FUNCPTR entry, ...) -{ - static const unsigned int MAX_ARGS = 10; - static char *argv[MAX_ARGS]; - va_list pvar; - unsigned int argc; - - // Hardcode a program name because the real one isn't available - // through the VxWorks shell. - argv[0] = "ace_main"; - - // Peel off arguments to spa () and put into argv. va_arg () isn't - // necessarily supposed to return 0 when done, though since the - // VxWorks shell uses a fixed number (10) of arguments, it might 0 - // the unused ones. This function could be used to increase that - // limit, but then it couldn't depend on the trailing 0. So, the - // number of arguments would have to be passed. - va_start (pvar, entry); - - for (argc = 1; argc <= MAX_ARGS; ++argc) - { - argv[argc] = va_arg (pvar, char *); - - if (argv[argc] == 0) - break; - } - - if (argc > MAX_ARGS && argv[argc-1] != 0) - { - // try to read another arg, and warn user if the limit was exceeded - if (va_arg (pvar, char *) != 0) - ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %d\n", - MAX_ARGS); - } - else - { - // fill unused argv slots with 0 to get rid of leftovers - // from previous invocations - for (unsigned int i = argc; i <= MAX_ARGS; ++i) - argv[i] = 0; - } - - // The hard-coded options are what ::sp () uses, except for the - // larger stack size (instead of ::sp ()'s 20000). - const int ret = ::taskSpawn (argv[0], // task name - 100, // task priority - VX_FP_TASK, // task options - ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size - entry, // entry point - argc, // first argument to main () - (int) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0, 0); - va_end (pvar); - - // ::taskSpawn () returns the taskID on success: return 0 instead if - // successful - return ret > 0 ? 0 : ret; -} - - - -// A helper function for the extended spa functions -static void -add_to_argv (int& argc, char** argv, int max_args, char* string) -{ - char indouble = 0; - size_t previous = 0; - size_t length = ACE_OS_String::strlen (string); - - // We use <= to make sure that we get the last argument - for (size_t i = 0; i <= length; i++) - { - // Is it a double quote that hasn't been escaped? - if (string[i] == '\"' && (i == 0 || string[i - 1] != '\\')) - { - indouble ^= 1; - if (indouble) - { - // We have just entered a double quoted string, so - // save the starting position of the contents. - previous = i + 1; - } - else - { - // We have just left a double quoted string, so - // zero out the ending double quote. - string[i] = '\0'; - } - } - else if (string[i] == '\\') // Escape the next character - { - // The next character is automatically - // skipped because of the strcpy - ACE_OS_String::strcpy (string + i, string + i + 1); - length--; - } - else if (!indouble && - (ACE_OS::ace_isspace (string[i]) || string[i] == '\0')) - { - string[i] = '\0'; - if (argc < max_args) - { - argv[argc] = string + previous; - argc++; - } - else - { - ACE_OS::fprintf (stderr, "spae(): number of arguments " - "limited to %d\n", max_args); - } - - // Skip over whitespace in between arguments - for(++i; i < length && ACE_OS::ace_isspace (string[i]); ++i) - { - } - - // Save the starting point for the next time around - previous = i; - - // Make sure we don't skip over a character due - // to the above loop to skip over whitespace - i--; - } - } -} - -// This global function can be used from the VxWorks shell to pass -// arguments to a C main () function. -// -// usage: -> spae main, "arg1 arg2 \"arg3 with spaces\"" -// -// All arguments must be within double quotes, even numbers. -int -spae (FUNCPTR entry, ...) -{ - static const int WINDSH_ARGS = 10; - static const int MAX_ARGS = 128; - static char* argv[MAX_ARGS] = { "ace_main", 0 }; - va_list pvar; - int argc = 1; - - // Peel off arguments to spa () and put into argv. va_arg () isn't - // necessarily supposed to return 0 when done, though since the - // VxWorks shell uses a fixed number (10) of arguments, it might 0 - // the unused ones. - va_start (pvar, entry); - - int i = 0; - for (char* str = va_arg (pvar, char*); - str != 0 && i < WINDSH_ARGS; str = va_arg (pvar, char*), ++i) - { - add_to_argv(argc, argv, MAX_ARGS, str); - } - - // fill unused argv slots with 0 to get rid of leftovers - // from previous invocations - for (i = argc; i < MAX_ARGS; ++i) - argv[i] = 0; - - // The hard-coded options are what ::sp () uses, except for the - // larger stack size (instead of ::sp ()'s 20000). - const int ret = ::taskSpawn (argv[0], // task name - 100, // task priority - VX_FP_TASK, // task options - ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size - entry, // entry point - argc, // first argument to main () - (int) argv, // second argument to main () - 0, 0, 0, 0, 0, 0, 0, 0); - va_end (pvar); - - // ::taskSpawn () returns the taskID on success: return 0 instead if - // successful - return ret > 0 ? 0 : ret; -} - - -// This global function can be used from the VxWorks shell to pass -// arguments to a C main () function. The function will be run -// within the shells task. -// -// usage: -> spaef main, "arg1 arg2 \"arg3 with spaces\"" -// -// All arguments must be within double quotes, even numbers. -// Unlike the spae function, this fuction executes the supplied -// routine in the foreground, rather than spawning it in a separate -// task. -int -spaef (FUNCPTR entry, ...) -{ - static const int WINDSH_ARGS = 10; - static const int MAX_ARGS = 128; - static char* argv[MAX_ARGS] = { "ace_main", 0 }; - va_list pvar; - int argc = 1; - - // Peel off arguments to spa () and put into argv. va_arg () isn't - // necessarily supposed to return 0 when done, though since the - // VxWorks shell uses a fixed number (10) of arguments, it might 0 - // the unused ones. - va_start (pvar, entry); - - int i = 0; - for (char* str = va_arg (pvar, char*); - str != 0 && i < WINDSH_ARGS; str = va_arg (pvar, char*), ++i) - { - add_to_argv(argc, argv, MAX_ARGS, str); - } - - // fill unused argv slots with 0 to get rid of leftovers - // from previous invocations - for (i = argc; i < MAX_ARGS; ++i) - argv[i] = 0; - - int ret = entry (argc, argv); - - va_end (pvar); - - // Return the return value of the invoked ace_main routine. - return ret; -} -# endif /* VXWORKS */ - -# if !defined (ACE_HAS_SIGINFO_T) -siginfo_t::siginfo_t (ACE_HANDLE handle) - : si_handle_ (handle), - si_handles_ (&handle) -{ -} - -siginfo_t::siginfo_t (ACE_HANDLE *handles) - : si_handle_ (handles[0]), - si_handles_ (handles) -{ -} -# endif /* ACE_HAS_SIGINFO_T */ - -pid_t -ACE_OS::fork (const ACE_TCHAR *program_name) -{ - ACE_OS_TRACE ("ACE_OS::fork"); -# if defined (ACE_LACKS_FORK) - ACE_UNUSED_ARG (program_name); - ACE_NOTSUP_RETURN (pid_t (-1)); -# else - pid_t pid = -# if defined (ACE_HAS_STHREADS) - ::fork1 (); -#else - ::fork (); -#endif /* ACE_HAS_STHREADS */ - -#if !defined (ACE_HAS_MINIMAL_ACE_OS) - if (pid == 0) - ACE_Base_Thread_Adapter::sync_log_msg (program_name); -#endif /* ! ACE_HAS_MINIMAL_ACE_OS */ - - return pid; -# endif /* ACE_WIN32 */ -} - -void -ACE_Cleanup::cleanup (void *) -{ - delete this; -} - - -ACE_Cleanup::~ACE_Cleanup (void) -{ -} - -// This is necessary to work around nasty problems with MVS C++. - -extern "C" void -ace_mutex_lock_cleanup_adapter (void *args) -{ - ACE_OS::mutex_lock_cleanup (args); -} - -ACE_Thread_ID::ACE_Thread_ID (ACE_thread_t thread_id, - ACE_hthread_t thread_handle) - : thread_id_ (thread_id), - thread_handle_ (thread_handle) -{ -} - -ACE_Thread_ID::ACE_Thread_ID (const ACE_Thread_ID &id) - : thread_id_ (id.thread_id_), - thread_handle_ (id.thread_handle_) -{ -} - -ACE_thread_t -ACE_Thread_ID::id (void) -{ - return this->thread_id_; -} - -void -ACE_Thread_ID::id (ACE_thread_t thread_id) -{ - this->thread_id_ = thread_id; -} - -ACE_hthread_t -ACE_Thread_ID::handle (void) -{ - return this->thread_handle_; -} - -void -ACE_Thread_ID::handle (ACE_hthread_t thread_handle) -{ - this->thread_handle_ = thread_handle; -} - -void -ACE_Thread_ID::to_string (char* thr_id) -{ - - char format[128]; // Converted format string - char *fp; // Current format pointer - fp = format; - *fp++ = '%'; // Copy in the % - -#if defined (ACE_WIN32) - ACE_OS::strcpy (fp, "u"); - ACE_OS::sprintf (thr_id, - format, - ACE_static_cast(unsigned, - ACE_OS::thr_self ())); -#elif defined (ACE_AIX_VERS) && (ACE_AIX_VERS <= 402) - // AIX's pthread_t (ACE_hthread_t) is a pointer, and it's - // a little ugly to send that through a %u format. So, - // get the kernel thread ID (tid_t) via thread_self() and - // display that instead. - // This isn't conditionalized on ACE_HAS_THREAD_SELF because - // 1. AIX 4.2 doesn't have that def anymore (it messes up - // other things) - // 2. OSF/1 V3.2 has that def, and I'm not sure what affect - // this would have on that. - // -Steve Huston, 19-Aug-97 - ACE_OS::strcpy (fp, "u"); - ACE_OS::sprintf (thr_id, format, thread_self()); -#elif defined (DIGITAL_UNIX) - ACE_OS::strcpy (fp, "u"); - ACE_OS::sprintf (thr_id, format, -# if defined (ACE_HAS_THREADS) - pthread_getselfseq_np () -# else - ACE_Thread::self () -# endif /* ACE_HAS_THREADS */ - ); -#else - ACE_hthread_t t_id; - ACE_OS::thr_self (t_id); - -# if defined (ACE_HAS_PTHREADS_DRAFT4) && defined (HPUX_10) - ACE_OS::strcpy (fp, "u"); - // HP-UX 10.x DCE's thread ID is a pointer. Grab the - // more meaningful, readable, thread ID. This will match - // the one seen in the debugger as well. - ACE_OS::sprintf (thr_id, format, - pthread_getunique_np(&t_id)); -# elif defined (ACE_MVS) - // MVS's pthread_t is a struct... yuck. So use the ACE 5.0 - // code for it. - ACE_OS::strcpy (fp, "u"); - ACE_OS::sprintf (thr_id, format, t_id); -# else - // Yes, this is an ugly C-style cast, but the correct - // C++ cast is different depending on whether the t_id - // is an integral type or a pointer type. FreeBSD uses - // a pointer type, but doesn't have a _np function to - // get an integral type, like the OSes above. - ACE_OS::strcpy (fp, "lu"); - ACE_OS::sprintf (thr_id, format, (unsigned long)t_id); -# endif /* ACE_HAS_PTHREADS_DRAFT4 && HPUX_10 */ - -#endif /* ACE_WIN32 */ -} - -int -ACE_Thread_ID::operator== (const ACE_Thread_ID &rhs) const -{ - return ACE_OS::thr_cmp (this->thread_handle_, rhs.thread_handle_) == 0 - && ACE_OS::thr_equal (this->thread_id_, rhs.thread_id_) == 0; -} - -int -ACE_Thread_ID::operator!= (const ACE_Thread_ID &rhs) const -{ - return !(*this == rhs); -} - -// All other platforms have this inlined in OS.i -#if defined (ACE_PSOS) -char * -ACE_OS::inet_ntoa (const struct in_addr addr) -{ - ACE_OS_TRACE ("ACE_OS::inet_ntoa"); - - static char addrstr[INET_ADDRSTRLEN + 1] = { 0 }; - ACE_UINT32 ipaddr = ntohl (addr.s_addr); - //printf("Socket address %X, IP address %X.\n",addr.s_addr,ipaddr); - sprintf(addrstr, "%d.%d.%d.%d", - ((ipaddr & 0xff000000) >> 24) & 0x000000ff, - (ipaddr & 0x00ff0000) >> 16, - (ipaddr & 0x0000ff00) >> 8, - (ipaddr & 0x000000ff)); - return addrstr; -} -#endif /* defined (ACE_PSOS) */ - -int -ACE_OS::inet_aton (const char *host_name, struct in_addr *addr) -{ -#if defined (ACE_LACKS_INET_ATON) - ACE_UINT32 ip_addr = ACE_OS::inet_addr (host_name); - - if (ip_addr == INADDR_NONE - // Broadcast addresses are weird... - && ACE_OS::strcmp (host_name, "255.255.255.255") != 0) - return 0; - else if (addr == 0) - return 0; - else - { - addr->s_addr = ip_addr; // Network byte ordered - return 1; - } -#elif defined (VXWORKS) - // inet_aton() returns OK (0) on success and ERROR (-1) on failure. - // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026 - ::errnoSet(0); - int result = ERROR; - ACE_OSCALL (::inet_aton ((char*)host_name, addr), int, ERROR, result); - return (result == ERROR) ? 0 : 1; -#else - // inet_aton() returns 0 upon failure, not -1 since -1 is a valid - // address (255.255.255.255). - ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0); -#endif /* ACE_LACKS_INET_ATON */ -} - -struct tm * -ACE_OS::localtime_r (const time_t *t, struct tm *res) -{ - ACE_OS_TRACE ("ACE_OS::localtime_r"); -#if defined (ACE_HAS_REENTRANT_FUNCTIONS) -# if defined (DIGITAL_UNIX) - ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0); -# elif defined (HPUX_10) - return (::localtime_r (t, res) == 0 ? res : (struct tm *)0); -# else - ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0); -# endif /* DIGITAL_UNIX */ -#elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - ACE_OS_GUARD - - ACE_UNUSED_ARG (res); - struct tm * res_ptr; - ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr); - if (res_ptr == 0) - return 0; - else - { - *res = *res_ptr; - return res; - } -#elif defined (ACE_HAS_WINCE) - // This is really stupid, converting FILETIME to timeval back and - // forth. It assumes FILETIME and DWORDLONG are the same structure - // internally. - - TIME_ZONE_INFORMATION pTz; - - const unsigned short int __mon_yday[2][13] = - { - /* Normal years. */ - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, - /* Leap years. */ - { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } - }; - - ULARGE_INTEGER _100ns; - ::GetTimeZoneInformation (&pTz); - - _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 + ACE_Time_Value::FILETIME_to_timval_skew; - FILETIME file_time; - file_time.dwLowDateTime = _100ns.LowPart; - file_time.dwHighDateTime = _100ns.HighPart; - - FILETIME localtime; - SYSTEMTIME systime; - FileTimeToLocalFileTime (&file_time, &localtime); - FileTimeToSystemTime (&localtime, &systime); - - res->tm_hour = systime.wHour; - - if(pTz.DaylightBias!=0) - res->tm_isdst = 1; - else - res->tm_isdst = 1; - - int iLeap; - iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0)); - // based on leap select which group to use - - res->tm_mday = systime.wDay; - res->tm_min = systime.wMinute; - res->tm_mon = systime.wMonth; - res->tm_sec = systime.wSecond; - res->tm_wday = systime.wDayOfWeek; - res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay; - res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900 - res->tm_year = res->tm_year - 1900; - - return res; -#else - // @@ Same as ACE_OS::localtime (), you need to implement it - // yourself. - ACE_UNUSED_ARG (t); - ACE_UNUSED_ARG (res); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -} - -ssize_t -ACE_OS::pread (ACE_HANDLE handle, - void *buf, - size_t nbytes, - off_t offset) -{ -# if defined (ACE_HAS_P_READ_WRITE) -# if defined (ACE_WIN32) - - ACE_OS_GUARD - - // Remember the original file pointer position - DWORD original_position = ::SetFilePointer (handle, - 0, - 0, - FILE_CURRENT); - - if (original_position == 0xFFFFFFFF) - return -1; - - // Go to the correct position - DWORD altered_position = ::SetFilePointer (handle, - offset, - 0, - FILE_BEGIN); - if (altered_position == 0xFFFFFFFF) - return -1; - - DWORD bytes_read; - -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) - - OVERLAPPED overlapped; - overlapped.Internal = 0; - overlapped.InternalHigh = 0; - overlapped.Offset = offset; - overlapped.OffsetHigh = 0; - overlapped.hEvent = 0; - - BOOL result = ::ReadFile (handle, - buf, - ACE_static_cast (DWORD, nbytes), - &bytes_read, - &overlapped); - - if (result == FALSE) - { - if (::GetLastError () != ERROR_IO_PENDING) - return -1; - - else - { - result = ::GetOverlappedResult (handle, - &overlapped, - &bytes_read, - TRUE); - if (result == FALSE) - return -1; - } - } - -# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - - BOOL result = ::ReadFile (handle, - buf, - nbytes, - &bytes_read, - 0); - if (result == FALSE) - return -1; - -# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - - // Reset the original file pointer position - if (::SetFilePointer (handle, - original_position, - 0, - FILE_BEGIN) == 0xFFFFFFFF) - return -1; - - return (ssize_t) bytes_read; - -# else /* ACE_WIN32 */ - - return ::pread (handle, buf, nbytes, offset); - -# endif /* ACE_WIN32 */ - -# else /* ACE_HAS_P_READ_WRITE */ - - ACE_OS_GUARD - - // Remember the original file pointer position - off_t original_position = ACE_OS::lseek (handle, - 0, - SEEK_CUR); - - if (original_position == -1) - return -1; - - // Go to the correct position - off_t altered_position = ACE_OS::lseek (handle, - offset, - SEEK_SET); - - if (altered_position == -1) - return -1; - - ssize_t bytes_read = ACE_OS::read (handle, - buf, - nbytes); - - if (bytes_read == -1) - return -1; - - if (ACE_OS::lseek (handle, - original_position, - SEEK_SET) == -1) - return -1; - - return bytes_read; - -# endif /* ACE_HAD_P_READ_WRITE */ -} - -ssize_t -ACE_OS::pwrite (ACE_HANDLE handle, - const void *buf, - size_t nbytes, - off_t offset) -{ -# if defined (ACE_HAS_P_READ_WRITE) -# if defined (ACE_WIN32) - - ACE_OS_GUARD - - // Remember the original file pointer position - DWORD original_position = ::SetFilePointer (handle, - 0, - 0, - FILE_CURRENT); - - if (original_position == 0xFFFFFFFF) - return -1; - - // Go to the correct position - DWORD altered_position = ::SetFilePointer (handle, - offset, - 0, - FILE_BEGIN); - if (altered_position == 0xFFFFFFFF) - return -1; - - DWORD bytes_written; - -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) - - OVERLAPPED overlapped; - overlapped.Internal = 0; - overlapped.InternalHigh = 0; - overlapped.Offset = offset; - overlapped.OffsetHigh = 0; - overlapped.hEvent = 0; - - BOOL result = ::WriteFile (handle, - buf, - ACE_static_cast (DWORD, nbytes), - &bytes_written, - &overlapped); - - if (result == FALSE) - { - if (::GetLastError () != ERROR_IO_PENDING) - return -1; - - else - { - result = ::GetOverlappedResult (handle, - &overlapped, - &bytes_written, - TRUE); - if (result == FALSE) - return -1; - } - } - -# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - - BOOL result = ::WriteFile (handle, - buf, - nbytes, - &bytes_written, - 0); - if (result == FALSE) - return -1; - -# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - - // Reset the original file pointer position - if (::SetFilePointer (handle, - original_position, - 0, - FILE_BEGIN) == 0xFFFFFFFF) - return -1; - - return (ssize_t) bytes_written; - -# else /* ACE_WIN32 */ - - return ::pwrite (handle, buf, nbytes, offset); -# endif /* ACE_WIN32 */ -# else /* ACE_HAS_P_READ_WRITE */ - - ACE_OS_GUARD - - // Remember the original file pointer position - off_t original_position = ACE_OS::lseek (handle, - 0, - SEEK_CUR); - if (original_position == -1) - return -1; - - // Go to the correct position - off_t altered_position = ACE_OS::lseek (handle, - offset, - SEEK_SET); - if (altered_position == -1) - return -1; - - ssize_t bytes_written = ACE_OS::write (handle, - buf, - nbytes); - if (bytes_written == -1) - return -1; - - if (ACE_OS::lseek (handle, - original_position, - SEEK_SET) == -1) - return -1; - - return bytes_written; -# endif /* ACE_HAD_P_READ_WRITE */ -} - -ACE_HANDLE -ACE_OS::open (const char *filename, - int mode, - int perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_OS_TRACE ("ACE_OS::open"); - -#if defined (ACE_WIN32) - DWORD access = GENERIC_READ; - if (ACE_BIT_ENABLED (mode, O_WRONLY)) - access = GENERIC_WRITE; - else if (ACE_BIT_ENABLED (mode, O_RDWR)) - access = GENERIC_READ | GENERIC_WRITE; - - DWORD creation = OPEN_EXISTING; - - if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) - creation = CREATE_NEW; - else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) - creation = CREATE_ALWAYS; - else if (ACE_BIT_ENABLED (mode, _O_CREAT)) - creation = OPEN_ALWAYS; - else if (ACE_BIT_ENABLED (mode, _O_TRUNC)) - creation = TRUNCATE_EXISTING; - - DWORD flags = 0; - - if (ACE_BIT_ENABLED (mode, _O_TEMPORARY)) - flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; - - if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) - flags |= FILE_FLAG_WRITE_THROUGH; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) - flags |= FILE_FLAG_OVERLAPPED; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) - flags |= FILE_FLAG_NO_BUFFERING; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) - flags |= FILE_FLAG_RANDOM_ACCESS; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) - flags |= FILE_FLAG_SEQUENTIAL_SCAN; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) - flags |= FILE_FLAG_DELETE_ON_CLOSE; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) - flags |= FILE_FLAG_BACKUP_SEMANTICS; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) - flags |= FILE_FLAG_POSIX_SEMANTICS; - - ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) - - if (ACE_BIT_ENABLED (mode, _O_APPEND)) - { - ACE_MT - ( - ace_os_monitor_lock = (ACE_thread_mutex_t *) - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]; - ACE_OS::thread_mutex_lock (ace_os_monitor_lock); - ) - } - - DWORD shared_mode = perms; - -#if defined (ACE_HAS_WINCE) - ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (), access, - shared_mode, - ACE_OS::default_win32_security_attributes (sa), - creation, - flags, - 0); -#else /* ACE_HAS_WINCE */ - ACE_HANDLE h = ::CreateFileA (filename, access, - shared_mode, - ACE_OS::default_win32_security_attributes (sa), - creation, - flags, - 0); -#endif /* ACE_HAS_WINCE */ - - if (ACE_BIT_ENABLED (mode, _O_APPEND)) - { - if (h != ACE_INVALID_HANDLE) - { - ::SetFilePointer (h, 0, 0, FILE_END); - } - - ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) - } - - if (h == ACE_INVALID_HANDLE) - ACE_FAIL_RETURN (h); - else - return h; -#elif defined (ACE_PSOS) - ACE_UNUSED_ARG (perms); - ACE_UNUSED_ARG (sa); -# if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (filename); - return 0; -# else - unsigned long result, handle; - result = ::open_f (&handle, ACE_const_cast(char *, filename), 0); - if (result != 0) - { - // We need to clean this up...not 100% correct! - // To correct we should handle all the cases of TRUNC and CREAT - if ((result == 0x200B) && (ACE_BIT_ENABLED (mode, O_CREAT))) - { - result = ::create_f(ACE_const_cast(char *, filename),1,0); - if (result != 0) - { - errno = result; - return ACE_static_cast (ACE_HANDLE, -1); - } - else //File created...try to open it again - { - result = ::open_f (&handle, ACE_const_cast(char *, filename), 0); - if (result != 0) - { - errno = result; - return ACE_static_cast (ACE_HANDLE, -1); - } - - } - } - else - { - errno = result; - return ACE_static_cast (ACE_HANDLE, -1); - } - } - return ACE_static_cast (ACE_HANDLE, handle); -# endif /* defined (ACE_PSOS_LACKS_PHILE) */ -#elif defined (INTEGRITY) - ACE_UNUSED_ARG (sa); - if(!strcmp(filename,ACE_DEV_NULL)) { - ACE_OSCALL_RETURN (::AllocateNullConsoleDescriptor(), ACE_HANDLE, -1); - } - else { - ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1); - } -#else - ACE_UNUSED_ARG (sa); - ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1); -#endif /* ACE_WIN32 */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_HANDLE -ACE_OS::open (const wchar_t *filename, - int mode, - int perms, - LPSECURITY_ATTRIBUTES sa) -{ -#if defined (ACE_WIN32) - // @@ (brunsch) Yuck, maybe there is a way to combine the code - // here with the char version - - DWORD access = GENERIC_READ; - if (ACE_BIT_ENABLED (mode, O_WRONLY)) - access = GENERIC_WRITE; - else if (ACE_BIT_ENABLED (mode, O_RDWR)) - access = GENERIC_READ | GENERIC_WRITE; - - DWORD creation = OPEN_EXISTING; - - if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) - creation = CREATE_NEW; - else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) - creation = CREATE_ALWAYS; - else if (ACE_BIT_ENABLED (mode, _O_CREAT)) - creation = OPEN_ALWAYS; - else if (ACE_BIT_ENABLED (mode, _O_TRUNC)) - creation = TRUNCATE_EXISTING; - - DWORD flags = 0; - - if (ACE_BIT_ENABLED (mode, _O_TEMPORARY)) - flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; - - if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) - flags |= FILE_FLAG_WRITE_THROUGH; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) - flags |= FILE_FLAG_OVERLAPPED; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) - flags |= FILE_FLAG_NO_BUFFERING; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) - flags |= FILE_FLAG_RANDOM_ACCESS; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) - flags |= FILE_FLAG_SEQUENTIAL_SCAN; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) - flags |= FILE_FLAG_DELETE_ON_CLOSE; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) - flags |= FILE_FLAG_BACKUP_SEMANTICS; - if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) - flags |= FILE_FLAG_POSIX_SEMANTICS; - - ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) - - if (ACE_BIT_ENABLED (mode, _O_APPEND)) - { - ACE_MT - ( - ace_os_monitor_lock = (ACE_thread_mutex_t *) - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]; - ACE_OS::thread_mutex_lock (ace_os_monitor_lock); - ) - } - - DWORD shared_mode = perms; - - ACE_HANDLE h = ::CreateFileW (filename, - access, - shared_mode, - ACE_OS::default_win32_security_attributes (sa), - creation, - flags, - 0); - - if (ACE_BIT_ENABLED (mode, _O_APPEND)) - { - if (h != ACE_INVALID_HANDLE) - { - ::SetFilePointer (h, 0, 0, FILE_END); - } - - ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) - } - - if (h == ACE_INVALID_HANDLE) - ACE_FAIL_RETURN (h); - else - return h; -#else /* ACE_WIN32 */ - // Just emulate with ascii version - return ACE_OS::open (ACE_Wide_To_Ascii (filename).char_rep (), - mode, - perms, - sa); -#endif /* ACE_WIN32 */ -} -#endif /* ACE_HAS_WCHAR */ - -# if defined (ACE_LACKS_DIFFTIME) -double -ACE_OS::difftime (time_t t1, time_t t0) -{ - /* return t1 - t0 in seconds */ - struct tm tms[2], *ptms[2], temp; - double seconds; - double days; - int swap = 0; - - /* extract the tm structure from time_t */ - ptms[1] = gmtime_r (&t1, &tms[1]); - if (ptms[1] == 0) return 0.0; - - ptms[0] = gmtime_r (&t0, &tms[0]); - if (ptms[0] == 0) return 0.0; - - /* make sure t1 is > t0 */ - if (tms[1].tm_year < tms[0].tm_year) - swap = 1; - else if (tms[1].tm_year == tms[0].tm_year) - { - if (tms[1].tm_yday < tms[0].tm_yday) - swap = 1; - else if (tms[1].tm_yday == tms[0].tm_yday) - { - if (tms[1].tm_hour < tms[0].tm_hour) - swap = 1; - else if (tms[1].tm_hour == tms[0].tm_hour) - { - if (tms[1].tm_min < tms[0].tm_min) - swap = 1; - else if (tms[1].tm_min == tms[0].tm_min) - { - if (tms[1].tm_sec < tms[0].tm_sec) - swap = 1; - } - } - } - } - - if (swap) - temp = tms[0], tms[0] = tms[1], tms[1] = temp; - - seconds = 0.0; - if (tms[1].tm_year > tms[0].tm_year) - { - // Accumulate the time until t[0] catches up to t[1]'s year. - seconds = 60 - tms[0].tm_sec; - tms[0].tm_sec = 0; - tms[0].tm_min += 1; - seconds += 60 * (60 - tms[0].tm_min); - tms[0].tm_min = 0; - tms[0].tm_hour += 1; - seconds += 60*60 * (24 - tms[0].tm_hour); - tms[0].tm_hour = 0; - tms[0].tm_yday += 1; - -# define ISLEAPYEAR(y) ((y)&3u?0:(y)%25u?1:(y)/25u&12?0:1) - - if (ISLEAPYEAR(tms[0].tm_year)) - seconds += 60*60*24 * (366 - tms[0].tm_yday); - else - seconds += 60*60*24 * (365 - tms[0].tm_yday); - - tms[0].tm_yday = 0; - tms[0].tm_year += 1; - - while (tms[1].tm_year > tms[0].tm_year) - { - if (ISLEAPYEAR(tms[0].tm_year)) - seconds += 60*60*24 * 366; - else - seconds += 60*60*24 * 365; - - tms[0].tm_year += 1; - } - -# undef ISLEAPYEAR - - } - else - { - // Normalize - if (tms[1].tm_sec < tms[0].tm_sec) - { - if (tms[1].tm_min == 0) - { - if (tms[1].tm_hour == 0) - { - tms[1].tm_yday -= 1; - tms[1].tm_hour += 24; - } - tms[1].tm_hour -= 1; - tms[1].tm_min += 60; - } - tms[1].tm_min -= 1; - tms[1].tm_sec += 60; - } - tms[1].tm_sec -= tms[0].tm_sec; - - if (tms[1].tm_min < tms[0].tm_min) - { - if (tms[1].tm_hour == 0) - { - tms[1].tm_yday -= 1; - tms[1].tm_hour += 24; - } - tms[1].tm_hour -= 1; - tms[1].tm_min += 60; - } - tms[1].tm_min -= tms[0].tm_min; - - if (tms[1].tm_hour < tms[0].tm_hour) - { - tms[1].tm_yday -= 1; - tms[1].tm_hour += 24; - } - tms[1].tm_hour -= tms[0].tm_hour; - - tms[1].tm_yday -= tms[0].tm_yday; - } - - // accumulate the seconds - seconds += tms[1].tm_sec; - seconds += 60 * tms[1].tm_min; - seconds += 60*60 * tms[1].tm_hour; - seconds += 60*60*24 * tms[1].tm_yday; - - return seconds; -} -# endif /* ACE_LACKS_DIFFTIME */ - -# if defined (ACE_HAS_WINCE) -ACE_TCHAR * -ACE_OS::ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen) -{ - // buflen must be at least 26 wchar_t long. - if (buflen < 26) // Again, 26 is a magic number. - { - errno = ERANGE; - return 0; - } - // This is really stupid, converting FILETIME to timeval back and - // forth. It assumes FILETIME and DWORDLONG are the same structure - // internally. - ULARGE_INTEGER _100ns; - _100ns.QuadPart = (DWORDLONG) *clock * 10000 * 1000 - + ACE_Time_Value::FILETIME_to_timval_skew; - FILETIME file_time; - file_time.dwLowDateTime = _100ns.LowPart; - file_time.dwHighDateTime = _100ns.HighPart; - - FILETIME localtime; - SYSTEMTIME systime; - FileTimeToLocalFileTime (&file_time, &localtime); - FileTimeToSystemTime (&localtime, &systime); - ACE_OS::sprintf (buf, ACE_OS_CTIME_R_FMTSTR, - ACE_OS::day_of_week_name[systime.wDayOfWeek], - ACE_OS::month_name[systime.wMonth - 1], - systime.wDay, - systime.wHour, - systime.wMinute, - systime.wSecond, - systime.wYear); - return buf; -} -# endif /* ACE_HAS_WINCE */ - -time_t -ACE_OS::mktime (struct tm *t) -{ - ACE_OS_TRACE ("ACE_OS::mktime"); -# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) - ACE_UNUSED_ARG (t); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WINCE) - SYSTEMTIME t_sys; - FILETIME t_file; - t_sys.wSecond = t->tm_sec; - t_sys.wMinute = t->tm_min; - t_sys.wHour = t->tm_hour; - t_sys.wDay = t->tm_mday; - t_sys.wMonth = t->tm_mon + 1; // SYSTEMTIME is 1-indexed, tm is 0-indexed - t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900 - t_sys.wDayOfWeek = t->tm_wday; // Ignored in below function call. - if (SystemTimeToFileTime (&t_sys, &t_file) == 0) - return -1; - ACE_Time_Value tv (t_file); - return tv.sec (); -# else -# if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_MT_SAFE_MKTIME) - ACE_OS_GUARD -# endif /* ACE_HAS_THREADS && ! ACE_HAS_MT_SAFE_MKTIME */ - - ACE_OSCALL_RETURN (::mktime (t), time_t, (time_t) -1); -# endif /* ACE_PSOS && ! ACE_PSOS_HAS_TIME */ -} - -# if !defined (ACE_HAS_THREADS) || defined (ACE_LACKS_RWLOCK_T) -int -ACE_OS::rwlock_init (ACE_rwlock_t *rw, - int type, - const ACE_TCHAR *name, - void *arg) -{ - // ACE_OS_TRACE ("ACE_OS::rwlock_init"); -# if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_RWLOCK_T) - // NT, POSIX, and VxWorks don't support this natively. - ACE_UNUSED_ARG (name); - int result = -1; - - // Since we cannot use the user specified name for all three - // objects, we will create three completely new names. - ACE_TCHAR name1[ACE_UNIQUE_NAME_LEN]; - ACE_TCHAR name2[ACE_UNIQUE_NAME_LEN]; - ACE_TCHAR name3[ACE_UNIQUE_NAME_LEN]; - ACE_TCHAR name4[ACE_UNIQUE_NAME_LEN]; - - ACE_OS::unique_name ((const void *) &rw->lock_, - name1, - ACE_UNIQUE_NAME_LEN); - ACE_OS::unique_name ((const void *) &rw->waiting_readers_, - name2, - ACE_UNIQUE_NAME_LEN); - ACE_OS::unique_name ((const void *) &rw->waiting_writers_, - name3, - ACE_UNIQUE_NAME_LEN); - ACE_OS::unique_name ((const void *) &rw->waiting_important_writer_, - name4, - ACE_UNIQUE_NAME_LEN); - - ACE_condattr_t attributes; - if (ACE_OS::condattr_init (attributes, type) == 0) - { - if (ACE_OS::mutex_init (&rw->lock_, type, name1, - (ACE_mutexattr_t *) arg) == 0 - && ACE_OS::cond_init (&rw->waiting_readers_, - attributes, name2, arg) == 0 - && ACE_OS::cond_init (&rw->waiting_writers_, - attributes, name3, arg) == 0 - && ACE_OS::cond_init (&rw->waiting_important_writer_, - attributes, name4, arg) == 0) - { - // Success! - rw->ref_count_ = 0; - rw->num_waiting_writers_ = 0; - rw->num_waiting_readers_ = 0; - rw->important_writer_ = 0; - result = 0; - } - ACE_OS::condattr_destroy (attributes); - } - - if (result == -1) - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::mutex_destroy (&rw->lock_); - ACE_OS::cond_destroy (&rw->waiting_readers_); - ACE_OS::cond_destroy (&rw->waiting_writers_); - ACE_OS::cond_destroy (&rw->waiting_important_writer_); - } - return result; -# else - ACE_UNUSED_ARG (rw); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -# endif /* ! ACE_HAS_THREADS || ACE_LACKS_RWLOCK_T */ - -#if defined (ACE_LACKS_COND_T) && ! defined (ACE_PSOS_DIAB_MIPS) -// NOTE: The ACE_OS::cond_* functions for some non-Unix platforms are -// defined here either because they're too big to be inlined, or -// to avoid use before definition if they were inline. - -int -ACE_OS::cond_destroy (ACE_cond_t *cv) -{ - ACE_OS_TRACE ("ACE_OS::cond_destroy"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) - ACE_OS::event_destroy (&cv->waiters_done_); -# elif defined (VXWORKS) || defined (ACE_PSOS) - ACE_OS::sema_destroy (&cv->waiters_done_); -# endif /* VXWORKS */ - ACE_OS::thread_mutex_destroy (&cv->waiters_lock_); - return ACE_OS::sema_destroy (&cv->sema_); -# else - ACE_UNUSED_ARG (cv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -// @@ The following functions could be inlined if i could figure where -// to put it among the #ifdefs! -int -ACE_OS::condattr_init (ACE_condattr_t &attributes, - int type) -{ - attributes.type = type; - return 0; -} - -int -ACE_OS::condattr_destroy (ACE_condattr_t &) -{ - return 0; -} - -int -ACE_OS::cond_init (ACE_cond_t *cv, - ACE_condattr_t &attributes, - const char *name, void *arg) -{ - return ACE_OS::cond_init (cv, attributes.type, name, arg); -} - -#if defined (ACE_HAS_WCHAR) -int -ACE_OS::cond_init (ACE_cond_t *cv, - ACE_condattr_t &attributes, - const wchar_t *name, void *arg) -{ - return ACE_OS::cond_init (cv, attributes.type, name, arg); -} -#endif /* ACE_HAS_WCHAR */ - -int -ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg) -{ - ACE_OS_TRACE ("ACE_OS::cond_init"); -# if defined (ACE_HAS_THREADS) - cv->waiters_ = 0; - cv->was_broadcast_ = 0; - - int result = 0; - if (ACE_OS::sema_init (&cv->sema_, 0, type, name, arg) == -1) - result = -1; - else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1) - result = -1; -# if defined (VXWORKS) || defined (ACE_PSOS) - else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1) -# else - else if (ACE_OS::event_init (&cv->waiters_done_) == -1) -# endif /* VXWORKS */ - result = -1; - return result; -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -#if defined (ACE_HAS_WCHAR) -int -ACE_OS::cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg) -{ - ACE_OS_TRACE ("ACE_OS::cond_init"); -# if defined (ACE_HAS_THREADS) - cv->waiters_ = 0; - cv->was_broadcast_ = 0; - - int result = 0; - if (ACE_OS::sema_init (&cv->sema_, 0, type, name, arg) == -1) - result = -1; - else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1) - result = -1; -# if defined (VXWORKS) || defined (ACE_PSOS) - else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1) -# else - else if (ACE_OS::event_init (&cv->waiters_done_) == -1) -# endif /* VXWORKS */ - result = -1; - return result; -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -#endif /* ACE_HAS_WCHAR */ - -int -ACE_OS::cond_signal (ACE_cond_t *cv) -{ - ACE_OS_TRACE ("ACE_OS::cond_signal"); -# if defined (ACE_HAS_THREADS) - // If there aren't any waiters, then this is a no-op. Note that - // this function *must* be called with the <external_mutex> held - // since other wise there is a race condition that can lead to the - // lost wakeup bug... This is needed to ensure that the <waiters_> - // value is not in an inconsistent internal state while being - // updated by another thread. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - int have_waiters = cv->waiters_ > 0; - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - if (have_waiters != 0) - return ACE_OS::sema_post (&cv->sema_); - else - return 0; // No-op -# else - ACE_UNUSED_ARG (cv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::cond_broadcast (ACE_cond_t *cv) -{ - ACE_OS_TRACE ("ACE_OS::cond_broadcast"); -# if defined (ACE_HAS_THREADS) - // The <external_mutex> must be locked before this call is made. - - // This is needed to ensure that <waiters_> and <was_broadcast_> are - // consistent relative to each other. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - int have_waiters = 0; - - if (cv->waiters_ > 0) - { - // We are broadcasting, even if there is just one waiter... - // Record the fact that we are broadcasting. This helps the - // cond_wait() method know how to optimize itself. Be sure to - // set this with the <waiters_lock_> held. - cv->was_broadcast_ = 1; - have_waiters = 1; - } - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - int result = 0; - if (have_waiters) - { - // Wake up all the waiters. - if (ACE_OS::sema_post (&cv->sema_, cv->waiters_) == -1) - result = -1; - // Wait for all the awakened threads to acquire their part of - // the counting semaphore. -# if defined (VXWORKS) || defined (ACE_PSOS) - else if (ACE_OS::sema_wait (&cv->waiters_done_) == -1) -# else - else if (ACE_OS::event_wait (&cv->waiters_done_) == -1) -# endif /* VXWORKS */ - result = -1; - // This is okay, even without the <waiters_lock_> held because - // no other waiter threads can wake up to access it. - cv->was_broadcast_ = 0; - } - return result; -# else - ACE_UNUSED_ARG (cv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::cond_wait (ACE_cond_t *cv, - ACE_mutex_t *external_mutex) -{ - ACE_OS_TRACE ("ACE_OS::cond_wait"); -# if defined (ACE_HAS_THREADS) - // Prevent race conditions on the <waiters_> count. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - cv->waiters_++; - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - int result = 0; - -# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) - if (external_mutex->type_ == USYNC_PROCESS) - // This call will automatically release the mutex and wait on the semaphore. - ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (external_mutex->proc_mutex_, - cv->sema_, INFINITE, FALSE), - result), - int, -1, result); - else -# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ - { - // We keep the lock held just long enough to increment the count of - // waiters by one. Note that we can't keep it held across the call - // to ACE_OS::sema_wait() since that will deadlock other calls to - // ACE_OS::cond_signal(). - if (ACE_OS::mutex_unlock (external_mutex) != 0) - return -1; - - // Wait to be awakened by a ACE_OS::cond_signal() or - // ACE_OS::cond_broadcast(). - result = ACE_OS::sema_wait (&cv->sema_); - } - - // Reacquire lock to avoid race conditions on the <waiters_> count. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - - // We're ready to return, so there's one less waiter. - cv->waiters_--; - - int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; - - // Release the lock so that other collaborating threads can make - // progress. - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - if (result == -1) - // Bad things happened, so let's just return below. - /* NOOP */; -# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) - else if (external_mutex->type_ == USYNC_PROCESS) - { - if (last_waiter) - - // This call atomically signals the <waiters_done_> event and - // waits until it can acquire the mutex. This is important to - // prevent unfairness. - ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (cv->waiters_done_, - external_mutex->proc_mutex_, - INFINITE, FALSE), - result), - int, -1, result); - else - // We must always regain the <external_mutex>, even when - // errors occur because that's the guarantee that we give to - // our callers. - ACE_OS::mutex_lock (external_mutex); - - return result; - /* NOTREACHED */ - } -# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ - // If we're the last waiter thread during this particular broadcast - // then let all the other threads proceed. - else if (last_waiter) -# if defined (VXWORKS) || defined (ACE_PSOS) - ACE_OS::sema_post (&cv->waiters_done_); -# else - ACE_OS::event_signal (&cv->waiters_done_); -# endif /* VXWORKS */ - - // We must always regain the <external_mutex>, even when errors - // occur because that's the guarantee that we give to our callers. - ACE_OS::mutex_lock (external_mutex); - - return result; -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (external_mutex); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::cond_timedwait (ACE_cond_t *cv, - ACE_mutex_t *external_mutex, - ACE_Time_Value *timeout) -{ - ACE_OS_TRACE ("ACE_OS::cond_timedwait"); -# if defined (ACE_HAS_THREADS) - // Handle the easy case first. - if (timeout == 0) - return ACE_OS::cond_wait (cv, external_mutex); -# if defined (ACE_HAS_WTHREADS) || defined (VXWORKS) || defined (ACE_PSOS) - - // Prevent race conditions on the <waiters_> count. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - cv->waiters_++; - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - int result = 0; - ACE_Errno_Guard error (errno, 0); - int msec_timeout; - - if (timeout->sec () == 0 && timeout->usec () == 0) - msec_timeout = 0; // Do a "poll." - else - { - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what - // WaitForSingleObjects() expects). - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); - - // Watchout for situations where a context switch has caused the - // current time to be > the timeout. - if (relative_time < ACE_Time_Value::zero) - msec_timeout = 0; - else - msec_timeout = relative_time.msec (); - } - -# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) - if (external_mutex->type_ == USYNC_PROCESS) - // This call will automatically release the mutex and wait on the - // semaphore. - result = ::SignalObjectAndWait (external_mutex->proc_mutex_, - cv->sema_, - msec_timeout, - FALSE); - else -# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ - { - // We keep the lock held just long enough to increment the count - // of waiters by one. Note that we can't keep it held across - // the call to WaitForSingleObject since that will deadlock - // other calls to ACE_OS::cond_signal(). - if (ACE_OS::mutex_unlock (external_mutex) != 0) - return -1; - - // Wait to be awakened by a ACE_OS::signal() or - // ACE_OS::broadcast(). -# if defined (ACE_WIN32) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - result = ::WaitForSingleObject (cv->sema_, msec_timeout); -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - // Can't use Win32 API on our simulated semaphores. - result = ACE_OS::sema_wait (&cv->sema_, - timeout); -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - // Inline the call to ACE_OS::sema_wait () because it takes an - // ACE_Time_Value argument. Avoid the cost of that conversion . . . - u_long ticks = (KC_TICKS2SEC * msec_timeout) / ACE_ONE_SECOND_IN_MSECS; - //Tick set to 0 tells pSOS to wait forever is SM_WAIT is set. - if(ticks == 0) - result = ::sm_p (cv->sema_.sema_, SM_NOWAIT, ticks); //no timeout - else - result = ::sm_p (cv->sema_.sema_, SM_WAIT, ticks); -# elif defined (VXWORKS) - // Inline the call to ACE_OS::sema_wait () because it takes an - // ACE_Time_Value argument. Avoid the cost of that conversion . . . - int ticks_per_sec = ::sysClkRateGet (); - int ticks = msec_timeout * ticks_per_sec / ACE_ONE_SECOND_IN_MSECS; - result = ::semTake (cv->sema_.sema_, ticks); -# endif /* ACE_WIN32 || VXWORKS */ - } - - // Reacquire lock to avoid race conditions. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - cv->waiters_--; - - int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; - - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - -# if defined (ACE_WIN32) - if (result != WAIT_OBJECT_0) - { - switch (result) - { - case WAIT_TIMEOUT: - error = ETIME; - break; - default: - error = ::GetLastError (); - break; - } - result = -1; - } -# elif defined (ACE_PSOS) - if (result != 0) - { - switch (result) - { - case ERR_TIMEOUT: // Timeout occured with SM_WAIT - case ERR_NOMSG: // Didn't acquire semaphore w/ SM_NOWAIT (ticks=0) - error = ETIME; - break; - default: - error = errno; - break; - } - result = -1; - } -# elif defined (VXWORKS) - if (result == ERROR) - { - switch (errno) - { - case S_objLib_OBJ_TIMEOUT: - error = ETIME; - break; - case S_objLib_OBJ_UNAVAILABLE: - if (msec_timeout == 0) - error = ETIME; - break; - default: - error = errno; - break; - } - result = -1; - } -# endif /* ACE_WIN32 || VXWORKS */ -# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) - if (external_mutex->type_ == USYNC_PROCESS) - { - if (last_waiter) - // This call atomically signals the <waiters_done_> event and - // waits until it can acquire the mutex. This is important to - // prevent unfairness. - ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (cv->waiters_done_, - external_mutex->proc_mutex_, - INFINITE, FALSE), - result), - int, -1, result); - else - // We must always regain the <external_Mutex>, even when - // errors occur because that's the guarantee that we give to - // our callers. - ACE_OS::mutex_lock (external_mutex); - - return result; - /* NOTREACHED */ - } -# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ - // Note that this *must* be an "if" statement rather than an "else - // if" statement since the caller may have timed out and hence the - // result would have been -1 above. - if (last_waiter) - // Release the signaler/broadcaster if we're the last waiter. -# if defined (ACE_WIN32) - ACE_OS::event_signal (&cv->waiters_done_); -# else - ACE_OS::sema_post (&cv->waiters_done_); -# endif /* ACE_WIN32 */ - - // We must always regain the <external_mutex>, even when errors - // occur because that's the guarantee that we give to our callers. - ACE_OS::mutex_lock (external_mutex); - - return result; -# endif /* ACE_HAS_WTHREADS || ACE_HAS_VXWORKS || ACE_PSOS */ -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (external_mutex); - ACE_UNUSED_ARG (timeout); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -# if defined (ACE_HAS_WTHREADS) -int -ACE_OS::cond_timedwait (ACE_cond_t *cv, - ACE_thread_mutex_t *external_mutex, - ACE_Time_Value *timeout) -{ - ACE_OS_TRACE ("ACE_OS::cond_timedwait"); -# if defined (ACE_HAS_THREADS) - // Handle the easy case first. - if (timeout == 0) - return ACE_OS::cond_wait (cv, external_mutex); - - // Prevent race conditions on the <waiters_> count. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - cv->waiters_++; - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - int result = 0; - int error = 0; - int msec_timeout; - - if (timeout->sec () == 0 && timeout->usec () == 0) - msec_timeout = 0; // Do a "poll." - else - { - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what - // WaitForSingleObjects() expects). - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); - - // Watchout for situations where a context switch has caused the - // current time to be > the timeout. - if (relative_time < ACE_Time_Value::zero) - msec_timeout = 0; - else - msec_timeout = relative_time.msec (); - } - - // We keep the lock held just long enough to increment the count of - // waiters by one. Note that we can't keep it held across the call - // to WaitForSingleObject since that will deadlock other calls to - // ACE_OS::cond_signal(). - if (ACE_OS::thread_mutex_unlock (external_mutex) != 0) - return -1; - - // Wait to be awakened by a ACE_OS::signal() or ACE_OS::broadcast(). -# if defined (ACE_USES_WINCE_SEMA_SIMULATION) - // Can't use Win32 API on simulated semaphores. - result = ACE_OS::sema_wait (&cv->sema_, - timeout); - - if (result == -1 && errno == ETIME) - result = WAIT_TIMEOUT; -# else - result = ::WaitForSingleObject (cv->sema_, msec_timeout); -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ - - // Reacquire lock to avoid race conditions. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - - cv->waiters_--; - - int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; - - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - if (result != WAIT_OBJECT_0) - { - switch (result) - { - case WAIT_TIMEOUT: - error = ETIME; - break; - default: - error = ::GetLastError (); - break; - } - result = -1; - } - - if (last_waiter) - // Release the signaler/broadcaster if we're the last waiter. - ACE_OS::event_signal (&cv->waiters_done_); - - // We must always regain the <external_mutex>, even when errors - // occur because that's the guarantee that we give to our callers. - ACE_OS::thread_mutex_lock (external_mutex); - errno = error; - return result; -# else - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -int -ACE_OS::cond_wait (ACE_cond_t *cv, - ACE_thread_mutex_t *external_mutex) -{ - ACE_OS_TRACE ("ACE_OS::cond_wait"); -# if defined (ACE_HAS_THREADS) - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - cv->waiters_++; - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - int result = 0; - int error = 0; - - // We keep the lock held just long enough to increment the count of - // waiters by one. Note that we can't keep it held across the call - // to ACE_OS::sema_wait() since that will deadlock other calls to - // ACE_OS::cond_signal(). - if (ACE_OS::thread_mutex_unlock (external_mutex) != 0) - return -1; - - // Wait to be awakened by a ACE_OS::cond_signal() or - // ACE_OS::cond_broadcast(). -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - result = ::WaitForSingleObject (cv->sema_, INFINITE); -# else - // Can't use Win32 API on simulated semaphores. - result = ACE_OS::sema_wait (&cv->sema_); - - if (result != WAIT_OBJECT_0 && errno == ETIME) - result = WAIT_TIMEOUT; - -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ - - // Reacquire lock to avoid race conditions. - ACE_OS::thread_mutex_lock (&cv->waiters_lock_); - - cv->waiters_--; - - int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; - - ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); - - if (result != WAIT_OBJECT_0) - { - switch (result) - { - case WAIT_TIMEOUT: - error = ETIME; - break; - default: - error = ::GetLastError (); - break; - } - } - else if (last_waiter) - // Release the signaler/broadcaster if we're the last waiter. - ACE_OS::event_signal (&cv->waiters_done_); - - // We must always regain the <external_mutex>, even when errors - // occur because that's the guarantee that we give to our callers. - ACE_OS::thread_mutex_lock (external_mutex); - - // Reset errno in case mutex_lock() also fails... - errno = error; - return result; -# else - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -# endif /* ACE_HAS_WTHREADS */ -#endif /* ACE_LACKS_COND_T */ - -void -ACE_OS::exit (int status) -{ - ACE_OS_TRACE ("ACE_OS::exit"); - -#if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) - // Shut down the ACE_Object_Manager, if it had registered its exit_hook. - // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is - // instantiated on the main's stack. ::exit () doesn't destroy it. - if (exit_hook_) - (*exit_hook_) (); -#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ - -#if !defined (ACE_HAS_WINCE) -# if defined (ACE_WIN32) - ::ExitProcess ((UINT) status); -# elif defined (ACE_PSOSIM) - ::u_exit (status); -# else - ::exit (status); -# endif /* ACE_WIN32 */ -#else - // @@ This is not exactly the same as ExitProcess. But this is the - // closest one I can get. - ::TerminateProcess (::GetCurrentProcess (), status); -#endif /* ACE_HAS_WINCE */ -} - -# if defined (ACE_PSOS) - -// bit masks and shifts for prying info out of the pSOS time encoding -const u_long ACE_PSOS_Time_t::year_mask = 0x0000FFFFul; -const u_long ACE_PSOS_Time_t::month_mask = 0x000000FFul; -const u_long ACE_PSOS_Time_t::day_mask = 0x000000FFul; -const u_long ACE_PSOS_Time_t::hour_mask = 0x0000FFFFul; -const u_long ACE_PSOS_Time_t::minute_mask = 0x000000FFul; -const u_long ACE_PSOS_Time_t::second_mask = 0x000000FFul; -const int ACE_PSOS_Time_t::year_shift = 16; -const int ACE_PSOS_Time_t::month_shift = 8; -const int ACE_PSOS_Time_t::hour_shift = 16; -const int ACE_PSOS_Time_t::minute_shift = 8; -const int ACE_PSOS_Time_t::year_origin = 1900; -const int ACE_PSOS_Time_t::month_origin = 1; - -// maximum number of clock ticks supported -const u_long ACE_PSOS_Time_t::max_ticks = ~0UL; - -ACE_PSOS_Time_t::ACE_PSOS_Time_t (void) - : date_ (0), - time_ (0), - ticks_ (0) -{ -} - -// default ctor: date, time, and ticks all zeroed - -ACE_PSOS_Time_t::ACE_PSOS_Time_t (const timespec_t& t) -{ - struct tm* tm_struct = ACE_OS::gmtime (&(t.tv_sec)); - - // Encode date values from tm struct into pSOS date bit array. - date_ = (ACE_PSOS_Time_t::year_mask & - ACE_static_cast (u_long, - tm_struct->tm_year + ACE_PSOS_Time_t::year_origin)) << - ACE_PSOS_Time_t::year_shift; - date_ |= (ACE_PSOS_Time_t::month_mask & - ACE_static_cast (u_long, - tm_struct->tm_mon + ACE_PSOS_Time_t::month_origin)) << - ACE_PSOS_Time_t::month_shift; - date_ |= ACE_PSOS_Time_t::day_mask & - ACE_static_cast (u_long, tm_struct->tm_mday); - // Encode time values from tm struct into pSOS time bit array. - time_ = (ACE_PSOS_Time_t::hour_mask & - ACE_static_cast (u_long, tm_struct->tm_hour)) << - ACE_PSOS_Time_t::hour_shift; - time_ |= (ACE_PSOS_Time_t::minute_mask & - ACE_static_cast (u_long, tm_struct->tm_min)) << - ACE_PSOS_Time_t::minute_shift; - time_ |= ACE_PSOS_Time_t::second_mask & - ACE_static_cast (u_int, tm_struct->tm_sec); - - // encode nanoseconds as system clock ticks - ticks_ = ACE_static_cast (u_long, - ((ACE_static_cast (double, t.tv_nsec) * - ACE_static_cast (double, KC_TICKS2SEC)) / - ACE_static_cast (double, 1000000000))); - -} - -// ctor from a timespec_t - -ACE_PSOS_Time_t::operator timespec_t (void) -{ - struct tm tm_struct; - - // Decode date and time bit arrays and fill in fields of tm_struct. - - tm_struct.tm_year = - ACE_static_cast (int, (ACE_PSOS_Time_t::year_mask & - (date_ >> ACE_PSOS_Time_t::year_shift))) - - ACE_PSOS_Time_t::year_origin; - tm_struct.tm_mon = - ACE_static_cast (int, (ACE_PSOS_Time_t::month_mask & - (date_ >> ACE_PSOS_Time_t::month_shift))) - - ACE_PSOS_Time_t::month_origin; - tm_struct.tm_mday = - ACE_static_cast (int, (ACE_PSOS_Time_t::day_mask & date_)); - tm_struct.tm_hour = - ACE_static_cast (int, (ACE_PSOS_Time_t::hour_mask & - (time_ >> ACE_PSOS_Time_t::hour_shift))); - tm_struct.tm_min = - ACE_static_cast (int, (ACE_PSOS_Time_t::minute_mask & - (time_ >> ACE_PSOS_Time_t::minute_shift))); - tm_struct.tm_sec = - ACE_static_cast (int, (ACE_PSOS_Time_t::second_mask & time_)); - - // Indicate values we don't know as negative numbers. - tm_struct.tm_wday = -1; - tm_struct.tm_yday = -1; - tm_struct.tm_isdst = -1; - - timespec_t t; - - // Convert calendar time to time struct. - t.tv_sec = ACE_OS::mktime (&tm_struct); - - // Encode nanoseconds as system clock ticks. - t.tv_nsec = ACE_static_cast (long, - ((ACE_static_cast (double, ticks_) * - ACE_static_cast (double, 1000000000)) / - ACE_static_cast (double, KC_TICKS2SEC))); - return t; -} - -// type cast operator (to a timespec_t) - -u_long -ACE_PSOS_Time_t::get_system_time (ACE_PSOS_Time_t& t) -{ - u_long ret_val = 0; - -# if defined (ACE_PSOSIM) // system time is broken in simulator. - timeval tv; - int result = 0; - ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result); - if (result == -1) - return 1; - - ACE_Time_Value atv (tv); - timespec ts = atv; - ACE_PSOS_Time_t pt (ts); - t.date_ = pt.date_; - t.time_ = pt.time_; - t.ticks_ = pt.ticks_; -# else - ret_val = tm_get (&(t.date_), &(t.time_), &(t.ticks_)); -# endif /* ACE_PSOSIM */ - return ret_val; -} - -// Static member function to get current system time. - -u_long -ACE_PSOS_Time_t::set_system_time (const ACE_PSOS_Time_t& t) -{ - return tm_set (t.date_, t.time_, t.ticks_); -} - -// Static member function to set current system time. - -# if defined (ACE_PSOSIM) - -u_long -ACE_PSOS_Time_t::init_simulator_time (void) -{ - // This is a hack using a direct UNIX system call, because the - // appropriate ACE_OS method ultimately uses the pSOS tm_get - // function, which would fail because the simulator's system time is - // uninitialized (chicken and egg). - timeval t; - int result = 0; - ACE_OSCALL (::gettimeofday (&t, 0), - int, - -1, - result); - - if (result == -1) - return 1; - else - { - ACE_Time_Value tv (t); - timespec ts = tv; - ACE_PSOS_Time_t pt (ts); - u_long ret_val = - ACE_PSOS_Time_t::set_system_time (pt); - return ret_val; - - } -} - -// Static member function to initialize system time, using UNIX calls. - -# endif /* ACE_PSOSIM */ -# endif /* ACE_PSOS && ! ACE_PSOS_DIAB_MIPS */ - -# if defined (__DGUX) && defined (ACE_HAS_THREADS) && defined (_POSIX4A_DRAFT10_SOURCE) -extern "C" int __d6_sigwait (sigset_t *set); - -extern "C" int __d10_sigwait (const sigset_t *set, int *sig) -{ - sigset_t unconst_set = *set; - int caught_sig = __d6_sigwait (&unconst_set); - - if (caught == -1) - return -1; - - *sig = caught_sig; - return 0; -} -# endif /* __DGUX && PTHREADS && _POSIX4A_DRAFT10_SOURCE */ - -# 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, - 0, - ::GetLastError (), - MAKELANGID (LANG_NEUTRAL, - SUBLANG_DEFAULT), - // Default language - (ACE_TCHAR *) &lpMsgBuf, - 0, - 0); - ::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 - * - * @brief Ensure that the <ACE_OS_Object_Manager> gets initialized at - * program startup, and destroyed at program termination. - * - * 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. - */ -class ACE_OS_Object_Manager_Manager -{ -public: - /// Constructor. - ACE_OS_Object_Manager_Manager (void); - - /// Destructor. - ~ACE_OS_Object_Manager_Manager (void); - -private: - /// Save the main thread ID, so that destruction can be suppressed. - ACE_thread_t saved_main_thread_id_; -}; - -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 */ - -// You may be asking yourself, why are we doing this? Well, in winbase.h, -// MS didn't follow their normal Api_FunctionA and Api_FunctionW style, -// so we have to #undef their define to get access to the unicode version. -// And because we don't want to #undef this for the users code, we keep -// this method in the .cpp file. -#if defined (ACE_WIN32) && defined (UNICODE) && !defined (ACE_USES_TCHAR) -#undef GetEnvironmentStrings -#endif /* ACE_WIN32 && UNICODE !ACE_USES_TCHAR */ - -ACE_TCHAR * -ACE_OS::getenvstrings (void) -{ -#if defined (ACE_LACKS_ENV) - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - return ::GetEnvironmentStringsW (); -# else /* ACE_USES_WCHAR */ - return ::GetEnvironmentStrings (); -# endif /* ACE_USES_WCHAR */ -#else /* ACE_WIN32 */ - ACE_NOTSUP_RETURN (0); -#endif /* ACE_WIN32 */ -} - -#if defined (ACE_HAS_STRPTIME) -char * -ACE_OS::strptime (char *buf, const char *format, struct tm *tm) -{ -#if !defined (ACE_HAS_WINCE) -#if defined (ACE_LACKS_NATIVE_STRPTIME) - int bi = 0; - int fi = 0; - int percent = 0; - - if (!buf || !format) - return 0; - - while (format[fi] != '\0') - { - if (percent) - { - percent = 0; - switch (format[fi]) - { - case '%': // an escaped % - if (buf[bi] == '%') - { - fi++; bi++; - } - else - return buf + bi; - break; - - /* not supported yet: weekday via locale long/short names - case 'a': / * weekday via locale * / - / * FALL THROUGH * / - case 'A': / * long/short names * / - break; - */ - - /* not supported yet: - case 'b': / * month via locale * / - / * FALL THROUGH * / - case 'B': / * long/short names * / - / * FALL THROUGH * / - case 'h': - break; - */ - - /* not supported yet: - case 'c': / * %x %X * / - break; - */ - - /* not supported yet: - case 'C': / * date & time - * / - / * locale long format * / - break; - */ - - case 'd': /* day of month (1-31) */ - /* FALL THROUGH */ - case 'e': - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mday, &bi, &fi, 1, 31)) - return buf + bi; - - break; - - case 'D': /* %m/%d/%y */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mon, &bi, &fi, 1, 12)) - return buf + bi; - - fi--; - tm->tm_mon--; - - if (buf[bi] != '/') - return buf + bi; - - bi++; - - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mday, &bi, &fi, 1, 31)) - return buf + bi; - - fi--; - if (buf[bi] != '/') - return buf + bi; - bi++; - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_year, &bi, &fi, 0, 99)) - return buf + bi; - if (tm->tm_year < 69) - tm->tm_year += 100; - break; - - case 'H': /* hour (0-23) */ - /* FALL THROUGH */ - case 'k': - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23)) - return buf + bi; - break; - - /* not supported yet: - case 'I': / * hour (0-12) * / - / * FALL THROUGH * / - case 'l': - break; - */ - - case 'j': /* day of year (0-366) */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_yday, &bi, &fi, 1, 366)) - return buf + bi; - - tm->tm_yday--; - break; - - case 'm': /* an escaped % */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mon, &bi, &fi, 1, 12)) - return buf + bi; - - tm->tm_mon--; - break; - - case 'M': /* minute (0-59) */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_min, &bi, &fi, 0, 59)) - return buf + bi; - - break; - - /* not supported yet: - case 'p': / * am or pm for locale * / - break; - */ - - /* not supported yet: - case 'r': / * %I:%M:%S %p * / - break; - */ - - case 'R': /* %H:%M */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23)) - return buf + bi; - - fi--; - if (buf[bi] != ':') - return buf + bi; - bi++; - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_min, &bi, &fi, 0, 59)) - return buf + bi; - - break; - - case 'S': /* seconds (0-61) */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_sec, &bi, &fi, 0, 61)) - return buf + bi; - break; - - case 'T': /* %H:%M:%S */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23)) - return buf + bi; - - fi--; - if (buf[bi] != ':') - return buf + bi; - bi++; - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_min, &bi, &fi, 0, 59)) - return buf + bi; - - fi--; - if (buf[bi] != ':') - return buf + bi; - bi++; - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_sec, &bi, &fi, 0, 61)) - return buf + bi; - - break; - - case 'w': /* day of week (0=Sun-6) */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_wday, &bi, &fi, 0, 6)) - return buf + bi; - - break; - - /* not supported yet: date, based on locale - case 'x': / * date, based on locale * / - break; - */ - - /* not supported yet: - case 'X': / * time, based on locale * / - break; - */ - - case 'y': /* the year - 1900 (0-99) */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_year, &bi, &fi, 0, 99)) - return buf + bi; - - if (tm->tm_year < 69) - tm->tm_year += 100; - break; - - case 'Y': /* the full year (1999) */ - if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_year, &bi, &fi, 0, 0)) - return buf + bi; - - tm->tm_year -= 1900; - break; - - default: /* unrecognised */ - return buf + bi; - } /* switch (format[fi]) */ - - } - else - { /* if (percent) */ - if (format[fi] == '%') - { - percent = 1; - fi++; - } - else - { - if (format[fi] == buf[bi]) - { - fi++; - bi++; - } - else - return buf + bi; - } - } /* if (percent) */ - } /* while (format[fi] */ - - return buf + bi; -#else /* ! ACE_LACKS_NATIVE_STRPTIME */ - return ::strptime (buf, - format, - tm); -#endif /* ! ACE_LACKS_NATIVE_STRPTIME */ -#else /* ! ACE_HAS_WINCE */ - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (tm); - - ACE_NOTSUP_RETURN (0); -#endif /* ! ACE_HAS_WINCE */ -} - -# if defined (ACE_LACKS_NATIVE_STRPTIME) -int -ACE_OS::strptime_getnum (char *buf, - int *num, - int *bi, - int *fi, - int min, - int max) -{ - int i = 0, tmp = 0; - - while (isdigit (buf[i])) - { - tmp = (tmp * 10) + (buf[i] - '0'); - if (max && (tmp > max)) - return 0; - i++; - } - - if (tmp < min) - return 0; - else if (i) - { - *num = tmp; - (*fi)++; - *bi += i; - return 1; - } - else - return 0; -} -# endif /* ACE_LACKS_NATIVE_STRPTIME */ -#endif /* ACE_HAS_STRPTIME */ - -#if !defined (ACE_HAS_WINCE) -ACE_HANDLE -ACE_OS::accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen, - const ACE_Accept_QoS_Params &qos_params) -{ -# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen, - (LPCONDITIONPROC) qos_params.qos_condition_callback (), - qos_params.callback_data ()), - ACE_HANDLE, - ACE_INVALID_HANDLE); -# else - ACE_UNUSED_ARG (qos_params); - return ACE_OS::accept (handle, - addr, - addrlen); -# endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_HANDLE -ACE_OS::join_leaf (ACE_HANDLE socket, - const sockaddr *name, - int namelen, - const ACE_QoS_Params &qos_params) -{ -# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - - QOS qos; - // Construct the WinSock2 QOS structure. - - qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ()); - qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ()); - qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific (); - - ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket, - name, - namelen, - (WSABUF *) qos_params.caller_data (), - (WSABUF *) qos_params.callee_data (), - &qos, - (QOS *) qos_params.group_socket_qos (), - qos_params.flags ()), - ACE_HANDLE, - ACE_INVALID_HANDLE); - -# else - ACE_UNUSED_ARG (socket); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (namelen); - ACE_UNUSED_ARG (qos_params); - ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); -# endif /* ACE_HAS_WINSOCK2 */ -} - -int -ACE_OS::ioctl (ACE_HANDLE socket, - u_long io_control_code, - void *in_buffer_p, - u_long in_buffer, - void *out_buffer_p, - u_long out_buffer, - u_long *bytes_returned, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func) -{ -# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, - io_control_code, - in_buffer_p, - in_buffer, - out_buffer_p, - out_buffer, - bytes_returned, - (WSAOVERLAPPED *) overlapped, - func), - int, - SOCKET_ERROR); -# else - ACE_UNUSED_ARG (socket); - ACE_UNUSED_ARG (io_control_code); - ACE_UNUSED_ARG (in_buffer_p); - ACE_UNUSED_ARG (in_buffer); - ACE_UNUSED_ARG (out_buffer_p); - ACE_UNUSED_ARG (out_buffer); - ACE_UNUSED_ARG (bytes_returned); - ACE_UNUSED_ARG (overlapped); - ACE_UNUSED_ARG (func); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WINSOCK2 */ -} - - -int -ACE_OS::ioctl (ACE_HANDLE socket, - u_long io_control_code, - ACE_QoS &ace_qos, - u_long *bytes_returned, - void *buffer_p, - u_long buffer, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func) -{ -# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - - QOS qos; - u_long qos_len = sizeof (QOS); - - if (io_control_code == SIO_SET_QOS) - { - qos.SendingFlowspec = *(ace_qos.sending_flowspec ()); - qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ()); - qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific (); - - qos_len += ace_qos.provider_specific ().iov_len; - - ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, - io_control_code, - &qos, - qos_len, - buffer_p, - buffer, - bytes_returned, - (WSAOVERLAPPED *) overlapped, - func), - int, - SOCKET_ERROR); - } - else - { - u_long dwBufferLen = 0; - - // Query for the buffer size. - int result = ::WSAIoctl ((ACE_SOCKET) socket, - io_control_code, - NULL, - 0, - &dwBufferLen, - sizeof (dwBufferLen), - bytes_returned, - NULL, - NULL); - - - if (result == SOCKET_ERROR) - { - u_long dwErr = ::WSAGetLastError (); - - if (dwErr == WSAEWOULDBLOCK) - { - errno = dwErr; - return -1; - } - else - if (dwErr != WSAENOBUFS) - { - errno = dwErr; - return -1; - } - } - - char *qos_buf; - ACE_NEW_RETURN (qos_buf, - char [dwBufferLen], - -1); - - QOS *qos = ACE_reinterpret_cast (QOS*, - qos_buf); - - result = ::WSAIoctl ((ACE_SOCKET) socket, - io_control_code, - NULL, - 0, - qos, - dwBufferLen, - bytes_returned, - NULL, - NULL); - - if (result == SOCKET_ERROR) - return result; - - ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate, - qos->SendingFlowspec.TokenBucketSize, - qos->SendingFlowspec.PeakBandwidth, - qos->SendingFlowspec.Latency, - qos->SendingFlowspec.DelayVariation, -# if defined(ACE_HAS_WINSOCK2_GQOS) - qos->SendingFlowspec.ServiceType, - qos->SendingFlowspec.MaxSduSize, - qos->SendingFlowspec.MinimumPolicedSize, -# else /* ACE_HAS_WINSOCK2_GQOS */ - 0, - 0, - 0, -# endif /* ACE_HAS_WINSOCK2_GQOS */ - 0, - 0); - - ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate, - qos->ReceivingFlowspec.TokenBucketSize, - qos->ReceivingFlowspec.PeakBandwidth, - qos->ReceivingFlowspec.Latency, - qos->ReceivingFlowspec.DelayVariation, -# if defined(ACE_HAS_WINSOCK2_GQOS) - qos->ReceivingFlowspec.ServiceType, - qos->ReceivingFlowspec.MaxSduSize, - qos->ReceivingFlowspec.MinimumPolicedSize, -# else /* ACE_HAS_WINSOCK2_GQOS */ - 0, - 0, - 0, -# endif /* ACE_HAS_WINSOCK2_GQOS */ - 0, - 0); - - ace_qos.sending_flowspec (&sending_flowspec); - ace_qos.receiving_flowspec (&receiving_flowspec); - ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific))); - - - return result; - } - -# else - ACE_UNUSED_ARG (socket); - ACE_UNUSED_ARG (io_control_code); - ACE_UNUSED_ARG (ace_qos); - ACE_UNUSED_ARG (bytes_returned); - ACE_UNUSED_ARG (buffer_p); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (overlapped); - ACE_UNUSED_ARG (func); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WINSOCK2 */ -} - -int -ACE_OS::connect (ACE_HANDLE handle, - const sockaddr *addr, - int addrlen, - const ACE_QoS_Params &qos_params) -{ - ACE_OS_TRACE ("ACE_OS::connect"); -# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle, - (const sockaddr *) addr, - (ACE_SOCKET_LEN) addrlen, - (WSABUF *) qos_params.caller_data (), - (WSABUF *) qos_params.callee_data (), - (QOS *) qos_params.socket_qos (), - (QOS *) qos_params.group_socket_qos ()), - int, -1); -# else - ACE_UNUSED_ARG (qos_params); - return ACE_OS::connect (handle, - (sockaddr *) addr, - addrlen); -# endif /* ACE_HAS_WINSOCK2 */ -} -#endif // ACE_HAS_WINCE - -long -ACE_OS::num_processors (void) -{ - ACE_OS_TRACE ("ACE_OS::num_processors"); -#if defined (ACE_HAS_PHARLAP) - return 1; -#elif defined (ACE_WIN32) || defined (ACE_WIN64) - SYSTEM_INFO sys_info; - ::GetSystemInfo (&sys_info); - return sys_info.dwNumberOfProcessors; -#elif defined (linux) || defined (sun) - return ::sysconf (_SC_NPROCESSORS_CONF); -#else - ACE_NOTSUP_RETURN (-1); -#endif -} - -long -ACE_OS::num_processors_online (void) -{ - ACE_OS_TRACE ("ACE_OS::num_processors_online"); -#if defined (ACE_HAS_PHARLAP) - return 1; -#elif defined (ACE_WIN32) || defined (ACE_WIN64) - SYSTEM_INFO sys_info; - ::GetSystemInfo (&sys_info); - return sys_info.dwNumberOfProcessors; -#elif defined (linux) || defined (sun) - return ::sysconf (_SC_NPROCESSORS_ONLN); -#elif defined (__hpux) - struct pst_dynamic psd; - if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) - return psd.psd_proc_cnt; - else - return -1; -#else - ACE_NOTSUP_RETURN (-1); #endif -} - -// Include if_arp so that getmacaddr can use the -// arp structure. -#if defined (sun) -# include /**/ <net/if_arp.h> -#endif - -int -ACE_OS::getmacaddress (struct macaddr_node_t *node) -{ - ACE_OS_TRACE ("ACE_OS::getmacaddress"); - -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - - /** Define a structure for use with the netbios routine */ - struct ADAPTERSTAT - { - ADAPTER_STATUS adapt; - NAME_BUFFER NameBuff [30]; - }; - - NCB ncb; - LANA_ENUM lenum; - unsigned char result; - - ACE_OS::memset (&ncb, 0, sizeof(ncb)); - ncb.ncb_command = NCBENUM; - ncb.ncb_buffer = ACE_reinterpret_cast (unsigned char*,&lenum); - ncb.ncb_length = sizeof(lenum); - - result = Netbios (&ncb); - for(int i = 0; i < lenum.length; i++) - { - ACE_OS::memset (&ncb, 0, sizeof(ncb)); - ncb.ncb_command = NCBRESET; - ncb.ncb_lana_num = lenum.lana [i]; - - /** Reset the netbios */ - result = Netbios (&ncb); - - if (ncb.ncb_retcode != NRC_GOODRET) - { - return -1; - } - - ADAPTERSTAT adapter; - ACE_OS::memset (&ncb, 0, sizeof (ncb)); -# if defined (__BORLANDC__) || defined (__MINGW32__) - ACE_OS::strcpy (ACE_reinterpret_cast (char*, ncb.ncb_callname), "*"); -# else - ACE_OS::strcpy (ACE_static_cast (char*, ncb.ncb_callname), "*"); -# endif /* __BORLANDC__ || __MINGW32__ */ - ncb.ncb_command = NCBASTAT; - ncb.ncb_lana_num = lenum.lana[i]; - ncb.ncb_buffer = ACE_reinterpret_cast (unsigned char*, &adapter); - ncb.ncb_length = sizeof (adapter); - - result = Netbios (&ncb); - - if (result == 0) - { - ACE_OS::memcpy (node->node, - adapter.adapt.adapter_address, - 6); - return 0; - } - } - return 0; -#elif defined (sun) - - /** obtain the local host name */ - char hostname [MAXHOSTNAMELEN]; - ACE_OS::hostname (hostname, sizeof (hostname)); - - /** Get the hostent to use with ioctl */ - struct hostent *phost = - ACE_OS::gethostbyname (hostname); - - if (phost == 0) - { - return -1; - } - - ACE_HANDLE handle = - ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); - - if (handle == ACE_INVALID_HANDLE) - { - return -1; - } - - char **paddrs = phost->h_addr_list; - - struct arpreq ar; - - struct sockaddr_in *psa = - (struct sockaddr_in *)&(ar.arp_pa); - - ACE_OS::memset (&ar, - 0, - sizeof (struct arpreq)); - - psa->sin_family = AF_INET; - - ACE_OS::memcpy (&(psa->sin_addr), - *paddrs, - sizeof (struct in_addr)); - - if (ACE_OS::ioctl (handle, - SIOCGARP, - &ar) == -1) - { - return -1; - } - - ACE_OS::close (handle); - - ACE_OS::memcpy (node->node, - ar.arp_ha.sa_data, - 6); - - return 0; - -#elif defined (linux) - - struct ifreq ifr; - - ACE_HANDLE handle = - ACE_OS::socket (PF_INET, SOCK_DGRAM, 0); - - if (handle == ACE_INVALID_HANDLE) - { - return -1; - } - - ACE_OS::strcpy (ifr.ifr_name, "eth0"); - - if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0) - { - ACE_OS::close (handle); - return -1; - } - - struct sockaddr* sa = - (struct sockaddr *) &ifr.ifr_addr; - - ACE_OS::memcpy (node->node, - sa->sa_data, - 6); - - return 0; - -#else - ACE_UNUSED_ARG (node); - ACE_NOTSUP_RETURN (-1); -#endif -} +// include new cpps +#include "ace/Cleanup.cpp" +#include "ace/Object_Manager_Base.cpp" +#include "ace/OS_NS_arpa_inet.cpp" +#include "ace/OS_NS_ctype.cpp" +#include "ace/OS_NS_dirent.cpp" +#include "ace/OS_NS_dlfcn.cpp" +#include "ace/OS_NS_errno.cpp" +#include "ace/OS_NS_fcntl.cpp" +#include "ace/OS_NS_math.cpp" +#include "ace/OS_NS_netdb.cpp" +#include "ace/OS_NS_poll.cpp" +#include "ace/OS_NS_pwd.cpp" +#include "ace/OS_NS_regex.cpp" +#include "ace/OS_NS_signal.cpp" +#include "ace/OS_NS_stdio.cpp" +#include "ace/OS_NS_stdlib.cpp" +#include "ace/OS_NS_string.cpp" +#include "ace/OS_NS_strings.cpp" +#include "ace/OS_NS_stropts.cpp" +#include "ace/OS_NS_sys_mman.cpp" +#include "ace/OS_NS_sys_msg.cpp" +#include "ace/OS_NS_sys_resource.cpp" +#include "ace/OS_NS_sys_select.cpp" +#include "ace/OS_NS_sys_shm.cpp" +#include "ace/OS_NS_sys_socket.cpp" +#include "ace/OS_NS_sys_stat.cpp" +#include "ace/OS_NS_sys_time.cpp" +#include "ace/OS_NS_sys_uio.cpp" +#include "ace/OS_NS_sys_utsname.cpp" +#include "ace/OS_NS_sys_wait.cpp" +#include "ace/OS_NS_Thread.cpp" +#include "ace/OS_NS_time.cpp" +#include "ace/OS_NS_unistd.cpp" +#include "ace/OS_NS_wchar.cpp" @@ -19,14 +19,47 @@ #include "ace/config-all.h" -#if defined (ACE_HAS_VIRTUAL_TIME) -#include "ace/os_include/sys/os_times.h" -#endif /*ACE_HAS_VIRTUAL_TIME*/ - #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#if !defined (DO_NOT_INCLUDE_OS_H) +#include "ace/Cleanup.h" +#include "ace/Object_Manager_Base.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_NS_dirent.h" +#include "ace/OS_NS_dlfcn.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_math.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_poll.h" +#include "ace/OS_NS_pwd.h" +#include "ace/OS_NS_regex.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_stropts.h" +#include "ace/OS_NS_sys_mman.h" +#include "ace/OS_NS_sys_msg.h" +#include "ace/OS_NS_sys_resource.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_sys_shm.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_sys_uio.h" +#include "ace/OS_NS_sys_utsname.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/OS_NS_Thread.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_wchar.h" + // Include the split up ACE_OS classes #include "ace/OS_Dirent.h" #include "ace/OS_String.h" @@ -66,16 +99,18 @@ class ACE_Timeout_Manager; // // /////////////////////////////////////////// -# if defined (ACE_PSOS) +#include "ace/os_include/netinet/os_tcp.h" +#include "ace/os_include/sys/os_stat.h" +#include "ace/os_include/os_stropts.h" +#include "ace/os_include/os_unistd.h" +#include "ace/os_include/sys/os_wait.h" -# if defined (ACE_PSOSIM) -# include /**/ "ace/sys_conf.h" /* system configuration file */ +# if defined (ACE_PSOS) +# include /**/ "ace/sys_conf.h" /* system configuration file */ +# include /**/ <pna.h> /* pNA+ TCP/IP Network Manager calls */ +# if defined (ACE_PSOSIM) # include /**/ <psos.h> /* pSOS+ system calls */ -# include /**/ <pna.h> /* pNA+ TCP/IP Network Manager calls */ - - - /* include <rpc.h> pRPC+ Remote Procedure Call Library calls */ /* are not supported by pSOSim */ /* */ @@ -85,115 +120,17 @@ class ACE_Timeout_Manager; /* 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 "ace/os_include/sys/os_stat.h" -# include "ace/os_include/os_stropts.h" // instead of <sys/ioctl.h> -# include "ace/os_include/netinet/os_tcp.h" - # else - -# 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 "ace/os_include/os_unistd.h" /* Diab Data supplied file system calls */ -# else +# if !defined (ACE_PSOS_USES_DIAB_SYS_CALLS) # include /**/ <prepc.h> # endif /* ACE_PSOS_USES_DIAB_SYS_CALLS */ -# include "ace/os_include/sys/os_wait.h" /* Diab Data supplied header file */ # endif /* ACE_PSOS_DIAB_MIPS */ - # endif /* defined (ACE_PSOSIM) */ - -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 -{ - /// Semaphore handle. This is allocated by pSOS. - u_long sema_; - - /// Name of the semaphore: really a 32 bit number to pSOS - char name_[4]; -} ACE_sema_t; - -# define ACE_SEH_TRY if (1) -# define ACE_SEH_EXCEPT(X) while (0) -# define ACE_SEH_FINALLY if (1) - -#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) **********************************************/ // This needs to go here *first* to avoid problems with AIX. @@ -201,264 +138,6 @@ private: # include "ace/os_include/os_pthread.h" # endif /* ACE_HAS_PTHREADS */ -// By default we perform no tracing on the OS layer, otherwise the -// coupling between the OS layer and Log_Msg is too tight. But the -// application can override the default if they wish to. -# if !defined(ACE_OS_TRACE) -# define ACE_OS_TRACE(X) -# endif /* ACE_OS_TRACE */ - -# 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 */ - -/** - * @class ACE_Countdown_Time - * - * @brief Keeps track of the amount of elapsed time. - * - * This class has a side-effect on the <max_wait_time> -- every - * time the <stop> method is called the <max_wait_time> is - * updated. - */ -class ACE_OS_Export ACE_Countdown_Time -{ -public: - // = Initialization and termination methods. - /// Cache the <max_wait_time> and call <start>. - ACE_Countdown_Time (ACE_Time_Value *max_wait_time); - - /// Call <stop>. - ~ACE_Countdown_Time (void); - - /// Cache the current time and enter a start state. - int start (void); - - /// Subtract the elapsed time from max_wait_time_ and enter a stopped - /// state. - int stop (void); - - /// Calls stop and then start. max_wait_time_ is modified by the - /// call to stop. - int update (void); - - /// Returns 1 if we've already been stopped, else 0. - int stopped (void) const; - -private: - /// Maximum time we were willing to wait. - ACE_Time_Value *max_wait_time_; - - /// Beginning of the start time. - ACE_Time_Value start_time_; - - /// Keeps track of whether we've already been stopped. - int stopped_; -}; - -// The following is necessary since many C++ compilers don't support -// typedef'd types inside of classes used as formal template -// arguments... ;-(. Luckily, using the C++ preprocessor I can hide -// most of this nastiness! - -# if defined (ACE_HAS_TEMPLATE_TYPEDEFS) - -// Handle ACE_Message_Queue. -# define ACE_SYNCH_DECL class _ACE_SYNCH -# define ACE_SYNCH_USE _ACE_SYNCH -# define ACE_SYNCH_MUTEX_T ACE_TYPENAME _ACE_SYNCH::MUTEX -# define ACE_SYNCH_CONDITION_T ACE_TYPENAME _ACE_SYNCH::CONDITION -# define ACE_SYNCH_SEMAPHORE_T ACE_TYPENAME _ACE_SYNCH::SEMAPHORE - -// Handle ACE_Malloc* -# define ACE_MEM_POOL_1 class _ACE_MEM_POOL -# define ACE_MEM_POOL_2 _ACE_MEM_POOL -# define ACE_MEM_POOL _ACE_MEM_POOL -# define ACE_MEM_POOL_OPTIONS ACE_TYPENAME _ACE_MEM_POOL::OPTIONS - -// Handle ACE_Svc_Handler -# define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM -# define ACE_PEER_STREAM_2 _ACE_PEER_STREAM -# define ACE_PEER_STREAM _ACE_PEER_STREAM -# define ACE_PEER_STREAM_ADDR ACE_TYPENAME _ACE_PEER_STREAM::PEER_ADDR - -// Handle ACE_Acceptor -# define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR -# define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR -# define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR -# define ACE_PEER_ACCEPTOR_ADDR ACE_TYPENAME _ACE_PEER_ACCEPTOR::PEER_ADDR - -// Handle ACE_Connector -# define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR -# define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR -# define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR -# define ACE_PEER_CONNECTOR_ADDR ACE_TYPENAME _ACE_PEER_CONNECTOR::PEER_ADDR -# if !defined(ACE_HAS_TYPENAME_KEYWORD) -# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any -# else - // - // If the compiler supports 'typename' we cannot use - // - // PEER_CONNECTOR::PEER_ADDR::sap_any - // - // because PEER_CONNECTOR::PEER_ADDR is not considered a type. But: - // - // typename PEER_CONNECTOR::PEER_ADDR::sap_any - // - // will not work either, because now we are declaring sap_any a - // type, further: - // - // (typename PEER_CONNECTOR::PEER_ADDR)::sap_any - // - // is considered a casting expression. All I can think of is using a - // typedef, I tried PEER_ADDR but that was a source of trouble on - // some platforms. I will try: - // -# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_ADDR_TYPEDEF::sap_any -# endif /* ACE_HAS_TYPENAME_KEYWORD */ - -// Handle ACE_SOCK_* -# define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor -# define ACE_SOCK_CONNECTOR ACE_SOCK_Connector -# define ACE_SOCK_STREAM ACE_SOCK_Stream - -// Handle ACE_SOCK_SEQPACK_* -# define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor -# define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector -# define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association - -// Handle ACE_MEM_* -# define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor -# define ACE_MEM_CONNECTOR ACE_MEM_Connector -# define ACE_MEM_STREAM ACE_MEM_Stream - -// Handle ACE_LSOCK_* -# define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor -# define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector -# define ACE_LSOCK_STREAM ACE_LSOCK_Stream - -// Handle ACE_TLI_* -# define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor -# define ACE_TLI_CONNECTOR ACE_TLI_Connector -# define ACE_TLI_STREAM ACE_TLI_Stream - -// Handle ACE_SPIPE_* -# define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor -# define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector -# define ACE_SPIPE_STREAM ACE_SPIPE_Stream - -// Handle ACE_UPIPE_* -# define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor -# define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector -# define ACE_UPIPE_STREAM ACE_UPIPE_Stream - -// Handle ACE_FILE_* -# define ACE_FILE_CONNECTOR ACE_FILE_Connector -# define ACE_FILE_STREAM ACE_FILE_IO - -// Handle ACE_*_Memory_Pool. -# define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool -# define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool -# define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool -# define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool -# define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool -# define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool - -# else /* TEMPLATES are broken in some form or another (i.e., most C++ compilers) */ - -// Handle ACE_Message_Queue. -# if defined (ACE_HAS_OPTIMIZED_MESSAGE_QUEUE) -# define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T, class _ACE_SYNCH_SEMAPHORE_T -# define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T, _ACE_SYNCH_SEMAPHORE_T -# else -# define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T -# define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T -# endif /* ACE_HAS_OPTIMIZED_MESSAGE_QUEUE */ -# define ACE_SYNCH_MUTEX_T _ACE_SYNCH_MUTEX_T -# define ACE_SYNCH_CONDITION_T _ACE_SYNCH_CONDITION_T -# define ACE_SYNCH_SEMAPHORE_T _ACE_SYNCH_SEMAPHORE_T - -// Handle ACE_Malloc* -# define ACE_MEM_POOL_1 class _ACE_MEM_POOL, class _ACE_MEM_POOL_OPTIONS -# define ACE_MEM_POOL_2 _ACE_MEM_POOL, _ACE_MEM_POOL_OPTIONS -# define ACE_MEM_POOL _ACE_MEM_POOL -# define ACE_MEM_POOL_OPTIONS _ACE_MEM_POOL_OPTIONS - -// Handle ACE_Svc_Handler -# define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM, class _ACE_PEER_ADDR -# define ACE_PEER_STREAM_2 _ACE_PEER_STREAM, _ACE_PEER_ADDR -# define ACE_PEER_STREAM _ACE_PEER_STREAM -# define ACE_PEER_STREAM_ADDR _ACE_PEER_ADDR - -// Handle ACE_Acceptor -# define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR, class _ACE_PEER_ADDR -# define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR, _ACE_PEER_ADDR -# define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR -# define ACE_PEER_ACCEPTOR_ADDR _ACE_PEER_ADDR - -// Handle ACE_Connector -# define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR, class _ACE_PEER_ADDR -# define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR, _ACE_PEER_ADDR -# define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR -# define ACE_PEER_CONNECTOR_ADDR _ACE_PEER_ADDR -# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any - -// Handle ACE_SOCK_* -# define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor, ACE_INET_Addr -# define ACE_SOCK_CONNECTOR ACE_SOCK_Connector, ACE_INET_Addr -# define ACE_SOCK_STREAM ACE_SOCK_Stream, ACE_INET_Addr - -// Handle ACE_SOCK_SEQPACK_* -# define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor, ACE_Multihomed_INET_Addr -# define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector, ACE_Multihomed_INET_Addr -# define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association, ACE_Multihomed_INET_Addr - -// Handle ACE_MEM_* -# define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor, ACE_MEM_Addr -# define ACE_MEM_CONNECTOR ACE_MEM_Connector, ACE_INET_Addr -# define ACE_MEM_STREAM ACE_MEM_Stream, ACE_INET_Addr - -// Handle ACE_LSOCK_* -# define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor, ACE_UNIX_Addr -# define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector, ACE_UNIX_Addr -# define ACE_LSOCK_STREAM ACE_LSOCK_Stream, ACE_UNIX_Addr - -// Handle ACE_TLI_* -# define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor, ACE_INET_Addr -# define ACE_TLI_CONNECTOR ACE_TLI_Connector, ACE_INET_Addr -# define ACE_TLI_STREAM ACE_TLI_Stream, ACE_INET_Addr - -// Handle ACE_SPIPE_* -# define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor, ACE_SPIPE_Addr -# define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector, ACE_SPIPE_Addr -# define ACE_SPIPE_STREAM ACE_SPIPE_Stream, ACE_SPIPE_Addr - -// Handle ACE_UPIPE_* -# define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor, ACE_SPIPE_Addr -# define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector, ACE_SPIPE_Addr -# define ACE_UPIPE_STREAM ACE_UPIPE_Stream, ACE_SPIPE_Addr - -// Handle ACE_FILE_* -# define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr -# define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr - -// Handle ACE_*_Memory_Pool. -# define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options -# define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options -# define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool, ACE_Sbrk_Memory_Pool_Options -# define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool, ACE_Shared_Memory_Pool_Options -# define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool, ACE_Local_Memory_Pool_Options -# define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool, ACE_Pagefile_Memory_Pool_Options -# endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ - # if defined (ACE_HAS_PROC_FS) # include /**/ <sys/procfs.h> # endif /* ACE_HAS_PROC_FS */ @@ -467,650 +146,12 @@ private: # include "ace/os_include/os_semaphore.h" # endif /* ACE_HAS_POSIX_SEM */ -# include "ace/os_include/sys/os_types.h" // /**/ <types.h> - -# include "ace/os_include/os_stddef.h" // WinCE .NET puts it in stddef.h +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_stddef.h" #if !defined (ACE_LACKS_UNISTD_H) # include "ace/os_include/os_unistd.h" #endif /* ACE_LACKS_UNISTD_H */ -#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 */ - -# 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) -// moved to pthread.h -# 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) -# include /**/ <sysLib.h> // for sysClkRateGet() -# include /**/ <taskLib.h> -# include /**/ <taskHookLib.h> - -// make sure these are included for VXWORKS. -// @todo move these to a common place, perhaps the top of the file. -#include "ace/os_include/os_fcntl.h" -#include "ace/os_include/os_netdb.h" -#include "ace/os_include/os_semaphore.h" -#include "ace/os_include/os_signal.h" -#include "ace/os_include/os_stdio.h" -#include "ace/os_include/os_stdlib.h" -#include "ace/os_include/os_stropts.h" -#include "ace/os_include/os_unistd.h" -#include "ace/os_include/arpa/os_inet.h" -#include "ace/os_include/sys/os_select.h" -#include "ace/os_include/sys/os_socket.h" - -// 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 -{ - /// Semaphore handle. This is allocated by VxWorks. - SEM_ID sema_; - - /// Name of the semaphore: always NULL with VxWorks. - char *name_; -} 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 CRITICAL_SECTION ACE_thread_mutex_t; - -typedef struct -{ - /// Either USYNC_THREAD or USYNC_PROCESS - int type_; - union - { - HANDLE proc_mutex_; - CRITICAL_SECTION thr_mutex_; - }; -} ACE_mutex_t; - -// Wrapper for NT Events. -typedef HANDLE ACE_event_t; - -# if defined (ACE_WIN32) -//@@ 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 */ -# endif /* defined (ACE_WIN32) */ - -// 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 we're using PACE then we don't want this class (since PACE -// takes care of it) unless we're on Windows. Win32 mutexes, semaphores, -// and condition variables are not yet supported in PACE. -# if defined (ACE_LACKS_COND_T) -/** - * @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 */ - -// Recursive mutex support. -// -// There are two parts to this: -// 1. The mutex type itself. This is based on whether or not the -// platform supports recursive mutexes natively or they're emulated. -// 2. Support for using the recursive mutex with a condition variable. -// When a thread waits on a condition variable, it has to relinquish -// the lock and wait atomically, then reacquire it after the condition -// variable is signaled. In non-recursive mutexes, the platform -// handles this automatically. But in recursive mutexes, especially -// when emulated, the recursion count needs to be maintained across -// the wait. Since another thread needs to be able to acquire the -// lock, it needs to appear free, even if the waiting thread had done -// multiple acquires. Thus, there's another structure to hold this -// information, and is used with the recursive_mutex_cond_unlock() -// and recursive_mutex_cond_relock() methods to maintain the expected -// state when the wait finishes. -#if defined (ACE_HAS_RECURSIVE_MUTEXES) -typedef ACE_thread_mutex_t ACE_recursive_thread_mutex_t; -# if defined (ACE_WIN32) -// Windows has recursive mutexes, but doesn't have condition variables, -// so there's no built-in support for this. Thus, the condition-related -// unlock/relock is augmented in ACE. -struct ACE_recursive_mutex_state -{ - // On Windows the augmented processing is simply unlocking/relocking - // the recursive locks - the condition handles a single lock ok. - LONG relock_count_; -}; -# else -// No need for special handling; just need a type for method signatures. -typedef int ACE_recursive_mutex_state; -# endif /* ACE_WIN32 */ -#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_; -}; - -// Since recursive mutex is emulated, the state saving needs to be handled -// in ACE as well. These members save those from ACE_recursive_thread_mutex_t. -struct ACE_recursive_mutex_state -{ - int nesting_level_; - ACE_thread_t owner_id_; -}; -#endif /* ACE_HAS_RECURSIVE_MUTEXES */ - -# 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; -typedef int ACE_recursive_mutex_state; -# 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 unsigned 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_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 */ - // Standard C Library includes // NOTE: stdarg.h must be #included before stdio.h on LynxOS. # include "ace/os_include/os_stdarg.h" @@ -1162,11 +203,6 @@ protected: # endif /* ACE_HAS_BYTESEX_H */ # include "ace/Basic_Types.h" -// Type-safe, and unsigned. -static const ACE_UINT32 ACE_U_ONE_SECOND_IN_MSECS = 1000U; -static const ACE_UINT32 ACE_U_ONE_SECOND_IN_USECS = 1000000U; -static const ACE_UINT32 ACE_U_ONE_SECOND_IN_NSECS = 1000000000U; - # if defined (ACE_HAS_UTIME) # include "ace/os_include/os_utime.h" # endif /* ACE_HAS_UTIME */ @@ -1177,39 +213,10 @@ static const ACE_UINT32 ACE_U_ONE_SECOND_IN_NSECS = 1000000000U; # include "ace/os_include/sys/os_timeb.h" # endif /* ACE_HAS_WINCE */ -# if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) -# define ACE_SEH_TRY if (1) -# define ACE_SEH_EXCEPT(X) while (0) -# define ACE_SEH_FINALLY if (1) -# elif defined(__BORLANDC__) -# if (__BORLANDC__ >= 0x0530) /* Borland C++ Builder 3.0 */ -# define ACE_SEH_TRY try -# define ACE_SEH_EXCEPT(X) __except(X) -# define ACE_SEH_FINALLY __finally -# else -# define ACE_SEH_TRY if (1) -# define ACE_SEH_EXCEPT(X) while (0) -# define ACE_SEH_FINALLY if (1) -# endif -# elif defined (__IBMCPP__) && (__IBMCPP__ >= 400) -# define ACE_SEH_TRY if (1) -# define ACE_SEH_EXCEPT(X) while (0) -# define ACE_SEH_FINALLY if (1) -# else -# define ACE_SEH_TRY __try -# define ACE_SEH_EXCEPT(X) __except(X) -# define ACE_SEH_FINALLY __finally -# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ - -// The "null" device on Win32. -# define ACE_DEV_NULL "nul" - # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) # include "ace/os_include/netinet/os_in.h" // <ws2tcpip.h> # endif /* ACE_HAS_WINSOCK2 */ - - # if !defined (ACE_HAS_WINCE) # include "ace/os_include/os_time.h" # include "ace/os_include/sys/os_stat.h" // <direct.h> @@ -1218,126 +225,8 @@ static const ACE_UINT32 ACE_U_ONE_SECOND_IN_NSECS = 1000000000U; # include "ace/os_include/os_fcntl.h" -typedef DWORD ACE_thread_t; -typedef HANDLE ACE_hthread_t; - -# 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 */ - -# if !defined (ACE_LACKS_LONGLONG_T) -// 64-bit quad-word definitions. -typedef unsigned __int64 ACE_QWORD; -typedef unsigned __int64 ACE_hrtime_t; -inline ACE_QWORD ACE_MAKE_QWORD (DWORD lo, DWORD hi) { return ACE_QWORD (lo) | (ACE_QWORD (hi) << 32); } -inline DWORD ACE_LOW_DWORD (ACE_QWORD q) { return (DWORD) q; } -inline DWORD ACE_HIGH_DWORD (ACE_QWORD q) { return (DWORD) (q >> 32); } -# else -// Can't find ANY place that ACE_QWORD is used, but hrtime_t is. -typedef ACE_UINT64 ACE_hrtime_t; -# endif // ACE_LACKS_LONGLONG_T - -// Win32 dummies to help compilation. - -// These are used in SPIPE_Acceptor/Connector, but are ignored at runtime. -# if defined (ACE_HAS_WINCE) -# if !defined (PIPE_TYPE_MESSAGE) -# define PIPE_TYPE_MESSAGE 0 -# endif -# if !defined (PIPE_READMODE_MESSAGE) -# define PIPE_READMODE_MESSAGE 0 -# endif -# if !defined (PIPE_WAIT) -# define PIPE_WAIT 0 -# endif -# endif /* ACE_HAS_WINCE */ - -# define ACE_SYSCALL_FAILED 0xFFFFFFFF - -// Needed to map calls to NT transparently. -# define MS_ASYNC 0 -# define MS_INVALIDATE 0 - -// Reliance on CRT - I don't really like this. - - -typedef int ACE_idtype_t; -typedef DWORD ACE_id_t; -# define ACE_SELF (0) -typedef int ACE_pri_t; - -# elif defined (ACE_PSOS) - -typedef ACE_UINT64 ACE_hrtime_t; - # else /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */ -# if defined (m88k) -# define RUSAGE_SELF 1 -# endif /* m88k */ - -// Be consistent with Winsock naming -# define ACE_INVALID_HANDLE -1 -# define ACE_SYSCALL_FAILED -1 - -# define ACE_SEH_TRY if (1) -# define ACE_SEH_EXCEPT(X) while (0) -# define ACE_SEH_FINALLY if (1) - -// The "null" device on UNIX. -# define ACE_DEV_NULL "/dev/null" - -/** - * @class ACE_event_t - * - * @brief 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. - unsigned long waiting_threads_; -}; - - -# if defined (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 - // 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 *); -# else /* ! (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 */ -# include "ace/os_include/arpa/os_inet.h" -# endif /* ! (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 */ - -# 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 "ace/os_include/netinet/os_tcp.h" -# endif /* ACE_LACKS_TCP_H */ - # if defined (CHORUS) # include /**/ <chorus.h> # if !defined(CHORUS_4) @@ -1354,15 +243,7 @@ protected: # include "ace/os_include/sys/os_wait.h" # include "ace/os_include/os_pwd.h" # include /**/ <timer/chBench.h> -extern_C int getgid __((void)); -extern_C int getuid __((void)); -extern_C char* getcwd __((char* buf, size_t size)); -extern_C int pipe __((int* fildes)); -extern_C int gethostname __((char*, size_t)); -# if !defined(CHORUS_4) -typedef void (*__sighandler_t)(int); // keep Signal compilation happy -# endif # elif defined (CYGWIN32) # include "ace/os_include/sys/os_uio.h" # include "ace/os_include/os_fcntl.h" // <sys/file.h> @@ -1380,9 +261,6 @@ typedef void (*__sighandler_t)(int); // keep Signal compilation happy // sets O_NDELAY # include /**/ <unix.h> # include "ace/os_include/os_limits.h" // <sys/param.h> /* for NBBY */ -# if !defined (NFDBITS) -# define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ -# endif /* ! NFDBITS */ # elif defined(__rtems__) # include "ace/os_include/os_fcntl.h" // <sys/file.h> # include "ace/os_include/sys/os_resource.h" @@ -1392,11 +270,6 @@ typedef void (*__sighandler_t)(int); // keep Signal compilation happy # include "ace/os_include/sys/os_wait.h" # include "ace/os_include/os_pwd.h" -extern "C" -{ - int select (int n, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, const struct timeval *timeout); -}; # elif ! defined (VXWORKS) && ! defined (INTEGRITY) # include "ace/os_include/sys/os_uio.h" # include "ace/os_include/sys/os_ipc.h" @@ -1433,18 +306,6 @@ extern "C" # endif /* HPUX */ # endif /* ACE_HAS_TERM_IOCTLS */ -#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 */ - # if defined (ACE_HAS_AIO_CALLS) # include "ace/os_include/os_aio.h" # endif /* ACE_HAS_AIO_CALLS */ @@ -1467,730 +328,26 @@ extern "C" # include "ace/os_include/os_poll.h" # endif /* ACE_HAS_POLL */ -# if defined (ACE_HAS_STREAMS) -# if defined (AIX) -# if !defined (_XOPEN_EXTENDED_SOURCE) -# define _XOPEN_EXTENDED_SOURCE -# endif /* !_XOPEN_EXTENDED_SOURCE */ -# include "ace/os_include/os_stropts.h" -# undef _XOPEN_EXTENDED_SOURCE -# else -# include "ace/os_include/os_stropts.h" -# endif /* AIX */ -# endif /* ACE_HAS_STREAMS */ - -# 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_HAS_SELECT_H) # include "ace/os_include/sys/os_select.h" # endif /* ACE_HAS_SELECT_H */ -// 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 */ - # include "ace/os_include/sys/os_msg.h" # if defined (ACE_HAS_PRIOCNTL) # include /**/ <sys/priocntl.h> # endif /* ACE_HAS_PRIOCNTL */ -# if defined (ACE_HAS_IDTYPE_T) - typedef idtype_t ACE_idtype_t; -# else - typedef int ACE_idtype_t; -# endif /* ACE_HAS_IDTYPE_T */ - -# if defined (ACE_HAS_STHREADS) || defined (DIGITAL_UNIX) -# if defined (ACE_LACKS_PRI_T) - typedef int pri_t; -# endif /* ACE_LACKS_PRI_T */ - typedef id_t ACE_id_t; -# define ACE_SELF P_MYID - typedef pri_t ACE_pri_t; -# else /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */ - typedef long ACE_id_t; -# define ACE_SELF (-1) - typedef short ACE_pri_t; -# endif /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */ - -# if defined (ACE_HAS_HI_RES_TIMER) && !defined (ACE_LACKS_LONGLONG_T) - /* hrtime_t is defined on systems (Suns) with ACE_HAS_HI_RES_TIMER */ - typedef hrtime_t ACE_hrtime_t; -# else /* ! ACE_HAS_HI_RES_TIMER || ACE_LACKS_LONGLONG_T */ - typedef ACE_UINT64 ACE_hrtime_t; -# endif /* ! ACE_HAS_HI_RES_TIMER || ACE_LACKS_LONGLONG_T */ - # endif /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */ -# if !defined (ACE_DEFAULT_SYNCH_TYPE) -# define ACE_DEFAULT_SYNCH_TYPE USYNC_THREAD -# endif /* ! ACE_DEFAULT_SYNCH_TYPE */ - -# 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 (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 -# include "ace/os_include/sys/os_utsname.h" -typedef struct utsname ACE_utsname; -# endif /* ACE_LACKS_UTSNAME_T */ - - -# if !defined (O_NONBLOCK) -# define O_NONBLOCK 1 -# endif /* O_NONBLOCK */ - -# 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 (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 */ - -# 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 (__Lynx__) - // LynxOS Neutrino sets NSIG to the highest-numbered signal. -# define ACE_NSIG (NSIG + 1) -# elif defined (__rtems__) -# define ACE_NSIG (SIGRTMAX) -# elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x600) -# define ACE_NSIG _NSIG -# else - // All other platforms set NSIG to one greater than the - // highest-numbered signal. -# define ACE_NSIG NSIG -# endif /* __Lynx__ */ - -# 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 */ - - - - -// Create some useful typedefs. - -typedef const char **SYS_SIGLIST; - -# 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 */ - -# if defined (ACE_HAS_CHARPTR_DL) -typedef ACE_TCHAR * ACE_DL_TYPE; -# else -typedef const ACE_TCHAR * ACE_DL_TYPE; -# endif /* ACE_HAS_CHARPTR_DL */ - -# if !defined (ACE_HAS_SIGINFO_T) -struct ACE_OS_Export siginfo_t -{ - siginfo_t (ACE_HANDLE handle); - siginfo_t (ACE_HANDLE *handles); // JCEJ 12/23/96 - - /// Win32 HANDLE that has become signaled. - ACE_HANDLE si_handle_; - - /// Array of Win32 HANDLEs all of which have become signaled. - ACE_HANDLE *si_handles_; -}; -# 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 */ - -/** - * @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); - - void to_string (char*); - - - // != 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_; -}; - -// Type of the extended signal handler. -typedef void (*ACE_Sig_Handler_Ex) (int, siginfo_t *siginfo, ucontext_t *ucontext); - -// = The ACE_Sched_Priority type should be used for platform- -// independent thread and process priorities, by convention. -// int should be used for OS-specific priorities. -typedef int ACE_Sched_Priority; - -// forward declaration -class ACE_Sched_Params; - -# if defined (ACE_LACKS_FILELOCKS) -# if ! defined (VXWORKS) && ! defined (ACE_PSOS) && ! defined (__rtems__) && !defined (INTEGRITY) -// 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 */ - -# if !defined (ACE_HAS_IP_MULTICAST) && defined (ACE_LACKS_IP_ADD_MEMBERSHIP) - // Even if ACE_HAS_IP_MULTICAST is not defined, if IP_ADD_MEMBERSHIP - // is defined, assume that the ip_mreq struct is also defined - // (presumably in netinet/in.h). - struct ip_mreq - { - /// IP multicast address of group - struct in_addr imr_multiaddr; - /// Local IP address of interface - struct in_addr imr_interface; - }; -# endif /* ! ACE_HAS_IP_MULTICAST && ACE_LACKS_IP_ADD_MEMBERSHIP */ - -# if !defined (ACE_HAS_STRBUF_T) -struct strbuf -{ - /// No. of bytes in buffer. - int maxlen; - /// No. of bytes returned. - int len; - /// Pointer to data. - void *buf; -}; -# endif /* ACE_HAS_STRBUF_T */ - -/** - * @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); - - /// Constructor. - ACE_Str_Buf (strbuf &); -}; - -# if defined (ACE_HAS_BROKEN_BITSHIFT) - // This might not be necessary any more: it was added prior to the - // (fd_mask) cast being added to the version below. Maybe that cast - // will fix the problem on tandems. Fri Dec 12 1997 David L. Levine -# define ACE_MSB_MASK (~(ACE_UINT32 (1) << ACE_UINT32 (NFDBITS - 1))) -# else - // This needs to go here to avoid overflow problems on some compilers. -# if defined (ACE_WIN32) - // Does ACE_WIN32 have an fd_mask? -# define ACE_MSB_MASK (~(1 << (NFDBITS - 1))) -# else /* ! ACE_WIN32 */ -# define ACE_MSB_MASK (~((fd_mask) 1 << (NFDBITS - 1))) -# endif /* ! ACE_WIN32 */ -# endif /* ACE_HAS_BROKEN_BITSHIFT */ - -# if defined (ACE_WIN32) -// Default WIN32 structured exception handler. -int ACE_SEH_Default_Exception_Selector (void *); -int ACE_SEH_Default_Exception_Handler (void *); -# endif /* ACE_WIN32 */ - -/** - * @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_Base_Thread_Adapter; -class ACE_Thread_Hook; - -# 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_LACKS_FLOATING_POINT) -typedef ACE_UINT32 ACE_timer_t; -# else -typedef double ACE_timer_t; -# endif /* ACE_LACKS_FLOATING_POINT */ - -# 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_WIN32) && !defined (ACE_LACKS_UNIX_SYSLOG) # include "ace/os_include/os_syslog.h" # endif /* !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SYSLOG) */ -# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && !defined (__BORLANDC__) - typedef struct _stat ACE_stat; -# else - typedef struct stat ACE_stat; -# endif /* ACE_WIN32 */ - -// We need this for MVS... -extern "C" { - typedef int (*ACE_COMPARE_FUNC)(const void *, const void *); -} - -#if defined (ACE_HAS_WINCE) -// WinCE doesn't have most of the standard C library time functions. It -// also doesn't define struct tm. SYSTEMTIME has pretty much the same -// info though, so we can map it when needed. Define struct tm here and -// use it when needed. This is taken from the standard C library. -struct tm { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; // Day of the month - int tm_mon; - int tm_year; - int tm_wday; // Day of the week - int tm_yday; // Day in the year - int tm_isdst; // >0 if dst in effet; 0 if not; <0 if unknown -}; -#endif /* ACE_HAS_WINCE */ - - -/// Helper for the ACE_OS::timezone() function -/** - * We put all the timezone stuff that used to be in ACE_OS::timezone() - * here because on some platforms "timezone" is a macro. Because of this, - * the name ACE_OS::timezone will cause errors. So in order to use the - * macro as it is defined but also keep the name ACE_OS::timezone, we - * use timezone first here in this inline function, and then undefine - * timezone. - */ -inline long ace_timezone() -{ -#if !defined (VXWORKS) && !defined (ACE_PSOS) && !defined (CHORUS) -# if defined (ACE_HAS_WINCE) - TIME_ZONE_INFORMATION tz; - GetTimeZoneInformation (&tz); - return tz.Bias * 60; -# elif defined (ACE_WIN32) - return _timezone; // For Win32. -# elif ( defined (__Lynx__) || defined (__FreeBSD__) || defined (ACE_HAS_SUNOS4_GETTIMEOFDAY) ) && ( !defined (__linux__) ) - long result = 0; - struct timeval time; - struct timezone zone; - ACE_UNUSED_ARG (result); - ACE_OSCALL (::gettimeofday (&time, &zone), int, -1, result); - return zone.tz_minuteswest * 60; -# else /* __Lynx__ || __FreeBSD__ ... */ -# if defined (__linux__) - // Under Linux, gettimeofday() does not correctly set the timezone - // struct, so we should use the global variable <timezone>. - // However, it is initialized by tzset(). I assume other systems - // are the same (i.e., tzset() needs to be called to set - // <timezone>), but since no one is complaining, I will only make - // the change for Linux. - ::tzset(); -# endif - return timezone; -# endif /* __Lynx__ || __FreeBSD__ ... */ -#else - ACE_NOTSUP_RETURN (0); -#endif /* !ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS */ -} - - -#if !defined (ACE_LACKS_DIFFTIME) -/// Helper for the ACE_OS::difftime() function /** - * We moved the difftime code that used to be in ACE_OS::difftime() - * here because on some platforms "difftime" is a macro. Because of this, - * the name ACE_OS::difftime will cause errors. So in order to use the - * macro as it is defined but also keep the name ACE_OS::difftime, we - * use difftime first here in this inline function, and then undefine - * it. - */ -inline double ace_difftime(time_t t1, time_t t0) -{ -# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) - // simulate difftime ; just subtracting ; ACE_PSOS case - return ((double)t1) - ((double)t0); -# else - return difftime (t1, t0); -# endif /* ACE_PSOS !ACE_PSOS_HAS_TIME */ -} -#endif /* !ACE_LACKS_DIFFTIME */ - - -/// Helper for the ACE_OS::cuserid() function -/** - * On some platforms cuserid is a macro. Defining ACE_OS::cuserid() - * becomes really hard, as there is no way to save the macro - * definition using the pre-processor. - * This inline function achieves the same effect, without namespace - * pollution or performance penalties. + * @namespace ACE_OS * - * @todo We maybe should move a lot of the code in ACE_OS::cuserid here so - * it is treated the same as the above ace_difftime and ace_timezone. - * But since there is a good deal more code in ACE_OS::cuserid, we - * probably need to move some of it off into some sort of emulation - * function. - */ -#if !defined (ACE_LACKS_CUSERID) && !defined(ACE_HAS_ALT_CUSERID) \ - && !defined(ACE_WIN32) && !defined (VXWORKS) -inline char *ace_cuserid(char *user) -{ - return cuserid(user); -} -#endif /* !ACE_LACKS_CUSERID && !ACE_HAS_ALT_CUSERID && ... */ - -#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_WINCE) -// forward declarations of QoS data structures -class ACE_QoS; -class ACE_QoS_Params; -class ACE_Accept_QoS_Params; -#endif // ACE_HAS_WINCE - -#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_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) */ -/** - * On some platforms clearerr is a macro. Defining ACE_OS::clearerr() - * becomes really hard, as there is no way to save the macro - * definition using the pre-processor. - */ -#if !defined (ACE_LACKS_CLEARERR) -#if defined (clearerr) -#define __ace_clearerr_hack -inline void __ace_clearerr(FILE *stream) -{ - clearerr(stream); -} -#undef clearerr -#endif /* defined (clearerr) */ -#endif /* !ACE_LACKS_CLEARERR */ - -/** - * @class ACE_OS - * - * @brief This class defines an OS independent programming API that + * @brief This namespace defines an OS independent programming API that * shields developers from nonportable aspects of writing * efficient system programs on Win32, POSIX and other versions * of UNIX, and various real-time operating systems. @@ -2204,2223 +361,15 @@ inline void __ace_clearerr(FILE *stream) * in this directory for complete information on the meaning of * the various macros. */ -class ACE_OS_Export ACE_OS - : public ACE_OS_Dirent, - public ACE_OS_String, - public ACE_OS_Memory, - public ACE_OS_TLI +namespace ACE_OS { - ACE_CLASS_IS_NAMESPACE (ACE_OS); -public: - friend class ACE_Timeout_Manager; - -# if defined (CHORUS) && !defined (CHORUS_4) - // We must format this code as follows to avoid confusing OSE. - enum ACE_HRTimer_Op - { - ACE_HRTIMER_START = K_BSTART, - ACE_HRTIMER_INCR = K_BPOINT, - ACE_HRTIMER_STOP = K_BSTOP, - ACE_HRTIMER_GETTIME = 0xFFFF - }; -# else /* ! CHORUS */ - enum ACE_HRTimer_Op - { - ACE_HRTIMER_START = 0x0, // Only use these if you can stand - ACE_HRTIMER_INCR = 0x1, // for interrupts to be disabled during - ACE_HRTIMER_STOP = 0x2, // the timed interval!!!! - ACE_HRTIMER_GETTIME = 0xFFFF - }; -# endif /* ! CHORUS */ - - /** - * @class ace_flock_t - * - * @brief OS file locking structure. - */ - class ACE_OS_Export ace_flock_t - { - public: - /// Dump state of the object. - void dump (void) const; - -# 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 */ - }; - -# if defined (ACE_WIN32) - // = Default Win32 Security Attributes definition. - static LPSECURITY_ATTRIBUTES default_win32_security_attributes (LPSECURITY_ATTRIBUTES); - - // = Win32 OS version determination function. - /// Return the win32 OSVERSIONINFO structure. - static const OSVERSIONINFO &get_win32_versioninfo (void); - - // = A pair of functions for modifying ACE's Win32 resource usage. - /// Return the handle of the module containing ACE's resources. By - /// default, for a DLL build of ACE this is a handle to the ACE DLL - /// itself, and for a static build it is a handle to the executable. - static HINSTANCE get_win32_resource_module (void); - - /// Allow an application to modify which module contains ACE's - /// resources. This is mainly useful for a static build of ACE where - /// the required resources reside somewhere other than the executable. - static void set_win32_resource_module (HINSTANCE); - -# endif /* ACE_WIN32 */ // = A set of wrappers for miscellaneous operations. - static int atoi (const char *s); - - struct macaddr_node_t { - unsigned char node[6]; - }; - - /** - * Get the first adapter found on the machine. - */ - static int getmacaddress (struct macaddr_node_t *node); - -# if defined (ACE_HAS_WCHAR) - static int atoi (const wchar_t *s); -# endif /* ACE_HAS_WCHAR */ - -#if defined (atop) -#undef atop -#endif /* atop */ - - static void *atop (const char *s); - -# if defined (ACE_HAS_WCHAR) - static void *atop (const wchar_t *s); -# endif /* ACE_HAS_WCHAR */ - - /// This method computes the largest integral value not greater than x. - static double floor (double x); - - /// This method computes the smallest integral value not less than x. - static double ceil (double x); - - static char *getenv (const char *symbol); -# if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32) - static wchar_t *getenv (const wchar_t *symbol); -# endif /* ACE_HAS_WCHAR && ACE_WIN32 */ - static int putenv (const ACE_TCHAR *string); - static ACE_TCHAR *strenvdup (const ACE_TCHAR *str); - static ACE_TCHAR *getenvstrings (void); - - static int getopt (int argc, - char *const *argv, - const char *optstring); - static int argv_to_string (ACE_TCHAR **argv, - ACE_TCHAR *&buf, - int substitute_env_args = 1); - static int string_to_argv (ACE_TCHAR *buf, - int &argc, - ACE_TCHAR **&argv, - int substitute_env_args = 1); - static long sysconf (int); - - //@{ @name A set of wrappers for condition variables. - static int condattr_init (ACE_condattr_t &attributes, - int type = ACE_DEFAULT_SYNCH_TYPE); - static int condattr_destroy (ACE_condattr_t &attributes); - static int cond_broadcast (ACE_cond_t *cv); - static int cond_destroy (ACE_cond_t *cv); - static int cond_init (ACE_cond_t *cv, - short type = ACE_DEFAULT_SYNCH_TYPE, - const char *name = 0, - void *arg = 0); - static int cond_init (ACE_cond_t *cv, - ACE_condattr_t &attributes, - const char *name = 0, - void *arg = 0); -# if defined (ACE_HAS_WCHAR) - static int cond_init (ACE_cond_t *cv, - short type, - const wchar_t *name, - void *arg = 0); - static int cond_init (ACE_cond_t *cv, - ACE_condattr_t &attributes, - const wchar_t *name, - void *arg = 0); -# endif /* ACE_HAS_WCHAR */ - static int cond_signal (ACE_cond_t *cv); - static int cond_timedwait (ACE_cond_t *cv, - ACE_mutex_t *m, - ACE_Time_Value *); - static int cond_wait (ACE_cond_t *cv, - ACE_mutex_t *m); -# if defined (ACE_WIN32) && defined (ACE_HAS_WTHREADS) - static int cond_timedwait (ACE_cond_t *cv, - ACE_thread_mutex_t *m, - ACE_Time_Value *); - static int cond_wait (ACE_cond_t *cv, - ACE_thread_mutex_t *m); -# endif /* ACE_WIN32 && ACE_HAS_WTHREADS */ - //@} - - - //@{ @name Wrappers to obtain the current user id -# if !defined (ACE_LACKS_CUSERID) -#if defined(cuserid) -# undef cuserid -#endif /* cuserid */ - static char *cuserid (char *user, - size_t maxlen = ACE_MAX_USERID); - -# if defined (ACE_HAS_WCHAR) - static wchar_t *cuserid (wchar_t *user, - size_t maxlen = ACE_MAX_USERID); -# endif /* ACE_HAS_WCHAR */ -# endif /* ACE_LACKS_CUSERID */ - //@} - - //@{ @name Wrappers to obtain configuration info - static int uname (ACE_utsname *name); - static long sysinfo (int cmd, - char *buf, - long count); - static int hostname (char *name, - size_t maxnamelen); - -#if defined (ACE_HAS_WCHAR) - static int hostname (wchar_t *name, - size_t maxnamelen); -#endif /* ACE_HAS_WCHAR */ - //@} - - //@{ @name A set of wrappers for explicit dynamic linking. - static int dlclose (ACE_SHLIB_HANDLE handle); - - static ACE_TCHAR *dlerror (void); - static ACE_SHLIB_HANDLE dlopen (const ACE_TCHAR *filename, - int mode = ACE_DEFAULT_SHLIB_MODE); - static void *dlsym (ACE_SHLIB_HANDLE handle, - const ACE_TCHAR *symbol); - //@} - - //@{ @name A set of wrappers for stdio file operations. - static int last_error (void); - static void last_error (int); - static int set_errno_to_last_error (void); - static int set_errno_to_wsa_last_error (void); - static int fclose (FILE *fp); - static int fcntl (ACE_HANDLE handle, - int cmd, - long arg = 0); - static int fdetach (const char *file); - - static int fsync (ACE_HANDLE handle); - -# if defined (ACE_USES_WCHAR) - // If fp points to the Unicode format file, the file pointer will be moved right next - // to the Unicode header (2 types). Otherwise, file pointer will be at the beginning. - static void checkUnicodeFormat (FILE* fp); -# endif // ACE_USES_WCHAR - - static FILE *fopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode); - static FILE *freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream); -# if defined (fdopen) -# undef fdopen -# endif /* fdopen */ - static FILE *fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode); - static ACE_TCHAR *fgets (ACE_TCHAR *buf, int size, FILE *fp); - static int stat (const ACE_TCHAR *file, ACE_stat *); - static int truncate (const ACE_TCHAR *filename, off_t length); - - static int fprintf (FILE *fp, const char *format, ...); - static int sprintf (char *buf, const char *format, ...); - static int snprintf (char *buf, size_t maxlen, const char *format, ...); - static int vsprintf (char *buffer, const char *format, va_list argptr); - static int printf (const char *format, ...); -# if defined (ACE_HAS_WCHAR) - static int sprintf (wchar_t *buf, const wchar_t *format, ...); - static int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...); - static int fprintf (FILE *fp, const wchar_t *format, ...); - static int vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr); -# endif /* ACE_HAS_WCHAR */ - - static void perror (const ACE_TCHAR *s); - - // The old gets () which directly maps to the evil, unprotected - // gets () has been deprecated. If you really need gets (), - // consider the following one. - - // A better gets (). - // If n == 0, input is swallowed, but NULL is returned. - // Otherwise, reads up to n-1 bytes (not including the newline), - // then swallows rest up to newline - // then swallows newline - static char *gets (char *str, int n = 0); - static int puts (const ACE_TCHAR *s); - static int fputs (const ACE_TCHAR *s, - FILE *stream); - - static int fflush (FILE *fp); - static size_t fread (void *ptr, - size_t size, - size_t nelems, - FILE *fp); - - static int fgetc (FILE* fp); - -#if !defined (ACE_LACKS_CLEARERR) - static void clearerr (FILE* fp); -#endif /* !ACE_LACKS_CLEARERR */ - -#if defined (ACE_HAS_WCHAR) - static wint_t fgetwc (FILE* fp); - static wint_t ungetwc (wint_t c, FILE* fp); -#endif /* ACE_HAS_WCHAR */ - - static int fseek (FILE *fp, - long offset, - int ptrname); - static long ftell (FILE* fp); - static int fgetpos (FILE* fp, fpos_t* pos); - static int fsetpos (FILE* fp, fpos_t* pos); - static int fstat (ACE_HANDLE, - ACE_stat *); - static int lstat (const char *, - ACE_stat *); - static int ftruncate (ACE_HANDLE, - off_t); - static size_t fwrite (const void *ptr, - size_t size, - size_t nitems, - FILE *fp); - static void rewind (FILE *fp); - //@} - - //@{ @name Wrappers for searching and sorting. - static void *bsearch (const void *key, - const void *base, - size_t nel, - size_t size, - ACE_COMPARE_FUNC); - static void qsort (void *base, - size_t nel, - size_t width, - ACE_COMPARE_FUNC); - //@} - - //@{ @name A set of wrappers for file locks. - static int flock_init (ACE_OS::ace_flock_t *lock, - int flags = 0, - const ACE_TCHAR *name = 0, - mode_t perms = 0); - static int flock_destroy (ACE_OS::ace_flock_t *lock, - int unlink_file = 1); -# if defined (ACE_WIN32) - static void adjust_flock_params (ACE_OS::ace_flock_t *lock, - short whence, - off_t &start, - off_t &len); -# endif /* ACE_WIN32 */ - static int flock_rdlock (ACE_OS::ace_flock_t *lock, - short whence = 0, - off_t start = 0, - off_t len = 0); - static int flock_tryrdlock (ACE_OS::ace_flock_t *lock, - short whence = 0, - off_t start = 0, - off_t len = 0); - static int flock_trywrlock (ACE_OS::ace_flock_t *lock, - short whence = 0, - off_t start = 0, - off_t len = 0); - static int flock_unlock (ACE_OS::ace_flock_t *lock, - short whence = 0, - off_t start = 0, - off_t len = 0); - static int flock_wrlock (ACE_OS::ace_flock_t *lock, - short whence = 0, - off_t start = 0, - off_t len = 0); - //@} - - //@{ @name A set of wrappers for low-level process operations. - static int atexit (ACE_EXIT_HOOK func); - static int execl (const char *path, - const char *arg0, ...); - static int execle (const char *path, - const char *arg0, ...); - static int execlp (const char *file, - const char *arg0, ...); - static int execv (const char *path, - char *const argv[]); - static int execvp (const char *file, - char *const argv[]); - static int execve (const char *path, - char *const argv[], - char *const envp[]); - static void _exit (int status = 0); - static void exit (int status = 0); - static void abort (void); - static pid_t fork (void); - - static int getpagesize (void); - static int allocation_granularity (void); - - static gid_t getgid (void); - static int setgid (gid_t); - static pid_t getpid (void); - static pid_t getpgid (pid_t pid); - static pid_t getppid (void); - static uid_t getuid (void); - static int setuid (uid_t); - static pid_t setsid (void); - static int setpgid (pid_t pid, pid_t pgid); - static int setreuid (uid_t ruid, uid_t euid); - static int setregid (gid_t rgid, gid_t egid); - static int system (const ACE_TCHAR *s); - //@} - - //@{ - /// Forks and exec's a process in a manner that works on Solaris and - /// NT. argv[0] must be the full path name to the executable. - static pid_t fork (const ACE_TCHAR *program_name); - static pid_t fork_exec (ACE_TCHAR *argv[]); - //@} - - /** - * Calls <::waitpid> on UNIX/POSIX platforms and <::await> on - * Chorus. Does not work on Vxworks, or pSoS. - * On Win32, <pid> is ignored if the <handle> is not equal to 0. - * Passing the process <handle> is prefer on Win32 because using - * <pid> to wait on the project doesn't always work correctly - * if the waited process has already terminated. - */ - static pid_t waitpid (pid_t pid, - ACE_exitcode *status = 0, - int wait_options = 0, - ACE_HANDLE handle = 0); - - /** - * Calls <::WaitForSingleObject> on Win32 and <ACE::waitpid> - * otherwise. Returns the passed in <pid_t> on success and -1 on - * failure. - * On Win32, <pid> is ignored if the <handle> is not equal to 0. - * Passing the process <handle> is prefer on Win32 because using - * <pid> to wait on the project doesn't always work correctly - * if the waited process has already terminated. - */ - static pid_t wait (pid_t pid, - ACE_exitcode *status, - int wait_options = 0, - ACE_HANDLE handle = 0); - - /// Calls OS <::wait> function, so it's only portable to UNIX/POSIX - /// platforms. - static pid_t wait (int * = 0); - - //@{ @name A set of wrappers for timers and resource stats. - static u_int alarm (u_int secs); - static u_int ualarm (u_int usecs, - u_int interval = 0); - static u_int ualarm (const ACE_Time_Value &tv, - const ACE_Time_Value &tv_interval = ACE_Time_Value::zero); - static ACE_hrtime_t gethrtime (const ACE_HRTimer_Op = ACE_HRTIMER_GETTIME); -# if defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__)) - static void readPPCTimeBase (u_long &most, - u_long &least); -# endif /* ACE_HAS_POWERPC_TIMER && (ghs or __GNUG__) */ - static int clock_gettime (clockid_t, - struct timespec *); - static ACE_Time_Value gettimeofday (void); - static int getrusage (int who, - struct rusage *rusage); - static int getrlimit (int resource, - struct rlimit *rl); - static int setrlimit (int resource, - ACE_SETRLIMIT_TYPE *rl); - static int sleep (u_int seconds); - static int sleep (const ACE_Time_Value &tv); - static int nanosleep (const struct timespec *requested, - struct timespec *remaining = 0); - -# if defined (ACE_HAS_BROKEN_R_ROUTINES) -# undef ctime_r -# undef asctime_r -# undef rand_r -# undef getpwnam_r -# endif /* ACE_HAS_BROKEN_R_ROUTINES */ - //@} - - //@{ @name A set of wrappers for operations on time. - - // Get the current time. - static time_t mktime (struct tm *timeptr); - - // wrapper for time zone information. - static void tzset (void); - -# if defined (timezone) -# undef timezone -# endif /* timezone */ - static long timezone (void); - -# if defined (difftime) -# undef difftime -# endif /* difftime */ - static double difftime (time_t t1, - time_t t0); - static time_t time (time_t *tloc = 0); - static struct tm *localtime (const time_t *clock); - static struct tm *localtime_r (const time_t *clock, - struct tm *res); - static struct tm *gmtime (const time_t *clock); - static struct tm *gmtime_r (const time_t *clock, - struct tm *res); - static char *asctime (const struct tm *tm); - static char *asctime_r (const struct tm *tm, - char *buf, int buflen); - static ACE_TCHAR *ctime (const time_t *t); - static ACE_TCHAR *ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen); - static size_t strftime (char *s, - size_t maxsize, - const char *format, - const struct tm *timeptr); - //@} - - //@{ @name A set of wrappers for System V message queues. - static int msgctl (int msqid, - int cmd, - struct msqid_ds *); - static int msgget (key_t key, - int msgflg); - static int msgrcv (int int_id, - void *buf, - size_t len, - long type, - int flags); - static int msgsnd (int int_id, - const void *buf, - size_t len, - int flags); - //@} - - //@{ @name A set of wrappers for memory mapped files. - static int madvise (caddr_t addr, - size_t len, - int map_advice); - static void *mmap (void *addr, - size_t len, - int prot, - int flags, - ACE_HANDLE handle, - off_t off = 0, - ACE_HANDLE *file_mapping = 0, - LPSECURITY_ATTRIBUTES sa = 0, - const ACE_TCHAR *file_mapping_name = 0); - static int mprotect (void *addr, - size_t len, - int prot); - static int msync (void *addr, - size_t len, - int sync); - static int munmap (void *addr, - size_t len); - //@} - - //@{ @name A set of wrappers for recursive mutex locks. - static int recursive_mutex_init (ACE_recursive_thread_mutex_t *m, - const ACE_TCHAR *name = 0, - ACE_mutexattr_t *arg = 0, - LPSECURITY_ATTRIBUTES sa = 0); - static int recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m); - static int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m); - static int recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m); - static int recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m); - // These two methods are primarily in support of - // ACE_Condition<ACE_Recursive_Thread_Mutex> and should probably not - // be called outside that context. - static int recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, - ACE_recursive_mutex_state &state); - static void recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, - ACE_recursive_mutex_state &state); - //@} - - //@{ @name A set of wrappers for mutex locks. - static int mutex_init (ACE_mutex_t *m, - int type = ACE_DEFAULT_SYNCH_TYPE, - const char *name = 0, - ACE_mutexattr_t *arg = 0, - LPSECURITY_ATTRIBUTES sa = 0); -#if defined (ACE_HAS_WCHAR) - static int mutex_init (ACE_mutex_t *m, - int type, - const wchar_t *name, - ACE_mutexattr_t *arg = 0, - LPSECURITY_ATTRIBUTES sa = 0); -#endif /* ACE_HAS_WCHAR */ - static int mutex_destroy (ACE_mutex_t *m); - - /// Win32 note: Abandoned mutexes are not treated differently. 0 is - /// returned since the calling thread does get the ownership. - static int mutex_lock (ACE_mutex_t *m); - - /// This method is only implemented for Win32. For abandoned - /// mutexes, <abandoned> is set to 1 and 0 is returned. - static int mutex_lock (ACE_mutex_t *m, - int &abandoned); - - /** - * This method attempts to acquire a lock, but gives up if the lock - * has not been acquired by the given time. If the lock is not - * acquired within the given amount of time, then this method - * returns -1 with an <ETIME> errno on platforms that actually - * support timed mutexes. The timeout should be an absolute time. - * Note that the mutex should not be a recursive one, i.e., it - * should only be a standard mutex or an error checking mutex. - */ - static int mutex_lock (ACE_mutex_t *m, - const ACE_Time_Value &timeout); - - /** - * If <timeout> == 0, calls <ACE_OS::mutex_lock(m)>. Otherwise, - * this method attempts to acquire a lock, but gives up if the lock - * has not been acquired by the given time, in which case it returns - * -1 with an <ETIME> errno on platforms that actually support timed - * mutexes. The timeout should be an absolute time. Note that the - * mutex should not be a recursive one, i.e., it should only be a - * standard mutex or an error checking mutex. - */ - static int mutex_lock (ACE_mutex_t *m, - const ACE_Time_Value *timeout); - - /// Win32 note: Abandoned mutexes are not treated differently. 0 is - /// returned since the calling thread does get the ownership. - static int mutex_trylock (ACE_mutex_t *m); - - /// This method is only implemented for Win32. For abandoned - /// mutexes, <abandoned> is set to 1 and 0 is returned. - static int mutex_trylock (ACE_mutex_t *m, - int &abandoned); - - static int mutex_unlock (ACE_mutex_t *m); - //@} - - //@{ @name A set of wrappers for mutex locks that only work within a single process. - static int thread_mutex_init (ACE_thread_mutex_t *m, - int type = ACE_DEFAULT_SYNCH_TYPE, - const char *name = 0, - ACE_mutexattr_t *arg = 0); -#if defined (ACE_HAS_WCHAR) - static int thread_mutex_init (ACE_thread_mutex_t *m, - int type, - const wchar_t *name, - ACE_mutexattr_t *arg = 0); -#endif /* ACE_HAS_WCHAR */ - static int thread_mutex_destroy (ACE_thread_mutex_t *m); - static int thread_mutex_lock (ACE_thread_mutex_t *m); - static int thread_mutex_lock (ACE_thread_mutex_t *m, - const ACE_Time_Value &timeout); - static int thread_mutex_lock (ACE_thread_mutex_t *m, - const ACE_Time_Value *timeout); - static int thread_mutex_trylock (ACE_thread_mutex_t *m); - static int thread_mutex_unlock (ACE_thread_mutex_t *m); - //@} - - //@{ @name A set of wrappers for low-level file operations. - static int access (const char *path, int amode); -#if defined (ACE_HAS_WCHAR) - static int access (const wchar_t *path, int amode); -#endif /* ACE_HAS_WCHAR */ - - static int close (ACE_HANDLE handle); - static ACE_HANDLE creat (const ACE_TCHAR *filename, - mode_t mode); - static ACE_HANDLE dup (ACE_HANDLE handle); - static int dup2 (ACE_HANDLE oldfd, - ACE_HANDLE newfd); - static int fattach (int handle, - const char *path); - static long filesize (ACE_HANDLE handle); - static long filesize (const ACE_TCHAR *handle); - static int getmsg (ACE_HANDLE handle, - struct strbuf *ctl, - struct strbuf - *data, int *flags); - static int getpmsg (ACE_HANDLE handle, - struct strbuf *ctl, - struct strbuf - *data, - int *band, - int *flags); - - /// UNIX-style <ioctl>. - static int ioctl (ACE_HANDLE handle, - int cmd, - void * = 0); - -#if !defined (ACE_HAS_WINCE) - /// QoS-enabled <ioctl>. - static int ioctl (ACE_HANDLE socket, - u_long io_control_code, - void *in_buffer_p, - u_long in_buffer, - void *out_buffer_p, - u_long out_buffer, - u_long *bytes_returned, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func); - - /// QoS-enabled <ioctl> when the I/O control code is either - /// SIO_SET_QOS or SIO_GET_QOS. - static int ioctl (ACE_HANDLE socket, - u_long io_control_code, - ACE_QoS &ace_qos, - u_long *bytes_returned, - void *buffer_p = 0, - u_long buffer = 0, - ACE_OVERLAPPED *overlapped = 0, - ACE_OVERLAPPED_COMPLETION_FUNC func = 0); -#endif // ACE_HAS_WINCE - - static int isastream (ACE_HANDLE handle); - static int isatty (int handle); -#if defined (ACE_WIN32) - static int isatty (ACE_HANDLE handle); -#endif /* ACE_WIN32 */ - static off_t lseek (ACE_HANDLE handle, - off_t offset, - int whence); -#if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64) - static ACE_LOFF_T llseek (ACE_HANDLE handle, ACE_LOFF_T offset, int whence); -#endif /* ACE_HAS_LLSEEK */ - - // It used to be that the <perms> argument default was 0 on all - // platforms. Further, the ACE_OS::open implementations ignored <perms> - // for Win32 and always supplied read|write|delete. To preserve - // backward compatibility and allow users to pass in values - // that are used as desired, the defaults are now what the default - // action used to be on Win32. The implementation now obeys what is passed. -#if defined (ACE_WIN32) -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1) -# define ACE_DEFAULT_OPEN_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE | \ - FILE_SHARE_DELETE) -# else -# define ACE_DEFAULT_OPEN_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE) -# endif /* ACE_HAS_WINCE */ -#else -# define ACE_DEFAULT_OPEN_PERMS 0 -#endif /* ACE_WIN32 */ - - /// The O_APPEND flag is only partly supported on Win32. If you specify - /// O_APPEND, then the file pointer will be positioned at the end of - /// the file initially during open, but it is not re-positioned at - /// the end prior to each write, as specified by POSIX. This - /// is generally good enough for typical situations, but it is ``not - /// quite right'' in its semantics. - static ACE_HANDLE open (const char *filename, - int mode, - int perms = ACE_DEFAULT_OPEN_PERMS, - LPSECURITY_ATTRIBUTES sa = 0); -#if defined (ACE_HAS_WCHAR) - static ACE_HANDLE open (const wchar_t *filename, - int mode, - int perms = ACE_DEFAULT_OPEN_PERMS, - LPSECURITY_ATTRIBUTES sa = 0); -#endif /* ACE_HAS_WCHAR */ - static int putmsg (ACE_HANDLE handle, - const struct strbuf *ctl, - const struct strbuf *data, - int flags); - static int putpmsg (ACE_HANDLE handle, - const struct strbuf *ctl, - const struct strbuf *data, - int band, - int flags); - static ssize_t read (ACE_HANDLE handle, - void *buf, - size_t len); - static ssize_t read (ACE_HANDLE handle, - void *buf, - size_t len, - ACE_OVERLAPPED *); - /** - * Receive <len> bytes into <buf> from <handle> (uses the - * <ACE_OS::read> call, which uses the <read> system call on UNIX - * and the <ReadFile> call on Win32). If errors occur, -1 is - * returned. If EOF occurs, 0 is returned. Whatever data has been - * read will be returned to the caller through<bytes_transferred>. - * - */ - static ssize_t read_n (ACE_HANDLE handle, - void *buf, - size_t len, - size_t *bytes_transferred = 0); - - static int readlink (const char *path, - char *buf, - size_t bufsiz); - static ssize_t pread (ACE_HANDLE handle, - void *buf, - size_t nbyte, - off_t offset); - static int recvmsg (ACE_HANDLE handle, - struct msghdr *msg, - int flags); - static int sendmsg (ACE_HANDLE handle, - const struct msghdr *msg, - int flags); - static ssize_t write (ACE_HANDLE handle, - const void *buf, - size_t nbyte); - static ssize_t write (ACE_HANDLE handle, - const void *buf, - size_t nbyte, - ACE_OVERLAPPED *); - - /** - * Send <len> bytes from <buf> to <handle> (uses the <ACE_OS::write> - * calls, which is uses the <write> system call on UNIX and the - * <WriteFile> call on Win32). If errors occur, -1 is returned. If - * EOF occurs, 0 is returned. Whatever data has been transmitted - * will be returned to the caller through <bytes_transferred>. - */ - static ssize_t write_n (ACE_HANDLE handle, - const void *buf, - size_t len, - size_t *bytes_transferred = 0); - - static ssize_t pwrite (ACE_HANDLE handle, - const void *buf, - size_t nbyte, - off_t offset); - static ssize_t readv (ACE_HANDLE handle, - iovec *iov, - int iovlen); - static ssize_t writev (ACE_HANDLE handle, - const iovec *iov, - int iovcnt); - static ssize_t recvv (ACE_HANDLE handle, - iovec *iov, - int iovlen); - static ssize_t sendv (ACE_HANDLE handle, - const iovec *iov, - int iovcnt); - //@} - - //@{ @name A set of wrappers for event demultiplexing and IPC. - static int select (int width, - fd_set *rfds, - fd_set *wfds = 0, - fd_set *efds = 0, - const ACE_Time_Value *tv = 0); - static int select (int width, - fd_set *rfds, - fd_set *wfds, - fd_set *efds, - const ACE_Time_Value &tv); - static int poll (struct pollfd *pollfds, - u_long len, - const ACE_Time_Value *tv = 0); - static int poll (struct pollfd *pollfds, - u_long len, - const ACE_Time_Value &tv); - static int pipe (ACE_HANDLE handles[]); - - static ACE_HANDLE shm_open (const ACE_TCHAR *filename, - int mode, - int perms = 0, - LPSECURITY_ATTRIBUTES sa = 0); - static int shm_unlink (const ACE_TCHAR *path); - //@} - - //@{ @name A set of wrappers for directory operations. - static mode_t umask (mode_t cmask); - -#if !defined (ACE_LACKS_CHDIR) - static int chdir (const char *path); - -#if defined (ACE_HAS_WCHAR) - static int chdir (const wchar_t *path); -#endif /* ACE_HAS_WCHAR */ -#endif /* ACE_LACKS_CHDIR */ - - static int mkdir (const ACE_TCHAR *path, - mode_t mode = ACE_DEFAULT_DIR_PERMS); - static int mkfifo (const ACE_TCHAR *file, - mode_t mode = ACE_DEFAULT_FILE_PERMS); - static ACE_TCHAR *mktemp (ACE_TCHAR *t); - static ACE_HANDLE mkstemp (ACE_TCHAR *t); - static ACE_TCHAR *getcwd (ACE_TCHAR *, size_t); - static int rename (const ACE_TCHAR *old_name, - const ACE_TCHAR *new_name, - int flags = -1); - static int unlink (const ACE_TCHAR *path); - static ACE_TCHAR *tempnam (const ACE_TCHAR *dir = 0, - const ACE_TCHAR *pfx = 0); - //@} - - //@{ @name A set of wrappers for random number operations. - static int rand (void); - static int rand_r (ACE_RANDR_TYPE &seed); - static void srand (u_int seed); - //@} - - //@{ @name A set of wrappers for readers/writer locks. - static int rwlock_init (ACE_rwlock_t *rw, - int type = ACE_DEFAULT_SYNCH_TYPE, - const ACE_TCHAR *name = 0, - void *arg = 0); - static int rwlock_destroy (ACE_rwlock_t *rw); - static int rw_rdlock (ACE_rwlock_t *rw); - static int rw_wrlock (ACE_rwlock_t *rw); - static int rw_tryrdlock (ACE_rwlock_t *rw); - static int rw_trywrlock (ACE_rwlock_t *rw); - static int rw_trywrlock_upgrade (ACE_rwlock_t *rw); - static int rw_unlock (ACE_rwlock_t *rw); - //@} - - //@{ @name A set of wrappers for auto-reset and manual events. - static int event_init (ACE_event_t *event, - int manual_reset = 0, - int initial_state = 0, - int type = ACE_DEFAULT_SYNCH_TYPE, - const char *name = 0, - void *arg = 0, - LPSECURITY_ATTRIBUTES sa = 0); -# if defined (ACE_HAS_WCHAR) - static int event_init (ACE_event_t *event, - int manual_reset, - int initial_state, - int type, - const wchar_t *name, - void *arg = 0, - LPSECURITY_ATTRIBUTES sa = 0); -# endif /* ACE_HAS_WCHAR */ - static int event_destroy (ACE_event_t *event); - static int event_wait (ACE_event_t *event); - static int event_timedwait (ACE_event_t *event, - ACE_Time_Value *timeout, - int use_absolute_time = 1); - static int event_signal (ACE_event_t *event); - static int event_pulse (ACE_event_t *event); - static int event_reset (ACE_event_t *event); - //@} - - //@{ @name A set of wrappers for semaphores. - static int sema_destroy (ACE_sema_t *s); - static int sema_init (ACE_sema_t *s, - u_int count, - int type = ACE_DEFAULT_SYNCH_TYPE, - const char *name = 0, - void *arg = 0, - int max = 0x7fffffff, - LPSECURITY_ATTRIBUTES sa = 0); -# if defined (ACE_HAS_WCHAR) - static int sema_init (ACE_sema_t *s, - u_int count, - int type, - const wchar_t *name, - void *arg = 0, - int max = 0x7fffffff, - LPSECURITY_ATTRIBUTES sa = 0); -# endif /* ACE_HAS_WCHAR */ - static int sema_post (ACE_sema_t *s); - static int sema_post (ACE_sema_t *s, - u_int release_count); - static int sema_trywait (ACE_sema_t *s); - static int sema_wait (ACE_sema_t *s); - static int sema_wait (ACE_sema_t *s, - ACE_Time_Value &tv); - static int sema_wait (ACE_sema_t *s, - ACE_Time_Value *tv); - //@} - - //@{ @name A set of wrappers for System V semaphores. - static int semctl (int int_id, - int semnum, - int cmd, - semun); - static int semget (key_t key, - int nsems, - int flags); - static int semop (int int_id, - struct sembuf *sops, - size_t nsops); - //@} - - //@{ @name Thread scheduler interface. - /// Set scheduling parameters. An id of ACE_SELF indicates, e.g., - /// set the parameters on the calling thread. - static int sched_params (const ACE_Sched_Params &, ACE_id_t id = ACE_SELF); - //@} - - //@{ @name A set of wrappers for System V shared memory. - static void *shmat (int int_id, - void *shmaddr, - int shmflg); - static int shmctl (int int_id, - int cmd, - struct shmid_ds *buf); - static int shmdt (void *shmaddr); - static int shmget (key_t key, - int size, - int flags); - ///@} - - //@{ @name A set of wrappers for Signals. - static int kill (pid_t pid, - int signum); - static int sigaction (int signum, - const struct sigaction *nsa, - struct sigaction *osa); - static int sigaddset (sigset_t *s, - int signum); - static int sigdelset (sigset_t *s, - int signum); - static int sigemptyset (sigset_t *s); - static int sigfillset (sigset_t *s); - static int sigismember (sigset_t *s, - int signum); - static ACE_SignalHandler signal (int signum, - ACE_SignalHandler); - static int sigsuspend (const sigset_t *set); - static int sigprocmask (int how, - const sigset_t *nsp, - sigset_t *osp); - - static int pthread_sigmask (int how, - const sigset_t *nsp, - sigset_t *osp); - //@} - - //@{ @name A set of wrappers for sockets. - /// BSD-style <accept> (no QoS). - static ACE_HANDLE accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen); - -#if !defined (ACE_HAS_WINCE) - /** - * QoS-enabled <accept>, which passes <qos_params> to <accept>. If - * the OS platform doesn't support QoS-enabled <accept> then the - * <qos_params> are ignored and the BSD-style <accept> is called. - */ - static ACE_HANDLE accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen, - const ACE_Accept_QoS_Params &qos_params); -#endif // ACE_HAS_WINCE - - /// BSD-style <connect> (no QoS). - static int connect (ACE_HANDLE handle, - struct sockaddr *addr, - int addrlen); - -#if !defined (ACE_HAS_WINCE) - /** - * QoS-enabled <connect>, which passes <qos_params> to <connect>. - * If the OS platform doesn't support QoS-enabled <connect> then the - * <qos_params> are ignored and the BSD-style <connect> is called. - */ - static int connect (ACE_HANDLE handle, - const sockaddr *addr, - int addrlen, - const ACE_QoS_Params &qos_params); -#endif // ACE_HAS_WINCE - - static int bind (ACE_HANDLE s, - struct sockaddr *name, - int namelen); - - static int closesocket (ACE_HANDLE s); - static struct hostent *gethostbyaddr (const char *addr, - int length, - int type); - static struct hostent *gethostbyname (const char *name); - static struct hostent *getipnodebyname (const char *name, int family, - int flags = 0); - static struct hostent *getipnodebyaddr (const void *src, size_t len, - int family); - static struct hostent *gethostbyaddr_r (const char *addr, - int length, - int type, - struct hostent *result, - ACE_HOSTENT_DATA buffer, - int *h_errnop); - static struct hostent *gethostbyname_r (const char *name, - struct hostent *result, - ACE_HOSTENT_DATA buffer, - int *h_errnop); - static int getpeername (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen); - static struct protoent *getprotobyname (const char *name); - static struct protoent *getprotobyname_r (const char *name, - struct protoent *result, - ACE_PROTOENT_DATA buffer); - static struct protoent *getprotobynumber (int proto); - static struct protoent *getprotobynumber_r (int proto, - struct protoent *result, - ACE_PROTOENT_DATA buffer); - static struct servent *getservbyname (const char *svc, - const char *proto); - static struct servent *getservbyname_r (const char *svc, - const char *proto, - struct servent *result, - ACE_SERVENT_DATA buf); - static int getsockname (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen); - static int getsockopt (ACE_HANDLE handle, - int level, - int optname, - char *optval, - int *optlen); - static unsigned long inet_addr (const char *name); - static char *inet_ntoa (const struct in_addr addr); - static int inet_aton (const char *strptr, - struct in_addr *addr); - static const char *inet_ntop (int family, - const void *addrptr, - char *strptr, - size_t len); - static int inet_pton (int family, - const char *strptr, - void *addrptr); - /// Retrieve information about available transport protocols - /// installed on the local machine. - static int enum_protocols (int *protocols, - ACE_Protocol_Info *protocol_buffer, - u_long *buffer_length); - -#if !defined (ACE_HAS_WINCE) - /// Joins a leaf node into a QoS-enabled multi-point session. - static ACE_HANDLE join_leaf (ACE_HANDLE socket, - const sockaddr *name, - int namelen, - const ACE_QoS_Params &qos_params); -#endif // ACE_HAS_WINCE - - static int listen (ACE_HANDLE handle, - int backlog); - static int recv (ACE_HANDLE handle, - char *buf, - size_t len, - int flags = 0); - static int recvfrom (ACE_HANDLE handle, - char *buf, - size_t len, - int flags, - struct sockaddr *addr, - int *addrlen); - static int recvfrom (ACE_HANDLE handle, - iovec *buffers, - int buffer_count, - size_t &number_of_bytes_recvd, - int &flags, - struct sockaddr *addr, - int *addrlen, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func); - static int send (ACE_HANDLE handle, - const char *buf, - size_t len, - int flags = 0); - static int sendto (ACE_HANDLE handle, - const char *buf, - size_t len, - int flags, - const struct sockaddr *addr, - int addrlen); - static int sendto (ACE_HANDLE handle, - const iovec *buffers, - int buffer_count, - size_t &number_of_bytes_sent, - int flags, - const struct sockaddr *addr, - int addrlen, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func); - - /// Manipulate the options associated with a socket. - static int setsockopt (ACE_HANDLE handle, - int level, - int optname, - const char *optval, - int optlen); - static int shutdown (ACE_HANDLE handle, - int how); - - /// Create a BSD-style socket (no QoS). - static ACE_HANDLE socket (int protocol_family, - int type, - int proto); - - /// Create a QoS-enabled socket. If the OS platform doesn't support - /// QoS-enabled <socket> then the BSD-style <socket> is called. - static ACE_HANDLE socket (int protocol_family, - int type, - int proto, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags); - - static int socketpair (int domain, - int type, - int protocol, - ACE_HANDLE sv[2]); - - /// Initialize WinSock before first use (e.g., when a DLL is first - /// loaded or the first use of a socket() call. - static int socket_init (int version_high = 1, - int version_low = 1); - - /// Finalize WinSock after last use (e.g., when a DLL is unloaded). - static int socket_fini (void); - //@} - - //@{ @name A set of wrappers for password routines. - static void setpwent (void); - static void endpwent (void); - static struct passwd *getpwent (void); - static struct passwd *getpwnam (const char *user); - static struct passwd *getpwnam_r (const char *name, - struct passwd *pwent, - char *buffer, - int buflen); - //@} - - //@{ @name A set of wrappers for regular expressions. - static char *compile (const char *instring, - char *expbuf, - char *endbuf); - static int step (const char *str, - char *expbuf); - //@} - - //@{ @name Wide-character strings - typedef ACE_WCHAR_T WChar; - - static u_int wslen (const WChar *); - static WChar *wscpy (WChar *, - const WChar *); - static int wscmp (const WChar *, - const WChar *); - static int wsncmp (const WChar *, - const WChar *, - size_t len); - //@} - -# if 0 - //@{ @name A set of wrappers for threads (these are portable since they use the ACE_Thread_ID). - static int thr_continue (const ACE_Thread_ID &thread); - static int thr_create (ACE_THR_FUNC, - void *args, - long flags, - ACE_Thread_ID *, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - void *stack = 0, - size_t stacksize = 0); - static int thr_getprio (ACE_Thread_ID thr_id, - int &prio, - int *policy = 0); - static int thr_join (ACE_Thread_ID waiter_id, - ACE_THR_FUNC_RETURN *status); - static int thr_kill (ACE_Thread_ID thr_id, - int signum); - static ACE_Thread_ID thr_self (void); - static int thr_setprio (ACE_Thread_ID thr_id, - int prio); - static int thr_setprio (const ACE_Sched_Priority prio); - static int thr_suspend (ACE_Thread_ID target_thread); - static int thr_cancel (ACE_Thread_ID t_id); - //@} -# endif /* 0 */ - - //@{ @name A set of wrappers for threads - - // These are non-portable since they use ACE_thread_t and - // ACE_hthread_t and will go away in a future release. - static int thr_continue (ACE_hthread_t target_thread); - - /* - * Creates a new thread having <flags> attributes and running <func> - * with <args> (if <thread_adapter> is non-0 then <func> and <args> - * are ignored and are obtained from <thread_adapter>). <thr_id> - * and <t_handle> are set to the thread's ID and handle (?), - * respectively. The thread runs at <priority> priority (see - * below). - * - * The <flags> are a bitwise-OR of the following: - * = BEGIN<INDENT> - * THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, - * THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, - * THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, - * THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, - * THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS - * = END<INDENT> - * - * By default, or if <priority> is set to - * ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for - * the given scheduling policy (specified in <flags}>, e.g., - * <THR_SCHED_DEFAULT>) is used. This value is calculated - * dynamically, and is the median value between the minimum and - * maximum priority values for the given policy. If an explicit - * value is given, it is used. Note that actual priority values are - * EXTREMEMLY implementation-dependent, and are probably best - * avoided. - * - * Note that <thread_adapter> is always deleted by <thr_create>, - * therefore it must be allocated with global operator new. - */ - static int thr_create (ACE_THR_FUNC func, - void *args, - long flags, - ACE_thread_t *thr_id, - ACE_hthread_t *t_handle = 0, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - void *stack = 0, - size_t stacksize = 0, - ACE_Base_Thread_Adapter *thread_adapter = 0); - - static int thr_join (ACE_hthread_t waiter_id, - ACE_THR_FUNC_RETURN *status); - static int thr_join (ACE_thread_t waiter_id, - ACE_thread_t *thr_id, - ACE_THR_FUNC_RETURN *status); - static int thr_kill (ACE_thread_t thr_id, - int signum); - static ACE_thread_t thr_self (void); - static void thr_self (ACE_hthread_t &); - static int thr_getprio (ACE_hthread_t id, - int &priority); - static int thr_getprio (ACE_hthread_t id, - int &priority, - int &policy); - static int thr_setprio (ACE_hthread_t id, - int priority, - int policy = -1); - static int thr_setprio (const ACE_Sched_Priority prio); - static int thr_suspend (ACE_hthread_t target_thread); - static int thr_cancel (ACE_thread_t t_id); - - static int thr_cmp (ACE_hthread_t t1, - ACE_hthread_t t2); - static int thr_equal (ACE_thread_t t1, - ACE_thread_t t2); - static void thr_exit (ACE_THR_FUNC_RETURN status = 0); - static int thr_getconcurrency (void); - static int lwp_getparams (ACE_Sched_Params &); -# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - static int thr_getspecific (ACE_OS_thread_key_t key, - void **data); -# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ - static int thr_getspecific (ACE_thread_key_t key, - void **data); - static int thr_keyfree (ACE_thread_key_t key); - static int thr_key_detach (void *inst); -# if defined (ACE_HAS_THR_C_DEST) -# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - static int thr_keycreate (ACE_OS_thread_key_t *key, - ACE_THR_C_DEST, - void *inst = 0); -# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ - static int thr_keycreate (ACE_thread_key_t *key, - ACE_THR_C_DEST, - void *inst = 0); -# else -# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - static int thr_keycreate (ACE_OS_thread_key_t *key, - ACE_THR_DEST, - void *inst = 0); -# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ - static int thr_keycreate (ACE_thread_key_t *key, - ACE_THR_DEST, - void *inst = 0); -# endif /* ACE_HAS_THR_C_DEST */ - static int thr_key_used (ACE_thread_key_t key); - static size_t thr_min_stack (void); - static int thr_setconcurrency (int hint); - static int lwp_setparams (const ACE_Sched_Params &); -# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - static int thr_setspecific (ACE_OS_thread_key_t key, - void *data); -# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ - static int thr_setspecific (ACE_thread_key_t key, - void *data); - static int thr_sigsetmask (int how, - const sigset_t *nsm, - sigset_t *osm); - static int thr_setcancelstate (int new_state, - int *old_state); - static int thr_setcanceltype (int new_type, - int *old_type); - static int sigwait (sigset_t *set, - int *sig = 0); - static int sigtimedwait (const sigset_t *set, - siginfo_t *info, - const ACE_Time_Value *timeout); - static int sigwaitinfo (const sigset_t *set, - siginfo_t *info); - static void thr_testcancel (void); - static void thr_yield (void); - - /** - * This method uses process id and object pointer to come up with a - * machine wide unique name. The process ID will provide uniqueness - * between processes on the same machine. The "this" pointer of the - * <object> will provide uniqueness between other "live" objects in - * the same process. The uniqueness of this name is therefore only - * valid for the life of <object>. - */ - static void unique_name (const void *object, - ACE_TCHAR *name, - size_t length); - - /// This is necessary to deal with POSIX pthreads and their use of - /// structures for thread ids. - static ACE_thread_t NULL_thread; - - /// This is necessary to deal with POSIX pthreads and their use of - /// structures for thread handles. - static ACE_hthread_t NULL_hthread; - - /// This is necessary to deal with POSIX pthreads and their use of - /// structures for TSS keys. - static ACE_thread_key_t NULL_key; - -# if defined (CHORUS) - /// This is used to map an actor's id into a KnCap for killing and - /// waiting actors. - static KnCap actorcaps_[ACE_CHORUS_MAX_ACTORS]; -# endif /* CHORUS */ - //@} - -# if defined (ACE_WIN32) - /// Keeps track of whether we've already initialized WinSock... - static int socket_initialized_; -# endif /* ACE_WIN32 */ - /// Handle asynchronous thread cancellation cleanup. - static void mutex_lock_cleanup (void *mutex); - /** - * Call TSS destructors for the current thread. If the current - * thread is the main thread, then the argument must be 1. - * For private use of ACE_Object_Manager and ACE_Thread_Adapter only. - */ - static void cleanup_tss (const u_int main_thread); - -# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) - static int netdb_acquire (void); - static int netdb_release (void); -# endif /* defined (ACE_MT_SAFE) && ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ - - /// Find the schedling class ID that corresponds to the class name. - static int scheduling_class (const char *class_name, ACE_id_t &); - - /// Friendly interface to <priocntl>(2). - static int set_scheduling_params (const ACE_Sched_Params &, - ACE_id_t id = ACE_SELF); - - /// Low-level interface to <priocntl>(2). - /** - * Can't call the following priocntl, because that's a macro on - * Solaris. - */ - static int priority_control (ACE_idtype_t, ACE_id_t, int, void *); - -#if defined (ACE_HAS_STRPTIME) - static char *strptime (char *buf, - const char *format, - struct tm *tm); - -# if defined (ACE_LACKS_NATIVE_STRPTIME) - static int strptime_getnum (char *buf, int *num, int *bi, - int *fi, int min, int max); -# endif /* ACE_LACKS_NATIVE_STRPTIME */ -#endif /* ACE_HAS_STRPTIME */ - - /// Get the number of CPUs configured in the machine. - static long num_processors (void); - - /// Get the number of CPUs currently online. - static long num_processors_online (void); - -private: - -#if defined (ACE_LACKS_WRITEV) - static int writev_emulation (ACE_HANDLE handle, - ACE_WRITEV_TYPE *iov, - int iovcnt); -#endif /* ACE_LACKS_WRITEV */ - -#if defined (ACE_LACKS_READV) - static ssize_t readv_emulation (ACE_HANDLE handle, - ACE_READV_TYPE *iov, - int iovcnt); -#endif /* ACE_LACKS_READV */ - - /// Function that is called by <ACE_OS::exit>, if non-null. - static ACE_EXIT_HOOK exit_hook_; - - /// For use by ACE_Object_Manager only, to register its exit hook.. - static ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook); - - /// Allow the ACE_OS_Object_Manager to call set_exit_hook. - friend class ACE_OS_Object_Manager; - -# if defined (ACE_WIN32) -# if defined (ACE_HAS_WINCE) - /// Supporting data for ctime and ctime_r functions on WinCE. - static const wchar_t *day_of_week_name[7]; - static const wchar_t *month_name[12]; -# endif /* ACE_HAS_WINCE */ - - /// Translate fopen's mode char to open's mode. This helper function - /// is here to avoid maintaining several pieces of identical code. - static void fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode); - - static OSVERSIONINFO win32_versioninfo_; - - static HINSTANCE win32_resource_module_; - -# endif /* ACE_WIN32 */ - -}; - -/** - * @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 &); -}; - -extern "C" -void -ACE_OS_Object_Manager_Internal_Exit_Hook (void); - - -// @@ This forward declaration should go away. -class ACE_Log_Msg; - -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 (); -}; - -# if 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 */ - -# if defined (ACE_HAS_TSS_EMULATION) - // Allow config.h to set the default number of thread keys. -# if !defined (ACE_DEFAULT_THREAD_KEYS) -# define ACE_DEFAULT_THREAD_KEYS 64 -# endif /* ! ACE_DEFAULT_THREAD_KEYS */ - -// forward declaration -class ACE_TSS_Keys; - -/** - * @class ACE_TSS_Emulation - * - * @brief Thread-specific storage emulation. - * - * This provides a thread-specific storage implementation. - * It is intended for use on platforms that don't have a - * native TSS, or have a TSS with limitations such as the - * number of keys or lack of support for removing keys. - */ -class ACE_OS_Export ACE_TSS_Emulation -{ -public: - typedef void (*ACE_TSS_DESTRUCTOR)(void *value) /* throw () */; - - /// Maximum number of TSS keys allowed over the life of the program. - enum { ACE_TSS_THREAD_KEYS_MAX = ACE_DEFAULT_THREAD_KEYS }; - - /// Returns the total number of keys allocated so far. - static u_int total_keys (); - - /// Sets the argument to the next available key. Returns 0 on success, - /// -1 if no keys are available. - static int next_key (ACE_thread_key_t &key); - - /// Release a key that was used. This way the key can be given out in a - /// new request. Returns 0 on success, 1 if the key was not reserved. - static int release_key (ACE_thread_key_t key); - - /// Returns the exit hook associated with the key. Does _not_ check - /// for a valid key. - static ACE_TSS_DESTRUCTOR tss_destructor (const ACE_thread_key_t key); - - /// Associates the TSS destructor with the key. Does _not_ check - /// for a valid key. - static void tss_destructor (const ACE_thread_key_t key, - ACE_TSS_DESTRUCTOR destructor); - - /// Accesses the object referenced by key in the current thread's TSS array. - /// Does _not_ check for a valid key. - static void *&ts_object (const ACE_thread_key_t key); - - /** - * Setup an array to be used for local TSS. Returns the array - * address on success. Returns 0 if local TSS had already been - * setup for this thread. There is no corresponding tss_close () - * because it is not needed. - * NOTE: tss_open () is called by ACE for threads that it spawns. - * If your application spawns threads without using ACE, and it uses - * ACE's TSS emulation, each of those threads should call tss_open - * (). See the ace_thread_adapter () implementation for an example. - */ - static void *tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]); - - /// Shutdown TSS emulation. For use only by ACE_OS::cleanup_tss (). - static void tss_close (); - -private: - // Global TSS structures. - /// Contains the possible value of the next key to be allocated. Which key - /// is actually allocated is based on the tss_keys_used - static u_int total_keys_; - - /// Array of thread exit hooks (TSS destructors) that are called for each - /// key (that has one) when the thread exits. - static ACE_TSS_DESTRUCTOR tss_destructor_ [ACE_TSS_THREAD_KEYS_MAX]; - - /// TSS_Keys instance to administrate whether a specific key is in used - /// or not - static ACE_TSS_Keys tss_keys_used_; - -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - /// Location of current thread's TSS array. - static void **tss_base (void* ts_storage[] = 0, u_int *ts_created = 0); -# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ - /// Location of current thread's TSS array. - static void **&tss_base (); -# endif /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ - -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) - // Rely on native thread specific storage for the implementation, - // but just use one key. - static ACE_OS_thread_key_t native_tss_key_; - - // Used to indicate if native tss key has been allocated - static int key_created_; -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ -}; - -# else /* ! ACE_HAS_TSS_EMULATION */ -# if defined (TLS_MINIMUM_AVAILABLE) - // WIN32 platforms define TLS_MINIMUM_AVAILABLE natively. -# define ACE_DEFAULT_THREAD_KEYS TLS_MINIMUM_AVAILABLE -# endif /* TSL_MINIMUM_AVAILABLE */ - -# endif /* ACE_HAS_TSS_EMULATION */ - -// moved ACE_TSS_Ref, ACE_TSS_Info, and ACE_TSS_Keys class -// declarations from OS.cpp so they are visible to the single -// file of template instantiations. -# if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) -/** - * @class ACE_TSS_Ref - * - * @brief "Reference count" for thread-specific storage keys. - * - * Since the <ACE_Unbounded_Stack> doesn't allow duplicates, the - * "reference count" is the identify of the thread_id. - */ -class ACE_TSS_Ref -{ -public: - /// Constructor - ACE_TSS_Ref (ACE_thread_t id); - - /// Default constructor - ACE_TSS_Ref (void); - - /// Check for equality. - int operator== (const ACE_TSS_Ref &) const; - - /// Check for inequality. - int operator!= (const ACE_TSS_Ref &) const; - -// private: - - /// ID of thread using a specific key. - ACE_thread_t tid_; -}; - -/** - * @class ACE_TSS_Info - * - * @brief Thread Specific Key management. - * - * This class maps a key to a "destructor." - */ -class ACE_TSS_Info -{ -public: - /// Constructor - ACE_TSS_Info (ACE_thread_key_t key, - void (*dest)(void *) = 0, - void *tss_inst = 0); - - /// Default constructor - ACE_TSS_Info (void); - - /// Returns 1 if the key is in use, 0 if not. - int key_in_use (void) const { return thread_count_ != -1; } - - /// Mark the key as being in use if the flag is non-zero, or - /// not in use if the flag is 0. - void key_in_use (int flag) { thread_count_ = flag == 0 ? -1 : 1; } - - /// Check for equality. - int operator== (const ACE_TSS_Info &) const; - - /// Check for inequality. - int operator!= (const ACE_TSS_Info &) const; - - /// Dump the state. - void dump (void); - -private: - /// Key to the thread-specific storage item. - ACE_thread_key_t key_; - - /// "Destructor" that gets called when the item is finally released. - void (*destructor_)(void *); - - /// Pointer to ACE_TSS<xxx> instance that has/will allocate the key. - void *tss_obj_; - - /// Count of threads that are using this key. Contains -1 when the - /// key is not in use. - int thread_count_; - - friend class ACE_TSS_Cleanup; -}; - -/** - * @class ACE_TSS_Keys - * - * @brief Collection of in-use flags for a thread's TSS keys. - * For internal use only by ACE_TSS_Cleanup; it is public because - * some compilers can't use nested classes for template instantiation - * parameters. - * - * Wrapper around array of whether each key is in use. A simple - * typedef doesn't work with Sun C++ 4.2. - */ -class ACE_TSS_Keys -{ -public: - /// Default constructor, to initialize all bits to zero (unused). - ACE_TSS_Keys (void); - - /// Mark the specified key as being in use, if it was not already so marked. - /// Returns 1 if the had already been marked, 0 if not. - int test_and_set (const ACE_thread_key_t key); - - /// Mark the specified key as not being in use, if it was not already so - /// cleared. Returns 1 if the key had already been cleared, 0 if not. - int test_and_clear (const ACE_thread_key_t key); - - /// Return whether the specific key is marked as in use. - /// Returns 1 if the key is been marked, 0 if not. - int is_set (const ACE_thread_key_t key) const; - -private: - /// For a given key, find the word and bit number that represent it. - static void find (const u_int key, u_int &word, u_int &bit); - - enum - { -# if ACE_SIZEOF_LONG == 8 - ACE_BITS_PER_WORD = 64, -# elif ACE_SIZEOF_LONG == 4 - ACE_BITS_PER_WORD = 32, -# else -# error ACE_TSS_Keys only supports 32 or 64 bit longs. -# endif /* ACE_SIZEOF_LONG == 8 */ - ACE_WORDS = (ACE_DEFAULT_THREAD_KEYS - 1) / ACE_BITS_PER_WORD + 1 - }; - - /// Bit flag collection. A bit value of 1 indicates that the key is in - /// use by this thread. - u_long key_bit_words_[ACE_WORDS]; -}; - -# endif /* defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) */ - -// Support non-scalar thread keys, such as with some POSIX -// implementations, e.g., MVS. -# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T) -# define ACE_KEY_INDEX(OBJ,KEY) \ - u_int OBJ; \ - ACE_OS::memcpy (&OBJ, &KEY, sizeof (u_int)) -# else -# define ACE_KEY_INDEX(OBJ,KEY) u_int OBJ = KEY -# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ - -# if defined (ACE_HAS_THR_C_FUNC) -// This is necessary to work around nasty problems with MVS C++. -extern "C" ACE_OS_Export void ace_mutex_lock_cleanup_adapter (void *args); -# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A); -# define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A) -# elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CLEANUP) -// Though we are defining a extern "C" function to match the prototype of -// pthread_cleanup_push, it is undone by the Solaris header file -// /usr/include/pthread.h. So this macro generates a warning under Solaris -// with SunCC. This is a bug in the Solaris header file. -extern "C" ACE_OS_Export void ace_mutex_lock_cleanup_adapter (void *args); -# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A); -# define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A) -# else -# define ACE_PTHREAD_CLEANUP_PUSH(A) -# define ACE_PTHREAD_CLEANUP_POP(A) -# endif /* ACE_HAS_THR_C_FUNC */ - -# if !defined (ACE_DEFAULT_MUTEX_A) -# define ACE_DEFAULT_MUTEX_A "ACE_MUTEX" -# endif /* ACE_DEFAULT_MUTEX_A */ - -# if defined (ACE_HAS_WCHAR) -# define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE(ACE_DEFAULT_MUTEX_A) -# endif /* ACE_HAS_WCHAR */ - -# define ACE_DEFAULT_MUTEX ACE_LIB_TEXT (ACE_DEFAULT_MUTEX_A) - -# 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) - -# if defined (ACE_TMAIN) // Use WinMain on CE; others give warning/error. -# undef ACE_TMAIN -# endif // ACE_TMAIN - -// CE only gets a command line string; no argv. So we need to convert it -// when the main entrypoint expects argc/argv. ACE_ARGV supports this. -# include "ace/ARGV.h" - -// Support for ACE_TMAIN, which is a recommended way. It would be nice if -// CE had CommandLineToArgvW()... but it's only on NT3.5 and up. - -# define ACE_TMAIN \ -ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ -int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ -{ \ - ACE_TCHAR cmdline[1024]; \ - ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ - ACE_OS::strcat (cmdline, lpCmdLine); \ - ACE_ARGV ce_argv (cmdline); \ - 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_TCHAR cmdline[1024]; \ - ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ - ACE_OS::strcat (cmdline, lpCmdLine); \ - ACE_ARGV ce_argv (cmdline); \ - 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. Unfortunately, evc 3 can't grok a #include within the macro -// expansion, so it needs to go out here. -# include "ace/Argv_Type_Converter.h" -# define main \ -ace_main_i (int, char *[]); /* forward declaration */ \ -int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ -{ \ - ACE_TCHAR cmdline[1024]; \ - ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ - ACE_OS::strcat (cmdline, lpCmdLine); \ - ACE_ARGV ce_argv (cmdline); \ - 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 */ +}; /* namespace ACE_OS */ # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) @@ -4430,159 +379,6 @@ ace_main_i # include "ace/OS.i" # endif /* ACE_HAS_INLINED_OSCALLS */ -// Byte swapping macros to deal with differences between little endian -// and big endian machines. Note that "long" here refers to 32 bit -// quantities. -# define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \ - | ACE_SWAP_WORD(((L) >> 16) & 0xFFFF)) -# define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8)) - -# if defined (ACE_LITTLE_ENDIAN) -# define ACE_HTONL(X) ACE_SWAP_LONG (X) -# define ACE_NTOHL(X) ACE_SWAP_LONG (X) -# define ACE_IDL_NCTOHL(X) (X) -# define ACE_IDL_NSTOHL(X) (X) -# else -# define ACE_HTONL(X) X -# define ACE_NTOHL(X) X -# define ACE_IDL_NCTOHL(X) (X << 24) -# define ACE_IDL_NSTOHL(X) ((X) << 16) -# endif /* ACE_LITTLE_ENDIAN */ - -# if defined (ACE_LITTLE_ENDIAN) -# define ACE_HTONS(x) ACE_SWAP_WORD(x) -# define ACE_NTOHS(x) ACE_SWAP_WORD(x) -# else -# define ACE_HTONS(x) x -# define ACE_NTOHS(x) x -# endif /* ACE_LITTLE_ENDIAN */ - -# if defined (ACE_HAS_POSIX_REALTIME_SIGNALS) - // = Giving unique ACE scoped names for some important - // RTSignal-Related constants. Becuase sometimes, different - // platforms use different names for these constants. - - // Number of realtime signals provided in the system. - // _POSIX_RTSIG_MAX is the upper limit on the number of real time - // signals supported in a posix-4 compliant system. -# if defined (_POSIX_RTSIG_MAX) -# define ACE_RTSIG_MAX _POSIX_RTSIG_MAX -# else /* not _POSIX_RTSIG_MAX */ - // POSIX-4 compilant system has to provide atleast 8 RT signals. - // @@ Make sure the platform does *not* define this constant with - // some other name. If yes, use that instead of 8. -# define ACE_RTSIG_MAX 8 -# endif /* _POSIX_RTSIG_MAX */ -# endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ - - // 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 */ - -/** - * In some environments it is useful to swap the bytes on write, for - * instance: a fast server can be feeding a lot of slow clients that - * happen to have the wrong byte order. - * Because this is a rarely used feature we disable it by default to - * minimize footprint. - * This macro enables the functionality, but we still need a way to - * activate it on a per-connection basis. - */ -// #define ACE_ENABLE_SWAP_ON_WRITE - -/** - * In some environements we never need to swap bytes when reading, for - * instance embebbed systems (such as avionics) or homogenous - * networks. - * Setting this macro disables the capabilities to demarshall streams - * in the wrong byte order. - */ -// #define ACE_DISABLE_SWAP_ON_READ - -# if defined (ACE_LACKS_SYS_NERR) -extern ACE_OS_Export int sys_nerr; -# endif /* ACE_LACKS_SYS_NERR */ - -/* ACE_Metrics */ -#if defined ACE_LACKS_ARRAY_PLACEMENT_NEW -# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \ - do { POINTER = ALLOCATOR; \ - if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ - else { for (u_int i = 0; i < COUNT; ++i) \ - {new (POINTER) CONSTRUCTOR; ++POINTER;} \ - POINTER -= COUNT;} \ - } while (0) -# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \ - do { POINTER = ALLOCATOR; \ - if (POINTER == 0) { errno = ENOMEM; return;} \ - else { for (u_int i = 0; i < COUNT; ++i) \ - {new (POINTER) CONSTRUCTOR; ++POINTER;} \ - POINTER -= COUNT;} \ - } while (0) -#else /* ! defined ACE_LACKS_ARRAY_PLACEMENT_NEW */ -# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \ - do { POINTER = ALLOCATOR; \ - if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ - else { new (POINTER) CONSTRUCTOR [COUNT]; } \ - } while (0) -# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \ - do { POINTER = ALLOCATOR; \ - if (POINTER == 0) { errno = ENOMEM; return;} \ - else { new (POINTER) CONSTRUCTOR [COUNT]; } \ - } while (0) -#endif /* defined ACE_LACKS_ARRAY_PLACEMENT_NEW */ - -/* Enable ACE Timeprobes */ -#if defined (ACE_ENABLE_TIMEPROBES) - #if !defined (ACE_COMPILE_TIMEPROBES) - #define ACE_COMPILE_TIMEPROBES - #endif /* ACE_COMPILE_TIMEPROBES */ -#endif /* ACE_ENABLE_TIMEPROBES */ - #if defined (ACE_LEGACY_MODE) # include "ace/Log_Msg.h" # include "ace/Thread_Hook.h" @@ -4591,5 +387,7 @@ extern ACE_OS_Export int sys_nerr; # include "ace/Thread_Control.h" #endif /* ACE_LEGACY_MODE */ +#endif /* 0 */ + #include /**/ "ace/post.h" #endif /* ACE_OS_H */ @@ -6,89 +6,10 @@ # define ACE_INLINE #endif /* ACE_HAS_INLINED_OSCALLS */ -#if defined (ACE_LACKS_RLIMIT_PROTOTYPE) -int getrlimit (int resource, struct rlimit *rlp); -int setrlimit (int resource, const struct rlimit *rlp); -#endif /* ACE_LACKS_RLIMIT_PROTOTYPE */ - -#if !defined (ACE_HAS_STRERROR) -# if defined (ACE_HAS_SYS_ERRLIST) -extern char *sys_errlist[]; -# define strerror(err) sys_errlist[err] -# else -# define strerror(err) "strerror is unsupported" -# endif /* ACE_HAS_SYS_ERRLIST */ -#endif /* !ACE_HAS_STERROR */ - -#if defined (ACE_HAS_SYS_SIGLIST) -# if !defined (_sys_siglist) -# define _sys_siglist sys_siglist -# endif /* !defined (sys_siglist) */ -//extern char **_sys_siglist; -#endif /* ACE_HAS_SYS_SIGLIST */ - -#if defined (ACE_HAS_SOCKLEN_T) -typedef socklen_t ACE_SOCKET_LEN; -#elif defined (ACE_HAS_SIZET_SOCKET_LEN) -typedef size_t ACE_SOCKET_LEN; -#else -typedef int ACE_SOCKET_LEN; -#endif /* ACE_HAS_SIZET_SOCKET_LEN */ - -#if defined (ACE_LACKS_CONST_STRBUF_PTR) -typedef struct strbuf *ACE_STRBUF_TYPE; -#else -typedef const struct strbuf *ACE_STRBUF_TYPE; -#endif /* ACE_LACKS_CONST_STRBUF_PTR */ - -#if defined (ACE_HAS_VOIDPTR_SOCKOPT) -typedef void *ACE_SOCKOPT_TYPE1; -#elif defined (ACE_HAS_CHARPTR_SOCKOPT) -typedef char *ACE_SOCKOPT_TYPE1; -#else -typedef const char *ACE_SOCKOPT_TYPE1; -#endif /* ACE_HAS_VOIDPTR_SOCKOPT */ - -#if (!defined (_BSD_SOURCE) && \ - !defined (_XOPEN_SOURCE) && !defined (_XOPEN_SOURCE_EXTENDED)) \ - || (defined (_XOPEN_SOURCE) && defined (__GNUC__)) - -# if defined (ACE_LACKS_SETREUID_PROTOTYPE) -extern "C" { -extern int setreuid (uid_t ruid, uid_t euid); -} -# endif /* ACE_LACKS_SETREUID_PROTOTYPE */ - -# if defined (ACE_LACKS_SETREGID_PROTOTYPE) -extern "C" { -extern int setregid (gid_t rgid, gid_t egid); -} -# endif /* ACE_LACKS_SETREGID_PROTOTYPE */ -#endif /* !_BSD_SOURCE && !_XOPEN_SOURCE && !_XOPEN_SOURCE_EXTENDED - || _XOPEN_SOURCE && __GNUC__ */ - -#if defined (ACE_NEEDS_FTRUNCATE) -extern "C" ACE_Export int ftruncate (ACE_HANDLE handle, long len); -#endif /* ACE_NEEDS_FTRUNCATE */ - -#if defined (ACE_HAS_VOIDPTR_MMAP) -// Needed for some odd OS's (e.g., SGI). -typedef void *ACE_MMAP_TYPE; -#else -typedef char *ACE_MMAP_TYPE; -#endif /* ACE_HAS_VOIDPTR_MMAP */ - #if defined (ACE_HAS_XLI) # include /**/ <xliuser.h> #endif /* ACE_HAS_XLI */ -#if defined (_M_UNIX) -extern "C" int _dlclose (void *); -extern "C" char *_dlerror (void); -extern "C" void *_dlopen (const char *, int); -extern "C" void * _dlsym (void *, const char *); -#endif /* _M_UNIX */ - #if !defined (ACE_HAS_CPLUSPLUS_HEADERS) # include /**/ <libc.h> # include /**/ <osfcn.h> @@ -114,120 +35,10 @@ using std::asctime; using std::strftime; #endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ -#if defined (ACE_HAS_SVR4_GETTIMEOFDAY) -# if !defined (m88k) && !defined (SCO) -extern "C" int gettimeofday (struct timeval *tp, void * = 0); -# else -extern "C" int gettimeofday (struct timeval *tp); -# endif /* !m88k && !SCO */ -#elif defined (ACE_HAS_OSF1_GETTIMEOFDAY) -extern "C" int gettimeofday (struct timeval *tp, struct timezone * = 0); -#elif defined (ACE_HAS_SUNOS4_GETTIMEOFDAY) -# define ACE_HAS_SVR4_GETTIMEOFDAY -#endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ - -#if defined (ACE_LACKS_CONST_TIMESPEC_PTR) -typedef struct timespec * ACE_TIMESPEC_PTR; -#else -typedef const struct timespec * ACE_TIMESPEC_PTR; -#endif /* HPUX */ - #if !defined (ACE_LACKS_MALLOC_H) # include /**/ <malloc.h> #endif /* ACE_LACKS_MALLOC_H */ -ACE_INLINE int -ACE_OS::fcntl (ACE_HANDLE handle, int cmd, long arg) -{ - ACE_OS_TRACE ("ACE_OS::fcntl"); -# if defined (ACE_LACKS_FCNTL) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (::fcntl (handle, cmd, arg), int, -1); -# endif /* ACE_LACKS_FCNTL */ -} - -#if !defined (ACE_LACKS_CHDIR) -ACE_INLINE int -ACE_OS::chdir (const char *path) -{ - ACE_OS_TRACE ("ACE_OS::chdir"); -#if defined (VXWORKS) - ACE_OSCALL_RETURN (::chdir (ACE_const_cast (char *, path)), int, -1); - -#elif defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (path); - ACE_NOTSUP_RETURN (-1); - -#elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::change_dir ((char *) path), ace_result_), - int, -1); - -// This #elif seems weird... is Visual Age on NT not setting ACE_WIN32? -#elif !defined (ACE_WIN32) && !defined (AIX) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) - ACE_OSCALL_RETURN (::_chdir (path), int, -1); - -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (path); - ACE_NOTSUP_RETURN (-1); - -#else - ACE_OSCALL_RETURN (::chdir (path), int, -1); - -#endif /* VXWORKS */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::chdir (const wchar_t *path) -{ -#if defined (ACE_WIN32) - ACE_OSCALL_RETURN (::_wchdir (path), int, -1); -#else /* ACE_WIN32 */ - return ACE_OS::chdir (ACE_Wide_To_Ascii (path).char_rep ()); -#endif /* ACE_WIN32 */ -} -#endif /* ACE_HAS_WCHAR */ -#endif /* ACE_LACKS_CHDIR */ - -#if !defined (ACE_LACKS_MKTEMP) -ACE_INLINE ACE_TCHAR * -ACE_OS::mktemp (ACE_TCHAR *s) -{ -# if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - return ::_wmktemp (s); -# elif defined (ACE_WIN32) - return ::_mktemp (s); -# else /* ACE_WIN32 */ - return ::mktemp (s); -# endif /* ACE_WIN32 */ -} -#endif /* !ACE_LACKS_MKTEMP */ - -#if !defined (ACE_LACKS_MKSTEMP) -ACE_INLINE ACE_HANDLE -ACE_OS::mkstemp (ACE_TCHAR *s) -{ - return ::mkstemp (s); -} -#endif /* !ACE_LACKS_MKSTEMP */ - -ACE_INLINE int -ACE_OS::mkfifo (const ACE_TCHAR *file, mode_t mode) -{ - ACE_OS_TRACE ("ACE_OS::mkfifo"); -#if defined (ACE_LACKS_MKFIFO) - ACE_UNUSED_ARG (file); - ACE_UNUSED_ARG (mode); - ACE_NOTSUP_RETURN (-1); -#else - ACE_OSCALL_RETURN (::mkfifo (file, mode), int, -1); -#endif /* ACE_LACKS_MKFIFO */ -} - #if !defined (ACE_WIN32) // Matthew Stevens 7-10-95 Fix GNU GCC 2.7 for memchr() problem. @@ -244,24 +55,6 @@ ACE_OS::mkfifo (const ACE_TCHAR *file, mode_t mode) # endif /* VXWORKS */ # endif /* ACE_HAS_GNU_CSTRING_H */ -// These prototypes are chronically lacking from many versions of -// UNIX. -#if !defined (ACE_HAS_ISASTREAM_PROTO) -extern "C" int isastream (int); -#endif /* ACE_HAS_ISASTREAM_PROTO */ - -# if !defined (ACE_HAS_GETRUSAGE_PROTO) -extern "C" int getrusage (int who, struct rusage *rusage); -# endif /* ! ACE_HAS_GETRUSAGE_PROTO */ - -# if defined (ACE_LACKS_SYSCALL) -extern "C" int syscall (int, ACE_HANDLE, struct rusage *); -# endif /* ACE_LACKS_SYSCALL */ - -# if defined (ACE_LACKS_MKTEMP) -extern "C" char *mktemp (char *); -# endif /* ACE_LACKS_MKTEMP */ - // The following are #defines and #includes that must be visible for // ACE to compile it's OS wrapper class implementation correctly. We // put them inside of here to reduce compiler overhead if we're not @@ -287,103 +80,6 @@ extern "C" char *mktemp (char *); # include /**/ <ifaddrs.h> # endif /* ACE_HAS_GETIFADDRS */ -// Adapt the weird threading and synchronization routines (which -// return errno rather than -1) so that they return -1 and set errno. -// This is more consistent with the rest of ACE_OS and enables use to -// use the ACE_OSCALL* macros. -# if defined (VXWORKS) -# define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != OK ? (errno = RESULT, -1) : 0) -# else -# define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0) -# endif /* VXWORKS */ - -ACE_INLINE int -ACE_OS::fstat (ACE_HANDLE handle, ACE_stat *stp) -{ - ACE_OS_TRACE ("ACE_OS::fstat"); -#if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (stp); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (::fstat_f (handle, stp), int, -1); -#else -# if defined (ACE_HAS_X86_STAT_MACROS) - // Solaris for intel uses an macro for fstat(), this is a wrapper - // for _fxstat() use of the macro. - // causes compile and runtime problems. - ACE_OSCALL_RETURN (::_fxstat (_STAT_VER, handle, stp), int, -1); -# elif defined (ACE_WIN32) - ACE_OSCALL_RETURN (::_fstat (handle, stp), int, -1); -# else - ACE_OSCALL_RETURN (::fstat (handle, stp), int, -1); -# endif /* !ACE_HAS_X86_STAT_MACROS */ -#endif /* ACE_PSOS_LACKS_PHILE */ -} - -ACE_INLINE int -ACE_OS::lstat (const char *file, ACE_stat *stp) -{ - ACE_OS_TRACE ("ACE_OS::lstat"); -# if defined (ACE_LACKS_LSTAT) || \ - defined (ACE_HAS_WINCE) || defined (ACE_WIN32) - ACE_UNUSED_ARG (file); - ACE_UNUSED_ARG (stp); - ACE_NOTSUP_RETURN (-1); -# else -# if defined (ACE_HAS_X86_STAT_MACROS) - // Solaris for intel uses an macro for lstat(), this macro is a - // wrapper for _lxstat(). - ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1); -# elif defined (ACE_WIN32) - ACE_OSCALL_RETURN (::_lstat (file, stp), int, -1); -# else /* !ACE_HAS_X86_STAT_MACROS */ - ACE_OSCALL_RETURN (::lstat (file, stp), int, -1); -# endif /* !ACE_HAS_X86_STAT_MACROS */ -# endif /* ACE_LACKS_LSTAT */ -} - -ACE_INLINE int -ACE_OS::fsync (ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::fsync"); -# if defined (ACE_LACKS_FSYNC) - ACE_UNUSED_ARG (handle); - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (::fsync (handle), int, -1); -# endif /* ACE_LACKS_FSYNC */ -} - -ACE_INLINE int -ACE_OS::getopt (int argc, char *const *argv, const char *optstring) -{ - ACE_OS_TRACE ("ACE_OS::getopt"); -#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_UNUSED_ARG (argc); - ACE_UNUSED_ARG (argv); - ACE_UNUSED_ARG (optstring); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_LACKS_GETOPT_PROTO) - ACE_OSCALL_RETURN (::getopt (argc, (char**) argv, optstring), int, -1); -# elif defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::getopt (argc, (const char* const *) argv, optstring), int, -1); -# else - ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1); -# endif /* VXWORKS */ -} - -ACE_INLINE int -ACE_OS::pipe (ACE_HANDLE fds[]) -{ - ACE_OS_TRACE ("ACE_OS::pipe"); -# if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_UNUSED_ARG (fds); - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (::pipe (fds), int, -1); -# endif /* VXWORKS || ACE_PSOS */ -} # if defined (DIGITAL_UNIX) extern "C" { @@ -406,71 +102,8 @@ extern "C" { } #endif /* AIX and VAC++ 4 */ -ACE_INLINE int -ACE_OS::rand_r (ACE_RANDR_TYPE &seed) -{ - ACE_OS_TRACE ("ACE_OS::rand_r"); -# if defined (ACE_HAS_REENTRANT_FUNCTIONS) && \ - !defined (ACE_LACKS_RAND_REENTRANT_FUNCTIONS) -# if defined (DIGITAL_UNIX) - ACE_OSCALL_RETURN (::_Prand_r (&seed), int, -1); -# elif defined (HPUX_10) - // rand() is thread-safe on HP-UX 10. rand_r's signature is not consistent - // with latest POSIX and will change in a future HP-UX release so that it - // is consistent. At that point, this #elif section can be changed or - // removed, and just call rand_r. - ACE_UNUSED_ARG (seed); - ACE_OSCALL_RETURN (::rand(), int, -1); -# elif defined (ACE_HAS_BROKEN_RANDR) - ACE_OSCALL_RETURN (::rand_r (seed), int, -1); -# else - ACE_OSCALL_RETURN (::rand_r (&seed), int, -1); -# endif /* DIGITAL_UNIX */ -# else - ACE_UNUSED_ARG (seed); - ACE_OSCALL_RETURN (::rand (), int, -1); -# endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -} - -ACE_INLINE pid_t -ACE_OS::setsid (void) -{ - ACE_OS_TRACE ("ACE_OS::setsid"); -# if defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (::setsid (), int, -1); -# endif /* VXWORKS || CHORUS || ACE_PSOS */ -} - -ACE_INLINE mode_t -ACE_OS::umask (mode_t cmask) -{ - ACE_OS_TRACE ("ACE_OS::umask"); -# if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_UNUSED_ARG (cmask); - ACE_NOTSUP_RETURN ((mode_t)-1); -# else - return ::umask (cmask); // This call shouldn't fail... -# endif /* VXWORKS || ACE_PSOS */ -} - #else /* ACE_WIN32 */ -// Adapt the Win32 System Calls (which return BOOLEAN values of TRUE -// and FALSE) into int values expected by the ACE_OSCALL macros. -# define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) == FALSE ? -1 : 0) - -// Perform a mapping of Win32 error numbers into POSIX errnos. -# define ACE_FAIL_RETURN(RESULT) do { \ - switch (ACE_OS::set_errno_to_last_error ()) { \ - case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; \ - case ERROR_FILE_EXISTS: errno = EEXIST; break; \ - case ERROR_SHARING_VIOLATION: errno = EACCES; break; \ - case ERROR_PATH_NOT_FOUND: errno = ENOENT; break; \ - } \ - return RESULT; } while (0) - ACE_INLINE LPSECURITY_ATTRIBUTES ACE_OS::default_win32_security_attributes (LPSECURITY_ATTRIBUTES sa) { @@ -493,10722 +126,11 @@ ACE_OS::default_win32_security_attributes (LPSECURITY_ATTRIBUTES sa) #endif /* ACE_DEFINES_DEFAULT_WIN32_SECURITY_ATTRIBUTES */ } -ACE_INLINE int -ACE_OS::getopt (int argc, char *const *argv, const char *optstring) -{ - ACE_UNUSED_ARG (argc); - ACE_UNUSED_ARG (argv); - ACE_UNUSED_ARG (optstring); - - ACE_OS_TRACE ("ACE_OS::getopt"); - ACE_NOTSUP_RETURN (-1); -} - -ACE_INLINE int -ACE_OS::pipe (ACE_HANDLE fds[]) -{ -# if !defined (ACE_HAS_WINCE) && !defined (__IBMCPP__) - ACE_OS_TRACE ("ACE_OS::pipe"); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL - (::CreatePipe (&fds[0], &fds[1], 0, 0), - ace_result_), int, -1); -# else - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WINCE && !__IBMCPP__ */ -} - -ACE_INLINE int -ACE_OS::rand_r (ACE_RANDR_TYPE& seed) -{ - ACE_OS_TRACE ("ACE_OS::rand_r"); - - long new_seed = (long)(seed); - if (new_seed == 0) - new_seed = 0x12345987; - long temp = new_seed / 127773; - new_seed = 16807 * (new_seed - temp * 127773) - 2836 * temp; - if (new_seed < 0) - new_seed += 2147483647; - (seed) = (unsigned int)new_seed; - return (int)(new_seed & RAND_MAX); -} - -ACE_INLINE pid_t -ACE_OS::setsid (void) -{ - ACE_OS_TRACE ("ACE_OS::setsid"); - ACE_NOTSUP_RETURN (-1); -} - -ACE_INLINE mode_t -ACE_OS::umask (mode_t cmask) -{ -#if !defined (ACE_HAS_WINCE) - ACE_OS_TRACE ("ACE_OS::umask"); - ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1); -# else - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_OS::fstat (ACE_HANDLE handle, ACE_stat *stp) -{ - ACE_OS_TRACE ("ACE_OS::fstat"); -# if 1 - BY_HANDLE_FILE_INFORMATION fdata; - - if (::GetFileInformationByHandle (handle, &fdata) == FALSE) - { - ACE_OS::set_errno_to_last_error (); - return -1; - } - else if (fdata.nFileSizeHigh != 0) - { - errno = EINVAL; - return -1; - } - else - { - stp->st_size = fdata.nFileSizeLow; - stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); - stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); - stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); - stp->st_nlink = ACE_static_cast (short, fdata.nNumberOfLinks); - stp->st_dev = stp->st_rdev = 0; // No equivalent conversion. - stp->st_mode = S_IXOTH | S_IROTH | - (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) | - (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG); - } - return 0; -# else /* 1 */ - // This implementation close the handle. - int retval = -1; - int fd = ::_open_osfhandle ((long) handle, 0); - if (fd != -1) - retval = ::_fstat (fd, stp); - - ::_close (fd); - // Remember to close the file handle. - return retval; -# endif /* 1 */ -} - #endif /* WIN32 */ -ACE_INLINE int -ACE_OS::clock_gettime (clockid_t clockid, struct timespec *ts) -{ - ACE_OS_TRACE ("ACE_OS::clock_gettime"); -#if defined (ACE_HAS_CLOCK_GETTIME) - ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1); -# elif defined (ACE_PSOS) && ! defined (ACE_PSOS_DIAB_MIPS) - ACE_UNUSED_ARG (clockid); - ACE_PSOS_Time_t pt; - int result = ACE_PSOS_Time_t::get_system_time (pt); - *ts = ACE_static_cast (struct timespec, pt); - return result; -#else - ACE_UNUSED_ARG (clockid); - ACE_UNUSED_ARG (ts); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_CLOCK_GETTIME */ -} - -ACE_INLINE ACE_Time_Value -ACE_OS::gettimeofday (void) -{ - // ACE_OS_TRACE ("ACE_OS::gettimeofday"); - -#if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) - timeval tv; - int result = 0; -#endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) - -#if (0) - struct timespec ts; - - ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); - tv.tv_sec = ts.tv_sec; - tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec - -#elif defined (ACE_HAS_WINCE) - SYSTEMTIME tsys; - FILETIME tfile; - ::GetSystemTime (&tsys); - ::SystemTimeToFileTime (&tsys, &tfile); - return ACE_Time_Value (tfile); -#elif defined (ACE_WIN32) - FILETIME tfile; - ::GetSystemTimeAsFileTime (&tfile); - return ACE_Time_Value (tfile); -#if 0 - // From Todd Montgomery... - struct _timeb tb; - ::_ftime (&tb); - tv.tv_sec = tb.time; - tv.tv_usec = 1000 * tb.millitm; -#endif /* 0 */ -#elif defined (ACE_HAS_AIX_HI_RES_TIMER) - timebasestruct_t tb; - - ::read_real_time (&tb, TIMEBASE_SZ); - ::time_base_to_time (&tb, TIMEBASE_SZ); - - tv.tv_sec = tb.tb_high; - tv.tv_usec = tb.tb_low / 1000L; -#else -# if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \ - (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (m88k) && !defined (SCO)) - ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result); -# elif defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) - // Assumes that struct timespec is same size as struct timeval, - // which assumes that time_t is a long: it currently (VxWorks - // 5.2/5.3) is. - struct timespec ts; - - ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); - tv.tv_sec = ts.tv_sec; - tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec -# else - ACE_OSCALL (::gettimeofday (&tv), int, -1, result); -# endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ -#endif /* 0 */ -#if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) - if (result == -1) - return -1; - else - return ACE_Time_Value (tv); -#endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) -} - -ACE_INLINE int -ACE_OS::stat (const ACE_TCHAR *file, ACE_stat *stp) -{ - ACE_OS_TRACE ("ACE_OS::stat"); -#if defined (VXWORKS) - ACE_OSCALL_RETURN (::stat ((char *) file, stp), int, -1); -#elif defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (file); - ACE_UNUSED_ARG (stp); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (::stat_f ((char *) file, stp), int, -1); -#elif defined (ACE_HAS_WINCE) - ACE_TEXT_WIN32_FIND_DATA fdata; - - HANDLE fhandle; - - fhandle = ::FindFirstFile (file, &fdata); - if (fhandle == INVALID_HANDLE_VALUE) - { - ACE_OS::set_errno_to_last_error (); - return -1; - } - else if (fdata.nFileSizeHigh != 0) - { - errno = EINVAL; - return -1; - } - else - { - stp->st_size = fdata.nFileSizeLow; - stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime); - stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime); - } - return 0; -#elif defined (ACE_HAS_X86_STAT_MACROS) - // Solaris for intel uses an macro for stat(), this macro is a - // wrapper for _xstat(). - ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1); -#elif defined (__BORLANDC__) && (__BORLANDC__ <= 0x540) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wstat (file, stp), int, -1); -#elif defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wstat (file, (struct _stat *) stp), int, -1); -# else - ACE_OSCALL_RETURN (::_stat (file, (struct _stat *) stp), int, -1); -# endif /* ACE_USES_WCHAR */ -#else /* VXWORKS */ - ACE_OSCALL_RETURN (::stat (file, stp), int, -1); -#endif /* VXWORKS */ -} - -ACE_INLINE time_t -ACE_OS::time (time_t *tloc) -{ -#if !defined (ACE_HAS_WINCE) - ACE_OS_TRACE ("ACE_OS::time"); -# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) - unsigned long d_date, d_time, d_tick; - tm_get(&d_date, &d_time, &d_tick); // get current time - if (tloc) - *tloc = d_time; // set time as time_t - return d_time; -# else - ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1); -# endif /* ACE_PSOS && ! ACE_PSOS_HAS_TIME */ -#else - time_t retv = ACE_OS::gettimeofday ().sec (); - if (tloc) - *tloc = retv; - return retv; -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE void -ACE_OS::srand (u_int seed) -{ - ACE_OS_TRACE ("ACE_OS::srand"); - ::srand (seed); -} - -ACE_INLINE int -ACE_OS::rand (void) -{ - ACE_OS_TRACE ("ACE_OS::rand"); - ACE_OSCALL_RETURN (::rand (), int, -1); -} - -ACE_INLINE int -ACE_OS::unlink (const ACE_TCHAR *path) -{ - ACE_OS_TRACE ("ACE_OS::unlink"); -# if defined (VXWORKS) - ACE_OSCALL_RETURN (::unlink (ACE_const_cast (char *, path)), int, -1); -# elif defined (ACE_PSOS) && ! defined (ACE_PSOS_LACKS_PHILE) - ACE_OSCALL_RETURN (::remove_f ((char *) path), int , -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_C_LIBRARY) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::remove ((char *) path), - ace_result_), - int, -1); -# elif defined (ACE_HAS_WINCE) - // @@ The problem is, DeleteFile is not actually equals to unlink. ;( - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (path), ace_result_), - int, -1); -# elif defined (ACE_LACKS_UNLINK) - ACE_UNUSED_ARG (path); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wunlink (path), int, -1); -# else - ACE_OSCALL_RETURN (::unlink (path), int, -1); -# endif /* VXWORKS */ -} - -ACE_INLINE int -ACE_OS::rename (const ACE_TCHAR *old_name, - const ACE_TCHAR *new_name, - int flags) -{ -# if defined (ACE_LACKS_RENAME) - ACE_UNUSED_ARG (old_name); - ACE_UNUSED_ARG (new_name); - ACE_UNUSED_ARG (flags); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (flags); - if (MoveFile (old_name, new_name) != 0) - ACE_FAIL_RETURN (-1); - return 0; -# elif defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1) - // NT4 (and up) provides a way to rename/move a file with similar semantics - // to what's usually done on UNIX - if there's an existing file with - // <new_name> it is removed before the file is renamed/moved. The - // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives. - if (flags == -1) - flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING; - if (ACE_TEXT_MoveFileEx(old_name, new_name, flags) == 0) - ACE_FAIL_RETURN (-1); - return 0; -# elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_UNUSED_ARG (flags); - ACE_OSCALL_RETURN (::_wrename (old_name, new_name), int, -1); -# else /* ACE_LACKS_RENAME */ - ACE_UNUSED_ARG (flags); - ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1); -# endif /* ACE_LACKS_RENAME */ -} - -ACE_INLINE ACE_TCHAR * -ACE_OS::tempnam (const ACE_TCHAR *dir, const ACE_TCHAR *pfx) -{ - ACE_OS_TRACE ("ACE_OS::tempnam"); -#if defined (ACE_HAS_WINCE) || defined (ACE_LACKS_TEMPNAM) - ACE_UNUSED_ARG (dir); - ACE_UNUSED_ARG (pfx); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_PSOS) - // pSOS only considers the directory prefix - ACE_UNUSED_ARG (pfx); - ACE_OSCALL_RETURN (::tmpnam ((char *) dir), char *, 0); -#elif (defined (ACE_WIN32) && ((defined (__BORLANDC__) && !defined(ACE_USES_WCHAR)) || defined (__IBMCPP__))) - ACE_OSCALL_RETURN (::_tempnam ((char *) dir, (char *) pfx), char *, 0); -#elif defined(ACE_WIN32) && defined (__BORLANDC__) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wtempnam ((wchar_t*) dir, (wchar_t*) pfx), wchar_t *, 0); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wtempnam (dir, pfx), wchar_t *, 0); -#else /* ACE_HAS_WINCE || ACE_LACKS_TEMPNAM */ - ACE_OSCALL_RETURN (::tempnam (dir, pfx), char *, 0); -#endif /* VXWORKS */ -} - #if defined (ACE_HAS_SHM_OPEN) && defined(INTEGRITY) #include "ace/os_include/sys/os_mman.h" #endif -ACE_INLINE ACE_HANDLE -ACE_OS::shm_open (const ACE_TCHAR *filename, - int mode, - int perms, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_OS_TRACE ("ACE_OS::shm_open"); -# if defined (ACE_HAS_SHM_OPEN) - ACE_UNUSED_ARG (sa); - ACE_OSCALL_RETURN (::shm_open (filename, mode, perms), ACE_HANDLE, -1); -# else /* ! ACE_HAS_SHM_OPEN */ - // Just use ::open. - return ACE_OS::open (filename, mode, perms, sa); -# endif /* ACE_HAS_SHM_OPEN */ -} - -ACE_INLINE int -ACE_OS::shm_unlink (const ACE_TCHAR *path) -{ - ACE_OS_TRACE ("ACE_OS::shm_unlink"); -# if defined (ACE_HAS_SHM_OPEN) - ACE_OSCALL_RETURN (::shm_unlink (path), int, -1); -# else /* ! ACE_HAS_SHM_OPEN */ - // Just use ::unlink. - return ACE_OS::unlink (path); -# endif /* ACE_HAS_SHM_OPEN */ -} - -#if !defined (ACE_LACKS_CUSERID) -ACE_INLINE char * -ACE_OS::cuserid (char *user, size_t maxlen) -{ - ACE_OS_TRACE ("ACE_OS::cuserid"); -#if defined (VXWORKS) - ACE_UNUSED_ARG (maxlen); - if (user == 0) - { - // Require that the user field be non-null, i.e., don't - // allocate or use static storage. - ACE_NOTSUP_RETURN (0); - } - else - { - ::remCurIdGet (user, 0); - return user; - } -#elif defined (CHORUS) || defined (ACE_PSOS) || defined (__QNXNTO__) - ACE_UNUSED_ARG (user); - ACE_UNUSED_ARG (maxlen); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_WIN32) - BOOL result = GetUserNameA (user, (u_long *) &maxlen); - if (result == FALSE) - ACE_FAIL_RETURN (0); - else - return user; -#elif defined (ACE_HAS_ALT_CUSERID) -# if defined (ACE_LACKS_PWD_FUNCTIONS) -# error Cannot use alternate cuserid() without POSIX password functions! -# endif /* ACE_LACKS_PWD_FUNCTIONS */ - - // POSIX.1 dropped the cuserid() function. - // GNU GLIBC and other platforms correctly deprecate the cuserid() - // function. - - if (maxlen == 0) - { - // It doesn't make sense to have a zero length user ID. - errno = EINVAL; - return 0; - } - - struct passwd *pw = 0; - - // Make sure the file pointer is at the beginning of the password file - ::setpwent (); - // Should use ACE_OS::setpwent() but I didn't want to move this - // method after it. - - // Use the effective user ID to determine the user name. - pw = ::getpwuid (::geteuid ()); - - // Make sure the password file is closed. - ::endpwent (); - - size_t max_length = 0; - char *userid = 0; - - if (user == 0) - { - // Not reentrant/thread-safe, but nothing else can be done if a - // zero pointer was passed in as the destination. - -#if defined (_POSIX_SOURCE) - const size_t ACE_L_cuserid = L_cuserid; -#else - const size_t ACE_L_cuserid = 9; // 8 character user ID + NULL -#endif /* _POSIX_SOURCE */ - - static ACE_TCHAR tmp[ACE_L_cuserid] = { '\0' }; - max_length = ACE_L_cuserid - 1; // Do not include NULL in length - - userid = tmp; - } - else - { - max_length = maxlen; - userid = user; - } - - // Extract the user name from the passwd structure. - if (ACE_OS_String::strlen (pw->pw_name) <= max_length) - { - return ACE_OS_String::strcpy (userid, pw->pw_name); - } - else - { - errno = ENOSPC; // Buffer is not large enough. - return 0; - } -#else - // Hackish because of missing buffer size! - ACE_UNUSED_ARG (maxlen); - ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0); -#endif /* VXWORKS */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS::cuserid (wchar_t *user, size_t maxlen) -{ -# if defined (ACE_WIN32) - BOOL result = GetUserNameW (user, (u_long *) &maxlen); - if (result == FALSE) - ACE_FAIL_RETURN (0); - else - return user; -# else /* ACE_WIN32 */ - char *char_user; - wchar_t *result = 0; - - ACE_NEW_RETURN (char_user, char[maxlen + 1], 0); - - if (ACE_OS::cuserid (char_user, maxlen)) - { - ACE_OS::strcpy (user, ACE_Ascii_To_Wide (char_user).wchar_rep ()); - result = user; - } - - delete [] char_user; - - return result; -# endif /* ACE_WIN32 */ -} -#endif /* ACE_HAS_WCHAR */ -#endif /* ACE_LACKS_CUSERID */ - -ACE_INLINE int -ACE_OS::atexit (ACE_EXIT_HOOK func) -{ - return ACE_OS_Object_Manager::instance ()->at_exit (func); -} - -// Doesn't need a macro since it *never* returns! - -ACE_INLINE void -ACE_OS::_exit (int status) -{ - ACE_OS_TRACE ("ACE_OS::_exit"); -#if defined (VXWORKS) - ::exit (status); -#elif defined (ACE_PSOSIM) - ::u_exit (status); -#elif defined (ACE_PSOS) -# if defined (ACE_PSOS_LACKS_PREPC) /* pSoS TM does not support exit. */ - ACE_UNUSED_ARG (status); - return; -# else - ::exit (status); -# endif /* defined (ACE_PSOS_LACKS_PREPC) */ -#elif !defined (ACE_HAS_WINCE) - ::_exit (status); -#else - ::TerminateProcess (::GetCurrentProcess (), - status); -#endif /* VXWORKS */ -} - -ACE_INLINE void -ACE_OS::abort (void) -{ -#if !defined (ACE_HAS_WINCE) - ::abort (); -#else - // @@ CE doesn't support abort? - exit (1); -#endif /* !ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_OS::vsprintf (char *buffer, const char *format, va_list argptr) -{ - return ACE_SPRINTF_ADAPTER (::vsprintf (buffer, format, argptr)); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr) -{ -# if defined (ACE_HAS_VSWPRINTF) - return ::vswprintf (buffer, format, argptr); - -# else - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (argptr); - ACE_NOTSUP_RETURN (-1); - -# endif /* ACE_HAS_VSWPRINTF */ -} -#endif /* ACE_HAS_WCHAR */ - - -ACE_INLINE long -ACE_OS::sysconf (int name) -{ - ACE_OS_TRACE ("ACE_OS::sysconf"); -#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (-1); -#else - ACE_OSCALL_RETURN (::sysconf (name), long, -1); -#endif /* ACE_WIN32 || VXWORKS || ACE_PSOS */ -} - -ACE_INLINE int -ACE_OS::mutex_init (ACE_mutex_t *m, - int type, - const char *name, - ACE_mutexattr_t *attributes, - LPSECURITY_ATTRIBUTES sa) -{ - // ACE_OS_TRACE ("ACE_OS::mutex_init"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (sa); - - pthread_mutexattr_t l_attributes; - if (attributes == 0) - attributes = &l_attributes; - int result = 0; - int attr_init = 0; // have we initialized the local attributes. - - // Only do these initializations if the <attributes> parameter - // wasn't originally set. - if (attributes == &l_attributes) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - if (::pthread_mutexattr_create (attributes) == 0) -# elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD) - if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0) -# else /* draft 6 */ - if (::pthread_mutexattr_init (attributes) == 0) -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - { - result = 0; - attr_init = 1; // we have initialized these attributes - } - else - result = -1; // ACE_ADAPT_RETVAL used it for intermediate status - } - - if (result == 0) - { -# if defined (ACE_HAS_PTHREADS_DRAFT4) - if ( -# if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) - ::pthread_mutexattr_setkind_np (attributes, type) == 0 && -# endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ - ::pthread_mutex_init (m, *attributes) == 0) -# elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD) - if ( -# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED) - ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes, type), - result) == 0 && -# endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_MUTEXATTR_PSHARED */ - ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0) -# else - if ( -# if !defined (ACE_LACKS_MUTEXATTR_PSHARED) - ::pthread_mutexattr_setpshared (attributes, type) == 0 && -# endif /* ACE_LACKS_MUTEXATTR_PSHARED */ -# if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) - ::pthread_mutexattr_setkind_np (attributes, type) == 0 && -# endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ - ::pthread_mutex_init (m, attributes) == 0) -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - result = 0; - else - result = -1; // ACE_ADAPT_RETVAL used it for intermediate status - } - -# if (!defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) && !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_MUTEXATTR_PSHARED)) \ - || ((defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)) && !defined (_POSIX_THREAD_PROCESS_SHARED)) - ACE_UNUSED_ARG (type); -# endif /* ! ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ - - // Only do the deletions if the <attributes> parameter wasn't - // originally set. - if (attributes == &l_attributes && attr_init) -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_mutexattr_delete (&l_attributes); -# else - ::pthread_mutexattr_destroy (&l_attributes); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - - return result; -# elif defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (sa); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m, type, attributes), - ace_result_), - int, -1); -# elif defined (ACE_HAS_WTHREADS) - m->type_ = type; - - switch (type) - { - case USYNC_PROCESS: -# if defined (ACE_HAS_WINCE) - // @@todo (brunsch) This idea should be moved into ACE_OS_Win32. - m->proc_mutex_ = ::CreateMutexW (ACE_OS::default_win32_security_attributes (sa), - FALSE, - ACE_Ascii_To_Wide (name).wchar_rep ()); -# else /* ACE_HAS_WINCE */ - m->proc_mutex_ = ::CreateMutexA (ACE_OS::default_win32_security_attributes (sa), - FALSE, - name); -# endif /* ACE_HAS_WINCE */ - if (m->proc_mutex_ == 0) - ACE_FAIL_RETURN (-1); - else - { - // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary. - ACE_OS::set_errno_to_last_error (); - return 0; - } - case USYNC_THREAD: - return ACE_OS::thread_mutex_init (&m->thr_mutex_, - type, - name, - attributes); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ - -# elif defined (ACE_PSOS) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (sa); -# if defined (ACE_PSOS_HAS_MUTEX) - - u_long flags = MU_LOCAL; - u_long ceiling = 0; - -# if defined (ACE_HAS_RECURSIVE_MUTEXES) - flags |= MU_RECURSIVE; -# else /* ! ACE_HAS_RECURSIVE_MUTEXES */ - flags |= MU_NONRECURSIVE; -# endif /* ACE_HAS_RECURSIVE_MUTEXES */ - -# if defined (ACE_PSOS_HAS_PRIO_MUTEX) - - flags |= MU_PRIOR; - -# if defined (ACE_PSOS_HAS_PRIO_INHERIT_MUTEX) - flags |= MU_PRIO_INHERIT; -# elif defined (ACE_PSOS_HAS_PRIO_PROTECT_MUTEX) - ceiling = PSOS_TASK_MAX_PRIORITY; - flags |= MU_PRIO_PROTECT; -# else - flags |= MU_PRIO_NONE; -# endif /* ACE_PSOS_HAS_PRIO_INHERIT_MUTEX */ - -# else /* ! ACE_PSOS_HAS_PRIO_MUTEX */ - - flags |= MU_FIFO | MU_PRIO_NONE; - -# endif - - // Fake a pSOS name - it can be any 4-byte value, not necessarily needing - // to be ASCII. So use the mutex pointer passed in. That should identify - // each one uniquely. - union { ACE_mutex_t *p; char n[4]; } m_name; - m_name.p = m; - - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_create (m_name.n, - flags, - ceiling, - m), - ace_result_), - int, -1); - -# else /* ! ACE_PSOS_HAS_MUTEX */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_create ((char *) name, - 1, - SM_LOCAL | SM_PRIOR, - m), - ace_result_), - int, -1); -# endif /* ACE_PSOS_HAS_MUTEX */ -# elif defined (VXWORKS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (sa); - - return (*m = ::semMCreate (type)) == 0 ? -1 : 0; -# endif /* ACE_HAS_PTHREADS */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (sa); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::mutex_init (ACE_mutex_t *m, - int type, - const wchar_t *name, - ACE_mutexattr_t *attributes, - LPSECURITY_ATTRIBUTES sa) -{ -#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) - m->type_ = type; - - switch (type) - { - case USYNC_PROCESS: - m->proc_mutex_ = ::CreateMutexW (ACE_OS::default_win32_security_attributes (sa), - FALSE, - name); - if (m->proc_mutex_ == 0) - ACE_FAIL_RETURN (-1); - else - return 0; - case USYNC_THREAD: - return ACE_OS::thread_mutex_init (&m->thr_mutex_, - type, - name, - attributes); - } - - errno = EINVAL; - return -1; -#else /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */ - return ACE_OS::mutex_init (m, - type, ACE_Wide_To_Ascii (name).char_rep (), - attributes, - sa); -#endif /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::mutex_destroy (ACE_mutex_t *m) -{ - ACE_OS_TRACE ("ACE_OS::mutex_destroy"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) - ACE_OSCALL_RETURN (::pthread_mutex_destroy (m), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m), - ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), ace_result_), int, -1); -# elif defined (ACE_HAS_WTHREADS) - switch (m->type_) - { - case USYNC_PROCESS: - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_), - ace_result_), - int, -1); - case USYNC_THREAD: - return ACE_OS::thread_mutex_destroy (&m->thr_mutex_); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ -# elif defined (ACE_PSOS) -# if defined (ACE_PSOS_HAS_MUTEX) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_delete (*m), ace_result_), - int, -1); -# else /* ! ACE_PSOS_HAS_MUTEX */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_delete (*m), ace_result_), - int, -1); -# endif /* ACE_PSOS_HAS_MUTEX */ -# elif defined (VXWORKS) - return ::semDelete (*m) == OK ? 0 : -1; -# endif /* Threads variety case */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::mutex_lock (ACE_mutex_t *m) -{ - // ACE_OS_TRACE ("ACE_OS::mutex_lock"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - // Note, don't use "::" here since the following call is often a macro. -# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) - ACE_OSCALL_RETURN (pthread_mutex_lock (m), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), ace_result_), int, -1); -# elif defined (ACE_HAS_WTHREADS) - switch (m->type_) - { - case USYNC_PROCESS: - switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) - { - // - // Timeout can't occur, so don't bother checking... - // - case WAIT_OBJECT_0: - case WAIT_ABANDONED: - // We will ignore abandonments in this method - // Note that we still hold the lock - return 0; - default: - // This is a hack, we need to find an appropriate mapping... - ACE_OS::set_errno_to_last_error (); - return -1; - } - case USYNC_THREAD: - return ACE_OS::thread_mutex_lock (&m->thr_mutex_); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ -# elif defined (ACE_PSOS) -# if defined (ACE_PSOS_HAS_MUTEX) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_lock (*m, MU_WAIT, 0), - ace_result_), - int, -1); -# else /* ACE_PSOS_HAS_MUTEX */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_p (*m, SM_WAIT, 0), - ace_result_), - int, -1); -# endif /* ACE_PSOS_HAS_MUTEX */ -# elif defined (VXWORKS) - return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1; -# endif /* Threads variety case */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::mutex_lock (ACE_mutex_t *m, - int &abandoned) -{ - ACE_OS_TRACE ("ACE_OS::mutex_lock"); -#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) - abandoned = 0; - switch (m->type_) - { - case USYNC_PROCESS: - switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) - { - // - // Timeout can't occur, so don't bother checking... - // - case WAIT_OBJECT_0: - return 0; - case WAIT_ABANDONED: - abandoned = 1; - return 0; // something goofed, but we hold the lock ... - default: - // This is a hack, we need to find an appropriate mapping... - ACE_OS::set_errno_to_last_error (); - return -1; - } - case USYNC_THREAD: - return ACE_OS::thread_mutex_lock (&m->thr_mutex_); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (abandoned); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */ -} - -ACE_INLINE int -ACE_OS::mutex_trylock (ACE_mutex_t *m) -{ - ACE_OS_TRACE ("ACE_OS::mutex_trylock"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - // Note, don't use "::" here since the following call is often a macro. -# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) - int status = pthread_mutex_trylock (m); - if (status == 1) - status = 0; - else if (status == 0) { - status = -1; - errno = EBUSY; - } - return status; -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), ace_result_), int, -1); -# elif defined (ACE_HAS_WTHREADS) - switch (m->type_) - { - case USYNC_PROCESS: - { - // Try for 0 milliseconds - i.e. nonblocking. - switch (::WaitForSingleObject (m->proc_mutex_, 0)) - { - case WAIT_OBJECT_0: - return 0; - case WAIT_ABANDONED: - // We will ignore abandonments in this method. Note that - // we still hold the lock. - return 0; - case WAIT_TIMEOUT: - errno = EBUSY; - return -1; - default: - ACE_OS::set_errno_to_last_error (); - return -1; - } - } - case USYNC_THREAD: - return ACE_OS::thread_mutex_trylock (&m->thr_mutex_); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ -# elif defined (ACE_PSOS) -# if defined (ACE_PSOS_HAS_MUTEX) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_lock (*m, MU_NOWAIT, 0), - ace_result_), - int, -1); -# else /* ! ACE_PSOS_HAS_MUTEX */ - switch (::sm_p (*m, SM_NOWAIT, 0)) - { - case 0: - return 0; - case ERR_NOSEM: - errno = EBUSY; - // intentional fall through - default: - return -1; - } -# endif /* ACE_PSOS_HAS_MUTEX */ - -# elif defined (VXWORKS) - if (::semTake (*m, NO_WAIT) == ERROR) - if (errno == S_objLib_OBJ_UNAVAILABLE) - { - // couldn't get the semaphore - errno = EBUSY; - return -1; - } - else - // error - return -1; - else - // got the semaphore - return 0; -# endif /* Threads variety case */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::mutex_trylock (ACE_mutex_t *m, int &abandoned) -{ -#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) - abandoned = 0; - switch (m->type_) - { - case USYNC_PROCESS: - { - // Try for 0 milliseconds - i.e. nonblocking. - switch (::WaitForSingleObject (m->proc_mutex_, 0)) - { - case WAIT_OBJECT_0: - return 0; - case WAIT_ABANDONED: - abandoned = 1; - return 0; // something goofed, but we hold the lock ... - case WAIT_TIMEOUT: - errno = EBUSY; - return -1; - default: - ACE_OS::set_errno_to_last_error (); - return -1; - } - } - case USYNC_THREAD: - return ACE_OS::thread_mutex_trylock (&m->thr_mutex_); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (abandoned); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */ -} - -ACE_INLINE int -ACE_OS::mutex_lock (ACE_mutex_t *m, - const ACE_Time_Value &timeout) -{ -#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS) - -# if defined (ACE_HAS_PTHREADS) - int result; - - // "timeout" should be an absolute time. - - timespec_t ts = timeout; // Calls ACE_Time_Value::operator timespec_t(). - - // Note that the mutex should not be a recursive one, i.e., it - // should only be a standard mutex or an error checking mutex. - - ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result); - - // We need to adjust this to make the errno values consistent. - if (result == -1 && errno == ETIMEDOUT) - errno = ETIME; - return result; - -# elif defined (ACE_HAS_WTHREADS) - // Note that we must convert between absolute time (which is passed - // as a parameter) and relative time (which is what the system call - // expects). - ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); - - switch (m->type_) - { - case USYNC_PROCESS: - switch (::WaitForSingleObject (m->proc_mutex_, - relative_time.msec ())) - { - case WAIT_OBJECT_0: - case WAIT_ABANDONED: - // We will ignore abandonments in this method - // Note that we still hold the lock - return 0; - case WAIT_TIMEOUT: - errno = ETIME; - return -1; - default: - // This is a hack, we need to find an appropriate mapping... - ACE_OS::set_errno_to_last_error (); - return -1; - } - case USYNC_THREAD: - ACE_NOTSUP_RETURN (-1); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ - -# elif defined (ACE_PSOS) - - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what - // the system call expects). - ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); - - u_long ticks = relative_time.sec() * KC_TICKS2SEC + - relative_time.usec () * KC_TICKS2SEC / - ACE_ONE_SECOND_IN_USECS; - if (ticks == 0) - ACE_OSCALL_RETURN (::sm_p (*m, SM_NOWAIT, 0), int, -1); // no timeout - else - ACE_OSCALL_RETURN (::sm_p (*m, SM_WAIT, ticks), int, -1); - -# elif defined (VXWORKS) - - // Note that we must convert between absolute time (which is passed - // as a parameter) and relative time (which is what the system call - // expects). - ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); - - int ticks_per_sec = ::sysClkRateGet (); - - int ticks = relative_time.sec() * ticks_per_sec + - relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; - if (::semTake (*m, ticks) == ERROR) - { - if (errno == S_objLib_OBJ_TIMEOUT) - // Convert the VxWorks errno to one that's common for to ACE - // platforms. - errno = ETIME; - else if (errno == S_objLib_OBJ_UNAVAILABLE) - errno = EBUSY; - return -1; - } - else - return 0; -# endif /* ACE_HAS_PTHREADS */ - -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (timeout); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */ -} - -ACE_INLINE int -ACE_OS::mutex_lock (ACE_mutex_t *m, - const ACE_Time_Value *timeout) -{ - return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout); -} - -ACE_INLINE int -ACE_OS::mutex_unlock (ACE_mutex_t *m) -{ - ACE_OS_TRACE ("ACE_OS::mutex_unlock"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - // Note, don't use "::" here since the following call is often a macro. -# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) - ACE_OSCALL_RETURN (pthread_mutex_unlock (m), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), ace_result_), int, -1); -# elif defined (ACE_HAS_WTHREADS) - switch (m->type_) - { - case USYNC_PROCESS: - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_), - ace_result_), - int, -1); - case USYNC_THREAD: - return ACE_OS::thread_mutex_unlock (&m->thr_mutex_); - default: - errno = EINVAL; - return -1; - } - /* NOTREACHED */ -# elif defined (ACE_PSOS) -# if defined (ACE_PSOS_HAS_MUTEX) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_unlock (*m), ace_result_), - int, -1); -# else /* ! ACE_PSOS_HAS_MUTEX */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_v (*m), ace_result_), - int, -1); -# endif /* ACE_PSOS_HAS_MUTEX */ -# elif defined (VXWORKS) - return ::semGive (*m) == OK ? 0 : -1; -# endif /* Threads variety case */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thread_mutex_init (ACE_thread_mutex_t *m, - int type, - const char *name, - ACE_mutexattr_t *arg) -{ - // ACE_OS_TRACE ("ACE_OS::thread_mutex_init"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ::InitializeCriticalSection (m); - return 0; - -# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (type); - // Force the use of USYNC_THREAD! - return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg); - -# elif defined (VXWORKS) || defined (ACE_PSOS) - return mutex_init (m, type, name, arg); - -# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ - -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); - -#endif /* ACE_HAS_THREADS */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::thread_mutex_init (ACE_thread_mutex_t *m, - int type, - const wchar_t *name, - ACE_mutexattr_t *arg) -{ - // ACE_OS_TRACE ("ACE_OS::thread_mutex_init"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ::InitializeCriticalSection (m); - return 0; - -# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (type); - // Force the use of USYNC_THREAD! - return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg); - -# elif defined (VXWORKS) || defined (ACE_PSOS) - return mutex_init (m, type, name, arg); - -# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ - -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); - -#endif /* ACE_HAS_THREADS */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::thread_mutex_destroy (ACE_thread_mutex_t *m) -{ - ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) - ::DeleteCriticalSection (m); - return 0; - -# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - return ACE_OS::mutex_destroy (m); - -# elif defined (VXWORKS) || defined (ACE_PSOS) - return mutex_destroy (m); - -# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ - -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); - -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m) -{ - // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) - ::EnterCriticalSection (m); - return 0; -# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - return ACE_OS::mutex_lock (m); -# elif defined (VXWORKS) || defined (ACE_PSOS) - return mutex_lock (m); -# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m, - const ACE_Time_Value &timeout) -{ - // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock"); - - // For all platforms, except MS Windows, this method is equivalent - // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and - // ACE_mutex_t are the same type. However, those typedefs evaluate - // to different types on MS Windows. The "thread mutex" - // implementation in ACE for MS Windows cannot readily support - // timeouts due to a lack of timeout features for this type of MS - // Windows synchronization mechanism. - -#if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS) -# if defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - return ACE_OS::mutex_lock (m, timeout); -#elif defined (VXWORKS) || defined (ACE_PSOS) - return mutex_lock (m, timeout); -#endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (timeout); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m, - const ACE_Time_Value *timeout) -{ - return timeout == 0 - ? ACE_OS::thread_mutex_lock (m) - : ACE_OS::thread_mutex_lock (m, *timeout); -} - -ACE_INLINE int -ACE_OS::thread_mutex_trylock (ACE_thread_mutex_t *m) -{ - ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock"); - -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) -# if defined (ACE_HAS_WIN32_TRYLOCK) - BOOL result = ::TryEnterCriticalSection (m); - if (result == TRUE) - return 0; - else - { - errno = EBUSY; - return -1; - } -# else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WIN32_TRYLOCK */ -# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - return ACE_OS::mutex_trylock (m); -# elif defined (VXWORKS) || defined (ACE_PSOS) - return ACE_OS::mutex_trylock (m); -#endif /* Threads variety case */ - -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thread_mutex_unlock (ACE_thread_mutex_t *m) -{ - ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_WTHREADS) - ::LeaveCriticalSection (m); - return 0; -# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) - return ACE_OS::mutex_unlock (m); -# elif defined (VXWORKS) || defined (ACE_PSOS) - return ACE_OS::mutex_unlock (m); -# endif /* Threads variety case */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -#if !defined (ACE_LACKS_COND_T) -// NOTE: The ACE_OS::cond_* functions for Unix platforms are defined -// here because the ACE_OS::sema_* functions below need them. -// However, ACE_WIN32 and VXWORKS define the ACE_OS::cond_* functions -// using the ACE_OS::sema_* functions. So, they are defined in OS.cpp. - -ACE_INLINE int -ACE_OS::cond_destroy (ACE_cond_t *cv) -{ - ACE_OS_TRACE ("ACE_OS::cond_destroy"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_cond_destroy (cv), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_destroy (cv), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), ace_result_), int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_delete (*cv), ace_result_), - int, -1); -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (cv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::condattr_init (ACE_condattr_t &attributes, - int type) -{ - ACE_UNUSED_ARG (type); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - int result = -1; - - if ( -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_condattr_create (&attributes) == 0 -# elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7) - ACE_ADAPT_RETVAL(::pthread_condattr_init (&attributes), result) == 0 -# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED) - && ACE_ADAPT_RETVAL(::pthread_condattr_setpshared(&attributes, type), - result) == 0 -# endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_MUTEXATTR_PSHARED */ -# else /* this is draft 6 */ - ::pthread_condattr_init (&attributes) == 0 -# if !defined (ACE_LACKS_CONDATTR_PSHARED) - && ::pthread_condattr_setpshared (&attributes, type) == 0 -# endif /* ACE_LACKS_CONDATTR_PSHARED */ -# if defined (ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP) - && ::pthread_condattr_setkind_np (&attributes, type) == 0 -# endif /* ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP */ -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - ) - result = 0; - else - result = -1; // ACE_ADAPT_RETVAL used it for intermediate status - - return result; -# elif defined (ACE_HAS_STHREADS) - attributes.type = type; - - return 0; - -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) -# if defined (ACE_PSOS_HAS_PRIO_MUTEX) - attributes = CV_LOCAL | CV_PRIOR; -# else /* ACE_PSOS_HAS_PRIO_MUTEX */ - attributes = CV_LOCAL | CV_FIFO; -# endif /* ACE_PSOS_HAS_PRIO_MUTEX */ - return 0; - -# else - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (type); - ACE_NOTSUP_RETURN (-1); - -# endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. pSOS */ - -# else - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (type); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::condattr_destroy (ACE_condattr_t &attributes) -{ -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_condattr_delete (&attributes); -# else - ::pthread_condattr_destroy (&attributes); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - -# elif defined (ACE_HAS_STHREADS) - attributes.type = 0; - -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - attributes = 0; - -# endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. ACE_PSOS */ - return 0; -# else - ACE_UNUSED_ARG (attributes); - return 0; -# endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::cond_init (ACE_cond_t *cv, - ACE_condattr_t &attributes, - const char *name, - void *arg) -{ - // ACE_OS_TRACE ("ACE_OS::cond_init"); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - int result = -1; - - if ( -# if defined (ACE_HAS_PTHREADS_DRAFT4) - ::pthread_cond_init (cv, attributes) == 0 -# elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7) - ACE_ADAPT_RETVAL(::pthread_cond_init (cv, &attributes), result) == 0 -# else /* this is draft 6 */ - ::pthread_cond_init (cv, &attributes) == 0 -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - ) - result = 0; - else - result = -1; // ACE_ADAPT_RETVAL used it for intermediate status - - return result; -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv, - attributes.type, - arg), - ace_result_), - int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_create (ACE_const_cast (char *, name), - attributes, - cv), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. ACE_PSOS */ -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (attributes); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::cond_init (ACE_cond_t *cv, - ACE_condattr_t &attributes, - const wchar_t *name, - void *arg) -{ - return ACE_OS::cond_init (cv, attributes, ACE_Wide_To_Ascii (name).char_rep (), arg); -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg) -{ - ACE_condattr_t attributes; - if (ACE_OS::condattr_init (attributes, type) == 0 - && ACE_OS::cond_init (cv, attributes, name, arg) == 0) - { - (void) ACE_OS::condattr_destroy (attributes); - return 0; - } - return -1; -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg) -{ - return ACE_OS::cond_init (cv, type, ACE_Wide_To_Ascii (name).char_rep (), arg); -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::cond_signal (ACE_cond_t *cv) -{ - ACE_OS_TRACE ("ACE_OS::cond_signal"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_cond_signal (cv), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_signal (cv),ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), ace_result_), int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_signal (*cv), ace_result_), - int, -1); -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (cv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::cond_broadcast (ACE_cond_t *cv) -{ - ACE_OS_TRACE ("ACE_OS::cond_broadcast"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_cond_broadcast (cv), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_broadcast (cv), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv), - ace_result_), - int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_broadcast (*cv), ace_result_), - int, -1); -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (cv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::cond_wait (ACE_cond_t *cv, - ACE_mutex_t *external_mutex) -{ - ACE_OS_TRACE ("ACE_OS::cond_wait"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_cond_wait (cv, external_mutex), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_wait (cv, external_mutex), ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), ace_result_), - int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, 0), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS */ -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (external_mutex); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::cond_timedwait (ACE_cond_t *cv, - ACE_mutex_t *external_mutex, - ACE_Time_Value *timeout) -{ - ACE_OS_TRACE ("ACE_OS::cond_timedwait"); -# if defined (ACE_HAS_THREADS) - int result; - timespec_t ts; - - if (timeout != 0) - ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). - -# if defined (ACE_HAS_PTHREADS) - -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - if (timeout == 0) - ACE_OSCALL (::pthread_cond_wait (cv, external_mutex), - int, -1, result); - else - { - -# if defined (__Lynx__) - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what the - // LynxOS pthread_cond_timedwait expects). This differs from 1003.4a - // draft 4. - - timespec_t relative_time = *timeout - ACE_OS::gettimeofday (); - - ACE_OSCALL (::pthread_cond_timedwait (cv, external_mutex, - &relative_time), - int, -1, result); -# else - ACE_OSCALL (::pthread_cond_timedwait (cv, external_mutex, - (ACE_TIMESPEC_PTR) &ts), - int, -1, result); -# endif /* __Lynx__ */ - } - -# else - ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0 - ? ::pthread_cond_wait (cv, external_mutex) - : ::pthread_cond_timedwait (cv, external_mutex, - (ACE_TIMESPEC_PTR) &ts), - result), - int, -1, result); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/ - // We need to adjust this to make the POSIX and Solaris return - // values consistent. EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and - // down); EINTR is from LynxOS. - if (result == -1 && - (errno == ETIMEDOUT || errno == EAGAIN || errno == EINTR)) - errno = ETIME; - -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0 - ? ::cond_wait (cv, external_mutex) - : ::cond_timedwait (cv, - external_mutex, - (timestruc_t*)&ts), - result), - int, -1, result); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) - // pSOS condition value timeout is expressed in ticks. If the - // cv_wait times out, the mutex is unlocked upon return. - if (timeout == 0) - { - ACE_OSCALL (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, 0), - result), - int, -1, result); - } - else - { - // Need to convert the passed absolute time to relative time - // expressed in ticks. - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); - int ticks = (relative_time.sec () * KC_TICKS2SEC) + - (relative_time.usec () * KC_TICKS2SEC / - ACE_ONE_SECOND_IN_USECS); - if (ticks <= 0) - ticks = 1; // Don't wait forever - ACE_OSCALL (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, ticks), - result), - int, -1, result); - if (result == -1 && errno == 1) - { - // cv timed out and returned pSOS timeout error 0x01, which - // ACE_ADAPT_RETVAL stored in errno. - ::mu_lock (*external_mutex, MU_WAIT, 0); - errno = ETIME; - } - } - - return result; - -# endif /* ACE_HAS_STHREADS */ - if (timeout != 0) - timeout->set (ts); // Update the time value before returning. - - return result; -# else - ACE_UNUSED_ARG (cv); - ACE_UNUSED_ARG (external_mutex); - ACE_UNUSED_ARG (timeout); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -#endif /* !ACE_LACKS_COND_T */ - -ACE_INLINE int -ACE_OS::thr_equal (ACE_thread_t t1, ACE_thread_t t2) -{ -#if defined (ACE_HAS_PTHREADS) -# if defined (pthread_equal) - // If it's a macro we can't say "::pthread_equal"... - return pthread_equal (t1, t2); -# else - return ::pthread_equal (t1, t2); -# endif /* pthread_equal */ -#elif defined (VXWORKS) - return ! ACE_OS::strcmp (t1, t2); -#else /* For both STHREADS and WTHREADS... */ - // Hum, Do we need to treat WTHREAD differently? - // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD. - return t1 == t2; -#endif /* ACE_HAS_PTHREADS */ -} - -ACE_INLINE void -ACE_OS::thr_self (ACE_hthread_t &self) -{ - ACE_OS_TRACE ("ACE_OS::thr_self"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - // Note, don't use "::" here since the following call is often a macro. - self = pthread_self (); -# elif defined (ACE_HAS_THREAD_SELF) - self = ::thread_self (); -# elif defined (ACE_HAS_STHREADS) - self = ::thr_self (); -# elif defined (ACE_HAS_WTHREADS) - self = ::GetCurrentThread (); -# elif defined (ACE_PSOS) - t_ident ((char *) 0, 0, &self); -# elif defined (VXWORKS) - self = ::taskIdSelf (); -# endif /* ACE_HAS_STHREADS */ -#else - self = 1; // Might as well make it the main thread ;-) -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE ACE_thread_t -ACE_OS::thr_self (void) -{ - // ACE_OS_TRACE ("ACE_OS::thr_self"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) - // Note, don't use "::" here since the following call is often a macro. - ACE_OSCALL_RETURN (pthread_self (), int, -1); -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (::thr_self (), int, -1); -# elif defined (ACE_HAS_WTHREADS) - return ::GetCurrentThreadId (); -# elif defined (ACE_PSOS) - // there does not appear to be a way to get - // a task's name other than at creation - return 0; -# elif defined (VXWORKS) - return ::taskName (::taskIdSelf ()); -# endif /* ACE_HAS_STHREADS */ -#else - return 1; // Might as well make it the first thread ;-) -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::recursive_mutex_init (ACE_recursive_thread_mutex_t *m, - const ACE_TCHAR *name, - ACE_mutexattr_t *arg, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_UNUSED_ARG (sa); -#if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_RECURSIVE_MUTEXES) - return ACE_OS::thread_mutex_init (m, 0, name, arg); -#else - if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1) - return -1; - else if (ACE_OS::cond_init (&m->lock_available_, - (short) USYNC_THREAD, - name, - 0) == -1) - return -1; - else - { - m->nesting_level_ = 0; - m->owner_id_ = ACE_OS::NULL_thread; - return 0; - } -#endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m) -{ -#if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_RECURSIVE_MUTEXES) - return ACE_OS::thread_mutex_destroy (m); -#else - if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1) - return -1; - else if (ACE_OS::cond_destroy (&m->lock_available_) == -1) - return -1; - else - return 0; -#endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::recursive_mutex_lock (ACE_recursive_thread_mutex_t *m) -{ -#if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_RECURSIVE_MUTEXES) - return ACE_OS::thread_mutex_lock (m); -#else - ACE_thread_t t_id = ACE_OS::thr_self (); - int result = 0; - - // Acquire the guard. - if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) - result = -1; - else - { - // If there's no contention, just grab the lock immediately - // (since this is the common case we'll optimize for it). - if (m->nesting_level_ == 0) - m->owner_id_ = t_id; - // If we already own the lock, then increment the nesting level - // and return. - else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0) - { - // Wait until the nesting level has dropped to zero, at - // which point we can acquire the lock. - while (m->nesting_level_ > 0) - ACE_OS::cond_wait (&m->lock_available_, - &m->nesting_mutex_); - - // At this point the nesting_mutex_ is held... - m->owner_id_ = t_id; - } - - // At this point, we can safely increment the nesting_level_ no - // matter how we got here! - m->nesting_level_++; - } - - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - } - return result; -#endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m) -{ -#if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_RECURSIVE_MUTEXES) - return ACE_OS::thread_mutex_trylock (m); -#else - ACE_thread_t t_id = ACE_OS::thr_self (); - int result = 0; - - // Acquire the guard. - if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) - result = -1; - else - { - // If there's no contention, just grab the lock immediately. - if (m->nesting_level_ == 0) - { - m->owner_id_ = t_id; - m->nesting_level_ = 1; - } - // If we already own the lock, then increment the nesting level - // and proceed. - else if (ACE_OS::thr_equal (t_id, m->owner_id_)) - m->nesting_level_++; - else - { - errno = EBUSY; - result = -1; - } - } - - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - } - return result; -#endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m) -{ -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_RECURSIVE_MUTEXES) - return ACE_OS::thread_mutex_unlock (m); -# else - ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock"); -# if !defined (ACE_NDEBUG) - ACE_thread_t t_id = ACE_OS::thr_self (); -# endif /* ACE_NDEBUG */ - int result = 0; - - if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) - result = -1; - else - { -# if !defined (ACE_NDEBUG) - if (m->nesting_level_ == 0 - || ACE_OS::thr_equal (t_id, m->owner_id_) == 0) - { - errno = EINVAL; - result = -1; - } - else -# endif /* ACE_NDEBUG */ - { - m->nesting_level_--; - if (m->nesting_level_ == 0) - { - // This may not be strictly necessary, but it does put - // the mutex into a known state... - m->owner_id_ = ACE_OS::NULL_thread; - - // Inform a waiter that the lock is free. - if (ACE_OS::cond_signal (&m->lock_available_) == -1) - result = -1; - } - } - } - - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - } - return result; -# endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -// This method is used to prepare the recursive mutex for releasing -// when waiting on a condition variable. If the platform doesn't have -// native recursive mutex and condition variable support, then ACE needs -// to save the recursion state around the wait and also ensure that the -// wait and lock release are atomic. recursive_mutex_cond_relock() -// is the inverse of this method. -ACE_INLINE int -ACE_OS::recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, - ACE_recursive_mutex_state &state) -{ -#if defined (ACE_HAS_THREADS) - ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock"); -# if defined (ACE_HAS_RECURSIVE_MUTEXES) - // Windows need special handling since it has recursive mutexes, but - // does not integrate them into a condition variable. -# if defined (ACE_WIN32) - // For Windows, the OS takes care of the mutex and its recursion. We just - // need to release the lock one fewer times than this thread has acquired - // it. Remember how many times, and reacquire it that many more times when - // the condition is signaled. - state.relock_count_ = 0; - while (m->LockCount > 0 -# if !defined (ACE_HAS_WINCE) /* WinCE doesn't have RecursionCount */ - && m->RecursionCount > 1 -# endif - ) - { - // This may fail if the current thread doesn't own the mutex. If it - // does fail, it'll be on the first try, so don't worry about resetting - // the state. - if (ACE_OS::recursive_mutex_unlock (m) == -1) - return -1; - ++state.relock_count_; - } -# else /* not ACE_WIN32 */ - // prevent warnings for unused variables - ACE_UNUSED_ARG (state); - ACE_UNUSED_ARG (m); -# endif /* ACE_WIN32 */ - return 0; -# else /* ACE_HAS_RECURSIVE_MUTEXES */ - // For platforms without recursive mutexes, we obtain the nesting mutex - // to gain control over the mutex internals. Then set the internals to say - // the mutex is available. If there are waiters, signal the condition - // to notify them (this is mostly like the recursive_mutex_unlock() method). - // Then, return with the nesting mutex still held. The condition wait - // will release it atomically, allowing mutex waiters to continue. - // Note that this arrangement relies on the fact that on return from - // the condition wait, this thread will again own the nesting mutex - // and can either set the mutex internals directly or get in line for - // the mutex... this part is handled in recursive_mutex_cond_relock(). - if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) - return -1; - -# if !defined (ACE_NDEBUG) - if (m->nesting_level_ == 0 - || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0) - { - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - errno = EINVAL; - return -1; - } -# endif /* ACE_NDEBUG */ - - // To make error recovery a bit easier, signal the condition now. Any - // waiter won't regain control until the mutex is released, which won't - // be until the caller returns and does the wait on the condition. - if (ACE_OS::cond_signal (&m->lock_available_) == -1) - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - return -1; - } - - // Ok, the nesting_mutex_ lock is still held, the condition has been - // signaled... reset the nesting info and return _WITH_ the lock - // held. The lock will be released when the condition waits, in the - // caller. - state.nesting_level_ = m->nesting_level_; - state.owner_id_ = m->owner_id_; - m->nesting_level_ = 0; - m->owner_id_ = ACE_OS::NULL_thread; - return 0; -# endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (state); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - - -// This method is called after waiting on a condition variable when a -// recursive mutex must be reacquired. If the platform doesn't natively -// integrate recursive mutexes and condition variables, it's taken care -// of here (inverse of ACE_OS::recursive_mutex_cond_unlock). -ACE_INLINE void -ACE_OS::recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, - ACE_recursive_mutex_state &state) -{ -#if defined (ACE_HAS_THREADS) - ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock"); -# if defined (ACE_HAS_RECURSIVE_MUTEXES) - // Windows need special handling since it has recursive mutexes, but - // does not integrate them into a condition variable. - // On entry, the OS has already reacquired the lock for us. Just - // reacquire it the proper number of times so the recursion is the same as - // before waiting on the condition. -# if defined (ACE_WIN32) - while (state.relock_count_ > 0) - { - ACE_OS::recursive_mutex_lock (m); - --state.relock_count_; - } - return; -# else /* not ACE_WIN32 */ - // prevent warnings for unused variables - ACE_UNUSED_ARG (state); - ACE_UNUSED_ARG (m); - -# endif /* ACE_WIN32 */ -# else - // Without recursive mutex support, it's somewhat trickier. On entry, - // the current thread holds the nesting_mutex_, but another thread may - // still be holding the ACE_recursive_mutex_t. If so, mimic the code - // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex. - // After acquiring it, restore the nesting counts and release the - // nesting mutex. This will restore the conditions to what they were - // before calling ACE_OS::recursive_mutex_cond_unlock(). - while (m->nesting_level_ > 0) - ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_); - - // At this point, we still have nesting_mutex_ and the mutex is free. - m->nesting_level_ = state.nesting_level_; - m->owner_id_ = state.owner_id_; - ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); - return; -# endif /* ACE_HAS_RECURSIVE_MUTEXES */ -#else - ACE_UNUSED_ARG (m); - ACE_UNUSED_ARG (state); - return; -#endif /* ACE_HAS_THREADS */ -} - - -ACE_INLINE int -ACE_OS::sema_destroy (ACE_sema_t *s) -{ - ACE_OS_TRACE ("ACE_OS::sema_destroy"); -# if defined (ACE_HAS_POSIX_SEM) - int result; -# if defined (ACE_LACKS_NAMED_POSIX_SEM) - if (s->name_) - { - // Only destroy the semaphore if we're the ones who - // initialized it. - ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result); - ACE_OS::shm_unlink (s->name_); - delete s->name_; - return result; - } -# else - if (s->name_) - { - ACE_OSCALL (::sem_unlink (s->name_), int, -1, result); - ACE_OS::free ((void *) s->name_); - ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1); - } -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ - else - { - ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result); -# if defined (ACE_LACKS_NAMED_POSIX_SEM) - if (s->new_sema_ != 0) -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ - delete s->sema_; - s->sema_ = 0; - return result; - } -# elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), ace_result_), int, -1); -# elif defined (ACE_HAS_PTHREADS) - int r1 = ACE_OS::mutex_destroy (&s->lock_); - int r2 = ACE_OS::cond_destroy (&s->count_nonzero_); - return r1 != 0 || r2 != 0 ? -1 : 0; -# elif defined (ACE_HAS_WTHREADS) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1); -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - // Free up underlying objects of the simulated semaphore. - int r1 = ACE_OS::thread_mutex_destroy (&s->lock_); - int r2 = ACE_OS::event_destroy (&s->count_nonzero_); - return r1 != 0 || r2 != 0 ? -1 : 0; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - int result; - ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_delete (s->sema_), result), int, -1, result); - s->sema_ = 0; - return result; -# elif defined (VXWORKS) - int result; - ACE_OSCALL (::semDelete (s->sema_), int, -1, result); - s->sema_ = 0; - return result; -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_POSIX_SEM */ -} - -// NOTE: The following four function definitions must appear before -// ACE_OS::sema_init (). - -ACE_INLINE int -ACE_OS::close (ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::close"); -#if defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1); -#elif defined (ACE_PSOS) && ! defined (ACE_PSOS_LACKS_PHILE) - u_long result = ::close_f (handle); - if (result != 0) - { - errno = result; - return ACE_static_cast (int, -1); - } - return ACE_static_cast (int, 0); -#else - ACE_OSCALL_RETURN (::close (handle), int, -1); -#endif /* ACE_WIN32 */ -} - -// This function returns the number of bytes in the file referenced by -// FD. - -ACE_INLINE long -ACE_OS::filesize (ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::filesize"); -#if defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (::GetFileSize (handle, 0), long, -1); -#else /* !ACE_WIN32 */ - struct stat sb; - return ACE_OS::fstat (handle, &sb) == -1 ? -1 : (long) sb.st_size; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::ftruncate (ACE_HANDLE handle, off_t offset) -{ - ACE_OS_TRACE ("ACE_OS::ftruncate"); -#if defined (ACE_WIN32) - if (::SetFilePointer (handle, offset, 0, FILE_BEGIN) != (unsigned) -1) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1); - else - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ -#elif defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (offset); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (::ftruncate_f (handle, offset), int, -1); -#else - ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE void * -ACE_OS::mmap (void *addr, - size_t len, - int prot, - int flags, - ACE_HANDLE file_handle, - off_t off, - ACE_HANDLE *file_mapping, - LPSECURITY_ATTRIBUTES sa, - const ACE_TCHAR *file_mapping_name) -{ - ACE_OS_TRACE ("ACE_OS::mmap"); -#if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) - ACE_UNUSED_ARG (file_mapping_name); -#endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */ - -#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) - -# if defined(ACE_HAS_WINCE) - ACE_UNUSED_ARG (addr); - if (ACE_BIT_ENABLED (flags, MAP_FIXED)) // not supported - { - errno = EINVAL; - return MAP_FAILED; - } -# else - if (!ACE_BIT_ENABLED (flags, MAP_FIXED)) - addr = 0; - else if (addr == 0) // can not map to address 0 - { - errno = EINVAL; - return MAP_FAILED; - } -# endif - - int nt_flags = 0; - ACE_HANDLE local_handle = ACE_INVALID_HANDLE; - - // Ensure that file_mapping is non-zero. - if (file_mapping == 0) - file_mapping = &local_handle; - - if (ACE_BIT_ENABLED (flags, MAP_PRIVATE)) - { -# if !defined(ACE_HAS_WINCE) - prot = PAGE_WRITECOPY; -# endif // ACE_HAS_WINCE - nt_flags = FILE_MAP_COPY; - } - else if (ACE_BIT_ENABLED (flags, MAP_SHARED)) - { - if (ACE_BIT_ENABLED (prot, PAGE_READONLY)) - nt_flags = FILE_MAP_READ; - if (ACE_BIT_ENABLED (prot, PAGE_READWRITE)) - nt_flags = FILE_MAP_WRITE; - } - - // Only create a new handle if we didn't have a valid one passed in. - if (*file_mapping == ACE_INVALID_HANDLE) - { -# if !defined(ACE_HAS_WINCE) && (!defined (ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0)) - int try_create = 1; - if ((file_mapping_name != 0) && (*file_mapping_name != 0)) - { - // On Win9x, we first try to OpenFileMapping to - // file_mapping_name. Only if there is no mapping object - // with that name, and the desired name is valid, do we try - // CreateFileMapping. - - *file_mapping = ACE_TEXT_OpenFileMapping (nt_flags, - 0, - file_mapping_name); - if (*file_mapping != 0 - || (::GetLastError () == ERROR_INVALID_NAME - && ::GetLastError () == ERROR_FILE_NOT_FOUND)) - try_create = 0; - } - - if (try_create) -# endif /* !ACE_HAS_WINCE && (ACE_HAS_WINNT4 || ACE_HAS_WINNT4 == 0) */ - { - const LPSECURITY_ATTRIBUTES attr = - ACE_OS::default_win32_security_attributes (sa); - - *file_mapping = ACE_TEXT_CreateFileMapping (file_handle, - attr, - prot, - 0, - 0, - file_mapping_name); - } - } - - if (*file_mapping == 0) - ACE_FAIL_RETURN (MAP_FAILED); - -# if defined (ACE_OS_EXTRA_MMAP_FLAGS) - nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS; -# endif /* ACE_OS_EXTRA_MMAP_FLAGS */ - -# if !defined (ACE_HAS_WINCE) - void *addr_mapping = ::MapViewOfFileEx (*file_mapping, - nt_flags, - 0, - off, - len, - addr); -# else - void *addr_mapping = ::MapViewOfFile (*file_mapping, - nt_flags, - 0, - off, - len); -# endif /* ! ACE_HAS_WINCE */ - - // Only close this down if we used the temporary. - if (file_mapping == &local_handle) - ::CloseHandle (*file_mapping); - - if (addr_mapping == 0) - ACE_FAIL_RETURN (MAP_FAILED); - else - return addr_mapping; -#elif defined (__Lynx__) - // The LynxOS 2.5.0 mmap doesn't allow operations on plain - // file descriptors. So, create a shm object and use that. - ACE_UNUSED_ARG (sa); - - char name [128]; - sprintf (name, "%d", file_handle); - - // Assumes that this was called by ACE_Mem_Map, so &file_mapping != - // 0. Otherwise, we don't support the incomplete LynxOS mmap - // implementation. We do support it by creating a hidden shared - // memory object, and using that for the mapping. - int shm_handle; - if (! file_mapping) - file_mapping = &shm_handle; - if ((*file_mapping = ::shm_open (name, - O_RDWR | O_CREAT | O_TRUNC, - ACE_DEFAULT_FILE_PERMS)) == -1) - return MAP_FAILED; - else - { - // The size of the shared memory object must be explicitly set on LynxOS. - const off_t filesize = ACE_OS::filesize (file_handle); - if (::ftruncate (*file_mapping, filesize) == -1) - return MAP_FAILED; - else - { -# if defined (ACE_OS_EXTRA_MMAP_FLAGS) - flags |= ACE_OS_EXTRA_MMAP_FLAGS; -# endif /* ACE_OS_EXTRA_MMAP_FLAGS */ - char *map = (char *) ::mmap ((ACE_MMAP_TYPE) addr, - len, - prot, - flags, - *file_mapping, - off); - if (map == MAP_FAILED) - return MAP_FAILED; - else - // Finally, copy the file contents to the shared memory object. - return ::read (file_handle, map, (int) filesize) == filesize - ? map - : MAP_FAILED; - } - } -#elif !defined (ACE_LACKS_MMAP) - ACE_UNUSED_ARG (sa); - -# if defined (ACE_OS_EXTRA_MMAP_FLAGS) - flags |= ACE_OS_EXTRA_MMAP_FLAGS; -# endif /* ACE_OS_EXTRA_MMAP_FLAGS */ - ACE_UNUSED_ARG (file_mapping); - ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr, - len, - prot, - flags, - file_handle, - off), - void *, MAP_FAILED); -#else - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (prot); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (file_handle); - ACE_UNUSED_ARG (off); - ACE_UNUSED_ARG (file_mapping); - ACE_UNUSED_ARG (sa); - ACE_NOTSUP_RETURN (MAP_FAILED); -#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ -} - -// NOTE: The previous four function definitions must appear before -// ACE_OS::sema_init (). - -ACE_INLINE int -ACE_OS::sema_init (ACE_sema_t *s, - u_int count, - int type, - const char *name, - void *arg, - int max, - LPSECURITY_ATTRIBUTES sa) -{ - ACE_OS_TRACE ("ACE_OS::sema_init"); -#if defined (ACE_HAS_POSIX_SEM) - ACE_UNUSED_ARG (arg); - ACE_UNUSED_ARG (max); - ACE_UNUSED_ARG (sa); - - s->name_ = 0; - -# if defined (ACE_LACKS_NAMED_POSIX_SEM) - s->new_sema_ = 0; - if (type == USYNC_PROCESS) - { - // Let's see if it already exists. - ACE_HANDLE fd = ACE_OS::shm_open (name, - O_RDWR | O_CREAT | O_EXCL, - ACE_DEFAULT_FILE_PERMS); - if (fd == ACE_INVALID_HANDLE) - { - if (errno == EEXIST) - fd = ACE_OS::shm_open (name, - O_RDWR | O_CREAT, - ACE_DEFAULT_FILE_PERMS); - else - return -1; - } - else - { - // We own this shared memory object! Let's set its - // size. - if (ACE_OS::ftruncate (fd, - sizeof (ACE_sema_t)) == -1) - return -1; - s->name_ = ACE_OS::strdup (name); - if (s->name_ == 0) - return -1; - } - if (fd == -1) - return -1; - - s->sema_ = (sem_t *) - ACE_OS::mmap (0, - sizeof (ACE_sema_t), - PROT_RDWR, - MAP_SHARED, - fd, - 0); - ACE_OS::close (fd); - if (s->sema_ == (sem_t *) MAP_FAILED) - return -1; - if (s->name_ - // @@ According UNIX Network Programming V2 by Stevens, - // sem_init() is currently not required to return zero on - // success, but it *does* return -1 upon failure. For - // this reason, check for failure by comparing to -1, - // instead of checking for success by comparing to zero. - // -Ossama - // Only initialize it if we're the one who created it. - && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1) - return -1; - return 0; - } -# else - if (name) - { -# if defined (sun) || defined (HPUX) - // Solaris and HP-UX require the name to start with a slash. Solaris - // further requires that there be no other slashes than the first. - const char *last_slash = ACE_OS::strrchr (name, '/'); - char name2[MAXPATHLEN]; - if (0 == last_slash) - { - ACE_OS::strcpy (name2, "/"); - ACE_OS::strcat (name2, name); - name = name2; - } -# if defined (sun) - else - name = last_slash; // Chop off chars preceding last slash -# endif /* sun */ -# endif /* sun || HPUX */ - - ACE_ALLOCATOR_RETURN (s->name_, - ACE_OS::strdup (name), - -1); - s->sema_ = ::sem_open (s->name_, - O_CREAT, - ACE_DEFAULT_FILE_PERMS, - count); - if (s->sema_ == (sem_t *) SEM_FAILED) - return -1; - else - return 0; - } -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ - else - { - ACE_NEW_RETURN (s->sema_, - sem_t, - -1); -# if defined (ACE_LACKS_NAMED_POSIX_SEM) - s->new_sema_ = 1; -# endif /* ACE_LACKS_NAMED_POSIX_SEM */ - ACE_OSCALL_RETURN (::sem_init (s->sema_, - type != USYNC_THREAD, - count), int, -1); - } -#elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (max); - ACE_UNUSED_ARG (sa); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), ace_result_), - int, -1); -# elif defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (max); - ACE_UNUSED_ARG (sa); - int result = -1; - - if (ACE_OS::mutex_init (&s->lock_, type, name, - (ACE_mutexattr_t *) arg) == 0 - && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0 - && ACE_OS::mutex_lock (&s->lock_) == 0) - { - s->count_ = count; - s->waiters_ = 0; - - if (ACE_OS::mutex_unlock (&s->lock_) == 0) - result = 0; - } - - if (result == -1) - { - ACE_OS::mutex_destroy (&s->lock_); - ACE_OS::cond_destroy (&s->count_nonzero_); - } - return result; -# elif defined (ACE_HAS_WTHREADS) -# if ! defined (ACE_USES_WINCE_SEMA_SIMULATION) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (arg); - // Create the semaphore with its value initialized to <count> and - // its maximum value initialized to <max>. - *s = - ::CreateSemaphoreA (ACE_OS::default_win32_security_attributes (sa), - count, - max, - name); - - if (*s == 0) - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ - else - return 0; -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - int result = -1; - - // Initialize internal object for semaphore simulation. - // Grab the lock as soon as possible when we initializing - // the semaphore count. Notice that we initialize the - // event object as "manually reset" so we can amortize the - // cost for singling/reseting the event. - // @@ I changed the mutex type to thread_mutex. Notice that this - // is basically a CriticalSection object and doesn't not has - // any security attribute whatsoever. However, since this - // semaphore implementation only works within a process, there - // shouldn't any security issue at all. - if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0 - && ACE_OS::event_init (&s->count_nonzero_, 1, - count > 0, type, name, arg, sa) == 0 - && ACE_OS::thread_mutex_lock (&s->lock_) == 0) - { - s->count_ = count; - - if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0) - result = 0; - } - - // Destroy the internal objects if we didn't initialize - // either of them successfully. Don't bother to check - // for errors. - if (result == -1) - { - ACE_OS::thread_mutex_destroy (&s->lock_); - ACE_OS::event_destroy (&s->count_nonzero_); - } - return result; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - u_long result; - ACE_OS::memcpy (s->name_, name, sizeof (s->name_)); - // default semaphore creation flags to priority based, global across nodes - u_long flags = 0; - flags |= (type & SM_LOCAL) ? SM_LOCAL : SM_GLOBAL; - flags |= (type & SM_FIFO) ? SM_FIFO : SM_PRIOR; - result = ::sm_create (s->name_, count, flags, &(s->sema_)); - return (result == 0) ? 0 : -1; -# elif defined (VXWORKS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_UNUSED_ARG (max); - ACE_UNUSED_ARG (sa); - s->name_ = 0; - s->sema_ = ::semCCreate (type, count); - return s->sema_ ? 0 : -1; -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (count); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_UNUSED_ARG (max); - ACE_UNUSED_ARG (sa); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_POSIX_SEM */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::sema_init (ACE_sema_t *s, - u_int count, - int type, - const wchar_t *name, - void *arg, - int max, - LPSECURITY_ATTRIBUTES sa) -{ -# if defined (ACE_HAS_WTHREADS) -# if ! defined (ACE_USES_WINCE_SEMA_SIMULATION) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (arg); - // Create the semaphore with its value initialized to <count> and - // its maximum value initialized to <max>. - *s = - ::CreateSemaphoreW (ACE_OS::default_win32_security_attributes (sa), - count, - max, - name); - - if (*s == 0) - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ - else - return 0; -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - int result = -1; - - // Initialize internal object for semaphore simulation. - // Grab the lock as soon as possible when we initializing - // the semaphore count. Notice that we initialize the - // event object as "manually reset" so we can amortize the - // cost for singling/reseting the event. - // @@ I changed the mutex type to thread_mutex. Notice that this - // is basically a CriticalSection object and doesn't not has - // any security attribute whatsoever. However, since this - // semaphore implementation only works within a process, there - // shouldn't any security issue at all. - if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0 - && ACE_OS::event_init (&s->count_nonzero_, 1, - count > 0, type, name, arg, sa) == 0 - && ACE_OS::thread_mutex_lock (&s->lock_) == 0) - { - s->count_ = count; - - if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0) - result = 0; - } - - // Destroy the internal objects if we didn't initialize - // either of them successfully. Don't bother to check - // for errors. - if (result == -1) - { - ACE_OS::thread_mutex_destroy (&s->lock_); - ACE_OS::event_destroy (&s->count_nonzero_); - } - return result; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# else /* ACE_HAS_WTHREADS */ - // Just call the normal char version. - return ACE_OS::sema_init (s, count, type, ACE_Wide_To_Ascii (name).char_rep (), arg, max, sa); -# endif /* ACE_HAS_WTHREADS */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::sema_post (ACE_sema_t *s) -{ - ACE_OS_TRACE ("ACE_OS::sema_post"); -# if defined (ACE_HAS_POSIX_SEM) - ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1); -# elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), ace_result_), int, -1); -# elif defined (ACE_HAS_PTHREADS) - int result = -1; - - if (ACE_OS::mutex_lock (&s->lock_) == 0) - { - // Always allow a waiter to continue if there is one. - if (s->waiters_ > 0) - result = ACE_OS::cond_signal (&s->count_nonzero_); - else - result = 0; - - s->count_++; - ACE_OS::mutex_unlock (&s->lock_); - } - return result; -# elif defined (ACE_HAS_WTHREADS) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0), - ace_result_), - int, -1); -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - int result = -1; - - // Since we are simulating semaphores, we need to update semaphore - // count manually. Grab the lock to prevent race condition first. - if (ACE_OS::thread_mutex_lock (&s->lock_) == 0) - { - // Check the original state of event object. Single the event - // object in transition from semaphore not available to - // semaphore available. - if (s->count_++ <= 0) - result = ACE_OS::event_signal (&s->count_nonzero_); - else - result = 0; - - ACE_OS::thread_mutex_unlock (&s->lock_); - } - return result; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - int result; - ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_v (s->sema_), result), int, -1, result); - return result; -# elif defined (VXWORKS) - ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1); -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_POSIX_SEM */ -} - -ACE_INLINE int -ACE_OS::sema_post (ACE_sema_t *s, u_int release_count) -{ -#if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION) - // Win32 supports this natively. - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0), - ace_result_), int, -1); -#else - // On POSIX platforms we need to emulate this ourselves. - // @@ We can optimize on this implementation. However, - // the semaphore promitive on Win32 doesn't allow one - // to increase a semaphore to more than the count it was - // first initialized. Posix and solaris don't seem to have - // this restriction. Should we impose the restriction in - // our semaphore simulation? - for (size_t i = 0; i < release_count; i++) - if (ACE_OS::sema_post (s) == -1) - return -1; - - return 0; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::sema_trywait (ACE_sema_t *s) -{ - ACE_OS_TRACE ("ACE_OS::sema_trywait"); -# if defined (ACE_HAS_POSIX_SEM) - // POSIX semaphores set errno to EAGAIN if trywait fails - ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1); -# elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - // STHREADS semaphores set errno to EBUSY if trywait fails. - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s), - ace_result_), - int, -1); -# elif defined (ACE_HAS_PTHREADS) - - int result = -1; - - if (ACE_OS::mutex_lock (&s->lock_) == 0) - { - if (s->count_ > 0) - { - --s->count_; - result = 0; - } - else - errno = EBUSY; - - ACE_OS::mutex_unlock (&s->lock_); - } - return result; -# elif defined (ACE_HAS_WTHREADS) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - int result = ::WaitForSingleObject (*s, 0); - - if (result == WAIT_OBJECT_0) - return 0; - else - { - if (result == WAIT_TIMEOUT) - errno = EBUSY; - else - ACE_OS::set_errno_to_last_error (); - // This is a hack, we need to find an appropriate mapping... - return -1; - } -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - // Check the status of semaphore first. Return immediately - // if the semaphore is not available and avoid grabing the - // lock. - int result = ::WaitForSingleObject (s->count_nonzero_, 0); - - if (result == WAIT_OBJECT_0) // Proceed when it is available. - { - ACE_OS::thread_mutex_lock (&s->lock_); - - // Need to double check if the semaphore is still available. - // The double checking scheme will slightly affect the - // efficiency if most of the time semaphores are not blocked. - result = ::WaitForSingleObject (s->count_nonzero_, 0); - if (result == WAIT_OBJECT_0) - { - // Adjust the semaphore count. Only update the event - // object status when the state changed. - s->count_--; - if (s->count_ <= 0) - ACE_OS::event_reset (&s->count_nonzero_); - result = 0; - } - - ACE_OS::thread_mutex_unlock (&s->lock_); - } - - // Translate error message to errno used by ACE. - if (result == WAIT_TIMEOUT) - errno = EBUSY; - else - ACE_OS::set_errno_to_last_error (); - // This is taken from the hack above. ;) - return -1; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - switch (::sm_p (s->sema_, SM_NOWAIT, 0)) - { - case 0: - return 0; - case ERR_NOSEM: - errno = EBUSY; - // intentional fall through - default: - return -1; - } -# elif defined (VXWORKS) - if (::semTake (s->sema_, NO_WAIT) == ERROR) - if (errno == S_objLib_OBJ_UNAVAILABLE) - { - // couldn't get the semaphore - errno = EBUSY; - return -1; - } - else - // error - return -1; - else - // got the semaphore - return 0; -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_POSIX_SEM */ -} - -ACE_INLINE int -ACE_OS::sema_wait (ACE_sema_t *s) -{ - ACE_OS_TRACE ("ACE_OS::sema_wait"); -# if defined (ACE_HAS_POSIX_SEM) - ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1); -# elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), ace_result_), int, -1); -# elif defined (ACE_HAS_PTHREADS) - int result = 0; - - ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); - - if (ACE_OS::mutex_lock (&s->lock_) != 0) - result = -1; - else - { - // Keep track of the number of waiters so that we can signal - // them properly in <ACE_OS::sema_post>. - s->waiters_++; - - // Wait until the semaphore count is > 0. - while (s->count_ == 0) - if (ACE_OS::cond_wait (&s->count_nonzero_, - &s->lock_) == -1) - { - result = -2; // -2 means that we need to release the mutex. - break; - } - - --s->waiters_; - } - - if (result == 0) - --s->count_; - - if (result != -1) - ACE_OS::mutex_unlock (&s->lock_); - ACE_PTHREAD_CLEANUP_POP (0); - return result < 0 ? -1 : result; - -# elif defined (ACE_HAS_WTHREADS) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - switch (::WaitForSingleObject (*s, INFINITE)) - { - case WAIT_OBJECT_0: - return 0; - default: - // This is a hack, we need to find an appropriate mapping... - ACE_OS::set_errno_to_last_error (); - return -1; - } - /* NOTREACHED */ -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - // Timed wait. - int result = -1; - for (;;) - // Check if the semaphore is avialable or not and wait forever. - // Don't bother to grab the lock if it is not available (to avoid - // deadlock.) - switch (::WaitForSingleObject (s->count_nonzero_, INFINITE)) - { - case WAIT_OBJECT_0: - ACE_OS::thread_mutex_lock (&s->lock_); - - // Need to double check if the semaphore is still available. - // This time, we shouldn't wait at all. - if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0) - { - // Decrease the internal counter. Only update the event - // object's status when the state changed. - s->count_--; - if (s->count_ <= 0) - ACE_OS::event_reset (&s->count_nonzero_); - result = 0; - } - - ACE_OS::thread_mutex_unlock (&s->lock_); - // if we didn't get a hold on the semaphore, the result won't - // be 0 and thus, we'll start from the beginning again. - if (result == 0) - return 0; - break; - - default: - // Since we wait indefinitely, anything other than - // WAIT_OBJECT_O indicates an error. - ACE_OS::set_errno_to_last_error (); - // This is taken from the hack above. ;) - return -1; - } - /* NOTREACHED */ -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - int result; - ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_WAIT, 0), result), - int, -1, result); - return result; -# elif defined (VXWORKS) - ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1); -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_POSIX_SEM */ -} - -ACE_INLINE int -ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) -{ - ACE_OS_TRACE ("ACE_OS::sema_wait"); -# if defined (ACE_HAS_POSIX_SEM) - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (tv); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (tv); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_PTHREADS) - int result = 0; - ACE_Errno_Guard error (errno); - - ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); - - if (ACE_OS::mutex_lock (&s->lock_) != 0) - result = -1; - else - { - // Keep track of the number of waiters so that we can signal - // them properly in <ACE_OS::sema_post>. - s->waiters_++; - - // Wait until the semaphore count is > 0 or until we time out. - while (s->count_ == 0) - if (ACE_OS::cond_timedwait (&s->count_nonzero_, - &s->lock_, - &tv) == -1) - { - error = errno; - result = -2; // -2 means that we need to release the mutex. - break; - } - - --s->waiters_; - } - - if (result == 0) - { -# if defined (ACE_LACKS_COND_TIMEDWAIT_RESET) - tv = ACE_OS::gettimeofday (); -# endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */ - --s->count_; - } - - if (result != -1) - ACE_OS::mutex_unlock (&s->lock_); - ACE_PTHREAD_CLEANUP_POP (0); - return result < 0 ? -1 : result; -# elif defined (ACE_HAS_WTHREADS) -# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) - int msec_timeout; - - if (tv.sec () == 0 && tv.usec () == 0) - msec_timeout = 0; // Do a "poll." - else - { - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what - // <WaitForSingleObjects> expects). - ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); - - // Watchout for situations where a context switch has caused the - // current time to be > the timeout. - if (relative_time < ACE_Time_Value::zero) - msec_timeout = 0; - else - msec_timeout = relative_time.msec (); - } - - switch (::WaitForSingleObject (*s, msec_timeout)) - { - case WAIT_OBJECT_0: - tv = ACE_OS::gettimeofday (); // Update time to when acquired - return 0; - case WAIT_TIMEOUT: - errno = ETIME; - return -1; - default: - // This is a hack, we need to find an appropriate mapping... - ACE_OS::set_errno_to_last_error (); - return -1; - } - /* NOTREACHED */ -# else /* ACE_USES_WINCE_SEMA_SIMULATION */ - // Note that in this mode, the acquire is done in two steps, and - // we may get signaled but cannot grab the semaphore before - // timeout. In that case, we'll need to restart the process with - // updated timeout value. - - // <tv> is an absolute time - ACE_Time_Value relative_time = tv - ACE_OS::gettimeofday (); - int result = -1; - - // While we are not timeout yet. - while (relative_time > ACE_Time_Value::zero) - { - // Wait for our turn to get the object. - switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ())) - { - case WAIT_OBJECT_0: - ACE_OS::thread_mutex_lock (&s->lock_); - - // Need to double check if the semaphore is still available. - // We can only do a "try lock" styled wait here to avoid - // blocking threads that want to signal the semaphore. - if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0) - { - // As before, only reset the object when the semaphore - // is no longer available. - s->count_--; - if (s->count_ <= 0) - ACE_OS::event_reset (&s->count_nonzero_); - result = 0; - } - - ACE_OS::thread_mutex_unlock (&s->lock_); - - // Only return when we successfully get the semaphore. - if (result == 0) - { - tv = ACE_OS::gettimeofday (); // Update to time acquired - return 0; - } - break; - - // We have timed out. - case WAIT_TIMEOUT: - errno = ETIME; - return -1; - - // What? - default: - ACE_OS::set_errno_to_last_error (); - // This is taken from the hack above. ;) - return -1; - }; - - // Haven't been able to get the semaphore yet, update the - // timeout value to reflect the remaining time we want to wait. - relative_time = tv - ACE_OS::gettimeofday (); - } - - // We have timed out. - errno = ETIME; - return -1; -# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ -# elif defined (ACE_PSOS) - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what - // the system call expects). - ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); - - u_long ticks = relative_time.sec() * KC_TICKS2SEC + - relative_time.usec () * KC_TICKS2SEC / - ACE_ONE_SECOND_IN_USECS; - if(ticks == 0) - ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_NOWAIT, 0), int, -1); //no timeout - else - ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_WAIT, ticks), int, -1); -# elif defined (VXWORKS) - // Note that we must convert between absolute time (which is - // passed as a parameter) and relative time (which is what - // the system call expects). - ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); - - int ticks_per_sec = ::sysClkRateGet (); - - int ticks = relative_time.sec() * ticks_per_sec + - relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; - if (::semTake (s->sema_, ticks) == ERROR) - { - if (errno == S_objLib_OBJ_TIMEOUT) - // Convert the VxWorks errno to one that's common for to ACE - // platforms. - errno = ETIME; - else if (errno == S_objLib_OBJ_UNAVAILABLE) - errno = EBUSY; - return -1; - } - else - { - tv = ACE_OS::gettimeofday (); // Update to time acquired - return 0; - } -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (tv); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_POSIX_SEM */ -} - -ACE_INLINE int -ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value *tv) -{ - return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv); -} - -ACE_INLINE int -ACE_OS::rw_tryrdlock (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rw_tryrdlock"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw), - ace_result_), - int, -1); -# else /* Solaris */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -# else /* NT, POSIX, and VxWorks don't support this natively. */ - int result = -1; - - if (ACE_OS::mutex_lock (&rw->lock_) != -1) - { - ACE_Errno_Guard error (errno); - - if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0) - { - error = EBUSY; - result = -1; - } - else - { - rw->ref_count_++; - result = 0; - } - - ACE_OS::mutex_unlock (&rw->lock_); - } - return result; -# endif /* ! ACE_LACKS_RWLOCK_T */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::rw_trywrlock (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rw_trywrlock"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw), - ace_result_), - int, -1); -# else /* Solaris */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -# else /* NT, POSIX, and VxWorks don't support this natively. */ - int result = -1; - - if (ACE_OS::mutex_lock (&rw->lock_) != -1) - { - ACE_Errno_Guard error (errno); - - if (rw->ref_count_ != 0) - { - error = EBUSY; - result = -1; - } - else - { - rw->ref_count_ = -1; - result = 0; - } - - ACE_OS::mutex_unlock (&rw->lock_); - } - return result; -# endif /* ! ACE_LACKS_RWLOCK_T */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::rw_rdlock (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rw_rdlock"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw), - ace_result_), - int, -1); -# else /* Solaris */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -# else /* NT, POSIX, and VxWorks don't support this natively. */ -# if defined (ACE_HAS_PTHREADS) - ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); -# endif /* ACE_HAS_PTHREADS */ - int result = 0; - if (ACE_OS::mutex_lock (&rw->lock_) == -1) - result = -1; // -1 means didn't get the mutex. - else - { - // Give preference to writers who are waiting. - while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0) - { - rw->num_waiting_readers_++; - if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1) - { - result = -2; // -2 means that we need to release the mutex. - break; - } - rw->num_waiting_readers_--; - } - } - if (result == 0) - rw->ref_count_++; - if (result != -1) - ACE_OS::mutex_unlock (&rw->lock_); -# if defined (ACE_HAS_PTHREADS) - ACE_PTHREAD_CLEANUP_POP (0); -# endif /* defined (ACE_HAS_PTHREADS) */ - return 0; -# endif /* ! ACE_LACKS_RWLOCK_T */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::rw_wrlock (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rw_wrlock"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw), - ace_result_), - int, -1); -# else /* Solaris */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -# else /* NT, POSIX, and VxWorks don't support this natively. */ -# if defined (ACE_HAS_PTHREADS) - ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); -# endif /* defined (ACE_HAS_PTHREADS) */ - int result = 0; - - if (ACE_OS::mutex_lock (&rw->lock_) == -1) - result = -1; // -1 means didn't get the mutex. - else - { - while (rw->ref_count_ != 0) - { - rw->num_waiting_writers_++; - - if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1) - { - result = -2; // -2 means we need to release the mutex. - break; - } - - rw->num_waiting_writers_--; - } - } - if (result == 0) - rw->ref_count_ = -1; - if (result != -1) - ACE_OS::mutex_unlock (&rw->lock_); -# if defined (ACE_HAS_PTHREADS) - ACE_PTHREAD_CLEANUP_POP (0); -# endif /* defined (ACE_HAS_PTHREADS) */ - return 0; -# endif /* ! ACE_LACKS_RWLOCK_T */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::rw_unlock (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rw_unlock"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw), - ace_result_), - int, -1); -# else /* Solaris */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -# else /* NT, POSIX, and VxWorks don't support this natively. */ - if (ACE_OS::mutex_lock (&rw->lock_) == -1) - return -1; - - if (rw->ref_count_ > 0) // Releasing a reader. - rw->ref_count_--; - else if (rw->ref_count_ == -1) // Releasing a writer. - rw->ref_count_ = 0; - else - return -1; // @@ ACE_ASSERT (!"count should not be 0!\n"); - - - int result = 0; - ACE_Errno_Guard error (errno); - - if (rw->important_writer_ && rw->ref_count_ == 1) - // only the reader requesting to upgrade its lock is left over. - { - result = ACE_OS::cond_signal (&rw->waiting_important_writer_); - error = errno; - } - else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0) - // give preference to writers over readers... - { - result = ACE_OS::cond_signal (&rw->waiting_writers_); - error = errno; - } - else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0) - { - result = ACE_OS::cond_broadcast (&rw->waiting_readers_); - error = errno; - } - - ACE_OS::mutex_unlock (&rw->lock_); - return result; -# endif /* ! ace_lacks_rwlock_t */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ace_has_threads */ -} - -// Note that the caller of this method *must* already possess this -// lock as a read lock. -// return {-1 and no errno set means: error, -// -1 and errno==EBUSY set means: could not upgrade, -// 0 means: upgraded successfully} - -ACE_INLINE int -ACE_OS::rw_trywrlock_upgrade (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) - // Some native rwlocks, such as those on Solaris and HP-UX 11, don't - // support the upgrade feature . . . - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -# else /* NT, POSIX, and VxWorks don't support this natively. */ - // The ACE rwlock emulation does support upgrade . . . - int result = 0; - -# if defined (ACE_HAS_PTHREADS) - ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); -# endif /* defined (ACE_HAS_PTHREADS) */ - - if (ACE_OS::mutex_lock (&rw->lock_) == -1) - return -1; - // -1 means didn't get the mutex, error - else if (rw->important_writer_) - // an other reader upgrades already - { - result = -1; - errno = EBUSY; - } - else - { - while (rw->ref_count_ > 1) // wait until only I am left - { - rw->num_waiting_writers_++; // prohibit any more readers - rw->important_writer_ = 1; - - if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1) - { - result = -1; - // we know that we have the lock again, we have this guarantee, - // but something went wrong - } - rw->important_writer_ = 0; - rw->num_waiting_writers_--; - } - if (result == 0) - { - // nothing bad happend - rw->ref_count_ = -1; - // now I am a writer - // everything is O.K. - } - } - - ACE_OS::mutex_unlock (&rw->lock_); - -# if defined (ACE_HAS_PTHREADS) - ACE_PTHREAD_CLEANUP_POP (0); -# endif /* defined (ACE_HAS_PTHREADS) */ - - return result; - -# endif /* ! ACE_LACKS_RWLOCK_T */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -#if defined (ACE_HAS_THREADS) && (!defined (ACE_LACKS_RWLOCK_T) || \ - defined (ACE_HAS_PTHREADS_UNIX98_EXT)) -ACE_INLINE int -ACE_OS::rwlock_init (ACE_rwlock_t *rw, - int type, - const ACE_TCHAR *name, - void *arg) -{ - // ACE_OS_TRACE ("ACE_OS::rwlock_init"); -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - - int status; - pthread_rwlockattr_t attr; - pthread_rwlockattr_init (&attr); - pthread_rwlockattr_setpshared (&attr, (type == USYNC_THREAD ? - PTHREAD_PROCESS_PRIVATE : - PTHREAD_PROCESS_SHARED)); - status = ACE_ADAPT_RETVAL (pthread_rwlock_init (rw, &attr), status); - pthread_rwlockattr_destroy (&attr); - - return status; - -# else - type = type; - name = name; - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -} -#endif /* ACE_HAS THREADS && !defined (ACE_LACKS_RWLOCK_T) */ - -ACE_INLINE int -ACE_OS::rwlock_destroy (ACE_rwlock_t *rw) -{ - ACE_OS_TRACE ("ACE_OS::rwlock_destroy"); -#if defined (ACE_HAS_THREADS) -# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) -# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw), - ace_result_), - int, -1); -# else /* Solaris */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), ace_result_), int, -1); -# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ -# else /* NT, POSIX, and VxWorks don't support this natively. */ - ACE_OS::mutex_destroy (&rw->lock_); - ACE_OS::cond_destroy (&rw->waiting_readers_); - ACE_OS::cond_destroy (&rw->waiting_important_writer_); - return ACE_OS::cond_destroy (&rw->waiting_writers_); -# endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */ -#else - ACE_UNUSED_ARG (rw); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::event_init (ACE_event_t *event, - int manual_reset, - int initial_state, - int type, - const char *name, - void *arg, - LPSECURITY_ATTRIBUTES sa) -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (arg); -# if defined (ACE_HAS_WINCE) - // @@todo (brunsch) This idea should be moved into ACE_OS_Win32. - *event = ::CreateEventW (ACE_OS::default_win32_security_attributes(sa), - manual_reset, - initial_state, - ACE_Ascii_To_Wide (name).wchar_rep ()); -# else /* ACE_HAS_WINCE */ - *event = ::CreateEventA (ACE_OS::default_win32_security_attributes(sa), - manual_reset, - initial_state, - name); -# endif /* ACE_HAS_WINCE */ - if (*event == 0) - ACE_FAIL_RETURN (-1); - else - return 0; -#elif defined (ACE_HAS_THREADS) - ACE_UNUSED_ARG (sa); - event->manual_reset_ = manual_reset; - event->is_signaled_ = initial_state; - event->waiting_threads_ = 0; - - int result = ACE_OS::cond_init (&event->condition_, - ACE_static_cast (short, type), - name, - arg); - if (result == 0) - result = ACE_OS::mutex_init (&event->lock_, - type, - name, - (ACE_mutexattr_t *) arg); - return result; -#else - ACE_UNUSED_ARG (event); - ACE_UNUSED_ARG (manual_reset); - ACE_UNUSED_ARG (initial_state); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (arg); - ACE_UNUSED_ARG (sa); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::event_init (ACE_event_t *event, - int manual_reset, - int initial_state, - int type, - const wchar_t *name, - void *arg, - LPSECURITY_ATTRIBUTES sa) -{ -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (arg); - *event = ::CreateEventW (ACE_OS::default_win32_security_attributes(sa), - manual_reset, - initial_state, - name); - if (*event == 0) - ACE_FAIL_RETURN (-1); - - return 0; -#else /* ACE_WIN32 */ - return ACE_OS::event_init (event, - manual_reset, - initial_state, - type, - ACE_Wide_To_Ascii (name).char_rep (), - arg, - sa); -#endif /* ACE_WIN32 */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::event_destroy (ACE_event_t *event) -{ -#if defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1); -#elif defined (ACE_HAS_THREADS) - int r1 = ACE_OS::mutex_destroy (&event->lock_); - int r2 = ACE_OS::cond_destroy (&event->condition_); - return r1 != 0 || r2 != 0 ? -1 : 0; -#else - ACE_UNUSED_ARG (event); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::event_wait (ACE_event_t *event) -{ -#if defined (ACE_WIN32) - switch (::WaitForSingleObject (*event, INFINITE)) - { - case WAIT_OBJECT_0: - return 0; - default: - ACE_OS::set_errno_to_last_error (); - return -1; - } -#elif defined (ACE_HAS_THREADS) - int result = 0; - int error = 0; - - // grab the lock first - if (ACE_OS::mutex_lock (&event->lock_) == 0) - { - if (event->is_signaled_ == 1) - // Event is currently signaled. - { - if (event->manual_reset_ == 0) - // AUTO: reset state - event->is_signaled_ = 0; - } - else - // event is currently not signaled - { - event->waiting_threads_++; - - if (ACE_OS::cond_wait (&event->condition_, - &event->lock_) != 0) - { - result = -1; - error = errno; - // Something went wrong... - } - - event->waiting_threads_--; - } - - // Now we can let go of the lock. - ACE_OS::mutex_unlock (&event->lock_); - - if (result == -1) - // Reset errno in case mutex_unlock() also fails... - errno = error; - } - else - result = -1; - return result; -#else - ACE_UNUSED_ARG (event); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::event_timedwait (ACE_event_t *event, - ACE_Time_Value *timeout, - int use_absolute_time) -{ -#if defined (ACE_WIN32) - DWORD result; - - if (timeout == 0) - // Wait forever - result = ::WaitForSingleObject (*event, INFINITE); - else if (timeout->sec () == 0 && timeout->usec () == 0) - // Do a "poll". - result = ::WaitForSingleObject (*event, 0); - else - { - // Wait for upto <relative_time> number of milliseconds. Note - // that we must convert between absolute time (which is passed - // as a parameter) and relative time (which is what - // WaitForSingleObjects() expects). - // <timeout> parameter is given in absolute or relative value - // depending on parameter <use_absolute_time>. - int msec_timeout; - if (use_absolute_time) - { - // Time is given in absolute time, we should use - // gettimeofday() to calculate relative time - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); - - // Watchout for situations where a context switch has caused - // the current time to be > the timeout. Thanks to Norbert - // Rapp <NRapp@nexus-informatics.de> for pointing this. - if (relative_time < ACE_Time_Value::zero) - msec_timeout = 0; - else - msec_timeout = relative_time.msec (); - } - else - // time is given in relative time, just convert it into - // milliseconds and use it - msec_timeout = timeout->msec (); - result = ::WaitForSingleObject (*event, msec_timeout); - } - - switch (result) - { - case WAIT_OBJECT_0: - return 0; - case WAIT_TIMEOUT: - errno = ETIME; - return -1; - default: - // This is a hack, we need to find an appropriate mapping... - ACE_OS::set_errno_to_last_error (); - return -1; - } -#elif defined (ACE_HAS_THREADS) - int result = 0; - int error = 0; - - // grab the lock first - if (ACE_OS::mutex_lock (&event->lock_) == 0) - { - if (event->is_signaled_ == 1) - // event is currently signaled - { - if (event->manual_reset_ == 0) - // AUTO: reset state - event->is_signaled_ = 0; - } - else - // event is currently not signaled - { - event->waiting_threads_++; - - ACE_Time_Value absolute_timeout = *timeout; - - // cond_timewait() expects absolute time, check - // <use_absolute_time> flag. - if (use_absolute_time == 0) - absolute_timeout += ACE_OS::gettimeofday (); - - if (ACE_OS::cond_timedwait (&event->condition_, - &event->lock_, - &absolute_timeout) != 0) - { - result = -1; - error = errno; - } - - event->waiting_threads_--; - } - - // Now we can let go of the lock. - ACE_OS::mutex_unlock (&event->lock_); - - if (result == -1) - // Reset errno in case mutex_unlock() also fails... - errno = error; - } - else - result = -1; - return result; -#else - ACE_UNUSED_ARG (event); - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (use_absolute_time); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::event_signal (ACE_event_t *event) -{ -#if defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1); -#elif defined (ACE_HAS_THREADS) - int result = 0; - int error = 0; - - // grab the lock first - if (ACE_OS::mutex_lock (&event->lock_) == 0) - { - // Manual-reset event. - if (event->manual_reset_ == 1) - { - // signal event - event->is_signaled_ = 1; - // wakeup all - if (ACE_OS::cond_broadcast (&event->condition_) != 0) - { - result = -1; - error = errno; - } - } - // Auto-reset event - else - { - if (event->waiting_threads_ == 0) - // No waiters: signal event. - event->is_signaled_ = 1; - - // Waiters: wakeup one waiter. - else if (ACE_OS::cond_signal (&event->condition_) != 0) - { - result = -1; - error = errno; - } - } - - // Now we can let go of the lock. - ACE_OS::mutex_unlock (&event->lock_); - - if (result == -1) - // Reset errno in case mutex_unlock() also fails... - errno = error; - } - else - result = -1; - return result; -#else - ACE_UNUSED_ARG (event); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::event_pulse (ACE_event_t *event) -{ -#if defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1); -#elif defined (ACE_HAS_THREADS) - int result = 0; - int error = 0; - - // grab the lock first - if (ACE_OS::mutex_lock (&event->lock_) == 0) - { - // Manual-reset event. - if (event->manual_reset_ == 1) - { - // Wakeup all waiters. - if (ACE_OS::cond_broadcast (&event->condition_) != 0) - { - result = -1; - error = errno; - } - } - // Auto-reset event: wakeup one waiter. - else if (ACE_OS::cond_signal (&event->condition_) != 0) - { - result = -1; - error = errno; - } - - // Reset event. - event->is_signaled_ = 0; - - // Now we can let go of the lock. - ACE_OS::mutex_unlock (&event->lock_); - - if (result == -1) - // Reset errno in case mutex_unlock() also fails... - errno = error; - } - else - result = -1; - return result; -#else - ACE_UNUSED_ARG (event); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::event_reset (ACE_event_t *event) -{ -#if defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1); -#elif defined (ACE_HAS_THREADS) - int result = 0; - - // Grab the lock first. - if (ACE_OS::mutex_lock (&event->lock_) == 0) - { - // Reset event. - event->is_signaled_ = 0; - - // Now we can let go of the lock. - ACE_OS::mutex_unlock (&event->lock_); - } - else - result = -1; - return result; -#else - ACE_UNUSED_ARG (event); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -#if defined (ACE_WIN32) -# define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) \ - do { TYPE ace_result_ = (TYPE) OP; \ - if (ace_result_ == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; return (TYPE) FAILVALUE; } else return ace_result_; \ - } while (0) -#else -# define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) ACE_OSCALL_RETURN(OP,TYPE,FAILVALUE) -#endif /* ACE_WIN32 */ - -#if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) -# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) -# define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \ - do \ - { \ - if (ACE_OS::netdb_acquire ()) \ - return FAILVALUE; \ - else \ - { \ - TYPE ace_result_; \ - ACE_OSCALL (OP, TYPE, FAILVALUE, ace_result_); \ - if (ace_result_ != FAILVALUE) \ - ::memcpy (TARGET, \ - ace_result_, \ - SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \ - ACE_OS::netdb_release (); \ - return ace_result_; \ - } \ - } while(0) -# else /* ! (ACE_MT_SAFE && ACE_MT_SAFE != 0) */ -# define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \ - do \ - { \ - TYPE ace_result_; \ - ACE_OSCALL(OP,TYPE,FAILVALUE,ace_result_); \ - if (ace_result_ != FAILVALUE) \ - ::memcpy (TARGET, \ - ace_result_, \ - SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \ - return ace_result_; \ - } while(0) -# endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ -#endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ - -ACE_INLINE ACE_HANDLE -ACE_OS::accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen) -{ - ACE_OS_TRACE ("ACE_OS::accept"); -#if defined (ACE_PSOS) -# if !defined (ACE_PSOS_DIAB_PPC) - ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, - (struct sockaddr_in *) addr, - (ACE_SOCKET_LEN *) addrlen), - ACE_HANDLE, - ACE_INVALID_HANDLE); -# else -ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, - (struct sockaddr *) addr, - (ACE_SOCKET_LEN *) addrlen), - ACE_HANDLE, - ACE_INVALID_HANDLE); -# endif /* defined ACE_PSOS_DIAB_PPC */ -#else - // On a non-blocking socket with no connections to accept, this - // system call will return EWOULDBLOCK or EAGAIN, depending on the - // platform. UNIX 98 allows either errno, and they may be the same - // numeric value. So to make life easier for upper ACE layers as - // well as application programmers, always change EAGAIN to - // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's - // handled explicitly here. If the ACE_OSCALL macro ever changes, - // this function needs to be reviewed. On Win32, the regular macros - // can be used, as this is not an issue. - -# if defined (ACE_WIN32) - ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen), - ACE_HANDLE, - ACE_INVALID_HANDLE); -# else -# if defined (ACE_HAS_BROKEN_ACCEPT_ADDR) - // Apparently some platforms like VxWorks can't correctly deal with - // a NULL addr. - - sockaddr_in fake_addr; - int fake_addrlen; - - if (addrlen == 0) - addrlen = &fake_addrlen; - - if (addr == 0) - { - addr = (sockaddr *) &fake_addr; - *addrlen = sizeof fake_addr; - } -# endif /* VXWORKS */ - ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen) ; - if (ace_result == ACE_INVALID_HANDLE && errno == EAGAIN) - errno = EWOULDBLOCK; - return ace_result; - -# endif /* defined (ACE_WIN32) */ -#endif /* defined (ACE_PSOS) */ -} - -ACE_INLINE int -ACE_OS::enum_protocols (int *protocols, - ACE_Protocol_Info *protocol_buffer, - u_long *buffer_length) -{ -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - - ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols, - protocol_buffer, - buffer_length), - int, - SOCKET_ERROR); - -#else - ACE_UNUSED_ARG (protocols); - ACE_UNUSED_ARG (protocol_buffer); - ACE_UNUSED_ARG (buffer_length); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_WINSOCK2 */ -} - - -ACE_INLINE int -ACE_OS::bind (ACE_HANDLE handle, struct sockaddr *addr, int addrlen) -{ - ACE_OS_TRACE ("ACE_OS::bind"); -#if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) - ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle, - (struct sockaddr_in *) addr, - (ACE_SOCKET_LEN) addrlen), - int, -1); -#else /* !defined (ACE_PSOS) || defined (ACE_PSOS_DIAB_PPC) */ - ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN) addrlen), int, -1); -#endif /* defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) */ -} - -ACE_INLINE int -ACE_OS::connect (ACE_HANDLE handle, - struct sockaddr *addr, - int addrlen) -{ - ACE_OS_TRACE ("ACE_OS::connect"); -#if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) - ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle, - (struct sockaddr_in *) addr, - (ACE_SOCKET_LEN) addrlen), - int, -1); -#else /* !defined (ACE_PSOS) || defined (ACE_PSOS_DIAB_PPC) */ - ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN) addrlen), int, -1); -#endif /* defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) */ -} - -#if !defined (VXWORKS) -ACE_INLINE struct hostent * -ACE_OS::gethostbyname (const char *name) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyname"); -# if defined (ACE_PSOS) - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (0); -# elif defined (ACE_HAS_NONCONST_GETBY) - ACE_SOCKCALL_RETURN (::gethostbyname (ACE_const_cast (char *, name)), - struct hostent *, - 0); -# else - ACE_SOCKCALL_RETURN (::gethostbyname (name), - struct hostent *, - 0); -# endif /* ACE_HAS_NONCONST_GETBY */ -} - - -ACE_INLINE struct hostent * -ACE_OS::gethostbyaddr (const char *addr, int length, int type) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyaddr"); -# if defined (ACE_PSOS) - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (length); - ACE_UNUSED_ARG (type); - ACE_NOTSUP_RETURN (0); -# elif defined (ACE_HAS_NONCONST_GETBY) - ACE_SOCKCALL_RETURN (::gethostbyaddr (ACE_const_cast (char *, addr), - (ACE_SOCKET_LEN) length, - type), - struct hostent *, - 0); -# else - ACE_SOCKCALL_RETURN (::gethostbyaddr (addr, - (ACE_SOCKET_LEN) length, - type), - struct hostent *, - 0); -# endif /* ACE_HAS_NONCONST_GETBY */ -} - - -ACE_INLINE struct hostent * -ACE_OS::getipnodebyname (const char *name, int family, int flags) -{ - ACE_OS_TRACE ("ACE_OS::getipnodebyname"); -# if defined (ACE_PSOS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (family); - ACE_UNUSED_ARG (flags); - ACE_NOTSUP_RETURN (0); -# elif defined (ACE_HAS_IPV6) -# if defined (__GLIBC__) - ACE_UNUSED_ARG (flags); -# if defined (ACE_HAS_NONCONST_GETBY) - ACE_SOCKCALL_RETURN (::gethostbyname2 (ACE_const_cast (char *, name), - family), - struct hostent *, 0); -# else - ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family), - struct hostent *, 0); -# endif /* ACE_HAS_NONCONST_GETBY */ -# else - struct hostent *hptr; - int errnum; - if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0) - { - errno = errnum; - } - return hptr; -# endif /* __GLIBC__ */ -# else - // IPv4-only implementation - ACE_UNUSED_ARG (flags); - if (family == AF_INET) - return ACE_OS::gethostbyname (name); - - ACE_NOTSUP_RETURN (0); -# endif /* ACE_PSOS */ -} - - -ACE_INLINE struct hostent * -ACE_OS::getipnodebyaddr (const void *src, size_t len, int family) -{ -#if defined (ACE_HAS_IPV6) -# if defined (__GLIBC__) - ACE_UNUSED_ARG (src); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (family); - ACE_NOTSUP_RETURN (0); -# else - struct hostent *hptr; - int errnum; - if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0) - { - errno = errnum; - } - return hptr; -# endif /* whatever_doesnt_have_getipnodebyname */ -#else - // IPv4-only implementation - if (family == AF_INET) - return ACE_OS::gethostbyaddr (ACE_static_cast (const char *, src), - ACE_static_cast (int, len), - family); - - ACE_NOTSUP_RETURN (0); -# endif /* ACE_PSOS */ -} -#endif /* ! VXWORKS */ - -// It would be really cool to add another version of select that would -// function like the one we're defending against below! -ACE_INLINE int -ACE_OS::select (int width, - fd_set *rfds, fd_set *wfds, fd_set *efds, - const ACE_Time_Value *timeout) -{ - ACE_OS_TRACE ("ACE_OS::select"); -#if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) - // We must defend against non-conformity! - timeval copy; - timeval *timep; - - if (timeout != 0) - { - copy = *timeout; - timep = © - } - else - timep = 0; -#else - const timeval *timep = (timeout == 0 ? (const timeval *)0 : *timeout); -#endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ - ACE_SOCKCALL_RETURN (::select (width, - (ACE_FD_SET_TYPE *) rfds, - (ACE_FD_SET_TYPE *) wfds, - (ACE_FD_SET_TYPE *) efds, - timep), - int, -1); -} - -ACE_INLINE int -ACE_OS::select (int width, - fd_set *rfds, fd_set *wfds, fd_set *efds, - const ACE_Time_Value &timeout) -{ - ACE_OS_TRACE ("ACE_OS::select"); -#if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) -# define ___ACE_TIMEOUT © - timeval copy = timeout; -#else -# define ___ACE_TIMEOUT timep - const timeval *timep = timeout; -#endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ - ACE_SOCKCALL_RETURN (::select (width, - (ACE_FD_SET_TYPE *) rfds, - (ACE_FD_SET_TYPE *) wfds, - (ACE_FD_SET_TYPE *) efds, - ___ACE_TIMEOUT), - int, -1); -#undef ___ACE_TIMEOUT -} - -ACE_INLINE int -ACE_OS::recv (ACE_HANDLE handle, char *buf, size_t len, int flags) -{ - ACE_OS_TRACE ("ACE_OS::recv"); - - // On UNIX, a non-blocking socket with no data to receive, this - // system call will return EWOULDBLOCK or EAGAIN, depending on the - // platform. UNIX 98 allows either errno, and they may be the same - // numeric value. So to make life easier for upper ACE layers as - // well as application programmers, always change EAGAIN to - // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's - // handled explicitly here. If the ACE_OSCALL macro ever changes, - // this function needs to be reviewed. On Win32, the regular macros - // can be used, as this is not an issue. -#if defined (ACE_WIN32) - ACE_SOCKCALL_RETURN (::recv ((ACE_SOCKET) handle, buf, - ACE_static_cast (int, len), flags), int, -1); -#else - int ace_result_; - ace_result_ = ::recv ((ACE_SOCKET) handle, buf, len, flags); - if (ace_result_ == -1 && errno == EAGAIN) - errno = EWOULDBLOCK; - return ace_result_; -#endif /* defined (ACE_WIN32) */ -} - -ACE_INLINE int -ACE_OS::recvfrom (ACE_HANDLE handle, - char *buf, - size_t len, - int flags, - struct sockaddr *addr, - int *addrlen) -{ - ACE_OS_TRACE ("ACE_OS::recvfrom"); -#if defined (ACE_PSOS) -# if !defined ACE_PSOS_DIAB_PPC - ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, - (struct sockaddr_in *) addr, (ACE_SOCKET_LEN *) addrlen), - int, -1); -# else - ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, - (struct sockaddr *) addr, (ACE_SOCKET_LEN *) addrlen), - int, -1); -# endif /* defined ACE_PSOS_DIAB_PPC */ -#elif defined (ACE_WIN32) - int shortened_len = ACE_static_cast (int, len); - int result = ::recvfrom ((ACE_SOCKET) handle, - buf, - shortened_len, - flags, - addr, - (ACE_SOCKET_LEN *) addrlen); - if (result == SOCKET_ERROR) - { - ACE_OS::set_errno_to_wsa_last_error (); - if (errno == WSAEMSGSIZE && - ACE_BIT_ENABLED (flags, MSG_PEEK)) - return shortened_len; - else - return -1; - } - else - return result; -#else /* non Win32 and non PSOS */ - ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, - addr, (ACE_SOCKET_LEN *) addrlen), - int, -1); -#endif /* defined (ACE_PSOS) */ -} - -ACE_INLINE int -ACE_OS::send (ACE_HANDLE handle, const char *buf, size_t len, int flags) -{ - ACE_OS_TRACE ("ACE_OS::send"); - - // On UNIX, a non-blocking socket with no data to receive, this - // system call will return EWOULDBLOCK or EAGAIN, depending on the - // platform. UNIX 98 allows either errno, and they may be the same - // numeric value. So to make life easier for upper ACE layers as - // well as application programmers, always change EAGAIN to - // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's - // handled explicitly here. If the ACE_OSCALL macro ever changes, - // this function needs to be reviewed. On Win32, the regular macros - // can be used, as this is not an issue. -#if defined (ACE_WIN32) - ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle, - buf, - ACE_static_cast (int, len), - flags), int, -1); -#else - int ace_result_; -# if defined (VXWORKS) || defined (HPUX) || defined (ACE_PSOS) - ace_result_ = ::send ((ACE_SOCKET) handle, (char *) buf, len, flags); -# else - ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags); -# endif /* VXWORKS */ - if (ace_result_ == -1 && errno == EAGAIN) - errno = EWOULDBLOCK; - return ace_result_; -#endif /* defined (ACE_WIN32) */ -} - -ACE_INLINE int -ACE_OS::recvfrom (ACE_HANDLE handle, - iovec *buffers, - int buffer_count, - size_t &number_of_bytes_recvd, - int &flags, - struct sockaddr *addr, - int *addrlen, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func) -{ - ACE_OS_TRACE ("ACE_OS::recvfrom"); - -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - DWORD bytes_recvd; - DWORD the_flags = flags; - int result = ::WSARecvFrom ((SOCKET) handle, - (WSABUF*)buffers, - buffer_count, - &bytes_recvd, - &the_flags, - addr, - addrlen, - overlapped, - func); - if (result != 0) { - ACE_OS::set_errno_to_last_error (); - } - flags = the_flags; - number_of_bytes_recvd = ACE_static_cast (size_t, bytes_recvd); - return result; -#else - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (buffers); - ACE_UNUSED_ARG (buffer_count); - ACE_UNUSED_ARG (number_of_bytes_recvd); - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (addrlen); - ACE_UNUSED_ARG (overlapped); - ACE_UNUSED_ARG (func); - ACE_NOTSUP_RETURN (-1); -#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ -} - -ACE_INLINE int -ACE_OS::sendto (ACE_HANDLE handle, - const char *buf, - size_t len, - int flags, - const struct sockaddr *addr, - int addrlen) -{ - ACE_OS_TRACE ("ACE_OS::sendto"); -#if defined (VXWORKS) - ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags, - ACE_const_cast (struct sockaddr *, addr), addrlen), - int, -1); -#elif defined (ACE_PSOS) -# if !defined (ACE_PSOS_DIAB_PPC) - ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags, - (struct sockaddr_in *) addr, addrlen), - int, -1); -# else - ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags, - (struct sockaddr *) addr, addrlen), - int, -1); -# endif /*defined ACE_PSOS_DIAB_PPC */ -#else -# if defined (ACE_WIN32) - ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, - ACE_static_cast (int, len), flags, - ACE_const_cast (struct sockaddr *, addr), addrlen), - int, -1); -# else - ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, len, flags, - ACE_const_cast (struct sockaddr *, addr), addrlen), - int, -1); -# endif /* ACE_WIN32 */ -#endif /* VXWORKS */ -} - -ACE_INLINE int -ACE_OS::sendto (ACE_HANDLE handle, - const iovec *buffers, - int buffer_count, - size_t &number_of_bytes_sent, - int flags, - const struct sockaddr *addr, - int addrlen, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func) -{ - ACE_OS_TRACE ("ACE_OS::sendto"); -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - DWORD bytes_sent; - int result = ::WSASendTo ((SOCKET) handle, - (WSABUF*)buffers, - buffer_count, - &bytes_sent, - flags, - addr, - addrlen, - overlapped, - func); - if (result != 0) { - ACE_OS::set_errno_to_last_error (); - } - number_of_bytes_sent = ACE_static_cast (size_t, bytes_sent); - return result; -#else - ACE_UNUSED_ARG (overlapped); - ACE_UNUSED_ARG (func); - - number_of_bytes_sent = 0; - - int result = 0; - - for (int i = 0; i < buffer_count; i++) - { - result = ACE_OS::sendto (handle, - ACE_reinterpret_cast (char *ACE_CAST_CONST, - buffers[i].iov_base), - buffers[i].iov_len, - flags, - addr, - addrlen); - if (result == -1) - break; - number_of_bytes_sent += result; - } - - return result; -#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ -} - -ACE_INLINE int -ACE_OS::getpeername (ACE_HANDLE handle, struct sockaddr *addr, - int *addrlen) -{ - ACE_OS_TRACE ("ACE_OS::getpeername"); -#if defined (ACE_PSOS) && !defined ACE_PSOS_DIAB_PPC - ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle, - (struct sockaddr_in *) addr, - (ACE_SOCKET_LEN *) addrlen), - int, -1); -#else - ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen), - int, -1); -#endif /* defined (ACE_PSOS) */ -} - -ACE_INLINE struct protoent * -ACE_OS::getprotobyname (const char *name) -{ -#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_NONCONST_GETBY) - ACE_SOCKCALL_RETURN (::getprotobyname (ACE_const_cast (char *, name)), - struct protoent *, - 0); -#else - ACE_SOCKCALL_RETURN (::getprotobyname (name), - struct protoent *, - 0); -#endif /* VXWORKS */ -} - -ACE_INLINE struct protoent * -ACE_OS::getprotobyname_r (const char *name, - struct protoent *result, - ACE_PROTOENT_DATA buffer) -{ -#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) -# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) - if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0) - return result; - else - return 0; -# elif defined (__GLIBC__) - // GNU C library has a different signature - if (::getprotobyname_r (name, - result, - buffer, - sizeof (ACE_PROTOENT_DATA), - &result) == 0) - return result; - else - return 0; -# else -# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) - ACE_UNUSED_ARG (result); - ACE_NETDBCALL_RETURN (::getprotobyname (name), - struct protoent *, 0, - buffer, sizeof (ACE_PROTOENT_DATA)); -# else - ACE_SOCKCALL_RETURN (::getprotobyname_r (name, - result, - buffer, - sizeof (ACE_PROTOENT_DATA)), - struct protoent *, 0); -# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ -# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ -#elif defined (ACE_HAS_NONCONST_GETBY) - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_SOCKCALL_RETURN (::getprotobyname (ACE_const_cast (char *, name)), - struct protoent *, 0); -#else - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (result); - - ACE_SOCKCALL_RETURN (::getprotobyname (name), - struct protoent *, - 0); -#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */ -} - -ACE_INLINE struct protoent * -ACE_OS::getprotobynumber (int proto) -{ -#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) - ACE_UNUSED_ARG (proto); - ACE_NOTSUP_RETURN (0); -#else - ACE_SOCKCALL_RETURN (::getprotobynumber (proto), - struct protoent *, 0); -#endif /* VXWORKS */ -} - -ACE_INLINE struct protoent * -ACE_OS::getprotobynumber_r (int proto, - struct protoent *result, - ACE_PROTOENT_DATA buffer) -{ -#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) - ACE_UNUSED_ARG (proto); - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) -# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) - if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0) - return result; - else - return 0; -# elif defined (__GLIBC__) - // GNU C library has a different signature - if (::getprotobynumber_r (proto, - result, - buffer, - sizeof (ACE_PROTOENT_DATA), - &result) == 0) - return result; - else - return 0; -# else -# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) - ACE_UNUSED_ARG (result); - ACE_NETDBCALL_RETURN (::getprotobynumber (proto), - struct protoent *, 0, - buffer, sizeof (ACE_PROTOENT_DATA)); -# else - ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)), - struct protoent *, 0); -# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ -# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ -#else - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (result); - - ACE_SOCKCALL_RETURN (::getprotobynumber (proto), - struct protoent *, 0); -#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ -} - -ACE_INLINE struct servent * -ACE_OS::getservbyname (const char *svc, const char *proto) -{ - ACE_OS_TRACE ("ACE_OS::getservbyname"); -#if defined (ACE_LACKS_GETSERVBYNAME) - ACE_UNUSED_ARG (svc); - ACE_UNUSED_ARG (proto); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_NONCONST_GETBY) - ACE_SOCKCALL_RETURN (::getservbyname (ACE_const_cast (char *, svc), - ACE_const_cast (char *, proto)), - struct servent *, - 0); -#else - ACE_SOCKCALL_RETURN (::getservbyname (svc, - proto), - struct servent *, - 0); -#endif /* ACE_HAS_NONCONST_GETBY */ -} - -ACE_INLINE int -ACE_OS::getsockname (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen) -{ - ACE_OS_TRACE ("ACE_OS::getsockname"); -#if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) - ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle, - (struct sockaddr_in *) addr, - (ACE_SOCKET_LEN *) addrlen), - int, -1); -#else - ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle, - addr, - (ACE_SOCKET_LEN *) addrlen), - int, -1); -#endif /* defined (ACE_PSOS) */ -} - -ACE_INLINE int -ACE_OS::getsockopt (ACE_HANDLE handle, - int level, - int optname, - char *optval, - int *optlen) -{ - ACE_OS_TRACE ("ACE_OS::getsockopt"); - ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle, - level, - optname, - optval, - (ACE_SOCKET_LEN *) optlen), - int, - -1); -} - -ACE_INLINE int -ACE_OS::listen (ACE_HANDLE handle, int backlog) -{ - ACE_OS_TRACE ("ACE_OS::listen"); - ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1); -} - -ACE_INLINE int -ACE_OS::setsockopt (ACE_HANDLE handle, - int level, - int optname, - const char *optval, - int optlen) -{ - ACE_OS_TRACE ("ACE_OS::setsockopt"); - - #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT) - // To work around an inconsistency with Microsofts implementation of - // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock - // always behaves as if SO_REUSEADDR=1. Some implementations have the - // same behaviour as Winsock, but use a new name for it. SO_REUSEPORT. - // If you want the normal behaviour for SO_REUSEADDR=0, then NT 4 sp4 and later - // supports SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform SDK - // so it was decided to ignore the option for now. (Especially since ACE always - // sets SO_REUSEADDR=1, which we can mimic by doing nothing.) - if (level == SOL_SOCKET) { - if (optname == SO_REUSEADDR) { - return 0; // Not supported by Winsock - } - if (optname == SO_REUSEPORT) { - optname = SO_REUSEADDR; - } - } - #endif /*ACE_HAS_WINSOCK2*/ - - ACE_SOCKCALL_RETURN (::setsockopt ((ACE_SOCKET) handle, - level, - optname, - (ACE_SOCKOPT_TYPE1) optval, - optlen), - int, - -1); -} - -ACE_INLINE int -ACE_OS::shutdown (ACE_HANDLE handle, int how) -{ - ACE_OS_TRACE ("ACE_OS::shutdown"); - ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1); -} - -ACE_INLINE ACE_HANDLE -ACE_OS::socket (int domain, - int type, - int proto) -{ - ACE_OS_TRACE ("ACE_OS::socket"); - ACE_SOCKCALL_RETURN (::socket (domain, - type, - proto), - ACE_HANDLE, - ACE_INVALID_HANDLE); -} - -ACE_INLINE ACE_HANDLE -ACE_OS::socket (int domain, - int type, - int proto, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags) -{ - ACE_OS_TRACE ("ACE_OS::socket"); - -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - ACE_SOCKCALL_RETURN (::WSASocket (domain, - type, - proto, - protocolinfo, - g, - flags), - ACE_HANDLE, - ACE_INVALID_HANDLE); -#else - ACE_UNUSED_ARG (protocolinfo); - ACE_UNUSED_ARG (g); - ACE_UNUSED_ARG (flags); - - return ACE_OS::socket (domain, - type, - proto); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE int -ACE_OS::atoi (const char *s) -{ - ACE_OSCALL_RETURN (::atoi (s), int, -1); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::atoi (const wchar_t *s) -{ -#if defined (ACE_WIN32) - ACE_OSCALL_RETURN (::_wtoi (s), int, -1); -#else /* ACE_WIN32 */ - return ACE_OS::atoi (ACE_Wide_To_Ascii(s).char_rep()); -#endif /* ACE_WIN32 */ -} -#endif /* ACE_HAS_WCHAR */ - - -ACE_INLINE void * -ACE_OS::atop (const char *s) -{ - ACE_TRACE ("ACE_OS::atop"); - // It would be nice to make use of Basic_Types.h here, but that - // file relies on OS.h. Fortunately, most platforms have int - // the same as pointer size (IA32, IA64), with Win64 being the - // exception. -#if defined (ACE_WIN64) - __int64 ip = ::_atoi64 (s); -#else - int ip = ::atoi (s); -#endif /* ACE_WIN64 */ - void *p = ACE_reinterpret_cast (void *, ip); - return p; -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE void * -ACE_OS::atop (const wchar_t *s) -{ -# if defined (ACE_WIN64) - __int64 ip = ::_wtoi64 (s); -# else - int ip = ACE_OS::atoi (s); -# endif /* ACE_WIN64 */ - void *p = ACE_reinterpret_cast (void *, ip); - return p; -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE double -ACE_OS::floor (double x) -{ - // This method computes the largest integral value not greater than x. - return double (ACE_static_cast (long, x)); -} - -ACE_INLINE double -ACE_OS::ceil (double x) -{ - // This method computes the smallest integral value not less than x. - double floor = ACE_OS::floor (x); - if (floor == x) - return floor; - else - return floor + 1; -} - -ACE_INLINE int -ACE_OS::recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags) -{ - ACE_OS_TRACE ("ACE_OS::recvmsg"); -#if !defined (ACE_LACKS_RECVMSG) -# if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) - DWORD bytes_received = 0; - - int result = ::WSARecvFrom ((SOCKET) handle, - (WSABUF *) msg->msg_iov, - msg->msg_iovlen, - &bytes_received, - (DWORD *) &flags, - msg->msg_name, - &msg->msg_namelen, - 0, - 0); - - if (result != 0) - { - ACE_OS::set_errno_to_last_error (); - return -1; - } - else - return (ssize_t) bytes_received; -# else /* ACE_HAS_WINSOCK2 */ - ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), int, -1); -# endif /* ACE_HAS_WINSOCK2 */ -#else - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (msg); - ACE_UNUSED_ARG (handle); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_LACKS_RECVMSG */ -} - -ACE_INLINE int -ACE_OS::sendmsg (ACE_HANDLE handle, - const struct msghdr *msg, - int flags) -{ - ACE_OS_TRACE ("ACE_OS::sendmsg"); -#if !defined (ACE_LACKS_SENDMSG) -# if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) - DWORD bytes_sent = 0; - int result = ::WSASendTo ((SOCKET) handle, - (WSABUF *) msg->msg_iov, - msg->msg_iovlen, - &bytes_sent, - flags, - msg->msg_name, - msg->msg_namelen, - 0, - 0); - - if (result != 0) - { - ACE_OS::set_errno_to_last_error (); - return -1; - } - else - return (ssize_t) bytes_sent; -# elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_PSOS) - ACE_SOCKCALL_RETURN (::sendmsg (handle, (struct msghdr *) msg, flags), int, -1); -# else - ACE_SOCKCALL_RETURN (::sendmsg (handle, (ACE_SENDMSG_TYPE *) msg, flags), int, -1); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ -#else - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (msg); - ACE_UNUSED_ARG (handle); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_LACKS_SENDMSG */ -} - -ACE_INLINE int -ACE_OS::fclose (FILE *fp) -{ - ACE_OS_TRACE ("ACE_OS::fclose"); - ACE_OSCALL_RETURN (::fclose (fp), int, -1); -} - -ACE_INLINE ACE_TCHAR * -ACE_OS::fgets (ACE_TCHAR *buf, int size, FILE *fp) -{ - ACE_OS_TRACE ("ACE_OS::fgets"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::fgetws (buf, size, fp), wchar_t *, 0); -#else /* ACE_WIN32 */ - ACE_OSCALL_RETURN (::fgets (buf, size, fp), char *, 0); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ -} - -#if !defined (ACE_WIN32) -// Win32 implementation of fopen(const ACE_TCHAR*, const ACE_TCHAR*) -// is in OS.cpp. -ACE_INLINE FILE * -ACE_OS::fopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode) -{ - ACE_OS_TRACE ("ACE_OS::fopen"); - ACE_OSCALL_RETURN (::fopen (filename, mode), FILE *, 0); -} -#endif /* ACE_WIN32 */ - -ACE_INLINE FILE * -ACE_OS::freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream) -{ - ACE_OS_TRACE ("ACE_OS::freopen"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wfreopen (filename, mode, stream), FILE *, 0); -#else - ACE_OSCALL_RETURN (::freopen (filename, mode, stream), FILE *, 0); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::fflush (FILE *fp) -{ - ACE_OS_TRACE ("ACE_OS::fflush"); -#if defined (VXWORKS) - if (fp == 0) - { - // Do not allow fflush(0) on VxWorks - return 0; - } -#endif /* VXWORKS */ - - ACE_OSCALL_RETURN (::fflush (fp), int, -1); -} - -ACE_INLINE size_t -ACE_OS::fread (void *ptr, size_t size, size_t nelems, FILE *fp) -{ - ACE_OS_TRACE ("ACE_OS::fread"); -#if defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::fread ((char *) ptr, size, nelems, fp), int, 0); -#else - ACE_OSCALL_RETURN (::fread (ptr, size, nelems, fp), int, 0); -#endif /* ACE_LACKS_POSIX_PROTOTYPES */ -} - -ACE_INLINE size_t -ACE_OS::fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp) -{ - ACE_OS_TRACE ("ACE_OS::fwrite"); -#if defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::fwrite ((const char *) ptr, size, nitems, fp), int, 0); -#else - ACE_OSCALL_RETURN (::fwrite (ptr, size, nitems, fp), int, 0); -#endif /* ACE_LACKS_POSIX_PROTOTYPES */ -} - -ACE_INLINE int -ACE_OS::truncate (const ACE_TCHAR *filename, - off_t offset) -{ - ACE_OS_TRACE ("ACE_OS::truncate"); -#if defined (ACE_WIN32) - ACE_HANDLE handle = ACE_OS::open (filename, - O_WRONLY, - ACE_DEFAULT_FILE_PERMS); - if (handle == ACE_INVALID_HANDLE) - ACE_FAIL_RETURN (-1); - else if (::SetFilePointer (handle, - offset, - 0, - FILE_BEGIN) != (unsigned) -1) - { - BOOL result = ::SetEndOfFile (handle); - ::CloseHandle (handle); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1); - } - else - { - ::CloseHandle (handle); - ACE_FAIL_RETURN (-1); - } - /* NOTREACHED */ -#elif !defined (ACE_LACKS_TRUNCATE) - ACE_OSCALL_RETURN (::truncate (filename, offset), int, -1); -#else - ACE_UNUSED_ARG (filename); - ACE_UNUSED_ARG (offset); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -// Accessors to PWD file. - -ACE_INLINE struct passwd * -ACE_OS::getpwnam (const char *name) -{ -#if !defined (ACE_LACKS_PWD_FUNCTIONS) -# if !defined (ACE_WIN32) - return ::getpwnam (name); -# else - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (0); -# endif /* ACE_WIN32 */ -#else - ACE_UNUSED_ARG (name); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_LACKS_PWD_FUNCTIONS */ -} - -ACE_INLINE void -ACE_OS::setpwent (void) -{ -#if !defined (ACE_LACKS_PWD_FUNCTIONS) -# if !defined (ACE_WIN32) - ::setpwent (); -# else -# endif /* ACE_WIN32 */ -#else -#endif /* ! ACE_LACKS_PWD_FUNCTIONS */ -} - -ACE_INLINE void -ACE_OS::endpwent (void) -{ -#if !defined (ACE_LACKS_PWD_FUNCTIONS) -# if !defined (ACE_WIN32) - ::endpwent (); -# else -# endif /* ACE_WIN32 */ -#else -#endif /* ! ACE_LACKS_PWD_FUNCTIONS */ -} - -ACE_INLINE struct passwd * -ACE_OS::getpwent (void) -{ -#if !defined (ACE_LACKS_PWD_FUNCTIONS) -# if !defined (ACE_WIN32) - return ::getpwent (); -# else - ACE_NOTSUP_RETURN (0); -# endif /* ACE_WIN32 */ -#else - ACE_NOTSUP_RETURN (0); -#endif /* ! ACE_LACKS_PWD_FUNCTIONS */ -} - -ACE_INLINE struct passwd * -ACE_OS::getpwnam_r (const char *name, struct passwd *pwent, - char *buffer, int buflen) -{ -#if defined (ACE_HAS_POSIX_GETPWNAM_R) - struct passwd *result; - int status; - - status = ::getpwnam_r (name, pwent, buffer, buflen, &result); - - if (status != 0) - { - errno = status; - result = 0; - } - return result; -#elif !defined (ACE_LACKS_PWD_FUNCTIONS) -# if defined (ACE_HAS_REENTRANT_FUNCTIONS) -# if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS) -# if defined (ACE_HAS_PTHREADS_STD) && \ - !defined (ACE_HAS_STHREADS) || \ - defined (HPUX_11) || \ - defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7. - struct passwd *result; - int status; -# if defined (DIGITAL_UNIX) - ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result); -# else - // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined - // in pwd.h, and that redefinition is used here -# if defined (__IBMCPP__) && (__IBMCPP__ >= 400) /* VAC++ 4 */ - status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result); -# else - status = ::getpwnam_r (name, pwent, buffer, buflen, &result); -# endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */ - if (status != 0) - { - errno = status; - result = 0; - } -# endif /* (DIGITAL_UNIX) */ - return result; -# elif defined (AIX) || defined (HPUX_10) - if (::getpwnam_r (name, pwent, buffer, buflen) == -1) - return 0; - else - return pwent; -# else - return ::getpwnam_r (name, pwent, buffer, buflen); -# endif /* ACE_HAS_PTHREADS_STD */ -# else - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (pwent); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (buflen); - ACE_NOTSUP_RETURN (0); -# endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */ -# else - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (pwent); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (buflen); - ACE_NOTSUP_RETURN (0); -# endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -#else - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (pwent); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (buflen); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_POSIX_GETPWNAM_R */ -} - -// DNS accessors. - -#if !defined (VXWORKS) -ACE_INLINE struct hostent * -ACE_OS::gethostbyaddr_r (const char *addr, - int length, - int type, - struct hostent *result, - ACE_HOSTENT_DATA buffer, - int *h_errnop) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r"); -# if defined (ACE_PSOS) - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (length); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (h_errnop); - ACE_NOTSUP_RETURN (0); -# elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) -# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) - ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); - - if (::gethostbyaddr_r ((char *) addr, length, type, result, - (struct hostent_data *) buffer)== 0) - return result; - else - { - *h_errnop = h_errno; - return (struct hostent *) 0; - } -# elif defined (__GLIBC__) - // GNU C library has a different signature - ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); - - if (::gethostbyaddr_r ((char *) addr, - length, - type, - result, - buffer, - sizeof (ACE_HOSTENT_DATA), - &result, - h_errnop) == 0) - return result; - else - return (struct hostent *) 0; -# else -# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (h_errnop); - ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type), - struct hostent *, 0, - buffer, sizeof (ACE_HOSTENT_DATA)); -# else - ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result, - buffer, sizeof (ACE_HOSTENT_DATA), - h_errnop), - struct hostent *, 0); -# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ -# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ -# elif defined (ACE_HAS_NONCONST_GETBY) - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (h_errnop); - ACE_SOCKCALL_RETURN (::gethostbyaddr (ACE_const_cast (char *, addr), - (ACE_SOCKET_LEN) length, - type), - struct hostent *, - 0); -# else - ACE_UNUSED_ARG (h_errnop); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (result); - - ACE_SOCKCALL_RETURN (::gethostbyaddr (addr, - (ACE_SOCKET_LEN) length, - type), - struct hostent *, - 0); -# endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ -} - -ACE_INLINE struct hostent * -ACE_OS::gethostbyname_r (const char *name, - struct hostent *result, - ACE_HOSTENT_DATA buffer, - int *h_errnop) -{ - ACE_OS_TRACE ("ACE_OS::gethostbyname_r"); -#if defined (ACE_PSOS) - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (h_errnop); - ACE_NOTSUP_RETURN (0); -# elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) -# if defined (DIGITAL_UNIX) || \ - (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2)) - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (h_errnop); - - // gethostbyname returns thread-specific storage on Digital Unix and - // AIX 4.3 - ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0); -# elif defined (AIX) || defined (HPUX_10) - ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); - - if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0) - return result; - else - { - *h_errnop = h_errno; - return (struct hostent *) 0; - } -# elif defined (__GLIBC__) - // GNU C library has a different signature - ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); - - if (::gethostbyname_r (name, - result, - buffer, - sizeof (ACE_HOSTENT_DATA), - &result, - h_errnop) == 0) - return result; - else - return (struct hostent *) 0; -# else -# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (h_errnop); - ACE_NETDBCALL_RETURN (::gethostbyname (name), - struct hostent *, 0, - buffer, sizeof (ACE_HOSTENT_DATA)); -# else - ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer, - sizeof (ACE_HOSTENT_DATA), - h_errnop), - struct hostent *, - 0); -# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ -# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ -# elif defined (ACE_HAS_NONCONST_GETBY) - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (h_errnop); - ACE_SOCKCALL_RETURN (::gethostbyname (ACE_const_cast (char *, name)), - struct hostent *, - 0); -# else - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buffer); - ACE_UNUSED_ARG (h_errnop); - - ACE_SOCKCALL_RETURN (::gethostbyname (name), - struct hostent *, - 0); -# endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ -} -#endif /* ! VXWORKS */ - -#if 0 -// @@ gets is evil anyway. -// and it is *** DEPRECATED *** now. If you -// really needs gets, use ACE_OS::gets (char*, int) -// instead. -ACE_INLINE char * -ACE_OS::gets (char *str) -{ - ACE_OS_TRACE ("ACE_OS::gets"); - ACE_OSCALL_RETURN (::gets (str), char *, 0); -} -#endif /* 0 */ - -ACE_INLINE struct servent * -ACE_OS::getservbyname_r (const char *svc, - const char *proto, - struct servent *result, - ACE_SERVENT_DATA buf) -{ - ACE_OS_TRACE ("ACE_OS::getservbyname_r"); -#if defined (ACE_LACKS_GETSERVBYNAME) - ACE_UNUSED_ARG (svc); - ACE_UNUSED_ARG (proto); - ACE_UNUSED_ARG (result); - ACE_UNUSED_ARG (buf); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) -# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) - ::memset (buf, 0, sizeof (ACE_SERVENT_DATA)); - - if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0) - return result; - else - return (struct servent *) 0; -# elif defined (__GLIBC__) - // GNU C library has a different signature - ::memset (buf, 0, sizeof (ACE_SERVENT_DATA)); - - if (::getservbyname_r (svc, - proto, - result, - buf, - sizeof (ACE_SERVENT_DATA), - &result) == 0) - return result; - else - return (struct servent *) 0; -# else -# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) - ACE_UNUSED_ARG (result); - ACE_NETDBCALL_RETURN (::getservbyname (svc, proto), - struct servent *, 0, - buf, sizeof (ACE_SERVENT_DATA)); -# else - ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf, - sizeof (ACE_SERVENT_DATA)), - struct servent *, 0); -# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ -# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ -#elif defined (ACE_HAS_NONCONST_GETBY) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (result); - ACE_SOCKCALL_RETURN (::getservbyname (ACE_const_cast (char *, svc), - ACE_const_cast (char *, proto)), - struct servent *, - 0); -#else - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (result); - - ACE_SOCKCALL_RETURN (::getservbyname (svc, - proto), - struct servent *, - 0); -#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ -} - -ACE_INLINE unsigned long -ACE_OS::inet_addr (const char *name) -{ - ACE_OS_TRACE ("ACE_OS::inet_addr"); -#if defined (VXWORKS) || defined (ACE_PSOS) - - u_long ret = 0; - u_int segment; - u_int valid = 1; - - for (u_int i = 0; i < 4; ++i) - { - ret <<= 8; - if (*name != '\0') - { - segment = 0; - - while (*name >= '0' && *name <= '9') - { - segment *= 10; - segment += *name++ - '0'; - } - if (*name != '.' && *name != '\0') - { - valid = 0; - break; - } - - ret |= segment; - - if (*name == '.') - { - ++name; - } - } - } - return valid ? htonl (ret) : INADDR_NONE; -#elif defined (ACE_HAS_NONCONST_GETBY) - return ::inet_addr ((char *) name); -#else - return ::inet_addr (name); -#endif /* ACE_HAS_NONCONST_GETBY */ -} - -// For pSOS, this function is in OS.cpp -#if !defined (ACE_PSOS) -ACE_INLINE char * -ACE_OS::inet_ntoa (const struct in_addr addr) -{ - ACE_OS_TRACE ("ACE_OS::inet_ntoa"); - ACE_OSCALL_RETURN (::inet_ntoa (addr), - char *, - 0); -} -#endif /* defined (ACE_PSOS) */ - -ACE_INLINE int -ACE_OS::inet_pton (int family, const char *strptr, void *addrptr) -{ - ACE_OS_TRACE ("ACE_OS::inet_pton"); - -#if defined (ACE_HAS_IPV6) - ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1); -#else - if (family == AF_INET) - { - struct in_addr in_val; - - if (ACE_OS::inet_aton (strptr, &in_val)) - { - ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr)); - return 1; // Success - } - - return 0; // Input is not a valid presentation format - } - - ACE_NOTSUP_RETURN(-1); -#endif /* ACE_HAS_IPV6 */ -} - -ACE_INLINE const char * -ACE_OS::inet_ntop (int family, const void *addrptr, char *strptr, size_t len) -{ - ACE_OS_TRACE ("ACE_OS::inet_ntop"); - -#if defined (ACE_HAS_IPV6) - ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0); -#else - const u_char *p = - ACE_reinterpret_cast (const u_char *, addrptr); - - if (family == AF_INET) - { - char temp[INET_ADDRSTRLEN]; - - // Stevens uses snprintf() in his implementation but snprintf() - // doesn't appear to be very portable. For now, hope that using - // sprintf() will not cause any string/memory overrun problems. - ACE_OS::sprintf (temp, - "%d.%d.%d.%d", - p[0], p[1], p[2], p[3]); - - if (ACE_OS::strlen (temp) >= len) - { - errno = ENOSPC; - return 0; // Failure - } - - ACE_OS::strcpy (strptr, temp); - return strptr; - } - - ACE_NOTSUP_RETURN(0); -#endif /* ACE_HAS_IPV6 */ -} - -ACE_INLINE int -ACE_OS::set_errno_to_last_error (void) -{ -# if defined (ACE_WIN32) -// Borland C++ Builder 4 has a bug in the RTL that resets the -// <GetLastError> value to zero when errno is accessed. Thus, we have -// to use this to set errno to GetLastError. It's bad, but only for -// WIN32. -# if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400) - int last_error = ::GetLastError (); - return errno = last_error; -# else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ - return errno = ::GetLastError (); -# endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ -#else - return errno; -# endif /* defined(ACE_WIN32) */ -} - -ACE_INLINE int -ACE_OS::set_errno_to_wsa_last_error (void) -{ -# if defined (ACE_WIN32) -// Borland C++ Builder 4 has a bug in the RTL that resets the -// <GetLastError> value to zero when errno is accessed. Thus, we have -// to use this to set errno to GetLastError. It's bad, but only for -// WIN32 -# if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400) - int last_error = ::WSAGetLastError (); - return errno = last_error; -# else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ - return errno = ::WSAGetLastError (); -# endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ -#else - return errno; -# endif /* defined(ACE_WIN32) */ -} - -ACE_INLINE int -ACE_OS::last_error (void) -{ - // ACE_OS_TRACE ("ACE_OS::last_error"); - -#if defined (ACE_WIN32) - int lerror = ::GetLastError (); - int lerrno = errno; - return lerrno == 0 ? lerror : lerrno; -#else - return errno; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE void -ACE_OS::last_error (int error) -{ - ACE_OS_TRACE ("ACE_OS::last_error"); -#if defined (ACE_WIN32) - ::SetLastError (error); -#endif /* ACE_WIN32 */ - errno = error; -} - -ACE_INLINE void -ACE_OS::perror (const ACE_TCHAR *s) -{ - ACE_OS_TRACE ("ACE_OS::perror"); -#if defined (ACE_HAS_WINCE) - // @@ WINCE: How should this be handled - ACE_UNUSED_ARG (s); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ::_wperror (s); -#else - ::perror (s); -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_OS::puts (const ACE_TCHAR *s) -{ - ACE_OS_TRACE ("ACE_OS::puts"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_putws (s), int, -1); -#else /* ACE_WIN32 */ - ACE_OSCALL_RETURN (::puts (s), int, -1); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::fputs (const ACE_TCHAR *s, FILE *stream) -{ - ACE_OS_TRACE ("ACE_OS::fputs"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::fputws (s, stream), int, -1); -#else /* ACE_WIN32 */ - ACE_OSCALL_RETURN (::fputs (s, stream), int, -1); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ -} - -ACE_INLINE ACE_SignalHandler -ACE_OS::signal (int signum, ACE_SignalHandler func) -{ - if (signum == 0) - return 0; - else -#if defined (ACE_PSOS) && !defined (ACE_PSOS_TM) && !defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) - return (ACE_SignalHandler) ::signal (signum, (void (*)(void)) func); -#elif defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC) - return 0; -#elif defined (ACE_PSOS_TM) - // @@ It would be good to rework this so the ACE_PSOS_TM specific - // branch is not needed, but prying it out of ACE_LACKS_UNIX_SIGNALS - // will take some extra work - deferred for now. - return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func); -#elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) -# if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS_SIGNALS) - return ::signal (signum, func); -# else - return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func); -# endif /* !ACE_HAS_TANDEM_SIGNALS */ -#else - // @@ WINCE: Don't know how to implement signal on WinCE (yet.) - ACE_UNUSED_ARG (signum); - ACE_UNUSED_ARG (func); - ACE_NOTSUP_RETURN (0); // Should return SIG_ERR but it is not defined on WinCE. -#endif /* ACE_PSOS && !ACE_PSOS_TM && !ACE_PSOS_DIAB_MIPS && !ACE_PSOS_DIAB_PPC */ -} - -ACE_INLINE int -ACE_OS::system (const ACE_TCHAR *s) -{ - // ACE_OS_TRACE ("ACE_OS::system"); -#if defined (CHORUS) || defined (ACE_HAS_WINCE) || defined(ACE_PSOS) - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wsystem (s), int, -1); -#else - ACE_OSCALL_RETURN (::system (s), int, -1); -#endif /* !CHORUS */ -} - -ACE_INLINE int -ACE_OS::thr_continue (ACE_hthread_t target_thread) -{ - ACE_OS_TRACE ("ACE_OS::thr_continue"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), ace_result_), int, -1); -# elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREAD_CONTINUE) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread), - ace_result_), - int, -1); -# else - ACE_UNUSED_ARG (target_thread); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PTHREAD_CONTINUE */ -# elif defined (ACE_HAS_WTHREADS) - DWORD result = ::ResumeThread (target_thread); - if (result == ACE_SYSCALL_FAILED) - ACE_FAIL_RETURN (-1); - else - return 0; -# elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_resume (target_thread), ace_result_), int, -1); -# elif defined (VXWORKS) - ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (target_thread); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2) -{ -#if defined (ACE_HAS_PTHREADS) -# if defined (pthread_equal) - // If it's a macro we can't say "::pthread_equal"... - return pthread_equal (t1, t2); -# else - return ::pthread_equal (t1, t2); -# endif /* pthread_equal */ -#else /* For STHREADS, WTHREADS, and VXWORKS ... */ - // Hum, Do we need to treat WTHREAD differently? - // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE. - return t1 == t2; -#endif /* ACE_HAS_PTHREADS */ -} - -ACE_INLINE int -ACE_OS::thr_getconcurrency (void) -{ - ACE_OS_TRACE ("ACE_OS::thr_getconcurrency"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - return ::thr_getconcurrency (); -# elif defined (ACE_HAS_PTHREADS) || defined (VXWORKS) || defined (ACE_PSOS) - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WTHREADS) - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_getprio (ACE_hthread_t id, int &priority, int &policy) -{ - ACE_OS_TRACE ("ACE_OS::thr_getprio"); - ACE_UNUSED_ARG (policy); -#if defined (ACE_HAS_THREADS) -# if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED)) - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - int result; - result = ::pthread_getprio (id); - if (result != -1) - { - priority = result; - return 0; - } - else - return -1; -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - - pthread_attr_t attr; - if (pthread_getschedattr (id, &attr) == 0) - { - priority = pthread_attr_getprio(&attr); - return 0; - } - return -1; -# else - - struct sched_param param; - int result; - - ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, ¶m), - result), int, - -1, result); - priority = param.sched_priority; - return result; -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (id, &priority), ace_result_), int, -1); -# elif defined (ACE_HAS_WTHREADS) - priority = ::GetThreadPriority (id); - if (priority == THREAD_PRIORITY_ERROR_RETURN) - ACE_FAIL_RETURN (-1); - else - return 0; -# elif defined (ACE_PSOS) - // passing a 0 in the second argument does not alter task priority, third arg gets existing one - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, 0, (u_long *) &priority), ace_result_), int, -1); -# elif defined (VXWORKS) - ACE_OSCALL_RETURN (::taskPriorityGet (id, &priority), int, -1); -# else - ACE_UNUSED_ARG (id); - ACE_UNUSED_ARG (priority); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (id); - ACE_UNUSED_ARG (priority); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_getprio (ACE_hthread_t id, int &priority) -{ - ACE_OS_TRACE ("ACE_OS::thr_getprio"); - int policy = 0; - return ACE_OS::thr_getprio (id, priority, policy); -} - -#if defined (ACE_HAS_TSS_EMULATION) - -# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) -ACE_INLINE int -ACE_OS::thr_getspecific (ACE_OS_thread_key_t key, void **data) -{ - ACE_OS_TRACE ("ACE_OS::thr_getspecific"); -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - return pthread_getspecific (key, data); -# else /* this is ACE_HAS_PTHREADS_DRAFT7 or STD */ -# if (pthread_getspecific) - // This is a macro on some platforms, e.g., CHORUS! - *data = pthread_getspecific (key); -# else - *data = pthread_getspecific (key); -# endif /* pthread_getspecific */ -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ - return 0; -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1); -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - ACE_hthread_t tid; - ACE_OS::thr_self (tid); - return (::tsd_getval (key, tid, data) == 0) ? 0 : -1; -# elif defined (ACE_HAS_WTHREADS) - - // The following handling of errno is designed like this due to - // ACE_Log_Msg::instance calling ACE_OS::thr_getspecific. - // Basically, it is ok for a system call to reset the error to zero. - // (It really shouldn't, though). However, we have to remember to - // store errno *immediately* after an error is detected. Calling - // ACE_ERROR_RETURN((..., errno)) did not work because errno was - // cleared before being passed to the thread-specific instance of - // ACE_Log_Msg. The workaround for was to make it so - // thr_getspecific did not have the side effect of clearing errno. - // The correct fix is for ACE_ERROR_RETURN to store errno - //(actually ACE_OS::last_error) before getting the ACE_Log_Msg tss - // pointer, which is how it is implemented now. However, other uses - // of ACE_Log_Msg may not work correctly, so we're keeping this as - // it is for now. - - ACE_Errno_Guard error (errno); - *data = ::TlsGetValue (key); - if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR) - return -1; - else - return 0; -# endif /* ACE_HAS_STHREADS */ -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (data); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ -} -# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ - -# if !defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) -ACE_INLINE -void **& -ACE_TSS_Emulation::tss_base () -{ -# if defined (VXWORKS) - return (void **&) taskIdCurrent->ACE_VXWORKS_SPARE; -# elif defined (ACE_PSOS) - // not supported - long x=0; //JINLU - return (void **&) x; -# else - // Uh oh. - ACE_NOTSUP_RETURN (0); -# endif /* VXWORKS */ -} -# endif /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ - -ACE_INLINE -ACE_TSS_Emulation::ACE_TSS_DESTRUCTOR -ACE_TSS_Emulation::tss_destructor (const ACE_thread_key_t key) -{ - ACE_KEY_INDEX (key_index, key); - return tss_destructor_ [key_index]; -} - -ACE_INLINE -void -ACE_TSS_Emulation::tss_destructor (const ACE_thread_key_t key, - ACE_TSS_DESTRUCTOR destructor) -{ - ACE_KEY_INDEX (key_index, key); - tss_destructor_ [key_index] = destructor; -} - -ACE_INLINE -void *& -ACE_TSS_Emulation::ts_object (const ACE_thread_key_t key) -{ - ACE_KEY_INDEX (key_index, key); - -#if defined (ACE_PSOS) - u_long tss_base; - t_getreg (0, PSOS_TASK_REG_TSS, &tss_base); - return ((void **) tss_base)[key_index]; -#else -# if defined (VXWORKS) - /* If someone wants tss_base make sure they get one. This - gets used if someone spawns a VxWorks task directly, not - through ACE. The allocated array will never be deleted! */ - if (0 == taskIdCurrent->ACE_VXWORKS_SPARE) - { - taskIdCurrent->ACE_VXWORKS_SPARE = - ACE_reinterpret_cast (int, new void *[ACE_TSS_THREAD_KEYS_MAX]); - - // Zero the entire TSS array. Do it manually instead of using - // memset, for optimum speed. Though, memset may be faster :-) - void **tss_base_p = - ACE_reinterpret_cast (void **, taskIdCurrent->ACE_VXWORKS_SPARE); - for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) - { - *tss_base_p = 0; - } - } -# endif /* VXWORKS */ - - return tss_base ()[key_index]; -#endif /* defined (ACE_PSOS) */ -} - -#endif /* ACE_HAS_TSS_EMULATION */ - - -ACE_INLINE int -ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data) -{ - // ACE_OS_TRACE ("ACE_OS::thr_getspecific"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_TSS_EMULATION) - ACE_KEY_INDEX (key_index, key); - if (key_index >= ACE_TSS_Emulation::total_keys ()) - { - errno = EINVAL; - data = 0; - return -1; - } - else - { - *data = ACE_TSS_Emulation::ts_object (key); - return 0; - } -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1); -# elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - return ::pthread_getspecific (key, data); -# else /* this is Draft 7 or STD */ - *data = pthread_getspecific (key); - return 0; -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ -# elif defined (ACE_HAS_WTHREADS) - - // The following handling of errno is designed like this due to - // ACE_Log_Msg::instance calling ACE_OS::thr_getspecific. - // Basically, it is ok for a system call to reset the error to zero. - // (It really shouldn't, though). However, we have to remember to - // store errno *immediately* after an error is detected. Calling - // ACE_ERROR_RETURN((..., errno)) did not work because errno was - // cleared before being passed to the thread-specific instance of - // ACE_Log_Msg. The workaround for was to make it so - // thr_getspecific did not have the side effect of clearing errno. - // The correct fix is for ACE_ERROR_RETURN to store errno - //(actually ACE_OS::last_error) before getting the ACE_Log_Msg tss - // pointer, which is how it is implemented now. However, other uses - // of ACE_Log_Msg may not work correctly, so we're keeping this as - // it is for now. - - ACE_Errno_Guard error (errno); - *data = ::TlsGetValue (key); - if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR) - return -1; - else - return 0; -# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) - ACE_hthread_t tid; - ACE_OS::thr_self (tid); - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::tsd_getval (key, tid, data), - ace_result_), - int, -1); -# else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (data); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (data); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -#if !defined (VXWORKS) -ACE_INLINE int -ACE_OS::thr_join (ACE_hthread_t thr_handle, - ACE_THR_FUNC_RETURN *status) -{ - ACE_OS_TRACE ("ACE_OS::thr_join"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), ace_result_), - int, -1); -# elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - int ace_result; -# if defined (ACE_LACKS_NULL_PTHREAD_STATUS) - void *temp; - ACE_OSCALL (::pthread_join (thr_handle, - status == 0 ? &temp : status), - int, -1, ace_result); -# else - ACE_OSCALL (::pthread_join (thr_handle, status), int, -1, ace_result); -# endif /* ACE_LACKS_NULL_PTHREAD_STATUS */ - // Joinable threads need to be detached after joining on Pthreads - // draft 4 (at least) to reclaim thread storage. -# if defined (ACE_HAS_PTHREADS_DRAFT4) -# if defined (HPUX_10) - // HP-UX DCE threads' pthread_detach will smash thr_id if it's just given - // as an argument. Since the id is still needed, give pthread_detach - // a junker to scribble on. - ACE_thread_t junker; - cma_handle_assign(&thr_handle, &junker); - ::pthread_detach (&junker); -# else - ::pthread_detach (&thr_handle); -# endif /* HPUX_10 */ -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ - - return ace_result; - -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_join (thr_handle, status), ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ -# elif defined (ACE_HAS_WTHREADS) - ACE_THR_FUNC_RETURN local_status = 0; - - // Make sure that status is non-NULL. - if (status == 0) - status = &local_status; - - if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0 - && ::GetExitCodeThread (thr_handle, status) != FALSE) - { - ::CloseHandle (thr_handle); - return 0; - } - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ -# elif defined (ACE_PSOS) - ACE_UNUSED_ARG (thr_handle); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -# else - ACE_UNUSED_ARG (thr_handle); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (thr_handle); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_join (ACE_thread_t waiter_id, - ACE_thread_t *thr_id, - ACE_THR_FUNC_RETURN *status) -{ - ACE_OS_TRACE ("ACE_OS::thr_join"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), ace_result_), - int, -1); -# elif defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (thr_id); -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) -# if defined (ACE_LACKS_NULL_PTHREAD_STATUS) - void *temp; - ACE_OSCALL_RETURN (::pthread_join (waiter_id, - status == 0 ? &temp : status), int, -1); -# else - ACE_OSCALL_RETURN (::pthread_join (waiter_id, status), int, -1); -# endif -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_join (waiter_id, status), ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ -# elif defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (waiter_id); - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (status); - - // This could be implemented if the DLL-Main function or the - // task exit base class some log the threads which have exited - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_PSOS) - ACE_UNUSED_ARG (waiter_id); - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (waiter_id); - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (status); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} -#endif /* !VXWORKS */ - -ACE_INLINE int -ACE_OS::thr_setcancelstate (int new_state, int *old_state) -{ - ACE_OS_TRACE ("ACE_OS::thr_setcancelstate"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) -# if defined (ACE_HAS_PTHREADS_DRAFT4) - int old; - old = pthread_setcancel (new_state); - if (old == -1) - return -1; - *old_state = old; - return 0; -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_UNUSED_ARG(old_state); - ACE_OSCALL_RETURN (pthread_setintr (new_state), int, -1); -# else /* this is draft 7 or std */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setcancelstate (new_state, - old_state), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ -# elif defined (ACE_HAS_STHREADS) - ACE_UNUSED_ARG (new_state); - ACE_UNUSED_ARG (old_state); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (new_state); - ACE_UNUSED_ARG (old_state); - ACE_NOTSUP_RETURN (-1); -# else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ - ACE_UNUSED_ARG (new_state); - ACE_UNUSED_ARG (old_state); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PTHREADS */ -#else - ACE_UNUSED_ARG (new_state); - ACE_UNUSED_ARG (old_state); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_setcanceltype (int new_type, int *old_type) -{ - ACE_OS_TRACE ("ACE_OS::thr_setcanceltype"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) -# if defined (ACE_HAS_PTHREADS_DRAFT4) - int old; - old = pthread_setasynccancel(new_type); - if (old == -1) - return -1; - *old_type = old; - return 0; -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_UNUSED_ARG(old_type); - ACE_OSCALL_RETURN (pthread_setintrtype (new_type), int, -1); -# else /* this is draft 7 or std */ - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setcanceltype (new_type, - old_type), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ -# else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ - ACE_UNUSED_ARG (new_type); - ACE_UNUSED_ARG (old_type); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PTHREADS */ -#else - ACE_UNUSED_ARG (new_type); - ACE_UNUSED_ARG (old_type); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_cancel (ACE_thread_t thr_id) -{ - ACE_OS_TRACE ("ACE_OS::thr_cancel"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) - ACE_OSCALL_RETURN (::pthread_cancel (thr_id), int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cancel (thr_id), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ -# else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ - ACE_UNUSED_ARG (thr_id); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PTHREADS */ -#else - ACE_UNUSED_ARG (thr_id); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::sigwait (sigset_t *sset, int *sig) -{ - ACE_OS_TRACE ("ACE_OS::sigwait"); - int local_sig; - if (sig == 0) - sig = &local_sig; -#if defined (ACE_HAS_THREADS) -# if (defined (__FreeBSD__) && (__FreeBSD__ < 3)) || defined (CHORUS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (sset); - ACE_NOTSUP_RETURN (-1); -# elif (defined (ACE_HAS_STHREADS) && !defined (_POSIX_PTHREAD_SEMANTICS)) - *sig = ::sigwait (sset); - return *sig; -# elif defined (ACE_HAS_PTHREADS) - // LynxOS and Digital UNIX have their own hoops to jump through. -# if defined (__Lynx__) - // Second arg is a void **, which we don't need (the selected - // signal number is returned). - *sig = ::sigwait (sset, 0); - return *sig; -# elif defined (DIGITAL_UNIX) && defined (__DECCXX_VER) - // DEC cxx (but not g++) needs this direct call to its internal - // sigwait (). This allows us to #undef sigwait, so that we can - // have ACE_OS::sigwait. cxx gets confused by ACE_OS::sigwait - // if sigwait is _not_ #undef'ed. - errno = ::_Psigwait (sset, sig); - return errno == 0 ? *sig : -1; -# else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */ -# if (defined (ACE_HAS_PTHREADS_DRAFT4) || (defined (ACE_HAS_PTHREADS_DRAFT6)) && !defined(ACE_HAS_FSU_PTHREADS)) || (defined (_UNICOS) && _UNICOS == 9) -# if defined (HPUX_10) - *sig = cma_sigwait (sset); -# else - *sig = ::sigwait (sset); -# endif /* HPUX_10 */ - return *sig; -# elif defined(ACE_HAS_FSU_PTHREADS) - return ::sigwait (sset, sig); -# elif defined(CYGWIN32) - // Cygwin has sigwait definition, but it is not implemented - ACE_UNUSED_ARG (sset); - ACE_NOTSUP_RETURN (-1); -# else /* this is draft 7 or std */ - errno = ::sigwait (sset, sig); - return errno == 0 ? *sig : -1; -# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ -# endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */ -# elif defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (sset); - ACE_NOTSUP_RETURN (-1); -# elif defined (VXWORKS) - // Second arg is a struct siginfo *, which we don't need (the - // selected signal number is returned). Third arg is timeout: 0 - // means forever. - *sig = ::sigtimedwait (sset, 0, 0); - return *sig; -# endif /* __FreeBSD__ */ -#else - ACE_UNUSED_ARG (sset); - ACE_UNUSED_ARG (sig); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::sigtimedwait (const sigset_t *sset, - siginfo_t *info, - const ACE_Time_Value *timeout) -{ - ACE_OS_TRACE ("ACE_OS::sigtimedwait"); -#if defined (ACE_HAS_SIGTIMEDWAIT) - timespec_t ts; - timespec_t *tsp; - - if (timeout != 0) - { - ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). - tsp = &ts; - } - else - tsp = 0; - - ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp), - int, -1); -#else - ACE_UNUSED_ARG (sset); - ACE_UNUSED_ARG (info); - ACE_UNUSED_ARG (timeout); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SIGTIMEDWAIT */ -} - -ACE_INLINE int -ACE_OS::sigwaitinfo (const sigset_t *sset, - siginfo_t *info) -{ - ACE_OS_TRACE ("ACE_OS::sigwaitinfo"); - // If this platform has sigtimedwait, it should have sigwaitinfo as well. - // If this isn't true somewhere, let me know and I'll fix this. - // -Steve Huston <shuston@riverace.com>. -#if defined (ACE_HAS_SIGTIMEDWAIT) - ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1); -#else - ACE_UNUSED_ARG (sset); - ACE_UNUSED_ARG (info); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SIGTIMEDWAIT */ -} - -ACE_INLINE void -ACE_OS::thr_testcancel (void) -{ - ACE_OS_TRACE ("ACE_OS::thr_testcancel"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) -#if defined(ACE_HAS_PTHREADS_DRAFT6) - ::pthread_testintr (); -#else /* ACE_HAS_PTHREADS_DRAFT6 */ - ::pthread_testcancel (); -#endif /* !ACE_HAS_PTHREADS_DRAFT6 */ -# elif defined (ACE_HAS_STHREADS) -# elif defined (ACE_HAS_WTHREADS) -# elif defined (VXWORKS) || defined (ACE_PSOS) -# else - // no-op: can't use ACE_NOTSUP_RETURN because there is no return value -# endif /* ACE_HAS_PTHREADS */ -#else -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_sigsetmask (int how, - const sigset_t *nsm, - sigset_t *osm) -{ - ACE_OS_TRACE ("ACE_OS::thr_sigsetmask"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) - // DCE threads and Solaris 2.4 have no such function. - ACE_UNUSED_ARG (osm); - ACE_UNUSED_ARG (nsm); - ACE_UNUSED_ARG (how); - - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_SIGTHREADMASK) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm), - ace_result_), int, -1); -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm), - ace_result_), - int, -1); -# elif defined (ACE_HAS_PTHREADS) -# if defined (AIX) - ACE_OSCALL_RETURN (sigthreadmask (how, nsm, osm), int, -1); - // Draft 4 and 6 implementations will sometimes have a sigprocmask () that - // modifies the calling thread's mask only. If this is not so for your - // platform, define ACE_LACKS_PTHREAD_THR_SIGSETMASK. -# elif defined(ACE_HAS_PTHREADS_DRAFT4) || \ - defined (ACE_HAS_PTHREADS_DRAFT6) || (defined (_UNICOS) && _UNICOS == 9) - ACE_OSCALL_RETURN (::sigprocmask (how, nsm, osm), int, -1); -# elif !defined (ACE_LACKS_PTHREAD_SIGMASK) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm), - ace_result_), int, -1); -# endif /* AIX */ - -#if 0 - /* Don't know if anyt platform actually needs this... */ - // as far as I can tell, this is now pthread_sigaction() -- jwr - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigaction (how, nsm, osm), - ace_result_), int, -1); -#endif /* 0 */ - -# elif defined (ACE_HAS_WTHREADS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (osm); - ACE_UNUSED_ARG (nsm); - ACE_UNUSED_ARG (how); - - ACE_NOTSUP_RETURN (-1); -# elif defined (VXWORKS) - switch (how) - { - case SIG_BLOCK: - case SIG_UNBLOCK: - { - // get the old mask - *osm = ::sigsetmask (*nsm); - // create a new mask: the following assumes that sigset_t is 4 bytes, - // which it is on VxWorks 5.2, so bit operations are done simply . . . - ::sigsetmask (how == SIG_BLOCK ? (*osm |= *nsm) : (*osm &= ~*nsm)); - break; - } - case SIG_SETMASK: - *osm = ::sigsetmask (*nsm); - break; - default: - return -1; - } - - return 0; -# else /* Should not happen. */ - ACE_UNUSED_ARG (how); - ACE_UNUSED_ARG (nsm); - ACE_UNUSED_ARG (osm); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ -#else - ACE_UNUSED_ARG (how); - ACE_UNUSED_ARG (nsm); - ACE_UNUSED_ARG (osm); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_kill (ACE_thread_t thr_id, int signum) -{ - ACE_OS_TRACE ("ACE_OS::thr_kill"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined(ACE_LACKS_PTHREAD_KILL) - ACE_UNUSED_ARG (signum); - ACE_UNUSED_ARG (thr_id); - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_kill (thr_id, signum), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum), - ace_result_), - int, -1); -# elif defined (ACE_HAS_WTHREADS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (signum); - ACE_UNUSED_ARG (thr_id); - - ACE_NOTSUP_RETURN (-1); -# elif defined (VXWORKS) - ACE_hthread_t tid; - ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid); - - if (tid == ERROR) - return -1; - else - ACE_OSCALL_RETURN (::kill (tid, signum), int, -1); - -# else /* This should not happen! */ - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (signum); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (thr_id); - ACE_UNUSED_ARG (signum); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE size_t -ACE_OS::thr_min_stack (void) -{ - ACE_OS_TRACE ("ACE_OS::thr_min_stack"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) -# if defined (ACE_HAS_THR_MINSTACK) - // Tandem did some weirdo mangling of STHREAD names... - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_minstack (), - ace_result_), - int, -1); -# else - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_min_stack (), - ace_result_), - int, -1); -# endif /* !ACE_HAS_THR_MINSTACK */ -# elif defined (ACE_HAS_PTHREADS) -# if defined (_SC_THREAD_STACK_MIN) - return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN); -# elif defined (PTHREAD_STACK_MIN) - return PTHREAD_STACK_MIN; -# else - ACE_NOTSUP_RETURN (0); -# endif /* _SC_THREAD_STACK_MIN */ -# elif defined (ACE_HAS_WTHREADS) - ACE_NOTSUP_RETURN (0); -# elif defined (ACE_PSOS) - // there does not appear to be a way to get the - // task stack size except at task creation - ACE_NOTSUP_RETURN (0); -# elif defined (VXWORKS) - TASK_DESC taskDesc; - STATUS status; - - ACE_hthread_t tid; - ACE_OS::thr_self (tid); - - ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc), - status), - STATUS, -1, status); - return status == OK ? taskDesc.td_stackSize : 0; -# else /* Should not happen... */ - ACE_NOTSUP_RETURN (0); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_setconcurrency (int hint) -{ - ACE_OS_TRACE ("ACE_OS::thr_setconcurrency"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint), - ace_result_), - int, -1); -# elif defined (ACE_HAS_PTHREADS) - ACE_UNUSED_ARG (hint); - ACE_NOTSUP_RETURN (-1); -# elif defined (ACE_HAS_WTHREADS) - ACE_UNUSED_ARG (hint); - - ACE_NOTSUP_RETURN (-1); -# elif defined (VXWORKS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (hint); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (hint); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_setprio (ACE_hthread_t id, int priority, int policy) -{ - ACE_OS_TRACE ("ACE_OS::thr_setprio"); - ACE_UNUSED_ARG (policy); -#if defined (ACE_HAS_THREADS) -# if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED)) - -# if defined (ACE_HAS_PTHREADS_DRAFT4) - int result; - result = ::pthread_setprio (id, priority); - return (result == -1 ? -1 : 0); -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - pthread_attr_t attr; - if (pthread_getschedattr (id, &attr) == -1) - return -1; - if (pthread_attr_setprio (attr, priority) == -1) - return -1; - return pthread_setschedattr (id, attr); -# else - int result; - struct sched_param param; - memset ((void *) ¶m, 0, sizeof param); - - // If <policy> is -1, we don't want to use it for - // pthread_setschedparam(). Instead, obtain policy from - // pthread_getschedparam(). - if (policy == -1) - { - ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, ¶m), - result), - int, -1, result); - if (result == -1) - return result; - } - - param.sched_priority = priority; - - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (id, policy, ¶m), - ace_result_), - int, -1); -# endif /* ACE_HAS_PTHREADS_DRAFT4 */ -# elif defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (id, priority), - ace_result_), - int, -1); -# elif defined (ACE_HAS_WTHREADS) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (id, priority), - ace_result_), - int, -1); -# elif defined (ACE_PSOS) - u_long oldpriority; - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, priority, &oldpriority), - ace_result_), - int, -1); -# elif defined (VXWORKS) - ACE_OSCALL_RETURN (::taskPrioritySet (id, priority), int, -1); -# else - // For example, platforms that support Pthreads but LACK_SETSCHED. - ACE_UNUSED_ARG (id); - ACE_UNUSED_ARG (priority); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (id); - ACE_UNUSED_ARG (priority); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::thr_suspend (ACE_hthread_t target_thread) -{ - ACE_OS_TRACE ("ACE_OS::thr_suspend"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_STHREADS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), ace_result_), int, -1); -# elif defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREAD_SUSPEND) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread), - ace_result_), - int, -1); -# else - ACE_UNUSED_ARG (target_thread); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PTHREAD_SUSPEND */ -# elif defined (ACE_HAS_WTHREADS) - if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED) - return 0; - else - ACE_FAIL_RETURN (-1); - /* NOTREACHED */ -# elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_suspend (target_thread), ace_result_), int, -1); -# elif defined (VXWORKS) - ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1); -# endif /* ACE_HAS_STHREADS */ -#else - ACE_UNUSED_ARG (target_thread); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE void -ACE_OS::thr_yield (void) -{ - ACE_OS_TRACE ("ACE_OS::thr_yield"); -#if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) -# if defined (ACE_HAS_PTHREADS_STD) - // Note - this is a POSIX.4 function - not a POSIX.1c function... - ::sched_yield (); -# elif defined (ACE_HAS_PTHREADS_DRAFT6) - ::pthread_yield (0); -# else /* Draft 4 and 7 */ - ::pthread_yield (); -# endif /* ACE_HAS_PTHREADS_STD */ -# elif defined (ACE_HAS_STHREADS) - ::thr_yield (); -# elif defined (ACE_HAS_WTHREADS) - ::Sleep (0); -# elif defined (VXWORKS) - // An argument of 0 to ::taskDelay doesn't appear to yield the - // current thread. - // Now, it does seem to work. The context_switch_time test - // works fine with task_delay set to 0. - ::taskDelay (0); -# endif /* ACE_HAS_STHREADS */ -#else - ; -#endif /* ACE_HAS_THREADS */ -} - -ACE_INLINE int -ACE_OS::priority_control (ACE_idtype_t idtype, ACE_id_t id, int cmd, void *arg) -{ - ACE_OS_TRACE ("ACE_OS::priority_control"); -#if defined (ACE_HAS_PRIOCNTL) - ACE_OSCALL_RETURN (priocntl (idtype, id, cmd, ACE_static_cast (caddr_t, arg)), - int, -1); -#else /* ! ACE_HAS_PRIOCNTL*/ - ACE_UNUSED_ARG (idtype); - ACE_UNUSED_ARG (id); - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (arg); - ACE_NOTSUP_RETURN (-1); -#endif /* ! ACE_HAS_PRIOCNTL*/ -} - -ACE_INLINE void -ACE_OS::rewind (FILE *fp) -{ -#if !defined (ACE_HAS_WINCE) - ACE_OS_TRACE ("ACE_OS::rewind"); - ::rewind (fp); -#else - // In WinCE, "FILE *" is actually a HANDLE. - ::SetFilePointer (fp, 0L, 0L, FILE_BEGIN); -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE ssize_t -ACE_OS::readv (ACE_HANDLE handle, - iovec *iov, - int iovlen) -{ - ACE_OS_TRACE ("ACE_OS::readv"); -#if defined (ACE_LACKS_READV) - ACE_OSCALL_RETURN (ACE_OS::readv_emulation (handle, iov, iovlen), - ssize_t, - -1); -#else /* ACE_LACKS_READV */ - ACE_OSCALL_RETURN (::readv (handle, iov, iovlen), ssize_t, -1); -#endif /* ACE_LACKS_READV */ -} - -ACE_INLINE ssize_t -ACE_OS::writev (ACE_HANDLE handle, - const iovec *iov, - int iovcnt) -{ - ACE_OS_TRACE ("ACE_OS::writev"); -#if defined (ACE_LACKS_WRITEV) - ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle, - (ACE_WRITEV_TYPE *) iov, - iovcnt), int, -1); -#else /* ACE_LACKS_WRITEV */ - ACE_OSCALL_RETURN (::writev (handle, - (ACE_WRITEV_TYPE *) iov, - iovcnt), int, -1); -#endif /* ACE_LACKS_WRITEV */ -} - -ACE_INLINE ssize_t -ACE_OS::recvv (ACE_HANDLE handle, - iovec *buffers, - int n) -{ -#if defined (ACE_HAS_WINSOCK2) - - DWORD bytes_received = 0; - int result = 1; - - // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs - // to do the recvs piece-by-piece. - -# if (ACE_HAS_WINSOCK2 != 0) - DWORD flags = 0; - result = ::WSARecv ((SOCKET) handle, - (WSABUF *) buffers, - n, - &bytes_received, - &flags, - 0, - 0); -# else - int i, chunklen; - char *chunkp = 0; - - // Step through the buffers requested by caller; for each one, cycle - // through reads until it's filled or an error occurs. - for (i = 0; i < n && result > 0; i++) - { - chunkp = buffers[i].iov_base; // Point to part of chunk being read - chunklen = buffers[i].iov_len; // Track how much to read to chunk - while (chunklen > 0 && result > 0) - { - result = ::recv ((SOCKET) handle, chunkp, chunklen, 0); - if (result > 0) - { - chunkp += result; - chunklen -= result; - bytes_received += result; - } - } - } -# endif /* ACE_HAS_WINSOCK2 != 0 */ - - if (result == SOCKET_ERROR) - { - ACE_OS::set_errno_to_wsa_last_error (); - return -1; - } - else - return (ssize_t) bytes_received; -#else - return ACE_OS::readv (handle, buffers, n); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE ssize_t -ACE_OS::sendv (ACE_HANDLE handle, - const iovec *buffers, - int n) -{ -#if defined (ACE_HAS_WINSOCK2) - DWORD bytes_sent = 0; - int result = 0; - - // Winsock 2 has WSASend and can do this directly, but Winsock 1 - // needs to do the sends one-by-one. -# if (ACE_HAS_WINSOCK2 != 0) - result = ::WSASend ((SOCKET) handle, - (WSABUF *) buffers, - n, - &bytes_sent, - 0, - 0, - 0); -# else - int i; - for (i = 0; i < n && result != SOCKET_ERROR; i++) - { - result = ::send ((SOCKET) handle, - buffers[i].iov_base, - buffers[i].iov_len, - 0); - // Gets ignored on error anyway - bytes_sent += buffers[i].iov_len; - - // If the transfer isnt complete just drop out of the loop. - if (result < (int)buffers[i].iov_len) - break; - } -# endif /* ACE_HAS_WINSOCK2 != 0 */ - - if (result == SOCKET_ERROR) - { - ACE_OS::set_errno_to_wsa_last_error (); - return -1; - } - else - return (ssize_t) bytes_sent; - -#else - return ACE_OS::writev (handle, buffers, n); -#endif /* ACE_HAS_WINSOCK2 */ -} - -ACE_INLINE int -ACE_OS::poll (struct pollfd *pollfds, u_long len, const ACE_Time_Value *timeout) -{ - ACE_OS_TRACE ("ACE_OS::poll"); -#if defined (ACE_HAS_POLL) - int to = timeout == 0 ? -1 : int (timeout->msec ()); - ACE_OSCALL_RETURN (::poll (pollfds, len, to), int, -1); -#else - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (pollfds); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_POLL */ -} - -ACE_INLINE int -ACE_OS::poll (struct pollfd *pollfds, u_long len, const ACE_Time_Value &timeout) -{ - ACE_OS_TRACE ("ACE_OS::poll"); -#if defined (ACE_HAS_POLL) - ACE_OSCALL_RETURN (::poll (pollfds, len, int (timeout.msec ())), int, -1); -#else - ACE_UNUSED_ARG (timeout); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (pollfds); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_POLL */ -} - -ACE_INLINE char * -ACE_OS::compile (const char *instring, char *expbuf, char *endbuf) -{ - ACE_OS_TRACE ("ACE_OS::compile"); -#if defined (ACE_HAS_REGEX) - ACE_OSCALL_RETURN (::compile (instring, expbuf, endbuf), char *, 0); -#else - ACE_UNUSED_ARG (instring); - ACE_UNUSED_ARG (expbuf); - ACE_UNUSED_ARG (endbuf); - - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_REGEX */ -} - -ACE_INLINE long -ACE_OS::filesize (const ACE_TCHAR *filename) -{ - ACE_OS_TRACE ("ACE_OS::filesize"); - - ACE_HANDLE h = ACE_OS::open (filename, O_RDONLY); - if (h != ACE_INVALID_HANDLE) - { - long size = ACE_OS::filesize (h); - ACE_OS::close (h); - return size; - } - else - return -1; -} - -ACE_INLINE int -ACE_OS::closesocket (ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::closesocket"); -#if defined (ACE_WIN32) - ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1); -#elif defined (ACE_PSOS_DIAB_PPC) - ACE_OSCALL_RETURN (::pna_close (handle), int, -1); -#else - ACE_OSCALL_RETURN (::close (handle), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::access (const char *path, int amode) -{ - ACE_OS_TRACE ("ACE_OS::access"); -#if defined (ACE_LACKS_ACCESS) -# if defined (ACE_HAS_WINCE) - // @@ WINCE: There should be a Win32 API that can do this. - // Hard coded read access here. - FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path), ACE_LIB_TEXT ("r")); - ACE_UNUSED_ARG (amode); - - ACE_OS::fclose (handle); - return (handle == ACE_INVALID_HANDLE ? -1 : 0); -# elif defined (VXWORKS) - FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path), ACE_LIB_TEXT ("r")); - ACE_UNUSED_ARG (amode); - if (handle != 0) - { - ACE_OS::fclose (handle); - return 0; - } - return (-1); -# else - ACE_UNUSED_ARG (path); - ACE_UNUSED_ARG (amode); - ACE_NOTSUP_RETURN (-1); -# endif // ACE_HAS_WINCE -#else - ACE_OSCALL_RETURN (::access (path, amode), int, -1); -#endif /* ACE_LACKS_ACCESS */ -} - - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::access (const wchar_t *path, int amode) -{ -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_OSCALL_RETURN (::_waccess (path, amode), int, -1); -#else /* ACE_WIN32 && !ACE_HAS_WINCE */ - return ACE_OS::access (ACE_Wide_To_Ascii (path).char_rep (), amode); -#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE ACE_HANDLE -ACE_OS::creat (const ACE_TCHAR *filename, mode_t mode) -{ - ACE_OS_TRACE ("ACE_OS::creat"); -#if defined (ACE_WIN32) - return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode); -#elif defined(ACE_PSOS) - ACE_OSCALL_RETURN(::create_f((char *)filename, 1024, - S_IRUSR | S_IWUSR | S_IXUSR), - ACE_HANDLE, ACE_INVALID_HANDLE); -#elif defined(ACE_PSOS_TM) - ACE_UNUSED_ARG (filename); - ACE_UNUSED_ARG (mode); - ACE_NOTSUP_RETURN (-1); -#elif defined(ACE_PSOS) - ACE_UNUSED_ARG (filename); - ACE_UNUSED_ARG (mode); - ACE_NOTSUP_RETURN (-1); -#else - ACE_OSCALL_RETURN (::creat (filename, mode), - ACE_HANDLE, ACE_INVALID_HANDLE); -#endif /* ACE_WIN32 */ -} - -#if !defined (ACE_WIN32) && !defined (VXWORKS) && !defined (CHORUS) && !defined (ACE_PSOS) -// Don't inline on those platforms because this function contains -// string literals, and some compilers, e.g., g++, don't handle those -// efficiently in unused inline functions. -ACE_INLINE int -ACE_OS::uname (ACE_utsname *name) -{ -#if defined (INTEGRITY) - if(!name) { - errno = EFAULT; - return -1; - } - strcpy(name->sysname,"INTEGRITY"); - int status = gethostname(name->nodename,_SYS_NMLN); - strcpy(name->release,"4.0"); - strcpy(name->version,"4.0.9"); - strcpy(name->machine,"a standard name"); - return status; -#else - ACE_OS_TRACE ("ACE_OS::uname"); - ACE_OSCALL_RETURN (::uname (name), int, -1); -#endif -} -#endif /* ! ACE_WIN32 && ! VXWORKS && ! CHORUS */ - -ACE_INLINE int -ACE_OS::hostname (char name[], size_t maxnamelen) -{ - ACE_OS_TRACE ("ACE_OS::hostname"); -#if defined (ACE_HAS_PHARLAP) - // PharLap only can do net stuff with the RT version. -# if defined (ACE_HAS_PHARLAP_RT) - // @@This is not at all reliable... requires ethernet and BOOTP to be used. - // A more reliable way is to go thru the devices w/ EtsTCPGetDeviceCfg until - // a legit IP address is found, then get its name w/ gethostbyaddr. - ACE_SOCKCALL_RETURN (gethostname (name, maxnamelen), int, SOCKET_ERROR); -# else - ACE_UNUSED_ARG (name); - ACE_UNUSED_ARG (maxnamelen); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PHARLAP_RT */ -#elif defined (VXWORKS) || defined (ACE_HAS_WINCE) - ACE_OSCALL_RETURN (::gethostname (name, maxnamelen), int, -1); -#elif defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name, - LPDWORD (&maxnamelen)), - ace_result_), int, -1); -#elif defined (CHORUS) - if (::gethostname (name, maxnamelen) == -1) - return -1; - else - { - if (ACE_OS::strlen (name) == 0) - { - // Try the HOST environment variable. - ACE_TCHAR *const hostenv = ::getenv (ACE_LIB_TEXT ("HOST")); - if (hostenv) - ACE_OS::strsncpy (name, hostenv, maxnamelen); - } - return 0; - } -#else /* ACE_HAS_PHARLAP */ - ACE_utsname host_info; - - if (ACE_OS::uname (&host_info) == -1) - return -1; - else - { - ACE_OS::strsncpy (name, host_info.nodename, maxnamelen); - return 0; - } -#endif /* ACE_HAS_PHARLAP */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS::hostname (wchar_t name[], size_t maxnamelen) -{ -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (GetComputerNameW (name, - LPDWORD (&maxnamelen)), - ace_result_), int, -1); -#else /* ACE_WIN32 && !ACE_HAS_WINCE */ - // Emulate using the char version - char *char_name = 0; - int result = 0; - - ACE_NEW_RETURN (char_name, char[maxnamelen], -1); - - result = ACE_OS::hostname(char_name, maxnamelen); - ACE_OS::strcpy (name, ACE_Ascii_To_Wide (char_name).wchar_rep ()); - - delete [] char_name; - return result; -#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS::msgctl (int msqid, int cmd, struct msqid_ds *val) -{ - ACE_OS_TRACE ("ACE_OS::msgctl"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::msgctl (msqid, cmd, val), int, -1); -#else - ACE_UNUSED_ARG (msqid); - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (val); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::msgget (key_t key, int msgflg) -{ - ACE_OS_TRACE ("ACE_OS::msgget"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::msgget (key, msgflg), int, -1); -#else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (msgflg); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::msgrcv (int int_id, void *buf, size_t len, - long type, int flags) -{ - ACE_OS_TRACE ("ACE_OS::msgrcv"); -#if defined (ACE_HAS_SYSV_IPC) -# if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::msgrcv (int_id, (msgbuf *) buf, len, type, flags), - int, -1); -# else - ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags), - int, -1); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ -#else - ACE_UNUSED_ARG (int_id); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (flags); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::msgsnd (int int_id, const void *buf, size_t len, int flags) -{ - ACE_OS_TRACE ("ACE_OS::msgsnd"); -#if defined (ACE_HAS_SYSV_IPC) -# if defined (ACE_HAS_NONCONST_MSGSND) - ACE_OSCALL_RETURN (::msgsnd (int_id, (void *) buf, len, flags), int, -1); -# elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::msgsnd (int_id, (msgbuf *) buf, len, flags), int, -1); -# else - ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1); -# endif /* ACE_LACKS_POSIX_PROTOTYPES || ACE_HAS_NONCONST_MSGSND */ -#else - ACE_UNUSED_ARG (int_id); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (flags); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE u_int -ACE_OS::alarm (u_int secs) -{ - ACE_OS_TRACE ("ACE_OS::alarm"); -#if defined (ACE_WIN32) || defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (secs); - - ACE_NOTSUP_RETURN (0); -#else - return ::alarm (secs); -#endif /* ACE_WIN32 || VXWORKS || CHORUS || ACE_PSOS */ -} - -ACE_INLINE u_int -ACE_OS::ualarm (u_int usecs, u_int interval) -{ - ACE_OS_TRACE ("ACE_OS::ualarm"); - -#if defined (ACE_HAS_UALARM) - return ::ualarm (usecs, interval); -#elif !defined (ACE_LACKS_UNIX_SIGNALS) - ACE_UNUSED_ARG (interval); - return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS); -#else - ACE_UNUSED_ARG (usecs); - ACE_UNUSED_ARG (interval); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_UALARM */ -} - -ACE_INLINE u_int -ACE_OS::ualarm (const ACE_Time_Value &tv, - const ACE_Time_Value &tv_interval) -{ - ACE_OS_TRACE ("ACE_OS::ualarm"); - -#if defined (ACE_HAS_UALARM) - u_int usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec (); - u_int interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec (); - return ::ualarm (usecs, interval); -#elif !defined (ACE_LACKS_UNIX_SIGNALS) - ACE_UNUSED_ARG (tv_interval); - return ::alarm (tv.sec ()); -#else - ACE_UNUSED_ARG (tv_interval); - ACE_UNUSED_ARG (tv); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_UALARM */ -} - -ACE_INLINE int -ACE_OS::dlclose (ACE_SHLIB_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::dlclose"); -#if defined (ACE_LACKS_DLCLOSE) - ACE_UNUSED_ARG (handle); - return 0; -#elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING) - -# if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) - // SunOS4 does not automatically call _fini()! - void *ptr; - - ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_fini")), void *, 0, ptr); - - if (ptr != 0) - (*((int (*)(void)) ptr)) (); // Call _fini hook explicitly. -# endif /* ACE_HAS_AUTOMATIC_INIT_FINI */ -#if defined (_M_UNIX) - ACE_OSCALL_RETURN (::_dlclose (handle), int, -1); -#else /* _MUNIX */ - ACE_OSCALL_RETURN (::dlclose (handle), int, -1); -#endif /* _M_UNIX */ -#elif defined (ACE_WIN32) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FreeLibrary (handle), ace_result_), int, -1); -#elif defined (__hpux) - // HP-UX 10.x and 32-bit 11.00 do not pay attention to the ref count - // when unloading a dynamic lib. So, if the ref count is more than - // 1, do not unload the lib. This will cause a library loaded more - // than once to not be unloaded until the process runs down, but - // that's life. It's better than unloading a library that's in use. - // So far as I know, there's no way to decrement the refcnt that the - // kernel is looking at - the shl_descriptor is a copy of what the - // kernel has, not the actual struct. On 64-bit HP-UX using dlopen, - // this problem has been fixed. - struct shl_descriptor desc; - if (shl_gethandle_r (handle, &desc) == -1) - return -1; - if (desc.ref_count > 1) - return 0; -# if defined(__GNUC__) || __cplusplus >= 199707L - ACE_OSCALL_RETURN (::shl_unload (handle), int, -1); -# else - ACE_OSCALL_RETURN (::cxxshl_unload (handle), int, -1); -# endif /* aC++ vs. Hp C++ */ -#else - ACE_UNUSED_ARG (handle); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ -} - -ACE_INLINE ACE_TCHAR * -ACE_OS::dlerror (void) -{ - ACE_OS_TRACE ("ACE_OS::dlerror"); -# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) -#if defined(_M_UNIX) - ACE_OSCALL_RETURN ((char *)::_dlerror (), char *, 0); -#else /* _M_UNIX */ - ACE_OSCALL_RETURN ((char *)::dlerror (), char *, 0); -#endif /* _M_UNIX */ -# elif defined (__hpux) || defined (VXWORKS) - ACE_OSCALL_RETURN (::strerror(errno), char *, 0); -# elif defined (ACE_WIN32) - static ACE_TCHAR buf[128]; -# if defined (ACE_HAS_PHARLAP) - ACE_OS::sprintf (buf, "error code %d", GetLastError()); -# else - ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, - 0, - ::GetLastError (), - 0, - buf, - sizeof buf / sizeof buf[0], - 0); -# endif /* ACE_HAS_PHARLAP */ - return buf; -# else - ACE_NOTSUP_RETURN (0); -# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ -} - -ACE_INLINE ACE_SHLIB_HANDLE -ACE_OS::dlopen (const ACE_TCHAR *fname, - int mode) -{ - ACE_OS_TRACE ("ACE_OS::dlopen"); - - // Get the correct OS type. - ACE_DL_TYPE filename = ACE_const_cast (ACE_DL_TYPE, fname); - -# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) - void *handle; -# if defined (ACE_HAS_SGIDLADD) - ACE_OSCALL (::sgidladd (filename, mode), void *, 0, handle); -# elif defined (_M_UNIX) - ACE_OSCALL (::_dlopen (filename, mode), void *, 0, handle); -# else - ACE_OSCALL (::dlopen (filename, mode), void *, 0, handle); -# endif /* ACE_HAS_SGIDLADD */ -# if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) - if (handle != 0) - { - void *ptr; - // Some systems (e.g., SunOS4) do not automatically call _init(), so - // we'll have to call it manually. - - ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_init")), void *, 0, ptr); - - if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly. - { - // Close down the handle to prevent leaks. - ::dlclose (handle); - return 0; - } - } -# endif /* ACE_HAS_AUTOMATIC_INIT_FINI */ - return handle; -# elif defined (ACE_WIN32) - ACE_UNUSED_ARG (mode); - - ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (filename), ACE_SHLIB_HANDLE, 0); -# elif defined (__hpux) - -# if defined(__GNUC__) || __cplusplus >= 199707L - ACE_OSCALL_RETURN (::shl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0); -# else - ACE_OSCALL_RETURN (::cxxshl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0); -# endif /* aC++ vs. Hp C++ */ -# elif defined (VXWORKS) - MODULE* handle; - // Open readonly - ACE_HANDLE filehandle = ACE_OS::open (filename, - O_RDONLY, - ACE_DEFAULT_FILE_PERMS); - - if (filehandle != ACE_INVALID_HANDLE) - { - ACE_OS::last_error(0); - ACE_OSCALL ( ::loadModule (filehandle, mode ), MODULE *, 0, handle); - int loaderror = ACE_OS::last_error(); - ACE_OS::close (filehandle); - - if ( (loaderror != 0) && (handle != 0) ) - { - // ouch something went wrong most likely unresolved externals - ::unldByModuleId ( handle, 0 ); - handle = 0; - } - } - else - { - // couldn't open file - handle = 0; - } - return handle; -# else - ACE_UNUSED_ARG (filename); - ACE_UNUSED_ARG (mode); - ACE_NOTSUP_RETURN (0); -# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ -} - -ACE_INLINE void * -ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, - const ACE_TCHAR *sname) -{ - ACE_OS_TRACE ("ACE_OS::dlsym"); - -#if defined (ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE) - // Check if the handle is valid before making any calls using it. - if (handle == ACE_SHLIB_INVALID_HANDLE) - return 0; -#endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */ - - // Get the correct OS type. -#if defined (ACE_HAS_WINCE) - const wchar_t *symbolname = sname; -#elif defined (ACE_HAS_CHARPTR_DL) - char *symbolname = ACE_const_cast (char *, sname); -#elif !defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) - const char *symbolname = sname; -#endif /* ACE_HAS_CHARPTR_DL */ - -# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) - -# if defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0); -# elif defined (ACE_USES_ASM_SYMBOL_IN_DLSYM) - int l = ACE_OS::strlen (symbolname) + 2; - char *asm_symbolname = 0; - ACE_NEW_RETURN (asm_symbolname, char[l], 0); - ACE_OS::strcpy (asm_symbolname, "_") ; - ACE_OS::strcpy (asm_symbolname + 1, symbolname) ; - void *ace_result; - ACE_OSCALL (::dlsym (handle, asm_symbolname), void *, 0, ace_result); - delete [] asm_symbolname; - return ace_result; -# elif defined (_M_UNIX) - ACE_OSCALL_RETURN (::_dlsym (handle, symbolname), void *, 0); -# else - ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ - -# elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) && !defined (ACE_HAS_WINCE) - - ACE_WIN32CALL_RETURN (::GetProcAddress (handle, ACE_TEXT_ALWAYS_CHAR (sname)), void *, 0); - -# elif defined (ACE_WIN32) - - ACE_WIN32CALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0); - -# elif defined (__hpux) - - void *value; - int status; - shl_t _handle = handle; - ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status); - return status == 0 ? value : 0; - -# elif defined (VXWORKS) - - // For now we use the VxWorks global symbol table - // which resolves the most recently loaded symbols .. which resolve mostly what we want.. - ACE_UNUSED_ARG (handle); - SYM_TYPE symtype; - void *value = 0; - STATUS status; - ACE_OSCALL (::symFindByName(sysSymTbl, symbolname, (char **)&value, &symtype), int, -1, status); - - return status == OK ? value : 0; - -# else - - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (symbolname); - ACE_NOTSUP_RETURN (0); - -# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ -} - -ACE_INLINE int -ACE_OS::step (const char *str, char *expbuf) -{ - ACE_OS_TRACE ("ACE_OS::step"); -#if defined (ACE_HAS_REGEX) - ACE_OSCALL_RETURN (::step (str, expbuf), int, -1); -#else - ACE_UNUSED_ARG (str); - ACE_UNUSED_ARG (expbuf); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_REGEX */ -} - -ACE_INLINE long -ACE_OS::sysinfo (int cmd, char *buf, long count) -{ - ACE_OS_TRACE ("ACE_OS::sysinfo"); -#if defined (ACE_HAS_SYSINFO) - ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1); -#else - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (count); - - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_SYSINFO */ -} - -ACE_INLINE ssize_t -ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte) -{ - ACE_OS_TRACE ("ACE_OS::write"); -#if defined (ACE_WIN32) - DWORD bytes_written; // This is set to 0 byte WriteFile. - - // Strictly correctly, we should loop writing all the data if more - // than a DWORD length can hold. - DWORD short_nbyte = ACE_static_cast (DWORD, nbyte); - if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0)) - return (ssize_t) bytes_written; - else - ACE_FAIL_RETURN (-1); -#elif defined (ACE_PSOS) -# if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (nbyte); - ACE_NOTSUP_RETURN (-1); -# else - if(::write_f (handle, (void *) buf, nbyte) == 0) - return (ssize_t) nbyte; - else - return -1; -# endif /* defined (ACE_PSOS_LACKS_PHILE) */ -#else -# if defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::write (handle, (const char *) buf, nbyte), ssize_t, -1); -# elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (::write_f(handle, (void *) buf, nbyte), ssize_t, -1); -# elif defined (ACE_HAS_CHARPTR_SOCKOPT) - ACE_OSCALL_RETURN (::write (handle, (char *) buf, nbyte), ssize_t, -1); -# else - ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ -#endif /* ACE_WIN32 */ -} - -ACE_INLINE ssize_t -ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte, - ACE_OVERLAPPED *overlapped) -{ - ACE_OS_TRACE ("ACE_OS::write"); - overlapped = overlapped; -#if defined (ACE_WIN32) - DWORD bytes_written; // This is set to 0 byte WriteFile. - - DWORD short_nbyte = ACE_static_cast (DWORD, nbyte); - if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped)) - return (ssize_t) bytes_written; - else - return -1; -#else - return ACE_OS::write (handle, buf, nbyte); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE ssize_t -ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len) -{ - ACE_OS_TRACE ("ACE_OS::read"); -#if defined (ACE_WIN32) - DWORD ok_len; - if (::ReadFile (handle, buf, ACE_static_cast (DWORD, len), &ok_len, 0)) - return (ssize_t) ok_len; - else - ACE_FAIL_RETURN (-1); -#elif defined (ACE_PSOS) -# if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -# else - u_long count; - u_long result = ::read_f (handle, buf, len, &count); - if (result != 0) - return ACE_static_cast (ssize_t, -1); - else - return ACE_static_cast (ssize_t, count == len ? count : 0); -# endif /* defined (ACE_PSOS_LACKS_PHILE */ -#else - - int result; - -# if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_HAS_CHARPTR_SOCKOPT) - ACE_OSCALL (::read (handle, (char *) buf, len), ssize_t, -1, result); -# else - ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ - if (result == -1 && errno == EAGAIN) - errno = EWOULDBLOCK; - return result; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE ssize_t -ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len, - ACE_OVERLAPPED *overlapped) -{ - ACE_OS_TRACE ("ACE_OS::read"); - overlapped = overlapped; -#if defined (ACE_WIN32) - DWORD ok_len; - DWORD short_len = ACE_static_cast (DWORD, len); - if (::ReadFile (handle, buf, short_len, &ok_len, overlapped)) - return (ssize_t) ok_len; - else - ACE_FAIL_RETURN (-1); -#else - return ACE_OS::read (handle, buf, len); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::readlink (const char *path, char *buf, size_t bufsiz) -{ - ACE_OS_TRACE ("ACE_OS::readlink"); -# if defined (ACE_LACKS_READLINK) || \ - defined (ACE_HAS_WINCE) || defined (ACE_WIN32) - ACE_UNUSED_ARG (path); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (bufsiz); - ACE_NOTSUP_RETURN (-1); -# else -# if !defined(ACE_HAS_NONCONST_READLINK) - ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), int, -1); -# else - ACE_OSCALL_RETURN (::readlink ((char *)path, buf, bufsiz), int, -1); -# endif -# endif /* ACE_LACKS_READLINK */ -} - -ACE_INLINE int -ACE_OS::getmsg (ACE_HANDLE handle, - struct strbuf *ctl, - struct strbuf *data, - int *flags) -{ - ACE_OS_TRACE ("ACE_OS::getmsg"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1); -#else - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (ctl); - ACE_UNUSED_ARG (data); - ACE_UNUSED_ARG (flags); - - // I'm not sure how to implement this correctly. - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE int -ACE_OS::getpmsg (ACE_HANDLE handle, - struct strbuf *ctl, - struct strbuf *data, - int *band, - int *flags) -{ - ACE_OS_TRACE ("ACE_OS::getpmsg"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1); -#else - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (ctl); - ACE_UNUSED_ARG (data); - ACE_UNUSED_ARG (band); - ACE_UNUSED_ARG (flags); - - // I'm not sure how to implement this correctly. - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE int -ACE_OS::getrusage (int who, struct rusage *ru) -{ - ACE_OS_TRACE ("ACE_OS::getrusage"); - -#if defined (ACE_HAS_SYSCALL_GETRUSAGE) - // This nonsense is necessary for HP/UX... - ACE_OSCALL_RETURN (::syscall (SYS_GETRUSAGE, who, ru), int, -1); -#elif defined (ACE_HAS_GETRUSAGE) -# if defined (ACE_WIN32) - ACE_UNUSED_ARG (who); - - FILETIME dummy_1; - FILETIME dummy_2; - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetProcessTimes (::GetCurrentProcess(), - &dummy_1, // start - &dummy_2, // exited - &ru->ru_stime, - &ru->ru_utime), - ace_result_), - int, -1); -# else -# if defined (ACE_HAS_RUSAGE_WHO_ENUM) - ACE_OSCALL_RETURN (::getrusage ((ACE_HAS_RUSAGE_WHO_ENUM) who, ru), int, -1); -# else - ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1); -# endif /* ACE_HAS_RUSAGE_WHO_ENUM */ -# endif /* ACE_WIN32 */ -#else - who = who; - ru = ru; - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSCALL_GETRUSAGE */ -} - -ACE_INLINE int -ACE_OS::isastream (ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::isastream"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::isastream (handle), int, -1); -#else - ACE_UNUSED_ARG (handle); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -// Implements simple read/write control for pages. Affects a page if -// part of the page is referenced. Currently PROT_READ, PROT_WRITE, -// and PROT_RDWR has been mapped in OS.h. This needn't have anything -// to do with a mmap region. - -ACE_INLINE int -ACE_OS::mprotect (void *addr, size_t len, int prot) -{ - ACE_OS_TRACE ("ACE_OS::mprotect"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) - DWORD dummy; // Sigh! - return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1; -#elif !defined (ACE_LACKS_MPROTECT) - ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1); -#else - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (prot); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ -} - -ACE_INLINE int -ACE_OS::msync (void *addr, size_t len, int sync) -{ - ACE_OS_TRACE ("ACE_OS::msync"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) - ACE_UNUSED_ARG (sync); - - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1); -#elif !defined (ACE_LACKS_MSYNC) -# if !defined (ACE_HAS_BROKEN_NETBSD_MSYNC) - ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1); -# else - ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len), int, -1); - ACE_UNUSED_ARG (sync); -# endif /* ACE_HAS_BROKEN_NETBSD_MSYNC */ -#else - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (sync); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ -} - -ACE_INLINE int -ACE_OS::munmap (void *addr, size_t len) -{ - ACE_OS_TRACE ("ACE_OS::munmap"); -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (len); - - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1); -#elif !defined (ACE_LACKS_MMAP) - ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1); -#else - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::madvise (caddr_t addr, size_t len, int map_advice) -{ - ACE_OS_TRACE ("ACE_OS::madvise"); -#if defined (ACE_WIN32) - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (map_advice); - - ACE_NOTSUP_RETURN (-1); -#elif !defined (ACE_LACKS_MADVISE) - ACE_OSCALL_RETURN (::madvise (addr, len, map_advice), int, -1); -#else - ACE_UNUSED_ARG (addr); - ACE_UNUSED_ARG (len); - ACE_UNUSED_ARG (map_advice); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl, - const struct strbuf *data, int flags) -{ - ACE_OS_TRACE ("ACE_OS::putmsg"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::putmsg (handle, - (ACE_STRBUF_TYPE) ctl, - (ACE_STRBUF_TYPE) data, - flags), int, -1); -#else - ACE_UNUSED_ARG (flags); - if (ctl == 0 && data == 0) - { - errno = EINVAL; - return 0; - } - // Handle the two easy cases. - else if (ctl != 0) - return ACE_OS::write (handle, ctl->buf, ctl->len); - else if (data != 0) - return ACE_OS::write (handle, data->buf, data->len); - else - { - // This is the hard case. - char *buf; - ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1); - ACE_OS::memcpy (buf, ctl->buf, ctl->len); - ACE_OS::memcpy (buf + ctl->len, data->buf, data->len); - int result = ACE_OS::write (handle, buf, ctl->len + data->len); - delete [] buf; - return result; - } -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE int -ACE_OS::putpmsg (ACE_HANDLE handle, - const struct strbuf *ctl, - const struct strbuf *data, - int band, - int flags) -{ - ACE_OS_TRACE ("ACE_OS::putpmsg"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::putpmsg (handle, - (ACE_STRBUF_TYPE) ctl, - (ACE_STRBUF_TYPE) data, - band, flags), int, -1); -#else - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (band); - return ACE_OS::putmsg (handle, ctl, data, flags); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE int -ACE_OS::semctl (int int_id, int semnum, int cmd, semun value) -{ - ACE_OS_TRACE ("ACE_OS::semctl"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1); -#else - ACE_UNUSED_ARG (int_id); - ACE_UNUSED_ARG (semnum); - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (value); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::semget (key_t key, int nsems, int flags) -{ - ACE_OS_TRACE ("ACE_OS::semget"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1); -#else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (nsems); - ACE_UNUSED_ARG (flags); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::semop (int int_id, struct sembuf *sops, size_t nsops) -{ - ACE_OS_TRACE ("ACE_OS::semop"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1); -#else - ACE_UNUSED_ARG (int_id); - ACE_UNUSED_ARG (sops); - ACE_UNUSED_ARG (nsops); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE void * -ACE_OS::shmat (int int_id, void *shmaddr, int shmflg) -{ - ACE_OS_TRACE ("ACE_OS::shmat"); -#if defined (ACE_HAS_SYSV_IPC) -# if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::shmat (int_id, (char *)shmaddr, shmflg), void *, (void *) -1); -# else - ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ -#else - ACE_UNUSED_ARG (int_id); - ACE_UNUSED_ARG (shmaddr); - ACE_UNUSED_ARG (shmflg); - - ACE_NOTSUP_RETURN ((void *) -1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::shmctl (int int_id, int cmd, struct shmid_ds *buf) -{ - ACE_OS_TRACE ("ACE_OS::shmctl"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1); -#else - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (cmd); - ACE_UNUSED_ARG (int_id); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::shmdt (void *shmaddr) -{ - ACE_OS_TRACE ("ACE_OS::shmdt"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::shmdt ((char *) shmaddr), int, -1); -#else - ACE_UNUSED_ARG (shmaddr); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE int -ACE_OS::shmget (key_t key, int size, int flags) -{ - ACE_OS_TRACE ("ACE_OS::shmget"); -#if defined (ACE_HAS_SYSV_IPC) - ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1); -#else - ACE_UNUSED_ARG (flags); - ACE_UNUSED_ARG (size); - ACE_UNUSED_ARG (key); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SYSV_IPC */ -} - -ACE_INLINE void -ACE_OS::tzset (void) -{ -#if !defined (ACE_HAS_WINCE) && !defined (VXWORKS) && !defined (ACE_PSOS) && ! defined(__rtems__) -# if defined (ACE_WIN32) - ::_tzset (); // For Win32. -# else - ::tzset (); // For UNIX platforms. -# endif /* ACE_WIN32 */ -# else - errno = ENOTSUP; -# endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS && !__rtems__ */ -} - -ACE_INLINE long -ACE_OS::timezone (void) -{ - return ::ace_timezone (); -} - -#if !defined (ACE_LACKS_DIFFTIME) -ACE_INLINE double -ACE_OS::difftime (time_t t1, time_t t0) -{ - return ::ace_difftime (t1, t0); -} -#endif /* ! ACE_LACKS_DIFFTIME */ - -// Magic number declaration and definition for ctime and ctime_r () -static const int ctime_buf_size = 26; - -ACE_INLINE ACE_TCHAR * -ACE_OS::ctime (const time_t *t) -{ - ACE_OS_TRACE ("ACE_OS::ctime"); -#if defined (ACE_HAS_BROKEN_CTIME) - ACE_OSCALL_RETURN (::asctime (::localtime (t)), char *, 0); -#elif defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) - return "ctime-return"; -#elif defined (ACE_HAS_WINCE) - static ACE_TCHAR buf [ctime_buf_size]; - return ACE_OS::ctime_r (t, - buf, - ctime_buf_size); -#elif defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0); -#else - ACE_OSCALL_RETURN (::ctime (t), char *, 0); -# endif /* ACE_HAS_BROKEN_CTIME */ -} - -#if !defined (ACE_HAS_WINCE) /* CE version in OS.cpp */ -ACE_INLINE ACE_TCHAR * -ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen) -{ - ACE_OS_TRACE ("ACE_OS::ctime_r"); - -#if defined (ACE_HAS_REENTRANT_FUNCTIONS) -# if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) - if (buflen < ctime_buf_size) - { - errno = ERANGE; - return 0; - } -# if defined (DIGITAL_UNIX) - ACE_OSCALL_RETURN (::_Pctime_r (t, buf), ACE_TCHAR *, 0); -# else /* DIGITAL_UNIX */ - ACE_OSCALL_RETURN (::ctime_r (t, buf), ACE_TCHAR *, 0); -# endif /* DIGITAL_UNIX */ - return buf; -# else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ - -# if defined (ACE_CTIME_R_RETURNS_INT) - return (::ctime_r (t, buf, buflen) == -1 ? 0 : buf); -# else /* ACE_CTIME_R_RETURNS_INT */ - ACE_OSCALL_RETURN (::ctime_r (t, buf, buflen), ACE_TCHAR *, 0); -# endif /* ACE_CTIME_R_RETURNS_INT */ - -# endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ -#else /* ACE_HAS_REENTRANT_FUNCTIONS */ -# if defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) - ACE_OS::strsncpy (buf, "ctime-return", buflen); - return buf; -# else /* ACE_PSOS && !ACE_PSOS_HAS_TIME */ - if (buflen < ctime_buf_size) - { - errno = ERANGE; - return 0; - } - - ACE_TCHAR *result; -# if defined (ACE_USES_WCHAR) - ACE_OSCALL (::_wctime (t), wchar_t *, 0, result); -# else /* ACE_USES_WCHAR */ - ACE_OSCALL (::ctime (t), char *, 0, result); -# endif /* ACE_USES_WCHAR */ - if (result != 0) - ACE_OS::strsncpy (buf, result, buflen); - return buf; -# endif /* ACE_PSOS && !ACE_PSOS_HAS_TIME */ -#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -} -#endif /* !ACE_HAS_WINCE */ - -ACE_INLINE struct tm * -ACE_OS::localtime (const time_t *t) -{ -#if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - ACE_OS_TRACE ("ACE_OS::localtime"); - ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0); -#else - // @@ Don't you start wondering what kind of functions - // does WinCE really support? - ACE_UNUSED_ARG (t); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ -} - -ACE_INLINE struct tm * -ACE_OS::gmtime (const time_t *t) -{ -#if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - ACE_OS_TRACE ("ACE_OS::gmtime"); - ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0); -#else - // @@ WinCE doesn't have gmtime also. - ACE_UNUSED_ARG (t); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ -} - -ACE_INLINE struct tm * -ACE_OS::gmtime_r (const time_t *t, struct tm *res) -{ - ACE_OS_TRACE ("ACE_OS::gmtime_r"); -#if defined (ACE_HAS_REENTRANT_FUNCTIONS) -# if defined (DIGITAL_UNIX) - ACE_OSCALL_RETURN (::_Pgmtime_r (t, res), struct tm *, 0); -# elif defined (HPUX_10) - return (::gmtime_r (t, res) == 0 ? res : (struct tm *) 0); -# else - ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0); -# endif /* DIGITAL_UNIX */ -#elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - struct tm *result; - ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ; - if (result != 0) - *res = *result; - return res; -#else - // @@ Same as ACE_OS::gmtime (), you need to implement it - // yourself. - ACE_UNUSED_ARG (t); - ACE_UNUSED_ARG (res); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -} - -ACE_INLINE char * -ACE_OS::asctime (const struct tm *t) -{ -#if !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - ACE_OS_TRACE ("ACE_OS::asctime"); - ACE_OSCALL_RETURN (::asctime (t), char *, 0); -#else - // @@ WinCE doesn't have gmtime also. - ACE_UNUSED_ARG (t); - ACE_NOTSUP_RETURN (0); -#endif /* !ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ -} - -ACE_INLINE char * -ACE_OS::asctime_r (const struct tm *t, char *buf, int buflen) -{ - ACE_OS_TRACE ("ACE_OS::asctime_r"); -#if defined (ACE_HAS_REENTRANT_FUNCTIONS) -# if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) - char *result; -# if defined (DIGITAL_UNIX) - ACE_OSCALL (::_Pasctime_r (t, buf), char *, 0, result); -# else - ACE_OSCALL (::asctime_r (t, buf), char *, 0, result); -# endif /* DIGITAL_UNIX */ - ACE_OS::strsncpy (buf, result, buflen); - return buf; -# else -# if defined (HPUX_10) - return (::asctime_r(t, buf, buflen) == 0 ? buf : (char *)0); -# else - ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0); -# endif /* HPUX_10 */ -# endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ -#elif ! defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - char *result; - ACE_OSCALL (::asctime (t), char *, 0, result); - ACE_OS::strsncpy (buf, result, buflen); - return buf; -#else - // @@ Same as ACE_OS::asctime (), you need to implement it - // yourself. - ACE_UNUSED_ARG (t); - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (buflen); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -} - -ACE_INLINE size_t -ACE_OS::strftime (char *s, size_t maxsize, const char *format, - const struct tm *timeptr) -{ -#if !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) - return ::strftime (s, maxsize, format, timeptr); -#else - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (maxsize); - ACE_UNUSED_ARG (format); - ACE_UNUSED_ARG (timeptr); - ACE_NOTSUP_RETURN (0); -#endif /* !ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ -} - -ACE_INLINE int -ACE_OS::flock_init (ACE_OS::ace_flock_t *lock, - int flags, - const ACE_TCHAR *name, - mode_t perms) -{ - ACE_OS_TRACE ("ACE_OS::flock_init"); -#if defined (CHORUS) - lock->lockname_ = 0; - // Let's see if it already exists. - lock->handle_ = ACE_OS::shm_open (name, - flags | O_CREAT | O_EXCL, - perms); - if (lock->handle_ == ACE_INVALID_HANDLE) - { - if (errno == EEXIST) - // It's already there, so we'll just open it. - lock->handle_ = ACE_OS::shm_open (name, - flags | O_CREAT, - ACE_DEFAULT_FILE_PERMS); - else - return -1; - } - else - { - // We own this shared memory object! Let's set its size. - if (ACE_OS::ftruncate (lock->handle_, - sizeof (ACE_mutex_t)) == -1) - return -1; - // Note that only the owner can destroy a file lock... - ACE_ALLOCATOR_RETURN (lock->lockname_, - ACE_OS::strdup (name), - -1); - } - if (lock->handle_ == ACE_INVALID_HANDLE) - return -1; - - lock->process_lock_ = - (ACE_mutex_t *) ACE_OS::mmap (0, - sizeof (ACE_mutex_t), - PROT_RDWR, - MAP_SHARED, - lock->handle_, - 0); - if (lock->process_lock_ == MAP_FAILED) - return -1; - - if (lock->lockname_ - // Only initialize it if we're the one who created it. - && ACE_OS::mutex_init (lock->process_lock_, - USYNC_PROCESS, - name, - 0) != 0) - return -1; - return 0; -#else -#if defined (ACE_WIN32) - // Once initialized, these values are never changed. - lock->overlapped_.Internal = 0; - lock->overlapped_.InternalHigh = 0; - lock->overlapped_.OffsetHigh = 0; - lock->overlapped_.hEvent = 0; -#endif /* ACE_WIN32 */ - lock->handle_ = ACE_INVALID_HANDLE; - lock->lockname_ = 0; - - if (name != 0) - { - ACE_OSCALL (ACE_OS::open (name, flags, perms), - ACE_HANDLE, - ACE_INVALID_HANDLE, - lock->handle_); - lock->lockname_ = ACE_OS::strdup (name); - return lock->handle_ == ACE_INVALID_HANDLE ? -1 : 0; - } - else - return 0; -#endif /* CHORUS */ -} - -#if defined (ACE_WIN32) -ACE_INLINE void -ACE_OS::adjust_flock_params (ACE_OS::ace_flock_t *lock, - short whence, - off_t &start, - off_t &len) -{ - switch (whence) - { - case SEEK_SET: - break; - case SEEK_CUR: - start += SetFilePointer (lock->handle_, 0, 0, FILE_CURRENT); - break; - case SEEK_END: - start += ::GetFileSize (lock->handle_, 0); - break; - } - lock->overlapped_.Offset = start; - if (len == 0) - len = ::GetFileSize (lock->handle_, - 0) - start; -} -#endif /* ACE_WIN32 */ - -ACE_INLINE int -ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock, - short whence, - off_t start, - off_t len) -{ - ACE_OS_TRACE ("ACE_OS::flock_wrlock"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_OS::adjust_flock_params (lock, whence, start, len); -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, - LOCKFILE_EXCLUSIVE_LOCK, - 0, - len, - 0, - &lock->overlapped_), - ace_result_), int, -1); -# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_, - lock->overlapped_.Offset, - 0, - len, - 0), - ace_result_), int, -1); -# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ -#elif defined (CHORUS) - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - return ACE_OS::mutex_lock (lock->process_lock_); -#elif defined (ACE_LACKS_FILELOCKS) - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -#else - lock->lock_.l_whence = whence; - lock->lock_.l_start = start; - lock->lock_.l_len = len; - lock->lock_.l_type = F_WRLCK; // set write lock - // block, if no access - ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW, - ACE_reinterpret_cast (long, &lock->lock_)), - int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::flock_rdlock (ACE_OS::ace_flock_t *lock, - short whence, - off_t start, - off_t len) -{ - ACE_OS_TRACE ("ACE_OS::flock_rdlock"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_OS::adjust_flock_params (lock, whence, start, len); -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, - 0, - 0, - len, - 0, - &lock->overlapped_), - ace_result_), int, -1); -# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_, - lock->overlapped_.Offset, - 0, - len, - 0), - ace_result_), int, -1); -# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ -#elif defined (CHORUS) - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - return ACE_OS::mutex_lock (lock->process_lock_); -#elif defined (ACE_LACKS_FILELOCKS) - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -#else - lock->lock_.l_whence = whence; - lock->lock_.l_start = start; - lock->lock_.l_len = len; - lock->lock_.l_type = F_RDLCK; // set read lock - // block, if no access - ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW, - ACE_reinterpret_cast (long, &lock->lock_)), - int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::flock_trywrlock (ACE_OS::ace_flock_t *lock, - short whence, - off_t start, - off_t len) -{ - ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) - ACE_OS::adjust_flock_params (lock, whence, start, len); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, - LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, - 0, - len, - 0, - &lock->overlapped_), - ace_result_), int, -1); -# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ -#elif defined (CHORUS) - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - return ACE_OS::mutex_trylock (lock->process_lock_); -#elif defined (ACE_LACKS_FILELOCKS) - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -#else - lock->lock_.l_whence = whence; - lock->lock_.l_start = start; - lock->lock_.l_len = len; - lock->lock_.l_type = F_WRLCK; // set write lock - - int result = 0; - // Does not block, if no access, returns -1 and set errno = EBUSY; - ACE_OSCALL (ACE_OS::fcntl (lock->handle_, - F_SETLK, - ACE_reinterpret_cast (long, &lock->lock_)), - int, -1, result); - -# if ! defined (ACE_PSOS) - if (result == -1 && (errno == EACCES || errno == EAGAIN)) - errno = EBUSY; -# endif /* ! defined (ACE_PSOS) */ - - return result; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::flock_tryrdlock (ACE_OS::ace_flock_t *lock, - short whence, - off_t start, - off_t len) -{ - ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) -# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) - ACE_OS::adjust_flock_params (lock, whence, start, len); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, - LOCKFILE_FAIL_IMMEDIATELY, - 0, - len, - 0, - &lock->overlapped_), - ace_result_), int, -1); -# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ -#elif defined (CHORUS) - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - return ACE_OS::mutex_trylock (lock->process_lock_); -#elif defined (ACE_LACKS_FILELOCKS) - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -#else - lock->lock_.l_whence = whence; - lock->lock_.l_start = start; - lock->lock_.l_len = len; - lock->lock_.l_type = F_RDLCK; // set read lock - - int result = 0; - // Does not block, if no access, returns -1 and set errno = EBUSY; - ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK, - ACE_reinterpret_cast (long, &lock->lock_)), - int, -1, result); - -# if ! defined (ACE_PSOS) - if (result == -1 && (errno == EACCES || errno == EAGAIN)) - errno = EBUSY; -# endif /* ! defined (ACE_PSOS) */ - - return result; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::flock_unlock (ACE_OS::ace_flock_t *lock, - short whence, - off_t start, - off_t len) -{ - ACE_OS_TRACE ("ACE_OS::flock_unlock"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_OS::adjust_flock_params (lock, whence, start, len); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnlockFile (lock->handle_, - lock->overlapped_.Offset, - 0, - len, - 0), - ace_result_), int, -1); -#elif defined (CHORUS) - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - return ACE_OS::mutex_unlock (lock->process_lock_); -#elif defined (ACE_LACKS_FILELOCKS) - ACE_UNUSED_ARG (lock); - ACE_UNUSED_ARG (whence); - ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (len); - ACE_NOTSUP_RETURN (-1); -#else - lock->lock_.l_whence = whence; - lock->lock_.l_start = start; - lock->lock_.l_len = len; - lock->lock_.l_type = F_UNLCK; // Unlock file. - - // release lock - ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLK, - ACE_reinterpret_cast (long, &lock->lock_)), - int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::flock_destroy (ACE_OS::ace_flock_t *lock, - int unlink_file) -{ - ACE_OS_TRACE ("ACE_OS::flock_destroy"); - if (lock->handle_ != ACE_INVALID_HANDLE) - { - ACE_OS::flock_unlock (lock); - // Close the handle. - ACE_OS::close (lock->handle_); - lock->handle_ = ACE_INVALID_HANDLE; -#if defined (CHORUS) - // Are we the owner? - if (lock->process_lock_ && lock->lockname_ != 0) - { - // Only destroy the lock if we're the owner - ACE_OS::mutex_destroy (lock->process_lock_); - ACE_OS::munmap (lock->process_lock_, - sizeof (ACE_mutex_t)); - if (unlink_file) - ACE_OS::shm_unlink (lock->lockname_); - ACE_OS::free (ACE_static_cast (void *, - ACE_const_cast (ACE_TCHAR *, - lock->lockname_))); - } - else if (lock->process_lock_) - // Just unmap the memory. - ACE_OS::munmap (lock->process_lock_, - sizeof (ACE_mutex_t)); -#else - if (lock->lockname_ != 0) - { - if (unlink_file) - ACE_OS::unlink (lock->lockname_); - ACE_OS::free (ACE_static_cast (void *, - ACE_const_cast (ACE_TCHAR *, - lock->lockname_))); - } -#endif /* CHORUS */ - lock->lockname_ = 0; - } - return 0; -} - -ACE_INLINE int -ACE_OS::execv (const char *path, - char *const argv[]) -{ - ACE_OS_TRACE ("ACE_OS::execv"); -#if defined (ACE_LACKS_EXEC) - ACE_UNUSED_ARG (path); - ACE_UNUSED_ARG (argv); - - ACE_NOTSUP_RETURN (-1); -#elif defined (CHORUS) - KnCap cactorcap; - int result = ::afexecv (path, &cactorcap, 0, argv); - if (result != -1) - ACE_OS::actorcaps_[result] = cactorcap; - return result; -#elif defined (ACE_WIN32) -# if defined (__BORLANDC__) /* VSB */ - return ::execv (path, argv); -# elif defined (__MINGW32__) - return ::_execv (path, (char *const *) argv); -# else - return ::_execv (path, (const char *const *) argv); -# endif /* __BORLANDC__ */ -#elif defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::execv (path, (const char **) argv), int, -1); -#else - ACE_OSCALL_RETURN (::execv (path, argv), int, -1); -#endif /* ACE_LACKS_EXEC */ -} - -ACE_INLINE int -ACE_OS::execve (const char *path, - char *const argv[], - char *const envp[]) -{ - ACE_OS_TRACE ("ACE_OS::execve"); -#if defined (ACE_LACKS_EXEC) - ACE_UNUSED_ARG (path); - ACE_UNUSED_ARG (argv); - ACE_UNUSED_ARG (envp); - - ACE_NOTSUP_RETURN (-1); -#elif defined(CHORUS) - KnCap cactorcap; - int result = ::afexecve (path, &cactorcap, 0, argv, envp); - if (result != -1) - ACE_OS::actorcaps_[result] = cactorcap; - return result; -#elif defined (ACE_WIN32) -# if defined (__BORLANDC__) /* VSB */ - return ::execve (path, argv, envp); -# elif defined (__MINGW32__) - return ::_execve (path, (char *const *) argv, (char *const *) envp); -# else - return ::_execve (path, (const char *const *) argv, (const char *const *) envp); -# endif /* __BORLANDC__ */ -#elif defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::execve (path, (const char **) argv, (char **) envp), int, -1); -#else - ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); -#endif /* ACE_LACKS_EXEC */ -} - -ACE_INLINE int -ACE_OS::execvp (const char *file, - char *const argv[]) -{ - ACE_OS_TRACE ("ACE_OS::execvp"); -#if defined (ACE_LACKS_EXEC) - ACE_UNUSED_ARG (file); - ACE_UNUSED_ARG (argv); - - ACE_NOTSUP_RETURN (-1); -#elif defined(CHORUS) - KnCap cactorcap; - int result = ::afexecvp (file, &cactorcap, 0, argv); - if (result != -1) - ACE_OS::actorcaps_[result] = cactorcap; - return result; -#elif defined (ACE_WIN32) -# if defined (__BORLANDC__) /* VSB */ - return ::execvp (file, argv); -# elif defined (__MINGW32__) - return ::_execvp (file, (char *const *) argv); -# else - return ::_execvp (file, (const char *const *) argv); -# endif /* __BORLANDC__ */ -#elif defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::execvp (file, (const char **) argv), int, -1); -#else - ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); -#endif /* ACE_LACKS_EXEC */ -} - -ACE_INLINE FILE * -ACE_OS::fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode) -{ - ACE_OS_TRACE ("ACE_OS::fdopen"); -# if defined (ACE_HAS_WINCE) - ACE_OSCALL_RETURN (::_wfdopen (handle, mode), FILE*, 0); -# elif defined (ACE_WIN32) - // kernel file handle -> FILE* conversion... - // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost - - FILE *file = 0; - -# if defined (ACE_WIN64) - int crt_handle = ::_open_osfhandle (intptr_t (handle), 0); -# else - int crt_handle = ::_open_osfhandle (long (handle), 0); -# endif /* ACE_WIN64 */ - - if (crt_handle != -1) - { -# if defined(__BORLANDC__) /* VSB */ - file = ::_fdopen (crt_handle, (char *) mode); -# elif defined (ACE_USES_WCHAR) - file = ::_wfdopen (crt_handle, mode); -# else - file = ::_fdopen (crt_handle, mode); -# endif /* __BORLANDC__ */ - - if (!file) - { -# if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) - ::_rtl_close (crt_handle); -# else - ::_close (crt_handle); -# endif /* (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) */ - } - } - - return file; -# elif defined (ACE_PSOS) - // @@ it may be possible to implement this for pSOS, - // but it isn't obvious how to do this (perhaps via - // f_stat to glean the default volume, and then open_fn ?) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (mode); - ACE_NOTSUP_RETURN (0); -# else - ACE_OSCALL_RETURN (::fdopen (handle, mode), FILE *, 0); -# endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_OS::getrlimit (int resource, struct rlimit *rl) -{ - ACE_OS_TRACE ("ACE_OS::getrlimit"); - -#if defined (ACE_LACKS_RLIMIT) - ACE_UNUSED_ARG (resource); - ACE_UNUSED_ARG (rl); - - ACE_NOTSUP_RETURN (-1); -#else -# if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM) - ACE_OSCALL_RETURN (::getrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1); -# else - ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1); -# endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ -#endif /* ACE_LACKS_RLIMIT */ -} - -ACE_INLINE int -ACE_OS::setrlimit (int resource, ACE_SETRLIMIT_TYPE *rl) -{ - ACE_OS_TRACE ("ACE_OS::setrlimit"); - -#if defined (ACE_LACKS_RLIMIT) - ACE_UNUSED_ARG (resource); - ACE_UNUSED_ARG (rl); - - ACE_NOTSUP_RETURN (-1); -#else -# if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM) - ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1); -# else - ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1); -# endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ -#endif /* ACE_LACKS_RLIMIT */ -} - -ACE_INLINE int -ACE_OS::socketpair (int domain, int type, - int protocol, ACE_HANDLE sv[2]) -{ - ACE_OS_TRACE ("ACE_OS::socketpair"); -#if defined (ACE_WIN32) || defined (ACE_LACKS_SOCKETPAIR) - ACE_UNUSED_ARG (domain); - ACE_UNUSED_ARG (type); - ACE_UNUSED_ARG (protocol); - ACE_UNUSED_ARG (sv); - - ACE_NOTSUP_RETURN (-1); -#else - ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv), - int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE ACE_HANDLE -ACE_OS::dup (ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::dup"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_HANDLE new_fd; - if (::DuplicateHandle(::GetCurrentProcess (), - handle, - ::GetCurrentProcess(), - &new_fd, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) - return new_fd; - else - ACE_FAIL_RETURN (ACE_INVALID_HANDLE); - /* NOTREACHED */ -#elif defined (VXWORKS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (handle); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (handle); - ACE_NOTSUP_RETURN (0); -#else - ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE); -#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_OS::dup2 (ACE_HANDLE oldhandle, ACE_HANDLE newhandle) -{ - ACE_OS_TRACE ("ACE_OS::dup2"); -#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS) - // msvcrt has _dup2 ?! - ACE_UNUSED_ARG (oldhandle); - ACE_UNUSED_ARG (newhandle); - - ACE_NOTSUP_RETURN (-1); -#else - ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1); -#endif /* ACE_WIN32 || VXWORKS || ACE_PSOS */ -} - -#if defined (ghs) && defined (ACE_HAS_PENTIUM) && !defined (ACE_WIN32) - extern "C" ACE_hrtime_t ACE_gethrtime (); -#endif /* ghs && ACE_HAS_PENTIUM */ - -ACE_INLINE ACE_hrtime_t -ACE_OS::gethrtime (const ACE_HRTimer_Op op) -{ - ACE_OS_TRACE ("ACE_OS::gethrtime"); -#if defined (ACE_HAS_HI_RES_TIMER) - ACE_UNUSED_ARG (op); - return ::gethrtime (); -#elif defined (ACE_HAS_AIX_HI_RES_TIMER) - ACE_UNUSED_ARG (op); - timebasestruct_t tb; - - ::read_real_time(&tb, TIMEBASE_SZ); - ::time_base_to_time(&tb, TIMEBASE_SZ); - - return ACE_hrtime_t(tb.tb_high) * ACE_ONE_SECOND_IN_NSECS + tb.tb_low; -#elif defined (ghs) && defined (ACE_HAS_PENTIUM) && !defined (ACE_WIN32) - ACE_UNUSED_ARG (op); - // Use .obj/gethrtime.o, which was compiled with g++. - return ACE_gethrtime (); -#elif (defined(__KCC) || defined (__GNUG__)) && !defined (__MINGW32__) && defined (ACE_HAS_PENTIUM) - ACE_UNUSED_ARG (op); - -# if defined (ACE_LACKS_LONGLONG_T) - double now; -# else /* ! ACE_LACKS_LONGLONG_T */ - ACE_hrtime_t now; -# endif /* ! ACE_LACKS_LONGLONG_T */ - - // See comments about the RDTSC Pentium instruction for the ACE_WIN32 - // version of ACE_OS::gethrtime (), below. - // - // Read the high-res tick counter directly into memory variable "now". - // The A constraint signifies a 64-bit int. - asm volatile ("rdtsc" : "=A" (now) : : "memory"); - -# if defined (ACE_LACKS_LONGLONG_T) - ACE_UINT32 least, most; - ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32)); - ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32), - sizeof (ACE_UINT32)); - - ACE_hrtime_t ret (least, most); - return ret; -# else /* ! ACE_LACKS_LONGLONG_T */ - return now; -# endif /* ! ACE_LACKS_LONGLONG_T */ -#elif defined (linux) && defined (ACE_HAS_ALPHA_TIMER) - // NOTE: alphas only have a 32 bit tick (cycle) counter. The rpcc - // instruction actually reads 64 bits, but the high 32 bits are - // implementation-specific. Linux and Digital Unix, for example, - // use them for virtual tick counts, i.e., taking into account only - // the time that the process was running. This information is from - // David Mosberger's article, see comment below. - ACE_UINT32 now; - - // The following statement is based on code published by: - // Mosberger, David, "How to Make Your Applications Fly, Part 1", - // Linux Journal Issue 42, October 1997, page 50. It reads the - // high-res tick counter directly into the memory variable. - asm volatile ("rpcc %0" : "=r" (now) : : "memory"); - - return now; -#elif defined (ACE_WIN32) - ACE_UNUSED_ARG(op); - LARGE_INTEGER freq; - - ::QueryPerformanceCounter (&freq); - -# if defined (ACE_LACKS_LONGLONG_T) - ACE_UINT64 uint64_freq(freq.u.LowPart, ACE_static_cast (unsigned int, freq.u.HighPart)); - return uint64_freq; -# else - return freq.QuadPart; -# endif //ACE_LACKS_LONGLONG_T - -#elif defined (CHORUS) - if (op == ACE_OS::ACE_HRTIMER_GETTIME) - { - struct timespec ts; - - ACE_OS::clock_gettime (CLOCK_REALTIME, &ts); - - // Carefully create the return value to avoid arithmetic overflow - // if ACE_hrtime_t is ACE_U_LongLong. - ACE_hrtime_t now = ts.tv_sec; - now *= ACE_U_ONE_SECOND_IN_NSECS; - now += ts.tv_nsec; - - return now; - } - else - { - // Use the sysBench timer on Chorus. On MVME177, at least, it only - // has 32 bits. Be careful, because using it disables interrupts! - ACE_UINT32 now; - if (::sysBench (op, (int *) &now) == K_OK) - { - now *= 1000u /* nanoseconds/microsecond */; - return (ACE_hrtime_t) now; - } - else - { - // Something went wrong. Just return 0. - return (ACE_hrtime_t) 0; - } - } - -#elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__)) - // PowerPC w/ GreenHills or g++. - - ACE_UNUSED_ARG (op); - u_long most; - u_long least; - ACE_OS::readPPCTimeBase (most, least); -#if defined (ACE_LACKS_LONGLONG_T) - return ACE_U_LongLong (least, most); -#else /* ! ACE_LACKS_LONGLONG_T */ - return 0x100000000llu * most + least; -#endif /* ! ACE_LACKS_LONGLONG_T */ - -#elif defined (ACE_HAS_CLOCK_GETTIME) || defined (ACE_PSOS) - // e.g., VxWorks (besides POWERPC && GreenHills) . . . - ACE_UNUSED_ARG (op); - struct timespec ts; - - ACE_OS::clock_gettime (CLOCK_REALTIME, &ts); - - // Carefully create the return value to avoid arithmetic overflow - // if ACE_hrtime_t is ACE_U_LongLong. - return ACE_static_cast (ACE_hrtime_t, ts.tv_sec) * - ACE_U_ONE_SECOND_IN_NSECS + ACE_static_cast (ACE_hrtime_t, ts.tv_nsec); -#else - ACE_UNUSED_ARG (op); - const ACE_Time_Value now = ACE_OS::gettimeofday (); - - // Carefully create the return value to avoid arithmetic overflow - // if ACE_hrtime_t is ACE_U_LongLong. - return (ACE_static_cast (ACE_hrtime_t, now.sec ()) * (ACE_UINT32) 1000000 + - ACE_static_cast (ACE_hrtime_t, now.usec ())) * (ACE_UINT32) 1000; -#endif /* ACE_HAS_HI_RES_TIMER */ -} - -ACE_INLINE int -ACE_OS::fdetach (const char *file) -{ - ACE_OS_TRACE ("ACE_OS::fdetach"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::fdetach (file), int, -1); -#else - ACE_UNUSED_ARG (file); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE int -ACE_OS::fattach (int handle, const char *path) -{ - ACE_OS_TRACE ("ACE_OS::fattach"); -#if defined (ACE_HAS_STREAM_PIPES) - ACE_OSCALL_RETURN (::fattach (handle, path), int, -1); -#else - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (path); - - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_STREAM_PIPES */ -} - -ACE_INLINE pid_t -ACE_OS::fork (void) -{ - ACE_OS_TRACE ("ACE_OS::fork"); -#if defined (ACE_LACKS_FORK) - ACE_NOTSUP_RETURN (pid_t (-1)); -#else - ACE_OSCALL_RETURN (::fork (), pid_t, -1); -#endif /* ACE_LACKS_FORK */ -} - -ACE_INLINE int -ACE_OS::getpagesize (void) -{ - ACE_OS_TRACE ("ACE_OS::getpagesize"); -#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) - SYSTEM_INFO sys_info; - ::GetSystemInfo (&sys_info); - return (int) sys_info.dwPageSize; -#elif defined (_SC_PAGESIZE) - return (int) ::sysconf (_SC_PAGESIZE); -#elif defined (ACE_HAS_GETPAGESIZE) - return ::getpagesize (); -#else - // Use the default set in config.h - return ACE_PAGE_SIZE; -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::allocation_granularity (void) -{ -#if defined (ACE_WIN32) - SYSTEM_INFO sys_info; - ::GetSystemInfo (&sys_info); - return (int) sys_info.dwAllocationGranularity; -#else - return ACE_OS::getpagesize (); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE pid_t -ACE_OS::getpid (void) -{ - // ACE_OS_TRACE ("ACE_OS::getpid"); -#if defined (ACE_WIN32) - return ::GetCurrentProcessId (); -#elif defined (VXWORKS) || defined (ACE_PSOS) - // getpid() is not supported: just one process anyways - return 0; -#elif defined (CHORUS) - return (pid_t) (::agetId ()); -#else - ACE_OSCALL_RETURN (::getpid (), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE pid_t -ACE_OS::getpgid (pid_t pid) -{ - ACE_OS_TRACE ("ACE_OS::getpgid"); -#if defined (ACE_LACKS_GETPGID) - ACE_UNUSED_ARG (pid); - ACE_NOTSUP_RETURN (-1); -#elif defined (VXWORKS) || defined (ACE_PSOS) - // getpgid() is not supported, only one process anyway. - ACE_UNUSED_ARG (pid); - return 0; -#elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0 - // getpgid() is from SVR4, which appears to be the reason why GLIBC - // doesn't enable its prototype by default. - // Rather than create our own extern prototype, just use the one - // that is visible (ugh). - ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1); -#else - ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE pid_t -ACE_OS::getppid (void) -{ - ACE_OS_TRACE ("ACE_OS::getppid"); -#if defined (ACE_LACKS_GETPPID) - ACE_NOTSUP_RETURN (-1); -#elif defined (VXWORKS) || defined (ACE_PSOS) - // getppid() is not supported, only one process anyway. - return 0; -#else - ACE_OSCALL_RETURN (::getppid (), pid_t, -1); -#endif /* ACE_LACKS_GETPPID */ -} - -ACE_INLINE int -ACE_OS::setpgid (pid_t pid, pid_t pgid) -{ - ACE_OS_TRACE ("ACE_OS::setpgid"); -#if defined (ACE_LACKS_SETPGID) - ACE_UNUSED_ARG (pid); - ACE_UNUSED_ARG (pgid); - ACE_NOTSUP_RETURN (-1); -#elif defined (VXWORKS) || defined (ACE_PSOS) - // <setpgid> is not supported, only one process anyway. - ACE_UNUSED_ARG (pid); - ACE_UNUSED_ARG (pgid); - return 0; -#else - ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1); -#endif /* ACE_LACKS_SETPGID */ -} - -ACE_INLINE int -ACE_OS::setreuid (uid_t ruid, uid_t euid) -{ - ACE_OS_TRACE ("ACE_OS::setreuid"); -#if defined (ACE_LACKS_SETREUID) - ACE_UNUSED_ARG (ruid); - ACE_UNUSED_ARG (euid); - ACE_NOTSUP_RETURN (-1); -#elif defined (VXWORKS) || defined (ACE_PSOS) - // <setpgid> is not supported, only one process anyway. - ACE_UNUSED_ARG (ruid); - ACE_UNUSED_ARG (euid); - return 0; -#else - ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::setregid (gid_t rgid, gid_t egid) -{ - ACE_OS_TRACE ("ACE_OS::setregid"); -#if defined (ACE_LACKS_SETREGID) - ACE_UNUSED_ARG (rgid); - ACE_UNUSED_ARG (egid); - ACE_NOTSUP_RETURN (-1); -#elif defined (VXWORKS) || defined (ACE_PSOS) - // <setregid> is not supported, only one process anyway. - ACE_UNUSED_ARG (rgid); - ACE_UNUSED_ARG (egid); - return 0; -#else - ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE off_t -ACE_OS::lseek (ACE_HANDLE handle, off_t offset, int whence) -{ - ACE_OS_TRACE ("ACE_OS::lseek"); -#if defined (ACE_WIN32) -# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END - //#error Windows NT is evil AND rude! - switch (whence) - { - case SEEK_SET: - whence = FILE_BEGIN; - break; - case SEEK_CUR: - whence = FILE_CURRENT; - break; - case SEEK_END: - whence = FILE_END; - break; - default: - errno = EINVAL; - return ACE_static_cast (off_t, -1); // rather safe than sorry - } -# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ - DWORD result = ::SetFilePointer (handle, offset, 0, whence); - if (result == ACE_SYSCALL_FAILED) - ACE_FAIL_RETURN (ACE_static_cast (off_t, -1)); - else - return result; -#elif defined (ACE_PSOS) -# if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (handle); - ACE_UNUSED_ARG (offset); - ACE_UNUSED_ARG (whence); - ACE_NOTSUP_RETURN (ACE_static_cast (off_t, -1)); -# else - unsigned long oldptr, newptr, result; - // seek to the requested position - result = ::lseek_f (handle, whence, offset, &oldptr); - if (result != 0) - { - errno = result; - return ACE_static_cast (off_t, -1); - } - // now do a dummy seek to the current position to obtain the position - result = ::lseek_f (handle, SEEK_CUR, 0, &newptr); - if (result != 0) - { - errno = result; - return ACE_static_cast (off_t, -1); - } - return ACE_static_cast (off_t, newptr); -# endif /* defined (ACE_PSOS_LACKS_PHILE */ -#else - ACE_OSCALL_RETURN (::lseek (handle, offset, whence), off_t, -1); -#endif /* ACE_WIN32 */ -} - -#if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64) -ACE_INLINE ACE_LOFF_T -ACE_OS::llseek (ACE_HANDLE handle, ACE_LOFF_T offset, int whence) -{ - ACE_OS_TRACE ("ACE_OS::llseek"); - -#if ACE_SIZEOF_LONG == 8 - /* The native lseek is 64 bit. Use it. */ - return ACE_OS::lseek (handle, offset, whence); -#elif defined (ACE_HAS_LLSEEK) && defined (ACE_HAS_LSEEK64) -# error Either ACE_HAS_LSEEK64 and ACE_HAS_LLSEEK should be defined, not both! -#elif defined (ACE_HAS_LSEEK64) - ACE_OSCALL_RETURN (::lseek64 (handle, offset, whence), ACE_LOFF_T, -1); -#elif defined (ACE_HAS_LLSEEK) - # if defined (ACE_WIN32) - LARGE_INTEGER li; - li.QuadPart = offset; - li.LowPart = ::SetFilePointer (handle, li.LowPart, &li.HighPart, whence); - if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) - li.QuadPart = -1; - return li.QuadPart; - # else - ACE_OSCALL_RETURN (::llseek (handle, offset, whence), ACE_LOFF_T, -1); - # endif /* WIN32 */ -#endif -} -#endif /* ACE_HAS_LLSEEK || ACE_HAS_LSEEK64 */ - -ACE_INLINE int -ACE_OS::fseek (FILE *fp, long offset, int whence) -{ -# if defined (ACE_WIN32) -# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END - //#error Windows NT is evil AND rude! - switch (whence) - { - case SEEK_SET: - whence = FILE_BEGIN; - break; - case SEEK_CUR: - whence = FILE_CURRENT; - break; - case SEEK_END: - whence = FILE_END; - break; - default: - errno = EINVAL; - return -1; // rather safe than sorry - } -# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ -# endif /* ACE_WIN32 */ - ACE_OSCALL_RETURN (::fseek (fp, offset, whence), int, -1); -} - -ACE_INLINE long -ACE_OS::ftell (FILE* fp) -{ - ACE_OSCALL_RETURN (::ftell (fp), long, -1); -} - -ACE_INLINE int -ACE_OS::fgetpos (FILE* fp, fpos_t* pos) -{ - ACE_OSCALL_RETURN (::fgetpos (fp, pos), int, -1); -} - -ACE_INLINE int -ACE_OS::fsetpos (FILE* fp, fpos_t* pos) -{ - ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1); -} - -ACE_INLINE int -ACE_OS::fgetc (FILE* fp) -{ - ACE_OSCALL_RETURN (::fgetc (fp), int, -1); -} - -#if !defined (ACE_LACKS_CLEARERR) -ACE_INLINE void -ACE_OS::clearerr (FILE* fp) -{ -#if defined (__ace_clearerr_hack) - __ace_clearerr(fp); -#else - ::clearerr(fp); -#endif /* __ace_clearerr_hack */ -} -#endif /* !ACE_LACKS_CLEARERR */ - -#if defined (ACE_HAS_WCHAR) - -ACE_INLINE wint_t -ACE_OS::fgetwc (FILE* fp) -{ -#if defined (ACE_LACKS_FGETWC) - ACE_UNUSED_ARG (fp); - ACE_NOTSUP_RETURN (0); -#else - ACE_OSCALL_RETURN (::fgetwc (fp), wint_t, WEOF); -#endif /* ACE_LACKS_FGETWC */ -} - -ACE_INLINE wint_t -ACE_OS::ungetwc (wint_t c, FILE* fp) -{ -#if defined (ACE_LACKS_FGETWC) - ACE_UNUSED_ARG (c); - ACE_UNUSED_ARG (fp); - ACE_NOTSUP_RETURN (0); -#else - ACE_OSCALL_RETURN (::ungetwc (c, fp), wint_t, WEOF); -#endif /* ACE_LACKS_FGETWC */ -} - -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE pid_t -ACE_OS::waitpid (pid_t pid, - ACE_exitcode *status, - int wait_options, - ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::waitpid"); -#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_UNUSED_ARG (pid); - ACE_UNUSED_ARG (status); - ACE_UNUSED_ARG (wait_options); - ACE_UNUSED_ARG (handle); - - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_WIN32) - int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG) - ? 0 /* don't hang */ - : INFINITE; - - ACE_HANDLE phandle = handle; - - if (phandle == 0) - { - phandle = ::OpenProcess (SYNCHRONIZE, - FALSE, - pid); - - if (phandle == 0) - { - ACE_OS::set_errno_to_last_error (); - return -1; - } - } - - pid_t result = pid; - - // Don't try to get the process exit status if wait failed so we can - // keep the original error code intact. - switch (::WaitForSingleObject (phandle, - blocking_period)) - { - case WAIT_OBJECT_0: - if (status != 0) - // The error status of <GetExitCodeProcess> is nonetheless - // not tested because we don't know how to return the value. - ::GetExitCodeProcess (phandle, - status); - break; - case WAIT_TIMEOUT: - errno = ETIME; - result = 0; - break; - default: - ACE_OS::set_errno_to_last_error (); - result = -1; - } - if (handle == 0) - ::CloseHandle (phandle); - return result; -#elif defined (CHORUS) - ACE_UNUSED_ARG (status); - ACE_UNUSED_ARG (wait_options); - ACE_UNUSED_ARG (handle); - ACE_OSCALL_RETURN (::await (&ACE_OS::actorcaps_[pid]), - pid_t, -1); -#else - ACE_UNUSED_ARG (handle); - ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options), - pid_t, -1); -#endif /* VXWORKS || ACE_PSOS */ -} - -ACE_INLINE pid_t -ACE_OS::wait (pid_t pid, - ACE_exitcode *status, - int wait_options, - ACE_HANDLE handle) -{ - ACE_OS_TRACE ("ACE_OS::wait"); - return ACE_OS::waitpid (pid, - status, - wait_options, - handle); -} - -ACE_INLINE pid_t -ACE_OS::wait (int *status) -{ - ACE_OS_TRACE ("ACE_OS::wait"); -#if defined (ACE_WIN32) || defined (VXWORKS) || defined(CHORUS) || defined (ACE_PSOS) || defined (INTEGRITY) - ACE_UNUSED_ARG (status); - - ACE_NOTSUP_RETURN (0); -#else -# if defined (ACE_HAS_UNION_WAIT) - ACE_OSCALL_RETURN (::wait ((union wait *) status), pid_t, -1); -# else - ACE_OSCALL_RETURN (::wait (status), pid_t, -1); -# endif /* ACE_HAS_UNION_WAIT */ -#endif /* ACE_WIN32 || VXWORKS || CHORUS || ACE_PSOS */ -} - -ACE_INLINE int -ACE_OS::ioctl (ACE_HANDLE handle, - int cmd, - void *val) -{ - ACE_OS_TRACE ("ACE_OS::ioctl"); - -#if defined (ACE_WIN32) - ACE_SOCKET sock = (ACE_SOCKET) handle; - ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, (u_long *) val), int, -1); -#elif defined (VXWORKS) - ACE_OSCALL_RETURN (::ioctl (handle, cmd, ACE_reinterpret_cast (int, val)), - int, -1); -#elif defined (ACE_PSOS) - ACE_OSCALL_RETURN (::ioctl (handle, cmd, (char *) val), int, -1); -#else - ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::kill (pid_t pid, int signum) -{ - ACE_OS_TRACE ("ACE_OS::kill"); -#if defined (ACE_WIN32) || defined (CHORUS) || defined (ACE_PSOS) - ACE_UNUSED_ARG (pid); - ACE_UNUSED_ARG (signum); - ACE_NOTSUP_RETURN (-1); -#else - ACE_OSCALL_RETURN (::kill (pid, signum), int, -1); -#endif /* ACE_WIN32 || CHORUS || ACE_PSOS */ -} - -ACE_INLINE int -ACE_OS::sigaction (int signum, - const struct sigaction *nsa, - struct sigaction *osa) -{ - ACE_OS_TRACE ("ACE_OS::sigaction"); - if (signum == 0) - return 0; -#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) - struct sigaction sa; - - if (osa == 0) - osa = &sa; - - if (nsa == 0) - { - osa->sa_handler = ::signal (signum, SIG_IGN); - ::signal (signum, osa->sa_handler); - } - else - osa->sa_handler = ::signal (signum, nsa->sa_handler); - return osa->sa_handler == SIG_ERR ? -1 : 0; -#elif defined (CHORUS) || defined (ACE_HAS_WINCE) || defined(ACE_PSOS) - ACE_UNUSED_ARG (signum); - ACE_UNUSED_ARG (nsa); - ACE_UNUSED_ARG (osa); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::sigaction (signum, (struct sigaction*) nsa, osa), int, -1); -#else - ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1); -#endif /* ACE_WIN32 !ACE_HAS_WINCE */ -} - -ACE_INLINE ACE_TCHAR * -ACE_OS::getcwd (ACE_TCHAR *buf, size_t size) -{ - ACE_OS_TRACE ("ACE_OS::getcwd"); -#if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (size); - ACE_NOTSUP_RETURN ( (char*)-1); -#elif defined (ACE_PSOS) - - static char pathbuf [BUFSIZ]; - - // blank the path buffer - ACE_OS::memset (pathbuf, '\0', BUFSIZ); - - // the following was suggested in the documentation for get_fn () - u_long result; - char cur_dir_name [BUFSIZ] = "."; - - u_long cur_dir = 0, prev_dir = 0; - while ((ACE_OS::strlen (pathbuf) < BUFSIZ) && - (ACE_OS::strlen (cur_dir_name) < BUFSIZ - ACE_OS::strlen ("/.."))) - { - // get the current directory handle - result = ::get_fn (cur_dir_name, &cur_dir); - - // check whether we're at the root: this test is - // really lame, but the get_fn documentation says - // *either* condition indicates you're trying to - // move above the root. - if ((result != 0) || ( cur_dir == prev_dir)) - { - break; - } - - // change name to the parent directory - ACE_OS::strcat (cur_dir_name, "/.."); - - // open the parent directory - XDIR xdir; - result = ::open_dir (cur_dir_name, &xdir); - if (result != 0) - { - return 0; - } - - // look for an entry that matches the current directory handle - struct dirent dir_entry; - while (1) - { - // get the next directory entry - result = ::read_dir (&xdir, &dir_entry); - if (result != 0) - { - return 0; - } - - // check for a match - if (dir_entry.d_filno == cur_dir) - { - // prefix the previous path with the entry's name and break - if (ACE_OS::strlen (pathbuf) + ACE_OS::strlen (dir_entry.d_name) < BUFSIZ) - { - ACE_OS::strcpy (pathbuf + ACE_OS::strlen (dir_entry.d_name), pathbuf); - ACE_OS::strcpy (pathbuf, dir_entry.d_name); - break; - } - else - { - // we're out of room in the buffer - return 0; - } - } - } - - // close the parent directory - result = ::close_dir (&xdir); - if (result != 0) - { - return 0; - } - - // save the current directory handle as the previous - prev_dir = cur_dir; - } - - // return the path, if there is one - return (ACE_OS::strlen (pathbuf) > 0) ? pathbuf : (char *) 0; -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (buf); - ACE_UNUSED_ARG (size); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - return ::_wgetcwd (buf, ACE_static_cast (int, size)); -# else - return ::getcwd (buf, ACE_static_cast (int, size)); -# endif /* ACE_USES_WCHAR */ -#else - ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0); -#endif /* ACE_PSOS_LACKS_PHILE */ -} - -ACE_INLINE int -ACE_OS::sleep (u_int seconds) -{ - ACE_OS_TRACE ("ACE_OS::sleep"); -#if defined (ACE_WIN32) - ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS); - return 0; -#if 0 -#elif defined (HPUX_10) && defined (ACE_HAS_PTHREADS_DRAFT4) - // On HP-UX 10, _CMA_NOWRAPPERS_ disables the mapping from sleep to cma_sleep - // which makes sleep() put the whole process to sleep, and keeps it from - // noticing pending cancels. So, in this case, use pthread_delay_np - struct timespec rqtp; - rqtp.tv_sec = seconds; - rqtp.tv_nsec = 0L; - return pthread_delay_np (&rqtp); -#endif /* 0 */ -#elif defined (ACE_HAS_CLOCK_GETTIME) - struct timespec rqtp; - // Initializer doesn't work with Green Hills 1.8.7 - rqtp.tv_sec = seconds; - rqtp.tv_nsec = 0L; - ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1); -#elif defined (ACE_PSOS) - timeval wait; - wait.tv_sec = seconds; - wait.tv_usec = 0; - ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &wait), int, -1); -#else - ACE_OSCALL_RETURN (::sleep (seconds), int, -1); -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::sleep (const ACE_Time_Value &tv) -{ - ACE_OS_TRACE ("ACE_OS::sleep"); -#if defined (ACE_WIN32) - ::Sleep (tv.msec ()); - return 0; -#else -# if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) - // Copy the timeval, because this platform doesn't declare the timeval - // as a pointer to const. - timeval tv_copy = tv; - ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1); -# else /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */ - const timeval *tvp = tv; - ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1); -# endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ -#endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::nanosleep (const struct timespec *requested, - struct timespec *remaining) -{ - ACE_OS_TRACE ("ACE_OS::nanosleep"); -#if defined (ACE_HAS_CLOCK_GETTIME) - // ::nanosleep () is POSIX 1003.1b. So is ::clock_gettime (). So, - // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should - // be available on the platform. On Solaris 2.x, both functions - // require linking with -lposix4. - return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining); -#elif defined (ACE_PSOS) -# if ! defined (ACE_PSOS_DIAB_MIPS) - double ticks = KC_TICKS2SEC * requested->tv_sec + - ( ACE_static_cast (double, requested->tv_nsec) * - ACE_static_cast (double, KC_TICKS2SEC) ) / - ACE_static_cast (double, ACE_ONE_SECOND_IN_NSECS); - - if (ticks > ACE_static_cast (double, ACE_PSOS_Time_t::max_ticks)) - { - ticks -= ACE_static_cast (double, ACE_PSOS_Time_t::max_ticks); - remaining->tv_sec = ACE_static_cast (time_t, - (ticks / - ACE_static_cast (double, - KC_TICKS2SEC))); - ticks -= ACE_static_cast (double, remaining->tv_sec) * - ACE_static_cast (double, KC_TICKS2SEC); - - remaining->tv_nsec = - ACE_static_cast (long, - (ticks * ACE_static_cast (double, - ACE_ONE_SECOND_IN_NSECS)) / - ACE_static_cast (double, KC_TICKS2SEC)); - - ::tm_wkafter (ACE_PSOS_Time_t::max_ticks); - } - else - { - remaining->tv_sec = 0; - remaining->tv_nsec = 0; - ::tm_wkafter (ACE_static_cast (u_long, ticks)); - } - - // tm_wkafter always returns 0 -# endif /* ACE_PSOS_DIAB_MIPS */ - return 0; -#else - ACE_UNUSED_ARG (remaining); - - // Convert into seconds and microseconds. -# if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS) - ACE_Time_Value tv (requested->tv_sec, - requested->tv_nsec / 1000); -# else - ACE_Time_Value tv (requested->ts_sec, - requested->ts_nsec / 1000); -# endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */ - return ACE_OS::sleep (tv); -#endif /* ACE_HAS_CLOCK_GETTIME */ -} - -ACE_INLINE int -ACE_OS::mkdir (const ACE_TCHAR *path, mode_t mode) -{ -#if defined (ACE_PSOS_LACKS_PHILE) - ACE_UNUSED_ARG (path); - ACE_UNUSED_ARG (mode); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_PSOS) - //The pSOS make_dir fails if the last character is a '/' - int location; - char *phile_path; - - phile_path = (char *)ACE_OS::malloc(strlen(path)); - if (phile_path == 0) - { - ACE_OS::printf ("malloc in make_dir failed: [%X]\n", - errno); - return -1; - } - else - ACE_OS::strcpy (phile_path, path); - - location = ACE_OS::strlen(phile_path); - if(phile_path[location-1] == '/') - { - phile_path[location-1] = 0; - } - - u_long result; - result = ::make_dir ((char *) phile_path, mode); - if (result == 0x2011) // Directory already exists - { - result = 0; - } - else if (result != 0) - { - result = -1; - } - - ACE_OS::free(phile_path); - return result; - -#elif defined (VXWORKS) - ACE_UNUSED_ARG (mode); - ACE_OSCALL_RETURN (::mkdir ((char *) path), int, -1); -#elif defined (ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) - ACE_UNUSED_ARG (mode); - ACE_OSCALL_RETURN (::_mkdir ((char *) path), int, -1); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (mode); - ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (path, 0), - ace_result_), - int, -1); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_UNUSED_ARG (mode); - ACE_OSCALL_RETURN (::_wmkdir (path), int, -1); -#elif defined (ACE_WIN32) - ACE_UNUSED_ARG (mode); - ACE_OSCALL_RETURN (::mkdir (path), int, -1); -#else - ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1); -#endif /* ACE_PSOS_LACKS_PHILE */ -} - -ACE_INLINE char * -ACE_OS::getenv (const char *symbol) -{ - ACE_OS_TRACE ("ACE_OS::getenv"); -#if defined (ACE_LACKS_ENV) - ACE_UNUSED_ARG (symbol); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_PSOS) - ACE_UNUSED_ARG (symbol); - ACE_NOTSUP_RETURN (0); -#else /* ACE_PSOS */ - ACE_OSCALL_RETURN (::getenv (symbol), char *, 0); -#endif /* ACE_LACKS_ENV */ -} - -#if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32) -ACE_INLINE wchar_t * -ACE_OS::getenv (const wchar_t *symbol) -{ -#if defined (ACE_LACKS_ENV) - ACE_UNUSED_ARG (symbol); - ACE_NOTSUP_RETURN (0); -#else - ACE_OSCALL_RETURN (::_wgetenv (symbol), wchar_t *, 0); -#endif /* ACE_LACKS_ENV */ -} -#endif /* ACE_HAS_WCHAR && ACE_WIN32 */ - -#if defined(INTEGRITY) -extern "C" { - int putenv(char *string); -} -#endif - -ACE_INLINE int -ACE_OS::putenv (const ACE_TCHAR *string) -{ - ACE_OS_TRACE ("ACE_OS::putenv"); -#if defined (ACE_HAS_WINCE) || defined (ACE_PSOS) - // WinCE and pSOS don't have the concept of environment variables. - ACE_UNUSED_ARG (string); - ACE_NOTSUP_RETURN (-1); -#elif defined (ACE_LACKS_ENV) - ACE_UNUSED_ARG (string); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::_wputenv (string), int, -1); -#else /* ! ACE_HAS_WINCE && ! ACE_PSOS */ - // VxWorks declares ::putenv with a non-const arg. - ACE_OSCALL_RETURN (::putenv ((char *) string), int, -1); -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE -ACE_Str_Buf::ACE_Str_Buf (void *b, int l, int max) -{ - this->maxlen = max; - this->len = l; - this->buf = (char *) b; -} - -ACE_INLINE -ACE_Str_Buf::ACE_Str_Buf (strbuf &sb) -{ - this->maxlen = sb.maxlen; - this->len = sb.len; - this->buf = sb.buf; -} - -ACE_INLINE u_int -ACE_OS::wslen (const WChar *s) -{ - u_int len = 0; - - while (*s++ != 0) - len++; - - return len; -} - -ACE_INLINE ACE_OS::WChar * -ACE_OS::wscpy (WChar *dest, const WChar *src) -{ - WChar *original_dest = dest; - - while ((*dest++ = *src++) != 0) - continue; - - return original_dest; -} - -ACE_INLINE int -ACE_OS::wscmp (const WChar *s, const WChar *t) -{ - const WChar *scan1 = s; - const WChar *scan2 = t; - - while (*scan1 != 0 && *scan1 == *scan2) - { - ++scan1; - ++scan2; - } - - return *scan1 - *scan2; -} - -ACE_INLINE int -ACE_OS::wsncmp (const WChar *s, const WChar *t, size_t len) -{ - const WChar *scan1 = s; - const WChar *scan2 = t; - - while (len != 0 && *scan1 != 0 && *scan1 == *scan2) - { - ++scan1; - ++scan2; - --len; - } - - return len == 0 ? 0 : *scan1 - *scan2; -} - -#if defined (ACE_LACKS_COND_T) && defined (ACE_HAS_THREADS) -ACE_INLINE long -ACE_cond_t::waiters (void) const -{ - return this->waiters_; -} -#endif /* ACE_LACKS_COND_T && ACE_HAS_THREADS */ - -#if 0 -ACE_INLINE int -ACE_OS::thr_continue (const ACE_Thread_ID &thr_id) -{ - ACE_OS_TRACE ("ACE_OS::thr_continue"); - return ACE_OS::thr_continue (thr_id.id ()); -} - -ACE_INLINE int -ACE_OS::thr_create (ACE_THR_FUNC func, - void *args, - long flags, - ACE_Thread_ID *thr_id, - long priority, - void *stack, - size_t stacksize); -{ - ACE_OS_TRACE ("ACE_OS::thr_create"); - ACE_thread_t thread_id; - ACE_hthread_t thread_handle; - - int result = ACE_OS::thr_create (func, args, flags, - &thread_id, &thread_handle, - priority, stack, stacksize); - if (result == -1) - return -1; - else if (thr_id != 0) - { - thr_id->id (thread_id); - thr_id->handle (thread_handle); - return result; - } -} - -ACE_INLINE int -ACE_OS::thr_getprio (const ACE_Thread_ID &thr_id, int &prio) -{ - ACE_OS_TRACE ("ACE_OS::thr_getprio"); - return ACE_OS::thr_getprio (thr_id.handle (), prio); -} - -ACE_INLINE int -ACE_OS::thr_join (const ACE_Thread_ID &thr_id, ACE_THR_FUNC_RETURN *status) -{ -# if defined (ACE_WIN32) - return ACE_OS::thr_join (thr_id.handle (), status); -# else - return ACE_OS::thr_join (thr_id.id (), status); -# endif /* ACE_WIN32 */ -} - -ACE_INLINE int -ACE_OS::thr_cancel (const ACE_Thread_ID &thr_id) -{ - return ACE_OS::thr_cancel (thr_id.id ()); -} - -ACE_INLINE int -ACE_OS::thr_kill (const ACE_Thread_ID &thr_id, int signum) -{ - return ACE_OS::thr_kill (thr_id.id (), signum); -} - -ACE_INLINE ACE_Thread_ID -ACE_OS::thr_self (void) -{ - ACE_hthread_t thr_handle; - ACE_OS::thr_self (thr_handle); - ACE_thread_t thr_id = ACE_OS::thr_self (); - - return ACE_Thread_ID (thr_id, thr_handle); -} - -ACE_INLINE int -ACE_OS::thr_setprio (const ACE_Thread_ID &thr_id, int prio) -{ - ACE_OS_TRACE ("ACE_OS::thr_setprio"); - return ACE_OS::thr_setprio (thr_id.handle (), prio); -} - -ACE_INLINE int -ACE_OS::thr_suspend (const ACE_Thread_ID &thr_id) -{ - return ACE_OS::thr_suspend (thr_id.handle ()); -} - -#endif /* 0 */ - -ACE_INLINE int -ACE_OS::sigaddset (sigset_t *s, int signum) -{ - ACE_OS_TRACE ("ACE_OS::sigaddset"); -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) - if (s == 0) - { - errno = EFAULT; - return -1; - } - else if (signum < 1 || signum >= ACE_NSIG) - { - errno = EINVAL; - return -1; // Invalid signum, return error - } -# if defined (ACE_PSOS) && defined (__DIAB) && ! defined(ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) - // treat 0th u_long of sigset_t as high bits, - // and 1st u_long of sigset_t as low bits. - if (signum <= ACE_BITS_PER_ULONG) - s->s[1] |= (1 << (signum - 1)); - else - s->s[0] |= (1 << (signum - ACE_BITS_PER_ULONG - 1)); -# else - *s |= (1 << (signum - 1)) ; -# endif /* defined (ACE_PSOS) && defined (__DIAB) */ - return 0 ; -#else - ACE_OSCALL_RETURN (::sigaddset (s, signum), int, -1); -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ -} - -ACE_INLINE int -ACE_OS::sigdelset (sigset_t *s, int signum) -{ -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) - if (s == 0) - { - errno = EFAULT; - return -1; - } - else if (signum < 1 || signum >= ACE_NSIG) - { - errno = EINVAL; - return -1; // Invalid signum, return error - } -# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) - // treat 0th u_long of sigset_t as high bits, - // and 1st u_long of sigset_t as low bits. - if (signum <= ACE_BITS_PER_ULONG) - s->s[1] &= ~(1 << (signum - 1)); - else - s->s[0] &= ~(1 << (signum - ACE_BITS_PER_ULONG - 1)); -# else - *s &= ~(1 << (signum - 1)) ; -# endif /* defined (ACE_PSOS) && defined (__DIAB) */ - return 0; -#else - ACE_OSCALL_RETURN (::sigdelset (s, signum), int, -1); -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ -} - -ACE_INLINE int -ACE_OS::sigemptyset (sigset_t *s) -{ -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) - if (s == 0) - { - errno = EFAULT; - return -1; - } -# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) - s->s[0] = 0; - s->s[1] = 0; -# else - *s = 0 ; -# endif /* defined (ACE_PSOS) && defined (__DIAB) */ - return 0 ; -#else - ACE_OSCALL_RETURN (::sigemptyset (s), int, -1); -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ -} - -ACE_INLINE int -ACE_OS::sigfillset (sigset_t *s) -{ -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) - if (s == 0) - { - errno = EFAULT; - return -1; - } -# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) - s->s[0] = ~(u_long) 0; - s->s[1] = ~(u_long) 0; -# else - *s = ~(sigset_t) 0; -# endif /* defined (ACE_PSOS) && defined (__DIAB) */ - return 0 ; -#else - ACE_OSCALL_RETURN (::sigfillset (s), int, -1); -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ -} - -ACE_INLINE int -ACE_OS::sigismember (sigset_t *s, int signum) -{ -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) - if (s == 0) - { - errno = EFAULT; - return -1; - } - else if (signum < 1 || signum >= ACE_NSIG) - { - errno = EINVAL; - return -1; // Invalid signum, return error - } -# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) - // treat 0th u_long of sigset_t as high bits, - // and 1st u_long of sigset_t as low bits. - if (signum <= ACE_BITS_PER_ULONG) - return ((s->s[1] & (1 << (signum - 1))) != 0); - else - return ((s->s[0] & (1 << (signum - ACE_BITS_PER_ULONG - 1))) != 0); -# else - return ((*s & (1 << (signum - 1))) != 0) ; -# endif /* defined (ACE_PSOS) && defined (__DIAB) */ -#else -# if defined (ACE_HAS_SIGISMEMBER_BUG) - if (signum < 1 || signum >= ACE_NSIG) - { - errno = EINVAL; - return -1; // Invalid signum, return error - } -# endif /* ACE_HAS_SIGISMEMBER_BUG */ - ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1); -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ -} - -ACE_INLINE int -ACE_OS::sigsuspend (const sigset_t *sigset) -{ -#if defined (ACE_HAS_SIGSUSPEND) - sigset_t s; - - if (sigset == 0) - { - sigset = &s; - ACE_OS::sigemptyset (&s); - } - ACE_OSCALL_RETURN (::sigsuspend (sigset), int, -1); -#else - ACE_UNUSED_ARG (sigset); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_SIGSUSPEND */ -} - -ACE_INLINE int -ACE_OS::sigprocmask (int how, const sigset_t *nsp, sigset_t *osp) -{ -#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) - ACE_UNUSED_ARG (how); - ACE_UNUSED_ARG (nsp); - ACE_UNUSED_ARG (osp); - ACE_NOTSUP_RETURN (-1); -#else -# if defined (ACE_LACKS_POSIX_PROTOTYPES) - ACE_OSCALL_RETURN (::sigprocmask (how, (int*) nsp, osp), int, -1); -# else - ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1); -# endif /* ACE_LACKS_POSIX_PROTOTYPES */ -#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ -} - -ACE_INLINE int -ACE_OS::pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp) -{ -#if defined (ACE_HAS_PTHREADS_STD) && !defined (ACE_LACKS_PTHREAD_SIGMASK) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp), - ace_result_), - int, - -1); -#else /* !ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */ - ACE_UNUSED_ARG (how); - ACE_UNUSED_ARG (nsp); - ACE_UNUSED_ARG (osp); - ACE_NOTSUP_RETURN (-1); -#endif /* ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */ -} - // **************************************************************** -#if defined (ACE_PSOS) -ACE_INLINE int -isatty (int h) -{ - return ACE_OS::isatty (h); -} -#if defined (fileno) -#undef fileno -#endif /* defined (fileno)*/ -ACE_INLINE ACE_HANDLE -fileno (FILE *fp) -{ - return (ACE_HANDLE) fp; -} -#endif /* defined (ACE_PSOS) */ - -ACE_INLINE -ACE_Cleanup::ACE_Cleanup (void) -{ -} - -ACE_INLINE void * -ACE_OS::bsearch (const void *key, - const void *base, - size_t nel, - size_t size, - ACE_COMPARE_FUNC compar) -{ -#if !defined (ACE_LACKS_BSEARCH) - return ::bsearch (key, base, nel, size, compar); -#else - ACE_UNUSED_ARG (key); - ACE_UNUSED_ARG (base); - ACE_UNUSED_ARG (nel); - ACE_UNUSED_ARG (size); - ACE_UNUSED_ARG (compar); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_LACKS_BSEARCH */ -} - -ACE_INLINE void -ACE_OS::qsort (void *base, - size_t nel, - size_t width, - ACE_COMPARE_FUNC compar) -{ -#if !defined (ACE_LACKS_QSORT) - ::qsort (base, nel, width, compar); -#else - ACE_UNUSED_ARG (base); - ACE_UNUSED_ARG (nel); - ACE_UNUSED_ARG (width); - ACE_UNUSED_ARG (compar); -#endif /* !ACE_LACKS_QSORT */ -} - -ACE_INLINE int -ACE_OS::setuid (uid_t uid) -{ - ACE_OS_TRACE ("ACE_OS::setuid"); -#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - // setuid() is not supported: just one user anyways - ACE_UNUSED_ARG (uid); - return 0; -# elif defined (ACE_WIN32) || defined(CHORUS) - ACE_UNUSED_ARG (uid); - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (::setuid (uid), int, -1); -# endif /* VXWORKS || ACE_PSOS */ -} - -ACE_INLINE uid_t -ACE_OS::getuid (void) -{ - ACE_OS_TRACE ("ACE_OS::getuid"); -#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - // getuid() is not supported: just one user anyways - return 0; -# elif defined (ACE_WIN32) || defined (CHORUS) - ACE_NOTSUP_RETURN (ACE_static_cast (uid_t, -1)); -# else - ACE_OSCALL_RETURN (::getuid (), uid_t, (uid_t) -1); -# endif /* VXWORKS || ACE_PSOS */ -} - -ACE_INLINE int -ACE_OS::setgid (gid_t gid) -{ - ACE_OS_TRACE ("ACE_OS::setgid"); -#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - // setgid() is not supported: just one user anyways - ACE_UNUSED_ARG (gid); - return 0; -# elif defined (ACE_WIN32) || defined (CHORUS) - ACE_UNUSED_ARG (gid); - ACE_NOTSUP_RETURN (-1); -# else - ACE_OSCALL_RETURN (::setgid (gid), int, -1); -# endif /* VXWORKS || ACE_PSOS */ -} - -ACE_INLINE gid_t -ACE_OS::getgid (void) -{ - ACE_OS_TRACE ("ACE_OS::getgid"); -#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) - // getgid() is not supported: just one user anyways - return 0; -# elif defined (ACE_WIN32) || defined (CHORUS) - ACE_NOTSUP_RETURN (ACE_static_cast (gid_t, -1)); -# else - ACE_OSCALL_RETURN (::getgid (), gid_t, (gid_t) -1); -# endif /* VXWORKS || ACE_PSOS */ -} - -ACE_INLINE ACE_EXIT_HOOK -ACE_OS::set_exit_hook (ACE_EXIT_HOOK exit_hook) -{ - ACE_EXIT_HOOK old_hook = exit_hook_; - exit_hook_ = exit_hook; - return old_hook; -} - -ACE_INLINE int -ACE_OS::isatty (int handle) -{ -#if defined (ACE_LACKS_ISATTY) - ACE_UNUSED_ARG (handle); - return 0; -# elif defined (ACE_WIN32) - ACE_OS_TRACE ("ACE_OS::isatty"); - return ::_isatty (handle); -# else - ACE_OS_TRACE ("ACE_OS::isatty"); - ACE_OSCALL_RETURN (::isatty (handle), int, -1); -# endif /* defined (ACE_LACKS_ISATTY) */ -} - -#if defined (ACE_WIN32) -ACE_INLINE int -ACE_OS::isatty (ACE_HANDLE handle) -{ -#if defined (ACE_LACKS_ISATTY) - ACE_UNUSED_ARG (handle); - return 0; -#else -# if defined (ACE_WIN64) - int fd = ::_open_osfhandle (intptr_t (handle), 0); -# else - int fd = ::_open_osfhandle (long (handle), 0); -# endif /* ACE_WIN64 */ - - int status = ::_isatty (fd); - ::_close (fd); - return status; -#endif /* ACE_LACKS_ISATTY */ -} - -ACE_INLINE void -ACE_OS::fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode) -{ - switch (x) - { - case ACE_LIB_TEXT ('r'): - if (ACE_BIT_DISABLED (hmode, _O_RDWR)) - { - ACE_CLR_BITS (hmode, _O_WRONLY); - ACE_SET_BITS (hmode, _O_RDONLY); - } - break; - case ACE_LIB_TEXT ('w'): - if (ACE_BIT_DISABLED (hmode, _O_RDWR)) - { - ACE_CLR_BITS (hmode, _O_RDONLY); - ACE_SET_BITS (hmode, _O_WRONLY); - } - ACE_SET_BITS (hmode, _O_CREAT | _O_TRUNC); - break; - case ACE_LIB_TEXT ('a'): - if (ACE_BIT_DISABLED (hmode, _O_RDWR)) - { - ACE_CLR_BITS (hmode, _O_RDONLY); - ACE_SET_BITS (hmode, _O_WRONLY); - } - ACE_SET_BITS (hmode, _O_CREAT | _O_APPEND); - break; - case ACE_LIB_TEXT ('+'): - ACE_CLR_BITS (hmode, _O_RDONLY | _O_WRONLY); - ACE_SET_BITS (hmode, _O_RDWR); - break; - case ACE_LIB_TEXT ('t'): - ACE_CLR_BITS (hmode, _O_BINARY); - ACE_SET_BITS (hmode, _O_TEXT); - break; - case ACE_LIB_TEXT ('b'): - ACE_CLR_BITS (hmode, _O_TEXT); - ACE_SET_BITS (hmode, _O_BINARY); - break; - } -} -#endif /* ACE_WIN32 */ - -// Return a dynamically allocated duplicate of <str>, substituting the -// environment variable if <str[0] == '$'>. Note that the pointer is -// allocated with <ACE_OS::malloc> and must be freed by -// <ACE_OS::free>. - -ACE_INLINE ACE_TCHAR * -ACE_OS::strenvdup (const ACE_TCHAR *str) -{ -#if defined (ACE_HAS_WINCE) - // WinCE doesn't have environment variables so we just skip it. - return ACE_OS::strdup (str); -#elif defined (ACE_LACKS_ENV) - ACE_UNUSED_ARG (str); - ACE_NOTSUP_RETURN (0); -#else - ACE_TCHAR *temp = 0; - - if (str[0] == ACE_LIB_TEXT ('$') - && (temp = ACE_OS::getenv (&str[1])) != 0) - return ACE_OS::strdup (temp); - else - return ACE_OS::strdup (str); -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_Countdown_Time::start (void) -{ - if (this->max_wait_time_ != 0) - { - this->start_time_ = ACE_OS::gettimeofday (); - this->stopped_ = 0; - } - return 0; -} - -ACE_INLINE int -ACE_Countdown_Time::stopped (void) const -{ - return stopped_; -} - -ACE_INLINE int -ACE_Countdown_Time::stop (void) -{ - if (this->max_wait_time_ != 0 && this->stopped_ == 0) - { - ACE_Time_Value elapsed_time = - ACE_OS::gettimeofday () - this->start_time_; - - if (*this->max_wait_time_ > elapsed_time) - *this->max_wait_time_ -= elapsed_time; - else - { - // Used all of timeout. - *this->max_wait_time_ = ACE_Time_Value::zero; - // errno = ETIME; - } - this->stopped_ = 1; - } - return 0; -} - -ACE_INLINE int -ACE_Countdown_Time::update (void) -{ - return this->stop () == 0 && this->start (); -} - -#if defined (ACE_WIN32) -ACE_INLINE const OSVERSIONINFO & -ACE_OS::get_win32_versioninfo () -{ - return ACE_OS::win32_versioninfo_; -} - -ACE_INLINE HINSTANCE -ACE_OS::get_win32_resource_module () -{ - return ACE_OS::win32_resource_module_; -} - -ACE_INLINE void -ACE_OS::set_win32_resource_module (HINSTANCE instance) -{ - ACE_OS::win32_resource_module_ = instance; -} -#endif /* ACE_WIN32 */ diff --git a/ace/OS_Dirent.cpp b/ace/OS_Dirent.cpp index 6941272d452..8ca959263ed 100644 --- a/ace/OS_Dirent.cpp +++ b/ace/OS_Dirent.cpp @@ -1,24 +1,6 @@ // $Id$ #include "ace/OS_Dirent.h" -#include "ace/OS_String.h" -#include "ace/OS_Memory.h" -#include "ace/Log_Msg.h" -#include "ace/OS.h" - -/* - These definitions are missing on the original VC6 distribution. The new - headers that define these are available in the Platform SDK and are defined - for those that don't have it. - */ -#if defined (ACE_WIN32) -# if !defined (INVALID_FILE_ATTRIBUTES) -# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) -# endif /* INVALID_FILE_ATTRIBUTES */ -# if !defined (INVALID_SET_FILE_POINTER) -# define INVALID_SET_FILE_POINTER ((DWORD)-1) -# endif /* INVALID_SET_FILE_POINTER */ -#endif /* ACE_WIN32 */ ACE_RCSID(ace, OS_Dirent, "$Id$") @@ -26,252 +8,3 @@ ACE_RCSID(ace, OS_Dirent, "$Id$") # include "ace/OS_Dirent.inl" #endif /* ACE_HAS_INLINED_OS_CALLS */ -ACE_DIR * -ACE_OS_Dirent::opendir_emulation (const ACE_TCHAR *filename) -{ -#if defined (ACE_WIN32) - ACE_DIR *dir; - ACE_TCHAR extra[3] = {0,0,0}; - - // Check if filename is a directory. - DWORD fileAttribute = ACE_TEXT_GetFileAttributes (filename); - if (fileAttribute == INVALID_FILE_ATTRIBUTES - || !(fileAttribute & FILE_ATTRIBUTE_DIRECTORY)) - return 0; - -/* - Note: the semantics of the win32 function FindFirstFile take the - basename(filename) as a pattern to be matched within the dirname(filename). - This is contrary to the behavior of the posix function readdir which treats - basename(filename) as a directory to be opened and read. - - For this reason, we append a slash-star or backslash-star to the supplied - filename so the result is that FindFirstFile will do what we need. - - According to the documentation for FindFirstFile, either a '/' or a '\' may - be used as a directory name separator. - - Of course, it is necessary to ensure that this is only done if the trailing - filespec is not already there. - - Phil Mesnier -*/ - - size_t lastchar = ACE_OS_String::strlen (filename); - if (lastchar > 0) - { - if (filename[lastchar-1] != '*') - { - if (filename[lastchar-1] != '/' && filename[lastchar-1] != '\\') - ACE_OS_String::strcpy (extra, ACE_LIB_TEXT ("/*")); - else - ACE_OS_String::strcpy (extra, ACE_LIB_TEXT ("*")); - } - } - - ACE_NEW_RETURN (dir, ACE_DIR, 0); - ACE_NEW_RETURN (dir->directory_name_, - ACE_TCHAR[lastchar + ACE_OS_String::strlen (extra) + 1], - 0); - ACE_OS_String::strcpy (dir->directory_name_, filename); - if (extra[0]) - ACE_OS_String::strcat (dir->directory_name_, extra); - dir->current_handle_ = INVALID_HANDLE_VALUE; - dir->started_reading_ = 0; - dir->dirent_ = 0; - return dir; -#else /* ACE_WIN32 */ - ACE_UNUSED_ARG (filename); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_WIN32 */ -} - -void -ACE_OS_Dirent::closedir_emulation (ACE_DIR *d) -{ -#if defined (ACE_WIN32) - if (d->current_handle_ != INVALID_HANDLE_VALUE) - ::FindClose (d->current_handle_); - - d->current_handle_ = INVALID_HANDLE_VALUE; - d->started_reading_ = 0; - if (d->dirent_ != 0) - { - ACE_OS_Memory::free (d->dirent_->d_name); - ACE_OS_Memory::free (d->dirent_); - } -#else /* ACE_WIN32 */ - ACE_UNUSED_ARG (d); -#endif /* ACE_WIN32 */ -} - -dirent * -ACE_OS_Dirent::readdir_emulation (ACE_DIR *d) -{ -#if defined (ACE_WIN32) - if (d->dirent_ != 0) - { - ACE_OS_Memory::free (d->dirent_->d_name); - ACE_OS_Memory::free (d->dirent_); - d->dirent_ = 0; - } - - if (!d->started_reading_) - { - d->current_handle_ = ACE_TEXT_FindFirstFile (d->directory_name_, - &d->fdata_); - d->started_reading_ = 1; - } - else - { - int retval = ACE_TEXT_FindNextFile (d->current_handle_, - &d->fdata_); - if (retval == 0) - { - // Make sure to close the handle explicitly to avoid a leak! - ::FindClose (d->current_handle_); - d->current_handle_ = INVALID_HANDLE_VALUE; - } - } - - if (d->current_handle_ != INVALID_HANDLE_VALUE) - { - d->dirent_ = (dirent *) - ACE_OS_Memory::malloc (sizeof (dirent)); - - if (d->dirent_ != 0) - { - d->dirent_->d_name = (ACE_TCHAR*) - ACE_OS_Memory::malloc ((ACE_OS_String::strlen (d->fdata_.cFileName) + 1) - * sizeof (ACE_TCHAR)); - ACE_OS_String::strcpy (d->dirent_->d_name, d->fdata_.cFileName); - d->dirent_->d_reclen = sizeof (dirent); - } - - return d->dirent_; - } - else - return 0; -#else /* ACE_WIN32 */ - ACE_UNUSED_ARG (d); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_WIN32 */ -} - -extern "C" -{ - typedef int (*ACE_SCANDIR_COMPARATOR) (const void *, const void *); -} - -int -ACE_OS_Dirent::scandir_emulation (const ACE_TCHAR *dirname, - dirent **namelist[], - int (*selector) (const dirent *entry), - int (*comparator) (const dirent **f1, - const dirent **f2)) -{ - ACE_DIR *dirp = ACE_OS_Dirent::opendir (dirname); - - if (dirp == 0) - return -1; - // A sanity check here. "namelist" had better not be zero. - else if (namelist == 0) - return -1; - - dirent **vector = 0; - dirent *dp; - int arena_size = 0; - - int nfiles = 0; - int fail = 0; - - // @@ This code shoulduse readdir_r() rather than readdir(). - for (dp = ACE_OS_Dirent::readdir (dirp); - dp != 0; - dp = ACE_OS_Dirent::readdir (dirp)) - { - if (selector && (*selector)(dp) == 0) - continue; - - // If we get here, we have a dirent that the user likes. - if (nfiles == arena_size) - { - dirent **newv; - if (arena_size == 0) - arena_size = 10; - else - arena_size *= 2; - - newv = (dirent **) ACE_OS_Memory::realloc (vector, - arena_size * sizeof (dirent *)); - if (newv == 0) - { - fail = 1; - break; - } - vector = newv; - } - -#if defined (ACE_LACKS_STRUCT_DIR) - dirent *newdp = (dirent *) ACE_OS_Memory::malloc (sizeof (dirent)); -#else - int dsize = - sizeof (dirent) + - ((ACE_OS_String::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); - dirent *newdp = (dirent *) ACE_OS_Memory::malloc (dsize); -#endif /* ACE_LACKS_STRUCT_DIR */ - - if (newdp == 0) - { - fail = 1; - break; - } - -#if defined (ACE_LACKS_STRUCT_DIR) - newdp->d_name = (ACE_TCHAR*) ACE_OS_Memory::malloc ( - (ACE_OS_String::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); - - if (newdp->d_name == 0) - { - fail = 1; - ACE_OS_Memory::free (newdp); - break; - } - - // Don't use memcpy here since d_name is now a pointer - newdp->d_ino = dp->d_ino; - newdp->d_off = dp->d_off; - newdp->d_reclen = dp->d_reclen; - ACE_OS_String::strcpy (newdp->d_name, dp->d_name); - vector[nfiles++] = newdp; -#else - vector[nfiles++] = (dirent *) ACE_OS_String::memcpy (newdp, dp, dsize); -#endif /* ACE_LACKS_STRUCT_DIR */ - } - - if (fail) - { - ACE_OS_Dirent::closedir (dirp); - while (nfiles-- > 0) - { -#if defined (ACE_LACKS_STRUCT_DIR) - ACE_OS_Memory::free (vector[nfiles]->d_name); -#endif /* ACE_LACKS_STRUCT_DIR */ - ACE_OS_Memory::free (vector[nfiles]); - } - ACE_OS_Memory::free (vector); - return -1; - } - - ACE_OS_Dirent::closedir (dirp); - - *namelist = vector; - - if (comparator) - ACE_OS::qsort (*namelist, - nfiles, - sizeof (dirent *), - (ACE_SCANDIR_COMPARATOR) comparator); - - return nfiles; -} diff --git a/ace/OS_Dirent.h b/ace/OS_Dirent.h index 3c0fb782d03..85fa4be0fe9 100644 --- a/ace/OS_Dirent.h +++ b/ace/OS_Dirent.h @@ -26,42 +26,16 @@ #include "ace/os_include/os_dirent.h" #include "ace/os_include/sys/os_types.h" +#include "ace/OS_NS_dirent.h" /** - * @class ACE_OS_Dirent + * @namespace ACE_OS_Dirent * * @brief This class is a wrapper for the dirent.h operations * */ -class ACE_OS_Export ACE_OS_Dirent -{ -public: - static ACE_DIR *opendir (const ACE_TCHAR *filename); - static void closedir (ACE_DIR *); - static dirent *readdir (ACE_DIR *); - static int readdir_r (ACE_DIR *dirp, - struct dirent *entry, - struct dirent **result); - static long telldir (ACE_DIR *); - static void seekdir (ACE_DIR *, - long loc); - static void rewinddir (ACE_DIR *); - - static int scandir (const ACE_TCHAR *dirname, - struct dirent **namelist[], - int (*selector) (const struct dirent *filename), - int (*comparator) (const struct dirent **f1, - const struct dirent **f2)); -private: - // Win32 emulation functions - static ACE_DIR *opendir_emulation (const ACE_TCHAR *filename); - static int scandir_emulation (const ACE_TCHAR *dirname, - dirent **namelist[], - int (*selector)(const dirent *entry), - int (*comparator)(const dirent **f1, - const dirent**f2)); - static void closedir_emulation (ACE_DIR *); - static dirent *readdir_emulation (ACE_DIR *); -}; +#define ACE_OS_Dirent ACE_OS +namespace ACE_OS { +}; /* namespace ACE_OS */ # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) diff --git a/ace/OS_Dirent.inl b/ace/OS_Dirent.inl index 314f33f32da..7f2b3228624 100644 --- a/ace/OS_Dirent.inl +++ b/ace/OS_Dirent.inl @@ -1,192 +1,3 @@ // -*- C++ -*- // $Id$ -ACE_INLINE ACE_DIR * -ACE_OS_Dirent::opendir (const ACE_TCHAR *filename) -{ -#if defined (ACE_HAS_DIRENT) -# if defined (ACE_PSOS) - // The pointer to the <ACE_DIR> buffer *must* be passed to - // <ACE_OS_Dirent::closedir> to free it and avoid a memory leak. - ACE_DIR *dir; - u_long result; - ACE_NEW_RETURN (dir, ACE_DIR, 0); - result = ::open_dir (ACE_const_cast (ACE_TCHAR *, - filename), - &dir->xdir); - if (result == 0) - return dir; - else - { - errno = result; - return 0; - } -# else /* ! ACE_PSOS */ -# if defined (ACE_WIN32) - return ::ACE_OS_Dirent::opendir_emulation (filename); -# else /* ! ACE_WIN32 */ - // VxWorks' ::opendir () is declared with a non-const argument. - return ::opendir (ACE_const_cast (ACE_TCHAR *, filename)); -# endif /* ACE_WIN32 */ -# endif /* ACE_PSOS */ -#else - ACE_UNUSED_ARG (filename); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_DIRENT */ -} - -ACE_INLINE void -ACE_OS_Dirent::closedir (ACE_DIR *d) -{ -#if defined (ACE_HAS_DIRENT) -# if defined (ACE_PSOS) - - u_long result = ::close_dir (&(d->xdir)); - delete d; - if (result != 0) - errno = result; - -# else /* ! ACE_PSOS */ - -# if defined (ACE_WIN32) - ACE_OS_Dirent::closedir_emulation (d); - delete [] d->directory_name_; - delete d; -# else /* ACE_WIN32 */ - ::closedir (d); -# endif /* ACE_WIN32 */ - -# endif /* ACE_PSOS */ -#else /* ACE_HAS_DIRENT */ - ACE_UNUSED_ARG (d); -#endif /* ACE_HAS_DIRENT */ -} - -ACE_INLINE struct dirent * -ACE_OS_Dirent::readdir (ACE_DIR *d) -{ -#if defined (ACE_HAS_DIRENT) -# if defined (ACE_PSOS) - - u_long result = ::read_dir (&d->xdir, &d->dirent); - if (0 == result) - return &d->dirent; - else - { - errno = result; - return 0; - } - -# else /* ! ACE_PSOS */ -# if defined (ACE_WIN32) - return ACE_OS_Dirent::readdir_emulation (d); -# else /* defined (ACE_WIN32) */ - return ::readdir (d); -# endif /* defined (ACE_WIN32) */ -# endif /* ACE_PSOS */ -#else - ACE_UNUSED_ARG (d); - ACE_NOTSUP_RETURN (0); -#endif /* ACE_HAS_DIRENT */ -} - -ACE_INLINE int -ACE_OS_Dirent::readdir_r (ACE_DIR *dirp, - struct dirent *entry, - struct dirent **result) -{ -#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) - ACE_UNUSED_ARG (entry); - // <result> has better not be 0! - *result = ACE_OS_Dirent::readdir (dirp); - if (*result) - return 0; // Keep iterating - else - return 1; // Oops, some type of error! -#elif defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_READDIR_R) -# if (defined (sun) && (defined (_POSIX_PTHREAD_SEMANTICS) || \ - (_FILE_OFFSET_BITS == 64))) || \ - (!defined (sun) && (defined (ACE_HAS_PTHREADS_STD) || \ - defined (ACE_HAS_PTHREADS_DRAFT7) || \ - defined (__USE_POSIX) || \ - defined (__FreeBSD__) || \ - defined (HPUX_11))) -# if defined (__GNUG__) && defined (DIGITAL_UNIX) - return readdir_r (dirp, entry, result); -# else - return ::readdir_r (dirp, entry, result); -# endif /* defined (__GNUG__) && defined (DIGITAL_UNIX) */ -# else /* ! POSIX.1c - this is draft 4 or draft 6 */ -# if defined (HPUX_10) /* But HP 10.x doesn't follow the draft either */ - *result = entry; - return ::readdir_r (dirp, entry); -# else - // <result> had better not be 0! - *result = ::readdir_r (dirp, entry); - return 0; -# endif /* HPUX_10 */ -# endif /* ! POSIX.1c */ -#else /* ! ACE_HAS_DIRENT || ACE_LACKS_READDIR_R */ - ACE_UNUSED_ARG (dirp); - ACE_UNUSED_ARG (entry); - ACE_UNUSED_ARG (result); - ACE_NOTSUP_RETURN (0); - -#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ -} - -ACE_INLINE long -ACE_OS_Dirent::telldir (ACE_DIR *d) -{ -#if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR) - return ::telldir (d); -#else /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */ - ACE_UNUSED_ARG (d); - ACE_NOTSUP_RETURN (-1); -#endif /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */ -} - -ACE_INLINE void -ACE_OS_Dirent::seekdir (ACE_DIR *d, long loc) -{ -#if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_SEEKDIR) - ::seekdir (d, loc); -#else /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */ - ACE_UNUSED_ARG (d); - ACE_UNUSED_ARG (loc); -#endif /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */ -} - -ACE_INLINE void -ACE_OS_Dirent::rewinddir (ACE_DIR *d) -{ -#if defined (ACE_HAS_DIRENT) -# if defined (ACE_LACKS_SEEKDIR) -# if defined (ACE_LACKS_REWINDDIR) - ACE_UNUSED_ARG (d); -# else /* ! defined (ACE_LACKS_REWINDDIR) */ - ::rewinddir (d); -# endif /* ! defined (ACE_LACKS_REWINDDIR) */ -# else /* ! ACE_LACKS_SEEKDIR */ - // We need to implement <rewinddir> using <seekdir> since it's often - // defined as a macro... - ::seekdir (d, long (0)); -# endif /* ! ACE_LACKS_SEEKDIR */ -#else - ACE_UNUSED_ARG (d); -#endif /* ACE_HAS_DIRENT */ -} - -ACE_INLINE int -ACE_OS_Dirent::scandir (const ACE_TCHAR *dirname, - struct dirent **namelist[], - int (*selector)(const struct dirent *), - int (*comparator) (const struct dirent **f1, - const struct dirent **f2)) -{ -#if defined (ACE_HAS_SCANDIR) - return ::scandir (dirname, namelist, selector, comparator); -#else /* ! defined ( ACE_HAS_SCANDIR) */ - return ACE_OS_Dirent::scandir_emulation (dirname, namelist, selector, comparator); -#endif /* ACE_HAS_SCANDIR */ -} diff --git a/ace/OS_Memory.cpp b/ace/OS_Memory.cpp index aed484de9d8..5847657bb46 100644 --- a/ace/OS_Memory.cpp +++ b/ace/OS_Memory.cpp @@ -14,32 +14,3 @@ static int shut_up_aCC = 0; #include "ace/os_include/os_stdlib.h" -void * -ACE_OS_Memory::malloc (size_t nbytes) -{ - return ACE_MALLOC_FUNC (nbytes); -} - -void * -ACE_OS_Memory::calloc (size_t elements, size_t sizeof_elements) -{ -#if !defined (ACE_HAS_WINCE) - return ACE_CALLOC_FUNC (elements, sizeof_elements); -#else - // @@ This will probably not work since it doesn't consider - // alignment properly. - return ACE_MALLOC_FUNC (elements * sizeof_elements); -#endif /* ACE_HAS_WINCE */ -} - -void * -ACE_OS_Memory::realloc (void *ptr, size_t nbytes) -{ - return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes); -} - -void -ACE_OS_Memory::free (void *ptr) -{ - ACE_FREE_FUNC (ACE_MALLOC_T (ptr)); -} diff --git a/ace/OS_Memory.h b/ace/OS_Memory.h index e914deebd1a..fa842b000ea 100644 --- a/ace/OS_Memory.h +++ b/ace/OS_Memory.h @@ -232,22 +232,18 @@ typedef void *ACE_MALLOC_T; ((char *) ACE_align_binary (((ptrdiff_t) (ptr)), (alignment))) //@} +#include "ace/OS_NS_stdlib.h" + /** - * @class ACE_OS_Memory + * @namespace ACE_OS_Memory * * @brief This class is a wrapper for dynamic memory operations. * */ -class ACE_OS_Export ACE_OS_Memory +#define ACE_OS_Memory ACE_OS +namespace ACE_OS { -public: - // = A set of wrappers for memory managment. - static void *sbrk (int brk); - static void *calloc (size_t elements, size_t sizeof_elements); - static void *malloc (size_t); - static void *realloc (void *, size_t); - static void free (void *); -}; +} /* namespace ACE_OS */ # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) diff --git a/ace/OS_Memory.inl b/ace/OS_Memory.inl index a0cb82573e9..3c4912199de 100644 --- a/ace/OS_Memory.inl +++ b/ace/OS_Memory.inl @@ -1,16 +1,7 @@ +// -*- C++ -*- // $Id$ #if !defined (ACE_LACKS_SBRK) # include "ace/os_include/os_unistd.h" #endif /* !ACE_LACKS_SBRK */ -ACE_INLINE void * -ACE_OS_Memory::sbrk (int brk) -{ -#if defined (ACE_LACKS_SBRK) - ACE_UNUSED_ARG (brk); - ACE_NOTSUP_RETURN (0); -#else - ACE_OSCALL_RETURN (::sbrk (brk), void *, 0); -#endif /* VXWORKS */ -} diff --git a/ace/OS_NS_Thread.cpp b/ace/OS_NS_Thread.cpp index fc532b41367..6af0b3f2850 100644 --- a/ace/OS_NS_Thread.cpp +++ b/ace/OS_NS_Thread.cpp @@ -1,4 +1,3803 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_Thread.h" + +ACE_RCSID(ace, OS_NS_Thread, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_Thread.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/OS_NS_stdio.h" +#include "ace/Sched_Params.h" +#include "ace/OS_Memory.h" +#include "ace/OS_Thread_Adapter.h" +#include "ace/Min_Max.h" +#include "ace/OS_NS_errno.h" + +// This is necessary to work around nasty problems with MVS C++. + +extern "C" void +ace_mutex_lock_cleanup_adapter (void *args) +{ + ACE_OS::mutex_lock_cleanup (args); +} + + +#if !defined(ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) +# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ + (*THR_ID = ::_beginthreadex ((void(_Optlink*)(void*))ENTRY_POINT, STACK, STACKSIZE, ARGS), *THR_ID) +#elif defined(ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) + +struct __IBMCPP__thread_params { + __IBMCPP__thread_params(ACE_THR_C_FUNC e, LPVOID a) + :entry_point(e),args(a) {} + ACE_THR_C_FUNC entry_point; + LPVOID args; +}; + +# pragma handler(initThread) +extern "C" DWORD __stdcall __IBMCPP__initThread(void *arg) +{ + // Must reset 387 since using CreateThread + _fpreset(); + + // Dispatch user function... + auto_ptr<__IBMCPP__thread_params> parms((__IBMCPP__thread_params *)arg); + (*parms->entry_point)(parms->args); + _endthread(); + return 0; +} + +HANDLE WINAPI __IBMCPP__beginthreadex(void *stack, + DWORD stacksize, + ACE_THR_C_FUNC entry_point, + LPVOID args, + DWORD flags, + LPDWORD thr_id) +{ + return CreateThread(0, + stacksize, + (LPTHREAD_START_ROUTINE)__IBMCPP__initThread, + new __IBMCPP__thread_params(entry_point, args), + flags, + thr_id); +} + +# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ + __IBMCPP__beginthreadex(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) + +#elif defined (ACE_HAS_WINCE) && defined (UNDER_CE) && (UNDER_CE >= 211) +# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ + CreateThread (0, STACKSIZE, (unsigned long (__stdcall *) (void *)) ENTRY_POINT, ARGS, (FLAGS) & CREATE_SUSPENDED, (unsigned long *) THR_ID) +#elif defined(ACE_HAS_WTHREADS) + // Green Hills compiler gets confused when __stdcall is imbedded in + // parameter list, so we define the type ACE_WIN32THRFUNC_T and use it + // instead. + typedef unsigned (__stdcall *ACE_WIN32THRFUNC_T)(void*); +# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \ + ::_beginthreadex (STACK, STACKSIZE, (ACE_WIN32THRFUNC_T) ENTRY_POINT, ARGS, FLAGS, (unsigned int *) THR_ID) +#endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */ + +/*****************************************************************************/ + +ACE_Thread_ID::ACE_Thread_ID (ACE_thread_t thread_id, + ACE_hthread_t thread_handle) + : thread_id_ (thread_id), + thread_handle_ (thread_handle) +{ +} + +ACE_Thread_ID::ACE_Thread_ID (const ACE_Thread_ID &id) + : thread_id_ (id.thread_id_), + thread_handle_ (id.thread_handle_) +{ +} + +ACE_thread_t +ACE_Thread_ID::id (void) +{ + return this->thread_id_; +} + +void +ACE_Thread_ID::id (ACE_thread_t thread_id) +{ + this->thread_id_ = thread_id; +} + +ACE_hthread_t +ACE_Thread_ID::handle (void) +{ + return this->thread_handle_; +} + +void +ACE_Thread_ID::handle (ACE_hthread_t thread_handle) +{ + this->thread_handle_ = thread_handle; +} + +void +ACE_Thread_ID::to_string (char* thr_id) +{ + + char format[128]; // Converted format string + char *fp; // Current format pointer + fp = format; + *fp++ = '%'; // Copy in the % + +#if defined (ACE_WIN32) + ACE_OS::strcpy (fp, "u"); + ACE_OS::sprintf (thr_id, + format, + ACE_static_cast(unsigned, + ACE_OS::thr_self ())); +#elif defined (ACE_AIX_VERS) && (ACE_AIX_VERS <= 402) + // AIX's pthread_t (ACE_hthread_t) is a pointer, and it's + // a little ugly to send that through a %u format. So, + // get the kernel thread ID (tid_t) via thread_self() and + // display that instead. + // This isn't conditionalized on ACE_HAS_THREAD_SELF because + // 1. AIX 4.2 doesn't have that def anymore (it messes up + // other things) + // 2. OSF/1 V3.2 has that def, and I'm not sure what affect + // this would have on that. + // -Steve Huston, 19-Aug-97 + ACE_OS::strcpy (fp, "u"); + ACE_OS::sprintf (thr_id, format, thread_self()); +#elif defined (DIGITAL_UNIX) + ACE_OS::strcpy (fp, "u"); + ACE_OS::sprintf (thr_id, format, +# if defined (ACE_HAS_THREADS) + pthread_getselfseq_np () +# else + ACE_Thread::self () +# endif /* ACE_HAS_THREADS */ + ); +#else + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); + +# if defined (ACE_HAS_PTHREADS_DRAFT4) && defined (HPUX_10) + ACE_OS::strcpy (fp, "u"); + // HP-UX 10.x DCE's thread ID is a pointer. Grab the + // more meaningful, readable, thread ID. This will match + // the one seen in the debugger as well. + ACE_OS::sprintf (thr_id, format, + pthread_getunique_np(&t_id)); +# elif defined (ACE_MVS) + // MVS's pthread_t is a struct... yuck. So use the ACE 5.0 + // code for it. + ACE_OS::strcpy (fp, "u"); + ACE_OS::sprintf (thr_id, format, t_id); +# else + // Yes, this is an ugly C-style cast, but the correct + // C++ cast is different depending on whether the t_id + // is an integral type or a pointer type. FreeBSD uses + // a pointer type, but doesn't have a _np function to + // get an integral type, like the OSes above. + ACE_OS::strcpy (fp, "lu"); + ACE_OS::sprintf (thr_id, format, (unsigned long)t_id); +# endif /* ACE_HAS_PTHREADS_DRAFT4 && HPUX_10 */ + +#endif /* ACE_WIN32 */ +} + +int +ACE_Thread_ID::operator== (const ACE_Thread_ID &rhs) const +{ + return ACE_OS::thr_cmp (this->thread_handle_, rhs.thread_handle_) == 0 + && ACE_OS::thr_equal (this->thread_id_, rhs.thread_id_) == 0; +} + +int +ACE_Thread_ID::operator!= (const ACE_Thread_ID &rhs) const +{ + return !(*this == rhs); +} + +/*****************************************************************************/ + +#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + +#if defined (ACE_HAS_TSS_EMULATION) +u_int ACE_TSS_Emulation::total_keys_ = 0; + +ACE_TSS_Keys ACE_TSS_Emulation::tss_keys_used_; + +ACE_TSS_Emulation::ACE_TSS_DESTRUCTOR +ACE_TSS_Emulation::tss_destructor_[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX] + = { 0 }; + +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + +int ACE_TSS_Emulation::key_created_ = 0; + +ACE_OS_thread_key_t ACE_TSS_Emulation::native_tss_key_; + +/* static */ +# if defined (ACE_HAS_THR_C_FUNC) +extern "C" +void +ACE_TSS_Emulation_cleanup (void *ptr) +{ + ACE_UNUSED_ARG (ptr); + // Really this must be used for ACE_TSS_Emulation code to make the TSS + // cleanup +} +# else +void +ACE_TSS_Emulation_cleanup (void *ptr) +{ + ACE_UNUSED_ARG (ptr); + // Really this must be used for ACE_TSS_Emulation code to make the TSS + // cleanup +} +# endif /* ACE_HAS_THR_C_FUNC */ + +void ** +ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created) +{ + // TSS Singleton implementation. + + // Create the one native TSS key, if necessary. + if (key_created_ == 0) + { + // Double-checked lock . . . + ACE_TSS_BASE_GUARD + + if (key_created_ == 0) + { + ACE_NO_HEAP_CHECK; + if (ACE_OS::thr_keycreate (&native_tss_key_, + &ACE_TSS_Emulation_cleanup) != 0) + { + return 0; // Major problems, this should *never* happen! + } + key_created_ = 1; + } + } + + void **old_ts_storage = 0; + + // Get the tss_storage from thread-OS specific storage. + if (ACE_OS::thr_getspecific (native_tss_key_, + (void **) &old_ts_storage) == -1) + return 0; // This should not happen! + + // Check to see if this is the first time in for this thread. + // This block can also be entered after a fork () in the child process, + // at least on Pthreads Draft 4 platforms. + if (old_ts_storage == 0) + { + if (ts_created) + *ts_created = 1u; + + // Use the ts_storage passed as argument, if non-zero. It is + // possible that this has been implemented in the stack. At the + // moment, this is unknown. The cleanup must not do nothing. + // If ts_storage is zero, allocate (and eventually leak) the + // storage array. + if (ts_storage == 0) + { + ACE_NO_HEAP_CHECK; + + ACE_NEW_RETURN (ts_storage, + void*[ACE_TSS_THREAD_KEYS_MAX], + 0); + + // Zero the entire TSS array. Do it manually instead of + // using memset, for optimum speed. Though, memset may be + // faster :-) + void **tss_base_p = ts_storage; + + for (u_int i = 0; + i < ACE_TSS_THREAD_KEYS_MAX; + ++i) + *tss_base_p++ = 0; + } + + // Store the pointer in thread-specific storage. It gets + // deleted via the ACE_TSS_Emulation_cleanup function when the + // thread terminates. + if (ACE_OS::thr_setspecific (native_tss_key_, + (void *) ts_storage) != 0) + return 0; // Major problems, this should *never* happen! + } + else + if (ts_created) + ts_created = 0; + + return ts_storage ? ts_storage : old_ts_storage; +} +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ + +u_int +ACE_TSS_Emulation::total_keys () +{ + ACE_OS_Recursive_Thread_Mutex_Guard ( + *ACE_static_cast (ACE_recursive_thread_mutex_t *, + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); + + return total_keys_; +} + +int +ACE_TSS_Emulation::next_key (ACE_thread_key_t &key) +{ + ACE_OS_Recursive_Thread_Mutex_Guard ( + *ACE_static_cast (ACE_recursive_thread_mutex_t *, + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); + + if (total_keys_ < ACE_TSS_THREAD_KEYS_MAX) + { + u_int counter = 0; + // Loop through all possible keys and check whether a key is free + for ( ;counter < ACE_TSS_THREAD_KEYS_MAX; counter++) + { + ACE_thread_key_t localkey; +# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T) + ACE_OS::memset (&localkey, 0, sizeof (ACE_thread_key_t)); + ACE_OS::memcpy (&localkey, &counter_, sizeof (u_int)); +# else + localkey = counter; +# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ + // If the key is not set as used, we can give out this key, if not + // we have to search further + if (tss_keys_used_.is_set(localkey) == 0) + { + tss_keys_used_.test_and_set(localkey); + key = localkey; + break; + } + } + + ++total_keys_; + return 0; + } + else + { + key = ACE_OS::NULL_key; + return -1; + } +} + +int +ACE_TSS_Emulation::release_key (ACE_thread_key_t key) +{ + ACE_OS_Recursive_Thread_Mutex_Guard ( + *ACE_static_cast (ACE_recursive_thread_mutex_t *, + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_TSS_KEY_LOCK])); + + if (tss_keys_used_.test_and_clear (key) == 0) + { + --total_keys_; + return 0; + } + return 1; +} + +void * +ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]) +{ +# if defined (ACE_PSOS) + u_long tss_base; + + // Use the supplied array for this thread's TSS. + tss_base = (u_long) ts_storage; + t_setreg (0, PSOS_TASK_REG_TSS, tss_base); + + // Zero the entire TSS array. + void **tss_base_p = ts_storage; + for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) + { + *tss_base_p = 0; + } + + return (void *) tss_base; +# else /* ! ACE_PSOS */ +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + // On VxWorks, in particular, don't check to see if the field + // is 0. It isn't always, specifically, when a program is run + // directly by the shell (without spawning a new task) after + // another program has been run. + + u_int ts_created = 0; + tss_base (ts_storage, &ts_created); + if (ts_created) + { +# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ + tss_base () = ts_storage; +# endif + + // Zero the entire TSS array. Do it manually instead of using + // memset, for optimum speed. Though, memset may be faster :-) + void **tss_base_p = tss_base (); + for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) + { + *tss_base_p = 0; + } + + return tss_base (); +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + } + else + { + return 0; + } +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ +# endif /* ! ACE_PSOS */ +} + +void +ACE_TSS_Emulation::tss_close () +{ +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + // Free native_tss_key_ here. +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ +} + +#endif /* ACE_HAS_TSS_EMULATION */ + +#endif /* WIN32 || ACE_HAS_TSS_EMULATION */ + +/*****************************************************************************/ + +#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + +// Moved class ACE_TSS_Ref declaration to OS.h so it can be visible to +// the single file of template instantiations. + +ACE_TSS_Ref::ACE_TSS_Ref (ACE_thread_t id) + : tid_(id) +{ + ACE_OS_TRACE ("ACE_TSS_Ref::ACE_TSS_Ref"); +} + +ACE_TSS_Ref::ACE_TSS_Ref (void) +{ + ACE_OS_TRACE ("ACE_TSS_Ref::ACE_TSS_Ref"); +} + +// Check for equality. +int +ACE_TSS_Ref::operator== (const ACE_TSS_Ref &info) const +{ + ACE_OS_TRACE ("ACE_TSS_Ref::operator=="); + + return this->tid_ == info.tid_; +} + +// Check for inequality. +ACE_SPECIAL_INLINE +int +ACE_TSS_Ref::operator != (const ACE_TSS_Ref &tss_ref) const +{ + ACE_OS_TRACE ("ACE_TSS_Ref::operator !="); + + return !(*this == tss_ref); +} + +// moved class ACE_TSS_Info declaration +// to OS.h so it can be visible to the +// single file of template instantiations + +ACE_TSS_Info::ACE_TSS_Info (ACE_thread_key_t key, + void (*dest)(void *), + void *tss_inst) + : key_ (key), + destructor_ (dest), + tss_obj_ (tss_inst), + thread_count_ (-1) +{ + ACE_OS_TRACE ("ACE_TSS_Info::ACE_TSS_Info"); +} + +ACE_TSS_Info::ACE_TSS_Info (void) + : key_ (ACE_OS::NULL_key), + destructor_ (0), + tss_obj_ (0), + thread_count_ (-1) +{ + ACE_OS_TRACE ("ACE_TSS_Info::ACE_TSS_Info"); +} + +# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T) +static inline int operator== (const ACE_thread_key_t &lhs, + const ACE_thread_key_t &rhs) +{ + return ! ACE_OS::memcmp (&lhs, &rhs, sizeof (ACE_thread_key_t)); +} + +static inline int operator!= (const ACE_thread_key_t &lhs, + const ACE_thread_key_t &rhs) +{ + return ! (lhs == rhs); +} +# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ + +// Check for equality. +int +ACE_TSS_Info::operator== (const ACE_TSS_Info &info) const +{ + ACE_OS_TRACE ("ACE_TSS_Info::operator=="); + + return this->key_ == info.key_; +} + +// Check for inequality. +int +ACE_TSS_Info::operator != (const ACE_TSS_Info &info) const +{ + ACE_OS_TRACE ("ACE_TSS_Info::operator !="); + + return !(*this == info); +} + +void +ACE_TSS_Info::dump (void) +{ +# if defined (ACE_HAS_DUMP) + // ACE_OS_TRACE ("ACE_TSS_Info::dump"); + +# if 0 + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("key_ = %u\n"), this->key_)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("destructor_ = %u\n"), this->destructor_)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("tss_obj_ = %u\n"), this->tss_obj_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +# endif /* 0 */ +# endif /* ACE_HAS_DUMP */ +} + +// Moved class ACE_TSS_Keys declaration to OS.h so it can be visible +// to the single file of template instantiations. + +ACE_TSS_Keys::ACE_TSS_Keys (void) +{ + for (u_int i = 0; i < ACE_WORDS; ++i) + { + key_bit_words_[i] = 0; + } +} + +ACE_SPECIAL_INLINE +void +ACE_TSS_Keys::find (const u_int key, u_int &word, u_int &bit) +{ + word = key / ACE_BITS_PER_WORD; + bit = key % ACE_BITS_PER_WORD; +} + +int +ACE_TSS_Keys::test_and_set (const ACE_thread_key_t key) +{ + ACE_KEY_INDEX (key_index, key); + u_int word, bit; + find (key_index, word, bit); + + if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit)) + { + return 1; + } + else + { + ACE_SET_BITS (key_bit_words_[word], 1 << bit); + return 0; + } +} + +int +ACE_TSS_Keys::test_and_clear (const ACE_thread_key_t key) +{ + ACE_KEY_INDEX (key_index, key); + u_int word, bit; + find (key_index, word, bit); + + if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit)) + { + ACE_CLR_BITS (key_bit_words_[word], 1 << bit); + return 0; + } + else + { + return 1; + } +} + +int +ACE_TSS_Keys::is_set (const ACE_thread_key_t key) const +{ + ACE_KEY_INDEX (key_index, key); + u_int word, bit; + find (key_index, word, bit); + + return ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit); +} + +/*****************************************************************************/ + +/** + * @class ACE_TSS_Cleanup + * + * @brief Singleton that knows how to clean up all the thread-specific + * resources for Win32. + * + * All this nonsense is required since Win32 doesn't + * automatically cleanup thread-specific storage on thread exit, + * unlike real operating systems... ;-) + */ +class ACE_TSS_Cleanup +{ +public: + static ACE_TSS_Cleanup *instance (void); + + ~ACE_TSS_Cleanup (void); + + /// Cleanup the thread-specific objects. Does _NOT_ exit the thread. + void exit (void *status); + + /// Insert a <key, destructor> tuple into the table. + int insert (ACE_thread_key_t key, void (*destructor)(void *), void *inst); + + /// Remove a <key, destructor> tuple from the table. + int remove (ACE_thread_key_t key); + + /// Detaches a tss_instance from its key. + int detach (void *inst); + + /// Mark a key as being used by this thread. + void key_used (ACE_thread_key_t key); + + /// Free all keys left in the table before destruction. + int free_all_keys_left (void); + + /// Indication of whether the ACE_TSS_CLEANUP_LOCK is usable, and + /// therefore whether we are in static constructor/destructor phase + /// or not. + static int lockable () { return instance_ != 0; } + +protected: + void dump (void); + + /// Ensure singleton. + ACE_TSS_Cleanup (void); + +private: + // Array of <ACE_TSS_Info> objects. + typedef ACE_TSS_Info ACE_TSS_TABLE[ACE_DEFAULT_THREAD_KEYS]; + typedef ACE_TSS_Info *ACE_TSS_TABLE_ITERATOR; + + /// Table of <ACE_TSS_Info>'s. + ACE_TSS_TABLE table_; + + /// Key for the thread-specific array of whether each TSS key is in use. + ACE_thread_key_t in_use_; + + /// Accessor for this threads ACE_TSS_Keys instance. + ACE_TSS_Keys *tss_keys (); + +# if defined (ACE_HAS_TSS_EMULATION) + /// Key that is used by in_use_. We save this key so that we know + /// not to call its destructor in free_all_keys_left (). + ACE_thread_key_t in_use_key_; +# endif /* ACE_HAS_TSS_EMULATION */ + + // = Static data. + /// Pointer to the singleton instance. + static ACE_TSS_Cleanup *instance_; +}; + +// = Static object initialization. + +// Pointer to the singleton instance. +ACE_TSS_Cleanup *ACE_TSS_Cleanup::instance_ = 0; + +ACE_TSS_Cleanup::~ACE_TSS_Cleanup (void) +{ + // Zero out the instance pointer to support lockable () accessor. + ACE_TSS_Cleanup::instance_ = 0; +} + +void +ACE_TSS_Cleanup::exit (void * /* status */) +{ + ACE_OS_TRACE ("ACE_TSS_Cleanup::exit"); + + ACE_TSS_TABLE_ITERATOR key_info = table_; + ACE_TSS_Info info_arr[ACE_DEFAULT_THREAD_KEYS]; + int info_ix = 0; + + // While holding the lock, we only collect the ACE_TSS_Info objects + // in an array without invoking the according destructors. + { + ACE_TSS_CLEANUP_GUARD + + // Iterate through all the thread-specific items and free them all + // up. + + for (unsigned int i = 0; + i < ACE_DEFAULT_THREAD_KEYS; + ++key_info, ++i) + { + if (key_info->key_ == ACE_OS::NULL_key || + ! key_info->key_in_use ()) continue; + + // If the key's ACE_TSS_Info in-use bit for this thread was set, + // unset it and decrement the key's thread_count_. + if (! tss_keys ()->test_and_clear (key_info->key_)) + { + --key_info->thread_count_; + } + + void *tss_info = 0; + + if (key_info->destructor_ + && ACE_OS::thr_getspecific (key_info->key_, &tss_info) == 0 + && tss_info) + { + info_arr[info_ix].key_ = key_info->key_; + info_arr[info_ix].destructor_ = key_info->destructor_; + info_arr[info_ix++].tss_obj_ = key_info->tss_obj_; + } + } + } + + // Now we have given up the ACE_TSS_Cleanup::lock_ and we start + // invoking destructors, in the reverse order of creation. + for (int i = info_ix - 1; i >= 0; --i) + { + void *tss_info = 0; + + ACE_OS::thr_getspecific (info_arr[i].key_, &tss_info); + + if (tss_info != 0) + { + // Only call the destructor if the value is non-zero for this + // thread. + (*info_arr[i].destructor_)(tss_info); + } + } + + // Acquire the ACE_TSS_CLEANUP_LOCK, then free TLS keys and remove + // entries from ACE_TSS_Info table. + { + ACE_TSS_CLEANUP_GUARD + +# if 0 + // We shouldn't free the key and remove it from the table here + // because if we do and some thread ends before other threads + // even get started (or their TSS object haven't been created yet,) + // it's entry will be removed from the table and we are in big chaos. + // For TSS object, these have been done in ACE_TSS_Cleanup::detach. + // Two other use cases will be user managed TSS'es and system wide + // TSS, ones are users responsibilities and the others should be + // persistant system wide. + for (int i = 0; i < index; i++) + { +# if defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + // Calling thr_keyfree here ensure the key + // gets removed appropriately. Notice that + // a key should be removed before freeing it. + ACE_OS::thr_keyfree (key_info->key_); +# else + // don't bother to free the key + this->remove (key_info->key_); +# endif /* ACE_WIN32 */ + } +# endif /* 0 */ + } +} + +int +ACE_TSS_Cleanup::free_all_keys_left (void) + // This is called from ACE_OS::cleanup_tss (). When this gets + // called, all threads should have exited except the main thread. + // No key should be freed from this routine. It there's any, + // something might be wrong. +{ + ACE_thread_key_t key_arr[ACE_DEFAULT_THREAD_KEYS]; + ACE_TSS_TABLE_ITERATOR key_info = table_; + unsigned int idx = 0; + unsigned int i; + + for (i = 0; + i < ACE_DEFAULT_THREAD_KEYS; + ++key_info, ++i) +# if defined (ACE_HAS_TSS_EMULATION) + if (key_info->key_ != in_use_key_) +# endif /* ACE_HAS_TSS_EMULATION */ + // Don't call ACE_OS::thr_keyfree () on ACE_TSS_Cleanup's own + // key. See the comments in ACE_OS::thr_key_detach (): the key + // doesn't get detached, so it will be in the table here. + // However, there's no resource associated with it, so we don't + // need to keyfree it. The dynamic memory associated with it + // was already deleted by ACE_TSS_Cleanup::exit (), so we don't + // want to access it again. + key_arr [idx++] = key_info->key_; + + for (i = 0; i < idx; i++) + if (key_arr[i] != ACE_OS::NULL_key) +# if defined (ACE_HAS_TSS_EMULATION) + ACE_OS::thr_keyfree (key_arr[i]); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + // Don't call ACE_OS::thr_keyfree here. It will try to use + // <in_use_> which has already been cleaned up here. + ::tsd_delete (key_arr[i]); +# else /* ACE_WIN32 */ + // Don't call ACE_OS::thr_keyfree here. It will try to use + // <in_use_> which has already been cleaned up here. + TlsFree (key_arr[i]); +# endif /* ACE_HAS_TSS_EMULATION */ + + return 0; +} + +extern "C" void +ACE_TSS_Cleanup_keys_destroyer (void *tss_keys) +{ + delete ACE_reinterpret_cast (ACE_TSS_Keys *, tss_keys); +} + +ACE_TSS_Cleanup::ACE_TSS_Cleanup (void) + : in_use_ (ACE_OS::NULL_key) +# if defined (ACE_HAS_TSS_EMULATION) + // ACE_TSS_Emulation::total_keys () provides the value of the next + // key to be created. + , in_use_key_ (ACE_TSS_Emulation::total_keys ()) +# endif /* ACE_HAS_TSS_EMULATION */ +{ + ACE_OS_TRACE ("ACE_TSS_Cleanup::ACE_TSS_Cleanup"); +} + +ACE_TSS_Cleanup * +ACE_TSS_Cleanup::instance (void) +{ + ACE_OS_TRACE ("ACE_TSS_Cleanup::instance"); + + // Create and initialize thread-specific key. + if (ACE_TSS_Cleanup::instance_ == 0) + { + // Insure that we are serialized! + ACE_TSS_CLEANUP_GUARD + + // Now, use the Double-Checked Locking pattern to make sure we + // only create the ACE_TSS_Cleanup instance once. + if (ACE_TSS_Cleanup::instance_ == 0) + ACE_NEW_RETURN (ACE_TSS_Cleanup::instance_, + ACE_TSS_Cleanup, + 0); + } + + return ACE_TSS_Cleanup::instance_; +} + +int +ACE_TSS_Cleanup::insert (ACE_thread_key_t key, + void (*destructor)(void *), + void *inst) +{ + ACE_OS_TRACE ("ACE_TSS_Cleanup::insert"); + ACE_TSS_CLEANUP_GUARD + + ACE_KEY_INDEX (key_index, key); + if (key_index < ACE_DEFAULT_THREAD_KEYS) + { + table_[key_index] = ACE_TSS_Info (key, destructor, inst); + return 0; + } + else + { + return -1; + } +} + +int +ACE_TSS_Cleanup::remove (ACE_thread_key_t key) +{ + ACE_OS_TRACE ("ACE_TSS_Cleanup::remove"); + ACE_TSS_CLEANUP_GUARD + + ACE_KEY_INDEX (key_index, key); + if (key_index < ACE_DEFAULT_THREAD_KEYS) + { + // "Remove" the TSS_Info table entry by zeroing out its key_ and + // destructor_ fields. Also, keep track of the number threads + // using the key. + ACE_TSS_Info &info = this->table_ [key_index]; + + // Don't bother to test/clear the in "use bit" if the program is + // shutting down. Doing so will cause a new ACE_TSS object to be + // created again. + if (!ACE_OS_Object_Manager::shutting_down ()) + tss_keys ()->test_and_clear (info.key_); + info.key_in_use (0); + info.key_ = ACE_OS::NULL_key; + info.destructor_ = 0; + return 0; + } + else + return -1; +} + +int +ACE_TSS_Cleanup::detach (void *inst) +{ + ACE_TSS_CLEANUP_GUARD + + ACE_TSS_TABLE_ITERATOR key_info = table_; + int success = 0; + int ref_cnt = 0; + + // Mark the key as detached in the TSS_Info table. + // It only works for the first key that "inst" owns. + // I don't know why. + for (unsigned int i = 0; + i < ACE_DEFAULT_THREAD_KEYS; + ++key_info, ++i) + { + if (key_info->tss_obj_ == inst) + { + key_info->tss_obj_ = 0; + ref_cnt = --key_info->thread_count_; + success = 1; + break; + } + } + + if (success == 0) + return -1; + else if (ref_cnt == 0) + { + // Mark the key as no longer being used. + key_info->key_in_use (0); +# if defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + ACE_thread_key_t temp_key = key_info->key_; +# endif /* ACE_WIN32 */ + int retv = this->remove (key_info->key_); + +# if defined (ACE_WIN32) + ::TlsFree (temp_key); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + ::tsd_delete (temp_key); +# endif /* ACE_WIN32 */ + return retv; + } + + return 0; +} + +void +ACE_TSS_Cleanup::key_used (ACE_thread_key_t key) +{ + // If the key's ACE_TSS_Info in-use bit for this thread is not set, + // set it and increment the key's thread_count_. + if (! tss_keys ()->test_and_set (key)) + { + ACE_TSS_CLEANUP_GUARD + + // Retrieve the key's ACE_TSS_Info and increment its thread_count_. + ACE_KEY_INDEX (key_index, key); + ACE_TSS_Info &key_info = this->table_ [key_index]; + if (!key_info.key_in_use ()) + key_info.key_in_use (1); + else + ++key_info.thread_count_; + } +} + +void +ACE_TSS_Cleanup::dump (void) +{ +# if defined (ACE_HAS_DUMP) + // Iterate through all the thread-specific items and dump them all. + + ACE_TSS_TABLE_ITERATOR key_info = table_; + for (unsigned int i = 0; + i < ACE_DEFAULT_THREAD_KEYS; + ++key_info, ++i) + key_info->dump (); +# endif /* ACE_HAS_DUMP */ +} + +ACE_TSS_Keys * +ACE_TSS_Cleanup::tss_keys () +{ + if (in_use_ == ACE_OS::NULL_key) + { + ACE_TSS_CLEANUP_GUARD + // Double-check; + if (in_use_ == ACE_OS::NULL_key) + { + // Initialize in_use_ with a new key. + if (ACE_OS::thr_keycreate (&in_use_, + &ACE_TSS_Cleanup_keys_destroyer)) + return 0; // Major problems, this should *never* happen! + } + } + + ACE_TSS_Keys *ts_keys = 0; + if (ACE_OS::thr_getspecific (in_use_, + ACE_reinterpret_cast (void **, &ts_keys)) == -1) + return 0; // This should not happen! + + if (ts_keys == 0) + { + ACE_NEW_RETURN (ts_keys, + ACE_TSS_Keys, + 0); + // Store the dynamically allocated pointer in thread-specific + // storage. + if (ACE_OS::thr_setspecific (in_use_, + ACE_reinterpret_cast (void *, + ts_keys)) == -1) + { + delete ts_keys; + return 0; // Major problems, this should *never* happen! + } + } + + return ts_keys; +} + +#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION || (ACE_PSOS && ACE_PSOS_HAS_TSS) */ + +/*****************************************************************************/ + +// = Static initialization. + +// This is necessary to deal with POSIX pthreads insanity. This +// guarantees that we've got a "zero'd" thread id even when +// ACE_thread_t, ACE_hthread_t, and ACE_thread_key_t are implemented +// as structures... Under no circumstances should these be given +// initial values. +// Note: these three objects require static construction. +ACE_thread_t ACE_OS::NULL_thread; +ACE_hthread_t ACE_OS::NULL_hthread; +#if defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + ACE_thread_key_t ACE_OS::NULL_key = ACE_static_cast (ACE_thread_key_t, -1); +#else /* ! ACE_HAS_TSS_EMULATION */ + ACE_thread_key_t ACE_OS::NULL_key; +#endif /* ! ACE_HAS_TSS_EMULATION */ + +#if defined (CHORUS) +KnCap ACE_OS::actorcaps_[ACE_CHORUS_MAX_ACTORS]; +// This is used to map an actor's id into a KnCap for killing and +// waiting actors. +#endif /* CHORUS */ + +/*****************************************************************************/ + +void +ACE_OS::cleanup_tss (const u_int main_thread) +{ +#if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + // Call TSS destructors for current thread. + ACE_TSS_Cleanup::instance ()->exit (0); +#endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 || ACE_PSOS_HAS_TSS */ + + if (main_thread) + { +#if !defined (ACE_HAS_TSS_EMULATION) && !defined (ACE_HAS_MINIMAL_ACE_OS) + // Just close the ACE_Log_Msg for the current (which should be + // main) thread. We don't have TSS emulation; if there's native + // TSS, it should call its destructors when the main thread + // exits. + ACE_Base_Thread_Adapter::close_log_msg (); +#endif /* ! ACE_HAS_TSS_EMULATION && ! ACE_HAS_MINIMAL_ACE_OS */ + +#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) +# if ! defined (ACE_HAS_TSS_EMULATION) + // Don't do this with TSS_Emulation, because the the + // ACE_TSS_Cleanup::instance () has already exited (). We can't + // safely access the TSS values that were created by the main + // thread. + + // Remove all TSS_Info table entries. + ACE_TSS_Cleanup::instance ()->free_all_keys_left (); +# endif /* ! ACE_HAS_TSS_EMULATION */ + + // Finally, free up the ACE_TSS_Cleanup instance. This method gets + // called by the ACE_Object_Manager. + delete ACE_TSS_Cleanup::instance (); +#endif /* WIN32 || ACE_HAS_TSS_EMULATION || ACE_PSOS_HAS_TSS */ + +#if defined (ACE_HAS_TSS_EMULATION) + ACE_TSS_Emulation::tss_close (); +#endif /* ACE_HAS_TSS_EMULATION */ + } +} + +#if defined (ACE_LACKS_COND_T) && ! defined (ACE_PSOS_DIAB_MIPS) +// NOTE: The ACE_OS::cond_* functions for some non-Unix platforms are +// defined here either because they're too big to be inlined, or +// to avoid use before definition if they were inline. + +// @@ The following functions could be inlined if i could figure where +// to put it among the #ifdefs! +int +ACE_OS::condattr_init (ACE_condattr_t &attributes, + int type) +{ + attributes.type = type; + return 0; +} + +int +ACE_OS::condattr_destroy (ACE_condattr_t &) +{ + return 0; +} + +int +ACE_OS::cond_broadcast (ACE_cond_t *cv) +{ + ACE_OS_TRACE ("ACE_OS::cond_broadcast"); +# if defined (ACE_HAS_THREADS) + // The <external_mutex> must be locked before this call is made. + + // This is needed to ensure that <waiters_> and <was_broadcast_> are + // consistent relative to each other. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + int have_waiters = 0; + + if (cv->waiters_ > 0) + { + // We are broadcasting, even if there is just one waiter... + // Record the fact that we are broadcasting. This helps the + // cond_wait() method know how to optimize itself. Be sure to + // set this with the <waiters_lock_> held. + cv->was_broadcast_ = 1; + have_waiters = 1; + } + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + int result = 0; + if (have_waiters) + { + // Wake up all the waiters. + if (ACE_OS::sema_post (&cv->sema_, cv->waiters_) == -1) + result = -1; + // Wait for all the awakened threads to acquire their part of + // the counting semaphore. +# if defined (VXWORKS) || defined (ACE_PSOS) + else if (ACE_OS::sema_wait (&cv->waiters_done_) == -1) +# else + else if (ACE_OS::event_wait (&cv->waiters_done_) == -1) +# endif /* VXWORKS */ + result = -1; + // This is okay, even without the <waiters_lock_> held because + // no other waiter threads can wake up to access it. + cv->was_broadcast_ = 0; + } + return result; +# else + ACE_UNUSED_ARG (cv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::cond_destroy (ACE_cond_t *cv) +{ + ACE_OS_TRACE ("ACE_OS::cond_destroy"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) + ACE_OS::event_destroy (&cv->waiters_done_); +# elif defined (VXWORKS) || defined (ACE_PSOS) + ACE_OS::sema_destroy (&cv->waiters_done_); +# endif /* VXWORKS */ + ACE_OS::thread_mutex_destroy (&cv->waiters_lock_); + return ACE_OS::sema_destroy (&cv->sema_); +# else + ACE_UNUSED_ARG (cv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::cond_init (ACE_cond_t *cv, + ACE_condattr_t &attributes, + const char *name, void *arg) +{ + return ACE_OS::cond_init (cv, attributes.type, name, arg); +} + +# if defined (ACE_HAS_WCHAR) +int +ACE_OS::cond_init (ACE_cond_t *cv, + ACE_condattr_t &attributes, + const wchar_t *name, void *arg) +{ + return ACE_OS::cond_init (cv, attributes.type, name, arg); +} +# endif /* ACE_HAS_WCHAR */ + +int +ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg) +{ + ACE_OS_TRACE ("ACE_OS::cond_init"); +# if defined (ACE_HAS_THREADS) + cv->waiters_ = 0; + cv->was_broadcast_ = 0; + + int result = 0; + if (ACE_OS::sema_init (&cv->sema_, 0, type, name, arg) == -1) + result = -1; + else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1) + result = -1; +# if defined (VXWORKS) || defined (ACE_PSOS) + else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1) +# else + else if (ACE_OS::event_init (&cv->waiters_done_) == -1) +# endif /* VXWORKS */ + result = -1; + return result; +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +# if defined (ACE_HAS_WCHAR) +int +ACE_OS::cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg) +{ + ACE_OS_TRACE ("ACE_OS::cond_init"); +# if defined (ACE_HAS_THREADS) + cv->waiters_ = 0; + cv->was_broadcast_ = 0; + + int result = 0; + if (ACE_OS::sema_init (&cv->sema_, 0, type, name, arg) == -1) + result = -1; + else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1) + result = -1; +# if defined (VXWORKS) || defined (ACE_PSOS) + else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1) +# else + else if (ACE_OS::event_init (&cv->waiters_done_) == -1) +# endif /* VXWORKS */ + result = -1; + return result; +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +# endif /* ACE_HAS_WCHAR */ + +int +ACE_OS::cond_signal (ACE_cond_t *cv) +{ + ACE_OS_TRACE ("ACE_OS::cond_signal"); +# if defined (ACE_HAS_THREADS) + // If there aren't any waiters, then this is a no-op. Note that + // this function *must* be called with the <external_mutex> held + // since other wise there is a race condition that can lead to the + // lost wakeup bug... This is needed to ensure that the <waiters_> + // value is not in an inconsistent internal state while being + // updated by another thread. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + int have_waiters = cv->waiters_ > 0; + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + if (have_waiters != 0) + return ACE_OS::sema_post (&cv->sema_); + else + return 0; // No-op +# else + ACE_UNUSED_ARG (cv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::cond_wait (ACE_cond_t *cv, + ACE_mutex_t *external_mutex) +{ + ACE_OS_TRACE ("ACE_OS::cond_wait"); +# if defined (ACE_HAS_THREADS) + // Prevent race conditions on the <waiters_> count. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + cv->waiters_++; + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + int result = 0; + +# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) + if (external_mutex->type_ == USYNC_PROCESS) + // This call will automatically release the mutex and wait on the semaphore. + ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (external_mutex->proc_mutex_, + cv->sema_, INFINITE, FALSE), + result), + int, -1, result); + else +# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ + { + // We keep the lock held just long enough to increment the count of + // waiters by one. Note that we can't keep it held across the call + // to ACE_OS::sema_wait() since that will deadlock other calls to + // ACE_OS::cond_signal(). + if (ACE_OS::mutex_unlock (external_mutex) != 0) + return -1; + + // Wait to be awakened by a ACE_OS::cond_signal() or + // ACE_OS::cond_broadcast(). + result = ACE_OS::sema_wait (&cv->sema_); + } + + // Reacquire lock to avoid race conditions on the <waiters_> count. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + + // We're ready to return, so there's one less waiter. + cv->waiters_--; + + int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; + + // Release the lock so that other collaborating threads can make + // progress. + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + if (result == -1) + // Bad things happened, so let's just return below. + /* NOOP */; +# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) + else if (external_mutex->type_ == USYNC_PROCESS) + { + if (last_waiter) + + // This call atomically signals the <waiters_done_> event and + // waits until it can acquire the mutex. This is important to + // prevent unfairness. + ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (cv->waiters_done_, + external_mutex->proc_mutex_, + INFINITE, FALSE), + result), + int, -1, result); + else + // We must always regain the <external_mutex>, even when + // errors occur because that's the guarantee that we give to + // our callers. + ACE_OS::mutex_lock (external_mutex); + + return result; + /* NOTREACHED */ + } +# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ + // If we're the last waiter thread during this particular broadcast + // then let all the other threads proceed. + else if (last_waiter) +# if defined (VXWORKS) || defined (ACE_PSOS) + ACE_OS::sema_post (&cv->waiters_done_); +# else + ACE_OS::event_signal (&cv->waiters_done_); +# endif /* VXWORKS */ + + // We must always regain the <external_mutex>, even when errors + // occur because that's the guarantee that we give to our callers. + ACE_OS::mutex_lock (external_mutex); + + return result; +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (external_mutex); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::cond_timedwait (ACE_cond_t *cv, + ACE_mutex_t *external_mutex, + ACE_Time_Value *timeout) +{ + ACE_OS_TRACE ("ACE_OS::cond_timedwait"); +# if defined (ACE_HAS_THREADS) + // Handle the easy case first. + if (timeout == 0) + return ACE_OS::cond_wait (cv, external_mutex); +# if defined (ACE_HAS_WTHREADS) || defined (VXWORKS) || defined (ACE_PSOS) + + // Prevent race conditions on the <waiters_> count. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + cv->waiters_++; + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + int result = 0; + ACE_Errno_Guard error (errno, 0); + int msec_timeout; + + if (timeout->sec () == 0 && timeout->usec () == 0) + msec_timeout = 0; // Do a "poll." + else + { + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // WaitForSingleObjects() expects). + ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + + // Watchout for situations where a context switch has caused the + // current time to be > the timeout. + if (relative_time < ACE_Time_Value::zero) + msec_timeout = 0; + else + msec_timeout = relative_time.msec (); + } + +# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) + if (external_mutex->type_ == USYNC_PROCESS) + // This call will automatically release the mutex and wait on the + // semaphore. + result = ::SignalObjectAndWait (external_mutex->proc_mutex_, + cv->sema_, + msec_timeout, + FALSE); + else +# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ + { + // We keep the lock held just long enough to increment the count + // of waiters by one. Note that we can't keep it held across + // the call to WaitForSingleObject since that will deadlock + // other calls to ACE_OS::cond_signal(). + if (ACE_OS::mutex_unlock (external_mutex) != 0) + return -1; + + // Wait to be awakened by a ACE_OS::signal() or + // ACE_OS::broadcast(). +# if defined (ACE_WIN32) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + result = ::WaitForSingleObject (cv->sema_, msec_timeout); +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + // Can't use Win32 API on our simulated semaphores. + result = ACE_OS::sema_wait (&cv->sema_, + timeout); +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + // Inline the call to ACE_OS::sema_wait () because it takes an + // ACE_Time_Value argument. Avoid the cost of that conversion . . . + u_long ticks = (KC_TICKS2SEC * msec_timeout) / ACE_ONE_SECOND_IN_MSECS; + //Tick set to 0 tells pSOS to wait forever is SM_WAIT is set. + if(ticks == 0) + result = ::sm_p (cv->sema_.sema_, SM_NOWAIT, ticks); //no timeout + else + result = ::sm_p (cv->sema_.sema_, SM_WAIT, ticks); +# elif defined (VXWORKS) + // Inline the call to ACE_OS::sema_wait () because it takes an + // ACE_Time_Value argument. Avoid the cost of that conversion . . . + int ticks_per_sec = ::sysClkRateGet (); + int ticks = msec_timeout * ticks_per_sec / ACE_ONE_SECOND_IN_MSECS; + result = ::semTake (cv->sema_.sema_, ticks); +# endif /* ACE_WIN32 || VXWORKS */ + } + + // Reacquire lock to avoid race conditions. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + cv->waiters_--; + + int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; + + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + +# if defined (ACE_WIN32) + if (result != WAIT_OBJECT_0) + { + switch (result) + { + case WAIT_TIMEOUT: + error = ETIME; + break; + default: + error = ::GetLastError (); + break; + } + result = -1; + } +# elif defined (ACE_PSOS) + if (result != 0) + { + switch (result) + { + case ERR_TIMEOUT: // Timeout occured with SM_WAIT + case ERR_NOMSG: // Didn't acquire semaphore w/ SM_NOWAIT (ticks=0) + error = ETIME; + break; + default: + error = errno; + break; + } + result = -1; + } +# elif defined (VXWORKS) + if (result == ERROR) + { + switch (errno) + { + case S_objLib_OBJ_TIMEOUT: + error = ETIME; + break; + case S_objLib_OBJ_UNAVAILABLE: + if (msec_timeout == 0) + error = ETIME; + break; + default: + error = errno; + break; + } + result = -1; + } +# endif /* ACE_WIN32 || VXWORKS */ +# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT) + if (external_mutex->type_ == USYNC_PROCESS) + { + if (last_waiter) + // This call atomically signals the <waiters_done_> event and + // waits until it can acquire the mutex. This is important to + // prevent unfairness. + ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (cv->waiters_done_, + external_mutex->proc_mutex_, + INFINITE, FALSE), + result), + int, -1, result); + else + // We must always regain the <external_Mutex>, even when + // errors occur because that's the guarantee that we give to + // our callers. + ACE_OS::mutex_lock (external_mutex); + + return result; + /* NOTREACHED */ + } +# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */ + // Note that this *must* be an "if" statement rather than an "else + // if" statement since the caller may have timed out and hence the + // result would have been -1 above. + if (last_waiter) + // Release the signaler/broadcaster if we're the last waiter. +# if defined (ACE_WIN32) + ACE_OS::event_signal (&cv->waiters_done_); +# else + ACE_OS::sema_post (&cv->waiters_done_); +# endif /* ACE_WIN32 */ + + // We must always regain the <external_mutex>, even when errors + // occur because that's the guarantee that we give to our callers. + ACE_OS::mutex_lock (external_mutex); + + return result; +# endif /* ACE_HAS_WTHREADS || ACE_HAS_VXWORKS || ACE_PSOS */ +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (external_mutex); + ACE_UNUSED_ARG (timeout); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +# if defined (ACE_HAS_WTHREADS) +int +ACE_OS::cond_timedwait (ACE_cond_t *cv, + ACE_thread_mutex_t *external_mutex, + ACE_Time_Value *timeout) +{ + ACE_OS_TRACE ("ACE_OS::cond_timedwait"); +# if defined (ACE_HAS_THREADS) + // Handle the easy case first. + if (timeout == 0) + return ACE_OS::cond_wait (cv, external_mutex); + + // Prevent race conditions on the <waiters_> count. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + cv->waiters_++; + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + int result = 0; + int error = 0; + int msec_timeout; + + if (timeout->sec () == 0 && timeout->usec () == 0) + msec_timeout = 0; // Do a "poll." + else + { + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // WaitForSingleObjects() expects). + ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + + // Watchout for situations where a context switch has caused the + // current time to be > the timeout. + if (relative_time < ACE_Time_Value::zero) + msec_timeout = 0; + else + msec_timeout = relative_time.msec (); + } + + // We keep the lock held just long enough to increment the count of + // waiters by one. Note that we can't keep it held across the call + // to WaitForSingleObject since that will deadlock other calls to + // ACE_OS::cond_signal(). + if (ACE_OS::thread_mutex_unlock (external_mutex) != 0) + return -1; + + // Wait to be awakened by a ACE_OS::signal() or ACE_OS::broadcast(). +# if defined (ACE_USES_WINCE_SEMA_SIMULATION) + // Can't use Win32 API on simulated semaphores. + result = ACE_OS::sema_wait (&cv->sema_, + timeout); + + if (result == -1 && errno == ETIME) + result = WAIT_TIMEOUT; +# else + result = ::WaitForSingleObject (cv->sema_, msec_timeout); +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ + + // Reacquire lock to avoid race conditions. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + + cv->waiters_--; + + int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; + + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + if (result != WAIT_OBJECT_0) + { + switch (result) + { + case WAIT_TIMEOUT: + error = ETIME; + break; + default: + error = ::GetLastError (); + break; + } + result = -1; + } + + if (last_waiter) + // Release the signaler/broadcaster if we're the last waiter. + ACE_OS::event_signal (&cv->waiters_done_); + + // We must always regain the <external_mutex>, even when errors + // occur because that's the guarantee that we give to our callers. + ACE_OS::thread_mutex_lock (external_mutex); + errno = error; + return result; +# else + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::cond_wait (ACE_cond_t *cv, + ACE_thread_mutex_t *external_mutex) +{ + ACE_OS_TRACE ("ACE_OS::cond_wait"); +# if defined (ACE_HAS_THREADS) + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + cv->waiters_++; + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + int result = 0; + int error = 0; + + // We keep the lock held just long enough to increment the count of + // waiters by one. Note that we can't keep it held across the call + // to ACE_OS::sema_wait() since that will deadlock other calls to + // ACE_OS::cond_signal(). + if (ACE_OS::thread_mutex_unlock (external_mutex) != 0) + return -1; + + // Wait to be awakened by a ACE_OS::cond_signal() or + // ACE_OS::cond_broadcast(). +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + result = ::WaitForSingleObject (cv->sema_, INFINITE); +# else + // Can't use Win32 API on simulated semaphores. + result = ACE_OS::sema_wait (&cv->sema_); + + if (result != WAIT_OBJECT_0 && errno == ETIME) + result = WAIT_TIMEOUT; + +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ + + // Reacquire lock to avoid race conditions. + ACE_OS::thread_mutex_lock (&cv->waiters_lock_); + + cv->waiters_--; + + int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0; + + ACE_OS::thread_mutex_unlock (&cv->waiters_lock_); + + if (result != WAIT_OBJECT_0) + { + switch (result) + { + case WAIT_TIMEOUT: + error = ETIME; + break; + default: + error = ::GetLastError (); + break; + } + } + else if (last_waiter) + // Release the signaler/broadcaster if we're the last waiter. + ACE_OS::event_signal (&cv->waiters_done_); + + // We must always regain the <external_mutex>, even when errors + // occur because that's the guarantee that we give to our callers. + ACE_OS::thread_mutex_lock (external_mutex); + + // Reset errno in case mutex_lock() also fails... + errno = error; + return result; +# else + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +# endif /* ACE_HAS_WTHREADS */ +#endif /* ACE_LACKS_COND_T */ + +int +ACE_OS::lwp_getparams (ACE_Sched_Params &sched_params) +{ +#if defined (ACE_HAS_STHREADS) || defined (sun) + // Get the class TS and RT class IDs. + ACE_id_t rt_id; + ACE_id_t ts_id; + if (ACE_OS::scheduling_class ("RT", rt_id) == -1 + || ACE_OS::scheduling_class ("TS", ts_id) == -1) + return -1; + + // Get this LWP's scheduling parameters. + pcparms_t pcparms; + // The following is just to avoid Purify warnings about unitialized + // memory reads. + ACE_OS::memset (&pcparms, 0, sizeof pcparms); + pcparms.pc_cid = PC_CLNULL; + + if (ACE_OS::priority_control (P_LWPID, + P_MYID, + PC_GETPARMS, + (char *) &pcparms) == -1) + return -1; + else if (pcparms.pc_cid == rt_id) + { + // RT class. + rtparms_t rtparms; + ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms); + + sched_params.policy (ACE_SCHED_FIFO); + sched_params.priority (rtparms.rt_pri); + sched_params.scope (ACE_SCOPE_THREAD); + ACE_Time_Value quantum (rtparms.rt_tqsecs, + rtparms.rt_tqnsecs == RT_TQINF + ? 0 : rtparms.rt_tqnsecs * 1000); + sched_params.quantum (quantum); + return 0; + } + else if (pcparms.pc_cid == ts_id) + { + /* TS class */ + tsparms_t tsparms; + ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms); + + sched_params.policy (ACE_SCHED_OTHER); + sched_params.priority (tsparms.ts_upri); + sched_params.scope (ACE_SCOPE_THREAD); + return 0; + } + else + return -1; + +#else /* ! ACE_HAS_STHREADS && ! sun */ + ACE_UNUSED_ARG (sched_params); + ACE_NOTSUP_RETURN (-1); +#endif /* ! ACE_HAS_STHREADS && ! sun */ +} + +int +ACE_OS::lwp_setparams (const ACE_Sched_Params &sched_params) +{ +#if defined (ACE_HAS_STHREADS) || defined (sun) + ACE_Sched_Params lwp_params (sched_params); + lwp_params.scope (ACE_SCOPE_LWP); + return ACE_OS::sched_params (lwp_params); +#else /* ! ACE_HAS_STHREADS && ! sun */ + ACE_UNUSED_ARG (sched_params); + ACE_NOTSUP_RETURN (-1); +#endif /* ! ACE_HAS_STHREADS && ! sun */ +} + +void +ACE_OS::mutex_lock_cleanup (void *mutex) +{ + ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex; + ACE_OS::mutex_unlock (p_lock); +# else + ACE_UNUSED_ARG (mutex); +# endif /* ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (mutex); +#endif /* ACE_HAS_THREADS */ +} + +#if !defined (ACE_HAS_THREADS) || defined (ACE_LACKS_RWLOCK_T) +int +ACE_OS::rwlock_init (ACE_rwlock_t *rw, + int type, + const ACE_TCHAR *name, + void *arg) +{ + // ACE_OS_TRACE ("ACE_OS::rwlock_init"); +# if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_RWLOCK_T) + // NT, POSIX, and VxWorks don't support this natively. + ACE_UNUSED_ARG (name); + int result = -1; + + // Since we cannot use the user specified name for all three + // objects, we will create three completely new names. + ACE_TCHAR name1[ACE_UNIQUE_NAME_LEN]; + ACE_TCHAR name2[ACE_UNIQUE_NAME_LEN]; + ACE_TCHAR name3[ACE_UNIQUE_NAME_LEN]; + ACE_TCHAR name4[ACE_UNIQUE_NAME_LEN]; + + ACE_OS::unique_name ((const void *) &rw->lock_, + name1, + ACE_UNIQUE_NAME_LEN); + ACE_OS::unique_name ((const void *) &rw->waiting_readers_, + name2, + ACE_UNIQUE_NAME_LEN); + ACE_OS::unique_name ((const void *) &rw->waiting_writers_, + name3, + ACE_UNIQUE_NAME_LEN); + ACE_OS::unique_name ((const void *) &rw->waiting_important_writer_, + name4, + ACE_UNIQUE_NAME_LEN); + + ACE_condattr_t attributes; + if (ACE_OS::condattr_init (attributes, type) == 0) + { + if (ACE_OS::mutex_init (&rw->lock_, type, name1, + (ACE_mutexattr_t *) arg) == 0 + && ACE_OS::cond_init (&rw->waiting_readers_, + attributes, name2, arg) == 0 + && ACE_OS::cond_init (&rw->waiting_writers_, + attributes, name3, arg) == 0 + && ACE_OS::cond_init (&rw->waiting_important_writer_, + attributes, name4, arg) == 0) + { + // Success! + rw->ref_count_ = 0; + rw->num_waiting_writers_ = 0; + rw->num_waiting_readers_ = 0; + rw->important_writer_ = 0; + result = 0; + } + ACE_OS::condattr_destroy (attributes); + } + + if (result == -1) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + ACE_OS::mutex_destroy (&rw->lock_); + ACE_OS::cond_destroy (&rw->waiting_readers_); + ACE_OS::cond_destroy (&rw->waiting_writers_); + ACE_OS::cond_destroy (&rw->waiting_important_writer_); + } + return result; +# else + ACE_UNUSED_ARG (rw); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +#endif /* ! ACE_HAS_THREADS || ACE_LACKS_RWLOCK_T */ + +int +ACE_OS::sched_params (const ACE_Sched_Params &sched_params, + ACE_id_t id) +{ + ACE_OS_TRACE ("ACE_OS::sched_params"); +#if defined (CHORUS) + ACE_UNUSED_ARG (id); + int result; + struct sched_param param; + ACE_thread_t thr_id = ACE_OS::thr_self (); + + param.sched_priority = sched_params.priority (); + + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, + sched_params.policy (), + ¶m), + result), + int, -1); +#elif defined (ACE_HAS_STHREADS) + return ACE_OS::set_scheduling_params (sched_params, id); +#elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED) + ACE_UNUSED_ARG (id); + if (sched_params.quantum () != ACE_Time_Value::zero) + { + // quantums not supported + errno = EINVAL; + return -1; + } + + // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for + // providing this code for 1003.1c PThreads. Please note that this + // has only been tested for POSIX 1003.1c threads, and may cause + // problems with other PThreads flavors! + + struct sched_param param; + param.sched_priority = sched_params.priority (); + + if (sched_params.scope () == ACE_SCOPE_PROCESS) + { + int result = ::sched_setscheduler (0, // this process + sched_params.policy (), + ¶m) == -1 ? -1 : 0; +# if defined (DIGITAL_UNIX) + return result == 0 + ? // Use priocntl (2) to set the process in the RT class, + // if using an RT policy. + ACE_OS::set_scheduling_params (sched_params) + : result; +# else /* ! DIGITAL_UNIX */ + return result; +# endif /* ! DIGITAL_UNIX */ + } + else if (sched_params.scope () == ACE_SCOPE_THREAD) + { + ACE_thread_t thr_id = ACE_OS::thr_self (); + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + return (::pthread_setscheduler (thr_id, + sched_params.policy (), + sched_params.priority()) == -1 ? -1 : 0); +# else + int result; + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, + sched_params.policy (), + ¶m), + result), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + } +# if defined (sun) + // We need to be able to set LWP priorities on Suns, even without + // ACE_HAS_STHREADS, to obtain preemption. + else if (sched_params.scope () == ACE_SCOPE_LWP) + return ACE_OS::set_scheduling_params (sched_params, id); +# endif /* sun */ + else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX + { + errno = EINVAL; + return -1; + } + +#elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + + // PharLap ETS can act on the current thread - it can set the + // quantum also, unlike Win32. All this only works on the RT + // version. +# if defined (ACE_HAS_PHARLAP_RT) + if (id != ACE_SELF) + ACE_NOTSUP_RETURN (-1); + + if (sched_params.quantum() != ACE_Time_Value::zero) + EtsSetTimeSlice (sched_params.quantum().msec()); + +# else + ACE_UNUSED_ARG (id); + + if (sched_params.scope () != ACE_SCOPE_PROCESS + || sched_params.quantum () != ACE_Time_Value::zero) + { + // Win32 only allows setting priority class (therefore, policy) + // at the process level. I don't know of a way to set the + // quantum. + errno = EINVAL; + return -1; + } + + // Set the priority class of this process to the REALTIME process class + // _if_ the policy is ACE_SCHED_FIFO. Otherwise, set to NORMAL. + if (!::SetPriorityClass (::GetCurrentProcess (), + (sched_params.policy () == ACE_SCHED_FIFO || + sched_params.policy () == ACE_SCHED_RR) + ? REALTIME_PRIORITY_CLASS + : NORMAL_PRIORITY_CLASS)) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } +# endif /* ACE_HAS_PHARLAP_RT */ + + // Set the thread priority on the current thread. + return ACE_OS::thr_setprio (sched_params.priority ()); + +#elif defined (VXWORKS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (id); + + // There is only one class of priorities on VxWorks, and no time + // quanta. So, just set the current thread's priority. + + if (sched_params.policy () != ACE_SCHED_FIFO + || sched_params.scope () != ACE_SCOPE_PROCESS + || sched_params.quantum () != ACE_Time_Value::zero) + { + errno = EINVAL; + return -1; + } + + // Set the thread priority on the current thread. + return ACE_OS::thr_setprio (sched_params.priority ()); +#else + ACE_UNUSED_ARG (sched_params); + ACE_UNUSED_ARG (id); + ACE_NOTSUP_RETURN (-1); +#endif /* CHORUS */ +} + +int +ACE_OS::scheduling_class (const char *class_name, ACE_id_t &id) +{ +#if defined (ACE_HAS_PRIOCNTL) + // Get the priority class ID. + pcinfo_t pcinfo; + // The following is just to avoid Purify warnings about unitialized + // memory reads. + ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); + + ACE_OS::strcpy (pcinfo.pc_clname, class_name); + if (ACE_OS::priority_control (P_ALL /* ignored */, + P_MYID /* ignored */, + PC_GETCID, + (char *) &pcinfo) == -1) + { + return -1; + } + else + { + id = pcinfo.pc_cid; + return 0; + } +#else /* ! ACE_HAS_PRIOCNTL */ + ACE_UNUSED_ARG (class_name); + ACE_UNUSED_ARG (id); + ACE_NOTSUP_RETURN (-1); +#endif /* ! ACE_HAS_PRIOCNTL */ +} + +int +ACE_OS::set_scheduling_params (const ACE_Sched_Params &sched_params, + ACE_id_t id) +{ +#if defined (ACE_HAS_PRIOCNTL) + // Set priority class, priority, and quantum of this LWP or process as + // specified in sched_params. + + // Get the priority class ID. + ACE_id_t class_id; + if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER ? + "TS" : + "RT", class_id) == -1) + { + return -1; + } + + pcparms_t pcparms; + // The following is just to avoid Purify warnings about unitialized + // memory reads. + ACE_OS::memset (&pcparms, 0, sizeof pcparms); + + pcparms.pc_cid = class_id; + + if (sched_params.policy () == ACE_SCHED_OTHER && + sched_params.quantum () == ACE_Time_Value::zero) + // SunOS doesn't support non-zero quantums in time-sharing class: use + // real-time class instead. + { + tsparms_t tsparms; + // The following is just to avoid Purify warnings about unitialized + // memory reads. + ACE_OS::memset (&tsparms, 0, sizeof tsparms); + + // Don't change ts_uprilim (user priority limit) + tsparms.ts_uprilim = TS_NOCHANGE; + tsparms.ts_upri = sched_params.priority (); + + // Package up the TS class ID and parameters for the + // priority_control () call. + ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms); + } + else if (sched_params.policy () == ACE_SCHED_FIFO || + (sched_params.policy () == ACE_SCHED_RR && + sched_params.quantum () != ACE_Time_Value::zero)) + // must have non-zero quantum for RR, to make it meaningful + // A zero quantum with FIFO has special significance: it actually + // means infinite time quantum, i.e., run-to-completion. + { + rtparms_t rtparms; + // The following is just to avoid Purify warnings about unitialized + // memory reads. + ACE_OS::memset (&rtparms, 0, sizeof rtparms); + + rtparms.rt_pri = sched_params.priority (); + + if (sched_params.quantum () == ACE_Time_Value::zero) + { + // rtparms.rt_tqsecs is ignored with RT_TQINF + rtparms.rt_tqnsecs = RT_TQINF; + } + else + { + rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec (); + rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000; + } + + // Package up the RT class ID and parameters for the + // priority_control () call. + ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms); + } + else + { + errno = EINVAL; + return -1; + } + + if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD + ? ACE_SCOPE_PROCESS + : sched_params.scope ()), + id, + PC_SETPARMS, + (char *) &pcparms) < 0) + { + return ACE_OS::last_error (); + } + + return 0; +#else /* ! ACE_HAS_PRIOCNTL */ + ACE_UNUSED_ARG (sched_params); + ACE_UNUSED_ARG (id); + ACE_NOTSUP_RETURN (-1); +#endif /* ! ACE_HAS_PRIOCNTL */ +} + +int +ACE_OS::thr_create (ACE_THR_FUNC func, + void *args, + long flags, + ACE_thread_t *thr_id, + ACE_hthread_t *thr_handle, + long priority, + void *stack, + size_t stacksize, + ACE_Base_Thread_Adapter *thread_adapter) +{ + ACE_OS_TRACE ("ACE_OS::thr_create"); + + if (ACE_BIT_DISABLED (flags, THR_DETACHED) && + ACE_BIT_DISABLED (flags, THR_JOINABLE)) + ACE_SET_BITS (flags, THR_JOINABLE); + +#if defined (ACE_NO_THREAD_ADAPTER) +# define ACE_THREAD_FUNCTION func +# define ACE_THREAD_ARGUMENT args +#else /* ! defined (ACE_NO_THREAD_ADAPTER) */ +# if defined (ACE_PSOS) +# define ACE_THREAD_FUNCTION (PSOS_TASK_ENTRY_POINT) thread_args->entry_point () +# else +# define ACE_THREAD_FUNCTION thread_args->entry_point () +# endif /* defined (ACE_PSOS) */ +# define ACE_THREAD_ARGUMENT thread_args +#endif /* ! defined (ACE_NO_THREAD_ADAPTER) */ + + + ACE_Base_Thread_Adapter *thread_args; + if (thread_adapter == 0) + +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + ACE_NEW_RETURN (thread_args, + ACE_OS_Thread_Adapter (func, args, + (ACE_THR_C_FUNC) ace_thread_adapter, + ACE_OS_Object_Manager::seh_except_selector(), + ACE_OS_Object_Manager::seh_except_handler()), + -1); +#else + ACE_NEW_RETURN (thread_args, + ACE_OS_Thread_Adapter (func, args, + (ACE_THR_C_FUNC) ace_thread_adapter), + -1); + +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + else + thread_args = thread_adapter; + +#if defined (ACE_HAS_THREADS) + + // *** Set Stack Size +# if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) + if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE) + stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE; +# endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ + +# if !defined (VXWORKS) + // On VxWorks, the OS will provide a task name if the user doesn't. + // So, we don't need to create a tmp_thr. If the caller of this + // member function is the Thread_Manager, than thr_id will be non-zero + // anyways. + ACE_thread_t tmp_thr; + + if (thr_id == 0) + thr_id = &tmp_thr; +# endif /* ! VXWORKS */ + + ACE_hthread_t tmp_handle; + if (thr_handle == 0) + thr_handle = &tmp_handle; + +# if defined (ACE_HAS_PTHREADS) + + int result; + pthread_attr_t attr; +# if defined (ACE_HAS_PTHREADS_DRAFT4) + if (::pthread_attr_create (&attr) != 0) +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + if (::pthread_attr_init (&attr) != 0) +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + +# if defined (CHORUS) + // If it is a super actor, we can't set stacksize. But for the time + // being we are all non-super actors. Should be fixed to take care + // of super actors!!! + if (stacksize == 0) + stacksize = ACE_CHORUS_DEFAULT_MIN_STACK_SIZE; + else if (stacksize < ACE_CHORUS_DEFAULT_MIN_STACK_SIZE) + stacksize = ACE_CHORUS_DEFAULT_MIN_STACK_SIZE; +# endif /*CHORUS */ + +# if defined (ACE_HAS_PTHREAD_SETSTACK) + if ((stacksize != 0) && (stack != 0)) +# else + if (stacksize != 0) +# endif /* ACE_HAS_PTHREAD_SETSTACK */ + { + size_t size = stacksize; + +# if defined (PTHREAD_STACK_MIN) + if (size < ACE_static_cast (size_t, PTHREAD_STACK_MIN)) + size = PTHREAD_STACK_MIN; +# endif /* PTHREAD_STACK_MIN */ + +# if !defined (ACE_LACKS_THREAD_STACK_SIZE) // JCEJ 12/17/96 +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + if (::pthread_attr_setstacksize (&attr, size) != 0) +# else +# if defined (ACE_HAS_PTHREAD_SETSTACK) + if (ACE_ADAPT_RETVAL(pthread_attr_setstack (&attr, stack, size), result) == -1) +# else + if (ACE_ADAPT_RETVAL(pthread_attr_setstacksize (&attr, size), result) == -1) +# endif /* ACE_HAS_PTHREAD_SETSTACK */ +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } +# else + ACE_UNUSED_ARG (size); +# endif /* !ACE_LACKS_THREAD_STACK_SIZE */ + } + + // *** Set Stack Address +# if !defined (ACE_HAS_PTHREAD_SETSTACK) +# if !defined (ACE_LACKS_THREAD_STACK_ADDR) + if (stack != 0) + { + if (::pthread_attr_setstackaddr (&attr, stack) != 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } +# else + ACE_UNUSED_ARG (stack); +# endif /* !ACE_LACKS_THREAD_STACK_ADDR */ +# endif /* ACE_HAS_PTHREAD_SETSTACK */ + + // *** Deal with various attributes + if (flags != 0) + { + // *** Set Detach state +# if !defined (ACE_LACKS_SETDETACH) + if (ACE_BIT_ENABLED (flags, THR_DETACHED) + || ACE_BIT_ENABLED (flags, THR_JOINABLE)) + { + int dstate = PTHREAD_CREATE_JOINABLE; + + if (ACE_BIT_ENABLED (flags, THR_DETACHED)) + dstate = PTHREAD_CREATE_DETACHED; + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + if (::pthread_attr_setdetach_np (&attr, dstate) != 0) +# else /* ACE_HAS_PTHREADS_DRAFT4 */ +# if defined (ACE_HAS_PTHREADS_DRAFT6) + if (::pthread_attr_setdetachstate (&attr, &dstate) != 0) +# else + if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate), + result) != 0) +# endif /* ACE_HAS_PTHREADS_DRAFT6 */ +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } + + // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we + // call ::pthread_detach () below. If THR_DETACHED is not + // enabled, we call ::pthread_detach () in the Thread_Manager, + // after joining with the thread. +# endif /* ACE_LACKS_SETDETACH */ + + // *** Set Policy +# if !defined (ACE_LACKS_SETSCHED) + // If we wish to set the priority explicitly, we have to enable + // explicit scheduling, and a policy, too. + if (priority != ACE_DEFAULT_THREAD_PRIORITY) + { + ACE_SET_BITS (flags, THR_EXPLICIT_SCHED); + if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO) + && ACE_BIT_DISABLED (flags, THR_SCHED_RR) + && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT)) + ACE_SET_BITS (flags, THR_SCHED_DEFAULT); + } + + if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) + || ACE_BIT_ENABLED (flags, THR_SCHED_RR) + || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) + { + int spolicy; + +# if defined (ACE_HAS_ONLY_SCHED_OTHER) + // SunOS, thru version 5.6, only supports SCHED_OTHER. + spolicy = SCHED_OTHER; +# else + // Make sure to enable explicit scheduling, in case we didn't + // enable it above (for non-default priority). + ACE_SET_BITS (flags, THR_EXPLICIT_SCHED); + + if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) + spolicy = SCHED_OTHER; + else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) + spolicy = SCHED_FIFO; +# if defined (SCHED_IO) + else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO)) + spolicy = SCHED_IO; +# else + else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO)) + { + errno = ENOSYS; + return -1; + } +# endif /* SCHED_IO */ + else + spolicy = SCHED_RR; + +# if defined (ACE_HAS_FSU_PTHREADS) + int ret; + switch (spolicy) + { + case SCHED_FIFO: + case SCHED_RR: + ret = 0; + break; + default: + ret = 22; + break; + } + if (ret != 0) + { + ::pthread_attr_destroy (&attr); + return -1; + } +# endif /* ACE_HAS_FSU_PTHREADS */ + +# endif /* ACE_HAS_ONLY_SCHED_OTHER */ + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + result = ::pthread_attr_setsched (&attr, spolicy); +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + result = ::pthread_attr_setschedpolicy (&attr, spolicy); +# else /* draft 7 or std */ + ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy), + result); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + if (result != 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } + + // *** Set Priority (use reasonable default priorities) +# if defined(ACE_HAS_PTHREADS_STD) + // If we wish to explicitly set a scheduling policy, we also + // have to specify a priority. We choose a "middle" priority as + // default. Maybe this is also necessary on other POSIX'ish + // implementations? + if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) + || ACE_BIT_ENABLED (flags, THR_SCHED_RR) + || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) + && priority == ACE_DEFAULT_THREAD_PRIORITY) + { + if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) + priority = ACE_THR_PRI_FIFO_DEF; + else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR)) + priority = ACE_THR_PRI_RR_DEF; + else // THR_SCHED_DEFAULT + priority = ACE_THR_PRI_OTHER_DEF; + } +# endif /* ACE_HAS_PTHREADS_STD */ + if (priority != ACE_DEFAULT_THREAD_PRIORITY) + { + struct sched_param sparam; + ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); + +# if defined (ACE_HAS_IRIX62_THREADS) + sparam.sched_priority = ACE_MIN (priority, + (long) PTHREAD_MAX_PRIORITY); +# elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS_STD) + /* For MIT pthreads... */ + sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY); +# elif defined(ACE_HAS_PTHREADS_STD) && !defined (ACE_HAS_STHREADS) + // The following code forces priority into range. + if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) + sparam.sched_priority = + ACE_MIN (ACE_THR_PRI_FIFO_MAX, + ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority)); + else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR)) + sparam.sched_priority = + ACE_MIN (ACE_THR_PRI_RR_MAX, + ACE_MAX (ACE_THR_PRI_RR_MIN, priority)); + else // Default policy, whether set or not + sparam.sched_priority = + ACE_MIN (ACE_THR_PRI_OTHER_MAX, + ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority)); +# elif defined (PRIORITY_MAX) + sparam.sched_priority = ACE_MIN (priority, + (long) PRIORITY_MAX); +# else + sparam.sched_priority = priority; +# endif /* ACE_HAS_IRIX62_THREADS */ + +# if defined (ACE_HAS_FSU_PTHREADS) + if (sparam.sched_priority >= PTHREAD_MIN_PRIORITY + && sparam.sched_priority <= PTHREAD_MAX_PRIORITY) + attr.prio = sparam.sched_priority; + else + { + pthread_attr_destroy (&attr); + errno = EINVAL; + return -1; + } +# else + { +# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER) + // SunOS, through 5.6, POSIX only allows priorities > 0 to + // ::pthread_attr_setschedparam. If a priority of 0 was + // requested, set the thread priority after creating it, below. + if (priority > 0) +# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */ + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + result = ::pthread_attr_setprio (&attr, + sparam.sched_priority); +# else /* this is draft 7 or std */ + ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam), + result); +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ + if (result != 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } + } +# endif /* ACE_HAS_FSU_PTHREADS */ + } + + // *** Set scheduling explicit or inherited + if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED) + || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED)) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + int sched = PTHREAD_DEFAULT_SCHED; +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + int sched = PTHREAD_EXPLICIT_SCHED; +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)) + sched = PTHREAD_INHERIT_SCHED; + if (::pthread_attr_setinheritsched (&attr, sched) != 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } +# else /* ACE_LACKS_SETSCHED */ + ACE_UNUSED_ARG (priority); +# endif /* ACE_LACKS_SETSCHED */ + + // *** Set Scope +# if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING) + if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM) + || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS)) + { +# if defined (ACE_CONFIG_LINUX_H) || defined (HPUX) + // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS. + // Neither does HPUX (up to HP-UX 11.00, as far as I know). + int scope = PTHREAD_SCOPE_SYSTEM; +# else /* ACE_CONFIG_LINUX_H */ + int scope = PTHREAD_SCOPE_PROCESS; +# endif /* ACE_CONFIG_LINUX_H */ + if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)) + scope = PTHREAD_SCOPE_SYSTEM; + + if (::pthread_attr_setscope (&attr, scope) != 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_attr_delete (&attr); +# else /* ACE_HAS_PTHREADS_DRAFT4 */ + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + return -1; + } + } +# endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */ + + if (ACE_BIT_ENABLED (flags, THR_NEW_LWP)) + { + // Increment the number of LWPs by one to emulate the + // SunOS semantics. + int lwps = ACE_OS::thr_getconcurrency (); + if (lwps == -1) + { + if (errno == ENOTSUP) + // Suppress the ENOTSUP because it's harmless. + errno = 0; + else + // This should never happen on SunOS: + // ::thr_getconcurrency () should always succeed. + return -1; + } + else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1) + { + if (errno == ENOTSUP) + { + // Unlikely: ::thr_getconcurrency () is supported but + // ::thr_setconcurrency () is not? + } + else + return -1; + } + } + } + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ACE_OSCALL (::pthread_create (thr_id, attr, + thread_args->entry_point (), + thread_args), + int, -1, result); + +# if defined (ACE_LACKS_SETDETACH) + if (ACE_BIT_ENABLED (flags, THR_DETACHED)) + { +# if defined (HPUX_10) + // HP-UX DCE threads' pthread_detach will smash thr_id if it's + // just given as an argument. This will cause + // ACE_Thread_Manager (if it's doing this create) to lose track + // of the new thread since the ID will be passed back equal to + // 0. So give pthread_detach a junker to scribble on. + ACE_thread_t junker; + cma_handle_assign(thr_id, &junker); + ::pthread_detach (&junker); +# else + ::pthread_detach (thr_id); +# endif /* HPUX_10 */ + } +# endif /* ACE_LACKS_SETDETACH */ + + ::pthread_attr_delete (&attr); + +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL (::pthread_create (thr_id, &attr, + thread_args->entry_point (), + thread_args), + int, -1, result); + ::pthread_attr_destroy (&attr); + +# else /* this is draft 7 or std */ + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id, + &attr, + thread_args->entry_point (), + thread_args), + result), + int, -1, result); + ::pthread_attr_destroy (&attr); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + + // This is a SunOS or POSIX implementation of pthreads, where we + // assume that ACE_thread_t and ACE_hthread_t are the same. If this + // *isn't* correct on some platform, please let us know. + if (result != -1) + *thr_handle = *thr_id; + +# if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER) + // SunOS prior to 5.7: + + // If the priority is 0, then we might have to set it now because we + // couldn't set it with ::pthread_attr_setschedparam, as noted + // above. This doesn't provide strictly correct behavior, because + // the thread was created (above) with the priority of its parent. + // (That applies regardless of the inherit_sched attribute: if it + // was PTHREAD_INHERIT_SCHED, then it certainly inherited its + // parent's priority. If it was PTHREAD_EXPLICIT_SCHED, then "attr" + // was initialized by the SunOS ::pthread_attr_init () to contain + // NULL for the priority, which indicated to SunOS ::pthread_create + // () to inherit the parent priority.) + if (priority == 0) + { + // Check the priority of this thread, which is the parent + // of the newly created thread. If it is 0, then the + // newly created thread will have inherited the priority + // of 0, so there's no need to explicitly set it. + struct sched_param sparam; + int policy = 0; + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (), + &policy, + &sparam), + result), int, + -1, result); + + // The only policy supported by by SunOS, thru version 5.6, + // is SCHED_OTHER, so that's hard-coded here. + policy = ACE_SCHED_OTHER; + + if (sparam.sched_priority != 0) + { + ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); + // The memset to 0 sets the priority to 0, so we don't need + // to explicitly set sparam.sched_priority. + + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id, + policy, + &sparam), + result), + int, -1); + } + } + +# if defined (ACE_NEEDS_LWP_PRIO_SET) +# if 0 + // It would be useful if we could make this work. But, it requires + // a mechanism for determining the ID of an LWP to which another + // thread is bound. Is there a way to do that? Instead, just rely + // on the code in ACE_Thread_Adapter::invoke () to set the LWP + // priority. + + // If the thread is bound, then set the priority on its LWP. + if (ACE_BIT_ENABLED (flags, THR_BOUND)) + { + ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) || + ACE_BIT_ENABLED (flags, THR_SCHED_RR) ? + ACE_SCHED_FIFO : + ACE_SCHED_OTHER, + priority); + result = ACE_OS::lwp_setparams (sched_params, + /* ? How do we find the ID of the LWP + to which *thr_id is bound? */); + } +# endif /* 0 */ +# endif /* ACE_NEEDS_LWP_PRIO_SET */ + +# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */ + return result; +# elif defined (ACE_HAS_STHREADS) + int result; + int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED); + + if (priority != ACE_DEFAULT_THREAD_PRIORITY) + // If we need to set the priority, then we need to start the + // thread in a suspended mode. + ACE_SET_BITS (flags, THR_SUSPENDED); + + ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize, + thread_args->entry_point (), + thread_args, + flags, thr_id), result), + int, -1, result); + + if (result != -1) + { + // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same. + *thr_handle = *thr_id; + + if (priority != ACE_DEFAULT_THREAD_PRIORITY) + { + // Set the priority of the new thread and then let it + // continue, but only if the user didn't start it suspended + // in the first place! + if ((result = ACE_OS::thr_setprio (*thr_id, priority)) != 0) + { + errno = result; + return -1; + } + + if (start_suspended == 0) + { + if ((result = ACE_OS::thr_continue (*thr_id)) != 0) + { + errno = result; + return -1; + } + } + } + } + return result; +# elif defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (stack); +# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) + if (ACE_BIT_ENABLED (flags, THR_USE_AFX)) + { + CWinThread *cwin_thread = + ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (), + thread_args, + priority, + 0, + flags | THR_SUSPENDED); + // Have to duplicate the handle because + // CWinThread::~CWinThread() closes the original handle. +# if !defined (ACE_HAS_WINCE) + (void) ::DuplicateHandle (::GetCurrentProcess (), + cwin_thread->m_hThread, + ::GetCurrentProcess (), + thr_handle, + 0, + TRUE, + DUPLICATE_SAME_ACCESS); +# endif /* ! ACE_HAS_WINCE */ + *thr_id = cwin_thread->m_nThreadID; + + if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0) + cwin_thread->ResumeThread (); + // cwin_thread will be deleted in AfxThreadExit() + // Warning: If AfxThreadExit() is called from within the + // thread, ACE_TSS_Cleanup->exit() never gets called ! + } + else +# endif /* ACE_HAS_MFC */ + { + int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED); + + if (priority != ACE_DEFAULT_THREAD_PRIORITY) + // If we need to set the priority, then we need to start the + // thread in a suspended mode. + ACE_SET_BITS (flags, THR_SUSPENDED); + + *thr_handle = (void *) ACE_BEGINTHREADEX (0, + ACE_static_cast + (u_int, stacksize), + thread_args->entry_point (), + thread_args, + flags, + thr_id); + + if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0) + { + // Set the priority of the new thread and then let it + // continue, but only if the user didn't start it suspended + // in the first place! + ACE_OS::thr_setprio (*thr_handle, priority); + + if (start_suspended == 0) + ACE_OS::thr_continue (*thr_handle); + } + } +# if 0 + *thr_handle = ::CreateThread + (0, + stacksize, + LPTHREAD_START_ROUTINE (thread_args->entry_point ()), + thread_args, + flags, + thr_id); +# endif /* 0 */ + + // Close down the handle if no one wants to use it. + if (thr_handle == &tmp_handle) + ::CloseHandle (tmp_handle); + + if (*thr_handle != 0) + return 0; + else + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ + +# elif defined (ACE_PSOS) + + // stack is created in the task's memory region 0 + ACE_UNUSED_ARG (stack); + + // task creation and start flags are fixed + ACE_UNUSED_ARG (flags); + + // lowest priority is reserved for the IDLE pSOS+ system daemon, + // highest are reserved for high priority pSOS+ system daemons + if (priority < PSOS_TASK_MIN_PRIORITY) + { + priority = PSOS_TASK_MIN_PRIORITY; + } + else if (priority > PSOS_TASK_MAX_PRIORITY) + { + priority = PSOS_TASK_MAX_PRIORITY; + } + + // set the stacksize to a default value if no size is specified + if (stacksize == 0) + stacksize = ACE_PSOS_DEFAULT_STACK_SIZE; + + ACE_hthread_t tid; + *thr_handle = 0; + + // create the thread + if (t_create ((char *) thr_id, // task name + priority, // (possibly adjusted) task priority + stacksize, // passed stack size is used for supervisor stack + 0, // no user stack: tasks run strictly in supervisor mode + T_LOCAL, // local to the pSOS+ node (does not support pSOS+m) + &tid) // receives task id + != 0) + { + return -1; + } + + // pSOS tasks are passed an array of 4 u_longs + u_long targs[4]; + targs[0] = (u_long) ACE_THREAD_ARGUMENT; + targs[1] = 0; + targs[2] = 0; + targs[3] = 0; + + // start the thread + if (t_start (tid, + T_PREEMPT | // Task can be preempted + // T_NOTSLICE | // Task is not timesliced with other tasks at same priority + T_TSLICE | // Task is timesliced with other tasks at same priority + T_NOASR | // Task level signals disabled + T_SUPV | // Task runs strictly in supervisor mode + T_ISR, // Hardware interrupts are enabled + ACE_THREAD_FUNCTION, // Task entry point + targs) // Task argument(s) + != 0) + { + return -1; + } + + // store the task id in the handle and return success + *thr_handle = tid; + return 0; + +# elif defined (VXWORKS) + // The hard-coded values below are what ::sp () would use. (::sp () + // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to + // 20,000.) stacksize should be an even integer. If a stack is not + // specified, ::taskSpawn () is used so that we can set the + // priority, flags, and stacksize. If a stack is specified, + // ::taskInit ()/::taskActivate() are used. + + // If called with thr_create() defaults, use same default values as ::sp (): + if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100; + // Assumes that there is a floating point coprocessor. As noted + // above, ::sp () hardcodes this, so we should be safe with it. + if (flags == 0) flags = VX_FP_TASK; + if (stacksize == 0) stacksize = 20000; + + const u_int thr_id_provided = + thr_id && *thr_id && (*thr_id)[0] != ACE_THR_ID_ALLOCATED; + + ACE_hthread_t tid; +# if 0 /* Don't support setting of stack, because it doesn't seem to work. */ + if (stack == 0) + { +# else + ACE_UNUSED_ARG (stack); +# endif /* 0 */ + // The call below to ::taskSpawn () causes VxWorks to assign a + // unique task name of the form: "t" + an integer, because the + // first argument is 0. + tid = ::taskSpawn (thr_id_provided ? *thr_id : 0, + priority, + (int) flags, + (int) stacksize, + thread_args->entry_point (), + (int) thread_args, + 0, 0, 0, 0, 0, 0, 0, 0, 0); +# if 0 /* Don't support setting of stack, because it doesn't seem to work. */ + } + else + { + // If a task name (thr_id) was not supplied, then the task will + // not have a unique name. That's VxWorks' behavior. + + // Carve out a TCB at the beginning of the stack space. The TCB + // occupies 400 bytes with VxWorks 5.3.1/I386. + WIND_TCB *tcb = (WIND_TCB *) stack; + + // The TID is defined to be the address of the TCB. + int status = ::taskInit (tcb, + thr_id_provided ? *thr_id : 0, + priority, + (int) flags, + (char *) stack + sizeof (WIND_TCB), + (int) (stacksize - sizeof (WIND_TCB)), + thread_args->entry_point (), + (int) thread_args, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (status == OK) + { + // The task was successfully initialized, now activate it. + status = ::taskActivate ((ACE_hthread_t) tcb); + } + + tid = status == OK ? (ACE_hthread_t) tcb : ERROR; + } +# endif /* 0 */ + + if (tid == ERROR) + return -1; + else + { + if (! thr_id_provided && thr_id) + { + if (*thr_id && (*thr_id)[0] == ACE_THR_ID_ALLOCATED) + // *thr_id was allocated by the Thread_Manager. ::taskTcb + // (int tid) returns the address of the WIND_TCB (task + // control block). According to the ::taskSpawn() + // documentation, the name of the new task is stored at + // pStackBase, but is that of the current task? If so, it + // might be a bit quicker than this extraction of the tcb + // . . . + ACE_OS::strsncpy (*thr_id + 1, ::taskTcb (tid)->name, 10); + else + // *thr_id was not allocated by the Thread_Manager. + // Pass back the task name in the location pointed to + // by thr_id. + *thr_id = ::taskTcb (tid)->name; + } + // else if the thr_id was provided, there's no need to overwrite + // it with the same value (string). If thr_id is 0, then we can't + // pass the task name back. + + if (thr_handle) + *thr_handle = tid; + + return 0; + } + +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (func); + ACE_UNUSED_ARG (args); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (thr_id); + ACE_UNUSED_ARG (thr_handle); + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (stack); + ACE_UNUSED_ARG (stacksize); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +void +ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status) +{ + ACE_OS_TRACE ("ACE_OS::thr_exit"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + ::pthread_exit (status); +# elif defined (ACE_HAS_STHREADS) + ::thr_exit (status); +# elif defined (ACE_HAS_WTHREADS) + // Can't call it here because on NT, the thread is exited + // directly by ACE_Thread_Adapter::invoke (). + // ACE_TSS_Cleanup::instance ()->exit (status); + +# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) + int using_afx = -1; + // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor. + // But without #including ace/Thread_Manager.h, we don't know that. + ACE_OS_Thread_Descriptor *td = + ACE_Base_Thread_Adapter::thr_desc_log_msg (); + if (td) + using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX); +# endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */ + + // Call TSS destructors. + ACE_OS::cleanup_tss (0 /* not main thread */); + + // Exit the thread. + // Allow CWinThread-destructor to be invoked from AfxEndThread. + // _endthreadex will be called from AfxEndThread so don't exit the + // thread now if we are running an MFC thread. +# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) + if (using_afx != -1) + { + if (using_afx) + ::AfxEndThread (status); + else + ACE_ENDTHREADEX (status); + } + else + { + // Not spawned by ACE_Thread_Manager, use the old buggy + // version. You should seriously consider using + // ACE_Thread_Manager to spawn threads. The following code is + // know to cause some problem. + CWinThread *pThread = ::AfxGetThread (); + if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ()) + ACE_ENDTHREADEX (status); + else + ::AfxEndThread (status); + } +# else + ACE_ENDTHREADEX (status); +# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/ + +# elif defined (VXWORKS) + ACE_hthread_t tid; + ACE_OS::thr_self (tid); + *((int *) status) = ::taskDelete (tid); +# elif defined (ACE_PSOS) + ACE_hthread_t tid; + ACE_OS::thr_self (tid); + +# if defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + // Call TSS destructors. + ACE_OS::cleanup_tss (0 /* not main thread */); +# endif /* ACE_PSOS && ACE_PSOS_HAS_TSS */ + + *((u_long *) status) = ::t_delete (tid); +# endif /* ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (status); +#endif /* ACE_HAS_THREADS */ +} + +#if defined (VXWORKS) +// Leave this in the global scope to allow +// users to adjust the delay value. +int ACE_THR_JOIN_DELAY = 5; + +int +ACE_OS::thr_join (ACE_hthread_t thr_handle, + ACE_THR_FUNC_RETURN *status) +{ + // We can't get the status of the thread + if (status != 0) + { + *status = 0; + } + + // This method can not support joining all threads + if (ACE_OS::thr_cmp (thr_handle, ACE_OS::NULL_hthread)) + { + ACE_NOTSUP_RETURN (-1); + } + + int retval = ESRCH; + ACE_hthread_t current; + ACE_OS::thr_self (current); + + // Make sure we are not joining ourself + if (ACE_OS::thr_cmp (thr_handle, current)) + { + retval = EDEADLK; + } + else + { + // Whether the task exists or not + // we will return a successful value + retval = 0; + + // Verify that the task id still exists + while (taskIdVerify (thr_handle) == OK) + { + // Wait a bit to see if the task is still active. + ACE_OS::sleep (ACE_THR_JOIN_DELAY); + } + } + + // Adapt the return value into errno and return value. + // The ACE_ADAPT_RETVAL macro doesn't exactly do what + // we need to do here, so we do it manually. + if (retval != 0) + { + errno = retval; + retval = -1; + } + + return retval; +} + +int +ACE_OS::thr_join (ACE_thread_t waiter_id, + ACE_thread_t *thr_id, + ACE_THR_FUNC_RETURN *status) +{ + thr_id = 0; + return ACE_OS::thr_join (taskNameToId (waiter_id), status); +} +#endif /* VXWORKS */ + +int +ACE_OS::thr_key_detach (void *inst) +{ +#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + if (ACE_TSS_Cleanup::lockable ()) + return ACE_TSS_Cleanup::instance()->detach (inst); + else + // We're in static constructor/destructor phase. Don't + // try to use the ACE_TSS_Cleanup instance because its lock + // might not have been constructed yet, or might have been + // destroyed already. Just leak the key . . . + return -1; +#else + ACE_UNUSED_ARG (inst); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */ +} + +int +ACE_OS::thr_key_used (ACE_thread_key_t key) +{ +#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) + ACE_TSS_Cleanup::instance ()->key_used (key); + return 0; +#else + ACE_UNUSED_ARG (key); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION || ACE_PSOS_HAS_TSS */ +} + +#if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) +int +ACE_OS::thr_keycreate (ACE_OS_thread_key_t *key, +# if defined (ACE_HAS_THR_C_DEST) + ACE_THR_C_DEST dest, +# else + ACE_THR_DEST dest, +# endif /* ACE_HAS_THR_C_DEST */ + void *inst) +{ + // ACE_OS_TRACE ("ACE_OS::thr_keycreate"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (inst); + + +# if defined (ACE_HAS_PTHREADS_DRAFT4) +# if defined (ACE_HAS_STDARG_THR_DEST) + ACE_OSCALL_RETURN (::pthread_keycreate (key, (void (*)(...)) dest), int, -1); +# else /* ! ACE_HAS_STDARG_THR_DEST */ + ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1); +# endif /* ! ACE_HAS_STDARG_THR_DEST */ +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_key_create (key, dest), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ +# elif defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (inst); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_keycreate (key, dest), + ace_result_), + int, -1); +# elif defined (ACE_HAS_WTHREADS) + *key = ::TlsAlloc (); + + if (*key != ACE_SYSCALL_FAILED) + { + // Extract out the thread-specific table instance and stash away + // the key and destructor so that we can free it up later on... + return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); + } + else + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (dest); + ACE_UNUSED_ARG (inst); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +#endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ + +int +ACE_OS::thr_keycreate (ACE_thread_key_t *key, +#if defined (ACE_HAS_THR_C_DEST) + ACE_THR_C_DEST dest, +#else + ACE_THR_DEST dest, +#endif /* ACE_HAS_THR_C_DEST */ + void *inst) +{ + // ACE_OS_TRACE ("ACE_OS::thr_keycreate"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_TSS_EMULATION) + if (ACE_TSS_Emulation::next_key (*key) == 0) + { + ACE_TSS_Emulation::tss_destructor (*key, dest); + + // Extract out the thread-specific table instance and stash away + // the key and destructor so that we can free it up later on... + return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); + } + else + { + errno = EAGAIN; + return -1; + } +# elif defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (inst); + +# if defined (ACE_HAS_PTHREADS_DRAFT4) +# if defined (ACE_HAS_STDARG_THR_DEST) + ACE_OSCALL_RETURN (::pthread_keycreate (key, (void (*)(...)) dest), int, -1); +# else /* ! ACE_HAS_STDARG_THR_DEST */ + ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1); +# endif /* ! ACE_HAS_STDARG_THR_DEST */ +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_key_create (key, dest), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + +# elif defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (inst); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_keycreate (key, dest), + ace_result_), + int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + + static u_long unique_name = 0; + void *tsdanchor; + + ++unique_name; + if (::tsd_create (ACE_reinterpret_cast (char *, &unique_name), + 0, + TSD_NOALLOC, + (void ****) &tsdanchor, + key) != 0) + { + return -1; + } + + return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); +# elif defined (ACE_HAS_WTHREADS) + *key = ::TlsAlloc (); + + if (*key != ACE_SYSCALL_FAILED) + { + // Extract out the thread-specific table instance and stash away + // the key and destructor so that we can free it up later on... + return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst); + } + else + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ +# else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (dest); + ACE_UNUSED_ARG (inst); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_TSS_EMULATION */ +#else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (dest); + ACE_UNUSED_ARG (inst); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::thr_keyfree (ACE_thread_key_t key) +{ + ACE_OS_TRACE ("ACE_OS::thr_keyfree"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_TSS_EMULATION) + // Release the key in the TSS_Emulation administration + ACE_TSS_Emulation::release_key (key); + return ACE_TSS_Cleanup::instance ()->remove (key); +# elif defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_UNUSED_ARG (key); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_PTHREADS) + return ::pthread_key_delete (key); +# elif defined (ACE_HAS_THR_KEYDELETE) + return ::thr_keydelete (key); +# elif defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (key); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_WTHREADS) + // Extract out the thread-specific table instance and free up + // the key and destructor. + ACE_TSS_Cleanup::instance ()->remove (key); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::TlsFree (key), ace_result_), int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + // Extract out the thread-specific table instance and free up + // the key and destructor. + ACE_TSS_Cleanup::instance ()->remove (key); + return (::tsd_delete (key) == 0) ? 0 : -1; +# else + ACE_UNUSED_ARG (key); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_TSS_EMULATION */ +#else + ACE_UNUSED_ARG (key); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +int +ACE_OS::thr_setprio (const ACE_Sched_Priority prio) +{ + // Set the thread priority on the current thread. + ACE_hthread_t my_thread_id; + ACE_OS::thr_self (my_thread_id); + + int status = ACE_OS::thr_setprio (my_thread_id, prio); + +#if defined (ACE_NEEDS_LWP_PRIO_SET) + // If the thread is in the RT class, then set the priority on its + // LWP. (Instead of doing this if the thread is in the RT class, it + // should be done for all bound threads. But, there doesn't appear + // to be an easy way to determine if the thread is bound.) + + if (status == 0) + { + // Find what scheduling class the thread's LWP is in. + ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0); + if (ACE_OS::lwp_getparams (sched_params) == -1) + { + return -1; + } + else if (sched_params.policy () == ACE_SCHED_FIFO || + sched_params.policy () == ACE_SCHED_RR) + { + // This thread's LWP is in the RT class, so we need to set + // its priority. + sched_params.priority (prio); + return ACE_OS::lwp_setparams (sched_params); + } + // else this is not an RT thread. Nothing more needs to be + // done. + } +#endif /* ACE_NEEDS_LWP_PRIO_SET */ + + return status; +} + +#if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) +int +ACE_OS::thr_setspecific (ACE_OS_thread_key_t key, void *data) +{ + // ACE_OS_TRACE ("ACE_OS::thr_setspecific"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_FSU_PTHREADS) + // Call pthread_init() here to initialize threads package. FSU + // threads need an initialization before the first thread constructor. + // This seems to be the one; however, a segmentation fault may + // indicate that another pthread_init() is necessary, perhaps in + // Synch.cpp or Synch_T.cpp. FSU threads will not reinit if called + // more than once, so another call to pthread_init will not adversely + // affect existing threads. + pthread_init (); +# endif /* ACE_HAS_FSU_PTHREADS */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setspecific (key, data), ace_result_), int, -1); +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setspecific (key, data), ace_result_), int, -1); +# elif defined (ACE_HAS_WTHREADS) + ::TlsSetValue (key, data); + return 0; +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (data); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +#endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ + +int +ACE_OS::thr_setspecific (ACE_thread_key_t key, void *data) +{ + // ACE_OS_TRACE ("ACE_OS::thr_setspecific"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_TSS_EMULATION) + ACE_KEY_INDEX (key_index, key); + + if (key_index >= ACE_TSS_Emulation::total_keys ()) + { + errno = EINVAL; + data = 0; + return -1; + } + else + { + ACE_TSS_Emulation::ts_object (key) = data; + ACE_TSS_Cleanup::instance ()->key_used (key); + + return 0; + } +# elif defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_FSU_PTHREADS) + // Call pthread_init() here to initialize threads package. FSU + // threads need an initialization before the first thread constructor. + // This seems to be the one; however, a segmentation fault may + // indicate that another pthread_init() is necessary, perhaps in + // Synch.cpp or Synch_T.cpp. FSU threads will not reinit if called + // more than once, so another call to pthread_init will not adversely + // affect existing threads. + pthread_init (); +# endif /* ACE_HAS_FSU_PTHREADS */ + +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_setspecific (key, data), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setspecific (key, data), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ + +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setspecific (key, data), ace_result_), int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + ACE_hthread_t tid; + ACE_OS::thr_self (tid); + if (::tsd_setval (key, tid, data) != 0) + return -1; + ACE_TSS_Cleanup::instance ()->key_used (key); + return 0; +# elif defined (ACE_HAS_WTHREADS) + ::TlsSetValue (key, data); + ACE_TSS_Cleanup::instance ()->key_used (key); + return 0; +# else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (data); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (data); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +void +ACE_OS::unique_name (const void *object, + ACE_TCHAR *name, + size_t length) +{ + // The process ID will provide uniqueness between processes on the + // same machine. The "this" pointer of the <object> will provide + // uniqueness between other "live" objects in the same process. The + // uniqueness of this name is therefore only valid for the life of + // <object>. + ACE_TCHAR temp_name[ACE_UNIQUE_NAME_LEN]; + ACE_OS::sprintf (temp_name, + ACE_LIB_TEXT ("%p%d"), + object, + ACE_static_cast (int, ACE_OS::getpid ())); + ACE_OS::strsncpy (name, + temp_name, + length); +} + + +#if defined (VXWORKS) +# include /**/ <usrLib.h> /* for ::sp() */ + +// This global function can be used from the VxWorks shell to pass +// arguments to a C main () function. +// +// usage: -> spa main, "arg1", "arg2" +// +// All arguments must be quoted, even numbers. +int +spa (FUNCPTR entry, ...) +{ + static const unsigned int MAX_ARGS = 10; + static char *argv[MAX_ARGS]; + va_list pvar; + unsigned int argc; + + // Hardcode a program name because the real one isn't available + // through the VxWorks shell. + argv[0] = "ace_main"; + + // Peel off arguments to spa () and put into argv. va_arg () isn't + // necessarily supposed to return 0 when done, though since the + // VxWorks shell uses a fixed number (10) of arguments, it might 0 + // the unused ones. This function could be used to increase that + // limit, but then it couldn't depend on the trailing 0. So, the + // number of arguments would have to be passed. + va_start (pvar, entry); + + for (argc = 1; argc <= MAX_ARGS; ++argc) + { + argv[argc] = va_arg (pvar, char *); + + if (argv[argc] == 0) + break; + } + + if (argc > MAX_ARGS && argv[argc-1] != 0) + { + // try to read another arg, and warn user if the limit was exceeded + if (va_arg (pvar, char *) != 0) + ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %d\n", + MAX_ARGS); + } + else + { + // fill unused argv slots with 0 to get rid of leftovers + // from previous invocations + for (unsigned int i = argc; i <= MAX_ARGS; ++i) + argv[i] = 0; + } + + // The hard-coded options are what ::sp () uses, except for the + // larger stack size (instead of ::sp ()'s 20000). + const int ret = ::taskSpawn (argv[0], // task name + 100, // task priority + VX_FP_TASK, // task options + ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size + entry, // entry point + argc, // first argument to main () + (int) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0, 0); + va_end (pvar); + + // ::taskSpawn () returns the taskID on success: return 0 instead if + // successful + return ret > 0 ? 0 : ret; +} + +// A helper function for the extended spa functions +static void +add_to_argv (int& argc, char** argv, int max_args, char* string) +{ + char indouble = 0; + size_t previous = 0; + size_t length = ACE_OS::strlen (string); + + // We use <= to make sure that we get the last argument + for (size_t i = 0; i <= length; i++) + { + // Is it a double quote that hasn't been escaped? + if (string[i] == '\"' && (i == 0 || string[i - 1] != '\\')) + { + indouble ^= 1; + if (indouble) + { + // We have just entered a double quoted string, so + // save the starting position of the contents. + previous = i + 1; + } + else + { + // We have just left a double quoted string, so + // zero out the ending double quote. + string[i] = '\0'; + } + } + else if (string[i] == '\\') // Escape the next character + { + // The next character is automatically + // skipped because of the strcpy + ACE_OS::strcpy (string + i, string + i + 1); + length--; + } + else if (!indouble && + (ACE_OS::ace_isspace (string[i]) || string[i] == '\0')) + { + string[i] = '\0'; + if (argc < max_args) + { + argv[argc] = string + previous; + argc++; + } + else + { + ACE_OS::fprintf (stderr, "spae(): number of arguments " + "limited to %d\n", max_args); + } + + // Skip over whitespace in between arguments + for(++i; i < length && ACE_OS::ace_isspace (string[i]); ++i) + { + } + + // Save the starting point for the next time around + previous = i; + + // Make sure we don't skip over a character due + // to the above loop to skip over whitespace + i--; + } + } +} + +// This global function can be used from the VxWorks shell to pass +// arguments to a C main () function. +// +// usage: -> spae main, "arg1 arg2 \"arg3 with spaces\"" +// +// All arguments must be within double quotes, even numbers. +int +spae (FUNCPTR entry, ...) +{ + static const int WINDSH_ARGS = 10; + static const int MAX_ARGS = 128; + static char* argv[MAX_ARGS] = { "ace_main", 0 }; + va_list pvar; + int argc = 1; + + // Peel off arguments to spa () and put into argv. va_arg () isn't + // necessarily supposed to return 0 when done, though since the + // VxWorks shell uses a fixed number (10) of arguments, it might 0 + // the unused ones. + va_start (pvar, entry); + + int i = 0; + for (char* str = va_arg (pvar, char*); + str != 0 && i < WINDSH_ARGS; str = va_arg (pvar, char*), ++i) + { + add_to_argv(argc, argv, MAX_ARGS, str); + } + + // fill unused argv slots with 0 to get rid of leftovers + // from previous invocations + for (i = argc; i < MAX_ARGS; ++i) + argv[i] = 0; + + // The hard-coded options are what ::sp () uses, except for the + // larger stack size (instead of ::sp ()'s 20000). + const int ret = ::taskSpawn (argv[0], // task name + 100, // task priority + VX_FP_TASK, // task options + ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size + entry, // entry point + argc, // first argument to main () + (int) argv, // second argument to main () + 0, 0, 0, 0, 0, 0, 0, 0); + va_end (pvar); + + // ::taskSpawn () returns the taskID on success: return 0 instead if + // successful + return ret > 0 ? 0 : ret; +} + +// This global function can be used from the VxWorks shell to pass +// arguments to a C main () function. The function will be run +// within the shells task. +// +// usage: -> spaef main, "arg1 arg2 \"arg3 with spaces\"" +// +// All arguments must be within double quotes, even numbers. +// Unlike the spae function, this fuction executes the supplied +// routine in the foreground, rather than spawning it in a separate +// task. +int +spaef (FUNCPTR entry, ...) +{ + static const int WINDSH_ARGS = 10; + static const int MAX_ARGS = 128; + static char* argv[MAX_ARGS] = { "ace_main", 0 }; + va_list pvar; + int argc = 1; + + // Peel off arguments to spa () and put into argv. va_arg () isn't + // necessarily supposed to return 0 when done, though since the + // VxWorks shell uses a fixed number (10) of arguments, it might 0 + // the unused ones. + va_start (pvar, entry); + + int i = 0; + for (char* str = va_arg (pvar, char*); + str != 0 && i < WINDSH_ARGS; str = va_arg (pvar, char*), ++i) + { + add_to_argv(argc, argv, MAX_ARGS, str); + } + + // fill unused argv slots with 0 to get rid of leftovers + // from previous invocations + for (i = argc; i < MAX_ARGS; ++i) + argv[i] = 0; + + int ret = entry (argc, argv); + + va_end (pvar); + + // Return the return value of the invoked ace_main routine. + return ret; +} +#endif /* VXWORKS */ + +#if defined (__DGUX) && defined (ACE_HAS_THREADS) && defined (_POSIX4A_DRAFT10_SOURCE) +extern "C" int __d6_sigwait (sigset_t *set); + +extern "C" int __d10_sigwait (const sigset_t *set, int *sig) +{ + sigset_t unconst_set = *set; + int caught_sig = __d6_sigwait (&unconst_set); + + if (caught == -1) + return -1; + + *sig = caught_sig; + return 0; +} +#endif /* __DGUX && PTHREADS && _POSIX4A_DRAFT10_SOURCE */ + + diff --git a/ace/OS_NS_Thread.h b/ace/OS_NS_Thread.h index fc532b41367..530fafd662d 100644 --- a/ace/OS_NS_Thread.h +++ b/ace/OS_NS_Thread.h @@ -1,4 +1,1709 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_Thread.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_THREAD_H +# define ACE_OS_NS_THREAD_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/Global_Macros.h" +# include "ace/Basic_Types.h" +# include "ace/Default_Constants.h" +# include "ace/os_include/os_pthread.h" +# include "ace/Base_Thread_Adapter.h" +# include "ace/os_include/sys/os_sem.h" +# include "ace/os_include/os_semaphore.h" +# include "ace/OS_Memory.h" +# include "ace/OS_NS_signal.h" + +# 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 */ + +# if defined (ACE_PSOS) +// Use pSOS semaphores, wrapped . . . +typedef struct +{ + /// Semaphore handle. This is allocated by pSOS. + u_long sema_; + + /// Name of the semaphore: really a 32 bit number to pSOS + char name_[4]; +} ACE_sema_t; +# endif /* ACE_PSOS */ + +# if defined (ACE_PSOS) + +// Wrapper for NT events on pSOS. +class ACE_OS_Export ACE_event_t +{ +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_WIN32) +typedef DWORD ACE_thread_t; +typedef HANDLE ACE_hthread_t; +# 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 */ +# endif /* ACE_WIN32 */ + +# 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) +// moved to pthread.h +# 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) +# include /**/ <sysLib.h> // for sysClkRateGet() +# include /**/ <taskLib.h> +# include /**/ <taskHookLib.h> + +// make sure these are included for VXWORKS. +// @todo move these to a common place, perhaps the top of the file. +# include "ace/os_include/os_fcntl.h" +# include "ace/os_include/os_netdb.h" +# include "ace/os_include/os_semaphore.h" +# include "ace/os_include/os_signal.h" +# include "ace/os_include/os_stdio.h" +# include "ace/os_include/os_stdlib.h" +# include "ace/os_include/os_stropts.h" +# include "ace/os_include/os_unistd.h" +# include "ace/os_include/arpa/os_inet.h" +# include "ace/os_include/sys/os_select.h" +# include "ace/os_include/sys/os_socket.h" + +// 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). */ + +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 +{ + /// Semaphore handle. This is allocated by VxWorks. + SEM_ID sema_; + + /// Name of the semaphore: always NULL with VxWorks. + char *name_; +} 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 CRITICAL_SECTION ACE_thread_mutex_t; + +typedef struct +{ + /// Either USYNC_THREAD or USYNC_PROCESS + int type_; + union + { + HANDLE proc_mutex_; + CRITICAL_SECTION thr_mutex_; + }; +} ACE_mutex_t; + +// Wrapper for NT Events. +typedef HANDLE ACE_event_t; + +# if defined (ACE_WIN32) +//@@ 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 */ +# endif /* defined (ACE_WIN32) */ + +// 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 we're using PACE then we don't want this class (since PACE +// takes care of it) unless we're on Windows. Win32 mutexes, semaphores, +// and condition variables are not yet supported in PACE. +# if defined (ACE_LACKS_COND_T) +/** + * @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: + + /// 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 +{ +public: +//protected: + + 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 */ + +// Recursive mutex support. +// +// There are two parts to this: +// 1. The mutex type itself. This is based on whether or not the +// platform supports recursive mutexes natively or they're emulated. +// 2. Support for using the recursive mutex with a condition variable. +// When a thread waits on a condition variable, it has to relinquish +// the lock and wait atomically, then reacquire it after the condition +// variable is signaled. In non-recursive mutexes, the platform +// handles this automatically. But in recursive mutexes, especially +// when emulated, the recursion count needs to be maintained across +// the wait. Since another thread needs to be able to acquire the +// lock, it needs to appear free, even if the waiting thread had done +// multiple acquires. Thus, there's another structure to hold this +// information, and is used with the recursive_mutex_cond_unlock() +// and recursive_mutex_cond_relock() methods to maintain the expected +// state when the wait finishes. +# if defined (ACE_HAS_RECURSIVE_MUTEXES) +typedef ACE_thread_mutex_t ACE_recursive_thread_mutex_t; +# if defined (ACE_WIN32) +// Windows has recursive mutexes, but doesn't have condition variables, +// so there's no built-in support for this. Thus, the condition-related +// unlock/relock is augmented in ACE. +struct ACE_recursive_mutex_state +{ + // On Windows the augmented processing is simply unlocking/relocking + // the recursive locks - the condition handles a single lock ok. + LONG relock_count_; +}; +# else +// No need for special handling; just need a type for method signatures. +typedef int ACE_recursive_mutex_state; +# endif /* ACE_WIN32 */ +# 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_; +}; + +// Since recursive mutex is emulated, the state saving needs to be handled +// in ACE as well. These members save those from ACE_recursive_thread_mutex_t. +struct ACE_recursive_mutex_state +{ + int nesting_level_; + ACE_thread_t owner_id_; +}; +# endif /* ACE_HAS_RECURSIVE_MUTEXES */ + +# 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; +typedef int ACE_recursive_mutex_state; +# 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 unsigned 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 ***********************************************/ + +/** + * @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); + + void to_string (char*); + + + // != 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_; +}; + +// = The ACE_Sched_Priority type should be used for platform- +// independent thread and process priorities, by convention. +// int should be used for OS-specific priorities. +typedef int ACE_Sched_Priority; + +# if !defined (ACE_DEFAULT_SYNCH_TYPE) +# if defined (VXWORKS) + // 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 +# else +# define ACE_DEFAULT_SYNCH_TYPE USYNC_THREAD +# endif /* VXWORKS */ +#endif /* ! ACE_DEFAULT_SYNCH_TYPE */ + +// forward declaration +class ACE_Sched_Params; +class ACE_Time_Value; + +# if defined (ACE_PSOS) +typedef u_long ACE_idtype_t; +typedef u_long ACE_id_t; +typedef u_long ACE_pri_t; +# define ACE_SELF (0) +# elif defined (ACE_WIN32) +typedef int ACE_idtype_t; +typedef DWORD ACE_id_t; +typedef int ACE_pri_t; +# define ACE_SELF (0) +# else /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */ +# if defined (ACE_HAS_IDTYPE_T) + typedef idtype_t ACE_idtype_t; +# else + typedef int ACE_idtype_t; +# endif /* ACE_HAS_IDTYPE_T */ +# if defined (ACE_HAS_STHREADS) || defined (DIGITAL_UNIX) +# if defined (ACE_LACKS_PRI_T) + typedef int pri_t; +# endif /* ACE_LACKS_PRI_T */ + typedef id_t ACE_id_t; +# define ACE_SELF P_MYID + typedef pri_t ACE_pri_t; +# else /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */ + typedef long ACE_id_t; +# define ACE_SELF (-1) + typedef short ACE_pri_t; +# endif /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */ +# endif /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */ + +# if defined (ACE_HAS_TSS_EMULATION) + // Allow config.h to set the default number of thread keys. +# if !defined (ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 64 +# endif /* ! ACE_DEFAULT_THREAD_KEYS */ + +// forward declaration +class ACE_TSS_Keys; + +/** + * @class ACE_TSS_Emulation + * + * @brief Thread-specific storage emulation. + * + * This provides a thread-specific storage implementation. + * It is intended for use on platforms that don't have a + * native TSS, or have a TSS with limitations such as the + * number of keys or lack of support for removing keys. + */ +class ACE_OS_Export ACE_TSS_Emulation +{ +public: + typedef void (*ACE_TSS_DESTRUCTOR)(void *value) /* throw () */; + + /// Maximum number of TSS keys allowed over the life of the program. + enum { ACE_TSS_THREAD_KEYS_MAX = ACE_DEFAULT_THREAD_KEYS }; + + /// Returns the total number of keys allocated so far. + static u_int total_keys (); + + /// Sets the argument to the next available key. Returns 0 on success, + /// -1 if no keys are available. + static int next_key (ACE_thread_key_t &key); + + /// Release a key that was used. This way the key can be given out in a + /// new request. Returns 0 on success, 1 if the key was not reserved. + static int release_key (ACE_thread_key_t key); + + /// Returns the exit hook associated with the key. Does _not_ check + /// for a valid key. + static ACE_TSS_DESTRUCTOR tss_destructor (const ACE_thread_key_t key); + + /// Associates the TSS destructor with the key. Does _not_ check + /// for a valid key. + static void tss_destructor (const ACE_thread_key_t key, + ACE_TSS_DESTRUCTOR destructor); + + /// Accesses the object referenced by key in the current thread's TSS array. + /// Does _not_ check for a valid key. + static void *&ts_object (const ACE_thread_key_t key); + + /** + * Setup an array to be used for local TSS. Returns the array + * address on success. Returns 0 if local TSS had already been + * setup for this thread. There is no corresponding tss_close () + * because it is not needed. + * NOTE: tss_open () is called by ACE for threads that it spawns. + * If your application spawns threads without using ACE, and it uses + * ACE's TSS emulation, each of those threads should call tss_open + * (). See the ace_thread_adapter () implementation for an example. + */ + static void *tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]); + + /// Shutdown TSS emulation. For use only by ACE_OS::cleanup_tss (). + static void tss_close (); + +private: + // Global TSS structures. + /// Contains the possible value of the next key to be allocated. Which key + /// is actually allocated is based on the tss_keys_used + static u_int total_keys_; + + /// Array of thread exit hooks (TSS destructors) that are called for each + /// key (that has one) when the thread exits. + static ACE_TSS_DESTRUCTOR tss_destructor_ [ACE_TSS_THREAD_KEYS_MAX]; + + /// TSS_Keys instance to administrate whether a specific key is in used + /// or not + static ACE_TSS_Keys tss_keys_used_; + +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + /// Location of current thread's TSS array. + static void **tss_base (void* ts_storage[] = 0, u_int *ts_created = 0); +# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ + /// Location of current thread's TSS array. + static void **&tss_base (); +# endif /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ + +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + // Rely on native thread specific storage for the implementation, + // but just use one key. + static ACE_OS_thread_key_t native_tss_key_; + + // Used to indicate if native tss key has been allocated + static int key_created_; +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ +}; + +# else /* ! ACE_HAS_TSS_EMULATION */ +# if defined (TLS_MINIMUM_AVAILABLE) + // WIN32 platforms define TLS_MINIMUM_AVAILABLE natively. +# define ACE_DEFAULT_THREAD_KEYS TLS_MINIMUM_AVAILABLE +# endif /* TSL_MINIMUM_AVAILABLE */ + +# endif /* ACE_HAS_TSS_EMULATION */ + +// moved ACE_TSS_Ref, ACE_TSS_Info, and ACE_TSS_Keys class +// declarations from OS.cpp so they are visible to the single +// file of template instantiations. +# if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)) +/** + * @class ACE_TSS_Ref + * + * @brief "Reference count" for thread-specific storage keys. + * + * Since the <ACE_Unbounded_Stack> doesn't allow duplicates, the + * "reference count" is the identify of the thread_id. + */ +class ACE_TSS_Ref +{ +public: + /// Constructor + ACE_TSS_Ref (ACE_thread_t id); + + /// Default constructor + ACE_TSS_Ref (void); + + /// Check for equality. + int operator== (const ACE_TSS_Ref &) const; + + /// Check for inequality. + int operator!= (const ACE_TSS_Ref &) const; + +// private: + + /// ID of thread using a specific key. + ACE_thread_t tid_; +}; + +/** + * @class ACE_TSS_Info + * + * @brief Thread Specific Key management. + * + * This class maps a key to a "destructor." + */ +class ACE_TSS_Info +{ +public: + /// Constructor + ACE_TSS_Info (ACE_thread_key_t key, + void (*dest)(void *) = 0, + void *tss_inst = 0); + + /// Default constructor + ACE_TSS_Info (void); + + /// Returns 1 if the key is in use, 0 if not. + int key_in_use (void) const { return thread_count_ != -1; } + + /// Mark the key as being in use if the flag is non-zero, or + /// not in use if the flag is 0. + void key_in_use (int flag) { thread_count_ = flag == 0 ? -1 : 1; } + + /// Check for equality. + int operator== (const ACE_TSS_Info &) const; + + /// Check for inequality. + int operator!= (const ACE_TSS_Info &) const; + + /// Dump the state. + void dump (void); + +private: + /// Key to the thread-specific storage item. + ACE_thread_key_t key_; + + /// "Destructor" that gets called when the item is finally released. + void (*destructor_)(void *); + + /// Pointer to ACE_TSS<xxx> instance that has/will allocate the key. + void *tss_obj_; + + /// Count of threads that are using this key. Contains -1 when the + /// key is not in use. + int thread_count_; + + friend class ACE_TSS_Cleanup; +}; + +/** + * @class ACE_TSS_Keys + * + * @brief Collection of in-use flags for a thread's TSS keys. + * For internal use only by ACE_TSS_Cleanup; it is public because + * some compilers can't use nested classes for template instantiation + * parameters. + * + * Wrapper around array of whether each key is in use. A simple + * typedef doesn't work with Sun C++ 4.2. + */ +class ACE_TSS_Keys +{ +public: + /// Default constructor, to initialize all bits to zero (unused). + ACE_TSS_Keys (void); + + /// Mark the specified key as being in use, if it was not already so marked. + /// Returns 1 if the had already been marked, 0 if not. + int test_and_set (const ACE_thread_key_t key); + + /// Mark the specified key as not being in use, if it was not already so + /// cleared. Returns 1 if the key had already been cleared, 0 if not. + int test_and_clear (const ACE_thread_key_t key); + + /// Return whether the specific key is marked as in use. + /// Returns 1 if the key is been marked, 0 if not. + int is_set (const ACE_thread_key_t key) const; + +private: + /// For a given key, find the word and bit number that represent it. + static void find (const u_int key, u_int &word, u_int &bit); + + enum + { +# if ACE_SIZEOF_LONG == 8 + ACE_BITS_PER_WORD = 64, +# elif ACE_SIZEOF_LONG == 4 + ACE_BITS_PER_WORD = 32, +# else +# error ACE_TSS_Keys only supports 32 or 64 bit longs. +# endif /* ACE_SIZEOF_LONG == 8 */ + ACE_WORDS = (ACE_DEFAULT_THREAD_KEYS - 1) / ACE_BITS_PER_WORD + 1 + }; + + /// Bit flag collection. A bit value of 1 indicates that the key is in + /// use by this thread. + u_long key_bit_words_[ACE_WORDS]; +}; + +# endif /* defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) */ + +// Support non-scalar thread keys, such as with some POSIX +// implementations, e.g., MVS. +# if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T) +# define ACE_KEY_INDEX(OBJ,KEY) \ + u_int OBJ; \ + ACE_OS::memcpy (&OBJ, &KEY, sizeof (u_int)) +# else +# define ACE_KEY_INDEX(OBJ,KEY) u_int OBJ = KEY +# endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */ + +# if defined (ACE_HAS_THR_C_FUNC) +// This is necessary to work around nasty problems with MVS C++. +extern "C" ACE_OS_Export void ace_mutex_lock_cleanup_adapter (void *args); +# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A); +# define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A) +# elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CLEANUP) +// Though we are defining a extern "C" function to match the prototype of +// pthread_cleanup_push, it is undone by the Solaris header file +// /usr/include/pthread.h. So this macro generates a warning under Solaris +// with SunCC. This is a bug in the Solaris header file. +extern "C" ACE_OS_Export void ace_mutex_lock_cleanup_adapter (void *args); +# define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A); +# define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A) +# else +# define ACE_PTHREAD_CLEANUP_PUSH(A) +# define ACE_PTHREAD_CLEANUP_POP(A) +# endif /* ACE_HAS_THR_C_FUNC */ + +#if !defined (ACE_WIN32) +// forward decl's +class ACE_event_t; +#endif + +namespace ACE_OS { + +# if 0 + //@{ @name A set of wrappers for threads (these are portable since they use the ACE_Thread_ID). + int thr_continue (const ACE_Thread_ID &thread); + int thr_create (ACE_THR_FUNC, + void *args, + long flags, + ACE_Thread_ID *, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack = 0, + size_t stacksize = 0); + int thr_getprio (ACE_Thread_ID thr_id, + int &prio, + int *policy = 0); + int thr_join (ACE_Thread_ID waiter_id, + ACE_THR_FUNC_RETURN *status); + int thr_kill (ACE_Thread_ID thr_id, + int signum); + ACE_Thread_ID thr_self (void); + int thr_setprio (ACE_Thread_ID thr_id, + int prio); + int thr_setprio (const ACE_Sched_Priority prio); + int thr_suspend (ACE_Thread_ID target_thread); + int thr_cancel (ACE_Thread_ID t_id); + //@} +# endif /* 0 */ + + + //@{ @name A set of wrappers for threads + + /// This is necessary to deal with POSIX pthreads and their use of + /// structures for thread ids. + extern ACE_thread_t NULL_thread; + + /// This is necessary to deal with POSIX pthreads and their use of + /// structures for thread handles. + extern ACE_hthread_t NULL_hthread; + + /// This is necessary to deal with POSIX pthreads and their use of + /// structures for TSS keys. + extern ACE_thread_key_t NULL_key; + +# if defined (CHORUS) + /// This is used to map an actor's id into a KnCap for killing and + /// waiting actors. + KnCap actorcaps_[ACE_CHORUS_MAX_ACTORS]; +# endif /* CHORUS */ + //@} + + /** + * Call TSS destructors for the current thread. If the current + * thread is the main thread, then the argument must be 1. + * For private use of ACE_Object_Manager and ACE_Thread_Adapter only. + */ + void cleanup_tss (const u_int main_thread); + + //@{ @name A set of wrappers for condition variables. + int condattr_init (ACE_condattr_t &attributes, + int type = ACE_DEFAULT_SYNCH_TYPE); + int condattr_destroy (ACE_condattr_t &attributes); + int cond_broadcast (ACE_cond_t *cv); + int cond_destroy (ACE_cond_t *cv); + int cond_init (ACE_cond_t *cv, + short type = ACE_DEFAULT_SYNCH_TYPE, + const char *name = 0, + void *arg = 0); + int cond_init (ACE_cond_t *cv, + ACE_condattr_t &attributes, + const char *name = 0, + void *arg = 0); +# if defined (ACE_HAS_WCHAR) + int cond_init (ACE_cond_t *cv, + short type, + const wchar_t *name, + void *arg = 0); + int cond_init (ACE_cond_t *cv, + ACE_condattr_t &attributes, + const wchar_t *name, + void *arg = 0); +# endif /* ACE_HAS_WCHAR */ + int cond_signal (ACE_cond_t *cv); + int cond_timedwait (ACE_cond_t *cv, + ACE_mutex_t *m, + ACE_Time_Value *); + int cond_wait (ACE_cond_t *cv, + ACE_mutex_t *m); +# if defined (ACE_WIN32) && defined (ACE_HAS_WTHREADS) + int cond_timedwait (ACE_cond_t *cv, + ACE_thread_mutex_t *m, + ACE_Time_Value *); + int cond_wait (ACE_cond_t *cv, + ACE_thread_mutex_t *m); +# endif /* ACE_WIN32 && ACE_HAS_WTHREADS */ + + //@{ @name A set of wrappers for auto-reset and manual events. + + int event_destroy (ACE_event_t *event); + + int event_init (ACE_event_t *event, + int manual_reset = 0, + int initial_state = 0, + int type = ACE_DEFAULT_SYNCH_TYPE, + const char *name = 0, + void *arg = 0, + LPSECURITY_ATTRIBUTES sa = 0); + +# if defined (ACE_HAS_WCHAR) + int event_init (ACE_event_t *event, + int manual_reset, + int initial_state, + int type, + const wchar_t *name, + void *arg = 0, + LPSECURITY_ATTRIBUTES sa = 0); +# endif /* ACE_HAS_WCHAR */ + + int event_pulse (ACE_event_t *event); + + int event_reset (ACE_event_t *event); + + int event_signal (ACE_event_t *event); + + int event_timedwait (ACE_event_t *event, + ACE_Time_Value *timeout, + int use_absolute_time = 1); + + int event_wait (ACE_event_t *event); + + //@} + + int lwp_getparams (ACE_Sched_Params &); + + int lwp_setparams (const ACE_Sched_Params &); + + + //@{ @name A set of wrappers for mutex locks. + + int mutex_destroy (ACE_mutex_t *m); + + int mutex_init (ACE_mutex_t *m, + int type = ACE_DEFAULT_SYNCH_TYPE, + const char *name = 0, + ACE_mutexattr_t *arg = 0, + LPSECURITY_ATTRIBUTES sa = 0); + +#if defined (ACE_HAS_WCHAR) + int mutex_init (ACE_mutex_t *m, + int type, + const wchar_t *name, + ACE_mutexattr_t *arg = 0, + LPSECURITY_ATTRIBUTES sa = 0); +#endif /* ACE_HAS_WCHAR */ + + /// Win32 note: Abandoned mutexes are not treated differently. 0 is + /// returned since the calling thread does get the ownership. + int mutex_lock (ACE_mutex_t *m); + + /// This method is only implemented for Win32. For abandoned + /// mutexes, <abandoned> is set to 1 and 0 is returned. + int mutex_lock (ACE_mutex_t *m, + int &abandoned); + + /** + * This method attempts to acquire a lock, but gives up if the lock + * has not been acquired by the given time. If the lock is not + * acquired within the given amount of time, then this method + * returns -1 with an <ETIME> errno on platforms that actually + * support timed mutexes. The timeout should be an absolute time. + * Note that the mutex should not be a recursive one, i.e., it + * should only be a standard mutex or an error checking mutex. + */ + int mutex_lock (ACE_mutex_t *m, + const ACE_Time_Value &timeout); + + /** + * If <timeout> == 0, calls <ACE_OS::mutex_lock(m)>. Otherwise, + * this method attempts to acquire a lock, but gives up if the lock + * has not been acquired by the given time, in which case it returns + * -1 with an <ETIME> errno on platforms that actually support timed + * mutexes. The timeout should be an absolute time. Note that the + * mutex should not be a recursive one, i.e., it should only be a + * standard mutex or an error checking mutex. + */ + int mutex_lock (ACE_mutex_t *m, + const ACE_Time_Value *timeout); + + /// Handle asynchronous thread cancellation cleanup. + void mutex_lock_cleanup (void *mutex); + + /// Win32 note: Abandoned mutexes are not treated differently. 0 is + /// returned since the calling thread does get the ownership. + int mutex_trylock (ACE_mutex_t *m); + + /// This method is only implemented for Win32. For abandoned + /// mutexes, <abandoned> is set to 1 and 0 is returned. + int mutex_trylock (ACE_mutex_t *m, + int &abandoned); + + int mutex_unlock (ACE_mutex_t *m); + + //@} + + /// Low-level interface to <priocntl>(2). + /** + * Can't call the following priocntl, because that's a macro on + * Solaris. + */ + int priority_control (ACE_idtype_t, ACE_id_t, int, void *); + + //@{ @name A set of wrappers for recursive mutex locks. + + // These two methods are primarily in support of + // ACE_Condition<ACE_Recursive_Thread_Mutex> and should probably not + // be called outside that context. + int recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, + ACE_recursive_mutex_state &state); + + void recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, + ACE_recursive_mutex_state &state); + + int recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m); + + int recursive_mutex_init (ACE_recursive_thread_mutex_t *m, + const ACE_TCHAR *name = 0, + ACE_mutexattr_t *arg = 0, + LPSECURITY_ATTRIBUTES sa = 0); + + int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m); + + int recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m); + + int recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m); + + //@} + + + //@{ @name A set of wrappers for readers/writer locks. + + int rw_rdlock (ACE_rwlock_t *rw); + + int rw_tryrdlock (ACE_rwlock_t *rw); + + int rw_trywrlock (ACE_rwlock_t *rw); + + int rw_trywrlock_upgrade (ACE_rwlock_t *rw); + + int rw_unlock (ACE_rwlock_t *rw); + + int rw_wrlock (ACE_rwlock_t *rw); + + int rwlock_destroy (ACE_rwlock_t *rw); + + int rwlock_init (ACE_rwlock_t *rw, + int type = ACE_DEFAULT_SYNCH_TYPE, + const ACE_TCHAR *name = 0, + void *arg = 0); + + //@} + + //@{ @name Thread scheduler interface. + /// Set scheduling parameters. An id of ACE_SELF indicates, e.g., + /// set the parameters on the calling thread. + int sched_params (const ACE_Sched_Params &, ACE_id_t id = ACE_SELF); + //@} + + /// Find the schedling class ID that corresponds to the class name. + int scheduling_class (const char *class_name, ACE_id_t &); + + //@{ @name A set of wrappers for semaphores. + + int sema_destroy (ACE_sema_t *s); + + int sema_init (ACE_sema_t *s, + u_int count, + int type = ACE_DEFAULT_SYNCH_TYPE, + const char *name = 0, + void *arg = 0, + int max = 0x7fffffff, + LPSECURITY_ATTRIBUTES sa = 0); + +# if defined (ACE_HAS_WCHAR) + int sema_init (ACE_sema_t *s, + u_int count, + int type, + const wchar_t *name, + void *arg = 0, + int max = 0x7fffffff, + LPSECURITY_ATTRIBUTES sa = 0); +# endif /* ACE_HAS_WCHAR */ + + int sema_post (ACE_sema_t *s); + + int sema_post (ACE_sema_t *s, + u_int release_count); + + int sema_trywait (ACE_sema_t *s); + + int sema_wait (ACE_sema_t *s); + + int sema_wait (ACE_sema_t *s, + ACE_Time_Value &tv); + + int sema_wait (ACE_sema_t *s, + ACE_Time_Value *tv); + + //@} + + //@{ @name A set of wrappers for System V semaphores. + int semctl (int int_id, + int semnum, + int cmd, + semun); + int semget (key_t key, + int nsems, + int flags); + int semop (int int_id, + struct sembuf *sops, + size_t nsops); + //@} + + /// Friendly interface to <priocntl>(2). + int set_scheduling_params (const ACE_Sched_Params &, + ACE_id_t id = ACE_SELF); + + int sigtimedwait (const sigset_t *set, + siginfo_t *info, + const ACE_Time_Value *timeout); + + int sigwait (sigset_t *set, + int *sig = 0); + + int sigwaitinfo (const sigset_t *set, + siginfo_t *info); + + int thr_cancel (ACE_thread_t t_id); + + int thr_cmp (ACE_hthread_t t1, + ACE_hthread_t t2); + // These are non-portable since they use ACE_thread_t and + // ACE_hthread_t and will go away in a future release. + int thr_continue (ACE_hthread_t target_thread); + + /* + * Creates a new thread having <flags> attributes and running <func> + * with <args> (if <thread_adapter> is non-0 then <func> and <args> + * are ignored and are obtained from <thread_adapter>). <thr_id> + * and <t_handle> are set to the thread's ID and handle (?), + * respectively. The thread runs at <priority> priority (see + * below). + * + * The <flags> are a bitwise-OR of the following: + * = BEGIN<INDENT> + * THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, + * THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, + * THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, + * THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, + * THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS + * = END<INDENT> + * + * By default, or if <priority> is set to + * ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for + * the given scheduling policy (specified in <flags}>, e.g., + * <THR_SCHED_DEFAULT>) is used. This value is calculated + * dynamically, and is the median value between the minimum and + * maximum priority values for the given policy. If an explicit + * value is given, it is used. Note that actual priority values are + * EXTREMEMLY implementation-dependent, and are probably best + * avoided. + * + * Note that <thread_adapter> is always deleted by <thr_create>, + * therefore it must be allocated with global operator new. + */ + int thr_create (ACE_THR_FUNC func, + void *args, + long flags, + ACE_thread_t *thr_id, + ACE_hthread_t *t_handle = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack = 0, + size_t stacksize = 0, + ACE_Base_Thread_Adapter *thread_adapter = 0); + + int thr_equal (ACE_thread_t t1, + ACE_thread_t t2); + + void thr_exit (ACE_THR_FUNC_RETURN status = 0); + + int thr_getconcurrency (void); + + int thr_getprio (ACE_hthread_t id, + int &priority); + + int thr_getprio (ACE_hthread_t id, + int &priority, + int &policy); + +# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + int thr_getspecific (ACE_OS_thread_key_t key, + void **data); +# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ + + int thr_getspecific (ACE_thread_key_t key, + void **data); + + int thr_join (ACE_hthread_t waiter_id, + ACE_THR_FUNC_RETURN *status); + + int thr_join (ACE_thread_t waiter_id, + ACE_thread_t *thr_id, + ACE_THR_FUNC_RETURN *status); + + int thr_key_detach (void *inst); + + int thr_key_used (ACE_thread_key_t key); + +# if defined (ACE_HAS_THR_C_DEST) +# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + int thr_keycreate (ACE_OS_thread_key_t *key, + ACE_THR_C_DEST, + void *inst = 0); +# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ + int thr_keycreate (ACE_thread_key_t *key, + ACE_THR_C_DEST, + void *inst = 0); +# else +# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + int thr_keycreate (ACE_OS_thread_key_t *key, + ACE_THR_DEST, + void *inst = 0); +# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ + int thr_keycreate (ACE_thread_key_t *key, + ACE_THR_DEST, + void *inst = 0); +# endif /* ACE_HAS_THR_C_DEST */ + + int thr_keyfree (ACE_thread_key_t key); + + int thr_kill (ACE_thread_t thr_id, + int signum); + + size_t thr_min_stack (void); + + ACE_thread_t thr_self (void); + + void thr_self (ACE_hthread_t &); + + int thr_setcancelstate (int new_state, + int *old_state); + + int thr_setcanceltype (int new_type, + int *old_type); + + int thr_setconcurrency (int hint); + + int thr_setprio (ACE_hthread_t id, + int priority, + int policy = -1); + + int thr_setprio (const ACE_Sched_Priority prio); + +# if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) + int thr_setspecific (ACE_OS_thread_key_t key, + void *data); +# endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */ + + int thr_setspecific (ACE_thread_key_t key, + void *data); + + int thr_sigsetmask (int how, + const sigset_t *nsm, + sigset_t *osm); + + int thr_suspend (ACE_hthread_t target_thread); + + void thr_testcancel (void); + + void thr_yield (void); + + //@{ @name A set of wrappers for mutex locks that only work within a single process. + + int thread_mutex_destroy (ACE_thread_mutex_t *m); + + int thread_mutex_init (ACE_thread_mutex_t *m, + int type = ACE_DEFAULT_SYNCH_TYPE, + const char *name = 0, + ACE_mutexattr_t *arg = 0); + +#if defined (ACE_HAS_WCHAR) + int thread_mutex_init (ACE_thread_mutex_t *m, + int type, + const wchar_t *name, + ACE_mutexattr_t *arg = 0); +#endif /* ACE_HAS_WCHAR */ + + int thread_mutex_lock (ACE_thread_mutex_t *m); + + int thread_mutex_lock (ACE_thread_mutex_t *m, + const ACE_Time_Value &timeout); + + int thread_mutex_lock (ACE_thread_mutex_t *m, + const ACE_Time_Value *timeout); + + int thread_mutex_trylock (ACE_thread_mutex_t *m); + + int thread_mutex_unlock (ACE_thread_mutex_t *m); + + //@} + + /** + * This method uses process id and object pointer to come up with a + * machine wide unique name. The process ID will provide uniqueness + * between processes on the same machine. The "this" pointer of the + * <object> will provide uniqueness between other "live" objects in + * the same process. The uniqueness of this name is therefore only + * valid for the life of <object>. + */ + void unique_name (const void *object, + ACE_TCHAR *name, + size_t length); + + //@} + +} /* namespace ACE_OS */ + +#if !defined (ACE_WIN32) +/** + * @class ACE_event_t + * + * @brief Wrapper for NT events on UNIX. + */ +class ACE_OS_Export ACE_event_t +{ + friend int ACE_OS::event_init(ACE_event_t*, int, int, int, const char*, void*,int); + friend int ACE_OS::event_destroy(ACE_event_t*); + friend int ACE_OS::event_wait(ACE_event_t*); + friend int ACE_OS::event_timedwait(ACE_event_t*, ACE_Time_Value*, int); + friend int ACE_OS::event_signal(ACE_event_t*); + friend int ACE_OS::event_pulse(ACE_event_t*); + friend int ACE_OS::event_reset(ACE_event_t*); +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. + unsigned long waiting_threads_; +}; +#endif /* ACE_WIN32 */ + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + +/** + * @class ACE_OS_Thread_Mutex_Guard + * + * This data structure is meant to be used within an ACE_OS + * function. It performs automatic aquisition and release of + * an ACE_thread_mutex_t. + * + * For internal use only by ACE_OS. + */ +class ACE_OS_Thread_Mutex_Guard +{ +public: + /// Implicitly and automatically acquire the lock. + ACE_OS_Thread_Mutex_Guard (ACE_thread_mutex_t &m); + + /// Implicitly release the lock. + ~ACE_OS_Thread_Mutex_Guard (void); + + /// Explicitly acquire the lock. + int acquire (void); + + /// Explicitly release the lock. + int release (void); + +protected: + /// Reference to the mutex. + ACE_thread_mutex_t &lock_; + + /// Keeps track of whether we acquired the lock or failed. + int owner_; + + // = Prevent assignment and initialization. + ACE_OS_Thread_Mutex_Guard &operator= (const ACE_OS_Thread_Mutex_Guard &); + ACE_OS_Thread_Mutex_Guard (const ACE_OS_Thread_Mutex_Guard &); +}; + +/** + * @class ACE_OS_Recursive_Thread_Mutex_Guard + * + * @brief For internal use only by ACE_OS. + * + * This data structure is meant to be used within an ACE_OS + * function. It performs automatic aquisition and release of + * an ACE_recursive_thread_mutex_t. + */ +class ACE_OS_Recursive_Thread_Mutex_Guard +{ +public: + /// Implicitly and automatically acquire the lock. + ACE_OS_Recursive_Thread_Mutex_Guard (ACE_recursive_thread_mutex_t &m); + + /// Implicitly release the lock. + ~ACE_OS_Recursive_Thread_Mutex_Guard (void); + + /// Explicitly acquire the lock. + int acquire (void); + + /// Explicitly release the lock. + int release (void); + +protected: + /// Reference to the mutex. + ACE_recursive_thread_mutex_t &lock_; + + /// Keeps track of whether we acquired the lock or failed. + int owner_; + + // = Prevent assignment and initialization. + ACE_OS_Recursive_Thread_Mutex_Guard &operator= ( + const ACE_OS_Recursive_Thread_Mutex_Guard &); + ACE_OS_Recursive_Thread_Mutex_Guard ( + const ACE_OS_Recursive_Thread_Mutex_Guard &); +}; + +// used in time and unistd +# define ACE_OS_GUARD \ + ACE_OS_Thread_Mutex_Guard ace_os_guard__ (*(ACE_thread_mutex_t *) \ + ACE_OS_Object_Manager::preallocated_object[ \ + ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); + +// used in Thread +# define ACE_TSS_CLEANUP_GUARD \ + ACE_OS_Recursive_Thread_Mutex_Guard ace_tss_cleanup_guard__ (*(ACE_recursive_thread_mutex_t *) \ + ACE_OS_Object_Manager::preallocated_object[ \ + ACE_OS_Object_Manager::ACE_TSS_CLEANUP_LOCK]); + +// used in Thread +# define ACE_TSS_BASE_GUARD \ + ACE_OS_Recursive_Thread_Mutex_Guard ace_tss_base_guard__ (*(ACE_recursive_thread_mutex_t *) \ + ACE_OS_Object_Manager::preallocated_object[ \ + ACE_OS_Object_Manager::ACE_TSS_BASE_LOCK]); + +#else /* ! ACE_MT_SAFE */ +# define ACE_OS_GUARD +# define ACE_TSS_CLEANUP_GUARD +# define ACE_TSS_BASE_GUARD +#endif /* ! ACE_MT_SAFE */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_Thread.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_THREAD_H */ diff --git a/ace/OS_NS_Thread.inl b/ace/OS_NS_Thread.inl index fc532b41367..73bb51eeeaf 100644 --- a/ace/OS_NS_Thread.inl +++ b/ace/OS_NS_Thread.inl @@ -1,4 +1,4589 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_macros.h" +// for timespec_t, perhaps move it to os_time.h +#include "ace/Time_Value.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" +#if defined (ACE_HAS_PRIOCNTL) +# include /**/ <sys/priocntl.h> +#endif /* ACE_HAS_PRIOCNTL */ + +/*****************************************************************************/ + +#if defined (ACE_LACKS_COND_T) && defined (ACE_HAS_THREADS) +ACE_INLINE long +ACE_cond_t::waiters (void) const +{ + return this->waiters_; +} +#endif /* ACE_LACKS_COND_T && ACE_HAS_THREADS */ + +/*****************************************************************************/ + +#if defined (ACE_HAS_TSS_EMULATION) + +# if !defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) +ACE_INLINE +void **& +ACE_TSS_Emulation::tss_base () +{ +# if defined (VXWORKS) + return (void **&) taskIdCurrent->ACE_VXWORKS_SPARE; +# elif defined (ACE_PSOS) + // not supported + long x=0; //JINLU + return (void **&) x; +# else + // Uh oh. + ACE_NOTSUP_RETURN (0); +# endif /* VXWORKS */ +} +# endif /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */ + +ACE_INLINE +ACE_TSS_Emulation::ACE_TSS_DESTRUCTOR +ACE_TSS_Emulation::tss_destructor (const ACE_thread_key_t key) +{ + ACE_KEY_INDEX (key_index, key); + return tss_destructor_ [key_index]; +} + +ACE_INLINE +void +ACE_TSS_Emulation::tss_destructor (const ACE_thread_key_t key, + ACE_TSS_DESTRUCTOR destructor) +{ + ACE_KEY_INDEX (key_index, key); + tss_destructor_ [key_index] = destructor; +} + +ACE_INLINE +void *& +ACE_TSS_Emulation::ts_object (const ACE_thread_key_t key) +{ + ACE_KEY_INDEX (key_index, key); + +# if defined (ACE_PSOS) + u_long tss_base; + t_getreg (0, PSOS_TASK_REG_TSS, &tss_base); + return ((void **) tss_base)[key_index]; +# else +# if defined (VXWORKS) + /* If someone wants tss_base make sure they get one. This + gets used if someone spawns a VxWorks task directly, not + through ACE. The allocated array will never be deleted! */ + if (0 == taskIdCurrent->ACE_VXWORKS_SPARE) + { + taskIdCurrent->ACE_VXWORKS_SPARE = + ACE_reinterpret_cast (int, new void *[ACE_TSS_THREAD_KEYS_MAX]); + + // Zero the entire TSS array. Do it manually instead of using + // memset, for optimum speed. Though, memset may be faster :-) + void **tss_base_p = + ACE_reinterpret_cast (void **, taskIdCurrent->ACE_VXWORKS_SPARE); + for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p) + { + *tss_base_p = 0; + } + } +# endif /* VXWORKS */ + + return tss_base ()[key_index]; +# endif /* defined (ACE_PSOS) */ +} + +#endif /* ACE_HAS_TSS_EMULATION */ + +/*****************************************************************************/ + +#if 0 +ACE_INLINE int +ACE_OS::thr_continue (const ACE_Thread_ID &thr_id) +{ + ACE_OS_TRACE ("ACE_OS::thr_continue"); + return ACE_OS::thr_continue (thr_id.id ()); +} + +ACE_INLINE int +ACE_OS::thr_create (ACE_THR_FUNC func, + void *args, + long flags, + ACE_Thread_ID *thr_id, + long priority, + void *stack, + size_t stacksize); +{ + ACE_OS_TRACE ("ACE_OS::thr_create"); + ACE_thread_t thread_id; + ACE_hthread_t thread_handle; + + int result = ACE_OS::thr_create (func, args, flags, + &thread_id, &thread_handle, + priority, stack, stacksize); + if (result == -1) + return -1; + else if (thr_id != 0) + { + thr_id->id (thread_id); + thr_id->handle (thread_handle); + return result; + } +} + +ACE_INLINE int +ACE_OS::thr_getprio (const ACE_Thread_ID &thr_id, int &prio) +{ + ACE_OS_TRACE ("ACE_OS::thr_getprio"); + return ACE_OS::thr_getprio (thr_id.handle (), prio); +} + +ACE_INLINE int +ACE_OS::thr_join (const ACE_Thread_ID &thr_id, ACE_THR_FUNC_RETURN *status) +{ +# if defined (ACE_WIN32) + return ACE_OS::thr_join (thr_id.handle (), status); +# else + return ACE_OS::thr_join (thr_id.id (), status); +# endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::thr_cancel (const ACE_Thread_ID &thr_id) +{ + return ACE_OS::thr_cancel (thr_id.id ()); +} + +ACE_INLINE int +ACE_OS::thr_kill (const ACE_Thread_ID &thr_id, int signum) +{ + return ACE_OS::thr_kill (thr_id.id (), signum); +} + +ACE_INLINE ACE_Thread_ID +ACE_OS::thr_self (void) +{ + ACE_hthread_t thr_handle; + ACE_OS::thr_self (thr_handle); + ACE_thread_t thr_id = ACE_OS::thr_self (); + + return ACE_Thread_ID (thr_id, thr_handle); +} + +ACE_INLINE int +ACE_OS::thr_setprio (const ACE_Thread_ID &thr_id, int prio) +{ + ACE_OS_TRACE ("ACE_OS::thr_setprio"); + return ACE_OS::thr_setprio (thr_id.handle (), prio); +} + +ACE_INLINE int +ACE_OS::thr_suspend (const ACE_Thread_ID &thr_id) +{ + return ACE_OS::thr_suspend (thr_id.handle ()); +} + +#endif /* 0 */ + +#if !defined (ACE_LACKS_COND_T) +// NOTE: The ACE_OS::cond_* functions for Unix platforms are defined +// here because the ACE_OS::sema_* functions below need them. +// However, ACE_WIN32 and VXWORKS define the ACE_OS::cond_* functions +// using the ACE_OS::sema_* functions. So, they are defined in OS.cpp. + +ACE_INLINE int +ACE_OS::condattr_destroy (ACE_condattr_t &attributes) +{ +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_condattr_delete (&attributes); +# else + ::pthread_condattr_destroy (&attributes); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + +# elif defined (ACE_HAS_STHREADS) + attributes.type = 0; + +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + attributes = 0; + +# endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. ACE_PSOS */ + return 0; +# else + ACE_UNUSED_ARG (attributes); + return 0; +# endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::condattr_init (ACE_condattr_t &attributes, + int type) +{ + ACE_UNUSED_ARG (type); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + int result = -1; + + if ( +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_condattr_create (&attributes) == 0 +# elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7) + ACE_ADAPT_RETVAL(::pthread_condattr_init (&attributes), result) == 0 +# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED) + && ACE_ADAPT_RETVAL(::pthread_condattr_setpshared(&attributes, type), + result) == 0 +# endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_MUTEXATTR_PSHARED */ +# else /* this is draft 6 */ + ::pthread_condattr_init (&attributes) == 0 +# if !defined (ACE_LACKS_CONDATTR_PSHARED) + && ::pthread_condattr_setpshared (&attributes, type) == 0 +# endif /* ACE_LACKS_CONDATTR_PSHARED */ +# if defined (ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP) + && ::pthread_condattr_setkind_np (&attributes, type) == 0 +# endif /* ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP */ +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + ) + result = 0; + else + result = -1; // ACE_ADAPT_RETVAL used it for intermediate status + + return result; +# elif defined (ACE_HAS_STHREADS) + attributes.type = type; + + return 0; + +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) +# if defined (ACE_PSOS_HAS_PRIO_MUTEX) + attributes = CV_LOCAL | CV_PRIOR; +# else /* ACE_PSOS_HAS_PRIO_MUTEX */ + attributes = CV_LOCAL | CV_FIFO; +# endif /* ACE_PSOS_HAS_PRIO_MUTEX */ + return 0; + +# else + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (type); + ACE_NOTSUP_RETURN (-1); + +# endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. pSOS */ + +# else + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (type); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::cond_broadcast (ACE_cond_t *cv) +{ + ACE_OS_TRACE ("ACE_OS::cond_broadcast"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_cond_broadcast (cv), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_broadcast (cv), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv), + ace_result_), + int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_broadcast (*cv), ace_result_), + int, -1); +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (cv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::cond_destroy (ACE_cond_t *cv) +{ + ACE_OS_TRACE ("ACE_OS::cond_destroy"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_cond_destroy (cv), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_destroy (cv), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), ace_result_), int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_delete (*cv), ace_result_), + int, -1); +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (cv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::cond_init (ACE_cond_t *cv, + ACE_condattr_t &attributes, + const char *name, + void *arg) +{ + // ACE_OS_TRACE ("ACE_OS::cond_init"); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + int result = -1; + + if ( +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_cond_init (cv, attributes) == 0 +# elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7) + ACE_ADAPT_RETVAL(::pthread_cond_init (cv, &attributes), result) == 0 +# else /* this is draft 6 */ + ::pthread_cond_init (cv, &attributes) == 0 +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + ) + result = 0; + else + result = -1; // ACE_ADAPT_RETVAL used it for intermediate status + + return result; +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv, + attributes.type, + arg), + ace_result_), + int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_create (ACE_const_cast (char *, name), + attributes, + cv), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. ACE_PSOS */ +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::cond_init (ACE_cond_t *cv, + ACE_condattr_t &attributes, + const wchar_t *name, + void *arg) +{ + return ACE_OS::cond_init (cv, attributes, ACE_Wide_To_Ascii (name).char_rep (), arg); +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg) +{ + ACE_condattr_t attributes; + if (ACE_OS::condattr_init (attributes, type) == 0 + && ACE_OS::cond_init (cv, attributes, name, arg) == 0) + { + (void) ACE_OS::condattr_destroy (attributes); + return 0; + } + return -1; +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg) +{ + return ACE_OS::cond_init (cv, type, ACE_Wide_To_Ascii (name).char_rep (), arg); +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::cond_signal (ACE_cond_t *cv) +{ + ACE_OS_TRACE ("ACE_OS::cond_signal"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_cond_signal (cv), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_signal (cv),ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), ace_result_), int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_signal (*cv), ace_result_), + int, -1); +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (cv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::cond_wait (ACE_cond_t *cv, + ACE_mutex_t *external_mutex) +{ + ACE_OS_TRACE ("ACE_OS::cond_wait"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_cond_wait (cv, external_mutex), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_wait (cv, external_mutex), ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), ace_result_), + int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, 0), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS */ +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (external_mutex); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::cond_timedwait (ACE_cond_t *cv, + ACE_mutex_t *external_mutex, + ACE_Time_Value *timeout) +{ + ACE_OS_TRACE ("ACE_OS::cond_timedwait"); +# if defined (ACE_HAS_THREADS) + int result; + timespec_t ts; + + if (timeout != 0) + ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). + +# if defined (ACE_HAS_PTHREADS) + +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + if (timeout == 0) + ACE_OSCALL (::pthread_cond_wait (cv, external_mutex), + int, -1, result); + else + { + +# if defined (__Lynx__) + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what the + // LynxOS pthread_cond_timedwait expects). This differs from 1003.4a + // draft 4. + + timespec_t relative_time = *timeout - ACE_OS::gettimeofday (); + + ACE_OSCALL (::pthread_cond_timedwait (cv, external_mutex, + &relative_time), + int, -1, result); +# else + ACE_OSCALL (::pthread_cond_timedwait (cv, external_mutex, + (ACE_TIMESPEC_PTR) &ts), + int, -1, result); +# endif /* __Lynx__ */ + } + +# else + ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0 + ? ::pthread_cond_wait (cv, external_mutex) + : ::pthread_cond_timedwait (cv, external_mutex, + (ACE_TIMESPEC_PTR) &ts), + result), + int, -1, result); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/ + // We need to adjust this to make the POSIX and Solaris return + // values consistent. EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and + // down); EINTR is from LynxOS. + if (result == -1 && + (errno == ETIMEDOUT || errno == EAGAIN || errno == EINTR)) + errno = ETIME; + +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0 + ? ::cond_wait (cv, external_mutex) + : ::cond_timedwait (cv, + external_mutex, + (timestruc_t*)&ts), + result), + int, -1, result); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T) + // pSOS condition value timeout is expressed in ticks. If the + // cv_wait times out, the mutex is unlocked upon return. + if (timeout == 0) + { + ACE_OSCALL (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, 0), + result), + int, -1, result); + } + else + { + // Need to convert the passed absolute time to relative time + // expressed in ticks. + ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + int ticks = (relative_time.sec () * KC_TICKS2SEC) + + (relative_time.usec () * KC_TICKS2SEC / + ACE_ONE_SECOND_IN_USECS); + if (ticks <= 0) + ticks = 1; // Don't wait forever + ACE_OSCALL (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, ticks), + result), + int, -1, result); + if (result == -1 && errno == 1) + { + // cv timed out and returned pSOS timeout error 0x01, which + // ACE_ADAPT_RETVAL stored in errno. + ::mu_lock (*external_mutex, MU_WAIT, 0); + errno = ETIME; + } + } + + return result; + +# endif /* ACE_HAS_STHREADS */ + if (timeout != 0) + timeout->set (ts); // Update the time value before returning. + + return result; +# else + ACE_UNUSED_ARG (cv); + ACE_UNUSED_ARG (external_mutex); + ACE_UNUSED_ARG (timeout); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +#endif /* !ACE_LACKS_COND_T */ + +ACE_INLINE int +ACE_OS::event_destroy (ACE_event_t *event) +{ +#if defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1); +#elif defined (ACE_HAS_THREADS) + int r1 = ACE_OS::mutex_destroy (&event->lock_); + int r2 = ACE_OS::cond_destroy (&event->condition_); + return r1 != 0 || r2 != 0 ? -1 : 0; +#else + ACE_UNUSED_ARG (event); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::event_init (ACE_event_t *event, + int manual_reset, + int initial_state, + int type, + const char *name, + void *arg, + LPSECURITY_ATTRIBUTES sa) +{ +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (arg); +# if defined (ACE_HAS_WINCE) + // @@todo (brunsch) This idea should be moved into ACE_OS_Win32. + *event = ::CreateEventW (ACE_OS::default_win32_security_attributes(sa), + manual_reset, + initial_state, + ACE_Ascii_To_Wide (name).wchar_rep ()); +# else /* ACE_HAS_WINCE */ + *event = ::CreateEventA (ACE_OS::default_win32_security_attributes(sa), + manual_reset, + initial_state, + name); +# endif /* ACE_HAS_WINCE */ + if (*event == 0) + ACE_FAIL_RETURN (-1); + else + return 0; +#elif defined (ACE_HAS_THREADS) + ACE_UNUSED_ARG (sa); + event->manual_reset_ = manual_reset; + event->is_signaled_ = initial_state; + event->waiting_threads_ = 0; + + int result = ACE_OS::cond_init (&event->condition_, + ACE_static_cast (short, type), + name, + arg); + if (result == 0) + result = ACE_OS::mutex_init (&event->lock_, + type, + name, + (ACE_mutexattr_t *) arg); + return result; +#else + ACE_UNUSED_ARG (event); + ACE_UNUSED_ARG (manual_reset); + ACE_UNUSED_ARG (initial_state); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_UNUSED_ARG (sa); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::event_init (ACE_event_t *event, + int manual_reset, + int initial_state, + int type, + const wchar_t *name, + void *arg, + LPSECURITY_ATTRIBUTES sa) +{ +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (arg); + *event = ::CreateEventW (ACE_OS::default_win32_security_attributes(sa), + manual_reset, + initial_state, + name); + if (*event == 0) + ACE_FAIL_RETURN (-1); + + return 0; +#else /* ACE_WIN32 */ + return ACE_OS::event_init (event, + manual_reset, + initial_state, + type, + ACE_Wide_To_Ascii (name).char_rep (), + arg, + sa); +#endif /* ACE_WIN32 */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::event_pulse (ACE_event_t *event) +{ +#if defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1); +#elif defined (ACE_HAS_THREADS) + int result = 0; + int error = 0; + + // grab the lock first + if (ACE_OS::mutex_lock (&event->lock_) == 0) + { + // Manual-reset event. + if (event->manual_reset_ == 1) + { + // Wakeup all waiters. + if (ACE_OS::cond_broadcast (&event->condition_) != 0) + { + result = -1; + error = errno; + } + } + // Auto-reset event: wakeup one waiter. + else if (ACE_OS::cond_signal (&event->condition_) != 0) + { + result = -1; + error = errno; + } + + // Reset event. + event->is_signaled_ = 0; + + // Now we can let go of the lock. + ACE_OS::mutex_unlock (&event->lock_); + + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; + return result; +#else + ACE_UNUSED_ARG (event); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::event_reset (ACE_event_t *event) +{ +#if defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1); +#elif defined (ACE_HAS_THREADS) + int result = 0; + + // Grab the lock first. + if (ACE_OS::mutex_lock (&event->lock_) == 0) + { + // Reset event. + event->is_signaled_ = 0; + + // Now we can let go of the lock. + ACE_OS::mutex_unlock (&event->lock_); + } + else + result = -1; + return result; +#else + ACE_UNUSED_ARG (event); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::event_signal (ACE_event_t *event) +{ +#if defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1); +#elif defined (ACE_HAS_THREADS) + int result = 0; + int error = 0; + + // grab the lock first + if (ACE_OS::mutex_lock (&event->lock_) == 0) + { + // Manual-reset event. + if (event->manual_reset_ == 1) + { + // signal event + event->is_signaled_ = 1; + // wakeup all + if (ACE_OS::cond_broadcast (&event->condition_) != 0) + { + result = -1; + error = errno; + } + } + // Auto-reset event + else + { + if (event->waiting_threads_ == 0) + // No waiters: signal event. + event->is_signaled_ = 1; + + // Waiters: wakeup one waiter. + else if (ACE_OS::cond_signal (&event->condition_) != 0) + { + result = -1; + error = errno; + } + } + + // Now we can let go of the lock. + ACE_OS::mutex_unlock (&event->lock_); + + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; + return result; +#else + ACE_UNUSED_ARG (event); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::event_timedwait (ACE_event_t *event, + ACE_Time_Value *timeout, + int use_absolute_time) +{ +#if defined (ACE_WIN32) + DWORD result; + + if (timeout == 0) + // Wait forever + result = ::WaitForSingleObject (*event, INFINITE); + else if (timeout->sec () == 0 && timeout->usec () == 0) + // Do a "poll". + result = ::WaitForSingleObject (*event, 0); + else + { + // Wait for upto <relative_time> number of milliseconds. Note + // that we must convert between absolute time (which is passed + // as a parameter) and relative time (which is what + // WaitForSingleObjects() expects). + // <timeout> parameter is given in absolute or relative value + // depending on parameter <use_absolute_time>. + int msec_timeout; + if (use_absolute_time) + { + // Time is given in absolute time, we should use + // gettimeofday() to calculate relative time + ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + + // Watchout for situations where a context switch has caused + // the current time to be > the timeout. Thanks to Norbert + // Rapp <NRapp@nexus-informatics.de> for pointing this. + if (relative_time < ACE_Time_Value::zero) + msec_timeout = 0; + else + msec_timeout = relative_time.msec (); + } + else + // time is given in relative time, just convert it into + // milliseconds and use it + msec_timeout = timeout->msec (); + result = ::WaitForSingleObject (*event, msec_timeout); + } + + switch (result) + { + case WAIT_OBJECT_0: + return 0; + case WAIT_TIMEOUT: + errno = ETIME; + return -1; + default: + // This is a hack, we need to find an appropriate mapping... + ACE_OS::set_errno_to_last_error (); + return -1; + } +#elif defined (ACE_HAS_THREADS) + int result = 0; + int error = 0; + + // grab the lock first + if (ACE_OS::mutex_lock (&event->lock_) == 0) + { + if (event->is_signaled_ == 1) + // event is currently signaled + { + if (event->manual_reset_ == 0) + // AUTO: reset state + event->is_signaled_ = 0; + } + else + // event is currently not signaled + { + event->waiting_threads_++; + + ACE_Time_Value absolute_timeout = *timeout; + + // cond_timewait() expects absolute time, check + // <use_absolute_time> flag. + if (use_absolute_time == 0) + absolute_timeout += ACE_OS::gettimeofday (); + + if (ACE_OS::cond_timedwait (&event->condition_, + &event->lock_, + &absolute_timeout) != 0) + { + result = -1; + error = errno; + } + + event->waiting_threads_--; + } + + // Now we can let go of the lock. + ACE_OS::mutex_unlock (&event->lock_); + + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; + return result; +#else + ACE_UNUSED_ARG (event); + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (use_absolute_time); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::event_wait (ACE_event_t *event) +{ +#if defined (ACE_WIN32) + switch (::WaitForSingleObject (*event, INFINITE)) + { + case WAIT_OBJECT_0: + return 0; + default: + ACE_OS::set_errno_to_last_error (); + return -1; + } +#elif defined (ACE_HAS_THREADS) + int result = 0; + int error = 0; + + // grab the lock first + if (ACE_OS::mutex_lock (&event->lock_) == 0) + { + if (event->is_signaled_ == 1) + // Event is currently signaled. + { + if (event->manual_reset_ == 0) + // AUTO: reset state + event->is_signaled_ = 0; + } + else + // event is currently not signaled + { + event->waiting_threads_++; + + if (ACE_OS::cond_wait (&event->condition_, + &event->lock_) != 0) + { + result = -1; + error = errno; + // Something went wrong... + } + + event->waiting_threads_--; + } + + // Now we can let go of the lock. + ACE_OS::mutex_unlock (&event->lock_); + + if (result == -1) + // Reset errno in case mutex_unlock() also fails... + errno = error; + } + else + result = -1; + return result; +#else + ACE_UNUSED_ARG (event); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::mutex_destroy (ACE_mutex_t *m) +{ + ACE_OS_TRACE ("ACE_OS::mutex_destroy"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) + ACE_OSCALL_RETURN (::pthread_mutex_destroy (m), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m), + ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), ace_result_), int, -1); +# elif defined (ACE_HAS_WTHREADS) + switch (m->type_) + { + case USYNC_PROCESS: + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_), + ace_result_), + int, -1); + case USYNC_THREAD: + return ACE_OS::thread_mutex_destroy (&m->thr_mutex_); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ +# elif defined (ACE_PSOS) +# if defined (ACE_PSOS_HAS_MUTEX) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_delete (*m), ace_result_), + int, -1); +# else /* ! ACE_PSOS_HAS_MUTEX */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_delete (*m), ace_result_), + int, -1); +# endif /* ACE_PSOS_HAS_MUTEX */ +# elif defined (VXWORKS) + return ::semDelete (*m) == OK ? 0 : -1; +# endif /* Threads variety case */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::mutex_init (ACE_mutex_t *m, + int type, + const char *name, + ACE_mutexattr_t *attributes, + LPSECURITY_ATTRIBUTES sa) +{ + // ACE_OS_TRACE ("ACE_OS::mutex_init"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (sa); + + pthread_mutexattr_t l_attributes; + if (attributes == 0) + attributes = &l_attributes; + int result = 0; + int attr_init = 0; // have we initialized the local attributes. + + // Only do these initializations if the <attributes> parameter + // wasn't originally set. + if (attributes == &l_attributes) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + if (::pthread_mutexattr_create (attributes) == 0) +# elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD) + if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0) +# else /* draft 6 */ + if (::pthread_mutexattr_init (attributes) == 0) +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + { + result = 0; + attr_init = 1; // we have initialized these attributes + } + else + result = -1; // ACE_ADAPT_RETVAL used it for intermediate status + } + + if (result == 0) + { +# if defined (ACE_HAS_PTHREADS_DRAFT4) + if ( +# if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) + ::pthread_mutexattr_setkind_np (attributes, type) == 0 && +# endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ + ::pthread_mutex_init (m, *attributes) == 0) +# elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD) + if ( +# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED) + ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes, type), + result) == 0 && +# endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_MUTEXATTR_PSHARED */ + ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0) +# else + if ( +# if !defined (ACE_LACKS_MUTEXATTR_PSHARED) + ::pthread_mutexattr_setpshared (attributes, type) == 0 && +# endif /* ACE_LACKS_MUTEXATTR_PSHARED */ +# if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) + ::pthread_mutexattr_setkind_np (attributes, type) == 0 && +# endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ + ::pthread_mutex_init (m, attributes) == 0) +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + result = 0; + else + result = -1; // ACE_ADAPT_RETVAL used it for intermediate status + } + +# if (!defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) && !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_MUTEXATTR_PSHARED)) \ + || ((defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)) && !defined (_POSIX_THREAD_PROCESS_SHARED)) + ACE_UNUSED_ARG (type); +# endif /* ! ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */ + + // Only do the deletions if the <attributes> parameter wasn't + // originally set. + if (attributes == &l_attributes && attr_init) +# if defined (ACE_HAS_PTHREADS_DRAFT4) + ::pthread_mutexattr_delete (&l_attributes); +# else + ::pthread_mutexattr_destroy (&l_attributes); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + + return result; +# elif defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (sa); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m, type, attributes), + ace_result_), + int, -1); +# elif defined (ACE_HAS_WTHREADS) + m->type_ = type; + + switch (type) + { + case USYNC_PROCESS: +# if defined (ACE_HAS_WINCE) + // @@todo (brunsch) This idea should be moved into ACE_OS_Win32. + m->proc_mutex_ = ::CreateMutexW (ACE_OS::default_win32_security_attributes (sa), + FALSE, + ACE_Ascii_To_Wide (name).wchar_rep ()); +# else /* ACE_HAS_WINCE */ + m->proc_mutex_ = ::CreateMutexA (ACE_OS::default_win32_security_attributes (sa), + FALSE, + name); +# endif /* ACE_HAS_WINCE */ + if (m->proc_mutex_ == 0) + ACE_FAIL_RETURN (-1); + else + { + // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary. + ACE_OS::set_errno_to_last_error (); + return 0; + } + case USYNC_THREAD: + return ACE_OS::thread_mutex_init (&m->thr_mutex_, + type, + name, + attributes); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ + +# elif defined (ACE_PSOS) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (sa); +# if defined (ACE_PSOS_HAS_MUTEX) + + u_long flags = MU_LOCAL; + u_long ceiling = 0; + +# if defined (ACE_HAS_RECURSIVE_MUTEXES) + flags |= MU_RECURSIVE; +# else /* ! ACE_HAS_RECURSIVE_MUTEXES */ + flags |= MU_NONRECURSIVE; +# endif /* ACE_HAS_RECURSIVE_MUTEXES */ + +# if defined (ACE_PSOS_HAS_PRIO_MUTEX) + + flags |= MU_PRIOR; + +# if defined (ACE_PSOS_HAS_PRIO_INHERIT_MUTEX) + flags |= MU_PRIO_INHERIT; +# elif defined (ACE_PSOS_HAS_PRIO_PROTECT_MUTEX) + ceiling = PSOS_TASK_MAX_PRIORITY; + flags |= MU_PRIO_PROTECT; +# else + flags |= MU_PRIO_NONE; +# endif /* ACE_PSOS_HAS_PRIO_INHERIT_MUTEX */ + +# else /* ! ACE_PSOS_HAS_PRIO_MUTEX */ + + flags |= MU_FIFO | MU_PRIO_NONE; + +# endif + + // Fake a pSOS name - it can be any 4-byte value, not necessarily needing + // to be ASCII. So use the mutex pointer passed in. That should identify + // each one uniquely. + union { ACE_mutex_t *p; char n[4]; } m_name; + m_name.p = m; + + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_create (m_name.n, + flags, + ceiling, + m), + ace_result_), + int, -1); + +# else /* ! ACE_PSOS_HAS_MUTEX */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_create ((char *) name, + 1, + SM_LOCAL | SM_PRIOR, + m), + ace_result_), + int, -1); +# endif /* ACE_PSOS_HAS_MUTEX */ +# elif defined (VXWORKS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (sa); + + return (*m = ::semMCreate (type)) == 0 ? -1 : 0; +# endif /* ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (attributes); + ACE_UNUSED_ARG (sa); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::mutex_init (ACE_mutex_t *m, + int type, + const wchar_t *name, + ACE_mutexattr_t *attributes, + LPSECURITY_ATTRIBUTES sa) +{ +#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) + m->type_ = type; + + switch (type) + { + case USYNC_PROCESS: + m->proc_mutex_ = ::CreateMutexW (ACE_OS::default_win32_security_attributes (sa), + FALSE, + name); + if (m->proc_mutex_ == 0) + ACE_FAIL_RETURN (-1); + else + return 0; + case USYNC_THREAD: + return ACE_OS::thread_mutex_init (&m->thr_mutex_, + type, + name, + attributes); + } + + errno = EINVAL; + return -1; +#else /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */ + return ACE_OS::mutex_init (m, + type, ACE_Wide_To_Ascii (name).char_rep (), + attributes, + sa); +#endif /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::mutex_lock (ACE_mutex_t *m) +{ + // ACE_OS_TRACE ("ACE_OS::mutex_lock"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + // Note, don't use "::" here since the following call is often a macro. +# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) + ACE_OSCALL_RETURN (pthread_mutex_lock (m), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), ace_result_), int, -1); +# elif defined (ACE_HAS_WTHREADS) + switch (m->type_) + { + case USYNC_PROCESS: + switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) + { + // + // Timeout can't occur, so don't bother checking... + // + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + // We will ignore abandonments in this method + // Note that we still hold the lock + return 0; + default: + // This is a hack, we need to find an appropriate mapping... + ACE_OS::set_errno_to_last_error (); + return -1; + } + case USYNC_THREAD: + return ACE_OS::thread_mutex_lock (&m->thr_mutex_); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ +# elif defined (ACE_PSOS) +# if defined (ACE_PSOS_HAS_MUTEX) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_lock (*m, MU_WAIT, 0), + ace_result_), + int, -1); +# else /* ACE_PSOS_HAS_MUTEX */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_p (*m, SM_WAIT, 0), + ace_result_), + int, -1); +# endif /* ACE_PSOS_HAS_MUTEX */ +# elif defined (VXWORKS) + return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1; +# endif /* Threads variety case */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::mutex_lock (ACE_mutex_t *m, + int &abandoned) +{ + ACE_OS_TRACE ("ACE_OS::mutex_lock"); +#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) + abandoned = 0; + switch (m->type_) + { + case USYNC_PROCESS: + switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) + { + // + // Timeout can't occur, so don't bother checking... + // + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + abandoned = 1; + return 0; // something goofed, but we hold the lock ... + default: + // This is a hack, we need to find an appropriate mapping... + ACE_OS::set_errno_to_last_error (); + return -1; + } + case USYNC_THREAD: + return ACE_OS::thread_mutex_lock (&m->thr_mutex_); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (abandoned); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */ +} + +ACE_INLINE int +ACE_OS::mutex_lock (ACE_mutex_t *m, + const ACE_Time_Value &timeout) +{ +#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS) + +# if defined (ACE_HAS_PTHREADS) + int result; + + // "timeout" should be an absolute time. + + timespec_t ts = timeout; // Calls ACE_Time_Value::operator timespec_t(). + + // Note that the mutex should not be a recursive one, i.e., it + // should only be a standard mutex or an error checking mutex. + + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result); + + // We need to adjust this to make the errno values consistent. + if (result == -1 && errno == ETIMEDOUT) + errno = ETIME; + return result; + +# elif defined (ACE_HAS_WTHREADS) + // Note that we must convert between absolute time (which is passed + // as a parameter) and relative time (which is what the system call + // expects). + ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); + + switch (m->type_) + { + case USYNC_PROCESS: + switch (::WaitForSingleObject (m->proc_mutex_, + relative_time.msec ())) + { + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + // We will ignore abandonments in this method + // Note that we still hold the lock + return 0; + case WAIT_TIMEOUT: + errno = ETIME; + return -1; + default: + // This is a hack, we need to find an appropriate mapping... + ACE_OS::set_errno_to_last_error (); + return -1; + } + case USYNC_THREAD: + ACE_NOTSUP_RETURN (-1); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ + +# elif defined (ACE_PSOS) + + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // the system call expects). + ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); + + u_long ticks = relative_time.sec() * KC_TICKS2SEC + + relative_time.usec () * KC_TICKS2SEC / + ACE_ONE_SECOND_IN_USECS; + if (ticks == 0) + ACE_OSCALL_RETURN (::sm_p (*m, SM_NOWAIT, 0), int, -1); // no timeout + else + ACE_OSCALL_RETURN (::sm_p (*m, SM_WAIT, ticks), int, -1); + +# elif defined (VXWORKS) + + // Note that we must convert between absolute time (which is passed + // as a parameter) and relative time (which is what the system call + // expects). + ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); + + int ticks_per_sec = ::sysClkRateGet (); + + int ticks = relative_time.sec() * ticks_per_sec + + relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; + if (::semTake (*m, ticks) == ERROR) + { + if (errno == S_objLib_OBJ_TIMEOUT) + // Convert the VxWorks errno to one that's common for to ACE + // platforms. + errno = ETIME; + else if (errno == S_objLib_OBJ_UNAVAILABLE) + errno = EBUSY; + return -1; + } + else + return 0; +# endif /* ACE_HAS_PTHREADS */ + +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (timeout); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */ +} + +ACE_INLINE int +ACE_OS::mutex_lock (ACE_mutex_t *m, + const ACE_Time_Value *timeout) +{ + return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout); +} + +ACE_INLINE int +ACE_OS::mutex_trylock (ACE_mutex_t *m) +{ + ACE_OS_TRACE ("ACE_OS::mutex_trylock"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + // Note, don't use "::" here since the following call is often a macro. +# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) + int status = pthread_mutex_trylock (m); + if (status == 1) + status = 0; + else if (status == 0) { + status = -1; + errno = EBUSY; + } + return status; +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), ace_result_), int, -1); +# elif defined (ACE_HAS_WTHREADS) + switch (m->type_) + { + case USYNC_PROCESS: + { + // Try for 0 milliseconds - i.e. nonblocking. + switch (::WaitForSingleObject (m->proc_mutex_, 0)) + { + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + // We will ignore abandonments in this method. Note that + // we still hold the lock. + return 0; + case WAIT_TIMEOUT: + errno = EBUSY; + return -1; + default: + ACE_OS::set_errno_to_last_error (); + return -1; + } + } + case USYNC_THREAD: + return ACE_OS::thread_mutex_trylock (&m->thr_mutex_); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ +# elif defined (ACE_PSOS) +# if defined (ACE_PSOS_HAS_MUTEX) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_lock (*m, MU_NOWAIT, 0), + ace_result_), + int, -1); +# else /* ! ACE_PSOS_HAS_MUTEX */ + switch (::sm_p (*m, SM_NOWAIT, 0)) + { + case 0: + return 0; + case ERR_NOSEM: + errno = EBUSY; + // intentional fall through + default: + return -1; + } +# endif /* ACE_PSOS_HAS_MUTEX */ + +# elif defined (VXWORKS) + if (::semTake (*m, NO_WAIT) == ERROR) + if (errno == S_objLib_OBJ_UNAVAILABLE) + { + // couldn't get the semaphore + errno = EBUSY; + return -1; + } + else + // error + return -1; + else + // got the semaphore + return 0; +# endif /* Threads variety case */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::mutex_trylock (ACE_mutex_t *m, int &abandoned) +{ +#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) + abandoned = 0; + switch (m->type_) + { + case USYNC_PROCESS: + { + // Try for 0 milliseconds - i.e. nonblocking. + switch (::WaitForSingleObject (m->proc_mutex_, 0)) + { + case WAIT_OBJECT_0: + return 0; + case WAIT_ABANDONED: + abandoned = 1; + return 0; // something goofed, but we hold the lock ... + case WAIT_TIMEOUT: + errno = EBUSY; + return -1; + default: + ACE_OS::set_errno_to_last_error (); + return -1; + } + } + case USYNC_THREAD: + return ACE_OS::thread_mutex_trylock (&m->thr_mutex_); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (abandoned); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */ +} + +ACE_INLINE int +ACE_OS::mutex_unlock (ACE_mutex_t *m) +{ + ACE_OS_TRACE ("ACE_OS::mutex_unlock"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + // Note, don't use "::" here since the following call is often a macro. +# if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)) + ACE_OSCALL_RETURN (pthread_mutex_unlock (m), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), ace_result_), int, -1); +# elif defined (ACE_HAS_WTHREADS) + switch (m->type_) + { + case USYNC_PROCESS: + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_), + ace_result_), + int, -1); + case USYNC_THREAD: + return ACE_OS::thread_mutex_unlock (&m->thr_mutex_); + default: + errno = EINVAL; + return -1; + } + /* NOTREACHED */ +# elif defined (ACE_PSOS) +# if defined (ACE_PSOS_HAS_MUTEX) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_unlock (*m), ace_result_), + int, -1); +# else /* ! ACE_PSOS_HAS_MUTEX */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_v (*m), ace_result_), + int, -1); +# endif /* ACE_PSOS_HAS_MUTEX */ +# elif defined (VXWORKS) + return ::semGive (*m) == OK ? 0 : -1; +# endif /* Threads variety case */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::priority_control (ACE_idtype_t idtype, ACE_id_t id, int cmd, void *arg) +{ + ACE_OS_TRACE ("ACE_OS::priority_control"); +#if defined (ACE_HAS_PRIOCNTL) + ACE_OSCALL_RETURN (priocntl (idtype, id, cmd, ACE_static_cast (caddr_t, arg)), + int, -1); +#else /* ! ACE_HAS_PRIOCNTL*/ + ACE_UNUSED_ARG (idtype); + ACE_UNUSED_ARG (id); + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +#endif /* ! ACE_HAS_PRIOCNTL*/ +} + +// This method is used to prepare the recursive mutex for releasing +// when waiting on a condition variable. If the platform doesn't have +// native recursive mutex and condition variable support, then ACE needs +// to save the recursion state around the wait and also ensure that the +// wait and lock release are atomic. recursive_mutex_cond_relock() +// is the inverse of this method. +ACE_INLINE int +ACE_OS::recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, + ACE_recursive_mutex_state &state) +{ +#if defined (ACE_HAS_THREADS) + ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock"); +# if defined (ACE_HAS_RECURSIVE_MUTEXES) + // Windows need special handling since it has recursive mutexes, but + // does not integrate them into a condition variable. +# if defined (ACE_WIN32) + // For Windows, the OS takes care of the mutex and its recursion. We just + // need to release the lock one fewer times than this thread has acquired + // it. Remember how many times, and reacquire it that many more times when + // the condition is signaled. + state.relock_count_ = 0; + while (m->LockCount > 0 +# if !defined (ACE_HAS_WINCE) /* WinCE doesn't have RecursionCount */ + && m->RecursionCount > 1 +# endif + ) + { + // This may fail if the current thread doesn't own the mutex. If it + // does fail, it'll be on the first try, so don't worry about resetting + // the state. + if (ACE_OS::recursive_mutex_unlock (m) == -1) + return -1; + ++state.relock_count_; + } +# else /* not ACE_WIN32 */ + // prevent warnings for unused variables + ACE_UNUSED_ARG (state); + ACE_UNUSED_ARG (m); +# endif /* ACE_WIN32 */ + return 0; +# else /* ACE_HAS_RECURSIVE_MUTEXES */ + // For platforms without recursive mutexes, we obtain the nesting mutex + // to gain control over the mutex internals. Then set the internals to say + // the mutex is available. If there are waiters, signal the condition + // to notify them (this is mostly like the recursive_mutex_unlock() method). + // Then, return with the nesting mutex still held. The condition wait + // will release it atomically, allowing mutex waiters to continue. + // Note that this arrangement relies on the fact that on return from + // the condition wait, this thread will again own the nesting mutex + // and can either set the mutex internals directly or get in line for + // the mutex... this part is handled in recursive_mutex_cond_relock(). + if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) + return -1; + +# if !defined (ACE_NDEBUG) + if (m->nesting_level_ == 0 + || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0) + { + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + errno = EINVAL; + return -1; + } +# endif /* ACE_NDEBUG */ + + // To make error recovery a bit easier, signal the condition now. Any + // waiter won't regain control until the mutex is released, which won't + // be until the caller returns and does the wait on the condition. + if (ACE_OS::cond_signal (&m->lock_available_) == -1) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + return -1; + } + + // Ok, the nesting_mutex_ lock is still held, the condition has been + // signaled... reset the nesting info and return _WITH_ the lock + // held. The lock will be released when the condition waits, in the + // caller. + state.nesting_level_ = m->nesting_level_; + state.owner_id_ = m->owner_id_; + m->nesting_level_ = 0; + m->owner_id_ = ACE_OS::NULL_thread; + return 0; +# endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (state); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + + +// This method is called after waiting on a condition variable when a +// recursive mutex must be reacquired. If the platform doesn't natively +// integrate recursive mutexes and condition variables, it's taken care +// of here (inverse of ACE_OS::recursive_mutex_cond_unlock). +ACE_INLINE void +ACE_OS::recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, + ACE_recursive_mutex_state &state) +{ +#if defined (ACE_HAS_THREADS) + ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock"); +# if defined (ACE_HAS_RECURSIVE_MUTEXES) + // Windows need special handling since it has recursive mutexes, but + // does not integrate them into a condition variable. + // On entry, the OS has already reacquired the lock for us. Just + // reacquire it the proper number of times so the recursion is the same as + // before waiting on the condition. +# if defined (ACE_WIN32) + while (state.relock_count_ > 0) + { + ACE_OS::recursive_mutex_lock (m); + --state.relock_count_; + } + return; +# else /* not ACE_WIN32 */ + // prevent warnings for unused variables + ACE_UNUSED_ARG (state); + ACE_UNUSED_ARG (m); + +# endif /* ACE_WIN32 */ +# else + // Without recursive mutex support, it's somewhat trickier. On entry, + // the current thread holds the nesting_mutex_, but another thread may + // still be holding the ACE_recursive_mutex_t. If so, mimic the code + // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex. + // After acquiring it, restore the nesting counts and release the + // nesting mutex. This will restore the conditions to what they were + // before calling ACE_OS::recursive_mutex_cond_unlock(). + while (m->nesting_level_ > 0) + ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_); + + // At this point, we still have nesting_mutex_ and the mutex is free. + m->nesting_level_ = state.nesting_level_; + m->owner_id_ = state.owner_id_; + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + return; +# endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (state); + return; +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m) +{ +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_RECURSIVE_MUTEXES) + return ACE_OS::thread_mutex_destroy (m); +#else + if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1) + return -1; + else if (ACE_OS::cond_destroy (&m->lock_available_) == -1) + return -1; + else + return 0; +#endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::recursive_mutex_init (ACE_recursive_thread_mutex_t *m, + const ACE_TCHAR *name, + ACE_mutexattr_t *arg, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_UNUSED_ARG (sa); +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_RECURSIVE_MUTEXES) + return ACE_OS::thread_mutex_init (m, 0, name, arg); +#else + if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1) + return -1; + else if (ACE_OS::cond_init (&m->lock_available_, + (short) USYNC_THREAD, + name, + 0) == -1) + return -1; + else + { + m->nesting_level_ = 0; + m->owner_id_ = ACE_OS::NULL_thread; + return 0; + } +#endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::recursive_mutex_lock (ACE_recursive_thread_mutex_t *m) +{ +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_RECURSIVE_MUTEXES) + return ACE_OS::thread_mutex_lock (m); +#else + ACE_thread_t t_id = ACE_OS::thr_self (); + int result = 0; + + // Acquire the guard. + if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) + result = -1; + else + { + // If there's no contention, just grab the lock immediately + // (since this is the common case we'll optimize for it). + if (m->nesting_level_ == 0) + m->owner_id_ = t_id; + // If we already own the lock, then increment the nesting level + // and return. + else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0) + { + // Wait until the nesting level has dropped to zero, at + // which point we can acquire the lock. + while (m->nesting_level_ > 0) + ACE_OS::cond_wait (&m->lock_available_, + &m->nesting_mutex_); + + // At this point the nesting_mutex_ is held... + m->owner_id_ = t_id; + } + + // At this point, we can safely increment the nesting_level_ no + // matter how we got here! + m->nesting_level_++; + } + + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + } + return result; +#endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m) +{ +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_RECURSIVE_MUTEXES) + return ACE_OS::thread_mutex_trylock (m); +#else + ACE_thread_t t_id = ACE_OS::thr_self (); + int result = 0; + + // Acquire the guard. + if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) + result = -1; + else + { + // If there's no contention, just grab the lock immediately. + if (m->nesting_level_ == 0) + { + m->owner_id_ = t_id; + m->nesting_level_ = 1; + } + // If we already own the lock, then increment the nesting level + // and proceed. + else if (ACE_OS::thr_equal (t_id, m->owner_id_)) + m->nesting_level_++; + else + { + errno = EBUSY; + result = -1; + } + } + + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + } + return result; +#endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m) +{ +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_RECURSIVE_MUTEXES) + return ACE_OS::thread_mutex_unlock (m); +# else + ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock"); +# if !defined (ACE_NDEBUG) + ACE_thread_t t_id = ACE_OS::thr_self (); +# endif /* ACE_NDEBUG */ + int result = 0; + + if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) + result = -1; + else + { +# if !defined (ACE_NDEBUG) + if (m->nesting_level_ == 0 + || ACE_OS::thr_equal (t_id, m->owner_id_) == 0) + { + errno = EINVAL; + result = -1; + } + else +# endif /* ACE_NDEBUG */ + { + m->nesting_level_--; + if (m->nesting_level_ == 0) + { + // This may not be strictly necessary, but it does put + // the mutex into a known state... + m->owner_id_ = ACE_OS::NULL_thread; + + // Inform a waiter that the lock is free. + if (ACE_OS::cond_signal (&m->lock_available_) == -1) + result = -1; + } + } + } + + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); + } + return result; +# endif /* ACE_HAS_RECURSIVE_MUTEXES */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::rw_rdlock (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rw_rdlock"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw), + ace_result_), + int, -1); +# else /* Solaris */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +# else /* NT, POSIX, and VxWorks don't support this natively. */ +# if defined (ACE_HAS_PTHREADS) + ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); +# endif /* ACE_HAS_PTHREADS */ + int result = 0; + if (ACE_OS::mutex_lock (&rw->lock_) == -1) + result = -1; // -1 means didn't get the mutex. + else + { + // Give preference to writers who are waiting. + while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0) + { + rw->num_waiting_readers_++; + if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1) + { + result = -2; // -2 means that we need to release the mutex. + break; + } + rw->num_waiting_readers_--; + } + } + if (result == 0) + rw->ref_count_++; + if (result != -1) + ACE_OS::mutex_unlock (&rw->lock_); +# if defined (ACE_HAS_PTHREADS) + ACE_PTHREAD_CLEANUP_POP (0); +# endif /* defined (ACE_HAS_PTHREADS) */ + return 0; +# endif /* ! ACE_LACKS_RWLOCK_T */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::rw_tryrdlock (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rw_tryrdlock"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw), + ace_result_), + int, -1); +# else /* Solaris */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +# else /* NT, POSIX, and VxWorks don't support this natively. */ + int result = -1; + + if (ACE_OS::mutex_lock (&rw->lock_) != -1) + { + ACE_Errno_Guard error (errno); + + if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0) + { + error = EBUSY; + result = -1; + } + else + { + rw->ref_count_++; + result = 0; + } + + ACE_OS::mutex_unlock (&rw->lock_); + } + return result; +# endif /* ! ACE_LACKS_RWLOCK_T */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::rw_trywrlock (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rw_trywrlock"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw), + ace_result_), + int, -1); +# else /* Solaris */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +# else /* NT, POSIX, and VxWorks don't support this natively. */ + int result = -1; + + if (ACE_OS::mutex_lock (&rw->lock_) != -1) + { + ACE_Errno_Guard error (errno); + + if (rw->ref_count_ != 0) + { + error = EBUSY; + result = -1; + } + else + { + rw->ref_count_ = -1; + result = 0; + } + + ACE_OS::mutex_unlock (&rw->lock_); + } + return result; +# endif /* ! ACE_LACKS_RWLOCK_T */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +// Note that the caller of this method *must* already possess this +// lock as a read lock. +// return {-1 and no errno set means: error, +// -1 and errno==EBUSY set means: could not upgrade, +// 0 means: upgraded successfully} + +ACE_INLINE int +ACE_OS::rw_trywrlock_upgrade (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) + // Some native rwlocks, such as those on Solaris and HP-UX 11, don't + // support the upgrade feature . . . + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +# else /* NT, POSIX, and VxWorks don't support this natively. */ + // The ACE rwlock emulation does support upgrade . . . + int result = 0; + +# if defined (ACE_HAS_PTHREADS) + ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); +# endif /* defined (ACE_HAS_PTHREADS) */ + + if (ACE_OS::mutex_lock (&rw->lock_) == -1) + return -1; + // -1 means didn't get the mutex, error + else if (rw->important_writer_) + // an other reader upgrades already + { + result = -1; + errno = EBUSY; + } + else + { + while (rw->ref_count_ > 1) // wait until only I am left + { + rw->num_waiting_writers_++; // prohibit any more readers + rw->important_writer_ = 1; + + if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1) + { + result = -1; + // we know that we have the lock again, we have this guarantee, + // but something went wrong + } + rw->important_writer_ = 0; + rw->num_waiting_writers_--; + } + if (result == 0) + { + // nothing bad happend + rw->ref_count_ = -1; + // now I am a writer + // everything is O.K. + } + } + + ACE_OS::mutex_unlock (&rw->lock_); + +# if defined (ACE_HAS_PTHREADS) + ACE_PTHREAD_CLEANUP_POP (0); +# endif /* defined (ACE_HAS_PTHREADS) */ + + return result; + +# endif /* ! ACE_LACKS_RWLOCK_T */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::rw_unlock (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rw_unlock"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw), + ace_result_), + int, -1); +# else /* Solaris */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +# else /* NT, POSIX, and VxWorks don't support this natively. */ + if (ACE_OS::mutex_lock (&rw->lock_) == -1) + return -1; + + if (rw->ref_count_ > 0) // Releasing a reader. + rw->ref_count_--; + else if (rw->ref_count_ == -1) // Releasing a writer. + rw->ref_count_ = 0; + else + return -1; // @@ ACE_ASSERT (!"count should not be 0!\n"); + + + int result = 0; + ACE_Errno_Guard error (errno); + + if (rw->important_writer_ && rw->ref_count_ == 1) + // only the reader requesting to upgrade its lock is left over. + { + result = ACE_OS::cond_signal (&rw->waiting_important_writer_); + error = errno; + } + else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0) + // give preference to writers over readers... + { + result = ACE_OS::cond_signal (&rw->waiting_writers_); + error = errno; + } + else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0) + { + result = ACE_OS::cond_broadcast (&rw->waiting_readers_); + error = errno; + } + + ACE_OS::mutex_unlock (&rw->lock_); + return result; +# endif /* ! ace_lacks_rwlock_t */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ace_has_threads */ +} + +ACE_INLINE int +ACE_OS::rw_wrlock (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rw_wrlock"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw), + ace_result_), + int, -1); +# else /* Solaris */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +# else /* NT, POSIX, and VxWorks don't support this natively. */ +# if defined (ACE_HAS_PTHREADS) + ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); +# endif /* defined (ACE_HAS_PTHREADS) */ + int result = 0; + + if (ACE_OS::mutex_lock (&rw->lock_) == -1) + result = -1; // -1 means didn't get the mutex. + else + { + while (rw->ref_count_ != 0) + { + rw->num_waiting_writers_++; + + if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1) + { + result = -2; // -2 means we need to release the mutex. + break; + } + + rw->num_waiting_writers_--; + } + } + if (result == 0) + rw->ref_count_ = -1; + if (result != -1) + ACE_OS::mutex_unlock (&rw->lock_); +# if defined (ACE_HAS_PTHREADS) + ACE_PTHREAD_CLEANUP_POP (0); +# endif /* defined (ACE_HAS_PTHREADS) */ + return 0; +# endif /* ! ACE_LACKS_RWLOCK_T */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::rwlock_destroy (ACE_rwlock_t *rw) +{ + ACE_OS_TRACE ("ACE_OS::rwlock_destroy"); +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw), + ace_result_), + int, -1); +# else /* Solaris */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +# else /* NT, POSIX, and VxWorks don't support this natively. */ + ACE_OS::mutex_destroy (&rw->lock_); + ACE_OS::cond_destroy (&rw->waiting_readers_); + ACE_OS::cond_destroy (&rw->waiting_important_writer_); + return ACE_OS::cond_destroy (&rw->waiting_writers_); +# endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */ +#else + ACE_UNUSED_ARG (rw); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +#if defined (ACE_HAS_THREADS) && (!defined (ACE_LACKS_RWLOCK_T) || \ + defined (ACE_HAS_PTHREADS_UNIX98_EXT)) +ACE_INLINE int +ACE_OS::rwlock_init (ACE_rwlock_t *rw, + int type, + const ACE_TCHAR *name, + void *arg) +{ + // ACE_OS_TRACE ("ACE_OS::rwlock_init"); +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + + int status; + pthread_rwlockattr_t attr; + pthread_rwlockattr_init (&attr); + pthread_rwlockattr_setpshared (&attr, (type == USYNC_THREAD ? + PTHREAD_PROCESS_PRIVATE : + PTHREAD_PROCESS_SHARED)); + status = ACE_ADAPT_RETVAL (pthread_rwlock_init (rw, &attr), status); + pthread_rwlockattr_destroy (&attr); + + return status; + +# else + type = type; + name = name; + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), ace_result_), int, -1); +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ +} +#endif /* ACE_HAS THREADS && !defined (ACE_LACKS_RWLOCK_T) */ + +ACE_INLINE int +ACE_OS::sema_destroy (ACE_sema_t *s) +{ + ACE_OS_TRACE ("ACE_OS::sema_destroy"); +# if defined (ACE_HAS_POSIX_SEM) + int result; +# if defined (ACE_LACKS_NAMED_POSIX_SEM) + if (s->name_) + { + // Only destroy the semaphore if we're the ones who + // initialized it. + ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result); + ACE_OS::shm_unlink (s->name_); + delete s->name_; + return result; + } +# else + if (s->name_) + { + ACE_OSCALL (::sem_unlink (s->name_), int, -1, result); + ACE_OS::free ((void *) s->name_); + ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1); + } +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ + else + { + ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result); +# if defined (ACE_LACKS_NAMED_POSIX_SEM) + if (s->new_sema_ != 0) +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ + delete s->sema_; + s->sema_ = 0; + return result; + } +# elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), ace_result_), int, -1); +# elif defined (ACE_HAS_PTHREADS) + int r1 = ACE_OS::mutex_destroy (&s->lock_); + int r2 = ACE_OS::cond_destroy (&s->count_nonzero_); + return r1 != 0 || r2 != 0 ? -1 : 0; +# elif defined (ACE_HAS_WTHREADS) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1); +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + // Free up underlying objects of the simulated semaphore. + int r1 = ACE_OS::thread_mutex_destroy (&s->lock_); + int r2 = ACE_OS::event_destroy (&s->count_nonzero_); + return r1 != 0 || r2 != 0 ? -1 : 0; +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + int result; + ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_delete (s->sema_), result), int, -1, result); + s->sema_ = 0; + return result; +# elif defined (VXWORKS) + int result; + ACE_OSCALL (::semDelete (s->sema_), int, -1, result); + s->sema_ = 0; + return result; +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (s); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_POSIX_SEM */ +} + +// NOTE: The previous four function definitions must appear before +// ACE_OS::sema_init (). + +ACE_INLINE int +ACE_OS::sema_init (ACE_sema_t *s, + u_int count, + int type, + const char *name, + void *arg, + int max, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_OS_TRACE ("ACE_OS::sema_init"); +#if defined (ACE_HAS_POSIX_SEM) + ACE_UNUSED_ARG (arg); + ACE_UNUSED_ARG (max); + ACE_UNUSED_ARG (sa); + + s->name_ = 0; + +# if defined (ACE_LACKS_NAMED_POSIX_SEM) + s->new_sema_ = 0; + if (type == USYNC_PROCESS) + { + // Let's see if it already exists. + ACE_HANDLE fd = ACE_OS::shm_open (name, + O_RDWR | O_CREAT | O_EXCL, + ACE_DEFAULT_FILE_PERMS); + if (fd == ACE_INVALID_HANDLE) + { + if (errno == EEXIST) + fd = ACE_OS::shm_open (name, + O_RDWR | O_CREAT, + ACE_DEFAULT_FILE_PERMS); + else + return -1; + } + else + { + // We own this shared memory object! Let's set its + // size. + if (ACE_OS::ftruncate (fd, + sizeof (ACE_sema_t)) == -1) + return -1; + s->name_ = ACE_OS::strdup (name); + if (s->name_ == 0) + return -1; + } + if (fd == -1) + return -1; + + s->sema_ = (sem_t *) + ACE_OS::mmap (0, + sizeof (ACE_sema_t), + PROT_RDWR, + MAP_SHARED, + fd, + 0); + ACE_OS::close (fd); + if (s->sema_ == (sem_t *) MAP_FAILED) + return -1; + if (s->name_ + // @@ According UNIX Network Programming V2 by Stevens, + // sem_init() is currently not required to return zero on + // success, but it *does* return -1 upon failure. For + // this reason, check for failure by comparing to -1, + // instead of checking for success by comparing to zero. + // -Ossama + // Only initialize it if we're the one who created it. + && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1) + return -1; + return 0; + } +# else + if (name) + { +# if defined (sun) || defined (HPUX) + // Solaris and HP-UX require the name to start with a slash. Solaris + // further requires that there be no other slashes than the first. + const char *last_slash = ACE_OS::strrchr (name, '/'); + char name2[MAXPATHLEN]; + if (0 == last_slash) + { + ACE_OS::strcpy (name2, "/"); + ACE_OS::strcat (name2, name); + name = name2; + } +# if defined (sun) + else + name = last_slash; // Chop off chars preceding last slash +# endif /* sun */ +# endif /* sun || HPUX */ + + ACE_ALLOCATOR_RETURN (s->name_, + ACE_OS::strdup (name), + -1); + s->sema_ = ::sem_open (s->name_, + O_CREAT, + ACE_DEFAULT_FILE_PERMS, + count); + if (s->sema_ == (sem_t *) SEM_FAILED) + return -1; + else + return 0; + } +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ + else + { + ACE_NEW_RETURN (s->sema_, + sem_t, + -1); +# if defined (ACE_LACKS_NAMED_POSIX_SEM) + s->new_sema_ = 1; +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ + ACE_OSCALL_RETURN (::sem_init (s->sema_, + type != USYNC_THREAD, + count), int, -1); + } +#elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (max); + ACE_UNUSED_ARG (sa); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), ace_result_), + int, -1); +# elif defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (max); + ACE_UNUSED_ARG (sa); + int result = -1; + + if (ACE_OS::mutex_init (&s->lock_, type, name, + (ACE_mutexattr_t *) arg) == 0 + && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0 + && ACE_OS::mutex_lock (&s->lock_) == 0) + { + s->count_ = count; + s->waiters_ = 0; + + if (ACE_OS::mutex_unlock (&s->lock_) == 0) + result = 0; + } + + if (result == -1) + { + ACE_OS::mutex_destroy (&s->lock_); + ACE_OS::cond_destroy (&s->count_nonzero_); + } + return result; +# elif defined (ACE_HAS_WTHREADS) +# if ! defined (ACE_USES_WINCE_SEMA_SIMULATION) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (arg); + // Create the semaphore with its value initialized to <count> and + // its maximum value initialized to <max>. + *s = + ::CreateSemaphoreA (ACE_OS::default_win32_security_attributes (sa), + count, + max, + name); + + if (*s == 0) + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ + else + return 0; +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + int result = -1; + + // Initialize internal object for semaphore simulation. + // Grab the lock as soon as possible when we initializing + // the semaphore count. Notice that we initialize the + // event object as "manually reset" so we can amortize the + // cost for singling/reseting the event. + // @@ I changed the mutex type to thread_mutex. Notice that this + // is basically a CriticalSection object and doesn't not has + // any security attribute whatsoever. However, since this + // semaphore implementation only works within a process, there + // shouldn't any security issue at all. + if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0 + && ACE_OS::event_init (&s->count_nonzero_, 1, + count > 0, type, name, arg, sa) == 0 + && ACE_OS::thread_mutex_lock (&s->lock_) == 0) + { + s->count_ = count; + + if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0) + result = 0; + } + + // Destroy the internal objects if we didn't initialize + // either of them successfully. Don't bother to check + // for errors. + if (result == -1) + { + ACE_OS::thread_mutex_destroy (&s->lock_); + ACE_OS::event_destroy (&s->count_nonzero_); + } + return result; +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + u_long result; + ACE_OS::memcpy (s->name_, name, sizeof (s->name_)); + // default semaphore creation flags to priority based, global across nodes + u_long flags = 0; + flags |= (type & SM_LOCAL) ? SM_LOCAL : SM_GLOBAL; + flags |= (type & SM_FIFO) ? SM_FIFO : SM_PRIOR; + result = ::sm_create (s->name_, count, flags, &(s->sema_)); + return (result == 0) ? 0 : -1; +# elif defined (VXWORKS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_UNUSED_ARG (max); + ACE_UNUSED_ARG (sa); + s->name_ = 0; + s->sema_ = ::semCCreate (type, count); + return s->sema_ ? 0 : -1; +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (s); + ACE_UNUSED_ARG (count); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_UNUSED_ARG (max); + ACE_UNUSED_ARG (sa); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_POSIX_SEM */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::sema_init (ACE_sema_t *s, + u_int count, + int type, + const wchar_t *name, + void *arg, + int max, + LPSECURITY_ATTRIBUTES sa) +{ +# if defined (ACE_HAS_WTHREADS) +# if ! defined (ACE_USES_WINCE_SEMA_SIMULATION) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (arg); + // Create the semaphore with its value initialized to <count> and + // its maximum value initialized to <max>. + *s = + ::CreateSemaphoreW (ACE_OS::default_win32_security_attributes (sa), + count, + max, + name); + + if (*s == 0) + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ + else + return 0; +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + int result = -1; + + // Initialize internal object for semaphore simulation. + // Grab the lock as soon as possible when we initializing + // the semaphore count. Notice that we initialize the + // event object as "manually reset" so we can amortize the + // cost for singling/reseting the event. + // @@ I changed the mutex type to thread_mutex. Notice that this + // is basically a CriticalSection object and doesn't not has + // any security attribute whatsoever. However, since this + // semaphore implementation only works within a process, there + // shouldn't any security issue at all. + if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0 + && ACE_OS::event_init (&s->count_nonzero_, 1, + count > 0, type, name, arg, sa) == 0 + && ACE_OS::thread_mutex_lock (&s->lock_) == 0) + { + s->count_ = count; + + if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0) + result = 0; + } + + // Destroy the internal objects if we didn't initialize + // either of them successfully. Don't bother to check + // for errors. + if (result == -1) + { + ACE_OS::thread_mutex_destroy (&s->lock_); + ACE_OS::event_destroy (&s->count_nonzero_); + } + return result; +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# else /* ACE_HAS_WTHREADS */ + // Just call the normal char version. + return ACE_OS::sema_init (s, count, type, ACE_Wide_To_Ascii (name).char_rep (), arg, max, sa); +# endif /* ACE_HAS_WTHREADS */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::sema_post (ACE_sema_t *s) +{ + ACE_OS_TRACE ("ACE_OS::sema_post"); +# if defined (ACE_HAS_POSIX_SEM) + ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1); +# elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), ace_result_), int, -1); +# elif defined (ACE_HAS_PTHREADS) + int result = -1; + + if (ACE_OS::mutex_lock (&s->lock_) == 0) + { + // Always allow a waiter to continue if there is one. + if (s->waiters_ > 0) + result = ACE_OS::cond_signal (&s->count_nonzero_); + else + result = 0; + + s->count_++; + ACE_OS::mutex_unlock (&s->lock_); + } + return result; +# elif defined (ACE_HAS_WTHREADS) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0), + ace_result_), + int, -1); +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + int result = -1; + + // Since we are simulating semaphores, we need to update semaphore + // count manually. Grab the lock to prevent race condition first. + if (ACE_OS::thread_mutex_lock (&s->lock_) == 0) + { + // Check the original state of event object. Single the event + // object in transition from semaphore not available to + // semaphore available. + if (s->count_++ <= 0) + result = ACE_OS::event_signal (&s->count_nonzero_); + else + result = 0; + + ACE_OS::thread_mutex_unlock (&s->lock_); + } + return result; +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + int result; + ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_v (s->sema_), result), int, -1, result); + return result; +# elif defined (VXWORKS) + ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1); +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (s); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_POSIX_SEM */ +} + +ACE_INLINE int +ACE_OS::sema_post (ACE_sema_t *s, u_int release_count) +{ +#if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION) + // Win32 supports this natively. + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0), + ace_result_), int, -1); +#else + // On POSIX platforms we need to emulate this ourselves. + // @@ We can optimize on this implementation. However, + // the semaphore promitive on Win32 doesn't allow one + // to increase a semaphore to more than the count it was + // first initialized. Posix and solaris don't seem to have + // this restriction. Should we impose the restriction in + // our semaphore simulation? + for (size_t i = 0; i < release_count; i++) + if (ACE_OS::sema_post (s) == -1) + return -1; + + return 0; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::sema_trywait (ACE_sema_t *s) +{ + ACE_OS_TRACE ("ACE_OS::sema_trywait"); +# if defined (ACE_HAS_POSIX_SEM) + // POSIX semaphores set errno to EAGAIN if trywait fails + ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1); +# elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + // STHREADS semaphores set errno to EBUSY if trywait fails. + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s), + ace_result_), + int, -1); +# elif defined (ACE_HAS_PTHREADS) + + int result = -1; + + if (ACE_OS::mutex_lock (&s->lock_) == 0) + { + if (s->count_ > 0) + { + --s->count_; + result = 0; + } + else + errno = EBUSY; + + ACE_OS::mutex_unlock (&s->lock_); + } + return result; +# elif defined (ACE_HAS_WTHREADS) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + int result = ::WaitForSingleObject (*s, 0); + + if (result == WAIT_OBJECT_0) + return 0; + else + { + if (result == WAIT_TIMEOUT) + errno = EBUSY; + else + ACE_OS::set_errno_to_last_error (); + // This is a hack, we need to find an appropriate mapping... + return -1; + } +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + // Check the status of semaphore first. Return immediately + // if the semaphore is not available and avoid grabing the + // lock. + int result = ::WaitForSingleObject (s->count_nonzero_, 0); + + if (result == WAIT_OBJECT_0) // Proceed when it is available. + { + ACE_OS::thread_mutex_lock (&s->lock_); + + // Need to double check if the semaphore is still available. + // The double checking scheme will slightly affect the + // efficiency if most of the time semaphores are not blocked. + result = ::WaitForSingleObject (s->count_nonzero_, 0); + if (result == WAIT_OBJECT_0) + { + // Adjust the semaphore count. Only update the event + // object status when the state changed. + s->count_--; + if (s->count_ <= 0) + ACE_OS::event_reset (&s->count_nonzero_); + result = 0; + } + + ACE_OS::thread_mutex_unlock (&s->lock_); + } + + // Translate error message to errno used by ACE. + if (result == WAIT_TIMEOUT) + errno = EBUSY; + else + ACE_OS::set_errno_to_last_error (); + // This is taken from the hack above. ;) + return -1; +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + switch (::sm_p (s->sema_, SM_NOWAIT, 0)) + { + case 0: + return 0; + case ERR_NOSEM: + errno = EBUSY; + // intentional fall through + default: + return -1; + } +# elif defined (VXWORKS) + if (::semTake (s->sema_, NO_WAIT) == ERROR) + if (errno == S_objLib_OBJ_UNAVAILABLE) + { + // couldn't get the semaphore + errno = EBUSY; + return -1; + } + else + // error + return -1; + else + // got the semaphore + return 0; +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (s); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_POSIX_SEM */ +} + +ACE_INLINE int +ACE_OS::sema_wait (ACE_sema_t *s) +{ + ACE_OS_TRACE ("ACE_OS::sema_wait"); +# if defined (ACE_HAS_POSIX_SEM) + ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1); +# elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), ace_result_), int, -1); +# elif defined (ACE_HAS_PTHREADS) + int result = 0; + + ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); + + if (ACE_OS::mutex_lock (&s->lock_) != 0) + result = -1; + else + { + // Keep track of the number of waiters so that we can signal + // them properly in <ACE_OS::sema_post>. + s->waiters_++; + + // Wait until the semaphore count is > 0. + while (s->count_ == 0) + if (ACE_OS::cond_wait (&s->count_nonzero_, + &s->lock_) == -1) + { + result = -2; // -2 means that we need to release the mutex. + break; + } + + --s->waiters_; + } + + if (result == 0) + --s->count_; + + if (result != -1) + ACE_OS::mutex_unlock (&s->lock_); + ACE_PTHREAD_CLEANUP_POP (0); + return result < 0 ? -1 : result; + +# elif defined (ACE_HAS_WTHREADS) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + switch (::WaitForSingleObject (*s, INFINITE)) + { + case WAIT_OBJECT_0: + return 0; + default: + // This is a hack, we need to find an appropriate mapping... + ACE_OS::set_errno_to_last_error (); + return -1; + } + /* NOTREACHED */ +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + // Timed wait. + int result = -1; + for (;;) + // Check if the semaphore is avialable or not and wait forever. + // Don't bother to grab the lock if it is not available (to avoid + // deadlock.) + switch (::WaitForSingleObject (s->count_nonzero_, INFINITE)) + { + case WAIT_OBJECT_0: + ACE_OS::thread_mutex_lock (&s->lock_); + + // Need to double check if the semaphore is still available. + // This time, we shouldn't wait at all. + if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0) + { + // Decrease the internal counter. Only update the event + // object's status when the state changed. + s->count_--; + if (s->count_ <= 0) + ACE_OS::event_reset (&s->count_nonzero_); + result = 0; + } + + ACE_OS::thread_mutex_unlock (&s->lock_); + // if we didn't get a hold on the semaphore, the result won't + // be 0 and thus, we'll start from the beginning again. + if (result == 0) + return 0; + break; + + default: + // Since we wait indefinitely, anything other than + // WAIT_OBJECT_O indicates an error. + ACE_OS::set_errno_to_last_error (); + // This is taken from the hack above. ;) + return -1; + } + /* NOTREACHED */ +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + int result; + ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_WAIT, 0), result), + int, -1, result); + return result; +# elif defined (VXWORKS) + ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1); +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (s); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_POSIX_SEM */ +} + +ACE_INLINE int +ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) +{ + ACE_OS_TRACE ("ACE_OS::sema_wait"); +# if defined (ACE_HAS_POSIX_SEM) + ACE_UNUSED_ARG (s); + ACE_UNUSED_ARG (tv); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (s); + ACE_UNUSED_ARG (tv); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_PTHREADS) + int result = 0; + ACE_Errno_Guard error (errno); + + ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); + + if (ACE_OS::mutex_lock (&s->lock_) != 0) + result = -1; + else + { + // Keep track of the number of waiters so that we can signal + // them properly in <ACE_OS::sema_post>. + s->waiters_++; + + // Wait until the semaphore count is > 0 or until we time out. + while (s->count_ == 0) + if (ACE_OS::cond_timedwait (&s->count_nonzero_, + &s->lock_, + &tv) == -1) + { + error = errno; + result = -2; // -2 means that we need to release the mutex. + break; + } + + --s->waiters_; + } + + if (result == 0) + { +# if defined (ACE_LACKS_COND_TIMEDWAIT_RESET) + tv = ACE_OS::gettimeofday (); +# endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */ + --s->count_; + } + + if (result != -1) + ACE_OS::mutex_unlock (&s->lock_); + ACE_PTHREAD_CLEANUP_POP (0); + return result < 0 ? -1 : result; +# elif defined (ACE_HAS_WTHREADS) +# if !defined (ACE_USES_WINCE_SEMA_SIMULATION) + int msec_timeout; + + if (tv.sec () == 0 && tv.usec () == 0) + msec_timeout = 0; // Do a "poll." + else + { + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // <WaitForSingleObjects> expects). + ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + + // Watchout for situations where a context switch has caused the + // current time to be > the timeout. + if (relative_time < ACE_Time_Value::zero) + msec_timeout = 0; + else + msec_timeout = relative_time.msec (); + } + + switch (::WaitForSingleObject (*s, msec_timeout)) + { + case WAIT_OBJECT_0: + tv = ACE_OS::gettimeofday (); // Update time to when acquired + return 0; + case WAIT_TIMEOUT: + errno = ETIME; + return -1; + default: + // This is a hack, we need to find an appropriate mapping... + ACE_OS::set_errno_to_last_error (); + return -1; + } + /* NOTREACHED */ +# else /* ACE_USES_WINCE_SEMA_SIMULATION */ + // Note that in this mode, the acquire is done in two steps, and + // we may get signaled but cannot grab the semaphore before + // timeout. In that case, we'll need to restart the process with + // updated timeout value. + + // <tv> is an absolute time + ACE_Time_Value relative_time = tv - ACE_OS::gettimeofday (); + int result = -1; + + // While we are not timeout yet. + while (relative_time > ACE_Time_Value::zero) + { + // Wait for our turn to get the object. + switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ())) + { + case WAIT_OBJECT_0: + ACE_OS::thread_mutex_lock (&s->lock_); + + // Need to double check if the semaphore is still available. + // We can only do a "try lock" styled wait here to avoid + // blocking threads that want to signal the semaphore. + if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0) + { + // As before, only reset the object when the semaphore + // is no longer available. + s->count_--; + if (s->count_ <= 0) + ACE_OS::event_reset (&s->count_nonzero_); + result = 0; + } + + ACE_OS::thread_mutex_unlock (&s->lock_); + + // Only return when we successfully get the semaphore. + if (result == 0) + { + tv = ACE_OS::gettimeofday (); // Update to time acquired + return 0; + } + break; + + // We have timed out. + case WAIT_TIMEOUT: + errno = ETIME; + return -1; + + // What? + default: + ACE_OS::set_errno_to_last_error (); + // This is taken from the hack above. ;) + return -1; + }; + + // Haven't been able to get the semaphore yet, update the + // timeout value to reflect the remaining time we want to wait. + relative_time = tv - ACE_OS::gettimeofday (); + } + + // We have timed out. + errno = ETIME; + return -1; +# endif /* ACE_USES_WINCE_SEMA_SIMULATION */ +# elif defined (ACE_PSOS) + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // the system call expects). + ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + + u_long ticks = relative_time.sec() * KC_TICKS2SEC + + relative_time.usec () * KC_TICKS2SEC / + ACE_ONE_SECOND_IN_USECS; + if(ticks == 0) + ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_NOWAIT, 0), int, -1); //no timeout + else + ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_WAIT, ticks), int, -1); +# elif defined (VXWORKS) + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // the system call expects). + ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + + int ticks_per_sec = ::sysClkRateGet (); + + int ticks = relative_time.sec() * ticks_per_sec + + relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; + if (::semTake (s->sema_, ticks) == ERROR) + { + if (errno == S_objLib_OBJ_TIMEOUT) + // Convert the VxWorks errno to one that's common for to ACE + // platforms. + errno = ETIME; + else if (errno == S_objLib_OBJ_UNAVAILABLE) + errno = EBUSY; + return -1; + } + else + { + tv = ACE_OS::gettimeofday (); // Update to time acquired + return 0; + } +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (s); + ACE_UNUSED_ARG (tv); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_POSIX_SEM */ +} + +ACE_INLINE int +ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value *tv) +{ + return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv); +} + +ACE_INLINE int +ACE_OS::semctl (int int_id, int semnum, int cmd, semun value) +{ + ACE_OS_TRACE ("ACE_OS::semctl"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1); +#else + ACE_UNUSED_ARG (int_id); + ACE_UNUSED_ARG (semnum); + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (value); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::semget (key_t key, int nsems, int flags) +{ + ACE_OS_TRACE ("ACE_OS::semget"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1); +#else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (nsems); + ACE_UNUSED_ARG (flags); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::semop (int int_id, struct sembuf *sops, size_t nsops) +{ + ACE_OS_TRACE ("ACE_OS::semop"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1); +#else + ACE_UNUSED_ARG (int_id); + ACE_UNUSED_ARG (sops); + ACE_UNUSED_ARG (nsops); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::sigtimedwait (const sigset_t *sset, + siginfo_t *info, + const ACE_Time_Value *timeout) +{ + ACE_OS_TRACE ("ACE_OS::sigtimedwait"); +#if defined (ACE_HAS_SIGTIMEDWAIT) + timespec_t ts; + timespec_t *tsp; + + if (timeout != 0) + { + ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). + tsp = &ts; + } + else + tsp = 0; + + ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp), + int, -1); +#else + ACE_UNUSED_ARG (sset); + ACE_UNUSED_ARG (info); + ACE_UNUSED_ARG (timeout); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SIGTIMEDWAIT */ +} + +ACE_INLINE int +ACE_OS::sigwait (sigset_t *sset, int *sig) +{ + ACE_OS_TRACE ("ACE_OS::sigwait"); + int local_sig; + if (sig == 0) + sig = &local_sig; +#if defined (ACE_HAS_THREADS) +# if (defined (__FreeBSD__) && (__FreeBSD__ < 3)) || defined (CHORUS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (sset); + ACE_NOTSUP_RETURN (-1); +# elif (defined (ACE_HAS_STHREADS) && !defined (_POSIX_PTHREAD_SEMANTICS)) + *sig = ::sigwait (sset); + return *sig; +# elif defined (ACE_HAS_PTHREADS) + // LynxOS and Digital UNIX have their own hoops to jump through. +# if defined (__Lynx__) + // Second arg is a void **, which we don't need (the selected + // signal number is returned). + *sig = ::sigwait (sset, 0); + return *sig; +# elif defined (DIGITAL_UNIX) && defined (__DECCXX_VER) + // DEC cxx (but not g++) needs this direct call to its internal + // sigwait (). This allows us to #undef sigwait, so that we can + // have ACE_OS::sigwait. cxx gets confused by ACE_OS::sigwait + // if sigwait is _not_ #undef'ed. + errno = ::_Psigwait (sset, sig); + return errno == 0 ? *sig : -1; +# else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */ +# if (defined (ACE_HAS_PTHREADS_DRAFT4) || (defined (ACE_HAS_PTHREADS_DRAFT6)) && !defined(ACE_HAS_FSU_PTHREADS)) || (defined (_UNICOS) && _UNICOS == 9) +# if defined (HPUX_10) + *sig = cma_sigwait (sset); +# else + *sig = ::sigwait (sset); +# endif /* HPUX_10 */ + return *sig; +# elif defined(ACE_HAS_FSU_PTHREADS) + return ::sigwait (sset, sig); +# elif defined(CYGWIN32) + // Cygwin has sigwait definition, but it is not implemented + ACE_UNUSED_ARG (sset); + ACE_NOTSUP_RETURN (-1); +# else /* this is draft 7 or std */ + errno = ::sigwait (sset, sig); + return errno == 0 ? *sig : -1; +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ +# endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */ +# elif defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (sset); + ACE_NOTSUP_RETURN (-1); +# elif defined (VXWORKS) + // Second arg is a struct siginfo *, which we don't need (the + // selected signal number is returned). Third arg is timeout: 0 + // means forever. + *sig = ::sigtimedwait (sset, 0, 0); + return *sig; +# endif /* __FreeBSD__ */ +#else + ACE_UNUSED_ARG (sset); + ACE_UNUSED_ARG (sig); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::sigwaitinfo (const sigset_t *sset, + siginfo_t *info) +{ + ACE_OS_TRACE ("ACE_OS::sigwaitinfo"); + // If this platform has sigtimedwait, it should have sigwaitinfo as well. + // If this isn't true somewhere, let me know and I'll fix this. + // -Steve Huston <shuston@riverace.com>. +#if defined (ACE_HAS_SIGTIMEDWAIT) + ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1); +#else + ACE_UNUSED_ARG (sset); + ACE_UNUSED_ARG (info); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SIGTIMEDWAIT */ +} + +ACE_INLINE int +ACE_OS::thr_cancel (ACE_thread_t thr_id) +{ + ACE_OS_TRACE ("ACE_OS::thr_cancel"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_OSCALL_RETURN (::pthread_cancel (thr_id), int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cancel (thr_id), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */ +# else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ + ACE_UNUSED_ARG (thr_id); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (thr_id); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2) +{ +#if defined (ACE_HAS_PTHREADS) +# if defined (pthread_equal) + // If it's a macro we can't say "::pthread_equal"... + return pthread_equal (t1, t2); +# else + return ::pthread_equal (t1, t2); +# endif /* pthread_equal */ +#else /* For STHREADS, WTHREADS, and VXWORKS ... */ + // Hum, Do we need to treat WTHREAD differently? + // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE. + return t1 == t2; +#endif /* ACE_HAS_PTHREADS */ +} + +ACE_INLINE int +ACE_OS::thr_continue (ACE_hthread_t target_thread) +{ + ACE_OS_TRACE ("ACE_OS::thr_continue"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), ace_result_), int, -1); +# elif defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREAD_CONTINUE) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread), + ace_result_), + int, -1); +# else + ACE_UNUSED_ARG (target_thread); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PTHREAD_CONTINUE */ +# elif defined (ACE_HAS_WTHREADS) + DWORD result = ::ResumeThread (target_thread); + if (result == ACE_SYSCALL_FAILED) + ACE_FAIL_RETURN (-1); + else + return 0; +# elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_resume (target_thread), ace_result_), int, -1); +# elif defined (VXWORKS) + ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (target_thread); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_equal (ACE_thread_t t1, ACE_thread_t t2) +{ +#if defined (ACE_HAS_PTHREADS) +# if defined (pthread_equal) + // If it's a macro we can't say "::pthread_equal"... + return pthread_equal (t1, t2); +# else + return ::pthread_equal (t1, t2); +# endif /* pthread_equal */ +#elif defined (VXWORKS) + return ! ACE_OS::strcmp (t1, t2); +#else /* For both STHREADS and WTHREADS... */ + // Hum, Do we need to treat WTHREAD differently? + // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD. + return t1 == t2; +#endif /* ACE_HAS_PTHREADS */ +} + +ACE_INLINE int +ACE_OS::thr_getconcurrency (void) +{ + ACE_OS_TRACE ("ACE_OS::thr_getconcurrency"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + return ::thr_getconcurrency (); +# elif defined (ACE_HAS_PTHREADS) || defined (VXWORKS) || defined (ACE_PSOS) + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_WTHREADS) + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_getprio (ACE_hthread_t id, int &priority, int &policy) +{ + ACE_OS_TRACE ("ACE_OS::thr_getprio"); + ACE_UNUSED_ARG (policy); +#if defined (ACE_HAS_THREADS) +# if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED)) + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + int result; + result = ::pthread_getprio (id); + if (result != -1) + { + priority = result; + return 0; + } + else + return -1; +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + + pthread_attr_t attr; + if (pthread_getschedattr (id, &attr) == 0) + { + priority = pthread_attr_getprio(&attr); + return 0; + } + return -1; +# else + + struct sched_param param; + int result; + + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, ¶m), + result), int, + -1, result); + priority = param.sched_priority; + return result; +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (id, &priority), ace_result_), int, -1); +# elif defined (ACE_HAS_WTHREADS) + priority = ::GetThreadPriority (id); + if (priority == THREAD_PRIORITY_ERROR_RETURN) + ACE_FAIL_RETURN (-1); + else + return 0; +# elif defined (ACE_PSOS) + // passing a 0 in the second argument does not alter task priority, third arg gets existing one + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, 0, (u_long *) &priority), ace_result_), int, -1); +# elif defined (VXWORKS) + ACE_OSCALL_RETURN (::taskPriorityGet (id, &priority), int, -1); +# else + ACE_UNUSED_ARG (id); + ACE_UNUSED_ARG (priority); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (id); + ACE_UNUSED_ARG (priority); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_getprio (ACE_hthread_t id, int &priority) +{ + ACE_OS_TRACE ("ACE_OS::thr_getprio"); + int policy = 0; + return ACE_OS::thr_getprio (id, priority, policy); +} + +#if defined (ACE_HAS_TSS_EMULATION) + +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) +ACE_INLINE int +ACE_OS::thr_getspecific (ACE_OS_thread_key_t key, void **data) +{ + ACE_OS_TRACE ("ACE_OS::thr_getspecific"); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + return pthread_getspecific (key, data); +# else /* this is ACE_HAS_PTHREADS_DRAFT7 or STD */ +# if (pthread_getspecific) + // This is a macro on some platforms, e.g., CHORUS! + *data = pthread_getspecific (key); +# else + *data = pthread_getspecific (key); +# endif /* pthread_getspecific */ +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ + return 0; +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + ACE_hthread_t tid; + ACE_OS::thr_self (tid); + return (::tsd_getval (key, tid, data) == 0) ? 0 : -1; +# elif defined (ACE_HAS_WTHREADS) + + // The following handling of errno is designed like this due to + // ACE_Log_Msg::instance calling ACE_OS::thr_getspecific. + // Basically, it is ok for a system call to reset the error to zero. + // (It really shouldn't, though). However, we have to remember to + // store errno *immediately* after an error is detected. Calling + // ACE_ERROR_RETURN((..., errno)) did not work because errno was + // cleared before being passed to the thread-specific instance of + // ACE_Log_Msg. The workaround for was to make it so + // thr_getspecific did not have the side effect of clearing errno. + // The correct fix is for ACE_ERROR_RETURN to store errno + //(actually ACE_OS::last_error) before getting the ACE_Log_Msg tss + // pointer, which is how it is implemented now. However, other uses + // of ACE_Log_Msg may not work correctly, so we're keeping this as + // it is for now. + + ACE_Errno_Guard error (errno); + *data = ::TlsGetValue (key); + if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR) + return -1; + else + return 0; +# endif /* ACE_HAS_STHREADS */ +# else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (data); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */ + +#endif /* ACE_HAS_TSS_EMULATION */ + + +ACE_INLINE int +ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data) +{ + // ACE_OS_TRACE ("ACE_OS::thr_getspecific"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_TSS_EMULATION) + ACE_KEY_INDEX (key_index, key); + if (key_index >= ACE_TSS_Emulation::total_keys ()) + { + errno = EINVAL; + data = 0; + return -1; + } + else + { + *data = ACE_TSS_Emulation::ts_object (key); + return 0; + } +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1); +# elif defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + return ::pthread_getspecific (key, data); +# else /* this is Draft 7 or STD */ + *data = pthread_getspecific (key); + return 0; +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ +# elif defined (ACE_HAS_WTHREADS) + + // The following handling of errno is designed like this due to + // ACE_Log_Msg::instance calling ACE_OS::thr_getspecific. + // Basically, it is ok for a system call to reset the error to zero. + // (It really shouldn't, though). However, we have to remember to + // store errno *immediately* after an error is detected. Calling + // ACE_ERROR_RETURN((..., errno)) did not work because errno was + // cleared before being passed to the thread-specific instance of + // ACE_Log_Msg. The workaround for was to make it so + // thr_getspecific did not have the side effect of clearing errno. + // The correct fix is for ACE_ERROR_RETURN to store errno + //(actually ACE_OS::last_error) before getting the ACE_Log_Msg tss + // pointer, which is how it is implemented now. However, other uses + // of ACE_Log_Msg may not work correctly, so we're keeping this as + // it is for now. + + ACE_Errno_Guard error (errno); + *data = ::TlsGetValue (key); + if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR) + return -1; + else + return 0; +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS) + ACE_hthread_t tid; + ACE_OS::thr_self (tid); + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::tsd_getval (key, tid, data), + ace_result_), + int, -1); +# else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (data); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (data); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +#if !defined (VXWORKS) +ACE_INLINE int +ACE_OS::thr_join (ACE_hthread_t thr_handle, + ACE_THR_FUNC_RETURN *status) +{ + ACE_OS_TRACE ("ACE_OS::thr_join"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), ace_result_), + int, -1); +# elif defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) + int ace_result; +# if defined (ACE_LACKS_NULL_PTHREAD_STATUS) + void *temp; + ACE_OSCALL (::pthread_join (thr_handle, + status == 0 ? &temp : status), + int, -1, ace_result); +# else + ACE_OSCALL (::pthread_join (thr_handle, status), int, -1, ace_result); +# endif /* ACE_LACKS_NULL_PTHREAD_STATUS */ + // Joinable threads need to be detached after joining on Pthreads + // draft 4 (at least) to reclaim thread storage. +# if defined (ACE_HAS_PTHREADS_DRAFT4) +# if defined (HPUX_10) + // HP-UX DCE threads' pthread_detach will smash thr_id if it's just given + // as an argument. Since the id is still needed, give pthread_detach + // a junker to scribble on. + ACE_thread_t junker; + cma_handle_assign(&thr_handle, &junker); + ::pthread_detach (&junker); +# else + ::pthread_detach (&thr_handle); +# endif /* HPUX_10 */ +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ + + return ace_result; + +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_join (thr_handle, status), ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ +# elif defined (ACE_HAS_WTHREADS) + ACE_THR_FUNC_RETURN local_status = 0; + + // Make sure that status is non-NULL. + if (status == 0) + status = &local_status; + + if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0 + && ::GetExitCodeThread (thr_handle, status) != FALSE) + { + ::CloseHandle (thr_handle); + return 0; + } + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ +# elif defined (ACE_PSOS) + ACE_UNUSED_ARG (thr_handle); + ACE_UNUSED_ARG (status); + ACE_NOTSUP_RETURN (-1); +# else + ACE_UNUSED_ARG (thr_handle); + ACE_UNUSED_ARG (status); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (thr_handle); + ACE_UNUSED_ARG (status); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_join (ACE_thread_t waiter_id, + ACE_thread_t *thr_id, + ACE_THR_FUNC_RETURN *status) +{ + ACE_OS_TRACE ("ACE_OS::thr_join"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), ace_result_), + int, -1); +# elif defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (thr_id); +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6) +# if defined (ACE_LACKS_NULL_PTHREAD_STATUS) + void *temp; + ACE_OSCALL_RETURN (::pthread_join (waiter_id, + status == 0 ? &temp : status), int, -1); +# else + ACE_OSCALL_RETURN (::pthread_join (waiter_id, status), int, -1); +# endif +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_join (waiter_id, status), ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */ +# elif defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (waiter_id); + ACE_UNUSED_ARG (thr_id); + ACE_UNUSED_ARG (status); + + // This could be implemented if the DLL-Main function or the + // task exit base class some log the threads which have exited + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_PSOS) + ACE_UNUSED_ARG (waiter_id); + ACE_UNUSED_ARG (thr_id); + ACE_UNUSED_ARG (status); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (waiter_id); + ACE_UNUSED_ARG (thr_id); + ACE_UNUSED_ARG (status); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} +#endif /* !VXWORKS */ + +ACE_INLINE int +ACE_OS::thr_kill (ACE_thread_t thr_id, int signum) +{ + ACE_OS_TRACE ("ACE_OS::thr_kill"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_DRAFT4) || defined(ACE_LACKS_PTHREAD_KILL) + ACE_UNUSED_ARG (signum); + ACE_UNUSED_ARG (thr_id); + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_kill (thr_id, signum), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum), + ace_result_), + int, -1); +# elif defined (ACE_HAS_WTHREADS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (signum); + ACE_UNUSED_ARG (thr_id); + + ACE_NOTSUP_RETURN (-1); +# elif defined (VXWORKS) + ACE_hthread_t tid; + ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid); + + if (tid == ERROR) + return -1; + else + ACE_OSCALL_RETURN (::kill (tid, signum), int, -1); + +# else /* This should not happen! */ + ACE_UNUSED_ARG (thr_id); + ACE_UNUSED_ARG (signum); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (thr_id); + ACE_UNUSED_ARG (signum); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE size_t +ACE_OS::thr_min_stack (void) +{ + ACE_OS_TRACE ("ACE_OS::thr_min_stack"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) +# if defined (ACE_HAS_THR_MINSTACK) + // Tandem did some weirdo mangling of STHREAD names... + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_minstack (), + ace_result_), + int, -1); +# else + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_min_stack (), + ace_result_), + int, -1); +# endif /* !ACE_HAS_THR_MINSTACK */ +# elif defined (ACE_HAS_PTHREADS) +# if defined (_SC_THREAD_STACK_MIN) + return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN); +# elif defined (PTHREAD_STACK_MIN) + return PTHREAD_STACK_MIN; +# else + ACE_NOTSUP_RETURN (0); +# endif /* _SC_THREAD_STACK_MIN */ +# elif defined (ACE_HAS_WTHREADS) + ACE_NOTSUP_RETURN (0); +# elif defined (ACE_PSOS) + // there does not appear to be a way to get the + // task stack size except at task creation + ACE_NOTSUP_RETURN (0); +# elif defined (VXWORKS) + TASK_DESC taskDesc; + STATUS status; + + ACE_hthread_t tid; + ACE_OS::thr_self (tid); + + ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc), + status), + STATUS, -1, status); + return status == OK ? taskDesc.td_stackSize : 0; +# else /* Should not happen... */ + ACE_NOTSUP_RETURN (0); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE ACE_thread_t +ACE_OS::thr_self (void) +{ + // ACE_OS_TRACE ("ACE_OS::thr_self"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + // Note, don't use "::" here since the following call is often a macro. + ACE_OSCALL_RETURN (pthread_self (), int, -1); +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (::thr_self (), int, -1); +# elif defined (ACE_HAS_WTHREADS) + return ::GetCurrentThreadId (); +# elif defined (ACE_PSOS) + // there does not appear to be a way to get + // a task's name other than at creation + return 0; +# elif defined (VXWORKS) + return ::taskName (::taskIdSelf ()); +# endif /* ACE_HAS_STHREADS */ +#else + return 1; // Might as well make it the first thread ;-) +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE void +ACE_OS::thr_self (ACE_hthread_t &self) +{ + ACE_OS_TRACE ("ACE_OS::thr_self"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) + // Note, don't use "::" here since the following call is often a macro. + self = pthread_self (); +# elif defined (ACE_HAS_THREAD_SELF) + self = ::thread_self (); +# elif defined (ACE_HAS_STHREADS) + self = ::thr_self (); +# elif defined (ACE_HAS_WTHREADS) + self = ::GetCurrentThread (); +# elif defined (ACE_PSOS) + t_ident ((char *) 0, 0, &self); +# elif defined (VXWORKS) + self = ::taskIdSelf (); +# endif /* ACE_HAS_STHREADS */ +#else + self = 1; // Might as well make it the main thread ;-) +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_setcancelstate (int new_state, int *old_state) +{ + ACE_OS_TRACE ("ACE_OS::thr_setcancelstate"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) +# if defined (ACE_HAS_PTHREADS_DRAFT4) + int old; + old = pthread_setcancel (new_state); + if (old == -1) + return -1; + *old_state = old; + return 0; +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_UNUSED_ARG(old_state); + ACE_OSCALL_RETURN (pthread_setintr (new_state), int, -1); +# else /* this is draft 7 or std */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setcancelstate (new_state, + old_state), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ +# elif defined (ACE_HAS_STHREADS) + ACE_UNUSED_ARG (new_state); + ACE_UNUSED_ARG (old_state); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (new_state); + ACE_UNUSED_ARG (old_state); + ACE_NOTSUP_RETURN (-1); +# else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ + ACE_UNUSED_ARG (new_state); + ACE_UNUSED_ARG (old_state); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (new_state); + ACE_UNUSED_ARG (old_state); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_setcanceltype (int new_type, int *old_type) +{ + ACE_OS_TRACE ("ACE_OS::thr_setcanceltype"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) +# if defined (ACE_HAS_PTHREADS_DRAFT4) + int old; + old = pthread_setasynccancel(new_type); + if (old == -1) + return -1; + *old_type = old; + return 0; +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + ACE_UNUSED_ARG(old_type); + ACE_OSCALL_RETURN (pthread_setintrtype (new_type), int, -1); +# else /* this is draft 7 or std */ + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setcanceltype (new_type, + old_type), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ +# else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ + ACE_UNUSED_ARG (new_type); + ACE_UNUSED_ARG (old_type); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (new_type); + ACE_UNUSED_ARG (old_type); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_setconcurrency (int hint) +{ + ACE_OS_TRACE ("ACE_OS::thr_setconcurrency"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint), + ace_result_), + int, -1); +# elif defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (hint); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (hint); + + ACE_NOTSUP_RETURN (-1); +# elif defined (VXWORKS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (hint); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (hint); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_setprio (ACE_hthread_t id, int priority, int policy) +{ + ACE_OS_TRACE ("ACE_OS::thr_setprio"); + ACE_UNUSED_ARG (policy); +#if defined (ACE_HAS_THREADS) +# if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED)) + +# if defined (ACE_HAS_PTHREADS_DRAFT4) + int result; + result = ::pthread_setprio (id, priority); + return (result == -1 ? -1 : 0); +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + pthread_attr_t attr; + if (pthread_getschedattr (id, &attr) == -1) + return -1; + if (pthread_attr_setprio (attr, priority) == -1) + return -1; + return pthread_setschedattr (id, attr); +# else + int result; + struct sched_param param; + memset ((void *) ¶m, 0, sizeof param); + + // If <policy> is -1, we don't want to use it for + // pthread_setschedparam(). Instead, obtain policy from + // pthread_getschedparam(). + if (policy == -1) + { + ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, ¶m), + result), + int, -1, result); + if (result == -1) + return result; + } + + param.sched_priority = priority; + + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (id, policy, ¶m), + ace_result_), + int, -1); +# endif /* ACE_HAS_PTHREADS_DRAFT4 */ +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (id, priority), + ace_result_), + int, -1); +# elif defined (ACE_HAS_WTHREADS) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (id, priority), + ace_result_), + int, -1); +# elif defined (ACE_PSOS) + u_long oldpriority; + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, priority, &oldpriority), + ace_result_), + int, -1); +# elif defined (VXWORKS) + ACE_OSCALL_RETURN (::taskPrioritySet (id, priority), int, -1); +# else + // For example, platforms that support Pthreads but LACK_SETSCHED. + ACE_UNUSED_ARG (id); + ACE_UNUSED_ARG (priority); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (id); + ACE_UNUSED_ARG (priority); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_sigsetmask (int how, + const sigset_t *nsm, + sigset_t *osm) +{ + ACE_OS_TRACE ("ACE_OS::thr_sigsetmask"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) + // DCE threads and Solaris 2.4 have no such function. + ACE_UNUSED_ARG (osm); + ACE_UNUSED_ARG (nsm); + ACE_UNUSED_ARG (how); + + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_SIGTHREADMASK) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm), + ace_result_), int, -1); +# elif defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm), + ace_result_), + int, -1); +# elif defined (ACE_HAS_PTHREADS) +# if defined (AIX) + ACE_OSCALL_RETURN (sigthreadmask (how, nsm, osm), int, -1); + // Draft 4 and 6 implementations will sometimes have a sigprocmask () that + // modifies the calling thread's mask only. If this is not so for your + // platform, define ACE_LACKS_PTHREAD_THR_SIGSETMASK. +# elif defined(ACE_HAS_PTHREADS_DRAFT4) || \ + defined (ACE_HAS_PTHREADS_DRAFT6) || (defined (_UNICOS) && _UNICOS == 9) + ACE_OSCALL_RETURN (::sigprocmask (how, nsm, osm), int, -1); +# elif !defined (ACE_LACKS_PTHREAD_SIGMASK) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm), + ace_result_), int, -1); +# endif /* AIX */ + +#if 0 + /* Don't know if anyt platform actually needs this... */ + // as far as I can tell, this is now pthread_sigaction() -- jwr + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigaction (how, nsm, osm), + ace_result_), int, -1); +#endif /* 0 */ + +# elif defined (ACE_HAS_WTHREADS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (osm); + ACE_UNUSED_ARG (nsm); + ACE_UNUSED_ARG (how); + + ACE_NOTSUP_RETURN (-1); +# elif defined (VXWORKS) + switch (how) + { + case SIG_BLOCK: + case SIG_UNBLOCK: + { + // get the old mask + *osm = ::sigsetmask (*nsm); + // create a new mask: the following assumes that sigset_t is 4 bytes, + // which it is on VxWorks 5.2, so bit operations are done simply . . . + ::sigsetmask (how == SIG_BLOCK ? (*osm |= *nsm) : (*osm &= ~*nsm)); + break; + } + case SIG_SETMASK: + *osm = ::sigsetmask (*nsm); + break; + default: + return -1; + } + + return 0; +# else /* Should not happen. */ + ACE_UNUSED_ARG (how); + ACE_UNUSED_ARG (nsm); + ACE_UNUSED_ARG (osm); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ +#else + ACE_UNUSED_ARG (how); + ACE_UNUSED_ARG (nsm); + ACE_UNUSED_ARG (osm); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thr_suspend (ACE_hthread_t target_thread) +{ + ACE_OS_TRACE ("ACE_OS::thr_suspend"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_STHREADS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), ace_result_), int, -1); +# elif defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREAD_SUSPEND) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread), + ace_result_), + int, -1); +# else + ACE_UNUSED_ARG (target_thread); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PTHREAD_SUSPEND */ +# elif defined (ACE_HAS_WTHREADS) + if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED) + return 0; + else + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ +# elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_suspend (target_thread), ace_result_), int, -1); +# elif defined (VXWORKS) + ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1); +# endif /* ACE_HAS_STHREADS */ +#else + ACE_UNUSED_ARG (target_thread); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE void +ACE_OS::thr_testcancel (void) +{ + ACE_OS_TRACE ("ACE_OS::thr_testcancel"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) +#if defined(ACE_HAS_PTHREADS_DRAFT6) + ::pthread_testintr (); +#else /* ACE_HAS_PTHREADS_DRAFT6 */ + ::pthread_testcancel (); +#endif /* !ACE_HAS_PTHREADS_DRAFT6 */ +# elif defined (ACE_HAS_STHREADS) +# elif defined (ACE_HAS_WTHREADS) +# elif defined (VXWORKS) || defined (ACE_PSOS) +# else + // no-op: can't use ACE_NOTSUP_RETURN because there is no return value +# endif /* ACE_HAS_PTHREADS */ +#else +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE void +ACE_OS::thr_yield (void) +{ + ACE_OS_TRACE ("ACE_OS::thr_yield"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) +# if defined (ACE_HAS_PTHREADS_STD) + // Note - this is a POSIX.4 function - not a POSIX.1c function... + ::sched_yield (); +# elif defined (ACE_HAS_PTHREADS_DRAFT6) + ::pthread_yield (0); +# else /* Draft 4 and 7 */ + ::pthread_yield (); +# endif /* ACE_HAS_PTHREADS_STD */ +# elif defined (ACE_HAS_STHREADS) + ::thr_yield (); +# elif defined (ACE_HAS_WTHREADS) + ::Sleep (0); +# elif defined (VXWORKS) + // An argument of 0 to ::taskDelay doesn't appear to yield the + // current thread. + // Now, it does seem to work. The context_switch_time test + // works fine with task_delay set to 0. + ::taskDelay (0); +# endif /* ACE_HAS_STHREADS */ +#else + ; +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thread_mutex_destroy (ACE_thread_mutex_t *m) +{ + ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) + ::DeleteCriticalSection (m); + return 0; + +# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + return ACE_OS::mutex_destroy (m); + +# elif defined (VXWORKS) || defined (ACE_PSOS) + return mutex_destroy (m); + +# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ + +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); + +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thread_mutex_init (ACE_thread_mutex_t *m, + int type, + const char *name, + ACE_mutexattr_t *arg) +{ + // ACE_OS_TRACE ("ACE_OS::thread_mutex_init"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ::InitializeCriticalSection (m); + return 0; + +# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (type); + // Force the use of USYNC_THREAD! + return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg); + +# elif defined (VXWORKS) || defined (ACE_PSOS) + return mutex_init (m, type, name, arg); + +# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ + +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); + +#endif /* ACE_HAS_THREADS */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::thread_mutex_init (ACE_thread_mutex_t *m, + int type, + const wchar_t *name, + ACE_mutexattr_t *arg) +{ + // ACE_OS_TRACE ("ACE_OS::thread_mutex_init"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ::InitializeCriticalSection (m); + return 0; + +# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + ACE_UNUSED_ARG (type); + // Force the use of USYNC_THREAD! + return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg); + +# elif defined (VXWORKS) || defined (ACE_PSOS) + return mutex_init (m, type, name, arg); + +# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ + +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); + +#endif /* ACE_HAS_THREADS */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m) +{ + // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) + ::EnterCriticalSection (m); + return 0; +# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + return ACE_OS::mutex_lock (m); +# elif defined (VXWORKS) || defined (ACE_PSOS) + return mutex_lock (m); +# endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m, + const ACE_Time_Value &timeout) +{ + // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock"); + + // For all platforms, except MS Windows, this method is equivalent + // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and + // ACE_mutex_t are the same type. However, those typedefs evaluate + // to different types on MS Windows. The "thread mutex" + // implementation in ACE for MS Windows cannot readily support + // timeouts due to a lack of timeout features for this type of MS + // Windows synchronization mechanism. + +#if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS) +# if defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + return ACE_OS::mutex_lock (m, timeout); +#elif defined (VXWORKS) || defined (ACE_PSOS) + return mutex_lock (m, timeout); +#endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ +#else + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (timeout); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m, + const ACE_Time_Value *timeout) +{ + return timeout == 0 + ? ACE_OS::thread_mutex_lock (m) + : ACE_OS::thread_mutex_lock (m, *timeout); +} + +ACE_INLINE int +ACE_OS::thread_mutex_trylock (ACE_thread_mutex_t *m) +{ + ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock"); + +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) +# if defined (ACE_HAS_WIN32_TRYLOCK) + BOOL result = ::TryEnterCriticalSection (m); + if (result == TRUE) + return 0; + else + { + errno = EBUSY; + return -1; + } +# else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WIN32_TRYLOCK */ +# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + return ACE_OS::mutex_trylock (m); +# elif defined (VXWORKS) || defined (ACE_PSOS) + return ACE_OS::mutex_trylock (m); +#endif /* Threads variety case */ + +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int +ACE_OS::thread_mutex_unlock (ACE_thread_mutex_t *m) +{ + ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock"); +#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_WTHREADS) + ::LeaveCriticalSection (m); + return 0; +# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) + return ACE_OS::mutex_unlock (m); +# elif defined (VXWORKS) || defined (ACE_PSOS) + return ACE_OS::mutex_unlock (m); +# endif /* Threads variety case */ +#else + ACE_UNUSED_ARG (m); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_THREADS */ +} + +/*****************************************************************************/ + +# if defined (ACE_IS_SPLITTING) +# define ACE_SPECIAL_INLINE +# else +# define ACE_SPECIAL_INLINE ACE_INLINE +//# define ACE_SPECIAL_INLINE inline +# endif + +ACE_INLINE +int +ACE_OS_Thread_Mutex_Guard::acquire (void) +{ + return owner_ = ACE_OS::thread_mutex_lock (&lock_); +} + +ACE_INLINE +int +ACE_OS_Thread_Mutex_Guard::release (void) +{ + if (owner_ == -1) + return 0; + else + { + owner_ = -1; + return ACE_OS::thread_mutex_unlock (&lock_); + } +} + +ACE_INLINE +ACE_OS_Thread_Mutex_Guard::ACE_OS_Thread_Mutex_Guard (ACE_thread_mutex_t &m) + : lock_ (m) +{ + acquire (); +} + +ACE_INLINE +ACE_OS_Thread_Mutex_Guard::~ACE_OS_Thread_Mutex_Guard () +{ + release (); +} + +/*****************************************************************************/ + +ACE_INLINE +int +ACE_OS_Recursive_Thread_Mutex_Guard::acquire (void) +{ + return owner_ = ACE_OS::recursive_mutex_lock (&lock_); +} + +ACE_INLINE +int +ACE_OS_Recursive_Thread_Mutex_Guard::release (void) +{ + if (owner_ == -1) + return 0; + else + { + owner_ = -1; + return ACE_OS::recursive_mutex_unlock (&lock_); + } +} + +ACE_INLINE +ACE_OS_Recursive_Thread_Mutex_Guard::ACE_OS_Recursive_Thread_Mutex_Guard ( + ACE_recursive_thread_mutex_t &m) + : lock_ (m), + owner_ (-1) +{ + acquire (); +} + +ACE_INLINE +ACE_OS_Recursive_Thread_Mutex_Guard::~ACE_OS_Recursive_Thread_Mutex_Guard () +{ + release (); +} diff --git a/ace/OS_NS_arpa_inet.cpp b/ace/OS_NS_arpa_inet.cpp index fc532b41367..b4040a0032c 100644 --- a/ace/OS_NS_arpa_inet.cpp +++ b/ace/OS_NS_arpa_inet.cpp @@ -1,4 +1,60 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_arpa_inet.h" + +ACE_RCSID(ace, OS_NS_arpa_inet, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_arpa_inet.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +int +ACE_OS::inet_aton (const char *host_name, struct in_addr *addr) +{ +#if defined (ACE_LACKS_INET_ATON) + ACE_UINT32 ip_addr = ACE_OS::inet_addr (host_name); + + if (ip_addr == INADDR_NONE + // Broadcast addresses are weird... + && ACE_OS::strcmp (host_name, "255.255.255.255") != 0) + return 0; + else if (addr == 0) + return 0; + else + { + addr->s_addr = ip_addr; // Network byte ordered + return 1; + } +#elif defined (VXWORKS) + // inet_aton() returns OK (0) on success and ERROR (-1) on failure. + // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026 + ::errnoSet(0); + int result = ERROR; + ACE_OSCALL (::inet_aton ((char*)host_name, addr), int, ERROR, result); + return (result == ERROR) ? 0 : 1; +#else + // inet_aton() returns 0 upon failure, not -1 since -1 is a valid + // address (255.255.255.255). + ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0); +#endif /* ACE_LACKS_INET_ATON */ +} + +// All other platforms have this inlined in OS_NS_arpa_inet.inl +#if defined (ACE_PSOS) +char * +ACE_OS::inet_ntoa (const struct in_addr addr) +{ + ACE_OS_TRACE ("ACE_OS::inet_ntoa"); + + static char addrstr[INET_ADDRSTRLEN + 1] = { 0 }; + ACE_UINT32 ipaddr = ntohl (addr.s_addr); + //printf("Socket address %X, IP address %X.\n",addr.s_addr,ipaddr); + sprintf(addrstr, "%d.%d.%d.%d", + ((ipaddr & 0xff000000) >> 24) & 0x000000ff, + (ipaddr & 0x00ff0000) >> 16, + (ipaddr & 0x0000ff00) >> 8, + (ipaddr & 0x000000ff)); + return addrstr; +} +#endif /* defined (ACE_PSOS) */ diff --git a/ace/OS_NS_arpa_inet.h b/ace/OS_NS_arpa_inet.h index fc532b41367..f1bf66bd73d 100644 --- a/ace/OS_NS_arpa_inet.h +++ b/ace/OS_NS_arpa_inet.h @@ -1,4 +1,59 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_arpa_inet.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_ARPA_INET_H +# define ACE_OS_NS_ARPA_INET_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/arpa/os_inet.h" + +namespace ACE_OS { + + unsigned long inet_addr (const char *name); + + int inet_aton (const char *strptr, + struct in_addr *addr); + + char *inet_ntoa (const struct in_addr addr); + + const char *inet_ntop (int family, + const void *addrptr, + char *strptr, + size_t len); + + int inet_pton (int family, + const char *strptr, + void *addrptr); + +}; /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_arpa_inet.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_ARPA_INET_H */ diff --git a/ace/OS_NS_arpa_inet.inl b/ace/OS_NS_arpa_inet.inl index fc532b41367..ea427c7c1e7 100644 --- a/ace/OS_NS_arpa_inet.inl +++ b/ace/OS_NS_arpa_inet.inl @@ -1,4 +1,123 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_stdio.h" + +ACE_INLINE unsigned long +ACE_OS::inet_addr (const char *name) +{ + ACE_OS_TRACE ("ACE_OS::inet_addr"); +#if defined (VXWORKS) || defined (ACE_PSOS) + + u_long ret = 0; + u_int segment; + u_int valid = 1; + + for (u_int i = 0; i < 4; ++i) + { + ret <<= 8; + if (*name != '\0') + { + segment = 0; + + while (*name >= '0' && *name <= '9') + { + segment *= 10; + segment += *name++ - '0'; + } + if (*name != '.' && *name != '\0') + { + valid = 0; + break; + } + + ret |= segment; + + if (*name == '.') + { + ++name; + } + } + } + return valid ? htonl (ret) : INADDR_NONE; +#elif defined (ACE_HAS_NONCONST_GETBY) + return ::inet_addr ((char *) name); +#else + return ::inet_addr (name); +#endif /* ACE_HAS_NONCONST_GETBY */ +} + +// For pSOS, this function is in OS.cpp +#if !defined (ACE_PSOS) +ACE_INLINE char * +ACE_OS::inet_ntoa (const struct in_addr addr) +{ + ACE_OS_TRACE ("ACE_OS::inet_ntoa"); + ACE_OSCALL_RETURN (::inet_ntoa (addr), + char *, + 0); +} +#endif /* defined (ACE_PSOS) */ + +ACE_INLINE int +ACE_OS::inet_pton (int family, const char *strptr, void *addrptr) +{ + ACE_OS_TRACE ("ACE_OS::inet_pton"); + +#if defined (ACE_HAS_IPV6) + ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1); +#else + if (family == AF_INET) + { + struct in_addr in_val; + + if (ACE_OS::inet_aton (strptr, &in_val)) + { + ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr)); + return 1; // Success + } + + return 0; // Input is not a valid presentation format + } + + ACE_NOTSUP_RETURN(-1); +#endif /* ACE_HAS_IPV6 */ +} + +ACE_INLINE const char * +ACE_OS::inet_ntop (int family, const void *addrptr, char *strptr, size_t len) +{ + ACE_OS_TRACE ("ACE_OS::inet_ntop"); + +#if defined (ACE_HAS_IPV6) + ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0); +#else + const u_char *p = + ACE_reinterpret_cast (const u_char *, addrptr); + + if (family == AF_INET) + { + char temp[INET_ADDRSTRLEN]; + + // Stevens uses snprintf() in his implementation but snprintf() + // doesn't appear to be very portable. For now, hope that using + // sprintf() will not cause any string/memory overrun problems. + ACE_OS::sprintf (temp, + "%d.%d.%d.%d", + p[0], p[1], p[2], p[3]); + + if (ACE_OS::strlen (temp) >= len) + { + errno = ENOSPC; + return 0; // Failure + } + + ACE_OS::strcpy (strptr, temp); + return strptr; + } + + ACE_NOTSUP_RETURN(0); +#endif /* ACE_HAS_IPV6 */ +} diff --git a/ace/OS_NS_ctype.cpp b/ace/OS_NS_ctype.cpp index fc532b41367..6672e6e7460 100644 --- a/ace/OS_NS_ctype.cpp +++ b/ace/OS_NS_ctype.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_ctype.h" + +ACE_RCSID(ace, OS_NS_ctype, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_ctype.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_ctype.h b/ace/OS_NS_ctype.h index fc532b41367..11740b2ccf1 100644 --- a/ace/OS_NS_ctype.h +++ b/ace/OS_NS_ctype.h @@ -1,4 +1,73 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_ctype.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_CTYPE_H +# define ACE_OS_NS_CTYPE_H + +# include /**/ "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace ACE_OS { + + // these are non-standard names... + + /** @name Functions from <cctype> + * + * Included are the functions defined in <cctype> and their <cwctype> + * equivalents. + * + * Since they are often implemented as macros, we don't use the same name + * here. Instead, we change by prepending "ace_" (with the exception of + * to_lower). + * + * @todo To be complete, we should add: isalnum, isalpha, iscntrl + * isdigit, isgraph, islower, ispunct, isupper, isxdigit, and toupper. + */ + //@{ + + /// Returns true if the character is a printable character. + int ace_isprint (const ACE_TCHAR c); + + /// Returns true if the character is a space character. + int ace_isspace (const ACE_TCHAR c); + + /// Converts a character to lower case (char version). + int to_lower (int c); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER) + /// Converts a character to lower case (wchar_t version). + wint_t to_lower (wint_t c); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_TOWLOWER */ + + //@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_ctype.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_CTYPE_H */ diff --git a/ace/OS_NS_ctype.inl b/ace/OS_NS_ctype.inl index fc532b41367..dfea0ad8640 100644 --- a/ace/OS_NS_ctype.inl +++ b/ace/OS_NS_ctype.inl @@ -1,4 +1,39 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/os_include/os_ctype.h" + +ACE_INLINE int +ACE_OS::ace_isprint (const ACE_TCHAR c) +{ +#if defined (ACE_USES_WCHAR) + return iswprint (c); +#else /* ACE_USES_WCHAR */ + return isprint ((unsigned char) c); +#endif /* ACE_USES_WCHAR */ +} + +ACE_INLINE int +ACE_OS::ace_isspace (const ACE_TCHAR c) +{ +#if defined (ACE_USES_WCHAR) + return iswspace (c); +#else /* ACE_USES_WCHAR */ + return isspace ((unsigned char) c); +#endif /* ACE_USES_WCHAR */ +} + +ACE_INLINE int +ACE_OS::to_lower (int c) +{ + return tolower (c); +} + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER) +ACE_INLINE wint_t +ACE_OS::to_lower (wint_t c) +{ + return towlower (c); +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_TOWLOWER */ + diff --git a/ace/OS_NS_dirent.cpp b/ace/OS_NS_dirent.cpp index fc532b41367..bbf9c0fb2df 100644 --- a/ace/OS_NS_dirent.cpp +++ b/ace/OS_NS_dirent.cpp @@ -1,4 +1,279 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_dirent.h" + +ACE_RCSID(ace, OS_NS_dirent, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_dirent.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_string.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdlib.h" + +extern "C" +{ + typedef int (*ACE_SCANDIR_COMPARATOR) (const void *, const void *); +} + +/* + These definitions are missing on the original VC6 distribution. The new + headers that define these are available in the Platform SDK and are defined + for those that don't have it. + */ +#if defined (ACE_WIN32) +# if !defined (INVALID_FILE_ATTRIBUTES) +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +# endif /* INVALID_FILE_ATTRIBUTES */ +# if !defined (INVALID_SET_FILE_POINTER) +# define INVALID_SET_FILE_POINTER ((DWORD)-1) +# endif /* INVALID_SET_FILE_POINTER */ +#endif /* ACE_WIN32 */ + +void +ACE_OS::closedir_emulation (ACE_DIR *d) +{ +#if defined (ACE_WIN32) + if (d->current_handle_ != INVALID_HANDLE_VALUE) + ::FindClose (d->current_handle_); + + d->current_handle_ = INVALID_HANDLE_VALUE; + d->started_reading_ = 0; + if (d->dirent_ != 0) + { + ACE_OS::free (d->dirent_->d_name); + ACE_OS::free (d->dirent_); + } +#else /* ACE_WIN32 */ + ACE_UNUSED_ARG (d); +#endif /* ACE_WIN32 */ +} + +ACE_DIR * +ACE_OS::opendir_emulation (const ACE_TCHAR *filename) +{ +#if defined (ACE_WIN32) + ACE_DIR *dir; + ACE_TCHAR extra[3] = {0,0,0}; + + // Check if filename is a directory. + DWORD fileAttribute = ACE_TEXT_GetFileAttributes (filename); + if (fileAttribute == INVALID_FILE_ATTRIBUTES + || !(fileAttribute & FILE_ATTRIBUTE_DIRECTORY)) + return 0; + +/* + Note: the semantics of the win32 function FindFirstFile take the + basename(filename) as a pattern to be matched within the dirname(filename). + This is contrary to the behavior of the posix function readdir which treats + basename(filename) as a directory to be opened and read. + + For this reason, we append a slash-star or backslash-star to the supplied + filename so the result is that FindFirstFile will do what we need. + + According to the documentation for FindFirstFile, either a '/' or a '\' may + be used as a directory name separator. + + Of course, it is necessary to ensure that this is only done if the trailing + filespec is not already there. + + Phil Mesnier +*/ + + size_t lastchar = ACE_OS::strlen (filename); + if (lastchar > 0) + { + if (filename[lastchar-1] != '*') + { + if (filename[lastchar-1] != '/' && filename[lastchar-1] != '\\') + ACE_OS::strcpy (extra, ACE_LIB_TEXT ("/*")); + else + ACE_OS::strcpy (extra, ACE_LIB_TEXT ("*")); + } + } + + ACE_NEW_RETURN (dir, ACE_DIR, 0); + ACE_NEW_RETURN (dir->directory_name_, + ACE_TCHAR[lastchar + ACE_OS::strlen (extra) + 1], + 0); + ACE_OS::strcpy (dir->directory_name_, filename); + if (extra[0]) + ACE_OS::strcat (dir->directory_name_, extra); + dir->current_handle_ = INVALID_HANDLE_VALUE; + dir->started_reading_ = 0; + dir->dirent_ = 0; + return dir; +#else /* ACE_WIN32 */ + ACE_UNUSED_ARG (filename); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_WIN32 */ +} + +dirent * +ACE_OS::readdir_emulation (ACE_DIR *d) +{ +#if defined (ACE_WIN32) + if (d->dirent_ != 0) + { + ACE_OS::free (d->dirent_->d_name); + ACE_OS::free (d->dirent_); + d->dirent_ = 0; + } + + if (!d->started_reading_) + { + d->current_handle_ = ACE_TEXT_FindFirstFile (d->directory_name_, + &d->fdata_); + d->started_reading_ = 1; + } + else + { + int retval = ACE_TEXT_FindNextFile (d->current_handle_, + &d->fdata_); + if (retval == 0) + { + // Make sure to close the handle explicitly to avoid a leak! + ::FindClose (d->current_handle_); + d->current_handle_ = INVALID_HANDLE_VALUE; + } + } + + if (d->current_handle_ != INVALID_HANDLE_VALUE) + { + d->dirent_ = (dirent *) + ACE_OS::malloc (sizeof (dirent)); + + if (d->dirent_ != 0) + { + d->dirent_->d_name = (ACE_TCHAR*) + ACE_OS::malloc ((ACE_OS::strlen (d->fdata_.cFileName) + 1) + * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (d->dirent_->d_name, d->fdata_.cFileName); + d->dirent_->d_reclen = sizeof (dirent); + } + + return d->dirent_; + } + else + return 0; +#else /* ACE_WIN32 */ + ACE_UNUSED_ARG (d); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_WIN32 */ +} + +int +ACE_OS::scandir_emulation (const ACE_TCHAR *dirname, + dirent **namelist[], + int (*selector) (const dirent *entry), + int (*comparator) (const dirent **f1, + const dirent **f2)) +{ + ACE_DIR *dirp = ACE_OS::opendir (dirname); + + if (dirp == 0) + return -1; + // A sanity check here. "namelist" had better not be zero. + else if (namelist == 0) + return -1; + + dirent **vector = 0; + dirent *dp; + int arena_size = 0; + + int nfiles = 0; + int fail = 0; + + // @@ This code shoulduse readdir_r() rather than readdir(). + for (dp = ACE_OS::readdir (dirp); + dp != 0; + dp = ACE_OS::readdir (dirp)) + { + if (selector && (*selector)(dp) == 0) + continue; + + // If we get here, we have a dirent that the user likes. + if (nfiles == arena_size) + { + dirent **newv; + if (arena_size == 0) + arena_size = 10; + else + arena_size *= 2; + + newv = (dirent **) ACE_OS::realloc (vector, + arena_size * sizeof (dirent *)); + if (newv == 0) + { + fail = 1; + break; + } + vector = newv; + } + +#if defined (ACE_LACKS_STRUCT_DIR) + dirent *newdp = (dirent *) ACE_OS::malloc (sizeof (dirent)); +#else + int dsize = + sizeof (dirent) + + ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); + dirent *newdp = (dirent *) ACE_OS::malloc (dsize); +#endif /* ACE_LACKS_STRUCT_DIR */ + + if (newdp == 0) + { + fail = 1; + break; + } + +#if defined (ACE_LACKS_STRUCT_DIR) + newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc ( + (ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR)); + + if (newdp->d_name == 0) + { + fail = 1; + ACE_OS::free (newdp); + break; + } + + // Don't use memcpy here since d_name is now a pointer + newdp->d_ino = dp->d_ino; + newdp->d_off = dp->d_off; + newdp->d_reclen = dp->d_reclen; + ACE_OS::strcpy (newdp->d_name, dp->d_name); + vector[nfiles++] = newdp; +#else + vector[nfiles++] = (dirent *) ACE_OS::memcpy (newdp, dp, dsize); +#endif /* ACE_LACKS_STRUCT_DIR */ + } + + if (fail) + { + ACE_OS::closedir (dirp); + while (nfiles-- > 0) + { +#if defined (ACE_LACKS_STRUCT_DIR) + ACE_OS::free (vector[nfiles]->d_name); +#endif /* ACE_LACKS_STRUCT_DIR */ + ACE_OS::free (vector[nfiles]); + } + ACE_OS::free (vector); + return -1; + } + + ACE_OS::closedir (dirp); + + *namelist = vector; + + if (comparator) + ACE_OS::qsort (*namelist, + nfiles, + sizeof (dirent *), + (ACE_SCANDIR_COMPARATOR) comparator); + + return nfiles; +} diff --git a/ace/OS_NS_dirent.h b/ace/OS_NS_dirent.h index fc532b41367..2e355ac236c 100644 --- a/ace/OS_NS_dirent.h +++ b/ace/OS_NS_dirent.h @@ -1,4 +1,79 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_dirent.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_DIRENT_H +# define ACE_OS_NS_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/os_dirent.h" + +namespace ACE_OS { + + void closedir (ACE_DIR *); + + ACE_DIR *opendir (const ACE_TCHAR *filename); + + dirent *readdir (ACE_DIR *); + + int readdir_r (ACE_DIR *dirp, + struct dirent *entry, + struct dirent **result); + + void rewinddir (ACE_DIR *); + + int scandir (const ACE_TCHAR *dirname, + struct dirent **namelist[], + int (*selector) (const struct dirent *filename), + int (*comparator) (const struct dirent **f1, + const struct dirent **f2)); + + void seekdir (ACE_DIR *, + long loc); + + long telldir (ACE_DIR *); + + // Win32 emulation functions + ACE_DIR *opendir_emulation (const ACE_TCHAR *filename); + + int scandir_emulation (const ACE_TCHAR *dirname, + dirent **namelist[], + int (*selector)(const dirent *entry), + int (*comparator)(const dirent **f1, + const dirent**f2)); + + void closedir_emulation (ACE_DIR *); + + dirent *readdir_emulation (ACE_DIR *); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_dirent.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_DIRENT_H */ diff --git a/ace/OS_NS_dirent.inl b/ace/OS_NS_dirent.inl index fc532b41367..520b23f5105 100644 --- a/ace/OS_NS_dirent.inl +++ b/ace/OS_NS_dirent.inl @@ -1,4 +1,191 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE void +ACE_OS::closedir (ACE_DIR *d) +{ +#if defined (ACE_HAS_DIRENT) +# if defined (ACE_PSOS) + + u_long result = ::close_dir (&(d->xdir)); + delete d; + if (result != 0) + errno = result; + +# else /* ! ACE_PSOS */ + +# if defined (ACE_WIN32) + ACE_OS::closedir_emulation (d); + delete [] d->directory_name_; + delete d; +# else /* ACE_WIN32 */ + ::closedir (d); +# endif /* ACE_WIN32 */ + +# endif /* ACE_PSOS */ +#else /* ACE_HAS_DIRENT */ + ACE_UNUSED_ARG (d); +#endif /* ACE_HAS_DIRENT */ +} + +ACE_INLINE ACE_DIR * +ACE_OS::opendir (const ACE_TCHAR *filename) +{ +#if defined (ACE_HAS_DIRENT) +# if defined (ACE_PSOS) + // The pointer to the <ACE_DIR> buffer *must* be passed to + // <ACE_OS::closedir> to free it and avoid a memory leak. + ACE_DIR *dir; + u_long result; + ACE_NEW_RETURN (dir, ACE_DIR, 0); + result = ::open_dir (ACE_const_cast (ACE_TCHAR *, + filename), + &dir->xdir); + if (result == 0) + return dir; + else + { + errno = result; + return 0; + } +# else /* ! ACE_PSOS */ +# if defined (ACE_WIN32) + return ::ACE_OS::opendir_emulation (filename); +# else /* ! ACE_WIN32 */ + // VxWorks' ::opendir () is declared with a non-const argument. + return ::opendir (ACE_const_cast (ACE_TCHAR *, filename)); +# endif /* ACE_WIN32 */ +# endif /* ACE_PSOS */ +#else + ACE_UNUSED_ARG (filename); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_DIRENT */ +} + +ACE_INLINE struct dirent * +ACE_OS::readdir (ACE_DIR *d) +{ +#if defined (ACE_HAS_DIRENT) +# if defined (ACE_PSOS) + + u_long result = ::read_dir (&d->xdir, &d->dirent); + if (0 == result) + return &d->dirent; + else + { + errno = result; + return 0; + } + +# else /* ! ACE_PSOS */ +# if defined (ACE_WIN32) + return ACE_OS::readdir_emulation (d); +# else /* defined (ACE_WIN32) */ + return ::readdir (d); +# endif /* defined (ACE_WIN32) */ +# endif /* ACE_PSOS */ +#else + ACE_UNUSED_ARG (d); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_DIRENT */ +} + +ACE_INLINE int +ACE_OS::readdir_r (ACE_DIR *dirp, + struct dirent *entry, + struct dirent **result) +{ +#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) + ACE_UNUSED_ARG (entry); + // <result> has better not be 0! + *result = ACE_OS::readdir (dirp); + if (*result) + return 0; // Keep iterating + else + return 1; // Oops, some type of error! +#elif defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_READDIR_R) +# if (defined (sun) && (defined (_POSIX_PTHREAD_SEMANTICS) || \ + (_FILE_OFFSET_BITS == 64))) || \ + (!defined (sun) && (defined (ACE_HAS_PTHREADS_STD) || \ + defined (ACE_HAS_PTHREADS_DRAFT7) || \ + defined (__USE_POSIX) || \ + defined (__FreeBSD__) || \ + defined (HPUX_11))) +# if defined (__GNUG__) && defined (DIGITAL_UNIX) + return readdir_r (dirp, entry, result); +# else + return ::readdir_r (dirp, entry, result); +# endif /* defined (__GNUG__) && defined (DIGITAL_UNIX) */ +# else /* ! POSIX.1c - this is draft 4 or draft 6 */ +# if defined (HPUX_10) /* But HP 10.x doesn't follow the draft either */ + *result = entry; + return ::readdir_r (dirp, entry); +# else + // <result> had better not be 0! + *result = ::readdir_r (dirp, entry); + return 0; +# endif /* HPUX_10 */ +# endif /* ! POSIX.1c */ +#else /* ! ACE_HAS_DIRENT || ACE_LACKS_READDIR_R */ + ACE_UNUSED_ARG (dirp); + ACE_UNUSED_ARG (entry); + ACE_UNUSED_ARG (result); + ACE_NOTSUP_RETURN (0); + +#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +} + +ACE_INLINE void +ACE_OS::rewinddir (ACE_DIR *d) +{ +#if defined (ACE_HAS_DIRENT) +# if defined (ACE_LACKS_SEEKDIR) +# if defined (ACE_LACKS_REWINDDIR) + ACE_UNUSED_ARG (d); +# else /* ! defined (ACE_LACKS_REWINDDIR) */ + ::rewinddir (d); +# endif /* ! defined (ACE_LACKS_REWINDDIR) */ +# else /* ! ACE_LACKS_SEEKDIR */ + // We need to implement <rewinddir> using <seekdir> since it's often + // defined as a macro... + ::seekdir (d, long (0)); +# endif /* ! ACE_LACKS_SEEKDIR */ +#else + ACE_UNUSED_ARG (d); +#endif /* ACE_HAS_DIRENT */ +} + +ACE_INLINE int +ACE_OS::scandir (const ACE_TCHAR *dirname, + struct dirent **namelist[], + int (*selector)(const struct dirent *), + int (*comparator) (const struct dirent **f1, + const struct dirent **f2)) +{ +#if defined (ACE_HAS_SCANDIR) + return ::scandir (dirname, namelist, selector, comparator); +#else /* ! defined ( ACE_HAS_SCANDIR) */ + return ACE_OS::scandir_emulation (dirname, namelist, selector, comparator); +#endif /* ACE_HAS_SCANDIR */ +} +ACE_INLINE void +ACE_OS::seekdir (ACE_DIR *d, long loc) +{ +#if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_SEEKDIR) + ::seekdir (d, loc); +#else /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */ + ACE_UNUSED_ARG (d); + ACE_UNUSED_ARG (loc); +#endif /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */ +} + +ACE_INLINE long +ACE_OS::telldir (ACE_DIR *d) +{ +#if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR) + return ::telldir (d); +#else /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */ + ACE_UNUSED_ARG (d); + ACE_NOTSUP_RETURN (-1); +#endif /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */ +} diff --git a/ace/OS_NS_dlfcn.cpp b/ace/OS_NS_dlfcn.cpp index fc532b41367..d0707dde1c2 100644 --- a/ace/OS_NS_dlfcn.cpp +++ b/ace/OS_NS_dlfcn.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_dlfcn.h" + +ACE_RCSID(ace, OS_NS_dlfcn, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_dlfcn.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_dlfcn.h b/ace/OS_NS_dlfcn.h index fc532b41367..5698b227623 100644 --- a/ace/OS_NS_dlfcn.h +++ b/ace/OS_NS_dlfcn.h @@ -1,4 +1,55 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_dlfcn.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_DLFCN_H +# define ACE_OS_NS_DLFCN_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/os_dlfcn.h" + +namespace ACE_OS { + + //@{ @name A set of wrappers for explicit dynamic linking. + int dlclose (ACE_SHLIB_HANDLE handle); + + ACE_TCHAR *dlerror (void); + + ACE_SHLIB_HANDLE dlopen (const ACE_TCHAR *filename, + int mode = ACE_DEFAULT_SHLIB_MODE); + + void *dlsym (ACE_SHLIB_HANDLE handle, + const ACE_TCHAR *symbol); + //@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_dlfcn.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_DLFCN_H */ diff --git a/ace/OS_NS_dlfcn.inl b/ace/OS_NS_dlfcn.inl index fc532b41367..83291148f8a 100644 --- a/ace/OS_NS_dlfcn.inl +++ b/ace/OS_NS_dlfcn.inl @@ -1,4 +1,252 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_macros.h" + + +ACE_INLINE int +ACE_OS::dlclose (ACE_SHLIB_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::dlclose"); +#if defined (ACE_LACKS_DLCLOSE) + ACE_UNUSED_ARG (handle); + return 0; +#elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING) + +# if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) + // SunOS4 does not automatically call _fini()! + void *ptr; + + ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_fini")), void *, 0, ptr); + + if (ptr != 0) + (*((int (*)(void)) ptr)) (); // Call _fini hook explicitly. +# endif /* ACE_HAS_AUTOMATIC_INIT_FINI */ +#if defined (_M_UNIX) + ACE_OSCALL_RETURN (::_dlclose (handle), int, -1); +#else /* _MUNIX */ + ACE_OSCALL_RETURN (::dlclose (handle), int, -1); +#endif /* _M_UNIX */ +#elif defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FreeLibrary (handle), ace_result_), int, -1); +#elif defined (__hpux) + // HP-UX 10.x and 32-bit 11.00 do not pay attention to the ref count + // when unloading a dynamic lib. So, if the ref count is more than + // 1, do not unload the lib. This will cause a library loaded more + // than once to not be unloaded until the process runs down, but + // that's life. It's better than unloading a library that's in use. + // So far as I know, there's no way to decrement the refcnt that the + // kernel is looking at - the shl_descriptor is a copy of what the + // kernel has, not the actual struct. On 64-bit HP-UX using dlopen, + // this problem has been fixed. + struct shl_descriptor desc; + if (shl_gethandle_r (handle, &desc) == -1) + return -1; + if (desc.ref_count > 1) + return 0; +# if defined(__GNUC__) || __cplusplus >= 199707L + ACE_OSCALL_RETURN (::shl_unload (handle), int, -1); +# else + ACE_OSCALL_RETURN (::cxxshl_unload (handle), int, -1); +# endif /* aC++ vs. Hp C++ */ +#else + ACE_UNUSED_ARG (handle); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ +} + +ACE_INLINE ACE_TCHAR * +ACE_OS::dlerror (void) +{ + ACE_OS_TRACE ("ACE_OS::dlerror"); +# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) +#if defined(_M_UNIX) + ACE_OSCALL_RETURN ((char *)::_dlerror (), char *, 0); +#else /* _M_UNIX */ + ACE_OSCALL_RETURN ((char *)::dlerror (), char *, 0); +#endif /* _M_UNIX */ +# elif defined (__hpux) || defined (VXWORKS) + ACE_OSCALL_RETURN (::strerror(errno), char *, 0); +# elif defined (ACE_WIN32) + static ACE_TCHAR buf[128]; +# if defined (ACE_HAS_PHARLAP) + ACE_OS::sprintf (buf, "error code %d", GetLastError()); +# else + ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, + 0, + ::GetLastError (), + 0, + buf, + sizeof buf / sizeof buf[0], + 0); +# endif /* ACE_HAS_PHARLAP */ + return buf; +# else + ACE_NOTSUP_RETURN (0); +# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ +} + +# if defined (ACE_HAS_CHARPTR_DL) +typedef ACE_TCHAR * ACE_DL_TYPE; +# else +typedef const ACE_TCHAR * ACE_DL_TYPE; +# endif /* ACE_HAS_CHARPTR_DL */ + +ACE_INLINE ACE_SHLIB_HANDLE +ACE_OS::dlopen (const ACE_TCHAR *fname, + int mode) +{ + ACE_OS_TRACE ("ACE_OS::dlopen"); + + // Get the correct OS type. + ACE_DL_TYPE filename = ACE_const_cast (ACE_DL_TYPE, fname); + +# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) + void *handle; +# if defined (ACE_HAS_SGIDLADD) + ACE_OSCALL (::sgidladd (filename, mode), void *, 0, handle); +# elif defined (_M_UNIX) + ACE_OSCALL (::_dlopen (filename, mode), void *, 0, handle); +# else + ACE_OSCALL (::dlopen (filename, mode), void *, 0, handle); +# endif /* ACE_HAS_SGIDLADD */ +# if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) + if (handle != 0) + { + void *ptr; + // Some systems (e.g., SunOS4) do not automatically call _init(), so + // we'll have to call it manually. + + ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_init")), void *, 0, ptr); + + if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly. + { + // Close down the handle to prevent leaks. + ::dlclose (handle); + return 0; + } + } +# endif /* ACE_HAS_AUTOMATIC_INIT_FINI */ + return handle; +# elif defined (ACE_WIN32) + ACE_UNUSED_ARG (mode); + + ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (filename), ACE_SHLIB_HANDLE, 0); +# elif defined (__hpux) + +# if defined(__GNUC__) || __cplusplus >= 199707L + ACE_OSCALL_RETURN (::shl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0); +# else + ACE_OSCALL_RETURN (::cxxshl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0); +# endif /* aC++ vs. Hp C++ */ +# elif defined (VXWORKS) + MODULE* handle; + // Open readonly + ACE_HANDLE filehandle = ACE_OS::open (filename, + O_RDONLY, + ACE_DEFAULT_FILE_PERMS); + + if (filehandle != ACE_INVALID_HANDLE) + { + ACE_OS::last_error(0); + ACE_OSCALL ( ::loadModule (filehandle, mode ), MODULE *, 0, handle); + int loaderror = ACE_OS::last_error(); + ACE_OS::close (filehandle); + + if ( (loaderror != 0) && (handle != 0) ) + { + // ouch something went wrong most likely unresolved externals + ::unldByModuleId ( handle, 0 ); + handle = 0; + } + } + else + { + // couldn't open file + handle = 0; + } + return handle; +# else + ACE_UNUSED_ARG (filename); + ACE_UNUSED_ARG (mode); + ACE_NOTSUP_RETURN (0); +# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ +} + +ACE_INLINE void * +ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, + const ACE_TCHAR *sname) +{ + ACE_OS_TRACE ("ACE_OS::dlsym"); + +#if defined (ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE) + // Check if the handle is valid before making any calls using it. + if (handle == ACE_SHLIB_INVALID_HANDLE) + return 0; +#endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */ + + // Get the correct OS type. +#if defined (ACE_HAS_WINCE) + const wchar_t *symbolname = sname; +#elif defined (ACE_HAS_CHARPTR_DL) + char *symbolname = ACE_const_cast (char *, sname); +#elif !defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) + const char *symbolname = sname; +#endif /* ACE_HAS_CHARPTR_DL */ + +# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) + +# if defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0); +# elif defined (ACE_USES_ASM_SYMBOL_IN_DLSYM) + int l = ACE_OS::strlen (symbolname) + 2; + char *asm_symbolname = 0; + ACE_NEW_RETURN (asm_symbolname, char[l], 0); + ACE_OS::strcpy (asm_symbolname, "_") ; + ACE_OS::strcpy (asm_symbolname + 1, symbolname) ; + void *ace_result; + ACE_OSCALL (::dlsym (handle, asm_symbolname), void *, 0, ace_result); + delete [] asm_symbolname; + return ace_result; +# elif defined (_M_UNIX) + ACE_OSCALL_RETURN (::_dlsym (handle, symbolname), void *, 0); +# else + ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ + +# elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) && !defined (ACE_HAS_WINCE) + + ACE_WIN32CALL_RETURN (::GetProcAddress (handle, ACE_TEXT_ALWAYS_CHAR (sname)), void *, 0); + +# elif defined (ACE_WIN32) + + ACE_WIN32CALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0); + +# elif defined (__hpux) + + void *value; + int status; + shl_t _handle = handle; + ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status); + return status == 0 ? value : 0; + +# elif defined (VXWORKS) + + // For now we use the VxWorks global symbol table + // which resolves the most recently loaded symbols .. which resolve mostly what we want.. + ACE_UNUSED_ARG (handle); + SYM_TYPE symtype; + void *value = 0; + STATUS status; + ACE_OSCALL (::symFindByName(sysSymTbl, symbolname, (char **)&value, &symtype), int, -1, status); + + return status == OK ? value : 0; + +# else + + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (symbolname); + ACE_NOTSUP_RETURN (0); + +# endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ +} diff --git a/ace/OS_NS_errno.cpp b/ace/OS_NS_errno.cpp index fc532b41367..27a0901f32a 100644 --- a/ace/OS_NS_errno.cpp +++ b/ace/OS_NS_errno.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_errno.h" + +ACE_RCSID(ace, OS_NS_errno, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_errno.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_errno.h b/ace/OS_NS_errno.h index fc532b41367..d35ad6eb665 100644 --- a/ace/OS_NS_errno.h +++ b/ace/OS_NS_errno.h @@ -1,4 +1,51 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_errno.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_ERRNO_H +# define ACE_OS_NS_ERRNO_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/os_errno.h" + +namespace ACE_OS { + + int last_error (void); + + void last_error (int); + + int set_errno_to_last_error (void); + + int set_errno_to_wsa_last_error (void); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_errno.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_ERRNO_H */ diff --git a/ace/OS_NS_errno.inl b/ace/OS_NS_errno.inl index fc532b41367..8e47ce38525 100644 --- a/ace/OS_NS_errno.inl +++ b/ace/OS_NS_errno.inl @@ -1,4 +1,64 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE int +ACE_OS::last_error (void) +{ + // ACE_OS_TRACE ("ACE_OS::last_error"); + +#if defined (ACE_WIN32) + int lerror = ::GetLastError (); + int lerrno = errno; + return lerrno == 0 ? lerror : lerrno; +#else + return errno; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE void +ACE_OS::last_error (int error) +{ + ACE_OS_TRACE ("ACE_OS::last_error"); +#if defined (ACE_WIN32) + ::SetLastError (error); +#endif /* ACE_WIN32 */ + errno = error; +} + +ACE_INLINE int +ACE_OS::set_errno_to_last_error (void) +{ +# if defined (ACE_WIN32) +// Borland C++ Builder 4 has a bug in the RTL that resets the +// <GetLastError> value to zero when errno is accessed. Thus, we have +// to use this to set errno to GetLastError. It's bad, but only for +// WIN32. +# if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400) + int last_error = ::GetLastError (); + return errno = last_error; +# else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ + return errno = ::GetLastError (); +# endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ +#else + return errno; +# endif /* defined(ACE_WIN32) */ +} + +ACE_INLINE int +ACE_OS::set_errno_to_wsa_last_error (void) +{ +# if defined (ACE_WIN32) +// Borland C++ Builder 4 has a bug in the RTL that resets the +// <GetLastError> value to zero when errno is accessed. Thus, we have +// to use this to set errno to GetLastError. It's bad, but only for +// WIN32 +# if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400) + int last_error = ::WSAGetLastError (); + return errno = last_error; +# else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ + return errno = ::WSAGetLastError (); +# endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */ +#else + return errno; +# endif /* defined(ACE_WIN32) */ +} diff --git a/ace/OS_NS_fcntl.cpp b/ace/OS_NS_fcntl.cpp index fc532b41367..e1e948c2d00 100644 --- a/ace/OS_NS_fcntl.cpp +++ b/ace/OS_NS_fcntl.cpp @@ -1,4 +1,254 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_fcntl.h" + +ACE_RCSID(ace, OS_NS_fcntl, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_fcntl.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +ACE_HANDLE +ACE_OS::open (const char *filename, + int mode, + int perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_OS_TRACE ("ACE_OS::open"); + +#if defined (ACE_WIN32) + DWORD access = GENERIC_READ; + if (ACE_BIT_ENABLED (mode, O_WRONLY)) + access = GENERIC_WRITE; + else if (ACE_BIT_ENABLED (mode, O_RDWR)) + access = GENERIC_READ | GENERIC_WRITE; + + DWORD creation = OPEN_EXISTING; + + if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) + creation = CREATE_NEW; + else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) + creation = CREATE_ALWAYS; + else if (ACE_BIT_ENABLED (mode, _O_CREAT)) + creation = OPEN_ALWAYS; + else if (ACE_BIT_ENABLED (mode, _O_TRUNC)) + creation = TRUNCATE_EXISTING; + + DWORD flags = 0; + + if (ACE_BIT_ENABLED (mode, _O_TEMPORARY)) + flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; + + if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) + flags |= FILE_FLAG_WRITE_THROUGH; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) + flags |= FILE_FLAG_OVERLAPPED; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) + flags |= FILE_FLAG_NO_BUFFERING; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) + flags |= FILE_FLAG_RANDOM_ACCESS; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) + flags |= FILE_FLAG_SEQUENTIAL_SCAN; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) + flags |= FILE_FLAG_DELETE_ON_CLOSE; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) + flags |= FILE_FLAG_BACKUP_SEMANTICS; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) + flags |= FILE_FLAG_POSIX_SEMANTICS; + + ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) + + if (ACE_BIT_ENABLED (mode, _O_APPEND)) + { + ACE_MT + ( + ace_os_monitor_lock = (ACE_thread_mutex_t *) + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]; + ACE_OS::thread_mutex_lock (ace_os_monitor_lock); + ) + } + + DWORD shared_mode = perms; + +#if defined (ACE_HAS_WINCE) + ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (), access, + shared_mode, + ACE_OS::default_win32_security_attributes (sa), + creation, + flags, + 0); +#else /* ACE_HAS_WINCE */ + ACE_HANDLE h = ::CreateFileA (filename, access, + shared_mode, + ACE_OS::default_win32_security_attributes (sa), + creation, + flags, + 0); +#endif /* ACE_HAS_WINCE */ + + if (ACE_BIT_ENABLED (mode, _O_APPEND)) + { + if (h != ACE_INVALID_HANDLE) + { + ::SetFilePointer (h, 0, 0, FILE_END); + } + + ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) + } + + if (h == ACE_INVALID_HANDLE) + ACE_FAIL_RETURN (h); + else + return h; +#elif defined (ACE_PSOS) + ACE_UNUSED_ARG (perms); + ACE_UNUSED_ARG (sa); +# if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (filename); + return 0; +# else + unsigned long result, handle; + result = ::open_f (&handle, ACE_const_cast(char *, filename), 0); + if (result != 0) + { + // We need to clean this up...not 100% correct! + // To correct we should handle all the cases of TRUNC and CREAT + if ((result == 0x200B) && (ACE_BIT_ENABLED (mode, O_CREAT))) + { + result = ::create_f(ACE_const_cast(char *, filename),1,0); + if (result != 0) + { + errno = result; + return ACE_static_cast (ACE_HANDLE, -1); + } + else //File created...try to open it again + { + result = ::open_f (&handle, ACE_const_cast(char *, filename), 0); + if (result != 0) + { + errno = result; + return ACE_static_cast (ACE_HANDLE, -1); + } + + } + } + else + { + errno = result; + return ACE_static_cast (ACE_HANDLE, -1); + } + } + return ACE_static_cast (ACE_HANDLE, handle); +# endif /* defined (ACE_PSOS_LACKS_PHILE) */ +#elif defined (INTEGRITY) + ACE_UNUSED_ARG (sa); + if(!strcmp(filename,ACE_DEV_NULL)) { + ACE_OSCALL_RETURN (::AllocateNullConsoleDescriptor(), ACE_HANDLE, -1); + } + else { + ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1); + } +#else + ACE_UNUSED_ARG (sa); + ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1); +#endif /* ACE_WIN32 */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_HANDLE +ACE_OS::open (const wchar_t *filename, + int mode, + int perms, + LPSECURITY_ATTRIBUTES sa) +{ +#if defined (ACE_WIN32) + // @@ (brunsch) Yuck, maybe there is a way to combine the code + // here with the char version + + DWORD access = GENERIC_READ; + if (ACE_BIT_ENABLED (mode, O_WRONLY)) + access = GENERIC_WRITE; + else if (ACE_BIT_ENABLED (mode, O_RDWR)) + access = GENERIC_READ | GENERIC_WRITE; + + DWORD creation = OPEN_EXISTING; + + if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) + creation = CREATE_NEW; + else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) + creation = CREATE_ALWAYS; + else if (ACE_BIT_ENABLED (mode, _O_CREAT)) + creation = OPEN_ALWAYS; + else if (ACE_BIT_ENABLED (mode, _O_TRUNC)) + creation = TRUNCATE_EXISTING; + + DWORD flags = 0; + + if (ACE_BIT_ENABLED (mode, _O_TEMPORARY)) + flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; + + if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) + flags |= FILE_FLAG_WRITE_THROUGH; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) + flags |= FILE_FLAG_OVERLAPPED; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) + flags |= FILE_FLAG_NO_BUFFERING; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) + flags |= FILE_FLAG_RANDOM_ACCESS; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) + flags |= FILE_FLAG_SEQUENTIAL_SCAN; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) + flags |= FILE_FLAG_DELETE_ON_CLOSE; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) + flags |= FILE_FLAG_BACKUP_SEMANTICS; + if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) + flags |= FILE_FLAG_POSIX_SEMANTICS; + + ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) + + if (ACE_BIT_ENABLED (mode, _O_APPEND)) + { + ACE_MT + ( + ace_os_monitor_lock = (ACE_thread_mutex_t *) + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]; + ACE_OS::thread_mutex_lock (ace_os_monitor_lock); + ) + } + + DWORD shared_mode = perms; + + ACE_HANDLE h = ::CreateFileW (filename, + access, + shared_mode, + ACE_OS::default_win32_security_attributes (sa), + creation, + flags, + 0); + + if (ACE_BIT_ENABLED (mode, _O_APPEND)) + { + if (h != ACE_INVALID_HANDLE) + { + ::SetFilePointer (h, 0, 0, FILE_END); + } + + ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) + } + + if (h == ACE_INVALID_HANDLE) + ACE_FAIL_RETURN (h); + else + return h; +#else /* ACE_WIN32 */ + // Just emulate with ascii version + return ACE_OS::open (ACE_Wide_To_Ascii (filename).char_rep (), + mode, + perms, + sa); +#endif /* ACE_WIN32 */ +} +#endif /* ACE_HAS_WCHAR */ diff --git a/ace/OS_NS_fcntl.h b/ace/OS_NS_fcntl.h index fc532b41367..027f4dd93c3 100644 --- a/ace/OS_NS_fcntl.h +++ b/ace/OS_NS_fcntl.h @@ -1,4 +1,82 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_fcntl.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_FCNTL_H +# define ACE_OS_NS_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/os_fcntl.h" +#include "ace/Global_Macros.h" // for LPSECURITY_ATTRIBUTES :-( + +namespace ACE_OS { + + int fcntl (ACE_HANDLE handle, + int cmd, + long arg = 0); + + // It used to be that the <perms> argument default was 0 on all + // platforms. Further, the ACE_OS::open implementations ignored <perms> + // for Win32 and always supplied read|write|delete. To preserve + // backward compatibility and allow users to pass in values + // that are used as desired, the defaults are now what the default + // action used to be on Win32. The implementation now obeys what is passed. +#if defined (ACE_WIN32) +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1) +# define ACE_DEFAULT_OPEN_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE | \ + FILE_SHARE_DELETE) +# else +# define ACE_DEFAULT_OPEN_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE) +# endif /* ACE_HAS_WINCE */ +#else +# define ACE_DEFAULT_OPEN_PERMS 0 +#endif /* ACE_WIN32 */ + + /// The O_APPEND flag is only partly supported on Win32. If you specify + /// O_APPEND, then the file pointer will be positioned at the end of + /// the file initially during open, but it is not re-positioned at + /// the end prior to each write, as specified by POSIX. This + /// is generally good enough for typical situations, but it is ``not + /// quite right'' in its semantics. + ACE_HANDLE open (const char *filename, + int mode, + int perms = ACE_DEFAULT_OPEN_PERMS, + LPSECURITY_ATTRIBUTES sa = 0); +#if defined (ACE_HAS_WCHAR) + ACE_HANDLE open (const wchar_t *filename, + int mode, + int perms = ACE_DEFAULT_OPEN_PERMS, + LPSECURITY_ATTRIBUTES sa = 0); +#endif /* ACE_HAS_WCHAR */ + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_fcntl.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_FCNTL_H */ diff --git a/ace/OS_NS_fcntl.inl b/ace/OS_NS_fcntl.inl index fc532b41367..3e0e4e14884 100644 --- a/ace/OS_NS_fcntl.inl +++ b/ace/OS_NS_fcntl.inl @@ -1,4 +1,17 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE int +ACE_OS::fcntl (ACE_HANDLE handle, int cmd, long arg) +{ + ACE_OS_TRACE ("ACE_OS::fcntl"); +# if defined (ACE_LACKS_FCNTL) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (::fcntl (handle, cmd, arg), int, -1); +# endif /* ACE_LACKS_FCNTL */ +} + diff --git a/ace/OS_NS_macros.h b/ace/OS_NS_macros.h index fc532b41367..c651d752ca8 100644 --- a/ace/OS_NS_macros.h +++ b/ace/OS_NS_macros.h @@ -1,4 +1,67 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_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... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_MACROS_H +# define ACE_OS_NS_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_WIN32) +# define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) \ + do { TYPE ace_result_ = (TYPE) OP; \ + if (ace_result_ == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; return (TYPE) FAILVALUE; } else return ace_result_; \ + } while (0) +#else +# define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) ACE_OSCALL_RETURN(OP,TYPE,FAILVALUE) +#endif /* ACE_WIN32 */ + +#if !defined (ACE_WIN32) + +// Adapt the weird threading and synchronization routines (which +// return errno rather than -1) so that they return -1 and set errno. +// This is more consistent with the rest of ACE_OS and enables use to +// use the ACE_OSCALL* macros. +# if defined (VXWORKS) +# define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != OK ? (errno = RESULT, -1) : 0) +# else +# define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0) +# endif /* VXWORKS */ + +#else /* ACE_WIN32 */ + +// Adapt the Win32 System Calls (which return BOOLEAN values of TRUE +// and FALSE) into int values expected by the ACE_OSCALL macros. +# define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) == FALSE ? -1 : 0) + +// Perform a mapping of Win32 error numbers into POSIX errnos. +# define ACE_FAIL_RETURN(RESULT) do { \ + switch (ACE_OS::set_errno_to_last_error ()) { \ + case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; \ + case ERROR_FILE_EXISTS: errno = EEXIST; break; \ + case ERROR_SHARING_VIOLATION: errno = EACCES; break; \ + case ERROR_PATH_NOT_FOUND: errno = ENOENT; break; \ + } \ + return RESULT; } while (0) + +#endif /* !ACE_WIN32 */ + +#endif /* ACE_OS_NS_MACROS_H */ diff --git a/ace/OS_NS_math.cpp b/ace/OS_NS_math.cpp index fc532b41367..dc009cad8ba 100644 --- a/ace/OS_NS_math.cpp +++ b/ace/OS_NS_math.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_math.h" + +ACE_RCSID(ace, OS_NS_math, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_math.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_math.h b/ace/OS_NS_math.h index fc532b41367..350f6ebd046 100644 --- a/ace/OS_NS_math.h +++ b/ace/OS_NS_math.h @@ -1,4 +1,48 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_math.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_MATH_H +# define ACE_OS_NS_MATH_H + +# include /**/ "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace ACE_OS { + + /// This method computes the largest integral value not greater than x. + double floor (double x); + + /// This method computes the smallest integral value not less than x. + double ceil (double x); + + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_math.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_MATH_H */ diff --git a/ace/OS_NS_math.inl b/ace/OS_NS_math.inl index fc532b41367..9ff3151ab4f 100644 --- a/ace/OS_NS_math.inl +++ b/ace/OS_NS_math.inl @@ -1,4 +1,20 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE double +ACE_OS::floor (double x) +{ + // This method computes the largest integral value not greater than x. + return double (ACE_static_cast (long, x)); +} + +ACE_INLINE double +ACE_OS::ceil (double x) +{ + // This method computes the smallest integral value not less than x. + double floor = ACE_OS::floor (x); + if (floor == x) + return floor; + else + return floor + 1; +} diff --git a/ace/OS_NS_netdb.cpp b/ace/OS_NS_netdb.cpp index fc532b41367..61073801acc 100644 --- a/ace/OS_NS_netdb.cpp +++ b/ace/OS_NS_netdb.cpp @@ -1,4 +1,359 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_netdb.h" + +ACE_RCSID(ace, OS_NS_netdb, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_netdb.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/os_include/net/os_if.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stropts.h" +#include "ace/OS_NS_sys_socket.h" + +#if defined (VXWORKS) + +struct hostent * +ACE_OS::gethostbyaddr (const char *addr, int length, int type) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyaddr"); + + if (length != 4 || type != AF_INET) + { + errno = EINVAL; + return 0; + } + + // not thread safe! + static hostent ret; + static char name [MAXNAMELEN + 1]; + static char *hostaddr[2]; + static char *aliases[1]; + + if (::hostGetByAddr (*(int *) addr, name) != 0) + { + // errno will have been set to S_hostLib_UNKNOWN_HOST. + return 0; + } + + // Might not be official: just echo input arg. + hostaddr[0] = (char *) addr; + hostaddr[1] = 0; + aliases[0] = 0; + + ret.h_name = name; + ret.h_addrtype = AF_INET; + ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; + ret.h_addr_list = hostaddr; + ret.h_aliases = aliases; + + return &ret; +} + +struct hostent * +ACE_OS::gethostbyaddr_r (const char *addr, int length, int type, + hostent *result, ACE_HOSTENT_DATA buffer, + int *h_errnop) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r"); + if (length != 4 || type != AF_INET) + { + errno = EINVAL; + return 0; + } + + if (ACE_OS::netdb_acquire ()) + return 0; + else + { + // buffer layout: + // buffer[0-3]: h_addr_list[0], the first (and only) addr. + // buffer[4-7]: h_addr_list[1], the null terminator for the h_addr_list. + // buffer[8]: the name of the host, null terminated. + + // Call ::hostGetByAddr (), which puts the (one) hostname into + // buffer. + if (::hostGetByAddr (*(int *) addr, &buffer[8]) == 0) + { + // Store the return values in result. + result->h_name = &buffer[8]; // null-terminated host name + result->h_addrtype = AF_INET; + result->h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN. + + result->h_addr_list = (char **) buffer; + // Might not be official: just echo input arg. + result->h_addr_list[0] = (char *) addr; + // Null-terminate the list of addresses. + result->h_addr_list[1] = 0; + // And no aliases, so null-terminate h_aliases. + result->h_aliases = &result->h_addr_list[1]; + } + else + { + // errno will have been set to S_hostLib_UNKNOWN_HOST. + result = 0; + } + } + + ACE_OS::netdb_release (); + *h_errnop = errno; + return result; +} + +struct hostent * +ACE_OS::gethostbyname (const char *name) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyname"); + + // not thread safe! + static hostent ret; + static int first_addr; + static char *hostaddr[2]; + static char *aliases[1]; + + ACE_OSCALL (::hostGetByName ((char *) name), int, -1, first_addr); + if (first_addr == -1) + return 0; + + hostaddr[0] = (char *) &first_addr; + hostaddr[1] = 0; + aliases[0] = 0; + + // Might not be official: just echo input arg. + ret.h_name = (char *) name; + ret.h_addrtype = AF_INET; + ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; + ret.h_addr_list = hostaddr; + ret.h_aliases = aliases; + + return &ret; +} + +struct hostent * +ACE_OS::gethostbyname_r (const char *name, hostent *result, + ACE_HOSTENT_DATA buffer, + int *h_errnop) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyname_r"); + + if (ACE_OS::netdb_acquire ()) + return 0; + else + { + int addr; + ACE_OSCALL (::hostGetByName ((char *) name), int, -1, addr); + + if (addr == -1) + { + // errno will have been set to S_hostLib_UNKNOWN_HOST + result = 0; + } + else + { + // Might not be official: just echo input arg. + result->h_name = (char *) name; + result->h_addrtype = AF_INET; + result->h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; + + // buffer layout: + // buffer[0-3]: h_addr_list[0], pointer to the addr. + // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list. + // buffer[8-11]: the first (and only) addr. + + // Store the address list in buffer. + result->h_addr_list = (char **) buffer; + // Store the actual address _after_ the address list. + result->h_addr_list[0] = (char *) &result->h_addr_list[2]; + result->h_addr_list[2] = (char *) addr; + // Null-terminate the list of addresses. + result->h_addr_list[1] = 0; + // And no aliases, so null-terminate h_aliases. + result->h_aliases = &result->h_addr_list[1]; + } + } + + ACE_OS::netdb_release (); + *h_errnop = errno; + return result; +} + +#endif /* VXWORKS */ + +// Include if_arp so that getmacaddr can use the +// arp structure. +#if defined (sun) +# include /**/ <net/if_arp.h> +#endif + +int +ACE_OS::getmacaddress (struct macaddr_node_t *node) +{ + ACE_OS_TRACE ("ACE_OS::getmacaddress"); + +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + + /** Define a structure for use with the netbios routine */ + struct ADAPTERSTAT + { + ADAPTER_STATUS adapt; + NAME_BUFFER NameBuff [30]; + }; + + NCB ncb; + LANA_ENUM lenum; + unsigned char result; + + ACE_OS::memset (&ncb, 0, sizeof(ncb)); + ncb.ncb_command = NCBENUM; + ncb.ncb_buffer = ACE_reinterpret_cast (unsigned char*,&lenum); + ncb.ncb_length = sizeof(lenum); + + result = Netbios (&ncb); + + for(int i = 0; i < lenum.length; i++) + { + ACE_OS::memset (&ncb, 0, sizeof(ncb)); + ncb.ncb_command = NCBRESET; + ncb.ncb_lana_num = lenum.lana [i]; + + /** Reset the netbios */ + result = Netbios (&ncb); + + if (ncb.ncb_retcode != NRC_GOODRET) + { + return -1; + } + + ADAPTERSTAT adapter; + ACE_OS::memset (&ncb, 0, sizeof (ncb)); +# if defined (__BORLANDC__) || defined (__MINGW32__) + ACE_OS::strcpy (ACE_reinterpret_cast (char*, ncb.ncb_callname), "*"); +# else + ACE_OS::strcpy (ACE_static_cast (char*, ncb.ncb_callname), "*"); +# endif /* __BORLANDC__ || __MINGW32__ */ + ncb.ncb_command = NCBASTAT; + ncb.ncb_lana_num = lenum.lana[i]; + ncb.ncb_buffer = ACE_reinterpret_cast (unsigned char*, &adapter); + ncb.ncb_length = sizeof (adapter); + + result = Netbios (&ncb); + + if (result == 0) + { + ACE_OS::memcpy (node->node, + adapter.adapt.adapter_address, + 6); + return 0; + } + } + return 0; +#elif defined (sun) + + /** obtain the local host name */ + char hostname [MAXHOSTNAMELEN]; + ACE_OS::hostname (hostname, sizeof (hostname)); + + /** Get the hostent to use with ioctl */ + struct hostent *phost = + ACE_OS::gethostbyname (hostname); + + if (phost == 0) + { + return -1; + } + + ACE_HANDLE handle = + ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); + + if (handle == ACE_INVALID_HANDLE) + { + return -1; + } + + char **paddrs = phost->h_addr_list; + + struct arpreq ar; + + struct sockaddr_in *psa = + (struct sockaddr_in *)&(ar.arp_pa); + + ACE_OS::memset (&ar, + 0, + sizeof (struct arpreq)); + + psa->sin_family = AF_INET; + + ACE_OS::memcpy (&(psa->sin_addr), + *paddrs, + sizeof (struct in_addr)); + + if (ACE_OS::ioctl (handle, + SIOCGARP, + &ar) == -1) + { + return -1; + } + + ACE_OS::close (handle); + + ACE_OS::memcpy (node->node, + ar.arp_ha.sa_data, + 6); + + return 0; + +#elif defined (linux) + + struct ifreq ifr; + + ACE_HANDLE handle = + ACE_OS::socket (PF_INET, SOCK_DGRAM, 0); + + if (handle == ACE_INVALID_HANDLE) + { + return -1; + } + + ACE_OS::strcpy (ifr.ifr_name, "eth0"); + + if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0) + { + ACE_OS::close (handle); + return -1; + } + + struct sockaddr* sa = + (struct sockaddr *) &ifr.ifr_addr; + + ACE_OS::memcpy (node->node, + sa->sa_data, + 6); + + return 0; + +#else + ACE_UNUSED_ARG (node); + ACE_NOTSUP_RETURN (-1); +#endif +} + +# if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) +int +ACE_OS::netdb_acquire (void) +{ + return ACE_OS::thread_mutex_lock ((ACE_thread_mutex_t *) + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); +} + +int +ACE_OS::netdb_release (void) +{ + return ACE_OS::thread_mutex_unlock ((ACE_thread_mutex_t *) + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); +} +# endif /* defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) */ diff --git a/ace/OS_NS_netdb.h b/ace/OS_NS_netdb.h index fc532b41367..234e16f3f6b 100644 --- a/ace/OS_NS_netdb.h +++ b/ace/OS_NS_netdb.h @@ -1,4 +1,103 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_netdb.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_NETDB_H +# define ACE_OS_NS_NETDB_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/os_netdb.h" + +namespace ACE_OS { + + struct hostent *gethostbyaddr (const char *addr, + int length, + int type); + + struct hostent *gethostbyaddr_r (const char *addr, + int length, + int type, + struct hostent *result, + ACE_HOSTENT_DATA buffer, + int *h_errnop); + + struct hostent *gethostbyname (const char *name); + + struct hostent *gethostbyname_r (const char *name, + struct hostent *result, + ACE_HOSTENT_DATA buffer, + int *h_errnop); + + + struct hostent *getipnodebyaddr (const void *src, size_t len, + int family); + + struct hostent *getipnodebyname (const char *name, int family, + int flags = 0); + + /** + * Get the first adapter found on the machine. + * @todo: this is really useless except for UUID, move there? dhinton + */ + struct macaddr_node_t { + unsigned char node[6]; + }; + + int getmacaddress (struct macaddr_node_t *node); + + struct protoent *getprotobyname (const char *name); + + struct protoent *getprotobyname_r (const char *name, + struct protoent *result, + ACE_PROTOENT_DATA buffer); + + struct protoent *getprotobynumber (int proto); + + struct protoent *getprotobynumber_r (int proto, + struct protoent *result, + ACE_PROTOENT_DATA buffer); + + struct servent *getservbyname (const char *svc, + const char *proto); + + struct servent *getservbyname_r (const char *svc, + const char *proto, + struct servent *result, + ACE_SERVENT_DATA buf); + +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + int netdb_acquire (void); + int netdb_release (void); +# endif /* defined (ACE_MT_SAFE) && ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_netdb.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_NETDB_H */ diff --git a/ace/OS_NS_netdb.inl b/ace/OS_NS_netdb.inl index fc532b41367..62ca9c182bc 100644 --- a/ace/OS_NS_netdb.inl +++ b/ace/OS_NS_netdb.inl @@ -1,4 +1,528 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_macros.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" + +#if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \ + do \ + { \ + if (ACE_OS::netdb_acquire ()) \ + return FAILVALUE; \ + else \ + { \ + TYPE ace_result_; \ + ACE_OSCALL (OP, TYPE, FAILVALUE, ace_result_); \ + if (ace_result_ != FAILVALUE) \ + ::memcpy (TARGET, \ + ace_result_, \ + SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \ + ACE_OS::netdb_release (); \ + return ace_result_; \ + } \ + } while(0) +# else /* ! (ACE_MT_SAFE && ACE_MT_SAFE != 0) */ +# define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \ + do \ + { \ + TYPE ace_result_; \ + ACE_OSCALL(OP,TYPE,FAILVALUE,ace_result_); \ + if (ace_result_ != FAILVALUE) \ + ::memcpy (TARGET, \ + ace_result_, \ + SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \ + return ace_result_; \ + } while(0) +# endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ +#endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ + +#if !defined (VXWORKS) + +ACE_INLINE struct hostent * +ACE_OS::gethostbyaddr (const char *addr, int length, int type) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyaddr"); +# if defined (ACE_PSOS) + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (length); + ACE_UNUSED_ARG (type); + ACE_NOTSUP_RETURN (0); +# elif defined (ACE_HAS_NONCONST_GETBY) + ACE_SOCKCALL_RETURN (::gethostbyaddr (ACE_const_cast (char *, addr), + (ACE_SOCKET_LEN) length, + type), + struct hostent *, + 0); +# else + ACE_SOCKCALL_RETURN (::gethostbyaddr (addr, + (ACE_SOCKET_LEN) length, + type), + struct hostent *, + 0); +# endif /* ACE_HAS_NONCONST_GETBY */ +} + +ACE_INLINE struct hostent * +ACE_OS::gethostbyaddr_r (const char *addr, + int length, + int type, + struct hostent *result, + ACE_HOSTENT_DATA buffer, + int *h_errnop) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r"); +# if defined (ACE_PSOS) + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (length); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (h_errnop); + ACE_NOTSUP_RETURN (0); +# elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) +# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) + ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); + + if (::gethostbyaddr_r ((char *) addr, length, type, result, + (struct hostent_data *) buffer)== 0) + return result; + else + { + *h_errnop = h_errno; + return (struct hostent *) 0; + } +# elif defined (__GLIBC__) + // GNU C library has a different signature + ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); + + if (::gethostbyaddr_r ((char *) addr, + length, + type, + result, + buffer, + sizeof (ACE_HOSTENT_DATA), + &result, + h_errnop) == 0) + return result; + else + return (struct hostent *) 0; +# else +# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (h_errnop); + ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type), + struct hostent *, 0, + buffer, sizeof (ACE_HOSTENT_DATA)); +# else + ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result, + buffer, sizeof (ACE_HOSTENT_DATA), + h_errnop), + struct hostent *, 0); +# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ +# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ +# elif defined (ACE_HAS_NONCONST_GETBY) + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (h_errnop); + ACE_SOCKCALL_RETURN (::gethostbyaddr (ACE_const_cast (char *, addr), + (ACE_SOCKET_LEN) length, + type), + struct hostent *, + 0); +# else + ACE_UNUSED_ARG (h_errnop); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (result); + + ACE_SOCKCALL_RETURN (::gethostbyaddr (addr, + (ACE_SOCKET_LEN) length, + type), + struct hostent *, + 0); +# endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ +} + +ACE_INLINE struct hostent * +ACE_OS::gethostbyname (const char *name) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyname"); +# if defined (ACE_PSOS) + ACE_UNUSED_ARG (name); + ACE_NOTSUP_RETURN (0); +# elif defined (ACE_HAS_NONCONST_GETBY) + ACE_SOCKCALL_RETURN (::gethostbyname (ACE_const_cast (char *, name)), + struct hostent *, + 0); +# else + ACE_SOCKCALL_RETURN (::gethostbyname (name), + struct hostent *, + 0); +# endif /* ACE_HAS_NONCONST_GETBY */ +} + +ACE_INLINE struct hostent * +ACE_OS::gethostbyname_r (const char *name, + struct hostent *result, + ACE_HOSTENT_DATA buffer, + int *h_errnop) +{ + ACE_OS_TRACE ("ACE_OS::gethostbyname_r"); +#if defined (ACE_PSOS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (h_errnop); + ACE_NOTSUP_RETURN (0); +# elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) +# if defined (DIGITAL_UNIX) || \ + (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2)) + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (h_errnop); + + // gethostbyname returns thread-specific storage on Digital Unix and + // AIX 4.3 + ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0); +# elif defined (AIX) || defined (HPUX_10) + ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); + + if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0) + return result; + else + { + *h_errnop = h_errno; + return (struct hostent *) 0; + } +# elif defined (__GLIBC__) + // GNU C library has a different signature + ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); + + if (::gethostbyname_r (name, + result, + buffer, + sizeof (ACE_HOSTENT_DATA), + &result, + h_errnop) == 0) + return result; + else + return (struct hostent *) 0; +# else +# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (h_errnop); + ACE_NETDBCALL_RETURN (::gethostbyname (name), + struct hostent *, 0, + buffer, sizeof (ACE_HOSTENT_DATA)); +# else + ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer, + sizeof (ACE_HOSTENT_DATA), + h_errnop), + struct hostent *, + 0); +# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ +# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ +# elif defined (ACE_HAS_NONCONST_GETBY) + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (h_errnop); + ACE_SOCKCALL_RETURN (::gethostbyname (ACE_const_cast (char *, name)), + struct hostent *, + 0); +# else + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (h_errnop); + + ACE_SOCKCALL_RETURN (::gethostbyname (name), + struct hostent *, + 0); +# endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ +} + +ACE_INLINE struct hostent * +ACE_OS::getipnodebyaddr (const void *src, size_t len, int family) +{ +#if defined (ACE_HAS_IPV6) +# if defined (__GLIBC__) + ACE_UNUSED_ARG (src); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (family); + ACE_NOTSUP_RETURN (0); +# else + struct hostent *hptr; + int errnum; + if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0) + { + errno = errnum; + } + return hptr; +# endif /* whatever_doesnt_have_getipnodebyname */ +#else + // IPv4-only implementation + if (family == AF_INET) + return ACE_OS::gethostbyaddr (ACE_static_cast (const char *, src), + ACE_static_cast (int, len), + family); + + ACE_NOTSUP_RETURN (0); +# endif /* ACE_PSOS */ +} + +ACE_INLINE struct hostent * +ACE_OS::getipnodebyname (const char *name, int family, int flags) +{ + ACE_OS_TRACE ("ACE_OS::getipnodebyname"); +# if defined (ACE_PSOS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (family); + ACE_UNUSED_ARG (flags); + ACE_NOTSUP_RETURN (0); +# elif defined (ACE_HAS_IPV6) +# if defined (__GLIBC__) + ACE_UNUSED_ARG (flags); +# if defined (ACE_HAS_NONCONST_GETBY) + ACE_SOCKCALL_RETURN (::gethostbyname2 (ACE_const_cast (char *, name), + family), + struct hostent *, 0); +# else + ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family), + struct hostent *, 0); +# endif /* ACE_HAS_NONCONST_GETBY */ +# else + struct hostent *hptr; + int errnum; + if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0) + { + errno = errnum; + } + return hptr; +# endif /* __GLIBC__ */ +# else + // IPv4-only implementation + ACE_UNUSED_ARG (flags); + if (family == AF_INET) + return ACE_OS::gethostbyname (name); + + ACE_NOTSUP_RETURN (0); +# endif /* ACE_PSOS */ +} + +#endif /* ! VXWORKS */ + +ACE_INLINE struct protoent * +ACE_OS::getprotobyname (const char *name) +{ +#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) + ACE_UNUSED_ARG (name); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_HAS_NONCONST_GETBY) + ACE_SOCKCALL_RETURN (::getprotobyname (ACE_const_cast (char *, name)), + struct protoent *, + 0); +#else + ACE_SOCKCALL_RETURN (::getprotobyname (name), + struct protoent *, + 0); +#endif /* VXWORKS */ +} + +ACE_INLINE struct protoent * +ACE_OS::getprotobyname_r (const char *name, + struct protoent *result, + ACE_PROTOENT_DATA buffer) +{ +#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) +# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) + if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0) + return result; + else + return 0; +# elif defined (__GLIBC__) + // GNU C library has a different signature + if (::getprotobyname_r (name, + result, + buffer, + sizeof (ACE_PROTOENT_DATA), + &result) == 0) + return result; + else + return 0; +# else +# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + ACE_UNUSED_ARG (result); + ACE_NETDBCALL_RETURN (::getprotobyname (name), + struct protoent *, 0, + buffer, sizeof (ACE_PROTOENT_DATA)); +# else + ACE_SOCKCALL_RETURN (::getprotobyname_r (name, + result, + buffer, + sizeof (ACE_PROTOENT_DATA)), + struct protoent *, 0); +# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ +# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ +#elif defined (ACE_HAS_NONCONST_GETBY) + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_SOCKCALL_RETURN (::getprotobyname (ACE_const_cast (char *, name)), + struct protoent *, 0); +#else + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (result); + + ACE_SOCKCALL_RETURN (::getprotobyname (name), + struct protoent *, + 0); +#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */ +} + +ACE_INLINE struct protoent * +ACE_OS::getprotobynumber (int proto) +{ +#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) + ACE_UNUSED_ARG (proto); + ACE_NOTSUP_RETURN (0); +#else + ACE_SOCKCALL_RETURN (::getprotobynumber (proto), + struct protoent *, 0); +#endif /* VXWORKS */ +} + +ACE_INLINE struct protoent * +ACE_OS::getprotobynumber_r (int proto, + struct protoent *result, + ACE_PROTOENT_DATA buffer) +{ +#if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS) + ACE_UNUSED_ARG (proto); + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buffer); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) +# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) + if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0) + return result; + else + return 0; +# elif defined (__GLIBC__) + // GNU C library has a different signature + if (::getprotobynumber_r (proto, + result, + buffer, + sizeof (ACE_PROTOENT_DATA), + &result) == 0) + return result; + else + return 0; +# else +# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + ACE_UNUSED_ARG (result); + ACE_NETDBCALL_RETURN (::getprotobynumber (proto), + struct protoent *, 0, + buffer, sizeof (ACE_PROTOENT_DATA)); +# else + ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)), + struct protoent *, 0); +# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ +# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ +#else + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (result); + + ACE_SOCKCALL_RETURN (::getprotobynumber (proto), + struct protoent *, 0); +#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ +} + +ACE_INLINE struct servent * +ACE_OS::getservbyname (const char *svc, const char *proto) +{ + ACE_OS_TRACE ("ACE_OS::getservbyname"); +#if defined (ACE_LACKS_GETSERVBYNAME) + ACE_UNUSED_ARG (svc); + ACE_UNUSED_ARG (proto); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_HAS_NONCONST_GETBY) + ACE_SOCKCALL_RETURN (::getservbyname (ACE_const_cast (char *, svc), + ACE_const_cast (char *, proto)), + struct servent *, + 0); +#else + ACE_SOCKCALL_RETURN (::getservbyname (svc, + proto), + struct servent *, + 0); +#endif /* ACE_HAS_NONCONST_GETBY */ +} + +ACE_INLINE struct servent * +ACE_OS::getservbyname_r (const char *svc, + const char *proto, + struct servent *result, + ACE_SERVENT_DATA buf) +{ + ACE_OS_TRACE ("ACE_OS::getservbyname_r"); +#if defined (ACE_LACKS_GETSERVBYNAME) + ACE_UNUSED_ARG (svc); + ACE_UNUSED_ARG (proto); + ACE_UNUSED_ARG (result); + ACE_UNUSED_ARG (buf); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) +# if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10) + ::memset (buf, 0, sizeof (ACE_SERVENT_DATA)); + + if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0) + return result; + else + return (struct servent *) 0; +# elif defined (__GLIBC__) + // GNU C library has a different signature + ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA)); + + if (::getservbyname_r (svc, + proto, + result, + buf, + sizeof (ACE_SERVENT_DATA), + &result) == 0) + return result; + else + return (struct servent *) 0; +# else +# if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + ACE_UNUSED_ARG (result); + ACE_NETDBCALL_RETURN (::getservbyname (svc, proto), + struct servent *, 0, + buf, sizeof (ACE_SERVENT_DATA)); +# else + ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf, + sizeof (ACE_SERVENT_DATA)), + struct servent *, 0); +# endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ +# endif /* defined (AIX) || defined (DIGITAL_UNIX) */ +#elif defined (ACE_HAS_NONCONST_GETBY) + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (result); + ACE_SOCKCALL_RETURN (::getservbyname (ACE_const_cast (char *, svc), + ACE_const_cast (char *, proto)), + struct servent *, + 0); +#else + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (result); + + ACE_SOCKCALL_RETURN (::getservbyname (svc, + proto), + struct servent *, + 0); +#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ +} diff --git a/ace/OS_NS_poll.cpp b/ace/OS_NS_poll.cpp index fc532b41367..c109c2f097e 100644 --- a/ace/OS_NS_poll.cpp +++ b/ace/OS_NS_poll.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_poll.h" + +ACE_RCSID(ace, OS_NS_poll, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_poll.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_poll.h b/ace/OS_NS_poll.h index fc532b41367..629fac2d4fe 100644 --- a/ace/OS_NS_poll.h +++ b/ace/OS_NS_poll.h @@ -1,4 +1,52 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_poll.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_POLL_H +# define ACE_OS_NS_POLL_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/os_poll.h" + +class ACE_Time_Value; + +namespace ACE_OS { + + int poll (struct pollfd *pollfds, + unsigned long len, + const ACE_Time_Value *tv = 0); + int poll (struct pollfd *pollfds, + unsigned long len, + const ACE_Time_Value &tv); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_poll.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_POLL_H */ diff --git a/ace/OS_NS_poll.inl b/ace/OS_NS_poll.inl index fc532b41367..59ce51f1bc9 100644 --- a/ace/OS_NS_poll.inl +++ b/ace/OS_NS_poll.inl @@ -1,4 +1,39 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/Time_Value.h" + +ACE_INLINE int +ACE_OS::poll (struct pollfd *pollfds, + unsigned long len, + const ACE_Time_Value *timeout) +{ + ACE_OS_TRACE ("ACE_OS::poll"); +#if defined (ACE_HAS_POLL) + int to = timeout == 0 ? -1 : int (timeout->msec ()); + ACE_OSCALL_RETURN (::poll (pollfds, len, to), int, -1); +#else + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (pollfds); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_POLL */ +} + +ACE_INLINE int +ACE_OS::poll (struct pollfd *pollfds, + unsigned long len, + const ACE_Time_Value &timeout) +{ + ACE_OS_TRACE ("ACE_OS::poll"); +#if defined (ACE_HAS_POLL) + ACE_OSCALL_RETURN (::poll (pollfds, len, int (timeout.msec ())), int, -1); +#else + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (pollfds); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_POLL */ +} diff --git a/ace/OS_NS_pwd.cpp b/ace/OS_NS_pwd.cpp index fc532b41367..61da06a1e7c 100644 --- a/ace/OS_NS_pwd.cpp +++ b/ace/OS_NS_pwd.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_pwd.h" + +ACE_RCSID(ace, OS_NS_pwd, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_pwd.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_pwd.h b/ace/OS_NS_pwd.h index fc532b41367..b8db10658d5 100644 --- a/ace/OS_NS_pwd.h +++ b/ace/OS_NS_pwd.h @@ -1,4 +1,65 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_pwd.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_PWD_H +# define ACE_OS_NS_PWD_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/os_pwd.h" + +# if defined (ACE_HAS_BROKEN_R_ROUTINES) +# undef getpwnam_r +# endif /* ACE_HAS_BROKEN_R_ROUTINES */ + +struct passwd; + +namespace ACE_OS { + + + //@{ @name A set of wrappers for password routines. + + void endpwent (void); + + struct passwd *getpwent (void); + + struct passwd *getpwnam (const char *user); + + struct passwd *getpwnam_r (const char *name, + struct passwd *pwent, + char *buffer, + int buflen); + void setpwent (void); + //@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_pwd.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_PWD_H */ diff --git a/ace/OS_NS_pwd.inl b/ace/OS_NS_pwd.inl index fc532b41367..b5d10ec914b 100644 --- a/ace/OS_NS_pwd.inl +++ b/ace/OS_NS_pwd.inl @@ -1,4 +1,133 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_errno.h" + +// Accessors to PWD file. + +ACE_INLINE void +ACE_OS::endpwent (void) +{ +#if !defined (ACE_LACKS_PWD_FUNCTIONS) +# if !defined (ACE_WIN32) + ::endpwent (); +# else +# endif /* ACE_WIN32 */ +#else +#endif /* ! ACE_LACKS_PWD_FUNCTIONS */ +} + +ACE_INLINE struct passwd * +ACE_OS::getpwent (void) +{ +#if !defined (ACE_LACKS_PWD_FUNCTIONS) +# if !defined (ACE_WIN32) + return ::getpwent (); +# else + ACE_NOTSUP_RETURN (0); +# endif /* ACE_WIN32 */ +#else + ACE_NOTSUP_RETURN (0); +#endif /* ! ACE_LACKS_PWD_FUNCTIONS */ +} + +ACE_INLINE struct passwd * +ACE_OS::getpwnam (const char *name) +{ +#if !defined (ACE_LACKS_PWD_FUNCTIONS) +# if !defined (ACE_WIN32) + return ::getpwnam (name); +# else + ACE_UNUSED_ARG (name); + ACE_NOTSUP_RETURN (0); +# endif /* ACE_WIN32 */ +#else + ACE_UNUSED_ARG (name); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_LACKS_PWD_FUNCTIONS */ +} + +ACE_INLINE struct passwd * +ACE_OS::getpwnam_r (const char *name, struct passwd *pwent, + char *buffer, int buflen) +{ +#if defined (ACE_HAS_POSIX_GETPWNAM_R) + struct passwd *result; + int status; + + status = ::getpwnam_r (name, pwent, buffer, buflen, &result); + + if (status != 0) + { + errno = status; + result = 0; + } + return result; +#elif !defined (ACE_LACKS_PWD_FUNCTIONS) +# if defined (ACE_HAS_REENTRANT_FUNCTIONS) +# if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS) +# if defined (ACE_HAS_PTHREADS_STD) && \ + !defined (ACE_HAS_STHREADS) || \ + defined (HPUX_11) || \ + defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7. + struct passwd *result; + int status; +# if defined (DIGITAL_UNIX) + ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result); +# else + // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined + // in pwd.h, and that redefinition is used here +# if defined (__IBMCPP__) && (__IBMCPP__ >= 400) /* VAC++ 4 */ + status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result); +# else + status = ::getpwnam_r (name, pwent, buffer, buflen, &result); +# endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */ + if (status != 0) + { + errno = status; + result = 0; + } +# endif /* (DIGITAL_UNIX) */ + return result; +# elif defined (AIX) || defined (HPUX_10) + if (::getpwnam_r (name, pwent, buffer, buflen) == -1) + return 0; + else + return pwent; +# else + return ::getpwnam_r (name, pwent, buffer, buflen); +# endif /* ACE_HAS_PTHREADS_STD */ +# else + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (pwent); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (buflen); + ACE_NOTSUP_RETURN (0); +# endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */ +# else + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (pwent); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (buflen); + ACE_NOTSUP_RETURN (0); +# endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +#else + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (pwent); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (buflen); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_POSIX_GETPWNAM_R */ +} + +ACE_INLINE void +ACE_OS::setpwent (void) +{ +#if !defined (ACE_LACKS_PWD_FUNCTIONS) +# if !defined (ACE_WIN32) + ::setpwent (); +# else +# endif /* ACE_WIN32 */ +#else +#endif /* ! ACE_LACKS_PWD_FUNCTIONS */ +} diff --git a/ace/OS_NS_regex.cpp b/ace/OS_NS_regex.cpp index fc532b41367..88fc9f3beb4 100644 --- a/ace/OS_NS_regex.cpp +++ b/ace/OS_NS_regex.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_regex.h" + +ACE_RCSID(ace, OS_NS_regex, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_regex.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_regex.h b/ace/OS_NS_regex.h index fc532b41367..f49ed62d58f 100644 --- a/ace/OS_NS_regex.h +++ b/ace/OS_NS_regex.h @@ -1,4 +1,50 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_regex.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_REGEX_H +# define ACE_OS_NS_REGEX_H + +# include /**/ "ace/pre.h" + +# include "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace ACE_OS { + + // non=standard.. + //@{ @name A set of wrappers for regular expressions. + char *compile (const char *instring, + char *expbuf, + char *endbuf); + int step (const char *str, + char *expbuf); + //@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_regex.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_REGEX_H */ diff --git a/ace/OS_NS_regex.inl b/ace/OS_NS_regex.inl index fc532b41367..b1f445f0e67 100644 --- a/ace/OS_NS_regex.inl +++ b/ace/OS_NS_regex.inl @@ -1,4 +1,35 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_errno.h" +#include "ace/os_include/os_regex.h" + +ACE_INLINE char * +ACE_OS::compile (const char *instring, char *expbuf, char *endbuf) +{ + ACE_OS_TRACE ("ACE_OS::compile"); +#if defined (ACE_HAS_REGEX) + ACE_OSCALL_RETURN (::compile (instring, expbuf, endbuf), char *, 0); +#else + ACE_UNUSED_ARG (instring); + ACE_UNUSED_ARG (expbuf); + ACE_UNUSED_ARG (endbuf); + + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_REGEX */ +} + +ACE_INLINE int +ACE_OS::step (const char *str, char *expbuf) +{ + ACE_OS_TRACE ("ACE_OS::step"); +#if defined (ACE_HAS_REGEX) + ACE_OSCALL_RETURN (::step (str, expbuf), int, -1); +#else + ACE_UNUSED_ARG (str); + ACE_UNUSED_ARG (expbuf); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_REGEX */ +} + diff --git a/ace/OS_NS_signal.cpp b/ace/OS_NS_signal.cpp index fc532b41367..3dc5e1c56fe 100644 --- a/ace/OS_NS_signal.cpp +++ b/ace/OS_NS_signal.cpp @@ -1,4 +1,24 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_signal.h" + +ACE_RCSID(ace, OS_NS_signal, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_signal.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#if !defined (ACE_HAS_SIGINFO_T) +siginfo_t::siginfo_t (ACE_HANDLE handle) + : si_handle_ (handle), + si_handles_ (&handle) +{ +} + +siginfo_t::siginfo_t (ACE_HANDLE *handles) + : si_handle_ (handles[0]), + si_handles_ (handles) +{ +} +#endif /* ACE_HAS_SIGINFO_T */ diff --git a/ace/OS_NS_signal.h b/ace/OS_NS_signal.h index fc532b41367..d26c02cb9bf 100644 --- a/ace/OS_NS_signal.h +++ b/ace/OS_NS_signal.h @@ -1,4 +1,110 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_signal.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SIGNAL_H +# define ACE_OS_NS_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/os_signal.h" + +# 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 */ + +// Create some useful typedefs. +// @todo: remove, not used dhinton +//typedef const char **SYS_SIGLIST; + +# if !defined (ACE_HAS_SIGINFO_T) +struct ACE_OS_Export siginfo_t +{ + siginfo_t (ACE_HANDLE handle); + siginfo_t (ACE_HANDLE *handles); // JCEJ 12/23/96 + + /// Win32 HANDLE that has become signaled. + ACE_HANDLE si_handle_; + + /// Array of Win32 HANDLEs all of which have become signaled. + ACE_HANDLE *si_handles_; +}; +# endif /* ACE_HAS_SIGINFO_T */ + +namespace ACE_OS { + + //@{ @name A set of wrappers for Signals. + + int kill (pid_t pid, + int signum); + + int pthread_sigmask (int how, + const sigset_t *nsp, + sigset_t *osp); + + int sigaction (int signum, + const struct sigaction *nsa, + struct sigaction *osa); + + int sigaddset (sigset_t *s, + int signum); + + int sigdelset (sigset_t *s, + int signum); + + int sigemptyset (sigset_t *s); + + int sigfillset (sigset_t *s); + + int sigismember (sigset_t *s, + int signum); + + ACE_SignalHandler signal (int signum, + ACE_SignalHandler); + + int sigprocmask (int how, + const sigset_t *nsp, + sigset_t *osp); + + int sigsuspend (const sigset_t *set); + + //@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_signal.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SIGNAL_H */ diff --git a/ace/OS_NS_signal.inl b/ace/OS_NS_signal.inl index fc532b41367..31e116fae9b 100644 --- a/ace/OS_NS_signal.inl +++ b/ace/OS_NS_signal.inl @@ -1,4 +1,271 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_macros.h" +#include "ace/OS_NS_errno.h" + +ACE_INLINE int +ACE_OS::kill (pid_t pid, int signum) +{ + ACE_OS_TRACE ("ACE_OS::kill"); +#if defined (ACE_WIN32) || defined (CHORUS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (pid); + ACE_UNUSED_ARG (signum); + ACE_NOTSUP_RETURN (-1); +#else + ACE_OSCALL_RETURN (::kill (pid, signum), int, -1); +#endif /* ACE_WIN32 || CHORUS || ACE_PSOS */ +} + +ACE_INLINE int +ACE_OS::pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp) +{ +#if defined (ACE_HAS_PTHREADS_STD) && !defined (ACE_LACKS_PTHREAD_SIGMASK) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp), + ace_result_), + int, + -1); +#else /* !ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */ + ACE_UNUSED_ARG (how); + ACE_UNUSED_ARG (nsp); + ACE_UNUSED_ARG (osp); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */ +} + +ACE_INLINE int +ACE_OS::sigaction (int signum, + const struct sigaction *nsa, + struct sigaction *osa) +{ + ACE_OS_TRACE ("ACE_OS::sigaction"); + if (signum == 0) + return 0; +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + struct sigaction sa; + + if (osa == 0) + osa = &sa; + + if (nsa == 0) + { + osa->sa_handler = ::signal (signum, SIG_IGN); + ::signal (signum, osa->sa_handler); + } + else + osa->sa_handler = ::signal (signum, nsa->sa_handler); + return osa->sa_handler == SIG_ERR ? -1 : 0; +#elif defined (CHORUS) || defined (ACE_HAS_WINCE) || defined(ACE_PSOS) + ACE_UNUSED_ARG (signum); + ACE_UNUSED_ARG (nsa); + ACE_UNUSED_ARG (osa); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::sigaction (signum, (struct sigaction*) nsa, osa), int, -1); +#else + ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1); +#endif /* ACE_WIN32 !ACE_HAS_WINCE */ +} + +ACE_INLINE int +ACE_OS::sigaddset (sigset_t *s, int signum) +{ + ACE_OS_TRACE ("ACE_OS::sigaddset"); +#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) + if (s == 0) + { + errno = EFAULT; + return -1; + } + else if (signum < 1 || signum >= ACE_NSIG) + { + errno = EINVAL; + return -1; // Invalid signum, return error + } +# if defined (ACE_PSOS) && defined (__DIAB) && ! defined(ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) + // treat 0th u_long of sigset_t as high bits, + // and 1st u_long of sigset_t as low bits. + if (signum <= ACE_BITS_PER_ULONG) + s->s[1] |= (1 << (signum - 1)); + else + s->s[0] |= (1 << (signum - ACE_BITS_PER_ULONG - 1)); +# else + *s |= (1 << (signum - 1)) ; +# endif /* defined (ACE_PSOS) && defined (__DIAB) */ + return 0 ; +#else + ACE_OSCALL_RETURN (::sigaddset (s, signum), int, -1); +#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ +} + +ACE_INLINE int +ACE_OS::sigdelset (sigset_t *s, int signum) +{ +#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) + if (s == 0) + { + errno = EFAULT; + return -1; + } + else if (signum < 1 || signum >= ACE_NSIG) + { + errno = EINVAL; + return -1; // Invalid signum, return error + } +# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) + // treat 0th u_long of sigset_t as high bits, + // and 1st u_long of sigset_t as low bits. + if (signum <= ACE_BITS_PER_ULONG) + s->s[1] &= ~(1 << (signum - 1)); + else + s->s[0] &= ~(1 << (signum - ACE_BITS_PER_ULONG - 1)); +# else + *s &= ~(1 << (signum - 1)) ; +# endif /* defined (ACE_PSOS) && defined (__DIAB) */ + return 0; +#else + ACE_OSCALL_RETURN (::sigdelset (s, signum), int, -1); +#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ +} + +ACE_INLINE int +ACE_OS::sigemptyset (sigset_t *s) +{ +#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) + if (s == 0) + { + errno = EFAULT; + return -1; + } +# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) + s->s[0] = 0; + s->s[1] = 0; +# else + *s = 0 ; +# endif /* defined (ACE_PSOS) && defined (__DIAB) */ + return 0 ; +#else + ACE_OSCALL_RETURN (::sigemptyset (s), int, -1); +#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ +} + +ACE_INLINE int +ACE_OS::sigfillset (sigset_t *s) +{ +#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) + if (s == 0) + { + errno = EFAULT; + return -1; + } +# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) + s->s[0] = ~(u_long) 0; + s->s[1] = ~(u_long) 0; +# else + *s = ~(sigset_t) 0; +# endif /* defined (ACE_PSOS) && defined (__DIAB) */ + return 0 ; +#else + ACE_OSCALL_RETURN (::sigfillset (s), int, -1); +#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ +} + +ACE_INLINE int +ACE_OS::sigismember (sigset_t *s, int signum) +{ +#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) + if (s == 0) + { + errno = EFAULT; + return -1; + } + else if (signum < 1 || signum >= ACE_NSIG) + { + errno = EINVAL; + return -1; // Invalid signum, return error + } +# if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) + // treat 0th u_long of sigset_t as high bits, + // and 1st u_long of sigset_t as low bits. + if (signum <= ACE_BITS_PER_ULONG) + return ((s->s[1] & (1 << (signum - 1))) != 0); + else + return ((s->s[0] & (1 << (signum - ACE_BITS_PER_ULONG - 1))) != 0); +# else + return ((*s & (1 << (signum - 1))) != 0) ; +# endif /* defined (ACE_PSOS) && defined (__DIAB) */ +#else +# if defined (ACE_HAS_SIGISMEMBER_BUG) + if (signum < 1 || signum >= ACE_NSIG) + { + errno = EINVAL; + return -1; // Invalid signum, return error + } +# endif /* ACE_HAS_SIGISMEMBER_BUG */ + ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1); +#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ +} + +ACE_INLINE ACE_SignalHandler +ACE_OS::signal (int signum, ACE_SignalHandler func) +{ + if (signum == 0) + return 0; + else +#if defined (ACE_PSOS) && !defined (ACE_PSOS_TM) && !defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC) + return (ACE_SignalHandler) ::signal (signum, (void (*)(void)) func); +#elif defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC) + return 0; +#elif defined (ACE_PSOS_TM) + // @@ It would be good to rework this so the ACE_PSOS_TM specific + // branch is not needed, but prying it out of ACE_LACKS_UNIX_SIGNALS + // will take some extra work - deferred for now. + return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func); +#elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) +# if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS_SIGNALS) + return ::signal (signum, func); +# else + return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func); +# endif /* !ACE_HAS_TANDEM_SIGNALS */ +#else + // @@ WINCE: Don't know how to implement signal on WinCE (yet.) + ACE_UNUSED_ARG (signum); + ACE_UNUSED_ARG (func); + ACE_NOTSUP_RETURN (0); // Should return SIG_ERR but it is not defined on WinCE. +#endif /* ACE_PSOS && !ACE_PSOS_TM && !ACE_PSOS_DIAB_MIPS && !ACE_PSOS_DIAB_PPC */ +} + +ACE_INLINE int +ACE_OS::sigprocmask (int how, const sigset_t *nsp, sigset_t *osp) +{ +#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) + ACE_UNUSED_ARG (how); + ACE_UNUSED_ARG (nsp); + ACE_UNUSED_ARG (osp); + ACE_NOTSUP_RETURN (-1); +#else +# if defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::sigprocmask (how, (int*) nsp, osp), int, -1); +# else + ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ +#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */ +} + +ACE_INLINE int +ACE_OS::sigsuspend (const sigset_t *sigset) +{ +#if defined (ACE_HAS_SIGSUSPEND) + sigset_t s; + + if (sigset == 0) + { + sigset = &s; + ACE_OS::sigemptyset (&s); + } + ACE_OSCALL_RETURN (::sigsuspend (sigset), int, -1); +#else + ACE_UNUSED_ARG (sigset); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SIGSUSPEND */ +} diff --git a/ace/OS_NS_stdio.cpp b/ace/OS_NS_stdio.cpp index fc532b41367..2abc599be40 100644 --- a/ace/OS_NS_stdio.cpp +++ b/ace/OS_NS_stdio.cpp @@ -1,4 +1,365 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_stdio.h" + +ACE_RCSID(ace, OS_NS_stdio, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_stdio.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +# if defined (ACE_WIN32) + +OSVERSIONINFO ACE_OS::win32_versioninfo_; +HINSTANCE ACE_OS::win32_resource_module_; + +# if defined (ACE_OS_HAS_DLL) && (ACE_OS_HAS_DLL == 1) && !defined (ACE_HAS_WINCE) +// This function is called by the OS when the ACE DLL is loaded. We +// use it to determine the default module containing ACE's resources. +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID) +{ + if (reason == DLL_PROCESS_ATTACH) + { +# if defined (ACE_DISABLES_THREAD_LIBRARY_CALLS) && (ACE_DISABLES_THREAD_LIBRARY_CALLS == 1) + ::DisableThreadLibraryCalls (instance); +# endif /* ACE_DISABLES_THREAD_LIBRARY_CALLS */ + ACE_OS::set_win32_resource_module(instance); + } + return TRUE; +} +# endif /* ACE_OS_HAS_DLL && ACE_OS_HAS_DLL == 1 */ +# endif /* ACE_WIN32 */ + +void +ACE_OS::ace_flock_t::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_OS_TRACE ("ACE_OS::ace_flock_t::dump"); + +# if 0 + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("handle_ = %u"), this->handle_)); +# if defined (ACE_WIN32) + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nInternal = %d"), + this->overlapped_.Internal)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nInternalHigh = %d"), + this->overlapped_.InternalHigh)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nOffsetHigh = %d"), + this->overlapped_.OffsetHigh)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nhEvent = %d"), + this->overlapped_.hEvent)); +# elif !defined (CHORUS) + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_whence = %d"), + this->lock_.l_whence)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_start = %d"), this->lock_.l_start)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_len = %d"), this->lock_.l_len)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nl_type = %d"), this->lock_.l_type)); +# endif /* ACE_WIN32 */ + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +# endif /* 0 */ +#endif /* ACE_HAS_DUMP */ +} + +/*****************************************************************************/ + +#if defined (ACE_USES_WCHAR) +void ACE_OS::checkUnicodeFormat (FILE* fp) +{ + if (fp != 0) + { + // Due to the ACE_TCHAR definition, all default input files, such as + // svc.conf, have to be in Unicode format (small endian) on WinCE + // because ACE has all 'char' converted into ACE_TCHAR. + // However, for TAO, ASCII files, such as IOR file, can still be read + // and be written without any error since given buffers are all in 'char' + // type instead of ACE_TCHAR. Therefore, it is user's reponsibility to + // select correct buffer type. + + // At this point, check if the file is Unicode or not. + WORD first_two_bytes; + int numRead = ACE_OS::fread(&first_two_bytes, sizeof(WORD), 1, fp); + + if (numRead == 1) + { + if ((first_two_bytes != 0xFFFE) && // not a small endian Unicode file + (first_two_bytes != 0xFEFF)) // not a big endian Unicode file + { + // set file pointer back to the beginning + ACE_OS::fseek(fp, 0, FILE_BEGIN); + } + } + // if it is a Unicode file, file pointer will be right next to the first + // two-bytes + } +} +#endif // ACE_USES_WCHAR + +#if defined (ACE_WIN32) +FILE * +ACE_OS::fopen (const ACE_TCHAR *filename, + const ACE_TCHAR *mode) +{ + ACE_OS_TRACE ("ACE_OS::fopen"); + int hmode = _O_TEXT; + + for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++) + ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode); + + ACE_HANDLE handle = ACE_OS::open (filename, hmode); + if (handle != ACE_INVALID_HANDLE) + { +# if defined (ACE_HAS_WINCE) + FILE *fp = ::_wfdopen (handle, mode); + if (fp != 0) + { + checkUnicodeFormat(fp); + return fp; + } +# else + hmode &= _O_TEXT | _O_RDONLY | _O_APPEND; +# if defined (ACE_WIN64) + int fd = _open_osfhandle (intptr_t (handle), hmode); +# else + int fd = _open_osfhandle (long (handle), hmode); +# endif /* ACE_WIN64 */ + if (fd != -1) + { +# if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR) + FILE *fp = ::_fdopen (fd, ACE_const_cast (char *, mode)); +# elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR) + FILE *fp = ::_wfdopen (fd, ACE_const_cast (wchar_t *, mode)); +# elif defined (ACE_USES_WCHAR) + FILE *fp = ::_wfdopen (fd, mode); +# else + FILE *fp = ::fdopen (fd, mode); +# endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */ + if (fp != 0) + { +# if defined (ACE_USES_WCHAR) + checkUnicodeFormat(fp); +# endif // ACE_USES_WCHAR + return fp; + } + _close (fd); + } +# endif // ACE_HAS_WINCE + + ACE_OS::close (handle); + } + return 0; +} +#endif /* ACE_WIN32 */ + +int +ACE_OS::fprintf (FILE *fp, const char *format, ...) +{ + ACE_OS_TRACE ("ACE_OS::fprintf"); + int result = 0; + va_list ap; + va_start (ap, format); + ACE_OSCALL (::vfprintf (fp, format, ap), int, -1, result); + va_end (ap); + return result; +} + +#if defined (ACE_HAS_WCHAR) +int +ACE_OS::fprintf (FILE *fp, const wchar_t *format, ...) +{ + ACE_OS_TRACE ("ACE_OS::fprintf"); + +# if !defined (ACE_HAS_VFWPRINTF) + ACE_UNUSED_ARG (fp); + ACE_UNUSED_ARG (format); + ACE_NOTSUP_RETURN (-1); + +# else + int result = 0; + va_list ap; + va_start (ap, format); + ACE_OSCALL (::vfwprintf (fp, format, ap), int, -1, result); + va_end (ap); + return result; + +# endif /* ACE_HAS_VFWPRINTF */ +} +#endif /* ACE_HAS_WCHAR */ + +char * +ACE_OS::gets (char *str, int n) +{ + ACE_OS_TRACE ("ACE_OS::gets"); + int c; + char *s = str; + + if (str == 0 || n < 0) n = 0; + if (n == 0) str = 0; + else n--; + + while ((c = getchar ()) != '\n') + { + + if (c == EOF && errno == EINTR) + { +# if defined (ACE_HAS_SIGNAL_SAFE_OS_CALLS) + continue; +# else + break; +# endif /* ACE_HAS_SIGNAL_SAFE_OS_CALLS */ + } + + if (c == EOF) + break; + + if (n > 0) + n--, *s++ = c; + } + if (s) *s = '\0'; + + return (c == EOF) ? 0 : str; +} + +// The following *printf functions aren't inline because +// they use varargs. + +int +ACE_OS::printf (const char *format, ...) +{ + ACE_OS_TRACE ("ACE_OS::printf"); + int result; + va_list ap; + va_start (ap, format); + ACE_OSCALL (::vprintf (format, ap), int, -1, result); + va_end (ap); + return result; +} + +int +ACE_OS::snprintf (char *buf, size_t maxlen, const char *format, ...) +{ + // ACE_OS_TRACE ("ACE_OS::snprintf"); +#if defined (ACE_HAS_SNPRINTF) + int result; + va_list ap; + va_start (ap, format); +# if defined (ACE_WIN32) + ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnprintf (buf, maxlen, format, ap)), + int, -1, result); + // Win32 doesn't 0-terminate the string if it overruns maxlen. + if (result == -1) + buf[maxlen-1] = '\0'; +# else + ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsnprintf (buf, maxlen, format, ap)), + int, -1, result); +# endif /* ACE_WIN32 */ + va_end (ap); + // In out-of-range conditions, C99 defines vsnprintf to return the number + // of characters that would have been written if enough space was available. + // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return + // -1. This method follows the C99 standard, but needs to guess at the + // value; uses maxlen + 1. + if (result == -1) + result = ACE_static_cast (int, (maxlen + 1)); + return result; + +#else + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (maxlen); + ACE_UNUSED_ARG (format); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SNPRINTF */ +} + +#if defined (ACE_HAS_WCHAR) +int +ACE_OS::snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...) +{ + // ACE_OS_TRACE ("ACE_OS::snprintf"); +#if (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) || defined (ACE_WIN32) + int result; + va_list ap; + va_start (ap, format); +# if defined (ACE_WIN32) + // Microsoft's vswprintf() doesn't have the maxlen argument that + // XPG4/UNIX98 define. They do, however, recommend use of _vsnwprintf() + // as a substitute, which does have the same signature as the UNIX98 one. + ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnwprintf (buf, maxlen, format, ap)), + int, -1, result); + // Win32 doesn't 0-terminate the string if it overruns maxlen. + if (result == -1) + buf[maxlen-1] = '\0'; +# else + ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vswprintf (buf, maxlen, format, ap)), + int, -1, result); +# endif /* ACE_WIN32 */ + va_end (ap); + // In out-of-range conditions, C99 defines vsnprintf to return the number + // of characters that would have been written if enough space was available. + // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return + // -1. This method follows the C99 standard, but needs to guess at the + // value; uses maxlen + 1. + if (result == -1) + result = ACE_static_cast (int, (maxlen + 1)); + return result; + +#else + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (maxlen); + ACE_UNUSED_ARG (format); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SNPRINTF */ +} +#endif /* ACE_HAS_WCHAR */ + +int +ACE_OS::sprintf (char *buf, const char *format, ...) +{ + // ACE_OS_TRACE ("ACE_OS::sprintf"); + + int result; + va_list ap; + va_start (ap, format); + ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsprintf (buf, format, ap)), int, -1, result); + va_end (ap); + return result; +} + +#if defined (ACE_HAS_WCHAR) +int +ACE_OS::sprintf (wchar_t *buf, const wchar_t *format, ...) +{ + ACE_OS_TRACE ("ACE_OS::sprintf"); + +# if defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) + + // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a + // maxlen argument. Since this method doesn't supply one, pass in + // the max possible length. If this isn't ok, use ACE_OS::snprintf(). + int result; + va_list ap; + va_start (ap, format); + ACE_OSCALL (::vswprintf (buf, ULONG_MAX, format, ap), int, -1, result); + va_end (ap); + return result; + +# elif defined (ACE_WIN32) + // Windows has vswprintf, but the signature is from the older ISO C + // standard. Also see ACE_OS::snprintf() for more info on this. + + int result; + va_list ap; + va_start (ap, format); + ACE_OSCALL (::vswprintf (buf, format, ap), int, -1, result); + va_end (ap); + return result; + +# else + + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (format); + ACE_NOTSUP_RETURN (-1); + +# endif /* ACE_HAS_VSWPRINTF */ +} +#endif /* ACE_HAS_WCHAR */ diff --git a/ace/OS_NS_stdio.h b/ace/OS_NS_stdio.h index fc532b41367..4471ad73139 100644 --- a/ace/OS_NS_stdio.h +++ b/ace/OS_NS_stdio.h @@ -1,4 +1,326 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_stdio.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_STDIO_H +# define ACE_OS_NS_STDIO_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/os_stdio.h" +#include "ace/os_include/os_fcntl.h" +#include "ace/OS_Export.h" + +/** + * On some platforms clearerr is a macro. Defining ACE_OS::clearerr() + * becomes really hard, as there is no way to save the macro + * definition using the pre-processor. + */ +# if !defined (ACE_LACKS_CLEARERR) +# if defined (clearerr) +# define __ace_clearerr_hack +inline void __ace_clearerr(FILE *stream) +{ + clearerr(stream); +} +# undef clearerr +# endif /* defined (clearerr) */ +# endif /* !ACE_LACKS_CLEARERR */ + +/// Helper for the ACE_OS::cuserid() function +/** + * On some platforms cuserid is a macro. Defining ACE_OS::cuserid() + * becomes really hard, as there is no way to save the macro + * definition using the pre-processor. + * This inline function achieves the same effect, without namespace + * pollution or performance penalties. + * + * @todo We maybe should move a lot of the code in ACE_OS::cuserid here so + * it is treated the same as the above ace_difftime and ace_timezone. + * But since there is a good deal more code in ACE_OS::cuserid, we + * probably need to move some of it off into some sort of emulation + * function. + */ +#if !defined (ACE_LACKS_CUSERID) && !defined(ACE_HAS_ALT_CUSERID) \ + && !defined(ACE_WIN32) && !defined (VXWORKS) +inline char *ace_cuserid(char *user) +{ + return cuserid(user); +} +#endif /* !ACE_LACKS_CUSERID && !ACE_HAS_ALT_CUSERID && ... */ + +# if defined (ACE_LACKS_FILELOCKS) +# if ! defined (VXWORKS) && ! defined (ACE_PSOS) && ! defined (__rtems__) && !defined (INTEGRITY) +// 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 */ + +namespace ACE_OS { + + /** + * @class ace_flock_t + * + * @brief OS file locking structure. + */ + class ACE_OS_Export ace_flock_t + { + public: + /// Dump state of the object. + void dump (void) const; + +# 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 */ + }; + +# if defined (ACE_USES_WCHAR) + // If fp points to the Unicode format file, the file pointer will be moved right next + // to the Unicode header (2 types). Otherwise, file pointer will be at the beginning. + void checkUnicodeFormat (FILE* fp); +# endif // ACE_USES_WCHAR + +# if !defined (ACE_LACKS_CLEARERR) + void clearerr (FILE* fp); +# endif /* !ACE_LACKS_CLEARERR */ + + //@{ @name Wrappers to obtain the current user id + // Legacy as per SUSV3 +# if !defined (ACE_LACKS_CUSERID) +# if defined(cuserid) +# undef cuserid +# endif /* cuserid */ + + char *cuserid (char *user, + size_t maxlen = ACE_MAX_USERID); + +# if defined (ACE_HAS_WCHAR) + wchar_t *cuserid (wchar_t *user, + size_t maxlen = ACE_MAX_USERID); +# endif /* ACE_HAS_WCHAR */ +# endif /* ACE_LACKS_CUSERID */ + //@} + + int fclose (FILE *fp); + +# if defined (fdopen) +# undef fdopen +# endif /* fdopen */ + + FILE *fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode); + + int fflush (FILE *fp); + + int fgetc (FILE* fp); + + int fgetpos (FILE* fp, fpos_t* pos); + + ACE_TCHAR *fgets (ACE_TCHAR *buf, int size, FILE *fp); + + //@{ @name A set of wrappers for file locks. + +# if defined (ACE_WIN32) + void flock_adjust_params (ace_flock_t *lock, + short whence, + off_t &start, + off_t &len); +# endif /* ACE_WIN32 */ + + int flock_init (ace_flock_t *lock, + int flags = 0, + const ACE_TCHAR *name = 0, + mode_t perms = 0); + + int flock_destroy (ace_flock_t *lock, + int unlink_file = 1); + + int flock_rdlock (ace_flock_t *lock, + short whence = 0, + off_t start = 0, + off_t len = 0); + + int flock_tryrdlock (ace_flock_t *lock, + short whence = 0, + off_t start = 0, + off_t len = 0); + + int flock_trywrlock (ace_flock_t *lock, + short whence = 0, + off_t start = 0, + off_t len = 0); + + int flock_unlock (ace_flock_t *lock, + short whence = 0, + off_t start = 0, + off_t len = 0); + + int flock_wrlock (ace_flock_t *lock, + short whence = 0, + off_t start = 0, + off_t len = 0); + + //@} + + FILE *fopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode); + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# if defined (ACE_WIN32) + // = Default Win32 Security Attributes definition. + LPSECURITY_ATTRIBUTES default_win32_security_attributes (LPSECURITY_ATTRIBUTES); + + // = Win32 OS version determination function. + /// Return the win32 OSVERSIONINFO structure. + const OSVERSIONINFO &get_win32_versioninfo (void); + + // = A pair of functions for modifying ACE's Win32 resource usage. + /// Return the handle of the module containing ACE's resources. By + /// default, for a DLL build of ACE this is a handle to the ACE DLL + /// itself, and for a static build it is a handle to the executable. + HINSTANCE get_win32_resource_module (void); + + /// Allow an application to modify which module contains ACE's + /// resources. This is mainly useful for a static build of ACE where + /// the required resources reside somewhere other than the executable. + void set_win32_resource_module (HINSTANCE); + + /// Translate fopen's mode char to open's mode. This helper function + /// is here to avoid maintaining several pieces of identical code. + void fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode); + + extern OSVERSIONINFO win32_versioninfo_; + + extern HINSTANCE win32_resource_module_; + +# endif /* ACE_WIN32 */ +#endif + + int fprintf (FILE *fp, const char *format, ...); + +# if defined (ACE_HAS_WCHAR) + int fprintf (FILE *fp, const wchar_t *format, ...); +# endif /* ACE_HAS_WCHAR */ + + int fputs (const ACE_TCHAR *s, + FILE *stream); + + size_t fread (void *ptr, + size_t size, + size_t nelems, + FILE *fp); + + FILE *freopen (const ACE_TCHAR *filename, + const ACE_TCHAR *mode, + FILE* stream); + + int fseek (FILE *fp, + long offset, + int ptrname); + + int fsetpos (FILE* fp, fpos_t* pos); + + long ftell (FILE* fp); + + size_t fwrite (const void *ptr, + size_t size, + size_t nitems, + FILE *fp); + + // The old gets () which directly maps to the evil, unprotected + // gets () has been deprecated. If you really need gets (), + // consider the following one. + + // A better gets (). + // If n == 0, input is swallowed, but NULL is returned. + // Otherwise, reads up to n-1 bytes (not including the newline), + // then swallows rest up to newline + // then swallows newline + char *gets (char *str, int n = 0); + + void perror (const ACE_TCHAR *s); + + int printf (const char *format, ...); + + int puts (const ACE_TCHAR *s); + + int rename (const ACE_TCHAR *old_name, + const ACE_TCHAR *new_name, + int flags = -1); + + void rewind (FILE *fp); + + int snprintf (char *buf, size_t maxlen, const char *format, ...); + +# if defined (ACE_HAS_WCHAR) + int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...); +# endif /* ACE_HAS_WCHAR */ + + int sprintf (char *buf, const char *format, ...); + +# if defined (ACE_HAS_WCHAR) + int sprintf (wchar_t *buf, const wchar_t *format, ...); +# endif /* ACE_HAS_WCHAR */ + + ACE_TCHAR *tempnam (const ACE_TCHAR *dir = 0, + const ACE_TCHAR *pfx = 0); + + int vsprintf (char *buffer, const char *format, va_list argptr); + +# if defined (ACE_HAS_WCHAR) + int vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr); +# endif /* ACE_HAS_WCHAR */ + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_stdio.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_STDIO_H */ diff --git a/ace/OS_NS_stdio.inl b/ace/OS_NS_stdio.inl index fc532b41367..5c093bcc307 100644 --- a/ace/OS_NS_stdio.inl +++ b/ace/OS_NS_stdio.inl @@ -1,4 +1,958 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_pwd.h" + +#if defined (ACE_HAS_CHARPTR_SPRINTF) +# define ACE_SPRINTF_ADAPTER(X) ACE_OS::strlen (X) +#else +# define ACE_SPRINTF_ADAPTER(X) X +#endif /* ACE_HAS_CHARPTR_SPRINTF */ + + +#if defined (ACE_PSOS) +ACE_INLINE int +isatty (int h) +{ + return ACE_OS::isatty (h); +} +#if defined (fileno) +#undef fileno +#endif /* defined (fileno)*/ +ACE_INLINE ACE_HANDLE +fileno (FILE *fp) +{ + return (ACE_HANDLE) fp; +} +#endif /* defined (ACE_PSOS) */ + +/*****************************************************************************/ + +#if defined (ACE_WIN32) +ACE_INLINE void +ACE_OS::flock_adjust_params (ACE_OS::ace_flock_t *lock, + short whence, + off_t &start, + off_t &len) +{ + switch (whence) + { + case SEEK_SET: + break; + case SEEK_CUR: + start += SetFilePointer (lock->handle_, 0, 0, FILE_CURRENT); + break; + case SEEK_END: + start += ::GetFileSize (lock->handle_, 0); + break; + } + lock->overlapped_.Offset = start; + if (len == 0) + len = ::GetFileSize (lock->handle_, + 0) - start; +} +#endif /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::flock_init (ACE_OS::ace_flock_t *lock, + int flags, + const ACE_TCHAR *name, + mode_t perms) +{ + ACE_OS_TRACE ("ACE_OS::flock_init"); +#if defined (CHORUS) + lock->lockname_ = 0; + // Let's see if it already exists. + lock->handle_ = ACE_OS::shm_open (name, + flags | O_CREAT | O_EXCL, + perms); + if (lock->handle_ == ACE_INVALID_HANDLE) + { + if (errno == EEXIST) + // It's already there, so we'll just open it. + lock->handle_ = ACE_OS::shm_open (name, + flags | O_CREAT, + ACE_DEFAULT_FILE_PERMS); + else + return -1; + } + else + { + // We own this shared memory object! Let's set its size. + if (ACE_OS::ftruncate (lock->handle_, + sizeof (ACE_mutex_t)) == -1) + return -1; + // Note that only the owner can destroy a file lock... + ACE_ALLOCATOR_RETURN (lock->lockname_, + ACE_OS::strdup (name), + -1); + } + if (lock->handle_ == ACE_INVALID_HANDLE) + return -1; + + lock->process_lock_ = + (ACE_mutex_t *) ACE_OS::mmap (0, + sizeof (ACE_mutex_t), + PROT_RDWR, + MAP_SHARED, + lock->handle_, + 0); + if (lock->process_lock_ == MAP_FAILED) + return -1; + + if (lock->lockname_ + // Only initialize it if we're the one who created it. + && ACE_OS::mutex_init (lock->process_lock_, + USYNC_PROCESS, + name, + 0) != 0) + return -1; + return 0; +#else +#if defined (ACE_WIN32) + // Once initialized, these values are never changed. + lock->overlapped_.Internal = 0; + lock->overlapped_.InternalHigh = 0; + lock->overlapped_.OffsetHigh = 0; + lock->overlapped_.hEvent = 0; +#endif /* ACE_WIN32 */ + lock->handle_ = ACE_INVALID_HANDLE; + lock->lockname_ = 0; + + if (name != 0) + { + ACE_OSCALL (ACE_OS::open (name, flags, perms), + ACE_HANDLE, + ACE_INVALID_HANDLE, + lock->handle_); + lock->lockname_ = ACE_OS::strdup (name); + return lock->handle_ == ACE_INVALID_HANDLE ? -1 : 0; + } + else + return 0; +#endif /* CHORUS */ +} + +ACE_INLINE int +ACE_OS::flock_destroy (ACE_OS::ace_flock_t *lock, + int unlink_file) +{ + ACE_OS_TRACE ("ACE_OS::flock_destroy"); + if (lock->handle_ != ACE_INVALID_HANDLE) + { + ACE_OS::flock_unlock (lock); + // Close the handle. + ACE_OS::close (lock->handle_); + lock->handle_ = ACE_INVALID_HANDLE; +#if defined (CHORUS) + // Are we the owner? + if (lock->process_lock_ && lock->lockname_ != 0) + { + // Only destroy the lock if we're the owner + ACE_OS::mutex_destroy (lock->process_lock_); + ACE_OS::munmap (lock->process_lock_, + sizeof (ACE_mutex_t)); + if (unlink_file) + ACE_OS::shm_unlink (lock->lockname_); + ACE_OS::free (ACE_static_cast (void *, + ACE_const_cast (ACE_TCHAR *, + lock->lockname_))); + } + else if (lock->process_lock_) + // Just unmap the memory. + ACE_OS::munmap (lock->process_lock_, + sizeof (ACE_mutex_t)); +#else + if (lock->lockname_ != 0) + { + if (unlink_file) + ACE_OS::unlink (lock->lockname_); + ACE_OS::free (ACE_static_cast (void *, + ACE_const_cast (ACE_TCHAR *, + lock->lockname_))); + } +#endif /* CHORUS */ + lock->lockname_ = 0; + } + return 0; +} + +ACE_INLINE int +ACE_OS::flock_rdlock (ACE_OS::ace_flock_t *lock, + short whence, + off_t start, + off_t len) +{ + ACE_OS_TRACE ("ACE_OS::flock_rdlock"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_OS::flock_adjust_params (lock, whence, start, len); +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, + 0, + 0, + len, + 0, + &lock->overlapped_), + ace_result_), int, -1); +# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_, + lock->overlapped_.Offset, + 0, + len, + 0), + ace_result_), int, -1); +# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ +#elif defined (CHORUS) + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + return ACE_OS::mutex_lock (lock->process_lock_); +#elif defined (ACE_LACKS_FILELOCKS) + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +#else + lock->lock_.l_whence = whence; + lock->lock_.l_start = start; + lock->lock_.l_len = len; + lock->lock_.l_type = F_RDLCK; // set read lock + // block, if no access + ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW, + ACE_reinterpret_cast (long, &lock->lock_)), + int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::flock_tryrdlock (ACE_OS::ace_flock_t *lock, + short whence, + off_t start, + off_t len) +{ + ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) + ACE_OS::flock_adjust_params (lock, whence, start, len); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, + LOCKFILE_FAIL_IMMEDIATELY, + 0, + len, + 0, + &lock->overlapped_), + ace_result_), int, -1); +# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ +#elif defined (CHORUS) + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + return ACE_OS::mutex_trylock (lock->process_lock_); +#elif defined (ACE_LACKS_FILELOCKS) + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +#else + lock->lock_.l_whence = whence; + lock->lock_.l_start = start; + lock->lock_.l_len = len; + lock->lock_.l_type = F_RDLCK; // set read lock + + int result = 0; + // Does not block, if no access, returns -1 and set errno = EBUSY; + ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK, + ACE_reinterpret_cast (long, &lock->lock_)), + int, -1, result); + +# if ! defined (ACE_PSOS) + if (result == -1 && (errno == EACCES || errno == EAGAIN)) + errno = EBUSY; +# endif /* ! defined (ACE_PSOS) */ + + return result; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::flock_trywrlock (ACE_OS::ace_flock_t *lock, + short whence, + off_t start, + off_t len) +{ + ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) + ACE_OS::flock_adjust_params (lock, whence, start, len); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, + LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, + 0, + len, + 0, + &lock->overlapped_), + ace_result_), int, -1); +# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ +#elif defined (CHORUS) + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + return ACE_OS::mutex_trylock (lock->process_lock_); +#elif defined (ACE_LACKS_FILELOCKS) + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +#else + lock->lock_.l_whence = whence; + lock->lock_.l_start = start; + lock->lock_.l_len = len; + lock->lock_.l_type = F_WRLCK; // set write lock + + int result = 0; + // Does not block, if no access, returns -1 and set errno = EBUSY; + ACE_OSCALL (ACE_OS::fcntl (lock->handle_, + F_SETLK, + ACE_reinterpret_cast (long, &lock->lock_)), + int, -1, result); + +# if ! defined (ACE_PSOS) + if (result == -1 && (errno == EACCES || errno == EAGAIN)) + errno = EBUSY; +# endif /* ! defined (ACE_PSOS) */ + + return result; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::flock_unlock (ACE_OS::ace_flock_t *lock, + short whence, + off_t start, + off_t len) +{ + ACE_OS_TRACE ("ACE_OS::flock_unlock"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_OS::flock_adjust_params (lock, whence, start, len); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnlockFile (lock->handle_, + lock->overlapped_.Offset, + 0, + len, + 0), + ace_result_), int, -1); +#elif defined (CHORUS) + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + return ACE_OS::mutex_unlock (lock->process_lock_); +#elif defined (ACE_LACKS_FILELOCKS) + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +#else + lock->lock_.l_whence = whence; + lock->lock_.l_start = start; + lock->lock_.l_len = len; + lock->lock_.l_type = F_UNLCK; // Unlock file. + + // release lock + ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLK, + ACE_reinterpret_cast (long, &lock->lock_)), + int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock, + short whence, + off_t start, + off_t len) +{ + ACE_OS_TRACE ("ACE_OS::flock_wrlock"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_OS::flock_adjust_params (lock, whence, start, len); +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, + LOCKFILE_EXCLUSIVE_LOCK, + 0, + len, + 0, + &lock->overlapped_), + ace_result_), int, -1); +# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_, + lock->overlapped_.Offset, + 0, + len, + 0), + ace_result_), int, -1); +# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ +#elif defined (CHORUS) + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + return ACE_OS::mutex_lock (lock->process_lock_); +#elif defined (ACE_LACKS_FILELOCKS) + ACE_UNUSED_ARG (lock); + ACE_UNUSED_ARG (whence); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +#else + lock->lock_.l_whence = whence; + lock->lock_.l_start = start; + lock->lock_.l_len = len; + lock->lock_.l_type = F_WRLCK; // set write lock + // block, if no access + ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW, + ACE_reinterpret_cast (long, &lock->lock_)), + int, -1); +#endif /* ACE_WIN32 */ +} + +#if defined (ACE_WIN32) +ACE_INLINE void +ACE_OS::fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode) +{ + switch (x) + { + case ACE_LIB_TEXT ('r'): + if (ACE_BIT_DISABLED (hmode, _O_RDWR)) + { + ACE_CLR_BITS (hmode, _O_WRONLY); + ACE_SET_BITS (hmode, _O_RDONLY); + } + break; + case ACE_LIB_TEXT ('w'): + if (ACE_BIT_DISABLED (hmode, _O_RDWR)) + { + ACE_CLR_BITS (hmode, _O_RDONLY); + ACE_SET_BITS (hmode, _O_WRONLY); + } + ACE_SET_BITS (hmode, _O_CREAT | _O_TRUNC); + break; + case ACE_LIB_TEXT ('a'): + if (ACE_BIT_DISABLED (hmode, _O_RDWR)) + { + ACE_CLR_BITS (hmode, _O_RDONLY); + ACE_SET_BITS (hmode, _O_WRONLY); + } + ACE_SET_BITS (hmode, _O_CREAT | _O_APPEND); + break; + case ACE_LIB_TEXT ('+'): + ACE_CLR_BITS (hmode, _O_RDONLY | _O_WRONLY); + ACE_SET_BITS (hmode, _O_RDWR); + break; + case ACE_LIB_TEXT ('t'): + ACE_CLR_BITS (hmode, _O_BINARY); + ACE_SET_BITS (hmode, _O_TEXT); + break; + case ACE_LIB_TEXT ('b'): + ACE_CLR_BITS (hmode, _O_TEXT); + ACE_SET_BITS (hmode, _O_BINARY); + break; + } +} +#endif /* ACE_WIN32 */ + +#if !defined (ACE_LACKS_CLEARERR) +ACE_INLINE void +ACE_OS::clearerr (FILE* fp) +{ +#if defined (__ace_clearerr_hack) + __ace_clearerr(fp); +#else + ::clearerr(fp); +#endif /* __ace_clearerr_hack */ +} +#endif /* !ACE_LACKS_CLEARERR */ + +#if !defined (ACE_LACKS_CUSERID) +ACE_INLINE char * +ACE_OS::cuserid (char *user, size_t maxlen) +{ + ACE_OS_TRACE ("ACE_OS::cuserid"); +#if defined (VXWORKS) + ACE_UNUSED_ARG (maxlen); + if (user == 0) + { + // Require that the user field be non-null, i.e., don't + // allocate or use static storage. + ACE_NOTSUP_RETURN (0); + } + else + { + ::remCurIdGet (user, 0); + return user; + } +#elif defined (CHORUS) || defined (ACE_PSOS) || defined (__QNXNTO__) + ACE_UNUSED_ARG (user); + ACE_UNUSED_ARG (maxlen); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_WIN32) + BOOL result = GetUserNameA (user, (u_long *) &maxlen); + if (result == FALSE) + ACE_FAIL_RETURN (0); + else + return user; +#elif defined (ACE_HAS_ALT_CUSERID) +# if defined (ACE_LACKS_PWD_FUNCTIONS) +# error Cannot use alternate cuserid() without POSIX password functions! +# endif /* ACE_LACKS_PWD_FUNCTIONS */ + + // POSIX.1 dropped the cuserid() function. + // GNU GLIBC and other platforms correctly deprecate the cuserid() + // function. + + if (maxlen == 0) + { + // It doesn't make sense to have a zero length user ID. + errno = EINVAL; + return 0; + } + + struct passwd *pw = 0; + + // Make sure the file pointer is at the beginning of the password file + ::setpwent (); + // Should use ACE_OS::setpwent() but I didn't want to move this + // method after it. + + // Use the effective user ID to determine the user name. + pw = ::getpwuid (::geteuid ()); + + // Make sure the password file is closed. + ::endpwent (); + + size_t max_length = 0; + char *userid = 0; + + if (user == 0) + { + // Not reentrant/thread-safe, but nothing else can be done if a + // zero pointer was passed in as the destination. + +#if defined (_POSIX_SOURCE) + const size_t ACE_L_cuserid = L_cuserid; +#else + const size_t ACE_L_cuserid = 9; // 8 character user ID + NULL +#endif /* _POSIX_SOURCE */ + + static ACE_TCHAR tmp[ACE_L_cuserid] = { '\0' }; + max_length = ACE_L_cuserid - 1; // Do not include NULL in length + + userid = tmp; + } + else + { + max_length = maxlen; + userid = user; + } + + // Extract the user name from the passwd structure. + if (ACE_OS::strlen (pw->pw_name) <= max_length) + { + return ACE_OS::strcpy (userid, pw->pw_name); + } + else + { + errno = ENOSPC; // Buffer is not large enough. + return 0; + } +#else + // Hackish because of missing buffer size! + ACE_UNUSED_ARG (maxlen); + ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0); +#endif /* VXWORKS */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::cuserid (wchar_t *user, size_t maxlen) +{ +# if defined (ACE_WIN32) + BOOL result = GetUserNameW (user, (u_long *) &maxlen); + if (result == FALSE) + ACE_FAIL_RETURN (0); + else + return user; +# else /* ACE_WIN32 */ + char *char_user; + wchar_t *result = 0; + + ACE_NEW_RETURN (char_user, char[maxlen + 1], 0); + + if (ACE_OS::cuserid (char_user, maxlen)) + { + ACE_OS::strcpy (user, ACE_Ascii_To_Wide (char_user).wchar_rep ()); + result = user; + } + + delete [] char_user; + + return result; +# endif /* ACE_WIN32 */ +} +#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_LACKS_CUSERID */ + +ACE_INLINE int +ACE_OS::fclose (FILE *fp) +{ + ACE_OS_TRACE ("ACE_OS::fclose"); + ACE_OSCALL_RETURN (::fclose (fp), int, -1); +} + +ACE_INLINE FILE * +ACE_OS::fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode) +{ + ACE_OS_TRACE ("ACE_OS::fdopen"); +# if defined (ACE_HAS_WINCE) + ACE_OSCALL_RETURN (::_wfdopen (handle, mode), FILE*, 0); +# elif defined (ACE_WIN32) + // kernel file handle -> FILE* conversion... + // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost + + FILE *file = 0; + +# if defined (ACE_WIN64) + int crt_handle = ::_open_osfhandle (intptr_t (handle), 0); +# else + int crt_handle = ::_open_osfhandle (long (handle), 0); +# endif /* ACE_WIN64 */ + + if (crt_handle != -1) + { +# if defined(__BORLANDC__) /* VSB */ + file = ::_fdopen (crt_handle, (char *) mode); +# elif defined (ACE_USES_WCHAR) + file = ::_wfdopen (crt_handle, mode); +# else + file = ::_fdopen (crt_handle, mode); +# endif /* __BORLANDC__ */ + + if (!file) + { +# if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) + ::_rtl_close (crt_handle); +# else + ::_close (crt_handle); +# endif /* (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) */ + } + } + + return file; +# elif defined (ACE_PSOS) + // @@ it may be possible to implement this for pSOS, + // but it isn't obvious how to do this (perhaps via + // f_stat to glean the default volume, and then open_fn ?) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (mode); + ACE_NOTSUP_RETURN (0); +# else + ACE_OSCALL_RETURN (::fdopen (handle, mode), FILE *, 0); +# endif /* ACE_HAS_WINCE */ +} + +ACE_INLINE int +ACE_OS::fflush (FILE *fp) +{ + ACE_OS_TRACE ("ACE_OS::fflush"); +#if defined (VXWORKS) + if (fp == 0) + { + // Do not allow fflush(0) on VxWorks + return 0; + } +#endif /* VXWORKS */ + + ACE_OSCALL_RETURN (::fflush (fp), int, -1); +} + +ACE_INLINE int +ACE_OS::fgetc (FILE* fp) +{ + ACE_OSCALL_RETURN (::fgetc (fp), int, -1); +} + +ACE_INLINE int +ACE_OS::fgetpos (FILE* fp, fpos_t* pos) +{ + ACE_OSCALL_RETURN (::fgetpos (fp, pos), int, -1); +} + +ACE_INLINE ACE_TCHAR * +ACE_OS::fgets (ACE_TCHAR *buf, int size, FILE *fp) +{ + ACE_OS_TRACE ("ACE_OS::fgets"); +#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::fgetws (buf, size, fp), wchar_t *, 0); +#else /* ACE_WIN32 */ + ACE_OSCALL_RETURN (::fgets (buf, size, fp), char *, 0); +#endif /* ACE_WIN32 && ACE_USES_WCHAR */ +} + +#if !defined (ACE_WIN32) +// Win32 implementation of fopen(const ACE_TCHAR*, const ACE_TCHAR*) +// is in OS.cpp. +ACE_INLINE FILE * +ACE_OS::fopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode) +{ + ACE_OS_TRACE ("ACE_OS::fopen"); + ACE_OSCALL_RETURN (::fopen (filename, mode), FILE *, 0); +} +#endif /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::fputs (const ACE_TCHAR *s, FILE *stream) +{ + ACE_OS_TRACE ("ACE_OS::fputs"); +#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::fputws (s, stream), int, -1); +#else /* ACE_WIN32 */ + ACE_OSCALL_RETURN (::fputs (s, stream), int, -1); +#endif /* ACE_WIN32 && ACE_USES_WCHAR */ +} + +ACE_INLINE size_t +ACE_OS::fread (void *ptr, size_t size, size_t nelems, FILE *fp) +{ + ACE_OS_TRACE ("ACE_OS::fread"); +#if defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::fread ((char *) ptr, size, nelems, fp), int, 0); +#else + ACE_OSCALL_RETURN (::fread (ptr, size, nelems, fp), int, 0); +#endif /* ACE_LACKS_POSIX_PROTOTYPES */ +} + +ACE_INLINE FILE * +ACE_OS::freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream) +{ + ACE_OS_TRACE ("ACE_OS::freopen"); +#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wfreopen (filename, mode, stream), FILE *, 0); +#else + ACE_OSCALL_RETURN (::freopen (filename, mode, stream), FILE *, 0); +#endif /* ACE_WIN32 && ACE_USES_WCHAR */ +} + +ACE_INLINE int +ACE_OS::fseek (FILE *fp, long offset, int whence) +{ +# if defined (ACE_WIN32) +# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END + //#error Windows NT is evil AND rude! + switch (whence) + { + case SEEK_SET: + whence = FILE_BEGIN; + break; + case SEEK_CUR: + whence = FILE_CURRENT; + break; + case SEEK_END: + whence = FILE_END; + break; + default: + errno = EINVAL; + return -1; // rather safe than sorry + } +# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ +# endif /* ACE_WIN32 */ + ACE_OSCALL_RETURN (::fseek (fp, offset, whence), int, -1); +} + +ACE_INLINE int +ACE_OS::fsetpos (FILE* fp, fpos_t* pos) +{ + ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1); +} + +ACE_INLINE long +ACE_OS::ftell (FILE* fp) +{ + ACE_OSCALL_RETURN (::ftell (fp), long, -1); +} + +ACE_INLINE size_t +ACE_OS::fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp) +{ + ACE_OS_TRACE ("ACE_OS::fwrite"); +#if defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::fwrite ((const char *) ptr, size, nitems, fp), int, 0); +#else + ACE_OSCALL_RETURN (::fwrite (ptr, size, nitems, fp), int, 0); +#endif /* ACE_LACKS_POSIX_PROTOTYPES */ +} + +#if 0 +// @@ gets is evil anyway. +// and it is *** DEPRECATED *** now. If you +// really needs gets, use ACE_OS::gets (char*, int) +// instead. +ACE_INLINE char * +ACE_OS::gets (char *str) +{ + ACE_OS_TRACE ("ACE_OS::gets"); + ACE_OSCALL_RETURN (::gets (str), char *, 0); +} +#endif /* 0 */ + +ACE_INLINE void +ACE_OS::perror (const ACE_TCHAR *s) +{ + ACE_OS_TRACE ("ACE_OS::perror"); +#if defined (ACE_HAS_WINCE) + // @@ WINCE: How should this be handled + ACE_UNUSED_ARG (s); +#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ::_wperror (s); +#else + ::perror (s); +#endif /* ACE_HAS_WINCE */ +} + +ACE_INLINE int +ACE_OS::puts (const ACE_TCHAR *s) +{ + ACE_OS_TRACE ("ACE_OS::puts"); +#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_putws (s), int, -1); +#else /* ACE_WIN32 */ + ACE_OSCALL_RETURN (::puts (s), int, -1); +#endif /* ACE_WIN32 && ACE_USES_WCHAR */ +} + +ACE_INLINE int +ACE_OS::rename (const ACE_TCHAR *old_name, + const ACE_TCHAR *new_name, + int flags) +{ +# if defined (ACE_LACKS_RENAME) + ACE_UNUSED_ARG (old_name); + ACE_UNUSED_ARG (new_name); + ACE_UNUSED_ARG (flags); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_WINCE) + ACE_UNUSED_ARG (flags); + if (MoveFile (old_name, new_name) != 0) + ACE_FAIL_RETURN (-1); + return 0; +# elif defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1) + // NT4 (and up) provides a way to rename/move a file with similar semantics + // to what's usually done on UNIX - if there's an existing file with + // <new_name> it is removed before the file is renamed/moved. The + // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives. + if (flags == -1) + flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING; + if (ACE_TEXT_MoveFileEx(old_name, new_name, flags) == 0) + ACE_FAIL_RETURN (-1); + return 0; +# elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_UNUSED_ARG (flags); + ACE_OSCALL_RETURN (::_wrename (old_name, new_name), int, -1); +# else /* ACE_LACKS_RENAME */ + ACE_UNUSED_ARG (flags); + ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1); +# endif /* ACE_LACKS_RENAME */ +} + +ACE_INLINE void +ACE_OS::rewind (FILE *fp) +{ +#if !defined (ACE_HAS_WINCE) + ACE_OS_TRACE ("ACE_OS::rewind"); + ::rewind (fp); +#else + // In WinCE, "FILE *" is actually a HANDLE. + ::SetFilePointer (fp, 0L, 0L, FILE_BEGIN); +#endif /* ACE_HAS_WINCE */ +} + +ACE_INLINE ACE_TCHAR * +ACE_OS::tempnam (const ACE_TCHAR *dir, const ACE_TCHAR *pfx) +{ + ACE_OS_TRACE ("ACE_OS::tempnam"); +#if defined (ACE_HAS_WINCE) || defined (ACE_LACKS_TEMPNAM) + ACE_UNUSED_ARG (dir); + ACE_UNUSED_ARG (pfx); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_PSOS) + // pSOS only considers the directory prefix + ACE_UNUSED_ARG (pfx); + ACE_OSCALL_RETURN (::tmpnam ((char *) dir), char *, 0); +#elif (defined (ACE_WIN32) && ((defined (__BORLANDC__) && !defined(ACE_USES_WCHAR)) || defined (__IBMCPP__))) + ACE_OSCALL_RETURN (::_tempnam ((char *) dir, (char *) pfx), char *, 0); +#elif defined(ACE_WIN32) && defined (__BORLANDC__) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wtempnam ((wchar_t*) dir, (wchar_t*) pfx), wchar_t *, 0); +#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wtempnam (dir, pfx), wchar_t *, 0); +#else /* ACE_HAS_WINCE || ACE_LACKS_TEMPNAM */ + ACE_OSCALL_RETURN (::tempnam (dir, pfx), char *, 0); +#endif /* VXWORKS */ +} + +ACE_INLINE int +ACE_OS::vsprintf (char *buffer, const char *format, va_list argptr) +{ + return ACE_SPRINTF_ADAPTER (::vsprintf (buffer, format, argptr)); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr) +{ +# if defined (ACE_HAS_VSWPRINTF) + return ::vswprintf (buffer, format, argptr); + +# else + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (format); + ACE_UNUSED_ARG (argptr); + ACE_NOTSUP_RETURN (-1); + +# endif /* ACE_HAS_VSWPRINTF */ +} +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#if defined (ACE_WIN32) +ACE_INLINE const OSVERSIONINFO & +ACE_OS::get_win32_versioninfo () +{ + return ACE_OS::win32_versioninfo_; +} + +ACE_INLINE HINSTANCE +ACE_OS::get_win32_resource_module () +{ + return ACE_OS::win32_resource_module_; +} + +ACE_INLINE void +ACE_OS::set_win32_resource_module (HINSTANCE instance) +{ + ACE_OS::win32_resource_module_ = instance; +} +#endif /* ACE_WIN32 */ +#endif diff --git a/ace/OS_NS_stdlib.cpp b/ace/OS_NS_stdlib.cpp index fc532b41367..339c277a693 100644 --- a/ace/OS_NS_stdlib.cpp +++ b/ace/OS_NS_stdlib.cpp @@ -1,4 +1,402 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_stdlib.h" + +ACE_RCSID(ace, OS_NS_stdlib, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_stdlib.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/OS_Memory.h" + +ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0; + +void * +ACE_OS::calloc (size_t elements, size_t sizeof_elements) +{ +#if !defined (ACE_HAS_WINCE) + return ACE_CALLOC_FUNC (elements, sizeof_elements); +#else + // @@ This will probably not work since it doesn't consider + // alignment properly. + return ACE_MALLOC_FUNC (elements * sizeof_elements); +#endif /* ACE_HAS_WINCE */ +} + +void +ACE_OS::exit (int status) +{ + ACE_OS_TRACE ("ACE_OS::exit"); + +#if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) + // Shut down the ACE_Object_Manager, if it had registered its exit_hook. + // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is + // instantiated on the main's stack. ::exit () doesn't destroy it. + if (exit_hook_) + (*exit_hook_) (); +#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ + +#if !defined (ACE_HAS_WINCE) +# if defined (ACE_WIN32) + ::ExitProcess ((UINT) status); +# elif defined (ACE_PSOSIM) + ::u_exit (status); +# else + ::exit (status); +# endif /* ACE_WIN32 */ +#else + // @@ This is not exactly the same as ExitProcess. But this is the + // closest one I can get. + ::TerminateProcess (::GetCurrentProcess (), status); +#endif /* ACE_HAS_WINCE */ +} + +void +ACE_OS::free (void *ptr) +{ + ACE_FREE_FUNC (ACE_MALLOC_T (ptr)); +} + +// You may be asking yourself, why are we doing this? Well, in winbase.h, +// MS didn't follow their normal Api_FunctionA and Api_FunctionW style, +// so we have to #undef their define to get access to the unicode version. +// And because we don't want to #undef this for the users code, we keep +// this method in the .cpp file. +#if defined (ACE_WIN32) && defined (UNICODE) && !defined (ACE_USES_TCHAR) +#undef GetEnvironmentStrings +#endif /* ACE_WIN32 && UNICODE !ACE_USES_TCHAR */ + +ACE_TCHAR * +ACE_OS::getenvstrings (void) +{ +#if defined (ACE_LACKS_ENV) + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_WIN32) +# if defined (ACE_USES_WCHAR) + return ::GetEnvironmentStringsW (); +# else /* ACE_USES_WCHAR */ + return ::GetEnvironmentStrings (); +# endif /* ACE_USES_WCHAR */ +#else /* ACE_WIN32 */ + ACE_NOTSUP_RETURN (0); +#endif /* ACE_WIN32 */ +} + +#if !defined (ACE_HAS_ITOA) +char * +ACE_OS::itoa_emulation (int value, char *string, int radix) +{ + char *e = string; + char *b = string; + + // Short circuit if 0 + + if (value == 0) + { + string[0] = '0'; + string[1] = 0; + return string; + } + + // If negative and base 10, print a - and then do the + // number. + + if (value < 0 && radix == 10) + { + string[0] = '-'; + ++b; + ++e; // Don't overwrite the negative sign. + value = -value; // Drop negative sign so character selection is correct. + } + + // Convert to base <radix>, but in reverse order + + while (value != 0) + { + int mod = value % radix; + value = value / radix; + + *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10; + } + + *e-- = 0; + + // Now reverse the string to get the correct result + + while (e > b) + { + char temp = *e; + *e = *b; + *b = temp; + ++b; + --e; + } + + return string; +} +#endif /* !ACE_HAS_ITOA */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW) +wchar_t * +ACE_OS::itow_emulation (int value, wchar_t *string, int radix) +{ + wchar_t *e = string; + wchar_t *b = string; + + // Short circuit if 0 + + if (value == 0) + { + string[0] = '0'; + string[1] = 0; + return string; + } + + // If negative and base 10, print a - and then do the + // number. + + if (value < 0 && radix == 10) + { + string[0] = '-'; + b++; + } + + // Convert to base <radix>, but in reverse order + + while (value != 0) + { + int mod = value % radix; + value = value / radix; + + *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10; + } + + *e-- = 0; + + // Now reverse the string to get the correct result + + while (e > b) + { + wchar_t temp = *e; + *e = *b; + *b = temp; + ++b; + --e; + } + + return string; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */ + +void * +ACE_OS::malloc (size_t nbytes) +{ + return ACE_MALLOC_FUNC (nbytes); +} + +#if defined (ACE_LACKS_MKTEMP) +ACE_TCHAR * +ACE_OS::mktemp (ACE_TCHAR *s) +{ + ACE_OS_TRACE ("ACE_OS::mktemp"); + if (s == 0) + // check for null template string failed! + return 0; + else + { + ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_LIB_TEXT ("XXXXXX")); + + if (xxxxxx == 0) + // the template string doesn't contain "XXXXXX"! + return s; + else + { + ACE_TCHAR unique_letter = ACE_LIB_TEXT ('a'); + ACE_stat sb; + + // Find an unused filename for this process. It is assumed + // that the user will open the file immediately after + // getting this filename back (so, yes, there is a race + // condition if multiple threads in a process use the same + // template). This appears to match the behavior of the + // SunOS 5.5 mktemp(). + ACE_OS::sprintf (xxxxxx, + ACE_LIB_TEXT ("%05d%c"), + ACE_OS::getpid (), + unique_letter); + while (ACE_OS::stat (s, &sb) >= 0) + { + if (++unique_letter <= ACE_LIB_TEXT ('z')) + ACE_OS::sprintf (xxxxxx, + ACE_LIB_TEXT ("%05d%c"), + ACE_OS::getpid (), + unique_letter); + else + { + // maximum of 26 unique files per template, per process + ACE_OS::sprintf (xxxxxx, ACE_LIB_TEXT ("%s"), ACE_LIB_TEXT ("")); + return s; + } + } + } + return s; + } +} +#endif /* ACE_LACKS_MKTEMP */ + +void * +ACE_OS::realloc (void *ptr, size_t nbytes) +{ + return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes); +} + +#if defined (ACE_LACKS_STRTOL) +long +ACE_OS::strtol_emulation (const char *nptr, char **endptr, int base) +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (char *)s - 1 : (char *)nptr; + return (acc); +} +#endif /* ACE_LACKS_STRTOL */ + +#if defined (ACE_LACKS_STRTOUL) +unsigned long +ACE_OS::strtoul_emulation (const char *nptr, + char **endptr, + register int base) +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do + c = *s++; + while (isspace(c)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long) ULONG_MAX / (unsigned long) base; + cutlim = (unsigned long) ULONG_MAX % (unsigned long) base; + + for (acc = 0, any = 0;; c = *s++) + { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else + { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? (char *) s - 1 : (char *) nptr; + return (acc); +} +#endif /* ACE_LACKS_STRTOUL */ + diff --git a/ace/OS_NS_stdlib.h b/ace/OS_NS_stdlib.h index fc532b41367..6ebc1d75c99 100644 --- a/ace/OS_NS_stdlib.h +++ b/ace/OS_NS_stdlib.h @@ -1,4 +1,193 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_stdlib.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_STDLIB_H +# define ACE_OS_NS_STDLIB_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/os_stdlib.h" + +# if defined (ACE_HAS_BROKEN_R_ROUTINES) +# undef rand_r +# endif /* ACE_HAS_BROKEN_R_ROUTINES */ + +// We need this for MVS... as well as Linux, etc... +extern "C" { + typedef int (*ACE_COMPARE_FUNC)(const void *, const void *); +} + +namespace ACE_OS { + + /** @name Non-standard functions + * + * These functions aren't in the standard. + * + */ + //@{ + + + void _exit (int status = 0); + + void abort (void); + + int atexit (ACE_EXIT_HOOK func); + + int atoi (const char *s); + +# if defined (ACE_HAS_WCHAR) + int atoi (const wchar_t *s); +# endif /* ACE_HAS_WCHAR */ + + // atop not in spec +# if defined (atop) +# undef atop +# endif /* atop */ + + void *atop (const char *s); + +# if defined (ACE_HAS_WCHAR) + void *atop (const wchar_t *s); +# endif /* ACE_HAS_WCHAR */ + + void *bsearch (const void *key, + const void *base, + size_t nel, + size_t size, + ACE_COMPARE_FUNC); + + void *calloc (size_t elements, size_t sizeof_elements); + + void exit (int status = 0); + + void free (void *); + + char *getenv (const char *symbol); + +# if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32) + wchar_t *getenv (const wchar_t *symbol); +# endif /* ACE_HAS_WCHAR && ACE_WIN32 */ + + // not in spec + ACE_TCHAR *getenvstrings (void); + + // itoa not in spec + /// Converts an integer to a string. + char *itoa (int value, char *string, int radix); + +#if defined (ACE_HAS_WCHAR) + /// Converts an integer to a string. + wchar_t *itoa (int value, wchar_t *string, int radix); +#endif /* ACE_HAS_WCHAR */ + +#if !defined (ACE_HAS_ITOA) + /// Emulated itoa - Converts an integer to a string. + char *itoa_emulation (int value, char *string, int radix); +#endif /* !ACE_HAS_ITOA */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW) + /// Emulated itow - Converts an integer to a string. + wchar_t *itow_emulation (int value, wchar_t *string, int radix); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */ + + void *malloc (size_t); + + ACE_HANDLE mkstemp (ACE_TCHAR *t); + + ACE_TCHAR *mktemp (ACE_TCHAR *t); + + int putenv (const ACE_TCHAR *string); + + void qsort (void *base, + size_t nel, + size_t width, + ACE_COMPARE_FUNC); + + int rand (void); + + int rand_r (ACE_RANDR_TYPE &seed); + + void *realloc (void *, size_t); + + // exit_hook and set_exit_hook not in spec + /// Function that is called by <ACE_OS::exit>, if non-null. + extern ACE_EXIT_HOOK exit_hook_; + + /// For use by ACE_Object_Manager only, to register its exit hook.. + ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook); + + void srand (u_int seed); + + // not in spec + ACE_TCHAR *strenvdup (const ACE_TCHAR *str); + +#if !defined (ACE_LACKS_STRTOD) + /// Converts a string to a double value (char version). + double strtod (const char *s, char **endptr); +#endif /* !ACE_LACKS_STRTOD */ + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD) + /// Converts a string to a double value (wchar_t version). + double strtod (const wchar_t *s, wchar_t **endptr); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */ + + /// Converts a string to a long value (char version). + long strtol (const char *s, char **ptr, int base); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL) + /// Converts a string to a long value (wchar_t version). + long strtol (const wchar_t *s, wchar_t **ptr, int base); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */ + +#if defined (ACE_LACKS_STRTOL) + long strtol_emulation (const char *nptr, char **endptr, int base); +#endif /* ACE_LACKS_STRTOL */ + + /// Converts a string to an unsigned long value (char version). + unsigned long strtoul (const char *s, char **ptr, int base); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL) + /// Converts a string to an unsigned long value (wchar_t version). + unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */ + +#if defined (ACE_LACKS_STRTOUL) + unsigned long strtoul_emulation (const char *nptr, + char **endptr, + int base); +#endif /* ACE_LACKS_STRTOUL */ + + int system (const ACE_TCHAR *s); + + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_stdlib.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_STDLIB_H */ diff --git a/ace/OS_NS_stdlib.inl b/ace/OS_NS_stdlib.inl index fc532b41367..816f6c39290 100644 --- a/ace/OS_NS_stdlib.inl +++ b/ace/OS_NS_stdlib.inl @@ -1,4 +1,397 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/Object_Manager_Base.h" +#include "ace/OS_NS_string.h" +#include "ace/Global_Macros.h" + +// Doesn't need a macro since it *never* returns! + +ACE_INLINE void +ACE_OS::_exit (int status) +{ + ACE_OS_TRACE ("ACE_OS::_exit"); +#if defined (VXWORKS) + ::exit (status); +#elif defined (ACE_PSOSIM) + ::u_exit (status); +#elif defined (ACE_PSOS) +# if defined (ACE_PSOS_LACKS_PREPC) /* pSoS TM does not support exit. */ + ACE_UNUSED_ARG (status); + return; +# else + ::exit (status); +# endif /* defined (ACE_PSOS_LACKS_PREPC) */ +#elif !defined (ACE_HAS_WINCE) + ::_exit (status); +#else + ::TerminateProcess (::GetCurrentProcess (), + status); +#endif /* VXWORKS */ +} + +ACE_INLINE void +ACE_OS::abort (void) +{ +#if !defined (ACE_HAS_WINCE) + ::abort (); +#else + // @@ CE doesn't support abort? + exit (1); +#endif /* !ACE_HAS_WINCE */ +} + +ACE_INLINE int +ACE_OS::atexit (ACE_EXIT_HOOK func) +{ + return ACE_OS_Object_Manager::instance ()->at_exit (func); +} + +ACE_INLINE int +ACE_OS::atoi (const char *s) +{ + ACE_OSCALL_RETURN (::atoi (s), int, -1); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::atoi (const wchar_t *s) +{ +#if defined (ACE_WIN32) + ACE_OSCALL_RETURN (::_wtoi (s), int, -1); +#else /* ACE_WIN32 */ + return ACE_OS::atoi (ACE_Wide_To_Ascii(s).char_rep()); +#endif /* ACE_WIN32 */ +} +#endif /* ACE_HAS_WCHAR */ + +#if defined (atop) +# undef atop +#endif /* atop */ + +ACE_INLINE void * +ACE_OS::atop (const char *s) +{ + ACE_TRACE ("ACE_OS::atop"); + // It would be nice to make use of Basic_Types.h here, but that + // file relies on OS.h. Fortunately, most platforms have int + // the same as pointer size (IA32, IA64), with Win64 being the + // exception. +#if defined (ACE_WIN64) + __int64 ip = ::_atoi64 (s); +#else + int ip = ::atoi (s); +#endif /* ACE_WIN64 */ + void *p = ACE_reinterpret_cast (void *, ip); + return p; +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE void * +ACE_OS::atop (const wchar_t *s) +{ +# if defined (ACE_WIN64) + __int64 ip = ::_wtoi64 (s); +# else + int ip = ACE_OS::atoi (s); +# endif /* ACE_WIN64 */ + void *p = ACE_reinterpret_cast (void *, ip); + return p; +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE void * +ACE_OS::bsearch (const void *key, + const void *base, + size_t nel, + size_t size, + ACE_COMPARE_FUNC compar) +{ +#if !defined (ACE_LACKS_BSEARCH) + return ::bsearch (key, base, nel, size, compar); +#else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (base); + ACE_UNUSED_ARG (nel); + ACE_UNUSED_ARG (size); + ACE_UNUSED_ARG (compar); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_LACKS_BSEARCH */ +} + +ACE_INLINE char * +ACE_OS::getenv (const char *symbol) +{ + ACE_OS_TRACE ("ACE_OS::getenv"); +#if defined (ACE_LACKS_ENV) + ACE_UNUSED_ARG (symbol); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_PSOS) + ACE_UNUSED_ARG (symbol); + ACE_NOTSUP_RETURN (0); +#else /* ACE_PSOS */ + ACE_OSCALL_RETURN (::getenv (symbol), char *, 0); +#endif /* ACE_LACKS_ENV */ +} + +#if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32) +ACE_INLINE wchar_t * +ACE_OS::getenv (const wchar_t *symbol) +{ +#if defined (ACE_LACKS_ENV) + ACE_UNUSED_ARG (symbol); + ACE_NOTSUP_RETURN (0); +#else + ACE_OSCALL_RETURN (::_wgetenv (symbol), wchar_t *, 0); +#endif /* ACE_LACKS_ENV */ +} +#endif /* ACE_HAS_WCHAR && ACE_WIN32 */ + +ACE_INLINE char * +ACE_OS::itoa (int value, char *string, int radix) +{ +#if !defined (ACE_HAS_ITOA) + return ACE_OS::itoa_emulation (value, string, radix); +#elif defined (ACE_ITOA_EQUIVALENT) + return ACE_ITOA_EQUIVALENT (value, string, radix); +#else /* !ACE_HAS_ITOA */ + return ::itoa (value, string, radix); +#endif /* !ACE_HAS_ITOA */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::itoa (int value, wchar_t *string, int radix) +{ +#if defined (ACE_LACKS_ITOW) + return ACE_OS::itow_emulation (value, string, radix); +#else /* ACE_LACKS_ITOW */ + return ::_itow (value, string, radix); +#endif /* ACE_LACKS_ITOW */ +} +#endif /* ACE_HAS_WCHAR */ + +#if !defined (ACE_LACKS_MKSTEMP) +ACE_INLINE ACE_HANDLE +ACE_OS::mkstemp (ACE_TCHAR *s) +{ + return ::mkstemp (s); +} +#endif /* !ACE_LACKS_MKSTEMP */ + +#if !defined (ACE_LACKS_MKTEMP) +ACE_INLINE ACE_TCHAR * +ACE_OS::mktemp (ACE_TCHAR *s) +{ +# if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + return ::_wmktemp (s); +# elif defined (ACE_WIN32) + return ::_mktemp (s); +# else /* ACE_WIN32 */ + return ::mktemp (s); +# endif /* ACE_WIN32 */ +} +#endif /* !ACE_LACKS_MKTEMP */ + +#if defined(INTEGRITY) +extern "C" { + int putenv(char *string); +} +#endif + +ACE_INLINE int +ACE_OS::putenv (const ACE_TCHAR *string) +{ + ACE_OS_TRACE ("ACE_OS::putenv"); +#if defined (ACE_HAS_WINCE) || defined (ACE_PSOS) + // WinCE and pSOS don't have the concept of environment variables. + ACE_UNUSED_ARG (string); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_LACKS_ENV) + ACE_UNUSED_ARG (string); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wputenv (string), int, -1); +#else /* ! ACE_HAS_WINCE && ! ACE_PSOS */ + // VxWorks declares ::putenv with a non-const arg. + ACE_OSCALL_RETURN (::putenv ((char *) string), int, -1); +#endif /* ACE_HAS_WINCE */ +} + +ACE_INLINE void +ACE_OS::qsort (void *base, + size_t nel, + size_t width, + ACE_COMPARE_FUNC compar) +{ +#if !defined (ACE_LACKS_QSORT) + ::qsort (base, nel, width, compar); +#else + ACE_UNUSED_ARG (base); + ACE_UNUSED_ARG (nel); + ACE_UNUSED_ARG (width); + ACE_UNUSED_ARG (compar); +#endif /* !ACE_LACKS_QSORT */ +} + +ACE_INLINE int +ACE_OS::rand (void) +{ + ACE_OS_TRACE ("ACE_OS::rand"); + ACE_OSCALL_RETURN (::rand (), int, -1); +} + +#if !defined (ACE_WIN32) + +ACE_INLINE int +ACE_OS::rand_r (ACE_RANDR_TYPE &seed) +{ + ACE_OS_TRACE ("ACE_OS::rand_r"); +# if defined (ACE_HAS_REENTRANT_FUNCTIONS) && \ + !defined (ACE_LACKS_RAND_REENTRANT_FUNCTIONS) +# if defined (DIGITAL_UNIX) + ACE_OSCALL_RETURN (::_Prand_r (&seed), int, -1); +# elif defined (HPUX_10) + // rand() is thread-safe on HP-UX 10. rand_r's signature is not consistent + // with latest POSIX and will change in a future HP-UX release so that it + // is consistent. At that point, this #elif section can be changed or + // removed, and just call rand_r. + ACE_UNUSED_ARG (seed); + ACE_OSCALL_RETURN (::rand(), int, -1); +# elif defined (ACE_HAS_BROKEN_RANDR) + ACE_OSCALL_RETURN (::rand_r (seed), int, -1); +# else + ACE_OSCALL_RETURN (::rand_r (&seed), int, -1); +# endif /* DIGITAL_UNIX */ +# else + ACE_UNUSED_ARG (seed); + ACE_OSCALL_RETURN (::rand (), int, -1); +# endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +} + +#else /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::rand_r (ACE_RANDR_TYPE& seed) +{ + ACE_OS_TRACE ("ACE_OS::rand_r"); + + long new_seed = (long)(seed); + if (new_seed == 0) + new_seed = 0x12345987; + long temp = new_seed / 127773; + new_seed = 16807 * (new_seed - temp * 127773) - 2836 * temp; + if (new_seed < 0) + new_seed += 2147483647; + (seed) = (unsigned int)new_seed; + return (int)(new_seed & RAND_MAX); +} + +#endif /* !ACE_WIN32 */ + +ACE_INLINE ACE_EXIT_HOOK +ACE_OS::set_exit_hook (ACE_EXIT_HOOK exit_hook) +{ + ACE_EXIT_HOOK old_hook = exit_hook_; + exit_hook_ = exit_hook; + return old_hook; +} + +ACE_INLINE void +ACE_OS::srand (u_int seed) +{ + ACE_OS_TRACE ("ACE_OS::srand"); + ::srand (seed); +} + +// Return a dynamically allocated duplicate of <str>, substituting the +// environment variable if <str[0] == '$'>. Note that the pointer is +// allocated with <ACE_OS::malloc> and must be freed by +// <ACE_OS::free>. + +ACE_INLINE ACE_TCHAR * +ACE_OS::strenvdup (const ACE_TCHAR *str) +{ +#if defined (ACE_HAS_WINCE) + // WinCE doesn't have environment variables so we just skip it. + return ACE_OS::strdup (str); +#elif defined (ACE_LACKS_ENV) + ACE_UNUSED_ARG (str); + ACE_NOTSUP_RETURN (0); +#else + ACE_TCHAR *temp = 0; + + if (str[0] == ACE_LIB_TEXT ('$') + && (temp = ACE_OS::getenv (&str[1])) != 0) + return ACE_OS::strdup (temp); + else + return ACE_OS::strdup (str); +#endif /* ACE_HAS_WINCE */ +} + +#if !defined (ACE_LACKS_STRTOD) +ACE_INLINE double +ACE_OS::strtod (const char *s, char **endptr) +{ + return ::strtod (s, endptr); +} +#endif /* !ACE_LACKS_STRTOD */ + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD) +ACE_INLINE double +ACE_OS::strtod (const wchar_t *s, wchar_t **endptr) +{ + return ::wcstod (s, endptr); +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */ + +ACE_INLINE long +ACE_OS::strtol (const char *s, char **ptr, int base) +{ +#if defined (ACE_LACKS_STRTOL) + return ACE_OS::strtol_emulation (s, ptr, base); +#else /* ACE_LACKS_STRTOL */ + return ::strtol (s, ptr, base); +#endif /* ACE_LACKS_STRTOL */ +} + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL) +ACE_INLINE long +ACE_OS::strtol (const wchar_t *s, wchar_t **ptr, int base) +{ + return ::wcstol (s, ptr, base); +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */ + +ACE_INLINE unsigned long +ACE_OS::strtoul (const char *s, char **ptr, int base) +{ +#if defined (ACE_LACKS_STRTOUL) + return ACE_OS::strtoul_emulation (s, ptr, base); +#else /* ACE_LACKS_STRTOUL */ + return ::strtoul (s, ptr, base); +#endif /* ACE_LACKS_STRTOUL */ +} + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL) +ACE_INLINE unsigned long +ACE_OS::strtoul (const wchar_t *s, wchar_t **ptr, int base) +{ + return ::wcstoul (s, ptr, base); +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */ + +ACE_INLINE int +ACE_OS::system (const ACE_TCHAR *s) +{ + // ACE_OS_TRACE ("ACE_OS::system"); +#if defined (CHORUS) || defined (ACE_HAS_WINCE) || defined(ACE_PSOS) + ACE_UNUSED_ARG (s); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wsystem (s), int, -1); +#else + ACE_OSCALL_RETURN (::system (s), int, -1); +#endif /* !CHORUS */ +} + diff --git a/ace/OS_NS_string.cpp b/ace/OS_NS_string.cpp index fc532b41367..f3317fc69b4 100644 --- a/ace/OS_NS_string.cpp +++ b/ace/OS_NS_string.cpp @@ -1,4 +1,389 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_string.h" + +ACE_RCSID(ace, OS_NS_string, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_string.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#if defined (ACE_LACKS_SYS_NERR) +# if defined (__rtems__) +int sys_nerr = EWOULDBLOCK + 1; // definitely a hack. +# else +int sys_nerr = ERRMAX + 1; +# endif /* __rtems__ */ +#endif /* ACE_LACKS_SYS_NERR */ + +#if !defined (ACE_HAS_MEMCHR) +const void * +ACE_OS::memchr_emulation (const void *s, int c, size_t len) +{ + const unsigned char *t = (const unsigned char *) s; + const unsigned char *e = (const unsigned char *) s + len; + + while (t < e) + if (((int) *t) == c) + return t; + else + t++; + + return 0; +} +#endif /*ACE_HAS_MEMCHR*/ + +#if defined (ACE_LACKS_STRCHR) +char * +ACE_OS::strchr_emulation (char *s, int c) +{ + for (;;++s) + { + if (*s == c) + return s; + if (*s == 0) + return 0; + } +} + +const char * +ACE_OS::strchr_emulation (const char *s, int c) +{ + for (;;++s) + { + if (*s == c) + return s; + if (*s == 0) + return 0; + } +} +#endif /* ACE_LACKS_STRCHR */ + +#if defined (ACE_LACKS_STRCSPN) +size_t +ACE_OS::strcspn_emulation (const char *s, const char *reject) +{ + const char *scan; + const char *rej_scan; + int count = 0; + + for (scan = s; *scan; scan++) + { + + for (rej_scan = reject; *rej_scan; rej_scan++) + if (*scan == *rej_scan) + return count; + + count++; + } + + return count; +} +#endif /* ACE_LACKS_STRCSPN */ + +char * +ACE_OS::strdup (const char *s) +{ +#if defined (ACE_HAS_STRDUP_EMULATION) + char *t = (char *) ACE_OS::malloc (ACE_OS::strlen (s) + 1); + if (t == 0) + return 0; + + return ACE_OS::strcpy (t, s); +#else + return ::strdup (s); +#endif /* ACE_HAS_STRDUP_EMULATION */ +} + +#if defined (ACE_HAS_WCHAR) +wchar_t * +ACE_OS::strdup (const wchar_t *s) +{ +# if defined (ACE_LACKS_WCSDUP) + wchar_t *buffer = + (wchar_t *) ACE_OS::malloc ((ACE_OS::strlen (s) + 1) + * sizeof (wchar_t)); + if (buffer == 0) + return 0; + + return ACE_OS::strcpy (buffer, s); +# elif defined (ACE_WCSDUP_EQUIVALENT) + return ACE_WCSDUP_EQUIVALENT (s); +# else /* ACE_LACKS_WCSDUP */ +# if defined (__MINGW32__) + return ::wcsdup (ACE_const_cast(wchar_t*, s)); +# else /* __MINGW32__ */ + return ::wcsdup (s); +# endif /* __MINGW32__ */ +# endif /* ACE_LACKS_WCSDUP */ +} +#endif /* ACE_HAS_WCHAR */ + +char * +ACE_OS::strecpy (char *s, const char *t) +{ + register char *dscan = s; + register const char *sscan = t; + + while ((*dscan++ = *sscan++) != '\0') + continue; + + return dscan; +} + +#if defined (ACE_HAS_WCHAR) +wchar_t * +ACE_OS::strecpy (wchar_t *s, const wchar_t *t) +{ + register wchar_t *dscan = s; + register const wchar_t *sscan = t; + + while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0')) + continue; + + return dscan; +} +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRERROR) +/** + * Just returns "Unknown Error" all the time. + */ +char * +ACE_OS::strerror_emulation (int errnum) +{ + return "Unknown Error"; +} +#endif /* ACE_LACKS_STRERROR */ + +const char * +ACE_OS::strnchr (const char *s, int c, size_t len) +{ + for (size_t i = 0; i < len; i++) + if (s[i] == c) + return s + i; + + return 0; +} + +const ACE_WCHAR_T * +ACE_OS::strnchr (const ACE_WCHAR_T *s, ACE_WINT_T c, size_t len) +{ + for (size_t i = 0; i < len; i++) + if (s[i] == ACE_static_cast(ACE_WCHAR_T, c)) + return s + i; + + return 0; +} + +const char * +ACE_OS::strnstr (const char *s1, const char *s2, size_t len2) +{ + // Substring length + size_t len1 = ACE_OS::strlen (s1); + + // Check if the substring is longer than the string being searched. + if (len2 > len1) + return 0; + + // Go upto <len> + size_t len = len1 - len2; + + for (size_t i = 0; i <= len; i++) + { + if (ACE_OS::memcmp (s1 + i, s2, len2) == 0) + // Found a match! Return the index. + return s1 + i; + } + + return 0; +} + +const ACE_WCHAR_T * +ACE_OS::strnstr (const ACE_WCHAR_T *s1, const ACE_WCHAR_T *s2, size_t len2) +{ + // Substring length + size_t len1 = ACE_OS::strlen (s1); + + // Check if the substring is longer than the string being searched. + if (len2 > len1) + return 0; + + // Go upto <len> + size_t len = len1 - len2; + + for (size_t i = 0; i <= len; i++) + { + if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0) + // Found a match! Return the index. + return s1 + i; + } + + return 0; +} + +#if defined (ACE_LACKS_STRPBRK) +char * +ACE_OS::strpbrk_emulation (const char *string, + const char *charset) +{ + const char *scanp; + int c, sc; + + while ((c = *string++) != 0) + { + for (scanp = charset; (sc = *scanp++) != 0;) + if (sc == c) + return ACE_const_cast (char *, string - 1); + } + + return 0; +} +#endif /* ACE_LACKS_STRPBRK */ + +#if defined (ACE_LACKS_STRRCHR) +char * +ACE_OS::strrchr_emulation (char *s, int c) +{ + char *p = s + ACE_OS::strlen (s); + + while (*p != c) + if (p == s) + return 0; + else + p--; + + return p; +} + +const char * +ACE_OS::strrchr_emulation (const char *s, int c) +{ + const char *p = s + ACE_OS::strlen (s); + + while (*p != c) + if (p == s) + return 0; + else + p--; + + return p; +} +#endif /* ACE_LACKS_STRRCHR */ + +char * +ACE_OS::strsncpy (char *dst, const char *src, size_t maxlen) +{ + register char *rdst = dst; + register const char *rsrc = src; + register size_t rmaxlen = maxlen; + + if (rmaxlen > 0) + { + if (rdst!=rsrc) + { + *rdst = '\0'; + if (rsrc != 0) + strncat (rdst, rsrc, --rmaxlen); + } + else + { + rdst += (rmaxlen - 1); + *rdst = '\0'; + } + } + return dst; +} + +ACE_WCHAR_T * +ACE_OS::strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen) +{ + register ACE_WCHAR_T *rdst = dst; + register const ACE_WCHAR_T *rsrc = src; + register size_t rmaxlen = maxlen; + + if (rmaxlen > 0) + { + if (rdst!=rsrc) + { + *rdst = ACE_TEXT_WIDE ('\0'); + if (rsrc != 0) + strncat (rdst, rsrc, --rmaxlen); + } + else + { + rdst += (rmaxlen - 1); + *rdst = ACE_TEXT_WIDE ('\0'); + } + } + return dst; +} + +#if defined (ACE_LACKS_STRSPN) +size_t +ACE_OS::strspn_emulation (const char *string, + const char *charset) +{ + const char *p = string; + const char *spanp; + wchar_t c, sc; + + // Skip any characters in charset, excluding the terminating \0. +cont: + c = *p++; + for (spanp = charset; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - string); +} +#endif /* ACE_LACKS_STRSPN */ + +#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) +char * +ACE_OS::strtok_r_emulation (char *s, const char *tokens, char **lasts) +{ + if (s == 0) + s = *lasts; + else + *lasts = s; + if (*s == 0) // We have reached the end + return 0; + size_t l_org = ACE_OS::strlen (s); + s = ::strtok (s, tokens); + if (s == 0) + return 0; + size_t l_sub = ACE_OS::strlen (s); + if (s + l_sub < *lasts + l_org) + *lasts = s + l_sub + 1; + else + *lasts = s + l_sub; + return s ; +} +#endif /* !ACE_HAS_REENTRANT_FUNCTIONS */ + +# if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSTOK) +wchar_t* +ACE_OS::strtok_r_emulation (ACE_WCHAR_T *s, + const ACE_WCHAR_T *tokens, + ACE_WCHAR_T **lasts) +{ + if (s == 0) + s = *lasts; + else + *lasts = s; + if (*s == 0) // We have reached the end + return 0; + int l_org = ACE_OS::strlen (s); + s = ACE_OS::strtok (s, tokens); + if (s == 0) + return 0; + int l_sub = ACE_OS::strlen (s); + if (s + l_sub < *lasts + l_org) + *lasts = s + l_sub + 1; + else + *lasts = s + l_sub; + return s ; +} +# endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSTOK */ + diff --git a/ace/OS_NS_string.h b/ace/OS_NS_string.h index fc532b41367..0af4da7c91b 100644 --- a/ace/OS_NS_string.h +++ b/ace/OS_NS_string.h @@ -1,4 +1,401 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_string.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_STRING_H +# define ACE_OS_NS_STRING_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/Basic_Types.h" // to get ACE_WCHAR_T, + // should be in os_stddef.h or not used like this. + +class ACE_Time_Value; + +# if defined (ACE_LACKS_SYS_NERR) +extern ACE_OS_Export int sys_nerr; +# endif /* ACE_LACKS_SYS_NERR */ + +namespace ACE_OS { + + /** @name Functions from <cstring> + * + * Included are the functions defined in <cstring> and their <cwchar> + * equivalents. + * + * @todo To be complete, we should add strcoll, and strxfrm. + */ + //@{ + + /// Finds characters in a buffer (const void version). + const void *memchr (const void *s, int c, size_t len); + + /// Finds characters in a buffer (void version). + void *memchr (void *s, int c, size_t len); + +#if !defined (ACE_HAS_MEMCHR) + /// Emulated memchr - Finds a character in a buffer. + const void *memchr_emulation (const void *s, int c, size_t len); +#endif /* ACE_HAS_MEMCHR */ + + /// Compares two buffers. + int memcmp (const void *t, const void *s, size_t len); + + /// Copies one buffer to another. + void *memcpy (void *t, const void *s, size_t len); + + /// Moves one buffer to another. + void *memmove (void *t, const void *s, size_t len); + + /// Fills a buffer with a character value. + void *memset (void *s, int c, size_t len); + + /// Appends a string to another string (char version). + char *strcat (char *s, const char *t); + +#if defined (ACE_HAS_WCHAR) + /// Appends a string to another string (wchar_t version). + wchar_t *strcat (wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a character in a string (const char + /// version). + const char *strchr (const char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a character in a string (const wchar_t + /// version). + const wchar_t *strchr (const wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a character in a string (char version). + char *strchr (char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a character in a string (wchar_t version). + wchar_t *strchr (wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRCHR) + /// Emulated strchr (char version) - Finds the first occurance of a + /// character in a string. + char *strchr_emulation (char *s, int c); + + /// Emulated strchr (const char version) - Finds the first occurance of a + /// character in a string. + const char *strchr_emulation (const char *s, int c); +#endif /* ACE_LACKS_STRCHR */ + + /// Compares two strings (char version). + int strcmp (const char *s, const char *t); + + /// Compares two strings (wchar_t version). + int strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t); + + /// Copies a string (char version). + char *strcpy (char *s, const char *t); + +#if defined (ACE_HAS_WCHAR) + /// Copies a string (wchar_t version). + wchar_t *strcpy (wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Searches for the first substring without any of the specified + /// characters and returns the size of the substring (char version). + size_t strcspn (const char *s, const char *reject); + +#if defined (ACE_HAS_WCHAR) + /// Searches for the first substring without any of the specified + /// characters and returns the size of the substring (wchar_t version). + size_t strcspn (const wchar_t *s, const wchar_t *reject); +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRCSPN) + /// Emulated strcspn - Finds a substring in a string. + size_t strcspn_emulation (const char *s, const char *reject); +#endif /* ACE_LACKS_STRCSPN */ + + /// Returns a malloced duplicated string (char version). + char *strdup (const char *s); + +#if defined (ACE_HAS_WCHAR) + /// Returns a malloced duplicated string (wchar_t version). + wchar_t *strdup (const wchar_t *s); +#endif /* ACE_HAS_WCHAR */ + + /// Copies a string, but returns a pointer to the end of the + /// copied region (char version). + char *strecpy (char *des, const char *src); + +#if defined (ACE_HAS_WCHAR) + /// Copies a string, but returns a pointer to the end of the + /// copied region (wchar_t version). + wchar_t *strecpy (wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Returns a system error message. + char *strerror (int errnum); + +#if defined (ACE_LACKS_STRERROR) + /// Emulated strerror - Returns a system error message. + char *strerror_emulation (int errnum); +#endif /* ACE_LACKS_STRERROR */ + + /// Finds the length of a string (char version). + size_t strlen (const char *s); + + /// Finds the length of a string (ACE_WCHAR_T version). + size_t strlen (const ACE_WCHAR_T *s); + + /// Appends part of a string to another string (char version). + char *strncat (char *s, const char *t, size_t len); + + /// Appends part of a string to another string (wchar_t version). + ACE_WCHAR_T *strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); + + /// Finds the first occurance of a character in an array (const char + /// version). + const char *strnchr (const char *s, int c, size_t len); + + /// Finds the first occurance of a character in an array (const ACE_WCHAR_T + /// version). + const ACE_WCHAR_T *strnchr (const ACE_WCHAR_T *s, ACE_WINT_T c, size_t len); + + /// Finds the first occurance of a character in an array (char version). + char *strnchr (char *s, int c, size_t len); + + /// Finds the first occurance of a character in an array (ACE_WCHAR_T version). + ACE_WCHAR_T *strnchr (ACE_WCHAR_T *s, ACE_WINT_T c, size_t len); + + /// Compares two arrays (char version). + int strncmp (const char *s, const char *t, size_t len); + + /// Compares two arrays (wchar_t version). + int strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); + + /// Copies an array (char version) + char *strncpy (char *s, const char *t, size_t len); + + /// Copies an array (ACE_WCHAR_T version) + ACE_WCHAR_T *strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); + + /// Finds the length of a limited-length string (char version). + /** + * @param s The character string to find the length of. + * @param maxlen The maximum number of characters that will be + * scanned for the terminating nul character. + * + * @return The length of @arg s, if the terminating nul character + * is located, else @arg maxlen. + */ + size_t strnlen (const char *s, size_t maxlen); + + /// Finds the length of a limited-length string (ACE_WCHAR_T version). + /** + * @param s The character string to find the length of. + * @param maxlen The maximum number of characters that will be + * scanned for the terminating nul character. + * + * @return The length of @arg s, if the terminating nul character + * is located, else @arg maxlen. + */ + size_t strnlen (const ACE_WCHAR_T *s, size_t maxlen); + + /// Finds the first occurance of a substring in an array (const char + /// version). + const char *strnstr (const char *s, const char *t, size_t len); + + /// Finds the first occurance of a substring in an array (const wchar_t + /// version). + const ACE_WCHAR_T *strnstr (const ACE_WCHAR_T *s, + const ACE_WCHAR_T *t, + size_t len); + + /// Finds the first occurance of a substring in an array (char version). + char *strnstr (char *s, const char *t, size_t len); + + /// Finds the first occurance of a substring in an array (wchar_t version). + ACE_WCHAR_T *strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); + + /// Searches for characters in a string (const char version). + const char *strpbrk (const char *s1, const char *s2); + +#if defined (ACE_HAS_WCHAR) + /// Searches for characters in a string (const wchar_t version). + const wchar_t *strpbrk (const wchar_t *s1, const wchar_t *s2); +#endif /* ACE_HAS_WCHAR */ + + /// Searches for characters in a string (char version). + char *strpbrk (char *s1, const char *s2); + +#if defined (ACE_HAS_WCHAR) + /// Searches for characters in a string (wchar_t version). + wchar_t *strpbrk (wchar_t *s1, const wchar_t *s2); +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRPBRK) + /// Emulated strpbrk - Searches for characters in a string. + char *strpbrk_emulation (const char *string, + const char *charset); +#endif /* ACE_LACKS_STRPBRK */ + + /// Finds the last occurance of a character in a string (const char + /// version). + const char *strrchr (const char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the last occurance of a character in a string (const wchar_t + /// version). + const wchar_t *strrchr (const wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the last occurance of a character in a string (char version). + char *strrchr (char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the last occurance of a character in a string (wchar_t version). + wchar_t *strrchr (wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRRCHR) + /// Emulated strrchr (char version) - Finds the last occurance of a + /// character in a string. + char *strrchr_emulation (char *s, int c); + + /// Emulated strrchr (const char version) - Finds the last occurance of a + /// character in a string. + const char *strrchr_emulation (const char *s, int c); +#endif /* ACE_LACKS_STRRCHR */ + + /// This is a "safe" c string copy function (char version). + /** + * Unlike strncpy() this function will always add a terminating '\0' + * char if maxlen > 0. So the user doesn't has to provide an extra + * '\0' if the user wants a '\0' terminated dst. The function + * doesn't check for a 0 <dst>, because this will give problems + * anyway. When <src> is 0 an empty string is made. We do not + * "touch" *<dst> if maxlen is 0. Returns <dst>. Care should be + * taken when replacing strncpy() calls, because in some cases a + * strncpy() user is using the "not '\0' terminating" feature from + * strncpy(). This happens most when the call to strncpy() was + * optimized by using a maxlen which is 1 smaller than the size + * because there's always written a '\0' inside this last position. + * Very seldom it's possible that the '\0' padding feature from + * strncpy() is needed. + */ + char *strsncpy (char *dst, + const char *src, + size_t maxlen); + + /// This is a "safe" c string copy function (wchar_t version). + /** + * Unlike strncpy() this function will always add a terminating '\0' + * char if maxlen > 0. So the user doesn't has to provide an extra + * '\0' if the user wants a '\0' terminated dst. The function + * doesn't check for a 0 <dst>, because this will give problems + * anyway. When <src> is 0 an empty string is made. We do not + * "touch" *<dst> if maxlen is 0. Returns <dst>. Care should be + * taken when replacing strncpy() calls, because in some cases a + * strncpy() user is using the "not '\0' terminating" feature from + * strncpy(). This happens most when the call to strncpy() was + * optimized by using a maxlen which is 1 smaller than the size + * because there's always written a '\0' inside this last position. + * Very seldom it's possible that the '\0' padding feature from + * strncpy() is needed. + */ + ACE_WCHAR_T *strsncpy (ACE_WCHAR_T *dst, + const ACE_WCHAR_T *src, + size_t maxlen); + + /// Searches for the first substring containing only the specified + /// characters and returns the size of the substring (char version). + size_t strspn (const char *s1, const char *s2); + +#if defined (ACE_HAS_WCHAR) + /// Searches for the first substring containing only the specified + /// characters and returns the size of the substring (wchar_t version). + size_t strspn (const wchar_t *s1, const wchar_t *s2); +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRSPN) + /// Emulated wcsspn. + size_t strspn_emulation (const char *string, + const char *charset); +#endif /* ACE_LACKS_STRSPN */ + + /// Finds the first occurance of a substring in a string (const char + /// version). + const char *strstr (const char *s, const char *t); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a substring in a string (const wchar_t + /// version). + const wchar_t *strstr (const wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a substring in a string (char version). + char *strstr (char *s, const char *t); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a substring in a string (wchar_t version). + wchar_t *strstr (wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the next token in a string (char version). + char *strtok (char *s, const char *tokens); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK) + /// Finds the next token in a string (wchar_t version). + wchar_t *strtok (wchar_t *s, const wchar_t *tokens); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOK */ + + //@} + + /// Finds the next token in a string (safe char version). + char *strtok_r (char *s, const char *tokens, char **lasts); + +#if defined (ACE_HAS_WCHAR) + /// Finds the next token in a string (wchar_t version). + wchar_t *strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts); +#endif // ACE_HAS_WCHAR + +#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) + /// Emulated strtok_r. + char *strtok_r_emulation (char *s, const char *tokens, char **lasts); + +# if defined (ACE_HAS_WCHAR) + /// Emulated strtok_r (wchar_t version). + wchar_t *strtok_r_emulation (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts); +# endif // ACE_HAS_WCHAR +#endif /* !ACE_HAS_REENTRANT_FUNCTIONS */ + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_string.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_STRING_H */ diff --git a/ace/OS_NS_string.inl b/ace/OS_NS_string.inl index fc532b41367..8604cb2153f 100644 --- a/ace/OS_NS_string.inl +++ b/ace/OS_NS_string.inl @@ -1,4 +1,493 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +// don't like this... dhinton +#include "ace/OS_NS_wchar.h" + +ACE_INLINE const void * +ACE_OS::memchr (const void *s, int c, size_t len) +{ +#if defined (ACE_HAS_MEMCHR) + return ::memchr (s, c, len); +#else /* ACE_HAS_MEMCHR */ + return ACE_OS::memchr_emulation (s, c, len); +#endif /* ACE_HAS_MEMCHR */ +} + +ACE_INLINE void * +ACE_OS::memchr (void *s, int c, size_t len) +{ + return ACE_const_cast (void *, + ACE_OS::memchr (ACE_static_cast (const void *, s), c, len)); +} + +ACE_INLINE int +ACE_OS::memcmp (const void *t, const void *s, size_t len) +{ + return ::memcmp (t, s, len); +} + + +ACE_INLINE void * +ACE_OS::memcpy (void *t, const void *s, size_t len) +{ + return ::memcpy (t, s, len); +} + +ACE_INLINE void * +ACE_OS::memmove (void *t, const void *s, size_t len) +{ + return ::memmove (t, s, len); +} + +ACE_INLINE void * +ACE_OS::memset (void *s, int c, size_t len) +{ + return ::memset (s, c, len); +} + +ACE_INLINE char * +ACE_OS::strcat (char *s, const char *t) +{ + return ::strcat (s, t); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::strcat (wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSCAT) + return ACE_OS::wcscat_emulation (s, t); +# else /* ACE_LACKS_WCSCAT */ + return ::wcscat (s, t); +# endif /* ACE_LACKS_WCSCAT */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE const char * +ACE_OS::strchr (const char *s, int c) +{ +#if defined (ACE_LACKS_STRCHR) + return ACE_OS::strchr_emulation (s, c); +#else /* ! ACE_LACKS_STRCHR */ + return (const char *) ::strchr (s, c); +#endif /* ACE_LACKS_STRCHR */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE const wchar_t * +ACE_OS::strchr (const wchar_t *s, wint_t c) +{ +# if defined (ACE_LACKS_WCSCHR) + return ACE_OS::wcschr_emulation (s, c); +# else /* ACE_LACKS_WCSCHR */ + return ::wcschr (s, c); +# endif /* ACE_LACKS_WCSCHR */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE char * +ACE_OS::strchr (char *s, int c) +{ +#if defined (ACE_LACKS_STRCHR) + return ACE_OS::strchr_emulation (s, c); +#else /* ! ACE_LACKS_STRCHR */ + return ::strchr (s, c); +#endif /* ACE_LACKS_STRCHR */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::strchr (wchar_t *s, wint_t c) +{ + return ACE_const_cast (wchar_t *, + ACE_OS::strchr (ACE_static_cast (const wchar_t *, s), c)); +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::strcmp (const char *s, const char *t) +{ + return ::strcmp (s, t); +} + +ACE_INLINE int +ACE_OS::strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t) +{ +# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) + return ACE_OS::wcscmp_emulation (s, t); +# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ + return ::wcscmp (s, t); +# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ +} + +ACE_INLINE char * +ACE_OS::strcpy (char *s, const char *t) +{ + return ::strcpy (s, t); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::strcpy (wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSCPY) + return ACE_OS::wcscpy_emulation (s, t); +# else /* ACE_LACKS_WCSCPY */ + return ::wcscpy (s, t); +# endif /* ACE_LACKS_WCSCPY */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE size_t +ACE_OS::strcspn (const char *s, const char *reject) +{ +#if defined (ACE_LACKS_STRCSPN) + return ACE_OS::strcspn_emulation (s, reject); +#else /* ACE_LACKS_STRCSPN */ + return ::strcspn (s, reject); +#endif /* ACE_LACKS_STRCSPN */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE size_t +ACE_OS::strcspn (const wchar_t *s, const wchar_t *reject) +{ +# if defined (ACE_LACKS_WCSCSPN) + return ACE_OS::wcscspn_emulation (s, reject); +# else /* ACE_LACKS_WCSCSPN */ + return ::wcscspn (s, reject); +# endif /* ACE_LACKS_WCSCSPN */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE char * +ACE_OS::strerror (int errnum) +{ +#if defined (ACE_LACKS_STRERROR) + return ACE_OS::strerror_emulation (errnum); +#else /* ACE_LACKS_STRERROR */ + return ::strerror (errnum); +#endif /* ACE_LACKS_STRERROR */ +} + +ACE_INLINE size_t +ACE_OS::strlen (const char *s) +{ + return ::strlen (s); +} + +ACE_INLINE size_t +ACE_OS::strlen (const ACE_WCHAR_T *s) +{ +# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) + return ACE_OS::wcslen_emulation (s); +# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ + return ::wcslen (s); +# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ +} + +ACE_INLINE char * +ACE_OS::strncat (char *s, const char *t, size_t len) +{ + return ::strncat (s, t, len); +} + +ACE_INLINE ACE_WCHAR_T * +ACE_OS::strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) +{ +# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) + return ACE_OS::wcsncat_emulation (s, t, len); +# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */ + return ::wcsncat (s, t, len); +# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */ +} + +ACE_INLINE char * +ACE_OS::strnchr (char *s, int c, size_t len) +{ +#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ + const char *const_char_s = s; + return ACE_const_cast (char *, + ACE_OS::strnchr (const_char_s, c, len)); +#else + return ACE_const_cast (char *, + ACE_OS::strnchr (ACE_static_cast (const char *, s), c, len)); +#endif +} + +ACE_INLINE ACE_WCHAR_T * +ACE_OS::strnchr (ACE_WCHAR_T *s, ACE_WINT_T c, size_t len) +{ + return ACE_const_cast (ACE_WCHAR_T *, + ACE_OS::strnchr (ACE_static_cast (const ACE_WCHAR_T *, s), c, len)); +} + +ACE_INLINE int +ACE_OS::strncmp (const char *s, const char *t, size_t len) +{ + return ::strncmp (s, t, len); +} + +ACE_INLINE int +ACE_OS::strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) +{ +# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) + return ACE_OS::wcsncmp_emulation (s, t, len); +# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ + return ::wcsncmp (s, t, len); +# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ +} + +ACE_INLINE char * +ACE_OS::strncpy (char *s, const char *t, size_t len) +{ + return ::strncpy (s, t, len); +} + +ACE_INLINE ACE_WCHAR_T * +ACE_OS::strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) +{ +# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) + return ACE_OS::wcsncpy_emulation (s, t, len); +# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ + return ::wcsncpy (s, t, len); +# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ +} + +ACE_INLINE size_t +ACE_OS::strnlen (const char *s, size_t maxlen) +{ +#if defined (ACE_HAS_STRNLEN) + return ::strnlen (s, maxlen); +#else /* ACE_HAS_STRNLEN */ + size_t i; + for (i = 0; i < maxlen; ++i) + if (s[i] == '\0') + break; + return i; +#endif /* ACE_HAS_STRNLEN */ +} + +ACE_INLINE size_t +ACE_OS::strnlen (const ACE_WCHAR_T *s, size_t maxlen) +{ +#if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN) + return wcsnlen (s, maxlen); +#else /* ACE_HAS_WCSNLEN */ + size_t i; + for (i = 0; i < maxlen; ++i) + if (s[i] == '\0') + break; + return i; +#endif /* ACE_HAS_WCSNLEN */ +} + +ACE_INLINE char * +ACE_OS::strnstr (char *s, const char *t, size_t len) +{ +#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ + const char *const_char_s=s; + return (char *) ACE_OS::strnstr (const_char_s, t, len); +#else + return (char *) ACE_OS::strnstr ((const char *) s, t, len); +#endif +} + +ACE_INLINE ACE_WCHAR_T * +ACE_OS::strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) +{ + return ACE_const_cast (ACE_WCHAR_T *, + ACE_OS::strnstr (ACE_static_cast (const ACE_WCHAR_T *, s), t, len)); +} + +ACE_INLINE const char * +ACE_OS::strpbrk (const char *s1, const char *s2) +{ +#if defined (ACE_LACKS_STRPBRK) + return ACE_OS::strpbrk_emulation (s1, s2); +#else /* ACE_LACKS_STRPBRK */ + return (const char *) ::strpbrk (s1, s2); +#endif /* ACE_LACKS_STRPBRK */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE const wchar_t * +ACE_OS::strpbrk (const wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSPBRK) + return ACE_OS::wcspbrk_emulation (s, t); +# else /* ACE_LACKS_WCSPBRK */ + return ::wcspbrk (s, t); +# endif /* ACE_LACKS_WCSPBRK */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE char * +ACE_OS::strpbrk (char *s1, const char *s2) +{ +#if defined (ACE_LACKS_STRPBRK) + return ACE_OS::strpbrk_emulation (s1, s2); +#else /* ACE_LACKS_STRPBRK */ + return ::strpbrk (s1, s2); +#endif /* ACE_LACKS_STRPBRK */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::strpbrk (wchar_t *s, const wchar_t *t) +{ + return ACE_const_cast (wchar_t *, + ACE_OS::strpbrk (ACE_static_cast (const wchar_t *, s), t)); +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE const char * +ACE_OS::strrchr (const char *s, int c) +{ +#if defined (ACE_LACKS_STRRCHR) + return ACE_OS::strrchr_emulation (s, c); +#else /* ! ACE_LACKS_STRRCHR */ + return (const char *) ::strrchr (s, c); +#endif /* ! ACE_LACKS_STRRCHR */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE const wchar_t * +ACE_OS::strrchr (const wchar_t *s, wint_t c) +{ +#if defined (ACE_LACKS_WCSRCHR) + return ACE_OS::wcsrchr_emulation (s, c); +#else /* ! ACE_LACKS_WCSRCHR */ + return (const wchar_t *) ::wcsrchr (s, c); +#endif /* ! ACE_LACKS_WCSRCHR */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE char * +ACE_OS::strrchr (char *s, int c) +{ +#if defined (ACE_LACKS_STRRCHR) + return ACE_OS::strrchr_emulation (s, c); +#else /* ! ACE_LACKS_STRRCHR */ + return ::strrchr (s, c); +#endif /* ! ACE_LACKS_STRRCHR */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::strrchr (wchar_t *s, wint_t c) +{ + return ACE_const_cast (wchar_t *, + ACE_OS::strrchr (ACE_static_cast (const wchar_t *, s), c)); +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE size_t +ACE_OS::strspn (const char *s, const char *t) +{ +#if defined (ACE_LACKS_STRSPN) + return ACE_OS::strspn_emulation (s, t); +#else /* ACE_LACKS_STRSPN */ + return ::strspn (s, t); +#endif /* ACE_LACKS_STRSPN */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE size_t +ACE_OS::strspn (const wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSSPN) + return ACE_OS::wcsspn_emulation (s, t); +# else /* ACE_LACKS_WCSSPN */ + return ::wcsspn (s, t); +# endif /* ACE_LACKS_WCSSPN */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE const char * +ACE_OS::strstr (const char *s, const char *t) +{ + return (const char *) ::strstr (s, t); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE const wchar_t * +ACE_OS::strstr (const wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSSTR) + return ACE_OS::wcsstr_emulation (s, t); +# elif defined (HPUX) + return (const wchar_t *) ::wcswcs (s, t); +# else /* ACE_LACKS_WCSSTR */ + return (const wchar_t *) ::wcsstr (s, t); +# endif /* ACE_LACKS_WCSSTR */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE char * +ACE_OS::strstr (char *s, const char *t) +{ + return ::strstr (s, t); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::strstr (wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSSTR) + return ACE_OS::wcsstr_emulation (s, t); +# elif defined (HPUX) + return ::wcswcs (s, t); +# else /* ACE_LACKS_WCSSTR */ + return ::wcsstr (s, t); +# endif /* ACE_LACKS_WCSSTR */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE char * +ACE_OS::strtok (char *s, const char *tokens) +{ + return ::strtok (s, tokens); +} + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK) +ACE_INLINE wchar_t * +ACE_OS::strtok (wchar_t *s, const wchar_t *tokens) +{ +#if defined (ACE_HAS_3_PARAM_WCSTOK) + static wchar_t *lasts; + return ::wcstok (s, tokens, &lasts); +#else + return ::wcstok (s, tokens); +#endif /* ACE_HAS_3_PARAM_WCSTOK */ +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOK */ + +ACE_INLINE char * +ACE_OS::strtok_r (char *s, const char *tokens, char **lasts) +{ +#if defined (ACE_HAS_REENTRANT_FUNCTIONS) + return ::strtok_r (s, tokens, lasts); +#else + return ACE_OS::strtok_r_emulation (s, tokens, lasts); +#endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t* +ACE_OS::strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts) +{ +#if defined (ACE_LACKS_WCSTOK) + return ACE_OS::strtok_r_emulation (s, tokens, lasts); +#else +# if defined (ACE_HAS_3_PARAM_WCSTOK) + return ::wcstok (s, tokens, lasts); +# else /* ACE_HAS_3_PARAM_WCSTOK */ + *lasts = ::wcstok (s, tokens); + return *lasts; +# endif /* ACE_HAS_3_PARAM_WCSTOK */ +#endif /* ACE_LACKS_WCSTOK */ +} +#endif // ACE_HAS_WCHAR + diff --git a/ace/OS_NS_strings.cpp b/ace/OS_NS_strings.cpp index fc532b41367..ec2ab0ee4a0 100644 --- a/ace/OS_NS_strings.cpp +++ b/ace/OS_NS_strings.cpp @@ -1,4 +1,77 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_strings.h" + +ACE_RCSID(ace, OS_NS_strings, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_strings.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#if defined (ACE_LACKS_STRCASECMP) +int +ACE_OS::strcasecmp_emulation (const char *s, const char *t) +{ + const char *scan1 = s; + const char *scan2 = t; + + while (*scan1 != 0 + && ACE_OS::to_lower (*scan1) + == ACE_OS::to_lower (*scan2)) + { + ++scan1; + ++scan2; + } + + // The following case analysis is necessary so that characters which + // look negative collate low against normal characters but high + // against the end-of-string NUL. + + if (*scan1 == '\0' && *scan2 == '\0') + return 0; + else if (*scan1 == '\0') + return -1; + else if (*scan2 == '\0') + return 1; + else + return ACE_OS::to_lower (*scan1) - ACE_OS::to_lower (*scan2); +} +#endif /* ACE_LACKS_STRCASECMP */ + +#if defined (ACE_LACKS_STRCASECMP) +int +ACE_OS::strncasecmp_emulation (const char *s, + const char *t, + size_t len) +{ + const char *scan1 = s; + const char *scan2 = t; + size_t count = 0; + + while (count++ < len + && *scan1 != 0 + && ACE_OS::to_lower (*scan1) + == ACE_OS::to_lower (*scan2)) + { + ++scan1; + ++scan2; + } + + if (count > len) + return 0; + + // The following case analysis is necessary so that characters which + // look negative collate low against normal characters but high + // against the end-of-string NUL. + + if (*scan1 == '\0' && *scan2 == '\0') + return 0; + else if (*scan1 == '\0') + return -1; + else if (*scan2 == '\0') + return 1; + else + return ACE_OS::to_lower (*scan1) - ACE_OS::to_lower (*scan2); +} +#endif /* ACE_LACKS_STRCASECMP */ diff --git a/ace/OS_NS_strings.h b/ace/OS_NS_strings.h index fc532b41367..e465ff94f64 100644 --- a/ace/OS_NS_strings.h +++ b/ace/OS_NS_strings.h @@ -1,4 +1,69 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_strings.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_STRINGS_H +# define ACE_OS_NS_STRINGS_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/os_strings.h" + +class ACE_Time_Value; + +namespace ACE_OS { + + /// Compares two strings (case insensitive const char version). + int strcasecmp (const char *s, const char *t); + +#if defined (ACE_HAS_WCHAR) + /// Compares two strings (case insensitive const wchar_t version). + int strcasecmp (const wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Compares two arrays (case insensitive const char version). + int strncasecmp (const char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Compares two arrays (case insensitive const wchar_t version). + int strncasecmp (const wchar_t *s, const wchar_t *t, size_t len); +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_LACKS_STRCASECMP) + /// Emulated strcasecmp - Performs a case insensitive comparison of strings. + int strcasecmp_emulation (const char *s, const char *t); + + /// Emulated strncasecmp - Performs a case insensitvie comparison of arrays. + int strncasecmp_emulation (const char *s, const char *t, size_t len); +#endif /* ACE_LACKS_STRCASECMP */ + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_strings.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_STRINGS_H */ diff --git a/ace/OS_NS_strings.inl b/ace/OS_NS_strings.inl index fc532b41367..52960598711 100644 --- a/ace/OS_NS_strings.inl +++ b/ace/OS_NS_strings.inl @@ -1,4 +1,51 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE int +ACE_OS::strcasecmp (const char *s, const char *t) +{ +#if defined (ACE_LACKS_STRCASECMP) + return ACE_OS::strcasecmp_emulation (s, t); +#elif defined (ACE_STRCASECMP_EQUIVALENT) + return ACE_STRCASECMP_EQUIVALENT (s, t); +#else /* ACE_LACKS_STRCASECMP */ + return ::strcasecmp (s, t); +#endif /* ACE_LACKS_STRCASECMP */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::strcasecmp (const wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSICMP) + return ACE_OS::wcsicmp_emulation (s, t); +# else /* ACE_LACKS_WCSICMP */ + return ::_wcsicmp (s, t); +# endif /* ACE_LACKS_WCSICMP */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::strncasecmp (const char *s, const char *t, size_t len) +{ +#if defined (ACE_LACKS_STRCASECMP) + return ACE_OS::strncasecmp_emulation (s, t, len); +#elif defined (ACE_STRNCASECMP_EQUIVALENT) + return ACE_STRNCASECMP_EQUIVALENT (s, t, len); +#else /* ACE_LACKS_STRCASECMP */ + return ::strncasecmp (s, t, len); +#endif /* ACE_LACKS_STRCASECMP */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::strncasecmp (const wchar_t *s, const wchar_t *t, size_t len) +{ +#if defined (ACE_LACKS_WCSNICMP) + return ACE_OS::wcsnicmp_emulation (s, t, len); +#else /* ACE_LACKS_WCSNICMP */ + return ::_wcsnicmp (s, t, len); +#endif /* ACE_LACKS_WCSNICMP */ +} +#endif /* ACE_HAS_WCHAR */ + diff --git a/ace/OS_NS_stropts.cpp b/ace/OS_NS_stropts.cpp index fc532b41367..72696cb7b72 100644 --- a/ace/OS_NS_stropts.cpp +++ b/ace/OS_NS_stropts.cpp @@ -1,4 +1,193 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_stropts.h" + +ACE_RCSID(ace, OS_NS_stropts, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_stropts.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +int +ACE_OS::ioctl (ACE_HANDLE socket, + unsigned long io_control_code, + void *in_buffer_p, + unsigned long in_buffer, + void *out_buffer_p, + unsigned long out_buffer, + unsigned long *bytes_returned, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) +{ +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, + io_control_code, + in_buffer_p, + in_buffer, + out_buffer_p, + out_buffer, + bytes_returned, + (WSAOVERLAPPED *) overlapped, + func), + int, + SOCKET_ERROR); +# else + ACE_UNUSED_ARG (socket); + ACE_UNUSED_ARG (io_control_code); + ACE_UNUSED_ARG (in_buffer_p); + ACE_UNUSED_ARG (in_buffer); + ACE_UNUSED_ARG (out_buffer_p); + ACE_UNUSED_ARG (out_buffer); + ACE_UNUSED_ARG (bytes_returned); + ACE_UNUSED_ARG (overlapped); + ACE_UNUSED_ARG (func); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WINSOCK2 */ +} + + +int +ACE_OS::ioctl (ACE_HANDLE socket, + unsigned long io_control_code, + ACE_QoS &ace_qos, + unsigned long *bytes_returned, + void *buffer_p, + unsigned long buffer, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) +{ +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + + QOS qos; + unsigned long qos_len = sizeof (QOS); + + if (io_control_code == SIO_SET_QOS) + { + qos.SendingFlowspec = *(ace_qos.sending_flowspec ()); + qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ()); + qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific (); + + qos_len += ace_qos.provider_specific ().iov_len; + + ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, + io_control_code, + &qos, + qos_len, + buffer_p, + buffer, + bytes_returned, + (WSAOVERLAPPED *) overlapped, + func), + int, + SOCKET_ERROR); + } + else + { + unsigned long dwBufferLen = 0; + + // Query for the buffer size. + int result = ::WSAIoctl ((ACE_SOCKET) socket, + io_control_code, + NULL, + 0, + &dwBufferLen, + sizeof (dwBufferLen), + bytes_returned, + NULL, + NULL); + + + if (result == SOCKET_ERROR) + { + unsigned long dwErr = ::WSAGetLastError (); + + if (dwErr == WSAEWOULDBLOCK) + { + errno = dwErr; + return -1; + } + else + if (dwErr != WSAENOBUFS) + { + errno = dwErr; + return -1; + } + } + + char *qos_buf; + ACE_NEW_RETURN (qos_buf, + char [dwBufferLen], + -1); + + QOS *qos = ACE_reinterpret_cast (QOS*, + qos_buf); + + result = ::WSAIoctl ((ACE_SOCKET) socket, + io_control_code, + NULL, + 0, + qos, + dwBufferLen, + bytes_returned, + NULL, + NULL); + + if (result == SOCKET_ERROR) + return result; + + ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate, + qos->SendingFlowspec.TokenBucketSize, + qos->SendingFlowspec.PeakBandwidth, + qos->SendingFlowspec.Latency, + qos->SendingFlowspec.DelayVariation, +# if defined(ACE_HAS_WINSOCK2_GQOS) + qos->SendingFlowspec.ServiceType, + qos->SendingFlowspec.MaxSduSize, + qos->SendingFlowspec.MinimumPolicedSize, +# else /* ACE_HAS_WINSOCK2_GQOS */ + 0, + 0, + 0, +# endif /* ACE_HAS_WINSOCK2_GQOS */ + 0, + 0); + + ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate, + qos->ReceivingFlowspec.TokenBucketSize, + qos->ReceivingFlowspec.PeakBandwidth, + qos->ReceivingFlowspec.Latency, + qos->ReceivingFlowspec.DelayVariation, +# if defined(ACE_HAS_WINSOCK2_GQOS) + qos->ReceivingFlowspec.ServiceType, + qos->ReceivingFlowspec.MaxSduSize, + qos->ReceivingFlowspec.MinimumPolicedSize, +# else /* ACE_HAS_WINSOCK2_GQOS */ + 0, + 0, + 0, +# endif /* ACE_HAS_WINSOCK2_GQOS */ + 0, + 0); + + ace_qos.sending_flowspec (&sending_flowspec); + ace_qos.receiving_flowspec (&receiving_flowspec); + ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific))); + + + return result; + } + +# else + ACE_UNUSED_ARG (socket); + ACE_UNUSED_ARG (io_control_code); + ACE_UNUSED_ARG (ace_qos); + ACE_UNUSED_ARG (bytes_returned); + ACE_UNUSED_ARG (buffer_p); + ACE_UNUSED_ARG (buffer); + ACE_UNUSED_ARG (overlapped); + ACE_UNUSED_ARG (func); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WINSOCK2 */ +} + diff --git a/ace/OS_NS_stropts.h b/ace/OS_NS_stropts.h index fc532b41367..4660a2ff1f9 100644 --- a/ace/OS_NS_stropts.h +++ b/ace/OS_NS_stropts.h @@ -1,4 +1,146 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_stropts.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_STROPTS_H +# define ACE_OS_NS_STROPTS_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_Export.h" +#include "ace/os_include/os_stropts.h" +#include "ace/os_include/os_stdio.h" + +#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_Protocol_Info +{ + unsigned 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) (unsigned long error, + unsigned long bytes_transferred, + ACE_OVERLAPPED *overlapped, + unsigned long flags); +typedef unsigned long ACE_SOCK_GROUP; + +#endif /* (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ + +// @todo: move this to it's own file... dhinton +/** + * @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); + + /// Constructor. + ACE_Str_Buf (strbuf &); +}; + +class ACE_QoS; + +namespace ACE_OS { + + int getmsg (ACE_HANDLE handle, + struct strbuf *ctl, + struct strbuf + *data, int *flags); + int getpmsg (ACE_HANDLE handle, + struct strbuf *ctl, + struct strbuf + *data, + int *band, + int *flags); + + int fattach (int handle, + const char *path); + int fdetach (const char *file); + + /// UNIX-style <ioctl>. + int ioctl (ACE_HANDLE handle, + int cmd, + void * = 0); + +#if !defined (ACE_HAS_WINCE) + /// QoS-enabled <ioctl>. + int ioctl (ACE_HANDLE socket, + unsigned long io_control_code, + void *in_buffer_p, + unsigned long in_buffer, + void *out_buffer_p, + unsigned long out_buffer, + unsigned long *bytes_returned, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func); + + /// QoS-enabled <ioctl> when the I/O control code is either + /// SIO_SET_QOS or SIO_GET_QOS. + int ioctl (ACE_HANDLE socket, + unsigned long io_control_code, + ACE_QoS &ace_qos, + unsigned long *bytes_returned, + void *buffer_p = 0, + unsigned long buffer = 0, + ACE_OVERLAPPED *overlapped = 0, + ACE_OVERLAPPED_COMPLETION_FUNC func = 0); +#endif // ACE_HAS_WINCE + + int isastream (ACE_HANDLE handle); + + int putmsg (ACE_HANDLE handle, + const struct strbuf *ctl, + const struct strbuf *data, + int flags); + int putpmsg (ACE_HANDLE handle, + const struct strbuf *ctl, + const struct strbuf *data, + int band, + int flags); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_stropts.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_STROPTS_H */ diff --git a/ace/OS_NS_stropts.inl b/ace/OS_NS_stropts.inl index fc532b41367..8925801d6ba 100644 --- a/ace/OS_NS_stropts.inl +++ b/ace/OS_NS_stropts.inl @@ -1,4 +1,189 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/os_include/os_errno.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" + +#if defined (ACE_LACKS_CONST_STRBUF_PTR) +typedef struct strbuf *ACE_STRBUF_TYPE; +#else +typedef const struct strbuf *ACE_STRBUF_TYPE; +#endif /* ACE_LACKS_CONST_STRBUF_PTR */ + +ACE_INLINE +ACE_Str_Buf::ACE_Str_Buf (void *b, int l, int max) +{ + this->maxlen = max; + this->len = l; + this->buf = (char *) b; +} + +ACE_INLINE +ACE_Str_Buf::ACE_Str_Buf (strbuf &sb) +{ + this->maxlen = sb.maxlen; + this->len = sb.len; + this->buf = sb.buf; +} + +/*****************************************************************************/ + +ACE_INLINE int +ACE_OS::getmsg (ACE_HANDLE handle, + struct strbuf *ctl, + struct strbuf *data, + int *flags) +{ + ACE_OS_TRACE ("ACE_OS::getmsg"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1); +#else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (ctl); + ACE_UNUSED_ARG (data); + ACE_UNUSED_ARG (flags); + + // I'm not sure how to implement this correctly. + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE int +ACE_OS::getpmsg (ACE_HANDLE handle, + struct strbuf *ctl, + struct strbuf *data, + int *band, + int *flags) +{ + ACE_OS_TRACE ("ACE_OS::getpmsg"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1); +#else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (ctl); + ACE_UNUSED_ARG (data); + ACE_UNUSED_ARG (band); + ACE_UNUSED_ARG (flags); + + // I'm not sure how to implement this correctly. + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE int +ACE_OS::fattach (int handle, const char *path) +{ + ACE_OS_TRACE ("ACE_OS::fattach"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::fattach (handle, path), int, -1); +#else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (path); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE int +ACE_OS::fdetach (const char *file) +{ + ACE_OS_TRACE ("ACE_OS::fdetach"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::fdetach (file), int, -1); +#else + ACE_UNUSED_ARG (file); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE int +ACE_OS::ioctl (ACE_HANDLE handle, + int cmd, + void *val) +{ + ACE_OS_TRACE ("ACE_OS::ioctl"); + +#if defined (ACE_WIN32) + ACE_SOCKET sock = (ACE_SOCKET) handle; + ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, (unsigned long *) val), int, -1); +#elif defined (VXWORKS) + ACE_OSCALL_RETURN (::ioctl (handle, cmd, ACE_reinterpret_cast (int, val)), + int, -1); +#elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (::ioctl (handle, cmd, (char *) val), int, -1); +#else + ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::isastream (ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::isastream"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::isastream (handle), int, -1); +#else + ACE_UNUSED_ARG (handle); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE int +ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl, + const struct strbuf *data, int flags) +{ + ACE_OS_TRACE ("ACE_OS::putmsg"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::putmsg (handle, + (ACE_STRBUF_TYPE) ctl, + (ACE_STRBUF_TYPE) data, + flags), int, -1); +#else + ACE_UNUSED_ARG (flags); + if (ctl == 0 && data == 0) + { + errno = EINVAL; + return 0; + } + // Handle the two easy cases. + else if (ctl != 0) + return ACE_OS::write (handle, ctl->buf, ctl->len); + else if (data != 0) + return ACE_OS::write (handle, data->buf, data->len); + else + { + // This is the hard case. + char *buf; + ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1); + ACE_OS::memcpy (buf, ctl->buf, ctl->len); + ACE_OS::memcpy (buf + ctl->len, data->buf, data->len); + int result = ACE_OS::write (handle, buf, ctl->len + data->len); + delete [] buf; + return result; + } +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE int +ACE_OS::putpmsg (ACE_HANDLE handle, + const struct strbuf *ctl, + const struct strbuf *data, + int band, + int flags) +{ + ACE_OS_TRACE ("ACE_OS::putpmsg"); +#if defined (ACE_HAS_STREAM_PIPES) + ACE_OSCALL_RETURN (::putpmsg (handle, + (ACE_STRBUF_TYPE) ctl, + (ACE_STRBUF_TYPE) data, + band, flags), int, -1); +#else + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (band); + return ACE_OS::putmsg (handle, ctl, data, flags); +#endif /* ACE_HAS_STREAM_PIPES */ +} diff --git a/ace/OS_NS_sys_mman.cpp b/ace/OS_NS_sys_mman.cpp index fc532b41367..5a9c10ce148 100644 --- a/ace/OS_NS_sys_mman.cpp +++ b/ace/OS_NS_sys_mman.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_mman.h" + +ACE_RCSID(ace, OS_NS_sys_mman, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_mman.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_sys_mman.h b/ace/OS_NS_sys_mman.h index fc532b41367..f9bcb7e353b 100644 --- a/ace/OS_NS_sys_mman.h +++ b/ace/OS_NS_sys_mman.h @@ -1,4 +1,73 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_mman.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_MMAN_H +# define ACE_OS_NS_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 */ + +#include "ace/Global_Macros.h" +#include "ace/os_include/sys/os_types.h" + +namespace ACE_OS { + + //@{ @name A set of wrappers for memory mapped files. + int madvise (caddr_t addr, + size_t len, + int map_advice); + void *mmap (void *addr, + size_t len, + int prot, + int flags, + ACE_HANDLE handle, + off_t off = 0, + ACE_HANDLE *file_mapping = 0, + LPSECURITY_ATTRIBUTES sa = 0, + const ACE_TCHAR *file_mapping_name = 0); + int mprotect (void *addr, + size_t len, + int prot); + int msync (void *addr, + size_t len, + int sync); + int munmap (void *addr, + size_t len); + //@} + + ACE_HANDLE shm_open (const ACE_TCHAR *filename, + int mode, + int perms = 0, + LPSECURITY_ATTRIBUTES sa = 0); + int shm_unlink (const ACE_TCHAR *path); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_mman.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_MMAN_H */ diff --git a/ace/OS_NS_sys_mman.inl b/ace/OS_NS_sys_mman.inl index fc532b41367..dd93e204e5f 100644 --- a/ace/OS_NS_sys_mman.inl +++ b/ace/OS_NS_sys_mman.inl @@ -1,4 +1,319 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_NS_unistd.h" +#include "ace/os_include/sys/os_mman.h" + +#if defined (ACE_HAS_VOIDPTR_MMAP) +// Needed for some odd OS's (e.g., SGI). +typedef void *ACE_MMAP_TYPE; +#else +typedef char *ACE_MMAP_TYPE; +#endif /* ACE_HAS_VOIDPTR_MMAP */ + +ACE_INLINE int +ACE_OS::madvise (caddr_t addr, size_t len, int map_advice) +{ + ACE_OS_TRACE ("ACE_OS::madvise"); +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (map_advice); + + ACE_NOTSUP_RETURN (-1); +#elif !defined (ACE_LACKS_MADVISE) + ACE_OSCALL_RETURN (::madvise (addr, len, map_advice), int, -1); +#else + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (map_advice); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE void * +ACE_OS::mmap (void *addr, + size_t len, + int prot, + int flags, + ACE_HANDLE file_handle, + off_t off, + ACE_HANDLE *file_mapping, + LPSECURITY_ATTRIBUTES sa, + const ACE_TCHAR *file_mapping_name) +{ + ACE_OS_TRACE ("ACE_OS::mmap"); +#if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) + ACE_UNUSED_ARG (file_mapping_name); +#endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */ + +#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) + +# if defined(ACE_HAS_WINCE) + ACE_UNUSED_ARG (addr); + if (ACE_BIT_ENABLED (flags, MAP_FIXED)) // not supported + { + errno = EINVAL; + return MAP_FAILED; + } +# else + if (!ACE_BIT_ENABLED (flags, MAP_FIXED)) + addr = 0; + else if (addr == 0) // can not map to address 0 + { + errno = EINVAL; + return MAP_FAILED; + } +# endif + + int nt_flags = 0; + ACE_HANDLE local_handle = ACE_INVALID_HANDLE; + + // Ensure that file_mapping is non-zero. + if (file_mapping == 0) + file_mapping = &local_handle; + + if (ACE_BIT_ENABLED (flags, MAP_PRIVATE)) + { +# if !defined(ACE_HAS_WINCE) + prot = PAGE_WRITECOPY; +# endif // ACE_HAS_WINCE + nt_flags = FILE_MAP_COPY; + } + else if (ACE_BIT_ENABLED (flags, MAP_SHARED)) + { + if (ACE_BIT_ENABLED (prot, PAGE_READONLY)) + nt_flags = FILE_MAP_READ; + if (ACE_BIT_ENABLED (prot, PAGE_READWRITE)) + nt_flags = FILE_MAP_WRITE; + } + + // Only create a new handle if we didn't have a valid one passed in. + if (*file_mapping == ACE_INVALID_HANDLE) + { +# if !defined(ACE_HAS_WINCE) && (!defined (ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0)) + int try_create = 1; + if ((file_mapping_name != 0) && (*file_mapping_name != 0)) + { + // On Win9x, we first try to OpenFileMapping to + // file_mapping_name. Only if there is no mapping object + // with that name, and the desired name is valid, do we try + // CreateFileMapping. + + *file_mapping = ACE_TEXT_OpenFileMapping (nt_flags, + 0, + file_mapping_name); + if (*file_mapping != 0 + || (::GetLastError () == ERROR_INVALID_NAME + && ::GetLastError () == ERROR_FILE_NOT_FOUND)) + try_create = 0; + } + + if (try_create) +# endif /* !ACE_HAS_WINCE && (ACE_HAS_WINNT4 || ACE_HAS_WINNT4 == 0) */ + { + const LPSECURITY_ATTRIBUTES attr = + ACE_OS::default_win32_security_attributes (sa); + + *file_mapping = ACE_TEXT_CreateFileMapping (file_handle, + attr, + prot, + 0, + 0, + file_mapping_name); + } + } + + if (*file_mapping == 0) + ACE_FAIL_RETURN (MAP_FAILED); + +# if defined (ACE_OS_EXTRA_MMAP_FLAGS) + nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS; +# endif /* ACE_OS_EXTRA_MMAP_FLAGS */ + +# if !defined (ACE_HAS_WINCE) + void *addr_mapping = ::MapViewOfFileEx (*file_mapping, + nt_flags, + 0, + off, + len, + addr); +# else + void *addr_mapping = ::MapViewOfFile (*file_mapping, + nt_flags, + 0, + off, + len); +# endif /* ! ACE_HAS_WINCE */ + + // Only close this down if we used the temporary. + if (file_mapping == &local_handle) + ::CloseHandle (*file_mapping); + + if (addr_mapping == 0) + ACE_FAIL_RETURN (MAP_FAILED); + else + return addr_mapping; +#elif defined (__Lynx__) + // The LynxOS 2.5.0 mmap doesn't allow operations on plain + // file descriptors. So, create a shm object and use that. + ACE_UNUSED_ARG (sa); + + char name [128]; + sprintf (name, "%d", file_handle); + + // Assumes that this was called by ACE_Mem_Map, so &file_mapping != + // 0. Otherwise, we don't support the incomplete LynxOS mmap + // implementation. We do support it by creating a hidden shared + // memory object, and using that for the mapping. + int shm_handle; + if (! file_mapping) + file_mapping = &shm_handle; + if ((*file_mapping = ::shm_open (name, + O_RDWR | O_CREAT | O_TRUNC, + ACE_DEFAULT_FILE_PERMS)) == -1) + return MAP_FAILED; + else + { + // The size of the shared memory object must be explicitly set on LynxOS. + const off_t filesize = ACE_OS::filesize (file_handle); + if (::ftruncate (*file_mapping, filesize) == -1) + return MAP_FAILED; + else + { +# if defined (ACE_OS_EXTRA_MMAP_FLAGS) + flags |= ACE_OS_EXTRA_MMAP_FLAGS; +# endif /* ACE_OS_EXTRA_MMAP_FLAGS */ + char *map = (char *) ::mmap ((ACE_MMAP_TYPE) addr, + len, + prot, + flags, + *file_mapping, + off); + if (map == MAP_FAILED) + return MAP_FAILED; + else + // Finally, copy the file contents to the shared memory object. + return ::read (file_handle, map, (int) filesize) == filesize + ? map + : MAP_FAILED; + } + } +#elif !defined (ACE_LACKS_MMAP) + ACE_UNUSED_ARG (sa); + +# if defined (ACE_OS_EXTRA_MMAP_FLAGS) + flags |= ACE_OS_EXTRA_MMAP_FLAGS; +# endif /* ACE_OS_EXTRA_MMAP_FLAGS */ + ACE_UNUSED_ARG (file_mapping); + ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr, + len, + prot, + flags, + file_handle, + off), + void *, MAP_FAILED); +#else + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (prot); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (file_handle); + ACE_UNUSED_ARG (off); + ACE_UNUSED_ARG (file_mapping); + ACE_UNUSED_ARG (sa); + ACE_NOTSUP_RETURN (MAP_FAILED); +#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ +} + +// Implements simple read/write control for pages. Affects a page if +// part of the page is referenced. Currently PROT_READ, PROT_WRITE, +// and PROT_RDWR has been mapped in OS.h. This needn't have anything +// to do with a mmap region. + +ACE_INLINE int +ACE_OS::mprotect (void *addr, size_t len, int prot) +{ + ACE_OS_TRACE ("ACE_OS::mprotect"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) + DWORD dummy; // Sigh! + return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1; +#elif !defined (ACE_LACKS_MPROTECT) + ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1); +#else + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (prot); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ +} + +ACE_INLINE int +ACE_OS::msync (void *addr, size_t len, int sync) +{ + ACE_OS_TRACE ("ACE_OS::msync"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) + ACE_UNUSED_ARG (sync); + + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1); +#elif !defined (ACE_LACKS_MSYNC) +# if !defined (ACE_HAS_BROKEN_NETBSD_MSYNC) + ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1); +# else + ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len), int, -1); + ACE_UNUSED_ARG (sync); +# endif /* ACE_HAS_BROKEN_NETBSD_MSYNC */ +#else + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (sync); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ +} + +ACE_INLINE int +ACE_OS::munmap (void *addr, size_t len) +{ + ACE_OS_TRACE ("ACE_OS::munmap"); +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (len); + + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1); +#elif !defined (ACE_LACKS_MMAP) + ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1); +#else + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE ACE_HANDLE +ACE_OS::shm_open (const ACE_TCHAR *filename, + int mode, + int perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_OS_TRACE ("ACE_OS::shm_open"); +# if defined (ACE_HAS_SHM_OPEN) + ACE_UNUSED_ARG (sa); + ACE_OSCALL_RETURN (::shm_open (filename, mode, perms), ACE_HANDLE, -1); +# else /* ! ACE_HAS_SHM_OPEN */ + // Just use ::open. + return ACE_OS::open (filename, mode, perms, sa); +# endif /* ACE_HAS_SHM_OPEN */ +} + +ACE_INLINE int +ACE_OS::shm_unlink (const ACE_TCHAR *path) +{ + ACE_OS_TRACE ("ACE_OS::shm_unlink"); +# if defined (ACE_HAS_SHM_OPEN) + ACE_OSCALL_RETURN (::shm_unlink (path), int, -1); +# else /* ! ACE_HAS_SHM_OPEN */ + // Just use ::unlink. + return ACE_OS::unlink (path); +# endif /* ACE_HAS_SHM_OPEN */ +} + diff --git a/ace/OS_NS_sys_msg.cpp b/ace/OS_NS_sys_msg.cpp index fc532b41367..917121a8680 100644 --- a/ace/OS_NS_sys_msg.cpp +++ b/ace/OS_NS_sys_msg.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_msg.h" + +ACE_RCSID(ace, OS_NS_sys_msg, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_msg.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_sys_msg.h b/ace/OS_NS_sys_msg.h index fc532b41367..2a20bc77cf2 100644 --- a/ace/OS_NS_sys_msg.h +++ b/ace/OS_NS_sys_msg.h @@ -1,4 +1,60 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_msg.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_MSG_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_msg.h" + +namespace ACE_OS { + + //@{ @name A set of wrappers for System V message queues. + int msgctl (int msqid, + int cmd, + struct msqid_ds *); + int msgget (key_t key, + int msgflg); + int msgrcv (int int_id, + void *buf, + size_t len, + long type, + int flags); + int msgsnd (int int_id, + const void *buf, + size_t len, + int flags); + //@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_msg.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_MSG_H */ diff --git a/ace/OS_NS_sys_msg.inl b/ace/OS_NS_sys_msg.inl index fc532b41367..f09e2b4895a 100644 --- a/ace/OS_NS_sys_msg.inl +++ b/ace/OS_NS_sys_msg.inl @@ -1,4 +1,78 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE int +ACE_OS::msgctl (int msqid, int cmd, struct msqid_ds *val) +{ + ACE_OS_TRACE ("ACE_OS::msgctl"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::msgctl (msqid, cmd, val), int, -1); +#else + ACE_UNUSED_ARG (msqid); + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (val); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::msgget (key_t key, int msgflg) +{ + ACE_OS_TRACE ("ACE_OS::msgget"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::msgget (key, msgflg), int, -1); +#else + ACE_UNUSED_ARG (key); + ACE_UNUSED_ARG (msgflg); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::msgrcv (int int_id, void *buf, size_t len, + long type, int flags) +{ + ACE_OS_TRACE ("ACE_OS::msgrcv"); +#if defined (ACE_HAS_SYSV_IPC) +# if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::msgrcv (int_id, (msgbuf *) buf, len, type, flags), + int, -1); +# else + ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags), + int, -1); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ +#else + ACE_UNUSED_ARG (int_id); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (flags); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::msgsnd (int int_id, const void *buf, size_t len, int flags) +{ + ACE_OS_TRACE ("ACE_OS::msgsnd"); +#if defined (ACE_HAS_SYSV_IPC) +# if defined (ACE_HAS_NONCONST_MSGSND) + ACE_OSCALL_RETURN (::msgsnd (int_id, (void *) buf, len, flags), int, -1); +# elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::msgsnd (int_id, (msgbuf *) buf, len, flags), int, -1); +# else + ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1); +# endif /* ACE_LACKS_POSIX_PROTOTYPES || ACE_HAS_NONCONST_MSGSND */ +#else + ACE_UNUSED_ARG (int_id); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (len); + ACE_UNUSED_ARG (flags); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + diff --git a/ace/OS_NS_sys_resource.cpp b/ace/OS_NS_sys_resource.cpp index fc532b41367..3499e4bfc5c 100644 --- a/ace/OS_NS_sys_resource.cpp +++ b/ace/OS_NS_sys_resource.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_resource.h" + +ACE_RCSID(ace, OS_NS_sys_resource, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_resource.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_sys_resource.h b/ace/OS_NS_sys_resource.h index fc532b41367..54dcf186ef9 100644 --- a/ace/OS_NS_sys_resource.h +++ b/ace/OS_NS_sys_resource.h @@ -1,4 +1,53 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_resource.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_RESOURCE_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_resource.h" + +namespace ACE_OS { + + int getrlimit (int resource, + struct rlimit *rl); + + int getrusage (int who, + struct rusage *rusage); + + + int setrlimit (int resource, + ACE_SETRLIMIT_TYPE *rl); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_resource.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_RESOURCE_H */ diff --git a/ace/OS_NS_sys_resource.inl b/ace/OS_NS_sys_resource.inl index fc532b41367..a061e888b54 100644 --- a/ace/OS_NS_sys_resource.inl +++ b/ace/OS_NS_sys_resource.inl @@ -1,4 +1,78 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_errno.h" + +ACE_INLINE int +ACE_OS::getrlimit (int resource, struct rlimit *rl) +{ + ACE_OS_TRACE ("ACE_OS::getrlimit"); + +#if defined (ACE_LACKS_RLIMIT) + ACE_UNUSED_ARG (resource); + ACE_UNUSED_ARG (rl); + + ACE_NOTSUP_RETURN (-1); +#else +# if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM) + ACE_OSCALL_RETURN (::getrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1); +# else + ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1); +# endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ +#endif /* ACE_LACKS_RLIMIT */ +} + +ACE_INLINE int +ACE_OS::getrusage (int who, struct rusage *ru) +{ + ACE_OS_TRACE ("ACE_OS::getrusage"); + +#if defined (ACE_HAS_SYSCALL_GETRUSAGE) + // This nonsense is necessary for HP/UX... + ACE_OSCALL_RETURN (::syscall (SYS_GETRUSAGE, who, ru), int, -1); +#elif defined (ACE_HAS_GETRUSAGE) +# if defined (ACE_WIN32) + ACE_UNUSED_ARG (who); + + FILETIME dummy_1; + FILETIME dummy_2; + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetProcessTimes (::GetCurrentProcess(), + &dummy_1, // start + &dummy_2, // exited + &ru->ru_stime, + &ru->ru_utime), + ace_result_), + int, -1); +# else +# if defined (ACE_HAS_RUSAGE_WHO_ENUM) + ACE_OSCALL_RETURN (::getrusage ((ACE_HAS_RUSAGE_WHO_ENUM) who, ru), int, -1); +# else + ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1); +# endif /* ACE_HAS_RUSAGE_WHO_ENUM */ +# endif /* ACE_WIN32 */ +#else + who = who; + ru = ru; + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSCALL_GETRUSAGE */ +} + +ACE_INLINE int +ACE_OS::setrlimit (int resource, ACE_SETRLIMIT_TYPE *rl) +{ + ACE_OS_TRACE ("ACE_OS::setrlimit"); + +#if defined (ACE_LACKS_RLIMIT) + ACE_UNUSED_ARG (resource); + ACE_UNUSED_ARG (rl); + + ACE_NOTSUP_RETURN (-1); +#else +# if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM) + ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1); +# else + ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1); +# endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ +#endif /* ACE_LACKS_RLIMIT */ +} + diff --git a/ace/OS_NS_sys_select.cpp b/ace/OS_NS_sys_select.cpp index fc532b41367..fb2bc11b1b2 100644 --- a/ace/OS_NS_sys_select.cpp +++ b/ace/OS_NS_sys_select.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_select.h" + +ACE_RCSID(ace, OS_NS_sys_select, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_select.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_sys_select.h b/ace/OS_NS_sys_select.h index fc532b41367..256f5fad57a 100644 --- a/ace/OS_NS_sys_select.h +++ b/ace/OS_NS_sys_select.h @@ -1,4 +1,57 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_select.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_SELECT_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_select.h" + +class ACE_Time_Value; + +namespace ACE_OS { + + // Should be moved to cpp or inl. + int select (int width, + fd_set *rfds, + fd_set *wfds = 0, + fd_set *efds = 0, + const ACE_Time_Value *tv = 0); + int select (int width, + fd_set *rfds, + fd_set *wfds, + fd_set *efds, + const ACE_Time_Value &tv); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_select.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_SELECT_H */ diff --git a/ace/OS_NS_sys_select.inl b/ace/OS_NS_sys_select.inl index fc532b41367..26d52eac344 100644 --- a/ace/OS_NS_sys_select.inl +++ b/ace/OS_NS_sys_select.inl @@ -1,4 +1,59 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/Time_Value.h" +#include "ace/OS_NS_macros.h" + +// It would be really cool to add another version of select that would +// function like the one we're defending against below! +ACE_INLINE int +ACE_OS::select (int width, + fd_set *rfds, fd_set *wfds, fd_set *efds, + const ACE_Time_Value *timeout) +{ + ACE_OS_TRACE ("ACE_OS::select"); +#if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) + // We must defend against non-conformity! + timeval copy; + timeval *timep; + + if (timeout != 0) + { + copy = *timeout; + timep = © + } + else + timep = 0; +#else + const timeval *timep = (timeout == 0 ? (const timeval *)0 : *timeout); +#endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ + ACE_SOCKCALL_RETURN (::select (width, + (ACE_FD_SET_TYPE *) rfds, + (ACE_FD_SET_TYPE *) wfds, + (ACE_FD_SET_TYPE *) efds, + timep), + int, -1); +} + +ACE_INLINE int +ACE_OS::select (int width, + fd_set *rfds, fd_set *wfds, fd_set *efds, + const ACE_Time_Value &timeout) +{ + ACE_OS_TRACE ("ACE_OS::select"); +#if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) +# define ___ACE_TIMEOUT © + timeval copy = timeout; +#else +# define ___ACE_TIMEOUT timep + const timeval *timep = timeout; +#endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ + ACE_SOCKCALL_RETURN (::select (width, + (ACE_FD_SET_TYPE *) rfds, + (ACE_FD_SET_TYPE *) wfds, + (ACE_FD_SET_TYPE *) efds, + ___ACE_TIMEOUT), + int, -1); +#undef ___ACE_TIMEOUT +} + diff --git a/ace/OS_NS_sys_shm.cpp b/ace/OS_NS_sys_shm.cpp index fc532b41367..33474349f7f 100644 --- a/ace/OS_NS_sys_shm.cpp +++ b/ace/OS_NS_sys_shm.cpp @@ -1,4 +1,17 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_shm.h" + +ACE_RCSID(ace, OS_NS_sys_shm, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_shm.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +// these don't appear to be used anywhere. dhinton +#if defined(INTEGRITY) && defined(ACE_HAS_SHM_OPEN) +char* shm_area_name = "ACE_Area"; +char* shm_area_password = "******"; +#endif + diff --git a/ace/OS_NS_sys_shm.h b/ace/OS_NS_sys_shm.h index fc532b41367..1f45bf90a7a 100644 --- a/ace/OS_NS_sys_shm.h +++ b/ace/OS_NS_sys_shm.h @@ -1,4 +1,56 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_shm.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_SHM_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_shm.h" + +namespace ACE_OS { + + //@{ @name A set of wrappers for System V shared memory. + void *shmat (int int_id, + void *shmaddr, + int shmflg); + int shmctl (int int_id, + int cmd, + struct shmid_ds *buf); + int shmdt (void *shmaddr); + int shmget (key_t key, + int size, + int flags); + ///@} + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_shm.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_SHM_H */ diff --git a/ace/OS_NS_sys_shm.inl b/ace/OS_NS_sys_shm.inl index fc532b41367..0e7cf34c070 100644 --- a/ace/OS_NS_sys_shm.inl +++ b/ace/OS_NS_sys_shm.inl @@ -1,4 +1,65 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE void * +ACE_OS::shmat (int int_id, void *shmaddr, int shmflg) +{ + ACE_OS_TRACE ("ACE_OS::shmat"); +#if defined (ACE_HAS_SYSV_IPC) +# if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::shmat (int_id, (char *)shmaddr, shmflg), void *, (void *) -1); +# else + ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ +#else + ACE_UNUSED_ARG (int_id); + ACE_UNUSED_ARG (shmaddr); + ACE_UNUSED_ARG (shmflg); + + ACE_NOTSUP_RETURN ((void *) -1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::shmctl (int int_id, int cmd, struct shmid_ds *buf) +{ + ACE_OS_TRACE ("ACE_OS::shmctl"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1); +#else + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (int_id); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::shmdt (void *shmaddr) +{ + ACE_OS_TRACE ("ACE_OS::shmdt"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::shmdt ((char *) shmaddr), int, -1); +#else + ACE_UNUSED_ARG (shmaddr); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + +ACE_INLINE int +ACE_OS::shmget (key_t key, int size, int flags) +{ + ACE_OS_TRACE ("ACE_OS::shmget"); +#if defined (ACE_HAS_SYSV_IPC) + ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1); +#else + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (size); + ACE_UNUSED_ARG (key); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_SYSV_IPC */ +} + diff --git a/ace/OS_NS_sys_socket.cpp b/ace/OS_NS_sys_socket.cpp index fc532b41367..0cfdbbc19da 100644 --- a/ace/OS_NS_sys_socket.cpp +++ b/ace/OS_NS_sys_socket.cpp @@ -1,4 +1,159 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_socket.h" + +ACE_RCSID(ace, OS_NS_sys_socket, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_socket.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#if defined (ACE_WIN32) +int ACE_OS::socket_initialized_; +#endif /* ACE_WIN32 */ + +#if !defined (ACE_HAS_WINCE) +ACE_HANDLE +ACE_OS::accept (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen, + const ACE_Accept_QoS_Params &qos_params) +{ +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN *) addrlen, + (LPCONDITIONPROC) qos_params.qos_condition_callback (), + qos_params.callback_data ()), + ACE_HANDLE, + ACE_INVALID_HANDLE); +# else + ACE_UNUSED_ARG (qos_params); + return ACE_OS::accept (handle, + addr, + addrlen); +# endif /* ACE_HAS_WINSOCK2 */ +} + +int +ACE_OS::connect (ACE_HANDLE handle, + const sockaddr *addr, + int addrlen, + const ACE_QoS_Params &qos_params) +{ + ACE_OS_TRACE ("ACE_OS::connect"); +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle, + (const sockaddr *) addr, + (ACE_SOCKET_LEN) addrlen, + (WSABUF *) qos_params.caller_data (), + (WSABUF *) qos_params.callee_data (), + (QOS *) qos_params.socket_qos (), + (QOS *) qos_params.group_socket_qos ()), + int, -1); +# else + ACE_UNUSED_ARG (qos_params); + return ACE_OS::connect (handle, + (sockaddr *) addr, + addrlen); +# endif /* ACE_HAS_WINSOCK2 */ +} +#endif // ACE_HAS_WINCE + +ACE_HANDLE +ACE_OS::join_leaf (ACE_HANDLE socket, + const sockaddr *name, + int namelen, + const ACE_QoS_Params &qos_params) +{ +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + + QOS qos; + // Construct the WinSock2 QOS structure. + + qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ()); + qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ()); + qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific (); + + ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket, + name, + namelen, + (WSABUF *) qos_params.caller_data (), + (WSABUF *) qos_params.callee_data (), + &qos, + (QOS *) qos_params.group_socket_qos (), + qos_params.flags ()), + ACE_HANDLE, + ACE_INVALID_HANDLE); + +# else + ACE_UNUSED_ARG (socket); + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (namelen); + ACE_UNUSED_ARG (qos_params); + ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); +# endif /* ACE_HAS_WINSOCK2 */ +} + +int +ACE_OS::socket_init (int version_high, int version_low) +{ +# if defined (ACE_WIN32) + if (ACE_OS::socket_initialized_ == 0) + { + WORD version_requested = MAKEWORD (version_high, version_low); + WSADATA wsa_data; + int error = WSAStartup (version_requested, &wsa_data); + + if (error != 0) +# if defined (ACE_HAS_WINCE) + { + wchar_t fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d"); + wchar_t buf[80]; // @@ Eliminate magic number. + ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSAStartup"), error); + ::MessageBox (0, buf, ACE_LIB_TEXT ("WSAStartup failed!"), MB_OK); + } +# else + ACE_OS::fprintf (stderr, + "ACE_OS::socket_init; WSAStartup failed, " + "WSAGetLastError returned %d\n", + error); +# endif /* ACE_HAS_WINCE */ + + ACE_OS::socket_initialized_ = 1; + } +# else + ACE_UNUSED_ARG (version_high); + ACE_UNUSED_ARG (version_low); +# endif /* ACE_WIN32 */ + return 0; +} + +int +ACE_OS::socket_fini (void) +{ +# if defined (ACE_WIN32) + if (ACE_OS::socket_initialized_ != 0) + { + if (WSACleanup () != 0) + { + int error = ::WSAGetLastError (); +# if defined (ACE_HAS_WINCE) + wchar_t fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d"); + wchar_t buf[80]; // @@ Eliminate magic number. + ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSACleanup"), error); + ::MessageBox (0, buf , ACE_LIB_TEXT ("WSACleanup failed!"), MB_OK); +# else + ACE_OS::fprintf (stderr, + "ACE_OS::socket_fini; WSACleanup failed, " + "WSAGetLastError returned %d\n", + error); +# endif /* ACE_HAS_WINCE */ + } + ACE_OS::socket_initialized_ = 0; + } +# endif /* ACE_WIN32 */ + return 0; +} + diff --git a/ace/OS_NS_sys_socket.h b/ace/OS_NS_sys_socket.h index fc532b41367..afde45c8a5c 100644 --- a/ace/OS_NS_sys_socket.h +++ b/ace/OS_NS_sys_socket.h @@ -1,4 +1,222 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_socket.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_SOCKET_H +# define ACE_OS_NS_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/sys/os_socket.h" +#include "ace/OS_NS_stropts.h" + +class ACE_Accept_QoS_Params; +class ACE_QoS_Params; + +namespace ACE_OS { + +# if defined (ACE_WIN32) + /// Keeps track of whether we've already initialized WinSock... + extern int socket_initialized_; +# endif /* ACE_WIN32 */ + + //@{ @name A set of wrappers for sockets. + /// BSD-style <accept> (no QoS). + ACE_HANDLE accept (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen); + +#if !defined (ACE_HAS_WINCE) + /** + * QoS-enabled <accept>, which passes <qos_params> to <accept>. If + * the OS platform doesn't support QoS-enabled <accept> then the + * <qos_params> are ignored and the BSD-style <accept> is called. + */ + ACE_HANDLE accept (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen, + const ACE_Accept_QoS_Params &qos_params); +#endif // ACE_HAS_WINCE + + int bind (ACE_HANDLE s, + struct sockaddr *name, + int namelen); + + // takes care of windows specific requirement to call closesocket + int closesocket (ACE_HANDLE s); + + /// BSD-style <connect> (no QoS). + int connect (ACE_HANDLE handle, + struct sockaddr *addr, + int addrlen); + +#if !defined (ACE_HAS_WINCE) + /** + * QoS-enabled <connect>, which passes <qos_params> to <connect>. + * If the OS platform doesn't support QoS-enabled <connect> then the + * <qos_params> are ignored and the BSD-style <connect> is called. + */ + int connect (ACE_HANDLE handle, + const sockaddr *addr, + int addrlen, + const ACE_QoS_Params &qos_params); +#endif // ACE_HAS_WINCE + + /// Retrieve information about available transport protocols + /// installed on the local machine. Windows specific... + int enum_protocols (int *protocols, + ACE_Protocol_Info *protocol_buffer, + u_long *buffer_length); + + int getpeername (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen); + + int getsockname (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen); + int getsockopt (ACE_HANDLE handle, + int level, + int optname, + char *optval, + int *optlen); + +#if !defined (ACE_HAS_WINCE) + /// Joins a leaf node into a QoS-enabled multi-point session. + ACE_HANDLE join_leaf (ACE_HANDLE socket, + const sockaddr *name, + int namelen, + const ACE_QoS_Params &qos_params); +#endif // ACE_HAS_WINCE + + int listen (ACE_HANDLE handle, + int backlog); + + int recv (ACE_HANDLE handle, + char *buf, + size_t len, + int flags = 0); + + int recvfrom (ACE_HANDLE handle, + char *buf, + size_t len, + int flags, + struct sockaddr *addr, + int *addrlen); + + int recvfrom (ACE_HANDLE handle, + iovec *buffers, + int buffer_count, + size_t &number_of_bytes_recvd, + int &flags, + struct sockaddr *addr, + int *addrlen, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func); + + int recvmsg (ACE_HANDLE handle, + struct msghdr *msg, + int flags); + + ssize_t recvv (ACE_HANDLE handle, + iovec *iov, + int iovlen); + + int send (ACE_HANDLE handle, + const char *buf, + size_t len, + int flags = 0); + + int sendmsg (ACE_HANDLE handle, + const struct msghdr *msg, + int flags); + + int sendto (ACE_HANDLE handle, + const char *buf, + size_t len, + int flags, + const struct sockaddr *addr, + int addrlen); + + int sendto (ACE_HANDLE handle, + const iovec *buffers, + int buffer_count, + size_t &number_of_bytes_sent, + int flags, + const struct sockaddr *addr, + int addrlen, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func); + + ssize_t sendv (ACE_HANDLE handle, + const iovec *iov, + int iovcnt); + + + /// Manipulate the options associated with a socket. + int setsockopt (ACE_HANDLE handle, + int level, + int optname, + const char *optval, + int optlen); + + int shutdown (ACE_HANDLE handle, + int how); + + /// Initialize WinSock before first use (e.g., when a DLL is first + /// loaded or the first use of a socket() call. + int socket_init (int version_high = 1, + int version_low = 1); + + /// Finalize WinSock after last use (e.g., when a DLL is unloaded). + int socket_fini (void); + + /// Create a BSD-style socket (no QoS). + ACE_HANDLE socket (int protocol_family, + int type, + int proto); + + /// Create a QoS-enabled socket. If the OS platform doesn't support + /// QoS-enabled <socket> then the BSD-style <socket> is called. + ACE_HANDLE socket (int protocol_family, + int type, + int proto, + ACE_Protocol_Info *protocolinfo, + ACE_SOCK_GROUP g, + u_long flags); + + int socketpair (int domain, + int type, + int protocol, + ACE_HANDLE sv[2]); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_socket.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_SOCKET_H */ diff --git a/ace/OS_NS_sys_socket.inl b/ace/OS_NS_sys_socket.inl index fc532b41367..631fc3fb85a 100644 --- a/ace/OS_NS_sys_socket.inl +++ b/ace/OS_NS_sys_socket.inl @@ -1,4 +1,736 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_macros.h" +#include "ace/OS_NS_sys_uio.h" + +#if defined (ACE_HAS_VOIDPTR_SOCKOPT) +typedef void *ACE_SOCKOPT_TYPE1; +#elif defined (ACE_HAS_CHARPTR_SOCKOPT) +typedef char *ACE_SOCKOPT_TYPE1; +#else +typedef const char *ACE_SOCKOPT_TYPE1; +#endif /* ACE_HAS_VOIDPTR_SOCKOPT */ + +ACE_INLINE ACE_HANDLE +ACE_OS::accept (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen) +{ + ACE_OS_TRACE ("ACE_OS::accept"); +#if defined (ACE_PSOS) +# if !defined (ACE_PSOS_DIAB_PPC) + ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, + (struct sockaddr_in *) addr, + (ACE_SOCKET_LEN *) addrlen), + ACE_HANDLE, + ACE_INVALID_HANDLE); +# else + ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, + (struct sockaddr *) addr, + (ACE_SOCKET_LEN *) addrlen), + ACE_HANDLE, + ACE_INVALID_HANDLE); +# endif /* defined ACE_PSOS_DIAB_PPC */ +#else + // On a non-blocking socket with no connections to accept, this + // system call will return EWOULDBLOCK or EAGAIN, depending on the + // platform. UNIX 98 allows either errno, and they may be the same + // numeric value. So to make life easier for upper ACE layers as + // well as application programmers, always change EAGAIN to + // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's + // handled explicitly here. If the ACE_OSCALL macro ever changes, + // this function needs to be reviewed. On Win32, the regular macros + // can be used, as this is not an issue. + +# if defined (ACE_WIN32) + ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN *) addrlen), + ACE_HANDLE, + ACE_INVALID_HANDLE); +# else +# if defined (ACE_HAS_BROKEN_ACCEPT_ADDR) + // Apparently some platforms like VxWorks can't correctly deal with + // a NULL addr. + + sockaddr_in fake_addr; + int fake_addrlen; + + if (addrlen == 0) + addrlen = &fake_addrlen; + + if (addr == 0) + { + addr = (sockaddr *) &fake_addr; + *addrlen = sizeof fake_addr; + } +# endif /* VXWORKS */ + ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN *) addrlen) ; + if (ace_result == ACE_INVALID_HANDLE && errno == EAGAIN) + errno = EWOULDBLOCK; + return ace_result; + +# endif /* defined (ACE_WIN32) */ +#endif /* defined (ACE_PSOS) */ +} + +ACE_INLINE int +ACE_OS::bind (ACE_HANDLE handle, struct sockaddr *addr, int addrlen) +{ + ACE_OS_TRACE ("ACE_OS::bind"); +#if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) + ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle, + (struct sockaddr_in *) addr, + (ACE_SOCKET_LEN) addrlen), + int, -1); +#else /* !defined (ACE_PSOS) || defined (ACE_PSOS_DIAB_PPC) */ + ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN) addrlen), int, -1); +#endif /* defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) */ +} + +ACE_INLINE int +ACE_OS::closesocket (ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::closesocket"); +#if defined (ACE_WIN32) + ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1); +#elif defined (ACE_PSOS_DIAB_PPC) + ACE_OSCALL_RETURN (::pna_close (handle), int, -1); +#else + ACE_OSCALL_RETURN (::close (handle), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::connect (ACE_HANDLE handle, + struct sockaddr *addr, + int addrlen) +{ + ACE_OS_TRACE ("ACE_OS::connect"); +#if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) + ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle, + (struct sockaddr_in *) addr, + (ACE_SOCKET_LEN) addrlen), + int, -1); +#else /* !defined (ACE_PSOS) || defined (ACE_PSOS_DIAB_PPC) */ + ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN) addrlen), int, -1); +#endif /* defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) */ +} + +ACE_INLINE int +ACE_OS::enum_protocols (int *protocols, + ACE_Protocol_Info *protocol_buffer, + u_long *buffer_length) +{ +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + + ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols, + protocol_buffer, + buffer_length), + int, + SOCKET_ERROR); + +#else + ACE_UNUSED_ARG (protocols); + ACE_UNUSED_ARG (protocol_buffer); + ACE_UNUSED_ARG (buffer_length); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_WINSOCK2 */ +} + +ACE_INLINE int +ACE_OS::getpeername (ACE_HANDLE handle, struct sockaddr *addr, + int *addrlen) +{ + ACE_OS_TRACE ("ACE_OS::getpeername"); +#if defined (ACE_PSOS) && !defined ACE_PSOS_DIAB_PPC + ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle, + (struct sockaddr_in *) addr, + (ACE_SOCKET_LEN *) addrlen), + int, -1); +#else + ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN *) addrlen), + int, -1); +#endif /* defined (ACE_PSOS) */ +} + +ACE_INLINE int +ACE_OS::getsockname (ACE_HANDLE handle, + struct sockaddr *addr, + int *addrlen) +{ + ACE_OS_TRACE ("ACE_OS::getsockname"); +#if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) + ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle, + (struct sockaddr_in *) addr, + (ACE_SOCKET_LEN *) addrlen), + int, -1); +#else + ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle, + addr, + (ACE_SOCKET_LEN *) addrlen), + int, -1); +#endif /* defined (ACE_PSOS) */ +} + +ACE_INLINE int +ACE_OS::getsockopt (ACE_HANDLE handle, + int level, + int optname, + char *optval, + int *optlen) +{ + ACE_OS_TRACE ("ACE_OS::getsockopt"); + ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle, + level, + optname, + optval, + (ACE_SOCKET_LEN *) optlen), + int, + -1); +} + +ACE_INLINE int +ACE_OS::listen (ACE_HANDLE handle, int backlog) +{ + ACE_OS_TRACE ("ACE_OS::listen"); + ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1); +} + +ACE_INLINE int +ACE_OS::recv (ACE_HANDLE handle, char *buf, size_t len, int flags) +{ + ACE_OS_TRACE ("ACE_OS::recv"); + + // On UNIX, a non-blocking socket with no data to receive, this + // system call will return EWOULDBLOCK or EAGAIN, depending on the + // platform. UNIX 98 allows either errno, and they may be the same + // numeric value. So to make life easier for upper ACE layers as + // well as application programmers, always change EAGAIN to + // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's + // handled explicitly here. If the ACE_OSCALL macro ever changes, + // this function needs to be reviewed. On Win32, the regular macros + // can be used, as this is not an issue. +#if defined (ACE_WIN32) + ACE_SOCKCALL_RETURN (::recv ((ACE_SOCKET) handle, buf, + ACE_static_cast (int, len), flags), int, -1); +#else + int ace_result_; + ace_result_ = ::recv ((ACE_SOCKET) handle, buf, len, flags); + if (ace_result_ == -1 && errno == EAGAIN) + errno = EWOULDBLOCK; + return ace_result_; +#endif /* defined (ACE_WIN32) */ +} + +ACE_INLINE int +ACE_OS::recvfrom (ACE_HANDLE handle, + char *buf, + size_t len, + int flags, + struct sockaddr *addr, + int *addrlen) +{ + ACE_OS_TRACE ("ACE_OS::recvfrom"); +#if defined (ACE_PSOS) +# if !defined ACE_PSOS_DIAB_PPC + ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, + (struct sockaddr_in *) addr, (ACE_SOCKET_LEN *) addrlen), + int, -1); +# else + ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, + (struct sockaddr *) addr, (ACE_SOCKET_LEN *) addrlen), + int, -1); +# endif /* defined ACE_PSOS_DIAB_PPC */ +#elif defined (ACE_WIN32) + int shortened_len = ACE_static_cast (int, len); + int result = ::recvfrom ((ACE_SOCKET) handle, + buf, + shortened_len, + flags, + addr, + (ACE_SOCKET_LEN *) addrlen); + if (result == SOCKET_ERROR) + { + ACE_OS::set_errno_to_wsa_last_error (); + if (errno == WSAEMSGSIZE && + ACE_BIT_ENABLED (flags, MSG_PEEK)) + return shortened_len; + else + return -1; + } + else + return result; +#else /* non Win32 and non PSOS */ + ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, + addr, (ACE_SOCKET_LEN *) addrlen), + int, -1); +#endif /* defined (ACE_PSOS) */ +} + +ACE_INLINE int +ACE_OS::recvfrom (ACE_HANDLE handle, + iovec *buffers, + int buffer_count, + size_t &number_of_bytes_recvd, + int &flags, + struct sockaddr *addr, + int *addrlen, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) +{ + ACE_OS_TRACE ("ACE_OS::recvfrom"); + +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + DWORD bytes_recvd; + DWORD the_flags = flags; + int result = ::WSARecvFrom ((SOCKET) handle, + (WSABUF*)buffers, + buffer_count, + &bytes_recvd, + &the_flags, + addr, + addrlen, + overlapped, + func); + if (result != 0) { + ACE_OS::set_errno_to_last_error (); + } + flags = the_flags; + number_of_bytes_recvd = ACE_static_cast (size_t, bytes_recvd); + return result; +#else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (buffers); + ACE_UNUSED_ARG (buffer_count); + ACE_UNUSED_ARG (number_of_bytes_recvd); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (addrlen); + ACE_UNUSED_ARG (overlapped); + ACE_UNUSED_ARG (func); + ACE_NOTSUP_RETURN (-1); +#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ +} + +ACE_INLINE int +ACE_OS::recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags) +{ + ACE_OS_TRACE ("ACE_OS::recvmsg"); +#if !defined (ACE_LACKS_RECVMSG) +# if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + DWORD bytes_received = 0; + + int result = ::WSARecvFrom ((SOCKET) handle, + (WSABUF *) msg->msg_iov, + msg->msg_iovlen, + &bytes_received, + (DWORD *) &flags, + msg->msg_name, + &msg->msg_namelen, + 0, + 0); + + if (result != 0) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + else + return (ssize_t) bytes_received; +# else /* ACE_HAS_WINSOCK2 */ + ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), int, -1); +# endif /* ACE_HAS_WINSOCK2 */ +#else + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (msg); + ACE_UNUSED_ARG (handle); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_LACKS_RECVMSG */ +} + +ACE_INLINE ssize_t +ACE_OS::recvv (ACE_HANDLE handle, + iovec *buffers, + int n) +{ +#if defined (ACE_HAS_WINSOCK2) + + DWORD bytes_received = 0; + int result = 1; + + // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs + // to do the recvs piece-by-piece. + +# if (ACE_HAS_WINSOCK2 != 0) + DWORD flags = 0; + result = ::WSARecv ((SOCKET) handle, + (WSABUF *) buffers, + n, + &bytes_received, + &flags, + 0, + 0); +# else + int i, chunklen; + char *chunkp = 0; + + // Step through the buffers requested by caller; for each one, cycle + // through reads until it's filled or an error occurs. + for (i = 0; i < n && result > 0; i++) + { + chunkp = buffers[i].iov_base; // Point to part of chunk being read + chunklen = buffers[i].iov_len; // Track how much to read to chunk + while (chunklen > 0 && result > 0) + { + result = ::recv ((SOCKET) handle, chunkp, chunklen, 0); + if (result > 0) + { + chunkp += result; + chunklen -= result; + bytes_received += result; + } + } + } +# endif /* ACE_HAS_WINSOCK2 != 0 */ + + if (result == SOCKET_ERROR) + { + ACE_OS::set_errno_to_wsa_last_error (); + return -1; + } + else + return (ssize_t) bytes_received; +#else + return ACE_OS::readv (handle, buffers, n); +#endif /* ACE_HAS_WINSOCK2 */ +} + +ACE_INLINE int +ACE_OS::send (ACE_HANDLE handle, const char *buf, size_t len, int flags) +{ + ACE_OS_TRACE ("ACE_OS::send"); + + // On UNIX, a non-blocking socket with no data to receive, this + // system call will return EWOULDBLOCK or EAGAIN, depending on the + // platform. UNIX 98 allows either errno, and they may be the same + // numeric value. So to make life easier for upper ACE layers as + // well as application programmers, always change EAGAIN to + // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's + // handled explicitly here. If the ACE_OSCALL macro ever changes, + // this function needs to be reviewed. On Win32, the regular macros + // can be used, as this is not an issue. +#if defined (ACE_WIN32) + ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle, + buf, + ACE_static_cast (int, len), + flags), int, -1); +#else + int ace_result_; +# if defined (VXWORKS) || defined (HPUX) || defined (ACE_PSOS) + ace_result_ = ::send ((ACE_SOCKET) handle, (char *) buf, len, flags); +# else + ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags); +# endif /* VXWORKS */ + if (ace_result_ == -1 && errno == EAGAIN) + errno = EWOULDBLOCK; + return ace_result_; +#endif /* defined (ACE_WIN32) */ +} + +ACE_INLINE int +ACE_OS::sendmsg (ACE_HANDLE handle, + const struct msghdr *msg, + int flags) +{ + ACE_OS_TRACE ("ACE_OS::sendmsg"); +#if !defined (ACE_LACKS_SENDMSG) +# if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + DWORD bytes_sent = 0; + int result = ::WSASendTo ((SOCKET) handle, + (WSABUF *) msg->msg_iov, + msg->msg_iovlen, + &bytes_sent, + flags, + msg->msg_name, + msg->msg_namelen, + 0, + 0); + + if (result != 0) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + else + return (ssize_t) bytes_sent; +# elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_PSOS) + ACE_SOCKCALL_RETURN (::sendmsg (handle, (struct msghdr *) msg, flags), int, -1); +# else + ACE_SOCKCALL_RETURN (::sendmsg (handle, (ACE_SENDMSG_TYPE *) msg, flags), int, -1); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ +#else + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (msg); + ACE_UNUSED_ARG (handle); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_LACKS_SENDMSG */ +} + +ACE_INLINE int +ACE_OS::sendto (ACE_HANDLE handle, + const char *buf, + size_t len, + int flags, + const struct sockaddr *addr, + int addrlen) +{ + ACE_OS_TRACE ("ACE_OS::sendto"); +#if defined (VXWORKS) + ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags, + ACE_const_cast (struct sockaddr *, addr), addrlen), + int, -1); +#elif defined (ACE_PSOS) +# if !defined (ACE_PSOS_DIAB_PPC) + ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags, + (struct sockaddr_in *) addr, addrlen), + int, -1); +# else + ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags, + (struct sockaddr *) addr, addrlen), + int, -1); +# endif /*defined ACE_PSOS_DIAB_PPC */ +#else +# if defined (ACE_WIN32) + ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, + ACE_static_cast (int, len), flags, + ACE_const_cast (struct sockaddr *, addr), addrlen), + int, -1); +# else + ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, len, flags, + ACE_const_cast (struct sockaddr *, addr), addrlen), + int, -1); +# endif /* ACE_WIN32 */ +#endif /* VXWORKS */ +} + +ACE_INLINE int +ACE_OS::sendto (ACE_HANDLE handle, + const iovec *buffers, + int buffer_count, + size_t &number_of_bytes_sent, + int flags, + const struct sockaddr *addr, + int addrlen, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) +{ + ACE_OS_TRACE ("ACE_OS::sendto"); +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + DWORD bytes_sent; + int result = ::WSASendTo ((SOCKET) handle, + (WSABUF*)buffers, + buffer_count, + &bytes_sent, + flags, + addr, + addrlen, + overlapped, + func); + if (result != 0) { + ACE_OS::set_errno_to_last_error (); + } + number_of_bytes_sent = ACE_static_cast (size_t, bytes_sent); + return result; +#else + ACE_UNUSED_ARG (overlapped); + ACE_UNUSED_ARG (func); + + number_of_bytes_sent = 0; + + int result = 0; + + for (int i = 0; i < buffer_count; i++) + { + result = ACE_OS::sendto (handle, + ACE_reinterpret_cast (char *ACE_CAST_CONST, + buffers[i].iov_base), + buffers[i].iov_len, + flags, + addr, + addrlen); + if (result == -1) + break; + number_of_bytes_sent += result; + } + + return result; +#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ +} + +ACE_INLINE ssize_t +ACE_OS::sendv (ACE_HANDLE handle, + const iovec *buffers, + int n) +{ +#if defined (ACE_HAS_WINSOCK2) + DWORD bytes_sent = 0; + int result = 0; + + // Winsock 2 has WSASend and can do this directly, but Winsock 1 + // needs to do the sends one-by-one. +# if (ACE_HAS_WINSOCK2 != 0) + result = ::WSASend ((SOCKET) handle, + (WSABUF *) buffers, + n, + &bytes_sent, + 0, + 0, + 0); +# else + int i; + for (i = 0; i < n && result != SOCKET_ERROR; i++) + { + result = ::send ((SOCKET) handle, + buffers[i].iov_base, + buffers[i].iov_len, + 0); + // Gets ignored on error anyway + bytes_sent += buffers[i].iov_len; + + // If the transfer isnt complete just drop out of the loop. + if (result < (int)buffers[i].iov_len) + break; + } +# endif /* ACE_HAS_WINSOCK2 != 0 */ + + if (result == SOCKET_ERROR) + { + ACE_OS::set_errno_to_wsa_last_error (); + return -1; + } + else + return (ssize_t) bytes_sent; + +#else + return ACE_OS::writev (handle, buffers, n); +#endif /* ACE_HAS_WINSOCK2 */ +} + +ACE_INLINE int +ACE_OS::setsockopt (ACE_HANDLE handle, + int level, + int optname, + const char *optval, + int optlen) +{ + ACE_OS_TRACE ("ACE_OS::setsockopt"); + + #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT) + // To work around an inconsistency with Microsofts implementation of + // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock + // always behaves as if SO_REUSEADDR=1. Some implementations have the + // same behaviour as Winsock, but use a new name for it. SO_REUSEPORT. + // If you want the normal behaviour for SO_REUSEADDR=0, then NT 4 sp4 and later + // supports SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform SDK + // so it was decided to ignore the option for now. (Especially since ACE always + // sets SO_REUSEADDR=1, which we can mimic by doing nothing.) + if (level == SOL_SOCKET) { + if (optname == SO_REUSEADDR) { + return 0; // Not supported by Winsock + } + if (optname == SO_REUSEPORT) { + optname = SO_REUSEADDR; + } + } + #endif /*ACE_HAS_WINSOCK2*/ + + ACE_SOCKCALL_RETURN (::setsockopt ((ACE_SOCKET) handle, + level, + optname, + (ACE_SOCKOPT_TYPE1) optval, + optlen), + int, + -1); +} + +ACE_INLINE int +ACE_OS::shutdown (ACE_HANDLE handle, int how) +{ + ACE_OS_TRACE ("ACE_OS::shutdown"); + ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1); +} + +ACE_INLINE ACE_HANDLE +ACE_OS::socket (int domain, + int type, + int proto) +{ + ACE_OS_TRACE ("ACE_OS::socket"); + ACE_SOCKCALL_RETURN (::socket (domain, + type, + proto), + ACE_HANDLE, + ACE_INVALID_HANDLE); +} + +ACE_INLINE ACE_HANDLE +ACE_OS::socket (int domain, + int type, + int proto, + ACE_Protocol_Info *protocolinfo, + ACE_SOCK_GROUP g, + u_long flags) +{ + ACE_OS_TRACE ("ACE_OS::socket"); + +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + ACE_SOCKCALL_RETURN (::WSASocket (domain, + type, + proto, + protocolinfo, + g, + flags), + ACE_HANDLE, + ACE_INVALID_HANDLE); +#else + ACE_UNUSED_ARG (protocolinfo); + ACE_UNUSED_ARG (g); + ACE_UNUSED_ARG (flags); + + return ACE_OS::socket (domain, + type, + proto); +#endif /* ACE_HAS_WINSOCK2 */ +} + +ACE_INLINE int +ACE_OS::socketpair (int domain, int type, + int protocol, ACE_HANDLE sv[2]) +{ + ACE_OS_TRACE ("ACE_OS::socketpair"); +#if defined (ACE_WIN32) || defined (ACE_LACKS_SOCKETPAIR) + ACE_UNUSED_ARG (domain); + ACE_UNUSED_ARG (type); + ACE_UNUSED_ARG (protocol); + ACE_UNUSED_ARG (sv); + + ACE_NOTSUP_RETURN (-1); +#else + ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv), + int, -1); +#endif /* ACE_WIN32 */ +} + diff --git a/ace/OS_NS_sys_stat.cpp b/ace/OS_NS_sys_stat.cpp index fc532b41367..fa50a6b040d 100644 --- a/ace/OS_NS_sys_stat.cpp +++ b/ace/OS_NS_sys_stat.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_stat.h" + +ACE_RCSID(ace, OS_NS_sys_stat, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_stat.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_sys_stat.h b/ace/OS_NS_sys_stat.h index fc532b41367..cf2e0a339f1 100644 --- a/ace/OS_NS_sys_stat.h +++ b/ace/OS_NS_sys_stat.h @@ -1,4 +1,79 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_stat.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_STAT_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_types.h" +#include "ace/Default_Constants.h" // for ACE_DEFAULT_DIR_PERMS + +# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && !defined (__BORLANDC__) + typedef struct _stat ACE_stat; +# else + typedef struct stat ACE_stat; +# endif /* ACE_WIN32 */ + +namespace ACE_OS { + + ACE_HANDLE creat (const ACE_TCHAR *filename, + mode_t mode); + + //@{ @name A set of wrappers for low-level file operations. + + // non-standard + long filesize (ACE_HANDLE handle); + + long filesize (const ACE_TCHAR *handle); + + + //@} + + int fstat (ACE_HANDLE, + ACE_stat *); + + int lstat (const char *, + ACE_stat *); + + int mkdir (const ACE_TCHAR *path, + mode_t mode = ACE_DEFAULT_DIR_PERMS); + + int mkfifo (const ACE_TCHAR *file, + mode_t mode = ACE_DEFAULT_FILE_PERMS); + + int stat (const ACE_TCHAR *file, ACE_stat *); + + mode_t umask (mode_t cmask); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_stat.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_STAT_H */ diff --git a/ace/OS_NS_sys_stat.inl b/ace/OS_NS_sys_stat.inl index fc532b41367..d6fefa014b2 100644 --- a/ace/OS_NS_sys_stat.inl +++ b/ace/OS_NS_sys_stat.inl @@ -1,4 +1,313 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_fcntl.h" + +ACE_INLINE ACE_HANDLE +ACE_OS::creat (const ACE_TCHAR *filename, mode_t mode) +{ + ACE_OS_TRACE ("ACE_OS::creat"); +#if defined (ACE_WIN32) + return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode); +#elif defined(ACE_PSOS) + ACE_OSCALL_RETURN(::create_f((char *)filename, 1024, + S_IRUSR | S_IWUSR | S_IXUSR), + ACE_HANDLE, ACE_INVALID_HANDLE); +#elif defined(ACE_PSOS_TM) + ACE_UNUSED_ARG (filename); + ACE_UNUSED_ARG (mode); + ACE_NOTSUP_RETURN (-1); +#elif defined(ACE_PSOS) + ACE_UNUSED_ARG (filename); + ACE_UNUSED_ARG (mode); + ACE_NOTSUP_RETURN (-1); +#else + ACE_OSCALL_RETURN (::creat (filename, mode), + ACE_HANDLE, ACE_INVALID_HANDLE); +#endif /* ACE_WIN32 */ +} + +// This function returns the number of bytes in the file referenced by +// FD. + +ACE_INLINE long +ACE_OS::filesize (ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::filesize"); +#if defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (::GetFileSize (handle, 0), long, -1); +#else /* !ACE_WIN32 */ + struct stat sb; + return ACE_OS::fstat (handle, &sb) == -1 ? -1 : (long) sb.st_size; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE long +ACE_OS::filesize (const ACE_TCHAR *filename) +{ + ACE_OS_TRACE ("ACE_OS::filesize"); + + ACE_HANDLE h = ACE_OS::open (filename, O_RDONLY); + if (h != ACE_INVALID_HANDLE) + { + long size = ACE_OS::filesize (h); + ACE_OS::close (h); + return size; + } + else + return -1; +} + +#if !defined (ACE_WIN32) + +ACE_INLINE int +ACE_OS::fstat (ACE_HANDLE handle, ACE_stat *stp) +{ + ACE_OS_TRACE ("ACE_OS::fstat"); +#if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (stp); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (::fstat_f (handle, stp), int, -1); +#else +# if defined (ACE_HAS_X86_STAT_MACROS) + // Solaris for intel uses an macro for fstat(), this is a wrapper + // for _fxstat() use of the macro. + // causes compile and runtime problems. + ACE_OSCALL_RETURN (::_fxstat (_STAT_VER, handle, stp), int, -1); +# elif defined (ACE_WIN32) + ACE_OSCALL_RETURN (::_fstat (handle, stp), int, -1); +# else + ACE_OSCALL_RETURN (::fstat (handle, stp), int, -1); +# endif /* !ACE_HAS_X86_STAT_MACROS */ +#endif /* ACE_PSOS_LACKS_PHILE */ +} + +#else /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::fstat (ACE_HANDLE handle, ACE_stat *stp) +{ + ACE_OS_TRACE ("ACE_OS::fstat"); +# if 1 + BY_HANDLE_FILE_INFORMATION fdata; + + if (::GetFileInformationByHandle (handle, &fdata) == FALSE) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + else if (fdata.nFileSizeHigh != 0) + { + errno = EINVAL; + return -1; + } + else + { + stp->st_size = fdata.nFileSizeLow; + stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); + stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); + stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); + stp->st_nlink = ACE_static_cast (short, fdata.nNumberOfLinks); + stp->st_dev = stp->st_rdev = 0; // No equivalent conversion. + stp->st_mode = S_IXOTH | S_IROTH | + (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) | + (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG); + } + return 0; +# else /* 1 */ + // This implementation close the handle. + int retval = -1; + int fd = ::_open_osfhandle ((long) handle, 0); + if (fd != -1) + retval = ::_fstat (fd, stp); + + ::_close (fd); + // Remember to close the file handle. + return retval; +# endif /* 1 */ +} + +#endif /* WIN32 */ + +ACE_INLINE int +ACE_OS::lstat (const char *file, ACE_stat *stp) +{ + ACE_OS_TRACE ("ACE_OS::lstat"); +# if defined (ACE_LACKS_LSTAT) || \ + defined (ACE_HAS_WINCE) || defined (ACE_WIN32) + ACE_UNUSED_ARG (file); + ACE_UNUSED_ARG (stp); + ACE_NOTSUP_RETURN (-1); +# else +# if defined (ACE_HAS_X86_STAT_MACROS) + // Solaris for intel uses an macro for lstat(), this macro is a + // wrapper for _lxstat(). + ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1); +# elif defined (ACE_WIN32) + ACE_OSCALL_RETURN (::_lstat (file, stp), int, -1); +# else /* !ACE_HAS_X86_STAT_MACROS */ + ACE_OSCALL_RETURN (::lstat (file, stp), int, -1); +# endif /* !ACE_HAS_X86_STAT_MACROS */ +# endif /* ACE_LACKS_LSTAT */ +} + +ACE_INLINE int +ACE_OS::mkdir (const ACE_TCHAR *path, mode_t mode) +{ +#if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (path); + ACE_UNUSED_ARG (mode); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_PSOS) + //The pSOS make_dir fails if the last character is a '/' + int location; + char *phile_path; + + phile_path = (char *)ACE_OS::malloc(strlen(path)); + if (phile_path == 0) + { + ACE_OS::printf ("malloc in make_dir failed: [%X]\n", + errno); + return -1; + } + else + ACE_OS::strcpy (phile_path, path); + + location = ACE_OS::strlen(phile_path); + if(phile_path[location-1] == '/') + { + phile_path[location-1] = 0; + } + + u_long result; + result = ::make_dir ((char *) phile_path, mode); + if (result == 0x2011) // Directory already exists + { + result = 0; + } + else if (result != 0) + { + result = -1; + } + + ACE_OS::free(phile_path); + return result; + +#elif defined (VXWORKS) + ACE_UNUSED_ARG (mode); + ACE_OSCALL_RETURN (::mkdir ((char *) path), int, -1); +#elif defined (ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) + ACE_UNUSED_ARG (mode); + ACE_OSCALL_RETURN (::_mkdir ((char *) path), int, -1); +#elif defined (ACE_HAS_WINCE) + ACE_UNUSED_ARG (mode); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (path, 0), + ace_result_), + int, -1); +#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_UNUSED_ARG (mode); + ACE_OSCALL_RETURN (::_wmkdir (path), int, -1); +#elif defined (ACE_WIN32) + ACE_UNUSED_ARG (mode); + ACE_OSCALL_RETURN (::mkdir (path), int, -1); +#else + ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1); +#endif /* ACE_PSOS_LACKS_PHILE */ +} + +ACE_INLINE int +ACE_OS::mkfifo (const ACE_TCHAR *file, mode_t mode) +{ + ACE_OS_TRACE ("ACE_OS::mkfifo"); +#if defined (ACE_LACKS_MKFIFO) + ACE_UNUSED_ARG (file); + ACE_UNUSED_ARG (mode); + ACE_NOTSUP_RETURN (-1); +#else + ACE_OSCALL_RETURN (::mkfifo (file, mode), int, -1); +#endif /* ACE_LACKS_MKFIFO */ +} + +ACE_INLINE int +ACE_OS::stat (const ACE_TCHAR *file, ACE_stat *stp) +{ + ACE_OS_TRACE ("ACE_OS::stat"); +#if defined (VXWORKS) + ACE_OSCALL_RETURN (::stat ((char *) file, stp), int, -1); +#elif defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (file); + ACE_UNUSED_ARG (stp); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (::stat_f ((char *) file, stp), int, -1); +#elif defined (ACE_HAS_WINCE) + ACE_TEXT_WIN32_FIND_DATA fdata; + + HANDLE fhandle; + + fhandle = ::FindFirstFile (file, &fdata); + if (fhandle == INVALID_HANDLE_VALUE) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + else if (fdata.nFileSizeHigh != 0) + { + errno = EINVAL; + return -1; + } + else + { + stp->st_size = fdata.nFileSizeLow; + stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime); + stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime); + } + return 0; +#elif defined (ACE_HAS_X86_STAT_MACROS) + // Solaris for intel uses an macro for stat(), this macro is a + // wrapper for _xstat(). + ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1); +#elif defined (__BORLANDC__) && (__BORLANDC__ <= 0x540) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wstat (file, stp), int, -1); +#elif defined (ACE_WIN32) +# if defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wstat (file, (struct _stat *) stp), int, -1); +# else + ACE_OSCALL_RETURN (::_stat (file, (struct _stat *) stp), int, -1); +# endif /* ACE_USES_WCHAR */ +#else /* VXWORKS */ + ACE_OSCALL_RETURN (::stat (file, stp), int, -1); +#endif /* VXWORKS */ +} + +#if !defined (ACE_WIN32) + +ACE_INLINE mode_t +ACE_OS::umask (mode_t cmask) +{ + ACE_OS_TRACE ("ACE_OS::umask"); +# if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_UNUSED_ARG (cmask); + ACE_NOTSUP_RETURN ((mode_t)-1); +# else + return ::umask (cmask); // This call shouldn't fail... +# endif /* VXWORKS || ACE_PSOS */ +} + +#else /* ACE_WIN32 */ + +ACE_INLINE mode_t +ACE_OS::umask (mode_t cmask) +{ +#if !defined (ACE_HAS_WINCE) + ACE_OS_TRACE ("ACE_OS::umask"); + ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1); +# else + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WINCE */ +} + +#endif /* WIN32 */ diff --git a/ace/OS_NS_sys_time.cpp b/ace/OS_NS_sys_time.cpp index fc532b41367..2109fa005e0 100644 --- a/ace/OS_NS_sys_time.cpp +++ b/ace/OS_NS_sys_time.cpp @@ -1,4 +1,11 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_time.h" + +ACE_RCSID(ace, OS_NS_sys_time, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_time.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + diff --git a/ace/OS_NS_sys_time.h b/ace/OS_NS_sys_time.h index fc532b41367..bb2ffd29882 100644 --- a/ace/OS_NS_sys_time.h +++ b/ace/OS_NS_sys_time.h @@ -1,4 +1,45 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_time.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_TIME_H +# define ACE_OS_NS_SYS_TIME_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/Time_Value.h" + +namespace ACE_OS { + + ACE_Time_Value gettimeofday (void); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_time.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_TIME_H */ diff --git a/ace/OS_NS_sys_time.inl b/ace/OS_NS_sys_time.inl index fc532b41367..1db85317bb4 100644 --- a/ace/OS_NS_sys_time.inl +++ b/ace/OS_NS_sys_time.inl @@ -1,4 +1,72 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/os_include/sys/os_time.h" + +ACE_INLINE ACE_Time_Value +ACE_OS::gettimeofday (void) +{ + // ACE_OS_TRACE ("ACE_OS::gettimeofday"); + +#if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) + timeval tv; + int result = 0; +#endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) + +#if (0) + struct timespec ts; + + ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); + tv.tv_sec = ts.tv_sec; + tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec + +#elif defined (ACE_HAS_WINCE) + SYSTEMTIME tsys; + FILETIME tfile; + ::GetSystemTime (&tsys); + ::SystemTimeToFileTime (&tsys, &tfile); + return ACE_Time_Value (tfile); +#elif defined (ACE_WIN32) + FILETIME tfile; + ::GetSystemTimeAsFileTime (&tfile); + return ACE_Time_Value (tfile); +#if 0 + // From Todd Montgomery... + struct _timeb tb; + ::_ftime (&tb); + tv.tv_sec = tb.time; + tv.tv_usec = 1000 * tb.millitm; +#endif /* 0 */ +#elif defined (ACE_HAS_AIX_HI_RES_TIMER) + timebasestruct_t tb; + + ::read_real_time (&tb, TIMEBASE_SZ); + ::time_base_to_time (&tb, TIMEBASE_SZ); + + tv.tv_sec = tb.tb_high; + tv.tv_usec = tb.tb_low / 1000L; +#else +# if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \ + (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (m88k) && !defined (SCO)) + ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result); +# elif defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) + // Assumes that struct timespec is same size as struct timeval, + // which assumes that time_t is a long: it currently (VxWorks + // 5.2/5.3) is. + struct timespec ts; + + ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); + tv.tv_sec = ts.tv_sec; + tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec +# else + ACE_OSCALL (::gettimeofday (&tv), int, -1, result); +# endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ +#endif /* 0 */ +#if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) + if (result == -1) + return -1; + else + return ACE_Time_Value (tv); +#endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32) +} + diff --git a/ace/OS_NS_sys_uio.cpp b/ace/OS_NS_sys_uio.cpp index fc532b41367..f51dd4bc3fb 100644 --- a/ace/OS_NS_sys_uio.cpp +++ b/ace/OS_NS_sys_uio.cpp @@ -1,4 +1,114 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_uio.h" + +ACE_RCSID(ace, OS_NS_sys_uio, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_uio.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +# if defined (ACE_LACKS_READV) + +// "Fake" readv for operating systems without it. Note that this is +// thread-safe. + +ssize_t +ACE_OS::readv_emulation (ACE_HANDLE handle, + ACE_READV_TYPE *iov, + int n) +{ + ACE_OS_TRACE ("ACE_OS::readv_emulation"); + + ssize_t length = 0; + int i; + + for (i = 0; i < n; i++) + if (ACE_static_cast (int, iov[i].iov_len) < 0) + return -1; + else + length += iov[i].iov_len; + + char *buf; +# if defined (ACE_HAS_ALLOCA) + buf = (char *) alloca (length); +# else + ACE_NEW_RETURN (buf, + char[length], + -1); +# endif /* !defined (ACE_HAS_ALLOCA) */ + + length = ACE_OS::read (handle, buf, length); + + if (length != -1) + { + char *ptr = buf; + ssize_t copyn = length; + + for (i = 0; + i < n && copyn > 0; + i++) + { + ACE_OS::memcpy (iov[i].iov_base, ptr, + // iov_len is int on some platforms, size_t on others + copyn > (int) iov[i].iov_len + ? (size_t) iov[i].iov_len + : (size_t) copyn); + ptr += iov[i].iov_len; + copyn -= iov[i].iov_len; + } + } + +# if !defined (ACE_HAS_ALLOCA) + delete [] buf; +# endif /* !defined (ACE_HAS_ALLOCA) */ + return length; +} +# endif /* ACE_LACKS_READV */ + +# if defined (ACE_LACKS_WRITEV) + +// "Fake" writev for operating systems without it. Note that this is +// thread-safe. + +int +ACE_OS::writev_emulation (ACE_HANDLE handle, ACE_WRITEV_TYPE iov[], int n) +{ + ACE_OS_TRACE ("ACE_OS::writev_emulation"); + + size_t length = 0; + int i; + + // Determine the total length of all the buffers in <iov>. + for (i = 0; i < n; i++) + if (ACE_static_cast (int, iov[i].iov_len) < 0) + return -1; + else + length += iov[i].iov_len; + + char *buf; + +# if defined (ACE_HAS_ALLOCA) + buf = (char *) alloca (length); +# else + ACE_NEW_RETURN (buf, + char[length], + -1); +# endif /* !defined (ACE_HAS_ALLOCA) */ + + char *ptr = buf; + + for (i = 0; i < n; i++) + { + ACE_OS::memcpy (ptr, iov[i].iov_base, iov[i].iov_len); + ptr += iov[i].iov_len; + } + + ssize_t result = ACE_OS::write (handle, buf, length); +# if !defined (ACE_HAS_ALLOCA) + delete [] buf; +# endif /* !defined (ACE_HAS_ALLOCA) */ + return result; +} +# endif /* ACE_LACKS_WRITEV */ diff --git a/ace/OS_NS_sys_uio.h b/ace/OS_NS_sys_uio.h index fc532b41367..2910dbdde29 100644 --- a/ace/OS_NS_sys_uio.h +++ b/ace/OS_NS_sys_uio.h @@ -1,4 +1,65 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_uio.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_UIO_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_uio.h" + +namespace ACE_OS { + + ssize_t readv (ACE_HANDLE handle, + iovec *iov, + int iovlen); + +#if defined (ACE_LACKS_READV) + ssize_t readv_emulation (ACE_HANDLE handle, + ACE_READV_TYPE *iov, + int iovcnt); +#endif /* ACE_LACKS_READV */ + + ssize_t writev (ACE_HANDLE handle, + const iovec *iov, + int iovcnt); + + // these don't need to be in the header, better to put them in the cpp + // or inl. +#if defined (ACE_LACKS_WRITEV) + int writev_emulation (ACE_HANDLE handle, + ACE_WRITEV_TYPE *iov, + int iovcnt); +#endif /* ACE_LACKS_WRITEV */ + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_uio.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_UIO_H */ diff --git a/ace/OS_NS_sys_uio.inl b/ace/OS_NS_sys_uio.inl index fc532b41367..2ffef0dc152 100644 --- a/ace/OS_NS_sys_uio.inl +++ b/ace/OS_NS_sys_uio.inl @@ -1,4 +1,35 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE ssize_t +ACE_OS::readv (ACE_HANDLE handle, + iovec *iov, + int iovlen) +{ + ACE_OS_TRACE ("ACE_OS::readv"); +#if defined (ACE_LACKS_READV) + ACE_OSCALL_RETURN (ACE_OS::readv_emulation (handle, iov, iovlen), + ssize_t, + -1); +#else /* ACE_LACKS_READV */ + ACE_OSCALL_RETURN (::readv (handle, iov, iovlen), ssize_t, -1); +#endif /* ACE_LACKS_READV */ +} + +ACE_INLINE ssize_t +ACE_OS::writev (ACE_HANDLE handle, + const iovec *iov, + int iovcnt) +{ + ACE_OS_TRACE ("ACE_OS::writev"); +#if defined (ACE_LACKS_WRITEV) + ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle, + (ACE_WRITEV_TYPE *) iov, + iovcnt), int, -1); +#else /* ACE_LACKS_WRITEV */ + ACE_OSCALL_RETURN (::writev (handle, + (ACE_WRITEV_TYPE *) iov, + iovcnt), int, -1); +#endif /* ACE_LACKS_WRITEV */ +} + diff --git a/ace/OS_NS_sys_utsname.cpp b/ace/OS_NS_sys_utsname.cpp index fc532b41367..726ac714e30 100644 --- a/ace/OS_NS_sys_utsname.cpp +++ b/ace/OS_NS_sys_utsname.cpp @@ -1,4 +1,227 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_utsname.h" + +ACE_RCSID(ace, OS_NS_sys_utsname, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_utsname.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#if defined (ACE_WIN32) || defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) +// Don't inline on those platforms because this function contains +// string literals, and some compilers, e.g., g++, don't handle those +// efficiently in unused inline functions. +int +ACE_OS::uname (ACE_utsname *name) +{ + ACE_OS_TRACE ("ACE_OS::uname"); +# if defined (ACE_WIN32) + size_t maxnamelen = sizeof name->nodename; + ACE_OS::strcpy (name->sysname, + ACE_LIB_TEXT ("Win32")); + + OSVERSIONINFO vinfo; + vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + ::GetVersionEx (&vinfo); + + SYSTEM_INFO sinfo; +# if defined (ACE_HAS_PHARLAP) + // PharLap doesn't do GetSystemInfo. What's really wanted is the + // CPU architecture, so we can get that with EtsGetSystemInfo. Fill + // in what's wanted in the SYSTEM_INFO structure, and carry on. Note + // that the CPU type values in EK_KERNELINFO have the same values + // are the ones defined for SYSTEM_INFO. + EK_KERNELINFO ets_kern; + EK_SYSTEMINFO ets_sys; + EtsGetSystemInfo (&ets_kern, &ets_sys); + sinfo.wProcessorLevel = ACE_static_cast (WORD, ets_kern.CpuType); + sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL; + sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86; +# else + ::GetSystemInfo(&sinfo); + + ACE_OS::strcpy (name->sysname, ACE_LIB_TEXT ("Win32")); +# endif /* ACE_HAS_PHARLAP */ + + const ACE_TCHAR* unknown = ACE_LIB_TEXT ("???"); + + if ( + vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT +# if defined (VER_PLATFORM_WIN32_CE) + || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE +# endif + ) + { + // Get information from the two structures + const ACE_TCHAR *os; + if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) + os = ACE_LIB_TEXT ("Windows NT %d.%d"); + else + os = ACE_LIB_TEXT ("Windows CE %d.%d"); + ACE_OS::sprintf (name->release, + os, + (int) vinfo.dwMajorVersion, + (int) vinfo.dwMinorVersion); + ACE_OS::sprintf (name->version, + ACE_LIB_TEXT ("Build %d %s"), + (int) vinfo.dwBuildNumber, + vinfo.szCSDVersion); + + // We have to make sure that the size of (processor + subtype) + // is not greater than the size of name->machine. So we give + // half the space to the processor and half the space to + // subtype. The -1 is necessary for because of the space + // between processor and subtype in the machine name. + const int bufsize = ((sizeof (name->machine) / sizeof (ACE_TCHAR)) / 2) - 1; + ACE_TCHAR processor[bufsize] = ACE_LIB_TEXT ("Unknown"); + ACE_TCHAR subtype[bufsize] = ACE_LIB_TEXT ("Unknown"); + +# if defined (ghs) + WORD arch = sinfo.u.s.wProcessorArchitecture; +# else + WORD arch = sinfo.wProcessorArchitecture; +# endif + + switch (arch) + { + case PROCESSOR_ARCHITECTURE_INTEL: + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Intel")); + if (sinfo.wProcessorLevel == 3) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80386")); + else if (sinfo.wProcessorLevel == 4) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80486")); + else if (sinfo.wProcessorLevel == 5) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium")); + else if (sinfo.wProcessorLevel == 6) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium Pro")); + else if (sinfo.wProcessorLevel == 7) // I'm guessing here + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium II")); + break; + case PROCESSOR_ARCHITECTURE_MIPS: + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("MIPS")); + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("R4000")); + break; + case PROCESSOR_ARCHITECTURE_ALPHA: + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Alpha")); + ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), sinfo.wProcessorLevel); + break; + case PROCESSOR_ARCHITECTURE_PPC: + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("PPC")); + if (sinfo.wProcessorLevel == 1) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("601")); + else if (sinfo.wProcessorLevel == 3) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603")); + else if (sinfo.wProcessorLevel == 4) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("604")); + else if (sinfo.wProcessorLevel == 6) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603+")); + else if (sinfo.wProcessorLevel == 9) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("804+")); + else if (sinfo.wProcessorLevel == 20) + ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("620")); + break; +# if defined PROCESSOR_ARCHITECTURE_IA64 + case PROCESSOR_ARCHITECTURE_IA64: + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Itanium")); + ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), + sinfo.wProcessorLevel); + break; +# endif +# if defined PROCESSOR_ARCHITECTURE_ARM + case PROCESSOR_ARCHITECTURE_ARM: + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("ARM")); + ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), + sinfo.wProcessorLevel); + break; +# endif + case PROCESSOR_ARCHITECTURE_UNKNOWN: + default: + // @@ We could provide WinCE specific info here. But let's + // defer that to some later point. + ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Unknown")); + break; + } + ACE_OS::sprintf (name->machine, + ACE_LIB_TEXT ("%s %s"), + processor, subtype); + } + else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + { + if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0) + { + ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 95")); + if (vinfo.szCSDVersion[1] == 'C') + ACE_OS::strcat (name->release, ACE_LIB_TEXT (" OSR2")); + } + else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10) + { + ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 98")); + if (vinfo.szCSDVersion[1] == 'A') + ACE_OS::strcat (name->release, ACE_LIB_TEXT (" SE")); + } + else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90) + { + ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows Me")); + } + else + { + ACE_OS::strcpy (name->release, unknown); + } + + ACE_OS::sprintf (name->version, ACE_LIB_TEXT ("%d"), + LOWORD (vinfo.dwBuildNumber)); + if (sinfo.dwProcessorType == PROCESSOR_INTEL_386) + ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80386")); + else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486) + ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80486")); + else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM) + ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel Pentium")); + else + ACE_OS::strcpy (name->machine, unknown); + } + else + { + // We don't know what this is! + + ACE_OS::strcpy (name->release, unknown); + ACE_OS::strcpy (name->version, unknown); + ACE_OS::strcpy (name->machine, unknown); + } + +# if defined (ACE_LACKS_HOSTNAME) + return 0; +# else /* ACE_LACKS_HOSTNAME */ + return ACE_OS::hostname (name->nodename, maxnamelen); +# endif /* ACE_LACKS_HOSTNAME */ + +# elif defined (VXWORKS) + size_t maxnamelen = sizeof name->nodename; + ACE_OS::strcpy (name->sysname, "VxWorks"); + ACE_OS::strcpy (name->release, "???"); + ACE_OS::strcpy (name->version, sysBspRev ()); + ACE_OS::strcpy (name->machine, sysModel ()); + + return ACE_OS::hostname (name->nodename, maxnamelen); +# elif defined (CHORUS) + size_t maxnamelen = sizeof name->nodename; + ACE_OS::strcpy (name->sysname, "CHORUS/ClassiX"); + ACE_OS::strcpy (name->release, "???"); + ACE_OS::strcpy (name->version, "???"); + ACE_OS::strcpy (name->machine, "???"); + + return ACE_OS::hostname (name->nodename, maxnamelen); +#elif defined (ACE_PSOS) + const unsigned long buflen(64); + char buf[buflen]; + unsigned long len; + sys_info(PSOS_VERSION,(void *)buf,buflen,&len); + ACE_OS::strcpy (name->sysname, "pSOS"); + ACE_OS::strcpy (name->release, "???"); + ACE_OS::strcpy (name->version, buf); + ACE_OS::strcpy (name->machine, "PPC 405"); // a bit of a hack + +#endif /* ACE_WIN32 */ +} +#endif /* ACE_WIN32 || VXWORKS */ diff --git a/ace/OS_NS_sys_utsname.h b/ace/OS_NS_sys_utsname.h index fc532b41367..fd780b14afd 100644 --- a/ace/OS_NS_sys_utsname.h +++ b/ace/OS_NS_sys_utsname.h @@ -1,4 +1,63 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_utsname.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_UTSNAME_H +# define ACE_OS_NS_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 */ + +#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 +# include "ace/os_include/sys/os_utsname.h" +typedef struct utsname ACE_utsname; +# endif /* ACE_LACKS_UTSNAME_T */ + +namespace ACE_OS { + + int uname (ACE_utsname *name); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_utsname.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_UTSNAME_H */ diff --git a/ace/OS_NS_sys_utsname.inl b/ace/OS_NS_sys_utsname.inl index fc532b41367..d2ca08ee515 100644 --- a/ace/OS_NS_sys_utsname.inl +++ b/ace/OS_NS_sys_utsname.inl @@ -1,4 +1,28 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#if !defined (ACE_WIN32) && !defined (VXWORKS) && !defined (CHORUS) && !defined (ACE_PSOS) +// Don't inline on those platforms because this function contains +// string literals, and some compilers, e.g., g++, don't handle those +// efficiently in unused inline functions. +ACE_INLINE int +ACE_OS::uname (ACE_utsname *name) +{ +#if defined (INTEGRITY) + if(!name) { + errno = EFAULT; + return -1; + } + strcpy(name->sysname,"INTEGRITY"); + int status = gethostname(name->nodename,_SYS_NMLN); + strcpy(name->release,"4.0"); + strcpy(name->version,"4.0.9"); + strcpy(name->machine,"a standard name"); + return status; +#else + ACE_OS_TRACE ("ACE_OS::uname"); + ACE_OSCALL_RETURN (::uname (name), int, -1); +#endif +} +#endif /* ! ACE_WIN32 && ! VXWORKS && ! CHORUS */ + diff --git a/ace/OS_NS_sys_wait.cpp b/ace/OS_NS_sys_wait.cpp index fc532b41367..0a1b8ee4d50 100644 --- a/ace/OS_NS_sys_wait.cpp +++ b/ace/OS_NS_sys_wait.cpp @@ -1,4 +1,10 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_wait.h" + +ACE_RCSID(ace, OS_NS_sys_wait, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_sys_wait.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ diff --git a/ace/OS_NS_sys_wait.h b/ace/OS_NS_sys_wait.h index fc532b41367..6551a42fd2f 100644 --- a/ace/OS_NS_sys_wait.h +++ b/ace/OS_NS_sys_wait.h @@ -1,4 +1,74 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_sys_wait.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_SYS_WAIT_H +# define ACE_OS_NS_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 */ + +#include "ace/os_include/sys/os_wait.h" + +namespace ACE_OS { + + /// Calls OS <::wait> function, so it's only portable to UNIX/POSIX + /// platforms. + pid_t wait (int * = 0); + + /** + * Calls <::WaitForSingleObject> on Win32 and <ACE::waitpid> + * otherwise. Returns the passed in <pid_t> on success and -1 on + * failure. + * On Win32, <pid> is ignored if the <handle> is not equal to 0. + * Passing the process <handle> is prefer on Win32 because using + * <pid> to wait on the project doesn't always work correctly + * if the waited process has already terminated. + */ + pid_t wait (pid_t pid, + ACE_exitcode *status, + int wait_options = 0, + ACE_HANDLE handle = 0); + + /** + * Calls <::waitpid> on UNIX/POSIX platforms and <::await> on + * Chorus. Does not work on Vxworks, or pSoS. + * On Win32, <pid> is ignored if the <handle> is not equal to 0. + * Passing the process <handle> is prefer on Win32 because using + * <pid> to wait on the project doesn't always work correctly + * if the waited process has already terminated. + */ + pid_t waitpid (pid_t pid, + ACE_exitcode *status = 0, + int wait_options = 0, + ACE_HANDLE handle = 0); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_sys_wait.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_SYS_WAIT_H */ diff --git a/ace/OS_NS_sys_wait.inl b/ace/OS_NS_sys_wait.inl index fc532b41367..9c018294a2b 100644 --- a/ace/OS_NS_sys_wait.inl +++ b/ace/OS_NS_sys_wait.inl @@ -1,4 +1,105 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +ACE_INLINE pid_t +ACE_OS::wait (int *status) +{ + ACE_OS_TRACE ("ACE_OS::wait"); +#if defined (ACE_WIN32) || defined (VXWORKS) || defined(CHORUS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_UNUSED_ARG (status); + + ACE_NOTSUP_RETURN (0); +#else +# if defined (ACE_HAS_UNION_WAIT) + ACE_OSCALL_RETURN (::wait ((union wait *) status), pid_t, -1); +# else + ACE_OSCALL_RETURN (::wait (status), pid_t, -1); +# endif /* ACE_HAS_UNION_WAIT */ +#endif /* ACE_WIN32 || VXWORKS || CHORUS || ACE_PSOS */ +} + +ACE_INLINE pid_t +ACE_OS::wait (pid_t pid, + ACE_exitcode *status, + int wait_options, + ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::wait"); + return ACE_OS::waitpid (pid, + status, + wait_options, + handle); +} + +ACE_INLINE pid_t +ACE_OS::waitpid (pid_t pid, + ACE_exitcode *status, + int wait_options, + ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::waitpid"); +#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_UNUSED_ARG (pid); + ACE_UNUSED_ARG (status); + ACE_UNUSED_ARG (wait_options); + ACE_UNUSED_ARG (handle); + + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_WIN32) + int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG) + ? 0 /* don't hang */ + : INFINITE; + + ACE_HANDLE phandle = handle; + + if (phandle == 0) + { + phandle = ::OpenProcess (SYNCHRONIZE, + FALSE, + pid); + + if (phandle == 0) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + } + + pid_t result = pid; + + // Don't try to get the process exit status if wait failed so we can + // keep the original error code intact. + switch (::WaitForSingleObject (phandle, + blocking_period)) + { + case WAIT_OBJECT_0: + if (status != 0) + // The error status of <GetExitCodeProcess> is nonetheless + // not tested because we don't know how to return the value. + ::GetExitCodeProcess (phandle, + status); + break; + case WAIT_TIMEOUT: + errno = ETIME; + result = 0; + break; + default: + ACE_OS::set_errno_to_last_error (); + result = -1; + } + if (handle == 0) + ::CloseHandle (phandle); + return result; +#elif defined (CHORUS) + ACE_UNUSED_ARG (status); + ACE_UNUSED_ARG (wait_options); + ACE_UNUSED_ARG (handle); + ACE_OSCALL_RETURN (::await (&ACE_OS::actorcaps_[pid]), + pid_t, -1); +#else + ACE_UNUSED_ARG (handle); + ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options), + pid_t, -1); +#endif /* VXWORKS || ACE_PSOS */ +} + diff --git a/ace/OS_NS_time.cpp b/ace/OS_NS_time.cpp index fc532b41367..50d8d686759 100644 --- a/ace/OS_NS_time.cpp +++ b/ace/OS_NS_time.cpp @@ -1,4 +1,810 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_time.h" + +ACE_RCSID(ace, OS_NS_time, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_time.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/OS_NS_Thread.h" +#include "ace/Object_Manager_Base.h" + +// hmmm, should this be only for ACE_MT_SAFE? dhinton +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# if defined (ACE_HAS_WINCE) +const wchar_t *ACE_OS::day_of_week_name[] = {ACE_LIB_TEXT ("Sun"), ACE_LIB_TEXT ("Mon"), + ACE_LIB_TEXT ("Tue"), ACE_LIB_TEXT ("Wed"), + ACE_LIB_TEXT ("Thu"), ACE_LIB_TEXT ("Fri"), + ACE_LIB_TEXT ("Sat")}; +const wchar_t *ACE_OS::month_name[] = {ACE_LIB_TEXT ("Jan"), ACE_LIB_TEXT ("Feb"), + ACE_LIB_TEXT ("Mar"), ACE_LIB_TEXT ("Apr"), + ACE_LIB_TEXT ("May"), ACE_LIB_TEXT ("Jun"), + ACE_LIB_TEXT ("Jul"), ACE_LIB_TEXT ("Aug"), + ACE_LIB_TEXT ("Sep"), ACE_LIB_TEXT ("Oct"), + ACE_LIB_TEXT ("Nov"), ACE_LIB_TEXT ("Dec") }; + +static const ACE_TCHAR *ACE_OS_CTIME_R_FMTSTR = ACE_LIB_TEXT ("%3s %3s %02d %02d:%02d:%02d %04d\n"); +# endif /* ACE_HAS_WINCE */ +#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ + +# if defined (ACE_PSOS) + +// bit masks and shifts for prying info out of the pSOS time encoding +const u_long ACE_PSOS_Time_t::year_mask = 0x0000FFFFul; +const u_long ACE_PSOS_Time_t::month_mask = 0x000000FFul; +const u_long ACE_PSOS_Time_t::day_mask = 0x000000FFul; +const u_long ACE_PSOS_Time_t::hour_mask = 0x0000FFFFul; +const u_long ACE_PSOS_Time_t::minute_mask = 0x000000FFul; +const u_long ACE_PSOS_Time_t::second_mask = 0x000000FFul; +const int ACE_PSOS_Time_t::year_shift = 16; +const int ACE_PSOS_Time_t::month_shift = 8; +const int ACE_PSOS_Time_t::hour_shift = 16; +const int ACE_PSOS_Time_t::minute_shift = 8; +const int ACE_PSOS_Time_t::year_origin = 1900; +const int ACE_PSOS_Time_t::month_origin = 1; + +// maximum number of clock ticks supported +const u_long ACE_PSOS_Time_t::max_ticks = ~0UL; + +ACE_PSOS_Time_t::ACE_PSOS_Time_t (void) + : date_ (0), + time_ (0), + ticks_ (0) +{ +} + +// default ctor: date, time, and ticks all zeroed + +ACE_PSOS_Time_t::ACE_PSOS_Time_t (const timespec_t& t) +{ + struct tm* tm_struct = ACE_OS::gmtime (&(t.tv_sec)); + + // Encode date values from tm struct into pSOS date bit array. + date_ = (ACE_PSOS_Time_t::year_mask & + ACE_static_cast (u_long, + tm_struct->tm_year + ACE_PSOS_Time_t::year_origin)) << + ACE_PSOS_Time_t::year_shift; + date_ |= (ACE_PSOS_Time_t::month_mask & + ACE_static_cast (u_long, + tm_struct->tm_mon + ACE_PSOS_Time_t::month_origin)) << + ACE_PSOS_Time_t::month_shift; + date_ |= ACE_PSOS_Time_t::day_mask & + ACE_static_cast (u_long, tm_struct->tm_mday); + // Encode time values from tm struct into pSOS time bit array. + time_ = (ACE_PSOS_Time_t::hour_mask & + ACE_static_cast (u_long, tm_struct->tm_hour)) << + ACE_PSOS_Time_t::hour_shift; + time_ |= (ACE_PSOS_Time_t::minute_mask & + ACE_static_cast (u_long, tm_struct->tm_min)) << + ACE_PSOS_Time_t::minute_shift; + time_ |= ACE_PSOS_Time_t::second_mask & + ACE_static_cast (u_int, tm_struct->tm_sec); + + // encode nanoseconds as system clock ticks + ticks_ = ACE_static_cast (u_long, + ((ACE_static_cast (double, t.tv_nsec) * + ACE_static_cast (double, KC_TICKS2SEC)) / + ACE_static_cast (double, 1000000000))); + +} + +// ctor from a timespec_t + +ACE_PSOS_Time_t::operator timespec_t (void) +{ + struct tm tm_struct; + + // Decode date and time bit arrays and fill in fields of tm_struct. + + tm_struct.tm_year = + ACE_static_cast (int, (ACE_PSOS_Time_t::year_mask & + (date_ >> ACE_PSOS_Time_t::year_shift))) - + ACE_PSOS_Time_t::year_origin; + tm_struct.tm_mon = + ACE_static_cast (int, (ACE_PSOS_Time_t::month_mask & + (date_ >> ACE_PSOS_Time_t::month_shift))) - + ACE_PSOS_Time_t::month_origin; + tm_struct.tm_mday = + ACE_static_cast (int, (ACE_PSOS_Time_t::day_mask & date_)); + tm_struct.tm_hour = + ACE_static_cast (int, (ACE_PSOS_Time_t::hour_mask & + (time_ >> ACE_PSOS_Time_t::hour_shift))); + tm_struct.tm_min = + ACE_static_cast (int, (ACE_PSOS_Time_t::minute_mask & + (time_ >> ACE_PSOS_Time_t::minute_shift))); + tm_struct.tm_sec = + ACE_static_cast (int, (ACE_PSOS_Time_t::second_mask & time_)); + + // Indicate values we don't know as negative numbers. + tm_struct.tm_wday = -1; + tm_struct.tm_yday = -1; + tm_struct.tm_isdst = -1; + + timespec_t t; + + // Convert calendar time to time struct. + t.tv_sec = ACE_OS::mktime (&tm_struct); + + // Encode nanoseconds as system clock ticks. + t.tv_nsec = ACE_static_cast (long, + ((ACE_static_cast (double, ticks_) * + ACE_static_cast (double, 1000000000)) / + ACE_static_cast (double, KC_TICKS2SEC))); + return t; +} + +// type cast operator (to a timespec_t) + +u_long +ACE_PSOS_Time_t::get_system_time (ACE_PSOS_Time_t& t) +{ + u_long ret_val = 0; + +# if defined (ACE_PSOSIM) // system time is broken in simulator. + timeval tv; + int result = 0; + ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result); + if (result == -1) + return 1; + + ACE_Time_Value atv (tv); + timespec ts = atv; + ACE_PSOS_Time_t pt (ts); + t.date_ = pt.date_; + t.time_ = pt.time_; + t.ticks_ = pt.ticks_; +# else + ret_val = tm_get (&(t.date_), &(t.time_), &(t.ticks_)); +# endif /* ACE_PSOSIM */ + return ret_val; +} + +// Static member function to get current system time. + +u_long +ACE_PSOS_Time_t::set_system_time (const ACE_PSOS_Time_t& t) +{ + return tm_set (t.date_, t.time_, t.ticks_); +} + +// Static member function to set current system time. + +# if defined (ACE_PSOSIM) + +u_long +ACE_PSOS_Time_t::init_simulator_time (void) +{ + // This is a hack using a direct UNIX system call, because the + // appropriate ACE_OS method ultimately uses the pSOS tm_get + // function, which would fail because the simulator's system time is + // uninitialized (chicken and egg). + timeval t; + int result = 0; + ACE_OSCALL (::gettimeofday (&t, 0), + int, + -1, + result); + + if (result == -1) + return 1; + else + { + ACE_Time_Value tv (t); + timespec ts = tv; + ACE_PSOS_Time_t pt (ts); + u_long ret_val = + ACE_PSOS_Time_t::set_system_time (pt); + return ret_val; + + } +} + +// Static member function to initialize system time, using UNIX calls. + +# endif /* ACE_PSOSIM */ +# endif /* ACE_PSOS && ! ACE_PSOS_DIAB_MIPS */ + +# if defined (ACE_HAS_WINCE) +ACE_TCHAR * +ACE_OS::ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen) +{ + // buflen must be at least 26 wchar_t long. + if (buflen < 26) // Again, 26 is a magic number. + { + errno = ERANGE; + return 0; + } + // This is really stupid, converting FILETIME to timeval back and + // forth. It assumes FILETIME and DWORDLONG are the same structure + // internally. + ULARGE_INTEGER _100ns; + _100ns.QuadPart = (DWORDLONG) *clock * 10000 * 1000 + + ACE_Time_Value::FILETIME_to_timval_skew; + FILETIME file_time; + file_time.dwLowDateTime = _100ns.LowPart; + file_time.dwHighDateTime = _100ns.HighPart; + + FILETIME localtime; + SYSTEMTIME systime; + FileTimeToLocalFileTime (&file_time, &localtime); + FileTimeToSystemTime (&localtime, &systime); + ACE_OS::sprintf (buf, ACE_OS_CTIME_R_FMTSTR, + ACE_OS::day_of_week_name[systime.wDayOfWeek], + ACE_OS::month_name[systime.wMonth - 1], + systime.wDay, + systime.wHour, + systime.wMinute, + systime.wSecond, + systime.wYear); + return buf; +} +# endif /* ACE_HAS_WINCE */ + +# if defined (ACE_LACKS_DIFFTIME) +double +ACE_OS::difftime (time_t t1, time_t t0) +{ + /* return t1 - t0 in seconds */ + struct tm tms[2], *ptms[2], temp; + double seconds; + double days; + int swap = 0; + + /* extract the tm structure from time_t */ + ptms[1] = gmtime_r (&t1, &tms[1]); + if (ptms[1] == 0) return 0.0; + + ptms[0] = gmtime_r (&t0, &tms[0]); + if (ptms[0] == 0) return 0.0; + + /* make sure t1 is > t0 */ + if (tms[1].tm_year < tms[0].tm_year) + swap = 1; + else if (tms[1].tm_year == tms[0].tm_year) + { + if (tms[1].tm_yday < tms[0].tm_yday) + swap = 1; + else if (tms[1].tm_yday == tms[0].tm_yday) + { + if (tms[1].tm_hour < tms[0].tm_hour) + swap = 1; + else if (tms[1].tm_hour == tms[0].tm_hour) + { + if (tms[1].tm_min < tms[0].tm_min) + swap = 1; + else if (tms[1].tm_min == tms[0].tm_min) + { + if (tms[1].tm_sec < tms[0].tm_sec) + swap = 1; + } + } + } + } + + if (swap) + temp = tms[0], tms[0] = tms[1], tms[1] = temp; + + seconds = 0.0; + if (tms[1].tm_year > tms[0].tm_year) + { + // Accumulate the time until t[0] catches up to t[1]'s year. + seconds = 60 - tms[0].tm_sec; + tms[0].tm_sec = 0; + tms[0].tm_min += 1; + seconds += 60 * (60 - tms[0].tm_min); + tms[0].tm_min = 0; + tms[0].tm_hour += 1; + seconds += 60*60 * (24 - tms[0].tm_hour); + tms[0].tm_hour = 0; + tms[0].tm_yday += 1; + +# define ISLEAPYEAR(y) ((y)&3u?0:(y)%25u?1:(y)/25u&12?0:1) + + if (ISLEAPYEAR(tms[0].tm_year)) + seconds += 60*60*24 * (366 - tms[0].tm_yday); + else + seconds += 60*60*24 * (365 - tms[0].tm_yday); + + tms[0].tm_yday = 0; + tms[0].tm_year += 1; + + while (tms[1].tm_year > tms[0].tm_year) + { + if (ISLEAPYEAR(tms[0].tm_year)) + seconds += 60*60*24 * 366; + else + seconds += 60*60*24 * 365; + + tms[0].tm_year += 1; + } + +# undef ISLEAPYEAR + + } + else + { + // Normalize + if (tms[1].tm_sec < tms[0].tm_sec) + { + if (tms[1].tm_min == 0) + { + if (tms[1].tm_hour == 0) + { + tms[1].tm_yday -= 1; + tms[1].tm_hour += 24; + } + tms[1].tm_hour -= 1; + tms[1].tm_min += 60; + } + tms[1].tm_min -= 1; + tms[1].tm_sec += 60; + } + tms[1].tm_sec -= tms[0].tm_sec; + + if (tms[1].tm_min < tms[0].tm_min) + { + if (tms[1].tm_hour == 0) + { + tms[1].tm_yday -= 1; + tms[1].tm_hour += 24; + } + tms[1].tm_hour -= 1; + tms[1].tm_min += 60; + } + tms[1].tm_min -= tms[0].tm_min; + + if (tms[1].tm_hour < tms[0].tm_hour) + { + tms[1].tm_yday -= 1; + tms[1].tm_hour += 24; + } + tms[1].tm_hour -= tms[0].tm_hour; + + tms[1].tm_yday -= tms[0].tm_yday; + } + + // accumulate the seconds + seconds += tms[1].tm_sec; + seconds += 60 * tms[1].tm_min; + seconds += 60*60 * tms[1].tm_hour; + seconds += 60*60*24 * tms[1].tm_yday; + + return seconds; +} +# endif /* ACE_LACKS_DIFFTIME */ + +struct tm * +ACE_OS::localtime_r (const time_t *t, struct tm *res) +{ + ACE_OS_TRACE ("ACE_OS::localtime_r"); +#if defined (ACE_HAS_REENTRANT_FUNCTIONS) +# if defined (DIGITAL_UNIX) + ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0); +# elif defined (HPUX_10) + return (::localtime_r (t, res) == 0 ? res : (struct tm *)0); +# else + ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0); +# endif /* DIGITAL_UNIX */ +#elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + ACE_OS_GUARD + + ACE_UNUSED_ARG (res); + struct tm * res_ptr; + ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr); + if (res_ptr == 0) + return 0; + else + { + *res = *res_ptr; + return res; + } +#elif defined (ACE_HAS_WINCE) + // This is really stupid, converting FILETIME to timeval back and + // forth. It assumes FILETIME and DWORDLONG are the same structure + // internally. + + TIME_ZONE_INFORMATION pTz; + + const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; + + ULARGE_INTEGER _100ns; + ::GetTimeZoneInformation (&pTz); + + _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 + ACE_Time_Value::FILETIME_to_timval_skew; + FILETIME file_time; + file_time.dwLowDateTime = _100ns.LowPart; + file_time.dwHighDateTime = _100ns.HighPart; + + FILETIME localtime; + SYSTEMTIME systime; + FileTimeToLocalFileTime (&file_time, &localtime); + FileTimeToSystemTime (&localtime, &systime); + + res->tm_hour = systime.wHour; + + if(pTz.DaylightBias!=0) + res->tm_isdst = 1; + else + res->tm_isdst = 1; + + int iLeap; + iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0)); + // based on leap select which group to use + + res->tm_mday = systime.wDay; + res->tm_min = systime.wMinute; + res->tm_mon = systime.wMonth; + res->tm_sec = systime.wSecond; + res->tm_wday = systime.wDayOfWeek; + res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay; + res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900 + res->tm_year = res->tm_year - 1900; + + return res; +#else + // @@ Same as ACE_OS::localtime (), you need to implement it + // yourself. + ACE_UNUSED_ARG (t); + ACE_UNUSED_ARG (res); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +} + +time_t +ACE_OS::mktime (struct tm *t) +{ + ACE_OS_TRACE ("ACE_OS::mktime"); +# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) + ACE_UNUSED_ARG (t); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_HAS_WINCE) + SYSTEMTIME t_sys; + FILETIME t_file; + t_sys.wSecond = t->tm_sec; + t_sys.wMinute = t->tm_min; + t_sys.wHour = t->tm_hour; + t_sys.wDay = t->tm_mday; + t_sys.wMonth = t->tm_mon + 1; // SYSTEMTIME is 1-indexed, tm is 0-indexed + t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900 + t_sys.wDayOfWeek = t->tm_wday; // Ignored in below function call. + if (SystemTimeToFileTime (&t_sys, &t_file) == 0) + return -1; + ACE_Time_Value tv (t_file); + return tv.sec (); +# else +# if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_MT_SAFE_MKTIME) + ACE_OS_GUARD +# endif /* ACE_HAS_THREADS && ! ACE_HAS_MT_SAFE_MKTIME */ + + ACE_OSCALL_RETURN (::mktime (t), time_t, (time_t) -1); +# endif /* ACE_PSOS && ! ACE_PSOS_HAS_TIME */ +} + +#if defined (ACE_HAS_POWERPC_TIMER) && defined (ghs) +void +ACE_OS::readPPCTimeBase (u_long &most, u_long &least) +{ + ACE_OS_TRACE ("ACE_OS::readPPCTimeBase"); + + // This function can't be inline because it depends on the arguments + // being in particular registers (r3 and r4), in conformance with the + // EABI standard. It would be nice if we knew how to put the variable + // names directly into the assembler instructions . . . + asm("aclock:"); + asm("mftb r5,TBU"); + asm("mftb r6,TBL"); + asm("mftb r7,TBU"); + asm("cmpw r5,r7"); + asm("bne aclock"); + + asm("stw r5, 0(r3)"); + asm("stw r6, 0(r4)"); +} +#elif defined (ACE_HAS_POWERPC_TIMER) && defined (__GNUG__) +void +ACE_OS::readPPCTimeBase (u_long &most, u_long &least) +{ + ACE_OS_TRACE ("ACE_OS::readPPCTimeBase"); + + // This function can't be inline because it defines a symbol, + // aclock. If there are multiple calls to the function in a + // compilation unit, then that symbol would be multiply defined if + // the function was inline. + asm volatile ("aclock:\n" + "mftbu 5\n" /* upper time base register */ + "mftb 6\n" /* lower time base register */ + "mftbu 7\n" /* upper time base register */ + "cmpw 5,7\n" /* check for rollover of upper */ + "bne aclock\n" + "stw 5,%0\n" /* most */ + "stw 6,%1" /* least */ + : "=m" (most), "=m" (least) /* outputs */ + : /* no inputs */ + : "5", "6", "7", "memory" /* constraints */); +} +#endif /* ACE_HAS_POWERPC_TIMER && (ghs or __GNUG__) */ + +#if defined (ACE_HAS_STRPTIME) +char * +ACE_OS::strptime (char *buf, const char *format, struct tm *tm) +{ +#if !defined (ACE_HAS_WINCE) +#if defined (ACE_LACKS_NATIVE_STRPTIME) + int bi = 0; + int fi = 0; + int percent = 0; + + if (!buf || !format) + return 0; + + while (format[fi] != '\0') + { + if (percent) + { + percent = 0; + switch (format[fi]) + { + case '%': // an escaped % + if (buf[bi] == '%') + { + fi++; bi++; + } + else + return buf + bi; + break; + + /* not supported yet: weekday via locale long/short names + case 'a': / * weekday via locale * / + / * FALL THROUGH * / + case 'A': / * long/short names * / + break; + */ + + /* not supported yet: + case 'b': / * month via locale * / + / * FALL THROUGH * / + case 'B': / * long/short names * / + / * FALL THROUGH * / + case 'h': + break; + */ + + /* not supported yet: + case 'c': / * %x %X * / + break; + */ + + /* not supported yet: + case 'C': / * date & time - * / + / * locale long format * / + break; + */ + + case 'd': /* day of month (1-31) */ + /* FALL THROUGH */ + case 'e': + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mday, &bi, &fi, 1, 31)) + return buf + bi; + + break; + + case 'D': /* %m/%d/%y */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mon, &bi, &fi, 1, 12)) + return buf + bi; + + fi--; + tm->tm_mon--; + + if (buf[bi] != '/') + return buf + bi; + + bi++; + + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mday, &bi, &fi, 1, 31)) + return buf + bi; + + fi--; + if (buf[bi] != '/') + return buf + bi; + bi++; + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_year, &bi, &fi, 0, 99)) + return buf + bi; + if (tm->tm_year < 69) + tm->tm_year += 100; + break; + + case 'H': /* hour (0-23) */ + /* FALL THROUGH */ + case 'k': + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23)) + return buf + bi; + break; + + /* not supported yet: + case 'I': / * hour (0-12) * / + / * FALL THROUGH * / + case 'l': + break; + */ + + case 'j': /* day of year (0-366) */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_yday, &bi, &fi, 1, 366)) + return buf + bi; + + tm->tm_yday--; + break; + + case 'm': /* an escaped % */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_mon, &bi, &fi, 1, 12)) + return buf + bi; + + tm->tm_mon--; + break; + + case 'M': /* minute (0-59) */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_min, &bi, &fi, 0, 59)) + return buf + bi; + + break; + + /* not supported yet: + case 'p': / * am or pm for locale * / + break; + */ + + /* not supported yet: + case 'r': / * %I:%M:%S %p * / + break; + */ + + case 'R': /* %H:%M */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23)) + return buf + bi; + + fi--; + if (buf[bi] != ':') + return buf + bi; + bi++; + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_min, &bi, &fi, 0, 59)) + return buf + bi; + + break; + + case 'S': /* seconds (0-61) */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_sec, &bi, &fi, 0, 61)) + return buf + bi; + break; + + case 'T': /* %H:%M:%S */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_hour, &bi, &fi, 0, 23)) + return buf + bi; + + fi--; + if (buf[bi] != ':') + return buf + bi; + bi++; + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_min, &bi, &fi, 0, 59)) + return buf + bi; + + fi--; + if (buf[bi] != ':') + return buf + bi; + bi++; + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_sec, &bi, &fi, 0, 61)) + return buf + bi; + + break; + + case 'w': /* day of week (0=Sun-6) */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_wday, &bi, &fi, 0, 6)) + return buf + bi; + + break; + + /* not supported yet: date, based on locale + case 'x': / * date, based on locale * / + break; + */ + + /* not supported yet: + case 'X': / * time, based on locale * / + break; + */ + + case 'y': /* the year - 1900 (0-99) */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_year, &bi, &fi, 0, 99)) + return buf + bi; + + if (tm->tm_year < 69) + tm->tm_year += 100; + break; + + case 'Y': /* the full year (1999) */ + if (!ACE_OS::strptime_getnum (buf + bi, &tm->tm_year, &bi, &fi, 0, 0)) + return buf + bi; + + tm->tm_year -= 1900; + break; + + default: /* unrecognised */ + return buf + bi; + } /* switch (format[fi]) */ + + } + else + { /* if (percent) */ + if (format[fi] == '%') + { + percent = 1; + fi++; + } + else + { + if (format[fi] == buf[bi]) + { + fi++; + bi++; + } + else + return buf + bi; + } + } /* if (percent) */ + } /* while (format[fi] */ + + return buf + bi; +#else /* ! ACE_LACKS_NATIVE_STRPTIME */ + return ::strptime (buf, + format, + tm); +#endif /* ! ACE_LACKS_NATIVE_STRPTIME */ +#else /* ! ACE_HAS_WINCE */ + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (format); + ACE_UNUSED_ARG (tm); + + ACE_NOTSUP_RETURN (0); +#endif /* ! ACE_HAS_WINCE */ +} + +# if defined (ACE_LACKS_NATIVE_STRPTIME) +int +ACE_OS::strptime_getnum (char *buf, + int *num, + int *bi, + int *fi, + int min, + int max) +{ + int i = 0, tmp = 0; + + while (isdigit (buf[i])) + { + tmp = (tmp * 10) + (buf[i] - '0'); + if (max && (tmp > max)) + return 0; + i++; + } + + if (tmp < min) + return 0; + else if (i) + { + *num = tmp; + (*fi)++; + *bi += i; + return 1; + } + else + return 0; +} +# endif /* ACE_LACKS_NATIVE_STRPTIME */ +#endif /* ACE_HAS_STRPTIME */ diff --git a/ace/OS_NS_time.h b/ace/OS_NS_time.h index fc532b41367..635e0a0e522 100644 --- a/ace/OS_NS_time.h +++ b/ace/OS_NS_time.h @@ -1,4 +1,317 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_time.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_TIME_H +# define ACE_OS_NS_TIME_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/os_time.h" + +# if defined (ACE_HAS_BROKEN_R_ROUTINES) +# undef ctime_r +# undef asctime_r +# endif /* ACE_HAS_BROKEN_R_ROUTINES */ + +#include "ace/Basic_Types.h" + +// Type-safe, and unsigned. +static const ACE_UINT32 ACE_U_ONE_SECOND_IN_MSECS = 1000U; +static const ACE_UINT32 ACE_U_ONE_SECOND_IN_USECS = 1000000U; +static const ACE_UINT32 ACE_U_ONE_SECOND_IN_NSECS = 1000000000U; + +#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 */ + +#if defined (ACE_HAS_WINCE) + /// Supporting data for ctime and ctime_r functions on WinCE. + const wchar_t *day_of_week_name[7]; + const wchar_t *month_name[12]; + +// WinCE doesn't have most of the standard C library time functions. It +// also doesn't define struct tm. SYSTEMTIME has pretty much the same +// info though, so we can map it when needed. Define struct tm here and +// use it when needed. This is taken from the standard C library. +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; // Day of the month + int tm_mon; + int tm_year; + int tm_wday; // Day of the week + int tm_yday; // Day in the year + int tm_isdst; // >0 if dst in effet; 0 if not; <0 if unknown +}; +#endif /* ACE_HAS_WINCE */ + +/// Helper for the ACE_OS::timezone() function +/** + * We put all the timezone stuff that used to be in ACE_OS::timezone() + * here because on some platforms "timezone" is a macro. Because of this, + * the name ACE_OS::timezone will cause errors. So in order to use the + * macro as it is defined but also keep the name ACE_OS::timezone, we + * use timezone first here in this inline function, and then undefine + * timezone. + */ +inline long ace_timezone() +{ +#if !defined (VXWORKS) && !defined (ACE_PSOS) && !defined (CHORUS) +# if defined (ACE_HAS_WINCE) + TIME_ZONE_INFORMATION tz; + GetTimeZoneInformation (&tz); + return tz.Bias * 60; +# elif defined (ACE_WIN32) + return _timezone; // For Win32. +# elif ( defined (__Lynx__) || defined (__FreeBSD__) || defined (ACE_HAS_SUNOS4_GETTIMEOFDAY) ) && ( !defined (__linux__) ) + long result = 0; + struct timeval time; + struct timezone zone; + ACE_UNUSED_ARG (result); + ACE_OSCALL (::gettimeofday (&time, &zone), int, -1, result); + return zone.tz_minuteswest * 60; +# else /* __Lynx__ || __FreeBSD__ ... */ +# if defined (__linux__) + // Under Linux, gettimeofday() does not correctly set the timezone + // struct, so we should use the global variable <timezone>. + // However, it is initialized by tzset(). I assume other systems + // are the same (i.e., tzset() needs to be called to set + // <timezone>), but since no one is complaining, I will only make + // the change for Linux. + ::tzset(); +# endif + return timezone; +# endif /* __Lynx__ || __FreeBSD__ ... */ +#else + ACE_NOTSUP_RETURN (0); +#endif /* !ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS */ +} + + +#if !defined (ACE_LACKS_DIFFTIME) +/// Helper for the ACE_OS::difftime() function +/** + * We moved the difftime code that used to be in ACE_OS::difftime() + * here because on some platforms "difftime" is a macro. Because of this, + * the name ACE_OS::difftime will cause errors. So in order to use the + * macro as it is defined but also keep the name ACE_OS::difftime, we + * use difftime first here in this inline function, and then undefine + * it. + */ +inline double ace_difftime(time_t t1, time_t t0) +{ +# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) + // simulate difftime ; just subtracting ; ACE_PSOS case + return ((double)t1) - ((double)t0); +# else + return difftime (t1, t0); +# endif /* ACE_PSOS !ACE_PSOS_HAS_TIME */ +} +#endif /* !ACE_LACKS_DIFFTIME */ + +# if defined (ACE_WIN32) +# if !defined (ACE_LACKS_LONGLONG_T) +// 64-bit quad-word definitions. +typedef unsigned __int64 ACE_QWORD; +typedef unsigned __int64 ACE_hrtime_t; +inline ACE_QWORD ACE_MAKE_QWORD (DWORD lo, DWORD hi) { return ACE_QWORD (lo) | (ACE_QWORD (hi) << 32); } +inline DWORD ACE_LOW_DWORD (ACE_QWORD q) { return (DWORD) q; } +inline DWORD ACE_HIGH_DWORD (ACE_QWORD q) { return (DWORD) (q >> 32); } +# else +// Can't find ANY place that ACE_QWORD is used, but hrtime_t is. +typedef ACE_UINT64 ACE_hrtime_t; +# endif // ACE_LACKS_LONGLONG_T +# elif defined (ACE_PSOS) +typedef ACE_UINT64 ACE_hrtime_t; +# else /* !ACE_WIN32 && !ACE_PSOS */ +# if defined (ACE_HAS_HI_RES_TIMER) && !defined (ACE_LACKS_LONGLONG_T) + /* hrtime_t is defined on systems (Suns) with ACE_HAS_HI_RES_TIMER */ + typedef hrtime_t ACE_hrtime_t; +# else /* ! ACE_HAS_HI_RES_TIMER || ACE_LACKS_LONGLONG_T */ + typedef ACE_UINT64 ACE_hrtime_t; +# endif /* ! ACE_HAS_HI_RES_TIMER || ACE_LACKS_LONGLONG_T */ +# endif /* ACE_WIN32 */ + + + +namespace ACE_OS { + +# if defined (CHORUS) && !defined (CHORUS_4) + // We must format this code as follows to avoid confusing OSE. + enum ACE_HRTimer_Op + { + ACE_HRTIMER_START = K_BSTART, + ACE_HRTIMER_INCR = K_BPOINT, + ACE_HRTIMER_STOP = K_BSTOP, + ACE_HRTIMER_GETTIME = 0xFFFF + }; +# else /* ! CHORUS */ + enum ACE_HRTimer_Op + { + ACE_HRTIMER_START = 0x0, // Only use these if you can stand + ACE_HRTIMER_INCR = 0x1, // for interrupts to be disabled during + ACE_HRTIMER_STOP = 0x2, // the timed interval!!!! + ACE_HRTIMER_GETTIME = 0xFFFF + }; +# endif /* ! CHORUS */ + + //@{ @name A set of wrappers for operations on time. + + char *asctime (const struct tm *tm); + + char *asctime_r (const struct tm *tm, + char *buf, int buflen); + + int clock_gettime (clockid_t, + struct timespec *); + + ACE_TCHAR *ctime (const time_t *t); + + ACE_TCHAR *ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen); + +# if defined (difftime) +# undef difftime +# endif /* difftime */ + + double difftime (time_t t1, + time_t t0); + + ACE_hrtime_t gethrtime (const ACE_HRTimer_Op = ACE_HRTIMER_GETTIME); + + struct tm *gmtime (const time_t *clock); + + struct tm *gmtime_r (const time_t *clock, + struct tm *res); + + struct tm *localtime (const time_t *clock); + + struct tm *localtime_r (const time_t *clock, + struct tm *res); + + // Get the current time. + time_t mktime (struct tm *timeptr); + + int nanosleep (const struct timespec *requested, + struct timespec *remaining = 0); + +# if defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__)) + void readPPCTimeBase (u_long &most, + u_long &least); +# endif /* ACE_HAS_POWERPC_TIMER && (ghs or __GNUG__) */ + + size_t strftime (char *s, + size_t maxsize, + const char *format, + const struct tm *timeptr); + +#if defined (ACE_HAS_STRPTIME) + char *strptime (char *buf, + const char *format, + struct tm *tm); + +# if defined (ACE_LACKS_NATIVE_STRPTIME) + int strptime_getnum (char *buf, int *num, int *bi, + int *fi, int min, int max); +# endif /* ACE_LACKS_NATIVE_STRPTIME */ +#endif /* ACE_HAS_STRPTIME */ + + time_t time (time_t *tloc = 0); + +# if defined (timezone) +# undef timezone +# endif /* timezone */ + + long timezone (void); + + // wrapper for time zone information. + void tzset (void); + + //@} +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_time.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_TIME_H */ diff --git a/ace/OS_NS_time.inl b/ace/OS_NS_time.inl index fc532b41367..dc5ba491912 100644 --- a/ace/OS_NS_time.inl +++ b/ace/OS_NS_time.inl @@ -1,4 +1,488 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/Time_Value.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE char * +ACE_OS::asctime (const struct tm *t) +{ +#if !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + ACE_OS_TRACE ("ACE_OS::asctime"); + ACE_OSCALL_RETURN (::asctime (t), char *, 0); +#else + // @@ WinCE doesn't have gmtime also. + ACE_UNUSED_ARG (t); + ACE_NOTSUP_RETURN (0); +#endif /* !ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ +} + +ACE_INLINE char * +ACE_OS::asctime_r (const struct tm *t, char *buf, int buflen) +{ + ACE_OS_TRACE ("ACE_OS::asctime_r"); +#if defined (ACE_HAS_REENTRANT_FUNCTIONS) +# if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) + char *result; +# if defined (DIGITAL_UNIX) + ACE_OSCALL (::_Pasctime_r (t, buf), char *, 0, result); +# else + ACE_OSCALL (::asctime_r (t, buf), char *, 0, result); +# endif /* DIGITAL_UNIX */ + ACE_OS::strsncpy (buf, result, buflen); + return buf; +# else +# if defined (HPUX_10) + return (::asctime_r(t, buf, buflen) == 0 ? buf : (char *)0); +# else + ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0); +# endif /* HPUX_10 */ +# endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ +#elif ! defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + char *result; + ACE_OSCALL (::asctime (t), char *, 0, result); + ACE_OS::strsncpy (buf, result, buflen); + return buf; +#else + // @@ Same as ACE_OS::asctime (), you need to implement it + // yourself. + ACE_UNUSED_ARG (t); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (buflen); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +} + +ACE_INLINE int +ACE_OS::clock_gettime (clockid_t clockid, struct timespec *ts) +{ + ACE_OS_TRACE ("ACE_OS::clock_gettime"); +#if defined (ACE_HAS_CLOCK_GETTIME) + ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1); +# elif defined (ACE_PSOS) && ! defined (ACE_PSOS_DIAB_MIPS) + ACE_UNUSED_ARG (clockid); + ACE_PSOS_Time_t pt; + int result = ACE_PSOS_Time_t::get_system_time (pt); + *ts = ACE_static_cast (struct timespec, pt); + return result; +#else + ACE_UNUSED_ARG (clockid); + ACE_UNUSED_ARG (ts); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_CLOCK_GETTIME */ +} + +// Magic number declaration and definition for ctime and ctime_r () +static const int ctime_buf_size = 26; + +ACE_INLINE ACE_TCHAR * +ACE_OS::ctime (const time_t *t) +{ + ACE_OS_TRACE ("ACE_OS::ctime"); +#if defined (ACE_HAS_BROKEN_CTIME) + ACE_OSCALL_RETURN (::asctime (::localtime (t)), char *, 0); +#elif defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) + return "ctime-return"; +#elif defined (ACE_HAS_WINCE) + static ACE_TCHAR buf [ctime_buf_size]; + return ACE_OS::ctime_r (t, + buf, + ctime_buf_size); +#elif defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0); +#else + ACE_OSCALL_RETURN (::ctime (t), char *, 0); +# endif /* ACE_HAS_BROKEN_CTIME */ +} + +#if !defined (ACE_HAS_WINCE) /* CE version in OS.cpp */ +ACE_INLINE ACE_TCHAR * +ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen) +{ + ACE_OS_TRACE ("ACE_OS::ctime_r"); + +#if defined (ACE_HAS_REENTRANT_FUNCTIONS) +# if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) + if (buflen < ctime_buf_size) + { + errno = ERANGE; + return 0; + } +# if defined (DIGITAL_UNIX) + ACE_OSCALL_RETURN (::_Pctime_r (t, buf), ACE_TCHAR *, 0); +# else /* DIGITAL_UNIX */ + ACE_OSCALL_RETURN (::ctime_r (t, buf), ACE_TCHAR *, 0); +# endif /* DIGITAL_UNIX */ + return buf; +# else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ + +# if defined (ACE_CTIME_R_RETURNS_INT) + return (::ctime_r (t, buf, buflen) == -1 ? 0 : buf); +# else /* ACE_CTIME_R_RETURNS_INT */ + ACE_OSCALL_RETURN (::ctime_r (t, buf, buflen), ACE_TCHAR *, 0); +# endif /* ACE_CTIME_R_RETURNS_INT */ + +# endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ +#else /* ACE_HAS_REENTRANT_FUNCTIONS */ +# if defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) + ACE_OS::strsncpy (buf, "ctime-return", buflen); + return buf; +# else /* ACE_PSOS && !ACE_PSOS_HAS_TIME */ + if (buflen < ctime_buf_size) + { + errno = ERANGE; + return 0; + } + + ACE_TCHAR *result; +# if defined (ACE_USES_WCHAR) + ACE_OSCALL (::_wctime (t), wchar_t *, 0, result); +# else /* ACE_USES_WCHAR */ + ACE_OSCALL (::ctime (t), char *, 0, result); +# endif /* ACE_USES_WCHAR */ + if (result != 0) + ACE_OS::strsncpy (buf, result, buflen); + return buf; +# endif /* ACE_PSOS && !ACE_PSOS_HAS_TIME */ +#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +} +#endif /* !ACE_HAS_WINCE */ + +#if !defined (ACE_LACKS_DIFFTIME) +ACE_INLINE double +ACE_OS::difftime (time_t t1, time_t t0) +{ + return ::ace_difftime (t1, t0); +} +#endif /* ! ACE_LACKS_DIFFTIME */ + +#if defined (ghs) && defined (ACE_HAS_PENTIUM) && !defined (ACE_WIN32) + extern "C" ACE_hrtime_t ACE_gethrtime (); +#endif /* ghs && ACE_HAS_PENTIUM */ + +ACE_INLINE ACE_hrtime_t +ACE_OS::gethrtime (const ACE_HRTimer_Op op) +{ + ACE_OS_TRACE ("ACE_OS::gethrtime"); +#if defined (ACE_HAS_HI_RES_TIMER) + ACE_UNUSED_ARG (op); + return ::gethrtime (); +#elif defined (ACE_HAS_AIX_HI_RES_TIMER) + ACE_UNUSED_ARG (op); + timebasestruct_t tb; + + ::read_real_time(&tb, TIMEBASE_SZ); + ::time_base_to_time(&tb, TIMEBASE_SZ); + + return ACE_hrtime_t(tb.tb_high) * ACE_ONE_SECOND_IN_NSECS + tb.tb_low; +#elif defined (ghs) && defined (ACE_HAS_PENTIUM) && !defined (ACE_WIN32) + ACE_UNUSED_ARG (op); + // Use .obj/gethrtime.o, which was compiled with g++. + return ACE_gethrtime (); +#elif (defined(__KCC) || defined (__GNUG__)) && !defined (__MINGW32__) && defined (ACE_HAS_PENTIUM) + ACE_UNUSED_ARG (op); + +# if defined (ACE_LACKS_LONGLONG_T) + double now; +# else /* ! ACE_LACKS_LONGLONG_T */ + ACE_hrtime_t now; +# endif /* ! ACE_LACKS_LONGLONG_T */ + + // See comments about the RDTSC Pentium instruction for the ACE_WIN32 + // version of ACE_OS::gethrtime (), below. + // + // Read the high-res tick counter directly into memory variable "now". + // The A constraint signifies a 64-bit int. + asm volatile ("rdtsc" : "=A" (now) : : "memory"); + +# if defined (ACE_LACKS_LONGLONG_T) + ACE_UINT32 least, most; + ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32)); + ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32), + sizeof (ACE_UINT32)); + + ACE_hrtime_t ret (least, most); + return ret; +# else /* ! ACE_LACKS_LONGLONG_T */ + return now; +# endif /* ! ACE_LACKS_LONGLONG_T */ +#elif defined (linux) && defined (ACE_HAS_ALPHA_TIMER) + // NOTE: alphas only have a 32 bit tick (cycle) counter. The rpcc + // instruction actually reads 64 bits, but the high 32 bits are + // implementation-specific. Linux and Digital Unix, for example, + // use them for virtual tick counts, i.e., taking into account only + // the time that the process was running. This information is from + // David Mosberger's article, see comment below. + ACE_UINT32 now; + + // The following statement is based on code published by: + // Mosberger, David, "How to Make Your Applications Fly, Part 1", + // Linux Journal Issue 42, October 1997, page 50. It reads the + // high-res tick counter directly into the memory variable. + asm volatile ("rpcc %0" : "=r" (now) : : "memory"); + + return now; +#elif defined (ACE_WIN32) + ACE_UNUSED_ARG(op); + LARGE_INTEGER freq; + + ::QueryPerformanceCounter (&freq); + +# if defined (ACE_LACKS_LONGLONG_T) + ACE_UINT64 uint64_freq(freq.u.LowPart, ACE_static_cast (unsigned int, freq.u.HighPart)); + return uint64_freq; +# else + return freq.QuadPart; +# endif //ACE_LACKS_LONGLONG_T + +#elif defined (CHORUS) + if (op == ACE_OS::ACE_HRTIMER_GETTIME) + { + struct timespec ts; + + ACE_OS::clock_gettime (CLOCK_REALTIME, &ts); + + // Carefully create the return value to avoid arithmetic overflow + // if ACE_hrtime_t is ACE_U_LongLong. + ACE_hrtime_t now = ts.tv_sec; + now *= ACE_U_ONE_SECOND_IN_NSECS; + now += ts.tv_nsec; + + return now; + } + else + { + // Use the sysBench timer on Chorus. On MVME177, at least, it only + // has 32 bits. Be careful, because using it disables interrupts! + ACE_UINT32 now; + if (::sysBench (op, (int *) &now) == K_OK) + { + now *= 1000u /* nanoseconds/microsecond */; + return (ACE_hrtime_t) now; + } + else + { + // Something went wrong. Just return 0. + return (ACE_hrtime_t) 0; + } + } + +#elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__)) + // PowerPC w/ GreenHills or g++. + + ACE_UNUSED_ARG (op); + u_long most; + u_long least; + ACE_OS::readPPCTimeBase (most, least); +#if defined (ACE_LACKS_LONGLONG_T) + return ACE_U_LongLong (least, most); +#else /* ! ACE_LACKS_LONGLONG_T */ + return 0x100000000llu * most + least; +#endif /* ! ACE_LACKS_LONGLONG_T */ + +#elif defined (ACE_HAS_CLOCK_GETTIME) || defined (ACE_PSOS) + // e.g., VxWorks (besides POWERPC && GreenHills) . . . + ACE_UNUSED_ARG (op); + struct timespec ts; + + ACE_OS::clock_gettime (CLOCK_REALTIME, &ts); + + // Carefully create the return value to avoid arithmetic overflow + // if ACE_hrtime_t is ACE_U_LongLong. + return ACE_static_cast (ACE_hrtime_t, ts.tv_sec) * + ACE_U_ONE_SECOND_IN_NSECS + ACE_static_cast (ACE_hrtime_t, ts.tv_nsec); +#else + ACE_UNUSED_ARG (op); + const ACE_Time_Value now = ACE_OS::gettimeofday (); + + // Carefully create the return value to avoid arithmetic overflow + // if ACE_hrtime_t is ACE_U_LongLong. + return (ACE_static_cast (ACE_hrtime_t, now.sec ()) * (ACE_UINT32) 1000000 + + ACE_static_cast (ACE_hrtime_t, now.usec ())) * (ACE_UINT32) 1000; +#endif /* ACE_HAS_HI_RES_TIMER */ +} + +ACE_INLINE struct tm * +ACE_OS::gmtime (const time_t *t) +{ +#if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + ACE_OS_TRACE ("ACE_OS::gmtime"); + ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0); +#else + // @@ WinCE doesn't have gmtime also. + ACE_UNUSED_ARG (t); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ +} + +ACE_INLINE struct tm * +ACE_OS::gmtime_r (const time_t *t, struct tm *res) +{ + ACE_OS_TRACE ("ACE_OS::gmtime_r"); +#if defined (ACE_HAS_REENTRANT_FUNCTIONS) +# if defined (DIGITAL_UNIX) + ACE_OSCALL_RETURN (::_Pgmtime_r (t, res), struct tm *, 0); +# elif defined (HPUX_10) + return (::gmtime_r (t, res) == 0 ? res : (struct tm *) 0); +# else + ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0); +# endif /* DIGITAL_UNIX */ +#elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + struct tm *result; + ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ; + if (result != 0) + *res = *result; + return res; +#else + // @@ Same as ACE_OS::gmtime (), you need to implement it + // yourself. + ACE_UNUSED_ARG (t); + ACE_UNUSED_ARG (res); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_REENTRANT_FUNCTIONS */ +} + +ACE_INLINE struct tm * +ACE_OS::localtime (const time_t *t) +{ +#if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + ACE_OS_TRACE ("ACE_OS::localtime"); + ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0); +#else + // @@ Don't you start wondering what kind of functions + // does WinCE really support? + ACE_UNUSED_ARG (t); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ +} + +ACE_INLINE int +ACE_OS::nanosleep (const struct timespec *requested, + struct timespec *remaining) +{ + ACE_OS_TRACE ("ACE_OS::nanosleep"); +#if defined (ACE_HAS_CLOCK_GETTIME) + // ::nanosleep () is POSIX 1003.1b. So is ::clock_gettime (). So, + // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should + // be available on the platform. On Solaris 2.x, both functions + // require linking with -lposix4. + return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining); +#elif defined (ACE_PSOS) +# if ! defined (ACE_PSOS_DIAB_MIPS) + double ticks = KC_TICKS2SEC * requested->tv_sec + + ( ACE_static_cast (double, requested->tv_nsec) * + ACE_static_cast (double, KC_TICKS2SEC) ) / + ACE_static_cast (double, ACE_ONE_SECOND_IN_NSECS); + + if (ticks > ACE_static_cast (double, ACE_PSOS_Time_t::max_ticks)) + { + ticks -= ACE_static_cast (double, ACE_PSOS_Time_t::max_ticks); + remaining->tv_sec = ACE_static_cast (time_t, + (ticks / + ACE_static_cast (double, + KC_TICKS2SEC))); + ticks -= ACE_static_cast (double, remaining->tv_sec) * + ACE_static_cast (double, KC_TICKS2SEC); + + remaining->tv_nsec = + ACE_static_cast (long, + (ticks * ACE_static_cast (double, + ACE_ONE_SECOND_IN_NSECS)) / + ACE_static_cast (double, KC_TICKS2SEC)); + + ::tm_wkafter (ACE_PSOS_Time_t::max_ticks); + } + else + { + remaining->tv_sec = 0; + remaining->tv_nsec = 0; + ::tm_wkafter (ACE_static_cast (u_long, ticks)); + } + + // tm_wkafter always returns 0 +# endif /* ACE_PSOS_DIAB_MIPS */ + return 0; +#else + ACE_UNUSED_ARG (remaining); + + // Convert into seconds and microseconds. +# if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS) + ACE_Time_Value tv (requested->tv_sec, + requested->tv_nsec / 1000); +# else + ACE_Time_Value tv (requested->ts_sec, + requested->ts_nsec / 1000); +# endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */ + return ACE_OS::sleep (tv); +#endif /* ACE_HAS_CLOCK_GETTIME */ +} + +ACE_INLINE size_t +ACE_OS::strftime (char *s, size_t maxsize, const char *format, + const struct tm *timeptr) +{ +#if !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME) + return ::strftime (s, maxsize, format, timeptr); +#else + ACE_UNUSED_ARG (s); + ACE_UNUSED_ARG (maxsize); + ACE_UNUSED_ARG (format); + ACE_UNUSED_ARG (timeptr); + ACE_NOTSUP_RETURN (0); +#endif /* !ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */ +} + +ACE_INLINE time_t +ACE_OS::time (time_t *tloc) +{ +#if !defined (ACE_HAS_WINCE) + ACE_OS_TRACE ("ACE_OS::time"); +# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) + unsigned long d_date, d_time, d_tick; + tm_get(&d_date, &d_time, &d_tick); // get current time + if (tloc) + *tloc = d_time; // set time as time_t + return d_time; +# else + ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1); +# endif /* ACE_PSOS && ! ACE_PSOS_HAS_TIME */ +#else + time_t retv = ACE_OS::gettimeofday ().sec (); + if (tloc) + *tloc = retv; + return retv; +#endif /* ACE_HAS_WINCE */ +} + +// Linux won't compile unless we explicitly use a namespace here. +#if defined (linux) || (defined (sun) && defined (__GNUG__)) +namespace ACE_OS { + ACE_INLINE long + timezone (void) + { + return ::ace_timezone (); + } +} /* namespace ACE_OS */ +#else +ACE_INLINE long +ACE_OS::timezone (void) +{ + return ::ace_timezone (); +} +#endif /* linux */ + +ACE_INLINE void +ACE_OS::tzset (void) +{ +#if !defined (ACE_HAS_WINCE) && !defined (VXWORKS) && !defined (ACE_PSOS) && ! defined(__rtems__) +# if defined (ACE_WIN32) + ::_tzset (); // For Win32. +# else + ::tzset (); // For UNIX platforms. +# endif /* ACE_WIN32 */ +# else + errno = ENOTSUP; +# endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS && !__rtems__ */ +} diff --git a/ace/OS_NS_unistd.cpp b/ace/OS_NS_unistd.cpp index fc532b41367..4b17f4667df 100644 --- a/ace/OS_NS_unistd.cpp +++ b/ace/OS_NS_unistd.cpp @@ -1,4 +1,712 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_unistd.h" + +ACE_RCSID(ace, OS_NS_unistd, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_unistd.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/Base_Thread_Adapter.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_ctype.h" +#include "ace/Default_Constants.h" +#include "ace/OS_Memory.h" + +#if defined (ACE_NEEDS_FTRUNCATE) +extern "C" int +ftruncate (ACE_HANDLE handle, long len) +{ + struct flock fl; + fl.l_whence = 0; + fl.l_len = 0; + fl.l_start = len; + fl.l_type = F_WRLCK; + + return ACE_OS::fcntl (handle, F_FREESP, ACE_reinterpret_cast (long, &fl)); +} +#endif /* ACE_NEEDS_FTRUNCATE */ + +/*****************************************************************************/ + +int +ACE_OS::argv_to_string (ACE_TCHAR **argv, + ACE_TCHAR *&buf, + int substitute_env_args) +{ + if (argv == 0 || argv[0] == 0) + return 0; + + size_t buf_len = 0; + + // Determine the length of the buffer. + + for (int i = 0; argv[i] != 0; i++) + { + ACE_TCHAR *temp = 0; + +#if !defined (ACE_LACKS_ENV) + // Account for environment variables. + if (substitute_env_args + && (argv[i][0] == '$' + && (temp = ACE_OS::getenv (&argv[i][1])) != 0)) + buf_len += ACE_OS::strlen (temp); + else +#endif /* ACE_LACKS_ENV */ + buf_len += ACE_OS::strlen (argv[i]); + + // Add one for the extra space between each string. + buf_len++; + } + + // Step through all argv params and copy each one into buf; separate + // each param with white space. + + ACE_NEW_RETURN (buf, + ACE_TCHAR[buf_len + 1], + 0); + + // Initial null charater to make it a null string. + buf[0] = '\0'; + ACE_TCHAR *end = buf; + int j; + + for (j = 0; argv[j] != 0; j++) + { + ACE_TCHAR *temp = 0; + +#if !defined (ACE_LACKS_ENV) + // Account for environment variables. + if (substitute_env_args + && (argv[j][0] == '$' + && (temp = ACE_OS::getenv (&argv[j][1])) != 0)) + end = ACE_OS::strecpy (end, temp); + else +#endif /* ACE_LACKS_ENV */ + end = ACE_OS::strecpy (end, argv[j]); + + // Replace the null char that strecpy put there with white + // space. + end[-1] = ' '; + } + + // Null terminate the string. + *end = '\0'; + // The number of arguments. + return j; +} + +int +ACE_OS::execl (const char * /* path */, const char * /* arg0 */, ...) +{ + ACE_OS_TRACE ("ACE_OS::execl"); +#if defined (ACE_WIN32) || defined (VXWORKS) + ACE_NOTSUP_RETURN (-1); +#else + ACE_NOTSUP_RETURN (-1); + // Need to write this code. + // ACE_OSCALL_RETURN (::execv (path, argv), int, -1); +#endif /* ACE_WIN32 */ +} + +int +ACE_OS::execle (const char * /* path */, const char * /* arg0 */, ...) +{ + ACE_OS_TRACE ("ACE_OS::execle"); +#if defined (ACE_WIN32) || defined (VXWORKS) + ACE_NOTSUP_RETURN (-1); +#else + ACE_NOTSUP_RETURN (-1); + // Need to write this code. + // ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); +#endif /* ACE_WIN32 */ +} + +int +ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...) +{ + ACE_OS_TRACE ("ACE_OS::execlp"); +#if defined (ACE_WIN32) || defined (VXWORKS) + ACE_NOTSUP_RETURN (-1); +#else + ACE_NOTSUP_RETURN (-1); + // Need to write this code. + // ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); +#endif /* ACE_WIN32 */ +} + +pid_t +ACE_OS::fork (const ACE_TCHAR *program_name) +{ + ACE_OS_TRACE ("ACE_OS::fork"); +# if defined (ACE_LACKS_FORK) + ACE_UNUSED_ARG (program_name); + ACE_NOTSUP_RETURN (pid_t (-1)); +# else + pid_t pid = +# if defined (ACE_HAS_STHREADS) + ::fork1 (); +#else + ::fork (); +#endif /* ACE_HAS_STHREADS */ + +#if !defined (ACE_HAS_MINIMAL_ACE_OS) + if (pid == 0) + ACE_Base_Thread_Adapter::sync_log_msg (program_name); +#endif /* ! ACE_HAS_MINIMAL_ACE_OS */ + + return pid; +# endif /* ACE_WIN32 */ +} + +// Create a contiguous command-line argument buffer with each arg +// separated by spaces. + +pid_t +ACE_OS::fork_exec (ACE_TCHAR *argv[]) +{ +# if defined (ACE_WIN32) + ACE_TCHAR *buf; + + if (ACE_OS::argv_to_string (argv, buf) != -1) + { + PROCESS_INFORMATION process_info; +# if !defined (ACE_HAS_WINCE) + ACE_TEXT_STARTUPINFO startup_info; + ACE_OS::memset ((void *) &startup_info, + 0, + sizeof startup_info); + startup_info.cb = sizeof startup_info; + + if (ACE_TEXT_CreateProcess (0, + buf, + 0, // No process attributes. + 0, // No thread attributes. + TRUE, // Allow handle inheritance. + 0, // Don't create a new console window. + 0, // No environment. + 0, // No current directory. + &startup_info, + &process_info)) +# else + if (ACE_TEXT_CreateProcess (0, + buf, + 0, // No process attributes. + 0, // No thread attributes. + FALSE, // Can's inherit handles on CE + 0, // Don't create a new console window. + 0, // No environment. + 0, // No current directory. + 0, // Can't use startup info on CE + &process_info)) +# endif /* ! ACE_HAS_WINCE */ + { + // Free resources allocated in kernel. + ACE_OS::close (process_info.hThread); + ACE_OS::close (process_info.hProcess); + // Return new process id. + delete [] buf; + return process_info.dwProcessId; + } + } + + // CreateProcess failed. + return -1; +# elif defined (CHORUS) + return ACE_OS::execv (argv[0], argv); +# else + pid_t result = ACE_OS::fork (); + + switch (result) + { + case -1: + // Error. + return -1; + case 0: + // Child process. + if (ACE_OS::execv (argv[0], argv) == -1) + { + // The OS layer should not print stuff out + // ACE_ERROR ((LM_ERROR, + // "%p Exec failed\n")); + + // If the execv fails, this child needs to exit. + ACE_OS::exit (errno); + } + default: + // Server process. The fork succeeded. + return result; + } +# endif /* ACE_WIN32 */ +} + +long +ACE_OS::num_processors (void) +{ + ACE_OS_TRACE ("ACE_OS::num_processors"); + +#if defined (ACE_HAS_PHARLAP) + return 1; +#elif defined (ACE_WIN32) || defined (ACE_WIN64) + SYSTEM_INFO sys_info; + ::GetSystemInfo (&sys_info); + return sys_info.dwNumberOfProcessors; +#elif defined (linux) || defined (sun) + return ::sysconf (_SC_NPROCESSORS_CONF); +#else + ACE_NOTSUP_RETURN (-1); +#endif +} + +long +ACE_OS::num_processors_online (void) +{ + ACE_OS_TRACE ("ACE_OS::num_processors_online"); + +#if defined (ACE_HAS_PHARLAP) + return 1; +#elif defined (ACE_WIN32) || defined (ACE_WIN64) + SYSTEM_INFO sys_info; + ::GetSystemInfo (&sys_info); + return sys_info.dwNumberOfProcessors; +#elif defined (linux) || defined (sun) + return ::sysconf (_SC_NPROCESSORS_ONLN); +#elif defined (__hpux) + struct pst_dynamic psd; + if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) + return psd.psd_proc_cnt; + else + return -1; +#else + ACE_NOTSUP_RETURN (-1); +#endif +} + +ssize_t +ACE_OS::read_n (ACE_HANDLE handle, + void *buf, + size_t len, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + n = ACE_OS::read (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred); + + if (n == -1 || n == 0) + return n; + } + + return bytes_transferred; +} + +ssize_t +ACE_OS::pread (ACE_HANDLE handle, + void *buf, + size_t nbytes, + off_t offset) +{ +# if defined (ACE_HAS_P_READ_WRITE) +# if defined (ACE_WIN32) + + ACE_OS_GUARD + + // Remember the original file pointer position + DWORD original_position = ::SetFilePointer (handle, + 0, + 0, + FILE_CURRENT); + + if (original_position == 0xFFFFFFFF) + return -1; + + // Go to the correct position + DWORD altered_position = ::SetFilePointer (handle, + offset, + 0, + FILE_BEGIN); + if (altered_position == 0xFFFFFFFF) + return -1; + + DWORD bytes_read; + +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) + + OVERLAPPED overlapped; + overlapped.Internal = 0; + overlapped.InternalHigh = 0; + overlapped.Offset = offset; + overlapped.OffsetHigh = 0; + overlapped.hEvent = 0; + + BOOL result = ::ReadFile (handle, + buf, + ACE_static_cast (DWORD, nbytes), + &bytes_read, + &overlapped); + + if (result == FALSE) + { + if (::GetLastError () != ERROR_IO_PENDING) + return -1; + + else + { + result = ::GetOverlappedResult (handle, + &overlapped, + &bytes_read, + TRUE); + if (result == FALSE) + return -1; + } + } + +# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + + BOOL result = ::ReadFile (handle, + buf, + nbytes, + &bytes_read, + 0); + if (result == FALSE) + return -1; + +# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + + // Reset the original file pointer position + if (::SetFilePointer (handle, + original_position, + 0, + FILE_BEGIN) == 0xFFFFFFFF) + return -1; + + return (ssize_t) bytes_read; + +# else /* ACE_WIN32 */ + + return ::pread (handle, buf, nbytes, offset); + +# endif /* ACE_WIN32 */ + +# else /* ACE_HAS_P_READ_WRITE */ + + ACE_OS_GUARD + + // Remember the original file pointer position + off_t original_position = ACE_OS::lseek (handle, + 0, + SEEK_CUR); + + if (original_position == -1) + return -1; + + // Go to the correct position + off_t altered_position = ACE_OS::lseek (handle, + offset, + SEEK_SET); + + if (altered_position == -1) + return -1; + + ssize_t bytes_read = ACE_OS::read (handle, + buf, + nbytes); + + if (bytes_read == -1) + return -1; + + if (ACE_OS::lseek (handle, + original_position, + SEEK_SET) == -1) + return -1; + + return bytes_read; + +# endif /* ACE_HAD_P_READ_WRITE */ +} + +ssize_t +ACE_OS::pwrite (ACE_HANDLE handle, + const void *buf, + size_t nbytes, + off_t offset) +{ +# if defined (ACE_HAS_P_READ_WRITE) +# if defined (ACE_WIN32) + + ACE_OS_GUARD + + // Remember the original file pointer position + DWORD original_position = ::SetFilePointer (handle, + 0, + 0, + FILE_CURRENT); + + if (original_position == 0xFFFFFFFF) + return -1; + + // Go to the correct position + DWORD altered_position = ::SetFilePointer (handle, + offset, + 0, + FILE_BEGIN); + if (altered_position == 0xFFFFFFFF) + return -1; + + DWORD bytes_written; + +# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0) + + OVERLAPPED overlapped; + overlapped.Internal = 0; + overlapped.InternalHigh = 0; + overlapped.Offset = offset; + overlapped.OffsetHigh = 0; + overlapped.hEvent = 0; + + BOOL result = ::WriteFile (handle, + buf, + ACE_static_cast (DWORD, nbytes), + &bytes_written, + &overlapped); + + if (result == FALSE) + { + if (::GetLastError () != ERROR_IO_PENDING) + return -1; + + else + { + result = ::GetOverlappedResult (handle, + &overlapped, + &bytes_written, + TRUE); + if (result == FALSE) + return -1; + } + } + +# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + + BOOL result = ::WriteFile (handle, + buf, + nbytes, + &bytes_written, + 0); + if (result == FALSE) + return -1; + +# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */ + + // Reset the original file pointer position + if (::SetFilePointer (handle, + original_position, + 0, + FILE_BEGIN) == 0xFFFFFFFF) + return -1; + + return (ssize_t) bytes_written; + +# else /* ACE_WIN32 */ + + return ::pwrite (handle, buf, nbytes, offset); +# endif /* ACE_WIN32 */ +# else /* ACE_HAS_P_READ_WRITE */ + + ACE_OS_GUARD + + // Remember the original file pointer position + off_t original_position = ACE_OS::lseek (handle, + 0, + SEEK_CUR); + if (original_position == -1) + return -1; + + // Go to the correct position + off_t altered_position = ACE_OS::lseek (handle, + offset, + SEEK_SET); + if (altered_position == -1) + return -1; + + ssize_t bytes_written = ACE_OS::write (handle, + buf, + nbytes); + if (bytes_written == -1) + return -1; + + if (ACE_OS::lseek (handle, + original_position, + SEEK_SET) == -1) + return -1; + + return bytes_written; +# endif /* ACE_HAD_P_READ_WRITE */ +} + +int +ACE_OS::string_to_argv (ACE_TCHAR *buf, + int &argc, + ACE_TCHAR **&argv, + int substitute_env_args) +{ + // Reset the number of arguments + argc = 0; + + if (buf == 0) + return -1; + + ACE_TCHAR *cp = buf; + + // First pass: count arguments. + + // '#' is the start-comment token.. + while (*cp != ACE_LIB_TEXT ('\0') && *cp != ACE_LIB_TEXT ('#')) + { + // Skip whitespace.. + while (ACE_OS::ace_isspace (*cp)) + cp++; + + // Increment count and move to next whitespace.. + if (*cp != ACE_LIB_TEXT ('\0')) + argc++; + + while (*cp != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*cp)) + { + // Grok quotes.... + if (*cp == ACE_LIB_TEXT ('\'') || *cp == ACE_LIB_TEXT ('"')) + { + ACE_TCHAR quote = *cp; + + // Scan past the string.. + for (cp++; *cp != ACE_LIB_TEXT ('\0') && *cp != quote; cp++) + continue; + + // '\0' implies unmatched quote.. + if (*cp == ACE_LIB_TEXT ('\0')) + { + argc--; + break; + } + else + cp++; + } + else + cp++; + } + } + + // Second pass: copy arguments. + ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ]; + ACE_TCHAR *argp = arg; + + // Make sure that the buffer we're copying into is always large + // enough. + if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ) + ACE_NEW_RETURN (argp, + ACE_TCHAR[cp - buf + 1], + -1); + + // Make a new argv vector of argc + 1 elements. + ACE_NEW_RETURN (argv, + ACE_TCHAR *[argc + 1], + -1); + + ACE_TCHAR *ptr = buf; + + for (int i = 0; i < argc; i++) + { + // Skip whitespace.. + while (ACE_OS::ace_isspace (*ptr)) + ptr++; + + // Copy next argument and move to next whitespace.. + cp = argp; + while (*ptr != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr)) + if (*ptr == ACE_LIB_TEXT ('\'') || *ptr == ACE_LIB_TEXT ('"')) + { + ACE_TCHAR quote = *ptr++; + + while (*ptr != ACE_LIB_TEXT ('\0') && *ptr != quote) + *cp++ = *ptr++; + + if (*ptr == quote) + ptr++; + } + else + *cp++ = *ptr++; + + *cp = ACE_LIB_TEXT ('\0'); + +#if !defined (ACE_LACKS_ENV) + // Check for environment variable substitution here. + if (substitute_env_args) { + argv[i] = ACE_OS::strenvdup(argp); + + if (argv[i] == 0) + { + if (argp != arg) + delete [] argp; + errno = ENOMEM; + return -1; + } + } + else +#endif /* ACE_LACKS_ENV */ + { + argv[i] = ACE_OS::strdup(argp); + + if (argv[i] == 0) + { + if (argp != arg) + delete [] argp; + errno = ENOMEM; + return -1; + } + } + } + + if (argp != arg) + delete [] argp; + + argv[argc] = 0; + return 0; +} + +// Write <len> bytes from <buf> to <handle> (uses the <write> +// system call on UNIX and the <WriteFile> call on Win32). + +ssize_t +ACE_OS::write_n (ACE_HANDLE handle, + const void *buf, + size_t len, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + n = ACE_OS::write (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred); + + if (n == -1 || n == 0) + return n; + } + + return bytes_transferred; +} + diff --git a/ace/OS_NS_unistd.h b/ace/OS_NS_unistd.h index fc532b41367..51f67f62f74 100644 --- a/ace/OS_NS_unistd.h +++ b/ace/OS_NS_unistd.h @@ -1,4 +1,264 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_unistd.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_UNISTD_H +# define ACE_OS_NS_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/os_unistd.h" +#include "ace/Time_Value.h" +#include "ace/os_include/os_stdio.h" + +// This should go in os_unistd.h, but since we don't yet implement any code +// at that level, we put it here. It used to be in OS.i. +#if defined (ACE_NEEDS_FTRUNCATE) +extern "C" ACE_Export int ftruncate (ACE_HANDLE handle, long len); +#endif /* ACE_NEEDS_FTRUNCATE */ + +namespace ACE_OS { + + int access (const char *path, int amode); + +#if defined (ACE_HAS_WCHAR) + int access (const wchar_t *path, int amode); +#endif /* ACE_HAS_WCHAR */ + + unsigned int alarm (u_int secs); + + int allocation_granularity (void); + + // used by ARGV::argv_to_string() and ACE_OS::fork_exec() + int argv_to_string (ACE_TCHAR **argv, + ACE_TCHAR *&buf, + int substitute_env_args = 1); + +#if !defined (ACE_LACKS_CHDIR) + int chdir (const char *path); + +#if defined (ACE_HAS_WCHAR) + int chdir (const wchar_t *path); +#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_LACKS_CHDIR */ + + int close (ACE_HANDLE handle); + + ACE_HANDLE dup (ACE_HANDLE handle); + + int dup2 (ACE_HANDLE oldfd, + ACE_HANDLE newfd); + + int execl (const char *path, + const char *arg0, ...); + + int execle (const char *path, + const char *arg0, ...); + + int execlp (const char *file, + const char *arg0, ...); + + int execv (const char *path, + char *const argv[]); + + int execve (const char *path, + char *const argv[], + char *const envp[]); + + int execvp (const char *file, + char *const argv[]); + + //@{ + /// Forks and exec's a process in a manner that works on Solaris and + /// NT. argv[0] must be the full path name to the executable. + pid_t fork (void); + + // not in susv3 + pid_t fork (const ACE_TCHAR *program_name); + + pid_t fork_exec (ACE_TCHAR *argv[]); + + //@} + + int fsync (ACE_HANDLE handle); + + int ftruncate (ACE_HANDLE, + off_t); + + ACE_TCHAR *getcwd (ACE_TCHAR *, size_t); + + gid_t getgid (void); + + int getopt (int argc, + char *const *argv, + const char *optstring); + + int getpagesize (void); + + pid_t getpgid (pid_t pid); + + pid_t getpid (void); + + pid_t getppid (void); + + uid_t getuid (void); + + // should call gethostname() + int hostname (char *name, + size_t maxnamelen); + +#if defined (ACE_HAS_WCHAR) + int hostname (wchar_t *name, + size_t maxnamelen); +#endif /* ACE_HAS_WCHAR */ + + int isatty (int handle); + +#if defined (ACE_WIN32) + int isatty (ACE_HANDLE handle); +#endif /* ACE_WIN32 */ + + off_t lseek (ACE_HANDLE handle, + off_t offset, + int whence); + +#if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64) + ACE_LOFF_T llseek (ACE_HANDLE handle, ACE_LOFF_T offset, int whence); +#endif /* ACE_HAS_LLSEEK */ + + /// Get the number of CPUs configured in the machine. + long num_processors (void); + + /// Get the number of CPUs currently online. + long num_processors_online (void); + + int pipe (ACE_HANDLE handles[]); + + ssize_t pread (ACE_HANDLE handle, + void *buf, + size_t nbyte, + off_t offset); + + ssize_t pwrite (ACE_HANDLE handle, + const void *buf, + size_t nbyte, + off_t offset); + + ssize_t read (ACE_HANDLE handle, + void *buf, + size_t len); + + ssize_t read (ACE_HANDLE handle, + void *buf, + size_t len, + ACE_OVERLAPPED *); + + /** + * Receive <len> bytes into <buf> from <handle> (uses the + * <ACE_OS::read> call, which uses the <read> system call on UNIX + * and the <ReadFile> call on Win32). If errors occur, -1 is + * returned. If EOF occurs, 0 is returned. Whatever data has been + * read will be returned to the caller through<bytes_transferred>. + * + */ + ssize_t read_n (ACE_HANDLE handle, + void *buf, + size_t len, + size_t *bytes_transferred = 0); + + int readlink (const char *path, + char *buf, + size_t bufsiz); + + void *sbrk (int brk); + + int setgid (gid_t); + + int setpgid (pid_t pid, pid_t pgid); + + int setregid (gid_t rgid, gid_t egid); + + int setreuid (uid_t ruid, uid_t euid); + + pid_t setsid (void); + + int setuid (uid_t); + + int sleep (u_int seconds); + + int sleep (const ACE_Time_Value &tv); + + // used by ARGV::string_to_argv + int string_to_argv (ACE_TCHAR *buf, + int &argc, + ACE_TCHAR **&argv, + int substitute_env_args = 1); + + long sysconf (int); + + // not in susv3 + long sysinfo (int cmd, + char *buf, + long count); + + int truncate (const ACE_TCHAR *filename, off_t length); + + u_int ualarm (u_int usecs, + u_int interval = 0); + + u_int ualarm (const ACE_Time_Value &tv, + const ACE_Time_Value &tv_interval = ACE_Time_Value::zero); + + int unlink (const ACE_TCHAR *path); + + ssize_t write (ACE_HANDLE handle, + const void *buf, + size_t nbyte); + + ssize_t write (ACE_HANDLE handle, + const void *buf, + size_t nbyte, + ACE_OVERLAPPED *); + + /** + * Send <len> bytes from <buf> to <handle> (uses the <ACE_OS::write> + * calls, which is uses the <write> system call on UNIX and the + * <WriteFile> call on Win32). If errors occur, -1 is returned. If + * EOF occurs, 0 is returned. Whatever data has been transmitted + * will be returned to the caller through <bytes_transferred>. + */ + ssize_t write_n (ACE_HANDLE handle, + const void *buf, + size_t len, + size_t *bytes_transferred = 0); + +} /* namespace ACE_OS */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_unistd.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_UNISTD_H */ diff --git a/ace/OS_NS_unistd.inl b/ace/OS_NS_unistd.inl index fc532b41367..ed2c6c34596 100644 --- a/ace/OS_NS_unistd.inl +++ b/ace/OS_NS_unistd.inl @@ -1,4 +1,1224 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_sys_utsname.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" + +ACE_INLINE int +ACE_OS::access (const char *path, int amode) +{ + ACE_OS_TRACE ("ACE_OS::access"); +#if defined (ACE_LACKS_ACCESS) +# if defined (ACE_HAS_WINCE) + // @@ WINCE: There should be a Win32 API that can do this. + // Hard coded read access here. + FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path), ACE_LIB_TEXT ("r")); + ACE_UNUSED_ARG (amode); + + ACE_OS::fclose (handle); + return (handle == ACE_INVALID_HANDLE ? -1 : 0); +# elif defined (VXWORKS) + FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path), ACE_LIB_TEXT ("r")); + ACE_UNUSED_ARG (amode); + if (handle != 0) + { + ACE_OS::fclose (handle); + return 0; + } + return (-1); +# else + ACE_UNUSED_ARG (path); + ACE_UNUSED_ARG (amode); + ACE_NOTSUP_RETURN (-1); +# endif // ACE_HAS_WINCE +#else + ACE_OSCALL_RETURN (::access (path, amode), int, -1); +#endif /* ACE_LACKS_ACCESS */ +} + + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::access (const wchar_t *path, int amode) +{ +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_OSCALL_RETURN (::_waccess (path, amode), int, -1); +#else /* ACE_WIN32 && !ACE_HAS_WINCE */ + return ACE_OS::access (ACE_Wide_To_Ascii (path).char_rep (), amode); +#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE u_int +ACE_OS::alarm (u_int secs) +{ + ACE_OS_TRACE ("ACE_OS::alarm"); +#if defined (ACE_WIN32) || defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (secs); + + ACE_NOTSUP_RETURN (0); +#else + return ::alarm (secs); +#endif /* ACE_WIN32 || VXWORKS || CHORUS || ACE_PSOS */ +} + +ACE_INLINE int +ACE_OS::allocation_granularity (void) +{ +#if defined (ACE_WIN32) + SYSTEM_INFO sys_info; + ::GetSystemInfo (&sys_info); + return (int) sys_info.dwAllocationGranularity; +#else + return ACE_OS::getpagesize (); +#endif /* ACE_WIN32 */ +} + +#if !defined (ACE_LACKS_CHDIR) +ACE_INLINE int +ACE_OS::chdir (const char *path) +{ + ACE_OS_TRACE ("ACE_OS::chdir"); +#if defined (VXWORKS) + ACE_OSCALL_RETURN (::chdir (ACE_const_cast (char *, path)), int, -1); + +#elif defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (path); + ACE_NOTSUP_RETURN (-1); + +#elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::change_dir ((char *) path), ace_result_), + int, -1); + +// This #elif seems weird... is Visual Age on NT not setting ACE_WIN32? +#elif !defined (ACE_WIN32) && !defined (AIX) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) + ACE_OSCALL_RETURN (::_chdir (path), int, -1); + +#elif defined (ACE_HAS_WINCE) + ACE_UNUSED_ARG (path); + ACE_NOTSUP_RETURN (-1); + +#else + ACE_OSCALL_RETURN (::chdir (path), int, -1); + +#endif /* VXWORKS */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::chdir (const wchar_t *path) +{ +#if defined (ACE_WIN32) + ACE_OSCALL_RETURN (::_wchdir (path), int, -1); +#else /* ACE_WIN32 */ + return ACE_OS::chdir (ACE_Wide_To_Ascii (path).char_rep ()); +#endif /* ACE_WIN32 */ +} +#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_LACKS_CHDIR */ + +// @todo: which 4 and why??? dhinton +// NOTE: The following four function definitions must appear before +// ACE_OS::sema_init (). + +ACE_INLINE int +ACE_OS::close (ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::close"); +#if defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1); +#elif defined (ACE_PSOS) && ! defined (ACE_PSOS_LACKS_PHILE) + u_long result = ::close_f (handle); + if (result != 0) + { + errno = result; + return ACE_static_cast (int, -1); + } + return ACE_static_cast (int, 0); +#else + ACE_OSCALL_RETURN (::close (handle), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE ACE_HANDLE +ACE_OS::dup (ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::dup"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_HANDLE new_fd; + if (::DuplicateHandle(::GetCurrentProcess (), + handle, + ::GetCurrentProcess(), + &new_fd, + 0, + TRUE, + DUPLICATE_SAME_ACCESS)) + return new_fd; + else + ACE_FAIL_RETURN (ACE_INVALID_HANDLE); + /* NOTREACHED */ +#elif defined (VXWORKS) || defined (ACE_PSOS) + ACE_UNUSED_ARG (handle); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_HAS_WINCE) + ACE_UNUSED_ARG (handle); + ACE_NOTSUP_RETURN (0); +#else + ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE); +#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ +} + +ACE_INLINE int +ACE_OS::dup2 (ACE_HANDLE oldhandle, ACE_HANDLE newhandle) +{ + ACE_OS_TRACE ("ACE_OS::dup2"); +#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS) + // msvcrt has _dup2 ?! + ACE_UNUSED_ARG (oldhandle); + ACE_UNUSED_ARG (newhandle); + + ACE_NOTSUP_RETURN (-1); +#else + ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1); +#endif /* ACE_WIN32 || VXWORKS || ACE_PSOS */ +} + +ACE_INLINE int +ACE_OS::execv (const char *path, + char *const argv[]) +{ + ACE_OS_TRACE ("ACE_OS::execv"); +#if defined (ACE_LACKS_EXEC) + ACE_UNUSED_ARG (path); + ACE_UNUSED_ARG (argv); + + ACE_NOTSUP_RETURN (-1); +#elif defined (CHORUS) + KnCap cactorcap; + int result = ::afexecv (path, &cactorcap, 0, argv); + if (result != -1) + ACE_OS::actorcaps_[result] = cactorcap; + return result; +#elif defined (ACE_WIN32) +# if defined (__BORLANDC__) /* VSB */ + return ::execv (path, argv); +# elif defined (__MINGW32__) + return ::_execv (path, (char *const *) argv); +# else + return ::_execv (path, (const char *const *) argv); +# endif /* __BORLANDC__ */ +#elif defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::execv (path, (const char **) argv), int, -1); +#else + ACE_OSCALL_RETURN (::execv (path, argv), int, -1); +#endif /* ACE_LACKS_EXEC */ +} + +ACE_INLINE int +ACE_OS::execve (const char *path, + char *const argv[], + char *const envp[]) +{ + ACE_OS_TRACE ("ACE_OS::execve"); +#if defined (ACE_LACKS_EXEC) + ACE_UNUSED_ARG (path); + ACE_UNUSED_ARG (argv); + ACE_UNUSED_ARG (envp); + + ACE_NOTSUP_RETURN (-1); +#elif defined(CHORUS) + KnCap cactorcap; + int result = ::afexecve (path, &cactorcap, 0, argv, envp); + if (result != -1) + ACE_OS::actorcaps_[result] = cactorcap; + return result; +#elif defined (ACE_WIN32) +# if defined (__BORLANDC__) /* VSB */ + return ::execve (path, argv, envp); +# elif defined (__MINGW32__) + return ::_execve (path, (char *const *) argv, (char *const *) envp); +# else + return ::_execve (path, (const char *const *) argv, (const char *const *) envp); +# endif /* __BORLANDC__ */ +#elif defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::execve (path, (const char **) argv, (char **) envp), int, -1); +#else + ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); +#endif /* ACE_LACKS_EXEC */ +} + +ACE_INLINE int +ACE_OS::execvp (const char *file, + char *const argv[]) +{ + ACE_OS_TRACE ("ACE_OS::execvp"); +#if defined (ACE_LACKS_EXEC) + ACE_UNUSED_ARG (file); + ACE_UNUSED_ARG (argv); + + ACE_NOTSUP_RETURN (-1); +#elif defined(CHORUS) + KnCap cactorcap; + int result = ::afexecvp (file, &cactorcap, 0, argv); + if (result != -1) + ACE_OS::actorcaps_[result] = cactorcap; + return result; +#elif defined (ACE_WIN32) +# if defined (__BORLANDC__) /* VSB */ + return ::execvp (file, argv); +# elif defined (__MINGW32__) + return ::_execvp (file, (char *const *) argv); +# else + return ::_execvp (file, (const char *const *) argv); +# endif /* __BORLANDC__ */ +#elif defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::execvp (file, (const char **) argv), int, -1); +#else + ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); +#endif /* ACE_LACKS_EXEC */ +} + +ACE_INLINE pid_t +ACE_OS::fork (void) +{ + ACE_OS_TRACE ("ACE_OS::fork"); +#if defined (ACE_LACKS_FORK) + ACE_NOTSUP_RETURN (pid_t (-1)); +#else + ACE_OSCALL_RETURN (::fork (), pid_t, -1); +#endif /* ACE_LACKS_FORK */ +} + +#if !defined (ACE_WIN32) +ACE_INLINE int +ACE_OS::fsync (ACE_HANDLE handle) +{ + ACE_OS_TRACE ("ACE_OS::fsync"); +# if defined (ACE_LACKS_FSYNC) + ACE_UNUSED_ARG (handle); + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (::fsync (handle), int, -1); +# endif /* ACE_LACKS_FSYNC */ +} +#endif /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::ftruncate (ACE_HANDLE handle, off_t offset) +{ + ACE_OS_TRACE ("ACE_OS::ftruncate"); +#if defined (ACE_WIN32) + if (::SetFilePointer (handle, offset, 0, FILE_BEGIN) != (unsigned) -1) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1); + else + ACE_FAIL_RETURN (-1); + /* NOTREACHED */ +#elif defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (offset); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (::ftruncate_f (handle, offset), int, -1); +#else + ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE ACE_TCHAR * +ACE_OS::getcwd (ACE_TCHAR *buf, size_t size) +{ + ACE_OS_TRACE ("ACE_OS::getcwd"); +#if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (size); + ACE_NOTSUP_RETURN ( (char*)-1); +#elif defined (ACE_PSOS) + + static char pathbuf [BUFSIZ]; + + // blank the path buffer + ACE_OS::memset (pathbuf, '\0', BUFSIZ); + + // the following was suggested in the documentation for get_fn () + u_long result; + char cur_dir_name [BUFSIZ] = "."; + + u_long cur_dir = 0, prev_dir = 0; + while ((ACE_OS::strlen (pathbuf) < BUFSIZ) && + (ACE_OS::strlen (cur_dir_name) < BUFSIZ - ACE_OS::strlen ("/.."))) + { + // get the current directory handle + result = ::get_fn (cur_dir_name, &cur_dir); + + // check whether we're at the root: this test is + // really lame, but the get_fn documentation says + // *either* condition indicates you're trying to + // move above the root. + if ((result != 0) || ( cur_dir == prev_dir)) + { + break; + } + + // change name to the parent directory + ACE_OS::strcat (cur_dir_name, "/.."); + + // open the parent directory + XDIR xdir; + result = ::open_dir (cur_dir_name, &xdir); + if (result != 0) + { + return 0; + } + + // look for an entry that matches the current directory handle + struct dirent dir_entry; + while (1) + { + // get the next directory entry + result = ::read_dir (&xdir, &dir_entry); + if (result != 0) + { + return 0; + } + + // check for a match + if (dir_entry.d_filno == cur_dir) + { + // prefix the previous path with the entry's name and break + if (ACE_OS::strlen (pathbuf) + ACE_OS::strlen (dir_entry.d_name) < BUFSIZ) + { + ACE_OS::strcpy (pathbuf + ACE_OS::strlen (dir_entry.d_name), pathbuf); + ACE_OS::strcpy (pathbuf, dir_entry.d_name); + break; + } + else + { + // we're out of room in the buffer + return 0; + } + } + } + + // close the parent directory + result = ::close_dir (&xdir); + if (result != 0) + { + return 0; + } + + // save the current directory handle as the previous + prev_dir = cur_dir; + } + + // return the path, if there is one + return (ACE_OS::strlen (pathbuf) > 0) ? pathbuf : (char *) 0; +#elif defined (ACE_HAS_WINCE) + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (size); + ACE_NOTSUP_RETURN (0); +#elif defined (ACE_WIN32) +# if defined (ACE_USES_WCHAR) + return ::_wgetcwd (buf, ACE_static_cast (int, size)); +# else + return ::getcwd (buf, ACE_static_cast (int, size)); +# endif /* ACE_USES_WCHAR */ +#else + ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0); +#endif /* ACE_PSOS_LACKS_PHILE */ +} + +ACE_INLINE gid_t +ACE_OS::getgid (void) +{ + ACE_OS_TRACE ("ACE_OS::getgid"); +#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + // getgid() is not supported: just one user anyways + return 0; +# elif defined (ACE_WIN32) || defined (CHORUS) + ACE_NOTSUP_RETURN (ACE_static_cast (gid_t, -1)); +# else + ACE_OSCALL_RETURN (::getgid (), gid_t, (gid_t) -1); +# endif /* VXWORKS || ACE_PSOS */ +} + +#if !defined (ACE_WIN32) + +ACE_INLINE int +ACE_OS::getopt (int argc, char *const *argv, const char *optstring) +{ + ACE_OS_TRACE ("ACE_OS::getopt"); +#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_UNUSED_ARG (argc); + ACE_UNUSED_ARG (argv); + ACE_UNUSED_ARG (optstring); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_LACKS_GETOPT_PROTO) + ACE_OSCALL_RETURN (::getopt (argc, (char**) argv, optstring), int, -1); +# elif defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::getopt (argc, (const char* const *) argv, optstring), int, -1); +# else + ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1); +# endif /* VXWORKS */ +} + +#else /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::getopt (int argc, char *const *argv, const char *optstring) +{ + ACE_UNUSED_ARG (argc); + ACE_UNUSED_ARG (argv); + ACE_UNUSED_ARG (optstring); + + ACE_OS_TRACE ("ACE_OS::getopt"); + ACE_NOTSUP_RETURN (-1); +} + +#endif /* !ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::getpagesize (void) +{ + ACE_OS_TRACE ("ACE_OS::getpagesize"); +#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) + SYSTEM_INFO sys_info; + ::GetSystemInfo (&sys_info); + return (int) sys_info.dwPageSize; +#elif defined (_SC_PAGESIZE) + return (int) ::sysconf (_SC_PAGESIZE); +#elif defined (ACE_HAS_GETPAGESIZE) + return ::getpagesize (); +#else + // Use the default set in config.h + return ACE_PAGE_SIZE; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE pid_t +ACE_OS::getpgid (pid_t pid) +{ + ACE_OS_TRACE ("ACE_OS::getpgid"); +#if defined (ACE_LACKS_GETPGID) + ACE_UNUSED_ARG (pid); + ACE_NOTSUP_RETURN (-1); +#elif defined (VXWORKS) || defined (ACE_PSOS) + // getpgid() is not supported, only one process anyway. + ACE_UNUSED_ARG (pid); + return 0; +#elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0 + // getpgid() is from SVR4, which appears to be the reason why GLIBC + // doesn't enable its prototype by default. + // Rather than create our own extern prototype, just use the one + // that is visible (ugh). + ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1); +#else + ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE pid_t +ACE_OS::getpid (void) +{ + // ACE_OS_TRACE ("ACE_OS::getpid"); +#if defined (ACE_WIN32) + return ::GetCurrentProcessId (); +#elif defined (VXWORKS) || defined (ACE_PSOS) + // getpid() is not supported: just one process anyways + return 0; +#elif defined (CHORUS) + return (pid_t) (::agetId ()); +#else + ACE_OSCALL_RETURN (::getpid (), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE pid_t +ACE_OS::getppid (void) +{ + ACE_OS_TRACE ("ACE_OS::getppid"); +#if defined (ACE_LACKS_GETPPID) + ACE_NOTSUP_RETURN (-1); +#elif defined (VXWORKS) || defined (ACE_PSOS) + // getppid() is not supported, only one process anyway. + return 0; +#else + ACE_OSCALL_RETURN (::getppid (), pid_t, -1); +#endif /* ACE_LACKS_GETPPID */ +} + +ACE_INLINE uid_t +ACE_OS::getuid (void) +{ + ACE_OS_TRACE ("ACE_OS::getuid"); +#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + // getuid() is not supported: just one user anyways + return 0; +# elif defined (ACE_WIN32) || defined (CHORUS) + ACE_NOTSUP_RETURN (ACE_static_cast (uid_t, -1)); +# else + ACE_OSCALL_RETURN (::getuid (), uid_t, (uid_t) -1); +# endif /* VXWORKS || ACE_PSOS */ +} + +ACE_INLINE int +ACE_OS::hostname (char name[], size_t maxnamelen) +{ + ACE_OS_TRACE ("ACE_OS::hostname"); +#if defined (ACE_HAS_PHARLAP) + // PharLap only can do net stuff with the RT version. +# if defined (ACE_HAS_PHARLAP_RT) + // @@This is not at all reliable... requires ethernet and BOOTP to be used. + // A more reliable way is to go thru the devices w/ EtsTCPGetDeviceCfg until + // a legit IP address is found, then get its name w/ gethostbyaddr. + ACE_SOCKCALL_RETURN (gethostname (name, maxnamelen), int, SOCKET_ERROR); +# else + ACE_UNUSED_ARG (name); + ACE_UNUSED_ARG (maxnamelen); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PHARLAP_RT */ +#elif defined (VXWORKS) || defined (ACE_HAS_WINCE) + ACE_OSCALL_RETURN (::gethostname (name, maxnamelen), int, -1); +#elif defined (ACE_WIN32) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name, + LPDWORD (&maxnamelen)), + ace_result_), int, -1); +#elif defined (CHORUS) + if (::gethostname (name, maxnamelen) == -1) + return -1; + else + { + if (ACE_OS::strlen (name) == 0) + { + // Try the HOST environment variable. + ACE_TCHAR *const hostenv = ::getenv (ACE_LIB_TEXT ("HOST")); + if (hostenv) + ACE_OS::strsncpy (name, hostenv, maxnamelen); + } + return 0; + } +#else /* ACE_HAS_PHARLAP */ + ACE_utsname host_info; + + if (ACE_OS::uname (&host_info) == -1) + return -1; + else + { + ACE_OS::strsncpy (name, host_info.nodename, maxnamelen); + return 0; + } +#endif /* ACE_HAS_PHARLAP */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::hostname (wchar_t name[], size_t maxnamelen) +{ +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (GetComputerNameW (name, + LPDWORD (&maxnamelen)), + ace_result_), int, -1); +#else /* ACE_WIN32 && !ACE_HAS_WINCE */ + // Emulate using the char version + char *char_name = 0; + int result = 0; + + ACE_NEW_RETURN (char_name, char[maxnamelen], -1); + + result = ACE_OS::hostname(char_name, maxnamelen); + ACE_OS::strcpy (name, ACE_Ascii_To_Wide (char_name).wchar_rep ()); + + delete [] char_name; + return result; +#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE int +ACE_OS::isatty (int handle) +{ +#if defined (ACE_LACKS_ISATTY) + ACE_UNUSED_ARG (handle); + return 0; +# elif defined (ACE_WIN32) + ACE_OS_TRACE ("ACE_OS::isatty"); + return ::_isatty (handle); +# else + ACE_OS_TRACE ("ACE_OS::isatty"); + ACE_OSCALL_RETURN (::isatty (handle), int, -1); +# endif /* defined (ACE_LACKS_ISATTY) */ +} + +#if defined (ACE_WIN32) +ACE_INLINE int +ACE_OS::isatty (ACE_HANDLE handle) +{ +#if defined (ACE_LACKS_ISATTY) + ACE_UNUSED_ARG (handle); + return 0; +#else +# if defined (ACE_WIN64) + int fd = ::_open_osfhandle (intptr_t (handle), 0); +# else + int fd = ::_open_osfhandle (long (handle), 0); +# endif /* ACE_WIN64 */ + + int status = ::_isatty (fd); + ::_close (fd); + return status; +#endif /* ACE_LACKS_ISATTY */ +} + +#endif /* ACE_WIN32 */ + +ACE_INLINE off_t +ACE_OS::lseek (ACE_HANDLE handle, off_t offset, int whence) +{ + ACE_OS_TRACE ("ACE_OS::lseek"); +#if defined (ACE_WIN32) +# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END + //#error Windows NT is evil AND rude! + switch (whence) + { + case SEEK_SET: + whence = FILE_BEGIN; + break; + case SEEK_CUR: + whence = FILE_CURRENT; + break; + case SEEK_END: + whence = FILE_END; + break; + default: + errno = EINVAL; + return ACE_static_cast (off_t, -1); // rather safe than sorry + } +# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ + DWORD result = ::SetFilePointer (handle, offset, 0, whence); + if (result == ACE_SYSCALL_FAILED) + ACE_FAIL_RETURN (ACE_static_cast (off_t, -1)); + else + return result; +#elif defined (ACE_PSOS) +# if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (offset); + ACE_UNUSED_ARG (whence); + ACE_NOTSUP_RETURN (ACE_static_cast (off_t, -1)); +# else + unsigned long oldptr, newptr, result; + // seek to the requested position + result = ::lseek_f (handle, whence, offset, &oldptr); + if (result != 0) + { + errno = result; + return ACE_static_cast (off_t, -1); + } + // now do a dummy seek to the current position to obtain the position + result = ::lseek_f (handle, SEEK_CUR, 0, &newptr); + if (result != 0) + { + errno = result; + return ACE_static_cast (off_t, -1); + } + return ACE_static_cast (off_t, newptr); +# endif /* defined (ACE_PSOS_LACKS_PHILE */ +#else + ACE_OSCALL_RETURN (::lseek (handle, offset, whence), off_t, -1); +#endif /* ACE_WIN32 */ +} + +#if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64) +ACE_INLINE ACE_LOFF_T +ACE_OS::llseek (ACE_HANDLE handle, ACE_LOFF_T offset, int whence) +{ + ACE_OS_TRACE ("ACE_OS::llseek"); + +#if ACE_SIZEOF_LONG == 8 + /* The native lseek is 64 bit. Use it. */ + return ACE_OS::lseek (handle, offset, whence); +#elif defined (ACE_HAS_LLSEEK) && defined (ACE_HAS_LSEEK64) +# error Either ACE_HAS_LSEEK64 and ACE_HAS_LLSEEK should be defined, not both! +#elif defined (ACE_HAS_LSEEK64) + ACE_OSCALL_RETURN (::lseek64 (handle, offset, whence), ACE_LOFF_T, -1); +#elif defined (ACE_HAS_LLSEEK) + # if defined (ACE_WIN32) + LARGE_INTEGER li; + li.QuadPart = offset; + li.LowPart = ::SetFilePointer (handle, li.LowPart, &li.HighPart, whence); + if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) + li.QuadPart = -1; + return li.QuadPart; + # else + ACE_OSCALL_RETURN (::llseek (handle, offset, whence), ACE_LOFF_T, -1); + # endif /* WIN32 */ +#endif +} +#endif /* ACE_HAS_LLSEEK || ACE_HAS_LSEEK64 */ + +ACE_INLINE ssize_t +ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len) +{ + ACE_OS_TRACE ("ACE_OS::read"); +#if defined (ACE_WIN32) + DWORD ok_len; + if (::ReadFile (handle, buf, ACE_static_cast (DWORD, len), &ok_len, 0)) + return (ssize_t) ok_len; + else + ACE_FAIL_RETURN (-1); +#elif defined (ACE_PSOS) +# if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (len); + ACE_NOTSUP_RETURN (-1); +# else + u_long count; + u_long result = ::read_f (handle, buf, len, &count); + if (result != 0) + return ACE_static_cast (ssize_t, -1); + else + return ACE_static_cast (ssize_t, count == len ? count : 0); +# endif /* defined (ACE_PSOS_LACKS_PHILE */ +#else + + int result; + +# if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_HAS_CHARPTR_SOCKOPT) + ACE_OSCALL (::read (handle, (char *) buf, len), ssize_t, -1, result); +# else + ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ + if (result == -1 && errno == EAGAIN) + errno = EWOULDBLOCK; + return result; +#endif /* ACE_WIN32 */ +} + +ACE_INLINE ssize_t +ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len, + ACE_OVERLAPPED *overlapped) +{ + ACE_OS_TRACE ("ACE_OS::read"); + overlapped = overlapped; +#if defined (ACE_WIN32) + DWORD ok_len; + DWORD short_len = ACE_static_cast (DWORD, len); + if (::ReadFile (handle, buf, short_len, &ok_len, overlapped)) + return (ssize_t) ok_len; + else + ACE_FAIL_RETURN (-1); +#else + return ACE_OS::read (handle, buf, len); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::readlink (const char *path, char *buf, size_t bufsiz) +{ + ACE_OS_TRACE ("ACE_OS::readlink"); +# if defined (ACE_LACKS_READLINK) || \ + defined (ACE_HAS_WINCE) || defined (ACE_WIN32) + ACE_UNUSED_ARG (path); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (bufsiz); + ACE_NOTSUP_RETURN (-1); +# else +# if !defined(ACE_HAS_NONCONST_READLINK) + ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), int, -1); +# else + ACE_OSCALL_RETURN (::readlink ((char *)path, buf, bufsiz), int, -1); +# endif +# endif /* ACE_LACKS_READLINK */ +} + +#if !defined (ACE_WIN32) + +ACE_INLINE int +ACE_OS::pipe (ACE_HANDLE fds[]) +{ + ACE_OS_TRACE ("ACE_OS::pipe"); +# if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_UNUSED_ARG (fds); + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (::pipe (fds), int, -1); +# endif /* VXWORKS || ACE_PSOS */ +} + +#else /* ACE_WIN32 */ + +ACE_INLINE int +ACE_OS::pipe (ACE_HANDLE fds[]) +{ +# if !defined (ACE_HAS_WINCE) && !defined (__IBMCPP__) + ACE_OS_TRACE ("ACE_OS::pipe"); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL + (::CreatePipe (&fds[0], &fds[1], 0, 0), + ace_result_), int, -1); +# else + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_WINCE && !__IBMCPP__ */ +} + +#endif /* !ACE_WIN32 */ + +ACE_INLINE void * +ACE_OS::sbrk (int brk) +{ +#if defined (ACE_LACKS_SBRK) + ACE_UNUSED_ARG (brk); + ACE_NOTSUP_RETURN (0); +#else + ACE_OSCALL_RETURN (::sbrk (brk), void *, 0); +#endif /* VXWORKS */ +} + +ACE_INLINE int +ACE_OS::setgid (gid_t gid) +{ + ACE_OS_TRACE ("ACE_OS::setgid"); +#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + // setgid() is not supported: just one user anyways + ACE_UNUSED_ARG (gid); + return 0; +# elif defined (ACE_WIN32) || defined (CHORUS) + ACE_UNUSED_ARG (gid); + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (::setgid (gid), int, -1); +# endif /* VXWORKS || ACE_PSOS */ +} + +ACE_INLINE int +ACE_OS::setpgid (pid_t pid, pid_t pgid) +{ + ACE_OS_TRACE ("ACE_OS::setpgid"); +#if defined (ACE_LACKS_SETPGID) + ACE_UNUSED_ARG (pid); + ACE_UNUSED_ARG (pgid); + ACE_NOTSUP_RETURN (-1); +#elif defined (VXWORKS) || defined (ACE_PSOS) + // <setpgid> is not supported, only one process anyway. + ACE_UNUSED_ARG (pid); + ACE_UNUSED_ARG (pgid); + return 0; +#else + ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1); +#endif /* ACE_LACKS_SETPGID */ +} + +ACE_INLINE int +ACE_OS::setregid (gid_t rgid, gid_t egid) +{ + ACE_OS_TRACE ("ACE_OS::setregid"); +#if defined (ACE_LACKS_SETREGID) + ACE_UNUSED_ARG (rgid); + ACE_UNUSED_ARG (egid); + ACE_NOTSUP_RETURN (-1); +#elif defined (VXWORKS) || defined (ACE_PSOS) + // <setregid> is not supported, only one process anyway. + ACE_UNUSED_ARG (rgid); + ACE_UNUSED_ARG (egid); + return 0; +#else + ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::setreuid (uid_t ruid, uid_t euid) +{ + ACE_OS_TRACE ("ACE_OS::setreuid"); +#if defined (ACE_LACKS_SETREUID) + ACE_UNUSED_ARG (ruid); + ACE_UNUSED_ARG (euid); + ACE_NOTSUP_RETURN (-1); +#elif defined (VXWORKS) || defined (ACE_PSOS) + // <setpgid> is not supported, only one process anyway. + ACE_UNUSED_ARG (ruid); + ACE_UNUSED_ARG (euid); + return 0; +#else + ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1); +#endif /* ACE_WIN32 */ +} + +#if !defined (ACE_WIN32) + +ACE_INLINE pid_t +ACE_OS::setsid (void) +{ + ACE_OS_TRACE ("ACE_OS::setsid"); +# if defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (::setsid (), int, -1); +# endif /* VXWORKS || CHORUS || ACE_PSOS */ +} + +#else /* ACE_WIN32 */ + +ACE_INLINE pid_t +ACE_OS::setsid (void) +{ + ACE_OS_TRACE ("ACE_OS::setsid"); + ACE_NOTSUP_RETURN (-1); +} + +#endif /* WIN32 */ + +ACE_INLINE int +ACE_OS::setuid (uid_t uid) +{ + ACE_OS_TRACE ("ACE_OS::setuid"); +#if defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + // setuid() is not supported: just one user anyways + ACE_UNUSED_ARG (uid); + return 0; +# elif defined (ACE_WIN32) || defined(CHORUS) + ACE_UNUSED_ARG (uid); + ACE_NOTSUP_RETURN (-1); +# else + ACE_OSCALL_RETURN (::setuid (uid), int, -1); +# endif /* VXWORKS || ACE_PSOS */ +} + +ACE_INLINE int +ACE_OS::sleep (u_int seconds) +{ + ACE_OS_TRACE ("ACE_OS::sleep"); +#if defined (ACE_WIN32) + ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS); + return 0; +#if 0 +#elif defined (HPUX_10) && defined (ACE_HAS_PTHREADS_DRAFT4) + // On HP-UX 10, _CMA_NOWRAPPERS_ disables the mapping from sleep to cma_sleep + // which makes sleep() put the whole process to sleep, and keeps it from + // noticing pending cancels. So, in this case, use pthread_delay_np + struct timespec rqtp; + rqtp.tv_sec = seconds; + rqtp.tv_nsec = 0L; + return pthread_delay_np (&rqtp); +#endif /* 0 */ +#elif defined (ACE_HAS_CLOCK_GETTIME) + struct timespec rqtp; + // Initializer doesn't work with Green Hills 1.8.7 + rqtp.tv_sec = seconds; + rqtp.tv_nsec = 0L; + ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1); +#elif defined (ACE_PSOS) + timeval wait; + wait.tv_sec = seconds; + wait.tv_usec = 0; + ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &wait), int, -1); +#else + ACE_OSCALL_RETURN (::sleep (seconds), int, -1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE_OS::sleep (const ACE_Time_Value &tv) +{ + ACE_OS_TRACE ("ACE_OS::sleep"); +#if defined (ACE_WIN32) + ::Sleep (tv.msec ()); + return 0; +#else +# if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) + // Copy the timeval, because this platform doesn't declare the timeval + // as a pointer to const. + timeval tv_copy = tv; + ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1); +# else /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */ + const timeval *tvp = tv; + ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1); +# endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ +#endif /* ACE_WIN32 */ +} + +ACE_INLINE long +ACE_OS::sysconf (int name) +{ + ACE_OS_TRACE ("ACE_OS::sysconf"); +#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS) || defined (INTEGRITY) + ACE_UNUSED_ARG (name); + ACE_NOTSUP_RETURN (-1); +#else + ACE_OSCALL_RETURN (::sysconf (name), long, -1); +#endif /* ACE_WIN32 || VXWORKS || ACE_PSOS */ +} + +ACE_INLINE long +ACE_OS::sysinfo (int cmd, char *buf, long count) +{ + ACE_OS_TRACE ("ACE_OS::sysinfo"); +#if defined (ACE_HAS_SYSINFO) + ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1); +#else + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (count); + + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_SYSINFO */ +} + +ACE_INLINE int +ACE_OS::truncate (const ACE_TCHAR *filename, + off_t offset) +{ + ACE_OS_TRACE ("ACE_OS::truncate"); +#if defined (ACE_WIN32) + ACE_HANDLE handle = ACE_OS::open (filename, + O_WRONLY, + ACE_DEFAULT_FILE_PERMS); + if (handle == ACE_INVALID_HANDLE) + ACE_FAIL_RETURN (-1); + else if (::SetFilePointer (handle, + offset, + 0, + FILE_BEGIN) != (unsigned) -1) + { + BOOL result = ::SetEndOfFile (handle); + ::CloseHandle (handle); + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1); + } + else + { + ::CloseHandle (handle); + ACE_FAIL_RETURN (-1); + } + /* NOTREACHED */ +#elif !defined (ACE_LACKS_TRUNCATE) + ACE_OSCALL_RETURN (::truncate (filename, offset), int, -1); +#else + ACE_UNUSED_ARG (filename); + ACE_UNUSED_ARG (offset); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE u_int +ACE_OS::ualarm (u_int usecs, u_int interval) +{ + ACE_OS_TRACE ("ACE_OS::ualarm"); + +#if defined (ACE_HAS_UALARM) + return ::ualarm (usecs, interval); +#elif !defined (ACE_LACKS_UNIX_SIGNALS) + ACE_UNUSED_ARG (interval); + return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS); +#else + ACE_UNUSED_ARG (usecs); + ACE_UNUSED_ARG (interval); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_UALARM */ +} + +ACE_INLINE u_int +ACE_OS::ualarm (const ACE_Time_Value &tv, + const ACE_Time_Value &tv_interval) +{ + ACE_OS_TRACE ("ACE_OS::ualarm"); + +#if defined (ACE_HAS_UALARM) + u_int usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec (); + u_int interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec (); + return ::ualarm (usecs, interval); +#elif !defined (ACE_LACKS_UNIX_SIGNALS) + ACE_UNUSED_ARG (tv_interval); + return ::alarm (tv.sec ()); +#else + ACE_UNUSED_ARG (tv_interval); + ACE_UNUSED_ARG (tv); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_UALARM */ +} + +ACE_INLINE int +ACE_OS::unlink (const ACE_TCHAR *path) +{ + ACE_OS_TRACE ("ACE_OS::unlink"); +# if defined (VXWORKS) + ACE_OSCALL_RETURN (::unlink (ACE_const_cast (char *, path)), int, -1); +# elif defined (ACE_PSOS) && ! defined (ACE_PSOS_LACKS_PHILE) + ACE_OSCALL_RETURN (::remove_f ((char *) path), int , -1); +# elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_C_LIBRARY) + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::remove ((char *) path), + ace_result_), + int, -1); +# elif defined (ACE_HAS_WINCE) + // @@ The problem is, DeleteFile is not actually equals to unlink. ;( + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (path), ace_result_), + int, -1); +# elif defined (ACE_LACKS_UNLINK) + ACE_UNUSED_ARG (path); + ACE_NOTSUP_RETURN (-1); +# elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::_wunlink (path), int, -1); +# else + ACE_OSCALL_RETURN (::unlink (path), int, -1); +# endif /* VXWORKS */ +} + +ACE_INLINE ssize_t +ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte) +{ + ACE_OS_TRACE ("ACE_OS::write"); +#if defined (ACE_WIN32) + DWORD bytes_written; // This is set to 0 byte WriteFile. + + // Strictly correctly, we should loop writing all the data if more + // than a DWORD length can hold. + DWORD short_nbyte = ACE_static_cast (DWORD, nbyte); + if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0)) + return (ssize_t) bytes_written; + else + ACE_FAIL_RETURN (-1); +#elif defined (ACE_PSOS) +# if defined (ACE_PSOS_LACKS_PHILE) + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (buf); + ACE_UNUSED_ARG (nbyte); + ACE_NOTSUP_RETURN (-1); +# else + if(::write_f (handle, (void *) buf, nbyte) == 0) + return (ssize_t) nbyte; + else + return -1; +# endif /* defined (ACE_PSOS_LACKS_PHILE) */ +#else +# if defined (ACE_LACKS_POSIX_PROTOTYPES) + ACE_OSCALL_RETURN (::write (handle, (const char *) buf, nbyte), ssize_t, -1); +# elif defined (ACE_PSOS) + ACE_OSCALL_RETURN (::write_f(handle, (void *) buf, nbyte), ssize_t, -1); +# elif defined (ACE_HAS_CHARPTR_SOCKOPT) + ACE_OSCALL_RETURN (::write (handle, (char *) buf, nbyte), ssize_t, -1); +# else + ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1); +# endif /* ACE_LACKS_POSIX_PROTOTYPES */ +#endif /* ACE_WIN32 */ +} + +ACE_INLINE ssize_t +ACE_OS::write (ACE_HANDLE handle, + const void *buf, + size_t nbyte, + ACE_OVERLAPPED *overlapped) +{ + ACE_OS_TRACE ("ACE_OS::write"); + overlapped = overlapped; +#if defined (ACE_WIN32) + DWORD bytes_written; // This is set to 0 byte WriteFile. + + DWORD short_nbyte = ACE_static_cast (DWORD, nbyte); + if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped)) + return (ssize_t) bytes_written; + else + return -1; +#else + return ACE_OS::write (handle, buf, nbyte); +#endif /* ACE_WIN32 */ +} + diff --git a/ace/OS_NS_wchar.cpp b/ace/OS_NS_wchar.cpp index fc532b41367..e934c9378ca 100644 --- a/ace/OS_NS_wchar.cpp +++ b/ace/OS_NS_wchar.cpp @@ -1,4 +1,370 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/OS_NS_wchar.h" + +ACE_RCSID(ace, OS_NS_wchar, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/OS_NS_wchar.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +// The following wcs*_emulation methods were created based on BSD code: +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * James W. Williams of NASA Goddard Space Flight Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT) +wchar_t * +ACE_OS::wcscat_emulation (wchar_t *destination, + const wchar_t *source) +{ + wchar_t *save = destination; + + for (; *destination; ++destination); + while ((*destination++ = *source++)); + return save; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR) +wchar_t * +ACE_OS::wcschr_emulation (const wchar_t *string, wint_t c) +{ + for (;*string ; ++string) + if (*string == ACE_static_cast (wchar_t, c)) + return ACE_const_cast (wchar_t *, string); + + return 0; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) +int +ACE_OS::wcscmp_emulation (const ACE_WCHAR_T *string1, + const ACE_WCHAR_T *string2) +{ + while (*string1 == *string2++) + if (*string1++ == 0) + return (0); + return (*string1 - *--string2); +} +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY) +wchar_t * +ACE_OS::wcscpy_emulation (wchar_t *destination, + const wchar_t *source) +{ + wchar_t *save = destination; + + for (; (*destination = *source); ++source, ++destination); + return save; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCSPN) +size_t +ACE_OS::wcscspn_emulation (const wchar_t *s, const wchar_t *reject) +{ + const wchar_t *scan; + const wchar_t *rej_scan; + int count = 0; + + for (scan = s; *scan; scan++) + { + + for (rej_scan = reject; *rej_scan; rej_scan++) + if (*scan == *rej_scan) + return count; + + count++; + } + + return count; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCSPN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP) +int +ACE_OS::wcsicmp_emulation (const wchar_t *s, const wchar_t *t) +{ + const wchar_t *scan1 = s; + const wchar_t *scan2 = t; + + while (*scan1 != 0 + && ACE_OS::to_lower (*scan1) + == ACE_OS::to_lower (*scan2)) + { + ++scan1; + ++scan2; + } + + // The following case analysis is necessary so that characters which + // look negative collate low against normal characters but high + // against the end-of-string NUL. + + if (*scan1 == '\0' && *scan2 == '\0') + return 0; + else if (*scan1 == '\0') + return -1; + else if (*scan2 == '\0') + return 1; + else + return ACE_OS::to_lower (*scan1) - ACE_OS::to_lower (*scan2); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) +size_t +ACE_OS::wcslen_emulation (const ACE_WCHAR_T *string) +{ + const ACE_WCHAR_T *s; + + for (s = string; *s; ++s) + continue; + + return s - string; +} +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) +ACE_WCHAR_T * +ACE_OS::wcsncat_emulation (ACE_WCHAR_T *destination, + const ACE_WCHAR_T *source, + size_t count) +{ + if (count != 0) + { + ACE_WCHAR_T *d = destination; + const ACE_WCHAR_T *s = source; + + while (*d != 0) + d++; + + do + { + if ((*d = *s++) == 0) + break; + + d++; + } while (--count != 0); + + *d = 0; + } + + return destination; +} +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCAT */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) +int +ACE_OS::wcsncmp_emulation (const ACE_WCHAR_T *s1, + const ACE_WCHAR_T *s2, + size_t len) +{ + if (len == 0) + return 0; + + do + { + if (*s1 != *s2++) + return (*s1 - *--s2); + if (*s1++ == 0) + break; + } while (--len != 0); + + return 0; +} +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) +ACE_WCHAR_T * +ACE_OS::wcsncpy_emulation (ACE_WCHAR_T *destination, + const ACE_WCHAR_T *source, + size_t len) +{ + if (len != 0) + { + ACE_WCHAR_T *d = destination; + const ACE_WCHAR_T *s = source; + + do + { + if ((*d++ = *s++) == 0) + { + // NUL pad the remaining n-1 bytes + while (--len != 0) + *d++ = 0; + break; + } + } while (--len != 0); + } + + return destination; +} +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP) +int +ACE_OS::wcsnicmp_emulation (const wchar_t *s, + const wchar_t *t, + size_t len) +{ + const wchar_t *scan1 = s; + const wchar_t *scan2 = t; + size_t count = 0; + + while (count++ < len + && *scan1 != 0 + && ACE_OS::to_lower (*scan1) + == ACE_OS::to_lower (*scan2)) + { + ++scan1; + ++scan2; + } + + if (count > len) + return 0; + + // The following case analysis is necessary so that characters which + // look negative collate low against normal characters but high + // against the end-of-string NUL. + + if (*scan1 == '\0' && *scan2 == '\0') + return 0; + else if (*scan1 == '\0') + return -1; + else if (*scan2 == '\0') + return 1; + else + return ACE_OS::to_lower (*scan1) - ACE_OS::to_lower (*scan2); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK) +wchar_t * +ACE_OS::wcspbrk_emulation (const wchar_t *string, + const wchar_t *charset) +{ + const wchar_t *scanp; + int c, sc; + + while ((c = *string++) != 0) + { + for (scanp = charset; (sc = *scanp++) != 0;) + if (sc == c) + return ACE_const_cast (wchar_t *, string - 1); + } + + return 0; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR) +const wchar_t * +ACE_OS::wcsrchr_emulation (const wchar_t *s, wint_t c) +{ + const wchar_t *p = s + ACE_OS::strlen (s); + + while (*p != ACE_static_cast (wchar_t, c)) + if (p == s) + return 0; + else + p--; + + return p; +} + +wchar_t * +ACE_OS::wcsrchr_emulation (wchar_t *s, wint_t c) +{ + wchar_t *p = s + ACE_OS::strlen (s); + + while (*p != ACE_static_cast(wchar_t, c)) + if (p == s) + return 0; + else + p--; + + return p; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN) +size_t +ACE_OS::wcsspn_emulation (const wchar_t *string, + const wchar_t *charset) +{ + const wchar_t *p = string; + const wchar_t *spanp; + wchar_t c, sc; + + // Skip any characters in charset, excluding the terminating \0. +cont: + c = *p++; + for (spanp = charset; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - string); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR) +wchar_t * +ACE_OS::wcsstr_emulation (const wchar_t *string, + const wchar_t *charset) +{ + wchar_t c, sc; + size_t len; + + if ((c = *charset++) != 0) + { + len = strlen(charset); + do + { + do + { + if ((sc = *string++) == 0) + return 0; + } while (sc != c); + } while (strncmp(string, charset, len) != 0); + string--; + } + + return ACE_const_cast (wchar_t *, string); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */ + diff --git a/ace/OS_NS_wchar.h b/ace/OS_NS_wchar.h index fc532b41367..9d113747232 100644 --- a/ace/OS_NS_wchar.h +++ b/ace/OS_NS_wchar.h @@ -1,4 +1,162 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_wchar.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_NS_WCHAR_H +# define ACE_OS_NS_WCHAR_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/os_wchar.h" +#include "ace/Basic_Types.h" + +namespace ACE_OS { + +//#if defined (ACE_HAS_WCHAR) + typedef ACE_WCHAR_T WChar; + + wint_t fgetwc (FILE* fp); + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT) + /// Emulated wcscat - Appends a string. + wchar_t *wcscat_emulation (wchar_t *destination, + const wchar_t *source); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR) + /// Emulated wcschr - Finds a character in a string. + wchar_t *wcschr_emulation (const wchar_t *string, wint_t c); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) + /// Emulated wcscmp - Compares strings. + int wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2); +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY) + /// Emulated wcscpy - Copies a string. + wchar_t *wcscpy_emulation (wchar_t *destination, + const wchar_t *source); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCSPN) + /// Emulated wcscspn. + size_t wcscspn_emulation (const wchar_t *string, + const wchar_t *reject); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCSPN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP) + /// Emulated wcsicmp - Performs a case insensitive comparison of strings. + int wcsicmp_emulation (const wchar_t *string1, + const wchar_t *string2); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) + /// Emulated wcslen - Returns the length of a string. + size_t wcslen_emulation (const ACE_WCHAR_T *string); +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) + /// Emulated wcscat - Appends a string. + ACE_WCHAR_T *wcsncat_emulation (ACE_WCHAR_T *destination, + const ACE_WCHAR_T *source, + size_t count); +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCAT */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) + /// Emulated wcsncmp - Compares two arrays. + int wcsncmp_emulation (const ACE_WCHAR_T *string1, + const ACE_WCHAR_T *string2, + size_t len); +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ + +#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) + /// Emulated wcsncpy - Copies an array. + ACE_WCHAR_T *wcsncpy_emulation (ACE_WCHAR_T *destination, + const ACE_WCHAR_T *source, + size_t len); +#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP) + /// Emulated wcsnicmp - Performs a case insensitive comparison of two + /// arrays + int wcsnicmp_emulation (const wchar_t *string1, + const wchar_t *string2, + size_t len); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK) + /// Emulated wcspbrk - Searches for characters in a string. + wchar_t *wcspbrk_emulation (const wchar_t *string, + const wchar_t *charset); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR) + /// Emulated wcsrchr (wchar_t version) - Finds the last occurance of a + /// character in a string. + wchar_t *wcsrchr_emulation (wchar_t *string, wint_t c); + + /// Emulated wcsrchr (const wchar_t version) - Finds the last occurance of a + /// character in a string. + const wchar_t *wcsrchr_emulation (const wchar_t *string, wint_t c); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN) + /// Emulated wcsspn. + size_t wcsspn_emulation (const wchar_t *string, + const wchar_t *charset); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR) + /// Emulated wcsstr - Performs a case insensitive comparison of two strings. + wchar_t *wcsstr_emulation (const wchar_t *string, + const wchar_t *charset); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */ + + // these are named wrong. should be wcslen, etc... dhinton + u_int wslen (const WChar *); + + WChar *wscpy (WChar *, + const WChar *); + + int wscmp (const WChar *, + const WChar *); + + int wsncmp (const WChar *, + const WChar *, + size_t len); + + wint_t ungetwc (wint_t c, FILE* fp); + +} /* namespace ACE_OS */ + +//#endif /* ACE_HAS_WCHAR */ + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/OS_NS_wchar.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_OS_NS_STDIO_H */ diff --git a/ace/OS_NS_wchar.inl b/ace/OS_NS_wchar.inl index fc532b41367..26caa1a43d0 100644 --- a/ace/OS_NS_wchar.inl +++ b/ace/OS_NS_wchar.inl @@ -1,4 +1,83 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wint_t +ACE_OS::fgetwc (FILE* fp) +{ +#if defined (ACE_LACKS_FGETWC) + ACE_UNUSED_ARG (fp); + ACE_NOTSUP_RETURN (0); +#else + ACE_OSCALL_RETURN (::fgetwc (fp), wint_t, WEOF); +#endif /* ACE_LACKS_FGETWC */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE u_int +ACE_OS::wslen (const WChar *s) +{ + u_int len = 0; + + while (*s++ != 0) + len++; + + return len; +} + +ACE_INLINE ACE_OS::WChar * +ACE_OS::wscpy (WChar *dest, const WChar *src) +{ + WChar *original_dest = dest; + + while ((*dest++ = *src++) != 0) + continue; + + return original_dest; +} + +ACE_INLINE int +ACE_OS::wscmp (const WChar *s, const WChar *t) +{ + const WChar *scan1 = s; + const WChar *scan2 = t; + + while (*scan1 != 0 && *scan1 == *scan2) + { + ++scan1; + ++scan2; + } + + return *scan1 - *scan2; +} + +ACE_INLINE int +ACE_OS::wsncmp (const WChar *s, const WChar *t, size_t len) +{ + const WChar *scan1 = s; + const WChar *scan2 = t; + + while (len != 0 && *scan1 != 0 && *scan1 == *scan2) + { + ++scan1; + ++scan2; + --len; + } + + return len == 0 ? 0 : *scan1 - *scan2; +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wint_t +ACE_OS::ungetwc (wint_t c, FILE* fp) +{ +#if defined (ACE_LACKS_FGETWC) + ACE_UNUSED_ARG (c); + ACE_UNUSED_ARG (fp); + ACE_NOTSUP_RETURN (0); +#else + ACE_OSCALL_RETURN (::ungetwc (c, fp), wint_t, WEOF); +#endif /* ACE_LACKS_FGETWC */ +} +#endif /* ACE_HAS_WCHAR */ + diff --git a/ace/OS_QoS.cpp b/ace/OS_QoS.cpp index b1985171661..8240231b9c5 100644 --- a/ace/OS_QoS.cpp +++ b/ace/OS_QoS.cpp @@ -11,15 +11,16 @@ //============================================================================= #include "ace/OS_QoS.h" +#include "ace/OS_NS_errno.h" -ACE_Flow_Spec::ACE_Flow_Spec (u_long token_rate, - u_long token_bucket_size, - u_long peak_bandwidth, - u_long latency, - u_long delay_variation, +ACE_Flow_Spec::ACE_Flow_Spec (unsigned long token_rate, + unsigned long token_bucket_size, + unsigned long peak_bandwidth, + unsigned long latency, + unsigned long delay_variation, ACE_SERVICE_TYPE service_type, - u_long max_sdu_size, - u_long minimum_policed_size, + unsigned long max_sdu_size, + unsigned long minimum_policed_size, int ttl, int priority) { @@ -86,7 +87,7 @@ ACE_Flow_Spec::ACE_Flow_Spec (void) #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ } -u_long +unsigned long ACE_Flow_Spec::token_rate (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) @@ -97,7 +98,7 @@ ACE_Flow_Spec::token_rate (void) const } void -ACE_Flow_Spec::token_rate (u_long tr) +ACE_Flow_Spec::token_rate (unsigned long tr) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) this->TokenRate = tr; @@ -106,7 +107,7 @@ ACE_Flow_Spec::token_rate (u_long tr) #endif /* ACE_HAS_WINSOCK2 */ } -u_long +unsigned long ACE_Flow_Spec::token_bucket_size (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) @@ -117,7 +118,7 @@ ACE_Flow_Spec::token_bucket_size (void) const } void -ACE_Flow_Spec::token_bucket_size (u_long tbs) +ACE_Flow_Spec::token_bucket_size (unsigned long tbs) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) this->TokenBucketSize = tbs; @@ -126,7 +127,7 @@ ACE_Flow_Spec::token_bucket_size (u_long tbs) #endif /* ACE_HAS_WINSOCK2 */ } -u_long +unsigned long ACE_Flow_Spec::peak_bandwidth (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) @@ -137,7 +138,7 @@ ACE_Flow_Spec::peak_bandwidth (void) const } void -ACE_Flow_Spec::peak_bandwidth (u_long pb) +ACE_Flow_Spec::peak_bandwidth (unsigned long pb) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) this->PeakBandwidth = pb; @@ -146,7 +147,7 @@ ACE_Flow_Spec::peak_bandwidth (u_long pb) #endif /* ACE_HAS_WINSOCK2 */ } -u_long +unsigned long ACE_Flow_Spec::latency (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) @@ -157,7 +158,7 @@ ACE_Flow_Spec::latency (void) const } void -ACE_Flow_Spec::latency (u_long l) +ACE_Flow_Spec::latency (unsigned long l) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) this->Latency = l; @@ -166,7 +167,7 @@ ACE_Flow_Spec::latency (u_long l) #endif /* ACE_HAS_WINSOCK2 */ } -u_long +unsigned long ACE_Flow_Spec::delay_variation (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) @@ -176,7 +177,7 @@ ACE_Flow_Spec::delay_variation (void) const #endif /* ACE_HAS_WINSOCK2 */ } void -ACE_Flow_Spec::delay_variation (u_long dv) +ACE_Flow_Spec::delay_variation (unsigned long dv) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) this->DelayVariation = dv; @@ -207,7 +208,7 @@ ACE_Flow_Spec::service_type (ACE_SERVICE_TYPE st) #endif /* ACE_HAS_WINSOCK2 */ } -u_long +unsigned long ACE_Flow_Spec::max_sdu_size (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \ @@ -219,7 +220,7 @@ ACE_Flow_Spec::max_sdu_size (void) const } void -ACE_Flow_Spec::max_sdu_size (u_long mss) +ACE_Flow_Spec::max_sdu_size (unsigned long mss) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \ defined (ACE_HAS_WINSOCK2_GQOS) @@ -229,7 +230,7 @@ ACE_Flow_Spec::max_sdu_size (u_long mss) #endif /* ACE_HAS_WINSOCK2 */ } -u_long +unsigned long ACE_Flow_Spec::minimum_policed_size (void) const { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \ @@ -241,7 +242,7 @@ ACE_Flow_Spec::minimum_policed_size (void) const } void -ACE_Flow_Spec::minimum_policed_size (u_long mps) +ACE_Flow_Spec::minimum_policed_size (unsigned long mps) { #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \ defined (ACE_HAS_WINSOCK2_GQOS) @@ -370,7 +371,7 @@ ACE_QoS_Params::ACE_QoS_Params (iovec *caller_data, iovec *callee_data, ACE_QoS *socket_qos, ACE_QoS *group_socket_qos, - u_long flags) + unsigned long flags) : caller_data_ (caller_data), callee_data_ (callee_data), socket_qos_ (socket_qos), @@ -427,20 +428,20 @@ ACE_QoS_Params::group_socket_qos (ACE_QoS *gsq) this->group_socket_qos_ = gsq; } -u_long +unsigned long ACE_QoS_Params::flags (void) const { return this->flags_; } void -ACE_QoS_Params::flags (u_long f) +ACE_QoS_Params::flags (unsigned long f) { this->flags_ = f; } ACE_Accept_QoS_Params::ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback, - u_long callback_data) + unsigned long callback_data) : qos_condition_callback_ (qos_condition_callback), callback_data_ (callback_data) { @@ -458,14 +459,14 @@ ACE_Accept_QoS_Params::qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc) this->qos_condition_callback_ = qcc; } -u_long +unsigned long ACE_Accept_QoS_Params::callback_data (void) const { return this->callback_data_; } void -ACE_Accept_QoS_Params::callback_data (u_long cd) +ACE_Accept_QoS_Params::callback_data (unsigned long cd) { this->callback_data_ = cd; } diff --git a/ace/OS_QoS.h b/ace/OS_QoS.h index 3756f4cf016..68e8705f51f 100644 --- a/ace/OS_QoS.h +++ b/ace/OS_QoS.h @@ -16,17 +16,20 @@ #define ACE_OS_QOS_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/OS_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/os_include/sys/os_uio.h" +#include "ace/OS_NS_stropts.h" + #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) #if defined (ACE_HAS_WINSOCK2_GQOS) typedef SERVICETYPE ACE_SERVICE_TYPE; #else -typedef u_long ACE_SERVICE_TYPE; +typedef unsigned long ACE_SERVICE_TYPE; #endif /* ACE_HAS_WINSOCK2_GQOS */ @@ -57,7 +60,7 @@ typedef u_long ACE_SERVICE_TYPE; #define ACE_SIO_SET_QOS SIO_SET_QOS #else -typedef u_long ACE_SERVICE_TYPE; +typedef unsigned long ACE_SERVICE_TYPE; #define ACE_OVERLAPPED_SOCKET_FLAG 0 #define ACE_XP1_QOS_SUPPORTED 0x00002000 @@ -108,46 +111,46 @@ public: ACE_Flow_Spec (void); /// Constructor that initializes all the fields. - ACE_Flow_Spec (u_long token_rate, - u_long token_bucket_size, - u_long peak_bandwidth, - u_long latency, - u_long delay_variation, + ACE_Flow_Spec (unsigned long token_rate, + unsigned long token_bucket_size, + unsigned long peak_bandwidth, + unsigned long latency, + unsigned long delay_variation, ACE_SERVICE_TYPE service_type, - u_long max_sdu_size, - u_long minimum_policed_size, + unsigned long max_sdu_size, + unsigned long minimum_policed_size, int ttl, int priority); /// Get the token rate in bytes/sec. - u_long token_rate (void) const; + unsigned long token_rate (void) const; /// Set the token rate in bytes/sec. - void token_rate (u_long tr); + void token_rate (unsigned long tr); /// Get the token bucket size in bytes. - u_long token_bucket_size (void) const; + unsigned long token_bucket_size (void) const; /// Set the token bucket size in bytes. - void token_bucket_size (u_long tbs); + void token_bucket_size (unsigned long tbs); /// Get the PeakBandwidth in bytes/sec. - u_long peak_bandwidth (void) const; + unsigned long peak_bandwidth (void) const; /// Set the PeakBandwidth in bytes/sec. - void peak_bandwidth (u_long pb); + void peak_bandwidth (unsigned long pb); /// Get the latency in microseconds. - u_long latency (void) const; + unsigned long latency (void) const; /// Set the latency in microseconds. - void latency (u_long l); + void latency (unsigned long l); /// Get the delay variation in microseconds. - u_long delay_variation (void) const; + unsigned long delay_variation (void) const; /// Set the delay variation in microseconds. - void delay_variation (u_long dv); + void delay_variation (unsigned long dv); /// Get the service type. ACE_SERVICE_TYPE service_type (void) const; @@ -156,16 +159,16 @@ public: void service_type (ACE_SERVICE_TYPE st); /// Get the maximum SDU size in bytes. - u_long max_sdu_size (void) const; + unsigned long max_sdu_size (void) const; /// Set the maximum SDU size in bytes. - void max_sdu_size (u_long mss); + void max_sdu_size (unsigned long mss); /// Get the minimum policed size in bytes. - u_long minimum_policed_size (void) const; + unsigned long minimum_policed_size (void) const; /// Set the minimum policed size in bytes. - void minimum_policed_size (u_long mps); + void minimum_policed_size (unsigned long mps); /// Get the time-to-live. int ttl (void) const; @@ -183,14 +186,14 @@ public: defined (ACE_HAS_WINSOCK2_GQOS) #else private: - u_long token_rate_; - u_long token_bucket_size_; - u_long peak_bandwidth_; - u_long latency_; - u_long delay_variation_; + unsigned long token_rate_; + unsigned long token_bucket_size_; + unsigned long peak_bandwidth_; + unsigned long latency_; + unsigned long delay_variation_; ACE_SERVICE_TYPE service_type_; - u_long max_sdu_size_; - u_long minimum_policed_size_; + unsigned long max_sdu_size_; + unsigned long minimum_policed_size_; int ttl_; int priority_; #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \ @@ -264,7 +267,7 @@ public: iovec *callee_data = 0, ACE_QoS *socket_qos = 0, ACE_QoS *group_socket_qos = 0, - u_long flags = 0); + unsigned long flags = 0); /// Get caller data. iovec *caller_data (void) const; @@ -291,10 +294,10 @@ public: void group_socket_qos (ACE_QoS *); /// Get flags. - u_long flags (void) const; + unsigned long flags (void) const; /// Set flags. - void flags (u_long); + void flags (unsigned long); private: /// A pointer to the user data that is to be transferred to the peer @@ -314,7 +317,7 @@ private: ACE_QoS *group_socket_qos_; /// Flags that indicate if we're a sender, receiver, or both. - u_long flags_; + unsigned long flags_; }; // Callback function that's used by the QoS-enabled <ACE_OS::accept> @@ -326,7 +329,7 @@ typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id, iovec *callee_id, iovec *callee_data, ACE_SOCK_GROUP *g, - u_long callbackdata); + unsigned long callbackdata); /** @@ -349,7 +352,7 @@ public: * i.e., it is an Asynchronous Completion Token (ACT). */ ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback = 0, - u_long callback_data = 0); + unsigned long callback_data = 0); /// Get QoS condition callback. ACE_QOS_CONDITION_FUNC qos_condition_callback (void) const; @@ -358,10 +361,10 @@ public: void qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc); /// Get callback data. - u_long callback_data (void) const; + unsigned long callback_data (void) const; /// Set callback data. - void callback_data (u_long cd); + void callback_data (unsigned long cd); private: /** @@ -378,7 +381,7 @@ private: * function parameter, i.e., it is an Asynchronous Completion Token * (ACT). */ - u_long callback_data_; + unsigned long callback_data_; }; diff --git a/ace/OS_String.cpp b/ace/OS_String.cpp index a7388fffd86..d8db2e3c296 100644 --- a/ace/OS_String.cpp +++ b/ace/OS_String.cpp @@ -21,1053 +21,3 @@ ACE_RCSID (ace, OS_String, "$Id$") extern "C" wchar_t *wcsdup __P ((__const wchar_t *__s)); #endif /* ACE_LACKS_WCSDUP_PROTOTYPE */ -const char * -ACE_OS_String::strnstr (const char *s1, const char *s2, size_t len2) -{ - // Substring length - size_t len1 = ACE_OS_String::strlen (s1); - - // Check if the substring is longer than the string being searched. - if (len2 > len1) - return 0; - - // Go upto <len> - size_t len = len1 - len2; - - for (size_t i = 0; i <= len; i++) - { - if (ACE_OS_String::memcmp (s1 + i, s2, len2) == 0) - // Found a match! Return the index. - return s1 + i; - } - - return 0; -} - -const ACE_WCHAR_T * -ACE_OS_String::strnstr (const ACE_WCHAR_T *s1, const ACE_WCHAR_T *s2, size_t len2) -{ - // Substring length - size_t len1 = ACE_OS_String::strlen (s1); - - // Check if the substring is longer than the string being searched. - if (len2 > len1) - return 0; - - // Go upto <len> - size_t len = len1 - len2; - - for (size_t i = 0; i <= len; i++) - { - if (ACE_OS_String::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0) - // Found a match! Return the index. - return s1 + i; - } - - return 0; -} - -char * -ACE_OS_String::strdup (const char *s) -{ -#if defined (ACE_HAS_STRDUP_EMULATION) - char *t = (char *) ACE_OS_Memory::malloc (ACE_OS_String::strlen (s) + 1); - if (t == 0) - return 0; - - return ACE_OS_String::strcpy (t, s); -#else - return ::strdup (s); -#endif /* ACE_HAS_STRDUP_EMULATION */ -} - -#if defined (ACE_HAS_WCHAR) -wchar_t * -ACE_OS_String::strdup (const wchar_t *s) -{ -# if defined (ACE_LACKS_WCSDUP) - wchar_t *buffer = - (wchar_t *) ACE_OS_Memory::malloc ((ACE_OS_String::strlen (s) + 1) - * sizeof (wchar_t)); - if (buffer == 0) - return 0; - - return ACE_OS_String::strcpy (buffer, s); -# elif defined (ACE_WCSDUP_EQUIVALENT) - return ACE_WCSDUP_EQUIVALENT (s); -# else /* ACE_LACKS_WCSDUP */ -# if defined (__MINGW32__) - return ::wcsdup (ACE_const_cast(wchar_t*, s)); -# else /* __MINGW32__ */ - return ::wcsdup (s); -# endif /* __MINGW32__ */ -# endif /* ACE_LACKS_WCSDUP */ -} -#endif /* ACE_HAS_WCHAR */ - -#if defined (ACE_LACKS_STRERROR) -/** - * Just returns "Unknown Error" all the time. - */ -char * -ACE_OS_String::strerror_emulation (int errnum) -{ - return "Unknown Error"; -} -#endif /* ACE_LACKS_STRERROR */ - -#if defined (ACE_LACKS_STRCHR) -char * -ACE_OS_String::strchr_emulation (char *s, int c) -{ - for (;;++s) - { - if (*s == c) - return s; - if (*s == 0) - return 0; - } -} - -const char * -ACE_OS_String::strchr_emulation (const char *s, int c) -{ - for (;;++s) - { - if (*s == c) - return s; - if (*s == 0) - return 0; - } -} -#endif /* ACE_LACKS_STRCHR */ - -const char * -ACE_OS_String::strnchr (const char *s, int c, size_t len) -{ - for (size_t i = 0; i < len; i++) - if (s[i] == c) - return s + i; - - return 0; -} - -const ACE_WCHAR_T * -ACE_OS_String::strnchr (const ACE_WCHAR_T *s, ACE_WINT_T c, size_t len) -{ - for (size_t i = 0; i < len; i++) - if (s[i] == ACE_static_cast(ACE_WCHAR_T, c)) - return s + i; - - return 0; -} - -#if defined (ACE_LACKS_STRRCHR) -char * -ACE_OS_String::strrchr_emulation (char *s, int c) -{ - char *p = s + ACE_OS_String::strlen (s); - - while (*p != c) - if (p == s) - return 0; - else - p--; - - return p; -} - -const char * -ACE_OS_String::strrchr_emulation (const char *s, int c) -{ - const char *p = s + ACE_OS_String::strlen (s); - - while (*p != c) - if (p == s) - return 0; - else - p--; - - return p; -} -#endif /* ACE_LACKS_STRRCHR */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR) -const wchar_t * -ACE_OS_String::wcsrchr_emulation (const wchar_t *s, wint_t c) -{ - const wchar_t *p = s + ACE_OS_String::strlen (s); - - while (*p != ACE_static_cast (wchar_t, c)) - if (p == s) - return 0; - else - p--; - - return p; -} - -wchar_t * -ACE_OS_String::wcsrchr_emulation (wchar_t *s, wint_t c) -{ - wchar_t *p = s + ACE_OS_String::strlen (s); - - while (*p != ACE_static_cast(wchar_t, c)) - if (p == s) - return 0; - else - p--; - - return p; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */ - -char * -ACE_OS_String::strecpy (char *s, const char *t) -{ - register char *dscan = s; - register const char *sscan = t; - - while ((*dscan++ = *sscan++) != '\0') - continue; - - return dscan; -} - -#if defined (ACE_HAS_WCHAR) -wchar_t * -ACE_OS_String::strecpy (wchar_t *s, const wchar_t *t) -{ - register wchar_t *dscan = s; - register const wchar_t *sscan = t; - - while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0')) - continue; - - return dscan; -} -#endif /* ACE_HAS_WCHAR */ - -#if defined (ACE_LACKS_STRCSPN) -size_t -ACE_OS_String::strcspn_emulation (const char *s, const char *reject) -{ - const char *scan; - const char *rej_scan; - int count = 0; - - for (scan = s; *scan; scan++) - { - - for (rej_scan = reject; *rej_scan; rej_scan++) - if (*scan == *rej_scan) - return count; - - count++; - } - - return count; -} -#endif /* ACE_LACKS_STRCSPN */ - -#if defined (ACE_LACKS_STRCASECMP) -int -ACE_OS_String::strcasecmp_emulation (const char *s, const char *t) -{ - const char *scan1 = s; - const char *scan2 = t; - - while (*scan1 != 0 - && ACE_OS_String::to_lower (*scan1) - == ACE_OS_String::to_lower (*scan2)) - { - ++scan1; - ++scan2; - } - - // The following case analysis is necessary so that characters which - // look negative collate low against normal characters but high - // against the end-of-string NUL. - - if (*scan1 == '\0' && *scan2 == '\0') - return 0; - else if (*scan1 == '\0') - return -1; - else if (*scan2 == '\0') - return 1; - else - return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); -} -#endif /* ACE_LACKS_STRCASECMP */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP) -int -ACE_OS_String::wcsicmp_emulation (const wchar_t *s, const wchar_t *t) -{ - const wchar_t *scan1 = s; - const wchar_t *scan2 = t; - - while (*scan1 != 0 - && ACE_OS_String::to_lower (*scan1) - == ACE_OS_String::to_lower (*scan2)) - { - ++scan1; - ++scan2; - } - - // The following case analysis is necessary so that characters which - // look negative collate low against normal characters but high - // against the end-of-string NUL. - - if (*scan1 == '\0' && *scan2 == '\0') - return 0; - else if (*scan1 == '\0') - return -1; - else if (*scan2 == '\0') - return 1; - else - return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */ - -#if defined (ACE_LACKS_STRCASECMP) -int -ACE_OS_String::strncasecmp_emulation (const char *s, - const char *t, - size_t len) -{ - const char *scan1 = s; - const char *scan2 = t; - size_t count = 0; - - while (count++ < len - && *scan1 != 0 - && ACE_OS_String::to_lower (*scan1) - == ACE_OS_String::to_lower (*scan2)) - { - ++scan1; - ++scan2; - } - - if (count > len) - return 0; - - // The following case analysis is necessary so that characters which - // look negative collate low against normal characters but high - // against the end-of-string NUL. - - if (*scan1 == '\0' && *scan2 == '\0') - return 0; - else if (*scan1 == '\0') - return -1; - else if (*scan2 == '\0') - return 1; - else - return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); -} -#endif /* ACE_LACKS_STRCASECMP */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP) -int -ACE_OS_String::wcsnicmp_emulation (const wchar_t *s, - const wchar_t *t, - size_t len) -{ - const wchar_t *scan1 = s; - const wchar_t *scan2 = t; - size_t count = 0; - - while (count++ < len - && *scan1 != 0 - && ACE_OS_String::to_lower (*scan1) - == ACE_OS_String::to_lower (*scan2)) - { - ++scan1; - ++scan2; - } - - if (count > len) - return 0; - - // The following case analysis is necessary so that characters which - // look negative collate low against normal characters but high - // against the end-of-string NUL. - - if (*scan1 == '\0' && *scan2 == '\0') - return 0; - else if (*scan1 == '\0') - return -1; - else if (*scan2 == '\0') - return 1; - else - return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */ - -#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) -char * -ACE_OS_String::strtok_r_emulation (char *s, const char *tokens, char **lasts) -{ - if (s == 0) - s = *lasts; - else - *lasts = s; - if (*s == 0) // We have reached the end - return 0; - size_t l_org = ACE_OS_String::strlen (s); - s = ::strtok (s, tokens); - if (s == 0) - return 0; - size_t l_sub = ACE_OS_String::strlen (s); - if (s + l_sub < *lasts + l_org) - *lasts = s + l_sub + 1; - else - *lasts = s + l_sub; - return s ; -} -#endif /* !ACE_HAS_REENTRANT_FUNCTIONS */ - -# if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSTOK) -wchar_t* -ACE_OS_String::strtok_r_emulation (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts) -{ - if (s == 0) - s = *lasts; - else - *lasts = s; - if (*s == 0) // We have reached the end - return 0; - int l_org = ACE_OS_String::strlen (s); - s = ACE_OS_String::strtok (s, tokens); - if (s == 0) - return 0; - int l_sub = ACE_OS_String::strlen (s); - if (s + l_sub < *lasts + l_org) - *lasts = s + l_sub + 1; - else - *lasts = s + l_sub; - return s ; -} -# endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSTOK */ - -#if !defined (ACE_HAS_MEMCHR) -const void * -ACE_OS_String::memchr_emulation (const void *s, int c, size_t len) -{ - const unsigned char *t = (const unsigned char *) s; - const unsigned char *e = (const unsigned char *) s + len; - - while (t < e) - if (((int) *t) == c) - return t; - else - t++; - - return 0; -} -#endif /*ACE_HAS_MEMCHR*/ - -#if !defined (ACE_HAS_ITOA) -char * -ACE_OS_String::itoa_emulation (int value, char *string, int radix) -{ - char *e = string; - char *b = string; - - // Short circuit if 0 - - if (value == 0) - { - string[0] = '0'; - string[1] = 0; - return string; - } - - // If negative and base 10, print a - and then do the - // number. - - if (value < 0 && radix == 10) - { - string[0] = '-'; - ++b; - ++e; // Don't overwrite the negative sign. - value = -value; // Drop negative sign so character selection is correct. - } - - // Convert to base <radix>, but in reverse order - - while (value != 0) - { - int mod = value % radix; - value = value / radix; - - *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10; - } - - *e-- = 0; - - // Now reverse the string to get the correct result - - while (e > b) - { - char temp = *e; - *e = *b; - *b = temp; - ++b; - --e; - } - - return string; -} -#endif /* !ACE_HAS_ITOA */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW) -wchar_t * -ACE_OS_String::itow_emulation (int value, wchar_t *string, int radix) -{ - wchar_t *e = string; - wchar_t *b = string; - - // Short circuit if 0 - - if (value == 0) - { - string[0] = '0'; - string[1] = 0; - return string; - } - - // If negative and base 10, print a - and then do the - // number. - - if (value < 0 && radix == 10) - { - string[0] = '-'; - b++; - } - - // Convert to base <radix>, but in reverse order - - while (value != 0) - { - int mod = value % radix; - value = value / radix; - - *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10; - } - - *e-- = 0; - - // Now reverse the string to get the correct result - - while (e > b) - { - wchar_t temp = *e; - *e = *b; - *b = temp; - ++b; - --e; - } - - return string; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCSPN) -size_t -ACE_OS_String::wcscspn_emulation (const wchar_t *s, const wchar_t *reject) -{ - const wchar_t *scan; - const wchar_t *rej_scan; - int count = 0; - - for (scan = s; *scan; scan++) - { - - for (rej_scan = reject; *rej_scan; rej_scan++) - if (*scan == *rej_scan) - return count; - - count++; - } - - return count; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCSPN */ - -// The following wcs*_emulation methods were created based on BSD code: -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * James W. Williams of NASA Goddard Space Flight Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - - - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT) -wchar_t * -ACE_OS_String::wcscat_emulation (wchar_t *destination, - const wchar_t *source) -{ - wchar_t *save = destination; - - for (; *destination; ++destination); - while ((*destination++ = *source++)); - return save; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ - -#if defined (ACE_LACKS_STRSPN) -size_t -ACE_OS_String::strspn_emulation (const char *string, - const char *charset) -{ - const char *p = string; - const char *spanp; - wchar_t c, sc; - - // Skip any characters in charset, excluding the terminating \0. -cont: - c = *p++; - for (spanp = charset; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (p - 1 - string); -} -#endif /* ACE_LACKS_STRSPN */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN) -size_t -ACE_OS_String::wcsspn_emulation (const wchar_t *string, - const wchar_t *charset) -{ - const wchar_t *p = string; - const wchar_t *spanp; - wchar_t c, sc; - - // Skip any characters in charset, excluding the terminating \0. -cont: - c = *p++; - for (spanp = charset; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (p - 1 - string); -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR) -wchar_t * -ACE_OS_String::wcsstr_emulation (const wchar_t *string, - const wchar_t *charset) -{ - wchar_t c, sc; - size_t len; - - if ((c = *charset++) != 0) - { - len = strlen(charset); - do - { - do - { - if ((sc = *string++) == 0) - return 0; - } while (sc != c); - } while (strncmp(string, charset, len) != 0); - string--; - } - - return ACE_const_cast (wchar_t *, string); -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) -size_t -ACE_OS_String::wcslen_emulation (const ACE_WCHAR_T *string) -{ - const ACE_WCHAR_T *s; - - for (s = string; *s; ++s) - continue; - - return s - string; -} -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) -ACE_WCHAR_T * -ACE_OS_String::wcsncpy_emulation (ACE_WCHAR_T *destination, - const ACE_WCHAR_T *source, - size_t len) -{ - if (len != 0) - { - ACE_WCHAR_T *d = destination; - const ACE_WCHAR_T *s = source; - - do - { - if ((*d++ = *s++) == 0) - { - // NUL pad the remaining n-1 bytes - while (--len != 0) - *d++ = 0; - break; - } - } while (--len != 0); - } - - return destination; -} -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) -int -ACE_OS_String::wcscmp_emulation (const ACE_WCHAR_T *string1, - const ACE_WCHAR_T *string2) -{ - while (*string1 == *string2++) - if (*string1++ == 0) - return (0); - return (*string1 - *--string2); -} -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY) -wchar_t * -ACE_OS_String::wcscpy_emulation (wchar_t *destination, - const wchar_t *source) -{ - wchar_t *save = destination; - - for (; (*destination = *source); ++source, ++destination); - return save; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */ - -#if defined (ACE_LACKS_STRPBRK) -char * -ACE_OS_String::strpbrk_emulation (const char *string, - const char *charset) -{ - const char *scanp; - int c, sc; - - while ((c = *string++) != 0) - { - for (scanp = charset; (sc = *scanp++) != 0;) - if (sc == c) - return ACE_const_cast (char *, string - 1); - } - - return 0; -} -#endif /* ACE_LACKS_STRPBRK */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK) -wchar_t * -ACE_OS_String::wcspbrk_emulation (const wchar_t *string, - const wchar_t *charset) -{ - const wchar_t *scanp; - int c, sc; - - while ((c = *string++) != 0) - { - for (scanp = charset; (sc = *scanp++) != 0;) - if (sc == c) - return ACE_const_cast (wchar_t *, string - 1); - } - - return 0; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) -ACE_WCHAR_T * -ACE_OS_String::wcsncat_emulation (ACE_WCHAR_T *destination, - const ACE_WCHAR_T *source, - size_t count) -{ - if (count != 0) - { - ACE_WCHAR_T *d = destination; - const ACE_WCHAR_T *s = source; - - while (*d != 0) - d++; - - do - { - if ((*d = *s++) == 0) - break; - - d++; - } while (--count != 0); - - *d = 0; - } - - return destination; -} -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCAT */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR) -wchar_t * -ACE_OS_String::wcschr_emulation (const wchar_t *string, wint_t c) -{ - for (;*string ; ++string) - if (*string == ACE_static_cast (wchar_t, c)) - return ACE_const_cast (wchar_t *, string); - - return 0; -} -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) -int -ACE_OS_String::wcsncmp_emulation (const ACE_WCHAR_T *s1, - const ACE_WCHAR_T *s2, - size_t len) -{ - if (len == 0) - return 0; - - do - { - if (*s1 != *s2++) - return (*s1 - *--s2); - if (*s1++ == 0) - break; - } while (--len != 0); - - return 0; -} -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ - -#if defined (ACE_LACKS_STRTOL) -long -ACE_OS_String::strtol_emulation (const char *nptr, char **endptr, int base) -{ - register const char *s = nptr; - register unsigned long acc; - register int c; - register unsigned long cutoff; - register int neg = 0, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; - cutlim = cutoff % (unsigned long)base; - cutoff /= (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = neg ? LONG_MIN : LONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; - return (acc); -} -#endif /* ACE_LACKS_STRTOL */ - -#if defined (ACE_LACKS_STRTOUL) -unsigned long -ACE_OS_String::strtoul_emulation (const char *nptr, - char **endptr, - register int base) -{ - register const char *s = nptr; - register unsigned long acc; - register int c; - register unsigned long cutoff; - register int neg = 0, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - do - c = *s++; - while (isspace(c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - cutoff = (unsigned long) ULONG_MAX / (unsigned long) base; - cutlim = (unsigned long) ULONG_MAX % (unsigned long) base; - - for (acc = 0, any = 0;; c = *s++) - { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) - any = -1; - else - { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = ULONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *) s - 1 : (char *) nptr; - return (acc); -} -#endif /* ACE_LACKS_STRTOUL */ - -char * -ACE_OS_String::strsncpy (char *dst, const char *src, size_t maxlen) -{ - register char *rdst = dst; - register const char *rsrc = src; - register size_t rmaxlen = maxlen; - - if (rmaxlen > 0) - { - if (rdst!=rsrc) - { - *rdst = '\0'; - if (rsrc != 0) - strncat (rdst, rsrc, --rmaxlen); - } - else - { - rdst += (rmaxlen - 1); - *rdst = '\0'; - } - } - return dst; -} - -ACE_WCHAR_T * -ACE_OS_String::strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen) -{ - register ACE_WCHAR_T *rdst = dst; - register const ACE_WCHAR_T *rsrc = src; - register size_t rmaxlen = maxlen; - - if (rmaxlen > 0) - { - if (rdst!=rsrc) - { - *rdst = ACE_TEXT_WIDE ('\0'); - if (rsrc != 0) - strncat (rdst, rsrc, --rmaxlen); - } - else - { - rdst += (rmaxlen - 1); - *rdst = ACE_TEXT_WIDE ('\0'); - } - } - return dst; -} diff --git a/ace/OS_String.h b/ace/OS_String.h index 3d011ef3479..759d4b078b6 100644 --- a/ace/OS_String.h +++ b/ace/OS_String.h @@ -23,598 +23,30 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Basic_Types.h" -#include "ace/os_include/os_stddef.h" - +//#include "ace/Basic_Types.h" +//#include "ace/os_include/os_stddef.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_wchar.h" +#include "ace/OS_NS_ctype.h" + +#if 0 #if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) using std::size_t; using std::wint_t; #endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ +#endif /** - * @class ACE_OS_String + * @namespace ACE_OS_String * * @brief This class includes functions available in string.h and ctype.h. */ -class ACE_OS_Export ACE_OS_String +#define ACE_OS_String ACE_OS +namespace ACE_OS { -public: - /** @name Functions from <cstring> - * - * Included are the functions defined in <cstring> and their <cwchar> - * equivalents. - * - * @todo To be complete, we should add strcoll, and strxfrm. - */ - //@{ - - /// Finds characters in a buffer (const void version). - static const void *memchr (const void *s, int c, size_t len); - - /// Finds characters in a buffer (void version). - static void *memchr (void *s, int c, size_t len); - - /// Compares two buffers. - static int memcmp (const void *t, const void *s, size_t len); - - /// Copies one buffer to another. - static void *memcpy (void *t, const void *s, size_t len); - - /// Moves one buffer to another. - static void *memmove (void *t, const void *s, size_t len); - - /// Fills a buffer with a character value. - static void *memset (void *s, int c, size_t len); - - /// Appends a string to another string (char version). - static char *strcat (char *s, const char *t); - -#if defined (ACE_HAS_WCHAR) - /// Appends a string to another string (wchar_t version). - static wchar_t *strcat (wchar_t *s, const wchar_t *t); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the first occurance of a character in a string (const char - /// version). - static const char *strchr (const char *s, int c); - -#if defined (ACE_HAS_WCHAR) - /// Finds the first occurance of a character in a string (const wchar_t - /// version). - static const wchar_t *strchr (const wchar_t *s, wint_t c); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the first occurance of a character in a string (char version). - static char *strchr (char *s, int c); - -#if defined (ACE_HAS_WCHAR) - /// Finds the first occurance of a character in a string (wchar_t version). - static wchar_t *strchr (wchar_t *s, wint_t c); -#endif /* ACE_HAS_WCHAR */ - - /// Compares two strings (char version). - static int strcmp (const char *s, const char *t); - - /// Compares two strings (wchar_t version). - static int strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t); - - /// Copies a string (char version). - static char *strcpy (char *s, const char *t); - -#if defined (ACE_HAS_WCHAR) - /// Copies a string (wchar_t version). - static wchar_t *strcpy (wchar_t *s, const wchar_t *t); -#endif /* ACE_HAS_WCHAR */ - - /// Searches for the first substring without any of the specified - /// characters and returns the size of the substring (char version). - static size_t strcspn (const char *s, const char *reject); - -#if defined (ACE_HAS_WCHAR) - /// Searches for the first substring without any of the specified - /// characters and returns the size of the substring (wchar_t version). - static size_t strcspn (const wchar_t *s, const wchar_t *reject); -#endif /* ACE_HAS_WCHAR */ - - /// Returns a system error message. - static char *strerror (int errnum); - - /// Finds the length of a string (char version). - static size_t strlen (const char *s); - - /// Finds the length of a string (ACE_WCHAR_T version). - static size_t strlen (const ACE_WCHAR_T *s); - - /// Finds the length of a limited-length string (char version). - /** - * @param s The character string to find the length of. - * @param maxlen The maximum number of characters that will be - * scanned for the terminating nul character. - * - * @return The length of @arg s, if the terminating nul character - * is located, else @arg maxlen. - */ - static size_t strnlen (const char *s, size_t maxlen); - - /// Finds the length of a limited-length string (ACE_WCHAR_T version). - /** - * @param s The character string to find the length of. - * @param maxlen The maximum number of characters that will be - * scanned for the terminating nul character. - * - * @return The length of @arg s, if the terminating nul character - * is located, else @arg maxlen. - */ - static size_t strnlen (const ACE_WCHAR_T *s, size_t maxlen); - - /// Appends part of a string to another string (char version). - static char *strncat (char *s, const char *t, size_t len); - - /// Appends part of a string to another string (wchar_t version). - static ACE_WCHAR_T *strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); - - /// Compares two arrays (char version). - static int strncmp (const char *s, const char *t, size_t len); - - /// Compares two arrays (wchar_t version). - static int strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); - - /// Copies an array (char version) - static char *strncpy (char *s, const char *t, size_t len); - - /// Copies an array (ACE_WCHAR_T version) - static ACE_WCHAR_T *strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); - - /// Searches for characters in a string (const char version). - static const char *strpbrk (const char *s1, const char *s2); - -#if defined (ACE_HAS_WCHAR) - /// Searches for characters in a string (const wchar_t version). - static const wchar_t *strpbrk (const wchar_t *s1, const wchar_t *s2); -#endif /* ACE_HAS_WCHAR */ - - /// Searches for characters in a string (char version). - static char *strpbrk (char *s1, const char *s2); - -#if defined (ACE_HAS_WCHAR) - /// Searches for characters in a string (wchar_t version). - static wchar_t *strpbrk (wchar_t *s1, const wchar_t *s2); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the last occurance of a character in a string (const char - /// version). - static const char *strrchr (const char *s, int c); - -#if defined (ACE_HAS_WCHAR) - /// Finds the last occurance of a character in a string (const wchar_t - /// version). - static const wchar_t *strrchr (const wchar_t *s, wint_t c); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the last occurance of a character in a string (char version). - static char *strrchr (char *s, int c); - -#if defined (ACE_HAS_WCHAR) - /// Finds the last occurance of a character in a string (wchar_t version). - static wchar_t *strrchr (wchar_t *s, wint_t c); -#endif /* ACE_HAS_WCHAR */ - - /// Searches for the first substring containing only the specified - /// characters and returns the size of the substring (char version). - static size_t strspn (const char *s1, const char *s2); - -#if defined (ACE_HAS_WCHAR) - /// Searches for the first substring containing only the specified - /// characters and returns the size of the substring (wchar_t version). - static size_t strspn (const wchar_t *s1, const wchar_t *s2); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the first occurance of a substring in a string (const char - /// version). - static const char *strstr (const char *s, const char *t); - -#if defined (ACE_HAS_WCHAR) - /// Finds the first occurance of a substring in a string (const wchar_t - /// version). - static const wchar_t *strstr (const wchar_t *s, const wchar_t *t); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the first occurance of a substring in a string (char version). - static char *strstr (char *s, const char *t); - -#if defined (ACE_HAS_WCHAR) - /// Finds the first occurance of a substring in a string (wchar_t version). - static wchar_t *strstr (wchar_t *s, const wchar_t *t); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the next token in a string (char version). - static char *strtok (char *s, const char *tokens); - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK) - /// Finds the next token in a string (wchar_t version). - static wchar_t *strtok (wchar_t *s, const wchar_t *tokens); -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOK */ - - //@} - - /** @name Functions from <cctype> - * - * Included are the functions defined in <cctype> and their <cwctype> - * equivalents. - * - * Since they are often implemented as macros, we don't use the same name - * here. Instead, we change by prepending "ace_" (with the exception of - * to_lower). - * - * @todo To be complete, we should add: isalnum, isalpha, iscntrl - * isdigit, isgraph, islower, ispunct, isupper, isxdigit, and toupper. - */ - //@{ - - /// Returns true if the character is a printable character. - static int ace_isprint (const ACE_TCHAR c); - - /// Returns true if the character is a space character. - static int ace_isspace (const ACE_TCHAR c); - - /// Converts a character to lower case (char version). - static int to_lower (int c); - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER) - /// Converts a character to lower case (wchar_t version). - static wint_t to_lower (wint_t c); -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_TOWLOWER */ - - //@} - - /** @name Non-standard functions - * - * These functions aren't in the standard. - * - */ - //@{ - - /// Converts an integer to a string. - static char *itoa (int value, char *string, int radix); - -#if defined (ACE_HAS_WCHAR) - /// Converts an integer to a string. - static wchar_t *itoa (int value, wchar_t *string, int radix); -#endif /* ACE_HAS_WCHAR */ - - /// Compares two strings (case insensitive const char version). - static int strcasecmp (const char *s, const char *t); - -#if defined (ACE_HAS_WCHAR) - /// Compares two strings (case insensitive const wchar_t version). - static int strcasecmp (const wchar_t *s, const wchar_t *t); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the first occurance of a character in an array (const char - /// version). - static const char *strnchr (const char *s, int c, size_t len); - - /// Finds the first occurance of a character in an array (const ACE_WCHAR_T - /// version). - static const ACE_WCHAR_T *strnchr (const ACE_WCHAR_T *s, ACE_WINT_T c, size_t len); - - /// Finds the first occurance of a character in an array (char version). - static char *strnchr (char *s, int c, size_t len); - - /// Finds the first occurance of a character in an array (ACE_WCHAR_T version). - static ACE_WCHAR_T *strnchr (ACE_WCHAR_T *s, ACE_WINT_T c, size_t len); - - /// Compares two arrays (case insensitive const char version). - static int strncasecmp (const char *s, const char *t, size_t len); - -#if defined (ACE_HAS_WCHAR) - /// Compares two arrays (case insensitive const wchar_t version). - static int strncasecmp (const wchar_t *s, const wchar_t *t, size_t len); -#endif /* ACE_HAS_WCHAR */ - - /// Copies a string, but returns a pointer to the end of the - /// copied region (char version). - static char *strecpy (char *des, const char *src); - -#if defined (ACE_HAS_WCHAR) - /// Copies a string, but returns a pointer to the end of the - /// copied region (wchar_t version). - static wchar_t *strecpy (wchar_t *s, const wchar_t *t); -#endif /* ACE_HAS_WCHAR */ - - /// This is a "safe" c string copy function (char version). - /** - * Unlike strncpy() this function will always add a terminating '\0' - * char if maxlen > 0. So the user doesn't has to provide an extra - * '\0' if the user wants a '\0' terminated dst. The function - * doesn't check for a 0 <dst>, because this will give problems - * anyway. When <src> is 0 an empty string is made. We do not - * "touch" *<dst> if maxlen is 0. Returns <dst>. Care should be - * taken when replacing strncpy() calls, because in some cases a - * strncpy() user is using the "not '\0' terminating" feature from - * strncpy(). This happens most when the call to strncpy() was - * optimized by using a maxlen which is 1 smaller than the size - * because there's always written a '\0' inside this last position. - * Very seldom it's possible that the '\0' padding feature from - * strncpy() is needed. - */ - static char *strsncpy (char *dst, - const char *src, - size_t maxlen); - - /// This is a "safe" c string copy function (wchar_t version). - /** - * Unlike strncpy() this function will always add a terminating '\0' - * char if maxlen > 0. So the user doesn't has to provide an extra - * '\0' if the user wants a '\0' terminated dst. The function - * doesn't check for a 0 <dst>, because this will give problems - * anyway. When <src> is 0 an empty string is made. We do not - * "touch" *<dst> if maxlen is 0. Returns <dst>. Care should be - * taken when replacing strncpy() calls, because in some cases a - * strncpy() user is using the "not '\0' terminating" feature from - * strncpy(). This happens most when the call to strncpy() was - * optimized by using a maxlen which is 1 smaller than the size - * because there's always written a '\0' inside this last position. - * Very seldom it's possible that the '\0' padding feature from - * strncpy() is needed. - */ - static ACE_WCHAR_T *strsncpy (ACE_WCHAR_T *dst, - const ACE_WCHAR_T *src, - size_t maxlen); - - /// Finds the first occurance of a substring in an array (const char - /// version). - static const char *strnstr (const char *s, const char *t, size_t len); - - /// Finds the first occurance of a substring in an array (const wchar_t - /// version). - static const ACE_WCHAR_T *strnstr (const ACE_WCHAR_T *s, - const ACE_WCHAR_T *t, - size_t len); - - /// Finds the first occurance of a substring in an array (char version). - static char *strnstr (char *s, const char *t, size_t len); - - /// Finds the first occurance of a substring in an array (wchar_t version). - static ACE_WCHAR_T *strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len); - - /// Returns a malloced duplicated string (char version). - static char *strdup (const char *s); - -#if defined (ACE_HAS_WCHAR) - /// Returns a malloced duplicated string (wchar_t version). - static wchar_t *strdup (const wchar_t *s); -#endif /* ACE_HAS_WCHAR */ - - /// Finds the next token in a string (safe char version). - static char *strtok_r (char *s, const char *tokens, char **lasts); - -#if defined (ACE_HAS_WCHAR) - /// Finds the next token in a string (wchar_t version). - static wchar_t *strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts); -#endif // ACE_HAS_WCHAR - -#if !defined (ACE_LACKS_STRTOD) - /// Converts a string to a double value (char version). - static double strtod (const char *s, char **endptr); -#endif /* !ACE_LACKS_STRTOD */ - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD) - /// Converts a string to a double value (wchar_t version). - static double strtod (const wchar_t *s, wchar_t **endptr); -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */ - - /// Converts a string to a long value (char version). - static long strtol (const char *s, char **ptr, int base); - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL) - /// Converts a string to a long value (wchar_t version). - static long strtol (const wchar_t *s, wchar_t **ptr, int base); -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */ - - /// Converts a string to an unsigned long value (char version). - static unsigned long strtoul (const char *s, char **ptr, int base); - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL) - /// Converts a string to an unsigned long value (wchar_t version). - static unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base); -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */ - - //@} - -private: - - /** @name Emulation - * - * These methods are provided for platforms that do not have a native - * implementation. - */ - //@{ - -#if !defined (ACE_HAS_ITOA) - /// Emulated itoa - Converts an integer to a string. - static char *itoa_emulation (int value, char *string, int radix); -#endif /* !ACE_HAS_ITOA */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW) - /// Emulated itow - Converts an integer to a string. - static wchar_t *itow_emulation (int value, wchar_t *string, int radix); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */ - -#if !defined (ACE_HAS_MEMCHR) - /// Emulated memchr - Finds a character in a buffer. - static const void *memchr_emulation (const void *s, int c, size_t len); -#endif /* ACE_HAS_MEMCHR */ - -#if defined (ACE_LACKS_STRCASECMP) - /// Emulated strcasecmp - Performs a case insensitive comparison of strings. - static int strcasecmp_emulation (const char *s, const char *t); - - /// Emulated strncasecmp - Performs a case insensitvie comparison of arrays. - static int strncasecmp_emulation (const char *s, const char *t, size_t len); -#endif /* ACE_LACKS_STRCASECMP */ - -#if defined (ACE_LACKS_STRCSPN) - /// Emulated strcspn - Finds a substring in a string. - static size_t strcspn_emulation (const char *s, const char *reject); -#endif /* ACE_LACKS_STRCSPN */ - -#if defined (ACE_LACKS_STRCHR) - /// Emulated strchr (char version) - Finds the first occurance of a - /// character in a string. - static char *strchr_emulation (char *s, int c); - - /// Emulated strchr (const char version) - Finds the first occurance of a - /// character in a string. - static const char *strchr_emulation (const char *s, int c); -#endif /* ACE_LACKS_STRCHR */ - -#if defined (ACE_LACKS_STRERROR) - /// Emulated strerror - Returns a system error message. - static char *strerror_emulation (int errnum); -#endif /* ACE_LACKS_STRERROR */ - -#if defined (ACE_LACKS_STRPBRK) - /// Emulated strpbrk - Searches for characters in a string. - static char *strpbrk_emulation (const char *string, - const char *charset); -#endif /* ACE_LACKS_STRPBRK */ - -#if defined (ACE_LACKS_STRRCHR) - /// Emulated strrchr (char version) - Finds the last occurance of a - /// character in a string. - static char *strrchr_emulation (char *s, int c); - - /// Emulated strrchr (const char version) - Finds the last occurance of a - /// character in a string. - static const char *strrchr_emulation (const char *s, int c); -#endif /* ACE_LACKS_STRRCHR */ - -#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) - /// Emulated strtok_r. - static char *strtok_r_emulation (char *s, const char *tokens, char **lasts); - -# if defined (ACE_HAS_WCHAR) - /// Emulated strtok_r (wchar_t version). - static wchar_t *strtok_r_emulation (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts); -# endif // ACE_HAS_WCHAR -#endif /* !ACE_HAS_REENTRANT_FUNCTIONS */ - -#if defined (ACE_LACKS_STRSPN) - /// Emulated wcsspn. - static size_t strspn_emulation (const char *string, - const char *charset); -#endif /* ACE_LACKS_STRSPN */ - -#if defined (ACE_LACKS_STRTOL) - static long strtol_emulation (const char *nptr, char **endptr, int base); -#endif /* ACE_LACKS_STRTOL */ - -#if defined (ACE_LACKS_STRTOUL) - static unsigned long strtoul_emulation (const char *nptr, - char **endptr, - int base); -#endif /* ACE_LACKS_STRTOUL */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT) - /// Emulated wcscat - Appends a string. - static wchar_t *wcscat_emulation (wchar_t *destination, - const wchar_t *source); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR) - /// Emulated wcschr - Finds a character in a string. - static wchar_t *wcschr_emulation (const wchar_t *string, wint_t c); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) - /// Emulated wcscmp - Compares strings. - static int wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2); -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY) - /// Emulated wcscpy - Copies a string. - static wchar_t *wcscpy_emulation (wchar_t *destination, - const wchar_t *source); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP) - /// Emulated wcsicmp - Performs a case insensitive comparison of strings. - static int wcsicmp_emulation (const wchar_t *string1, - const wchar_t *string2); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) - /// Emulated wcslen - Returns the length of a string. - static size_t wcslen_emulation (const ACE_WCHAR_T *string); -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) - /// Emulated wcscat - Appends a string. - static ACE_WCHAR_T *wcsncat_emulation (ACE_WCHAR_T *destination, - const ACE_WCHAR_T *source, - size_t count); -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCAT */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) - /// Emulated wcsncmp - Compares two arrays. - static int wcsncmp_emulation (const ACE_WCHAR_T *string1, - const ACE_WCHAR_T *string2, - size_t len); -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ - -#if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) - /// Emulated wcsncpy - Copies an array. - static ACE_WCHAR_T *wcsncpy_emulation (ACE_WCHAR_T *destination, - const ACE_WCHAR_T *source, - size_t len); -#endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP) - /// Emulated wcsnicmp - Performs a case insensitive comparison of two - /// arrays - static int wcsnicmp_emulation (const wchar_t *string1, - const wchar_t *string2, - size_t len); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK) - /// Emulated wcspbrk - Searches for characters in a string. - static wchar_t *wcspbrk_emulation (const wchar_t *string, - const wchar_t *charset); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR) - /// Emulated wcsrchr (wchar_t version) - Finds the last occurance of a - /// character in a string. - static wchar_t *wcsrchr_emulation (wchar_t *string, wint_t c); - - /// Emulated wcsrchr (const wchar_t version) - Finds the last occurance of a - /// character in a string. - static const wchar_t *wcsrchr_emulation (const wchar_t *string, wint_t c); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCSPN) - /// Emulated wcscspn. - static size_t wcscspn_emulation (const wchar_t *string, - const wchar_t *reject); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCSPN */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN) - /// Emulated wcsspn. - static size_t wcsspn_emulation (const wchar_t *string, - const wchar_t *charset); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */ - -#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR) - /// Emulated wcsstr - Performs a case insensitive comparison of two strings. - static wchar_t *wcsstr_emulation (const wchar_t *string, - const wchar_t *charset); -#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */ - - //@} -}; +}; /* namespace ACE_OS */ # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) diff --git a/ace/OS_String.inl b/ace/OS_String.inl index aa86825114c..64b6ef0150d 100644 --- a/ace/OS_String.inl +++ b/ace/OS_String.inl @@ -9,663 +9,10 @@ */ //============================================================================= -// 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 */ - #include "ace/os_include/os_stdlib.h" #include "ace/os_include/os_string.h" #include "ace/os_include/os_strings.h" #include "ace/os_include/os_ctype.h" -ACE_INLINE const void * -ACE_OS_String::memchr (const void *s, int c, size_t len) -{ -#if defined (ACE_HAS_MEMCHR) - return ::memchr (s, c, len); -#else /* ACE_HAS_MEMCHR */ - return ACE_OS_String::memchr_emulation (s, c, len); -#endif /* ACE_HAS_MEMCHR */ -} - -ACE_INLINE void * -ACE_OS_String::memchr (void *s, int c, size_t len) -{ - return ACE_const_cast (void *, - ACE_OS_String::memchr (ACE_static_cast (const void *, s), c, len)); -} - - -ACE_INLINE int -ACE_OS_String::memcmp (const void *t, const void *s, size_t len) -{ - return ::memcmp (t, s, len); -} - - -ACE_INLINE void * -ACE_OS_String::memcpy (void *t, const void *s, size_t len) -{ - return ::memcpy (t, s, len); -} - -ACE_INLINE void * -ACE_OS_String::memmove (void *t, const void *s, size_t len) -{ - return ::memmove (t, s, len); -} - -ACE_INLINE void * -ACE_OS_String::memset (void *s, int c, size_t len) -{ - return ::memset (s, c, len); -} - -ACE_INLINE char * -ACE_OS_String::strcat (char *s, const char *t) -{ - return ::strcat (s, t); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strcat (wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSCAT) - return ACE_OS_String::wcscat_emulation (s, t); -# else /* ACE_LACKS_WCSCAT */ - return ::wcscat (s, t); -# endif /* ACE_LACKS_WCSCAT */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE const char * -ACE_OS_String::strchr (const char *s, int c) -{ -#if defined (ACE_LACKS_STRCHR) - return ACE_OS_String::strchr_emulation (s, c); -#else /* ! ACE_LACKS_STRCHR */ - return (const char *) ::strchr (s, c); -#endif /* ACE_LACKS_STRCHR */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE const wchar_t * -ACE_OS_String::strchr (const wchar_t *s, wint_t c) -{ -# if defined (ACE_LACKS_WCSCHR) - return ACE_OS_String::wcschr_emulation (s, c); -# else /* ACE_LACKS_WCSCHR */ - return ::wcschr (s, c); -# endif /* ACE_LACKS_WCSCHR */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strchr (char *s, int c) -{ -#if defined (ACE_LACKS_STRCHR) - return ACE_OS_String::strchr_emulation (s, c); -#else /* ! ACE_LACKS_STRCHR */ - return ::strchr (s, c); -#endif /* ACE_LACKS_STRCHR */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strchr (wchar_t *s, wint_t c) -{ - return ACE_const_cast (wchar_t *, - ACE_OS_String::strchr (ACE_static_cast (const wchar_t *, s), c)); -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS_String::strcmp (const char *s, const char *t) -{ - return ::strcmp (s, t); -} - -ACE_INLINE int -ACE_OS_String::strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t) -{ -# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) - return ACE_OS_String::wcscmp_emulation (s, t); -# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ - return ::wcscmp (s, t); -# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ -} - -ACE_INLINE char * -ACE_OS_String::strcpy (char *s, const char *t) -{ - return ::strcpy (s, t); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strcpy (wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSCPY) - return ACE_OS_String::wcscpy_emulation (s, t); -# else /* ACE_LACKS_WCSCPY */ - return ::wcscpy (s, t); -# endif /* ACE_LACKS_WCSCPY */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE size_t -ACE_OS_String::strcspn (const char *s, const char *reject) -{ -#if defined (ACE_LACKS_STRCSPN) - return ACE_OS_String::strcspn_emulation (s, reject); -#else /* ACE_LACKS_STRCSPN */ - return ::strcspn (s, reject); -#endif /* ACE_LACKS_STRCSPN */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE size_t -ACE_OS_String::strcspn (const wchar_t *s, const wchar_t *reject) -{ -# if defined (ACE_LACKS_WCSCSPN) - return ACE_OS_String::wcscspn_emulation (s, reject); -# else /* ACE_LACKS_WCSCSPN */ - return ::wcscspn (s, reject); -# endif /* ACE_LACKS_WCSCSPN */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strerror (int errnum) -{ -#if defined (ACE_LACKS_STRERROR) - return ACE_OS_String::strerror_emulation (errnum); -#else /* ACE_LACKS_STRERROR */ - return ::strerror (errnum); -#endif /* ACE_LACKS_STRERROR */ -} - -ACE_INLINE size_t -ACE_OS_String::strlen (const char *s) -{ - return ::strlen (s); -} - -ACE_INLINE size_t -ACE_OS_String::strlen (const ACE_WCHAR_T *s) -{ -# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) - return ACE_OS_String::wcslen_emulation (s); -# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ - return ::wcslen (s); -# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ -} - -ACE_INLINE size_t -ACE_OS_String::strnlen (const char *s, size_t maxlen) -{ -#if defined (ACE_HAS_STRNLEN) - return ::strnlen (s, maxlen); -#else /* ACE_HAS_STRNLEN */ - size_t i; - for (i = 0; i < maxlen; ++i) - if (s[i] == '\0') - break; - return i; -#endif /* ACE_HAS_STRNLEN */ -} - -ACE_INLINE size_t -ACE_OS_String::strnlen (const ACE_WCHAR_T *s, size_t maxlen) -{ -#if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN) - return wcsnlen (s, maxlen); -#else /* ACE_HAS_WCSNLEN */ - size_t i; - for (i = 0; i < maxlen; ++i) - if (s[i] == '\0') - break; - return i; -#endif /* ACE_HAS_WCSNLEN */ -} - -ACE_INLINE char * -ACE_OS_String::strncat (char *s, const char *t, size_t len) -{ - return ::strncat (s, t, len); -} - -ACE_INLINE ACE_WCHAR_T * -ACE_OS_String::strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) -{ -# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) - return ACE_OS_String::wcsncat_emulation (s, t, len); -# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */ - return ::wcsncat (s, t, len); -# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */ -} - -ACE_INLINE int -ACE_OS_String::strncmp (const char *s, const char *t, size_t len) -{ - return ::strncmp (s, t, len); -} - -ACE_INLINE int -ACE_OS_String::strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) -{ -# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) - return ACE_OS_String::wcsncmp_emulation (s, t, len); -# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ - return ::wcsncmp (s, t, len); -# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ -} - -ACE_INLINE char * -ACE_OS_String::strncpy (char *s, const char *t, size_t len) -{ - return ::strncpy (s, t, len); -} - -ACE_INLINE ACE_WCHAR_T * -ACE_OS_String::strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) -{ -# if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) - return ACE_OS_String::wcsncpy_emulation (s, t, len); -# else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ - return ::wcsncpy (s, t, len); -# endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ -} - -ACE_INLINE const char * -ACE_OS_String::strpbrk (const char *s1, const char *s2) -{ -#if defined (ACE_LACKS_STRPBRK) - return ACE_OS_String::strpbrk_emulation (s1, s2); -#else /* ACE_LACKS_STRPBRK */ - return (const char *) ::strpbrk (s1, s2); -#endif /* ACE_LACKS_STRPBRK */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE const wchar_t * -ACE_OS_String::strpbrk (const wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSPBRK) - return ACE_OS_String::wcspbrk_emulation (s, t); -# else /* ACE_LACKS_WCSPBRK */ - return ::wcspbrk (s, t); -# endif /* ACE_LACKS_WCSPBRK */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strpbrk (char *s1, const char *s2) -{ -#if defined (ACE_LACKS_STRPBRK) - return ACE_OS_String::strpbrk_emulation (s1, s2); -#else /* ACE_LACKS_STRPBRK */ - return ::strpbrk (s1, s2); -#endif /* ACE_LACKS_STRPBRK */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strpbrk (wchar_t *s, const wchar_t *t) -{ - return ACE_const_cast (wchar_t *, - ACE_OS_String::strpbrk (ACE_static_cast (const wchar_t *, s), t)); -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE const char * -ACE_OS_String::strrchr (const char *s, int c) -{ -#if defined (ACE_LACKS_STRRCHR) - return ACE_OS_String::strrchr_emulation (s, c); -#else /* ! ACE_LACKS_STRRCHR */ - return (const char *) ::strrchr (s, c); -#endif /* ! ACE_LACKS_STRRCHR */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE const wchar_t * -ACE_OS_String::strrchr (const wchar_t *s, wint_t c) -{ -#if defined (ACE_LACKS_WCSRCHR) - return ACE_OS_String::wcsrchr_emulation (s, c); -#else /* ! ACE_LACKS_WCSRCHR */ - return (const wchar_t *) ::wcsrchr (s, c); -#endif /* ! ACE_LACKS_WCSRCHR */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strrchr (char *s, int c) -{ -#if defined (ACE_LACKS_STRRCHR) - return ACE_OS_String::strrchr_emulation (s, c); -#else /* ! ACE_LACKS_STRRCHR */ - return ::strrchr (s, c); -#endif /* ! ACE_LACKS_STRRCHR */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strrchr (wchar_t *s, wint_t c) -{ - return ACE_const_cast (wchar_t *, - ACE_OS_String::strrchr (ACE_static_cast (const wchar_t *, s), c)); -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE size_t -ACE_OS_String::strspn (const char *s, const char *t) -{ -#if defined (ACE_LACKS_STRSPN) - return ACE_OS_String::strspn_emulation (s, t); -#else /* ACE_LACKS_STRSPN */ - return ::strspn (s, t); -#endif /* ACE_LACKS_STRSPN */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE size_t -ACE_OS_String::strspn (const wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSSPN) - return ACE_OS_String::wcsspn_emulation (s, t); -# else /* ACE_LACKS_WCSSPN */ - return ::wcsspn (s, t); -# endif /* ACE_LACKS_WCSSPN */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE const char * -ACE_OS_String::strstr (const char *s, const char *t) -{ - return (const char *) ::strstr (s, t); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE const wchar_t * -ACE_OS_String::strstr (const wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSSTR) - return ACE_OS_String::wcsstr_emulation (s, t); -# elif defined (HPUX) - return (const wchar_t *) ::wcswcs (s, t); -# else /* ACE_LACKS_WCSSTR */ - return (const wchar_t *) ::wcsstr (s, t); -# endif /* ACE_LACKS_WCSSTR */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strstr (char *s, const char *t) -{ - return ::strstr (s, t); -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strstr (wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSSTR) - return ACE_OS_String::wcsstr_emulation (s, t); -# elif defined (HPUX) - return ::wcswcs (s, t); -# else /* ACE_LACKS_WCSSTR */ - return ::wcsstr (s, t); -# endif /* ACE_LACKS_WCSSTR */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strtok (char *s, const char *tokens) -{ - return ::strtok (s, tokens); -} - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK) -ACE_INLINE wchar_t * -ACE_OS_String::strtok (wchar_t *s, const wchar_t *tokens) -{ -#if defined (ACE_HAS_3_PARAM_WCSTOK) - static wchar_t *lasts; - return ::wcstok (s, tokens, &lasts); -#else - return ::wcstok (s, tokens); -#endif /* ACE_HAS_3_PARAM_WCSTOK */ -} -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOK */ - -ACE_INLINE int -ACE_OS_String::ace_isprint (const ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswprint (c); -#else /* ACE_USES_WCHAR */ - return isprint ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS_String::ace_isspace (const ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswspace (c); -#else /* ACE_USES_WCHAR */ - return isspace ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS_String::to_lower (int c) -{ - return tolower (c); -} - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER) -ACE_INLINE wint_t -ACE_OS_String::to_lower (wint_t c) -{ - return towlower (c); -} -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_TOWLOWER */ - -ACE_INLINE char * -ACE_OS_String::itoa (int value, char *string, int radix) -{ -#if !defined (ACE_HAS_ITOA) - return ACE_OS_String::itoa_emulation (value, string, radix); -#elif defined (ACE_ITOA_EQUIVALENT) - return ACE_ITOA_EQUIVALENT (value, string, radix); -#else /* !ACE_HAS_ITOA */ - return ::itoa (value, string, radix); -#endif /* !ACE_HAS_ITOA */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::itoa (int value, wchar_t *string, int radix) -{ -#if defined (ACE_LACKS_ITOW) - return ACE_OS_String::itow_emulation (value, string, radix); -#else /* ACE_LACKS_ITOW */ - return ::_itow (value, string, radix); -#endif /* ACE_LACKS_ITOW */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS_String::strcasecmp (const char *s, const char *t) -{ -#if defined (ACE_LACKS_STRCASECMP) - return ACE_OS_String::strcasecmp_emulation (s, t); -#elif defined (ACE_STRCASECMP_EQUIVALENT) - return ACE_STRCASECMP_EQUIVALENT (s, t); -#else /* ACE_LACKS_STRCASECMP */ - return ::strcasecmp (s, t); -#endif /* ACE_LACKS_STRCASECMP */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS_String::strcasecmp (const wchar_t *s, const wchar_t *t) -{ -# if defined (ACE_LACKS_WCSICMP) - return ACE_OS_String::wcsicmp_emulation (s, t); -# else /* ACE_LACKS_WCSICMP */ - return ::_wcsicmp (s, t); -# endif /* ACE_LACKS_WCSICMP */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strnchr (char *s, int c, size_t len) -{ -#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ - const char *const_char_s = s; - return ACE_const_cast (char *, - ACE_OS_String::strnchr (const_char_s, c, len)); -#else - return ACE_const_cast (char *, - ACE_OS_String::strnchr (ACE_static_cast (const char *, s), c, len)); -#endif -} - -ACE_INLINE ACE_WCHAR_T * -ACE_OS_String::strnchr (ACE_WCHAR_T *s, ACE_WINT_T c, size_t len) -{ - return ACE_const_cast (ACE_WCHAR_T *, - ACE_OS_String::strnchr (ACE_static_cast (const ACE_WCHAR_T *, s), c, len)); -} - -ACE_INLINE int -ACE_OS_String::strncasecmp (const char *s, const char *t, size_t len) -{ -#if defined (ACE_LACKS_STRCASECMP) - return ACE_OS_String::strncasecmp_emulation (s, t, len); -#elif defined (ACE_STRNCASECMP_EQUIVALENT) - return ACE_STRNCASECMP_EQUIVALENT (s, t, len); -#else /* ACE_LACKS_STRCASECMP */ - return ::strncasecmp (s, t, len); -#endif /* ACE_LACKS_STRCASECMP */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS_String::strncasecmp (const wchar_t *s, const wchar_t *t, size_t len) -{ -#if defined (ACE_LACKS_WCSNICMP) - return ACE_OS_String::wcsnicmp_emulation (s, t, len); -#else /* ACE_LACKS_WCSNICMP */ - return ::_wcsnicmp (s, t, len); -#endif /* ACE_LACKS_WCSNICMP */ -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE char * -ACE_OS_String::strnstr (char *s, const char *t, size_t len) -{ -#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ - const char *const_char_s=s; - return (char *) ACE_OS_String::strnstr (const_char_s, t, len); -#else - return (char *) ACE_OS_String::strnstr ((const char *) s, t, len); -#endif -} - -ACE_INLINE ACE_WCHAR_T * -ACE_OS_String::strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) -{ - return ACE_const_cast (ACE_WCHAR_T *, - ACE_OS_String::strnstr (ACE_static_cast (const ACE_WCHAR_T *, s), t, len)); -} - -ACE_INLINE char * -ACE_OS_String::strtok_r (char *s, const char *tokens, char **lasts) -{ -#if defined (ACE_HAS_REENTRANT_FUNCTIONS) - return ::strtok_r (s, tokens, lasts); -#else - return ACE_OS_String::strtok_r_emulation (s, tokens, lasts); -#endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t* -ACE_OS_String::strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts) -{ -#if defined (ACE_LACKS_WCSTOK) - return ACE_OS_String::strtok_r_emulation (s, tokens, lasts); -#else -# if defined (ACE_HAS_3_PARAM_WCSTOK) - return ::wcstok (s, tokens, lasts); -# else /* ACE_HAS_3_PARAM_WCSTOK */ - *lasts = ::wcstok (s, tokens); - return *lasts; -# endif /* ACE_HAS_3_PARAM_WCSTOK */ -#endif /* ACE_LACKS_WCSTOK */ -} -#endif // ACE_HAS_WCHAR - -#if !defined (ACE_LACKS_STRTOD) -ACE_INLINE double -ACE_OS_String::strtod (const char *s, char **endptr) -{ - return ::strtod (s, endptr); -} -#endif /* !ACE_LACKS_STRTOD */ - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD) -ACE_INLINE double -ACE_OS_String::strtod (const wchar_t *s, wchar_t **endptr) -{ - return ::wcstod (s, endptr); -} -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */ - -ACE_INLINE long -ACE_OS_String::strtol (const char *s, char **ptr, int base) -{ -#if defined (ACE_LACKS_STRTOL) - return ACE_OS_String::strtol_emulation (s, ptr, base); -#else /* ACE_LACKS_STRTOL */ - return ::strtol (s, ptr, base); -#endif /* ACE_LACKS_STRTOL */ -} - -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL) -ACE_INLINE long -ACE_OS_String::strtol (const wchar_t *s, wchar_t **ptr, int base) -{ - return ::wcstol (s, ptr, base); -} -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */ -ACE_INLINE unsigned long -ACE_OS_String::strtoul (const char *s, char **ptr, int base) -{ -#if defined (ACE_LACKS_STRTOUL) - return ACE_OS_String::strtoul_emulation (s, ptr, base); -#else /* ACE_LACKS_STRTOUL */ - return ::strtoul (s, ptr, base); -#endif /* ACE_LACKS_STRTOUL */ -} -#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL) -ACE_INLINE unsigned long -ACE_OS_String::strtoul (const wchar_t *s, wchar_t **ptr, int base) -{ - return ::wcstoul (s, ptr, base); -} -#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */ diff --git a/ace/OS_TLI.h b/ace/OS_TLI.h index 1a83e22f93f..3615805a1bd 100644 --- a/ace/OS_TLI.h +++ b/ace/OS_TLI.h @@ -119,71 +119,71 @@ extern "C" int _xti_error(char *); # endif /* ACE_REDEFINES_XTI_FUNCTIONS */ /** - * @class ACE_OS_TLI + * @namespace ACE_OS_TLI * * @brief This class is a wrapper for the TLI operations * */ -class ACE_OS_Export ACE_OS_TLI +#define ACE_OS_TLI ACE_OS +namespace ACE_OS { -public: // = A set of wrappers for TLI. - static int t_accept (ACE_HANDLE fildes, + int t_accept (ACE_HANDLE fildes, ACE_HANDLE resfd, struct t_call *call); - static char *t_alloc (ACE_HANDLE fildes, + char *t_alloc (ACE_HANDLE fildes, int struct_type, int fields); - static int t_bind (ACE_HANDLE fildes, + int t_bind (ACE_HANDLE fildes, struct t_bind *req, struct t_bind *ret); - static int t_close (ACE_HANDLE fildes); - static int t_connect (ACE_HANDLE fildes, + int t_close (ACE_HANDLE fildes); + int t_connect (ACE_HANDLE fildes, struct t_call *sndcall, struct t_call *rcvcall); - static void t_error (const char *errmsg); - static int t_free (char *ptr, + void t_error (const char *errmsg); + int t_free (char *ptr, int struct_type); - static int t_getinfo (ACE_HANDLE fildes, + int t_getinfo (ACE_HANDLE fildes, struct t_info *info); - static int t_getname (ACE_HANDLE fildes, + int t_getname (ACE_HANDLE fildes, struct netbuf *namep, int type); - static int t_getstate (ACE_HANDLE fildes); - static int t_listen (ACE_HANDLE fildes, - struct t_call *call); - static int t_look (ACE_HANDLE fildes); - static ACE_HANDLE t_open (char *path, + int t_getstate (ACE_HANDLE fildes); + int t_listen (ACE_HANDLE fildes, + struct t_call *call); + int t_look (ACE_HANDLE fildes); + ACE_HANDLE t_open (char *path, int oflag, struct t_info *info); - static int t_optmgmt (ACE_HANDLE fildes, + int t_optmgmt (ACE_HANDLE fildes, struct t_optmgmt *req, struct t_optmgmt *ret); - static int t_rcv (ACE_HANDLE fildes, + int t_rcv (ACE_HANDLE fildes, char *buf, unsigned int nbytes, int *flags); - static int t_rcvdis (ACE_HANDLE fildes, + int t_rcvdis (ACE_HANDLE fildes, struct t_discon *discon); - static int t_rcvrel (ACE_HANDLE fildes); - static int t_rcvudata (ACE_HANDLE fildes, + int t_rcvrel (ACE_HANDLE fildes); + int t_rcvudata (ACE_HANDLE fildes, struct t_unitdata *unitdata, int *flags); - static int t_rcvuderr (ACE_HANDLE fildes, + int t_rcvuderr (ACE_HANDLE fildes, struct t_uderr *uderr); - static int t_snd (ACE_HANDLE fildes, + int t_snd (ACE_HANDLE fildes, const char *buf, unsigned int nbytes, int flags); - static int t_snddis (ACE_HANDLE fildes, + int t_snddis (ACE_HANDLE fildes, struct t_call *call); - static int t_sndrel (ACE_HANDLE fildes); - static int t_sync (ACE_HANDLE fildes); - static int t_unbind (ACE_HANDLE fildes); -}; + int t_sndrel (ACE_HANDLE fildes); + int t_sync (ACE_HANDLE fildes); + int t_unbind (ACE_HANDLE fildes); +}; /* namespace ACE_OS */ # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) diff --git a/ace/OS_TLI.inl b/ace/OS_TLI.inl index c4dc02d5346..4b8ff91bbde 100644 --- a/ace/OS_TLI.inl +++ b/ace/OS_TLI.inl @@ -2,9 +2,9 @@ // $Id$ ACE_INLINE int -ACE_OS_TLI::t_accept (ACE_HANDLE handle, - ACE_HANDLE reshandle, - struct t_call *call) +ACE_OS::t_accept (ACE_HANDLE handle, + ACE_HANDLE reshandle, + struct t_call *call) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_accept (handle, reshandle, call), int, -1); @@ -18,8 +18,8 @@ ACE_OS_TLI::t_accept (ACE_HANDLE handle, } ACE_INLINE char * -ACE_OS_TLI::t_alloc (ACE_HANDLE handle, int struct_type, - int fields) +ACE_OS::t_alloc (ACE_HANDLE handle, int struct_type, + int fields) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_alloc (handle, struct_type, fields), @@ -34,8 +34,8 @@ ACE_OS_TLI::t_alloc (ACE_HANDLE handle, int struct_type, } ACE_INLINE int -ACE_OS_TLI::t_bind (ACE_HANDLE handle, struct t_bind *req, - struct t_bind *ret) +ACE_OS::t_bind (ACE_HANDLE handle, struct t_bind *req, + struct t_bind *ret) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_bind (handle, req, ret), int, -1); @@ -49,7 +49,7 @@ ACE_OS_TLI::t_bind (ACE_HANDLE handle, struct t_bind *req, } ACE_INLINE int -ACE_OS_TLI::t_close (ACE_HANDLE handle) +ACE_OS::t_close (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_close (handle), int, -1); @@ -61,9 +61,9 @@ ACE_OS_TLI::t_close (ACE_HANDLE handle) } ACE_INLINE int -ACE_OS_TLI::t_connect(ACE_HANDLE fildes, - struct t_call *sndcall, - struct t_call *rcvcall) +ACE_OS::t_connect(ACE_HANDLE fildes, + struct t_call *sndcall, + struct t_call *rcvcall) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_connect (fildes, sndcall, rcvcall), int, -1); @@ -77,7 +77,7 @@ ACE_OS_TLI::t_connect(ACE_HANDLE fildes, } ACE_INLINE void -ACE_OS_TLI::t_error (const char *errmsg) +ACE_OS::t_error (const char *errmsg) { #if defined (ACE_HAS_TLI) #if defined (ACE_HAS_BROKEN_T_ERROR) @@ -91,7 +91,7 @@ ACE_OS_TLI::t_error (const char *errmsg) } ACE_INLINE int -ACE_OS_TLI::t_free (char *ptr, int struct_type) +ACE_OS::t_free (char *ptr, int struct_type) { #if defined (ACE_HAS_TLI) if (ptr == 0) @@ -106,7 +106,7 @@ ACE_OS_TLI::t_free (char *ptr, int struct_type) } ACE_INLINE int -ACE_OS_TLI::t_getinfo (ACE_HANDLE handle, struct t_info *info) +ACE_OS::t_getinfo (ACE_HANDLE handle, struct t_info *info) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_getinfo (handle, info), int, -1); @@ -119,9 +119,9 @@ ACE_OS_TLI::t_getinfo (ACE_HANDLE handle, struct t_info *info) } ACE_INLINE int -ACE_OS_TLI::t_getname (ACE_HANDLE handle, - struct netbuf *namep, - int type) +ACE_OS::t_getname (ACE_HANDLE handle, + struct netbuf *namep, + int type) { #if defined (ACE_HAS_SVR4_TLI) ACE_OSCALL_RETURN (::t_getname (handle, namep, type), int, -1); @@ -135,7 +135,7 @@ ACE_OS_TLI::t_getname (ACE_HANDLE handle, } ACE_INLINE int -ACE_OS_TLI::t_getstate (ACE_HANDLE handle) +ACE_OS::t_getstate (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_getstate (handle), int, -1); @@ -147,7 +147,7 @@ ACE_OS_TLI::t_getstate (ACE_HANDLE handle) } ACE_INLINE int -ACE_OS_TLI::t_listen (ACE_HANDLE handle, struct t_call *call) +ACE_OS::t_listen (ACE_HANDLE handle, struct t_call *call) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_listen (handle, call), int, -1); @@ -160,7 +160,7 @@ ACE_OS_TLI::t_listen (ACE_HANDLE handle, struct t_call *call) } ACE_INLINE int -ACE_OS_TLI::t_look (ACE_HANDLE handle) +ACE_OS::t_look (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_look (handle), int, -1); @@ -172,7 +172,7 @@ ACE_OS_TLI::t_look (ACE_HANDLE handle) } ACE_INLINE ACE_HANDLE -ACE_OS_TLI::t_open (char *path, int oflag, struct t_info *info) +ACE_OS::t_open (char *path, int oflag, struct t_info *info) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_open (path, oflag, info), ACE_HANDLE, ACE_INVALID_HANDLE); @@ -186,9 +186,9 @@ ACE_OS_TLI::t_open (char *path, int oflag, struct t_info *info) } ACE_INLINE int -ACE_OS_TLI::t_optmgmt (ACE_HANDLE handle, - struct t_optmgmt *req, - struct t_optmgmt *ret) +ACE_OS::t_optmgmt (ACE_HANDLE handle, + struct t_optmgmt *req, + struct t_optmgmt *ret) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_optmgmt (handle, req, ret), int, -1); @@ -202,10 +202,10 @@ ACE_OS_TLI::t_optmgmt (ACE_HANDLE handle, } ACE_INLINE int -ACE_OS_TLI::t_rcv (ACE_HANDLE handle, - char *buf, - unsigned int nbytes, - int *flags) +ACE_OS::t_rcv (ACE_HANDLE handle, + char *buf, + unsigned int nbytes, + int *flags) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcv (handle, buf, nbytes, flags), @@ -221,7 +221,7 @@ ACE_OS_TLI::t_rcv (ACE_HANDLE handle, } ACE_INLINE int -ACE_OS_TLI::t_rcvdis (ACE_HANDLE handle, struct t_discon *discon) +ACE_OS::t_rcvdis (ACE_HANDLE handle, struct t_discon *discon) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvdis (handle, discon), int, -1); @@ -234,7 +234,7 @@ ACE_OS_TLI::t_rcvdis (ACE_HANDLE handle, struct t_discon *discon) } ACE_INLINE int -ACE_OS_TLI::t_rcvrel (ACE_HANDLE handle) +ACE_OS::t_rcvrel (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvrel (handle), int, -1); @@ -246,9 +246,9 @@ ACE_OS_TLI::t_rcvrel (ACE_HANDLE handle) } ACE_INLINE int -ACE_OS_TLI::t_rcvudata (ACE_HANDLE handle, - struct t_unitdata *unitdata, - int *flags) +ACE_OS::t_rcvudata (ACE_HANDLE handle, + struct t_unitdata *unitdata, + int *flags) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvudata (handle, unitdata, flags), @@ -263,7 +263,7 @@ ACE_OS_TLI::t_rcvudata (ACE_HANDLE handle, } ACE_INLINE int -ACE_OS_TLI::t_rcvuderr (ACE_HANDLE handle, struct t_uderr *uderr) +ACE_OS::t_rcvuderr (ACE_HANDLE handle, struct t_uderr *uderr) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvuderr (handle, uderr), int, -1); @@ -276,10 +276,10 @@ ACE_OS_TLI::t_rcvuderr (ACE_HANDLE handle, struct t_uderr *uderr) } ACE_INLINE int -ACE_OS_TLI::t_snd (ACE_HANDLE handle, - const char *buf, - unsigned int nbytes, - int flags) +ACE_OS::t_snd (ACE_HANDLE handle, + const char *buf, + unsigned int nbytes, + int flags) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_snd (handle, (char *) buf, nbytes, flags), int, -1); @@ -294,7 +294,7 @@ ACE_OS_TLI::t_snd (ACE_HANDLE handle, } ACE_INLINE int -ACE_OS_TLI::t_snddis (ACE_HANDLE handle, struct t_call *call) +ACE_OS::t_snddis (ACE_HANDLE handle, struct t_call *call) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_snddis (handle, call), int, -1); @@ -307,7 +307,7 @@ ACE_OS_TLI::t_snddis (ACE_HANDLE handle, struct t_call *call) } ACE_INLINE int -ACE_OS_TLI::t_sndrel (ACE_HANDLE handle) +ACE_OS::t_sndrel (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_sndrel (handle), int, -1); @@ -319,7 +319,7 @@ ACE_OS_TLI::t_sndrel (ACE_HANDLE handle) } ACE_INLINE int -ACE_OS_TLI::t_sync (ACE_HANDLE handle) +ACE_OS::t_sync (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_sync (handle), int, -1); @@ -331,7 +331,7 @@ ACE_OS_TLI::t_sync (ACE_HANDLE handle) } ACE_INLINE int -ACE_OS_TLI::t_unbind (ACE_HANDLE handle) +ACE_OS::t_unbind (ACE_HANDLE handle) { #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_unbind (handle), int, -1); diff --git a/ace/OS_Thread_Adapter.cpp b/ace/OS_Thread_Adapter.cpp index 0e59ad0926b..745facaf9a9 100644 --- a/ace/OS_Thread_Adapter.cpp +++ b/ace/OS_Thread_Adapter.cpp @@ -1,8 +1,6 @@ // $Id$ #include "ace/OS_Thread_Adapter.h" -#include "ace/Thread_Hook.h" -#include "ace/OS.h" ACE_RCSID (ace, OS_Thread_Adapter, @@ -12,6 +10,11 @@ ACE_RCSID (ace, # include "ace/OS_Thread_Adapter.inl" #endif /* ACE_HAS_INLINED_OS_CALLS */ +#include "ace/Thread_Hook.h" +#include "ace/Object_Manager_Base.h" +#include "ace/Global_Macros.h" +#include "ace/OS_NS_Thread.h" + ACE_OS_Thread_Adapter::ACE_OS_Thread_Adapter ( ACE_THR_FUNC user_func , void *arg diff --git a/ace/OS_main.h b/ace/OS_main.h index fc532b41367..175378dcba8 100644 --- a/ace/OS_main.h +++ b/ace/OS_main.h @@ -1,4 +1,203 @@ // -*- C++ -*- -// $Id$ -// This is a placeholder. +//============================================================================= +/** + * @file OS_NS_main.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_MAIN_H +# define ACE_OS_MAIN_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) + +# if defined (ACE_TMAIN) // Use WinMain on CE; others give warning/error. +# undef ACE_TMAIN +# endif // ACE_TMAIN + +// CE only gets a command line string; no argv. So we need to convert it +// when the main entrypoint expects argc/argv. ACE_ARGV supports this. +# include "ace/ARGV.h" + +// Support for ACE_TMAIN, which is a recommended way. It would be nice if +// CE had CommandLineToArgvW()... but it's only on NT3.5 and up. + +# define ACE_TMAIN \ +ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ +{ \ + ACE_TCHAR cmdline[1024]; \ + ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ + ACE_OS::strcat (cmdline, lpCmdLine); \ + ACE_ARGV ce_argv (cmdline); \ + 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_TCHAR cmdline[1024]; \ + ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ + ACE_OS::strcat (cmdline, lpCmdLine); \ + ACE_ARGV ce_argv (cmdline); \ + 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. Unfortunately, evc 3 can't grok a #include within the macro +// expansion, so it needs to go out here. +# include "ace/Argv_Type_Converter.h" +# define main \ +ace_main_i (int, char *[]); /* forward declaration */ \ +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ +{ \ + ACE_TCHAR cmdline[1024]; \ + ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ + ACE_OS::strcat (cmdline, lpCmdLine); \ + ACE_ARGV ce_argv (cmdline); \ + 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_OS_MAIN_H */ diff --git a/ace/Object_Manager.h b/ace/Object_Manager.h index 2101ca83c83..0e3b75aade7 100644 --- a/ace/Object_Manager.h +++ b/ace/Object_Manager.h @@ -16,7 +16,8 @@ #define ACE_OBJECT_MANAGER_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/ACE_export.h" +#include "ace/Object_Manager_Base.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -35,16 +36,20 @@ class ACE_Sig_Set; // This is included because Svc_conf_l.cpp needs it and I don't want to // have to change it right now. :-( - // The worst thing about this, is that it still includes OS.h, but since we - // have to include it above anyway, it doesn't make a difference right now. // dhinton. #include "ace/Recursive_Thread_Mutex.h" #endif /* ACE_MT_SAFE */ +// only used by ACE_OS_Object_Manager::ctor +# if defined (ACE_WIN32) +// Default WIN32 structured exception handler. +int ACE_SEH_Default_Exception_Selector (void *); +int ACE_SEH_Default_Exception_Handler (void *); +# endif /* ACE_WIN32 */ + class ACE_Cleanup_Info_Node; template <class T> class ACE_Cleanup_Adapter; - // Configuration parameters. #if !defined (ACE_MAX_MANAGED_OBJECTS) # define ACE_MAX_MANAGED_OBJECTS 128 @@ -58,7 +63,6 @@ template <class T> class ACE_Cleanup_Adapter; # define ACE_APPLICATION_PREALLOCATED_ARRAY_DECLARATIONS #endif /* ! ACE_APPLICATION_PREALLOCATED_ARRAY_DECLARATIONS */ - /** * @class ACE_Object_Manager * diff --git a/ace/Object_Manager_Base.cpp b/ace/Object_Manager_Base.cpp index fc532b41367..c0209773c1f 100644 --- a/ace/Object_Manager_Base.cpp +++ b/ace/Object_Manager_Base.cpp @@ -1,4 +1,506 @@ // -*- C++ -*- // $Id$ -// This is a placeholder. +#include "ace/Object_Manager_Base.h" + +ACE_RCSID(ace, OS_NS_sys_time, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Object_Manager_Base.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +#include "ace/OS_Memory.h" +#include "ace/OS_NS_Thread.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_signal.h" + +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +int ACE_SEH_Default_Exception_Selector (void *) +{ +#if 0 + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%t) Win32 structured exception exiting thread\n"))); +#endif /* 0 */ + // this is only windows and only used here, + // defined in ace/config-win32-common.h. + return (DWORD) ACE_SEH_DEFAULT_EXCEPTION_HANDLING_ACTION; +} + +int ACE_SEH_Default_Exception_Handler (void *) +{ + return 0; +} +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + +# 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, + 0, + ::GetLastError (), + MAKELANGID (LANG_NEUTRAL, + SUBLANG_DEFAULT), + // Default language + (ACE_TCHAR *) &lpMsgBuf, + 0, + 0); + ::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 + * + * @brief Ensure that the <ACE_OS_Object_Manager> gets initialized at + * program startup, and destroyed at program termination. + * + * 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. + */ +class ACE_OS_Object_Manager_Manager +{ +public: + /// Constructor. + ACE_OS_Object_Manager_Manager (void); + + /// Destructor. + ~ACE_OS_Object_Manager_Manager (void); + +private: + /// Save the main thread ID, so that destruction can be suppressed. + ACE_thread_t saved_main_thread_id_; +}; + +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 index fc532b41367..6c4ff9eb83a 100644 --- a/ace/Object_Manager_Base.h +++ b/ace/Object_Manager_Base.h @@ -1,4 +1,283 @@ -// -*- C++ -*- -// $Id$ +/* -*- C++ -*- */ -// This is a placeholder. +//============================================================================= +/** + * @file Object_Manager_Base.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller<stophph@diku.dk> + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#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_Export.h" +#include "ace/Cleanup.h" +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_signal.h" +//#include "ace/OS_NS_netdb.h" +//#include "ace/OS_NS_unistd.h" +//#include "ace/OS_NS_time.h" +//#include "ace/OS_NS_stdlib.h" +namespace ACE_OS { +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) +int netdb_acquire (void); +int netdb_release (void); +# endif /* defined (ACE_MT_SAFE) && ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ +ssize_t pread(ACE_HANDLE, void*, size_t, off_t); +ssize_t pwrite(ACE_HANDLE, const void*, size_t, off_t); +time_t mktime(tm*); +int atexit(void (*)()); +} +class ACE_Object_Manager; +class ACE_OS_Object_Manager_Manager; +class ACE_TSS_Cleanup; +class ACE_TSS_Emulation; +class ACE_Log_Msg; +//void ACE_OS_Object_Manager_Internal_Exit_Hook (); + +class ACE_Thread_Hook; + +/** + * @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 &); +}; + +extern "C" +void +ACE_OS_Object_Manager_Internal_Exit_Hook (void); + + +// @@ This forward declaration should go away. +class ACE_Log_Msg; + +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); + + /// Accessor to singleton instance. + static ACE_OS_Object_Manager *instance (void); + + /// For <ACE_OS::atexit> support. + int at_exit (ACE_EXIT_HOOK func); + +//private: + /// 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 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. +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) + friend int ACE_OS::netdb_acquire (void); + friend int ACE_OS::netdb_release (void); +# endif /* defined (ACE_MT_SAFE) && ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ + friend ssize_t ACE_OS::pread(ACE_HANDLE, void*, size_t, off_t); + friend ssize_t ACE_OS::pwrite(ACE_HANDLE, const void*, size_t, off_t); + friend time_t ACE_OS::mktime(tm*); + friend int ACE_OS::atexit(void (*)()); + 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 (); +}; + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/Object_Manager_Base.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +#include /**/ "ace/post.h" +#endif /* ACE_OBJECT_MANAGER_BASE_H */ diff --git a/ace/Object_Manager_Base.inl b/ace/Object_Manager_Base.inl index fc532b41367..c130d6682b1 100644 --- a/ace/Object_Manager_Base.inl +++ b/ace/Object_Manager_Base.inl @@ -1,4 +1,2 @@ // -*- C++ -*- // $Id$ - -// This is a placeholder. diff --git a/ace/PI_Malloc.cpp b/ace/PI_Malloc.cpp index 2c8b503cd99..46c3767c73e 100644 --- a/ace/PI_Malloc.cpp +++ b/ace/PI_Malloc.cpp @@ -9,14 +9,14 @@ ACE_RCSID (ace, #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) -#include "ace/Object_Manager.h" -#include "ace/Process_Mutex.h" - #if !defined (__ACE_INLINE__) #include "ace/PI_Malloc.i" #endif /* __ACE_INLINE__ */ +#include "ace/Object_Manager.h" +#include "ace/Process_Mutex.h" #include "ace/Synch_T.h" +#include "ace/OS_NS_string.h" void ACE_PI_Control_Block::ACE_Malloc_Header::dump (void) const diff --git a/ace/POSIX_Asynch_IO.cpp b/ace/POSIX_Asynch_IO.cpp index d1d153e5baa..af4bd925c68 100644 --- a/ace/POSIX_Asynch_IO.cpp +++ b/ace/POSIX_Asynch_IO.cpp @@ -2,16 +2,16 @@ #if defined (ACE_HAS_AIO_CALLS) +#if !defined (__ACE_INLINE__) +#include "ace/POSIX_Asynch_IO.i" +#endif /* __ACE_INLINE__ */ + #include "ace/Proactor.h" #include "ace/Message_Block.h" #include "ace/INET_Addr.h" #include "ace/Asynch_Pseudo_Task.h" #include "ace/POSIX_Proactor.h" - -#if !defined (__ACE_INLINE__) -#include "ace/POSIX_Asynch_IO.i" -#endif /* __ACE_INLINE__ */ - +#include "ace/OS_NS_sys_socket.h" ACE_RCSID (ace, POSIX_Asynch_IO, diff --git a/ace/POSIX_Asynch_IO.h b/ace/POSIX_Asynch_IO.h index 1ea2bb6e48b..aa985cdbacd 100644 --- a/ace/POSIX_Asynch_IO.h +++ b/ace/POSIX_Asynch_IO.h @@ -28,7 +28,7 @@ #if defined (ACE_HAS_AIO_CALLS) -#include "ace/OS.h" +#include "ace/os_include/os_aio.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Unbounded_Queue.h" diff --git a/ace/POSIX_Proactor.cpp b/ace/POSIX_Proactor.cpp index b28b38a0430..f577cf5b716 100644 --- a/ace/POSIX_Proactor.cpp +++ b/ace/POSIX_Proactor.cpp @@ -5,11 +5,6 @@ #if defined (ACE_HAS_AIO_CALLS) -#include "ace/ACE.h" -#include "ace/Task_T.h" -#include "ace/Log_Msg.h" -#include "ace/Object_Manager.h" - #if !defined (__ACE_INLINE__) #include "ace/POSIX_Proactor.i" #endif /* __ACE_INLINE__ */ @@ -18,6 +13,17 @@ # include /**/ <sys/systeminfo.h> # endif /* ACE_HAS_SYS_INFO */ +#include "ace/ACE.h" +#include "ace/Task_T.h" +#include "ace/Log_Msg.h" +#include "ace/Object_Manager.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_signal.h" + +#if defined (sun) +# include "ace/OS_NS_strings.h" +#endif /* sun */ + // ********************************************************************* /** * @class ACE_POSIX_Wakeup_Completion @@ -61,11 +67,11 @@ ACE_POSIX_Proactor::ACE_POSIX_Proactor (void) ACE_OS::sysinfo (SI_RELEASE , Buf, sizeof(Buf)-1); - if (ACE_OS_String::strcasecmp (Buf , "5.6") == 0) + if (ACE_OS::strcasecmp (Buf , "5.6") == 0) os_id_ = OS_SUN_56; - else if (ACE_OS_String::strcasecmp (Buf , "5.7") == 0) + else if (ACE_OS::strcasecmp (Buf , "5.7") == 0) os_id_ = OS_SUN_57; - else if (ACE_OS_String::strcasecmp (Buf , "5.8") == 0) + else if (ACE_OS::strcasecmp (Buf , "5.8") == 0) os_id_ = OS_SUN_58; #elif defined(HPUX) diff --git a/ace/Pipe.h b/ace/Pipe.h index f8f11d47063..2a466db1a8b 100644 --- a/ace/Pipe.h +++ b/ace/Pipe.h @@ -22,7 +22,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/Default_Constants.h" /** * @class ACE_Pipe diff --git a/ace/Pipe.i b/ace/Pipe.i index 0eb87370827..35074670827 100644 --- a/ace/Pipe.i +++ b/ace/Pipe.i @@ -3,6 +3,8 @@ // Pipe.i +#include "ace/Global_Macros.h" + ASYS_INLINE ACE_Pipe::~ACE_Pipe (void) { diff --git a/ace/Proactor.h b/ace/Proactor.h index 72db9ff4e9f..f4dff770e54 100644 --- a/ace/Proactor.h +++ b/ace/Proactor.h @@ -20,7 +20,6 @@ #include "ace/config-all.h" #include "ace/ACE_export.h" -#include "ace/OS.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once diff --git a/ace/Proactor_Impl.h b/ace/Proactor_Impl.h index 39d90f9e945..ae41266d180 100644 --- a/ace/Proactor_Impl.h +++ b/ace/Proactor_Impl.h @@ -21,7 +21,6 @@ #if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS))) // This only works on Win32 platforms and on Unix platforms supporting // aio calls. -#include "ace/OS.h" #include "ace/Asynch_IO.h" #include "ace/Reactor.h" diff --git a/ace/Process.cpp b/ace/Process.cpp index 99761069c48..3aeeda30207 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -1,16 +1,19 @@ // $Id$ -#include "ace/OS.h" #include "ace/Process.h" -#include "ace/ARGV.h" -#include "ace/Signal.h" -#include "ace/SString.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) #include "ace/Process.i" #endif /* __ACE_INLINE__ */ +#include "ace/ARGV.h" +#include "ace/Signal.h" +#include "ace/SString.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_errno.h" + ACE_RCSID (ace, Process, "$Id$") @@ -578,7 +581,7 @@ ACE_Process_Options::setenv (ACE_TCHAR *envp[]) while (envp[i]) { if (this->setenv_i (envp[i], - ACE_OS_String::strlen (envp[i])) == -1) + ACE_OS::strlen (envp[i])) == -1) return -1; i++; } @@ -609,7 +612,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *format, ...) // Append the string to are environment buffer. if (this->setenv_i (stack_buf, - ACE_OS_String::strlen (stack_buf)) == -1) + ACE_OS::strlen (stack_buf)) == -1) return -1; #if defined (ACE_WIN32) @@ -646,7 +649,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name, // Append the string to our environment buffer. if (this->setenv_i (stack_buf, - ACE_OS_String::strlen (stack_buf)) == -1) + ACE_OS::strlen (stack_buf)) == -1) return -1; #if defined (ACE_WIN32) diff --git a/ace/Process.i b/ace/Process.i index db86fe4f4d2..ad887d0f048 100644 --- a/ace/Process.i +++ b/ace/Process.i @@ -2,6 +2,9 @@ // $Id$ #include "ace/ACE.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_pwd.h" #if defined (ACE_WIN32) diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index 6a3cba11800..86de468f43b 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -1,17 +1,20 @@ // $Id$ // Process_Manager.cpp -#include "ace/ACE.h" -#include "ace/Process.h" -#include "ace/Signal.h" #include "ace/Process_Manager.h" -#include "ace/Object_Manager.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) #include "ace/Process_Manager.i" #endif /* __ACE_INLINE__ */ +#include "ace/ACE.h" +#include "ace/Process.h" +#include "ace/Signal.h" +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/OS_NS_signal.h" + ACE_RCSID(ace, Process_Manager, "$Id$") #if defined (ACE_HAS_SIG_C_FUNC) diff --git a/ace/Profile_Timer.cpp b/ace/Profile_Timer.cpp index 4beedd397f0..ca72b14d6d3 100644 --- a/ace/Profile_Timer.cpp +++ b/ace/Profile_Timer.cpp @@ -1,12 +1,14 @@ // $Id$ #include "ace/Profile_Timer.h" -#include "ace/Log_Msg.h" #if !defined (__ACE_INLINE__) # include "ace/Profile_Timer.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + ACE_RCSID(ace, Profile_Timer, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Profile_Timer) diff --git a/ace/Profile_Timer.h b/ace/Profile_Timer.h index a8000401e84..3f96b41a581 100644 --- a/ace/Profile_Timer.h +++ b/ace/Profile_Timer.h @@ -21,7 +21,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" #include "ace/High_Res_Timer.h" /** diff --git a/ace/Profile_Timer.i b/ace/Profile_Timer.i index e77af9b1686..b4070d3250c 100644 --- a/ace/Profile_Timer.i +++ b/ace/Profile_Timer.i @@ -1,6 +1,10 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_sys_resource.h" +#include "ace/Global_Macros.h" + #if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32) # if defined (ACE_HAS_PRUSAGE_T) diff --git a/ace/RMCast/RMCast.h b/ace/RMCast/RMCast.h index 2259af24fbb..9d9d7650e54 100644 --- a/ace/RMCast/RMCast.h +++ b/ace/RMCast/RMCast.h @@ -18,13 +18,14 @@ #define ACE_RMCAST_H #include /**/ "ace/pre.h" -#include "ace/OS.h" #include "RMCast_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Basic_Types.h" + class ACE_Message_Block; class ACE_RMCast_Proxy; diff --git a/ace/RMCast/RMCast_Copy_On_Write.h b/ace/RMCast/RMCast_Copy_On_Write.h index 4421ca92b83..c73dade591b 100644 --- a/ace/RMCast/RMCast_Copy_On_Write.h +++ b/ace/RMCast/RMCast_Copy_On_Write.h @@ -6,7 +6,9 @@ #include /**/ "ace/pre.h" #include "RMCast_Worker.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Basic_Types.h" +#include "ace/Condition_Thread_Mutex.h" //! A wrapper to implement reference counted collections template<class COLLECTION, class ITERATOR> diff --git a/ace/RMCast/RMCast_Copy_On_Write.i b/ace/RMCast/RMCast_Copy_On_Write.i index 3c069c84eb6..c83483c0729 100644 --- a/ace/RMCast/RMCast_Copy_On_Write.i +++ b/ace/RMCast/RMCast_Copy_On_Write.i @@ -1,5 +1,9 @@ +// -*- C++ -*- // $Id$ +#include "ace/Guard_T.h" +#include "ace/Null_Mutex.h" + template<class COLLECTION, class ITERATOR> ACE_INLINE ACE_RMCast_Copy_On_Write_Collection<COLLECTION,ITERATOR>:: ACE_RMCast_Copy_On_Write_Collection (void) diff --git a/ace/RMCast/RMCast_IO_UDP.cpp b/ace/RMCast/RMCast_IO_UDP.cpp index cfed8a53d98..13801b47bd5 100644 --- a/ace/RMCast/RMCast_IO_UDP.cpp +++ b/ace/RMCast/RMCast_IO_UDP.cpp @@ -1,16 +1,21 @@ // $Id$ #include "RMCast_IO_UDP.h" + +#if !defined (__ACE_INLINE__) +# include "RMCast_IO_UDP.i" +#endif /* ! __ACE_INLINE__ */ + #include "RMCast_UDP_Proxy.h" #include "RMCast_Module_Factory.h" #include "ace/Handle_Set.h" #include "ace/Reactor.h" #include "ace/Message_Block.h" - -#if !defined (__ACE_INLINE__) -# include "RMCast_IO_UDP.i" -#endif /* ! __ACE_INLINE__ */ +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/os_include/arpa/os_inet.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(ace, RMCast_IO_UDP, "RMCast_IO_UDP.cpp,v 1.12 2000/12/20 22:00:33 oci Exp") diff --git a/ace/RMCast/RMCast_IO_UDP.h b/ace/RMCast/RMCast_IO_UDP.h index 4881233cb59..9e1a83dc032 100644 --- a/ace/RMCast/RMCast_IO_UDP.h +++ b/ace/RMCast/RMCast_IO_UDP.h @@ -19,6 +19,7 @@ #include "ace/Hash_Map_Manager.h" #include "ace/Synch.h" #include "ace/INET_Addr.h" +#include "ace/Null_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/RMCast/RMCast_Membership.cpp b/ace/RMCast/RMCast_Membership.cpp index 91c9b1a9cea..598e05019af 100644 --- a/ace/RMCast/RMCast_Membership.cpp +++ b/ace/RMCast/RMCast_Membership.cpp @@ -3,12 +3,14 @@ // #include "RMCast_Membership.h" -#include "RMCast_Proxy.h" #if !defined (__ACE_INLINE__) # include "RMCast_Membership.i" #endif /* ! __ACE_INLINE__ */ +#include "RMCast_Proxy.h" +#include "ace/Guard_T.h" + ACE_RCSID(ace, RMCast_Membership, "$Id$") ACE_RMCast_Membership::~ACE_RMCast_Membership (void) diff --git a/ace/RMCast/RMCast_Membership.h b/ace/RMCast/RMCast_Membership.h index beab2c881f9..14d5790e584 100644 --- a/ace/RMCast/RMCast_Membership.h +++ b/ace/RMCast/RMCast_Membership.h @@ -20,7 +20,8 @@ #include "RMCast_Module.h" #include "ace/Containers.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/RMCast/RMCast_Reassembly.h b/ace/RMCast/RMCast_Reassembly.h index bc3fc17049d..d4ed999cf78 100644 --- a/ace/RMCast/RMCast_Reassembly.h +++ b/ace/RMCast/RMCast_Reassembly.h @@ -16,7 +16,9 @@ #include "RMCast_Module.h" #include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" +#include "ace/Null_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/RMCast/RMCast_Reordering.h b/ace/RMCast/RMCast_Reordering.h index 4ecf824acac..dadca2aa0f6 100644 --- a/ace/RMCast/RMCast_Reordering.h +++ b/ace/RMCast/RMCast_Reordering.h @@ -17,7 +17,9 @@ #include "RMCast_Module.h" #include "ace/RB_Tree.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" +#include "ace/Null_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/RMCast/RMCast_Sequencer.cpp b/ace/RMCast/RMCast_Sequencer.cpp index f8bc0e6c57d..356fbb4a01b 100644 --- a/ace/RMCast/RMCast_Sequencer.cpp +++ b/ace/RMCast/RMCast_Sequencer.cpp @@ -8,6 +8,8 @@ # include "RMCast_Sequencer.i" #endif /* ! __ACE_INLINE__ */ +#include "ace/Guard_T.h" + ACE_RCSID(ace, RMCast_Sequencer, "$Id$") ACE_RMCast_Sequencer::~ACE_RMCast_Sequencer (void) diff --git a/ace/RMCast/RMCast_Sequencer.h b/ace/RMCast/RMCast_Sequencer.h index 8e6447dce62..28f83a1d4b3 100644 --- a/ace/RMCast/RMCast_Sequencer.h +++ b/ace/RMCast/RMCast_Sequencer.h @@ -16,7 +16,8 @@ #include /**/ "ace/pre.h" #include "RMCast_Module.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/RMCast/RMCast_UDP_Proxy.cpp b/ace/RMCast/RMCast_UDP_Proxy.cpp index c84b8c0f2ef..fb7eaf72f76 100644 --- a/ace/RMCast/RMCast_UDP_Proxy.cpp +++ b/ace/RMCast/RMCast_UDP_Proxy.cpp @@ -1,14 +1,17 @@ // $Id$ #include "RMCast_UDP_Proxy.h" -#include "RMCast_Module.h" -#include "RMCast_IO_UDP.h" -#include "ace/Message_Block.h" #if !defined (__ACE_INLINE__) # include "RMCast_UDP_Proxy.i" #endif /* ! __ACE_INLINE__ */ +#include "RMCast_Module.h" +#include "RMCast_IO_UDP.h" +#include "ace/Message_Block.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/arpa/os_inet.h" + ACE_RCSID(ace, RMCast_UDP_Proxy, "$Id$") ACE_RMCast_UDP_Proxy::ACE_RMCast_UDP_Proxy (ACE_RMCast_IO_UDP *io_udp, diff --git a/ace/RW_Mutex.cpp b/ace/RW_Mutex.cpp index 9da0d1199c0..cde11394329 100644 --- a/ace/RW_Mutex.cpp +++ b/ace/RW_Mutex.cpp @@ -17,6 +17,8 @@ #include "ace/RW_Mutex.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" + ACE_RCSID(ace, RW_Mutex, "$Id$") void diff --git a/ace/RW_Mutex.h b/ace/RW_Mutex.h index 41ed4e91fcb..5129f31e253 100644 --- a/ace/RW_Mutex.h +++ b/ace/RW_Mutex.h @@ -25,7 +25,7 @@ // ACE platform supports some form of threading. #if defined (ACE_HAS_THREADS) -#include "ace/OS.h" +#include "ace/OS_NS_Thread.h" /** * @class ACE_RW_Mutex diff --git a/ace/RW_Process_Mutex.h b/ace/RW_Process_Mutex.h index 8cfc164ac44..ad97920779b 100644 --- a/ace/RW_Process_Mutex.h +++ b/ace/RW_Process_Mutex.h @@ -20,6 +20,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Default_Constants.h" + /** * @class ACE_RW_Process_Mutex * diff --git a/ace/Reactor_Timer_Interface.h b/ace/Reactor_Timer_Interface.h index 484b1fb55c5..e015a4d314a 100644 --- a/ace/Reactor_Timer_Interface.h +++ b/ace/Reactor_Timer_Interface.h @@ -18,6 +18,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Time_Value.h" + class ACE_Event_Handler; /** diff --git a/ace/Read_Buffer.cpp b/ace/Read_Buffer.cpp index 34b38e54634..f576c3e1db0 100644 --- a/ace/Read_Buffer.cpp +++ b/ace/Read_Buffer.cpp @@ -1,14 +1,16 @@ // $Id$ #include "ace/Read_Buffer.h" -#include "ace/Log_Msg.h" -#include "ace/Malloc_Base.h" -#include "ace/Service_Config.h" #if !defined (__ACE_INLINE__) #include "ace/Read_Buffer.i" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/Malloc_Base.h" +#include "ace/Service_Config.h" +#include "ace/OS_NS_stdio.h" + ACE_RCSID(ace, Read_Buffer, "$Id$") void diff --git a/ace/Recursive_Thread_Mutex.cpp b/ace/Recursive_Thread_Mutex.cpp index 0644e4ba6f7..15a809ed898 100644 --- a/ace/Recursive_Thread_Mutex.cpp +++ b/ace/Recursive_Thread_Mutex.cpp @@ -17,6 +17,8 @@ #include "ace/Recursive_Thread_Mutex.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" + ACE_RCSID(ace, Recursive_Thread_Mutex, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Recursive_Thread_Mutex) diff --git a/ace/Recursive_Thread_Mutex.h b/ace/Recursive_Thread_Mutex.h index a5b90c59ca8..3732ff42334 100644 --- a/ace/Recursive_Thread_Mutex.h +++ b/ace/Recursive_Thread_Mutex.h @@ -27,7 +27,7 @@ #else /* ACE_HAS_THREADS */ // ACE platform supports some form of threading. -#include "ace/OS.h" +#include "ace/OS_NS_Thread.h" /** * @class ACE_Recursive_Thread_Mutex diff --git a/ace/Refcounted_Auto_Ptr.h b/ace/Refcounted_Auto_Ptr.h index f7590ec85ce..c6b6910b12f 100644 --- a/ace/Refcounted_Auto_Ptr.h +++ b/ace/Refcounted_Auto_Ptr.h @@ -14,7 +14,6 @@ #define ACE_REFCOUNTED_AUTO_PTR_H #include /**/ "ace/pre.h" -#include "ace/OS.h" #include "ace/Auto_Ptr.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) diff --git a/ace/Registry.cpp b/ace/Registry.cpp index e09443e075c..9e2d0dff25b 100644 --- a/ace/Registry.cpp +++ b/ace/Registry.cpp @@ -6,6 +6,8 @@ ACE_RCSID(ace, Registry, "$Id$") #if defined (ACE_WIN32) +# include "ace/os_include/os_netdb.h" + // Funky macro to deal with strange error passing semantics // of Win32 Reg*() functions #define ACE_REGISTRY_CALL_RETURN(X) \ @@ -650,7 +652,7 @@ ACE_Registry::make_name (const ACE_TString &string) new_position - last_position); // Skip past the seperator new_position += - ACE_OS_String::strlen (ACE_Registry::STRING_SEPARATOR); + ACE_OS::strlen (ACE_Registry::STRING_SEPARATOR); } else { diff --git a/ace/Registry.h b/ace/Registry.h index 0680cf1f0ee..e163d4e9592 100644 --- a/ace/Registry.h +++ b/ace/Registry.h @@ -15,7 +15,7 @@ #define ACE_REGISTRY_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Registry_Name_Space.h b/ace/Registry_Name_Space.h index 5ce3fc2431f..7635b0bafbe 100644 --- a/ace/Registry_Name_Space.h +++ b/ace/Registry_Name_Space.h @@ -15,7 +15,7 @@ #define ACE_REGISTRY_NAME_SPACE_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Remote_Name_Space.cpp b/ace/Remote_Name_Space.cpp index ce1af622d17..003cda8858c 100644 --- a/ace/Remote_Name_Space.cpp +++ b/ace/Remote_Name_Space.cpp @@ -49,7 +49,7 @@ ACE_Remote_Name_Space::bind (const ACE_NS_WString &name, ACE_UINT32 value_len = ACE_static_cast (ACE_UINT32, value.length () * sizeof (ACE_WCHAR_T)); ACE_UINT32 type_len = - ACE_static_cast (ACE_UINT32, ACE_OS_String::strlen (type)); + ACE_static_cast (ACE_UINT32, ACE_OS::strlen (type)); ACE_Name_Request request (ACE_Name_Request::BIND, name_urep.get (), name_len, @@ -73,7 +73,7 @@ ACE_Remote_Name_Space::rebind (const ACE_NS_WString &name, ACE_UINT32 value_len = ACE_static_cast (ACE_UINT32, value.length () * sizeof (ACE_WCHAR_T)); ACE_UINT32 type_len = - ACE_static_cast (ACE_UINT32, ACE_OS_String::strlen (type)); + ACE_static_cast (ACE_UINT32, ACE_OS::strlen (type)); ACE_Name_Request request (ACE_Name_Request::REBIND, name_urep.get (), name_len, diff --git a/ace/SOCK.h b/ace/SOCK.h index c616ce8c0ef..076f2e57196 100644 --- a/ace/SOCK.h +++ b/ace/SOCK.h @@ -22,7 +22,30 @@ #include "ace/Addr.h" #include "ace/IPC_SAP.h" -#include "ace/OS.h" + +#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 */ /** * @class ACE_SOCK diff --git a/ace/SOCK.i b/ace/SOCK.i index 78b17d3e36e..63adf4e2577 100644 --- a/ace/SOCK.i +++ b/ace/SOCK.i @@ -3,6 +3,8 @@ // SOCK.i +#include "OS_NS_sys_socket.h" + ASYS_INLINE ACE_SOCK::~ACE_SOCK (void) { diff --git a/ace/SOCK_Acceptor.cpp b/ace/SOCK_Acceptor.cpp index 898bffd60ba..2ff777ee54b 100644 --- a/ace/SOCK_Acceptor.cpp +++ b/ace/SOCK_Acceptor.cpp @@ -2,16 +2,18 @@ // $Id$ #include "ace/SOCK_Acceptor.h" + +#if defined (ACE_LACKS_INLINE_FUNCTIONS) +#include "ace/SOCK_Acceptor.i" +#endif /* ACE_LACKS_INLINE_FUNCTIONS */ + #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" #if !defined (ACE_HAS_WINCE) #include "ace/OS_QoS.h" #endif // ACE_HAS_WINCE -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "ace/SOCK_Acceptor.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - ACE_RCSID(ace, SOCK_Acceptor, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Acceptor) diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp index 3f93f73fa92..062468327a6 100644 --- a/ace/SOCK_Dgram.cpp +++ b/ace/SOCK_Dgram.cpp @@ -1,12 +1,16 @@ #include "ace/SOCK_Dgram.h" + +#if defined (ACE_LACKS_INLINE_FUNCTIONS) +# include "ace/SOCK_Dgram.i" +#endif + #include "ace/Handle_Set.h" #include "ace/Log_Msg.h" #include "ace/INET_Addr.h" #include "ace/ACE.h" - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "ace/SOCK_Dgram.i" -#endif +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/os_include/net/os_if.h" ACE_RCSID (ace, SOCK_Dgram, diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h index 9aee48839d6..826884c654b 100644 --- a/ace/SOCK_Dgram.h +++ b/ace/SOCK_Dgram.h @@ -24,6 +24,8 @@ #include "ace/Addr.h" +class ACE_Time_Value; + /** * @class ACE_SOCK_Dgram * diff --git a/ace/SOCK_Dgram_Bcast.cpp b/ace/SOCK_Dgram_Bcast.cpp index 560545fd0b6..c95735395c4 100644 --- a/ace/SOCK_Dgram_Bcast.cpp +++ b/ace/SOCK_Dgram_Bcast.cpp @@ -1,13 +1,17 @@ // $Id$ #include "ace/SOCK_Dgram_Bcast.h" -#include "ace/Log_Msg.h" -#include "ace/ACE.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/SOCK_Dgram_Bcast.i" #endif +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/net/os_if.h" +#include "ace/OS_NS_netdb.h" + ACE_RCSID(ace, SOCK_Dgram_Bcast, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Dgram_Bcast) diff --git a/ace/SOCK_Dgram_Mcast.cpp b/ace/SOCK_Dgram_Mcast.cpp index 2aaff6d51ab..95d0937bbae 100644 --- a/ace/SOCK_Dgram_Mcast.cpp +++ b/ace/SOCK_Dgram_Mcast.cpp @@ -6,6 +6,11 @@ #include "ace/SOCK_Dgram_Mcast.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/os_include/net/os_if.h" +#include "ace/os_include/arpa/os_inet.h" + ACE_RCSID (ace, SOCK_Dgram_Mcast, "$Id$") @@ -31,13 +36,13 @@ public: { if (ip_addr.addr_to_string (ret_string, len, 1) == -1) { - ACE_OS_String::strcpy (ret_string, ACE_LIB_TEXT ("<?>")); + ACE_OS::strcpy (ret_string, ACE_LIB_TEXT ("<?>")); } else { ACE_TCHAR *pc; if (clip_portnum - && (pc = ACE_OS_String::strchr (ret_string, ACE_LIB_TEXT (':')))) + && (pc = ACE_OS::strchr (ret_string, ACE_LIB_TEXT (':')))) *pc = ACE_LIB_TEXT ('\0'); // clip port# info. } } @@ -99,10 +104,10 @@ ACE_SOCK_Dgram_Mcast::dump (void) const ACE_NTOHL (pm->imr_interface.s_addr)); ACE_SDM_helpers::addr_to_string (if_addr, iface_string, sizeof iface_string, 1); - if (ACE_OS_String::strcmp (iface_string, ACE_LIB_TEXT ("0.0.0.0")) == 0) + if (ACE_OS::strcmp (iface_string, ACE_LIB_TEXT ("0.0.0.0")) == 0) // Receives on system default iface. (Note that null_iface_opt_ // option processing has already occurred.) - ACE_OS_String::strcpy (iface_string, ACE_LIB_TEXT ("<default>")); + ACE_OS::strcpy (iface_string, ACE_LIB_TEXT ("<default>")); // Dump info. ACE_DEBUG ((LM_DEBUG, @@ -155,7 +160,7 @@ ACE_SOCK_Dgram_Mcast::open (const ACE_INET_Addr &mcast_addr, reuse_addr) == -1) return -1; - return open_i (mcast_addr, net_if, reuse_addr); + return this->open_i (mcast_addr, net_if, reuse_addr); } int @@ -222,8 +227,8 @@ ACE_SOCK_Dgram_Mcast::open_i (const ACE_INET_Addr &mcast_addr, &(send_mreq.imr_interface), sizeof send_mreq.imr_interface) == -1) return -1; - this->send_net_if_ = new ACE_TCHAR[ACE_OS_String::strlen (net_if) + 1]; - ACE_OS_String::strcpy (this->send_net_if_, net_if); + this->send_net_if_ = new ACE_TCHAR[ACE_OS::strlen (net_if) + 1]; + ACE_OS::strcpy (this->send_net_if_, net_if); #else // Send interface option not supported - ignore it. // (We may have been invoked by ::subscribe, so we have to allow @@ -657,7 +662,7 @@ ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr (ip_mreq *ret_mreq, // Look up the interface by number, not name. if_address.ifr_ifno = ACE_OS::atoi (net_if); #else - ACE_OS_String::strcpy (if_address.ifr_name, net_if); + ACE_OS::strcpy (if_address.ifr_name, net_if); #endif /* defined (ACE_PSOS) */ if (ACE_OS::ioctl (this->get_handle (), diff --git a/ace/SOCK_IO.cpp b/ace/SOCK_IO.cpp index 83d13192be0..c9a8a881289 100644 --- a/ace/SOCK_IO.cpp +++ b/ace/SOCK_IO.cpp @@ -2,12 +2,14 @@ // $Id$ #include "ace/SOCK_IO.h" -#include "ace/Handle_Set.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/SOCK_IO.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ +#include "ace/Handle_Set.h" +#include "ace/OS_NS_sys_select.h" + ACE_RCSID(ace, SOCK_IO, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_IO) diff --git a/ace/SOCK_SEQPACK_Acceptor.cpp b/ace/SOCK_SEQPACK_Acceptor.cpp index 746775d8a89..3bf5eab1ef8 100644 --- a/ace/SOCK_SEQPACK_Acceptor.cpp +++ b/ace/SOCK_SEQPACK_Acceptor.cpp @@ -3,13 +3,13 @@ #include "ace/SOCK_SEQPACK_Acceptor.h" -#include "ace/Log_Msg.h" - #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/SOCK_SEQPACK_Acceptor.i" #endif /* ACE_LACKS_INLINE_FUNCTIONS */ #include "ace/Auto_Ptr.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" ACE_RCSID(ace, SOCK_SEQPACK_Acceptor, "SOCK_SEQPACK_Acceptor.cpp,v 4.30 2002/03/08 23:18:09 spark Exp") diff --git a/ace/SOCK_SEQPACK_Association.cpp b/ace/SOCK_SEQPACK_Association.cpp index fcf3f0b9b7f..3b62bc0ed4c 100644 --- a/ace/SOCK_SEQPACK_Association.cpp +++ b/ace/SOCK_SEQPACK_Association.cpp @@ -1,13 +1,15 @@ // SOCK_SEQPACK_Association.cpp -#include /**/ "ace/SOCK_SEQPACK_Association.h" -#include /**/ "ace/Auto_Ptr.h" -#include /**/ "ace/Log_Msg.h" +#include "ace/SOCK_SEQPACK_Association.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include /**/ "ace/SOCK_SEQPACK_Association.i" +#include "ace/SOCK_SEQPACK_Association.i" #endif +#include "ace/Auto_Ptr.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + ACE_RCSID(ace, SOCK_SEQPACK_Association, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_SEQPACK_Association) diff --git a/ace/SPIPE.cpp b/ace/SPIPE.cpp index eafbc05925f..f91c7ff545d 100644 --- a/ace/SPIPE.cpp +++ b/ace/SPIPE.cpp @@ -7,6 +7,8 @@ #include "ace/SPIPE.i" #endif +#include "ace/OS_NS_unistd.h" + ACE_RCSID(ace, SPIPE, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE) diff --git a/ace/SPIPE_Acceptor.cpp b/ace/SPIPE_Acceptor.cpp index 3728004dfe8..0cd7dc63a9e 100644 --- a/ace/SPIPE_Acceptor.cpp +++ b/ace/SPIPE_Acceptor.cpp @@ -3,6 +3,8 @@ #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_sys_time.h" ACE_RCSID(ace, SPIPE_Acceptor, "$Id$") diff --git a/ace/SPIPE_Addr.cpp b/ace/SPIPE_Addr.cpp index b234e9e3882..4540fac90b9 100644 --- a/ace/SPIPE_Addr.cpp +++ b/ace/SPIPE_Addr.cpp @@ -116,10 +116,10 @@ ACE_SPIPE_Addr::set (const ACE_TCHAR *addr, ACE_OS::strcat (temp, ACE_LIB_TEXT ("\\pipe\\")); ACE_OS::strcat (temp, colonp + 1); } - len += ACE_static_cast (int, ACE_OS_String::strlen (temp)); + len += ACE_static_cast (int, ACE_OS::strlen (temp)); this->ACE_Addr::base_set (AF_SPIPE, len); - ACE_OS_String::strcpy (this->SPIPE_addr_.rendezvous_, temp); + ACE_OS::strcpy (this->SPIPE_addr_.rendezvous_, temp); #else this->ACE_Addr::base_set (AF_SPIPE, ACE_OS::strlen (addr) + 1 + len); diff --git a/ace/SPIPE_Addr.h b/ace/SPIPE_Addr.h index 5510f7e0e55..cf801317edb 100644 --- a/ace/SPIPE_Addr.h +++ b/ace/SPIPE_Addr.h @@ -23,7 +23,8 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" -#include "ace/OS.h" +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_dirent.h" /** * @class ACE_SPIPE_Addr diff --git a/ace/SPIPE_Connector.cpp b/ace/SPIPE_Connector.cpp index 8a20df75d28..cacf44b9b37 100644 --- a/ace/SPIPE_Connector.cpp +++ b/ace/SPIPE_Connector.cpp @@ -3,6 +3,7 @@ #include "ace/SPIPE_Connector.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_time.h" #if defined (ACE_LACKS_INLINE_FUNCTIONS) #include "ace/SPIPE_Connector.i" diff --git a/ace/SPIPE_Stream.i b/ace/SPIPE_Stream.i index c52523d28b7..cb855663448 100644 --- a/ace/SPIPE_Stream.i +++ b/ace/SPIPE_Stream.i @@ -3,6 +3,9 @@ // SPIPE_Stream.i +#include "ace/OS_NS_sys_uio.h" +#include "ace/OS_NS_errno.h" + // Create an ACE_SPIPE_Stream. ASYS_INLINE int diff --git a/ace/SString.cpp b/ace/SString.cpp index a81a290333c..052eafd1993 100644 --- a/ace/SString.cpp +++ b/ace/SString.cpp @@ -314,7 +314,7 @@ ACE_NS_WString::ACE_NS_WString (const char *s, if (s == 0) return; - this->len_ = this->buf_len_ = ACE_OS_String::strlen (s); + this->len_ = this->buf_len_ = ACE_OS::strlen (s); if (this->buf_len_ == 0) return; diff --git a/ace/SString.h b/ace/SString.h index 104a9b0cf1d..6fbaa7a93c1 100644 --- a/ace/SString.h +++ b/ace/SString.h @@ -21,8 +21,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/String_Base.h" -#include "ace/OS.h" - #if !defined (ACE_DEFAULT_GROWSIZE) #define ACE_DEFAULT_GROWSIZE 32 diff --git a/ace/SV_Message.h b/ace/SV_Message.h index 6a988490b15..92a0b17c7c7 100644 --- a/ace/SV_Message.h +++ b/ace/SV_Message.h @@ -22,8 +22,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" - /** * @class ACE_SV_Message * diff --git a/ace/SV_Message.i b/ace/SV_Message.i index 8c08e41d151..44cd5e25759 100644 --- a/ace/SV_Message.i +++ b/ace/SV_Message.i @@ -3,6 +3,8 @@ // SV_Message.i +#include "ace/Global_Macros.h" + ACE_INLINE ACE_SV_Message::ACE_SV_Message (long t) : type_ (t) diff --git a/ace/SV_Message_Queue.h b/ace/SV_Message_Queue.h index 7c8296824be..5c813805573 100644 --- a/ace/SV_Message_Queue.h +++ b/ace/SV_Message_Queue.h @@ -22,6 +22,8 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SV_Message.h" +#include "ace/os_include/sys/os_ipc.h" +#include "ace/Default_Constants.h" /** * @class ACE_SV_Message_Queue diff --git a/ace/SV_Message_Queue.i b/ace/SV_Message_Queue.i index 65c092136f7..182b44c3cc4 100644 --- a/ace/SV_Message_Queue.i +++ b/ace/SV_Message_Queue.i @@ -3,7 +3,8 @@ // SV_Message_Queue.i -#include "ace/SV_Message_Queue.h" +#include "ace/Global_Macros.h" +#include "ace/OS_NS_sys_msg.h" // Open a message queue using the <external_id>. diff --git a/ace/SV_Semaphore_Simple.h b/ace/SV_Semaphore_Simple.h index eb48aa15a9d..b2471d03a9a 100644 --- a/ace/SV_Semaphore_Simple.h +++ b/ace/SV_Semaphore_Simple.h @@ -21,7 +21,9 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/os_include/sys/os_ipc.h" +#include "ace/os_include/sys/os_sem.h" +#include "ace/Default_Constants.h" #if defined (ACE_WIN32) && !defined (ACE_PSOS) // Default semaphore key and mutex name diff --git a/ace/SV_Semaphore_Simple.i b/ace/SV_Semaphore_Simple.i index 448ad8cd5d2..3fd4fb9f81c 100644 --- a/ace/SV_Semaphore_Simple.i +++ b/ace/SV_Semaphore_Simple.i @@ -3,6 +3,9 @@ // SV_Semaphore_Simple.i +#include "ace/Global_Macros.h" +#include "ace/OS_NS_Thread.h" + ASYS_INLINE int ACE_SV_Semaphore_Simple::control (int cmd, semun arg, diff --git a/ace/SV_Shared_Memory.h b/ace/SV_Shared_Memory.h index dfd9d1b0db1..71faf4e8b4d 100644 --- a/ace/SV_Shared_Memory.h +++ b/ace/SV_Shared_Memory.h @@ -21,7 +21,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/os_include/sys/os_ipc.h" +#include "ace/Default_Constants.h" /** * @class ACE_SV_Shared_Memory diff --git a/ace/SV_Shared_Memory.i b/ace/SV_Shared_Memory.i index 3e7bf1db6ef..f01f5b2c969 100644 --- a/ace/SV_Shared_Memory.i +++ b/ace/SV_Shared_Memory.i @@ -3,7 +3,9 @@ // SV_Shared_Memory.i -#include "ace/SV_Shared_Memory.h" +#include "ace/OS_NS_sys_shm.h" +#include "ace/Global_Macros.h" +#include "ace/OS_NS_errno.h" ACE_INLINE size_t ACE_SV_Shared_Memory::round_up (size_t len) diff --git a/ace/Sample_History.cpp b/ace/Sample_History.cpp index 38bc4507776..349d36bf38c 100644 --- a/ace/Sample_History.cpp +++ b/ace/Sample_History.cpp @@ -1,14 +1,15 @@ // $Id$ #include "ace/Sample_History.h" -#include "ace/Basic_Stats.h" -#include "ace/Log_Msg.h" -#include "ace/OS.h" #if !defined (__ACE_INLINE__) #include "ace/Sample_History.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Basic_Stats.h" +#include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" + ACE_RCSID(ace, Sample_History, "$Id$") ACE_Sample_History::ACE_Sample_History (size_t max_samples) diff --git a/ace/Sched_Params.cpp b/ace/Sched_Params.cpp index 0dd45f79fd1..e0a2e14b0b9 100644 --- a/ace/Sched_Params.cpp +++ b/ace/Sched_Params.cpp @@ -22,6 +22,11 @@ #include "ace/Sched_Params.i" #endif /* __ACE_INLINE__ */ +#if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS) +# include "ace/OS_NS_string.h" +# include /**/ <sys/priocntl.h> +#endif /* ACE_HAS_PRIOCNTL && ACE_HAS_THREADS */ + ACE_RCSID(ace, Sched_Params, "$Id$") int diff --git a/ace/Sched_Params.h b/ace/Sched_Params.h index 0edeaffceec..d5776449a2d 100644 --- a/ace/Sched_Params.h +++ b/ace/Sched_Params.h @@ -15,12 +15,15 @@ #define ACE_SCHED_PARAMS_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/ACE_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Time_Value.h" +#include "ace/OS_NS_Thread.h" + /** * @class ACE_Sched_Params * diff --git a/ace/Select_Reactor_T.cpp b/ace/Select_Reactor_T.cpp index f62b7b85b2a..93429f09b2c 100644 --- a/ace/Select_Reactor_T.cpp +++ b/ace/Select_Reactor_T.cpp @@ -13,6 +13,8 @@ #include "ace/Log_Msg.h" #include "ace/Thread.h" #include "ace/Timer_Heap.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_sys_stat.h" // For timer_queue_ #include "ace/Recursive_Thread_Mutex.h" diff --git a/ace/Semaphore.cpp b/ace/Semaphore.cpp index 44f3fa6e882..2cc8eef740d 100644 --- a/ace/Semaphore.cpp +++ b/ace/Semaphore.cpp @@ -6,6 +6,8 @@ #include "ace/Semaphore.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" + ACE_RCSID (ace, Semaphore, "$Id$") diff --git a/ace/Semaphore.h b/ace/Semaphore.h index b152f2ac5a9..01c116ef991 100644 --- a/ace/Semaphore.h +++ b/ace/Semaphore.h @@ -22,7 +22,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/OS_NS_Thread.h" class ACE_Time_Value; @@ -103,7 +103,7 @@ public: /// Increment the semaphore by <release_count>, potentially /// unblocking waiting threads. - int release (u_int release_count); + int release (unsigned int release_count); /** * Acquire semaphore ownership. This calls <acquire> and is only diff --git a/ace/Semaphore.inl b/ace/Semaphore.inl index 0702173fc78..a519c4e7920 100644 --- a/ace/Semaphore.inl +++ b/ace/Semaphore.inl @@ -57,7 +57,7 @@ ACE_Semaphore::release (void) } ACE_INLINE int -ACE_Semaphore::release (u_int release_count) +ACE_Semaphore::release (unsigned int release_count) { // ACE_TRACE ("ACE_Semaphore::release"); return ACE_OS::sema_post (&this->semaphore_, release_count); diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index a9536b7f514..26461919013 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -1,5 +1,11 @@ // $Id$ +#include "ace/Service_Config.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Config.i" +#endif /* __ACE_INLINE__ */ + #include "ace/Svc_Conf.h" #include "ace/Get_Opt.h" #include "ace/ARGV.h" @@ -12,13 +18,9 @@ #include "ace/Reactor.h" #include "ace/Thread_Manager.h" #include "ace/DLL.h" - -#include "ace/Service_Config.h" +#include "ace/OS_NS_stdio.h" #include "ace/XML_Svc_Conf.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Service_Config.i" -#endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_time.h" ACE_RCSID (ace, Service_Config, diff --git a/ace/Service_Manager.cpp b/ace/Service_Manager.cpp index 40437aab625..3e8f90f0cae 100644 --- a/ace/Service_Manager.cpp +++ b/ace/Service_Manager.cpp @@ -1,16 +1,17 @@ +#include "ace/Service_Manager.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Manager.i" +#endif /* __ACE_INLINE__ */ + #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #include "ace/Service_Repository.h" #include "ace/Service_Config.h" -#include "ace/Service_Manager.h" #include "ace/Service_Types.h" #include "ace/Reactor.h" #include "ace/WFMO_Reactor.h" - -#if !defined (__ACE_INLINE__) -#include "ace/Service_Manager.i" -#endif /* __ACE_INLINE__ */ - +#include "ace/OS_NS_stdio.h" ACE_RCSID (ace, Service_Manager, @@ -82,7 +83,7 @@ ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const return -1; else ACE_OS::strsncpy (*strp, buf, length); - return ACE_static_cast (int, ACE_OS_String::strlen (buf)); + return ACE_static_cast (int, ACE_OS::strlen (buf)); } int @@ -173,7 +174,7 @@ ACE_Service_Manager::list_services (void) sri.next (sr) != 0; sri.advance ()) { - size_t len = ACE_OS_String::strlen (sr->name ()) + 11; + size_t len = ACE_OS::strlen (sr->name ()) + 11; ACE_TCHAR buf[BUFSIZ]; ACE_TCHAR *p = buf + len; diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index e2654349561..c6174357f11 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -1,13 +1,15 @@ #include "ace/Service_Repository.h" -#include "ace/Service_Types.h" -#include "ace/Object_Manager.h" -#include "ace/Log_Msg.h" -#include "ace/ACE.h" #if !defined (__ACE_INLINE__) #include "ace/Service_Repository.i" #endif /* __ACE_INLINE__ */ +#include "ace/Service_Types.h" +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/OS_NS_string.h" + ACE_RCSID (ace, Service_Repository, "$Id$") diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index f29bc9205c7..8218f26aa79 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -1,8 +1,14 @@ // $Id$ #include "ace/Service_Types.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Types.i" +#endif /* __ACE_INLINE__ */ + #include "ace/Stream_Modules.h" #include "ace/Stream.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(ace, Service_Types, "$Id$") @@ -10,10 +16,6 @@ typedef ACE_Stream<ACE_SYNCH> MT_Stream; typedef ACE_Module<ACE_SYNCH> MT_Module; typedef ACE_Task<ACE_SYNCH> MT_Task; -#if !defined (__ACE_INLINE__) -#include "ace/Service_Types.i" -#endif /* __ACE_INLINE__ */ - ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type_Impl) void @@ -204,7 +206,7 @@ ACE_Module_Type::info (ACE_TCHAR **str, size_t len) const return -1; else ACE_OS::strsncpy (*str, buf, len); - return ACE_static_cast (int, ACE_OS_String::strlen (buf)); + return ACE_static_cast (int, ACE_OS::strlen (buf)); } void @@ -288,7 +290,7 @@ ACE_Stream_Type::info (ACE_TCHAR **str, size_t len) const return -1; else ACE_OS::strsncpy (*str, buf, len); - return ACE_static_cast (int, ACE_OS_String::strlen (buf)); + return ACE_static_cast (int, ACE_OS::strlen (buf)); } int diff --git a/ace/Shared_Memory.h b/ace/Shared_Memory.h index 2f2af867c54..7e1b096b528 100644 --- a/ace/Shared_Memory.h +++ b/ace/Shared_Memory.h @@ -22,8 +22,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" - /** * @class ACE_Shared_Memory * diff --git a/ace/Shared_Memory_SV.i b/ace/Shared_Memory_SV.i index f1998fb3ae6..96699c87097 100644 --- a/ace/Shared_Memory_SV.i +++ b/ace/Shared_Memory_SV.i @@ -3,6 +3,8 @@ // Shared_Memory_SV.i +#include "ace/Global_Macros.h" + ACE_INLINE int ACE_Shared_Memory_SV::open (key_t id, int length, diff --git a/ace/Signal.h b/ace/Signal.h index 63e4ad05c9c..0d5f39fa63e 100644 --- a/ace/Signal.h +++ b/ace/Signal.h @@ -15,7 +15,7 @@ #include /**/ "ace/pre.h" #if defined (ACE_DONT_INCLUDE_ACE_SIGNAL_H) -# error ace/Signal.h was #included instead of signal.h by ace/OS.h: fix!!!! +# error ace/Signal.h was #included instead of signal.h by ace/OS_NS_signal.h: fix!!!! #endif /* ACE_DONT_INCLUDE_ACE_SIGNAL_H */ #include "ace/ACE_export.h" @@ -26,6 +26,9 @@ #include "ace/Event_Handler.h" +// Type of the extended signal handler. +typedef void (*ACE_Sig_Handler_Ex) (int, siginfo_t *siginfo, ucontext_t *ucontext); + // This worksaround a horrible bug with HP/UX C++... typedef struct sigaction ACE_SIGACTION; diff --git a/ace/Signal.i b/ace/Signal.i index e2ca95be130..908eb365b43 100644 --- a/ace/Signal.i +++ b/ace/Signal.i @@ -1,6 +1,8 @@ /* -*- C++ -*- */ // $Id$ +#include "ace/OS_NS_signal.h" + ACE_INLINE ACE_Sig_Set::ACE_Sig_Set (sigset_t *ss) // : sigset_ () diff --git a/ace/Singleton.h b/ace/Singleton.h index 818e93cbc8e..5e94ba1396b 100644 --- a/ace/Singleton.h +++ b/ace/Singleton.h @@ -23,7 +23,7 @@ #include "ace/config-all.h" #include "ace/TSS_T.h" -#include "ace/OS.h" // for ACE_Cleanup +#include "ace/Cleanup.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Sock_Connect.cpp b/ace/Sock_Connect.cpp index 4e4ae1844d6..fe5ac412f4a 100644 --- a/ace/Sock_Connect.cpp +++ b/ace/Sock_Connect.cpp @@ -1,12 +1,14 @@ // $Id$ #include "ace/Sock_Connect.h" -#include "ace/OS.h" // Needed to get the ifreq stuff #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" #include "ace/Handle_Set.h" #include "ace/Auto_Ptr.h" #include "ace/SString.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_netdb.h" +#include "ace/os_include/net/os_if.h" # if defined (ACE_HAS_GETIFADDRS) # include /**/ <ifaddrs.h> diff --git a/ace/Stats.cpp b/ace/Stats.cpp index 0ca18fafcb8..766f831fcbb 100644 --- a/ace/Stats.cpp +++ b/ace/Stats.cpp @@ -1,12 +1,15 @@ // $Id$ #include "ace/Stats.h" -#include "ace/High_Res_Timer.h" #if !defined (__ACE_INLINE__) # include "ace/Stats.i" #endif /* __ACE_INLINE__ */ +#include "ace/High_Res_Timer.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" + ACE_RCSID(ace, Stats, "$Id$") ACE_UINT32 @@ -272,7 +275,7 @@ ACE_Stats::print_summary (const u_int precision, #if !defined (ACE_HAS_WINCE) ACE_OS::fprintf (file, ACE_LIB_TEXT ("ACE_Stats::print_summary: OVERFLOW: %s\n"), - strerror (overflow_)); + ACE_OS::strerror (overflow_)); #else // WinCE doesn't have strerror ;( ACE_OS::fprintf (file, diff --git a/ace/Stats.h b/ace/Stats.h index 79c3c31bc21..d228f8fa07f 100644 --- a/ace/Stats.h +++ b/ace/Stats.h @@ -25,7 +25,6 @@ #include "ace/Unbounded_Queue.h" #include "ace/Log_Msg.h" #include "ace/Basic_Stats.h" -#include "ace/OS.h" /** * @class ACE_Stats_Value diff --git a/ace/Stream_Modules.cpp b/ace/Stream_Modules.cpp index 71681344db7..6afe507f06b 100644 --- a/ace/Stream_Modules.cpp +++ b/ace/Stream_Modules.cpp @@ -5,6 +5,7 @@ #define ACE_STREAM_MODULES_C #include "ace/Stream_Modules.h" +#include "ace/OS_NS_string.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -142,7 +143,7 @@ ACE_Stream_Head<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const return -1; else ACE_OS::strsncpy (*strp, name, length); - return ACE_static_cast (int, ACE_OS_String::strlen (name)); + return ACE_static_cast (int, ACE_OS::strlen (name)); } template <ACE_SYNCH_DECL> int @@ -285,7 +286,7 @@ ACE_Stream_Tail<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const return -1; else ACE_OS::strsncpy (*strp, name, length); - return ACE_static_cast (int, ACE_OS_String::strlen (name)); + return ACE_static_cast (int, ACE_OS::strlen (name)); } template <ACE_SYNCH_DECL> int @@ -364,7 +365,7 @@ ACE_Thru_Task<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, return -1; else ACE_OS::strsncpy (*strp, name, length); - return ACE_static_cast (int, ACE_OS_String::strlen (name)); + return ACE_static_cast (int, ACE_OS::strlen (name)); } template <ACE_SYNCH_DECL> int diff --git a/ace/String_Base.cpp b/ace/String_Base.cpp index e695b941e45..eb599426850 100644 --- a/ace/String_Base.cpp +++ b/ace/String_Base.cpp @@ -5,7 +5,7 @@ #include "ace/Malloc_Base.h" #include "ace/String_Base.h" #include "ace/Auto_Ptr.h" -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" #if !defined (__ACE_INLINE__) #include "ace/String_Base.i" @@ -43,7 +43,7 @@ ACE_String_Base<CHAR>::set (const CHAR *s, this->buf_len_ = new_buf_len; this->release_ = 1; this->len_ = len; - ACE_OS_String::memcpy (this->rep_, s, len * sizeof (CHAR)); + ACE_OS::memcpy (this->rep_, s, len * sizeof (CHAR)); // NUL terminate. this->rep_[len] = '\0'; } @@ -77,7 +77,7 @@ ACE_String_Base<CHAR>::set (const CHAR *s, } else { - ACE_OS_String::memcpy (this->rep_, s, len * sizeof (CHAR)); + ACE_OS::memcpy (this->rep_, s, len * sizeof (CHAR)); // NUL terminate. this->rep_[len] = 0; this->len_ = len; @@ -126,7 +126,7 @@ ACE_String_Base<CHAR>::operator+= (const ACE_String_Base<CHAR> &s) // case 1. No memory allocation needed. if (this->buf_len_ >= new_buf_len) // Copy in data from new string. - ACE_OS_String::memcpy (this->rep_ + this->len_, + ACE_OS::memcpy (this->rep_ + this->len_, s.rep_, s.len_ * sizeof (CHAR)); // case 2. Memory reallocation is needed @@ -140,11 +140,11 @@ ACE_String_Base<CHAR>::operator+= (const ACE_String_Base<CHAR> &s) *this); // Copy memory from old string into new string. - ACE_OS_String::memcpy (t, + ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (CHAR)); - ACE_OS_String::memcpy (t + this->len_, + ACE_OS::memcpy (t + this->len_, s.rep_, s.len_ * sizeof (CHAR)); @@ -189,7 +189,7 @@ ACE_String_Base<CHAR>::resize (size_t len, CHAR c) } this->len_ = 0; - ACE_OS_String::memset (this->rep_, + ACE_OS::memset (this->rep_, c, this->buf_len_ * sizeof (CHAR)); } diff --git a/ace/String_Base.h b/ace/String_Base.h index a2430034fe2..b4afab07731 100644 --- a/ace/String_Base.h +++ b/ace/String_Base.h @@ -23,9 +23,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Global_Macros.h" -#include "ace/OS_String.h" -#include "ace/OS_Memory.h" - // Forward decl. class ACE_Allocator; diff --git a/ace/String_Base.i b/ace/String_Base.i index f35a1378bc4..af13ef5d50f 100644 --- a/ace/String_Base.i +++ b/ace/String_Base.i @@ -5,6 +5,8 @@ #include "ace/Malloc_Base.h" #include "ace/Min_Max.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" // Default constructor. @@ -35,7 +37,7 @@ ACE_String_Base<CHAR>::ACE_String_Base (const CHAR *s, size_t length; if (s != 0) - length = ACE_OS_String::strlen (s); + length = ACE_OS::strlen (s); else length = 0; @@ -146,7 +148,7 @@ ACE_String_Base<CHAR>::set (const CHAR *s, int release) { size_t length; if (s != 0) - length = ACE_OS_String::strlen (s); + length = ACE_OS::strlen (s); else length = 0; @@ -200,7 +202,7 @@ ACE_String_Base<CHAR>::rep (void) const CHAR *new_string; ACE_NEW_RETURN (new_string, CHAR[this->len_ + 1], 0); - ACE_OS_String::strsncpy (new_string, this->rep_, this->len_+1); + ACE_OS::strsncpy (new_string, this->rep_, this->len_+1); return new_string; } @@ -225,7 +227,7 @@ ACE_String_Base<CHAR>::compare (const ACE_String_Base<CHAR> &s) const // Pick smaller of the two lengths and perform the comparison. size_t smaller_length = ace_min (this->len_, s.len_); - int result = ACE_OS_String::memcmp (this->rep_, + int result = ACE_OS::memcmp (this->rep_, s.rep_, smaller_length * sizeof (CHAR)); @@ -277,8 +279,8 @@ template <class CHAR> ACE_INLINE ssize_t ACE_String_Base<CHAR>::find (const CHAR *s, size_t pos) const { CHAR *substr = this->rep_ + pos; - size_t len = ACE_OS_String::strlen (s); - CHAR *pointer = ACE_OS_String::strnstr (substr, s, len); + size_t len = ACE_OS::strlen (s); + CHAR *pointer = ACE_OS::strnstr (substr, s, len); if (pointer == 0) return ACE_String_Base<CHAR>::npos; else @@ -289,7 +291,7 @@ template <class CHAR> ACE_INLINE ssize_t ACE_String_Base<CHAR>::find (CHAR c, size_t pos) const { CHAR *substr = this->rep_ + pos; - CHAR *pointer = ACE_OS_String::strnchr (substr, c, this->len_ - pos); + CHAR *pointer = ACE_OS::strnchr (substr, c, this->len_ - pos); if (pointer == 0) return ACE_String_Base<CHAR>::npos; else diff --git a/ace/Synch.h b/ace/Synch.h index dd6e8a3363a..ae8387b71f7 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -22,6 +22,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#if !defined (DO_NOT_INCLUDE_SYNCH_H) + /* All the classes have been moved out into their own headers as part of the compile-time and footprint reduction effort. */ @@ -60,5 +62,7 @@ # include "ace/Test_and_Set.h" #endif /* ACE_LEGACY_MODE */ +#endif /* DO_NOT_INCLUDE_SYNCH_H */ + #include /**/ "ace/post.h" #endif /* ACE_SYNCH_H */ diff --git a/ace/System_Time.cpp b/ace/System_Time.cpp index 9e2f2b69380..125fa2f5050 100644 --- a/ace/System_Time.cpp +++ b/ace/System_Time.cpp @@ -2,6 +2,8 @@ // $Id$ #include "ace/System_Time.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_time.h" ACE_RCSID(ace, System_Time, "$Id$") diff --git a/ace/System_Time.h b/ace/System_Time.h index 242c944617c..906247bde0d 100644 --- a/ace/System_Time.h +++ b/ace/System_Time.h @@ -17,7 +17,7 @@ #define ACE_SYSTEM_TIME_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/TLI.cpp b/ace/TLI.cpp index 2a07df957ff..da0674c605e 100644 --- a/ace/TLI.cpp +++ b/ace/TLI.cpp @@ -5,6 +5,8 @@ #include "ace/TLI.h" #include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" ACE_RCSID(ace, TLI, "$Id$") diff --git a/ace/TLI.h b/ace/TLI.h index 58c35284c8d..ac8089be7a9 100644 --- a/ace/TLI.h +++ b/ace/TLI.h @@ -22,6 +22,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" +#include "ace/OS_TLI.h" #if defined (ACE_HAS_TLI) diff --git a/ace/TLI_Acceptor.cpp b/ace/TLI_Acceptor.cpp index d3116be865e..cc74c45113a 100644 --- a/ace/TLI_Acceptor.cpp +++ b/ace/TLI_Acceptor.cpp @@ -3,6 +3,7 @@ #include "ace/TLI_Acceptor.h" #include "ace/Log_Msg.h" #include "ace/ACE.h" +#include "ace/OS_NS_string.h" ACE_RCSID(ace, TLI_Acceptor, "$Id$") diff --git a/ace/TLI_Acceptor.h b/ace/TLI_Acceptor.h index 3e958c1c9ee..2eb8008030c 100644 --- a/ace/TLI_Acceptor.h +++ b/ace/TLI_Acceptor.h @@ -23,6 +23,7 @@ #include "ace/Time_Value.h" #include "ace/TLI_Stream.h" +#include "ace/Default_Constants.h" #if defined (ACE_HAS_TLI) diff --git a/ace/TLI_Connector.cpp b/ace/TLI_Connector.cpp index 6acf741f3ba..96b5bf3649e 100644 --- a/ace/TLI_Connector.cpp +++ b/ace/TLI_Connector.cpp @@ -1,9 +1,7 @@ // TLI_Connector.cpp // $Id$ -#include "ace/Handle_Set.h" #include "ace/TLI_Connector.h" -#include "ace/ACE.h" ACE_RCSID(ace, TLI_Connector, "$Id$") @@ -13,6 +11,10 @@ ACE_RCSID(ace, TLI_Connector, "$Id$") #include "ace/TLI_Connector.i" #endif /* __ACE_INLINE__ */ +#include "ace/Handle_Set.h" +#include "ace/ACE.h" +#include "ace/OS_NS_string.h" + ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Connector) void diff --git a/ace/TLI_Stream.h b/ace/TLI_Stream.h index 7cb03c7904b..4a1ce7fcde0 100644 --- a/ace/TLI_Stream.h +++ b/ace/TLI_Stream.h @@ -25,6 +25,8 @@ #if defined (ACE_HAS_TLI) +class ACE_Time_Value; + /** * @class ACE_TLI_Stream * diff --git a/ace/TSS_T.cpp b/ace/TSS_T.cpp index 08cae3e52e0..c2cb22847c0 100644 --- a/ace/TSS_T.cpp +++ b/ace/TSS_T.cpp @@ -18,6 +18,7 @@ ACE_RCSID(ace, TSS_T, "$Id$") #include "ace/Thread.h" #include "ace/Log_Msg.h" #include "ace/Guard_T.h" +#include "ace/OS_NS_stdio.h" #if defined (ACE_HAS_THR_C_DEST) # include "ace/TSS_Adapter.h" diff --git a/ace/TTY_IO.cpp b/ace/TTY_IO.cpp index 8b7ae2bb74b..46567e6ce64 100644 --- a/ace/TTY_IO.cpp +++ b/ace/TTY_IO.cpp @@ -1,6 +1,10 @@ // $Id$ #include "ace/TTY_IO.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/os_include/os_termios.h" +#include "ace/OS_NS_errno.h" ACE_RCSID (ace, TTY_IO, diff --git a/ace/TTY_IO.h b/ace/TTY_IO.h index b0c7028fa54..f0fab47fe0b 100644 --- a/ace/TTY_IO.h +++ b/ace/TTY_IO.h @@ -13,13 +13,23 @@ #ifndef ACE_TTY_IO_H #define ACE_TTY_IO_H -#include "ace/OS.h" +#include "ace/DEV_IO.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/DEV_IO.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 */ /** * @class ACE_TTY_IO diff --git a/ace/Task_T.i b/ace/Task_T.i index 1a78650279f..e4694062fc4 100644 --- a/ace/Task_T.i +++ b/ace/Task_T.i @@ -3,6 +3,8 @@ // Task_T.i +#include "ace/os_include/os_assert.h" + template <ACE_SYNCH_DECL> ACE_INLINE void ACE_Task<ACE_SYNCH_USE>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, size_t wm_size) diff --git a/ace/Thread.h b/ace/Thread.h index 0763850eb85..0da56b10427 100644 --- a/ace/Thread.h +++ b/ace/Thread.h @@ -21,7 +21,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" +#include "ace/OS_NS_Thread.h" #include "ace/Thread_Adapter.h" struct cancel_state diff --git a/ace/Thread.i b/ace/Thread.i index 0a489f873b9..f12145ff040 100644 --- a/ace/Thread.i +++ b/ace/Thread.i @@ -3,6 +3,8 @@ // Thread.i +#include "ace/OS_NS_string.h" + // Allocates a <keyp> that is used to identify data that is specific // to each thread in the process. The key is global to all threads in // the process. diff --git a/ace/Thread_Adapter.cpp b/ace/Thread_Adapter.cpp index 0fef397baf2..3e2f3dfe9ea 100644 --- a/ace/Thread_Adapter.cpp +++ b/ace/Thread_Adapter.cpp @@ -1,7 +1,6 @@ // $Id$ #include "ace/Thread_Adapter.h" -#include "ace/OS.h" #include "ace/Thread_Manager.h" #include "ace/Thread_Exit.h" #include "ace/Thread_Hook.h" diff --git a/ace/Thread_Control.h b/ace/Thread_Control.h index 3448007fefe..fa2bc559c8d 100644 --- a/ace/Thread_Control.h +++ b/ace/Thread_Control.h @@ -20,10 +20,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#if !defined (ACE_LEGACY_MODE) -# include "ace/OS.h" -#endif /* ACE_LEGACY_MODE */ - class ACE_Thread_Manager; /** diff --git a/ace/Thread_Hook.cpp b/ace/Thread_Hook.cpp index 4d7a582f6c5..d0472c5fac7 100644 --- a/ace/Thread_Hook.cpp +++ b/ace/Thread_Hook.cpp @@ -1,7 +1,7 @@ // $Id$ #include "ace/Thread_Hook.h" -#include "ace/OS.h" +#include "ace/Object_Manager_Base.h" ACE_RCSID(ace, Thread_Hook, "$Id$") diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index 049f8776181..e8be214ad66 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -29,6 +29,7 @@ #include "ace/Singleton.h" #include "ace/Log_Msg.h" #include "ace/Synch_Traits.h" +#include "ace/Basic_Types.h" // The following macros control how a Thread Manager manages a pool of // Thread_Descriptor. Currently, the default behavior is not to diff --git a/ace/Thread_Mutex.cpp b/ace/Thread_Mutex.cpp index 000c7f00bbb..0c7f3e45442 100644 --- a/ace/Thread_Mutex.cpp +++ b/ace/Thread_Mutex.cpp @@ -17,6 +17,8 @@ #include "ace/Thread_Mutex.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" + ACE_RCSID(ace, Thread_Mutex, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Mutex_Guard) diff --git a/ace/Thread_Mutex.h b/ace/Thread_Mutex.h index dc6c1b52788..2c7f32bf7f5 100644 --- a/ace/Thread_Mutex.h +++ b/ace/Thread_Mutex.h @@ -28,7 +28,7 @@ // ACE platform supports some form of threading. #include "ace/ACE_export.h" -#include "ace/OS.h" +#include "ace/OS_NS_Thread.h" /** * @class ACE_Thread_Mutex diff --git a/ace/Time_Value.cpp b/ace/Time_Value.cpp index a9153981576..603fe34ea17 100644 --- a/ace/Time_Value.cpp +++ b/ace/Time_Value.cpp @@ -199,3 +199,69 @@ ACE_Time_Value::normalize (void) this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; } } + +/*****************************************************************************/ +// These need to be moved to another file due unresolvable dependency +// issues with inlining. + +ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time) + : max_wait_time_ (max_wait_time), + stopped_ (0) +{ + this->start (); +} + +ACE_Countdown_Time::~ACE_Countdown_Time (void) +{ + this->stop (); +} + +/*****************************************************************************/ + +//ACE_INLINE +int +ACE_Countdown_Time::start (void) +{ + if (this->max_wait_time_ != 0) + { + this->start_time_ = ACE_OS::gettimeofday (); + this->stopped_ = 0; + } + return 0; +} + +//ACE_INLINE +int +ACE_Countdown_Time::stopped (void) const +{ + return stopped_; +} + +//ACE_INLINE +int +ACE_Countdown_Time::stop (void) +{ + if (this->max_wait_time_ != 0 && this->stopped_ == 0) + { + ACE_Time_Value elapsed_time = + ACE_OS::gettimeofday () - this->start_time_; + + if (*this->max_wait_time_ > elapsed_time) + *this->max_wait_time_ -= elapsed_time; + else + { + // Used all of timeout. + *this->max_wait_time_ = ACE_Time_Value::zero; + // errno = ETIME; + } + this->stopped_ = 1; + } + return 0; +} + +//ACE_INLINE +int +ACE_Countdown_Time::update (void) +{ + return this->stop () == 0 && this->start (); +} diff --git a/ace/Time_Value.h b/ace/Time_Value.h index f6792d5a1d5..dff278f063d 100644 --- a/ace/Time_Value.h +++ b/ace/Time_Value.h @@ -321,6 +321,50 @@ private: timeval tv_; }; +/** + * @class ACE_Countdown_Time + * + * @brief Keeps track of the amount of elapsed time. + * + * This class has a side-effect on the <max_wait_time> -- every + * time the <stop> method is called the <max_wait_time> is + * updated. + */ +class ACE_OS_Export ACE_Countdown_Time +{ +public: + // = Initialization and termination methods. + /// Cache the <max_wait_time> and call <start>. + ACE_Countdown_Time (ACE_Time_Value *max_wait_time); + + /// Call <stop>. + ~ACE_Countdown_Time (void); + + /// Cache the current time and enter a start state. + int start (void); + + /// Subtract the elapsed time from max_wait_time_ and enter a stopped + /// state. + int stop (void); + + /// Calls stop and then start. max_wait_time_ is modified by the + /// call to stop. + int update (void); + + /// Returns 1 if we've already been stopped, else 0. + int stopped (void) const; + +private: + /// Maximum time we were willing to wait. + ACE_Time_Value *max_wait_time_; + + /// Beginning of the start time. + ACE_Time_Value start_time_; + + /// Keeps track of whether we've already been stopped. + int stopped_; +}; + #if defined (__ACE_INLINE__) #include "ace/Time_Value.inl" #endif /* __ACE_INLINE__ */ diff --git a/ace/Time_Value.inl b/ace/Time_Value.inl index 95fba6c98d1..f41f0ee88f9 100644 --- a/ace/Time_Value.inl +++ b/ace/Time_Value.inl @@ -2,6 +2,7 @@ // // $Id$ +#include "ace/OS_NS_sys_time.h" // Returns the value of the object as a timeval. @@ -327,3 +328,4 @@ operator - (const ACE_Time_Value &tv1, delta.normalize (); return delta; } + diff --git a/ace/Timeprobe.cpp b/ace/Timeprobe.cpp index b1edbf1b54e..1738da19618 100644 --- a/ace/Timeprobe.cpp +++ b/ace/Timeprobe.cpp @@ -1,6 +1,6 @@ // $Id$ -#include "ace/OS.h" +#include "ace/config-all.h" ACE_RCSID(ace, Timeprobe, "$Id$") diff --git a/ace/Timeprobe.h b/ace/Timeprobe.h index e12636a78de..243a8ffaa0c 100644 --- a/ace/Timeprobe.h +++ b/ace/Timeprobe.h @@ -40,13 +40,19 @@ #include /**/ "ace/pre.h" #include "ace/ACE_export.h" -#include "ace/OS.h" #include "ace/Malloc_Allocator.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +/* Enable ACE Timeprobes */ +#if defined (ACE_ENABLE_TIMEPROBES) + #if !defined (ACE_COMPILE_TIMEPROBES) + #define ACE_COMPILE_TIMEPROBES + #endif /* ACE_COMPILE_TIMEPROBES */ +#endif /* ACE_ENABLE_TIMEPROBES */ + #if defined (ACE_COMPILE_TIMEPROBES) /** diff --git a/ace/Timeprobe_T.cpp b/ace/Timeprobe_T.cpp index a0491472234..8356e6e4296 100644 --- a/ace/Timeprobe_T.cpp +++ b/ace/Timeprobe_T.cpp @@ -3,7 +3,7 @@ #ifndef ACE_TIMEPROBE_T_C #define ACE_TIMEPROBE_T_C -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Timeprobe_T.h b/ace/Timeprobe_T.h index 599951fc43d..9867a540d02 100644 --- a/ace/Timeprobe_T.h +++ b/ace/Timeprobe_T.h @@ -14,7 +14,8 @@ #ifndef ACE_TIMEPROBE_T_H #define ACE_TIMEPROBE_T_H #include /**/ "ace/pre.h" -#include "ace/OS.h" + +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Timer_Heap_T.cpp b/ace/Timer_Heap_T.cpp index 5ef38cd70af..f3021edfd89 100644 --- a/ace/Timer_Heap_T.cpp +++ b/ace/Timer_Heap_T.cpp @@ -5,6 +5,7 @@ #include "ace/Timer_Heap_T.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Timer_Queue_Adapters.cpp b/ace/Timer_Queue_Adapters.cpp index 00d5723d80a..e1c9413f477 100644 --- a/ace/Timer_Queue_Adapters.cpp +++ b/ace/Timer_Queue_Adapters.cpp @@ -15,6 +15,8 @@ ACE_RCSID(ace, Timer_Queue_Adapters, "$Id$") # include "ace/Timer_Queue_Adapters.i" # endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_unistd.h" + template <class TQ> TQ & ACE_Async_Timer_Queue_Adapter<TQ>::timer_queue (void) { diff --git a/ace/Timer_Queue_T.cpp b/ace/Timer_Queue_T.cpp index 6909c2ce9f2..7ab266d511b 100644 --- a/ace/Timer_Queue_T.cpp +++ b/ace/Timer_Queue_T.cpp @@ -14,6 +14,7 @@ #include "ace/Log_Msg.h" #include "ace/Reactor_Timer_Interface.h" #include "ace/Null_Mutex.h" +#include "ace/OS_NS_sys_time.h" #if !defined (__ACE_INLINE__) #include "ace/Timer_Queue_T.i" diff --git a/ace/Token.h b/ace/Token.h index fdc48ecc3ad..ef2ffb21acd 100644 --- a/ace/Token.h +++ b/ace/Token.h @@ -27,7 +27,6 @@ #if defined (ACE_HAS_THREADS) -#include "ace/OS.h" #include "ace/Thread_Mutex.h" #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || defined (VXWORKS) || defined (ACE_PSOS) diff --git a/ace/Token.i b/ace/Token.i index 4892f11b131..5cea9866cea 100644 --- a/ace/Token.i +++ b/ace/Token.i @@ -7,6 +7,8 @@ #if defined (ACE_HAS_THREADS) +#include "ace/Time_Value.h" + ACE_INLINE int ACE_Token::queueing_strategy (void) { diff --git a/ace/Trace.cpp b/ace/Trace.cpp index 25ad1d27022..5869f8bef45 100644 --- a/ace/Trace.cpp +++ b/ace/Trace.cpp @@ -14,7 +14,7 @@ ACE_RCSID (ace, #define ACE_NTRACE 1 #include "ace/Log_Msg.h" -#include "ace/OS.h" +#include "ace/Object_Manager_Base.h" // = Static initialization. diff --git a/ace/UNIX_Addr.i b/ace/UNIX_Addr.i index 2ef10e67556..d70ec1ffaa9 100644 --- a/ace/UNIX_Addr.i +++ b/ace/UNIX_Addr.i @@ -1,8 +1,11 @@ + /* -*- C++ -*- */ // $Id$ // UNIX_Addr.i +#include "ace/OS_NS_string.h" + #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) // Return a pointer to the underlying address. diff --git a/ace/UUID.cpp b/ace/UUID.cpp index 7a846cee69f..8137d16bd60 100644 --- a/ace/UUID.cpp +++ b/ace/UUID.cpp @@ -1,12 +1,16 @@ //$Id$ -#include "ace/OS.h" -#include "ace/Log_Msg.h" + #include "ace/UUID.h" #if !defined (__ACE_INLINE__) #include "ace/UUID.inl" #endif /* __ACE_INLINE__ */ +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_netdb.h" + ACE_RCSID (ace, UUID, "$Id$") diff --git a/ace/UUID.h b/ace/UUID.h index 631ac673eca..66bc291d785 100644 --- a/ace/UUID.h +++ b/ace/UUID.h @@ -14,7 +14,7 @@ #define ACE_UUID_H #include /**/ "ace/pre.h" -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Unbounded_Set.h b/ace/Unbounded_Set.h index 369dd849198..b185063c6af 100644 --- a/ace/Unbounded_Set.h +++ b/ace/Unbounded_Set.h @@ -15,6 +15,7 @@ #include /**/ "ace/pre.h" #include "ace/Node.h" +#include "ace/os_include/os_stddef.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/WFMO_Reactor.cpp b/ace/WFMO_Reactor.cpp index 11652d7b87a..735883f5540 100644 --- a/ace/WFMO_Reactor.cpp +++ b/ace/WFMO_Reactor.cpp @@ -7,6 +7,7 @@ #include "ace/Handle_Set.h" #include "ace/Timer_Heap.h" #include "ace/Thread.h" +#include "ace/OS_NS_errno.h" #if !defined (__ACE_INLINE__) #include "ace/WFMO_Reactor.i" diff --git a/ace/WIN32_Asynch_IO.cpp b/ace/WIN32_Asynch_IO.cpp index 6e8346850d2..0a95863ca95 100644 --- a/ace/WIN32_Asynch_IO.cpp +++ b/ace/WIN32_Asynch_IO.cpp @@ -11,6 +11,7 @@ ACE_RCSID (ace, #include "ace/Service_Config.h" #include "ace/INET_Addr.h" #include "ace/Task_T.h" +#include "ace/OS_NS_errno.h" size_t ACE_WIN32_Asynch_Result::bytes_transferred (void) const diff --git a/ace/WIN32_Asynch_IO.h b/ace/WIN32_Asynch_IO.h index ee3e18c3716..b9d875164b1 100644 --- a/ace/WIN32_Asynch_IO.h +++ b/ace/WIN32_Asynch_IO.h @@ -34,7 +34,6 @@ #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) -#include "ace/OS.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Addr.h" #include "ace/Event_Handler.h" diff --git a/ace/WIN32_Proactor.cpp b/ace/WIN32_Proactor.cpp index dfbbe4fd025..8013f0807c8 100644 --- a/ace/WIN32_Proactor.cpp +++ b/ace/WIN32_Proactor.cpp @@ -9,6 +9,7 @@ #include "ace/Log_Msg.h" #include "ace/Object_Manager.h" +#include "ace/OS_NS_errno.h" /** * @class ACE_WIN32_Wakeup_Completion diff --git a/ace/WIN32_Proactor.h b/ace/WIN32_Proactor.h index 56f2aab5e14..fef14f7f172 100644 --- a/ace/WIN32_Proactor.h +++ b/ace/WIN32_Proactor.h @@ -27,7 +27,6 @@ #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) // WIN32 implementation of the Proactor. -#include "ace/OS.h" #include "ace/WIN32_Asynch_IO.h" #include "ace/Event_Handler.h" diff --git a/ace/ace.mpc b/ace/ace.mpc index d01e04067cd..d7d77717729 100644 --- a/ace/ace.mpc +++ b/ace/ace.mpc @@ -11,11 +11,45 @@ project(ACE) : acedefaults, aceversion, core, qt_moc, qt_reactor { OS { Basic_Types.cpp Time_Value.cpp - OS.cpp - OS_Dirent.cpp - OS_Memory.cpp + Cleanup.cpp + Object_Manager_Base.cpp + //OS.cpp + //OS_Dirent.cpp + //OS_Memory.cpp OS_QoS.cpp - OS_String.cpp + //OS_String.cpp + OS_NS_arpa_inet.cpp + OS_NS_fcntl.cpp + OS_NS_regex.cpp + OS_NS_strings.cpp + OS_NS_sys_select.cpp + OS_NS_sys_uio.cpp + OS_NS_unistd.cpp + OS_NS_ctype.cpp + OS_NS_math.cpp + OS_NS_signal.cpp + OS_NS_stropts.cpp + OS_NS_sys_shm.cpp + OS_NS_sys_utsname.cpp + OS_NS_wchar.cpp + OS_NS_dirent.cpp + OS_NS_netdb.cpp + OS_NS_stdio.cpp + OS_NS_sys_mman.cpp + OS_NS_sys_socket.cpp + OS_NS_sys_wait.cpp + OS_NS_dlfcn.cpp + OS_NS_poll.cpp + OS_NS_stdlib.cpp + OS_NS_sys_msg.cpp + OS_NS_sys_stat.cpp + OS_NS_Thread.cpp + OS_NS_errno.cpp + OS_NS_pwd.cpp + OS_NS_string.cpp + OS_NS_sys_resource.cpp + OS_NS_sys_time.cpp + OS_NS_time.cpp OS_TLI.cpp OS_Errno.cpp ARGV.cpp @@ -88,7 +122,22 @@ project(ACE) : acedefaults, aceversion, core, qt_moc, qt_reactor { Atomic_Op.cpp Process.cpp Process_Manager.cpp - Synch.cpp + //Synch.cpp + TSS_Adapter.cpp + Auto_Event.cpp + Manual_Event.cpp + Barrier.cpp + Condition_Thread_Mutex.cpp + Condition_Recursive_Thread_Mutex.cpp + Event.cpp + Lock.cpp + Mutex.cpp + RW_Mutex.cpp + RW_Thread_Mutex.cpp + Recursive_Thread_Mutex.cpp + Semaphore.cpp + Thread_Mutex.cpp + Thread_Semaphore.cpp Synch_Options.cpp Process_Semaphore.cpp Process_Mutex.cpp diff --git a/ace/config-all.h b/ace/config-all.h index 0c5f03c2cd6..9462bd35f08 100644 --- a/ace/config-all.h +++ b/ace/config-all.h @@ -23,6 +23,13 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +// By default we perform no tracing on the OS layer, otherwise the +// coupling between the OS layer and Log_Msg is too tight. But the +// application can override the default if they wish to. +# if !defined(ACE_OS_TRACE) +# define ACE_OS_TRACE(X) +# endif /* ACE_OS_TRACE */ + #define ACE_BITS_PER_ULONG (8 * sizeof (u_long)) #if !defined (ACE_OSTREAM_TYPE) @@ -692,6 +699,9 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ # define ACE_NOTSUP do { errno = ENOTSUP; return; } while (0) #endif /* ! ACE_HAS_VERBOSE_NOTSUP */ +// empty ACE_OS namespace to help identify compiler errors more easily. +namespace ACE_OS {} + #include /**/ "ace/post.h" #endif /* ACE_CONFIG_ALL_H */ diff --git a/ace/config-vxworks5.x.h b/ace/config-vxworks5.x.h index 85bc5c4040a..20cb1b723e6 100644 --- a/ace/config-vxworks5.x.h +++ b/ace/config-vxworks5.x.h @@ -83,6 +83,10 @@ # error unsupported compiler on VxWorks #endif /* ! __GNUG__ && ! ghs */ +#if defined (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 +# define ACE_LACKS_ARPA_INET_H +#endif /* ! (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 */ + // OS-specific configuration #define ACE_LACKS_UNIX_SYSLOG diff --git a/ace/config-win32-msvc.h b/ace/config-win32-msvc.h index 2bc7efdb98d..af74f73ca72 100644 --- a/ace/config-win32-msvc.h +++ b/ace/config-win32-msvc.h @@ -82,6 +82,17 @@ #define ACE_LACKS_SYS_WAIT_H #define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_SEMAPHORE_H +#define ACE_LACKS_STRINGS_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_NETINET_TCP_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_REGEX_H + + // Turn off warnings for /W4 // To resume any of these warning: #pragma warning(default: 4xxx) // which should be placed after these defines diff --git a/ace/gethrtime.cpp b/ace/gethrtime.cpp index 08de489f7f6..b242ef2db27 100644 --- a/ace/gethrtime.cpp +++ b/ace/gethrtime.cpp @@ -5,7 +5,7 @@ // knew a way to correctly move values from registers to a 64-bit // variable in GHS asm code. That's easy with g++ asm. -#include "ace/OS.h" +#include "ace/config-all.h" ACE_RCSID(ace, gethrtime, "$Id$") diff --git a/ace/os_include/arpa/os_inet.h b/ace/os_include/arpa/os_inet.h index b425a5d3b3f..2819c522714 100644 --- a/ace/os_include/arpa/os_inet.h +++ b/ace/os_include/arpa/os_inet.h @@ -36,13 +36,39 @@ # include /**/ <inetLib.h> #endif /* VXWORKS */ +/** + * In some environments it is useful to swap the bytes on write, for + * instance: a fast server can be feeding a lot of slow clients that + * happen to have the wrong byte order. + * Because this is a rarely used feature we disable it by default to + * minimize footprint. + * This macro enables the functionality, but we still need a way to + * activate it on a per-connection basis. + */ +// #define ACE_ENABLE_SWAP_ON_WRITE + +/** + * In some environements we never need to swap bytes when reading, for + * instance embebbed systems (such as avionics) or homogenous + * networks. + * Setting this macro disables the capabilities to demarshall streams + * in the wrong byte order. + */ +// #define ACE_DISABLE_SWAP_ON_READ + // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -// @todo move the ACE_HTONL, etc macros here +#if defined (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 + // 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 *); +#endif /* ! (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 */ #ifdef __cplusplus } diff --git a/ace/os_include/netinet/os_in.h b/ace/os_include/netinet/os_in.h index d831515bad3..88e25e3f507 100644 --- a/ace/os_include/netinet/os_in.h +++ b/ace/os_include/netinet/os_in.h @@ -49,6 +49,25 @@ extern "C" { #endif /* __cplusplus */ +# 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_IP_MULTICAST) && defined (ACE_LACKS_IP_ADD_MEMBERSHIP) + // Even if ACE_HAS_IP_MULTICAST is not defined, if IP_ADD_MEMBERSHIP + // is defined, assume that the ip_mreq struct is also defined + // (presumably in netinet/in.h). + struct ip_mreq + { + /// IP multicast address of group + struct in_addr imr_multiaddr; + /// Local IP address of interface + struct in_addr imr_interface; + }; +# endif /* ! ACE_HAS_IP_MULTICAST && ACE_LACKS_IP_ADD_MEMBERSHIP */ + #if !defined (IPPORT_RESERVED) # define IPPORT_RESERVED 1024 #endif /* !IPPORT_RESERVED */ @@ -80,6 +99,35 @@ extern "C" # define INET6_ADDRSTRLEN 46 #endif /* INET6_ADDRSTRLEN */ +# 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 */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/netinet/os_tcp.h b/ace/os_include/netinet/os_tcp.h index bf9886ef632..85facbfd4a6 100644 --- a/ace/os_include/netinet/os_tcp.h +++ b/ace/os_include/netinet/os_tcp.h @@ -24,10 +24,24 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +// @todo: remove this, and fix references when you get a chance... dhinton +#if defined (ACE_LACKS_TCP_H) +# define ACE_LACKS_NETINET_TCP_H +#endif /* ACE_LACKS_TCP_H */ + #if !defined (ACE_LACKS_NETINET_TCP_H) # include /**/ <netinet/tcp.h> #endif /* !ACE_LACKS_NETIINET_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 /* ACE_HAS_CONFLICTING_XTI_MACROS */ + // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus extern "C" diff --git a/ace/os_include/os_dirent.h b/ace/os_include/os_dirent.h index 32c92249e0b..d76f0f4010b 100644 --- a/ace/os_include/os_dirent.h +++ b/ace/os_include/os_dirent.h @@ -45,6 +45,13 @@ extern "C" # define MAXNAMLEN NAME_MAX #endif /* !MAXNAMLEN */ +# if defined (ACE_PSOS) +// pHILE+ calls the DIR struct XDIR instead +# if !defined (ACE_PSOS_DIAB_PPC) +typedef XDIR ACE_DIR; +# endif /* !defined (ACE_PSOS_DIAB_PPC) */ +# endif /* ACE_PSOS */ + // At least compile on some of the platforms without <ACE_DIR> info yet. #if !defined (ACE_HAS_DIRENT) typedef int ACE_DIR; diff --git a/ace/os_include/os_dlfcn.h b/ace/os_include/os_dlfcn.h index a0b5934c2cd..91864eae5e0 100644 --- a/ace/os_include/os_dlfcn.h +++ b/ace/os_include/os_dlfcn.h @@ -55,6 +55,13 @@ extern "C" { #endif /* __cplusplus */ +#if defined (_M_UNIX) + int _dlclose (void *); + char *_dlerror (void); + void *_dlopen (const char *, int); + void * _dlsym (void *, const char *); +#endif /* _M_UNIX */ + /* 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 */ diff --git a/ace/os_include/os_fcntl.h b/ace/os_include/os_fcntl.h index 13b47486786..4f7e3ec02fd 100644 --- a/ace/os_include/os_fcntl.h +++ b/ace/os_include/os_fcntl.h @@ -80,12 +80,20 @@ extern "C" # define O_NDELAY 1 #endif /* ACE_WIN32 */ +# 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 (F_GETFL) +# define F_GETFL 0 +# endif /* F_GETFL */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_limits.h b/ace/os_include/os_limits.h index 0501064ea08..d03eedef7ec 100644 --- a/ace/os_include/os_limits.h +++ b/ace/os_include/os_limits.h @@ -101,6 +101,24 @@ extern "C" # define PIPE_BUF 5120 #endif /* PIPE_BUF */ +#if defined (ACE_HAS_POSIX_REALTIME_SIGNALS) + // = Giving unique ACE scoped names for some important + // RTSignal-Related constants. Becuase sometimes, different + // platforms use different names for these constants. + + // Number of realtime signals provided in the system. + // _POSIX_RTSIG_MAX is the upper limit on the number of real time + // signals supported in a posix-4 compliant system. +# if defined (_POSIX_RTSIG_MAX) +# define ACE_RTSIG_MAX _POSIX_RTSIG_MAX +# else /* not _POSIX_RTSIG_MAX */ + // POSIX-4 compilant system has to provide atleast 8 RT signals. + // @@ Make sure the platform does *not* define this constant with + // some other name. If yes, use that instead of 8. +# define ACE_RTSIG_MAX 8 +# endif /* _POSIX_RTSIG_MAX */ +#endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_pthread.h b/ace/os_include/os_pthread.h index 030730a8a6b..574e0d9c71c 100644 --- a/ace/os_include/os_pthread.h +++ b/ace/os_include/os_pthread.h @@ -24,6 +24,18 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#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 */ + #include "ace/os_include/sys/os_types.h" // This needs to go here *first* to avoid problems with AIX. @@ -362,8 +374,7 @@ extern "C" pthread_t pthread_self (void); */ class ACE_OS_Export ACE_sema_t { -friend class ACE_OS; -protected: +public: /// Serialize access to internal state. ACE_mutex_t lock_; diff --git a/ace/os_include/os_regex.h b/ace/os_include/os_regex.h index df0634b2510..fdc323c2a6d 100644 --- a/ace/os_include/os_regex.h +++ b/ace/os_include/os_regex.h @@ -30,6 +30,10 @@ # include /**/ <regex.h> #endif /* !ACE_LACKS_REGEX_H */ +#if defined (ACE_HAS_REGEX) +# include /**/ <regexpr.h> +#endif /* ACE_HAS_REGEX */ + // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus extern "C" diff --git a/ace/os_include/os_signal.h b/ace/os_include/os_signal.h index 4668e1f8b33..7c6fa25fdcb 100644 --- a/ace/os_include/os_signal.h +++ b/ace/os_include/os_signal.h @@ -51,9 +51,15 @@ #if defined (VXWORKS) # include /**/ <sigLib.h> -# define NSIG (_NSIGS + 1) #endif /* VXWORKS */ +// should this be extern "C" {}? +#if defined (CHORUS) +# if !defined(CHORUS_4) +typedef void (*__sighandler_t)(int); // keep Signal compilation happy +# endif +#endif /* CHORUS */ + // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus extern "C" @@ -90,6 +96,14 @@ extern "C" typedef int sig_atomic_t; #endif /* !ACE_HAS_SIG_ATOMIC_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 (SIGHUP) # define SIGHUP 0 #endif /* SIGHUP */ @@ -180,6 +194,21 @@ extern "C" # endif /* NSIG */ #endif /* ACE_PSOS && !ACE_PSOSIM */ +#if defined (VXWORKS) +# define NSIG (_NSIGS + 1) +#elif defined (__Lynx__) + // LynxOS Neutrino sets NSIG to the highest-numbered signal. +# define ACE_NSIG (NSIG + 1) +#elif defined (__rtems__) +# define ACE_NSIG (SIGRTMAX) +#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x600) +# define ACE_NSIG _NSIG +#else + // All other platforms set NSIG to one greater than the + // highest-numbered signal. +# define ACE_NSIG NSIG +#endif /* __Lynx__ */ + #if defined (ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES) // Prototypes for both signal() and struct sigaction are consistent.. //# if defined (ACE_HAS_SIG_C_FUNC) @@ -259,6 +288,34 @@ extern "C" #endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ +#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. + 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__) + int sigwait (const sigset_t *set, int *sig); +# else + int sigwait (sigset_t *set); +# endif /* __rtems__ */ +#endif /* ! DIGITAL_UNIX && ! ACE_HAS_SIGWAIT */ + +#if !defined (ACE_WIN32) + typedef void (*ACE_SIGNAL_C_FUNC)(int,siginfo_t*,void*); +#endif /* ACE_WIN32 */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_stdio.h b/ace/os_include/os_stdio.h index 673802faba0..4036b631e3e 100644 --- a/ace/os_include/os_stdio.h +++ b/ace/os_include/os_stdio.h @@ -45,9 +45,13 @@ extern "C" { #endif /* __cplusplus */ -#if !defined (ACE_WIN32) && !defined (INTEGRITY) +# if defined (INTEGRITY) +# define ACE_MAX_USERID 32 +# elif defined (ACE_WIN32) +# define ACE_MAX_USERID 32 +# else # define ACE_MAX_USERID L_cuserid -#endif /*!ACE_WIN32*/ +#endif /* INTEGRITY */ // this is a nasty hack to get around problems with the // pSOS definition of BUFSIZ as the config table entry diff --git a/ace/os_include/os_stdlib.h b/ace/os_include/os_stdlib.h index e1bc4c9a042..95d56f67c54 100644 --- a/ace/os_include/os_stdlib.h +++ b/ace/os_include/os_stdlib.h @@ -67,6 +67,12 @@ extern "C" int putenv (char *); // stdlib.h #endif /* ACE_PSOS_SNARFS_HEADER_INFO */ +// These prototypes are chronically lacking from many versions of +// UNIX. +#if !defined (ACE_WIN32) && defined (ACE_LACKS_MKTEMP) + char *mktemp (char *); +#endif /* !ACE_WIN32 && ACE_LACKS_MKTEMP */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_string.h b/ace/os_include/os_string.h index d56a1117ca4..2af1d2901f8 100644 --- a/ace/os_include/os_string.h +++ b/ace/os_include/os_string.h @@ -26,9 +26,18 @@ #include "ace/os_include/os_stddef.h" -#if !defined (ACE_LACKS_STRING_H) -# include /**/ <string.h> -#endif /* !ACE_LACKS_STRING_H */ +// 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 */ +# if !defined (ACE_LACKS_STRING_H) +# include /**/ <string.h> +# endif /* !ACE_LACKS_STRING_H */ +#endif /* ACE_HAS_GNU_CSTRING_H */ // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus @@ -36,6 +45,16 @@ extern "C" { #endif /* __cplusplus */ + // this looks fishy... dhinton +#if !defined (ACE_HAS_STRERROR) +# if defined (ACE_HAS_SYS_ERRLIST) + extern char *sys_errlist[]; +# define strerror(err) sys_errlist[err] +# else +# define strerror(err) "strerror is unsupported" +# endif /* ACE_HAS_SYS_ERRLIST */ +#endif /* !ACE_HAS_STERROR */ + #if defined (ACE_LACKS_STRTOK_R_PROTOTYPE) && !defined (_POSIX_SOURCE) char *strtok_r (char *s, const char *delim, char **save_ptr); #endif /* ACE_LACKS_STRTOK_R_PROTOTYPE */ @@ -45,12 +64,6 @@ extern "C" # define _strnicmp strnicmp #endif /* __BORLANDC__ */ -#if defined (ACE_HAS_CHARPTR_SPRINTF) -# define ACE_SPRINTF_ADAPTER(X) ::strlen (X) -#else -# define ACE_SPRINTF_ADAPTER(X) X -#endif /* ACE_HAS_CHARPTR_SPRINTF */ - #if defined (ACE_PSOS_SNARFS_HEADER_INFO) // Header information snarfed from compiler provided header files // that are not included because there is already an identically diff --git a/ace/os_include/os_strings.h b/ace/os_include/os_strings.h index 789b6b3fbbe..50843d0fc0c 100644 --- a/ace/os_include/os_strings.h +++ b/ace/os_include/os_strings.h @@ -26,11 +26,6 @@ #include "ace/os_include/os_stddef.h" -// The is for backward compatibility and needs to be fixed in the config files. -#if !defined (ACE_HAS_STRINGS) -# define ACE_LACKS_STRINGS_H -#endif /* !ACE_HAS_STRINGS */ - #if !defined (ACE_LACKS_STRINGS_H) # include /**/ <strings.h> #endif /* !ACE_LACKS_STRINGS_H */ diff --git a/ace/os_include/os_stropts.h b/ace/os_include/os_stropts.h index 65fff659b2f..d4113e49983 100644 --- a/ace/os_include/os_stropts.h +++ b/ace/os_include/os_stropts.h @@ -50,10 +50,28 @@ # include /**/ <sys/sockio.h> #endif /* ACE_HAS_SOCKIO_ */ +// This is sorta counter intuitive, but this is how it was done in OS.h +// @todo: fix this... dhinton +#if defined (ACE_HAS_STREAMS) +# if defined (AIX) +# if !defined (_XOPEN_EXTENDED_SOURCE) +# define _XOPEN_EXTENDED_SOURCE +# endif /* !_XOPEN_EXTENDED_SOURCE */ +# endif /* AIX */ +#endif /* ACE_HAS_STREAMS */ + #if !defined (ACE_LACKS_STROPTS_H) # include /**/ <stropts.h> #endif /* !ACE_LACKS_STROPTS_H */ +// This is sorta counter intuitive, but this is how it was done in OS.h +// @todo: fix this... dhinton +#if defined (ACE_HAS_STREAMS) +# if defined (AIX) +# undef _XOPEN_EXTENDED_SOURCE +# endif /* AIX */ +#endif /* ACE_HAS_STREAMS */ + #if defined (VXWORKS) // for ioctl() # include /**/ <ioLib.h> @@ -69,6 +87,32 @@ extern "C" struct strrecvfd {}; #endif /* ACE_LACKS_STRRECVFD */ +# if !defined (SIOCGIFBRDADDR) +# define SIOCGIFBRDADDR 0 +# endif /* SIOCGIFBRDADDR */ + +# if !defined (SIOCGIFADDR) +# define SIOCGIFADDR 0 +# endif /* SIOCGIFADDR */ + +# if !defined (ACE_HAS_STRBUF_T) +struct strbuf +{ + /// No. of bytes in buffer. + int maxlen; + /// No. of bytes returned. + int len; + /// Pointer to data. + void *buf; +}; +# endif /* ACE_HAS_STRBUF_T */ + +// These prototypes are chronically lacking from many versions of +// UNIX. +#if !defined (ACE_WIN32) && !defined (ACE_HAS_ISASTREAM_PROTO) + int isastream (int); +#endif /* !ACE_WIN32 && ACE_HAS_ISASTREAM_PROTO */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_time.h b/ace/os_include/os_time.h index 14e843ab03f..6ba9cc45aa9 100644 --- a/ace/os_include/os_time.h +++ b/ace/os_include/os_time.h @@ -31,6 +31,17 @@ # include /**/ <time.h> #endif /* !ACE_LACKS_TIME_H */ +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) +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 */ + // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus extern "C" @@ -70,6 +81,12 @@ extern "C" # endif /* defined (ACE_PSOS_DIAB_PPC) */ #endif /* defined (ACE_PSOS) && !defined (USER_INCLUDE_SYS_TIME_TM) */ +#if defined (ACE_LACKS_CONST_TIMESPEC_PTR) +typedef struct timespec * ACE_TIMESPEC_PTR; +#else +typedef const struct timespec * ACE_TIMESPEC_PTR; +#endif /* HPUX */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_ucontext.h b/ace/os_include/os_ucontext.h index e04c7228374..67ce5ba9b10 100644 --- a/ace/os_include/os_ucontext.h +++ b/ace/os_include/os_ucontext.h @@ -36,6 +36,10 @@ extern "C" { #endif /* __cplusplus */ +# if !defined (ACE_HAS_UCONTEXT_T) +typedef int ucontext_t; +# endif /* ACE_HAS_UCONTEXT_T */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/os_unistd.h b/ace/os_include/os_unistd.h index a9ca19f0ec2..c7d7aafc3a5 100644 --- a/ace/os_include/os_unistd.h +++ b/ace/os_include/os_unistd.h @@ -36,6 +36,10 @@ # include /**/ <io.h> #endif /* ACE_WIN32 && !ACE_HAS_WINCE */ +#if defined (ACE_HAS_SYSINFO) +# include /**/ <sys/systeminfo.h> +#endif /* ACE_HAS_SYS_INFO */ + #if !defined (ACE_LACKS_UNISTD_H) # include /**/ <unistd.h> #endif /* !ACE_LACKS_UNISTD_H */ @@ -52,6 +56,55 @@ extern "C" { #endif /* __cplusplus */ +#if (!defined (_BSD_SOURCE) && \ + !defined (_XOPEN_SOURCE) && !defined (_XOPEN_SOURCE_EXTENDED)) \ + || (defined (_XOPEN_SOURCE) && defined (__GNUC__)) + +# if defined (ACE_LACKS_SETREUID_PROTOTYPE) + extern int setreuid (uid_t ruid, uid_t euid); +# endif /* ACE_LACKS_SETREUID_PROTOTYPE */ + +# if defined (ACE_LACKS_SETREGID_PROTOTYPE) + extern int setregid (gid_t rgid, gid_t egid); +# endif /* ACE_LACKS_SETREGID_PROTOTYPE */ +#endif /* !_BSD_SOURCE && !_XOPEN_SOURCE && !_XOPEN_SOURCE_EXTENDED + || _XOPEN_SOURCE && __GNUC__ */ + +# 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 */ + + // for use by access() +# 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 (CHORUS) + int getgid __((void)); + int getuid __((void)); + char* getcwd __((char* buf, size_t size)); + int pipe __((int* fildes)); + int gethostname __((char*, size_t)); +#endif /* CHORUS */ + #if defined (ACE_LACKS_UALARM_PROTOTYPE) u_int ualarm (u_int usecs, u_int interval); #endif /* ACE_LACKS_UALARM_PROTOTYPE */ @@ -111,6 +164,20 @@ extern "C" int isatty (int h); #endif /* ACE_PSOS_SNARFS_HEADER_INFO */ +# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) + + ssize_t read_timedwait (ACE_HANDLE handle, + char *buf, + size_t n, + struct timespec *timeout); + + ssize_t write_timedwait (ACE_HANDLE handle, + const void *buf, + size_t n, + struct timespec *timeout); + +# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/sys/os_mman.h b/ace/os_include/sys/os_mman.h index 7014343bda6..d481cafaad8 100644 --- a/ace/os_include/sys/os_mman.h +++ b/ace/os_include/sys/os_mman.h @@ -76,10 +76,36 @@ PAGE_NOACCESS PAGE_NOCACHE */ #endif /* !ACE_LACKS_SYS_MMAN_H && !ACE_WIN32*/ +# 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 (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 */ + #if !defined (PROT_RDWR) # define PROT_RDWR (PROT_READ|PROT_WRITE) #endif /* PROT_RDWR */ +# if defined (ACE_WIN32) + // Needed to map calls to NT transparently. +# define MS_ASYNC 0 +# define MS_INVALIDATE 0 +# endif /* ACE_WIN32 */ + # if !defined (MS_SYNC) # define MS_SYNC 0x0 # endif /* !MS_SYNC */ diff --git a/ace/os_include/sys/os_resource.h b/ace/os_include/sys/os_resource.h index 1aa55705ffe..8245d5bf92e 100644 --- a/ace/os_include/sys/os_resource.h +++ b/ace/os_include/sys/os_resource.h @@ -37,6 +37,17 @@ extern "C" { #endif /* __cplusplus */ +// 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 */ + #if defined (ACE_HAS_BROKEN_SETRLIMIT) typedef struct rlimit ACE_SETRLIMIT_TYPE; #else @@ -52,8 +63,37 @@ extern "C" FILETIME ru_utime; FILETIME ru_stime; }; +#else /* !ACE_WIN32 */ +# if defined (m88k) +# define RUSAGE_SELF 1 +# endif /* m88k */ #endif /* ACE_WIN32 */ +#if defined (ACE_LACKS_RLIMIT_PROTOTYPE) + int getrlimit (int resource, struct rlimit *rlp); + int setrlimit (int resource, const struct rlimit *rlp); +#endif /* ACE_LACKS_RLIMIT_PROTOTYPE */ + +#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_WIN32) +// These prototypes are chronically lacking from many versions of +// UNIX. +# if !defined (ACE_HAS_GETRUSAGE_PROTO) + int getrusage (int who, struct rusage *rusage); +# endif /* ! ACE_HAS_GETRUSAGE_PROTO */ + +# if defined (ACE_LACKS_SYSCALL) + int syscall (int, ACE_HANDLE, struct rusage *); +# endif /* ACE_LACKS_SYSCALL */ +#endif /* !ACE_WIN32 */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/sys/os_select.h b/ace/os_include/sys/os_select.h index 21b8d4a4ae5..ae5f371abdf 100644 --- a/ace/os_include/sys/os_select.h +++ b/ace/os_include/sys/os_select.h @@ -44,6 +44,10 @@ extern "C" #if defined (ACE_WIN32) // This will help until we figure out everything: # define NFDBITS 32 /* only used in unused functions... */ +#elif defined (__QNX__) +# if !defined (NFDBITS) +# define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +# endif /* ! NFDBITS */ #endif /* ACE_WIN32 */ #if defined (ACE_SELECT_USES_INT) @@ -52,6 +56,11 @@ extern "C" typedef fd_set ACE_FD_SET_TYPE; #endif /* ACE_SELECT_USES_INT */ +#if defined (__rtems__) + int select (int n, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct timeval *timeout); +#endif /* __rtems__ */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/sys/os_sem.h b/ace/os_include/sys/os_sem.h index ef35feb3397..b0f3544dd26 100644 --- a/ace/os_include/sys/os_sem.h +++ b/ace/os_include/sys/os_sem.h @@ -36,6 +36,26 @@ extern "C" { #endif /* __cplusplus */ +# if !defined (GETVAL) +# define GETVAL 0 +# endif /* GETVAL */ + +# 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_LACKS_SEMBUF_T) struct sembuf { diff --git a/ace/os_include/sys/os_socket.h b/ace/os_include/sys/os_socket.h index 5c9ac3796a9..d0b69c0aef2 100644 --- a/ace/os_include/sys/os_socket.h +++ b/ace/os_include/sys/os_socket.h @@ -141,6 +141,14 @@ extern "C" # define ACE_PROTOCOL_FAMILY_INET PF_INET #endif /* ACE_HAS_IPV6 */ +#if defined (ACE_HAS_SOCKLEN_T) +typedef socklen_t ACE_SOCKET_LEN; +#elif defined (ACE_HAS_SIZET_SOCKET_LEN) +typedef size_t ACE_SOCKET_LEN; +#else +typedef int ACE_SOCKET_LEN; +#endif /* ACE_HAS_SIZET_SOCKET_LEN */ + #if defined (ACE_HAS_LKSCTP) extern "C" { @@ -148,6 +156,48 @@ extern "C" } #endif /* ACE_HAS_LKSCTP */ +# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) + + ssize_t recv_timedwait (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct timespec *timeout); + + ssize_t recvmsg_timedwait (ACE_HANDLE handle, + struct msghdr *msg, + int flags, + struct timespec *timeout); + + ssize_t recvfrom_timedwait (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct sockaddr *addr, + int *addrlen, + struct timespec *timeout); + + ssize_t send_timedwait (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + struct timespec *timeout); + + ssize_t sendmsg_timedwait (ACE_HANDLE handle, + ACE_SENDMSG_TYPE *msg, + int flags, + struct timespec *timeout); + + ssize_t sendto_timedwait (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + const struct sockaddr *addr, + int addrlen, + struct timespec *timeout); + +# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/sys/os_stat.h b/ace/os_include/sys/os_stat.h index e43c68ca282..7224eee9160 100644 --- a/ace/os_include/sys/os_stat.h +++ b/ace/os_include/sys/os_stat.h @@ -27,7 +27,7 @@ #include "ace/os_include/sys/os_types.h" #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) -# include <direct.h> +# include /**/ <direct.h> #endif /* ACE_WIN32 && !ACE_HAS_WINCE */ // This collides with phile.h on PSOS diff --git a/ace/os_include/sys/os_time.h b/ace/os_include/sys/os_time.h index 297a4ce084f..16336d47034 100644 --- a/ace/os_include/sys/os_time.h +++ b/ace/os_include/sys/os_time.h @@ -37,6 +37,18 @@ extern "C" { #endif /* __cplusplus */ +#if defined (ACE_HAS_SVR4_GETTIMEOFDAY) +# if !defined (m88k) && !defined (SCO) + int gettimeofday (struct timeval *tp, void * = 0); +# else + int gettimeofday (struct timeval *tp); +# endif /* !m88k && !SCO */ +#elif defined (ACE_HAS_OSF1_GETTIMEOFDAY) + int gettimeofday (struct timeval *tp, struct timezone * = 0); +#elif defined (ACE_HAS_SUNOS4_GETTIMEOFDAY) +# define ACE_HAS_SVR4_GETTIMEOFDAY +#endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/sys/os_times.h b/ace/os_include/sys/os_times.h index 13d75f8678f..62e69921e7d 100644 --- a/ace/os_include/sys/os_times.h +++ b/ace/os_include/sys/os_times.h @@ -24,7 +24,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/os_include/sys/types.h" +#include "ace/os_include/sys/os_types.h" #if !defined (ACE_LACKS_SYS_TIMES_H) # include /**/ <sys/times.h> diff --git a/ace/os_include/sys/os_types.h b/ace/os_include/sys/os_types.h index 800d35dbf3f..5ba552dde08 100644 --- a/ace/os_include/sys/os_types.h +++ b/ace/os_include/sys/os_types.h @@ -34,12 +34,23 @@ # include /**/ <types.h> #endif /* ACE_HAS_WINCE */ +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) +using std::time_t; +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ + // Place all additions (especially function declarations) within extern "C" {} #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +# if defined (ACE_LACKS_FLOATING_POINT) +typedef ACE_UINT32 ACE_timer_t; +# else +typedef double ACE_timer_t; +# endif /* ACE_LACKS_FLOATING_POINT */ + // todo: don't forget to clean this up! ;-) #if !defined (ACE_HAS_CLOCK_GETTIME) && !(defined (_CLOCKID_T_) || defined (_CLOCKID_T)) typedef int clockid_t; diff --git a/ace/os_include/sys/os_uio.h b/ace/os_include/sys/os_uio.h index 1cb7a6d2e71..6c39c1e15b8 100644 --- a/ace/os_include/sys/os_uio.h +++ b/ace/os_include/sys/os_uio.h @@ -75,6 +75,20 @@ extern "C" typedef struct iovec ACE_READV_TYPE; #endif /* ACE_HAS_BROKEN_READV */ +# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) + + ssize_t readv_timedwait (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + struct timespec* timeout); + + ssize_t writev_timedwait (ACE_HANDLE handle, + ACE_WRITEV_TYPE *iov, + int iovcnt, + struct timespec *timeout); + +# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ace/os_include/sys/os_wait.h b/ace/os_include/sys/os_wait.h index 8b36fedfe1d..8e6ec6e1624 100644 --- a/ace/os_include/sys/os_wait.h +++ b/ace/os_include/sys/os_wait.h @@ -37,9 +37,57 @@ extern "C" { #endif /* __cplusplus */ -#if !defined (WNOHANG) -# define WNOHANG 0100 -#endif /* !WNOHANG */ + // Wrapping around wait status <wstat> macros for platforms that + // lack them. + +# if !defined (WCOREDUMP) +# define WCOREDUMP(stat) 0 +# endif /* WCOREDUMP */ + +# if !defined (WNOHANG) +# define WNOHANG 0100 +# endif /* !WNOHANG */ + + // 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 */ + +# if !defined (WIFCONTINUED) +# define WIFCONTINUED(stat) 0 +# endif /* WIFCONTINUED */ + + // 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 */ + + // 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 !defined (WIFSTOPPED) +# define WIFSTOPPED(stat) 0 +# endif /* WIFSTOPPED */ + +# if !defined (WSTOPSIG) +# define WSTOPSIG(stat) 0 +# endif /* WSTOPSIG */ + + // 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 */ #ifdef __cplusplus } diff --git a/apps/Gateway/Gateway/Connection_Handler_Connector.cpp b/apps/Gateway/Gateway/Connection_Handler_Connector.cpp index 81645b1b3fb..a91d00f9e38 100644 --- a/apps/Gateway/Gateway/Connection_Handler_Connector.cpp +++ b/apps/Gateway/Gateway/Connection_Handler_Connector.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Connection_Handler_Connector.h" +#include "ace/os_include/os_netdb.h" ACE_RCSID(Gateway, Connection_Handler_Connector, "$Id$") diff --git a/apps/Gateway/Gateway/Event.h b/apps/Gateway/Gateway/Event.h index fe4ae2c2272..0b83febc92c 100644 --- a/apps/Gateway/Gateway/Event.h +++ b/apps/Gateway/Gateway/Event.h @@ -17,12 +17,14 @@ #ifndef EVENT_H #define EVENT_H -#include "ace/OS.h" +#include "ace/os_include/arpa/os_inet.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Basic_Types.h" + // = The following #defines should really be in a separate include // file that is shared with the ../Peer/ directory. For now, we'll // keep them here to simplify the sharing between the two directories. diff --git a/apps/Gateway/Gateway/Event_Channel.cpp b/apps/Gateway/Gateway/Event_Channel.cpp index 350a72a4c16..f993869ed58 100644 --- a/apps/Gateway/Gateway/Event_Channel.cpp +++ b/apps/Gateway/Gateway/Event_Channel.cpp @@ -4,6 +4,7 @@ #include "Connection_Handler_Connector.h" #include "Event_Channel.h" +#include "ace/OS_NS_sys_select.h" ACE_RCSID(Gateway, Event_Channel, "$Id$") diff --git a/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h b/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h index 10bc4409589..2a83a53a584 100644 --- a/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h +++ b/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h @@ -23,7 +23,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Synch.h" +#include "ace/Null_Mutex.h" #include "Event.h" #include "Consumer_Dispatch_Set.h" diff --git a/apps/Gateway/Gateway/File_Parser.cpp b/apps/Gateway/Gateway/File_Parser.cpp index 6f248e6762d..e108636a83e 100644 --- a/apps/Gateway/Gateway/File_Parser.cpp +++ b/apps/Gateway/Gateway/File_Parser.cpp @@ -4,7 +4,7 @@ #define FILE_PARSER_C -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/Gateway/Gateway/File_Parser.h b/apps/Gateway/Gateway/File_Parser.h index a91a8f75827..9b5033bf5a6 100644 --- a/apps/Gateway/Gateway/File_Parser.h +++ b/apps/Gateway/Gateway/File_Parser.h @@ -17,7 +17,7 @@ #ifndef _FILE_PARSER #define _FILE_PARSER -#include "ace/OS.h" +#include "ace/Basic_Types.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/Gateway/Gateway/Gateway.h b/apps/Gateway/Gateway/Gateway.h index cd50cfa6e8e..fe7d138b3a1 100644 --- a/apps/Gateway/Gateway/Gateway.h +++ b/apps/Gateway/Gateway/Gateway.h @@ -22,7 +22,6 @@ #ifndef ACE_GATEWAY #define ACE_GATEWAY -#include "ace/OS.h" #include "ace/svc_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) diff --git a/apps/Gateway/Gateway/Options.cpp b/apps/Gateway/Gateway/Options.cpp index d13848835bf..b97f5aab784 100644 --- a/apps/Gateway/Gateway/Options.cpp +++ b/apps/Gateway/Gateway/Options.cpp @@ -6,6 +6,9 @@ #include "Options.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/os_include/os_fcntl.h" ACE_RCSID(Gateway, Options, "$Id$") diff --git a/apps/Gateway/Gateway/Options.h b/apps/Gateway/Gateway/Options.h index 82bb7069c3a..c6913dd2310 100644 --- a/apps/Gateway/Gateway/Options.h +++ b/apps/Gateway/Gateway/Options.h @@ -24,6 +24,9 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/svc_export.h" +#include "ace/Lock_Adapter_T.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" class ACE_Svc_Export Options { diff --git a/apps/Gateway/Peer/Options.cpp b/apps/Gateway/Peer/Options.cpp index e4c5842c696..92dc6474a73 100644 --- a/apps/Gateway/Peer/Options.cpp +++ b/apps/Gateway/Peer/Options.cpp @@ -5,6 +5,8 @@ #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #include "Options.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_string.h" ACE_RCSID(Peer, Options, "$Id$") diff --git a/apps/JAWS/clients/Blobby/Blob.cpp b/apps/JAWS/clients/Blobby/Blob.cpp index 171fa0c34fe..e688241313b 100644 --- a/apps/JAWS/clients/Blobby/Blob.cpp +++ b/apps/JAWS/clients/Blobby/Blob.cpp @@ -19,7 +19,7 @@ ACE_Blob::~ACE_Blob (void) int ACE_Blob::open (ACE_TCHAR *filename, const ACE_TCHAR *hostname , u_short port) { - filename_ = ACE_OS_String::strdup (filename); + filename_ = ACE_OS::strdup (filename); inet_addr_.set (port, hostname); return 0; } diff --git a/apps/JAWS/clients/Blobby/Blob.h b/apps/JAWS/clients/Blobby/Blob.h index b2c078b0af2..afd880bf46c 100644 --- a/apps/JAWS/clients/Blobby/Blob.h +++ b/apps/JAWS/clients/Blobby/Blob.h @@ -21,7 +21,7 @@ #ifndef ACE_BLOB_H #define ACE_BLOB_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS/clients/Blobby/Blob_Handler.cpp b/apps/JAWS/clients/Blobby/Blob_Handler.cpp index 783736eb05f..005a8829539 100644 --- a/apps/JAWS/clients/Blobby/Blob_Handler.cpp +++ b/apps/JAWS/clients/Blobby/Blob_Handler.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Blob_Handler.h" +#include "ace/OS_NS_strings.h" ACE_RCSID(Blobby, Blob_Handler, "$Id$") @@ -17,7 +18,7 @@ ACE_Blob_Handler::ACE_Blob_Handler (ACE_Message_Block * mb, mb_ (mb), length_ (length), offset_ (offset), - filename_ (ACE_OS_String::strdup (filename)), + filename_ (ACE_OS::strdup (filename)), bytecount_ (0) { } @@ -96,9 +97,9 @@ ACE_Blob_Reader::send_request (void) char mesg [MAX_HEADER_SIZE]; // Check to see if the request is too big - if (MAX_HEADER_SIZE < (ACE_OS_String::strlen (request_prefix_) - + ACE_OS_String::strlen (filename_) - + ACE_OS_String::strlen (request_suffix_) + 4)) + if (MAX_HEADER_SIZE < (ACE_OS::strlen (request_prefix_) + + ACE_OS::strlen (filename_) + + ACE_OS::strlen (request_suffix_) + 4)) ACE_ERROR_RETURN((LM_ERROR,"Request too large!"), -1); // Create a message to send to the server requesting retrieval of the file diff --git a/apps/JAWS/clients/Blobby/Blob_Handler.h b/apps/JAWS/clients/Blobby/Blob_Handler.h index b18df484ac5..41e13ff9c03 100644 --- a/apps/JAWS/clients/Blobby/Blob_Handler.h +++ b/apps/JAWS/clients/Blobby/Blob_Handler.h @@ -22,7 +22,7 @@ #ifndef ACE_BLOB_HANDLER_H #define ACE_BLOB_HANDLER_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS/clients/Blobby/blobby.cpp b/apps/JAWS/clients/Blobby/blobby.cpp index cb2067e083d..13f0f7dbd9a 100644 --- a/apps/JAWS/clients/Blobby/blobby.cpp +++ b/apps/JAWS/clients/Blobby/blobby.cpp @@ -23,6 +23,7 @@ //============================================================================ #include "Options.h" +#include "ace/OS_main.h" ACE_RCSID(Blobby, blobby, "$Id$") diff --git a/apps/JAWS/clients/Caching/URL_Properties.cpp b/apps/JAWS/clients/Caching/URL_Properties.cpp index eeae1f43581..40688bfe169 100644 --- a/apps/JAWS/clients/Caching/URL_Properties.cpp +++ b/apps/JAWS/clients/Caching/URL_Properties.cpp @@ -9,7 +9,6 @@ #include "URL_Properties.i" #endif /* __ACE_INLINE__ */ -#include "ace/OS.h" #include "ace/Auto_Ptr.h" #include "URL_Array_Helper.h" diff --git a/apps/JAWS/server/HTTP_Config.cpp b/apps/JAWS/server/HTTP_Config.cpp index ec67142c970..11890037d3c 100644 --- a/apps/JAWS/server/HTTP_Config.cpp +++ b/apps/JAWS/server/HTTP_Config.cpp @@ -2,7 +2,7 @@ // HTTP_Config.cpp -#include "ace/OS.h" +#include "ace/OS_NS_stdlib.h" #include "HTTP_Config.h" ACE_RCSID(server, HTTP_Config, "$Id$") diff --git a/apps/JAWS/server/HTTP_Handler.cpp b/apps/JAWS/server/HTTP_Handler.cpp index 30ddff2de1c..c90e7a11fa0 100644 --- a/apps/JAWS/server/HTTP_Handler.cpp +++ b/apps/JAWS/server/HTTP_Handler.cpp @@ -8,6 +8,8 @@ #include "HTTP_Handler.h" #include "HTTP_Helpers.h" #include "IO.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(server, HTTP_Handler, "$Id$") diff --git a/apps/JAWS/server/HTTP_Helpers.cpp b/apps/JAWS/server/HTTP_Helpers.cpp index 1ad58b96451..314e88985ac 100644 --- a/apps/JAWS/server/HTTP_Helpers.cpp +++ b/apps/JAWS/server/HTTP_Helpers.cpp @@ -4,6 +4,10 @@ #include "HTTP_Helpers.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/Guard_T.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(server, HTTP_Helpers, "$Id$") diff --git a/apps/JAWS/server/HTTP_Helpers.h b/apps/JAWS/server/HTTP_Helpers.h index 68f05729e48..e7d6eae4f42 100644 --- a/apps/JAWS/server/HTTP_Helpers.h +++ b/apps/JAWS/server/HTTP_Helpers.h @@ -18,7 +18,8 @@ #ifndef HTTP_HELPERS_H #define HTTP_HELPERS_H -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS/server/HTTP_Request.cpp b/apps/JAWS/server/HTTP_Request.cpp index 7140b7aa21a..970d9a82126 100644 --- a/apps/JAWS/server/HTTP_Request.cpp +++ b/apps/JAWS/server/HTTP_Request.cpp @@ -4,6 +4,9 @@ #include "HTTP_Request.h" #include "HTTP_Helpers.h" #include "HTTP_Config.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_pwd.h" +#include "ace/Log_Msg.h" ACE_RCSID(server, HTTP_Request, "$Id$") @@ -97,7 +100,7 @@ HTTP_Request::parse_request (ACE_Message_Block &mb) while (this->headers_.complete_header_line (mb.rd_ptr ()) > 0); } - mb.wr_ptr (strlen(mb.rd_ptr ()) - mb.length ()); + mb.wr_ptr (ACE_OS::strlen(mb.rd_ptr ()) - mb.length ()); if (this->headers_.end_of_headers () || (this->got_request_line () && this->version () == 0)) diff --git a/apps/JAWS/server/HTTP_Request.h b/apps/JAWS/server/HTTP_Request.h index 48dac56366c..3a3bed182fe 100644 --- a/apps/JAWS/server/HTTP_Request.h +++ b/apps/JAWS/server/HTTP_Request.h @@ -20,7 +20,7 @@ class ACE_Message_Block; -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS/server/HTTP_Response.cpp b/apps/JAWS/server/HTTP_Response.cpp index 2e401add738..50c14604253 100644 --- a/apps/JAWS/server/HTTP_Response.cpp +++ b/apps/JAWS/server/HTTP_Response.cpp @@ -3,6 +3,7 @@ #include "ace/Process.h" #include "ace/Mem_Map.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" #include "HTTP_Response.h" #include "HTTP_Request.h" diff --git a/apps/JAWS/server/HTTP_Server.h b/apps/JAWS/server/HTTP_Server.h index 8abb502e68a..3724dad6234 100644 --- a/apps/JAWS/server/HTTP_Server.h +++ b/apps/JAWS/server/HTTP_Server.h @@ -30,6 +30,9 @@ #include "ace/Asynch_IO.h" #include "ace/svc_export.h" #include "HTTP_Handler.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" +#include "ace/Null_Mutex.h" // Forward declaration. class ACE_Proactor; diff --git a/apps/JAWS/server/IO.cpp b/apps/JAWS/server/IO.cpp index b1f3eb3ec62..cd6d37b88e4 100644 --- a/apps/JAWS/server/IO.cpp +++ b/apps/JAWS/server/IO.cpp @@ -5,6 +5,7 @@ #include "ace/Filecache.h" #include "IO.h" #include "HTTP_Helpers.h" +#include "ace/OS_NS_sys_uio.h" ACE_RCSID(server, IO, "$Id$") diff --git a/apps/JAWS/server/Parse_Headers.cpp b/apps/JAWS/server/Parse_Headers.cpp index dc94b1354d9..0d7dd273c59 100644 --- a/apps/JAWS/server/Parse_Headers.cpp +++ b/apps/JAWS/server/Parse_Headers.cpp @@ -3,6 +3,10 @@ #include "ace/Log_Msg.h" #include "Parse_Headers.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/os_include/os_ctype.h" ACE_RCSID(server, Parse_Headers, "$Id$") @@ -64,7 +68,7 @@ Headers::parse_header_line (char * const header_line) } // Write back the unused portion of the input. - ACE_OS::memmove (header_line, ptr, strlen(ptr) + 1); + ACE_OS::memmove (header_line, ptr, ACE_OS::strlen(ptr) + 1); } int diff --git a/apps/JAWS/server/Parse_Headers.h b/apps/JAWS/server/Parse_Headers.h index 68274bd442b..f5d564d8d0b 100644 --- a/apps/JAWS/server/Parse_Headers.h +++ b/apps/JAWS/server/Parse_Headers.h @@ -18,7 +18,7 @@ #ifndef PARSE_HEADERS_H #define PARSE_HEADERS_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS/server/main.cpp b/apps/JAWS/server/main.cpp index 0d04f565a06..4f319f02727 100644 --- a/apps/JAWS/server/main.cpp +++ b/apps/JAWS/server/main.cpp @@ -5,6 +5,8 @@ #include "ace/Filecache.h" #include "HTTP_Server.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_signal.h" ACE_RCSID(server, main, "$Id$") diff --git a/apps/JAWS/stress_testing/global.h b/apps/JAWS/stress_testing/global.h index a0ec4a9757d..0d916f2cc41 100644 --- a/apps/JAWS/stress_testing/global.h +++ b/apps/JAWS/stress_testing/global.h @@ -6,7 +6,6 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Connector.h" #include "ace/Pipe.h" diff --git a/apps/JAWS2/HTTPU/http_export.h b/apps/JAWS2/HTTPU/http_export.h index 84a819c8932..b0f6848cba2 100644 --- a/apps/JAWS2/HTTPU/http_export.h +++ b/apps/JAWS2/HTTPU/http_export.h @@ -7,7 +7,7 @@ #ifndef HTTPU_EXPORT_H #define HTTPU_EXPORT_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS2/HTTPU/parse_http_request.h b/apps/JAWS2/HTTPU/parse_http_request.h index 26c83348e37..43c2f954790 100644 --- a/apps/JAWS2/HTTPU/parse_http_request.h +++ b/apps/JAWS2/HTTPU/parse_http_request.h @@ -3,7 +3,7 @@ #ifndef HTTPU_PARSE_HTTP_REQUEST_H #define HTTPU_PARSE_HTTP_REQUEST_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS2/HTTPU/parse_http_response.cpp b/apps/JAWS2/HTTPU/parse_http_response.cpp index 4f20ac688d5..f3a195d1935 100644 --- a/apps/JAWS2/HTTPU/parse_http_response.cpp +++ b/apps/JAWS2/HTTPU/parse_http_response.cpp @@ -1,6 +1,8 @@ // $Id$ #include "HTTPU/parse_http_response.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdlib.h" Parse_HTTP_Response::Parse_HTTP_Response (const char *response) : code_ (200), diff --git a/apps/JAWS2/HTTPU/parse_http_response.h b/apps/JAWS2/HTTPU/parse_http_response.h index 42fd5a31afe..58f126f654a 100644 --- a/apps/JAWS2/HTTPU/parse_http_response.h +++ b/apps/JAWS2/HTTPU/parse_http_response.h @@ -3,7 +3,7 @@ #ifndef HTTPU_PARSE_HTTP_RESPONSE_H #define HTTPU_PARSE_HTTP_RESPONSE_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS2/HTTPU/parse_url.cpp b/apps/JAWS2/HTTPU/parse_url.cpp index 2c998c7083a..c1c753d0784 100644 --- a/apps/JAWS2/HTTPU/parse_url.cpp +++ b/apps/JAWS2/HTTPU/parse_url.cpp @@ -1,6 +1,7 @@ // $Id$ -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdlib.h" #include "ace/Log_Msg.h" #include "HTTPU/parse_url.h" diff --git a/apps/JAWS2/HTTP_10_Write.cpp b/apps/JAWS2/HTTP_10_Write.cpp index e22bfef849b..16bf3f56d9e 100644 --- a/apps/JAWS2/HTTP_10_Write.cpp +++ b/apps/JAWS2/HTTP_10_Write.cpp @@ -1,7 +1,5 @@ // $Id$ -#include "ace/OS.h" - #include "JAWS/JAWS.h" #include "JAWS/IO.h" #include "JAWS/IO_Handler.h" diff --git a/apps/JAWS2/JAWS/Cache_Hash_T.h b/apps/JAWS2/JAWS/Cache_Hash_T.h index 2d310873cb2..f5f050c3801 100644 --- a/apps/JAWS2/JAWS/Cache_Hash_T.h +++ b/apps/JAWS2/JAWS/Cache_Hash_T.h @@ -4,7 +4,6 @@ #ifndef JAWS_CACHE_HASH_T_H #define JAWS_CACHE_HASH_T_H -#include "ace/OS.h" #include "JAWS/Cache_Object.h" // Forward declaration diff --git a/apps/JAWS2/JAWS/Cache_Manager.cpp b/apps/JAWS2/JAWS/Cache_Manager.cpp index a91ac38375a..7abbcfaf020 100644 --- a/apps/JAWS2/JAWS/Cache_Manager.cpp +++ b/apps/JAWS2/JAWS/Cache_Manager.cpp @@ -1,8 +1,6 @@ // $Id$ -#include "ace/OS.h" #include "ace/ACE.h" -#include "ace/Synch.h" #include "JAWS/Cache_Manager.h" #include "JAWS/Cache_List_T.h" diff --git a/apps/JAWS2/JAWS/Cache_Manager.h b/apps/JAWS2/JAWS/Cache_Manager.h index 723e6729f33..c7837b935ba 100644 --- a/apps/JAWS2/JAWS/Cache_Manager.h +++ b/apps/JAWS2/JAWS/Cache_Manager.h @@ -4,9 +4,7 @@ #ifndef JAWS_CACHE_MANAGER_H #define JAWS_CACHE_MANAGER_H -#include "ace/OS.h" #include "ace/ACE.h" -#include "ace/Synch.h" #include "JAWS/Cache_Manager_T.h" diff --git a/apps/JAWS2/JAWS/Cache_Object.cpp b/apps/JAWS2/JAWS/Cache_Object.cpp index abb582aa9c7..bb1a258ef2d 100644 --- a/apps/JAWS2/JAWS/Cache_Object.cpp +++ b/apps/JAWS2/JAWS/Cache_Object.cpp @@ -1,6 +1,7 @@ // $Id$ #include "JAWS/Cache_Object.h" +#include "ace/OS_NS_time.h" JAWS_Cache_Object::JAWS_Cache_Object (const void *data, size_t size) : internal_ (0), diff --git a/apps/JAWS2/JAWS/Cache_Object.h b/apps/JAWS2/JAWS/Cache_Object.h index fbd570b4140..96a9cfa096c 100644 --- a/apps/JAWS2/JAWS/Cache_Object.h +++ b/apps/JAWS2/JAWS/Cache_Object.h @@ -5,8 +5,9 @@ #ifndef JAWS_CACHE_OBJECT_H #define JAWS_CACHE_OBJECT_H -#include "ace/OS.h" -#include "ace/Synch.h" +#include "ace/Lock_Adapter_T.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" #include "ace/Malloc.h" // Cache bucket -- use Hash_Bucket to hold cacheable objects. diff --git a/apps/JAWS2/JAWS/Export.h b/apps/JAWS2/JAWS/Export.h index f06afcdb767..432b23f6984 100644 --- a/apps/JAWS2/JAWS/Export.h +++ b/apps/JAWS2/JAWS/Export.h @@ -7,7 +7,7 @@ #ifndef JAWS_EXPORT_H #define JAWS_EXPORT_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/JAWS2/JAWS/FILE.cpp b/apps/JAWS2/JAWS/FILE.cpp index 1394b7f1696..3f01f368a88 100644 --- a/apps/JAWS2/JAWS/FILE.cpp +++ b/apps/JAWS2/JAWS/FILE.cpp @@ -1,7 +1,6 @@ // $Id$ -#include "ace/OS.h" -#include "ace/Synch.h" +#include "ace/Guard_T.h" #include "JAWS/FILE.h" diff --git a/apps/JAWS2/JAWS/FILE.h b/apps/JAWS2/JAWS/FILE.h index 527227f85e2..478f3271e31 100644 --- a/apps/JAWS2/JAWS/FILE.h +++ b/apps/JAWS2/JAWS/FILE.h @@ -9,6 +9,8 @@ #include "ace/Mem_Map.h" #include "JAWS/Export.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" class JAWS_Export JAWS_FILE : public ACE_FILE_IO // diff --git a/apps/JAWS2/JAWS/Filecache.cpp b/apps/JAWS2/JAWS/Filecache.cpp index a6791538921..d551542d59c 100644 --- a/apps/JAWS2/JAWS/Filecache.cpp +++ b/apps/JAWS2/JAWS/Filecache.cpp @@ -1,6 +1,5 @@ // $Id$ -#include "ace/OS.h" #include "ace/FILE_Connector.h" #include "JAWS/Filecache.h" diff --git a/apps/JAWS2/JAWS/Filecache.h b/apps/JAWS2/JAWS/Filecache.h index a770f1fd959..7ea313a43b1 100644 --- a/apps/JAWS2/JAWS/Filecache.h +++ b/apps/JAWS2/JAWS/Filecache.h @@ -4,7 +4,6 @@ #ifndef JAWS_FILECACHE_H #define JAWS_FILECACHE_H -#include "ace/OS.h" #include "ace/FILE_IO.h" #include "JAWS/Cache_Manager.h" diff --git a/apps/JAWS2/JAWS/Headers.cpp b/apps/JAWS2/JAWS/Headers.cpp index b41ddd87ff5..3e7d2b3018b 100644 --- a/apps/JAWS2/JAWS/Headers.cpp +++ b/apps/JAWS2/JAWS/Headers.cpp @@ -1,6 +1,7 @@ /* $Id$ */ #include "JAWS/Headers.h" +#include "ace/OS_NS_strings.h" // Header Data diff --git a/apps/drwho/BS_Client.cpp b/apps/drwho/BS_Client.cpp index ec6ae351632..95f2ea940d7 100644 --- a/apps/drwho/BS_Client.cpp +++ b/apps/drwho/BS_Client.cpp @@ -5,6 +5,7 @@ #include "BS_Client.h" #include "ace/Log_Msg.h" #include "ace/Null_Mutex.h" +#include "ace/OS_NS_string.h" BS_Client::BS_Client (void) { diff --git a/apps/drwho/BS_Server.cpp b/apps/drwho/BS_Server.cpp index bddaa5a31aa..057fbc25a04 100644 --- a/apps/drwho/BS_Server.cpp +++ b/apps/drwho/BS_Server.cpp @@ -1,6 +1,10 @@ // $Id$ #include "BS_Server.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_Memory.h" +#include "ace/os_include/os_netdb.h" // This constructor takes a message of sorted login names and loads up // the symbol table on the server's side. It assumes that the number diff --git a/apps/drwho/Binary_Search.cpp b/apps/drwho/Binary_Search.cpp index 54582052629..b4c39de27be 100644 --- a/apps/drwho/Binary_Search.cpp +++ b/apps/drwho/Binary_Search.cpp @@ -3,6 +3,7 @@ #include "Options.h" #include "Binary_Search.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" // This function is passed to qsort to perform the comparison between // login names for two friends. diff --git a/apps/drwho/CM_Client.cpp b/apps/drwho/CM_Client.cpp index 8bdc9cec179..3352d8d9a92 100644 --- a/apps/drwho/CM_Client.cpp +++ b/apps/drwho/CM_Client.cpp @@ -4,6 +4,12 @@ #include "Multicast_Manager.h" #include "CM_Client.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/os_include/os_string.h" // Creates and binds a UDP socket... @@ -68,7 +74,7 @@ CM_Client::receive (int timeout) ACE_DEBUG ((LM_DEBUG, "receiving from server host %s (%s)\n", np->h_name, - inet_ntoa (this->sin_.sin_addr))); + ACE_OS::inet_ntoa (this->sin_.sin_addr))); } if (this->demux (this->recv_packet_, n) < 0) diff --git a/apps/drwho/CM_Client.h b/apps/drwho/CM_Client.h index 1e789633a5a..43d3e9e940e 100644 --- a/apps/drwho/CM_Client.h +++ b/apps/drwho/CM_Client.h @@ -22,6 +22,7 @@ #define _CM_CLIENT_H #include "Comm_Manager.h" +#include "ace/Time_Value.h" class CM_Client : public Comm_Manager { diff --git a/apps/drwho/CM_Server.cpp b/apps/drwho/CM_Server.cpp index 0cf6b9b9df2..16a7bcfe07b 100644 --- a/apps/drwho/CM_Server.cpp +++ b/apps/drwho/CM_Server.cpp @@ -5,6 +5,9 @@ #include "CM_Server.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_arpa_inet.h" // Creates and binds a UDP socket... diff --git a/apps/drwho/Comm_Manager.h b/apps/drwho/Comm_Manager.h index ec3caf93e74..f0f05d454c2 100644 --- a/apps/drwho/Comm_Manager.h +++ b/apps/drwho/Comm_Manager.h @@ -18,6 +18,7 @@ #define _COMM_MANAGER_H #include "global.h" +#include "ace/os_include/netinet/os_in.h" class Comm_Manager { diff --git a/apps/drwho/File_Manager.cpp b/apps/drwho/File_Manager.cpp index bca426b824f..ff731e54e48 100644 --- a/apps/drwho/File_Manager.cpp +++ b/apps/drwho/File_Manager.cpp @@ -1,6 +1,9 @@ // $Id$ #include "File_Manager.h" +#include "ace/OS_NS_pwd.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_ctype.h" File_Manager::File_Manager (void) : number_of_friends (0), @@ -81,7 +84,7 @@ File_Manager::open_passwd_file (void) (pwent = ACE_OS::getpwent ()) != 0; ) if (*pwent->pw_gecos != '\0') { - char *cp = strchr (pwent->pw_gecos, ','); + char *cp = ACE_OS::strchr (pwent->pw_gecos, ','); if (cp != 0) *cp = '\0'; diff --git a/apps/drwho/HT_Client.cpp b/apps/drwho/HT_Client.cpp index 0ff9674cf93..8854919fd73 100644 --- a/apps/drwho/HT_Client.cpp +++ b/apps/drwho/HT_Client.cpp @@ -2,6 +2,7 @@ #include "HT_Client.h" #include "ace/ACE.h" +#include "ace/OS_NS_string.h" // Insert a KEY_NAME into the hash table, if it doesn't already exist // there. What gets returned is a pointer to the node inserted. Note diff --git a/apps/drwho/HT_Server.cpp b/apps/drwho/HT_Server.cpp index 5af2b21c4b5..ff61a2876fe 100644 --- a/apps/drwho/HT_Server.cpp +++ b/apps/drwho/HT_Server.cpp @@ -2,6 +2,7 @@ #include "HT_Server.h" #include "ace/ACE.h" +#include "ace/OS_NS_string.h" // Insert a KEY_NAME into the hash table, if it doesn't already exist // there. What gets returned is a pointer to the node inserted. Note @@ -15,7 +16,7 @@ HT_Server::insert (const char *key_name, int max_len) // This is tricky... for (prpp = &this->hash_table[ACE::hash_pjw (key_name) % this->hash_table_size]; - *prpp != 0 && strncmp ((*prpp)->get_login (), key_name, max_len) != 0; + *prpp != 0 && ACE_OS::strncmp ((*prpp)->get_login (), key_name, max_len) != 0; prpp = &(*prpp)->next_) continue; diff --git a/apps/drwho/Hash_Table.cpp b/apps/drwho/Hash_Table.cpp index 51fba821db9..574cb71718b 100644 --- a/apps/drwho/Hash_Table.cpp +++ b/apps/drwho/Hash_Table.cpp @@ -3,6 +3,8 @@ #include "Options.h" #include "Hash_Table.h" #include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" Hash_Table::Hash_Table (void) : current_ptr (0), diff --git a/apps/drwho/Multicast_Manager.cpp b/apps/drwho/Multicast_Manager.cpp index f213a65846e..71bb56ee894 100644 --- a/apps/drwho/Multicast_Manager.cpp +++ b/apps/drwho/Multicast_Manager.cpp @@ -3,6 +3,11 @@ #include "Multicast_Manager.h" #include "ace/Mem_Map.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_Memory.h" +#include "ace/os_include/os_ctype.h" // Initialize all the static member vars. int Multicast_Manager::received_host_count = 0; @@ -118,7 +123,7 @@ Multicast_Manager::get_host_entry (const char *host) hp = ACE_OS::gethostbyname (host); - return hp == 0 ? 0 : (hostent *) memcpy (&host_entry, hp, sizeof *hp); + return hp == 0 ? 0 : (hostent *) ACE_OS::memcpy (&host_entry, hp, sizeof *hp); } // Adds an additional new host to the list of host machines. diff --git a/apps/drwho/Multicast_Manager.h b/apps/drwho/Multicast_Manager.h index 82f609a6546..ee21ac6ac08 100644 --- a/apps/drwho/Multicast_Manager.h +++ b/apps/drwho/Multicast_Manager.h @@ -18,6 +18,8 @@ #define _MULTICAST_MANAGER_H #include "global.h" +#include "ace/os_include/netinet/os_in.h" +#include "ace/os_include/os_netdb.h" class Host_Elem { diff --git a/apps/drwho/Options.h b/apps/drwho/Options.h index 567c91a49f6..bfc9d054c43 100644 --- a/apps/drwho/Options.h +++ b/apps/drwho/Options.h @@ -60,7 +60,7 @@ public: static char *user_name; static void print_usage_and_die (int long_msg); - static u_int option_word; + static unsigned int option_word; }; #endif /* _OPTIONS_H */ diff --git a/apps/drwho/PMC_All.cpp b/apps/drwho/PMC_All.cpp index 2f599150785..8a77182fd0a 100644 --- a/apps/drwho/PMC_All.cpp +++ b/apps/drwho/PMC_All.cpp @@ -6,6 +6,7 @@ #include "PMC_All.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" // This function is pretty much a no-op that just sets up the // appropriate lookup function to use. diff --git a/apps/drwho/PMC_Flo.cpp b/apps/drwho/PMC_Flo.cpp index 72758191d00..58105822e55 100644 --- a/apps/drwho/PMC_Flo.cpp +++ b/apps/drwho/PMC_Flo.cpp @@ -5,6 +5,7 @@ #include "PMC_Flo.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" // This function "encodes" a list of friends by putting the userid's // in a contiguous block. This block can then be transmitted over to diff --git a/apps/drwho/PMC_Ruser.cpp b/apps/drwho/PMC_Ruser.cpp index f32b13a7bc2..0d872b3dcb5 100644 --- a/apps/drwho/PMC_Ruser.cpp +++ b/apps/drwho/PMC_Ruser.cpp @@ -6,6 +6,8 @@ #include "PMC_Ruser.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_netdb.h" // This function is pretty much a no-op that just sets up the // appropriate lookup function to use. diff --git a/apps/drwho/PMC_Usr.cpp b/apps/drwho/PMC_Usr.cpp index c406e3e9d16..ca781b74848 100644 --- a/apps/drwho/PMC_Usr.cpp +++ b/apps/drwho/PMC_Usr.cpp @@ -5,6 +5,7 @@ #include "PMC_Usr.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" int PMC_Usr::encode (char *packet, int &packet_length) diff --git a/apps/drwho/PMS_All.cpp b/apps/drwho/PMS_All.cpp index a942b498273..e51e7701931 100644 --- a/apps/drwho/PMS_All.cpp +++ b/apps/drwho/PMS_All.cpp @@ -5,6 +5,8 @@ #include "PMS_All.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_pwd.h" // This function packs the located friends userids, plus the machines // they are logged into (along with the inactive and active counts on @@ -80,7 +82,7 @@ Protocol_Record * PMS_All::insert_protocol_info (Protocol_Record &protocol_record) { Protocol_Record *prp = PM_Server::insert_protocol_info (protocol_record); - passwd *pwent = getpwnam (prp->get_login ()); + passwd *pwent = ACE_OS::getpwnam (prp->get_login ()); char *cp = (char *) ACE_OS::strchr (prp->set_real (pwent == 0 ? prp->get_login () : diff --git a/apps/drwho/PMS_Flo.cpp b/apps/drwho/PMS_Flo.cpp index 2fecac44057..291884b18cf 100644 --- a/apps/drwho/PMS_Flo.cpp +++ b/apps/drwho/PMS_Flo.cpp @@ -5,6 +5,7 @@ #include "PMS_Flo.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" // This function packs the located friends userids, plus the machines // they are logged into (along with the inactive and active counts on diff --git a/apps/drwho/PMS_Ruser.cpp b/apps/drwho/PMS_Ruser.cpp index 0f4288a868b..50c969bf52a 100644 --- a/apps/drwho/PMS_Ruser.cpp +++ b/apps/drwho/PMS_Ruser.cpp @@ -5,6 +5,9 @@ #include "PMS_Ruser.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_pwd.h" +#include "ace/os_include/os_netdb.h" // This function packs the located friends userids, plus the machines // they are logged into (along with the inactive and active counts on @@ -86,7 +89,7 @@ PMS_Ruser::insert_protocol_info (Protocol_Record &protocol_record) np->set_real_name (""); else { - passwd *pwent = getpwnam (np->get_login_name ()); + passwd *pwent = ACE_OS::getpwnam (np->get_login_name ()); char *cp = (char *) ACE_OS::strchr (np->set_real_name (pwent == 0 ? np->get_login_name () diff --git a/apps/drwho/PMS_Usr.cpp b/apps/drwho/PMS_Usr.cpp index 6c1138734ca..636967f59d4 100644 --- a/apps/drwho/PMS_Usr.cpp +++ b/apps/drwho/PMS_Usr.cpp @@ -5,6 +5,7 @@ #include "PMS_Usr.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" // This function "encodes" a list of friends by putting the userid's in // a contiguous block. This block can then be transmitted over to the diff --git a/apps/drwho/PM_Client.cpp b/apps/drwho/PM_Client.cpp index 44476007dc4..cffa91719fa 100644 --- a/apps/drwho/PM_Client.cpp +++ b/apps/drwho/PM_Client.cpp @@ -5,6 +5,7 @@ #include "PM_Client.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" // This function is used to merge the LOGIN_NAME from server HOST_NAME // into the userids kept on the client's side. Note that we must diff --git a/apps/drwho/PM_Server.cpp b/apps/drwho/PM_Server.cpp index 0b946f5cca9..88a32b586c6 100644 --- a/apps/drwho/PM_Server.cpp +++ b/apps/drwho/PM_Server.cpp @@ -4,6 +4,7 @@ #include "Rwho_DB_Manager.h" #include "PM_Server.h" #include "ace/ACE.h" +#include "ace/OS_NS_string.h" // This is the main method for the server side of things. It reads // the RWHO file on the local machine and inserts HOST_NAME @@ -67,7 +68,7 @@ PM_Server::handle_protocol_entries (char *buf_ptr, np->get_inactive_count (), np->get_active_count (), np->get_host_name ()); - buf_ptr += strlen (buf_ptr) + 1; + buf_ptr += ACE_OS::strlen (buf_ptr) + 1; } return buf_ptr; diff --git a/apps/drwho/Protocol_Manager.cpp b/apps/drwho/Protocol_Manager.cpp index 9545d7ee341..faf118ef169 100644 --- a/apps/drwho/Protocol_Manager.cpp +++ b/apps/drwho/Protocol_Manager.cpp @@ -2,6 +2,8 @@ #include "ace/config.h" #include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" #include "Options.h" #include "Protocol_Manager.h" diff --git a/apps/drwho/Protocol_Manager.h b/apps/drwho/Protocol_Manager.h index d61e752c8df..fd4ef92a9ed 100644 --- a/apps/drwho/Protocol_Manager.h +++ b/apps/drwho/Protocol_Manager.h @@ -17,7 +17,7 @@ #ifndef _PROTOCOL_MANAGER_H #define _PROTOCOL_MANAGER_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/drwho/Rwho_DB_Manager.cpp b/apps/drwho/Rwho_DB_Manager.cpp index 52cf4fb0faa..cd437bfd407 100644 --- a/apps/drwho/Rwho_DB_Manager.cpp +++ b/apps/drwho/Rwho_DB_Manager.cpp @@ -3,6 +3,9 @@ #include "Options.h" #include "Rwho_DB_Manager.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_fcntl.h" // Change to the RWHO directory to speed up and simplify later // processing. This requires opening the directory for reading with diff --git a/apps/drwho/SL_Server.cpp b/apps/drwho/SL_Server.cpp index 35c29d598dc..7dc172deb08 100644 --- a/apps/drwho/SL_Server.cpp +++ b/apps/drwho/SL_Server.cpp @@ -2,6 +2,7 @@ #include "global.h" #include "SL_Server.h" +#include "ace/OS_NS_string.h" SL_Server::SL_Server (const char *usr_name) : Single_Lookup (usr_name) diff --git a/apps/drwho/SM_Client.cpp b/apps/drwho/SM_Client.cpp index 48bca11b7e3..02e552c9af9 100644 --- a/apps/drwho/SM_Client.cpp +++ b/apps/drwho/SM_Client.cpp @@ -7,6 +7,7 @@ #include "PMC_Ruser.h" #include "SM_Client.h" #include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" // Call-back function that invokes the appropriate decode function. diff --git a/apps/drwho/SM_Server.cpp b/apps/drwho/SM_Server.cpp index 74229921845..25a43375524 100644 --- a/apps/drwho/SM_Server.cpp +++ b/apps/drwho/SM_Server.cpp @@ -7,6 +7,7 @@ #include "PMS_Ruser.h" #include "SM_Server.h" #include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" int SM_Server::demux (char *packet, int &packet_length) diff --git a/apps/drwho/client.cpp b/apps/drwho/client.cpp index 3a66b3ac9b5..5b8f4fcf8ab 100644 --- a/apps/drwho/client.cpp +++ b/apps/drwho/client.cpp @@ -21,6 +21,7 @@ #include "Options.h" #include "SML_Client.h" #include "SMR_Client.h" +#include "ace/OS_Memory.h" // Factory function. diff --git a/apps/drwho/global.h b/apps/drwho/global.h index d049bd3f43d..c6713f0063e 100644 --- a/apps/drwho/global.h +++ b/apps/drwho/global.h @@ -20,7 +20,7 @@ #ifndef _GLOBAL_H #define _GLOBAL_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/drwho/server.cpp b/apps/drwho/server.cpp index 41f005354c7..db2766d0d75 100644 --- a/apps/drwho/server.cpp +++ b/apps/drwho/server.cpp @@ -23,6 +23,9 @@ #include "SMR_Server.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_sys_socket.h" static char * time_stamp (void) diff --git a/apps/gperf/src/Bool_Array.cpp b/apps/gperf/src/Bool_Array.cpp index 718d997b456..668f0cd0016 100644 --- a/apps/gperf/src/Bool_Array.cpp +++ b/apps/gperf/src/Bool_Array.cpp @@ -24,12 +24,14 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Bool_Array.h" -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" ACE_RCSID(src, Bool_Array, "$Id$") #if defined (ACE_HAS_GPERF) +#include "ace/OS_Memory.h" + // Prints out debugging diagnostics. Bool_Array::~Bool_Array (void) @@ -60,7 +62,7 @@ Bool_Array::open (u_long s) u_long[s], -1); - ACE_OS_String::memset (storage_array_, + ACE_OS::memset (storage_array_, 0, s * sizeof *storage_array_); @@ -94,9 +96,9 @@ Bool_Array::reset (void) "(re-initializing bool_array)...")); this->generation_number_ = 1; - ACE_OS_String::memset (storage_array_, - 0, - size_ * sizeof *storage_array_); + ACE_OS::memset (storage_array_, + 0, + size_ * sizeof *storage_array_); if (option[DEBUGGING]) ACE_DEBUG ((LM_DEBUG, "done\n")); diff --git a/apps/gperf/src/Gen_Perf.cpp b/apps/gperf/src/Gen_Perf.cpp index 60202b4edc5..da925e89b63 100644 --- a/apps/gperf/src/Gen_Perf.cpp +++ b/apps/gperf/src/Gen_Perf.cpp @@ -28,6 +28,9 @@ ACE_RCSID(src, Gen_Perf, "$Id$") #if defined (ACE_HAS_GPERF) #include "Vectors.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_Memory.h" // Current release version. extern const char *version_string; diff --git a/apps/gperf/src/Hash_Table.cpp b/apps/gperf/src/Hash_Table.cpp index 179bb17f502..f25f3b9bef7 100644 --- a/apps/gperf/src/Hash_Table.cpp +++ b/apps/gperf/src/Hash_Table.cpp @@ -28,6 +28,7 @@ ACE_RCSID(src, Hash_Table, "$Id$") #if defined (ACE_HAS_GPERF) #include "ace/ACE.h" +#include "ace/OS_NS_string.h" // The size of the hash table is always the smallest power of 2 >= the // size indicated by the user. This allows several optimizations, diff --git a/apps/gperf/src/Hash_Table.h b/apps/gperf/src/Hash_Table.h index dba0c478eff..d8385858271 100644 --- a/apps/gperf/src/Hash_Table.h +++ b/apps/gperf/src/Hash_Table.h @@ -24,7 +24,7 @@ #ifndef HASH_TABLE_H #define HASH_TABLE_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/gperf/src/Iterator.cpp b/apps/gperf/src/Iterator.cpp index 75d6e40ddef..4e3c86318d1 100644 --- a/apps/gperf/src/Iterator.cpp +++ b/apps/gperf/src/Iterator.cpp @@ -27,6 +27,8 @@ ACE_RCSID(src, Iterator, "$Id$") #if defined (ACE_HAS_GPERF) +#include "ace/os_include/os_ctype.h" + // Constructor for Iterator. Iterator::Iterator (char *s, diff --git a/apps/gperf/src/Key_List.cpp b/apps/gperf/src/Key_List.cpp index 3c17802f7ae..dceb489f28b 100644 --- a/apps/gperf/src/Key_List.cpp +++ b/apps/gperf/src/Key_List.cpp @@ -29,6 +29,9 @@ ACE_RCSID(src, Key_List, "$Id$") #include "ace/Read_Buffer.h" #include "Hash_Table.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" // Default type for generated code. const char *const Key_List::default_array_type = "char *"; @@ -362,7 +365,7 @@ Key_List::merge (List_Node *list1, List_Node *list2) return list1; else if (occurrence_sort && list1->occurrence < list2->occurrence || hash_sort && list1->hash_value > list2->hash_value - || key_sort && strcmp (list1->key, list2->key) >= 0) + || key_sort && ACE_OS::strcmp (list1->key, list2->key) >= 0) { list2->next = merge (list2->next, list1); return list2; @@ -553,7 +556,7 @@ Key_List::output_switch (int use_keyword_table) // Keep track of the longest string we'll need! const char *s = "charmap[*str] == *resword->%s && !strncasecmp (str + 1, resword->%s + 1, len - 1)"; comp_buffer = - new char [strlen (s) + 2 * strlen (option.key_name ()) + 1]; + new char [ACE_OS::strlen (s) + 2 * ACE_OS::strlen (option.key_name ()) + 1]; if (option[COMP]) sprintf (comp_buffer, "%s == *resword->%s && !%s (str + 1, resword->%s + 1, len - 1)", option[STRCASECMP] ? "charmap[*str]" : "*str", option.key_name (), diff --git a/apps/gperf/src/List_Node.cpp b/apps/gperf/src/List_Node.cpp index 9564c1829f7..b5e22bc0bb9 100644 --- a/apps/gperf/src/List_Node.cpp +++ b/apps/gperf/src/List_Node.cpp @@ -28,6 +28,7 @@ ACE_RCSID(src, List_Node, "$Id$") #if defined (ACE_HAS_GPERF) #include "Vectors.h" +#include "ace/os_include/os_ctype.h" // Sorts the key set alphabetically to speed up subsequent operation // Uses insertion sort since the set is probably quite small. diff --git a/apps/gperf/src/Options.cpp b/apps/gperf/src/Options.cpp index 4b543045855..b74c1023d75 100644 --- a/apps/gperf/src/Options.cpp +++ b/apps/gperf/src/Options.cpp @@ -31,6 +31,8 @@ ACE_RCSID(src, Options, "$Id$") #include "ace/Get_Opt.h" #include "Iterator.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" // Global option coordinator for the entire program. Options option; diff --git a/apps/gperf/src/Options.h b/apps/gperf/src/Options.h index bc737b0cd6e..783c1304663 100644 --- a/apps/gperf/src/Options.h +++ b/apps/gperf/src/Options.h @@ -25,7 +25,6 @@ #define OPTIONS_H #include "ace/Log_Msg.h" -#include "ace/OS.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/gperf/src/Vectors.h b/apps/gperf/src/Vectors.h index 236ff0986eb..6555c3f50b7 100644 --- a/apps/gperf/src/Vectors.h +++ b/apps/gperf/src/Vectors.h @@ -24,7 +24,7 @@ #ifndef VECTORS_H #define VECTORS_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/apps/gperf/src/gperf.cpp b/apps/gperf/src/gperf.cpp index ef8b9c31792..244ba24b498 100644 --- a/apps/gperf/src/gperf.cpp +++ b/apps/gperf/src/gperf.cpp @@ -33,6 +33,8 @@ ACE_RCSID(src, gperf, "$Id$") #if defined (ACE_HAS_GPERF) #include "Options.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdio.h" int main (int argc, char *argv[]) diff --git a/apps/gperf/tests/test.cpp b/apps/gperf/tests/test.cpp index 156b9bf922d..b73a9214e80 100644 --- a/apps/gperf/tests/test.cpp +++ b/apps/gperf/tests/test.cpp @@ -5,7 +5,8 @@ // The -v option prints diagnostics as to whether a word is in the set // or not. Without -v the program is useful for timing. -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(tests, test, "$Id$") @@ -25,9 +26,9 @@ main (int argc, char *argv[]) int len = ACE_OS::strlen (buf) - 1; buf[len] = '\0'; if (in_word_set (buf, len) && verbose) - printf ("in word set %s\n", buf); + ACE_OS::printf ("in word set %s\n", buf); else if (verbose) - printf ("NOT in word set %s\n", buf); + ACE_OS::printf ("NOT in word set %s\n", buf); } return 0; diff --git a/apps/mkcsregdb/mkcsregdb.cpp b/apps/mkcsregdb/mkcsregdb.cpp index 097f68b0bd9..ea862ae4d42 100644 --- a/apps/mkcsregdb/mkcsregdb.cpp +++ b/apps/mkcsregdb/mkcsregdb.cpp @@ -11,6 +11,9 @@ #include "ace/streams.h" #include "ace/Codeset_Registry.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdio.h" class csdb_generator : public ACE_Codeset_Registry { diff --git a/apps/soreduce/Library.cpp b/apps/soreduce/Library.cpp index 9dfa945d47f..8222415cdf7 100644 --- a/apps/soreduce/Library.cpp +++ b/apps/soreduce/Library.cpp @@ -11,10 +11,10 @@ // library. -#include <ace/OS.h> -#include <ace/OS_Dirent.h> -#include <ace/Log_Msg.h> -#include <ace/streams.h> +#include "ace/OS_NS_dirent.h" +#include "ace/Log_Msg.h" +#include "ace/streams.h" +#include "ace/OS_NS_sys_stat.h" #include "Library.h" @@ -250,13 +250,13 @@ Library::has_modules () const static int selector (const dirent *d) { - return ACE_OS_String::strstr (d->d_name, ".o") != 0; + return ACE_OS::strstr (d->d_name, ".o") != 0; } static int comparator (const dirent **d1, const dirent **d2) { - return ACE_OS_String::strcmp ((*d1)->d_name, (*d2)->d_name); + return ACE_OS::strcmp ((*d1)->d_name, (*d2)->d_name); } void @@ -265,7 +265,7 @@ Library::load_modules () ACE_CString subdir = path_ + "/.shobj"; struct dirent **dent; - num_modules_ = ACE_OS_Dirent::scandir(subdir.c_str(), + num_modules_ = ACE_OS::scandir(subdir.c_str(), &dent,selector,comparator); if (num_modules_ > 0) { @@ -273,12 +273,12 @@ Library::load_modules () for (int i = 0; i < num_modules_; i++) { modules_[i] = new Obj_Module(dent[i]->d_name); modules_[i]->add_source (ACE_CString(subdir + "/" + dent[i]->d_name).c_str()); - ACE_OS_Memory::free(dent[i]); + ACE_OS::free(dent[i]); }; } if (num_modules_ > -1) - ACE_OS_Memory::free(dent); + ACE_OS::free(dent); } void diff --git a/apps/soreduce/Obj_Module.cpp b/apps/soreduce/Obj_Module.cpp index 7fa3fcfe934..4da90b63b6e 100644 --- a/apps/soreduce/Obj_Module.cpp +++ b/apps/soreduce/Obj_Module.cpp @@ -150,7 +150,7 @@ Obj_Module::add_source(const ACE_TCHAR *p, int imports_only) if (eoln == 2) break; is_import = dummy == 'U'; - is_export = !imports_only && (ACE_OS_String::strchr("BCDRTVW",dummy) != 0); + is_export = !imports_only && (ACE_OS::strchr("BCDRTVW",dummy) != 0); // if (ACE::recv(pipe[0],&dummy,1,&timeout) != 1) if (ACE_OS::read(pipe[0],&dummy,1) != 1) diff --git a/apps/soreduce/SO_Group.cpp b/apps/soreduce/SO_Group.cpp index d2af08ef61b..1e4a20a7a62 100644 --- a/apps/soreduce/SO_Group.cpp +++ b/apps/soreduce/SO_Group.cpp @@ -1,9 +1,8 @@ -#include <ace/OS.h> -#include <ace/Log_Msg.h> +#include "ace/Log_Msg.h" -#include <ace/Process.h> -#include <ace/Pipe.h> +#include "ace/Process.h" +#include "ace/Pipe.h" #include "Library.h" #include "SO_Group.h" diff --git a/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp b/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp index 165e370e87b..6a6ea29876f 100644 --- a/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp +++ b/examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp @@ -2,6 +2,7 @@ #include "Consumer_Router.h" #include "Options.h" +#include "ace/os_include/os_assert.h" ACE_RCSID(Event_Server, Consumer_Router, "$Id$") diff --git a/examples/ASX/Event_Server/Event_Server/Options.cpp b/examples/ASX/Event_Server/Event_Server/Options.cpp index 1bf6f760c47..a10270a5369 100644 --- a/examples/ASX/Event_Server/Event_Server/Options.cpp +++ b/examples/ASX/Event_Server/Event_Server/Options.cpp @@ -4,6 +4,7 @@ #include "ace/Synch.h" #include "ace/Thread.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" #include "Options.h" diff --git a/examples/ASX/Event_Server/Event_Server/Options.h b/examples/ASX/Event_Server/Event_Server/Options.h index fbde9aa1c34..0dbe093a079 100644 --- a/examples/ASX/Event_Server/Event_Server/Options.h +++ b/examples/ASX/Event_Server/Event_Server/Options.h @@ -4,7 +4,7 @@ #ifndef OPTIONS_H #define OPTIONS_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp b/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp index 7e2018a3d56..a7edd7893b5 100644 --- a/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp +++ b/examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp @@ -2,6 +2,7 @@ #include "Supplier_Router.h" #include "Options.h" +#include "ace/os_include/os_assert.h" ACE_RCSID(Event_Server, Supplier_Router, "$Id$") diff --git a/examples/ASX/Message_Queue/bounded_buffer.cpp b/examples/ASX/Message_Queue/bounded_buffer.cpp index a631d2d4861..ada4c6304d1 100644 --- a/examples/ASX/Message_Queue/bounded_buffer.cpp +++ b/examples/ASX/Message_Queue/bounded_buffer.cpp @@ -6,6 +6,8 @@ #include "ace/Message_Queue.h" #include "ace/Thread_Manager.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(Message_Queue, bounded_buffer, "$Id$") diff --git a/examples/ASX/Message_Queue/buffer_stream.cpp b/examples/ASX/Message_Queue/buffer_stream.cpp index 80681b44fb8..33dd26f5a34 100644 --- a/examples/ASX/Message_Queue/buffer_stream.cpp +++ b/examples/ASX/Message_Queue/buffer_stream.cpp @@ -13,6 +13,7 @@ #include "ace/Stream.h" #include "ace/Module.h" #include "ace/Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Message_Queue, buffer_stream, "$Id$") diff --git a/examples/ASX/UPIPE_Event_Server/Options.cpp b/examples/ASX/UPIPE_Event_Server/Options.cpp index d5055415ded..d5a01cb9f0e 100644 --- a/examples/ASX/UPIPE_Event_Server/Options.cpp +++ b/examples/ASX/UPIPE_Event_Server/Options.cpp @@ -3,6 +3,8 @@ #include "ace/Get_Opt.h" #include "ace/Synch.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_Thread.h" +#include "ace/OS_NS_stdio.h" #include "Options.h" diff --git a/examples/ASX/UPIPE_Event_Server/Options.h b/examples/ASX/UPIPE_Event_Server/Options.h index 3badf1e9daf..2a98787398b 100644 --- a/examples/ASX/UPIPE_Event_Server/Options.h +++ b/examples/ASX/UPIPE_Event_Server/Options.h @@ -6,7 +6,7 @@ #ifndef DEVICE_OPTIONS_H #define DEVICE_OPTIONS_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/C++NPv1/Logging_Client.cpp b/examples/C++NPv1/Logging_Client.cpp index d3308ea649e..2a542ba9f4a 100644 --- a/examples/C++NPv1/Logging_Client.cpp +++ b/examples/C++NPv1/Logging_Client.cpp @@ -4,7 +4,7 @@ ** Copyright 2001 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" +#include "ace/OS_NS_sys_time.h" #include "ace/CDR_Stream.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Connector.h" diff --git a/examples/C++NPv1/Logging_Handler.cpp b/examples/C++NPv1/Logging_Handler.cpp index 002958f028e..a1bcb5851fd 100644 --- a/examples/C++NPv1/Logging_Handler.cpp +++ b/examples/C++NPv1/Logging_Handler.cpp @@ -12,7 +12,7 @@ #include "Logging_Handler.h" #include "ace/streams.h" - +#include "ace/os_include/os_netdb.h" int operator>> (ACE_InputCDR &cdr, ACE_Log_Record &log_record) { diff --git a/examples/C++NPv1/Logging_Server.cpp b/examples/C++NPv1/Logging_Server.cpp index ec4317a6d97..c685412c769 100644 --- a/examples/C++NPv1/Logging_Server.cpp +++ b/examples/C++NPv1/Logging_Server.cpp @@ -10,6 +10,8 @@ #include "ace/INET_Addr.h" #include "ace/SOCK_Stream.h" #include "Logging_Server.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_netdb.h" int Logging_Server::run (int argc, char *argv[]) { @@ -56,10 +58,10 @@ int Logging_Server::make_log_file (ACE_FILE_IO &logging_file, ACE_INET_Addr logging_peer_addr; logging_peer->get_remote_addr (logging_peer_addr); logging_peer_addr.get_host_name (filename, MAXHOSTNAMELEN); - strcat (filename, ".log"); + ACE_OS::strcat (filename, ".log"); } else - strcpy (filename, "logging_server.log"); + ACE_OS::strcpy (filename, "logging_server.log"); ACE_FILE_Connector connector; return connector.connect (logging_file, diff --git a/examples/C++NPv1/Reactive_Logging_Server_Ex.h b/examples/C++NPv1/Reactive_Logging_Server_Ex.h index 371190f8f75..ad9724df3a4 100644 --- a/examples/C++NPv1/Reactive_Logging_Server_Ex.h +++ b/examples/C++NPv1/Reactive_Logging_Server_Ex.h @@ -15,9 +15,9 @@ #include "ace/Log_Record.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" -#include "ace/Synch.h" #include "Logging_Server.h" #include "Logging_Handler.h" +#include "ace/Null_Mutex.h" typedef ACE_Hash_Map_Manager<ACE_HANDLE, ACE_FILE_IO *, diff --git a/examples/C++NPv2/AC_Client_Logging_Daemon.cpp b/examples/C++NPv2/AC_Client_Logging_Daemon.cpp index 601fa6e0ec7..00078e85673 100644 --- a/examples/C++NPv2/AC_Client_Logging_Daemon.cpp +++ b/examples/C++NPv2/AC_Client_Logging_Daemon.cpp @@ -4,7 +4,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/Acceptor.h" #include "ace/Connector.h" #include "ace/Get_Opt.h" @@ -399,7 +398,7 @@ int AC_Client_Logging_Daemon::init u_short cld_port = ACE_DEFAULT_SERVICE_PORT; u_short sld_port = ACE_DEFAULT_LOGGING_SERVER_PORT; ACE_TCHAR sld_host[MAXHOSTNAMELEN]; - ACE_OS_String::strcpy (sld_host, ACE_LOCALHOST); + ACE_OS::strcpy (sld_host, ACE_LOCALHOST); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:r:s:"), 0); get_opt.long_option (ACE_TEXT ("client_port"), 'p', @@ -420,7 +419,7 @@ int AC_Client_Logging_Daemon::init (u_short, ACE_OS::atoi (get_opt.opt_arg ())); break; case 's': // Server logging daemon hostname. - ACE_OS_String::strsncpy + ACE_OS::strsncpy (sld_host, get_opt.opt_arg (), MAXHOSTNAMELEN); break; } diff --git a/examples/C++NPv2/AIO_Client_Logging_Daemon.cpp b/examples/C++NPv2/AIO_Client_Logging_Daemon.cpp index 923ea7bfe67..3d12842739d 100644 --- a/examples/C++NPv2/AIO_Client_Logging_Daemon.cpp +++ b/examples/C++NPv2/AIO_Client_Logging_Daemon.cpp @@ -4,7 +4,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/Asynch_Acceptor.h" #include "ace/Asynch_Connector.h" #include "ace/Asynch_IO.h" @@ -386,7 +385,7 @@ int AIO_Client_Logging_Daemon::init u_short cld_port = ACE_DEFAULT_SERVICE_PORT; u_short sld_port = ACE_DEFAULT_LOGGING_SERVER_PORT; ACE_TCHAR sld_host[MAXHOSTNAMELEN]; - ACE_OS_String::strcpy (sld_host, ACE_LOCALHOST); + ACE_OS::strcpy (sld_host, ACE_LOCALHOST); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:r:s:"), 0); get_opt.long_option (ACE_TEXT ("client_port"), 'p', @@ -407,7 +406,7 @@ int AIO_Client_Logging_Daemon::init (u_short, ACE_OS::atoi (get_opt.opt_arg ())); break; case 's': // Server logging daemon hostname. - ACE_OS_String::strsncpy + ACE_OS::strsncpy (sld_host, get_opt.opt_arg (), MAXHOSTNAMELEN); break; } diff --git a/examples/C++NPv2/Client_Logging_Daemon.cpp b/examples/C++NPv2/Client_Logging_Daemon.cpp index 696c0b1bc6c..b60f16d795d 100644 --- a/examples/C++NPv2/Client_Logging_Daemon.cpp +++ b/examples/C++NPv2/Client_Logging_Daemon.cpp @@ -4,7 +4,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/Event_Handler.h" #include "ace/INET_Addr.h" #include "ace/Get_Opt.h" @@ -14,14 +13,13 @@ #include "ace/Reactor.h" #include "ace/Service_Object.h" #include "ace/Signal.h" -#include "ace/Synch.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Stream.h" #include "ace/Thread_Manager.h" #include "Logging_Acceptor.h" #include "CLD_export.h" - +#include "ace/os_include/os_netdb.h" #if !defined (FLUSH_TIMEOUT) #define FLUSH_TIMEOUT 120 /* 120 seconds == 2 minutes. */ @@ -332,7 +330,7 @@ int Client_Logging_Daemon::init (int argc, ACE_TCHAR *argv[]) { u_short cld_port = ACE_DEFAULT_SERVICE_PORT; u_short sld_port = ACE_DEFAULT_LOGGING_SERVER_PORT; ACE_TCHAR sld_host[MAXHOSTNAMELEN]; - ACE_OS_String::strcpy (sld_host, ACE_LOCALHOST); + ACE_OS::strcpy (sld_host, ACE_LOCALHOST); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:r:s:"), 0); get_opt.long_option (ACE_TEXT ("client_port"), 'p', @@ -353,7 +351,7 @@ int Client_Logging_Daemon::init (int argc, ACE_TCHAR *argv[]) { (u_short, ACE_OS::atoi (get_opt.opt_arg ())); break; case 's': // Server logging daemon hostname. - ACE_OS_String::strsncpy + ACE_OS::strsncpy (sld_host, get_opt.opt_arg (), MAXHOSTNAMELEN); break; } diff --git a/examples/C++NPv2/Configurable_Logging_Server.cpp b/examples/C++NPv2/Configurable_Logging_Server.cpp index 7ba77999b42..bcd6d42b884 100644 --- a/examples/C++NPv2/Configurable_Logging_Server.cpp +++ b/examples/C++NPv2/Configurable_Logging_Server.cpp @@ -4,7 +4,7 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Reactor.h" diff --git a/examples/C++NPv2/Logging_Event_Handler.cpp b/examples/C++NPv2/Logging_Event_Handler.cpp index e6de908074d..d805e776390 100644 --- a/examples/C++NPv2/Logging_Event_Handler.cpp +++ b/examples/C++NPv2/Logging_Event_Handler.cpp @@ -7,6 +7,8 @@ #include "ace/FILE_Connector.h" #include "Logging_Event_Handler.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_netdb.h" int Logging_Event_Handler::open () { @@ -16,7 +18,7 @@ int Logging_Event_Handler::open () { logging_handler_.peer ().get_remote_addr (logging_peer_addr); logging_peer_addr.get_host_name (filename, MAXHOSTNAMELEN); - strcat (filename, LOGFILE_SUFFIX); + ACE_OS::strcat (filename, LOGFILE_SUFFIX); ACE_FILE_Connector connector; connector.connect (log_file_, diff --git a/examples/C++NPv2/Logging_Handler.cpp b/examples/C++NPv2/Logging_Handler.cpp index 2f755bdf82b..247164cd361 100644 --- a/examples/C++NPv2/Logging_Handler.cpp +++ b/examples/C++NPv2/Logging_Handler.cpp @@ -12,7 +12,7 @@ #include "ace/streams.h" #include "Logging_Handler.h" - +#include "ace/os_include/os_netdb.h" int operator>> (ACE_InputCDR &cdr, ACE_Log_Record &log_record) { diff --git a/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp b/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp index 1a5c8c11cae..128ad5cabd3 100644 --- a/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp +++ b/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp @@ -11,6 +11,8 @@ #include "ace/Auto_Ptr.h" #include "ace/INET_Addr.h" #include "Reactor_Logging_Server_Adapter.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" template <class ACCEPTOR> int Reactor_Logging_Server_Adapter<ACCEPTOR>::init (int argc, @@ -45,13 +47,13 @@ Reactor_Logging_Server_Adapter<ACCEPTOR>::info ACE_OS::sprintf (buf, ACE_TEXT ("%hu"), local_addr.get_port_number ()); - ACE_OS_String::strcat + ACE_OS::strcat (buf, ACE_TEXT ("/tcp # Reactor-based logging server\n")); if (*bufferp == 0) *bufferp = ACE::strnew (buf); else - ACE_OS_String::strncpy (*bufferp, buf, length); - return ACE_OS_String::strlen (*bufferp); + ACE_OS::strncpy (*bufferp, buf, length); + return ACE_OS::strlen (*bufferp); } diff --git a/examples/C++NPv2/SR_Configurable_Logging_Server.cpp b/examples/C++NPv2/SR_Configurable_Logging_Server.cpp index 4e8eb05e5e5..764af2c9839 100644 --- a/examples/C++NPv2/SR_Configurable_Logging_Server.cpp +++ b/examples/C++NPv2/SR_Configurable_Logging_Server.cpp @@ -4,7 +4,7 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Reactor.h" #include "ace/Select_Reactor.h" #include "ace/Service_Config.h" diff --git a/examples/C++NPv2/Select_Reactor_Logging_Server.cpp b/examples/C++NPv2/Select_Reactor_Logging_Server.cpp index a7c80a3c4eb..b42e8ef359c 100644 --- a/examples/C++NPv2/Select_Reactor_Logging_Server.cpp +++ b/examples/C++NPv2/Select_Reactor_Logging_Server.cpp @@ -63,7 +63,7 @@ static ACE_THR_FUNC_RETURN controller (void *arg) { for (;;) { char user_input[80]; gets (user_input); - if (ACE_OS_String::strcmp (user_input, "quit") == 0) { + if (ACE_OS::strcmp (user_input, "quit") == 0) { reactor->notify (quit_handler); break; } diff --git a/examples/C++NPv2/Server_Shutdown.cpp b/examples/C++NPv2/Server_Shutdown.cpp index 7aa53224ec0..51cbe716203 100644 --- a/examples/C++NPv2/Server_Shutdown.cpp +++ b/examples/C++NPv2/Server_Shutdown.cpp @@ -4,7 +4,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/Event_Handler.h" #include "ace/Reactor.h" #include "ace/Service_Object.h" @@ -52,7 +51,7 @@ static ACE_THR_FUNC_RETURN controller (void *arg) { for (;;) { char user_input[80]; gets (user_input); - if (ACE_OS_String::strcmp (user_input, "quit") == 0) { + if (ACE_OS::strcmp (user_input, "quit") == 0) { reactor->notify (quit_handler); break; } diff --git a/examples/C++NPv2/Service_Reporter.cpp b/examples/C++NPv2/Service_Reporter.cpp index ba241ec67ea..9080e4e6f5e 100644 --- a/examples/C++NPv2/Service_Reporter.cpp +++ b/examples/C++NPv2/Service_Reporter.cpp @@ -4,7 +4,7 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" #include "ace/Get_Opt.h" #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" @@ -51,12 +51,12 @@ int Service_Reporter::handle_input (ACE_HANDLE) { iovec iov[3]; iov[0].iov_base = ACE_const_cast (char *, st->name ()); iov[0].iov_len = - ACE_OS_String::strlen (st->name ()) * sizeof (ACE_TCHAR); + ACE_OS::strlen (st->name ()) * sizeof (ACE_TCHAR); const ACE_TCHAR *state = st->active () ? ACE_TEXT (" (active) ") : ACE_TEXT (" (paused) "); iov[1].iov_base = ACE_const_cast (char *, state); iov[1].iov_len = - ACE_OS_String::strlen (state) * sizeof (ACE_TCHAR); + ACE_OS::strlen (state) * sizeof (ACE_TCHAR); ACE_TCHAR *report = 0; // Ask info() to allocate buffer int len = st->type ()->info (&report, 0); iov[2].iov_base = ACE_static_cast (char *, report); @@ -79,13 +79,13 @@ int Service_Reporter::info (ACE_TCHAR **bufferp, ACE_TCHAR buf[BUFSIZ]; ACE_OS::sprintf (buf, ACE_TEXT ("%hu"), local_addr.get_port_number ()); - ACE_OS_String::strcat + ACE_OS::strcat (buf, ACE_TEXT ("/tcp # lists services in daemon\n")); if (*bufferp == 0) *bufferp = ACE::strnew (buf); else - ACE_OS_String::strncpy (*bufferp, buf, length); - return ACE_OS_String::strlen (*bufferp); + ACE_OS::strncpy (*bufferp, buf, length); + return ACE_OS::strlen (*bufferp); } diff --git a/examples/C++NPv2/TPC_Logging_Server.cpp b/examples/C++NPv2/TPC_Logging_Server.cpp index 7c78c02d22a..c01a4c54459 100644 --- a/examples/C++NPv2/TPC_Logging_Server.cpp +++ b/examples/C++NPv2/TPC_Logging_Server.cpp @@ -6,7 +6,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/FILE_Addr.h" #include "ace/FILE_Connector.h" #include "Reactor_Logging_Server_Adapter.h" @@ -20,7 +19,7 @@ int TPC_Logging_Handler::open (void *) { peer ().get_remote_addr (logging_peer_addr); logging_peer_addr.get_host_name (filename, MAXHOSTNAMELEN); - ACE_OS_String::strcat (filename, LOGFILE_SUFFIX); + ACE_OS::strcat (filename, LOGFILE_SUFFIX); ACE_FILE_Connector connector; connector.connect (log_file_, diff --git a/examples/C++NPv2/TP_Logging_Server.cpp b/examples/C++NPv2/TP_Logging_Server.cpp index 251179032a9..3f0cb9bb51c 100644 --- a/examples/C++NPv2/TP_Logging_Server.cpp +++ b/examples/C++NPv2/TP_Logging_Server.cpp @@ -4,7 +4,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/Message_Block.h" #include "TP_Logging_Server.h" diff --git a/examples/C++NPv2/TP_Logging_Server.h b/examples/C++NPv2/TP_Logging_Server.h index 1ea62c796ed..be7d35316e1 100644 --- a/examples/C++NPv2/TP_Logging_Server.h +++ b/examples/C++NPv2/TP_Logging_Server.h @@ -7,7 +7,6 @@ #ifndef _TP_LOGGING_SERVER_H #define _TP_LOGGING_SERVER_H -#include "ace/OS.h" #include "ace/Auto_Ptr.h" #include "ace/Singleton.h" #include "ace/Synch.h" diff --git a/examples/C++NPv2/TP_Reactor_Logging_Server.cpp b/examples/C++NPv2/TP_Reactor_Logging_Server.cpp index d1ac0536c78..a85196d16ce 100644 --- a/examples/C++NPv2/TP_Reactor_Logging_Server.cpp +++ b/examples/C++NPv2/TP_Reactor_Logging_Server.cpp @@ -64,7 +64,7 @@ static ACE_THR_FUNC_RETURN controller (void *arg) { for (;;) { char user_input[80]; gets (user_input); - if (ACE_OS_String::strcmp (user_input, "quit") == 0) { + if (ACE_OS::strcmp (user_input, "quit") == 0) { reactor->notify (quit_handler); break; } diff --git a/examples/C++NPv2/WFMO_Reactor_Logging_Server.cpp b/examples/C++NPv2/WFMO_Reactor_Logging_Server.cpp index 5cdc6814f2b..b68e4f742bb 100644 --- a/examples/C++NPv2/WFMO_Reactor_Logging_Server.cpp +++ b/examples/C++NPv2/WFMO_Reactor_Logging_Server.cpp @@ -48,7 +48,7 @@ public: return -1; user_input[count] = '\0'; - if (ACE_OS_String::strncmp (user_input, "quit", 4) == 0) + if (ACE_OS::strncmp (user_input, "quit", 4) == 0) return -1; return 0; } diff --git a/examples/C++NPv2/display_logfile.cpp b/examples/C++NPv2/display_logfile.cpp index 16ace4a5cb5..612e364ecc6 100644 --- a/examples/C++NPv2/display_logfile.cpp +++ b/examples/C++NPv2/display_logfile.cpp @@ -4,7 +4,6 @@ ** Copyright 2002 Addison Wesley. All Rights Reserved. */ -#include "ace/OS.h" #include "ace/CDR_Stream.h" #include "ace/FILE_Addr.h" #include "ace/FILE_Connector.h" @@ -13,9 +12,10 @@ #include "ace/Module.h" #include "ace/SString.h" #include "ace/Stream.h" -#include "ace/Synch.h" #include "ace/Task.h" #include "ace/Thread_Manager.h" +#include "ace/Lock_Adapter_T.h" +#include "ace/OS_NS_time.h" template <class TASK> class Logrec_Module : public ACE_Module<ACE_SYNCH> @@ -79,7 +79,7 @@ public: // extract what's needed, crunch the block to move all remaining // data to the beginning and read more from the file. for (;;) { - size_t name_len = ACE_OS_String::strnlen + size_t name_len = ACE_OS::strnlen (mblk.rd_ptr (), mblk.length ()); if (name_len == mblk.length ()) break; diff --git a/examples/DLL/Newsweek.cpp b/examples/DLL/Newsweek.cpp index 33e6d9868a6..4d90c5e333c 100644 --- a/examples/DLL/Newsweek.cpp +++ b/examples/DLL/Newsweek.cpp @@ -5,6 +5,7 @@ #include "Newsweek.h" #include "ace/Log_Msg.h" #include "ace/svc_export.h" +#include "ace/OS_Memory.h" // Implementation of the abstract class method which describes // the magazine. diff --git a/examples/DLL/Newsweek.h b/examples/DLL/Newsweek.h index 2e6d634cafa..82f7c74f49f 100644 --- a/examples/DLL/Newsweek.h +++ b/examples/DLL/Newsweek.h @@ -21,8 +21,8 @@ #ifndef NEWSWEEK_H #define NEWSWEEK_H -#include "ace/OS.h" #include "Magazine.h" +#include "ace/os_include/os_stddef.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/DLL/Today.cpp b/examples/DLL/Today.cpp index 1cc087f38f4..359826c94a9 100644 --- a/examples/DLL/Today.cpp +++ b/examples/DLL/Today.cpp @@ -5,6 +5,7 @@ #include "Today.h" #include "ace/Log_Msg.h" #include "ace/svc_export.h" +#include "ace/OS_Memory.h" // Implementation of the abstract class method which describes the // magazine. diff --git a/examples/DLL/Today.h b/examples/DLL/Today.h index 6b0fdaa2c28..bae5d238e94 100644 --- a/examples/DLL/Today.h +++ b/examples/DLL/Today.h @@ -21,8 +21,8 @@ #ifndef TODAY_H #define TODAY_H -#include "ace/OS.h" #include "Magazine.h" +#include "ace/os_include/os_stddef.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/IPC_SAP/ATM_SAP/CPP-client.cpp b/examples/IPC_SAP/ATM_SAP/CPP-client.cpp index 2a00d136e33..cbe2c00ae5c 100644 --- a/examples/IPC_SAP/ATM_SAP/CPP-client.cpp +++ b/examples/IPC_SAP/ATM_SAP/CPP-client.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/ATM_Connector.h" #include "ace/ATM_Addr.h" #include "ace/High_Res_Timer.h" diff --git a/examples/IPC_SAP/ATM_SAP/CPP-server.cpp b/examples/IPC_SAP/ATM_SAP/CPP-server.cpp index 57489b9b652..8cf6e9c9c92 100644 --- a/examples/IPC_SAP/ATM_SAP/CPP-server.cpp +++ b/examples/IPC_SAP/ATM_SAP/CPP-server.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/ATM_Acceptor.h" #include "ace/ATM_Addr.h" #include "ace/High_Res_Timer.h" diff --git a/examples/IPC_SAP/DEV_SAP/reader/reader.cpp b/examples/IPC_SAP/DEV_SAP/reader/reader.cpp index c6f8801380f..9a22e3f756f 100644 --- a/examples/IPC_SAP/DEV_SAP/reader/reader.cpp +++ b/examples/IPC_SAP/DEV_SAP/reader/reader.cpp @@ -1,6 +1,5 @@ // $Id$ -#include "ace/OS.h" #include "ace/DEV_Addr.h" #include "ace/DEV_Connector.h" #include "ace/DEV_IO.h" diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp index 9186e5f6d1e..3f267ba66ce 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-client.cpp @@ -1,7 +1,11 @@ // $Id$ #include "ace/FIFO_Send_Msg.h" -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_string.h" ACE_RCSID(FIFO_SAP, FIFO_Msg_client, "$Id$") @@ -19,7 +23,7 @@ ACE_TMAIN (int, ACE_TCHAR *[]) while (ACE_OS::fgets (buf, sizeof buf, stdin) != 0) { - msg.len = strlen (buf) + 1; + msg.len = ACE_OS::strlen (buf) + 1; if (client.send (ACE_OS::rand () % 11, &msg) == -1) ::perror ("send"); } diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp index da38671afdc..6b653ba24e5 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp @@ -2,6 +2,8 @@ #include "ace/FIFO_Recv_Msg.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_main.h" ACE_RCSID(FIFO_SAP, FIFO_Msg_server, "$Id$") diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp index dac5c740120..8c80809f380 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp @@ -2,6 +2,9 @@ #include "ace/FIFO_Send.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_main.h" ACE_RCSID(FIFO_SAP, FIFO_client, "$Id$") diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp index 8ef94e9e905..eb31e171725 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-server.cpp @@ -2,6 +2,8 @@ #include "ace/FIFO_Recv.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_main.h" ACE_RCSID(FIFO_SAP, FIFO_server, "$Id$") diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp index 3a79d275215..277874db3cd 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp @@ -9,6 +9,7 @@ #include "ace/FIFO_Recv.h" #include "ace/FIFO_Send.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_wait.h" ACE_RCSID(FIFO_SAP, FIFO_test, "$Id$") diff --git a/examples/IPC_SAP/FILE_SAP/client.cpp b/examples/IPC_SAP/FILE_SAP/client.cpp index ea04ffed654..0a04f3b2d09 100644 --- a/examples/IPC_SAP/FILE_SAP/client.cpp +++ b/examples/IPC_SAP/FILE_SAP/client.cpp @@ -1,9 +1,11 @@ // $Id$ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/FILE_Addr.h" #include "ace/FILE_Connector.h" #include "ace/FILE_IO.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(FILE_SAP, client, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp b/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp index d9c6ca3ac18..724491fdb0a 100644 --- a/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/C-inclient.cpp @@ -1,6 +1,13 @@ // $Id$ -#include "ace/OS.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_netdb.h" +#include "ace/Default_Constants.h" ACE_RCSID(SOCK_SAP, C_inclient, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp b/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp index 6f53ab2db9d..3273a306cdc 100644 --- a/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/C-inserver.cpp @@ -1,6 +1,14 @@ // $Id$ -#include "ace/OS.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_errno.h" +#include "ace/Default_Constants.h" ACE_RCSID(SOCK_SAP, C_inserver, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp index ea1835908cb..bba003e1c39 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp @@ -6,15 +6,16 @@ // is useful as a baseline to compare against ORB-level performance // for the same types of data. +#include "CPP-inclient.h" + #include "ace/SOCK_Connector.h" #include "ace/INET_Addr.h" #include "ace/Thread_Manager.h" #include "ace/Singleton.h" #include "ace/Get_Opt.h" #include "ace/High_Res_Timer.h" -#include "ace/Synch.h" - -#include "CPP-inclient.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_main.h" ACE_RCSID(SOCK_SAP, CPP_inclient, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.h b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.h index 266de7f32ea..de5f4aac030 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inclient.h +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inclient.h @@ -6,9 +6,8 @@ #ifndef __CPP_INCLIENT_H #define __CPP_INCLIENT_H -#include "ace/OS.h" #include "ace/SOCK_Stream.h" -#include "ace/Synch.h" +#include "ace/Barrier.h" class Options // = TITLE diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-fancy.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-fancy.cpp index 9034292f638..8be302f8ebd 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-fancy.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-fancy.cpp @@ -5,12 +5,14 @@ // supports threads it uses a thread-per-connection concurrency model. // Otherwise, it uses a single-threaded iterative server model. +#include "ace/OS_main.h" #include "ace/SOCK_Acceptor.h" #include "ace/Svc_Handler.h" #include "ace/Singleton.h" #include "ace/Synch.h" #include "ace/Profile_Timer.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_sys_select.h" #include "CPP-inserver-fancy.h" diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp index a1d41fc5941..a281d2e380d 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp @@ -5,10 +5,13 @@ // single-threaded concurrent server. This server program can be // driven by the oneway test mode of CPP-inclient.cpp. +#include "ace/OS_main.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_poll.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SOCK_SAP, CPP_inserver_poll, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp index 094af0673b1..71b568fd9cc 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver.cpp @@ -9,6 +9,8 @@ #include "ace/Thread_Manager.h" #include "ace/Handle_Set.h" #include "ace/Profile_Timer.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_main.h" ACE_RCSID(SOCK_SAP, CPP_inserver, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp index 6fd627a50bb..850570bd02f 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp @@ -5,7 +5,6 @@ #include "ace/LSOCK_Connector.h" #include "ace/UNIX_Addr.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" ACE_RCSID(SOCK_SAP, CPP_unclient, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp index 97e7adb61e3..97b988e2853 100644 --- a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp @@ -3,7 +3,7 @@ #include "ace/LSOCK_Connector.h" #include "ace/UNIX_Addr.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" +#include "ace/OS_main.h" ACE_RCSID(SOCK_SAP, FD_unclient, "$Id$") diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp index 66121d8c505..bf86d12082e 100644 --- a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp @@ -4,7 +4,9 @@ #include "ace/LSOCK_Stream.h" #include "ace/UNIX_Addr.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SOCK_SAP, FD_unserver, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp b/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp index 17ea66317e4..1c8c2c3dede 100644 --- a/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp @@ -1,8 +1,10 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Connector.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" ACE_RCSID(SPIPE_SAP, NPClient, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp b/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp index c7ea7c12eca..762a634b015 100644 --- a/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp @@ -3,6 +3,7 @@ #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SPIPE_SAP, NPServer, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/client.cpp b/examples/IPC_SAP/SPIPE_SAP/client.cpp index 989a8ac3c49..ad0ee029dbd 100644 --- a/examples/IPC_SAP/SPIPE_SAP/client.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/client.cpp @@ -1,8 +1,11 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Connector.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" ACE_RCSID(SPIPE_SAP, client, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp b/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp index febcfeca0e0..19c41f7cbef 100644 --- a/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp @@ -1,8 +1,10 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SPIPE_SAP, consumer_msg, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp b/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp index 84f9e96ec05..95f088eff46 100644 --- a/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp @@ -1,8 +1,10 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SPIPE_SAP, consumer_read, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp b/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp index 088b7356a30..e663aa7f84f 100644 --- a/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp @@ -1,8 +1,10 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Connector.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SPIPE_SAP, producer_msg, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp b/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp index fe7d23f9bf8..03aa5ea244a 100644 --- a/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/producer_read.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Connector.h" #include "ace/Log_Msg.h" diff --git a/examples/IPC_SAP/SPIPE_SAP/server.cpp b/examples/IPC_SAP/SPIPE_SAP/server.cpp index 728eb824bf8..f2f5ef12a01 100644 --- a/examples/IPC_SAP/SPIPE_SAP/server.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/server.cpp @@ -1,8 +1,11 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SPIPE_Addr.h" #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_poll.h" ACE_RCSID(SPIPE_SAP, server, "$Id$") diff --git a/examples/IPC_SAP/SPIPE_SAP/shared.h b/examples/IPC_SAP/SPIPE_SAP/shared.h index 368ee0a7615..47f2e8db6bc 100644 --- a/examples/IPC_SAP/SPIPE_SAP/shared.h +++ b/examples/IPC_SAP/SPIPE_SAP/shared.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ // $Id$ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/IPC_SAP/SSL_SAP/SSL-client-simple.h b/examples/IPC_SAP/SSL_SAP/SSL-client-simple.h index 4fdd92c8a49..d044b7262e5 100644 --- a/examples/IPC_SAP/SSL_SAP/SSL-client-simple.h +++ b/examples/IPC_SAP/SSL_SAP/SSL-client-simple.h @@ -7,9 +7,8 @@ #ifndef ACE_SSL_CLIENT_SIMPLE_H #define ACE_SSL_CLIENT_SIMPLE_H -#include "ace/OS.h" - #include "ace/SSL/SSL_SOCK_Stream.h" +#include "ace/Time_Value.h" class Options // = TITLE diff --git a/examples/IPC_SAP/SSL_SAP/SSL-client.h b/examples/IPC_SAP/SSL_SAP/SSL-client.h index e01729845c7..728e2e4a88e 100644 --- a/examples/IPC_SAP/SSL_SAP/SSL-client.h +++ b/examples/IPC_SAP/SSL_SAP/SSL-client.h @@ -7,8 +7,8 @@ #ifndef __ACE_SSL_CLIENT_H #define __ACE_SSL_CLIENT_H -#include "ace/OS.h" -#include "ace/Synch.h" +#include "ace/BArrier.h" +#include "Time_Value.h" #include "ace/SSL/SSL_SOCK_Stream.h" diff --git a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp index 480ed4f9adf..fe6c1ff09ba 100644 --- a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp +++ b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp @@ -3,6 +3,9 @@ #include "ace/TLI_Connector.h" #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" +#include "ace/Time_Value.h" ACE_RCSID(TLI_SAP, CPP_client, "$Id$") diff --git a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp index 08d3162dca1..8f8fdda9efe 100644 --- a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp +++ b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp @@ -2,6 +2,8 @@ #include "ace/TLI_Acceptor.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(TLI_SAP, CPP_server, "$Id$") diff --git a/examples/IPC_SAP/TLI_SAP/db-client.cpp b/examples/IPC_SAP/TLI_SAP/db-client.cpp index aedb139967a..168c5beb1af 100644 --- a/examples/IPC_SAP/TLI_SAP/db-client.cpp +++ b/examples/IPC_SAP/TLI_SAP/db-client.cpp @@ -2,6 +2,9 @@ #include "ace/TLI_Connector.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_string.h" ACE_RCSID(TLI_SAP, db_client, "$Id$") diff --git a/examples/IPC_SAP/TLI_SAP/ftp-client.cpp b/examples/IPC_SAP/TLI_SAP/ftp-client.cpp index 6c6d1ced180..86f64df29c7 100644 --- a/examples/IPC_SAP/TLI_SAP/ftp-client.cpp +++ b/examples/IPC_SAP/TLI_SAP/ftp-client.cpp @@ -2,6 +2,9 @@ #include "ace/TLI_Connector.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(TLI_SAP, ftp_client, "$Id$") diff --git a/examples/IPC_SAP/UPIPE_SAP/ex1.cpp b/examples/IPC_SAP/UPIPE_SAP/ex1.cpp index 7de8e7e100f..ae071fa9afe 100644 --- a/examples/IPC_SAP/UPIPE_SAP/ex1.cpp +++ b/examples/IPC_SAP/UPIPE_SAP/ex1.cpp @@ -17,6 +17,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Stream.h" #include "ace/UPIPE_Acceptor.h" #include "ace/UPIPE_Connector.h" diff --git a/examples/IPC_SAP/UPIPE_SAP/ex2.cpp b/examples/IPC_SAP/UPIPE_SAP/ex2.cpp index d807f53857d..e19a83460ce 100644 --- a/examples/IPC_SAP/UPIPE_SAP/ex2.cpp +++ b/examples/IPC_SAP/UPIPE_SAP/ex2.cpp @@ -17,9 +17,11 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/UPIPE_Connector.h" #include "ace/UPIPE_Acceptor.h" #include "ace/Auto_Ptr.h" +#include "ace/OS_NS_time.h" ACE_RCSID(UPIPE_SAP, ex2, "$Id$") diff --git a/examples/IPC_SAP/UPIPE_SAP/ex3.cpp b/examples/IPC_SAP/UPIPE_SAP/ex3.cpp index 0ef3577f075..57ff4f34d9e 100644 --- a/examples/IPC_SAP/UPIPE_SAP/ex3.cpp +++ b/examples/IPC_SAP/UPIPE_SAP/ex3.cpp @@ -18,9 +18,11 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/UPIPE_Connector.h" #include "ace/UPIPE_Acceptor.h" #include "ace/Auto_Ptr.h" +#include "ace/OS_NS_time.h" ACE_RCSID(UPIPE_SAP, ex3, "$Id$") diff --git a/examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.cpp b/examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.cpp index dc7c3a11622..00e707ffc20 100644 --- a/examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.cpp +++ b/examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.cpp @@ -14,7 +14,6 @@ static char THIS_FILE[] = __FILE__; #endif -#include <ace/OS.h> #include <ace/ACE.h> ///////////////////////////////////////////////////////////////////////////// diff --git a/examples/Log_Msg/test_callback.cpp b/examples/Log_Msg/test_callback.cpp index a3057a88824..59f87bb4c44 100644 --- a/examples/Log_Msg/test_callback.cpp +++ b/examples/Log_Msg/test_callback.cpp @@ -18,10 +18,11 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Log_Msg.h" #include "ace/Log_Msg_Callback.h" #include "ace/Log_Record.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Log_Msg, test_callback, "$Id$") diff --git a/examples/Log_Msg/test_log_msg.cpp b/examples/Log_Msg/test_log_msg.cpp index 035520105d5..018ab3b8978 100644 --- a/examples/Log_Msg/test_log_msg.cpp +++ b/examples/Log_Msg/test_log_msg.cpp @@ -17,9 +17,11 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/streams.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" ACE_RCSID(Log_Msg, test_log_msg, "$Id$") diff --git a/examples/Log_Msg/test_ostream.cpp b/examples/Log_Msg/test_ostream.cpp index 6bc0bee4fa8..33b5cbfd498 100644 --- a/examples/Log_Msg/test_ostream.cpp +++ b/examples/Log_Msg/test_ostream.cpp @@ -17,7 +17,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/streams.h" #include "ace/Log_Msg.h" diff --git a/examples/Logger/Acceptor-server/server_loggerd.h b/examples/Logger/Acceptor-server/server_loggerd.h index dcb48be907f..debc98a38b3 100644 --- a/examples/Logger/Acceptor-server/server_loggerd.h +++ b/examples/Logger/Acceptor-server/server_loggerd.h @@ -8,7 +8,7 @@ #include "ace/SOCK_Stream.h" #include "ace/Svc_Handler.h" #include "ace/Synch.h" - +#include "ace/os_include/os_netdb.h" class Options { diff --git a/examples/Logger/client/logging_app.cpp b/examples/Logger/client/logging_app.cpp index e804ce04752..29f0174597d 100644 --- a/examples/Logger/client/logging_app.cpp +++ b/examples/Logger/client/logging_app.cpp @@ -6,6 +6,8 @@ #include "ace/SOCK_Connector.h" #include "ace/Log_Record.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(client, logging_app, "$Id$") diff --git a/examples/Logger/simple-server/Logging_Handler.h b/examples/Logger/simple-server/Logging_Handler.h index 6f960694947..633e04a167c 100644 --- a/examples/Logger/simple-server/Logging_Handler.h +++ b/examples/Logger/simple-server/Logging_Handler.h @@ -26,6 +26,7 @@ #include "ace/INET_Addr.h" #include "ace/SOCK_Stream.h" +#include "ace/os_include/os_netdb.h" class Logging_Handler : public ACE_Event_Handler // = TITLE diff --git a/examples/Map_Manager/test_hash_map_manager.cpp b/examples/Map_Manager/test_hash_map_manager.cpp index dec80fc5488..c8ecec29c68 100644 --- a/examples/Map_Manager/test_hash_map_manager.cpp +++ b/examples/Map_Manager/test_hash_map_manager.cpp @@ -1,9 +1,12 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Hash_Map_Manager.h" #include "ace/ACE.h" #include "ace/SString.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/OS_NS_stdio.h" +#include "ace/os_include/os_assert.h" ACE_RCSID(Map_Manager, test_hash_map_manager, "$Id$") diff --git a/examples/Mem_Map/IO-tests/IO_Test.cpp b/examples/Mem_Map/IO-tests/IO_Test.cpp index 72ab4bf53e5..0aebceb2de9 100644 --- a/examples/Mem_Map/IO-tests/IO_Test.cpp +++ b/examples/Mem_Map/IO-tests/IO_Test.cpp @@ -2,7 +2,9 @@ #if !defined(_WIN32) -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdio.h" #include "ace/Mem_Map.h" #include "ace/Log_Msg.h" #include "IO_Test.h" diff --git a/examples/Mem_Map/IO-tests/test_io.cpp b/examples/Mem_Map/IO-tests/test_io.cpp index 30e492e7283..362bdd16582 100644 --- a/examples/Mem_Map/IO-tests/test_io.cpp +++ b/examples/Mem_Map/IO-tests/test_io.cpp @@ -3,7 +3,7 @@ // Test program for different methods of copying files. #if !defined(_WIN32) -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" #include "ace/ACE.h" #include "ace/Profile_Timer.h" #include "ace/Get_Opt.h" diff --git a/examples/Mem_Map/file-reverse/file-reverse.cpp b/examples/Mem_Map/file-reverse/file-reverse.cpp index 93893c412d7..2e64c272c12 100644 --- a/examples/Mem_Map/file-reverse/file-reverse.cpp +++ b/examples/Mem_Map/file-reverse/file-reverse.cpp @@ -3,6 +3,7 @@ // Print a file in reverse by using the ACE memory mapped file // wrapper. It is SO easy to do compared with alternatives! +#include "ace/OS_main.h" #include "ace/Mem_Map.h" #include "ace/Log_Msg.h" diff --git a/examples/Misc/test_XtReactor1.cpp b/examples/Misc/test_XtReactor1.cpp index 6dc02e9ea45..297aff30785 100644 --- a/examples/Misc/test_XtReactor1.cpp +++ b/examples/Misc/test_XtReactor1.cpp @@ -3,6 +3,7 @@ // The following is another test that exercises the Eric C. Newton's // <ecn@clark.net> XtReactor implementation. +#include "ace/OS_main.h" #include "ace/XtReactor.h" #include "ace/Reactor.h" #include "ace/Message_Block.h" diff --git a/examples/Misc/test_XtReactor2.cpp b/examples/Misc/test_XtReactor2.cpp index 973a4432e5b..f338f4e8189 100644 --- a/examples/Misc/test_XtReactor2.cpp +++ b/examples/Misc/test_XtReactor2.cpp @@ -3,6 +3,7 @@ // The following test exercises the Eric C. Newton's <ecn@clark.net> // XtReactor implementation. +#include "ace/OS_main.h" #include "ace/XtReactor.h" #include "ace/Reactor.h" #include "ace/Message_Block.h" diff --git a/examples/Misc/test_dump.cpp b/examples/Misc/test_dump.cpp index 3c18ad6c105..1d908ba7505 100644 --- a/examples/Misc/test_dump.cpp +++ b/examples/Misc/test_dump.cpp @@ -4,6 +4,7 @@ // integrated into ACE components like the SOCK_Acceptor and // SOCK_Stream. +#include "ace/OS_main.h" #include "ace/Dump.h" #include "test_dump.h" diff --git a/examples/Misc/test_dump.h b/examples/Misc/test_dump.h index b6f9d35affa..9c7e0bb7de8 100644 --- a/examples/Misc/test_dump.h +++ b/examples/Misc/test_dump.h @@ -6,7 +6,7 @@ #define __TEST_DUMP_H #include "ace/Dump.h" -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" class SOCK { diff --git a/examples/Misc/test_get_opt.cpp b/examples/Misc/test_get_opt.cpp index 9fd3e66d929..3fd0a16ac80 100644 --- a/examples/Misc/test_get_opt.cpp +++ b/examples/Misc/test_get_opt.cpp @@ -2,7 +2,7 @@ // Test the ACE_Get_Opt class. -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" diff --git a/examples/Misc/test_profile_timer.cpp b/examples/Misc/test_profile_timer.cpp index 33ee7726ffc..adb6f599f83 100644 --- a/examples/Misc/test_profile_timer.cpp +++ b/examples/Misc/test_profile_timer.cpp @@ -1,7 +1,10 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Profile_Timer.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(Misc, test_profile_timer, "$Id$") diff --git a/examples/Misc/test_read_buffer.cpp b/examples/Misc/test_read_buffer.cpp index 0ec073a88a6..f03e2f597ee 100644 --- a/examples/Misc/test_read_buffer.cpp +++ b/examples/Misc/test_read_buffer.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Malloc_Base.h" #include "ace/Service_Config.h" #include "ace/Read_Buffer.h" diff --git a/examples/Misc/test_set.cpp b/examples/Misc/test_set.cpp index 5ed71dbeaf0..b5c81d64bc8 100644 --- a/examples/Misc/test_set.cpp +++ b/examples/Misc/test_set.cpp @@ -1,6 +1,6 @@ // $Id$ -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Containers.h" #include "ace/Log_Msg.h" diff --git a/examples/Misc/test_sstring.cpp b/examples/Misc/test_sstring.cpp index ef85290c1f7..67bd996e73c 100644 --- a/examples/Misc/test_sstring.cpp +++ b/examples/Misc/test_sstring.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/SString.h" #include "ace/Log_Msg.h" diff --git a/examples/Misc/test_trace.cpp b/examples/Misc/test_trace.cpp index 23aaf25251a..2def9cf613d 100644 --- a/examples/Misc/test_trace.cpp +++ b/examples/Misc/test_trace.cpp @@ -21,7 +21,7 @@ // Enable tracing #define ACE_NTRACE 0 -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Signal.h" #include "ace/Task.h" diff --git a/examples/NT_Service/ntsvc.cpp b/examples/NT_Service/ntsvc.cpp index d872769bc46..b20510bc84a 100644 --- a/examples/NT_Service/ntsvc.cpp +++ b/examples/NT_Service/ntsvc.cpp @@ -18,7 +18,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Reactor.h" #include "ntsvc.h" diff --git a/examples/Naming/test_multiple_contexts.cpp b/examples/Naming/test_multiple_contexts.cpp index b9a7b5969f8..06cb4d1c376 100644 --- a/examples/Naming/test_multiple_contexts.cpp +++ b/examples/Naming/test_multiple_contexts.cpp @@ -1,7 +1,9 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Naming_Context.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Naming, test_multiple_contexts, "$Id$") diff --git a/examples/Naming/test_non_existent.cpp b/examples/Naming/test_non_existent.cpp index 8225555138f..448594bd969 100644 --- a/examples/Naming/test_non_existent.cpp +++ b/examples/Naming/test_non_existent.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Naming_Context.h" #include "ace/Log_Msg.h" diff --git a/examples/Naming/test_open.cpp b/examples/Naming/test_open.cpp index 64166acc09d..97f8ca37373 100644 --- a/examples/Naming/test_open.cpp +++ b/examples/Naming/test_open.cpp @@ -1,7 +1,9 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Naming_Context.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Naming, test_open, "$Id$") diff --git a/examples/Naming/test_writers.cpp b/examples/Naming/test_writers.cpp index 85249691abd..114d9ee836e 100644 --- a/examples/Naming/test_writers.cpp +++ b/examples/Naming/test_writers.cpp @@ -1,7 +1,9 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Naming_Context.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Naming, test_writers, "$Id$") diff --git a/examples/OS/Process/imore.cpp b/examples/OS/Process/imore.cpp index e6470e8e777..7454bc198b3 100644 --- a/examples/OS/Process/imore.cpp +++ b/examples/OS/Process/imore.cpp @@ -22,7 +22,8 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_errno.h" #include "ace/FIFO_Recv.h" #include "ace/FIFO_Send.h" #include "ace/Pipe.h" diff --git a/examples/OS/Process/process.cpp b/examples/OS/Process/process.cpp index e68c4456604..577bd1af62a 100644 --- a/examples/OS/Process/process.cpp +++ b/examples/OS/Process/process.cpp @@ -17,7 +17,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_NS_errno.h" #include "ace/Get_Opt.h" #include "ace/Process.h" #include "ace/Log_Msg.h" diff --git a/examples/QOS/Change_Receiver_FlowSpec/Fill_ACE_QoS.h b/examples/QOS/Change_Receiver_FlowSpec/Fill_ACE_QoS.h index 710b8bd7c94..cdc06cea422 100644 --- a/examples/QOS/Change_Receiver_FlowSpec/Fill_ACE_QoS.h +++ b/examples/QOS/Change_Receiver_FlowSpec/Fill_ACE_QoS.h @@ -19,9 +19,9 @@ #include "ace/SString.h" #include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" #include "ace/ACE.h" -#include "ace/OS.h" #include "ace/OS_QoS.h" class Fill_ACE_QoS diff --git a/examples/QOS/Change_Receiver_FlowSpec/QoS_Util.cpp b/examples/QOS/Change_Receiver_FlowSpec/QoS_Util.cpp index 9a72bf56df1..4005b40a25a 100644 --- a/examples/QOS/Change_Receiver_FlowSpec/QoS_Util.cpp +++ b/examples/QOS/Change_Receiver_FlowSpec/QoS_Util.cpp @@ -6,6 +6,7 @@ #include "ace/Log_Msg.h" #include "ace/Get_Opt.h" #include "QoS_Util.h" +#include "ace/OS_NS_strings.h" ACE_RCSID(QOS, QoS_Util,"$Id$") diff --git a/examples/QOS/Change_Receiver_FlowSpec/Sender_QoS_Event_Handler.cpp b/examples/QOS/Change_Receiver_FlowSpec/Sender_QoS_Event_Handler.cpp index 5be73e3853b..561746a3641 100644 --- a/examples/QOS/Change_Receiver_FlowSpec/Sender_QoS_Event_Handler.cpp +++ b/examples/QOS/Change_Receiver_FlowSpec/Sender_QoS_Event_Handler.cpp @@ -17,7 +17,6 @@ #include "Sender_QoS_Event_Handler.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" #include "Fill_ACE_QoS.h" // Constructor. @@ -122,7 +121,7 @@ Sender_QoS_Event_Handler::handle_qos (ACE_HANDLE) char* msg = "Hello sent on a QoS enabled session !!\n"; iovec iov[1]; iov[0].iov_base = msg; - iov[0].iov_len = ACE_OS_String::strlen(msg); + iov[0].iov_len = ACE_OS::strlen(msg); size_t bytes_sent = 0; diff --git a/examples/QOS/Change_Receiver_FlowSpec/receiver.cpp b/examples/QOS/Change_Receiver_FlowSpec/receiver.cpp index 38252c4c221..abeda6cd58e 100644 --- a/examples/QOS/Change_Receiver_FlowSpec/receiver.cpp +++ b/examples/QOS/Change_Receiver_FlowSpec/receiver.cpp @@ -16,7 +16,6 @@ #define QOSEVENT_MAIN -#include "ace/OS.h" #include "ace/QoS/QoS_Session.h" #include "ace/QoS/QoS_Session_Factory.h" #include "ace/QoS/QoS_Decorator.h" diff --git a/examples/QOS/Change_Receiver_FlowSpec/sender.cpp b/examples/QOS/Change_Receiver_FlowSpec/sender.cpp index 775f01e5cd0..2dea073a12b 100644 --- a/examples/QOS/Change_Receiver_FlowSpec/sender.cpp +++ b/examples/QOS/Change_Receiver_FlowSpec/sender.cpp @@ -15,7 +15,6 @@ // ============================================================================ -#include "ace/OS.h" #include "ace/QoS/QoS_Session.h" #include "ace/QoS/QoS_Session_Factory.h" #include "ace/QoS/QoS_Session_Impl.h" diff --git a/examples/QOS/Change_Sender_TSpec/Fill_ACE_QoS.h b/examples/QOS/Change_Sender_TSpec/Fill_ACE_QoS.h index 710b8bd7c94..776d713e5e5 100644 --- a/examples/QOS/Change_Sender_TSpec/Fill_ACE_QoS.h +++ b/examples/QOS/Change_Sender_TSpec/Fill_ACE_QoS.h @@ -19,9 +19,8 @@ #include "ace/SString.h" #include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" +#include "ace/Null_Mutex.h" #include "ace/ACE.h" -#include "ace/OS.h" #include "ace/OS_QoS.h" class Fill_ACE_QoS diff --git a/examples/QOS/Change_Sender_TSpec/QoS_Util.cpp b/examples/QOS/Change_Sender_TSpec/QoS_Util.cpp index 9a72bf56df1..4005b40a25a 100644 --- a/examples/QOS/Change_Sender_TSpec/QoS_Util.cpp +++ b/examples/QOS/Change_Sender_TSpec/QoS_Util.cpp @@ -6,6 +6,7 @@ #include "ace/Log_Msg.h" #include "ace/Get_Opt.h" #include "QoS_Util.h" +#include "ace/OS_NS_strings.h" ACE_RCSID(QOS, QoS_Util,"$Id$") diff --git a/examples/QOS/Change_Sender_TSpec/Sender_QoS_Event_Handler.cpp b/examples/QOS/Change_Sender_TSpec/Sender_QoS_Event_Handler.cpp index d57a1b69812..7688bc34373 100644 --- a/examples/QOS/Change_Sender_TSpec/Sender_QoS_Event_Handler.cpp +++ b/examples/QOS/Change_Sender_TSpec/Sender_QoS_Event_Handler.cpp @@ -17,7 +17,6 @@ #include "Sender_QoS_Event_Handler.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" #include "Fill_ACE_QoS.h" // Constructor. @@ -122,7 +121,7 @@ Sender_QoS_Event_Handler::handle_qos (ACE_HANDLE) char* msg = "Hello sent on a QoS enabled session !!\n"; iovec iov[1]; iov[0].iov_base = msg; - iov[0].iov_len = ACE_OS_String::strlen(msg); + iov[0].iov_len = ACE_OS::strlen(msg); size_t bytes_sent = 0; diff --git a/examples/QOS/Change_Sender_TSpec/receiver.cpp b/examples/QOS/Change_Sender_TSpec/receiver.cpp index 7faf927b262..c01433655a2 100644 --- a/examples/QOS/Change_Sender_TSpec/receiver.cpp +++ b/examples/QOS/Change_Sender_TSpec/receiver.cpp @@ -16,7 +16,6 @@ #define QOSEVENT_MAIN -#include "ace/OS.h" #include "ace/QoS/QoS_Session.h" #include "ace/QoS/QoS_Session_Factory.h" #include "ace/QoS/QoS_Decorator.h" diff --git a/examples/QOS/Change_Sender_TSpec/sender.cpp b/examples/QOS/Change_Sender_TSpec/sender.cpp index 9468ca4647d..7777973116d 100644 --- a/examples/QOS/Change_Sender_TSpec/sender.cpp +++ b/examples/QOS/Change_Sender_TSpec/sender.cpp @@ -15,7 +15,6 @@ // ============================================================================ -#include "ace/OS.h" #include "ace/QoS/QoS_Session.h" #include "ace/QoS/QoS_Session_Factory.h" #include "ace/QoS/QoS_Session_Impl.h" diff --git a/examples/QOS/Simple/Fill_ACE_QoS.h b/examples/QOS/Simple/Fill_ACE_QoS.h index 710b8bd7c94..5d7f97b91c0 100644 --- a/examples/QOS/Simple/Fill_ACE_QoS.h +++ b/examples/QOS/Simple/Fill_ACE_QoS.h @@ -21,7 +21,7 @@ #include "ace/Hash_Map_Manager.h" #include "ace/Synch.h" #include "ace/ACE.h" -#include "ace/OS.h" +#include "ace/Null_Mutex.h" #include "ace/OS_QoS.h" class Fill_ACE_QoS diff --git a/examples/QOS/Simple/QoS_Util.cpp b/examples/QOS/Simple/QoS_Util.cpp index 9a72bf56df1..4005b40a25a 100644 --- a/examples/QOS/Simple/QoS_Util.cpp +++ b/examples/QOS/Simple/QoS_Util.cpp @@ -6,6 +6,7 @@ #include "ace/Log_Msg.h" #include "ace/Get_Opt.h" #include "QoS_Util.h" +#include "ace/OS_NS_strings.h" ACE_RCSID(QOS, QoS_Util,"$Id$") diff --git a/examples/QOS/Simple/Sender_QoS_Event_Handler.cpp b/examples/QOS/Simple/Sender_QoS_Event_Handler.cpp index 4d7891f191c..44334bf5229 100644 --- a/examples/QOS/Simple/Sender_QoS_Event_Handler.cpp +++ b/examples/QOS/Simple/Sender_QoS_Event_Handler.cpp @@ -119,7 +119,7 @@ Sender_QoS_Event_Handler::handle_qos (ACE_HANDLE) char* msg = "Hello sent on a QoS enabled session !!\n"; iovec iov[1]; iov[0].iov_base = msg; - iov[0].iov_len = ACE_OS_String::strlen(msg); + iov[0].iov_len = ACE_OS::strlen(msg); size_t bytes_sent = 0; diff --git a/examples/QOS/Simple/receiver.cpp b/examples/QOS/Simple/receiver.cpp index 30d0f2827d5..ecf85a51d45 100644 --- a/examples/QOS/Simple/receiver.cpp +++ b/examples/QOS/Simple/receiver.cpp @@ -16,7 +16,6 @@ #define QOSEVENT_MAIN -#include "ace/OS.h" #include "ace/QoS/QoS_Session.h" #include "ace/QoS/QoS_Session_Factory.h" #include "ace/QoS/QoS_Decorator.h" diff --git a/examples/QOS/Simple/sender.cpp b/examples/QOS/Simple/sender.cpp index baab9d72224..7ccce8eb351 100644 --- a/examples/QOS/Simple/sender.cpp +++ b/examples/QOS/Simple/sender.cpp @@ -15,7 +15,6 @@ // ============================================================================ -#include "ace/OS.h" #include "ace/QoS/QoS_Session.h" #include "ace/QoS/QoS_Session_Factory.h" #include "ace/QoS/QoS_Session_Impl.h" diff --git a/examples/RMCast/Send_File/Receiver.cpp b/examples/RMCast/Send_File/Receiver.cpp index e905373b4b3..9e305d5f3cd 100644 --- a/examples/RMCast/Send_File/Receiver.cpp +++ b/examples/RMCast/Send_File/Receiver.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/RMCast/RMCast_UDP_Reliable_Receiver.h" #include "ace/INET_Addr.h" #include "ace/FILE_IO.h" diff --git a/examples/RMCast/Send_File/Sender.cpp b/examples/RMCast/Send_File/Sender.cpp index 61c40d438ac..8699b5e017e 100644 --- a/examples/RMCast/Send_File/Sender.cpp +++ b/examples/RMCast/Send_File/Sender.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/RMCast/RMCast_UDP_Reliable_Sender.h" #include "ace/INET_Addr.h" #include "ace/FILE_IO.h" diff --git a/examples/Reactor/Dgram/CODgram.cpp b/examples/Reactor/Dgram/CODgram.cpp index dcf081892b6..60de891bf3a 100644 --- a/examples/Reactor/Dgram/CODgram.cpp +++ b/examples/Reactor/Dgram/CODgram.cpp @@ -25,6 +25,7 @@ // give the name "peer1" as the final argument to one and // only one of the programs so that the test will work properly. +#include "ace/OS_main.h" #include "ace/Reactor.h" #include "ace/SOCK_CODgram.h" #include "ace/INET_Addr.h" diff --git a/examples/Reactor/Dgram/Dgram.cpp b/examples/Reactor/Dgram/Dgram.cpp index ec0e02f4063..144e02beed6 100644 --- a/examples/Reactor/Dgram/Dgram.cpp +++ b/examples/Reactor/Dgram/Dgram.cpp @@ -24,6 +24,7 @@ // give the name "peer1" as the final argument to one and // only one of the programs so that the test will work properly. +#include "ace/OS_main.h" #include "ace/Reactor.h" #include "ace/Process.h" #include "ace/SOCK_Dgram.h" diff --git a/examples/Reactor/Misc/pingpong.cpp b/examples/Reactor/Misc/pingpong.cpp index 3ccc380739d..0ec3311882b 100644 --- a/examples/Reactor/Misc/pingpong.cpp +++ b/examples/Reactor/Misc/pingpong.cpp @@ -35,12 +35,12 @@ stop it earlier, just hit the control-C sequence and you'll see the same messages. */ -#include "ace/Synch.h" #include "ace/Reactor.h" #include "ace/Pipe.h" #include "ace/Log_Msg.h" #include "ace/ACE.h" #include "ace/Test_and_Set.h" +#include "ace/OS_NS_string.h" #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Test_and_Set<ACE_Null_Mutex, sig_atomic_t>; diff --git a/examples/Reactor/Misc/test_early_timeouts.cpp b/examples/Reactor/Misc/test_early_timeouts.cpp index 6cedd05d7f9..910fad2e3f9 100644 --- a/examples/Reactor/Misc/test_early_timeouts.cpp +++ b/examples/Reactor/Misc/test_early_timeouts.cpp @@ -21,6 +21,9 @@ #include "ace/Handle_Set.h" #include "ace/Pipe.h" #include "ace/Log_Msg.h" +#include "ace/Time_Value.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_sys_select.h" ACE_RCSID(Misc, test_early_timeouts, "$Id$") diff --git a/examples/Reactor/Misc/test_time_value.cpp b/examples/Reactor/Misc/test_time_value.cpp index 2f6bf9d461e..c86e3503c19 100644 --- a/examples/Reactor/Misc/test_time_value.cpp +++ b/examples/Reactor/Misc/test_time_value.cpp @@ -1,8 +1,8 @@ // $Id$ -#include "ace/OS.h" #include "ace/streams.h" #include "ace/Log_Msg.h" +#include "ace/Time_Value.h" ACE_RCSID(Misc, test_time_value, "$Id$") diff --git a/examples/Reactor/Multicast/Log_Wrapper.cpp b/examples/Reactor/Multicast/Log_Wrapper.cpp index 94f3361a597..8a11973152c 100644 --- a/examples/Reactor/Multicast/Log_Wrapper.cpp +++ b/examples/Reactor/Multicast/Log_Wrapper.cpp @@ -3,6 +3,10 @@ // client.C #include "Log_Wrapper.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_utsname.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_netdb.h" ACE_RCSID(Multicast, Log_Wrapper, "$Id$") @@ -55,7 +59,7 @@ Log_Wrapper::log_message (Log_Priority type, char *message) this->log_msg_.type = type; this->log_msg_.time = time (0); - this->log_msg_.msg_length = strlen(message)+1; + this->log_msg_.msg_length = ACE_OS::strlen(message)+1; this->log_msg_.sequence_number = htonl(sequence_number_); iovec iovp[2]; diff --git a/examples/Reactor/Multicast/client.cpp b/examples/Reactor/Multicast/client.cpp index 4ffc8fc5ecb..0805e0f107d 100644 --- a/examples/Reactor/Multicast/client.cpp +++ b/examples/Reactor/Multicast/client.cpp @@ -3,6 +3,9 @@ // This program reads in messages from stdin and sends them to a // Log_Wrapper. +#include "ace/OS_main.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #include "Log_Wrapper.h" diff --git a/examples/Reactor/Multicast/server.cpp b/examples/Reactor/Multicast/server.cpp index 337b07aca36..15fc818bab4 100644 --- a/examples/Reactor/Multicast/server.cpp +++ b/examples/Reactor/Multicast/server.cpp @@ -5,12 +5,16 @@ // Listens to multicast address for client log messages. Prints // Mbits/sec received from client. +#include "ace/OS_main.h" #include "ace/SOCK_Dgram.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Dgram_Mcast.h" #include "ace/Reactor.h" #include "ace/Log_Msg.h" #include "Log_Wrapper.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" +#include "ace/os_include/os_netdb.h" ACE_RCSID(Multicast, server, "$Id$") diff --git a/examples/Reactor/Ntalker/ntalker.cpp b/examples/Reactor/Ntalker/ntalker.cpp index 3b4019044fa..81291afa465 100644 --- a/examples/Reactor/Ntalker/ntalker.cpp +++ b/examples/Reactor/Ntalker/ntalker.cpp @@ -3,6 +3,7 @@ // Listens to multicast address. After first message received, will // listen for 5 more seconds. Prints Mbits/sec received from client. +#include "ace/OS_main.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Dgram_Mcast.h" #include "ace/Reactor.h" diff --git a/examples/Reactor/Proactor/post_completions.cpp b/examples/Reactor/Proactor/post_completions.cpp index a3e28129d86..72cc2bc5eff 100644 --- a/examples/Reactor/Proactor/post_completions.cpp +++ b/examples/Reactor/Proactor/post_completions.cpp @@ -31,6 +31,7 @@ // // ===================================================================== +#include "ace/OS_main.h" #include "ace/Proactor.h" #include "ace/Synch.h" #include "ace/Task.h" diff --git a/examples/Reactor/Proactor/test_aiocb_ace.cpp b/examples/Reactor/Proactor/test_aiocb_ace.cpp index a554719602b..cd4b585f063 100644 --- a/examples/Reactor/Proactor/test_aiocb_ace.cpp +++ b/examples/Reactor/Proactor/test_aiocb_ace.cpp @@ -32,7 +32,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" diff --git a/examples/Reactor/Proactor/test_cancel.cpp b/examples/Reactor/Proactor/test_cancel.cpp index 15cb12e6106..3a540ff0c20 100644 --- a/examples/Reactor/Proactor/test_cancel.cpp +++ b/examples/Reactor/Proactor/test_cancel.cpp @@ -35,6 +35,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" diff --git a/examples/Reactor/Proactor/test_end_event_loop.cpp b/examples/Reactor/Proactor/test_end_event_loop.cpp index 8177f2ca429..919a076ec37 100644 --- a/examples/Reactor/Proactor/test_end_event_loop.cpp +++ b/examples/Reactor/Proactor/test_end_event_loop.cpp @@ -29,6 +29,7 @@ #include "ace/Task.h" #include "ace/WIN32_Proactor.h" #include "ace/POSIX_Proactor.h" +#include "ace/OS_main.h" #if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \ (defined (ACE_HAS_AIO_CALLS)) && !defined (ACE_POSIX_AIOCB_PROACTOR)) diff --git a/examples/Reactor/Proactor/test_proactor.cpp b/examples/Reactor/Proactor/test_proactor.cpp index 53c8db49ca5..a2366fbdd79 100644 --- a/examples/Reactor/Proactor/test_proactor.cpp +++ b/examples/Reactor/Proactor/test_proactor.cpp @@ -18,6 +18,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" @@ -30,6 +31,7 @@ #include "ace/Message_Block.h" #include "ace/Get_Opt.h" #include "ace/streams.h" +#include "ace/OS_NS_sys_stat.h" ACE_RCSID(Proactor, test_proactor, "$Id$") diff --git a/examples/Reactor/Proactor/test_timeout.cpp b/examples/Reactor/Proactor/test_timeout.cpp index 8639b79ee23..0df96f9efbf 100644 --- a/examples/Reactor/Proactor/test_timeout.cpp +++ b/examples/Reactor/Proactor/test_timeout.cpp @@ -25,6 +25,8 @@ #include "ace/Synch.h" #include "ace/Task.h" #include "ace/Atomic_Op.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_main.h" ACE_RCSID(Proactor, test_timeout, "$Id$") diff --git a/examples/Reactor/Proactor/test_udp_proactor.cpp b/examples/Reactor/Proactor/test_udp_proactor.cpp index 84f1bd8ad7e..8ce6e8ac481 100644 --- a/examples/Reactor/Proactor/test_udp_proactor.cpp +++ b/examples/Reactor/Proactor/test_udp_proactor.cpp @@ -19,6 +19,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/INET_Addr.h" diff --git a/examples/Reactor/WFMO_Reactor/APC.cpp b/examples/Reactor/WFMO_Reactor/APC.cpp index 77233099662..ff1cbdd8233 100644 --- a/examples/Reactor/WFMO_Reactor/APC.cpp +++ b/examples/Reactor/WFMO_Reactor/APC.cpp @@ -19,7 +19,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Abandoned.cpp b/examples/Reactor/WFMO_Reactor/Abandoned.cpp index 5feca2edd61..6f1466f1ef6 100644 --- a/examples/Reactor/WFMO_Reactor/Abandoned.cpp +++ b/examples/Reactor/WFMO_Reactor/Abandoned.cpp @@ -18,7 +18,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp b/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp index b481c4929bd..50e8fab847f 100644 --- a/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp +++ b/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp @@ -18,7 +18,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Exceptions.cpp b/examples/Reactor/WFMO_Reactor/Exceptions.cpp index d87069be9b3..c433f8496ae 100644 --- a/examples/Reactor/WFMO_Reactor/Exceptions.cpp +++ b/examples/Reactor/WFMO_Reactor/Exceptions.cpp @@ -23,7 +23,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Multithreading.cpp b/examples/Reactor/WFMO_Reactor/Multithreading.cpp index efe1b25e4e0..23bc2a148b1 100644 --- a/examples/Reactor/WFMO_Reactor/Multithreading.cpp +++ b/examples/Reactor/WFMO_Reactor/Multithreading.cpp @@ -22,7 +22,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Registration.cpp b/examples/Reactor/WFMO_Reactor/Registration.cpp index 1a857350868..81c4400c3bd 100644 --- a/examples/Reactor/WFMO_Reactor/Registration.cpp +++ b/examples/Reactor/WFMO_Reactor/Registration.cpp @@ -33,7 +33,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Registry_Changes.cpp b/examples/Reactor/WFMO_Reactor/Registry_Changes.cpp index 52cb536725a..8e6a023ce1f 100644 --- a/examples/Reactor/WFMO_Reactor/Registry_Changes.cpp +++ b/examples/Reactor/WFMO_Reactor/Registry_Changes.cpp @@ -18,7 +18,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Removals.cpp b/examples/Reactor/WFMO_Reactor/Removals.cpp index 3e9d4809f7f..50aed5b36fc 100644 --- a/examples/Reactor/WFMO_Reactor/Removals.cpp +++ b/examples/Reactor/WFMO_Reactor/Removals.cpp @@ -20,7 +20,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Suspended_Removals.cpp b/examples/Reactor/WFMO_Reactor/Suspended_Removals.cpp index 46a670e169e..227fc851ba9 100644 --- a/examples/Reactor/WFMO_Reactor/Suspended_Removals.cpp +++ b/examples/Reactor/WFMO_Reactor/Suspended_Removals.cpp @@ -18,7 +18,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Talker.cpp b/examples/Reactor/WFMO_Reactor/Talker.cpp index f2326903e02..4e2a8c96e8c 100644 --- a/examples/Reactor/WFMO_Reactor/Talker.cpp +++ b/examples/Reactor/WFMO_Reactor/Talker.cpp @@ -132,7 +132,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Reactor/WFMO_Reactor/Timeouts.cpp b/examples/Reactor/WFMO_Reactor/Timeouts.cpp index d88a5bd232b..b157ccab3e3 100644 --- a/examples/Reactor/WFMO_Reactor/Timeouts.cpp +++ b/examples/Reactor/WFMO_Reactor/Timeouts.cpp @@ -26,7 +26,7 @@ #include "ace/Reactor.h" #include "ace/Service_Config.h" -#include "ace/OS.h" +#include "ace/OS_main.h" ACE_RCSID(WFMO_Reactor, Timeouts, "$Id$") diff --git a/examples/Reactor/WFMO_Reactor/Window_Messages.cpp b/examples/Reactor/WFMO_Reactor/Window_Messages.cpp index df247025384..db3eddaa37e 100644 --- a/examples/Reactor/WFMO_Reactor/Window_Messages.cpp +++ b/examples/Reactor/WFMO_Reactor/Window_Messages.cpp @@ -19,7 +19,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Registry/test_registry_iterator.cpp b/examples/Registry/test_registry_iterator.cpp index 1585e87ce6e..4d96dcc7a78 100644 --- a/examples/Registry/test_registry_iterator.cpp +++ b/examples/Registry/test_registry_iterator.cpp @@ -7,7 +7,7 @@ // // This examples points the cool iterators in ACE_Registry -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Registry/test_registry_update.cpp b/examples/Registry/test_registry_update.cpp index bc732d95807..9d64435e7a8 100644 --- a/examples/Registry/test_registry_update.cpp +++ b/examples/Registry/test_registry_update.cpp @@ -13,7 +13,7 @@ // Note that this application will not work with remote registries // if used with the CURRENT_USER predefined registry. -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_WIN32) diff --git a/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp index 7cb5b719a1b..9918ecfdc28 100644 --- a/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp @@ -3,10 +3,13 @@ // Tests out the broadcast service of the // Internet domain IPC-SAP dgram abstraction. +#include "ace/OS_main.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Dgram_Bcast.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" ACE_RCSID(client, broadcast_client_test, "$Id$") @@ -51,7 +54,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) static char buf[] = "testing socket broadcast service"; - if (sd.send (buf, strlen (buf), broadcast_port_number) == -1) + if (sd.send (buf, ACE_OS::strlen (buf), broadcast_port_number) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "can't send broadcast"), -1); return 0; diff --git a/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp index fb9769dd458..08b5524c947 100644 --- a/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp @@ -2,11 +2,13 @@ // Tests out the UNIX domain IPC-SAP abstraction. -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/LSOCK_CODgram.h" #include "ace/LSOCK_Dgram.h" #include "ace/UNIX_Addr.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(client, local_dgram_client_test, "$Id$") diff --git a/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp index 51b566c24e9..eaf416c9dbf 100644 --- a/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/local_fifo_client_test.cpp @@ -3,6 +3,7 @@ // Send a file through ACE_FIFO communication channel by // breaking it (the file) into pieces. +#include "ace/OS_main.h" #include "ace/Mem_Map.h" #include "ace/FIFO_Send_Msg.h" #include "ace/Get_Opt.h" diff --git a/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp index 08d00e325eb..5671bd73224 100644 --- a/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp @@ -4,7 +4,7 @@ // pipes and then ships certain ends over to the server to act as a // filter! -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/LSOCK_Connector.h" #include "ace/UNIX_Addr.h" #include "ace/Get_Opt.h" diff --git a/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp index a565c8b4f15..77406f9bada 100644 --- a/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/local_spipe_client_test.cpp @@ -3,6 +3,7 @@ // Send a file through ACE_SPIPE communication channel by // breaking it (the file) into pieces. +#include "ace/OS_main.h" #include "ace/Mem_Map.h" #include "ace/SPIPE_Connector.h" #include "ace/Get_Opt.h" diff --git a/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp index 9bb8dbf128d..a26d988bd05 100644 --- a/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp @@ -2,7 +2,7 @@ // Tests out the UNIX domain IPC-SAP abstraction. -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/LSOCK_Connector.h" #include "ace/UNIX_Addr.h" #include "ace/Get_Opt.h" diff --git a/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp index 7640824a36e..400865ad7bb 100644 --- a/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/remote_dgram_client_test.cpp @@ -2,6 +2,7 @@ // Tests out the Internet domain IPC-SAP dgram abstraction. +#include "ace/OS_main.h" #include "ace/Mem_Map.h" #include "ace/SOCK_Dgram.h" #include "ace/INET_Addr.h" diff --git a/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp index 9b3327e07e0..efefebbed9e 100644 --- a/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/remote_service_directory_test.cpp @@ -2,6 +2,8 @@ // Test program for the INET IPC-SAPs... +#include "ace/OS_main.h" +#include "ace/OS_NS_string.h" #include "ace/SOCK_Connector.h" #include "ace/INET_Addr.h" #include "ace/Get_Opt.h" diff --git a/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp index 636223e2349..9fd5b3c00b6 100644 --- a/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp @@ -2,6 +2,8 @@ // Test program for the INET IPC-SAPs... +#include "ace/OS_main.h" +#include "ace/OS_NS_string.h" #include "ace/Mem_Map.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_CODgram.h" diff --git a/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp b/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp index 6c0c3fb9d1d..1ca5edea908 100644 --- a/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp +++ b/examples/Service_Configurator/IPC-tests/client/remote_thr_stream_client_test.cpp @@ -2,11 +2,13 @@ // Test program for the INET ACE_TLI-SAPs... +#include "ace/OS_main.h" #include "ace/Mem_Map.h" #include "ace/TLI_Connector.h" #include "ace/INET_Addr.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(client, remote_thr_stream_client_test, "$Id$") diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i index 2d960f3e9dd..d27f612bc8a 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i @@ -2,6 +2,7 @@ // $Id$ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_Broadcast::~Handle_Broadcast (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i index 4865b5eaa36..df441aff0ee 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i @@ -2,6 +2,7 @@ // $Id$ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_L_CODgram::Handle_L_CODgram (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i index 295bdd7d76d..325acada54a 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i @@ -2,6 +2,7 @@ // $Id$ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_L_Dgram::Handle_L_Dgram (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i index 930b4390fd8..e1a47df19fc 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_L_FIFO::Handle_L_FIFO (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i index a48081058e1..35c27f7c9cd 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i @@ -2,6 +2,7 @@ // $Id$ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_L_Pipe::~Handle_L_Pipe (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i index 209acc871de..1f88a676743 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i @@ -4,6 +4,7 @@ #include "ace/SPIPE_Stream.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" #if defined (ACE_HAS_STREAM_PIPES) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i index 465eb3e2fbe..7c59a4b61ff 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i @@ -2,6 +2,8 @@ // $Id$ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_time.h" ACE_INLINE Handle_L_Stream::~Handle_L_Stream (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i index 505735ba3ed..02408f58a64 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i @@ -2,6 +2,7 @@ // $Id$ #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_R_Dgram::Handle_R_Dgram (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i index f6599713678..476521b8c27 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i @@ -3,6 +3,8 @@ #include "ace/Get_Opt.h" #include "ace/WFMO_Reactor.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_time.h" ACE_INLINE Handle_R_Stream::Handle_R_Stream (void) diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp index c5c1cf3e166..58f6ef15e1c 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp @@ -16,6 +16,8 @@ ACE_RCSID(server, Handle_Thr_Stream, "$Id$") #include "Handle_Thr_Stream.i" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_time.h" + // Shorthand names. #define SVH SVC_HANDLER #define PR_AC_1 ACE_PEER_ACCEPTOR_1 diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i index 29f4be5d7d1..94aaf48f74f 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i @@ -3,6 +3,7 @@ #include "ace/Service_Config.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" ACE_INLINE Handle_Timeout::Handle_Timeout (void): count (0) diff --git a/examples/Service_Configurator/Misc/main.cpp b/examples/Service_Configurator/Misc/main.cpp index 3bb4abd62a6..ab679d47930 100644 --- a/examples/Service_Configurator/Misc/main.cpp +++ b/examples/Service_Configurator/Misc/main.cpp @@ -18,6 +18,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/ARGV.h" #include "ace/Log_Msg.h" diff --git a/examples/Shared_Malloc/Options.cpp b/examples/Shared_Malloc/Options.cpp index 5b898cb2b83..6ff3244bfe3 100644 --- a/examples/Shared_Malloc/Options.cpp +++ b/examples/Shared_Malloc/Options.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "Options.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" ACE_RCSID(Shared_Malloc, Options, "$Id$") diff --git a/examples/Shared_Malloc/Options.h b/examples/Shared_Malloc/Options.h index c96cd5fb322..b2f0fdfa8af 100644 --- a/examples/Shared_Malloc/Options.h +++ b/examples/Shared_Malloc/Options.h @@ -4,7 +4,7 @@ #ifndef _OPTIONS #define _OPTIONS -#include "ace/OS.h" +#include "ace/os_include/os_stddef.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/Shared_Malloc/test_malloc.cpp b/examples/Shared_Malloc/test_malloc.cpp index 8ede38848d1..ff9ee9e1eac 100644 --- a/examples/Shared_Malloc/test_malloc.cpp +++ b/examples/Shared_Malloc/test_malloc.cpp @@ -5,6 +5,7 @@ #include "ace/Thread.h" #include "ace/Thread_Manager.h" +#include "ace/OS_NS_sys_wait.h" #include "Malloc.h" #include "Options.h" diff --git a/examples/Shared_Memory/test_MM.cpp b/examples/Shared_Memory/test_MM.cpp index f26d58f4310..5a7688af45b 100644 --- a/examples/Shared_Memory/test_MM.cpp +++ b/examples/Shared_Memory/test_MM.cpp @@ -2,6 +2,9 @@ #include "ace/Shared_Memory_MM.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stdlib.h" ACE_RCSID(Shared_Memory, test_MM, "$Id$") diff --git a/examples/Shared_Memory/test_SV.cpp b/examples/Shared_Memory/test_SV.cpp index f341f976639..b7e8a36adfc 100644 --- a/examples/Shared_Memory/test_SV.cpp +++ b/examples/Shared_Memory/test_SV.cpp @@ -2,6 +2,7 @@ #include "ace/Shared_Memory_SV.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(Shared_Memory, test_SV, "$Id$") diff --git a/examples/Smart_Pointers/Widget_Part_Impl.cpp b/examples/Smart_Pointers/Widget_Part_Impl.cpp index ffb42fe3a43..0e4e496f180 100644 --- a/examples/Smart_Pointers/Widget_Part_Impl.cpp +++ b/examples/Smart_Pointers/Widget_Part_Impl.cpp @@ -14,6 +14,7 @@ #include "ace/Log_Msg.h" #include "ace/Refcounted_Auto_Ptr.h" #include "ace/Unbounded_Queue.h" +#include "ace/Null_Mutex.h" Widget_Part_Impl::Widget_Part_Impl (Widget *owner, const char* name, int size) : owner_ (owner), diff --git a/examples/Smart_Pointers/gadget_test.cpp b/examples/Smart_Pointers/gadget_test.cpp index 95fd5d89b87..1577d860255 100644 --- a/examples/Smart_Pointers/gadget_test.cpp +++ b/examples/Smart_Pointers/gadget_test.cpp @@ -9,7 +9,6 @@ */ //============================================================================= -#include "ace/OS.h" #include "ace/Auto_Ptr.h" #include "ace/Refcounted_Auto_Ptr.h" #include "ace/Unbounded_Queue.h" diff --git a/examples/Smart_Pointers/widget_test.cpp b/examples/Smart_Pointers/widget_test.cpp index d90692371ee..d94b9ed05f8 100644 --- a/examples/Smart_Pointers/widget_test.cpp +++ b/examples/Smart_Pointers/widget_test.cpp @@ -9,7 +9,6 @@ */ //============================================================================= -#include "ace/OS.h" #include "ace/Auto_Ptr.h" #include "ace/Refcounted_Auto_Ptr.h" #include "ace/Unbounded_Queue.h" diff --git a/examples/Synch/proc_sema.cpp b/examples/Synch/proc_sema.cpp index 3666b552cd8..13b53895ce4 100644 --- a/examples/Synch/proc_sema.cpp +++ b/examples/Synch/proc_sema.cpp @@ -1,9 +1,11 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Process_Semaphore.h" #include "ace/Synch_T.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" int producer (ACE_SYNCH_PROCESS_SEMAPHORE &sema, int iter) diff --git a/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp b/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp index 9a6020d590c..d0ccc9840bc 100644 --- a/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp +++ b/examples/System_V_IPC/SV_Message_Queues/MQ_Client.cpp @@ -4,6 +4,7 @@ #include "test.h" #include "ace/streams.h" #include "ace/Malloc.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(SV_Message_Queues, MQ_Client, "$Id$") diff --git a/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp index 7b6bca929f8..dd7a9573f92 100644 --- a/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp +++ b/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp @@ -4,6 +4,8 @@ #include "ace/SV_Message_Queue.h" #include "ace/streams.h" #include "test.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(SV_Message_Queues, MQ_Server, "$Id$") diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp index 2310029816d..cbd1ed90268 100644 --- a/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp +++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp @@ -4,6 +4,8 @@ #include "ace/streams.h" #include "ace/Log_Msg.h" #include "test.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(SV_Message_Queues, TMQ_Client, "$Id$") diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp index 373c92dae79..3e789a76867 100644 --- a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp +++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp @@ -6,6 +6,8 @@ #include "test.h" #include "ace/streams.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(SV_Message_Queues, TMQ_Server, "$Id$") diff --git a/examples/System_V_IPC/SV_Message_Queues/test.h b/examples/System_V_IPC/SV_Message_Queues/test.h index b3da2877bc7..f17cf11c63e 100644 --- a/examples/System_V_IPC/SV_Message_Queues/test.h +++ b/examples/System_V_IPC/SV_Message_Queues/test.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ // $Id$ -#include "ace/OS.h" +#include "ace/OS_NS_string.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -20,17 +20,17 @@ public: const char user[] = "", const char text[] = ""): pid_ (p) { - ::strncpy (this->username_, user, 9); - ::strncpy (this->mtext_, text, MSGSZ); + ACE_OS::strncpy (this->username_, user, 9); + ACE_OS::strncpy (this->mtext_, text, MSGSZ); } long pid (void) { return this->pid_; } void pid (long p) { this->pid_ = p; } char *user (void) { return this->username_; } - void user (char user[]) { ::strncpy (this->username_, user, 9); } + void user (char user[]) { ACE_OS::strncpy (this->username_, user, 9); } char *text (void) { return this->mtext_; } - void text (char text[]) { ::strncpy (this->mtext_, text, MSGSZ); } - int length (void) { return sizeof *this - sizeof this->mtext_ + ::strlen (this->mtext_) + 1; } + void text (char text[]) { ACE_OS::strncpy (this->mtext_, text, MSGSZ); } + int length (void) { return sizeof *this - sizeof this->mtext_ + ACE_OS::strlen (this->mtext_) + 1; } protected: long pid_; diff --git a/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp index 39157552b93..981663630f0 100644 --- a/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp +++ b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp @@ -3,6 +3,9 @@ #include "ace/SV_Shared_Memory.h" #include "ace/Log_Msg.h" #include "SV_Shared_Memory_Test.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(SV_Shared_Memory, SV_Shared_Memory_Test, "$Id$") diff --git a/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h index 4e8cd9b9d13..3cfff4672b9 100644 --- a/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h +++ b/examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ // $Id$ -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/examples/Threads/auto_event.cpp b/examples/Threads/auto_event.cpp index 4c7ebcb2392..3fc6f082045 100644 --- a/examples/Threads/auto_event.cpp +++ b/examples/Threads/auto_event.cpp @@ -7,8 +7,9 @@ // by the writer. The writer thread calculates the value and signals // the reader when the calculation completes. +#include "ace/OS_main.h" #include "ace/Service_Config.h" -#include "ace/Synch.h" +#include "ace/Auto_Event.h" #include "ace/Singleton.h" #include "ace/Thread_Manager.h" diff --git a/examples/Threads/barrier1.cpp b/examples/Threads/barrier1.cpp index e6d8c8f17dc..4d3762b1eb6 100644 --- a/examples/Threads/barrier1.cpp +++ b/examples/Threads/barrier1.cpp @@ -3,7 +3,8 @@ // This test program illustrates how the ACE barrier synchronization // mechanisms work. -#include "ace/Synch.h" +#include "ace/OS_main.h" +#include "ace/Barrier.h" #include "ace/Thread_Manager.h" #include "ace/Service_Config.h" diff --git a/examples/Threads/barrier2.cpp b/examples/Threads/barrier2.cpp index 13d152da7fe..6b3e3df9b3a 100644 --- a/examples/Threads/barrier2.cpp +++ b/examples/Threads/barrier2.cpp @@ -10,6 +10,7 @@ // should work with this flag disabled! The BARRIER_TYPE is supposed // to enable/disable barrier sync on each svc a worker has done. +#include "ace/OS_main.h" #include "ace/Task.h" #include "ace/Service_Config.h" diff --git a/examples/Threads/cancel.cpp b/examples/Threads/cancel.cpp index 05f56101f31..4d2b741839a 100644 --- a/examples/Threads/cancel.cpp +++ b/examples/Threads/cancel.cpp @@ -3,6 +3,7 @@ // Test out the cooperative thread cancellation mechanisms provided by // the ACE_Thread_Manager. +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Thread_Manager.h" diff --git a/examples/Threads/future1.cpp b/examples/Threads/future1.cpp index 6823b27625a..8151f236e7b 100644 --- a/examples/Threads/future1.cpp +++ b/examples/Threads/future1.cpp @@ -17,9 +17,10 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Task.h" -#include "ace/Synch.h" +#include "ace/Thread_Mutex.h" #include "ace/Message_Queue.h" #include "ace/Future.h" #include "ace/Method_Request.h" diff --git a/examples/Threads/future2.cpp b/examples/Threads/future2.cpp index 6178396ec61..2b64d5e0094 100644 --- a/examples/Threads/future2.cpp +++ b/examples/Threads/future2.cpp @@ -25,9 +25,9 @@ // the tests so they are more modular. // ============================================================================ +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Task.h" -#include "ace/Synch.h" #include "ace/Message_Queue.h" #include "ace/Future.h" #include "ace/Method_Request.h" diff --git a/examples/Threads/manual_event.cpp b/examples/Threads/manual_event.cpp index 6871fbadeea..75287e02620 100644 --- a/examples/Threads/manual_event.cpp +++ b/examples/Threads/manual_event.cpp @@ -11,8 +11,10 @@ // ACE_Manual_Event is use to synch with other // threads. ACE_Manual_Event::signal() is used for broadcasting. +#include "ace/OS_main.h" #include "ace/Service_Config.h" -#include "ace/Synch.h" +#include "ace/Thread_Mutex.h" +#include "ace/Manual_Event.h" #include "ace/Thread_Manager.h" #include "ace/Atomic_Op.h" diff --git a/examples/Threads/process_manager.cpp b/examples/Threads/process_manager.cpp index 94b5eb23b35..08058ef2cc9 100644 --- a/examples/Threads/process_manager.cpp +++ b/examples/Threads/process_manager.cpp @@ -26,6 +26,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Thread_Manager.h" #include "ace/Process_Manager.h" diff --git a/examples/Threads/process_mutex.cpp b/examples/Threads/process_mutex.cpp index 61c27fd5cdb..bbb03c08d0b 100644 --- a/examples/Threads/process_mutex.cpp +++ b/examples/Threads/process_mutex.cpp @@ -3,7 +3,9 @@ // This program tests ACE_Process_Mutexes. To run it, open 3 or 4 // windows and run this program in each window... -#include "ace/Synch.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_unistd.h" +#include "ace/Thread_Mutex.h" #include "ace/Signal.h" #include "ace/Log_Msg.h" #include "ace/Process_Mutex.h" diff --git a/examples/Threads/process_semaphore.cpp b/examples/Threads/process_semaphore.cpp index 43e57dacd4c..1a80e5ebe0d 100644 --- a/examples/Threads/process_semaphore.cpp +++ b/examples/Threads/process_semaphore.cpp @@ -3,7 +3,8 @@ // This program tests ACE_Process_Semaphore. To run it, open 3 or 4 // windows and run this program in each window... -#include "ace/Synch.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_unistd.h" #include "ace/Signal.h" #include "ace/Log_Msg.h" #include "ace/Process_Semaphore.h" diff --git a/examples/Threads/reader_writer.cpp b/examples/Threads/reader_writer.cpp index 8332eb93efa..57846a563ff 100644 --- a/examples/Threads/reader_writer.cpp +++ b/examples/Threads/reader_writer.cpp @@ -3,7 +3,7 @@ // This test program verifies the functionality of the ACE_OS // implementation of readers/writer locks on Win32 and Posix pthreads. -#include "ace/Synch.h" +#include "ace/OS_main.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/Get_Opt.h" diff --git a/examples/Threads/recursive_mutex.cpp b/examples/Threads/recursive_mutex.cpp index ed7a602826c..ca1296f787e 100644 --- a/examples/Threads/recursive_mutex.cpp +++ b/examples/Threads/recursive_mutex.cpp @@ -3,6 +3,7 @@ // This test program verifies the functionality of the ACE_OS // implementation of recursive mutexes on Win32 and Posix pthreads. +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Thread_Manager.h" #include "ace/Get_Opt.h" diff --git a/examples/Threads/task_five.cpp b/examples/Threads/task_five.cpp index c43dd88f1b4..8f96ee3420e 100644 --- a/examples/Threads/task_five.cpp +++ b/examples/Threads/task_five.cpp @@ -18,8 +18,10 @@ // ============================================================================ +#include "ace/OS_main.h" #include "ace/Thread_Manager.h" #include "ace/Task.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(Threads, task_five, "$Id$") diff --git a/examples/Threads/task_four.cpp b/examples/Threads/task_four.cpp index d13330b96df..c7e691d531e 100644 --- a/examples/Threads/task_four.cpp +++ b/examples/Threads/task_four.cpp @@ -31,6 +31,7 @@ // // test_task [num_tasks] [num_threads] [num_iterations] +#include "ace/OS_main.h" #include "ace/Task.h" #include "ace/Service_Config.h" diff --git a/examples/Threads/task_one.cpp b/examples/Threads/task_one.cpp index 734c0863712..ea4fd71dcf8 100644 --- a/examples/Threads/task_one.cpp +++ b/examples/Threads/task_one.cpp @@ -5,6 +5,7 @@ // ACE_Thread_Manager. It is instructive to compare this with the // test_barrier.cpp test to see how they differ. +#include "ace/OS_main.h" #include "ace/Task.h" #include "ace/Service_Config.h" diff --git a/examples/Threads/task_three.cpp b/examples/Threads/task_three.cpp index 23434dec97a..ed06a6719ff 100644 --- a/examples/Threads/task_three.cpp +++ b/examples/Threads/task_three.cpp @@ -11,6 +11,7 @@ // ACE_LOG_MSG->msg_ostream (out_stream); // } +#include "ace/OS_main.h" #include "ace/Reactor.h" #include "ace/Service_Config.h" #include "ace/Task.h" diff --git a/examples/Threads/task_two.cpp b/examples/Threads/task_two.cpp index 81d829f7990..b4c703a8ed8 100644 --- a/examples/Threads/task_two.cpp +++ b/examples/Threads/task_two.cpp @@ -4,6 +4,7 @@ // zillions of tasks and then wait for them using both polling and the // ACE Thread Manager. +#include "ace/OS_main.h" #include "ace/Task.h" #include "ace/Service_Config.h" diff --git a/examples/Threads/thread_manager.cpp b/examples/Threads/thread_manager.cpp index 37b017df439..2528cda57b7 100644 --- a/examples/Threads/thread_manager.cpp +++ b/examples/Threads/thread_manager.cpp @@ -5,6 +5,7 @@ // suspension and resumption, and cooperative thread cancellation // mechanisms. +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Thread_Manager.h" diff --git a/examples/Threads/thread_pool.cpp b/examples/Threads/thread_pool.cpp index bb45c652e90..9f37f510ecb 100644 --- a/examples/Threads/thread_pool.cpp +++ b/examples/Threads/thread_pool.cpp @@ -11,11 +11,10 @@ // Dorn <Karlheinz.Dorn@med.siemens.de>. It was modified to utilize // more ACE features by Doug Schmidt <schmidt@cs.wustl.edu>. +#include "ace/OS_main.h" #include "ace/Task.h" #include "ace/Service_Config.h" -#include "ace/Task.h" - ACE_RCSID(Threads, thread_pool, "$Id$") #if defined (ACE_HAS_THREADS) diff --git a/examples/Threads/thread_specific.cpp b/examples/Threads/thread_specific.cpp index 13df67404c4..e04b1da748b 100644 --- a/examples/Threads/thread_specific.cpp +++ b/examples/Threads/thread_specific.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Thread_Manager.h" #include "ace/Synch.h" diff --git a/examples/Threads/token.cpp b/examples/Threads/token.cpp index b87960ee072..bbda579369b 100644 --- a/examples/Threads/token.cpp +++ b/examples/Threads/token.cpp @@ -2,8 +2,10 @@ // Test out the ACE Token class. +#include "ace/OS_main.h" #include "ace/Token.h" #include "ace/Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Threads, token, "$Id$") diff --git a/examples/Threads/tss1.cpp b/examples/Threads/tss1.cpp index b958a367396..77fd622b831 100644 --- a/examples/Threads/tss1.cpp +++ b/examples/Threads/tss1.cpp @@ -21,6 +21,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Synch.h" #include "ace/Task.h" diff --git a/examples/Threads/tss2.cpp b/examples/Threads/tss2.cpp index 58e3f5f5ece..59b52fe59ca 100644 --- a/examples/Threads/tss2.cpp +++ b/examples/Threads/tss2.cpp @@ -17,6 +17,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Thread.h" #include "ace/Log_Msg.h" #include "ace/Atomic_Op.h" diff --git a/examples/Timer_Queue/main_async.cpp b/examples/Timer_Queue/main_async.cpp index 62d3b629ab5..7cb90111fde 100644 --- a/examples/Timer_Queue/main_async.cpp +++ b/examples/Timer_Queue/main_async.cpp @@ -29,6 +29,7 @@ information */ #endif /* _MSC_VER */ +#include "ace/OS_main.h" #include "ace/Auto_Ptr.h" #include "Driver.h" #include "Async_Timer_Queue_Test.h" diff --git a/examples/Timer_Queue/main_reactor.cpp b/examples/Timer_Queue/main_reactor.cpp index d69d415805a..76088bc5287 100644 --- a/examples/Timer_Queue/main_reactor.cpp +++ b/examples/Timer_Queue/main_reactor.cpp @@ -29,6 +29,7 @@ information */ #endif /* _MSC_VER */ +#include "ace/OS_main.h" #include "ace/Auto_Ptr.h" #include "Reactor_Timer_Queue_Test.h" #include "Driver.h" diff --git a/examples/Timer_Queue/main_thread.cpp b/examples/Timer_Queue/main_thread.cpp index 5a0493fb45b..3f8aba5866e 100644 --- a/examples/Timer_Queue/main_thread.cpp +++ b/examples/Timer_Queue/main_thread.cpp @@ -29,6 +29,7 @@ information */ #endif /* _MSC_VER */ +#include "ace/OS_main.h" #include "ace/Auto_Ptr.h" #include "Driver.h" #include "Thread_Timer_Queue_Test.h" diff --git a/examples/Web_Crawler/Options.cpp b/examples/Web_Crawler/Options.cpp index b9c7585a807..c4e96acb77d 100644 --- a/examples/Web_Crawler/Options.cpp +++ b/examples/Web_Crawler/Options.cpp @@ -3,6 +3,7 @@ #include "ace/Get_Opt.h" #include "URL_Addr.h" #include "Options.h" +#include "ace/OS_NS_string.h" ACE_RCSID(Web_Crawler, Options, "$Id$") diff --git a/examples/Web_Crawler/Options.h b/examples/Web_Crawler/Options.h index 45b8bfd2f71..e7cdbb336bf 100644 --- a/examples/Web_Crawler/Options.h +++ b/examples/Web_Crawler/Options.h @@ -18,7 +18,7 @@ #define _OPTIONS_H #include "ace/Singleton.h" -#include "ace/Synch.h" +#include "ace/Time_Value.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once diff --git a/examples/Web_Crawler/URL_Addr.cpp b/examples/Web_Crawler/URL_Addr.cpp index 259fb05517e..b64cf5eb3b6 100644 --- a/examples/Web_Crawler/URL_Addr.cpp +++ b/examples/Web_Crawler/URL_Addr.cpp @@ -2,6 +2,8 @@ #include "URL_Addr.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Web_Crawler, URL_Addr, "$Id$") diff --git a/examples/Web_Crawler/URL_Status.h b/examples/Web_Crawler/URL_Status.h index fc916a4eee5..c6b56042b24 100644 --- a/examples/Web_Crawler/URL_Status.h +++ b/examples/Web_Crawler/URL_Status.h @@ -17,7 +17,7 @@ #ifndef _URL_STATUS_H #define _URL_STATUS_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once diff --git a/netsvcs/clients/Logger/direct_logging.cpp b/netsvcs/clients/Logger/direct_logging.cpp index cdbcafef39a..d1880808e13 100644 --- a/netsvcs/clients/Logger/direct_logging.cpp +++ b/netsvcs/clients/Logger/direct_logging.cpp @@ -6,6 +6,7 @@ #include "ace/SOCK_Connector.h" #include "ace/Log_Record.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_time.h" ACE_RCSID(Logger, direct_logging, "$Id$") diff --git a/netsvcs/clients/Logger/indirect_logging.cpp b/netsvcs/clients/Logger/indirect_logging.cpp index 1739f0a668f..2bec071fdaf 100644 --- a/netsvcs/clients/Logger/indirect_logging.cpp +++ b/netsvcs/clients/Logger/indirect_logging.cpp @@ -5,7 +5,8 @@ // them to the Server Logging Daemon. If there is no Server Logging // Daemon, the logging records will be written to stderr. -#include "ace/OS.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdlib.h" #include "ace/Log_Msg.h" ACE_RCSID(Logger, indirect_logging, "$Id$") diff --git a/netsvcs/clients/Naming/Client/Client_Test.cpp b/netsvcs/clients/Naming/Client/Client_Test.cpp index 72c7e9b8494..11b4e66d29d 100644 --- a/netsvcs/clients/Naming/Client/Client_Test.cpp +++ b/netsvcs/clients/Naming/Client/Client_Test.cpp @@ -7,6 +7,8 @@ #include "ace/Dynamic_Service.h" #include "ace/Thread_Manager.h" #include "Client_Test.h" +#include "ace/OS_NS_signal.h" +#include "ace/os_include/os_assert.h" ACE_RCSID(Client, Client_Test, "$Id$") diff --git a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp index ef7b26ba5d7..da41e3ec1f7 100644 --- a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp +++ b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp @@ -6,6 +6,7 @@ #include "ace/Thread_Manager.h" #include "ace/streams.h" /* Because dump () uses ofstream. */ #include "Dump_Restore.h" +#include "ace/OS_NS_signal.h" ACE_RCSID(Dump_Restore, Dump_Restore, "$Id$") diff --git a/netsvcs/clients/Tokens/collection/collection.cpp b/netsvcs/clients/Tokens/collection/collection.cpp index c6d223ed095..8df0ae625fc 100644 --- a/netsvcs/clients/Tokens/collection/collection.cpp +++ b/netsvcs/clients/Tokens/collection/collection.cpp @@ -19,7 +19,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Token_Collection.h" diff --git a/netsvcs/clients/Tokens/collection/rw_locks.cpp b/netsvcs/clients/Tokens/collection/rw_locks.cpp index 2a64f8d9786..2670f99214f 100644 --- a/netsvcs/clients/Tokens/collection/rw_locks.cpp +++ b/netsvcs/clients/Tokens/collection/rw_locks.cpp @@ -1,6 +1,5 @@ // $Id$ -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" diff --git a/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp b/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp index 46a9daabf80..e1a9d60ccd6 100644 --- a/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp +++ b/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp @@ -15,7 +15,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Token_Manager.h" #include "ace/Remote_Tokens.h" #include "ace/Thread.h" diff --git a/netsvcs/clients/Tokens/invariant/invariant.cpp b/netsvcs/clients/Tokens/invariant/invariant.cpp index f5c223c3568..cda1f54f6f7 100644 --- a/netsvcs/clients/Tokens/invariant/invariant.cpp +++ b/netsvcs/clients/Tokens/invariant/invariant.cpp @@ -15,7 +15,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Singleton.h" #include "ace/Thread_Manager.h" diff --git a/netsvcs/clients/Tokens/manual/manual.cpp b/netsvcs/clients/Tokens/manual/manual.cpp index 9574fc7edb6..04f46d0b3da 100644 --- a/netsvcs/clients/Tokens/manual/manual.cpp +++ b/netsvcs/clients/Tokens/manual/manual.cpp @@ -16,7 +16,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" diff --git a/netsvcs/clients/Tokens/mutex/test_mutex.cpp b/netsvcs/clients/Tokens/mutex/test_mutex.cpp index c291981789d..73a33cb6c6e 100644 --- a/netsvcs/clients/Tokens/mutex/test_mutex.cpp +++ b/netsvcs/clients/Tokens/mutex/test_mutex.cpp @@ -15,7 +15,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" diff --git a/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp b/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp index 098d2bd9d84..5d0d95af876 100644 --- a/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp +++ b/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp @@ -17,7 +17,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" diff --git a/netsvcs/lib/Base_Optimizer.h b/netsvcs/lib/Base_Optimizer.h index 72b83e9f456..1869531cba9 100644 --- a/netsvcs/lib/Base_Optimizer.h +++ b/netsvcs/lib/Base_Optimizer.h @@ -17,7 +17,7 @@ #ifndef BASE_OPTIMIZER_H #define BASE_OPTIMIZER_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/netsvcs/lib/Log_Message_Receiver.h b/netsvcs/lib/Log_Message_Receiver.h index 784fe07cec7..6be17dba751 100644 --- a/netsvcs/lib/Log_Message_Receiver.h +++ b/netsvcs/lib/Log_Message_Receiver.h @@ -23,7 +23,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Guard_T.h" // ==========================================================================// //------------- General Requirements on a Log Message Receiver --------------// diff --git a/netsvcs/lib/Server_Logging_Handler.h b/netsvcs/lib/Server_Logging_Handler.h index f314a877d5d..e6b017ffd06 100644 --- a/netsvcs/lib/Server_Logging_Handler.h +++ b/netsvcs/lib/Server_Logging_Handler.h @@ -19,7 +19,6 @@ #include "Log_Message_Receiver.h" #include "Server_Logging_Handler_T.h" -#include "ace/OS.h" #include "ace/svc_export.h" // Typedefs for Logging Handlers & acceptors using a static type based diff --git a/netsvcs/lib/Server_Logging_Handler_T.cpp b/netsvcs/lib/Server_Logging_Handler_T.cpp index 63b65612024..f72fefb2589 100644 --- a/netsvcs/lib/Server_Logging_Handler_T.cpp +++ b/netsvcs/lib/Server_Logging_Handler_T.cpp @@ -5,7 +5,7 @@ #define ACE_BUILD_SVC_DLL -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/netsvcs/lib/TS_Clerk_Handler.cpp b/netsvcs/lib/TS_Clerk_Handler.cpp index a16f4cc688c..0e8460b2913 100644 --- a/netsvcs/lib/TS_Clerk_Handler.cpp +++ b/netsvcs/lib/TS_Clerk_Handler.cpp @@ -4,6 +4,8 @@ #include "ace/Get_Opt.h" #include "TS_Clerk_Handler.h" +#include "ace/OS_NS_time.h" +#include "ace/os_include/os_netdb.h" ACE_RCSID(lib, TS_Clerk_Handler, "$Id$") diff --git a/netsvcs/lib/TS_Server_Handler.cpp b/netsvcs/lib/TS_Server_Handler.cpp index 3b50a1c0255..0e4223ec088 100644 --- a/netsvcs/lib/TS_Server_Handler.cpp +++ b/netsvcs/lib/TS_Server_Handler.cpp @@ -6,6 +6,7 @@ #include "ace/Containers.h" #include "ace/Get_Opt.h" #include "TS_Server_Handler.h" +#include "ace/OS_NS_time.h" ACE_RCSID(lib, TS_Server_Handler, "$Id$") diff --git a/performance-tests/Misc/basic_perf.cpp b/performance-tests/Misc/basic_perf.cpp index 6156ff6ce30..a6dce2c6fb1 100644 --- a/performance-tests/Misc/basic_perf.cpp +++ b/performance-tests/Misc/basic_perf.cpp @@ -22,8 +22,9 @@ #include "basic_func.h" #include "ace/High_Res_Timer.h" #include "ace/Get_Opt.h" -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_utsname.h" ACE_RCSID(Misc, basic_perf, "$Id$") diff --git a/performance-tests/Misc/childbirth_time.cpp b/performance-tests/Misc/childbirth_time.cpp index e3b76ef23a3..64f5b79a595 100644 --- a/performance-tests/Misc/childbirth_time.cpp +++ b/performance-tests/Misc/childbirth_time.cpp @@ -62,7 +62,7 @@ // Process Creation profiling -#include "ace/OS.h" +#include "ace/OS_main.h" #include "ace/Get_Opt.h" #include "ace/Process.h" #include "ace/Profile_Timer.h" diff --git a/performance-tests/Misc/context_switch_time.cpp b/performance-tests/Misc/context_switch_time.cpp index 863dc551e20..657d354bd69 100644 --- a/performance-tests/Misc/context_switch_time.cpp +++ b/performance-tests/Misc/context_switch_time.cpp @@ -49,12 +49,16 @@ static const char usage [] = "[-? |\n" " [-n to spawn a new LWP with each thread\n" "[<iterations>]]"; +#include "ace/OS_main.h" #include "ace/Task.h" #include "ace/Sched_Params.h" #include "ace/Stats.h" #include "ace/High_Res_Timer.h" #include "ace/Get_Opt.h" -#include "ace/Synch.h" +#include "ace/Thread_Semaphore.h" +#include "ace/Barrier.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_errno.h" ACE_RCSID(Misc, context_switch_time, "$Id$") diff --git a/performance-tests/Misc/preempt.cpp b/performance-tests/Misc/preempt.cpp index 210a2cf40cf..b544c7120fa 100644 --- a/performance-tests/Misc/preempt.cpp +++ b/performance-tests/Misc/preempt.cpp @@ -31,10 +31,14 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Task.h" #include "ace/Sched_Params.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_errno.h" ACE_RCSID(Misc, preempt, "$Id$") diff --git a/performance-tests/Misc/test_mutex.cpp b/performance-tests/Misc/test_mutex.cpp index 6c510dfc164..0c7ccf33f0d 100644 --- a/performance-tests/Misc/test_mutex.cpp +++ b/performance-tests/Misc/test_mutex.cpp @@ -49,7 +49,8 @@ #include "ace/Log_Msg.h" #include "ace/Profile_Timer.h" -#include "ace/OS.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_Thread.h" ACE_RCSID(Misc, test_mutex, "$Id$") diff --git a/performance-tests/Misc/test_naming.cpp b/performance-tests/Misc/test_naming.cpp index f8af5fc827d..a725aca99bd 100644 --- a/performance-tests/Misc/test_naming.cpp +++ b/performance-tests/Misc/test_naming.cpp @@ -17,10 +17,12 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/SString.h" #include "ace/Naming_Context.h" #include "ace/Profile_Timer.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(Misc, test_naming, "$Id$") diff --git a/performance-tests/Misc/test_singleton.cpp b/performance-tests/Misc/test_singleton.cpp index f46b9cf6e44..6045a104b4b 100644 --- a/performance-tests/Misc/test_singleton.cpp +++ b/performance-tests/Misc/test_singleton.cpp @@ -27,9 +27,10 @@ // for the lock. If there were multiple threads contending for the lock, // the Mutex_Singleton performance would get increasing worse... +#include "ace/OS_main.h" #include "ace/Profile_Timer.h" #include "ace/Singleton.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" #include "ace/Log_Msg.h" #include "test_singleton.h" diff --git a/performance-tests/SCTP/Options_Manager.cpp b/performance-tests/SCTP/Options_Manager.cpp index 198c063e2e9..5efda2650f4 100644 --- a/performance-tests/SCTP/Options_Manager.cpp +++ b/performance-tests/SCTP/Options_Manager.cpp @@ -8,7 +8,7 @@ extern "C" { #include "ace/Get_Opt.h" #include "ace/os_include/netinet/os_in.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" // make sure that the code compiles cleanly even if SCTP is not // available. If SCTP is not installed, program will exit early in @@ -25,6 +25,8 @@ extern "C" { #include "Options_Manager.h" #include "ace/streams.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_arpa_inet.h" // Set default values ACE_CDR::ULong Options_Manager::test_iterations=1000000; @@ -120,10 +122,10 @@ Options_Manager::Options_Manager(int argc, ACE_TCHAR **argv, ACE_TCHAR const * c break; } case 'm': - histogram_min_bin = ACE_OS_String::strtod(get_opt->opt_arg (), 0); + histogram_min_bin = ACE_OS::strtod(get_opt->opt_arg (), 0); break; case 'M': - histogram_max_bin = ACE_OS_String::strtod(get_opt->opt_arg (), 0); + histogram_max_bin = ACE_OS::strtod(get_opt->opt_arg (), 0); break; case 'x': histogram_num_outliers = ACE_OS::atoi(get_opt->opt_arg ()); @@ -247,7 +249,7 @@ Options_Manager::Options_Manager(int argc, ACE_TCHAR **argv, ACE_TCHAR const * c break; } case 'p': - server_port = ACE_OS::atoi(get_opt->opt_arg ()); + server_port = ACE_OS::atoi(get_opt->opt_arg ()); break; case 'a':{ diff --git a/performance-tests/SCTP/SOCK_SEQPACK_Association_Test.cpp b/performance-tests/SCTP/SOCK_SEQPACK_Association_Test.cpp index 09b426cc5f4..f47421060f4 100644 --- a/performance-tests/SCTP/SOCK_SEQPACK_Association_Test.cpp +++ b/performance-tests/SCTP/SOCK_SEQPACK_Association_Test.cpp @@ -23,11 +23,10 @@ // // ============================================================================ -#include /**/ "ace/OS.h" -#include /**/ "ace/SOCK_SEQPACK_Association.h" -#include /**/ "ace/SOCK_SEQPACK_Connector.h" -#include /**/ "ace/INET_Addr.h" -#include /**/ "ace/Log_Msg.h" +#include "ace/SOCK_SEQPACK_Association.h" +#include "ace/SOCK_SEQPACK_Connector.h" +#include "ace/INET_Addr.h" +#include "ace/Log_Msg.h" void dump_names(const ACE_SOCK_SEQPACK_Association& assoc); diff --git a/performance-tests/SCTP/SOCK_SEQPACK_clt.cpp b/performance-tests/SCTP/SOCK_SEQPACK_clt.cpp index 394e82cb29d..58afaff15d5 100644 --- a/performance-tests/SCTP/SOCK_SEQPACK_clt.cpp +++ b/performance-tests/SCTP/SOCK_SEQPACK_clt.cpp @@ -7,6 +7,7 @@ #include "ace/CDR_Stream.h" #include "ace/High_Res_Timer.h" #include "ace/streams.h" +#include "ace/os_include/arpa/os_inet.h" // make sure that the code compiles cleanly even if SCTP is not // available. If SCTP is not installed, program will exit early in diff --git a/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp b/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp index cf1b679114a..2fd1daa1661 100644 --- a/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp +++ b/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp @@ -8,6 +8,8 @@ #include "ace/Handle_Set.h" #include "ace/CDR_Stream.h" #include "ace/streams.h" +#include "ace/os_include/arpa/os_inet.h" +#include "ace/OS_NS_sys_select.h" // make sure that the code compiles cleanly even if SCTP is not // available. If SCTP is not installed, program will exit early in diff --git a/performance-tests/SCTP/SOCK_STREAM_clt.cpp b/performance-tests/SCTP/SOCK_STREAM_clt.cpp index 639b62c30c1..780308ee972 100644 --- a/performance-tests/SCTP/SOCK_STREAM_clt.cpp +++ b/performance-tests/SCTP/SOCK_STREAM_clt.cpp @@ -7,6 +7,8 @@ #include "ace/CDR_Stream.h" #include "ace/High_Res_Timer.h" #include "ace/streams.h" +#include "ace/os_include/netinet/os_tcp.h" +#include "ace/os_include/arpa/os_inet.h" // make sure that the code compiles cleanly even if SCTP is not // available. If SCTP is not installed, program will exit early in diff --git a/performance-tests/SCTP/SOCK_STREAM_srv.cpp b/performance-tests/SCTP/SOCK_STREAM_srv.cpp index 94d3d8b5dde..71a4896e569 100644 --- a/performance-tests/SCTP/SOCK_STREAM_srv.cpp +++ b/performance-tests/SCTP/SOCK_STREAM_srv.cpp @@ -8,6 +8,9 @@ #include "ace/Handle_Set.h" #include "ace/CDR_Stream.h" #include "ace/streams.h" +#include "ace/os_include/netinet/os_tcp.h" +#include "ace/os_include/arpa/os_inet.h" +#include "ace/OS_NS_sys_select.h" // make sure that the code compiles cleanly even if SCTP is not // available. If SCTP is not installed, program will exit early in diff --git a/performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.cpp b/performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.cpp index 035f5596f49..519ea333af8 100644 --- a/performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.cpp +++ b/performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.cpp @@ -7,6 +7,7 @@ #if defined (ACE_HAS_THREADS) // We need the following only if we have threads enabled.. +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Get_Opt.h" #include "ace/High_Res_Timer.h" diff --git a/performance-tests/Server_Concurrency/Leader_Follower/leader_follower.cpp b/performance-tests/Server_Concurrency/Leader_Follower/leader_follower.cpp index 6e63e333e83..0c481f25a3c 100644 --- a/performance-tests/Server_Concurrency/Leader_Follower/leader_follower.cpp +++ b/performance-tests/Server_Concurrency/Leader_Follower/leader_follower.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Task.h" #include "ace/Get_Opt.h" diff --git a/performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.cpp b/performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.cpp index 0bce791a652..2a22d18b385 100644 --- a/performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.cpp +++ b/performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.cpp @@ -3,6 +3,7 @@ #if defined (ACE_HAS_THREADS) +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Get_Opt.h" #include "ace/High_Res_Timer.h" diff --git a/performance-tests/Server_Concurrency/Queue_Based_Workers/workers.cpp b/performance-tests/Server_Concurrency/Queue_Based_Workers/workers.cpp index bc08f453245..a7860ddefbc 100644 --- a/performance-tests/Server_Concurrency/Queue_Based_Workers/workers.cpp +++ b/performance-tests/Server_Concurrency/Queue_Based_Workers/workers.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/OS_main.h" #include "ace/ACE.h" #include "ace/Task.h" #include "ace/Get_Opt.h" diff --git a/performance-tests/Synch-Benchmarks/Perf_Test/Performance_Test_Options.h b/performance-tests/Synch-Benchmarks/Perf_Test/Performance_Test_Options.h index cb17c8c822c..a3f5a49cd12 100644 --- a/performance-tests/Synch-Benchmarks/Perf_Test/Performance_Test_Options.h +++ b/performance-tests/Synch-Benchmarks/Perf_Test/Performance_Test_Options.h @@ -6,7 +6,7 @@ #ifndef _PERFORMANCE_TEST_OPTIONS_H #define _PERFORMANCE_TEST_OPTIONS_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h b/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h index 9ccc20f399d..60cf50aed9d 100644 --- a/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h +++ b/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h @@ -7,7 +7,7 @@ #if !defined (SYNCHLIB_EXPORT_H) #define SYNCHLIB_EXPORT_H -#include "ace/OS.h" +#include "ace/config-all.h" #if !defined (SYNCHLIB_HAS_DLL) #define SYNCHLIB_HAS_DLL 1 diff --git a/performance-tests/TCP/tcp_test.cpp b/performance-tests/TCP/tcp_test.cpp index 3af48a8f0c5..df093045a2f 100644 --- a/performance-tests/TCP/tcp_test.cpp +++ b/performance-tests/TCP/tcp_test.cpp @@ -31,6 +31,9 @@ #include "ace/Sched_Params.h" #include "ace/Stats.h" #include "ace/Sample_History.h" +#include "ace/OS_main.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/OS_NS_errno.h" // FUZZ: disable check_for_math_include #include <math.h> diff --git a/performance-tests/UDP/udp_test.cpp b/performance-tests/UDP/udp_test.cpp index 2b0d8361da9..47126bd0e41 100644 --- a/performance-tests/UDP/udp_test.cpp +++ b/performance-tests/UDP/udp_test.cpp @@ -16,6 +16,7 @@ // // ============================================================================ +#include "ace/OS_main.h" #include "ace/Reactor.h" #include "ace/SOCK_Dgram.h" #include "ace/INET_Addr.h" @@ -23,6 +24,10 @@ #include "ace/Get_Opt.h" #include "ace/High_Res_Timer.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_arpa_inet.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_netdb.h" // FUZZ: disable check_for_math_include #include <math.h> diff --git a/protocols/ace/RMCast/RMCast.h b/protocols/ace/RMCast/RMCast.h index 2259af24fbb..9d9d7650e54 100644 --- a/protocols/ace/RMCast/RMCast.h +++ b/protocols/ace/RMCast/RMCast.h @@ -18,13 +18,14 @@ #define ACE_RMCAST_H #include /**/ "ace/pre.h" -#include "ace/OS.h" #include "RMCast_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/Basic_Types.h" + class ACE_Message_Block; class ACE_RMCast_Proxy; diff --git a/protocols/ace/RMCast/RMCast_Copy_On_Write.h b/protocols/ace/RMCast/RMCast_Copy_On_Write.h index 4421ca92b83..c73dade591b 100644 --- a/protocols/ace/RMCast/RMCast_Copy_On_Write.h +++ b/protocols/ace/RMCast/RMCast_Copy_On_Write.h @@ -6,7 +6,9 @@ #include /**/ "ace/pre.h" #include "RMCast_Worker.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Basic_Types.h" +#include "ace/Condition_Thread_Mutex.h" //! A wrapper to implement reference counted collections template<class COLLECTION, class ITERATOR> diff --git a/protocols/ace/RMCast/RMCast_Copy_On_Write.i b/protocols/ace/RMCast/RMCast_Copy_On_Write.i index 3c069c84eb6..c83483c0729 100644 --- a/protocols/ace/RMCast/RMCast_Copy_On_Write.i +++ b/protocols/ace/RMCast/RMCast_Copy_On_Write.i @@ -1,5 +1,9 @@ +// -*- C++ -*- // $Id$ +#include "ace/Guard_T.h" +#include "ace/Null_Mutex.h" + template<class COLLECTION, class ITERATOR> ACE_INLINE ACE_RMCast_Copy_On_Write_Collection<COLLECTION,ITERATOR>:: ACE_RMCast_Copy_On_Write_Collection (void) diff --git a/protocols/ace/RMCast/RMCast_IO_UDP.cpp b/protocols/ace/RMCast/RMCast_IO_UDP.cpp index cfed8a53d98..13801b47bd5 100644 --- a/protocols/ace/RMCast/RMCast_IO_UDP.cpp +++ b/protocols/ace/RMCast/RMCast_IO_UDP.cpp @@ -1,16 +1,21 @@ // $Id$ #include "RMCast_IO_UDP.h" + +#if !defined (__ACE_INLINE__) +# include "RMCast_IO_UDP.i" +#endif /* ! __ACE_INLINE__ */ + #include "RMCast_UDP_Proxy.h" #include "RMCast_Module_Factory.h" #include "ace/Handle_Set.h" #include "ace/Reactor.h" #include "ace/Message_Block.h" - -#if !defined (__ACE_INLINE__) -# include "RMCast_IO_UDP.i" -#endif /* ! __ACE_INLINE__ */ +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/os_include/arpa/os_inet.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(ace, RMCast_IO_UDP, "RMCast_IO_UDP.cpp,v 1.12 2000/12/20 22:00:33 oci Exp") diff --git a/protocols/ace/RMCast/RMCast_IO_UDP.h b/protocols/ace/RMCast/RMCast_IO_UDP.h index 4881233cb59..9e1a83dc032 100644 --- a/protocols/ace/RMCast/RMCast_IO_UDP.h +++ b/protocols/ace/RMCast/RMCast_IO_UDP.h @@ -19,6 +19,7 @@ #include "ace/Hash_Map_Manager.h" #include "ace/Synch.h" #include "ace/INET_Addr.h" +#include "ace/Null_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/protocols/ace/RMCast/RMCast_Membership.cpp b/protocols/ace/RMCast/RMCast_Membership.cpp index 91c9b1a9cea..598e05019af 100644 --- a/protocols/ace/RMCast/RMCast_Membership.cpp +++ b/protocols/ace/RMCast/RMCast_Membership.cpp @@ -3,12 +3,14 @@ // #include "RMCast_Membership.h" -#include "RMCast_Proxy.h" #if !defined (__ACE_INLINE__) # include "RMCast_Membership.i" #endif /* ! __ACE_INLINE__ */ +#include "RMCast_Proxy.h" +#include "ace/Guard_T.h" + ACE_RCSID(ace, RMCast_Membership, "$Id$") ACE_RMCast_Membership::~ACE_RMCast_Membership (void) diff --git a/protocols/ace/RMCast/RMCast_Membership.h b/protocols/ace/RMCast/RMCast_Membership.h index beab2c881f9..14d5790e584 100644 --- a/protocols/ace/RMCast/RMCast_Membership.h +++ b/protocols/ace/RMCast/RMCast_Membership.h @@ -20,7 +20,8 @@ #include "RMCast_Module.h" #include "ace/Containers.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/protocols/ace/RMCast/RMCast_Reassembly.h b/protocols/ace/RMCast/RMCast_Reassembly.h index bc3fc17049d..d4ed999cf78 100644 --- a/protocols/ace/RMCast/RMCast_Reassembly.h +++ b/protocols/ace/RMCast/RMCast_Reassembly.h @@ -16,7 +16,9 @@ #include "RMCast_Module.h" #include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" +#include "ace/Null_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/protocols/ace/RMCast/RMCast_Reordering.h b/protocols/ace/RMCast/RMCast_Reordering.h index 4ecf824acac..dadca2aa0f6 100644 --- a/protocols/ace/RMCast/RMCast_Reordering.h +++ b/protocols/ace/RMCast/RMCast_Reordering.h @@ -17,7 +17,9 @@ #include "RMCast_Module.h" #include "ace/RB_Tree.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" +#include "ace/Null_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/protocols/ace/RMCast/RMCast_Sequencer.cpp b/protocols/ace/RMCast/RMCast_Sequencer.cpp index f8bc0e6c57d..356fbb4a01b 100644 --- a/protocols/ace/RMCast/RMCast_Sequencer.cpp +++ b/protocols/ace/RMCast/RMCast_Sequencer.cpp @@ -8,6 +8,8 @@ # include "RMCast_Sequencer.i" #endif /* ! __ACE_INLINE__ */ +#include "ace/Guard_T.h" + ACE_RCSID(ace, RMCast_Sequencer, "$Id$") ACE_RMCast_Sequencer::~ACE_RMCast_Sequencer (void) diff --git a/protocols/ace/RMCast/RMCast_Sequencer.h b/protocols/ace/RMCast/RMCast_Sequencer.h index 8e6447dce62..28f83a1d4b3 100644 --- a/protocols/ace/RMCast/RMCast_Sequencer.h +++ b/protocols/ace/RMCast/RMCast_Sequencer.h @@ -16,7 +16,8 @@ #include /**/ "ace/pre.h" #include "RMCast_Module.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/protocols/ace/RMCast/RMCast_UDP_Proxy.cpp b/protocols/ace/RMCast/RMCast_UDP_Proxy.cpp index c84b8c0f2ef..fb7eaf72f76 100644 --- a/protocols/ace/RMCast/RMCast_UDP_Proxy.cpp +++ b/protocols/ace/RMCast/RMCast_UDP_Proxy.cpp @@ -1,14 +1,17 @@ // $Id$ #include "RMCast_UDP_Proxy.h" -#include "RMCast_Module.h" -#include "RMCast_IO_UDP.h" -#include "ace/Message_Block.h" #if !defined (__ACE_INLINE__) # include "RMCast_UDP_Proxy.i" #endif /* ! __ACE_INLINE__ */ +#include "RMCast_Module.h" +#include "RMCast_IO_UDP.h" +#include "ace/Message_Block.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/arpa/os_inet.h" + ACE_RCSID(ace, RMCast_UDP_Proxy, "$Id$") ACE_RMCast_UDP_Proxy::ACE_RMCast_UDP_Proxy (ACE_RMCast_IO_UDP *io_udp, diff --git a/tests/Aio_Platform_Test.cpp b/tests/Aio_Platform_Test.cpp index e2ec2209aa1..9d22b6da78d 100644 --- a/tests/Aio_Platform_Test.cpp +++ b/tests/Aio_Platform_Test.cpp @@ -19,7 +19,7 @@ // ===================================================================== #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Aio_Platform_Test, "$Id$") diff --git a/tests/Auto_IncDec_Test.cpp b/tests/Auto_IncDec_Test.cpp index 31516eed34d..6b4330e83ba 100644 --- a/tests/Auto_IncDec_Test.cpp +++ b/tests/Auto_IncDec_Test.cpp @@ -21,7 +21,7 @@ #include "ace/Thread_Manager.h" #include "ace/Atomic_Op.h" #include "tests/test_config.h" - +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Auto_IncDec_Test, "Auto_IncDec_Test.cpp, by Edan Ayal") diff --git a/tests/Barrier_Test.cpp b/tests/Barrier_Test.cpp index c7db6350014..ce2fa29cb5b 100644 --- a/tests/Barrier_Test.cpp +++ b/tests/Barrier_Test.cpp @@ -18,7 +18,7 @@ // ============================================================================ #include "test_config.h" -#include "ace/Synch.h" +#include "ace/Barrier.h" #include "ace/Thread_Manager.h" ACE_RCSID(tests, Barrier_Test, "$Id$") diff --git a/tests/Basic_Types_Test.cpp b/tests/Basic_Types_Test.cpp index 95e1cd848cf..cd7c58f6174 100644 --- a/tests/Basic_Types_Test.cpp +++ b/tests/Basic_Types_Test.cpp @@ -36,7 +36,7 @@ #endif /* ! ACE_HAS_MINIMAL_ACE_OS */ #include "ace/Basic_Types.h" -#include "ace/OS.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Basic_Types_Test, "$Id$") diff --git a/tests/Buffer_Stream_Test.cpp b/tests/Buffer_Stream_Test.cpp index 9a8575ff6b1..7c903162435 100644 --- a/tests/Buffer_Stream_Test.cpp +++ b/tests/Buffer_Stream_Test.cpp @@ -26,6 +26,7 @@ #include "ace/Stream.h" #include "ace/Module.h" #include "ace/Task.h" +#include "ace/OS_NS_time.h" ACE_RCSID(tests, Buffer_Stream_Test, "$Id$") diff --git a/tests/CE_fostream.h b/tests/CE_fostream.h index 347cfc0e71d..b488aaba3b1 100644 --- a/tests/CE_fostream.h +++ b/tests/CE_fostream.h @@ -23,8 +23,7 @@ #ifdef ACE_HAS_WINCE -#include "ace/OS.h" - +#include "ace/Null_Mutex.h" #include "ace/Singleton.h" #ifdef ostream diff --git a/tests/Cache_Map_Manager_Test.cpp b/tests/Cache_Map_Manager_Test.cpp index 871ca9319b9..524c64e63f2 100644 --- a/tests/Cache_Map_Manager_Test.cpp +++ b/tests/Cache_Map_Manager_Test.cpp @@ -19,12 +19,13 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_NS_string.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "ace/OS_NS_time.h" #include "test_config.h" #include "ace/Hash_Cache_Map_Manager_T.h" #include "ace/Map_Manager.h" diff --git a/tests/Config_Test.cpp b/tests/Config_Test.cpp index 29d0aa2dd25..a1f0b549f44 100644 --- a/tests/Config_Test.cpp +++ b/tests/Config_Test.cpp @@ -22,6 +22,8 @@ #include "test_config.h" #include "Config_Test.h" #include "ace/Configuration_Import_Export.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(tests, Config_Test, "$Id$") diff --git a/tests/Conn_Test.cpp b/tests/Conn_Test.cpp index 04466e250bd..1a238c5e5af 100644 --- a/tests/Conn_Test.cpp +++ b/tests/Conn_Test.cpp @@ -33,6 +33,10 @@ #include "ace/Get_Opt.h" #include "ace/Process_Mutex.h" #include "Conn_Test.h" +#include "ace/Barrier.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/os_include/os_netdb.h" ACE_RCSID(tests, Conn_Test, "$Id$") diff --git a/tests/DLL_Test.cpp b/tests/DLL_Test.cpp index 077de0581e8..adea3f2903a 100644 --- a/tests/DLL_Test.cpp +++ b/tests/DLL_Test.cpp @@ -117,7 +117,7 @@ int basic_test (ACE_DLL &dll) // Allocate and free a string allocated via malloc in a different dll. ACE_TCHAR *malloc_str = my_hello->malloc_info (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Result for malloc_info(): %s\n"), malloc_str)); - ACE_OS_Memory::free (malloc_str); + ACE_OS::free (malloc_str); return 0; } diff --git a/tests/DLL_Test_Impl.cpp b/tests/DLL_Test_Impl.cpp index 7663009ceec..e1171b1c5e2 100644 --- a/tests/DLL_Test_Impl.cpp +++ b/tests/DLL_Test_Impl.cpp @@ -20,6 +20,7 @@ #include "ace/ACE.h" #include "ace/OS_Errno.h" #include "ace/svc_export.h" +#include "ace/OS_NS_string.h" ACE_RCSID (tests, DLL_Test_Impl, @@ -51,7 +52,7 @@ Hello_Impl::new_info (void) ACE_TCHAR * Hello_Impl::malloc_info (void) { - return ACE_OS_String::strdup (ACE_TEXT ("Hello_Impl::new_info() allocated by ACE_OS_Memory::malloc()")); + return ACE_OS::strdup (ACE_TEXT ("Hello_Impl::new_info() allocated by ACE_OS::malloc()")); } void * diff --git a/tests/DLL_Test_Impl.h b/tests/DLL_Test_Impl.h index 5ae706edf2b..bf16bdd5c48 100644 --- a/tests/DLL_Test_Impl.h +++ b/tests/DLL_Test_Impl.h @@ -46,7 +46,7 @@ public: // Uses ACE::strnew() to allocate the returned string. ACE_TCHAR *malloc_info (void); - // Uses ACE_OS_Memory::malloc() to allocate the returned string. + // Uses ACE_OS::malloc() to allocate the returned string. // Overload the new/delete opertors so the object will be // created/deleted using the memory allocator associated with the diff --git a/tests/Dirent_Test.cpp b/tests/Dirent_Test.cpp index 0ddec323d80..e392d022c7a 100644 --- a/tests/Dirent_Test.cpp +++ b/tests/Dirent_Test.cpp @@ -24,8 +24,7 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" #include "ace/Dirent.h" #include "ace/Dirent_Selector.h" @@ -47,13 +46,13 @@ static int entrycount = 0; static int selector (const dirent *d) { - return ACE_OS_String::strcmp (d->d_name, ACE_TEXT (TEST_ENTRY)) == 0; + return ACE_OS::strcmp (d->d_name, ACE_TEXT (TEST_ENTRY)) == 0; } static int comparator (const dirent **d1, const dirent **d2) { - return ACE_OS_String::strcmp ((*d1)->d_name, (*d2)->d_name); + return ACE_OS::strcmp ((*d1)->d_name, (*d2)->d_name); } static int diff --git a/tests/Enum_Interfaces_Test.cpp b/tests/Enum_Interfaces_Test.cpp index f9855977db6..71f409dfae9 100644 --- a/tests/Enum_Interfaces_Test.cpp +++ b/tests/Enum_Interfaces_Test.cpp @@ -29,7 +29,7 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_sys_utsname.h" #include "ace/INET_Addr.h" ACE_RCSID(tests, Enum_Interfaces_Test, "$Id$") diff --git a/tests/Env_Value_Test.cpp b/tests/Env_Value_Test.cpp index 8971ffd39a6..bb2ece06627 100644 --- a/tests/Env_Value_Test.cpp +++ b/tests/Env_Value_Test.cpp @@ -15,7 +15,6 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" #include "ace/Process.h" #include "ace/Env_Value_T.h" diff --git a/tests/FIFO_Test.cpp b/tests/FIFO_Test.cpp index 6d82391a83a..7778d52a9db 100644 --- a/tests/FIFO_Test.cpp +++ b/tests/FIFO_Test.cpp @@ -20,7 +20,9 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_sys_wait.h" #include "ace/ACE.h" #include "ace/FIFO_Send_Msg.h" #include "ace/FIFO_Recv_Msg.h" @@ -187,7 +189,7 @@ test_fifo_msg (void) if (ACE_Lib_Find::get_temp_dir (fifo_path, MAXPATHLEN) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_temp_dir")), 1); - ACE_OS_String::strcat (fifo_path, ACE_TEXT ("FIFO_Test")); + ACE_OS::strcat (fifo_path, ACE_TEXT ("FIFO_Test")); ACE_FIFO_Recv_Msg read_side; // Open read only, not persistent (4th arg is 0) if (-1 == read_side.open (fifo_path, diff --git a/tests/Framework_Component_DLL.cpp b/tests/Framework_Component_DLL.cpp index e5a1bdb4bca..894d1af9f4f 100644 --- a/tests/Framework_Component_DLL.cpp +++ b/tests/Framework_Component_DLL.cpp @@ -3,7 +3,6 @@ #include "ace/Service_Config.h" #include "ace/Service_Object.h" #include "ace/Framework_Component_T.h" -#include "ace/OS.h" ACE_RCSID (tests, Framework_Component_DLL, diff --git a/tests/Hash_Map_Bucket_Iterator_Test.cpp b/tests/Hash_Map_Bucket_Iterator_Test.cpp index cae31d8c504..affd0ba8698 100644 --- a/tests/Hash_Map_Bucket_Iterator_Test.cpp +++ b/tests/Hash_Map_Bucket_Iterator_Test.cpp @@ -18,7 +18,8 @@ #include "test_config.h" #include "ace/Hash_Map_Manager.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" #include "ace/Get_Opt.h" #include "ace/Functor.h" diff --git a/tests/Hash_Map_Manager_Test.cpp b/tests/Hash_Map_Manager_Test.cpp index c87f7c5f9b0..26a41c0cd98 100644 --- a/tests/Hash_Map_Manager_Test.cpp +++ b/tests/Hash_Map_Manager_Test.cpp @@ -23,7 +23,7 @@ #include "test_config.h" #include "ace/Hash_Map_Manager.h" #include "ace/Malloc_T.h" -#include "ace/Synch.h" +#include "ace/Null_Mutex.h" ACE_RCSID(tests, Hash_Map_Manager_Test, "$Id$") diff --git a/tests/High_Res_Timer_Test.cpp b/tests/High_Res_Timer_Test.cpp index b2e99072314..7a990302fd8 100644 --- a/tests/High_Res_Timer_Test.cpp +++ b/tests/High_Res_Timer_Test.cpp @@ -20,6 +20,7 @@ #include "ace/High_Res_Timer.h" #include "ace/Sched_Params.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, High_Res_Timer_Test, "High_Res_Timer_Test.cpp,v 4.6 2000/04/23 04:43:58 brunsch Exp") diff --git a/tests/INET_Addr_Test.cpp b/tests/INET_Addr_Test.cpp index f48f99f51fa..c738ff94d1d 100644 --- a/tests/INET_Addr_Test.cpp +++ b/tests/INET_Addr_Test.cpp @@ -19,9 +19,10 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" +#include "ace/OS_NS_arpa_inet.h" // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. diff --git a/tests/Logging_Strategy_Test.cpp b/tests/Logging_Strategy_Test.cpp index 32ab9aace06..f393d3033d1 100644 --- a/tests/Logging_Strategy_Test.cpp +++ b/tests/Logging_Strategy_Test.cpp @@ -32,7 +32,7 @@ // //========================================================================== -#include "ace/OS.h" +#include "ace/OS_NS_sys_stat.h" #include "ace/Auto_Ptr.h" #include "ace/Service_Config.h" #include "ace/Thread_Manager.h" @@ -46,6 +46,7 @@ #include "ace/Auto_Ptr.cpp" #include "ace/Get_Opt.h" #include "test_config.h" +#include "ace/OS_NS_time.h" ACE_RCSID(tests, Logging_Strategy_Test, "$Id$") @@ -463,11 +464,11 @@ int run_main (int argc, ACE_TCHAR *argv []) for (int i = 1; i < argc; i++) { - ACE_OS_String::strcat (arg_str, argv[i]); - ACE_OS_String::strcat (arg_str, ACE_TEXT (" ")); + ACE_OS::strcat (arg_str, argv[i]); + ACE_OS::strcat (arg_str, ACE_TEXT (" ")); } - ACE_OS_String::strcat (arg_str, ACE_TEXT ("\"")); + ACE_OS::strcat (arg_str, ACE_TEXT ("\"")); if (ACE_Service_Config::process_directive (arg_str) == -1) ACE_ERROR_RETURN ((LM_ERROR, diff --git a/tests/MEM_Stream_Test.cpp b/tests/MEM_Stream_Test.cpp index 77089073451..2c5ee3b24b3 100644 --- a/tests/MEM_Stream_Test.cpp +++ b/tests/MEM_Stream_Test.cpp @@ -18,7 +18,6 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" #include "ace/Get_Opt.h" #include "ace/Thread_Manager.h" #include "ace/MEM_Connector.h" @@ -123,7 +122,7 @@ Echo_Handler::handle_input (ACE_HANDLE) ACE_TCHAR return_buf[MAXPATHLEN]; ACE_OS::strcpy (return_buf, this->name_); - ACE_OS_String::strcat (return_buf, buf); + ACE_OS::strcat (return_buf, buf); len = (ACE_OS::strlen (return_buf) + 1) * sizeof (ACE_TCHAR); if (this->peer ().send (return_buf, len) != len) diff --git a/tests/MEM_Stream_Test.h b/tests/MEM_Stream_Test.h index 663bfcb8ac6..b9ed6924463 100644 --- a/tests/MEM_Stream_Test.h +++ b/tests/MEM_Stream_Test.h @@ -26,11 +26,10 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" #include "ace/MEM_Stream.h" #include "ace/Reactor.h" #include "ace/Svc_Handler.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) diff --git a/tests/MM_Shared_Memory_Test.cpp b/tests/MM_Shared_Memory_Test.cpp index 46f2be7d000..a69a33a0606 100644 --- a/tests/MM_Shared_Memory_Test.cpp +++ b/tests/MM_Shared_Memory_Test.cpp @@ -23,11 +23,11 @@ #include "test_config.h" #include "ace/Shared_Memory_MM.h" -#include "ace/Synch.h" #include "ace/SV_Semaphore_Simple.h" #include "ace/Process_Semaphore.h" #include "ace/Thread_Manager.h" #include "ace/ACE.h" +#include "ace/OS_NS_string.h" ACE_RCSID(tests, MM_Shared_Memory_Test, "$Id$") @@ -202,7 +202,7 @@ run_main (int, ACE_TCHAR *[]) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Temporary path too long\n")), -1); // Add the filename to the end - ACE_OS_String::strcat (temp_file, ACE_TEXT ("mm_shared_mem_testXXXXXX")); + ACE_OS::strcat (temp_file, ACE_TEXT ("mm_shared_mem_testXXXXXX")); // Store in the global variable. shm_key = temp_file; diff --git a/tests/MT_Reactor_Upcall_Test.cpp b/tests/MT_Reactor_Upcall_Test.cpp index 71ec9cc5f2b..5c9e5992c9f 100644 --- a/tests/MT_Reactor_Upcall_Test.cpp +++ b/tests/MT_Reactor_Upcall_Test.cpp @@ -208,8 +208,8 @@ test_reactor_upcall (ACE_Reactor &reactor) data_message.type_ = Message::DATA; data_message.size_ = - ACE_OS_String::strlen (message); - ACE_OS_String::strcpy (data_message.data_, message); + ACE_OS::strlen (message); + ACE_OS::strcpy (data_message.data_, message); // Send in three pieces because the struct members may not be adjacent // in memory. diff --git a/tests/MT_Reference_Counted_Event_Handler_Test.cpp b/tests/MT_Reference_Counted_Event_Handler_Test.cpp index d7f9f73e3fb..e994b4344a1 100644 --- a/tests/MT_Reference_Counted_Event_Handler_Test.cpp +++ b/tests/MT_Reference_Counted_Event_Handler_Test.cpp @@ -36,6 +36,8 @@ #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Connector.h" #include "ace/Auto_Event.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_time.h" ACE_RCSID(tests, MT_Reference_Counted_Event_Handler_Test, "$Id$") diff --git a/tests/MT_SOCK_Test.cpp b/tests/MT_SOCK_Test.cpp index 35377099030..a82d7a19aaa 100644 --- a/tests/MT_SOCK_Test.cpp +++ b/tests/MT_SOCK_Test.cpp @@ -24,7 +24,8 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_sys_wait.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/SOCK_Connector.h" diff --git a/tests/Main.cpp b/tests/Main.cpp index e80f79ca2c2..44b92128394 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -17,7 +17,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_HAS_WINCE) # include "ace/ACE.h" #endif /* ACE_HAS_WINCE */ diff --git a/tests/Map_Test.cpp b/tests/Map_Test.cpp index 4d9d7bba1ac..9a8a634662f 100644 --- a/tests/Map_Test.cpp +++ b/tests/Map_Test.cpp @@ -21,7 +21,6 @@ #include "Map_Test.h" #include "ace/Map_T.h" #include "ace/Profile_Timer.h" -#include "ace/Synch.h" ACE_RCSID(tests, Map_Test, "$Id$") diff --git a/tests/Map_Test.h b/tests/Map_Test.h index 946b03f33f1..c881a3f7645 100644 --- a/tests/Map_Test.h +++ b/tests/Map_Test.h @@ -22,11 +22,12 @@ #ifndef ACE_TESTS_MAP_TEST_H #define ACE_TESTS_MAP_TEST_H +#include "ace/OS_NS_string.h" + #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS.h" #include "ace/Active_Map_Manager.h" #include "ace/Containers.h" diff --git a/tests/Max_Default_Port_Test.cpp b/tests/Max_Default_Port_Test.cpp index 242edbb3e8a..39ab791ccc8 100644 --- a/tests/Max_Default_Port_Test.cpp +++ b/tests/Max_Default_Port_Test.cpp @@ -26,7 +26,6 @@ // // ============================================================================ -#include "ace/OS.h" #include "ace/streams.h" #include "ace/Reactor.h" #include "ace/SOCK_Connector.h" diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp index 199efe6e824..87a7953ee31 100644 --- a/tests/Mem_Map_Test.cpp +++ b/tests/Mem_Map_Test.cpp @@ -22,6 +22,7 @@ #include "test_config.h" #include "ace/Mem_Map.h" #include "ace/ACE.h" +#include "ace/OS_NS_string.h" ACE_RCSID(tests, Mem_Map_Test, "$Id$") @@ -144,12 +145,12 @@ run_main (int, ACE_TCHAR *[]) ACE_OS::strcpy (temp_file2, test_file); // Add the filenames to the end - ACE_OS_String::strcat (test_file, - ACE_TEXT ("ace_mem_map_test")); - ACE_OS_String::strcat (temp_file1, - ACE_TEXT ("ace_mem_map_temp_1")); - ACE_OS_String::strcat (temp_file2, - ACE_TEXT ("ace_mem_map_temp_2")); + ACE_OS::strcat (test_file, + ACE_TEXT ("ace_mem_map_test")); + ACE_OS::strcat (temp_file1, + ACE_TEXT ("ace_mem_map_temp_1")); + ACE_OS::strcat (temp_file2, + ACE_TEXT ("ace_mem_map_temp_2")); // First create a test file to work on if (create_test_file (test_file, LINE_LENGTH, NUM_LINES) != 0) diff --git a/tests/Message_Queue_Notifications_Test.cpp b/tests/Message_Queue_Notifications_Test.cpp index 567df50cf00..96b707a9e04 100644 --- a/tests/Message_Queue_Notifications_Test.cpp +++ b/tests/Message_Queue_Notifications_Test.cpp @@ -40,6 +40,7 @@ #include "ace/Reactor_Notification_Strategy.h" #include "ace/Atomic_Op.h" #include "ace/Barrier.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Message_Queue_Notifications_Test, "$Id$") diff --git a/tests/Message_Queue_Test.cpp b/tests/Message_Queue_Test.cpp index a60d99253e4..6f4c9a07166 100644 --- a/tests/Message_Queue_Test.cpp +++ b/tests/Message_Queue_Test.cpp @@ -25,8 +25,11 @@ #include "test_config.h" #include "ace/Thread_Manager.h" #include "ace/Message_Queue.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" +#include "ace/Null_Condition.h" #include "ace/High_Res_Timer.h" +#include "ace/OS_NS_string.h" ACE_RCSID(tests, Message_Queue_Test, "$Id$") diff --git a/tests/Message_Queue_Test_Ex.cpp b/tests/Message_Queue_Test_Ex.cpp index b26ae57b453..b48471699e6 100644 --- a/tests/Message_Queue_Test_Ex.cpp +++ b/tests/Message_Queue_Test_Ex.cpp @@ -26,7 +26,9 @@ #include "test_config.h" #include "ace/Thread_Manager.h" #include "ace/Message_Queue.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" +#include "ace/Null_Condition.h" #include "ace/High_Res_Timer.h" #include "ace/Message_Block.h" #include "Message_Queue_Test_Ex.h" // Declares User_Class diff --git a/tests/Message_Queue_Test_Ex.h b/tests/Message_Queue_Test_Ex.h index fb3533a00d2..70c5e1f9cf8 100644 --- a/tests/Message_Queue_Test_Ex.h +++ b/tests/Message_Queue_Test_Ex.h @@ -18,7 +18,7 @@ #ifndef ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H #define ACE_TESTS_MESSAGE_QUEUE_TEST_EX_H -#include "ace/OS.h" +#include "ace/OS_NS_string.h" // User-defined class used for queue data. class User_Class diff --git a/tests/Multicast_Test.cpp b/tests/Multicast_Test.cpp index 83d28d72200..84b25bd01dd 100644 --- a/tests/Multicast_Test.cpp +++ b/tests/Multicast_Test.cpp @@ -39,7 +39,8 @@ #include "ace/SOCK_Dgram_Mcast.h" #include "ace/ACE.h" #include "ace/Reactor.h" -#include "ace/OS_String.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" #include "ace/Task.h" #include "ace/Atomic_Op.h" #include "ace/SString.h" @@ -738,7 +739,7 @@ int send_dgram (ACE_SOCK_Dgram &socket, ACE_INET_Addr addr, int done = 0) else ACE_OS::sprintf (buf, "%s/%d", address, port); //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("sending (%s)\n"), buf)); - if (socket.send (buf, ACE_OS_String::strlen (buf),addr) == -1) + if (socket.send (buf, ACE_OS::strlen (buf),addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_dgram - error calling send on ") ACE_TEXT ("ACE_SOCK_Dgram.")), -1); diff --git a/tests/Multihomed_INET_Addr_Test.cpp b/tests/Multihomed_INET_Addr_Test.cpp index 6d89b769946..0312f9be665 100644 --- a/tests/Multihomed_INET_Addr_Test.cpp +++ b/tests/Multihomed_INET_Addr_Test.cpp @@ -18,10 +18,11 @@ // // ============================================================================ -#include /**/ "test_config.h" -#include /**/ "ace/OS.h" -#include /**/ "ace/Multihomed_INET_Addr.h" -#include /**/ "ace/Log_Msg.h" +#include "test_config.h" +#include "ace/OS_NS_string.h" +#include "ace/Multihomed_INET_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_arpa_inet.h" int run_main (int argc, ACE_TCHAR *argv[]) { diff --git a/tests/Naming_Test.cpp b/tests/Naming_Test.cpp index 4944a706f1d..1cb459060e4 100644 --- a/tests/Naming_Test.cpp +++ b/tests/Naming_Test.cpp @@ -22,6 +22,7 @@ #include "ace/SString.h" #include "ace/Naming_Context.h" #include "ace/Profile_Timer.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(tests, Naming_Test, "$Id$") @@ -198,7 +199,7 @@ run_main (int argc, ACE_TCHAR *argv[]) { ACE_OS::strcpy (temp_file, ACE::basename (name_options->process_name (), ACE_DIRECTORY_SEPARATOR_CHAR)); - ACE_OS_String::strcat (temp_file, ACE_TEXT ("XXXXXX")); + ACE_OS::strcat (temp_file, ACE_TEXT ("XXXXXX")); // Set the database name using mktemp to generate a unique file name name_options->database (ACE_OS::mktemp (temp_file)); diff --git a/tests/New_Fail_Test.cpp b/tests/New_Fail_Test.cpp index 20fcc8f8ba9..4a25d63933c 100644 --- a/tests/New_Fail_Test.cpp +++ b/tests/New_Fail_Test.cpp @@ -25,7 +25,7 @@ #include "test_config.h" #include "ace/Log_Msg.h" -#include "ace/OS.h" +#include "ace/OS_Memory.h" #include "ace/CORBA_macros.h" ACE_RCSID(tests, New_Fail_Test, "$Id$") diff --git a/tests/OS_Test.cpp b/tests/OS_Test.cpp index e11b78c3278..343c31119ff 100644 --- a/tests/OS_Test.cpp +++ b/tests/OS_Test.cpp @@ -13,7 +13,14 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_unistd.h" #include "test_config.h" ACE_RCSID(tests, OS_Test, "$Id$") @@ -141,11 +148,11 @@ string_emulation_test (void) const char *memchr1 = "abcdefghijklmnopqrstuvwxyz"; - ACE_ASSERT (ACE_OS_String::memchr (ACE_static_cast (const void *, NULL), - 'a', - 0) == NULL); - ACE_ASSERT (ACE_OS_String::memchr (memchr1, 'a', sizeof (memchr1)) != NULL); - ACE_ASSERT (ACE_OS_String::memchr (memchr1, '1', sizeof (memchr1)) == NULL); + ACE_ASSERT (ACE_OS::memchr (ACE_static_cast (const void *, NULL), + 'a', + 0) == NULL); + ACE_ASSERT (ACE_OS::memchr (memchr1, 'a', sizeof (memchr1)) != NULL); + ACE_ASSERT (ACE_OS::memchr (memchr1, '1', sizeof (memchr1)) == NULL); // ======================================================================== // Test strchr @@ -153,9 +160,9 @@ string_emulation_test (void) const char *strchr1 = "abcdefghijkabcdefghijk"; - ACE_ASSERT (*ACE_OS_String::strchr (strchr1, 'h') == 'h'); - ACE_ASSERT (ACE_OS_String::strchr (strchr1, 'h') == strchr1 + 7); - ACE_ASSERT (ACE_OS_String::strchr (strchr1, '1') == NULL); + ACE_ASSERT (*ACE_OS::strchr (strchr1, 'h') == 'h'); + ACE_ASSERT (ACE_OS::strchr (strchr1, 'h') == strchr1 + 7); + ACE_ASSERT (ACE_OS::strchr (strchr1, '1') == NULL); // ======================================================================== // Test strrchr @@ -163,9 +170,9 @@ string_emulation_test (void) const char *strrchr1 = "abcdefghijkabcdefghijk"; - ACE_ASSERT (*ACE_OS_String::strrchr (strrchr1, 'h') == 'h'); - ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, 'h') == strrchr1 + 18); - ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, '1') == NULL); + ACE_ASSERT (*ACE_OS::strrchr (strrchr1, 'h') == 'h'); + ACE_ASSERT (ACE_OS::strrchr (strrchr1, 'h') == strrchr1 + 18); + ACE_ASSERT (ACE_OS::strrchr (strrchr1, '1') == NULL); // ======================================================================== // Test strcspn @@ -173,8 +180,8 @@ string_emulation_test (void) const char *strcspn1 = "abcdefghijkabcdefghijk"; - ACE_ASSERT (ACE_OS_String::strcspn (strcspn1, "d") == 3); - ACE_ASSERT (ACE_OS_String::strcspn (strcspn1, "abcdefghijk") == 0); + ACE_ASSERT (ACE_OS::strcspn (strcspn1, "d") == 3); + ACE_ASSERT (ACE_OS::strcspn (strcspn1, "abcdefghijk") == 0); // ======================================================================== // Test strcasecmp @@ -186,11 +193,11 @@ string_emulation_test (void) const char *strcasecmp4 = "STRINGF"; // Different case const char *strcasecmp5 = "stringe"; // The last letter is lower - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp1) == 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp2) < 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp3) < 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp4) == 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp5) > 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp1) == 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp2) < 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp3) < 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp4) == 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp5) > 0); // ======================================================================== // Test strtok_r @@ -199,23 +206,23 @@ string_emulation_test (void) char strtok_r1[] = "A string of tokens"; char *strtok_r2; - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (strtok_r1, - " ", - &strtok_r2), - "A") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (0, - " ", - &strtok_r2), - "string") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (0, - " ", - &strtok_r2), - "of") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (0, - " ", - &strtok_r2), - "tokens") == 0); - ACE_ASSERT (ACE_OS_String::strtok_r (0, " ", &strtok_r2) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok_r (strtok_r1, + " ", + &strtok_r2), + "A") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok_r (0, + " ", + &strtok_r2), + "string") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok_r (0, + " ", + &strtok_r2), + "of") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok_r (0, + " ", + &strtok_r2), + "tokens") == 0); + ACE_ASSERT (ACE_OS::strtok_r (0, " ", &strtok_r2) == 0); // ======================================================================== // Test itoa @@ -223,32 +230,32 @@ string_emulation_test (void) char itoa1[33]; - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itoa1, 2), - "101010") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (42, itoa1, 2), + "101010") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itoa1, 3), - "1120") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (42, itoa1, 3), + "1120") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itoa1, 16), - "2a") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (42, itoa1, 16), + "2a") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (8, itoa1, 10), - "8") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (8, itoa1, 10), + "8") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (-8, itoa1, 10), - "-8") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (-8, itoa1, 10), + "-8") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (20345, itoa1, 10), - "20345") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (20345, itoa1, 10), + "20345") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (-20345, itoa1, 10), - "-20345") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (-20345, itoa1, 10), + "-20345") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (4566733, itoa1, 10), - "4566733") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (4566733, itoa1, 10), + "4566733") == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (-4566733, itoa1, 10), - "-4566733") == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (-4566733, itoa1, 10), + "-4566733") == 0); } #if defined (ACE_HAS_WCHAR) @@ -259,14 +266,14 @@ string_emulation_test (void) wchar_t itow1[33]; - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itow1, 2), - ACE_TEXT_WIDE ("101010")) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (42, itow1, 2), + ACE_TEXT_WIDE ("101010")) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itow1, 3), - ACE_TEXT_WIDE ("1120")) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (42, itow1, 3), + ACE_TEXT_WIDE ("1120")) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itow1, 16), - ACE_TEXT_WIDE ("2a")) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::itoa (42, itow1, 16), + ACE_TEXT_WIDE ("2a")) == 0); // ======================================================================== @@ -279,11 +286,11 @@ string_emulation_test (void) const wchar_t *strcmp4 = ACE_TEXT_WIDE ("STRINGF"); const wchar_t *strcmp5 = ACE_TEXT_WIDE ("stringe"); - ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp1) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp2) < 0); - ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp3) < 0); - ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp4) != 0); - ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp5) > 0); + ACE_ASSERT (ACE_OS::strcmp (strcmp1, strcmp1) == 0); + ACE_ASSERT (ACE_OS::strcmp (strcmp1, strcmp2) < 0); + ACE_ASSERT (ACE_OS::strcmp (strcmp1, strcmp3) < 0); + ACE_ASSERT (ACE_OS::strcmp (strcmp1, strcmp4) != 0); + ACE_ASSERT (ACE_OS::strcmp (strcmp1, strcmp5) > 0); // ======================================================================== // Test strcpy (wchar_t version) @@ -293,9 +300,9 @@ string_emulation_test (void) wchar_t strcpy2[27]; ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strcpy (strcpy2, strcpy1), - strcpy1) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (strcpy2, strcpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strcpy (strcpy2, strcpy1), + strcpy1) == 0); + ACE_ASSERT (ACE_OS::strcmp (strcpy2, strcpy1) == 0); // ======================================================================== // Test strcat (wchar_t version) @@ -306,9 +313,9 @@ string_emulation_test (void) const wchar_t *strcat3 = ACE_TEXT_WIDE ("mnopqrstuvwxyz"); ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strcat (strcat2, strcat3), - strcat1) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (strcat2, strcat1) == 0); + (ACE_OS::strcmp (ACE_OS::strcat (strcat2, strcat3), + strcat1) == 0); + ACE_ASSERT (ACE_OS::strcmp (strcat2, strcat1) == 0); // ======================================================================== // Test strncat (wchar_t version) @@ -319,9 +326,9 @@ string_emulation_test (void) const wchar_t *strncat3 = ACE_TEXT_WIDE ("mnopqrstuvwxyzabc"); ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strncat (strncat2, strncat3, 14), - strncat1) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (strncat2, strncat1) == 0); + (ACE_OS::strcmp (ACE_OS::strncat (strncat2, strncat3, 14), + strncat1) == 0); + ACE_ASSERT (ACE_OS::strcmp (strncat2, strncat1) == 0); // ======================================================================== // Test strspn (wchar_t version) @@ -329,10 +336,10 @@ string_emulation_test (void) const wchar_t *strspn1 = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); - ACE_ASSERT (ACE_OS_String::strspn (strspn1, - ACE_TEXT_WIDE ("abcdf")) == 4); - ACE_ASSERT (ACE_OS_String::strspn (strspn1, - ACE_TEXT_WIDE ("mno")) == 0); + ACE_ASSERT (ACE_OS::strspn (strspn1, + ACE_TEXT_WIDE ("abcdf")) == 4); + ACE_ASSERT (ACE_OS::strspn (strspn1, + ACE_TEXT_WIDE ("mno")) == 0); // ======================================================================== // Test strchr (wchar_t version) @@ -340,11 +347,11 @@ string_emulation_test (void) const wchar_t *strchr1 = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); - ACE_ASSERT (*ACE_OS_String::strchr (strchr1, ACE_TEXT_WIDE ('h')) - == ACE_TEXT_WIDE ('h')); - ACE_ASSERT (ACE_OS_String::strchr (strchr1, ACE_TEXT_WIDE ('h')) - == strchr1 + 7); - ACE_ASSERT (ACE_OS_String::strchr (strchr1, ACE_TEXT_WIDE ('1')) == NULL); + ACE_ASSERT (*ACE_OS::strchr (strchr1, ACE_TEXT_WIDE ('h')) + == ACE_TEXT_WIDE ('h')); + ACE_ASSERT (ACE_OS::strchr (strchr1, ACE_TEXT_WIDE ('h')) + == strchr1 + 7); + ACE_ASSERT (ACE_OS::strchr (strchr1, ACE_TEXT_WIDE ('1')) == NULL); // ======================================================================== // Test strstr (wchar_t version) @@ -352,13 +359,13 @@ string_emulation_test (void) const wchar_t *strstr1 = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); - ACE_ASSERT (ACE_OS_String::strncmp ( - ACE_OS_String::strstr (strstr1, ACE_TEXT_WIDE ("def")), + ACE_ASSERT (ACE_OS::strncmp ( + ACE_OS::strstr (strstr1, ACE_TEXT_WIDE ("def")), ACE_TEXT_WIDE ("def"), 3) == 0); - ACE_ASSERT (ACE_OS_String::strstr (strstr1, - ACE_TEXT_WIDE ("mno")) == 0); + ACE_ASSERT (ACE_OS::strstr (strstr1, + ACE_TEXT_WIDE ("mno")) == 0); // ======================================================================== // Test strlen (wchar_t version) @@ -367,8 +374,8 @@ string_emulation_test (void) const wchar_t *strlen1 = ACE_TEXT_WIDE (""); const wchar_t *strlen2 = ACE_TEXT_WIDE ("12345"); - ACE_ASSERT (ACE_OS_String::strlen (strlen1) == 0); - ACE_ASSERT (ACE_OS_String::strlen (strlen2) == 5); + ACE_ASSERT (ACE_OS::strlen (strlen1) == 0); + ACE_ASSERT (ACE_OS::strlen (strlen2) == 5); // ======================================================================== // Test strpbrk (wchar_t version) @@ -376,9 +383,9 @@ string_emulation_test (void) const wchar_t *strpbrk1 = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); - ACE_ASSERT (ACE_OS_String::strpbrk (strpbrk1, ACE_TEXT_WIDE ("ijkb")) + ACE_ASSERT (ACE_OS::strpbrk (strpbrk1, ACE_TEXT_WIDE ("ijkb")) == strpbrk1 + 1); - ACE_ASSERT (ACE_OS_String::strpbrk (strpbrk1, + ACE_ASSERT (ACE_OS::strpbrk (strpbrk1, ACE_TEXT_WIDE ("mno")) == 0); // ======================================================================== @@ -387,11 +394,11 @@ string_emulation_test (void) const wchar_t *strrchr1 = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); - ACE_ASSERT (*ACE_OS_String::strrchr (strrchr1, ACE_TEXT_WIDE ('h')) + ACE_ASSERT (*ACE_OS::strrchr (strrchr1, ACE_TEXT_WIDE ('h')) == ACE_TEXT_WIDE ('h')); - ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, ACE_TEXT_WIDE ('h')) + ACE_ASSERT (ACE_OS::strrchr (strrchr1, ACE_TEXT_WIDE ('h')) == strrchr1 + 18); - ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, ACE_TEXT_WIDE ('1')) + ACE_ASSERT (ACE_OS::strrchr (strrchr1, ACE_TEXT_WIDE ('1')) == NULL); // ======================================================================== @@ -404,11 +411,11 @@ string_emulation_test (void) const wchar_t *strcasecmp4 = ACE_TEXT_WIDE ("STRINGF"); const wchar_t *strcasecmp5 = ACE_TEXT_WIDE ("stringe"); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp1) == 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp2) < 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp3) < 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp4) == 0); - ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp5) > 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp1) == 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp2) < 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp3) < 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp4) == 0); + ACE_ASSERT (ACE_OS::strcasecmp (strcasecmp1, strcasecmp5) > 0); // ======================================================================== // Test strncasecmp (wchar_t version) @@ -421,15 +428,15 @@ string_emulation_test (void) const wchar_t *strncasecmp5 = ACE_TEXT_WIDE ("stringe"); ACE_ASSERT - (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp2, 7) == 0); + (ACE_OS::strncasecmp (strncasecmp1, strncasecmp2, 7) == 0); ACE_ASSERT - (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp2, 8) < 0); + (ACE_OS::strncasecmp (strncasecmp1, strncasecmp2, 8) < 0); ACE_ASSERT - (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp3, 7) < 0); + (ACE_OS::strncasecmp (strncasecmp1, strncasecmp3, 7) < 0); ACE_ASSERT - (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp4, 7) == 0); + (ACE_OS::strncasecmp (strncasecmp1, strncasecmp4, 7) == 0); ACE_ASSERT - (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp5, 7) > 0); + (ACE_OS::strncasecmp (strncasecmp1, strncasecmp5, 7) > 0); // ======================================================================== // Test strncmp (wchar_t version) @@ -441,11 +448,11 @@ string_emulation_test (void) const wchar_t *strncmp4 = ACE_TEXT_WIDE ("STRINGF"); const wchar_t *strncmp5 = ACE_TEXT_WIDE ("stringe"); - ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp2, 7) == 0); - ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp2, 8) < 0); - ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp3, 7) < 0); - ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp4, 7) != 0); - ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp5, 7) > 0); + ACE_ASSERT (ACE_OS::strncmp (strncmp1, strncmp2, 7) == 0); + ACE_ASSERT (ACE_OS::strncmp (strncmp1, strncmp2, 8) < 0); + ACE_ASSERT (ACE_OS::strncmp (strncmp1, strncmp3, 7) < 0); + ACE_ASSERT (ACE_OS::strncmp (strncmp1, strncmp4, 7) != 0); + ACE_ASSERT (ACE_OS::strncmp (strncmp1, strncmp5, 7) > 0); // ======================================================================== // Test strncpy (wchar_t version) @@ -455,34 +462,34 @@ string_emulation_test (void) wchar_t strncpy2[27]; ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strncpy (strncpy2, - strncpy1, - 26), - strncpy1, - 26) == 0); + (ACE_OS::strncmp (ACE_OS::strncpy (strncpy2, + strncpy1, + 26), + strncpy1, + 26) == 0); strncpy1[26] = 0; strncpy2[26] = 0; - ACE_ASSERT (ACE_OS_String::strcmp (strncpy2, strncpy1) == 0); + ACE_ASSERT (ACE_OS::strcmp (strncpy2, strncpy1) == 0); // ======================================================================== // Test strtok (wchar_t version) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strtok (wchar_t version)\n"))); wchar_t strtok_r1[] = ACE_TEXT_WIDE ("A string of tokens"); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok (strtok_r1, - ACE_TEXT_WIDE (" ")), - ACE_TEXT_WIDE ("A")) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok (0, - ACE_TEXT_WIDE (" ")), - ACE_TEXT_WIDE ("string") ) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok (0, - ACE_TEXT_WIDE (" ")), - ACE_TEXT_WIDE ("of") ) == 0); - ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok (0, - ACE_TEXT_WIDE (" ")), - ACE_TEXT_WIDE ("tokens") ) == 0); - ACE_ASSERT (ACE_OS_String::strtok (0, ACE_TEXT_WIDE (" ")) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok (strtok_r1, + ACE_TEXT_WIDE (" ")), + ACE_TEXT_WIDE ("A")) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok (0, + ACE_TEXT_WIDE (" ")), + ACE_TEXT_WIDE ("string") ) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok (0, + ACE_TEXT_WIDE (" ")), + ACE_TEXT_WIDE ("of") ) == 0); + ACE_ASSERT (ACE_OS::strcmp (ACE_OS::strtok (0, + ACE_TEXT_WIDE (" ")), + ACE_TEXT_WIDE ("tokens") ) == 0); + ACE_ASSERT (ACE_OS::strtok (0, ACE_TEXT_WIDE (" ")) == 0); } @@ -529,7 +536,7 @@ ctime_r_test (void) if (result == 0) { ACE_TCHAR bufcheck[27]; - ACE_OS_String::strcpy (bufcheck, buf); + ACE_OS::strcpy (bufcheck, buf); if (ACE_OS::ctime_r (&secs, buf, 10) != 0) { ACE_ERROR ((LM_ERROR, @@ -545,7 +552,7 @@ ctime_r_test (void) result = -1; } // Make sure it didn't scribble - else if (ACE_OS_String::strcmp (buf, bufcheck) != 0) + else if (ACE_OS::strcmp (buf, bufcheck) != 0) { result = -1; ACE_ERROR ((LM_ERROR, @@ -571,60 +578,60 @@ string_strsncpy_test (void) // strsncpy() where the max. length doesn't matter ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 36), - strsncpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 36), + strsncpy1) == 0); // strsncpy() where the max length does matter ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 26), - strsncpy1, - 25) == 0); + (ACE_OS::strncmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 26), + strsncpy1, + 25) == 0); // strsncpy1 and strsncpy2 are different size --> not equal - ACE_ASSERT (ACE_OS_String::strcmp (strsncpy2, strsncpy1) != 0); + ACE_ASSERT (ACE_OS::strcmp (strsncpy2, strsncpy1) != 0); // max. length == 2 --> 1 char available ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 2), - strsncpy1, - 1) == 0); + (ACE_OS::strncmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 2), + strsncpy1, + 1) == 0); // max length == 1 --> empty string ACE_ASSERT - (ACE_OS_String::strlen (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 1)) == 0); + (ACE_OS::strlen (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 1)) == 0); // just preparation for the next assert ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 36), - strsncpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 36), + strsncpy1) == 0); // A tricky one, if the max. length == 0 --> do nothing // so the strsncpy2 shouldn't change ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strsncpy (strsncpy2, - "test", - 0), - strsncpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strsncpy (strsncpy2, + "test", + 0), + strsncpy1) == 0); // If src == dst --> truncate dst if needed! ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy2, - 10), - strsncpy1, - 9) == 0); + (ACE_OS::strncmp (ACE_OS::strsncpy (strsncpy2, + strsncpy2, + 10), + strsncpy1, + 9) == 0); // size should be 9 (+ '\0' char) - ACE_ASSERT(ACE_OS_String::strlen(strsncpy2) == 9); + ACE_ASSERT(ACE_OS::strlen(strsncpy2) == 9); } @@ -639,61 +646,61 @@ string_strsncpy_test (void) // strsncpy() where the max. length doesn't matter ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 36), - strsncpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 36), + strsncpy1) == 0); // strsncpy() where the max length does matter ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 26), - strsncpy1, - 25) == 0); + (ACE_OS::strncmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 26), + strsncpy1, + 25) == 0); // strsncpy1 and strsncpy2 are different size --> not equal - ACE_ASSERT (ACE_OS_String::strcmp (strsncpy2, strsncpy1) != 0); + ACE_ASSERT (ACE_OS::strcmp (strsncpy2, strsncpy1) != 0); // max. length == 2 --> 1 char available ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 2), - strsncpy1, - 1) == 0); + (ACE_OS::strncmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 2), + strsncpy1, + 1) == 0); // max length == 1 --> empty string ACE_ASSERT - (ACE_OS_String::strlen (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 1)) == 0); + (ACE_OS::strlen (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 1)) == 0); // just preparation for the next assert ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy1, - 36), - strsncpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strsncpy (strsncpy2, + strsncpy1, + 36), + strsncpy1) == 0); // A tricky one, if the max. length == 0 --> do nothing // so the strsncpy2 shouldn't change ACE_ASSERT - (ACE_OS_String::strcmp (ACE_OS_String::strsncpy (strsncpy2, - ACE_TEXT_WIDE -("test"), - 0), - strsncpy1) == 0); + (ACE_OS::strcmp (ACE_OS::strsncpy (strsncpy2, + ACE_TEXT_WIDE + ("test"), + 0), + strsncpy1) == 0); // If src == dst --> truncate dst if needed! ACE_ASSERT - (ACE_OS_String::strncmp (ACE_OS_String::strsncpy (strsncpy2, - strsncpy2, - 10), - strsncpy1, - 9) == 0); + (ACE_OS::strncmp (ACE_OS::strsncpy (strsncpy2, + strsncpy2, + 10), + strsncpy1, + 9) == 0); // size should be 9 (+ '\0' char) - ACE_ASSERT(ACE_OS_String::strlen(strsncpy2) == 9); + ACE_ASSERT(ACE_OS::strlen(strsncpy2) == 9); } #endif /* ACE_HAS_WCHAR */ diff --git a/tests/Obstack_Test.cpp b/tests/Obstack_Test.cpp index fde46168f7d..516ff79e83b 100644 --- a/tests/Obstack_Test.cpp +++ b/tests/Obstack_Test.cpp @@ -16,7 +16,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_NS_string.h" #include "ace/Obstack.h" #include "ace/Log_Msg.h" #include "test_config.h" @@ -35,7 +35,7 @@ int run_main (int, ACE_TCHAR *[]) const ACE_TCHAR str2[] = ACE_TEXT ("It's fleece was white as snow; but...."); ACE_Obstack_T<ACE_TCHAR> stack (sizeof (str1) + 1); - for (size_t i = 0; i < ACE_OS_String::strlen (str1); i++) + for (size_t i = 0; i < ACE_OS::strlen (str1); i++) stack.grow_fast (str1[i]); ACE_TCHAR *str = stack.freeze (); @@ -45,7 +45,7 @@ int run_main (int, ACE_TCHAR *[]) ACE_ERROR ((LM_ERROR, ACE_TEXT ("freeze failed!\n"))); ++errors; } - else if (ACE_OS_String::strcmp (str, str1) != 0) + else if (ACE_OS::strcmp (str, str1) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT("Lost first string; expected: %s, have: %s\n"), @@ -53,7 +53,7 @@ int run_main (int, ACE_TCHAR *[]) ++errors; } - for (size_t j = 0; j < ACE_OS_String::strlen (str2); ++j) + for (size_t j = 0; j < ACE_OS::strlen (str2); ++j) stack.grow (str2[j]); ACE_TCHAR* temp = stack.freeze(); @@ -71,7 +71,7 @@ int run_main (int, ACE_TCHAR *[]) ++errors; } - for (size_t k = 0; k < ACE_OS_String::strlen (str1); ++k) + for (size_t k = 0; k < ACE_OS::strlen (str1); ++k) stack.grow (str1[k]); ACE_TCHAR* tmp = stack.freeze (); @@ -80,7 +80,7 @@ int run_main (int, ACE_TCHAR *[]) ACE_ERROR ((LM_ERROR, ACE_TEXT ("freeze failed!\n"))); ++errors; } - else if (ACE_OS_String::strcmp (tmp, str1) != 0) + else if (ACE_OS::strcmp (tmp, str1) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Lost third string; expected: %s, have: %s\n"), @@ -90,7 +90,7 @@ int run_main (int, ACE_TCHAR *[]) stack.unwind (temp); - for (size_t l = 0; l < ACE_OS_String::strlen (str2); ++l) + for (size_t l = 0; l < ACE_OS::strlen (str2); ++l) stack.grow (str2[l]); temp = stack.freeze(); diff --git a/tests/Pipe_Test.cpp b/tests/Pipe_Test.cpp index 188317be335..f1767c1af48 100644 --- a/tests/Pipe_Test.cpp +++ b/tests/Pipe_Test.cpp @@ -21,6 +21,7 @@ #include "ace/Process.h" #include "ace/Get_Opt.h" #include "ace/ACE.h" +#include "ace/OS_NS_stdio.h" ACE_RCSID(tests, Pipe_Test, "$Id$") diff --git a/tests/Priority_Task_Test.cpp b/tests/Priority_Task_Test.cpp index 197c28e8b0e..fe883d27573 100644 --- a/tests/Priority_Task_Test.cpp +++ b/tests/Priority_Task_Test.cpp @@ -21,6 +21,7 @@ #include "test_config.h" #include "ace/Task.h" #include "ace/Sched_Params.h" +#include "ace/OS_NS_errno.h" ACE_RCSID(tests, Priority_Task_Test, "$Id$") diff --git a/tests/Proactor_Test.cpp b/tests/Proactor_Test.cpp index bb42a90d68d..4b1821f191f 100644 --- a/tests/Proactor_Test.cpp +++ b/tests/Proactor_Test.cpp @@ -40,6 +40,8 @@ ACE_RCSID (tests, #include "ace/Asynch_Connector.h" #include "ace/Task.h" #include "ace/Thread_Semaphore.h" +#include "ace/OS_NS_signal.h" +#include "ace/os_include/netinet/os_tcp.h" #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) diff --git a/tests/Process_Mutex_Test.cpp b/tests/Process_Mutex_Test.cpp index 38623975e06..42dbfb82d8a 100644 --- a/tests/Process_Mutex_Test.cpp +++ b/tests/Process_Mutex_Test.cpp @@ -17,11 +17,13 @@ // ============================================================================ #include "test_config.h" -#include "ace/Synch.h" +#include "ace/Mutex.h" #include "ace/Process.h" #include "ace/Process_Mutex.h" #include "ace/Get_Opt.h" #include "ace/ACE.h" +#include "ace/OS_NS_stdio.h" +#include "ace/os_include/os_dirent.h" ACE_RCSID(tests, Process_Mutex_Test, "$Id$") diff --git a/tests/Process_Strategy_Test.cpp b/tests/Process_Strategy_Test.cpp index 80dd3a31f11..d871dce2133 100644 --- a/tests/Process_Strategy_Test.cpp +++ b/tests/Process_Strategy_Test.cpp @@ -197,7 +197,7 @@ Options::parse_args (int argc, ACE_TCHAR *argv[]) ACE_TEXT ("Temporary path too long\n")), -1); - ACE_OS_String::strcat (this->filename_, ACE_TEXT ("process_strategy_test_temp")); + ACE_OS::strcat (this->filename_, ACE_TEXT ("process_strategy_test_temp")); for (int c; (c = get_opt ()) != -1; ) switch (c) diff --git a/tests/RB_Tree_Test.cpp b/tests/RB_Tree_Test.cpp index afdae22f04d..5ca2df7bcc7 100644 --- a/tests/RB_Tree_Test.cpp +++ b/tests/RB_Tree_Test.cpp @@ -29,7 +29,7 @@ #include "test_config.h" /* Include first to enable ACE_ASSERT. */ #include "ace/RB_Tree.h" #include "ace/SString.h" -#include "ace/Synch.h" +#include "ace/Null_Mutex.h" #include "RB_Tree_Test.h" diff --git a/tests/RMCast/Main.cpp b/tests/RMCast/Main.cpp index e80f79ca2c2..44b92128394 100644 --- a/tests/RMCast/Main.cpp +++ b/tests/RMCast/Main.cpp @@ -17,7 +17,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_HAS_WINCE) # include "ace/ACE.h" #endif /* ACE_HAS_WINCE */ diff --git a/tests/RMCast/RMCast_Fragment_Test.cpp b/tests/RMCast/RMCast_Fragment_Test.cpp index 5ff54679a0c..9d04bc72fb7 100644 --- a/tests/RMCast/RMCast_Fragment_Test.cpp +++ b/tests/RMCast/RMCast_Fragment_Test.cpp @@ -15,6 +15,7 @@ #include "ace/Message_Block.h" #include "ace/Task.h" #include "ace/RMCast/RMCast_Fragment.h" +#include "ace/OS_NS_time.h" ACE_RCSID(tests, RMCast_Fragment_Test, "$Id$") diff --git a/tests/RMCast/RMCast_Membership_Test.cpp b/tests/RMCast/RMCast_Membership_Test.cpp index 8e6b716cded..4a34a73c5fd 100644 --- a/tests/RMCast/RMCast_Membership_Test.cpp +++ b/tests/RMCast/RMCast_Membership_Test.cpp @@ -14,7 +14,7 @@ #include "ace/RMCast/RMCast_Proxy.h" #include "ace/RMCast/RMCast_Membership.h" #include "ace/ACE.h" - +#include "ace/OS_NS_time.h" #include "ace/Task.h" ACE_RCSID(tests, RMCast_Membership_Test, "$Id$") diff --git a/tests/RMCast/RMCast_Reassembly_Test.cpp b/tests/RMCast/RMCast_Reassembly_Test.cpp index 1e12fc8af4e..48e49fdd907 100644 --- a/tests/RMCast/RMCast_Reassembly_Test.cpp +++ b/tests/RMCast/RMCast_Reassembly_Test.cpp @@ -14,6 +14,7 @@ #include "ace/Task.h" #include "ace/ACE.h" #include "ace/RMCast/RMCast_Reassembly.h" +#include "ace/OS_NS_time.h" ACE_RCSID(tests, RMCast_Reassembly_Test, "$Id$") diff --git a/tests/RMCast/RMCast_Reordering_Test.cpp b/tests/RMCast/RMCast_Reordering_Test.cpp index e17f8b5cabb..f06ea6477c7 100644 --- a/tests/RMCast/RMCast_Reordering_Test.cpp +++ b/tests/RMCast/RMCast_Reordering_Test.cpp @@ -3,6 +3,7 @@ #include "../test_config.h" #include "ace/RMCast/RMCast_Proxy.h" #include "ace/RMCast/RMCast_Reordering.h" +#include "ace/OS_NS_time.h" #include "ace/Task.h" diff --git a/tests/RMCast/RMCast_Retransmission_Test.cpp b/tests/RMCast/RMCast_Retransmission_Test.cpp index 1fdaaeeb601..f5fc31d5955 100644 --- a/tests/RMCast/RMCast_Retransmission_Test.cpp +++ b/tests/RMCast/RMCast_Retransmission_Test.cpp @@ -3,6 +3,7 @@ #include "../test_config.h" #include "ace/RMCast/RMCast_Proxy.h" #include "ace/RMCast/RMCast_Retransmission.h" +#include "ace/OS_NS_time.h" #include "ace/Task.h" diff --git a/tests/Reactor_Notify_Test.cpp b/tests/Reactor_Notify_Test.cpp index f7bd0c3671e..0136a75f64c 100644 --- a/tests/Reactor_Notify_Test.cpp +++ b/tests/Reactor_Notify_Test.cpp @@ -22,12 +22,13 @@ // ============================================================================ #include "test_config.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" #include "ace/Task.h" #include "ace/Pipe.h" #include "ace/Auto_Ptr.h" #include "ace/Reactor.h" #include "ace/Select_Reactor.h" +#include "ace/Thread_Semaphore.h" ACE_RCSID(tests, Reactor_Notify_Test, "$Id$") diff --git a/tests/Reader_Writer_Test.cpp b/tests/Reader_Writer_Test.cpp index 468bff43479..7e270d646e8 100644 --- a/tests/Reader_Writer_Test.cpp +++ b/tests/Reader_Writer_Test.cpp @@ -24,6 +24,8 @@ #include "ace/Thread_Manager.h" #include "ace/Get_Opt.h" #include "ace/Atomic_Op.h" +#include "ace/OS_NS_unistd.h" +#include "ace/Time_Value.h" ACE_RCSID(tests, Reader_Writer_Test, "$Id$") diff --git a/tests/Reverse_Lock_Test.cpp b/tests/Reverse_Lock_Test.cpp index e69f97ecbd8..7cc83e5e929 100644 --- a/tests/Reverse_Lock_Test.cpp +++ b/tests/Reverse_Lock_Test.cpp @@ -19,7 +19,10 @@ // ============================================================================ #include "test_config.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" +#include "ace/Guard_T.h" +#include "ace/Reverse_Lock_T.h" ACE_RCSID(tests, Reverse_Lock_Test, "$Id$") diff --git a/tests/SOCK_Connector_Test.cpp b/tests/SOCK_Connector_Test.cpp index 45dbac561b0..5f7a5bb1899 100644 --- a/tests/SOCK_Connector_Test.cpp +++ b/tests/SOCK_Connector_Test.cpp @@ -18,10 +18,12 @@ // ========================================================================== #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_string.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Stream.h" +#include "ace/OS_NS_sys_utsname.h" +#include "ace/OS_NS_netdb.h" ACE_RCSID(tests, SOCK_Connector_Test, "SOCK_Connector_Test.cpp,v 4.34 2000/04/23 21:29:17 brunsch Exp") diff --git a/tests/SOCK_Send_Recv_Test.cpp b/tests/SOCK_Send_Recv_Test.cpp index c8aa7b059b8..495dff5a494 100644 --- a/tests/SOCK_Send_Recv_Test.cpp +++ b/tests/SOCK_Send_Recv_Test.cpp @@ -25,7 +25,7 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_sys_wait.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/SOCK_Connector.h" diff --git a/tests/SOCK_Test.cpp b/tests/SOCK_Test.cpp index db2a630a594..bdfa79f2a6a 100644 --- a/tests/SOCK_Test.cpp +++ b/tests/SOCK_Test.cpp @@ -21,7 +21,8 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_sys_wait.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/SOCK_Connector.h" diff --git a/tests/SPIPE_Test.cpp b/tests/SPIPE_Test.cpp index 0f472e9f918..c8ac22b648a 100644 --- a/tests/SPIPE_Test.cpp +++ b/tests/SPIPE_Test.cpp @@ -22,7 +22,6 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/SPIPE_Addr.h" diff --git a/tests/SSL/Main.cpp b/tests/SSL/Main.cpp index e80f79ca2c2..44b92128394 100644 --- a/tests/SSL/Main.cpp +++ b/tests/SSL/Main.cpp @@ -17,7 +17,7 @@ // // ============================================================================ -#include "ace/OS.h" +#include "ace/OS_main.h" #if defined (ACE_HAS_WINCE) # include "ace/ACE.h" #endif /* ACE_HAS_WINCE */ diff --git a/tests/Semaphore_Test.cpp b/tests/Semaphore_Test.cpp index 8e69393b972..3561fac9e7c 100644 --- a/tests/Semaphore_Test.cpp +++ b/tests/Semaphore_Test.cpp @@ -18,10 +18,13 @@ // ============================================================================ #include "test_config.h" -#include "ace/Synch.h" +#include "ace/Thread_Semaphore.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Semaphore_Test, "$Id$") diff --git a/tests/Signal_Test.cpp b/tests/Signal_Test.cpp index f0767e2e608..cbb8298c306 100644 --- a/tests/Signal_Test.cpp +++ b/tests/Signal_Test.cpp @@ -25,6 +25,7 @@ #include "ace/Get_Opt.h" #include "ace/ARGV.h" #include "ace/ACE.h" +#include "ace/OS_NS_signal.h" ACE_RCSID(tests, Signal_Test, "$Id$") diff --git a/tests/Sigset_Ops_Test.cpp b/tests/Sigset_Ops_Test.cpp index 45988cfb6d2..3c6f4439fc0 100644 --- a/tests/Sigset_Ops_Test.cpp +++ b/tests/Sigset_Ops_Test.cpp @@ -19,7 +19,8 @@ // ============================================================================ #include "test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_errno.h" ACE_RCSID(tests, Sigset_Ops_Test, "$Id$") diff --git a/tests/Simple_Message_Block_Test.cpp b/tests/Simple_Message_Block_Test.cpp index 2e727410c38..788ab0fff3e 100644 --- a/tests/Simple_Message_Block_Test.cpp +++ b/tests/Simple_Message_Block_Test.cpp @@ -21,7 +21,10 @@ #include "test_config.h" #include "ace/Message_Block.h" -#include "ace/Synch.h" +#include "ace/Synch_Traits.h" +#include "ace/Lock_Adapter_T.h" +#include "ace/OS_NS_string.h" +#include "ace/Thread_Mutex.h" ACE_RCSID(tests, Simple_Message_Block_Test, "$Id$") diff --git a/tests/TP_Reactor_Test.cpp b/tests/TP_Reactor_Test.cpp index bf47bb328d2..61039f41f14 100644 --- a/tests/TP_Reactor_Test.cpp +++ b/tests/TP_Reactor_Test.cpp @@ -61,6 +61,9 @@ #include "ace/Reactor.h" #include "ace/TP_Reactor.h" +#include "ace/OS_NS_signal.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Semaphore.h" ACE_RCSID(TPReactor, TPReactor_Test, "TPReactor_Test.cpp,v 1.27 2000/03/07 17:15:56 schmidt Exp") @@ -822,7 +825,7 @@ Sender::initiate_write (void) { if ( this->msg_queue ()->message_count () < 20) // flow control { - size_t nbytes = ACE_OS_String::strlen (send_buf_); + size_t nbytes = ACE_OS::strlen (send_buf_); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, diff --git a/tests/TP_Reactor_Test.h b/tests/TP_Reactor_Test.h index db6728c3763..a04a6e5ca1a 100644 --- a/tests/TP_Reactor_Test.h +++ b/tests/TP_Reactor_Test.h @@ -20,7 +20,6 @@ #ifndef ACE_TESTS_TP_REACTOR_TEST_H #define ACE_TESTS_TP_REACTOR_TEST_H -#include "ace/OS.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Connector.h" diff --git a/tests/TSS_Test.cpp b/tests/TSS_Test.cpp index 1515af06be4..2da81d0ab3d 100644 --- a/tests/TSS_Test.cpp +++ b/tests/TSS_Test.cpp @@ -21,7 +21,7 @@ // ============================================================================ #include "test_config.h" -#include "ace/Synch.h" +#include "ace/OS_NS_unistd.h" #include "ace/Thread_Manager.h" #include "ace/Signal.h" #include "TSS_Test_Errno.h" diff --git a/tests/Test_Output.cpp b/tests/Test_Output.cpp index 4c5106d5ae8..f67fbd81549 100644 --- a/tests/Test_Output.cpp +++ b/tests/Test_Output.cpp @@ -17,7 +17,9 @@ // ============================================================================ #include "tests/test_config.h" -#include "ace/OS.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/Guard_T.h" #include "ace/Object_Manager.h" #include "ace/streams.h" #include "ace/Framework_Component.h" diff --git a/tests/Thread_Manager_Test.cpp b/tests/Thread_Manager_Test.cpp index 7bb10bfe411..ba32ecfc487 100644 --- a/tests/Thread_Manager_Test.cpp +++ b/tests/Thread_Manager_Test.cpp @@ -24,6 +24,7 @@ #include "ace/Thread_Manager.h" #include "ace/Signal.h" #include "ace/Task.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Thread_Manager_Test, "$Id$") diff --git a/tests/Thread_Mutex_Test.cpp b/tests/Thread_Mutex_Test.cpp index 79ec0f26399..f40250d6754 100644 --- a/tests/Thread_Mutex_Test.cpp +++ b/tests/Thread_Mutex_Test.cpp @@ -21,6 +21,9 @@ #include "test_config.h" #include "ace/Thread_Manager.h" #include "ace/Process_Mutex.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Thread_Mutex_Test, "$Id$") diff --git a/tests/Thread_Pool_Reactor_Resume_Test.cpp b/tests/Thread_Pool_Reactor_Resume_Test.cpp index 711457aecd7..87ea2e1fee9 100644 --- a/tests/Thread_Pool_Reactor_Resume_Test.cpp +++ b/tests/Thread_Pool_Reactor_Resume_Test.cpp @@ -293,7 +293,7 @@ worker (void *) ACE_OS::sleep (3); const ACE_TCHAR *msg = ACE_TEXT ("Message from Connection worker"); ACE_TCHAR buf [BUFSIZ]; - buf[0] = ACE_static_cast (ACE_TCHAR, (ACE_OS_String::strlen (msg) + 1)); + buf[0] = ACE_static_cast (ACE_TCHAR, (ACE_OS::strlen (msg) + 1)); ACE_OS::strcpy (&buf[1], msg); ACE_INET_Addr addr (rendezvous); diff --git a/tests/Thread_Pool_Reactor_Test.cpp b/tests/Thread_Pool_Reactor_Test.cpp index 4e818b1339e..1aeac44f713 100644 --- a/tests/Thread_Pool_Reactor_Test.cpp +++ b/tests/Thread_Pool_Reactor_Test.cpp @@ -251,7 +251,7 @@ worker (void *) ACE_OS::sleep (3); const ACE_TCHAR *msg = ACE_TEXT ("Message from Connection worker"); ACE_TCHAR buf [BUFSIZ]; - buf[0] = ACE_static_cast (ACE_TCHAR, (ACE_OS_String::strlen (msg) + 1)); + buf[0] = ACE_static_cast (ACE_TCHAR, (ACE_OS::strlen (msg) + 1)); ACE_OS::strcpy (&buf[1], msg); ACE_INET_Addr addr (rendezvous); diff --git a/tests/Thread_Pool_Test.cpp b/tests/Thread_Pool_Test.cpp index d26bce9915c..c5bbd4e4aa0 100644 --- a/tests/Thread_Pool_Test.cpp +++ b/tests/Thread_Pool_Test.cpp @@ -31,6 +31,7 @@ ACE_RCSID(tests, Thread_Pool_Test, "$Id$") #if defined (ACE_HAS_THREADS) #include "ace/Lock_Adapter_T.h" +#include "ace/OS_NS_unistd.h" // Number of iterations to run the test. static size_t n_iterations = 100; diff --git a/tests/Time_Service_Test.cpp b/tests/Time_Service_Test.cpp index e4d1fd4e158..94f02605775 100644 --- a/tests/Time_Service_Test.cpp +++ b/tests/Time_Service_Test.cpp @@ -66,7 +66,7 @@ run_main (int, ACE_TCHAR *[]) } // Add the filename to the end - ACE_OS_String::strcat (backing_store, + ACE_OS::strcat (backing_store, ACE_TEXT ("ace-malloc-XXXXXX")); #endif /* ACE_DEFAULT_BACKING_STORE */ diff --git a/tests/Timeprobe_Test.cpp b/tests/Timeprobe_Test.cpp index 83bb71aa4e6..541d4d06bea 100644 --- a/tests/Timeprobe_Test.cpp +++ b/tests/Timeprobe_Test.cpp @@ -25,6 +25,7 @@ #include "ace/Singleton.h" #include "ace/Synch_Traits.h" #include "ace/Recursive_Thread_Mutex.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Timeprobe_Test, "$Id$") diff --git a/tests/Timer_Queue_Reference_Counting_Test.cpp b/tests/Timer_Queue_Reference_Counting_Test.cpp index 9b4b9cf70e5..52c38bc0df5 100644 --- a/tests/Timer_Queue_Reference_Counting_Test.cpp +++ b/tests/Timer_Queue_Reference_Counting_Test.cpp @@ -27,6 +27,7 @@ #include "ace/Reactor.h" #include "ace/Recursive_Thread_Mutex.h" #include "ace/Null_Mutex.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Timer_Queue_Reference_Counting_Test, "$Id$") diff --git a/tests/Timer_Queue_Test.cpp b/tests/Timer_Queue_Test.cpp index 6ca67a9aafd..0ea7e561998 100644 --- a/tests/Timer_Queue_Test.cpp +++ b/tests/Timer_Queue_Test.cpp @@ -33,6 +33,7 @@ #include "ace/Timer_Queue.h" #include "ace/Recursive_Thread_Mutex.h" #include "ace/Null_Mutex.h" +#include "ace/OS_NS_unistd.h" ACE_RCSID(tests, Timer_Queue_Test, "$Id$") diff --git a/tests/Upgradable_RW_Test.h b/tests/Upgradable_RW_Test.h index cfcee6a0675..41c6c0dba1e 100644 --- a/tests/Upgradable_RW_Test.h +++ b/tests/Upgradable_RW_Test.h @@ -22,7 +22,7 @@ #define ACE_TESTS_UPGRADABLE_RW_TEST_H #include "test_config.h" -#include "ace/Synch.h" +#include "ace/Barrier.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/websvcs/lib/URL_Addr.cpp b/websvcs/lib/URL_Addr.cpp index 43a471075aa..38cd14eb8f0 100644 --- a/websvcs/lib/URL_Addr.cpp +++ b/websvcs/lib/URL_Addr.cpp @@ -6,6 +6,9 @@ #include "URL_Addr.i" #endif /* __ACE_INLINE__ */ +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_stdio.h" + ACE_RCSID(ace, URL_Addr, "$Id$") static ACE_TCHAR http[] = ACE_TEXT ("http:"); diff --git a/websvcs/lib/URL_Addr.i b/websvcs/lib/URL_Addr.i index 89ca74d8b7a..2e3c8ddba89 100644 --- a/websvcs/lib/URL_Addr.i +++ b/websvcs/lib/URL_Addr.i @@ -1,8 +1,9 @@ +// -*- C++ -*- // $Id$ // **************************************************************** -#include "ace/OS.h" +#include "ace/OS_NS_string.h" ACE_INLINE ACE_URL_Addr::ACE_URL_Addr (const ACE_URL_Addr& address) |