summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-29 16:12:07 +0000
committervzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-29 16:12:07 +0000
commitff3f906033425bc675d4b2892cb5565eca885d93 (patch)
treeb7389a0b4746c44e5d1bc5b10aa92022a10debde
parent039255b67ea0c1006c58cb58ff00afcc610e61e9 (diff)
downloadATCD-ff3f906033425bc675d4b2892cb5565eca885d93.tar.gz
ChangeLogTag: Thu May 29 16:08:01 UTC 2008 Vladimir Zykov <vzykov@prismtech.com>
-rw-r--r--ACE/ChangeLog13
-rw-r--r--ACE/ace/OS_NS_stdlib.cpp91
-rw-r--r--ACE/ace/OS_NS_stdlib.h19
-rw-r--r--ACE/ace/OS_NS_stdlib.inl25
-rw-r--r--ACE/configure.ac10
5 files changed, 143 insertions, 15 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index a290c9201dd..e0ad7835a95 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,16 @@
+Thu May 29 16:08:01 UTC 2008 Vladimir Zykov <vzykov@prismtech.com>
+
+ * ace/OS_NS_stdlib.cpp:
+ * ace/OS_NS_stdlib.inl:
+ * ace/OS_NS_stdlib.h:
+
+ Added strtoull() function to ACE_OS.
+
+ * configure.ac:
+
+ Added a check for presence of strtoull() and wcstoull()
+ in the build environment.
+
Thu May 29 15:15:00 UTC 2008 Simon Massey <sma at prismtech dot com>
* ace/INET_Addr.cpp:
diff --git a/ACE/ace/OS_NS_stdlib.cpp b/ACE/ace/OS_NS_stdlib.cpp
index a04086d8a2b..9bc2b2fa4a4 100644
--- a/ACE/ace/OS_NS_stdlib.cpp
+++ b/ACE/ace/OS_NS_stdlib.cpp
@@ -15,6 +15,7 @@ ACE_RCSID (ace,
#include "ace/OS_Memory.h"
#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_ctype.h"
#if defined (ACE_LACKS_MKTEMP) \
|| defined (ACE_LACKS_MKSTEMP) \
@@ -532,7 +533,7 @@ ACE_OS::strtol_emulation (const char *nptr, char **endptr, int base)
*/
do {
c = *s++;
- } while (isspace(c));
+ } while (ACE_OS::ace_isspace(c));
if (c == '-') {
neg = 1;
c = *s++;
@@ -568,10 +569,10 @@ ACE_OS::strtol_emulation (const char *nptr, char **endptr, int base)
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
+ if (ACE_OS::ace_isdigit(c))
c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else if (ACE_OS::ace_isalpha(c))
+ c -= ACE_OS::ace_isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
@@ -612,7 +613,7 @@ ACE_OS::strtoul_emulation (const char *nptr,
*/
do
c = *s++;
- while (isspace(c));
+ while (ACE_OS::ace_isspace(c));
if (c == '-')
{
neg = 1;
@@ -634,10 +635,10 @@ ACE_OS::strtoul_emulation (const char *nptr,
for (acc = 0, any = 0;; c = *s++)
{
- if (isdigit(c))
+ if (ACE_OS::ace_isdigit(c))
c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else if (ACE_OS::ace_isalpha(c))
+ c -= ACE_OS::ace_isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
@@ -655,7 +656,8 @@ ACE_OS::strtoul_emulation (const char *nptr,
{
acc = ULONG_MAX;
errno = ERANGE;
- } else if (neg)
+ }
+ else if (neg)
acc = -acc;
if (endptr != 0)
*endptr = any ? (char *) s - 1 : (char *) nptr;
@@ -663,6 +665,75 @@ ACE_OS::strtoul_emulation (const char *nptr,
}
#endif /* ACE_LACKS_STRTOUL */
+#if defined (ACE_LACKS_STRTOULL)
+ACE_UINT64
+ACE_OS::strtoull_emulation (const char *nptr,
+ char **endptr,
+ register int base)
+{
+ register const char *s = nptr;
+ register ACE_UINT64 acc;
+ register int c;
+ register ACE_UINT64 cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do
+ c = *s++;
+ while (ACE_OS::ace_isspace(c));
+ if (c == '-')
+ {
+ neg = 1;
+ c = *s++;
+ }
+ else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X'))
+ {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ cutoff = (ACE_UINT64) ACE_UINT64_MAX / (ACE_UINT64) base;
+ cutlim = (ACE_UINT64) ACE_UINT64_MAX % (ACE_UINT64) base;
+
+ for (acc = 0, any = 0;; c = *s++)
+ {
+ if (ACE_OS::ace_isdigit(c))
+ c -= '0';
+ else if (ACE_OS::ace_isalpha(c))
+ c -= ACE_OS::ace_isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ any = -1;
+ else
+ {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0)
+ {
+ acc = ACE_UINT64_MAX;
+ errno = ERANGE;
+ }
+ else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = any ? (char *) s - 1 : (char *) nptr;
+ return (acc);
+}
+#endif /* ACE_LACKS_STRTOULL */
#if defined (ACE_LACKS_MKSTEMP)
ACE_HANDLE
@@ -788,7 +859,7 @@ ACE_OS::getprogname_emulation ()
#if !defined (ACE_HAS_SETPROGNAME)
void
-ACE_OS::setprogname_emulation (const char* progname)
+ACE_OS::setprogname_emulation (const char* progname)
{
const char *p = ACE_OS::strrchr (progname, '/');
if (p != 0)
diff --git a/ACE/ace/OS_NS_stdlib.h b/ACE/ace/OS_NS_stdlib.h
index 28a0bbdf072..ba9894c8ca9 100644
--- a/ACE/ace/OS_NS_stdlib.h
+++ b/ACE/ace/OS_NS_stdlib.h
@@ -28,6 +28,8 @@
#include "ace/os_include/os_stdlib.h"
#include /**/ "ace/ACE_export.h"
+#include "ace/Basic_Types.h" /* ACE_UINT64 and intptr_t in inl file */
+
#if defined (ACE_EXPORT_MACRO)
# undef ACE_EXPORT_MACRO
#endif
@@ -272,6 +274,23 @@ namespace ACE_OS {
int base);
#endif /* ACE_LACKS_STRTOUL */
+ /// Converts a string to a 64 bit int value (char version).
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ACE_UINT64 strtoull (const char *s, char **ptr, int base);
+
+#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOULL)
+ /// Converts a string to a 64 bit int value (wchar_t version).
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ACE_UINT64 strtoull (const wchar_t *s, wchar_t **ptr, int base);
+#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */
+
+#if defined (ACE_LACKS_STRTOULL)
+ extern ACE_Export
+ ACE_UINT64 strtoull_emulation (const char *nptr,
+ char **endptr,
+ int base);
+#endif /* ACE_LACKS_STRTOULL */
+
ACE_NAMESPACE_INLINE_FUNCTION
int system (const ACE_TCHAR *s);
diff --git a/ACE/ace/OS_NS_stdlib.inl b/ACE/ace/OS_NS_stdlib.inl
index 2896fef63d4..3ed7b606869 100644
--- a/ACE/ace/OS_NS_stdlib.inl
+++ b/ACE/ace/OS_NS_stdlib.inl
@@ -6,7 +6,6 @@
#include "ace/Object_Manager_Base.h"
#include "ace/OS_NS_string.h"
#include "ace/Global_Macros.h"
-#include "ace/Basic_Types.h" /* intptr_t */
#include "ace/os_include/os_errno.h"
#include "ace/os_include/os_search.h"
@@ -460,6 +459,30 @@ ACE_OS::strtoul (const wchar_t *s, wchar_t **ptr, int base)
}
#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */
+ACE_INLINE ACE_UINT64
+ACE_OS::strtoull (const char *s, char **ptr, int base)
+{
+#if defined (ACE_LACKS_STRTOULL)
+ return ACE_OS::strtoull_emulation (s, ptr, base);
+#elif defined (ACE_WIN32)
+ return ::_strtoui64 (s, ptr, base);
+#else
+ return ::strtoull (s, ptr, base);
+#endif /* ACE_LACKS_STRTOULL */
+}
+
+#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOULL)
+ACE_INLINE ACE_UINT64
+ACE_OS::strtoull (const wchar_t *s, wchar_t **ptr, int base)
+{
+#if defined (ACE_WIN32)
+ return ::_wcstoui64 (s, ptr, base);
+#else
+ return ACE_WCHAR_STD_NAMESPACE::wcstoull (s, ptr, base);
+#endif /* ACE_WIN32 */
+}
+#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOULL */
+
ACE_INLINE int
ACE_OS::system (const ACE_TCHAR *s)
{
diff --git a/ACE/configure.ac b/ACE/configure.ac
index e21a85893c0..db91db456be 100644
--- a/ACE/configure.ac
+++ b/ACE/configure.ac
@@ -2499,8 +2499,8 @@ dnl FIXME: This test may be broken.
dnl
dnl FIXME: This test contains vestigial bits of tests for explicit
dnl template instantiation feature macros, even though support for
-dnl the same has been removed.
-dnl
+dnl the same has been removed.
+dnl
dnl A rewrite to test only whether ACE_TEMPLATES_REQUIRE_SOURCE or
dnl ACE_TEMPLATES_REQUIRE_PRAGMA is clearly needed.
dnl
@@ -3782,6 +3782,8 @@ ACE_CHECK_LACKS_FUNCS(strtol)
ACE_CHECK_LACKS_FUNCS(strtoul)
+ACE_CHECK_LACKS_FUNCS(strtoull)
+
# swab() comes in a number of forms:
# swab (const void*, void*, size_t) is POSIX, XPG4, SUS, SUSv2 standard.
# swab (const char*, char*, size_t) is SVID third edition.
@@ -4116,7 +4118,7 @@ ACE_CHECK_HAS_FUNCS(vasprintf vaswprintf vfwprintf vswprintf)
ACE_CHECK_HAS_FUNCS(wcsnlen)
-ACE_CHECK_LACKS_FUNCS(fgetws fputws itow towlower towupper wcscat wcschr wcscmp wcscpy wcscspn wcslen wcsncat wcsncmp wcsncpy wcsnicmp wcspbrk wcsrchr wcsspn wcsstr wcstod wcstok wcstol wcstoul)
+ACE_CHECK_LACKS_FUNCS(fgetws fputws itow towlower towupper wcscat wcschr wcscmp wcscpy wcscspn wcslen wcsncat wcsncmp wcsncpy wcsnicmp wcspbrk wcsrchr wcsspn wcsstr wcstod wcstok wcstol wcstoul wcstoull)
if test "$ac_cv_func_wcstok" = yes; then
dnl The wcstok() function varies with standards. Check which one we have.
@@ -4672,7 +4674,7 @@ dnl Check for Unix98 pthreads extensions
ACE_CHECK_HAS_FUNCS(pthread_getconcurrency pthread_setconcurrency)
ACE_CHECK_HAS_FUNCS(pthread_attr_setcreatesuspend_np)
-dnl Don't test for pthread_getaffinity_np() or pthread_setaffinity_np()
+dnl Don't test for pthread_getaffinity_np() or pthread_setaffinity_np()
dnl if the system doesn't also have cpu_set_t. The functions are almost
dnl certainly incompatible with our wrapper facade, as we use a "dummy"
dnl cpu_set_t defined in ace/os_include/os_sched.h.