summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-17 02:33:12 +0000
committercdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-17 02:33:12 +0000
commit7eb3627f96b862be0a5e8b6dbd635cea69fcd854 (patch)
treeda093e9b3045e2a0656ad7ad5ac16c48d2d30df4
parent0a1f94d39714c171ed34516b0fcd3c074def6168 (diff)
downloadATCD-pSOS.tar.gz
pSOSim portpSOS
-rw-r--r--ace/OS.cpp469
-rw-r--r--ace/OS.h989
-rw-r--r--ace/OS.i807
3 files changed, 1621 insertions, 644 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 37cab7635e2..06f3ad4a4bf 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -19,6 +19,8 @@
#include "ace/Synch_T.h"
#include "ace/Containers.h"
+#include "ace/streams.h"
+
#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
#include "ace/Object_Manager.h"
@@ -84,6 +86,27 @@ ACE_Time_Value::operator FILETIME () const
#endif
+ACE_Cleanup_Info::ACE_Cleanup_Info (void)
+ : object_ (0),
+ cleanup_hook_ (0),
+ param_ (0)
+{
+}
+
+int
+ACE_Cleanup_Info::operator== (const struct 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 struct ACE_Cleanup_Info &o) const
+{
+ return !(*this == o);
+}
+
void
ACE_Time_Value::dump (void) const
{
@@ -179,17 +202,6 @@ ACE_Countdown_Time::~ACE_Countdown_Time (void)
this->stop ();
}
-#if ! defined (ACE_WIN32) && ! defined (ACE_HAS_LONGLONG_T)
-void
-ACE_U_LongLong::output (FILE *file) const
-{
- if (hi_ > 0)
- ACE_OS::fprintf (file, "0x%lx%0*lx", hi_, 2 * sizeof lo_, lo_);
- else
- ACE_OS::fprintf (file, "0x%lx", lo_);
-}
-#endif /* !ACE_WIN32 && ! ACE_HAS_LONGLONG_T */
-
#if defined (ACE_HAS_POWERPC) && defined (ghs)
void
ACE_OS::readPPCTimeBase (u_long &most, u_long &least)
@@ -248,7 +260,12 @@ ACE_OS::uname (struct utsname *name)
char processor[10] = "Unknown";
char subtype[10] = "Unknown";
- switch (sinfo.wProcessorArchitecture)
+#if defined (__BORLANDC__)
+ // Some changes should be made in winbase.h...
+ switch (sinfo.s.wProcessorArchitecture)
+#else
+ switch (sinfo.wProcessorArchitecture)
+#endif /* __BORLAND__ */
{
case PROCESSOR_ARCHITECTURE_INTEL:
ACE_OS::strcpy (processor, "Intel");
@@ -335,51 +352,169 @@ ACE_OS::uname (struct utsname *name)
#endif /* ACE_WIN32 || VXWORKS */
+#if defined (VXWORKS)
struct hostent *
ACE_OS::gethostbyname (const char *name)
{
// ACE_TRACE ("ACE_OS::gethostbyname");
-#if defined (VXWORKS)
+
// not thread safe!
static hostent ret;
- static int first_addr = ::hostGetByName ((char *) name);
+ 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.
+ // 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;
-#elif defined (ACE_HAS_NONCONST_GETBY)
- ACE_SOCKCALL_RETURN (::gethostbyname ((char *) name), struct hostent *, 0);
-#else
- ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
-#endif /* ACE_HAS_NONCONST_GETBY */
}
-#if defined (VXWORKS)
-// not inline because it has the static char array
-char *
-ACE_OS::inet_ntoa (const struct in_addr addr)
+struct hostent *
+ACE_OS::gethostbyaddr (const char *addr, int length, int type)
{
- // ACE_TRACE ("ACE_OS::inet_ntoa");
+ // ACE_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];
- // the following storage is not thread-specific!
- static char buf[32];
- // assumes that addr is already in network byte order
- ACE_OS::sprintf (buf, "%d.%d.%d.%d", addr.s_addr / (256*256*256) & 255,
- addr.s_addr / (256*256) & 255,
- addr.s_addr / 256 & 255,
- addr.s_addr & 255);
- return buf;
+ 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_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_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 */
@@ -762,11 +897,6 @@ ACE_thread_t ACE_OS::NULL_thread;
ACE_hthread_t ACE_OS::NULL_hthread;
ACE_thread_key_t ACE_OS::NULL_key;
-ACE_OS::ACE_OS (void)
-{
-// ACE_TRACE ("ACE_OS::ACE_OS");
-}
-
#if defined (ACE_WIN32)
// = Static initialization.
@@ -976,9 +1106,9 @@ private:
enum
{
-#if defined (ACE_HAS_64BIT_LONGS)
+#if ACE_SIZEOF_LONG == 8
ACE_BITS_PER_WORD = 64,
-#elif ULONG_MAX == 4294967295UL
+#elif ACE_SIZEOF_LONG == 4
ACE_BITS_PER_WORD = 32,
#else
#error ACE_TSS_Keys only supports 32 or 64 bit longs.
@@ -1442,19 +1572,20 @@ template class ACE_TSS<ACE_TSS_Keys>;
void
ACE_OS::cleanup_tss (const u_int main_thread)
{
-#if defined (ACE_HAS_TSS_EMULATION)
+#if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
// Call TSS destructors for current thread.
ACE_TSS_Cleanup::instance ()->exit (0);
-#endif /* ACE_HAS_TSS_EMULATION */
+#endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */
if (main_thread)
{
-#if !defined (ACE_HAS_TSS_EMULATION)
- // 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.
+#if ! defined (ACE_HAS_TSS_EMULATION)
+ // 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_Log_Msg::close ();
-#endif /* ! ACE_HAS_TSS_EMULATION */
+#endif /* ! ACE_HAS_TSS_EMULATION || ACE_WIN32 */
#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
// Remove all TSS_Info table entries.
@@ -1464,10 +1595,6 @@ ACE_OS::cleanup_tss (const u_int main_thread)
delete ACE_TSS_Cleanup::instance ();
#endif /* WIN32 || ACE_HAS_TSS_EMULATION */
}
-#if defined (ACE_WIN32)
- else
- ACE_TSS_Cleanup::instance ()->exit (0);
-#endif /* ACE_WIN32 */
}
void
@@ -1517,6 +1644,9 @@ ACE_Thread_Adapter::invoke (void)
void *status = 0;
+#if 0
+ status = (void*) (*func) (arg); // Call thread entry point.
+#else
ACE_SEH_TRY {
status = (void*) (*func) (arg); // Call thread entry point.
}
@@ -1527,6 +1657,7 @@ ACE_Thread_Adapter::invoke (void)
// so that we can make sure to clean up correctly when the thread
// exits.
}
+#endif /* 0 */
// Call the Task->close () hook.
if (func == (ACE_THR_FUNC) ACE_Task_Base::svc_run)
@@ -1700,13 +1831,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
// being we are all non-super actors. Should be fixed to take care
// of super actors!!!
if (stacksize == 0)
- stacksize = 2 * ACE_OS::sysconf (_SC_PTHREAD_STACK_MIN);
- else
- {
- size_t _s = 2 * ACE_OS::sysconf (_SC_PTHREAD_STACK_MIN);
- if (stacksize < _s)
- stacksize = _s;
- }
+ 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 (stacksize != 0)
@@ -2207,7 +2334,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
}
# if 0
*thr_handle = ::CreateThread
- (0,
+ (0,
stacksize,
LPTHREAD_START_ROUTINE (ACE_THREAD_FUNCTION),
ACE_THREAD_ARGUMENT,
@@ -2413,7 +2540,11 @@ ACE_OS::thr_keycreate (ACE_thread_key_t *key,
}
# elif defined (ACE_HAS_DCETHREADS)
ACE_UNUSED_ARG (inst);
- ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1);
+# if defined (ACE_HAS_STDARG_THR_DEST)
+ ACE_OSCALL_RETURN (::pthread_keycreate (key, (void (*)(...)) dest), int, -1);
+# else
+ ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1);
+# endif /* ACE_HAS_STDARG_THR_DEST */
# elif defined (ACE_HAS_PTHREADS)
ACE_UNUSED_ARG (inst);
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest),
@@ -2891,18 +3022,19 @@ ACE_Thread_ID::operator!= (const ACE_Thread_ID &rhs)
int
ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
{
- long ip_addr = ACE_OS::inet_addr (host_name);
- if (ip_addr == (long) htonl ((ACE_UINT32) ~0)
+ ACE_UINT32 ip_addr = ACE_OS::inet_addr (host_name);
+
+ if (ip_addr == (ACE_UINT32) htonl ((ACE_UINT32) ~0)
// Broadcast addresses are weird...
&& ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
return 0;
- else if (addr != 0)
+ else if (addr == 0)
+ return 0;
+ else
{
ACE_OS::memcpy ((void *) addr, (void *) &ip_addr, sizeof ip_addr);
return 1;
}
- else
- return 1;
}
ssize_t
@@ -2934,7 +3066,7 @@ ACE_OS::pread (ACE_HANDLE handle,
#else
return ::pread (handle, buf, nbytes, offset);
#endif /* ACE_WIN32 */
-#elif defined (ACE_HAS_THREADS)
+#else
ACE_MT (ACE_Thread_Mutex *ace_os_monitor_lock =
ACE_Managed_Object<ACE_Thread_Mutex>::get_preallocated_object
(ACE_Object_Manager::ACE_OS_MONITOR_LOCK);
@@ -2944,12 +3076,6 @@ ACE_OS::pread (ACE_HANDLE handle,
return -1;
else
return ACE_OS::read (handle, buf, nbytes);
-#else
- ACE_UNUSED_ARG (handle);
- ACE_UNUSED_ARG (buf);
- ACE_UNUSED_ARG (nbytes);
- ACE_UNUSED_ARG (offset);
- ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAD_P_READ_WRITE */
}
@@ -2982,7 +3108,7 @@ ACE_OS::pwrite (ACE_HANDLE handle,
#else
return ::pwrite (handle, buf, nbytes, offset);
#endif /* ACE_WIN32 */
-#elif defined (ACE_HAS_THREADS)
+#else
ACE_MT (ACE_Thread_Mutex *ace_os_monitor_lock =
ACE_Managed_Object<ACE_Thread_Mutex>::get_preallocated_object
(ACE_Object_Manager::ACE_OS_MONITOR_LOCK);
@@ -2992,12 +3118,6 @@ ACE_OS::pwrite (ACE_HANDLE handle,
return -1;
else
return ACE_OS::write (handle, buf, nbytes);
-#else
- ACE_UNUSED_ARG (handle);
- ACE_UNUSED_ARG (buf);
- ACE_UNUSED_ARG (nbytes);
- ACE_UNUSED_ARG (offset);
- ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAD_P_READ_WRITE */
}
@@ -3079,6 +3199,197 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw,
}
#endif /* ! ACE_HAS_THREADS || ! ACE_HAS_STHREADS */
+#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 ()
+ : 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 ()
+{
+ 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)
+
+ACE_INLINE 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
+
+ACE_INLINE u_long
+ACE_PSOS_Time_t::set_system_time (const ACE_PSOS_Time_t& t)
+{
+ u_long ret_val = tm_set (t.date_, t.time_, t.ticks_);
+ return ret_val;
+}
+ // static member function to set current system time
+
+#if defined (ACE_PSOSIM)
+
+ACE_INLINE u_long
+ACE_PSOS_Time_t::init_simulator_time ()
+{
+ // 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 */
+
#if defined (CHORUS)
extern "C"
void
diff --git a/ace/OS.h b/ace/OS.h
index 48daef7a534..3da485d6f97 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -20,7 +20,20 @@
// This file should be a link to the platform/compiler-specific
// configuration file (e.g., config-sunos5-sunc++-4.x.h).
-#include "ace/config.h"
+#include "ace/inc_user_config.h"
+
+
+#if defined (ACE_HAS_ANSI_CASTS)
+# define ACE_static_cast(TYPE, EXPR) static_cast<TYPE> (EXPR)
+# define ACE_const_cast(TYPE, EXPR) const_cast<TYPE> (EXPR)
+# define ACE_reinterpret_cast(TYPE, EXPR) reinterpret_cast<TYPE> (EXPR)
+# define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast<TYPE> (EXPR)
+#else
+# define ACE_static_cast(TYPE, EXPR) (TYPE) (EXPR)
+# define ACE_const_cast(TYPE, EXPR) (TYPE) (EXPR)
+# define ACE_reinterpret_cast(TYPE, EXPR) (TYPE) (EXPR)
+# define ACE_dynamic_cast(TYPE, EXPR) (TYPE) (EXPR)
+#endif /* ACE_HAS_ANSI_CASTS */
// Deal with MSVC++ insanity for CORBA...
#if defined (ACE_WIN32) && !defined (ACE_ORBIX_HAS_NAMESPACES)
@@ -46,6 +59,10 @@
# undef __ACE_INLINE__
#endif /* ! ACE_NO_INLINE */
+#if !defined (ACE_DEFAULT_CLOSE_ALL_HANDLES)
+#define ACE_DEFAULT_CLOSE_ALL_HANDLES 1
+#endif /* ACE_DEFAULT_CLOSE_ALL_HANDLES */
+
// The maximum length for a fully qualified Internet name.
#if !defined(ACE_MAX_FULLY_QUALIFIED_NAME_LEN)
#define ACE_MAX_FULLY_QUALIFIED_NAME_LEN 256
@@ -195,10 +212,17 @@
#endif /* ACE_LACKS_FIFO */
#endif /* ACE_DEFAULT_RENDEZVOUS */
-// The default starting port number for TAO servers.
-#if !defined (TAO_DEFAULT_SERVER_PORT)
-#define TAO_DEFAULT_SERVER_PORT 10013
-#endif /* TAO_DEFAULT_SERVER_PORT */
+#if !defined (ACE_DEFAULT_LOGGER_KEY)
+#if defined (ACE_WIN32)
+#define ACE_DEFAULT_LOGGER_KEY __TEXT ("\\temp\\server_daemon")
+#else
+#if defined (ACE_HAS_STREAM_PIPES)
+#define ACE_DEFAULT_LOGGER_KEY "/tmp/server_daemon"
+#else
+#define ACE_DEFAULT_LOGGER_KEY "localhost:10013"
+#endif /* ACE_HAS_STREAM_PIPES */
+#endif /* ACE_WIN32 */
+#endif /* ACE_DEFAULT_LOGGER_KEY */
#if !defined (ACE_DEFAULT_SERVER_HOST)
#define ACE_DEFAULT_SERVER_HOST "localhost"
@@ -342,6 +366,7 @@ private:
#endif /* ACE_WIN32 */
// Increase the range of "address families".
+#define AF_ANY (-1)
#define AF_SPIPE (AF_MAX + 1)
#define AF_FILE (AF_MAX + 2)
#define AF_DEV (AF_MAX + 3)
@@ -386,8 +411,8 @@ private:
#endif
#if defined (ACE_REQUIRES_FUNC_DEFINITIONS)
- // Provide a null definition for the function. Not pleasant.
-# define ACE_UNIMPLEMENTED_FUNC(f) f {}
+// It just evaporated ;-) Not pleasant.
+# define ACE_UNIMPLEMENTED_FUNC(f)
#else
# define ACE_UNIMPLEMENTED_FUNC(f) f;
#endif /* ACE_REQUIRES_FUNC_DEFINITIONS */
@@ -396,8 +421,8 @@ private:
// Insures that g++ "friendship" anamolies are properly handled.
#define ACE_CLASS_IS_NAMESPACE(CLASSNAME) \
private: \
-ACE_UNIMPLEMENTED_FUNC (CLASSNAME (void)) \
-ACE_UNIMPLEMENTED_FUNC (CLASSNAME (const CLASSNAME&)) \
+CLASSNAME (void); \
+CLASSNAME (const CLASSNAME&); \
friend class ace_dewarn_gplusplus
// These hooks enable ACE to have all dynamic memory management
@@ -450,6 +475,336 @@ typedef int key_t;
// //
///////////////////////////////////////////
+#if defined (ACE_PSOS)
+
+ #include <ace/sys_conf.h> /* system configuration file */
+ #include <psos.h> /* pSOS+ system calls */
+ #include <pna.h> /* pNA+ TCP/IP Network Manager calls */
+
+
+ #if defined (ACE_PSOSIM)
+
+ /* In the *simulator* environment, use unsigned int for size_t */
+ #define size_t unsigned int
+
+// #include <prepc.h> /* pREPC+ ANSI C Standard Library calls */
+
+ /* #include <rpc.h> pRPC+ Remote Procedure Call Library calls */
+ /* are not supported by pSOSim */
+ /* */
+ /* #include <phile.h> pHILE+ file system calls are not supported */
+ /* by pSOSim *so*, for the time being, we make */
+ /* use of UNIX file system headers and then */
+ /* when we have time, we wrap UNIX file system */
+ /* calls w/ pHILE+ wrappers, and modify ACE to */
+ /* use the wrappers under pSOSim */
+
+ /* put includes for necessary UNIX file system calls here */
+ #include <sys/stat.h>
+ #include <sys/ioctl.h>
+ #include <sys/sockio.h>
+ #include <netinet/tcp.h>
+
+ // remap missing error numbers for system functions
+ #define EPERM 1 /* Not super-user */
+ #define ENOENT 2 /* No such file or directory */
+ #define ESRCH 3 /* No such process */
+ #define EINTR 4 /* interrupted system call */
+ #define EBADF 9 /* Bad file number */
+ #define EAGAIN 11 /* Resource temporarily unavailable */
+ #define EWOULDBLOCK EAGAIN /* Blocking resource request would block */
+ #define ENOMEM 12 /* Not enough core */
+ #define EACCES 13 /* Permission denied */
+ #define EEXIST 17 /* File exists */
+ #define ENOSPC 28 /* No space left on device */
+ #define EPIPE 32 /* Broken pipe */
+ #define ETIME 62 /* timer expired */
+ #define ENAMETOOLONG 78 /* path name is too long */
+ #define ENOSYS 89 /* Unsupported file system operation */
+ #define EADDRINUSE 125 /* Address already in use */
+ #define ENETUNREACH 128 /* Network is unreachable */
+ #define EISCONN 133 /* Socket is already connected */
+ #define ESHUTDOWN 143 /* Can't send after socket shutdown */
+ #define ECONNREFUSED 146 /* Connection refused */
+ #define EINPROGRESS 150 /* operation now in progress */
+ #define ERRMAX 151 /* Last error number */
+
+ #define TCP_
+ #if ! defined (BUFSIZ)
+ #define BUFSIZ 1024
+ #endif /* ! defined (BUFSIZ) */
+
+
+ #else
+
+ #include <rpc.h> /* pRPC+ Remote Procedure Call Library calls */
+ #include <phile.h> /* pHILE+ file system calls */
+
+
+ #endif /* defined (ACE_PSOSIM) */
+
+
+
+
+// For general purpose portability
+
+// Use pSOS semaphores, wrapped . . .
+typedef struct
+{
+ u_long sema_;
+ // Semaphore handle. This is allocated by pSOS.
+
+ char name_[4];
+ // Name of the semaphore: really a 32 bit number to pSOS
+} ACE_sema_t;
+
+// Used for ACE_MMAP_Memory_Pool
+#if !defined (ACE_DEFAULT_BACKING_STORE)
+#define ACE_DEFAULT_BACKING_STORE "/tmp/ace-malloc-XXXXXX"
+#endif /* ACE_DEFAULT_BACKING_STORE */
+
+// Used for logging
+#if !defined (ACE_DEFAULT_LOGFILE)
+#define ACE_DEFAULT_LOGFILE "/tmp/logfile"
+#endif /* ACE_DEFAULT_LOGFILE */
+
+// Used for dynamic linking.
+#if !defined (ACE_DEFAULT_SVC_CONF)
+#define ACE_DEFAULT_SVC_CONF "./svc.conf"
+#endif /* ACE_DEFAULT_SVC_CONF */
+
+#if !defined (ACE_DEFAULT_SEM_KEY)
+#define ACE_DEFAULT_SEM_KEY "ACE_SEM_KEY"
+#endif /* ACE_DEFAULT_SEM_KEY */
+
+#define ACE_STDIN 0
+#define ACE_STDOUT 1
+#define ACE_STDERR 2
+
+#define ACE_DIRECTORY_SEPARATOR_STR_A "/"
+#define ACE_DIRECTORY_SEPARATOR_CHAR_A '/'
+
+#define ACE_DLL_SUFFIX ".so"
+#define ACE_DLL_PREFIX "lib"
+#define ACE_LD_SEARCH_PATH "LD_LIBRARY_PATH"
+#define ACE_LD_SEARCH_PATH_SEPARATOR_STR ":"
+#define ACE_LOGGER_KEY "/tmp/server_daemon"
+
+#define ACE_PLATFORM_A "pSOS"
+#define ACE_PLATFORM_EXE_SUFFIX_A ""
+
+#if defined (ACE_HAS_UNICODE)
+#define ACE_DIRECTORY_SEPARATOR_STR_W L"/"
+#define ACE_DIRECTORY_SEPARATOR_CHAR_W L'/'
+#define ACE_PLATFORM_W L"pSOS"
+#define ACE_PLATFORM_EXE_SUFFIX_W L""
+#else
+#define ACE_DIRECTORY_SEPARATOR_STR_W "/"
+#define ACE_DIRECTORY_SEPARATOR_CHAR_W '/'
+#define ACE_PLATFORM_W "pSOS"
+#define ACE_PLATFORM_EXE_SUFFIX_W ""
+#endif /* ACE_HAS_UNICODE */
+
+
+#define ACE_MAX_DEFAULT_PORT 65535
+
+#if ! defined(MAXPATHLEN)
+#define MAXPATHLEN 1024
+#endif /* MAXPATHLEN */
+
+#if ! defined(MAXNAMLEN)
+#define MAXNAMLEN 255
+#endif /* MAXNAMLEN */
+
+#if ! defined(MAXHOSTNAMELEN)
+#define MAXHOSTNAMELEN 256
+#endif /* MAXHOSTNAMELEN */
+
+#if defined (ACE_LACKS_MMAP)
+#define PROT_READ 0
+#define PROT_WRITE 0
+#define PROT_EXEC 0
+#define PROT_NONE 0
+#define PROT_RDWR 0
+#define MAP_PRIVATE 0
+#define MAP_SHARED 0
+#define MAP_FIXED 0
+#endif /* ACE_LACKS_MMAP */
+
+// The following 3 defines are used by the ACE Name Server...
+#if !defined (ACE_DEFAULT_NAMESPACE_DIR_A)
+#define ACE_DEFAULT_NAMESPACE_DIR_A "/tmp"
+#endif /* ACE_DEFAULT_NAMESPACE_DIR_A */
+
+#if !defined (ACE_DEFAULT_LOCALNAME_A)
+#define ACE_DEFAULT_LOCALNAME_A "/localnames"
+#endif /* ACE_DEFAULT_LOCALNAME_A */
+
+#if !defined (ACE_DEFAULT_GLOBALNAME_A)
+#define ACE_DEFAULT_GLOBALNAME_A "/globalnames"
+#endif /* ACE_DEFAULT_GLOBALNAME_A */
+
+#if defined (ACE_HAS_UNICODE)
+#if !defined (ACE_DEFAULT_NAMESPACE_DIR_W)
+#define ACE_DEFAULT_NAMESPACE_DIR_W L"/tmp"
+#endif /* ACE_DEFAULT_NAMESPACE_DIR_W */
+#if !defined (ACE_DEFAULT_LOCALNAME_W)
+#define ACE_DEFAULT_LOCALNAME_W L"/localnames"
+#endif /* ACE_DEFAULT_LOCALNAME_W */
+#if !defined (ACE_DEFAULT_GLOBALNAME_W)
+#define ACE_DEFAULT_GLOBALNAME_W L"/globalnames"
+#endif /* ACE_DEFAULT_GLOBALNAME_W */
+#else
+#if !defined (ACE_DEFAULT_NAMESPACE_DIR_W)
+#define ACE_DEFAULT_NAMESPACE_DIR_W "/tmp"
+#endif /* ACE_DEFAULT_NAMESPACE_DIR_W */
+#if !defined (ACE_DEFAULT_LOCALNAME_W)
+#define ACE_DEFAULT_LOCALNAME_W "/localnames"
+#endif /* ACE_DEFAULT_LOCALNAME_W */
+#if !defined (ACE_DEFAULT_GLOBALNAME_W)
+#define ACE_DEFAULT_GLOBALNAME_W "/globalnames"
+#endif /* ACE_DEFAULT_GLOBALNAME_W */
+#endif /* ACE_HAS_UNICODE */
+
+#if !defined (__TEXT)
+#if (defined (ACE_HAS_UNICODE) && (defined (UNICODE)))
+#define __TEXT(STRING) L##STRING
+#else
+#define __TEXT(STRING) STRING
+#endif /* UNICODE && ACE_HAS_UNICODE */
+#endif /* !defined __TEXT */
+
+typedef int ACE_HANDLE;
+typedef ACE_HANDLE ACE_SOCKET;
+#define ACE_INVALID_HANDLE -1
+
+typedef ACE_HANDLE ACE_SHLIB_HANDLE;
+const int ACE_DEFAULT_SHLIB_MODE = 0;
+
+#define ACE_INVALID_SEM_KEY -1
+
+struct hostent {
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
+ int h_addrtype; /* host address type */
+ int h_length; /* address length */
+ char **h_addr_list; /* (first, only) address from name server */
+#define h_addr h_addr_list[0] /* the first address */
+};
+
+struct servent {
+ char *s_name; /* official service name */
+ char **s_aliases; /* alias list */
+ int s_port; /* port # */
+ char *s_proto; /* protocol to use */
+};
+
+// For Win32 compatibility.
+
+typedef const char *LPCTSTR;
+typedef char *LPTSTR;
+typedef char TCHAR;
+
+#define ACE_SEH_TRY if (1)
+#define ACE_SEH_EXCEPT(X) while (0)
+#define ACE_SEH_FINALLY while (0)
+
+#if !defined (LPSECURITY_ATTRIBUTES)
+#define LPSECURITY_ATTRIBUTES int
+#endif /* !defined LPSECURITY_ATTRIBUTES */
+#if !defined (GENERIC_READ)
+#define GENERIC_READ 0
+#endif /* !defined GENERIC_READ */
+#if !defined (FILE_SHARE_READ)
+#define FILE_SHARE_READ 0
+#endif /* !defined FILE_SHARE_READ */
+#if !defined (OPEN_EXISTING)
+#define OPEN_EXISTING 0
+#endif /* !defined OPEN_EXISTING */
+#if !defined (FILE_ATTRIBUTE_NORMAL)
+#define FILE_ATTRIBUTE_NORMAL 0
+#endif /* !defined FILE_ATTRIBUTE_NORMAL */
+#if !defined (MAXIMUM_WAIT_OBJECTS)
+#define MAXIMUM_WAIT_OBJECTS 0
+#endif /* !defined MAXIMUM_WAIT_OBJECTS */
+#if !defined (FILE_FLAG_OVERLAPPED)
+#define FILE_FLAG_OVERLAPPED 0
+#endif /* !defined FILE_FLAG_OVERLAPPED */
+
+struct ACE_OVERLAPPED
+{
+ u_long Internal;
+ u_long InternalHigh;
+ u_long Offset;
+ u_long OffsetHigh;
+ ACE_HANDLE hEvent;
+};
+
+// Use pSOS time, wrapped . . .
+class ACE_PSOS_Time_t
+{
+public:
+
+ ACE_PSOS_Time_t ();
+ // default ctor: date, time, and ticks all zeroed
+
+ ACE_PSOS_Time_t (const timespec_t& t);
+ // ctor from a timespec_t
+
+ operator timespec_t ();
+ // type cast operator (to a timespec_t)
+
+ static u_long get_system_time (ACE_PSOS_Time_t& t);
+ // static member function to get current system time
+
+ static u_long set_system_time (const ACE_PSOS_Time_t& t);
+ // static member function to set current system time
+
+#if defined (ACE_PSOSIM)
+
+ static u_long init_simulator_time ();
+ // static member function to initialize system time, using UNIX calls
+
+#endif /* ACE_PSOSIM */
+
+ static const u_long max_ticks;
+ // max number of ticks supported in a single system call
+
+private:
+
+ // constants for prying info out of the pSOS time encoding
+ static const u_long year_mask;
+ static const u_long month_mask;
+ static const u_long day_mask;
+ static const u_long hour_mask;
+ static const u_long minute_mask;
+ static const u_long second_mask;
+ static const int year_shift;
+ static const int month_shift;
+ static const int hour_shift;
+ static const int minute_shift;
+ static const int year_origin;
+ static const int month_origin;
+
+ // error codes
+ static const u_long err_notime; // system time not set
+ static const u_long err_illdate; // date out of range
+ static const u_long err_illtime; // time out of range
+ static const u_long err_illticks; // ticks out of range
+
+ u_long date_;
+ // date : year in bits 31-16, month in bits 15-8, day in bits 7-0
+
+ u_long time_;
+ // time : hour in bits 31-16, minutes in bits 15-8, seconds in bits 7-0
+
+ u_long ticks_;
+ // ticks: number of system clock ticks (KC_TICKS2SEC-1 max)
+} ;
+
+#endif /* defined (ACE_PSOS) */
+
+
#if defined (ACE_HAS_CHARPTR_SPRINTF)
#define ACE_SPRINTF_ADAPTER(X) ::strlen (X)
@@ -483,66 +838,65 @@ typedef int key_t;
// use these macros so that we don't end up with ACE software
// hard-coded to Microsoft proprietary extensions to C++.
+// First, we define how to properly export/import objects.
+#if defined (ACE_WIN32) // Only Win32 needs special treatment.
+# if !defined (_MSC_VER) /* Mark classes as exported, Borland. */
+# define ACE_Proper_Export_Flag _export
+# define ACE_Proper_Import_Flag _import
+// @@ Don't know how to handle this when using Borland's compilers.
+# define ACE_EXPORT_SINGLETON_DECLARATION(T)
+# define ACE_IMPORT_SINGLETON_DECLARATION(T)
+# define ACE_PROPER_SINGLETON_INSTANTIATION(T)
+# else /* Microsoft: */
+# define ACE_Proper_Export_Flag __declspec (dllexport)
+# define ACE_Proper_Import_Flag __declspec (dllimport)
+# define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T
+# define ACE_IMPORT_SINGLETON_DECLARATION(T) extern template class T
+# define ACE_PROPER_SINGLETON_INSTANTIATION(T) template class T
+# endif /* !_MSC_VER */
+#else /* ! ACE_WIN32 */
+# define ACE_Proper_Export_Flag
+# define ACE_Proper_Import_Flag
+# define ACE_EXPORT_SINGLETON_DECLARATION(T)
+# define ACE_IMPORT_SINGLETON_DECLARATION(T)
+# define ACE_PROPER_SINGLETONE_INSTANTIATION(T)
+#endif /* ACE_WIN32 */
+
+// Here are definition for ACE library.
#if defined (ACE_HAS_DLL) && (ACE_HAS_DLL == 1)
# if defined (ACE_BUILD_DLL)
-# if !defined (_MSC_VER) /* Mark classes as exported, Borland. */
-# define ACE_Export _export
-// @@ Don't know how to handle this when using Borland's compilers.
-# define ACE_SINGLETON_DECLARATION (T)
-# define ACE_SINGLETON_INSTANTIATION (T)
-# else /* Microsoft: */
-# define ACE_Export __declspec (dllexport)
-# define ACE_SINGLETON_DECLATATION (T) template class ACE_Export T
-# define ACE_SINGLETON_INSTANTIATION (T) template class T
-# endif /* !_MSC_VER */
-# else /* Using the DLL. */
-# define ACE_SINGLETON_INSTANTIATION (T)
-# if !defined _MSC_VER
-# define ACE_Export _import
-// @@ Don't know how to handle this when using Borland's compilers.
-# define ACE_SINGLETON_DECLARATION (T)
-# else
-# define ACE_Export __declspec (dllimport)
-# define ACE_SINGLETON_DECLARATION (T) extern template class T
-# endif /* !_MSC_VER */
+# define ACE_Export ACE_Proper_Export_Flag
+# define ACE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACE_SINGLETON_INSTANTIATION(T) ACE_PROPER_SINGLETON_INSTANTIATION (T)
+# else
+# define ACE_Export ACE_Proper_Import_Flag
+# define ACE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACE_SINGLETON_INSTANTIATION(T)
# endif /* ACE_BUILD_DLL */
-
-#else /* We're not building a DLL! */
+#else /* ! ACE_HAS_DLL */
# define ACE_Export
-# define ACE_SINGLETON_DECLARATION (T)
-# define ACE_SINGLETON_INSTANTIATION (T)
+# define ACE_SINGLETON_DECLARATION(T)
+# define ACE_SINGLETON_INSTANTIATION(T)
#endif /* ACE_HAS_DLL */
+// Here are definition for ACE_Svc library.
#if defined (ACE_HAS_SVC_DLL) && (ACE_HAS_SVC_DLL == 1)
# if defined (ACE_BUILD_SVC_DLL)
-# if !defined (_MSC_VER) /* Mark classes as exported, Borland. */
-# define ACE_Svc_Export _export
-// @@ Don't know how to handle this when using Borland's compilers.
-# define ACE_SVC_SINGLETON_DECLARATION (T)
-# define ACE_SVC_SINGLETON_INSTANTIATION (T)
-# else /* Microsoft: */
-# define ACE_Svc_Export __declspec (dllexport)
-# define ACE_SVC_SINGLETON_DECLARATION (T) template class ACE_Svc_Export T
-# define ACE_SVC_SINGLETON_INSTANTIATION (T) template class T
-# endif /* !_MSC_VER */
-# else /* Using the DLL. */
-# define ACE_SVC_SINGLETON_INSTANTIATION (T)
-# if !defined _MSC_VER
-# define ACE_Svc_Export _import
-// @@ Don't know how to handle this when using Borland's compilers.
-# define ACE_SVC_SINGLETON_DECLARATION (T)
-# else
-# define ACE_Svc_Export __declspec (dllimport)
-# define ACE_SVC_SINGLETON_DECLARATION (T) extern template class T
-# endif /* !_MSC_VER */
-# endif /* ACE_BUILD_DLL || ACE_BUILD_SVC_DLL */
-
-#else /* We're not building a DLL! */
+# define ACE_Svc_Export ACE_Proper_Export_Flag
+# define ACE_SVC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACE_SVC_SINGLETON_INSTANTIATION(T) ACE_PROPER_SINGLETON_INSTANTIATION (T)
+# else
+# define ACE_Svc_Export ACE_Proper_Import_Flag
+# define ACE_SVC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACE_SVC_SINGLETON_INSTANTIATION(T)
+# endif /* ACE_BUILD_SVC_DLL */
+#else /* ACE_HAS_SVC_DLL */
# define ACE_Svc_Export
-# define ACE_SVC_SINGLETON_DECLARATION (T)
-# define ACE_SVC_SINGLETON_INSTANTIATION (T)
+# define ACE_SVC_SINGLETON_DECLARATION(T)
+# define ACE_SVC_SINGLETON_INSTANTIATION(T)
#endif /* ACE_HAS_SVC_DLL */
+
// This needs to go here *first* to avoid problems with AIX.
// Just to be safe we'll do it with pthreads, too -- jwr
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
@@ -562,6 +916,7 @@ extern "C" pthread_t pthread_self (void);
#endif /* ACE_NTRACE */
#include /**/ <time.h>
+
#if defined (ACE_NEEDS_SYSTIME_H)
// Some platforms may need to include this, but I suspect that most
// will get it from <time.h>
@@ -797,8 +1152,8 @@ private:
#if defined (ACE_HAS_TEMPLATE_TYPEDEFS)
// Handle ACE_Message_Queue.
-#define ACE_SYNCH_1 class _ACE_SYNCH
-#define ACE_SYNCH_2 _ACE_SYNCH
+#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
@@ -886,11 +1241,11 @@ private:
// Handle ACE_Message_Queue.
#if defined (ACE_HAS_OPTIMIZED_MESSAGE_QUEUE)
-#define ACE_SYNCH_1 class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T, class _ACE_SYNCH_SEMAPHORE_T
-#define ACE_SYNCH_2 _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T, _ACE_SYNCH_SEMAPHORE_T
+#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_1 class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T
-#define ACE_SYNCH_2 _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T
+#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
@@ -975,11 +1330,16 @@ public:\
};\
static ACE_Static_Svc_##X ace_static_svc_##X;
+
+// More generic dynamic/static service macros.
+#define ACE_FACTORY_DECLARE(CLS,X) extern "C" CLS##_Export ACE_Service_Object *_make_##X (void);
+#define ACE_FACTORY_DEFINE(CLS,X) extern "C" ACE_Service_Object *_make_##X () { ACE_TRACE (#X); return new X; }
+
// Dynamic/static service macros.
-#define ACE_SVC_FACTORY_DECLARE(X) extern "C" ACE_Svc_Export ACE_Service_Object *_make_##X (void);
+#define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X)
#define ACE_SVC_INVOKE(X) _make_##X ()
#define ACE_SVC_NAME(X) _make_##X
-#define ACE_SVC_FACTORY_DEFINE(X) extern "C" ACE_Service_Object *_make_##X () { ACE_TRACE (#X); return new X; }
+#define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X)
#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
# define ACE_TSS_TYPE(T) ACE_TSS< T >
@@ -1045,9 +1405,13 @@ struct strrecvfd {};
#if defined (ACE_HAS_UNICODE)
# if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0)
# include /**/ <cwchar>
-# else /* ACE_HAS_STANDARD_CPP_LIBRARY */
+# elif !defined (__BORLANDC__) /* ACE_HAS_STANDARD_CPP_LIBRARY */
# include /**/ <wchar.h>
# endif /* ACE_HAS_STANDARD_CPP_LIBRARY */
+#elif defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
+# include /**/ <wchar.h>
+#elif defined (ACE_LACKS_WCHAR_T)
+typedef long wchar_t;
#endif /* ACE_HAS_UNICODE */
#if defined (ACE_HAS_BROKEN_WRITEV)
@@ -1109,18 +1473,24 @@ enum ACE_Thread_State
// Convenient macro for testing for deadlock, as well as for detecting
// when mutexes fail.
+#define ACE_GUARD(MUTEX,OBJ,LOCK) \
+ ACE_Guard<MUTEX> OBJ (LOCK); \
+ if (OBJ.locked () == 0) return;
#define ACE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
ACE_Guard<MUTEX> OBJ (LOCK); \
if (OBJ.locked () == 0) return RETURN;
+#define ACE_WRITE_GUARD(MUTEX,OBJ,LOCK) \
+ ACE_Write_Guard<MUTEX> OBJ (LOCK); \
+ if (OBJ.locked () == 0) return;
#define ACE_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
ACE_Write_Guard<MUTEX> OBJ (LOCK); \
if (OBJ.locked () == 0) return RETURN;
+#define ACE_READ_GUARD(MUTEX,OBJ,LOCK) \
+ ACE_Read_Guard<MUTEX> OBJ (LOCK); \
+ if (OBJ.locked () == 0) return;
#define ACE_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
ACE_Read_Guard<MUTEX> OBJ (LOCK); \
if (OBJ.locked () == 0) return RETURN;
-#define ACE_GUARD(MUTEX,OBJ,LOCK) \
- ACE_Guard<MUTEX> OBJ (LOCK); \
- if (OBJ.locked () == 0) return;
#if defined (ACE_HAS_POSIX_SEM)
#include /**/ <semaphore.h>
@@ -1147,7 +1517,20 @@ struct cancel_state
// e.g., PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS.
};
-#include /**/ <sys/types.h>
+#if defined (ACE_LACKS_SYS_TYPES_H)
+ typedef unsigned char u_char;
+ typedef unsigned short u_short;
+ typedef unsigned int u_int;
+ typedef unsigned long u_long;
+
+ typedef unsigned char uchar_t;
+ typedef unsigned short ushort_t;
+ typedef unsigned int uint_t;
+ typedef unsigned long ulong_t;
+#else
+ #include /**/ <sys/types.h>
+#endif /* ACE_LACKS_SYS_TYPES_H */
+
#include /**/ <sys/stat.h>
#if defined (ACE_HAS_THREADS)
@@ -1413,6 +1796,83 @@ typedef ACE_mutex_t ACE_thread_mutex_t;
# define THR_SCHED_FIFO 0
# define THR_SCHED_RR 0
# define THR_SCHED_DEFAULT 0
+
+#elif defined (ACE_PSOS)
+
+// implement ACE_thread_mutex_t and ACE_mutex_t using pSOS semaphores
+typedef u_long ACE_mutex_t;
+typedef u_long ACE_thread_mutex_t;
+typedef long pid_t;
+
+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 unsigned int, so the ACE TSS emulation is compatible with them.)
+typedef u_int ACE_thread_key_t;
+
+/* CDG - TBD - revisit these: compare pthreads and pSOS threads */
+# 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 */
+
+// pSOS signals are sent via as_send(u_long tid, u_long signals)
+typedef u_long sigset_t;
+
+// Wrapper for NT events on pSOS.
+class ACE_Export ACE_event_t
+{
+ friend class ACE_OS;
+protected:
+ ACE_mutex_t lock_;
+ // Protect critical section.
+
+ ACE_cond_t condition_;
+ // Keeps track of waiters.
+
+ int manual_reset_;
+ // Specifies if this is an auto- or manual-reset event.
+
+ int is_signaled_;
+ // "True" if signaled.
+
+ u_long waiting_threads_;
+ // Number of waiting threads.
+};
+
+
#elif defined (VXWORKS)
// For mutex implementation using mutual-exclusion semaphores (which
// can be taken recursively).
@@ -1480,7 +1940,7 @@ 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 unsigned int, so the ACE TSS emulation is compatible with them.)
+// use u_int, so the ACE TSS emulation is compatible with them.)
typedef u_int ACE_thread_key_t;
#elif defined (ACE_HAS_WTHREADS)
@@ -1541,7 +2001,7 @@ protected:
ACE_sema_t sema_;
// Queue up threads waiting for the condition to become signaled.
-#if defined (VXWORKS)
+#if (defined (VXWORKS) || defined (ACE_PSOS))
ACE_sema_t waiters_done_;
// A semaphore used by the broadcast/signal thread to wait for all
// the waiting thread(s) to wake up and be released from the
@@ -1552,8 +2012,8 @@ protected:
// for the waiting thread(s) to wake up and get a chance at the
// semaphore.
#else
-#error "SOMEONE FIX ME!"
-#endif /* VXWORKS */
+ #error "SOMEONE FIX ME!"
+#endif /* VXWORKS || ACE_PSOS */
size_t was_broadcast_;
// Keeps track of whether we were broadcasting or just signaling.
@@ -1624,29 +2084,77 @@ typedef rwlock_t ACE_rwlock_t;
typedef int ACE_cond_t;
typedef int ACE_mutex_t;
typedef int ACE_thread_mutex_t;
-#if !defined (ACE_HAS_POSIX_SEM)
+#if !defined (ACE_HAS_POSIX_SEM) && !defined (ACE_PSOS)
typedef int ACE_sema_t;
#endif /* !ACE_HAS_POSIX_SEM */
typedef int ACE_rwlock_t;
typedef int ACE_thread_t;
typedef int ACE_hthread_t;
typedef u_int ACE_thread_key_t;
-#endif /* ACE_HAS_THREADS */
-#include "ace/stdcpp.h"
+#if defined (ACE_PSOS)
+
+// Wrapper for NT events on pSOS.
+class ACE_Export ACE_event_t
+{
+ friend class ACE_OS;
+protected:
+ ACE_mutex_t lock_;
+ // Protect critical section.
+
+ ACE_cond_t condition_;
+ // Keeps track of waiters.
+
+ int manual_reset_;
+ // Specifies if this is an auto- or manual-reset event.
+ int is_signaled_;
+ // "True" if signaled.
+
+ u_long waiting_threads_;
+ // Number of waiting threads.
+};
+
+#endif /* ACE_PSOS */
+
+#endif /* ACE_HAS_THREADS */
+
+// Standard C Library includes
+# include /**/ <assert.h>
+# include /**/ <limits.h>
+// NOTE: stdarg.h must be #included before stdio.h on LynxOS.
+# include /**/ <stdarg.h>
+# include /**/ <stdio.h>
+# include /**/ <new.h>
+# include /**/ <ctype.h>
+# include /**/ <signal.h>
+# include /**/ <string.h>
+# include /**/ <errno.h>
+# include /**/ <stdlib.h>
+# include /**/ <fcntl.h>
+# include /**/ <float.h>
+
+// If the user wants minimum IOStream inclusion, we will just include
+// the forward declarations
#if defined (ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION)
-class ostream;
+// Forward declaration for streams
+#include "ace/iosfwd.h"
+#else /* ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION */
+// Else they will get all the stream header files
+#include "ace/streams.h"
#endif /* ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION */
-#include /**/ <fcntl.h>
-
// This must come after signal.h is #included.
#if defined (SCO)
#define SIGIO SIGPOLL
#include /**/ <sys/regset.h>
#endif /* SCO */
+#if defined ACE_HAS_BYTESEX_H
+# include <bytesex.h>
+#endif /* ACE_HAS_BYTESEX_H */
+#include "ace/Basic_Types.h"
+
#if defined (ACE_HAS_SIG_MACROS)
#undef sigemptyset
#undef sigfillset
@@ -1663,13 +2171,6 @@ class ostream;
#undef sigfillset
#endif /* linux && __OPTIMIZE__ */
-// 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 (DIGITAL_UNIX)
-#undef sigwait
-#endif /* DIGITAL_UNIX */
-
#if defined (ACE_HAS_BROKEN_SENDMSG)
typedef struct msghdr ACE_SENDMSG_TYPE;
#else
@@ -1678,14 +2179,14 @@ typedef const struct msghdr ACE_SENDMSG_TYPE;
#if defined (ACE_HAS_BROKEN_RANDR)
// The SunOS 5.x version of rand_r is inconsistent with the header files...
-typedef unsigned int ACE_RANDR_TYPE;
+typedef u_int ACE_RANDR_TYPE;
extern "C" int rand_r (ACE_RANDR_TYPE seed);
#else
# if defined (__hpux)
-// HP-UX's stdlib.h (long *) doesn't match that man page (unsigned int *)
+// HP-UX's stdlib.h (long *) doesn't match that man page (u_int *)
typedef long *ACE_RANDR_TYPE;
# else
-typedef unsigned int *ACE_RANDR_TYPE;
+typedef u_int *ACE_RANDR_TYPE;
# endif /* __hpux */
#endif /* ACE_HAS_BROKEN_RANDR */
@@ -1779,6 +2280,7 @@ struct utsname
#include /**/ <sys/utsname.h>
#endif /* ACE_LACKS_UTSNAME_T */
+
#if defined (ACE_WIN32)
// Turn off warnings for /W4
// To resume any of these warning: #pragma warning(default: 4xxx)
@@ -1879,9 +2381,14 @@ struct utsname
#define ACE_INVALID_SEM_KEY 0
+#if defined(__BORLANDC__)
+#define ACE_SEH_TRY try
+#define ACE_SEH_FINALLY catch(...)
+#else
#define ACE_SEH_TRY __try
-#define ACE_SEH_EXCEPT(X) __except(X)
#define ACE_SEH_FINALLY __finally
+#endif /* __BORLANDC__ */
+#define ACE_SEH_EXCEPT(X) __except(X)
// The "null" device on Win32.
#define ACE_DEV_NULL "nul"
@@ -1893,7 +2400,6 @@ struct utsname
#define ACE_DIRECTORY_SEPARATOR_CHAR_W L'\\'
#define ACE_LD_SEARCH_PATH "PATH"
#define ACE_LD_SEARCH_PATH_SEPARATOR_STR ";"
-#define ACE_LOGGER_KEY __TEXT ("\\temp\\server_daemon")
#define ACE_DLL_SUFFIX ".dll"
#define ACE_DLL_PREFIX ""
@@ -1984,34 +2490,51 @@ PAGE_NOCACHE */
#include /**/ <process.h>
#include /**/ <io.h>
+#if defined (__BORLANDC__)
+#include <fcntl.h>
+#define _chdir chdir
+#define _ftime ftime
+#define _access access
+#define _getcwd getcwd
+#define _isatty isatty
+#define _umask umask
+#define _fstat fstat
+#define _stat stat
+#define _stricmp stricmp
+#define _strnicmp strnicmp
+
+#define _timeb timeb
+
+#define _O_CREAT O_CREAT
+#define _O_EXCL O_EXCL
+#define _O_TRUNC O_TRUNC
+#define _O_TEMPORARY 0x0800 // see fcntl.h
+#endif /* __BORLANDC__ */
+
typedef OVERLAPPED ACE_OVERLAPPED;
typedef DWORD ACE_thread_t;
typedef HANDLE ACE_hthread_t;
typedef long pid_t;
typedef DWORD ACE_thread_key_t;
+#if !defined (__BORLANDC__)
typedef DWORD nlink_t;
+#endif /* __BORLANDC__ */
-// 64-bit quad-word definitions
-#if !defined (_MSC_VER) /* Borland? */
-typedef uint64 ACE_QWORD;
-typedef ACE_QWORD ACE_hrtime_t;
-inline ACE_QWORD ACE_MAKE_QWORD (DWORD lo, DWORD hi) { return uint64 (lo, hi); }
-inline DWORD ACE_LOW_DWORD (ACE_QWORD q) { return q.LowPart; }
-inline DWORD ACE_HIGH_DWORD (ACE_QWORD q) { return q.HighPart; }
-#else
+// 64-bit quad-word definitions.
typedef unsigned __int64 ACE_QWORD;
-typedef signed __int64 ACE_hrtime_t; /* VC++ won't convert unsigned __int64 to double */
-// typedef unsigned __int64 ACE_hrtime_t; /* Why do we need this? */
+// VC++ won't convert unsigned __int64 to double.
+typedef signed __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); }
-#endif /* !defined (_MSC_VER) */
// Win32 dummies to help compilation.
+#if !defined (__BORLANDC__)
typedef int mode_t;
typedef int uid_t;
typedef int gid_t;
+#endif /* __BORLANDC__ */
typedef char *caddr_t;
struct rlimit { };
struct t_call { };
@@ -2062,7 +2585,12 @@ typedef int ACE_pri_t;
typedef HINSTANCE ACE_SHLIB_HANDLE;
const int ACE_DEFAULT_SHLIB_MODE = 0;
-#else /* !defined (ACE_WIN32) */
+
+#elif defined (ACE_PSOS)
+
+typedef ACE_UINT64 ACE_hrtime_t;
+
+#else /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */
typedef const char *LPCTSTR;
typedef char *LPTSTR;
@@ -2112,7 +2640,7 @@ typedef char TCHAR;
#define ACE_LD_SEARCH_PATH "LD_LIBRARY_PATH"
#define ACE_LD_SEARCH_PATH_SEPARATOR_STR ":"
-#define ACE_LOGGER_KEY "/tmp/server_daemon"
+
#if defined (__hpux)
#define ACE_DLL_SUFFIX ".sl"
#else
@@ -2187,6 +2715,7 @@ typedef char TCHAR;
// The "null" device on UNIX.
#define ACE_DEV_NULL "/dev/null"
+
// Wrapper for NT events on UNIX.
class ACE_Export ACE_event_t
{
@@ -2262,6 +2791,7 @@ extern "C"
#if defined (VXWORKS)
struct hostent {
char *h_name; /* official name of host */
+ char **h_aliases; /* aliases: not used on VxWorks */
int h_addrtype; /* host address type */
int h_length; /* address length */
char **h_addr_list; /* (first, only) address from name server */
@@ -2282,7 +2812,15 @@ extern "C"
#endif
#include /**/ <netinet/in.h>
+#if defined(VXWORKS) && defined(ghs)
+// Works around a lack of proper 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
#include /**/ <arpa/inet.h>
+#endif /* VXWORKS && ghs */
}
#if !defined (ACE_LACKS_TCP_H)
#include /**/ <netinet/tcp.h>
@@ -2309,6 +2847,7 @@ 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));
// This must come after limits.h is included
#define MAXPATHLEN _POSIX_PATH_MAX
@@ -2387,9 +2926,17 @@ typedef void (*__sighandler_t)(int); // keep Signal compilation happy
extern int t_errno;
#endif /* ACE_LACKS_T_ERRNO */
-#if !defined (ACE_HAS_SIGWAIT)
+// 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.
+# undef sigwait
+
+#if defined (DIGITAL_UNIX) && __DECCXX_VER >= 60090006
+extern "C" int __P_C(sigwait) __((const sigset_t *set, int *sig));
+#elif !defined (ACE_HAS_SIGWAIT)
extern "C" int sigwait (sigset_t *set);
-#endif /* ACE_HAS_SIGWAIT */
+#endif /* ! ACE_HAS_SIGWAIT */
#if defined (ACE_HAS_SELECT_H)
#include /**/ <sys/select.h>
@@ -2477,13 +3024,13 @@ extern "C"
int t_open(char *path, int oflag, struct t_info *info);
int t_optmgmt(int fildes, struct t_optmgmt *req,
struct t_optmgmt *ret);
- int t_rcv(int fildes, char *buf, unsigned nbytes, int *flags);
+ int t_rcv(int fildes, char *buf, u_int nbytes, int *flags);
int t_rcvconnect(int fildes, struct t_call *call);
int t_rcvdis(int fildes, struct t_discon *discon);
int t_rcvrel(int fildes);
int t_rcvudata(int fildes, struct t_unitdata *unitdata, int *flags);
int t_rcvuderr(int fildes, struct t_uderr *uderr);
- int t_snd(int fildes, char *buf, unsigned nbytes, int flags);
+ int t_snd(int fildes, char *buf, u_int nbytes, int flags);
int t_snddis(int fildes, struct t_call *call);
int t_sndrel(int fildes);
int t_sndudata(int fildes, struct t_unitdata *unitdata);
@@ -2549,68 +3096,11 @@ typedef short ACE_pri_t;
#if defined (ACE_HAS_HI_RES_TIMER)
/* hrtime_t is defined on systems (Suns) with ACE_HAS_HI_RES_TIMER */
typedef hrtime_t ACE_hrtime_t;
-#elif defined (ACE_HAS_64BIT_LONGS)
- typedef u_long ACE_hrtime_t;
-#elif defined (ACE_HAS_LONGLONG_T)
- typedef unsigned long long ACE_hrtime_t;
#else
- class ACE_Export ACE_U_LongLong
- // = TITLE
- // Unsigned long long for platforms that don't have one.
- //
- // = DESCRIPTION
- // Provide our own unsigned long long. This is intended to be
- // use with ACE_High_Res_Timer, so the division operator assumes
- // that the quotient fits into a u_long.
- // Please note that the constructor takes (optionally) two values.
- // The high one contributes 0x100000000 times its value. So,
- // for example, (0, 2) is _not_ 20000000000, but instead
- // 0x200000000. To emphasize this, the default values are expressed
- // in hex, and dump () outputs the value in hex.
- {
- public:
- // = Initialization and termination methods.
- ACE_U_LongLong (const u_long lo = 0x0, const u_long hi = 0x0);
- ACE_U_LongLong (const ACE_U_LongLong &);
- ACE_U_LongLong &operator= (const ACE_U_LongLong &);
- ~ACE_U_LongLong (void);
-
- // = Overloaded relation operators.
- int operator== (const ACE_U_LongLong &) const;
- int operator!= (const ACE_U_LongLong &) const;
- int operator< (const ACE_U_LongLong &) const;
- int operator<= (const ACE_U_LongLong &) const;
- int operator> (const ACE_U_LongLong &) const;
- int operator>= (const ACE_U_LongLong &) const;
-
- ACE_U_LongLong operator+ (const ACE_U_LongLong &) const;
- ACE_U_LongLong operator- (const ACE_U_LongLong &) const;
- u_long operator/ (const u_long) const;
-
- ACE_U_LongLong &operator+= (const ACE_U_LongLong &);
- ACE_U_LongLong &operator-= (const ACE_U_LongLong &);
-
- // = Helper methods.
- void output (FILE * = stdout) const;
- // Outputs the value to the FILE, in hex.
-
- u_long hi (void) const;
- u_long lo (void) const;
-
- void hi (const u_long hi);
- void lo (const u_long lo);
-
- ACE_ALLOC_HOOK_DECLARE;
-
- private:
- u_long hi_;
- u_long lo_;
- };
-
- typedef ACE_U_LongLong ACE_hrtime_t;
+ typedef ACE_UINT64 ACE_hrtime_t;
#endif /* ACE_HAS_HI_RES_TIMER */
-#endif /* ACE_WIN32 */
+#endif /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */
#if defined (ACE_SELECT_USES_INT)
typedef int ACE_FD_SET_TYPE;
@@ -2627,7 +3117,7 @@ typedef fd_set ACE_FD_SET_TYPE;
#endif /* MAXNAMELEN */
#if defined (ACE_LACKS_SIGSET)
-typedef unsigned int sigset_t;
+typedef u_int sigset_t;
#endif /* ACE_LACKS_SIGSET */
#if defined (ACE_LACKS_SIGACTION)
@@ -2798,8 +3288,12 @@ struct sigaction
#define EIDRM 0
#endif /* !EIDRM */
+#if !defined (ENOSYS)
+#define ENOSYS EFAULT /* Operation not supported or unknown error. */
+#endif /* !ENOSYS */
+
#if !defined (ENOTSUP)
-#define ENOTSUP ENOSYS /* Operation not supported . */
+#define ENOTSUP ENOSYS /* Operation not supported. */
#endif /* !ENOTSUP */
#if !defined (WNOHANG)
@@ -2835,16 +3329,6 @@ struct sigaction
#define LOCALNAME 0
#define REMOTENAME 1
-#if defined (ACE_HAS_64BIT_LONGS)
-// Necessary to support the Alphas, which have 64 bit longs and 32 bit
-// ints...
-typedef u_int ACE_UINT32;
-typedef int ACE_INT32;
-#else
-typedef u_long ACE_UINT32;
-typedef long ACE_INT32;
-#endif /* ACE_HAS_64BIT_LONGS */
-
#if !defined (ETIMEDOUT) && defined (ETIME)
#define ETIMEDOUT ETIME
#endif /* ETIMEDOUT */
@@ -2922,11 +3406,7 @@ typedef void *(*ACE_THR_FUNC)(void *);
extern "C" {
typedef void (*ACE_THR_C_DEST)(void *);
}
-#if defined (ACE_HAS_STDARG_THR_DEST)
-typedef void (*ACE_THR_DEST)(...);
-#else
typedef void (*ACE_THR_DEST)(void *);
-#endif /* ACE_HAS_STDARG_THR_DEST */
extern "C"
{
@@ -2934,7 +3414,7 @@ extern "C"
typedef FUNCPTR ACE_THR_C_FUNC; // where typedef int (*FUNCPTR) (...)
#else
typedef void *(*ACE_THR_C_FUNC)(void *);
-#endif /* ACE_WIN32 */
+#endif /* VXWORKS */
}
#if !defined (MAP_FAILED)
@@ -3029,7 +3509,7 @@ typedef void (*ACE_Sig_Handler_Ex) (int, siginfo_t *siginfo, ucontext_t *ucontex
#if defined (ACE_REDEFINES_XTI_FUNCTIONS)
#include /**/ <xti.h>
-#if defined (UNIXWARE) /* They apparantly forgot one... */
+#if defined (UNIXWARE_2_0) /* They apparantly forgot one... */
extern "C" int _xti_error(char *);
#endif /* UNIXWARE */
#endif /* ACE_REDEFINES_XTI_FUNCTIONS */
@@ -3091,10 +3571,18 @@ struct ACE_Export ACE_Str_Buf : public strbuf
};
#if defined (ACE_HAS_BROKEN_BITSHIFT)
-#define ACE_MSB_MASK (~(ACE_UINT32 (1) << ACE_UINT32 (NFDBITS - 1)))
+ // 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.
-#define ACE_MSB_MASK (~(1 << (NFDBITS - 1)))
+ // 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 */
// Signature for registering a cleanup function that is used by the
@@ -3127,9 +3615,15 @@ struct ACE_Cleanup_Info
// = TITLE
// Hold cleanup information for thread/process
{
- ACE_Cleanup_Info (void) : object_ (0), cleanup_hook_ (0), param_ (0) {}
+ ACE_Cleanup_Info (void);
// Default constructor.
+ int operator== (const struct ACE_Cleanup_Info &o) const;
+ // Equality operator.
+
+ int operator!= (const struct ACE_Cleanup_Info &o) const;
+ // Inequality operator.
+
void *object_;
// Point to object that gets passed into the <cleanup_hook_>.
@@ -3399,6 +3893,7 @@ public:
// 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 int getpagesize (void);
static gid_t getgid (void);
static pid_t getpid (void);
static pid_t getpgid (pid_t pid);
@@ -3896,10 +4391,14 @@ public:
size_t len);
static char *strcat (char *s,
const char *t);
- static char *strchr (const char *s,
+ static char *strchr (char *s,
int c);
- static char *strrchr (const char *s,
+ static char *strrchr (char *s,
int c);
+ static const char *strchr (const char *s,
+ int c);
+ static const char *strrchr (const char *s,
+ int c);
static int strcmp (const char *s,
const char *t);
static int strncmp (const char *s,
@@ -3907,12 +4406,16 @@ public:
size_t len);
static char *strcpy (char *s,
const char *t);
- static char *strpbrk (const char *s1,
+ static char *strpbrk (char *s1,
const char *s2);
+ static const char *strpbrk (const char *s1,
+ const char *s2);
static size_t strspn(const char *s1,
const char *s2);
- static char *strstr (const char *s,
+ static char *strstr (char *s,
const char *t);
+ static const char *strstr (const char *s,
+ const char *t);
static char *strdup (const char *s);
static size_t strlen (const char *s);
static char *strncpy (char *s,
@@ -3926,15 +4429,19 @@ public:
static char *strtok_r (char *s,
const char *tokens,
char **lasts);
- static char *strsplit_r (char *s,
- const char *token,
- char *&next_start);
static long strtol (const char *s,
char **ptr,
int base);
- static unsigned long strtoul(const char *s,
- char **ptr,
- int base);
+ static u_long strtoul(const char *s,
+ char **ptr,
+ int base);
+
+#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR)
+ // = These go here since they are needed for TAO.
+ static size_t strlen (const wchar_t *s);
+ static wchar_t *strcpy (wchar_t *s,
+ const wchar_t *t);
+#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */
#if defined (ACE_HAS_UNICODE)
// = A set of wrappers for UNICODE string operations.
@@ -3950,8 +4457,6 @@ public:
static int strncmp (const wchar_t *s,
const wchar_t *t,
size_t len);
- static wchar_t *strcpy (wchar_t *s,
- const wchar_t *t);
static int strcasecmp (const wchar_t *s,
const wchar_t *t);
static int strncasecmp (const wchar_t *s,
@@ -3959,7 +4464,6 @@ public:
size_t len);
static wchar_t *strpbrk (const wchar_t *s1,
const wchar_t *s2);
- static size_t strlen (const wchar_t *s);
static wchar_t *strncpy (wchar_t *s,
const wchar_t *t,
size_t len);
@@ -4387,6 +4891,40 @@ private:
if (POINTER == 0) { errno = ENOMEM; return; } \
} while (0)
+// Some useful abstration for expressions involving
+// ACE_Allocator.malloc (). The difference between ACE_NEW_MALLOC*
+// with ACE_ALLOCATOR* is that they call constructors also.
+
+#define ACE_ALLOCATOR_RETURN(POINTER,ALLOCATOR,RET_VAL) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return RET_VAL; } \
+ } while (0)
+#define ACE_ALLOCATOR(POINTER,ALLOCATOR) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return; } \
+ } while (0)
+
+#define ACE_NEW_MALLOC_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,RET_VAL) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
+ else { new (POINTER) CONSTRUCTOR; } \
+ } while (0)
+#define ACE_NEW_MALLOC(POINTER,ALLOCATOR,CONSTRUCTOR) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return;} \
+ else { new (POINTER) CONSTRUCTOR; } \
+ } while (0)
+
+#define ACE_DES_NOFREE (POINTER,CLASS) POINTER->CLASS::~CLASS ()
+#define ACE_DES_FREE(POINTER,DEALLOCATOR,CLASS) \
+ do { POINTER->CLASS::~CLASS (); DEALLOCATOR (POINTER); } while (0)
+#define ACE_DES_NOFREE_TEMPLATE (POINTER,T_CLASS,T_PARAMETER) \
+ POINTER-> T_CLASS T_PARAMETER ::~ T_CLASS ()
+#define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
+ do { POINTER-> T_CLASS T_PARAMETER ::~ T_CLASS (); \
+ DEALLOCATOR (POINTER); \
+ } while (0)
+
#if defined (ACE_HAS_SIGNAL_SAFE_OS_CALLS)
// The following two macros ensure that system calls are properly
// restarted (if necessary) when interrupts occur.
@@ -4455,6 +4993,48 @@ extern "C" ACE_Export void ace_mutex_lock_cleanup_adapter (void *args);
// Also, create an ACE_Object_Manager static instance in "main ()".
#include "ace/Object_Manager.h"
+#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_Object_Manager ace_object_manager; /* has program lifetime */ \
+ 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)
+// 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[] = {""}; /* dummy arg list */ \
+ ACE_Object_Manager ace_object_manager; /* has program lifetime */ \
+ ace_main_i (argc, argv); /* call user main, ignore result */ \
+} \
+int \
+ace_main_i
+#else
#define main \
ace_main_i (int, char *[]); /* forward declaration */ \
int \
@@ -4465,6 +5045,7 @@ ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., "main" */ \
} \
int \
ace_main_i
+#endif /* ACE_PSOSIM */
#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */
#if defined (UNICODE)
diff --git a/ace/OS.i b/ace/OS.i
index 1fad7c48828..47c03078d4f 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -760,7 +760,8 @@ ACE_INLINE int
ACE_OS::fstat (ACE_HANDLE handle, struct stat *stp)
{
// ACE_TRACE ("ACE_OS::fstat");
- ACE_OSCALL_RETURN (::_fstat ((int) handle, (struct _stat *) stp), int, -1);
+ int fd = ::_open_osfhandle ((long) handle, 0);
+ ACE_OSCALL_RETURN (::_fstat (fd, (struct _stat *) stp), int, -1);
}
#endif /* WIN32 */
@@ -771,6 +772,12 @@ ACE_OS::clock_gettime (clockid_t clockid, struct timespec *ts)
// ACE_TRACE ("ACE_OS::clock_gettime");
#if defined (ACE_HAS_CLOCK_GETTIME)
ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1);
+#elif defined (ACE_PSOS)
+ 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);
@@ -802,7 +809,7 @@ ACE_OS::gettimeofday (void)
#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)
+#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;
@@ -864,7 +871,6 @@ ACE_OS::unlink (const char *path)
#endif /* VXWORKS */
}
-
ACE_INLINE char *
ACE_OS::tempnam (const char *dir, const char *pfx)
{
@@ -874,8 +880,12 @@ ACE_OS::tempnam (const char *dir, const char *pfx)
ACE_UNUSED_ARG (pfx);
ACE_NOTSUP_RETURN (0);
#else
-#if defined (WIN32)
+#if defined (ACE_WIN32)
+#if defined (__BORLANDC__)
+ ACE_OSCALL_RETURN (::_tempnam ((char *) dir, (char *) pfx), char *, 0);
+#else
ACE_OSCALL_RETURN (::_tempnam (dir, pfx), char *, 0);
+#endif /* __BORLANDC__ */
#else
ACE_OSCALL_RETURN (::tempnam (dir, pfx), char *, 0);
#endif /* WIN32 */
@@ -925,6 +935,8 @@ ACE_OS::_exit (int status)
// ACE_TRACE ("ACE_OS::_exit");
#if defined (VXWORKS)
::exit (status);
+#elif defined (ACE_PSOSIM)
+ ::u_exit (status);
#else
::_exit (status);
#endif /* VXWORKS */
@@ -993,13 +1005,6 @@ ACE_OS::strcat (char *s, const char *t)
return ::strcat (s, t);
}
-ACE_INLINE char *
-ACE_OS::strstr (const char *s, const char *t)
-{
- // ACE_TRACE ("ACE_OS::strstr");
- return ::strstr (s, t);
-}
-
ACE_INLINE size_t
ACE_OS::strspn (const char *s, const char *t)
{
@@ -1008,19 +1013,47 @@ ACE_OS::strspn (const char *s, const char *t)
}
ACE_INLINE char *
-ACE_OS::strchr (const char *s, int c)
+ACE_OS::strchr (char *s, int c)
{
// ACE_TRACE ("ACE_OS::strchr");
return ::strchr (s, c);
}
+ACE_INLINE const char *
+ACE_OS::strchr (const char *s, int c)
+{
+ // ACE_TRACE ("ACE_OS::strchr");
+ return (const char *) ::strchr (s, c);
+}
+
+ACE_INLINE const char *
+ACE_OS::strstr (const char *s, const char *t)
+{
+ // ACE_TRACE ("ACE_OS::strstr");
+ return (const char *) ::strstr (s, t);
+}
+
ACE_INLINE char *
-ACE_OS::strrchr (const char *s, int c)
+ACE_OS::strstr (char *s, const char *t)
+{
+ // ACE_TRACE ("ACE_OS::strstr");
+ return ::strstr (s, t);
+}
+
+ACE_INLINE char *
+ACE_OS::strrchr (char *s, int c)
{
// ACE_TRACE ("ACE_OS::strrchr");
return ::strrchr (s, c);
}
+ACE_INLINE const char *
+ACE_OS::strrchr (const char *s, int c)
+{
+ // ACE_TRACE ("ACE_OS::strrchr");
+ return (const char *) ::strrchr (s, c);
+}
+
ACE_INLINE int
ACE_OS::strcmp (const char *s, const char *t)
{
@@ -1043,11 +1076,17 @@ ACE_OS::to_lower (int c)
}
ACE_INLINE char *
-ACE_OS::strpbrk (const char *s1, const char *s2)
+ACE_OS::strpbrk (char *s1, const char *s2)
{
return ::strpbrk (s1, s2);
}
+ACE_INLINE const char *
+ACE_OS::strpbrk (const char *s1, const char *s2)
+{
+ return (const char *) ::strpbrk (s1, s2);
+}
+
ACE_INLINE char *
ACE_OS::strdup (const char *s)
{
@@ -1088,21 +1127,17 @@ ACE_OS::strcasecmp (const char *s, const char *t)
// equal.
int result = 0;
- if (ACE_OS::strlen (s) != ACE_OS::strlen (t))
- result = 1;
- else
- {
- for (;
- *s != '\0' && *t != '\0';
- ++s, ++t)
- if (ACE_OS::to_lower (*s) != ACE_OS::to_lower (*t))
- {
- result = ((ACE_OS::to_lower (*s) < ACE_OS::to_lower (*t)) ? -1 : 1);
- break;
- }
- }
-
- return result; // == 0 for match, else 1
+ do
+ {
+ int a = ACE_OS::to_lower (*s);
+ int b = ACE_OS::to_lower (*t);
+ result = ((a < b) ? -1 : (a > b));
+ if (result != 0)
+ break;
+ } while (*s++ != '\0' && *t++ != '\0');
+ // paranoid termination condition
+
+ return result; // == 0 for match, else 1
#else
return ::strcasecmp (s, t);
#endif /* ACE_LACKS_STRCASECMP */
@@ -1193,25 +1228,6 @@ ACE_OS::strtok_r (char *s, const char *tokens, char **lasts)
#endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */
}
-ACE_INLINE char *
-ACE_OS::strsplit_r (char *str, const char *token, char *&next_start)
-{
- char *tok_loc;
- char *ret = 0;
-
- if (str != 0)
- next_start = str;
-
- if ( (tok_loc = strstr(next_start, token)) != 0)
- {
- ret = next_start; // return the beginning of the string
- *tok_loc = '\0'; // insure its terminated
- next_start = tok_loc + strlen(token);
- }
-
- return ret;
-}
-
ACE_INLINE long
ACE_OS::strtol (const char *s, char **ptr, int base)
{
@@ -1330,7 +1346,7 @@ ACE_OS::mutex_destroy (ACE_mutex_t *m)
// ACE_TRACE ("ACE_OS::mutex_destroy");
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL_RETURN (::pthread_mutex_destroy (m), int, -1);
# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m), ace_result_), int, -1);
@@ -1342,8 +1358,8 @@ ACE_OS::mutex_destroy (ACE_mutex_t *m)
{
case USYNC_PROCESS:
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
- ace_result_),
- int, -1);
+ ace_result_),
+ int, -1);
case USYNC_THREAD:
return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
default:
@@ -1367,7 +1383,7 @@ ACE_OS::mutex_lock (ACE_mutex_t *m)
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
// Note, don't use "::" here since the following call is often a macro.
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL_RETURN (pthread_mutex_lock (m), int, -1);
# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), ace_result_),
@@ -1453,8 +1469,15 @@ ACE_OS::mutex_trylock (ACE_mutex_t *m)
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
// Note, don't use "::" here since the following call is often a macro.
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
- ACE_OSCALL_RETURN (pthread_mutex_trylock (m), int, -1);
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
+ 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);
@@ -1557,7 +1580,7 @@ ACE_OS::mutex_unlock (ACE_mutex_t *m)
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
// Note, don't use "::" here since the following call is often a macro.
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL_RETURN (pthread_mutex_unlock (m), int, -1);
# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), ace_result_),
@@ -1570,8 +1593,8 @@ ACE_OS::mutex_unlock (ACE_mutex_t *m)
{
case USYNC_PROCESS:
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_),
- ace_result_),
- int, -1);
+ ace_result_),
+ int, -1);
case USYNC_THREAD:
return ACE_OS::thread_mutex_unlock (&m->thr_mutex_);
default:
@@ -1666,8 +1689,14 @@ ACE_OS::thread_mutex_trylock (ACE_thread_mutex_t *m)
return ACE_OS::mutex_trylock (m);
#elif defined (ACE_HAS_WTHREADS)
#if defined (ACE_HAS_WIN32_TRYLOCK)
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::TryEnterCriticalSection (m), ace_result_),
- int, -1) ;
+ BOOL result = ::TryEnterCriticalSection (m);
+ if (result == TRUE)
+ return 0;
+ else
+ {
+ errno = EBUSY;
+ return -1;
+ }
#else
ACE_UNUSED_ARG (m);
ACE_NOTSUP_RETURN (-1);
@@ -1712,7 +1741,7 @@ ACE_OS::cond_destroy (ACE_cond_t *cv)
// ACE_TRACE ("ACE_OS::cond_destroy");
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL_RETURN (::pthread_cond_destroy (cv), int, -1);
# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_destroy (cv), ace_result_), int, -1);
@@ -1781,7 +1810,7 @@ ACE_OS::cond_signal (ACE_cond_t *cv)
// ACE_TRACE ("ACE_OS::cond_signal");
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL_RETURN (::pthread_cond_signal (cv), int, -1);
# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_signal (cv),ace_result_),
@@ -1802,7 +1831,7 @@ ACE_OS::cond_broadcast (ACE_cond_t *cv)
// ACE_TRACE ("ACE_OS::cond_broadcast");
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL_RETURN (::pthread_cond_broadcast (cv), int, -1);
# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_broadcast (cv),
@@ -1827,7 +1856,7 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
// ACE_TRACE ("ACE_OS::cond_wait");
#if defined (ACE_HAS_THREADS)
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
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_),
@@ -1858,7 +1887,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
#if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)
-# if defined (ACE_HAS_DCE_DRAFT4_THREADS) || defined (ACE_HAS_FSU_PTHREADS)
+# if defined (ACE_HAS_DCE_DRAFT4_THREADS)
ACE_OSCALL (timeout == 0
? ::pthread_cond_wait (cv, external_mutex)
: ::pthread_cond_timedwait (cv, external_mutex,
@@ -1936,6 +1965,12 @@ ACE_OS::sema_destroy (ACE_sema_t *s)
s->sema_ = 0;
return result;
#endif /* ACE_HAS_STHREADS */
+#elif defined (ACE_PSOS)
+ /* TBD - move this into threaded section with mutithreaded port */
+ int result;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_delete (s->sema_), result), int, -1, result);
+ s->sema_ = 0;
+ return result;
#else
ACE_UNUSED_ARG (s);
ACE_NOTSUP_RETURN (-1);
@@ -1956,10 +1991,11 @@ ACE_OS::sema_init (ACE_sema_t *s, u_int count, int type,
#if !defined (ACE_LACKS_NAMED_POSIX_SEM)
if (name)
{
- s->name_ = ACE_OS::strdup (name);
-
- s->sema_ = ::sem_open (s->name_, O_CREAT,
- ACE_DEFAULT_FILE_PERMS, count);
+ ACE_ALLOCATOR_RETURN (s->name_, ACE_OS::strdup (name), -1);
+ s->sema_ = ::sem_open (s->name_,
+ O_CREAT,
+ ACE_DEFAULT_FILE_PERMS,
+ count);
return (int) s->sema_ == -1 ? -1 : 0;
}
else
@@ -2022,6 +2058,17 @@ ACE_OS::sema_init (ACE_sema_t *s, u_int count, int type,
return s->sema_ ? 0 : -1;
#endif /* ACE_HAS_STHREADS */
+#elif defined (ACE_PSOS)
+ /* TBD - move this into threaded section with mutithreaded port */
+ int 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;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_create (s->name_, count, flags, &(s->sema_)),
+ result), int, -1, result);
+ return result;
#else
ACE_UNUSED_ARG (s);
ACE_UNUSED_ARG (count);
@@ -2060,11 +2107,16 @@ ACE_OS::sema_post (ACE_sema_t *s)
return result;
#elif defined (ACE_HAS_WTHREADS)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
- ace_result_),
- int, -1);
+ ace_result_),
+ int, -1);
#elif defined (VXWORKS)
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::semGive (s->sema_), ace_result_), int, -1);
#endif /* ACE_HAS_STHREADS */
+#elif defined (ACE_PSOS)
+ /* TBD - move this into threaded section with mutithreaded port */
+ int result;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_v (s->sema_), result), int, -1, result);
+ return result;
#else
ACE_UNUSED_ARG (s);
ACE_NOTSUP_RETURN (-1);
@@ -2077,7 +2129,7 @@ ACE_OS::sema_post (ACE_sema_t *s, size_t release_count)
#if defined (ACE_WIN32)
// Win32 supports this natively.
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
- ace_result_), int, -1);
+ ace_result_), int, -1);
#else
// On POSIX platforms we need to emulate this ourselves.
for (size_t i = 0; i < release_count; i++)
@@ -2146,6 +2198,12 @@ ACE_OS::sema_trywait (ACE_sema_t *s)
// got the semaphore
return 0;
#endif /* ACE_HAS_STHREADS */
+#elif defined (ACE_PSOS)
+ /* TBD - move this into threaded section with mutithreaded port */
+ int result;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_NOWAIT, 0), result),
+ int, -1, result);
+ return result;
#else
ACE_UNUSED_ARG (s);
ACE_NOTSUP_RETURN (-1);
@@ -2208,6 +2266,12 @@ ACE_OS::sema_wait (ACE_sema_t *s)
#elif defined (VXWORKS)
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::semTake (s->sema_, WAIT_FOREVER), ace_result_), int, -1);
#endif /* ACE_HAS_STHREADS */
+#elif defined (ACE_PSOS)
+ /* TBD - move this into threaded section with mutithreaded port */
+ int result;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_WAIT, 0), result),
+ int, -1, result);
+ return result;
#else
ACE_UNUSED_ARG (s);
ACE_NOTSUP_RETURN (-1);
@@ -2283,6 +2347,14 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv)
tv.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::semTake (s->sema_, ticks), ace_result_), int, -1);
#endif /* ACE_HAS_STHREADS */
+#elif defined (ACE_PSOS)
+ /* TBD - move this into threaded section with mutithreaded port */
+ int result;
+ u_long ticks = tv.sec() * KC_TICKS2SEC +
+ tv.usec () * KC_TICKS2SEC / ACE_ONE_SECOND_IN_USECS;
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_WAIT, ticks), result),
+ int, -1, result);
+ return result;
#else
ACE_UNUSED_ARG (s);
ACE_UNUSED_ARG (tv);
@@ -2408,20 +2480,20 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
{
// ACE_TRACE ("ACE_OS::cond_wait");
#if defined (ACE_HAS_THREADS)
- // It's ok to increment this because the <external_mutex> must be
- // locked by the caller.
+ // 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;
#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);
+ cv->sema_, INFINITE, FALSE),
+ result),
+ int, -1, result);
else
#endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
{
@@ -2437,54 +2509,57 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
result = ACE_OS::sema_wait (&cv->sema_);
}
- // Reacquire lock to avoid race conditions.
+ // 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)
- if (external_mutex->type_ == USYNC_PROCESS)
+ 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.
+ // 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);
+ 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.
+ // 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 */
}
- else
#endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
- if (result != -1)
- {
- // If we're the last waiter thread during this particular
- // broadcast then let all the other threads proceed.
- if (last_waiter)
+ // 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)
- ACE_OS::sema_post (&cv->waiters_done_);
+ ACE_OS::sema_post (&cv->waiters_done_);
#else
- ACE_OS::event_signal (&cv->waiters_done_);
+ 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.
+ // 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);
- // Reset errno in case mutex_lock() also fails...
- errno = error;
return result;
#else
ACE_UNUSED_ARG (cv);
@@ -2505,9 +2580,10 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
return ACE_OS::cond_wait (cv, external_mutex);
#if defined (ACE_HAS_WTHREADS) || defined (VXWORKS)
- // It's ok to increment this because the <external_mutex> must be
- // locked by the caller.
+ // 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;
@@ -2532,9 +2608,12 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
#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.
+ // This call will automatically release the mutex and wait on the
+ // semaphore.
result = ::SignalObjectAndWait (external_mutex->proc_mutex_,
- cv->sema_, msec_timeout, FALSE);
+ cv->sema_,
+ msec_timeout,
+ FALSE);
else
#endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
{
@@ -2599,19 +2678,22 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
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.
+ // 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);
+ 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.
+ // 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 */
else if (last_waiter)
@@ -2622,8 +2704,8 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
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.
+ // 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);
errno = error;
@@ -2649,9 +2731,10 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
if (timeout == 0)
return ACE_OS::cond_wait (cv, external_mutex);
- // It's ok to increment this because the <external_mutex> must be
- // locked by the caller.
+ // 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;
@@ -2686,9 +2769,11 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
// 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)
@@ -2708,8 +2793,8 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
// 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.
+ // 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;
@@ -2724,9 +2809,9 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
{
// ACE_TRACE ("ACE_OS::cond_wait");
#if defined (ACE_HAS_THREADS)
- // It's ok to increment this because the <external_mutex> must be
- // locked by the caller.
+ ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
cv->waiters_++;
+ ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
int result = 0;
int error = 0;
@@ -2744,9 +2829,11 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
// 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)
@@ -2765,9 +2852,8 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
// 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.
+ // 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...
@@ -3405,16 +3491,23 @@ ACE_OS::connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN) addrlen), int, -1);
}
+#if !defined (VXWORKS)
+ACE_INLINE struct hostent *
+ACE_OS::gethostbyname (const char *name)
+{
+ // ACE_TRACE ("ACE_OS::gethostbyname");
+#if defined (ACE_HAS_NONCONST_GETBY)
+ ACE_SOCKCALL_RETURN (::gethostbyname ((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_TRACE ("ACE_OS::gethostbyaddr");
-#if defined (VXWORKS)
- ACE_UNUSED_ARG (addr);
- ACE_UNUSED_ARG (length);
- ACE_UNUSED_ARG (type);
- ACE_NOTSUP_RETURN (0);
-#elif defined (ACE_HAS_NONCONST_GETBY)
+#if defined (ACE_HAS_NONCONST_GETBY)
ACE_SOCKCALL_RETURN (::gethostbyaddr ((char *) addr, (ACE_SOCKET_LEN) length, type),
struct hostent *, 0);
#else
@@ -3422,6 +3515,7 @@ ACE_OS::gethostbyaddr (const char *addr, int length, int type)
struct hostent *, 0);
#endif /* ACE_HAS_NONCONST_GETBY */
}
+#endif /* ! VXWORKS */
// It would be really cool to add another version of select that would
// function like the one we're defending against below!
@@ -3562,6 +3656,8 @@ ACE_OS::getprotobyname_r (const char *name,
#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 ((char *) name),
struct protoent *, 0);
#else
@@ -3851,21 +3947,14 @@ ACE_OS::getpwnam_r (const char *name, struct passwd *pwent,
// DNS accessors.
+#if !defined (VXWORKS)
ACE_INLINE struct hostent *
ACE_OS::gethostbyaddr_r (const char *addr, int length, int type,
hostent *result, ACE_HOSTENT_DATA buffer,
int *h_errnop)
{
// ACE_TRACE ("ACE_OS::gethostbyaddr_r");
-#if defined (VXWORKS)
- 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 (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
#if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10)
::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
@@ -3892,6 +3981,9 @@ ACE_OS::gethostbyaddr_r (const char *addr, int length, int type,
#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 ((char *) addr, (ACE_SOCKET_LEN) length, type),
struct hostent *, 0);
#else
@@ -3910,13 +4002,7 @@ ACE_OS::gethostbyname_r (const char *name, hostent *result,
int *h_errnop)
{
// ACE_TRACE ("ACE_OS::gethostbyname_r");
-#if defined (VXWORKS)
- 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 (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
#if defined (DIGITAL_UNIX)
// gethostbyname returns thread-specific storage on Digital Unix
ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
@@ -3944,6 +4030,9 @@ ACE_OS::gethostbyname_r (const char *name, hostent *result,
#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 ((char *) name), struct hostent *, 0);
#else
ACE_UNUSED_ARG (h_errnop);
@@ -3953,6 +4042,7 @@ ACE_OS::gethostbyname_r (const char *name, hostent *result,
ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
}
+#endif /* ! VXWORKS */
ACE_INLINE char *
ACE_OS::gets (char *str)
@@ -3993,6 +4083,8 @@ ACE_OS::getservbyname_r (const char *svc, const char *proto,
#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 ((char *) svc, (char *) proto),
struct servent *, 0);
#else
@@ -4012,7 +4104,7 @@ ACE_OS::inet_addr (const char *name)
u_long ret = 0;
u_int segment;
- bool valid = true;
+ u_int valid = 1;
for (u_int i = 0; i < 4; ++i)
{
@@ -4028,7 +4120,7 @@ ACE_OS::inet_addr (const char *name)
}
if (*name != '.' && *name != '\0')
{
- valid = false;
+ valid = 0;
break;
}
@@ -4048,14 +4140,12 @@ ACE_OS::inet_addr (const char *name)
#endif /* ACE_HAS_NONCONST_GETBY */
}
-#if ! defined (VXWORKS)
ACE_INLINE char *
ACE_OS::inet_ntoa (const struct in_addr addr)
{
// ACE_TRACE ("ACE_OS::inet_ntoa");
ACE_OSCALL_RETURN (::inet_ntoa (addr), char *, 0);
}
-#endif /* ! VXWORKS */
ACE_INLINE int
ACE_OS::last_error (void)
@@ -4384,8 +4474,7 @@ ACE_OS::thr_getspecific (ACE_thread_key_t key, void **data)
# elif !defined (ACE_HAS_FSU_PTHREADS) && defined (ACE_HAS_SETKIND_NP) || defined (ACE_HAS_PTHREAD_GETSPECIFIC_DATAPTR)
::pthread_getspecific (key, data);
# else /* ACE_HAS_FSU_PTHREADS */
- // Is this really used anywhere?
- *data = ::pthread_getspecific (key, data);
+ ::pthread_getspecific (key, data);
# endif /* ACE_HAS_FSU_PTHREADS */
return 0;
# elif defined (ACE_HAS_WTHREADS)
@@ -4633,16 +4722,20 @@ ACE_OS::sigwait (sigset_t *set, int *sig)
*sig = ::sigwait (set);
return *sig;
#else /* ACE_HAS_ONEARG_SETWAIT */
-#if defined (DIGITAL_UNIX)
- errno = ::__sigwaitd10 (set, sig);
-#elif defined (__Lynx__)
- // Second arg is a void **, which we don't need (the selected
- // signal number is returned).
- *sig = ::sigwait (set, 0);
- return *sig;
-#else
- errno = ::sigwait (set, sig);
-#endif /* DIGITAL_UNIX */
+# if defined (DIGITAL_UNIX)
+# if __DECCXX_VER < 60090006
+ errno = ::__sigwaitd10 (set, sig);
+# else
+ errno = sigwait (set, sig);
+# endif /* __DECCXX_VER < 60090006 */
+# elif defined (__Lynx__)
+ // Second arg is a void **, which we don't need (the selected
+ // signal number is returned).
+ *sig = ::sigwait (set, 0);
+ return *sig;
+# else
+ errno = ::sigwait (set, sig);
+# endif /* DIGITAL_UNIX */
if (errno == -1)
return -1;
else
@@ -4903,8 +4996,8 @@ ACE_OS::thr_setprio (ACE_hthread_t thr_id, int prio)
# endif /* ACE_HAS_DCE_DRAFT4_THREADS */
#elif defined (ACE_HAS_WTHREADS)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (thr_id, prio),
- ace_result_),
- int, -1);
+ ace_result_),
+ int, -1);
#elif defined (VXWORKS)
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::taskPrioritySet (thr_id, prio),
ace_result_),
@@ -5486,8 +5579,8 @@ ACE_OS::hostname (char name[], size_t maxnamelen)
// ACE_TRACE ("ACE_OS::hostname");
#if defined (ACE_WIN32)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name, LPDWORD (&maxnamelen)),
- ace_result_), int, -1);
-#elif defined (VXWORKS)
+ ace_result_), int, -1);
+#elif defined (VXWORKS) || defined (CHORUS)
ACE_OSCALL_RETURN (::gethostname (name, maxnamelen), int, -1);
#else /* !ACE_WIN32 */
struct utsname host_info;
@@ -5677,15 +5770,21 @@ ACE_OS::dlopen (ACE_DL_TYPE filename, int mode)
void *handle;
ACE_OSCALL (::dlopen (filename, mode), void *, 0, handle);
#if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
- // Some systems (e.g., SunOS4) do not automatically call _init(), so
- // we'll have to call it manually.
-
- void *ptr;
+ 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, "_init"), void *, 0, ptr);
+ ACE_OSCALL (::dlsym (handle, "_init"), void *, 0, ptr);
- if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly.
- return 0;
+ 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)
@@ -5751,6 +5850,8 @@ ACE_OS::exit (int status)
// ACE_TRACE ("ACE_OS::exit");
#if defined (ACE_WIN32)
::ExitProcess ((UINT) status);
+#elif defined (ACE_PSOSIM)
+ ::u_exit (status);
#else
::exit (status);
#endif /* ACE_WIN32 */
@@ -5914,12 +6015,12 @@ ACE_OS::getrusage (int who, struct rusage *ru)
FILETIME dummy_1, 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);
+ &dummy_1, // start
+ &dummy_2, // exited
+ &ru->ru_stime,
+ &ru->ru_utime),
+ ace_result_),
+ int, -1);
#else
ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1);
#endif /* ACE_WIN32 */
@@ -6050,8 +6151,13 @@ ACE_OS::msync (void *addr, size_t len, int 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);
@@ -6515,7 +6621,7 @@ ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, off_
if (len == 0)
len = ::GetFileSize (lock->handle_, NULL);
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, LOCKFILE_EXCLUSIVE_LOCK, 0, len, 0, &lock->overlapped_),
- ace_result_), int, -1);
+ ace_result_), int, -1);
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -6542,7 +6648,7 @@ ACE_OS::flock_rdlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, off_
if (len == 0)
len = ::GetFileSize (lock->handle_, NULL);
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, 0, 0, len, 0, &lock->overlapped_),
- ace_result_), int, -1);
+ ace_result_), int, -1);
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -6568,8 +6674,11 @@ ACE_OS::flock_trywrlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, o
lock->overlapped_.Offset = start;
if (len == 0)
len = ::GetFileSize (lock->handle_, NULL);
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, 0, len, 0, &lock->overlapped_),
- ace_result_), int, -1);
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
+ LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
+ 0, len, 0,
+ &lock->overlapped_),
+ ace_result_), int, -1);
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -6586,8 +6695,10 @@ ACE_OS::flock_trywrlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, o
// Does not block, if no access, returns -1 and set errno = EBUSY;
ACE_OSCALL (::fcntl (lock->handle_, F_SETLK, &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 */
@@ -6602,8 +6713,11 @@ ACE_OS::flock_tryrdlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, o
lock->overlapped_.Offset = start;
if (len == 0)
len = ::GetFileSize (lock->handle_, NULL);
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, LOCKFILE_FAIL_IMMEDIATELY, 0, len, 0, &lock->overlapped_),
- ace_result_), int, -1);
+ ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
+ LOCKFILE_FAIL_IMMEDIATELY,
+ 0, len, 0,
+ &lock->overlapped_),
+ ace_result_), int, -1);
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -6620,8 +6734,10 @@ ACE_OS::flock_tryrdlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, o
// Does not block, if no access, returns -1 and set errno = EBUSY;
ACE_OSCALL (::fcntl (lock->handle_, F_SETLK, &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 */
@@ -6637,7 +6753,7 @@ ACE_OS::flock_unlock (ACE_OS::ace_flock_t *lock, short whence, off_t start, off_
if (len == 0)
len = ::GetFileSize (lock->handle_, NULL);
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnlockFileEx (lock->handle_, 0, len, 0, &lock->overlapped_),
- ace_result_), int, -1);
+ ace_result_), int, -1);
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -6678,7 +6794,11 @@ ACE_OS::execv (const char *path, char *const argv[])
ACE_NOTSUP_RETURN (-1);
#elif defined (ACE_WIN32)
+#if defined (__BORLANDC__) // VSB
+ return ::execv (path, 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
@@ -6697,7 +6817,11 @@ ACE_OS::execve (const char *path, char *const argv[], char *const envp[])
ACE_NOTSUP_RETURN (-1);
#elif defined (ACE_WIN32)
+#if defined (__BORLANDC__) // VSB
+ return ::execve (path, argv, 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
@@ -6715,7 +6839,11 @@ ACE_OS::execvp (const char *file, char *const argv[])
ACE_NOTSUP_RETURN (-1);
#elif defined (ACE_WIN32)
+#if defined (__BORLANDC__) // VSB
+ return ::execvp (file, 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
@@ -6737,7 +6865,11 @@ ACE_OS::fdopen (ACE_HANDLE handle, const char *mode)
if (crt_handle != -1)
{
+#if defined(__BORLANDC__) // VSB
+ file = ::_fdopen (crt_handle, (char *) mode);
+#else
file = ::_fdopen (crt_handle, mode);
+#endif /* __BORLANDC__ */
if (!file)
::_close (crt_handle);
@@ -6769,14 +6901,14 @@ ACE_OS::getrlimit (int resource, struct rlimit *rl)
{
// ACE_TRACE ("ACE_OS::getrlimit");
-#if defined (ACE_WIN32) || defined (ACE_LACKS_RLIMIT)
+#if defined (ACE_LACKS_RLIMIT)
ACE_UNUSED_ARG (resource);
ACE_UNUSED_ARG (rl);
ACE_NOTSUP_RETURN (-1);
#else
ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1);
-#endif /* ACE_WIN32 */
+#endif /* ACE_LACKS_RLIMIT */
}
ACE_INLINE int
@@ -6784,14 +6916,14 @@ ACE_OS::setrlimit (int resource, ACE_SETRLIMIT_TYPE *rl)
{
// ACE_TRACE ("ACE_OS::setrlimit");
-#if defined (ACE_WIN32) || defined (ACE_LACKS_RLIMIT)
+#if defined (ACE_LACKS_RLIMIT)
ACE_UNUSED_ARG (resource);
ACE_UNUSED_ARG (rl);
ACE_NOTSUP_RETURN (-1);
#else
ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1);
-#endif /* ACE_WIN32 */
+#endif /* ACE_LACKS_RLIMIT */
}
ACE_INLINE int
@@ -6852,142 +6984,6 @@ ACE_OS::dup2 (ACE_HANDLE oldhandle, ACE_HANDLE newhandle)
#endif /* ACE_WIN32 */
}
-#if ! defined (ACE_WIN32) && ! defined (ACE_HAS_LONGLONG_T)
-ACE_INLINE
-ACE_U_LongLong::ACE_U_LongLong (const u_long lo, const u_long hi)
- : hi_ (hi), lo_ (lo)
-{
-}
-
-ACE_INLINE u_long
-ACE_U_LongLong::hi (void) const
-{
- return hi_;
-}
-
-ACE_INLINE u_long
-ACE_U_LongLong::lo (void) const
-{
- return lo_;
-}
-
-ACE_INLINE void
-ACE_U_LongLong::hi (const u_long hi)
-{
- hi_ = hi;
-}
-
-ACE_INLINE void
-ACE_U_LongLong::lo (const u_long lo)
-{
- lo_ = lo;
-}
-
-ACE_INLINE
-ACE_U_LongLong::~ACE_U_LongLong (void)
-{
-}
-
-ACE_INLINE int
-ACE_U_LongLong::operator== (const ACE_U_LongLong &ll) const
-{
- return hi_ == ll.hi_ && lo_ == ll.lo_;
-}
-
-ACE_INLINE int
-ACE_U_LongLong::operator!= (const ACE_U_LongLong &ll) const
-{
- return ! (*this == ll);
-}
-
-ACE_INLINE int
-ACE_U_LongLong::operator< (const ACE_U_LongLong &ll) const
-{
- return hi_ < ll.hi_ ? 1
- : hi_ > ll.hi_ ? 0
- : lo_ < ll.lo_;
-}
-
-ACE_INLINE int
-ACE_U_LongLong::operator<= (const ACE_U_LongLong &ll) const
-{
- return hi_ < ll.hi_ ? 1
- : hi_ > ll.hi_ ? 0
- : lo_ <= ll.lo_;
-}
-
-ACE_INLINE int
-ACE_U_LongLong::operator> (const ACE_U_LongLong &ll) const
-{
- return hi_ > ll.hi_ ? 1
- : hi_ < ll.hi_ ? 0
- : lo_ > ll.lo_;
-}
-
-ACE_INLINE int
-ACE_U_LongLong::operator>= (const ACE_U_LongLong &ll) const
-{
- return hi_ > ll.hi_ ? 1
- : hi_ < ll.hi_ ? 0
- : lo_ >= ll.lo_;
-}
-
-ACE_INLINE
-ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &ll)
- : hi_ (ll.hi_),
- lo_ (ll.lo_)
-{
-}
-
-ACE_INLINE ACE_U_LongLong &
-ACE_U_LongLong::operator= (const ACE_U_LongLong &ll)
-{
- hi_ = ll.hi_;
- lo_ = ll.lo_;
- return *this;
-}
-
-ACE_INLINE ACE_U_LongLong
-ACE_U_LongLong::operator+ (const ACE_U_LongLong &ll) const
-{
- ACE_U_LongLong ret (lo_ + ll.lo_, hi_ + ll.hi_);
- if (ret.lo_ < ll.lo_) /* carry */ ++ret.hi_;
- return ret;
-}
-
-ACE_INLINE ACE_U_LongLong
-ACE_U_LongLong::operator- (const ACE_U_LongLong &ll) const
-{
- ACE_U_LongLong ret (lo_ - ll.lo_, hi_ - ll.hi_);
- if (lo_ < ll.lo_) /* borrow */ --ret.hi_;
- return ret;
-}
-
-ACE_INLINE u_long
-ACE_U_LongLong::operator/ (const u_long ul) const
-{
- return hi_ / ul * ULONG_MAX + lo_ / ul;
-}
-
-ACE_INLINE ACE_U_LongLong &
-ACE_U_LongLong::operator+= (const ACE_U_LongLong &ll)
-{
- hi_ += ll.hi_;
- lo_ += ll.lo_;
- if (lo_ < ll.lo_) /* carry */ ++hi_;
- return *this;
-}
-
-ACE_INLINE ACE_U_LongLong &
-ACE_U_LongLong::operator-= (const ACE_U_LongLong &ll)
-{
- hi_ -= ll.hi_;
- if (lo_ < ll.lo_) /* borrow */ --hi_;
- lo_ -= ll.lo_;
- return *this;
-}
-#endif /* ! ACE_WIN32 && ! ACE_HAS_LONGLONG_T */
-
ACE_INLINE ACE_hrtime_t
ACE_OS::gethrtime (void)
{
@@ -7058,7 +7054,7 @@ ACE_OS::gethrtime (void)
ACE_OS::readPPCTimeBase (most, least);
return ACE_U_LongLong (least, most);
-#elif defined (ACE_HAS_CLOCK_GETTIME)
+#elif defined (ACE_HAS_CLOCK_GETTIME) || defined (ACE_PSOS)
// e.g., VxWorks (besides POWERPC && GreenHills) . . .
struct timespec ts;
@@ -7109,6 +7105,24 @@ ACE_OS::fork (void)
#endif /* ACE_WIN32 */
}
+ACE_INLINE int
+ACE_OS::getpagesize (void)
+{
+ // ACE_TRACE ("ACE_OS::getpid");
+#if defined (ACE_WIN32)
+ 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::getpid (void)
{
@@ -7289,6 +7303,11 @@ ACE_OS::sleep (u_int seconds)
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_sec = 0;
+ ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &wait), int, -1);
#else
ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
#endif /* ACE_WIN32 */
@@ -7319,6 +7338,39 @@ ACE_OS::nanosleep (const struct timespec *requested,
// 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)
+ 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
+ return 0;
#else
ACE_UNUSED_ARG (remaining);
@@ -7373,6 +7425,48 @@ ACE_Str_Buf::ACE_Str_Buf (strbuf &sb)
this->buf = sb.buf;
}
+#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR)
+ACE_INLINE size_t
+ACE_OS::strlen (const wchar_t *s)
+{
+ // ACE_TRACE ("ACE_OS::strlen");
+#if defined (ACE_HAS_UNICODE)
+ return ::wcslen (s);
+#else
+# if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
+ return wcslen (s);
+# else
+ u_int len = 0;
+
+ while (*s++ != 0)
+ len++;
+
+ return len;
+# endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
+#endif /* ACE_HAS_UNICODE */
+}
+
+ACE_INLINE wchar_t *
+ACE_OS::strcpy (wchar_t *s, const wchar_t *t)
+{
+ // ACE_TRACE ("ACE_OS::strcpy");
+#if defined (ACE_HAS_UNICODE)
+ return ::wcscpy (s, t);
+#else
+# if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
+ return wcscpy (s, t);
+# else
+ wchar_t *result = s;
+
+ while ((*s++ = *t++) != 0)
+ continue;
+
+ return result;
+# endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
+#endif /* ACE_HAS_UNICODE */
+}
+#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */
+
#if defined (ACE_HAS_UNICODE)
ACE_INLINE wchar_t *
@@ -7410,13 +7504,6 @@ ACE_OS::strcmp (const wchar_t *s, const wchar_t *t)
return ::wcscmp (s, t);
}
-ACE_INLINE wchar_t *
-ACE_OS::strcpy (wchar_t *s, const wchar_t *t)
-{
- // ACE_TRACE ("ACE_OS::strcpy");
- return ::wcscpy (s, t);
-}
-
ACE_INLINE wint_t
ACE_OS::to_lower (wint_t c)
{
@@ -7424,13 +7511,6 @@ ACE_OS::to_lower (wint_t c)
return ::towlower (c);
}
-ACE_INLINE size_t
-ACE_OS::strlen (const wchar_t *s)
-{
- // ACE_TRACE ("ACE_OS::strlen");
- return ::wcslen (s);
-}
-
ACE_INLINE int
ACE_OS::strcasecmp (const wchar_t *s, const wchar_t *t)
{
@@ -7443,21 +7523,17 @@ ACE_OS::strcasecmp (const wchar_t *s, const wchar_t *t)
// equal.
int result = 0;
- if (ACE_OS::strlen (s) != ACE_OS::strlen (t))
- result = 1;
- else
- {
- for (;
- *s != '\0' && *t != '\0';
- ++s, ++t)
- if (ACE_OS::to_lower (*s) != ACE_OS::to_lower (*t))
- {
- result = ((ACE_OS::to_lower (*s) < ACE_OS::to_lower (*t)) ? -1 : 1);
- break;
- }
- }
-
- return result; // == 0 for match, else 1
+ do
+ {
+ int a = ACE_OS::to_lower (*s);
+ int b = ACE_OS::to_lower (*t);
+ result = ((a < b) ? -1 : (a > b));
+ if (result != 0)
+ break;
+ } while (*s++ != '\0' && *t++ != '\0');
+ // paranoid termination condition
+
+ return result; // == 0 for match, else 1
#else /* ACE_WIN32 */
return ::_wcsicmp (s, t);
@@ -7549,7 +7625,12 @@ ACE_INLINE wchar_t *
ACE_OS::strdup (const wchar_t *s)
{
// ACE_TRACE ("ACE_OS::strdup");
+#if defined (__BORLANDC__)
+ wchar_t *buffer = (wchar_t *) malloc (strlen (s) * sizeof (wchar_t) + 1);
+ return ::wcscpy (buffer, s);
+#else
return ::wcsdup (s);
+#endif /* __BORLANDC__ */
}
ACE_INLINE int
@@ -7563,7 +7644,7 @@ ACE_OS::hostname (wchar_t *name, size_t maxnamelen)
{
// ACE_TRACE ("ACE_OS::hostname");
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameW (name, LPDWORD (&maxnamelen)),
- ace_result_), int, -1);
+ ace_result_), int, -1);
}
ACE_INLINE ACE_HANDLE
@@ -7666,7 +7747,11 @@ ACE_INLINE int
ACE_OS::stat (const wchar_t *file, struct stat *stp)
{
// ACE_TRACE ("ACE_OS::stat");
+#if defined (__BORLANDC__)
+ ACE_OSCALL_RETURN (::_wstat (file, stp), int, -1);
+#else
ACE_OSCALL_RETURN (::_wstat (file, (struct _stat *) stp), int, -1);
+#endif /* __BORLANDC__ */
}
ACE_INLINE int