summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2005-07-07 22:14:37 +0000
committerSteve Huston <shuston@riverace.com>2005-07-07 22:14:37 +0000
commit44a3cdbee0274d016865ed9f533827683532edf4 (patch)
treec8431a74505fd63945db65d97c29397f4d81b7f8 /ace
parent65ca46676121b7710a40e6231a208ceb1d9813a3 (diff)
downloadATCD-44a3cdbee0274d016865ed9f533827683532edf4.tar.gz
ChangeLogTag:Thu Jul 7 18:11:29 2005 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace')
-rw-r--r--ace/Log_Msg.cpp97
-rw-r--r--ace/OS_NS_string.cpp32
-rw-r--r--ace/OS_NS_string.h11
-rw-r--r--ace/README3
-rw-r--r--ace/Select_Reactor_Base.cpp2
-rw-r--r--ace/config-WinCE.h3
-rw-r--r--ace/config-mvs.h2
-rw-r--r--ace/config-openvms.h1
-rw-r--r--ace/config-psos-diab-mips.h2
-rw-r--r--ace/config-psos-diab-ppc.h2
-rw-r--r--ace/config-psos-diab.h2
-rw-r--r--ace/config-psos-tm.h2
-rw-r--r--ace/config-psosim-g++.h2
-rw-r--r--ace/config-rtems.h1
-rw-r--r--ace/config-sunos5.7.h2
-rw-r--r--ace/config-tandem-nsk-mips-v2.h3
-rw-r--r--ace/config-tandem-nsk-mips-v3.h3
-rw-r--r--ace/config-vxworks5.x.h1
-rw-r--r--ace/config-win32-interix.h2
-rw-r--r--ace/config-win32-visualage.h2
20 files changed, 58 insertions, 117 deletions
diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp
index 40ef21db236..2b79e357577 100644
--- a/ace/Log_Msg.cpp
+++ b/ace/Log_Msg.cpp
@@ -952,15 +952,6 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
ACE_TRACE ("ACE_Log_Msg::log");
// External decls.
-// sys_nerr is deprecated on some platforms, and is declared by
-// system header files on others.
-#if ! (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) \
- && !defined(__MINGW32__) && !defined(__GLIBC__) \
- && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) \
- && !defined(__APPLE__) \
- && !defined(__QNX__)
- extern int sys_nerr;
-#endif /* ! (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) && ... */
typedef void (*PTF)(...);
// Check if there were any conditional values set.
@@ -1229,33 +1220,34 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case 'p': // <errno> string, ala perror()
{
- errno = ACE::map_errno (this->errnum ());
-#if !defined (ACE_HAS_WINCE) /* CE doesn't do strerror() */
- if (errno >= 0
-# if !defined (__GLIBC__) /* sys_nerr is deprecated on some
- platforms. */
- && errno < sys_nerr
-# endif /* !__GLIBC__ */
- )
+ errno = 0;
+ char *msg;
+ msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
+ // Windows can try to translate the errnum using
+ // system calls if strerror() doesn't get anything useful.
+#if defined (ACE_WIN32)
+ if (errno == 0)
{
-# if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
+#endif
+
+#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls: %ls"));
-# else
+#else
ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
-# endif
+#endif
if (can_check)
this_len = ACE_OS::snprintf
(bp, bspace, format, va_arg (argp, ACE_TCHAR *),
- ACE_TEXT_CHAR_TO_TCHAR (ACE_OS::strerror (errno)));
+ ACE_TEXT_CHAR_TO_TCHAR (msg));
else
this_len = ACE_OS::sprintf
(bp, format, va_arg (argp, ACE_TCHAR *),
- ACE_TEXT_CHAR_TO_TCHAR (ACE_OS::strerror (errno)));
+ ACE_TEXT_CHAR_TO_TCHAR (msg));
+#if defined (ACE_WIN32)
}
else
-#endif /* !ACE_HAS_WINCE */
{
-#if defined (ACE_WIN32)
+ errno = ACE::map_errno (this->errnum ());
ACE_TCHAR *lpMsgBuf = 0;
// PharLap can't do FormatMessage, so try for socket
@@ -1312,24 +1304,8 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
// Free the buffer.
::LocalFree (lpMsgBuf);
}
-#elif !defined (ACE_HAS_WINCE)
- ACE_OS::strcpy (fp,
- ACE_LIB_TEXT (
- "s: <unknown error> = %d"));
- if (can_check)
- this_len = ACE_OS::snprintf
- (bp, bspace,
- format,
- va_arg (argp, ACE_TCHAR *),
- errno);
- else
- this_len = ACE_OS::sprintf
- (bp,
- format,
- va_arg (argp, ACE_TCHAR *),
- errno);
-#endif /* ACE_WIN32 */
}
+#endif /* ACE_WIN32 */
ACE_UPDATE_COUNT (bspace, this_len);
break;
}
@@ -1353,15 +1329,16 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case 'm': // Format the string assocated with the errno value.
{
- errno = ACE::map_errno (this->errnum ());
- if (errno >= 0
-
-# if !defined (__GLIBC__) /* sys_nerr is deprecated on some
- platforms. */
- && errno < sys_nerr
-# endif /* !__GLIBC__ */
- )
+ errno = 0;
+ char *msg;
+ msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
+ // Windows can try to translate the errnum using
+ // system calls if strerror() doesn't get anything useful.
+#if defined (ACE_WIN32)
+ if (errno == 0)
{
+#endif
+
#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
#else /* ACE_WIN32 && ACE_USES_WCHAR */
@@ -1369,16 +1346,15 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
#endif
if (can_check)
this_len = ACE_OS::snprintf
- (bp, bspace, format,
- ACE_TEXT_CHAR_TO_TCHAR (ACE_OS::strerror (errno)));
+ (bp, bspace, format, ACE_TEXT_CHAR_TO_TCHAR (msg));
else
this_len = ACE_OS::sprintf
- (bp, format,
- ACE_TEXT_CHAR_TO_TCHAR (ACE_OS::strerror (errno)));
+ (bp, format, ACE_TEXT_CHAR_TO_TCHAR (msg));
+#if defined (ACE_WIN32)
}
else
{
-#if defined (ACE_WIN32)
+ errno = ACE::map_errno (this->errnum ());
ACE_TCHAR *lpMsgBuf = 0;
// PharLap can't do FormatMessage, so try for socket
@@ -1426,19 +1402,8 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
// Free the buffer.
::LocalFree (lpMsgBuf);
}
-#elif !defined (ACE_HAS_WINCE)
- // Ignore the built format... if this is a problem,
- // this part can be changed to build another string
- // and pass that with the complete conversion specs.
- if (can_check)
- this_len = ACE_OS::snprintf
- (bp, bspace,
- ACE_LIB_TEXT ("<unknown error> = %d"), errno);
- else
- this_len = ACE_OS::sprintf
- (bp, ACE_LIB_TEXT ("<unknown error> = %d"), errno);
-#endif /* ACE_WIN32 */
}
+#endif /* ACE_WIN32 */
ACE_UPDATE_COUNT (bspace, this_len);
break;
}
diff --git a/ace/OS_NS_string.cpp b/ace/OS_NS_string.cpp
index 608ce8cb2f7..a2fa754141c 100644
--- a/ace/OS_NS_string.cpp
+++ b/ace/OS_NS_string.cpp
@@ -16,14 +16,6 @@ ACE_RCSID (ace,
# include "ace/OS_NS_stdlib.h"
#endif /* ACE_HAS_WCHAR */
-#if defined (ACE_LACKS_SYS_NERR)
-# if defined (__rtems__)
-int sys_nerr = EWOULDBLOCK + 1; // definitely a hack.
-# else
-int sys_nerr = ERRMAX + 1;
-# endif /* __rtems__ */
-#endif /* ACE_LACKS_SYS_NERR */
-
#if !defined (ACE_HAS_MEMCHR)
const void *
ACE_OS::memchr_emulation (const void *s, int c, size_t len)
@@ -108,17 +100,35 @@ ACE_OS::strecpy (wchar_t *s, const wchar_t *t)
char *
ACE_OS::strerror (int errnum)
{
+ static char ret_errortext[128];
+
if (ACE::is_sock_error (errnum))
{
const ACE_TCHAR *errortext = ACE::sock_error (errnum);
- static char ret_errortext[128];
- ACE_OS::strncpy (ret_errortext, ACE_TEXT_ALWAYS_CHAR(errortext), sizeof(ret_errortext));
+ ACE_OS::strncpy (ret_errortext,
+ ACE_TEXT_ALWAYS_CHAR (errortext),
+ sizeof (ret_errortext));
return ret_errortext;
}
#if defined (ACE_LACKS_STRERROR)
+ errno = EINVAL;
return ACE_OS::strerror_emulation (errnum);
#else /* ACE_LACKS_STRERROR */
- return ::strerror (errnum);
+ // Adapt to the various ways that strerror() indicates a bad errnum.
+ // Most modern systems set errno to EINVAL. Some older platforms return
+ // a pointer to a NULL string. This code makes the behavior more consistent
+ // across platforms. On a bad errnum, we make a string with the error number
+ // and set errno to EINVAL.
+ ACE_Errno_Guard g (errno);
+ errno = 0;
+ char *errmsg = ::strerror (errnum);
+ if (errno == EINVAL || ACE_OS::strlen (errmsg) == 0)
+ {
+ ACE_OS::sprintf (ret_errortext, "Unknown error %d", errnum);
+ errmsg = ret_errortext;
+ g = EINVAL;
+ }
+ return errmsg;
#endif /* ACE_LACKS_STRERROR */
}
diff --git a/ace/OS_NS_string.h b/ace/OS_NS_string.h
index 2f357ce7ab5..b5d49bd9446 100644
--- a/ace/OS_NS_string.h
+++ b/ace/OS_NS_string.h
@@ -34,11 +34,6 @@
#endif
#define ACE_EXPORT_MACRO ACE_Export
-
-# if defined (ACE_LACKS_SYS_NERR)
-extern ACE_Export int sys_nerr;
-# endif /* ACE_LACKS_SYS_NERR */
-
namespace ACE_OS {
/** @name Functions from <cstring>
@@ -164,7 +159,11 @@ namespace ACE_OS {
wchar_t *strecpy (wchar_t *s, const wchar_t *t);
#endif /* ACE_HAS_WCHAR */
- /// Returns a system error message.
+ /*
+ ** Returns a system error message. If the supplied errnum is out of range,
+ ** a string of the form "Unknown error %d" is used to format the string
+ ** whose pointer is returned and errno is set to EINVAL.
+ */
extern ACE_Export
char *strerror (int errnum);
diff --git a/ace/README b/ace/README
index 01b1831830e..b14aec2c856 100644
--- a/ace/README
+++ b/ace/README
@@ -1037,9 +1037,6 @@ ACE_LACKS_WCSRCHR Platform/compiler lacks wcsrchr ()
function
ACE_LACKS_SWAB Platform/compiler lacks
swab () function.
-ACE_LACKS_SYS_NERR Platforms/compiler lacks the
- sys_nerr variable (e.g.,
- VxWorks and MVS).
ACE_LACKS_SYSTIME_H <time.h> doesn't automatically
#include /**/ <sys/time.h>
ACE_LACKS_SYS_MSG_H Platform lacks sys/msg.h
diff --git a/ace/Select_Reactor_Base.cpp b/ace/Select_Reactor_Base.cpp
index bd824e90ea1..9292548f918 100644
--- a/ace/Select_Reactor_Base.cpp
+++ b/ace/Select_Reactor_Base.cpp
@@ -5,7 +5,7 @@
#include "ace/Thread.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/SOCK_Connector.h"
-#include "ace/Timer_Heap.h"
+#include "ace/Timer_Queue.h"
#include "ace/Log_Msg.h"
#include "ace/Signal.h"
#include "ace/OS_NS_fcntl.h"
diff --git a/ace/config-WinCE.h b/ace/config-WinCE.h
index 5f7ccb11ac8..97e64383eac 100644
--- a/ace/config-WinCE.h
+++ b/ace/config-WinCE.h
@@ -188,9 +188,6 @@
#define ACE_LACKS_ISATTY
#define ACE_LACKS_STRERROR
-#define ERRMAX 256 // Needed for following define
-#define ACE_LACKS_SYS_NERR // Needed for sys_nerr in Log_Msg.cpp
-
#define ACE_LACKS_CUSERID
#define ACE_LACKS_CHDIR
#define ACE_LACKS_ENV
diff --git a/ace/config-mvs.h b/ace/config-mvs.h
index 30e75c159f9..f3982f72e7b 100644
--- a/ace/config-mvs.h
+++ b/ace/config-mvs.h
@@ -15,7 +15,6 @@
#define howmany __howmany /* MVS uses different names than most others */
#define fd_mask __fd_mask
#define MAXNAMLEN __DIR_NAME_MAX
-#define ERRMAX __sys_nerr
#if defined (log) /* log is a macro in math.h */
# undef log /* conflicts with log function in ACE */
#endif /* log */
@@ -95,7 +94,6 @@
#define ACE_LACKS_SIGINFO_H
#define ACE_LACKS_STRRECVFD
#define ACE_LACKS_SYSTIME_H
-#define ACE_LACKS_SYS_NERR
#define ACE_LACKS_NETINET_TCP_H
#define ACE_LACKS_THREAD_PROCESS_SCOPING
#define ACE_LACKS_THREAD_STACK_ADDR
diff --git a/ace/config-openvms.h b/ace/config-openvms.h
index 9533109886f..759f338f113 100644
--- a/ace/config-openvms.h
+++ b/ace/config-openvms.h
@@ -16,7 +16,6 @@
#pragma message disable UNSCOMZER
//#define MAXPATHLEN 255
-//#define ERRMAX sys_nerr
//#define howmany __howmany
//#define MAXHOSTNAMELEN 255
//#define MAXNAMLEN FILENAME_MAX
diff --git a/ace/config-psos-diab-mips.h b/ace/config-psos-diab-mips.h
index 5013201a244..9427fa7962b 100644
--- a/ace/config-psos-diab-mips.h
+++ b/ace/config-psos-diab-mips.h
@@ -204,8 +204,6 @@
#define ACE_LACKS_SYSV_SHMEM
-// #define ACE_LACKS_SYS_NERR
-
#define ACE_LACKS_SYS_TYPES_H
#define ACE_LACKS_TIMESPEC_T
diff --git a/ace/config-psos-diab-ppc.h b/ace/config-psos-diab-ppc.h
index 39def652617..a73d96aecdf 100644
--- a/ace/config-psos-diab-ppc.h
+++ b/ace/config-psos-diab-ppc.h
@@ -215,8 +215,6 @@
#define ACE_LACKS_SYSV_SHMEM
-#define ACE_LACKS_SYS_NERR
-
#define ACE_LACKS_SYS_TYPES_H
#define ACE_LACKS_TIMESPEC_T
diff --git a/ace/config-psos-diab.h b/ace/config-psos-diab.h
index 7824151310c..f7a4b804164 100644
--- a/ace/config-psos-diab.h
+++ b/ace/config-psos-diab.h
@@ -197,8 +197,6 @@
#define ACE_LACKS_SYSV_SHMEM
-#define ACE_LACKS_SYS_NERR
-
#define ACE_LACKS_SYS_TYPES_H
#define ACE_LACKS_TIMESPEC_T
diff --git a/ace/config-psos-tm.h b/ace/config-psos-tm.h
index 35ee52422eb..02c510f016d 100644
--- a/ace/config-psos-tm.h
+++ b/ace/config-psos-tm.h
@@ -166,8 +166,6 @@
#define ACE_LACKS_SYSV_SHMEM
-#define ACE_LACKS_SYS_NERR // psos/tm does not have sys_nerr
-
#define ACE_LACKS_SYS_TYPES_H
#define ACE_LACKS_TIMESPEC_T
diff --git a/ace/config-psosim-g++.h b/ace/config-psosim-g++.h
index fa71b463fdc..703edc1c950 100644
--- a/ace/config-psosim-g++.h
+++ b/ace/config-psosim-g++.h
@@ -210,8 +210,6 @@
#define ACE_LACKS_SYSV_SHMEM
#define ACE_LACKS_DUP2
-#define ACE_LACKS_SYS_NERR
-
#define ACE_LACKS_TIMESPEC_T
#define ACE_LACKS_UCONTEXT_H
diff --git a/ace/config-rtems.h b/ace/config-rtems.h
index 0ec7eb27342..2cbb47fb4cd 100644
--- a/ace/config-rtems.h
+++ b/ace/config-rtems.h
@@ -117,7 +117,6 @@
#define ACE_LACKS_SYS_MSG_H
#define ACE_LACKS_SYSV_SHMEM
#define ACE_LACKS_SYSCALL
-#define ACE_LACKS_SYS_NERR
#define ACE_LACKS_UALARM_PROTOTYPE
#define ACE_LACKS_UCONTEXT_H
#define ACE_HAS_NONCONST_WRITEV
diff --git a/ace/config-sunos5.7.h b/ace/config-sunos5.7.h
index b968963154d..17b5ec18e28 100644
--- a/ace/config-sunos5.7.h
+++ b/ace/config-sunos5.7.h
@@ -77,8 +77,6 @@ typedef unsigned long long uint64_t;
#define ACE_HAS_SNPRINTF
#if defined (__sparcv9)
-#define ERRMAX 256 /* Needed for following define */
-#define ACE_LACKS_SYS_NERR
#define _LP64
#define ACE_SIZEOF_LONG 8 /* Needed to circumvent compiler bug #4294969 */
#endif /* __sparcv9 */
diff --git a/ace/config-tandem-nsk-mips-v2.h b/ace/config-tandem-nsk-mips-v2.h
index a6799bc803c..6026f204197 100644
--- a/ace/config-tandem-nsk-mips-v2.h
+++ b/ace/config-tandem-nsk-mips-v2.h
@@ -217,9 +217,6 @@ typedef enum CMA_T_SCHED_POLICY {
// Platform lacks setregid()
#define ACE_LACKS_SETREGID
-// Platforms/compiler lacks the sys_nerr variable
-#define ACE_LACKS_SYS_NERR
-
// Compile using multi-thread libraries
#define ACE_MT_SAFE 1
diff --git a/ace/config-tandem-nsk-mips-v3.h b/ace/config-tandem-nsk-mips-v3.h
index f1221eaa94c..23371f54c29 100644
--- a/ace/config-tandem-nsk-mips-v3.h
+++ b/ace/config-tandem-nsk-mips-v3.h
@@ -218,9 +218,6 @@ typedef enum CMA_T_SCHED_POLICY {
// Platform lacks setregid()
#define ACE_LACKS_SETREGID
-// Platforms/compiler lacks the sys_nerr variable
-#define ACE_LACKS_SYS_NERR
-
// Compile using multi-thread libraries
#define ACE_MT_SAFE 1
diff --git a/ace/config-vxworks5.x.h b/ace/config-vxworks5.x.h
index 2ba6a0f6953..d3299b203be 100644
--- a/ace/config-vxworks5.x.h
+++ b/ace/config-vxworks5.x.h
@@ -176,7 +176,6 @@
#define ACE_LACKS_SYSCALL
#define ACE_LACKS_SYSTIME_H
#define ACE_LACKS_SYSV_SHMEM
-#define ACE_LACKS_SYS_NERR
#define ACE_LACKS_TELLDIR
#define ACE_LACKS_TEMPNAM
#define ACE_LACKS_TIMESPEC_T
diff --git a/ace/config-win32-interix.h b/ace/config-win32-interix.h
index d39a32cd1f0..1ab9a73ac11 100644
--- a/ace/config-win32-interix.h
+++ b/ace/config-win32-interix.h
@@ -17,8 +17,6 @@
# define ACE_LACKS_RWLOCK_T
# define ACE_LACKS_GETPGID // Don't have getpgid(), have setpgid() though...
# define ACE_LACKS_UCONTEXT_H
-# define ACE_LACKS_SYS_NERR // If we don't have sys_nerr...
-# define ERRMAX 256 // Then we define ERRMAX .
# define ACE_HAS_REENTRANT_FUNCTIONS
# define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS // Don't have gethostbyaddr_r and friends.
# define ACE_HAS_DIRENT
diff --git a/ace/config-win32-visualage.h b/ace/config-win32-visualage.h
index 000417540d6..4e30082e635 100644
--- a/ace/config-win32-visualage.h
+++ b/ace/config-win32-visualage.h
@@ -48,8 +48,6 @@
#define FD_SETSIZE 1024
//These need to be defined for VisualAgeC++
-#define ERRMAX 256 /* Needed for following define */
-#define ACE_LACKS_SYS_NERR /* Needed for sys_nerr in Log_Msg.cpp */
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES /* For signal handling */
#define ACE_LACKS_MKTEMP
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES