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   A