void ace_flock_t::dump (void) const { #if defined (ACE_HAS_DUMP) ACE_OS_TRACE ("ACE_OS::ace_flock_t::dump"); # if 0 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("handle_ = %u"), this->handle_)); # if defined (ACE_WIN32) ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nInternal = %d"), this->overlapped_.Internal)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nInternalHigh = %d"), this->overlapped_.InternalHigh)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nOffsetHigh = %d"), this->overlapped_.OffsetHigh)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhEvent = %d"), this->overlapped_.hEvent)); # else ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_whence = %d"), this->lock_.l_whence)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_start = %d"), this->lock_.l_start)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_len = %d"), this->lock_.l_len)); ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nl_type = %d"), this->lock_.l_type)); # endif /* ACE_WIN32 */ ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP)); # endif /* 0 */ #endif /* ACE_HAS_DUMP */ }
time_t ACE_OS::mktime (struct tm *t) { ACE_OS_TRACE ("ACE_OS::mktime"); # if defined (ACE_HAS_WINCE) SYSTEMTIME t_sys; FILETIME t_file; t_sys.wSecond = t->tm_sec; t_sys.wMinute = t->tm_min; t_sys.wHour = t->tm_hour; t_sys.wDay = t->tm_mday; t_sys.wMonth = t->tm_mon + 1; // SYSTEMTIME is 1-indexed, tm is 0-indexed t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900 t_sys.wDayOfWeek = t->tm_wday; // Ignored in below function call. if (SystemTimeToFileTime (&t_sys, &t_file) == 0) return -1; ACE_Time_Value tv (t_file); return tv.sec (); # else # if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_MT_SAFE_MKTIME) ACE_OS_GUARD # endif /* ACE_HAS_THREADS && ! ACE_HAS_MT_SAFE_MKTIME */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::mktime (t), time_t, (time_t) -1); # endif /* ACE_HAS_WINCE */ }
long ACE_OS::num_processors (void) { ACE_OS_TRACE ("ACE_OS::num_processors"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return sys_info.dwNumberOfProcessors; #elif defined (ACE_HAS_VXCPULIB) return vxCpuConfiguredGet(); #elif defined (_SC_NPROCESSORS_CONF) return ::sysconf (_SC_NPROCESSORS_CONF); #elif defined (ACE_HAS_SYSCTL) int num_processors = 0; int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof (num_processors); if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1) return num_processors; else return -1; #elif defined (__hpux) struct pst_dynamic psd; if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) return psd.psd_max_proc_cnt; else return -1; #else ACE_NOTSUP_RETURN (-1); #endif }
ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter ( ACE_THR_FUNC user_func, void *arg, ACE_THR_C_FUNC entry_point, ACE_OS_Thread_Descriptor *td #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , ACE_SEH_EXCEPT_HANDLER selector , ACE_SEH_EXCEPT_HANDLER handler #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ ) : user_func_ (user_func) , arg_ (arg) , entry_point_ (entry_point) , thr_desc_ (td) , ctx_ (ACE_Service_Config::current()) { ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter"); if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0) (*ACE_Base_Thread_Adapter::init_log_msg_hook_) ( this->log_msg_attributes_ # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , selector , handler # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ ); #ifdef ACE_USES_GPROF getitimer (ITIMER_PROF, &itimer_); #endif // ACE_USES_GPROF }
extern "C" ACE_THR_FUNC_RETURN ACE_THREAD_ADAPTER_NAME (void *args) { ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME"); #if defined (ACE_HAS_TSS_EMULATION) // As early as we can in the execution of the new thread, allocate // its local TS storage. Allocate it on the stack, to save dynamic // allocation/dealloction. void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX]; ACE_TSS_Emulation::tss_open (ts_storage); #endif /* ACE_HAS_TSS_EMULATION */ ACE_Base_Thread_Adapter * const thread_args = static_cast<ACE_Base_Thread_Adapter *> (args); #ifdef ACE_USES_GPROF setitimer (ITIMER_PROF, thread_args->timerval (), 0); #endif // ACE_USES_GPROF // Invoke the user-supplied function with the args. ACE_THR_FUNC_RETURN status = thread_args->invoke (); return status; }
void ACE_OS::exit (int status) { ACE_OS_TRACE ("ACE_OS::exit"); #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) // Shut down the ACE_Object_Manager, if it had registered its exit_hook. // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is // instantiated on the main's stack. ::exit () doesn't destroy it. if (exit_hook_) (*exit_hook_) (); #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ #if !defined (ACE_HAS_WINCE) # if defined (ACE_WIN32) ::ExitProcess ((UINT) status); # elif defined (ACE_PSOSIM) ::u_exit (status); # else ::exit (status); # endif /* ACE_WIN32 */ #else // @@ This is not exactly the same as ExitProcess. But this is the // closest one I can get. ::TerminateProcess (::GetCurrentProcess (), status); #endif /* ACE_HAS_WINCE */ }
int ACE_OS::execle (const char * /* path */, const char * /* arg0 */, ...) { ACE_OS_TRACE ("ACE_OS::execle"); ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); }
int ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...) { ACE_OS_TRACE ("ACE_OS::execlp"); ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_Thread_Control::dump (void) const { #if defined (ACE_HAS_DUMP) ACE_OS_TRACE ("ACE_Thread_Control::dump"); #endif /* ACE_HAS_DUMP */ }
// Automatically kill thread on exit. ACE_Thread_Control::~ACE_Thread_Control (void) { ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control"); #if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) this->exit (this->status_, 0); #else this->exit (this->status_, 1); #endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */ }
int ACE_OS::execlp (const char * /* file */, const char * /* arg0 */, ...) { ACE_OS_TRACE ("ACE_OS::execlp"); #if defined (ACE_WIN32) || defined (VXWORKS) ACE_NOTSUP_RETURN (-1); #else ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::execle (const char * /* path */, const char * /* arg0 */, ...) { ACE_OS_TRACE ("ACE_OS::execle"); #if defined (ACE_WIN32) || defined (VXWORKS) ACE_NOTSUP_RETURN (-1); #else ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); #endif /* ACE_WIN32 */ }
long ACE_OS::num_processors_online (void) { ACE_OS_TRACE ("ACE_OS::num_processors_online"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); long active_processors = 0; DWORD_PTR mask = sys_info.dwActiveProcessorMask; while (mask != 0) { if (mask & 1) ++active_processors; mask >>= 1; } return active_processors; #elif defined (ACE_HAS_VXCPULIB) long num_cpu = 0; cpuset_t cpuset; CPUSET_ZERO (cpuset); cpuset = vxCpuEnabledGet(); unsigned int const maxcpu = vxCpuConfiguredGet(); for (unsigned int i =0; i < maxcpu; i++) { if (CPUSET_ISSET (cpuset, i)) { ++num_cpu; } } return num_cpu; #elif defined (_SC_NPROCESSORS_ONLN) return ::sysconf (_SC_NPROCESSORS_ONLN); #elif defined (ACE_HAS_SYSCTL) int num_processors; int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof (num_processors); if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1) return num_processors; else return -1; #elif defined (__hpux) struct pst_dynamic psd; if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) return psd.psd_proc_cnt; else return -1; #else ACE_NOTSUP_RETURN (-1); #endif }
FILE * ACE_OS::fopen (const char *filename, const ACE_TCHAR *mode) { ACE_OS_TRACE ("ACE_OS::fopen"); #if defined (ACE_LACKS_FOPEN) ACE_UNUSED_ARG (filename); ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (0); #else int hmode = _O_TEXT; // Let the chips fall where they may if the user passes in a NULL // mode string. Convert to an empty mode string to prevent a // crash. ACE_TCHAR const empty_mode[] = ACE_TEXT (""); if (!mode) mode = empty_mode; for (ACE_TCHAR const* mode_ptr = mode; *mode_ptr != 0; ++mode_ptr) fopen_mode_to_open_mode_converter (*mode_ptr, hmode); ACE_HANDLE const handle = ACE_OS::open (filename, hmode); if (handle != ACE_INVALID_HANDLE) { hmode &= _O_TEXT | _O_RDONLY | _O_APPEND; int const fd = ::_open_osfhandle (intptr_t (handle), hmode); if (fd != -1) { # if defined (ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR) FILE * const fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode)); # elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR) FILE * const fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode)); # elif defined (ACE_USES_WCHAR) FILE * const fp = ::_wfdopen (fd, mode); # else FILE * const fp = ::fdopen (fd, mode); # endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */ if (fp != 0) { return fp; } ::_close (fd); } ACE_OS::close (handle); } return 0; #endif }
int ACE_Thread_Control::insert (ACE_Thread_Manager *tm, bool insert) { ACE_OS_TRACE ("ACE_Thread_Control::insert"); ACE_hthread_t t_id; ACE_OS::thr_self (t_id); this->tm_ = tm; if (insert) return this->tm_->insert_thr (ACE_OS::thr_self (), t_id); else return 0; }
// Initialize the thread controller. ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t, int insert) : tm_ (t), status_ (0) { ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control"); if (this->tm_ != 0 && insert) { ACE_hthread_t t_id; ACE_OS::thr_self (t_id); this->tm_->insert_thr (ACE_OS::thr_self (), t_id); } }
ssize_t ACE_OS::writev_emulation (ACE_HANDLE handle, const iovec *iov, int n) { ACE_OS_TRACE ("ACE_OS::writev_emulation"); // To avoid having to allocate a temporary buffer to which all of // the data will be copied and then written, this implementation // performs incremental writes. ssize_t bytes_sent = 0; for (int i = 0; i < n; ++i) { ssize_t const result = ACE_OS::write (handle, iov[i].iov_base, iov[i].iov_len); if (result == -1) { // There is a subtle difference in behaviour depending on // whether or not any data was sent. If no data was sent, // then always return -1. Otherwise return bytes_sent. // This gives the caller an opportunity to keep track of // bytes that have already been sent. if (bytes_sent > 0) break; else return -1; } else { bytes_sent += result; // Do not continue on to the next loop iteration if the // amount of data sent was less than the amount data given. // This avoids a subtle problem where "holes" in the data // stream would occur if partial sends of a given buffer in // the iovec array occured. # if defined (ACE_HAS_SIGNED_IOVLEN) if (result < iov[i].iov_len) # else if (static_cast<size_t> (result) < iov[i].iov_len) # endif /* ACE_HAS_SIGNED_IOVLEN */ break; } } return bytes_sent; }
ACE_TCHAR * ACE_OS::mktemp (ACE_TCHAR *s) { ACE_OS_TRACE ("ACE_OS::mktemp"); if (s == 0) // check for null template string failed! return 0; else { ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX")); if (xxxxxx == 0) // the template string doesn't contain "XXXXXX"! return s; else { 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; } }
FILE * ACE_OS::fopen (const char *filename, const ACE_TCHAR *mode) { ACE_OS_TRACE ("ACE_OS::fopen"); int hmode = _O_TEXT; for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++) ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode); ACE_HANDLE handle = ACE_OS::open (filename, hmode); if (handle != ACE_INVALID_HANDLE) { # if defined (ACE_HAS_WINCE) FILE *fp = ::_wfdopen (handle, mode); if (fp != 0) { checkUnicodeFormat(fp); return fp; } # else hmode &= _O_TEXT | _O_RDONLY | _O_APPEND; # if defined (ACE_WIN64) int fd = _open_osfhandle (intptr_t (handle), hmode); # else int fd = _open_osfhandle (long (handle), hmode); # endif /* ACE_WIN64 */ if (fd != -1) { # if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR) FILE *fp = ::_fdopen (fd, ACE_const_cast (char *, mode)); # elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR) FILE *fp = ::_wfdopen (fd, ACE_const_cast (wchar_t *, mode)); # elif defined (ACE_USES_WCHAR) FILE *fp = ::_wfdopen (fd, mode); # else FILE *fp = ::fdopen (fd, mode); # endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */ if (fp != 0) { # if defined (ACE_USES_WCHAR) checkUnicodeFormat(fp); # endif // ACE_USES_WCHAR return fp; } ::_close (fd); }
long ACE_OS::num_processors (void) { ACE_OS_TRACE ("ACE_OS::num_processors"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) || defined (ACE_WIN64) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return sys_info.dwNumberOfProcessors; #elif defined (linux) || defined (sun) return ::sysconf (_SC_NPROCESSORS_CONF); #else ACE_NOTSUP_RETURN (-1); #endif }
// Exit from thread (but clean up first). ACE_THR_FUNC_RETURN ACE_Thread_Control::exit (ACE_THR_FUNC_RETURN exit_status, int do_thr_exit) { ACE_OS_TRACE ("ACE_Thread_Control::exit"); if (this->tm_ != 0) return this->tm_->exit (exit_status, do_thr_exit); else { #if !defined (ACE_HAS_TSS_EMULATION) // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke () // exit the thread after cleaning up TSS. ACE_OS::thr_exit (exit_status); #endif /* ! ACE_HAS_TSS_EMULATION */ return 0; } }
FILE * ACE_OS::fopen (const wchar_t *filename, const ACE_TCHAR *mode) { ACE_OS_TRACE ("ACE_OS::fopen"); #if defined (ACE_LACKS_FOPEN) ACE_UNUSED_ARG (filename); ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (0); #else int hmode = _O_TEXT; for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++) fopen_mode_to_open_mode_converter (*mode_ptr, hmode); ACE_HANDLE handle = ACE_OS::open (filename, hmode); if (handle != ACE_INVALID_HANDLE) { hmode &= _O_TEXT | _O_RDONLY | _O_APPEND; int const fd = ::_open_osfhandle (intptr_t (handle), hmode); if (fd != -1) { # if defined (ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR) FILE *fp = ::_fdopen (fd, const_cast<char *> (mode)); # elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR) FILE *fp = ::_wfdopen (fd, const_cast<wchar_t *> (mode)); # elif defined (ACE_USES_WCHAR) FILE *fp = ::_wfdopen (fd, mode); # else FILE *fp = ::fdopen (fd, mode); # endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */ if (fp != 0) { return fp; } ::_close (fd); } ACE_OS::close (handle); } return 0; #endif }
ssize_t ACE_OS::readv_emulation (ACE_HANDLE handle, ACE_READV_TYPE *iov, int n) { ACE_OS_TRACE ("ACE_OS::readv_emulation"); // In case there's a single element, skip the memcpy. if (1 == n) return ACE_OS::read (handle, iov[0].iov_base, iov[0].iov_len); ssize_t length = 0; int i; for (i = 0; i < n; i++) if (ACE_static_cast (int, iov[i].iov_len) < 0) return -1; else
void ACE_OS::exit (int status) { ACE_OS_TRACE ("ACE_OS::exit"); #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) // Shut down the ACE_Object_Manager, if it had registered its exit_hook. // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is // instantiated on the main's stack. ::exit () doesn't destroy it. if (exit_hook_) (*exit_hook_) (); #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ #if defined (ACE_WIN32) ::ExitProcess ((UINT) status); #else ::exit (status); #endif /* ACE_WIN32 */ }
void ACE_OS::readPPCTimeBase (u_long &most, u_long &least) { ACE_OS_TRACE ("ACE_OS::readPPCTimeBase"); // This function can't be inline because it depends on the arguments // being in particular registers (r3 and r4), in conformance with the // EABI standard. It would be nice if we knew how to put the variable // names directly into the assembler instructions . . . asm("aclock:"); asm("mftb r5,TBU"); asm("mftb r6,TBL"); asm("mftb r7,TBU"); asm("cmpw r5,r7"); asm("bne aclock"); asm("stw r5, 0(r3)"); asm("stw r6, 0(r4)"); }
pid_t ACE_OS::fork (const ACE_TCHAR *program_name) { ACE_OS_TRACE ("ACE_OS::fork"); # if defined (ACE_LACKS_FORK) ACE_UNUSED_ARG (program_name); ACE_NOTSUP_RETURN (pid_t (-1)); # else pid_t const pid = # if defined (ACE_HAS_STHREADS) ::fork1 (); #else ::fork (); #endif /* ACE_HAS_STHREADS */ #if !defined (ACE_HAS_MINIMAL_ACE_OS) && !defined (ACE_HAS_THREADS) // ACE_Base_Thread_Adapter::sync_log_msg() is used to update the // program name and process id in ACE's log framework. However, we // can't invoke it from (the child process of) threaded programs // because it calls async signal unsafe functions, which will result // in undefined behavior (only async signal safe functions can be // called after fork() until an exec()). // // This is no great loss. Using the ACE log framework in the child // process will undoubtedly call async signal unsafe functions too. // So it doesn't really matter that the program name and process id // will not be updated. if (pid == 0) ACE_Base_Thread_Adapter::sync_log_msg (program_name); #else ACE_UNUSED_ARG (program_name); #endif /* ! ACE_HAS_MINIMAL_ACE_OS && !ACE_HAS_THREADS */ return pid; # endif /* ACE_WIN32 */ }
long ACE_OS::num_processors_online (void) { ACE_OS_TRACE ("ACE_OS::num_processors_online"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); long active_processors = 0; DWORD_PTR mask = sys_info.dwActiveProcessorMask; while (mask != 0) { if (mask & 1) ++active_processors; mask >>= 1; } return active_processors; #elif defined (_SC_NPROCESSORS_ONLN) return ::sysconf (_SC_NPROCESSORS_ONLN); #elif defined (ACE_HAS_SYSCTL) int num_processors; int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof (num_processors); if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1) return num_processors; else return -1; #elif defined (__hpux) struct pst_dynamic psd; if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) return psd.psd_proc_cnt; else return -1; #else ACE_NOTSUP_RETURN (-1); #endif }
long ACE_OS::num_processors_online (void) { ACE_OS_TRACE ("ACE_OS::num_processors_online"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) || defined (ACE_WIN64) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return sys_info.dwNumberOfProcessors; #elif defined (linux) || defined (sun) return ::sysconf (_SC_NPROCESSORS_ONLN); #elif defined (__hpux) struct pst_dynamic psd; if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) return psd.psd_proc_cnt; else return -1; #else ACE_NOTSUP_RETURN (-1); #endif }
pid_t ACE_OS::fork (const ACE_TCHAR *program_name) { ACE_OS_TRACE ("ACE_OS::fork"); # if defined (ACE_LACKS_FORK) ACE_UNUSED_ARG (program_name); ACE_NOTSUP_RETURN (pid_t (-1)); # else pid_t pid = # if defined (ACE_HAS_STHREADS) ::fork1 (); #else ::fork (); #endif /* ACE_HAS_STHREADS */ #if !defined (ACE_HAS_MINIMAL_ACE_OS) if (pid == 0) ACE_Base_Thread_Adapter::sync_log_msg (program_name); #endif /* ! ACE_HAS_MINIMAL_ACE_OS */ return pid; # endif /* ACE_WIN32 */ }
long ACE_OS::num_processors (void) { ACE_OS_TRACE ("ACE_OS::num_processors"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return sys_info.dwNumberOfProcessors; #elif defined (_SC_NPROCESSORS_CONF) return ::sysconf (_SC_NPROCESSORS_CONF); #elif defined (ACE_HAS_SYSCTL) int num_processors; int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof (num_processors); sysctl(mib, 2, &num_processors, &len, NULL, 0); return num_processors; #else ACE_NOTSUP_RETURN (-1); #endif }