summaryrefslogtreecommitdiff
path: root/ace/OS_NS_unistd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/OS_NS_unistd.cpp')
-rw-r--r--ace/OS_NS_unistd.cpp91
1 files changed, 21 insertions, 70 deletions
diff --git a/ace/OS_NS_unistd.cpp b/ace/OS_NS_unistd.cpp
index 370ff5f4510..c472f5d7cca 100644
--- a/ace/OS_NS_unistd.cpp
+++ b/ace/OS_NS_unistd.cpp
@@ -16,7 +16,14 @@ ACE_RCSID(ace, OS_NS_unistd, "$Id$")
#include "ace/OS_Memory.h"
#include "ace/OS_NS_Thread.h"
#include "ace/Object_Manager_Base.h"
-#include "ace/os_include/sys/os_pstat.h"
+
+// This is here for ACE_OS::num_processors_online(). On HP-UX, it
+// needs sys/param.h (above) and sys/pstat.h. The implementation of the
+// num_processors_online() method also uses 'defined (__hpux)' to decide
+// whether or not to try the syscall.
+#if defined (__hpux)
+# include /**/ <sys/pstat.h>
+#endif /* __hpux **/
#if defined (ACE_NEEDS_FTRUNCATE)
extern "C" int
@@ -48,30 +55,14 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
for (int i = 0; argv[i] != 0; i++)
{
+ ACE_TCHAR *temp = 0;
+
#if !defined (ACE_LACKS_ENV)
// Account for environment variables.
- if (substitute_env_args && argv[i][0] == ACE_LIB_TEXT ('$'))
- {
-# if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR)
- ACE_TCHAR *temp = 0;
- // Win32 is the only platform with a wide-char ACE_OS::getenv().
- if ((temp = ACE_OS::getenv (&argv[i][1])) != 0)
- buf_len += ACE_OS::strlen (temp);
- else
- buf_len += ACE_OS::strlen (argv[i]);
-# else
- // This is an ACE_HAS_WCHAR platform and not ACE_WIN32.
- // Convert the env variable name for getenv(), then add
- // the length of the returned char *string. Later, when we
- // actually use the returned env variable value, convert it
- // as well.
- char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[i][1]));
- if (ctemp == 0)
- buf_len += ACE_OS::strlen (argv[i]);
- else
- buf_len += ACE_OS::strlen (ctemp);
-# endif /* ACE_WIN32 || !ACE_HAS_WCHAR */
- }
+ if (substitute_env_args
+ && (argv[i][0] == '$'
+ && (temp = ACE_OS::getenv (&argv[i][1])) != 0))
+ buf_len += ACE_OS::strlen (temp);
else
#endif /* ACE_LACKS_ENV */
buf_len += ACE_OS::strlen (argv[i]);
@@ -94,29 +85,14 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
for (j = 0; argv[j] != 0; j++)
{
+ ACE_TCHAR *temp = 0;
#if !defined (ACE_LACKS_ENV)
// Account for environment variables.
- if (substitute_env_args && argv[j][0] == ACE_LIB_TEXT ('$'))
- {
-# if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR)
- // Win32 is the only platform with a wide-char ACE_OS::getenv().
- ACE_TCHAR *temp = ACE_OS::getenv (&argv[j][1]);
- if (temp != 0)
- end = ACE_OS::strecpy (end, temp);
- else
- end = ACE_OS::strecpy (end, argv[j]);
-# else
- // This is an ACE_HAS_WCHAR platform and not ACE_WIN32.
- // Convert the env variable name for getenv(), then convert
- // the returned char *string back to wchar_t.
- char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[j][1]));
- if (ctemp == 0)
- end = ACE_OS::strecpy (end, argv[j]);
- else
- end = ACE_OS::strecpy (end, ACE_TEXT_CHAR_TO_TCHAR (ctemp));
-# endif /* ACE_WIN32 || !ACE_HAS_WCHAR */
- }
+ if (substitute_env_args
+ && (argv[j][0] == '$'
+ && (temp = ACE_OS::getenv (&argv[j][1])) != 0))
+ end = ACE_OS::strecpy (end, temp);
else
#endif /* ACE_LACKS_ENV */
end = ACE_OS::strecpy (end, argv[j]);
@@ -253,13 +229,6 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
# else
pid_t result = ACE_OS::fork ();
-# if defined (ACE_USES_WCHAR)
- // Wide-char builds need to convert the command-line args to
- // narrow char strings for execv().
- char **cargv;
- int arg_count;
-# endif /* ACE_HAS_WCHAR */
-
switch (result)
{
case -1:
@@ -267,22 +236,6 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
return -1;
case 0:
// Child process.
-# if defined (ACE_USES_WCHAR)
- for (arg_count = 0; argv[arg_count] != 0; ++arg_count)
- ;
- ++arg_count; // Need a 0-pointer end-of-array marker
- ACE_NEW_NORETURN (cargv, char*[arg_count]);
- if (cargv == 0)
- ACE_OS::exit (errno);
- --arg_count; // Back to 0-indexed
- cargv[arg_count] = 0;
- while (--arg_count >= 0)
- cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
- // Don't worry about freeing the cargv or the strings it points to.
- // Either the process will be replaced, or we'll exit.
- if (ACE_OS::execv (cargv[0], cargv) == -1)
- ACE_OS::exit (errno);
-# else
if (ACE_OS::execv (argv[0], argv) == -1)
{
// The OS layer should not print stuff out
@@ -292,8 +245,6 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
// If the execv fails, this child needs to exit.
ACE_OS::exit (errno);
}
-# endif /* ACE_HAS_WCHAR */
-
default:
// Server process. The fork succeeded.
return result;
@@ -312,7 +263,7 @@ ACE_OS::num_processors (void)
SYSTEM_INFO sys_info;
::GetSystemInfo (&sys_info);
return sys_info.dwNumberOfProcessors;
-#elif defined (linux) || defined (sun) || defined (DIGITAL_UNIX) || defined (CYGWIN32)
+#elif defined (linux) || defined (sun)
return ::sysconf (_SC_NPROCESSORS_CONF);
#else
ACE_NOTSUP_RETURN (-1);
@@ -330,7 +281,7 @@ ACE_OS::num_processors_online (void)
SYSTEM_INFO sys_info;
::GetSystemInfo (&sys_info);
return sys_info.dwNumberOfProcessors;
-#elif defined (linux) || defined (sun) || defined (DIGITAL_UNIX) || defined (CYGWIN32)
+#elif defined (linux) || defined (sun)
return ::sysconf (_SC_NPROCESSORS_ONLN);
#elif defined (__hpux)
struct pst_dynamic psd;