mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
Some missing from merge.
Signed-off-by: Salja <salja2012@hotmail.de>
This commit is contained in:
parent
ec939a5bce
commit
f4be15a7af
1895 changed files with 160408 additions and 53601 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// $Id: OS_NS_stdlib.cpp 97921 2014-10-10 21:58:31Z shuston $
|
||||
|
||||
#include "ace/OS_NS_stdlib.h"
|
||||
|
||||
#include "ace/Default_Constants.h"
|
||||
|
|
@ -26,10 +28,6 @@
|
|||
# include "ace/Numeric_Limits.h"
|
||||
#endif /* ACE_LACKS_MKSTEMP */
|
||||
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
# include "ace/Malloc_Base.h"
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0;
|
||||
|
|
@ -61,21 +59,15 @@ ACE_OS::exit (int status)
|
|||
|
||||
#if defined (ACE_WIN32)
|
||||
::ExitProcess ((UINT) status);
|
||||
#elif !defined ACE_LACKS_EXIT
|
||||
::exit (status);
|
||||
#else
|
||||
ACE_UNUSED_ARG (status);
|
||||
::exit (status);
|
||||
#endif /* ACE_WIN32 */
|
||||
}
|
||||
|
||||
void
|
||||
ACE_OS::free (void *ptr)
|
||||
{
|
||||
#if defined (ACE_LACKS_FREE)
|
||||
ACE_UNUSED_ARG (ptr);
|
||||
#else
|
||||
ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
// You may be asking yourself, why are we doing this? Well, in winbase.h,
|
||||
|
|
@ -140,11 +132,7 @@ ACE_OS::strenvdup (const ACE_TCHAR *str)
|
|||
if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ)
|
||||
{
|
||||
buf_p =
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
(ACE_TCHAR *) ACE_Allocator::instance()->malloc (buf_len * sizeof (ACE_TCHAR));
|
||||
#else
|
||||
(ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR));
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
if (buf_p == 0)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
|
|
@ -289,7 +277,7 @@ ACE_OS::malloc (size_t nbytes)
|
|||
return ACE_MALLOC_FUNC (nbytes);
|
||||
}
|
||||
|
||||
#if defined (ACE_LACKS_MKTEMP) && !defined (ACE_DISABLE_MKTEMP)
|
||||
#if defined (ACE_LACKS_MKTEMP) && !defined (ACE_DISBALE_MKTEMP)
|
||||
ACE_TCHAR *
|
||||
ACE_OS::mktemp (ACE_TCHAR *s)
|
||||
{
|
||||
|
|
@ -297,51 +285,52 @@ ACE_OS::mktemp (ACE_TCHAR *s)
|
|||
if (s == 0)
|
||||
// check for null template string failed!
|
||||
return 0;
|
||||
|
||||
ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX"));
|
||||
if (xxxxxx == 0)
|
||||
// the template string doesn't contain "XXXXXX"!
|
||||
return s;
|
||||
|
||||
// Find an unused filename for this process. It is assumed
|
||||
// that the user will open the file immediately after
|
||||
// getting this filename back (so, yes, there is a race
|
||||
// condition if multiple threads in a process use the same
|
||||
// template). This appears to match the behavior of the
|
||||
// SunOS 5.5 mktemp().
|
||||
bool found = false;
|
||||
for (ACE_TCHAR letter = ACE_TEXT ('a');
|
||||
letter <= ACE_TEXT ('z');
|
||||
++letter)
|
||||
else
|
||||
{
|
||||
ACE_stat sb;
|
||||
ACE_OS::snprintf (xxxxxx, 7,
|
||||
ACE_TEXT ("%05d%c"),
|
||||
(int)ACE_OS::getpid () % 100000,
|
||||
letter);
|
||||
if (ACE_OS::stat (s, &sb) < 0)
|
||||
ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX"));
|
||||
|
||||
if (xxxxxx == 0)
|
||||
// the template string doesn't contain "XXXXXX"!
|
||||
return s;
|
||||
else
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
ACE_TCHAR unique_letter = ACE_TEXT ('a');
|
||||
ACE_stat sb;
|
||||
|
||||
// Find an unused filename for this process. It is assumed
|
||||
// that the user will open the file immediately after
|
||||
// getting this filename back (so, yes, there is a race
|
||||
// condition if multiple threads in a process use the same
|
||||
// template). This appears to match the behavior of the
|
||||
// SunOS 5.5 mktemp().
|
||||
ACE_OS::sprintf (xxxxxx,
|
||||
ACE_TEXT ("%05d%c"),
|
||||
ACE_OS::getpid (),
|
||||
unique_letter);
|
||||
while (ACE_OS::stat (s, &sb) >= 0)
|
||||
{
|
||||
if (++unique_letter <= ACE_TEXT ('z'))
|
||||
ACE_OS::sprintf (xxxxxx,
|
||||
ACE_TEXT ("%05d%c"),
|
||||
ACE_OS::getpid (),
|
||||
unique_letter);
|
||||
else
|
||||
{
|
||||
// maximum of 26 unique files per template, per process
|
||||
ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT (""));
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
if (!found)
|
||||
// maximum of 26 unique files per template, per process
|
||||
xxxxxx[0] = ACE_TEXT ('\0');
|
||||
return s;
|
||||
}
|
||||
#endif /* ACE_LACKS_MKTEMP && !ACE_DISABLE_MKTEMP */
|
||||
#endif /* ACE_LACKS_MKTEMP &7 !ACE_DISABLE_MKTEMP */
|
||||
|
||||
void *
|
||||
ACE_OS::realloc (void *ptr, size_t nbytes)
|
||||
{
|
||||
#ifdef ACE_LACKS_REALLOC
|
||||
ACE_UNUSED_ARG (ptr);
|
||||
ACE_UNUSED_ARG (nbytes);
|
||||
ACE_NOTSUP_RETURN (0);
|
||||
#else
|
||||
return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (ACE_LACKS_REALPATH)
|
||||
|
|
@ -378,11 +367,7 @@ ACE_OS::realpath (const char *file_name,
|
|||
// To match glibc realpath() and Win32 _fullpath() behavior,
|
||||
// allocate room for the return value if resolved_name is
|
||||
// a null pointer.
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
rpath = static_cast<char*>(ACE_Allocator::instance()->malloc (PATH_MAX));
|
||||
#else
|
||||
rpath = static_cast<char*>(ACE_OS::malloc (PATH_MAX));
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
if (rpath == 0)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
|
|
@ -402,11 +387,7 @@ ACE_OS::realpath (const char *file_name,
|
|||
if (ACE_OS::getcwd (rpath, PATH_MAX) == 0)
|
||||
{
|
||||
if (resolved_name == 0)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_Allocator::instance()->free (rpath);
|
||||
#else
|
||||
ACE_OS::free (rpath);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
return 0;
|
||||
}
|
||||
dest = ACE_OS::strchr (rpath, '\0');
|
||||
|
|
@ -439,11 +420,7 @@ ACE_OS::realpath (const char *file_name,
|
|||
{
|
||||
errno = ENAMETOOLONG;
|
||||
if (resolved_name == 0)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_Allocator::instance()->free (rpath);
|
||||
#else
|
||||
ACE_OS::free (rpath);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -474,11 +451,7 @@ ACE_OS::realpath (const char *file_name,
|
|||
if (ACE_OS::lstat(rpath, &st) < 0)
|
||||
{
|
||||
if (resolved_name == 0)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_Allocator::instance()->free (rpath);
|
||||
#else
|
||||
ACE_OS::free (rpath);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
ACE_OS::free (rpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -489,11 +462,7 @@ ACE_OS::realpath (const char *file_name,
|
|||
{
|
||||
errno = ELOOP;
|
||||
if (resolved_name == 0)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_Allocator::instance()->free (rpath);
|
||||
#else
|
||||
ACE_OS::free (rpath);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -507,11 +476,7 @@ ACE_OS::realpath (const char *file_name,
|
|||
{
|
||||
errno = ENAMETOOLONG;
|
||||
if (resolved_name == 0)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_Allocator::instance()->free (rpath);
|
||||
#else
|
||||
ACE_OS::free (rpath);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -545,11 +510,11 @@ ACE_OS::realpath (const char *file_name,
|
|||
long
|
||||
ACE_OS::strtol_emulation (const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const char *s = nptr;
|
||||
ACE_REGISTER unsigned long acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER unsigned long cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
|
|
@ -627,11 +592,11 @@ ACE_OS::wcstol_emulation (const wchar_t *nptr,
|
|||
wchar_t **endptr,
|
||||
int base)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const wchar_t *s = nptr;
|
||||
ACE_REGISTER unsigned long acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER unsigned long cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
|
|
@ -693,13 +658,13 @@ ACE_OS::wcstol_emulation (const wchar_t *nptr,
|
|||
unsigned long
|
||||
ACE_OS::strtoul_emulation (const char *nptr,
|
||||
char **endptr,
|
||||
int base)
|
||||
ACE_REGISTER int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const char *s = nptr;
|
||||
ACE_REGISTER unsigned long acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER unsigned long cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
|
|
@ -765,11 +730,11 @@ ACE_OS::wcstoul_emulation (const wchar_t *nptr,
|
|||
wchar_t **endptr,
|
||||
int base)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const wchar_t *s = nptr;
|
||||
ACE_REGISTER unsigned long acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER unsigned long cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
|
|
@ -832,13 +797,13 @@ ACE_OS::wcstoul_emulation (const wchar_t *nptr,
|
|||
ACE_INT64
|
||||
ACE_OS::strtoll_emulation (const char *nptr,
|
||||
char **endptr,
|
||||
int base)
|
||||
ACE_REGISTER int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
ACE_UINT64 acc;
|
||||
int c;
|
||||
ACE_UINT64 cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const char *s = nptr;
|
||||
ACE_REGISTER ACE_UINT64 acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER ACE_UINT64 cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
|
|
@ -902,11 +867,11 @@ ACE_OS::wcstoll_emulation (const wchar_t *nptr,
|
|||
wchar_t **endptr,
|
||||
int base)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
ACE_UINT64 acc;
|
||||
int c;
|
||||
ACE_UINT64 cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const wchar_t *s = nptr;
|
||||
ACE_REGISTER ACE_UINT64 acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER ACE_UINT64 cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
|
|
@ -969,13 +934,13 @@ ACE_OS::wcstoll_emulation (const wchar_t *nptr,
|
|||
ACE_UINT64
|
||||
ACE_OS::strtoull_emulation (const char *nptr,
|
||||
char **endptr,
|
||||
int base)
|
||||
ACE_REGISTER int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
ACE_UINT64 acc;
|
||||
int c;
|
||||
ACE_UINT64 cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const char *s = nptr;
|
||||
ACE_REGISTER ACE_UINT64 acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER ACE_UINT64 cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
|
|
@ -1041,11 +1006,11 @@ ACE_OS::wcstoull_emulation (const wchar_t *nptr,
|
|||
wchar_t **endptr,
|
||||
int base)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
ACE_UINT64 acc;
|
||||
int c;
|
||||
ACE_UINT64 cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
ACE_REGISTER const wchar_t *s = nptr;
|
||||
ACE_REGISTER ACE_UINT64 acc;
|
||||
ACE_REGISTER int c;
|
||||
ACE_REGISTER ACE_UINT64 cutoff;
|
||||
ACE_REGISTER int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
|
|
@ -1138,10 +1103,7 @@ ACE_OS::mkstemp_emulation (ACE_TCHAR * s)
|
|||
|
||||
// Add the process and thread ids to ensure uniqueness.
|
||||
msec += ACE_OS::getpid();
|
||||
|
||||
#ifndef ACE_THREAD_T_IS_A_STRUCT
|
||||
msec += (size_t) ACE_OS::thr_self();
|
||||
#endif
|
||||
|
||||
// ACE_thread_t may be a char* (returned by ACE_OS::thr_self()) so
|
||||
// we need to use a C-style cast as a catch-all in order to use a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue