Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_OS Class Reference

This class defines an OS independent programming API that shields developers from nonportable aspects of writing efficient system programs on Win32, POSIX and other versions of UNIX, and various real-time operating systems. More...

#include <OS.h>

Inheritance diagram for ACE_OS:

Inheritance graph
[legend]
Collaboration diagram for ACE_OS:

Collaboration graph
[legend]
List of all members.

Wide-character strings

typedef wchar_t WChar
u_int wslen (const WChar *)
WCharwscpy (WChar *, const WChar *)
int wscmp (const WChar *, const WChar *)
int wsncmp (const WChar *, const WChar *, size_t len)

A set of wrappers for threads

int thr_continue (ACE_hthread_t target_thread)
int thr_create (ACE_THR_FUNC func, void *args, long flags, ACE_thread_t *thr_id, ACE_hthread_t *t_handle=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, void *stack=0, size_t stacksize=0, ACE_Base_Thread_Adapter *thread_adapter=0)
int thr_join (ACE_hthread_t waiter_id, ACE_THR_FUNC_RETURN *status)
int thr_join (ACE_thread_t waiter_id, ACE_thread_t *thr_id, ACE_THR_FUNC_RETURN *status)
int thr_kill (ACE_thread_t thr_id, int signum)
ACE_thread_t thr_self (void)
void thr_self (ACE_hthread_t &)
int thr_getprio (ACE_hthread_t id, int &priority)
int thr_getprio (ACE_hthread_t id, int &priority, int &policy)
int thr_setprio (ACE_hthread_t id, int priority, int policy=-1)
int thr_setprio (const ACE_Sched_Priority prio)
int thr_suspend (ACE_hthread_t target_thread)
int thr_cancel (ACE_thread_t t_id)
int thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2)
int thr_equal (ACE_thread_t t1, ACE_thread_t t2)
void thr_exit (ACE_THR_FUNC_RETURN status=0)
int thr_getconcurrency (void)
int lwp_getparams (ACE_Sched_Params &)
int thr_getspecific (ACE_thread_key_t key, void **data)
int thr_keyfree (ACE_thread_key_t key)
int thr_key_detach (void *inst)
int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST, void *inst=0)
int thr_key_used (ACE_thread_key_t key)
size_t thr_min_stack (void)
int thr_setconcurrency (int hint)
int lwp_setparams (const ACE_Sched_Params &)
int thr_setspecific (ACE_thread_key_t key, void *data)
int thr_sigsetmask (int how, const sigset_t *nsm, sigset_t *osm)
int thr_setcancelstate (int new_state, int *old_state)
int thr_setcanceltype (int new_type, int *old_type)
int sigwait (sigset_t *set, int *sig=0)
int sigtimedwait (const sigset_t *set, siginfo_t *info, const ACE_Time_Value *timeout)
int sigwaitinfo (const sigset_t *set, siginfo_t *info)
void thr_testcancel (void)
void thr_yield (void)
void unique_name (const void *object, ACE_TCHAR *name, size_t length)
ACE_thread_t NULL_thread
 This is necessary to deal with POSIX pthreads and their use of structures for thread ids. More...

ACE_hthread_t NULL_hthread
 This is necessary to deal with POSIX pthreads and their use of structures for thread handles. More...

ACE_thread_key_t NULL_key
 This is necessary to deal with POSIX pthreads and their use of structures for TSS keys. More...


Public Types

enum  ACE_HRTimer_Op { ACE_HRTIMER_START = 0x0, ACE_HRTIMER_INCR = 0x1, ACE_HRTIMER_STOP = 0x2, ACE_HRTIMER_GETTIME = 0xFFFF }

Static Public Methods

LPSECURITY_ATTRIBUTES default_win32_security_attributes (LPSECURITY_ATTRIBUTES)
const OSVERSIONINFO & get_win32_versioninfo (void)
 Return the win32 OSVERSIONINFO structure. More...

HINSTANCE get_win32_resource_module (void)
 Return the handle of the module containing ACE's resources. By default, for a DLL build of ACE this is a handle to the ACE DLL itself, and for a static build it is a handle to the executable. More...

void set_win32_resource_module (HINSTANCE)
 Allow an application to modify which module contains ACE's resources. This is mainly useful for a static build of ACE where the required resources reside somewhere other than the executable. More...

int atoi (const char *s)
int atoi (const wchar_t *s)
void * atop (const char *s)
void * atop (const wchar_t *s)
double floor (double x)
 This method computes the largest integral value not greater than x. More...

double ceil (double x)
 This method computes the smallest integral value not less than x. More...

char * getenv (const char *symbol)
wchar_t * getenv (const wchar_t *symbol)
int putenv (const ACE_TCHAR *string)
ACE_TCHARstrenvdup (const ACE_TCHAR *str)
ACE_TCHARgetenvstrings (void)
int getopt (int argc, char *const *argv, const char *optstring)
int argv_to_string (ACE_TCHAR **argv, ACE_TCHAR *&buf, int substitute_env_args=1)
int string_to_argv (ACE_TCHAR *buf, int &argc, ACE_TCHAR **&argv, int substitute_env_args=1)
long sysconf (int)
pid_t waitpid (pid_t pid, ACE_exitcode *status=0, int wait_options=0, ACE_HANDLE handle=0)
pid_t wait (pid_t pid, ACE_exitcode *status, int wait_options=0, ACE_HANDLE handle=0)
pid_t wait (int *=0)
 Calls OS <wait> function, so it's only portable to UNIX/POSIX platforms. More...

void mutex_lock_cleanup (void *mutex)
 Handle asynchronous thread cancellation cleanup. More...

void cleanup_tss (const u_int main_thread)
int scheduling_class (const char *class_name, ACE_id_t &)
 Find the schedling class ID that corresponds to the class name. More...

int set_scheduling_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)
 Friendly interface to <priocntl>(2). More...

int priority_control (ACE_idtype_t, ACE_id_t, int, void *)
 Low-level interface to <priocntl>(2). More...

long num_processors (void)
 Get the number of CPUs configured in the machine. More...

long num_processors_online (void)
 Get the number of CPUs currently online. More...

A set of wrappers for condition variables.
int condattr_init (ACE_condattr_t &attributes, int type=ACE_DEFAULT_SYNCH_TYPE)
int condattr_destroy (ACE_condattr_t &attributes)
int cond_broadcast (ACE_cond_t *cv)
int cond_destroy (ACE_cond_t *cv)
int cond_init (ACE_cond_t *cv, short type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0)
int cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const char *name=0, void *arg=0)
int cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg=0)
int cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const wchar_t *name, void *arg=0)
int cond_signal (ACE_cond_t *cv)
int cond_timedwait (ACE_cond_t *cv, ACE_mutex_t *m, ACE_Time_Value *)
int cond_wait (ACE_cond_t *cv, ACE_mutex_t *m)
Wrappers to obtain the current user id
char * cuserid (char *user, size_t maxlen=ACE_MAX_USERID)
wchar_t * cuserid (wchar_t *user, size_t maxlen=ACE_MAX_USERID)
Wrappers to obtain configuration info
int uname (ACE_utsname *name)
long sysinfo (int cmd, char *buf, long count)
int hostname (char *name, size_t maxnamelen)
int hostname (wchar_t *name, size_t maxnamelen)
A set of wrappers for explicit dynamic linking.
int dlclose (ACE_SHLIB_HANDLE handle)
ACE_TCHARdlerror (void)
ACE_SHLIB_HANDLE dlopen (const ACE_TCHAR *filename, int mode=ACE_DEFAULT_SHLIB_MODE)
void * dlsym (ACE_SHLIB_HANDLE handle, const ACE_TCHAR *symbol)
A set of wrappers for stdio file operations.
int last_error (void)
void last_error (int)
int set_errno_to_last_error (void)
int set_errno_to_wsa_last_error (void)
int fclose (FILE *fp)
int fcntl (ACE_HANDLE handle, int cmd, long arg=0)
int fdetach (const char *file)
int fsync (ACE_HANDLE handle)
FILE * fopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode)
FILE * freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE *stream)
FILE * fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode)
ACE_TCHARfgets (ACE_TCHAR *buf, int size, FILE *fp)
int stat (const ACE_TCHAR *file, ACE_stat *)
int truncate (const ACE_TCHAR *filename, off_t length)
int fprintf (FILE *fp, const char *format,...)
int sprintf (char *buf, const char *format,...)
int snprintf (char *buf, size_t maxlen, const char *format,...)
int vsprintf (char *buffer, const char *format, va_list argptr)
int printf (const char *format,...)
int sprintf (wchar_t *buf, const wchar_t *format,...)
int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...)
int fprintf (FILE *fp, const wchar_t *format,...)
int vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr)
void perror (const ACE_TCHAR *s)
char * gets (char *str, int n=0)
int puts (const ACE_TCHAR *s)
int fputs (const ACE_TCHAR *s, FILE *stream)
int fflush (FILE *fp)
size_t fread (void *ptr, size_t size, size_t nelems, FILE *fp)
int fgetc (FILE *fp)
void clearerr (FILE *fp)
wint_t fgetwc (FILE *fp)
wint_t ungetwc (wint_t c, FILE *fp)
int fseek (FILE *fp, long offset, int ptrname)
long ftell (FILE *fp)
int fgetpos (FILE *fp, fpos_t *pos)
int fsetpos (FILE *fp, fpos_t *pos)
int fstat (ACE_HANDLE, ACE_stat *)
int lstat (const char *, ACE_stat *)
int ftruncate (ACE_HANDLE, off_t)
size_t fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp)
void rewind (FILE *fp)
Wrappers for searching and sorting.
void * bsearch (const void *key, const void *base, size_t nel, size_t size, ACE_COMPARE_FUNC)
void qsort (void *base, size_t nel, size_t width, ACE_COMPARE_FUNC)
A set of wrappers for file locks.
int flock_init (ACE_OS::ace_flock_t *lock, int flags=0, const ACE_TCHAR *name=0, mode_t perms=0)
int flock_destroy (ACE_OS::ace_flock_t *lock, int unlink_file=1)
void adjust_flock_params (ACE_OS::ace_flock_t *lock, short whence, off_t &start, off_t &len)
int flock_rdlock (ACE_OS::ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
int flock_tryrdlock (ACE_OS::ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
int flock_trywrlock (ACE_OS::ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
int flock_unlock (ACE_OS::ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
int flock_wrlock (ACE_OS::ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
A set of wrappers for low-level process operations.
int atexit (ACE_EXIT_HOOK func)
int execl (const char *path, const char *arg0,...)
int execle (const char *path, const char *arg0,...)
int execlp (const char *file, const char *arg0,...)
int execv (const char *path, char *const argv[])
int execvp (const char *file, char *const argv[])
int execve (const char *path, char *const argv[], char *const envp[])
void _exit (int status=0)
void exit (int status=0)
void abort (void)
pid_t fork (void)
int getpagesize (void)
int allocation_granularity (void)
gid_t getgid (void)
int setgid (gid_t)
pid_t getpid (void)
pid_t getpgid (pid_t pid)
pid_t getppid (void)
uid_t getuid (void)
int setuid (uid_t)
pid_t setsid (void)
int setpgid (pid_t pid, pid_t pgid)
int setreuid (uid_t ruid, uid_t euid)
int setregid (gid_t rgid, gid_t egid)
int system (const ACE_TCHAR *s)
pid_t fork (const ACE_TCHAR *program_name)
 Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable. More...

pid_t fork_exec (ACE_TCHAR *argv[])
 Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable. More...

A set of wrappers for timers and resource stats.
u_int alarm (u_int secs)
u_int ualarm (u_int usecs, u_int interval=0)
u_int ualarm (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval=ACE_Time_Value::zero)
ACE_hrtime_t gethrtime (const ACE_HRTimer_Op=ACE_HRTIMER_GETTIME)
int clock_gettime (clockid_t, struct timespec *)
ACE_Time_Value gettimeofday (void)
int getrusage (int who, struct rusage *rusage)
int getrlimit (int resource, struct rlimit *rl)
int setrlimit (int resource, ACE_SETRLIMIT_TYPE *rl)
int sleep (u_int seconds)
int sleep (const ACE_Time_Value &tv)
int nanosleep (const struct timespec *requested, struct timespec *remaining=0)
A set of wrappers for operations on time.
time_t mktime (struct tm *timeptr)
void tzset (void)
long timezone (void)
double difftime (time_t t1, time_t t0)
time_t time (time_t *tloc=0)
tm * localtime (const time_t *clock)
tm * localtime_r (const time_t *clock, struct tm *res)
tm * gmtime (const time_t *clock)
tm * gmtime_r (const time_t *clock, struct tm *res)
char * asctime (const struct tm *tm)
char * asctime_r (const struct tm *tm, char *buf, int buflen)
ACE_TCHARctime (const time_t *t)
ACE_TCHARctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
size_t strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr)
A set of wrappers for System V message queues.
int msgctl (int msqid, int cmd, struct msqid_ds *)
int msgget (key_t key, int msgflg)
int msgrcv (int int_id, void *buf, size_t len, long type, int flags)
int msgsnd (int int_id, const void *buf, size_t len, int flags)
A set of wrappers for memory mapped files.
int madvise (caddr_t addr, size_t len, int advice)
void * mmap (void *addr, size_t len, int prot, int flags, ACE_HANDLE handle, off_t off=0, ACE_HANDLE *file_mapping=0, LPSECURITY_ATTRIBUTES sa=0, const ACE_TCHAR *file_mapping_name=0)
int mprotect (void *addr, size_t len, int prot)
int msync (void *addr, size_t len, int sync)
int munmap (void *addr, size_t len)
A set of wrappers for recursive mutex locks.
int recursive_mutex_init (ACE_recursive_thread_mutex_t *m, const ACE_TCHAR *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0)
int recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m)
int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m)
int recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m)
int recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m)
int recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
void recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
A set of wrappers for mutex locks.
int mutex_init (ACE_mutex_t *m, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0)
int mutex_init (ACE_mutex_t *m, int type, const wchar_t *name, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0)
int mutex_destroy (ACE_mutex_t *m)
int mutex_lock (ACE_mutex_t *m)
 Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership. More...

int mutex_lock (ACE_mutex_t *m, int &abandoned)
 This method is only implemented for Win32. For abandoned mutexes, <abandoned> is set to 1 and 0 is returned. More...

int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value &timeout)
int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value *timeout)
int mutex_trylock (ACE_mutex_t *m)
 Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership. More...

int mutex_trylock (ACE_mutex_t *m, int &abandoned)
 This method is only implemented for Win32. For abandoned mutexes, <abandoned> is set to 1 and 0 is returned. More...

int mutex_unlock (ACE_mutex_t *m)
A set of wrappers for mutex locks that only work within a single process.
int thread_mutex_init (ACE_thread_mutex_t *m, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, ACE_mutexattr_t *arg=0)
int thread_mutex_init (ACE_thread_mutex_t *m, int type, const wchar_t *name, ACE_mutexattr_t *arg=0)
int thread_mutex_destroy (ACE_thread_mutex_t *m)
int thread_mutex_lock (ACE_thread_mutex_t *m)
int thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value &timeout)
int thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value *timeout)
int thread_mutex_trylock (ACE_thread_mutex_t *m)
int thread_mutex_unlock (ACE_thread_mutex_t *m)
A set of wrappers for low-level file operations.
int access (const char *path, int amode)
int access (const wchar_t *path, int amode)
int close (ACE_HANDLE handle)
ACE_HANDLE creat (const ACE_TCHAR *filename, mode_t mode)
ACE_HANDLE dup (ACE_HANDLE handle)
int dup2 (ACE_HANDLE oldfd, ACE_HANDLE newfd)
int fattach (int handle, const char *path)
long filesize (ACE_HANDLE handle)
long filesize (const ACE_TCHAR *handle)
int getmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *flags)
int getpmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *band, int *flags)
int ioctl (ACE_HANDLE handle, int cmd, void *=0)
 UNIX-style <ioctl>. More...

int ioctl (ACE_HANDLE socket, u_long io_control_code, void *in_buffer_p, u_long in_buffer, void *out_buffer_p, u_long out_buffer, u_long *bytes_returned, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 QoS-enabled <ioctl>. More...

int ioctl (ACE_HANDLE socket, u_long io_control_code, ACE_QoS &ace_qos, u_long *bytes_returned, void *buffer_p=0, u_long buffer=0, ACE_OVERLAPPED *overlapped=0, ACE_OVERLAPPED_COMPLETION_FUNC func=0)
 QoS-enabled <ioctl> when the I/O control code is either SIO_SET_QOS or SIO_GET_QOS. More...

int isastream (ACE_HANDLE handle)
int isatty (int handle)
int isatty (ACE_HANDLE handle)
off_t lseek (ACE_HANDLE handle, off_t offset, int whence)
ACE_HANDLE open (const char *filename, int mode, int perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
 The O_APPEND flag is only partly supported on Win32. If you specify O_APPEND, then the file pointer will be positioned at the end of the file initially during open, but it is not re-positioned at the end prior to each write, as specified by POSIX. This is generally good enough for typical situations, but it is ``not quite right'' in its semantics. More...

ACE_HANDLE open (const wchar_t *filename, int mode, int perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
int putmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int flags)
int putpmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int band, int flags)
ssize_t read (ACE_HANDLE handle, void *buf, size_t len)
ssize_t read (ACE_HANDLE handle, void *buf, size_t len, ACE_OVERLAPPED *)
ssize_t read_n (ACE_HANDLE handle, void *buf, size_t len, size_t *bytes_transferred=0)
int readlink (const char *path, char *buf, size_t bufsiz)
ssize_t pread (ACE_HANDLE handle, void *buf, size_t nbyte, off_t offset)
int recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags)
int sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
ssize_t write (ACE_HANDLE handle, const void *buf, size_t nbyte)
ssize_t write (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OVERLAPPED *)
ssize_t write_n (ACE_HANDLE handle, const void *buf, size_t len, size_t *bytes_transferred=0)
ssize_t pwrite (ACE_HANDLE handle, const void *buf, size_t nbyte, off_t offset)
ssize_t readv (ACE_HANDLE handle, iovec *iov, int iovlen)
ssize_t writev (ACE_HANDLE handle, const iovec *iov, int iovcnt)
ssize_t recvv (ACE_HANDLE handle, iovec *iov, int iovlen)
ssize_t sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt)
A set of wrappers for event demultiplexing and IPC.
int select (int width, fd_set *rfds, fd_set *wfds=0, fd_set *efds=0, const ACE_Time_Value *tv=0)
int select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &tv)
int poll (struct pollfd *pollfds, u_long len, const ACE_Time_Value *tv=0)
int poll (struct pollfd *pollfds, u_long len, const ACE_Time_Value &tv)
int pipe (ACE_HANDLE handles[])
ACE_HANDLE shm_open (const ACE_TCHAR *filename, int mode, int perms=0, LPSECURITY_ATTRIBUTES sa=0)
int shm_unlink (const ACE_TCHAR *path)
A set of wrappers for directory operations.
mode_t umask (mode_t cmask)
int chdir (const char *path)
int chdir (const wchar_t *path)
int mkdir (const ACE_TCHAR *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
int mkfifo (const ACE_TCHAR *file, mode_t mode=ACE_DEFAULT_FILE_PERMS)
ACE_TCHARmktemp (ACE_TCHAR *t)
ACE_HANDLE mkstemp (ACE_TCHAR *t)
ACE_TCHARgetcwd (ACE_TCHAR *, size_t)
int rename (const ACE_TCHAR *old_name, const ACE_TCHAR *new_name, int flags=-1)
int unlink (const ACE_TCHAR *path)
ACE_TCHARtempnam (const ACE_TCHAR *dir=0, const ACE_TCHAR *pfx=0)
A set of wrappers for random number operations.
int rand (void)
int rand_r (ACE_RANDR_TYPE &seed)
void srand (u_int seed)
A set of wrappers for readers/writer locks.
int rwlock_init (ACE_rwlock_t *rw, int type=ACE_DEFAULT_SYNCH_TYPE, const ACE_TCHAR *name=0, void *arg=0)
int rwlock_destroy (ACE_rwlock_t *rw)
int rw_rdlock (ACE_rwlock_t *rw)
int rw_wrlock (ACE_rwlock_t *rw)
int rw_tryrdlock (ACE_rwlock_t *rw)
int rw_trywrlock (ACE_rwlock_t *rw)
int rw_trywrlock_upgrade (ACE_rwlock_t *rw)
int rw_unlock (ACE_rwlock_t *rw)
A set of wrappers for auto-reset and manual events.
int event_init (ACE_event_t *event, int manual_reset=0, int initial_state=0, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
int event_init (ACE_event_t *event, int manual_reset, int initial_state, int type, const wchar_t *name, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
int event_destroy (ACE_event_t *event)
int event_wait (ACE_event_t *event)
int event_timedwait (ACE_event_t *event, ACE_Time_Value *timeout, int use_absolute_time=1)
int event_signal (ACE_event_t *event)
int event_pulse (ACE_event_t *event)
int event_reset (ACE_event_t *event)
A set of wrappers for semaphores.
int sema_destroy (ACE_sema_t *s)
int sema_init (ACE_sema_t *s, u_int count, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0, int max=0x7fffffff, LPSECURITY_ATTRIBUTES sa=0)
int sema_init (ACE_sema_t *s, u_int count, int type, const wchar_t *name, void *arg=0, int max=0x7fffffff, LPSECURITY_ATTRIBUTES sa=0)
int sema_post (ACE_sema_t *s)
int sema_post (ACE_sema_t *s, u_int release_count)
int sema_trywait (ACE_sema_t *s)
int sema_wait (ACE_sema_t *s)
int sema_wait (ACE_sema_t *s, ACE_Time_Value &tv)
int sema_wait (ACE_sema_t *s, ACE_Time_Value *tv)
A set of wrappers for System V semaphores.
int semctl (int int_id, int semnum, int cmd, semun)
int semget (key_t key, int nsems, int flags)
int semop (int int_id, struct sembuf *sops, size_t nsops)
Thread scheduler interface.
int sched_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)
 Set scheduling parameters. An id of ACE_SELF indicates, e.g., set the parameters on the calling thread. More...

A set of wrappers for System V shared memory.
void * shmat (int int_id, void *shmaddr, int shmflg)
int shmctl (int int_id, int cmd, struct shmid_ds *buf)
int shmdt (void *shmaddr)
int shmget (key_t key, int size, int flags)
A set of wrappers for Signals.
int kill (pid_t pid, int signum)
int sigaction (int signum, const struct sigaction *nsa, struct sigaction *osa)
int sigaddset (sigset_t *s, int signum)
int sigdelset (sigset_t *s, int signum)
int sigemptyset (sigset_t *s)
int sigfillset (sigset_t *s)
int sigismember (sigset_t *s, int signum)
ACE_SignalHandler signal (int signum, ACE_SignalHandler)
int sigsuspend (const sigset_t *set)
int sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
int pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp)
A set of wrappers for sockets.
ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS). More...

ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen, const ACE_Accept_QoS_Params &qos_params)
int connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
 BSD-style <connect> (no QoS). More...

int connect (ACE_HANDLE handle, const sockaddr *addr, int addrlen, const ACE_QoS_Params &qos_params)
int bind (ACE_HANDLE s, struct sockaddr *name, int namelen)
 BSD-style <accept> (no QoS). More...

int closesocket (ACE_HANDLE s)
 BSD-style <accept> (no QoS). More...

hostent * gethostbyaddr (const char *addr, int length, int type)
 BSD-style <accept> (no QoS). More...

hostent * gethostbyname (const char *name)
 BSD-style <accept> (no QoS). More...

hostent * getipnodebyname (const char *name, int family, int flags=0)
 BSD-style <accept> (no QoS). More...

hostent * getipnodebyaddr (const void *src, size_t len, int family)
 BSD-style <accept> (no QoS). More...

hostent * gethostbyaddr_r (const char *addr, int length, int type, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
 BSD-style <accept> (no QoS). More...

hostent * gethostbyname_r (const char *name, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
 BSD-style <accept> (no QoS). More...

int getpeername (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS). More...

protoent * getprotobyname (const char *name)
 BSD-style <accept> (no QoS). More...

protoent * getprotobyname_r (const char *name, struct protoent *result, ACE_PROTOENT_DATA buffer)
 BSD-style <accept> (no QoS). More...

protoent * getprotobynumber (int proto)
 BSD-style <accept> (no QoS). More...

protoent * getprotobynumber_r (int proto, struct protoent *result, ACE_PROTOENT_DATA buffer)
 BSD-style <accept> (no QoS). More...

servent * getservbyname (const char *svc, const char *proto)
 BSD-style <accept> (no QoS). More...

servent * getservbyname_r (const char *svc, const char *proto, struct servent *result, ACE_SERVENT_DATA buf)
 BSD-style <accept> (no QoS). More...

int getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS). More...

int getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen)
 BSD-style <accept> (no QoS). More...

unsigned long inet_addr (const char *name)
 BSD-style <accept> (no QoS). More...

char * inet_ntoa (const struct in_addr addr)
 BSD-style <accept> (no QoS). More...

int inet_aton (const char *strptr, struct in_addr *addr)
 BSD-style <accept> (no QoS). More...

const char * inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
 BSD-style <accept> (no QoS). More...

int inet_pton (int family, const char *strptr, void *addrptr)
 BSD-style <accept> (no QoS). More...

int enum_protocols (int *protocols, ACE_Protocol_Info *protocol_buffer, u_long *buffer_length)
 Retrieve information about available transport protocols installed on the local machine. More...

ACE_HANDLE join_leaf (ACE_HANDLE socket, const sockaddr *name, int namelen, const ACE_QoS_Params &qos_params)
 Joins a leaf node into a QoS-enabled multi-point session. More...

int listen (ACE_HANDLE handle, int backlog)
 BSD-style <accept> (no QoS). More...

int recv (ACE_HANDLE handle, char *buf, size_t len, int flags=0)
 BSD-style <accept> (no QoS). More...

int recvfrom (ACE_HANDLE handle, char *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS). More...

int recvfrom (ACE_HANDLE handle, iovec *buffers, int buffer_count, size_t &number_of_bytes_recvd, int &flags, struct sockaddr *addr, int *addrlen, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 BSD-style <accept> (no QoS). More...

int send (ACE_HANDLE handle, const char *buf, size_t len, int flags=0)
 BSD-style <accept> (no QoS). More...

int sendto (ACE_HANDLE handle, const char *buf, size_t len, int flags, const struct sockaddr *addr, int addrlen)
 BSD-style <accept> (no QoS). More...

int sendto (ACE_HANDLE handle, const iovec *buffers, int buffer_count, size_t &number_of_bytes_sent, int flags, const struct sockaddr *addr, int addrlen, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 BSD-style <accept> (no QoS). More...

int setsockopt (ACE_HANDLE handle, int level, int optname, const char *optval, int optlen)
 Manipulate the options associated with a socket. More...

int shutdown (ACE_HANDLE handle, int how)
 BSD-style <accept> (no QoS). More...

ACE_HANDLE socket (int protocol_family, int type, int proto)
 Create a BSD-style socket (no QoS). More...

ACE_HANDLE socket (int protocol_family, int type, int proto, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags)
 Create a QoS-enabled socket. If the OS platform doesn't support QoS-enabled <socket> then the BSD-style <socket> is called. More...

int socketpair (int domain, int type, int protocol, ACE_HANDLE sv[2])
 BSD-style <accept> (no QoS). More...

int socket_init (int version_high=1, int version_low=1)
 Initialize WinSock before first use (e.g., when a DLL is first loaded or the first use of a socket() call. More...

int socket_fini (void)
 Finalize WinSock after last use (e.g., when a DLL is unloaded). More...

A set of wrappers for password routines.
void setpwent (void)
void endpwent (void)
passwd * getpwent (void)
passwd * getpwnam (const char *user)
passwd * getpwnam_r (const char *name, struct passwd *pwent, char *buffer, int buflen)
A set of wrappers for regular expressions.
char * compile (const char *instring, char *expbuf, char *endbuf)
int step (const char *str, char *expbuf)

Static Public Attributes

int socket_initialized_
 Keeps track of whether we've already initialized WinSock... More...


Private Methods

 ACE_CLASS_IS_NAMESPACE (ACE_OS)

Static Private Methods

ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook)
 For use by ACE_Object_Manager only, to register its exit hook.. More...

void fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode)
 Translate fopen's mode char to open's mode. This helper function is here to avoid maintaining several pieces of identical code. More...

int cond_timedwait_i (ACE_cond_t *cv, ACE_mutex_t *m, ACE_Time_Value *)
u_int alarm_i (u_int secs)
u_int ualarm_i (u_int usecs, u_int interval=0)
u_int ualarm_i (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval=ACE_Time_Value::zero)
int sleep_i (u_int seconds)
int sleep_i (const ACE_Time_Value &tv)
int nanosleep_i (const struct timespec *requested, struct timespec *remaining=0)
int select_i (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value *tv=0)
int select_i (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &tv)
int poll_i (struct pollfd *pollfds, u_long len, const ACE_Time_Value *tv=0)
int poll_i (struct pollfd *pollfds, u_long len, const ACE_Time_Value &tv)
int sema_wait_i (ACE_sema_t *s)
int sema_wait_i (ACE_sema_t *s, ACE_Time_Value &tv)
int sigtimedwait_i (const sigset_t *set, siginfo_t *info, const ACE_Time_Value *timeout)
ACE_Time_Value gettimeofday_i (void)

Static Private Attributes

ACE_EXIT_HOOK exit_hook_ = 0
 Function that is called by <ACE_OS::exit>, if non-null. More...

OSVERSIONINFO win32_versioninfo_
HINSTANCE win32_resource_module_

Friends

class ACE_Timeout_Manager
class ACE_OS_Object_Manager
 Allow the ACE_OS_Object_Manager to call set_exit_hook. More...


Detailed Description

This class defines an OS independent programming API that shields developers from nonportable aspects of writing efficient system programs on Win32, POSIX and other versions of UNIX, and various real-time operating systems.

This class encapsulates the differences between various OS platforms. When porting ACE to a new platform, this class is the place to focus on. Once this file is ported to a new platform, pretty much everything else comes for "free." See <www.cs.wustl.edu/~schmidt/ACE_wrappers/etc/ACE-porting.html> for instructions on porting ACE. Please see the README file in this directory for complete information on the meaning of the various macros.

Definition at line 4585 of file OS.h.


Member Typedef Documentation

typedef wchar_t ACE_OS::WChar
 

Definition at line 5793 of file OS.h.

Referenced by ACE_Log_Msg::log, wscmp, wscpy, and wsncmp.


Member Enumeration Documentation

enum ACE_OS::ACE_HRTimer_Op
 

Enumeration values:
ACE_HRTIMER_START 
ACE_HRTIMER_INCR 
ACE_HRTIMER_STOP 
ACE_HRTIMER_GETTIME 

Definition at line 4606 of file OS.h.

Referenced by ACE_High_Res_Timer::gettime, ACE_High_Res_Timer::gettimeofday, ACE_High_Res_Timer::start, ACE_High_Res_Timer::start_incr, ACE_High_Res_Timer::stop, and ACE_High_Res_Timer::stop_incr.

04607     {
04608       ACE_HRTIMER_START = 0x0,  // Only use these if you can stand
04609       ACE_HRTIMER_INCR = 0x1,   // for interrupts to be disabled during
04610       ACE_HRTIMER_STOP = 0x2,   // the timed interval!!!!
04611       ACE_HRTIMER_GETTIME = 0xFFFF
04612     };


Member Function Documentation

ACE_INLINE void ACE_OS::_exit int    status = 0 [static]
 

Definition at line 1019 of file OS.i.

References ACE_OS_TRACE.

Referenced by ACE::fork, and ACE_Process::spawn.

01020 {
01021   ACE_OS_TRACE ("ACE_OS::_exit");
01022 #if defined (VXWORKS)
01023   ::exit (status);
01024 #elif defined (ACE_PSOSIM)
01025   ::u_exit (status);
01026 #elif defined (ACE_PSOS)
01027 # if defined (ACE_PSOS_LACKS_PREPC)  /* pSoS TM does not support exit. */
01028   ACE_UNUSED_ARG (status);
01029   return;
01030 # else
01031   ::exit (status);
01032 # endif /* defined (ACE_PSOS_LACKS_PREPC) */
01033 #elif !defined (ACE_HAS_WINCE)
01034   ::_exit (status);
01035 #else
01036   ::TerminateProcess (::GetCurrentProcess (),
01037                       status);
01038 #endif /* VXWORKS */
01039 }

ACE_INLINE void ACE_OS::abort void    [static]
 

Definition at line 1042 of file OS.i.

References exit.

Referenced by ACE_Log_Msg::log.

01043 {
01044 #if !defined (ACE_HAS_WINCE)
01045   ::abort ();
01046 #else
01047   // @@ CE doesn't support abort?
01048   exit (1);
01049 #endif /* !ACE_HAS_WINCE */
01050 }

ACE_HANDLE ACE_OS::accept ACE_HANDLE    handle,
struct sockaddr *    addr,
int *    addrlen,
const ACE_Accept_QoS_Params   qos_params
[static]
 

QoS-enabled <accept>, which passes <qos_params> to <accept>. If the OS platform doesn't support QoS-enabled <accept> then the <qos_params> are ignored and the BSD-style <accept> is called.

Definition at line 7412 of file OS.cpp.

References accept, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, ACE_Accept_QoS_Params::callback_data, and ACE_Accept_QoS_Params::qos_condition_callback.

07416 {
07417 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
07418   ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle,
07419                                     addr,
07420                                     (ACE_SOCKET_LEN *) addrlen,
07421                                     (LPCONDITIONPROC) qos_params.qos_condition_callback (),
07422                                     qos_params.callback_data ()),
07423                        ACE_HANDLE,
07424                        ACE_INVALID_HANDLE);
07425 # else
07426   ACE_UNUSED_ARG (qos_params);
07427   return ACE_OS::accept (handle,
07428                          addr,
07429                          addrlen);
07430 # endif /* ACE_HAS_WINSOCK2 */
07431 }

ACE_INLINE ACE_HANDLE ACE_OS::accept ACE_HANDLE    handle,
struct sockaddr *    addr,
int *    addrlen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4694 of file OS.i.

References accept, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and EWOULDBLOCK.

Referenced by ACE_SOCK_Acceptor::accept, accept, ACE_MEM_Acceptor::accept, ACE_LSOCK_Acceptor::accept, ACE_ATM_Acceptor::accept, and ACE_POSIX_Asynch_Accept::handle_input.

04697 {
04698   ACE_OS_TRACE ("ACE_OS::accept");
04699 #if defined (ACE_PSOS)
04700 #  if !defined (ACE_PSOS_DIAB_PPC)
04701   ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle,
04702                                  (struct sockaddr_in *) addr,
04703                                  (ACE_SOCKET_LEN *) addrlen),
04704                        ACE_HANDLE,
04705                        ACE_INVALID_HANDLE);
04706 #  else
04707 ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle,
04708                                (struct sockaddr *) addr,
04709                                (ACE_SOCKET_LEN *) addrlen),
04710                      ACE_HANDLE,
04711                      ACE_INVALID_HANDLE);
04712 #  endif /* defined ACE_PSOS_DIAB_PPC */
04713 #else
04714   // On a non-blocking socket with no connections to accept, this
04715   // system call will return EWOULDBLOCK or EAGAIN, depending on the
04716   // platform.  UNIX 98 allows either errno, and they may be the same
04717   // numeric value.  So to make life easier for upper ACE layers as
04718   // well as application programmers, always change EAGAIN to
04719   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
04720   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
04721   // this function needs to be reviewed.  On Win32, the regular macros
04722   // can be used, as this is not an issue.
04723 
04724 #  if defined (ACE_WIN32)
04725   ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle,
04726                                  addr,
04727                                  (ACE_SOCKET_LEN *) addrlen),
04728                        ACE_HANDLE,
04729                        ACE_INVALID_HANDLE);
04730 #  else
04731 #    if defined (ACE_HAS_BROKEN_ACCEPT_ADDR)
04732   // Apparently some platforms like VxWorks can't correctly deal with
04733   // a NULL addr.
04734 
04735    sockaddr_in fake_addr;
04736    int fake_addrlen;
04737 
04738    if (addrlen == 0)
04739      addrlen = &fake_addrlen;
04740 
04741    if (addr == 0)
04742      {
04743        addr = (sockaddr *) &fake_addr;
04744        *addrlen = sizeof fake_addr;
04745      }
04746 #    endif /* VXWORKS */
04747   ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle,
04748                                     addr,
04749                                     (ACE_SOCKET_LEN *) addrlen) ;
04750   if (ace_result == ACE_INVALID_HANDLE && errno == EAGAIN)
04751     errno = EWOULDBLOCK;
04752   return ace_result;
04753 
04754 #  endif /* defined (ACE_WIN32) */
04755 #endif /* defined (ACE_PSOS) */
04756 }

int ACE_OS::access const wchar_t *    path,
int    amode
[static]
 

ACE_INLINE int ACE_OS::access const char *    path,
int    amode
[static]
 

Definition at line 7681 of file OS.i.

References access, ACE_LIB_TEXT, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, fclose, and fopen.

Referenced by access, ACE_Filecache_Object::ACE_Filecache_Object, ACE_Local_Name_Space::create_manager_i, ACE_Lib_Find::ldfind, open, and ACE_Configuration_Heap::open.

07682 {
07683   ACE_OS_TRACE ("ACE_OS::access");
07684 #if defined (ACE_LACKS_ACCESS)
07685 #  if defined (ACE_HAS_WINCE)
07686   // @@ WINCE: There should be a Win32 API that can do this.
07687   // Hard coded read access here.
07688     FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path), ACE_LIB_TEXT ("r"));
07689   ACE_UNUSED_ARG (amode);
07690 
07691   ACE_OS::fclose (handle);
07692   return (handle == ACE_INVALID_HANDLE ? -1 : 0);
07693 #  else
07694     ACE_UNUSED_ARG (path);
07695     ACE_UNUSED_ARG (amode);
07696     ACE_NOTSUP_RETURN (-1);
07697 #  endif  // ACE_HAS_WINCE
07698 #else
07699   ACE_OSCALL_RETURN (::access (path, amode), int, -1);
07700 #endif /* ACE_LACKS_ACCESS */
07701 }

ACE_OS::ACE_CLASS_IS_NAMESPACE ACE_OS    [private]
 

void ACE_OS::adjust_flock_params ACE_OS::ace_flock_t   lock,
short    whence,
off_t &    start,
off_t &    len
[static]
 

Referenced by flock_rdlock, flock_tryrdlock, flock_trywrlock, flock_unlock, and flock_wrlock.

ACE_INLINE u_int ACE_OS::alarm u_int    secs [static]
 

Definition at line 7901 of file OS.i.

References ACE_OS_TRACE.

07902 {
07903   ACE_OS_TRACE ("ACE_OS::alarm");
07904 #if defined (ACE_WIN32) || defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS)
07905   ACE_UNUSED_ARG (secs);
07906 
07907   ACE_NOTSUP_RETURN (0);
07908 #else
07909   return ::alarm (secs);
07910 #endif /* ACE_WIN32 || VXWORKS || CHORUS || ACE_PSOS */
07911 }

u_int ACE_OS::alarm_i u_int    secs [static, private]
 

ACE_INLINE int ACE_OS::allocation_granularity void    [static]
 

Definition at line 9719 of file OS.i.

References getpagesize.

Referenced by ACE::round_to_allocation_granularity.

09720 {
09721 #if defined (ACE_WIN32)
09722   SYSTEM_INFO sys_info;
09723   ::GetSystemInfo (&sys_info);
09724   return (int) sys_info.dwAllocationGranularity;
09725 #else
09726   return ACE_OS::getpagesize ();
09727 #endif /* ACE_WIN32 */
09728 }

int ACE_OS::argv_to_string ACE_TCHAR **    argv,
ACE_TCHAR *&    buf,
int    substitute_env_args = 1
[static]
 

Definition at line 3900 of file OS.cpp.

References ACE_NEW_RETURN, ACE_TCHAR, getenv, ACE_OS_String::strecpy, and ACE_OS_String::strlen.

Referenced by ACE_ARGV::argv_to_string, and fork_exec.

03903 {
03904   if (argv == 0 || argv[0] == 0)
03905     return 0;
03906 
03907   size_t buf_len = 0;
03908 
03909   // Determine the length of the buffer.
03910 
03911   for (int i = 0; argv[i] != 0; i++)
03912     {
03913       ACE_TCHAR *temp = 0;
03914 
03915 #if !defined (ACE_LACKS_ENV)
03916       // Account for environment variables.
03917       if (substitute_env_args
03918           && (argv[i][0] == '$'
03919               && (temp = ACE_OS::getenv (&argv[i][1])) != 0))
03920         buf_len += ACE_OS_String::strlen (temp);
03921       else
03922 #endif /* ACE_LACKS_ENV */
03923         buf_len += ACE_OS_String::strlen (argv[i]);
03924 
03925       // Add one for the extra space between each string.
03926       buf_len++;
03927     }
03928 
03929   // Step through all argv params and copy each one into buf; separate
03930   // each param with white space.
03931 
03932   ACE_NEW_RETURN (buf,
03933                   ACE_TCHAR[buf_len + 1],
03934                   0);
03935 
03936   // Initial null charater to make it a null string.
03937   buf[0] = '\0';
03938   ACE_TCHAR *end = buf;
03939   int j;
03940 
03941   for (j = 0; argv[j] != 0; j++)
03942     {
03943       ACE_TCHAR *temp = 0;
03944 
03945 # if !defined (ACE_LACKS_ENV)
03946       // Account for environment variables.
03947       if (substitute_env_args
03948       && (argv[j][0] == '$'
03949               && (temp = ACE_OS::getenv (&argv[j][1])) != 0))
03950         end = ACE_OS::strecpy (end, temp);
03951       else
03952 #endif /* ACE_LACKS_ENV */
03953         end = ACE_OS::strecpy (end, argv[j]);
03954 
03955       // Replace the null char that strecpy put there with white
03956       // space.
03957       end[-1] = ' ';
03958     }
03959 
03960   // Null terminate the string.
03961   *end = '\0';
03962   // The number of arguments.
03963   return j;
03964 }

ACE_INLINE char * ACE_OS::asctime const struct tm *    tm [static]
 

Definition at line 8811 of file OS.i.

References ACE_OS_TRACE, and asctime.

Referenced by asctime, asctime_r, and ctime.

08812 {
08813 #if !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
08814   ACE_OS_TRACE ("ACE_OS::asctime");
08815   ACE_OSCALL_RETURN (::asctime (t), char *, 0);
08816 #else
08817   // @@ WinCE doesn't have gmtime also.
08818   ACE_UNUSED_ARG (t);
08819   ACE_NOTSUP_RETURN (0);
08820 #endif /*  !ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */
08821 }

ACE_INLINE char * ACE_OS::asctime_r const struct tm *    tm,
char *    buf,
int    buflen
[static]
 

Definition at line 8824 of file OS.i.

References ACE_OS_TRACE, asctime, asctime_r, and ACE_OS_String::strsncpy.

Referenced by asctime_r.

08825 {
08826   ACE_OS_TRACE ("ACE_OS::asctime_r");
08827 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
08828 # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
08829   char *result;
08830 #   if defined (DIGITAL_UNIX)
08831   ACE_OSCALL (::_Pasctime_r (t, buf), char *, 0, result);
08832 #   else
08833   ACE_OSCALL (::asctime_r (t, buf), char *, 0, result);
08834 #   endif /* DIGITAL_UNIX */
08835   ACE_OS::strsncpy (buf, result, buflen);
08836   return buf;
08837 # else
08838 #   if defined (HPUX_10)
08839   return (::asctime_r(t, buf, buflen) == 0 ? buf : (char *)0);
08840 #   else
08841   ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0);
08842 #   endif /* HPUX_10 */
08843 # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
08844 #elif ! defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
08845   char *result;
08846   ACE_OSCALL (::asctime (t), char *, 0, result);
08847   ACE_OS::strsncpy (buf, result, buflen);
08848   return buf;
08849 #else
08850   // @@ Same as ACE_OS::asctime (), you need to implement it
08851   //    yourself.
08852   ACE_UNUSED_ARG (t);
08853   ACE_UNUSED_ARG (buf);
08854   ACE_UNUSED_ARG (buflen);
08855   ACE_NOTSUP_RETURN (0);
08856 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
08857 }

ACE_INLINE int ACE_OS::atexit ACE_EXIT_HOOK    func [static]
 

Definition at line 1011 of file OS.i.

References ACE_OS_Object_Manager::at_exit, and ACE_OS_Object_Manager::instance.

01012 {
01013   return ACE_OS_Object_Manager::instance ()->at_exit (func);
01014 }

int ACE_OS::atoi const wchar_t *    s [static]
 

ACE_INLINE int ACE_OS::atoi const char *    s [static]
 

Definition at line 5521 of file OS.i.

References atoi.

Referenced by atoi, ACE_High_Res_Timer::get_env_global_scale_factor, ACE_Service_Manager::init, ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr, ACE_Service_Config::parse_args, ACE_Name_Options::parse_args, ACE_Logging_Strategy::parse_args, ACE_Registry_ImpExp::process_previous_line_format, ACE_SOCK_Dgram::set_nic, and ACE_INET_Addr::string_to_addr.

05522 {
05523   ACE_OSCALL_RETURN (::atoi (s), int, -1);
05524 }

void* ACE_OS::atop const wchar_t *    s [static]
 

ACE_INLINE void * ACE_OS::atop const char *    s [static]
 

Definition at line 5540 of file OS.i.

References ACE_TRACE.

Referenced by ACE_Name_Options::parse_args.

05541 {
05542   ACE_TRACE ("ACE_OS::atop");
05543   // It would be nice to make use of Basic_Types.h here, but that
05544   // file relies on OS.h. Fortunately, most platforms have int
05545   // the same as pointer size (IA32, IA64), with Win64 being the
05546   // exception.
05547 #if defined (ACE_WIN64)
05548   __int64 ip = ::_atoi64 (s);
05549 #else
05550   int ip = ::atoi (s);
05551 #endif /* ACE_WIN64 */
05552   void *p = ACE_reinterpret_cast (void *, ip);
05553   return p;
05554 }

ACE_INLINE int ACE_OS::bind ACE_HANDLE    s,
struct sockaddr *    name,
int    namelen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4781 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and bind.

Referenced by bind, ACE_Sock_Connect::bind_port, ACE_WIN32_Asynch_Connect::connect_i, ACE_POSIX_Asynch_Connect::connect_i, ACE_SOCK_CODgram::open, ACE_ATM_Stream::open, ACE_ATM_Acceptor::open, ACE_Asynch_Acceptor::open, ACE_SOCK_Connector::shared_connect_start, ACE_SOCK_Dgram::shared_open, and ACE_SOCK_Acceptor::shared_open.

04782 {
04783   ACE_OS_TRACE ("ACE_OS::bind");
04784 #if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC)
04785   ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle,
04786                                (struct sockaddr_in *) addr,
04787                                (ACE_SOCKET_LEN) addrlen),
04788                        int, -1);
04789 #else /* !defined (ACE_PSOS) || defined (ACE_PSOS_DIAB_PPC) */
04790   ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle,
04791                                addr,
04792                                (ACE_SOCKET_LEN) addrlen), int, -1);
04793 #endif /* defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC) */
04794 }

ACE_INLINE void * ACE_OS::bsearch const void *    key,
const void *    base,
size_t    nel,
size_t    size,
ACE_COMPARE_FUNC   
[static]
 

Definition at line 10887 of file OS.i.

References ACE_COMPARE_FUNC.

10892 {
10893 #if !defined (ACE_LACKS_BSEARCH)
10894   return ::bsearch (key, base, nel, size, compar);
10895 #else
10896   ACE_UNUSED_ARG (key);
10897   ACE_UNUSED_ARG (base);
10898   ACE_UNUSED_ARG (nel);
10899   ACE_UNUSED_ARG (size);
10900   ACE_UNUSED_ARG (compar);
10901   ACE_NOTSUP_RETURN (0);
10902 #endif /* ACE_LACKS_BSEARCH */
10903 }

ACE_INLINE double ACE_OS::ceil double    x [static]
 

This method computes the smallest integral value not less than x.

Definition at line 5578 of file OS.i.

References floor.

05579 {
05580   // This method computes the smallest integral value not less than x.
05581   double floor = ACE_OS::floor (x);
05582   if (floor == x)
05583     return floor;
05584   else
05585     return floor + 1;
05586 }

int ACE_OS::chdir const wchar_t *    path [static]
 

ACE_INLINE int ACE_OS::chdir const char *    path [static]
 

Definition at line 159 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and chdir.

Referenced by chdir, ACE::daemonize, and ACE_Process::spawn.

00160 {
00161   ACE_OS_TRACE ("ACE_OS::chdir");
00162 #if defined (VXWORKS)
00163   ACE_OSCALL_RETURN (::chdir (ACE_const_cast (char *, path)), int, -1);
00164 
00165 #elif defined (ACE_PSOS_LACKS_PHILE)
00166   ACE_UNUSED_ARG (path);
00167   ACE_NOTSUP_RETURN (-1);
00168 
00169 #elif defined (ACE_PSOS)
00170     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::change_dir ((char *) path), ace_result_),
00171                      int, -1);
00172 
00173 // This #elif seems weird... is Visual Age on NT not setting ACE_WIN32?
00174 #elif !defined (ACE_WIN32) && !defined (AIX) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00175   ACE_OSCALL_RETURN (::_chdir (path), int, -1);
00176 
00177 #elif defined (ACE_HAS_WINCE)
00178   ACE_UNUSED_ARG (path);
00179   ACE_NOTSUP_RETURN (-1);
00180 
00181 #else
00182   ACE_OSCALL_RETURN (::chdir (path), int, -1);
00183 
00184 #endif /* VXWORKS */
00185 }

void ACE_OS::cleanup_tss const u_int    main_thread [static]
 

Call TSS destructors for the current thread. If the current thread is the main thread, then the argument must be 1. For private use of ACE_Object_Manager and ACE_Thread_Adapter only.

Definition at line 2445 of file OS.cpp.

References ACE_Base_Thread_Adapter::close_log_msg, ACE_TSS_Cleanup::exit, ACE_TSS_Cleanup::free_all_keys_left, and ACE_TSS_Cleanup::instance.

Referenced by ACE_Object_Manager::fini, ACE_OS_Thread_Adapter::invoke, ACE_Thread_Adapter::invoke_i, and thr_exit.

02446 {
02447 #if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS))
02448   // Call TSS destructors for current thread.
02449   ACE_TSS_Cleanup::instance ()->exit (0);
02450 #endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 || ACE_PSOS_HAS_TSS */
02451 
02452   if (main_thread)
02453     {
02454 #if !defined (ACE_HAS_TSS_EMULATION)  &&  !defined (ACE_HAS_MINIMAL_ACE_OS)
02455       // Just close the ACE_Log_Msg for the current (which should be
02456       // main) thread.  We don't have TSS emulation; if there's native
02457       // TSS, it should call its destructors when the main thread
02458       // exits.
02459       ACE_Base_Thread_Adapter::close_log_msg ();
02460 #endif /* ! ACE_HAS_TSS_EMULATION  &&  ! ACE_HAS_MINIMAL_ACE_OS */
02461 
02462 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS))
02463 #if ! defined (ACE_HAS_TSS_EMULATION)
02464       // Don't do this with TSS_Emulation, because the the
02465       // ACE_TSS_Cleanup::instance () has already exited ().  We can't
02466       // safely access the TSS values that were created by the main
02467       // thread.
02468 
02469       // Remove all TSS_Info table entries.
02470       ACE_TSS_Cleanup::instance ()->free_all_keys_left ();
02471 #endif /* ! ACE_HAS_TSS_EMULATION */
02472 
02473       // Finally, free up the ACE_TSS_Cleanup instance.  This method gets
02474       // called by the ACE_Object_Manager.
02475       delete ACE_TSS_Cleanup::instance ();
02476 #endif /* WIN32 || ACE_HAS_TSS_EMULATION || ACE_PSOS_HAS_TSS */
02477 
02478 #if defined (ACE_HAS_TSS_EMULATION)
02479       ACE_TSS_Emulation::tss_close ();
02480 #endif /* ACE_HAS_TSS_EMULATION */
02481     }
02482 }

ACE_INLINE void ACE_OS::clearerr FILE *    fp [static]
 

Definition at line 9973 of file OS.i.

09974 {
09975   ::clearerr(fp);
09976 }

ACE_INLINE int ACE_OS::clock_gettime clockid_t   ,
struct timespec  
[static]
 

Definition at line 597 of file OS.i.

References ACE_OS_TRACE, clock_gettime, and clockid_t.

Referenced by clock_gettime, gethrtime, and gettimeofday.

00598 {
00599   ACE_OS_TRACE ("ACE_OS::clock_gettime");
00600 #if defined (ACE_HAS_CLOCK_GETTIME)
00601   ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1);
00602 # elif defined (ACE_PSOS) && ! defined (ACE_PSOS_DIAB_MIPS)
00603   ACE_UNUSED_ARG (clockid);
00604   ACE_PSOS_Time_t pt;
00605   int result = ACE_PSOS_Time_t::get_system_time (pt);
00606   *ts = ACE_static_cast (struct timespec, pt);
00607   return result;
00608 #else
00609   ACE_UNUSED_ARG (clockid);
00610   ACE_UNUSED_ARG (ts);
00611   ACE_NOTSUP_RETURN (-1);
00612 #endif /* ACE_HAS_CLOCK_GETTIME */
00613 }

ACE_INLINE int ACE_OS::close ACE_HANDLE    handle [static]
 

Definition at line 2830 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and close.

Referenced by ACE_Condition::ACE_Condition, ACE_Filecache_Object::ACE_Filecache_Object, ACE_Mutex::ACE_Mutex, ACE_WIN32_Proactor::close, ACE_TLI_Stream::close, ACE_SPIPE::close, close, ACE_FILE::close, ACE_FIFO_Recv::close, ACE_FIFO::close, ACE_Dev_Poll_Reactor::close, ACE_DEV::close, ACE_Mem_Map::close_filemapping_handle, ACE_Mem_Map::close_handle, ACE_Handle_Gobbler::close_remaining_handles, closesocket, ACE_SPIPE_Connector::connect, ACE_SPIPE_Acceptor::create_new_instance, ACE::daemonize, filesize, flock_destroy, fopen, fork_exec, ACE_Handle_Gobbler::free_handles, ACE_Sock_Connect::get_bcast_addr, ACE_Sock_Connect::get_ip_interfaces, ACE_Filecache_Object::release, ACE_Process_Options::release_handles, sema_init, ACE_Process::spawn, ACE::terminate_process, ACE_Filecache_Handle::~ACE_Filecache_Handle, ACE_Filecache_Object::~ACE_Filecache_Object, and ACE_Process::~ACE_Process.

02831 {
02832   ACE_OS_TRACE ("ACE_OS::close");
02833 #if defined (ACE_WIN32)
02834   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1);
02835 #elif defined (ACE_PSOS) && ! defined (ACE_PSOS_LACKS_PHILE)
02836   u_long result = ::close_f (handle);
02837   if (result != 0)
02838     {
02839       errno = result;
02840       return ACE_static_cast (int, -1);
02841     }
02842   return ACE_static_cast (int, 0);
02843 #else
02844   ACE_OSCALL_RETURN (::close (handle), int, -1);
02845 #endif /* ACE_WIN32 */
02846 }

ACE_INLINE int ACE_OS::closesocket ACE_HANDLE    s [static]
 

BSD-style <accept> (no QoS).

Definition at line 7668 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, close, and closesocket.

Referenced by ACE_WIN32_Asynch_Accept::accept, ACE_SOCK::close, ACE_POSIX_Asynch_Accept::close, ACE_Pipe::close, ACE_Process::close_dup_handles, ACE_Process::close_passed_handles, closesocket, ACE_Asynch_Acceptor::handle_accept, ACE_Asynch_Connector::handle_connect, ACE_POSIX_Asynch_Accept::handle_input, ACE_Sock_Connect::ipv6_enabled, ACE_WIN32_Asynch_Connect::post_result, ACE_POSIX_Asynch_Connect::post_result, and ACE_AIOCB_Notify_Pipe_Manager::~ACE_AIOCB_Notify_Pipe_Manager.

07669 {
07670   ACE_OS_TRACE ("ACE_OS::closesocket");
07671 #if defined (ACE_WIN32)
07672   ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1);
07673 #elif defined (ACE_PSOS_DIAB_PPC)
07674   ACE_OSCALL_RETURN (::pna_close (handle), int, -1);
07675 #else
07676   ACE_OSCALL_RETURN (::close (handle), int, -1);
07677 #endif /* ACE_WIN32 */
07678 }

ACE_INLINE char * ACE_OS::compile const char *    instring,
char *    expbuf,
char *    endbuf
[static]
 

Definition at line 7637 of file OS.i.

References ACE_OS_TRACE, and compile.

Referenced by compile, ACE_Local_Name_Space::list_type_entries_i, and ACE_Local_Name_Space::list_types_i.

07638 {
07639   ACE_OS_TRACE ("ACE_OS::compile");
07640 #if defined (ACE_HAS_REGEX)
07641   ACE_OSCALL_RETURN (::compile (instring, expbuf, endbuf), char *, 0);
07642 #else
07643   ACE_UNUSED_ARG (instring);
07644   ACE_UNUSED_ARG (expbuf);
07645   ACE_UNUSED_ARG (endbuf);
07646 
07647   ACE_NOTSUP_RETURN (0);
07648 #endif /* ACE_HAS_REGEX */
07649 }

ACE_INLINE int ACE_OS::cond_broadcast ACE_cond_t *    cv [static]
 

Definition at line 2178 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and cond_broadcast.

Referenced by ACE_Condition::broadcast, ACE_Condition< ACE_Recursive_Thread_Mutex >::broadcast, ACE_Condition_Thread_Mutex::broadcast, cond_broadcast, event_pulse, event_signal, ACE_Condition::remove, and rw_unlock.

02179 {
02180   ACE_OS_TRACE ("ACE_OS::cond_broadcast");
02181 # if defined (ACE_HAS_THREADS)
02182 #   if defined (ACE_HAS_PTHREADS)
02183 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02184   ACE_OSCALL_RETURN (::pthread_cond_broadcast (cv), int, -1);
02185 #     else
02186   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_broadcast (cv),
02187                                        ace_result_),
02188                      int, -1);
02189 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02190 #   elif defined (ACE_HAS_STHREADS)
02191   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv),
02192                                        ace_result_),
02193                      int, -1);
02194 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02195   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_broadcast (*cv), ace_result_),
02196                      int, -1);
02197 #   endif /* ACE_HAS_STHREADS */
02198 # else
02199   ACE_UNUSED_ARG (cv);
02200   ACE_NOTSUP_RETURN (-1);
02201 # endif /* ACE_HAS_THREADS */
02202 }

ACE_INLINE int ACE_OS::cond_destroy ACE_cond_t *    cv [static]
 

Definition at line 1964 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and cond_destroy.

Referenced by cond_destroy, event_destroy, recursive_mutex_destroy, ACE_Condition::remove, ACE_Condition< ACE_Recursive_Thread_Mutex >::remove, rwlock_destroy, sema_destroy, and sema_init.

01965 {
01966   ACE_OS_TRACE ("ACE_OS::cond_destroy");
01967 # if defined (ACE_HAS_THREADS)
01968 #   if defined (ACE_HAS_PTHREADS)
01969 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
01970   ACE_OSCALL_RETURN (::pthread_cond_destroy (cv), int, -1);
01971 #     else
01972   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_destroy (cv), ace_result_), int, -1);
01973 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
01974 #   elif defined (ACE_HAS_STHREADS)
01975   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), ace_result_), int, -1);
01976 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
01977   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_delete (*cv), ace_result_),
01978                      int, -1);
01979 #   endif /* ACE_HAS_STHREADS */
01980 # else
01981   ACE_UNUSED_ARG (cv);
01982   ACE_NOTSUP_RETURN (-1);
01983 # endif /* ACE_HAS_THREADS */
01984 }

int ACE_OS::cond_init ACE_cond_t *    cv,
ACE_condattr_t &    attributes,
const wchar_t *    name,
void *    arg = 0
[static]
 

int ACE_OS::cond_init ACE_cond_t *    cv,
short    type,
const wchar_t *    name,
void *    arg = 0
[static]
 

ACE_INLINE int ACE_OS::cond_init ACE_cond_t *    cv,
ACE_condattr_t &    attributes,
const char *    name = 0,
void *    arg = 0
[static]
 

Definition at line 2073 of file OS.i.

References ACE_ADAPT_RETVAL, and cond_init.

02077 {
02078   // ACE_OS_TRACE ("ACE_OS::cond_init");
02079   ACE_UNUSED_ARG (name);
02080   ACE_UNUSED_ARG (arg);
02081 # if defined (ACE_HAS_THREADS)
02082 #   if defined (ACE_HAS_PTHREADS)
02083   int result = -1;
02084 
02085   if (
02086 #     if defined  (ACE_HAS_PTHREADS_DRAFT4)
02087       ::pthread_cond_init (cv, attributes) == 0
02088 #     elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7)
02089       ACE_ADAPT_RETVAL(::pthread_cond_init (cv, &attributes), result) == 0
02090 #     else  /* this is draft 6 */
02091       ::pthread_cond_init (cv, &attributes) == 0
02092 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
02093       )
02094      result = 0;
02095   else
02096      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
02097 
02098   return result;
02099 #   elif defined (ACE_HAS_STHREADS)
02100   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv,
02101                                                     attributes.type,
02102                                                     arg),
02103                                        ace_result_),
02104                      int, -1);
02105 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02106   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_create (ACE_const_cast (char *, name),
02107                                                     attributes,
02108                                                     cv),
02109                                        ace_result_),
02110                      int, -1);
02111 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. ACE_PSOS */
02112 # else
02113   ACE_UNUSED_ARG (cv);
02114   ACE_UNUSED_ARG (attributes);
02115   ACE_UNUSED_ARG (name);
02116   ACE_UNUSED_ARG (arg);
02117   ACE_NOTSUP_RETURN (-1);
02118 # endif /* ACE_HAS_THREADS */
02119 }

ACE_INLINE int ACE_OS::cond_init ACE_cond_t *    cv,
short    type = ACE_DEFAULT_SYNCH_TYPE,
const char *    name = 0,
void *    arg = 0
[static]
 

Definition at line 2133 of file OS.i.

References condattr_destroy, and condattr_init.

Referenced by ACE_Condition::ACE_Condition, ACE_Condition< ACE_Recursive_Thread_Mutex >::ACE_Condition, ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex, cond_init, event_init, recursive_mutex_init, and sema_init.

02134 {
02135   ACE_condattr_t attributes;
02136   if (ACE_OS::condattr_init (attributes, type) == 0
02137       && ACE_OS::cond_init (cv, attributes, name, arg) == 0)
02138     {
02139       (void) ACE_OS::condattr_destroy (attributes);
02140       return 0;
02141     }
02142   return -1;
02143 }

ACE_INLINE int ACE_OS::cond_signal ACE_cond_t *    cv [static]
 

Definition at line 2154 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and cond_signal.

Referenced by cond_signal, event_pulse, event_signal, recursive_mutex_cond_unlock, recursive_mutex_unlock, rw_unlock, sema_post, ACE_Condition::signal, ACE_Condition< ACE_Recursive_Thread_Mutex >::signal, and ACE_Condition_Thread_Mutex::signal.

02155 {
02156   ACE_OS_TRACE ("ACE_OS::cond_signal");
02157 # if defined (ACE_HAS_THREADS)
02158 #   if defined (ACE_HAS_PTHREADS)
02159 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02160   ACE_OSCALL_RETURN (::pthread_cond_signal (cv), int, -1);
02161 #     else
02162   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_signal (cv),ace_result_),
02163                      int, -1);
02164 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02165 #   elif defined (ACE_HAS_STHREADS)
02166   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), ace_result_), int, -1);
02167 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02168   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_signal (*cv), ace_result_),
02169                      int, -1);
02170 #   endif /* ACE_HAS_STHREADS */
02171 # else
02172   ACE_UNUSED_ARG (cv);
02173   ACE_NOTSUP_RETURN (-1);
02174 # endif /* ACE_HAS_THREADS */
02175 }

ACE_INLINE int ACE_OS::cond_timedwait ACE_cond_t *    cv,
ACE_mutex_t *    m,
ACE_Time_Value  
[static]
 

Definition at line 2233 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, cond_wait, ETIME, ETIMEDOUT, gettimeofday, ACE_Time_Value::sec, ACE_Time_Value::set, and ACE_Time_Value::usec.

Referenced by event_timedwait, sema_wait, ACE_Condition::wait, ACE_Condition< ACE_Recursive_Thread_Mutex >::wait, and ACE_Condition_Thread_Mutex::wait.

02236 {
02237   ACE_OS_TRACE ("ACE_OS::cond_timedwait");
02238 # if defined (ACE_HAS_THREADS)
02239   int result;
02240   timespec_t ts;
02241 
02242   if (timeout != 0)
02243     ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
02244 
02245 #   if defined (ACE_HAS_PTHREADS)
02246 
02247 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02248   if (timeout == 0)
02249     ACE_OSCALL (::pthread_cond_wait (cv, external_mutex),
02250                 int, -1, result);
02251   else
02252     {
02253 
02254 #     if defined (__Lynx__)
02255       // Note that we must convert between absolute time (which is
02256       // passed as a parameter) and relative time (which is what the
02257       // LynxOS pthread_cond_timedwait expects).  This differs from 1003.4a
02258       // draft 4.
02259 
02260       timespec_t relative_time = *timeout - ACE_OS::gettimeofday ();
02261 
02262       ACE_OSCALL (::pthread_cond_timedwait (cv, external_mutex,
02263                                             &relative_time),
02264                   int, -1, result);
02265 #     else
02266       ACE_OSCALL (::pthread_cond_timedwait (cv, external_mutex,
02267                                             (ACE_TIMESPEC_PTR) &ts),
02268                   int, -1, result);
02269 #     endif /* __Lynx__ */
02270     }
02271 
02272 #     else
02273   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
02274                                 ? ::pthread_cond_wait (cv, external_mutex)
02275                                 : ::pthread_cond_timedwait (cv, external_mutex,
02276                                                             (ACE_TIMESPEC_PTR) &ts),
02277                                 result),
02278               int, -1, result);
02279 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/
02280   // We need to adjust this to make the POSIX and Solaris return
02281   // values consistent.  EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and
02282   // down); EINTR is from LynxOS.
02283   if (result == -1 &&
02284       (errno == ETIMEDOUT || errno == EAGAIN || errno == EINTR))
02285     errno = ETIME;
02286 
02287 #   elif defined (ACE_HAS_STHREADS)
02288   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
02289                                 ? ::cond_wait (cv, external_mutex)
02290                                 : ::cond_timedwait (cv,
02291                                                     external_mutex,
02292                                                     (timestruc_t*)&ts),
02293                                 result),
02294               int, -1, result);
02295 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02296   // pSOS condition value timeout is expressed in ticks. If the
02297   // cv_wait times out, the mutex is unlocked upon return.
02298   if (timeout == 0)
02299     {
02300       ACE_OSCALL (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, 0),
02301                                     result),
02302                   int, -1, result);
02303     }
02304   else
02305     {
02306       // Need to convert the passed absolute time to relative time
02307       // expressed in ticks.
02308       ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
02309       int ticks = (relative_time.sec () * KC_TICKS2SEC) +
02310                   (relative_time.usec () * KC_TICKS2SEC /
02311                    ACE_ONE_SECOND_IN_USECS);
02312       if (ticks <= 0)
02313         ticks = 1;    // Don't wait forever
02314       ACE_OSCALL (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, ticks),
02315                                     result),
02316                   int, -1, result);
02317       if (result == -1 && errno == 1)
02318         {
02319           // cv timed out and returned pSOS timeout error 0x01, which
02320           // ACE_ADAPT_RETVAL stored in errno.
02321           ::mu_lock (*external_mutex, MU_WAIT, 0);
02322           errno = ETIME;
02323         }
02324     }
02325 
02326   return result;
02327 
02328 #   endif /* ACE_HAS_STHREADS */
02329   if (timeout != 0)
02330     timeout->set (ts); // Update the time value before returning.
02331 
02332   return result;
02333 # else
02334   ACE_UNUSED_ARG (cv);
02335   ACE_UNUSED_ARG (external_mutex);
02336   ACE_UNUSED_ARG (timeout);
02337   ACE_NOTSUP_RETURN (-1);
02338 # endif /* ACE_HAS_THREADS */
02339 }

int ACE_OS::cond_timedwait_i ACE_cond_t *    cv,
ACE_mutex_t *    m,
ACE_Time_Value  
[static, private]
 

ACE_INLINE int ACE_OS::cond_wait ACE_cond_t *    cv,
ACE_mutex_t *    m
[static]
 

Definition at line 2205 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and cond_wait.

Referenced by cond_timedwait, cond_wait, event_wait, recursive_mutex_cond_relock, recursive_mutex_lock, rw_rdlock, rw_trywrlock_upgrade, rw_wrlock, sema_wait, ACE_Condition::wait, ACE_Condition< ACE_Recursive_Thread_Mutex >::wait, and ACE_Condition_Thread_Mutex::wait.

02207 {
02208   ACE_OS_TRACE ("ACE_OS::cond_wait");
02209 # if defined (ACE_HAS_THREADS)
02210 #   if defined (ACE_HAS_PTHREADS)
02211 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02212   ACE_OSCALL_RETURN (::pthread_cond_wait (cv, external_mutex), int, -1);
02213 #     else
02214   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cond_wait (cv, external_mutex), ace_result_),
02215                      int, -1);
02216 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02217 #   elif defined (ACE_HAS_STHREADS)
02218   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), ace_result_),
02219                      int, -1);
02220 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02221   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cv_wait (*cv, *external_mutex, 0),
02222                                        ace_result_),
02223                      int, -1);
02224 #   endif /* ACE_HAS_PTHREADS */
02225 # else
02226   ACE_UNUSED_ARG (cv);
02227   ACE_UNUSED_ARG (external_mutex);
02228   ACE_NOTSUP_RETURN (-1);
02229 # endif /* ACE_HAS_THREADS */
02230 }

ACE_INLINE int ACE_OS::condattr_destroy ACE_condattr_t &    attributes [static]
 

Definition at line 2047 of file OS.i.

Referenced by cond_init.

02048 {
02049 #if defined (ACE_HAS_THREADS)
02050 #   if defined (ACE_HAS_PTHREADS)
02051 
02052 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
02053   ::pthread_condattr_delete (&attributes);
02054 #     else
02055   ::pthread_condattr_destroy (&attributes);
02056 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
02057 
02058 #   elif defined (ACE_HAS_STHREADS)
02059   attributes.type = 0;
02060 
02061 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02062   attributes = 0;
02063 
02064 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. ACE_PSOS */
02065   return 0;
02066 # else
02067   ACE_UNUSED_ARG (attributes);
02068   return 0;
02069 # endif /* ACE_HAS_THREADS  */
02070 }

ACE_INLINE int ACE_OS::condattr_init ACE_condattr_t &    attributes,
int    type = ACE_DEFAULT_SYNCH_TYPE
[static]
 

Definition at line 1987 of file OS.i.

References ACE_ADAPT_RETVAL.

Referenced by cond_init.

01989 {
01990   ACE_UNUSED_ARG (type);
01991 # if defined (ACE_HAS_THREADS)
01992 #   if defined (ACE_HAS_PTHREADS)
01993   int result = -1;
01994 
01995   if (
01996 #     if defined  (ACE_HAS_PTHREADS_DRAFT4)
01997       ::pthread_condattr_create (&attributes) == 0
01998 #     elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7)
01999       ACE_ADAPT_RETVAL(::pthread_condattr_init (&attributes), result) == 0
02000 #       if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
02001       && ACE_ADAPT_RETVAL(::pthread_condattr_setpshared(&attributes, type),
02002                           result) == 0
02003 #       endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_MUTEXATTR_PSHARED */
02004 #     else  /* this is draft 6 */
02005       ::pthread_condattr_init (&attributes) == 0
02006 #       if !defined (ACE_LACKS_CONDATTR_PSHARED)
02007       && ::pthread_condattr_setpshared (&attributes, type) == 0
02008 #       endif /* ACE_LACKS_CONDATTR_PSHARED */
02009 #       if defined (ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP)
02010       && ::pthread_condattr_setkind_np (&attributes, type) == 0
02011 #       endif /* ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP */
02012 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
02013       )
02014      result = 0;
02015   else
02016      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
02017 
02018   return result;
02019 #   elif defined (ACE_HAS_STHREADS)
02020   attributes.type = type;
02021 
02022   return 0;
02023 
02024 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_COND_T)
02025 #     if defined (ACE_PSOS_HAS_PRIO_MUTEX)
02026   attributes = CV_LOCAL | CV_PRIOR;
02027 #     else /* ACE_PSOS_HAS_PRIO_MUTEX */
02028   attributes = CV_LOCAL | CV_FIFO;
02029 #     endif /* ACE_PSOS_HAS_PRIO_MUTEX */
02030   return 0;
02031 
02032 #   else
02033   ACE_UNUSED_ARG (attributes);
02034   ACE_UNUSED_ARG (type);
02035   ACE_NOTSUP_RETURN (-1);
02036 
02037 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS vs. pSOS */
02038 
02039 # else
02040   ACE_UNUSED_ARG (attributes);
02041   ACE_UNUSED_ARG (type);
02042   ACE_NOTSUP_RETURN (-1);
02043 # endif /* ACE_HAS_THREADS */
02044 }

int ACE_OS::connect ACE_HANDLE    handle,
const sockaddr *    addr,
int    addrlen,
const ACE_QoS_Params   qos_params
[static]
 

QoS-enabled <connect>, which passes <qos_params> to <connect>. If the OS platform doesn't support QoS-enabled <connect> then the <qos_params> are ignored and the BSD-style <connect> is called.

Definition at line 7651 of file OS.cpp.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, ACE_QoS_Params::callee_data, ACE_QoS_Params::caller_data, connect, ACE_QoS_Params::group_socket_qos, and ACE_QoS_Params::socket_qos.

07655 {
07656   ACE_OS_TRACE ("ACE_OS::connect");
07657 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
07658   ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle,
07659                                      (const sockaddr *) addr,
07660                                      (ACE_SOCKET_LEN) addrlen,
07661                                      (WSABUF *) qos_params.caller_data (),
07662                                      (WSABUF *) qos_params.callee_data (),
07663                                      (QOS *) qos_params.socket_qos (),
07664                                      (QOS *) qos_params.group_socket_qos ()),
07665                        int, -1);
07666 # else
07667   ACE_UNUSED_ARG (qos_params);
07668   return ACE_OS::connect (handle,
07669                           (sockaddr *) addr,
07670                           addrlen);
07671 # endif /* ACE_HAS_WINSOCK2 */
07672 }

ACE_INLINE int ACE_OS::connect ACE_HANDLE    handle,
struct sockaddr *    addr,
int    addrlen
[static]
 

BSD-style <connect> (no QoS).

Definition at line 4797 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and connect.

Referenced by ACE_SOCK_Connector::connect, connect, ACE_ATM_Connector::connect, ACE_WIN32_Asynch_Connect::connect_i, ACE_POSIX_Asynch_Connect::connect_i, and ACE_SOCK_CODgram::open.

04800 {
04801   ACE_OS_TRACE ("ACE_OS::connect");
04802 #if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC)
04803   ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle,
04804                                   (struct sockaddr_in *) addr,
04805                                   (ACE_SOCKET_LEN) addrlen),
04806                        int, -1);
04807 #else  /* !defined (ACE_PSOS) || defined (ACE_PSOS_DIAB_PPC) */
04808   ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle,
04809                                   addr,
04810                                   (ACE_SOCKET_LEN) addrlen), int, -1);
04811 #endif /* defined (ACE_PSOS)  && !defined (ACE_PSOS_DIAB_PPC) */
04812 }

ACE_INLINE ACE_HANDLE ACE_OS::creat const ACE_TCHAR   filename,
mode_t    mode
[static]
 

Definition at line 7717 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, creat, mode_t, and open.

Referenced by creat, and ACE_SPIPE_Acceptor::create_new_instance.

07718 {
07719   ACE_OS_TRACE ("ACE_OS::creat");
07720 #if defined (ACE_WIN32)
07721   return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode);
07722 #elif defined(ACE_PSOS)
07723    ACE_OSCALL_RETURN(::create_f((char *)filename, 1024,
07724                               S_IRUSR | S_IWUSR | S_IXUSR),
07725                      ACE_HANDLE, ACE_INVALID_HANDLE);
07726 #elif defined(ACE_PSOS_TM)
07727   ACE_UNUSED_ARG (filename);
07728   ACE_UNUSED_ARG (mode);
07729   ACE_NOTSUP_RETURN (-1);
07730 #elif defined(ACE_PSOS)
07731   ACE_UNUSED_ARG (filename);
07732   ACE_UNUSED_ARG (mode);
07733   ACE_NOTSUP_RETURN (-1);
07734 #else
07735   ACE_OSCALL_RETURN (::creat (filename, mode),
07736                      ACE_HANDLE, ACE_INVALID_HANDLE);
07737 #endif /* ACE_WIN32 */
07738 }

ACE_INLINE ACE_TCHAR * ACE_OS::ctime const time_t *    t [static]
 

Definition at line 8684 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, asctime, ctime, ctime_buf_size, ctime_r, and localtime.

Referenced by ctime, ctime_r, and ACE_Service_Config::reconfigure.

08685 {
08686   ACE_OS_TRACE ("ACE_OS::ctime");
08687 #if defined (ACE_HAS_BROKEN_CTIME)
08688   ACE_OSCALL_RETURN (::asctime (::localtime (t)), char *, 0);
08689 #elif defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
08690   return "ctime-return";
08691 #elif defined (ACE_HAS_WINCE)
08692   static ACE_TCHAR buf [ctime_buf_size];
08693   return ACE_OS::ctime_r (t,
08694                           buf,
08695                           ctime_buf_size);
08696 #elif defined (ACE_USES_WCHAR)
08697   ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0);
08698 #else
08699   ACE_OSCALL_RETURN (::ctime (t), char *, 0);
08700 # endif /* ACE_HAS_BROKEN_CTIME */
08701 }

ACE_INLINE ACE_TCHAR * ACE_OS::ctime_r const time_t *    clock,
ACE_TCHAR   buf,
int    buflen
[static]
 

Definition at line 8705 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, ctime, ctime_buf_size, ctime_r, and ACE_OS_String::strsncpy.

Referenced by ctime, ctime_r, ACE_Log_Record::format_msg, and ACE::timestamp.

08706 {
08707   ACE_OS_TRACE ("ACE_OS::ctime_r");
08708 
08709 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
08710 #   if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
08711   if (buflen < ctime_buf_size)
08712     {
08713       errno = ERANGE;
08714       return 0;
08715     }
08716 #      if defined (DIGITAL_UNIX)
08717   ACE_OSCALL_RETURN (::_Pctime_r (t, buf), ACE_TCHAR *, 0);
08718 #      else /* DIGITAL_UNIX */
08719   ACE_OSCALL_RETURN (::ctime_r (t, buf), ACE_TCHAR *, 0);
08720 #      endif /* DIGITAL_UNIX */
08721   return buf;
08722 #   else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
08723 
08724 #      if defined (ACE_CTIME_R_RETURNS_INT)
08725   return (::ctime_r (t, buf, buflen) == -1 ? 0 : buf);
08726 #      else /* ACE_CTIME_R_RETURNS_INT */
08727   ACE_OSCALL_RETURN (::ctime_r (t, buf, buflen), ACE_TCHAR *, 0);
08728 #      endif /* ACE_CTIME_R_RETURNS_INT */
08729 
08730 #   endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
08731 #else /* ACE_HAS_REENTRANT_FUNCTIONS */
08732 #   if defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
08733   ACE_OS::strsncpy (buf, "ctime-return", buflen);
08734   return buf;
08735 #   else /* ACE_PSOS && !ACE_PSOS_HAS_TIME */
08736   if (buflen < ctime_buf_size)
08737     {
08738       errno = ERANGE;
08739       return 0;
08740     }
08741 
08742   ACE_TCHAR *result;
08743 #     if defined (ACE_USES_WCHAR)
08744   ACE_OSCALL (::_wctime (t), wchar_t *, 0, result);
08745 #     else /* ACE_USES_WCHAR */
08746   ACE_OSCALL (::ctime (t), char *, 0, result);
08747 #     endif /* ACE_USES_WCHAR */
08748   if (result != 0)
08749     ACE_OS::strsncpy (buf, result, buflen);
08750   return buf;
08751 #   endif /* ACE_PSOS && !ACE_PSOS_HAS_TIME */
08752 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
08753 }

wchar_t* ACE_OS::cuserid wchar_t *    user,
size_t    maxlen = ACE_MAX_USERID
[static]
 

ACE_INLINE char * ACE_OS::cuserid char *    user,
size_t    maxlen = ACE_MAX_USERID
[static]
 

Definition at line 883 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, ACE_OS_String::strcpy, and ACE_OS_String::strlen.

00884 {
00885   ACE_OS_TRACE ("ACE_OS::cuserid");
00886 #if defined (VXWORKS)
00887   ACE_UNUSED_ARG (maxlen);
00888   if (user == 0)
00889     {
00890       // Require that the user field be non-null, i.e., don't
00891       // allocate or use static storage.
00892       ACE_NOTSUP_RETURN (0);
00893     }
00894   else
00895     {
00896       ::remCurIdGet (user, 0);
00897       return user;
00898     }
00899 #elif defined (CHORUS) || defined (ACE_PSOS) || defined (__QNXNTO__)
00900   ACE_UNUSED_ARG (user);
00901   ACE_UNUSED_ARG (maxlen);
00902   ACE_NOTSUP_RETURN (0);
00903 #elif defined (ACE_WIN32)
00904   BOOL result = GetUserNameA (user, (u_long *) &maxlen);
00905   if (result == FALSE)
00906     ACE_FAIL_RETURN (0);
00907   else
00908     return user;
00909 #elif defined (ACE_HAS_ALT_CUSERID)
00910 #  if defined (ACE_LACKS_PWD_FUNCTIONS)
00911 #    error Cannot use alternate cuserid() without POSIX password functions!
00912 #  endif  /* ACE_LACKS_PWD_FUNCTIONS */
00913 
00914   // POSIX.1 dropped the cuserid() function.
00915   // GNU GLIBC and other platforms correctly deprecate the cuserid()
00916   // function.
00917 
00918   if (maxlen == 0)
00919     {
00920       // It doesn't make sense to have a zero length user ID.
00921       errno = EINVAL;
00922       return 0;
00923     }
00924 
00925   struct passwd *pw = 0;
00926 
00927   // Make sure the file pointer is at the beginning of the password file
00928   ::setpwent ();
00929   // Should use ACE_OS::setpwent() but I didn't want to move this
00930   // method after it.
00931 
00932   // Use the effective user ID to determine the user name.
00933   pw = ::getpwuid (::geteuid ());
00934 
00935   // Make sure the password file is closed.
00936   ::endpwent ();
00937 
00938   size_t max_length = 0;
00939   char *userid = 0;
00940 
00941   if (user == 0)
00942     {
00943       // Not reentrant/thread-safe, but nothing else can be done if a
00944       // zero pointer was passed in as the destination.
00945 
00946 #if defined (_POSIX_SOURCE)
00947       const size_t ACE_L_cuserid = L_cuserid;
00948 #else
00949       const size_t ACE_L_cuserid = 9;  // 8 character user ID + NULL
00950 #endif  /* _POSIX_SOURCE */
00951 
00952       static ACE_TCHAR tmp[ACE_L_cuserid] = { '\0' };
00953       max_length = ACE_L_cuserid - 1; // Do not include NULL in length
00954 
00955       userid = tmp;
00956     }
00957   else
00958     {
00959       max_length = maxlen;
00960       userid = user;
00961     }
00962 
00963   // Extract the user name from the passwd structure.
00964   if (ACE_OS_String::strlen (pw->pw_name) <= max_length)
00965     {
00966       return ACE_OS_String::strcpy (userid, pw->pw_name);
00967     }
00968   else
00969     {
00970       errno = ENOSPC;  // Buffer is not large enough.
00971       return 0;
00972     }
00973 #else
00974   // Hackish because of missing buffer size!
00975   ACE_UNUSED_ARG (maxlen);
00976   ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0);
00977 #endif /* VXWORKS */
00978 }

LPSECURITY_ATTRIBUTES ACE_OS::default_win32_security_attributes LPSECURITY_ATTRIBUTES    [static]
 

Referenced by event_init, mmap, mutex_init, open, and sema_init.

ACE_INLINE double ACE_OS::difftime time_t    t1,
time_t    t0
[static]
 

Definition at line 8674 of file OS.i.

References ace_difftime.

Referenced by ACE_Filecache_Object::update.

08675 {
08676   return ::ace_difftime (t1, t0);
08677 }

ACE_INLINE int ACE_OS::dlclose ACE_SHLIB_HANDLE    handle [static]
 

Definition at line 7951 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_LIB_TEXT, ACE_OS_TRACE, ACE_SHLIB_HANDLE, dlclose, and dlsym.

Referenced by ACE_DLL_Handle::close, and dlclose.

07952 {
07953   ACE_OS_TRACE ("ACE_OS::dlclose");
07954 #if defined (ACE_LACKS_DLCLOSE)
07955   ACE_UNUSED_ARG (handle);
07956   return 0;
07957 #elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
07958 
07959 # if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
07960   // SunOS4 does not automatically call _fini()!
07961   void *ptr;
07962 
07963   ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_fini")), void *, 0, ptr);
07964 
07965   if (ptr != 0)
07966     (*((int (*)(void)) ptr)) (); // Call _fini hook explicitly.
07967 # endif /* ACE_HAS_AUTOMATIC_INIT_FINI */
07968 #if defined (_M_UNIX)
07969   ACE_OSCALL_RETURN (::_dlclose (handle), int, -1);
07970 #else /* _MUNIX */
07971     ACE_OSCALL_RETURN (::dlclose (handle), int, -1);
07972 #endif /* _M_UNIX */
07973 #elif defined (ACE_WIN32)
07974   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FreeLibrary (handle), ace_result_), int, -1);
07975 #elif defined (__hpux)
07976   // HP-UX 10.x and 32-bit 11.00 do not pay attention to the ref count
07977   // when unloading a dynamic lib.  So, if the ref count is more than
07978   // 1, do not unload the lib.  This will cause a library loaded more
07979   // than once to not be unloaded until the process runs down, but
07980   // that's life.  It's better than unloading a library that's in use.
07981   // So far as I know, there's no way to decrement the refcnt that the
07982   // kernel is looking at - the shl_descriptor is a copy of what the
07983   // kernel has, not the actual struct.  On 64-bit HP-UX using dlopen,
07984   // this problem has been fixed.
07985   struct shl_descriptor  desc;
07986   if (shl_gethandle_r (handle, &desc) == -1)
07987     return -1;
07988   if (desc.ref_count > 1)
07989     return 0;
07990 # if defined(__GNUC__) || __cplusplus >= 199707L
07991   ACE_OSCALL_RETURN (::shl_unload (handle), int, -1);
07992 # else
07993   ACE_OSCALL_RETURN (::cxxshl_unload (handle), int, -1);
07994 # endif  /* aC++ vs. Hp C++ */
07995 #else
07996   ACE_UNUSED_ARG (handle);
07997   ACE_NOTSUP_RETURN (-1);
07998 #endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
07999 }

ACE_INLINE ACE_TCHAR * ACE_OS::dlerror void    [static]
 

Definition at line 8002 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, sprintf, and ACE_OS_String::strerror.

Referenced by ACE_DLL_Handle::error.

08003 {
08004   ACE_OS_TRACE ("ACE_OS::dlerror");
08005 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
08006 #if defined(_M_UNIX)
08007   ACE_OSCALL_RETURN ((char *)::_dlerror (), char *, 0);
08008 #else /* _M_UNIX */
08009   ACE_OSCALL_RETURN ((char *)::dlerror (), char *, 0);
08010 #endif /* _M_UNIX */
08011 # elif defined (__hpux)
08012   ACE_OSCALL_RETURN (::strerror(errno), char *, 0);
08013 # elif defined (ACE_WIN32)
08014   static ACE_TCHAR buf[128];
08015 #   if defined (ACE_HAS_PHARLAP)
08016   ACE_OS::sprintf (buf, "error code %d", GetLastError());
08017 #   else
08018   ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
08019                           0,
08020                           ::GetLastError (),
08021                           0,
08022                           buf,
08023                           sizeof buf / sizeof buf[0],
08024                           0);
08025 #   endif /* ACE_HAS_PHARLAP */
08026   return buf;
08027 # else
08028   ACE_NOTSUP_RETURN (0);
08029 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
08030 }

ACE_INLINE ACE_SHLIB_HANDLE ACE_OS::dlopen const ACE_TCHAR   filename,
int    mode = ACE_DEFAULT_SHLIB_MODE
[static]
 

Definition at line 8033 of file OS.i.

References ACE_DL_TYPE, ACE_LIB_TEXT, ACE_OS_TRACE, ACE_SHLIB_HANDLE, ACE_TCHAR, dlopen, and dlsym.

Referenced by dlopen, ACE_DLL_Strategy::make_svc_handler, and ACE_DLL_Handle::open.

08035 {
08036   ACE_OS_TRACE ("ACE_OS::dlopen");
08037 
08038   // Get the correct OS type.
08039   ACE_DL_TYPE filename = ACE_const_cast (ACE_DL_TYPE, fname);
08040 
08041 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
08042   void *handle;
08043 #   if defined (ACE_HAS_SGIDLADD)
08044   ACE_OSCALL (::sgidladd (filename, mode), void *, 0, handle);
08045 #   elif defined (_M_UNIX)
08046   ACE_OSCALL (::_dlopen (filename, mode), void *, 0, handle);
08047 #   else
08048   ACE_OSCALL (::dlopen (filename, mode), void *, 0, handle);
08049 #   endif /* ACE_HAS_SGIDLADD */
08050 #   if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
08051   if (handle != 0)
08052     {
08053       void *ptr;
08054       // Some systems (e.g., SunOS4) do not automatically call _init(), so
08055       // we'll have to call it manually.
08056 
08057       ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_init")), void *, 0, ptr);
08058 
08059       if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly.
08060         {
08061           // Close down the handle to prevent leaks.
08062           ::dlclose (handle);
08063           return 0;
08064         }
08065     }
08066 #   endif /* ACE_HAS_AUTOMATIC_INIT_FINI */
08067   return handle;
08068 # elif defined (ACE_WIN32)
08069   ACE_UNUSED_ARG (mode);
08070 
08071   ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (filename), ACE_SHLIB_HANDLE, 0);
08072 # elif defined (__hpux)
08073 
08074 #   if defined(__GNUC__) || __cplusplus >= 199707L
08075   ACE_OSCALL_RETURN (::shl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0);
08076 #   else
08077   ACE_OSCALL_RETURN (::cxxshl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0);
08078 #   endif  /* aC++ vs. Hp C++ */
08079 
08080 # else
08081   ACE_UNUSED_ARG (filename);
08082   ACE_UNUSED_ARG (mode);
08083   ACE_NOTSUP_RETURN (0);
08084 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
08085 }

ACE_INLINE void * ACE_OS::dlsym ACE_SHLIB_HANDLE    handle,
const ACE_TCHAR   symbol
[static]
 

Definition at line 8088 of file OS.i.

References ACE_NEW_RETURN, ACE_OS_TRACE, ACE_SHLIB_HANDLE, ACE_SHLIB_INVALID_HANDLE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, dlsym, ACE_OS_String::strcpy, and ACE_OS_String::strlen.

Referenced by dlclose, dlopen, dlsym, ACE_DLL_Strategy::make_svc_handler, and ACE_DLL_Handle::symbol.

08090 {
08091   ACE_OS_TRACE ("ACE_OS::dlsym");
08092 
08093 #if defined (ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE)
08094   // Check if the handle is valid before making any calls using it.
08095   if (handle == ACE_SHLIB_INVALID_HANDLE)
08096     return 0;
08097 #endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */
08098 
08099   // Get the correct OS type.
08100 #if defined (ACE_HAS_WINCE)
08101   const wchar_t *symbolname = sname;
08102 #elif defined (ACE_HAS_CHARPTR_DL)
08103   char *symbolname = ACE_const_cast (char *, sname);
08104 #elif !defined (ACE_WIN32) || !defined (ACE_USES_WCHAR)
08105   const char *symbolname = sname;
08106 #endif /* ACE_HAS_CHARPTR_DL */
08107 
08108 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
08109 
08110 #   if defined (ACE_LACKS_POSIX_PROTOTYPES)
08111   ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0);
08112 #   elif defined (ACE_USES_ASM_SYMBOL_IN_DLSYM)
08113   int l = ACE_OS::strlen (symbolname) + 2;
08114   char *asm_symbolname = 0;
08115   ACE_NEW_RETURN (asm_symbolname, char[l], 0);
08116   ACE_OS::strcpy (asm_symbolname, "_") ;
08117   ACE_OS::strcpy (asm_symbolname + 1, symbolname) ;
08118   void *ace_result;
08119   ACE_OSCALL (::dlsym (handle, asm_symbolname), void *, 0, ace_result);
08120   delete [] asm_symbolname;
08121   return ace_result;
08122 #   elif defined (_M_UNIX)
08123   ACE_OSCALL_RETURN (::_dlsym (handle, symbolname), void *, 0);
08124 #   else
08125   ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0);
08126 #   endif /* ACE_LACKS_POSIX_PROTOTYPES */
08127 
08128 # elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) && !defined (ACE_HAS_WINCE)
08129 
08130   ACE_WIN32CALL_RETURN (::GetProcAddress (handle, ACE_TEXT_ALWAYS_CHAR (sname)), void *, 0);
08131 
08132 # elif defined (ACE_WIN32)
08133 
08134   ACE_WIN32CALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0);
08135 
08136 # elif defined (__hpux)
08137 
08138   void *value;
08139   int status;
08140   shl_t _handle = handle;
08141   ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status);
08142   return status == 0 ? value : 0;
08143 
08144 # else
08145 
08146   ACE_UNUSED_ARG (handle);
08147   ACE_UNUSED_ARG (symbolname);
08148   ACE_NOTSUP_RETURN (0);
08149 
08150 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
08151 }

ACE_INLINE ACE_HANDLE ACE_OS::dup ACE_HANDLE    handle [static]
 

Definition at line 9474 of file OS.i.

References ACE_OS_TRACE, and dup.

Referenced by dup, ACE_Filecache_Handle::handle, and ACE_Process_Options::set_handles.

09475 {
09476   ACE_OS_TRACE ("ACE_OS::dup");
09477 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
09478   ACE_HANDLE new_fd;
09479   if (::DuplicateHandle(::GetCurrentProcess (),
09480                         handle,
09481                         ::GetCurrentProcess(),
09482                         &new_fd,
09483                         0,
09484                         TRUE,
09485                         DUPLICATE_SAME_ACCESS))
09486     return new_fd;
09487   else
09488     ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
09489   /* NOTREACHED */
09490 #elif defined (VXWORKS) || defined (ACE_PSOS)
09491   ACE_UNUSED_ARG (handle);
09492   ACE_NOTSUP_RETURN (-1);
09493 #elif defined (ACE_HAS_WINCE)
09494   ACE_UNUSED_ARG (handle);
09495   ACE_NOTSUP_RETURN (0);
09496 #else
09497   ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE);
09498 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */
09499 }

ACE_INLINE int ACE_OS::dup2 ACE_HANDLE    oldfd,
ACE_HANDLE    newfd
[static]
 

Definition at line 9502 of file OS.i.

References ACE_OS_TRACE, and dup2.

Referenced by dup2, and ACE_Process::spawn.

09503 {
09504   ACE_OS_TRACE ("ACE_OS::dup2");
09505 #if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS)
09506   // msvcrt has _dup2 ?!
09507   ACE_UNUSED_ARG (oldhandle);
09508   ACE_UNUSED_ARG (newhandle);
09509 
09510   ACE_NOTSUP_RETURN (-1);
09511 #else
09512   ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1);
09513 #endif /* ACE_WIN32 || VXWORKS || ACE_PSOS */
09514 }

ACE_INLINE void ACE_OS::endpwent void    [static]
 

Definition at line 5819 of file OS.i.

05820 {
05821 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
05822 # if !defined (ACE_WIN32)
05823   ::endpwent ();
05824 # else
05825 # endif /* ACE_WIN32 */
05826 #else
05827 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
05828 }

ACE_INLINE int ACE_OS::enum_protocols int *    protocols,
ACE_Protocol_Info   protocol_buffer,
u_long *    buffer_length
[static]
 

Retrieve information about available transport protocols installed on the local machine.

Definition at line 4759 of file OS.i.

References ACE_SOCKCALL_RETURN.

04762 {
04763 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
04764 
04765   ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols,
04766                                            protocol_buffer,
04767                                            buffer_length),
04768                        int,
04769                        SOCKET_ERROR);
04770 
04771 #else
04772   ACE_UNUSED_ARG (protocols);
04773   ACE_UNUSED_ARG (protocol_buffer);
04774   ACE_UNUSED_ARG (buffer_length);
04775   ACE_NOTSUP_RETURN (-1);
04776 #endif /* ACE_HAS_WINSOCK2 */
04777 }

ACE_INLINE int ACE_OS::event_destroy ACE_event_t *    event [static]
 

Definition at line 4340 of file OS.i.

References ACE_ADAPT_RETVAL, cond_destroy, and mutex_destroy.

Referenced by ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos, ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos, ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos, ACE_Event::remove, sema_destroy, and sema_init.

04341 {
04342 #if defined (ACE_WIN32)
04343   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
04344 #elif defined (ACE_HAS_THREADS)
04345   int r1 = ACE_OS::mutex_destroy (&event->lock_);
04346   int r2 = ACE_OS::cond_destroy (&event->condition_);
04347   return r1 != 0 || r2 != 0 ? -1 : 0;
04348 #else
04349   ACE_UNUSED_ARG (event);
04350   ACE_NOTSUP_RETURN (-1);
04351 #endif /* ACE_WIN32 */
04352 }

int ACE_OS::event_init ACE_event_t *    event,
int    manual_reset,
int    initial_state,
int    type,
const wchar_t *    name,
void *    arg = 0,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

ACE_INLINE int ACE_OS::event_init ACE_event_t *    event,
int    manual_reset = 0,
int    initial_state = 0,
int    type = ACE_DEFAULT_SYNCH_TYPE,
const char *    name = 0,
void *    arg = 0,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

Definition at line 4251 of file OS.i.

References cond_init, default_win32_security_attributes, and mutex_init.

Referenced by ACE_Event::ACE_Event, and sema_init.

04258 {
04259 #if defined (ACE_WIN32)
04260   ACE_UNUSED_ARG (type);
04261   ACE_UNUSED_ARG (arg);
04262 # if defined (ACE_HAS_WINCE)
04263   // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
04264   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes(sa),
04265                            manual_reset,
04266                            initial_state,
04267                            ACE_Ascii_To_Wide (name).wchar_rep ());
04268 # else /* ACE_HAS_WINCE */
04269   *event = ::CreateEventA (ACE_OS::default_win32_security_attributes(sa),
04270                            manual_reset,
04271                            initial_state,
04272                            name);
04273 # endif /* ACE_HAS_WINCE */
04274   if (*event == 0)
04275     ACE_FAIL_RETURN (-1);
04276   else
04277     return 0;
04278 #elif defined (ACE_HAS_THREADS)
04279   ACE_UNUSED_ARG (sa);
04280   event->manual_reset_ = manual_reset;
04281   event->is_signaled_ = initial_state;
04282   event->waiting_threads_ = 0;
04283 
04284   int result = ACE_OS::cond_init (&event->condition_,
04285                                   ACE_static_cast (short, type),
04286                                   name,
04287                                   arg);
04288   if (result == 0)
04289     result = ACE_OS::mutex_init (&event->lock_,
04290                                  type,
04291                                  name,
04292                                  (ACE_mutexattr_t *) arg);
04293   return result;
04294 #else
04295   ACE_UNUSED_ARG (event);
04296   ACE_UNUSED_ARG (manual_reset);
04297   ACE_UNUSED_ARG (initial_state);
04298   ACE_UNUSED_ARG (type);
04299   ACE_UNUSED_ARG (name);
04300   ACE_UNUSED_ARG (arg);
04301   ACE_UNUSED_ARG (sa);
04302   ACE_NOTSUP_RETURN (-1);
04303 #endif /* ACE_WIN32 */
04304 }

ACE_INLINE int ACE_OS::event_pulse ACE_event_t *    event [static]
 

Definition at line 4577 of file OS.i.

References ACE_ADAPT_RETVAL, cond_broadcast, cond_signal, mutex_lock, and mutex_unlock.

Referenced by ACE_Event::pulse.

04578 {
04579 #if defined (ACE_WIN32)
04580   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
04581 #elif defined (ACE_HAS_THREADS)
04582   int result = 0;
04583   int error = 0;
04584 
04585   // grab the lock first
04586   if (ACE_OS::mutex_lock (&event->lock_) == 0)
04587     {
04588       // Manual-reset event.
04589       if (event->manual_reset_ == 1)
04590         {
04591           // Wakeup all waiters.
04592           if (ACE_OS::cond_broadcast (&event->condition_) != 0)
04593             {
04594               result = -1;
04595               error = errno;
04596             }
04597         }
04598       // Auto-reset event: wakeup one waiter.
04599       else if (ACE_OS::cond_signal (&event->condition_) != 0)
04600         {
04601           result = -1;
04602           error = errno;
04603         }
04604 
04605       // Reset event.
04606       event->is_signaled_ = 0;
04607 
04608       // Now we can let go of the lock.
04609       ACE_OS::mutex_unlock (&event->lock_);
04610 
04611       if (result == -1)
04612         // Reset errno in case mutex_unlock() also fails...
04613         errno = error;
04614     }
04615   else
04616     result = -1;
04617   return result;
04618 #else
04619   ACE_UNUSED_ARG (event);
04620   ACE_NOTSUP_RETURN (-1);
04621 #endif /* ACE_WIN32 */
04622 }

ACE_INLINE int ACE_OS::event_reset ACE_event_t *    event [static]
 

Definition at line 4625 of file OS.i.

References ACE_ADAPT_RETVAL, mutex_lock, and mutex_unlock.

Referenced by ACE_Event::reset, sema_trywait, and sema_wait.

04626 {
04627 #if defined (ACE_WIN32)
04628   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
04629 #elif defined (ACE_HAS_THREADS)
04630   int result = 0;
04631 
04632   // Grab the lock first.
04633   if (ACE_OS::mutex_lock (&event->lock_) == 0)
04634     {
04635       // Reset event.
04636       event->is_signaled_ = 0;
04637 
04638       // Now we can let go of the lock.
04639       ACE_OS::mutex_unlock (&event->lock_);
04640     }
04641   else
04642     result = -1;
04643   return result;
04644 #else
04645   ACE_UNUSED_ARG (event);
04646   ACE_NOTSUP_RETURN (-1);
04647 #endif /* ACE_WIN32 */
04648 }

ACE_INLINE int ACE_OS::event_signal ACE_event_t *    event [static]
 

Definition at line 4522 of file OS.i.

References ACE_ADAPT_RETVAL, cond_broadcast, cond_signal, mutex_lock, and mutex_unlock.

Referenced by ACE_WIN32_Proactor::post_completion, sema_post, and ACE_Event::signal.

04523 {
04524 #if defined (ACE_WIN32)
04525   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
04526 #elif defined (ACE_HAS_THREADS)
04527   int result = 0;
04528   int error = 0;
04529 
04530   // grab the lock first
04531   if (ACE_OS::mutex_lock (&event->lock_) == 0)
04532     {
04533       // Manual-reset event.
04534       if (event->manual_reset_ == 1)
04535         {
04536           // signal event
04537           event->is_signaled_ = 1;
04538           // wakeup all
04539           if (ACE_OS::cond_broadcast (&event->condition_) != 0)
04540             {
04541               result = -1;
04542               error = errno;
04543             }
04544         }
04545       // Auto-reset event
04546       else
04547         {
04548           if (event->waiting_threads_ == 0)
04549             // No waiters: signal event.
04550             event->is_signaled_ = 1;
04551 
04552           // Waiters: wakeup one waiter.
04553           else if (ACE_OS::cond_signal (&event->condition_) != 0)
04554             {
04555               result = -1;
04556               error = errno;
04557             }
04558         }
04559 
04560       // Now we can let go of the lock.
04561       ACE_OS::mutex_unlock (&event->lock_);
04562 
04563       if (result == -1)
04564         // Reset errno in case mutex_unlock() also fails...
04565         errno = error;
04566     }
04567   else
04568     result = -1;
04569   return result;
04570 #else
04571   ACE_UNUSED_ARG (event);
04572   ACE_NOTSUP_RETURN (-1);
04573 #endif /* ACE_WIN32 */
04574 }

ACE_INLINE int ACE_OS::event_timedwait ACE_event_t *    event,
ACE_Time_Value   timeout,
int    use_absolute_time = 1
[static]
 

Definition at line 4413 of file OS.i.

References cond_timedwait, ETIME, gettimeofday, ACE_Time_Value::msec, mutex_lock, mutex_unlock, ACE_Time_Value::sec, set_errno_to_last_error, ACE_Time_Value::usec, and ACE_Time_Value::zero.

Referenced by ACE_Event::wait.

04416 {
04417 #if defined (ACE_WIN32)
04418   DWORD result;
04419 
04420   if (timeout == 0)
04421     // Wait forever
04422     result = ::WaitForSingleObject (*event, INFINITE);
04423   else if (timeout->sec () == 0 && timeout->usec () == 0)
04424     // Do a "poll".
04425     result = ::WaitForSingleObject (*event, 0);
04426   else
04427     {
04428       // Wait for upto <relative_time> number of milliseconds.  Note
04429       // that we must convert between absolute time (which is passed
04430       // as a parameter) and relative time (which is what
04431       // WaitForSingleObjects() expects).
04432       // <timeout> parameter is given in absolute or relative value
04433       // depending on parameter <use_absolute_time>.
04434       int msec_timeout;
04435       if (use_absolute_time)
04436         {
04437           // Time is given in absolute time, we should use
04438           // gettimeofday() to calculate relative time
04439           ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
04440 
04441           // Watchout for situations where a context switch has caused
04442           // the current time to be > the timeout.  Thanks to Norbert
04443           // Rapp <NRapp@nexus-informatics.de> for pointing this.
04444           if (relative_time < ACE_Time_Value::zero)
04445             msec_timeout = 0;
04446           else
04447             msec_timeout = relative_time.msec ();
04448         }
04449        else
04450          // time is given in relative time, just convert it into
04451          // milliseconds and use it
04452          msec_timeout = timeout->msec ();
04453       result = ::WaitForSingleObject (*event, msec_timeout);
04454     }
04455 
04456   switch (result)
04457     {
04458     case WAIT_OBJECT_0:
04459       return 0;
04460     case WAIT_TIMEOUT:
04461       errno = ETIME;
04462       return -1;
04463     default:
04464       // This is a hack, we need to find an appropriate mapping...
04465       ACE_OS::set_errno_to_last_error ();
04466       return -1;
04467     }
04468 #elif defined (ACE_HAS_THREADS)
04469   int result = 0;
04470   int error = 0;
04471 
04472   // grab the lock first
04473   if (ACE_OS::mutex_lock (&event->lock_) == 0)
04474     {
04475       if (event->is_signaled_ == 1)
04476         // event is currently signaled
04477         {
04478           if (event->manual_reset_ == 0)
04479             // AUTO: reset state
04480             event->is_signaled_ = 0;
04481         }
04482       else
04483         // event is currently not signaled
04484         {
04485           event->waiting_threads_++;
04486 
04487           // cond_timewait() expects absolute time, check
04488           // <use_absolute_time> flag.
04489           if (use_absolute_time == 0 && timeout != 0)
04490             *timeout += ACE_OS::gettimeofday ();
04491 
04492           if (ACE_OS::cond_timedwait (&event->condition_,
04493                                       &event->lock_,
04494                                       timeout) != 0)
04495             {
04496               result = -1;
04497               error = errno;
04498             }
04499 
04500           event->waiting_threads_--;
04501         }
04502 
04503       // Now we can let go of the lock.
04504       ACE_OS::mutex_unlock (&event->lock_);
04505 
04506       if (result == -1)
04507         // Reset errno in case mutex_unlock() also fails...
04508         errno = error;
04509     }
04510   else
04511     result = -1;
04512   return result;
04513 #else
04514   ACE_UNUSED_ARG (event);
04515   ACE_UNUSED_ARG (timeout);
04516   ACE_UNUSED_ARG (use_absolute_time);
04517   ACE_NOTSUP_RETURN (-1);
04518 #endif /* ACE_WIN32 */
04519 }

ACE_INLINE int ACE_OS::event_wait ACE_event_t *    event [static]
 

Definition at line 4355 of file OS.i.

References cond_wait, mutex_lock, mutex_unlock, and set_errno_to_last_error.

Referenced by ACE_Event::wait.

04356 {
04357 #if defined (ACE_WIN32)
04358   switch (::WaitForSingleObject (*event, INFINITE))
04359     {
04360     case WAIT_OBJECT_0:
04361       return 0;
04362     default:
04363       ACE_OS::set_errno_to_last_error ();
04364       return -1;
04365     }
04366 #elif defined (ACE_HAS_THREADS)
04367   int result = 0;
04368   int error = 0;
04369 
04370   // grab the lock first
04371   if (ACE_OS::mutex_lock (&event->lock_) == 0)
04372     {
04373       if (event->is_signaled_ == 1)
04374         // Event is currently signaled.
04375         {
04376           if (event->manual_reset_ == 0)
04377             // AUTO: reset state
04378             event->is_signaled_ = 0;
04379         }
04380       else
04381         // event is currently not signaled
04382         {
04383           event->waiting_threads_++;
04384 
04385           if (ACE_OS::cond_wait (&event->condition_,
04386                                  &event->lock_) != 0)
04387             {
04388               result = -1;
04389               error = errno;
04390               // Something went wrong...
04391             }
04392 
04393           event->waiting_threads_--;
04394         }
04395 
04396       // Now we can let go of the lock.
04397       ACE_OS::mutex_unlock (&event->lock_);
04398 
04399       if (result == -1)
04400         // Reset errno in case mutex_unlock() also fails...
04401         errno = error;
04402     }
04403   else
04404     result = -1;
04405   return result;
04406 #else
04407   ACE_UNUSED_ARG (event);
04408   ACE_NOTSUP_RETURN (-1);
04409 #endif /* ACE_WIN32 */
04410 }

int ACE_OS::execl const char *    path,
const char *    arg0,
...   
[static]
 

Definition at line 1230 of file OS.cpp.

References ACE_OS_TRACE.

01231 {
01232   ACE_OS_TRACE ("ACE_OS::execl");
01233 #if defined (ACE_WIN32) || defined (VXWORKS)
01234   ACE_NOTSUP_RETURN (-1);
01235 #else
01236   ACE_NOTSUP_RETURN (-1);
01237   // Need to write this code.
01238   // ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
01239 #endif /* ACE_WIN32 */
01240 }

int ACE_OS::execle const char *    path,
const char *    arg0,
...   
[static]
 

Definition at line 1243 of file OS.cpp.

References ACE_OS_TRACE.

01244 {
01245   ACE_OS_TRACE ("ACE_OS::execle");
01246 #if defined (ACE_WIN32) || defined (VXWORKS)
01247   ACE_NOTSUP_RETURN (-1);
01248 #else
01249   ACE_NOTSUP_RETURN (-1);
01250   // Need to write this code.
01251   //  ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
01252 #endif /* ACE_WIN32 */
01253 }

int ACE_OS::execlp const char *    file,
const char *    arg0,
...   
[static]
 

Definition at line 1256 of file OS.cpp.

References ACE_OS_TRACE.

01257 {
01258   ACE_OS_TRACE ("ACE_OS::execlp");
01259 #if defined (ACE_WIN32) || defined (VXWORKS)
01260   ACE_NOTSUP_RETURN (-1);
01261 #else
01262   ACE_NOTSUP_RETURN (-1);
01263   // Need to write this code.
01264   //  ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
01265 #endif /* ACE_WIN32 */
01266 }

ACE_INLINE int ACE_OS::execv const char *    path,
char *const    argv[]
[static]
 

Definition at line 9272 of file OS.i.

References ACE_OS_TRACE, and execv.

Referenced by execv, and fork_exec.

09274 {
09275   ACE_OS_TRACE ("ACE_OS::execv");
09276 #if defined (ACE_LACKS_EXEC)
09277   ACE_UNUSED_ARG (path);
09278   ACE_UNUSED_ARG (argv);
09279 
09280   ACE_NOTSUP_RETURN (-1);
09281 #elif defined (CHORUS)
09282   KnCap cactorcap;
09283   int result = ::afexecv (path, &cactorcap, 0, argv);
09284   if (result != -1)
09285     ACE_OS::actorcaps_[result] = cactorcap;
09286   return result;
09287 #elif defined (ACE_WIN32)
09288 # if defined (__BORLANDC__) /* VSB */
09289   return ::execv (path, argv);
09290 # elif defined (__MINGW32__)
09291   return ::_execv (path, (char *const *) argv);
09292 # else
09293   return ::_execv (path, (const char *const *) argv);
09294 # endif /* __BORLANDC__ */
09295 #elif defined (ACE_LACKS_POSIX_PROTOTYPES)
09296   ACE_OSCALL_RETURN (::execv (path, (const char **) argv), int, -1);
09297 #else
09298   ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
09299 #endif /* ACE_LACKS_EXEC */
09300 }

ACE_INLINE int ACE_OS::execve const char *    path,
char *const    argv[],
char *const    envp[]
[static]
 

Definition at line 9303 of file OS.i.

References ACE_OS_TRACE, and execve.

Referenced by execve, and ACE_Process::spawn.

09306 {
09307   ACE_OS_TRACE ("ACE_OS::execve");
09308 #if defined (ACE_LACKS_EXEC)
09309   ACE_UNUSED_ARG (path);
09310   ACE_UNUSED_ARG (argv);
09311   ACE_UNUSED_ARG (envp);
09312 
09313   ACE_NOTSUP_RETURN (-1);
09314 #elif defined(CHORUS)
09315   KnCap cactorcap;
09316   int result = ::afexecve (path, &cactorcap, 0, argv, envp);
09317   if (result != -1)
09318     ACE_OS::actorcaps_[result] = cactorcap;
09319   return result;
09320 #elif defined (ACE_WIN32)
09321 # if defined (__BORLANDC__) /* VSB */
09322   return ::execve (path, argv, envp);
09323 # elif defined (__MINGW32__)
09324   return ::_execve (path, (char *const *) argv, (char *const *) envp);
09325 # else
09326   return ::_execve (path, (const char *const *) argv, (const char *const *) envp);
09327 # endif /* __BORLANDC__ */
09328 #elif defined (ACE_LACKS_POSIX_PROTOTYPES)
09329   ACE_OSCALL_RETURN (::execve (path, (const char **) argv, (char **) envp), int, -1);
09330 #else
09331   ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
09332 #endif /* ACE_LACKS_EXEC */
09333 }

ACE_INLINE int ACE_OS::execvp const char *    file,
char *const    argv[]
[static]
 

Definition at line 9336 of file OS.i.

References ACE_OS_TRACE, and execvp.

Referenced by execvp, and ACE_Process::spawn.

09338 {
09339   ACE_OS_TRACE ("ACE_OS::execvp");
09340 #if defined (ACE_LACKS_EXEC)
09341   ACE_UNUSED_ARG (file);
09342   ACE_UNUSED_ARG (argv);
09343 
09344   ACE_NOTSUP_RETURN (-1);
09345 #elif defined(CHORUS)
09346   KnCap cactorcap;
09347   int result = ::afexecvp (file, &cactorcap, 0, argv);
09348   if (result != -1)
09349     ACE_OS::actorcaps_[result] = cactorcap;
09350   return result;
09351 #elif defined (ACE_WIN32)
09352 # if defined (__BORLANDC__) /* VSB */
09353   return ::execvp (file, argv);
09354 # elif defined (__MINGW32__)
09355   return ::_execvp (file, (char *const *) argv);
09356 # else
09357   return ::_execvp (file, (const char *const *) argv);
09358 # endif /* __BORLANDC__ */
09359 #elif defined (ACE_LACKS_POSIX_PROTOTYPES)
09360   ACE_OSCALL_RETURN (::execvp (file, (const char **) argv), int, -1);
09361 #else
09362   ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
09363 #endif /* ACE_LACKS_EXEC */
09364 }

void ACE_OS::exit int    status = 0 [static]
 

Definition at line 6286 of file OS.cpp.

References ACE_OS_TRACE.

Referenced by abort, ACE::daemonize, fork_exec, and ACE_Process::spawn.

06287 {
06288   ACE_OS_TRACE ("ACE_OS::exit");
06289 
06290 #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
06291   // Shut down the ACE_Object_Manager, if it had registered its exit_hook.
06292   // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is
06293   // instantiated on the main's stack.  ::exit () doesn't destroy it.
06294   if (exit_hook_)
06295     (*exit_hook_) ();
06296 #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
06297 
06298 #if !defined (ACE_HAS_WINCE)
06299 # if defined (ACE_WIN32)
06300   ::ExitProcess ((UINT) status);
06301 # elif defined (ACE_PSOSIM)
06302   ::u_exit (status);
06303 # else
06304   ::exit (status);
06305 # endif /* ACE_WIN32 */
06306 #else
06307   // @@ This is not exactly the same as ExitProcess.  But this is the
06308   // closest one I can get.
06309   ::TerminateProcess (::GetCurrentProcess (), status);
06310 #endif /* ACE_HAS_WINCE */
06311 }

ACE_INLINE int ACE_OS::fattach int    handle,
const char *    path
[static]
 

Definition at line 9676 of file OS.i.

References ACE_OS_TRACE, and fattach.

Referenced by ACE_SPIPE_Acceptor::create_new_instance, and fattach.

09677 {
09678   ACE_OS_TRACE ("ACE_OS::fattach");
09679 #if defined (ACE_HAS_STREAM_PIPES)
09680   ACE_OSCALL_RETURN (::fattach (handle, path), int, -1);
09681 #else
09682   ACE_UNUSED_ARG (handle);
09683   ACE_UNUSED_ARG (path);
09684 
09685   ACE_NOTSUP_RETURN (-1);
09686 #endif /* ACE_HAS_STREAM_PIPES */
09687 }

ACE_INLINE int ACE_OS::fclose FILE *    fp [static]
 

Definition at line 5666 of file OS.i.

References ACE_OS_TRACE, and fclose.

Referenced by access, ACE_Ini_ImpExp::export_config, ACE_Registry_ImpExp::export_config, fclose, ACE_Capabilities::getent, ACE_Logging_Strategy::handle_timeout, ACE_Ini_ImpExp::import_config, ACE_Registry_ImpExp::import_config, ACE_Service_Config::process_file, ACE_Log_Msg::~ACE_Log_Msg, and ACE_Read_Buffer::~ACE_Read_Buffer.

05667 {
05668   ACE_OS_TRACE ("ACE_OS::fclose");
05669   ACE_OSCALL_RETURN (::fclose (fp), int, -1);
05670 }

ACE_INLINE int ACE_OS::fcntl ACE_HANDLE    handle,
int    cmd,
long    arg = 0
[static]
 

Definition at line 144 of file OS.i.

References ACE_OS_TRACE, and fcntl.

Referenced by ACE_Flag_Manip::clr_flags, ACE_IPC_SAP::disable, ACE_IO_SAP::disable, ACE_IPC_SAP::enable, ACE_IO_SAP::enable, fcntl, flock_rdlock, flock_tryrdlock, flock_trywrlock, flock_unlock, flock_wrlock, ACE_Flag_Manip::get_flags, ACE_Select_Reactor_Notify::open, ACE_Dev_Poll_Reactor_Notify::open, and ACE_Flag_Manip::set_flags.

00145 {
00146   ACE_OS_TRACE ("ACE_OS::fcntl");
00147 # if defined (ACE_LACKS_FCNTL)
00148   ACE_UNUSED_ARG (handle);
00149   ACE_UNUSED_ARG (cmd);
00150   ACE_UNUSED_ARG (arg);
00151   ACE_NOTSUP_RETURN (-1);
00152 # else
00153   ACE_OSCALL_RETURN (::fcntl (handle, cmd, arg), int, -1);
00154 # endif /* ACE_LACKS_FCNTL */
00155 }

ACE_INLINE int ACE_OS::fdetach const char *    file [static]
 

Definition at line 9663 of file OS.i.

References ACE_OS_TRACE, and fdetach.

Referenced by ACE_SPIPE_Acceptor::close, and fdetach.

09664 {
09665   ACE_OS_TRACE ("ACE_OS::fdetach");
09666 #if defined (ACE_HAS_STREAM_PIPES)
09667   ACE_OSCALL_RETURN (::fdetach (file), int, -1);
09668 #else
09669   ACE_UNUSED_ARG (file);
09670 
09671   ACE_NOTSUP_RETURN (-1);
09672 #endif /* ACE_HAS_STREAM_PIPES */
09673 }

ACE_INLINE FILE * ACE_OS::fdopen ACE_HANDLE    handle,
const ACE_TCHAR   mode
[static]
 

Definition at line 9367 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and fdopen.

Referenced by fdopen.

09368 {
09369   ACE_OS_TRACE ("ACE_OS::fdopen");
09370 # if defined (ACE_HAS_WINCE)
09371   ACE_OSCALL_RETURN (::_wfdopen (handle, mode), FILE*, 0);
09372 # elif defined (ACE_WIN32)
09373   // kernel file handle -> FILE* conversion...
09374   // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost
09375 
09376   FILE *file = 0;
09377 
09378 #  if defined (ACE_WIN64)
09379   int crt_handle = ::_open_osfhandle (intptr_t (handle), 0);
09380 #  else
09381   int crt_handle = ::_open_osfhandle (long (handle), 0);
09382 #  endif /* ACE_WIN64 */
09383 
09384   if (crt_handle != -1)
09385     {
09386 #   if defined(__BORLANDC__) /* VSB */
09387       file = ::_fdopen (crt_handle, (char *) mode);
09388 #   elif defined (ACE_USES_WCHAR)
09389       file = ::_wfdopen (crt_handle, mode);
09390 #   else
09391       file = ::_fdopen (crt_handle, mode);
09392 #   endif /* __BORLANDC__ */
09393 
09394       if (!file)
09395         {
09396 #   if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530)
09397           ::_rtl_close (crt_handle);
09398 #   else
09399           ::_close (crt_handle);
09400 #   endif /* (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) */
09401         }
09402     }
09403 
09404   return file;
09405 # elif defined (ACE_PSOS)
09406   // @@ it may be possible to implement this for pSOS,
09407   // but it isn't obvious how to do this (perhaps via
09408   // f_stat to glean the default volume, and then open_fn ?)
09409   ACE_UNUSED_ARG (handle);
09410   ACE_UNUSED_ARG (mode);
09411   ACE_NOTSUP_RETURN (0);
09412 # else
09413   ACE_OSCALL_RETURN (::fdopen (handle, mode), FILE *, 0);
09414 # endif /* ACE_HAS_WINCE */
09415 }

ACE_INLINE int ACE_OS::fflush FILE *    fp [static]
 

Definition at line 5711 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and fflush.

Referenced by fflush, and ACE_Log_Record::print.

05712 {
05713 #if !defined (ACE_HAS_WINCE)
05714   ACE_OS_TRACE ("ACE_OS::fflush");
05715 #if defined (VXWORKS)
05716   if (fp == 0)
05717     {
05718       // Do not allow fflush(0) on VxWorks
05719       return 0;
05720     }
05721 #endif /* VXWORKS */
05722 
05723   ACE_OSCALL_RETURN (::fflush (fp), int, -1);
05724 #else
05725   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL(::FlushFileBuffers (fp),
05726                                          ace_result_),
05727                         int, -1);
05728 #endif /* !ACE_HAS_WINCE */
05729 }

ACE_INLINE int ACE_OS::fgetc FILE *    fp [static]
 

Definition at line 9966 of file OS.i.

References fgetc.

Referenced by fgetc.

09967 {
09968   ACE_OSCALL_RETURN (::fgetc (fp), int, -1);
09969 }

ACE_INLINE int ACE_OS::fgetpos FILE *    fp,
fpos_t *    pos
[static]
 

Definition at line 9954 of file OS.i.

References fgetpos.

Referenced by fgetpos.

09955 {
09956   ACE_OSCALL_RETURN (::fgetpos (fp, pos), int, -1);
09957 }

ACE_INLINE ACE_TCHAR * ACE_OS::fgets ACE_TCHAR   buf,
int    size,
FILE *    fp
[static]
 

Definition at line 5673 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and fgets.

Referenced by fgets, ACE_Ini_ImpExp::import_config, and ACE_Registry_ImpExp::import_config.

05674 {
05675   ACE_OS_TRACE ("ACE_OS::fgets");
05676 #if defined (ACE_HAS_WINCE)
05677   ACE_UNUSED_ARG (buf);
05678   ACE_UNUSED_ARG (size);
05679   ACE_UNUSED_ARG (fp);
05680   ACE_NOTSUP_RETURN (0);
05681 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
05682   ACE_OSCALL_RETURN (::fgetws (buf, size, fp), wchar_t *, 0);
05683 #else /* ACE_WIN32 */
05684   ACE_OSCALL_RETURN (::fgets (buf, size, fp), char *, 0);
05685 #endif /* ACE_HAS_WINCE */
05686 }

wint_t ACE_OS::fgetwc FILE *    fp [static]
 

ACE_INLINE long ACE_OS::filesize const ACE_TCHAR   handle [static]
 

Definition at line 7652 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, close, filesize, and open.

07653 {
07654   ACE_OS_TRACE ("ACE_OS::filesize");
07655 
07656   ACE_HANDLE h = ACE_OS::open (filename, O_RDONLY);
07657   if (h != ACE_INVALID_HANDLE)
07658     {
07659       long size = ACE_OS::filesize (h);
07660       ACE_OS::close (h);
07661       return size;
07662     }
07663   else
07664     return -1;
07665 }

ACE_INLINE long ACE_OS::filesize ACE_HANDLE    handle [static]
 

Definition at line 2852 of file OS.i.

References ACE_OS_TRACE, fstat, and stat.

Referenced by ACE_POSIX_Asynch_Transmit_Handler::ACE_POSIX_Asynch_Transmit_Handler, filesize, ACE_MMAP_Memory_Pool::handle_signal, ACE_Mem_Map::map_it, mmap, ACE_FILE_IO::recvv, ACE_MMAP_Memory_Pool::remap, ACE_POSIX_Asynch_Transmit_File::transmit_file, and ACE_Mem_Map::unmap.

02853 {
02854   ACE_OS_TRACE ("ACE_OS::filesize");
02855 #if defined (ACE_WIN32)
02856   ACE_WIN32CALL_RETURN (::GetFileSize (handle, 0), long, -1);
02857 #else /* !ACE_WIN32 */
02858   struct stat sb;
02859   return ACE_OS::fstat (handle, &sb) == -1 ? -1 : (long) sb.st_size;
02860 #endif /* ACE_WIN32 */
02861 }

ACE_INLINE int ACE_OS::flock_destroy ACE_OS::ace_flock_t   lock,
int    unlink_file = 1
[static]
 

Definition at line 9228 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, close, flock_unlock, ACE_OS_Memory::free, ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, munmap, mutex_destroy, shm_unlink, and unlink.

Referenced by ACE_File_Lock::remove.

09230 {
09231   ACE_OS_TRACE ("ACE_OS::flock_destroy");
09232   if (lock->handle_ != ACE_INVALID_HANDLE)
09233     {
09234       ACE_OS::flock_unlock (lock);
09235       // Close the handle.
09236       ACE_OS::close (lock->handle_);
09237       lock->handle_ = ACE_INVALID_HANDLE;
09238 #if defined (CHORUS)
09239       // Are we the owner?
09240       if (lock->process_lock_ && lock->lockname_ != 0)
09241         {
09242           // Only destroy the lock if we're the owner
09243           ACE_OS::mutex_destroy (lock->process_lock_);
09244           ACE_OS::munmap (lock->process_lock_,
09245                           sizeof (ACE_mutex_t));
09246           if (unlink_file)
09247             ACE_OS::shm_unlink (lock->lockname_);
09248           ACE_OS::free (ACE_static_cast (void *,
09249                                          ACE_const_cast (ACE_TCHAR *,
09250                                                          lock->lockname_)));
09251         }
09252       else if (lock->process_lock_)
09253         // Just unmap the memory.
09254         ACE_OS::munmap (lock->process_lock_,
09255                         sizeof (ACE_mutex_t));
09256 #else
09257       if (lock->lockname_ != 0)
09258         {
09259           if (unlink_file)
09260             ACE_OS::unlink (lock->lockname_);
09261           ACE_OS::free (ACE_static_cast (void *,
09262                                          ACE_const_cast (ACE_TCHAR *,
09263                                                          lock->lockname_)));
09264         }
09265 #endif /* CHORUS */
09266       lock->lockname_ = 0;
09267     }
09268   return 0;
09269 }

ACE_INLINE int ACE_OS::flock_init ACE_OS::ace_flock_t   lock,
int    flags = 0,
const ACE_TCHAR   name = 0,
mode_t    perms = 0
[static]
 

Definition at line 8875 of file OS.i.

References ACE_ALLOCATOR_RETURN, ACE_DEFAULT_FILE_PERMS, ACE_OS_TRACE, ACE_TCHAR, ftruncate, ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, MAP_FAILED, MAP_SHARED, mmap, mode_t, mutex_init, open, ACE_OS::ace_flock_t::overlapped_, PROT_RDWR, shm_open, and ACE_OS_String::strdup.

Referenced by ACE_File_Lock::ACE_File_Lock, and ACE_File_Lock::open.

08879 {
08880   ACE_OS_TRACE ("ACE_OS::flock_init");
08881 #if defined (CHORUS)
08882   lock->lockname_ = 0;
08883   // Let's see if it already exists.
08884   lock->handle_ = ACE_OS::shm_open (name,
08885                                     flags | O_CREAT | O_EXCL,
08886                                     perms);
08887   if (lock->handle_ == ACE_INVALID_HANDLE)
08888     {
08889       if (errno == EEXIST)
08890         // It's already there, so we'll just open it.
08891         lock->handle_ = ACE_OS::shm_open (name,
08892                                           flags | O_CREAT,
08893                                           ACE_DEFAULT_FILE_PERMS);
08894       else
08895         return -1;
08896     }
08897   else
08898     {
08899       // We own this shared memory object!  Let's set its size.
08900       if (ACE_OS::ftruncate (lock->handle_,
08901                              sizeof (ACE_mutex_t)) == -1)
08902         return -1;
08903       // Note that only the owner can destroy a file lock...
08904       ACE_ALLOCATOR_RETURN (lock->lockname_,
08905                             ACE_OS::strdup (name),
08906                             -1);
08907     }
08908   if (lock->handle_ == ACE_INVALID_HANDLE)
08909     return -1;
08910 
08911   lock->process_lock_ =
08912     (ACE_mutex_t *) ACE_OS::mmap (0,
08913                                   sizeof (ACE_mutex_t),
08914                                   PROT_RDWR,
08915                                   MAP_SHARED,
08916                                   lock->handle_,
08917                                   0);
08918   if (lock->process_lock_ == MAP_FAILED)
08919     return -1;
08920 
08921   if (lock->lockname_
08922       // Only initialize it if we're the one who created it.
08923       && ACE_OS::mutex_init (lock->process_lock_,
08924                              USYNC_PROCESS,
08925                              name,
08926                              0) != 0)
08927         return -1;
08928   return 0;
08929 #else
08930 #if defined (ACE_WIN32)
08931   // Once initialized, these values are never changed.
08932   lock->overlapped_.Internal = 0;
08933   lock->overlapped_.InternalHigh = 0;
08934   lock->overlapped_.OffsetHigh = 0;
08935   lock->overlapped_.hEvent = 0;
08936 #endif /* ACE_WIN32 */
08937   lock->handle_ = ACE_INVALID_HANDLE;
08938   lock->lockname_ = 0;
08939 
08940   if (name != 0)
08941     {
08942       ACE_OSCALL (ACE_OS::open (name, flags, perms),
08943                   ACE_HANDLE,
08944                   ACE_INVALID_HANDLE,
08945                   lock->handle_);
08946       lock->lockname_ = ACE_OS::strdup (name);
08947       return lock->handle_ == ACE_INVALID_HANDLE ? -1 : 0;
08948     }
08949   else
08950     return 0;
08951 #endif /* CHORUS */
08952 }

ACE_INLINE int ACE_OS::flock_rdlock ACE_OS::ace_flock_t   lock,
short    whence = 0,
off_t    start = 0,
off_t    len = 0
[static]
 

Definition at line 9028 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, adjust_flock_params, fcntl, ACE_OS::ace_flock_t::handle_, mutex_lock, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::acquire_read.

09032 {
09033   ACE_OS_TRACE ("ACE_OS::flock_rdlock");
09034 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
09035   ACE_OS::adjust_flock_params (lock, whence, start, len);
09036 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
09037   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
09038                                                         0,
09039                                                         0,
09040                                                         len,
09041                                                         0,
09042                                                         &lock->overlapped_),
09043                                           ace_result_), int, -1);
09044 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09045   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
09046                                                       lock->overlapped_.Offset,
09047                                                       0,
09048                                                       len,
09049                                                       0),
09050                                           ace_result_), int, -1);
09051 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09052 #elif defined (CHORUS)
09053   ACE_UNUSED_ARG (whence);
09054   ACE_UNUSED_ARG (start);
09055   ACE_UNUSED_ARG (len);
09056   return ACE_OS::mutex_lock (lock->process_lock_);
09057 #elif defined (ACE_LACKS_FILELOCKS)
09058   ACE_UNUSED_ARG (lock);
09059   ACE_UNUSED_ARG (whence);
09060   ACE_UNUSED_ARG (start);
09061   ACE_UNUSED_ARG (len);
09062   ACE_NOTSUP_RETURN (-1);
09063 #else
09064   lock->lock_.l_whence = whence;
09065   lock->lock_.l_start = start;
09066   lock->lock_.l_len = len;
09067   lock->lock_.l_type = F_RDLCK;         // set read lock
09068   // block, if no access
09069   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
09070                                     ACE_reinterpret_cast (long, &lock->lock_)),
09071                      int, -1);
09072 #endif /* ACE_WIN32 */
09073 }

ACE_INLINE int ACE_OS::flock_tryrdlock ACE_OS::ace_flock_t   lock,
short    whence = 0,
off_t    start = 0,
off_t    len = 0
[static]
 

Definition at line 9133 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, adjust_flock_params, EBUSY, fcntl, ACE_OS::ace_flock_t::handle_, mutex_trylock, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::tryacquire_read.

09137 {
09138   ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock");
09139 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
09140 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
09141   ACE_OS::adjust_flock_params (lock, whence, start, len);
09142   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
09143                                                         LOCKFILE_FAIL_IMMEDIATELY,
09144                                                         0,
09145                                                         len,
09146                                                         0,
09147                                                         &lock->overlapped_),
09148                                           ace_result_), int, -1);
09149 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09150   ACE_UNUSED_ARG (lock);
09151   ACE_UNUSED_ARG (whence);
09152   ACE_UNUSED_ARG (start);
09153   ACE_UNUSED_ARG (len);
09154   ACE_NOTSUP_RETURN (-1);
09155 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09156 #elif defined (CHORUS)
09157   ACE_UNUSED_ARG (whence);
09158   ACE_UNUSED_ARG (start);
09159   ACE_UNUSED_ARG (len);
09160   return ACE_OS::mutex_trylock (lock->process_lock_);
09161 #elif defined (ACE_LACKS_FILELOCKS)
09162   ACE_UNUSED_ARG (lock);
09163   ACE_UNUSED_ARG (whence);
09164   ACE_UNUSED_ARG (start);
09165   ACE_UNUSED_ARG (len);
09166   ACE_NOTSUP_RETURN (-1);
09167 #else
09168   lock->lock_.l_whence = whence;
09169   lock->lock_.l_start = start;
09170   lock->lock_.l_len = len;
09171   lock->lock_.l_type = F_RDLCK;         // set read lock
09172 
09173   int result = 0;
09174   // Does not block, if no access, returns -1 and set errno = EBUSY;
09175   ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK,
09176                              ACE_reinterpret_cast (long, &lock->lock_)),
09177               int, -1, result);
09178 
09179 # if ! defined (ACE_PSOS)
09180   if (result == -1 && (errno == EACCES || errno == EAGAIN))
09181     errno = EBUSY;
09182 # endif /* ! defined (ACE_PSOS) */
09183 
09184   return result;
09185 #endif /* ACE_WIN32 */
09186 }

ACE_INLINE int ACE_OS::flock_trywrlock ACE_OS::ace_flock_t   lock,
short    whence = 0,
off_t    start = 0,
off_t    len = 0
[static]
 

Definition at line 9076 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, adjust_flock_params, EBUSY, fcntl, ACE_OS::ace_flock_t::handle_, mutex_trylock, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::tryacquire_write, and ACE_File_Lock::tryacquire_write_upgrade.

09080 {
09081   ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock");
09082 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
09083 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
09084   ACE_OS::adjust_flock_params (lock, whence, start, len);
09085   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
09086                                                         LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
09087                                                         0,
09088                                                         len,
09089                                                         0,
09090                                                         &lock->overlapped_),
09091                                           ace_result_), int, -1);
09092 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09093   ACE_UNUSED_ARG (lock);
09094   ACE_UNUSED_ARG (whence);
09095   ACE_UNUSED_ARG (start);
09096   ACE_UNUSED_ARG (len);
09097   ACE_NOTSUP_RETURN (-1);
09098 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09099 #elif defined (CHORUS)
09100   ACE_UNUSED_ARG (whence);
09101   ACE_UNUSED_ARG (start);
09102   ACE_UNUSED_ARG (len);
09103   return ACE_OS::mutex_trylock (lock->process_lock_);
09104 #elif defined (ACE_LACKS_FILELOCKS)
09105   ACE_UNUSED_ARG (lock);
09106   ACE_UNUSED_ARG (whence);
09107   ACE_UNUSED_ARG (start);
09108   ACE_UNUSED_ARG (len);
09109   ACE_NOTSUP_RETURN (-1);
09110 #else
09111   lock->lock_.l_whence = whence;
09112   lock->lock_.l_start = start;
09113   lock->lock_.l_len = len;
09114   lock->lock_.l_type = F_WRLCK;         // set write lock
09115 
09116   int result = 0;
09117   // Does not block, if no access, returns -1 and set errno = EBUSY;
09118   ACE_OSCALL (ACE_OS::fcntl (lock->handle_,
09119                              F_SETLK,
09120                              ACE_reinterpret_cast (long, &lock->lock_)),
09121               int, -1, result);
09122 
09123 # if ! defined (ACE_PSOS)
09124   if (result == -1 && (errno == EACCES || errno == EAGAIN))
09125     errno = EBUSY;
09126 # endif /* ! defined (ACE_PSOS) */
09127 
09128   return result;
09129 #endif /* ACE_WIN32 */
09130 }

ACE_INLINE int ACE_OS::flock_unlock ACE_OS::ace_flock_t   lock,
short    whence = 0,
off_t    start = 0,
off_t    len = 0
[static]
 

Definition at line 9189 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, adjust_flock_params, fcntl, ACE_OS::ace_flock_t::handle_, mutex_unlock, and ACE_OS::ace_flock_t::overlapped_.

Referenced by flock_destroy, and ACE_File_Lock::release.

09193 {
09194   ACE_OS_TRACE ("ACE_OS::flock_unlock");
09195 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
09196   ACE_OS::adjust_flock_params (lock, whence, start, len);
09197   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnlockFile (lock->handle_,
09198                                                         lock->overlapped_.Offset,
09199                                                         0,
09200                                                         len,
09201                                                         0),
09202                                           ace_result_), int, -1);
09203 #elif defined (CHORUS)
09204   ACE_UNUSED_ARG (whence);
09205   ACE_UNUSED_ARG (start);
09206   ACE_UNUSED_ARG (len);
09207   return ACE_OS::mutex_unlock (lock->process_lock_);
09208 #elif defined (ACE_LACKS_FILELOCKS)
09209   ACE_UNUSED_ARG (lock);
09210   ACE_UNUSED_ARG (whence);
09211   ACE_UNUSED_ARG (start);
09212   ACE_UNUSED_ARG (len);
09213   ACE_NOTSUP_RETURN (-1);
09214 #else
09215   lock->lock_.l_whence = whence;
09216   lock->lock_.l_start = start;
09217   lock->lock_.l_len = len;
09218   lock->lock_.l_type = F_UNLCK;   // Unlock file.
09219 
09220   // release lock
09221   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLK,
09222                                     ACE_reinterpret_cast (long, &lock->lock_)),
09223                      int, -1);
09224 #endif /* ACE_WIN32 */
09225 }

ACE_INLINE int ACE_OS::flock_wrlock ACE_OS::ace_flock_t   lock,
short    whence = 0,
off_t    start = 0,
off_t    len = 0
[static]
 

Definition at line 8980 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, adjust_flock_params, fcntl, ACE_OS::ace_flock_t::handle_, mutex_lock, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::acquire_write.

08984 {
08985   ACE_OS_TRACE ("ACE_OS::flock_wrlock");
08986 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
08987   ACE_OS::adjust_flock_params (lock, whence, start, len);
08988 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
08989   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
08990                                                         LOCKFILE_EXCLUSIVE_LOCK,
08991                                                         0,
08992                                                         len,
08993                                                         0,
08994                                                         &lock->overlapped_),
08995                                           ace_result_), int, -1);
08996 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
08997   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
08998                                                       lock->overlapped_.Offset,
08999                                                       0,
09000                                                       len,
09001                                                       0),
09002                                           ace_result_), int, -1);
09003 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
09004 #elif defined (CHORUS)
09005   ACE_UNUSED_ARG (whence);
09006   ACE_UNUSED_ARG (start);
09007   ACE_UNUSED_ARG (len);
09008   return ACE_OS::mutex_lock (lock->process_lock_);
09009 #elif defined (ACE_LACKS_FILELOCKS)
09010   ACE_UNUSED_ARG (lock);
09011   ACE_UNUSED_ARG (whence);
09012   ACE_UNUSED_ARG (start);
09013   ACE_UNUSED_ARG (len);
09014   ACE_NOTSUP_RETURN (-1);
09015 #else
09016   lock->lock_.l_whence = whence;
09017   lock->lock_.l_start = start;
09018   lock->lock_.l_len = len;
09019   lock->lock_.l_type = F_WRLCK;         // set write lock
09020   // block, if no access
09021   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
09022                                     ACE_reinterpret_cast (long, &lock->lock_)),
09023                      int, -1);
09024 #endif /* ACE_WIN32 */
09025 }

ACE_INLINE double ACE_OS::floor double    x [static]
 

This method computes the largest integral value not greater than x.

Definition at line 5571 of file OS.i.

Referenced by ceil.

05572 {
05573   // This method computes the largest integral value not greater than x.
05574   return double (ACE_static_cast (long, x));
05575 }

ACE_INLINE FILE * ACE_OS::fopen const ACE_TCHAR   filename,
const ACE_TCHAR   mode
[static]
 

Definition at line 962 of file OS.cpp.

References _O_TEXT, ACE_OS_TRACE, ACE_TCHAR, close, fopen_mode_to_open_mode_converter, and open.

Referenced by access, ACE_Ini_ImpExp::export_config, ACE_Registry_ImpExp::export_config, ACE_Capabilities::getent, ACE_Logging_Strategy::handle_timeout, ACE_Ini_ImpExp::import_config, ACE_Registry_ImpExp::import_config, ACE_Logging_Strategy::init, ACE_Lib_Find::ldopen, and ACE_Service_Config::process_file.

00964 {
00965   ACE_OS_TRACE ("ACE_OS::fopen");
00966   int hmode = _O_TEXT;
00967 
00968   for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
00969     ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
00970 
00971   ACE_HANDLE handle = ACE_OS::open (filename, hmode);
00972   if (handle != ACE_INVALID_HANDLE)
00973     {
00974 # if defined (ACE_HAS_WINCE)
00975       FILE *fp = ::_wfdopen (handle, mode);
00976       if (fp != 0)
00977       {
00978         checkUnicodeFormat(fp);
00979         return fp;
00980       }
00981 # else
00982       hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
00983 #   if defined (ACE_WIN64)
00984       int fd = _open_osfhandle (intptr_t (handle), hmode);
00985 #   else
00986       int fd = _open_osfhandle (long (handle), hmode);
00987 #   endif /* ACE_WIN64 */
00988       if (fd != -1)
00989         {
00990 #   if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR)
00991           FILE *fp = ::_fdopen (fd, ACE_const_cast (char *, mode));
00992 #   elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR)
00993           FILE *fp = ::_wfdopen (fd, ACE_const_cast (wchar_t *, mode));
00994 #   elif defined (ACE_USES_WCHAR)
00995           FILE *fp = ::_wfdopen (fd, mode);
00996 #   else
00997           FILE *fp = ::fdopen (fd, mode);
00998 #   endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */
00999           if (fp != 0)
01000           {
01001 #   if defined (ACE_USES_WCHAR)
01002             checkUnicodeFormat(fp);
01003 #   endif  // ACE_USES_WCHAR
01004             return fp;
01005           }
01006           _close (fd);
01007         }
01008 # endif  // ACE_HAS_WINCE
01009 
01010       ACE_OS::close (handle);
01011     }
01012   return 0;
01013 }

void ACE_OS::fopen_mode_to_open_mode_converter ACE_TCHAR    x,
int &    hmode
[static, private]
 

Translate fopen's mode char to open's mode. This helper function is here to avoid maintaining several pieces of identical code.

Referenced by fopen.

pid_t ACE_OS::fork const ACE_TCHAR   program_name [static]
 

Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable.

Definition at line 4714 of file OS.cpp.

References ACE_OS_TRACE, ACE_TCHAR, pid_t, and ACE_Base_Thread_Adapter::sync_log_msg.

04715 {
04716   ACE_OS_TRACE ("ACE_OS::fork");
04717 # if defined (ACE_LACKS_FORK)
04718   ACE_UNUSED_ARG (program_name);
04719   ACE_NOTSUP_RETURN (pid_t (-1));
04720 # else
04721   pid_t pid =
04722 # if defined (ACE_HAS_STHREADS)
04723     ::fork1 ();
04724 #else
04725     ::fork ();
04726 #endif /* ACE_HAS_STHREADS */
04727 
04728 #if !defined (ACE_HAS_MINIMAL_ACE_OS)
04729   if (pid == 0)
04730     ACE_Base_Thread_Adapter::sync_log_msg (program_name);
04731 #endif /* ! ACE_HAS_MINIMAL_ACE_OS */
04732 
04733   return pid;
04734 # endif /* ACE_WIN32 */
04735 }

ACE_INLINE pid_t ACE_OS::fork void    [static]
 

Definition at line 9690 of file OS.i.

References ACE_OS_TRACE, fork, and pid_t.

Referenced by ACE::daemonize, fork, ACE::fork, and fork_exec.

09691 {
09692   ACE_OS_TRACE ("ACE_OS::fork");
09693 #if defined (ACE_LACKS_FORK)
09694   ACE_NOTSUP_RETURN (pid_t (-1));
09695 #else
09696   ACE_OSCALL_RETURN (::fork (), pid_t, -1);
09697 #endif /* ACE_LACKS_FORK */
09698 }

pid_t ACE_OS::fork_exec ACE_TCHAR   argv[] [static]
 

Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable.

Definition at line 4099 of file OS.cpp.

References ACE_TCHAR, argv_to_string, close, execv, exit, fork, ACE_OS_String::memset, and pid_t.

04100 {
04101 # if defined (ACE_WIN32)
04102   ACE_TCHAR *buf;
04103 
04104   if (ACE_OS::argv_to_string (argv, buf) != -1)
04105     {
04106       PROCESS_INFORMATION process_info;
04107 #   if !defined (ACE_HAS_WINCE)
04108       ACE_TEXT_STARTUPINFO startup_info;
04109       ACE_OS::memset ((void *) &startup_info,
04110                       0,
04111                       sizeof startup_info);
04112       startup_info.cb = sizeof startup_info;
04113 
04114       if (ACE_TEXT_CreateProcess (0,
04115                                   buf,
04116                                   0, // No process attributes.
04117                                   0,  // No thread attributes.
04118                                   TRUE, // Allow handle inheritance.
04119                                   0, // Don't create a new console window.
04120                                   0, // No environment.
04121                                   0, // No current directory.
04122                                   &startup_info,
04123                                   &process_info))
04124 #   else
04125       if (ACE_TEXT_CreateProcess (0,
04126                                   buf,
04127                                   0, // No process attributes.
04128                                   0,  // No thread attributes.
04129                                   FALSE, // Can's inherit handles on CE
04130                                   0, // Don't create a new console window.
04131                                   0, // No environment.
04132                                   0, // No current directory.
04133                                   0, // Can't use startup info on CE
04134                                   &process_info))
04135 #   endif /* ! ACE_HAS_WINCE */
04136         {
04137           // Free resources allocated in kernel.
04138           ACE_OS::close (process_info.hThread);
04139           ACE_OS::close (process_info.hProcess);
04140           // Return new process id.
04141           delete [] buf;
04142           return process_info.dwProcessId;
04143         }
04144     }
04145 
04146   // CreateProcess failed.
04147   return -1;
04148 # elif defined (CHORUS)
04149   return ACE_OS::execv (argv[0], argv);
04150 # else
04151       pid_t result = ACE_OS::fork ();
04152 
04153       switch (result)
04154         {
04155         case -1:
04156           // Error.
04157           return -1;
04158         case 0:
04159           // Child process.
04160           if (ACE_OS::execv (argv[0], argv) == -1)
04161             {
04162               // The OS layer should not print stuff out
04163               // ACE_ERROR ((LM_ERROR,
04164               //             "%p Exec failed\n"));
04165 
04166               // If the execv fails, this child needs to exit.
04167               ACE_OS::exit (errno);
04168             }
04169         default:
04170           // Server process.  The fork succeeded.
04171           return result;
04172         }
04173 # endif /* ACE_WIN32 */
04174 }

int ACE_OS::fprintf FILE *    fp,
const wchar_t *    format,
...   
[static]
 

Definition at line 1033 of file OS.cpp.

References ACE_OS_TRACE.

01034 {
01035   ACE_OS_TRACE ("ACE_OS::fprintf");
01036 
01037 # if !defined (ACE_HAS_VFWPRINTF)
01038   ACE_UNUSED_ARG (fp);
01039   ACE_UNUSED_ARG (format);
01040   ACE_NOTSUP_RETURN (-1);
01041 
01042 # else
01043   int result = 0;
01044   va_list ap;
01045   va_start (ap, format);
01046   ACE_OSCALL (::vfwprintf (fp, format, ap), int, -1, result);
01047   va_end (ap);
01048   return result;
01049 
01050 # endif /* ACE_HAS_VFWPRINTF */
01051 }

int ACE_OS::fprintf FILE *    fp,
const char *    format,
...   
[static]
 

Definition at line 1020 of file OS.cpp.

References ACE_OS_TRACE.

Referenced by ACE_ATM_Stream::get_vpi_vci, ACE_Log_Msg::log, ACE_Name_Options::parse_args, ACE_Log_Record::print, ACE_Stats::print_summary, socket_fini, and socket_init.

01021 {
01022   ACE_OS_TRACE ("ACE_OS::fprintf");
01023   int result = 0;
01024   va_list ap;
01025   va_start (ap, format);
01026   ACE_OSCALL (::vfprintf (fp, format, ap), int, -1, result);
01027   va_end (ap);
01028   return result;
01029 }

ACE_INLINE int ACE_OS::fputs const ACE_TCHAR   s,
FILE *    stream
[static]
 

Definition at line 6363 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and fputs.

Referenced by ACE_Ini_ImpExp::export_section, ACE_Registry_ImpExp::export_section, and fputs.

06364 {
06365   ACE_OS_TRACE ("ACE_OS::fputs");
06366 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
06367   ACE_OSCALL_RETURN (::fputws (s, stream), int, -1);
06368 #else /* ACE_WIN32 */
06369   ACE_OSCALL_RETURN (::fputs (s, stream), int, -1);
06370 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
06371 }

ACE_INLINE size_t ACE_OS::fread void *    ptr,
size_t    size,
size_t    nelems,
FILE *    fp
[static]
 

Definition at line 5732 of file OS.i.

References ACE_OS_TRACE, and fread.

Referenced by fread.

05733 {
05734   ACE_OS_TRACE ("ACE_OS::fread");
05735 #if defined (ACE_LACKS_POSIX_PROTOTYPES)
05736   ACE_OSCALL_RETURN (::fread ((char *) ptr, size, nelems, fp), int, 0);
05737 #else
05738   ACE_OSCALL_RETURN (::fread (ptr, size, nelems, fp), int, 0);
05739 #endif /* ACE_LACKS_POSIX_PROTOTYPES */
05740 }

ACE_INLINE FILE * ACE_OS::freopen const ACE_TCHAR   filename,
const ACE_TCHAR   mode,
FILE *    stream
[static]
 

Definition at line 5700 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and freopen.

Referenced by freopen.

05701 {
05702   ACE_OS_TRACE ("ACE_OS::freopen");
05703 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
05704   ACE_OSCALL_RETURN (::_wfreopen (filename, mode, stream), FILE *, 0);
05705 #else
05706   ACE_OSCALL_RETURN (::freopen (filename, mode, stream), FILE *, 0);
05707 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
05708 }

ACE_INLINE int ACE_OS::fseek FILE *    fp,
long    offset,
int    ptrname
[static]
 

Definition at line 9922 of file OS.i.

References fseek.

Referenced by fseek, and ACE_Logging_Strategy::handle_timeout.

09923 {
09924 # if defined (ACE_WIN32)
09925 #   if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
09926   //#error Windows NT is evil AND rude!
09927   switch (whence)
09928     {
09929     case SEEK_SET:
09930       whence = FILE_BEGIN;
09931       break;
09932     case SEEK_CUR:
09933       whence = FILE_CURRENT;
09934       break;
09935     case SEEK_END:
09936       whence = FILE_END;
09937       break;
09938     default:
09939       errno = EINVAL;
09940       return -1; // rather safe than sorry
09941     }
09942 #   endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
09943 # endif   /* ACE_WIN32 */
09944   ACE_OSCALL_RETURN (::fseek (fp, offset, whence), int, -1);
09945 }

ACE_INLINE int ACE_OS::fsetpos FILE *    fp,
fpos_t *    pos
[static]
 

Definition at line 9960 of file OS.i.

References fsetpos.

Referenced by fsetpos.

09961 {
09962   ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
09963 }

ACE_INLINE int ACE_OS::fstat ACE_HANDLE   ,
ACE_stat  
[static]
 

Definition at line 305 of file OS.i.

References ACE_OS_TRACE, ACE_stat, and fstat.

Referenced by ACE_Select_Reactor_T::check_handles, filesize, fstat, and ACE_FILE::get_info.

00306 {
00307   ACE_OS_TRACE ("ACE_OS::fstat");
00308 #if defined (ACE_PSOS_LACKS_PHILE)
00309   ACE_UNUSED_ARG (handle);
00310   ACE_UNUSED_ARG (stp);
00311   ACE_NOTSUP_RETURN (-1);
00312 #elif defined (ACE_PSOS)
00313   ACE_OSCALL_RETURN (::fstat_f (handle, stp), int, -1);
00314 #else
00315 # if defined (ACE_HAS_X86_STAT_MACROS)
00316     // Solaris for intel uses an macro for fstat(), this is a wrapper
00317     // for _fxstat() use of the macro.
00318     // causes compile and runtime problems.
00319     ACE_OSCALL_RETURN (::_fxstat (_STAT_VER, handle, stp), int, -1);
00320 # elif defined (ACE_WIN32)
00321     ACE_OSCALL_RETURN (::_fstat (handle, stp), int, -1);
00322 # else
00323     ACE_OSCALL_RETURN (::fstat (handle, stp), int, -1);
00324 # endif /* !ACE_HAS_X86_STAT_MACROS */
00325 #endif /* ACE_PSOS_LACKS_PHILE */
00326 }

ACE_INLINE int ACE_OS::fsync ACE_HANDLE    handle [static]
 

Definition at line 351 of file OS.i.

References ACE_OS_TRACE, and fsync.

Referenced by fsync.

00352 {
00353   ACE_OS_TRACE ("ACE_OS::fsync");
00354 # if defined (ACE_LACKS_FSYNC)
00355   ACE_UNUSED_ARG (handle);
00356   ACE_NOTSUP_RETURN (-1);
00357 # else
00358   ACE_OSCALL_RETURN (::fsync (handle), int, -1);
00359 # endif /* ACE_LACKS_FSYNC */
00360 }

ACE_INLINE long ACE_OS::ftell FILE *    fp [static]
 

Definition at line 9948 of file OS.i.

References ftell.

Referenced by ftell.

09949 {
09950   ACE_OSCALL_RETURN (::ftell (fp), long, -1);
09951 }

ACE_INLINE int ACE_OS::ftruncate ACE_HANDLE   ,
off_t   
[static]
 

Definition at line 2864 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and ftruncate.

Referenced by ACE_Condition::ACE_Condition, ACE_Mutex::ACE_Mutex, flock_init, ftruncate, ACE_Mem_Map::map_it, ACE_Mem_Map::remove, sema_init, and ACE_FILE::truncate.

02865 {
02866   ACE_OS_TRACE ("ACE_OS::ftruncate");
02867 #if defined (ACE_WIN32)
02868   if (::SetFilePointer (handle, offset, 0, FILE_BEGIN) != (unsigned) -1)
02869     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
02870   else
02871     ACE_FAIL_RETURN (-1);
02872   /* NOTREACHED */
02873 #elif defined (ACE_PSOS_LACKS_PHILE)
02874   ACE_UNUSED_ARG (handle);
02875   ACE_UNUSED_ARG (offset);
02876   ACE_NOTSUP_RETURN (-1);
02877 #elif defined (ACE_PSOS)
02878   ACE_OSCALL_RETURN (::ftruncate_f (handle, offset), int, -1);
02879 #else
02880   ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1);
02881 #endif /* ACE_WIN32 */
02882 }

ACE_INLINE size_t ACE_OS::fwrite const void *    ptr,
size_t    size,
size_t    nitems,
FILE *    fp
[static]
 

Definition at line 5743 of file OS.i.

References ACE_OS_TRACE, and fwrite.

Referenced by fwrite.

05744 {
05745   ACE_OS_TRACE ("ACE_OS::fwrite");
05746 #if defined (ACE_LACKS_POSIX_PROTOTYPES)
05747   ACE_OSCALL_RETURN (::fwrite ((const char *) ptr, size, nitems, fp), int, 0);
05748 #else
05749   ACE_OSCALL_RETURN (::fwrite (ptr, size, nitems, fp), int, 0);
05750 #endif /* ACE_LACKS_POSIX_PROTOTYPES */
05751 }

HINSTANCE ACE_OS::get_win32_resource_module void    [static]
 

Return the handle of the module containing ACE's resources. By default, for a DLL build of ACE this is a handle to the ACE DLL itself, and for a static build it is a handle to the executable.

const OSVERSIONINFO& ACE_OS::get_win32_versioninfo void    [static]
 

Return the win32 OSVERSIONINFO structure.

ACE_INLINE ACE_TCHAR * ACE_OS::getcwd ACE_TCHAR  ,
size_t   
[static]
 

Definition at line 10181 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, getcwd, ACE_OS_String::memset, ACE_OS_String::strcat, ACE_OS_String::strcpy, and ACE_OS_String::strlen.

Referenced by getcwd.

10182 {
10183   ACE_OS_TRACE ("ACE_OS::getcwd");
10184 #if defined (ACE_PSOS_LACKS_PHILE)
10185   ACE_UNUSED_ARG (buf);
10186   ACE_UNUSED_ARG (size);
10187   ACE_NOTSUP_RETURN ( (char*)-1);
10188 #elif defined (ACE_PSOS)
10189 
10190   static char pathbuf [BUFSIZ];
10191 
10192   // blank the path buffer
10193   ACE_OS::memset (pathbuf, '\0', BUFSIZ);
10194 
10195   // the following was suggested in the documentation for get_fn ()
10196   u_long result;
10197   char cur_dir_name [BUFSIZ] = ".";
10198 
10199   u_long cur_dir = 0, prev_dir = 0;
10200   while ((ACE_OS::strlen (pathbuf) < BUFSIZ) &&
10201          (ACE_OS::strlen (cur_dir_name) < BUFSIZ - ACE_OS::strlen ("/..")))
10202   {
10203     // get the current directory handle
10204     result = ::get_fn (cur_dir_name, &cur_dir);
10205 
10206     // check whether we're at the root: this test is
10207     // really lame, but the get_fn documentation says
10208     // *either* condition indicates you're trying to
10209     // move above the root.
10210     if ((result != 0) || ( cur_dir == prev_dir))
10211     {
10212       break;
10213     }
10214 
10215     // change name to the parent directory
10216     ACE_OS::strcat (cur_dir_name, "/..");
10217 
10218     // open the parent directory
10219     XDIR xdir;
10220     result = ::open_dir (cur_dir_name, &xdir);
10221     if (result != 0)
10222     {
10223       return 0;
10224     }
10225 
10226     // look for an entry that matches the current directory handle
10227     struct dirent dir_entry;
10228     while (1)
10229     {
10230       // get the next directory entry
10231       result = ::read_dir (&xdir, &dir_entry);
10232       if (result != 0)
10233       {
10234         return 0;
10235       }
10236 
10237       // check for a match
10238       if (dir_entry.d_filno == cur_dir)
10239       {
10240         // prefix the previous path with the entry's name and break
10241         if (ACE_OS::strlen (pathbuf) + ACE_OS::strlen (dir_entry.d_name) < BUFSIZ)
10242         {
10243           ACE_OS::strcpy (pathbuf + ACE_OS::strlen (dir_entry.d_name), pathbuf);
10244           ACE_OS::strcpy (pathbuf, dir_entry.d_name);
10245           break;
10246         }
10247         else
10248         {
10249           // we're out of room in the buffer
10250           return 0;
10251         }
10252       }
10253     }
10254 
10255     // close the parent directory
10256     result = ::close_dir (&xdir);
10257     if (result != 0)
10258     {
10259       return 0;
10260     }
10261 
10262     // save the current directory handle as the previous
10263     prev_dir =  cur_dir;
10264   }
10265 
10266   // return the path, if there is one
10267   return (ACE_OS::strlen (pathbuf) > 0) ? pathbuf : (char *) 0;
10268 #elif defined (ACE_HAS_WINCE)
10269   ACE_UNUSED_ARG (buf);
10270   ACE_UNUSED_ARG (size);
10271   ACE_NOTSUP_RETURN (0);
10272 #elif defined (ACE_WIN32)
10273 #  if defined (ACE_USES_WCHAR)
10274   return ::_wgetcwd (buf, ACE_static_cast (int, size));
10275 #  else
10276   return ::getcwd (buf, ACE_static_cast (int, size));
10277 #  endif /* ACE_USES_WCHAR */
10278 #else
10279   ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0);
10280 #endif /* ACE_PSOS_LACKS_PHILE */
10281 }

wchar_t* ACE_OS::getenv const wchar_t *    symbol [static]
 

ACE_INLINE char * ACE_OS::getenv const char *    symbol [static]
 

Definition at line 10462 of file OS.i.

References ACE_OS_TRACE, and getenv.

Referenced by ACE_ARGV::ACE_ARGV, ACE_Get_Opt::ACE_Get_Opt, argv_to_string, ACE_Env_Value::fetch_value, ACE_High_Res_Timer::get_env_global_scale_factor, ACE_Lib_Find::get_temp_dir, getenv, ACE_Lib_Find::ldfind, and strenvdup.

10463 {
10464   ACE_OS_TRACE ("ACE_OS::getenv");
10465 #if defined (ACE_LACKS_ENV)
10466   ACE_UNUSED_ARG (symbol);
10467   ACE_NOTSUP_RETURN (0);
10468 #elif defined (ACE_PSOS)
10469   ACE_UNUSED_ARG (symbol);
10470   ACE_NOTSUP_RETURN (0);
10471 #else /* ACE_PSOS */
10472   ACE_OSCALL_RETURN (::getenv (symbol), char *, 0);
10473 #endif /* ACE_LACKS_ENV */
10474 }

ACE_TCHAR * ACE_OS::getenvstrings void    [static]
 

Definition at line 7119 of file OS.cpp.

Referenced by ACE_Process_Options::inherit_environment.

07120 {
07121 #if defined (ACE_LACKS_ENV)
07122   ACE_NOTSUP_RETURN (0);
07123 #elif defined (ACE_WIN32)
07124 # if defined (ACE_USES_WCHAR)
07125   return ::GetEnvironmentStringsW ();
07126 # else /* ACE_USES_WCHAR */
07127   return ::GetEnvironmentStrings ();
07128 # endif /* ACE_USES_WCHAR */
07129 #else /* ACE_WIN32 */
07130   ACE_NOTSUP_RETURN (0);
07131 #endif /* ACE_WIN32 */
07132 }

ACE_INLINE gid_t ACE_OS::getgid void    [static]
 

Definition at line 10968 of file OS.i.

References ACE_OS_TRACE, getgid, and gid_t.

Referenced by getgid, and ACE_SPIPE_Addr::set.

10969 {
10970   ACE_OS_TRACE ("ACE_OS::getgid");
10971 #if defined (VXWORKS) || defined (ACE_PSOS)
10972   // getgid() is not supported:  just one user anyways
10973   return 0;
10974 # elif defined (ACE_WIN32) || defined (CHORUS)
10975   ACE_NOTSUP_RETURN (ACE_static_cast (gid_t, -1));
10976 # else
10977   ACE_OSCALL_RETURN (::getgid (), gid_t, (gid_t) -1);
10978 # endif /* VXWORKS || ACE_PSOS */
10979 }

ACE_INLINE struct hostent * ACE_OS::gethostbyaddr const char *    addr,
int    length,
int    type
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4835 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ACE_SOCKET_LEN.

Referenced by ACE_INET_Addr::get_host_name_i, and getipnodebyaddr.

04836 {
04837   ACE_OS_TRACE ("ACE_OS::gethostbyaddr");
04838 # if defined (ACE_PSOS)
04839   ACE_UNUSED_ARG (addr);
04840   ACE_UNUSED_ARG (length);
04841   ACE_UNUSED_ARG (type);
04842   ACE_NOTSUP_RETURN (0);
04843 # elif defined (ACE_HAS_NONCONST_GETBY)
04844   ACE_SOCKCALL_RETURN (::gethostbyaddr (ACE_const_cast (char *, addr),
04845                                         (ACE_SOCKET_LEN) length,
04846                                         type),
04847                        struct hostent *,
04848                        0);
04849 # else
04850   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
04851                                         (ACE_SOCKET_LEN) length,
04852                                         type),
04853                        struct hostent *,
04854                        0);
04855 # endif /* ACE_HAS_NONCONST_GETBY */
04856 }

ACE_INLINE struct hostent * ACE_OS::gethostbyaddr_r const char *    addr,
int    length,
int    type,
struct hostent *    result,
ACE_HOSTENT_DATA    buffer,
int *    h_errnop
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5921 of file OS.i.

References ACE_HOSTENT_DATA, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ACE_SOCKET_LEN.

Referenced by ACE_INET_Addr::get_host_name_i.

05927 {
05928   ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r");
05929 # if defined (ACE_PSOS)
05930   ACE_UNUSED_ARG (addr);
05931   ACE_UNUSED_ARG (length);
05932   ACE_UNUSED_ARG (type);
05933   ACE_UNUSED_ARG (result);
05934   ACE_UNUSED_ARG (buffer);
05935   ACE_UNUSED_ARG (h_errnop);
05936   ACE_NOTSUP_RETURN (0);
05937 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
05938 #   if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10)
05939   ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
05940 
05941   if (::gethostbyaddr_r ((char *) addr, length, type, result,
05942                          (struct hostent_data *) buffer)== 0)
05943     return result;
05944   else
05945     {
05946       *h_errnop = h_errno;
05947       return (struct hostent *) 0;
05948     }
05949 # elif defined (__GLIBC__)
05950   // GNU C library has a different signature
05951   ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
05952 
05953   if (::gethostbyaddr_r ((char *) addr,
05954                          length,
05955                          type,
05956                          result,
05957                          buffer,
05958                          sizeof (ACE_HOSTENT_DATA),
05959                          &result,
05960                          h_errnop) == 0)
05961     return result;
05962   else
05963     return (struct hostent *) 0;
05964 #   else
05965 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
05966   ACE_UNUSED_ARG (result);
05967   ACE_UNUSED_ARG (h_errnop);
05968   ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type),
05969                         struct hostent *, 0,
05970                         buffer, sizeof (ACE_HOSTENT_DATA));
05971 #     else
05972   ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result,
05973                                           buffer, sizeof (ACE_HOSTENT_DATA),
05974                                           h_errnop),
05975                        struct hostent *, 0);
05976 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
05977 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
05978 # elif defined (ACE_HAS_NONCONST_GETBY)
05979   ACE_UNUSED_ARG (result);
05980   ACE_UNUSED_ARG (buffer);
05981   ACE_UNUSED_ARG (h_errnop);
05982   ACE_SOCKCALL_RETURN (::gethostbyaddr (ACE_const_cast (char *, addr),
05983                                         (ACE_SOCKET_LEN) length,
05984                                         type),
05985                        struct hostent *,
05986                        0);
05987 # else
05988   ACE_UNUSED_ARG (h_errnop);
05989   ACE_UNUSED_ARG (buffer);
05990   ACE_UNUSED_ARG (result);
05991 
05992   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
05993                                         (ACE_SOCKET_LEN) length,
05994                                         type),
05995                        struct hostent *,
05996                        0);
05997 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
05998 }

ACE_INLINE struct hostent * ACE_OS::gethostbyname const char *    name [static]
 

BSD-style <accept> (no QoS).

Definition at line 4816 of file OS.i.

References ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

Referenced by ACE_Sock_Connect::get_bcast_addr, getipnodebyname, ACE_SOCK_Dgram_Bcast::mk_broadcast, and ACE_INET_Addr::set.

04817 {
04818   ACE_OS_TRACE ("ACE_OS::gethostbyname");
04819 # if defined (ACE_PSOS)
04820   ACE_UNUSED_ARG (name);
04821   ACE_NOTSUP_RETURN (0);
04822 # elif defined (ACE_HAS_NONCONST_GETBY)
04823   ACE_SOCKCALL_RETURN (::gethostbyname (ACE_const_cast (char *, name)),
04824                        struct hostent *,
04825                        0);
04826 # else
04827   ACE_SOCKCALL_RETURN (::gethostbyname (name),
04828                        struct hostent *,
04829                        0);
04830 # endif /* ACE_HAS_NONCONST_GETBY */
04831 }

ACE_INLINE struct hostent * ACE_OS::gethostbyname_r const char *    name,
struct hostent *    result,
ACE_HOSTENT_DATA    buffer,
int *    h_errnop
[static]
 

BSD-style <accept> (no QoS).

Definition at line 6001 of file OS.i.

References ACE_HOSTENT_DATA, ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

Referenced by ACE_INET_Addr::set.

06005 {
06006   ACE_OS_TRACE ("ACE_OS::gethostbyname_r");
06007 #if defined (ACE_PSOS)
06008   ACE_UNUSED_ARG (name);
06009   ACE_UNUSED_ARG (result);
06010   ACE_UNUSED_ARG (buffer);
06011   ACE_UNUSED_ARG (h_errnop);
06012   ACE_NOTSUP_RETURN (0);
06013 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
06014 #   if defined (DIGITAL_UNIX) || \
06015        (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2))
06016   ACE_UNUSED_ARG (result);
06017   ACE_UNUSED_ARG (buffer);
06018   ACE_UNUSED_ARG (h_errnop);
06019 
06020   // gethostbyname returns thread-specific storage on Digital Unix and
06021   // AIX 4.3
06022   ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
06023 #   elif defined (AIX) || defined (HPUX_10)
06024   ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
06025 
06026   if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0)
06027     return result;
06028   else
06029     {
06030       *h_errnop = h_errno;
06031       return (struct hostent *) 0;
06032     }
06033 # elif defined (__GLIBC__)
06034   // GNU C library has a different signature
06035   ::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
06036 
06037   if (::gethostbyname_r (name,
06038                          result,
06039                          buffer,
06040                          sizeof (ACE_HOSTENT_DATA),
06041                          &result,
06042                          h_errnop) == 0)
06043     return result;
06044   else
06045     return (struct hostent *) 0;
06046 #   else
06047 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
06048   ACE_UNUSED_ARG (result);
06049   ACE_UNUSED_ARG (h_errnop);
06050   ACE_NETDBCALL_RETURN (::gethostbyname (name),
06051                         struct hostent *, 0,
06052                         buffer, sizeof (ACE_HOSTENT_DATA));
06053 #     else
06054   ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer,
06055                                           sizeof (ACE_HOSTENT_DATA),
06056                                           h_errnop),
06057                        struct hostent *,
06058                        0);
06059 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
06060 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
06061 # elif defined (ACE_HAS_NONCONST_GETBY)
06062   ACE_UNUSED_ARG (result);
06063   ACE_UNUSED_ARG (buffer);
06064   ACE_UNUSED_ARG (h_errnop);
06065   ACE_SOCKCALL_RETURN (::gethostbyname (ACE_const_cast (char *, name)),
06066                        struct hostent *,
06067                        0);
06068 # else
06069   ACE_UNUSED_ARG (result);
06070   ACE_UNUSED_ARG (buffer);
06071   ACE_UNUSED_ARG (h_errnop);
06072 
06073   ACE_SOCKCALL_RETURN (::gethostbyname (name),
06074                        struct hostent *,
06075                        0);
06076 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
06077 }

ACE_INLINE ACE_hrtime_t ACE_OS::gethrtime const    ACE_HRTimer_Op = ACE_HRTIMER_GETTIME [static]
 

Definition at line 9521 of file OS.i.

References ACE_hrtime_t, ACE_HRTIMER_GETTIME, ACE_ONE_SECOND_IN_NSECS, ACE_OS_TRACE, ACE_UINT64, clock_gettime, CLOCK_REALTIME, gettimeofday, ACE_OS_String::memcpy, ACE_Time_Value::sec, timespec::tv_nsec, timespec::tv_sec, and ACE_Time_Value::usec.

Referenced by ACE_High_Res_Timer::calibrate, ACE_High_Res_Timer::gettime, ACE_High_Res_Timer::gettimeofday, and ACE_Timeprobe::timeprobe.

09522 {
09523   ACE_OS_TRACE ("ACE_OS::gethrtime");
09524 #if defined (ACE_HAS_HI_RES_TIMER)
09525   ACE_UNUSED_ARG (op);
09526   return ::gethrtime ();
09527 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
09528   ACE_UNUSED_ARG (op);
09529   timebasestruct_t tb;
09530 
09531   ::read_real_time(&tb, TIMEBASE_SZ);
09532   ::time_base_to_time(&tb, TIMEBASE_SZ);
09533 
09534   return ACE_hrtime_t(tb.tb_high) * ACE_ONE_SECOND_IN_NSECS + tb.tb_low;
09535 #elif defined (ghs) && defined (ACE_HAS_PENTIUM) && !defined (ACE_WIN32)
09536   ACE_UNUSED_ARG (op);
09537   // Use .obj/gethrtime.o, which was compiled with g++.
09538   return ACE_gethrtime ();
09539 #elif (defined(__KCC) || defined (__GNUG__)) && !defined (__MINGW32__) && defined (ACE_HAS_PENTIUM)
09540   ACE_UNUSED_ARG (op);
09541 
09542 # if defined (ACE_LACKS_LONGLONG_T)
09543   double now;
09544 # else  /* ! ACE_LACKS_LONGLONG_T */
09545   ACE_hrtime_t now;
09546 # endif /* ! ACE_LACKS_LONGLONG_T */
09547 
09548   // See comments about the RDTSC Pentium instruction for the ACE_WIN32
09549   // version of ACE_OS::gethrtime (), below.
09550   //
09551   // Read the high-res tick counter directly into memory variable "now".
09552   // The A constraint signifies a 64-bit int.
09553   asm volatile ("rdtsc" : "=A" (now) : : "memory");
09554 
09555 # if defined (ACE_LACKS_LONGLONG_T)
09556   ACE_UINT32 least, most;
09557   ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32));
09558   ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32),
09559                   sizeof (ACE_UINT32));
09560 
09561   ACE_hrtime_t ret (least, most);
09562   return ret;
09563 # else  /* ! ACE_LACKS_LONGLONG_T */
09564   return now;
09565 # endif /* ! ACE_LACKS_LONGLONG_T */
09566 #elif defined (linux) && defined (ACE_HAS_ALPHA_TIMER)
09567   // NOTE:  alphas only have a 32 bit tick (cycle) counter.  The rpcc
09568   // instruction actually reads 64 bits, but the high 32 bits are
09569   // implementation-specific.  Linux and Digital Unix, for example,
09570   // use them for virtual tick counts, i.e., taking into account only
09571   // the time that the process was running.  This information is from
09572   // David Mosberger's article, see comment below.
09573   ACE_UINT32 now;
09574 
09575   // The following statement is based on code published by:
09576   // Mosberger, David, "How to Make Your Applications Fly, Part 1",
09577   // Linux Journal Issue 42, October 1997, page 50.  It reads the
09578   // high-res tick counter directly into the memory variable.
09579   asm volatile ("rpcc %0" : "=r" (now) : : "memory");
09580 
09581   return now;
09582 #elif defined (ACE_WIN32)
09583   ACE_UNUSED_ARG(op);
09584   LARGE_INTEGER freq;
09585 
09586   ::QueryPerformanceCounter (&freq);
09587 
09588 #  if defined (ACE_LACKS_LONGLONG_T)
09589   ACE_UINT64 uint64_freq(freq.u.LowPart, ACE_static_cast (unsigned int, freq.u.HighPart));
09590   return uint64_freq;
09591 #  else
09592   return freq.QuadPart;
09593 #  endif //ACE_LACKS_LONGLONG_T
09594 
09595 #elif defined (CHORUS)
09596   if (op == ACE_OS::ACE_HRTIMER_GETTIME)
09597     {
09598       struct timespec ts;
09599 
09600       ACE_OS::clock_gettime (CLOCK_REALTIME, &ts);
09601 
09602       // Carefully create the return value to avoid arithmetic overflow
09603       // if ACE_hrtime_t is ACE_U_LongLong.
09604       ACE_hrtime_t now = ts.tv_sec;
09605       now *= ACE_U_ONE_SECOND_IN_NSECS;
09606       now += ts.tv_nsec;
09607 
09608       return now;
09609     }
09610   else
09611     {
09612       // Use the sysBench timer on Chorus.  On MVME177, at least, it only
09613       // has 32 bits.  Be careful, because using it disables interrupts!
09614       ACE_UINT32 now;
09615       if (::sysBench (op, (int *) &now) == K_OK)
09616         {
09617           now *= 1000u /* nanoseconds/microsecond */;
09618           return (ACE_hrtime_t) now;
09619         }
09620       else
09621         {
09622           // Something went wrong.  Just return 0.
09623           return (ACE_hrtime_t) 0;
09624         }
09625     }
09626 
09627 #elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__))
09628   // PowerPC w/ GreenHills or g++.
09629 
09630   ACE_UNUSED_ARG (op);
09631   u_long most;
09632   u_long least;
09633   ACE_OS::readPPCTimeBase (most, least);
09634 #if defined (ACE_LACKS_LONGLONG_T)
09635   return ACE_U_LongLong (least, most);
09636 #else  /* ! ACE_LACKS_LONGLONG_T */
09637   return 0x100000000llu * most  +  least;
09638 #endif /* ! ACE_LACKS_LONGLONG_T */
09639 
09640 #elif defined (ACE_HAS_CLOCK_GETTIME) || defined (ACE_PSOS)
09641   // e.g., VxWorks (besides POWERPC && GreenHills) . . .
09642   ACE_UNUSED_ARG (op);
09643   struct timespec ts;
09644 
09645   ACE_OS::clock_gettime (CLOCK_REALTIME, &ts);
09646 
09647   // Carefully create the return value to avoid arithmetic overflow
09648   // if ACE_hrtime_t is ACE_U_LongLong.
09649   return ACE_static_cast (ACE_hrtime_t, ts.tv_sec) *
09650     ACE_U_ONE_SECOND_IN_NSECS  +  ACE_static_cast (ACE_hrtime_t, ts.tv_nsec);
09651 #else
09652   ACE_UNUSED_ARG (op);
09653   const ACE_Time_Value now = ACE_OS::gettimeofday ();
09654 
09655   // Carefully create the return value to avoid arithmetic overflow
09656   // if ACE_hrtime_t is ACE_U_LongLong.
09657   return (ACE_static_cast (ACE_hrtime_t, now.sec ()) * (ACE_UINT32) 1000000  +
09658           ACE_static_cast (ACE_hrtime_t, now.usec ())) * (ACE_UINT32) 1000;
09659 #endif /* ACE_HAS_HI_RES_TIMER */
09660 }

ACE_INLINE struct hostent * ACE_OS::getipnodebyaddr const void *    src,
size_t    len,
int    family
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4900 of file OS.i.

References gethostbyaddr.

04901 {
04902 #if defined (ACE_HAS_IPV6)
04903 #  if defined (__GLIBC__)
04904   ACE_UNUSED_ARG (src);
04905   ACE_UNUSED_ARG (len);
04906   ACE_UNUSED_ARG (family);
04907   ACE_NOTSUP_RETURN (0);
04908 #  else
04909   struct hostent *hptr;
04910   int errnum;
04911   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
04912     {
04913       errno = errnum;
04914     }
04915   return hptr;
04916 #  endif /* whatever_doesnt_have_getipnodebyname */
04917 #else
04918   // IPv4-only implementation
04919   if (family == AF_INET)
04920     return ACE_OS::gethostbyaddr (ACE_static_cast (const char *, src),
04921                                   ACE_static_cast (int, len),
04922                                   family);
04923 
04924   ACE_NOTSUP_RETURN (0);
04925 # endif /* ACE_PSOS */
04926 }

ACE_INLINE struct hostent * ACE_OS::getipnodebyname const char *    name,
int    family,
int    flags = 0
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4860 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and gethostbyname.

04861 {
04862   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
04863 # if defined (ACE_PSOS)
04864   ACE_UNUSED_ARG (name);
04865   ACE_UNUSED_ARG (family);
04866   ACE_UNUSED_ARG (flags);
04867   ACE_NOTSUP_RETURN (0);
04868 # elif defined (ACE_HAS_IPV6)
04869 #   if defined (__GLIBC__)
04870   ACE_UNUSED_ARG (flags);
04871 #     if defined (ACE_HAS_NONCONST_GETBY)
04872   ACE_SOCKCALL_RETURN (::gethostbyname2 (ACE_const_cast (char *, name),
04873                                          family),
04874                        struct hostent *, 0);
04875 #     else
04876   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
04877                        struct hostent *, 0);
04878 #     endif /* ACE_HAS_NONCONST_GETBY */
04879 #   else
04880   struct hostent *hptr;
04881   int errnum;
04882   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
04883     {
04884       errno = errnum;
04885     }
04886   return hptr;
04887 #   endif /* __GLIBC__ */
04888 # else
04889   // IPv4-only implementation
04890   ACE_UNUSED_ARG (flags);
04891   if (family == AF_INET)
04892     return ACE_OS::gethostbyname (name);
04893 
04894   ACE_NOTSUP_RETURN (0);
04895 # endif /* ACE_PSOS */
04896 }

ACE_INLINE int ACE_OS::getmsg ACE_HANDLE    handle,
struct strbuf   ctl,
struct strbuf   data,
int *    flags
[static]
 

Definition at line 8317 of file OS.i.

References ACE_OS_TRACE, and getmsg.

Referenced by getmsg, ACE_SPIPE_Stream::recv, and ACE_FIFO_Recv_Msg::recv.

08321 {
08322   ACE_OS_TRACE ("ACE_OS::getmsg");
08323 #if defined (ACE_HAS_STREAM_PIPES)
08324   ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1);
08325 #else
08326   ACE_UNUSED_ARG (handle);
08327   ACE_UNUSED_ARG (ctl);
08328   ACE_UNUSED_ARG (data);
08329   ACE_UNUSED_ARG (flags);
08330 
08331   // I'm not sure how to implement this correctly.
08332   ACE_NOTSUP_RETURN (-1);
08333 #endif /* ACE_HAS_STREAM_PIPES */
08334 }

ACE_INLINE int ACE_OS::getopt int    argc,
char *const *    argv,
const char *    optstring
[static]
 

Definition at line 363 of file OS.i.

References ACE_OS_TRACE, and getopt.

Referenced by getopt.

00364 {
00365   ACE_OS_TRACE ("ACE_OS::getopt");
00366 #if defined (VXWORKS) || defined (ACE_PSOS)
00367   ACE_UNUSED_ARG (argc);
00368   ACE_UNUSED_ARG (argv);
00369   ACE_UNUSED_ARG (optstring);
00370   ACE_NOTSUP_RETURN (-1);
00371 # elif defined (ACE_LACKS_GETOPT_PROTO)
00372   ACE_OSCALL_RETURN (::getopt (argc, (char**) argv, optstring), int, -1);
00373 # elif defined (ACE_LACKS_POSIX_PROTOTYPES)
00374   ACE_OSCALL_RETURN (::getopt (argc, (const char* const *) argv, optstring), int, -1);
00375 # else
00376   ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1);
00377 # endif /* VXWORKS */
00378 }

ACE_INLINE int ACE_OS::getpagesize void    [static]
 

Definition at line 9701 of file OS.i.

References ACE_OS_TRACE.

Referenced by allocation_granularity, ACE_WIN32_Asynch_Write_File_Result::complete, ACE_WIN32_Asynch_Read_File_Result::complete, ACE_WIN32_Asynch_Read_File::readv, ACE::round_to_pagesize, and ACE_WIN32_Asynch_Write_File::writev.

09702 {
09703   ACE_OS_TRACE ("ACE_OS::getpagesize");
09704 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
09705   SYSTEM_INFO sys_info;
09706   ::GetSystemInfo (&sys_info);
09707   return (int) sys_info.dwPageSize;
09708 #elif defined (_SC_PAGESIZE)
09709   return (int) ::sysconf (_SC_PAGESIZE);
09710 #elif defined (ACE_HAS_GETPAGESIZE)
09711   return ::getpagesize ();
09712 #else
09713   // Use the default set in config.h
09714   return ACE_PAGE_SIZE;
09715 #endif /* ACE_WIN32 */
09716 }

ACE_INLINE int ACE_OS::getpeername ACE_HANDLE    handle,
struct sockaddr *    addr,
int *    addrlen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5222 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and getpeername.

Referenced by ACE_SOCK_Connector::complete, ACE_ATM_Stream::get_peer_name, ACE_SOCK::get_remote_addr, getpeername, and ACE_Asynch_Connector::parse_address.

05224 {
05225   ACE_OS_TRACE ("ACE_OS::getpeername");
05226 #if defined (ACE_PSOS) && !defined ACE_PSOS_DIAB_PPC
05227   ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle,
05228                                       (struct sockaddr_in *) addr,
05229                                       (ACE_SOCKET_LEN *) addrlen),
05230                        int, -1);
05231 #else
05232   ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle,
05233                                       addr,
05234                                       (ACE_SOCKET_LEN *) addrlen),
05235                        int, -1);
05236 #endif /* defined (ACE_PSOS) */
05237 }

ACE_INLINE pid_t ACE_OS::getpgid pid_t    pid [static]
 

Definition at line 9747 of file OS.i.

References ACE_OS_TRACE, getpgid, and pid_t.

Referenced by getpgid.

09748 {
09749   ACE_OS_TRACE ("ACE_OS::getpgid");
09750 #if defined (ACE_LACKS_GETPGID)
09751   ACE_UNUSED_ARG (pid);
09752   ACE_NOTSUP_RETURN (-1);
09753 #elif defined (VXWORKS) || defined (ACE_PSOS)
09754   // getpgid() is not supported, only one process anyway.
09755   ACE_UNUSED_ARG (pid);
09756   return 0;
09757 #elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0
09758   // getpgid() is from SVR4, which appears to be the reason why GLIBC
09759   // doesn't enable its prototype by default.
09760   // Rather than create our own extern prototype, just use the one
09761   // that is visible (ugh).
09762   ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1);
09763 #else
09764   ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1);
09765 #endif /* ACE_WIN32 */
09766 }

ACE_INLINE pid_t ACE_OS::getpid void    [static]
 

Definition at line 9731 of file OS.i.

References getpid.

Referenced by ACE_TPQ_Entry::ACE_TPQ_Entry, ACE_IPC_SAP::enable, ACE_IO_SAP::enable, getpid, ACE_Log_Msg::getpid, ACE_SPIPE_Stream::recv_handle, ACE_Log_Msg::sync, and unique_name.

09732 {
09733   // ACE_OS_TRACE ("ACE_OS::getpid");
09734 #if defined (ACE_WIN32)
09735   return ::GetCurrentProcessId ();
09736 #elif defined (VXWORKS) || defined (ACE_PSOS)
09737   // getpid() is not supported:  just one process anyways
09738   return 0;
09739 #elif defined (CHORUS)
09740   return (pid_t) (::agetId ());
09741 #else
09742   ACE_OSCALL_RETURN (::getpid (), int, -1);
09743 #endif /* ACE_WIN32 */
09744 }

ACE_INLINE int ACE_OS::getpmsg ACE_HANDLE    handle,
struct strbuf   ctl,
struct strbuf   data,
int *    band,
int *    flags
[static]
 

Definition at line 8337 of file OS.i.

References ACE_OS_TRACE, and getpmsg.

Referenced by getpmsg, and ACE_SPIPE_Stream::recv.

08342 {
08343   ACE_OS_TRACE ("ACE_OS::getpmsg");
08344 #if defined (ACE_HAS_STREAM_PIPES)
08345   ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1);
08346 #else
08347   ACE_UNUSED_ARG (handle);
08348   ACE_UNUSED_ARG (ctl);
08349   ACE_UNUSED_ARG (data);
08350   ACE_UNUSED_ARG (band);
08351   ACE_UNUSED_ARG (flags);
08352 
08353   // I'm not sure how to implement this correctly.
08354   ACE_NOTSUP_RETURN (-1);
08355 #endif /* ACE_HAS_STREAM_PIPES */
08356 }

ACE_INLINE pid_t ACE_OS::getppid void    [static]
 

Definition at line 9769 of file OS.i.

References ACE_OS_TRACE, getppid, and pid_t.

Referenced by getppid, and ACE_Process::spawn.

09770 {
09771   ACE_OS_TRACE ("ACE_OS::getppid");
09772 #if defined (ACE_LACKS_GETPPID)
09773   ACE_NOTSUP_RETURN (-1);
09774 #elif defined (VXWORKS) || defined (ACE_PSOS)
09775   // getppid() is not supported, only one process anyway.
09776   return 0;
09777 #else
09778   ACE_OSCALL_RETURN (::getppid (), pid_t, -1);
09779 #endif /* ACE_LACKS_GETPPID */
09780 }

ACE_INLINE struct protoent * ACE_OS::getprotobyname const char *    name [static]
 

BSD-style <accept> (no QoS).

Definition at line 5240 of file OS.i.

References ACE_SOCKCALL_RETURN.

05241 {
05242 #if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS)
05243   ACE_UNUSED_ARG (name);
05244   ACE_NOTSUP_RETURN (0);
05245 #elif defined (ACE_HAS_NONCONST_GETBY)
05246   ACE_SOCKCALL_RETURN (::getprotobyname (ACE_const_cast (char *, name)),
05247                        struct protoent *,
05248                        0);
05249 #else
05250   ACE_SOCKCALL_RETURN (::getprotobyname (name),
05251                        struct protoent *,
05252                        0);
05253 #endif /* VXWORKS */
05254 }

ACE_INLINE struct protoent * ACE_OS::getprotobyname_r const char *    name,
struct protoent *    result,
ACE_PROTOENT_DATA    buffer
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5257 of file OS.i.

References ACE_PROTOENT_DATA, and ACE_SOCKCALL_RETURN.

05260 {
05261 #if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS)
05262   ACE_UNUSED_ARG (name);
05263   ACE_UNUSED_ARG (result);
05264   ACE_UNUSED_ARG (buffer);
05265   ACE_NOTSUP_RETURN (0);
05266 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
05267 # if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10)
05268   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
05269     return result;
05270   else
05271     return 0;
05272 # elif defined (__GLIBC__)
05273   // GNU C library has a different signature
05274   if (::getprotobyname_r (name,
05275                           result,
05276                           buffer,
05277                           sizeof (ACE_PROTOENT_DATA),
05278                           &result) == 0)
05279     return result;
05280   else
05281     return 0;
05282 # else
05283 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
05284   ACE_UNUSED_ARG (result);
05285   ACE_NETDBCALL_RETURN (::getprotobyname (name),
05286                         struct protoent *, 0,
05287                         buffer, sizeof (ACE_PROTOENT_DATA));
05288 #   else
05289     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
05290                                              result,
05291                                              buffer,
05292                                              sizeof (ACE_PROTOENT_DATA)),
05293                        struct protoent *, 0);
05294 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
05295 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
05296 #elif defined (ACE_HAS_NONCONST_GETBY)
05297   ACE_UNUSED_ARG (result);
05298   ACE_UNUSED_ARG (buffer);
05299   ACE_SOCKCALL_RETURN (::getprotobyname (ACE_const_cast (char *, name)),
05300                        struct protoent *, 0);
05301 #else
05302   ACE_UNUSED_ARG (buffer);
05303   ACE_UNUSED_ARG (result);
05304 
05305   ACE_SOCKCALL_RETURN (::getprotobyname (name),
05306                        struct protoent *,
05307                        0);
05308 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
05309 }

ACE_INLINE struct protoent * ACE_OS::getprotobynumber int    proto [static]
 

BSD-style <accept> (no QoS).

Definition at line 5312 of file OS.i.

References ACE_SOCKCALL_RETURN.

05313 {
05314 #if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS)
05315   ACE_UNUSED_ARG (proto);
05316   ACE_NOTSUP_RETURN (0);
05317 #else
05318   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
05319                        struct protoent *, 0);
05320 #endif /* VXWORKS */
05321 }

ACE_INLINE struct protoent * ACE_OS::getprotobynumber_r int    proto,
struct protoent *    result,
ACE_PROTOENT_DATA    buffer
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5324 of file OS.i.

References ACE_PROTOENT_DATA, and ACE_SOCKCALL_RETURN.

05327 {
05328 #if defined (VXWORKS) || defined (ACE_HAS_WINCE) || (defined (ghs) && defined (__Chorus)) || defined (ACE_PSOS)
05329   ACE_UNUSED_ARG (proto);
05330   ACE_UNUSED_ARG (result);
05331   ACE_UNUSED_ARG (buffer);
05332   ACE_NOTSUP_RETURN (0);
05333 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
05334 # if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10)
05335   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
05336     return result;
05337   else
05338     return 0;
05339 # elif defined (__GLIBC__)
05340   // GNU C library has a different signature
05341   if (::getprotobynumber_r (proto,
05342                             result,
05343                             buffer,
05344                             sizeof (ACE_PROTOENT_DATA),
05345                             &result) == 0)
05346     return result;
05347   else
05348     return 0;
05349 # else
05350 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
05351   ACE_UNUSED_ARG (result);
05352   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
05353                         struct protoent *, 0,
05354                         buffer, sizeof (ACE_PROTOENT_DATA));
05355 #   else
05356   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
05357                        struct protoent *, 0);
05358 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
05359 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
05360 #else
05361   ACE_UNUSED_ARG (buffer);
05362   ACE_UNUSED_ARG (result);
05363 
05364   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
05365                        struct protoent *, 0);
05366 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
05367 }

ACE_INLINE struct passwd * ACE_OS::getpwent void    [static]
 

Definition at line 5831 of file OS.i.

05832 {
05833 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
05834 # if !defined (ACE_WIN32)
05835   return ::getpwent ();
05836 # else
05837   ACE_NOTSUP_RETURN (0);
05838 # endif /* ACE_WIN32 */
05839 #else
05840   ACE_NOTSUP_RETURN (0);
05841 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
05842 }

ACE_INLINE struct passwd * ACE_OS::getpwnam const char *    user [static]
 

Definition at line 5791 of file OS.i.

05792 {
05793 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
05794 # if !defined (ACE_WIN32)
05795   return ::getpwnam (name);
05796 # else
05797   ACE_UNUSED_ARG (name);
05798   ACE_NOTSUP_RETURN (0);
05799 # endif /* ACE_WIN32 */
05800 #else
05801   ACE_UNUSED_ARG (name);
05802   ACE_NOTSUP_RETURN (0);
05803 #endif /* ACE_LACKS_PWD_FUNCTIONS */
05804 }

ACE_INLINE struct passwd * ACE_OS::getpwnam_r const char *    name,
struct passwd *    pwent,
char *    buffer,
int    buflen
[static]
 

Definition at line 5845 of file OS.i.

05847 {
05848 #if defined (ACE_HAS_POSIX_GETPWNAM_R)
05849   struct passwd *result;
05850   int status;
05851 
05852   status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
05853 
05854   if (status != 0)
05855   {
05856     errno = status;
05857     result = 0;
05858   }
05859   return result;
05860 #elif !defined (ACE_LACKS_PWD_FUNCTIONS)
05861 # if defined (ACE_HAS_REENTRANT_FUNCTIONS)
05862 #   if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS)
05863 #     if defined (ACE_HAS_PTHREADS_STD) && \
05864       !defined (ACE_HAS_STHREADS) || \
05865       defined (HPUX_11)  || \
05866       defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7.
05867   struct passwd *result;
05868   int status;
05869 #       if defined (DIGITAL_UNIX)
05870   ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result);
05871 #       else
05872   // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined
05873   // in pwd.h, and that redefinition is used here
05874 #         if defined (__IBMCPP__) && (__IBMCPP__ >= 400)   /* VAC++ 4 */
05875   status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result);
05876 #         else
05877   status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
05878 #         endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */
05879   if (status != 0)
05880     {
05881       errno = status;
05882       result = 0;
05883     }
05884 #       endif /* (DIGITAL_UNIX) */
05885   return result;
05886 #     elif defined (AIX) || defined (HPUX_10)
05887   if (::getpwnam_r (name, pwent, buffer, buflen) == -1)
05888     return 0;
05889   else
05890     return pwent;
05891 #     else
05892   return ::getpwnam_r (name, pwent, buffer, buflen);
05893 #     endif /* ACE_HAS_PTHREADS_STD */
05894 #   else
05895   ACE_UNUSED_ARG (name);
05896   ACE_UNUSED_ARG (pwent);
05897   ACE_UNUSED_ARG (buffer);
05898   ACE_UNUSED_ARG (buflen);
05899   ACE_NOTSUP_RETURN (0);
05900 #   endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */
05901 # else
05902   ACE_UNUSED_ARG (name);
05903   ACE_UNUSED_ARG (pwent);
05904   ACE_UNUSED_ARG (buffer);
05905   ACE_UNUSED_ARG (buflen);
05906   ACE_NOTSUP_RETURN (0);
05907 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
05908 #else
05909   ACE_UNUSED_ARG (name);
05910   ACE_UNUSED_ARG (pwent);
05911   ACE_UNUSED_ARG (buffer);
05912   ACE_UNUSED_ARG (buflen);
05913   ACE_NOTSUP_RETURN (0);
05914 #endif /* ACE_HAS_POSIX_GETPWNAM_R */
05915 }

ACE_INLINE int ACE_OS::getrlimit int    resource,
struct rlimit *    rl
[static]
 

Definition at line 9418 of file OS.i.

References ACE_OS_TRACE, and getrlimit.

Referenced by getrlimit, ACE::max_handles, and ACE::set_handle_limit.

09419 {
09420   ACE_OS_TRACE ("ACE_OS::getrlimit");
09421 
09422 #if defined (ACE_LACKS_RLIMIT)
09423   ACE_UNUSED_ARG (resource);
09424   ACE_UNUSED_ARG (rl);
09425 
09426   ACE_NOTSUP_RETURN (-1);
09427 #else
09428 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
09429   ACE_OSCALL_RETURN (::getrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1);
09430 # else
09431   ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1);
09432 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
09433 #endif /* ACE_LACKS_RLIMIT */
09434 }

ACE_INLINE int ACE_OS::getrusage int    who,
struct rusage   rusage
[static]
 

Definition at line 8359 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, getrusage, rusage::ru_stime, and rusage::ru_utime.

Referenced by getrusage.

08360 {
08361   ACE_OS_TRACE ("ACE_OS::getrusage");
08362 
08363 #if defined (ACE_HAS_SYSCALL_GETRUSAGE)
08364   // This nonsense is necessary for HP/UX...
08365   ACE_OSCALL_RETURN (::syscall (SYS_GETRUSAGE, who, ru), int, -1);
08366 #elif defined (ACE_HAS_GETRUSAGE)
08367 # if defined (ACE_WIN32)
08368   ACE_UNUSED_ARG (who);
08369 
08370   FILETIME dummy_1;
08371   FILETIME dummy_2;
08372   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetProcessTimes (::GetCurrentProcess(),
08373                                                              &dummy_1,   // start
08374                                                              &dummy_2,     // exited
08375                                                              &ru->ru_stime,
08376                                                              &ru->ru_utime),
08377                                           ace_result_),
08378                         int, -1);
08379 # else
08380 #   if defined (ACE_HAS_RUSAGE_WHO_ENUM)
08381   ACE_OSCALL_RETURN (::getrusage ((ACE_HAS_RUSAGE_WHO_ENUM) who, ru), int, -1);
08382 #   else
08383   ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1);
08384 #   endif /* ACE_HAS_RUSAGE_WHO_ENUM */
08385 # endif /* ACE_WIN32 */
08386 #else
08387   who = who;
08388   ru = ru;
08389   ACE_NOTSUP_RETURN (-1);
08390 #endif /* ACE_HAS_SYSCALL_GETRUSAGE */
08391 }

char * ACE_OS::gets char *    str,
int    n = 0
[static]
 

Definition at line 1196 of file OS.cpp.

References ACE_OS_TRACE.

01197 {
01198   ACE_OS_TRACE ("ACE_OS::gets");
01199   int c;
01200   char *s = str;
01201 
01202   if (str == 0 || n < 0) n = 0;
01203   if (n == 0) str = 0;
01204   else n--;
01205 
01206   while ((c = getchar ()) != '\n')
01207     {
01208 
01209       if (c == EOF && errno == EINTR)
01210         {
01211 #   if defined (ACE_HAS_SIGNAL_SAFE_OS_CALLS)
01212           continue;
01213 #   else
01214           break;
01215 #   endif /* ACE_HAS_SIGNAL_SAFE_OS_CALLS */
01216         }
01217 
01218       if (c == EOF)
01219         break;
01220 
01221       if (n > 0)
01222         n--, *s++ = c;
01223     }
01224   if (s) *s = '\0';
01225 
01226   return (c == EOF) ? 0 : str;
01227 }

ACE_INLINE struct servent * ACE_OS::getservbyname const char *    svc,
const char *    proto
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5370 of file OS.i.

References ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

05371 {
05372   ACE_OS_TRACE ("ACE_OS::getservbyname");
05373 #if defined (ACE_LACKS_GETSERVBYNAME)
05374   ACE_UNUSED_ARG (svc);
05375   ACE_UNUSED_ARG (proto);
05376   ACE_NOTSUP_RETURN (0);
05377 #elif defined (ACE_HAS_NONCONST_GETBY)
05378   ACE_SOCKCALL_RETURN (::getservbyname (ACE_const_cast (char *, svc),
05379                                         ACE_const_cast (char *, proto)),
05380                        struct servent *,
05381                        0);
05382 #else
05383   ACE_SOCKCALL_RETURN (::getservbyname (svc,
05384                                         proto),
05385                        struct servent *,
05386                        0);
05387 #endif /* ACE_HAS_NONCONST_GETBY */
05388 }

ACE_INLINE struct servent * ACE_OS::getservbyname_r const char *    svc,
const char *    proto,
struct servent *    result,
ACE_SERVENT_DATA    buf
[static]
 

BSD-style <accept> (no QoS).

Definition at line 6094 of file OS.i.

References ACE_OS_TRACE, ACE_SERVENT_DATA, and ACE_SOCKCALL_RETURN.

Referenced by ACE_INET_Addr::set.

06098 {
06099   ACE_OS_TRACE ("ACE_OS::getservbyname_r");
06100 #if defined (ACE_LACKS_GETSERVBYNAME)
06101   ACE_UNUSED_ARG (svc);
06102   ACE_UNUSED_ARG (proto);
06103   ACE_UNUSED_ARG (result);
06104   ACE_UNUSED_ARG (buf);
06105   ACE_NOTSUP_RETURN (0);
06106 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
06107 # if defined (AIX) || defined (DIGITAL_UNIX) || defined (HPUX_10)
06108   ::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
06109 
06110   if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0)
06111     return result;
06112   else
06113     return (struct servent *) 0;
06114 # elif defined (__GLIBC__)
06115   // GNU C library has a different signature
06116   ::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
06117 
06118   if (::getservbyname_r (svc,
06119                          proto,
06120                          result,
06121                          buf,
06122                          sizeof (ACE_SERVENT_DATA),
06123                          &result) == 0)
06124     return result;
06125   else
06126     return (struct servent *) 0;
06127 # else
06128 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
06129   ACE_UNUSED_ARG (result);
06130   ACE_NETDBCALL_RETURN (::getservbyname (svc, proto),
06131                         struct servent *, 0,
06132                         buf, sizeof (ACE_SERVENT_DATA));
06133 #   else
06134   ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf,
06135                                           sizeof (ACE_SERVENT_DATA)),
06136                        struct servent *, 0);
06137 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
06138 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
06139 #elif defined (ACE_HAS_NONCONST_GETBY)
06140   ACE_UNUSED_ARG (buf);
06141   ACE_UNUSED_ARG (result);
06142   ACE_SOCKCALL_RETURN (::getservbyname (ACE_const_cast (char *, svc),
06143                                         ACE_const_cast (char *, proto)),
06144                        struct servent *,
06145                        0);
06146 #else
06147   ACE_UNUSED_ARG (buf);
06148   ACE_UNUSED_ARG (result);
06149 
06150   ACE_SOCKCALL_RETURN (::getservbyname (svc,
06151                                         proto),
06152                        struct servent *,
06153                        0);
06154 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
06155 }

ACE_INLINE int ACE_OS::getsockname ACE_HANDLE    handle,
struct sockaddr *    addr,
int *    addrlen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5391 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and getsockname.

Referenced by ACE_SOCK::get_local_addr, ACE_ATM_Acceptor::get_local_addr, getsockname, and ACE_Asynch_Connector::parse_address.

05394 {
05395   ACE_OS_TRACE ("ACE_OS::getsockname");
05396 #if defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC)
05397   ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle,
05398                                       (struct sockaddr_in *) addr,
05399                                       (ACE_SOCKET_LEN *) addrlen),
05400                        int, -1);
05401 #else
05402   ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle,
05403                                       addr,
05404                                       (ACE_SOCKET_LEN *) addrlen),
05405                        int, -1);
05406 #endif /* defined (ACE_PSOS) */
05407 }

ACE_INLINE int ACE_OS::getsockopt ACE_HANDLE    handle,
int    level,
int    optname,
char *    optval,
int *    optlen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5410 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and getsockopt.

Referenced by ACE_SOCK::get_option, ACE_ATM_Stream::get_vpi_vci, getsockopt, ACE_WIN32_Asynch_Connect::handle_output, ACE_POSIX_Asynch_Connect::handle_output, and ACE::handle_timed_complete.

05415 {
05416   ACE_OS_TRACE ("ACE_OS::getsockopt");
05417   ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle,
05418                                      level,
05419                                      optname,
05420                                      optval,
05421                                      (ACE_SOCKET_LEN *) optlen),
05422                        int,
05423                        -1);
05424 }

ACE_INLINE ACE_Time_Value ACE_OS::gettimeofday void    [static]
 

Definition at line 616 of file OS.i.

References clock_gettime, CLOCK_REALTIME, gettimeofday, timespec::tv_nsec, and timespec::tv_sec.

Referenced by ACE_SPIPE_Acceptor::accept, ACE_Buffered_Svc_Handler::ACE_Buffered_Svc_Handler, ACE_Timer_Hash_T::ACE_Timer_Hash_T, ACE_TP_Token_Guard::acquire_token, ACE_High_Res_Timer::calibrate, cond_timedwait, ACE_SPIPE_Connector::connect, ACE_Dynamic_Message_Queue::dequeue_head, ACE_Dynamic_Message_Queue::enqueue_i, event_timedwait, gethrtime, ACE_High_Res_Timer::gettime, gettimeofday, ACE_High_Res_Timer::gettimeofday, ACE_TP_Token_Guard::grab_token, ACE_Log_Msg::log, mutex_lock, ACE_Timer_Wheel_T::open_i, ACE_Buffered_Svc_Handler::put, ACE::recv, ACE::recvfrom, ACE::recvmsg, ACE::recvv, ACE_Dynamic_Message_Queue::remove_messages, ACE_Async_Timer_Queue_Adapter::schedule_ualarm, sema_wait, ACE::send, ACE::sendmsg, ACE::sendto, ACE::sendv, ACE_Countdown_Time::start, ACE_Countdown_Time::stop, time, ACE::timestamp, ACE_Date_Time::update, ACE_Process_Manager::wait, and ACE_NT_Service::wait_for_service_state.

00617 {
00618   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
00619 
00620 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00621   timeval tv;
00622   int result = 0;
00623 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00624 
00625 #if (0)
00626   struct timespec ts;
00627 
00628   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00629   tv.tv_sec = ts.tv_sec;
00630   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00631 
00632 #elif defined (ACE_HAS_WINCE)
00633   SYSTEMTIME tsys;
00634   FILETIME   tfile;
00635   ::GetSystemTime (&tsys);
00636   ::SystemTimeToFileTime (&tsys, &tfile);
00637   return ACE_Time_Value (tfile);
00638 #elif defined (ACE_WIN32)
00639   FILETIME   tfile;
00640   ::GetSystemTimeAsFileTime (&tfile);
00641   return ACE_Time_Value (tfile);
00642 #if 0
00643   // From Todd Montgomery...
00644   struct _timeb tb;
00645   ::_ftime (&tb);
00646   tv.tv_sec = tb.time;
00647   tv.tv_usec = 1000 * tb.millitm;
00648 #endif /* 0 */
00649 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00650   timebasestruct_t tb;
00651 
00652   ::read_real_time (&tb, TIMEBASE_SZ);
00653   ::time_base_to_time (&tb, TIMEBASE_SZ);
00654 
00655   tv.tv_sec = tb.tb_high;
00656   tv.tv_usec = tb.tb_low / 1000L;
00657 #else
00658 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00659   (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (m88k) && !defined (SCO))
00660   ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00661 # elif defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS)
00662   // Assumes that struct timespec is same size as struct timeval,
00663   // which assumes that time_t is a long: it currently (VxWorks
00664   // 5.2/5.3) is.
00665   struct timespec ts;
00666 
00667   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00668   tv.tv_sec = ts.tv_sec;
00669   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00670 # else
00671   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00672 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
00673 #endif /* 0 */
00674 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00675   if (result == -1)
00676     return -1;
00677   else
00678     return ACE_Time_Value (tv);
00679 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00680 }

ACE_Time_Value ACE_OS::gettimeofday_i void    [static, private]
 

ACE_INLINE uid_t ACE_OS::getuid void    [static]
 

Definition at line 10938 of file OS.i.

References ACE_OS_TRACE, getuid, and uid_t.

Referenced by getuid, and ACE_SPIPE_Addr::set.

10939 {
10940   ACE_OS_TRACE ("ACE_OS::getuid");
10941 #if defined (VXWORKS) || defined (ACE_PSOS)
10942   // getuid() is not supported:  just one user anyways
10943   return 0;
10944 # elif defined (ACE_WIN32) || defined (CHORUS)
10945   ACE_NOTSUP_RETURN (ACE_static_cast (uid_t, -1));
10946 # else
10947   ACE_OSCALL_RETURN (::getuid (), uid_t, (uid_t) -1);
10948 # endif /* VXWORKS || ACE_PSOS */
10949 }

ACE_INLINE struct tm * ACE_OS::gmtime const time_t *    clock [static]
 

Definition at line 8771 of file OS.i.

References ACE_OS_TRACE.

08772 {
08773 #if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
08774   ACE_OS_TRACE ("ACE_OS::gmtime");
08775   ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
08776 #else
08777   // @@ WinCE doesn't have gmtime also.
08778   ACE_UNUSED_ARG (t);
08779   ACE_NOTSUP_RETURN (0);
08780 #endif /* ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */
08781 }

ACE_INLINE struct tm * ACE_OS::gmtime_r const time_t *    clock,
struct tm *    res
[static]
 

Definition at line 8784 of file OS.i.

References ACE_OS_TRACE.

08785 {
08786   ACE_OS_TRACE ("ACE_OS::gmtime_r");
08787 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
08788 # if defined (DIGITAL_UNIX)
08789   ACE_OSCALL_RETURN (::_Pgmtime_r (t, res), struct tm *, 0);
08790 # elif defined (HPUX_10)
08791   return (::gmtime_r (t, res) == 0 ? res : (struct tm *) 0);
08792 # else
08793   ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0);
08794 # endif /* DIGITAL_UNIX */
08795 #elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
08796   struct tm *result;
08797   ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ;
08798   if (result != 0)
08799     *res = *result;
08800   return res;
08801 #else
08802   // @@ Same as ACE_OS::gmtime (), you need to implement it
08803   //    yourself.
08804   ACE_UNUSED_ARG (t);
08805   ACE_UNUSED_ARG (res);
08806   ACE_NOTSUP_RETURN (0);
08807 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
08808 }

int ACE_OS::hostname wchar_t *    name,
size_t    maxnamelen
[static]
 

int ACE_OS::hostname char *    name,
size_t    maxnamelen
[static]
 

Referenced by ACE_TPQ_Entry::ACE_TPQ_Entry, ACE_INET_Addr::get_host_name_i, ACE_MEM_Addr::initialize_local, ACE_Predefined_Naming_Contexts::is_local_host, ACE_Naming_Context::open, and uname.

ACE_INLINE unsigned long ACE_OS::inet_addr const char *    name [static]
 

BSD-style <accept> (no QoS).

Definition at line 6158 of file OS.i.

References ACE_OS_TRACE, and INADDR_NONE.

Referenced by inet_aton.

06159 {
06160   ACE_OS_TRACE ("ACE_OS::inet_addr");
06161 #if defined (VXWORKS) || defined (ACE_PSOS)
06162 
06163   u_long ret = 0;
06164   u_int segment;
06165   u_int valid = 1;
06166 
06167   for (u_int i = 0; i < 4; ++i)
06168     {
06169       ret <<= 8;
06170       if (*name != '\0')
06171         {
06172           segment = 0;
06173 
06174           while (*name >= '0'  &&  *name <= '9')
06175             {
06176               segment *= 10;
06177               segment += *name++ - '0';
06178             }
06179           if (*name != '.' && *name != '\0')
06180             {
06181               valid = 0;
06182               break;
06183             }
06184 
06185           ret |= segment;
06186 
06187           if (*name == '.')
06188             {
06189               ++name;
06190             }
06191         }
06192     }
06193   return valid ? htonl (ret) : INADDR_NONE;
06194 #elif defined (ACE_HAS_NONCONST_GETBY)
06195   return ::inet_addr ((char *) name);
06196 #else
06197   return ::inet_addr (name);
06198 #endif /* ACE_HAS_NONCONST_GETBY */
06199 }

int ACE_OS::inet_aton const char *    strptr,
struct in_addr *    addr
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4826 of file OS.cpp.

References INADDR_NONE, inet_addr, inet_aton, and ACE_OS_String::strcmp.

Referenced by inet_aton, inet_pton, and ACE_INET_Addr::set.

04827 {
04828 #if defined (ACE_LACKS_INET_ATON)
04829   ACE_UINT32 ip_addr = ACE_OS::inet_addr (host_name);
04830 
04831   if (ip_addr == INADDR_NONE
04832       // Broadcast addresses are weird...
04833       && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
04834     return 0;
04835   else if (addr == 0)
04836     return 0;
04837   else
04838     {
04839       addr->s_addr = ip_addr;  // Network byte ordered
04840       return 1;
04841     }
04842 #elif defined (VXWORKS)
04843   // inet_aton() must returns 0 upon failure and 1 on failure, but
04844   // VxWorks inet_aton() returns OK (0) on success and ERROR (-1) on failure
04845   // like most other systems calls.  We will align here.
04846   if ( host_name && addr )
04847     {
04848       // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
04849       errnoSet(0);
04850       return ::inet_aton((char*)host_name,addr) ? 0 : 1;
04851     }
04852   return 0;
04853 #else
04854   // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
04855   // address (255.255.255.255).
04856   ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
04857 #endif  /* ACE_LACKS_INET_ATON */
04858 }

ACE_INLINE char * ACE_OS::inet_ntoa const struct in_addr    addr [static]
 

BSD-style <accept> (no QoS).

Definition at line 6204 of file OS.i.

References ACE_OS_TRACE, and inet_ntoa.

Referenced by ACE_INET_Addr::get_host_addr, and inet_ntoa.

06205 {
06206   ACE_OS_TRACE ("ACE_OS::inet_ntoa");
06207   ACE_OSCALL_RETURN (::inet_ntoa (addr),
06208                      char *,
06209                      0);
06210 }

ACE_INLINE const char * ACE_OS::inet_ntop int    family,
const void *    addrptr,
char *    strptr,
size_t    len
[static]
 

BSD-style <accept> (no QoS).

Definition at line 6239 of file OS.i.

References ACE_OS_TRACE, INET_ADDRSTRLEN, inet_ntop, sprintf, ACE_OS_String::strcpy, and ACE_OS_String::strlen.

Referenced by ACE_INET_Addr::get_host_addr, and inet_ntop.

06240 {
06241   ACE_OS_TRACE ("ACE_OS::inet_ntop");
06242 
06243 #if defined (ACE_HAS_IPV6)
06244   ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0);
06245 #else
06246   const u_char *p =
06247     ACE_reinterpret_cast (const u_char *, addrptr);
06248 
06249   if (family == AF_INET)
06250     {
06251       char temp[INET_ADDRSTRLEN];
06252 
06253       // Stevens uses snprintf() in his implementation but snprintf()
06254       // doesn't appear to be very portable.  For now, hope that using
06255       // sprintf() will not cause any string/memory overrun problems.
06256       ACE_OS::sprintf (temp,
06257                        "%d.%d.%d.%d",
06258                        p[0], p[1], p[2], p[3]);
06259 
06260       if (ACE_OS::strlen (temp) >= len)
06261         {
06262           errno = ENOSPC;
06263           return 0; // Failure
06264         }
06265 
06266       ACE_OS::strcpy (strptr, temp);
06267       return strptr;
06268     }
06269 
06270   ACE_NOTSUP_RETURN(0);
06271 #endif /* ACE_HAS_IPV6 */
06272 }

ACE_INLINE int ACE_OS::inet_pton int    family,
const char *    strptr,
void *    addrptr
[static]
 

BSD-style <accept> (no QoS).

Definition at line 6214 of file OS.i.

References ACE_OS_TRACE, inet_aton, inet_pton, and ACE_OS_String::memcpy.

Referenced by inet_pton.

06215 {
06216   ACE_OS_TRACE ("ACE_OS::inet_pton");
06217 
06218 #if defined (ACE_HAS_IPV6)
06219   ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1);
06220 #else
06221   if (family == AF_INET)
06222     {
06223       struct in_addr in_val;
06224 
06225       if (ACE_OS::inet_aton (strptr, &in_val))
06226         {
06227           ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr));
06228           return 1; // Success
06229         }
06230 
06231       return 0; // Input is not a valid presentation format
06232     }
06233 
06234   ACE_NOTSUP_RETURN(-1);
06235 #endif  /* ACE_HAS_IPV6 */
06236 }

int ACE_OS::ioctl ACE_HANDLE    socket,
u_long    io_control_code,
ACE_QoS   ace_qos,
u_long *    bytes_returned,
void *    buffer_p = 0,
u_long    buffer = 0,
ACE_OVERLAPPED   overlapped = 0,
ACE_OVERLAPPED_COMPLETION_FUNC    func = 0
[static]
 

QoS-enabled <ioctl> when the I/O control code is either SIO_SET_QOS or SIO_GET_QOS.

Definition at line 7507 of file OS.cpp.

References ACE_NEW_RETURN, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_SOCKCALL_RETURN, iovec::iov_len, ACE_QoS::provider_specific, ACE_QoS::receiving_flowspec, ACE_QoS::sending_flowspec, and socket.

07515 {
07516 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
07517 
07518   QOS qos;
07519   u_long qos_len = sizeof (QOS);
07520 
07521   if (io_control_code == SIO_SET_QOS)
07522     {
07523       qos.SendingFlowspec = *(ace_qos.sending_flowspec ());
07524       qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ());
07525       qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific ();
07526 
07527       qos_len += ace_qos.provider_specific ().iov_len;
07528 
07529       ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
07530                                        io_control_code,
07531                                        &qos,
07532                                        qos_len,
07533                                        buffer_p,
07534                                        buffer,
07535                                        bytes_returned,
07536                                        (WSAOVERLAPPED *) overlapped,
07537                                        func),
07538                            int,
07539                            SOCKET_ERROR);
07540     }
07541   else
07542     {
07543       u_long dwBufferLen = 0;
07544 
07545       // Query for the buffer size.
07546       int result = ::WSAIoctl ((ACE_SOCKET) socket,
07547                                 io_control_code,
07548                                 NULL,
07549                                 0,
07550                                 &dwBufferLen,
07551                                 sizeof (dwBufferLen),
07552                                 bytes_returned,
07553                                 NULL,
07554                                 NULL);
07555 
07556 
07557       if (result == SOCKET_ERROR)
07558           {
07559                 u_long dwErr = ::WSAGetLastError ();
07560 
07561                 if (dwErr == WSAEWOULDBLOCK)
07562                 {
07563                         errno = dwErr;
07564                         return -1;
07565                 }
07566                 else
07567                         if (dwErr != WSAENOBUFS)
07568                         {
07569                                 errno = dwErr;
07570                                 return -1;
07571                         }
07572           }
07573 
07574     char *qos_buf;
07575         ACE_NEW_RETURN (qos_buf,
07576                                         char [dwBufferLen],
07577                                         -1);
07578 
07579         QOS *qos = ACE_reinterpret_cast (QOS*,
07580                                                                          qos_buf);
07581 
07582         result = ::WSAIoctl ((ACE_SOCKET) socket,
07583                                    io_control_code,
07584                        NULL,
07585                        0,
07586                        qos,
07587                        dwBufferLen,
07588                        bytes_returned,
07589                        NULL,
07590                        NULL);
07591 
07592     if (result == SOCKET_ERROR)
07593                 return result;
07594 
07595     ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate,
07596                                     qos->SendingFlowspec.TokenBucketSize,
07597                                     qos->SendingFlowspec.PeakBandwidth,
07598                                     qos->SendingFlowspec.Latency,
07599                                     qos->SendingFlowspec.DelayVariation,
07600 #  if defined(ACE_HAS_WINSOCK2_GQOS)
07601                                     qos->SendingFlowspec.ServiceType,
07602                                     qos->SendingFlowspec.MaxSduSize,
07603                                     qos->SendingFlowspec.MinimumPolicedSize,
07604 #  else /* ACE_HAS_WINSOCK2_GQOS */
07605                                     0,
07606                                     0,
07607                                     0,
07608 #  endif /* ACE_HAS_WINSOCK2_GQOS */
07609                                     0,
07610                                     0);
07611 
07612     ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate,
07613                                       qos->ReceivingFlowspec.TokenBucketSize,
07614                                       qos->ReceivingFlowspec.PeakBandwidth,
07615                                       qos->ReceivingFlowspec.Latency,
07616                                       qos->ReceivingFlowspec.DelayVariation,
07617 #  if defined(ACE_HAS_WINSOCK2_GQOS)
07618                                       qos->ReceivingFlowspec.ServiceType,
07619                                       qos->ReceivingFlowspec.MaxSduSize,
07620                                       qos->ReceivingFlowspec.MinimumPolicedSize,
07621 #  else /* ACE_HAS_WINSOCK2_GQOS */
07622                                       0,
07623                                       0,
07624                                       0,
07625 #  endif /* ACE_HAS_WINSOCK2_GQOS */
07626                                       0,
07627                                       0);
07628 
07629        ace_qos.sending_flowspec (&sending_flowspec);
07630        ace_qos.receiving_flowspec (&receiving_flowspec);
07631        ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific)));
07632 
07633 
07634       return result;
07635     }
07636 
07637 # else
07638   ACE_UNUSED_ARG (socket);
07639   ACE_UNUSED_ARG (io_control_code);
07640   ACE_UNUSED_ARG (ace_qos);
07641   ACE_UNUSED_ARG (bytes_returned);
07642   ACE_UNUSED_ARG (buffer_p);
07643   ACE_UNUSED_ARG (buffer);
07644   ACE_UNUSED_ARG (overlapped);
07645   ACE_UNUSED_ARG (func);
07646   ACE_NOTSUP_RETURN (-1);
07647 # endif /* ACE_HAS_WINSOCK2 */
07648 }

int ACE_OS::ioctl ACE_HANDLE    socket,
u_long    io_control_code,
void *    in_buffer_p,
u_long    in_buffer,
void *    out_buffer_p,
u_long    out_buffer,
u_long *    bytes_returned,
ACE_OVERLAPPED   overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC    func
[static]
 

QoS-enabled <ioctl>.

Definition at line 7469 of file OS.cpp.

References ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_SOCKCALL_RETURN, and socket.

07478 {
07479 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
07480   ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
07481                                    io_control_code,
07482                                    in_buffer_p,
07483                                    in_buffer,
07484                                    out_buffer_p,
07485                                    out_buffer,
07486                                    bytes_returned,
07487                                    (WSAOVERLAPPED *) overlapped,
07488                                    func),
07489                        int,
07490                        SOCKET_ERROR);
07491 # else
07492   ACE_UNUSED_ARG (socket);
07493   ACE_UNUSED_ARG (io_control_code);
07494   ACE_UNUSED_ARG (in_buffer_p);
07495   ACE_UNUSED_ARG (in_buffer);
07496   ACE_UNUSED_ARG (out_buffer_p);
07497   ACE_UNUSED_ARG (out_buffer);
07498   ACE_UNUSED_ARG (bytes_returned);
07499   ACE_UNUSED_ARG (overlapped);
07500   ACE_UNUSED_ARG (func);
07501   ACE_NOTSUP_RETURN (-1);
07502 # endif /* ACE_HAS_WINSOCK2 */
07503 }

ACE_INLINE int ACE_OS::ioctl ACE_HANDLE    handle,
int    cmd,
void *    = 0
[static]
 

UNIX-style <ioctl>.

Definition at line 10109 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ioctl.

Referenced by ACE_SPIPE_Acceptor::accept, ACE_Dev_Poll_Reactor::close, ACE_Flag_Manip::clr_flags, ACE_TLI_Connector::complete, ACE_TLI_Connector::connect, ACE_IPC_SAP::control, ACE_IO_SAP::control, ACE_Sock_Connect::count_interfaces, ACE_SPIPE_Acceptor::create_new_instance, ACE_IPC_SAP::disable, ACE_IPC_SAP::enable, ACE_Sock_Connect::get_bcast_addr, ACE_Sock_Connect::get_ip_interfaces, ACE_TLI::get_local_addr, ACE_TLI_Stream::get_remote_addr, ioctl, ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr, ACE_SOCK_Dgram_Bcast::mk_broadcast, ACE_Pipe::open, ACE_Dev_Poll_Reactor::open, ACE_ATM_Acceptor::open, open_new_endpoint, ACE_SOCK_Dgram::recv, ACE_SPIPE_Stream::recv_handle, ACE_SOCK_IO::recvv, ACE_SPIPE_Stream::send_handle, ACE_Flag_Manip::set_flags, ACE_SOCK_Dgram::set_nic, and ACE_Dev_Poll_Reactor::work_pending_i.

10112 {
10113   ACE_OS_TRACE ("ACE_OS::ioctl");
10114 
10115 #if defined (ACE_WIN32)
10116   ACE_SOCKET sock = (ACE_SOCKET) handle;
10117   ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, (u_long *) val), int, -1);
10118 #elif defined (VXWORKS)
10119   ACE_OSCALL_RETURN (::ioctl (handle, cmd, ACE_reinterpret_cast (int, val)),
10120                      int, -1);
10121 #elif defined (ACE_PSOS)
10122   ACE_OSCALL_RETURN (::ioctl (handle, cmd, (char *) val), int, -1);
10123 #elif defined (__CYGWIN32__)
10124   ACE_UNUSED_ARG (handle);
10125    ACE_UNUSED_ARG (cmd);
10126    ACE_UNUSED_ARG (val);
10127    ACE_NOTSUP_RETURN (-1);
10128 #else
10129   ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
10130 #endif /* ACE_WIN32 */
10131 }

ACE_INLINE int ACE_OS::isastream ACE_HANDLE    handle [static]
 

Definition at line 8394 of file OS.i.

References ACE_OS_TRACE, and isastream.

Referenced by ACE_UPIPE_Connector::connect, and isastream.

08395 {
08396   ACE_OS_TRACE ("ACE_OS::isastream");
08397 #if defined (ACE_HAS_STREAM_PIPES)
08398   ACE_OSCALL_RETURN (::isastream (handle), int, -1);
08399 #else
08400   ACE_UNUSED_ARG (handle);
08401 
08402   ACE_NOTSUP_RETURN (-1);
08403 #endif /* ACE_HAS_STREAM_PIPES */
08404 }

int ACE_OS::isatty ACE_HANDLE    handle [static]
 

ACE_INLINE int ACE_OS::isatty int    handle [static]
 

Definition at line 10990 of file OS.i.

References ACE_OS_TRACE, and isatty.

Referenced by isatty.

10991 {
10992 #if defined (ACE_LACKS_ISATTY)
10993   ACE_UNUSED_ARG (handle);
10994   return 0;
10995 # elif defined (ACE_WIN32)
10996   ACE_OS_TRACE ("ACE_OS::isatty");
10997   return ::_isatty (handle);
10998 # else
10999   ACE_OS_TRACE ("ACE_OS::isatty");
11000   ACE_OSCALL_RETURN (::isatty (handle), int, -1);
11001 # endif /* defined (ACE_LACKS_ISATTY) */
11002 }

ACE_HANDLE ACE_OS::join_leaf ACE_HANDLE    socket,
const sockaddr *    name,
int    namelen,
const ACE_QoS_Params   qos_params
[static]
 

Joins a leaf node into a QoS-enabled multi-point session.

Definition at line 7434 of file OS.cpp.

References ACE_SOCKCALL_RETURN, ACE_QoS_Params::callee_data, ACE_QoS_Params::caller_data, ACE_QoS_Params::flags, ACE_QoS_Params::group_socket_qos, ACE_QoS::provider_specific, ACE_QoS::receiving_flowspec, ACE_QoS::sending_flowspec, socket, and ACE_QoS_Params::socket_qos.

Referenced by ACE_ATM_Connector::add_leaf.

07438 {
07439 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
07440 
07441   QOS qos;
07442   // Construct the WinSock2 QOS structure.
07443 
07444   qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ());
07445   qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ());
07446   qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific ();
07447 
07448   ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket,
07449                                       name,
07450                                       namelen,
07451                                       (WSABUF *) qos_params.caller_data (),
07452                                       (WSABUF *) qos_params.callee_data (),
07453                                       &qos,
07454                                       (QOS *) qos_params.group_socket_qos (),
07455                                       qos_params.flags ()),
07456                        ACE_HANDLE,
07457                        ACE_INVALID_HANDLE);
07458 
07459 # else
07460   ACE_UNUSED_ARG (socket);
07461   ACE_UNUSED_ARG (name);
07462   ACE_UNUSED_ARG (namelen);
07463   ACE_UNUSED_ARG (qos_params);
07464   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
07465 # endif /* ACE_HAS_WINSOCK2 */
07466 }

ACE_INLINE int ACE_OS::kill pid_t    pid,
int    signum
[static]
 

Definition at line 10134 of file OS.i.

References ACE_OS_TRACE, kill, and pid_t.

Referenced by ACE_Process::kill, kill, ACE::process_active, ACE_Process::running, ACE_Process_Manager::terminate, ACE::terminate_process, and thr_kill.

10135 {
10136   ACE_OS_TRACE ("ACE_OS::kill");
10137 #if defined (ACE_WIN32) || defined (CHORUS) || defined (ACE_PSOS)
10138   ACE_UNUSED_ARG (pid);
10139   ACE_UNUSED_ARG (signum);
10140   ACE_NOTSUP_RETURN (-1);
10141 #else
10142   ACE_OSCALL_RETURN (::kill (pid, signum), int, -1);
10143 #endif /* ACE_WIN32 || CHORUS || ACE_PSOS */
10144 }

ACE_INLINE void ACE_OS::last_error int    [static]
 

Definition at line 6327 of file OS.i.

References ACE_OS_TRACE.

06328 {
06329   ACE_OS_TRACE ("ACE_OS::last_error");
06330 #if defined (ACE_WIN32)
06331   ::SetLastError (error);
06332 #else
06333   errno = error;
06334 #endif /* ACE_WIN32 */
06335 }

ACE_INLINE int ACE_OS::last_error void    [static]
 

Definition at line 6313 of file OS.i.

Referenced by ACE_Log_Msg::last_error_adapter, set_errno_to_last_error, set_errno_to_wsa_last_error, and set_scheduling_params.

06314 {
06315   // ACE_OS_TRACE ("ACE_OS::last_error");
06316 
06317 #if defined (ACE_WIN32)
06318   int lerror = ::GetLastError ();
06319   int lerrno = errno;
06320   return lerrno == 0 ? lerror : lerrno;
06321 #else
06322   return errno;
06323 #endif /* ACE_WIN32 */
06324 }

ACE_INLINE int ACE_OS::listen ACE_HANDLE    handle,
int    backlog
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5427 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and listen.

Referenced by listen, ACE_ATM_Acceptor::open, ACE_Asynch_Acceptor::open, and ACE_SOCK_Acceptor::shared_open.

05428 {
05429   ACE_OS_TRACE ("ACE_OS::listen");
05430   ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1);
05431 }

ACE_INLINE struct tm * ACE_OS::localtime const time_t *    clock [static]
 

Definition at line 8757 of file OS.i.

References ACE_OS_TRACE.

Referenced by ctime.

08758 {
08759 #if !defined (ACE_HAS_WINCE) && !defined (ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
08760   ACE_OS_TRACE ("ACE_OS::localtime");
08761   ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0);
08762 #else
08763   // @@ Don't you start wondering what kind of functions
08764   //    does WinCE really support?
08765   ACE_UNUSED_ARG (t);
08766   ACE_NOTSUP_RETURN (0);
08767 #endif /* ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */
08768 }

struct tm * ACE_OS::localtime_r const time_t *    clock,
struct tm *    res
[static]
 

Definition at line 4861 of file OS.cpp.

References ACE_OS_GUARD, and ACE_OS_TRACE.

Referenced by ACE_Date_Time::update.

04862 {
04863   ACE_OS_TRACE ("ACE_OS::localtime_r");
04864 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
04865 # if defined (DIGITAL_UNIX)
04866   ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0);
04867 # elif defined (HPUX_10)
04868   return (::localtime_r (t, res) == 0 ? res : (struct tm *)0);
04869 # else
04870   ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0);
04871 # endif /* DIGITAL_UNIX */
04872 #elif !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
04873   ACE_OS_GUARD
04874 
04875   ACE_UNUSED_ARG (res);
04876   struct tm * res_ptr;
04877   ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr);
04878   if (res_ptr == 0)
04879     return 0;
04880   else
04881     {
04882       *res = *res_ptr;
04883       return res;
04884     }
04885 #else
04886   // @@ Same as ACE_OS::localtime (), you need to implement it
04887   //    yourself.
04888   ACE_UNUSED_ARG (t);
04889   ACE_UNUSED_ARG (res);
04890   ACE_NOTSUP_RETURN (0);
04891 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
04892 }

ACE_INLINE off_t ACE_OS::lseek ACE_HANDLE    handle,
off_t    offset,
int    whence
[static]
 

Definition at line 9837 of file OS.i.

References ACE_OS_TRACE, ACE_SYSCALL_FAILED, and lseek.

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name, lseek, pread, ACE_MMAP_Memory_Pool::protect, pwrite, ACE_FILE::seek, ACE_MMAP_Memory_Pool::sync, ACE_FILE::tell, and ACE_Mem_Map::unmap.

09838 {
09839   ACE_OS_TRACE ("ACE_OS::lseek");
09840 #if defined (ACE_WIN32)
09841 # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
09842   //#error Windows NT is evil AND rude!
09843   switch (whence)
09844     {
09845     case SEEK_SET:
09846       whence = FILE_BEGIN;
09847       break;
09848     case SEEK_CUR:
09849       whence = FILE_CURRENT;
09850       break;
09851     case SEEK_END:
09852       whence = FILE_END;
09853       break;
09854     default:
09855       errno = EINVAL;
09856       return ACE_static_cast (off_t, -1); // rather safe than sorry
09857     }
09858 # endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
09859   DWORD result = ::SetFilePointer (handle, offset, 0, whence);
09860   if (result == ACE_SYSCALL_FAILED)
09861     ACE_FAIL_RETURN (ACE_static_cast (off_t, -1));
09862   else
09863     return result;
09864 #elif defined (ACE_PSOS)
09865 # if defined (ACE_PSOS_LACKS_PHILE)
09866   ACE_UNUSED_ARG (handle);
09867   ACE_UNUSED_ARG (offset);
09868   ACE_UNUSED_ARG (whence);
09869   ACE_NOTSUP_RETURN (ACE_static_cast (off_t, -1));
09870 # else
09871   unsigned long oldptr, newptr, result;
09872   // seek to the requested position
09873   result = ::lseek_f (handle, whence, offset, &oldptr);
09874   if (result != 0)
09875     {
09876       errno = result;
09877       return ACE_static_cast (off_t, -1);
09878     }
09879   // now do a dummy seek to the current position to obtain the position
09880   result = ::lseek_f (handle, SEEK_CUR, 0, &newptr);
09881   if (result != 0)
09882     {
09883       errno = result;
09884       return ACE_static_cast (off_t, -1);
09885     }
09886   return ACE_static_cast (off_t, newptr);
09887 # endif /* defined (ACE_PSOS_LACKS_PHILE */
09888 #else
09889   ACE_OSCALL_RETURN (::lseek (handle, offset, whence), off_t, -1);
09890 #endif /* ACE_WIN32 */
09891 }

ACE_INLINE int ACE_OS::lstat const char *   ,
ACE_stat  
[static]
 

Definition at line 329 of file OS.i.

References ACE_OS_TRACE, ACE_stat, and lstat.

Referenced by lstat.

00330 {
00331   ACE_OS_TRACE ("ACE_OS::lstat");
00332 # if defined (ACE_LACKS_LSTAT) || \
00333      defined (ACE_HAS_WINCE) || defined (ACE_WIN32)
00334   ACE_UNUSED_ARG (file);
00335   ACE_UNUSED_ARG (stp);
00336   ACE_NOTSUP_RETURN (-1);
00337 # else
00338 #   if defined (ACE_HAS_X86_STAT_MACROS)
00339    // Solaris for intel uses an macro for lstat(), this macro is a
00340    // wrapper for _lxstat().
00341   ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1);
00342 #   elif defined (ACE_WIN32)
00343   ACE_OSCALL_RETURN (::_lstat (file, stp), int, -1);
00344 #   else /* !ACE_HAS_X86_STAT_MACROS */
00345   ACE_OSCALL_RETURN (::lstat (file, stp), int, -1);
00346 #   endif /* !ACE_HAS_X86_STAT_MACROS */
00347 # endif /* ACE_LACKS_LSTAT */
00348 }

int ACE_OS::lwp_getparams ACE_Sched_Params   [static]
 

Definition at line 3497 of file OS.cpp.

References ACE_id_t, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCOPE_THREAD, ACE_OS_String::memcpy, ACE_OS_String::memset, ACE_Sched_Params::policy, ACE_Sched_Params::priority, priority_control, ACE_Sched_Params::quantum, scheduling_class, and ACE_Sched_Params::scope.

Referenced by thr_setprio.

03498 {
03499 # if defined (ACE_HAS_STHREADS) || defined (sun)
03500   // Get the class TS and RT class IDs.
03501   ACE_id_t rt_id;
03502   ACE_id_t ts_id;
03503   if (ACE_OS::scheduling_class ("RT", rt_id) == -1
03504       || ACE_OS::scheduling_class ("TS", ts_id) == -1)
03505     return -1;
03506 
03507   // Get this LWP's scheduling parameters.
03508   pcparms_t pcparms;
03509   // The following is just to avoid Purify warnings about unitialized
03510   // memory reads.
03511   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03512   pcparms.pc_cid = PC_CLNULL;
03513 
03514   if (ACE_OS::priority_control (P_LWPID,
03515                                 P_MYID,
03516                                 PC_GETPARMS,
03517                                 (char *) &pcparms) == -1)
03518     return -1;
03519   else if (pcparms.pc_cid == rt_id)
03520     {
03521       // RT class.
03522       rtparms_t rtparms;
03523       ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms);
03524 
03525       sched_params.policy (ACE_SCHED_FIFO);
03526       sched_params.priority (rtparms.rt_pri);
03527       sched_params.scope (ACE_SCOPE_THREAD);
03528       ACE_Time_Value quantum (rtparms.rt_tqsecs,
03529                               rtparms.rt_tqnsecs == RT_TQINF
03530                               ? 0 : rtparms.rt_tqnsecs * 1000);
03531       sched_params.quantum (quantum);
03532       return 0;
03533     }
03534   else if (pcparms.pc_cid == ts_id)
03535     {
03536       /* TS class */
03537       tsparms_t tsparms;
03538       ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms);
03539 
03540       sched_params.policy (ACE_SCHED_OTHER);
03541       sched_params.priority (tsparms.ts_upri);
03542       sched_params.scope (ACE_SCOPE_THREAD);
03543       return 0;
03544     }
03545   else
03546     return -1;
03547 
03548 # else  /* ! ACE_HAS_STHREADS && ! sun */
03549   ACE_UNUSED_ARG (sched_params);
03550   ACE_NOTSUP_RETURN (-1);
03551 # endif /* ! ACE_HAS_STHREADS && ! sun */
03552 }

int ACE_OS::lwp_setparams const ACE_Sched_Params   [static]
 

Definition at line 3555 of file OS.cpp.

References ACE_SCOPE_LWP, sched_params, and ACE_Sched_Params::scope.

Referenced by thr_create, and thr_setprio.

03556 {
03557 # if defined (ACE_HAS_STHREADS) || defined (sun)
03558   ACE_Sched_Params lwp_params (sched_params);
03559   lwp_params.scope (ACE_SCOPE_LWP);
03560   return ACE_OS::sched_params (lwp_params);
03561 # else  /* ! ACE_HAS_STHREADS && ! sun */
03562   ACE_UNUSED_ARG (sched_params);
03563   ACE_NOTSUP_RETURN (-1);
03564 # endif /* ! ACE_HAS_STHREADS && ! sun */
03565 }

ACE_INLINE int ACE_OS::madvise caddr_t    addr,
size_t    len,
int    advice
[static]
 

Definition at line 8469 of file OS.i.

References ACE_OS_TRACE, caddr_t, and madvise.

Referenced by ACE_Mem_Map::advise, and madvise.

08470 {
08471   ACE_OS_TRACE ("ACE_OS::madvise");
08472 #if defined (ACE_WIN32)
08473   ACE_UNUSED_ARG (addr);
08474   ACE_UNUSED_ARG (len);
08475   ACE_UNUSED_ARG (advice);
08476 
08477   ACE_NOTSUP_RETURN (-1);
08478 #elif !defined (ACE_LACKS_MADVISE)
08479   ACE_OSCALL_RETURN (::madvise (addr, len, advice), int, -1);
08480 #else
08481   ACE_UNUSED_ARG (addr);
08482   ACE_UNUSED_ARG (len);
08483   ACE_UNUSED_ARG (advice);
08484   ACE_NOTSUP_RETURN (-1);
08485 #endif /* ACE_WIN32 */
08486 }

ACE_INLINE int ACE_OS::mkdir const ACE_TCHAR   path,
mode_t    mode = ACE_DEFAULT_DIR_PERMS
[static]
 

Definition at line 10398 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_TCHAR, ACE_OS_Memory::free, ACE_OS_Memory::malloc, mkdir, mode_t, printf, ACE_OS_String::strcpy, and ACE_OS_String::strlen.

Referenced by mkdir.

10399 {
10400 #if defined (ACE_PSOS_LACKS_PHILE)
10401   ACE_UNUSED_ARG (path);
10402   ACE_UNUSED_ARG (mode);
10403   ACE_NOTSUP_RETURN (-1);
10404 #elif defined (ACE_PSOS)
10405   //The pSOS make_dir fails if the last character is a '/'
10406   int location;
10407   char *phile_path;
10408 
10409   phile_path = (char *)ACE_OS::malloc(strlen(path));
10410   if (phile_path == 0)
10411     {
10412       ACE_OS::printf ("malloc in make_dir failed: [%X]\n",
10413                       errno);
10414       return -1;
10415     }
10416   else
10417     ACE_OS::strcpy (phile_path, path);
10418 
10419   location = ACE_OS::strlen(phile_path);
10420   if(phile_path[location-1] == '/')
10421   {
10422      phile_path[location-1] = 0;
10423   }
10424 
10425   u_long result;
10426   result = ::make_dir ((char *) phile_path, mode);
10427   if (result == 0x2011)  // Directory already exists
10428     {
10429       result = 0;
10430     }
10431   else if (result != 0)
10432     {
10433       result = -1;
10434     }
10435 
10436   ACE_OS::free(phile_path);
10437   return result;
10438 
10439 #elif defined (VXWORKS)
10440   ACE_UNUSED_ARG (mode);
10441   ACE_OSCALL_RETURN (::mkdir ((char *) path), int, -1);
10442 #elif defined (ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
10443   ACE_UNUSED_ARG (mode);
10444   ACE_OSCALL_RETURN (::_mkdir ((char *) path), int, -1);
10445 #elif defined (ACE_HAS_WINCE)
10446   ACE_UNUSED_ARG (mode);
10447   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (path, 0),
10448                                           ace_result_),
10449                         int, -1);
10450 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
10451   ACE_UNUSED_ARG (mode);
10452   ACE_OSCALL_RETURN (::_wmkdir (path), int, -1);
10453 #elif defined (ACE_WIN32)
10454   ACE_UNUSED_ARG (mode);
10455   ACE_OSCALL_RETURN (::mkdir (path), int, -1);
10456 #else
10457   ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1);
10458 #endif /* ACE_PSOS_LACKS_PHILE */
10459 }

ACE_INLINE int ACE_OS::mkfifo const ACE_TCHAR   file,
mode_t    mode = ACE_DEFAULT_FILE_PERMS
[static]
 

Definition at line 223 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, mkfifo, and mode_t.

Referenced by mkfifo, and ACE_FIFO::open.

00224 {
00225   ACE_OS_TRACE ("ACE_OS::mkfifo");
00226 #if defined (ACE_LACKS_MKFIFO)
00227   ACE_UNUSED_ARG (file);
00228   ACE_UNUSED_ARG (mode);
00229   ACE_NOTSUP_RETURN (-1);
00230 #else
00231   ACE_OSCALL_RETURN (::mkfifo (file, mode), int, -1);
00232 #endif /* ACE_LACKS_MKFIFO */
00233 }

ACE_INLINE ACE_HANDLE ACE_OS::mkstemp ACE_TCHAR   t [static]
 

Definition at line 216 of file OS.i.

References ACE_TCHAR.

Referenced by ACE_FILE_Connector::connect.

00217 {
00218   return ::mkstemp (s);
00219 }

ACE_INLINE ACE_TCHAR * ACE_OS::mktemp ACE_TCHAR   t [static]
 

Definition at line 202 of file OS.i.

References ACE_TCHAR.

Referenced by ACE_FILE_Addr::set.

00203 {
00204 # if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00205   return ::_wmktemp (s);
00206 # elif defined (ACE_WIN32)
00207   return ::_mktemp (s);
00208 # else /* ACE_WIN32 */
00209   return ::mktemp (s);
00210 # endif /* ACE_WIN32 */
00211 }

time_t ACE_OS::mktime struct tm *    timeptr [static]
 

Definition at line 5545 of file OS.cpp.

References ACE_OS_GUARD, ACE_OS_TRACE, mktime, and ACE_Time_Value::sec.

Referenced by mktime.

05546 {
05547   ACE_OS_TRACE ("ACE_OS::mktime");
05548 #   if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
05549   ACE_UNUSED_ARG (t);
05550   ACE_NOTSUP_RETURN (-1);
05551 #   elif defined (ACE_HAS_WINCE)
05552   SYSTEMTIME t_sys;
05553   FILETIME t_file;
05554   t_sys.wSecond = t->tm_sec;
05555   t_sys.wMinute = t->tm_min;
05556   t_sys.wHour = t->tm_hour;
05557   t_sys.wDay = t->tm_mday;
05558   t_sys.wMonth = t->tm_mon + 1;  // SYSTEMTIME is 1-indexed, tm is 0-indexed
05559   t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900
05560   t_sys.wDayOfWeek = t->tm_wday;  // Ignored in below function call.
05561   if (SystemTimeToFileTime (&t_sys, &t_file) == 0)
05562     return -1;
05563   ACE_Time_Value tv (t_file);
05564   return tv.sec ();
05565 #   else
05566 #     if defined (ACE_HAS_THREADS)  &&  !defined (ACE_HAS_MT_SAFE_MKTIME)
05567   ACE_OS_GUARD
05568 #     endif /* ACE_HAS_THREADS  &&  ! ACE_HAS_MT_SAFE_MKTIME */
05569 
05570   ACE_OSCALL_RETURN (::mktime (t), time_t, (time_t) -1);
05571 #   endif /* ACE_PSOS && ! ACE_PSOS_HAS_TIME */
05572 }

ACE_INLINE void * ACE_OS::mmap void *    addr,
size_t    len,
int    prot,
int    flags,
ACE_HANDLE    handle,
off_t    off = 0,
ACE_HANDLE *    file_mapping = 0,
LPSECURITY_ATTRIBUTES    sa = 0,
const ACE_TCHAR   file_mapping_name = 0
[static]
 

Definition at line 2885 of file OS.i.

References ACE_BIT_ENABLED, ACE_DEFAULT_FILE_PERMS, ACE_MMAP_TYPE, ACE_OS_TRACE, ACE_TCHAR, default_win32_security_attributes, filesize, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, MAP_SHARED, and sprintf.

Referenced by ACE_Condition::ACE_Condition, ACE_Mutex::ACE_Mutex, flock_init, ACE_Mem_Map::map_it, ACE_Dev_Poll_Reactor::open, and sema_init.

02894 {
02895   ACE_OS_TRACE ("ACE_OS::mmap");
02896 #if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP)
02897   ACE_UNUSED_ARG (file_mapping_name);
02898 #endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */
02899 
02900 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
02901 
02902 #  if defined(ACE_HAS_WINCE)
02903   ACE_UNUSED_ARG (addr);
02904   if (ACE_BIT_ENABLED (flags, MAP_FIXED))     // not supported
02905   {
02906     errno = EINVAL;
02907     return MAP_FAILED;
02908   }
02909 #  else
02910   if (!ACE_BIT_ENABLED (flags, MAP_FIXED))
02911     addr = 0;
02912   else if (addr == 0)   // can not map to address 0
02913   {
02914     errno = EINVAL;
02915     return MAP_FAILED;
02916   }
02917 #  endif
02918 
02919   int nt_flags = 0;
02920   ACE_HANDLE local_handle = ACE_INVALID_HANDLE;
02921 
02922   // Ensure that file_mapping is non-zero.
02923   if (file_mapping == 0)
02924     file_mapping = &local_handle;
02925 
02926   if (ACE_BIT_ENABLED (flags, MAP_PRIVATE))
02927     {
02928 #  if !defined(ACE_HAS_WINCE)
02929       prot = PAGE_WRITECOPY;
02930 #  endif  // ACE_HAS_WINCE
02931       nt_flags = FILE_MAP_COPY;
02932     }
02933   else if (ACE_BIT_ENABLED (flags, MAP_SHARED))
02934     {
02935       if (ACE_BIT_ENABLED (prot, PAGE_READONLY))
02936         nt_flags = FILE_MAP_READ;
02937       if (ACE_BIT_ENABLED (prot, PAGE_READWRITE))
02938         nt_flags = FILE_MAP_WRITE;
02939     }
02940 
02941   // Only create a new handle if we didn't have a valid one passed in.
02942   if (*file_mapping == ACE_INVALID_HANDLE)
02943     {
02944 #  if !defined(ACE_HAS_WINCE) && (!defined (ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0))
02945       int try_create = 1;
02946       if ((file_mapping_name != 0) && (*file_mapping_name != 0))
02947         {
02948           // On Win9x, we first try to OpenFileMapping to
02949           // file_mapping_name. Only if there is no mapping object
02950           // with that name, and the desired name is valid, do we try
02951           // CreateFileMapping.
02952 
02953           *file_mapping = ACE_TEXT_OpenFileMapping (nt_flags,
02954                                                     0,
02955                                                     file_mapping_name);
02956           if (*file_mapping != 0
02957               || (::GetLastError () == ERROR_INVALID_NAME
02958                   && ::GetLastError () == ERROR_FILE_NOT_FOUND))
02959             try_create = 0;
02960         }
02961 
02962       if (try_create)
02963 #  endif /* !ACE_HAS_WINCE && (ACE_HAS_WINNT4 || ACE_HAS_WINNT4 == 0) */
02964         {
02965           const LPSECURITY_ATTRIBUTES attr =
02966             ACE_OS::default_win32_security_attributes (sa);
02967 
02968           *file_mapping = ACE_TEXT_CreateFileMapping (file_handle,
02969                                                       attr,
02970                                                       prot,
02971                                                       0,
02972                                                       0,
02973                                                       file_mapping_name);
02974         }
02975     }
02976 
02977   if (*file_mapping == 0)
02978     ACE_FAIL_RETURN (MAP_FAILED);
02979 
02980 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
02981   nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS;
02982 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
02983 
02984 #  if !defined (ACE_HAS_WINCE)
02985   void *addr_mapping = ::MapViewOfFileEx (*file_mapping,
02986                                           nt_flags,
02987                                           0,
02988                                           off,
02989                                           len,
02990                                           addr);
02991 #  else
02992   void *addr_mapping = ::MapViewOfFile (*file_mapping,
02993                                         nt_flags,
02994                                         0,
02995                                         off,
02996                                         len);
02997 #  endif /* ! ACE_HAS_WINCE */
02998 
02999   // Only close this down if we used the temporary.
03000   if (file_mapping == &local_handle)
03001     ::CloseHandle (*file_mapping);
03002 
03003   if (addr_mapping == 0)
03004     ACE_FAIL_RETURN (MAP_FAILED);
03005   else
03006     return addr_mapping;
03007 #elif defined (__Lynx__)
03008   // The LynxOS 2.5.0 mmap doesn't allow operations on plain
03009   // file descriptors.  So, create a shm object and use that.
03010   ACE_UNUSED_ARG (sa);
03011 
03012   char name [128];
03013   sprintf (name, "%d", file_handle);
03014 
03015   // Assumes that this was called by ACE_Mem_Map, so &file_mapping !=
03016   // 0.  Otherwise, we don't support the incomplete LynxOS mmap
03017   // implementation.  We do support it by creating a hidden shared
03018   // memory object, and using that for the mapping.
03019   int shm_handle;
03020   if (! file_mapping)
03021     file_mapping = &shm_handle;
03022   if ((*file_mapping = ::shm_open (name,
03023                                    O_RDWR | O_CREAT | O_TRUNC,
03024                                    ACE_DEFAULT_FILE_PERMS)) == -1)
03025     return MAP_FAILED;
03026   else
03027     {
03028       // The size of the shared memory object must be explicitly set on LynxOS.
03029       const off_t filesize = ACE_OS::filesize (file_handle);
03030       if (::ftruncate (*file_mapping, filesize) == -1)
03031         return MAP_FAILED;
03032       else
03033         {
03034 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
03035           flags |= ACE_OS_EXTRA_MMAP_FLAGS;
03036 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
03037           char *map = (char *) ::mmap ((ACE_MMAP_TYPE) addr,
03038                                        len,
03039                                        prot,
03040                                        flags,
03041                                        *file_mapping,
03042                                        off);
03043           if (map == MAP_FAILED)
03044             return MAP_FAILED;
03045           else
03046             // Finally, copy the file contents to the shared memory object.
03047             return ::read (file_handle, map, (int) filesize) == filesize
03048               ? map
03049               : MAP_FAILED;
03050         }
03051     }
03052 #elif !defined (ACE_LACKS_MMAP)
03053   ACE_UNUSED_ARG (sa);
03054 
03055 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
03056   flags |= ACE_OS_EXTRA_MMAP_FLAGS;
03057 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
03058   ACE_UNUSED_ARG (file_mapping);
03059   ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr,
03060                                       len,
03061                                       prot,
03062                                       flags,
03063                                       file_handle,
03064                                       off),
03065                      void *, MAP_FAILED);
03066 #else
03067   ACE_UNUSED_ARG (addr);
03068   ACE_UNUSED_ARG (len);
03069   ACE_UNUSED_ARG (prot);
03070   ACE_UNUSED_ARG (flags);
03071   ACE_UNUSED_ARG (file_handle);
03072   ACE_UNUSED_ARG (off);
03073   ACE_UNUSED_ARG (file_mapping);
03074   ACE_UNUSED_ARG (sa);
03075   ACE_NOTSUP_RETURN (MAP_FAILED);
03076 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
03077 }

ACE_INLINE int ACE_OS::mprotect void *    addr,
size_t    len,
int    prot
[static]
 

Definition at line 8412 of file OS.i.

References ACE_MMAP_TYPE, ACE_OS_TRACE, and mprotect.

Referenced by mprotect, ACE_MMAP_Memory_Pool::protect, and ACE_Mem_Map::protect.

08413 {
08414   ACE_OS_TRACE ("ACE_OS::mprotect");
08415 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
08416   DWORD dummy; // Sigh!
08417   return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1;
08418 #elif !defined (ACE_LACKS_MPROTECT)
08419   ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1);
08420 #else
08421   ACE_UNUSED_ARG (addr);
08422   ACE_UNUSED_ARG (len);
08423   ACE_UNUSED_ARG (prot);
08424   ACE_NOTSUP_RETURN (-1);
08425 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
08426 }

ACE_INLINE int ACE_OS::msgctl int    msqid,
int    cmd,
struct msqid_ds  
[static]
 

Definition at line 7826 of file OS.i.

References ACE_OS_TRACE, and msgctl.

Referenced by ACE_SV_Message_Queue::control, and msgctl.

07827 {
07828   ACE_OS_TRACE ("ACE_OS::msgctl");
07829 #if defined (ACE_HAS_SYSV_IPC)
07830   ACE_OSCALL_RETURN (::msgctl (msqid, cmd, val), int, -1);
07831 #else
07832   ACE_UNUSED_ARG (msqid);
07833   ACE_UNUSED_ARG (cmd);
07834   ACE_UNUSED_ARG (val);
07835 
07836   ACE_NOTSUP_RETURN (-1);
07837 #endif /* ACE_HAS_SYSV_IPC */
07838 }

ACE_INLINE int ACE_OS::msgget key_t    key,
int    msgflg
[static]
 

Definition at line 7841 of file OS.i.

References ACE_OS_TRACE, and msgget.

Referenced by msgget, and ACE_SV_Message_Queue::open.

07842 {
07843   ACE_OS_TRACE ("ACE_OS::msgget");
07844 #if defined (ACE_HAS_SYSV_IPC)
07845   ACE_OSCALL_RETURN (::msgget (key, msgflg), int, -1);
07846 #else
07847   ACE_UNUSED_ARG (key);
07848   ACE_UNUSED_ARG (msgflg);
07849 
07850   ACE_NOTSUP_RETURN (-1);
07851 #endif /* ACE_HAS_SYSV_IPC */
07852 }

ACE_INLINE int ACE_OS::msgrcv int    int_id,
void *    buf,
size_t    len,
long    type,
int    flags
[static]
 

Definition at line 7855 of file OS.i.

References ACE_OS_TRACE, and msgrcv.

Referenced by msgrcv, and ACE_SV_Message_Queue::recv.

07857 {
07858   ACE_OS_TRACE ("ACE_OS::msgrcv");
07859 #if defined (ACE_HAS_SYSV_IPC)
07860 # if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES)
07861   ACE_OSCALL_RETURN (::msgrcv (int_id, (msgbuf *) buf, len, type, flags),
07862                      int, -1);
07863 # else
07864   ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags),
07865                      int, -1);
07866 # endif /* ACE_LACKS_POSIX_PROTOTYPES */
07867 #else
07868   ACE_UNUSED_ARG (int_id);
07869   ACE_UNUSED_ARG (buf);
07870   ACE_UNUSED_ARG (len);
07871   ACE_UNUSED_ARG (type);
07872   ACE_UNUSED_ARG (flags);
07873 
07874   ACE_NOTSUP_RETURN (-1);
07875 #endif /* ACE_HAS_SYSV_IPC */
07876 }

ACE_INLINE int ACE_OS::msgsnd int    int_id,
const void *    buf,
size_t    len,
int    flags
[static]
 

Definition at line 7879 of file OS.i.

References ACE_OS_TRACE, and msgsnd.

Referenced by msgsnd, and ACE_SV_Message_Queue::send.

07880 {
07881   ACE_OS_TRACE ("ACE_OS::msgsnd");
07882 #if defined (ACE_HAS_SYSV_IPC)
07883 # if defined (ACE_HAS_NONCONST_MSGSND)
07884   ACE_OSCALL_RETURN (::msgsnd (int_id, (void *) buf, len, flags), int, -1);
07885 # elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES)
07886   ACE_OSCALL_RETURN (::msgsnd (int_id, (msgbuf *) buf, len, flags), int, -1);
07887 # else
07888   ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1);
07889 # endif /* ACE_LACKS_POSIX_PROTOTYPES || ACE_HAS_NONCONST_MSGSND */
07890 #else
07891   ACE_UNUSED_ARG (int_id);
07892   ACE_UNUSED_ARG (buf);
07893   ACE_UNUSED_ARG (len);
07894   ACE_UNUSED_ARG (flags);
07895 
07896   ACE_NOTSUP_RETURN (-1);
07897 #endif /* ACE_HAS_SYSV_IPC */
07898 }

ACE_INLINE int ACE_OS::msync void *    addr,
size_t    len,
int    sync
[static]
 

Definition at line 8429 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_OS_TRACE, and msync.

Referenced by msync, ACE_MMAP_Memory_Pool::sync, and ACE_Mem_Map::sync.

08430 {
08431   ACE_OS_TRACE ("ACE_OS::msync");
08432 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
08433   ACE_UNUSED_ARG (sync);
08434 
08435   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1);
08436 #elif !defined (ACE_LACKS_MSYNC)
08437 # if !defined (ACE_HAS_BROKEN_NETBSD_MSYNC)
08438   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1);
08439 # else
08440   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len), int, -1);
08441   ACE_UNUSED_ARG (sync);
08442 # endif /* ACE_HAS_BROKEN_NETBSD_MSYNC */
08443 #else
08444   ACE_UNUSED_ARG (addr);
08445   ACE_UNUSED_ARG (len);
08446   ACE_UNUSED_ARG (sync);
08447   ACE_NOTSUP_RETURN (-1);
08448 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
08449 }

ACE_INLINE int ACE_OS::munmap void *    addr,
size_t    len
[static]
 

Definition at line 8452 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_OS_TRACE, and munmap.

Referenced by ACE_Dev_Poll_Reactor::close, flock_destroy, munmap, ACE_Condition::remove, ACE_Mutex::remove, and ACE_Mem_Map::unmap.

08453 {
08454   ACE_OS_TRACE ("ACE_OS::munmap");
08455 #if defined (ACE_WIN32)
08456   ACE_UNUSED_ARG (len);
08457 
08458   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1);
08459 #elif !defined (ACE_LACKS_MMAP)
08460   ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1);
08461 #else
08462   ACE_UNUSED_ARG (addr);
08463   ACE_UNUSED_ARG (len);
08464   ACE_NOTSUP_RETURN (-1);
08465 #endif /* ACE_WIN32 */
08466 }

ACE_INLINE int ACE_OS::mutex_destroy ACE_mutex_t *    m [static]
 

Definition at line 1327 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, mutex_destroy, and thread_mutex_destroy.

Referenced by event_destroy, flock_destroy, mutex_destroy, ACE_Mutex::remove, rwlock_destroy, sema_destroy, sema_init, and thread_mutex_destroy.

01328 {
01329   ACE_OS_TRACE ("ACE_OS::mutex_destroy");
01330 #if defined (ACE_HAS_THREADS)
01331 # if defined (ACE_HAS_PTHREADS)
01332 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
01333   ACE_OSCALL_RETURN (::pthread_mutex_destroy (m), int, -1);
01334 #   else
01335   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
01336                                        ace_result_), int, -1);
01337 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/
01338 # elif defined (ACE_HAS_STHREADS)
01339   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), ace_result_), int, -1);
01340 # elif defined (ACE_HAS_WTHREADS)
01341   switch (m->type_)
01342     {
01343     case USYNC_PROCESS:
01344       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
01345                                               ace_result_),
01346                             int, -1);
01347     case USYNC_THREAD:
01348       return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
01349     default:
01350       errno = EINVAL;
01351       return -1;
01352     }
01353   /* NOTREACHED */
01354 # elif defined (ACE_PSOS)
01355 #   if defined (ACE_PSOS_HAS_MUTEX)
01356   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_delete (*m), ace_result_),
01357                      int, -1);
01358 #   else /* ! ACE_PSOS_HAS_MUTEX */
01359   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_delete (*m), ace_result_),
01360                      int, -1);
01361 #   endif /* ACE_PSOS_HAS_MUTEX */
01362 # elif defined (VXWORKS)
01363   return ::semDelete (*m) == OK ? 0 : -1;
01364 # endif /* Threads variety case */
01365 #else
01366   ACE_UNUSED_ARG (m);
01367   ACE_NOTSUP_RETURN (-1);
01368 #endif /* ACE_HAS_THREADS */
01369 }

int ACE_OS::mutex_init ACE_mutex_t *    m,
int    type,
const wchar_t *    name,
ACE_mutexattr_t *    arg = 0,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

ACE_INLINE int ACE_OS::mutex_init ACE_mutex_t *    m,
int    type = ACE_DEFAULT_SYNCH_TYPE,
const char *    name = 0,
ACE_mutexattr_t *    arg = 0,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

Definition at line 1091 of file OS.i.

References ACE_ADAPT_RETVAL, default_win32_security_attributes, mutex_init, set_errno_to_last_error, and thread_mutex_init.

Referenced by ACE_Mutex::ACE_Mutex, event_init, flock_init, mutex_init, sema_init, and thread_mutex_init.

01096 {
01097   // ACE_OS_TRACE ("ACE_OS::mutex_init");
01098 #if defined (ACE_HAS_THREADS)
01099 # if defined (ACE_HAS_PTHREADS)
01100   ACE_UNUSED_ARG (name);
01101   ACE_UNUSED_ARG (attributes);
01102   ACE_UNUSED_ARG (sa);
01103 
01104   pthread_mutexattr_t l_attributes;
01105   if (attributes == 0)
01106     attributes = &l_attributes;
01107   int result = 0;
01108   int attr_init = 0;  // have we initialized the local attributes.
01109 
01110   // Only do these initializations if the <attributes> parameter
01111   // wasn't originally set.
01112   if (attributes == &l_attributes)
01113     {
01114 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01115       if (::pthread_mutexattr_create (attributes) == 0)
01116 #   elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01117       if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0)
01118 #   else /* draft 6 */
01119       if (::pthread_mutexattr_init (attributes) == 0)
01120 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01121         {
01122           result = 0;
01123           attr_init = 1; // we have initialized these attributes
01124         }
01125       else
01126         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01127     }
01128 
01129   if (result == 0)
01130     {
01131 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01132       if (
01133 #     if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP)
01134           ::pthread_mutexattr_setkind_np (attributes, type) == 0 &&
01135 #     endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */
01136           ::pthread_mutex_init (m, *attributes) == 0)
01137 #   elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01138       if (
01139 #     if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01140            ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes, type),
01141                              result) == 0 &&
01142 #     endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_MUTEXATTR_PSHARED */
01143            ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0)
01144 #   else
01145         if (
01146 #     if !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01147             ::pthread_mutexattr_setpshared (attributes, type) == 0 &&
01148 #     endif /* ACE_LACKS_MUTEXATTR_PSHARED */
01149 #     if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP)
01150             ::pthread_mutexattr_setkind_np (attributes, type) == 0 &&
01151 #     endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */
01152             ::pthread_mutex_init (m, attributes) == 0)
01153 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01154         result = 0;
01155       else
01156         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01157     }
01158 
01159 #   if (!defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP) && !defined (_POSIX_THREAD_PROCESS_SHARED)  ||  defined (ACE_LACKS_MUTEXATTR_PSHARED)) \
01160        || ((defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)) && !defined (_POSIX_THREAD_PROCESS_SHARED))
01161   ACE_UNUSED_ARG (type);
01162 #   endif /* ! ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */
01163 
01164   // Only do the deletions if the <attributes> parameter wasn't
01165   // originally set.
01166   if (attributes == &l_attributes && attr_init)
01167 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01168     ::pthread_mutexattr_delete (&l_attributes);
01169 #   else
01170     ::pthread_mutexattr_destroy (&l_attributes);
01171 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01172 
01173   return result;
01174 # elif defined (ACE_HAS_STHREADS)
01175   ACE_UNUSED_ARG (name);
01176   ACE_UNUSED_ARG (sa);
01177   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m, type, attributes),
01178                                        ace_result_),
01179                      int, -1);
01180 # elif defined (ACE_HAS_WTHREADS)
01181   m->type_ = type;
01182 
01183   switch (type)
01184     {
01185     case USYNC_PROCESS:
01186 #   if defined (ACE_HAS_WINCE)
01187       // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
01188       m->proc_mutex_ = ::CreateMutexW (ACE_OS::default_win32_security_attributes (sa),
01189                                        FALSE,
01190                                        ACE_Ascii_To_Wide (name).wchar_rep ());
01191 #   else /* ACE_HAS_WINCE */
01192       m->proc_mutex_ = ::CreateMutexA (ACE_OS::default_win32_security_attributes (sa),
01193                                        FALSE,
01194                                        name);
01195 #   endif /* ACE_HAS_WINCE */
01196       if (m->proc_mutex_ == 0)
01197         ACE_FAIL_RETURN (-1);
01198       else
01199         {
01200           // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01201           ACE_OS::set_errno_to_last_error ();
01202           return 0;
01203         }
01204     case USYNC_THREAD:
01205       return ACE_OS::thread_mutex_init (&m->thr_mutex_,
01206                                         type,
01207                                         name,
01208                                         attributes);
01209     default:
01210       errno = EINVAL;
01211       return -1;
01212     }
01213   /* NOTREACHED */
01214 
01215 # elif defined (ACE_PSOS)
01216   ACE_UNUSED_ARG (type);
01217   ACE_UNUSED_ARG (attributes);
01218   ACE_UNUSED_ARG (sa);
01219 #   if defined (ACE_PSOS_HAS_MUTEX)
01220 
01221     u_long flags = MU_LOCAL;
01222     u_long ceiling = 0;
01223 
01224 #     if defined (ACE_HAS_RECURSIVE_MUTEXES)
01225     flags |= MU_RECURSIVE;
01226 #     else /* ! ACE_HAS_RECURSIVE_MUTEXES */
01227     flags |= MU_NONRECURSIVE;
01228 #     endif /* ACE_HAS_RECURSIVE_MUTEXES */
01229 
01230 #     if defined (ACE_PSOS_HAS_PRIO_MUTEX)
01231 
01232     flags |= MU_PRIOR;
01233 
01234 #       if defined (ACE_PSOS_HAS_PRIO_INHERIT_MUTEX)
01235     flags |= MU_PRIO_INHERIT;
01236 #       elif defined (ACE_PSOS_HAS_PRIO_PROTECT_MUTEX)
01237     ceiling =  PSOS_TASK_MAX_PRIORITY;
01238     flags |= MU_PRIO_PROTECT;
01239 #       else
01240     flags |= MU_PRIO_NONE;
01241 #       endif /* ACE_PSOS_HAS_PRIO_INHERIT_MUTEX */
01242 
01243 #     else /* ! ACE_PSOS_HAS_PRIO_MUTEX */
01244 
01245     flags |= MU_FIFO | MU_PRIO_NONE;
01246 
01247 #     endif
01248 
01249     // Fake a pSOS name - it can be any 4-byte value, not necessarily needing
01250     // to be ASCII. So use the mutex pointer passed in. That should identify
01251     // each one uniquely.
01252     union { ACE_mutex_t *p; char n[4]; } m_name;
01253     m_name.p = m;
01254 
01255     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_create (m_name.n,
01256                                                       flags,
01257                                                       ceiling,
01258                                                       m),
01259                                          ace_result_),
01260                        int, -1);
01261 
01262 #   else /* ! ACE_PSOS_HAS_MUTEX */
01263   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_create ((char *) name,
01264                                                     1,
01265                                                     SM_LOCAL | SM_PRIOR,
01266                                                     m),
01267                                        ace_result_),
01268                      int, -1);
01269 #   endif /* ACE_PSOS_HAS_MUTEX */
01270 # elif defined (VXWORKS)
01271   ACE_UNUSED_ARG (name);
01272   ACE_UNUSED_ARG (attributes);
01273   ACE_UNUSED_ARG (sa);
01274 
01275   return (*m = ::semMCreate (type)) == 0 ? -1 : 0;
01276 # endif /* ACE_HAS_PTHREADS */
01277 #else
01278   ACE_UNUSED_ARG (m);
01279   ACE_UNUSED_ARG (type);
01280   ACE_UNUSED_ARG (name);
01281   ACE_UNUSED_ARG (attributes);
01282   ACE_UNUSED_ARG (sa);
01283   ACE_NOTSUP_RETURN (-1);
01284 #endif /* ACE_HAS_THREADS */
01285 }

ACE_INLINE int ACE_OS::mutex_lock ACE_mutex_t *    m,
const ACE_Time_Value   timeout
[static]
 

If <timeout> == 0, calls <ACE_OS::mutex_lock(m)>. Otherwise, this method attempts to acquire a lock, but gives up if the lock has not been acquired by the given time, in which case it returns -1 with an <ETIME> errno on platforms that actually support timed mutexes. The timeout should be an absolute time. Note that the mutex should not be a recursive one, i.e., it should only be a standard mutex or an error checking mutex.

Definition at line 1703 of file OS.i.

References mutex_lock.

01705 {
01706   return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
01707 }

ACE_INLINE int ACE_OS::mutex_lock ACE_mutex_t *    m,
const ACE_Time_Value   timeout
[static]
 

This method attempts to acquire a lock, but gives up if the lock has not been acquired by the given time. If the lock is not acquired within the given amount of time, then this method returns -1 with an <ETIME> errno on platforms that actually support timed mutexes. The timeout should be an absolute time. Note that the mutex should not be a recursive one, i.e., it should only be a standard mutex or an error checking mutex.

Definition at line 1600 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_ONE_SECOND_IN_USECS, EBUSY, ETIME, ETIMEDOUT, gettimeofday, ACE_Time_Value::msec, ACE_Time_Value::sec, set_errno_to_last_error, and ACE_Time_Value::usec.

01602 {
01603 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS)
01604 
01605 #  if defined (ACE_HAS_PTHREADS)
01606   int result;
01607 
01608   // "timeout" should be an absolute time.
01609 
01610   timespec_t ts = timeout;  // Calls ACE_Time_Value::operator timespec_t().
01611 
01612   // Note that the mutex should not be a recursive one, i.e., it
01613   // should only be a standard mutex or an error checking mutex.
01614 
01615   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result);
01616 
01617   // We need to adjust this to make the errno values consistent.
01618   if (result == -1 && errno == ETIMEDOUT)
01619     errno = ETIME;
01620   return result;
01621 
01622 #  elif defined (ACE_HAS_WTHREADS)
01623   // Note that we must convert between absolute time (which is passed
01624   // as a parameter) and relative time (which is what the system call
01625   // expects).
01626   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
01627 
01628   switch (m->type_)
01629     {
01630     case USYNC_PROCESS:
01631       switch (::WaitForSingleObject (m->proc_mutex_,
01632                                      relative_time.msec ()))
01633         {
01634         case WAIT_OBJECT_0:
01635         case WAIT_ABANDONED:
01636           // We will ignore abandonments in this method
01637           // Note that we still hold the lock
01638           return 0;
01639         case WAIT_TIMEOUT:
01640           errno = ETIME;
01641           return -1;
01642         default:
01643           // This is a hack, we need to find an appropriate mapping...
01644           ACE_OS::set_errno_to_last_error ();
01645           return -1;
01646         }
01647     case USYNC_THREAD:
01648       ACE_NOTSUP_RETURN (-1);
01649     default:
01650       errno = EINVAL;
01651       return -1;
01652     }
01653   /* NOTREACHED */
01654 
01655 #  elif defined (ACE_PSOS)
01656 
01657   // Note that we must convert between absolute time (which is
01658   // passed as a parameter) and relative time (which is what
01659   // the system call expects).
01660   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
01661 
01662   u_long ticks = relative_time.sec() * KC_TICKS2SEC +
01663                  relative_time.usec () * KC_TICKS2SEC /
01664                    ACE_ONE_SECOND_IN_USECS;
01665   if (ticks == 0)
01666     ACE_OSCALL_RETURN (::sm_p (*m, SM_NOWAIT, 0), int, -1); // no timeout
01667   else
01668     ACE_OSCALL_RETURN (::sm_p (*m, SM_WAIT, ticks), int, -1);
01669 
01670 #  elif defined (VXWORKS)
01671 
01672   // Note that we must convert between absolute time (which is passed
01673   // as a parameter) and relative time (which is what the system call
01674   // expects).
01675   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
01676 
01677   int ticks_per_sec = ::sysClkRateGet ();
01678 
01679   int ticks = relative_time.sec() * ticks_per_sec +
01680               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
01681   if (::semTake (*m, ticks) == ERROR)
01682     {
01683       if (errno == S_objLib_OBJ_TIMEOUT)
01684         // Convert the VxWorks errno to one that's common for to ACE
01685         // platforms.
01686         errno = ETIME;
01687       else if (errno == S_objLib_OBJ_UNAVAILABLE)
01688         errno = EBUSY;
01689       return -1;
01690     }
01691   else
01692     return 0;
01693 #  endif /* ACE_HAS_PTHREADS */
01694 
01695 #else
01696   ACE_UNUSED_ARG (m);
01697   ACE_UNUSED_ARG (timeout);
01698   ACE_NOTSUP_RETURN (-1);
01699 #endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */
01700 }

ACE_INLINE int ACE_OS::mutex_lock ACE_mutex_t *    m,
int &    abandoned
[static]
 

This method is only implemented for Win32. For abandoned mutexes, <abandoned> is set to 1 and 0 is returned.

Definition at line 1432 of file OS.i.

References ACE_OS_TRACE, set_errno_to_last_error, and thread_mutex_lock.

01434 {
01435   ACE_OS_TRACE ("ACE_OS::mutex_lock");
01436 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
01437   abandoned = 0;
01438   switch (m->type_)
01439     {
01440     case USYNC_PROCESS:
01441       switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
01442         {
01443           //
01444           // Timeout can't occur, so don't bother checking...
01445           //
01446         case WAIT_OBJECT_0:
01447           return 0;
01448         case WAIT_ABANDONED:
01449           abandoned = 1;
01450           return 0;  // something goofed, but we hold the lock ...
01451         default:
01452           // This is a hack, we need to find an appropriate mapping...
01453           ACE_OS::set_errno_to_last_error ();
01454           return -1;
01455         }
01456     case USYNC_THREAD:
01457       return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
01458     default:
01459       errno = EINVAL;
01460       return -1;
01461     }
01462   /* NOTREACHED */
01463 #else
01464   ACE_UNUSED_ARG (m);
01465   ACE_UNUSED_ARG (abandoned);
01466   ACE_NOTSUP_RETURN (-1);
01467 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
01468 }

ACE_INLINE int ACE_OS::mutex_lock ACE_mutex_t *    m [static]
 

Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership.

Definition at line 1372 of file OS.i.

References ACE_ADAPT_RETVAL, mutex_lock, set_errno_to_last_error, and thread_mutex_lock.

Referenced by ACE_Mutex::acquire, ACE_Mutex::acquire_read, ACE_Mutex::acquire_write, event_pulse, event_reset, event_signal, event_timedwait, event_wait, flock_rdlock, flock_wrlock, ACE_Recursive_Thread_Mutex::get_nesting_level, ACE_Recursive_Thread_Mutex::get_thread_id, mutex_lock, rw_rdlock, rw_tryrdlock, rw_trywrlock, rw_trywrlock_upgrade, rw_unlock, rw_wrlock, sema_init, sema_post, sema_trywait, sema_wait, and thread_mutex_lock.

01373 {
01374   // ACE_OS_TRACE ("ACE_OS::mutex_lock");
01375 #if defined (ACE_HAS_THREADS)
01376 # if defined (ACE_HAS_PTHREADS)
01377   // Note, don't use "::" here since the following call is often a macro.
01378 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
01379   ACE_OSCALL_RETURN (pthread_mutex_lock (m), int, -1);
01380 #   else
01381   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), ace_result_),
01382                      int, -1);
01383 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
01384 # elif defined (ACE_HAS_STHREADS)
01385   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), ace_result_), int, -1);
01386 # elif defined (ACE_HAS_WTHREADS)
01387   switch (m->type_)
01388     {
01389     case USYNC_PROCESS:
01390       switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
01391         {
01392           //
01393           // Timeout can't occur, so don't bother checking...
01394           //
01395         case WAIT_OBJECT_0:
01396         case WAIT_ABANDONED:
01397           // We will ignore abandonments in this method
01398           // Note that we still hold the lock
01399           return 0;
01400         default:
01401           // This is a hack, we need to find an appropriate mapping...
01402           ACE_OS::set_errno_to_last_error ();
01403           return -1;
01404         }
01405     case USYNC_THREAD:
01406       return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
01407     default:
01408       errno = EINVAL;
01409       return -1;
01410     }
01411   /* NOTREACHED */
01412 # elif defined (ACE_PSOS)
01413 #   if defined (ACE_PSOS_HAS_MUTEX)
01414   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_lock (*m, MU_WAIT, 0),
01415                                        ace_result_),
01416                      int, -1);
01417 #   else /* ACE_PSOS_HAS_MUTEX */
01418   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_p (*m, SM_WAIT, 0),
01419                                        ace_result_),
01420                      int, -1);
01421 #   endif /* ACE_PSOS_HAS_MUTEX */
01422 # elif defined (VXWORKS)
01423   return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1;
01424 # endif /* Threads variety case */
01425 #else
01426   ACE_UNUSED_ARG (m);
01427   ACE_NOTSUP_RETURN (-1);
01428 #endif /* ACE_HAS_THREADS */
01429 }

void ACE_OS::mutex_lock_cleanup void *    mutex [static]
 

Handle asynchronous thread cancellation cleanup.

Definition at line 915 of file OS.cpp.

References ACE_OS_TRACE, and mutex_unlock.

Referenced by ace_mutex_lock_cleanup_adapter.

00916 {
00917   ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup");
00918 #if defined (ACE_HAS_THREADS)
00919 #  if defined (ACE_HAS_PTHREADS)
00920   ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex;
00921   ACE_OS::mutex_unlock (p_lock);
00922 #  else
00923   ACE_UNUSED_ARG (mutex);
00924 #  endif /* ACE_HAS_PTHREADS */
00925 # else
00926   ACE_UNUSED_ARG (mutex);
00927 # endif /* ACE_HAS_THREADS */
00928 }

ACE_INLINE int ACE_OS::mutex_trylock ACE_mutex_t *    m,
int &    abandoned
[static]
 

This method is only implemented for Win32. For abandoned mutexes, <abandoned> is set to 1 and 0 is returned.

Definition at line 1561 of file OS.i.

References EBUSY, set_errno_to_last_error, and thread_mutex_trylock.

01562 {
01563 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
01564   abandoned = 0;
01565   switch (m->type_)
01566     {
01567     case USYNC_PROCESS:
01568       {
01569         // Try for 0 milliseconds - i.e. nonblocking.
01570         switch (::WaitForSingleObject (m->proc_mutex_, 0))
01571           {
01572           case WAIT_OBJECT_0:
01573             return 0;
01574           case WAIT_ABANDONED:
01575             abandoned = 1;
01576             return 0;  // something goofed, but we hold the lock ...
01577           case WAIT_TIMEOUT:
01578             errno = EBUSY;
01579             return -1;
01580           default:
01581             ACE_OS::set_errno_to_last_error ();
01582             return -1;
01583           }
01584       }
01585     case USYNC_THREAD:
01586       return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
01587     default:
01588       errno = EINVAL;
01589       return -1;
01590     }
01591   /* NOTREACHED */
01592 #else
01593   ACE_UNUSED_ARG (m);
01594   ACE_UNUSED_ARG (abandoned);
01595   ACE_NOTSUP_RETURN (-1);
01596 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
01597 }

ACE_INLINE int ACE_OS::mutex_trylock ACE_mutex_t *    m [static]
 

Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership.

Definition at line 1471 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, EBUSY, mutex_trylock, set_errno_to_last_error, and thread_mutex_trylock.

Referenced by flock_tryrdlock, flock_trywrlock, mutex_trylock, thread_mutex_trylock, ACE_Mutex::tryacquire, ACE_Mutex::tryacquire_read, and ACE_Mutex::tryacquire_write.

01472 {
01473   ACE_OS_TRACE ("ACE_OS::mutex_trylock");
01474 #if defined (ACE_HAS_THREADS)
01475 # if defined (ACE_HAS_PTHREADS)
01476   // Note, don't use "::" here since the following call is often a macro.
01477 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
01478   int status = pthread_mutex_trylock (m);
01479   if (status == 1)
01480     status = 0;
01481   else if (status == 0) {
01482     status = -1;
01483     errno = EBUSY;
01484   }
01485   return status;
01486 #   else
01487   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), ace_result_),
01488                      int, -1);
01489 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
01490 # elif defined (ACE_HAS_STHREADS)
01491   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), ace_result_), int, -1);
01492 # elif defined (ACE_HAS_WTHREADS)
01493   switch (m->type_)
01494     {
01495     case USYNC_PROCESS:
01496       {
01497         // Try for 0 milliseconds - i.e. nonblocking.
01498         switch (::WaitForSingleObject (m->proc_mutex_, 0))
01499           {
01500           case WAIT_OBJECT_0:
01501             return 0;
01502           case WAIT_ABANDONED:
01503             // We will ignore abandonments in this method.  Note that
01504             // we still hold the lock.
01505             return 0;
01506           case WAIT_TIMEOUT:
01507             errno = EBUSY;
01508             return -1;
01509           default:
01510             ACE_OS::set_errno_to_last_error ();
01511             return -1;
01512           }
01513       }
01514     case USYNC_THREAD:
01515       return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
01516     default:
01517       errno = EINVAL;
01518       return -1;
01519     }
01520   /* NOTREACHED */
01521 # elif defined (ACE_PSOS)
01522 #   if defined (ACE_PSOS_HAS_MUTEX)
01523    ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_lock (*m, MU_NOWAIT, 0),
01524                                         ace_result_),
01525                       int, -1);
01526 #   else /* ! ACE_PSOS_HAS_MUTEX */
01527    switch (::sm_p (*m, SM_NOWAIT, 0))
01528    {
01529      case 0:
01530        return 0;
01531      case ERR_NOSEM:
01532        errno = EBUSY;
01533        // intentional fall through
01534      default:
01535        return -1;
01536    }
01537 #   endif /* ACE_PSOS_HAS_MUTEX */
01538 
01539 # elif defined (VXWORKS)
01540   if (::semTake (*m, NO_WAIT) == ERROR)
01541     if (errno == S_objLib_OBJ_UNAVAILABLE)
01542       {
01543         // couldn't get the semaphore
01544         errno = EBUSY;
01545         return -1;
01546       }
01547     else
01548       // error
01549       return -1;
01550   else
01551     // got the semaphore
01552     return 0;
01553 # endif /* Threads variety case */
01554 #else
01555   ACE_UNUSED_ARG (m);
01556   ACE_NOTSUP_RETURN (-1);
01557 #endif /* ACE_HAS_THREADS */
01558 }

ACE_INLINE int ACE_OS::mutex_unlock ACE_mutex_t *    m [static]
 

Definition at line 1710 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, mutex_unlock, and thread_mutex_unlock.

Referenced by event_pulse, event_reset, event_signal, event_timedwait, event_wait, flock_unlock, ACE_Recursive_Thread_Mutex::get_nesting_level, ACE_Recursive_Thread_Mutex::get_thread_id, mutex_lock_cleanup, mutex_unlock, ACE_Mutex::release, rw_rdlock, rw_tryrdlock, rw_trywrlock, rw_trywrlock_upgrade, rw_unlock, rw_wrlock, sema_init, sema_post, sema_trywait, sema_wait, and thread_mutex_unlock.

01711 {
01712   ACE_OS_TRACE ("ACE_OS::mutex_unlock");
01713 #if defined (ACE_HAS_THREADS)
01714 # if defined (ACE_HAS_PTHREADS)
01715   // Note, don't use "::" here since the following call is often a macro.
01716 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
01717   ACE_OSCALL_RETURN (pthread_mutex_unlock (m), int, -1);
01718 #   else
01719   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), ace_result_),
01720                      int, -1);
01721 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
01722 # elif defined (ACE_HAS_STHREADS)
01723   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), ace_result_), int, -1);
01724 # elif defined (ACE_HAS_WTHREADS)
01725   switch (m->type_)
01726     {
01727     case USYNC_PROCESS:
01728       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_),
01729                                               ace_result_),
01730                             int, -1);
01731     case USYNC_THREAD:
01732       return ACE_OS::thread_mutex_unlock (&m->thr_mutex_);
01733     default:
01734       errno = EINVAL;
01735       return -1;
01736     }
01737   /* NOTREACHED */
01738 # elif defined (ACE_PSOS)
01739 #   if defined (ACE_PSOS_HAS_MUTEX)
01740   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mu_unlock (*m), ace_result_),
01741                      int, -1);
01742 #   else /* ! ACE_PSOS_HAS_MUTEX */
01743   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sm_v (*m), ace_result_),
01744                      int, -1);
01745 #   endif /* ACE_PSOS_HAS_MUTEX */
01746 # elif defined (VXWORKS)
01747   return ::semGive (*m) == OK ? 0 : -1;
01748 # endif /* Threads variety case */
01749 #else
01750   ACE_UNUSED_ARG (m);
01751   ACE_NOTSUP_RETURN (-1);
01752 #endif /* ACE_HAS_THREADS */
01753 }

ACE_INLINE int ACE_OS::nanosleep const struct timespec   requested,
struct timespec   remaining = 0
[static]
 

Definition at line 10337 of file OS.i.

References ACE_ONE_SECOND_IN_NSECS, ACE_OS_TRACE, sleep, timespec::tv_nsec, and timespec::tv_sec.

Referenced by sleep.

10339 {
10340   ACE_OS_TRACE ("ACE_OS::nanosleep");
10341 #if defined (ACE_HAS_CLOCK_GETTIME)
10342   // ::nanosleep () is POSIX 1003.1b.  So is ::clock_gettime ().  So,
10343   // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should
10344   // be available on the platform.  On Solaris 2.x, both functions
10345   // require linking with -lposix4.
10346   return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining);
10347 #elif defined (ACE_PSOS)
10348 #  if ! defined (ACE_PSOS_DIAB_MIPS)
10349   double ticks = KC_TICKS2SEC * requested->tv_sec +
10350                  ( ACE_static_cast (double, requested->tv_nsec) *
10351                    ACE_static_cast (double, KC_TICKS2SEC) ) /
10352                  ACE_static_cast (double, ACE_ONE_SECOND_IN_NSECS);
10353 
10354   if (ticks > ACE_static_cast (double, ACE_PSOS_Time_t::max_ticks))
10355   {
10356     ticks -= ACE_static_cast (double, ACE_PSOS_Time_t::max_ticks);
10357     remaining->tv_sec = ACE_static_cast (time_t,
10358                                          (ticks /
10359                                           ACE_static_cast (double,
10360                                                            KC_TICKS2SEC)));
10361     ticks -= ACE_static_cast (double, remaining->tv_sec) *
10362              ACE_static_cast (double, KC_TICKS2SEC);
10363 
10364     remaining->tv_nsec =
10365       ACE_static_cast (long,
10366                        (ticks * ACE_static_cast (double,
10367                                                  ACE_ONE_SECOND_IN_NSECS)) /
10368                        ACE_static_cast (double, KC_TICKS2SEC));
10369 
10370     ::tm_wkafter (ACE_PSOS_Time_t::max_ticks);
10371   }
10372   else
10373   {
10374     remaining->tv_sec = 0;
10375     remaining->tv_nsec = 0;
10376     ::tm_wkafter (ACE_static_cast (u_long, ticks));
10377   }
10378 
10379   // tm_wkafter always returns 0
10380 #  endif /* ACE_PSOS_DIAB_MIPS */
10381   return 0;
10382 #else
10383   ACE_UNUSED_ARG (remaining);
10384 
10385   // Convert into seconds and microseconds.
10386 # if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS)
10387   ACE_Time_Value tv (requested->tv_sec,
10388                      requested->tv_nsec / 1000);
10389 # else
10390   ACE_Time_Value tv (requested->ts_sec,
10391                      requested->ts_nsec / 1000);
10392 # endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */
10393   return ACE_OS::sleep (tv);
10394 #endif /* ACE_HAS_CLOCK_GETTIME */
10395 }

int ACE_OS::nanosleep_i const struct timespec   requested,
struct timespec   remaining = 0
[static, private]
 

long ACE_OS::num_processors void    [static]
 

Get the number of CPUs configured in the machine.

Definition at line 7676 of file OS.cpp.

References ACE_OS_TRACE.

07677 {
07678   ACE_OS_TRACE ("ACE_OS::num_processors");
07679 
07680 #if defined (ACE_WIN32) || defined (ACE_WIN64)
07681   SYSTEM_INFO sys_info;
07682   ::GetSystemInfo (&sys_info);
07683   return sys_info.dwNumberOfProcessors;
07684 #elif defined (linux) || defined (sun)
07685   return ::sysconf (_SC_NPROCESSORS_CONF);
07686 #else
07687   ACE_NOTSUP_RETURN (-1);
07688 #endif
07689 }

long ACE_OS::num_processors_online void    [static]
 

Get the number of CPUs currently online.

Definition at line 7692 of file OS.cpp.

References ACE_OS_TRACE.

07693 {
07694   ACE_OS_TRACE ("ACE_OS::num_processors_online");
07695 
07696 #if defined (ACE_WIN32) || defined (ACE_WIN64)
07697   SYSTEM_INFO sys_info;
07698   ::GetSystemInfo (&sys_info);
07699   return sys_info.dwNumberOfProcessors;
07700 #elif defined (linux) || defined (sun)
07701   return ::sysconf (_SC_NPROCESSORS_ONLN);
07702 #elif defined (__hpux)
07703   struct pst_dynamic psd;
07704   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
07705     return psd.psd_proc_cnt;
07706   else
07707     return -1;
07708 #else
07709   ACE_NOTSUP_RETURN (-1);
07710 #endif
07711 }

ACE_HANDLE ACE_OS::open const wchar_t *    filename,
int    mode,
int    perms = ACE_DEFAULT_OPEN_PERMS,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

Definition at line 5280 of file OS.cpp.

References access, ACE_BIT_ENABLED, ACE_MT, default_win32_security_attributes, open, ACE_OS_Object_Manager::preallocated_object, thread_mutex_lock, and thread_mutex_unlock.

05284 {
05285 #if defined (ACE_WIN32)
05286   // @@ (brunsch) Yuck, maybe there is a way to combine the code
05287   // here with the char version
05288 
05289   DWORD access = GENERIC_READ;
05290   if (ACE_BIT_ENABLED (mode, O_WRONLY))
05291     access = GENERIC_WRITE;
05292   else if (ACE_BIT_ENABLED (mode, O_RDWR))
05293     access = GENERIC_READ | GENERIC_WRITE;
05294 
05295   DWORD creation = OPEN_EXISTING;
05296 
05297   if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
05298     creation = CREATE_NEW;
05299   else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
05300     creation = CREATE_ALWAYS;
05301   else if (ACE_BIT_ENABLED (mode, _O_CREAT))
05302     creation = OPEN_ALWAYS;
05303   else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
05304     creation = TRUNCATE_EXISTING;
05305 
05306   DWORD flags = 0;
05307 
05308   if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
05309     flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
05310 
05311   if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
05312     flags |= FILE_FLAG_WRITE_THROUGH;
05313   if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
05314     flags |= FILE_FLAG_OVERLAPPED;
05315   if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
05316     flags |= FILE_FLAG_NO_BUFFERING;
05317   if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
05318     flags |= FILE_FLAG_RANDOM_ACCESS;
05319   if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
05320     flags |= FILE_FLAG_SEQUENTIAL_SCAN;
05321   if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
05322     flags |= FILE_FLAG_DELETE_ON_CLOSE;
05323   if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
05324     flags |= FILE_FLAG_BACKUP_SEMANTICS;
05325   if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
05326     flags |= FILE_FLAG_POSIX_SEMANTICS;
05327 
05328   ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
05329 
05330   if (ACE_BIT_ENABLED (mode, _O_APPEND))
05331     {
05332       ACE_MT
05333         (
05334           ace_os_monitor_lock = (ACE_thread_mutex_t *)
05335             ACE_OS_Object_Manager::preallocated_object[
05336               ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK];
05337           ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
05338         )
05339     }
05340 
05341   DWORD shared_mode = perms;
05342 
05343   ACE_HANDLE h = ::CreateFileW (filename,
05344                                 access,
05345                                 shared_mode,
05346                                 ACE_OS::default_win32_security_attributes (sa),
05347                                 creation,
05348                                 flags,
05349                                 0);
05350 
05351   if (ACE_BIT_ENABLED (mode, _O_APPEND))
05352     {
05353       if (h != ACE_INVALID_HANDLE)
05354         {
05355           ::SetFilePointer (h, 0, 0, FILE_END);
05356         }
05357 
05358       ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
05359     }
05360 
05361   if (h == ACE_INVALID_HANDLE)
05362     ACE_FAIL_RETURN (h);
05363   else
05364     return h;
05365 #else /* ACE_WIN32 */
05366   // Just emulate with ascii version
05367   return ACE_OS::open (ACE_Wide_To_Ascii (filename).char_rep (),
05368                        mode,
05369                        perms,
05370                        sa);
05371 #endif /* ACE_WIN32 */
05372 }

ACE_HANDLE ACE_OS::open const char *    filename,
int    mode,
int    perms = ACE_DEFAULT_OPEN_PERMS,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

The O_APPEND flag is only partly supported on Win32. If you specify O_APPEND, then the file pointer will be positioned at the end of the file initially during open, but it is not re-positioned at the end prior to each write, as specified by POSIX. This is generally good enough for typical situations, but it is ``not quite right'' in its semantics.

Definition at line 5139 of file OS.cpp.

References access, ACE_BIT_ENABLED, ACE_MT, ACE_OS_TRACE, default_win32_security_attributes, open, ACE_OS_Object_Manager::preallocated_object, thread_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Filecache_Object::ACE_Filecache_Object, ACE_SPIPE_Connector::connect, ACE_Handle_Gobbler::consume_handles, creat, filesize, flock_init, fopen, ACE_Sock_Connect::get_handle, ACE_Handle_Ops::handle_timed_open, open, ACE_Mem_Map::open, ACE_FIFO_Recv::open, ACE_FIFO::open, ACE_Dev_Poll_Reactor::open, ACE_Lib_Find::open_temp_file, ACE_Filecache_Object::release, shm_open, and truncate.

05143 {
05144   ACE_OS_TRACE ("ACE_OS::open");
05145 
05146 #if defined (ACE_WIN32)
05147   DWORD access = GENERIC_READ;
05148   if (ACE_BIT_ENABLED (mode, O_WRONLY))
05149     access = GENERIC_WRITE;
05150   else if (ACE_BIT_ENABLED (mode, O_RDWR))
05151     access = GENERIC_READ | GENERIC_WRITE;
05152 
05153   DWORD creation = OPEN_EXISTING;
05154 
05155   if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
05156     creation = CREATE_NEW;
05157   else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
05158     creation = CREATE_ALWAYS;
05159   else if (ACE_BIT_ENABLED (mode, _O_CREAT))
05160     creation = OPEN_ALWAYS;
05161   else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
05162     creation = TRUNCATE_EXISTING;
05163 
05164   DWORD flags = 0;
05165 
05166   if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
05167     flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
05168 
05169   if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
05170     flags |= FILE_FLAG_WRITE_THROUGH;
05171   if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
05172     flags |= FILE_FLAG_OVERLAPPED;
05173   if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
05174     flags |= FILE_FLAG_NO_BUFFERING;
05175   if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
05176     flags |= FILE_FLAG_RANDOM_ACCESS;
05177   if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
05178     flags |= FILE_FLAG_SEQUENTIAL_SCAN;
05179   if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
05180     flags |= FILE_FLAG_DELETE_ON_CLOSE;
05181   if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
05182     flags |= FILE_FLAG_BACKUP_SEMANTICS;
05183   if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
05184     flags |= FILE_FLAG_POSIX_SEMANTICS;
05185 
05186   ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
05187 
05188   if (ACE_BIT_ENABLED (mode, _O_APPEND))
05189     {
05190       ACE_MT
05191         (
05192           ace_os_monitor_lock = (ACE_thread_mutex_t *)
05193             ACE_OS_Object_Manager::preallocated_object[
05194               ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK];
05195           ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
05196         )
05197     }
05198 
05199   DWORD shared_mode = perms;
05200 
05201 #if defined (ACE_HAS_WINCE)
05202   ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (), access,
05203                                 shared_mode,
05204                                 ACE_OS::default_win32_security_attributes (sa),
05205                                 creation,
05206                                 flags,
05207                                 0);
05208 #else /* ACE_HAS_WINCE */
05209   ACE_HANDLE h = ::CreateFileA (filename, access,
05210                                 shared_mode,
05211                                 ACE_OS::default_win32_security_attributes (sa),
05212                                 creation,
05213                                 flags,
05214                                 0);
05215 #endif /* ACE_HAS_WINCE */
05216 
05217   if (ACE_BIT_ENABLED (mode, _O_APPEND))
05218     {
05219       if (h != ACE_INVALID_HANDLE)
05220         {
05221           ::SetFilePointer (h, 0, 0, FILE_END);
05222         }
05223 
05224       ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
05225     }
05226 
05227   if (h == ACE_INVALID_HANDLE) {
05228     ACE_FAIL_RETURN (h);
05229   } else {
05230     return h;
05231   }
05232 #elif defined (ACE_PSOS)
05233   ACE_UNUSED_ARG (perms);
05234   ACE_UNUSED_ARG (sa);
05235 # if defined (ACE_PSOS_LACKS_PHILE)
05236   ACE_UNUSED_ARG (filename);
05237   return 0;
05238 # else
05239   unsigned long result, handle;
05240   result = ::open_f (&handle, ACE_const_cast(char *, filename), 0);
05241   if (result != 0)
05242     {
05243       // We need to clean this up...not 100% correct!
05244       // To correct we should handle all the cases of TRUNC and CREAT
05245       if ((result == 0x200B) && (ACE_BIT_ENABLED (mode, O_CREAT)))
05246         {
05247           result = ::create_f(ACE_const_cast(char *, filename),1,0);
05248           if (result != 0)
05249             {
05250               errno = result;
05251               return ACE_static_cast (ACE_HANDLE, -1);
05252             }
05253           else  //File created...try to open it again
05254             {
05255               result = ::open_f (&handle, ACE_const_cast(char *, filename), 0);
05256               if (result != 0)
05257                 {
05258                   errno = result;
05259                   return ACE_static_cast (ACE_HANDLE, -1);
05260                 }
05261 
05262             }
05263         }
05264       else
05265         {
05266           errno = result;
05267           return ACE_static_cast (ACE_HANDLE, -1);
05268         }
05269     }
05270   return ACE_static_cast (ACE_HANDLE, handle);
05271 # endif /* defined (ACE_PSOS_LACKS_PHILE) */
05272 #else
05273   ACE_UNUSED_ARG (sa);
05274   ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1);
05275 #endif /* ACE_WIN32 */
05276 }

ACE_INLINE void ACE_OS::perror const ACE_TCHAR   s [static]
 

Definition at line 6338 of file OS.i.

References ACE_OS_TRACE, and ACE_TCHAR.

Referenced by ACE_ATM_Stream::get_peer_name, and ACE_ATM_Acceptor::open.

06339 {
06340   ACE_OS_TRACE ("ACE_OS::perror");
06341 #if defined (ACE_HAS_WINCE)
06342   // @@ WINCE: How should this be handled
06343   ACE_UNUSED_ARG (s);
06344 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
06345   ::_wperror (s);
06346 #else
06347   ::perror (s);
06348 #endif /* ACE_HAS_WINCE */
06349 }

ACE_INLINE int ACE_OS::pipe ACE_HANDLE    handles[] [static]
 

Definition at line 381 of file OS.i.

References ACE_OS_TRACE, and pipe.

Referenced by ACE_SPIPE_Acceptor::create_new_instance, ACE_Pipe::open, and pipe.

00382 {
00383   ACE_OS_TRACE ("ACE_OS::pipe");
00384 # if defined (VXWORKS) || defined (ACE_PSOS)
00385   ACE_UNUSED_ARG (fds);
00386   ACE_NOTSUP_RETURN (-1);
00387 # else
00388   ACE_OSCALL_RETURN (::pipe (fds), int, -1);
00389 # endif /* VXWORKS || ACE_PSOS */
00390 }

ACE_INLINE int ACE_OS::poll struct pollfd *    pollfds,
u_long    len,
const ACE_Time_Value   tv
[static]
 

Definition at line 7622 of file OS.i.

References ACE_OS_TRACE, ACE_Time_Value::msec, and poll.

07623 {
07624   ACE_OS_TRACE ("ACE_OS::poll");
07625 #if defined (ACE_HAS_POLL)
07626   ACE_OSCALL_RETURN (::poll (pollfds, len, int (timeout.msec ())), int, -1);
07627 #else
07628   ACE_UNUSED_ARG (timeout);
07629   ACE_UNUSED_ARG (len);
07630   ACE_UNUSED_ARG (pollfds);
07631 
07632   ACE_NOTSUP_RETURN (-1);
07633 #endif /* ACE_HAS_POLL */
07634 }

ACE_INLINE int ACE_OS::poll struct pollfd *    pollfds,
u_long    len,
const ACE_Time_Value   tv = 0
[static]
 

Definition at line 7606 of file OS.i.

References ACE_OS_TRACE, ACE_Time_Value::msec, and poll.

Referenced by ACE::handle_ready, ACE::handle_timed_accept, ACE::handle_timed_complete, and poll.

07607 {
07608   ACE_OS_TRACE ("ACE_OS::poll");
07609 #if defined (ACE_HAS_POLL)
07610   int to = timeout == 0 ? -1 : int (timeout->msec ());
07611   ACE_OSCALL_RETURN (::poll (pollfds, len, to), int, -1);
07612 #else
07613   ACE_UNUSED_ARG (timeout);
07614   ACE_UNUSED_ARG (len);
07615   ACE_UNUSED_ARG (pollfds);
07616 
07617   ACE_NOTSUP_RETURN (-1);
07618 #endif /* ACE_HAS_POLL */
07619 }

int ACE_OS::poll_i struct pollfd *    pollfds,
u_long    len,
const ACE_Time_Value   tv
[static, private]
 

int ACE_OS::poll_i struct pollfd *    pollfds,
u_long    len,
const ACE_Time_Value   tv = 0
[static, private]
 

ssize_t ACE_OS::pread ACE_HANDLE    handle,
void *    buf,
size_t    nbyte,
off_t    offset
[static]
 

Definition at line 4895 of file OS.cpp.

References ACE_OS_GUARD, lseek, read, and ssize_t.

04899 {
04900 # if defined (ACE_HAS_P_READ_WRITE)
04901 #   if defined (ACE_WIN32)
04902 
04903   ACE_OS_GUARD
04904 
04905   // Remember the original file pointer position
04906   DWORD original_position = ::SetFilePointer (handle,
04907                                               0,
04908                                               0,
04909                                               FILE_CURRENT);
04910 
04911   if (original_position == 0xFFFFFFFF)
04912     return -1;
04913 
04914   // Go to the correct position
04915   DWORD altered_position = ::SetFilePointer (handle,
04916                                              offset,
04917                                              0,
04918                                              FILE_BEGIN);
04919   if (altered_position == 0xFFFFFFFF)
04920     return -1;
04921 
04922   DWORD bytes_read;
04923 
04924 #     if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
04925 
04926   OVERLAPPED overlapped;
04927   overlapped.Internal = 0;
04928   overlapped.InternalHigh = 0;
04929   overlapped.Offset = offset;
04930   overlapped.OffsetHigh = 0;
04931   overlapped.hEvent = 0;
04932 
04933   BOOL result = ::ReadFile (handle,
04934                             buf,
04935                             ACE_static_cast (DWORD, nbytes),
04936                             &bytes_read,
04937                             &overlapped);
04938 
04939   if (result == FALSE)
04940     {
04941       if (::GetLastError () != ERROR_IO_PENDING)
04942         return -1;
04943 
04944       else
04945         {
04946           result = ::GetOverlappedResult (handle,
04947                                           &overlapped,
04948                                           &bytes_read,
04949                                           TRUE);
04950           if (result == FALSE)
04951             return -1;
04952         }
04953     }
04954 
04955 #     else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
04956 
04957   BOOL result = ::ReadFile (handle,
04958                             buf,
04959                             nbytes,
04960                             &bytes_read,
04961                             0);
04962   if (result == FALSE)
04963     return -1;
04964 
04965 #     endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
04966 
04967   // Reset the original file pointer position
04968   if (::SetFilePointer (handle,
04969                         original_position,
04970                         0,
04971                         FILE_BEGIN) == 0xFFFFFFFF)
04972     return -1;
04973 
04974   return (ssize_t) bytes_read;
04975 
04976 #   else /* ACE_WIN32 */
04977 
04978   return ::pread (handle, buf, nbytes, offset);
04979 
04980 #   endif /* ACE_WIN32 */
04981 
04982 # else /* ACE_HAS_P_READ_WRITE */
04983 
04984   ACE_OS_GUARD
04985 
04986   // Remember the original file pointer position
04987   off_t original_position = ACE_OS::lseek (handle,
04988                                            0,
04989                                            SEEK_CUR);
04990 
04991   if (original_position == -1)
04992     return -1;
04993 
04994   // Go to the correct position
04995   off_t altered_position = ACE_OS::lseek (handle,
04996                                           offset,
04997                                           SEEK_SET);
04998 
04999   if (altered_position == -1)
05000     return -1;
05001 
05002   ssize_t bytes_read = ACE_OS::read (handle,
05003                                      buf,
05004                                      nbytes);
05005 
05006   if (bytes_read == -1)
05007     return -1;
05008 
05009   if (ACE_OS::lseek (handle,
05010                      original_position,
05011                      SEEK_SET) == -1)
05012     return -1;
05013 
05014   return bytes_read;
05015 
05016 # endif /* ACE_HAD_P_READ_WRITE */
05017 }

int ACE_OS::printf const char *    format,
...   
[static]
 

Definition at line 1055 of file OS.cpp.

References ACE_OS_TRACE.

Referenced by ACE_ATM_Acceptor::accept, ACE_ATM_Connector::add_leaf, ACE_ATM_Connector::connect, ACE_ATM_Acceptor::get_local_addr, ACE_ATM_Stream::get_vpi_vci, mkdir, ACE_ATM_Stream::open, ACE_ATM_Acceptor::open, ACE_ATM_QoS::set_cbr_rate, and ACE_ATM_Addr::string_to_addr.

01056 {
01057   ACE_OS_TRACE ("ACE_OS::printf");
01058   int result;
01059   va_list ap;
01060   va_start (ap, format);
01061   ACE_OSCALL (::vprintf (format, ap), int, -1, result);
01062   va_end (ap);
01063   return result;
01064 }

ACE_INLINE int ACE_OS::priority_control ACE_idtype_t   ,
ACE_id_t   ,
int   ,
void *   
[static]
 

Low-level interface to <priocntl>(2).

Can't call the following priocntl, because that's a macro on Solaris.

Definition at line 7440 of file OS.i.

References ACE_id_t, ACE_idtype_t, ACE_OS_TRACE, and caddr_t.

Referenced by lwp_getparams, ACE_Sched_Params::priority_max, ACE_Sched_Params::priority_min, scheduling_class, and set_scheduling_params.

07441 {
07442   ACE_OS_TRACE ("ACE_OS::priority_control");
07443 #if defined (ACE_HAS_PRIOCNTL)
07444   ACE_OSCALL_RETURN (priocntl (idtype, id, cmd, ACE_static_cast (caddr_t, arg)),
07445                      int, -1);
07446 #else  /* ! ACE_HAS_PRIOCNTL*/
07447   ACE_UNUSED_ARG (idtype);
07448   ACE_UNUSED_ARG (id);
07449   ACE_UNUSED_ARG (cmd);
07450   ACE_UNUSED_ARG (arg);
07451   ACE_NOTSUP_RETURN (-1);
07452 #endif /* ! ACE_HAS_PRIOCNTL*/
07453 }

ACE_INLINE int ACE_OS::pthread_sigmask int    how,
const sigset_t *    nsp,
sigset_t *    osp
[static]
 

Definition at line 10848 of file OS.i.

References ACE_ADAPT_RETVAL, and pthread_sigmask.

Referenced by pthread_sigmask, ACE_Asynch_Pseudo_Task::svc, and thr_sigsetmask.

10849 {
10850 #if defined (ACE_HAS_PTHREADS_STD)  &&  !defined (ACE_LACKS_PTHREAD_SIGMASK)
10851   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp),
10852                                        ace_result_),
10853                      int,
10854                      -1);
10855 #else /* !ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */
10856   ACE_UNUSED_ARG (how);
10857   ACE_UNUSED_ARG (nsp);
10858   ACE_UNUSED_ARG (osp);
10859   ACE_NOTSUP_RETURN (-1);
10860 #endif /* ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */
10861 }

ACE_INLINE int ACE_OS::putenv const ACE_TCHAR   string [static]
 

Definition at line 10490 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and putenv.

Referenced by putenv, and ACE_Process::spawn.

10491 {
10492   ACE_OS_TRACE ("ACE_OS::putenv");
10493 #if defined (ACE_HAS_WINCE) || defined (ACE_PSOS)
10494   // WinCE and pSOS don't have the concept of environment variables.
10495   ACE_UNUSED_ARG (string);
10496   ACE_NOTSUP_RETURN (-1);
10497 #elif defined (ACE_LACKS_ENV)
10498   ACE_UNUSED_ARG (string);
10499   ACE_NOTSUP_RETURN (0);
10500 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
10501   ACE_OSCALL_RETURN (::_wputenv (string), int, -1);
10502 #else /* ! ACE_HAS_WINCE && ! ACE_PSOS */
10503   // VxWorks declares ::putenv with a non-const arg.
10504   ACE_OSCALL_RETURN (::putenv ((char *) string), int, -1);
10505 #endif /* ACE_HAS_WINCE */
10506 }

ACE_INLINE int ACE_OS::putmsg ACE_HANDLE    handle,
const struct strbuf   ctl,
const struct strbuf   data,
int    flags
[static]
 

Definition at line 8489 of file OS.i.

References ACE_NEW_RETURN, ACE_OS_TRACE, strbuf::buf, strbuf::len, ACE_OS_String::memcpy, putmsg, and write.

Referenced by putmsg, putpmsg, ACE_SPIPE_Stream::send, and ACE_FIFO_Send_Msg::send.

08491 {
08492   ACE_OS_TRACE ("ACE_OS::putmsg");
08493 #if defined (ACE_HAS_STREAM_PIPES)
08494   ACE_OSCALL_RETURN (::putmsg (handle,
08495                                (ACE_STRBUF_TYPE) ctl,
08496                                (ACE_STRBUF_TYPE) data,
08497                                flags), int, -1);
08498 #else
08499   ACE_UNUSED_ARG (flags);
08500   if (ctl == 0 && data == 0)
08501     {
08502       errno = EINVAL;
08503       return 0;
08504     }
08505   // Handle the two easy cases.
08506   else if (ctl != 0)
08507     return ACE_OS::write (handle, ctl->buf, ctl->len);
08508   else if (data != 0)
08509     return ACE_OS::write (handle, data->buf, data->len);
08510   else
08511     {
08512       // This is the hard case.
08513       char *buf;
08514       ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
08515       ACE_OS::memcpy (buf, ctl->buf, ctl->len);
08516       ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
08517       int result = ACE_OS::write (handle, buf, ctl->len + data->len);
08518       delete [] buf;
08519       return result;
08520     }
08521 #endif /* ACE_HAS_STREAM_PIPES */
08522 }

ACE_INLINE int ACE_OS::putpmsg ACE_HANDLE    handle,
const struct strbuf   ctl,
const struct strbuf   data,
int    band,
int    flags
[static]
 

Definition at line 8525 of file OS.i.

References ACE_OS_TRACE, putmsg, and putpmsg.

Referenced by putpmsg, and ACE_SPIPE_Stream::send.

08530 {
08531   ACE_OS_TRACE ("ACE_OS::putpmsg");
08532 #if defined (ACE_HAS_STREAM_PIPES)
08533   ACE_OSCALL_RETURN (::putpmsg (handle,
08534                                 (ACE_STRBUF_TYPE) ctl,
08535                                 (ACE_STRBUF_TYPE) data,
08536                                 band, flags), int, -1);
08537 #else
08538   ACE_UNUSED_ARG (flags);
08539   ACE_UNUSED_ARG (band);
08540   return ACE_OS::putmsg (handle, ctl, data, flags);
08541 #endif /* ACE_HAS_STREAM_PIPES */
08542 }

ACE_INLINE int ACE_OS::puts const ACE_TCHAR   s [static]
 

Definition at line 6352 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and puts.

Referenced by puts.

06353 {
06354   ACE_OS_TRACE ("ACE_OS::puts");
06355 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
06356   ACE_OSCALL_RETURN (::_putws (s), int, -1);
06357 #else /* ACE_WIN32 */
06358   ACE_OSCALL_RETURN (::puts (s), int, -1);
06359 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
06360 }

ssize_t ACE_OS::pwrite ACE_HANDLE    handle,
const void *    buf,
size_t    nbyte,
off_t    offset
[static]
 

Definition at line 5020 of file OS.cpp.

References ACE_OS_GUARD, lseek, ssize_t, and write.

Referenced by ACE_Filecache_Object::ACE_Filecache_Object, and ACE_Mem_Map::map_it.

05024 {
05025 # if defined (ACE_HAS_P_READ_WRITE)
05026 #   if defined (ACE_WIN32)
05027 
05028   ACE_OS_GUARD
05029 
05030   // Remember the original file pointer position
05031   DWORD original_position = ::SetFilePointer (handle,
05032                                               0,
05033                                               0,
05034                                               FILE_CURRENT);
05035 
05036   if (original_position == 0xFFFFFFFF)
05037     return -1;
05038 
05039   // Go to the correct position
05040   DWORD altered_position = ::SetFilePointer (handle,
05041                                              offset,
05042                                              0,
05043                                              FILE_BEGIN);
05044   if (altered_position == 0xFFFFFFFF)
05045     return -1;
05046 
05047   DWORD bytes_written;
05048 
05049 #     if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
05050 
05051   OVERLAPPED overlapped;
05052   overlapped.Internal = 0;
05053   overlapped.InternalHigh = 0;
05054   overlapped.Offset = offset;
05055   overlapped.OffsetHigh = 0;
05056   overlapped.hEvent = 0;
05057 
05058   BOOL result = ::WriteFile (handle,
05059                              buf,
05060                              ACE_static_cast (DWORD, nbytes),
05061                              &bytes_written,
05062                              &overlapped);
05063 
05064   if (result == FALSE)
05065     {
05066       if (::GetLastError () != ERROR_IO_PENDING)
05067         return -1;
05068 
05069       else
05070         {
05071           result = ::GetOverlappedResult (handle,
05072                                           &overlapped,
05073                                           &bytes_written,
05074                                           TRUE);
05075           if (result == FALSE)
05076             return -1;
05077         }
05078     }
05079 
05080 #     else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
05081 
05082   BOOL result = ::WriteFile (handle,
05083                              buf,
05084                              nbytes,
05085                              &bytes_written,
05086                              0);
05087   if (result == FALSE)
05088     return -1;
05089 
05090 #     endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
05091 
05092   // Reset the original file pointer position
05093   if (::SetFilePointer (handle,
05094                         original_position,
05095                         0,
05096                         FILE_BEGIN) == 0xFFFFFFFF)
05097     return -1;
05098 
05099   return (ssize_t) bytes_written;
05100 
05101 #   else /* ACE_WIN32 */
05102 
05103   return ::pwrite (handle, buf, nbytes, offset);
05104 #   endif /* ACE_WIN32 */
05105 # else /* ACE_HAS_P_READ_WRITE */
05106 
05107   ACE_OS_GUARD
05108 
05109   // Remember the original file pointer position
05110   off_t original_position = ACE_OS::lseek (handle,
05111                                            0,
05112                                            SEEK_CUR);
05113   if (original_position == -1)
05114     return -1;
05115 
05116   // Go to the correct position
05117   off_t altered_position = ACE_OS::lseek (handle,
05118                                           offset,
05119                                           SEEK_SET);
05120   if (altered_position == -1)
05121     return -1;
05122 
05123   ssize_t bytes_written = ACE_OS::write (handle,
05124                                          buf,
05125                                          nbytes);
05126   if (bytes_written == -1)
05127     return -1;
05128 
05129   if (ACE_OS::lseek (handle,
05130                      original_position,
05131                      SEEK_SET) == -1)
05132     return -1;
05133 
05134   return bytes_written;
05135 # endif /* ACE_HAD_P_READ_WRITE */
05136 }

ACE_INLINE void ACE_OS::qsort void *    base,
size_t    nel,
size_t    width,
ACE_COMPARE_FUNC   
[static]
 

Definition at line 10906 of file OS.i.

References ACE_COMPARE_FUNC.

Referenced by ACE_OS_Dirent::scandir_emulation.

10910 {
10911 #if !defined (ACE_LACKS_QSORT)
10912   ::qsort (base, nel, width, compar);
10913 #else
10914   ACE_UNUSED_ARG (base);
10915   ACE_UNUSED_ARG (nel);
10916   ACE_UNUSED_ARG (width);
10917   ACE_UNUSED_ARG (compar);
10918 #endif /* !ACE_LACKS_QSORT */
10919 }

ACE_INLINE int ACE_OS::rand void    [static]
 

Definition at line 764 of file OS.i.

References ACE_OS_TRACE, and rand.

Referenced by rand, and rand_r.

00765 {
00766   ACE_OS_TRACE ("ACE_OS::rand");
00767   ACE_OSCALL_RETURN (::rand (), int, -1);
00768 }

ACE_INLINE int ACE_OS::rand_r ACE_RANDR_TYPE   seed [static]
 

Definition at line 414 of file OS.i.

References ACE_OS_TRACE, ACE_RANDR_TYPE, rand, and rand_r.

Referenced by rand_r.

00415 {
00416   ACE_OS_TRACE ("ACE_OS::rand_r");
00417 # if defined (ACE_HAS_REENTRANT_FUNCTIONS) && \
00418     !defined (ACE_LACKS_RAND_REENTRANT_FUNCTIONS)
00419 #   if defined (DIGITAL_UNIX)
00420   ACE_OSCALL_RETURN (::_Prand_r (&seed), int, -1);
00421 #   elif defined (HPUX_10)
00422   // rand() is thread-safe on HP-UX 10.  rand_r's signature is not consistent
00423   // with latest POSIX and will change in a future HP-UX release so that it
00424   // is consistent.  At that point, this #elif section can be changed or
00425   // removed, and just call rand_r.
00426   ACE_UNUSED_ARG (seed);
00427   ACE_OSCALL_RETURN (::rand(), int, -1);
00428 #   elif defined (ACE_HAS_BROKEN_RANDR)
00429   ACE_OSCALL_RETURN (::rand_r (seed), int, -1);
00430 #   else
00431   ACE_OSCALL_RETURN (::rand_r (&seed), int, -1);
00432 #   endif /* DIGITAL_UNIX */
00433 # else
00434   ACE_UNUSED_ARG (seed);
00435   ACE_OSCALL_RETURN (::rand (), int, -1);
00436 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00437 }

ACE_INLINE ssize_t ACE_OS::read ACE_HANDLE    handle,
void *    buf,
size_t    len,
ACE_OVERLAPPED  
[static]
 

Definition at line 8280 of file OS.i.

References ACE_OS_TRACE, ACE_OVERLAPPED, and read.

08282 {
08283   ACE_OS_TRACE ("ACE_OS::read");
08284   overlapped = overlapped;
08285 #if defined (ACE_WIN32)
08286   DWORD ok_len;
08287   DWORD short_len = ACE_static_cast (DWORD, len);
08288   if (::ReadFile (handle, buf, short_len, &ok_len, overlapped))
08289     return (ssize_t) ok_len;
08290   else
08291     ACE_FAIL_RETURN (-1);
08292 #else
08293   return ACE_OS::read (handle, buf, len);
08294 #endif /* ACE_WIN32 */
08295 }

ACE_INLINE ssize_t ACE_OS::read ACE_HANDLE    handle,
void *    buf,
size_t    len
[static]
 

Definition at line 8241 of file OS.i.

References ACE_OS_TRACE, EWOULDBLOCK, read, and ssize_t.

Referenced by ACE_UPIPE_Acceptor::accept, pread, read, read_n, ACE_SPIPE_Stream::recv, ACE_SOCK_IO::recv, ACE_FILE_IO::recv, ACE_FIFO_Recv_Msg::recv, ACE_FIFO_Recv::recv, ACE_DEV_IO::recv, and ACE::recv_i.

08242 {
08243   ACE_OS_TRACE ("ACE_OS::read");
08244 #if defined (ACE_WIN32)
08245   DWORD ok_len;
08246   if (::ReadFile (handle, buf, ACE_static_cast (DWORD, len), &ok_len, 0))
08247     return (ssize_t) ok_len;
08248   else
08249     ACE_FAIL_RETURN (-1);
08250 #elif defined (ACE_PSOS)
08251 # if defined (ACE_PSOS_LACKS_PHILE)
08252   ACE_UNUSED_ARG (handle);
08253   ACE_UNUSED_ARG (buf);
08254   ACE_UNUSED_ARG (len);
08255   ACE_NOTSUP_RETURN (-1);
08256 # else
08257   u_long count;
08258   u_long result = ::read_f (handle, buf, len, &count);
08259   if (result != 0)
08260     return ACE_static_cast (ssize_t, -1);
08261   else
08262     return ACE_static_cast (ssize_t, count == len ? count : 0);
08263 # endif /* defined (ACE_PSOS_LACKS_PHILE */
08264 #else
08265 
08266   int result;
08267 
08268 # if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_HAS_CHARPTR_SOCKOPT)
08269   ACE_OSCALL (::read (handle, (char *) buf, len), ssize_t, -1, result);
08270 # else
08271   ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result);
08272 # endif /* ACE_LACKS_POSIX_PROTOTYPES */
08273   if (result == -1 && errno == EAGAIN)
08274     errno = EWOULDBLOCK;
08275   return result;
08276 #endif /* ACE_WIN32 */
08277 }

ssize_t ACE_OS::read_n ACE_HANDLE    handle,
void *    buf,
size_t    len,
size_t *    bytes_transferred = 0
[static]
 

Receive <len> bytes into <buf> from <handle> (uses the <ACE_OS::read> call, which uses the <read> system call on UNIX and the <ReadFile> call on Win32). If errors occur, -1 is returned. If EOF occurs, 0 is returned. Whatever data has been transmitted will be returned to the caller through <bytes_transferred>.

Definition at line 4177 of file OS.cpp.

References read, and ssize_t.

Referenced by ACE::read_n.

04181 {
04182   size_t temp;
04183   size_t &bytes_transferred = bt == 0 ? temp : *bt;
04184   ssize_t n;
04185 
04186   for (bytes_transferred = 0;
04187        bytes_transferred < len;
04188        bytes_transferred += n)
04189     {
04190       n = ACE_OS::read (handle,
04191                         (char *) buf + bytes_transferred,
04192                         len - bytes_transferred);
04193 
04194       if (n == -1 || n == 0)
04195         return n;
04196     }
04197 
04198   return bytes_transferred;
04199 }

ACE_INLINE int ACE_OS::readlink const char *    path,
char *    buf,
size_t    bufsiz
[static]
 

Definition at line 8298 of file OS.i.

References ACE_OS_TRACE, and readlink.

Referenced by readlink.

08299 {
08300   ACE_OS_TRACE ("ACE_OS::readlink");
08301 # if defined (ACE_LACKS_READLINK) || \
08302      defined (ACE_HAS_WINCE) || defined (ACE_WIN32)
08303   ACE_UNUSED_ARG (path);
08304   ACE_UNUSED_ARG (buf);
08305   ACE_UNUSED_ARG (bufsiz);
08306   ACE_NOTSUP_RETURN (-1);
08307 # else
08308 #   if !defined(ACE_HAS_NONCONST_READLINK)
08309       ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), int, -1);
08310 #   else
08311       ACE_OSCALL_RETURN (::readlink ((char *)path, buf, bufsiz), int, -1);
08312 #   endif
08313 # endif /* ACE_LACKS_READLINK */
08314 }

ACE_INLINE ssize_t ACE_OS::readv ACE_HANDLE    handle,
iovec   iov,
int    iovlen
[static]
 

Definition at line 7468 of file OS.i.

References ACE_OS_TRACE, readv, and ssize_t.

Referenced by readv, ACE::readv_n, ACE_SPIPE_Stream::recv, ACE_FILE_IO::recv, ACE_DEV_IO::recv, recvv, ACE_SPIPE_Stream::recvv_n, and ACE_FILE_IO::recvv_n.

07471 {
07472   ACE_OS_TRACE ("ACE_OS::readv");
07473 #if defined (ACE_LACKS_READV)
07474   ACE_OSCALL_RETURN (ACE_OS::readv_emulation (handle, iov, iovlen),
07475                      ssize_t,
07476                      -1);
07477 #else /* ACE_LACKS_READV */
07478   ACE_OSCALL_RETURN (::readv (handle, iov, iovlen), ssize_t, -1);
07479 #endif /* ACE_LACKS_READV */
07480 }

ACE_INLINE void ACE_OS::recursive_mutex_cond_relock ACE_recursive_thread_mutex_t   m,
ACE_recursive_mutex_state   state
[static]
 

Definition at line 2710 of file OS.i.

References ACE_OS_TRACE, cond_wait, ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_mutex_state::nesting_level_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_mutex_state::owner_id_, ACE_recursive_thread_mutex_t::owner_id_, recursive_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Condition< ACE_Recursive_Thread_Mutex >::wait.

02712 {
02713 #if defined (ACE_HAS_THREADS)
02714   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock");
02715 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
02716   // Windows need special handling since it has recursive mutexes, but
02717   // does not integrate them into a condition variable.
02718   // On entry, the OS has already reacquired the lock for us. Just
02719   // reacquire it the proper number of times so the recursion is the same as
02720   // before waiting on the condition.
02721 #    if defined (ACE_WIN32)
02722   while (state.relock_count_ > 0)
02723     {
02724       ACE_OS::recursive_mutex_lock (m);
02725       --state.relock_count_;
02726     }
02727   return;
02728 #    else /* not ACE_WIN32 */
02729     // prevent warnings for unused variables
02730     ACE_UNUSED_ARG (state);
02731     ACE_UNUSED_ARG (m);
02732 
02733 #    endif /* ACE_WIN32 */
02734 #  else
02735   // Without recursive mutex support, it's somewhat trickier. On entry,
02736   // the current thread holds the nesting_mutex_, but another thread may
02737   // still be holding the ACE_recursive_mutex_t. If so, mimic the code
02738   // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex.
02739   // After acquiring it, restore the nesting counts and release the
02740   // nesting mutex. This will restore the conditions to what they were
02741   // before calling ACE_OS::recursive_mutex_cond_unlock().
02742   while (m->nesting_level_ > 0)
02743     ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_);
02744 
02745   // At this point, we still have nesting_mutex_ and the mutex is free.
02746   m->nesting_level_ = state.nesting_level_;
02747   m->owner_id_ = state.owner_id_;
02748   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
02749   return;
02750 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
02751 #else
02752   ACE_UNUSED_ARG (m);
02753   ACE_UNUSED_ARG (state);
02754   return;
02755 #endif /* ACE_HAS_THREADS */
02756 }

ACE_INLINE int ACE_OS::recursive_mutex_cond_unlock ACE_recursive_thread_mutex_t   m,
ACE_recursive_mutex_state   state
[static]
 

Definition at line 2619 of file OS.i.

References ACE_OS_TRACE, cond_signal, ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_mutex_state::nesting_level_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, NULL_thread, ACE_recursive_mutex_state::owner_id_, ACE_recursive_thread_mutex_t::owner_id_, recursive_mutex_unlock, thr_equal, thr_self, thread_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Condition< ACE_Recursive_Thread_Mutex >::wait.

02621 {
02622 #if defined (ACE_HAS_THREADS)
02623   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock");
02624 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
02625   // Windows need special handling since it has recursive mutexes, but
02626   // does not integrate them into a condition variable.
02627 #    if defined (ACE_WIN32)
02628   // For Windows, the OS takes care of the mutex and its recursion. We just
02629   // need to release the lock one fewer times than this thread has acquired
02630   // it. Remember how many times, and reacquire it that many more times when
02631   // the condition is signaled.
02632   state.relock_count_ = 0;
02633   while (m->LockCount > 0
02634 #      if !defined (ACE_HAS_WINCE)    /* WinCE doesn't have RecursionCount */
02635          && m->RecursionCount > 1
02636 #      endif
02637          )
02638     {
02639       // This may fail if the current thread doesn't own the mutex. If it
02640       // does fail, it'll be on the first try, so don't worry about resetting
02641       // the state.
02642       if (ACE_OS::recursive_mutex_unlock (m) == -1)
02643         return -1;
02644       ++state.relock_count_;
02645     }
02646 #    else /* not ACE_WIN32 */
02647     // prevent warnings for unused variables
02648     ACE_UNUSED_ARG (state);
02649     ACE_UNUSED_ARG (m);
02650 #    endif /* ACE_WIN32 */
02651   return 0;
02652 #  else /* ACE_HAS_RECURSIVE_MUTEXES */
02653   // For platforms without recursive mutexes, we obtain the nesting mutex
02654   // to gain control over the mutex internals. Then set the internals to say
02655   // the mutex is available. If there are waiters, signal the condition
02656   // to notify them (this is mostly like the recursive_mutex_unlock() method).
02657   // Then, return with the nesting mutex still held. The condition wait
02658   // will release it atomically, allowing mutex waiters to continue.
02659   // Note that this arrangement relies on the fact that on return from
02660   // the condition wait, this thread will again own the nesting mutex
02661   // and can either set the mutex internals directly or get in line for
02662   // the mutex... this part is handled in recursive_mutex_cond_relock().
02663   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
02664     return -1;
02665 
02666 #    if !defined (ACE_NDEBUG)
02667   if (m->nesting_level_ == 0
02668       || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0)
02669     {
02670       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
02671       errno = EINVAL;
02672       return -1;
02673     }
02674 #    endif /* ACE_NDEBUG */
02675 
02676   // To make error recovery a bit easier, signal the condition now. Any
02677   // waiter won't regain control until the mutex is released, which won't
02678   // be until the caller returns and does the wait on the condition.
02679   if (ACE_OS::cond_signal (&m->lock_available_) == -1)
02680     {
02681       // Save/restore errno.
02682       ACE_Errno_Guard error (errno);
02683       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
02684       return -1;
02685     }
02686 
02687   // Ok, the nesting_mutex_ lock is still held, the condition has been
02688   // signaled... reset the nesting info and return _WITH_ the lock
02689   // held. The lock will be released when the condition waits, in the
02690   // caller.
02691   state.nesting_level_ = m->nesting_level_;
02692   state.owner_id_ = m->owner_id_;
02693   m->nesting_level_ = 0;
02694   m->owner_id_ = ACE_OS::NULL_thread;
02695   return 0;
02696 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
02697 #else
02698   ACE_UNUSED_ARG (m);
02699   ACE_UNUSED_ARG (state);
02700   ACE_NOTSUP_RETURN (-1);
02701 #endif /* ACE_HAS_THREADS */
02702 }

ACE_INLINE int ACE_OS::recursive_mutex_destroy ACE_recursive_thread_mutex_t   m [static]
 

Definition at line 2443 of file OS.i.

References cond_destroy, ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_mutex_, and thread_mutex_destroy.

Referenced by ACE_OS_Object_Manager::fini, and ACE_Recursive_Thread_Mutex::remove.

02444 {
02445 #if defined (ACE_HAS_THREADS)
02446 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
02447   return ACE_OS::thread_mutex_destroy (m);
02448 #else
02449   if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
02450     return -1;
02451   else if (ACE_OS::cond_destroy (&m->lock_available_) == -1)
02452     return -1;
02453   else
02454     return 0;
02455 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
02456 #else
02457   ACE_UNUSED_ARG (m);
02458   ACE_NOTSUP_RETURN (-1);
02459 #endif /* ACE_HAS_THREADS */
02460 }

ACE_INLINE int ACE_OS::recursive_mutex_init ACE_recursive_thread_mutex_t   m,
const ACE_TCHAR   name = 0,
ACE_mutexattr_t *    arg = 0,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

Definition at line 2410 of file OS.i.

References ACE_TCHAR, cond_init, ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, NULL_thread, ACE_recursive_thread_mutex_t::owner_id_, and thread_mutex_init.

Referenced by ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex, and ACE_OS_Object_Manager::init.

02414 {
02415   ACE_UNUSED_ARG (sa);
02416 #if defined (ACE_HAS_THREADS)
02417 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
02418   return ACE_OS::thread_mutex_init (m, 0, name, arg);
02419 #else
02420   if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1)
02421     return -1;
02422   else if (ACE_OS::cond_init (&m->lock_available_,
02423                               (short) USYNC_THREAD,
02424                               name,
02425                               0) == -1)
02426     return -1;
02427   else
02428     {
02429       m->nesting_level_ = 0;
02430       m->owner_id_ = ACE_OS::NULL_thread;
02431       return 0;
02432     }
02433 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
02434 #else
02435   ACE_UNUSED_ARG (m);
02436   ACE_UNUSED_ARG (name);
02437   ACE_UNUSED_ARG (arg);
02438   ACE_NOTSUP_RETURN (-1);
02439 #endif /* ACE_HAS_THREADS */
02440 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t   m [static]
 

Definition at line 2463 of file OS.i.

References ACE_thread_t, cond_wait, ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal, thr_self, thread_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Recursive_Thread_Mutex::acquire, and recursive_mutex_cond_relock.

02464 {
02465 #if defined (ACE_HAS_THREADS)
02466 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
02467   return ACE_OS::thread_mutex_lock (m);
02468 #else
02469   ACE_thread_t t_id = ACE_OS::thr_self ();
02470   int result = 0;
02471 
02472   // Acquire the guard.
02473   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
02474     result = -1;
02475   else
02476     {
02477       // If there's no contention, just grab the lock immediately
02478       // (since this is the common case we'll optimize for it).
02479       if (m->nesting_level_ == 0)
02480         m->owner_id_ = t_id;
02481       // If we already own the lock, then increment the nesting level
02482       // and return.
02483       else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
02484         {
02485           // Wait until the nesting level has dropped to zero, at
02486           // which point we can acquire the lock.
02487           while (m->nesting_level_ > 0)
02488             ACE_OS::cond_wait (&m->lock_available_,
02489                                &m->nesting_mutex_);
02490 
02491           // At this point the nesting_mutex_ is held...
02492           m->owner_id_ = t_id;
02493         }
02494 
02495       // At this point, we can safely increment the nesting_level_ no
02496       // matter how we got here!
02497       m->nesting_level_++;
02498     }
02499 
02500   {
02501     // Save/restore errno.
02502     ACE_Errno_Guard error (errno);
02503     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
02504   }
02505   return result;
02506 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
02507 #else
02508   ACE_UNUSED_ARG (m);
02509   ACE_NOTSUP_RETURN (-1);
02510 #endif /* ACE_HAS_THREADS */
02511 }

ACE_INLINE int ACE_OS::recursive_mutex_trylock ACE_recursive_thread_mutex_t   m [static]
 

Definition at line 2514 of file OS.i.

References ACE_thread_t, EBUSY, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal, thr_self, thread_mutex_lock, thread_mutex_trylock, and thread_mutex_unlock.

Referenced by ACE_Recursive_Thread_Mutex::tryacquire.

02515 {
02516 #if defined (ACE_HAS_THREADS)
02517 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
02518   return ACE_OS::thread_mutex_trylock (m);
02519 #else
02520   ACE_thread_t t_id = ACE_OS::thr_self ();
02521   int result = 0;
02522 
02523   // Acquire the guard.
02524   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
02525     result = -1;
02526   else
02527     {
02528       // If there's no contention, just grab the lock immediately.
02529       if (m->nesting_level_ == 0)
02530         {
02531           m->owner_id_ = t_id;
02532           m->nesting_level_ = 1;
02533         }
02534       // If we already own the lock, then increment the nesting level
02535       // and proceed.
02536       else if (ACE_OS::thr_equal (t_id, m->owner_id_))
02537         m->nesting_level_++;
02538       else
02539         {
02540           errno = EBUSY;
02541           result = -1;
02542         }
02543     }
02544 
02545   {
02546     // Save/restore errno.
02547     ACE_Errno_Guard error (errno);
02548     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
02549   }
02550   return result;
02551 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
02552 #else
02553   ACE_UNUSED_ARG (m);
02554   ACE_NOTSUP_RETURN (-1);
02555 #endif /* ACE_HAS_THREADS */
02556 }

ACE_INLINE int ACE_OS::recursive_mutex_unlock ACE_recursive_thread_mutex_t   m [static]
 

Definition at line 2559 of file OS.i.

References ACE_OS_TRACE, ACE_thread_t, cond_signal, ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, NULL_thread, ACE_recursive_thread_mutex_t::owner_id_, thr_equal, thr_self, thread_mutex_lock, and thread_mutex_unlock.

Referenced by recursive_mutex_cond_unlock, and ACE_Recursive_Thread_Mutex::release.

02560 {
02561 #if defined (ACE_HAS_THREADS)
02562 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
02563   return ACE_OS::thread_mutex_unlock (m);
02564 #  else
02565   ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock");
02566 #    if !defined (ACE_NDEBUG)
02567   ACE_thread_t t_id = ACE_OS::thr_self ();
02568 #    endif /* ACE_NDEBUG */
02569   int result = 0;
02570 
02571   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
02572     result = -1;
02573   else
02574     {
02575 #    if !defined (ACE_NDEBUG)
02576       if (m->nesting_level_ == 0
02577           || ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
02578         {
02579           errno = EINVAL;
02580           result = -1;
02581         }
02582       else
02583 #    endif /* ACE_NDEBUG */
02584         {
02585           m->nesting_level_--;
02586           if (m->nesting_level_ == 0)
02587             {
02588               // This may not be strictly necessary, but it does put
02589               // the mutex into a known state...
02590               m->owner_id_ = ACE_OS::NULL_thread;
02591 
02592               // Inform a waiter that the lock is free.
02593               if (ACE_OS::cond_signal (&m->lock_available_) == -1)
02594                 result = -1;
02595             }
02596         }
02597     }
02598 
02599   {
02600     // Save/restore errno.
02601     ACE_Errno_Guard error (errno);
02602     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
02603   }
02604   return result;
02605 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
02606 #else
02607   ACE_UNUSED_ARG (m);
02608   ACE_NOTSUP_RETURN (-1);
02609 #endif /* ACE_HAS_THREADS */
02610 }

ACE_INLINE int ACE_OS::recv ACE_HANDLE    handle,
char *    buf,
size_t    len,
int    flags = 0
[static]
 

BSD-style <accept> (no QoS).

Definition at line 4983 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, EWOULDBLOCK, and recv.

Referenced by recv, ACE::recv, ACE::recv_i, and ACE::recv_n_i.

04984 {
04985   ACE_OS_TRACE ("ACE_OS::recv");
04986 
04987   // On UNIX, a non-blocking socket with no data to receive, this
04988   // system call will return EWOULDBLOCK or EAGAIN, depending on the
04989   // platform.  UNIX 98 allows either errno, and they may be the same
04990   // numeric value.  So to make life easier for upper ACE layers as
04991   // well as application programmers, always change EAGAIN to
04992   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
04993   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
04994   // this function needs to be reviewed.  On Win32, the regular macros
04995   // can be used, as this is not an issue.
04996 #if defined (ACE_WIN32)
04997   ACE_SOCKCALL_RETURN (::recv ((ACE_SOCKET) handle, buf,
04998                                ACE_static_cast (int, len), flags), int, -1);
04999 #else
05000   int ace_result_;
05001   ace_result_ = ::recv ((ACE_SOCKET) handle, buf, len, flags);
05002   if (ace_result_ == -1 && errno == EAGAIN)
05003     errno = EWOULDBLOCK;
05004   return ace_result_;
05005 #endif /* defined (ACE_WIN32) */
05006 }

ACE_INLINE int ACE_OS::recvfrom ACE_HANDLE    handle,
iovec   buffers,
int    buffer_count,
size_t &    number_of_bytes_recvd,
int &    flags,
struct sockaddr *    addr,
int *    addrlen,
ACE_OVERLAPPED   overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC    func
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5086 of file OS.i.

References ACE_OS_TRACE, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, and set_errno_to_last_error.

05095 {
05096   ACE_OS_TRACE ("ACE_OS::recvfrom");
05097 
05098 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
05099   DWORD bytes_recvd;
05100   DWORD the_flags = flags;
05101   int result = ::WSARecvFrom ((SOCKET) handle,
05102                               (WSABUF*)buffers,
05103                               buffer_count,
05104                               &bytes_recvd,
05105                               &the_flags,
05106                               addr,
05107                               addrlen,
05108                               overlapped,
05109                               func);
05110   if (result != 0) {
05111     ACE_OS::set_errno_to_last_error ();
05112   }
05113   flags = the_flags;
05114   number_of_bytes_recvd = ACE_static_cast (size_t, bytes_recvd);
05115   return result;
05116 #else
05117   ACE_UNUSED_ARG (handle);
05118   ACE_UNUSED_ARG (buffers);
05119   ACE_UNUSED_ARG (buffer_count);
05120   ACE_UNUSED_ARG (number_of_bytes_recvd);
05121   ACE_UNUSED_ARG (flags);
05122   ACE_UNUSED_ARG (addr);
05123   ACE_UNUSED_ARG (addrlen);
05124   ACE_UNUSED_ARG (overlapped);
05125   ACE_UNUSED_ARG (func);
05126   ACE_NOTSUP_RETURN (-1);
05127 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
05128 }

ACE_INLINE int ACE_OS::recvfrom ACE_HANDLE    handle,
char *    buf,
size_t    len,
int    flags,
struct sockaddr *    addr,
int *    addrlen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5009 of file OS.i.

References ACE_BIT_ENABLED, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, recvfrom, and set_errno_to_wsa_last_error.

Referenced by ACE_WIN32_Asynch_Read_Dgram::recv, ACE_SOCK_Dgram::recv, recvfrom, and ACE::recvfrom.

05015 {
05016   ACE_OS_TRACE ("ACE_OS::recvfrom");
05017 #if defined (ACE_PSOS)
05018 #  if !defined ACE_PSOS_DIAB_PPC
05019   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags,
05020                                    (struct sockaddr_in *) addr, (ACE_SOCKET_LEN *) addrlen),
05021                        int, -1);
05022 #  else
05023   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags,
05024                                    (struct sockaddr *) addr, (ACE_SOCKET_LEN *) addrlen),
05025                        int, -1);
05026 #  endif /* defined ACE_PSOS_DIAB_PPC */
05027 #elif defined (ACE_WIN32)
05028   int shortened_len = ACE_static_cast (int, len);
05029   int result = ::recvfrom ((ACE_SOCKET) handle,
05030                            buf,
05031                            shortened_len,
05032                            flags,
05033                            addr,
05034                            (ACE_SOCKET_LEN *) addrlen);
05035   if (result == SOCKET_ERROR)
05036     {
05037       ACE_OS::set_errno_to_wsa_last_error ();
05038       if (errno == WSAEMSGSIZE &&
05039           ACE_BIT_ENABLED (flags, MSG_PEEK))
05040         return shortened_len;
05041       else
05042         return -1;
05043     }
05044   else
05045     return result;
05046 #else /* non Win32 and non PSOS */
05047   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags,
05048                                    addr, (ACE_SOCKET_LEN *) addrlen),
05049                        int, -1);
05050 #endif /* defined (ACE_PSOS) */
05051 }

ACE_INLINE int ACE_OS::recvmsg ACE_HANDLE    handle,
struct msghdr   msg,
int    flags
[static]
 

Definition at line 5589 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, recvmsg, and set_errno_to_last_error.

Referenced by recvmsg, and ACE::recvmsg.

05590 {
05591   ACE_OS_TRACE ("ACE_OS::recvmsg");
05592 #if !defined (ACE_LACKS_RECVMSG)
05593 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
05594   DWORD bytes_received = 0;
05595 
05596   int result = ::WSARecvFrom ((SOCKET) handle,
05597                               (WSABUF *) msg->msg_iov,
05598                               msg->msg_iovlen,
05599                               &bytes_received,
05600                               (DWORD *) &flags,
05601                               msg->msg_name,
05602                               &msg->msg_namelen,
05603                               0,
05604                               0);
05605 
05606   if (result != 0)
05607     {
05608       ACE_OS::set_errno_to_last_error ();
05609       return -1;
05610     }
05611   else
05612     return (ssize_t) bytes_received;
05613 # else /* ACE_HAS_WINSOCK2 */
05614   ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), int, -1);
05615 # endif /* ACE_HAS_WINSOCK2 */
05616 #else
05617   ACE_UNUSED_ARG (flags);
05618   ACE_UNUSED_ARG (msg);
05619   ACE_UNUSED_ARG (handle);
05620 
05621   ACE_NOTSUP_RETURN (-1);
05622 #endif /* ACE_LACKS_RECVMSG */
05623 }

ACE_INLINE ssize_t ACE_OS::recvv ACE_HANDLE    handle,
iovec   iov,
int    iovlen
[static]
 

Definition at line 7500 of file OS.i.

References iovec::iov_base, iovec::iov_len, readv, and set_errno_to_wsa_last_error.

Referenced by ACE_SOCK_IO::recv, ACE::recv, ACE::recvv, and ACE::recvv_n_i.

07503 {
07504 #if defined (ACE_HAS_WINSOCK2)
07505 
07506   DWORD bytes_received = 0;
07507   int result = 1;
07508 
07509   // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs
07510   // to do the recvs piece-by-piece.
07511 
07512 # if (ACE_HAS_WINSOCK2 != 0)
07513   DWORD flags = 0;
07514   result = ::WSARecv ((SOCKET) handle,
07515                       (WSABUF *) buffers,
07516                       n,
07517                       &bytes_received,
07518                       &flags,
07519                       0,
07520                       0);
07521 # else
07522   int i, chunklen;
07523   char *chunkp = 0;
07524 
07525   // Step through the buffers requested by caller; for each one, cycle
07526   // through reads until it's filled or an error occurs.
07527   for (i = 0; i < n && result > 0; i++)
07528     {
07529       chunkp = buffers[i].iov_base;     // Point to part of chunk being read
07530       chunklen = buffers[i].iov_len;    // Track how much to read to chunk
07531       while (chunklen > 0 && result > 0)
07532         {
07533           result = ::recv ((SOCKET) handle, chunkp, chunklen, 0);
07534           if (result > 0)
07535             {
07536               chunkp += result;
07537               chunklen -= result;
07538               bytes_received += result;
07539             }
07540         }
07541     }
07542 # endif /* ACE_HAS_WINSOCK2 != 0 */
07543 
07544   if (result == SOCKET_ERROR)
07545     {
07546       ACE_OS::set_errno_to_wsa_last_error ();
07547       return -1;
07548     }
07549   else
07550     return (ssize_t) bytes_received;
07551 #else
07552   return ACE_OS::readv (handle, buffers, n);
07553 #endif /* ACE_HAS_WINSOCK2 */
07554 }

ACE_INLINE int ACE_OS::rename const ACE_TCHAR   old_name,
const ACE_TCHAR   new_name,
int    flags = -1
[static]
 

Definition at line 797 of file OS.i.

References ACE_TCHAR, and rename.

Referenced by ACE_Logging_Strategy::handle_timeout, and rename.

00800 {
00801 # if defined (ACE_LACKS_RENAME)
00802   ACE_UNUSED_ARG (old_name);
00803   ACE_UNUSED_ARG (new_name);
00804   ACE_UNUSED_ARG (flags);
00805   ACE_NOTSUP_RETURN (-1);
00806 # elif defined (ACE_HAS_WINCE)
00807   ACE_UNUSED_ARG (flags);
00808   if (MoveFile (old_name, new_name) != 0)
00809     ACE_FAIL_RETURN (-1);
00810   return 0;
00811 # elif defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1)
00812   // NT4 (and up) provides a way to rename/move a file with similar semantics
00813   // to what's usually done on UNIX - if there's an existing file with
00814   // <new_name> it is removed before the file is renamed/moved. The
00815   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00816   if (flags == -1)
00817     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00818   if (ACE_TEXT_MoveFileEx(old_name, new_name, flags) == 0)
00819     ACE_FAIL_RETURN (-1);
00820   return 0;
00821 # elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00822   ACE_UNUSED_ARG (flags);
00823   ACE_OSCALL_RETURN (::_wrename (old_name, new_name), int, -1);
00824 # else /* ACE_LACKS_RENAME */
00825   ACE_UNUSED_ARG (flags);
00826   ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
00827 # endif /* ACE_LACKS_RENAME */
00828 }

ACE_INLINE void ACE_OS::rewind FILE *    fp [static]
 

Definition at line 7456 of file OS.i.

References ACE_OS_TRACE.

07457 {
07458 #if !defined (ACE_HAS_WINCE)
07459   ACE_OS_TRACE ("ACE_OS::rewind");
07460   ::rewind (fp);
07461 #else
07462   // In WinCE, "FILE *" is actually a HANDLE.
07463   ::SetFilePointer (fp, 0L, 0L, FILE_BEGIN);
07464 #endif /* ACE_HAS_WINCE */
07465 }

ACE_INLINE int ACE_OS::rw_rdlock ACE_rwlock_t *    rw [static]
 

Definition at line 3966 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait, mutex_lock, mutex_unlock, and rw_rdlock.

Referenced by ACE_RW_Mutex::acquire_read, and rw_rdlock.

03967 {
03968   ACE_OS_TRACE ("ACE_OS::rw_rdlock");
03969 #if defined (ACE_HAS_THREADS)
03970 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
03971 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
03972   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
03973                                        ace_result_),
03974                      int, -1);
03975 #  else /* Solaris */
03976   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), ace_result_), int, -1);
03977 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
03978 # else /* NT, POSIX, and VxWorks don't support this natively. */
03979 #   if defined (ACE_HAS_PTHREADS)
03980   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
03981 #   endif /* ACE_HAS_PTHREADS */
03982   int result = 0;
03983   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
03984     result = -1; // -1 means didn't get the mutex.
03985   else
03986     {
03987       // Give preference to writers who are waiting.
03988       while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0)
03989         {
03990           rw->num_waiting_readers_++;
03991           if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1)
03992             {
03993               result = -2; // -2 means that we need to release the mutex.
03994               break;
03995             }
03996           rw->num_waiting_readers_--;
03997         }
03998     }
03999   if (result == 0)
04000     rw->ref_count_++;
04001   if (result != -1)
04002     ACE_OS::mutex_unlock (&rw->lock_);
04003 #   if defined (ACE_HAS_PTHREADS)
04004   ACE_PTHREAD_CLEANUP_POP (0);
04005 #   endif /* defined (ACE_HAS_PTHREADS) */
04006   return 0;
04007 # endif /* ! ACE_LACKS_RWLOCK_T */
04008 #else
04009   ACE_UNUSED_ARG (rw);
04010   ACE_NOTSUP_RETURN (-1);
04011 #endif /* ACE_HAS_THREADS */
04012 }

ACE_INLINE int ACE_OS::rw_tryrdlock ACE_rwlock_t *    rw [static]
 

Definition at line 3884 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, EBUSY, mutex_lock, mutex_unlock, and rw_tryrdlock.

Referenced by rw_tryrdlock, and ACE_RW_Mutex::tryacquire_read.

03885 {
03886   ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
03887 #if defined (ACE_HAS_THREADS)
03888 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
03889 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
03890   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
03891                                        ace_result_),
03892                      int, -1);
03893 #  else /* Solaris */
03894   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), ace_result_), int, -1);
03895 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
03896 # else /* NT, POSIX, and VxWorks don't support this natively. */
03897   int result = -1;
03898 
03899   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
03900     {
03901       ACE_Errno_Guard error (errno);
03902 
03903       if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0)
03904         {
03905           error = EBUSY;
03906           result = -1;
03907         }
03908       else
03909         {
03910           rw->ref_count_++;
03911           result = 0;
03912         }
03913 
03914       ACE_OS::mutex_unlock (&rw->lock_);
03915     }
03916   return result;
03917 # endif /* ! ACE_LACKS_RWLOCK_T */
03918 #else
03919   ACE_UNUSED_ARG (rw);
03920   ACE_NOTSUP_RETURN (-1);
03921 #endif /* ACE_HAS_THREADS */
03922 }

ACE_INLINE int ACE_OS::rw_trywrlock ACE_rwlock_t *    rw [static]
 

Definition at line 3925 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, EBUSY, mutex_lock, mutex_unlock, and rw_trywrlock.

Referenced by rw_trywrlock, and ACE_RW_Mutex::tryacquire_write.

03926 {
03927   ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
03928 #if defined (ACE_HAS_THREADS)
03929 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
03930 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
03931   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
03932                                        ace_result_),
03933                      int, -1);
03934 #  else /* Solaris */
03935   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), ace_result_), int, -1);
03936 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
03937 # else /* NT, POSIX, and VxWorks don't support this natively. */
03938   int result = -1;
03939 
03940   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
03941     {
03942       ACE_Errno_Guard error (errno);
03943 
03944       if (rw->ref_count_ != 0)
03945         {
03946           error = EBUSY;
03947           result = -1;
03948         }
03949       else
03950         {
03951           rw->ref_count_ = -1;
03952           result = 0;
03953         }
03954 
03955       ACE_OS::mutex_unlock (&rw->lock_);
03956     }
03957   return result;
03958 # endif /* ! ACE_LACKS_RWLOCK_T */
03959 #else
03960   ACE_UNUSED_ARG (rw);
03961   ACE_NOTSUP_RETURN (-1);
03962 #endif /* ACE_HAS_THREADS */
03963 }

ACE_INLINE int ACE_OS::rw_trywrlock_upgrade ACE_rwlock_t *    rw [static]
 

Definition at line 4127 of file OS.i.

References ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait, EBUSY, mutex_lock, and mutex_unlock.

Referenced by ACE_RW_Mutex::tryacquire_write_upgrade.

04128 {
04129   ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
04130 #if defined (ACE_HAS_THREADS)
04131 # if !defined (ACE_LACKS_RWLOCK_T)
04132   // Some native rwlocks, such as those on Solaris and HP-UX 11, don't
04133   // support the upgrade feature . . .
04134   ACE_UNUSED_ARG (rw);
04135   ACE_NOTSUP_RETURN (-1);
04136 # else /* NT, POSIX, and VxWorks don't support this natively. */
04137   // The ACE rwlock emulation does support upgrade . . .
04138   int result = 0;
04139 
04140 #   if defined (ACE_HAS_PTHREADS)
04141   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
04142 #   endif /* defined (ACE_HAS_PTHREADS) */
04143 
04144   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
04145     return -1;
04146     // -1 means didn't get the mutex, error
04147   else if (rw->important_writer_)
04148     // an other reader upgrades already
04149     {
04150       result = -1;
04151       errno = EBUSY;
04152     }
04153   else
04154     {
04155       while (rw->ref_count_ > 1) // wait until only I am left
04156         {
04157           rw->num_waiting_writers_++; // prohibit any more readers
04158           rw->important_writer_ = 1;
04159 
04160           if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1)
04161             {
04162               result = -1;
04163               // we know that we have the lock again, we have this guarantee,
04164               // but something went wrong
04165             }
04166           rw->important_writer_ = 0;
04167           rw->num_waiting_writers_--;
04168         }
04169       if (result == 0)
04170         {
04171           // nothing bad happend
04172           rw->ref_count_ = -1;
04173           // now I am a writer
04174           // everything is O.K.
04175         }
04176     }
04177 
04178   ACE_OS::mutex_unlock (&rw->lock_);
04179 
04180 #   if defined (ACE_HAS_PTHREADS)
04181   ACE_PTHREAD_CLEANUP_POP (0);
04182 #   endif /* defined (ACE_HAS_PTHREADS) */
04183 
04184   return result;
04185 
04186 # endif /* ! ACE_LACKS_RWLOCK_T */
04187 #else
04188   ACE_UNUSED_ARG (rw);
04189   ACE_NOTSUP_RETURN (-1);
04190 #endif /* ACE_HAS_THREADS */
04191 }

ACE_INLINE int ACE_OS::rw_unlock ACE_rwlock_t *    rw [static]
 

Definition at line 4066 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, cond_broadcast, cond_signal, mutex_lock, mutex_unlock, and rw_unlock.

Referenced by ACE_RW_Mutex::release, and rw_unlock.

04067 {
04068   ACE_OS_TRACE ("ACE_OS::rw_unlock");
04069 #if defined (ACE_HAS_THREADS)
04070 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
04071 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
04072   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
04073                                        ace_result_),
04074                      int, -1);
04075 #  else /* Solaris */
04076   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), ace_result_), int, -1);
04077 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
04078 # else /* NT, POSIX, and VxWorks don't support this natively. */
04079   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
04080     return -1;
04081 
04082   if (rw->ref_count_ > 0) // Releasing a reader.
04083     rw->ref_count_--;
04084   else if (rw->ref_count_ == -1) // Releasing a writer.
04085     rw->ref_count_ = 0;
04086   else
04087     return -1; // @@ ACE_ASSERT (!"count should not be 0!\n");
04088 
04089 
04090   int result = 0;
04091   ACE_Errno_Guard error (errno);
04092 
04093   if (rw->important_writer_ && rw->ref_count_ == 1)
04094     // only the reader requesting to upgrade its lock is left over.
04095     {
04096       result = ACE_OS::cond_signal (&rw->waiting_important_writer_);
04097       error = errno;
04098     }
04099   else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0)
04100     // give preference to writers over readers...
04101     {
04102       result = ACE_OS::cond_signal (&rw->waiting_writers_);
04103       error =  errno;
04104     }
04105   else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0)
04106     {
04107       result = ACE_OS::cond_broadcast (&rw->waiting_readers_);
04108       error = errno;
04109     }
04110 
04111   ACE_OS::mutex_unlock (&rw->lock_);
04112   return result;
04113 # endif /* ! ace_lacks_rwlock_t */
04114 #else
04115   ACE_UNUSED_ARG (rw);
04116   ACE_NOTSUP_RETURN (-1);
04117 #endif /* ace_has_threads */
04118 }

ACE_INLINE int ACE_OS::rw_wrlock ACE_rwlock_t *    rw [static]
 

Definition at line 4015 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait, mutex_lock, mutex_unlock, and rw_wrlock.

Referenced by ACE_RW_Mutex::acquire, ACE_RW_Mutex::acquire_write, and rw_wrlock.

04016 {
04017   ACE_OS_TRACE ("ACE_OS::rw_wrlock");
04018 #if defined (ACE_HAS_THREADS)
04019 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
04020 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
04021   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
04022                                        ace_result_),
04023                      int, -1);
04024 #  else /* Solaris */
04025   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), ace_result_), int, -1);
04026 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
04027 # else /* NT, POSIX, and VxWorks don't support this natively. */
04028 #   if defined (ACE_HAS_PTHREADS)
04029   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
04030 #   endif /* defined (ACE_HAS_PTHREADS) */
04031   int result = 0;
04032 
04033   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
04034     result = -1; // -1 means didn't get the mutex.
04035   else
04036     {
04037       while (rw->ref_count_ != 0)
04038         {
04039           rw->num_waiting_writers_++;
04040 
04041           if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1)
04042             {
04043               result = -2; // -2 means we need to release the mutex.
04044               break;
04045             }
04046 
04047           rw->num_waiting_writers_--;
04048         }
04049     }
04050   if (result == 0)
04051     rw->ref_count_ = -1;
04052   if (result != -1)
04053     ACE_OS::mutex_unlock (&rw->lock_);
04054 #   if defined (ACE_HAS_PTHREADS)
04055   ACE_PTHREAD_CLEANUP_POP (0);
04056 #   endif /* defined (ACE_HAS_PTHREADS) */
04057   return 0;
04058 # endif /* ! ACE_LACKS_RWLOCK_T */
04059 #else
04060   ACE_UNUSED_ARG (rw);
04061   ACE_NOTSUP_RETURN (-1);
04062 #endif /* ACE_HAS_THREADS */
04063 }

ACE_INLINE int ACE_OS::rwlock_destroy ACE_rwlock_t *    rw [static]
 

Definition at line 4226 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, cond_destroy, mutex_destroy, and rwlock_destroy.

Referenced by ACE_RW_Mutex::remove, and rwlock_destroy.

04227 {
04228   ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
04229 #if defined (ACE_HAS_THREADS)
04230 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
04231 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
04232   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
04233                                        ace_result_),
04234                      int, -1);
04235 #  else /* Solaris */
04236   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), ace_result_), int, -1);
04237 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
04238 # else /* NT, POSIX, and VxWorks don't support this natively. */
04239   ACE_OS::mutex_destroy (&rw->lock_);
04240   ACE_OS::cond_destroy (&rw->waiting_readers_);
04241   ACE_OS::cond_destroy (&rw->waiting_important_writer_);
04242   return ACE_OS::cond_destroy (&rw->waiting_writers_);
04243 # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */
04244 #else
04245   ACE_UNUSED_ARG (rw);
04246   ACE_NOTSUP_RETURN (-1);
04247 #endif /* ACE_HAS_THREADS */
04248 }

int ACE_OS::rwlock_init ACE_rwlock_t *    rw,
int    type = ACE_DEFAULT_SYNCH_TYPE,
const ACE_TCHAR   name = 0,
void *    arg = 0
[static]
 

Referenced by ACE_RW_Mutex::ACE_RW_Mutex.

int ACE_OS::sched_params const ACE_Sched_Params  ,
ACE_id_t    id = ACE_SELF
[static]
 

Set scheduling parameters. An id of ACE_SELF indicates, e.g., set the parameters on the calling thread.

Definition at line 1433 of file OS.cpp.

References ACE_ADAPT_RETVAL, ACE_id_t, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCOPE_LWP, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, ACE_SELF, ACE_thread_t, ACE_Time_Value::msec, ACE_Sched_Params::policy, ACE_Sched_Params::priority, ACE_Sched_Params::quantum, ACE_Sched_Params::scope, set_errno_to_last_error, set_scheduling_params, thr_self, thr_setprio, and ACE_Time_Value::zero.

Referenced by lwp_setparams, thr_create, and thr_setprio.

01435 {
01436   ACE_OS_TRACE ("ACE_OS::sched_params");
01437 # if defined (CHORUS)
01438   ACE_UNUSED_ARG (id);
01439   int result;
01440   struct sched_param param;
01441   ACE_thread_t thr_id = ACE_OS::thr_self ();
01442 
01443   param.sched_priority = sched_params.priority ();
01444 
01445   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
01446                                                                 sched_params.policy (),
01447                                                                 &param),
01448                                        result),
01449                      int, -1);
01450 # elif defined (ACE_HAS_STHREADS)
01451   return ACE_OS::set_scheduling_params (sched_params, id);
01452 # elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED)
01453   ACE_UNUSED_ARG (id);
01454   if (sched_params.quantum () != ACE_Time_Value::zero)
01455     {
01456       // quantums not supported
01457       errno = EINVAL;
01458       return -1;
01459     }
01460 
01461   // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for
01462   // providing this code for 1003.1c PThreads.  Please note that this
01463   // has only been tested for POSIX 1003.1c threads, and may cause
01464   // problems with other PThreads flavors!
01465 
01466   struct sched_param param;
01467   param.sched_priority = sched_params.priority ();
01468 
01469   if (sched_params.scope () == ACE_SCOPE_PROCESS)
01470     {
01471       int result = ::sched_setscheduler (0, // this process
01472                                          sched_params.policy (),
01473                                          &param) == -1 ? -1 : 0;
01474 #   if defined (DIGITAL_UNIX)
01475       return result == 0
01476         ? // Use priocntl (2) to set the process in the RT class,
01477         // if using an RT policy.
01478         ACE_OS::set_scheduling_params (sched_params)
01479         : result;
01480 #   else  /* ! DIGITAL_UNIX */
01481       return result;
01482 #   endif /* ! DIGITAL_UNIX */
01483     }
01484   else if (sched_params.scope () == ACE_SCOPE_THREAD)
01485     {
01486       ACE_thread_t thr_id = ACE_OS::thr_self ();
01487 
01488 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01489       return (::pthread_setscheduler (thr_id,
01490                                       sched_params.policy (),
01491                                       sched_params.priority()) == -1 ? -1 : 0);
01492 #   else
01493       int result;
01494       ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
01495                                                                     sched_params.policy (),
01496                                                                     &param),
01497                                            result),
01498                          int, -1);
01499 #   endif  /* ACE_HAS_PTHREADS_DRAFT4 */
01500     }
01501 #   if defined (sun)
01502   // We need to be able to set LWP priorities on Suns, even without
01503   // ACE_HAS_STHREADS, to obtain preemption.
01504   else if (sched_params.scope () == ACE_SCOPE_LWP)
01505     return ACE_OS::set_scheduling_params (sched_params, id);
01506 #   endif /* sun */
01507   else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX
01508     {
01509       errno = EINVAL;
01510       return -1;
01511     }
01512 
01513 # elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
01514 
01515   // PharLap ETS can act on the current thread - it can set the
01516   // quantum also, unlike Win32. All this only works on the RT
01517   // version.
01518 #   if defined (ACE_HAS_PHARLAP_RT)
01519   if (id != ACE_SELF)
01520     ACE_NOTSUP_RETURN (-1);
01521 
01522   if (sched_params.quantum() != ACE_Time_Value::zero)
01523     EtsSetTimeSlice (sched_params.quantum().msec());
01524 
01525 #   else
01526   ACE_UNUSED_ARG (id);
01527 
01528   if (sched_params.scope () != ACE_SCOPE_PROCESS
01529       || sched_params.quantum () != ACE_Time_Value::zero)
01530     {
01531       // Win32 only allows setting priority class (therefore, policy)
01532       // at the process level.  I don't know of a way to set the
01533       // quantum.
01534       errno = EINVAL;
01535       return -1;
01536     }
01537 #ifndef ACE_DISABLE_WIN32_INCREASE_PRIORITY
01538   // Set the priority class of this process to the REALTIME process class
01539   // _if_ the policy is ACE_SCHED_FIFO.  Otherwise, set to NORMAL.
01540   if (!::SetPriorityClass (::GetCurrentProcess (),
01541                            sched_params.policy () == ACE_SCHED_FIFO
01542                            ? REALTIME_PRIORITY_CLASS
01543                            : NORMAL_PRIORITY_CLASS))
01544     {
01545       ACE_OS::set_errno_to_last_error ();
01546       return -1;
01547     }
01548 #endif
01549 #   endif /* ACE_HAS_PHARLAP_RT */
01550 
01551   // Set the thread priority on the current thread.
01552   return ACE_OS::thr_setprio (sched_params.priority ());
01553 
01554 # elif defined (VXWORKS) || defined (ACE_PSOS)
01555   ACE_UNUSED_ARG (id);
01556 
01557   // There is only one class of priorities on VxWorks, and no time
01558   // quanta.  So, just set the current thread's priority.
01559 
01560   if (sched_params.policy () != ACE_SCHED_FIFO
01561       || sched_params.scope () != ACE_SCOPE_PROCESS
01562       || sched_params.quantum () != ACE_Time_Value::zero)
01563     {
01564       errno = EINVAL;
01565       return -1;
01566     }
01567 
01568   // Set the thread priority on the current thread.
01569   return ACE_OS::thr_setprio (sched_params.priority ());
01570 # else
01571   ACE_UNUSED_ARG (sched_params);
01572   ACE_UNUSED_ARG (id);
01573   ACE_NOTSUP_RETURN (-1);
01574 # endif /* CHORUS */
01575 }

int ACE_OS::scheduling_class const char *    class_name,
ACE_id_t  
[static]
 

Find the schedling class ID that corresponds to the class name.

Definition at line 1269 of file OS.cpp.

References ACE_id_t, ACE_OS_String::memset, priority_control, and ACE_OS_String::strcpy.

Referenced by lwp_getparams, and set_scheduling_params.

01270 {
01271 #if defined (ACE_HAS_PRIOCNTL)
01272   // Get the priority class ID.
01273   pcinfo_t pcinfo;
01274   // The following is just to avoid Purify warnings about unitialized
01275   // memory reads.
01276   ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
01277 
01278   ACE_OS::strcpy (pcinfo.pc_clname, class_name);
01279   if (ACE_OS::priority_control (P_ALL /* ignored */,
01280                                 P_MYID /* ignored */,
01281                                 PC_GETCID,
01282                                 (char *) &pcinfo) == -1)
01283     {
01284       return -1;
01285     }
01286   else
01287     {
01288       id = pcinfo.pc_cid;
01289       return 0;
01290     }
01291 #else  /* ! ACE_HAS_PRIOCNTL */
01292   ACE_UNUSED_ARG (class_name);
01293   ACE_UNUSED_ARG (id);
01294   ACE_NOTSUP_RETURN (-1);
01295 #endif /* ! ACE_HAS_PRIOCNTL */
01296 }

ACE_INLINE int ACE_OS::select int    width,
fd_set *    rfds,
fd_set *    wfds,
fd_set *    efds,
const ACE_Time_Value   tv
[static]
 

Definition at line 4961 of file OS.i.

References ACE_FD_SET_TYPE, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and select.

04964 {
04965   ACE_OS_TRACE ("ACE_OS::select");
04966 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
04967 # define ___ACE_TIMEOUT &copy
04968   timeval copy = timeout;
04969 #else
04970 # define ___ACE_TIMEOUT timep
04971   const timeval *timep = timeout;
04972 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
04973   ACE_SOCKCALL_RETURN (::select (width,
04974                                  (ACE_FD_SET_TYPE *) rfds,
04975                                  (ACE_FD_SET_TYPE *) wfds,
04976                                  (ACE_FD_SET_TYPE *) efds,
04977                                  ___ACE_TIMEOUT),
04978                        int, -1);
04979 #undef ___ACE_TIMEOUT
04980 }

ACE_INLINE int ACE_OS::select int    width,
fd_set *    rfds,
fd_set *    wfds = 0,
fd_set *    efds = 0,
const ACE_Time_Value   tv = 0
[static]
 

Definition at line 4932 of file OS.i.

References ACE_FD_SET_TYPE, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and select.

Referenced by ACE_Select_Reactor_T::check_handles, ACE_FlReactor::fl_io_proc, ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::handle_input, ACE::handle_ready, ACE::handle_timed_accept, ACE::handle_timed_complete, ACE_XtReactor::InputCallbackProc, ACE_TkReactor::InputCallbackProc, ACE_QtReactor::QtWaitForMultipleEvents, ACE_SOCK_Dgram::recv, ACE_SOCK_Dgram_SC::recv, ACE_SOCK_IO::recvv, select, ACE::select, ACE_SOCK_Dgram::send, sleep, ACE_TkReactor::TkWaitForMultipleEvents, ACE_Select_Reactor_T::wait_for_multiple_events, ACE_FlReactor::wait_for_multiple_events, ACE_Select_Reactor_T::work_pending, and ACE_XtReactor::XtWaitForMultipleEvents.

04935 {
04936   ACE_OS_TRACE ("ACE_OS::select");
04937 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
04938   // We must defend against non-conformity!
04939   timeval copy;
04940   timeval *timep;
04941 
04942   if (timeout != 0)
04943     {
04944       copy = *timeout;
04945       timep = &copy;
04946     }
04947   else
04948     timep = 0;
04949 #else
04950   const timeval *timep = (timeout == 0 ? (const timeval *)0 : *timeout);
04951 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
04952   ACE_SOCKCALL_RETURN (::select (width,
04953                                  (ACE_FD_SET_TYPE *) rfds,
04954                                  (ACE_FD_SET_TYPE *) wfds,
04955                                  (ACE_FD_SET_TYPE *) efds,
04956                                  timep),
04957                        int, -1);
04958 }

int ACE_OS::select_i int    width,
fd_set *    rfds,
fd_set *    wfds,
fd_set *    efds,
const ACE_Time_Value   tv
[static, private]
 

int ACE_OS::select_i int    width,
fd_set *    rfds,
fd_set *    wfds,
fd_set *    efds,
const ACE_Time_Value   tv = 0
[static, private]
 

ACE_INLINE int ACE_OS::sema_destroy ACE_sema_t *    s [static]
 

Definition at line 2760 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, cond_destroy, event_destroy, ACE_OS_Memory::free, mutex_destroy, sema_destroy, shm_unlink, and thread_mutex_destroy.

Referenced by ACE_Semaphore::remove, and sema_destroy.

02761 {
02762   ACE_OS_TRACE ("ACE_OS::sema_destroy");
02763 # if defined (ACE_HAS_POSIX_SEM)
02764   int result;
02765 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
02766   if (s->name_)
02767     {
02768       // Only destroy the semaphore if we're the ones who
02769       // initialized it.
02770       ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
02771       ACE_OS::shm_unlink (s->name_);
02772       delete s->name_;
02773       return result;
02774     }
02775 #   else
02776   if (s->name_)
02777     {
02778       ACE_OSCALL (::sem_unlink (s->name_), int, -1, result);
02779       ACE_OS::free ((void *) s->name_);
02780       ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
02781     }
02782 #   endif /*  ACE_LACKS_NAMED_POSIX_SEM */
02783   else
02784     {
02785       ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
02786 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
02787       if (s->new_sema_ != 0)
02788 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
02789         delete s->sema_;
02790       s->sema_ = 0;
02791       return result;
02792     }
02793 # elif defined (ACE_HAS_THREADS)
02794 #   if defined (ACE_HAS_STHREADS)
02795   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), ace_result_), int, -1);
02796 #   elif defined (ACE_HAS_PTHREADS)
02797   int r1 = ACE_OS::mutex_destroy (&s->lock_);
02798   int r2 = ACE_OS::cond_destroy (&s->count_nonzero_);
02799   return r1 != 0 || r2 != 0 ? -1 : 0;
02800 #   elif defined (ACE_HAS_WTHREADS)
02801 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02802   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1);
02803 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02804   // Free up underlying objects of the simulated semaphore.
02805   int r1 = ACE_OS::thread_mutex_destroy (&s->lock_);
02806   int r2 = ACE_OS::event_destroy (&s->count_nonzero_);
02807   return r1 != 0 || r2 != 0 ? -1 : 0;
02808 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02809 #   elif defined (ACE_PSOS)
02810   int result;
02811   ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_delete (s->sema_), result), int, -1, result);
02812   s->sema_ = 0;
02813   return result;
02814 #   elif defined (VXWORKS)
02815   int result;
02816   ACE_OSCALL (::semDelete (s->sema_), int, -1, result);
02817   s->sema_ = 0;
02818   return result;
02819 #   endif /* ACE_HAS_STHREADS */
02820 # else
02821   ACE_UNUSED_ARG (s);
02822   ACE_NOTSUP_RETURN (-1);
02823 # endif /* ACE_HAS_POSIX_SEM */
02824 }

int ACE_OS::sema_init ACE_sema_t *    s,
u_int    count,
int    type,
const wchar_t *    name,
void *    arg = 0,
int    max = 0x7fffffff,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

ACE_INLINE int ACE_OS::sema_init ACE_sema_t *    s,
u_int    count,
int    type = ACE_DEFAULT_SYNCH_TYPE,
const char *    name = 0,
void *    arg = 0,
int    max = 0x7fffffff,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

Definition at line 3083 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_ALLOCATOR_RETURN, ACE_DEFAULT_FILE_PERMS, ACE_NEW_RETURN, ACE_OS_TRACE, close, cond_destroy, cond_init, default_win32_security_attributes, event_destroy, event_init, ftruncate, MAP_FAILED, MAP_SHARED, MAXPATHLEN, ACE_OS_String::memcpy, mmap, mutex_destroy, mutex_init, mutex_lock, mutex_unlock, PROT_RDWR, sema_init, shm_open, ACE_OS_String::strcat, ACE_OS_String::strcpy, ACE_OS_String::strdup, ACE_OS_String::strrchr, thread_mutex_destroy, thread_mutex_init, thread_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Semaphore::ACE_Semaphore, and sema_init.

03090 {
03091   ACE_OS_TRACE ("ACE_OS::sema_init");
03092 #if defined (ACE_HAS_POSIX_SEM)
03093   ACE_UNUSED_ARG (arg);
03094   ACE_UNUSED_ARG (max);
03095   ACE_UNUSED_ARG (sa);
03096 
03097   s->name_ = 0;
03098 
03099 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
03100   s->new_sema_ = 0;
03101   if (type == USYNC_PROCESS)
03102     {
03103       // Let's see if it already exists.
03104       ACE_HANDLE fd = ACE_OS::shm_open (name,
03105                                         O_RDWR | O_CREAT | O_EXCL,
03106                                         ACE_DEFAULT_FILE_PERMS);
03107       if (fd == ACE_INVALID_HANDLE)
03108         {
03109           if (errno == EEXIST)
03110             fd = ACE_OS::shm_open (name,
03111                                    O_RDWR | O_CREAT,
03112                                    ACE_DEFAULT_FILE_PERMS);
03113           else
03114             return -1;
03115         }
03116       else
03117         {
03118           // We own this shared memory object!  Let's set its
03119           // size.
03120           if (ACE_OS::ftruncate (fd,
03121                                  sizeof (ACE_sema_t)) == -1)
03122             return -1;
03123           s->name_ = ACE_OS::strdup (name);
03124           if (s->name_ == 0)
03125             return -1;
03126         }
03127       if (fd == -1)
03128         return -1;
03129 
03130       s->sema_ = (sem_t *)
03131         ACE_OS::mmap (0,
03132                       sizeof (ACE_sema_t),
03133                       PROT_RDWR,
03134                       MAP_SHARED,
03135                       fd,
03136                       0);
03137       ACE_OS::close (fd);
03138       if (s->sema_ == (sem_t *) MAP_FAILED)
03139         return -1;
03140       if (s->name_
03141           // @@ According UNIX Network Programming V2 by Stevens,
03142           //    sem_init() is currently not required to return zero on
03143           //    success, but it *does* return -1 upon failure.  For
03144           //    this reason, check for failure by comparing to -1,
03145           //    instead of checking for success by comparing to zero.
03146           //        -Ossama
03147           // Only initialize it if we're the one who created it.
03148           && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1)
03149         return -1;
03150       return 0;
03151     }
03152 #  else
03153   if (name)
03154     {
03155 #    if defined (sun) || defined (HPUX)
03156       // Solaris and HP-UX require the name to start with a slash. Solaris
03157       // further requires that there be no other slashes than the first.
03158       const char *last_slash = ACE_OS::strrchr (name, '/');
03159       char name2[MAXPATHLEN];
03160       if (0 == last_slash)
03161         {
03162           ACE_OS::strcpy (name2, "/");
03163           ACE_OS::strcat (name2, name);
03164           name = name2;
03165         }
03166 #      if defined (sun)
03167       else
03168         name = last_slash;         // Chop off chars preceding last slash
03169 #      endif /* sun */
03170 #    endif /* sun || HPUX */
03171 
03172       ACE_ALLOCATOR_RETURN (s->name_,
03173                             ACE_OS::strdup (name),
03174                             -1);
03175       s->sema_ = ::sem_open (s->name_,
03176                              O_CREAT,
03177                              ACE_DEFAULT_FILE_PERMS,
03178                              count);
03179       if (s->sema_ == (sem_t *) SEM_FAILED)
03180         return -1;
03181       else
03182         return 0;
03183     }
03184 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
03185   else
03186     {
03187       ACE_NEW_RETURN (s->sema_,
03188                       sem_t,
03189                       -1);
03190 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
03191       s->new_sema_ = 1;
03192 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
03193       ACE_OSCALL_RETURN (::sem_init (s->sema_,
03194                                      type != USYNC_THREAD,
03195                                      count), int, -1);
03196     }
03197 #elif defined (ACE_HAS_THREADS)
03198 #  if defined (ACE_HAS_STHREADS)
03199   ACE_UNUSED_ARG (name);
03200   ACE_UNUSED_ARG (max);
03201   ACE_UNUSED_ARG (sa);
03202   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), ace_result_),
03203                      int, -1);
03204 #  elif defined (ACE_HAS_PTHREADS)
03205   ACE_UNUSED_ARG (max);
03206   ACE_UNUSED_ARG (sa);
03207   int result = -1;
03208 
03209   if (ACE_OS::mutex_init (&s->lock_, type, name,
03210                           (ACE_mutexattr_t *) arg) == 0
03211       && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0
03212       && ACE_OS::mutex_lock (&s->lock_) == 0)
03213     {
03214       s->count_ = count;
03215       s->waiters_ = 0;
03216 
03217       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
03218         result = 0;
03219     }
03220 
03221   if (result == -1)
03222     {
03223       ACE_OS::mutex_destroy (&s->lock_);
03224       ACE_OS::cond_destroy (&s->count_nonzero_);
03225     }
03226   return result;
03227 #  elif defined (ACE_HAS_WTHREADS)
03228 #    if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
03229   ACE_UNUSED_ARG (type);
03230   ACE_UNUSED_ARG (arg);
03231   // Create the semaphore with its value initialized to <count> and
03232   // its maximum value initialized to <max>.
03233   *s =
03234     ::CreateSemaphoreA (ACE_OS::default_win32_security_attributes (sa),
03235                         count,
03236                         max,
03237                         name);
03238 
03239   if (*s == 0)
03240     ACE_FAIL_RETURN (-1);
03241   /* NOTREACHED */
03242   else
03243     return 0;
03244 #    else /* ACE_USES_WINCE_SEMA_SIMULATION */
03245   int result = -1;
03246 
03247   // Initialize internal object for semaphore simulation.
03248   // Grab the lock as soon as possible when we initializing
03249   // the semaphore count.  Notice that we initialize the
03250   // event object as "manually reset" so we can amortize the
03251   // cost for singling/reseting the event.
03252   // @@ I changed the mutex type to thread_mutex.  Notice that this
03253   // is basically a CriticalSection object and doesn't not has
03254   // any security attribute whatsoever.  However, since this
03255   // semaphore implementation only works within a process, there
03256   // shouldn't any security issue at all.
03257   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
03258       && ACE_OS::event_init (&s->count_nonzero_, 1,
03259                              count > 0, type, name, arg, sa) == 0
03260       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
03261     {
03262       s->count_ = count;
03263 
03264       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
03265         result = 0;
03266     }
03267 
03268   // Destroy the internal objects if we didn't initialize
03269   // either of them successfully.  Don't bother to check
03270   // for errors.
03271   if (result == -1)
03272     {
03273       ACE_OS::thread_mutex_destroy (&s->lock_);
03274       ACE_OS::event_destroy (&s->count_nonzero_);
03275     }
03276   return result;
03277 #    endif /* ACE_USES_WINCE_SEMA_SIMULATION */
03278 #  elif defined (ACE_PSOS)
03279   u_long result;
03280   ACE_OS::memcpy (s->name_, name, sizeof (s->name_));
03281   // default semaphore creation flags to priority based, global across nodes
03282   u_long flags = 0;
03283   flags |= (type & SM_LOCAL) ? SM_LOCAL : SM_GLOBAL;
03284   flags |= (type & SM_FIFO) ? SM_FIFO : SM_PRIOR;
03285   result = ::sm_create (s->name_, count, flags, &(s->sema_));
03286   return (result == 0) ? 0 : -1;
03287 #  elif defined (VXWORKS)
03288   ACE_UNUSED_ARG (name);
03289   ACE_UNUSED_ARG (arg);
03290   ACE_UNUSED_ARG (max);
03291   ACE_UNUSED_ARG (sa);
03292   s->name_ = 0;
03293   s->sema_ = ::semCCreate (type, count);
03294   return s->sema_ ? 0 : -1;
03295 #  endif /* ACE_HAS_STHREADS */
03296 #else
03297   ACE_UNUSED_ARG (s);
03298   ACE_UNUSED_ARG (count);
03299   ACE_UNUSED_ARG (type);
03300   ACE_UNUSED_ARG (name);
03301   ACE_UNUSED_ARG (arg);
03302   ACE_UNUSED_ARG (max);
03303   ACE_UNUSED_ARG (sa);
03304   ACE_NOTSUP_RETURN (-1);
03305 #endif /* ACE_HAS_POSIX_SEM */
03306 }

ACE_INLINE int ACE_OS::sema_post ACE_sema_t *    s,
u_int    release_count
[static]
 

Definition at line 3438 of file OS.i.

References ACE_ADAPT_RETVAL, and sema_post.

03439 {
03440 #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
03441   // Win32 supports this natively.
03442   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
03443                                           ace_result_), int, -1);
03444 #else
03445   // On POSIX platforms we need to emulate this ourselves.
03446   // @@ We can optimize on this implementation.  However,
03447   // the semaphore promitive on Win32 doesn't allow one
03448   // to increase a semaphore to more than the count it was
03449   // first initialized.  Posix and solaris don't seem to have
03450   // this restriction.  Should we impose the restriction in
03451   // our semaphore simulation?
03452   for (size_t i = 0; i < release_count; i++)
03453     if (ACE_OS::sema_post (s) == -1)
03454       return -1;
03455 
03456   return 0;
03457 #endif /* ACE_WIN32 */
03458 }

ACE_INLINE int ACE_OS::sema_post ACE_sema_t *    s [static]
 

Definition at line 3377 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, cond_signal, event_signal, mutex_lock, mutex_unlock, sema_post, thread_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Semaphore::release, and sema_post.

03378 {
03379   ACE_OS_TRACE ("ACE_OS::sema_post");
03380 # if defined (ACE_HAS_POSIX_SEM)
03381   ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1);
03382 # elif defined (ACE_HAS_THREADS)
03383 #   if defined (ACE_HAS_STHREADS)
03384   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), ace_result_), int, -1);
03385 #   elif defined (ACE_HAS_PTHREADS)
03386   int result = -1;
03387 
03388   if (ACE_OS::mutex_lock (&s->lock_) == 0)
03389     {
03390       // Always allow a waiter to continue if there is one.
03391       if (s->waiters_ > 0)
03392         result = ACE_OS::cond_signal (&s->count_nonzero_);
03393       else
03394         result = 0;
03395 
03396       s->count_++;
03397       ACE_OS::mutex_unlock (&s->lock_);
03398     }
03399   return result;
03400 #   elif defined (ACE_HAS_WTHREADS)
03401 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
03402   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
03403                                           ace_result_),
03404                         int, -1);
03405 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
03406   int result = -1;
03407 
03408   // Since we are simulating semaphores, we need to update semaphore
03409   // count manually.  Grab the lock to prevent race condition first.
03410   if (ACE_OS::thread_mutex_lock (&s->lock_) == 0)
03411     {
03412       // Check the original state of event object.  Single the event
03413       // object in transition from semaphore not available to
03414       // semaphore available.
03415       if (s->count_++ <= 0)
03416         result = ACE_OS::event_signal (&s->count_nonzero_);
03417       else
03418         result = 0;
03419 
03420       ACE_OS::thread_mutex_unlock (&s->lock_);
03421     }
03422   return result;
03423 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
03424 #   elif defined (ACE_PSOS)
03425   int result;
03426   ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_v (s->sema_), result), int, -1, result);
03427   return result;
03428 #   elif defined (VXWORKS)
03429   ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1);
03430 #   endif /* ACE_HAS_STHREADS */
03431 # else
03432   ACE_UNUSED_ARG (s);
03433   ACE_NOTSUP_RETURN (-1);
03434 # endif /* ACE_HAS_POSIX_SEM */
03435 }

ACE_INLINE int ACE_OS::sema_trywait ACE_sema_t *    s [static]
 

Definition at line 3461 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, EBUSY, event_reset, mutex_lock, mutex_unlock, sema_trywait, set_errno_to_last_error, thread_mutex_lock, and thread_mutex_unlock.

Referenced by sema_trywait, and ACE_Semaphore::tryacquire.

03462 {
03463   ACE_OS_TRACE ("ACE_OS::sema_trywait");
03464 # if defined (ACE_HAS_POSIX_SEM)
03465   // POSIX semaphores set errno to EAGAIN if trywait fails
03466   ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1);
03467 # elif defined (ACE_HAS_THREADS)
03468 #   if defined (ACE_HAS_STHREADS)
03469   // STHREADS semaphores set errno to EBUSY if trywait fails.
03470   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s),
03471                                        ace_result_),
03472                      int, -1);
03473 #   elif defined (ACE_HAS_PTHREADS)
03474 
03475   int result = -1;
03476 
03477   if (ACE_OS::mutex_lock (&s->lock_) == 0)
03478     {
03479       if (s->count_ > 0)
03480         {
03481           --s->count_;
03482           result = 0;
03483         }
03484       else
03485         errno = EBUSY;
03486 
03487       ACE_OS::mutex_unlock (&s->lock_);
03488     }
03489   return result;
03490 #   elif defined (ACE_HAS_WTHREADS)
03491 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
03492   int result = ::WaitForSingleObject (*s, 0);
03493 
03494   if (result == WAIT_OBJECT_0)
03495     return 0;
03496   else
03497     {
03498       if (result == WAIT_TIMEOUT)
03499         errno = EBUSY;
03500       else
03501         ACE_OS::set_errno_to_last_error ();
03502       // This is a hack, we need to find an appropriate mapping...
03503       return -1;
03504     }
03505 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
03506   // Check the status of semaphore first.  Return immediately
03507   // if the semaphore is not available and avoid grabing the
03508   // lock.
03509   int result = ::WaitForSingleObject (s->count_nonzero_, 0);
03510 
03511   if (result == WAIT_OBJECT_0)  // Proceed when it is available.
03512     {
03513       ACE_OS::thread_mutex_lock (&s->lock_);
03514 
03515       // Need to double check if the semaphore is still available.
03516       // The double checking scheme will slightly affect the
03517       // efficiency if most of the time semaphores are not blocked.
03518       result = ::WaitForSingleObject (s->count_nonzero_, 0);
03519       if (result == WAIT_OBJECT_0)
03520         {
03521           // Adjust the semaphore count.  Only update the event
03522           // object status when the state changed.
03523           s->count_--;
03524           if (s->count_ <= 0)
03525             ACE_OS::event_reset (&s->count_nonzero_);
03526           result = 0;
03527         }
03528 
03529       ACE_OS::thread_mutex_unlock (&s->lock_);
03530     }
03531 
03532   // Translate error message to errno used by ACE.
03533   if (result == WAIT_TIMEOUT)
03534     errno = EBUSY;
03535   else
03536     ACE_OS::set_errno_to_last_error ();
03537   // This is taken from the hack above. ;)
03538   return -1;
03539 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
03540 #   elif defined (ACE_PSOS)
03541    switch (::sm_p (s->sema_, SM_NOWAIT, 0))
03542    {
03543      case 0:
03544        return 0;
03545      case ERR_NOSEM:
03546        errno = EBUSY;
03547        // intentional fall through
03548      default:
03549        return -1;
03550    }
03551 #   elif defined (VXWORKS)
03552   if (::semTake (s->sema_, NO_WAIT) == ERROR)
03553     if (errno == S_objLib_OBJ_UNAVAILABLE)
03554       {
03555         // couldn't get the semaphore
03556         errno = EBUSY;
03557         return -1;
03558       }
03559     else
03560       // error
03561       return -1;
03562   else
03563     // got the semaphore
03564     return 0;
03565 #   endif /* ACE_HAS_STHREADS */
03566 # else
03567   ACE_UNUSED_ARG (s);
03568   ACE_NOTSUP_RETURN (-1);
03569 # endif /* ACE_HAS_POSIX_SEM */
03570 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *    s,
ACE_Time_Value   tv
[static]
 

Definition at line 3878 of file OS.i.

References sema_wait.

03879 {
03880   return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
03881 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *    s,
ACE_Time_Value   tv
[static]
 

Definition at line 3681 of file OS.i.

References ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_timedwait, EBUSY, ETIME, event_reset, gettimeofday, ACE_Time_Value::msec, mutex_lock, mutex_unlock, ACE_Time_Value::sec, set_errno_to_last_error, thread_mutex_lock, thread_mutex_unlock, ACE_Time_Value::usec, and ACE_Time_Value::zero.

03682 {
03683   ACE_OS_TRACE ("ACE_OS::sema_wait");
03684 # if defined (ACE_HAS_POSIX_SEM)
03685   ACE_UNUSED_ARG (s);
03686   ACE_UNUSED_ARG (tv);
03687   ACE_NOTSUP_RETURN (-1);
03688 # elif defined (ACE_HAS_THREADS)
03689 #   if defined (ACE_HAS_STHREADS)
03690   ACE_UNUSED_ARG (s);
03691   ACE_UNUSED_ARG (tv);
03692   ACE_NOTSUP_RETURN (-1);
03693 #   elif defined (ACE_HAS_PTHREADS)
03694   int result = 0;
03695   ACE_Errno_Guard error (errno);
03696 
03697   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
03698 
03699   if (ACE_OS::mutex_lock (&s->lock_) != 0)
03700     result = -1;
03701   else
03702     {
03703       // Keep track of the number of waiters so that we can signal
03704       // them properly in <ACE_OS::sema_post>.
03705       s->waiters_++;
03706 
03707       // Wait until the semaphore count is > 0 or until we time out.
03708       while (s->count_ == 0)
03709         if (ACE_OS::cond_timedwait (&s->count_nonzero_,
03710                                     &s->lock_,
03711                                     &tv) == -1)
03712           {
03713             error = errno;
03714             result = -2; // -2 means that we need to release the mutex.
03715             break;
03716           }
03717 
03718       --s->waiters_;
03719     }
03720 
03721   if (result == 0)
03722     {
03723 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
03724       tv = ACE_OS::gettimeofday ();
03725 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
03726       --s->count_;
03727     }
03728 
03729   if (result != -1)
03730     ACE_OS::mutex_unlock (&s->lock_);
03731   ACE_PTHREAD_CLEANUP_POP (0);
03732   return result < 0 ? -1 : result;
03733 #   elif defined (ACE_HAS_WTHREADS)
03734 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
03735   int msec_timeout;
03736 
03737   if (tv.sec () == 0 && tv.usec () == 0)
03738     msec_timeout = 0; // Do a "poll."
03739   else
03740     {
03741       // Note that we must convert between absolute time (which is
03742       // passed as a parameter) and relative time (which is what
03743       // <WaitForSingleObjects> expects).
03744       ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
03745 
03746       // Watchout for situations where a context switch has caused the
03747       // current time to be > the timeout.
03748       if (relative_time < ACE_Time_Value::zero)
03749         msec_timeout = 0;
03750       else
03751         msec_timeout = relative_time.msec ();
03752     }
03753 
03754   switch (::WaitForSingleObject (*s, msec_timeout))
03755     {
03756     case WAIT_OBJECT_0:
03757       tv = ACE_OS::gettimeofday ();     // Update time to when acquired
03758       return 0;
03759     case WAIT_TIMEOUT:
03760       errno = ETIME;
03761       return -1;
03762     default:
03763       // This is a hack, we need to find an appropriate mapping...
03764       ACE_OS::set_errno_to_last_error ();
03765       return -1;
03766     }
03767   /* NOTREACHED */
03768 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
03769   // Note that in this mode, the acquire is done in two steps, and
03770   // we may get signaled but cannot grab the semaphore before
03771   // timeout.  In that case, we'll need to restart the process with
03772   // updated timeout value.
03773 
03774   // <tv> is an absolute time
03775   ACE_Time_Value relative_time = tv - ACE_OS::gettimeofday ();
03776   int result = -1;
03777 
03778   // While we are not timeout yet.
03779   while (relative_time > ACE_Time_Value::zero)
03780     {
03781       // Wait for our turn to get the object.
03782       switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ()))
03783         {
03784         case WAIT_OBJECT_0:
03785           ACE_OS::thread_mutex_lock (&s->lock_);
03786 
03787           // Need to double check if the semaphore is still available.
03788           // We can only do a "try lock" styled wait here to avoid
03789           // blocking threads that want to signal the semaphore.
03790           if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
03791             {
03792               // As before, only reset the object when the semaphore
03793               // is no longer available.
03794               s->count_--;
03795               if (s->count_ <= 0)
03796                 ACE_OS::event_reset (&s->count_nonzero_);
03797               result = 0;
03798             }
03799 
03800           ACE_OS::thread_mutex_unlock (&s->lock_);
03801 
03802           // Only return when we successfully get the semaphore.
03803           if (result == 0)
03804             {
03805               tv = ACE_OS::gettimeofday ();     // Update to time acquired
03806               return 0;
03807             }
03808           break;
03809 
03810           // We have timed out.
03811         case WAIT_TIMEOUT:
03812           errno = ETIME;
03813           return -1;
03814 
03815           // What?
03816         default:
03817           ACE_OS::set_errno_to_last_error ();
03818           // This is taken from the hack above. ;)
03819           return -1;
03820         };
03821 
03822       // Haven't been able to get the semaphore yet, update the
03823       // timeout value to reflect the remaining time we want to wait.
03824       relative_time = tv - ACE_OS::gettimeofday ();
03825     }
03826 
03827   // We have timed out.
03828   errno = ETIME;
03829   return -1;
03830 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
03831 #   elif defined (ACE_PSOS)
03832   // Note that we must convert between absolute time (which is
03833   // passed as a parameter) and relative time (which is what
03834   // the system call expects).
03835   ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
03836 
03837   u_long ticks = relative_time.sec() * KC_TICKS2SEC +
03838                  relative_time.usec () * KC_TICKS2SEC /
03839                    ACE_ONE_SECOND_IN_USECS;
03840   if(ticks == 0)
03841     ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_NOWAIT, 0), int, -1); //no timeout
03842   else
03843     ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_WAIT, ticks), int, -1);
03844 #   elif defined (VXWORKS)
03845   // Note that we must convert between absolute time (which is
03846   // passed as a parameter) and relative time (which is what
03847   // the system call expects).
03848   ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
03849 
03850   int ticks_per_sec = ::sysClkRateGet ();
03851 
03852   int ticks = relative_time.sec() * ticks_per_sec +
03853               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
03854   if (::semTake (s->sema_, ticks) == ERROR)
03855     {
03856       if (errno == S_objLib_OBJ_TIMEOUT)
03857         // Convert the VxWorks errno to one that's common for to ACE
03858         // platforms.
03859         errno = ETIME;
03860       else if (errno == S_objLib_OBJ_UNAVAILABLE)
03861         errno = EBUSY;
03862       return -1;
03863     }
03864   else
03865     {
03866       tv = ACE_OS::gettimeofday ();  // Update to time acquired
03867       return 0;
03868     }
03869 #   endif /* ACE_HAS_STHREADS */
03870 # else
03871   ACE_UNUSED_ARG (s);
03872   ACE_UNUSED_ARG (tv);
03873   ACE_NOTSUP_RETURN (-1);
03874 # endif /* ACE_HAS_POSIX_SEM */
03875 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *    s [static]
 

Definition at line 3573 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait, event_reset, mutex_lock, mutex_unlock, sema_wait, set_errno_to_last_error, thread_mutex_lock, and thread_mutex_unlock.

Referenced by ACE_Semaphore::acquire, and sema_wait.

03574 {
03575   ACE_OS_TRACE ("ACE_OS::sema_wait");
03576 # if defined (ACE_HAS_POSIX_SEM)
03577   ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1);
03578 # elif defined (ACE_HAS_THREADS)
03579 #   if defined (ACE_HAS_STHREADS)
03580   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), ace_result_), int, -1);
03581 #   elif defined (ACE_HAS_PTHREADS)
03582   int result = 0;
03583 
03584   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
03585 
03586   if (ACE_OS::mutex_lock (&s->lock_) != 0)
03587     result = -1;
03588   else
03589     {
03590       // Keep track of the number of waiters so that we can signal
03591       // them properly in <ACE_OS::sema_post>.
03592       s->waiters_++;
03593 
03594       // Wait until the semaphore count is > 0.
03595       while (s->count_ == 0)
03596         if (ACE_OS::cond_wait (&s->count_nonzero_,
03597                                &s->lock_) == -1)
03598           {
03599             result = -2; // -2 means that we need to release the mutex.
03600             break;
03601           }
03602 
03603       --s->waiters_;
03604     }
03605 
03606   if (result == 0)
03607     --s->count_;
03608 
03609   if (result != -1)
03610     ACE_OS::mutex_unlock (&s->lock_);
03611   ACE_PTHREAD_CLEANUP_POP (0);
03612   return result < 0 ? -1 : result;
03613 
03614 #   elif defined (ACE_HAS_WTHREADS)
03615 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
03616   switch (::WaitForSingleObject (*s, INFINITE))
03617     {
03618     case WAIT_OBJECT_0:
03619       return 0;
03620     default:
03621       // This is a hack, we need to find an appropriate mapping...
03622       ACE_OS::set_errno_to_last_error ();
03623       return -1;
03624     }
03625   /* NOTREACHED */
03626 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
03627   // Timed wait.
03628   int result = -1;
03629   for (;;)
03630     // Check if the semaphore is avialable or not and wait forever.
03631     // Don't bother to grab the lock if it is not available (to avoid
03632     // deadlock.)
03633     switch (::WaitForSingleObject (s->count_nonzero_, INFINITE))
03634       {
03635       case WAIT_OBJECT_0:
03636         ACE_OS::thread_mutex_lock (&s->lock_);
03637 
03638         // Need to double check if the semaphore is still available.
03639         // This time, we shouldn't wait at all.
03640         if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
03641           {
03642             // Decrease the internal counter.  Only update the event
03643             // object's status when the state changed.
03644             s->count_--;
03645             if (s->count_ <= 0)
03646               ACE_OS::event_reset (&s->count_nonzero_);
03647             result = 0;
03648           }
03649 
03650         ACE_OS::thread_mutex_unlock (&s->lock_);
03651         // if we didn't get a hold on the semaphore, the result won't
03652         // be 0 and thus, we'll start from the beginning again.
03653         if (result == 0)
03654           return 0;
03655         break;
03656 
03657       default:
03658         // Since we wait indefinitely, anything other than
03659         // WAIT_OBJECT_O indicates an error.
03660         ACE_OS::set_errno_to_last_error ();
03661         // This is taken from the hack above. ;)
03662         return -1;
03663       }
03664   /* NOTREACHED */
03665 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
03666 #   elif defined (ACE_PSOS)
03667   int result;
03668   ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_WAIT, 0), result),
03669                                 int, -1, result);
03670   return result;
03671 #   elif defined (VXWORKS)
03672   ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1);
03673 #   endif /* ACE_HAS_STHREADS */
03674 # else
03675   ACE_UNUSED_ARG (s);
03676   ACE_NOTSUP_RETURN (-1);
03677 # endif /* ACE_HAS_POSIX_SEM */
03678 }

int ACE_OS::sema_wait_i ACE_sema_t *    s,
ACE_Time_Value   tv
[static, private]
 

int ACE_OS::sema_wait_i ACE_sema_t *    s [static, private]
 

ACE_INLINE int ACE_OS::semctl int    int_id,
int    semnum,
int    cmd,
semun   
[static]
 

Definition at line 8545 of file OS.i.

References ACE_OS_TRACE, and semctl.

Referenced by ACE_SV_Semaphore_Simple::control, ACE_SV_Semaphore_Simple::open, and semctl.

08546 {
08547   ACE_OS_TRACE ("ACE_OS::semctl");
08548 #if defined (ACE_HAS_SYSV_IPC)
08549   ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1);
08550 #else
08551   ACE_UNUSED_ARG (int_id);
08552   ACE_UNUSED_ARG (semnum);
08553   ACE_UNUSED_ARG (cmd);
08554   ACE_UNUSED_ARG (value);
08555 
08556   ACE_NOTSUP_RETURN (-1);
08557 #endif /* ACE_HAS_SYSV_IPC */
08558 }

ACE_INLINE int ACE_OS::semget key_t    key,
int    nsems,
int    flags
[static]
 

Definition at line 8561 of file OS.i.

References ACE_OS_TRACE, and semget.

Referenced by ACE_SV_Semaphore_Simple::open, ACE_SV_Semaphore_Complex::open, and semget.

08562 {
08563   ACE_OS_TRACE ("ACE_OS::semget");
08564 #if defined (ACE_HAS_SYSV_IPC)
08565   ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1);
08566 #else
08567   ACE_UNUSED_ARG (key);
08568   ACE_UNUSED_ARG (nsems);
08569   ACE_UNUSED_ARG (flags);
08570 
08571   ACE_NOTSUP_RETURN (-1);
08572 #endif /* ACE_HAS_SYSV_IPC */
08573 }

ACE_INLINE int ACE_OS::semop int    int_id,
struct sembuf *    sops,
size_t    nsops
[static]
 

Definition at line 8576 of file OS.i.

References ACE_OS_TRACE, and semop.

Referenced by ACE_SV_Semaphore_Complex::close, ACE_SV_Semaphore_Simple::op, ACE_SV_Semaphore_Complex::open, and semop.

08577 {
08578   ACE_OS_TRACE ("ACE_OS::semop");
08579 #if defined (ACE_HAS_SYSV_IPC)
08580   ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1);
08581 #else
08582   ACE_UNUSED_ARG (int_id);
08583   ACE_UNUSED_ARG (sops);
08584   ACE_UNUSED_ARG (nsops);
08585 
08586   ACE_NOTSUP_RETURN (-1);
08587 #endif /* ACE_HAS_SYSV_IPC */
08588 }

ACE_INLINE int ACE_OS::send ACE_HANDLE    handle,
const char *    buf,
size_t    len,
int    flags = 0
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5054 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, EWOULDBLOCK, and send.

Referenced by send, ACE::send, ACE::send_i, and ACE::send_n_i.

05055 {
05056   ACE_OS_TRACE ("ACE_OS::send");
05057 
05058   // On UNIX, a non-blocking socket with no data to receive, this
05059   // system call will return EWOULDBLOCK or EAGAIN, depending on the
05060   // platform.  UNIX 98 allows either errno, and they may be the same
05061   // numeric value.  So to make life easier for upper ACE layers as
05062   // well as application programmers, always change EAGAIN to
05063   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
05064   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
05065   // this function needs to be reviewed.  On Win32, the regular macros
05066   // can be used, as this is not an issue.
05067 #if defined (ACE_WIN32)
05068   ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle,
05069                                buf,
05070                                ACE_static_cast (int, len),
05071                                flags), int, -1);
05072 #else
05073   int ace_result_;
05074 #  if defined (VXWORKS) || defined (HPUX) || defined (ACE_PSOS)
05075   ace_result_ = ::send ((ACE_SOCKET) handle, (char *) buf, len, flags);
05076 #  else
05077   ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
05078 #  endif /* VXWORKS */
05079   if (ace_result_ == -1 && errno == EAGAIN)
05080     errno = EWOULDBLOCK;
05081   return ace_result_;
05082 #endif /* defined (ACE_WIN32) */
05083 }

ACE_INLINE int ACE_OS::sendmsg ACE_HANDLE    handle,
const struct msghdr   msg,
int    flags
[static]
 

Definition at line 5626 of file OS.i.

References ACE_OS_TRACE, ACE_SENDMSG_TYPE, ACE_SOCKCALL_RETURN, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, sendmsg, and set_errno_to_last_error.

Referenced by sendmsg, and ACE::sendmsg.

05629 {
05630   ACE_OS_TRACE ("ACE_OS::sendmsg");
05631 #if !defined (ACE_LACKS_SENDMSG)
05632 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
05633   DWORD bytes_sent = 0;
05634   int result = ::WSASendTo ((SOCKET) handle,
05635                             (WSABUF *) msg->msg_iov,
05636                             msg->msg_iovlen,
05637                             &bytes_sent,
05638                             flags,
05639                             msg->msg_name,
05640                             msg->msg_namelen,
05641                             0,
05642                             0);
05643 
05644   if (result != 0)
05645     {
05646       ACE_OS::set_errno_to_last_error ();
05647       return -1;
05648     }
05649   else
05650     return (ssize_t) bytes_sent;
05651 # elif defined (ACE_LACKS_POSIX_PROTOTYPES) ||  defined (ACE_PSOS)
05652   ACE_SOCKCALL_RETURN (::sendmsg (handle, (struct msghdr *) msg, flags), int, -1);
05653 # else
05654   ACE_SOCKCALL_RETURN (::sendmsg (handle, (ACE_SENDMSG_TYPE *) msg, flags), int, -1);
05655 # endif /* ACE_LACKS_POSIX_PROTOTYPES */
05656 #else
05657   ACE_UNUSED_ARG (flags);
05658   ACE_UNUSED_ARG (msg);
05659   ACE_UNUSED_ARG (handle);
05660 
05661   ACE_NOTSUP_RETURN (-1);
05662 #endif /* ACE_LACKS_SENDMSG */
05663 }

ACE_INLINE int ACE_OS::sendto ACE_HANDLE    handle,
const iovec   buffers,
int    buffer_count,
size_t &    number_of_bytes_sent,
int    flags,
const struct sockaddr *    addr,
int    addrlen,
ACE_OVERLAPPED   overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC    func
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5168 of file OS.i.

References ACE_OS_TRACE, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, sendto, and set_errno_to_last_error.

05177 {
05178   ACE_OS_TRACE ("ACE_OS::sendto");
05179 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
05180   DWORD bytes_sent;
05181   int result = ::WSASendTo ((SOCKET) handle,
05182                             (WSABUF*)buffers,
05183                             buffer_count,
05184                             &bytes_sent,
05185                             flags,
05186                             addr,
05187                             addrlen,
05188                             overlapped,
05189                             func);
05190   if (result != 0) {
05191     ACE_OS::set_errno_to_last_error ();
05192   }
05193   number_of_bytes_sent = ACE_static_cast (size_t, bytes_sent);
05194   return result;
05195 #else
05196   ACE_UNUSED_ARG (overlapped);
05197   ACE_UNUSED_ARG (func);
05198 
05199   number_of_bytes_sent = 0;
05200 
05201   int result = 0;
05202 
05203   for (int i = 0; i < buffer_count; i++)
05204     {
05205        result = ACE_OS::sendto (handle,
05206                                 ACE_reinterpret_cast (char *ACE_CAST_CONST,
05207                                                       buffers[i].iov_base),
05208                                 buffers[i].iov_len,
05209                                 flags,
05210                                 addr,
05211                                 addrlen);
05212        if (result == -1)
05213          break;
05214        number_of_bytes_sent += result;
05215     }
05216 
05217   return result;
05218 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
05219 }

ACE_INLINE int ACE_OS::sendto ACE_HANDLE    handle,
const char *    buf,
size_t    len,
int    flags,
const struct sockaddr *    addr,
int    addrlen
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5131 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and sendto.

Referenced by ACE_WIN32_Asynch_Write_Dgram::send, ACE_SOCK_Dgram_Bcast::send, ACE_SOCK_Dgram::send, sendto, and ACE::sendto.

05137 {
05138   ACE_OS_TRACE ("ACE_OS::sendto");
05139 #if defined (VXWORKS)
05140   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags,
05141                                  ACE_const_cast (struct sockaddr *, addr), addrlen),
05142                        int, -1);
05143 #elif defined (ACE_PSOS)
05144 #  if !defined (ACE_PSOS_DIAB_PPC)
05145   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags,
05146                                  (struct sockaddr_in *) addr, addrlen),
05147                        int, -1);
05148 #  else
05149   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, (char *) buf, len, flags,
05150                                  (struct sockaddr *) addr, addrlen),
05151                        int, -1);
05152 #  endif /*defined ACE_PSOS_DIAB_PPC */
05153 #else
05154 #  if defined (ACE_WIN32)
05155   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf,
05156                                  ACE_static_cast (int, len), flags,
05157                                  ACE_const_cast (struct sockaddr *, addr), addrlen),
05158                        int, -1);
05159 #  else
05160   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, len, flags,
05161                                  ACE_const_cast (struct sockaddr *, addr), addrlen),
05162                        int, -1);
05163 #  endif /* ACE_WIN32 */
05164 #endif /* VXWORKS */
05165 }

ACE_INLINE ssize_t ACE_OS::sendv ACE_HANDLE    handle,
const iovec   iov,
int    iovcnt
[static]
 

Definition at line 7557 of file OS.i.

References iovec::iov_base, iovec::iov_len, set_errno_to_wsa_last_error, and writev.

Referenced by ACE_SOCK_IO::send, ACE::send, ACE::sendv, and ACE::sendv_n_i.

07560 {
07561 #if defined (ACE_HAS_WINSOCK2)
07562   DWORD bytes_sent = 0;
07563   int result = 0;
07564 
07565   // Winsock 2 has WSASend and can do this directly, but Winsock 1
07566   // needs to do the sends one-by-one.
07567 # if (ACE_HAS_WINSOCK2 != 0)
07568   result = ::WSASend ((SOCKET) handle,
07569                       (WSABUF *) buffers,
07570                       n,
07571                       &bytes_sent,
07572                       0,
07573                       0,
07574                       0);
07575 # else
07576   int i;
07577   for (i = 0; i < n && result != SOCKET_ERROR; i++)
07578     {
07579       result = ::send ((SOCKET) handle,
07580                        buffers[i].iov_base,
07581                        buffers[i].iov_len,
07582                        0);
07583       // Gets ignored on error anyway
07584       bytes_sent += buffers[i].iov_len;
07585 
07586       // If the transfer isnt complete just drop out of the loop.
07587       if (result < (int)buffers[i].iov_len)
07588         break;
07589     }
07590 # endif /* ACE_HAS_WINSOCK2 != 0 */
07591 
07592   if (result == SOCKET_ERROR)
07593     {
07594       ACE_OS::set_errno_to_wsa_last_error ();
07595       return -1;
07596     }
07597   else
07598     return (ssize_t) bytes_sent;
07599 
07600 #else
07601   return ACE_OS::writev (handle, buffers, n);
07602 #endif /* ACE_HAS_WINSOCK2 */
07603 }

ACE_INLINE int ACE_OS::set_errno_to_last_error void    [static]
 

Definition at line 6275 of file OS.i.

References last_error.

Referenced by ACE_WIN32_Asynch_Accept::accept, ACE_TTY_IO::control, ACE_WFMO_Reactor::dispatch, ACE_WFMO_Reactor::dispatch_handles, event_timedwait, event_wait, ACE_WIN32_Proactor::handle_events, ACE_NT_Service::insert, mutex_init, mutex_lock, mutex_trylock, ACE_WFMO_Reactor::ok_to_wait, ACE_WIN32_Asynch_Read_File::readv, ACE_WIN32_Asynch_Read_Stream::readv, ACE_WIN32_Asynch_Read_Dgram::recv, recvfrom, recvmsg, ACE_WIN32_Proactor::register_handle, sched_params, sema_trywait, sema_wait, ACE_WIN32_Asynch_Write_Dgram::send, sendmsg, sendto, ACE_WIN32_Asynch_Read_Stream::shared_read, ACE_WIN32_Asynch_Write_Stream::shared_write, stat, ACE_NT_Service::svc_sc_handle, ACE_WIN32_Asynch_Transmit_File::transmit_file, ACE_Process::wait, waitpid, ACE_WIN32_Asynch_Write_File::writev, and ACE_WIN32_Asynch_Write_Stream::writev.

06276 {
06277 # if defined (ACE_WIN32)
06278 // Borland C++ Builder 4 has a bug in the RTL that resets the
06279 // <GetLastError> value to zero when errno is accessed.  Thus, we have
06280 // to use this to set errno to GetLastError.  It's bad, but only for
06281 // WIN32.
06282 #   if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400)
06283   int last_error = ::GetLastError ();
06284   return errno = last_error;
06285 #   else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
06286   return errno = ::GetLastError ();
06287 #   endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
06288 #else
06289   return errno;
06290 # endif /* defined(ACE_WIN32) */
06291 }

ACE_INLINE int ACE_OS::set_errno_to_wsa_last_error void    [static]
 

Definition at line 6294 of file OS.i.

References last_error.

Referenced by recvfrom, recvv, ACE_SPIPE_Stream::send_handle, and sendv.

06295 {
06296 # if defined (ACE_WIN32)
06297 // Borland C++ Builder 4 has a bug in the RTL that resets the
06298 // <GetLastError> value to zero when errno is accessed.  Thus, we have
06299 // to use this to set errno to GetLastError.  It's bad, but only for
06300 // WIN32
06301 #   if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400)
06302   int last_error = ::WSAGetLastError ();
06303   return errno = last_error;
06304 #   else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
06305   return errno = ::WSAGetLastError ();
06306 #   endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
06307 #else
06308   return errno;
06309 # endif /* defined(ACE_WIN32) */
06310 }

ACE_INLINE ACE_EXIT_HOOK ACE_OS::set_exit_hook ACE_EXIT_HOOK    hook [static, private]
 

For use by ACE_Object_Manager only, to register its exit hook..

Definition at line 10982 of file OS.i.

References exit_hook_.

Referenced by ACE_OS_Object_Manager::init.

10983 {
10984   ACE_EXIT_HOOK old_hook = exit_hook_;
10985   exit_hook_ = exit_hook;
10986   return old_hook;
10987 }

int ACE_OS::set_scheduling_params const ACE_Sched_Params  ,
ACE_id_t    id = ACE_SELF
[static]
 

Friendly interface to <priocntl>(2).

Definition at line 1299 of file OS.cpp.

References ACE_id_t, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCHED_RR, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, last_error, ACE_OS_String::memcpy, ACE_OS_String::memset, ACE_Sched_Params::policy, ACE_Sched_Params::priority, priority_control, ACE_Sched_Params::quantum, scheduling_class, ACE_Sched_Params::scope, ACE_Time_Value::sec, ACE_Time_Value::usec, and ACE_Time_Value::zero.

Referenced by sched_params.

01301 {
01302 #if defined (ACE_HAS_PRIOCNTL)
01303   // Set priority class, priority, and quantum of this LWP or process as
01304   // specified in sched_params.
01305 
01306   // Get the priority class ID.
01307   ACE_id_t class_id;
01308   if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER  ?
01309                                   "TS"  :
01310                                   "RT", class_id) == -1)
01311     {
01312       return -1;
01313     }
01314 
01315   pcparms_t pcparms;
01316   // The following is just to avoid Purify warnings about unitialized
01317   // memory reads.
01318   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
01319 
01320   pcparms.pc_cid = class_id;
01321 
01322   if (sched_params.policy () == ACE_SCHED_OTHER  &&
01323       sched_params.quantum () == ACE_Time_Value::zero)
01324       // SunOS doesn't support non-zero quantums in time-sharing class:  use
01325       // real-time class instead.
01326     {
01327       tsparms_t tsparms;
01328       // The following is just to avoid Purify warnings about unitialized
01329       // memory reads.
01330       ACE_OS::memset (&tsparms, 0, sizeof tsparms);
01331 
01332       // Don't change ts_uprilim (user priority limit)
01333       tsparms.ts_uprilim = TS_NOCHANGE;
01334       tsparms.ts_upri = sched_params.priority ();
01335 
01336       // Package up the TS class ID and parameters for the
01337       // priority_control () call.
01338       ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms);
01339     }
01340   else if (sched_params.policy () == ACE_SCHED_FIFO  ||
01341            (sched_params.policy () == ACE_SCHED_RR &&
01342             sched_params.quantum () != ACE_Time_Value::zero))
01343            // must have non-zero quantum for RR, to make it meaningful
01344            // A zero quantum with FIFO has special significance:  it actually
01345            // means infinite time quantum, i.e., run-to-completion.
01346     {
01347       rtparms_t rtparms;
01348       // The following is just to avoid Purify warnings about unitialized
01349       // memory reads.
01350       ACE_OS::memset (&rtparms, 0, sizeof rtparms);
01351 
01352       rtparms.rt_pri = sched_params.priority ();
01353 
01354       if (sched_params.quantum () == ACE_Time_Value::zero)
01355         {
01356           // rtparms.rt_tqsecs is ignored with RT_TQINF
01357           rtparms.rt_tqnsecs = RT_TQINF;
01358         }
01359       else
01360         {
01361           rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec ();
01362           rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000;
01363         }
01364 
01365       // Package up the RT class ID and parameters for the
01366       // priority_control () call.
01367       ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms);
01368     }
01369   else
01370     {
01371       errno = EINVAL;
01372       return -1;
01373     }
01374 
01375   if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD
01376                                             ? ACE_SCOPE_PROCESS
01377                                             : sched_params.scope ()),
01378                                 id,
01379                                 PC_SETPARMS,
01380                                 (char *) &pcparms) < 0)
01381     {
01382       return ACE_OS::last_error ();
01383     }
01384 
01385   return 0;
01386 #else  /* ! ACE_HAS_PRIOCNTL */
01387   ACE_UNUSED_ARG (sched_params);
01388   ACE_UNUSED_ARG (id);
01389   ACE_NOTSUP_RETURN (-1);
01390 #endif /* ! ACE_HAS_PRIOCNTL */
01391 }

void ACE_OS::set_win32_resource_module HINSTANCE    [static]
 

Allow an application to modify which module contains ACE's resources. This is mainly useful for a static build of ACE where the required resources reside somewhere other than the executable.

ACE_INLINE int ACE_OS::setgid gid_t    [static]
 

Definition at line 10952 of file OS.i.

References ACE_OS_TRACE, gid_t, and setgid.

Referenced by setgid.

10953 {
10954   ACE_OS_TRACE ("ACE_OS::setgid");
10955 #if defined (VXWORKS) || defined (ACE_PSOS)
10956   // setgid() is not supported:  just one user anyways
10957   ACE_UNUSED_ARG (gid);
10958   return 0;
10959 # elif defined (ACE_WIN32) || defined (CHORUS)
10960   ACE_UNUSED_ARG (gid);
10961   ACE_NOTSUP_RETURN (-1);
10962 # else
10963   ACE_OSCALL_RETURN (::setgid (gid), int,  -1);
10964 # endif /* VXWORKS || ACE_PSOS */
10965 }

ACE_INLINE int ACE_OS::setpgid pid_t    pid,
pid_t    pgid
[static]
 

Definition at line 9783 of file OS.i.

References ACE_OS_TRACE, pid_t, and setpgid.

Referenced by setpgid, and ACE_Process::spawn.

09784 {
09785   ACE_OS_TRACE ("ACE_OS::setpgid");
09786 #if defined (ACE_LACKS_SETPGID)
09787   ACE_UNUSED_ARG (pid);
09788   ACE_UNUSED_ARG (pgid);
09789   ACE_NOTSUP_RETURN (-1);
09790 #elif defined (VXWORKS) || defined (ACE_PSOS)
09791   // <setpgid> is not supported, only one process anyway.
09792   ACE_UNUSED_ARG (pid);
09793   ACE_UNUSED_ARG (pgid);
09794   return 0;
09795 #else
09796   ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1);
09797 #endif /* ACE_LACKS_SETPGID */
09798 }

ACE_INLINE void ACE_OS::setpwent void    [static]
 

Definition at line 5807 of file OS.i.

05808 {
05809 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
05810 # if !defined (ACE_WIN32)
05811   ::setpwent ();
05812 # else
05813 # endif /* ACE_WIN32 */
05814 #else
05815 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
05816 }

ACE_INLINE int ACE_OS::setregid gid_t    rgid,
gid_t    egid
[static]
 

Definition at line 9819 of file OS.i.

References ACE_OS_TRACE, gid_t, and setregid.

Referenced by setregid, and ACE_Process::spawn.

09820 {
09821   ACE_OS_TRACE ("ACE_OS::setregid");
09822 #if defined (ACE_LACKS_SETREGID)
09823   ACE_UNUSED_ARG (rgid);
09824   ACE_UNUSED_ARG (egid);
09825   ACE_NOTSUP_RETURN (-1);
09826 #elif defined (VXWORKS) || defined (ACE_PSOS)
09827   // <setregid> is not supported, only one process anyway.
09828   ACE_UNUSED_ARG (rgid);
09829   ACE_UNUSED_ARG (egid);
09830   return 0;
09831 #else
09832   ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1);
09833 #endif /* ACE_WIN32 */
09834 }

ACE_INLINE int ACE_OS::setreuid uid_t    ruid,
uid_t    euid
[static]
 

Definition at line 9801 of file OS.i.

References ACE_OS_TRACE, setreuid, and uid_t.

Referenced by setreuid, and ACE_Process::spawn.

09802 {
09803   ACE_OS_TRACE ("ACE_OS::setreuid");
09804 #if defined (ACE_LACKS_SETREUID)
09805   ACE_UNUSED_ARG (ruid);
09806   ACE_UNUSED_ARG (euid);
09807   ACE_NOTSUP_RETURN (-1);
09808 #elif defined (VXWORKS) || defined (ACE_PSOS)
09809   // <setpgid> is not supported, only one process anyway.
09810   ACE_UNUSED_ARG (ruid);
09811   ACE_UNUSED_ARG (euid);
09812   return 0;
09813 #else
09814   ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1);
09815 #endif /* ACE_WIN32 */
09816 }

ACE_INLINE int ACE_OS::setrlimit int    resource,
ACE_SETRLIMIT_TYPE   rl
[static]
 

Definition at line 9437 of file OS.i.

References ACE_OS_TRACE, ACE_SETRLIMIT_TYPE, and setrlimit.

Referenced by ACE::set_handle_limit, and setrlimit.

09438 {
09439   ACE_OS_TRACE ("ACE_OS::setrlimit");
09440 
09441 #if defined (ACE_LACKS_RLIMIT)
09442   ACE_UNUSED_ARG (resource);
09443   ACE_UNUSED_ARG (rl);
09444 
09445   ACE_NOTSUP_RETURN (-1);
09446 #else
09447 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
09448   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1);
09449 # else
09450   ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1);
09451 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
09452 #endif /* ACE_LACKS_RLIMIT */
09453 }

ACE_INLINE pid_t ACE_OS::setsid void    [static]
 

Definition at line 440 of file OS.i.

References ACE_OS_TRACE, and setsid.

Referenced by ACE::daemonize, and setsid.

00441 {
00442   ACE_OS_TRACE ("ACE_OS::setsid");
00443 # if defined (VXWORKS) || defined (CHORUS) || defined (ACE_PSOS)
00444   ACE_NOTSUP_RETURN (-1);
00445 # else
00446   ACE_OSCALL_RETURN (::setsid (), int, -1);
00447 # endif /* VXWORKS || CHORUS || ACE_PSOS */
00448 }

ACE_INLINE int ACE_OS::setsockopt ACE_HANDLE    handle,
int    level,
int    optname,
const char *    optval,
int    optlen
[static]
 

Manipulate the options associated with a socket.

Definition at line 5434 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKOPT_TYPE1, and setsockopt.

Referenced by ACE_ATM_Acceptor::accept, ACE_ATM_Connector::connect, ACE_WIN32_Asynch_Connect::connect_i, ACE_POSIX_Asynch_Connect::connect_i, ACE_Asynch_Acceptor::handle_accept, ACE_SOCK_Dgram_Bcast::mk_broadcast, ACE_Pipe::open, ACE_ATM_Acceptor::open, ACE_Asynch_Acceptor::open, ACE_SOCK::set_option, and setsockopt.

05439 {
05440   ACE_OS_TRACE ("ACE_OS::setsockopt");
05441 
05442   #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT)
05443   // To work around an inconsistency with Microsofts implementation of
05444   // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock
05445   // always behaves as if SO_REUSEADDR=1. Some implementations have the
05446   // same behaviour as Winsock, but use a new name for it. SO_REUSEPORT.
05447   // If you want the normal behaviour for SO_REUSEADDR=0, then NT 4 sp4 and later
05448   // supports SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform SDK
05449   // so it was decided to ignore the option for now. (Especially since ACE always
05450   // sets SO_REUSEADDR=1, which we can mimic by doing nothing.)
05451   if (level == SOL_SOCKET) {
05452     if (optname == SO_REUSEADDR) {
05453       return 0; // Not supported by Winsock
05454     }
05455     if (optname == SO_REUSEPORT) {
05456       optname = SO_REUSEADDR;
05457     }
05458   }
05459   #endif /*ACE_HAS_WINSOCK2*/
05460 
05461   ACE_SOCKCALL_RETURN (::setsockopt ((ACE_SOCKET) handle,
05462                                      level,
05463                                      optname,
05464                                      (ACE_SOCKOPT_TYPE1) optval,
05465                                      optlen),
05466                        int,
05467                        -1);
05468 }

ACE_INLINE int ACE_OS::setuid uid_t    [static]
 

Definition at line 10922 of file OS.i.

References ACE_OS_TRACE, setuid, and uid_t.

Referenced by setuid.

10923 {
10924   ACE_OS_TRACE ("ACE_OS::setuid");
10925 #if defined (VXWORKS) || defined (ACE_PSOS)
10926   // setuid() is not supported:  just one user anyways
10927   ACE_UNUSED_ARG (uid);
10928   return 0;
10929 # elif defined (ACE_WIN32) || defined(CHORUS)
10930   ACE_UNUSED_ARG (uid);
10931   ACE_NOTSUP_RETURN (-1);
10932 # else
10933   ACE_OSCALL_RETURN (::setuid (uid), int,  -1);
10934 # endif /* VXWORKS || ACE_PSOS */
10935 }

ACE_INLINE ACE_HANDLE ACE_OS::shm_open const ACE_TCHAR   filename,
int    mode,
int    perms = 0,
LPSECURITY_ATTRIBUTES    sa = 0
[static]
 

Definition at line 854 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, open, and shm_open.

Referenced by ACE_Condition::ACE_Condition, ACE_Mutex::ACE_Mutex, flock_init, ACE_Mem_Map::open, sema_init, and shm_open.

00858 {
00859   ACE_OS_TRACE ("ACE_OS::shm_open");
00860 # if defined (ACE_HAS_SHM_OPEN)
00861   ACE_UNUSED_ARG (sa);
00862   ACE_OSCALL_RETURN (::shm_open (filename, mode, perms), ACE_HANDLE, -1);
00863 # else  /* ! ACE_HAS_SHM_OPEN */
00864   // Just use ::open.
00865   return ACE_OS::open (filename, mode, perms, sa);
00866 # endif /* ACE_HAS_SHM_OPEN */
00867 }

ACE_INLINE int ACE_OS::shm_unlink const ACE_TCHAR   path [static]
 

Definition at line 870 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, shm_unlink, and unlink.

Referenced by flock_destroy, ACE_Condition::remove, ACE_Mutex::remove, ACE_Mem_Map::remove, sema_destroy, and shm_unlink.

00871 {
00872   ACE_OS_TRACE ("ACE_OS::shm_unlink");
00873 # if defined (ACE_HAS_SHM_OPEN)
00874   ACE_OSCALL_RETURN (::shm_unlink (path), int, -1);
00875 # else  /* ! ACE_HAS_SHM_OPEN */
00876   // Just use ::unlink.
00877   return ACE_OS::unlink (path);
00878 # endif /* ACE_HAS_SHM_OPEN */
00879 }

ACE_INLINE void * ACE_OS::shmat int    int_id,
void *    shmaddr,
int    shmflg
[static]
 

Definition at line 8591 of file OS.i.

References ACE_OS_TRACE, and shmat.

Referenced by ACE_SV_Shared_Memory::attach, ACE_Shared_Memory_Pool::commit_backing_store_name, ACE_Shared_Memory_Pool::handle_signal, ACE_Shared_Memory_Pool::init_acquire, and shmat.

08592 {
08593   ACE_OS_TRACE ("ACE_OS::shmat");
08594 #if defined (ACE_HAS_SYSV_IPC)
08595 # if defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES)
08596   ACE_OSCALL_RETURN (::shmat (int_id, (char *)shmaddr, shmflg), void *, (void *) -1);
08597 # else
08598   ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1);
08599 # endif /* ACE_LACKS_POSIX_PROTOTYPES */
08600 #else
08601   ACE_UNUSED_ARG (int_id);
08602   ACE_UNUSED_ARG (shmaddr);
08603   ACE_UNUSED_ARG (shmflg);
08604 
08605   ACE_NOTSUP_RETURN ((void *) -1);
08606 #endif /* ACE_HAS_SYSV_IPC */
08607 }

ACE_INLINE int ACE_OS::shmctl int    int_id,
int    cmd,
struct shmid_ds *    buf
[static]
 

Definition at line 8610 of file OS.i.

References ACE_OS_TRACE, and shmctl.

Referenced by ACE_SV_Shared_Memory::control, ACE_Shared_Memory_Pool::find_seg, ACE_Shared_Memory_Pool::in_use, ACE_Shared_Memory_Pool::release, ACE_SV_Shared_Memory::remove, and shmctl.

08611 {
08612   ACE_OS_TRACE ("ACE_OS::shmctl");
08613 #if defined (ACE_HAS_SYSV_IPC)
08614   ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1);
08615 #else
08616   ACE_UNUSED_ARG (buf);
08617   ACE_UNUSED_ARG (cmd);
08618   ACE_UNUSED_ARG (int_id);
08619 
08620   ACE_NOTSUP_RETURN (-1);
08621 #endif /* ACE_HAS_SYSV_IPC */
08622 }

ACE_INLINE int ACE_OS::shmdt void *    shmaddr [static]
 

Definition at line 8625 of file OS.i.

References ACE_OS_TRACE, and shmdt.

Referenced by ACE_SV_Shared_Memory::detach, and shmdt.

08626 {
08627   ACE_OS_TRACE ("ACE_OS::shmdt");
08628 #if defined (ACE_HAS_SYSV_IPC)
08629   ACE_OSCALL_RETURN (::shmdt ((char *) shmaddr), int, -1);
08630 #else
08631   ACE_UNUSED_ARG (shmaddr);
08632 
08633   ACE_NOTSUP_RETURN (-1);
08634 #endif /* ACE_HAS_SYSV_IPC */
08635 }

ACE_INLINE int ACE_OS::shmget key_t    key,
int    size,
int    flags
[static]
 

Definition at line 8638 of file OS.i.

References ACE_OS_TRACE, and shmget.

Referenced by ACE_Shared_Memory_Pool::commit_backing_store_name, ACE_Shared_Memory_Pool::init_acquire, ACE_SV_Shared_Memory::open, and shmget.

08639 {
08640   ACE_OS_TRACE ("ACE_OS::shmget");
08641 #if defined (ACE_HAS_SYSV_IPC)
08642   ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1);
08643 #else
08644   ACE_UNUSED_ARG (flags);
08645   ACE_UNUSED_ARG (size);
08646   ACE_UNUSED_ARG (key);
08647 
08648   ACE_NOTSUP_RETURN (-1);
08649 #endif /* ACE_HAS_SYSV_IPC */
08650 }

ACE_INLINE int ACE_OS::shutdown ACE_HANDLE    handle,
int    how
[static]
 

BSD-style <accept> (no QoS).

Definition at line 5471 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and shutdown.

Referenced by ACE_SOCK_Stream::close_reader, ACE_MEM_Stream::close_reader, ACE_SOCK_Stream::close_writer, ACE_MEM_Stream::close_writer, and shutdown.

05472 {
05473   ACE_OS_TRACE ("ACE_OS::shutdown");
05474   ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1);
05475 }

ACE_INLINE int ACE_OS::sigaction int    signum,
const struct sigaction *    nsa,
struct sigaction *    osa
[static]
 

Definition at line 10147 of file OS.i.

References ACE_OS_TRACE, SIG_ERR, SIG_IGN, and sigaction.

Referenced by ACE_Sig_Action::ACE_Sig_Action, ACE_Sig_Action::register_action, ACE_Sig_Action::restore_action, ACE_Sig_Action::retrieve_action, and sigaction.

10150 {
10151   ACE_OS_TRACE ("ACE_OS::sigaction");
10152   if (signum == 0)
10153     return 0;
10154 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
10155   struct sigaction sa;
10156 
10157   if (osa == 0)
10158     osa = &sa;
10159 
10160   if (nsa == 0)
10161     {
10162       osa->sa_handler = ::signal (signum, SIG_IGN);
10163       ::signal (signum, osa->sa_handler);
10164     }
10165   else
10166     osa->sa_handler = ::signal (signum, nsa->sa_handler);
10167   return osa->sa_handler == SIG_ERR ? -1 : 0;
10168 #elif defined (CHORUS) || defined (ACE_HAS_WINCE) || defined(ACE_PSOS)
10169   ACE_UNUSED_ARG (signum);
10170   ACE_UNUSED_ARG (nsa);
10171   ACE_UNUSED_ARG (osa);
10172   ACE_NOTSUP_RETURN (-1);
10173 #elif defined (ACE_LACKS_POSIX_PROTOTYPES) || defined (ACE_LACKS_SOME_POSIX_PROTOTYPES)
10174   ACE_OSCALL_RETURN (::sigaction (signum, (struct sigaction*) nsa, osa), int, -1);
10175 #else
10176   ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1);
10177 #endif /* ACE_WIN32 !ACE_HAS_WINCE */
10178 }

ACE_INLINE int ACE_OS::sigaddset sigset_t *    s,
int    signum
[static]
 

Definition at line 10674 of file OS.i.

References ACE_NSIG, ACE_OS_TRACE, and sigaddset.

Referenced by ACE_Sig_Set::sig_add, and sigaddset.

10675 {
10676   ACE_OS_TRACE ("ACE_OS::sigaddset");
10677 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
10678   if (s == 0)
10679     {
10680       errno = EFAULT;
10681       return -1;
10682     }
10683   else if (signum < 1 || signum >= ACE_NSIG)
10684     {
10685       errno = EINVAL;
10686       return -1;                 // Invalid signum, return error
10687     }
10688 #   if defined (ACE_PSOS) && defined (__DIAB) && ! defined(ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC)
10689   // treat 0th u_long of sigset_t as high bits,
10690   // and 1st u_long of sigset_t as low bits.
10691   if (signum <= ACE_BITS_PER_ULONG)
10692     s->s[1] |= (1 << (signum - 1));
10693   else
10694     s->s[0] |= (1 << (signum - ACE_BITS_PER_ULONG - 1));
10695 #   else
10696   *s |= (1 << (signum - 1)) ;
10697 #   endif /* defined (ACE_PSOS) && defined (__DIAB) */
10698   return 0 ;
10699 #else
10700   ACE_OSCALL_RETURN (::sigaddset (s, signum), int, -1);
10701 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
10702 }

ACE_INLINE int ACE_OS::sigdelset sigset_t *    s,
int    signum
[static]
 

Definition at line 10705 of file OS.i.

References ACE_NSIG, and sigdelset.

Referenced by ACE_Sig_Set::sig_del, and sigdelset.

10706 {
10707 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
10708   if (s == 0)
10709     {
10710       errno = EFAULT;
10711       return -1;
10712     }
10713   else if (signum < 1 || signum >= ACE_NSIG)
10714     {
10715       errno = EINVAL;
10716       return -1;                 // Invalid signum, return error
10717     }
10718 #   if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC)
10719   // treat 0th u_long of sigset_t as high bits,
10720   // and 1st u_long of sigset_t as low bits.
10721   if (signum <= ACE_BITS_PER_ULONG)
10722     s->s[1] &= ~(1 << (signum - 1));
10723   else
10724     s->s[0] &= ~(1 << (signum - ACE_BITS_PER_ULONG - 1));
10725 #   else
10726   *s &= ~(1 << (signum - 1)) ;
10727 #   endif /* defined (ACE_PSOS) && defined (__DIAB) */
10728   return 0;
10729 #else
10730   ACE_OSCALL_RETURN (::sigdelset (s, signum), int, -1);
10731 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
10732 }

ACE_INLINE int ACE_OS::sigemptyset sigset_t *    s [static]
 

Definition at line 10735 of file OS.i.

References sigemptyset.

Referenced by ACE_Sig_Action::ACE_Sig_Action, ACE_Sig_Set::ACE_Sig_Set, ACE_Sig_Set::empty_set, sigemptyset, sigsuspend, and ACE_Sig_Set::~ACE_Sig_Set.

10736 {
10737 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
10738   if (s == 0)
10739     {
10740       errno = EFAULT;
10741       return -1;
10742     }
10743 #   if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC)
10744   s->s[0] = 0;
10745   s->s[1] = 0;
10746 #   else
10747   *s = 0 ;
10748 #   endif /* defined (ACE_PSOS) && defined (__DIAB) */
10749   return 0 ;
10750 #else
10751   ACE_OSCALL_RETURN (::sigemptyset (s), int, -1);
10752 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
10753 }

ACE_INLINE int ACE_OS::sigfillset sigset_t *    s [static]
 

Definition at line 10756 of file OS.i.

References sigfillset.

Referenced by ACE_Sig_Set::ACE_Sig_Set, ACE_Sig_Set::fill_set, ACE_OS_Object_Manager::init, and sigfillset.

10757 {
10758 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
10759   if (s == 0)
10760     {
10761       errno = EFAULT;
10762       return -1;
10763     }
10764 #   if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC)
10765   s->s[0] = ~(u_long) 0;
10766   s->s[1] = ~(u_long) 0;
10767 #   else
10768   *s = ~(sigset_t) 0;
10769 #   endif /* defined (ACE_PSOS) && defined (__DIAB) */
10770   return 0 ;
10771 #else
10772   ACE_OSCALL_RETURN (::sigfillset (s), int, -1);
10773 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
10774 }

ACE_INLINE int ACE_OS::sigismember sigset_t *    s,
int    signum
[static]
 

Definition at line 10777 of file OS.i.

References ACE_NSIG, and sigismember.

Referenced by ACE_Sig_Set::is_member, and sigismember.

10778 {
10779 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
10780   if (s == 0)
10781     {
10782       errno = EFAULT;
10783       return -1;
10784     }
10785   else if (signum < 1 || signum >= ACE_NSIG)
10786     {
10787       errno = EINVAL;
10788       return -1;                 // Invalid signum, return error
10789     }
10790 #   if defined (ACE_PSOS) && defined (__DIAB) && ! defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC)
10791   // treat 0th u_long of sigset_t as high bits,
10792   // and 1st u_long of sigset_t as low bits.
10793   if (signum <= ACE_BITS_PER_ULONG)
10794     return ((s->s[1] & (1 << (signum - 1))) != 0);
10795   else
10796     return ((s->s[0] & (1 << (signum - ACE_BITS_PER_ULONG - 1))) != 0);
10797 #   else
10798   return ((*s & (1 << (signum - 1))) != 0) ;
10799 #   endif /* defined (ACE_PSOS) && defined (__DIAB) */
10800 #else
10801 #  if defined (ACE_HAS_SIGISMEMBER_BUG)
10802   if (signum < 1 || signum >= ACE_NSIG)
10803     {
10804       errno = EINVAL;
10805       return -1;                 // Invalid signum, return error
10806     }
10807 #  endif /* ACE_HAS_SIGISMEMBER_BUG */
10808   ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1);
10809 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
10810 }

ACE_INLINE ACE_SignalHandler ACE_OS::signal int    signum,
ACE_SignalHandler   
[static]
 

Definition at line 6374 of file OS.i.

References ACE_SignalHandler.

Referenced by ACE::daemonize.

06375 {
06376   if (signum == 0)
06377     return 0;
06378   else
06379 #if defined (ACE_PSOS) && !defined (ACE_PSOS_TM) && !defined (ACE_PSOS_DIAB_MIPS) && !defined (ACE_PSOS_DIAB_PPC)
06380     return (ACE_SignalHandler) ::signal (signum, (void (*)(void)) func);
06381 #elif defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC)
06382     return 0;
06383 #elif defined (ACE_PSOS_TM)
06384     // @@ It would be good to rework this so the ACE_PSOS_TM specific
06385     //    branch is not needed, but prying it out of ACE_LACKS_UNIX_SIGNALS
06386     //    will take some extra work - deferred for now.
06387     return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func);
06388 #elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS)
06389 #  if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS_SIGNALS)
06390     return ::signal (signum, func);
06391 #  else
06392     return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func);
06393 #  endif /* !ACE_HAS_TANDEM_SIGNALS */
06394 #else
06395     // @@ WINCE: Don't know how to implement signal on WinCE (yet.)
06396     ACE_UNUSED_ARG (signum);
06397     ACE_UNUSED_ARG (func);
06398     ACE_NOTSUP_RETURN (0);     // Should return SIG_ERR but it is not defined on WinCE.
06399 #endif /*  ACE_PSOS && !ACE_PSOS_TM && !ACE_PSOS_DIAB_MIPS && !ACE_PSOS_DIAB_PPC */
06400 }

ACE_INLINE int ACE_OS::sigprocmask int    how,
const sigset_t *    nsp,
sigset_t *    osp
[static]
 

Definition at line 10831 of file OS.i.

References sigprocmask.

Referenced by ACE_Sig_Guard::ACE_Sig_Guard, sigprocmask, thr_sigsetmask, and ACE_Sig_Guard::~ACE_Sig_Guard.

10832 {
10833 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
10834   ACE_UNUSED_ARG (how);
10835   ACE_UNUSED_ARG (nsp);
10836   ACE_UNUSED_ARG (osp);
10837   ACE_NOTSUP_RETURN (-1);
10838 #else
10839 # if defined (ACE_LACKS_POSIX_PROTOTYPES)
10840   ACE_OSCALL_RETURN (::sigprocmask (how, (int*) nsp, osp), int, -1);
10841 # else
10842   ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1);
10843 # endif /* ACE_LACKS_POSIX_PROTOTYPES */
10844 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
10845 }

ACE_INLINE int ACE_OS::sigsuspend const sigset_t *    set [static]
 

Definition at line 10813 of file OS.i.

References sigemptyset, and sigsuspend.

Referenced by sigsuspend.

10814 {
10815 #if defined (ACE_HAS_SIGSUSPEND)
10816   sigset_t s;
10817 
10818   if (sigset == 0)
10819     {
10820       sigset = &s;
10821       ACE_OS::sigemptyset (&s);
10822     }
10823   ACE_OSCALL_RETURN (::sigsuspend (sigset), int, -1);
10824 #else
10825   ACE_UNUSED_ARG (sigset);
10826   ACE_NOTSUP_RETURN (-1);
10827 #endif /* ACE_HAS_SIGSUSPEND */
10828 }

ACE_INLINE int ACE_OS::sigtimedwait const sigset_t *    set,
siginfo_t   info,
const ACE_Time_Value   timeout
[static]
 

Definition at line 7038 of file OS.i.

References ACE_OS_TRACE, and sigtimedwait.

Referenced by sigtimedwait.

07041 {
07042   ACE_OS_TRACE ("ACE_OS::sigtimedwait");
07043 #if defined (ACE_HAS_SIGTIMEDWAIT)
07044   timespec_t ts;
07045   timespec_t *tsp;
07046 
07047   if (timeout != 0)
07048     {
07049       ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
07050       tsp = &ts;
07051     }
07052   else
07053     tsp = 0;
07054 
07055   ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp),
07056                      int, -1);
07057 #else
07058     ACE_UNUSED_ARG (sset);
07059     ACE_UNUSED_ARG (info);
07060     ACE_UNUSED_ARG (timeout);
07061     ACE_NOTSUP_RETURN (-1);
07062 #endif /* ACE_HAS_SIGTIMEDWAIT */
07063 }

int ACE_OS::sigtimedwait_i const sigset_t *    set,
siginfo_t   info,
const ACE_Time_Value   timeout
[static, private]
 

ACE_INLINE int ACE_OS::sigwait sigset_t *    set,
int *    sig = 0
[static]
 

Definition at line 6978 of file OS.i.

References ACE_OS_TRACE.

06979 {
06980   ACE_OS_TRACE ("ACE_OS::sigwait");
06981   int local_sig;
06982   if (sig == 0)
06983     sig = &local_sig;
06984 #if defined (ACE_HAS_THREADS)
06985 # if (defined (__FreeBSD__) && (__FreeBSD__ < 3)) || defined (CHORUS) || defined (ACE_PSOS)
06986     ACE_UNUSED_ARG (sset);
06987     ACE_NOTSUP_RETURN (-1);
06988 # elif (defined (ACE_HAS_STHREADS) && !defined (_POSIX_PTHREAD_SEMANTICS))
06989     *sig = ::sigwait (sset);
06990     return *sig;
06991 # elif defined (ACE_HAS_PTHREADS)
06992   // LynxOS and Digital UNIX have their own hoops to jump through.
06993 #   if defined (__Lynx__)
06994     // Second arg is a void **, which we don't need (the selected
06995     // signal number is returned).
06996     *sig = ::sigwait (sset, 0);
06997     return *sig;
06998 #   elif defined (DIGITAL_UNIX)  &&  defined (__DECCXX_VER)
06999       // DEC cxx (but not g++) needs this direct call to its internal
07000       // sigwait ().  This allows us to #undef sigwait, so that we can
07001       // have ACE_OS::sigwait.  cxx gets confused by ACE_OS::sigwait
07002       // if sigwait is _not_ #undef'ed.
07003       errno = ::_Psigwait (sset, sig);
07004       return errno == 0  ?  *sig  :  -1;
07005 #   else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */
07006 #     if (defined (ACE_HAS_PTHREADS_DRAFT4) || (defined (ACE_HAS_PTHREADS_DRAFT6)) && !defined(ACE_HAS_FSU_PTHREADS)) || (defined (_UNICOS) && _UNICOS == 9)
07007 #       if defined (HPUX_10)
07008         *sig = cma_sigwait (sset);
07009 #       else
07010         *sig = ::sigwait (sset);
07011 #       endif  /* HPUX_10 */
07012         return *sig;
07013 #     elif defined(ACE_HAS_FSU_PTHREADS)
07014         return ::sigwait (sset, sig);
07015 #     else   /* this is draft 7 or std */
07016         errno = ::sigwait (sset, sig);
07017         return errno == 0  ?  *sig  :  -1;
07018 #     endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
07019 #   endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */
07020 # elif defined (ACE_HAS_WTHREADS)
07021     ACE_UNUSED_ARG (sset);
07022     ACE_NOTSUP_RETURN (-1);
07023 # elif defined (VXWORKS)
07024     // Second arg is a struct siginfo *, which we don't need (the
07025     // selected signal number is returned).  Third arg is timeout:  0
07026     // means forever.
07027     *sig = ::sigtimedwait (sset, 0, 0);
07028     return *sig;
07029 # endif /* __FreeBSD__ */
07030 #else
07031     ACE_UNUSED_ARG (sset);
07032     ACE_UNUSED_ARG (sig);
07033     ACE_NOTSUP_RETURN (-1);
07034 #endif /* ACE_HAS_THREADS */
07035 }

ACE_INLINE int ACE_OS::sigwaitinfo const sigset_t *    set,
siginfo_t   info
[static]
 

Definition at line 7066 of file OS.i.

References ACE_OS_TRACE, and sigwaitinfo.

Referenced by sigwaitinfo.

07068 {
07069   ACE_OS_TRACE ("ACE_OS::sigwaitinfo");
07070   // If this platform has sigtimedwait, it should have sigwaitinfo as well.
07071   // If this isn't true somewhere, let me know and I'll fix this.
07072   // -Steve Huston <shuston@riverace.com>.
07073 #if defined (ACE_HAS_SIGTIMEDWAIT)
07074   ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1);
07075 #else
07076   ACE_UNUSED_ARG (sset);
07077   ACE_UNUSED_ARG (info);
07078   ACE_NOTSUP_RETURN (-1);
07079 #endif /* ACE_HAS_SIGTIMEDWAIT */
07080 }

ACE_INLINE int ACE_OS::sleep const ACE_Time_Value   tv [static]
 

Definition at line 10317 of file OS.i.

References ACE_OS_TRACE, ACE_Time_Value::msec, and select.

10318 {
10319   ACE_OS_TRACE ("ACE_OS::sleep");
10320 #if defined (ACE_WIN32)
10321   ::Sleep (tv.msec ());
10322   return 0;
10323 #else
10324 # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
10325   // Copy the timeval, because this platform doesn't declare the timeval
10326   // as a pointer to const.
10327   timeval tv_copy = tv;
10328   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1);
10329 # else  /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */
10330   const timeval *tvp = tv;
10331   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1);
10332 # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
10333 #endif /* ACE_WIN32 */
10334 }

ACE_INLINE int ACE_OS::sleep u_int    seconds [static]
 

Definition at line 10284 of file OS.i.

References ACE_ONE_SECOND_IN_MSECS, ACE_OS_TRACE, nanosleep, select, sleep, timespec::tv_nsec, timespec::tv_sec, and wait.

Referenced by ACE_High_Res_Timer::calibrate, ACE_SOCK_Connector::complete, ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::handle_output, nanosleep, sleep, ACE_Process_Manager::wait, and ACE_Process::wait.

10285 {
10286   ACE_OS_TRACE ("ACE_OS::sleep");
10287 #if defined (ACE_WIN32)
10288   ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
10289   return 0;
10290 #if 0
10291 #elif defined (HPUX_10) && defined (ACE_HAS_PTHREADS_DRAFT4)
10292   // On HP-UX 10, _CMA_NOWRAPPERS_ disables the mapping from sleep to cma_sleep
10293   // which makes sleep() put the whole process to sleep, and keeps it from
10294   // noticing pending cancels.  So, in this case, use pthread_delay_np
10295   struct timespec rqtp;
10296   rqtp.tv_sec = seconds;
10297   rqtp.tv_nsec = 0L;
10298   return pthread_delay_np (&rqtp);
10299 #endif /* 0 */
10300 #elif defined (ACE_HAS_CLOCK_GETTIME)
10301   struct timespec rqtp;
10302   // Initializer doesn't work with Green Hills 1.8.7
10303   rqtp.tv_sec = seconds;
10304   rqtp.tv_nsec = 0L;
10305   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
10306 #elif defined (ACE_PSOS)
10307   timeval wait;
10308   wait.tv_sec = seconds;
10309   wait.tv_usec = 0;
10310   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &wait), int, -1);
10311 #else
10312   ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
10313 #endif /* ACE_WIN32 */
10314 }

int ACE_OS::sleep_i const ACE_Time_Value   tv [static, private]
 

int ACE_OS::sleep_i u_int    seconds [static, private]
 

int ACE_OS::snprintf wchar_t *    buf,
size_t    maxlen,
const wchar_t *    format,
...   
[static]
 

Definition at line 1156 of file OS.cpp.

References ACE_SPRINTF_ADAPTER.

01157 {
01158   // ACE_OS_TRACE ("ACE_OS::snprintf");
01159 #if (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) || defined (ACE_WIN32)
01160   int result;
01161   va_list ap;
01162   va_start (ap, format);
01163 #  if defined (ACE_WIN32)
01164   // Microsoft's vswprintf() doesn't have the maxlen argument that
01165   // XPG4/UNIX98 define. They do, however, recommend use of _vsnwprintf()
01166   // as a substitute, which does have the same signature as the UNIX98 one.
01167   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnwprintf (buf, maxlen, format, ap)),
01168               int, -1, result);
01169   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01170   if (result == -1)
01171     buf[maxlen-1] = '\0';
01172 #  else
01173   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vswprintf (buf, maxlen, format, ap)),
01174               int, -1, result);
01175 #  endif /* ACE_WIN32 */
01176   va_end (ap);
01177   // In out-of-range conditions, C99 defines vsnprintf to return the number
01178   // of characters that would have been written if enough space was available.
01179   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
01180   // -1. This method follows the C99 standard, but needs to guess at the
01181   // value; uses maxlen + 1.
01182   if (result == -1)
01183     result = ACE_static_cast (int, (maxlen + 1));
01184   return result;
01185 
01186 #else
01187   ACE_UNUSED_ARG (buf);
01188   ACE_UNUSED_ARG (maxlen);
01189   ACE_UNUSED_ARG (format);
01190   ACE_NOTSUP_RETURN (-1);
01191 #endif /* ACE_HAS_SNPRINTF */
01192 }

int ACE_OS::snprintf char *    buf,
size_t    maxlen,
const char *    format,
...   
[static]
 

Definition at line 1119 of file OS.cpp.

References ACE_SPRINTF_ADAPTER.

Referenced by ACE_Log_Msg::log.

01120 {
01121   // ACE_OS_TRACE ("ACE_OS::snprintf");
01122 #if defined (ACE_HAS_SNPRINTF)
01123   int result;
01124   va_list ap;
01125   va_start (ap, format);
01126 #  if defined (ACE_WIN32)
01127   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnprintf (buf, maxlen, format, ap)),
01128               int, -1, result);
01129   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01130   if (result == -1)
01131     buf[maxlen-1] = '\0';
01132 #  else
01133   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsnprintf (buf, maxlen, format, ap)),
01134               int, -1, result);
01135 #  endif /* ACE_WIN32 */
01136   va_end (ap);
01137   // In out-of-range conditions, C99 defines vsnprintf to return the number
01138   // of characters that would have been written if enough space was available.
01139   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
01140   // -1. This method follows the C99 standard, but needs to guess at the
01141   // value; uses maxlen + 1.
01142   if (result == -1)
01143     result = ACE_static_cast (int, (maxlen + 1));
01144   return result;
01145 
01146 #else
01147   ACE_UNUSED_ARG (buf);
01148   ACE_UNUSED_ARG (maxlen);
01149   ACE_UNUSED_ARG (format);
01150   ACE_NOTSUP_RETURN (-1);
01151 #endif /* ACE_HAS_SNPRINTF */
01152 }

ACE_INLINE ACE_HANDLE ACE_OS::socket int    protocol_family,
int    type,
int    proto,
ACE_Protocol_Info   protocolinfo,
ACE_SOCK_GROUP    g,
u_long    flags
[static]
 

Create a QoS-enabled socket. If the OS platform doesn't support QoS-enabled <socket> then the BSD-style <socket> is called.

Definition at line 5491 of file OS.i.

References ACE_OS_TRACE, ACE_SOCK_GROUP, ACE_SOCKCALL_RETURN, and socket.

05497 {
05498   ACE_OS_TRACE ("ACE_OS::socket");
05499 
05500 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
05501   ACE_SOCKCALL_RETURN (::WSASocket (domain,
05502                                     type,
05503                                     proto,
05504                                     protocolinfo,
05505                                     g,
05506                                     flags),
05507                        ACE_HANDLE,
05508                        ACE_INVALID_HANDLE);
05509 #else
05510   ACE_UNUSED_ARG (protocolinfo);
05511   ACE_UNUSED_ARG (g);
05512   ACE_UNUSED_ARG (flags);
05513 
05514   return ACE_OS::socket (domain,
05515                          type,
05516                          proto);
05517 #endif /* ACE_HAS_WINSOCK2 */
05518 }

ACE_INLINE ACE_HANDLE ACE_OS::socket int    protocol_family,
int    type,
int    proto
[static]
 

Create a BSD-style socket (no QoS).

Definition at line 5478 of file OS.i.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and socket.

Referenced by ACE_WIN32_Asynch_Accept::accept, ACE_WIN32_Asynch_Connect::connect_i, ACE_POSIX_Asynch_Connect::connect_i, ACE_Sock_Connect::get_bcast_addr, ACE_Sock_Connect::get_handle, ioctl, ACE_Sock_Connect::ipv6_enabled, join_leaf, ACE_SOCK::open, ACE_ATM_Acceptor::open, ACE_Asynch_Acceptor::open, ACE_SPIPE_Stream::recv_handle, and socket.

05481 {
05482   ACE_OS_TRACE ("ACE_OS::socket");
05483   ACE_SOCKCALL_RETURN (::socket (domain,
05484                                  type,
05485                                  proto),
05486                        ACE_HANDLE,
05487                        ACE_INVALID_HANDLE);
05488 }

int ACE_OS::socket_fini void    [static]
 

Finalize WinSock after last use (e.g., when a DLL is unloaded).

Definition at line 4432 of file OS.cpp.

References ACE_LIB_TEXT, fprintf, socket_initialized_, and sprintf.

Referenced by ACE_OS_Object_Manager::fini.

04433 {
04434 # if defined (ACE_WIN32)
04435   if (ACE_OS::socket_initialized_ != 0)
04436     {
04437       if (WSACleanup () != 0)
04438         {
04439           int error = ::WSAGetLastError ();
04440 #   if defined (ACE_HAS_WINCE)
04441           wchar_t fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d");
04442           wchar_t buf[80];  // @@ Eliminate magic number.
04443           ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSACleanup"), error);
04444           ::MessageBox (0, buf , ACE_LIB_TEXT ("WSACleanup failed!"), MB_OK);
04445 #   else
04446           ACE_OS::fprintf (stderr,
04447                            "ACE_OS::socket_fini; WSACleanup failed, "
04448                              "WSAGetLastError returned %d\n",
04449                            error);
04450 #   endif /* ACE_HAS_WINCE */
04451         }
04452       ACE_OS::socket_initialized_ = 0;
04453     }
04454 # endif /* ACE_WIN32 */
04455   return 0;
04456 }

int ACE_OS::socket_init int    version_high = 1,
int    version_low = 1
[static]
 

Initialize WinSock before first use (e.g., when a DLL is first loaded or the first use of a socket() call.

Definition at line 4398 of file OS.cpp.

References ACE_LIB_TEXT, fprintf, socket_initialized_, and sprintf.

Referenced by ACE_OS_Object_Manager::init.

04399 {
04400 # if defined (ACE_WIN32)
04401   if (ACE_OS::socket_initialized_ == 0)
04402     {
04403       WORD version_requested = MAKEWORD (version_high, version_low);
04404       WSADATA wsa_data;
04405       int error = WSAStartup (version_requested, &wsa_data);
04406 
04407       if (error != 0)
04408 #   if defined (ACE_HAS_WINCE)
04409         {
04410           wchar_t fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d");
04411           wchar_t buf[80];  // @@ Eliminate magic number.
04412           ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSAStartup"), error);
04413           ::MessageBox (0, buf, ACE_LIB_TEXT ("WSAStartup failed!"), MB_OK);
04414         }
04415 #   else
04416       ACE_OS::fprintf (stderr,
04417                        "ACE_OS::socket_init; WSAStartup failed, "
04418                          "WSAGetLastError returned %d\n",
04419                        error);
04420 #   endif /* ACE_HAS_WINCE */
04421 
04422       ACE_OS::socket_initialized_ = 1;
04423     }
04424 # else
04425   ACE_UNUSED_ARG (version_high);
04426   ACE_UNUSED_ARG (version_low);
04427 # endif /* ACE_WIN32 */
04428   return 0;
04429 }

ACE_INLINE int ACE_OS::socketpair int    domain,
int    type,
int    protocol,
ACE_HANDLE    sv[2]
[static]
 

BSD-style <accept> (no QoS).

Definition at line 9456 of file OS.i.

References ACE_OS_TRACE, and socketpair.

Referenced by ACE_Pipe::open, and socketpair.

09458 {
09459   ACE_OS_TRACE ("ACE_OS::socketpair");
09460 #if defined (ACE_WIN32) || defined (ACE_LACKS_SOCKETPAIR)
09461   ACE_UNUSED_ARG (domain);
09462   ACE_UNUSED_ARG (type);
09463   ACE_UNUSED_ARG (protocol);
09464   ACE_UNUSED_ARG (sv);
09465 
09466   ACE_NOTSUP_RETURN (-1);
09467 #else
09468   ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv),
09469                      int, -1);
09470 #endif /* ACE_WIN32 */
09471 }

int ACE_OS::sprintf wchar_t *    buf,
const wchar_t *    format,
...   
[static]
 

Definition at line 1081 of file OS.cpp.

References ACE_OS_TRACE.

01082 {
01083   ACE_OS_TRACE ("ACE_OS::sprintf");
01084 
01085 # if defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
01086 
01087   // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a
01088   // maxlen argument. Since this method doesn't supply one, pass in
01089   // the max possible length. If this isn't ok, use ACE_OS::snprintf().
01090   int result;
01091   va_list ap;
01092   va_start (ap, format);
01093   ACE_OSCALL (::vswprintf (buf, ULONG_MAX, format, ap), int, -1, result);
01094   va_end (ap);
01095   return result;
01096 
01097 # elif defined (ACE_WIN32)
01098   // Windows has vswprintf, but the signature is from the older ISO C
01099   // standard. Also see ACE_OS::snprintf() for more info on this.
01100 
01101   int result;
01102   va_list ap;
01103   va_start (ap, format);
01104   ACE_OSCALL (::vswprintf (buf, format, ap), int, -1, result);
01105   va_end (ap);
01106   return result;
01107 
01108 # else
01109 
01110   ACE_UNUSED_ARG (buf);
01111   ACE_UNUSED_ARG (format);
01112   ACE_NOTSUP_RETURN (-1);
01113 
01114 # endif /* ACE_HAS_VSWPRINTF */
01115 }

int ACE_OS::sprintf char *    buf,
const char *    format,
...   
[static]
 

Definition at line 1067 of file OS.cpp.

References ACE_SPRINTF_ADAPTER, and vsprintf.

Referenced by ACE_MEM_Acceptor::accept, ACE_STATIC_SVC_DEFINE, ACE_TPQ_Entry::ACE_TPQ_Entry, ACE_INET_Addr::addr_to_string, ACE_ATM_Addr::addr_to_string, dlerror, ACE_ATM_Addr::dump, ACE_Ini_ImpExp::export_section, ACE_Registry_ImpExp::export_section, ACE::format_hexdump, ACE_Log_Record::format_msg, ACE_Sock_Connect::get_ip_interfaces, ACE_Logging_Strategy::handle_timeout, inet_ntop, ACE_Stream_Type::info, ACE_Module_Type::info, ACE_Service_Manager::info, ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info, ACE_Oneshot_Acceptor::info, ACE_Strategy_Acceptor::info, ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info, ACE_Lib_Find::ldfind, ACE_Log_Msg::log, ACE_Log_Msg::log_hexdump, mmap, ACE_Token_Proxy::open, ACE_Timeprobe::print_absolute_times, ACE_High_Res_Timer::print_ave, ACE_Stats::print_summary, ACE_High_Res_Timer::print_total, ACE_Process_Options::setenv, ACE::sock_error, socket_fini, socket_init, ACE_Process::spawn, ACE::timestamp, uname, and unique_name.

01068 {
01069   // ACE_OS_TRACE ("ACE_OS::sprintf");
01070 
01071   int result;
01072   va_list ap;
01073   va_start (ap, format);
01074   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsprintf (buf, format, ap)), int, -1, result);
01075   va_end (ap);
01076   return result;
01077 }

ACE_INLINE void ACE_OS::srand u_int    seed [static]
 

Definition at line 757 of file OS.i.

References ACE_OS_TRACE.

00758 {
00759   ACE_OS_TRACE ("ACE_OS::srand");
00760   ::srand (seed);
00761 }

ACE_INLINE int ACE_OS::stat const ACE_TCHAR   file,
ACE_stat  
[static]
 

Definition at line 683 of file OS.i.

References ACE_OS_TRACE, ACE_stat, ACE_TCHAR, set_errno_to_last_error, and stat.

Referenced by ACE_Filecache_Object::ACE_Filecache_Object, filesize, ACE_Filecache_Object::release, stat, and ACE_Filecache_Object::update.

00684 {
00685   ACE_OS_TRACE ("ACE_OS::stat");
00686 #if defined (VXWORKS)
00687   ACE_OSCALL_RETURN (::stat ((char *) file, stp), int, -1);
00688 #elif defined (ACE_PSOS_LACKS_PHILE)
00689   ACE_UNUSED_ARG (file);
00690   ACE_UNUSED_ARG (stp);
00691   ACE_NOTSUP_RETURN (-1);
00692 #elif defined (ACE_PSOS)
00693   ACE_OSCALL_RETURN (::stat_f ((char *) file, stp), int, -1);
00694 #elif defined (ACE_HAS_WINCE)
00695   ACE_TEXT_WIN32_FIND_DATA fdata;
00696 
00697   HANDLE fhandle;
00698 
00699   fhandle = ::FindFirstFile (file, &fdata);
00700   if (fhandle == INVALID_HANDLE_VALUE)
00701     {
00702       ACE_OS::set_errno_to_last_error ();
00703       return -1;
00704     }
00705   else if (fdata.nFileSizeHigh != 0)
00706     {
00707       errno = EINVAL;
00708       return -1;
00709     }
00710   else
00711     {
00712       stp->st_size = fdata.nFileSizeLow;
00713       stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime);
00714       stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime);
00715     }
00716   return 0;
00717 #elif defined (ACE_HAS_X86_STAT_MACROS)
00718    // Solaris for intel uses an macro for stat(), this macro is a
00719    // wrapper for _xstat().
00720   ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1);
00721 #elif defined (__BORLANDC__)  && (__BORLANDC__ <= 0x540) && defined (ACE_USES_WCHAR)
00722   ACE_OSCALL_RETURN (::_wstat (file, stp), int, -1);
00723 #elif defined (ACE_WIN32)
00724 #   if defined (ACE_USES_WCHAR)
00725   ACE_OSCALL_RETURN (::_wstat (file, (struct _stat *) stp), int, -1);
00726 #   else
00727   ACE_OSCALL_RETURN (::_stat (file, (struct _stat *) stp), int, -1);
00728 #   endif /* ACE_USES_WCHAR */
00729 #else /* VXWORKS */
00730   ACE_OSCALL_RETURN (::stat (file, stp), int, -1);
00731 #endif /* VXWORKS */
00732 }

ACE_INLINE int ACE_OS::step const char *    str,
char *    expbuf
[static]
 

Definition at line 8154 of file OS.i.

References ACE_OS_TRACE, and step.

Referenced by ACE_Local_Name_Space::list_type_entries_i, ACE_Local_Name_Space::list_types_i, and step.

08155 {
08156   ACE_OS_TRACE ("ACE_OS::step");
08157 #if defined (ACE_HAS_REGEX)
08158   ACE_OSCALL_RETURN (::step (str, expbuf), int, -1);
08159 #else
08160   ACE_UNUSED_ARG (str);
08161   ACE_UNUSED_ARG (expbuf);
08162 
08163   ACE_NOTSUP_RETURN (-1);
08164 #endif /* ACE_HAS_REGEX */
08165 }

ACE_INLINE ACE_TCHAR * ACE_OS::strenvdup const ACE_TCHAR   str [static]
 

Definition at line 11074 of file OS.i.

References ACE_LIB_TEXT, ACE_TCHAR, getenv, and ACE_OS_String::strdup.

Referenced by ACE::strenvdup, and string_to_argv.

11075 {
11076 #if defined (ACE_HAS_WINCE)
11077   // WinCE doesn't have environment variables so we just skip it.
11078   return ACE_OS::strdup (str);
11079 #elif defined (ACE_LACKS_ENV)
11080   ACE_UNUSED_ARG (str);
11081   ACE_NOTSUP_RETURN (0);
11082 #else
11083   ACE_TCHAR *temp = 0;
11084 
11085   if (str[0] == ACE_LIB_TEXT ('$')
11086       && (temp = ACE_OS::getenv (&str[1])) != 0)
11087     return ACE_OS::strdup (temp);
11088   else
11089     return ACE_OS::strdup (str);
11090 #endif /* ACE_HAS_WINCE */
11091 }

ACE_INLINE size_t ACE_OS::strftime char *    s,
size_t    maxsize,
const char *    format,
const struct tm *    timeptr
[static]
 

Definition at line 8860 of file OS.i.

08862 {
08863 #if !defined (ACE_HAS_WINCE) && !defined(ACE_PSOS) || defined (ACE_PSOS_HAS_TIME)
08864   return ::strftime (s, maxsize, format, timeptr);
08865 #else
08866   ACE_UNUSED_ARG (s);
08867   ACE_UNUSED_ARG (maxsize);
08868   ACE_UNUSED_ARG (format);
08869   ACE_UNUSED_ARG (timeptr);
08870   ACE_NOTSUP_RETURN (0);
08871 #endif /* !ACE_HAS_WINCE && !ACE_PSOS || ACE_PSOS_HAS_TIME */
08872 }

int ACE_OS::string_to_argv ACE_TCHAR   buf,
int &    argc,
ACE_TCHAR **&    argv,
int    substitute_env_args = 1
[static]
 

Definition at line 3967 of file OS.cpp.

References ACE_DEFAULT_ARGV_BUFSIZ, ACE_OS_String::ace_isspace, ACE_NEW_RETURN, ACE_TCHAR, ACE_OS_String::strdup, and strenvdup.

Referenced by ACE_ARGV::string_to_argv.

03971 {
03972   // Reset the number of arguments
03973   argc = 0;
03974 
03975   if (buf == 0)
03976     return -1;
03977 
03978   ACE_TCHAR *cp = buf;
03979 
03980   // First pass: count arguments.
03981 
03982   // '#' is the start-comment token..
03983   while (*cp != '\0' && *cp != '#')
03984     {
03985       // Skip whitespace..
03986       while (ACE_OS::ace_isspace (*cp))
03987         cp++;
03988 
03989       // Increment count and move to next whitespace..
03990       if (*cp != '\0')
03991         argc++;
03992 
03993       while (*cp != '\0' && !ACE_OS::ace_isspace (*cp))
03994         {
03995           // Grok quotes....
03996           if (*cp == '\'' || *cp == '"')
03997             {
03998               ACE_TCHAR quote = *cp;
03999 
04000               // Scan past the string..
04001               for (cp++; *cp != '\0' && *cp != quote; cp++)
04002                 continue;
04003 
04004               // '\0' implies unmatched quote..
04005               if (*cp == '\0')
04006                 {
04007                   argc--;
04008                   break;
04009                 }
04010               else
04011                 cp++;
04012             }
04013           else
04014             cp++;
04015         }
04016     }
04017 
04018   // Second pass: copy arguments.
04019   ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
04020   ACE_TCHAR *argp = arg;
04021 
04022   // Make sure that the buffer we're copying into is always large
04023   // enough.
04024   if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
04025     ACE_NEW_RETURN (argp,
04026                     ACE_TCHAR[cp - buf + 1],
04027                     -1);
04028 
04029   // Make a new argv vector of argc + 1 elements.
04030   ACE_NEW_RETURN (argv,
04031                   ACE_TCHAR *[argc + 1],
04032                   -1);
04033 
04034   ACE_TCHAR *ptr = buf;
04035 
04036   for (int i = 0; i < argc; i++)
04037     {
04038       // Skip whitespace..
04039       while (ACE_OS::ace_isspace (*ptr))
04040         ptr++;
04041 
04042       // Copy next argument and move to next whitespace..
04043       cp = argp;
04044       while (*ptr != '\0' && !ACE_OS::ace_isspace (*ptr))
04045         if (*ptr == '\'' || *ptr == '"')
04046           {
04047             ACE_TCHAR quote = *ptr++;
04048 
04049             while (*ptr != '\0' && *ptr != quote)
04050               *cp++ = *ptr++;
04051 
04052             if (*ptr == quote)
04053               ptr++;
04054           }
04055         else
04056           *cp++ = *ptr++;
04057 
04058       *cp = '\0';
04059 
04060 #if !defined (ACE_LACKS_ENV)
04061       // Check for environment variable substitution here.
04062       if (substitute_env_args) {
04063           argv[i] = ACE_OS::strenvdup(argp);
04064 
04065           if (argv[i] == 0)
04066             {
04067               if (argp != arg)
04068                 delete [] argp;
04069               errno = ENOMEM;
04070               return -1;
04071             }
04072       }
04073       else
04074 #endif /* ACE_LACKS_ENV */
04075         {
04076           argv[i] = ACE_OS::strdup(argp);
04077 
04078           if (argv[i] == 0)
04079             {
04080               if (argp != arg)
04081                 delete [] argp;
04082               errno = ENOMEM;
04083               return -1;
04084             }
04085       }
04086   }
04087 
04088   if (argp != arg)
04089     delete [] argp;
04090 
04091   argv[argc] = 0;
04092   return 0;
04093 }

ACE_INLINE long ACE_OS::sysconf int    [static]
 

Definition at line 1079 of file OS.i.

References ACE_OS_TRACE, and sysconf.

Referenced by ACE_POSIX_AIOCB_Proactor::check_max_aio_num, ACE::max_handles, sysconf, and thr_min_stack.

01080 {
01081   ACE_OS_TRACE ("ACE_OS::sysconf");
01082 #if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_PSOS)
01083   ACE_UNUSED_ARG (name);
01084   ACE_NOTSUP_RETURN (-1);
01085 #else
01086   ACE_OSCALL_RETURN (::sysconf (name), long, -1);
01087 #endif /* ACE_WIN32 || VXWORKS || ACE_PSOS */
01088 }

ACE_INLINE long ACE_OS::sysinfo int    cmd,
char *    buf,
long    count
[static]
 

Definition at line 8168 of file OS.i.

References ACE_OS_TRACE, and sysinfo.

Referenced by ACE_POSIX_Proactor::ACE_POSIX_Proactor, and sysinfo.

08169 {
08170   ACE_OS_TRACE ("ACE_OS::sysinfo");
08171 #if defined (ACE_HAS_SYSINFO)
08172   ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1);
08173 #else
08174   ACE_UNUSED_ARG (cmd);
08175   ACE_UNUSED_ARG (buf);
08176   ACE_UNUSED_ARG (count);
08177 
08178   ACE_NOTSUP_RETURN (0);
08179 #endif /* ACE_HAS_SYSINFO */
08180 }

ACE_INLINE int ACE_OS::system const ACE_TCHAR   s [static]
 

Definition at line 6403 of file OS.i.

References ACE_TCHAR, and system.

Referenced by system.

06404 {
06405   // ACE_OS_TRACE ("ACE_OS::system");
06406 #if defined (CHORUS) || defined (ACE_HAS_WINCE) || defined(ACE_PSOS)
06407   ACE_UNUSED_ARG (s);
06408   ACE_NOTSUP_RETURN (-1);
06409 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
06410   ACE_OSCALL_RETURN (::_wsystem (s), int, -1);
06411 #else
06412   ACE_OSCALL_RETURN (::system (s), int, -1);
06413 #endif /* !CHORUS */
06414 }

ACE_INLINE ACE_TCHAR * ACE_OS::tempnam const ACE_TCHAR   dir = 0,
const ACE_TCHAR   pfx = 0
[static]
 

Definition at line 831 of file OS.i.

References ACE_OS_TRACE, ACE_TCHAR, and tempnam.

Referenced by tempnam.

00832 {
00833   ACE_OS_TRACE ("ACE_OS::tempnam");
00834 #if defined (VXWORKS) || defined (ACE_HAS_WINCE) || defined (ACE_LACKS_TEMPNAM)
00835   ACE_UNUSED_ARG (dir);
00836   ACE_UNUSED_ARG (pfx);
00837   ACE_NOTSUP_RETURN (0);
00838 #elif defined (ACE_PSOS)
00839   // pSOS only considers the directory prefix
00840   ACE_UNUSED_ARG (pfx);
00841   ACE_OSCALL_RETURN (::tmpnam ((char *) dir), char *, 0);
00842 #elif (defined (ACE_WIN32) && ((defined (__BORLANDC__) && !defined(ACE_USES_WCHAR)) || defined (__IBMCPP__)))
00843   ACE_OSCALL_RETURN (::_tempnam ((char *) dir, (char *) pfx), char *, 0);
00844 #elif defined(ACE_WIN32) && defined (__BORLANDC__) && defined (ACE_USES_WCHAR)
00845   ACE_OSCALL_RETURN (::_wtempnam ((wchar_t*) dir, (wchar_t*) pfx), wchar_t *, 0);
00846 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00847   ACE_OSCALL_RETURN (::_wtempnam (dir, pfx), wchar_t *, 0);
00848 #else /* VXWORKS */
00849   ACE_OSCALL_RETURN (::tempnam (dir, pfx), char *, 0);
00850 #endif /* VXWORKS */
00851 }

ACE_INLINE int ACE_OS::thr_cancel ACE_thread_t    t_id [static]
 

Definition at line 6955 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and ACE_thread_t.

Referenced by ACE_Thread::cancel.

06956 {
06957   ACE_OS_TRACE ("ACE_OS::thr_cancel");
06958 #if defined (ACE_HAS_THREADS)
06959 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
06960 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
06961   ACE_OSCALL_RETURN (::pthread_cancel (thr_id), int, -1);
06962 #   else
06963   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_cancel (thr_id),
06964                                        ace_result_),
06965                      int, -1);
06966 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
06967 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
06968   ACE_UNUSED_ARG (thr_id);
06969   ACE_NOTSUP_RETURN (-1);
06970 # endif /* ACE_HAS_PTHREADS */
06971 #else
06972   ACE_UNUSED_ARG (thr_id);
06973   ACE_NOTSUP_RETURN (-1);
06974 #endif /* ACE_HAS_THREADS */
06975 }

ACE_INLINE int ACE_OS::thr_cmp ACE_hthread_t    t1,
ACE_hthread_t    t2
[static]
 

Definition at line 6450 of file OS.i.

References ACE_hthread_t.

Referenced by ACE_Thread_Manager::find_hthread, ACE_Thread_Manager::hthread_within, ACE_Thread_Descriptor_Base::operator==, and ACE_Thread_ID::operator==.

06451 {
06452 #if defined (ACE_HAS_PTHREADS)
06453 # if defined (pthread_equal)
06454   // If it's a macro we can't say "::pthread_equal"...
06455   return pthread_equal (t1, t2);
06456 # else
06457   return ::pthread_equal (t1, t2);
06458 # endif /* pthread_equal */
06459 #else /* For STHREADS, WTHREADS, and VXWORKS ... */
06460   // Hum, Do we need to treat WTHREAD differently?
06461   // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE.
06462   return t1 == t2;
06463 #endif /* ACE_HAS_PTHREADS */
06464 }

ACE_INLINE int ACE_OS::thr_continue ACE_hthread_t    target_thread [static]
 

Definition at line 6417 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_continue.

Referenced by ACE_Thread::resume, thr_continue, and thr_create.

06418 {
06419   ACE_OS_TRACE ("ACE_OS::thr_continue");
06420 #if defined (ACE_HAS_THREADS)
06421 # if defined (ACE_HAS_STHREADS)
06422   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), ace_result_), int, -1);
06423 # elif defined (ACE_HAS_PTHREADS)
06424 #  if defined (ACE_HAS_PTHREAD_CONTINUE)
06425   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread),
06426                                        ace_result_),
06427                      int, -1);
06428 #  else
06429   ACE_UNUSED_ARG (target_thread);
06430   ACE_NOTSUP_RETURN (-1);
06431 #  endif /* ACE_HAS_PTHREAD_CONTINUE */
06432 # elif defined (ACE_HAS_WTHREADS)
06433   DWORD result = ::ResumeThread (target_thread);
06434   if (result == ACE_SYSCALL_FAILED)
06435     ACE_FAIL_RETURN (-1);
06436   else
06437     return 0;
06438 # elif defined (ACE_PSOS)
06439   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_resume (target_thread), ace_result_), int, -1);
06440 # elif defined (VXWORKS)
06441   ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1);
06442 # endif /* ACE_HAS_STHREADS */
06443 #else
06444   ACE_UNUSED_ARG (target_thread);
06445   ACE_NOTSUP_RETURN (-1);
06446 #endif /* ACE_HAS_THREADS */
06447 }

int ACE_OS::thr_create ACE_THR_FUNC    func,
void *    args,
long    flags,
ACE_thread_t   thr_id,
ACE_hthread_t   t_handle = 0,
long    priority = ACE_DEFAULT_THREAD_PRIORITY,
void *    stack = 0,
size_t    stacksize = 0,
ACE_Base_Thread_Adapter   thread_adapter = 0
[static]
 

Definition at line 2562 of file OS.cpp.

References ACE_ADAPT_RETVAL, ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_DEFAULT_THREAD_PRIORITY, ACE_hthread_t, ACE_MAX, ACE_MIN, ACE_NEW_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SET_BITS, ACE_THR_PRI_FIFO_DEF, ACE_THR_PRI_OTHER_DEF, ACE_thread_t, ENOSYS, ENOTSUP, ACE_Base_Thread_Adapter::entry_point, lwp_setparams, ACE_OS_String::memset, sched_params, ACE_OS_String::strsncpy, thr_continue, thr_create, thr_getconcurrency, thr_self, thr_setconcurrency, and thr_setprio.

Referenced by ACE_Thread::spawn, ACE_Thread::spawn_n, and thr_create.

02571 {
02572   ACE_OS_TRACE ("ACE_OS::thr_create");
02573 
02574   if (ACE_BIT_DISABLED (flags, THR_DETACHED) &&
02575       ACE_BIT_DISABLED (flags, THR_JOINABLE))
02576     ACE_SET_BITS (flags, THR_JOINABLE);
02577 
02578 # if defined (ACE_NO_THREAD_ADAPTER)
02579 #   define  ACE_THREAD_FUNCTION  func
02580 #   define  ACE_THREAD_ARGUMENT  args
02581 # else /* ! defined (ACE_NO_THREAD_ADAPTER) */
02582 #   if defined (ACE_PSOS)
02583 #     define  ACE_THREAD_FUNCTION (PSOS_TASK_ENTRY_POINT) thread_args->entry_point ()
02584 #   else
02585 #     define  ACE_THREAD_FUNCTION  thread_args->entry_point ()
02586 #   endif /* defined (ACE_PSOS) */
02587 #   define  ACE_THREAD_ARGUMENT  thread_args
02588 # endif /* ! defined (ACE_NO_THREAD_ADAPTER) */
02589 
02590 
02591   ACE_Base_Thread_Adapter *thread_args;
02592   if (thread_adapter == 0)
02593 
02594 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
02595     ACE_NEW_RETURN (thread_args,
02596                     ACE_OS_Thread_Adapter (func, args,
02597                                            (ACE_THR_C_FUNC) ace_thread_adapter,
02598                                            ACE_OS_Object_Manager::seh_except_selector(),
02599                                            ACE_OS_Object_Manager::seh_except_handler()),
02600                     -1);
02601 # else
02602   ACE_NEW_RETURN (thread_args,
02603                   ACE_OS_Thread_Adapter (func, args,
02604                                          (ACE_THR_C_FUNC) ace_thread_adapter),
02605                   -1);
02606 
02607 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
02608   else
02609     thread_args = thread_adapter;
02610 
02611 # if defined (ACE_HAS_THREADS)
02612 
02613   // *** Set Stack Size
02614 #   if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
02615   if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE)
02616     stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE;
02617 #   endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
02618 
02619 #   if !defined (VXWORKS)
02620   // On VxWorks, the OS will provide a task name if the user doesn't.
02621   // So, we don't need to create a tmp_thr.  If the caller of this
02622   // member function is the Thread_Manager, than thr_id will be non-zero
02623   // anyways.
02624   ACE_thread_t tmp_thr;
02625 
02626   if (thr_id == 0)
02627     thr_id = &tmp_thr;
02628 #   endif /* ! VXWORKS */
02629 
02630   ACE_hthread_t tmp_handle;
02631   if (thr_handle == 0)
02632     thr_handle = &tmp_handle;
02633 
02634 #   if defined (ACE_HAS_PTHREADS)
02635 
02636   int result;
02637   pthread_attr_t attr;
02638 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
02639   if (::pthread_attr_create (&attr) != 0)
02640 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
02641     if (::pthread_attr_init (&attr) != 0)
02642 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
02643       return -1;
02644 
02645 #     if defined (CHORUS)
02646   // If it is a super actor, we can't set stacksize.  But for the time
02647   // being we are all non-super actors.  Should be fixed to take care
02648   // of super actors!!!
02649   if (stacksize == 0)
02650     stacksize = ACE_CHORUS_DEFAULT_MIN_STACK_SIZE;
02651   else if (stacksize < ACE_CHORUS_DEFAULT_MIN_STACK_SIZE)
02652     stacksize = ACE_CHORUS_DEFAULT_MIN_STACK_SIZE;
02653 #     endif /*CHORUS */
02654 
02655 # if defined (ACE_HAS_PTHREAD_SETSTACK)
02656   if ((stacksize != 0) && (stack != 0))
02657 # else
02658   if (stacksize != 0)
02659 # endif /* ACE_HAS_PTHREAD_SETSTACK */
02660     {
02661       size_t size = stacksize;
02662 
02663 #     if defined (PTHREAD_STACK_MIN)
02664       if (size < ACE_static_cast (size_t, PTHREAD_STACK_MIN))
02665         size = PTHREAD_STACK_MIN;
02666 #     endif /* PTHREAD_STACK_MIN */
02667 
02668 #     if !defined (ACE_LACKS_THREAD_STACK_SIZE)      // JCEJ 12/17/96
02669 #       if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02670       if (::pthread_attr_setstacksize (&attr, size) != 0)
02671 #       else
02672 #         if defined (ACE_HAS_PTHREAD_SETSTACK)
02673         if (ACE_ADAPT_RETVAL(pthread_attr_setstack (&attr, stack, size), result) == -1)
02674 #         else
02675         if (ACE_ADAPT_RETVAL(pthread_attr_setstacksize (&attr, size), result) == -1)
02676 #         endif /* ACE_HAS_PTHREAD_SETSTACK */
02677 #       endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02678           {
02679 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02680             ::pthread_attr_delete (&attr);
02681 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02682             ::pthread_attr_destroy (&attr);
02683 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02684             return -1;
02685           }
02686 #     else
02687       ACE_UNUSED_ARG (size);
02688 #     endif /* !ACE_LACKS_THREAD_STACK_SIZE */
02689     }
02690 
02691   // *** Set Stack Address
02692 #     if !defined (ACE_HAS_PTHREAD_SETSTACK)
02693 #     if !defined (ACE_LACKS_THREAD_STACK_ADDR)
02694   if (stack != 0)
02695     {
02696       if (::pthread_attr_setstackaddr (&attr, stack) != 0)
02697         {
02698 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02699           ::pthread_attr_delete (&attr);
02700 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02701           ::pthread_attr_destroy (&attr);
02702 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02703           return -1;
02704         }
02705     }
02706 #     else
02707   ACE_UNUSED_ARG (stack);
02708 #     endif /* !ACE_LACKS_THREAD_STACK_ADDR */
02709 #     endif /* ACE_HAS_PTHREAD_SETSTACK */
02710 
02711   // *** Deal with various attributes
02712   if (flags != 0)
02713     {
02714       // *** Set Detach state
02715 #     if !defined (ACE_LACKS_SETDETACH)
02716       if (ACE_BIT_ENABLED (flags, THR_DETACHED)
02717           || ACE_BIT_ENABLED (flags, THR_JOINABLE))
02718         {
02719           int dstate = PTHREAD_CREATE_JOINABLE;
02720 
02721           if (ACE_BIT_ENABLED (flags, THR_DETACHED))
02722             dstate = PTHREAD_CREATE_DETACHED;
02723 
02724 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02725           if (::pthread_attr_setdetach_np (&attr, dstate) != 0)
02726 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02727 #         if defined (ACE_HAS_PTHREADS_DRAFT6)
02728             if (::pthread_attr_setdetachstate (&attr, &dstate) != 0)
02729 #         else
02730               if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate),
02731                                    result) != 0)
02732 #         endif /* ACE_HAS_PTHREADS_DRAFT6 */
02733 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02734                 {
02735 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02736                   ::pthread_attr_delete (&attr);
02737 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02738                   ::pthread_attr_destroy (&attr);
02739 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02740                   return -1;
02741                 }
02742         }
02743 
02744       // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we
02745       // call ::pthread_detach () below.  If THR_DETACHED is not
02746       // enabled, we call ::pthread_detach () in the Thread_Manager,
02747       // after joining with the thread.
02748 #     endif /* ACE_LACKS_SETDETACH */
02749 
02750       // *** Set Policy
02751 #     if !defined (ACE_LACKS_SETSCHED)
02752       // If we wish to set the priority explicitly, we have to enable
02753       // explicit scheduling, and a policy, too.
02754       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
02755         {
02756           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
02757           if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO)
02758               && ACE_BIT_DISABLED (flags, THR_SCHED_RR)
02759               && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT))
02760             ACE_SET_BITS (flags, THR_SCHED_DEFAULT);
02761         }
02762 
02763       if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
02764           || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
02765           || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
02766         {
02767           int spolicy;
02768 
02769 #       if defined (ACE_HAS_ONLY_SCHED_OTHER)
02770           // SunOS, thru version 5.6, only supports SCHED_OTHER.
02771           spolicy = SCHED_OTHER;
02772 #       else
02773           // Make sure to enable explicit scheduling, in case we didn't
02774           // enable it above (for non-default priority).
02775           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
02776 
02777           if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
02778             spolicy = SCHED_OTHER;
02779           else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
02780             spolicy = SCHED_FIFO;
02781 #         if defined (SCHED_IO)
02782           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
02783             spolicy = SCHED_IO;
02784 #         else
02785           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
02786             {
02787               errno = ENOSYS;
02788               return -1;
02789             }
02790 #         endif /* SCHED_IO */
02791           else
02792             spolicy = SCHED_RR;
02793 
02794 #         if defined (ACE_HAS_FSU_PTHREADS)
02795           int ret;
02796           switch (spolicy)
02797             {
02798             case SCHED_FIFO:
02799             case SCHED_RR:
02800               ret = 0;
02801               break;
02802             default:
02803               ret = 22;
02804               break;
02805             }
02806           if (ret != 0)
02807             {
02808               ::pthread_attr_destroy (&attr);
02809               return -1;
02810             }
02811 #         endif    /*  ACE_HAS_FSU_PTHREADS */
02812 
02813 #       endif /* ACE_HAS_ONLY_SCHED_OTHER */
02814 
02815 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02816           result = ::pthread_attr_setsched (&attr, spolicy);
02817 #       elif defined (ACE_HAS_PTHREADS_DRAFT6)
02818           result = ::pthread_attr_setschedpolicy (&attr, spolicy);
02819 #       else  /* draft 7 or std */
02820           ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy),
02821                            result);
02822 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02823           if (result != 0)
02824             {
02825 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02826               ::pthread_attr_delete (&attr);
02827 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02828               ::pthread_attr_destroy (&attr);
02829 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02830               return -1;
02831             }
02832         }
02833 
02834       // *** Set Priority (use reasonable default priorities)
02835 #       if defined(ACE_HAS_PTHREADS_STD)
02836       // If we wish to explicitly set a scheduling policy, we also
02837       // have to specify a priority.  We choose a "middle" priority as
02838       // default.  Maybe this is also necessary on other POSIX'ish
02839       // implementations?
02840       if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
02841            || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
02842            || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
02843           && priority == ACE_DEFAULT_THREAD_PRIORITY)
02844         {
02845           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
02846             priority = ACE_THR_PRI_FIFO_DEF;
02847           else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR))
02848             priority = ACE_THR_PRI_RR_DEF;
02849           else // THR_SCHED_DEFAULT
02850             priority = ACE_THR_PRI_OTHER_DEF;
02851         }
02852 #       endif /* ACE_HAS_PTHREADS_STD */
02853       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
02854         {
02855           struct sched_param sparam;
02856           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
02857 
02858 #       if defined (ACE_HAS_IRIX62_THREADS)
02859           sparam.sched_priority = ACE_MIN (priority,
02860                                            (long) PTHREAD_MAX_PRIORITY);
02861 #       elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS_STD)
02862           /* For MIT pthreads... */
02863           sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY);
02864 #       elif defined(ACE_HAS_PTHREADS_STD) && !defined (ACE_HAS_STHREADS)
02865           // The following code forces priority into range.
02866           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
02867             sparam.sched_priority =
02868               ACE_MIN (ACE_THR_PRI_FIFO_MAX,
02869                        ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
02870           else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
02871             sparam.sched_priority =
02872               ACE_MIN (ACE_THR_PRI_RR_MAX,
02873                        ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
02874           else // Default policy, whether set or not
02875             sparam.sched_priority =
02876               ACE_MIN (ACE_THR_PRI_OTHER_MAX,
02877                        ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
02878 #       elif defined (PRIORITY_MAX)
02879           sparam.sched_priority = ACE_MIN (priority,
02880                                            (long) PRIORITY_MAX);
02881 #       else
02882           sparam.sched_priority = priority;
02883 #       endif /* ACE_HAS_IRIX62_THREADS */
02884 
02885 #       if defined (ACE_HAS_FSU_PTHREADS)
02886           if (sparam.sched_priority >= PTHREAD_MIN_PRIORITY
02887               && sparam.sched_priority <= PTHREAD_MAX_PRIORITY)
02888             attr.prio = sparam.sched_priority;
02889           else
02890             {
02891               pthread_attr_destroy (&attr);
02892               errno = EINVAL;
02893               return -1;
02894             }
02895 #       else
02896           {
02897 #         if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
02898             // SunOS, through 5.6, POSIX only allows priorities > 0 to
02899             // ::pthread_attr_setschedparam.  If a priority of 0 was
02900             // requested, set the thread priority after creating it, below.
02901             if (priority > 0)
02902 #         endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
02903               {
02904 #         if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02905                 result = ::pthread_attr_setprio (&attr,
02906                                                  sparam.sched_priority);
02907 #         else /* this is draft 7 or std */
02908                 ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam),
02909                                  result);
02910 #         endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02911                 if (result != 0)
02912                   {
02913 #         if defined (ACE_HAS_PTHREADS_DRAFT4)
02914                     ::pthread_attr_delete (&attr);
02915 #         else /* ACE_HAS_PTHREADS_DRAFT4 */
02916                     ::pthread_attr_destroy (&attr);
02917 #         endif /* ACE_HAS_PTHREADS_DRAFT4 */
02918                     return -1;
02919                   }
02920               }
02921           }
02922 #       endif    /* ACE_HAS_FSU_PTHREADS */
02923         }
02924 
02925       // *** Set scheduling explicit or inherited
02926       if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)
02927           || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED))
02928         {
02929 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02930           int sched = PTHREAD_DEFAULT_SCHED;
02931 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02932           int sched = PTHREAD_EXPLICIT_SCHED;
02933 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02934           if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED))
02935             sched = PTHREAD_INHERIT_SCHED;
02936           if (::pthread_attr_setinheritsched (&attr, sched) != 0)
02937             {
02938 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02939               ::pthread_attr_delete (&attr);
02940 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02941               ::pthread_attr_destroy (&attr);
02942 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02943               return -1;
02944             }
02945         }
02946 #     else /* ACE_LACKS_SETSCHED */
02947       ACE_UNUSED_ARG (priority);
02948 #     endif /* ACE_LACKS_SETSCHED */
02949 
02950       // *** Set Scope
02951 #     if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING)
02952       if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)
02953           || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS))
02954         {
02955 #         if defined (ACE_CONFIG_LINUX_H) || defined (HPUX)
02956           // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS.
02957           // Neither does HPUX (up to HP-UX 11.00, as far as I know).
02958           int scope = PTHREAD_SCOPE_SYSTEM;
02959 #         else /* ACE_CONFIG_LINUX_H */
02960           int scope = PTHREAD_SCOPE_PROCESS;
02961 #         endif /* ACE_CONFIG_LINUX_H */
02962           if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM))
02963             scope = PTHREAD_SCOPE_SYSTEM;
02964 
02965           if (::pthread_attr_setscope (&attr, scope) != 0)
02966             {
02967 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
02968               ::pthread_attr_delete (&attr);
02969 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
02970               ::pthread_attr_destroy (&attr);
02971 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
02972               return -1;
02973             }
02974         }
02975 #     endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */
02976 
02977       if (ACE_BIT_ENABLED (flags, THR_NEW_LWP))
02978         {
02979           // Increment the number of LWPs by one to emulate the
02980           // SunOS semantics.
02981           int lwps = ACE_OS::thr_getconcurrency ();
02982           if (lwps == -1)
02983             {
02984               if (errno == ENOTSUP)
02985                 // Suppress the ENOTSUP because it's harmless.
02986                 errno = 0;
02987               else
02988                 // This should never happen on SunOS:
02989                 // ::thr_getconcurrency () should always succeed.
02990                 return -1;
02991             }
02992           else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1)
02993             {
02994               if (errno == ENOTSUP)
02995                 {
02996                   // Unlikely:  ::thr_getconcurrency () is supported but
02997                   // ::thr_setconcurrency () is not?
02998                 }
02999               else
03000                 return -1;
03001             }
03002         }
03003     }
03004 
03005 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
03006   ACE_OSCALL (::pthread_create (thr_id, attr,
03007                                 thread_args->entry_point (),
03008                                 thread_args),
03009               int, -1, result);
03010 
03011 #       if defined (ACE_LACKS_SETDETACH)
03012   if (ACE_BIT_ENABLED (flags, THR_DETACHED))
03013     {
03014 #         if defined (HPUX_10)
03015       // HP-UX DCE threads' pthread_detach will smash thr_id if it's
03016       // just given as an argument.  This will cause
03017       // ACE_Thread_Manager (if it's doing this create) to lose track
03018       // of the new thread since the ID will be passed back equal to
03019       // 0.  So give pthread_detach a junker to scribble on.
03020       ACE_thread_t  junker;
03021       cma_handle_assign(thr_id, &junker);
03022       ::pthread_detach (&junker);
03023 #         else
03024       ::pthread_detach (thr_id);
03025 #         endif /* HPUX_10 */
03026     }
03027 #       endif /* ACE_LACKS_SETDETACH */
03028 
03029   ::pthread_attr_delete (&attr);
03030 
03031 #     elif defined (ACE_HAS_PTHREADS_DRAFT6)
03032   ACE_OSCALL (::pthread_create (thr_id, &attr,
03033                                 thread_args->entry_point (),
03034                                 thread_args),
03035               int, -1, result);
03036   ::pthread_attr_destroy (&attr);
03037 
03038 #     else /* this is draft 7 or std */
03039   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id,
03040                                                   &attr,
03041                                                   thread_args->entry_point (),
03042                                                   thread_args),
03043                                 result),
03044               int, -1, result);
03045   ::pthread_attr_destroy (&attr);
03046 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
03047 
03048   // This is a SunOS or POSIX implementation of pthreads, where we
03049   // assume that ACE_thread_t and ACE_hthread_t are the same.  If this
03050   // *isn't* correct on some platform, please let us know.
03051   if (result != -1)
03052     *thr_handle = *thr_id;
03053 
03054 #     if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
03055   // SunOS prior to 5.7:
03056 
03057   // If the priority is 0, then we might have to set it now because we
03058   // couldn't set it with ::pthread_attr_setschedparam, as noted
03059   // above.  This doesn't provide strictly correct behavior, because
03060   // the thread was created (above) with the priority of its parent.
03061   // (That applies regardless of the inherit_sched attribute: if it
03062   // was PTHREAD_INHERIT_SCHED, then it certainly inherited its
03063   // parent's priority.  If it was PTHREAD_EXPLICIT_SCHED, then "attr"
03064   // was initialized by the SunOS ::pthread_attr_init () to contain
03065   // NULL for the priority, which indicated to SunOS ::pthread_create
03066   // () to inherit the parent priority.)
03067   if (priority == 0)
03068     {
03069       // Check the priority of this thread, which is the parent
03070       // of the newly created thread.  If it is 0, then the
03071       // newly created thread will have inherited the priority
03072       // of 0, so there's no need to explicitly set it.
03073       struct sched_param sparam;
03074       int policy = 0;
03075       ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (),
03076                                                              &policy,
03077                                                              &sparam),
03078                                     result), int,
03079                   -1, result);
03080 
03081       // The only policy supported by by SunOS, thru version 5.6,
03082       // is SCHED_OTHER, so that's hard-coded here.
03083       policy = ACE_SCHED_OTHER;
03084 
03085       if (sparam.sched_priority != 0)
03086         {
03087           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
03088           // The memset to 0 sets the priority to 0, so we don't need
03089           // to explicitly set sparam.sched_priority.
03090 
03091           ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id,
03092                                                                         policy,
03093                                                                         &sparam),
03094                                                result),
03095                              int, -1);
03096         }
03097     }
03098 
03099 #       if defined (ACE_NEEDS_LWP_PRIO_SET)
03100 #         if 0
03101   // It would be useful if we could make this work.  But, it requires
03102   // a mechanism for determining the ID of an LWP to which another
03103   // thread is bound.  Is there a way to do that?  Instead, just rely
03104   // on the code in ACE_Thread_Adapter::invoke () to set the LWP
03105   // priority.
03106 
03107   // If the thread is bound, then set the priority on its LWP.
03108   if (ACE_BIT_ENABLED (flags, THR_BOUND))
03109     {
03110       ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) ||
03111                                      ACE_BIT_ENABLED (flags, THR_SCHED_RR)  ?
03112                                      ACE_SCHED_FIFO  :
03113                                      ACE_SCHED_OTHER,
03114                                      priority);
03115       result = ACE_OS::lwp_setparams (sched_params,
03116                                       /* ? How do we find the ID of the LWP
03117                                          to which *thr_id is bound? */);
03118     }
03119 #         endif /* 0 */
03120 #       endif /* ACE_NEEDS_LWP_PRIO_SET */
03121 
03122 #     endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
03123   return result;
03124 #   elif defined (ACE_HAS_STHREADS)
03125   int result;
03126   int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
03127 
03128   if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03129     // If we need to set the priority, then we need to start the
03130     // thread in a suspended mode.
03131     ACE_SET_BITS (flags, THR_SUSPENDED);
03132 
03133   ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize,
03134                                               thread_args->entry_point (),
03135                                               thread_args,
03136                                               flags, thr_id), result),
03137               int, -1, result);
03138 
03139   if (result != -1)
03140     {
03141       // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same.
03142       *thr_handle = *thr_id;
03143 
03144       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03145         {
03146           // Set the priority of the new thread and then let it
03147           // continue, but only if the user didn't start it suspended
03148           // in the first place!
03149           if ((result = ACE_OS::thr_setprio (*thr_id, priority)) != 0)
03150             {
03151               errno = result;
03152               return -1;
03153             }
03154 
03155           if (start_suspended == 0)
03156             {
03157               if ((result = ACE_OS::thr_continue (*thr_id)) != 0)
03158                 {
03159                   errno = result;
03160                   return -1;
03161                 }
03162             }
03163         }
03164     }
03165   return result;
03166 #   elif defined (ACE_HAS_WTHREADS)
03167   ACE_UNUSED_ARG (stack);
03168 #     if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
03169   if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
03170     {
03171       CWinThread *cwin_thread =
03172         ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (),
03173                           thread_args,
03174                           priority,
03175                           0,
03176                           flags | THR_SUSPENDED);
03177       // Have to duplicate the handle because
03178       // CWinThread::~CWinThread() closes the original handle.
03179 #       if !defined (ACE_HAS_WINCE)
03180       (void) ::DuplicateHandle (::GetCurrentProcess (),
03181                                 cwin_thread->m_hThread,
03182                                 ::GetCurrentProcess (),
03183                                 thr_handle,
03184                                 0,
03185                                 TRUE,
03186                                 DUPLICATE_SAME_ACCESS);
03187 #       endif /* ! ACE_HAS_WINCE */
03188       *thr_id = cwin_thread->m_nThreadID;
03189 
03190       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0)
03191         cwin_thread->ResumeThread ();
03192       // cwin_thread will be deleted in AfxThreadExit()
03193       // Warning: If AfxThreadExit() is called from within the
03194       // thread, ACE_TSS_Cleanup->exit() never gets called !
03195     }
03196   else
03197 #     endif /* ACE_HAS_MFC */
03198     {
03199       int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
03200 
03201       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03202         // If we need to set the priority, then we need to start the
03203         // thread in a suspended mode.
03204         ACE_SET_BITS (flags, THR_SUSPENDED);
03205 
03206       *thr_handle = (void *) ACE_BEGINTHREADEX (0,
03207                                                 ACE_static_cast
03208                                                    (u_int, stacksize),
03209                                                 thread_args->entry_point (),
03210                                                 thread_args,
03211                                                 flags,
03212                                                 thr_id);
03213 
03214       if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
03215         {
03216           // Set the priority of the new thread and then let it
03217           // continue, but only if the user didn't start it suspended
03218           // in the first place!
03219           ACE_OS::thr_setprio (*thr_handle, priority);
03220 
03221           if (start_suspended == 0)
03222             ACE_OS::thr_continue (*thr_handle);
03223         }
03224     }
03225 #     if 0
03226   *thr_handle = ::CreateThread
03227     (0,
03228      stacksize,
03229      LPTHREAD_START_ROUTINE (thread_args->entry_point ()),
03230      thread_args,
03231      flags,
03232      thr_id);
03233 #     endif /* 0 */
03234 
03235   // Close down the handle if no one wants to use it.
03236   if (thr_handle == &tmp_handle)
03237     ::CloseHandle (tmp_handle);
03238 
03239   if (*thr_handle != 0)
03240     return 0;
03241   else
03242     ACE_FAIL_RETURN (-1);
03243   /* NOTREACHED */
03244 
03245 #   elif defined (ACE_PSOS)
03246 
03247   // stack is created in the task's memory region 0
03248   ACE_UNUSED_ARG (stack);
03249 
03250   // task creation and start flags are fixed
03251   ACE_UNUSED_ARG (flags);
03252 
03253   // lowest priority is reserved for the IDLE pSOS+ system daemon,
03254   // highest are reserved for high priority pSOS+ system daemons
03255   if (priority < PSOS_TASK_MIN_PRIORITY)
03256     {
03257       priority = PSOS_TASK_MIN_PRIORITY;
03258     }
03259   else if (priority > PSOS_TASK_MAX_PRIORITY)
03260     {
03261       priority = PSOS_TASK_MAX_PRIORITY;
03262     }
03263 
03264   // set the stacksize to a default value if no size is specified
03265   if (stacksize == 0)
03266     stacksize = ACE_PSOS_DEFAULT_STACK_SIZE;
03267 
03268   ACE_hthread_t tid;
03269   *thr_handle = 0;
03270 
03271   // create the thread
03272   if (t_create ((char *) thr_id, // task name
03273                 priority,        // (possibly adjusted) task priority
03274                 stacksize,       // passed stack size is used for supervisor stack
03275                 0,               // no user stack: tasks run strictly in supervisor mode
03276                 T_LOCAL,         // local to the pSOS+ node (does not support pSOS+m)
03277                 &tid)            // receives task id
03278       != 0)
03279     {
03280       return -1;
03281     }
03282 
03283   // pSOS tasks are passed an array of 4 u_longs
03284   u_long targs[4];
03285   targs[0] = (u_long) ACE_THREAD_ARGUMENT;
03286   targs[1] = 0;
03287   targs[2] = 0;
03288   targs[3] = 0;
03289 
03290   // start the thread
03291   if (t_start (tid,
03292                T_PREEMPT |            // Task can be preempted
03293                //             T_NOTSLICE |           // Task is not timesliced with other tasks at same priority
03294                T_TSLICE |             // Task is timesliced with other tasks at same priority
03295                T_NOASR |              // Task level signals disabled
03296                T_SUPV |               // Task runs strictly in supervisor mode
03297                T_ISR,                 // Hardware interrupts are enabled
03298                ACE_THREAD_FUNCTION,   // Task entry point
03299                targs)                 // Task argument(s)
03300       != 0)
03301     {
03302       return -1;
03303     }
03304 
03305   // store the task id in the handle and return success
03306   *thr_handle = tid;
03307   return 0;
03308 
03309 #   elif defined (VXWORKS)
03310   // The hard-coded values below are what ::sp () would use.  (::sp ()
03311   // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to
03312   // 20,000.)  stacksize should be an even integer.  If a stack is not
03313   // specified, ::taskSpawn () is used so that we can set the
03314   // priority, flags, and stacksize.  If a stack is specified,
03315   // ::taskInit ()/::taskActivate() are used.
03316 
03317   // If called with thr_create() defaults, use same default values as ::sp ():
03318   if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100;
03319   // Assumes that there is a floating point coprocessor.  As noted
03320   // above, ::sp () hardcodes this, so we should be safe with it.
03321   if (flags == 0) flags = VX_FP_TASK;
03322   if (stacksize == 0) stacksize = 20000;
03323 
03324   const u_int thr_id_provided =
03325     thr_id  &&  *thr_id  &&  (*thr_id)[0] != ACE_THR_ID_ALLOCATED;
03326 
03327   ACE_hthread_t tid;
03328 #     if 0 /* Don't support setting of stack, because it doesn't seem to work. */
03329   if (stack == 0)
03330     {
03331 #     else
03332       ACE_UNUSED_ARG (stack);
03333 #     endif /* 0 */
03334       // The call below to ::taskSpawn () causes VxWorks to assign a
03335       // unique task name of the form: "t" + an integer, because the
03336       // first argument is 0.
03337       tid = ::taskSpawn (thr_id_provided  ?  *thr_id  :  0,
03338                          priority,
03339                          (int) flags,
03340                          (int) stacksize,
03341                          thread_args->entry_point (),
03342                          (int) thread_args,
03343                          0, 0, 0, 0, 0, 0, 0, 0, 0);
03344 #     if 0 /* Don't support setting of stack, because it doesn't seem to work. */
03345     }
03346   else
03347     {
03348       // If a task name (thr_id) was not supplied, then the task will
03349       // not have a unique name.  That's VxWorks' behavior.
03350 
03351       // Carve out a TCB at the beginning of the stack space.  The TCB
03352       // occupies 400 bytes with VxWorks 5.3.1/I386.
03353       WIND_TCB *tcb = (WIND_TCB *) stack;
03354 
03355       // The TID is defined to be the address of the TCB.
03356       int status = ::taskInit (tcb,
03357                                thr_id_provided  ?  *thr_id  :  0,
03358                                priority,
03359                                (int) flags,
03360                                (char *) stack + sizeof (WIND_TCB),
03361                                (int) (stacksize - sizeof (WIND_TCB)),
03362                                thread_args->entry_point (),
03363                                (int) thread_args,
03364                                0, 0, 0, 0, 0, 0, 0, 0, 0);
03365 
03366       if (status == OK)
03367         {
03368           // The task was successfully initialized, now activate it.
03369           status = ::taskActivate ((ACE_hthread_t) tcb);
03370         }
03371 
03372       tid = status == OK  ?  (ACE_hthread_t) tcb  :  ERROR;
03373     }
03374 #     endif /* 0 */
03375 
03376   if (tid == ERROR)
03377     return -1;
03378   else
03379     {
03380       if (! thr_id_provided  &&  thr_id)
03381         {
03382           if (*thr_id  &&  (*thr_id)[0] == ACE_THR_ID_ALLOCATED)
03383             // *thr_id was allocated by the Thread_Manager.  ::taskTcb
03384             // (int tid) returns the address of the WIND_TCB (task
03385             // control block).  According to the ::taskSpawn()
03386             // documentation, the name of the new task is stored at
03387             // pStackBase, but is that of the current task?  If so, it
03388             // might be a bit quicker than this extraction of the tcb
03389             // . . .
03390             ACE_OS::strsncpy (*thr_id + 1, ::taskTcb (tid)->name, 10);
03391           else
03392             // *thr_id was not allocated by the Thread_Manager.
03393             // Pass back the task name in the location pointed to
03394             // by thr_id.
03395             *thr_id = ::taskTcb (tid)->name;
03396         }
03397       // else if the thr_id was provided, there's no need to overwrite
03398       // it with the same value (string).  If thr_id is 0, then we can't
03399       // pass the task name back.
03400 
03401       if (thr_handle)
03402         *thr_handle = tid;
03403 
03404       return 0;
03405     }
03406 
03407 #   endif /* ACE_HAS_STHREADS */
03408 # else
03409   ACE_UNUSED_ARG (func);
03410   ACE_UNUSED_ARG (args);
03411   ACE_UNUSED_ARG (flags);
03412   ACE_UNUSED_ARG (thr_id);
03413   ACE_UNUSED_ARG (thr_handle);
03414   ACE_UNUSED_ARG (priority);
03415   ACE_UNUSED_ARG (stack);
03416   ACE_UNUSED_ARG (stacksize);
03417   ACE_NOTSUP_RETURN (-1);
03418 # endif /* ACE_HAS_THREADS */
03419 }

ACE_INLINE int ACE_OS::thr_equal ACE_thread_t    t1,
ACE_thread_t    t2
[static]
 

Definition at line 2343 of file OS.i.

References ACE_thread_t, and ACE_OS_String::strcmp.

Referenced by ACE_Thread_Manager::check_state, ACE_Thread_Manager::find_thread, ACE_Select_Reactor_T::handle_events, ACE_Thread_Manager::join, ACE_Thread_Descriptor_Base::operator==, ACE_Thread_ID::operator==, recursive_mutex_cond_unlock, recursive_mutex_lock, recursive_mutex_trylock, recursive_mutex_unlock, ACE_Token::renew, ACE_Token::shared_acquire, ACE_Thread_Manager::thread_within, ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager, and ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager.

02344 {
02345 #if defined (ACE_HAS_PTHREADS)
02346 # if defined (pthread_equal)
02347   // If it's a macro we can't say "::pthread_equal"...
02348   return pthread_equal (t1, t2);
02349 # else
02350   return ::pthread_equal (t1, t2);
02351 # endif /* pthread_equal */
02352 #elif defined (VXWORKS)
02353   return ! ACE_OS::strcmp (t1, t2);
02354 #else /* For both STHREADS and WTHREADS... */
02355   // Hum, Do we need to treat WTHREAD differently?
02356   // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD.
02357   return t1 == t2;
02358 #endif /* ACE_HAS_PTHREADS */
02359 }

void ACE_OS::thr_exit ACE_THR_FUNC_RETURN    status = 0 [static]
 

Definition at line 3422 of file OS.cpp.

References ACE_BIT_ENABLED, ACE_hthread_t, ACE_OS_TRACE, cleanup_tss, ACE_OS_Thread_Descriptor::flags, ACE_Base_Thread_Adapter::thr_desc_log_msg, and thr_self.

Referenced by ACE_Thread_Control::exit, and ACE_Thread::exit.

03423 {
03424   ACE_OS_TRACE ("ACE_OS::thr_exit");
03425 #if defined (ACE_HAS_THREADS)
03426 #   if defined (ACE_HAS_PTHREADS)
03427     ::pthread_exit (status);
03428 #   elif defined (ACE_HAS_STHREADS)
03429     ::thr_exit (status);
03430 #   elif defined (ACE_HAS_WTHREADS)
03431     // Can't call it here because on NT, the thread is exited
03432     // directly by ACE_Thread_Adapter::invoke ().
03433     //   ACE_TSS_Cleanup::instance ()->exit (status);
03434 
03435 #     if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
03436     int using_afx = -1;
03437     // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor.
03438     // But without #including ace/Thread_Manager.h, we don't know that.
03439     ACE_OS_Thread_Descriptor *td =
03440       ACE_Base_Thread_Adapter::thr_desc_log_msg ();
03441     if (td)
03442       using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX);
03443 #     endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
03444 
03445     // Call TSS destructors.
03446     ACE_OS::cleanup_tss (0 /* not main thread */);
03447 
03448     // Exit the thread.
03449     // Allow CWinThread-destructor to be invoked from AfxEndThread.
03450     // _endthreadex will be called from AfxEndThread so don't exit the
03451     // thread now if we are running an MFC thread.
03452 #     if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
03453     if (using_afx != -1)
03454       {
03455         if (using_afx)
03456           ::AfxEndThread (status);
03457         else
03458           ACE_ENDTHREADEX (status);
03459       }
03460     else
03461       {
03462         // Not spawned by ACE_Thread_Manager, use the old buggy
03463         // version.  You should seriously consider using
03464         // ACE_Thread_Manager to spawn threads.  The following code is
03465         // know to cause some problem.
03466         CWinThread *pThread = ::AfxGetThread ();
03467         if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
03468           ACE_ENDTHREADEX (status);
03469         else
03470           ::AfxEndThread (status);
03471       }
03472 #     else
03473     ACE_ENDTHREADEX (status);
03474 #     endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
03475 
03476 #   elif defined (VXWORKS)
03477     ACE_hthread_t tid;
03478     ACE_OS::thr_self (tid);
03479     *((int *) status) = ::taskDelete (tid);
03480 #   elif defined (ACE_PSOS)
03481     ACE_hthread_t tid;
03482     ACE_OS::thr_self (tid);
03483 
03484 #     if defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)
03485     // Call TSS destructors.
03486     ACE_OS::cleanup_tss (0 /* not main thread */);
03487 #     endif /* ACE_PSOS && ACE_PSOS_HAS_TSS */
03488 
03489     *((u_long *) status) = ::t_delete (tid);
03490 #   endif /* ACE_HAS_PTHREADS */
03491 # else
03492   ACE_UNUSED_ARG (status);
03493 # endif /* ACE_HAS_THREADS */
03494 }

ACE_INLINE int ACE_OS::thr_getconcurrency void    [static]
 

Definition at line 6467 of file OS.i.

References ACE_OS_TRACE.

Referenced by ACE_Thread::getconcurrency, and thr_create.

06468 {
06469   ACE_OS_TRACE ("ACE_OS::thr_getconcurrency");
06470 #if defined (ACE_HAS_THREADS)
06471 # if defined (ACE_HAS_STHREADS)
06472   return ::thr_getconcurrency ();
06473 # elif defined (ACE_HAS_PTHREADS) || defined (VXWORKS) || defined (ACE_PSOS)
06474   ACE_NOTSUP_RETURN (-1);
06475 # elif defined (ACE_HAS_WTHREADS)
06476   ACE_NOTSUP_RETURN (-1);
06477 # endif /* ACE_HAS_STHREADS */
06478 #else
06479   ACE_NOTSUP_RETURN (-1);
06480 #endif /* ACE_HAS_THREADS */
06481 }

ACE_INLINE int ACE_OS::thr_getprio ACE_hthread_t    id,
int &    priority,
int &    policy
[static]
 

Definition at line 6484 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, and thr_getprio.

06485 {
06486   ACE_OS_TRACE ("ACE_OS::thr_getprio");
06487   ACE_UNUSED_ARG (policy);
06488 #if defined (ACE_HAS_THREADS)
06489 # if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED))
06490 
06491 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
06492   int result;
06493   result = ::pthread_getprio (id);
06494   if (result != -1)
06495     {
06496       priority = result;
06497       return 0;
06498     }
06499   else
06500     return -1;
06501 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
06502 
06503   pthread_attr_t  attr;
06504   if (pthread_getschedattr (id, &attr) == 0)
06505     {
06506       priority = pthread_attr_getprio(&attr);
06507       return 0;
06508     }
06509   return -1;
06510 #   else
06511 
06512   struct sched_param param;
06513   int result;
06514 
06515   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, &param),
06516                                 result), int,
06517               -1, result);
06518   priority = param.sched_priority;
06519   return result;
06520 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
06521 # elif defined (ACE_HAS_STHREADS)
06522   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (id, &priority), ace_result_), int, -1);
06523 # elif defined (ACE_HAS_WTHREADS)
06524   priority = ::GetThreadPriority (id);
06525   if (priority == THREAD_PRIORITY_ERROR_RETURN)
06526     ACE_FAIL_RETURN (-1);
06527   else
06528     return 0;
06529 # elif defined (ACE_PSOS)
06530   // passing a 0 in the second argument does not alter task priority, third arg gets existing one
06531   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, 0, (u_long *) &priority), ace_result_), int, -1);
06532 # elif defined (VXWORKS)
06533   ACE_OSCALL_RETURN (::taskPriorityGet (id, &priority), int, -1);
06534 # else
06535   ACE_UNUSED_ARG (id);
06536   ACE_UNUSED_ARG (priority);
06537   ACE_NOTSUP_RETURN (-1);
06538 # endif /* ACE_HAS_STHREADS */
06539 #else
06540   ACE_UNUSED_ARG (id);
06541   ACE_UNUSED_ARG (priority);
06542   ACE_NOTSUP_RETURN (-1);
06543 #endif /* ACE_HAS_THREADS */
06544 }

ACE_INLINE int ACE_OS::thr_getprio ACE_hthread_t    id,
int &    priority
[static]
 

Definition at line 6547 of file OS.i.

References ACE_hthread_t, and ACE_OS_TRACE.

Referenced by ACE_Thread::getprio, ACE_OS_Thread_Adapter::invoke, ACE_Thread_Adapter::invoke_i, and thr_getprio.

06548 {
06549   ACE_OS_TRACE ("ACE_OS::thr_getprio");
06550   int policy = 0;
06551   return ACE_OS::thr_getprio (id, priority, policy);
06552 }

ACE_INLINE int ACE_OS::thr_getspecific ACE_thread_key_t    key,
void **    data
[static]
 

Definition at line 6688 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_KEY_INDEX, ACE_thread_key_t, thr_getspecific, and thr_self.

Referenced by ACE_TSS_Cleanup::exit, ACE_Thread::getspecific, thr_getspecific, and ACE_TSS_Cleanup::tss_keys.

06689 {
06690   // ACE_OS_TRACE ("ACE_OS::thr_getspecific");
06691 #if defined (ACE_HAS_THREADS)
06692 # if defined (ACE_HAS_TSS_EMULATION)
06693     ACE_KEY_INDEX (key_index, key);
06694     if (key_index >= ACE_TSS_Emulation::total_keys ())
06695       {
06696         errno = EINVAL;
06697         data = 0;
06698         return -1;
06699       }
06700     else
06701       {
06702         *data = ACE_TSS_Emulation::ts_object (key);
06703         return 0;
06704       }
06705 # elif defined (ACE_HAS_STHREADS)
06706     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getspecific (key, data), ace_result_), int, -1);
06707 # elif defined (ACE_HAS_PTHREADS)
06708 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
06709       return ::pthread_getspecific (key, data);
06710 #   else /* this is Draft 7 or STD */
06711       *data = pthread_getspecific (key);
06712       return 0;
06713 #   endif       /*  ACE_HAS_PTHREADS_DRAFT4, 6 */
06714 # elif defined (ACE_HAS_WTHREADS)
06715 
06716   // The following handling of errno is designed like this due to
06717   // ACE_Log_Msg::instance calling ACE_OS::thr_getspecific.
06718   // Basically, it is ok for a system call to reset the error to zero.
06719   // (It really shouldn't, though).  However, we have to remember to
06720   // store errno *immediately* after an error is detected.  Calling
06721   // ACE_ERROR_RETURN((..., errno)) did not work because errno was
06722   // cleared before being passed to the thread-specific instance of
06723   // ACE_Log_Msg.  The workaround for was to make it so
06724   // thr_getspecific did not have the side effect of clearing errno.
06725   // The correct fix is for ACE_ERROR_RETURN to store errno
06726   //(actually ACE_OS::last_error) before getting the ACE_Log_Msg tss
06727   // pointer, which is how it is implemented now.  However, other uses
06728   // of ACE_Log_Msg may not work correctly, so we're keeping this as
06729   // it is for now.
06730 
06731   ACE_Errno_Guard error (errno);
06732   *data = ::TlsGetValue (key);
06733 #   if !defined (ACE_HAS_WINCE)
06734   if (*data == 0 && (error = ::GetLastError ()) != NO_ERROR)
06735 
06736     return -1;
06737   else
06738 #   endif /* ACE_HAS_WINCE */
06739     return 0;
06740 # elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)
06741   ACE_hthread_t tid;
06742   ACE_OS::thr_self (tid);
06743   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::tsd_getval (key, tid, data),
06744                                        ace_result_),
06745                      int, -1);
06746 # else
06747   ACE_UNUSED_ARG (key);
06748   ACE_UNUSED_ARG (data);
06749   ACE_NOTSUP_RETURN (-1);
06750 # endif /* ACE_HAS_STHREADS */
06751 #else
06752   ACE_UNUSED_ARG (key);
06753   ACE_UNUSED_ARG (data);
06754   ACE_NOTSUP_RETURN (-1);
06755 #endif /* ACE_HAS_THREADS */
06756 }

ACE_INLINE int ACE_OS::thr_join ACE_thread_t    waiter_id,
ACE_thread_t   thr_id,
ACE_THR_FUNC_RETURN *    status
[static]
 

Definition at line 6832 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_thread_t, and thr_join.

06835 {
06836   ACE_OS_TRACE ("ACE_OS::thr_join");
06837 #if defined (ACE_HAS_THREADS)
06838 # if defined (ACE_HAS_STHREADS)
06839   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), ace_result_),
06840                      int, -1);
06841 # elif defined (ACE_HAS_PTHREADS)
06842   ACE_UNUSED_ARG (thr_id);
06843 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
06844 #     if defined (ACE_LACKS_NULL_PTHREAD_STATUS)
06845   void *temp;
06846   ACE_OSCALL_RETURN (::pthread_join (waiter_id,
06847     status == 0  ?  &temp  :  status), int, -1);
06848 #     else
06849   ACE_OSCALL_RETURN (::pthread_join (waiter_id, status), int, -1);
06850 #     endif
06851 #   else
06852   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_join (waiter_id, status), ace_result_),
06853                      int, -1);
06854 #   endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
06855 # elif defined (ACE_HAS_WTHREADS)
06856   ACE_UNUSED_ARG (waiter_id);
06857   ACE_UNUSED_ARG (thr_id);
06858   ACE_UNUSED_ARG (status);
06859 
06860   // This could be implemented if the DLL-Main function or the
06861   // task exit base class some log the threads which have exited
06862   ACE_NOTSUP_RETURN (-1);
06863 # elif defined (ACE_PSOS)
06864   ACE_UNUSED_ARG (waiter_id);
06865   ACE_UNUSED_ARG (thr_id);
06866   ACE_UNUSED_ARG (status);
06867   ACE_NOTSUP_RETURN (-1);
06868 # endif /* ACE_HAS_STHREADS */
06869 #else
06870   ACE_UNUSED_ARG (waiter_id);
06871   ACE_UNUSED_ARG (thr_id);
06872   ACE_UNUSED_ARG (status);
06873   ACE_NOTSUP_RETURN (-1);
06874 #endif /* ACE_HAS_THREADS */
06875 }

ACE_INLINE int ACE_OS::thr_join ACE_hthread_t    waiter_id,
ACE_THR_FUNC_RETURN *    status
[static]
 

Definition at line 6760 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, ACE_thread_t, and thr_join.

Referenced by ACE_Thread::join, and thr_join.

06762 {
06763   ACE_OS_TRACE ("ACE_OS::thr_join");
06764 #if defined (ACE_HAS_THREADS)
06765 # if defined (ACE_HAS_STHREADS)
06766   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), ace_result_),
06767                      int, -1);
06768 # elif defined (ACE_HAS_PTHREADS)
06769 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
06770   int ace_result;
06771 #     if defined (ACE_LACKS_NULL_PTHREAD_STATUS)
06772   void *temp;
06773   ACE_OSCALL (::pthread_join (thr_handle,
06774                               status == 0  ?  &temp  :  status),
06775               int, -1, ace_result);
06776 #     else
06777   ACE_OSCALL (::pthread_join (thr_handle, status), int, -1, ace_result);
06778 #     endif /* ACE_LACKS_NULL_PTHREAD_STATUS */
06779   // Joinable threads need to be detached after joining on Pthreads
06780   // draft 4 (at least) to reclaim thread storage.
06781 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
06782 #       if defined (HPUX_10)
06783   // HP-UX DCE threads' pthread_detach will smash thr_id if it's just given
06784   // as an argument.  Since the id is still needed, give pthread_detach
06785   // a junker to scribble on.
06786   ACE_thread_t  junker;
06787   cma_handle_assign(&thr_handle, &junker);
06788   ::pthread_detach (&junker);
06789 #       else
06790   ::pthread_detach (&thr_handle);
06791 #       endif  /* HPUX_10 */
06792 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
06793 
06794     return ace_result;
06795 
06796 #   else
06797   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_join (thr_handle, status), ace_result_),
06798                      int, -1);
06799 #   endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
06800 # elif defined (ACE_HAS_WTHREADS)
06801   ACE_THR_FUNC_RETURN local_status = 0;
06802 
06803   // Make sure that status is non-NULL.
06804   if (status == 0)
06805     status = &local_status;
06806 
06807   if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0
06808       && ::GetExitCodeThread (thr_handle, status) != FALSE)
06809     {
06810       ::CloseHandle (thr_handle);
06811       return 0;
06812     }
06813   ACE_FAIL_RETURN (-1);
06814   /* NOTREACHED */
06815 # elif defined (ACE_PSOS)
06816   ACE_UNUSED_ARG (thr_handle);
06817   ACE_UNUSED_ARG (status);
06818   ACE_NOTSUP_RETURN (-1);
06819 # else
06820   ACE_UNUSED_ARG (thr_handle);
06821   ACE_UNUSED_ARG (status);
06822   ACE_NOTSUP_RETURN (-1);
06823 # endif /* ACE_HAS_STHREADS */
06824 #else
06825   ACE_UNUSED_ARG (thr_handle);
06826   ACE_UNUSED_ARG (status);
06827   ACE_NOTSUP_RETURN (-1);
06828 #endif /* ACE_HAS_THREADS */
06829 }

int ACE_OS::thr_key_detach void *    inst [static]
 

Definition at line 3862 of file OS.cpp.

References ACE_TSS_Cleanup::detach, ACE_TSS_Cleanup::instance, and ACE_TSS_Cleanup::lockable.

Referenced by ACE_TSS::~ACE_TSS.

03863 {
03864 # if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS))
03865   if (ACE_TSS_Cleanup::lockable ())
03866     return ACE_TSS_Cleanup::instance()->detach (inst);
03867   else
03868     // We're in static constructor/destructor phase.  Don't
03869     // try to use the ACE_TSS_Cleanup instance because its lock
03870     // might not have been constructed yet, or might have been
03871     // destroyed already.  Just leak the key . . .
03872     return -1;
03873 # else
03874   ACE_UNUSED_ARG (inst);
03875   ACE_NOTSUP_RETURN (-1);
03876 # endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
03877 }

int ACE_OS::thr_key_used ACE_thread_key_t    key [static]
 

Definition at line 3850 of file OS.cpp.

References ACE_thread_key_t, ACE_TSS_Cleanup::instance, and ACE_TSS_Cleanup::key_used.

03851 {
03852 # if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS))
03853   ACE_TSS_Cleanup::instance ()->key_used (key);
03854   return 0;
03855 # else
03856   ACE_UNUSED_ARG (key);
03857   ACE_NOTSUP_RETURN (-1);
03858 # endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION || ACE_PSOS_HAS_TSS */
03859 }

int ACE_OS::thr_keycreate ACE_thread_key_t   key,
ACE_THR_DEST   ,
void *    inst = 0
[static]
 

Definition at line 3761 of file OS.cpp.

References ACE_ADAPT_RETVAL, ACE_SYSCALL_FAILED, ACE_thread_key_t, ACE_TSS_Cleanup::insert, ACE_TSS_Cleanup::instance, thr_keycreate, and unique_name.

Referenced by ACE_Thread::keycreate, thr_keycreate, and ACE_TSS_Cleanup::tss_keys.

03768 {
03769   // ACE_OS_TRACE ("ACE_OS::thr_keycreate");
03770 #if defined (ACE_HAS_THREADS)
03771 #   if defined (ACE_HAS_TSS_EMULATION)
03772     if (ACE_TSS_Emulation::next_key (*key) == 0)
03773       {
03774         ACE_TSS_Emulation::tss_destructor (*key, dest);
03775 
03776         // Extract out the thread-specific table instance and stash away
03777         // the key and destructor so that we can free it up later on...
03778         return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst);
03779       }
03780     else
03781       {
03782         errno = EAGAIN;
03783         return -1;
03784       }
03785 #   elif defined (ACE_HAS_PTHREADS)
03786     ACE_UNUSED_ARG (inst);
03787 
03788 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
03789 #       if defined (ACE_HAS_STDARG_THR_DEST)
03790     ACE_OSCALL_RETURN (::pthread_keycreate (key, (void (*)(...)) dest), int, -1);
03791 #       else  /* ! ACE_HAS_STDARG_THR_DEST */
03792     ACE_OSCALL_RETURN (::pthread_keycreate (key, dest), int, -1);
03793 #       endif /* ! ACE_HAS_STDARG_THR_DEST */
03794 #     elif defined (ACE_HAS_PTHREADS_DRAFT6)
03795     ACE_OSCALL_RETURN (::pthread_key_create (key, dest), int, -1);
03796 #     else
03797     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_key_create (key, dest),
03798                                          ace_result_),
03799                        int, -1);
03800 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
03801 
03802 #   elif defined (ACE_HAS_STHREADS)
03803     ACE_UNUSED_ARG (inst);
03804     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_keycreate (key, dest),
03805                                          ace_result_),
03806                        int, -1);
03807 #     elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)
03808 
03809     static u_long unique_name = 0;
03810     void *tsdanchor;
03811 
03812     ++unique_name;
03813     if (::tsd_create (ACE_reinterpret_cast (char *, &unique_name),
03814                       0,
03815                       TSD_NOALLOC,
03816                       (void ****) &tsdanchor,
03817                       key) != 0)
03818       {
03819         return -1;
03820       }
03821 
03822     return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst);
03823 #   elif defined (ACE_HAS_WTHREADS)
03824     *key = ::TlsAlloc ();
03825 
03826     if (*key != ACE_SYSCALL_FAILED)
03827       {
03828         // Extract out the thread-specific table instance and stash away
03829         // the key and destructor so that we can free it up later on...
03830         return ACE_TSS_Cleanup::instance ()->insert (*key, dest, inst);
03831       }
03832     else
03833       ACE_FAIL_RETURN (-1);
03834       /* NOTREACHED */
03835 #   else
03836     ACE_UNUSED_ARG (key);
03837     ACE_UNUSED_ARG (dest);
03838     ACE_UNUSED_ARG (inst);
03839     ACE_NOTSUP_RETURN (-1);
03840 #   endif /* ACE_HAS_TSS_EMULATION */
03841 # else
03842   ACE_UNUSED_ARG (key);
03843   ACE_UNUSED_ARG (dest);
03844   ACE_UNUSED_ARG (inst);
03845   ACE_NOTSUP_RETURN (-1);
03846 # endif /* ACE_HAS_THREADS */
03847 }

int ACE_OS::thr_keyfree ACE_thread_key_t    key [static]
 

Definition at line 3666 of file OS.cpp.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_thread_key_t, ACE_TSS_Cleanup::instance, and ACE_TSS_Cleanup::remove.

Referenced by ACE_TSS_Cleanup::exit, ACE_TSS_Cleanup::free_all_keys_left, and ACE_Thread::keyfree.

03667 {
03668   ACE_OS_TRACE ("ACE_OS::thr_keyfree");
03669 # if defined (ACE_HAS_THREADS)
03670 #   if defined (ACE_HAS_TSS_EMULATION)
03671     // Release the key in the TSS_Emulation administration
03672     ACE_TSS_Emulation::release_key (key);
03673     return ACE_TSS_Cleanup::instance ()->remove (key);
03674 #   elif defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
03675     ACE_UNUSED_ARG (key);
03676     ACE_NOTSUP_RETURN (-1);
03677 #   elif defined (ACE_HAS_PTHREADS)
03678     return ::pthread_key_delete (key);
03679 #   elif defined (ACE_HAS_THR_KEYDELETE)
03680     return ::thr_keydelete (key);
03681 #   elif defined (ACE_HAS_STHREADS)
03682     ACE_UNUSED_ARG (key);
03683     ACE_NOTSUP_RETURN (-1);
03684 #   elif defined (ACE_HAS_WTHREADS)
03685     // Extract out the thread-specific table instance and free up
03686     // the key and destructor.
03687     ACE_TSS_Cleanup::instance ()->remove (key);
03688     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::TlsFree (key), ace_result_), int, -1);
03689 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)
03690     // Extract out the thread-specific table instance and free up
03691     // the key and destructor.
03692     ACE_TSS_Cleanup::instance ()->remove (key);
03693     return (::tsd_delete (key) == 0) ? 0 : -1;
03694 #   else
03695     ACE_UNUSED_ARG (key);
03696     ACE_NOTSUP_RETURN (-1);
03697 #   endif /* ACE_HAS_TSS_EMULATION */
03698 # else
03699   ACE_UNUSED_ARG (key);
03700   ACE_NOTSUP_RETURN (-1);
03701 # endif /* ACE_HAS_THREADS */
03702 }

ACE_INLINE int ACE_OS::thr_kill ACE_thread_t    thr_id,
int    signum
[static]
 

Definition at line 7187 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, ACE_thread_t, kill, and thr_kill.

Referenced by ACE_Thread::kill, and thr_kill.

07188 {
07189   ACE_OS_TRACE ("ACE_OS::thr_kill");
07190 #if defined (ACE_HAS_THREADS)
07191 # if defined (ACE_HAS_PTHREADS)
07192 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined(ACE_LACKS_PTHREAD_KILL)
07193   ACE_UNUSED_ARG (signum);
07194   ACE_UNUSED_ARG (thr_id);
07195   ACE_NOTSUP_RETURN (-1);
07196 #   else
07197   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_kill (thr_id, signum),
07198                                        ace_result_),
07199                      int, -1);
07200 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
07201 # elif defined (ACE_HAS_STHREADS)
07202   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum),
07203                                        ace_result_),
07204                      int, -1);
07205 # elif defined (ACE_HAS_WTHREADS) || defined (ACE_PSOS)
07206   ACE_UNUSED_ARG (signum);
07207   ACE_UNUSED_ARG (thr_id);
07208 
07209   ACE_NOTSUP_RETURN (-1);
07210 # elif defined (VXWORKS)
07211   ACE_hthread_t tid;
07212   ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid);
07213 
07214   if (tid == ERROR)
07215     return -1;
07216   else
07217     ACE_OSCALL_RETURN (::kill (tid, signum), int, -1);
07218 
07219 # else /* This should not happen! */
07220   ACE_UNUSED_ARG (thr_id);
07221   ACE_UNUSED_ARG (signum);
07222   ACE_NOTSUP_RETURN (-1);
07223 # endif /* ACE_HAS_STHREADS */
07224 #else
07225   ACE_UNUSED_ARG (thr_id);
07226   ACE_UNUSED_ARG (signum);
07227   ACE_NOTSUP_RETURN (-1);
07228 #endif /* ACE_HAS_THREADS */
07229 }

ACE_INLINE size_t ACE_OS::thr_min_stack void    [static]
 

Definition at line 7232 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, sysconf, thr_min_stack, and thr_self.

Referenced by thr_min_stack.

07233 {
07234   ACE_OS_TRACE ("ACE_OS::thr_min_stack");
07235 #if defined (ACE_HAS_THREADS)
07236 # if defined (ACE_HAS_STHREADS)
07237 #   if defined (ACE_HAS_THR_MINSTACK)
07238   // Tandem did some weirdo mangling of STHREAD names...
07239   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_minstack (),
07240                                        ace_result_),
07241                      int, -1);
07242 #   else
07243   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_min_stack (),
07244                                        ace_result_),
07245                      int, -1);
07246 #   endif /* !ACE_HAS_THR_MINSTACK */
07247 # elif defined (ACE_HAS_PTHREADS)
07248 #   if defined (_SC_THREAD_STACK_MIN)
07249   return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
07250 #   elif defined (PTHREAD_STACK_MIN)
07251   return PTHREAD_STACK_MIN;
07252 #   else
07253   ACE_NOTSUP_RETURN (0);
07254 #   endif /* _SC_THREAD_STACK_MIN */
07255 # elif defined (ACE_HAS_WTHREADS)
07256   ACE_NOTSUP_RETURN (0);
07257 # elif defined (ACE_PSOS)
07258   // there does not appear to be a way to get the
07259   // task stack size except at task creation
07260   ACE_NOTSUP_RETURN (0);
07261 # elif defined (VXWORKS)
07262   TASK_DESC taskDesc;
07263   STATUS status;
07264 
07265   ACE_hthread_t tid;
07266   ACE_OS::thr_self (tid);
07267 
07268   ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc),
07269                                 status),
07270               STATUS, -1, status);
07271   return status == OK ? taskDesc.td_stackSize : 0;
07272 # else /* Should not happen... */
07273   ACE_NOTSUP_RETURN (0);
07274 # endif /* ACE_HAS_STHREADS */
07275 #else
07276   ACE_NOTSUP_RETURN (0);
07277 #endif /* ACE_HAS_THREADS */
07278 }

ACE_INLINE void ACE_OS::thr_self ACE_hthread_t   [static]
 

Definition at line 2362 of file OS.i.

References ACE_hthread_t, and ACE_OS_TRACE.

02363 {
02364   ACE_OS_TRACE ("ACE_OS::thr_self");
02365 #if defined (ACE_HAS_THREADS)
02366 # if defined (ACE_HAS_PTHREADS)
02367   // Note, don't use "::" here since the following call is often a macro.
02368   self = pthread_self ();
02369 # elif defined (ACE_HAS_THREAD_SELF)
02370   self = ::thread_self ();
02371 # elif defined (ACE_HAS_STHREADS)
02372   self = ::thr_self ();
02373 # elif defined (ACE_HAS_WTHREADS)
02374   self = ::GetCurrentThread ();
02375 # elif defined (ACE_PSOS)
02376   t_ident ((char *) 0, 0, &self);
02377 # elif defined (VXWORKS)
02378   self = ::taskIdSelf ();
02379 # endif /* ACE_HAS_STHREADS */
02380 #else
02381   self = 1; // Might as well make it the main thread ;-)
02382 #endif /* ACE_HAS_THREADS */
02383 }

ACE_INLINE ACE_thread_t ACE_OS::thr_self void    [static]
 

Definition at line 2386 of file OS.i.

References thr_self.

Referenced by ACE_Thread_Control::ACE_Thread_Control, ACE_Thread_Manager::check_state, ACE_Thread_Manager::exit, ACE_Thread_Control::insert, ACE_OS_Thread_Adapter::invoke, ACE_Thread_Adapter::invoke_i, recursive_mutex_cond_unlock, recursive_mutex_lock, recursive_mutex_trylock, recursive_mutex_unlock, sched_params, ACE_Thread::self, thr_create, thr_exit, thr_getspecific, thr_min_stack, thr_self, thr_setprio, thr_setspecific, ACE_Thread_Manager::thread_desc_self, ACE_Timeprobe::timeprobe, ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager, and ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager.

02387 {
02388   // ACE_OS_TRACE ("ACE_OS::thr_self");
02389 #if defined (ACE_HAS_THREADS)
02390 # if defined (ACE_HAS_PTHREADS)
02391   // Note, don't use "::" here since the following call is often a macro.
02392   ACE_OSCALL_RETURN (pthread_self (), int, -1);
02393 # elif defined (ACE_HAS_STHREADS)
02394   ACE_OSCALL_RETURN (::thr_self (), int, -1);
02395 # elif defined (ACE_HAS_WTHREADS)
02396   return ::GetCurrentThreadId ();
02397 # elif defined (ACE_PSOS)
02398   // there does not appear to be a way to get
02399   // a task's name other than at creation
02400   return 0;
02401 # elif defined (VXWORKS)
02402   return ::taskName (::taskIdSelf ());
02403 # endif /* ACE_HAS_STHREADS */
02404 #else
02405   return 1; // Might as well make it the first thread ;-)
02406 #endif /* ACE_HAS_THREADS */
02407 }

ACE_INLINE int ACE_OS::thr_setcancelstate int    new_state,
int *    old_state
[static]
 

Definition at line 6879 of file OS.i.

References ACE_ADAPT_RETVAL, and ACE_OS_TRACE.

Referenced by ACE_Thread::disablecancel, ACE_Thread::enablecancel, and ACE_Thread::setcancelstate.

06880 {
06881   ACE_OS_TRACE ("ACE_OS::thr_setcancelstate");
06882 #if defined (ACE_HAS_THREADS)
06883 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
06884 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
06885   int old;
06886   old = pthread_setcancel (new_state);
06887   if (old == -1)
06888     return -1;
06889   *old_state = old;
06890   return 0;
06891 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
06892   ACE_UNUSED_ARG(old_state);
06893   ACE_OSCALL_RETURN (pthread_setintr (new_state), int, -1);
06894 #   else /* this is draft 7 or std */
06895   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setcancelstate (new_state,
06896                                                                  old_state),
06897                                        ace_result_),
06898                      int, -1);
06899 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
06900 # elif defined (ACE_HAS_STHREADS)
06901   ACE_UNUSED_ARG (new_state);
06902   ACE_UNUSED_ARG (old_state);
06903   ACE_NOTSUP_RETURN (-1);
06904 # elif defined (ACE_HAS_WTHREADS)
06905   ACE_UNUSED_ARG (new_state);
06906   ACE_UNUSED_ARG (old_state);
06907   ACE_NOTSUP_RETURN (-1);
06908 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
06909   ACE_UNUSED_ARG (new_state);
06910   ACE_UNUSED_ARG (old_state);
06911   ACE_NOTSUP_RETURN (-1);
06912 # endif /* ACE_HAS_PTHREADS */
06913 #else
06914   ACE_UNUSED_ARG (new_state);
06915   ACE_UNUSED_ARG (old_state);
06916   ACE_NOTSUP_RETURN (-1);
06917 #endif /* ACE_HAS_THREADS */
06918 }

ACE_INLINE int ACE_OS::thr_setcanceltype int    new_type,
int *    old_type
[static]
 

Definition at line 6921 of file OS.i.

References ACE_ADAPT_RETVAL, and ACE_OS_TRACE.

Referenced by ACE_Thread::enablecancel, and ACE_Thread::setcancelstate.

06922 {
06923   ACE_OS_TRACE ("ACE_OS::thr_setcanceltype");
06924 #if defined (ACE_HAS_THREADS)
06925 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
06926 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
06927   int old;
06928   old = pthread_setasynccancel(new_type);
06929   if (old == -1)
06930     return -1;
06931   *old_type = old;
06932   return 0;
06933 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
06934   ACE_UNUSED_ARG(old_type);
06935   ACE_OSCALL_RETURN (pthread_setintrtype (new_type), int, -1);
06936 #   else /* this is draft 7 or std */
06937   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setcanceltype (new_type,
06938                                                                 old_type),
06939                                        ace_result_),
06940                      int, -1);
06941 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
06942 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
06943   ACE_UNUSED_ARG (new_type);
06944   ACE_UNUSED_ARG (old_type);
06945   ACE_NOTSUP_RETURN (-1);
06946 # endif /* ACE_HAS_PTHREADS */
06947 #else
06948   ACE_UNUSED_ARG (new_type);
06949   ACE_UNUSED_ARG (old_type);
06950   ACE_NOTSUP_RETURN (-1);
06951 #endif /* ACE_HAS_THREADS */
06952 }

ACE_INLINE int ACE_OS::thr_setconcurrency int    hint [static]
 

Definition at line 7281 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and thr_setconcurrency.

Referenced by ACE_Thread::setconcurrency, thr_create, and thr_setconcurrency.

07282 {
07283   ACE_OS_TRACE ("ACE_OS::thr_setconcurrency");
07284 #if defined (ACE_HAS_THREADS)
07285 # if defined (ACE_HAS_STHREADS)
07286   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint),
07287                                        ace_result_),
07288                      int, -1);
07289 # elif defined (ACE_HAS_PTHREADS)
07290   ACE_UNUSED_ARG (hint);
07291   ACE_NOTSUP_RETURN (-1);
07292 # elif defined (ACE_HAS_WTHREADS)
07293   ACE_UNUSED_ARG (hint);
07294 
07295   ACE_NOTSUP_RETURN (-1);
07296 # elif defined (VXWORKS) || defined (ACE_PSOS)
07297   ACE_UNUSED_ARG (hint);
07298   ACE_NOTSUP_RETURN (-1);
07299 # endif /* ACE_HAS_STHREADS */
07300 #else
07301   ACE_UNUSED_ARG (hint);
07302   ACE_NOTSUP_RETURN (-1);
07303 #endif /* ACE_HAS_THREADS */
07304 }

int ACE_OS::thr_setprio const ACE_Sched_Priority    prio [static]
 

Definition at line 1394 of file OS.cpp.

References ACE_hthread_t, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_Sched_Priority, ACE_SCHED_RR, lwp_getparams, lwp_setparams, ACE_Sched_Params::policy, ACE_Sched_Params::priority, sched_params, thr_self, and thr_setprio.

01395 {
01396   // Set the thread priority on the current thread.
01397   ACE_hthread_t my_thread_id;
01398   ACE_OS::thr_self (my_thread_id);
01399 
01400   int status = ACE_OS::thr_setprio (my_thread_id, prio);
01401 
01402 # if defined (ACE_NEEDS_LWP_PRIO_SET)
01403   // If the thread is in the RT class, then set the priority on its
01404   // LWP.  (Instead of doing this if the thread is in the RT class, it
01405   // should be done for all bound threads.  But, there doesn't appear
01406   // to be an easy way to determine if the thread is bound.)
01407 
01408   if (status == 0)
01409     {
01410       // Find what scheduling class the thread's LWP is in.
01411       ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0);
01412       if (ACE_OS::lwp_getparams (sched_params) == -1)
01413         {
01414           return -1;
01415         }
01416       else if (sched_params.policy () == ACE_SCHED_FIFO  ||
01417                sched_params.policy () == ACE_SCHED_RR)
01418         {
01419           // This thread's LWP is in the RT class, so we need to set
01420           // its priority.
01421           sched_params.priority (prio);
01422           return ACE_OS::lwp_setparams (sched_params);
01423         }
01424       // else this is not an RT thread.  Nothing more needs to be
01425       // done.
01426     }
01427 # endif /* ACE_NEEDS_LWP_PRIO_SET */
01428 
01429   return status;
01430 }

ACE_INLINE int ACE_OS::thr_setprio ACE_hthread_t    id,
int    priority,
int    policy = -1
[static]
 

Definition at line 7307 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, ACE_OS_String::memset, and thr_setprio.

Referenced by ACE_OS_Thread_Adapter::invoke, ACE_Thread_Adapter::invoke_i, sched_params, ACE_Thread::setprio, thr_create, and thr_setprio.

07308 {
07309   ACE_OS_TRACE ("ACE_OS::thr_setprio");
07310   ACE_UNUSED_ARG (policy);
07311 #if defined (ACE_HAS_THREADS)
07312 # if (defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_SETSCHED))
07313 
07314 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
07315   int result;
07316   result = ::pthread_setprio (id, priority);
07317   return (result == -1 ? -1 : 0);
07318 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
07319   pthread_attr_t  attr;
07320   if (pthread_getschedattr (id, &attr) == -1)
07321     return -1;
07322   if (pthread_attr_setprio (attr, priority) == -1)
07323     return -1;
07324   return pthread_setschedattr (id, attr);
07325 #   else
07326   int result;
07327   struct sched_param param;
07328   memset ((void *) &param, 0, sizeof param);
07329 
07330   // If <policy> is -1, we don't want to use it for
07331   // pthread_setschedparam().  Instead, obtain policy from
07332   // pthread_getschedparam().
07333   if (policy == -1)
07334     {
07335       ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (id, &policy, &param),
07336                                     result),
07337                   int, -1, result);
07338       if (result == -1)
07339         return result;
07340     }
07341 
07342   param.sched_priority = priority;
07343 
07344   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (id, policy, &param),
07345                                        ace_result_),
07346                      int, -1);
07347 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
07348 # elif defined (ACE_HAS_STHREADS)
07349   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (id, priority),
07350                                        ace_result_),
07351                      int, -1);
07352 # elif defined (ACE_HAS_WTHREADS)
07353   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (id, priority),
07354                                           ace_result_),
07355                         int, -1);
07356 # elif defined (ACE_PSOS)
07357   u_long oldpriority;
07358   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_setpri (id, priority, &oldpriority),
07359                                        ace_result_),
07360                      int, -1);
07361 # elif defined (VXWORKS)
07362   ACE_OSCALL_RETURN (::taskPrioritySet (id, priority), int, -1);
07363 # else
07364   // For example, platforms that support Pthreads but LACK_SETSCHED.
07365   ACE_UNUSED_ARG (id);
07366   ACE_UNUSED_ARG (priority);
07367   ACE_NOTSUP_RETURN (-1);
07368 # endif /* ACE_HAS_STHREADS */
07369 #else
07370   ACE_UNUSED_ARG (id);
07371   ACE_UNUSED_ARG (priority);
07372   ACE_NOTSUP_RETURN (-1);
07373 #endif /* ACE_HAS_THREADS */
07374 }

int ACE_OS::thr_setspecific ACE_thread_key_t    key,
void *    data
[static]
 

Definition at line 3600 of file OS.cpp.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_KEY_INDEX, ACE_thread_key_t, ACE_TSS_Cleanup::instance, ACE_TSS_Cleanup::key_used, thr_self, and thr_setspecific.

Referenced by ACE_Thread::setspecific, thr_setspecific, and ACE_TSS_Cleanup::tss_keys.

03601 {
03602   // ACE_OS_TRACE ("ACE_OS::thr_setspecific");
03603 #if defined (ACE_HAS_THREADS)
03604 #   if defined (ACE_HAS_TSS_EMULATION)
03605     ACE_KEY_INDEX (key_index, key);
03606 
03607     if (key_index >= ACE_TSS_Emulation::total_keys ())
03608       {
03609         errno = EINVAL;
03610         data = 0;
03611         return -1;
03612       }
03613     else
03614       {
03615         ACE_TSS_Emulation::ts_object (key) = data;
03616         ACE_TSS_Cleanup::instance ()->key_used (key);
03617 
03618         return 0;
03619       }
03620 #   elif defined (ACE_HAS_PTHREADS)
03621 #     if defined (ACE_HAS_FSU_PTHREADS)
03622       // Call pthread_init() here to initialize threads package.  FSU
03623       // threads need an initialization before the first thread constructor.
03624       // This seems to be the one; however, a segmentation fault may
03625       // indicate that another pthread_init() is necessary, perhaps in
03626       // Synch.cpp or Synch_T.cpp.  FSU threads will not reinit if called
03627       // more than once, so another call to pthread_init will not adversely
03628       // affect existing threads.
03629       pthread_init ();
03630 #     endif /*  ACE_HAS_FSU_PTHREADS */
03631 
03632 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
03633     ACE_OSCALL_RETURN (::pthread_setspecific (key, data), int, -1);
03634 #     else
03635     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setspecific (key, data),
03636                                          ace_result_),
03637                        int, -1);
03638 #     endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
03639 
03640 #   elif defined (ACE_HAS_STHREADS)
03641     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setspecific (key, data), ace_result_), int, -1);
03642 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS)
03643     ACE_hthread_t tid;
03644     ACE_OS::thr_self (tid);
03645     if (::tsd_setval (key, tid, data) != 0)
03646      return -1;
03647     ACE_TSS_Cleanup::instance ()->key_used (key);
03648     return 0;
03649 #   elif defined (ACE_HAS_WTHREADS)
03650     ::TlsSetValue (key, data);
03651     ACE_TSS_Cleanup::instance ()->key_used (key);
03652     return 0;
03653 #   else
03654     ACE_UNUSED_ARG (key);
03655     ACE_UNUSED_ARG (data);
03656     ACE_NOTSUP_RETURN (-1);
03657 #   endif /* ACE_HAS_STHREADS */
03658 # else
03659   ACE_UNUSED_ARG (key);
03660   ACE_UNUSED_ARG (data);
03661   ACE_NOTSUP_RETURN (-1);
03662 # endif /* ACE_HAS_THREADS */
03663 }

ACE_INLINE int ACE_OS::thr_sigsetmask int    how,
const sigset_t *    nsm,
sigset_t *    osm
[static]
 

Definition at line 7104 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, pthread_sigmask, SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK, sigprocmask, and thr_sigsetmask.

Referenced by ACE_Sig_Guard::ACE_Sig_Guard, ACE_Thread::sigsetmask, thr_sigsetmask, and ACE_Sig_Guard::~ACE_Sig_Guard.

07107 {
07108   ACE_OS_TRACE ("ACE_OS::thr_sigsetmask");
07109 #if defined (ACE_HAS_THREADS)
07110 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
07111   // DCE threads and Solaris 2.4 have no such function.
07112   ACE_UNUSED_ARG (osm);
07113   ACE_UNUSED_ARG (nsm);
07114   ACE_UNUSED_ARG (how);
07115 
07116   ACE_NOTSUP_RETURN (-1);
07117 # elif defined (ACE_HAS_SIGTHREADMASK)
07118   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm),
07119                                        ace_result_), int, -1);
07120 # elif defined (ACE_HAS_STHREADS)
07121   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm),
07122                                        ace_result_),
07123                      int, -1);
07124 # elif defined (ACE_HAS_PTHREADS)
07125 #   if defined (AIX)
07126   ACE_OSCALL_RETURN (sigthreadmask (how, nsm, osm), int, -1);
07127   // Draft 4 and 6 implementations will sometimes have a sigprocmask () that
07128   // modifies the calling thread's mask only.  If this is not so for your
07129   // platform, define ACE_LACKS_PTHREAD_THR_SIGSETMASK.
07130 #   elif defined(ACE_HAS_PTHREADS_DRAFT4) || \
07131     defined (ACE_HAS_PTHREADS_DRAFT6) || (defined (_UNICOS) && _UNICOS == 9)
07132   ACE_OSCALL_RETURN (::sigprocmask (how, nsm, osm), int, -1);
07133 #   elif !defined (ACE_LACKS_PTHREAD_SIGMASK)
07134   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
07135                                        ace_result_), int, -1);
07136 #   endif /* AIX */
07137 
07138 #if 0
07139   /* Don't know if anyt platform actually needs this... */
07140   // as far as I can tell, this is now pthread_sigaction() -- jwr
07141   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigaction (how, nsm, osm),
07142                                        ace_result_), int, -1);
07143 #endif /* 0 */
07144 
07145 # elif defined (ACE_HAS_WTHREADS) || defined (ACE_PSOS)
07146   ACE_UNUSED_ARG (osm);
07147   ACE_UNUSED_ARG (nsm);
07148   ACE_UNUSED_ARG (how);
07149 
07150   ACE_NOTSUP_RETURN (-1);
07151 # elif defined (VXWORKS)
07152   switch (how)
07153     {
07154     case SIG_BLOCK:
07155     case SIG_UNBLOCK:
07156       {
07157         // get the old mask
07158         *osm = ::sigsetmask (*nsm);
07159         // create a new mask:  the following assumes that sigset_t is 4 bytes,
07160         // which it is on VxWorks 5.2, so bit operations are done simply . . .
07161         ::sigsetmask (how == SIG_BLOCK ? (*osm |= *nsm) : (*osm &= ~*nsm));
07162         break;
07163       }
07164     case SIG_SETMASK:
07165       *osm = ::sigsetmask (*nsm);
07166       break;
07167     default:
07168       return -1;
07169     }
07170 
07171   return 0;
07172 # else /* Should not happen. */
07173   ACE_UNUSED_ARG (how);
07174   ACE_UNUSED_ARG (nsm);
07175   ACE_UNUSED_ARG (osm);
07176   ACE_NOTSUP_RETURN (-1);
07177 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
07178 #else
07179   ACE_UNUSED_ARG (how);
07180   ACE_UNUSED_ARG (nsm);
07181   ACE_UNUSED_ARG (osm);
07182   ACE_NOTSUP_RETURN (-1);
07183 #endif /* ACE_HAS_THREADS */
07184 }

ACE_INLINE int ACE_OS::thr_suspend ACE_hthread_t    target_thread [static]
 

Definition at line 7377 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_suspend.

Referenced by ACE_Thread::suspend, and thr_suspend.

07378 {
07379   ACE_OS_TRACE ("ACE_OS::thr_suspend");
07380 #if defined (ACE_HAS_THREADS)
07381 # if defined (ACE_HAS_STHREADS)
07382   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), ace_result_), int, -1);
07383 # elif defined (ACE_HAS_PTHREADS)
07384 #  if defined (ACE_HAS_PTHREAD_SUSPEND)
07385   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread),
07386                                        ace_result_),
07387                      int, -1);
07388 #  else
07389   ACE_UNUSED_ARG (target_thread);
07390   ACE_NOTSUP_RETURN (-1);
07391 #  endif /* ACE_HAS_PTHREAD_SUSPEND */
07392 # elif defined (ACE_HAS_WTHREADS)
07393   if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED)
07394     return 0;
07395   else
07396     ACE_FAIL_RETURN (-1);
07397   /* NOTREACHED */
07398 # elif defined (ACE_PSOS)
07399   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::t_suspend (target_thread), ace_result_), int, -1);
07400 # elif defined (VXWORKS)
07401   ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1);
07402 # endif /* ACE_HAS_STHREADS */
07403 #else
07404   ACE_UNUSED_ARG (target_thread);
07405   ACE_NOTSUP_RETURN (-1);
07406 #endif /* ACE_HAS_THREADS */
07407 }

ACE_INLINE void ACE_OS::thr_testcancel void    [static]
 

Definition at line 7083 of file OS.i.

References ACE_OS_TRACE.

Referenced by ACE_Thread::testcancel.

07084 {
07085   ACE_OS_TRACE ("ACE_OS::thr_testcancel");
07086 #if defined (ACE_HAS_THREADS)
07087 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
07088 #if defined(ACE_HAS_PTHREADS_DRAFT6)
07089   ::pthread_testintr ();
07090 #else /* ACE_HAS_PTHREADS_DRAFT6 */
07091   ::pthread_testcancel ();
07092 #endif /* !ACE_HAS_PTHREADS_DRAFT6 */
07093 # elif defined (ACE_HAS_STHREADS)
07094 # elif defined (ACE_HAS_WTHREADS)
07095 # elif defined (VXWORKS) || defined (ACE_PSOS)
07096 # else
07097   // no-op:  can't use ACE_NOTSUP_RETURN because there is no return value
07098 # endif /* ACE_HAS_PTHREADS */
07099 #else
07100 #endif /* ACE_HAS_THREADS */
07101 }

ACE_INLINE void ACE_OS::thr_yield void    [static]
 

Definition at line 7410 of file OS.i.

References ACE_OS_TRACE.

Referenced by ACE_Condition::remove, and ACE_Thread::yield.

07411 {
07412   ACE_OS_TRACE ("ACE_OS::thr_yield");
07413 #if defined (ACE_HAS_THREADS)
07414 # if defined (ACE_HAS_PTHREADS)
07415 #   if defined (ACE_HAS_PTHREADS_STD)
07416   // Note - this is a POSIX.4 function - not a POSIX.1c function...
07417   ::sched_yield ();
07418 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
07419   ::pthread_yield (0);
07420 #   else    /* Draft 4 and 7 */
07421   ::pthread_yield ();
07422 #   endif  /* ACE_HAS_PTHREADS_STD */
07423 # elif defined (ACE_HAS_STHREADS)
07424   ::thr_yield ();
07425 # elif defined (ACE_HAS_WTHREADS)
07426   ::Sleep (0);
07427 # elif defined (VXWORKS)
07428   // An argument of 0 to ::taskDelay doesn't appear to yield the
07429   // current thread.
07430   // Now, it does seem to work.  The context_switch_time test
07431   // works fine with task_delay set to 0.
07432   ::taskDelay (0);
07433 # endif /* ACE_HAS_STHREADS */
07434 #else
07435   ;
07436 #endif /* ACE_HAS_THREADS */
07437 }

ACE_INLINE int ACE_OS::thread_mutex_destroy ACE_thread_mutex_t *    m [static]
 

Definition at line 1828 of file OS.i.

References ACE_OS_TRACE, and mutex_destroy.

Referenced by ACE_OS_Object_Manager::fini, mutex_destroy, recursive_mutex_destroy, sema_destroy, and sema_init.

01829 {
01830   ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy");
01831 #if defined (ACE_HAS_THREADS)
01832 # if defined (ACE_HAS_WTHREADS)
01833   ::DeleteCriticalSection (m);
01834   return 0;
01835 
01836 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
01837   return ACE_OS::mutex_destroy (m);
01838 
01839 # elif defined (VXWORKS) || defined (ACE_PSOS)
01840   return mutex_destroy (m);
01841 
01842 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
01843 
01844 #else
01845   ACE_UNUSED_ARG (m);
01846   ACE_NOTSUP_RETURN (-1);
01847 
01848 #endif /* ACE_HAS_THREADS */
01849 }

int ACE_OS::thread_mutex_init ACE_thread_mutex_t *    m,
int    type,
const wchar_t *    name,
ACE_mutexattr_t *    arg = 0
[static]
 

ACE_INLINE int ACE_OS::thread_mutex_init ACE_thread_mutex_t *    m,
int    type = ACE_DEFAULT_SYNCH_TYPE,
const char *    name = 0,
ACE_mutexattr_t *    arg = 0
[static]
 

Definition at line 1756 of file OS.i.

References mutex_init.

Referenced by ACE_Thread_Mutex::ACE_Thread_Mutex, ACE_OS_Object_Manager::init, mutex_init, recursive_mutex_init, and sema_init.

01760 {
01761   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
01762 #if defined (ACE_HAS_THREADS)
01763 # if defined (ACE_HAS_WTHREADS)
01764   ACE_UNUSED_ARG (type);
01765   ACE_UNUSED_ARG (name);
01766   ACE_UNUSED_ARG (arg);
01767   ::InitializeCriticalSection (m);
01768   return 0;
01769 
01770 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
01771   ACE_UNUSED_ARG (type);
01772   // Force the use of USYNC_THREAD!
01773   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg);
01774 
01775 # elif defined (VXWORKS) || defined (ACE_PSOS)
01776   return mutex_init (m, type, name, arg);
01777 
01778 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
01779 
01780 #else
01781   ACE_UNUSED_ARG (m);
01782   ACE_UNUSED_ARG (type);
01783   ACE_UNUSED_ARG (name);
01784   ACE_UNUSED_ARG (arg);
01785   ACE_NOTSUP_RETURN (-1);
01786 
01787 #endif /* ACE_HAS_THREADS */
01788 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *    m,
const ACE_Time_Value   timeout
[static]
 

Definition at line 1898 of file OS.i.

References thread_mutex_lock.

01900 {
01901   return timeout == 0
01902     ? ACE_OS::thread_mutex_lock (m)
01903     : ACE_OS::thread_mutex_lock (m, *timeout);
01904 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *    m,
const ACE_Time_Value   timeout
[static]
 

Definition at line 1871 of file OS.i.

References mutex_lock.

01873 {
01874   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
01875 
01876   // For all platforms, except MS Windows, this method is equivalent
01877   // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and
01878   // ACE_mutex_t are the same type.  However, those typedefs evaluate
01879   // to different types on MS Windows.  The "thread mutex"
01880   // implementation in ACE for MS Windows cannot readily support
01881   // timeouts due to a lack of timeout features for this type of MS
01882   // Windows synchronization mechanism.
01883 
01884 #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS)
01885 # if defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
01886   return ACE_OS::mutex_lock (m, timeout);
01887 #elif defined (VXWORKS) || defined (ACE_PSOS)
01888   return mutex_lock (m, timeout);
01889 #endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
01890 #else
01891   ACE_UNUSED_ARG (m);
01892   ACE_UNUSED_ARG (timeout);
01893   ACE_NOTSUP_RETURN (-1);
01894 #endif /* ACE_HAS_THREADS */
01895 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *    m [static]
 

Definition at line 1852 of file OS.i.

References mutex_lock.

Referenced by ACE_Log_Msg::close, ACE_Log_Msg::instance, mutex_lock, open, recursive_mutex_cond_unlock, recursive_mutex_lock, recursive_mutex_trylock, recursive_mutex_unlock, sema_init, sema_post, sema_trywait, sema_wait, and thread_mutex_lock.

01853 {
01854   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
01855 #if defined (ACE_HAS_THREADS)
01856 # if defined (ACE_HAS_WTHREADS)
01857   ::EnterCriticalSection (m);
01858   return 0;
01859 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
01860   return ACE_OS::mutex_lock (m);
01861 # elif defined (VXWORKS) || defined (ACE_PSOS)
01862   return mutex_lock (m);
01863 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
01864 #else
01865   ACE_UNUSED_ARG (m);
01866   ACE_NOTSUP_RETURN (-1);
01867 #endif /* ACE_HAS_THREADS */
01868 }

ACE_INLINE int ACE_OS::thread_mutex_trylock ACE_thread_mutex_t *    m [static]
 

Definition at line 1907 of file OS.i.

References ACE_OS_TRACE, EBUSY, and mutex_trylock.

Referenced by mutex_trylock, and recursive_mutex_trylock.

01908 {
01909   ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
01910 
01911 #if defined (ACE_HAS_THREADS)
01912 # if defined (ACE_HAS_WTHREADS)
01913 #   if defined (ACE_HAS_WIN32_TRYLOCK)
01914   BOOL result = ::TryEnterCriticalSection (m);
01915   if (result == TRUE)
01916     return 0;
01917   else
01918     {
01919       errno = EBUSY;
01920       return -1;
01921     }
01922 #   else
01923   ACE_UNUSED_ARG (m);
01924   ACE_NOTSUP_RETURN (-1);
01925 #   endif /* ACE_HAS_WIN32_TRYLOCK */
01926 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
01927   return ACE_OS::mutex_trylock (m);
01928 # elif defined (VXWORKS) || defined (ACE_PSOS)
01929   return ACE_OS::mutex_trylock (m);
01930 #endif /* Threads variety case */
01931 
01932 #else
01933   ACE_UNUSED_ARG (m);
01934   ACE_NOTSUP_RETURN (-1);
01935 #endif /* ACE_HAS_THREADS */
01936 }

ACE_INLINE int ACE_OS::thread_mutex_unlock ACE_thread_mutex_t *    m [static]
 

Definition at line 1939 of file OS.i.

References ACE_OS_TRACE, and mutex_unlock.

Referenced by ACE_Log_Msg::close, ACE_Log_Msg::instance, mutex_unlock, open, recursive_mutex_cond_relock, recursive_mutex_cond_unlock, recursive_mutex_lock, recursive_mutex_trylock, recursive_mutex_unlock, sema_init, sema_post, sema_trywait, and sema_wait.

01940 {
01941   ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock");
01942 #if defined (ACE_HAS_THREADS)
01943 # if defined (ACE_HAS_WTHREADS)
01944   ::LeaveCriticalSection (m);
01945   return 0;
01946 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
01947   return ACE_OS::mutex_unlock (m);
01948 # elif defined (VXWORKS) || defined (ACE_PSOS)
01949   return ACE_OS::mutex_unlock (m);
01950 # endif /* Threads variety case */
01951 #else
01952   ACE_UNUSED_ARG (m);
01953   ACE_NOTSUP_RETURN (-1);
01954 #endif /* ACE_HAS_THREADS */
01955 }

ACE_INLINE time_t ACE_OS::time time_t *    tloc = 0 [static]
 

Definition at line 735 of file OS.i.

References ACE_OS_TRACE, gettimeofday, ACE_Time_Value::sec, and time.

Referenced by ACE_System_Time::get_local_system_time, ACE_Service_Config::reconfigure, and time.

00736 {
00737 #if !defined (ACE_HAS_WINCE)
00738   ACE_OS_TRACE ("ACE_OS::time");
00739 #  if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
00740         unsigned long d_date, d_time, d_tick;
00741         tm_get(&d_date, &d_time, &d_tick); // get current time
00742         if (tloc)
00743                 *tloc = d_time; // set time as time_t
00744         return d_time;
00745 #  else
00746   ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1);
00747 #  endif /* ACE_PSOS && ! ACE_PSOS_HAS_TIME */
00748 #else
00749   time_t retv = ACE_OS::gettimeofday ().sec ();
00750   if (tloc)
00751     *tloc = retv;
00752   return retv;
00753 #endif /* ACE_HAS_WINCE */
00754 }

ACE_INLINE long ACE_OS::timezone void    [static]
 

Definition at line 8667 of file OS.i.

References ace_timezone.

08668 {
08669   return ::ace_timezone ();
08670 }

ACE_INLINE int ACE_OS::truncate const ACE_TCHAR   filename,
off_t    length
[static]
 

Definition at line 5754 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_DEFAULT_FILE_PERMS, ACE_OS_TRACE, ACE_TCHAR, open, and truncate.

Referenced by truncate.

05756 {
05757   ACE_OS_TRACE ("ACE_OS::truncate");
05758 #if defined (ACE_WIN32)
05759   ACE_HANDLE handle = ACE_OS::open (filename,
05760                                     O_WRONLY,
05761                                     ACE_DEFAULT_FILE_PERMS);
05762   if (handle == ACE_INVALID_HANDLE)
05763     ACE_FAIL_RETURN (-1);
05764   else if (::SetFilePointer (handle,
05765                              offset,
05766                              0,
05767                              FILE_BEGIN) != (unsigned) -1)
05768     {
05769       BOOL result = ::SetEndOfFile (handle);
05770       ::CloseHandle (handle);
05771       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1);
05772     }
05773   else
05774     {
05775       ::CloseHandle (handle);
05776       ACE_FAIL_RETURN (-1);
05777     }
05778   /* NOTREACHED */
05779 #elif !defined (ACE_LACKS_TRUNCATE)
05780   ACE_OSCALL_RETURN (::truncate (filename, offset), int, -1);
05781 #else
05782   ACE_UNUSED_ARG (filename);
05783   ACE_UNUSED_ARG (offset);
05784   ACE_NOTSUP_RETURN (-1);
05785 #endif /* ACE_WIN32 */
05786 }

ACE_INLINE void ACE_OS::tzset void    [static]
 

Definition at line 8653 of file OS.i.

References ENOTSUP.

08654 {
08655 #if !defined (ACE_HAS_WINCE) && !defined (VXWORKS) && !defined (ACE_PSOS) && ! defined(__rtems__)
08656 #   if defined (ACE_WIN32)
08657   ::_tzset ();  // For Win32.
08658 #   else
08659   ::tzset ();   // For UNIX platforms.
08660 #   endif /* ACE_WIN32 */
08661 # else
08662   errno = ENOTSUP;
08663 # endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS && !__rtems__ */
08664 }

ACE_INLINE u_int ACE_OS::ualarm const ACE_Time_Value   tv,
const ACE_Time_Value   tv_interval = ACE_Time_Value::zero
[static]
 

Definition at line 7931 of file OS.i.

References ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, ACE_Time_Value::sec, and ACE_Time_Value::usec.

07933 {
07934   ACE_OS_TRACE ("ACE_OS::ualarm");
07935 
07936 #if defined (ACE_HAS_UALARM)
07937   u_int usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec ();
07938   u_int interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec ();
07939   return ::ualarm (usecs, interval);
07940 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
07941   ACE_UNUSED_ARG (tv_interval);
07942   return ::alarm (tv.sec ());
07943 #else
07944   ACE_UNUSED_ARG (tv_interval);
07945   ACE_UNUSED_ARG (tv);
07946   ACE_NOTSUP_RETURN (0);
07947 #endif /* ACE_HAS_UALARM */
07948 }

ACE_INLINE u_int ACE_OS::ualarm u_int    usecs,
u_int    interval = 0
[static]
 

Definition at line 7914 of file OS.i.

References ACE_ONE_SECOND_IN_USECS, and ACE_OS_TRACE.

Referenced by ACE_Async_Timer_Queue_Adapter::schedule_ualarm.

07915 {
07916   ACE_OS_TRACE ("ACE_OS::ualarm");
07917 
07918 #if defined (ACE_HAS_UALARM)
07919   return ::ualarm (usecs, interval);
07920 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
07921   ACE_UNUSED_ARG (interval);
07922   return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS);
07923 #else
07924   ACE_UNUSED_ARG (usecs);
07925   ACE_UNUSED_ARG (interval);
07926   ACE_NOTSUP_RETURN (0);
07927 #endif /* ACE_HAS_UALARM */
07928 }

u_int ACE_OS::ualarm_i const ACE_Time_Value   tv,
const ACE_Time_Value   tv_interval = ACE_Time_Value::zero
[static, private]
 

u_int ACE_OS::ualarm_i u_int    usecs,
u_int    interval = 0
[static, private]
 

ACE_INLINE mode_t ACE_OS::umask mode_t    cmask [static]
 

Definition at line 451 of file OS.i.

References ACE_OS_TRACE, and mode_t.

Referenced by ACE::daemonize.

00452 {
00453   ACE_OS_TRACE ("ACE_OS::umask");
00454 # if defined (VXWORKS) || defined (ACE_PSOS)
00455   ACE_UNUSED_ARG (cmask);
00456   ACE_NOTSUP_RETURN (-1);
00457 # else
00458   return ::umask (cmask); // This call shouldn't fail...
00459 # endif /* VXWORKS || ACE_PSOS */
00460 }

ACE_INLINE int ACE_OS::uname ACE_utsname   name [static]
 

Definition at line 462 of file OS.cpp.

References ACE_LIB_TEXT, ACE_OS_TRACE, ACE_TCHAR, ACE_utsname, hostname, sprintf, ACE_OS_String::strcat, and ACE_OS_String::strcpy.

00463 {
00464   ACE_OS_TRACE ("ACE_OS::uname");
00465 # if defined (ACE_WIN32)
00466   size_t maxnamelen = sizeof name->nodename;
00467   ACE_OS::strcpy (name->sysname,
00468                   ACE_LIB_TEXT ("Win32"));
00469 
00470   OSVERSIONINFO vinfo;
00471   vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00472   ::GetVersionEx (&vinfo);
00473 
00474   SYSTEM_INFO sinfo;
00475 #   if defined (ACE_HAS_PHARLAP)
00476   // PharLap doesn't do GetSystemInfo.  What's really wanted is the
00477   // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
00478   // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
00479   // that the CPU type values in EK_KERNELINFO have the same values
00480   // are the ones defined for SYSTEM_INFO.
00481   EK_KERNELINFO ets_kern;
00482   EK_SYSTEMINFO ets_sys;
00483   EtsGetSystemInfo (&ets_kern, &ets_sys);
00484   sinfo.wProcessorLevel = ACE_static_cast (WORD, ets_kern.CpuType);
00485   sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
00486   sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
00487 #   else
00488   ::GetSystemInfo(&sinfo);
00489 
00490   ACE_OS::strcpy (name->sysname, ACE_LIB_TEXT ("Win32"));
00491 #   endif /* ACE_HAS_PHARLAP */
00492 
00493   const ACE_TCHAR* unknown = ACE_LIB_TEXT ("???");
00494 
00495   if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
00496     {
00497       // Get information from the two structures
00498       ACE_OS::sprintf (name->release,
00499 #   if defined (ACE_HAS_WINCE)
00500                        ACE_LIB_TEXT ("Windows CE %d.%d"),
00501 #   else
00502                        ACE_LIB_TEXT ("Windows NT %d.%d"),
00503 #   endif /* ACE_HAS_WINCE */
00504                        (int) vinfo.dwMajorVersion,
00505                        (int) vinfo.dwMinorVersion);
00506       ACE_OS::sprintf (name->version,
00507                        ACE_LIB_TEXT ("Build %d %s"),
00508                        (int) vinfo.dwBuildNumber,
00509                        vinfo.szCSDVersion);
00510 
00511       // We have to make sure that the size of (processor + subtype)
00512       // is not greater than the size of name->machine.  So we give
00513       // half the space to the processor and half the space to
00514       // subtype.  The -1 is necessary for because of the space
00515       // between processor and subtype in the machine name.
00516       const int bufsize = ((sizeof (name->machine) / sizeof (ACE_TCHAR)) / 2) - 1;
00517       ACE_TCHAR processor[bufsize] = ACE_LIB_TEXT ("Unknown");
00518       ACE_TCHAR subtype[bufsize] = ACE_LIB_TEXT ("Unknown");
00519 
00520 #   if defined (ghs)
00521     WORD arch = sinfo.u.s.wProcessorArchitecture;
00522 #   else
00523     WORD arch = sinfo.wProcessorArchitecture;
00524 #   endif
00525 
00526       switch (arch)
00527         {
00528         case PROCESSOR_ARCHITECTURE_INTEL:
00529           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Intel"));
00530           if (sinfo.wProcessorLevel == 3)
00531             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80386"));
00532           else if (sinfo.wProcessorLevel == 4)
00533             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80486"));
00534           else if (sinfo.wProcessorLevel == 5)
00535             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium"));
00536           else if (sinfo.wProcessorLevel == 6)
00537             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium Pro"));
00538           else if (sinfo.wProcessorLevel == 7)  // I'm guessing here
00539             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium II"));
00540           break;
00541         case PROCESSOR_ARCHITECTURE_MIPS:
00542           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("MIPS"));
00543           ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("R4000"));
00544           break;
00545         case PROCESSOR_ARCHITECTURE_ALPHA:
00546           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Alpha"));
00547           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), sinfo.wProcessorLevel);
00548           break;
00549         case PROCESSOR_ARCHITECTURE_PPC:
00550           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("PPC"));
00551           if (sinfo.wProcessorLevel == 1)
00552             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("601"));
00553           else if (sinfo.wProcessorLevel == 3)
00554             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603"));
00555           else if (sinfo.wProcessorLevel == 4)
00556             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("604"));
00557           else if (sinfo.wProcessorLevel == 6)
00558             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603+"));
00559           else if (sinfo.wProcessorLevel == 9)
00560             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("804+"));
00561           else if (sinfo.wProcessorLevel == 20)
00562             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("620"));
00563           break;
00564 #     if defined PROCESSOR_ARCHITECTURE_IA64
00565         case PROCESSOR_ARCHITECTURE_IA64:
00566           ACE_OS_String::strcpy (processor, ACE_LIB_TEXT ("Itanium"));
00567           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), sinfo.wProcessorLevel);
00568           break;
00569 #     endif
00570         case PROCESSOR_ARCHITECTURE_UNKNOWN:
00571         default:
00572           // @@ We could provide WinCE specific info here.  But let's
00573           //    defer that to some later point.
00574           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Unknown"));
00575           break;
00576         }
00577       ACE_OS::sprintf (name->machine,
00578                        ACE_LIB_TEXT ("%s %s"),
00579                        processor, subtype);
00580     }
00581   else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00582     {
00583       if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
00584         {
00585           ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 95"));
00586           if (vinfo.szCSDVersion[1] == 'C')
00587             ACE_OS::strcat (name->release, ACE_LIB_TEXT (" OSR2"));
00588         }
00589       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
00590         {
00591           ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 98"));
00592           if (vinfo.szCSDVersion[1] == 'A')
00593             ACE_OS::strcat (name->release, ACE_LIB_TEXT (" SE"));
00594         }
00595       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
00596         {
00597           ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows Me"));
00598         }
00599       else
00600         {
00601           ACE_OS::strcpy (name->release, unknown);
00602         }
00603 
00604       ACE_OS::sprintf (name->version, ACE_LIB_TEXT ("%d"),
00605                        LOWORD (vinfo.dwBuildNumber));
00606       if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
00607         ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80386"));
00608       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
00609         ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80486"));
00610       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
00611         ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel Pentium"));
00612       else
00613         ACE_OS::strcpy (name->machine, unknown);
00614     }
00615   else
00616     {
00617       // We don't know what this is!
00618 
00619       ACE_OS::strcpy (name->release, unknown);
00620       ACE_OS::strcpy (name->version, unknown);
00621       ACE_OS::strcpy (name->machine, unknown);
00622     }
00623 
00624 # if defined (ACE_LACKS_HOSTNAME)
00625   return 0;
00626 # else /* ACE_LACKS_HOSTNAME */
00627   return ACE_OS::hostname (name->nodename, maxnamelen);
00628 # endif /* ACE_LACKS_HOSTNAME */
00629 
00630 # elif defined (VXWORKS)
00631   size_t maxnamelen = sizeof name->nodename;
00632   ACE_OS::strcpy (name->sysname, "VxWorks");
00633   ACE_OS::strcpy (name->release, "???");
00634   ACE_OS::strcpy (name->version, sysBspRev ());
00635   ACE_OS::strcpy (name->machine, sysModel ());
00636 
00637   return ACE_OS::hostname (name->nodename, maxnamelen);
00638 # elif defined (CHORUS)
00639   size_t maxnamelen = sizeof name->nodename;
00640   ACE_OS::strcpy (name->sysname, "CHORUS/ClassiX");
00641   ACE_OS::strcpy (name->release, "???");
00642   ACE_OS::strcpy (name->version, "???");
00643   ACE_OS::strcpy (name->machine, "???");
00644 
00645   return ACE_OS::hostname (name->nodename, maxnamelen);
00646 #elif defined (ACE_PSOS)
00647   const unsigned long buflen(64);
00648   char buf[buflen];
00649   unsigned long len;
00650   sys_info(PSOS_VERSION,(void *)buf,buflen,&len);
00651   ACE_OS::strcpy (name->sysname, "pSOS");
00652   ACE_OS::strcpy (name->release, "???");
00653   ACE_OS::strcpy (name->version, buf);
00654   ACE_OS::strcpy (name->machine, "PPC 405");  // a bit of a hack
00655 
00656 #endif /* ACE_WIN32 */
00657 }

wint_t ACE_OS::ungetwc wint_t    c,
FILE *    fp
[static]
 

void ACE_OS::unique_name const void *    object,
ACE_TCHAR   name,
size_t    length
[static]
 

This method uses process id and object pointer to come up with a machine wide unique name. The process ID will provide uniqueness between processes on the same machine. The "this" pointer of the <object> will provide uniqueness between other "live" objects in the same process. The uniqueness of this name is therefore only valid for the life of <object>.

Definition at line 3880 of file OS.cpp.

References ACE_LIB_TEXT, ACE_TCHAR, ACE_UNIQUE_NAME_LEN, getpid, sprintf, and ACE_OS_String::strsncpy.

Referenced by ACE_MEM_Acceptor::accept, ACE_DLL::set_handle, thr_keycreate, and ACE::unique_name.

03883 {
03884   // The process ID will provide uniqueness between processes on the
03885   // same machine. The "this" pointer of the <object> will provide
03886   // uniqueness between other "live" objects in the same process. The
03887   // uniqueness of this name is therefore only valid for the life of
03888   // <object>.
03889   ACE_TCHAR temp_name[ACE_UNIQUE_NAME_LEN];
03890   ACE_OS::sprintf (temp_name,
03891                    ACE_LIB_TEXT ("%p%d"),
03892                    object,
03893                    ACE_static_cast (int, ACE_OS::getpid ()));
03894   ACE_OS::strsncpy (name,
03895                     temp_name,
03896                     length);
03897 }

ACE_INLINE int ACE_OS::unlink const ACE_TCHAR   path [static]
 

Definition at line 771 of file OS.i.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_TCHAR, and unlink.

Referenced by ACE_MEM_Acceptor::accept, flock_destroy, ACE_Logging_Strategy::handle_timeout, ACE_Lib_Find::open_temp_file, ACE_Filecache_Object::release, ACE_SPIPE_Acceptor::remove, ACE_SPIPE::remove, ACE_Mem_Map::remove, ACE_LSOCK_Acceptor::remove, ACE_FILE::remove, ACE_FIFO::remove, shm_unlink, unlink, and ACE_FILE::unlink.

00772 {
00773   ACE_OS_TRACE ("ACE_OS::unlink");
00774 # if defined (VXWORKS)
00775     ACE_OSCALL_RETURN (::unlink (ACE_const_cast (char *, path)), int, -1);
00776 # elif defined (ACE_PSOS) && ! defined (ACE_PSOS_LACKS_PHILE)
00777     ACE_OSCALL_RETURN (::remove_f ((char *) path), int , -1);
00778 # elif defined (ACE_PSOS) && defined (ACE_PSOS_HAS_C_LIBRARY)
00779     ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::remove ((char *) path),
00780                                                    ace_result_),
00781                        int, -1);
00782 # elif defined (ACE_HAS_WINCE)
00783   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
00784   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (path), ace_result_),
00785                         int, -1);
00786 # elif defined (ACE_LACKS_UNLINK)
00787     ACE_UNUSED_ARG (path);
00788     ACE_NOTSUP_RETURN (-1);
00789 # elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00790   ACE_OSCALL_RETURN (::_wunlink (path), int, -1);
00791 # else
00792   ACE_OSCALL_RETURN (::unlink (path), int, -1);
00793 # endif /* VXWORKS */
00794 }

int ACE_OS::vsprintf wchar_t *    buffer,
const wchar_t *    format,
va_list    argptr
[static]
 

ACE_INLINE int ACE_OS::vsprintf char *    buffer,
const char *    format,
va_list    argptr
[static]
 

Definition at line 1054 of file OS.i.

References ACE_SPRINTF_ADAPTER, and vsprintf.

Referenced by ACE_Process_Options::command_line, ACE_Process_Options::setenv, sprintf, and vsprintf.

01055 {
01056   return ACE_SPRINTF_ADAPTER (::vsprintf (buffer, format, argptr));
01057 }

ACE_INLINE pid_t ACE_OS::wait int *    = 0 [static]
 

Calls OS <wait> function, so it's only portable to UNIX/POSIX platforms.

Definition at line 10092 of file OS.i.

References ACE_OS_TRACE, pid_t, and wait.

10093 {
10094   ACE_OS_TRACE ("ACE_OS::wait");
10095 #if defined (ACE_WIN32) || defined (VXWORKS) || defined(CHORUS) || defined (ACE_PSOS)
10096   ACE_UNUSED_ARG (status);
10097 
10098   ACE_NOTSUP_RETURN (0);
10099 #else
10100 # if defined (ACE_HAS_UNION_WAIT)
10101   ACE_OSCALL_RETURN (::wait ((union wait *) status), pid_t, -1);
10102 # else
10103   ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
10104 # endif /* ACE_HAS_UNION_WAIT */
10105 #endif /* ACE_WIN32 || VXWORKS || CHORUS || ACE_PSOS */
10106 }

ACE_INLINE pid_t ACE_OS::wait pid_t    pid,
ACE_exitcode   status,
int    wait_options = 0,
ACE_HANDLE    handle = 0
[static]
 

Calls <WaitForSingleObject> on Win32 and <ACE::waitpid> otherwise. Returns the passed in <pid_t> on success and -1 on failure. On Win32, <pid> is ignored if the <handle> is not equal to 0. Passing the process <handle> is prefer on Win32 because using <pid> to wait on the project doesn't always work correctly if the waited process has already terminated.

Definition at line 10079 of file OS.i.

References ACE_exitcode, ACE_OS_TRACE, pid_t, and waitpid.

Referenced by sleep, ACE_Process::wait, and wait.

10083 {
10084   ACE_OS_TRACE ("ACE_OS::wait");
10085   return ACE_OS::waitpid (pid,
10086                           status,
10087                           wait_options,
10088                           handle);
10089 }

ACE_INLINE pid_t ACE_OS::waitpid pid_t    pid,
ACE_exitcode   status = 0,
int    wait_options = 0,
ACE_HANDLE    handle = 0
[static]
 

Calls <waitpid> on UNIX/POSIX platforms and <await> on Chorus. Does not work on Vxworks, or pSoS. On Win32, <pid> is ignored if the <handle> is not equal to 0. Passing the process <handle> is prefer on Win32 because using <pid> to wait on the project doesn't always work correctly if the waited process has already terminated.

Definition at line 10007 of file OS.i.

References ACE_BIT_ENABLED, ACE_exitcode, ACE_OS_TRACE, ETIME, pid_t, set_errno_to_last_error, waitpid, and WNOHANG.

Referenced by ACE::fork, ACE_Process_Manager::wait, ACE_Process::wait, wait, and waitpid.

10011 {
10012   ACE_OS_TRACE ("ACE_OS::waitpid");
10013 #if defined (VXWORKS) || defined (ACE_PSOS)
10014   ACE_UNUSED_ARG (pid);
10015   ACE_UNUSED_ARG (status);
10016   ACE_UNUSED_ARG (wait_options);
10017   ACE_UNUSED_ARG (handle);
10018 
10019   ACE_NOTSUP_RETURN (0);
10020 #elif defined (ACE_WIN32)
10021   int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
10022     ? 0 /* don't hang */
10023     : INFINITE;
10024 
10025   ACE_HANDLE phandle = handle;
10026 
10027   if (phandle == 0)
10028     {
10029       phandle = ::OpenProcess (SYNCHRONIZE,
10030                                FALSE,
10031                                pid);
10032 
10033       if (phandle == 0)
10034         {
10035           ACE_OS::set_errno_to_last_error ();
10036           return -1;
10037         }
10038     }
10039 
10040   pid_t result = pid;
10041 
10042   // Don't try to get the process exit status if wait failed so we can
10043   // keep the original error code intact.
10044   switch (::WaitForSingleObject (phandle,
10045                                  blocking_period))
10046     {
10047     case WAIT_OBJECT_0:
10048       if (status != 0)
10049         // The error status of <GetExitCodeProcess> is nonetheless
10050         // not tested because we don't know how to return the value.
10051         ::GetExitCodeProcess (phandle,
10052                               status);
10053       break;
10054     case WAIT_TIMEOUT:
10055       errno = ETIME;
10056       result = 0;
10057       break;
10058     default:
10059       ACE_OS::set_errno_to_last_error ();
10060       result = -1;
10061     }
10062   if (handle == 0)
10063     ::CloseHandle (phandle);
10064   return result;
10065 #elif defined (CHORUS)
10066   ACE_UNUSED_ARG (status);
10067   ACE_UNUSED_ARG (wait_options);
10068   ACE_UNUSED_ARG (handle);
10069   ACE_OSCALL_RETURN (::await (&ACE_OS::actorcaps_[pid]),
10070                      pid_t, -1);
10071 #else
10072   ACE_UNUSED_ARG (handle);
10073   ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
10074                      pid_t, -1);
10075 #endif /* VXWORKS || ACE_PSOS */
10076 }

ACE_INLINE ssize_t ACE_OS::write ACE_HANDLE    handle,
const void *    buf,
size_t    nbyte,
ACE_OVERLAPPED  
[static]
 

Definition at line 8222 of file OS.i.

References ACE_OS_TRACE, ACE_OVERLAPPED, and write.

08224 {
08225   ACE_OS_TRACE ("ACE_OS::write");
08226   overlapped = overlapped;
08227 #if defined (ACE_WIN32)
08228   DWORD bytes_written; // This is set to 0 byte WriteFile.
08229 
08230   DWORD short_nbyte = ACE_static_cast (DWORD, nbyte);
08231   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped))
08232     return (ssize_t) bytes_written;
08233   else
08234     return -1;
08235 #else
08236   return ACE_OS::write (handle, buf, nbyte);
08237 #endif /* ACE_WIN32 */
08238 }

ACE_INLINE ssize_t ACE_OS::write ACE_HANDLE    handle,
const void *    buf,
size_t    nbyte
[static]
 

Definition at line 8183 of file OS.i.

References ACE_OS_TRACE, ssize_t, and write.

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name, ACE_UPIPE_Connector::connect, ACE_Dev_Poll_Reactor::mask_ops_i, ACE_High_Res_Timer::print_ave, ACE_High_Res_Timer::print_total, putmsg, pwrite, ACE_Dev_Poll_Reactor::register_handler_i, ACE_Filecache_Object::release, ACE_Dev_Poll_Reactor::resume_handler_i, ACE_SPIPE_Stream::send, ACE_SOCK_IO::send, ACE_FILE_IO::send, ACE_FIFO_Send::send, ACE_DEV_IO::send, ACE::send_i, ACE_Dev_Poll_Reactor::suspend_handler_i, ACE_Mem_Map::unmap, write, and write_n.

08184 {
08185   ACE_OS_TRACE ("ACE_OS::write");
08186 #if defined (ACE_WIN32)
08187   DWORD bytes_written; // This is set to 0 byte WriteFile.
08188 
08189   // Strictly correctly, we should loop writing all the data if more
08190   // than a DWORD length can hold.
08191   DWORD short_nbyte = ACE_static_cast (DWORD, nbyte);
08192   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0))
08193     return (ssize_t) bytes_written;
08194   else
08195     ACE_FAIL_RETURN (-1);
08196 #elif defined (ACE_PSOS)
08197 # if defined (ACE_PSOS_LACKS_PHILE)
08198   ACE_UNUSED_ARG (handle);
08199   ACE_UNUSED_ARG (buf);
08200   ACE_UNUSED_ARG (nbyte);
08201   ACE_NOTSUP_RETURN (-1);
08202 # else
08203   if(::write_f (handle, (void *) buf, nbyte) == 0)
08204     return (ssize_t) nbyte;
08205   else
08206     return -1;
08207 # endif /* defined (ACE_PSOS_LACKS_PHILE) */
08208 #else
08209 # if defined (ACE_LACKS_POSIX_PROTOTYPES)
08210   ACE_OSCALL_RETURN (::write (handle, (const char *) buf, nbyte), ssize_t, -1);
08211 # elif defined (ACE_PSOS)
08212   ACE_OSCALL_RETURN (::write_f(handle, (void *) buf, nbyte), ssize_t, -1);
08213 # elif defined (ACE_HAS_CHARPTR_SOCKOPT)
08214   ACE_OSCALL_RETURN (::write (handle, (char *) buf, nbyte), ssize_t, -1);
08215 # else
08216   ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
08217 # endif /* ACE_LACKS_POSIX_PROTOTYPES */
08218 #endif /* ACE_WIN32 */
08219 }

ssize_t ACE_OS::write_n ACE_HANDLE    handle,
const void *    buf,
size_t    len,
size_t *    bytes_transferred = 0
[static]
 

Send <len> bytes from <buf> to <handle> (uses the <ACE_OS::write> calls, which is uses the <write> system call on UNIX and the <WriteFile> call on Win32). If errors occur, -1 is returned. If EOF occurs, 0 is returned. Whatever data has been transmitted will be returned to the caller through <bytes_transferred>.

Definition at line 4205 of file OS.cpp.

References ssize_t, and write.

Referenced by ACE::write_n.

04209 {
04210   size_t temp;
04211   size_t &bytes_transferred = bt == 0 ? temp : *bt;
04212   ssize_t n;
04213 
04214   for (bytes_transferred = 0;
04215        bytes_transferred < len;
04216        bytes_transferred += n)
04217     {
04218       n = ACE_OS::write (handle,
04219                          (char *) buf + bytes_transferred,
04220                          len - bytes_transferred);
04221 
04222       if (n == -1 || n == 0)
04223         return n;
04224     }
04225 
04226   return bytes_transferred;
04227 }

ACE_INLINE ssize_t ACE_OS::writev ACE_HANDLE    handle,
const iovec   iov,
int    iovcnt
[static]
 

Definition at line 7483 of file OS.i.

References ACE_OS_TRACE, ACE_WRITEV_TYPE, and writev.

Referenced by ACE_SPIPE_Stream::send, ACE_FILE_IO::send, ACE_FIFO_Send_Msg::send, ACE_DEV_IO::send, ACE_SPIPE_Stream::sendv, sendv, ACE_FILE_IO::sendv, writev, and ACE::writev_n.

07486 {
07487   ACE_OS_TRACE ("ACE_OS::writev");
07488 #if defined (ACE_LACKS_WRITEV)
07489   ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle,
07490                                                (ACE_WRITEV_TYPE *) iov,
07491                                                iovcnt), int, -1);
07492 #else /* ACE_LACKS_WRITEV */
07493   ACE_OSCALL_RETURN (::writev (handle,
07494                                (ACE_WRITEV_TYPE *) iov,
07495                                iovcnt), int, -1);
07496 #endif /* ACE_LACKS_WRITEV */
07497 }

ACE_INLINE int ACE_OS::wscmp const WChar  ,
const WChar  
[static]
 

Definition at line 10547 of file OS.i.

References WChar.

10548 {
10549   const WChar *scan1 = s;
10550   const WChar *scan2 = t;
10551 
10552   while (*scan1 != 0 && *scan1 == *scan2)
10553     {
10554       ++scan1;
10555       ++scan2;
10556     }
10557 
10558   return *scan1 - *scan2;
10559 }

ACE_INLINE ACE_OS::WChar * ACE_OS::wscpy WChar  ,
const WChar  
[static]
 

Definition at line 10536 of file OS.i.

References WChar.

10537 {
10538   WChar *original_dest = dest;
10539 
10540   while ((*dest++ = *src++) != 0)
10541     continue;
10542 
10543   return original_dest;
10544 }

ACE_INLINE u_int ACE_OS::wslen const WChar   [static]
 

Definition at line 10525 of file OS.i.

Referenced by ACE_Log_Msg::log, operator<<, operator>>, and ACE_OutputCDR::write_wstring.

10526 {
10527   u_int len = 0;
10528 
10529   while (*s++ != 0)
10530     len++;
10531 
10532   return len;
10533 }

ACE_INLINE int ACE_OS::wsncmp const WChar  ,
const WChar  ,
size_t    len
[static]
 

Definition at line 10562 of file OS.i.

References WChar.

10563 {
10564   const WChar *scan1 = s;
10565   const WChar *scan2 = t;
10566 
10567   while (len != 0 && *scan1 != 0 && *scan1 == *scan2)
10568     {
10569       ++scan1;
10570       ++scan2;
10571       --len;
10572     }
10573 
10574   return len == 0 ? 0 : *scan1 - *scan2;
10575 }


Friends And Related Function Documentation

friend class ACE_OS_Object_Manager [friend]
 

Allow the ACE_OS_Object_Manager to call set_exit_hook.

Definition at line 6064 of file OS.h.

friend class ACE_Timeout_Manager [friend]
 

Definition at line 4594 of file OS.h.


Member Data Documentation

ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0 [static, private]
 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 249 of file OS.cpp.

Referenced by set_exit_hook.

ACE_hthread_t ACE_OS::NULL_hthread [static]
 

This is necessary to deal with POSIX pthreads and their use of structures for thread handles.

Definition at line 1586 of file OS.cpp.

Referenced by ACE_Thread_Descriptor_Base::reset.

ACE_thread_key_t ACE_OS::NULL_key [static]
 

This is necessary to deal with POSIX pthreads and their use of structures for TSS keys.

Definition at line 1590 of file OS.cpp.

Referenced by ACE_TSS_Cleanup::exit, ACE_TSS_Cleanup::free_all_keys_left, ACE_TSS_Cleanup::remove, and ACE_TSS_Cleanup::tss_keys.

ACE_thread_t ACE_OS::NULL_thread [static]
 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1585 of file OS.cpp.

Referenced by ACE_Recursive_Thread_Mutex::get_thread_id, recursive_mutex_cond_unlock, recursive_mutex_init, recursive_mutex_unlock, ACE_Thread_Descriptor_Base::reset, and ACE_Token::wakeup_next_waiter.

int ACE_OS::socket_initialized_ [static]
 

Keeps track of whether we've already initialized WinSock...

Definition at line 1604 of file OS.cpp.

Referenced by socket_fini, and socket_init.

HINSTANCE ACE_OS::win32_resource_module_ [static, private]
 

Definition at line 6079 of file OS.h.

OSVERSIONINFO ACE_OS::win32_versioninfo_ [static, private]
 

Definition at line 6077 of file OS.h.

Referenced by ACE_OS_Object_Manager::init.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:51:46 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002