ACE_OS Namespace Reference

This namespace 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...

Classes

struct  macaddr_node_t
class  ace_flock_t
 OS file locking structure. More...

Typedefs

typedef ACE_WCHAR_T WChar

Enumerations

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

Functions

ACE_NAMESPACE_INLINE_FUNCTION
unsigned long 
inet_addr (const char *name)
ACE_Export int inet_aton (const char *strptr, struct in_addr *addr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
inet_ntoa (const struct in_addr addr)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION int inet_pton (int family, const char *strptr, void *addrptr)
ACE_NAMESPACE_INLINE_FUNCTION int posix_devctl (int filedes, int dcmd, void *dev_data_ptr, size_t nbyte, int *dev_info_ptr)
void closedir (ACE_DIR *)
ACE_DIRopendir (const ACE_TCHAR *filename)
struct ACE_DIRENT * readdir (ACE_DIR *)
int readdir_r (ACE_DIR *dirp, struct ACE_DIRENT *entry, struct ACE_DIRENT **result)
void rewinddir (ACE_DIR *)
int scandir (const ACE_TCHAR *dirname, struct ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator)
int alphasort (const void *, const void *)
void seekdir (ACE_DIR *, long loc)
long telldir (ACE_DIR *)
int scandir_emulation (const ACE_TCHAR *dirname, ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator)
ACE_NAMESPACE_INLINE_FUNCTION int last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION void last_error (int error)
ACE_NAMESPACE_INLINE_FUNCTION int set_errno_to_last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION int set_errno_to_wsa_last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION int fcntl (ACE_HANDLE handle, int cmd, long arg=0)
ACE_Export ACE_HANDLE open (const char *filename, int mode, mode_t 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.
ACE_Export ACE_HANDLE open (const wchar_t *filename, int mode, mode_t perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
template<typename T >
floor (T x)
 This method computes the largest integral value not greater than x.
template<typename T >
ceil (T x)
 This method computes the smallest integral value not less than x.
double log2 (double x)
 This method computes the base-2 logarithm of x.
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent
gethostbyaddr (const char *addr, int length, int type)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent
gethostbyaddr_r (const char *addr, int length, int type, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent
gethostbyname (const char *name)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent
gethostbyname_r (const char *name, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent
getipnodebyaddr (const void *src, size_t len, int family)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent
getipnodebyname (const char *name, int family, int flags=0)
ACE_Export int getmacaddress (struct macaddr_node_t *node)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent
getprotobyname (const char *name)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent
getprotobyname_r (const char *name, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent
getprotobynumber (int proto)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent
getprotobynumber_r (int proto, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_NAMESPACE_INLINE_FUNCTION
struct servent
getservbyname (const char *svc, const char *proto)
ACE_NAMESPACE_INLINE_FUNCTION
struct servent
getservbyname_r (const char *svc, const char *proto, struct servent *result, ACE_SERVENT_DATA buf)
ACE_NAMESPACE_INLINE_FUNCTION int getaddrinfo (const char *name, const char *service, const addrinfo *hints, addrinfo **result)
ACE_NAMESPACE_INLINE_FUNCTION void freeaddrinfo (addrinfo *result)
ACE_NAMESPACE_INLINE_FUNCTION
const ACE_TCHAR
gai_strerror (int errcode)
ACE_NAMESPACE_INLINE_FUNCTION int getnameinfo (const sockaddr *addr, ACE_SOCKET_LEN addr_len, char *host, ACE_SOCKET_LEN host_len, char *service, ACE_SOCKET_LEN service_len, unsigned int flags)
ACE_Export int getaddrinfo_emulation (const char *name, addrinfo **result)
ACE_Export void freeaddrinfo_emulation (addrinfo *result)
ACE_Export int getnameinfo_emulation (const sockaddr *addr, ACE_SOCKET_LEN addr_len, char *host, ACE_SOCKET_LEN host_len)
ACE_Export int netdb_acquire (void)
ACE_Export int netdb_release (void)
ACE_NAMESPACE_INLINE_FUNCTION int poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value *tv=0)
ACE_NAMESPACE_INLINE_FUNCTION int poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value &tv)
void clearerr (FILE *fp)
int asprintf (char **bufp, const char *format,...) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int asprintf (wchar_t **bufp, const wchar_t *format,...)
int fclose (FILE *fp)
FILE * fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode)
int fflush (FILE *fp)
int fgetc (FILE *fp)
int getc (FILE *fp)
int fgetpos (FILE *fp, fpos_t *pos)
char * fgets (char *buf, int size, FILE *fp)
wchar_tfgets (wchar_t *buf, int size, FILE *fp)
ACE_HANDLE fileno (FILE *stream)
FILE * fopen (const char *filename, const char *mode)
FILE * fopen (const char *filename, const wchar_t *mode)
FILE * fopen (const wchar_t *filename, const wchar_t *mode)
FILE * fopen (const wchar_t *filename, const char *mode)
LPSECURITY_ATTRIBUTES default_win32_security_attributes (LPSECURITY_ATTRIBUTES)
 Default Win32 Security Attributes definition.
LPSECURITY_ATTRIBUTES default_win32_security_attributes_r (LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, SECURITY_DESCRIPTOR *)
const ACE_TEXT_OSVERSIONINFO & get_win32_versioninfo (void)
 Return the win32 OSVERSIONINFO structure.
HINSTANCE get_win32_resource_module (void)
void set_win32_resource_module (HINSTANCE)
int fprintf (FILE *fp, const char *format,...) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int fprintf (FILE *fp, const wchar_t *format,...)
int ungetc (int c, FILE *fp)
int fputc (int c, FILE *fp)
int putc (int c, FILE *fp)
int fputs (const char *s, FILE *stream)
int fputs (const wchar_t *s, FILE *stream)
size_t fread (void *ptr, size_t size, size_t nelems, FILE *fp)
FILE * freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE *stream)
int fseek (FILE *fp, long offset, int ptrname)
int fsetpos (FILE *fp, fpos_t *pos)
long ftell (FILE *fp)
size_t fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp)
void perror (const char *s)
void perror (const wchar_t *s)
int printf (const char *format,...) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int printf (const wchar_t *format,...)
int puts (const char *s)
int puts (const wchar_t *s)
int rename (const char *old_name, const char *new_name, int flags=-1)
int rename (const wchar_t *old_name, const wchar_t *new_name, int flags=-1)
void rewind (FILE *fp)
int snprintf (char *buf, size_t maxlen, const char *format,...) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...)
int sprintf (char *buf, const char *format,...) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int sprintf (wchar_t *buf, const wchar_t *format,...)
char * tempnam (const char *dir=0, const char *pfx=0)
wchar_ttempnam (const wchar_t *dir, const wchar_t *pfx=0)
int vasprintf (char **bufp, const char *format, va_list argptr) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int vprintf (const char *format, va_list argptr) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int int vfprintf (FILE *fp, const char *format, va_list argptr) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int int int vsprintf (char *buffer, const char *format, va_list argptr) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int int int int vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr) ACE_GCC_FORMAT_ATTRIBUTE(printf
int int int int int int vasprintf (wchar_t **bufp, const wchar_t *format, va_list argptr)
int vprintf (const wchar_t *format, va_list argptr)
int vfprintf (FILE *fp, const wchar_t *format, va_list argptr)
int vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr)
int vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_list argptr)
int vasprintf_emulation (char **bufp, const char *format, va_list argptr)
int vaswprintf_emulation (wchar_t **bufp, const wchar_t *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strtok_r (char *s, const char *tokens, char **lasts)
 Finds the next token in a string (safe char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
 Finds the next token in a string (wchar_t version).
ACE_Export char * strtok_r_emulation (char *s, const char *tokens, char **lasts)
 Emulated strtok_r.
ACE_Export wchar_tstrtok_r_emulation (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
 Emulated strtok_r (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION int strcasecmp (const char *s, const char *t)
 Compares two strings (case insensitive const char version).
ACE_NAMESPACE_INLINE_FUNCTION int strcasecmp (const wchar_t *s, const wchar_t *t)
 Compares two strings (case insensitive const wchar_t version).
int strncasecmp (const char *s, const char *t, size_t len)
 Compares two arrays (case insensitive const char version).
int strncasecmp (const wchar_t *s, const wchar_t *t, size_t len)
 Compares two arrays (case insensitive const wchar_t version).
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 fattach (int handle, const char *path)
int fdetach (const char *file)
int ioctl (ACE_HANDLE handle, ACE_IOCTL_TYPE_ARG2 cmd, void *=0)
 UNIX-style ioctl.
int ioctl (ACE_HANDLE socket, unsigned long io_control_code, void *in_buffer_p, unsigned long in_buffer, void *out_buffer_p, unsigned long out_buffer, unsigned long *bytes_returned, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 QoS-enabled ioctl.
int ioctl (ACE_HANDLE socket, unsigned long io_control_code, ACE_QoS &ace_qos, unsigned long *bytes_returned, void *buffer_p=0, unsigned long buffer=0, ACE_OVERLAPPED *overlapped=0, ACE_OVERLAPPED_COMPLETION_FUNC func=0)
int isastream (ACE_HANDLE handle)
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)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
shm_open (const ACE_TCHAR *filename, int mode, mode_t perms=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION int shm_unlink (const ACE_TCHAR *path)
ACE_NAMESPACE_INLINE_FUNCTION int getrlimit (int resource, struct rlimit *rl)
ACE_NAMESPACE_INLINE_FUNCTION int getrusage (int who, struct rusage *rusage)
ACE_NAMESPACE_INLINE_FUNCTION int setrlimit (int resource, const struct rlimit *rl)
ACE_NAMESPACE_INLINE_FUNCTION int select (int width, fd_set *rfds, fd_set *wfds=0, fd_set *efds=0, const ACE_Time_Value *tv=0)
ACE_NAMESPACE_INLINE_FUNCTION int select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendfile (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
 Finds the length of a string (char version).
ACE_Export ssize_t sendfile_emulation (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
ACE_HANDLE creat (const ACE_TCHAR *filename, mode_t mode)
int fstat (ACE_HANDLE, ACE_stat *)
int lstat (const char *, ACE_stat *)
int lstat (const wchar_t *, ACE_stat *)
int mkdir (const char *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
int mkdir (const wchar_t *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
int mkfifo (const ACE_TCHAR *file, mode_t mode=ACE_DEFAULT_FILE_PERMS)
int stat (const char *file, ACE_stat *)
int stat (const wchar_t *file, ACE_stat *)
mode_t umask (mode_t cmask)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_Time_Value 
gettimeofday (void)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_Time_Value 
gettimeofday_ (void)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
readv (ACE_HANDLE handle, const iovec *iov, int iovlen)
ACE_Export ssize_t readv_emulation (ACE_HANDLE handle, const iovec *iov, int iovcnt)
ssize_t writev (ACE_HANDLE handle, const iovec *iov, int iovcnt)
int uname (ACE_utsname *name)
ACE_NAMESPACE_INLINE_FUNCTION pid_t wait (int *=0)
 Calls OS wait function, so it's only portable to UNIX/POSIX platforms.
ACE_NAMESPACE_INLINE_FUNCTION pid_t wait (pid_t pid, ACE_exitcode *status, int wait_options=0, ACE_HANDLE handle=0)
ACE_NAMESPACE_INLINE_FUNCTION pid_t waitpid (pid_t pid, ACE_exitcode *status=0, int wait_options=0, ACE_HANDLE handle=0)
void cleanup_tss (const u_int main_thread)
int lwp_getparams (ACE_Sched_Params &)
int lwp_setparams (const ACE_Sched_Params &)
long priority_control (ACE_idtype_t, ACE_id_t, int, void *)
 Low-level interface to priocntl(2).
int scheduling_class (const char *class_name, ACE_id_t &)
 Find the scheduling class ID that corresponds to the class name.
int set_scheduling_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)
 Friendly interface to priocntl(2).
int sigtimedwait (const sigset_t *set, siginfo_t *info, const ACE_Time_Value *timeout)
int sigwait (sigset_t *set, int *sig=0)
int sigwaitinfo (const sigset_t *set, siginfo_t *info)
int thr_cancel (ACE_thread_t t_id)
int thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2)
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=ACE_DEFAULT_THREAD_STACKSIZE, ACE_Base_Thread_Adapter *thread_adapter=0, const char **thr_name=0)
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 thr_getprio (ACE_hthread_t id, int &priority)
int thr_getprio (ACE_hthread_t id, int &priority, int &policy)
int thr_getspecific (ACE_thread_key_t key, void **data)
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_get_affinity (ACE_hthread_t thr_id, size_t cpu_set_size, cpu_set_t *cpu_mask)
int thr_set_affinity (ACE_hthread_t thr_id, size_t cpu_set_size, const cpu_set_t *cpu_mask)
int thr_key_detach (ACE_thread_key_t key)
int thr_key_used (ACE_thread_key_t key)
int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST)
int thr_keyfree (ACE_thread_key_t key)
int thr_kill (ACE_thread_t thr_id, int signum)
size_t thr_min_stack (void)
ACE_thread_t thr_self (void)
void thr_self (ACE_hthread_t &)
const char * thr_name (void)
ssize_t thr_id (char buffer[], size_t buffer_length)
int thr_setcancelstate (int new_state, int *old_state)
 State is THR_CANCEL_ENABLE or THR_CANCEL_DISABLE.
int thr_setcanceltype (int new_type, int *old_type)
 Type is THR_CANCEL_DEFERRED or THR_CANCEL_ASYNCHRONOUS.
int thr_setconcurrency (int hint)
int thr_setprio (ACE_hthread_t ht_id, int priority, int policy=-1)
int thr_setprio (const ACE_Sched_Priority prio)
int thr_setspecific (ACE_thread_key_t key, void *data)
int thr_sigsetmask (int how, const sigset_t *nsm, sigset_t *osm)
int thr_suspend (ACE_hthread_t target_thread)
void thr_testcancel (void)
void thr_yield (void)
void unique_name (const void *object, char *name, size_t length)
ACE_NAMESPACE_INLINE_FUNCTION int access (const char *path, int amode)
ACE_NAMESPACE_INLINE_FUNCTION int access (const wchar_t *path, int amode)
unsigned int alarm (u_int secs)
long allocation_granularity (void)
int argv_to_string (int argc, ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args=true, bool quote_args=false)
 used by ARGV::argv_to_string() and ACE_OS::fork_exec()
int argv_to_string (ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args=true, bool quote_args=false)
int chdir (const char *path)
int chdir (const wchar_t *path)
int rmdir (const char *path)
int rmdir (const wchar_t *path)
int close (ACE_HANDLE handle)
ACE_HANDLE dup (ACE_HANDLE handle)
ACE_HANDLE dup (ACE_HANDLE handle, pid_t pid)
int dup2 (ACE_HANDLE oldfd, ACE_HANDLE newfd)
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 execve (const char *path, char *const argv[], char *const envp[])
int execvp (const char *file, char *const argv[])
int fsync (ACE_HANDLE handle)
int ftruncate (ACE_HANDLE handle, ACE_OFF_T offset)
char * getcwd (char *, size_t)
wchar_tgetcwd (wchar_t *, size_t)
gid_t getgid (void)
gid_t getegid (void)
int getopt (int argc, char *const *argv, const char *optstring)
long getpagesize (void)
pid_t getpgid (pid_t pid)
pid_t getpid (void)
pid_t getppid (void)
uid_t getuid (void)
uid_t geteuid (void)
int hostname (char name[], size_t maxnamelen)
int hostname (wchar_t name[], size_t maxnamelen)
int isatty (int handle)
int isatty (ACE_HANDLE handle)
ACE_OFF_T lseek (ACE_HANDLE handle, ACE_OFF_T offset, int whence)
long num_processors (void)
 Get the number of CPUs configured in the machine.
long num_processors_online (void)
 Get the number of CPUs currently online.
int pipe (ACE_HANDLE handles[])
ssize_t pread (ACE_HANDLE handle, void *buf, size_t nbyte, ACE_OFF_T offset)
ssize_t pwrite (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OFF_T offset)
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)
ssize_t readlink (const char *path, char *buf, size_t bufsiz)
void * sbrk (intptr_t brk)
int setgid (gid_t)
int setegid (gid_t)
int setpgid (pid_t pid, pid_t pgid)
int setregid (gid_t rgid, gid_t egid)
int setreuid (uid_t ruid, uid_t euid)
pid_t setsid (void)
int setuid (uid_t)
int seteuid (uid_t)
int sleep (u_int seconds)
int sleep (const ACE_Time_Value &tv)
int string_to_argv (ACE_TCHAR *buf, int &argc, ACE_TCHAR **&argv, bool substitute_env_args=true)
void swab (const void *src, void *dest, ssize_t n)
long sysconf (int)
long sysinfo (int cmd, char *buf, long count)
int truncate (const ACE_TCHAR *filename, ACE_OFF_T length)
useconds_t ualarm (useconds_t usecs, useconds_t interval=0)
useconds_t ualarm (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval=ACE_Time_Value::zero)
int unlink (const char *path)
int unlink (const wchar_t *path)
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)
ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
fgetwc (FILE *fp)
u_int wslen (const WChar *)
WCharwscpy (WChar *, const WChar *)
int wscmp (const WChar *, const WChar *)
int wsncmp (const WChar *, const WChar *, size_t len)
wint_t ungetwc (wint_t c, FILE *fp)
int t_accept (ACE_HANDLE fildes, ACE_HANDLE resfd, struct t_call *call)
char * t_alloc (ACE_HANDLE fildes, int struct_type, int fields)
int t_bind (ACE_HANDLE fildes, ACE_TBIND *req, ACE_TBIND *ret)
int t_close (ACE_HANDLE fildes)
int t_connect (ACE_HANDLE fildes, struct t_call *sndcall, struct t_call *rcvcall)
void t_error (const char *errmsg)
int t_free (char *ptr, int struct_type)
int t_getinfo (ACE_HANDLE fildes, struct t_info *info)
int t_getname (ACE_HANDLE fildes, struct netbuf *namep, int type)
int t_getstate (ACE_HANDLE fildes)
int t_listen (ACE_HANDLE fildes, struct t_call *call)
int t_look (ACE_HANDLE fildes)
ACE_HANDLE t_open (char *path, int oflag, struct t_info *info)
int t_optmgmt (ACE_HANDLE handle, ACE_TOPTMGMT *req, ACE_TOPTMGMT *ret)
int t_rcv (ACE_HANDLE fildes, char *buf, unsigned int nbytes, int *flags)
int t_rcvdis (ACE_HANDLE fildes, struct t_discon *discon)
int t_rcvrel (ACE_HANDLE fildes)
int t_rcvudata (ACE_HANDLE fildes, struct t_unitdata *unitdata, int *flags)
int t_rcvuderr (ACE_HANDLE fildes, struct t_uderr *uderr)
int t_snd (ACE_HANDLE fildes, const char *buf, unsigned int nbytes, int flags)
int t_snddis (ACE_HANDLE fildes, struct t_call *call)
int t_sndrel (ACE_HANDLE fildes)
int t_sync (ACE_HANDLE fildes)
int t_unbind (ACE_HANDLE fildes)
Functions from <cctype>

Included are the functions defined in <cctype> and their <cwctype> equivalents.

Since they are often implemented as macros, we don't use the same name here. Instead, we change by prepending "ace_".



int ace_isalnum (ACE_TCHAR c)
 Returns true if the character is an alphanumeric character.
int ace_isalpha (ACE_TCHAR c)
 Returns true if the character is an alphabetic character.
int ace_isblank (ACE_TCHAR c)
 Returns true if the character is a control character.
int ace_isascii (ACE_TCHAR c)
 Returns true if the character is a control character.
int ace_iscntrl (ACE_TCHAR c)
 Returns true if the character is a control character.
int ace_isdigit (ACE_TCHAR c)
 Returns true if the character is a decimal-digit character.
int ace_isgraph (ACE_TCHAR c)
 Returns true if the character is a printable character other than a space.
int ace_islower (ACE_TCHAR c)
 Returns true if the character is a lowercase character.
int ace_isprint (ACE_TCHAR c)
 Returns true if the character is a printable character.
int ace_ispunct (ACE_TCHAR c)
 Returns true if the character is a punctuation character.
int ace_isspace (ACE_TCHAR c)
 Returns true if the character is a space character.
int ace_isupper (ACE_TCHAR c)
 Returns true if the character is an uppercase character.
int ace_isxdigit (ACE_TCHAR c)
 Returns true if the character is a hexadecimal-digit character.
int ace_tolower (int c)
 Converts a character to lower case (char version).
wint_t ace_towlower (wint_t c)
 Converts a character to lower case (wchar_t version).
int ace_toupper (int c)
 Converts a character to upper case (char version).
wint_t ace_towupper (wint_t c)
 Converts a character to upper case (wchar_t version).
int ace_isctype (int c, ctype_t desc)
 Tests c for the property specified by the desc argument.
int ace_iswctype (wint_t c, wctype_t desc)
 Tests c for the property specified by the desc argument.
Functions from <cstring>

Included are the functions defined in <cstring> and their <cwchar> equivalents.

Todo:
To be complete, we should add strcoll, and strxfrm.


ACE_NAMESPACE_INLINE_FUNCTION
const void * 
memchr (const void *s, int c, size_t len)
 Finds characters in a buffer (const void version).
ACE_NAMESPACE_INLINE_FUNCTION
void * 
memchr (void *s, int c, size_t len)
 Finds characters in a buffer (void version).
ACE_Export const void * memchr_emulation (const void *s, int c, size_t len)
 Emulated memchr - Finds a character in a buffer.
ACE_NAMESPACE_INLINE_FUNCTION int memcmp (const void *t, const void *s, size_t len)
 Compares two buffers.
ACE_NAMESPACE_INLINE_FUNCTION
void * 
memcpy (void *t, const void *s, size_t len)
 Copies one buffer to another.
ACE_Export void * fast_memcpy (void *t, const void *s, size_t len)
 Finds characters in a buffer (const void version).
ACE_NAMESPACE_INLINE_FUNCTION
void * 
memmove (void *t, const void *s, size_t len)
 Moves one buffer to another.
ACE_NAMESPACE_INLINE_FUNCTION
void * 
memset (void *s, int c, size_t len)
 Fills a buffer with a character value.
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strcat (char *s, const char *t)
 Appends a string to another string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strcat (wchar_t *s, const wchar_t *t)
 Appends a string to another string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t
strchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strchr (char *s, int c)
 Finds the first occurrence of a character in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strchr (wchar_t *s, wchar_t c)
 Finds the first occurrence of a character in a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION int strcmp (const char *s, const char *t)
 Compares two strings (char version).
ACE_NAMESPACE_INLINE_FUNCTION int strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
 Compares two strings (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strcpy (char *s, const char *t)
 Copies a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strcpy (wchar_t *s, const wchar_t *t)
 Copies a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strcspn (const char *s, const char *reject)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strcspn (const wchar_t *s, const wchar_t *reject)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strdup (const char *s)
 Returns a malloced duplicated string (char version).
ACE_Export char * strdup_emulation (const char *s)
 Finds characters in a buffer (const void version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strdup (const wchar_t *s)
 Returns a malloced duplicated string (wchar_t version).
ACE_Export wchar_tstrdup_emulation (const wchar_t *s)
 Finds characters in a buffer (const void version).
ACE_Export char * strecpy (char *des, const char *src)
ACE_Export wchar_tstrecpy (wchar_t *s, const wchar_t *t)
ACE_Export char * strerror (int errnum)
ACE_Export char * strerror_emulation (int errnum)
 Emulated strerror - Returns a system error message.
ACE_Export char * strsignal (int signum)
ACE_Export char * strerror_r (int errnum, char *buf, size_t buflen)
 Finds characters in a buffer (const void version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strlen (const char *s)
 Finds the length of a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strlen (const ACE_WCHAR_T *s)
 Finds the length of a string (ACE_WCHAR_T version).
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strncat (char *s, const char *t, size_t len)
 Appends part of a string to another string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Appends part of a string to another string (wchar_t version).
ACE_Export const char * strnchr (const char *s, int c, size_t len)
ACE_Export const ACE_WCHAR_T * strnchr (const ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strnchr (char *s, int c, size_t len)
 Finds the first occurrence of a character in an array (char version).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
 Finds the first occurrence of a character in an array (ACE_WCHAR_T version).
ACE_NAMESPACE_INLINE_FUNCTION int strncmp (const char *s, const char *t, size_t len)
 Compares two arrays (char version).
ACE_NAMESPACE_INLINE_FUNCTION int strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Compares two arrays (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strncpy (char *s, const char *t, size_t len)
 Copies an array (char version).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Copies an array (ACE_WCHAR_T version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strnlen (const char *s, size_t maxlen)
 Finds the length of a limited-length string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strnlen (const ACE_WCHAR_T *s, size_t maxlen)
 Finds the length of a limited-length string (ACE_WCHAR_T version).
ACE_Export const char * strnstr (const char *s, const char *t, size_t len)
ACE_Export const ACE_WCHAR_T * strnstr (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strnstr (char *s, const char *t, size_t len)
 Finds the first occurrence of a substring in an array (char version).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Finds the first occurrence of a substring in an array (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strpbrk (const char *s1, const char *s2)
 Searches for characters in a string (const char version).
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t
strpbrk (const wchar_t *s1, const wchar_t *s2)
 Searches for characters in a string (const wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strpbrk (char *s1, const char *s2)
 Searches for characters in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strpbrk (wchar_t *s1, const wchar_t *s2)
 Searches for characters in a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strrchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t
strrchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strrchr (char *s, int c)
 Finds the last occurrence of a character in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strrchr (wchar_t *s, wchar_t c)
 Finds the last occurrence of a character in a string (wchar_t version).
ACE_Export char * strrchr_emulation (char *s, int c)
ACE_Export const char * strrchr_emulation (const char *s, int c)
ACE_Export char * strsncpy (char *dst, const char *src, size_t maxlen)
 This is a "safe" c string copy function (char version).
ACE_Export ACE_WCHAR_T * strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen)
 This is a "safe" c string copy function (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const char *s1, const char *s2)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const wchar_t *s1, const wchar_t *s2)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strstr (const char *s, const char *t)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t
strstr (const wchar_t *s, const wchar_t *t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strstr (char *s, const char *t)
 Finds the first occurrence of a substring in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strstr (wchar_t *s, const wchar_t *t)
 Finds the first occurrence of a substring in a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strtok (char *s, const char *tokens)
 Finds the next token in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t
strtok (wchar_t *s, const wchar_t *tokens)
 Finds the next token in a string (wchar_t version).

Variables

ACE_TEXT_OSVERSIONINFO win32_versioninfo_
HINSTANCE win32_resource_module_
int socket_initialized_
 Keeps track of whether we've already initialized WinSock...

Non-standard functions

These functions aren't in the standard.



ACE_EXIT_HOOK exit_hook_ = 0
 Function that is called by <ACE_OS::exit>, if non-null.
void _exit (int status=0)
 Function that is called by <ACE_OS::exit>, if non-null.
void abort (void)
 Function that is called by <ACE_OS::exit>, if non-null.
int atexit (ACE_EXIT_HOOK func, const char *name=0)
int atoi (const char *s)
 Function that is called by <ACE_OS::exit>, if non-null.
int atoi (const wchar_t *s)
 Function that is called by <ACE_OS::exit>, if non-null.
long atol (const char *s)
 Function that is called by <ACE_OS::exit>, if non-null.
long atol (const wchar_t *s)
 Function that is called by <ACE_OS::exit>, if non-null.
double atof (const char *s)
 Function that is called by <ACE_OS::exit>, if non-null.
double atof (const wchar_t *s)
 Function that is called by <ACE_OS::exit>, if non-null.
void * atop (const char *s)
 Function that is called by <ACE_OS::exit>, if non-null.
void * atop (const wchar_t *s)
 Function that is called by <ACE_OS::exit>, if non-null.
void * bsearch (const void *key, const void *base, size_t nel, size_t size, ACE_COMPARE_FUNC)
 Function that is called by <ACE_OS::exit>, if non-null.
void * calloc (size_t elements, size_t sizeof_elements)
 Function that is called by <ACE_OS::exit>, if non-null.
void exit (int status=0)
 Function that is called by <ACE_OS::exit>, if non-null.
void free (void *)
 Function that is called by <ACE_OS::exit>, if non-null.
char * getenv (const char *symbol)
 Function that is called by <ACE_OS::exit>, if non-null.
wchar_tgetenv (const wchar_t *symbol)
 Function that is called by <ACE_OS::exit>, if non-null.
ACE_TCHARgetenvstrings (void)
 Function that is called by <ACE_OS::exit>, if non-null.
char * itoa (int value, char *string, int radix)
 Converts an integer to a string.
wchar_titoa (int value, wchar_t *string, int radix)
 Converts an integer to a string.
char * itoa_emulation (int value, char *string, int radix)
 Emulated itoa - Converts an integer to a string.
void * malloc (size_t)
 Function that is called by <ACE_OS::exit>, if non-null.
ACE_HANDLE mkstemp (char *s)
 Function that is called by <ACE_OS::exit>, if non-null.
ACE_HANDLE mkstemp (wchar_t *s)
 Function that is called by <ACE_OS::exit>, if non-null.
char * mktemp (char *s)
 Function that is called by <ACE_OS::exit>, if non-null.
wchar_tmktemp (wchar_t *s)
 Function that is called by <ACE_OS::exit>, if non-null.
int putenv (const char *string)
 Function that is called by <ACE_OS::exit>, if non-null.
int putenv (const wchar_t *string)
 Function that is called by <ACE_OS::exit>, if non-null.
void qsort (void *base, size_t nel, size_t width, ACE_COMPARE_FUNC)
 Function that is called by <ACE_OS::exit>, if non-null.
int setenv (const char *envname, const char *envval, int overwrite)
 Function that is called by <ACE_OS::exit>, if non-null.
int unsetenv (const char *name)
 Function that is called by <ACE_OS::exit>, if non-null.
int rand (void)
 Function that is called by <ACE_OS::exit>, if non-null.
int rand_r (unsigned int *seed)
 Function that is called by <ACE_OS::exit>, if non-null.
void * realloc (void *, size_t)
 Function that is called by <ACE_OS::exit>, if non-null.
char * realpath (const char *file_name, char *resolved_name)
 Function that is called by <ACE_OS::exit>, if non-null.
wchar_trealpath (const wchar_t *file_name, wchar_t *resolved_name)
 Function that is called by <ACE_OS::exit>, if non-null.
ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook)
 For use by ACE_Object_Manager only, to register its exit hook..
void srand (u_int seed)
 Function that is called by <ACE_OS::exit>, if non-null.
ACE_TCHARstrenvdup (const ACE_TCHAR *str)
 Function that is called by <ACE_OS::exit>, if non-null.
double strtod (const char *s, char **endptr)
 Converts a string to a double value (char version).
double strtod (const wchar_t *s, wchar_t **endptr)
 Converts a string to a double value (wchar_t version).
long strtol (const char *s, char **ptr, int base)
 Converts a string to a long value (char version).
long strtol (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to a long value (wchar_t version).
unsigned long strtoul (const char *s, char **ptr, int base)
 Converts a string to an unsigned long value (char version).
unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to an unsigned long value (wchar_t version).
ACE_INT64 strtoll (const char *s, char **ptr, int base)
 Converts a string to a signed 64 bit int value (char version).
ACE_INT64 strtoll (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to a signed 64 bit int value (wchar_t version).
ACE_UINT64 strtoull (const char *s, char **ptr, int base)
 Converts a string to a unsigned 64 bit int value (char version).
ACE_UINT64 strtoull (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to a unsigned 64 bit int value (wchar_t version).
int system (const ACE_TCHAR *s)
 Function that is called by <ACE_OS::exit>, if non-null.
const char * getprogname ()
const char * getprogname_emulation ()
 Function that is called by <ACE_OS::exit>, if non-null.
void setprogname (const char *name)
void setprogname_emulation (const char *name)
 Function that is called by <ACE_OS::exit>, if non-null.



ACE_thread_t NULL_thread
ACE_hthread_t NULL_hthread
ACE_thread_key_t NULL_key
ACE_NAMESPACE_INLINE_FUNCTION int dlclose (ACE_SHLIB_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
dlerror (void)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_SHLIB_HANDLE 
dlopen (const ACE_TCHAR *filename, int mode=ACE_DEFAULT_SHLIB_MODE)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
dlsym (ACE_SHLIB_HANDLE handle, const ACE_TCHAR *symbol)
ACE_NAMESPACE_INLINE_FUNCTION void endpwent (void)
ACE_NAMESPACE_INLINE_FUNCTION
struct passwd * 
getpwent (void)
ACE_NAMESPACE_INLINE_FUNCTION
struct passwd * 
getpwnam (const char *user)
ACE_NAMESPACE_INLINE_FUNCTION int getpwnam_r (const char *name, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
ACE_NAMESPACE_INLINE_FUNCTION void setpwent (void)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
compile (const char *instring, char *expbuf, char *endbuf)
ACE_NAMESPACE_INLINE_FUNCTION int step (const char *str, char *expbuf)
int kill (pid_t pid, int signum)
int pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp)
int sigaction (int signum, const ACE_SIGACTION *nsa, ACE_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 sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
int sigsuspend (const sigset_t *s)
int raise (const int signum)
char * cuserid (char *user, size_t maxlen=ACE_MAX_USERID)
wchar_tcuserid (wchar_t *user, size_t maxlen=ACE_MAX_USERID)
void flock_adjust_params (ace_flock_t *lock, short whence, ACE_OFF_T &start, ACE_OFF_T &len)
int flock_init (ace_flock_t *lock, int flags=0, const ACE_TCHAR *name=0, mode_t perms=0)
int flock_destroy (ace_flock_t *lock, int unlink_file=1)
int flock_rdlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
int flock_tryrdlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
int flock_trywrlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
int flock_unlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
int flock_wrlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
ACE_NAMESPACE_INLINE_FUNCTION int madvise (caddr_t addr, size_t len, int map_advice)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
mmap (void *addr, size_t len, int prot, int flags, ACE_HANDLE handle, ACE_OFF_T off=0, ACE_HANDLE *file_mapping=0, LPSECURITY_ATTRIBUTES sa=0, const ACE_TCHAR *file_mapping_name=0)
ACE_NAMESPACE_INLINE_FUNCTION int mprotect (void *addr, size_t len, int prot)
ACE_NAMESPACE_INLINE_FUNCTION int msync (void *addr, size_t len, int sync)
ACE_NAMESPACE_INLINE_FUNCTION int munmap (void *addr, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION int msgctl (int msqid, int cmd, struct msqid_ds *)
ACE_NAMESPACE_INLINE_FUNCTION int msgget (key_t key, int msgflg)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
msgrcv (int int_id, void *buf, size_t len, long type, int flags)
ACE_NAMESPACE_INLINE_FUNCTION int msgsnd (int int_id, const void *buf, size_t len, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
shmat (int int_id, const void *shmaddr, int shmflg)
ACE_NAMESPACE_INLINE_FUNCTION int shmctl (int int_id, int cmd, struct shmid_ds *buf)
ACE_NAMESPACE_INLINE_FUNCTION int shmdt (const void *shmaddr)
ACE_NAMESPACE_INLINE_FUNCTION int shmget (key_t key, size_t size, int flags)
ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style accept (no QoS).
ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen, const ACE_Accept_QoS_Params &qos_params)
int bind (ACE_HANDLE s, struct sockaddr *name, int namelen)
 BSD-style accept (no QoS).
int closesocket (ACE_HANDLE s)
 Takes care of windows specific requirement to call closesocket.
int connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
 BSD-style connect (no QoS).
int connect (ACE_HANDLE handle, const sockaddr *addr, int addrlen, const ACE_QoS_Params &qos_params)
int enum_protocols (int *protocols, ACE_Protocol_Info *protocol_buffer, u_long *buffer_length)
int getpeername (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style accept (no QoS).
int getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style accept (no QoS).
int getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen)
 BSD-style accept (no QoS).
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.
int listen (ACE_HANDLE handle, int backlog)
 BSD-style accept (no QoS).
ssize_t recv (ACE_HANDLE handle, char *buf, size_t len, int flags=0)
 BSD-style accept (no QoS).
ssize_t recvfrom (ACE_HANDLE handle, char *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen)
 BSD-style accept (no QoS).
ssize_t 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).
ssize_t recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags)
 BSD-style accept (no QoS).
ssize_t recvv (ACE_HANDLE handle, iovec *iov, int iovlen)
 BSD-style accept (no QoS).
ssize_t send (ACE_HANDLE handle, const char *buf, size_t len, int flags=0)
 BSD-style accept (no QoS).
ssize_t send_partial_i (ACE_HANDLE handle, const char *buf, size_t len, int flags)
ssize_t sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
 BSD-style accept (no QoS).
ssize_t sendto (ACE_HANDLE handle, const char *buf, size_t len, int flags, const struct sockaddr *addr, int addrlen)
 BSD-style accept (no QoS).
ssize_t 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).
ssize_t sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt)
 BSD-style accept (no QoS).
ssize_t sendv_partial_i (ACE_HANDLE handle, const iovec *iov, int iovcnt)
int setsockopt (ACE_HANDLE handle, int level, int optname, const char *optval, int optlen)
 Manipulate the options associated with a socket.
int shutdown (ACE_HANDLE handle, int how)
 BSD-style accept (no QoS).
int socket_init (int version_high=1, int version_low=1)
int socket_fini (void)
 Finalize WinSock after last use (e.g., when a DLL is unloaded).
ACE_HANDLE socket (int protocol_family, int type, int proto)
 Create a BSD-style socket (no QoS).
ACE_HANDLE socket (int protocol_family, int type, int proto, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags)
int socketpair (int domain, int type, int protocol, ACE_HANDLE sv[2])
 BSD-style accept (no QoS).
ACE_OFF_T filesize (ACE_HANDLE handle)
ACE_OFF_T filesize (const ACE_TCHAR *handle)
int condattr_init (ACE_condattr_t &attributes, int type=ACE_DEFAULT_SYNCH_TYPE)
int condattr_synctype (ACE_condattr_t &attributes, int &type)
int condattr_destroy (ACE_condattr_t &attributes)
int condattr_setclock (ACE_condattr_t &attributes, clockid_t clock_id)
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 *timeout)
int cond_wait (ACE_cond_t *cv, ACE_mutex_t *m)
int event_destroy (ACE_event_t *event)
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 type, ACE_condattr_t *attributes, int manual_reset=0, int initial_state=0, 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_init (ACE_event_t *event, int type, ACE_condattr_t *attributes, int manual_reset, int initial_state, const wchar_t *name, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
int event_pulse (ACE_event_t *event)
int event_reset (ACE_event_t *event)
int event_signal (ACE_event_t *event)
int event_timedwait (ACE_event_t *event, ACE_Time_Value *timeout, int use_absolute_time=1)
int event_wait (ACE_event_t *event)
int mutex_destroy (ACE_mutex_t *m)
int mutex_init (ACE_mutex_t *m, int lock_scope=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0, int lock_type=0)
int mutex_init (ACE_mutex_t *m, int lock_scope, const wchar_t *name, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0, int lock_type=0)
int mutex_lock (ACE_mutex_t *m)
int mutex_lock (ACE_mutex_t *m, int &abandoned)
int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value &timeout)
int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value *timeout)
void mutex_lock_cleanup (void *mutex)
 Handle asynchronous thread cancellation cleanup.
int mutex_trylock (ACE_mutex_t *m)
int mutex_trylock (ACE_mutex_t *m, int &abandoned)
int mutex_unlock (ACE_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)
int recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m)
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_lock (ACE_recursive_thread_mutex_t *m)
int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value &timeout)
int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value *timeout)
int recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m)
int recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m)
int rw_rdlock (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)
int rw_wrlock (ACE_rwlock_t *rw)
int rwlock_destroy (ACE_rwlock_t *rw)
int rwlock_init (ACE_rwlock_t *rw, int type=ACE_DEFAULT_SYNCH_TYPE, const ACE_TCHAR *name=0, void *arg=0)
int sched_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)
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, ACE_condattr_t *attributes, 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_init (ACE_sema_t *s, u_int count, int type, ACE_condattr_t *attributes, const wchar_t *name, void *arg=0, int max=0x7fffffff, LPSECURITY_ATTRIBUTES sa=0)
void sema_avoid_unlink (ACE_sema_t *s, bool avoid_unlink)
int sema_unlink (const char *name)
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)
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)
int thread_mutex_destroy (ACE_thread_mutex_t *m)
int thread_mutex_init (ACE_thread_mutex_t *m, int lock_type=0, const char *name=0, ACE_mutexattr_t *arg=0)
int thread_mutex_init (ACE_thread_mutex_t *m, int lock_type, const wchar_t *name, ACE_mutexattr_t *arg=0)
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)
char * asctime (const struct tm *tm)
char * asctime_r (const struct tm *tm, char *buf, int buflen)
int clock_gettime (clockid_t, struct timespec *)
int clock_settime (clockid_t, const struct timespec *)
ACE_TCHARctime (const time_t *t)
ACE_TCHARctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
double difftime (time_t t1, time_t t0)
ACE_hrtime_t gethrtime (const ACE_HRTimer_Op=ACE_HRTIMER_GETTIME)
struct tmgmtime (const time_t *clock)
struct tmgmtime_r (const time_t *clock, struct tm *res)
struct tmlocaltime (const time_t *clock)
struct tmlocaltime_r (const time_t *clock, struct tm *res)
time_t mktime (struct tm *timeptr)
int nanosleep (const struct timespec *requested, struct timespec *remaining=0)
size_t strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr) ACE_GCC_FORMAT_ATTRIBUTE(strftime
size_t char * strptime (const char *buf, const char *format, struct tm *tm)
time_t time (time_t *tloc=0)
long timezone (void)
void tzset (void)
pid_t fork (void)
pid_t fork (const ACE_TCHAR *program_name)
pid_t fork_exec (ACE_TCHAR *argv[])

Detailed Description

This namespace 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 is a wrapper for the XTI/TLI operations.

This namespace 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.


Typedef Documentation

typedef ACE_WCHAR_T ACE_OS::WChar

Definition at line 43 of file OS_NS_wchar.h.


Enumeration Type Documentation

Enumerator:
ACE_HRTIMER_START 
ACE_HRTIMER_INCR 
ACE_HRTIMER_STOP 
ACE_HRTIMER_GETTIME 

Definition at line 188 of file OS_NS_time.h.

00189     {
00190       ACE_HRTIMER_START = 0x0,  // Only use these if you can stand
00191       ACE_HRTIMER_INCR = 0x1,   // for interrupts to be disabled during
00192       ACE_HRTIMER_STOP = 0x2,   // the timed interval!!!!
00193       ACE_HRTIMER_GETTIME = 0xFFFF
00194     };


Function Documentation

void ACE_OS::_exit ( int  status = 0  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 23 of file OS_NS_stdlib.inl.

00024 {
00025   ACE_OS_TRACE ("ACE_OS::_exit");
00026 #if defined (ACE_VXWORKS)
00027   ::exit (status);
00028 #elif defined (ACE_HAS_WINCE)
00029   ::TerminateProcess (::GetCurrentProcess (), status);
00030 #elif !defined (ACE_LACKS__EXIT)
00031    ::_exit (status);
00032 #else
00033   ACE_UNUSED_ARG (status);
00034 
00035 #endif /* ACE_VXWORKS */
00036 }

void ACE_OS::abort ( void   )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 39 of file OS_NS_stdlib.inl.

00040 {
00041 #if defined (ACE_ANDROID) && (__ANDROID_API__ < 19)
00042   ACE_OS::_exit (128 + SIGABRT);
00043 #elif !defined (ACE_LACKS_ABORT)
00044   ::abort ();
00045 #elif !defined (ACE_LACKS_EXIT)
00046   exit (1);
00047 #endif /* !ACE_LACKS_ABORT */
00048 }

ACE_HANDLE ACE_OS::accept ( ACE_HANDLE  handle,
struct sockaddr addr,
int *  addrlen,
const ACE_Accept_QoS_Params qos_params 
)

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 16 of file OS_NS_sys_socket.cpp.

00020 {
00021 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00022   ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle,
00023                                     addr,
00024                                     (ACE_SOCKET_LEN *) addrlen,
00025                                     (LPCONDITIONPROC) qos_params.qos_condition_callback (),
00026                                     qos_params.callback_data ()),
00027                        ACE_HANDLE,
00028                        ACE_INVALID_HANDLE);
00029 # else
00030   ACE_UNUSED_ARG (qos_params);
00031   return ACE_OS::accept (handle,
00032                          addr,
00033                          addrlen);
00034 # endif /* ACE_HAS_WINSOCK2 */
00035 }

ACE_HANDLE ACE_OS::accept ( ACE_HANDLE  handle,
struct sockaddr addr,
int *  addrlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 26 of file OS_NS_sys_socket.inl.

00029 {
00030   ACE_OS_TRACE ("ACE_OS::accept");
00031   // On a non-blocking socket with no connections to accept, this
00032   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00033   // platform.  UNIX 98 allows either errno, and they may be the same
00034   // numeric value.  So to make life easier for upper ACE layers as
00035   // well as application programmers, always change EAGAIN to
00036   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00037   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00038   // this function needs to be reviewed.  On Win32, the regular macros
00039   // can be used, as this is not an issue.
00040 
00041 #if defined (ACE_LACKS_ACCEPT)
00042   ACE_UNUSED_ARG (handle);
00043   ACE_UNUSED_ARG (addr);
00044   ACE_UNUSED_ARG (addrlen);
00045   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00046 #elif defined (ACE_WIN32)
00047   ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle,
00048                                  addr,
00049                                  (ACE_SOCKET_LEN *) addrlen),
00050                        ACE_HANDLE,
00051                        ACE_INVALID_HANDLE);
00052 #else
00053 #  if defined (ACE_HAS_BROKEN_ACCEPT_ADDR)
00054   // Apparently some platforms like VxWorks can't correctly deal with
00055   // a NULL addr.
00056 
00057 #    if defined (ACE_HAS_IPV6)
00058    sockaddr_in6 fake_addr;
00059 #    else
00060    sockaddr_in fake_addr;
00061 #    endif /* ACE_HAS_IPV6 */
00062    int fake_addrlen;
00063 
00064    if (addrlen == 0)
00065      addrlen = &fake_addrlen;
00066 
00067    if (addr == 0)
00068      {
00069        addr = (sockaddr *) &fake_addr;
00070        *addrlen = sizeof fake_addr;
00071      }
00072 #  endif /* ACE_HAS_BROKEN_ACCEPT_ADDR */
00073   ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle,
00074                                     addr,
00075                                     (ACE_SOCKET_LEN *) addrlen);
00076 
00077 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00078   // Optimize this code out if we can detect that EAGAIN ==
00079   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00080   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00081   // macros) perform the check at run-time.  The goal is to avoid two
00082   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00083   if (ace_result == ACE_INVALID_HANDLE
00084 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00085       && EAGAIN != EWOULDBLOCK
00086 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00087       && errno == EAGAIN)
00088     {
00089       errno = EWOULDBLOCK;
00090     }
00091 # endif /* EAGAIN != EWOULDBLOCK*/
00092 
00093   return ace_result;
00094 
00095 #endif /* defined (ACE_WIN32) */
00096 }

int ACE_OS::access ( const wchar_t path,
int  amode 
)

Definition at line 70 of file OS_NS_unistd.inl.

00071 {
00072 #if defined (ACE_WIN32) && !defined (ACE_LACKS__WACCESS)
00073   ACE_OSCALL_RETURN (::_waccess (path, amode), int, -1);
00074 #else /* ACE_WIN32 && !ACE_HAS_WINCE */
00075   return ACE_OS::access (ACE_Wide_To_Ascii (path).char_rep (), amode);
00076 #endif /* ACE_WIN32 && !ACE_LACKS__WACCESS */
00077 }

int ACE_OS::access ( const char *  path,
int  amode 
)

Definition at line 34 of file OS_NS_unistd.inl.

00035 {
00036   ACE_OS_TRACE ("ACE_OS::access");
00037 #if defined (ACE_LACKS_ACCESS)
00038 #  if defined (ACE_HAS_ACCESS_EMULATION)
00039   // @@ WINCE: There should be a Win32 API that can do this.
00040   // Hard coded read access here.
00041   ACE_UNUSED_ARG (amode);
00042   FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path),
00043                                 ACE_TEXT ("r"));
00044   if (handle != 0)
00045     {
00046       ACE_OS::fclose (handle);
00047       return 0;
00048     }
00049   return -1;
00050 #  else
00051     ACE_UNUSED_ARG (path);
00052     ACE_UNUSED_ARG (amode);
00053     ACE_NOTSUP_RETURN (-1);
00054 #  endif  /* ACE_HAS_ACCESS_EMULATION */
00055 #elif defined(ACE_WIN32)
00056   // Windows doesn't support checking X_OK(6)
00057 #  if defined (ACE_ACCESS_EQUIVALENT)
00058      ACE_OSCALL_RETURN (ACE_ACCESS_EQUIVALENT (path, amode & 6), int, -1);
00059 #  else
00060      ACE_OSCALL_RETURN (::access (path, amode & 6), int, -1);
00061 #  endif
00062 #else
00063   ACE_OSCALL_RETURN (::access (path, amode), int, -1);
00064 #endif /* ACE_LACKS_ACCESS */
00065 }

int ACE_OS::ace_isalnum ( ACE_TCHAR  c  )  [inline]

Returns true if the character is an alphanumeric character.

Definition at line 13 of file OS_NS_ctype.inl.

00014 {
00015 #if defined (ACE_USES_WCHAR)
00016 # if defined (_MSC_VER)
00017   // For MSVC 7.x, we need to prevent "illegal" character getting into
00018   // isalnum, otherwise, it will crash the program.
00019   return c > 0 && c < 0xFF && iswalnum (c);
00020 # else
00021   return iswalnum (c);
00022 # endif /* _MSC_VER */
00023 #else /* ACE_USES_WCHAR */
00024   return isalnum ((unsigned char) c);
00025 #endif /* ACE_USES_WCHAR */
00026 }

int ACE_OS::ace_isalpha ( ACE_TCHAR  c  )  [inline]

Returns true if the character is an alphabetic character.

Definition at line 74 of file OS_NS_ctype.inl.

00075 {
00076 #if defined (ACE_USES_WCHAR)
00077   return iswalpha (c);
00078 #else /* ACE_USES_WCHAR */
00079   return isalpha ((unsigned char) c);
00080 #endif /* ACE_USES_WCHAR */
00081 }

int ACE_OS::ace_isascii ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a control character.

Definition at line 29 of file OS_NS_ctype.inl.

00030 {
00031 #if defined (ACE_USES_WCHAR)
00032 # if defined (ACE_LACKS_ISWASCII)
00033   if (c < 256)
00034 #  if defined (ACE_LACKS_ISASCII)
00035   return (static_cast<unsigned char>(c) <= 0x7F);
00036 #  else
00037   return isascii ((unsigned char) c);
00038 #  endif /* ACE_LACKS_ISASCII */
00039   else
00040     return c;
00041 # else
00042   return iswascii (c);
00043 # endif
00044 #else /* ACE_USES_WCHAR */
00045 # if defined (ACE_LACKS_ISASCII)
00046   return (static_cast<unsigned char>(c) <= 0x7F);
00047 #else
00048   return isascii ((unsigned char) c);
00049 #endif /* ACE_LACKS_ISASCII */
00050 #endif /* ACE_USES_WCHAR */
00051 }

int ACE_OS::ace_isblank ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a control character.

Definition at line 54 of file OS_NS_ctype.inl.

00055 {
00056 #if defined (ACE_USES_WCHAR)
00057 # if defined (ACE_LACKS_ISWBLANK)
00058 #  if !defined (ACE_LACKS_ISWCTYPE)
00059   return ace_iswctype (c, _BLANK);
00060 #  else
00061   return (c == 0x9) || (c == 0x20);
00062 #  endif /* !ACE_LACKS_ISWCTYPE */
00063 # else
00064    return iswblank (c);
00065 # endif /* ACE_LACKS_ISWBLANK */
00066 #elif defined (ACE_LACKS_ISBLANK)
00067   return (c == 0x9) || (c == 0x20);
00068 #else /* ACE_USES_WCHAR */
00069   return isblank ((unsigned char) c);
00070 #endif /* ACE_USES_WCHAR */
00071 }

int ACE_OS::ace_iscntrl ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a control character.

Definition at line 84 of file OS_NS_ctype.inl.

00085 {
00086 #if defined (ACE_USES_WCHAR)
00087   return iswcntrl (c);
00088 #else /* ACE_USES_WCHAR */
00089   return iscntrl ((unsigned char) c);
00090 #endif /* ACE_USES_WCHAR */
00091 }

int ACE_OS::ace_isctype ( int  c,
ctype_t  desc 
) [inline]

Tests c for the property specified by the desc argument.

Definition at line 219 of file OS_NS_ctype.inl.

00220 {
00221 #if defined (ACE_ISCTYPE_EQUIVALENT)
00222   return ACE_ISCTYPE_EQUIVALENT (c, desc);
00223 #elif !defined (ACE_LACKS_ISCTYPE)
00224   return isctype (c, desc);
00225 #else
00226   ACE_UNUSED_ARG (c);
00227   ACE_UNUSED_ARG (desc);
00228   ACE_NOTSUP_RETURN (-1);
00229 #endif
00230 }

int ACE_OS::ace_isdigit ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a decimal-digit character.

Definition at line 94 of file OS_NS_ctype.inl.

00095 {
00096 #if defined (ACE_USES_WCHAR)
00097   return iswdigit (c);
00098 #else /* ACE_USES_WCHAR */
00099   return isdigit ((unsigned char) c);
00100 #endif /* ACE_USES_WCHAR */
00101 }

int ACE_OS::ace_isgraph ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a printable character other than a space.

Definition at line 104 of file OS_NS_ctype.inl.

00105 {
00106 #if defined (ACE_USES_WCHAR)
00107   return iswgraph (c);
00108 #else /* ACE_USES_WCHAR */
00109   return isgraph ((unsigned char) c);
00110 #endif /* ACE_USES_WCHAR */
00111 }

int ACE_OS::ace_islower ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a lowercase character.

Definition at line 114 of file OS_NS_ctype.inl.

00115 {
00116 #if defined (ACE_USES_WCHAR)
00117   return iswlower (c);
00118 #else /* ACE_USES_WCHAR */
00119   return islower ((unsigned char) c);
00120 #endif /* ACE_USES_WCHAR */
00121 }

int ACE_OS::ace_isprint ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a printable character.

Definition at line 124 of file OS_NS_ctype.inl.

00125 {
00126 #if defined (ACE_USES_WCHAR)
00127 # if defined (ACE_LACKS_CORRECT_ISWPRINT_TAB)
00128   /* The MS CRT has the bug that for tab (\t) iswprint returns true instead of
00129    * false.  This has been reported to Microsoft:
00130    * https://connect.microsoft.com/VisualStudio/feedback ID# 381915
00131    */
00132   if (c == 0x9)
00133     {
00134       return 0;
00135     }
00136 # endif
00137   return iswprint (c);
00138 #else /* ACE_USES_WCHAR */
00139   return isprint ((unsigned char) c);
00140 #endif /* ACE_USES_WCHAR */
00141 }

int ACE_OS::ace_ispunct ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a punctuation character.

Definition at line 144 of file OS_NS_ctype.inl.

00145 {
00146 #if defined (ACE_USES_WCHAR)
00147   return iswpunct (c);
00148 #else /* ACE_USES_WCHAR */
00149   return ispunct ((unsigned char) c);
00150 #endif /* ACE_USES_WCHAR */
00151 }

int ACE_OS::ace_isspace ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a space character.

Definition at line 154 of file OS_NS_ctype.inl.

00155 {
00156 #if defined (ACE_USES_WCHAR)
00157   return iswspace (c);
00158 #else /* ACE_USES_WCHAR */
00159   return isspace ((unsigned char) c);
00160 #endif /* ACE_USES_WCHAR */
00161 }

int ACE_OS::ace_isupper ( ACE_TCHAR  c  )  [inline]

Returns true if the character is an uppercase character.

Definition at line 164 of file OS_NS_ctype.inl.

00165 {
00166 #if defined (ACE_USES_WCHAR)
00167   return iswupper (c);
00168 #else /* ACE_USES_WCHAR */
00169   return isupper ((unsigned char) c);
00170 #endif /* ACE_USES_WCHAR */
00171 }

int ACE_OS::ace_iswctype ( wint_t  c,
wctype_t  desc 
) [inline]

Tests c for the property specified by the desc argument.

Definition at line 10 of file OS_NS_wctype.inl.

00011 {
00012 #if !defined (ACE_LACKS_ISWCTYPE)
00013   return iswctype (c, desc);
00014 #else
00015   ACE_UNUSED_ARG (c);
00016   ACE_UNUSED_ARG (desc);
00017   ACE_NOTSUP_RETURN (-1);
00018 #endif
00019 }

int ACE_OS::ace_isxdigit ( ACE_TCHAR  c  )  [inline]

Returns true if the character is a hexadecimal-digit character.

Definition at line 174 of file OS_NS_ctype.inl.

00175 {
00176 #if defined (ACE_USES_WCHAR)
00177   return iswxdigit (c);
00178 #else /* ACE_USES_WCHAR */
00179   return isxdigit ((unsigned char) c);
00180 #endif /* ACE_USES_WCHAR */
00181 }

int ACE_OS::ace_tolower ( int  c  )  [inline]

Converts a character to lower case (char version).

Definition at line 184 of file OS_NS_ctype.inl.

00185 {
00186   return tolower (c);
00187 }

int ACE_OS::ace_toupper ( int  c  )  [inline]

Converts a character to upper case (char version).

Definition at line 205 of file OS_NS_ctype.inl.

00206 {
00207   return toupper (c);
00208 }

wint_t ACE_OS::ace_towlower ( wint_t  c  )  [inline]

Converts a character to lower case (wchar_t version).

Definition at line 191 of file OS_NS_ctype.inl.

00192 {
00193 #if defined (ACE_LACKS_TOWLOWER)
00194   if (c < 256)
00195     return tolower (static_cast<int> (c));
00196   else
00197     return c;
00198 #else
00199   return towlower (c);
00200 #endif /* ACE_LACKS_TOWLOWER */
00201 }

wint_t ACE_OS::ace_towupper ( wint_t  c  )  [inline]

Converts a character to upper case (wchar_t version).

Definition at line 212 of file OS_NS_ctype.inl.

00213 {
00214   return towupper (c);
00215 }

u_int ACE_OS::alarm ( u_int  secs  )  [inline]

Definition at line 81 of file OS_NS_unistd.inl.

00082 {
00083   ACE_OS_TRACE ("ACE_OS::alarm");
00084 #if defined (ACE_LACKS_ALARM)
00085   ACE_UNUSED_ARG (secs);
00086   ACE_NOTSUP_RETURN (0);
00087 #else
00088   return ::alarm (secs);
00089 #endif /* ACE_LACKS_ALARM */
00090 }

long ACE_OS::allocation_granularity ( void   )  [inline]

Definition at line 111 of file OS_NS_unistd.inl.

00112 {
00113 #if defined (ACE_WIN32)
00114   SYSTEM_INFO sys_info;
00115   ::GetSystemInfo (&sys_info);
00116   return sys_info.dwAllocationGranularity;
00117 #else
00118   return ACE_OS::getpagesize ();
00119 #endif /* ACE_WIN32 */
00120 }

int ACE_OS::alphasort ( const void *  a,
const void *  b 
) [inline]

Definition at line 139 of file OS_NS_dirent.inl.

00140 {
00141 #if defined (ACE_LACKS_ALPHASORT)
00142   return ACE_OS::strcmp ((*static_cast<const struct ACE_DIRENT * const *>(a))->d_name,
00143                           (*static_cast<const struct ACE_DIRENT * const *>(b))->d_name);
00144 #else
00145 #  if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
00146   return ::alphasort (const_cast<void *>(a),
00147                       const_cast<void *>(b));
00148 #  elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
00149   return ::alphasort (a, b);
00150 #  else
00151   return ::alphasort ((const struct ACE_DIRENT **)a,
00152                       (const struct ACE_DIRENT **)b);
00153 #  endif
00154 #endif
00155 }

int ACE_OS::argv_to_string ( ACE_TCHAR **  argv,
ACE_TCHAR *&  buf,
bool  substitute_env_args = true,
bool  quote_args = false 
)

Definition at line 26 of file OS_NS_unistd.cpp.

00030 {
00031   if (argv == 0 || argv[0] == 0)
00032     return 0;
00033 
00034   int argc;
00035   for (argc = 0; argv[argc] != 0; ++argc)
00036     continue;
00037 
00038   return argv_to_string (argc,
00039                          argv,
00040                          buf,
00041                          substitute_env_args,
00042                          quote_args);
00043 }

int ACE_OS::argv_to_string ( int  argc,
ACE_TCHAR **  argv,
ACE_TCHAR *&  buf,
bool  substitute_env_args = true,
bool  quote_args = false 
)

used by ARGV::argv_to_string() and ACE_OS::fork_exec()

Definition at line 46 of file OS_NS_unistd.cpp.

00051 {
00052 #if defined (ACE_LACKS_STRENVDUP)
00053   ACE_UNUSED_ARG (substitute_env_args);
00054 #endif /* ACE_LACKS_STRENVDUP */
00055 
00056   if (argc <= 0 || argv == 0 || argv[0] == 0)
00057     return 0;
00058 
00059   size_t buf_len = 0;
00060 
00061   // Determine the length of the buffer.
00062 
00063   ACE_TCHAR **argv_p = argv;
00064 
00065   for (int i = 0; i < argc; ++i)
00066     {
00067 #if !defined (ACE_LACKS_STRENVDUP)
00068       // Account for environment variables.
00069       if (substitute_env_args
00070           && ACE_OS::strchr (argv[i], ACE_TEXT ('$')) != 0)
00071         {
00072           if (argv_p == argv)
00073             {
00074 #if defined (ACE_HAS_ALLOC_HOOKS)
00075               argv_p = (ACE_TCHAR **) ACE_Allocator::instance()->malloc (argc * sizeof (ACE_TCHAR *));
00076 #else
00077               argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
00078 #endif /* ACE_HAS_ALLOC_HOOKS */
00079               if (argv_p == 0)
00080                 {
00081                   errno = ENOMEM;
00082                   return 0;
00083                 }
00084               ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *));
00085             }
00086           argv_p[i] = ACE_OS::strenvdup (argv[i]);
00087           if (argv_p[i] == 0)
00088             {
00089 #if defined (ACE_HAS_ALLOC_HOOKS)
00090               ACE_Allocator::instance()->free (argv_p);
00091 #else
00092               ACE_OS::free (argv_p);
00093 #endif /* ACE_HAS_ALLOC_HOOKS */
00094               errno = ENOMEM;
00095               return 0;
00096             }
00097         }
00098 #endif /* ACE_LACKS_STRENVDUP */
00099       // If must quote, we only do it if the arg contains spaces, or
00100       // is empty. Perhaps a check for other c | ord(c) <= 32 is in
00101       // order?
00102       if (quote_args
00103           && (ACE_OS::strchr (argv_p[i], ACE_TEXT (' ')) != 0
00104               || ACE_OS::strchr (argv_p[i], ACE_TEXT ('\t')) != 0
00105               || ACE_OS::strchr (argv_p[i], ACE_TEXT ('\n')) != 0
00106               || *argv_p[i] == 0))
00107         {
00108           if (argv_p == argv)
00109             {
00110 #if defined (ACE_HAS_ALLOC_HOOKS)
00111               argv_p = (ACE_TCHAR **) ACE_Allocator::instance()->malloc (argc * sizeof (ACE_TCHAR *));
00112 #else
00113               argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
00114 #endif /* ACE_HAS_ALLOC_HOOKS */
00115               if (argv_p == 0)
00116                 {
00117                   errno = ENOMEM;
00118                   return 0;
00119                 }
00120               ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *));
00121             }
00122           int quotes = 0;
00123           ACE_TCHAR *temp = argv_p[i];
00124           if (ACE_OS::strchr (temp, ACE_TEXT ('"')) != 0)
00125             {
00126               for (int j = 0; temp[j] != 0; ++j)
00127                 if (temp[j] == ACE_TEXT ('"'))
00128                   ++quotes;
00129             }
00130           argv_p[i] =
00131 #if defined (ACE_HAS_ALLOC_HOOKS)
00132             (ACE_TCHAR *) ACE_Allocator::instance()->malloc ((ACE_OS::strlen (temp) + quotes + 3)
00133                                                              * sizeof (ACE_TCHAR));
00134 #else
00135             (ACE_TCHAR *) ACE_OS::malloc ((ACE_OS::strlen (temp) + quotes + 3)
00136                                           * sizeof (ACE_TCHAR));
00137 #endif /* ACE_HAS_ALLOC_HOOKS */
00138           if (argv_p[i] == 0)
00139             {
00140 #if defined (ACE_HAS_ALLOC_HOOKS)
00141               ACE_Allocator::instance()->free (argv_p);
00142 #else
00143               ACE_OS::free (argv_p);
00144 #endif /* ACE_HAS_ALLOC_HOOKS */
00145               errno = ENOMEM;
00146               return 0;
00147             }
00148           ACE_TCHAR *end = argv_p[i];
00149 
00150           *end++ = ACE_TEXT ('"');
00151 
00152           if (quotes > 0)
00153             {
00154               for (ACE_TCHAR *p = temp;
00155                    *p != 0;
00156                    *end++ = *p++)
00157                 if (*p == ACE_TEXT ('"'))
00158                   *end++ = ACE_TEXT ('\\');
00159 
00160               *end++ = ACE_TEXT ('\0');
00161             }
00162           else
00163             end = ACE_OS::strecpy (end, temp);
00164 
00165           end[-1] = ACE_TEXT ('"');
00166 
00167           *end = ACE_TEXT ('\0');
00168           if (temp != argv[i])
00169 #if defined (ACE_HAS_ALLOC_HOOKS)
00170             ACE_Allocator::instance()->free (temp);
00171 #else
00172             ACE_OS::free (temp);
00173 #endif /* ACE_HAS_ALLOC_HOOKS */
00174         }
00175       buf_len += ACE_OS::strlen (argv_p[i]);
00176 
00177       // Add one for the extra space between each string.
00178       buf_len++;
00179     }
00180 
00181   // Step through all argv params and copy each one into buf; separate
00182   // each param with white space.
00183 
00184 #if defined (ACE_HAS_ALLOC_HOOKS)
00185   ACE_ALLOCATOR_RETURN (buf,
00186                         static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (buf_len + 1))),
00187                         0);
00188 #else
00189   ACE_NEW_RETURN (buf,
00190                   ACE_TCHAR[buf_len + 1],
00191                   0);
00192 #endif /* ACE_HAS_ALLOC_HOOKS */
00193 
00194   // Initial null charater to make it a null string.
00195   buf[0] = ACE_TEXT ('\0');
00196   ACE_TCHAR *end = buf;
00197 
00198   for (int i = 0; i < argc; ++i)
00199     {
00200       end = ACE_OS::strecpy (end, argv_p[i]);
00201       if (argv_p[i] != argv[i])
00202 #if defined (ACE_HAS_ALLOC_HOOKS)
00203         ACE_Allocator::instance()->free (argv_p[i]);
00204 #else
00205         ACE_OS::free (argv_p[i]);
00206 #endif /* ACE_HAS_ALLOC_HOOKS */
00207 
00208       // Replace the null char that strecpy put there with white
00209       // space.
00210       end[-1] = ACE_TEXT (' ');
00211     }
00212   // Null terminate the string.
00213   *end = ACE_TEXT ('\0');
00214 
00215   if (argv_p != argv)
00216 #if defined (ACE_HAS_ALLOC_HOOKS)
00217     ACE_Allocator::instance()->free (argv_p);
00218 #else
00219     ACE_OS::free (argv_p);
00220 #endif /* ACE_HAS_ALLOC_HOOKS */
00221 
00222   // The number of arguments.
00223   return argc;
00224 }

char * ACE_OS::asctime ( const struct tm tm  )  [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 11 of file OS_NS_time.inl.

00012 {
00013   ACE_OS_TRACE ("ACE_OS::asctime");
00014 #if defined (ACE_LACKS_ASCTIME)
00015   ACE_UNUSED_ARG (t);
00016   ACE_NOTSUP_RETURN (0);
00017 #else
00018   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::asctime (t), char *, 0);
00019 #endif /* ACE_LACKS_ASCTIME */
00020 }

char * ACE_OS::asctime_r ( const struct tm tm,
char *  buf,
int  buflen 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 23 of file OS_NS_time.inl.

00024 {
00025   ACE_OS_TRACE ("ACE_OS::asctime_r");
00026 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00027 # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
00028   char *result = 0;
00029   ace_asctime_r_helper (t, buf);
00030   ACE_OS::strsncpy (buf, result, buflen);
00031   return buf;
00032 # else
00033 #   if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R)
00034   ACE_OSCALL_RETURN (::asctime_r (t, buf, reinterpret_cast<size_t*>(&buflen)), char *, 0);
00035 #   else
00036   ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0);
00037 #   endif /* ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R */
00038 # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
00039 #elif defined (ACE_HAS_TR24731_2005_CRT)
00040   char *result = buf;
00041   ACE_SECURECRTCALL (asctime_s (buf, static_cast<size_t> (buflen), t), \
00042                      char*, 0, result);
00043   return result;
00044 #elif defined (ACE_LACKS_ASCTIME)
00045   ACE_UNUSED_ARG (t);
00046   ACE_UNUSED_ARG (buf);
00047   ACE_UNUSED_ARG (buflen);
00048   ACE_NOTSUP_RETURN (0);
00049 #else
00050   char *result = 0;
00051   ACE_OSCALL (ACE_STD_NAMESPACE::asctime (t), char *, 0, result);
00052   ACE_OS::strsncpy (buf, result, buflen);
00053   return buf;
00054 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00055 }

int ACE_OS::asprintf ( wchar_t **  bufp,
const wchar_t format,
  ... 
)

Definition at line 315 of file OS_NS_stdio.cpp.

00316 {
00317   // ACE_OS_TRACE ("ACE_OS::asprintf");
00318 #if defined (ACE_LACKS_VA_FUNCTIONS)
00319   ACE_UNUSED_ARG (bufp);
00320   ACE_UNUSED_ARG (format);
00321   ACE_NOTSUP_RETURN (-1);
00322 #else
00323   va_list ap;
00324   va_start (ap, format);
00325   int const result = ACE_OS::vasprintf (bufp, format, ap);
00326   va_end (ap);
00327   return result;
00328 #endif /* ACE_LACKS_VA_FUNCTIONS */
00329 }

int ACE_OS::asprintf ( char **  bufp,
const char *  format,
  ... 
)

Definition at line 297 of file OS_NS_stdio.cpp.

00298 {
00299   // ACE_OS_TRACE ("ACE_OS::asprintf");
00300 #if defined (ACE_LACKS_VA_FUNCTIONS)
00301   ACE_UNUSED_ARG (bufp);
00302   ACE_UNUSED_ARG (format);
00303   ACE_NOTSUP_RETURN (-1);
00304 #else
00305   va_list ap;
00306   va_start (ap, format);
00307   int const result = ACE_OS::vasprintf (bufp, format, ap);
00308   va_end (ap);
00309   return result;
00310 #endif /* ACE_LACKS_VA_FUNCTIONS */
00311 }

int ACE_OS::atexit ( ACE_EXIT_HOOK  func,
const char *  name = 0 
) [inline]

Register an at exit hook. The name can be used to analyze shutdown problems

Definition at line 51 of file OS_NS_stdlib.inl.

00052 {
00053   return ACE_OS_Object_Manager::instance ()->at_exit (func, name);
00054 }

double ACE_OS::atof ( const wchar_t s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 100 of file OS_NS_stdlib.inl.

00101 {
00102 #if !defined (ACE_HAS_WTOF)
00103   return ACE_OS::atof (ACE_Wide_To_Ascii (s).char_rep ());
00104 #elif defined (ACE_WTOF_EQUIVALENT)
00105   ACE_OSCALL_RETURN (ACE_WTOF_EQUIVALENT (s), double, -1);
00106 #else /* ACE_HAS__WTOF */
00107   ACE_OSCALL_RETURN (::wtof (s), double, -1);
00108 #endif /* ACE_HAS_WTOF */
00109 }

double ACE_OS::atof ( const char *  s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 93 of file OS_NS_stdlib.inl.

00094 {
00095   ACE_OSCALL_RETURN (::atof (s), double, -1);
00096 }

int ACE_OS::atoi ( const wchar_t s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 64 of file OS_NS_stdlib.inl.

00065 {
00066 #if defined (ACE_WIN32) && defined (ACE_HAS_WTOI)
00067   ACE_OSCALL_RETURN (::_wtoi (s), int, -1);
00068 #else /* ACE_WIN32 */
00069   return ACE_OS::atoi (ACE_Wide_To_Ascii (s).char_rep ());
00070 #endif /* ACE_WIN32 */
00071 }

int ACE_OS::atoi ( const char *  s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 57 of file OS_NS_stdlib.inl.

00058 {
00059   ACE_OSCALL_RETURN (::atoi (s), int, -1);
00060 }

long ACE_OS::atol ( const wchar_t s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 82 of file OS_NS_stdlib.inl.

00083 {
00084 #if defined (ACE_WIN32) && defined (ACE_HAS_WTOL)
00085   ACE_OSCALL_RETURN (::_wtol (s), long, -1);
00086 #else /* ACE_WIN32 */
00087   return ACE_OS::atol (ACE_Wide_To_Ascii (s).char_rep ());
00088 #endif /* ACE_WIN32 */
00089 }

long ACE_OS::atol ( const char *  s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 75 of file OS_NS_stdlib.inl.

00076 {
00077   ACE_OSCALL_RETURN (::atol (s), long, -1);
00078 }

void * ACE_OS::atop ( const wchar_t s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 133 of file OS_NS_stdlib.inl.

00134 {
00135 #  if defined (ACE_WIN64)
00136   intptr_t ip = ::_wtoi64 (s);
00137 #  elif defined (ACE_OPENVMS)
00138 #    if !defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)
00139   int ip = ACE_OS::atoi (s);
00140 #    else
00141   intptr_t ip = ACE_OS::atoi (s);
00142 #    endif
00143 #  else
00144   intptr_t ip = ACE_OS::atoi (s);
00145 #  endif /* ACE_WIN64 */
00146   void * p = reinterpret_cast<void *> (ip);
00147   return p;
00148 }

void * ACE_OS::atop ( const char *  s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 113 of file OS_NS_stdlib.inl.

00114 {
00115   ACE_TRACE ("ACE_OS::atop");
00116 #if defined (ACE_WIN64)
00117   intptr_t ip = ::_atoi64 (s);
00118 #elif defined (ACE_OPENVMS)
00119 #  if !defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)
00120   int ip = ::atoi (s);
00121 #  else
00122   intptr_t ip = ::atoi (s);
00123 #  endif
00124 #else
00125   intptr_t ip = ::atoi (s);
00126 #endif /* ACE_WIN64 */
00127   void * p = reinterpret_cast<void *> (ip);
00128   return p;
00129 }

int ACE_OS::bind ( ACE_HANDLE  s,
struct sockaddr name,
int  namelen 
) [inline]

BSD-style accept (no QoS).

Definition at line 99 of file OS_NS_sys_socket.inl.

00100 {
00101   ACE_OS_TRACE ("ACE_OS::bind");
00102 #if defined (ACE_LACKS_BIND)
00103   ACE_UNUSED_ARG (handle);
00104   ACE_UNUSED_ARG (addr);
00105   ACE_UNUSED_ARG (addrlen);
00106   ACE_NOTSUP_RETURN (-1);
00107 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x640)
00108   // VxWorks clears the sin_port member after a successful bind when
00109   // sin_addr != INADDR_ANY, so after the bind we do retrieve the
00110   // original address so that user code can safely check the addr
00111   // after the bind. See bugzilla 3107 for more details
00112   int result;
00113   ACE_SOCKCALL (::bind ((ACE_SOCKET) handle,
00114                         addr,
00115                         (ACE_SOCKET_LEN) addrlen), int, -1, result);
00116   if (result == -1)
00117     return -1;
00118   else
00119     return ACE_OS::getsockname (handle, addr, &addrlen);
00120 #else
00121   ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle,
00122                                addr,
00123                                (ACE_SOCKET_LEN) addrlen), int, -1);
00124 #endif
00125 }

void * ACE_OS::bsearch ( const void *  key,
const void *  base,
size_t  nel,
size_t  size,
ACE_COMPARE_FUNC  compar 
) [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 152 of file OS_NS_stdlib.inl.

00157 {
00158 #if !defined (ACE_LACKS_BSEARCH)
00159   return ::bsearch (key, base, nel, size, compar);
00160 #else
00161   ACE_UNUSED_ARG (key);
00162   ACE_UNUSED_ARG (base);
00163   ACE_UNUSED_ARG (nel);
00164   ACE_UNUSED_ARG (size);
00165   ACE_UNUSED_ARG (compar);
00166   ACE_NOTSUP_RETURN (0);
00167 #endif /* ACE_LACKS_BSEARCH */
00168 }

void * ACE_OS::calloc ( size_t  elements,
size_t  sizeof_elements 
)

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 38 of file OS_NS_stdlib.cpp.

00039 {
00040 #if !defined (ACE_HAS_WINCE)
00041   return ACE_CALLOC_FUNC (elements, sizeof_elements);
00042 #else
00043   // @@ This will probably not work since it doesn't consider
00044   // alignment properly.
00045   return ACE_MALLOC_FUNC (elements * sizeof_elements);
00046 #endif /* ACE_HAS_WINCE */
00047 }

template<typename T >
T ACE_OS::ceil ( x  )  [inline]

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

Definition at line 108 of file OS_NS_math.h.

00109   {
00110     return ACE_STD_NAMESPACE::ceil (x);
00111   }

int ACE_OS::chdir ( const wchar_t path  )  [inline]

Definition at line 140 of file OS_NS_unistd.inl.

00141 {
00142 #if defined (ACE_LACKS_CHDIR)
00143   ACE_UNUSED_ARG (path);
00144   ACE_NOTSUP_RETURN (-1);
00145 #elif defined (ACE_WIN32)
00146   ACE_OSCALL_RETURN (::_wchdir (path), int, -1);
00147 #else /* ACE_WIN32 */
00148   return ACE_OS::chdir (ACE_Wide_To_Ascii (path).char_rep ());
00149 #endif /* ACE_WIN32 */
00150 }

int ACE_OS::chdir ( const char *  path  )  [inline]

Definition at line 123 of file OS_NS_unistd.inl.

00124 {
00125   ACE_OS_TRACE ("ACE_OS::chdir");
00126 #if defined (ACE_LACKS_CHDIR)
00127   ACE_UNUSED_ARG (path);
00128   ACE_NOTSUP_RETURN (-1);
00129 #elif defined (ACE_HAS_NONCONST_CHDIR)
00130   ACE_OSCALL_RETURN (::chdir (const_cast<char *> (path)), int, -1);
00131 #elif defined (ACE_CHDIR_EQUIVALENT)
00132   ACE_OSCALL_RETURN (ACE_CHDIR_EQUIVALENT (path), int, -1);
00133 #else
00134   ACE_OSCALL_RETURN (::chdir (path), int, -1);
00135 #endif /* ACE_HAS_NONCONST_CHDIR */
00136 }

void ACE_OS::cleanup_tss ( const u_int  main_thread  ) 

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 1074 of file OS_NS_Thread.cpp.

01075 {
01076 #if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
01077   { // scope the cleanup instance
01078     // Call TSS destructors for current thread.
01079     TSS_Cleanup_Instance cleanup;
01080     if (cleanup.valid ())
01081       {
01082         cleanup->thread_exit ();
01083       }
01084   }
01085 #endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */
01086 
01087   if (main_thread)
01088     {
01089 #if !defined (ACE_HAS_TSS_EMULATION)  &&  !defined (ACE_HAS_MINIMAL_ACE_OS)
01090       // Just close the ACE_Log_Msg for the current (which should be
01091       // main) thread.  We don't have TSS emulation; if there's native
01092       // TSS, it should call its destructors when the main thread
01093       // exits.
01094       ACE_Base_Thread_Adapter::close_log_msg ();
01095 #endif /* ! ACE_HAS_TSS_EMULATION  &&  ! ACE_HAS_MINIMAL_ACE_OS */
01096 
01097 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
01098       // Finally, free up the ACE_TSS_Cleanup instance.  This method gets
01099       // called by the ACE_Object_Manager.
01100       TSS_Cleanup_Instance cleanup(TSS_Cleanup_Instance::DESTROY);
01101       if (cleanup.valid ())
01102       {
01103         ; // the pointer deletes the Cleanup when it goes out of scope
01104       }
01105 
01106 #endif /* WIN32 || ACE_HAS_TSS_EMULATION */
01107 
01108 #if defined (ACE_HAS_TSS_EMULATION)
01109       ACE_TSS_Emulation::tss_close ();
01110 #endif /* ACE_HAS_TSS_EMULATION */
01111     }
01112 }

void ACE_OS::clearerr ( FILE *  fp  )  [inline]

Definition at line 349 of file OS_NS_stdio.inl.

00350 {
00351   ace_clearerr_helper (fp);
00352 }

int ACE_OS::clock_gettime ( clockid_t  clockid,
struct timespec ts 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 58 of file OS_NS_time.inl.

00059 {
00060   ACE_OS_TRACE ("ACE_OS::clock_gettime");
00061 #if defined (ACE_HAS_CLOCK_GETTIME)
00062   ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1);
00063 #else
00064   ACE_UNUSED_ARG (clockid);
00065   ACE_UNUSED_ARG (ts);
00066   ACE_NOTSUP_RETURN (-1);
00067 #endif /* ACE_HAS_CLOCK_GETTIME */
00068 }

int ACE_OS::clock_settime ( clockid_t  clockid,
const struct timespec ts 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 71 of file OS_NS_time.inl.

00072 {
00073 #if defined (ACE_HAS_CLOCK_SETTIME)
00074 #  if defined (ACE_HAS_NONCONST_CLOCK_SETTIME)
00075   ACE_OSCALL_RETURN (::clock_settime (clockid, const_cast<struct timespec *>(ts)), int, -1);
00076 #  else
00077   ACE_OSCALL_RETURN (::clock_settime (clockid, ts), int, -1);
00078 #  endif /* ACE_HAS_NONCONST_CLOCK_SETTIME */
00079 #else
00080   ACE_UNUSED_ARG (clockid);
00081   ACE_UNUSED_ARG (ts);
00082   ACE_NOTSUP_RETURN (-1);
00083 #endif /* ACE_HAS_CLOCK_SETTIME */
00084 }

int ACE_OS::close ( ACE_HANDLE  handle  )  [inline]

Definition at line 189 of file OS_NS_unistd.inl.

00190 {
00191   ACE_OS_TRACE ("ACE_OS::close");
00192 #if defined (ACE_WIN32)
00193   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1);
00194 #else
00195   ACE_OSCALL_RETURN (::close (handle), int, -1);
00196 #endif /* ACE_WIN32 */
00197 }

void ACE_OS::closedir ( ACE_DIR d  )  [inline]

Definition at line 14 of file OS_NS_dirent.inl.

00015 {
00016 #if defined (ACE_HAS_DIRENT)
00017 # if defined (ACE_WIN32) && defined (ACE_LACKS_CLOSEDIR)
00018   ACE_OS::closedir_emulation (d);
00019   delete [] d->directory_name_;
00020   delete d;
00021 # elif defined (ACE_HAS_WCLOSEDIR) && defined (ACE_USES_WCHAR)
00022   ::wclosedir (d);
00023 # else /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */
00024   ::closedir (d);
00025 # endif /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */
00026 
00027 #else /* ACE_HAS_DIRENT */
00028   ACE_UNUSED_ARG (d);
00029 #endif /* ACE_HAS_DIRENT */
00030 }

int ACE_OS::closesocket ( ACE_HANDLE  s  )  [inline]

Takes care of windows specific requirement to call closesocket.

Definition at line 128 of file OS_NS_sys_socket.inl.

00129 {
00130   ACE_OS_TRACE ("ACE_OS::closesocket");
00131 #if defined (ACE_WIN32)
00132   // @note Do not shutdown the write end here.  Doing so will break
00133   //       applications that duplicate a handle on fork(), for
00134   //       example, and expect to continue writing in the fork()ed
00135   //       process.
00136 
00137   ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1);
00138 #else
00139   //FUZZ: disable check_for_lack_ACE_OS
00140   ACE_OSCALL_RETURN (::close (handle), int, -1);
00141   //FUZZ: enable check_for_lack_ACE_OS
00142 #endif /* ACE_WIN32 */
00143 }

char * ACE_OS::compile ( const char *  instring,
char *  expbuf,
char *  endbuf 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 8 of file OS_NS_regex.inl.

00009 {
00010   ACE_OS_TRACE ("ACE_OS::compile");
00011 #if defined (ACE_HAS_REGEX)
00012   ACE_OSCALL_RETURN (::compile (instring, expbuf, endbuf), char *, 0);
00013 #else
00014   ACE_UNUSED_ARG (instring);
00015   ACE_UNUSED_ARG (expbuf);
00016   ACE_UNUSED_ARG (endbuf);
00017 
00018   ACE_NOTSUP_RETURN (0);
00019 #endif /* ACE_HAS_REGEX */
00020 }

int ACE_OS::cond_broadcast ( ACE_cond_t cv  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 255 of file OS_NS_Thread.inl.

00256 {
00257   ACE_OS_TRACE ("ACE_OS::cond_broadcast");
00258 # if defined (ACE_HAS_THREADS)
00259 #   if defined (ACE_HAS_PTHREADS)
00260   int result;
00261   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_broadcast (cv),
00262                                        result),
00263                      int, -1);
00264 #   elif defined (ACE_HAS_STHREADS)
00265   int result;
00266   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv),
00267                                        result),
00268                      int, -1);
00269 #   elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
00270   ::WakeAllConditionVariable  (cv);
00271   return 0;
00272 #   endif /* ACE_HAS_STHREADS */
00273 # else
00274   ACE_UNUSED_ARG (cv);
00275   ACE_NOTSUP_RETURN (-1);
00276 # endif /* ACE_HAS_THREADS */
00277 }

int ACE_OS::cond_destroy ( ACE_cond_t cv  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 280 of file OS_NS_Thread.inl.

00281 {
00282   ACE_OS_TRACE ("ACE_OS::cond_destroy");
00283 # if defined (ACE_HAS_THREADS)
00284 #   if defined (ACE_HAS_PTHREADS)
00285   int result;
00286   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_destroy (cv), result), int, -1);
00287 #   elif defined (ACE_HAS_STHREADS)
00288   int result;
00289   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), result), int, -1);
00290 #   elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
00291   // Windows doesn't have a destroy
00292   return 0;
00293 #   endif /* ACE_HAS_STHREADS */
00294 # else
00295   ACE_UNUSED_ARG (cv);
00296   ACE_NOTSUP_RETURN (-1);
00297 # endif /* ACE_HAS_THREADS */
00298 }

int ACE_OS::cond_init ( ACE_cond_t cv,
ACE_condattr_t attributes,
const wchar_t name,
void *  arg = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 351 of file OS_NS_Thread.inl.

00355 {
00356   return ACE_OS::cond_init (cv, attributes, ACE_Wide_To_Ascii (name).char_rep (), arg);
00357 }

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

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 362 of file OS_NS_Thread.inl.

00363 {
00364   return ACE_OS::cond_init (cv, type, ACE_Wide_To_Ascii (name).char_rep (), arg);
00365 }

int ACE_OS::cond_init ( ACE_cond_t cv,
ACE_condattr_t attributes,
const char *  name = 0,
void *  arg = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 301 of file OS_NS_Thread.inl.

00305 {
00306   // ACE_OS_TRACE ("ACE_OS::cond_init");
00307   ACE_UNUSED_ARG (name);
00308   ACE_UNUSED_ARG (arg);
00309 # if defined (ACE_HAS_THREADS)
00310 #   if defined (ACE_HAS_PTHREADS)
00311   int result = -1;
00312 
00313 #     if defined (ACE_PTHREAD_COND_T_INITIALIZE)
00314   /* VxWorks 6.x API reference states:
00315    *   If the memory for the condition variable object has been allocated
00316    *   dynamically, it is a good policy to always zero out the
00317    *   block of memory so as to avoid spurious EBUSY return code
00318    *   when calling this routine.
00319    */
00320   ACE_OS::memset (cv, 0, sizeof (*cv));
00321 #     endif
00322 
00323   if (ACE_ADAPT_RETVAL (pthread_cond_init (cv, &attributes), result) == 0)
00324      result = 0;
00325   else
00326      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00327 
00328   return result;
00329 #   elif defined (ACE_HAS_STHREADS)
00330   int result;
00331   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv,
00332                                                     attributes.type,
00333                                                     arg),
00334                                        result),
00335                      int, -1);
00336 #   elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
00337     ::InitializeConditionVariable (cv);
00338     return 0;
00339 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00340 # else
00341   ACE_UNUSED_ARG (cv);
00342   ACE_UNUSED_ARG (attributes);
00343   ACE_UNUSED_ARG (name);
00344   ACE_UNUSED_ARG (arg);
00345   ACE_NOTSUP_RETURN (-1);
00346 # endif /* ACE_HAS_THREADS */
00347 }

int ACE_OS::cond_init ( ACE_cond_t cv,
short  type = ACE_DEFAULT_SYNCH_TYPE,
const char *  name = 0,
void *  arg = 0 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1586 of file OS_NS_Thread.cpp.

01587 {
01588   ACE_condattr_t attributes;
01589   if (ACE_OS::condattr_init (attributes, type) == 0
01590       && ACE_OS::cond_init (cv, attributes, name, arg) == 0)
01591     {
01592       (void) ACE_OS::condattr_destroy (attributes);
01593       return 0;
01594     }
01595   return -1;
01596 }

int ACE_OS::cond_signal ( ACE_cond_t cv  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 369 of file OS_NS_Thread.inl.

00370 {
00371   ACE_OS_TRACE ("ACE_OS::cond_signal");
00372 # if defined (ACE_HAS_THREADS)
00373 #   if defined (ACE_HAS_PTHREADS)
00374   int result;
00375   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_signal (cv), result),
00376                      int, -1);
00377 #   elif defined (ACE_HAS_STHREADS)
00378   int result;
00379   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), result), int, -1);
00380 #   elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
00381   ::WakeConditionVariable (cv);
00382   return 0;
00383 #   endif /* ACE_HAS_STHREADS */
00384 # else
00385   ACE_UNUSED_ARG (cv);
00386   ACE_NOTSUP_RETURN (-1);
00387 # endif /* ACE_HAS_THREADS */
00388 }

int ACE_OS::cond_timedwait ( ACE_cond_t cv,
ACE_mutex_t m,
ACE_Time_Value timeout 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 417 of file OS_NS_Thread.inl.

00420 {
00421   ACE_OS_TRACE ("ACE_OS::cond_timedwait");
00422 # if defined (ACE_HAS_THREADS)
00423   int result = 0;
00424   timespec_t ts;
00425 
00426   if (timeout != 0)
00427     ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
00428 
00429 #   if defined (ACE_HAS_PTHREADS)
00430 
00431   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00432                                 ? pthread_cond_wait (cv, external_mutex)
00433                                 : pthread_cond_timedwait (cv, external_mutex,
00434                                                             (ACE_TIMESPEC_PTR) &ts),
00435                                 result),
00436               int, -1, result);
00437   // We need to adjust this to make the POSIX and Solaris return
00438   // values consistent.  EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and down)
00439   if (result == -1 &&
00440       (errno == ETIMEDOUT || errno == EAGAIN))
00441     errno = ETIME;
00442 
00443 #   elif defined (ACE_HAS_STHREADS)
00444   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00445                                 ? ::cond_wait (cv, external_mutex)
00446                                 : ::cond_timedwait (cv,
00447                                                     external_mutex,
00448                                                     (timestruc_t*)&ts),
00449                                 result),
00450               int, -1, result);
00451 #   elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
00452   int msec_timeout = 0;
00453   if (timeout != 0)
00454     {
00455       ACE_Time_Value relative_time = timeout->to_relative_time ();
00456       // Watchout for situations where a context switch has caused the
00457       // current time to be > the timeout.
00458       if (relative_time > ACE_Time_Value::zero)
00459         msec_timeout = relative_time.msec ();
00460     }
00461 
00462   ACE_OSCALL (ACE_ADAPT_RETVAL (::SleepConditionVariableCS (cv, &external_mutex->thr_mutex_, msec_timeout),
00463                                 result),
00464               int, -1, result);
00465 
00466   return result;
00467 #   endif /* ACE_HAS_STHREADS */
00468   if (timeout != 0)
00469     timeout->set (ts); // Update the time value before returning.
00470 
00471   return result;
00472 # else
00473   ACE_UNUSED_ARG (cv);
00474   ACE_UNUSED_ARG (external_mutex);
00475   ACE_UNUSED_ARG (timeout);
00476   ACE_NOTSUP_RETURN (-1);
00477 # endif /* ACE_HAS_THREADS */
00478 }

int ACE_OS::cond_wait ( ACE_cond_t cv,
ACE_mutex_t m 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 391 of file OS_NS_Thread.inl.

00393 {
00394   ACE_OS_TRACE ("ACE_OS::cond_wait");
00395 # if defined (ACE_HAS_THREADS)
00396 #   if defined (ACE_HAS_PTHREADS)
00397   int result;
00398   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_wait (cv, external_mutex), result),
00399                      int, -1);
00400 #   elif defined (ACE_HAS_STHREADS)
00401   int result;
00402   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), result),
00403                      int, -1);
00404 #   elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
00405   int result;
00406   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::SleepConditionVariableCS (cv, &external_mutex->thr_mutex_, INFINITE), result),
00407                      int, -1);
00408 #   endif /* ACE_HAS_PTHREADS */
00409 # else
00410   ACE_UNUSED_ARG (cv);
00411   ACE_UNUSED_ARG (external_mutex);
00412   ACE_NOTSUP_RETURN (-1);
00413 # endif /* ACE_HAS_THREADS */
00414 }

int ACE_OS::condattr_destroy ( ACE_condattr_t attributes  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 123 of file OS_NS_Thread.inl.

00124 {
00125 #if defined (ACE_HAS_THREADS) && !defined (ACE_LACKS_CONDATTR)
00126 #   if defined (ACE_HAS_PTHREADS)
00127   pthread_condattr_destroy (&attributes);
00128 #   else
00129   attributes.type = 0;
00130 #   endif /* ACE_HAS_PTHREADS */
00131   return 0;
00132 # else
00133   ACE_UNUSED_ARG (attributes);
00134   return 0;
00135 # endif /* ACE_HAS_THREADS  */
00136 }

int ACE_OS::condattr_init ( ACE_condattr_t attributes,
int  type = ACE_DEFAULT_SYNCH_TYPE 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 139 of file OS_NS_Thread.inl.

00140 {
00141   ACE_UNUSED_ARG (type);
00142 # if defined (ACE_HAS_THREADS)
00143 #   if defined (ACE_HAS_PTHREADS)
00144   int result = -1;
00145 
00146 #   if !defined (ACE_LACKS_CONDATTR)
00147 #     if defined (ACE_PTHREAD_CONDATTR_T_INITIALIZE)
00148   /* Tests show that VxWorks 6.x pthread lib does not only
00149     * require zeroing of mutex/condition objects to function correctly
00150     * but also of the attribute objects.
00151     */
00152   ACE_OS::memset (&attributes, 0, sizeof (attributes));
00153 #     endif
00154   if (
00155       ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0
00156 #     if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)
00157       && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type),
00158                            result) == 0
00159 #     endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */
00160       )
00161 #   else
00162   if (type == USYNC_THREAD)
00163 #   endif /* !ACE_LACKS_CONDATTR */
00164      result = 0;
00165   else
00166     {
00167       ACE_UNUSED_ARG (attributes);
00168       result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00169     }
00170 
00171   return result;
00172 #   else
00173   attributes.type = type;
00174   return 0;
00175 #   endif /* ACE_HAS_PTHREADS */
00176 
00177 # else
00178   ACE_UNUSED_ARG (attributes);
00179   ACE_UNUSED_ARG (type);
00180   ACE_NOTSUP_RETURN (-1);
00181 # endif /* ACE_HAS_THREADS */
00182 }

int ACE_OS::condattr_setclock ( ACE_condattr_t attributes,
clockid_t  clock_id 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 219 of file OS_NS_Thread.inl.

00220 {
00221 # if defined (ACE_HAS_THREADS)
00222 #   if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_CONDATTR)
00223   int result = -1;
00224 
00225 #   if defined (_POSIX_CLOCK_SELECTION) && !defined (ACE_LACKS_CONDATTR_SETCLOCK)
00226   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_condattr_setclock (&attributes, clock_id),
00227                                        result),
00228                      int, -1);
00229 #   else
00230   ACE_UNUSED_ARG (clock_id);
00231   ACE_UNUSED_ARG (attributes);
00232 #   endif /* _POSIX_CLOCK_SELECTION) && !ACE_LACKS_CONDATTR_SETCLOCK */
00233 
00234   return result;
00235 #   else
00236   ACE_UNUSED_ARG (clock_id);
00237   ACE_UNUSED_ARG (attributes);
00238   ACE_NOTSUP_RETURN (-1);
00239 #   endif /* ACE_HAS_PTHREADS && !ACE_LACKS_CONDATTR */
00240 
00241 # else
00242   ACE_UNUSED_ARG (clock_id);
00243   ACE_UNUSED_ARG (attributes);
00244   ACE_NOTSUP_RETURN (-1);
00245 # endif /* ACE_HAS_THREADS */
00246 }

int ACE_OS::condattr_synctype ( ACE_condattr_t attributes,
int &  type 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 185 of file OS_NS_Thread.inl.

00186 {
00187 # if defined (ACE_HAS_THREADS)
00188 #   if defined (ACE_HAS_PTHREADS)
00189 #   if !defined (ACE_LACKS_CONDATTR) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)
00190   int result = -1;
00191 
00192   if (
00193       ACE_ADAPT_RETVAL (pthread_condattr_getpshared (&attributes, &type),
00194                            result) == 0
00195      )
00196     {
00197       result = 0;
00198     }
00199 #   else
00200   ACE_UNUSED_ARG (attributes);
00201   int result = 0;
00202   type = USYNC_THREAD;
00203 #   endif /* !ACE_LACKS_CONDATTR && _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */
00204 
00205   return result;
00206 #   else
00207   type = attributes.type;
00208   return 0;
00209 #   endif /* ACE_HAS_PTHREADS */
00210 
00211 # else
00212   ACE_UNUSED_ARG (attributes);
00213   ACE_UNUSED_ARG (type);
00214   ACE_NOTSUP_RETURN (-1);
00215 # endif /* ACE_HAS_THREADS */
00216 }

int ACE_OS::connect ( ACE_HANDLE  handle,
const sockaddr addr,
int  addrlen,
const ACE_QoS_Params qos_params 
)

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 38 of file OS_NS_sys_socket.cpp.

00042 {
00043   ACE_OS_TRACE ("ACE_OS::connect");
00044 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00045   ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle,
00046                                      (const sockaddr *) addr,
00047                                      (ACE_SOCKET_LEN) addrlen,
00048                                      (WSABUF *) qos_params.caller_data (),
00049                                      (WSABUF *) qos_params.callee_data (),
00050                                      (QOS *) qos_params.socket_qos (),
00051                                      (QOS *) qos_params.group_socket_qos ()),
00052                        int, -1);
00053 # else
00054   ACE_UNUSED_ARG (qos_params);
00055   return ACE_OS::connect (handle,
00056                           const_cast <sockaddr *> (addr),
00057                           addrlen);
00058 # endif /* ACE_HAS_WINSOCK2 */
00059 }

int ACE_OS::connect ( ACE_HANDLE  handle,
struct sockaddr addr,
int  addrlen 
) [inline]

BSD-style connect (no QoS).

Definition at line 146 of file OS_NS_sys_socket.inl.

00149 {
00150   ACE_OS_TRACE ("ACE_OS::connect");
00151 #if defined (ACE_LACKS_CONNECT)
00152   ACE_UNUSED_ARG (handle);
00153   ACE_UNUSED_ARG (addr);
00154   ACE_UNUSED_ARG (addrlen);
00155   ACE_NOTSUP_RETURN (-1);
00156 #else
00157   ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle,
00158                                   addr,
00159                                   (ACE_SOCKET_LEN) addrlen), int, -1);
00160 #endif /* ACE_LACKS_CONNECT */
00161 }

ACE_HANDLE ACE_OS::creat ( const ACE_TCHAR filename,
mode_t  mode 
) [inline]

Definition at line 13 of file OS_NS_sys_stat.inl.

00014   {
00015     ACE_OS_TRACE ("ACE_OS::creat");
00016 #if defined (ACE_WIN32)
00017     return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode);
00018 #else
00019     ACE_OSCALL_RETURN (::creat (ACE_TEXT_ALWAYS_CHAR (filename), mode),
00020                        ACE_HANDLE, ACE_INVALID_HANDLE);
00021 #endif /* ACE_WIN32 */
00022   }

ACE_TCHAR * ACE_OS::ctime ( const time_t *  t  )  [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 90 of file OS_NS_time.inl.

00091 {
00092   ACE_OS_TRACE ("ACE_OS::ctime");
00093 #if defined (ACE_LACKS_CTIME)
00094   ACE_UNUSED_ARG (t);
00095   ACE_NOTSUP_RETURN (0);
00096 #elif defined (ACE_HAS_WINCE)
00097   static ACE_TCHAR buf [ctime_buf_size];
00098   return ACE_OS::ctime_r (t,
00099                           buf,
00100                           ctime_buf_size);
00101 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00102   ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0);
00103 #else
00104 #  if defined (ACE_USES_WCHAR)   /* Not Win32, else it would do the above */
00105   char *narrow_time;
00106   ACE_OSCALL (::ctime (t), char *, 0, narrow_time);
00107   if (narrow_time == 0)
00108     return 0;
00109   // ACE_Ascii_To_Wide::convert allocates (via new []) a wchar_t[]. If
00110   // we've done this before, free the previous one. Yes, this leaves a
00111   // small memory leak (26 characters) but there's no way around this
00112   // that I know of. (Steve Huston, 12-Feb-2003).
00113   static wchar_t *wide_time = 0;
00114   if (wide_time != 0)
00115     delete [] wide_time;
00116   wide_time = ACE_Ascii_To_Wide::convert (narrow_time);
00117   return wide_time;
00118 #  else
00119   ACE_OSCALL_RETURN (::ctime (t), char *, 0);
00120 #  endif /* ACE_USES_WCHAR */
00121 # endif /* ACE_HAS_WINCE */
00122 }

ACE_TCHAR * ACE_OS::ctime_r ( const time_t *  clock,
ACE_TCHAR buf,
int  buflen 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 126 of file OS_NS_time.inl.

00127 {
00128   ACE_OS_TRACE ("ACE_OS::ctime_r");
00129 
00130 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00131 
00132   char *bufp = 0;
00133 #   if defined (ACE_USES_WCHAR)
00134   char narrow_buf[ctime_buf_size];
00135   bufp = narrow_buf;
00136 #   else
00137   bufp = buf;
00138 #   endif /* ACE_USES_WCHAR */
00139 
00140   if (buflen < ctime_buf_size)
00141     {
00142       errno = ERANGE;
00143       return 0;
00144     }
00145 #   if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
00146   ACE_OSCALL (::ctime_r (t, bufp), char *, 0, bufp);
00147 #   else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
00148 
00149 #      if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R)
00150   bufp = ::ctime_r (t, bufp, reinterpret_cast<size_t*>(&buflen));
00151 #      else /* ACE_CTIME_R_RETURNS_INT */
00152   bufp = ::ctime_r (t, bufp, buflen);
00153 #      endif /* ACE_CTIME_R_RETURNS_INT */
00154 
00155 #   endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
00156 
00157   if (bufp == 0)
00158     return 0;
00159 
00160 #   if defined (ACE_USES_WCHAR)
00161   ACE_Ascii_To_Wide wide_buf (bufp);
00162   ACE_OS_String::strcpy (buf, wide_buf.wchar_rep ());
00163   return buf;
00164 #   else
00165   return bufp;
00166 #   endif /* ACE_USES_WCHAR */
00167 
00168 #elif defined (ACE_HAS_TR24731_2005_CRT)
00169   if (buflen < ctime_buf_size)
00170     {
00171       errno = ERANGE;
00172       return 0;
00173     }
00174   ACE_TCHAR *result = buf;
00175 #  if defined (ACE_USES_WCHAR)
00176   ACE_SECURECRTCALL (_wctime_s (buf, buflen, t), wchar_t *, 0, result);
00177 #  else
00178   ACE_SECURECRTCALL (ctime_s (buf, buflen, t), char *, 0, result);
00179 #  endif
00180   return result;
00181 
00182 #else /* ACE_HAS_REENTRANT_FUNCTIONS */
00183   if (buflen < ctime_buf_size)
00184     {
00185       errno = ERANGE;
00186       return 0;
00187     }
00188 
00189   ACE_TCHAR *result = 0;
00190 #     if defined (ACE_USES_WCHAR)
00191   ACE_OSCALL (::_wctime (t), wchar_t *, 0, result);
00192 #     else /* ACE_USES_WCHAR */
00193   ACE_OSCALL (::ctime (t), char *, 0, result);
00194 #     endif /* ACE_USES_WCHAR */
00195   if (result != 0)
00196     ACE_OS::strsncpy (buf, result, buflen);
00197   return buf;
00198 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00199 }

wchar_t * ACE_OS::cuserid ( wchar_t user,
size_t  maxlen = ACE_MAX_USERID 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 464 of file OS_NS_stdio.inl.

00465 {
00466 # if defined (ACE_HAS_WINCE)
00467   ACE_UNUSED_ARG (user);
00468   ACE_UNUSED_ARG (maxlen);
00469   ACE_NOTSUP_RETURN (0);
00470 # elif defined (ACE_WIN32)
00471   BOOL const result = GetUserNameW (user, (u_long *) &maxlen);
00472   if (result == FALSE)
00473     ACE_FAIL_RETURN (0);
00474   else
00475     return user;
00476 # else /* ACE_WIN32 */
00477   char *char_user;
00478   wchar_t *result = 0;
00479 
00480   ACE_NEW_RETURN (char_user, char[maxlen + 1], 0);
00481 
00482   if (ACE_OS::cuserid (char_user, maxlen))
00483     {
00484       ACE_OS::strcpy (user, ACE_Ascii_To_Wide (char_user).wchar_rep ());
00485       result = user;
00486     }
00487 
00488   delete [] char_user;
00489 
00490   return result;
00491 # endif /* ACE_WIN32 */
00492 }

char * ACE_OS::cuserid ( char *  user,
size_t  maxlen = ACE_MAX_USERID 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 356 of file OS_NS_stdio.inl.

00357 {
00358   ACE_OS_TRACE ("ACE_OS::cuserid");
00359 #if defined (ACE_VXWORKS)
00360   ACE_UNUSED_ARG (maxlen);
00361   if (user == 0)
00362     {
00363       // Require that the user field be non-null, i.e., don't
00364       // allocate or use static storage.
00365       ACE_NOTSUP_RETURN (0);
00366     }
00367   else
00368     {
00369       ::remCurIdGet (user, 0);
00370       return user;
00371     }
00372 #elif defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE)
00373   ACE_UNUSED_ARG (user);
00374   ACE_UNUSED_ARG (maxlen);
00375   ACE_NOTSUP_RETURN (0);
00376 #elif defined (ACE_WIN32)
00377   BOOL const result = GetUserNameA (user, (u_long *) &maxlen);
00378   if (result == FALSE)
00379     ACE_FAIL_RETURN (0);
00380   else
00381     return user;
00382 #elif defined (ACE_HAS_ALT_CUSERID)
00383 #  if defined (ACE_LACKS_PWD_FUNCTIONS)
00384   ACE_UNUSED_ARG (user);
00385   ACE_UNUSED_ARG (maxlen);
00386   ACE_NOTSUP_RETURN (0);
00387   //#    error Cannot use alternate cuserid() without POSIX password functions!
00388 #  endif  /* ACE_LACKS_PWD_FUNCTIONS */
00389 
00390   // POSIX.1 dropped the cuserid() function.
00391   // GNU GLIBC and other platforms correctly deprecate the cuserid()
00392   // function.
00393 
00394   if (maxlen == 0)
00395     {
00396       // It doesn't make sense to have a zero length user ID.
00397       errno = EINVAL;
00398       return 0;
00399     }
00400 
00401   struct passwd *pw = 0;
00402 
00403   // Make sure the file pointer is at the beginning of the password file
00404   ACE_OS::setpwent ();
00405   // Should use ACE_OS::setpwent() but I didn't want to move this
00406   // method after it.
00407 
00408   // Use the effective user ID to determine the user name.
00409   pw = ::getpwuid (ACE_OS::geteuid ());
00410 
00411   // Make sure the password file is closed.
00412   ACE_OS::endpwent ();
00413 
00414   if (pw == 0)
00415     {
00416       errno = ENOENT;
00417       return 0;
00418     }
00419 
00420   size_t max_length = 0;
00421   char *userid = 0;
00422 
00423   if (user == 0)
00424     {
00425       // Not reentrant/thread-safe, but nothing else can be done if a
00426       // zero pointer was passed in as the destination.
00427 
00428 #if defined (_POSIX_SOURCE) && defined (L_cuserid)
00429       const size_t ACE_L_cuserid = L_cuserid;
00430 #else
00431       const size_t ACE_L_cuserid = 9;  // 8 character user ID + NULL
00432 #endif  /* _POSIX_SOURCE */
00433 
00434       static char tmp[ACE_L_cuserid] = { '\0' };
00435       max_length = ACE_L_cuserid - 1; // Do not include NULL in length
00436 
00437       userid = tmp;
00438     }
00439   else
00440     {
00441       max_length = maxlen;
00442       userid = user;
00443     }
00444 
00445   // Extract the user name from the passwd structure.
00446   if (ACE_OS::strlen (pw->pw_name) <= max_length)
00447     {
00448       return ACE_OS::strcpy (userid, pw->pw_name);
00449     }
00450   else
00451     {
00452       errno = ENOSPC;  // Buffer is not large enough.
00453       return 0;
00454     }
00455 #else
00456   // Hackish because of missing buffer size!
00457   ACE_UNUSED_ARG (maxlen);
00458   ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0);
00459 #endif /* ACE_VXWORKS */
00460 }

LPSECURITY_ATTRIBUTES ACE_OS::default_win32_security_attributes ( LPSECURITY_ATTRIBUTES   )  [inline]

Default Win32 Security Attributes definition.

LPSECURITY_ATTRIBUTES ACE_OS::default_win32_security_attributes_r ( LPSECURITY_ATTRIBUTES  ,
LPSECURITY_ATTRIBUTES  ,
SECURITY_DESCRIPTOR *   
) [inline]
double ACE_OS::difftime ( time_t  t1,
time_t  t0 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 246 of file OS_NS_time.inl.

00247 {
00248   return ::ace_difftime (t1, t0);
00249 }

int ACE_OS::dlclose ( ACE_SHLIB_HANDLE  handle  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 23 of file OS_NS_dlfcn.inl.

00024 {
00025   ACE_OS_TRACE ("ACE_OS::dlclose");
00026 #if defined (ACE_LACKS_DLCLOSE)
00027   ACE_UNUSED_ARG (handle);
00028   return 0;
00029 #elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00030 
00031 # if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
00032   // SunOS4 does not automatically call _fini()!
00033   void *ptr;
00034 
00035   ACE_OSCALL (::dlsym (handle, ACE_TEXT ("_fini")), void *, 0, ptr);
00036 
00037   if (ptr != 0)
00038     (*((int (*)(void)) ptr)) (); // Call _fini hook explicitly.
00039 # endif /* ACE_HAS_AUTOMATIC_INIT_FINI */
00040   ACE_OSCALL_RETURN (::dlclose (handle), int, -1);
00041 #elif defined (ACE_WIN32)
00042   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FreeLibrary (handle), ace_result_), int, -1);
00043 #elif defined (__hpux)
00044   // HP-UX 10.x and 32-bit 11.00 do not pay attention to the ref count
00045   // when unloading a dynamic lib.  So, if the ref count is more than
00046   // 1, do not unload the lib.  This will cause a library loaded more
00047   // than once to not be unloaded until the process runs down, but
00048   // that's life.  It's better than unloading a library that's in use.
00049   // So far as I know, there's no way to decrement the refcnt that the
00050   // kernel is looking at - the shl_descriptor is a copy of what the
00051   // kernel has, not the actual struct.  On 64-bit HP-UX using dlopen,
00052   // this problem has been fixed.
00053   struct shl_descriptor  desc;
00054   if (shl_gethandle_r (handle, &desc) == -1)
00055     return -1;
00056   if (desc.ref_count > 1)
00057     return 0;
00058 # if defined(__GNUC__) || __cplusplus >= 199707L
00059   ACE_OSCALL_RETURN (::shl_unload (handle), int, -1);
00060 # else
00061   ACE_OSCALL_RETURN (::cxxshl_unload (handle), int, -1);
00062 # endif  /* aC++ vs. Hp C++ */
00063 #else
00064   ACE_UNUSED_ARG (handle);
00065   ACE_NOTSUP_RETURN (-1);
00066 #endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00067 }

ACE_TCHAR * ACE_OS::dlerror ( void   ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 70 of file OS_NS_dlfcn.inl.

00071 {
00072   ACE_OS_TRACE ("ACE_OS::dlerror");
00073 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00074   const char *err = 0;
00075   ACE_OSCALL (::dlerror (), const char *, 0, err);
00076   if (err == 0)
00077     return 0;
00078 #   if defined (ACE_USES_WCHAR)
00079   const size_t BufLen = 256;
00080   static wchar_t buf[BufLen];
00081   ACE_OS::strncpy (buf, ACE_TEXT_CHAR_TO_TCHAR (err), BufLen);
00082   return buf;
00083 #   else
00084   return const_cast <char *> (err);
00085 #   endif /* ACE_USES_WCHAR */
00086 # elif defined (__hpux) || defined (ACE_VXWORKS)
00087   //FUZZ: disable check_for_lack_ACE_OS
00088   ACE_OSCALL_RETURN (::strerror(errno), char *, 0);
00089   //FUZZ: enable check_for_lack_ACE_OS
00090 # elif defined (ACE_WIN32)
00091   static ACE_TCHAR buf[128];
00092 #   if defined (ACE_HAS_PHARLAP)
00093   ACE_OS::sprintf (buf, "error code %d", GetLastError());
00094 #   else
00095   ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
00096                           0,
00097                           ::GetLastError (),
00098                           0,
00099                           buf,
00100                           sizeof buf / sizeof buf[0],
00101                           0);
00102 #   endif /* ACE_HAS_PHARLAP */
00103   return buf;
00104 # else
00105   ACE_NOTSUP_RETURN (0);
00106 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00107 }

ACE_SHLIB_HANDLE ACE_OS::dlopen ( const ACE_TCHAR filename,
int  mode = ACE_DEFAULT_SHLIB_MODE 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 110 of file OS_NS_dlfcn.inl.

00112 {
00113   ACE_OS_TRACE ("ACE_OS::dlopen");
00114 
00115 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00116   void *handle;
00117 #   if defined (ACE_HAS_SGIDLADD)
00118   ACE_OSCALL
00119     (::sgidladd (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle);
00120 #   else
00121   ACE_OSCALL
00122     (::dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle);
00123 #   endif /* ACE_HAS_SGIDLADD */
00124 #   if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
00125   if (handle != 0)
00126     {
00127       void *ptr;
00128       // Some systems (e.g., SunOS4) do not automatically call _init(), so
00129       // we'll have to call it manually.
00130 
00131       ACE_OSCALL (::dlsym (handle, ACE_TEXT ("_init")), void *, 0, ptr);
00132 
00133       if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly.
00134         {
00135           // Close down the handle to prevent leaks.
00136           ::dlclose (handle);
00137           return 0;
00138         }
00139     }
00140 #   endif /* ACE_HAS_AUTOMATIC_INIT_FINI */
00141   return handle;
00142 # elif defined (ACE_WIN32)
00143   ACE_UNUSED_ARG (mode);
00144 
00145   ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (fname), ACE_SHLIB_HANDLE, 0);
00146 # elif defined (__hpux)
00147 
00148 #   if defined(__GNUC__) || __cplusplus >= 199707L
00149   ACE_OSCALL_RETURN (::shl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0);
00150 #   else
00151   ACE_OSCALL_RETURN (::cxxshl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0);
00152 #   endif  /* aC++ vs. Hp C++ */
00153 # elif defined (ACE_VXWORKS) && !defined (__RTP__)
00154   ACE_UNUSED_ARG (mode);
00155   MODULE* handle = 0;
00156   // Open readonly
00157   ACE_HANDLE filehandle = ACE_OS::open (fname,
00158                                         O_RDONLY,
00159                                         ACE_DEFAULT_FILE_PERMS);
00160 
00161   if (filehandle != ACE_INVALID_HANDLE)
00162     {
00163       ACE_OS::last_error(0);
00164       ACE_OSCALL ( ::loadModule (filehandle, LOAD_GLOBAL_SYMBOLS|LOAD_COMMON_MATCH_ALL ), MODULE *, 0, handle);
00165       int loaderror = ACE_OS::last_error();
00166       ACE_OS::close (filehandle);
00167 
00168       if ( (loaderror != 0) && (handle != 0) )
00169         {
00170           // ouch something went wrong most likely unresolved externals
00171           if (handle)
00172             ::unldByModuleId ( handle, 0 );
00173           handle = 0;
00174         }
00175     }
00176   else
00177     {
00178       // couldn't open file
00179       handle = 0;
00180     }
00181   return handle;
00182 # else
00183   ACE_UNUSED_ARG (fname);
00184   ACE_UNUSED_ARG (mode);
00185   ACE_NOTSUP_RETURN (0);
00186 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00187 }

void * ACE_OS::dlsym ( ACE_SHLIB_HANDLE  handle,
const ACE_TCHAR symbol 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 190 of file OS_NS_dlfcn.inl.

00192 {
00193   ACE_OS_TRACE ("ACE_OS::dlsym");
00194 
00195 #if defined (ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE)
00196   // Check if the handle is valid before making any calls using it.
00197   if (handle == ACE_SHLIB_INVALID_HANDLE)
00198     return 0;
00199 #endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */
00200 
00201   // Get the correct OS type.
00202 #if defined (ACE_HAS_WINCE)
00203   // CE (at least thru Pocket PC 2003) offers GetProcAddressW, not ...A, so
00204   // we always need a wide-char string.
00205   const wchar_t *symbolname = 0;
00206 #  if defined (ACE_USES_WCHAR)
00207   symbolname = sname;
00208 #  else
00209   ACE_Ascii_To_Wide sname_xlate (sname);
00210   symbolname = sname_xlate.wchar_rep ();
00211 #  endif /* ACE_USES_WCHAR */
00212 #elif defined (ACE_USES_WCHAR)
00213   // WinCE is WCHAR always; other platforms need a char * symbol name
00214   ACE_Wide_To_Ascii w_sname (sname);
00215   char *symbolname = w_sname.char_rep ();
00216 #elif defined (ACE_VXWORKS)
00217   char *symbolname = const_cast<char *> (sname);
00218 #else
00219   const char *symbolname = sname;
00220 #endif /* ACE_HAS_WINCE */
00221 
00222 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00223 
00224 #   if defined (ACE_USES_ASM_SYMBOL_IN_DLSYM)
00225   int l = ACE_OS::strlen (symbolname) + 2;
00226   char *asm_symbolname = 0;
00227   ACE_NEW_RETURN (asm_symbolname, char[l], 0);
00228   ACE_OS::strcpy (asm_symbolname, "_") ;
00229   ACE_OS::strcpy (asm_symbolname + 1, symbolname) ;
00230   void *ace_result;
00231   ACE_OSCALL (::dlsym (handle, asm_symbolname), void *, 0, ace_result);
00232   delete [] asm_symbolname;
00233   return ace_result;
00234 #   else
00235   ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0);
00236 #   endif /* ACE_USES_ASM_SYMBOL_IN_DLSYM */
00237 
00238 # elif defined (ACE_WIN32)
00239 
00240   ACE_WIN32CALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0);
00241 
00242 # elif defined (__hpux)
00243 
00244   void *value = 0;
00245   int status;
00246   shl_t _handle = handle;
00247   ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status);
00248   return status == 0 ? value : 0;
00249 
00250 # elif defined (ACE_VXWORKS) && !defined (__RTP__)
00251 
00252   // For now we use the VxWorks global symbol table
00253   // which resolves the most recently loaded symbols, which resolve
00254   // mostly what we want..
00255   ACE_UNUSED_ARG (handle);
00256 #if (ACE_VXWORKS < 0x690)
00257   SYM_TYPE symtype;
00258   char *value = 0;
00259   STATUS status;
00260   ACE_OSCALL (::symFindByName(sysSymTbl, symbolname, &value, &symtype), int, -1, status);
00261 
00262   return status == OK ? reinterpret_cast <void*>(value) : 0;
00263 #else
00264   STATUS status;
00265 
00266   SYMBOL_DESC symbolDesc;     /* symFind() descriptor */
00267   ACE_OS::memset (&symbolDesc, 0, sizeof (SYMBOL_DESC));
00268   symbolDesc.mask = SYM_FIND_BY_NAME;
00269   symbolDesc.name = symbolname;
00270 
00271   ACE_OSCALL (::symFind(sysSymTbl, &symbolDesc), int, -1, status);
00272 
00273   return status == OK ? reinterpret_cast <void*>(symbolDesc.value) : 0;
00274 #endif /* (ACE_VXWORKS < 0x690) */
00275 
00276 # else
00277 
00278   ACE_UNUSED_ARG (handle);
00279   ACE_UNUSED_ARG (symbolname);
00280   ACE_NOTSUP_RETURN (0);
00281 
00282 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00283 }

ACE_HANDLE ACE_OS::dup ( ACE_HANDLE  handle,
pid_t  pid 
) [inline]

Definition at line 225 of file OS_NS_unistd.inl.

00226 {
00227   ACE_OS_TRACE("ACE_OS::dup");
00228 #if defined (ACE_LACKS_DUP)
00229   ACE_UNUSED_ARG (handle);
00230   ACE_UNUSED_ARG (pid);
00231   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00232 #elif defined (ACE_WIN32)
00233   ACE_HANDLE new_fd;
00234   ACE_HANDLE hTargetProcess = ::OpenProcess (PROCESS_DUP_HANDLE,
00235                                              FALSE,
00236                                              pid);
00237   if(::DuplicateHandle(::GetCurrentProcess (),
00238                        handle,
00239                        hTargetProcess,
00240                        &new_fd,
00241                        0,
00242                        TRUE,
00243                        DUPLICATE_SAME_ACCESS))
00244     {
00245       ::CloseHandle (hTargetProcess);
00246       return new_fd;
00247     }
00248   else
00249     ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00250   /*NOTREACHED*/
00251 #else
00252   ACE_UNUSED_ARG (pid);
00253   ACE_OSCALL_RETURN(::dup(handle), ACE_HANDLE, ACE_INVALID_HANDLE);
00254 #endif /*ACE_WIN32 &&  !ACE_HAS_WINCE*/
00255 }

ACE_HANDLE ACE_OS::dup ( ACE_HANDLE  handle  )  [inline]

Definition at line 200 of file OS_NS_unistd.inl.

00201 {
00202   ACE_OS_TRACE ("ACE_OS::dup");
00203 #if defined (ACE_LACKS_DUP)
00204   ACE_UNUSED_ARG (handle);
00205   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00206 #elif defined (ACE_WIN32)
00207   ACE_HANDLE new_fd;
00208   if (::DuplicateHandle(::GetCurrentProcess (),
00209                         handle,
00210                         ::GetCurrentProcess(),
00211                         &new_fd,
00212                         0,
00213                         TRUE,
00214                         DUPLICATE_SAME_ACCESS))
00215     return new_fd;
00216   else
00217     ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00218   /* NOTREACHED */
00219 #else
00220   ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE);
00221 #endif /* ACE_LACKS_DUP */
00222 }

int ACE_OS::dup2 ( ACE_HANDLE  oldfd,
ACE_HANDLE  newfd 
) [inline]

Definition at line 258 of file OS_NS_unistd.inl.

00259 {
00260   ACE_OS_TRACE ("ACE_OS::dup2");
00261 #if defined (ACE_LACKS_DUP2)
00262   // msvcrt has _dup2 ?!
00263   ACE_UNUSED_ARG (oldhandle);
00264   ACE_UNUSED_ARG (newhandle);
00265   ACE_NOTSUP_RETURN (-1);
00266 #else
00267   ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1);
00268 #endif /* ACE_LACKS_DUP2 */
00269 }

void ACE_OS::endpwent ( void   ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 9 of file OS_NS_pwd.inl.

00010 {
00011 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00012   ::endpwent ();
00013 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00014 }

int ACE_OS::enum_protocols ( int *  protocols,
ACE_Protocol_Info protocol_buffer,
u_long buffer_length 
) [inline]

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

Definition at line 164 of file OS_NS_sys_socket.inl.

00167 {
00168 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00169 
00170   ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols,
00171                                            protocol_buffer,
00172                                            buffer_length),
00173                        int,
00174                        SOCKET_ERROR);
00175 
00176 #else
00177   ACE_UNUSED_ARG (protocols);
00178   ACE_UNUSED_ARG (protocol_buffer);
00179   ACE_UNUSED_ARG (buffer_length);
00180   ACE_NOTSUP_RETURN (-1);
00181 #endif /* ACE_HAS_WINSOCK2 */
00182 }

int ACE_OS::event_destroy ( ACE_event_t *  event  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2442 of file OS_NS_Thread.cpp.

02443 {
02444 #if defined (ACE_WIN32)
02445   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
02446 #elif defined (ACE_HAS_THREADS)
02447   if (!event->eventdata_)
02448     {
02449       errno = EINVAL;
02450       return -1;
02451     }
02452 
02453   // mutex_destroy()/cond_destroy() are called in a loop if the object
02454   // is BUSY.  This avoids conditions where we fail to destroy these
02455   // objects because at time of destroy they were just being used in
02456   // another thread possibly causing deadlocks later on if they keep
02457   // being used after we're gone.
02458 
02459   if (event->eventdata_->type_ == USYNC_PROCESS)
02460     {
02461       if (event->name_)
02462         {
02463           int r1, r2;
02464 # if ACE_EVENT_USE_MUTEX_PSHARED
02465           // First destroy the mutex so locking after this will return
02466           // errors.
02467           while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02468                  && errno == EBUSY)
02469             ACE_OS::thr_yield ();
02470 # else
02471           r1 = ACE_OS::sema_destroy (&event->lock_);
02472 # endif
02473 
02474 # if ACE_EVENT_USE_COND_PSHARED
02475           // Now fix event to manual reset, raise signal and broadcast
02476           // until is's possible to destroy the condition.
02477           event->eventdata_->manual_reset_ = 1;
02478           while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_))
02479                  == -1 && errno == EBUSY)
02480             {
02481               event->eventdata_->is_signaled_ = 1;
02482               if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02483                 return -1;
02484               ACE_OS::thr_yield ();
02485             }
02486 # else
02487           r2 = ACE_OS::sema_destroy (&event->semaphore_);
02488 # endif
02489           ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t));
02490           ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (event->name_));
02491 # if defined (ACE_HAS_ALLOC_HOOKS)
02492           ACE_Allocator::instance ()->free (event->name_);
02493 # else
02494           ACE_OS::free (event->name_);
02495 # endif /* ACE_HAS_ALLOC_HOOKS */
02496           return r1 != 0 || r2 != 0 ? -1 : 0;
02497         }
02498       else // !name_ (not owned by this process)
02499         {
02500           ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t));
02501 
02502 # if !ACE_EVENT_USE_MUTEX_PSHARED
02503           ACE_OS::sema_destroy (&event->lock_);
02504 # endif
02505 
02506 # if !ACE_EVENT_USE_COND_PSHARED
02507           return ACE_OS::sema_destroy (&event->semaphore_);
02508 # endif
02509         }
02510     }
02511   else // USYNC_THREAD:
02512     {
02513       int r1, r2;
02514       // First destroy the mutex so locking after this will return errors.
02515       while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02516              && errno == EBUSY)
02517         ACE_OS::thr_yield ();
02518 
02519       // Now fix event to manual reset, raise signal and broadcast until
02520       // it's possible to destroy the condition.
02521       event->eventdata_->manual_reset_ = 1;
02522       while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02523              && errno == EBUSY)
02524         {
02525           event->eventdata_->is_signaled_ = 1;
02526           if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02527             return -1;
02528           ACE_OS::thr_yield ();
02529         }
02530 
02531       delete event->eventdata_;
02532       return r1 != 0 || r2 != 0 ? -1 : 0;
02533     }
02534 
02535   return 0;
02536 #else
02537   ACE_UNUSED_ARG (event);
02538   ACE_NOTSUP_RETURN (-1);
02539 #endif /* ACE_WIN32 */
02540 }

int ACE_OS::event_init ( ACE_event_t *  event,
int  type,
ACE_condattr_t attributes,
int  manual_reset,
int  initial_state,
const wchar_t name,
void *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 545 of file OS_NS_Thread.inl.

00553 {
00554 #if defined (ACE_WIN32)
00555   ACE_UNUSED_ARG (type);
00556   ACE_UNUSED_ARG (attributes);
00557   ACE_UNUSED_ARG (arg);
00558   SECURITY_ATTRIBUTES sa_buffer;
00559   SECURITY_DESCRIPTOR sd_buffer;
00560   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
00561       (sa, &sa_buffer, &sd_buffer),
00562   manual_reset,
00563   initial_state,
00564   name);
00565   if (*event == 0)
00566     ACE_FAIL_RETURN (-1);
00567 
00568   // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
00569   ACE_OS::set_errno_to_last_error ();
00570   return 0;
00571 #else  /* ACE_WIN32 */
00572   return ACE_OS::event_init (event,
00573                              type,
00574                              attributes,
00575                              manual_reset,
00576                              initial_state,
00577                              ACE_Wide_To_Ascii (name).char_rep (),
00578                              arg,
00579                              sa);
00580 #endif /* ACE_WIN32 */
00581 }

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 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 509 of file OS_NS_Thread.inl.

00516 {
00517 #if defined (ACE_WIN32)
00518   ACE_UNUSED_ARG (type);
00519   ACE_UNUSED_ARG (arg);
00520   SECURITY_ATTRIBUTES sa_buffer;
00521   SECURITY_DESCRIPTOR sd_buffer;
00522   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
00523       (sa, &sa_buffer, &sd_buffer),
00524   manual_reset,
00525   initial_state,
00526   name);
00527   if (*event == 0)
00528     ACE_FAIL_RETURN (-1);
00529 
00530   // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
00531   ACE_OS::set_errno_to_last_error ();
00532   return 0;
00533 #else  /* ACE_WIN32 */
00534   return ACE_OS::event_init (event,
00535                              manual_reset,
00536                              initial_state,
00537                              type,
00538                              ACE_Wide_To_Ascii (name).char_rep (),
00539                              arg,
00540                              sa);
00541 #endif /* ACE_WIN32 */
00542 }

int ACE_OS::event_init ( ACE_event_t *  event,
int  type,
ACE_condattr_t attributes,
int  manual_reset = 0,
int  initial_state = 0,
const char *  name = 0,
void *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2582 of file OS_NS_Thread.cpp.

02590 {
02591 #if defined (ACE_WIN32)
02592   ACE_UNUSED_ARG (type);
02593   ACE_UNUSED_ARG (attributes);
02594   ACE_UNUSED_ARG (arg);
02595   SECURITY_ATTRIBUTES sa_buffer;
02596   SECURITY_DESCRIPTOR sd_buffer;
02597 # if defined (ACE_HAS_WINCE)
02598   // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
02599   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
02600                              (sa, &sa_buffer, &sd_buffer),
02601                            manual_reset,
02602                            initial_state,
02603                            ACE_Ascii_To_Wide (name).wchar_rep ());
02604 # else /* ACE_HAS_WINCE */
02605   *event = ::CreateEventA (ACE_OS::default_win32_security_attributes_r
02606                              (sa, &sa_buffer, &sd_buffer),
02607                            manual_reset,
02608                            initial_state,
02609                            name);
02610 # endif /* ACE_HAS_WINCE */
02611   if (*event == 0)
02612     ACE_FAIL_RETURN (-1);
02613   else
02614     {
02615       // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
02616       ACE_OS::set_errno_to_last_error ();
02617       return 0;
02618     }
02619 #elif defined (ACE_HAS_THREADS)
02620   ACE_UNUSED_ARG (sa);
02621   event->name_ = 0;
02622   event->eventdata_ = 0;
02623 
02624   if (type == USYNC_PROCESS)
02625     {
02626       const char *name_p = name;
02627 #  if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH)
02628       char adj_name[MAXPATHLEN];
02629       if (name[0] != '/')
02630         {
02631           adj_name[0] = '/';
02632           ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1);
02633           name_p = adj_name;
02634         }
02635 #  endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */
02636 
02637       bool owner = false;
02638       // Let's see if the shared memory entity already exists.
02639       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
02640                                         O_RDWR | O_CREAT | O_EXCL,
02641                                         ACE_DEFAULT_FILE_PERMS);
02642       if (fd == ACE_INVALID_HANDLE)
02643         {
02644           if (errno == EEXIST)
02645             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
02646                                    O_RDWR | O_CREAT,
02647                                    ACE_DEFAULT_FILE_PERMS);
02648           if (fd == ACE_INVALID_HANDLE)   // Still can't get it.
02649             return -1;
02650         }
02651       else
02652         {
02653           // We own this shared memory object!  Let's set its size.
02654           if (ACE_OS::ftruncate (fd, sizeof (ACE_eventdata_t)) == -1)
02655             {
02656               ACE_OS::close (fd);
02657               return -1;
02658             }
02659           owner = true;
02660         }
02661 
02662       void *const mapped = ACE_OS::mmap (0, sizeof (ACE_eventdata_t),
02663                                          PROT_RDWR, MAP_SHARED, fd);
02664       ACE_eventdata_t *evtdata = reinterpret_cast<ACE_eventdata_t *> (mapped);
02665       ACE_OS::close (fd);
02666       if (evtdata == MAP_FAILED)
02667         {
02668           if (owner)
02669             ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02670           return -1;
02671         }
02672 
02673       event->eventdata_ = evtdata;
02674 
02675       if (owner)
02676         {
02677           event->name_ = ACE_OS::strdup (name_p);
02678           if (event->name_ == 0 ||
02679               eventdata_init (event->eventdata_, USYNC_PROCESS, manual_reset,
02680                               initial_state, attributes, name, arg,
02681                               ACE_EVENT_USE_COND_PSHARED,
02682                               ACE_EVENT_USE_MUTEX_PSHARED) != 0)
02683             {
02684               ACE_OS::munmap (evtdata, sizeof (ACE_eventdata_t));
02685               ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02686               return -1;
02687             }
02688         }
02689 
02690       int result = 0;
02691 # if !ACE_EVENT_USE_COND_PSHARED
02692       char sem_name[128] = {};
02693       format_name (sem_name, name, "._ACE_EVTSEM_");
02694       result = ACE_OS::sema_init (&event->semaphore_, 0, type, attributes,
02695                                   sem_name, arg);
02696 # endif
02697 
02698 # if !ACE_EVENT_USE_MUTEX_PSHARED
02699       if (result == 0)
02700         {
02701           char lck_name[128] = {};
02702           format_name (lck_name, name, "._ACE_EVTLCK_");
02703           result = ACE_OS::sema_init (&event->lock_, owner, type, attributes,
02704                                       lck_name, arg);
02705         }
02706 # endif
02707 
02708 # if !ACE_EVENT_USE_COND_PSHARED || !ACE_EVENT_USE_MUTEX_PSHARED
02709       if (result != 0 && owner)
02710         ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02711 # endif
02712 
02713       return result;
02714     }
02715   else
02716     {
02717       ACE_NEW_RETURN (event->eventdata_, ACE_eventdata_t, -1);
02718       return eventdata_init (event->eventdata_, USYNC_THREAD, manual_reset,
02719                              initial_state, attributes, name, arg);
02720     }
02721 #else
02722   ACE_UNUSED_ARG (event);
02723   ACE_UNUSED_ARG (manual_reset);
02724   ACE_UNUSED_ARG (initial_state);
02725   ACE_UNUSED_ARG (type);
02726   ACE_UNUSED_ARG (attributes);
02727   ACE_UNUSED_ARG (name);
02728   ACE_UNUSED_ARG (arg);
02729   ACE_UNUSED_ARG (sa);
02730   ACE_NOTSUP_RETURN (-1);
02731 #endif /* ACE_WIN32 */
02732 }

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 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 495 of file OS_NS_Thread.inl.

00502 {
00503   ACE_condattr_t *pattr = 0;
00504   return ACE_OS::event_init (event, type, pattr, manual_reset, initial_state, name, arg, sa);
00505 }

int ACE_OS::event_pulse ( ACE_event_t *  event  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2735 of file OS_NS_Thread.cpp.

02736 {
02737 #if defined (ACE_WIN32)
02738   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
02739 #elif defined (ACE_HAS_THREADS)
02740   int error = 0;
02741   int result = event->lock ();
02742   if (result != 0)
02743     return result;
02744 
02745   if (event->eventdata_->waiting_threads_ > 0)
02746     {
02747       if (event->eventdata_->manual_reset_ == 1)
02748         {
02749           // Wakeup all waiters.
02750 # if !ACE_EVENT_USE_COND_PSHARED
02751           if (event->eventdata_->type_ == USYNC_PROCESS)
02752             {
02753               event->eventdata_->signal_count_ =
02754                 event->eventdata_->waiting_threads_;
02755               for (unsigned long i = 0;
02756                    i < event->eventdata_->signal_count_; ++i)
02757                 if (ACE_OS::sema_post (&event->semaphore_) != 0)
02758                   {
02759                     event->eventdata_->signal_count_ = 0;
02760                     result = -1;
02761                     error = errno;
02762                   }
02763 
02764               if (result == 0)
02765                 while (event->eventdata_->signal_count_ != 0 &&
02766                        event->eventdata_->waiting_threads_ != 0)
02767                   ACE_OS::thr_yield ();
02768             }
02769           else
02770 #endif
02771             if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02772               {
02773                 result = -1;
02774                 error = errno;
02775               }
02776             else
02777               event->eventdata_->signal_count_ =
02778                 event->eventdata_->waiting_threads_;
02779         }
02780       else // Auto-reset event: wakeup one waiter.
02781         {
02782           if (event->wake_one () != 0)
02783             {
02784               result = -1;
02785               error = errno;
02786             }
02787 
02788           event->eventdata_->auto_event_signaled_ = true;
02789         }
02790     }
02791 
02792   event->eventdata_->is_signaled_ = 0;
02793 
02794   if (event->unlock () != 0)
02795     return -1;
02796 
02797   if (result == -1)
02798     errno = error;
02799 
02800   return result;
02801 #else
02802   ACE_UNUSED_ARG (event);
02803   ACE_NOTSUP_RETURN (-1);
02804 #endif /* ACE_WIN32 */
02805 }

int ACE_OS::event_reset ( ACE_event_t *  event  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2808 of file OS_NS_Thread.cpp.

02809 {
02810 #if defined (ACE_WIN32)
02811   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
02812 #elif defined (ACE_HAS_THREADS)
02813   if (event->lock () != 0)
02814     return -1;
02815 
02816   event->eventdata_->is_signaled_ = 0;
02817   event->eventdata_->auto_event_signaled_ = false;
02818 
02819   return event->unlock ();
02820 #else
02821   ACE_UNUSED_ARG (event);
02822   ACE_NOTSUP_RETURN (-1);
02823 #endif /* ACE_WIN32 */
02824 }

int ACE_OS::event_signal ( ACE_event_t *  event  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2827 of file OS_NS_Thread.cpp.

02828 {
02829 #if defined (ACE_WIN32)
02830   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
02831 #elif defined (ACE_HAS_THREADS)
02832   int error = 0;
02833   int result = event->lock ();
02834 
02835   if (result != 0)
02836     return result;
02837 
02838   if (event->eventdata_->manual_reset_ == 1)
02839     {
02840       // wakeup all
02841 # if !ACE_EVENT_USE_COND_PSHARED
02842       if (event->eventdata_->type_ == USYNC_PROCESS)
02843         {
02844           if (ACE_OS::sema_post (&event->semaphore_) != 0)
02845             {
02846               result = -1;
02847               error = errno;
02848             }
02849         }
02850       else
02851 #endif
02852         if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02853           {
02854             result = -1;
02855             error = errno;
02856           }
02857 
02858       if (result == 0)
02859         event->eventdata_->is_signaled_ = 1;
02860     }
02861   else // Auto-reset event
02862     {
02863       if (event->eventdata_->waiting_threads_ == 0)
02864         event->eventdata_->is_signaled_ = 1;
02865       else if (event->wake_one () != 0)
02866         {
02867           result = -1;
02868           error = errno;
02869         }
02870 
02871       event->eventdata_->auto_event_signaled_ = true;
02872     }
02873 
02874   if (event->unlock () != 0)
02875     return -1;
02876 
02877   if (result == -1)
02878     errno = error;
02879 
02880   return result;
02881 #else
02882   ACE_UNUSED_ARG (event);
02883   ACE_NOTSUP_RETURN (-1);
02884 #endif /* ACE_WIN32 */
02885 }

int ACE_OS::event_timedwait ( ACE_event_t *  event,
ACE_Time_Value timeout,
int  use_absolute_time = 1 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2888 of file OS_NS_Thread.cpp.

02891 {
02892 #if defined (ACE_WIN32)
02893   DWORD result;
02894 
02895   if (timeout && *timeout == ACE_Time_Value::zero)
02896     // Do a "poll".
02897     result = ::WaitForSingleObject (*event, 0);
02898   else
02899     {
02900       // Wait for upto <relative_time> number of milliseconds.  Note
02901       // that we must convert between absolute time (which is passed
02902       // as a parameter) and relative time (which is what
02903       // WaitForSingleObjects() expects).
02904       // <timeout> parameter is given in absolute or relative value
02905       // depending on parameter <use_absolute_time>.
02906       int msec_timeout = 0;
02907       if (!timeout)
02908         {
02909           msec_timeout = INFINITE;
02910         }
02911       else if (use_absolute_time)
02912         {
02913           // Time is given in absolute time, we should use
02914           // gettimeofday() to calculate relative time
02915           ACE_Time_Value relative_time = timeout->to_relative_time ();
02916 
02917           // Watchout for situations where a context switch has caused
02918           // the current time to be > the timeout.  Thanks to Norbert
02919           // Rapp <NRapp@nexus-informatics.de> for pointing this.
02920           if (relative_time > ACE_Time_Value::zero)
02921             msec_timeout = relative_time.msec ();
02922         }
02923       else
02924         // time is given in relative time, just convert it into
02925         // milliseconds and use it
02926         msec_timeout = timeout->msec ();
02927       result = ::WaitForSingleObject (*event, msec_timeout);
02928     }
02929 
02930   switch (result)
02931     {
02932     case WAIT_OBJECT_0:
02933       return 0;
02934     case WAIT_TIMEOUT:
02935       errno = ETIME;
02936       return -1;
02937     default:
02938       // This is a hack, we need to find an appropriate mapping...
02939       ACE_OS::set_errno_to_last_error ();
02940       return -1;
02941     }
02942 #elif defined (ACE_HAS_THREADS)
02943   int error = 0;
02944   int result = event->lock ();
02945 
02946   if (result != 0)
02947     return result;
02948 
02949   if (event->eventdata_->is_signaled_ == 1)
02950     {
02951       if (event->eventdata_->manual_reset_ == 0)
02952         {
02953           // AUTO: reset state
02954           event->eventdata_->is_signaled_ = 0;
02955           event->eventdata_->auto_event_signaled_ = false;
02956         }
02957     }
02958   else // event is currently not signaled
02959     {
02960       ++event->eventdata_->waiting_threads_;
02961 
02962       ACE_Time_Value *absolute_timeout = timeout, converted_time;
02963 
02964       // cond_timedwait() expects absolute time, check <use_absolute_time> flag
02965       if (timeout && use_absolute_time == 0)
02966         {
02967           converted_time = timeout->to_absolute_time ();
02968           absolute_timeout = &converted_time;
02969         }
02970 
02971       while (event->eventdata_->is_signaled_ == 0 &&
02972              !event->eventdata_->auto_event_signaled_)
02973 # if !ACE_EVENT_USE_COND_PSHARED
02974         if (event->eventdata_->type_ == USYNC_PROCESS)
02975           {
02976             if (event->unlock () != 0)
02977               {
02978                 --event->eventdata_->waiting_threads_;
02979                 return -1;
02980               }
02981 
02982             if (ACE_OS::sema_wait (&event->semaphore_, absolute_timeout) != 0)
02983               {
02984                 result = -1;
02985                 error = (errno == ETIMEDOUT) // Semaphores use ETIMEDOUT (POSIX)
02986                   ? ETIME : errno;
02987               }
02988 
02989             bool signalled = false;
02990             if (result == 0 && event->eventdata_->signal_count_ > 0)
02991               {
02992                 --event->eventdata_->signal_count_;
02993                 signalled = true;
02994               }
02995 
02996             if (event->lock () != 0)
02997               {
02998                 --event->eventdata_->waiting_threads_;
02999                 return -1;
03000               }
03001 
03002             if (result != 0)
03003               break;
03004 
03005             if (event->eventdata_->manual_reset_ == 1 &&
03006                 event->eventdata_->is_signaled_ == 1 &&
03007                 ACE_OS::sema_post (&event->semaphore_) != 0)
03008               {
03009                 result = -1;
03010                 error = errno;
03011                 break;
03012               }
03013 
03014             if (signalled)
03015               break;
03016           }
03017         else
03018 #endif
03019           {
03020             if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
03021                                         &event->eventdata_->lock_,
03022                                         absolute_timeout) != 0)
03023               {
03024                 result = -1;
03025                 error = errno;
03026                 break;
03027               }
03028 
03029             if (event->eventdata_->signal_count_ > 0)
03030               {
03031                 --event->eventdata_->signal_count_;
03032                 break;
03033               }
03034           }
03035 
03036       // Reset the auto_event_signaled_ to false now that we have woken up.
03037       if (event->eventdata_->auto_event_signaled_)
03038         event->eventdata_->auto_event_signaled_ = false;
03039 
03040       --event->eventdata_->waiting_threads_;
03041     }
03042 
03043   if (event->unlock () != 0)
03044     return -1;
03045 
03046   if (result == -1)
03047     errno = error;
03048 
03049   return result;
03050 #else
03051   ACE_UNUSED_ARG (event);
03052   ACE_UNUSED_ARG (timeout);
03053   ACE_UNUSED_ARG (use_absolute_time);
03054   ACE_NOTSUP_RETURN (-1);
03055 #endif /* ACE_WIN32 */
03056 }

int ACE_OS::event_wait ( ACE_event_t *  event  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 489 of file OS_NS_Thread.inl.

00490 {
00491   return ACE_OS::event_timedwait (event, 0);
00492 }

int ACE_OS::execl ( const char *  path,
const char *  arg0,
  ... 
)

Definition at line 227 of file OS_NS_unistd.cpp.

00228 {
00229   ACE_OS_TRACE ("ACE_OS::execl");
00230   ACE_NOTSUP_RETURN (-1);
00231   // Need to write this code.
00232   // ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00233 }

int ACE_OS::execle ( const char *  path,
const char *  arg0,
  ... 
)

Definition at line 236 of file OS_NS_unistd.cpp.

00237 {
00238   ACE_OS_TRACE ("ACE_OS::execle");
00239   ACE_NOTSUP_RETURN (-1);
00240   // Need to write this code.
00241   //  ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
00242 }

int ACE_OS::execlp ( const char *  file,
const char *  arg0,
  ... 
)

Definition at line 245 of file OS_NS_unistd.cpp.

00246 {
00247   ACE_OS_TRACE ("ACE_OS::execlp");
00248   ACE_NOTSUP_RETURN (-1);
00249   // Need to write this code.
00250   //  ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00251 }

int ACE_OS::execv ( const char *  path,
char *const   argv[] 
) [inline]

Definition at line 272 of file OS_NS_unistd.inl.

00274 {
00275   ACE_OS_TRACE ("ACE_OS::execv");
00276 #if defined (ACE_LACKS_EXEC)
00277   ACE_UNUSED_ARG (path);
00278   ACE_UNUSED_ARG (argv);
00279 
00280   ACE_NOTSUP_RETURN (-1);
00281 #elif defined (ACE_WIN32)
00282 # if defined (__BORLANDC__)
00283   return ::execv (path, argv);
00284 # elif defined (__MINGW32__)
00285   return ::_execv (path, (char *const *) argv);
00286 # else
00287   // Why this odd-looking code? If execv() returns at all, it's an error.
00288   // Windows defines this as returning an intptr_t rather than a simple int,
00289   // and the conversion triggers compile warnings. So just return -1 if
00290   // the call returns.
00291   ::_execv (path, (const char *const *) argv);
00292   return -1;
00293 # endif /* __BORLANDC__ */
00294 #else
00295   ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00296 #endif /* ACE_LACKS_EXEC */
00297 }

int ACE_OS::execve ( const char *  path,
char *const   argv[],
char *const   envp[] 
) [inline]

Definition at line 300 of file OS_NS_unistd.inl.

00303 {
00304   ACE_OS_TRACE ("ACE_OS::execve");
00305 #if defined (ACE_LACKS_EXEC)
00306   ACE_UNUSED_ARG (path);
00307   ACE_UNUSED_ARG (argv);
00308   ACE_UNUSED_ARG (envp);
00309 
00310   ACE_NOTSUP_RETURN (-1);
00311 #elif defined (ACE_WIN32)
00312 # if defined (__BORLANDC__)
00313   return ::execve (path, argv, envp);
00314 # elif defined (__MINGW32__)
00315   return ::_execve (path, (char *const *) argv, (char *const *) envp);
00316 # else
00317   // Why this odd-looking code? If execv() returns at all, it's an error.
00318   // Windows defines this as returning an intptr_t rather than a simple int,
00319   // and the conversion triggers compile warnings. So just return -1 if
00320   // the call returns.
00321   ::_execve (path, (const char *const *) argv, (const char *const *) envp);
00322   return -1;
00323 # endif /* __BORLANDC__ */
00324 #else
00325   ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
00326 #endif /* ACE_LACKS_EXEC */
00327 }

int ACE_OS::execvp ( const char *  file,
char *const   argv[] 
) [inline]

Definition at line 330 of file OS_NS_unistd.inl.

00332 {
00333   ACE_OS_TRACE ("ACE_OS::execvp");
00334 #if defined (ACE_LACKS_EXEC) || defined (ACE_LACKS_EXECVP)
00335   ACE_UNUSED_ARG (file);
00336   ACE_UNUSED_ARG (argv);
00337 
00338   ACE_NOTSUP_RETURN (-1);
00339 #elif defined (ACE_WIN32)
00340 # if defined (__BORLANDC__)
00341   return ::execvp (file, argv);
00342 # elif defined (__MINGW32__)
00343   return ::_execvp (file, (char *const *) argv);
00344 # else
00345   // Why this odd-looking code? If execv() returns at all, it's an error.
00346   // Windows defines this as returning an intptr_t rather than a simple int,
00347   // and the conversion triggers compile warnings. So just return -1 if
00348   // the call returns.
00349   ::_execvp (file, (const char *const *) argv);
00350   return -1;
00351 # endif /* __BORLANDC__ */
00352 #else
00353   ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00354 #endif /* ACE_LACKS_EXEC */
00355 }

void ACE_OS::exit ( int  status = 0  ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 50 of file OS_NS_stdlib.cpp.

00051 {
00052   ACE_OS_TRACE ("ACE_OS::exit");
00053 
00054 #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
00055   // Shut down the ACE_Object_Manager, if it had registered its exit_hook.
00056   // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is
00057   // instantiated on the main's stack.  ::exit () doesn't destroy it.
00058   if (exit_hook_)
00059     (*exit_hook_) ();
00060 #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
00061 
00062 #if defined (ACE_WIN32)
00063   ::ExitProcess ((UINT) status);
00064 #elif !defined ACE_LACKS_EXIT
00065   ::exit (status);
00066 #else
00067   ACE_UNUSED_ARG (status);
00068 #endif /* ACE_WIN32 */
00069 }

ACE_Export void* ACE_OS::fast_memcpy ( void *  t,
const void *  s,
size_t  len 
)

Finds characters in a buffer (const void version).

int ACE_OS::fattach ( int  handle,
const char *  path 
) [inline]

Definition at line 83 of file OS_NS_stropts.inl.

00084 {
00085   ACE_OS_TRACE ("ACE_OS::fattach");
00086 #if defined (ACE_HAS_STREAM_PIPES)
00087   ACE_OSCALL_RETURN (::fattach (handle, path), int, -1);
00088 #else
00089   ACE_UNUSED_ARG (handle);
00090   ACE_UNUSED_ARG (path);
00091 
00092   ACE_NOTSUP_RETURN (-1);
00093 #endif /* ACE_HAS_STREAM_PIPES */
00094 }

int ACE_OS::fclose ( FILE *  fp  )  [inline]

Definition at line 497 of file OS_NS_stdio.inl.

00498 {
00499   ACE_OS_TRACE ("ACE_OS::fclose");
00500   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fclose (fp), int, -1);
00501 }

int ACE_OS::fcntl ( ACE_HANDLE  handle,
int  cmd,
long  arg = 0 
)

Definition at line 7 of file OS_NS_fcntl.inl.

00008 {
00009   ACE_OS_TRACE ("ACE_OS::fcntl");
00010 # if defined (ACE_LACKS_FCNTL)
00011   ACE_UNUSED_ARG (handle);
00012   ACE_UNUSED_ARG (cmd);
00013   ACE_UNUSED_ARG (arg);
00014   ACE_NOTSUP_RETURN (-1);
00015 # else
00016   ACE_OSCALL_RETURN (::fcntl (handle, cmd, arg), int, -1);
00017 # endif /* ACE_LACKS_FCNTL */
00018 }

int ACE_OS::fdetach ( const char *  file  )  [inline]

Definition at line 97 of file OS_NS_stropts.inl.

00098 {
00099   ACE_OS_TRACE ("ACE_OS::fdetach");
00100 #if defined (ACE_HAS_STREAM_PIPES)
00101   ACE_OSCALL_RETURN (::fdetach (file), int, -1);
00102 #else
00103   ACE_UNUSED_ARG (file);
00104 
00105   ACE_NOTSUP_RETURN (-1);
00106 #endif /* ACE_HAS_STREAM_PIPES */
00107 }

FILE * ACE_OS::fdopen ( ACE_HANDLE  handle,
const ACE_TCHAR mode 
) [inline]

Definition at line 504 of file OS_NS_stdio.inl.

00505 {
00506   ACE_OS_TRACE ("ACE_OS::fdopen");
00507 #if defined (ACE_HAS_WINCE)
00508 # if defined (ACE_HAS_NONCONST_WFDOPEN)
00509   ACE_OSCALL_RETURN (::_wfdopen ((int)handle, const_cast <ACE_TCHAR*> (ACE_TEXT_ALWAYS_WCHAR (mode))),
00510                      FILE*,
00511                      0);
00512 # else
00513   ACE_OSCALL_RETURN (::_wfdopen (handle, ACE_TEXT_ALWAYS_WCHAR (mode)),
00514                      FILE*,
00515                      0);
00516 # endif
00517 #elif defined (ACE_WIN32)
00518   // kernel file handle -> FILE* conversion...
00519   // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost
00520 
00521   FILE * file = 0;
00522 
00523   int const crt_handle = ::_open_osfhandle (intptr_t (handle), 0);
00524 
00525   if (crt_handle != -1)
00526     {
00527 #   if defined (ACE_USES_WCHAR)
00528       file = ::_wfdopen (crt_handle, mode);
00529 #   else
00530       file = ::_fdopen (crt_handle, mode);
00531 #   endif /* ACE_USES_WCHAR */
00532 
00533       if (!file)
00534         {
00535           ::_close (crt_handle);
00536         }
00537     }
00538 
00539   return file;
00540 #elif defined (ACE_LACKS_FDOPEN)
00541   ACE_UNUSED_ARG (handle);
00542   ACE_UNUSED_ARG (mode);
00543   ACE_NOTSUP_RETURN (0);
00544 #else
00545   ACE_OSCALL_RETURN
00546     (::fdopen (handle, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0);
00547 #endif /* ACE_HAS_WINCE */
00548 }

int ACE_OS::fflush ( FILE *  fp  )  [inline]

Definition at line 551 of file OS_NS_stdio.inl.

00552 {
00553   ACE_OS_TRACE ("ACE_OS::fflush");
00554   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fflush (fp), int, -1);
00555 }

int ACE_OS::fgetc ( FILE *  fp  )  [inline]

Definition at line 558 of file OS_NS_stdio.inl.

00559 {
00560   return ace_fgetc_helper (fp);
00561 }

int ACE_OS::fgetpos ( FILE *  fp,
fpos_t *  pos 
) [inline]

Definition at line 575 of file OS_NS_stdio.inl.

00576 {
00577 #ifdef ACE_LACKS_FGETPOS
00578   ACE_UNUSED_ARG (fp);
00579   ACE_UNUSED_ARG (pos);
00580   ACE_NOTSUP_RETURN (-1);
00581 #else
00582   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1);
00583 #endif
00584 }

wchar_t * ACE_OS::fgets ( wchar_t buf,
int  size,
FILE *  fp 
) [inline]

Definition at line 608 of file OS_NS_stdio.inl.

00609 {
00610   ACE_OS_TRACE ("ACE_OS::fgets");
00611   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetws (buf, size, fp), wchar_t *, 0);
00612 }

char * ACE_OS::fgets ( char *  buf,
int  size,
FILE *  fp 
) [inline]

Definition at line 587 of file OS_NS_stdio.inl.

00588 {
00589   ACE_OS_TRACE ("ACE_OS::fgets");
00590 #if defined (ACE_LACKS_FGETS)
00591   char *iter = buf;
00592   int c = EOF;
00593   for (int i = 0; i < size - 1 && c != '\n'; ++i)
00594     {
00595       c = ACE_STD_NAMESPACE::fgetc (fp);
00596       if (c != EOF)
00597         *iter++ = static_cast<char> (c);
00598     }
00599   *iter = '\0';
00600   return c == EOF ? 0 : buf;
00601 #else
00602   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0);
00603 #endif /* ACE_LACKS_FGETS */
00604 }

wint_t ACE_OS::fgetwc ( FILE *  fp  ) 

Definition at line 6 of file OS_NS_wchar.inl.

00007 {
00008 #  if defined (ACE_LACKS_FGETWC)
00009   ACE_UNUSED_ARG (fp);
00010   ACE_NOTSUP_RETURN (0);
00011 #  else
00012   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetwc (fp), wint_t, WEOF);
00013 #  endif /* ACE_LACKS_FGETWC */
00014 }

ACE_HANDLE ACE_OS::fileno ( FILE *  stream  )  [inline]

Definition at line 616 of file OS_NS_stdio.inl.

00617 {
00618 #if defined ACE_FILENO_EQUIVALENT
00619   return (ACE_HANDLE)((intptr_t)ACE_FILENO_EQUIVALENT (stream));
00620 #else
00621   return ace_fileno_helper (stream);
00622 #endif
00623 }

ACE_OFF_T ACE_OS::filesize ( const ACE_TCHAR handle  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 98 of file OS_NS_sys_stat.inl.

00099   {
00100     ACE_OS_TRACE ("ACE_OS::filesize");
00101 
00102     ACE_HANDLE const h = ACE_OS::open (filename, O_RDONLY);
00103     if (h != ACE_INVALID_HANDLE)
00104       {
00105         ACE_OFF_T size = ACE_OS::filesize (h);
00106         ACE_OS::close (h);
00107         return size;
00108       }
00109     else
00110       return -1;
00111   }

ACE_OFF_T ACE_OS::filesize ( ACE_HANDLE  handle  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 73 of file OS_NS_sys_stat.inl.

00074   {
00075     ACE_OS_TRACE ("ACE_OS::filesize");
00076 #if defined (ACE_WIN32)
00077 # if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
00078     LARGE_INTEGER size;
00079     return
00080       (::GetFileSizeEx (handle, &size)
00081        ? size.QuadPart
00082        : (ACE_OS::set_errno_to_last_error (), -1));
00083 # else
00084     DWORD const size = ::GetFileSize (handle, 0);
00085     return
00086       (size != INVALID_FILE_SIZE
00087        ? static_cast<ACE_OFF_T> (size)
00088        : (ACE_OS::set_errno_to_last_error (), -1));
00089 # endif  /* _FILE_OFFSET_BITS == 64 */
00090 #else /* !ACE_WIN32 */
00091     ACE_stat sb;
00092     return ACE_OS::fstat (handle, &sb) == -1 ?
00093                     static_cast<ACE_OFF_T> (-1) : sb.st_size;
00094 #endif
00095   }

void ACE_OS::flock_adjust_params ( ACE_OS::ace_flock_t lock,
short  whence,
ACE_OFF_T start,
ACE_OFF_T len 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 26 of file OS_NS_stdio.inl.

00030 {
00031   switch (whence)
00032     {
00033     case SEEK_SET:
00034       break;
00035     case SEEK_CUR:
00036       {
00037         LARGE_INTEGER offset;
00038 # if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
00039         LARGE_INTEGER distance;
00040         distance.QuadPart = 0;
00041         if (!::SetFilePointerEx (lock->handle_,
00042                                  distance,
00043                                  &offset,
00044                                  FILE_CURRENT))
00045           {
00046             ACE_OS::set_errno_to_last_error ();
00047             return;
00048           }
00049 # else
00050         offset.LowPart = ::SetFilePointer (lock->handle_,
00051                                            0,
00052                                            &offset.HighPart,
00053                                            FILE_CURRENT);
00054         if (offset.LowPart == INVALID_SET_FILE_POINTER &&
00055             ::GetLastError() != NO_ERROR)
00056           {
00057             ACE_OS::set_errno_to_last_error ();
00058             return;
00059           }
00060 # endif /* ACE_LACKS_WIN32_SETFILEPOINTEREX */
00061 
00062 # if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
00063         start += offset.QuadPart;
00064 # else
00065         start += offset.LowPart;
00066 # endif /* _FILE_OFFSET_BITS == 64 */
00067       }
00068       break;
00069     case SEEK_END:
00070       {
00071         ACE_OFF_T const size = ACE_OS::filesize (lock->handle_);
00072         if (size == -1)
00073           return;
00074 
00075         start += size;
00076       }
00077       break;
00078     }
00079   lock->overlapped_.Offset = ACE_LOW_PART (start);
00080   lock->overlapped_.OffsetHigh = ACE_HIGH_PART (start);
00081   if (len == 0)
00082     {
00083       ACE_OFF_T const tlen = ACE_OS::filesize (lock->handle_);
00084       if (tlen != -1)
00085         len = tlen - start;
00086     }
00087 }

int ACE_OS::flock_destroy ( ACE_OS::ace_flock_t lock,
int  unlink_file = 1 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 159 of file OS_NS_stdio.inl.

00161 {
00162   ACE_OS_TRACE ("ACE_OS::flock_destroy");
00163   if (lock->handle_ != ACE_INVALID_HANDLE)
00164     {
00165       ACE_OS::flock_unlock (lock);
00166       // Close the handle.
00167       ACE_OS::close (lock->handle_);
00168       lock->handle_ = ACE_INVALID_HANDLE;
00169       if (lock->lockname_ != 0)
00170         {
00171           if (unlink_file)
00172             ACE_OS::unlink (lock->lockname_);
00173 #if defined (ACE_HAS_ALLOC_HOOKS)
00174           ACE_Allocator::instance()->free (
00175             static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
00176 #else
00177           ACE_OS::free (
00178             static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
00179 #endif /* ACE_HAS_ALLOC_HOOKS */
00180         }
00181       lock->lockname_ = 0;
00182     }
00183   return 0;
00184 }

int ACE_OS::flock_init ( ACE_OS::ace_flock_t lock,
int  flags = 0,
const ACE_TCHAR name = 0,
mode_t  perms = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 91 of file OS_NS_stdio.inl.

00095 {
00096   ACE_OS_TRACE ("ACE_OS::flock_init");
00097 #if defined (ACE_WIN32)
00098   // Once initialized, these values are never changed.
00099   lock->overlapped_.Internal = 0;
00100   lock->overlapped_.InternalHigh = 0;
00101   lock->overlapped_.OffsetHigh = 0;
00102   lock->overlapped_.hEvent = 0;
00103 #endif /* ACE_WIN32 */
00104   lock->handle_ = ACE_INVALID_HANDLE;
00105   lock->lockname_ = 0;
00106 
00107   if (name != 0)
00108     {
00109       ACE_OSCALL (ACE_OS::open (name, flags, perms),
00110                   ACE_HANDLE,
00111                   ACE_INVALID_HANDLE,
00112                   lock->handle_);
00113       if (lock->handle_ != ACE_INVALID_HANDLE)
00114         lock->lockname_ = ACE_OS::strdup (name);
00115       return lock->handle_ == ACE_INVALID_HANDLE ? -1 : 0;
00116     }
00117   else
00118     return 0;
00119 }

int ACE_OS::flock_rdlock ( ACE_OS::ace_flock_t lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 187 of file OS_NS_stdio.inl.

00191 {
00192   ACE_OS_TRACE ("ACE_OS::flock_rdlock");
00193 #if defined (ACE_LACKS_FILELOCKS)
00194   ACE_UNUSED_ARG (lock);
00195   ACE_UNUSED_ARG (whence);
00196   ACE_UNUSED_ARG (start);
00197   ACE_UNUSED_ARG (len);
00198   ACE_NOTSUP_RETURN (-1);
00199 #elif defined (ACE_WIN32)
00200   ACE_OS::flock_adjust_params (lock, whence, start, len);
00201   DWORD low_len = ACE_LOW_PART (len);
00202   DWORD high_len = ACE_HIGH_PART (len);
00203   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00204                                                         0,
00205                                                         0,
00206                                                         low_len,
00207                                                         high_len,
00208                                                         &lock->overlapped_),
00209                                           ace_result_), int, -1);
00210 #else
00211   lock->lock_.l_whence = whence;
00212   lock->lock_.l_start = start;
00213   lock->lock_.l_len = len;
00214   lock->lock_.l_type = F_RDLCK;         // set read lock
00215   // block, if no access
00216   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
00217                                     reinterpret_cast<long> (&lock->lock_)),
00218                      int, -1);
00219 #endif /* ACE_WIN32 */
00220 }

int ACE_OS::flock_tryrdlock ( ACE_OS::ace_flock_t lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 223 of file OS_NS_stdio.inl.

00227 {
00228   ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock");
00229 #if defined (ACE_LACKS_FILELOCKS)
00230   ACE_UNUSED_ARG (lock);
00231   ACE_UNUSED_ARG (whence);
00232   ACE_UNUSED_ARG (start);
00233   ACE_UNUSED_ARG (len);
00234   ACE_NOTSUP_RETURN (-1);
00235 #elif defined (ACE_WIN32)
00236   ACE_OS::flock_adjust_params (lock, whence, start, len);
00237   DWORD low_len = ACE_LOW_PART (len);
00238   DWORD high_len = ACE_HIGH_PART (len);
00239   ACE_WIN32CALL_RETURN (
00240     ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00241                                     LOCKFILE_FAIL_IMMEDIATELY,
00242                                     0,
00243                                     low_len,
00244                                     high_len,
00245                                     &lock->overlapped_),
00246                       ace_result_), int, -1);
00247 #else
00248   lock->lock_.l_whence = whence;
00249   lock->lock_.l_start = start;
00250   lock->lock_.l_len = len;
00251   lock->lock_.l_type = F_RDLCK;         // set read lock
00252 
00253   int result = 0;
00254   // Does not block, if no access, returns -1 and set errno = EBUSY;
00255   ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK,
00256                              reinterpret_cast<long> (&lock->lock_)),
00257               int, -1, result);
00258 
00259   if (result == -1 && (errno == EACCES || errno == EAGAIN))
00260     errno = EBUSY;
00261 
00262   return result;
00263 #endif /* ACE_WIN32 */
00264 }

int ACE_OS::flock_trywrlock ( ACE_OS::ace_flock_t lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 267 of file OS_NS_stdio.inl.

00271 {
00272   ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock");
00273 #if defined (ACE_LACKS_FILELOCKS)
00274   ACE_UNUSED_ARG (lock);
00275   ACE_UNUSED_ARG (whence);
00276   ACE_UNUSED_ARG (start);
00277   ACE_UNUSED_ARG (len);
00278   ACE_NOTSUP_RETURN (-1);
00279 #elif defined (ACE_WIN32)
00280   ACE_OS::flock_adjust_params (lock, whence, start, len);
00281   DWORD low_len = ACE_LOW_PART (len);
00282   DWORD high_len = ACE_HIGH_PART (len);
00283   ACE_WIN32CALL_RETURN (
00284     ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00285                                     LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
00286                                     0,
00287                                     low_len,
00288                                     high_len,
00289                                     &lock->overlapped_),
00290                       ace_result_), int, -1);
00291 #else
00292   lock->lock_.l_whence = whence;
00293   lock->lock_.l_start = start;
00294   lock->lock_.l_len = len;
00295   lock->lock_.l_type = F_WRLCK;         // set write lock
00296 
00297   int result = 0;
00298   // Does not block, if no access, returns -1 and set errno = EBUSY;
00299   ACE_OSCALL (ACE_OS::fcntl (lock->handle_,
00300                              F_SETLK,
00301                              reinterpret_cast<long> (&lock->lock_)),
00302               int, -1, result);
00303 
00304   if (result == -1 && (errno == EACCES || errno == EAGAIN))
00305     errno = EBUSY;
00306 
00307   return result;
00308 #endif /* ACE_WIN32 */
00309 }

int ACE_OS::flock_unlock ( ACE_OS::ace_flock_t lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 122 of file OS_NS_stdio.inl.

00126 {
00127   ACE_OS_TRACE ("ACE_OS::flock_unlock");
00128 #if defined (ACE_LACKS_FILELOCKS)
00129   ACE_UNUSED_ARG (lock);
00130   ACE_UNUSED_ARG (whence);
00131   ACE_UNUSED_ARG (start);
00132   ACE_UNUSED_ARG (len);
00133   ACE_NOTSUP_RETURN (-1);
00134 #elif defined (ACE_WIN32)
00135   ACE_OS::flock_adjust_params (lock, whence, start, len);
00136   DWORD low_len = ACE_LOW_PART (len);
00137   DWORD high_len = ACE_HIGH_PART (len);
00138   ACE_WIN32CALL_RETURN (
00139     ACE_ADAPT_RETVAL (::UnlockFileEx (lock->handle_,
00140                                       0,
00141                                       low_len,
00142                                       high_len,
00143                                       &lock->overlapped_),
00144                       ace_result_), int, -1);
00145 #else
00146   lock->lock_.l_whence = whence;
00147   lock->lock_.l_start = start;
00148   lock->lock_.l_len = len;
00149   lock->lock_.l_type = F_UNLCK;   // Unlock file.
00150 
00151   // release lock
00152   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLK,
00153                                     reinterpret_cast<long> (&lock->lock_)),
00154                      int, -1);
00155 #endif /* ACE_WIN32 */
00156 }

int ACE_OS::flock_wrlock ( ACE_OS::ace_flock_t lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 312 of file OS_NS_stdio.inl.

00316 {
00317   ACE_OS_TRACE ("ACE_OS::flock_wrlock");
00318 #if defined (ACE_LACKS_FILELOCKS)
00319   ACE_UNUSED_ARG (lock);
00320   ACE_UNUSED_ARG (whence);
00321   ACE_UNUSED_ARG (start);
00322   ACE_UNUSED_ARG (len);
00323   ACE_NOTSUP_RETURN (-1);
00324 #elif defined (ACE_WIN32)
00325   ACE_OS::flock_adjust_params (lock, whence, start, len);
00326   DWORD low_len = ACE_LOW_PART (len);
00327   DWORD high_len = ACE_HIGH_PART (len);
00328   ACE_WIN32CALL_RETURN (
00329     ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00330                                     LOCKFILE_EXCLUSIVE_LOCK,
00331                                     0,
00332                                     low_len,
00333                                     high_len,
00334                                     &lock->overlapped_),
00335                       ace_result_), int, -1);
00336 #else
00337   lock->lock_.l_whence = whence;
00338   lock->lock_.l_start = start;
00339   lock->lock_.l_len = len;
00340   lock->lock_.l_type = F_WRLCK;         // set write lock
00341   // block, if no access
00342   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
00343                                     reinterpret_cast<long> (&lock->lock_)),
00344                      int, -1);
00345 #endif /* ACE_WIN32 */
00346 }

template<typename T >
T ACE_OS::floor ( x  )  [inline]

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

Definition at line 90 of file OS_NS_math.h.

00091   {
00092     return ACE_STD_NAMESPACE::floor (x);
00093   }

FILE * ACE_OS::fopen ( const wchar_t filename,
const char *  mode 
)

Definition at line 208 of file OS_NS_stdio.cpp.

00210 {
00211   ACE_OS_TRACE ("ACE_OS::fopen");
00212 #if defined (ACE_LACKS_FOPEN)
00213   ACE_UNUSED_ARG (filename);
00214   ACE_UNUSED_ARG (mode);
00215   ACE_NOTSUP_RETURN (0);
00216 #else
00217   int hmode = _O_TEXT;
00218 
00219   for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
00220     fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
00221 
00222   ACE_HANDLE handle = ACE_OS::open (filename, hmode);
00223   if (handle != ACE_INVALID_HANDLE)
00224     {
00225       hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
00226 
00227       int const fd = ::_open_osfhandle (intptr_t (handle), hmode);
00228 
00229       if (fd != -1)
00230         {
00231 #   if defined (ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)
00232           FILE *fp = ::_fdopen (fd, const_cast<char *> (mode));
00233 #   elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR)
00234           FILE *fp = ::_wfdopen (fd, const_cast<wchar_t *> (mode));
00235 #   elif defined (ACE_USES_WCHAR)
00236           FILE *fp = ::_wfdopen (fd, mode);
00237 #   else
00238           FILE *fp = ::fdopen (fd, mode);
00239 #   endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */
00240           if (fp != 0)
00241           {
00242             return fp;
00243           }
00244           ::_close (fd);
00245         }
00246 
00247       ACE_OS::close (handle);
00248     }
00249   return 0;
00250 #endif
00251 }

FILE* ACE_OS::fopen ( const wchar_t filename,
const wchar_t mode 
)
FILE* ACE_OS::fopen ( const char *  filename,
const wchar_t mode 
)
FILE * ACE_OS::fopen ( const char *  filename,
const char *  mode 
)

Definition at line 140 of file OS_NS_stdio.cpp.

00142 {
00143   ACE_OS_TRACE ("ACE_OS::fopen");
00144 #if defined (ACE_LACKS_FOPEN)
00145   ACE_UNUSED_ARG (filename);
00146   ACE_UNUSED_ARG (mode);
00147   ACE_NOTSUP_RETURN (0);
00148 #else
00149   int hmode = _O_TEXT;
00150 
00151   // Let the chips fall where they may if the user passes in a NULL
00152   // mode string.  Convert to an empty mode string to prevent a
00153   // crash.
00154   ACE_TCHAR const empty_mode[] = ACE_TEXT ("");
00155   if (!mode)
00156     mode = empty_mode;
00157 
00158   for (ACE_TCHAR const* mode_ptr = mode; *mode_ptr != 0; ++mode_ptr)
00159     fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
00160 
00161   ACE_HANDLE const handle = ACE_OS::open (filename, hmode);
00162   if (handle != ACE_INVALID_HANDLE)
00163     {
00164       hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
00165 
00166       int const fd = ::_open_osfhandle (intptr_t (handle), hmode);
00167 
00168       if (fd != -1)
00169         {
00170 #   if defined (ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)
00171           FILE * const fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode));
00172 #   elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR)
00173           FILE * const fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode));
00174 #   elif defined (ACE_USES_WCHAR)
00175           FILE * const fp = ::_wfdopen (fd, mode);
00176 #   else
00177           FILE * const fp = ::fdopen (fd, mode);
00178 #   endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */
00179           if (fp != 0)
00180           {
00181             return fp;
00182           }
00183           ::_close (fd);
00184         }
00185 
00186       ACE_OS::close (handle);
00187     }
00188   return 0;
00189 #endif
00190 }

pid_t ACE_OS::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.

Definition at line 254 of file OS_NS_unistd.cpp.

00255 {
00256   ACE_OS_TRACE ("ACE_OS::fork");
00257 # if defined (ACE_LACKS_FORK)
00258   ACE_UNUSED_ARG (program_name);
00259   ACE_NOTSUP_RETURN (pid_t (-1));
00260 # else
00261   pid_t const pid =
00262 # if defined (ACE_HAS_STHREADS)
00263     ::fork1 ();
00264 #else
00265     ::fork ();
00266 #endif /* ACE_HAS_STHREADS */
00267 
00268 #if !defined (ACE_HAS_MINIMAL_ACE_OS) && !defined (ACE_HAS_THREADS)
00269 
00270   // ACE_Base_Thread_Adapter::sync_log_msg() is used to update the
00271   // program name and process id in ACE's log framework.  However, we
00272   // can't invoke it from (the child process of) threaded programs
00273   // because it calls async signal unsafe functions, which will result
00274   // in undefined behavior (only async signal safe functions can be
00275   // called after fork() until an exec()).
00276   //
00277   // This is no great loss.  Using the ACE log framework in the child
00278   // process will undoubtedly call async signal unsafe functions too.
00279   // So it doesn't really matter that the program name and process id
00280   // will not be updated.
00281 
00282   if (pid == 0)
00283     ACE_Base_Thread_Adapter::sync_log_msg (program_name);
00284 
00285 #else
00286 
00287   ACE_UNUSED_ARG (program_name);
00288 
00289 #endif /* ! ACE_HAS_MINIMAL_ACE_OS && !ACE_HAS_THREADS */
00290 
00291   return pid;
00292 # endif /* ACE_WIN32 */
00293 }

pid_t ACE_OS::fork ( void   )  [inline]

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 358 of file OS_NS_unistd.inl.

00359 {
00360   ACE_OS_TRACE ("ACE_OS::fork");
00361 #if defined (ACE_LACKS_FORK)
00362   ACE_NOTSUP_RETURN (pid_t (-1));
00363 #else
00364   ACE_OSCALL_RETURN (::fork (), pid_t, -1);
00365 #endif /* ACE_LACKS_FORK */
00366 }

pid_t ACE_OS::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.

Definition at line 299 of file OS_NS_unistd.cpp.

00300 {
00301 # if defined (ACE_WIN32)
00302 
00303   ACE_TCHAR *buf = 0;
00304   ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_ptr (buf);
00305   if (ACE_OS::argv_to_string (argv, buf) != -1)
00306     {
00307       PROCESS_INFORMATION process_info;
00308 #   if !defined (ACE_HAS_WINCE)
00309       ACE_TEXT_STARTUPINFO startup_info;
00310       ACE_OS::memset ((void *) &startup_info,
00311                       0,
00312                       sizeof startup_info);
00313       startup_info.cb = sizeof startup_info;
00314 
00315       if (ACE_TEXT_CreateProcess (0,
00316                                   buf,
00317                                   0, // No process attributes.
00318                                   0,  // No thread attributes.
00319                                   TRUE, // Allow handle inheritance.
00320                                   0, // Don't create a new console window.
00321                                   0, // No environment.
00322                                   0, // No current directory.
00323                                   &startup_info,
00324                                   &process_info))
00325 #   else
00326       if (ACE_TEXT_CreateProcess (0,
00327                                   buf,
00328                                   0, // No process attributes.
00329                                   0,  // No thread attributes.
00330                                   FALSE, // Can's inherit handles on CE
00331                                   0, // Don't create a new console window.
00332                                   0, // No environment.
00333                                   0, // No current directory.
00334                                   0, // Can't use startup info on CE
00335                                   &process_info))
00336 #   endif /* ! ACE_HAS_WINCE */
00337         {
00338           // Free resources allocated in kernel.
00339           ACE_OS::close (process_info.hThread);
00340           ACE_OS::close (process_info.hProcess);
00341           // Return new process id.
00342           return process_info.dwProcessId;
00343         }
00344     }
00345 
00346   // CreateProcess failed.
00347   return -1;
00348 # else
00349       pid_t const result = ACE_OS::fork ();
00350 
00351 #   if defined (ACE_USES_WCHAR)
00352       // Wide-char builds need to convert the command-line args to
00353       // narrow char strings for execv ().
00354       char **cargv = 0;
00355       int arg_count;
00356 #   endif /* ACE_HAS_WCHAR */
00357 
00358       switch (result)
00359         {
00360         case -1:
00361           // Error.
00362           return -1;
00363         case 0:
00364           // Child process.
00365 #   if defined (ACE_USES_WCHAR)
00366           for (arg_count = 0; argv[arg_count] != 0; ++arg_count)
00367             ;
00368           ++arg_count;    // Need a 0-pointer end-of-array marker
00369           ACE_NEW_NORETURN (cargv, char*[arg_count]);
00370           if (cargv == 0)
00371             ACE_OS::exit (errno);
00372           --arg_count;    // Back to 0-indexed
00373           cargv[arg_count] = 0;
00374           while (--arg_count >= 0)
00375             cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
00376           // Don't worry about freeing the cargv or the strings it points to.
00377           // Either the process will be replaced, or we'll exit.
00378           if (ACE_OS::execv (cargv[0], cargv) == -1)
00379             ACE_OS::exit (errno);
00380 #   else
00381           if (ACE_OS::execv (argv[0], argv) == -1)
00382             {
00383               // The OS layer should not print stuff out
00384               // ACELIB_ERROR ((LM_ERROR,
00385               //             "%p Exec failed\n"));
00386 
00387               // If the execv fails, this child needs to exit.
00388               ACE_OS::exit (errno);
00389             }
00390 #   endif /* ACE_HAS_WCHAR */
00391 
00392         default:
00393           // Server process.  The fork succeeded.
00394           return result;
00395         }
00396 # endif /* ACE_WIN32 */
00397 }

int ACE_OS::fprintf ( FILE *  fp,
const wchar_t format,
  ... 
)

Definition at line 279 of file OS_NS_stdio.cpp.

00280 {
00281   // ACE_OS_TRACE ("ACE_OS::fprintf");
00282 #if defined (ACE_LACKS_VA_FUNCTIONS)
00283   ACE_UNUSED_ARG (fp);
00284   ACE_UNUSED_ARG (format);
00285   ACE_NOTSUP_RETURN (-1);
00286 #else
00287   va_list ap;
00288   va_start (ap, format);
00289   int const result = ACE_OS::vfprintf (fp, format, ap);
00290   va_end (ap);
00291   return result;
00292 #endif /* ACE_LACKS_VA_FUNCTIONS */
00293 }

int ACE_OS::fprintf ( FILE *  fp,
const char *  format,
  ... 
)

Definition at line 260 of file OS_NS_stdio.cpp.

00261 {
00262   // ACE_OS_TRACE ("ACE_OS::fprintf");
00263 #if defined (ACE_LACKS_VA_FUNCTIONS)
00264   ACE_UNUSED_ARG (fp);
00265   ACE_UNUSED_ARG (format);
00266   ACE_NOTSUP_RETURN (-1);
00267 #else
00268   va_list ap;
00269   va_start (ap, format);
00270   int const result = ACE_OS::vfprintf (fp, format, ap);
00271   va_end (ap);
00272   return result;
00273 #endif /* ACE_LACKS_VA_FUNCTIONS */
00274 }

int ACE_OS::fputc ( int  c,
FILE *  fp 
) [inline]

Definition at line 692 of file OS_NS_stdio.inl.

00693 {
00694 #ifdef ACE_LACKS_FPUTC
00695   ACE_UNUSED_ARG (c);
00696   ACE_UNUSED_ARG (fp);
00697   ACE_NOTSUP_RETURN (-1);
00698 #else
00699   return ace_fputc_helper (c, fp);
00700 #endif
00701 }

int ACE_OS::fputs ( const wchar_t s,
FILE *  stream 
) [inline]

Definition at line 730 of file OS_NS_stdio.inl.

00731 {
00732   ACE_OS_TRACE ("ACE_OS::fputs");
00733   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputws (s, stream), int, -1);
00734 }

int ACE_OS::fputs ( const char *  s,
FILE *  stream 
) [inline]

Definition at line 716 of file OS_NS_stdio.inl.

00717 {
00718   ACE_OS_TRACE ("ACE_OS::fputs");
00719 #ifdef ACE_LACKS_FPUTS
00720   ACE_UNUSED_ARG (s);
00721   ACE_UNUSED_ARG (stream);
00722   ACE_NOTSUP_RETURN (-1);
00723 #else
00724   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1);
00725 #endif
00726 }

size_t ACE_OS::fread ( void *  ptr,
size_t  size,
size_t  nelems,
FILE *  fp 
) [inline]

Definition at line 738 of file OS_NS_stdio.inl.

00739 {
00740   ACE_OS_TRACE ("ACE_OS::fread");
00741   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fread (ptr, size, nelems, fp),
00742                      size_t,
00743                      0);
00744 }

void ACE_OS::free ( void *  ptr  ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 72 of file OS_NS_stdlib.cpp.

00073 {
00074 #if defined (ACE_LACKS_FREE)
00075   ACE_UNUSED_ARG (ptr);
00076 #else
00077   ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
00078 #endif
00079 }

void ACE_OS::freeaddrinfo ( addrinfo result  ) 

Definition at line 754 of file OS_NS_netdb.inl.

00755 {
00756   ACE_OS_TRACE ("ACE_OS::freeaddrinfo");
00757 #ifdef ACE_LACKS_GETADDRINFO
00758   ACE_OS::freeaddrinfo_emulation (result);
00759 #else
00760   ::freeaddrinfo (result);
00761 #endif
00762 }

ACE_Export void ACE_OS::freeaddrinfo_emulation ( addrinfo result  ) 
FILE * ACE_OS::freopen ( const ACE_TCHAR filename,
const ACE_TCHAR mode,
FILE *  stream 
) [inline]

Definition at line 747 of file OS_NS_stdio.inl.

00748 {
00749   ACE_OS_TRACE ("ACE_OS::freopen");
00750 #if defined (ACE_WIN32) && defined(ACE_USES_WCHAR)
00751   ACE_OSCALL_RETURN (::_wfreopen (ACE_TEXT_ALWAYS_WCHAR (filename),
00752                                   ACE_TEXT_ALWAYS_WCHAR (mode),
00753                                   stream),
00754                      FILE *, 0);
00755 #else
00756   ACE_OSCALL_RETURN
00757     (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename),
00758                                  ACE_TEXT_ALWAYS_CHAR (mode),
00759                                  stream),
00760      FILE *, 0);
00761 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
00762 }

int ACE_OS::fseek ( FILE *  fp,
long  offset,
int  ptrname 
) [inline]

Definition at line 765 of file OS_NS_stdio.inl.

00766 {
00767 #if defined (ACE_WIN32)
00768 # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00769   //#error Windows NT is evil AND rude!
00770   switch (whence)
00771     {
00772     case SEEK_SET:
00773       whence = FILE_BEGIN;
00774       break;
00775     case SEEK_CUR:
00776       whence = FILE_CURRENT;
00777       break;
00778     case SEEK_END:
00779       whence = FILE_END;
00780       break;
00781     default:
00782       errno = EINVAL;
00783       return -1; // rather safe than sorry
00784     }
00785 # endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00786 #endif   /* ACE_WIN32 */
00787   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1);
00788 }

int ACE_OS::fsetpos ( FILE *  fp,
fpos_t *  pos 
) [inline]

Definition at line 791 of file OS_NS_stdio.inl.

00792 {
00793 #if defined (ACE_LACKS_FSETPOS)
00794   ACE_UNUSED_ARG (fp);
00795   ACE_UNUSED_ARG (pos);
00796   ACE_NOTSUP_RETURN (-1);
00797 #else
00798   ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
00799 #endif /* ACE_LACKS_FSETPOS */
00800 }

int ACE_OS::fstat ( ACE_HANDLE  handle,
ACE_stat stp 
) [inline]

Definition at line 25 of file OS_NS_sys_stat.inl.

00026   {
00027     ACE_OS_TRACE ("ACE_OS::fstat");
00028 #if defined (ACE_HAS_X86_STAT_MACROS)
00029     // Solaris for intel uses an macro for fstat(), this is a wrapper
00030     // for _fxstat() use of the macro.
00031     // causes compile and runtime problems.
00032     ACE_OSCALL_RETURN (::_fxstat (_STAT_VER, handle, stp), int, -1);
00033 #elif defined (ACE_WIN32)
00034     BY_HANDLE_FILE_INFORMATION fdata;
00035 
00036     if (::GetFileInformationByHandle (handle, &fdata) == FALSE)
00037       {
00038         ACE_OS::set_errno_to_last_error ();
00039         return -1;
00040       }
00041     else if (fdata.nFileSizeHigh != 0)
00042       {
00043         errno = EINVAL;
00044         return -1;
00045       }
00046     else
00047       {
00048         stp->st_size = fdata.nFileSizeLow;
00049         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec ();
00050         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec ();
00051         stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec ();
00052         stp->st_nlink = static_cast<short> (fdata.nNumberOfLinks);
00053         stp->st_dev = stp->st_rdev = 0; // No equivalent conversion.
00054         stp->st_mode = S_IXOTH | S_IROTH |
00055           (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) |
00056           (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG);
00057       }
00058     return 0;
00059 #else
00060 # if defined (ACE_OPENVMS)
00061     //FUZZ: disable check_for_lack_ACE_OS
00062     ::fsync(handle);
00063     //FUZZ: enable check_for_lack_ACE_OS
00064  #endif
00065     ACE_OSCALL_RETURN (::fstat (handle, stp), int, -1);
00066 # endif /* !ACE_HAS_X86_STAT_MACROS */
00067   }

int ACE_OS::fsync ( ACE_HANDLE  handle  )  [inline]

Definition at line 369 of file OS_NS_unistd.inl.

00370 {
00371   ACE_OS_TRACE ("ACE_OS::fsync");
00372 # if defined (ACE_LACKS_FSYNC)
00373   ACE_UNUSED_ARG (handle);
00374   ACE_NOTSUP_RETURN (-1);
00375 # elif defined (ACE_WIN32)
00376   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushFileBuffers (handle), ace_result_), int, -1);
00377 # else
00378   ACE_OSCALL_RETURN (::fsync (handle), int, -1);
00379 # endif /* ACE_LACKS_FSYNC */
00380 }

long ACE_OS::ftell ( FILE *  fp  )  [inline]

Definition at line 803 of file OS_NS_stdio.inl.

00804 {
00805   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ftell (fp), long, -1);
00806 }

int ACE_OS::ftruncate ( ACE_HANDLE  handle,
ACE_OFF_T  offset 
) [inline]

Definition at line 383 of file OS_NS_unistd.inl.

00384 {
00385   ACE_OS_TRACE ("ACE_OS::ftruncate");
00386 #if defined (ACE_WIN32)
00387 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
00388   LARGE_INTEGER loff;
00389   loff.QuadPart = offset;
00390   if (::SetFilePointerEx (handle, loff, 0, FILE_BEGIN))
00391 #  else
00392   if (::SetFilePointer (handle,
00393                         offset,
00394                         0,
00395                         FILE_BEGIN) != INVALID_SET_FILE_POINTER)
00396 #  endif
00397     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
00398   else
00399     ACE_FAIL_RETURN (-1);
00400 #else
00401   ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1);
00402 #endif /* ACE_WIN32 */
00403 }

size_t ACE_OS::fwrite ( const void *  ptr,
size_t  size,
size_t  nitems,
FILE *  fp 
) [inline]

Definition at line 809 of file OS_NS_stdio.inl.

00810 {
00811   ACE_OS_TRACE ("ACE_OS::fwrite");
00812   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fwrite (ptr, size, nitems, fp),
00813                      size_t,
00814                      0);
00815 }

const ACE_TCHAR * ACE_OS::gai_strerror ( int  errcode  ) 

Definition at line 765 of file OS_NS_netdb.inl.

00766 {
00767   ACE_OS_TRACE ("ACE_OS::gai_strerror");
00768 #ifdef ACE_LACKS_GAI_STRERROR
00769   switch (errcode)
00770     {
00771     case EAI_NONAME:
00772       return ACE_TEXT ("Name does not resolve to an address");
00773     case EAI_AGAIN:
00774       return ACE_TEXT ("Temporary failure, try again");
00775     case EAI_FAIL:
00776       return ACE_TEXT ("Name resolution failed");
00777     case EAI_FAMILY:
00778       return ACE_TEXT ("Address family not supported");
00779     case EAI_MEMORY:
00780       return ACE_TEXT ("Out of memory");
00781     case EAI_SYSTEM:
00782       return ACE_TEXT ("Other error, see errno");
00783     case EAI_OVERFLOW:
00784       return ACE_TEXT ("Buffer provided by caller was too small");
00785     default:
00786       return ACE_TEXT ("Unknown error");
00787     }
00788 #elif defined ACE_WIN32
00789   return ACE_TEXT_gai_strerror (errcode);
00790 #else
00791   return ACE_TEXT_CHAR_TO_TCHAR (::gai_strerror (errcode));
00792 #endif
00793 }

HINSTANCE ACE_OS::get_win32_resource_module ( void   )  [inline]

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 ACE_TEXT_OSVERSIONINFO& ACE_OS::get_win32_versioninfo ( void   )  [inline]

Return the win32 OSVERSIONINFO structure.

int ACE_OS::getaddrinfo ( const char *  name,
const char *  service,
const addrinfo hints,
addrinfo **  result 
)

Definition at line 740 of file OS_NS_netdb.inl.

00742 {
00743   ACE_OS_TRACE ("ACE_OS::getaddrinfo");
00744 #ifdef ACE_LACKS_GETADDRINFO
00745   ACE_UNUSED_ARG (service);
00746   ACE_UNUSED_ARG (hints);
00747   return ACE_OS::getaddrinfo_emulation (name, result);
00748 #else
00749   return ::getaddrinfo (name, service, hints, result);
00750 #endif
00751 }

ACE_Export int ACE_OS::getaddrinfo_emulation ( const char *  name,
addrinfo **  result 
)
int ACE_OS::getc ( FILE *  fp  )  [inline]

Definition at line 564 of file OS_NS_stdio.inl.

00565 {
00566 #ifdef ACE_LACKS_GETC
00567   ACE_UNUSED_ARG (fp);
00568   ACE_NOTSUP_RETURN (-1);
00569 #else
00570   return ace_getc_helper (fp);
00571 #endif
00572 }

wchar_t * ACE_OS::getcwd ( wchar_t buf,
size_t  size 
) [inline]

Definition at line 426 of file OS_NS_unistd.inl.

00427 {
00428 #  if defined (ACE_HAS_WINCE)
00429   ACE_UNUSED_ARG (buf);
00430   ACE_UNUSED_ARG (size);
00431   ACE_NOTSUP_RETURN (0);
00432 #  elif defined (ACE_WIN32)
00433   return ::_wgetcwd (buf, static_cast<int> (size));
00434 #  else
00435   char *narrow_buf = new char[size];
00436   char *result = 0;
00437   result = ACE_OS::getcwd (narrow_buf, size);
00438   ACE_Ascii_To_Wide wide_buf (result);
00439   delete [] narrow_buf;
00440   if (result != 0)
00441     ACE_OS::strsncpy (buf, wide_buf.wchar_rep (), size);
00442   return result == 0 ? 0 : buf;
00443 #  endif /* ACE_WIN32 */
00444 }

char * ACE_OS::getcwd ( char *  buf,
size_t  size 
) [inline]

Definition at line 406 of file OS_NS_unistd.inl.

00407 {
00408   ACE_OS_TRACE ("ACE_OS::getcwd");
00409 #if defined (ACE_LACKS_GETCWD)
00410   ACE_UNUSED_ARG (buf);
00411   ACE_UNUSED_ARG (size);
00412   ACE_NOTSUP_RETURN (0);
00413 #elif defined (ACE_WIN32)
00414 #  if defined (ACE_GETCWD_EQUIVALENT)
00415   return ACE_GETCWD_EQUIVALENT (buf, static_cast<int> (size));
00416 #  else
00417   return ::getcwd (buf, static_cast<int> (size));
00418 #  endif
00419 #else
00420   ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0);
00421 #endif /* ACE_LACKS_GETCWD */
00422 }

gid_t ACE_OS::getegid ( void   )  [inline]

Definition at line 459 of file OS_NS_unistd.inl.

00460 {
00461   ACE_OS_TRACE ("ACE_OS::getegid");
00462 #if defined (ACE_LACKS_GETEGID)
00463   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00464 # else
00465   ACE_OSCALL_RETURN (::getegid (), gid_t, static_cast<gid_t> (-1));
00466 # endif /* ACE_LACKS_GETEGID */
00467 }

wchar_t * ACE_OS::getenv ( const wchar_t symbol  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 184 of file OS_NS_stdlib.inl.

00185 {
00186 #if defined (ACE_LACKS_GETENV)
00187   ACE_UNUSED_ARG (symbol);
00188   ACE_NOTSUP_RETURN (0);
00189 #else
00190   ACE_OSCALL_RETURN (::_wgetenv (symbol), wchar_t *, 0);
00191 #endif /* ACE_LACKS_GETENV */
00192 }

char * ACE_OS::getenv ( const char *  symbol  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 171 of file OS_NS_stdlib.inl.

00172 {
00173   ACE_OS_TRACE ("ACE_OS::getenv");
00174 #if defined (ACE_LACKS_GETENV)
00175   ACE_UNUSED_ARG (symbol);
00176   ACE_NOTSUP_RETURN (0);
00177 #else /* ACE_LACKS_GETENV */
00178   ACE_OSCALL_RETURN (::getenv (symbol), char *, 0);
00179 #endif /* ACE_LACKS_GETENV */
00180 }

ACE_TCHAR * ACE_OS::getenvstrings ( void   ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 91 of file OS_NS_stdlib.cpp.

00092 {
00093 #if defined (ACE_LACKS_GETENVSTRINGS)
00094   ACE_NOTSUP_RETURN (0);
00095 #elif defined (ACE_WIN32)
00096 # if defined (ACE_USES_WCHAR)
00097   return ::GetEnvironmentStringsW ();
00098 # else /* ACE_USES_WCHAR */
00099   return ::GetEnvironmentStrings ();
00100 # endif /* ACE_USES_WCHAR */
00101 #else /* ACE_WIN32 */
00102   ACE_NOTSUP_RETURN (0);
00103 #endif /* ACE_WIN32 */
00104 }

uid_t ACE_OS::geteuid ( void   )  [inline]

Definition at line 537 of file OS_NS_unistd.inl.

00538 {
00539   ACE_OS_TRACE ("ACE_OS::geteuid");
00540 #if defined (ACE_LACKS_GETEUID)
00541   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00542 # else
00543   ACE_OSCALL_RETURN (::geteuid (), uid_t, (uid_t) -1);
00544 # endif /* ACE_LACKS_GETEUID */
00545 }

gid_t ACE_OS::getgid ( void   )  [inline]

Definition at line 448 of file OS_NS_unistd.inl.

00449 {
00450   ACE_OS_TRACE ("ACE_OS::getgid");
00451 #if defined (ACE_LACKS_GETGID)
00452   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00453 # else
00454   ACE_OSCALL_RETURN (::getgid (), gid_t, static_cast<gid_t> (-1));
00455 # endif /* ACE_LACKS_GETGID */
00456 }

struct hostent * ACE_OS::gethostbyaddr ( const char *  addr,
int  length,
int  type 
) [read]

Definition at line 43 of file OS_NS_netdb.inl.

00044 {
00045   ACE_OS_TRACE ("ACE_OS::gethostbyaddr");
00046 # if defined (ACE_LACKS_GETHOSTBYADDR)
00047   ACE_UNUSED_ARG (addr);
00048   ACE_UNUSED_ARG (length);
00049   ACE_UNUSED_ARG (type);
00050   ACE_NOTSUP_RETURN (0);
00051 # else
00052 
00053   if (0 == addr || '\0' == addr[0])
00054       return 0;
00055 
00056 #   if defined (ACE_VXWORKS)
00057   // VxWorks 6.x has a gethostbyaddr() that is threadsafe and
00058   // returns an heap-allocated hostentry structure.
00059   // just call ACE_OS::gethostbyaddr_r () which knows how to handle this.
00060   struct hostent hentry;
00061   ACE_HOSTENT_DATA buf;
00062   int h_error;  // Not the same as errno!
00063   return ACE_OS::gethostbyaddr_r (addr, length, type, &hentry, buf, &h_error);
00064 #   elif defined (ACE_HAS_NONCONST_GETBY)
00065   //FUZZ: disable check_for_lack_ACE_OS
00066   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00067                                         (ACE_SOCKET_LEN) length,
00068                                         type),
00069                        struct hostent *,
00070                        0);
00071   //FUZZ: enable check_for_lack_ACE_OS
00072 #   else
00073   //FUZZ: disable check_for_lack_ACE_OS
00074   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00075                                         (ACE_SOCKET_LEN) length,
00076                                         type),
00077                        struct hostent *,
00078                        0);
00079   //FUZZ: enable check_for_lack_ACE_OS
00080 #   endif /* ACE_HAS_NONCONST_GETBY */
00081 # endif /* !ACE_LACKS_GETHOSTBYADDR */
00082 }

struct hostent * ACE_OS::gethostbyaddr_r ( const char *  addr,
int  length,
int  type,
struct hostent result,
ACE_HOSTENT_DATA  buffer,
int *  h_errnop 
) [read]

Definition at line 85 of file OS_NS_netdb.inl.

00091 {
00092   ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r");
00093 # if defined (ACE_LACKS_GETHOSTBYADDR_R)
00094   ACE_UNUSED_ARG (addr);
00095   ACE_UNUSED_ARG (length);
00096   ACE_UNUSED_ARG (type);
00097   ACE_UNUSED_ARG (result);
00098   ACE_UNUSED_ARG (buffer);
00099   if (h_errnop)
00100     *h_errnop = ENOTSUP;
00101   ACE_NOTSUP_RETURN (0);
00102 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
00103 
00104   if (0 == addr || '\0' == addr[0])
00105       return 0;
00106 
00107 #   if defined (AIX)
00108   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00109 
00110   //FUZZ: disable check_for_lack_ACE_OS
00111   if (::gethostbyaddr_r ((char *) addr, length, type, result,
00112                          (struct hostent_data *) buffer)== 0)
00113     return result;
00114   //FUZZ: enable check_for_lack_ACE_OS
00115   else
00116     {
00117       *h_errnop = h_errno;
00118       return (struct hostent *) 0;
00119     }
00120 #   elif defined (__GLIBC__)
00121   // GNU C library has a different signature
00122   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00123 
00124   //FUZZ: disable check_for_lack_ACE_OS
00125   if (::gethostbyaddr_r ((char *) addr,
00126                          length,
00127                          type,
00128                          result,
00129                          buffer,
00130                          sizeof (ACE_HOSTENT_DATA),
00131                          &result,
00132                          h_errnop) == 0)
00133     return result;
00134   //FUZZ: enable check_for_lack_ACE_OS
00135   else
00136     return (struct hostent *) 0;
00137 #   elif defined (ACE_VXWORKS)
00138   ACE_UNUSED_ARG (h_errnop);
00139   // VxWorks 6.x has a threadsafe gethostbyaddr() which returns a heap-allocated
00140   // data structure which needs to be freed with hostentFree()
00141   //FUZZ: disable check_for_lack_ACE_OS
00142   struct hostent* hp = ::gethostbyaddr (addr, length, type);
00143   //FUZZ: enable check_for_lack_ACE_OS
00144 
00145   if (hp)
00146   {
00147     result->h_addrtype = hp->h_addrtype;
00148     result->h_length = hp->h_length;
00149 
00150     // buffer layout:
00151     // buffer[0-3]: h_addr_list[0], pointer to the addr.
00152     // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
00153     // buffer[8..(8+h_length)]: the first (and only) addr.
00154     // buffer[(8+h_length)...]: hostname
00155 
00156     // Store the address list in buffer.
00157     result->h_addr_list = (char **) buffer;
00158     // Store the actual address _after_ the address list.
00159     result->h_addr_list[0] = (char *) &result->h_addr_list[2];
00160     ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length);
00161     // Null-terminate the list of addresses.
00162     result->h_addr_list[1] = 0;
00163     // And no aliases, so null-terminate h_aliases.
00164     result->h_aliases = &result->h_addr_list[1];
00165 
00166     if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) <= sizeof (ACE_HOSTENT_DATA))
00167     {
00168       result->h_name = (char *) result->h_addr_list[0] + hp->h_length;
00169       ACE_OS::strcpy (result->h_name, hp->h_name);
00170     }
00171     else
00172     {
00173       result->h_name = (char *)0;
00174     }
00175 
00176     // free hostent memory
00177     ::hostentFree (hp);
00178 
00179     return result;
00180   }
00181   else
00182   {
00183     return (struct hostent *) 0;
00184   }
00185 #   else
00186 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00187   ACE_UNUSED_ARG (result);
00188   ACE_UNUSED_ARG (h_errnop);
00189   //FUZZ: disable check_for_lack_ACE_OS
00190   ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type),
00191                         struct hostent *, 0,
00192                         buffer, sizeof (ACE_HOSTENT_DATA));
00193   //FUZZ: enable check_for_lack_ACE_OS
00194 #     else
00195   //FUZZ: disable check_for_lack_ACE_OS
00196   ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result,
00197                                           buffer, sizeof (ACE_HOSTENT_DATA),
00198                                           h_errnop),
00199                        struct hostent *, 0);
00200   //FUZZ: enable check_for_lack_ACE_OS
00201 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00202 #   endif /* defined (AIX) */
00203 # elif defined (ACE_HAS_NONCONST_GETBY)
00204   ACE_UNUSED_ARG (result);
00205   ACE_UNUSED_ARG (buffer);
00206   ACE_UNUSED_ARG (h_errnop);
00207   //FUZZ: disable check_for_lack_ACE_OS
00208   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00209                                         (ACE_SOCKET_LEN) length,
00210                                         type),
00211                        struct hostent *,
00212                        0);
00213   //FUZZ: enable check_for_lack_ACE_OS
00214 # else
00215   ACE_UNUSED_ARG (h_errnop);
00216   ACE_UNUSED_ARG (buffer);
00217   ACE_UNUSED_ARG (result);
00218 
00219   //FUZZ: disable check_for_lack_ACE_OS
00220   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00221                                         (ACE_SOCKET_LEN) length,
00222                                         type),
00223                        struct hostent *,
00224                        0);
00225   //FUZZ: enable check_for_lack_ACE_OS
00226 # endif /* ACE_LACKS_GETHOSTBYADDR_R */
00227 }

struct hostent * ACE_OS::gethostbyname ( const char *  name  )  [read]

Definition at line 230 of file OS_NS_netdb.inl.

00231 {
00232   ACE_OS_TRACE ("ACE_OS::gethostbyname");
00233 # if defined (ACE_LACKS_GETHOSTBYNAME)
00234   ACE_UNUSED_ARG (name);
00235   ACE_NOTSUP_RETURN (0);
00236 # else
00237 
00238   if (0 == name || '\0' == name[0])
00239       return 0;
00240 
00241 #   if defined (ACE_VXWORKS)
00242   // VxWorks 6.x has a gethostbyname() that is threadsafe and
00243   // returns an heap-allocated hostentry structure.
00244   // just call ACE_OS::gethostbyname_r () which knows how to handle this.
00245   struct hostent hentry;
00246   ACE_HOSTENT_DATA buf;
00247   int h_error;  // Not the same as errno!
00248   return ACE_OS::gethostbyname_r (name, &hentry, buf, &h_error);
00249 #   elif defined (ACE_HAS_NONCONST_GETBY)
00250   //FUZZ: disable check_for_lack_ACE_OS
00251   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
00252                        struct hostent *,
00253                        0);
00254   //FUZZ: enable check_for_lack_ACE_OS
00255 #   else
00256   //FUZZ: disable check_for_lack_ACE_OS
00257   ACE_SOCKCALL_RETURN (::gethostbyname (name),
00258                        struct hostent *,
00259                        0);
00260   //FUZZ: enable check_for_lack_ACE_OS
00261 #   endif /* ACE_HAS_NONCONST_GETBY */
00262 # endif /* !ACE_LACKS_GETHOSTBYNAME */
00263 }

struct hostent * ACE_OS::gethostbyname_r ( const char *  name,
struct hostent result,
ACE_HOSTENT_DATA  buffer,
int *  h_errnop 
) [read]

Definition at line 266 of file OS_NS_netdb.inl.

00270 {
00271   ACE_OS_TRACE ("ACE_OS::gethostbyname_r");
00272 #if defined (ACE_LACKS_GETHOSTBYNAME)
00273   ACE_UNUSED_ARG (name);
00274   ACE_UNUSED_ARG (result);
00275   ACE_UNUSED_ARG (buffer);
00276   if (h_errnop)
00277     *h_errnop = ENOTSUP;
00278   ACE_NOTSUP_RETURN (0);
00279 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
00280 
00281   if (0 == name || '\0' == name[0])
00282       return (struct hostent *)0;
00283 
00284 # if (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2))
00285   ACE_UNUSED_ARG (result);
00286   ACE_UNUSED_ARG (buffer);
00287   ACE_UNUSED_ARG (h_errnop);
00288 
00289   // gethostbyname returns thread-specific storage on Digital Unix and
00290   // AIX 4.3
00291   //FUZZ: disable check_for_lack_ACE_OS
00292   ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
00293   //FUZZ: enable check_for_lack_ACE_OS
00294 #   elif defined (AIX)
00295   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00296 
00297   //FUZZ: disable check_for_lack_ACE_OS
00298   if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0)
00299     return result;
00300   //FUZZ: enable check_for_lack_ACE_OS
00301   else
00302     {
00303       *h_errnop = h_errno;
00304       return (struct hostent *) 0;
00305     }
00306 #   elif defined (__GLIBC__)
00307   // GNU C library has a different signature
00308   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00309 
00310   //FUZZ: disable check_for_lack_ACE_OS
00311   if (::gethostbyname_r (name,
00312                          result,
00313                          buffer,
00314                          sizeof (ACE_HOSTENT_DATA),
00315                          &result,
00316                          h_errnop) == 0)
00317     return result;
00318   //FUZZ: enable check_for_lack_ACE_OS
00319   else
00320     return (struct hostent *) 0;
00321 #   elif defined (ACE_VXWORKS)
00322   ACE_UNUSED_ARG (h_errnop);
00323   // VxWorks 6.x has a threadsafe gethostbyname() which returns a heap-allocated
00324   // data structure which needs to be freed with hostentFree()
00325   //FUZZ: disable check_for_lack_ACE_OS
00326   struct hostent* hp = ::gethostbyname (name);
00327   //FUZZ: enable check_for_lack_ACE_OS
00328 
00329   if (hp)
00330   {
00331     result->h_addrtype = hp->h_addrtype;
00332     result->h_length = hp->h_length;
00333 
00334     // buffer layout:
00335     // buffer[0-3]: h_addr_list[0], pointer to the addr.
00336     // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
00337     // buffer[8...]: the first (and only) addr.
00338 
00339     // Store the address list in buffer.
00340     result->h_addr_list = (char **) buffer;
00341     // Store the actual address _after_ the address list.
00342     result->h_addr_list[0] = (char *) &result->h_addr_list[2];
00343     ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length);
00344     // Null-terminate the list of addresses.
00345     result->h_addr_list[1] = 0;
00346     // And no aliases, so null-terminate h_aliases.
00347     result->h_aliases = &result->h_addr_list[1];
00348 
00349     if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) <= sizeof (ACE_HOSTENT_DATA))
00350     {
00351       result->h_name = (char *) result->h_addr_list[0] + hp->h_length;
00352       ACE_OS::strcpy (result->h_name, hp->h_name);
00353     }
00354     else
00355     {
00356       result->h_name = (char *)0;
00357     }
00358 
00359     // free hostent memory
00360     ::hostentFree (hp);
00361 
00362     return result;
00363   }
00364   else
00365   {
00366     return (struct hostent *) 0;
00367   }
00368 #   else
00369 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00370   ACE_UNUSED_ARG (result);
00371   ACE_UNUSED_ARG (h_errnop);
00372   //FUZZ: disable check_for_lack_ACE_OS
00373   ACE_NETDBCALL_RETURN (::gethostbyname (name),
00374                         struct hostent *, 0,
00375                         buffer, sizeof (ACE_HOSTENT_DATA));
00376   //FUZZ: enable check_for_lack_ACE_OS
00377 #     else
00378   //FUZZ: disable check_for_lack_ACE_OS
00379   ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer,
00380                                           sizeof (ACE_HOSTENT_DATA),
00381                                           h_errnop),
00382                        struct hostent *,
00383                        0);
00384   //FUZZ: enable check_for_lack_ACE_OS
00385 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00386 #   endif /* defined (AIX) */
00387 # elif defined (ACE_HAS_NONCONST_GETBY)
00388   ACE_UNUSED_ARG (result);
00389   ACE_UNUSED_ARG (buffer);
00390   ACE_UNUSED_ARG (h_errnop);
00391   //FUZZ: disable check_for_lack_ACE_OS
00392   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
00393                        struct hostent *,
00394                        0);
00395   //FUZZ: enable check_for_lack_ACE_OS
00396 # else
00397   ACE_UNUSED_ARG (result);
00398   ACE_UNUSED_ARG (buffer);
00399 
00400   // FUZZ: disable check_for_lack_ACE_OS
00401   struct hostent *result2 = 0;
00402   ACE_SOCKCALL (::gethostbyname (name),
00403                 struct hostent *,
00404                 0,
00405                 result2);
00406   if (result2 == 0 && h_errnop)
00407     *h_errnop = errno;
00408   return result2;
00409   //FUZZ: enable check_for_lack_ACE_OS
00410 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) */
00411 }

ACE_hrtime_t ACE_OS::gethrtime ( const ACE_HRTimer_Op  op = ACE_HRTIMER_GETTIME  )  [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 253 of file OS_NS_time.inl.

00254 {
00255   ACE_OS_TRACE ("ACE_OS::gethrtime");
00256 #if defined (ACE_HAS_HI_RES_TIMER)
00257   ACE_UNUSED_ARG (op);
00258   return ::gethrtime ();
00259 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00260   ACE_UNUSED_ARG (op);
00261   timebasestruct_t tb;
00262 
00263   ::read_real_time(&tb, TIMEBASE_SZ);
00264   ::time_base_to_time(&tb, TIMEBASE_SZ);
00265 
00266   return ACE_hrtime_t(tb.tb_high) * ACE_ONE_SECOND_IN_NSECS + tb.tb_low;
00267 #elif defined (ACE_WIN32)
00268   ACE_UNUSED_ARG(op);
00269   LARGE_INTEGER freq;
00270 
00271   ::QueryPerformanceCounter (&freq);
00272 
00273   return freq.QuadPart;
00274 #elif defined (ghs) && defined (ACE_HAS_PENTIUM)
00275   ACE_UNUSED_ARG (op);
00276   // Use .obj/gethrtime.o, which was compiled with g++.
00277   return ACE_GETHRTIME_NAME ();
00278 #elif (defined (__GNUG__) || defined (__INTEL_COMPILER)) && \
00279   !defined (ACE_VXWORKS) && defined (ACE_HAS_PENTIUM) && \
00280   !defined (ACE_LACKS_PENTIUM_RDTSC)
00281   ACE_UNUSED_ARG (op);
00282   ACE_hrtime_t now;
00283 
00284 # if defined (__amd64__) || defined (__x86_64__)
00285   // Read the high res tick counter into 32 bit int variables "eax" and
00286   // "edx", and then combine them into 64 bit int "now"
00287   ACE_UINT32 eax, edx;
00288   asm volatile ("rdtsc" : "=a" (eax), "=d" (edx) : : "memory");
00289   now = (((ACE_UINT64) eax) | (((ACE_UINT64) edx) << 32));
00290 # else
00291   // Read the high-res tick counter directly into memory variable "now".
00292   // The A constraint signifies a 64-bit int.
00293   asm volatile ("rdtsc" : "=A" (now) : : "memory");
00294 # endif
00295 
00296   return now;
00297 #elif defined (ACE_LINUX) && defined (ACE_HAS_ALPHA_TIMER)
00298   // NOTE:  alphas only have a 32 bit tick (cycle) counter.  The rpcc
00299   // instruction actually reads 64 bits, but the high 32 bits are
00300   // implementation-specific.  Linux and Digital Unix, for example,
00301   // use them for virtual tick counts, i.e., taking into account only
00302   // the time that the process was running.  This information is from
00303   // David Mosberger's article, see comment below.
00304   ACE_UINT32 now;
00305 
00306   // The following statement is based on code published by:
00307   // Mosberger, David, "How to Make Your Applications Fly, Part 1",
00308   // Linux Journal Issue 42, October 1997, page 50.  It reads the
00309   // high-res tick counter directly into the memory variable.
00310   asm volatile ("rpcc %0" : "=r" (now) : : "memory");
00311 
00312   return now;
00313 #elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__))
00314   // PowerPC w/ GreenHills or g++.
00315 
00316   ACE_UNUSED_ARG (op);
00317   u_long most;
00318   u_long least;
00319 
00320 #if defined (ghs)
00321   ACE_OS::readPPCTimeBase (most, least);
00322 #else
00323   u_long scratch;
00324 
00325   do {
00326     asm volatile ("mftbu %0\n"
00327           "mftb  %1\n"
00328           "mftbu %2"
00329           : "=r" (most), "=r" (least), "=r" (scratch));
00330   } while (most != scratch);
00331 #endif
00332 
00333   return 0x100000000llu * most  +  least;
00334 
00335 #elif defined (ACE_HAS_CLOCK_GETTIME)
00336   // e.g., VxWorks (besides POWERPC && GreenHills) . . .
00337   ACE_UNUSED_ARG (op);
00338   struct timespec ts;
00339 
00340   ACE_OS::clock_gettime (
00341 #if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC)
00342          CLOCK_MONOTONIC,
00343 #else
00344          CLOCK_REALTIME,
00345 #endif /* !ACE_HAS_CLOCK_GETTIME_MONOTONIC */
00346          &ts);
00347 
00348   // Carefully create the return value to avoid arithmetic overflow
00349   return static_cast<ACE_hrtime_t> (ts.tv_sec) *
00350     ACE_U_ONE_SECOND_IN_NSECS  +  static_cast<ACE_hrtime_t> (ts.tv_nsec);
00351 #else
00352   ACE_UNUSED_ARG (op);
00353   ACE_Time_Value const now = ACE_OS::gettimeofday ();
00354 
00355   // Carefully create the return value to avoid arithmetic overflow
00356   return (static_cast<ACE_hrtime_t> (now.sec ()) * (ACE_UINT32) 1000000  +
00357           static_cast<ACE_hrtime_t> (now.usec ())) * (ACE_UINT32) 1000;
00358 #endif /* ACE_HAS_HI_RES_TIMER */
00359 }

struct hostent * ACE_OS::getipnodebyaddr ( const void *  src,
size_t  len,
int  family 
) [read]

Definition at line 414 of file OS_NS_netdb.inl.

00415 {
00416 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00417 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
00418   ACE_UNUSED_ARG (src);
00419   ACE_UNUSED_ARG (len);
00420   ACE_UNUSED_ARG (family);
00421   ACE_NOTSUP_RETURN (0);
00422 #  else
00423   struct hostent *hptr = 0;
00424   int errnum;
00425   //FUZZ: disable check_for_lack_ACE_OS
00426   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
00427     {
00428       errno = errnum;
00429     }
00430   //FUZZ: enable check_for_lack_ACE_OS
00431   return hptr;
00432 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
00433 #else
00434   // IPv4-only implementation
00435   if (family == AF_INET)
00436     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
00437                                   static_cast<int> (len),
00438                                   family);
00439 
00440   ACE_NOTSUP_RETURN (0);
00441 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00442 }

struct hostent * ACE_OS::getipnodebyname ( const char *  name,
int  family,
int  flags = 0 
) [read]

Definition at line 445 of file OS_NS_netdb.inl.

00446 {
00447   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
00448 # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6)
00449 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
00450   ACE_UNUSED_ARG (flags);
00451 #     if defined (ACE_HAS_NONCONST_GETBY)
00452   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
00453                                          family),
00454                        struct hostent *, 0);
00455 #     else
00456   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
00457                        struct hostent *, 0);
00458 #     endif /* ACE_HAS_NONCONST_GETBY */
00459 #   else
00460   struct hostent *hptr = 0;
00461   int errnum;
00462   //FUZZ: disable check_for_lack_ACE_OS
00463   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
00464     {
00465       errno = errnum;
00466     }
00467   //FUZZ: enable check_for_lack_ACE_OS
00468   return hptr;
00469 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
00470 # else
00471   // IPv4-only implementation
00472   ACE_UNUSED_ARG (flags);
00473   if (family == AF_INET)
00474     return ACE_OS::gethostbyname (name);
00475 
00476   ACE_NOTSUP_RETURN (0);
00477 # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */
00478 }

int ACE_OS::getmacaddress ( struct macaddr_node_t *  node  ) 

Define a structure for use with the netbios routine

Reset the netbios

Definition at line 48 of file OS_NS_netdb.cpp.

00049 {
00050   ACE_OS_TRACE ("ACE_OS::getmacaddress");
00051 
00052 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00053 # if !defined (ACE_HAS_PHARLAP)
00054     /** Define a structure for use with the netbios routine */
00055     struct ADAPTERSTAT
00056     {
00057       ADAPTER_STATUS adapt;
00058       NAME_BUFFER    NameBuff [30];
00059     };
00060 
00061     NCB         ncb;
00062     LANA_ENUM   lenum;
00063     unsigned char result;
00064 
00065     ACE_OS::memset (&ncb, 0, sizeof(ncb));
00066     ncb.ncb_command = NCBENUM;
00067     ncb.ncb_buffer  = reinterpret_cast<unsigned char*> (&lenum);
00068     ncb.ncb_length  = sizeof(lenum);
00069 
00070     result = Netbios (&ncb);
00071 
00072     for(int i = 0; i < lenum.length; i++)
00073       {
00074         ACE_OS::memset (&ncb, 0, sizeof(ncb));
00075         ncb.ncb_command  = NCBRESET;
00076         ncb.ncb_lana_num = lenum.lana [i];
00077 
00078         /** Reset the netbios */
00079         result = Netbios (&ncb);
00080 
00081         if (ncb.ncb_retcode != NRC_GOODRET)
00082         {
00083           return -1;
00084         }
00085 
00086         ADAPTERSTAT adapter;
00087         ACE_OS::memset (&ncb, 0, sizeof (ncb));
00088         ACE_OS::strcpy (reinterpret_cast<char*> (ncb.ncb_callname), "*");
00089         ncb.ncb_command     = NCBASTAT;
00090         ncb.ncb_lana_num    = lenum.lana[i];
00091         ncb.ncb_buffer      = reinterpret_cast<unsigned char*> (&adapter);
00092         ncb.ncb_length      = sizeof (adapter);
00093 
00094         result = Netbios (&ncb);
00095 
00096         if (result == 0)
00097         {
00098           ACE_OS::memcpy (node->node,
00099               adapter.adapt.adapter_address,
00100               6);
00101           return 0;
00102         }
00103       }
00104     return 0;
00105 # else
00106 #   if defined (ACE_HAS_PHARLAP_RT)
00107       DEVHANDLE ip_dev = (DEVHANDLE)0;
00108       EK_TCPIPCFG *devp = 0;
00109       size_t i;
00110       ACE_TCHAR dev_name[16];
00111 
00112       for (i = 0; i < 10; i++)
00113         {
00114           // Ethernet.
00115           ACE_OS::snprintf (dev_name, 16, "ether%d", i);
00116           ip_dev = EtsTCPGetDeviceHandle (dev_name);
00117           if (ip_dev != 0)
00118             break;
00119         }
00120       if (ip_dev == 0)
00121         return -1;
00122       devp = EtsTCPGetDeviceCfg (ip_dev);
00123       if (devp == 0)
00124         return -1;
00125       ACE_OS::memcpy (node->node,
00126             &devp->EthernetAddress[0],
00127             6);
00128       return 0;
00129 #   else
00130       ACE_UNUSED_ARG (node);
00131       ACE_NOTSUP_RETURN (-1);
00132 #   endif /* ACE_HAS_PHARLAP_RT */
00133 # endif /* ACE_HAS_PHARLAP */
00134 #elif defined (sun)
00135 
00136   /** obtain the local host name */
00137   char hostname [MAXHOSTNAMELEN];
00138   ACE_OS::hostname (hostname, sizeof (hostname));
00139 
00140   /** Get the hostent to use with ioctl */
00141   struct hostent *phost =
00142     ACE_OS::gethostbyname (hostname);
00143 
00144   if (phost == 0)
00145     return -1;
00146 
00147   ACE_HANDLE handle =
00148     ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
00149 
00150   if (handle == ACE_INVALID_HANDLE)
00151     return -1;
00152 
00153   char **paddrs = phost->h_addr_list;
00154 
00155   struct arpreq ar;
00156 
00157   struct sockaddr_in *psa =
00158     (struct sockaddr_in *)&(ar.arp_pa);
00159 
00160   ACE_OS::memset (&ar,
00161                   0,
00162                   sizeof (struct arpreq));
00163 
00164   psa->sin_family = AF_INET;
00165 
00166   ACE_OS::memcpy (&(psa->sin_addr),
00167                   *paddrs,
00168                   sizeof (struct in_addr));
00169 
00170   if (ACE_OS::ioctl (handle,
00171                      SIOCGARP,
00172                      &ar) == -1)
00173     {
00174       ACE_OS::close (handle);
00175       return -1;
00176     }
00177 
00178   ACE_OS::close (handle);
00179 
00180   ACE_OS::memcpy (node->node,
00181                   ar.arp_ha.sa_data,
00182                   6);
00183 
00184   return 0;
00185 
00186 #elif defined (ACE_LINUX) && !defined (ACE_LACKS_NETWORKING)
00187 
00188   // It's easiest to know the first MAC-using interface. Use the BSD
00189   // getifaddrs function that simplifies access to connected interfaces.
00190   struct ifaddrs *ifap = 0;
00191   struct ifaddrs *p_if = 0;
00192 
00193   if (::getifaddrs (&ifap) != 0)
00194     return -1;
00195 
00196   for (p_if = ifap; p_if != 0; p_if = p_if->ifa_next)
00197     {
00198       if (p_if->ifa_addr == 0)
00199         continue;
00200 
00201       // Check to see if it's up and is not either PPP or loopback
00202       if ((p_if->ifa_flags & IFF_UP) == IFF_UP &&
00203           (p_if->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) == 0)
00204         break;
00205     }
00206   if (p_if == 0)
00207     {
00208       errno = ENODEV;
00209       ::freeifaddrs (ifap);
00210       return -1;
00211     }
00212 
00213   struct ifreq ifr;
00214   ACE_OS::strcpy (ifr.ifr_name, p_if->ifa_name);
00215   ::freeifaddrs (ifap);
00216 
00217   ACE_HANDLE handle =
00218     ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
00219 
00220   if (handle == ACE_INVALID_HANDLE)
00221     return -1;
00222 
00223 # ifdef ACE_LACKS_IOCTL
00224   int info = 0;
00225   if (ACE_OS::posix_devctl (handle, SIOCGIFHWADDR, &ifr, sizeof ifr, &info) < 0)
00226 # else
00227   if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
00228 # endif
00229     {
00230       ACE_OS::close (handle);
00231       return -1;
00232     }
00233 
00234   struct sockaddr* sa =
00235     (struct sockaddr *) &ifr.ifr_addr;
00236 
00237   ACE_OS::close (handle);
00238 
00239   ACE_OS::memcpy (node->node,
00240                   sa->sa_data,
00241                   6);
00242 
00243   return 0;
00244 
00245 #elif defined (__ANDROID_API__) && defined (ACE_HAS_SIOCGIFCONF) && !defined (ACE_LACKS_NETWORKING)
00246 
00247   struct ifconf ifc;
00248   struct ifreq ifr_buf[32];
00249 
00250 
00251   ACE_HANDLE handle =
00252     ACE_OS::socket (AF_INET, SOCK_DGRAM, 0);
00253 
00254   if (handle == ACE_INVALID_HANDLE)
00255     {
00256       return -1;
00257     }
00258 
00259 
00260   ifc.ifc_len = sizeof(ifr_buf);
00261   ifc.ifc_req = &ifr_buf[0];
00262 
00263   if (ACE_OS::ioctl (handle, SIOCGIFCONF, &ifc) < 0)
00264     {
00265       ACE_OS::close (handle);
00266       return -1;
00267     }
00268 
00269   int numif = ifc.ifc_len / sizeof(struct ifreq);
00270 
00271   // find first eligible device
00272   struct ifreq* ifr = 0;
00273   for (int i=0; i< numif ;++i)
00274     {
00275       ifr = &ifr_buf[i];
00276 
00277       // get device flags
00278       if (ACE_OS::ioctl (handle, SIOCGIFFLAGS, ifr) < 0)
00279         {
00280           ACE_OS::close (handle);
00281           return -1;
00282         }
00283 
00284       // Check to see if it's up and is not either PPP or loopback
00285       if ((ifr->ifr_flags & IFF_UP) == IFF_UP &&
00286           (ifr->ifr_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) == 0)
00287         break;
00288 
00289       ifr = 0;
00290     }
00291   // did we find any?
00292   if (ifr == 0)
00293     {
00294       ACE_OS::close (handle);
00295       errno = ENODEV;
00296       return -1;
00297     }
00298 
00299   if (ACE_OS::ioctl (handle, SIOCGIFHWADDR, ifr) < 0)
00300     {
00301       ACE_OS::close (handle);
00302       return -1;
00303     }
00304 
00305   struct sockaddr* sa =
00306     (struct sockaddr *) &ifr->ifr_hwaddr;
00307 
00308   ACE_OS::close (handle);
00309 
00310   ACE_OS::memcpy (node->node,
00311                   sa->sa_data,
00312                   6);
00313 
00314   return 0;
00315 
00316 #elif defined (ACE_HAS_SIOCGIFCONF) && !defined (__ANDROID_API__)
00317 
00318   const long BUFFERSIZE = 4000;
00319   char buffer[BUFFERSIZE];
00320 
00321   struct ifconf ifc;
00322   struct ifreq* ifr = 0;
00323 
00324   ACE_HANDLE handle =
00325     ACE_OS::socket (AF_INET, SOCK_DGRAM, 0);
00326 
00327   if (handle == ACE_INVALID_HANDLE)
00328     {
00329       return -1;
00330     }
00331 
00332   ifc.ifc_len = BUFFERSIZE;
00333   ifc.ifc_buf = buffer;
00334 
00335   if (ACE_OS::ioctl (handle, SIOCGIFCONF, &ifc) < 0)
00336     {
00337       ACE_OS::close (handle);
00338       return -1;
00339     }
00340 
00341   for(char* ptr=buffer; ptr < buffer + ifc.ifc_len; )
00342     {
00343       ifr = (struct ifreq *) ptr;
00344 
00345       if (ifr->ifr_addr.sa_family == AF_LINK)
00346         {
00347           if(ACE_OS::strcmp (ifr->ifr_name, "en0") == 0)
00348             {
00349               struct sockaddr_dl* sdl =
00350                 (struct sockaddr_dl *) &ifr->ifr_addr;
00351 
00352               ACE_OS::memcpy (node->node,
00353                               LLADDR(sdl),
00354                               6);
00355             }
00356         }
00357 
00358       ptr += sizeof(ifr->ifr_name);
00359 
00360       if(sizeof(ifr->ifr_addr) > ifr->ifr_addr.sa_len)
00361         ptr += sizeof(ifr->ifr_addr);
00362       else
00363         ptr += ifr->ifr_addr.sa_len;
00364     }
00365 
00366   ACE_OS::close (handle);
00367 
00368   return 0;
00369 
00370 #elif defined ACE_VXWORKS
00371 
00372   int name[] = {CTL_NET, AF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
00373   static const size_t name_elts = sizeof name / sizeof name[0];
00374 
00375   size_t result_sz = 0u;
00376   if (sysctl (name, name_elts, 0, &result_sz, 0, 0u) != 0)
00377     return -1;
00378 
00379 # ifdef ACE_HAS_ALLOC_HOOKS
00380   char *const result =
00381     static_cast<char *> (ACE_Allocator::instance ()->malloc (result_sz));
00382 #  define ACE_NETDB_CLEANUP ACE_Allocator::instance ()->free (result)
00383 # else
00384   char *const result = static_cast<char *> (ACE_OS::malloc (result_sz));
00385 #  define ACE_NETDB_CLEANUP ACE_OS::free (result)
00386 # endif
00387 
00388   if (sysctl (name, name_elts, result, &result_sz, 0, 0u) != 0)
00389     {
00390       ACE_NETDB_CLEANUP;
00391       return -1;
00392     }
00393 
00394   for (size_t pos = 0, n; pos + sizeof (if_msghdr) < result_sz; pos += n)
00395     {
00396       if_msghdr *const hdr = reinterpret_cast<if_msghdr *> (result + pos);
00397       n = hdr->ifm_msglen;
00398       sockaddr_dl *const addr =
00399         reinterpret_cast<sockaddr_dl *> (result + pos + sizeof (if_msghdr));
00400 
00401       if (addr->sdl_alen >= sizeof node->node)
00402         {
00403           ACE_OS::memcpy (node->node, LLADDR (addr), sizeof node->node);
00404           ACE_NETDB_CLEANUP;
00405           return 0;
00406         }
00407 
00408       while (pos + n < result_sz)
00409         {
00410           ifa_msghdr *const ifa =
00411             reinterpret_cast<ifa_msghdr *> (result + pos + n);
00412           if (ifa->ifam_type != RTM_NEWADDR)
00413             break;
00414           n += ifa->ifam_msglen;
00415         }
00416     }
00417 
00418   ACE_NETDB_CLEANUP;
00419 # undef ACE_NETDB_CLEANUP
00420   return -1;
00421 
00422 #else
00423   ACE_UNUSED_ARG (node);
00424   ACE_NOTSUP_RETURN (-1);
00425 #endif
00426 }

int ACE_OS::getmsg ( ACE_HANDLE  handle,
struct strbuf ctl,
struct strbuf data,
int *  flags 
) [inline]

Definition at line 41 of file OS_NS_stropts.inl.

00045 {
00046   ACE_OS_TRACE ("ACE_OS::getmsg");
00047 #if defined (ACE_HAS_STREAM_PIPES)
00048   ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1);
00049 #else
00050   ACE_UNUSED_ARG (handle);
00051   ACE_UNUSED_ARG (ctl);
00052   ACE_UNUSED_ARG (data);
00053   ACE_UNUSED_ARG (flags);
00054 
00055   // I'm not sure how to implement this correctly.
00056   ACE_NOTSUP_RETURN (-1);
00057 #endif /* ACE_HAS_STREAM_PIPES */
00058 }

int ACE_OS::getnameinfo ( const sockaddr addr,
ACE_SOCKET_LEN  addr_len,
char *  host,
ACE_SOCKET_LEN  host_len,
char *  service,
ACE_SOCKET_LEN  service_len,
unsigned int  flags 
)

Definition at line 796 of file OS_NS_netdb.inl.

00800 {
00801   ACE_OS_TRACE ("ACE_OS::getnameinfo");
00802 #ifdef ACE_LACKS_GETNAMEINFO
00803   ACE_UNUSED_ARG (service);
00804   ACE_UNUSED_ARG (service_len);
00805   ACE_UNUSED_ARG (flags);
00806   return ACE_OS::getnameinfo_emulation (addr, addr_len, host, host_len);
00807 #else
00808   return ::getnameinfo (addr, addr_len, host, host_len,
00809                         service, service_len, flags);
00810 #endif
00811 }

ACE_Export int ACE_OS::getnameinfo_emulation ( const sockaddr addr,
ACE_SOCKET_LEN  addr_len,
char *  host,
ACE_SOCKET_LEN  host_len 
)
int ACE_OS::getopt ( int  argc,
char *const *  argv,
const char *  optstring 
) [inline]

Definition at line 470 of file OS_NS_unistd.inl.

00471 {
00472   ACE_OS_TRACE ("ACE_OS::getopt");
00473 #if defined (ACE_LACKS_GETOPT)
00474   ACE_UNUSED_ARG (argc);
00475   ACE_UNUSED_ARG (argv);
00476   ACE_UNUSED_ARG (optstring);
00477   ACE_NOTSUP_RETURN (-1);
00478 # else
00479   ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1);
00480 # endif /* ACE_LACKS_GETOPT */
00481 }

long ACE_OS::getpagesize ( void   )  [inline]

Definition at line 93 of file OS_NS_unistd.inl.

00094 {
00095   ACE_OS_TRACE ("ACE_OS::getpagesize");
00096 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00097   SYSTEM_INFO sys_info;
00098   ::GetSystemInfo (&sys_info);
00099   return (long) sys_info.dwPageSize;
00100 #elif defined (_SC_PAGESIZE) && !defined (ACE_HAS_NOTSUP_SC_PAGESIZE)
00101   return ::sysconf (_SC_PAGESIZE);
00102 #elif defined (ACE_HAS_GETPAGESIZE)
00103   return ::getpagesize ();
00104 #else
00105   // Use the default set in config.h
00106   return ACE_PAGE_SIZE;
00107 #endif /* ACE_WIN32 */
00108 }

int ACE_OS::getpeername ( ACE_HANDLE  handle,
struct sockaddr addr,
int *  addrlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 185 of file OS_NS_sys_socket.inl.

00187 {
00188   ACE_OS_TRACE ("ACE_OS::getpeername");
00189 
00190 #if defined (ACE_LACKS_GETPEERNAME)
00191   ACE_UNUSED_ARG (handle);
00192   ACE_UNUSED_ARG (addr);
00193   ACE_UNUSED_ARG (addrlen);
00194   ACE_NOTSUP_RETURN (-1);
00195 #elif defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) \
00196            && (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO == 1)
00197   int result;
00198   ACE_SOCKCALL (::getpeername ((ACE_SOCKET) handle,
00199                                addr,
00200                                (ACE_SOCKET_LEN *) addrlen),
00201                int,
00202                 -1,
00203                 result);
00204 
00205   // Some platforms, like older versions of the Linux kernel, do not
00206   // initialize the sin_zero field since that field is generally only
00207   // used for padding/alignment purposes.  On those platforms
00208   // memcmp()-based comparisons of the sockaddr_in structure, such as
00209   // the one in the ACE_INET_Addr equality operator, may fail due to
00210   // random bytes in the sin_zero field even though that field is
00211   // unused.  Prevent equality comparison of two different sockaddr_in
00212   // instances that refer to the same socket from failing by
00213   // explicitly initializing the sockaddr_in::sin_zero field to a
00214   // consistent value, e.g. zero.
00215   if (result != -1 && addr->sa_family == AF_INET)
00216     {
00217       ACE_OS::memset (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero,
00218                       0,
00219                       sizeof (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero));
00220     }
00221 
00222   return result;
00223 #else
00224   ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle,
00225                                       addr,
00226                                       (ACE_SOCKET_LEN *) addrlen),
00227                        int,
00228                        -1);
00229 #endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */
00230 }

pid_t ACE_OS::getpgid ( pid_t  pid  )  [inline]

Definition at line 484 of file OS_NS_unistd.inl.

00485 {
00486   ACE_OS_TRACE ("ACE_OS::getpgid");
00487 #if defined (ACE_LACKS_GETPGID)
00488   ACE_UNUSED_ARG (pid);
00489   ACE_NOTSUP_RETURN (-1);
00490 #elif defined (ACE_LINUX) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0
00491   // getpgid() is from SVR4, which appears to be the reason why GLIBC
00492   // doesn't enable its prototype by default.
00493   // Rather than create our own extern prototype, just use the one
00494   // that is visible (ugh).
00495   ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1);
00496 #else
00497   ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1);
00498 #endif /* ACE_LACKS_GETPGID */
00499 }

pid_t ACE_OS::getpid ( void   )  [inline]

Definition at line 502 of file OS_NS_unistd.inl.

00503 {
00504   // ACE_OS_TRACE ("ACE_OS::getpid");
00505 #if defined (ACE_LACKS_GETPID)
00506   ACE_NOTSUP_RETURN (-1);
00507 #elif defined (ACE_WIN32)
00508   return ::GetCurrentProcessId ();
00509 #else
00510   ACE_OSCALL_RETURN (::getpid (), pid_t, -1);
00511 #endif /* ACE_LACKS_GETPID */
00512 }

int ACE_OS::getpmsg ( ACE_HANDLE  handle,
struct strbuf ctl,
struct strbuf data,
int *  band,
int *  flags 
) [inline]

Definition at line 61 of file OS_NS_stropts.inl.

00066 {
00067   ACE_OS_TRACE ("ACE_OS::getpmsg");
00068 #if defined (ACE_HAS_STREAM_PIPES)
00069   ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1);
00070 #else
00071   ACE_UNUSED_ARG (handle);
00072   ACE_UNUSED_ARG (ctl);
00073   ACE_UNUSED_ARG (data);
00074   ACE_UNUSED_ARG (band);
00075   ACE_UNUSED_ARG (flags);
00076 
00077   // I'm not sure how to implement this correctly.
00078   ACE_NOTSUP_RETURN (-1);
00079 #endif /* ACE_HAS_STREAM_PIPES */
00080 }

pid_t ACE_OS::getppid ( void   )  [inline]

Definition at line 515 of file OS_NS_unistd.inl.

00516 {
00517   ACE_OS_TRACE ("ACE_OS::getppid");
00518 #if defined (ACE_LACKS_GETPPID)
00519   ACE_NOTSUP_RETURN (-1);
00520 #else
00521   ACE_OSCALL_RETURN (::getppid (), pid_t, -1);
00522 #endif /* ACE_LACKS_GETPPID */
00523 }

const char * ACE_OS::getprogname (  )  [inline]

Get the name of the current program

Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.

Definition at line 618 of file OS_NS_stdlib.inl.

00619 {
00620 #if defined (ACE_HAS_GETPROGNAME)
00621   return ::getprogname ();
00622 #else
00623   return ACE_OS::getprogname_emulation ();
00624 #endif /* ACE_HAS_GETPROGNAME */
00625 }

const char * ACE_OS::getprogname_emulation (  ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 1227 of file OS_NS_stdlib.cpp.

01228 {
01229     return __progname;
01230 }

struct protoent * ACE_OS::getprotobyname ( const char *  name  )  [read]

Definition at line 481 of file OS_NS_netdb.inl.

00482 {
00483 #if defined (ACE_LACKS_GETPROTOBYNAME)
00484   ACE_UNUSED_ARG (name);
00485   ACE_NOTSUP_RETURN (0);
00486 #elif defined (ACE_HAS_NONCONST_GETBY)
00487   //FUZZ: disable check_for_lack_ACE_OS
00488   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00489                        struct protoent *,
00490                        0);
00491   //FUZZ: enable check_for_lack_ACE_OS
00492 #else
00493   //FUZZ: disable check_for_lack_ACE_OS
00494   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00495                        struct protoent *,
00496                        0);
00497   //FUZZ: enable check_for_lack_ACE_OS
00498 #endif /* ACE_LACKS_GETPROTOBYNAME */
00499 }

struct protoent * ACE_OS::getprotobyname_r ( const char *  name,
struct protoent result,
ACE_PROTOENT_DATA  buffer 
) [read]

Definition at line 502 of file OS_NS_netdb.inl.

00505 {
00506 #if defined (ACE_LACKS_GETPROTOBYNAME)
00507   ACE_UNUSED_ARG (name);
00508   ACE_UNUSED_ARG (result);
00509   ACE_UNUSED_ARG (buffer);
00510   ACE_NOTSUP_RETURN (0);
00511 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
00512 # if defined (AIX)
00513   //FUZZ: disable check_for_lack_ACE_OS
00514   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
00515     return result;
00516   else
00517     return 0;
00518   //FUZZ: enable check_for_lack_ACE_OS
00519 # elif defined (__GLIBC__)
00520   // GNU C library has a different signature
00521   //FUZZ: disable check_for_lack_ACE_OS
00522   if (::getprotobyname_r (name,
00523                           result,
00524                           buffer,
00525                           sizeof (ACE_PROTOENT_DATA),
00526                           &result) == 0)
00527   //FUZZ: enable check_for_lack_ACE_OS
00528     return result;
00529   else
00530     return 0;
00531 # else
00532 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00533   ACE_UNUSED_ARG (result);
00534   //FUZZ: disable check_for_lack_ACE_OS
00535   ACE_NETDBCALL_RETURN (::getprotobyname (name),
00536                         struct protoent *, 0,
00537                         buffer, sizeof (ACE_PROTOENT_DATA));
00538   //FUZZ: enable check_for_lack_ACE_OS
00539 #   else
00540     //FUZZ: disable check_for_lack_ACE_OS
00541     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
00542                                              result,
00543                                              buffer,
00544                                              sizeof (ACE_PROTOENT_DATA)),
00545                        struct protoent *, 0);
00546     //FUZZ: enable check_for_lack_ACE_OS
00547 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00548 # endif /* defined (AIX) */
00549 #elif defined (ACE_HAS_NONCONST_GETBY)
00550   ACE_UNUSED_ARG (result);
00551   ACE_UNUSED_ARG (buffer);
00552   //FUZZ: disable check_for_lack_ACE_OS
00553   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00554                        struct protoent *, 0);
00555   //FUZZ: enable check_for_lack_ACE_OS
00556 #else
00557   ACE_UNUSED_ARG (buffer);
00558   ACE_UNUSED_ARG (result);
00559 
00560   //FUZZ: disable check_for_lack_ACE_OS
00561   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00562                        struct protoent *,
00563                        0);
00564   //FUZZ: enable check_for_lack_ACE_OS
00565 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) */
00566 }

struct protoent * ACE_OS::getprotobynumber ( int  proto  )  [read]

Definition at line 569 of file OS_NS_netdb.inl.

00570 {
00571 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00572   ACE_UNUSED_ARG (proto);
00573   ACE_NOTSUP_RETURN (0);
00574 #else
00575   //FUZZ: disable check_for_lack_ACE_OS
00576   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00577                        struct protoent *, 0);
00578   //FUZZ: enable check_for_lack_ACE_OS
00579 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
00580 }

struct protoent * ACE_OS::getprotobynumber_r ( int  proto,
struct protoent result,
ACE_PROTOENT_DATA  buffer 
) [read]

Definition at line 583 of file OS_NS_netdb.inl.

00586 {
00587 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00588   ACE_UNUSED_ARG (proto);
00589   ACE_UNUSED_ARG (result);
00590   ACE_UNUSED_ARG (buffer);
00591   ACE_NOTSUP_RETURN (0);
00592 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
00593 # if defined (AIX)
00594   //FUZZ: disable check_for_lack_ACE_OS
00595   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
00596     return result;
00597   //FUZZ: enable check_for_lack_ACE_OS
00598   else
00599     return 0;
00600 # elif defined (__GLIBC__)
00601   // GNU C library has a different signature
00602   //FUZZ: disable check_for_lack_ACE_OS
00603   if (::getprotobynumber_r (proto,
00604                             result,
00605                             buffer,
00606                             sizeof (ACE_PROTOENT_DATA),
00607                             &result) == 0)
00608   //FUZZ: enable check_for_lack_ACE_OS
00609     return result;
00610   else
00611     return 0;
00612 # else
00613 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00614   ACE_UNUSED_ARG (result);
00615   //FUZZ: disable check_for_lack_ACE_OS
00616   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
00617                         struct protoent *, 0,
00618                         buffer, sizeof (ACE_PROTOENT_DATA));
00619   //FUZZ: enable check_for_lack_ACE_OS
00620 #   else
00621   //FUZZ: disable check_for_lack_ACE_OS
00622   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
00623                        struct protoent *, 0);
00624   //FUZZ: enable check_for_lack_ACE_OS
00625 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00626 # endif /* defined (AIX) */
00627 #else
00628   ACE_UNUSED_ARG (buffer);
00629   ACE_UNUSED_ARG (result);
00630 
00631   //FUZZ: disable check_for_lack_ACE_OS
00632   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00633                        struct protoent *, 0);
00634   //FUZZ: enable check_for_lack_ACE_OS
00635 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) */
00636 }

struct passwd * ACE_OS::getpwent ( void   )  [read]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 17 of file OS_NS_pwd.inl.

00018 {
00019 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00020   return ::getpwent ();
00021 #else
00022   ACE_NOTSUP_RETURN (0);
00023 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00024 }

struct passwd * ACE_OS::getpwnam ( const char *  user  )  [read]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 27 of file OS_NS_pwd.inl.

00028 {
00029 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00030   return ::getpwnam (name);
00031 # else
00032   ACE_UNUSED_ARG (name);
00033   ACE_NOTSUP_RETURN (0);
00034 #endif /* ACE_LACKS_PWD_FUNCTIONS */
00035 }

int ACE_OS::getpwnam_r ( const char *  name,
struct passwd *  pwd,
char *  buffer,
size_t  bufsize,
struct passwd **  result 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 38 of file OS_NS_pwd.inl.

00043 {
00044 #if defined (ACE_LACKS_PWD_FUNCTIONS)
00045   ACE_UNUSED_ARG (name);
00046   ACE_UNUSED_ARG (pwd);
00047   ACE_UNUSED_ARG (buffer);
00048   ACE_UNUSED_ARG (bufsize);
00049   ACE_UNUSED_ARG (result);
00050   ACE_NOTSUP_RETURN (0);
00051 #elif defined (ACE_HAS_LYNXOS4_GETPWNAM_R)
00052   if (::getpwnam_r (pwd, const_cast<char*>(name), buffer, bufsize) == -1)
00053     {
00054       *result = 0;
00055       return -1;
00056     }
00057   *result = pwd;
00058   return 0;
00059 #elif defined (ACE_HAS_STHREADS)
00060   if (::getpwnam_r (name, pwd, buffer, bufsize) != 0)
00061     {
00062       *result = 0;
00063       return -1;
00064     }
00065   *result = pwd;
00066   return 0;
00067 #else
00068   return ::getpwnam_r (name, pwd, buffer, bufsize, result);
00069 #endif /* ACE_LACKS_PWD_FUNCTIONS */
00070 }

int ACE_OS::getrlimit ( int  resource,
struct rlimit *  rl 
)

Definition at line 8 of file OS_NS_sys_resource.inl.

00009 {
00010   ACE_OS_TRACE ("ACE_OS::getrlimit");
00011 
00012 #if defined (ACE_LACKS_RLIMIT)
00013   ACE_UNUSED_ARG (resource);
00014   ACE_UNUSED_ARG (rl);
00015 
00016   ACE_NOTSUP_RETURN (-1);
00017 #else
00018 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
00019   ACE_OSCALL_RETURN (::getrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1);
00020 # else
00021   ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1);
00022 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00023 #endif /* ACE_LACKS_RLIMIT */
00024 }

int ACE_OS::getrusage ( int  who,
struct rusage rusage 
)

Definition at line 27 of file OS_NS_sys_resource.inl.

00028 {
00029   ACE_OS_TRACE ("ACE_OS::getrusage");
00030 
00031 #if defined (ACE_HAS_GETRUSAGE)
00032 # if defined (ACE_WIN32)
00033   ACE_UNUSED_ARG (who);
00034 
00035 #  if defined (ACE_LACKS_GETPROCESSTIMES)
00036   ACE_UNUSED_ARG (ru);
00037   ACE_NOTSUP_RETURN (-1);
00038 #  else
00039   FILETIME dummy_1;
00040   FILETIME dummy_2;
00041   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetProcessTimes (::GetCurrentProcess(),
00042                                                              &dummy_1,   // start
00043                                                              &dummy_2,     // exited
00044                                                              &ru->ru_stime,
00045                                                              &ru->ru_utime),
00046                                           ace_result_),
00047                         int, -1);
00048 #  endif /* ACE_LACKS_WIN32_GETPROCESSTIMES */
00049 # else
00050 #   if defined (ACE_HAS_RUSAGE_WHO_ENUM)
00051   ACE_OSCALL_RETURN (::getrusage ((ACE_HAS_RUSAGE_WHO_ENUM) who, ru), int, -1);
00052 #   else
00053   ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1);
00054 #   endif /* ACE_HAS_RUSAGE_WHO_ENUM */
00055 # endif /* ACE_WIN32 */
00056 #else
00057   ACE_UNUSED_ARG (who);
00058   ACE_UNUSED_ARG (ru);
00059   ACE_NOTSUP_RETURN (-1);
00060 #endif /* ACE_HAS_GETRUSAGE */
00061 }

struct servent * ACE_OS::getservbyname ( const char *  svc,
const char *  proto 
) [read]

Definition at line 639 of file OS_NS_netdb.inl.

00640 {
00641   ACE_OS_TRACE ("ACE_OS::getservbyname");
00642 #if defined (ACE_LACKS_GETSERVBYNAME)
00643   ACE_UNUSED_ARG (svc);
00644   ACE_UNUSED_ARG (proto);
00645   ACE_NOTSUP_RETURN (0);
00646 #elif defined (ACE_HAS_NONCONST_GETBY)
00647   //FUZZ: disable check_for_lack_ACE_OS
00648   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00649                                         const_cast<char *> (proto)),
00650                        struct servent *,
00651                        0);
00652   //FUZZ: enable check_for_lack_ACE_OS
00653 #else
00654   //FUZZ: disable check_for_lack_ACE_OS
00655   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00656                                         proto),
00657                        struct servent *,
00658                        0);
00659   //FUZZ: enable check_for_lack_ACE_OS
00660 #endif /* ACE_HAS_NONCONST_GETBY */
00661 }

struct servent * ACE_OS::getservbyname_r ( const char *  svc,
const char *  proto,
struct servent result,
ACE_SERVENT_DATA  buf 
) [read]

Definition at line 664 of file OS_NS_netdb.inl.

00668 {
00669   ACE_OS_TRACE ("ACE_OS::getservbyname_r");
00670 #if defined (ACE_LACKS_GETSERVBYNAME)
00671   ACE_UNUSED_ARG (svc);
00672   ACE_UNUSED_ARG (proto);
00673   ACE_UNUSED_ARG (result);
00674   ACE_UNUSED_ARG (buf);
00675   ACE_NOTSUP_RETURN (0);
00676 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
00677 # if defined (AIX)
00678   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00679 
00680   //FUZZ: disable check_for_lack_ACE_OS
00681   if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0)
00682     return result;
00683   //FUZZ: enable check_for_lack_ACE_OS
00684   else
00685     return (struct servent *) 0;
00686 # elif defined (__GLIBC__)
00687   // GNU C library has a different signature
00688   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00689 
00690   //FUZZ: disable check_for_lack_ACE_OS
00691   if (::getservbyname_r (svc,
00692                          proto,
00693                          result,
00694                          buf,
00695                          sizeof (ACE_SERVENT_DATA),
00696                          &result) == 0)
00697     return result;
00698   //FUZZ: enable check_for_lack_ACE_OS
00699   else
00700     return (struct servent *) 0;
00701 # else
00702 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00703   ACE_UNUSED_ARG (result);
00704   //FUZZ: disable check_for_lack_ACE_OS
00705   ACE_NETDBCALL_RETURN (::getservbyname (svc, proto),
00706                         struct servent *, 0,
00707                         buf, sizeof (ACE_SERVENT_DATA));
00708   //FUZZ: enable check_for_lack_ACE_OS
00709 #   else
00710   //FUZZ: disable check_for_lack_ACE_OS
00711   ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf,
00712                                           sizeof (ACE_SERVENT_DATA)),
00713                        struct servent *, 0);
00714   //FUZZ: enable check_for_lack_ACE_OS
00715 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00716 # endif /* defined (AIX) */
00717 #elif defined (ACE_HAS_NONCONST_GETBY)
00718   ACE_UNUSED_ARG (buf);
00719   ACE_UNUSED_ARG (result);
00720   //FUZZ: disable check_for_lack_ACE_OS
00721   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00722                                         const_cast<char *> (proto)),
00723                        struct servent *,
00724                        0);
00725   //FUZZ: enable check_for_lack_ACE_OS
00726 #else
00727   ACE_UNUSED_ARG (buf);
00728   ACE_UNUSED_ARG (result);
00729   //FUZZ: disable check_for_lack_ACE_OS
00730   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00731                                         proto),
00732                        struct servent *,
00733                        0);
00734   //FUZZ: enable check_for_lack_ACE_OS
00735 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) */
00736 }

int ACE_OS::getsockname ( ACE_HANDLE  handle,
struct sockaddr addr,
int *  addrlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 233 of file OS_NS_sys_socket.inl.

00236 {
00237   ACE_OS_TRACE ("ACE_OS::getsockname");
00238 #if defined (ACE_LACKS_GETSOCKNAME)
00239   ACE_UNUSED_ARG (handle);
00240   ACE_UNUSED_ARG (addr);
00241   ACE_UNUSED_ARG (addrlen);
00242   ACE_NOTSUP_RETURN (-1);
00243 #elif defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) \
00244            && (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO == 1)
00245   int result;
00246   ACE_SOCKCALL (::getsockname ((ACE_SOCKET) handle,
00247                                addr,
00248                                (ACE_SOCKET_LEN *) addrlen),
00249                int, -1, result);
00250 
00251   // Some platforms, like older versions of the Linux kernel, do not
00252   // initialize the sin_zero field since that field is generally only
00253   // used for padding/alignment purposes.  On those platforms
00254   // memcmp()-based comparisons of the sockaddr_in structure, such as
00255   // the one in the ACE_INET_Addr equality operator, may fail due to
00256   // random bytes in the sin_zero field even though that field is
00257   // unused.  Prevent equality comparison of two different sockaddr_in
00258   // instances that refer to the same socket from failing by
00259   // explicitly initializing the sockaddr_in::sin_zero field to a
00260   // consistent value, e.g. zero.
00261   if (result != -1 && addr->sa_family == AF_INET)
00262     {
00263       ACE_OS::memset (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero,
00264                       0,
00265                       sizeof (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero));
00266     }
00267 
00268   return result;
00269 #else
00270   ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle,
00271                                       addr,
00272                                       (ACE_SOCKET_LEN *) addrlen),
00273                        int, -1);
00274 #endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */
00275 }

int ACE_OS::getsockopt ( ACE_HANDLE  handle,
int  level,
int  optname,
char *  optval,
int *  optlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 278 of file OS_NS_sys_socket.inl.

00283 {
00284   ACE_OS_TRACE ("ACE_OS::getsockopt");
00285 #if defined (ACE_LACKS_GETSOCKOPT)
00286   ACE_UNUSED_ARG (handle);
00287   ACE_UNUSED_ARG (level);
00288   ACE_UNUSED_ARG (optname);
00289   ACE_UNUSED_ARG (optval);
00290   ACE_UNUSED_ARG (optlen);
00291   ACE_NOTSUP_RETURN (-1);
00292 #else
00293   ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle,
00294                                      level,
00295                                      optname,
00296                                      optval,
00297                                      (ACE_SOCKET_LEN *) optlen),
00298                        int,
00299                        -1);
00300 #endif /* ACE_LACKS_GETSOCKOPT */
00301 }

ACE_Time_Value ACE_OS::gettimeofday ( void   ) 

Definition at line 12 of file OS_NS_sys_time.inl.

00013 {
00014   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
00015 
00016 #if !defined (ACE_WIN32)
00017   timeval tv;
00018   int result = 0;
00019 #endif // !defined (ACE_WIN32)
00020 
00021 #if defined (ACE_LACKS_GETTIMEOFDAY) && defined (ACE_HAS_CLOCK_GETTIME)
00022   timespec ts;
00023   if (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts) == -1)
00024     {
00025       return ACE_Time_Value (-1);
00026     }
00027 
00028   return ACE_Time_Value (ts);
00029 
00030 #elif defined (ACE_WIN32) && defined (ACE_LACKS_GETSYSTEMTIMEASFILETIME)
00031   SYSTEMTIME tsys;
00032   FILETIME   tfile;
00033   ::GetSystemTime (&tsys);
00034   ::SystemTimeToFileTime (&tsys, &tfile);
00035   return ACE_Time_Value (tfile);
00036 #elif defined (ACE_WIN32)
00037   FILETIME   tfile;
00038   ::GetSystemTimeAsFileTime (&tfile);
00039   return ACE_Time_Value (tfile);
00040 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00041   timebasestruct_t tb;
00042 
00043   ::read_real_time (&tb, TIMEBASE_SZ);
00044   ::time_base_to_time (&tb, TIMEBASE_SZ);
00045 
00046   tv.tv_sec = tb.tb_high;
00047   tv.tv_usec = tb.tb_low / 1000L;
00048 #else
00049 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00050   defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
00051   (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (SCO))
00052   ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00053 # elif defined (ACE_VXWORKS)
00054   // Assumes that struct timespec is same size as struct timeval,
00055   // which assumes that time_t is a long: it currently (VxWorks
00056   // 5.2/5.3) is.
00057   struct timespec ts;
00058 
00059   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00060   tv.tv_sec = ts.tv_sec;
00061   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00062 # else
00063 #  if defined (ACE_LACKS_GETTIMEOFDAY)
00064   ACE_NOTSUP_RETURN (ACE_Time_Value ((time_t)-1));
00065 #  else
00066   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00067 #  endif /* ACE_LACKS_GETTIMEOFDAY */
00068 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
00069 #endif /* 0 */
00070 #if !defined (ACE_WIN32)
00071   if (result == -1)
00072     return ACE_Time_Value ((time_t)-1);
00073   else
00074     return ACE_Time_Value (tv);
00075 #endif // !defined (ACE_WIN32)
00076 }

ACE_Time_Value ACE_OS::gettimeofday_ ( void   ) 

Definition at line 79 of file OS_NS_sys_time.inl.

00080 {
00081   return ACE_OS::gettimeofday ();
00082 }

uid_t ACE_OS::getuid ( void   )  [inline]

Definition at line 526 of file OS_NS_unistd.inl.

00527 {
00528   ACE_OS_TRACE ("ACE_OS::getuid");
00529 #if defined (ACE_LACKS_GETUID)
00530   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00531 # else
00532   ACE_OSCALL_RETURN (::getuid (), uid_t, static_cast<uid_t> (-1));
00533 # endif /* ACE_LACKS_GETUID*/
00534 }

struct tm * ACE_OS::gmtime ( const time_t *  clock  )  [read]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 362 of file OS_NS_time.inl.

00363 {
00364   ACE_OS_TRACE ("ACE_OS::gmtime");
00365 #if defined (ACE_LACKS_GMTIME)
00366   ACE_UNUSED_ARG (t);
00367   ACE_NOTSUP_RETURN (0);
00368 #else
00369   ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
00370 #endif /* ACE_LACKS_GMTIME */
00371 }

struct tm * ACE_OS::gmtime_r ( const time_t *  clock,
struct tm res 
) [read]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 374 of file OS_NS_time.inl.

00375 {
00376   ACE_OS_TRACE ("ACE_OS::gmtime_r");
00377 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00378   return ace_gmtime_r_helper (t, res);
00379 #elif defined (ACE_HAS_TR24731_2005_CRT)
00380   struct tm *tm_p = res;
00381   ACE_SECURECRTCALL (gmtime_s (res, t), struct tm *, 0, tm_p);
00382   return tm_p;
00383 #elif defined (ACE_LACKS_GMTIME)
00384   ACE_UNUSED_ARG (t);
00385   ACE_UNUSED_ARG (res);
00386   ACE_NOTSUP_RETURN (0);
00387 #else
00388   struct tm *result;
00389   ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ;
00390   if (result != 0)
00391     *res = *result;
00392   return res;
00393 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00394 }

int ACE_OS::hostname ( wchar_t  name[],
size_t  maxnamelen 
) [inline]

Definition at line 591 of file OS_NS_unistd.inl.

00592 {
00593 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00594   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (GetComputerNameW (name,
00595                                                         LPDWORD (&maxnamelen)),
00596                                           ace_result_), int, -1);
00597 #else /* ACE_WIN32 && !ACE_HAS_WINCE */
00598   // Emulate using the char version
00599   char *char_name = 0;
00600 
00601   ACE_NEW_RETURN (char_name, char[maxnamelen], -1);
00602 
00603   int result = ACE_OS::hostname(char_name, maxnamelen);
00604   ACE_OS::strcpy (name, ACE_Ascii_To_Wide (char_name).wchar_rep ());
00605 
00606   delete [] char_name;
00607   return result;
00608 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */
00609 }

int ACE_OS::hostname ( char  name[],
size_t  maxnamelen 
) [inline]

Definition at line 548 of file OS_NS_unistd.inl.

00549 {
00550   ACE_OS_TRACE ("ACE_OS::hostname");
00551 #if defined (ACE_HAS_PHARLAP)
00552   // PharLap only can do net stuff with the RT version.
00553 #   if defined (ACE_HAS_PHARLAP_RT)
00554   // @@This is not at all reliable... requires ethernet and BOOTP to be used.
00555   // A more reliable way is to go thru the devices w/ EtsTCPGetDeviceCfg until
00556   // a legit IP address is found, then get its name w/ gethostbyaddr.
00557   ACE_SOCKCALL_RETURN (gethostname (name, maxnamelen), int, SOCKET_ERROR);
00558 #   else
00559   ACE_UNUSED_ARG (name);
00560   ACE_UNUSED_ARG (maxnamelen);
00561   ACE_NOTSUP_RETURN (-1);
00562 #   endif /* ACE_HAS_PHARLAP_RT */
00563 #elif defined (ACE_VXWORKS) || defined (ACE_HAS_WINCE)
00564   ACE_OSCALL_RETURN (::gethostname (name, maxnamelen), int, -1);
00565 #elif defined (ACE_WIN32)
00566   if (::gethostname (name, ACE_Utils::truncate_cast<int> (maxnamelen)) == 0)
00567   {
00568     return 0;
00569   }
00570   else
00571   {
00572     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name,
00573                                             LPDWORD (&maxnamelen)),
00574                                             ace_result_), int, -1);
00575   }
00576 #else /* ACE_HAS_PHARLAP */
00577   ACE_utsname host_info;
00578 
00579   if (ACE_OS::uname (&host_info) == -1)
00580     return -1;
00581   else
00582     {
00583       ACE_OS::strsncpy (name, host_info.nodename, maxnamelen);
00584       return 0;
00585     }
00586 #endif /* ACE_HAS_PHARLAP */
00587 }

unsigned long ACE_OS::inet_addr ( const char *  name  ) 

Definition at line 9 of file OS_NS_arpa_inet.inl.

00010 {
00011   ACE_OS_TRACE ("ACE_OS::inet_addr");
00012 #if defined (ACE_LACKS_INET_ADDR)
00013   ACE_UNUSED_ARG (name);
00014   ACE_NOTSUP_RETURN (0);
00015 #elif defined (ACE_HAS_NONCONST_INET_ADDR)
00016   return ::inet_addr (const_cast <char*> (name));
00017 #else
00018   return ::inet_addr (name);
00019 #endif /* ACE_HAS_NONCONST_INET_ADDR */
00020 }

int ACE_OS::inet_aton ( const char *  strptr,
struct in_addr addr 
)

Definition at line 15 of file OS_NS_arpa_inet.cpp.

00016 {
00017 #if defined (ACE_LACKS_INET_ATON)
00018 #  if defined (ACE_WIN32)
00019   // Windows Server 2003 changed the behavior of a zero-length input
00020   // string to inet_addr(). It used to return 0 (INADDR_ANY) but now
00021   // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space
00022   // string, though, as do previous versions of Windows.
00023   if (host_name == 0 || host_name[0] == '\0')
00024     host_name = " ";
00025 #  endif /* ACE_WIN32 */
00026 
00027 #  if defined (ACE_LACKS_INET_ADDR)
00028   if (!host_name)
00029     return 0;
00030   ACE_UINT32 ip = 0;
00031   int part = 0;
00032   for (const char *dot; *host_name; host_name = *dot ? dot + 1 : dot, ++part)
00033     {
00034       if (part > 3)
00035         return 0;
00036       dot = ACE_OS::strchr (host_name, '.');
00037       if (!dot)
00038         dot = host_name + ACE_OS::strlen (host_name);
00039       char *last;
00040       const unsigned long n = std::strtoul (host_name, &last, 0);
00041       if (last != dot)
00042         return 0;
00043       if (!*dot)
00044         switch (part)
00045           {
00046           case 0:
00047 #    if ACE_SIZEOF_LONG > 4
00048             if (n > 0xffffffff)
00049               return 0;
00050 #    endif
00051             ip = static_cast<ACE_UINT32> (n);
00052             continue;
00053           case 1:
00054             if (n > 0xffffff)
00055               return 0;
00056             ip <<= 24;
00057             ip |= n;
00058             continue;
00059           case 2:
00060             if (n > 0xffff)
00061               return 0;
00062             ip <<= 16;
00063             ip |= n;
00064             continue;
00065           }
00066       if (n > 0xff)
00067         return 0;
00068       ip <<= 8;
00069       ip |= n;
00070     }
00071   addr->s_addr = ACE_HTONL (ip);
00072   return 1;
00073 #  else
00074   unsigned long ip_addr = ACE_OS::inet_addr (host_name);
00075 
00076   if (ip_addr == INADDR_NONE
00077       // Broadcast addresses are weird...
00078       && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
00079     return 0;
00080   else if (addr == 0)
00081     return 0;
00082   else
00083     {
00084       addr->s_addr = ip_addr;  // Network byte ordered
00085       return 1;
00086     }
00087 #  endif // ACE_LACKS_INET_ADDR
00088 #elif defined (ACE_VXWORKS)
00089   // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
00090   // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
00091   ::errnoSet(0);
00092   int result = ERROR;
00093   ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result);
00094   return (result == ERROR) ? 0 : 1;
00095 #else
00096   // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
00097   // address (255.255.255.255).
00098   ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
00099 #endif  /* ACE_LACKS_INET_ATON */
00100 }

char * ACE_OS::inet_ntoa ( const struct in_addr  addr  ) 

Definition at line 23 of file OS_NS_arpa_inet.inl.

00024 {
00025   ACE_OS_TRACE ("ACE_OS::inet_ntoa");
00026 #if defined (ACE_LACKS_INET_NTOA)
00027   ACE_UNUSED_ARG (addr);
00028   ACE_NOTSUP_RETURN (0);
00029 #else
00030   ACE_OSCALL_RETURN (::inet_ntoa (addr), char *, 0);
00031 #endif
00032 }

const char * ACE_OS::inet_ntop ( int  family,
const void *  addrptr,
char *  strptr,
size_t  len 
)

Definition at line 35 of file OS_NS_arpa_inet.inl.

00036 {
00037   ACE_OS_TRACE ("ACE_OS::inet_ntop");
00038 
00039 #if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_NTOP
00040 #  if defined (ACE_HAS_NONCONST_INET_NTOP)
00041   ACE_OSCALL_RETURN (::inet_ntop (family, const_cast<void *> (addrptr), strptr, len), const char *, 0);
00042 #  else
00043   ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0);
00044 #  endif
00045 #else
00046 
00047   if (family == AF_INET)
00048     {
00049       const u_char *const p = reinterpret_cast<const u_char *> (addrptr);
00050       if (ACE_OS::snprintf (strptr, len, "%d.%d.%d.%d", p[0], p[1], p[2], p[3])
00051           > static_cast<int> (len))
00052         {
00053           errno = ENOSPC;
00054           return 0; // Failure
00055         }
00056       return strptr;
00057     }
00058 
00059   errno = EAFNOSUPPORT;
00060   return 0;
00061 #endif
00062 }

int ACE_OS::inet_pton ( int  family,
const char *  strptr,
void *  addrptr 
)

Definition at line 65 of file OS_NS_arpa_inet.inl.

00066 {
00067   ACE_OS_TRACE ("ACE_OS::inet_pton");
00068 
00069 #if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_PTON
00070   ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1);
00071 #else
00072 
00073   if (family == AF_INET)
00074     {
00075       if (ACE_OS::inet_aton (strptr, static_cast<in_addr *> (addrptr)))
00076         return 1; // Success
00077 
00078       return 0; // Input is not a valid presentation format
00079     }
00080 
00081   errno = EAFNOSUPPORT;
00082   return 0;
00083 #endif
00084 }

int ACE_OS::ioctl ( ACE_HANDLE  socket,
unsigned long  io_control_code,
ACE_QoS ace_qos,
unsigned long *  bytes_returned,
void *  buffer_p = 0,
unsigned 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.

Definition at line 49 of file OS_NS_stropts.cpp.

00057 {
00058 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00059 
00060   QOS qos;
00061   unsigned long qos_len = sizeof (QOS);
00062 
00063   if (io_control_code == SIO_SET_QOS)
00064     {
00065       qos.SendingFlowspec = *(ace_qos.sending_flowspec ());
00066       qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ());
00067       qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific ();
00068 
00069       qos_len += ace_qos.provider_specific ().iov_len;
00070 
00071       ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
00072                                        io_control_code,
00073                                        &qos,
00074                                        qos_len,
00075                                        buffer_p,
00076                                        buffer,
00077                                        bytes_returned,
00078                                        (WSAOVERLAPPED *) overlapped,
00079                                        func),
00080                            int,
00081                            SOCKET_ERROR);
00082     }
00083   else
00084     {
00085       unsigned long dwBufferLen = 0;
00086 
00087       // Query for the buffer size.
00088       int result = ::WSAIoctl ((ACE_SOCKET) socket,
00089                                 io_control_code,
00090                                 0,
00091                                 0,
00092                                 &dwBufferLen,
00093                                 sizeof (dwBufferLen),
00094                                 bytes_returned,
00095                                 0,
00096                                 0);
00097 
00098 
00099       if (result == SOCKET_ERROR)
00100         {
00101           unsigned long dwErr = ::WSAGetLastError ();
00102 
00103           if (dwErr == WSAEWOULDBLOCK)
00104             {
00105               errno = dwErr;
00106               return -1;
00107             }
00108           else
00109             if (dwErr != WSAENOBUFS)
00110               {
00111                 errno = dwErr;
00112                 return -1;
00113               }
00114           }
00115 
00116     char *qos_buf = 0;
00117     ACE_NEW_RETURN (qos_buf,
00118                     char [dwBufferLen],
00119                     -1);
00120 
00121     QOS *qos = reinterpret_cast<QOS*> (qos_buf);
00122 
00123     result = ::WSAIoctl ((ACE_SOCKET) socket,
00124                        io_control_code,
00125                        0,
00126                        0,
00127                        qos,
00128                        dwBufferLen,
00129                        bytes_returned,
00130                        0,
00131                        0);
00132 
00133     if (result == SOCKET_ERROR)
00134       return result;
00135 
00136     ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate,
00137                                     qos->SendingFlowspec.TokenBucketSize,
00138                                     qos->SendingFlowspec.PeakBandwidth,
00139                                     qos->SendingFlowspec.Latency,
00140                                     qos->SendingFlowspec.DelayVariation,
00141 #  if defined(ACE_HAS_WINSOCK2_GQOS)
00142                                     qos->SendingFlowspec.ServiceType,
00143                                     qos->SendingFlowspec.MaxSduSize,
00144                                     qos->SendingFlowspec.MinimumPolicedSize,
00145 #  else /* ACE_HAS_WINSOCK2_GQOS */
00146                                     0,
00147                                     0,
00148                                     0,
00149 #  endif /* ACE_HAS_WINSOCK2_GQOS */
00150                                     0,
00151                                     0);
00152 
00153     ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate,
00154                                       qos->ReceivingFlowspec.TokenBucketSize,
00155                                       qos->ReceivingFlowspec.PeakBandwidth,
00156                                       qos->ReceivingFlowspec.Latency,
00157                                       qos->ReceivingFlowspec.DelayVariation,
00158 #  if defined(ACE_HAS_WINSOCK2_GQOS)
00159                                       qos->ReceivingFlowspec.ServiceType,
00160                                       qos->ReceivingFlowspec.MaxSduSize,
00161                                       qos->ReceivingFlowspec.MinimumPolicedSize,
00162 #  else /* ACE_HAS_WINSOCK2_GQOS */
00163                                       0,
00164                                       0,
00165                                       0,
00166 #  endif /* ACE_HAS_WINSOCK2_GQOS */
00167                                       0,
00168                                       0);
00169 
00170        ace_qos.sending_flowspec (&sending_flowspec);
00171        ace_qos.receiving_flowspec (&receiving_flowspec);
00172        ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific)));
00173 
00174 
00175       return result;
00176     }
00177 
00178 # else
00179   ACE_UNUSED_ARG (socket);
00180   ACE_UNUSED_ARG (io_control_code);
00181   ACE_UNUSED_ARG (ace_qos);
00182   ACE_UNUSED_ARG (bytes_returned);
00183   ACE_UNUSED_ARG (buffer_p);
00184   ACE_UNUSED_ARG (buffer);
00185   ACE_UNUSED_ARG (overlapped);
00186   ACE_UNUSED_ARG (func);
00187   ACE_NOTSUP_RETURN (-1);
00188 # endif /* ACE_HAS_WINSOCK2 */
00189 }

int ACE_OS::ioctl ( ACE_HANDLE  socket,
unsigned long  io_control_code,
void *  in_buffer_p,
unsigned long  in_buffer,
void *  out_buffer_p,
unsigned long  out_buffer,
unsigned long *  bytes_returned,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func 
)

QoS-enabled ioctl.

Definition at line 12 of file OS_NS_stropts.cpp.

00021 {
00022 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00023   ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
00024                                    io_control_code,
00025                                    in_buffer_p,
00026                                    in_buffer,
00027                                    out_buffer_p,
00028                                    out_buffer,
00029                                    bytes_returned,
00030                                    (WSAOVERLAPPED *) overlapped,
00031                                    func),
00032                        int,
00033                        SOCKET_ERROR);
00034 # else
00035   ACE_UNUSED_ARG (socket);
00036   ACE_UNUSED_ARG (io_control_code);
00037   ACE_UNUSED_ARG (in_buffer_p);
00038   ACE_UNUSED_ARG (in_buffer);
00039   ACE_UNUSED_ARG (out_buffer_p);
00040   ACE_UNUSED_ARG (out_buffer);
00041   ACE_UNUSED_ARG (bytes_returned);
00042   ACE_UNUSED_ARG (overlapped);
00043   ACE_UNUSED_ARG (func);
00044   ACE_NOTSUP_RETURN (-1);
00045 # endif /* ACE_HAS_WINSOCK2 */
00046 }

int ACE_OS::ioctl ( ACE_HANDLE  handle,
ACE_IOCTL_TYPE_ARG2  cmd,
void *  val = 0 
) [inline]

UNIX-style ioctl.

Definition at line 110 of file OS_NS_stropts.inl.

00113 {
00114   ACE_OS_TRACE ("ACE_OS::ioctl");
00115 #if defined (ACE_LACKS_IOCTL)
00116   ACE_UNUSED_ARG (handle);
00117   ACE_UNUSED_ARG (cmd);
00118   ACE_UNUSED_ARG (val);
00119   ACE_NOTSUP_RETURN (-1);
00120 #elif defined (ACE_WIN32)
00121   ACE_SOCKET sock = (ACE_SOCKET) handle;
00122   ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
00123 #elif defined (ACE_HAS_IOCTL_INT_3_PARAM)
00124   ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)),
00125                      int, -1);
00126 #else
00127   ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
00128 #endif /* ACE_WIN32 */
00129 }

int ACE_OS::isastream ( ACE_HANDLE  handle  )  [inline]

Definition at line 132 of file OS_NS_stropts.inl.

00133 {
00134   ACE_OS_TRACE ("ACE_OS::isastream");
00135 #if defined (ACE_HAS_STREAM_PIPES)
00136   ACE_OSCALL_RETURN (::isastream (handle), int, -1);
00137 #else
00138   ACE_UNUSED_ARG (handle);
00139 
00140   ACE_NOTSUP_RETURN (-1);
00141 #endif /* ACE_HAS_STREAM_PIPES */
00142 }

int ACE_OS::isatty ( ACE_HANDLE  handle  )  [inline]

Definition at line 628 of file OS_NS_unistd.inl.

00629 {
00630 #if defined (ACE_LACKS_ISATTY)
00631   ACE_UNUSED_ARG (handle);
00632   return 0;
00633 #else
00634   int const fd = ::_open_osfhandle (intptr_t (handle), 0);
00635   int status = 0;
00636   if (fd != -1)
00637     {
00638       status = ::_isatty (fd);
00639       ::_close (fd);
00640     }
00641   return status;
00642 #endif /* ACE_LACKS_ISATTY */
00643 }

int ACE_OS::isatty ( int  handle  )  [inline]

Definition at line 613 of file OS_NS_unistd.inl.

00614 {
00615   ACE_OS_TRACE ("ACE_OS::isatty");
00616 #if defined (ACE_LACKS_ISATTY)
00617   ACE_UNUSED_ARG (handle);
00618   return 0;
00619 # elif defined (ACE_WIN32)
00620   return ::_isatty (handle);
00621 # else
00622   ACE_OSCALL_RETURN (::isatty (handle), int, -1);
00623 # endif /* ACE_LACKS_ISATTY */
00624 }

wchar_t * ACE_OS::itoa ( int  value,
wchar_t string,
int  radix 
) [inline]

Converts an integer to a string.

Definition at line 209 of file OS_NS_stdlib.inl.

00210 {
00211 #if defined (ACE_LACKS_ITOW)
00212   return ACE_OS::itow_emulation (value, string, radix);
00213 #else /* ACE_LACKS_ITOW */
00214   return ::_itow (value, string, radix);
00215 #endif /* ACE_LACKS_ITOW */
00216 }

char * ACE_OS::itoa ( int  value,
char *  string,
int  radix 
) [inline]

Converts an integer to a string.

Definition at line 196 of file OS_NS_stdlib.inl.

00197 {
00198 #if !defined (ACE_HAS_ITOA)
00199   return ACE_OS::itoa_emulation (value, string, radix);
00200 #elif defined (ACE_ITOA_EQUIVALENT)
00201   return ACE_ITOA_EQUIVALENT (value, string, radix);
00202 #else /* !ACE_HAS_ITOA */
00203   return ::itoa (value, string, radix);
00204 #endif /* !ACE_HAS_ITOA */
00205 }

char * ACE_OS::itoa_emulation ( int  value,
char *  string,
int  radix 
)

Emulated itoa - Converts an integer to a string.

Definition at line 182 of file OS_NS_stdlib.cpp.

00183 {
00184   char *e = string;
00185   char *b = string;
00186 
00187   // Short circuit if 0
00188 
00189   if (value == 0)
00190     {
00191       string[0] = '0';
00192       string[1] = 0;
00193       return string;
00194     }
00195 
00196   // If negative and base 10, print a - and then do the
00197   // number.
00198 
00199   if (value < 0 && radix == 10)
00200     {
00201       string[0] = '-';
00202       ++b;
00203       ++e; // Don't overwrite the negative sign.
00204       value = -value; // Drop negative sign so character selection is correct.
00205     }
00206 
00207   // Convert to base <radix>, but in reverse order
00208 
00209   while (value != 0)
00210     {
00211       int mod = value % radix;
00212       value = value / radix;
00213 
00214       *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
00215     }
00216 
00217   *e-- = 0;
00218 
00219   // Now reverse the string to get the correct result
00220 
00221   while (e > b)
00222     {
00223       char temp = *e;
00224       *e = *b;
00225       *b = temp;
00226       ++b;
00227       --e;
00228     }
00229 
00230   return string;
00231 }

ACE_HANDLE ACE_OS::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.

Definition at line 62 of file OS_NS_sys_socket.cpp.

00066 {
00067 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00068 
00069   QOS qos;
00070   // Construct the WinSock2 QOS structure.
00071 
00072   qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ());
00073   qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ());
00074   qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific ();
00075 
00076   ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket,
00077                                       name,
00078                                       namelen,
00079                                       (WSABUF *) qos_params.caller_data (),
00080                                       (WSABUF *) qos_params.callee_data (),
00081                                       &qos,
00082                                       (QOS *) qos_params.group_socket_qos (),
00083                                       qos_params.flags ()),
00084                        ACE_HANDLE,
00085                        ACE_INVALID_HANDLE);
00086 
00087 # else
00088   ACE_UNUSED_ARG (socket);
00089   ACE_UNUSED_ARG (name);
00090   ACE_UNUSED_ARG (namelen);
00091   ACE_UNUSED_ARG (qos_params);
00092   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00093 # endif /* ACE_HAS_WINSOCK2 */
00094 }

int ACE_OS::kill ( pid_t  pid,
int  signum 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 12 of file OS_NS_signal.inl.

00013 {
00014   ACE_OS_TRACE ("ACE_OS::kill");
00015 #if defined (ACE_LACKS_KILL)
00016   ACE_UNUSED_ARG (pid);
00017   ACE_UNUSED_ARG (signum);
00018   ACE_NOTSUP_RETURN (-1);
00019 #elif defined (ACE_VXWORKS)
00020   /*
00021    * The VxWorks kill interface is not really POSIX
00022    * since they use a task id in place of a pid type.
00023    * This only becomes an issue when using the 64bit compiler
00024    * as the TASK_ID is no longer defined as an int.
00025    */
00026   ACE_OSCALL_RETURN (::kill ((ACE_VX_TASK_ID)pid, signum), int, -1);
00027 #else
00028   ACE_OSCALL_RETURN (::kill (pid, signum), int, -1);
00029 #endif /* ACE_LACKS_KILL */
00030 }

void ACE_OS::last_error ( int  error  ) 

Definition at line 26 of file OS_NS_errno.inl.

00027 {
00028   ACE_OS_TRACE ("ACE_OS::last_error");
00029 #if defined (ACE_WIN32)
00030   ::SetLastError (error);
00031 #endif /* ACE_WIN32 */
00032   errno = error;
00033 }

int ACE_OS::last_error ( void   ) 

Definition at line 7 of file OS_NS_errno.inl.

00008 {
00009   // ACE_OS_TRACE ("ACE_OS::last_error");
00010 
00011 #if defined (ACE_WIN32)
00012   // ACE_OS::last_error() prefers errnor since started out as a way to
00013   // avoid directly accessing errno in ACE code - particularly the ACE
00014   // C++ socket wrapper facades.  On Windows, some things that would
00015   // use errno on UNIX require ::GetLastError(), so this method tries
00016   // to shield the rest of ACE from having to know about this.
00017   int const lerror = ::GetLastError ();
00018   int const lerrno = errno;
00019   return lerrno == 0 ? lerror : lerrno;
00020 #else
00021   return errno;
00022 #endif /* ACE_WIN32 */
00023 }

int ACE_OS::listen ( ACE_HANDLE  handle,
int  backlog 
) [inline]

BSD-style accept (no QoS).

Definition at line 304 of file OS_NS_sys_socket.inl.

00305 {
00306   ACE_OS_TRACE ("ACE_OS::listen");
00307 #if defined (ACE_LACKS_LISTEN)
00308   ACE_UNUSED_ARG (handle);
00309   ACE_UNUSED_ARG (backlog);
00310   ACE_NOTSUP_RETURN (-1);
00311 #else
00312   ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1);
00313 #endif /* ACE_LACKS_LISTEN */
00314 }

struct tm * ACE_OS::localtime ( const time_t *  clock  )  [read]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 397 of file OS_NS_time.inl.

00398 {
00399   ACE_OS_TRACE ("ACE_OS::localtime");
00400 #if defined (ACE_LACKS_LOCALTIME)
00401   ACE_UNUSED_ARG (t);
00402   ACE_NOTSUP_RETURN (0);
00403 #else
00404   ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0);
00405 #endif /* ACE_LACKS_LOCALTIME */
00406 }

struct tm * ACE_OS::localtime_r ( const time_t *  clock,
struct tm res 
) [read]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 221 of file OS_NS_time.cpp.

00222 {
00223   ACE_OS_TRACE ("ACE_OS::localtime_r");
00224 #if defined (ACE_HAS_TR24731_2005_CRT)
00225   ACE_SECURECRTCALL (localtime_s (res, t), struct tm *, 0, res);
00226   return res;
00227 #elif defined (ACE_HAS_WINCE)
00228   // This is really stupid, converting FILETIME to timeval back and
00229   // forth.  It assumes FILETIME and DWORDLONG are the same structure
00230   // internally.
00231 
00232   TIME_ZONE_INFORMATION pTz;
00233 
00234   const unsigned short int __mon_yday[2][13] =
00235   {
00236     /* Normal years.  */
00237     { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
00238     /* Leap years.  */
00239     { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
00240   };
00241 
00242   ULARGE_INTEGER _100ns;
00243   ::GetTimeZoneInformation (&pTz);
00244 
00245   _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 + ACE_Time_Value::FILETIME_to_timval_skew;
00246   FILETIME file_time;
00247   file_time.dwLowDateTime = _100ns.LowPart;
00248   file_time.dwHighDateTime = _100ns.HighPart;
00249 
00250   FILETIME localtime;
00251   SYSTEMTIME systime;
00252   FileTimeToLocalFileTime (&file_time, &localtime);
00253   FileTimeToSystemTime (&localtime, &systime);
00254 
00255   res->tm_hour = systime.wHour;
00256 
00257   if(pTz.DaylightBias!=0)
00258     res->tm_isdst = 1;
00259   else
00260     res->tm_isdst = 1;
00261 
00262    int iLeap;
00263    iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0));
00264    // based on leap select which group to use
00265 
00266    res->tm_mday = systime.wDay;
00267    res->tm_min = systime.wMinute;
00268    res->tm_mon = systime.wMonth - 1;
00269    res->tm_sec = systime.wSecond;
00270    res->tm_wday = systime.wDayOfWeek;
00271    res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay;
00272    res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900
00273    res->tm_year = res->tm_year - 1900;
00274 
00275    return res;
00276 #elif defined (ACE_LACKS_LOCALTIME_R)
00277   ACE_OS_GUARD
00278 
00279   ACE_UNUSED_ARG (res);
00280   struct tm * res_ptr = 0;
00281   ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr);
00282   if (res_ptr == 0)
00283     return 0;
00284   else
00285     {
00286       *res = *res_ptr;
00287       return res;
00288     }
00289 #else
00290   return ace_localtime_r_helper (t, res);
00291 #endif /* ACE_HAS_TR24731_2005_CRT */
00292 }

double ACE_OS::log2 ( double  x  )  [inline]

This method computes the base-2 logarithm of x.

Definition at line 7 of file OS_NS_math.inl.

00008   {
00009     return ace_log2_helper (x);
00010   }

ACE_OFF_T ACE_OS::lseek ( ACE_HANDLE  handle,
ACE_OFF_T  offset,
int  whence 
) [inline]

Definition at line 648 of file OS_NS_unistd.inl.

00649 {
00650   ACE_OS_TRACE ("ACE_OS::lseek");
00651 #if defined (ACE_WIN32)
00652 # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00653   //#error Windows NT is evil AND rude!
00654   switch (whence)
00655     {
00656     case SEEK_SET:
00657       whence = FILE_BEGIN;
00658       break;
00659     case SEEK_CUR:
00660       whence = FILE_CURRENT;
00661       break;
00662     case SEEK_END:
00663       whence = FILE_END;
00664       break;
00665     default:
00666       errno = EINVAL;
00667       return static_cast<ACE_OFF_T> (-1); // rather safe than sorry
00668     }
00669 # endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00670   LONG low_offset = ACE_LOW_PART(offset);
00671   LONG high_offset = ACE_HIGH_PART(offset);
00672   DWORD const result =
00673     ::SetFilePointer (handle, low_offset, &high_offset, whence);
00674   if (result == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
00675     ACE_FAIL_RETURN (static_cast<ACE_OFF_T> (-1));
00676   else
00677     return result;
00678 #else
00679   ACE_OSCALL_RETURN (::lseek (handle, offset, whence), ACE_OFF_T, -1);
00680 #endif /* ACE_WIN32 */
00681 }

int ACE_OS::lstat ( const wchar_t file,
ACE_stat stp 
) [inline]

Definition at line 130 of file OS_NS_sys_stat.inl.

00131   {
00132     ACE_OS_TRACE ("ACE_OS::lstat");
00133 # if defined (ACE_LACKS_LSTAT)
00134     return ACE_OS::stat (file, stp);
00135 # else
00136     return ACE_OS::lstat (ACE_Wide_To_Ascii (file).char_rep (), stp);
00137 # endif /* ACE_LACKS_LSTAT */
00138   }

int ACE_OS::lstat ( const char *  file,
ACE_stat stp 
) [inline]

Definition at line 114 of file OS_NS_sys_stat.inl.

00115   {
00116     ACE_OS_TRACE ("ACE_OS::lstat");
00117 # if defined (ACE_LACKS_LSTAT)
00118     return ACE_OS::stat (file, stp);
00119 # elif defined (ACE_HAS_X86_STAT_MACROS)
00120     // Solaris for intel uses an macro for lstat(), this macro is a
00121     // wrapper for _lxstat().
00122     ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1);
00123 # else /* !ACE_HAS_X86_STAT_MACROS */
00124     ACE_OSCALL_RETURN (::lstat (file, stp), int, -1);
00125 # endif /* ACE_LACKS_LSTAT */
00126   }

int ACE_OS::lwp_getparams ( ACE_Sched_Params sched_params  ) 

Definition at line 3063 of file OS_NS_Thread.cpp.

03064 {
03065 #if defined (ACE_HAS_STHREADS) || defined (sun)
03066   // Get the class TS and RT class IDs.
03067   ACE_id_t rt_id;
03068   ACE_id_t ts_id;
03069   if (ACE_OS::scheduling_class ("RT", rt_id) == -1
03070       || ACE_OS::scheduling_class ("TS", ts_id) == -1)
03071     return -1;
03072 
03073   // Get this LWP's scheduling parameters.
03074   pcparms_t pcparms;
03075   // The following is just to avoid Purify warnings about unitialized
03076   // memory reads.
03077   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03078   pcparms.pc_cid = PC_CLNULL;
03079 
03080   if (ACE_OS::priority_control (P_LWPID,
03081                                 P_MYID,
03082                                 PC_GETPARMS,
03083                                 (char *) &pcparms) == -1)
03084     return -1;
03085   else if (pcparms.pc_cid == rt_id)
03086     {
03087       // RT class.
03088       rtparms_t rtparms;
03089       ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms);
03090 
03091       sched_params.policy (ACE_SCHED_FIFO);
03092       sched_params.priority (rtparms.rt_pri);
03093       sched_params.scope (ACE_SCOPE_THREAD);
03094       ACE_Time_Value quantum (rtparms.rt_tqsecs,
03095                               rtparms.rt_tqnsecs == RT_TQINF
03096                               ? 0 : rtparms.rt_tqnsecs * 1000);
03097       sched_params.quantum (quantum);
03098       return 0;
03099     }
03100   else if (pcparms.pc_cid == ts_id)
03101     {
03102       /* TS class */
03103       tsparms_t tsparms;
03104       ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms);
03105 
03106       sched_params.policy (ACE_SCHED_OTHER);
03107       sched_params.priority (tsparms.ts_upri);
03108       sched_params.scope (ACE_SCOPE_THREAD);
03109       return 0;
03110     }
03111   else
03112     return -1;
03113 
03114 #else  /* ! ACE_HAS_STHREADS && ! sun */
03115   ACE_UNUSED_ARG (sched_params);
03116   ACE_NOTSUP_RETURN (-1);
03117 #endif /* ! ACE_HAS_STHREADS && ! sun */
03118 }

int ACE_OS::lwp_setparams ( const ACE_Sched_Params sched_params  ) 

Definition at line 3121 of file OS_NS_Thread.cpp.

03122 {
03123 #if defined (ACE_HAS_STHREADS) || defined (sun)
03124   ACE_Sched_Params lwp_params (sched_params);
03125   lwp_params.scope (ACE_SCOPE_LWP);
03126   return ACE_OS::sched_params (lwp_params);
03127 #else  /* ! ACE_HAS_STHREADS && ! sun */
03128   ACE_UNUSED_ARG (sched_params);
03129   ACE_NOTSUP_RETURN (-1);
03130 #endif /* ! ACE_HAS_STHREADS && ! sun */
03131 }

int ACE_OS::madvise ( caddr_t  addr,
size_t  len,
int  map_advice 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 18 of file OS_NS_sys_mman.inl.

00019 {
00020   ACE_OS_TRACE ("ACE_OS::madvise");
00021 #if !defined (ACE_LACKS_MADVISE)
00022   ACE_OSCALL_RETURN (::madvise (addr, len, map_advice), int, -1);
00023 #else
00024   ACE_UNUSED_ARG (addr);
00025   ACE_UNUSED_ARG (len);
00026   ACE_UNUSED_ARG (map_advice);
00027   ACE_NOTSUP_RETURN (-1);
00028 #endif /* ACE_WIN32 */
00029 }

void * ACE_OS::malloc ( size_t  nbytes  ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 287 of file OS_NS_stdlib.cpp.

00288 {
00289   return ACE_MALLOC_FUNC (nbytes);
00290 }

void * ACE_OS::memchr ( void *  s,
int  c,
size_t  len 
)

Finds characters in a buffer (void version).

Definition at line 20 of file OS_NS_string.inl.

00021 {
00022   return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
00023                                              c,
00024                                              len));
00025 }

const void * ACE_OS::memchr ( const void *  s,
int  c,
size_t  len 
)

Finds characters in a buffer (const void version).

Definition at line 10 of file OS_NS_string.inl.

00011 {
00012 #if !defined (ACE_LACKS_MEMCHR)
00013   return ::memchr (s, c, len);
00014 #else /* ACE_LACKS_MEMCHR */
00015   return ACE_OS::memchr_emulation (s, c, len);
00016 #endif /* !ACE_LACKS_MEMCHR */
00017 }

ACE_Export const void* ACE_OS::memchr_emulation ( const void *  s,
int  c,
size_t  len 
)

Emulated memchr - Finds a character in a buffer.

int ACE_OS::memcmp ( const void *  t,
const void *  s,
size_t  len 
)

Compares two buffers.

Definition at line 28 of file OS_NS_string.inl.

00029 {
00030   return ::memcmp (t, s, len);
00031 }

void * ACE_OS::memcpy ( void *  t,
const void *  s,
size_t  len 
)

Copies one buffer to another.

Definition at line 34 of file OS_NS_string.inl.

00035 {
00036 #if defined (ACE_HAS_MEMCPY_LOOP_UNROLL)
00037   return fast_memcpy (t, s, len);
00038 #else
00039   return ::memcpy (t, s, len);
00040 #endif /* ACE_HAS_MEMCPY_LOOP_UNROLL */
00041 }

void * ACE_OS::memmove ( void *  t,
const void *  s,
size_t  len 
)

Moves one buffer to another.

Definition at line 44 of file OS_NS_string.inl.

00045 {
00046   return ::memmove (t, s, len);
00047 }

void * ACE_OS::memset ( void *  s,
int  c,
size_t  len 
)

Fills a buffer with a character value.

Definition at line 50 of file OS_NS_string.inl.

00051 {
00052 #if defined (ACE_HAS_SLOW_MEMSET)
00053   // This section requires a high optimization level (-xO4 with SunCC)
00054   // in order to actually be inlined.
00055   char* ptr = static_cast<char*> (s);
00056   switch (len)
00057     {
00058     case 16:
00059       ptr[15] = c;
00060     case 15:
00061       ptr[14] = c;
00062     case 14:
00063       ptr[13] = c;
00064     case 13:
00065       ptr[12] = c;
00066     case 12:
00067       ptr[11] = c;
00068     case 11:
00069       ptr[10] = c;
00070     case 10:
00071       ptr[9] = c;
00072     case 9:
00073       ptr[8] = c;
00074     case 8:
00075       ptr[7] = c;
00076     case 7:
00077       ptr[6] = c;
00078     case 6:
00079       ptr[5] = c;
00080     case 5:
00081       ptr[4] = c;
00082     case 4:
00083       ptr[3] = c;
00084     case 3:
00085       ptr[2] = c;
00086     case 2:
00087       ptr[1] = c;
00088     case 1:
00089       ptr[0] = c;
00090       break;
00091     default:
00092       for (size_t i = 0; i < len; ++i)
00093         {
00094           ptr[i] = c;
00095         }
00096     }
00097 
00098   return s;
00099 #else
00100   return ::memset (s, c, len);
00101 #endif /* ACE_HAS_SLOW_MEMSET */
00102 }

int ACE_OS::mkdir ( const wchar_t path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS 
) [inline]

Definition at line 164 of file OS_NS_sys_stat.inl.

00165   {
00166 #if defined (ACE_HAS_WINCE)
00167     ACE_UNUSED_ARG (mode);
00168     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (CreateDirectoryW (path, 0),
00169                                             ace_result_),
00170                           int, -1);
00171 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00172     ACE_UNUSED_ARG (mode);
00173     ACE_OSCALL_RETURN (::_wmkdir (path), int, -1);
00174 #else
00175     return ACE_OS::mkdir (ACE_Wide_To_Ascii (path).char_rep (), mode);
00176 #endif /* ACE_HAS_WINCE */
00177   }

int ACE_OS::mkdir ( const char *  path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS 
) [inline]

Definition at line 142 of file OS_NS_sys_stat.inl.

00143   {
00144 #if defined (ACE_HAS_WINCE)
00145     ACE_UNUSED_ARG (mode);
00146     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (ACE_TEXT_CHAR_TO_TCHAR (path), 0),
00147                                             ace_result_),
00148                           int, -1);
00149 #elif defined (ACE_MKDIR_LACKS_MODE)
00150     ACE_UNUSED_ARG (mode);
00151 #  if defined (ACE_MKDIR_EQUIVALENT)
00152     ACE_OSCALL_RETURN (ACE_MKDIR_EQUIVALENT (path), int, -1);
00153 #  else
00154     ACE_OSCALL_RETURN (::mkdir (path), int, -1);
00155 #  endif
00156 #else
00157     ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1);
00158 #endif
00159   }

int ACE_OS::mkfifo ( const ACE_TCHAR file,
mode_t  mode = ACE_DEFAULT_FILE_PERMS 
) [inline]

Definition at line 182 of file OS_NS_sys_stat.inl.

00183   {
00184     ACE_OS_TRACE ("ACE_OS::mkfifo");
00185 #if defined (ACE_LACKS_MKFIFO)
00186     ACE_UNUSED_ARG (file);
00187     ACE_UNUSED_ARG (mode);
00188     ACE_NOTSUP_RETURN (-1);
00189 #else
00190     ACE_OSCALL_RETURN (::mkfifo (ACE_TEXT_ALWAYS_CHAR (file), mode), int, -1);
00191 #endif /* ACE_LACKS_MKFIFO */
00192   }

ACE_HANDLE ACE_OS::mkstemp ( wchar_t s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 243 of file OS_NS_stdlib.inl.

00244 {
00245 #  if !defined (ACE_LACKS_MKSTEMP)
00246   // For wide-char filesystems, we must convert the wide-char input to
00247   // a narrow-char string for mkstemp(), then convert the name
00248   // back to wide-char for the caller.
00249   ACE_Wide_To_Ascii narrow_s (s);
00250   const ACE_HANDLE fh = ::mkstemp (narrow_s.char_rep ());
00251   if (fh != ACE_INVALID_HANDLE)
00252     {
00253       ACE_Ascii_To_Wide wide_s (narrow_s.char_rep ());
00254       ACE_OS::strcpy (s, wide_s.wchar_rep ());
00255     }
00256   return fh;
00257 #  elif defined (ACE_USES_WCHAR)
00258   return ACE_OS::mkstemp_emulation (s);
00259 #  else
00260   // For wide-char filesystems, we must convert the wide-char input to
00261   // a narrow-char string for mkstemp_emulation(), then convert the name
00262   // back to wide-char for the caller.
00263   ACE_Wide_To_Ascii narrow_s (s);
00264   const ACE_HANDLE fh = ACE_OS::mkstemp_emulation (narrow_s.char_rep ());
00265   if (fh != ACE_INVALID_HANDLE)
00266     {
00267       ACE_Ascii_To_Wide wide_s (narrow_s.char_rep ());
00268       ACE_OS::strcpy (s, wide_s.wchar_rep ());
00269     }
00270   return fh;
00271 #  endif  /* !ACE_LACKS_MKSTEMP */
00272 }

ACE_HANDLE ACE_OS::mkstemp ( char *  s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 220 of file OS_NS_stdlib.inl.

00221 {
00222 #if !defined (ACE_LACKS_MKSTEMP)
00223   return ::mkstemp (s);
00224 #elif defined (ACE_USES_WCHAR)
00225   // For wide-char filesystems, we must convert the narrow-char input to
00226   // a wide-char string for mkstemp_emulation(), then convert the name
00227   // back to narrow-char for the caller.
00228   ACE_Ascii_To_Wide wide_s (s);
00229   const ACE_HANDLE fh = ACE_OS::mkstemp_emulation (wide_s.wchar_rep ());
00230   if (fh != ACE_INVALID_HANDLE)
00231     {
00232       ACE_Wide_To_Ascii narrow_s (wide_s.wchar_rep ());
00233       ACE_OS::strcpy (s, narrow_s.char_rep ());
00234     }
00235   return fh;
00236 #else
00237   return ACE_OS::mkstemp_emulation (s);
00238 #endif  /* !ACE_LACKS_MKSTEMP */
00239 }

wchar_t * ACE_OS::mktemp ( wchar_t s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 290 of file OS_NS_stdlib.inl.

00291 {
00292 #      if defined (ACE_WIN32)
00293   return ::_wmktemp (s);
00294 #      else
00295   // For narrow-char filesystems, we must convert the wide-char input to
00296   // a narrow-char string for mktemp (), then convert the name back to
00297   // wide-char for the caller.
00298   ACE_Wide_To_Ascii narrow_s (s);
00299   if (::mktemp (narrow_s.char_rep ()) == 0)
00300     return 0;
00301   ACE_Ascii_To_Wide wide_s (narrow_s.char_rep ());
00302   ACE_OS::strcpy (s, wide_s.wchar_rep ());
00303   return s;
00304 #      endif
00305 }

char * ACE_OS::mktemp ( char *  s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 279 of file OS_NS_stdlib.inl.

00280 {
00281 #    if defined (ACE_WIN32)
00282   return ::_mktemp (s);
00283 #    else /* ACE_WIN32 */
00284   return ::mktemp (s);
00285 #    endif /* ACE_WIN32 */
00286 }

time_t ACE_OS::mktime ( struct tm timeptr  ) 

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 295 of file OS_NS_time.cpp.

00296 {
00297   ACE_OS_TRACE ("ACE_OS::mktime");
00298 #   if defined (ACE_HAS_WINCE)
00299   SYSTEMTIME t_sys;
00300   FILETIME t_file;
00301   t_sys.wSecond = t->tm_sec;
00302   t_sys.wMinute = t->tm_min;
00303   t_sys.wHour = t->tm_hour;
00304   t_sys.wDay = t->tm_mday;
00305   t_sys.wMonth = t->tm_mon + 1;  // SYSTEMTIME is 1-indexed, tm is 0-indexed
00306   t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900
00307   t_sys.wDayOfWeek = t->tm_wday;  // Ignored in below function call.
00308   t_sys.wMilliseconds = 0;
00309   if (SystemTimeToFileTime (&t_sys, &t_file) == 0)
00310     return -1;
00311   ACE_Time_Value tv (t_file);
00312   return tv.sec ();
00313 #   else
00314 #     if defined (ACE_HAS_THREADS)  &&  !defined (ACE_HAS_MT_SAFE_MKTIME)
00315   ACE_OS_GUARD
00316 #     endif /* ACE_HAS_THREADS  &&  ! ACE_HAS_MT_SAFE_MKTIME */
00317 
00318   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::mktime (t), time_t, (time_t) -1);
00319 #   endif /* ACE_HAS_WINCE */
00320 }

void * ACE_OS::mmap ( void *  addr,
size_t  len,
int  prot,
int  flags,
ACE_HANDLE  handle,
ACE_OFF_T  off = 0,
ACE_HANDLE *  file_mapping = 0,
LPSECURITY_ATTRIBUTES  sa = 0,
const ACE_TCHAR file_mapping_name = 0 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 32 of file OS_NS_sys_mman.inl.

00041 {
00042   ACE_OS_TRACE ("ACE_OS::mmap");
00043 #if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP)
00044   ACE_UNUSED_ARG (file_mapping_name);
00045 #endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */
00046 
00047 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00048 
00049 #  if defined(ACE_HAS_WINCE)
00050   ACE_UNUSED_ARG (addr);
00051   if (ACE_BIT_ENABLED (flags, MAP_FIXED))     // not supported
00052   {
00053     errno = EINVAL;
00054     return MAP_FAILED;
00055   }
00056 #  else
00057   if (!ACE_BIT_ENABLED (flags, MAP_FIXED))
00058     addr = 0;
00059   else if (addr == 0)   // can not map to address 0
00060   {
00061     errno = EINVAL;
00062     return MAP_FAILED;
00063   }
00064 #  endif
00065 
00066   int nt_flags = 0;
00067   ACE_HANDLE local_handle = ACE_INVALID_HANDLE;
00068 
00069   // Ensure that file_mapping is non-zero.
00070   if (file_mapping == 0)
00071     file_mapping = &local_handle;
00072 
00073   if (ACE_BIT_ENABLED (flags, MAP_PRIVATE))
00074     {
00075 #  if defined(ACE_HAS_WINCE)
00076       // PAGE_WRITECOPY is not avaible on CE, but this should be the same
00077       // as PAGE_READONLY according to MSDN
00078       nt_flags = FILE_MAP_ALL_ACCESS;
00079 #  else
00080       prot = PAGE_WRITECOPY;
00081       nt_flags = FILE_MAP_COPY;
00082 #  endif  // ACE_HAS_WINCE
00083     }
00084   else if (ACE_BIT_ENABLED (flags, MAP_SHARED))
00085     {
00086       if (ACE_BIT_ENABLED (prot, PAGE_READONLY))
00087         nt_flags = FILE_MAP_READ;
00088       if (ACE_BIT_ENABLED (prot, PAGE_READWRITE))
00089         nt_flags = FILE_MAP_WRITE;
00090     }
00091 
00092   // Only create a new handle if we didn't have a valid one passed in.
00093   if (*file_mapping == ACE_INVALID_HANDLE)
00094     {
00095       SECURITY_ATTRIBUTES sa_buffer;
00096       SECURITY_DESCRIPTOR sd_buffer;
00097       LPSECURITY_ATTRIBUTES const attr =
00098         ACE_OS::default_win32_security_attributes_r (sa,
00099                                                      &sa_buffer,
00100                                                      &sd_buffer);
00101 
00102 #  ifdef ACE_WIN64
00103       const DWORD len_low = static_cast<DWORD>(len),
00104         len_high = static_cast<DWORD>(len >> 32);
00105 #  else
00106       const DWORD len_low = static_cast<DWORD>(len), len_high = 0;
00107 #  endif
00108 
00109       *file_mapping = ACE_TEXT_CreateFileMapping (file_handle,
00110                                                   attr,
00111                                                   prot,
00112                                                   (file_handle == ACE_INVALID_HANDLE) ? len_high : 0,
00113                                                   (file_handle == ACE_INVALID_HANDLE) ? len_low : 0,
00114                                                   file_mapping_name);
00115     }
00116 
00117   if (*file_mapping == 0)
00118     ACE_FAIL_RETURN (MAP_FAILED);
00119 
00120 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
00121   nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS;
00122 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
00123 
00124   DWORD low_off  = ACE_LOW_PART (off);
00125   DWORD high_off = ACE_HIGH_PART (off);
00126 
00127 #  if defined (ACE_HAS_WINCE)
00128   void *addr_mapping = ::MapViewOfFile (*file_mapping,
00129                                         nt_flags,
00130                                         high_off,
00131                                         low_off,
00132                                         len);
00133 #  else
00134   void *addr_mapping = ::MapViewOfFileEx (*file_mapping,
00135                                           nt_flags,
00136                                           high_off,
00137                                           low_off,
00138                                           len,
00139                                           addr);
00140 #  endif /* ACE_HAS_WINCE */
00141 
00142   // Only close this down if we used the temporary.
00143   if (file_mapping == &local_handle)
00144     ::CloseHandle (*file_mapping);
00145 
00146   if (addr_mapping == 0)
00147     ACE_FAIL_RETURN (MAP_FAILED);
00148   else
00149     return addr_mapping;
00150 #elif !defined (ACE_LACKS_MMAP)
00151   ACE_UNUSED_ARG (sa);
00152 
00153 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
00154   flags |= ACE_OS_EXTRA_MMAP_FLAGS;
00155 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
00156   ACE_UNUSED_ARG (file_mapping);
00157 #  if defined (ACE_OPENVMS)
00158   //FUZZ: disable check_for_lack_ACE_OS
00159   ::fsync(file_handle);
00160   //FUZZ: enable check_for_lack_ACE_OS
00161 #  endif
00162   //FUZZ: disable check_for_lack_ACE_OS
00163   ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr,
00164                                       len,
00165                                       prot,
00166                                       flags,
00167                                       file_handle,
00168                                       off),
00169                      void *, MAP_FAILED);
00170   //FUZZ: enable check_for_lack_ACE_OS
00171 #else
00172   ACE_UNUSED_ARG (addr);
00173   ACE_UNUSED_ARG (len);
00174   ACE_UNUSED_ARG (prot);
00175   ACE_UNUSED_ARG (flags);
00176   ACE_UNUSED_ARG (file_handle);
00177   ACE_UNUSED_ARG (off);
00178   ACE_UNUSED_ARG (file_mapping);
00179   ACE_UNUSED_ARG (sa);
00180   ACE_NOTSUP_RETURN (MAP_FAILED);
00181 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00182 }

int ACE_OS::mprotect ( void *  addr,
size_t  len,
int  prot 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 190 of file OS_NS_sys_mman.inl.

00191 {
00192   ACE_OS_TRACE ("ACE_OS::mprotect");
00193 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00194   DWORD dummy; // Sigh!
00195   return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1;
00196 #elif !defined (ACE_LACKS_MPROTECT)
00197   ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1);
00198 #else
00199   ACE_UNUSED_ARG (addr);
00200   ACE_UNUSED_ARG (len);
00201   ACE_UNUSED_ARG (prot);
00202   ACE_NOTSUP_RETURN (-1);
00203 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00204 }

int ACE_OS::msgctl ( int  msqid,
int  cmd,
struct msqid_ds *  val 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 7 of file OS_NS_sys_msg.inl.

00008 {
00009   ACE_OS_TRACE ("ACE_OS::msgctl");
00010 #if defined (ACE_HAS_SYSV_IPC)
00011   ACE_OSCALL_RETURN (::msgctl (msqid, cmd, val), int, -1);
00012 #else
00013   ACE_UNUSED_ARG (msqid);
00014   ACE_UNUSED_ARG (cmd);
00015   ACE_UNUSED_ARG (val);
00016 
00017   ACE_NOTSUP_RETURN (-1);
00018 #endif /* ACE_HAS_SYSV_IPC */
00019 }

int ACE_OS::msgget ( key_t  key,
int  msgflg 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 22 of file OS_NS_sys_msg.inl.

00023 {
00024   ACE_OS_TRACE ("ACE_OS::msgget");
00025 #if defined (ACE_HAS_SYSV_IPC)
00026   ACE_OSCALL_RETURN (::msgget (key, msgflg), int, -1);
00027 #else
00028   ACE_UNUSED_ARG (key);
00029   ACE_UNUSED_ARG (msgflg);
00030 
00031   ACE_NOTSUP_RETURN (-1);
00032 #endif /* ACE_HAS_SYSV_IPC */
00033 }

ssize_t ACE_OS::msgrcv ( int  int_id,
void *  buf,
size_t  len,
long  type,
int  flags 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 36 of file OS_NS_sys_msg.inl.

00038 {
00039   ACE_OS_TRACE ("ACE_OS::msgrcv");
00040 #if defined (ACE_HAS_SYSV_IPC)
00041   ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags),
00042                      int, -1);
00043 #else
00044   ACE_UNUSED_ARG (int_id);
00045   ACE_UNUSED_ARG (buf);
00046   ACE_UNUSED_ARG (len);
00047   ACE_UNUSED_ARG (type);
00048   ACE_UNUSED_ARG (flags);
00049 
00050   ACE_NOTSUP_RETURN (-1);
00051 #endif /* ACE_HAS_SYSV_IPC */
00052 }

int ACE_OS::msgsnd ( int  int_id,
const void *  buf,
size_t  len,
int  flags 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 55 of file OS_NS_sys_msg.inl.

00056 {
00057   ACE_OS_TRACE ("ACE_OS::msgsnd");
00058 #if defined (ACE_HAS_SYSV_IPC)
00059 # if defined (ACE_HAS_NONCONST_MSGSND)
00060   ACE_OSCALL_RETURN (::msgsnd (int_id,
00061                                const_cast<void *> (buf), len, flags), int, -1);
00062 # else
00063   ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1);
00064 # endif /* ACE_HAS_NONCONST_MSGSND */
00065 #else
00066   ACE_UNUSED_ARG (int_id);
00067   ACE_UNUSED_ARG (buf);
00068   ACE_UNUSED_ARG (len);
00069   ACE_UNUSED_ARG (flags);
00070 
00071   ACE_NOTSUP_RETURN (-1);
00072 #endif /* ACE_HAS_SYSV_IPC */
00073 }

int ACE_OS::msync ( void *  addr,
size_t  len,
int  sync 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 207 of file OS_NS_sys_mman.inl.

00208 {
00209   ACE_OS_TRACE ("ACE_OS::msync");
00210 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00211   ACE_UNUSED_ARG (sync);
00212 
00213   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1);
00214 #elif !defined (ACE_LACKS_MSYNC)
00215   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1);
00216 #else
00217   ACE_UNUSED_ARG (addr);
00218   ACE_UNUSED_ARG (len);
00219   ACE_UNUSED_ARG (sync);
00220   ACE_NOTSUP_RETURN (-1);
00221 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00222 }

int ACE_OS::munmap ( void *  addr,
size_t  len 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 225 of file OS_NS_sys_mman.inl.

00226 {
00227   ACE_OS_TRACE ("ACE_OS::munmap");
00228 #if defined (ACE_WIN32)
00229   ACE_UNUSED_ARG (len);
00230 
00231   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1);
00232 #elif !defined (ACE_LACKS_MMAP) && !defined (ACE_LACKS_MUNMAP)
00233   ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1);
00234 #else
00235   ACE_UNUSED_ARG (addr);
00236   ACE_UNUSED_ARG (len);
00237   ACE_NOTSUP_RETURN (-1);
00238 #endif /* ACE_WIN32 */
00239 }

int ACE_OS::mutex_destroy ( ACE_mutex_t m  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1979 of file OS_NS_Thread.cpp.

01980 {
01981   ACE_OS_TRACE ("ACE_OS::mutex_destroy");
01982 #if defined (ACE_HAS_THREADS)
01983 # if defined (ACE_HAS_PTHREADS)
01984 #  if defined (ACE_LACKS_PTHREAD_MUTEX_DESTROY)
01985   ACE_UNUSED_ARG (m);
01986   ACE_NOTSUP_RETURN (-1);
01987 #  else
01988   int result;
01989   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
01990                      result), int, -1);
01991 #  endif /* ACE_LACKS_PTHREAD_MUTEX_DESTROY */
01992 # elif defined (ACE_HAS_STHREADS)
01993   int result;
01994   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1);
01995 # elif defined (ACE_HAS_WTHREADS)
01996   switch (m->type_)
01997 {
01998   case USYNC_PROCESS:
01999     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
02000                           ace_result_),
02001     int, -1);
02002   case USYNC_THREAD:
02003     return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
02004   default:
02005     errno = EINVAL;
02006     return -1;
02007 }
02008   /* NOTREACHED */
02009 # elif defined (ACE_VXWORKS)
02010   return ::semDelete (*m) == OK ? 0 : -1;
02011 # endif /* Threads variety case */
02012 #else
02013   ACE_UNUSED_ARG (m);
02014   ACE_NOTSUP_RETURN (-1);
02015 #endif /* ACE_HAS_THREADS */
02016 }

int ACE_OS::mutex_init ( ACE_mutex_t m,
int  lock_scope,
const wchar_t name,
ACE_mutexattr_t arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0,
int  lock_type = 0 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2020 of file OS_NS_Thread.cpp.

02026 {
02027 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02028   m->type_ = lock_scope;
02029   SECURITY_ATTRIBUTES sa_buffer;
02030   SECURITY_DESCRIPTOR sd_buffer;
02031   switch (lock_scope)
02032   {
02033     case USYNC_PROCESS:
02034       m->proc_mutex_ =
02035       ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
02036           (sa, &sa_buffer, &sd_buffer),
02037       FALSE,
02038       name);
02039       if (m->proc_mutex_ == 0)
02040         ACE_FAIL_RETURN (-1);
02041       else
02042         {
02043           // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
02044           ACE_OS::set_errno_to_last_error ();
02045           return 0;
02046         }
02047     case USYNC_THREAD:
02048       return ACE_OS::thread_mutex_init (&m->thr_mutex_,
02049                                          lock_type,
02050                                          name,
02051                                          attributes);
02052   }
02053 
02054   errno = EINVAL;
02055   return -1;
02056 #else /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
02057   return ACE_OS::mutex_init (m,
02058                              lock_scope,
02059                              ACE_Wide_To_Ascii (name).char_rep (),
02060                              attributes,
02061                              sa,
02062                              lock_type);
02063 #endif /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
02064 }

int ACE_OS::mutex_init ( ACE_mutex_t m,
int  lock_scope = ACE_DEFAULT_SYNCH_TYPE,
const char *  name = 0,
ACE_mutexattr_t arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0,
int  lock_type = 0 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1823 of file OS_NS_Thread.cpp.

01829 {
01830   // ACE_OS_TRACE ("ACE_OS::mutex_init");
01831 #if defined (ACE_HAS_THREADS)
01832 # if defined (ACE_HAS_PTHREADS)
01833   ACE_UNUSED_ARG (name);
01834   ACE_UNUSED_ARG (sa);
01835 
01836 # if defined (ACE_PTHREAD_MUTEXATTR_T_INITIALIZE)
01837   /* Tests show that VxWorks 6.x pthread lib does not only
01838    * require zeroing of mutex/condition objects to function correctly
01839    * but also of the attribute objects.
01840    */
01841   pthread_mutexattr_t l_attributes = {0};
01842 # else
01843   pthread_mutexattr_t l_attributes;
01844 # endif
01845 
01846   if (attributes == 0)
01847     attributes = &l_attributes;
01848   int result = 0;
01849   int attr_init = 0;  // have we initialized the local attributes.
01850 
01851   // Only do these initializations if the <attributes> parameter
01852   // wasn't originally set.
01853   if (attributes == &l_attributes)
01854   {
01855       if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0)
01856         {
01857           result = 0;
01858           attr_init = 1; // we have initialized these attributes
01859         }
01860       else
01861         {
01862           result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01863         }
01864   }
01865 
01866   if (result == 0 && lock_scope != 0)
01867 {
01868 #     if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01869       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes,
01870                                                                lock_scope),
01871                                result);
01872 #     endif /* _POSIX_THREAD_PROCESS_SHARED && !ACE_LACKS_MUTEXATTR_PSHARED */
01873 }
01874 
01875   if (result == 0 && lock_type != 0)
01876 {
01877 #   if defined (ACE_HAS_RECURSIVE_MUTEXES) && !defined (ACE_LACKS_PTHREAD_MUTEXATTR_SETTYPE)
01878       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes,
01879                                                             lock_type),
01880                                result);
01881 #   endif /* ACE_HAS_RECURSIVE_MUTEXES */
01882 }
01883 
01884   if (result == 0)
01885     {
01886 #   if defined (ACE_PTHREAD_MUTEX_T_INITIALIZE)
01887       /* VxWorks 6.x API reference states:
01888        * If the memory for the mutex variable object has been allocated
01889        *   dynamically, it is a good policy to always zero out the
01890        *   block of memory so as to avoid spurious EBUSY return code
01891        *   when calling this routine.
01892        * Tests shows this to be necessary.
01893        */
01894       ACE_OS::memset (m, 0, sizeof (*m));
01895 #   endif
01896       if (ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0)
01897         result = 0;
01898       else
01899         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01900     }
01901 
01902   // Only do the deletions if the <attributes> parameter wasn't
01903   // originally set.
01904   if (attributes == &l_attributes && attr_init)
01905     ::pthread_mutexattr_destroy (&l_attributes);
01906 
01907   return result;
01908 # elif defined (ACE_HAS_STHREADS)
01909   ACE_UNUSED_ARG (name);
01910   ACE_UNUSED_ARG (sa);
01911   ACE_UNUSED_ARG (lock_type);
01912   int result;
01913   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m,
01914                      lock_scope,
01915                      attributes),
01916   result),
01917   int, -1);
01918 # elif defined (ACE_HAS_WTHREADS)
01919   m->type_ = lock_scope;
01920 
01921   SECURITY_ATTRIBUTES sa_buffer;
01922   SECURITY_DESCRIPTOR sd_buffer;
01923   switch (lock_scope)
01924 {
01925   case USYNC_PROCESS:
01926 #   if defined (ACE_HAS_WINCE)
01927       // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
01928       m->proc_mutex_ =
01929   ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
01930                           (sa, &sa_buffer, &sd_buffer),
01931                         FALSE,
01932                         ACE_Ascii_To_Wide (name).wchar_rep ());
01933 #   else /* ACE_HAS_WINCE */
01934       m->proc_mutex_ =
01935   ::CreateMutexA (ACE_OS::default_win32_security_attributes_r
01936                           (sa, &sa_buffer, &sd_buffer),
01937                         FALSE,
01938                         name);
01939 #   endif /* ACE_HAS_WINCE */
01940       if (m->proc_mutex_ == 0)
01941         ACE_FAIL_RETURN (-1);
01942       else
01943       {
01944         // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01945         ACE_OS::set_errno_to_last_error ();
01946         return 0;
01947       }
01948   case USYNC_THREAD:
01949     return ACE_OS::thread_mutex_init (&m->thr_mutex_,
01950                                        lock_type,
01951                                        name,
01952                                        attributes);
01953   default:
01954     errno = EINVAL;
01955     return -1;
01956 }
01957   /* NOTREACHED */
01958 
01959 # elif defined (ACE_VXWORKS)
01960   ACE_UNUSED_ARG (name);
01961   ACE_UNUSED_ARG (attributes);
01962   ACE_UNUSED_ARG (sa);
01963   ACE_UNUSED_ARG (lock_type);
01964 
01965   return (*m = ::semMCreate (lock_scope)) == 0 ? -1 : 0;
01966 # endif /* ACE_HAS_PTHREADS */
01967 #else
01968   ACE_UNUSED_ARG (m);
01969   ACE_UNUSED_ARG (lock_scope);
01970   ACE_UNUSED_ARG (name);
01971   ACE_UNUSED_ARG (attributes);
01972   ACE_UNUSED_ARG (sa);
01973   ACE_UNUSED_ARG (lock_type);
01974   ACE_NOTSUP_RETURN (-1);
01975 #endif /* ACE_HAS_THREADS */
01976 }

int ACE_OS::mutex_lock ( ACE_mutex_t m,
const ACE_Time_Value timeout 
) [inline]

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 since some implementations of this method don't support recursive mutexes. If you want to use a recursive mutex see the methods below.

Definition at line 482 of file OS_NS_Thread.inl.

00484 {
00485   return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
00486 }

int ACE_OS::mutex_lock ( ACE_mutex_t m,
const ACE_Time_Value timeout 
)

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 since some implementations of this method don't support recursive mutexes. If you want to use a recursive mutex see the methods below.

Definition at line 2155 of file OS_NS_Thread.cpp.

02157 {
02158 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS)
02159 
02160 #  if defined (ACE_HAS_PTHREADS)
02161   int result;
02162 
02163   // "timeout" should be an absolute time.
02164 
02165   timespec_t ts = timeout;  // Calls ACE_Time_Value::operator timespec_t().
02166 
02167   // Note that the mutex should not be a recursive one, i.e., it
02168   // should only be a standard mutex or an error checking mutex.
02169 
02170   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result);
02171 
02172   // We need to adjust this to make the errno values consistent.
02173   if (result == -1 && errno == ETIMEDOUT)
02174     errno = ETIME;
02175   return result;
02176 
02177 #  elif defined (ACE_HAS_WTHREADS)
02178   // Note that we must convert between absolute time (which is passed
02179   // as a parameter) and relative time (which is what the system call
02180   // expects).
02181   ACE_Time_Value relative_time = timeout.to_relative_time ();
02182 
02183   switch (m->type_)
02184   {
02185     case USYNC_PROCESS:
02186       switch (::WaitForSingleObject (m->proc_mutex_,
02187                 relative_time.msec ()))
02188       {
02189         case WAIT_OBJECT_0:
02190         case WAIT_ABANDONED:
02191           // We will ignore abandonments in this method
02192           // Note that we still hold the lock
02193           return 0;
02194         case WAIT_TIMEOUT:
02195           errno = ETIME;
02196           return -1;
02197         default:
02198           // This is a hack, we need to find an appropriate mapping...
02199           ACE_OS::set_errno_to_last_error ();
02200           return -1;
02201       }
02202     case USYNC_THREAD:
02203       ACE_NOTSUP_RETURN (-1);
02204     default:
02205       errno = EINVAL;
02206       return -1;
02207   }
02208   /* NOTREACHED */
02209 
02210 #  elif defined (ACE_VXWORKS)
02211 
02212   // Note that we must convert between absolute time (which is passed
02213   // as a parameter) and relative time (which is what the system call
02214   // expects).
02215   ACE_Time_Value relative_time = timeout.to_relative_time ();
02216 
02217   int ticks_per_sec = ::sysClkRateGet ();
02218 
02219   int ticks = relative_time.sec() * ticks_per_sec +
02220       relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02221   if (::semTake (*m, ticks) == ERROR)
02222   {
02223     if (errno == S_objLib_OBJ_TIMEOUT)
02224         // Convert the VxWorks errno to one that's common for to ACE
02225         // platforms.
02226       errno = ETIME;
02227     else if (errno == S_objLib_OBJ_UNAVAILABLE)
02228       errno = EBUSY;
02229     return -1;
02230   }
02231   else
02232     return 0;
02233 #  endif /* ACE_HAS_PTHREADS */
02234 
02235 #else
02236   ACE_UNUSED_ARG (m);
02237   ACE_UNUSED_ARG (timeout);
02238   ACE_NOTSUP_RETURN (-1);
02239 #endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */
02240 }

int ACE_OS::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.

Definition at line 2116 of file OS_NS_Thread.cpp.

02118 {
02119   ACE_OS_TRACE ("ACE_OS::mutex_lock");
02120 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02121   abandoned = 0;
02122   switch (m->type_)
02123   {
02124     case USYNC_PROCESS:
02125       switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02126       {
02127         //
02128           // Timeout can't occur, so don't bother checking...
02129         //
02130         case WAIT_OBJECT_0:
02131           return 0;
02132         case WAIT_ABANDONED:
02133           abandoned = 1;
02134           return 0;  // something goofed, but we hold the lock ...
02135         default:
02136           // This is a hack, we need to find an appropriate mapping...
02137           ACE_OS::set_errno_to_last_error ();
02138           return -1;
02139       }
02140     case USYNC_THREAD:
02141       return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02142     default:
02143       errno = EINVAL;
02144       return -1;
02145   }
02146   /* NOTREACHED */
02147 #else
02148   ACE_UNUSED_ARG (m);
02149   ACE_UNUSED_ARG (abandoned);
02150   ACE_NOTSUP_RETURN (-1);
02151 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02152 }

int ACE_OS::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.

Definition at line 2068 of file OS_NS_Thread.cpp.

02069 {
02070   // ACE_OS_TRACE ("ACE_OS::mutex_lock");
02071 #if defined (ACE_HAS_THREADS)
02072 # if defined (ACE_HAS_PTHREADS)
02073   // Note, don't use "::" here since the following call is often a macro.
02074   int result;
02075   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), result),
02076                      int, -1);
02077 # elif defined (ACE_HAS_STHREADS)
02078   int result;
02079   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), result), int, -1);
02080 # elif defined (ACE_HAS_WTHREADS)
02081   switch (m->type_)
02082 {
02083   case USYNC_PROCESS:
02084     switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02085       {
02086         //
02087         // Timeout can't occur, so don't bother checking...
02088         //
02089       case WAIT_OBJECT_0:
02090       case WAIT_ABANDONED:
02091         // We will ignore abandonments in this method
02092         // Note that we still hold the lock
02093         return 0;
02094       default:
02095         // This is a hack, we need to find an appropriate mapping...
02096         ACE_OS::set_errno_to_last_error ();
02097         return -1;
02098       }
02099   case USYNC_THREAD:
02100     return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02101   default:
02102     errno = EINVAL;
02103     return -1;
02104 }
02105   /* NOTREACHED */
02106 # elif defined (ACE_VXWORKS)
02107   return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1;
02108 # endif /* Threads variety case */
02109 #else
02110   ACE_UNUSED_ARG (m);
02111   ACE_NOTSUP_RETURN (-1);
02112 #endif /* ACE_HAS_THREADS */
02113 }

void ACE_OS::mutex_lock_cleanup ( void *  mutex  ) 

Handle asynchronous thread cancellation cleanup.

Definition at line 2381 of file OS_NS_Thread.cpp.

02382 {
02383   ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup");
02384 #if defined (ACE_HAS_THREADS)
02385 # if defined (ACE_HAS_PTHREADS)
02386   ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex;
02387   ACE_OS::mutex_unlock (p_lock);
02388 # else
02389   ACE_UNUSED_ARG (mutex);
02390 # endif /* ACE_HAS_PTHREADS */
02391 #else
02392   ACE_UNUSED_ARG (mutex);
02393 #endif /* ACE_HAS_THREADS */
02394 }

int ACE_OS::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.

Definition at line 2306 of file OS_NS_Thread.cpp.

02307 {
02308 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02309   abandoned = 0;
02310   switch (m->type_)
02311   {
02312     case USYNC_PROCESS:
02313     {
02314         // Try for 0 milliseconds - i.e. nonblocking.
02315       switch (::WaitForSingleObject (m->proc_mutex_, 0))
02316       {
02317         case WAIT_OBJECT_0:
02318           return 0;
02319         case WAIT_ABANDONED:
02320           abandoned = 1;
02321           return 0;  // something goofed, but we hold the lock ...
02322         case WAIT_TIMEOUT:
02323           errno = EBUSY;
02324           return -1;
02325         default:
02326           ACE_OS::set_errno_to_last_error ();
02327           return -1;
02328       }
02329     }
02330     case USYNC_THREAD:
02331       return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
02332     default:
02333       errno = EINVAL;
02334       return -1;
02335   }
02336   /* NOTREACHED */
02337 #else
02338   ACE_UNUSED_ARG (m);
02339   ACE_UNUSED_ARG (abandoned);
02340   ACE_NOTSUP_RETURN (-1);
02341 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02342 }

int ACE_OS::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.

Definition at line 2243 of file OS_NS_Thread.cpp.

02244 {
02245   ACE_OS_TRACE ("ACE_OS::mutex_trylock");
02246 #if defined (ACE_HAS_THREADS)
02247 # if defined (ACE_HAS_PTHREADS)
02248   // Note, don't use "::" here since the following call is often a macro.
02249   int result;
02250   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), result),
02251                      int, -1);
02252 # elif defined (ACE_HAS_STHREADS)
02253   int result;
02254   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), result), int, -1);
02255 # elif defined (ACE_HAS_WTHREADS)
02256   switch (m->type_)
02257 {
02258   case USYNC_PROCESS:
02259   {
02260         // Try for 0 milliseconds - i.e. nonblocking.
02261     switch (::WaitForSingleObject (m->proc_mutex_, 0))
02262     {
02263       case WAIT_OBJECT_0:
02264         return 0;
02265       case WAIT_ABANDONED:
02266             // We will ignore abandonments in this method.  Note that
02267             // we still hold the lock.
02268         return 0;
02269       case WAIT_TIMEOUT:
02270         errno = EBUSY;
02271         return -1;
02272       default:
02273         ACE_OS::set_errno_to_last_error ();
02274         return -1;
02275     }
02276   }
02277   case USYNC_THREAD:
02278     return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
02279   default:
02280     errno = EINVAL;
02281     return -1;
02282 }
02283   /* NOTREACHED */
02284 # elif defined (ACE_VXWORKS)
02285   if (::semTake (*m, NO_WAIT) == ERROR)
02286     if (errno == S_objLib_OBJ_UNAVAILABLE)
02287 {
02288         // couldn't get the semaphore
02289   errno = EBUSY;
02290   return -1;
02291 }
02292     else
02293       // error
02294       return -1;
02295     else
02296     // got the semaphore
02297       return 0;
02298 # endif /* Threads variety case */
02299 #else
02300   ACE_UNUSED_ARG (m);
02301   ACE_NOTSUP_RETURN (-1);
02302 #endif /* ACE_HAS_THREADS */
02303 }

int ACE_OS::mutex_unlock ( ACE_mutex_t m  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2345 of file OS_NS_Thread.cpp.

02346 {
02347   ACE_OS_TRACE ("ACE_OS::mutex_unlock");
02348 #if defined (ACE_HAS_THREADS)
02349 # if defined (ACE_HAS_PTHREADS)
02350   // Note, don't use "::" here since the following call is often a macro.
02351   int result;
02352   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), result),
02353                      int, -1);
02354 # elif defined (ACE_HAS_STHREADS)
02355   int result;
02356   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), result), int, -1);
02357 # elif defined (ACE_HAS_WTHREADS)
02358   switch (m->type_)
02359 {
02360   case USYNC_PROCESS:
02361     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_),
02362                           ace_result_),
02363     int, -1);
02364   case USYNC_THREAD:
02365     return ACE_OS::thread_mutex_unlock (&m->thr_mutex_);
02366   default:
02367     errno = EINVAL;
02368     return -1;
02369 }
02370   /* NOTREACHED */
02371 # elif defined (ACE_VXWORKS)
02372   return ::semGive (*m) == OK ? 0 : -1;
02373 # endif /* Threads variety case */
02374 #else
02375   ACE_UNUSED_ARG (m);
02376   ACE_NOTSUP_RETURN (-1);
02377 #endif /* ACE_HAS_THREADS */
02378 }

int ACE_OS::nanosleep ( const struct timespec requested,
struct timespec remaining = 0 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 409 of file OS_NS_time.inl.

00411 {
00412   ACE_OS_TRACE ("ACE_OS::nanosleep");
00413 #if defined (ACE_HAS_CLOCK_GETTIME)
00414   // ::nanosleep () is POSIX 1003.1b.  So is ::clock_gettime ().  So,
00415   // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should
00416   // be available on the platform.  On Solaris 2.x, both functions
00417   // require linking with -lposix4.
00418   return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining);
00419 #else
00420   ACE_UNUSED_ARG (remaining);
00421 
00422   // Convert into seconds and microseconds.
00423   ACE_Time_Value tv (requested->tv_sec,
00424                      requested->tv_nsec / 1000);
00425   return ACE_OS::sleep (tv);
00426 #endif /* ACE_HAS_CLOCK_GETTIME */
00427 }

ACE_Export int ACE_OS::netdb_acquire ( void   ) 
ACE_Export int ACE_OS::netdb_release ( void   ) 
long ACE_OS::num_processors ( void   ) 

Get the number of CPUs configured in the machine.

Definition at line 400 of file OS_NS_unistd.cpp.

00401 {
00402   ACE_OS_TRACE ("ACE_OS::num_processors");
00403 
00404 #if defined (ACE_HAS_PHARLAP)
00405   return 1;
00406 #elif defined (ACE_WIN32)
00407   SYSTEM_INFO sys_info;
00408   ::GetSystemInfo (&sys_info);
00409   return sys_info.dwNumberOfProcessors;
00410 #elif defined (ACE_HAS_VXCPULIB)
00411   return vxCpuConfiguredGet();
00412 #elif defined (_SC_NPROCESSORS_CONF)
00413   return ::sysconf (_SC_NPROCESSORS_CONF);
00414 #elif defined (ACE_HAS_SYSCTL)
00415   int num_processors = 0;
00416   int mib[2] = { CTL_HW, HW_NCPU };
00417   size_t len = sizeof (num_processors);
00418   if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
00419     return num_processors;
00420   else
00421     return -1;
00422 #elif defined (__hpux)
00423   struct pst_dynamic psd;
00424   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00425     return psd.psd_max_proc_cnt;
00426   else
00427     return -1;
00428 #else
00429   ACE_NOTSUP_RETURN (-1);
00430 #endif
00431 }

long ACE_OS::num_processors_online ( void   ) 

Get the number of CPUs currently online.

Definition at line 434 of file OS_NS_unistd.cpp.

00435 {
00436   ACE_OS_TRACE ("ACE_OS::num_processors_online");
00437 
00438 #if defined (ACE_HAS_PHARLAP)
00439   return 1;
00440 #elif defined (ACE_WIN32)
00441   SYSTEM_INFO sys_info;
00442   ::GetSystemInfo (&sys_info);
00443   long active_processors = 0;
00444   DWORD_PTR mask = sys_info.dwActiveProcessorMask;
00445   while (mask != 0)
00446     {
00447       if (mask & 1)
00448         ++active_processors;
00449       mask >>= 1;
00450     }
00451   return active_processors;
00452 #elif defined (ACE_HAS_VXCPULIB)
00453   long num_cpu = 0;
00454   cpuset_t cpuset;
00455   CPUSET_ZERO (cpuset);
00456   cpuset = vxCpuEnabledGet();
00457   unsigned int const maxcpu = vxCpuConfiguredGet();
00458   for (unsigned int i =0; i < maxcpu; i++)
00459     {
00460       if (CPUSET_ISSET (cpuset, i))
00461         {
00462           ++num_cpu;
00463         }
00464     }
00465   return num_cpu;
00466 #elif defined (_SC_NPROCESSORS_ONLN)
00467   return ::sysconf (_SC_NPROCESSORS_ONLN);
00468 #elif defined (ACE_HAS_SYSCTL)
00469   int num_processors;
00470   int mib[2] = { CTL_HW, HW_NCPU };
00471   size_t len = sizeof (num_processors);
00472   if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
00473     return num_processors;
00474   else
00475     return -1;
00476 #elif defined (__hpux)
00477   struct pst_dynamic psd;
00478   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00479     return psd.psd_proc_cnt;
00480   else
00481     return -1;
00482 #else
00483   ACE_NOTSUP_RETURN (-1);
00484 #endif
00485 }

ACE_HANDLE ACE_OS::open ( const wchar_t filename,
int  mode,
mode_t  perms = ACE_DEFAULT_OPEN_PERMS,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Definition at line 136 of file OS_NS_fcntl.cpp.

00140 {
00141 #if defined (ACE_WIN32)
00142   // @@ (brunsch) Yuck, maybe there is a way to combine the code
00143   // here with the char version
00144 
00145   DWORD access = GENERIC_READ;
00146   if (ACE_BIT_ENABLED (mode, O_WRONLY))
00147     access = GENERIC_WRITE;
00148   else if (ACE_BIT_ENABLED (mode, O_RDWR))
00149     access = GENERIC_READ | GENERIC_WRITE;
00150 
00151   DWORD creation = OPEN_EXISTING;
00152 
00153   if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
00154     creation = CREATE_NEW;
00155   else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
00156     creation = CREATE_ALWAYS;
00157   else if (ACE_BIT_ENABLED (mode, _O_CREAT))
00158     creation = OPEN_ALWAYS;
00159   else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
00160     creation = TRUNCATE_EXISTING;
00161 
00162   DWORD flags = 0;
00163 
00164   if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
00165     flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
00166 
00167   if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
00168     flags |= FILE_FLAG_WRITE_THROUGH;
00169   if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
00170     flags |= FILE_FLAG_OVERLAPPED;
00171   if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
00172     flags |= FILE_FLAG_NO_BUFFERING;
00173   if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
00174     flags |= FILE_FLAG_RANDOM_ACCESS;
00175   if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
00176     flags |= FILE_FLAG_SEQUENTIAL_SCAN;
00177   if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
00178     flags |= FILE_FLAG_DELETE_ON_CLOSE;
00179   if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
00180     flags |= FILE_FLAG_BACKUP_SEMANTICS;
00181   if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
00182     flags |= FILE_FLAG_POSIX_SEMANTICS;
00183 
00184   ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
00185 
00186   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00187     {
00188       ACE_MT
00189         (
00190           ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> (
00191             ACE_OS_Object_Manager::preallocated_object[
00192               ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
00193           ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
00194         )
00195     }
00196 
00197   DWORD shared_mode = perms;
00198   SECURITY_ATTRIBUTES sa_buffer;
00199   SECURITY_DESCRIPTOR sd_buffer;
00200 
00201   ACE_HANDLE h = ::CreateFileW (filename,
00202                                 access,
00203                                 shared_mode,
00204                                 ACE_OS::default_win32_security_attributes_r
00205                                   (sa, &sa_buffer, &sd_buffer),
00206                                 creation,
00207                                 flags,
00208                                 0);
00209 
00210   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00211     {
00212       LONG high_size = 0;
00213       if (h != ACE_INVALID_HANDLE
00214           && ::SetFilePointer (h,
00215                                0,
00216                                &high_size,
00217                                FILE_END) == INVALID_SET_FILE_POINTER
00218           && GetLastError () != NO_ERROR)
00219         {
00220           ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
00221           ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00222         }
00223 
00224       ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
00225     }
00226 
00227   if (h == ACE_INVALID_HANDLE)
00228     ACE_FAIL_RETURN (h);
00229   else
00230     return h;
00231 #else /* ACE_WIN32 */
00232   // Just emulate with ascii version
00233   return ACE_OS::open (ACE_Wide_To_Ascii (filename).char_rep (),
00234                        mode,
00235                        perms,
00236                        sa);
00237 #endif /* ACE_WIN32 */
00238 }

ACE_HANDLE ACE_OS::open ( const char *  filename,
int  mode,
mode_t  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.

Definition at line 15 of file OS_NS_fcntl.cpp.

00019 {
00020   ACE_OS_TRACE ("ACE_OS::open");
00021 
00022 #if defined (ACE_WIN32)
00023   DWORD access = GENERIC_READ;
00024   if (ACE_BIT_ENABLED (mode, O_WRONLY))
00025     access = GENERIC_WRITE;
00026   else if (ACE_BIT_ENABLED (mode, O_RDWR))
00027     access = GENERIC_READ | GENERIC_WRITE;
00028 
00029   DWORD creation = OPEN_EXISTING;
00030 
00031   if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
00032     creation = CREATE_NEW;
00033   else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
00034     creation = CREATE_ALWAYS;
00035   else if (ACE_BIT_ENABLED (mode, _O_CREAT))
00036     creation = OPEN_ALWAYS;
00037   else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
00038     creation = TRUNCATE_EXISTING;
00039 
00040   DWORD flags = 0;
00041 
00042   if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
00043     flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
00044 
00045   if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
00046     flags |= FILE_FLAG_WRITE_THROUGH;
00047   if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
00048     flags |= FILE_FLAG_OVERLAPPED;
00049   if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
00050     flags |= FILE_FLAG_NO_BUFFERING;
00051   if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
00052     flags |= FILE_FLAG_RANDOM_ACCESS;
00053   if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
00054     flags |= FILE_FLAG_SEQUENTIAL_SCAN;
00055   if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
00056     flags |= FILE_FLAG_DELETE_ON_CLOSE;
00057   if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
00058     flags |= FILE_FLAG_BACKUP_SEMANTICS;
00059   if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
00060     flags |= FILE_FLAG_POSIX_SEMANTICS;
00061 
00062   ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
00063 
00064   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00065     {
00066       ACE_MT
00067         (
00068           ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> (
00069             ACE_OS_Object_Manager::preallocated_object[
00070               ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
00071           ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
00072         )
00073     }
00074 
00075   DWORD shared_mode = perms;
00076   SECURITY_ATTRIBUTES sa_buffer;
00077   SECURITY_DESCRIPTOR sd_buffer;
00078 
00079 #if defined (ACE_HAS_WINCE)
00080   ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (),
00081                                 access,
00082                                 shared_mode,
00083                                 ACE_OS::default_win32_security_attributes_r
00084                                   (sa, &sa_buffer, &sd_buffer),
00085                                 creation,
00086                                 flags,
00087                                 0);
00088 #else /* ACE_HAS_WINCE */
00089   ACE_HANDLE h = ::CreateFileA (filename,
00090                                 access,
00091                                 shared_mode,
00092                                 ACE_OS::default_win32_security_attributes_r
00093                                   (sa, &sa_buffer, &sd_buffer),
00094                                 creation,
00095                                 flags,
00096                                 0);
00097 #endif /* ACE_HAS_WINCE */
00098 
00099   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00100     {
00101       LONG high_size = 0;
00102       if (h != ACE_INVALID_HANDLE
00103           && ::SetFilePointer (h,
00104                                0,
00105                                &high_size,
00106                                FILE_END) == INVALID_SET_FILE_POINTER
00107           && GetLastError () != NO_ERROR)
00108         {
00109           ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
00110           ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00111         }
00112 
00113       ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
00114     }
00115 
00116   if (h == ACE_INVALID_HANDLE)
00117     ACE_FAIL_RETURN (h);
00118   else
00119     return h;
00120 #elif defined (INTEGRITY)
00121   ACE_UNUSED_ARG (sa);
00122   if(!strcmp(filename,ACE_DEV_NULL)) {
00123       ACE_OSCALL_RETURN (::AllocateNullConsoleDescriptor(), ACE_HANDLE, -1);
00124   }
00125   else {
00126       ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1);
00127   }
00128 #else
00129   ACE_UNUSED_ARG (sa);
00130   ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00131 #endif /* ACE_WIN32 */
00132 }

ACE_DIR * ACE_OS::opendir ( const ACE_TCHAR filename  )  [inline]

Definition at line 33 of file OS_NS_dirent.inl.

00034 {
00035 #if defined (ACE_HAS_DIRENT)
00036 #    if defined (ACE_WIN32) && defined (ACE_LACKS_OPENDIR)
00037   return ::ACE_OS::opendir_emulation (filename);
00038 #  elif defined (ACE_HAS_WOPENDIR) && defined (ACE_USES_WCHAR)
00039   return ::wopendir (filename);
00040 #    elif defined (ACE_HAS_NONCONST_OPENDIR)
00041   return ::opendir (const_cast<char *> (filename));
00042 #    else /* ! ACE_WIN32 && ACE_LACKS_OPENDIR */
00043   return ::opendir (ACE_TEXT_ALWAYS_CHAR (filename));
00044 #    endif /* ACE_WIN32 && ACE_LACKS_OPENDIR */
00045 #else
00046   ACE_UNUSED_ARG (filename);
00047   ACE_NOTSUP_RETURN (0);
00048 #endif /* ACE_HAS_DIRENT */
00049 }

void ACE_OS::perror ( const wchar_t s  )  [inline]

Definition at line 830 of file OS_NS_stdio.inl.

00831 {
00832   ACE_OS_TRACE ("ACE_OS::perror");
00833 #if defined (ACE_LACKS_PERROR)
00834   ACE_UNUSED_ARG (s);
00835 #elif defined (ACE_WIN32)
00836   ::_wperror (s);
00837 #else
00838   ACE_Wide_To_Ascii n_s (s);
00839   ::perror (n_s.char_rep ());
00840 #endif /* ACE_LACKS_PERROR */
00841 }

void ACE_OS::perror ( const char *  s  )  [inline]

Definition at line 818 of file OS_NS_stdio.inl.

00819 {
00820   ACE_OS_TRACE ("ACE_OS::perror");
00821 #if defined (ACE_LACKS_PERROR)
00822   ACE_UNUSED_ARG (s);
00823 #else
00824   ::perror (s);
00825 #endif /* ACE_HAS_WINCE */
00826 }

int ACE_OS::pipe ( ACE_HANDLE  handles[]  )  [inline]

Definition at line 806 of file OS_NS_unistd.inl.

00807 {
00808   ACE_OS_TRACE ("ACE_OS::pipe");
00809 # if defined (ACE_LACKS_PIPE)
00810   ACE_UNUSED_ARG (fds);
00811   ACE_NOTSUP_RETURN (-1);
00812 # elif defined (ACE_WIN32)
00813   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL
00814                         (::CreatePipe (&fds[0], &fds[1], 0, 0),
00815                          ace_result_), int, -1);
00816 # else
00817   ACE_OSCALL_RETURN (::pipe (fds), int, -1);
00818 # endif /* ACE_LACKS_PIPE */
00819 }

int ACE_OS::poll ( struct pollfd *  pollfds,
unsigned long  len,
const ACE_Time_Value tv 
)

Definition at line 26 of file OS_NS_poll.inl.

00029 {
00030   ACE_OS_TRACE ("ACE_OS::poll");
00031 #if defined (ACE_HAS_POLL)
00032   ACE_OSCALL_RETURN (::poll (pollfds, len, int (timeout.msec ())), int, -1);
00033 #else
00034   ACE_UNUSED_ARG (timeout);
00035   ACE_UNUSED_ARG (len);
00036   ACE_UNUSED_ARG (pollfds);
00037 
00038   ACE_NOTSUP_RETURN (-1);
00039 #endif /* ACE_HAS_POLL */
00040 }

int ACE_OS::poll ( struct pollfd *  pollfds,
unsigned long  len,
const ACE_Time_Value tv = 0 
)

Definition at line 8 of file OS_NS_poll.inl.

00011 {
00012   ACE_OS_TRACE ("ACE_OS::poll");
00013 #if defined (ACE_HAS_POLL)
00014   int to = timeout == 0 ? -1 : int (timeout->msec ());
00015   ACE_OSCALL_RETURN (::poll (pollfds, len, to), int, -1);
00016 #else
00017   ACE_UNUSED_ARG (timeout);
00018   ACE_UNUSED_ARG (len);
00019   ACE_UNUSED_ARG (pollfds);
00020 
00021   ACE_NOTSUP_RETURN (-1);
00022 #endif /* ACE_HAS_POLL */
00023 }

int ACE_OS::posix_devctl ( int  filedes,
int  dcmd,
void *  dev_data_ptr,
size_t  nbyte,
int *  dev_info_ptr 
)

Definition at line 10 of file OS_NS_devctl.inl.

00013 {
00014   ACE_OS_TRACE ("ACE_OS::posix_devctl");
00015 #ifdef ACE_LACKS_POSIX_DEVCTL
00016   ACE_UNUSED_ARG (nbyte);
00017   ACE_UNUSED_ARG (dev_info_ptr);
00018 # if defined ACE_EMULATE_POSIX_DEVCTL && ACE_EMULATE_POSIX_DEVCTL
00019   ACE_OSCALL_RETURN (::ioctl (filedes, dcmd, dev_data_ptr), int, -1);
00020 # else
00021   ACE_UNUSED_ARG (filedes);
00022   ACE_UNUSED_ARG (dcmd);
00023   ACE_UNUSED_ARG (dev_data_ptr);
00024   ACE_NOTSUP_RETURN (-1);
00025 # endif
00026 #else
00027   ACE_OSCALL_RETURN (::posix_devctl (filedes, dcmd, dev_data_ptr, nbyte,
00028                                      dev_info_ptr), int, -1);
00029 #endif
00030 }

ssize_t ACE_OS::pread ( ACE_HANDLE  handle,
void *  buf,
size_t  nbyte,
ACE_OFF_T  offset 
)

Definition at line 515 of file OS_NS_unistd.cpp.

00519 {
00520 # if defined (ACE_HAS_P_READ_WRITE)
00521 #   if defined (ACE_WIN32)
00522 
00523   ACE_OS_GUARD
00524 
00525   // Remember the original file pointer position
00526   LONG original_high_position = 0;
00527   DWORD original_low_position = ::SetFilePointer (handle,
00528                                                   0,
00529                                                   &original_high_position,
00530                                                   FILE_CURRENT);
00531 
00532   if (original_low_position == INVALID_SET_FILE_POINTER
00533       && GetLastError () != NO_ERROR)
00534     {
00535       ACE_OS::set_errno_to_last_error ();
00536       return -1;
00537     }
00538 
00539   // Go to the correct position
00540   LONG low_offset = ACE_LOW_PART (offset);
00541   LONG high_offset = ACE_HIGH_PART (offset);
00542   DWORD altered_position = ::SetFilePointer (handle,
00543                                              low_offset,
00544                                              &high_offset,
00545                                              FILE_BEGIN);
00546   if (altered_position == INVALID_SET_FILE_POINTER
00547       && GetLastError () != NO_ERROR)
00548     {
00549       ACE_OS::set_errno_to_last_error ();
00550       return -1;
00551     }
00552 
00553   DWORD bytes_read;
00554 
00555 #     if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00556 
00557   OVERLAPPED overlapped;
00558   overlapped.Internal = 0;
00559   overlapped.InternalHigh = 0;
00560   overlapped.Offset = low_offset;
00561   overlapped.OffsetHigh = high_offset;
00562   overlapped.hEvent = 0;
00563 
00564   BOOL result = ::ReadFile (handle,
00565                             buf,
00566                             static_cast <DWORD> (nbytes),
00567                             &bytes_read,
00568                             &overlapped);
00569 
00570   if (result == FALSE)
00571     {
00572       if (::GetLastError () != ERROR_IO_PENDING)
00573         return -1;
00574 
00575       else
00576         {
00577           result = ::GetOverlappedResult (handle,
00578                                           &overlapped,
00579                                           &bytes_read,
00580                                           TRUE);
00581           if (result == FALSE)
00582             return -1;
00583         }
00584     }
00585 
00586 #     else /* ACE_HAS_WIN32_OVERLAPPED_IO */
00587 
00588   BOOL result = ::ReadFile (handle,
00589                             buf,
00590                             nbytes,
00591                             &bytes_read,
00592                             0);
00593   if (result == FALSE)
00594     return -1;
00595 
00596 #     endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00597 
00598   // Reset the original file pointer position
00599   if (::SetFilePointer (handle,
00600                         original_low_position,
00601                         &original_high_position,
00602                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00603       && GetLastError () != NO_ERROR)
00604     {
00605       ACE_OS::set_errno_to_last_error ();
00606       return -1;
00607     }
00608 
00609   return (ssize_t) bytes_read;
00610 
00611 #   else /* ACE_WIN32 */
00612 
00613   return ::pread (handle, buf, nbytes, offset);
00614 
00615 #   endif /* ACE_WIN32 */
00616 
00617 # else /* ACE_HAS_P_READ_WRITE */
00618 
00619   ACE_OS_GUARD
00620 
00621   // Remember the original file pointer position
00622   ACE_OFF_T original_position = ACE_OS::lseek (handle,
00623                                                0,
00624                                                SEEK_CUR);
00625 
00626   if (original_position == -1)
00627     return -1;
00628 
00629   // Go to the correct position
00630   ACE_OFF_T altered_position = ACE_OS::lseek (handle, offset, SEEK_SET);
00631 
00632   if (altered_position == -1)
00633     return -1;
00634 
00635   ssize_t const bytes_read = ACE_OS::read (handle, buf, nbytes);
00636 
00637   if (bytes_read == -1)
00638     return -1;
00639 
00640   if (ACE_OS::lseek (handle,
00641                      original_position,
00642                      SEEK_SET) == -1)
00643     return -1;
00644 
00645   return bytes_read;
00646 
00647 # endif /* ACE_HAS_P_READ_WRITE */
00648 }

int ACE_OS::printf ( const wchar_t format,
  ... 
)

Definition at line 352 of file OS_NS_stdio.cpp.

00353 {
00354   // ACE_OS_TRACE ("ACE_OS::printf");
00355 #if defined (ACE_LACKS_VA_FUNCTIONS)
00356   ACE_UNUSED_ARG (format);
00357   ACE_NOTSUP_RETURN (-1);
00358 #else
00359   va_list ap;
00360   va_start (ap, format);
00361   int const result = ACE_OS::vprintf (format, ap);
00362   va_end (ap);
00363   return result;
00364 #endif /* ACE_LACKS_VA_FUNCTIONS */
00365 }

int ACE_OS::printf ( const char *  format,
  ... 
)

Definition at line 334 of file OS_NS_stdio.cpp.

00335 {
00336   // ACE_OS_TRACE ("ACE_OS::printf");
00337 #if defined (ACE_LACKS_VA_FUNCTIONS)
00338   ACE_UNUSED_ARG (format);
00339   ACE_NOTSUP_RETURN (-1);
00340 #else
00341   va_list ap;
00342   va_start (ap, format);
00343   int const result = ACE_OS::vprintf (format, ap);
00344   va_end (ap);
00345   return result;
00346 #endif /* ACE_LACKS_VA_FUNCTIONS */
00347 }

long ACE_OS::priority_control ( ACE_idtype_t  idtype,
ACE_id_t  identifier,
int  cmd,
void *  arg 
) [inline]

Low-level interface to priocntl(2).

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

Definition at line 585 of file OS_NS_Thread.inl.

00586 {
00587   ACE_OS_TRACE ("ACE_OS::priority_control");
00588 #if defined (ACE_HAS_PRIOCNTL)
00589   ACE_OSCALL_RETURN (priocntl (idtype, identifier, cmd, static_cast<caddr_t> (arg)),
00590                      long, -1);
00591 #else  /* ! ACE_HAS_PRIOCNTL*/
00592   ACE_UNUSED_ARG (idtype);
00593   ACE_UNUSED_ARG (identifier);
00594   ACE_UNUSED_ARG (cmd);
00595   ACE_UNUSED_ARG (arg);
00596   ACE_NOTSUP_RETURN (-1);
00597 #endif /* ! ACE_HAS_PRIOCNTL*/
00598 }

int ACE_OS::pthread_sigmask ( int  how,
const sigset_t nsp,
sigset_t osp 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 33 of file OS_NS_signal.inl.

00034 {
00035 #if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_SIGMASK)
00036   int result;
00037 # ifdef ACE_PTHREAD_SIGMASK_MACRO
00038   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (ACE_PTHREAD_SIGMASK_MACRO (how, nsp, osp)
00039                                       , result), int, -1);
00040 # elif defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK)
00041   sigset_t *ncnsp = const_cast<sigset_t *>(nsp);
00042   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsp, osp),
00043                                        result),
00044                      int,
00045                      -1);
00046 # else
00047   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp),
00048                                        result),
00049                      int,
00050                      -1);
00051 # endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */
00052 #else /* !ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
00053   ACE_UNUSED_ARG (how);
00054   ACE_UNUSED_ARG (nsp);
00055   ACE_UNUSED_ARG (osp);
00056   ACE_NOTSUP_RETURN (-1);
00057 #endif /* ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
00058 }

int ACE_OS::putc ( int  c,
FILE *  fp 
) [inline]

Definition at line 704 of file OS_NS_stdio.inl.

00705 {
00706 #ifdef ACE_LACKS_PUTC
00707   ACE_UNUSED_ARG (c);
00708   ACE_UNUSED_ARG (fp);
00709   ACE_NOTSUP_RETURN (-1);
00710 #else
00711   return ace_putc_helper (c, fp);
00712 #endif
00713 }

int ACE_OS::putenv ( const wchar_t string  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 380 of file OS_NS_stdlib.inl.

00381 {
00382   ACE_OS_TRACE ("ACE_OS::putenv");
00383 #if defined (ACE_LACKS_PUTENV)
00384   ACE_UNUSED_ARG (string);
00385   ACE_NOTSUP_RETURN (-1);
00386 #else
00387   ACE_OSCALL_RETURN (::_wputenv (string), int, -1);
00388 #endif /* ACE_LACKS_PUTENV */
00389 }

int ACE_OS::putenv ( const char *  string  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 312 of file OS_NS_stdlib.inl.

00313 {
00314   ACE_OS_TRACE ("ACE_OS::putenv");
00315 #if defined (ACE_LACKS_PUTENV) && defined (ACE_HAS_SETENV)
00316   int result = 0;
00317   char *sp = ACE_OS::strchr (const_cast <char *> (string), '=');
00318   if (sp)
00319     {
00320       char *stmp = ACE_OS::strdup (string);
00321       if (stmp)
00322         {
00323           stmp[sp - string] = '\0';
00324           result = ACE_OS::setenv (stmp, sp+sizeof (char), 1);
00325           ACE_OS::free (stmp);
00326         }
00327       else
00328         {
00329           errno = ENOMEM;
00330           result = -1;
00331         }
00332     }
00333   else
00334     {
00335       result = ACE_OS::setenv (string, "", 1);
00336     }
00337 
00338   return result;
00339 #elif defined (ACE_LACKS_PUTENV)
00340   ACE_UNUSED_ARG (string);
00341   ACE_NOTSUP_RETURN (0);
00342 #elif defined (ACE_PUTENV_EQUIVALENT)
00343   ACE_OSCALL_RETURN (ACE_PUTENV_EQUIVALENT (const_cast <char *> (string)), int, -1);
00344 #else /* ! ACE_HAS_WINCE */
00345   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::putenv (const_cast <char *> (string)), int, -1);
00346 #endif /* ACE_LACKS_PUTENV && ACE_HAS_SETENV */
00347 }

int ACE_OS::putmsg ( ACE_HANDLE  handle,
const struct strbuf ctl,
const struct strbuf data,
int  flags 
) [inline]

Definition at line 145 of file OS_NS_stropts.inl.

00147 {
00148   ACE_OS_TRACE ("ACE_OS::putmsg");
00149 #if defined (ACE_HAS_STREAM_PIPES)
00150   ACE_OSCALL_RETURN (::putmsg (handle,
00151                                (ACE_STRBUF_TYPE) ctl,
00152                                (ACE_STRBUF_TYPE) data,
00153                                flags), int, -1);
00154 #else
00155   ACE_UNUSED_ARG (flags);
00156   ssize_t result;
00157   if (ctl == 0 && data == 0)
00158     {
00159       errno = EINVAL;
00160       return 0;
00161     }
00162   // Handle the two easy cases.
00163   else if (ctl != 0)
00164     {
00165       result =  ACE_OS::write (handle, ctl->buf, ctl->len);
00166       return static_cast<int> (result);
00167     }
00168   else if (data != 0)
00169     {
00170       result = ACE_OS::write (handle, data->buf, data->len);
00171       return static_cast<int> (result);
00172     }
00173   else
00174     {
00175       // This is the hard case.
00176       char *buf;
00177 #if defined (ACE_HAS_ALLOC_HOOKS)
00178       ACE_ALLOCATOR_RETURN (buf, static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (ctl->len + data->len))), -1);
00179 #else
00180       ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
00181 #endif /* ACE_HAS_ALLOC_HOOKS */
00182       ACE_OS::memcpy (buf, ctl->buf, ctl->len);
00183       ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
00184       result = ACE_OS::write (handle, buf, ctl->len + data->len);
00185 #if defined (ACE_HAS_ALLOC_HOOKS)
00186       ACE_Allocator::instance()->free(buf);
00187 #else
00188       delete [] buf;
00189 #endif /* ACE_HAS_ALLOC_HOOKS */
00190 
00191       return static_cast<int> (result);
00192     }
00193 #endif /* ACE_HAS_STREAM_PIPES */
00194 }

int ACE_OS::putpmsg ( ACE_HANDLE  handle,
const struct strbuf ctl,
const struct strbuf data,
int  band,
int  flags 
) [inline]

Definition at line 197 of file OS_NS_stropts.inl.

00202 {
00203   ACE_OS_TRACE ("ACE_OS::putpmsg");
00204 #if defined (ACE_HAS_STREAM_PIPES)
00205   ACE_OSCALL_RETURN (::putpmsg (handle,
00206                                 (ACE_STRBUF_TYPE) ctl,
00207                                 (ACE_STRBUF_TYPE) data,
00208                                 band, flags), int, -1);
00209 #else
00210   ACE_UNUSED_ARG (flags);
00211   ACE_UNUSED_ARG (band);
00212   return ACE_OS::putmsg (handle, ctl, data, flags);
00213 #endif /* ACE_HAS_STREAM_PIPES */
00214 }

int ACE_OS::puts ( const wchar_t s  )  [inline]

Definition at line 858 of file OS_NS_stdio.inl.

00859 {
00860   ACE_OS_TRACE ("ACE_OS::puts");
00861 #if defined (ACE_WIN32)
00862   ACE_OSCALL_RETURN (::_putws (s), int, -1);
00863 #else /* ACE_WIN32 */
00864   // There's no putws()...
00865   ACE_Wide_To_Ascii n_s (s);
00866   ACE_OSCALL_RETURN (::puts (n_s.char_rep ()), int, -1);
00867 #endif /* ACE_WIN32 */
00868 }

int ACE_OS::puts ( const char *  s  )  [inline]

Definition at line 845 of file OS_NS_stdio.inl.

00846 {
00847   ACE_OS_TRACE ("ACE_OS::puts");
00848 #if defined (ACE_LACKS_PUTS)
00849   ACE_UNUSED_ARG (s);
00850   ACE_NOTSUP_RETURN (-1);
00851 #else
00852   ACE_OSCALL_RETURN (::puts (s), int, -1);
00853 #endif /* ACE_LACKS_PUTS */
00854 }

ssize_t ACE_OS::pwrite ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_OFF_T  offset 
)

Definition at line 651 of file OS_NS_unistd.cpp.

00655 {
00656 # if defined (ACE_HAS_P_READ_WRITE)
00657 #   if defined (ACE_WIN32)
00658 
00659   ACE_OS_GUARD
00660 
00661   // Remember the original file pointer position
00662   LONG original_high_position = 0;
00663   DWORD original_low_position = ::SetFilePointer (handle,
00664                                                   0,
00665                                                   &original_high_position,
00666                                                   FILE_CURRENT);
00667 
00668   if (original_low_position == INVALID_SET_FILE_POINTER
00669       && GetLastError () != NO_ERROR)
00670     {
00671       ACE_OS::set_errno_to_last_error ();
00672       return -1;
00673     }
00674 
00675   DWORD bytes_written;
00676   LONG low_offset = ACE_LOW_PART (offset);
00677   LONG high_offset = ACE_HIGH_PART (offset);
00678 
00679 #     if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00680 
00681   OVERLAPPED overlapped;
00682   overlapped.Internal = 0;
00683   overlapped.InternalHigh = 0;
00684   overlapped.Offset = low_offset;
00685   overlapped.OffsetHigh = high_offset;
00686   overlapped.hEvent = 0;
00687 
00688   BOOL result = ::WriteFile (handle,
00689                              buf,
00690                              static_cast <DWORD> (nbytes),
00691                              &bytes_written,
00692                              &overlapped);
00693 
00694   if (result == FALSE)
00695     {
00696       if (::GetLastError () != ERROR_IO_PENDING)
00697         {
00698           return -1;
00699         }
00700       else
00701         {
00702           result = ::GetOverlappedResult (handle,
00703                                           &overlapped,
00704                                           &bytes_written,
00705                                           TRUE);
00706           if (result == FALSE)
00707             return -1;
00708         }
00709     }
00710 
00711 #     else /* ACE_HAS_WIN32_OVERLAPPED_IO */
00712 
00713   if (::SetFilePointer (handle,
00714                         low_offset,
00715                         &high_offset,
00716                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00717                         && ::GetLastError () != NO_ERROR)
00718     {
00719       ACE_OS::set_errno_to_last_error ();
00720       return -1;
00721     }
00722 
00723   BOOL result = ::WriteFile (handle,
00724                              buf,
00725                              nbytes,
00726                              &bytes_written,
00727                              0);
00728   if (result == FALSE)
00729     return -1;
00730 
00731 #     endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00732 
00733   // Reset the original file pointer position
00734   if (::SetFilePointer (handle,
00735                         original_low_position,
00736                         &original_high_position,
00737                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00738       && GetLastError () != NO_ERROR)
00739     {
00740       ACE_OS::set_errno_to_last_error ();
00741       return -1;
00742     }
00743 
00744   return (ssize_t) bytes_written;
00745 
00746 #   else /* ACE_WIN32 */
00747 #     if defined (ACE_HAS_NON_CONST_PWRITE)
00748   return ::pwrite (handle, const_cast<void*> (buf), nbytes, offset);
00749 #     else
00750   return ::pwrite (handle, buf, nbytes, offset);
00751 #     endif
00752 #   endif /* ACE_WIN32 */
00753 # else /* ACE_HAS_P_READ_WRITE */
00754 
00755   ACE_OS_GUARD
00756 
00757   // Remember the original file pointer position
00758   ACE_OFF_T original_position = ACE_OS::lseek (handle,
00759                                                0,
00760                                                SEEK_CUR);
00761   if (original_position == -1)
00762     return -1;
00763 
00764   // Go to the correct position
00765   ACE_OFF_T altered_position = ACE_OS::lseek (handle,
00766                                               offset,
00767                                               SEEK_SET);
00768   if (altered_position == -1)
00769     return -1;
00770 
00771   ssize_t const bytes_written = ACE_OS::write (handle,
00772                                                buf,
00773                                                nbytes);
00774   if (bytes_written == -1)
00775     return -1;
00776 
00777   if (ACE_OS::lseek (handle,
00778                      original_position,
00779                      SEEK_SET) == -1)
00780     return -1;
00781 
00782   return bytes_written;
00783 # endif /* ACE_HAS_P_READ_WRITE */
00784 }

void ACE_OS::qsort ( void *  base,
size_t  nel,
size_t  width,
ACE_COMPARE_FUNC  compar 
) [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 393 of file OS_NS_stdlib.inl.

00397 {
00398 #if !defined (ACE_LACKS_QSORT)
00399   ::qsort (base, nel, width, compar);
00400 #else
00401   ACE_UNUSED_ARG (base);
00402   ACE_UNUSED_ARG (nel);
00403   ACE_UNUSED_ARG (width);
00404   ACE_UNUSED_ARG (compar);
00405 #endif /* !ACE_LACKS_QSORT */
00406 }

int ACE_OS::raise ( const int  signum  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 249 of file OS_NS_signal.inl.

00250 {
00251 #if defined (ACE_LACKS_RAISE)
00252   ACE_UNUSED_ARG (signum);
00253   ACE_NOTSUP_RETURN (-1);
00254 #else
00255   ACE_OSCALL_RETURN (::raise (signum), int, -1);
00256 #endif /* ACE_LACKS_RAISE */
00257 }

int ACE_OS::rand ( void   )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 409 of file OS_NS_stdlib.inl.

00410 {
00411   ACE_OS_TRACE ("ACE_OS::rand");
00412 #if !defined (ACE_LACKS_RAND)
00413   ACE_OSCALL_RETURN (::rand (), int, -1);
00414 #else
00415   ACE_NOTSUP_RETURN (-1);
00416 #endif /* ACE_LACKS_RAND */
00417 }

int ACE_OS::rand_r ( unsigned int *  seed  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 420 of file OS_NS_stdlib.inl.

00421 {
00422   ACE_OS_TRACE ("ACE_OS::rand_r");
00423 #if defined (ACE_LACKS_RAND_R)
00424   long new_seed = (long) *seed;
00425   if (new_seed == 0)
00426     new_seed = 0x12345987;
00427   long temp = new_seed / 127773;
00428   new_seed = 16807 * (new_seed - temp * 127773) - 2836 * temp;
00429   if (new_seed < 0)
00430     new_seed += 2147483647;
00431   *seed = (unsigned int)new_seed;
00432   return (int) (new_seed & RAND_MAX);
00433 #else
00434   return ace_rand_r_helper (seed);
00435 # endif /* ACE_LACKS_RAND_R */
00436 }

ssize_t ACE_OS::read ( ACE_HANDLE  handle,
void *  buf,
size_t  len,
ACE_OVERLAPPED overlapped 
) [inline]

Definition at line 771 of file OS_NS_unistd.inl.

00773 {
00774   ACE_OS_TRACE ("ACE_OS::read");
00775 #if defined (ACE_WIN32)
00776   DWORD ok_len;
00777   DWORD short_len = static_cast<DWORD> (len);
00778   if (::ReadFile (handle, buf, short_len, &ok_len, overlapped))
00779     return (ssize_t) ok_len;
00780   else
00781     ACE_FAIL_RETURN (-1);
00782 #else
00783   ACE_UNUSED_ARG (overlapped);
00784   return ACE_OS::read (handle, buf, len);
00785 #endif /* ACE_WIN32 */
00786 }

ssize_t ACE_OS::read ( ACE_HANDLE  handle,
void *  buf,
size_t  len 
) [inline]

Definition at line 731 of file OS_NS_unistd.inl.

00732 {
00733   ACE_OS_TRACE ("ACE_OS::read");
00734 #if defined (ACE_WIN32)
00735   DWORD ok_len;
00736   if (::ReadFile (handle, buf, static_cast<DWORD> (len), &ok_len, 0))
00737     return (ssize_t) ok_len;
00738   else
00739     ACE_FAIL_RETURN (-1);
00740 #else
00741 
00742   ssize_t result;
00743 
00744 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
00745   ACE_OSCALL (::read (handle, static_cast <char *> (buf), len), ssize_t, -1, result);
00746 # else
00747   ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result);
00748 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
00749 
00750 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00751   // Optimize this code out if we can detect that EAGAIN ==
00752   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00753   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00754   // macros) perform the check at run-time.  The goal is to avoid two
00755   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00756   if (result == -1
00757 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00758       && EAGAIN != EWOULDBLOCK
00759 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00760       && errno == EAGAIN)
00761     {
00762       errno = EWOULDBLOCK;
00763     }
00764 # endif /* EAGAIN != EWOULDBLOCK*/
00765 
00766   return result;
00767 #endif /* ACE_WIN32 */
00768 }

ssize_t ACE_OS::read_n ( ACE_HANDLE  handle,
void *  buf,
size_t  len,
size_t bytes_transferred = 0 
)

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 read will be returned to the caller through bytes_transferred.

Definition at line 488 of file OS_NS_unistd.cpp.

00492 {
00493   size_t temp;
00494   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00495   ssize_t n = 0;
00496 
00497   for (bytes_transferred = 0;
00498        bytes_transferred < len;
00499        bytes_transferred += n)
00500     {
00501       n = ACE_OS::read (handle,
00502                         (char *) buf + bytes_transferred,
00503                         len - bytes_transferred);
00504 
00505       if (n == -1 || n == 0)
00506         {
00507           return n;
00508         }
00509     }
00510 
00511   return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
00512 }

struct ACE_DIRENT * ACE_OS::readdir ( ACE_DIR d  )  [read]

Definition at line 52 of file OS_NS_dirent.inl.

00053 {
00054 #if defined (ACE_HAS_DIRENT)
00055 #  if defined (ACE_WIN32) && defined (ACE_LACKS_READDIR)
00056      return ACE_OS::readdir_emulation (d);
00057 #  elif defined (ACE_HAS_WREADDIR) && defined (ACE_USES_WCHAR)
00058      return ::wreaddir (d);
00059 #  else /* ACE_WIN32 && ACE_LACKS_READDIR */
00060      return ::readdir (d);
00061 #  endif /* ACE_WIN32 && ACE_LACKS_READDIR */
00062 #else
00063   ACE_UNUSED_ARG (d);
00064   ACE_NOTSUP_RETURN (0);
00065 #endif /* ACE_HAS_DIRENT */
00066 }

int ACE_OS::readdir_r ( ACE_DIR dirp,
struct ACE_DIRENT *  entry,
struct ACE_DIRENT **  result 
) [inline]

Definition at line 69 of file OS_NS_dirent.inl.

00072 {
00073 #if !defined (ACE_HAS_REENTRANT_FUNCTIONS)
00074   ACE_UNUSED_ARG (entry);
00075   // <result> has better not be 0!
00076   *result = ACE_OS::readdir (dirp);
00077   if (*result)
00078     return 0; // Keep iterating
00079   else
00080     return 1; // Oops, some type of error!
00081 #elif defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_READDIR_R)
00082 #  if defined (ACE_HAS_3_PARAM_READDIR_R)
00083        return ::readdir_r (dirp, entry, result);
00084 #  else
00085        // <result> had better not be 0!
00086        *result = ::readdir_r (dirp, entry);
00087        return 0;
00088 #  endif /* sun */
00089 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_READDIR_R */
00090   ACE_UNUSED_ARG (dirp);
00091   ACE_UNUSED_ARG (entry);
00092   ACE_UNUSED_ARG (result);
00093   ACE_NOTSUP_RETURN (0);
00094 
00095 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00096 }

ssize_t ACE_OS::readlink ( const char *  path,
char *  buf,
size_t  bufsiz 
) [inline]

Definition at line 789 of file OS_NS_unistd.inl.

00790 {
00791   ACE_OS_TRACE ("ACE_OS::readlink");
00792 # if defined (ACE_LACKS_READLINK)
00793   ACE_UNUSED_ARG (path);
00794   ACE_UNUSED_ARG (buf);
00795   ACE_UNUSED_ARG (bufsiz);
00796   ACE_NOTSUP_RETURN (-1);
00797 # elif defined(ACE_HAS_NONCONST_READLINK)
00798   ACE_OSCALL_RETURN (
00799     ::readlink (const_cast <char *>(path), buf, bufsiz), ssize_t, -1);
00800 # else
00801   ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), ssize_t, -1);
00802 # endif /* ACE_LACKS_READLINK */
00803 }

ssize_t ACE_OS::readv ( ACE_HANDLE  handle,
const iovec iov,
int  iovlen 
)

Definition at line 7 of file OS_NS_sys_uio.inl.

00010 {
00011   ACE_OS_TRACE ("ACE_OS::readv");
00012 #if defined (ACE_LACKS_READV)
00013   ACE_OSCALL_RETURN (ACE_OS::readv_emulation (handle, iov, iovlen),
00014                      ssize_t,
00015                      -1);
00016 #else /* ACE_LACKS_READV */
00017 #if defined (ACE_HAS_NONCONST_READV)
00018   ACE_OSCALL_RETURN (::readv (handle,
00019                               const_cast<iovec *>(iov),
00020                               iovlen), ssize_t, -1);
00021 #else
00022   ACE_OSCALL_RETURN (::readv (handle,
00023                               iov,
00024                               iovlen), ssize_t, -1);
00025 #endif /* ACE_HAS_NONCONST_READV */
00026 #endif /* ACE_LACKS_READV */
00027 }

ACE_Export ssize_t ACE_OS::readv_emulation ( ACE_HANDLE  handle,
const iovec iov,
int  iovcnt 
)
void * ACE_OS::realloc ( void *  ptr,
size_t  nbytes 
)

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 336 of file OS_NS_stdlib.cpp.

00337 {
00338 #ifdef ACE_LACKS_REALLOC
00339   ACE_UNUSED_ARG (ptr);
00340   ACE_UNUSED_ARG (nbytes);
00341   ACE_NOTSUP_RETURN (0);
00342 #else
00343   return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
00344 #endif
00345 }

wchar_t * ACE_OS::realpath ( const wchar_t file_name,
wchar_t resolved_name 
) [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 452 of file OS_NS_stdlib.inl.

00454 {
00455 #    if defined (ACE_WIN32)
00456   return ::_wfullpath (resolved_name, file_name, PATH_MAX);
00457 #    else /* ACE_WIN32 */
00458   ACE_Wide_To_Ascii n_file_name (file_name);
00459   char n_resolved[PATH_MAX];
00460   if (0 != ACE_OS::realpath (n_file_name.char_rep (), n_resolved))
00461     {
00462       ACE_Ascii_To_Wide w_resolved (n_resolved);
00463       ACE_OS::strcpy (resolved_name, w_resolved.wchar_rep ());
00464       return resolved_name;
00465     }
00466   return 0;
00467 #    endif /* ! ACE_WIN32 */
00468 }

char * ACE_OS::realpath ( const char *  file_name,
char *  resolved_name 
) [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 440 of file OS_NS_stdlib.inl.

00442 {
00443 #    if defined (ACE_WIN32)
00444   return ::_fullpath (resolved_name, file_name, PATH_MAX);
00445 #    else /* ACE_WIN32 */
00446   return ::realpath (file_name, resolved_name);
00447 #    endif /* ! ACE_WIN32 */
00448 }

void ACE_OS::recursive_mutex_cond_relock ( ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 708 of file OS_NS_Thread.inl.

00710 {
00711 #if defined (ACE_HAS_THREADS)
00712   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock");
00713 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00714   // Windows need special handling since it has recursive mutexes, but
00715   // does not integrate them into a condition variable.
00716   // On entry, the OS has already reacquired the lock for us. Just
00717   // reacquire it the proper number of times so the recursion is the same as
00718   // before waiting on the condition.
00719 #    if defined (ACE_WIN32)
00720   while (state.relock_count_ > 0)
00721     {
00722       ACE_OS::recursive_mutex_lock (m);
00723       --state.relock_count_;
00724     }
00725   return;
00726 #    else /* not ACE_WIN32 */
00727     // prevent warnings for unused variables
00728     ACE_UNUSED_ARG (state);
00729     ACE_UNUSED_ARG (m);
00730 
00731 #    endif /* ACE_WIN32 */
00732 #  else
00733   // Without recursive mutex support, it's somewhat trickier. On entry,
00734   // the current thread holds the nesting_mutex_, but another thread may
00735   // still be holding the ACE_recursive_mutex_t. If so, mimic the code
00736   // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex.
00737   // After acquiring it, restore the nesting counts and release the
00738   // nesting mutex. This will restore the conditions to what they were
00739   // before calling ACE_OS::recursive_mutex_cond_unlock().
00740   while (m->nesting_level_ > 0)
00741     ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_);
00742 
00743   // At this point, we still have nesting_mutex_ and the mutex is free.
00744   m->nesting_level_ = state.nesting_level_;
00745   m->owner_id_ = state.owner_id_;
00746   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00747   return;
00748 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00749 #else
00750   ACE_UNUSED_ARG (m);
00751   ACE_UNUSED_ARG (state);
00752   return;
00753 #endif /* ACE_HAS_THREADS */
00754 }

int ACE_OS::recursive_mutex_cond_unlock ( ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 607 of file OS_NS_Thread.inl.

00609 {
00610 #if defined (ACE_HAS_THREADS)
00611   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock");
00612 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00613   // Windows need special handling since it has recursive mutexes, but
00614   // does not integrate them into a condition variable.
00615 #    if defined (ACE_WIN32)
00616   // For Windows, the OS takes care of the mutex and its recursion. We just
00617   // need to release the lock one fewer times than this thread has acquired
00618   // it. Remember how many times, and reacquire it that many more times when
00619   // the condition is signaled.
00620 
00621   // We're using undocumented fields in the CRITICAL_SECTION structure
00622   // and they've been known to change across Windows variants and versions./
00623   // So be careful if you need to change these - there may be other
00624   // Windows variants that depend on existing values and limits.
00625 
00626   state.relock_count_ = 0;
00627   while (
00628 #      if !defined (ACE_HAS_WINCE)
00629          m->LockCount > 0 && m->RecursionCount > 1
00630 #      else
00631          // WinCE doesn't have RecursionCount and the LockCount semantic
00632          // Mobile 5 has it 1-indexed.
00633          m->LockCount > 1
00634 #      endif /* ACE_HAS_WINCE */
00635          )
00636     {
00637       // This may fail if the current thread doesn't own the mutex. If it
00638       // does fail, it'll be on the first try, so don't worry about resetting
00639       // the state.
00640       if (ACE_OS::recursive_mutex_unlock (m) == -1)
00641         return -1;
00642       ++state.relock_count_;
00643     }
00644 #    else /* not ACE_WIN32 */
00645     // prevent warnings for unused variables
00646     ACE_UNUSED_ARG (state);
00647     ACE_UNUSED_ARG (m);
00648 #    endif /* ACE_WIN32 */
00649   return 0;
00650 #  else /* ACE_HAS_RECURSIVE_MUTEXES */
00651   // For platforms without recursive mutexes, we obtain the nesting mutex
00652   // to gain control over the mutex internals. Then set the internals to say
00653   // the mutex is available. If there are waiters, signal the condition
00654   // to notify them (this is mostly like the recursive_mutex_unlock() method).
00655   // Then, return with the nesting mutex still held. The condition wait
00656   // will release it atomically, allowing mutex waiters to continue.
00657   // Note that this arrangement relies on the fact that on return from
00658   // the condition wait, this thread will again own the nesting mutex
00659   // and can either set the mutex internals directly or get in line for
00660   // the mutex... this part is handled in recursive_mutex_cond_relock().
00661   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00662     return -1;
00663 
00664 #    if !defined (ACE_NDEBUG)
00665   if (m->nesting_level_ == 0
00666       || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0)
00667     {
00668       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00669       errno = EINVAL;
00670       return -1;
00671     }
00672 #    endif /* ACE_NDEBUG */
00673 
00674   // To make error recovery a bit easier, signal the condition now. Any
00675   // waiter won't regain control until the mutex is released, which won't
00676   // be until the caller returns and does the wait on the condition.
00677   if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00678     {
00679       // Save/restore errno.
00680       ACE_Errno_Guard error (errno);
00681       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00682       return -1;
00683     }
00684 
00685   // Ok, the nesting_mutex_ lock is still held, the condition has been
00686   // signaled... reset the nesting info and return _WITH_ the lock
00687   // held. The lock will be released when the condition waits, in the
00688   // caller.
00689   state.nesting_level_ = m->nesting_level_;
00690   state.owner_id_ = m->owner_id_;
00691   m->nesting_level_ = 0;
00692   m->owner_id_ = ACE_OS::NULL_thread;
00693   return 0;
00694 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00695 #else
00696   ACE_UNUSED_ARG (m);
00697   ACE_UNUSED_ARG (state);
00698   ACE_NOTSUP_RETURN (-1);
00699 #endif /* ACE_HAS_THREADS */
00700 }

int ACE_OS::recursive_mutex_destroy ( ACE_recursive_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 757 of file OS_NS_Thread.inl.

00758 {
00759 #if defined (ACE_HAS_THREADS)
00760 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00761   return ACE_OS::thread_mutex_destroy (m);
00762 #else
00763   if (ACE_OS::cond_destroy (&m->lock_available_) == -1
00764       || ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
00765     return -1;
00766   return 0;
00767 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00768 #else
00769   ACE_UNUSED_ARG (m);
00770   ACE_NOTSUP_RETURN (-1);
00771 #endif /* ACE_HAS_THREADS */
00772 }

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 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 775 of file OS_NS_Thread.inl.

00779 {
00780   ACE_UNUSED_ARG (sa);
00781 #if defined (ACE_HAS_THREADS)
00782 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00783 #    if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00784   return ACE_OS::thread_mutex_init (m, PTHREAD_MUTEX_RECURSIVE, name, arg);
00785 #    else
00786   return ACE_OS::thread_mutex_init (m, 0, name, arg);
00787 #    endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00788 #  else
00789   if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1)
00790     return -1;
00791   else if (ACE_OS::cond_init (&m->lock_available_,
00792                               (short) USYNC_THREAD,
00793                               name,
00794                               0) == -1)
00795     return -1;
00796   else
00797     {
00798       m->nesting_level_ = 0;
00799       m->owner_id_ = ACE_OS::NULL_thread;
00800       return 0;
00801     }
00802 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00803 #else
00804   ACE_UNUSED_ARG (m);
00805   ACE_UNUSED_ARG (name);
00806   ACE_UNUSED_ARG (arg);
00807   ACE_NOTSUP_RETURN (-1);
00808 #endif /* ACE_HAS_THREADS */
00809 }

int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 928 of file OS_NS_Thread.inl.

00930 {
00931   return timeout == 0
00932     ? ACE_OS::recursive_mutex_lock (m)
00933     : ACE_OS::recursive_mutex_lock (m, *timeout);
00934 }

int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 863 of file OS_NS_Thread.inl.

00865 {
00866 #if defined (ACE_HAS_THREADS)
00867 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00868   return ACE_OS::thread_mutex_lock (m, timeout);
00869 #else
00870   ACE_thread_t t_id = ACE_OS::thr_self ();
00871   int result = 0;
00872 
00873   // Try to acquire the guard.
00874   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_, timeout) == -1)
00875     result = -1;
00876   else
00877     {
00878       // If there's no contention, just grab the lock immediately
00879       // (since this is the common case we'll optimize for it).
00880       if (m->nesting_level_ == 0)
00881         m->owner_id_ = t_id;
00882       // If we already own the lock, then increment the nesting level
00883       // and return.
00884       else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00885         {
00886           // Wait until the nesting level has dropped to zero, at
00887           // which point we can acquire the lock.
00888           while (m->nesting_level_ > 0)
00889             {
00890               result = ACE_OS::cond_timedwait (&m->lock_available_,
00891                                                &m->nesting_mutex_,
00892                                                const_cast <ACE_Time_Value *> (&timeout));
00893 
00894               // The mutex is reacquired even in the case of a timeout
00895               // release the mutex to prevent a deadlock
00896               if (result == -1)
00897                 {
00898                   // Save/restore errno.
00899                   ACE_Errno_Guard error (errno);
00900                   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00901 
00902                   return result;
00903                 }
00904             }
00905 
00906           // At this point the nesting_mutex_ is held...
00907           m->owner_id_ = t_id;
00908         }
00909 
00910       // At this point, we can safely increment the nesting_level_ no
00911       // matter how we got here!
00912       m->nesting_level_++;
00913 
00914       // Save/restore errno.
00915       ACE_Errno_Guard error (errno);
00916       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00917     }
00918   return result;
00919 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00920 #else
00921   ACE_UNUSED_ARG (m);
00922   ACE_UNUSED_ARG (timeout);
00923   ACE_NOTSUP_RETURN (-1);
00924 #endif /* ACE_HAS_THREADS */
00925 }

int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 812 of file OS_NS_Thread.inl.

00813 {
00814 #if defined (ACE_HAS_THREADS)
00815 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00816   return ACE_OS::thread_mutex_lock (m);
00817 #else
00818   ACE_thread_t const t_id = ACE_OS::thr_self ();
00819   int result = 0;
00820 
00821   // Acquire the guard.
00822   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00823     result = -1;
00824   else
00825   {
00826     // If there's no contention, just grab the lock immediately
00827     // (since this is the common case we'll optimize for it).
00828     if (m->nesting_level_ == 0)
00829       m->owner_id_ = t_id;
00830       // If we already own the lock, then increment the nesting level
00831       // and return.
00832     else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00833     {
00834           // Wait until the nesting level has dropped to zero, at
00835           // which point we can acquire the lock.
00836       while (m->nesting_level_ > 0)
00837         ACE_OS::cond_wait (&m->lock_available_,
00838                             &m->nesting_mutex_);
00839 
00840           // At this point the nesting_mutex_ is held...
00841       m->owner_id_ = t_id;
00842     }
00843 
00844     // At this point, we can safely increment the nesting_level_ no
00845     // matter how we got here!
00846     ++m->nesting_level_;
00847   }
00848 
00849   {
00850     // Save/restore errno.
00851     ACE_Errno_Guard error (errno);
00852     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00853   }
00854   return result;
00855 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00856 #else
00857   ACE_UNUSED_ARG (m);
00858   ACE_NOTSUP_RETURN (-1);
00859 #endif /* ACE_HAS_THREADS */
00860 }

int ACE_OS::recursive_mutex_trylock ( ACE_recursive_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 937 of file OS_NS_Thread.inl.

00938 {
00939 #if defined (ACE_HAS_THREADS)
00940 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00941   return ACE_OS::thread_mutex_trylock (m);
00942 #else
00943   ACE_thread_t t_id = ACE_OS::thr_self ();
00944   int result = 0;
00945 
00946   // Acquire the guard.
00947   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00948     result = -1;
00949   else
00950   {
00951       // If there's no contention, just grab the lock immediately.
00952     if (m->nesting_level_ == 0)
00953     {
00954       m->owner_id_ = t_id;
00955       m->nesting_level_ = 1;
00956     }
00957       // If we already own the lock, then increment the nesting level
00958       // and proceed.
00959     else if (ACE_OS::thr_equal (t_id, m->owner_id_))
00960       m->nesting_level_++;
00961     else
00962     {
00963       errno = EBUSY;
00964       result = -1;
00965     }
00966   }
00967 
00968   {
00969     // Save/restore errno.
00970     ACE_Errno_Guard error (errno);
00971     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00972   }
00973   return result;
00974 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00975 #else
00976   ACE_UNUSED_ARG (m);
00977   ACE_NOTSUP_RETURN (-1);
00978 #endif /* ACE_HAS_THREADS */
00979 }

int ACE_OS::recursive_mutex_unlock ( ACE_recursive_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 982 of file OS_NS_Thread.inl.

00983 {
00984 #if defined (ACE_HAS_THREADS)
00985 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00986   return ACE_OS::thread_mutex_unlock (m);
00987 #  else
00988   ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock");
00989 #    if !defined (ACE_NDEBUG)
00990   ACE_thread_t t_id = ACE_OS::thr_self ();
00991 #    endif /* ACE_NDEBUG */
00992   int result = 0;
00993 
00994   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00995     result = -1;
00996   else
00997   {
00998 #    if !defined (ACE_NDEBUG)
00999       if (m->nesting_level_ == 0
01000           || ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
01001 {
01002   errno = EINVAL;
01003   result = -1;
01004 }
01005       else
01006 #    endif /* ACE_NDEBUG */
01007 {
01008   m->nesting_level_--;
01009   if (m->nesting_level_ == 0)
01010   {
01011               // This may not be strictly necessary, but it does put
01012               // the mutex into a known state...
01013     m->owner_id_ = ACE_OS::NULL_thread;
01014 
01015               // Inform a waiter that the lock is free.
01016     if (ACE_OS::cond_signal (&m->lock_available_) == -1)
01017       result = -1;
01018   }
01019 }
01020   }
01021 
01022 {
01023     // Save/restore errno.
01024   ACE_Errno_Guard error (errno);
01025   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
01026 }
01027   return result;
01028 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
01029 #else
01030   ACE_UNUSED_ARG (m);
01031   ACE_NOTSUP_RETURN (-1);
01032 #endif /* ACE_HAS_THREADS */
01033 }

ssize_t ACE_OS::recv ( ACE_HANDLE  handle,
char *  buf,
size_t  len,
int  flags = 0 
) [inline]

BSD-style accept (no QoS).

Definition at line 317 of file OS_NS_sys_socket.inl.

00318 {
00319   ACE_OS_TRACE ("ACE_OS::recv");
00320 
00321   // On UNIX, a non-blocking socket with no data to receive, this
00322   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00323   // platform.  UNIX 98 allows either errno, and they may be the same
00324   // numeric value.  So to make life easier for upper ACE layers as
00325   // well as application programmers, always change EAGAIN to
00326   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00327   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00328   // this function needs to be reviewed.  On Win32, the regular macros
00329   // can be used, as this is not an issue.
00330 #if defined (ACE_LACKS_RECV)
00331   ACE_UNUSED_ARG (handle);
00332   ACE_UNUSED_ARG (buf);
00333   ACE_UNUSED_ARG (len);
00334   ACE_UNUSED_ARG (flags);
00335   ACE_NOTSUP_RETURN (-1);
00336 #elif defined (ACE_WIN32)
00337   ACE_SOCKCALL_RETURN (::recv ((ACE_SOCKET) handle, buf,
00338                                static_cast<int> (len), flags), ssize_t, -1);
00339 #else
00340   ssize_t ace_result_;
00341   ace_result_ = ::recv ((ACE_SOCKET) handle, buf, len, flags);
00342 
00343 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00344   // Optimize this code out if we can detect that EAGAIN ==
00345   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00346   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00347   // macros) perform the check at run-time.  The goal is to avoid two
00348   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00349   if (ace_result_ == -1
00350 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00351       && EAGAIN != EWOULDBLOCK
00352 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00353       && errno == EAGAIN)
00354     {
00355       errno = EWOULDBLOCK;
00356     }
00357 # endif /* EAGAIN != EWOULDBLOCK*/
00358 
00359   return ace_result_;
00360 #endif /* ACE_LACKS_RECV */
00361 }

ssize_t 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 
) [inline]

BSD-style accept (no QoS).

Definition at line 420 of file OS_NS_sys_socket.inl.

00429 {
00430   ACE_OS_TRACE ("ACE_OS::recvfrom");
00431 
00432 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00433   DWORD bytes_recvd;
00434   DWORD the_flags = flags;
00435   int result = ::WSARecvFrom ((SOCKET) handle,
00436                               (WSABUF*)buffers,
00437                               buffer_count,
00438                               &bytes_recvd,
00439                               &the_flags,
00440                               addr,
00441                               addrlen,
00442                               overlapped,
00443                               func);
00444   if (result != 0) {
00445     ACE_OS::set_errno_to_wsa_last_error ();
00446   }
00447   flags = the_flags;
00448   number_of_bytes_recvd = static_cast<size_t> (bytes_recvd);
00449   return result;
00450 #else
00451   ACE_UNUSED_ARG (handle);
00452   ACE_UNUSED_ARG (buffers);
00453   ACE_UNUSED_ARG (buffer_count);
00454   ACE_UNUSED_ARG (number_of_bytes_recvd);
00455   ACE_UNUSED_ARG (flags);
00456   ACE_UNUSED_ARG (addr);
00457   ACE_UNUSED_ARG (addrlen);
00458   ACE_UNUSED_ARG (overlapped);
00459   ACE_UNUSED_ARG (func);
00460   ACE_NOTSUP_RETURN (-1);
00461 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00462 }

ssize_t ACE_OS::recvfrom ( ACE_HANDLE  handle,
char *  buf,
size_t  len,
int  flags,
struct sockaddr addr,
int *  addrlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 364 of file OS_NS_sys_socket.inl.

00370 {
00371   ACE_OS_TRACE ("ACE_OS::recvfrom");
00372 #if defined (ACE_LACKS_RECVFROM)
00373   ACE_UNUSED_ARG (handle);
00374   ACE_UNUSED_ARG (buf);
00375   ACE_UNUSED_ARG (len);
00376   ACE_UNUSED_ARG (flags);
00377   ACE_UNUSED_ARG (addr);
00378   ACE_UNUSED_ARG (addrlen);
00379   ACE_NOTSUP_RETURN (-1);
00380 #elif defined (ACE_WIN32)
00381   int const shortened_len = static_cast<int> (len);
00382   int const result = ::recvfrom ((ACE_SOCKET) handle,
00383                                  buf,
00384                                  shortened_len,
00385                                  flags,
00386                                  addr,
00387                                  (ACE_SOCKET_LEN *) addrlen);
00388   if (result == SOCKET_ERROR)
00389     {
00390       ACE_OS::set_errno_to_wsa_last_error ();
00391       if (errno == WSAEMSGSIZE &&
00392           ACE_BIT_ENABLED (flags, MSG_PEEK))
00393         return shortened_len;
00394       else
00395         return -1;
00396     }
00397   else
00398     {
00399 #  if defined (ACE_HAS_PHARLAP)
00400       // Pharlap ETS (at least to v13) returns a legit address but doesn't
00401       // include the sin_zero[8] bytes in the count. Correct for this here.
00402       if (addrlen != 0 && addr != 0 &&
00403           *addrlen == 8 && addr->sa_family == AF_INET)
00404         *addrlen = sizeof(sockaddr_in);
00405 #  endif /* ACE_HAS_PHARLAP */
00406       return result;
00407     }
00408 #else /* non Win32 */
00409   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle,
00410                                    buf,
00411                                    len,
00412                                    flags,
00413                                    addr,
00414                                    (ACE_SOCKET_LEN *) addrlen),
00415                        ssize_t, -1);
00416 #endif /* ACE_LACKS_RECVFROM */
00417 }

ssize_t ACE_OS::recvmsg ( ACE_HANDLE  handle,
struct msghdr msg,
int  flags 
) [inline]

BSD-style accept (no QoS).

Definition at line 465 of file OS_NS_sys_socket.inl.

00466 {
00467   ACE_OS_TRACE ("ACE_OS::recvmsg");
00468 #if !defined (ACE_LACKS_RECVMSG)
00469 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00470   DWORD bytes_received = 0;
00471 
00472   int result = ::WSARecvFrom ((SOCKET) handle,
00473                               (WSABUF *) msg->msg_iov,
00474                               msg->msg_iovlen,
00475                               &bytes_received,
00476                               (DWORD *) &flags,
00477                               msg->msg_name,
00478                               &msg->msg_namelen,
00479                               0,
00480                               0);
00481 
00482   if (result != 0)
00483     {
00484       ACE_OS::set_errno_to_wsa_last_error ();
00485       return -1;
00486     }
00487   else
00488     return bytes_received;
00489 # else /* ACE_HAS_WINSOCK2 */
00490   ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), ssize_t, -1);
00491 # endif /* ACE_HAS_WINSOCK2 */
00492 #else
00493   ACE_UNUSED_ARG (flags);
00494   ACE_UNUSED_ARG (msg);
00495   ACE_UNUSED_ARG (handle);
00496 
00497   ACE_NOTSUP_RETURN (-1);
00498 #endif /* ACE_LACKS_RECVMSG */
00499 }

ssize_t ACE_OS::recvv ( ACE_HANDLE  handle,
iovec iov,
int  iovlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 502 of file OS_NS_sys_socket.inl.

00505 {
00506 #if defined (ACE_HAS_WINSOCK2)
00507 
00508   DWORD bytes_received = 0;
00509   int result = 1;
00510 
00511   // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs
00512   // to do the recvs piece-by-piece.
00513 
00514 # if (ACE_HAS_WINSOCK2 != 0)
00515   DWORD flags = 0;
00516   result = ::WSARecv ((SOCKET) handle,
00517                       (WSABUF *) buffers,
00518                       n,
00519                       &bytes_received,
00520                       &flags,
00521                       0,
00522                       0);
00523 # else
00524   // Step through the buffers requested by caller; for each one, cycle
00525   // through reads until it's filled or an error occurs.
00526   for (int i = 0; i < n && result > 0; ++i)
00527     {
00528       char *chunkp = buffers[i].iov_base;     // Point to part of chunk being read
00529       int chunklen = buffers[i].iov_len;    // Track how much to read to chunk
00530       while (chunklen > 0 && result > 0)
00531         {
00532           result = ::recv ((SOCKET) handle, chunkp, chunklen, 0);
00533           if (result > 0)
00534             {
00535               chunkp += result;
00536               chunklen -= result;
00537               bytes_received += result;
00538             }
00539         }
00540     }
00541 # endif /* ACE_HAS_WINSOCK2 != 0 */
00542 
00543   if (result == SOCKET_ERROR)
00544     {
00545       ACE_OS::set_errno_to_wsa_last_error ();
00546       return -1;
00547     }
00548   else
00549     return (ssize_t) bytes_received;
00550 #else
00551   return ACE_OS::readv (handle, buffers, n);
00552 #endif /* ACE_HAS_WINSOCK2 */
00553 }

int ACE_OS::rename ( const wchar_t old_name,
const wchar_t new_name,
int  flags = -1 
) [inline]

Definition at line 906 of file OS_NS_stdio.inl.

00909 {
00910 # if defined (ACE_LACKS_RENAME)
00911   ACE_UNUSED_ARG (old_name);
00912   ACE_UNUSED_ARG (new_name);
00913   ACE_UNUSED_ARG (flags);
00914   ACE_NOTSUP_RETURN (-1);
00915 # elif defined (ACE_HAS_WINCE)
00916   ACE_UNUSED_ARG (flags);
00917   if (::MoveFileW (old_name, new_name) == 0)
00918     ACE_FAIL_RETURN (-1);
00919   return 0;
00920 # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX)
00921   // NT4 (and up) provides a way to rename/move a file with similar semantics
00922   // to what's usually done on UNIX - if there's an existing file with
00923   // <new_name> it is removed before the file is renamed/moved. The
00924   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00925   if (flags == -1)
00926     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00927   if (::MoveFileExW (old_name, new_name, flags) == 0)
00928     ACE_FAIL_RETURN (-1);
00929   return 0;
00930 # elif defined (ACE_WIN32)
00931   ACE_UNUSED_ARG (flags);
00932   ACE_OSCALL_RETURN (::_wrename (old_name, new_name), int, -1);
00933 # else
00934   ACE_Wide_To_Ascii nold_name (old_name);
00935   ACE_Wide_To_Ascii nnew_name (new_name);
00936   return ACE_OS::rename (nold_name.char_rep (), nnew_name.char_rep (), flags);
00937 # endif /* ACE_HAS_WINCE */
00938 }

int ACE_OS::rename ( const char *  old_name,
const char *  new_name,
int  flags = -1 
) [inline]

Definition at line 872 of file OS_NS_stdio.inl.

00875 {
00876 # if defined (ACE_LACKS_RENAME)
00877   ACE_UNUSED_ARG (old_name);
00878   ACE_UNUSED_ARG (new_name);
00879   ACE_UNUSED_ARG (flags);
00880   ACE_NOTSUP_RETURN (-1);
00881 # elif defined (ACE_HAS_WINCE)
00882   // Win CE is always wide-char.
00883   ACE_UNUSED_ARG (flags);
00884   if (0 == ::MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name),
00885                        ACE_TEXT_CHAR_TO_TCHAR (new_name)))
00886     ACE_FAIL_RETURN (-1);
00887   return 0;
00888 # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX)
00889   // NT4 (and up) provides a way to rename/move a file with similar semantics
00890   // to what's usually done on UNIX - if there's an existing file with
00891   // <new_name> it is removed before the file is renamed/moved. The
00892   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00893   if (flags == -1)
00894     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00895   if (::MoveFileExA (old_name, new_name, flags) == 0)
00896     ACE_FAIL_RETURN (-1);
00897   return 0;
00898 # else
00899   ACE_UNUSED_ARG (flags);
00900   ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
00901 # endif /* ACE_HAS_WINCE */
00902 }

void ACE_OS::rewind ( FILE *  fp  )  [inline]

Definition at line 942 of file OS_NS_stdio.inl.

00943 {
00944 #if !defined (ACE_HAS_WINCE)
00945   ACE_OS_TRACE ("ACE_OS::rewind");
00946 # if defined (ACE_LACKS_REWIND)
00947   ACE_UNUSED_ARG (fp);
00948 # else
00949   ::rewind (fp);
00950 # endif /* ACE_LACKS_REWIND */
00951 #else
00952   // This isn't perfect since it doesn't reset EOF, but it's probably
00953   // the closest we can get on WINCE.
00954   (void) ::fseek (fp, 0L, SEEK_SET);
00955 #endif /* ACE_HAS_WINCE */
00956 }

void ACE_OS::rewinddir ( ACE_DIR d  )  [inline]

Definition at line 99 of file OS_NS_dirent.inl.

00100 {
00101 #if defined (ACE_HAS_DIRENT)
00102 #  if defined (ACE_HAS_WREWINDDIR) && defined (ACE_USES_WCHAR)
00103   ::wrewinddir (d);
00104 #  elif !defined (ACE_LACKS_REWINDDIR)
00105   ace_rewinddir_helper (d);
00106 #  else
00107   ACE_UNUSED_ARG (d);
00108 #  endif /* !defined (ACE_LACKS_REWINDDIR) */
00109 #endif /* ACE_HAS_DIRENT */
00110 }

int ACE_OS::rmdir ( const wchar_t path  )  [inline]

Definition at line 169 of file OS_NS_unistd.inl.

00170 {
00171 #if defined (ACE_HAS_WINCE)
00172   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectoryW (path),
00173                                           ace_result_),
00174                         int, -1);
00175 #elif defined (ACE_WIN32)
00176   ACE_OSCALL_RETURN (::_wrmdir (path), int, -1);
00177 #else
00178   ACE_Wide_To_Ascii n_path (path);
00179   return ACE_OS::rmdir (n_path.char_rep ());
00180 #endif /* ACE_HAS_WINCE */
00181 }

int ACE_OS::rmdir ( const char *  path  )  [inline]

Definition at line 154 of file OS_NS_unistd.inl.

00155 {
00156 #if defined (ACE_HAS_WINCE)
00157   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (ACE_TEXT_CHAR_TO_TCHAR(path)),
00158                                           ace_result_),
00159                         int, -1);
00160 #elif defined (ACE_RMDIR_EQUIVALENT)
00161   ACE_OSCALL_RETURN (ACE_RMDIR_EQUIVALENT (path), int, -1);
00162 #else
00163   ACE_OSCALL_RETURN (::rmdir (path), int, -1);
00164 #endif /* ACE_WIN32 */
00165 }

int ACE_OS::rw_rdlock ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1036 of file OS_NS_Thread.inl.

01037 {
01038   ACE_OS_TRACE ("ACE_OS::rw_rdlock");
01039 #if defined (ACE_HAS_THREADS)
01040 # if !defined (ACE_LACKS_RWLOCK_T)
01041 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01042   int result;
01043   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
01044                                        result),
01045                      int, -1);
01046 #  else /* Solaris */
01047   int result;
01048   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), result), int, -1);
01049 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01050 # else /* NT, POSIX, and VxWorks don't support this natively. */
01051 #   if defined (ACE_HAS_PTHREADS)
01052   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01053 #   endif /* ACE_HAS_PTHREADS */
01054   int result = 0;
01055   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01056     result = -1; // -1 means didn't get the mutex.
01057   else
01058     {
01059       // Give preference to writers who are waiting.
01060       while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0)
01061         {
01062           rw->num_waiting_readers_++;
01063           if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1)
01064             {
01065               result = -2; // -2 means that we need to release the mutex.
01066               break;
01067             }
01068           rw->num_waiting_readers_--;
01069         }
01070     }
01071   if (result == 0)
01072     rw->ref_count_++;
01073   if (result != -1)
01074     ACE_OS::mutex_unlock (&rw->lock_);
01075 #   if defined (ACE_HAS_PTHREADS)
01076   ACE_PTHREAD_CLEANUP_POP (0);
01077 #   endif /* defined (ACE_HAS_PTHREADS) */
01078   return 0;
01079 # endif /* ! ACE_LACKS_RWLOCK_T */
01080 #else
01081   ACE_UNUSED_ARG (rw);
01082   ACE_NOTSUP_RETURN (-1);
01083 #endif /* ACE_HAS_THREADS */
01084 }

int ACE_OS::rw_tryrdlock ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1087 of file OS_NS_Thread.inl.

01088 {
01089   ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
01090 #if defined (ACE_HAS_THREADS)
01091 # if !defined (ACE_LACKS_RWLOCK_T)
01092 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01093   int result;
01094   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
01095                                        result),
01096                      int, -1);
01097 #  else /* Solaris */
01098   int result;
01099   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), result), int, -1);
01100 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01101 # else /* NT, POSIX, and VxWorks don't support this natively. */
01102   int result = -1;
01103 
01104   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01105     {
01106       ACE_Errno_Guard error (errno);
01107 
01108       if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0)
01109         {
01110           error = EBUSY;
01111           result = -1;
01112         }
01113       else
01114         {
01115           rw->ref_count_++;
01116           result = 0;
01117         }
01118 
01119       ACE_OS::mutex_unlock (&rw->lock_);
01120     }
01121   return result;
01122 # endif /* ! ACE_LACKS_RWLOCK_T */
01123 #else
01124   ACE_UNUSED_ARG (rw);
01125   ACE_NOTSUP_RETURN (-1);
01126 #endif /* ACE_HAS_THREADS */
01127 }

int ACE_OS::rw_trywrlock ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1130 of file OS_NS_Thread.inl.

01131 {
01132   ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
01133 #if defined (ACE_HAS_THREADS)
01134 # if !defined (ACE_LACKS_RWLOCK_T)
01135 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01136   int result;
01137   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01138                                        result),
01139                      int, -1);
01140 #  else /* Solaris */
01141   int result;
01142   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), result), int, -1);
01143 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01144 # else /* NT, POSIX, and VxWorks don't support this natively. */
01145   int result = -1;
01146 
01147   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01148     {
01149       ACE_Errno_Guard error (errno);
01150 
01151       if (rw->ref_count_ != 0)
01152         {
01153           error = EBUSY;
01154           result = -1;
01155         }
01156       else
01157         {
01158           rw->ref_count_ = -1;
01159           result = 0;
01160         }
01161 
01162       ACE_OS::mutex_unlock (&rw->lock_);
01163     }
01164   return result;
01165 # endif /* ! ACE_LACKS_RWLOCK_T */
01166 #else
01167   ACE_UNUSED_ARG (rw);
01168   ACE_NOTSUP_RETURN (-1);
01169 #endif /* ACE_HAS_THREADS */
01170 }

int ACE_OS::rw_trywrlock_upgrade ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1179 of file OS_NS_Thread.inl.

01180 {
01181   ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
01182 #if defined (ACE_HAS_THREADS)
01183 # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) && !defined (ACE_LACKS_RWLOCK_T)
01184   int result;
01185   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01186                                        result),
01187                      int, -1);
01188 # elif !defined (ACE_LACKS_RWLOCK_T)
01189   // Some native rwlocks, such as those on Solaris, don't
01190   // support the upgrade feature . . .
01191   ACE_UNUSED_ARG (rw);
01192   ACE_NOTSUP_RETURN (-1);
01193 # else /* NT, POSIX, and VxWorks don't support this natively. */
01194   // The ACE rwlock emulation does support upgrade . . .
01195   int result = 0;
01196 
01197 #   if defined (ACE_HAS_PTHREADS)
01198   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01199 #   endif /* defined (ACE_HAS_PTHREADS) */
01200 
01201   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01202     return -1;
01203     // -1 means didn't get the mutex, error
01204   else if (rw->important_writer_)
01205     // an other reader upgrades already
01206     {
01207       result = -1;
01208       errno = EBUSY;
01209     }
01210   else
01211     {
01212       while (rw->ref_count_ > 1) // wait until only I am left
01213         {
01214           rw->num_waiting_writers_++; // prohibit any more readers
01215           rw->important_writer_ = true;
01216 
01217           if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1)
01218             {
01219               result = -1;
01220               // we know that we have the lock again, we have this guarantee,
01221               // but something went wrong
01222             }
01223           rw->important_writer_ = false;
01224           rw->num_waiting_writers_--;
01225         }
01226       if (result == 0)
01227         {
01228           // nothing bad happend
01229           rw->ref_count_ = -1;
01230           // now I am a writer
01231           // everything is O.K.
01232         }
01233     }
01234 
01235   ACE_OS::mutex_unlock (&rw->lock_);
01236 
01237 #   if defined (ACE_HAS_PTHREADS)
01238   ACE_PTHREAD_CLEANUP_POP (0);
01239 #   endif /* defined (ACE_HAS_PTHREADS) */
01240 
01241   return result;
01242 
01243 # endif /* ! ACE_LACKS_RWLOCK_T */
01244 #else
01245   ACE_UNUSED_ARG (rw);
01246   ACE_NOTSUP_RETURN (-1);
01247 #endif /* ACE_HAS_THREADS */
01248 }

int ACE_OS::rw_unlock ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1251 of file OS_NS_Thread.inl.

01252 {
01253   ACE_OS_TRACE ("ACE_OS::rw_unlock");
01254 #if defined (ACE_HAS_THREADS)
01255 # if !defined (ACE_LACKS_RWLOCK_T)
01256 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01257   int result;
01258   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
01259                                        result),
01260                      int, -1);
01261 #  else /* Solaris */
01262   int result;
01263   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), result), int, -1);
01264 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01265 # else /* NT, POSIX, and VxWorks don't support this natively. */
01266   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01267     return -1;
01268 
01269   if (rw->ref_count_ > 0) // Releasing a reader.
01270     rw->ref_count_--;
01271   else if (rw->ref_count_ == -1) // Releasing a writer.
01272     rw->ref_count_ = 0;
01273   else
01274     {
01275       (void) ACE_OS::mutex_unlock (&rw->lock_);
01276       return -1; // @@ ACE_ASSERT (!"count should not be 0!\n");
01277     }
01278 
01279   int result = 0;
01280   ACE_Errno_Guard error (errno);
01281 
01282   if (rw->important_writer_ && rw->ref_count_ == 1)
01283     // only the reader requesting to upgrade its lock is left over.
01284     {
01285       result = ACE_OS::cond_signal (&rw->waiting_important_writer_);
01286       error = errno;
01287     }
01288   else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0)
01289     // give preference to writers over readers...
01290     {
01291       result = ACE_OS::cond_signal (&rw->waiting_writers_);
01292       error =  errno;
01293     }
01294   else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0)
01295     {
01296       result = ACE_OS::cond_broadcast (&rw->waiting_readers_);
01297       error = errno;
01298     }
01299 
01300   (void) ACE_OS::mutex_unlock (&rw->lock_);
01301   return result;
01302 # endif /* ! ace_lacks_rwlock_t */
01303 #else
01304   ACE_UNUSED_ARG (rw);
01305   ACE_NOTSUP_RETURN (-1);
01306 #endif /* ace_has_threads */
01307 }

int ACE_OS::rw_wrlock ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1310 of file OS_NS_Thread.inl.

01311 {
01312   ACE_OS_TRACE ("ACE_OS::rw_wrlock");
01313 #if defined (ACE_HAS_THREADS)
01314 # if !defined (ACE_LACKS_RWLOCK_T)
01315 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01316   int result;
01317   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
01318                                        result),
01319                      int, -1);
01320 #  else /* Solaris */
01321   int result;
01322   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), result), int, -1);
01323 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01324 # else /* NT, POSIX, and VxWorks don't support this natively. */
01325 #   if defined (ACE_HAS_PTHREADS)
01326   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01327 #   endif /* defined (ACE_HAS_PTHREADS) */
01328   int result = 0;
01329 
01330   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01331     result = -1; // -1 means didn't get the mutex.
01332   else
01333     {
01334       while (rw->ref_count_ != 0)
01335         {
01336           rw->num_waiting_writers_++;
01337 
01338           if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1)
01339             {
01340               result = -2; // -2 means we need to release the mutex.
01341               break;
01342             }
01343 
01344           rw->num_waiting_writers_--;
01345         }
01346     }
01347   if (result == 0)
01348     rw->ref_count_ = -1;
01349   if (result != -1)
01350     ACE_OS::mutex_unlock (&rw->lock_);
01351 #   if defined (ACE_HAS_PTHREADS)
01352   ACE_PTHREAD_CLEANUP_POP (0);
01353 #   endif /* defined (ACE_HAS_PTHREADS) */
01354   return 0;
01355 # endif /* ! ACE_LACKS_RWLOCK_T */
01356 #else
01357   ACE_UNUSED_ARG (rw);
01358   ACE_NOTSUP_RETURN (-1);
01359 #endif /* ACE_HAS_THREADS */
01360 }

int ACE_OS::rwlock_destroy ( ACE_rwlock_t rw  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1363 of file OS_NS_Thread.inl.

01364 {
01365   ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
01366 #if defined (ACE_HAS_THREADS)
01367 # if !defined (ACE_LACKS_RWLOCK_T)
01368 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01369   int result;
01370   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
01371                                        result),
01372                      int, -1);
01373 #  else /* Solaris */
01374   int result;
01375   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), result), int, -1);
01376 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01377 # else /* NT, POSIX, and VxWorks don't support this natively. */
01378   ACE_OS::mutex_destroy (&rw->lock_);
01379   ACE_OS::cond_destroy (&rw->waiting_readers_);
01380   ACE_OS::cond_destroy (&rw->waiting_important_writer_);
01381   return ACE_OS::cond_destroy (&rw->waiting_writers_);
01382 # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */
01383 #else
01384   ACE_UNUSED_ARG (rw);
01385   ACE_NOTSUP_RETURN (-1);
01386 #endif /* ACE_HAS_THREADS */
01387 }

int ACE_OS::rwlock_init ( ACE_rwlock_t rw,
int  type = ACE_DEFAULT_SYNCH_TYPE,
const ACE_TCHAR name = 0,
void *  arg = 0 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1391 of file OS_NS_Thread.inl.

01395 {
01396   // ACE_OS_TRACE ("ACE_OS::rwlock_init");
01397 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01398   ACE_UNUSED_ARG (name);
01399   ACE_UNUSED_ARG (arg);
01400 
01401   int status;
01402   pthread_rwlockattr_t attr;
01403   pthread_rwlockattr_init (&attr);
01404 #    if !defined (ACE_LACKS_RWLOCKATTR_PSHARED)
01405   pthread_rwlockattr_setpshared (&attr, (type == USYNC_THREAD ?
01406                                          PTHREAD_PROCESS_PRIVATE :
01407                                          PTHREAD_PROCESS_SHARED));
01408 #    else
01409   ACE_UNUSED_ARG (type);
01410 #    endif /* !ACE_LACKS_RWLOCKATTR_PSHARED */
01411   status = ACE_ADAPT_RETVAL (pthread_rwlock_init (rw, &attr), status);
01412   pthread_rwlockattr_destroy (&attr);
01413 
01414   return status;
01415 
01416 #  else
01417   type = type;
01418   name = name;
01419   int result;
01420   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), result), int, -1);
01421 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01422 }

void * ACE_OS::sbrk ( intptr_t  brk  )  [inline]

Definition at line 822 of file OS_NS_unistd.inl.

00823 {
00824 #if defined (ACE_LACKS_SBRK)
00825   ACE_UNUSED_ARG (brk);
00826   ACE_NOTSUP_RETURN (0);
00827 #else
00828   ACE_OSCALL_RETURN (::sbrk (brk), void *, 0);
00829 #endif /* ACE_LACKS_SBRK */
00830 }

int ACE_OS::scandir ( const ACE_TCHAR dirname,
struct ACE_DIRENT **  namelist[],
ACE_SCANDIR_SELECTOR  selector,
ACE_SCANDIR_COMPARATOR  comparator 
) [inline]

Definition at line 113 of file OS_NS_dirent.inl.

00117 {
00118 #if defined (ACE_HAS_SCANDIR)
00119   return ::scandir (ACE_TEXT_ALWAYS_CHAR (dirname),
00120                     namelist,
00121 #  if defined (ACE_SCANDIR_SEL_LACKS_CONST)
00122                     reinterpret_cast<ACE_SCANDIR_OS_SELECTOR> (selector),
00123 #  else
00124                     selector,
00125 #  endif /* ACE_SCANDIR_SEL_LACKS_CONST */
00126 #  if defined (ACE_SCANDIR_CMP_USES_VOIDPTR) || \
00127       defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
00128                     reinterpret_cast<ACE_SCANDIR_OS_COMPARATOR> (comparator));
00129 #  else
00130                     comparator);
00131 #  endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
00132 
00133 #else /* ! defined ( ACE_HAS_SCANDIR) */
00134   return ACE_OS::scandir_emulation (dirname, namelist, selector, comparator);
00135 #endif /* ACE_HAS_SCANDIR */
00136 }

int ACE_OS::scandir_emulation ( const ACE_TCHAR dirname,
ACE_DIRENT **  namelist[],
ACE_SCANDIR_SELECTOR  selector,
ACE_SCANDIR_COMPARATOR  comparator 
)

Definition at line 165 of file OS_NS_dirent.cpp.

00169 {
00170   ACE_DIR *dirp = ACE_OS::opendir (dirname);
00171 
00172   if (dirp == 0)
00173     return -1;
00174   // A sanity check here.  "namelist" had better not be zero.
00175   else if (namelist == 0)
00176     return -1;
00177 
00178   ACE_DIRENT **vector = 0;
00179   ACE_DIRENT *dp = 0;
00180   int arena_size = 0;
00181   int nfiles = 0;
00182   int fail = 0;
00183 
00184   // @@ This code shoulduse readdir_r() rather than readdir().
00185   for (dp = ACE_OS::readdir (dirp);
00186        dp != 0;
00187        dp = ACE_OS::readdir (dirp))
00188     {
00189       if (selector && (*selector)(dp) == 0)
00190         continue;
00191 
00192       // If we get here, we have a dirent that the user likes.
00193       if (nfiles == arena_size)
00194         {
00195           ACE_DIRENT **newv = 0;
00196           int new_arena_size;
00197           if (arena_size == 0)
00198             new_arena_size = 10;
00199           else
00200             new_arena_size = arena_size * 2;
00201 
00202 #if defined (ACE_HAS_ALLOC_HOOKS)
00203           newv = (ACE_DIRENT **) ACE_Allocator::instance()->malloc (new_arena_size * sizeof (ACE_DIRENT *));
00204           if (newv && vector)
00205             {
00206               ACE_OS::memcpy (newv, vector, arena_size * sizeof (ACE_DIRENT *));
00207             }
00208 #else
00209           newv = (ACE_DIRENT **) ACE_OS::realloc (vector,
00210                                               new_arena_size * sizeof (ACE_DIRENT *));
00211 #endif /* ACE_HAS_ALLOC_HOOKS */
00212 
00213           arena_size = new_arena_size;
00214 
00215           if (newv == 0)
00216             {
00217               fail = 1;
00218               break;
00219             }
00220           vector = newv;
00221         }
00222 
00223 #if defined (ACE_LACKS_STRUCT_DIR)
00224 #if defined (ACE_HAS_ALLOC_HOOKS)
00225       ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_Allocator::instance()->malloc (sizeof (ACE_DIRENT));
00226 #else
00227       ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (sizeof (ACE_DIRENT));
00228 #endif /* ACE_HAS_ALLOC_HOOKS */
00229 #else
00230       size_t dsize =
00231         sizeof (ACE_DIRENT) +
00232         ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
00233 #if defined (ACE_HAS_ALLOC_HOOKS)
00234       ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_Allocator::instance()->malloc (dsize);
00235 #else
00236       ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (dsize);
00237 #endif /* ACE_HAS_ALLOC_HOOKS */
00238 #endif /* ACE_LACKS_STRUCT_DIR */
00239 
00240       if (newdp == 0)
00241         {
00242           fail = 1;
00243           break;
00244         }
00245 
00246 #if defined (ACE_LACKS_STRUCT_DIR)
00247 #if defined (ACE_HAS_ALLOC_HOOKS)
00248       newdp->d_name = (ACE_TCHAR*) ACE_Allocator::instance()->malloc ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
00249 #else
00250       newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
00251 #endif /* ACE_HAS_ALLOC_HOOKS */
00252 
00253       if (newdp->d_name == 0)
00254         {
00255           fail = 1;
00256 #if defined (ACE_HAS_ALLOC_HOOKS)
00257           ACE_Allocator::instance()->free (newdp);
00258 #else
00259           ACE_OS::free (newdp);
00260 #endif /* ACE_HAS_ALLOC_HOOKS */
00261           break;
00262         }
00263 
00264       // Don't use memcpy here since d_name is now a pointer
00265       newdp->d_ino = dp->d_ino;
00266       newdp->d_off = dp->d_off;
00267       newdp->d_reclen = dp->d_reclen;
00268       ACE_OS::strcpy (newdp->d_name, dp->d_name);
00269       vector[nfiles++] = newdp;
00270 #else
00271       vector[nfiles++] = (ACE_DIRENT *) ACE_OS::memcpy (newdp, dp, dsize);
00272 #endif /* ACE_LACKS_STRUCT_DIR */
00273     }
00274 
00275   if (fail)
00276     {
00277       ACE_OS::closedir (dirp);
00278       while (vector && nfiles-- > 0)
00279         {
00280 #if defined (ACE_LACKS_STRUCT_DIR)
00281 #if defined (ACE_HAS_ALLOC_HOOKS)
00282           ACE_Allocator::instance()->free (vector[nfiles]->d_name);
00283 #else
00284           ACE_OS::free (vector[nfiles]->d_name);
00285 #endif /* ACE_HAS_ALLOC_HOOKS */
00286 #endif /* ACE_LACKS_STRUCT_DIR */
00287 #if defined (ACE_HAS_ALLOC_HOOKS)
00288           ACE_Allocator::instance()->free (vector[nfiles]);
00289 #else
00290           ACE_OS::free (vector[nfiles]);
00291 #endif /* ACE_HAS_ALLOC_HOOKS */
00292         }
00293 #if defined (ACE_HAS_ALLOC_HOOKS)
00294       ACE_Allocator::instance()->free (vector);
00295 #else
00296       ACE_OS::free (vector);
00297 #endif /* ACE_HAS_ALLOC_HOOKS */
00298       return -1;
00299     }
00300 
00301   ACE_OS::closedir (dirp);
00302 
00303   *namelist = vector;
00304 
00305   if (comparator)
00306     ACE_OS::qsort (*namelist,
00307                    nfiles,
00308                    sizeof (ACE_DIRENT *),
00309                    (ACE_COMPARE_FUNC) comparator);
00310 
00311   return nfiles;
00312 }

int ACE_OS::sched_params ( const ACE_Sched_Params 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.

Definition at line 3213 of file OS_NS_Thread.cpp.

03215 {
03216   ACE_OS_TRACE ("ACE_OS::sched_params");
03217 #if defined (ACE_HAS_STHREADS)
03218   return ACE_OS::set_scheduling_params (sched_params, id);
03219 #elif defined (ACE_HAS_PTHREADS) && \
03220       (!defined (ACE_LACKS_SETSCHED) || \
03221       defined (ACE_HAS_PTHREAD_SCHEDPARAM))
03222   if (sched_params.quantum () != ACE_Time_Value::zero)
03223     {
03224       // quantums not supported
03225       errno = EINVAL;
03226       return -1;
03227     }
03228 
03229   // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for
03230   // providing this code for 1003.1c PThreads.  Please note that this
03231   // has only been tested for POSIX 1003.1c threads, and may cause
03232   // problems with other PThreads flavors!
03233 
03234   struct sched_param param;
03235   param.sched_priority = sched_params.priority ();
03236 
03237   if (sched_params.scope () == ACE_SCOPE_PROCESS)
03238     {
03239 # if defined (ACE_HAS_PTHREAD_SCHEDPARAM)
03240       ACE_UNUSED_ARG (id);
03241       ACE_NOTSUP_RETURN (-1);
03242 # else  /* !ACE_HAS_PTHREAD_SCHEDPARAM */
03243       int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id,
03244                                          sched_params.policy (),
03245                                          &param) == -1 ? -1 : 0;
03246       return result;
03247 # endif /* !ACE_HAS_PTHREAD_SCHEDPARAM */
03248     }
03249   else if (sched_params.scope () == ACE_SCOPE_THREAD)
03250     {
03251       ACE_thread_t thr_id = ACE_OS::thr_self ();
03252 
03253       int result;
03254       ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
03255                                                                     sched_params.policy (),
03256                                                                     &param),
03257                                            result),
03258                          int, -1);
03259     }
03260 # if defined (sun)
03261   // We need to be able to set LWP priorities on Suns, even without
03262   // ACE_HAS_STHREADS, to obtain preemption.
03263   else if (sched_params.scope () == ACE_SCOPE_LWP)
03264     return ACE_OS::set_scheduling_params (sched_params, id);
03265 # endif /* sun */
03266   else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX
03267     {
03268       errno = EINVAL;
03269       return -1;
03270     }
03271 
03272 #elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
03273 
03274   // PharLap ETS can act on the current thread - it can set the
03275   // quantum also, unlike Win32. All this only works on the RT
03276   // version.
03277 # if defined (ACE_HAS_PHARLAP_RT)
03278   if (id != ACE_SELF)
03279     ACE_NOTSUP_RETURN (-1);
03280 
03281 #   if !defined (ACE_PHARLAP_LABVIEW_RT)
03282   if (sched_params.quantum() != ACE_Time_Value::zero)
03283     EtsSetTimeSlice (sched_params.quantum().msec());
03284 #   endif
03285 
03286 # else
03287 
03288   if (sched_params.quantum () != ACE_Time_Value::zero)
03289     {
03290       // I don't know of a way to set the quantum on Win32.
03291       errno = EINVAL;
03292       return -1;
03293     }
03294 
03295 # endif /* ACE_HAS_PHARLAP_RT */
03296 
03297   if (sched_params.scope () == ACE_SCOPE_THREAD)
03298     {
03299 
03300       // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always
03301       // a VERY BAD THING. This include guard will allow people
03302       // to easily disable this feature in ACE.
03303       // It won't work at all for Pharlap since there's no SetPriorityClass.
03304 #if !defined (ACE_HAS_PHARLAP) && \
03305     !defined (ACE_DISABLE_WIN32_INCREASE_PRIORITY)
03306       // Set the priority class of this process to the REALTIME process class
03307       // _if_ the policy is ACE_SCHED_FIFO.  Otherwise, set to NORMAL.
03308       if (!::SetPriorityClass (::GetCurrentProcess (),
03309                                (sched_params.policy () == ACE_SCHED_FIFO ||
03310                                 sched_params.policy () == ACE_SCHED_RR)
03311                                ? REALTIME_PRIORITY_CLASS
03312                                : NORMAL_PRIORITY_CLASS))
03313         {
03314           ACE_OS::set_errno_to_last_error ();
03315           return -1;
03316         }
03317 #endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */
03318 
03319       // Now that we have set the priority class of the process, set the
03320       // priority of the current thread to the desired value.
03321       return ACE_OS::thr_setprio (sched_params.priority ());
03322     }
03323   else if (sched_params.scope () == ACE_SCOPE_PROCESS)
03324     {
03325 
03326 # if defined (ACE_HAS_PHARLAP_RT)
03327       ACE_NOTSUP_RETURN (-1);
03328 # else
03329       HANDLE hProcess
03330         = ::OpenProcess (PROCESS_SET_INFORMATION,
03331                          FALSE,
03332                          id == ACE_SELF ? ::GetCurrentProcessId() : id);
03333       if (!hProcess)
03334         {
03335           ACE_OS::set_errno_to_last_error();
03336           return -1;
03337         }
03338       // There is no way for us to set the priority of the thread when we
03339       // are setting the priority of a different process.  So just ignore
03340       // the priority argument when ACE_SCOPE_PROCESS is specified.
03341       // Setting the priority class will automatically increase the base
03342       // priority of all the threads within a process while maintaining the
03343       // relative priorities of the threads within it.
03344       if (!::SetPriorityClass (hProcess,
03345                                (sched_params.policy () == ACE_SCHED_FIFO ||
03346                                 sched_params.policy () == ACE_SCHED_RR)
03347                                ? REALTIME_PRIORITY_CLASS
03348                                : NORMAL_PRIORITY_CLASS))
03349         {
03350           ACE_OS::set_errno_to_last_error ();
03351           ::CloseHandle (hProcess);
03352           return -1;
03353         }
03354       ::CloseHandle (hProcess);
03355       return 0;
03356 #endif /* ACE_HAS_PHARLAP_RT */
03357 
03358     }
03359   else
03360     {
03361       errno = EINVAL;
03362       return -1;
03363     }
03364 #elif defined (ACE_VXWORKS)
03365   ACE_UNUSED_ARG (id);
03366 
03367   // There is only one class of priorities on VxWorks, and no time
03368   // quanta.  So, just set the current thread's priority.
03369 
03370   if (sched_params.policy () != ACE_SCHED_FIFO
03371       || sched_params.scope () != ACE_SCOPE_PROCESS
03372       || sched_params.quantum () != ACE_Time_Value::zero)
03373     {
03374       errno = EINVAL;
03375       return -1;
03376     }
03377 
03378   // Set the thread priority on the current thread.
03379   return ACE_OS::thr_setprio (sched_params.priority ());
03380 #else
03381   ACE_UNUSED_ARG (sched_params);
03382   ACE_UNUSED_ARG (id);
03383   ACE_NOTSUP_RETURN (-1);
03384 #endif /* ACE_HAS_STHREADS */
03385 }

int ACE_OS::scheduling_class ( const char *  class_name,
ACE_id_t id 
)

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

Definition at line 3388 of file OS_NS_Thread.cpp.

03389 {
03390 #if defined (ACE_HAS_PRIOCNTL)
03391   // Get the priority class ID.
03392   pcinfo_t pcinfo;
03393   // The following is just to avoid Purify warnings about unitialized
03394   // memory reads.
03395   ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
03396 
03397   ACE_OS::strcpy (pcinfo.pc_clname, class_name);
03398   if (ACE_OS::priority_control (P_ALL /* ignored */,
03399                                 P_MYID /* ignored */,
03400                                 PC_GETCID,
03401                                 (char *) &pcinfo) == -1)
03402     {
03403       return -1;
03404     }
03405   else
03406     {
03407       id = pcinfo.pc_cid;
03408       return 0;
03409     }
03410 #else  /* ! ACE_HAS_PRIOCNTL */
03411   ACE_UNUSED_ARG (class_name);
03412   ACE_UNUSED_ARG (id);
03413   ACE_NOTSUP_RETURN (-1);
03414 #endif /* ! ACE_HAS_PRIOCNTL */
03415 }

void ACE_OS::seekdir ( ACE_DIR d,
long  loc 
) [inline]

Definition at line 158 of file OS_NS_dirent.inl.

00159 {
00160 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_SEEKDIR)
00161   ::seekdir (d, loc);
00162 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_SEEKDIR */
00163   ACE_UNUSED_ARG (d);
00164   ACE_UNUSED_ARG (loc);
00165 #endif /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_SEEKDIR */
00166 }

int ACE_OS::select ( int  width,
fd_set *  rfds,
fd_set *  wfds,
fd_set *  efds,
const ACE_Time_Value tv 
)

Definition at line 45 of file OS_NS_sys_select.inl.

00048 {
00049   ACE_OS_TRACE ("ACE_OS::select");
00050 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00051 # define ___ACE_TIMEOUT &copy
00052   timeval copy = timeout;
00053 #else
00054 # define ___ACE_TIMEOUT timep
00055   const timeval *timep = timeout;
00056 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00057 #if defined (ACE_LACKS_SELECT)
00058   ACE_UNUSED_ARG (width);
00059   ACE_UNUSED_ARG (rfds);
00060   ACE_UNUSED_ARG (wfds);
00061   ACE_UNUSED_ARG (efds);
00062   ACE_UNUSED_ARG (timeout);
00063   ACE_NOTSUP_RETURN (-1);
00064 #else
00065   ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, ___ACE_TIMEOUT),
00066                        int, -1);
00067 #endif
00068 #undef ___ACE_TIMEOUT
00069 }

int ACE_OS::select ( int  width,
fd_set *  rfds,
fd_set *  wfds = 0,
fd_set *  efds = 0,
const ACE_Time_Value tv = 0 
)

Definition at line 11 of file OS_NS_sys_select.inl.

00014 {
00015   ACE_OS_TRACE ("ACE_OS::select");
00016 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00017   // We must defend against non-conformity!
00018   timeval copy;
00019   timeval *timep = 0;
00020 
00021   if (timeout != 0)
00022     {
00023       copy = *timeout;
00024       timep = &copy;
00025     }
00026   else
00027     timep = 0;
00028 #else
00029   const timeval *timep = (timeout == 0 ? (const timeval *)0 : *timeout);
00030 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00031 #if defined (ACE_LACKS_SELECT)
00032   ACE_UNUSED_ARG (width);
00033   ACE_UNUSED_ARG (rfds);
00034   ACE_UNUSED_ARG (wfds);
00035   ACE_UNUSED_ARG (efds);
00036   ACE_UNUSED_ARG (timeout);
00037   ACE_NOTSUP_RETURN (-1);
00038 #else
00039   ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, timep),
00040                        int, -1);
00041 #endif
00042 }

void ACE_OS::sema_avoid_unlink ( ACE_sema_t s,
bool  avoid_unlink 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1978 of file OS_NS_Thread.inl.

01979 {
01980 #if defined (ACE_HAS_POSIX_SEM)
01981   s->avoid_unlink_ = avoid_unlink;
01982 #else
01983   ACE_UNUSED_ARG (s);
01984   ACE_UNUSED_ARG (avoid_unlink);
01985 #endif
01986 }

int ACE_OS::sema_destroy ( ACE_sema_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1426 of file OS_NS_Thread.inl.

01427 {
01428   ACE_OS_TRACE ("ACE_OS::sema_destroy");
01429 #if defined (ACE_HAS_POSIX_SEM)
01430   int result = 0;
01431 # if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01432   ACE_OS::mutex_destroy (&s->lock_);
01433   ACE_OS::cond_destroy (&s->count_nonzero_);
01434 # endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01435 # if defined (ACE_LACKS_NAMED_POSIX_SEM)
01436   if (s->name_)
01437     {
01438       // Only destroy the semaphore if we're the ones who
01439       // initialized it.
01440 #  if !defined (ACE_LACKS_SEM_DESTROY)
01441       ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
01442 #  endif /* ACE_LACKS_SEM_DESTROY */
01443       ACE_OS::shm_unlink (s->name_);
01444       delete s->name_;
01445       return result;
01446     }
01447 # else
01448   if (s->name_)
01449     {
01450       if (!s->avoid_unlink_)
01451         ACE_OS::sema_unlink (s->name_);
01452 #if defined (ACE_HAS_ALLOC_HOOKS)
01453       ACE_Allocator::instance()->free ((void *) s->name_);
01454 #else
01455       ACE_OS::free ((void *) s->name_);
01456 #endif /* ACE_HAS_ALLOC_HOOKS */
01457       ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
01458     }
01459 # endif /*  ACE_LACKS_NAMED_POSIX_SEM */
01460   else
01461     {
01462 # if !defined (ACE_LACKS_UNNAMED_SEMAPHORE) && !defined (ACE_LACKS_SEM_DESTROY)
01463       ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
01464 # endif /* !ACE_LACKS_UNNAMED_SEMAPHORE  && !ACE_LACKS_SEM_DESTROY */
01465 # if defined (ACE_LACKS_NAMED_POSIX_SEM)
01466       if (s->new_sema_)
01467 # endif /* ACE_LACKS_NAMED_POSIX_SEM */
01468 #if defined (ACE_HAS_ALLOC_HOOKS)
01469         ACE_Allocator::instance()->free(s->sema_);
01470 #else
01471         delete s->sema_;
01472 #endif /* ACE_HAS_ALLOC_HOOKS */
01473       s->sema_ = 0;
01474       return result;
01475     }
01476 #elif defined (ACE_USES_FIFO_SEM)
01477   int r0 = 0;
01478   if (s->name_)
01479     {
01480       r0 = ACE_OS::unlink (s->name_);
01481 #if defined (ACE_HAS_ALLOC_HOOKS)
01482       ACE_Allocator::instance()->free ((void *) s->name_);
01483 #else
01484       ACE_OS::free ((void *) s->name_);
01485 #endif /* ACE_HAS_ALLOC_HOOKS */
01486       s->name_ = 0;
01487     }
01488   int r1 = ACE_OS::close (s->fd_[0]);      /* ignore error */
01489   int r2 = ACE_OS::close (s->fd_[1]);      /* ignore error */
01490   return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0;
01491 #elif defined (ACE_HAS_THREADS)
01492 # if defined (ACE_HAS_STHREADS)
01493   int result;
01494   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1);
01495 # elif defined (ACE_HAS_PTHREADS)
01496   int r1 = ACE_OS::mutex_destroy (&s->lock_);
01497   int r2 = ACE_OS::cond_destroy (&s->count_nonzero_);
01498   return r1 != 0 || r2 != 0 ? -1 : 0;
01499 # elif defined (ACE_HAS_WTHREADS)
01500 #  if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01501   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1);
01502 #  else /* ACE_USES_WINCE_SEMA_SIMULATION */
01503   // Free up underlying objects of the simulated semaphore.
01504   int const r1 = ACE_OS::thread_mutex_destroy (&s->lock_);
01505   int const r2 = ACE_OS::event_destroy (&s->count_nonzero_);
01506   return r1 != 0 || r2 != 0 ? -1 : 0;
01507 #  endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01508 # elif defined (ACE_VXWORKS)
01509   int result;
01510   ACE_OSCALL (::semDelete (s->sema_), int, -1, result);
01511   s->sema_ = 0;
01512   return result;
01513 # endif /* ACE_HAS_STHREADS */
01514 #else
01515   ACE_UNUSED_ARG (s);
01516   ACE_NOTSUP_RETURN (-1);
01517 #endif /* ACE_HAS_POSIX_SEM */
01518 }

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

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1903 of file OS_NS_Thread.inl.

01911 {
01912 # if defined (ACE_HAS_WTHREADS)
01913   ACE_UNUSED_ARG (attributes);
01914 #   if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01915   ACE_UNUSED_ARG (type);
01916   ACE_UNUSED_ARG (arg);
01917   // Create the semaphore with its value initialized to <count> and
01918   // its maximum value initialized to <max>.
01919   SECURITY_ATTRIBUTES sa_buffer;
01920   SECURITY_DESCRIPTOR sd_buffer;
01921   *s = ::CreateSemaphoreW
01922     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01923      count,
01924      max,
01925      name);
01926 
01927   if (*s == 0)
01928     ACE_FAIL_RETURN (-1);
01929   /* NOTREACHED */
01930   else
01931     {
01932       // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01933       ACE_OS::set_errno_to_last_error ();
01934       return 0;
01935     }
01936 #   else /* ACE_USES_WINCE_SEMA_SIMULATION */
01937   int result = -1;
01938 
01939   // Initialize internal object for semaphore simulation.
01940   // Grab the lock as soon as possible when we initializing
01941   // the semaphore count.  Notice that we initialize the
01942   // event object as "manually reset" so we can amortize the
01943   // cost for singling/reseting the event.
01944   // @@ I changed the mutex type to thread_mutex.  Notice that this
01945   // is basically a CriticalSection object and doesn't not has
01946   // any security attribute whatsoever.  However, since this
01947   // semaphore implementation only works within a process, there
01948   // shouldn't any security issue at all.
01949   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01950       && ACE_OS::event_init (&s->count_nonzero_, 1,
01951                              count > 0, type, name, arg, sa) == 0
01952       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01953     {
01954       s->count_ = count;
01955 
01956       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01957         result = 0;
01958     }
01959 
01960   // Destroy the internal objects if we didn't initialize
01961   // either of them successfully.  Don't bother to check
01962   // for errors.
01963   if (result == -1)
01964     {
01965       ACE_OS::thread_mutex_destroy (&s->lock_);
01966       ACE_OS::event_destroy (&s->count_nonzero_);
01967     }
01968   return result;
01969 #   endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01970 # else /* ACE_HAS_WTHREADS */
01971   // Just call the normal char version.
01972   return ACE_OS::sema_init (s, count, type, attributes, ACE_Wide_To_Ascii (name).char_rep (), arg, max, sa);
01973 # endif /* ACE_HAS_WTHREADS */
01974 }

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

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1890 of file OS_NS_Thread.inl.

01897 {
01898   ACE_condattr_t *pattr = 0;
01899   return ACE_OS::sema_init (s, count, type, pattr, name, arg, max, sa);
01900 }

int ACE_OS::sema_init ( ACE_sema_t s,
u_int  count,
int  type,
ACE_condattr_t attributes,
const char *  name = 0,
void *  arg = 0,
int  max = 0x7fffffff,
LPSECURITY_ATTRIBUTES  sa = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1537 of file OS_NS_Thread.inl.

01545 {
01546   ACE_OS_TRACE ("ACE_OS::sema_init");
01547 #if defined (ACE_HAS_POSIX_SEM)
01548   ACE_UNUSED_ARG (max);
01549   ACE_UNUSED_ARG (sa);
01550 
01551   s->name_ = 0;
01552   s->avoid_unlink_ = false;
01553 #  if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01554   ACE_UNUSED_ARG (arg);
01555   ACE_UNUSED_ARG (attributes);
01556 #  else
01557   int result = -1;
01558 
01559   if (ACE_OS::mutex_init (&s->lock_, type, name,
01560                           (ACE_mutexattr_t *) arg) == 0
01561       && (attributes == 0 ?
01562           ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) :
01563             ACE_OS::cond_init (&s->count_nonzero_, *attributes, name, arg)) == 0
01564       && ACE_OS::mutex_lock (&s->lock_) == 0)
01565     {
01566       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01567         result = 0;
01568     }
01569 
01570   if (result == -1)
01571     {
01572       ACE_OS::mutex_destroy (&s->lock_);
01573       ACE_OS::cond_destroy (&s->count_nonzero_);
01574       return result;
01575     }
01576 #  endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01577 
01578 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01579   s->new_sema_ = false;
01580   if (type == USYNC_PROCESS)
01581     {
01582       // Let's see if it already exists.
01583       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01584                                         O_RDWR | O_CREAT | O_EXCL,
01585                                         ACE_DEFAULT_FILE_PERMS);
01586       if (fd == ACE_INVALID_HANDLE)
01587         {
01588           if (errno == EEXIST)
01589             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01590                                    O_RDWR | O_CREAT,
01591                                    ACE_DEFAULT_FILE_PERMS);
01592           else
01593             return -1;
01594         }
01595       else
01596         {
01597           // We own this shared memory object!  Let's set its
01598           // size.
01599           if (ACE_OS::ftruncate (fd,
01600                                  sizeof (ACE_sema_t)) == -1)
01601             return -1;
01602           s->name_ = ACE_OS::strdup (name);
01603           if (s->name_ == 0)
01604             return -1;
01605         }
01606       if (fd == -1)
01607         return -1;
01608 
01609       s->sema_ = (sem_t *)
01610         ACE_OS::mmap (0,
01611                       sizeof (ACE_sema_t),
01612                       PROT_RDWR,
01613                       MAP_SHARED,
01614                       fd,
01615                       0);
01616       ACE_OS::close (fd);
01617       if (s->sema_ == (sem_t *) MAP_FAILED)
01618         return -1;
01619       if (s->name_
01620           // @@ According UNIX Network Programming V2 by Stevens,
01621           //    sem_init() is currently not required to return zero on
01622           //    success, but it *does* return -1 upon failure.  For
01623           //    this reason, check for failure by comparing to -1,
01624           //    instead of checking for success by comparing to zero.
01625           //        -Ossama
01626           // Only initialize it if we're the one who created it.
01627           && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1)
01628         return -1;
01629       return 0;
01630     }
01631 #  else
01632   if (name)
01633     {
01634 #    if defined (sun) || defined (HPUX)
01635       // Solaris and HP-UX require the name to start with a slash. Solaris
01636       // further requires that there be no other slashes than the first.
01637       const char *last_slash = ACE_OS::strrchr (name, '/');
01638       char name2[MAXPATHLEN];
01639       if (0 == last_slash)
01640         {
01641           ACE_OS::strcpy (name2, "/");
01642           ACE_OS::strcat (name2, name);
01643           name = name2;
01644         }
01645 #      if defined (sun)
01646       else
01647         name = last_slash;         // Chop off chars preceding last slash
01648 #      endif /* sun */
01649 #    endif /* sun || HPUX */
01650 
01651       ACE_ALLOCATOR_RETURN (s->name_,
01652                             ACE_OS::strdup (name),
01653                             -1);
01654       s->sema_ = ::sem_open (s->name_,
01655                              O_CREAT,
01656                              ACE_DEFAULT_FILE_PERMS,
01657                              count);
01658       if (s->sema_ == (sem_t *) SEM_FAILED)
01659         return -1;
01660       else
01661         return 0;
01662     }
01663 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01664   else
01665     {
01666 #  if defined (ACE_LACKS_UNNAMED_SEMAPHORE)
01667       ACE_NOTSUP_RETURN (-1);
01668 #  else
01669 #if defined (ACE_HAS_ALLOC_HOOKS)
01670       ACE_ALLOCATOR_RETURN (s->sema_,
01671                             static_cast<sem_t*>(ACE_Allocator::instance()->malloc(sizeof(sem_t))),
01672                             -1);
01673 #else
01674       ACE_NEW_RETURN (s->sema_,
01675                       sem_t,
01676                       -1);
01677 #endif /* ACE_HAS_ALLOC_HOOKS */
01678 
01679 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01680       s->new_sema_ = true;
01681 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
01682       ACE_OSCALL_RETURN (::sem_init (s->sema_,
01683                                      type != USYNC_THREAD,
01684                                      count), int, -1);
01685 #  endif /* ACE_LACKS_UNNAMED_SEMAPHORE */
01686     }
01687 
01688 #elif defined (ACE_USES_FIFO_SEM)
01689   ACE_UNUSED_ARG (arg);
01690   ACE_UNUSED_ARG (max);
01691   ACE_UNUSED_ARG (sa);
01692   int             flags = 0;
01693   mode_t          mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;
01694 
01695   if (type == USYNC_THREAD)
01696     {
01697       // Create systemwide unique name for semaphore
01698       char   uname[ACE_UNIQUE_NAME_LEN];
01699       ACE_OS::unique_name ((const void *) s,
01700                             uname,
01701                             ACE_UNIQUE_NAME_LEN);
01702       name = &uname[0];
01703     }
01704 
01705   s->name_ = 0;
01706   s->fd_[0] = s->fd_[1] = ACE_INVALID_HANDLE;
01707   bool creator = false;
01708 
01709   if (ACE_OS::mkfifo (ACE_TEXT_CHAR_TO_TCHAR (name), mode) < 0)
01710     {
01711       if (errno != EEXIST)    /* already exists OK else ERR */
01712         return -1;
01713       // check if this is a real FIFO, not just some other existing file
01714       ACE_stat fs;
01715       if (ACE_OS::stat (name, &fs))
01716         return -1;
01717       if (!S_ISFIFO (fs.st_mode))
01718         {
01719           // existing file is not a FIFO
01720           errno = EEXIST;
01721           return -1;
01722         }
01723     }
01724     else
01725       creator = true; // remember we created it for initialization at end
01726 
01727   // for processshared semaphores remember who we are to be able to remove
01728   // the FIFO when we're done with it
01729   if (type == USYNC_PROCESS)
01730     {
01731       s->name_ = ACE_OS::strdup (name);
01732       if (s->name_ == 0)
01733         {
01734           if (creator)
01735             ACE_OS::unlink (name);
01736           return -1;
01737         }
01738     }
01739 
01740   if ((s->fd_[0] = ACE_OS::open (name, O_RDONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE
01741       || (s->fd_[1] = ACE_OS::open (name, O_WRONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE)
01742     return -1;
01743 
01744   /* turn off nonblocking for fd_[0] */
01745   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01746     return -1;
01747 
01748   flags &= ~O_NONBLOCK;
01749   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01750     return -1;
01751 
01752   //if (s->name_ && count)
01753   if (creator && count)
01754     {
01755       char    c = 1;
01756       for (u_int i=0; i<count ;++i)
01757         if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) != 1)
01758           return -1;
01759     }
01760 
01761   // In the case of process scope semaphores we can already unlink the FIFO now that
01762   // we completely set it up (the opened handles will keep it active until we close
01763   // thos down). This way we're protected against unexpected crashes as far as removal
01764   // is concerned.
01765   // Unfortunately this does not work for processshared FIFOs since as soon as we
01766   // have unlinked the semaphore no other process will be able to open it anymore.
01767   if (type == USYNC_THREAD)
01768     {
01769       ACE_OS::unlink (name);
01770     }
01771 
01772   return 0;
01773 #elif defined (ACE_HAS_THREADS)
01774 #  if defined (ACE_HAS_STHREADS)
01775   ACE_UNUSED_ARG (name);
01776   ACE_UNUSED_ARG (max);
01777   ACE_UNUSED_ARG (sa);
01778   ACE_UNUSED_ARG (attributes);
01779   int result;
01780   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), result),
01781                      int, -1);
01782 #  elif defined (ACE_HAS_PTHREADS)
01783   ACE_UNUSED_ARG (max);
01784   ACE_UNUSED_ARG (sa);
01785   int result = -1;
01786 
01787   if (ACE_OS::mutex_init (&s->lock_, type, name,
01788                           (ACE_mutexattr_t *) arg) == 0
01789       && (attributes == 0 ?
01790           ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) :
01791             ACE_OS::cond_init (&s->count_nonzero_, *attributes, name, arg)) == 0
01792       && ACE_OS::mutex_lock (&s->lock_) == 0)
01793     {
01794       s->count_ = count;
01795       s->waiters_ = 0;
01796 
01797       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01798         result = 0;
01799     }
01800 
01801   if (result == -1)
01802     {
01803       ACE_OS::mutex_destroy (&s->lock_);
01804       ACE_OS::cond_destroy (&s->count_nonzero_);
01805     }
01806   return result;
01807 #  elif defined (ACE_HAS_WTHREADS)
01808   ACE_UNUSED_ARG (attributes);
01809 #    if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01810   ACE_UNUSED_ARG (type);
01811   ACE_UNUSED_ARG (arg);
01812   // Create the semaphore with its value initialized to <count> and
01813   // its maximum value initialized to <max>.
01814   SECURITY_ATTRIBUTES sa_buffer;
01815   SECURITY_DESCRIPTOR sd_buffer;
01816   *s = ACE_TEXT_CreateSemaphore
01817     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01818      count,
01819      max,
01820      ACE_TEXT_CHAR_TO_TCHAR (name));
01821 
01822   if (*s == 0)
01823     ACE_FAIL_RETURN (-1);
01824   /* NOTREACHED */
01825   else
01826     {
01827       // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01828       ACE_OS::set_errno_to_last_error ();
01829       return 0;
01830     }
01831 #    else /* ACE_USES_WINCE_SEMA_SIMULATION */
01832   int result = -1;
01833 
01834   // Initialize internal object for semaphore simulation.
01835   // Grab the lock as soon as possible when we initializing
01836   // the semaphore count.  Notice that we initialize the
01837   // event object as "manually reset" so we can amortize the
01838   // cost for singling/reseting the event.
01839   // @@ I changed the mutex type to thread_mutex.  Notice that this
01840   // is basically a CriticalSection object and doesn't not has
01841   // any security attribute whatsoever.  However, since this
01842   // semaphore implementation only works within a process, there
01843   // shouldn't any security issue at all.
01844   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01845       && ACE_OS::event_init (&s->count_nonzero_, 1,
01846                              count > 0, type, name, arg, sa) == 0
01847       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01848     {
01849       s->count_ = count;
01850 
01851       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01852         result = 0;
01853     }
01854 
01855   // Destroy the internal objects if we didn't initialize
01856   // either of them successfully.  Don't bother to check
01857   // for errors.
01858   if (result == -1)
01859     {
01860       ACE_OS::thread_mutex_destroy (&s->lock_);
01861       ACE_OS::event_destroy (&s->count_nonzero_);
01862     }
01863   return result;
01864 #    endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01865 #  elif defined (ACE_VXWORKS)
01866   ACE_UNUSED_ARG (attributes);
01867   ACE_UNUSED_ARG (name);
01868   ACE_UNUSED_ARG (arg);
01869   ACE_UNUSED_ARG (max);
01870   ACE_UNUSED_ARG (sa);
01871   s->name_ = 0;
01872   s->sema_ = ::semCCreate (type, count);
01873   return s->sema_ ? 0 : -1;
01874 #  endif /* ACE_HAS_STHREADS */
01875 #else
01876   ACE_UNUSED_ARG (s);
01877   ACE_UNUSED_ARG (count);
01878   ACE_UNUSED_ARG (type);
01879   ACE_UNUSED_ARG (attributes);
01880   ACE_UNUSED_ARG (name);
01881   ACE_UNUSED_ARG (arg);
01882   ACE_UNUSED_ARG (max);
01883   ACE_UNUSED_ARG (sa);
01884   ACE_NOTSUP_RETURN (-1);
01885 #endif /* ACE_HAS_POSIX_SEM */
01886 }

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

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1524 of file OS_NS_Thread.inl.

01531 {
01532   ACE_condattr_t *pattr = 0;
01533   return ACE_OS::sema_init (s, count, type, pattr, name, arg, max, sa);
01534 }

int ACE_OS::sema_post ( ACE_sema_t s,
u_int  release_count 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2076 of file OS_NS_Thread.inl.

02077 {
02078 #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02079   // Win32 supports this natively.
02080   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
02081                                           ace_result_), int, -1);
02082 #else
02083   // On POSIX platforms we need to emulate this ourselves.
02084   // @@ We can optimize on this implementation.  However,
02085   // the semaphore promitive on Win32 doesn't allow one
02086   // to increase a semaphore to more than the count it was
02087   // first initialized.  Posix and solaris don't seem to have
02088   // this restriction.  Should we impose the restriction in
02089   // our semaphore simulation?
02090   for (size_t i = 0; i < release_count; i++)
02091     if (ACE_OS::sema_post (s) == -1)
02092       return -1;
02093 
02094   return 0;
02095 #endif /* ACE_WIN32 */
02096 }

int ACE_OS::sema_post ( ACE_sema_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2000 of file OS_NS_Thread.inl.

02001 {
02002   ACE_OS_TRACE ("ACE_OS::sema_post");
02003 # if defined (ACE_HAS_POSIX_SEM)
02004 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
02005   ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1);
02006 #   else
02007   int result = -1;
02008 
02009   if (ACE_OS::mutex_lock (&s->lock_) == 0)
02010     {
02011       if (::sem_post (s->sema_) == 0)
02012         result = ACE_OS::cond_signal (&s->count_nonzero_);
02013 
02014       ACE_OS::mutex_unlock (&s->lock_);
02015     }
02016   return result;
02017 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
02018 # elif defined (ACE_USES_FIFO_SEM)
02019   char    c = 1;
02020   if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) == sizeof (char))
02021     return 0;
02022   return -1;
02023 # elif defined (ACE_HAS_THREADS)
02024 #   if defined (ACE_HAS_STHREADS)
02025   int result;
02026   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), result), int, -1);
02027 #   elif defined (ACE_HAS_PTHREADS)
02028   int result = -1;
02029 
02030   if (ACE_OS::mutex_lock (&s->lock_) == 0)
02031     {
02032       // Always allow a waiter to continue if there is one.
02033       if (s->waiters_ > 0)
02034         result = ACE_OS::cond_signal (&s->count_nonzero_);
02035       else
02036         result = 0;
02037 
02038       s->count_++;
02039       ACE_OS::mutex_unlock (&s->lock_);
02040     }
02041   return result;
02042 #   elif defined (ACE_HAS_WTHREADS)
02043 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02044   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
02045                                           ace_result_),
02046                         int, -1);
02047 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02048   int result = -1;
02049 
02050   // Since we are simulating semaphores, we need to update semaphore
02051   // count manually.  Grab the lock to prevent race condition first.
02052   if (ACE_OS::thread_mutex_lock (&s->lock_) == 0)
02053     {
02054       // Check the original state of event object.  Single the event
02055       // object in transition from semaphore not available to
02056       // semaphore available.
02057       if (s->count_++ <= 0)
02058         result = ACE_OS::event_signal (&s->count_nonzero_);
02059       else
02060         result = 0;
02061 
02062       ACE_OS::thread_mutex_unlock (&s->lock_);
02063     }
02064   return result;
02065 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02066 #   elif defined (ACE_VXWORKS)
02067   ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1);
02068 #   endif /* ACE_HAS_STHREADS */
02069 # else
02070   ACE_UNUSED_ARG (s);
02071   ACE_NOTSUP_RETURN (-1);
02072 # endif /* ACE_HAS_POSIX_SEM */
02073 }

int ACE_OS::sema_trywait ( ACE_sema_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2099 of file OS_NS_Thread.inl.

02100 {
02101   ACE_OS_TRACE ("ACE_OS::sema_trywait");
02102 # if defined (ACE_HAS_POSIX_SEM)
02103   // POSIX semaphores set errno to EAGAIN if trywait fails
02104   ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1);
02105 # elif defined (ACE_USES_FIFO_SEM)
02106   char  c;
02107   int     rc, flags;
02108 
02109   /* turn on nonblocking for s->fd_[0] */
02110   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
02111     return -1;
02112   flags |= O_NONBLOCK;
02113   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
02114     return -1;
02115 
02116   // read sets errno to EAGAIN if no input
02117   rc = ACE_OS::read (s->fd_[0], &c, sizeof (char));
02118 
02119   /* turn off nonblocking for fd_[0] */
02120   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) >= 0)
02121   {
02122     flags &= ~O_NONBLOCK;
02123     ACE_OS::fcntl (s->fd_[0], F_SETFL, flags);
02124   }
02125 
02126   return rc == 1 ? 0 : (-1);
02127 # elif defined (ACE_HAS_THREADS)
02128 #   if defined (ACE_HAS_STHREADS)
02129   // STHREADS semaphores set errno to EBUSY if trywait fails.
02130   int result;
02131   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s),
02132                                        result),
02133                      int, -1);
02134 #   elif defined (ACE_HAS_PTHREADS)
02135 
02136   int result = -1;
02137 
02138   if (ACE_OS::mutex_lock (&s->lock_) == 0)
02139     {
02140       if (s->count_ > 0)
02141         {
02142           --s->count_;
02143           result = 0;
02144         }
02145       else
02146         errno = EBUSY;
02147 
02148       ACE_OS::mutex_unlock (&s->lock_);
02149     }
02150   return result;
02151 #   elif defined (ACE_HAS_WTHREADS)
02152 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02153   DWORD result = ::WaitForSingleObject (*s, 0);
02154 
02155   if (result == WAIT_OBJECT_0)
02156     return 0;
02157   else
02158     {
02159       if (result == WAIT_TIMEOUT)
02160         errno = EBUSY;
02161       else
02162         ACE_OS::set_errno_to_last_error ();
02163       // This is a hack, we need to find an appropriate mapping...
02164       return -1;
02165     }
02166 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02167   // Check the status of semaphore first.  Return immediately
02168   // if the semaphore is not available and avoid grabing the
02169   // lock.
02170   DWORD result = ::WaitForSingleObject (s->count_nonzero_, 0);
02171 
02172   if (result == WAIT_OBJECT_0)  // Proceed when it is available.
02173     {
02174       ACE_OS::thread_mutex_lock (&s->lock_);
02175 
02176       // Need to double check if the semaphore is still available.
02177       // The double checking scheme will slightly affect the
02178       // efficiency if most of the time semaphores are not blocked.
02179       result = ::WaitForSingleObject (s->count_nonzero_, 0);
02180       if (result == WAIT_OBJECT_0)
02181         {
02182           // Adjust the semaphore count.  Only update the event
02183           // object status when the state changed.
02184           s->count_--;
02185           if (s->count_ <= 0)
02186             ACE_OS::event_reset (&s->count_nonzero_);
02187           result = 0;
02188         }
02189 
02190       ACE_OS::thread_mutex_unlock (&s->lock_);
02191     }
02192 
02193   // Translate error message to errno used by ACE.
02194   if (result == WAIT_TIMEOUT)
02195     errno = EBUSY;
02196   else
02197     ACE_OS::set_errno_to_last_error ();
02198   // This is taken from the hack above. ;)
02199   return -1;
02200 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02201 #   elif defined (ACE_VXWORKS)
02202   if (::semTake (s->sema_, NO_WAIT) == ERROR)
02203     if (errno == S_objLib_OBJ_UNAVAILABLE)
02204       {
02205         // couldn't get the semaphore
02206         errno = EBUSY;
02207         return -1;
02208       }
02209     else
02210       // error
02211       return -1;
02212   else
02213     // got the semaphore
02214     return 0;
02215 #   endif /* ACE_HAS_STHREADS */
02216 # else
02217   ACE_UNUSED_ARG (s);
02218   ACE_NOTSUP_RETURN (-1);
02219 # endif /* ACE_HAS_POSIX_SEM */
02220 }

int ACE_OS::sema_unlink ( const char *  name  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1989 of file OS_NS_Thread.inl.

01990 {
01991 #if defined (ACE_HAS_POSIX_SEM) && !defined (ACE_LACKS_SEM_UNLINK)
01992   ACE_OSCALL_RETURN (::sem_unlink (name), int, -1);
01993 #else
01994   ACE_UNUSED_ARG (name);
01995   ACE_NOTSUP_RETURN (-1);
01996 #endif
01997 }

int ACE_OS::sema_wait ( ACE_sema_t s,
ACE_Time_Value tv 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2614 of file OS_NS_Thread.inl.

02615 {
02616   return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
02617 }

int ACE_OS::sema_wait ( ACE_sema_t s,
ACE_Time_Value tv 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2332 of file OS_NS_Thread.inl.

02333 {
02334   ACE_OS_TRACE ("ACE_OS::sema_wait");
02335 # if defined (ACE_HAS_POSIX_SEM)
02336 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
02337   int rc;
02338   timespec_t ts;
02339   ts = tv; // Calls ACE_Time_Value::operator timespec_t().
02340   ACE_OSCALL (::sem_timedwait (s->sema_, &ts), int, -1, rc);
02341   if (rc == -1 && errno == ETIMEDOUT)
02342     errno = ETIME;  /* POSIX returns ETIMEDOUT but we need ETIME */
02343   return rc;
02344 #   elif !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
02345   int result = 0;
02346   bool expired = false;
02347   ACE_Errno_Guard error (errno);
02348 
02349   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02350 
02351   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02352     result = -2;
02353   else
02354     {
02355       bool finished = true;
02356       do
02357       {
02358         result = ACE_OS::sema_trywait (s);
02359         if (result == -1 && errno == EAGAIN)
02360           expired = (tv.to_relative_time () <= ACE_Time_Value::zero);
02361         else
02362           expired = false;
02363 
02364         finished = result != -1 || expired ||
02365                    (result == -1 && errno != EAGAIN);
02366         if (!finished)
02367           {
02368             if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02369                                         &s->lock_,
02370                                         &tv) == -1)
02371               {
02372                 error = errno;
02373                 result = -1;
02374                 break;
02375               }
02376           }
02377       } while (!finished);
02378 
02379       if (expired)
02380         error = ETIME;
02381 
02382 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02383       tv = tv.now ();
02384 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02385     }
02386 
02387   if (result != -2)
02388     ACE_OS::mutex_unlock (&s->lock_);
02389   ACE_PTHREAD_CLEANUP_POP (0);
02390   return result < 0 ? -1 : result;
02391 #   else /* No native sem_timedwait(), and emulation disabled */
02392   ACE_UNUSED_ARG (s);
02393   ACE_UNUSED_ARG (tv);
02394   ACE_NOTSUP_RETURN (-1);
02395 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT */
02396 # elif defined (ACE_USES_FIFO_SEM)
02397   int rc;
02398   ACE_Time_Value timeout = tv.to_relative_time ();
02399 
02400   while (timeout > ACE_Time_Value::zero)
02401     {
02402       ACE_Handle_Set  fds_;
02403 
02404       fds_.set_bit (s->fd_[0]);
02405       if ((rc = ACE_OS::select (ACE_Handle_Set::MAXSIZE, fds_, 0, 0, timeout)) != 1)
02406         {
02407           if (rc == 0 || errno != EAGAIN)
02408           {
02409             if (rc == 0)
02410               errno = ETIME;
02411             return -1;
02412           }
02413         }
02414 
02415       // try to read the signal *but* do *not* block
02416       if (rc == 1 && ACE_OS::sema_trywait (s) == 0)
02417         return 0;
02418 
02419       // we were woken for input but someone beat us to it
02420       // so we wait again if there is still time
02421       timeout = tv.to_relative_time ();
02422     }
02423 
02424   // make sure errno is set right
02425   errno = ETIME;
02426 
02427   return -1;
02428 # elif defined (ACE_HAS_THREADS)
02429 #   if defined (ACE_HAS_STHREADS)
02430   ACE_UNUSED_ARG (s);
02431   ACE_UNUSED_ARG (tv);
02432   ACE_NOTSUP_RETURN (-1);
02433 #   elif defined (ACE_HAS_PTHREADS)
02434   int result = 0;
02435   ACE_Errno_Guard error (errno);
02436 
02437   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02438 
02439   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02440     result = -1;
02441   else
02442     {
02443       // Keep track of the number of waiters so that we can signal
02444       // them properly in <ACE_OS::sema_post>.
02445       s->waiters_++;
02446 
02447       // Wait until the semaphore count is > 0 or until we time out.
02448       while (s->count_ == 0)
02449         if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02450                                     &s->lock_,
02451                                     &tv) == -1)
02452           {
02453             error = errno;
02454             result = -2; // -2 means that we need to release the mutex.
02455             break;
02456           }
02457 
02458       --s->waiters_;
02459     }
02460 
02461   if (result == 0)
02462     {
02463 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02464       tv = tv.now ();
02465 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02466       --s->count_;
02467     }
02468 
02469   if (result != -1)
02470     ACE_OS::mutex_unlock (&s->lock_);
02471   ACE_PTHREAD_CLEANUP_POP (0);
02472   return result < 0 ? -1 : result;
02473 #   elif defined (ACE_HAS_WTHREADS)
02474 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02475   int msec_timeout;
02476 
02477   if (tv == ACE_Time_Value::zero)
02478     msec_timeout = 0; // Do a "poll."
02479   else
02480     {
02481       // Note that we must convert between absolute time (which is
02482       // passed as a parameter) and relative time (which is what
02483       // <WaitForSingleObjects> expects).
02484       ACE_Time_Value relative_time = tv.to_relative_time ();
02485 
02486       // Watchout for situations where a context switch has caused the
02487       // current time to be > the timeout.
02488       if (relative_time < ACE_Time_Value::zero)
02489         msec_timeout = 0;
02490       else
02491         msec_timeout = relative_time.msec ();
02492     }
02493 
02494   switch (::WaitForSingleObject (*s, msec_timeout))
02495     {
02496     case WAIT_OBJECT_0:
02497       tv = tv.now ();     // Update time to when acquired
02498       return 0;
02499     case WAIT_TIMEOUT:
02500       errno = ETIME;
02501       return -1;
02502     default:
02503       // This is a hack, we need to find an appropriate mapping...
02504       ACE_OS::set_errno_to_last_error ();
02505       return -1;
02506     }
02507   /* NOTREACHED */
02508 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02509   // Note that in this mode, the acquire is done in two steps, and
02510   // we may get signaled but cannot grab the semaphore before
02511   // timeout.  In that case, we'll need to restart the process with
02512   // updated timeout value.
02513 
02514   // tv is an absolute time, but we need relative to work with the Windows
02515   // API. Also, some users have become accustomed to using a 0 time value
02516   // as a shortcut for "now", which works on non-Windows because 0 is
02517   // always earlier than now. However, the need to convert to relative time
02518   // means we need to watch out for this case.
02519   ACE_Time_Value relative_time (ACE_Time_Value::zero);
02520   if (tv != ACE_Time_Value::zero)
02521     relative_time = tv.to_relative_time ();
02522   int result = -1;
02523 
02524   // While we are not timeout yet. >= 0 will let this go through once
02525   // and if not able to get the object, it should hit WAIT_TIMEOUT
02526   // right away.
02527   while (relative_time >= ACE_Time_Value::zero)
02528     {
02529       // Wait for our turn to get the object.
02530       switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ()))
02531         {
02532         case WAIT_OBJECT_0:
02533           ACE_OS::thread_mutex_lock (&s->lock_);
02534 
02535           // Need to double check if the semaphore is still available.
02536           // We can only do a "try lock" styled wait here to avoid
02537           // blocking threads that want to signal the semaphore.
02538           if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02539             {
02540               // As before, only reset the object when the semaphore
02541               // is no longer available.
02542               s->count_--;
02543               if (s->count_ <= 0)
02544                 ACE_OS::event_reset (&s->count_nonzero_);
02545               result = 0;
02546             }
02547 
02548           ACE_OS::thread_mutex_unlock (&s->lock_);
02549 
02550           // Only return when we successfully get the semaphore.
02551           if (result == 0)
02552             {
02553               tv = tv.now ();     // Update to time acquired
02554               return 0;
02555             }
02556           break;
02557 
02558           // We have timed out.
02559         case WAIT_TIMEOUT:
02560           errno = ETIME;
02561           return -1;
02562 
02563           // What?
02564         default:
02565           ACE_OS::set_errno_to_last_error ();
02566           // This is taken from the hack above. ;)
02567           return -1;
02568         };
02569 
02570       // Haven't been able to get the semaphore yet, update the
02571       // timeout value to reflect the remaining time we want to wait.
02572       // in case of tv == 0 relative_time will now be < 0 and we will be out of time
02573       relative_time = tv.to_relative_time ();
02574     }
02575 
02576   // We have timed out.
02577   errno = ETIME;
02578   return -1;
02579 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02580 #   elif defined (ACE_VXWORKS)
02581   // Note that we must convert between absolute time (which is
02582   // passed as a parameter) and relative time (which is what
02583   // the system call expects).
02584   ACE_Time_Value relative_time = tv.to_relative_time ();
02585 
02586   int ticks_per_sec = ::sysClkRateGet ();
02587 
02588   int ticks = relative_time.sec () * ticks_per_sec +
02589               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02590   if (::semTake (s->sema_, ticks) == ERROR)
02591     {
02592       if (errno == S_objLib_OBJ_TIMEOUT)
02593         // Convert the VxWorks errno to one that's common for to ACE
02594         // platforms.
02595         errno = ETIME;
02596       else if (errno == S_objLib_OBJ_UNAVAILABLE)
02597         errno = EBUSY;
02598       return -1;
02599     }
02600   else
02601     {
02602       tv = tv.now ();  // Update to time acquired
02603       return 0;
02604     }
02605 #   endif /* ACE_HAS_STHREADS */
02606 # else
02607   ACE_UNUSED_ARG (s);
02608   ACE_UNUSED_ARG (tv);
02609   ACE_NOTSUP_RETURN (-1);
02610 # endif /* ACE_HAS_POSIX_SEM */
02611 }

int ACE_OS::sema_wait ( ACE_sema_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2223 of file OS_NS_Thread.inl.

02224 {
02225   ACE_OS_TRACE ("ACE_OS::sema_wait");
02226 # if defined (ACE_HAS_POSIX_SEM)
02227   ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1);
02228 # elif defined (ACE_USES_FIFO_SEM)
02229   char c;
02230   if (ACE_OS::read (s->fd_[0], &c, sizeof (char)) == 1)
02231     return 0;
02232   return -1;
02233 # elif defined (ACE_HAS_THREADS)
02234 #   if defined (ACE_HAS_STHREADS)
02235   int result;
02236   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), result), int, -1);
02237 #   elif defined (ACE_HAS_PTHREADS)
02238   int result = 0;
02239 
02240   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02241 
02242   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02243     result = -1;
02244   else
02245     {
02246       // Keep track of the number of waiters so that we can signal
02247       // them properly in <ACE_OS::sema_post>.
02248       s->waiters_++;
02249 
02250       // Wait until the semaphore count is > 0.
02251       while (s->count_ == 0)
02252         if (ACE_OS::cond_wait (&s->count_nonzero_,
02253                                &s->lock_) == -1)
02254           {
02255             result = -2; // -2 means that we need to release the mutex.
02256             break;
02257           }
02258 
02259       --s->waiters_;
02260     }
02261 
02262   if (result == 0)
02263     --s->count_;
02264 
02265   if (result != -1)
02266     ACE_OS::mutex_unlock (&s->lock_);
02267   ACE_PTHREAD_CLEANUP_POP (0);
02268   return result < 0 ? -1 : result;
02269 
02270 #   elif defined (ACE_HAS_WTHREADS)
02271 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02272   switch (::WaitForSingleObject (*s, INFINITE))
02273     {
02274     case WAIT_OBJECT_0:
02275       return 0;
02276     default:
02277       // This is a hack, we need to find an appropriate mapping...
02278       ACE_OS::set_errno_to_last_error ();
02279       return -1;
02280     }
02281   /* NOTREACHED */
02282 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02283   // Timed wait.
02284   int result = -1;
02285   for (;;)
02286     // Check if the semaphore is avialable or not and wait forever.
02287     // Don't bother to grab the lock if it is not available (to avoid
02288     // deadlock.)
02289     switch (::WaitForSingleObject (s->count_nonzero_, INFINITE))
02290       {
02291       case WAIT_OBJECT_0:
02292         ACE_OS::thread_mutex_lock (&s->lock_);
02293 
02294         // Need to double check if the semaphore is still available.
02295         // This time, we shouldn't wait at all.
02296         if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02297           {
02298             // Decrease the internal counter.  Only update the event
02299             // object's status when the state changed.
02300             s->count_--;
02301             if (s->count_ <= 0)
02302               ACE_OS::event_reset (&s->count_nonzero_);
02303             result = 0;
02304           }
02305 
02306         ACE_OS::thread_mutex_unlock (&s->lock_);
02307         // if we didn't get a hold on the semaphore, the result won't
02308         // be 0 and thus, we'll start from the beginning again.
02309         if (result == 0)
02310           return 0;
02311         break;
02312 
02313       default:
02314         // Since we wait indefinitely, anything other than
02315         // WAIT_OBJECT_O indicates an error.
02316         ACE_OS::set_errno_to_last_error ();
02317         // This is taken from the hack above. ;)
02318         return -1;
02319       }
02320   /* NOTREACHED */
02321 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02322 #   elif defined (ACE_VXWORKS)
02323   ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1);
02324 #   endif /* ACE_HAS_STHREADS */
02325 # else
02326   ACE_UNUSED_ARG (s);
02327   ACE_NOTSUP_RETURN (-1);
02328 # endif /* ACE_HAS_POSIX_SEM */
02329 }

int ACE_OS::semctl ( int  int_id,
int  semnum,
int  cmd,
semun  value 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2620 of file OS_NS_Thread.inl.

02621 {
02622   ACE_OS_TRACE ("ACE_OS::semctl");
02623 #if defined (ACE_HAS_SYSV_IPC)
02624   ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1);
02625 #else
02626   ACE_UNUSED_ARG (int_id);
02627   ACE_UNUSED_ARG (semnum);
02628   ACE_UNUSED_ARG (cmd);
02629   ACE_UNUSED_ARG (value);
02630 
02631   ACE_NOTSUP_RETURN (-1);
02632 #endif /* ACE_HAS_SYSV_IPC */
02633 }

int ACE_OS::semget ( key_t  key,
int  nsems,
int  flags 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2636 of file OS_NS_Thread.inl.

02637 {
02638   ACE_OS_TRACE ("ACE_OS::semget");
02639 #if defined (ACE_HAS_SYSV_IPC)
02640   ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1);
02641 #else
02642   ACE_UNUSED_ARG (key);
02643   ACE_UNUSED_ARG (nsems);
02644   ACE_UNUSED_ARG (flags);
02645 
02646   ACE_NOTSUP_RETURN (-1);
02647 #endif /* ACE_HAS_SYSV_IPC */
02648 }

int ACE_OS::semop ( int  int_id,
struct sembuf sops,
size_t  nsops 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 2651 of file OS_NS_Thread.inl.

02652 {
02653   ACE_OS_TRACE ("ACE_OS::semop");
02654 #if defined (ACE_HAS_SYSV_IPC)
02655   ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1);
02656 #else
02657   ACE_UNUSED_ARG (int_id);
02658   ACE_UNUSED_ARG (sops);
02659   ACE_UNUSED_ARG (nsops);
02660 
02661   ACE_NOTSUP_RETURN (-1);
02662 #endif /* ACE_HAS_SYSV_IPC */
02663 }

ssize_t ACE_OS::send ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags = 0 
) [inline]

BSD-style accept (no QoS).

Definition at line 556 of file OS_NS_sys_socket.inl.

00557 {
00558   ACE_OS_TRACE ("ACE_OS::send");
00559 
00560   // On UNIX, a non-blocking socket with no data to receive, this
00561   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00562   // platform.  UNIX 98 allows either errno, and they may be the same
00563   // numeric value.  So to make life easier for upper ACE layers as
00564   // well as application programmers, always change EAGAIN to
00565   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00566   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00567   // this function needs to be reviewed.  On Win32, the regular macros
00568   // can be used, as this is not an issue.
00569 #if defined (ACE_LACKS_SEND)
00570   ACE_UNUSED_ARG (handle);
00571   ACE_UNUSED_ARG (buf);
00572   ACE_UNUSED_ARG (len);
00573   ACE_UNUSED_ARG (flags);
00574   ACE_NOTSUP_RETURN (-1);
00575 #elif defined (ACE_WIN32)
00576   ssize_t result = ::send ((ACE_SOCKET) handle,
00577                            buf,
00578                            static_cast<int> (len),
00579                            flags);
00580   if (result == -1)
00581     {
00582       ACE_OS::set_errno_to_wsa_last_error();
00583       if (errno != ENOBUFS)
00584         return -1;
00585 
00586       ACE_SOCKCALL_RETURN(send_partial_i(handle, buf, len, flags), ssize_t, -1);
00587     }
00588   else
00589     return result;
00590 
00591 #else
00592   ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
00593 
00594 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00595   // Optimize this code out if we can detect that EAGAIN ==
00596   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00597   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00598   // macros) perform the check at run-time.  The goal is to avoid two
00599   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00600   if (ace_result_ == -1
00601 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00602       && EAGAIN != EWOULDBLOCK
00603 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00604       && errno == EAGAIN)
00605     {
00606       errno = EWOULDBLOCK;
00607     }
00608 # endif /* EAGAIN != EWOULDBLOCK*/
00609 
00610   return ace_result_;
00611 #endif /* defined (ACE_WIN32) */
00612 }

ssize_t ACE_OS::send_partial_i ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags 
)

internal function used by send when an ENOBUFS condition requires a buffer to do a partial send

Definition at line 229 of file OS_NS_sys_socket.cpp.

00233 {
00234   // the divide and conquer logic should remain consistent
00235   // with sendv_partial_i
00236 #if !defined (ACE_LACKS_SEND) && defined (ACE_WIN32)
00237   DWORD bytes_sent = 0;
00238   ssize_t result = 1;
00239   // keep dividing the current buffer_size in half and then
00240   // attempt to send the modified buffer until some data is
00241   // sent, or we get an errno that is not ENOBUFS
00242   while (true)
00243     {
00244       len -= len / 2;
00245 
00246       result = (ssize_t) ::send ((SOCKET) handle,
00247                                  buf,
00248                                  static_cast<int> (len),
00249                                  flags);
00250       if (result != SOCKET_ERROR)
00251         break;
00252 
00253       ACE_OS::set_errno_to_wsa_last_error ();
00254       // if ENOBUFS is received, we apply a divide and
00255       // conquer strategy, but if bytes are sent we
00256       // cannot guarantee this is the same behavior
00257       if ((errno != ENOBUFS) ||
00258           (bytes_sent != 0))
00259         {
00260           return -1;
00261         }
00262     }
00263 
00264   return result;
00265 #else
00266   ACE_UNUSED_ARG (handle);
00267   ACE_UNUSED_ARG (buf);
00268   ACE_UNUSED_ARG (len);
00269   ACE_UNUSED_ARG (flags);
00270   ACE_NOTSUP_RETURN (-1);
00271 #endif /* ACE_LACKS_SEND && ACE_WIN32 */
00272 }

ssize_t ACE_OS::sendfile ( ACE_HANDLE  out_fd,
ACE_HANDLE  in_fd,
off_t offset,
size_t  count 
)

Finds the length of a string (char version).

Definition at line 9 of file OS_NS_sys_sendfile.inl.

00013 {
00014 #if defined ACE_HAS_SENDFILE && ACE_HAS_SENDFILE == 1
00015   return ::sendfile (out_fd, in_fd, offset, count);
00016 #else
00017   return ACE_OS::sendfile_emulation (out_fd, in_fd, offset, count);
00018 #endif  /* ACE_HAS_SENDFILE==1 */
00019 }

ACE_Export ssize_t ACE_OS::sendfile_emulation ( ACE_HANDLE  out_fd,
ACE_HANDLE  in_fd,
off_t offset,
size_t  count 
)
ssize_t ACE_OS::sendmsg ( ACE_HANDLE  handle,
const struct msghdr msg,
int  flags 
) [inline]

BSD-style accept (no QoS).

Definition at line 615 of file OS_NS_sys_socket.inl.

00618 {
00619   ACE_OS_TRACE ("ACE_OS::sendmsg");
00620 #if !defined (ACE_LACKS_SENDMSG)
00621 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00622   DWORD bytes_sent = 0;
00623   int result = ::WSASendTo ((SOCKET) handle,
00624                             (WSABUF *) msg->msg_iov,
00625                             msg->msg_iovlen,
00626                             &bytes_sent,
00627                             flags,
00628                             msg->msg_name,
00629                             msg->msg_namelen,
00630                             0,
00631                             0);
00632 
00633   if (result != 0)
00634     {
00635       ACE_OS::set_errno_to_wsa_last_error ();
00636       return -1;
00637     }
00638   else
00639     return (ssize_t) bytes_sent;
00640 # elif defined (ACE_HAS_NONCONST_SENDMSG)
00641   ACE_SOCKCALL_RETURN (::sendmsg (handle,
00642                                   const_cast<struct msghdr *>(msg),
00643                                   flags), ssize_t, -1);
00644 # else
00645   ACE_SOCKCALL_RETURN (::sendmsg (handle, msg, flags), ssize_t, -1);
00646 # endif
00647 #else
00648   ACE_UNUSED_ARG (flags);
00649   ACE_UNUSED_ARG (msg);
00650   ACE_UNUSED_ARG (handle);
00651 
00652   ACE_NOTSUP_RETURN (-1);
00653 #endif /* ACE_LACKS_SENDMSG */
00654 }

ssize_t ACE_OS::sendto ( ACE_HANDLE  handle,
const iovec buffers,
int  buffer_count,
size_t number_of_bytes_sent,
int  flags,
const struct sockaddr addr,
int  addrlen,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func 
) [inline]

BSD-style accept (no QoS).

Definition at line 701 of file OS_NS_sys_socket.inl.

00710 {
00711   ACE_OS_TRACE ("ACE_OS::sendto");
00712 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00713   DWORD bytes_sent = 0;
00714   int result = ::WSASendTo ((SOCKET) handle,
00715                             (WSABUF*) buffers,
00716                             buffer_count,
00717                             &bytes_sent,
00718                             flags,
00719                             addr,
00720                             addrlen,
00721                             overlapped,
00722                             func);
00723   if (result != 0) {
00724     ACE_OS::set_errno_to_wsa_last_error ();
00725   }
00726   number_of_bytes_sent = static_cast<size_t> (bytes_sent);
00727   return (ssize_t) result;
00728 #else
00729   ACE_UNUSED_ARG (overlapped);
00730   ACE_UNUSED_ARG (func);
00731 
00732   number_of_bytes_sent = 0;
00733 
00734   ssize_t result = 0;
00735 
00736   for (int i = 0; i < buffer_count; ++i)
00737     {
00738        result = ACE_OS::sendto (handle,
00739                                 reinterpret_cast<char *> (
00740                                                  buffers[i].iov_base),
00741                                 buffers[i].iov_len,
00742                                 flags,
00743                                 addr,
00744                                 addrlen);
00745        if (result == -1)
00746          break;
00747        number_of_bytes_sent += static_cast<size_t> (result);
00748     }
00749 
00750   return result;
00751 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00752 }

ssize_t ACE_OS::sendto ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags,
const struct sockaddr addr,
int  addrlen 
) [inline]

BSD-style accept (no QoS).

Definition at line 657 of file OS_NS_sys_socket.inl.

00663 {
00664   ACE_OS_TRACE ("ACE_OS::sendto");
00665 #if defined (ACE_LACKS_SENDTO)
00666   ACE_UNUSED_ARG (handle);
00667   ACE_UNUSED_ARG (buf);
00668   ACE_UNUSED_ARG (len);
00669   ACE_UNUSED_ARG (flags);
00670   ACE_UNUSED_ARG (addr);
00671   ACE_UNUSED_ARG (addrlen);
00672   ACE_NOTSUP_RETURN (-1);
00673 #elif defined (ACE_VXWORKS)
00674   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00675                                  const_cast <char *> (buf),
00676                                  len,
00677                                  flags,
00678                                  const_cast<struct sockaddr *> (addr),
00679                                  addrlen),
00680                        ssize_t, -1);
00681 #elif defined (ACE_WIN32)
00682   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00683                                  buf,
00684                                  static_cast<int> (len),
00685                                  flags,
00686                                  const_cast<struct sockaddr *> (addr),
00687                                  addrlen),
00688                        ssize_t, -1);
00689 #else
00690   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00691                                  buf,
00692                                  len,
00693                                  flags,
00694                                  const_cast<struct sockaddr *> (addr),
00695                                  addrlen),
00696                        ssize_t, -1);
00697 #endif /* ACE_LACKS_SENDTO */
00698 }

ssize_t ACE_OS::sendv ( ACE_HANDLE  handle,
const iovec iov,
int  iovcnt 
) [inline]

BSD-style accept (no QoS).

Definition at line 755 of file OS_NS_sys_socket.inl.

00758 {
00759 #if defined (ACE_HAS_WINSOCK2)
00760   DWORD bytes_sent = 0;
00761   ssize_t result = 0;
00762 
00763   // Winsock 2 has WSASend and can do this directly, but Winsock 1
00764   // needs to do the sends one-by-one.
00765 # if (ACE_HAS_WINSOCK2 != 0) && !defined (ACE_DONT_USE_WSASEND)
00766   result = ::WSASend ((SOCKET) handle,
00767                       (WSABUF *) buffers,
00768                       n,
00769                       &bytes_sent,
00770                       0,
00771                       0,
00772                       0);
00773   if (result == SOCKET_ERROR)
00774     {
00775       ACE_OS::set_errno_to_wsa_last_error ();
00776       if ((errno != ENOBUFS) ||
00777           (bytes_sent != 0))
00778         {
00779           return -1;
00780         }
00781       result = sendv_partial_i(handle, buffers, n);
00782       if (result == SOCKET_ERROR)
00783         {
00784           ACE_OS::set_errno_to_wsa_last_error ();
00785           return -1;
00786         }
00787       bytes_sent = static_cast<DWORD>(result);
00788     }
00789 # else
00790   for (int i = 0; i < n; ++i)
00791     {
00792       result = ::send ((SOCKET) handle,
00793                        buffers[i].iov_base,
00794                        buffers[i].iov_len,
00795                        0);
00796 
00797       if (result == SOCKET_ERROR)
00798         {
00799           // There is a subtle difference in behaviour depending on
00800           // whether or not any data was sent.  If no data was sent,
00801           // then always return -1.  Otherwise return bytes_sent.
00802           // This gives the caller an opportunity to keep track of
00803           // bytes that have already been sent.
00804           if (bytes_sent > 0)
00805             break;
00806           else
00807             {
00808               ACE_OS::set_errno_to_wsa_last_error ();
00809               return -1;
00810             }
00811         }
00812       else
00813         {
00814           // Gets ignored on error anyway
00815           bytes_sent += result;
00816 
00817           // If the transfer isn't complete just drop out of the loop.
00818           if (result < (int)buffers[i].iov_len)
00819             break;
00820         }
00821     }
00822 # endif /* ACE_HAS_WINSOCK2 != 0 */
00823 
00824   return (ssize_t) bytes_sent;
00825 
00826 #elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX)
00827 
00828   // Platform limits the maximum socket message size.  Pare down the
00829   // iovec, if necessary, to obey the limit.
00830   iovec local_iov[ACE_IOV_MAX];
00831   long total = 0;
00832   long new_total = 0;
00833   for (int i = 0; i < n; i++)
00834     {
00835       local_iov[i].iov_base = buffers[i].iov_base;
00836       local_iov[i].iov_len  = buffers[i].iov_len;
00837 
00838       new_total = total + buffers[i].iov_len;
00839       if (new_total >= ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE)
00840         {
00841           local_iov[i].iov_len = ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE - total;
00842           n = i+1;
00843           break;
00844         }
00845       total = new_total;
00846     }
00847   return ACE_OS::writev (handle, local_iov, n);
00848 
00849 #else
00850   return ACE_OS::writev (handle, buffers, n);
00851 #endif /* ACE_HAS_WINSOCK2 */
00852 }

ssize_t ACE_OS::sendv_partial_i ( ACE_HANDLE  handle,
const iovec iov,
int  iovcnt 
)

internal function used by sendv when an ENOBUFS condition requires a buffer to do a partial send

Definition at line 158 of file OS_NS_sys_socket.cpp.

00161 {
00162   // the divide and conquer logic should remain consistent
00163   // with send_partial_i
00164 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00165   DWORD bytes_sent = 0;
00166   int result = 1;
00167   int simulated_n = n;
00168   ACE_UINT64 buffer_size = 0;
00169   ACE_Array<iovec> iovec_array(simulated_n);
00170   int i = 0;
00171   for ( ; i < simulated_n; ++i)
00172     {
00173       iovec_array[i].iov_base = buffers[i].iov_base;
00174       iovec_array[i].iov_len = buffers[i].iov_len;
00175       buffer_size += buffers[i].iov_len;
00176     }
00177   // keep dividing the current buffer_size in half and then
00178   // attempt to send the modified iovec buffer until some
00179   // data is sent, or we get an errno that is not ENOBUFS
00180   while (true)
00181     {
00182       ACE_UINT64 remove_size = buffer_size / 2;
00183       buffer_size -= remove_size;
00184       for (i = simulated_n - 1; (i >= 0) && (remove_size > 0); --i)
00185         {
00186           // if the buffer division splits an iovec, we need
00187           // to set its iov_len properly
00188           if (iovec_array[i].iov_len > remove_size)
00189             {
00190               iovec_array[i].iov_len -= static_cast<u_long>(remove_size);
00191               break;
00192             }
00193           remove_size -= iovec_array[i].iov_len;
00194         }
00195 
00196       simulated_n = i + 1;
00197 
00198       result = ::WSASend ((SOCKET) handle,
00199                           (WSABUF *) &(iovec_array[0]),
00200                           simulated_n,
00201                           &bytes_sent,
00202                           0,
00203                           0,
00204                           0);
00205       if (result != SOCKET_ERROR)
00206         break;
00207 
00208       ACE_OS::set_errno_to_wsa_last_error ();
00209       // if ENOBUFS is received, we apply a divide and
00210       // conquer strategy, but if bytes are sent we
00211       // cannot guarantee this is the same behavior
00212       if ((errno != ENOBUFS) ||
00213           (bytes_sent != 0))
00214         {
00215           return -1;
00216         }
00217     }
00218 
00219   return (ssize_t) bytes_sent;
00220 #else
00221   ACE_UNUSED_ARG (handle);
00222   ACE_UNUSED_ARG (buffers);
00223   ACE_UNUSED_ARG (n);
00224   ACE_NOTSUP_RETURN (-1);
00225 #endif /* ACE_HAS_WINSOCK2 */
00226 }

int ACE_OS::set_errno_to_last_error ( void   ) 

Definition at line 36 of file OS_NS_errno.inl.

00037 {
00038 # if defined (ACE_WIN32)
00039   return errno = ::GetLastError ();
00040 #else
00041   return errno;
00042 # endif /* defined(ACE_WIN32) */
00043 }

int ACE_OS::set_errno_to_wsa_last_error ( void   ) 

Definition at line 46 of file OS_NS_errno.inl.

00047 {
00048 # if defined (ACE_WIN32)
00049   return errno = ::WSAGetLastError ();
00050 #else
00051   return errno;
00052 # endif /* defined(ACE_WIN32) */
00053 }

ACE_EXIT_HOOK ACE_OS::set_exit_hook ( ACE_EXIT_HOOK  hook  )  [inline]

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

Definition at line 473 of file OS_NS_stdlib.inl.

00474 {
00475   ACE_EXIT_HOOK old_hook = exit_hook_;
00476   exit_hook_ = exit_hook;
00477   return old_hook;
00478 }

int ACE_OS::set_scheduling_params ( const ACE_Sched_Params sched_params,
ACE_id_t  id = ACE_SELF 
)

Friendly interface to priocntl(2).

Definition at line 3418 of file OS_NS_Thread.cpp.

03420 {
03421 #if defined (ACE_HAS_PRIOCNTL)
03422   // Set priority class, priority, and quantum of this LWP or process as
03423   // specified in sched_params.
03424 
03425   // Get the priority class ID.
03426   ACE_id_t class_id;
03427   if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER  ?
03428                                   "TS"  :
03429                                   "RT", class_id) == -1)
03430     {
03431       return -1;
03432     }
03433 
03434   pcparms_t pcparms;
03435   // The following is just to avoid Purify warnings about unitialized
03436   // memory reads.
03437   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03438 
03439   pcparms.pc_cid = class_id;
03440 
03441   if (sched_params.policy () == ACE_SCHED_OTHER  &&
03442       sched_params.quantum () == ACE_Time_Value::zero)
03443       // SunOS doesn't support non-zero quantums in time-sharing class:  use
03444       // real-time class instead.
03445     {
03446       tsparms_t tsparms;
03447       // The following is just to avoid Purify warnings about unitialized
03448       // memory reads.
03449       ACE_OS::memset (&tsparms, 0, sizeof tsparms);
03450 
03451       // Don't change ts_uprilim (user priority limit)
03452       tsparms.ts_uprilim = TS_NOCHANGE;
03453       tsparms.ts_upri = sched_params.priority ();
03454 
03455       // Package up the TS class ID and parameters for the
03456       // priority_control () call.
03457       ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms);
03458     }
03459   else if (sched_params.policy () == ACE_SCHED_FIFO  ||
03460            (sched_params.policy () == ACE_SCHED_RR &&
03461             sched_params.quantum () != ACE_Time_Value::zero))
03462            // must have non-zero quantum for RR, to make it meaningful
03463            // A zero quantum with FIFO has special significance:  it actually
03464            // means infinite time quantum, i.e., run-to-completion.
03465     {
03466       rtparms_t rtparms;
03467       // The following is just to avoid Purify warnings about unitialized
03468       // memory reads.
03469       ACE_OS::memset (&rtparms, 0, sizeof rtparms);
03470 
03471       rtparms.rt_pri = sched_params.priority ();
03472 
03473       if (sched_params.quantum () == ACE_Time_Value::zero)
03474         {
03475           // rtparms.rt_tqsecs is ignored with RT_TQINF
03476           rtparms.rt_tqnsecs = RT_TQINF;
03477         }
03478       else
03479         {
03480           rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec ();
03481           rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000;
03482         }
03483 
03484       // Package up the RT class ID and parameters for the
03485       // priority_control () call.
03486       ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms);
03487     }
03488   else
03489     {
03490       errno = EINVAL;
03491       return -1;
03492     }
03493 
03494   if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD
03495                                             ? ACE_SCOPE_PROCESS
03496                                             : sched_params.scope ()),
03497                                 id,
03498                                 PC_SETPARMS,
03499                                 (char *) &pcparms) < 0)
03500     {
03501       return ACE_OS::last_error ();
03502     }
03503 
03504   return 0;
03505 #else  /* ! ACE_HAS_PRIOCNTL */
03506   ACE_UNUSED_ARG (sched_params);
03507   ACE_UNUSED_ARG (id);
03508   ACE_NOTSUP_RETURN (-1);
03509 #endif /* ! ACE_HAS_PRIOCNTL */
03510 }

void ACE_OS::set_win32_resource_module ( HINSTANCE   )  [inline]

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.

int ACE_OS::setegid ( gid_t  gid  )  [inline]

Definition at line 845 of file OS_NS_unistd.inl.

00846 {
00847   ACE_OS_TRACE ("ACE_OS::setegid");
00848 #if defined (ACE_LACKS_SETEGID)
00849   ACE_UNUSED_ARG (gid);
00850   ACE_NOTSUP_RETURN (-1);
00851 # else
00852   ACE_OSCALL_RETURN (::setegid (gid), int,  -1);
00853 # endif /* ACE_LACKS_SETEGID */
00854 }

int ACE_OS::setenv ( const char *  envname,
const char *  envval,
int  overwrite 
) [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 350 of file OS_NS_stdlib.inl.

00351 {
00352 #if defined (ACE_LACKS_SETENV)
00353   ACE_UNUSED_ARG (envname);
00354   ACE_UNUSED_ARG (envval);
00355   ACE_UNUSED_ARG (overwrite);
00356   ACE_NOTSUP_RETURN (-1);
00357 #else
00358   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::setenv (envname, envval, overwrite), int, -1);
00359 #endif
00360 }

int ACE_OS::seteuid ( uid_t  uid  )  [inline]

Definition at line 919 of file OS_NS_unistd.inl.

00920 {
00921   ACE_OS_TRACE ("ACE_OS::seteuid");
00922 #if defined (ACE_LACKS_SETEUID)
00923   ACE_UNUSED_ARG (uid);
00924   ACE_NOTSUP_RETURN (-1);
00925 # else
00926   ACE_OSCALL_RETURN (::seteuid (uid), int,  -1);
00927 # endif /* ACE_LACKS_SETEUID */
00928 }

int ACE_OS::setgid ( gid_t  gid  )  [inline]

Definition at line 833 of file OS_NS_unistd.inl.

00834 {
00835   ACE_OS_TRACE ("ACE_OS::setgid");
00836 #if defined (ACE_LACKS_SETGID)
00837   ACE_UNUSED_ARG (gid);
00838   ACE_NOTSUP_RETURN (-1);
00839 # else
00840   ACE_OSCALL_RETURN (::setgid (gid), int,  -1);
00841 # endif /* ACE_LACKS_SETGID */
00842 }

int ACE_OS::setpgid ( pid_t  pid,
pid_t  pgid 
) [inline]

Definition at line 857 of file OS_NS_unistd.inl.

00858 {
00859   ACE_OS_TRACE ("ACE_OS::setpgid");
00860 #if defined (ACE_LACKS_SETPGID)
00861   ACE_UNUSED_ARG (pid);
00862   ACE_UNUSED_ARG (pgid);
00863   ACE_NOTSUP_RETURN (-1);
00864 #else
00865   ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1);
00866 #endif /* ACE_LACKS_SETPGID */
00867 }

void ACE_OS::setprogname ( const char *  name  )  [inline]

Set the name of the current program

Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.

Definition at line 628 of file OS_NS_stdlib.inl.

00629 {
00630 #if defined (ACE_HAS_SETPROGNAME)
00631   ::setprogname (name);
00632 #else
00633   ACE_OS::setprogname_emulation (name);
00634 #endif /* ACE_HAS_SETPROGNAME */
00635 }

void ACE_OS::setprogname_emulation ( const char *  name  ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 1235 of file OS_NS_stdlib.cpp.

01236 {
01237   const char *p = ACE_OS::strrchr (progname, '/');
01238   if (p != 0)
01239     __progname = p + 1;
01240   else
01241     __progname = progname;
01242 }

void ACE_OS::setpwent ( void   ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 73 of file OS_NS_pwd.inl.

00074 {
00075 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00076   ::setpwent ();
00077 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00078 }

int ACE_OS::setregid ( gid_t  rgid,
gid_t  egid 
) [inline]

Definition at line 870 of file OS_NS_unistd.inl.

00871 {
00872   ACE_OS_TRACE ("ACE_OS::setregid");
00873 #if defined (ACE_LACKS_SETREGID)
00874   ACE_UNUSED_ARG (rgid);
00875   ACE_UNUSED_ARG (egid);
00876   ACE_NOTSUP_RETURN (-1);
00877 #else
00878   ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1);
00879 #endif /* ACE_LACKS_SETREGID */
00880 }

int ACE_OS::setreuid ( uid_t  ruid,
uid_t  euid 
) [inline]

Definition at line 883 of file OS_NS_unistd.inl.

00884 {
00885   ACE_OS_TRACE ("ACE_OS::setreuid");
00886 #if defined (ACE_LACKS_SETREUID)
00887   ACE_UNUSED_ARG (ruid);
00888   ACE_UNUSED_ARG (euid);
00889   ACE_NOTSUP_RETURN (-1);
00890 #else
00891   ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1);
00892 #endif /* ACE_LACKS_SETREUID */
00893 }

int ACE_OS::setrlimit ( int  resource,
const struct rlimit *  rl 
)

Definition at line 64 of file OS_NS_sys_resource.inl.

00065 {
00066   ACE_OS_TRACE ("ACE_OS::setrlimit");
00067 
00068 #if defined (ACE_LACKS_RLIMIT)
00069   ACE_UNUSED_ARG (resource);
00070   ACE_UNUSED_ARG (rl);
00071 
00072   ACE_NOTSUP_RETURN (-1);
00073 #else
00074 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
00075 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00076   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00077                                   const_cast<struct rlimit *>(rl)
00078                                   ), int, -1);
00079 # else
00080   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00081                                   rl
00082                                   ), int, -1);
00083 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00084 # else /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00085 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00086   ACE_OSCALL_RETURN (::setrlimit (resource, const_cast<struct rlimit *>(rl)
00087                                   ), int, -1);
00088 #  else
00089   ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1);
00090 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00091 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00092 #endif /* ACE_LACKS_RLIMIT */
00093 }

pid_t ACE_OS::setsid ( void   )  [inline]

Definition at line 896 of file OS_NS_unistd.inl.

00897 {
00898   ACE_OS_TRACE ("ACE_OS::setsid");
00899 #if defined (ACE_LACKS_SETSID)
00900   ACE_NOTSUP_RETURN (-1);
00901 #else
00902   ACE_OSCALL_RETURN (::setsid (), int, -1);
00903 # endif /* ACE_LACKS_SETSID */
00904 }

int ACE_OS::setsockopt ( ACE_HANDLE  handle,
int  level,
int  optname,
const char *  optval,
int  optlen 
) [inline]

Manipulate the options associated with a socket.

Definition at line 855 of file OS_NS_sys_socket.inl.

00860 {
00861   ACE_OS_TRACE ("ACE_OS::setsockopt");
00862 #if defined (ACE_LACKS_SETSOCKOPT)
00863   ACE_UNUSED_ARG (handle);
00864   ACE_UNUSED_ARG (level);
00865   ACE_UNUSED_ARG (optname);
00866   ACE_UNUSED_ARG (optval);
00867   ACE_UNUSED_ARG (optlen);
00868   ACE_NOTSUP_RETURN (-1);
00869 #else
00870   int result;
00871   ACE_SOCKCALL (::setsockopt ((ACE_SOCKET) handle,
00872                               level,
00873                               optname,
00874                               (ACE_SOCKOPT_TYPE1) optval,
00875                               optlen),
00876                 int,
00877                 -1,
00878                 result);
00879 #if defined (WSAEOPNOTSUPP)
00880   if (result == -1 && (errno == WSAEOPNOTSUPP || errno == WSAENOPROTOOPT))
00881 #else
00882   if (result == -1)
00883 #endif /* WSAEOPNOTSUPP */
00884     errno = ENOTSUP;
00885   return result;
00886 #endif
00887 }

int ACE_OS::setuid ( uid_t  uid  )  [inline]

Definition at line 907 of file OS_NS_unistd.inl.

00908 {
00909   ACE_OS_TRACE ("ACE_OS::setuid");
00910 #if defined (ACE_LACKS_SETUID)
00911   ACE_UNUSED_ARG (uid);
00912   ACE_NOTSUP_RETURN (-1);
00913 # else
00914   ACE_OSCALL_RETURN (::setuid (uid), int,  -1);
00915 # endif /* ACE_LACKS_SETUID */
00916 }

ACE_HANDLE ACE_OS::shm_open ( const ACE_TCHAR filename,
int  mode,
mode_t  perms = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Definition at line 242 of file OS_NS_sys_mman.inl.

00246 {
00247   ACE_OS_TRACE ("ACE_OS::shm_open");
00248 #if defined (ACE_HAS_SHM_OPEN)
00249   ACE_UNUSED_ARG (sa);
00250 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670)
00251   // With VxWorks the file should just start with / and no other
00252   // slashes, so replace all other / by _
00253   ACE_TCHAR buf [MAXPATHLEN + 1];
00254   ACE_OS::sprintf (buf,
00255                    ACE_TEXT ("%s"),
00256                    filename);
00257   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00258     {
00259       if (buf[i] == '/')
00260         {
00261           buf[i] = '_';
00262         }
00263     }
00264   filename = buf;
00265 #endif
00266   ACE_OSCALL_RETURN (::shm_open (ACE_TEXT_ALWAYS_CHAR(filename), mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00267 #elif defined (ACE_OPENVMS)
00268   //FUZZ: disable check_for_lack_ACE_OS
00269   ACE_OSCALL_RETURN (::open (filename, mode, perms, ACE_TEXT("shr=get,put,upd")), ACE_HANDLE, ACE_INVALID_HANDLE);
00270   //FUZZ: enable check_for_lack_ACE_OS
00271 #else  /* ! ACE_HAS_SHM_OPEN */
00272   // Just use ::open.
00273   return ACE_OS::open (filename, mode, perms, sa);
00274 #endif /* ACE_HAS_SHM_OPEN */
00275 }

int ACE_OS::shm_unlink ( const ACE_TCHAR path  ) 

Definition at line 278 of file OS_NS_sys_mman.inl.

00279 {
00280   ACE_OS_TRACE ("ACE_OS::shm_unlink");
00281 #if defined (ACE_HAS_SHM_OPEN)
00282 # if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670)
00283   // With VxWorks the file should just start with / and no other
00284   // slashes, so replace all other / by _
00285   ACE_TCHAR buf [MAXPATHLEN + 1];
00286   ACE_OS::sprintf (buf,
00287                    ACE_TEXT ("%s"),
00288                    path);
00289   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00290     {
00291       if (buf[i] == '/')
00292         {
00293           buf[i] = '_';
00294         }
00295     }
00296   path = buf;
00297 # endif
00298 # if defined (ACE_LACKS_SHM_UNLINK)
00299   ACE_UNUSED_ARG (path);
00300   ACE_NOTSUP_RETURN (-1);
00301 # else
00302   ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1);
00303 # endif /* ACE_LACKS_SHM_UNLINK */
00304 #else  /* ! ACE_HAS_SHM_OPEN */
00305   // Just use ::unlink.
00306   return ACE_OS::unlink (path);
00307 #endif /* ACE_HAS_SHM_OPEN */
00308 }

void * ACE_OS::shmat ( int  int_id,
const void *  shmaddr,
int  shmflg 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 7 of file OS_NS_sys_shm.inl.

00008 {
00009   ACE_OS_TRACE ("ACE_OS::shmat");
00010 #if defined (ACE_HAS_SYSV_IPC)
00011 #  if defined (ACE_HAS_CHARPTR_SHMAT)
00012   ACE_OSCALL_RETURN (::shmat (int_id, static_cast <char*> (const_cast <void *>(shmaddr)), shmflg), void *, (void *) -1);
00013 #  else
00014   ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1);
00015 #  endif /* ACE_HAS_CHARPTR_SHMAT */
00016 #else
00017   ACE_UNUSED_ARG (int_id);
00018   ACE_UNUSED_ARG (shmaddr);
00019   ACE_UNUSED_ARG (shmflg);
00020 
00021   ACE_NOTSUP_RETURN ((void *) -1);
00022 #endif /* ACE_HAS_SYSV_IPC */
00023 }

int ACE_OS::shmctl ( int  int_id,
int  cmd,
struct shmid_ds *  buf 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 26 of file OS_NS_sys_shm.inl.

00027 {
00028   ACE_OS_TRACE ("ACE_OS::shmctl");
00029 #if defined (ACE_HAS_SYSV_IPC)
00030   ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1);
00031 #else
00032   ACE_UNUSED_ARG (buf);
00033   ACE_UNUSED_ARG (cmd);
00034   ACE_UNUSED_ARG (int_id);
00035 
00036   ACE_NOTSUP_RETURN (-1);
00037 #endif /* ACE_HAS_SYSV_IPC */
00038 }

int ACE_OS::shmdt ( const void *  shmaddr  ) 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 41 of file OS_NS_sys_shm.inl.

00042 {
00043   ACE_OS_TRACE ("ACE_OS::shmdt");
00044 #if defined (ACE_HAS_SYSV_IPC)
00045 #  if defined (ACE_HAS_CHARPTR_SHMDT)
00046      ACE_OSCALL_RETURN (::shmdt (
00047       static_cast <char*> (const_cast <void *>(shmaddr))), int, -1);
00048 # else
00049      ACE_OSCALL_RETURN (::shmdt (shmaddr), int, -1);
00050 #  endif /* ACE_HAS_CHARPTR_SHMDT */
00051 #else
00052   ACE_UNUSED_ARG (shmaddr);
00053 
00054   ACE_NOTSUP_RETURN (-1);
00055 #endif /* ACE_HAS_SYSV_IPC */
00056 }

int ACE_OS::shmget ( key_t  key,
size_t  size,
int  flags 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 59 of file OS_NS_sys_shm.inl.

00060 {
00061   ACE_OS_TRACE ("ACE_OS::shmget");
00062 #if defined (ACE_HAS_SYSV_IPC)
00063   ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1);
00064 #else
00065   ACE_UNUSED_ARG (flags);
00066   ACE_UNUSED_ARG (size);
00067   ACE_UNUSED_ARG (key);
00068 
00069   ACE_NOTSUP_RETURN (-1);
00070 #endif /* ACE_HAS_SYSV_IPC */
00071 }

int ACE_OS::shutdown ( ACE_HANDLE  handle,
int  how 
) [inline]

BSD-style accept (no QoS).

Definition at line 890 of file OS_NS_sys_socket.inl.

00891 {
00892   ACE_OS_TRACE ("ACE_OS::shutdown");
00893 #if defined (ACE_LACKS_SHUTDOWN)
00894   ACE_UNUSED_ARG (handle);
00895   ACE_UNUSED_ARG (how);
00896   ACE_NOTSUP_RETURN (-1);
00897 #else
00898   ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1);
00899 #endif /* ACE_LACKS_SHUTDOWN */
00900 }

int ACE_OS::sigaction ( int  signum,
const ACE_SIGACTION nsa,
ACE_SIGACTION osa 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 61 of file OS_NS_signal.inl.

00062 {
00063   ACE_OS_TRACE ("ACE_OS::sigaction");
00064   if (signum == 0)
00065     return 0;
00066 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00067   struct sigaction sa;
00068 
00069   if (osa == 0)
00070     osa = &sa;
00071 
00072   if (nsa == 0)
00073     {
00074       osa->sa_handler = ::signal (signum, SIG_IGN);
00075       ::signal (signum, osa->sa_handler);
00076     }
00077   else
00078     osa->sa_handler = ::signal (signum, nsa->sa_handler);
00079   return osa->sa_handler == SIG_ERR ? -1 : 0;
00080 #elif defined (ACE_LACKS_SIGACTION)
00081   ACE_UNUSED_ARG (nsa);
00082   ACE_UNUSED_ARG (osa);
00083   ACE_NOTSUP_RETURN (-1);
00084 #elif !defined (ACE_HAS_SIGACTION_CONSTP2)
00085   ACE_OSCALL_RETURN (::sigaction (signum,
00086                                   const_cast<ACE_SIGACTION*> (nsa),
00087                                   osa),
00088                      int, -1);
00089 #else
00090   ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1);
00091 #endif /* ACE_WIN32 !ACE_HAS_WINCE */
00092 }

int ACE_OS::sigaddset ( sigset_t s,
int  signum 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 95 of file OS_NS_signal.inl.

00096 {
00097   ACE_OS_TRACE ("ACE_OS::sigaddset");
00098 #if defined (ACE_LACKS_SIGSET)
00099   if (s == 0)
00100     {
00101       errno = EFAULT;
00102       return -1;
00103     }
00104   else if (signum < 1 || signum >= ACE_NSIG)
00105     {
00106       errno = EINVAL;
00107       return -1;                 // Invalid signum, return error
00108     }
00109   *s |= (1 << (signum - 1)) ;
00110   return 0 ;
00111 #else
00112   return ace_sigaddset_helper (s, signum);
00113 #endif /* ACE_LACKS_SIGSET */
00114 }

int ACE_OS::sigdelset ( sigset_t s,
int  signum 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 117 of file OS_NS_signal.inl.

00118 {
00119 #if defined (ACE_LACKS_SIGSET)
00120   if (s == 0)
00121     {
00122       errno = EFAULT;
00123       return -1;
00124     }
00125   else if (signum < 1 || signum >= ACE_NSIG)
00126     {
00127       errno = EINVAL;
00128       return -1;                 // Invalid signum, return error
00129     }
00130   *s &= ~(1 << (signum - 1)) ;
00131   return 0;
00132 #else
00133   return ace_sigdelset_helper (s, signum);
00134 #endif /* ACE_LACKS_SIGSET */
00135 }

int ACE_OS::sigemptyset ( sigset_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 138 of file OS_NS_signal.inl.

00139 {
00140 #if defined (ACE_LACKS_SIGSET)
00141   if (s == 0)
00142     {
00143       errno = EFAULT;
00144       return -1;
00145     }
00146   *s = 0 ;
00147   return 0;
00148 #else
00149   return ace_sigemptyset_helper (s);
00150 #endif /* ACE_LACKS_SIGSET */
00151 }

int ACE_OS::sigfillset ( sigset_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 154 of file OS_NS_signal.inl.

00155 {
00156 #if defined (ACE_LACKS_SIGSET)
00157   if (s == 0)
00158     {
00159       errno = EFAULT;
00160       return -1;
00161     }
00162   *s = ~(sigset_t) 0;
00163   return 0 ;
00164 #else
00165   return ace_sigfillset_helper (s);
00166 #endif /* ACE_LACKS_SIGSET */
00167 }

int ACE_OS::sigismember ( sigset_t s,
int  signum 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 170 of file OS_NS_signal.inl.

00171 {
00172 #if defined (ACE_LACKS_SIGSET)
00173   if (s == 0)
00174     {
00175       errno = EFAULT;
00176       return -1;
00177     }
00178   else if (signum < 1 || signum >= ACE_NSIG)
00179     {
00180       errno = EINVAL;
00181       return -1;                 // Invalid signum, return error
00182     }
00183   return ((*s & (1 << (signum - 1))) != 0) ;
00184 #else
00185 #  if defined (ACE_HAS_SIGISMEMBER_BUG)
00186   if (signum < 1 || signum >= ACE_NSIG)
00187     {
00188       errno = EINVAL;
00189       return -1;                 // Invalid signum, return error
00190     }
00191 #  endif /* ACE_HAS_SIGISMEMBER_BUG */
00192   return ace_sigismember_helper (s, signum);
00193 #endif /* ACE_LACKS_SIGSET */
00194 }

ACE_SignalHandler ACE_OS::signal ( int  signum,
ACE_SignalHandler  func 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 197 of file OS_NS_signal.inl.

00198 {
00199   if (signum == 0)
00200     return 0;
00201   else
00202 #if (defined ACE_WIN32 && !defined ACE_HAS_WINCE) || \
00203     (!defined ACE_LACKS_UNIX_SIGNALS && !defined ACE_LACKS_SIGNAL)
00204 #  if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS4_SIGNALS)
00205     return ::signal (signum, func);
00206 #  else
00207     return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func);
00208 #  endif /* !ACE_HAS_TANDEM_SIGNALS && !ACE_HAS_LYNXOS4_SIGNALS */
00209 #else
00210     // @@ WINCE: Don't know how to implement signal on WinCE (yet.)
00211     ACE_UNUSED_ARG (signum);
00212     ACE_UNUSED_ARG (func);
00213     ACE_NOTSUP_RETURN (0);     // Should return SIG_ERR but it is not defined on WinCE.
00214 #endif /* defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) */
00215 }

int ACE_OS::sigprocmask ( int  how,
const sigset_t nsp,
sigset_t osp 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 218 of file OS_NS_signal.inl.

00219 {
00220 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) || defined (ACE_LACKS_SIGPROCMASK)
00221   ACE_UNUSED_ARG (how);
00222   ACE_UNUSED_ARG (nsp);
00223   ACE_UNUSED_ARG (osp);
00224   ACE_NOTSUP_RETURN (-1);
00225 #else
00226   ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1);
00227 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS || ACE_LACKS_SIGPROCMASK */
00228 }

int ACE_OS::sigsuspend ( const sigset_t s  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 231 of file OS_NS_signal.inl.

00232 {
00233 #if defined (ACE_HAS_SIGSUSPEND)
00234   sigset_t sigset;
00235 
00236   if (s == 0)
00237     {
00238       ACE_OS::sigemptyset (&sigset);
00239       s = &sigset;
00240     }
00241   return ace_sigsuspend_helper (s);
00242 #else
00243   ACE_UNUSED_ARG (s);
00244   ACE_NOTSUP_RETURN (-1);
00245 #endif /* ACE_HAS_SIGSUSPEND */
00246 }

int ACE_OS::sigtimedwait ( const sigset_t set,
siginfo_t info,
const ACE_Time_Value timeout 
) [inline]

Definition at line 2666 of file OS_NS_Thread.inl.

02669 {
02670   ACE_OS_TRACE ("ACE_OS::sigtimedwait");
02671 #if defined (ACE_HAS_SIGTIMEDWAIT)
02672   timespec_t ts;
02673   timespec_t *tsp = 0;
02674 
02675   if (timeout != 0)
02676     {
02677       ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
02678       tsp = &ts;
02679     }
02680 
02681   ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp),
02682                      int, -1);
02683 #else
02684     ACE_UNUSED_ARG (sset);
02685     ACE_UNUSED_ARG (info);
02686     ACE_UNUSED_ARG (timeout);
02687     ACE_NOTSUP_RETURN (-1);
02688 #endif /* ACE_HAS_SIGTIMEDWAIT */
02689 }

int ACE_OS::sigwait ( sigset_t set,
int *  sig = 0 
) [inline]

Definition at line 2692 of file OS_NS_Thread.inl.

02693 {
02694   ACE_OS_TRACE ("ACE_OS::sigwait");
02695   int local_sig;
02696   if (sig == 0)
02697     sig = &local_sig;
02698 #if defined (ACE_HAS_THREADS)
02699 # if (defined (__FreeBSD__) && (__FreeBSD__ < 3))
02700     ACE_UNUSED_ARG (sset);
02701     ACE_NOTSUP_RETURN (-1);
02702 # elif defined (ACE_HAS_STHREADS)
02703    # if (_POSIX_C_SOURCE - 0 >= 199506L) || defined (_POSIX_PTHREAD_SEMANTICS)
02704      errno = ::sigwait (sset, sig);
02705      return errno == 0  ?  *sig  :  -1;
02706    #else
02707      *sig = ::sigwait (sset);
02708      return *sig;
02709    #endif /* _POSIX_C_SOURCE - 0 >= 199506L || _POSIX_PTHREAD_SEMANTICS */
02710 # elif defined (ACE_HAS_PTHREADS)
02711 #   if defined (CYGWIN32)
02712       // Cygwin has sigwait definition, but it is not implemented
02713       ACE_UNUSED_ARG (sset);
02714       ACE_NOTSUP_RETURN (-1);
02715 #   else   /* this is std */
02716       errno = ::sigwait (sset, sig);
02717       return errno == 0  ?  *sig  :  -1;
02718 #   endif /* CYGWIN32 */
02719 # elif defined (ACE_HAS_WTHREADS)
02720     ACE_UNUSED_ARG (sset);
02721     ACE_NOTSUP_RETURN (-1);
02722 # elif defined (ACE_VXWORKS)
02723     // Second arg is a struct siginfo *, which we don't need (the
02724     // selected signal number is returned).  Third arg is timeout:  0
02725     // means forever.
02726     *sig = ::sigtimedwait (sset, 0, 0);
02727     return *sig;
02728 # endif /* __FreeBSD__ */
02729 #else
02730     ACE_UNUSED_ARG (sset);
02731     ACE_UNUSED_ARG (sig);
02732     ACE_NOTSUP_RETURN (-1);
02733 #endif /* ACE_HAS_THREADS */
02734 }

int ACE_OS::sigwaitinfo ( const sigset_t set,
siginfo_t info 
) [inline]

Definition at line 2737 of file OS_NS_Thread.inl.

02739 {
02740   ACE_OS_TRACE ("ACE_OS::sigwaitinfo");
02741   // If this platform has sigtimedwait, it should have sigwaitinfo as well.
02742   // If this isn't true somewhere, let me know and I'll fix this.
02743   // -Steve Huston <shuston@riverace.com>.
02744 #if defined (ACE_HAS_SIGTIMEDWAIT)
02745   ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1);
02746 #else
02747   ACE_UNUSED_ARG (sset);
02748   ACE_UNUSED_ARG (info);
02749   ACE_NOTSUP_RETURN (-1);
02750 #endif /* ACE_HAS_SIGTIMEDWAIT */
02751 }

int ACE_OS::sleep ( const ACE_Time_Value tv  )  [inline]

Definition at line 954 of file OS_NS_unistd.inl.

00955 {
00956   ACE_OS_TRACE ("ACE_OS::sleep");
00957 #if defined (ACE_WIN32)
00958   ::Sleep (tv.msec ());
00959   return 0;
00960 #elif defined (ACE_HAS_CLOCK_GETTIME)
00961   timespec_t rqtp = tv;
00962   //FUZZ: disable check_for_lack_ACE_OS
00963   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00964   //FUZZ: enable check_for_lack_ACE_OS
00965 #else
00966 # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00967   // Copy the timeval, because this platform doesn't declare the timeval
00968   // as a pointer to const.
00969   timeval tv_copy = tv;
00970   //FUZZ: disable check_for_lack_ACE_OS
00971   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1);
00972   //FUZZ: enable check_for_lack_ACE_OS
00973 # else  /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */
00974   const timeval *tvp = tv;
00975   //FUZZ: disable check_for_lack_ACE_OS
00976   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1);
00977   //FUZZ: enable check_for_lack_ACE_OS
00978 # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00979 #endif /* ACE_WIN32 */
00980 }

int ACE_OS::sleep ( u_int  seconds  )  [inline]

Definition at line 931 of file OS_NS_unistd.inl.

00932 {
00933   ACE_OS_TRACE ("ACE_OS::sleep");
00934 #if defined (ACE_HAS_CLOCK_GETTIME)
00935   struct timespec rqtp;
00936   // Initializer doesn't work with Green Hills 1.8.7
00937   rqtp.tv_sec = seconds;
00938   rqtp.tv_nsec = 0L;
00939   //FUZZ: disable check_for_lack_ACE_OS
00940   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00941   //FUZZ: enable check_for_lack_ACE_OS
00942 #elif defined (ACE_LACKS_SLEEP)
00943   ACE_UNUSED_ARG (seconds);
00944   ACE_NOTSUP_RETURN (-1);
00945 #elif defined (ACE_WIN32)
00946   ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
00947   return 0;
00948 #else
00949   ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
00950 #endif /* ACE_WIN32 */
00951 }

int ACE_OS::snprintf ( wchar_t buf,
size_t  maxlen,
const wchar_t format,
  ... 
)

Definition at line 390 of file OS_NS_stdio.cpp.

00391 {
00392   // ACE_OS_TRACE ("ACE_OS::snprintf");
00393 #if defined (ACE_LACKS_VA_FUNCTIONS)
00394   ACE_UNUSED_ARG (buf);
00395   ACE_UNUSED_ARG (maxlen);
00396   ACE_UNUSED_ARG (format);
00397   ACE_NOTSUP_RETURN (-1);
00398 #else
00399   va_list ap;
00400   va_start (ap, format);
00401   int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
00402   va_end (ap);
00403   return result;
00404 #endif /* ACE_LACKS_VA_FUNCTIONS */
00405 }

int ACE_OS::snprintf ( char *  buf,
size_t  maxlen,
const char *  format,
  ... 
)

Definition at line 370 of file OS_NS_stdio.cpp.

00371 {
00372   // ACE_OS_TRACE ("ACE_OS::snprintf");
00373 #if defined (ACE_LACKS_VA_FUNCTIONS)
00374   ACE_UNUSED_ARG (buf);
00375   ACE_UNUSED_ARG (maxlen);
00376   ACE_UNUSED_ARG (format);
00377   ACE_NOTSUP_RETURN (-1);
00378 #else
00379   va_list ap;
00380   va_start (ap, format);
00381   int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
00382   va_end (ap);
00383   return result;
00384 #endif /* ACE_LACKS_VA_FUNCTIONS */
00385 }

ACE_HANDLE ACE_OS::socket ( int  protocol_family,
int  type,
int  proto,
ACE_Protocol_Info protocolinfo,
ACE_SOCK_GROUP  g,
u_long  flags 
) [inline]

Create a QoS-enabled socket. If the OS platform doesn't support QoS-enabled <socket> then the BSD-style <socket> is called.

Definition at line 923 of file OS_NS_sys_socket.inl.

00929 {
00930   ACE_OS_TRACE ("ACE_OS::socket");
00931 
00932 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00933   ACE_SOCKCALL_RETURN (::WSASocket (domain,
00934                                     type,
00935                                     proto,
00936                                     protocolinfo,
00937                                     g,
00938                                     flags),
00939                        ACE_HANDLE,
00940                        ACE_INVALID_HANDLE);
00941 #else
00942   ACE_UNUSED_ARG (protocolinfo);
00943   ACE_UNUSED_ARG (g);
00944   ACE_UNUSED_ARG (flags);
00945 
00946   return ACE_OS::socket (domain,
00947                          type,
00948                          proto);
00949 #endif /* ACE_HAS_WINSOCK2 */
00950 }

ACE_HANDLE ACE_OS::socket ( int  protocol_family,
int  type,
int  proto 
) [inline]

Create a BSD-style socket (no QoS).

Definition at line 903 of file OS_NS_sys_socket.inl.

00906 {
00907   ACE_OS_TRACE ("ACE_OS::socket");
00908 #if defined (ACE_LACKS_SOCKET)
00909   ACE_UNUSED_ARG (domain);
00910   ACE_UNUSED_ARG (type);
00911   ACE_UNUSED_ARG (proto);
00912   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00913 #else
00914   ACE_SOCKCALL_RETURN (::socket (domain,
00915                                  type,
00916                                  proto),
00917                        ACE_HANDLE,
00918                        ACE_INVALID_HANDLE);
00919 #endif /* ACE_LACKS_SOCKET */
00920 }

int ACE_OS::socket_fini ( void   ) 

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

Definition at line 131 of file OS_NS_sys_socket.cpp.

00132 {
00133 # if defined (ACE_WIN32)
00134   if (ACE_OS::socket_initialized_ != 0)
00135     {
00136       if (WSACleanup () != 0)
00137         {
00138           int error = ::WSAGetLastError ();
00139 #   if defined (ACE_HAS_WINCE)
00140           ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
00141           ACE_TCHAR buf[80];  // @@ Eliminate magic number.
00142           ACE_OS::snprintf (buf, 80, fmt, ACE_TEXT ("WSACleanup %d"), error);
00143           ::MessageBox (0, buf , ACE_TEXT ("WSACleanup failed!"), MB_OK);
00144 #   else
00145           ACE_OS::fprintf (stderr,
00146                            "ACE_OS::socket_fini; WSACleanup failed, "
00147                              "WSAGetLastError returned %d\n",
00148                            error);
00149 #   endif /* ACE_HAS_WINCE */
00150         }
00151       ACE_OS::socket_initialized_ = 0;
00152     }
00153 # endif /* ACE_WIN32 */
00154   return 0;
00155 }

int ACE_OS::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.

Definition at line 97 of file OS_NS_sys_socket.cpp.

00098 {
00099 # if defined (ACE_WIN32) && !defined(ACE_DONT_INIT_WINSOCK)
00100   if (ACE_OS::socket_initialized_ == 0)
00101     {
00102       WORD version_requested = MAKEWORD (version_high, version_low);
00103       WSADATA wsa_data;
00104       int error = WSAStartup (version_requested, &wsa_data);
00105 
00106       if (error != 0)
00107 #   if defined (ACE_HAS_WINCE)
00108         {
00109           ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
00110           ACE_TCHAR buf[80];  // @@ Eliminate magic number.
00111           ACE_OS::snprintf (buf, 80, fmt, ACE_TEXT ("WSAStartup %d"), error);
00112           ::MessageBox (0, buf, ACE_TEXT ("WSAStartup failed!"), MB_OK);
00113         }
00114 #   else
00115       ACE_OS::fprintf (stderr,
00116                        "ACE_OS::socket_init; WSAStartup failed, "
00117                          "WSAGetLastError returned %d\n",
00118                        error);
00119 #   endif /* ACE_HAS_WINCE */
00120 
00121       ACE_OS::socket_initialized_ = 1;
00122     }
00123 # else
00124   ACE_UNUSED_ARG (version_high);
00125   ACE_UNUSED_ARG (version_low);
00126 # endif /* ACE_WIN32 */
00127   return 0;
00128 }

int ACE_OS::socketpair ( int  domain,
int  type,
int  protocol,
ACE_HANDLE  sv[2] 
) [inline]

BSD-style accept (no QoS).

Definition at line 953 of file OS_NS_sys_socket.inl.

00955 {
00956   ACE_OS_TRACE ("ACE_OS::socketpair");
00957 #if defined (ACE_LACKS_SOCKETPAIR)
00958   ACE_UNUSED_ARG (domain);
00959   ACE_UNUSED_ARG (type);
00960   ACE_UNUSED_ARG (protocol);
00961   ACE_UNUSED_ARG (sv);
00962 
00963   ACE_NOTSUP_RETURN (-1);
00964 #else
00965   ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv),
00966                      int, -1);
00967 #endif /* ACE_LACKS_SOCKETPAIR */
00968 }

int ACE_OS::sprintf ( wchar_t buf,
const wchar_t format,
  ... 
)

Definition at line 427 of file OS_NS_stdio.cpp.

00428 {
00429   // ACE_OS_TRACE ("ACE_OS::sprintf");
00430 #if defined (ACE_LACKS_VA_FUNCTIONS)
00431   ACE_UNUSED_ARG (buf);
00432   ACE_UNUSED_ARG (format);
00433   ACE_NOTSUP_RETURN (-1);
00434 #else
00435   va_list ap;
00436   va_start (ap, format);
00437   int const result = ACE_OS::vsprintf (buf, format, ap);
00438   va_end (ap);
00439   return result;
00440 #endif /* ACE_LACKS_VA_FUNCTIONS */
00441 }

int ACE_OS::sprintf ( char *  buf,
const char *  format,
  ... 
)

Definition at line 409 of file OS_NS_stdio.cpp.

00410 {
00411   // ACE_OS_TRACE ("ACE_OS::sprintf");
00412 #if defined (ACE_LACKS_VA_FUNCTIONS)
00413   ACE_UNUSED_ARG (buf);
00414   ACE_UNUSED_ARG (format);
00415   ACE_NOTSUP_RETURN (-1);
00416 #else
00417   va_list ap;
00418   va_start (ap, format);
00419   int const result = ACE_OS::vsprintf (buf, format, ap);
00420   va_end (ap);
00421   return result;
00422 #endif /* ACE_LACKS_VA_FUNCTIONS */
00423 }

void ACE_OS::srand ( u_int  seed  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 481 of file OS_NS_stdlib.inl.

00482 {
00483   ACE_OS_TRACE ("ACE_OS::srand");
00484 #ifdef ACE_LACKS_SRAND
00485   ACE_UNUSED_ARG (seed);
00486 #else
00487   ::srand (seed);
00488 #endif
00489 }

int ACE_OS::stat ( const wchar_t file,
ACE_stat stp 
) [inline]

Definition at line 239 of file OS_NS_sys_stat.inl.

00240   {
00241     ACE_OS_TRACE ("ACE_OS::stat");
00242 #if defined (ACE_HAS_WINCE)
00243     WIN32_FIND_DATAW fdata;
00244 
00245     int rc = 0;
00246     HANDLE fhandle;
00247 
00248     fhandle = ::FindFirstFileW (file, &fdata);
00249     if (fhandle == INVALID_HANDLE_VALUE)
00250       {
00251         ACE_OS::set_errno_to_last_error ();
00252         return -1;
00253       }
00254     else if (fdata.nFileSizeHigh != 0)
00255       {
00256         errno = EINVAL;
00257         rc = -1;
00258       }
00259     else
00260       {
00261         stp->st_mode = static_cast<mode_t>(fdata.dwFileAttributes);
00262         stp->st_size = fdata.nFileSizeLow;
00263         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec ();
00264         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec ();
00265         stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec ();
00266       }
00267 
00268     ::FindClose (fhandle);
00269     return rc;
00270 #elif defined (__BORLANDC__) \
00271       || defined (_MSC_VER) \
00272       || (defined (__MINGW32__) && !defined (__MINGW64_VERSION_MAJOR))
00273     ACE_OSCALL_RETURN (ACE_WSTAT_FUNC_NAME (file, stp), int, -1);
00274 #else /* ACE_HAS_WINCE */
00275     ACE_Wide_To_Ascii nfile (file);
00276     return ACE_OS::stat (nfile.char_rep (), stp);
00277 #endif /* ACE_HAS_WINCE */
00278   }

int ACE_OS::stat ( const char *  file,
ACE_stat stp 
) [inline]

Definition at line 195 of file OS_NS_sys_stat.inl.

00196   {
00197     ACE_OS_TRACE ("ACE_OS::stat");
00198 #if defined (ACE_HAS_NONCONST_STAT)
00199     ACE_OSCALL_RETURN (::stat (const_cast <char *> (file), stp), int, -1);
00200 #elif defined (ACE_HAS_WINCE)
00201     ACE_TEXT_WIN32_FIND_DATA fdata;
00202 
00203     int rc = 0;
00204     HANDLE fhandle;
00205 
00206     fhandle = ::FindFirstFile (ACE_TEXT_CHAR_TO_TCHAR (file), &fdata);
00207     if (fhandle == INVALID_HANDLE_VALUE)
00208       {
00209         ACE_OS::set_errno_to_last_error ();
00210         return -1;
00211       }
00212     else if (fdata.nFileSizeHigh != 0)
00213       {
00214         errno = EINVAL;
00215         rc = -1;
00216       }
00217     else
00218       {
00219         stp->st_mode = static_cast<mode_t>(fdata.dwFileAttributes);
00220         stp->st_size = fdata.nFileSizeLow;
00221         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec ();
00222         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec ();
00223         stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec ();
00224       }
00225 
00226     ::FindClose (fhandle);
00227     return rc;
00228 #elif defined (ACE_HAS_X86_STAT_MACROS)
00229     // Solaris for intel uses an macro for stat(), this macro is a
00230     // wrapper for _xstat().
00231     ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1);
00232 #else
00233     ACE_OSCALL_RETURN (ACE_STAT_FUNC_NAME (file, stp), int, -1);
00234 #endif /* ACE_HAS_NONCONST_STAT */
00235   }

int ACE_OS::step ( const char *  str,
char *  expbuf 
)

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 23 of file OS_NS_regex.inl.

00024 {
00025   ACE_OS_TRACE ("ACE_OS::step");
00026 #if defined (ACE_HAS_REGEX)
00027   ACE_OSCALL_RETURN (::step (str, expbuf), int, -1);
00028 #else
00029   ACE_UNUSED_ARG (str);
00030   ACE_UNUSED_ARG (expbuf);
00031 
00032   ACE_NOTSUP_RETURN (-1);
00033 #endif /* ACE_HAS_REGEX */
00034 }

int ACE_OS::strcasecmp ( const wchar_t s,
const wchar_t t 
)

Compares two strings (case insensitive const wchar_t version).

Definition at line 22 of file OS_NS_strings.inl.

00023 {
00024 #  if defined (ACE_LACKS_WCSICMP)
00025   return ACE_OS::wcsicmp_emulation (s, t);
00026 #  else  /* ACE_LACKS_WCSICMP */
00027   return ::_wcsicmp (s, t);
00028 #  endif /* ACE_LACKS_WCSICMP */
00029 }

int ACE_OS::strcasecmp ( const char *  s,
const char *  t 
)

Compares two strings (case insensitive const char version).

Definition at line 9 of file OS_NS_strings.inl.

00010 {
00011 #if defined (ACE_LACKS_STRCASECMP)
00012   return ACE_OS::strcasecmp_emulation (s, t);
00013 #elif defined (ACE_STRCASECMP_EQUIVALENT)
00014   return ACE_STRCASECMP_EQUIVALENT (s, t);
00015 #else /* ACE_LACKS_STRCASECMP */
00016   return ::strcasecmp (s, t);
00017 #endif /* ACE_LACKS_STRCASECMP */
00018 }

wchar_t * ACE_OS::strcat ( wchar_t s,
const wchar_t t 
)

Appends a string to another string (wchar_t version).

Definition at line 112 of file OS_NS_string.inl.

00113 {
00114 #  if defined (ACE_LACKS_WCSCAT)
00115   return ACE_OS::wcscat_emulation (s, t);
00116 #  else /* ACE_LACKS_WCSCAT */
00117   return ::wcscat (s, t);
00118 #  endif /* ACE_LACKS_WCSCAT */
00119 }

char * ACE_OS::strcat ( char *  s,
const char *  t 
)

Appends a string to another string (char version).

Definition at line 105 of file OS_NS_string.inl.

00106 {
00107   return ::strcat (s, t);
00108 }

wchar_t * ACE_OS::strchr ( wchar_t s,
wchar_t  c 
)

Finds the first occurrence of a character in a string (wchar_t version).

Definition at line 148 of file OS_NS_string.inl.

00149 {
00150   return
00151     const_cast<wchar_t *> (ACE_OS::strchr (const_cast<const wchar_t *> (s),
00152                                            c));
00153 }

char * ACE_OS::strchr ( char *  s,
int  c 
)

Finds the first occurrence of a character in a string (char version).

Definition at line 141 of file OS_NS_string.inl.

00142 {
00143   return ::strchr (s, c);
00144 }

const wchar_t * ACE_OS::strchr ( const wchar_t s,
wchar_t  c 
)

Finds the first occurrence of a character in a string (const wchar_t version).

Definition at line 130 of file OS_NS_string.inl.

00131 {
00132 #  if defined (ACE_LACKS_WCSCHR)
00133   return ACE_OS::wcschr_emulation (s, c);
00134 #  else /* ACE_LACKS_WCSCHR */
00135   return ::wcschr (s, c);
00136 #  endif /* ACE_LACKS_WCSCHR */
00137 }

const char * ACE_OS::strchr ( const char *  s,
int  c 
)

Finds the first occurrence of a character in a string (const char version).

Definition at line 123 of file OS_NS_string.inl.

00124 {
00125   return const_cast <const char *> (::strchr (s, c));
00126 }

int ACE_OS::strcmp ( const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t 
)

Compares two strings (wchar_t version).

Definition at line 163 of file OS_NS_string.inl.

00164 {
00165 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00166   return ACE_OS::wcscmp_emulation (s, t);
00167 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00168   return ::wcscmp (s, t);
00169 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00170 }

int ACE_OS::strcmp ( const char *  s,
const char *  t 
)

Compares two strings (char version).

Definition at line 157 of file OS_NS_string.inl.

00158 {
00159   return ::strcmp (s, t);
00160 }

wchar_t * ACE_OS::strcpy ( wchar_t s,
const wchar_t t 
)

Copies a string (wchar_t version).

Definition at line 180 of file OS_NS_string.inl.

00181 {
00182 #  if defined (ACE_LACKS_WCSCPY)
00183   return ACE_OS::wcscpy_emulation (s, t);
00184 #  else /* ACE_LACKS_WCSCPY */
00185   return ::wcscpy (s, t);
00186 #  endif /* ACE_LACKS_WCSCPY */
00187 }

char * ACE_OS::strcpy ( char *  s,
const char *  t 
)

Copies a string (char version).

Definition at line 173 of file OS_NS_string.inl.

00174 {
00175   return ::strcpy (s, t);
00176 }

size_t ACE_OS::strcspn ( const wchar_t s,
const wchar_t reject 
)

Searches for the first substring without any of the specified characters and returns the size of the substring (wchar_t version).

Definition at line 198 of file OS_NS_string.inl.

00199 {
00200 #  if defined (ACE_LACKS_WCSCSPN)
00201   return ACE_OS::wcscspn_emulation (s, reject);
00202 #  else /* ACE_LACKS_WCSCSPN */
00203   return ::wcscspn (s, reject);
00204 #  endif /* ACE_LACKS_WCSCSPN */
00205 }

size_t ACE_OS::strcspn ( const char *  s,
const char *  reject 
)

Searches for the first substring without any of the specified characters and returns the size of the substring (char version).

Definition at line 191 of file OS_NS_string.inl.

00192 {
00193   return ::strcspn (s, reject);
00194 }

wchar_t * ACE_OS::strdup ( const wchar_t s  ) 

Returns a malloced duplicated string (wchar_t version).

Definition at line 225 of file OS_NS_string.inl.

00226 {
00227 #  if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
00228   || defined (ACE_HAS_WCSDUMP_EMULATION)
00229   return ACE_OS::strdup_emulation (s);
00230 #  elif defined (ACE_WCSDUP_EQUIVALENT)
00231   return ACE_WCSDUP_EQUIVALENT (s);
00232 #  elif defined (ACE_HAS_NONCONST_WCSDUP)
00233   return ::wcsdup (const_cast<wchar_t*> (s));
00234 #  else
00235   return ::wcsdup (s);
00236 #  endif /* (ACE_LACKS_WCSDUP && !ACE_WCSDUP_EQUIVALENT) || ... */
00237 }

char * ACE_OS::strdup ( const char *  s  ) 

Returns a malloced duplicated string (char version).

Definition at line 209 of file OS_NS_string.inl.

00210 {
00211 #  if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
00212   || defined (ACE_HAS_STRDUP_EMULATION)
00213   return ACE_OS::strdup_emulation (s);
00214 #  elif defined (ACE_STRDUP_EQUIVALENT)
00215   return ACE_STRDUP_EQUIVALENT (s);
00216 #  elif defined (ACE_HAS_NONCONST_STRDUP)
00217   return ::strdup (const_cast<char *> (s));
00218 #else
00219   return ::strdup (s);
00220 #  endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
00221 }

ACE_Export wchar_t* ACE_OS::strdup_emulation ( const wchar_t s  ) 

Finds characters in a buffer (const void version).

ACE_Export char* ACE_OS::strdup_emulation ( const char *  s  ) 

Finds characters in a buffer (const void version).

wchar_t * ACE_OS::strecpy ( wchar_t s,
const wchar_t t 
)

Copies a string, but returns a pointer to the end of the copied region (wchar_t version).

Definition at line 83 of file OS_NS_string.cpp.

00084 {
00085   wchar_t *dscan = s;
00086   const wchar_t *sscan = t;
00087 
00088   while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0'))
00089     continue;
00090 
00091   return dscan;
00092 }

char * ACE_OS::strecpy ( char *  des,
const char *  src 
)

Copies a string, but returns a pointer to the end of the copied region (char version).

Definition at line 70 of file OS_NS_string.cpp.

00071 {
00072   char *dscan = s;
00073   const char *sscan = t;
00074 
00075   while ((*dscan++ = *sscan++) != '\0')
00076     continue;
00077 
00078   return dscan;
00079 }

ACE_TCHAR * ACE_OS::strenvdup ( const ACE_TCHAR str  ) 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 112 of file OS_NS_stdlib.cpp.

00113 {
00114 #if defined (ACE_HAS_WINCE)
00115   // WinCE doesn't have environment variables so we just skip it.
00116   return ACE_OS::strdup (str);
00117 #elif defined (ACE_LACKS_STRENVDUP)
00118   ACE_UNUSED_ARG (str);
00119   ACE_NOTSUP_RETURN (0);
00120 #else
00121   const ACE_TCHAR * start = 0;
00122   if ((start = ACE_OS::strchr (str, ACE_TEXT ('$'))) != 0)
00123     {
00124       ACE_TCHAR buf[ACE_DEFAULT_ARGV_BUFSIZ];
00125       size_t var_len = ACE_OS::strcspn (&start[1],
00126         ACE_TEXT ("$~!#%^&*()-+=\\|/?,.;:'\"`[]{} \t\n\r"));
00127       ACE_OS::strncpy (buf, &start[1], var_len);
00128       buf[var_len++] = ACE_TEXT ('\0');
00129 #  if defined (ACE_WIN32)
00130       // Always use the ACE_TCHAR for Windows.
00131       ACE_TCHAR *temp = ACE_OS::getenv (buf);
00132 #  else
00133       // Use char * for environment on non-Windows.
00134       char *temp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (buf));
00135 #  endif /* ACE_WIN32 */
00136       size_t buf_len = ACE_OS::strlen (str) + 1;
00137       if (temp != 0)
00138         buf_len += ACE_OS::strlen (temp) - var_len;
00139       ACE_TCHAR * buf_p = buf;
00140       if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ)
00141         {
00142           buf_p =
00143 #if defined (ACE_HAS_ALLOC_HOOKS)
00144             (ACE_TCHAR *) ACE_Allocator::instance()->malloc (buf_len * sizeof (ACE_TCHAR));
00145 #else
00146             (ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR));
00147 #endif /* ACE_HAS_ALLOC_HOOKS */
00148           if (buf_p == 0)
00149             {
00150               errno = ENOMEM;
00151               return 0;
00152             }
00153         }
00154       ACE_TCHAR * p = buf_p;
00155       size_t len = start - str;
00156       ACE_OS::strncpy (p, str, len);
00157       p += len;
00158       if (temp != 0)
00159         {
00160 #  if defined (ACE_WIN32)
00161           p = ACE_OS::strecpy (p, temp) - 1;
00162 #  else
00163           p = ACE_OS::strecpy (p, ACE_TEXT_CHAR_TO_TCHAR (temp)) - 1;
00164 #  endif /* ACE_WIN32 */
00165         }
00166       else
00167         {
00168           ACE_OS::strncpy (p, start, var_len);
00169           p += var_len;
00170           *p = ACE_TEXT ('\0');
00171         }
00172       ACE_OS::strcpy (p, &start[var_len]);
00173       return (buf_p == buf) ? ACE_OS::strdup (buf) : buf_p;
00174     }
00175   else
00176     return ACE_OS::strdup (str);
00177 #endif /* ACE_HAS_WINCE */
00178 }

char * ACE_OS::strerror ( int  errnum  ) 

Returns a system error message. If the supplied errnum is out of range, a string of the form "Unknown error %d" is used to format the string whose pointer is returned and errno is set to EINVAL.

Definition at line 96 of file OS_NS_string.cpp.

00097 {
00098   static char ret_errortext[128];
00099 
00100   if (ACE::is_sock_error (errnum))
00101     {
00102       const ACE_TCHAR *errortext = ACE::sock_error (errnum);
00103       ACE_OS::strncpy (ret_errortext,
00104                        ACE_TEXT_ALWAYS_CHAR (errortext),
00105                        sizeof (ret_errortext));
00106       return ret_errortext;
00107     }
00108 #if defined (ACE_LACKS_STRERROR)
00109   errno = EINVAL;
00110   return ACE_OS::strerror_emulation (errnum);
00111 #else /* ACE_LACKS_STRERROR */
00112   // Adapt to the various ways that strerror() indicates a bad errnum.
00113   // Most modern systems set errno to EINVAL. Some older platforms return
00114   // a pointer to a NULL string. This code makes the behavior more consistent
00115   // across platforms. On a bad errnum, we make a string with the error number
00116   // and set errno to EINVAL.
00117   ACE_Errno_Guard g (errno);
00118   errno = 0;
00119   char *errmsg = 0;
00120 
00121 #if defined (ACE_HAS_TR24731_2005_CRT)
00122   errmsg = ret_errortext;
00123   ACE_SECURECRTCALL (strerror_s (ret_errortext, sizeof(ret_errortext), errnum),
00124                      char *, 0, errmsg);
00125   if (errnum < 0 || errnum >= _sys_nerr)
00126     g = EINVAL;
00127 
00128   return errmsg;
00129 #elif defined (ACE_WIN32)
00130   if (errnum < 0 || errnum >= _sys_nerr)
00131     errno = EINVAL;
00132 #endif /* ACE_WIN32 */
00133   errmsg = ::strerror (errnum);
00134 
00135   if (errno == EINVAL || errmsg == 0 || errmsg[0] == 0)
00136     {
00137       ACE_OS::snprintf (ret_errortext, 128, "Unknown error %d", errnum);
00138       errmsg = ret_errortext;
00139       g = EINVAL;
00140     }
00141   return errmsg;
00142 #endif /* ACE_LACKS_STRERROR */
00143 }

ACE_Export char* ACE_OS::strerror_emulation ( int  errnum  ) 

Emulated strerror - Returns a system error message.

char * ACE_OS::strerror_r ( int  errnum,
char *  buf,
size_t  buflen 
)

Finds characters in a buffer (const void version).

Definition at line 192 of file OS_NS_string.cpp.

00193 {
00194 #ifdef ACE_HAS_STRERROR_R
00195 # ifdef ACE_HAS_STRERROR_R_XSI
00196   if (::strerror_r (errnum, buf, buflen) == 0)
00197     return buf;
00198   return const_cast <char*> ("Unknown Error");
00199 # else
00200   return ::strerror_r (errnum, buf, buflen);
00201 # endif
00202 #else
00203   return ACE_OS::strncpy (buf, strerror (errnum), buflen);
00204 #endif
00205 }

size_t ACE_OS::strftime ( char *  s,
size_t  maxsize,
const char *  format,
const struct tm timeptr 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 430 of file OS_NS_time.inl.

00432 {
00433 #if defined (ACE_LACKS_STRFTIME)
00434   ACE_UNUSED_ARG (s);
00435   ACE_UNUSED_ARG (maxsize);
00436   ACE_UNUSED_ARG (format);
00437   ACE_UNUSED_ARG (timeptr);
00438   ACE_NOTSUP_RETURN (0);
00439 #else
00440   return ACE_STD_NAMESPACE::strftime (s, maxsize, format, timeptr);
00441 #endif /* ACE_LACKS_STRFTIME */
00442 }

int ACE_OS::string_to_argv ( ACE_TCHAR buf,
int &  argc,
ACE_TCHAR **&  argv,
bool  substitute_env_args = true 
)

Definition at line 787 of file OS_NS_unistd.cpp.

00791 {
00792 #if defined (ACE_LACKS_STRENVDUP)
00793   ACE_UNUSED_ARG (substitute_env_args);
00794 #endif /* ACE_LACKS_STRENVDUP */
00795 
00796   // Reset the number of arguments
00797   argc = 0;
00798 
00799   if (buf == 0)
00800     return -1;
00801 
00802   ACE_TCHAR *cp = buf;
00803 
00804   // First pass: count arguments.
00805 
00806   // '#' is the start-comment token..
00807   while (*cp != ACE_TEXT ('\0') && *cp != ACE_TEXT ('#'))
00808     {
00809       // Skip whitespace..
00810       while (ACE_OS::ace_isspace (*cp))
00811         ++cp;
00812 
00813       // Increment count and move to next whitespace..
00814       if (*cp != ACE_TEXT ('\0'))
00815         ++argc;
00816 
00817       while (*cp != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
00818         {
00819           // Grok quotes....
00820           if (*cp == ACE_TEXT ('\'') || *cp == ACE_TEXT ('"'))
00821             {
00822               ACE_TCHAR quote = *cp;
00823 
00824               // Scan past the string..
00825               for (++cp; *cp != ACE_TEXT ('\0')
00826                    && (*cp != quote || cp[-1] == ACE_TEXT ('\\')); ++cp)
00827                 continue;
00828 
00829               // '\0' implies unmatched quote..
00830               if (*cp == ACE_TEXT ('\0'))
00831                 {
00832                   --argc;
00833                   break;
00834                 }
00835               else
00836                 ++cp;
00837             }
00838           else
00839             ++cp;
00840         }
00841     }
00842 
00843   // Second pass: copy arguments.
00844   ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
00845   ACE_TCHAR *argp = arg;
00846 
00847   // Make sure that the buffer we're copying into is always large
00848   // enough.
00849   if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
00850 #if defined (ACE_HAS_ALLOC_HOOKS)
00851   ACE_ALLOCATOR_RETURN(argp,
00852                        static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR) * (cp - buf + 1))),
00853                        -1);
00854 #else
00855     ACE_NEW_RETURN (argp,
00856                     ACE_TCHAR[cp - buf + 1],
00857                     -1);
00858 #endif /* ACE_HAS_ALLOC_HOOKS */
00859 
00860   // Make a new argv vector of argc + 1 elements.
00861 #if defined (ACE_HAS_ALLOC_HOOKS)
00862   ACE_ALLOCATOR_RETURN(argv,
00863                        static_cast<ACE_TCHAR **>(ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR*) * (argc + 1))),
00864                        -1);
00865 #else
00866   ACE_NEW_RETURN (argv,
00867                   ACE_TCHAR *[argc + 1],
00868                   -1);
00869 #endif /* ACE_HAS_ALLOC_HOOKS */
00870 
00871   ACE_TCHAR *ptr = buf;
00872 
00873   for (int i = 0; i < argc; ++i)
00874     {
00875       // Skip whitespace..
00876       while (ACE_OS::ace_isspace (*ptr))
00877         ++ptr;
00878 
00879       // Copy next argument and move to next whitespace..
00880       cp = argp;
00881       while (*ptr != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
00882         if (*ptr == ACE_TEXT ('\'') || *ptr == ACE_TEXT ('"'))
00883           {
00884             ACE_TCHAR quote = *ptr++;
00885 
00886             while (*ptr != ACE_TEXT ('\0')
00887                    && (*ptr != quote || ptr[-1] == ACE_TEXT ('\\')))
00888               {
00889                 if (*ptr == quote && ptr[-1] == ACE_TEXT ('\\')) --cp;
00890                 *cp++ = *ptr++;
00891               }
00892 
00893             if (*ptr == quote)
00894               ++ptr;
00895           }
00896         else
00897           *cp++ = *ptr++;
00898 
00899       *cp = ACE_TEXT ('\0');
00900 
00901 #if !defined (ACE_LACKS_STRENVDUP)
00902       // Check for environment variable substitution here.
00903       if (substitute_env_args) {
00904           argv[i] = ACE_OS::strenvdup (argp);
00905 
00906           if (argv[i] == 0)
00907             {
00908               if (argp != arg)
00909 #if defined (ACE_HAS_ALLOC_HOOKS)
00910                 ACE_Allocator::instance()->free(argp);
00911 #else
00912                 delete [] argp;
00913 #endif /* ACE_HAS_ALLOC_HOOKS */
00914               errno = ENOMEM;
00915               return -1;
00916             }
00917       }
00918       else
00919 #endif /* ACE_LACKS_STRENVDUP */
00920         {
00921           argv[i] = ACE_OS::strdup (argp);
00922 
00923           if (argv[i] == 0)
00924             {
00925               if (argp != arg)
00926                 {
00927 #if defined (ACE_HAS_ALLOC_HOOKS)
00928                   ACE_Allocator::instance()->free(argp);
00929 #else
00930                   delete [] argp;
00931 #endif /* ACE_HAS_ALLOC_HOOKS */
00932                 }
00933 
00934               errno = ENOMEM;
00935               return -1;
00936             }
00937         }
00938     }
00939 
00940   if (argp != arg)
00941     {
00942 #if defined (ACE_HAS_ALLOC_HOOKS)
00943       ACE_Allocator::instance()->free(argp);
00944 #else
00945       delete [] argp;
00946 #endif /* ACE_HAS_ALLOC_HOOKS */
00947     }
00948 
00949   argv[argc] = 0;
00950   return 0;
00951 }

size_t ACE_OS::strlen ( const ACE_WCHAR_T *  s  ) 

Finds the length of a string (ACE_WCHAR_T version).

Definition at line 247 of file OS_NS_string.inl.

00248 {
00249 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00250   return ACE_OS::wcslen_emulation (s);
00251 # else  /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00252   return ::wcslen (s);
00253 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00254 }

size_t ACE_OS::strlen ( const char *  s  ) 

Finds the length of a string (char version).

Definition at line 241 of file OS_NS_string.inl.

00242 {
00243   return ::strlen (s);
00244 }

int ACE_OS::strncasecmp ( const wchar_t s,
const wchar_t t,
size_t  len 
) [inline]

Compares two arrays (case insensitive const wchar_t version).

Definition at line 46 of file OS_NS_strings.inl.

00047 {
00048 #if defined (ACE_LACKS_WCSNICMP)
00049   return ACE_OS::wcsnicmp_emulation (s, t, len);
00050 #else  /* ACE_LACKS_WCSNICMP */
00051   return ::_wcsnicmp (s, t, len);
00052 #endif /* ACE_LACKS_WCSNICMP */
00053 }

int ACE_OS::strncasecmp ( const char *  s,
const char *  t,
size_t  len 
) [inline]

Compares two arrays (case insensitive const char version).

Definition at line 33 of file OS_NS_strings.inl.

00034 {
00035 #if defined (ACE_LACKS_STRCASECMP)
00036   return ACE_OS::strncasecmp_emulation (s, t, len);
00037 #elif defined (ACE_STRNCASECMP_EQUIVALENT)
00038   return ACE_STRNCASECMP_EQUIVALENT (s, t, len);
00039 #else /* ACE_LACKS_STRCASECMP */
00040   return ::strncasecmp (s, t, len);
00041 #endif /* ACE_LACKS_STRCASECMP */
00042 }

ACE_WCHAR_T * ACE_OS::strncat ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Appends part of a string to another string (wchar_t version).

Definition at line 263 of file OS_NS_string.inl.

00264 {
00265 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00266   return ACE_OS::wcsncat_emulation (s, t, len);
00267 #  elif 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00268   wcsncat_s (s, len + 1, t, _TRUNCATE);
00269   return s;
00270 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00271   return ::wcsncat (s, t, len);
00272 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00273 }

char * ACE_OS::strncat ( char *  s,
const char *  t,
size_t  len 
)

Appends part of a string to another string (char version).

Definition at line 257 of file OS_NS_string.inl.

00258 {
00259   return ::strncat (s, t, len);
00260 }

ACE_WCHAR_T * ACE_OS::strnchr ( ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len 
)

Finds the first occurrence of a character in an array (ACE_WCHAR_T version).

Definition at line 284 of file OS_NS_string.inl.

00285 {
00286   return
00287     const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
00288                                  const_cast<const ACE_WCHAR_T *> (s),
00289                                  c,
00290                                  len));
00291 }

char * ACE_OS::strnchr ( char *  s,
int  c,
size_t  len 
)

Finds the first occurrence of a character in an array (char version).

Definition at line 276 of file OS_NS_string.inl.

00277 {
00278   return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
00279                                               c,
00280                                               len));
00281 }

const ACE_WCHAR_T * ACE_OS::strnchr ( const ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len 
)

Finds the first occurrence of a character in an array (const ACE_WCHAR_T version).

Definition at line 218 of file OS_NS_string.cpp.

00219 {
00220   for (size_t i = 0; i < len; ++i)
00221     {
00222       if (s[i] == c)
00223         {
00224           return s + i;
00225         }
00226     }
00227 
00228   return 0;
00229 }

const char * ACE_OS::strnchr ( const char *  s,
int  c,
size_t  len 
)

Finds the first occurrence of a character in an array (const char version).

Definition at line 208 of file OS_NS_string.cpp.

00209 {
00210   for (size_t i = 0; i < len; ++i)
00211     if (s[i] == c)
00212       return s + i;
00213 
00214   return 0;
00215 }

int ACE_OS::strncmp ( const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Compares two arrays (wchar_t version).

Definition at line 300 of file OS_NS_string.inl.

00301 {
00302 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00303   return ACE_OS::wcsncmp_emulation (s, t, len);
00304 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00305   return ::wcsncmp (s, t, len);
00306 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00307 }

int ACE_OS::strncmp ( const char *  s,
const char *  t,
size_t  len 
)

Compares two arrays (char version).

Definition at line 294 of file OS_NS_string.inl.

00295 {
00296   return ::strncmp (s, t, len);
00297 }

ACE_WCHAR_T * ACE_OS::strncpy ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Copies an array (ACE_WCHAR_T version).

Definition at line 316 of file OS_NS_string.inl.

00317 {
00318 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00319   return ACE_OS::wcsncpy_emulation (s, t, len);
00320 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00321   return ::wcsncpy (s, t, len);
00322 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00323 }

char * ACE_OS::strncpy ( char *  s,
const char *  t,
size_t  len 
)

Copies an array (char version).

Definition at line 310 of file OS_NS_string.inl.

00311 {
00312   return ::strncpy (s, t, len);
00313 }

size_t ACE_OS::strnlen ( const ACE_WCHAR_T *  s,
size_t  maxlen 
)

Finds the length of a limited-length string (ACE_WCHAR_T version).

Parameters:
s The character string to find the length of.
maxlen The maximum number of characters that will be scanned for the terminating nul character.
Returns:
The length of
  • s, if the terminating nul character is located, else
  • maxlen.

Definition at line 340 of file OS_NS_string.inl.

00341 {
00342 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00343   return wcsnlen (s, maxlen);
00344 #else /* ACE_HAS_WCSNLEN */
00345   size_t i;
00346   for (i = 0; i < maxlen; ++i)
00347     if (s[i] == '\0')
00348       break;
00349   return i;
00350 #endif /* ACE_HAS_WCSNLEN */
00351 }

size_t ACE_OS::strnlen ( const char *  s,
size_t  maxlen 
)

Finds the length of a limited-length string (char version).

Parameters:
s The character string to find the length of.
maxlen The maximum number of characters that will be scanned for the terminating nul character.
Returns:
The length of
  • s, if the terminating nul character is located, else
  • maxlen.

Definition at line 326 of file OS_NS_string.inl.

00327 {
00328 #if defined (ACE_HAS_STRNLEN)
00329   return ::strnlen (s, maxlen);
00330 #else /* ACE_HAS_STRNLEN */
00331   size_t i;
00332   for (i = 0; i < maxlen; ++i)
00333     if (s[i] == '\0')
00334       break;
00335   return i;
00336 #endif /* ACE_HAS_STRNLEN */
00337 }

ACE_WCHAR_T * ACE_OS::strnstr ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Finds the first occurrence of a substring in an array (wchar_t version).

Definition at line 361 of file OS_NS_string.inl.

00362 {
00363   return
00364     const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
00365                                  static_cast<const ACE_WCHAR_T *> (s),
00366                                  t,
00367                                  len));
00368 }

char * ACE_OS::strnstr ( char *  s,
const char *  t,
size_t  len 
)

Finds the first occurrence of a substring in an array (char version).

Definition at line 354 of file OS_NS_string.inl.

00355 {
00356   return
00357     const_cast <char *> (ACE_OS::strnstr (const_cast <const char *> (s), t, len));
00358 }

const ACE_WCHAR_T * ACE_OS::strnstr ( const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Finds the first occurrence of a substring in an array (const wchar_t version).

Definition at line 257 of file OS_NS_string.cpp.

00258 {
00259   // Substring length
00260   size_t const len1 = ACE_OS::strlen (s1);
00261 
00262   // Check if the substring is longer than the string being searched.
00263   if (len2 > len1)
00264     return 0;
00265 
00266   // Go upto <len>
00267   size_t const len = len1 - len2;
00268 
00269   for (size_t i = 0; i <= len; i++)
00270     {
00271       if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0)
00272         {
00273           // Found a match!  Return the index.
00274           return s1 + i;
00275         }
00276     }
00277 
00278   return 0;
00279 }

const char * ACE_OS::strnstr ( const char *  s,
const char *  t,
size_t  len 
)

Finds the first occurrence of a substring in an array (const char version).

Definition at line 232 of file OS_NS_string.cpp.

00233 {
00234   // Substring length
00235   size_t const len1 = ACE_OS::strlen (s1);
00236 
00237   // Check if the substring is longer than the string being searched.
00238   if (len2 > len1)
00239     return 0;
00240 
00241   // Go upto <len>
00242   size_t const len = len1 - len2;
00243 
00244   for (size_t i = 0; i <= len; i++)
00245     {
00246       if (ACE_OS::memcmp (s1 + i, s2, len2) == 0)
00247         {
00248          // Found a match!  Return the index.
00249           return s1 + i;
00250         }
00251     }
00252 
00253   return 0;
00254 }

wchar_t * ACE_OS::strpbrk ( wchar_t s1,
const wchar_t s2 
)

Searches for characters in a string (wchar_t version).

Definition at line 396 of file OS_NS_string.inl.

00397 {
00398   return const_cast<wchar_t *> (ACE_OS::strpbrk (
00399                                   const_cast<const wchar_t *> (s), t));
00400 }

char * ACE_OS::strpbrk ( char *  s1,
const char *  s2 
)

Searches for characters in a string (char version).

Definition at line 389 of file OS_NS_string.inl.

00390 {
00391   return ::strpbrk (s1, s2);
00392 }

const wchar_t * ACE_OS::strpbrk ( const wchar_t s1,
const wchar_t s2 
)

Searches for characters in a string (const wchar_t version).

Definition at line 378 of file OS_NS_string.inl.

00379 {
00380 #  if defined (ACE_LACKS_WCSPBRK)
00381   return ACE_OS::wcspbrk_emulation (s, t);
00382 #  else /* ACE_LACKS_WCSPBRK */
00383   return ::wcspbrk (s, t);
00384 #  endif /* ACE_LACKS_WCSPBRK */
00385 }

const char * ACE_OS::strpbrk ( const char *  s1,
const char *  s2 
)

Searches for characters in a string (const char version).

Definition at line 371 of file OS_NS_string.inl.

00372 {
00373   return const_cast <const char *> (::strpbrk (s1, s2));
00374 }

char * ACE_OS::strptime ( const char *  buf,
const char *  format,
struct tm tm 
) [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 445 of file OS_NS_time.inl.

00446 {
00447   ACE_OS::memset (tm, 0, sizeof (struct tm));
00448 #if defined (ACE_LACKS_STRPTIME)
00449   return ACE_OS::strptime_emulation (buf, format, tm);
00450 #else
00451   return ACE_STD_NAMESPACE::strptime (buf, format, tm);
00452 #endif /* ACE_LACKS_STRPTIME */
00453 }

wchar_t * ACE_OS::strrchr ( wchar_t s,
wchar_t  c 
)

Finds the last occurrence of a character in a string (wchar_t version).

Definition at line 437 of file OS_NS_string.inl.

00438 {
00439   return const_cast<wchar_t *> (ACE_OS::strrchr (
00440                      const_cast<const wchar_t *> (s), c));
00441 }

char * ACE_OS::strrchr ( char *  s,
int  c 
)

Finds the last occurrence of a character in a string (char version).

Definition at line 426 of file OS_NS_string.inl.

00427 {
00428 #if defined (ACE_LACKS_STRRCHR)
00429   return ACE_OS::strrchr_emulation (s, c);
00430 #else  /* ! ACE_LACKS_STRRCHR */
00431   return ::strrchr (s, c);
00432 #endif /* ! ACE_LACKS_STRRCHR */
00433 }

const wchar_t * ACE_OS::strrchr ( const wchar_t s,
wchar_t  c 
)

Finds the last occurrence of a character in a string (const wchar_t version).

Definition at line 415 of file OS_NS_string.inl.

00416 {
00417 #if defined (ACE_LACKS_WCSRCHR)
00418   return ACE_OS::wcsrchr_emulation (s, c);
00419 #else /* ! ACE_LACKS_WCSRCHR */
00420   return const_cast <const wchar_t *> (::wcsrchr (s, c));
00421 #endif /* ! ACE_LACKS_WCSRCHR */
00422 }

const char * ACE_OS::strrchr ( const char *  s,
int  c 
)

Finds the last occurrence of a character in a string (const char version).

Definition at line 404 of file OS_NS_string.inl.

00405 {
00406 #if defined (ACE_LACKS_STRRCHR)
00407   return ACE_OS::strrchr_emulation (s, c);
00408 #else  /* ! ACE_LACKS_STRRCHR */
00409   return (const char *) ::strrchr (s, c);
00410 #endif /* ! ACE_LACKS_STRRCHR */
00411 }

ACE_Export const char* ACE_OS::strrchr_emulation ( const char *  s,
int  c 
)

Emulated strrchr (const char version) - Finds the last occurrence of a character in a string.

ACE_Export char* ACE_OS::strrchr_emulation ( char *  s,
int  c 
)

Emulated strrchr (char version) - Finds the last occurrence of a character in a string.

char * ACE_OS::strsignal ( int  signum  ) 

Returns a string describing the signal number passed in the argument signum. If the supplied signal number is out of range, a string of the form "Unknown signal %d" is used to format the string whose pointer is returned.

Definition at line 157 of file OS_NS_string.cpp.

00158 {
00159   static char signal_text[128];
00160 #if defined (ACE_HAS_STRSIGNAL)
00161   char *ret_val = 0;
00162 
00163 # if defined (ACE_NEEDS_STRSIGNAL_RANGE_CHECK)
00164   if (signum < 0 || signum >= ACE_NSIG)
00165     ret_val = 0;
00166   else
00167 # endif /* (ACE_NEEDS_STRSIGNAL_RANGE_CHECK */
00168   ret_val = ACE_STD_NAMESPACE::strsignal (signum);
00169 
00170   if (ret_val <= reinterpret_cast<char *> (0))
00171     {
00172       ACE_OS::snprintf (signal_text, 128, "Unknown signal: %d", signum);
00173       ret_val = signal_text;
00174     }
00175   return ret_val;
00176 #else
00177   if (signum < 0 || signum >= ACE_NSIG)
00178     {
00179       ACE_OS::snprintf (signal_text, 128, "Unknown signal: %d", signum);
00180       return signal_text;
00181     }
00182 # if defined (ACE_SYS_SIGLIST)
00183   return ACE_SYS_SIGLIST[signum];
00184 # else
00185   ACE_OS::snprintf (signal_text, 128, "Signal: %d", signum);
00186   return signal_text;
00187 # endif /* ACE_SYS_SIGLIST */
00188 #endif /* ACE_HAS_STRSIGNAL */
00189 }

ACE_WCHAR_T * ACE_OS::strsncpy ( ACE_WCHAR_T *  dst,
const ACE_WCHAR_T *  src,
size_t  maxlen 
)

This is a "safe" c string copy function (wchar_t version).

Unlike strncpy() this function will always add a terminating '' char if maxlen > 0. So the user doesn't has to provide an extra '' if the user wants a '' terminated dst. The function doesn't check for a 0 dst, because this will give problems anyway. When src is 0 an empty string is made. We do not "touch" * dst if maxlen is 0. Returns dst. Care should be taken when replacing strncpy() calls, because in some cases a strncpy() user is using the "not '\0' terminating" feature from strncpy(). This happens most when the call to strncpy() was optimized by using a maxlen which is 1 smaller than the size because there's always written a '' inside this last position. Very seldom it's possible that the '' padding feature from strncpy() is needed.

Definition at line 369 of file OS_NS_string.cpp.

00370 {
00371   ACE_WCHAR_T *rdst = dst;
00372   const ACE_WCHAR_T *rsrc = src;
00373   size_t rmaxlen = maxlen;
00374 
00375   if (rmaxlen > 0)
00376     {
00377       if (rdst!= rsrc)
00378         {
00379           *rdst = ACE_TEXT_WIDE ('\0');
00380           if (rsrc != 0)
00381             {
00382               ACE_OS::strncat (rdst, rsrc, --rmaxlen);
00383             }
00384         }
00385       else
00386         {
00387           rdst += (rmaxlen - 1);
00388           *rdst = ACE_TEXT_WIDE ('\0');
00389         }
00390     }
00391   return dst;
00392 }

char * ACE_OS::strsncpy ( char *  dst,
const char *  src,
size_t  maxlen 
)

This is a "safe" c string copy function (char version).

Unlike strncpy() this function will always add a terminating '' char if maxlen > 0. So the user doesn't has to provide an extra '' if the user wants a '' terminated dst. The function doesn't check for a 0 dst, because this will give problems anyway. When src is 0 an empty string is made. We do not "touch" * dst if maxlen is 0. Returns dst. Care should be taken when replacing strncpy() calls, because in some cases a strncpy() user is using the "not '\0' terminating" feature from strncpy(). This happens most when the call to strncpy() was optimized by using a maxlen which is 1 smaller than the size because there's always written a '' inside this last position. Very seldom it's possible that the '' padding feature from strncpy() is needed.

Definition at line 343 of file OS_NS_string.cpp.

00344 {
00345   char *rdst = dst;
00346   const char *rsrc = src;
00347   size_t rmaxlen = maxlen;
00348 
00349   if (rmaxlen > 0)
00350     {
00351       if (rdst!=rsrc)
00352         {
00353           *rdst = '\0';
00354           if (rsrc != 0)
00355             {
00356               ACE_OS::strncat (rdst, rsrc, --rmaxlen);
00357             }
00358         }
00359       else
00360         {
00361           rdst += (rmaxlen - 1);
00362           *rdst = '\0';
00363         }
00364     }
00365   return dst;
00366 }

size_t ACE_OS::strspn ( const wchar_t s1,
const wchar_t s2 
)

Searches for the first substring containing only the specified characters and returns the size of the substring (wchar_t version).

Definition at line 452 of file OS_NS_string.inl.

00453 {
00454 #  if defined (ACE_LACKS_WCSSPN)
00455   return ACE_OS::wcsspn_emulation (s, t);
00456 #  else /* ACE_LACKS_WCSSPN */
00457   return ::wcsspn (s, t);
00458 #  endif /* ACE_LACKS_WCSSPN */
00459 }

size_t ACE_OS::strspn ( const char *  s1,
const char *  s2 
)

Searches for the first substring containing only the specified characters and returns the size of the substring (char version).

Definition at line 445 of file OS_NS_string.inl.

00446 {
00447   return ::strspn (s, t);
00448 }

wchar_t * ACE_OS::strstr ( wchar_t s,
const wchar_t t 
)

Finds the first occurrence of a substring in a string (wchar_t version).

Definition at line 490 of file OS_NS_string.inl.

00491 {
00492 #  if defined (ACE_LACKS_WCSSTR)
00493   return ACE_OS::wcsstr_emulation (s, t);
00494 #  elif defined (HPUX)
00495   return ::wcswcs (s, t);
00496 #  else /* ACE_LACKS_WCSSTR */
00497   return ::wcsstr (s, t);
00498 #  endif /* ACE_LACKS_WCSSTR */
00499 }

char * ACE_OS::strstr ( char *  s,
const char *  t 
)

Finds the first occurrence of a substring in a string (char version).

Definition at line 483 of file OS_NS_string.inl.

00484 {
00485   return ::strstr (s, t);
00486 }

const wchar_t * ACE_OS::strstr ( const wchar_t s,
const wchar_t t 
)

Finds the first occurrence of a substring in a string (const wchar_t version).

Definition at line 470 of file OS_NS_string.inl.

00471 {
00472 #  if defined (ACE_LACKS_WCSSTR)
00473   return ACE_OS::wcsstr_emulation (s, t);
00474 #  elif defined (HPUX)
00475   return const_cast <const wchar_t *> (::wcswcs (s, t));
00476 #  else /* ACE_LACKS_WCSSTR */
00477   return const_cast <const wchar_t *> (::wcsstr (s, t));
00478 #  endif /* ACE_LACKS_WCSSTR */
00479 }

const char * ACE_OS::strstr ( const char *  s,
const char *  t 
)

Finds the first occurrence of a substring in a string (const char version).

Definition at line 463 of file OS_NS_string.inl.

00464 {
00465   return (const char *) ::strstr (s, t);
00466 }

double ACE_OS::strtod ( const wchar_t s,
wchar_t **  endptr 
) [inline]

Converts a string to a double value (wchar_t version).

Definition at line 501 of file OS_NS_stdlib.inl.

00502 {
00503   return ACE_WCHAR_STD_NAMESPACE::wcstod (s, endptr);
00504 }

double ACE_OS::strtod ( const char *  s,
char **  endptr 
) [inline]

Converts a string to a double value (char version).

Definition at line 493 of file OS_NS_stdlib.inl.

00494 {
00495   return ::strtod (s, endptr);
00496 }

wchar_t * ACE_OS::strtok ( wchar_t s,
const wchar_t tokens 
)

Finds the next token in a string (wchar_t version).

Definition at line 516 of file OS_NS_string.inl.

00517 {
00518 #if defined (ACE_HAS_3_PARAM_WCSTOK)
00519   static wchar_t *lasts = 0;
00520   return ::wcstok (s, tokens, &lasts);
00521 #else
00522   return ::wcstok (s, tokens);
00523 #endif /* ACE_HAS_3_PARAM_WCSTOK */
00524 }

char * ACE_OS::strtok ( char *  s,
const char *  tokens 
)

Finds the next token in a string (char version).

Definition at line 503 of file OS_NS_string.inl.

00504 {
00505 #if !defined (ACE_LACKS_STRTOK)
00506   return ::strtok (s, tokens);
00507 #else
00508   ACE_UNUSED_ARG (s);
00509   ACE_UNUSED_ARG (tokens);
00510   ACE_NOTSUP_RETURN (0);
00511 #endif /* ACE_LACKS_STRTOK */
00512 }

wchar_t * ACE_OS::strtok_r ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  tokens,
ACE_WCHAR_T **  lasts 
)

Finds the next token in a string (wchar_t version).

Definition at line 541 of file OS_NS_string.inl.

00542 {
00543 #if defined (ACE_HAS_TR24731_2005_CRT)
00544   return wcstok_s (s, tokens, lasts);
00545 #elif defined (ACE_LACKS_WCSTOK)
00546   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00547 #else
00548 #  if defined (ACE_HAS_3_PARAM_WCSTOK)
00549   return ::wcstok (s, tokens, lasts);
00550 #  else /* ACE_HAS_3_PARAM_WCSTOK */
00551   *lasts = ::wcstok (s, tokens);
00552   return *lasts;
00553 #  endif /* ACE_HAS_3_PARAM_WCSTOK */
00554 #endif  /* ACE_LACKS_WCSTOK */
00555 }

char * ACE_OS::strtok_r ( char *  s,
const char *  tokens,
char **  lasts 
)

Finds the next token in a string (safe char version).

Definition at line 528 of file OS_NS_string.inl.

00529 {
00530 #if defined (ACE_HAS_TR24731_2005_CRT)
00531   return strtok_s (s, tokens, lasts);
00532 #elif defined (ACE_LACKS_STRTOK_R)
00533   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00534 #else
00535   return ::strtok_r (s, tokens, lasts);
00536 #endif /* ACE_HAS_TR24731_2005_CRT */
00537 }

ACE_Export wchar_t* ACE_OS::strtok_r_emulation ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  tokens,
ACE_WCHAR_T **  lasts 
)

Emulated strtok_r (wchar_t version).

ACE_Export char* ACE_OS::strtok_r_emulation ( char *  s,
const char *  tokens,
char **  lasts 
)

Emulated strtok_r.

long ACE_OS::strtol ( const wchar_t s,
wchar_t **  ptr,
int  base 
) [inline]

Converts a string to a long value (wchar_t version).

Definition at line 519 of file OS_NS_stdlib.inl.

00520 {
00521 #if defined (ACE_LACKS_WCSTOL)
00522   return ACE_OS::wcstol_emulation (s, ptr, base);
00523 #else
00524   return ACE_WCHAR_STD_NAMESPACE::wcstol (s, ptr, base);
00525 #endif /* ACE_LACKS_WCSTOL */
00526 }

long ACE_OS::strtol ( const char *  s,
char **  ptr,
int  base 
) [inline]

Converts a string to a long value (char version).

Definition at line 508 of file OS_NS_stdlib.inl.

00509 {
00510 #if defined (ACE_LACKS_STRTOL)
00511   return ACE_OS::strtol_emulation (s, ptr, base);
00512 #else  /* ACE_LACKS_STRTOL */
00513   return ::strtol (s, ptr, base);
00514 #endif /* ACE_LACKS_STRTOL */
00515 }

ACE_INT64 ACE_OS::strtoll ( const wchar_t s,
wchar_t **  ptr,
int  base 
) [inline]

Converts a string to a signed 64 bit int value (wchar_t version).

Definition at line 565 of file OS_NS_stdlib.inl.

00566 {
00567 #if defined (ACE_LACKS_WCSTOLL)
00568   return ACE_OS::wcstoll_emulation (s, ptr, base);
00569 #elif defined (ACE_WCSTOLL_EQUIVALENT)
00570   return ACE_WCSTOLL_EQUIVALENT (s, ptr, base);
00571 #else
00572   return ACE_WCHAR_STD_NAMESPACE::wcstoll (s, ptr, base);
00573 #endif /* ACE_LACKS_WCSTOLL */
00574 }

ACE_INT64 ACE_OS::strtoll ( const char *  s,
char **  ptr,
int  base 
) [inline]

Converts a string to a signed 64 bit int value (char version).

Definition at line 552 of file OS_NS_stdlib.inl.

00553 {
00554 #if defined (ACE_LACKS_STRTOLL)
00555   return ACE_OS::strtoll_emulation (s, ptr, base);
00556 #elif defined (ACE_STRTOLL_EQUIVALENT)
00557   return ACE_STRTOLL_EQUIVALENT (s, ptr, base);
00558 #else
00559   return ace_strtoll_helper (s, ptr, base);
00560 #endif /* ACE_LACKS_STRTOLL */
00561 }

unsigned long ACE_OS::strtoul ( const wchar_t s,
wchar_t **  ptr,
int  base 
) [inline]

Converts a string to an unsigned long value (wchar_t version).

Definition at line 541 of file OS_NS_stdlib.inl.

00542 {
00543 #if defined (ACE_LACKS_WCSTOUL)
00544   return ACE_OS::wcstoul_emulation (s, ptr, base);
00545 #else
00546   return ACE_WCHAR_STD_NAMESPACE::wcstoul (s, ptr, base);
00547 #endif /* ACE_LACKS_WCSTOUL */
00548 }

unsigned long ACE_OS::strtoul ( const char *  s,
char **  ptr,
int  base 
) [inline]

Converts a string to an unsigned long value (char version).

Definition at line 530 of file OS_NS_stdlib.inl.

00531 {
00532 #if defined (ACE_LACKS_STRTOUL)
00533   return ACE_OS::strtoul_emulation (s, ptr, base);
00534 #else /* ACE_LACKS_STRTOUL */
00535   return ::strtoul (s, ptr, base);
00536 #endif /* ACE_LACKS_STRTOUL */
00537 }

ACE_UINT64 ACE_OS::strtoull ( const wchar_t s,
wchar_t **  ptr,
int  base 
) [inline]

Converts a string to a unsigned 64 bit int value (wchar_t version).

Definition at line 591 of file OS_NS_stdlib.inl.

00592 {
00593 #if defined (ACE_LACKS_WCSTOULL)
00594   return ACE_OS::wcstoull_emulation (s, ptr, base);
00595 #elif defined (ACE_WCSTOULL_EQUIVALENT)
00596   return ACE_WCSTOULL_EQUIVALENT (s, ptr, base);
00597 #else
00598   return ACE_WCHAR_STD_NAMESPACE::wcstoull (s, ptr, base);
00599 #endif /* ACE_LACKS_WCSTOULL */
00600 }

ACE_UINT64 ACE_OS::strtoull ( const char *  s,
char **  ptr,
int  base 
) [inline]

Converts a string to a unsigned 64 bit int value (char version).

Definition at line 578 of file OS_NS_stdlib.inl.

00579 {
00580 #if defined (ACE_LACKS_STRTOULL)
00581   return ACE_OS::strtoull_emulation (s, ptr, base);
00582 #elif defined (ACE_STRTOULL_EQUIVALENT)
00583   return ACE_STRTOULL_EQUIVALENT (s, ptr, base);
00584 #else
00585   return ace_strtoull_helper (s, ptr, base);
00586 #endif /* ACE_LACKS_STRTOULL */
00587 }

void ACE_OS::swab ( const void *  src,
void *  dest,
ssize_t  n 
) [inline]

Definition at line 983 of file OS_NS_unistd.inl.

00986 {
00987 #if defined (ACE_LACKS_SWAB)
00988   // ------------------------------------------------------------
00989   // The following copyright notice applies to the swab()
00990   // implementation within this "ACE_LACKS_SWAB" block of code.
00991   // ------------------------------------------------------------
00992   /*
00993     Copyright (c) 1994-2006  Red Hat, Inc. All rights reserved.
00994 
00995     This copyrighted material is made available to anyone wishing to
00996     use, modify, copy, or redistribute it subject to the terms and
00997     conditions of the BSD License.   This program is distributed in
00998     the hope that it will be useful, but WITHOUT ANY WARRANTY
00999     expressed or implied, including the implied warranties of
01000     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  A copy of
01001     this license is available at
01002     http://www.opensource.org/licenses. Any Red Hat trademarks that
01003     are incorporated in the source code or documentation are not
01004     subject to the BSD License and may only be used or replicated with
01005     the express permission of Red Hat, Inc.
01006   */
01007 
01008   const char *from = static_cast<const char*> (src);
01009   char *to = static_cast<char *> (dest);
01010   ssize_t ptr = 0;
01011   for (ptr = 1; ptr < length; ptr += 2)
01012     {
01013       char p = from[ptr];
01014       char q = from[ptr-1];
01015       to[ptr-1] = p;
01016       to[ptr  ] = q;
01017     }
01018   if (ptr == length) /* I.e., if length is odd, */
01019     to[ptr-1] = 0;   /* then pad with a NUL. */
01020 #elif defined (ACE_HAS_NONCONST_SWAB)
01021   const char *tmp = static_cast<const char*> (src);
01022   char *from = const_cast<char *> (tmp);
01023   char *to = static_cast<char *> (dest);
01024 #  if defined (ACE_HAS_INT_SWAB)
01025   int ilength = ACE_Utils::truncate_cast<int> (length);
01026 #    if defined (ACE_SWAB_EQUIVALENT)
01027   ACE_SWAB_EQUIVALENT (from, to, ilength);
01028 #    else
01029   ::swab (from, to, ilength);
01030 #    endif
01031 #  else
01032   ::swab (from, to, length);
01033 #  endif /* ACE_HAS_INT_SWAB */
01034 #elif defined (ACE_HAS_CONST_CHAR_SWAB)
01035   const char *from = static_cast<const char*> (src);
01036   char *to = static_cast<char *> (dest);
01037   ::swab (from, to, length);
01038 #else
01039   ::swab (src, dest, length);
01040 #endif /* ACE_LACKS_SWAB */
01041 
01042 }

long ACE_OS::sysconf ( int  name  )  [inline]

Definition at line 1045 of file OS_NS_unistd.inl.

01046 {
01047   ACE_OS_TRACE ("ACE_OS::sysconf");
01048 #if defined (ACE_LACKS_SYSCONF)
01049   ACE_UNUSED_ARG (name);
01050   ACE_NOTSUP_RETURN (-1);
01051 #else
01052   ACE_OSCALL_RETURN (::sysconf (name), long, -1);
01053 #endif /* ACE_LACKS_SYSCONF */
01054 }

long ACE_OS::sysinfo ( int  cmd,
char *  buf,
long  count 
) [inline]

Definition at line 1057 of file OS_NS_unistd.inl.

01058 {
01059   ACE_OS_TRACE ("ACE_OS::sysinfo");
01060 #if defined (ACE_HAS_SYSV_SYSINFO)
01061   ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1);
01062 #else
01063   ACE_UNUSED_ARG (cmd);
01064   ACE_UNUSED_ARG (buf);
01065   ACE_UNUSED_ARG (count);
01066 
01067   ACE_NOTSUP_RETURN (0);
01068 #endif /* ACE_HAS_SYSV_SYSINFO */
01069 }

int ACE_OS::system ( const ACE_TCHAR s  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 604 of file OS_NS_stdlib.inl.

00605 {
00606   // ACE_OS_TRACE ("ACE_OS::system");
00607 #if defined (ACE_LACKS_SYSTEM)
00608   ACE_UNUSED_ARG (s);
00609   ACE_NOTSUP_RETURN (-1);
00610 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00611   ACE_OSCALL_RETURN (::_wsystem (s), int, -1);
00612 #else
00613   ACE_OSCALL_RETURN (::system (ACE_TEXT_ALWAYS_CHAR (s)), int, -1);
00614 #endif /* ACE_LACKS_SYSTEM */
00615 }

int ACE_OS::t_accept ( ACE_HANDLE  fildes,
ACE_HANDLE  resfd,
struct t_call *  call 
) [inline]

Definition at line 9 of file OS_TLI.inl.

00010 {
00011 #if defined (ACE_HAS_TLI)
00012   ACE_OSCALL_RETURN (::t_accept (handle, reshandle, call), int, -1);
00013 #else
00014   ACE_UNUSED_ARG (call);
00015   ACE_UNUSED_ARG (reshandle);
00016   ACE_UNUSED_ARG (handle);
00017 
00018   ACE_NOTSUP_RETURN (-1);
00019 #endif /* ACE_HAS_TLI */
00020 }

char * ACE_OS::t_alloc ( ACE_HANDLE  fildes,
int  struct_type,
int  fields 
) [inline]

Definition at line 23 of file OS_TLI.inl.

00024 {
00025 #if defined (ACE_HAS_TLI)
00026 #  if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)
00027   // XPG5 changes t_alloc() return from char* to void*, so ACE_OSCALL_RETURN
00028   // doesn't compile correctly.
00029   char *result;
00030   ACE_OSCALL (::t_alloc (handle, struct_type, fields), char *, 0, result);
00031   return result;
00032 #  else
00033   ACE_OSCALL_RETURN (::t_alloc (handle, struct_type, fields),
00034                      char *, 0);
00035 #  endif /* XPG4 vs XPG5 */
00036 #else
00037   ACE_UNUSED_ARG (fields);
00038   ACE_UNUSED_ARG (struct_type);
00039   ACE_UNUSED_ARG (handle);
00040 
00041   ACE_NOTSUP_RETURN (0);
00042 #endif /* ACE_HAS_TLI */
00043 }

int ACE_OS::t_bind ( ACE_HANDLE  fildes,
ACE_TBIND req,
ACE_TBIND ret 
) [inline]

Definition at line 46 of file OS_TLI.inl.

00047 {
00048 #if defined (ACE_HAS_TLI)
00049   ACE_OSCALL_RETURN (::t_bind (handle, req, ret), int, -1);
00050 #else
00051   ACE_UNUSED_ARG (ret);
00052   ACE_UNUSED_ARG (req);
00053   ACE_UNUSED_ARG (handle);
00054 
00055   ACE_NOTSUP_RETURN (-1);
00056 #endif /* ACE_HAS_TLI */
00057 }

int ACE_OS::t_close ( ACE_HANDLE  fildes  )  [inline]

Definition at line 60 of file OS_TLI.inl.

00061 {
00062 #if defined (ACE_HAS_TLI)
00063   ACE_OSCALL_RETURN (::t_close (handle), int, -1);
00064 #else
00065   ACE_UNUSED_ARG (handle);
00066 
00067   ACE_NOTSUP_RETURN (-1);
00068 #endif /* ACE_HAS_TLI */
00069 }

int ACE_OS::t_connect ( ACE_HANDLE  fildes,
struct t_call *  sndcall,
struct t_call *  rcvcall 
) [inline]

Definition at line 72 of file OS_TLI.inl.

00075 {
00076 #if defined (ACE_HAS_TLI)
00077   ACE_OSCALL_RETURN (::t_connect (fildes, sndcall, rcvcall), int, -1);
00078 #else
00079   ACE_UNUSED_ARG (fildes);
00080   ACE_UNUSED_ARG (sndcall);
00081   ACE_UNUSED_ARG (rcvcall);
00082 
00083   ACE_NOTSUP_RETURN (-1);
00084 #endif /* ACE_HAS_TLI */
00085 }

void ACE_OS::t_error ( const char *  errmsg  )  [inline]

Definition at line 88 of file OS_TLI.inl.

00089 {
00090 #if defined (ACE_HAS_TLI)
00091 #if defined (ACE_HAS_BROKEN_T_ERROR)
00092   ::t_error (const_cast<char *> (errmsg));
00093 #else
00094   ::t_error (errmsg);
00095 #endif /* ACE_HAS_BROKEN_T_ERROR */
00096 #else
00097   ACE_UNUSED_ARG (errmsg);
00098 #endif /* ACE_HAS_TLI */
00099 }

int ACE_OS::t_free ( char *  ptr,
int  struct_type 
) [inline]

Definition at line 102 of file OS_TLI.inl.

00103 {
00104 #if defined (ACE_HAS_TLI)
00105   if (ptr == 0)
00106     return 0;
00107   ACE_OSCALL_RETURN (::t_free (ptr, struct_type), int, -1);
00108 #else
00109   ACE_UNUSED_ARG (struct_type);
00110   ACE_UNUSED_ARG (ptr);
00111 
00112   ACE_NOTSUP_RETURN (-1);
00113 #endif /* ACE_HAS_TLI */
00114 }

int ACE_OS::t_getinfo ( ACE_HANDLE  fildes,
struct t_info *  info 
) [inline]

Definition at line 117 of file OS_TLI.inl.

00118 {
00119 #if defined (ACE_HAS_TLI)
00120   ACE_OSCALL_RETURN (::t_getinfo (handle, info), int, -1);
00121 #else
00122   ACE_UNUSED_ARG (info);
00123   ACE_UNUSED_ARG (handle);
00124 
00125   ACE_NOTSUP_RETURN (-1);
00126 #endif /* ACE_HAS_TLI */
00127 }

int ACE_OS::t_getname ( ACE_HANDLE  fildes,
struct netbuf *  namep,
int  type 
) [inline]

Definition at line 130 of file OS_TLI.inl.

00131 {
00132 #if defined (ACE_HAS_XTI)
00133   ACE_TBIND bound, peer;
00134   // Depending on which address the caller wants, fill caller's values
00135   // into one of the t_bind netbufs. The other is set up to ignore that
00136   // address.
00137   switch (type)
00138     {
00139     case LOCALNAME:
00140       bound.addr.buf = namep->buf;
00141       bound.addr.maxlen = namep->maxlen;
00142       bound.addr.len = 0;
00143       peer.addr.buf = 0;
00144       peer.addr.maxlen = 0;
00145       peer.addr.len = 0;
00146       break;
00147     case REMOTENAME:
00148       bound.addr.buf = 0;
00149       bound.addr.maxlen = 0;
00150       bound.addr.len = 0;
00151       peer.addr.buf = namep->buf;
00152       peer.addr.maxlen = namep->maxlen;
00153       peer.addr.len = 0;
00154       break;
00155     default:
00156       ACE_OS::last_error (EINVAL);
00157       return -1;
00158     }
00159   if (t_getprotaddr (handle, &bound, &peer) == -1)
00160     return -1;
00161   // Call succeeded; put the caller's desired address length in his netbuf.
00162   if (type == LOCALNAME)
00163     namep->len = bound.addr.len;
00164   else
00165     namep->len = peer.addr.len;
00166   return 0;
00167 
00168 #elif defined (ACE_HAS_SVR4_TLI)
00169   ACE_OSCALL_RETURN (::t_getname (handle, namep, type), int, -1);
00170 #else
00171   ACE_UNUSED_ARG (handle);
00172   ACE_UNUSED_ARG (namep);
00173   ACE_UNUSED_ARG (type);
00174 
00175   ACE_NOTSUP_RETURN (-1);
00176 #endif /* ACE_HAS_SVR4_TLI */
00177 }

int ACE_OS::t_getstate ( ACE_HANDLE  fildes  )  [inline]

Definition at line 180 of file OS_TLI.inl.

00181 {
00182 #if defined (ACE_HAS_TLI)
00183   ACE_OSCALL_RETURN (::t_getstate (handle), int, -1);
00184 #else
00185   ACE_UNUSED_ARG (handle);
00186 
00187   ACE_NOTSUP_RETURN (-1);
00188 #endif /* ACE_HAS_TLI */
00189 }

int ACE_OS::t_listen ( ACE_HANDLE  fildes,
struct t_call *  call 
) [inline]

Definition at line 192 of file OS_TLI.inl.

00193 {
00194 #if defined (ACE_HAS_TLI)
00195   ACE_OSCALL_RETURN (::t_listen (handle, call), int, -1);
00196 #else
00197   ACE_UNUSED_ARG (handle);
00198   ACE_UNUSED_ARG (call);
00199 
00200   ACE_NOTSUP_RETURN (-1);
00201 #endif /* ACE_HAS_TLI */
00202 }

int ACE_OS::t_look ( ACE_HANDLE  fildes  )  [inline]

Definition at line 205 of file OS_TLI.inl.

00206 {
00207 #if defined (ACE_HAS_TLI)
00208   ACE_OSCALL_RETURN (::t_look (handle), int, -1);
00209 #else
00210   ACE_UNUSED_ARG (handle);
00211 
00212   ACE_NOTSUP_RETURN (-1);
00213 #endif /* ACE_HAS_TLI */
00214 }

ACE_HANDLE ACE_OS::t_open ( char *  path,
int  oflag,
struct t_info *  info 
) [inline]

Definition at line 217 of file OS_TLI.inl.

00218 {
00219 #if defined (ACE_HAS_TLI)
00220   ACE_OSCALL_RETURN (::t_open (path, oflag, info), ACE_HANDLE, ACE_INVALID_HANDLE);
00221 #else
00222   ACE_UNUSED_ARG (path);
00223   ACE_UNUSED_ARG (oflag);
00224   ACE_UNUSED_ARG (info);
00225 
00226   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00227 #endif /* ACE_HAS_TLI */
00228 }

int ACE_OS::t_optmgmt ( ACE_HANDLE  handle,
ACE_TOPTMGMT req,
ACE_TOPTMGMT ret 
) [inline]

Definition at line 231 of file OS_TLI.inl.

00232 {
00233 #if defined (ACE_HAS_TLI)
00234   ACE_OSCALL_RETURN (::t_optmgmt (handle, req, ret), int, -1);
00235 #else
00236   ACE_UNUSED_ARG (handle);
00237   ACE_UNUSED_ARG (req);
00238   ACE_UNUSED_ARG (ret);
00239 
00240   ACE_NOTSUP_RETURN (-1);
00241 #endif /* ACE_HAS_TLI */
00242 }

int ACE_OS::t_rcv ( ACE_HANDLE  fildes,
char *  buf,
unsigned int  nbytes,
int *  flags 
) [inline]

Definition at line 245 of file OS_TLI.inl.

00249 {
00250 #if defined (ACE_HAS_TLI)
00251   ACE_OSCALL_RETURN (::t_rcv (handle, buf, nbytes, flags),
00252                      int, -1);
00253 #else
00254   ACE_UNUSED_ARG (handle);
00255   ACE_UNUSED_ARG (buf);
00256   ACE_UNUSED_ARG (nbytes);
00257   ACE_UNUSED_ARG (flags);
00258 
00259   ACE_NOTSUP_RETURN (-1);
00260 #endif /* ACE_HAS_TLI */
00261 }

int ACE_OS::t_rcvdis ( ACE_HANDLE  fildes,
struct t_discon *  discon 
) [inline]

Definition at line 264 of file OS_TLI.inl.

00265 {
00266 #if defined (ACE_HAS_TLI)
00267   ACE_OSCALL_RETURN (::t_rcvdis (handle, discon), int, -1);
00268 #else
00269   ACE_UNUSED_ARG (handle);
00270   ACE_UNUSED_ARG (discon);
00271 
00272   ACE_NOTSUP_RETURN (-1);
00273 #endif /* ACE_HAS_TLI */
00274 }

int ACE_OS::t_rcvrel ( ACE_HANDLE  fildes  )  [inline]

Definition at line 277 of file OS_TLI.inl.

00278 {
00279 #if defined (ACE_HAS_TLI)
00280   ACE_OSCALL_RETURN (::t_rcvrel (handle), int, -1);
00281 #else
00282   ACE_UNUSED_ARG (handle);
00283 
00284   ACE_NOTSUP_RETURN (-1);
00285 #endif /* ACE_HAS_TLI */
00286 }

int ACE_OS::t_rcvudata ( ACE_HANDLE  fildes,
struct t_unitdata *  unitdata,
int *  flags 
) [inline]

Definition at line 289 of file OS_TLI.inl.

00292 {
00293 #if defined (ACE_HAS_TLI)
00294   ACE_OSCALL_RETURN (::t_rcvudata (handle, unitdata, flags),
00295                      int, -1);
00296 #else
00297   ACE_UNUSED_ARG (handle);
00298   ACE_UNUSED_ARG (unitdata);
00299   ACE_UNUSED_ARG (flags);
00300 
00301   ACE_NOTSUP_RETURN (-1);
00302 #endif /* ACE_HAS_TLI */
00303 }

int ACE_OS::t_rcvuderr ( ACE_HANDLE  fildes,
struct t_uderr *  uderr 
) [inline]

Definition at line 306 of file OS_TLI.inl.

00307 {
00308 #if defined (ACE_HAS_TLI)
00309   ACE_OSCALL_RETURN (::t_rcvuderr (handle, uderr), int, -1);
00310 #else
00311   ACE_UNUSED_ARG (handle);
00312   ACE_UNUSED_ARG (uderr);
00313 
00314   ACE_NOTSUP_RETURN (-1);
00315 #endif /* ACE_HAS_TLI */
00316 }

int ACE_OS::t_snd ( ACE_HANDLE  fildes,
const char *  buf,
unsigned int  nbytes,
int  flags 
) [inline]

Definition at line 319 of file OS_TLI.inl.

00323 {
00324 #if defined (ACE_HAS_TLI)
00325   ACE_OSCALL_RETURN (::t_snd (handle, (char *) buf, nbytes, flags), int, -1);
00326 #else
00327   ACE_UNUSED_ARG (handle);
00328   ACE_UNUSED_ARG (buf);
00329   ACE_UNUSED_ARG (nbytes);
00330   ACE_UNUSED_ARG (flags);
00331 
00332   ACE_NOTSUP_RETURN (-1);
00333 #endif /* ACE_HAS_TLI */
00334 }

int ACE_OS::t_snddis ( ACE_HANDLE  fildes,
struct t_call *  call 
) [inline]

Definition at line 337 of file OS_TLI.inl.

00338 {
00339 #if defined (ACE_HAS_TLI)
00340   ACE_OSCALL_RETURN (::t_snddis (handle, call), int, -1);
00341 #else
00342   ACE_UNUSED_ARG (handle);
00343   ACE_UNUSED_ARG (call);
00344 
00345   ACE_NOTSUP_RETURN (-1);
00346 #endif /* ACE_HAS_TLI */
00347 }

int ACE_OS::t_sndrel ( ACE_HANDLE  fildes  )  [inline]

Definition at line 350 of file OS_TLI.inl.

00351 {
00352 #if defined (ACE_HAS_TLI)
00353   ACE_OSCALL_RETURN (::t_sndrel (handle), int, -1);
00354 #else
00355   ACE_UNUSED_ARG (handle);
00356 
00357   ACE_NOTSUP_RETURN (-1);
00358 #endif /* ACE_HAS_TLI */
00359 }

int ACE_OS::t_sync ( ACE_HANDLE  fildes  )  [inline]

Definition at line 362 of file OS_TLI.inl.

00363 {
00364 #if defined (ACE_HAS_TLI)
00365   ACE_OSCALL_RETURN (::t_sync (handle), int, -1);
00366 #else
00367   ACE_UNUSED_ARG (handle);
00368 
00369   ACE_NOTSUP_RETURN (-1);
00370 #endif /* ACE_HAS_TLI */
00371 }

int ACE_OS::t_unbind ( ACE_HANDLE  fildes  )  [inline]

Definition at line 374 of file OS_TLI.inl.

00375 {
00376 #if defined (ACE_HAS_TLI)
00377   ACE_OSCALL_RETURN (::t_unbind (handle), int, -1);
00378 #else
00379   ACE_UNUSED_ARG (handle);
00380 
00381   ACE_NOTSUP_RETURN (-1);
00382 #endif /* ACE_HAS_TLI */
00383 }

long ACE_OS::telldir ( ACE_DIR d  )  [inline]

Definition at line 169 of file OS_NS_dirent.inl.

00170 {
00171 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR)
00172   return ::telldir (d);
00173 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_TELLDIR */
00174   ACE_UNUSED_ARG (d);
00175   ACE_NOTSUP_RETURN (-1);
00176 #endif /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_TELLDIR */
00177 }

wchar_t * ACE_OS::tempnam ( const wchar_t dir,
const wchar_t pfx = 0 
) [inline]

Definition at line 978 of file OS_NS_stdio.inl.

00979 {
00980   ACE_OS_TRACE ("ACE_OS::tempnam");
00981 #if defined (ACE_LACKS_TEMPNAM)
00982   ACE_UNUSED_ARG (dir);
00983   ACE_UNUSED_ARG (pfx);
00984   ACE_NOTSUP_RETURN (0);
00985 #elif defined(ACE_WIN32)
00986 #  if defined (ACE_HAS_NONCONST_TEMPNAM)
00987   ACE_OSCALL_RETURN (::_wtempnam (const_cast <wchar_t*> (dir), const_cast <wchar_t*> (pfx)), wchar_t *, 0);
00988 #  else
00989   ACE_OSCALL_RETURN (::_wtempnam (dir, pfx), wchar_t *, 0);
00990 #  endif /* ACE_HAS_NONCONST_TEMPNAM */
00991 #else /* ACE_LACKS_TEMPNAM */
00992   // No native wide-char support; convert to narrow and call the char* variant.
00993   char *ndir = ACE_Wide_To_Ascii (dir).char_rep ();
00994   char *npfx = ACE_Wide_To_Ascii (pfx).char_rep ();
00995   char *name = ACE_OS::tempnam (ndir, npfx);
00996   // ACE_OS::tempnam returns a pointer to a malloc()-allocated space.
00997   // Convert that string to wide-char and free() the original.
00998   wchar_t *wname = 0;
00999   if (name != 0)
01000     {
01001       size_t namelen = ACE_OS::strlen (name) + 1;
01002       wname = reinterpret_cast<wchar_t *>
01003         (ACE_OS::malloc (namelen * sizeof (wchar_t)));
01004       if (wname != 0)
01005         ACE_OS::strcpy (wname, ACE_Ascii_To_Wide (name).wchar_rep ());
01006       ACE_OS::free (name);
01007     }
01008   return wname;
01009 #endif /* ACE_LACKS_TEMPNAM */
01010 }

char * ACE_OS::tempnam ( const char *  dir = 0,
const char *  pfx = 0 
) [inline]

Definition at line 960 of file OS_NS_stdio.inl.

00961 {
00962   ACE_OS_TRACE ("ACE_OS::tempnam");
00963 #if defined (ACE_LACKS_TEMPNAM)
00964   ACE_UNUSED_ARG (dir);
00965   ACE_UNUSED_ARG (pfx);
00966   ACE_NOTSUP_RETURN (0);
00967 #elif defined (ACE_HAS_NONCONST_TEMPNAM)
00968   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast <char *> (dir), const_cast<char *> (pfx)), char *, 0);
00969 #elif defined (ACE_TEMPNAM_EQUIVALENT)
00970   ACE_OSCALL_RETURN (ACE_TEMPNAM_EQUIVALENT (dir, pfx), char *, 0);
00971 #else /* ACE_LACKS_TEMPNAM */
00972   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0);
00973 #endif /* ACE_LACKS_TEMPNAM */
00974 }

int ACE_OS::thr_cancel ( ACE_thread_t  t_id  )  [inline]

Definition at line 2754 of file OS_NS_Thread.inl.

02755 {
02756   ACE_OS_TRACE ("ACE_OS::thr_cancel");
02757 #if defined (ACE_HAS_THREADS)
02758 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02759   int result;
02760   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02761                                         result),
02762                       int, -1);
02763 # elif defined (ACE_HAS_VXTHREADS)
02764   ACE_OSCALL_RETURN (::taskDelete (thr_id), int, -1);
02765 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
02766   ACE_UNUSED_ARG (thr_id);
02767   ACE_NOTSUP_RETURN (-1);
02768 # endif /* ACE_HAS_PTHREADS */
02769 #else
02770   ACE_UNUSED_ARG (thr_id);
02771   ACE_NOTSUP_RETURN (-1);
02772 #endif /* ACE_HAS_THREADS */
02773 }

int ACE_OS::thr_cmp ( ACE_hthread_t  t1,
ACE_hthread_t  t2 
) [inline]

Definition at line 2776 of file OS_NS_Thread.inl.

02777 {
02778 #if defined (ACE_HAS_PTHREADS)
02779 # if defined (pthread_equal)
02780   // If it's a macro we can't say "pthread_equal"...
02781   return pthread_equal (t1, t2);
02782 # else
02783   return pthread_equal (t1, t2);
02784 # endif /* pthread_equal */
02785 #else /* For STHREADS, WTHREADS, and VXWORKS ... */
02786   // Hum, Do we need to treat WTHREAD differently?
02787   // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE.
02788   return t1 == t2;
02789 #endif /* ACE_HAS_PTHREADS */
02790 }

int ACE_OS::thr_continue ( ACE_hthread_t  target_thread  )  [inline]

Definition at line 2793 of file OS_NS_Thread.inl.

02794 {
02795   ACE_OS_TRACE ("ACE_OS::thr_continue");
02796 #if defined (ACE_HAS_THREADS)
02797 # if defined (ACE_HAS_STHREADS)
02798   int result;
02799   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), result), int, -1);
02800 # elif defined (ACE_HAS_PTHREADS)
02801 #  if defined (ACE_HAS_PTHREAD_CONTINUE)
02802   int result;
02803   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread),
02804                                        result),
02805                      int, -1);
02806 #  elif defined (ACE_HAS_PTHREAD_CONTINUE_NP)
02807   int result;
02808   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue_np (target_thread),
02809                                        result),
02810                      int, -1);
02811 #  elif defined (ACE_HAS_PTHREAD_RESUME_NP)
02812   int result;
02813   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_resume_np (target_thread),
02814                                        result),
02815                      int, -1);
02816 #  else
02817   ACE_UNUSED_ARG (target_thread);
02818   ACE_NOTSUP_RETURN (-1);
02819 #  endif /* ACE_HAS_PTHREAD_CONTINUE */
02820 # elif defined (ACE_HAS_WTHREADS)
02821   DWORD result = ::ResumeThread (target_thread);
02822   if (result == ACE_SYSCALL_FAILED)
02823     ACE_FAIL_RETURN (-1);
02824   else
02825     return 0;
02826 # elif defined (ACE_HAS_VXTHREADS)
02827   ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1);
02828 # endif /* ACE_HAS_STHREADS */
02829 #else
02830   ACE_UNUSED_ARG (target_thread);
02831   ACE_NOTSUP_RETURN (-1);
02832 #endif /* ACE_HAS_THREADS */
02833 }

int ACE_OS::thr_create ( ACE_THR_FUNC  func,
void *  args,
long  flags,
ACE_thread_t thr_id,
ACE_hthread_t t_handle = 0,
long  priority = ACE_DEFAULT_THREAD_PRIORITY,
void *  stack = 0,
size_t  stacksize = ACE_DEFAULT_THREAD_STACKSIZE,
ACE_Base_Thread_Adapter thread_adapter = 0,
const char **  thr_name = 0 
)

Creates a new thread having flags attributes and running func with args (if thread_adapter is non-0 then func and args are ignored and are obtained from thread_adapter). thr_id and t_handle are set to the thread's ID and handle (?), respectively. The thread runs at priority priority (see below).

The flags are a bitwise-OR of the following: = BEGIN<INDENT> THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS = END<INDENT>

By default, or if priority is set to ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for the given scheduling policy (specified in flags, e.g., THR_SCHED_DEFAULT) is used. This value is calculated dynamically, and is the median value between the minimum and maximum priority values for the given policy. If an explicit value is given, it is used. Note that actual priority values are EXTREMEMLY implementation-dependent, and are probably best avoided.

Note that thread_adapter is always deleted by thr_create, therefore it must be allocated with global operator new.

At the moment for thr_name a valid string is passed then this will be used on VxWorks to set the task name. If we just pass a pointer the name of the task is returned

Definition at line 3513 of file OS_NS_Thread.cpp.

03523 {
03524   ACE_OS_TRACE ("ACE_OS::thr_create");
03525 
03526   if (ACE_BIT_DISABLED (flags, THR_DETACHED) &&
03527       ACE_BIT_DISABLED (flags, THR_JOINABLE))
03528     ACE_SET_BITS (flags, THR_JOINABLE);
03529 
03530 #if defined (ACE_NO_THREAD_ADAPTER)
03531 # define  ACE_THREAD_FUNCTION  func
03532 # define  ACE_THREAD_ARGUMENT  args
03533 #else /* ! defined (ACE_NO_THREAD_ADAPTER) */
03534 # define  ACE_THREAD_FUNCTION  thread_args->entry_point ()
03535 # define  ACE_THREAD_ARGUMENT  thread_args
03536 #endif /* ! defined (ACE_NO_THREAD_ADAPTER) */
03537 
03538   ACE_Base_Thread_Adapter *thread_args = 0;
03539   if (thread_adapter == 0)
03540 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
03541     ACE_NEW_RETURN (thread_args,
03542                     ACE_OS_Thread_Adapter (func, args,
03543                                            (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
03544                                            ACE_OS_Object_Manager::seh_except_selector(),
03545                                            ACE_OS_Object_Manager::seh_except_handler(),
03546                                            flags),
03547                     -1);
03548 #else
03549   ACE_NEW_RETURN (thread_args,
03550                   ACE_OS_Thread_Adapter (func, args,
03551                                          (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
03552                                          flags),
03553                   -1);
03554 
03555 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
03556   else
03557     thread_args = thread_adapter;
03558 
03559 #if defined (ACE_HAS_CPP11)
03560   std::unique_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
03561 #else
03562   auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
03563 #endif /* ACE_HAS_CPP11 */
03564 
03565   if (thread_adapter == 0)
03566     ACE_auto_ptr_reset (auto_thread_args,
03567                         thread_args);
03568 
03569 #if defined (ACE_HAS_THREADS)
03570 
03571   // *** Set Stack Size
03572 # if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03573   if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03574     stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE;
03575 # endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
03576 
03577   ACE_thread_t tmp_thr;
03578   if (thr_id == 0)
03579     thr_id = &tmp_thr;
03580 
03581   ACE_hthread_t tmp_handle;
03582   if (thr_handle == 0)
03583     thr_handle = &tmp_handle;
03584 
03585 # if defined (ACE_HAS_PTHREADS)
03586   int result;
03587 # if defined (ACE_PTHREAD_ATTR_T_INITIALIZE)
03588   /* Tests show that VxWorks 6.x pthread lib does not only
03589    * require zeroing of mutex/condition objects to function correctly
03590    * but also of the attribute objects.
03591    */
03592   pthread_attr_t attr = {0};
03593 #   else
03594   pthread_attr_t attr;
03595 #   endif
03596   if (ACE_ADAPT_RETVAL(::pthread_attr_init(&attr), result) != 0)
03597     return -1;
03598 
03599   if (stacksize != 0)
03600     {
03601       size_t size = stacksize;
03602 
03603 #   if defined (PTHREAD_STACK_MIN)
03604       if (size < static_cast <size_t> (PTHREAD_STACK_MIN))
03605         size = PTHREAD_STACK_MIN;
03606 #   endif /* PTHREAD_STACK_MIN */
03607 
03608 #   if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE)
03609 #     if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
03610       int result;
03611       if (stack != 0)
03612         result = ACE_ADAPT_RETVAL (pthread_attr_setstack (&attr, stack, size), result);
03613       else
03614         result = ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result);
03615       if (result == -1)
03616 #     else
03617       if (ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result) == -1)
03618 #     endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACK */
03619         {
03620           ::pthread_attr_destroy (&attr);
03621           return -1;
03622         }
03623 #   else
03624       ACE_UNUSED_ARG (size);
03625 #   endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE */
03626     }
03627 
03628   // *** Set Stack Address
03629 #   if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
03630 #     if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR)
03631   if (stack != 0)
03632     {
03633       if (ACE_ADAPT_RETVAL(::pthread_attr_setstackaddr (&attr, stack), result) != 0)
03634         {
03635           ::pthread_attr_destroy (&attr);
03636           return -1;
03637         }
03638     }
03639 #     else
03640   ACE_UNUSED_ARG (stack);
03641 #     endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR */
03642 #   endif /* ACE_LACKS_PTHREAD_ATTR_SETSTACK */
03643 
03644   // *** Deal with various attributes
03645   if (flags != 0)
03646     {
03647       // *** Set Detach state
03648 #   if !defined (ACE_LACKS_SETDETACH)
03649       if (ACE_BIT_ENABLED (flags, THR_DETACHED)
03650           || ACE_BIT_ENABLED (flags, THR_JOINABLE))
03651         {
03652           int dstate = PTHREAD_CREATE_JOINABLE;
03653 
03654           if (ACE_BIT_ENABLED (flags, THR_DETACHED))
03655             dstate = PTHREAD_CREATE_DETACHED;
03656 
03657           if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate),
03658                                result) != 0)
03659             {
03660               ::pthread_attr_destroy (&attr);
03661               return -1;
03662             }
03663         }
03664 
03665       // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we
03666       // call ::pthread_detach () below.  If THR_DETACHED is not
03667       // enabled, we call ::pthread_detach () in the Thread_Manager,
03668       // after joining with the thread.
03669 #   endif /* ACE_LACKS_SETDETACH */
03670 
03671       // *** Set Policy
03672 #   if !defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
03673       // If we wish to set the priority explicitly, we have to enable
03674       // explicit scheduling, and a policy, too.
03675       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03676         {
03677           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
03678           if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO)
03679               && ACE_BIT_DISABLED (flags, THR_SCHED_RR)
03680               && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT))
03681             ACE_SET_BITS (flags, THR_SCHED_DEFAULT);
03682         }
03683 
03684       if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
03685           || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
03686           || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
03687         {
03688           int spolicy;
03689 
03690 #     if defined (ACE_HAS_ONLY_SCHED_OTHER)
03691           // SunOS, thru version 5.6, only supports SCHED_OTHER.
03692           spolicy = SCHED_OTHER;
03693 #     elif defined (ACE_HAS_ONLY_SCHED_FIFO)
03694           // NonStop OSS standard pthread supports only SCHED_FIFO.
03695           spolicy = SCHED_FIFO;
03696 #     else
03697           // Make sure to enable explicit scheduling, in case we didn't
03698           // enable it above (for non-default priority).
03699           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
03700 
03701           if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
03702             spolicy = SCHED_OTHER;
03703           else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
03704             spolicy = SCHED_FIFO;
03705 #       if defined (SCHED_IO)
03706           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
03707             spolicy = SCHED_IO;
03708 #       else
03709           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
03710             {
03711               errno = ENOSYS;
03712               return -1;
03713             }
03714 #       endif /* SCHED_IO */
03715           else
03716             spolicy = SCHED_RR;
03717 
03718 #     endif /* ACE_HAS_ONLY_SCHED_OTHER */
03719 
03720           (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy),
03721                            result);
03722           if (result != 0)
03723             {
03724               ::pthread_attr_destroy (&attr);
03725               return -1;
03726             }
03727         }
03728 
03729       // *** Set Priority (use reasonable default priorities)
03730 #     if defined(ACE_HAS_PTHREADS)
03731       // If we wish to explicitly set a scheduling policy, we also
03732       // have to specify a priority.  We choose a "middle" priority as
03733       // default.  Maybe this is also necessary on other POSIX'ish
03734       // implementations?
03735       if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
03736            || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
03737            || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
03738           && priority == ACE_DEFAULT_THREAD_PRIORITY)
03739         {
03740           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
03741             priority = ACE_THR_PRI_FIFO_DEF;
03742           else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR))
03743             priority = ACE_THR_PRI_RR_DEF;
03744           else // THR_SCHED_DEFAULT
03745             priority = ACE_THR_PRI_OTHER_DEF;
03746         }
03747 #     endif /* ACE_HAS_PTHREADS */
03748       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03749         {
03750           struct sched_param sparam;
03751           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
03752 
03753 #     if defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS)
03754           /* For MIT pthreads... */
03755           sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY);
03756 #     elif defined(ACE_HAS_PTHREADS) && !defined (ACE_HAS_STHREADS)
03757           // The following code forces priority into range.
03758           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
03759             sparam.sched_priority =
03760               ACE_MIN (ACE_THR_PRI_FIFO_MAX,
03761                        ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
03762           else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
03763             sparam.sched_priority =
03764               ACE_MIN (ACE_THR_PRI_RR_MAX,
03765                        ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
03766           else // Default policy, whether set or not
03767             sparam.sched_priority =
03768               ACE_MIN (ACE_THR_PRI_OTHER_MAX,
03769                        ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
03770 #     elif defined (PRIORITY_MAX)
03771           sparam.sched_priority = ACE_MIN (priority,
03772                                            (long) PRIORITY_MAX);
03773 #     else
03774           sparam.sched_priority = priority;
03775 #     endif /*  PTHREAD_MAX_PRIORITY */
03776 
03777           {
03778 #       if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
03779             // SunOS, through 5.6, POSIX only allows priorities > 0 to
03780             // ::pthread_attr_setschedparam.  If a priority of 0 was
03781             // requested, set the thread priority after creating it, below.
03782             if (priority > 0)
03783 #       endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
03784               {
03785                 (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam),
03786                                         result);
03787                 if (result != 0)
03788                   {
03789                     ::pthread_attr_destroy (&attr);
03790                     return -1;
03791                   }
03792               }
03793           }
03794         }
03795 
03796 #       if !defined (ACE_LACKS_SETINHERITSCHED)
03797       // *** Set scheduling explicit or inherited
03798       if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)
03799           || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED))
03800         {
03801           int sched = PTHREAD_EXPLICIT_SCHED;
03802           if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED))
03803             sched = PTHREAD_INHERIT_SCHED;
03804           if (ACE_ADAPT_RETVAL(::pthread_attr_setinheritsched (&attr, sched), result) != 0)
03805             {
03806               ::pthread_attr_destroy (&attr);
03807               return -1;
03808             }
03809         }
03810 #       endif /* ACE_LACKS_SETINHERITSCHED */
03811 #   else /* ACE_LACKS_SETSCHED */
03812       ACE_UNUSED_ARG (priority);
03813 #   endif /* ACE_LACKS_SETSCHED */
03814 
03815   // *** Set pthread name
03816 #   if defined (ACE_HAS_PTHREAD_ATTR_SETNAME)
03817   if (thr_name && *thr_name)
03818     {
03819       if (ACE_ADAPT_RETVAL(::pthread_attr_setname (&attr, const_cast<char*>(*thr_name)), result) != 0)
03820         {
03821           ::pthread_attr_destroy (&attr);
03822           return -1;
03823         }
03824     }
03825 #else
03826   ACE_UNUSED_ARG (thr_name);
03827 #   endif
03828 
03829       // *** Set Scope
03830 #   if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING)
03831       if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)
03832           || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS))
03833         {
03834 #     if defined (ACE_LACKS_PTHREAD_SCOPE_PROCESS)
03835           int scope = PTHREAD_SCOPE_SYSTEM;
03836 #     else /* ACE_LACKS_PTHREAD_SCOPE_PROCESS */
03837           int scope = PTHREAD_SCOPE_PROCESS;
03838 #     endif /* ACE_LACKS_PTHREAD_SCOPE_PROCESS */
03839           if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM))
03840             scope = PTHREAD_SCOPE_SYSTEM;
03841 
03842           if (ACE_ADAPT_RETVAL(::pthread_attr_setscope (&attr, scope), result) != 0)
03843             {
03844               ::pthread_attr_destroy (&attr);
03845               return -1;
03846             }
03847         }
03848 #   endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */
03849 
03850 #   ifdef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP
03851       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED))
03852         {
03853            if (ACE_ADAPT_RETVAL(::pthread_attr_setcreatesuspend_np(&attr), result) != 0)
03854             {
03855 
03856               ::pthread_attr_destroy (&attr);
03857               return -1;
03858             }
03859         }
03860 #   endif /* !ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP */
03861 
03862 #   if ! defined(ACE_LACKS_THR_CONCURRENCY_FUNCS)
03863       if (ACE_BIT_ENABLED (flags, THR_NEW_LWP))
03864         {
03865           // Increment the number of LWPs by one to emulate the
03866           // SunOS semantics.
03867           int lwps = ACE_OS::thr_getconcurrency ();
03868           if (lwps == -1)
03869             {
03870               if (errno == ENOTSUP)
03871                 // Suppress the ENOTSUP because it's harmless.
03872                 errno = 0;
03873               else
03874                 // This should never happen on SunOS:
03875                 // ::thr_getconcurrency () should always succeed.
03876                 return -1;
03877             }
03878           else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1)
03879             {
03880               if (errno == ENOTSUP)
03881                 {
03882                   // Unlikely: ::thr_getconcurrency () is supported
03883                   // but ::thr_setconcurrency () is not?
03884                 }
03885               else
03886                 return -1;
03887             }
03888         }
03889 #   endif /* ! ACE_LACKS_THR_CONCURRENCY_FUNCS */
03890     }
03891 
03892   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id,
03893                                                   &attr,
03894                                                   thread_args->entry_point (),
03895                                                   thread_args),
03896                                 result),
03897               int, -1, result);
03898   ::pthread_attr_destroy (&attr);
03899 
03900   // This is a SunOS or POSIX implementation of pthreads, where we
03901   // assume that ACE_thread_t and ACE_hthread_t are the same.  If this
03902   // *isn't* correct on some platform, please let us know.
03903   if (result != -1)
03904     *thr_handle = *thr_id;
03905 
03906 #   if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
03907   // SunOS prior to 5.7:
03908 
03909   // If the priority is 0, then we might have to set it now because we
03910   // couldn't set it with ::pthread_attr_setschedparam, as noted
03911   // above.  This doesn't provide strictly correct behavior, because
03912   // the thread was created (above) with the priority of its parent.
03913   // (That applies regardless of the inherit_sched attribute: if it
03914   // was PTHREAD_INHERIT_SCHED, then it certainly inherited its
03915   // parent's priority.  If it was PTHREAD_EXPLICIT_SCHED, then "attr"
03916   // was initialized by the SunOS ::pthread_attr_init () to contain
03917   // NULL for the priority, which indicated to SunOS ::pthread_create
03918   // () to inherit the parent priority.)
03919   if (priority == 0)
03920     {
03921       // Check the priority of this thread, which is the parent
03922       // of the newly created thread.  If it is 0, then the
03923       // newly created thread will have inherited the priority
03924       // of 0, so there's no need to explicitly set it.
03925       struct sched_param sparam;
03926       int policy = 0;
03927       ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (),
03928                                                              &policy,
03929                                                              &sparam),
03930                                     result), int,
03931                   -1, result);
03932 
03933       // The only policy supported by by SunOS, thru version 5.6,
03934       // is SCHED_OTHER, so that's hard-coded here.
03935       policy = ACE_SCHED_OTHER;
03936 
03937       if (sparam.sched_priority != 0)
03938         {
03939           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
03940           // The memset to 0 sets the priority to 0, so we don't need
03941           // to explicitly set sparam.sched_priority.
03942 
03943           ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id,
03944                                                                         policy,
03945                                                                         &sparam),
03946                                                result),
03947                              int, -1);
03948         }
03949     }
03950 
03951 #     if defined (ACE_NEEDS_LWP_PRIO_SET)
03952 #       if 0
03953   // It would be useful if we could make this work.  But, it requires
03954   // a mechanism for determining the ID of an LWP to which another
03955   // thread is bound.  Is there a way to do that?  Instead, just rely
03956   // on the code in ACE_Thread_Adapter::invoke () to set the LWP
03957   // priority.
03958 
03959   // If the thread is bound, then set the priority on its LWP.
03960   if (ACE_BIT_ENABLED (flags, THR_BOUND))
03961     {
03962       ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) ||
03963                                      ACE_BIT_ENABLED (flags, THR_SCHED_RR)  ?
03964                                      ACE_SCHED_FIFO  :
03965                                      ACE_SCHED_OTHER,
03966                                      priority);
03967       result = ACE_OS::lwp_setparams (sched_params,
03968                                       /* ? How do we find the ID of the LWP
03969                                          to which *thr_id is bound? */);
03970     }
03971 #       endif /* 0 */
03972 #     endif /* ACE_NEEDS_LWP_PRIO_SET */
03973 
03974 #   endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
03975   auto_thread_args.release ();
03976   return result;
03977 # elif defined (ACE_HAS_STHREADS)
03978   int result;
03979   int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
03980 
03981   if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03982     // If we need to set the priority, then we need to start the
03983     // thread in a suspended mode.
03984     ACE_SET_BITS (flags, THR_SUSPENDED);
03985 
03986   ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize,
03987                                               thread_args->entry_point (),
03988                                               thread_args,
03989                                               flags, thr_id), result),
03990               int, -1, result);
03991 
03992   if (result != -1)
03993     {
03994       // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same.
03995       *thr_handle = *thr_id;
03996 
03997       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03998         {
03999           // Set the priority of the new thread and then let it
04000           // continue, but only if the user didn't start it suspended
04001           // in the first place!
04002           result = ACE_OS::thr_setprio (*thr_id, priority);
04003           if (result != 0)
04004             {
04005               errno = result;
04006               return -1;
04007             }
04008 
04009           if (start_suspended == 0)
04010             {
04011               result = ACE_OS::thr_continue (*thr_id);
04012               if (result != 0)
04013                 {
04014                   errno = result;
04015                   return -1;
04016                 }
04017             }
04018         }
04019     }
04020   auto_thread_args.release ();
04021   return result;
04022 # elif defined (ACE_HAS_WTHREADS)
04023   ACE_UNUSED_ARG (thr_name);
04024   ACE_UNUSED_ARG (stack);
04025 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04026   if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
04027     {
04028       CWinThread *cwin_thread =
04029         ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (),
04030                           thread_args,
04031                           priority,
04032                           0,
04033                           flags | THR_SUSPENDED);
04034       // Have to duplicate the handle because
04035       // CWinThread::~CWinThread() closes the original handle.
04036 #     if !defined (ACE_HAS_WINCE)
04037       (void) ::DuplicateHandle (::GetCurrentProcess (),
04038                                 cwin_thread->m_hThread,
04039                                 ::GetCurrentProcess (),
04040                                 thr_handle,
04041                                 0,
04042                                 TRUE,
04043                                 DUPLICATE_SAME_ACCESS);
04044 #     endif /* ! ACE_HAS_WINCE */
04045       *thr_id = cwin_thread->m_nThreadID;
04046 
04047       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0)
04048         cwin_thread->ResumeThread ();
04049       // cwin_thread will be deleted in AfxThreadExit()
04050       // Warning: If AfxThreadExit() is called from within the
04051       // thread, ACE_TSS_Cleanup->thread_exit() never gets called !
04052     }
04053   else
04054 #   endif /* ACE_HAS_MFC */
04055     {
04056       int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04057 
04058       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04059         // If we need to set the priority, then we need to start the
04060         // thread in a suspended mode.
04061         ACE_SET_BITS (flags, THR_SUSPENDED);
04062 
04063       *thr_handle = (void *) ACE_BEGINTHREADEX (0,
04064                                                 static_cast <u_int> (stacksize),
04065                                                 thread_args->entry_point (),
04066                                                 thread_args,
04067                                                 flags,
04068                                                 thr_id);
04069 
04070       if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
04071         {
04072           // Set the priority of the new thread and then let it
04073           // continue, but only if the user didn't start it suspended
04074           // in the first place!
04075           if (ACE_OS::thr_setprio (*thr_handle, priority) != 0)
04076             {
04077               return -1;
04078             }
04079 
04080           if (start_suspended == 0)
04081             {
04082               ACE_OS::thr_continue (*thr_handle);
04083             }
04084         }
04085     }
04086 #   if 0
04087   *thr_handle = ::CreateThread
04088     (0,
04089      stacksize,
04090      LPTHREAD_START_ROUTINE (thread_args->entry_point ()),
04091      thread_args,
04092      flags,
04093      thr_id);
04094 #   endif /* 0 */
04095 
04096   // Close down the handle if no one wants to use it.
04097   if (thr_handle == &tmp_handle && tmp_handle != 0)
04098     ::CloseHandle (tmp_handle);
04099 
04100   if (*thr_handle != 0)
04101     {
04102       auto_thread_args.release ();
04103       return 0;
04104     }
04105   else
04106     ACE_FAIL_RETURN (-1);
04107   /* NOTREACHED */
04108 
04109 # elif defined (ACE_VXWORKS)
04110   // The hard-coded values below are what ::sp () would use.  (::sp ()
04111   // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to
04112   // 20,000.)  stacksize should be an even integer.  If a stack is not
04113   // specified, ::taskSpawn () is used so that we can set the
04114   // priority, flags, and stacksize.  If a stack is specified,
04115   // ::taskInit ()/::taskActivate() are used.
04116 
04117   // If called with thr_create() defaults, use same default values as ::sp ():
04118   if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100;
04119   // Assumes that there is a floating point coprocessor.  As noted
04120   // above, ::sp () hardcodes this, so we should be safe with it.
04121   if (flags == 0) flags = VX_FP_TASK;
04122   if (stacksize == 0) stacksize = 20000;
04123 
04124   ACE_thread_t tid;
04125 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04126   if (stack == 0)
04127     {
04128 #   else
04129       ACE_UNUSED_ARG (stack);
04130 #   endif /* 0 */
04131       // The call below to ::taskSpawn () causes VxWorks to assign a
04132       // unique task name of the form: "t" + an integer, because the
04133       // first argument is 0.
04134       tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0,
04135                          priority,
04136                          (int) flags,
04137                          stacksize,
04138                          thread_args->entry_point (),
04139                          (ACE_VX_USR_ARG_T) thread_args,
04140                          0, 0, 0, 0, 0, 0, 0, 0, 0);
04141 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04142     }
04143   else
04144     {
04145       // If a task name (thr_id) was not supplied, then the task will
04146       // not have a unique name.  That's VxWorks' behavior.
04147 
04148       // Carve out a TCB at the beginning of the stack space.  The TCB
04149       // occupies 400 bytes with VxWorks 5.3.1/I386.
04150       WIND_TCB *tcb = (WIND_TCB *) stack;
04151 
04152       // The TID is defined to be the address of the TCB.
04153       int status = ::taskInit (tcb,
04154                                thr_name && *thr_name ? const_cast <char*>(*thr_name) : 0,
04155                                priority,
04156                                (int) flags,
04157                                (char *) stack + sizeof (WIND_TCB),
04158                                (int) (stacksize - sizeof (WIND_TCB)),
04159                                thread_args->entry_point (),
04160                                (int) thread_args,
04161                                0, 0, 0, 0, 0, 0, 0, 0, 0);
04162 
04163       if (status == OK)
04164         {
04165           // The task was successfully initialized, now activate it.
04166           status = ::taskActivate ((ACE_hthread_t) tcb);
04167         }
04168 
04169       tid = status == OK  ? (ACE_thread_t) tcb  :  ERROR;
04170     }
04171 #   endif /* 0 */
04172 
04173   if (tid == ACE_VX_TASK_ID_ERROR)
04174     return -1;
04175   else
04176     {
04177       if (thr_id)
04178         *thr_id = tid;
04179 
04180       if (thr_handle)
04181         *thr_handle = tid;
04182 
04183       if (thr_name && !(*thr_name))
04184         *thr_name = ::taskName (tid);
04185 
04186       auto_thread_args.release ();
04187       return 0;
04188     }
04189 
04190 # endif /* ACE_HAS_STHREADS */
04191 #else
04192   ACE_UNUSED_ARG (func);
04193   ACE_UNUSED_ARG (args);
04194   ACE_UNUSED_ARG (flags);
04195   ACE_UNUSED_ARG (thr_id);
04196   ACE_UNUSED_ARG (thr_handle);
04197   ACE_UNUSED_ARG (priority);
04198   ACE_UNUSED_ARG (stack);
04199   ACE_UNUSED_ARG (stacksize);
04200   ACE_UNUSED_ARG (thr_name);
04201   ACE_NOTSUP_RETURN (-1);
04202 #endif /* ACE_HAS_THREADS */
04203 }

int ACE_OS::thr_equal ( ACE_thread_t  t1,
ACE_thread_t  t2 
) [inline]

Definition at line 106 of file OS_NS_Thread.inl.

00107 {
00108 #if defined (ACE_HAS_PTHREADS)
00109 # if defined (pthread_equal)
00110   // If it's a macro we can't say "pthread_equal"...
00111   return pthread_equal (t1, t2);
00112 # else
00113   return pthread_equal (t1, t2);
00114 # endif /* pthread_equal */
00115 #else /* For both STHREADS and WTHREADS... */
00116   // Hum, Do we need to treat WTHREAD differently?
00117   // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD.
00118   return t1 == t2;
00119 #endif /* ACE_HAS_PTHREADS */
00120 }

void ACE_OS::thr_exit ( ACE_THR_FUNC_RETURN  status = 0  ) 

Definition at line 4206 of file OS_NS_Thread.cpp.

04207 {
04208   ACE_OS_TRACE ("ACE_OS::thr_exit");
04209 #if defined (ACE_HAS_THREADS)
04210 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_EXIT)
04211     ::pthread_exit (status);
04212 # elif defined (ACE_HAS_STHREADS)
04213     ::thr_exit (status);
04214 # elif defined (ACE_HAS_WTHREADS)
04215     // Can't call it here because on NT, the thread is exited
04216     // directly by ACE_Thread_Adapter::invoke ().
04217     //   ACE_TSS_Cleanup::instance ()->thread_exit (status);
04218 
04219 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04220     int using_afx = -1;
04221     // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor.
04222     // But without #including ace/Thread_Manager.h, we don't know that.
04223     ACE_OS_Thread_Descriptor *td =
04224       ACE_Base_Thread_Adapter::thr_desc_log_msg ();
04225     if (td)
04226       using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX);
04227 #   endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
04228 
04229     // Call TSS destructors.
04230     ACE_OS::cleanup_tss (0 /* not main thread */);
04231 
04232     // Exit the thread.
04233     // Allow CWinThread-destructor to be invoked from AfxEndThread.
04234     // _endthreadex will be called from AfxEndThread so don't exit the
04235     // thread now if we are running an MFC thread.
04236 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04237     if (using_afx != -1)
04238       {
04239         if (using_afx)
04240           ::AfxEndThread (status);
04241         else
04242           ACE_ENDTHREADEX (status);
04243       }
04244     else
04245       {
04246         // Not spawned by ACE_Thread_Manager, use the old buggy
04247         // version.  You should seriously consider using
04248         // ACE_Thread_Manager to spawn threads.  The following code is
04249         // know to cause some problem.
04250         CWinThread *pThread = ::AfxGetThread ();
04251         if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
04252           ACE_ENDTHREADEX (status);
04253         else
04254           ::AfxEndThread (status);
04255       }
04256 #   else
04257     ACE_ENDTHREADEX (status);
04258 #   endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
04259 
04260 # elif defined (ACE_HAS_VXTHREADS)
04261     ACE_UNUSED_ARG (status);
04262     ::taskDelete (ACE_OS::thr_self ());
04263 # else
04264     ACE_UNUSED_ARG (status);
04265 # endif /* ACE_HAS_PTHREADS */
04266 #else
04267   ACE_UNUSED_ARG (status);
04268 #endif /* ACE_HAS_THREADS */
04269 }

int ACE_OS::thr_get_affinity ( ACE_hthread_t  thr_id,
size_t  cpu_set_size,
cpu_set_t cpu_mask 
)

Get the thread affinity

Parameters:
thr_id For NPTL-threads, when ACE_HAS_PTHREAD_SETAFFINITY_NP defined, this is the thread-id. For linux-threads, when ACE_HAS_SCHED_SETAFFINITY defined, it expects a process-id. Since for linux-threads a thread is seen as a process, it does the job.
cpu_set_size The size of the cpu_mask, in bytes.
cpu_mask Is a bitmask of CPUs to bind to, e.g value 1 binds the thread to the "CPU 0", etc

Definition at line 4356 of file OS_NS_Thread.cpp.

04359 {
04360 #if defined (ACE_HAS_PTHREAD_GETAFFINITY_NP)
04361   // Handle of the thread, which is NPTL thread-id, normally a big number
04362   if (::pthread_getaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
04363     {
04364       return -1;
04365     }
04366   return 0;
04367 #elif defined (ACE_HAS_2_PARAM_SCHED_GETAFFINITY)
04368   // The process-id is expected as <thr_id>, which can be a thread-id of
04369   // linux-thread, thus making binding to cpu of that particular thread only.
04370   // If you are using this flag for NPTL-threads, however, please pass as a
04371   // thr_id process id obtained by ACE_OS::getpid ()
04372   ACE_UNUSED_ARG (cpu_set_size);
04373   if (::sched_getaffinity(thr_id, cpu_mask) == -1)
04374     {
04375       return -1;
04376     }
04377   return 0;
04378 #elif defined (ACE_HAS_SCHED_GETAFFINITY)
04379   // The process-id is expected as <thr_id>, which can be a thread-id of
04380   // linux-thread, thus making binding to cpu of that particular thread only.
04381   // If you are using this flag for NPTL-threads, however, please pass as a
04382   // thr_id process id obtained by ACE_OS::getpid ()
04383   if (::sched_getaffinity(thr_id, cpu_set_size, cpu_mask) == -1)
04384     {
04385       return -1;
04386     }
04387   return 0;
04388 #elif defined (ACE_HAS_TASKCPUAFFINITYSET)
04389   ACE_UNUSED_ARG (cpu_set_size);
04390   int result = 0;
04391   if (ACE_ADAPT_RETVAL (::taskCpuAffinitySet (thr_id, *cpu_mask), result) == -1)
04392     {
04393       return -1;
04394     }
04395   return 0;
04396 #else
04397   ACE_UNUSED_ARG (thr_id);
04398   ACE_UNUSED_ARG (cpu_set_size);
04399   ACE_UNUSED_ARG (cpu_mask);
04400   ACE_NOTSUP_RETURN (-1);
04401 #endif
04402 }

int ACE_OS::thr_getconcurrency ( void   )  [inline]

Definition at line 2836 of file OS_NS_Thread.inl.

02837 {
02838   ACE_OS_TRACE ("ACE_OS::thr_getconcurrency");
02839 #if defined (ACE_HAS_THREADS)
02840 # if defined (ACE_HAS_STHREADS)
02841   return ::thr_getconcurrency ();
02842 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_GETCONCURRENCY)
02843   return pthread_getconcurrency ();
02844 # else
02845   ACE_NOTSUP_RETURN (-1);
02846 # endif /* ACE_HAS_STHREADS */
02847 #else
02848   ACE_NOTSUP_RETURN (-1);
02849 #endif /* ACE_HAS_THREADS */
02850 }

int ACE_OS::thr_getprio ( ACE_hthread_t  id,
int &  priority,
int &  policy 
) [inline]

Definition at line 2853 of file OS_NS_Thread.inl.

02854 {
02855   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02856   ACE_UNUSED_ARG (policy);
02857 #if defined (ACE_HAS_THREADS)
02858 # if (defined (ACE_HAS_PTHREADS) && \
02859      (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
02860 
02861   struct sched_param param;
02862   int result;
02863 
02864   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
02865                                 result), int,
02866               -1, result);
02867   priority = param.sched_priority;
02868   return result;
02869 # elif defined (ACE_HAS_STHREADS)
02870   int result;
02871   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (ht_id, &priority), result), int, -1);
02872 # elif defined (ACE_HAS_WTHREADS)
02873   ACE_Errno_Guard error (errno);
02874 
02875 #   if defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY)
02876   priority = ::CeGetThreadPriority (ht_id);
02877 #   else
02878   priority = ::GetThreadPriority (ht_id);
02879 #   endif /* defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY) */
02880 
02881 #   if defined (ACE_HAS_PHARLAP)
02882 #     if defined (ACE_PHARLAP_LABVIEW_RT)
02883   policy = ACE_SCHED_FIFO;
02884 #     else
02885   DWORD timeslice = ::EtsGetTimeSlice ();
02886   policy = timeslice == 0 ? ACE_SCHED_OTHER : ACE_SCHED_FIFO;
02887 #     endif /* ACE_PHARLAP_LABVIEW_RT */
02888 #   elif !defined (ACE_HAS_WINCE)
02889   DWORD priority_class = ::GetPriorityClass (::GetCurrentProcess ());
02890   if (priority_class == 0 && (error = ::GetLastError ()) != NO_ERROR)
02891     ACE_FAIL_RETURN (-1);
02892 
02893   policy =
02894     (priority_class ==
02895      REALTIME_PRIORITY_CLASS) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER;
02896 #   endif /* ACE_HAS_PHARLAP */
02897 
02898   return 0;
02899 # elif defined (ACE_HAS_VXTHREADS)
02900   ACE_OSCALL_RETURN (::taskPriorityGet (ht_id, &priority), int, -1);
02901 # else
02902   ACE_UNUSED_ARG (ht_id);
02903   ACE_UNUSED_ARG (priority);
02904   ACE_NOTSUP_RETURN (-1);
02905 # endif /* ACE_HAS_STHREADS */
02906 #else
02907   ACE_UNUSED_ARG (ht_id);
02908   ACE_UNUSED_ARG (priority);
02909   ACE_NOTSUP_RETURN (-1);
02910 #endif /* ACE_HAS_THREADS */
02911 }

int ACE_OS::thr_getprio ( ACE_hthread_t  id,
int &  priority 
) [inline]

Definition at line 2914 of file OS_NS_Thread.inl.

02915 {
02916   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02917   int policy = 0;
02918   return ACE_OS::thr_getprio (ht_id, priority, policy);
02919 }

int ACE_OS::thr_getspecific ( ACE_thread_key_t  key,
void **  data 
) [inline]

Definition at line 2950 of file OS_NS_Thread.inl.

02951 {
02952 //   ACE_OS_TRACE ("ACE_OS::thr_getspecific");
02953 #if defined (ACE_HAS_THREADS)
02954 # if defined (ACE_HAS_TSS_EMULATION)
02955     if (ACE_TSS_Emulation::is_key (key) == 0)
02956       {
02957         errno = EINVAL;
02958         data = 0;
02959         return -1;
02960       }
02961     else
02962       {
02963         *data = ACE_TSS_Emulation::ts_object (key);
02964         return 0;
02965       }
02966 # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
02967   return ACE_OS::thr_getspecific_native (key, data);
02968 #else
02969   ACE_UNUSED_ARG (key);
02970   ACE_UNUSED_ARG (data);
02971   ACE_NOTSUP_RETURN (-1);
02972 # endif /* ACE_HAS_TSS_EMULATION */
02973 #else
02974   ACE_UNUSED_ARG (key);
02975   ACE_UNUSED_ARG (data);
02976   ACE_NOTSUP_RETURN (-1);
02977 #endif /* ACE_HAS_THREADS */
02978 }

ssize_t ACE_OS::thr_id ( char  buffer[],
size_t  buffer_length 
) [inline]

Stores a string version of the current thread id into buffer and returns the size of this thread id in bytes.

Definition at line 3163 of file OS_NS_Thread.inl.

03164 {
03165 #if defined (ACE_WIN32)
03166   return ACE_OS::snprintf (buffer,
03167                            buffer_length,
03168                            "%u",
03169                            static_cast <unsigned> (ACE_OS::thr_self ()));
03170 #else /* ACE_WIN32 */
03171   ACE_hthread_t t_id;
03172   ACE_OS::thr_self (t_id);
03173 #if defined(ACE_HAS_OPAQUE_PTHREAD_T)
03174   return ACE_OS::snprintf (buffer,
03175                            buffer_length,
03176                            "%s",
03177                            "<unknown>");
03178 #else /* ACE_HAS_OPAQUE_PTHREAD_T */
03179   return ACE_OS::snprintf (buffer,
03180                            buffer_length,
03181                            "%lu",
03182                            (unsigned long) t_id);
03183 #endif /* ACE_HAS_OPAQUE_PTHREAD_T */
03184 #endif /* WIN32 */
03185 }

int ACE_OS::thr_join ( ACE_thread_t  waiter_id,
ACE_thread_t thr_id,
ACE_THR_FUNC_RETURN *  status 
) [inline]

Definition at line 3045 of file OS_NS_Thread.inl.

03048 {
03049   ACE_OS_TRACE ("ACE_OS::thr_join");
03050 #if defined (ACE_HAS_THREADS)
03051 # if defined (ACE_HAS_STHREADS)
03052   int result;
03053   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result),
03054                      int, -1);
03055 # elif defined (ACE_HAS_PTHREADS)
03056 #  if defined (ACE_LACKS_PTHREAD_JOIN)
03057   ACE_UNUSED_ARG (waiter_id);
03058   ACE_UNUSED_ARG (thr_id);
03059   ACE_UNUSED_ARG (status);
03060   ACE_NOTSUP_RETURN (-1);
03061 #  else
03062   ACE_UNUSED_ARG (thr_id);
03063   int result;
03064   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result),
03065                      int, -1);
03066 #  endif /* ACE_LACKS_PTHREAD_JOIN */
03067 # elif defined (ACE_HAS_WTHREADS)
03068   ACE_UNUSED_ARG (waiter_id);
03069   ACE_UNUSED_ARG (thr_id);
03070   ACE_UNUSED_ARG (status);
03071 
03072   // This could be implemented if the DLL-Main function or the
03073   // task exit base class some log the threads which have exited
03074   ACE_NOTSUP_RETURN (-1);
03075 # endif /* ACE_HAS_STHREADS */
03076 #else
03077   ACE_UNUSED_ARG (waiter_id);
03078   ACE_UNUSED_ARG (thr_id);
03079   ACE_UNUSED_ARG (status);
03080   ACE_NOTSUP_RETURN (-1);
03081 #endif /* ACE_HAS_THREADS */
03082 }

int ACE_OS::thr_join ( ACE_hthread_t  waiter_id,
ACE_THR_FUNC_RETURN *  status 
) [inline]

Definition at line 2982 of file OS_NS_Thread.inl.

02984 {
02985   ACE_OS_TRACE ("ACE_OS::thr_join");
02986 #if defined (ACE_HAS_THREADS)
02987 # if defined (ACE_HAS_STHREADS)
02988   int result;
02989   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result),
02990                      int, -1);
02991 # elif defined (ACE_HAS_PTHREADS)
02992 #  if defined (ACE_LACKS_PTHREAD_JOIN)
02993   ACE_UNUSED_ARG (thr_handle);
02994   ACE_UNUSED_ARG (status);
02995   ACE_NOTSUP_RETURN (-1);
02996 #  else
02997   int result;
02998   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result),
02999                      int, -1);
03000 #  endif /* ACE_LACKS_PTHREAD_JOIN */
03001 # elif defined (ACE_HAS_WTHREADS)
03002   // Waiting on the calling thread will deadlock, so try to avoid that. The
03003   // direct access to the needed info (GetThreadId) was added at Vista.
03004   // Win Server 2003 is 5.2; Vista is 6.0
03005 #   if defined (_WIN32_WINNT) && (_WIN32_WINNT >= 0x0502)
03006   const ACE_TEXT_OSVERSIONINFO &info = ACE_OS::get_win32_versioninfo ();
03007   if (info.dwMajorVersion >= 6 ||
03008       (info.dwMajorVersion == 5 && info.dwMinorVersion == 2))
03009     {
03010       if (::GetThreadId (thr_handle) == ::GetCurrentThreadId ())
03011         {
03012           errno = ERROR_POSSIBLE_DEADLOCK;
03013           return -1;
03014         }
03015     }
03016 #   endif /* _WIN32_WINNT */
03017 
03018   ACE_THR_FUNC_RETURN local_status = 0;
03019 
03020   // Make sure that status is non-NULL.
03021   if (status == 0)
03022     status = &local_status;
03023 
03024   if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0
03025       && ::GetExitCodeThread (thr_handle, status) != FALSE)
03026     {
03027       ::CloseHandle (thr_handle);
03028       return 0;
03029     }
03030   ACE_FAIL_RETURN (-1);
03031   /* NOTREACHED */
03032 # else
03033   ACE_UNUSED_ARG (thr_handle);
03034   ACE_UNUSED_ARG (status);
03035   ACE_NOTSUP_RETURN (-1);
03036 # endif /* ACE_HAS_STHREADS */
03037 #else
03038   ACE_UNUSED_ARG (thr_handle);
03039   ACE_UNUSED_ARG (status);
03040   ACE_NOTSUP_RETURN (-1);
03041 #endif /* ACE_HAS_THREADS */
03042 }

int ACE_OS::thr_key_detach ( ACE_thread_key_t  key  ) 

Definition at line 4337 of file OS_NS_Thread.cpp.

04338 {
04339 #if defined (ACE_HAS_WTHREADS) || defined (ACE_HAS_TSS_EMULATION)
04340   TSS_Cleanup_Instance cleanup;
04341   if (cleanup.valid ())
04342     {
04343       return cleanup->thread_detach_key (key);
04344     }
04345   else
04346     {
04347       return -1;
04348     }
04349 #else
04350   ACE_UNUSED_ARG (key);
04351   ACE_NOTSUP_RETURN (-1);
04352 #endif /* ACE_HAS_WTHREADS || ACE_HAS_TSS_EMULATION */
04353 }

int ACE_OS::thr_key_used ( ACE_thread_key_t  key  ) 

Definition at line 4455 of file OS_NS_Thread.cpp.

04456 {
04457 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
04458   TSS_Cleanup_Instance cleanup;
04459   if (cleanup.valid ())
04460     {
04461       cleanup->thread_use_key (key);
04462       return 0;
04463     }
04464   return -1;
04465 #else
04466   ACE_UNUSED_ARG (key);
04467   ACE_NOTSUP_RETURN (-1);
04468 #endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
04469 }

int ACE_OS::thr_keycreate ( ACE_thread_key_t key,
ACE_THR_DEST  dest 
)

Definition at line 4511 of file OS_NS_Thread.cpp.

04517 {
04518   // ACE_OS_TRACE ("ACE_OS::thr_keycreate");
04519 #if defined (ACE_HAS_THREADS)
04520 #   if defined (ACE_HAS_TSS_EMULATION)
04521     if (ACE_TSS_Emulation::next_key (*key) == 0)
04522       {
04523         ACE_TSS_Emulation::tss_destructor (*key, dest);
04524 
04525         // Extract out the thread-specific table instance and stash away
04526         // the key and destructor so that we can free it up later on...
04527         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04528         if (cleanup.valid ())
04529           {
04530             return cleanup->insert (*key, dest);
04531           }
04532         else
04533           {
04534             return -1;
04535           }
04536       }
04537     else
04538       return -1;
04539 #   elif defined (ACE_HAS_WTHREADS)
04540     if (ACE_OS::thr_keycreate_native (key, dest) == 0)
04541       {
04542         // Extract out the thread-specific table instance and stash away
04543         // the key and destructor so that we can free it up later on...
04544         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04545         if (cleanup.valid ())
04546           {
04547             return cleanup->insert (*key, dest);
04548           }
04549         else
04550           {
04551             return -1;
04552           }
04553       }
04554     else
04555       return -1;
04556       /* NOTREACHED */
04557 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04558     return  ACE_OS::thr_keycreate_native (key, dest);
04559 #   else
04560     ACE_UNUSED_ARG (key);
04561     ACE_UNUSED_ARG (dest);
04562     ACE_NOTSUP_RETURN (-1);
04563 #   endif /* ACE_HAS_TSS_EMULATION */
04564 # else /* ACE_HAS_THREADS */
04565   ACE_UNUSED_ARG (key);
04566   ACE_UNUSED_ARG (dest);
04567   ACE_NOTSUP_RETURN (-1);
04568 # endif /* ACE_HAS_THREADS */
04569 }

int ACE_OS::thr_keyfree ( ACE_thread_key_t  key  ) 

Definition at line 4612 of file OS_NS_Thread.cpp.

04613 {
04614   ACE_OS_TRACE ("ACE_OS::thr_keyfree");
04615 # if defined (ACE_HAS_THREADS)
04616 #   if defined (ACE_HAS_TSS_EMULATION)
04617     // Release the key in the TSS_Emulation administration
04618     ACE_TSS_Emulation::release_key (key);
04619     TSS_Cleanup_Instance cleanup;
04620     if (cleanup.valid ())
04621       {
04622         return cleanup->free_key (key);
04623       }
04624     return -1;
04625 #   elif defined (ACE_HAS_WTHREADS)
04626     // Extract out the thread-specific table instance and free up
04627     // the key and destructor.
04628     TSS_Cleanup_Instance cleanup;
04629     if (cleanup.valid ())
04630       {
04631         return cleanup->free_key (key);
04632       }
04633     return -1;
04634 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04635     return ACE_OS::thr_keyfree_native (key);
04636 #   else
04637     ACE_UNUSED_ARG (key);
04638     ACE_NOTSUP_RETURN (-1);
04639 #   endif /* ACE_HAS_TSS_EMULATION */
04640 # else /* ACE_HAS_THREADS */
04641   ACE_UNUSED_ARG (key);
04642   ACE_NOTSUP_RETURN (-1);
04643   return 0;
04644 # endif /* ACE_HAS_THREADS */
04645 }

int ACE_OS::thr_kill ( ACE_thread_t  thr_id,
int  signum 
) [inline]

Definition at line 3086 of file OS_NS_Thread.inl.

03087 {
03088   ACE_OS_TRACE ("ACE_OS::thr_kill");
03089 #if defined (ACE_HAS_THREADS)
03090 # if defined (ACE_HAS_PTHREADS)
03091 #   if defined (ACE_LACKS_PTHREAD_KILL)
03092   ACE_UNUSED_ARG (signum);
03093   ACE_UNUSED_ARG (thr_id);
03094   ACE_NOTSUP_RETURN (-1);
03095 #   else
03096   int result;
03097   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_kill (thr_id, signum),
03098                                        result),
03099                      int, -1);
03100 #   endif /* ACE_LACKS_PTHREAD_KILL */
03101 # elif defined (ACE_HAS_STHREADS)
03102   int result;
03103   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum),
03104                                        result),
03105                      int, -1);
03106 # elif defined (ACE_HAS_VXTHREADS)
03107   //FUZZ: disable check_for_lack_ACE_OS
03108   ACE_OSCALL_RETURN (::kill (thr_id, signum), int, -1);
03109   //FUZZ: enable check_for_lack_ACE_OS
03110 # else
03111   ACE_UNUSED_ARG (thr_id);
03112   ACE_UNUSED_ARG (signum);
03113   ACE_NOTSUP_RETURN (-1);
03114 # endif /* ACE_HAS_STHREADS */
03115 #else
03116   ACE_UNUSED_ARG (thr_id);
03117   ACE_UNUSED_ARG (signum);
03118   ACE_NOTSUP_RETURN (-1);
03119 #endif /* ACE_HAS_THREADS */
03120 }

size_t ACE_OS::thr_min_stack ( void   )  [inline]

Definition at line 3123 of file OS_NS_Thread.inl.

03124 {
03125   ACE_OS_TRACE ("ACE_OS::thr_min_stack");
03126 #if defined (ACE_HAS_THREADS)
03127 # if defined (ACE_HAS_STHREADS)
03128 #   if defined (ACE_HAS_THR_MINSTACK)
03129   // Tandem did some weirdo mangling of STHREAD names...
03130   return ::thr_minstack ();
03131 #   else
03132   return ::thr_min_stack ();
03133 #   endif /* !ACE_HAS_THR_MINSTACK */
03134 # elif defined (ACE_HAS_PTHREADS)
03135 #   if defined (_SC_THREAD_STACK_MIN)
03136   return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
03137 #   elif defined (PTHREAD_STACK_MIN)
03138   return PTHREAD_STACK_MIN;
03139 #   else
03140   ACE_NOTSUP_RETURN (0);
03141 #   endif /* _SC_THREAD_STACK_MIN */
03142 # elif defined (ACE_HAS_WTHREADS)
03143   ACE_NOTSUP_RETURN (0);
03144 # elif defined (ACE_HAS_VXTHREADS)
03145   TASK_DESC taskDesc;
03146   STATUS status;
03147 
03148   ACE_thread_t tid = ACE_OS::thr_self ();
03149 
03150   ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc),
03151                                 status),
03152               STATUS, -1, status);
03153   return status == OK ? taskDesc.td_stackSize : 0;
03154 # else /* Should not happen... */
03155   ACE_NOTSUP_RETURN (0);
03156 # endif /* ACE_HAS_STHREADS */
03157 #else
03158   ACE_NOTSUP_RETURN (0);
03159 #endif /* ACE_HAS_THREADS */
03160 }

const char * ACE_OS::thr_name ( void   )  [inline]

Definition at line 3208 of file OS_NS_Thread.inl.

03209 {
03210 #if defined (ACE_HAS_THREADS)
03211 #if defined (ACE_HAS_VXTHREADS)
03212   return ::taskName (ACE_OS::thr_self ());
03213 #else
03214   ACE_NOTSUP_RETURN (0);
03215 #endif
03216 #else
03217   ACE_NOTSUP_RETURN (0);
03218 #endif
03219 }

void ACE_OS::thr_self ( ACE_hthread_t self  )  [inline]

Definition at line 3222 of file OS_NS_Thread.inl.

03223 {
03224   ACE_OS_TRACE ("ACE_OS::thr_self");
03225 #if defined (ACE_HAS_THREADS)
03226 # if defined (ACE_HAS_PTHREADS)
03227   // Note, don't use "::" here since the following call is often a macro.
03228   self = pthread_self ();
03229 # elif defined (ACE_HAS_THREAD_SELF)
03230   self = ::thread_self ();
03231 # elif defined (ACE_HAS_STHREADS)
03232   self = ::thr_self ();
03233 # elif defined (ACE_HAS_WTHREADS)
03234   self = ::GetCurrentThread ();
03235 # elif defined (ACE_HAS_VXTHREADS)
03236   self = ::taskIdSelf ();
03237 # endif /* ACE_HAS_STHREADS */
03238 #else
03239   self = 1; // Might as well make it the main thread ;-)
03240 #endif /* ACE_HAS_THREADS */
03241 }

ACE_thread_t ACE_OS::thr_self ( void   )  [inline]

Definition at line 3188 of file OS_NS_Thread.inl.

03189 {
03190   // ACE_OS_TRACE ("ACE_OS::thr_self");
03191 #if defined (ACE_HAS_THREADS)
03192 # if defined (ACE_HAS_PTHREADS)
03193   // Note, don't use "::" here since the following call is often a macro.
03194   return pthread_self ();
03195 # elif defined (ACE_HAS_STHREADS)
03196   ACE_OSCALL_RETURN (::thr_self (), int, -1);
03197 # elif defined (ACE_HAS_WTHREADS)
03198   return ::GetCurrentThreadId ();
03199 # elif defined (ACE_HAS_VXTHREADS)
03200   return ::taskIdSelf ();
03201 # endif /* ACE_HAS_STHREADS */
03202 #else
03203   return 1; // Might as well make it the first thread ;-)
03204 #endif /* ACE_HAS_THREADS */
03205 }

int ACE_OS::thr_set_affinity ( ACE_hthread_t  thr_id,
size_t  cpu_set_size,
const cpu_set_t cpu_mask 
)

Set the thread affinity

Parameters:
thr_id For NPTL-threads, when ACE_HAS_PTHREAD_SETAFFINITY_NP defined, this is the thread-id. For linux-threads, when ACE_HAS_SCHED_SETAFFINITY defined, it expects a process-id. Since for linux-threads a thread is seen as a process, it does the job.
cpu_set_size The size of the cpu_mask, in bytes.
cpu_mask Is a bitmask of CPUs to bind to, e.g value 1 binds the thread to the "CPU 0", etc

Definition at line 4405 of file OS_NS_Thread.cpp.

04408 {
04409 #if defined (ACE_HAS_PTHREAD_SETAFFINITY_NP)
04410   if (::pthread_setaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
04411     {
04412       return -1;
04413     }
04414   return 0;
04415 #elif defined (ACE_HAS_2_PARAM_SCHED_SETAFFINITY)
04416   // The process-id is expected as <thr_id>, which can be a thread-id of
04417   // linux-thread, thus making binding to cpu of that particular thread only.
04418   // If you are using this flag for NPTL-threads, however, please pass as a
04419   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04420   //
04421   ACE_UNUSED_ARG (cpu_set_size);
04422   if (::sched_setaffinity (thr_id, cpu_mask) == -1)
04423     {
04424       return -1;
04425     }
04426   return 0;
04427 #elif defined (ACE_HAS_SCHED_SETAFFINITY)
04428   // The process-id is expected as <thr_id>, which can be a thread-id of
04429   // linux-thread, thus making binding to cpu of that particular thread only.
04430   // If you are using this flag for NPTL-threads, however, please pass as a
04431   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04432   //
04433   if (::sched_setaffinity (thr_id, cpu_set_size, cpu_mask) == -1)
04434     {
04435       return -1;
04436     }
04437   return 0;
04438 #elif defined (ACE_HAS_TASKCPUAFFINITYSET)
04439   ACE_UNUSED_ARG (cpu_set_size);
04440   int result = 0;
04441   if (ACE_ADAPT_RETVAL (::taskCpuAffinitySet (thr_id, *cpu_mask), result) == -1)
04442     {
04443       return -1;
04444     }
04445   return 0;
04446 #else
04447   ACE_UNUSED_ARG (thr_id);
04448   ACE_UNUSED_ARG (cpu_set_size);
04449   ACE_UNUSED_ARG (cpu_mask);
04450   ACE_NOTSUP_RETURN (-1);
04451 #endif
04452 }

int ACE_OS::thr_setcancelstate ( int  new_state,
int *  old_state 
) [inline]

State is THR_CANCEL_ENABLE or THR_CANCEL_DISABLE.

Definition at line 3244 of file OS_NS_Thread.inl.

03245 {
03246   ACE_OS_TRACE ("ACE_OS::thr_setcancelstate");
03247 #if defined (ACE_HAS_THREADS)
03248 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03249   int result;
03250   int local_new, local_old;
03251   switch (new_state)
03252     {
03253     case THR_CANCEL_ENABLE:
03254       local_new = PTHREAD_CANCEL_ENABLE;
03255       break;
03256     case THR_CANCEL_DISABLE:
03257       local_new = PTHREAD_CANCEL_DISABLE;
03258       break;
03259     default:
03260       errno = EINVAL;
03261       return -1;
03262     }
03263   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_setcancelstate (local_new,
03264                                                         &local_old),
03265                                 result),
03266               int, -1, result);
03267   if (result == -1)
03268     return -1;
03269   switch (local_old)
03270     {
03271     case PTHREAD_CANCEL_ENABLE:
03272       *old_state = THR_CANCEL_ENABLE;
03273       break;
03274     case PTHREAD_CANCEL_DISABLE:
03275       *old_state = THR_CANCEL_DISABLE;
03276       break;
03277     }
03278   return result;
03279 # elif defined (ACE_HAS_STHREADS)
03280   ACE_UNUSED_ARG (new_state);
03281   ACE_UNUSED_ARG (old_state);
03282   ACE_NOTSUP_RETURN (-1);
03283 # elif defined (ACE_HAS_WTHREADS)
03284   ACE_UNUSED_ARG (new_state);
03285   ACE_UNUSED_ARG (old_state);
03286   ACE_NOTSUP_RETURN (-1);
03287 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03288   ACE_UNUSED_ARG (new_state);
03289   ACE_UNUSED_ARG (old_state);
03290   ACE_NOTSUP_RETURN (-1);
03291 # endif /* ACE_HAS_PTHREADS */
03292 #else
03293   ACE_UNUSED_ARG (new_state);
03294   ACE_UNUSED_ARG (old_state);
03295   ACE_NOTSUP_RETURN (-1);
03296 #endif /* ACE_HAS_THREADS */
03297 }

int ACE_OS::thr_setcanceltype ( int  new_type,
int *  old_type 
) [inline]

Type is THR_CANCEL_DEFERRED or THR_CANCEL_ASYNCHRONOUS.

Definition at line 3300 of file OS_NS_Thread.inl.

03301 {
03302   ACE_OS_TRACE ("ACE_OS::thr_setcanceltype");
03303 #if defined (ACE_HAS_THREADS)
03304 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03305   int result;
03306   int local_new, local_old;
03307   switch (new_type)
03308     {
03309     case THR_CANCEL_DEFERRED:
03310       local_new = PTHREAD_CANCEL_DEFERRED;
03311       break;
03312     case THR_CANCEL_ASYNCHRONOUS:
03313       local_new = PTHREAD_CANCEL_ASYNCHRONOUS;
03314       break;
03315     default:
03316       errno = EINVAL;
03317       return -1;
03318     }
03319   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_setcanceltype (local_new,
03320                                                        &local_old),
03321                                 result),
03322               int, -1, result);
03323   if (result == -1)
03324     return -1;
03325   switch (local_old)
03326     {
03327     case PTHREAD_CANCEL_DEFERRED:
03328       *old_type = THR_CANCEL_DEFERRED;
03329       break;
03330     case PTHREAD_CANCEL_ASYNCHRONOUS:
03331       *old_type = THR_CANCEL_ASYNCHRONOUS;
03332       break;
03333     }
03334   return result;
03335 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03336   ACE_UNUSED_ARG (new_type);
03337   ACE_UNUSED_ARG (old_type);
03338   ACE_NOTSUP_RETURN (-1);
03339 # endif /* ACE_HAS_PTHREADS */
03340 #else
03341   ACE_UNUSED_ARG (new_type);
03342   ACE_UNUSED_ARG (old_type);
03343   ACE_NOTSUP_RETURN (-1);
03344 #endif /* ACE_HAS_THREADS */
03345 }

int ACE_OS::thr_setconcurrency ( int  hint  )  [inline]

Definition at line 3348 of file OS_NS_Thread.inl.

03349 {
03350   ACE_OS_TRACE ("ACE_OS::thr_setconcurrency");
03351 #if defined (ACE_HAS_THREADS)
03352 # if defined (ACE_HAS_STHREADS)
03353   int result;
03354   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint),
03355                                        result),
03356                      int, -1);
03357 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_SETCONCURRENCY)
03358   int result;
03359   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setconcurrency (hint),
03360                                        result),
03361                      int, -1);
03362 # else
03363   ACE_UNUSED_ARG (hint);
03364   ACE_NOTSUP_RETURN (-1);
03365 # endif /* ACE_HAS_STHREADS */
03366 #else
03367   ACE_UNUSED_ARG (hint);
03368   ACE_NOTSUP_RETURN (-1);
03369 #endif /* ACE_HAS_THREADS */
03370 }

int ACE_OS::thr_setprio ( const ACE_Sched_Priority  prio  ) 

Definition at line 4648 of file OS_NS_Thread.cpp.

04649 {
04650   // Set the thread priority on the current thread.
04651   ACE_hthread_t my_thread_id;
04652   ACE_OS::thr_self (my_thread_id);
04653 
04654   int const status = ACE_OS::thr_setprio (my_thread_id, prio);
04655 
04656 #if defined (ACE_NEEDS_LWP_PRIO_SET)
04657   // If the thread is in the RT class, then set the priority on its
04658   // LWP.  (Instead of doing this if the thread is in the RT class, it
04659   // should be done for all bound threads.  But, there doesn't appear
04660   // to be an easy way to determine if the thread is bound.)
04661 
04662   if (status == 0)
04663     {
04664       // Find what scheduling class the thread's LWP is in.
04665       ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0);
04666       if (ACE_OS::lwp_getparams (sched_params) == -1)
04667         {
04668           return -1;
04669         }
04670       else if (sched_params.policy () == ACE_SCHED_FIFO  ||
04671                sched_params.policy () == ACE_SCHED_RR)
04672         {
04673           // This thread's LWP is in the RT class, so we need to set
04674           // its priority.
04675           sched_params.priority (prio);
04676           return ACE_OS::lwp_setparams (sched_params);
04677         }
04678       // else this is not an RT thread.  Nothing more needs to be
04679       // done.
04680     }
04681 #endif /* ACE_NEEDS_LWP_PRIO_SET */
04682 
04683   return status;
04684 }

int ACE_OS::thr_setprio ( ACE_hthread_t  ht_id,
int  priority,
int  policy = -1 
) [inline]

Definition at line 3373 of file OS_NS_Thread.inl.

03374 {
03375   ACE_OS_TRACE ("ACE_OS::thr_setprio");
03376   ACE_UNUSED_ARG (policy);
03377 #if defined (ACE_HAS_THREADS)
03378 # if (defined (ACE_HAS_PTHREADS) && \
03379       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
03380 
03381   int result;
03382   struct sched_param param;
03383   ACE_OS::memset ((void *) &param, 0, sizeof param);
03384 
03385   // If <policy> is -1, we don't want to use it for
03386   // pthread_setschedparam().  Instead, obtain policy from
03387   // pthread_getschedparam().
03388   if (policy == -1)
03389     {
03390       ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
03391                                     result),
03392                   int, -1, result);
03393       if (result == -1)
03394         return result;
03395     }
03396 
03397   param.sched_priority = priority;
03398 
03399   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id,
03400                                                               policy,
03401                                                               &param),
03402                                        result),
03403                      int, -1);
03404 # elif defined (ACE_HAS_STHREADS)
03405   int result;
03406   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (ht_id, priority),
03407                                        result),
03408                      int, -1);
03409 # elif defined (ACE_HAS_WTHREADS)
03410 
03411 #   if defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY)
03412   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CeSetThreadPriority (ht_id, priority),
03413                                           ace_result_),
03414                         int, -1);
03415 #   else
03416   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (ht_id, priority),
03417                                           ace_result_),
03418                         int, -1);
03419 #   endif /* defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY) */
03420 
03421 # elif defined (ACE_HAS_VXTHREADS)
03422   ACE_OSCALL_RETURN (::taskPrioritySet (ht_id, priority), int, -1);
03423 # else
03424   // For example, platforms that support Pthreads but LACK_SETSCHED.
03425   ACE_UNUSED_ARG (ht_id);
03426   ACE_UNUSED_ARG (priority);
03427   ACE_NOTSUP_RETURN (-1);
03428 # endif /* ACE_HAS_STHREADS */
03429 #else
03430   ACE_UNUSED_ARG (ht_id);
03431   ACE_UNUSED_ARG (priority);
03432   ACE_NOTSUP_RETURN (-1);
03433 #endif /* ACE_HAS_THREADS */
03434 }

int ACE_OS::thr_setspecific ( ACE_thread_key_t  key,
void *  data 
)

Definition at line 4717 of file OS_NS_Thread.cpp.

04718 {
04719   // ACE_OS_TRACE ("ACE_OS::thr_setspecific");
04720 #if defined (ACE_HAS_THREADS)
04721 #   if defined (ACE_HAS_TSS_EMULATION)
04722     if (ACE_TSS_Emulation::is_key (key) == 0)
04723       {
04724         errno = EINVAL;
04725         data = 0;
04726         return -1;
04727       }
04728     else
04729       {
04730         ACE_TSS_Emulation::ts_object (key) = data;
04731         TSS_Cleanup_Instance cleanup;
04732         if (cleanup.valid ())
04733           {
04734             cleanup->thread_use_key (key);
04735             // for TSS_Cleanup purposes treat stetting data to zero
04736             // like detaching.  This is a consequence of POSIX allowing
04737             // deletion of a "used" key.
04738             if (data == 0)
04739               {
04740                 cleanup->thread_detach_key (key);
04741               }
04742             return 0;
04743           }
04744         else
04745           {
04746             return -1;
04747           }
04748       }
04749 #   elif defined (ACE_HAS_WTHREADS)
04750     if (ACE_OS::thr_setspecific_native (key, data) == 0)
04751       {
04752         TSS_Cleanup_Instance cleanup;
04753         if (cleanup.valid ())
04754           {
04755             cleanup->thread_use_key (key);
04756             // for TSS_Cleanup purposes treat stetting data to zero
04757             // like detaching.  This is a consequence of POSIX allowing
04758             // deletion of a "used" key.
04759             if (data == 0)
04760               {
04761                 cleanup->thread_detach_key (key);
04762               }
04763             return 0;
04764           }
04765         return -1;
04766       }
04767     return -1;
04768 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04769       return ACE_OS::thr_setspecific_native (key, data);
04770 #   else /* ACE_HAS_TSS_EMULATION */
04771       ACE_UNUSED_ARG (key);
04772       ACE_UNUSED_ARG (data);
04773       ACE_NOTSUP_RETURN (-1);
04774 #   endif /* ACE_HAS_TSS_EMULATION */
04775 # else /* ACE_HAS_THREADS */
04776   ACE_UNUSED_ARG (key);
04777   ACE_UNUSED_ARG (data);
04778   ACE_NOTSUP_RETURN (-1);
04779 # endif /* ACE_HAS_THREADS */
04780 }

int ACE_OS::thr_sigsetmask ( int  how,
const sigset_t nsm,
sigset_t osm 
) [inline]

Definition at line 3437 of file OS_NS_Thread.inl.

03440 {
03441   ACE_OS_TRACE ("ACE_OS::thr_sigsetmask");
03442 #if defined (ACE_HAS_THREADS)
03443 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
03444   // DCE threads and Solaris 2.4 have no such function.
03445   ACE_UNUSED_ARG (osm);
03446   ACE_UNUSED_ARG (nsm);
03447   ACE_UNUSED_ARG (how);
03448 
03449   ACE_NOTSUP_RETURN (-1);
03450 # elif defined (ACE_HAS_SIGTHREADMASK)
03451   int result;
03452   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm),
03453                                        result), int, -1);
03454 # elif defined (ACE_HAS_STHREADS)
03455   int result;
03456   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm),
03457                                        result),
03458                      int, -1);
03459 # elif defined (ACE_HAS_PTHREADS)
03460 #   if !defined (ACE_LACKS_PTHREAD_SIGMASK)
03461   int result;
03462   //FUZZ: disable check_for_lack_ACE_OS
03463 #    if defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK)
03464   sigset_t *ncnsm = const_cast<sigset_t *>(nsm);
03465   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsm, osm),
03466                                        result),
03467                      int,
03468                      -1);
03469 #    else
03470   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
03471                                        result),
03472                      int,
03473                      -1);
03474 #    endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */
03475   //FUZZ: enable check_for_lack_ACE_OS
03476 #   endif /* !ACE_LACKS_PTHREAD_SIGMASK */
03477 
03478 # elif defined (ACE_HAS_WTHREADS)
03479   ACE_UNUSED_ARG (osm);
03480   ACE_UNUSED_ARG (nsm);
03481   ACE_UNUSED_ARG (how);
03482 
03483   ACE_NOTSUP_RETURN (-1);
03484 # elif defined (ACE_VXWORKS)
03485   int old_mask = 0;
03486   switch (how)
03487     {
03488     case SIG_BLOCK:
03489     case SIG_UNBLOCK:
03490       {
03491         // get the old mask
03492         old_mask = ::sigsetmask (*nsm);
03493         // create a new mask:  the following assumes that sigset_t is 4 bytes,
03494         // which it is on VxWorks 5.2, so bit operations are done simply . . .
03495         ::sigsetmask (how == SIG_BLOCK ? (old_mask |= *nsm) : (old_mask &= ~*nsm));
03496         if (osm)
03497           *osm = old_mask;
03498         break;
03499       }
03500     case SIG_SETMASK:
03501       old_mask = ::sigsetmask (*nsm);
03502       if (osm)
03503         *osm = old_mask;
03504       break;
03505     default:
03506       return -1;
03507     }
03508 
03509   return 0;
03510 # else /* Should not happen. */
03511   ACE_UNUSED_ARG (how);
03512   ACE_UNUSED_ARG (nsm);
03513   ACE_UNUSED_ARG (osm);
03514   ACE_NOTSUP_RETURN (-1);
03515 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
03516 #else
03517   ACE_UNUSED_ARG (how);
03518   ACE_UNUSED_ARG (nsm);
03519   ACE_UNUSED_ARG (osm);
03520   ACE_NOTSUP_RETURN (-1);
03521 #endif /* ACE_HAS_THREADS */
03522 }

int ACE_OS::thr_suspend ( ACE_hthread_t  target_thread  )  [inline]

Definition at line 3525 of file OS_NS_Thread.inl.

03526 {
03527   ACE_OS_TRACE ("ACE_OS::thr_suspend");
03528 #if defined (ACE_HAS_THREADS)
03529 # if defined (ACE_HAS_STHREADS)
03530   int result;
03531   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), result), int, -1);
03532 # elif defined (ACE_HAS_PTHREADS)
03533 #  if defined (ACE_HAS_PTHREAD_SUSPEND)
03534   int result;
03535   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread),
03536                                        result),
03537                      int, -1);
03538 #  elif defined (ACE_HAS_PTHREAD_SUSPEND_NP)
03539   int result;
03540   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend_np (target_thread),
03541                                        result),
03542                      int, -1);
03543 #  else
03544   ACE_UNUSED_ARG (target_thread);
03545   ACE_NOTSUP_RETURN (-1);
03546 #  endif /* ACE_HAS_PTHREAD_SUSPEND */
03547 # elif defined (ACE_HAS_WTHREADS)
03548   if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED)
03549     return 0;
03550   else
03551     ACE_FAIL_RETURN (-1);
03552   /* NOTREACHED */
03553 # elif defined (ACE_HAS_VXTHREADS)
03554   ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1);
03555 # endif /* ACE_HAS_STHREADS */
03556 #else
03557   ACE_UNUSED_ARG (target_thread);
03558   ACE_NOTSUP_RETURN (-1);
03559 #endif /* ACE_HAS_THREADS */
03560 }

void ACE_OS::thr_testcancel ( void   )  [inline]

Definition at line 3563 of file OS_NS_Thread.inl.

03564 {
03565   ACE_OS_TRACE ("ACE_OS::thr_testcancel");
03566 #if defined (ACE_HAS_THREADS)
03567 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03568   pthread_testcancel ();
03569 # elif defined (ACE_HAS_STHREADS)
03570 # elif defined (ACE_HAS_WTHREADS)
03571 # elif defined (ACE_HAS_VXTHREADS)
03572 # else
03573   // no-op:  can't use ACE_NOTSUP_RETURN because there is no return value
03574 # endif /* ACE_HAS_PTHREADS */
03575 #else
03576 #endif /* ACE_HAS_THREADS */
03577 }

void ACE_OS::thr_yield ( void   )  [inline]

Definition at line 3580 of file OS_NS_Thread.inl.

03581 {
03582   ACE_OS_TRACE ("ACE_OS::thr_yield");
03583 #if defined (ACE_HAS_THREADS)
03584 # if defined (ACE_HAS_PTHREADS)
03585   ::sched_yield ();
03586 # elif defined (ACE_HAS_STHREADS)
03587   ::thr_yield ();
03588 # elif defined (ACE_HAS_WTHREADS)
03589   ::Sleep (0);
03590 # elif defined (ACE_HAS_VXTHREADS)
03591   // An argument of 0 to ::taskDelay doesn't appear to yield the
03592   // current thread.
03593   // Now, it does seem to work.  The context_switch_time test
03594   // works fine with task_delay set to 0.
03595   ::taskDelay (0);
03596 # endif /* ACE_HAS_STHREADS */
03597 #else
03598   ;
03599 #endif /* ACE_HAS_THREADS */
03600 }

int ACE_OS::thread_mutex_destroy ( ACE_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3603 of file OS_NS_Thread.inl.

03604 {
03605   ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy");
03606 #if defined (ACE_HAS_THREADS)
03607 # if defined (ACE_HAS_WTHREADS)
03608   ::DeleteCriticalSection (m);
03609   return 0;
03610 # else
03611   return ACE_OS::mutex_destroy (m);
03612 # endif /* ACE_HAS_WTHREADS */
03613 #else
03614   ACE_UNUSED_ARG (m);
03615   ACE_NOTSUP_RETURN (-1);
03616 
03617 #endif /* ACE_HAS_THREADS */
03618 }

int ACE_OS::thread_mutex_init ( ACE_thread_mutex_t m,
int  lock_type,
const wchar_t name,
ACE_mutexattr_t arg = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3664 of file OS_NS_Thread.inl.

03668 {
03669   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03670 #if defined (ACE_HAS_THREADS)
03671 # if defined (ACE_HAS_WTHREADS)
03672   ACE_UNUSED_ARG (lock_type);
03673   ACE_UNUSED_ARG (name);
03674   ACE_UNUSED_ARG (arg);
03675 
03676   ACE_SEH_TRY
03677     {
03678       ::InitializeCriticalSection (m);
03679     }
03680   ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
03681     {
03682       errno = ENOMEM;
03683       return -1;
03684     }
03685   return 0;
03686 
03687 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03688   // Force the use of USYNC_THREAD!
03689   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03690 # elif defined (ACE_HAS_VXTHREADS)
03691   return mutex_init (m, lock_type, name, arg);
03692 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03693 #else
03694   ACE_UNUSED_ARG (m);
03695   ACE_UNUSED_ARG (lock_type);
03696   ACE_UNUSED_ARG (name);
03697   ACE_UNUSED_ARG (arg);
03698   ACE_NOTSUP_RETURN (-1);
03699 
03700 #endif /* ACE_HAS_THREADS */
03701 }

int ACE_OS::thread_mutex_init ( ACE_thread_mutex_t m,
int  lock_type = 0,
const char *  name = 0,
ACE_mutexattr_t arg = 0 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3621 of file OS_NS_Thread.inl.

03625 {
03626   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03627 #if defined (ACE_HAS_THREADS)
03628 # if defined (ACE_HAS_WTHREADS)
03629   ACE_UNUSED_ARG (lock_type);
03630   ACE_UNUSED_ARG (name);
03631   ACE_UNUSED_ARG (arg);
03632 
03633   ACE_SEH_TRY
03634     {
03635       ::InitializeCriticalSection (m);
03636     }
03637   ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
03638     {
03639       errno = ENOMEM;
03640       return -1;
03641     }
03642   return 0;
03643 
03644 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03645   // Force the use of USYNC_THREAD!
03646   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03647 # elif defined (ACE_HAS_VXTHREADS)
03648   return mutex_init (m, lock_type, name, arg);
03649 
03650 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03651 
03652 #else
03653   ACE_UNUSED_ARG (m);
03654   ACE_UNUSED_ARG (lock_type);
03655   ACE_UNUSED_ARG (name);
03656   ACE_UNUSED_ARG (arg);
03657   ACE_NOTSUP_RETURN (-1);
03658 
03659 #endif /* ACE_HAS_THREADS */
03660 }

int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m,
const ACE_Time_Value timeout 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3745 of file OS_NS_Thread.inl.

03747 {
03748   return timeout == 0
03749     ? ACE_OS::thread_mutex_lock (m)
03750     : ACE_OS::thread_mutex_lock (m, *timeout);
03751 }

int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m,
const ACE_Time_Value timeout 
) [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3722 of file OS_NS_Thread.inl.

03724 {
03725   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03726 
03727   // For all platforms, except MS Windows, this method is equivalent
03728   // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and
03729   // ACE_mutex_t are the same type.  However, those typedefs evaluate
03730   // to different types on MS Windows.  The "thread mutex"
03731   // implementation in ACE for MS Windows cannot readily support
03732   // timeouts due to a lack of timeout features for this type of MS
03733   // Windows synchronization mechanism.
03734 
03735 #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS)
03736   return ACE_OS::mutex_lock (m, timeout);
03737 #else
03738   ACE_UNUSED_ARG (m);
03739   ACE_UNUSED_ARG (timeout);
03740   ACE_NOTSUP_RETURN (-1);
03741 #endif /* ACE_HAS_THREADS */
03742 }

int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3705 of file OS_NS_Thread.inl.

03706 {
03707   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03708 #if defined (ACE_HAS_THREADS)
03709 # if defined (ACE_HAS_WTHREADS)
03710   ::EnterCriticalSection (m);
03711   return 0;
03712 # else
03713   return ACE_OS::mutex_lock (m);
03714 # endif /* ACE_HAS_WTHREADS */
03715 #else
03716   ACE_UNUSED_ARG (m);
03717   ACE_NOTSUP_RETURN (-1);
03718 #endif /* ACE_HAS_THREADS */
03719 }

int ACE_OS::thread_mutex_trylock ( ACE_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3754 of file OS_NS_Thread.inl.

03755 {
03756   ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
03757 
03758 #if defined (ACE_HAS_THREADS)
03759 # if defined (ACE_HAS_WTHREADS)
03760 #   if defined (ACE_HAS_WIN32_TRYLOCK)
03761   BOOL result = ::TryEnterCriticalSection (m);
03762   if (result == TRUE)
03763     {
03764       return 0;
03765     }
03766   else
03767     {
03768       errno = EBUSY;
03769       return -1;
03770     }
03771 #   else
03772   ACE_UNUSED_ARG (m);
03773   ACE_NOTSUP_RETURN (-1);
03774 #   endif /* ACE_HAS_WIN32_TRYLOCK */
03775 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03776   return ACE_OS::mutex_trylock (m);
03777 #endif /* Threads variety case */
03778 
03779 #else
03780   ACE_UNUSED_ARG (m);
03781   ACE_NOTSUP_RETURN (-1);
03782 #endif /* ACE_HAS_THREADS */
03783 }

int ACE_OS::thread_mutex_unlock ( ACE_thread_mutex_t m  )  [inline]

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 3786 of file OS_NS_Thread.inl.

03787 {
03788   ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock");
03789 #if defined (ACE_HAS_THREADS)
03790 # if defined (ACE_HAS_WTHREADS)
03791   ::LeaveCriticalSection (m);
03792   return 0;
03793 # else
03794   return ACE_OS::mutex_unlock (m);
03795 # endif /* ACE_HAS_WTHREADS */
03796 #else
03797   ACE_UNUSED_ARG (m);
03798   ACE_NOTSUP_RETURN (-1);
03799 #endif /* ACE_HAS_THREADS */
03800 }

time_t ACE_OS::time ( time_t *  tloc = 0  )  [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 456 of file OS_NS_time.inl.

00457 {
00458   ACE_OS_TRACE ("ACE_OS::time");
00459 #if defined (ACE_LACKS_TIME)
00460   time_t const retv = ACE_OS::gettimeofday ().sec ();
00461   if (tloc)
00462     *tloc = retv;
00463   return retv;
00464 #else
00465   ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1);
00466 #endif /* ACE_LACKS_TIME */
00467 }

long ACE_OS::timezone ( void   )  [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 480 of file OS_NS_time.inl.

00481 {
00482   return ::ace_timezone ();
00483 }

int ACE_OS::truncate ( const ACE_TCHAR filename,
ACE_OFF_T  length 
) [inline]

Definition at line 1072 of file OS_NS_unistd.inl.

01074 {
01075   ACE_OS_TRACE ("ACE_OS::truncate");
01076 #if defined (ACE_WIN32)
01077   ACE_HANDLE handle = ACE_OS::open (filename,
01078                                     O_WRONLY,
01079                                     ACE_DEFAULT_FILE_PERMS);
01080 
01081 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01082   LARGE_INTEGER loffset;
01083   loffset.QuadPart = offset;
01084 #else
01085   LONG low_offset = ACE_LOW_PART(offset);
01086   LONG high_offset = ACE_HIGH_PART(offset);
01087 #endif
01088 
01089   if (handle == ACE_INVALID_HANDLE)
01090     ACE_FAIL_RETURN (-1);
01091 
01092 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01093   else if (::SetFilePointerEx (handle,
01094                                loffset,
01095                                0,
01096                                FILE_BEGIN))
01097 #  else
01098   else if (::SetFilePointer (handle,
01099                              low_offset,
01100                              &high_offset,
01101                              FILE_BEGIN) != INVALID_SET_FILE_POINTER
01102            || GetLastError () == NO_ERROR)
01103 #  endif /* ACE_LACKS_WIN32_SETFILEPOINTEREX */
01104     {
01105       BOOL result = ::SetEndOfFile (handle);
01106       ::CloseHandle (handle);
01107       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1);
01108     }
01109   else
01110     {
01111       ::CloseHandle (handle);
01112       ACE_FAIL_RETURN (-1);
01113     }
01114   /* NOTREACHED */
01115 #elif !defined (ACE_LACKS_TRUNCATE)
01116   ACE_OSCALL_RETURN
01117     (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1);
01118 #else
01119   ACE_UNUSED_ARG (filename);
01120   ACE_UNUSED_ARG (offset);
01121   ACE_NOTSUP_RETURN (-1);
01122 #endif /* ACE_WIN32 */
01123 }

void ACE_OS::tzset ( void   )  [inline]

strptime wrapper. Note that the struct tm will always be set to zero

Definition at line 487 of file OS_NS_time.inl.

00488 {
00489 #if defined (ACE_LACKS_TZSET)
00490   errno = ENOTSUP;
00491 #elif defined (ACE_WIN32)
00492   ::_tzset ();  // For Win32.
00493 #else
00494   ::tzset ();   // For UNIX platforms.
00495 #endif /* ACE_LACKS_TZSET */
00496 }

useconds_t ACE_OS::ualarm ( const ACE_Time_Value tv,
const ACE_Time_Value tv_interval = ACE_Time_Value::zero 
) [inline]

Definition at line 1147 of file OS_NS_unistd.inl.

01149 {
01150   ACE_OS_TRACE ("ACE_OS::ualarm");
01151 
01152 #if defined (ACE_HAS_UALARM)
01153   useconds_t usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec ();
01154   useconds_t interval =
01155     (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec ();
01156   return ::ualarm (usecs, interval);
01157 #elif !defined (ACE_LACKS_UNIX_SIGNALS) && !defined (ACE_LACKS_ALARM)
01158   ACE_UNUSED_ARG (tv_interval);
01159 # if defined (ACE_VXWORKS) && ACE_VXWORKS >= 0x690 && defined (_WRS_CONFIG_LP64)
01160   return ::alarm (static_cast<unsigned int> (tv.sec ()));
01161 # else
01162   return ::alarm (tv.sec ());
01163 # endif
01164 #else
01165   ACE_UNUSED_ARG (tv_interval);
01166   ACE_UNUSED_ARG (tv);
01167   ACE_NOTSUP_RETURN (0);
01168 #endif /* ACE_HAS_UALARM */
01169 }

useconds_t ACE_OS::ualarm ( useconds_t  usecs,
useconds_t  interval = 0 
) [inline]

Definition at line 1126 of file OS_NS_unistd.inl.

01127 {
01128   ACE_OS_TRACE ("ACE_OS::ualarm");
01129 
01130 #if defined (ACE_HAS_UALARM)
01131   return ::ualarm (usecs, interval);
01132 #elif !defined (ACE_LACKS_UNIX_SIGNALS) && !defined (ACE_LACKS_ALARM)
01133   ACE_UNUSED_ARG (interval);
01134 # if defined (ACE_VXWORKS) && ACE_VXWORKS >= 0x690 && defined (_WRS_CONFIG_LP64)
01135   return ::alarm (static_cast<unsigned int> (usecs * ACE_ONE_SECOND_IN_USECS));
01136 # else
01137   return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS);
01138 #endif
01139 #else
01140   ACE_UNUSED_ARG (usecs);
01141   ACE_UNUSED_ARG (interval);
01142   ACE_NOTSUP_RETURN (0);
01143 #endif /* ACE_HAS_UALARM */
01144 }

mode_t ACE_OS::umask ( mode_t  cmask  )  [inline]

Definition at line 282 of file OS_NS_sys_stat.inl.

00283   {
00284     ACE_OS_TRACE ("ACE_OS::umask");
00285 # if defined (ACE_LACKS_UMASK)
00286     ACE_UNUSED_ARG (cmask);
00287     ACE_NOTSUP_RETURN ((mode_t)-1);
00288 # elif defined (ACE_HAS_TR24731_2005_CRT)
00289     int old_mode;
00290     int new_mode = static_cast<int> (cmask);
00291     ACE_SECURECRTCALL (_umask_s (new_mode, &old_mode), mode_t, -1, old_mode);
00292     return static_cast<mode_t> (old_mode);
00293 # elif defined (ACE_WIN32) && !defined (__BORLANDC__)
00294     ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1);
00295 # else
00296     return ::umask (cmask); // This call shouldn't fail...
00297 # endif /* ACE_LACKS_UMASK */
00298   }

int ACE_OS::uname ( ACE_utsname name  ) 

Definition at line 17 of file OS_NS_sys_utsname.cpp.

00018 {
00019   ACE_OS_TRACE ("ACE_OS::uname");
00020 #if !defined (ACE_LACKS_UNAME)
00021   ACE_OSCALL_RETURN (::uname (name), int, -1);
00022 #elif defined (ACE_WIN32)
00023   size_t maxnamelen = sizeof name->nodename;
00024   ACE_OS::strcpy (name->sysname, "Win32");
00025 
00026 # if defined (ACE_HAS_WIN32_GETVERSION)
00027   /* Since MS found it necessary to deprecate these. */
00028 #   pragma warning(push)
00029 #   pragma warning(disable:4996)
00030 #   if defined(__clang__)
00031 #     pragma clang diagnostic push
00032 #     pragma clang diagnostic ignored "-Wdeprecated-declarations"
00033 #   endif /* __clang__ */
00034   ACE_TEXT_OSVERSIONINFO vinfo;
00035   vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO);
00036   ACE_TEXT_GetVersionEx (&vinfo);
00037 #   if defined(__clang__)
00038 #     pragma clang diagnostic pop
00039 #   endif /* __clang__ */
00040 #   pragma warning(pop)
00041 # endif
00042 
00043   SYSTEM_INFO sinfo;
00044 #   if defined (ACE_HAS_PHARLAP)
00045   // PharLap doesn't do GetSystemInfo.  What's really wanted is the
00046   // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
00047   // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
00048   // that the CPU type values in EK_KERNELINFO have the same values
00049   // are the ones defined for SYSTEM_INFO.
00050   EK_KERNELINFO ets_kern;
00051   EK_SYSTEMINFO ets_sys;
00052   EtsGetSystemInfo (&ets_kern, &ets_sys);
00053   sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType);
00054   sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
00055   sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
00056 #   else
00057   ::GetSystemInfo(&sinfo);
00058 #   endif /* ACE_HAS_PHARLAP */
00059 
00060   const char* unknown = "???";
00061 
00062 # if defined (ACE_HAS_WIN32_GETVERSION)
00063   if (
00064       vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
00065 #   if defined (VER_PLATFORM_WIN32_CE)
00066       || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
00067 #   endif
00068       )
00069     {
00070       // Get information from the two structures
00071       const char *os = 0;
00072       if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
00073         os = "Windows NT %d.%d";
00074       else
00075         os = "Windows CE %d.%d";
00076       ACE_OS::snprintf (name->release, maxnamelen,
00077                         os,
00078                         (int) vinfo.dwMajorVersion,
00079                         (int) vinfo.dwMinorVersion);
00080       ACE_OS::snprintf (name->version, maxnamelen,
00081                         "Build %d %s",
00082                         (int) vinfo.dwBuildNumber,
00083                         ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
00084 
00085       // We have to make sure that the size of (processor + subtype)
00086       // is not greater than the size of name->machine.  So we give
00087       // half the space to the processor and half the space to
00088       // subtype.  The -1 is necessary for because of the space
00089       // between processor and subtype in the machine name.
00090       int const bufsize = (sizeof (name->machine) / 2) - 1;
00091       char processor[bufsize] = "Unknown";
00092       char subtype[bufsize] = "Unknown";
00093 
00094       WORD arch = sinfo.wProcessorArchitecture;
00095 
00096       switch (arch)
00097         {
00098         case PROCESSOR_ARCHITECTURE_INTEL:
00099           ACE_OS::strcpy (processor, "Intel");
00100           if (sinfo.wProcessorLevel == 3)
00101             ACE_OS::strcpy (subtype, "80386");
00102           else if (sinfo.wProcessorLevel == 4)
00103             ACE_OS::strcpy (subtype, "80486");
00104           else if (sinfo.wProcessorLevel == 5)
00105             ACE_OS::strcpy (subtype, "Pentium");
00106           else if (sinfo.wProcessorLevel == 6)
00107             ACE_OS::strcpy (subtype, "Pentium Pro");
00108           else if (sinfo.wProcessorLevel == 7)  // I'm guessing here
00109             ACE_OS::strcpy (subtype, "Pentium II");
00110           else
00111             ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00112           break;
00113         case PROCESSOR_ARCHITECTURE_MIPS:
00114           ACE_OS::strcpy (processor, "MIPS");
00115           if (sinfo.wProcessorLevel == 3)
00116             ACE_OS::strcpy (subtype, "R3000");
00117           else if (sinfo.wProcessorLevel == 4)
00118             ACE_OS::strcpy (subtype, "R4000");
00119           else
00120             ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00121           break;
00122         case PROCESSOR_ARCHITECTURE_ALPHA:
00123           ACE_OS::strcpy (processor, "Alpha");
00124           ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00125           break;
00126         case PROCESSOR_ARCHITECTURE_PPC:
00127           ACE_OS::strcpy (processor, "PPC");
00128           if (sinfo.wProcessorLevel == 1)
00129             ACE_OS::strcpy (subtype, "601");
00130           else if (sinfo.wProcessorLevel == 3)
00131             ACE_OS::strcpy (subtype, "603");
00132           else if (sinfo.wProcessorLevel == 4)
00133             ACE_OS::strcpy (subtype, "604");
00134           else if (sinfo.wProcessorLevel == 6)
00135             ACE_OS::strcpy (subtype, "603+");
00136           else if (sinfo.wProcessorLevel == 9)
00137             ACE_OS::strcpy (subtype, "804+");
00138           else if (sinfo.wProcessorLevel == 20)
00139             ACE_OS::strcpy (subtype, "620");
00140           break;
00141 #     if defined PROCESSOR_ARCHITECTURE_IA64
00142         case PROCESSOR_ARCHITECTURE_IA64:
00143           ACE_OS::strcpy (processor, "Itanium");
00144           ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00145           break;
00146 #     endif
00147 #     if defined PROCESSOR_ARCHITECTURE_AMD64
00148         case PROCESSOR_ARCHITECTURE_AMD64:
00149           ACE_OS::strcpy (processor, "x64");
00150           ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00151           break;
00152 #     endif
00153 #     if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
00154         case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
00155           ACE_OS::strcpy (processor, "WOW64");
00156           ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00157           break;
00158 #     endif
00159 #     if defined PROCESSOR_ARCHITECTURE_ARM
00160         case PROCESSOR_ARCHITECTURE_ARM:
00161           ACE_OS::strcpy (processor, "ARM");
00162           ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
00163           break;
00164 #     endif
00165         case PROCESSOR_ARCHITECTURE_UNKNOWN:
00166         default:
00167           // @@ We could provide WinCE specific info here.  But let's
00168           //    defer that to some later point.
00169           ACE_OS::strcpy (processor, "Unknown");
00170           break;
00171         }
00172       ACE_OS::snprintf (name->machine, maxnamelen, "%s %s", processor, subtype);
00173     }
00174   else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00175     {
00176       if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
00177         {
00178           ACE_OS::strcpy (name->release, "Windows 95");
00179           if (vinfo.szCSDVersion[1] == ACE_TEXT('C'))
00180             ACE_OS::strcat (name->release, " OSR2");
00181         }
00182       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
00183         {
00184           ACE_OS::strcpy (name->release, "Windows 98");
00185           if (vinfo.szCSDVersion[1] == ACE_TEXT('A'))
00186             ACE_OS::strcat (name->release, " SE");
00187         }
00188       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
00189         {
00190           ACE_OS::strcpy (name->release, "Windows Me");
00191         }
00192       else
00193         {
00194           ACE_OS::strcpy (name->release, unknown);
00195         }
00196 
00197       ACE_OS::snprintf (name->version, maxnamelen, "%d",
00198                         LOWORD (vinfo.dwBuildNumber));
00199       if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
00200         ACE_OS::strcpy (name->machine, "Intel 80386");
00201       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
00202         ACE_OS::strcpy (name->machine, "Intel 80486");
00203       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
00204         ACE_OS::strcpy (name->machine, "Intel Pentium");
00205       else
00206         ACE_OS::strcpy (name->machine, unknown);
00207     }
00208   else
00209 # endif /* !ACE_HAS_WIN32_GETVERSION */
00210     {
00211       // We don't know what this is!
00212 
00213       ACE_OS::strcpy (name->release, unknown);
00214       ACE_OS::strcpy (name->version, unknown);
00215       ACE_OS::strcpy (name->machine, unknown);
00216     }
00217 
00218 # if defined (ACE_LACKS_HOSTNAME)
00219   return 0;
00220 # else /* ACE_LACKS_HOSTNAME */
00221   return ACE_OS::hostname (name->nodename, maxnamelen);
00222 # endif /* ACE_LACKS_HOSTNAME */
00223 
00224 #elif defined (ACE_VXWORKS) && !defined (__RTP__)
00225   size_t const maxnamelen = sizeof name->nodename;
00226   ACE_OS::strcpy (name->sysname, "VxWorks");
00227   ACE_OS::strcpy (name->release, kernelVersion());
00228   ACE_OS::strcpy (name->version, sysBspRev ());
00229   ACE_OS::strcpy (name->machine, sysModel ());
00230 
00231   return ACE_OS::hostname (name->nodename, maxnamelen);
00232 #elif defined (INTEGRITY)
00233   if(!name) {
00234     errno = EFAULT;
00235     return -1;
00236   }
00237   strcpy(name->sysname,"INTEGRITY");
00238   int status = gethostname(name->nodename,_SYS_NMLN);
00239   strcpy(name->release,"4.0");
00240   strcpy(name->version,"4.0.9");
00241   strcpy(name->machine,"a standard name");
00242   return status;
00243 #else
00244   ACE_UNUSED_ARG (name);
00245   ACE_NOTSUP_RETURN (-1);
00246 #endif /* ACE_WIN32 */
00247 }

int ACE_OS::ungetc ( int  c,
FILE *  fp 
) [inline]

Definition at line 680 of file OS_NS_stdio.inl.

00681 {
00682 #ifdef ACE_LACKS_UNGETC
00683   ACE_UNUSED_ARG (c);
00684   ACE_UNUSED_ARG (fp);
00685   ACE_NOTSUP_RETURN (-1);
00686 #else
00687   return ace_ungetc_helper (c, fp);
00688 #endif
00689 }

wint_t ACE_OS::ungetwc ( wint_t  c,
FILE *  fp 
) [inline]

Definition at line 72 of file OS_NS_wchar.inl.

00073 {
00074 #  if defined (ACE_LACKS_FGETWC)
00075   ACE_UNUSED_ARG (c);
00076   ACE_UNUSED_ARG (fp);
00077   ACE_NOTSUP_RETURN (0);
00078 #  else
00079   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ungetwc (c, fp), wint_t, WEOF);
00080 #  endif /* ACE_LACKS_FGETWC */
00081 }

void ACE_OS::unique_name ( const void *  object,
char *  name,
size_t  length 
)

This method uses process id and object pointer to come up with a machine wide unique name. The process ID will provide uniqueness between processes on the same machine. The "this" pointer of the object will provide uniqueness between other "live" objects in the same process. The uniqueness of this name is therefore only valid for the life of object.

Definition at line 4783 of file OS_NS_Thread.cpp.

04786 {
04787   // The process ID will provide uniqueness between processes on the
04788   // same machine. The "this" pointer of the <object> will provide
04789   // uniqueness between other "live" objects in the same process. The
04790   // uniqueness of this name is therefore only valid for the life of
04791   // <object>.
04792   ACE_OS::snprintf (name, length, "%p%d", object,
04793                     static_cast<int> (ACE_OS::getpid ()));
04794 }

int ACE_OS::unlink ( const wchar_t path  )  [inline]

Definition at line 1193 of file OS_NS_unistd.inl.

01194 {
01195   ACE_OS_TRACE ("ACE_OS::unlink");
01196 # if defined (ACE_HAS_WINCE)
01197   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01198   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFileW (path), ace_result_),
01199                         int, -1);
01200 # elif defined (ACE_WIN32)
01201   ACE_OSCALL_RETURN (::_wunlink (path), int, -1);
01202 # else
01203   ACE_Wide_To_Ascii npath (path);
01204   return ACE_OS::unlink (npath.char_rep ());
01205 # endif /* ACE_HAS_WINCE */
01206 }

int ACE_OS::unlink ( const char *  path  )  [inline]

Definition at line 1172 of file OS_NS_unistd.inl.

01173 {
01174   ACE_OS_TRACE ("ACE_OS::unlink");
01175 # if defined (ACE_HAS_NONCONST_UNLINK)
01176   ACE_OSCALL_RETURN (::unlink (const_cast<char *> (path)), int, -1);
01177 # elif defined (ACE_HAS_WINCE)
01178   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01179   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (ACE_TEXT_CHAR_TO_TCHAR (path)), ace_result_),
01180                         int, -1);
01181 # elif defined (ACE_LACKS_UNLINK)
01182   ACE_UNUSED_ARG (path);
01183   ACE_NOTSUP_RETURN (-1);
01184 # elif defined (ACE_UNLINK_EQUIVALENT)
01185   ACE_OSCALL_RETURN (ACE_UNLINK_EQUIVALENT (path), int, -1);
01186 # else
01187   ACE_OSCALL_RETURN (::unlink (path), int, -1);
01188 # endif /* ACE_HAS_NONCONST_UNLINK */
01189 }

int ACE_OS::unsetenv ( const char *  name  )  [inline]

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 363 of file OS_NS_stdlib.inl.

00364 {
00365 #if defined (ACE_LACKS_UNSETENV)
00366   ACE_UNUSED_ARG (name);
00367   ACE_NOTSUP_RETURN (-1);
00368 #else
00369 # if defined (ACE_HAS_VOID_UNSETENV)
00370   ::unsetenv (name);
00371   return 0;
00372 #else
00373   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::unsetenv (name), int, -1);
00374 # endif /* ACE_HAS_VOID_UNSETENV */
00375 #endif /* ACE_LACKS_UNSETENV */
00376 }

int ACE_OS::vasprintf ( wchar_t **  bufp,
const wchar_t format,
va_list  argptr 
) [inline]

Definition at line 1031 of file OS_NS_stdio.inl.

01032 {
01033 #if defined (ACE_HAS_VASWPRINTF)
01034   return ::vaswprintf (bufp, format, argptr);
01035 #elif defined (ACE_LACKS_VA_COPY)
01036   ACE_UNUSED_ARG (bufp);
01037   ACE_UNUSED_ARG (format);
01038   ACE_UNUSED_ARG (argptr);
01039   ACE_NOTSUP_RETURN (-1);
01040 #else
01041   return ACE_OS::vaswprintf_emulation (bufp, format, argptr);
01042 #endif /* ACE_HAS_VASWPRINTF */
01043 }

int ACE_OS::vasprintf ( char **  bufp,
const char *  format,
va_list  argptr 
) [inline]

Definition at line 1015 of file OS_NS_stdio.inl.

01016 {
01017 #if defined (ACE_HAS_VASPRINTF)
01018   return ::vasprintf (bufp, format, argptr);
01019 #elif defined (ACE_LACKS_VA_COPY)
01020   ACE_UNUSED_ARG (bufp);
01021   ACE_UNUSED_ARG (format);
01022   ACE_UNUSED_ARG (argptr);
01023   ACE_NOTSUP_RETURN (-1);
01024 #else
01025   return ACE_OS::vasprintf_emulation (bufp, format, argptr);
01026 #endif /* ACE_HAS_VASPRINTF */
01027 }

int ACE_OS::vasprintf_emulation ( char **  bufp,
const char *  format,
va_list  argptr 
)

Definition at line 446 of file OS_NS_stdio.cpp.

00447 {
00448   va_list ap;
00449   va_copy (ap, argptr);
00450   int size = ACE_OS::vsnprintf (0, 0, format, ap);
00451   va_end (ap);
00452 
00453   if (size != -1)
00454     {
00455       char *buf = reinterpret_cast<char*>(ACE_OS::malloc(size + 1));
00456       if (!buf)
00457         return -1;
00458 
00459       va_list aq;
00460       va_copy (aq, argptr);
00461       size = ACE_OS::vsnprintf(buf, size + 1, format, aq);
00462       va_end (aq);
00463 
00464       if (size != -1)
00465         *bufp = buf;
00466     }
00467 
00468   return size;
00469 }

int ACE_OS::vaswprintf_emulation ( wchar_t **  bufp,
const wchar_t format,
va_list  argptr 
)

Definition at line 475 of file OS_NS_stdio.cpp.

00476 {
00477   va_list ap;
00478   va_copy (ap, argptr);
00479   int size = ACE_OS::vsnprintf(0, 0, format, ap);
00480   va_end (ap);
00481 
00482   if (size != -1)
00483     {
00484       wchar_t *buf = reinterpret_cast<wchar_t*>
00485         (ACE_OS::malloc((size + 1) * sizeof(wchar_t)));
00486       if (!buf)
00487         return -1;
00488 
00489       va_list aq;
00490       va_copy (aq, argptr);
00491       size = ACE_OS::vsnprintf(buf, size + 1, format, aq);
00492       va_end (aq);
00493 
00494       if (size != -1)
00495         *bufp = buf;
00496     }
00497 
00498   return size;
00499 }

int ACE_OS::vfprintf ( FILE *  fp,
const wchar_t format,
va_list  argptr 
) [inline]

Definition at line 1087 of file OS_NS_stdio.inl.

01088 {
01089 #if defined (ACE_HAS_VFWPRINTF)
01090   return ::vfwprintf (fp, format, argptr);
01091 #else
01092   ACE_UNUSED_ARG (fp);
01093   ACE_UNUSED_ARG (format);
01094   ACE_UNUSED_ARG (argptr);
01095   ACE_NOTSUP_RETURN (-1);
01096 #endif /* ACE_HAS_VFWPRINTF */
01097 }

int ACE_OS::vfprintf ( FILE *  fp,
const char *  format,
va_list  argptr 
) [inline]

Definition at line 1073 of file OS_NS_stdio.inl.

01074 {
01075 #ifdef ACE_LACKS_VFPRINTF
01076   ACE_UNUSED_ARG (fp);
01077   ACE_UNUSED_ARG (format);
01078   ACE_UNUSED_ARG (argptr);
01079   ACE_NOTSUP_RETURN (-1);
01080 #else
01081   return ACE_STD_NAMESPACE::vfprintf (fp, format, argptr);
01082 #endif
01083 }

int ACE_OS::vprintf ( const wchar_t format,
va_list  argptr 
) [inline]

Definition at line 1060 of file OS_NS_stdio.inl.

01061 {
01062 #if defined (ACE_HAS_VWPRINTF)
01063   return ::vwprintf (format, argptr);
01064 #else
01065   ACE_UNUSED_ARG (format);
01066   ACE_UNUSED_ARG (argptr);
01067   ACE_NOTSUP_RETURN (-1);
01068 #endif /* ACE_HAS_VWPRINTF */
01069 }

int ACE_OS::vprintf ( const char *  format,
va_list  argptr 
) [inline]

Definition at line 1047 of file OS_NS_stdio.inl.

01048 {
01049 #if defined (ACE_LACKS_VPRINTF)
01050   ACE_UNUSED_ARG (format);
01051   ACE_UNUSED_ARG (argptr);
01052   ACE_NOTSUP_RETURN (-1);
01053 #else
01054   return ::vprintf (format, argptr);
01055 #endif /* ACE_LACKS_VPRINTF */
01056 }

int ACE_OS::vsnprintf ( wchar_t buffer,
size_t  maxlen,
const wchar_t format,
va_list  argptr 
) [inline]

Definition at line 1199 of file OS_NS_stdio.inl.

01200 {
01201 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
01202      (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \
01203      (defined (ACE_HAS_DINKUM_STL) || defined (__DMC__)) || \
01204       defined (ACE_HAS_VSWPRINTF) || \
01205       defined (ACE_WIN32)
01206 
01207   int result;
01208 
01209 # if defined (ACE_WIN32) && !defined (ACE_HAS_C99_VSNWPRINTF)
01210   // Microsoft's vswprintf() doesn't have the maxlen argument that
01211   // XPG4/UNIX98 define. They do, however, recommend use of _vsnwprintf()
01212   // as a substitute, which does have the same signature as the UNIX98 one.
01213   result = ::_vsnwprintf (buffer, maxlen, format, ap);
01214 
01215   // Win32 doesn't regard a full buffer with no 0-terminate as an overrun.
01216   if (result == static_cast<int> (maxlen) && maxlen > 0)
01217     buffer[maxlen-1] = '\0';
01218 
01219   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01220   if (result == -1 && maxlen > 0)
01221     buffer[maxlen-1] = '\0';
01222 # else
01223   result = vswprintf (buffer, maxlen, format, ap);
01224 #endif
01225 
01226   // In out-of-range conditions, C99 defines vsnprintf() to return the
01227   // number of characters that would have been written if enough space
01228   // was available.  Earlier variants of the vsnprintf() (e.g. UNIX98)
01229   // defined it to return -1. This method follows the C99 standard,
01230   // but needs to guess at the value; uses maxlen + 1.
01231   // Note that a formatting failure also returns -1. On RHEL this is
01232   // errno EINVAL. Don't indicate a simple memory shortage for that.
01233   if (result == -1 && errno != EINVAL)
01234     result = static_cast <int> (maxlen + 1);
01235 
01236   return result;
01237 # else
01238   ACE_UNUSED_ARG (buffer);
01239   ACE_UNUSED_ARG (maxlen);
01240   ACE_UNUSED_ARG (format);
01241   ACE_UNUSED_ARG (ap);
01242   ACE_NOTSUP_RETURN (-1);
01243 # endif /* platforms with a variant of vswprintf */
01244 }

int ACE_OS::vsnprintf ( char *  buffer,
size_t  maxlen,
const char *  format,
va_list  argptr 
) [inline]

Definition at line 1156 of file OS_NS_stdio.inl.

01157 {
01158 #if !defined (ACE_LACKS_VSNPRINTF)
01159   int result;
01160 # if defined (ACE_WIN32) && !defined (ACE_HAS_C99_VSNPRINTF)
01161   result = ::_vsnprintf (buffer, maxlen, format, ap);
01162 
01163   // Win32 doesn't regard a full buffer with no 0-terminate as an overrun.
01164   if (result == static_cast<int> (maxlen) && maxlen > 0)
01165     buffer[maxlen-1] = '\0';
01166 
01167   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01168   if (result == -1 && maxlen > 0)
01169     buffer[maxlen-1] = '\0';
01170 # else
01171   result = ::vsnprintf (buffer, maxlen, format, ap);
01172 # endif
01173   // In out-of-range conditions, C99 defines vsnprintf() to return the number
01174   // of characters that would have been written if enough space was available.
01175   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
01176   // -1. This method follows the C99 standard, but needs to guess at the
01177   // value; uses maxlen + 1.
01178   if (result == -1)
01179     {
01180       result = static_cast <int> (maxlen + 1);
01181     }
01182 
01183   return result;
01184 #elif defined (ACE_HAS_TRIO)
01185   return trio_vsnprintf (buffer, maxlen, format, ap);
01186 #elif defined (ACE_HAS_VSNPRINTF_EMULATION)
01187   return vsnprintf_emulation (buffer, maxlen, format, ap);
01188 #else
01189   ACE_UNUSED_ARG (buffer);
01190   ACE_UNUSED_ARG (maxlen);
01191   ACE_UNUSED_ARG (format);
01192   ACE_UNUSED_ARG (ap);
01193   ACE_NOTSUP_RETURN (-1);
01194 #endif /* ACE_LACKS_VSNPRINTF */
01195 }

int ACE_OS::vsprintf ( wchar_t buffer,
const wchar_t format,
va_list  argptr 
) [inline]

Definition at line 1115 of file OS_NS_stdio.inl.

01116 {
01117 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
01118      (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \
01119       defined (ACE_HAS_DINKUM_STL) || defined (__DMC__) || \
01120       defined (ACE_HAS_VSWPRINTF) || \
01121       (defined (ACE_WIN32_VC10) && !defined (ACE_HAS_WINCE)) || \
01122       (defined (ACE_WIN32_VC9) && !defined (ACE_HAS_WINCE)) || \
01123       (defined (ACE_WIN32_VC8) && !defined (ACE_HAS_WINCE) && \
01124       _MSC_FULL_VER > 140050000)
01125 
01126   // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a
01127   // maxlen argument. Since this method doesn't supply one, pass in
01128   // a length that works (ULONG_MAX doesn't on all platform since some check
01129   // to see if the operation will remain in bounds). If this isn't ok, use
01130   // ACE_OS::snprintf().
01131   return vswprintf (buffer, 4096, format, argptr);
01132 
01133 # elif defined (__MINGW64_VERSION_MAJOR) && !defined (WIN64)
01134   // the MingW64 32bit version causes link errors when using the
01135   // 'standard' vswprint(). Luckily they have a mingw special.
01136 
01137   return __mingw_vswprintf (buffer, format, argptr);
01138 
01139 # elif defined (ACE_WIN32)
01140   // Windows has vswprintf, but the pre-VC8 signature is from the older
01141   // ISO C standard. Also see ACE_OS::snprintf() for more info on this.
01142 
01143   return vswprintf (buffer, format, argptr);
01144 
01145 # else
01146   ACE_UNUSED_ARG (buffer);
01147   ACE_UNUSED_ARG (format);
01148   ACE_UNUSED_ARG (argptr);
01149   ACE_NOTSUP_RETURN (-1);
01150 
01151 # endif /* XPG5 || ACE_HAS_DINKUM_STL */
01152 }

int ACE_OS::vsprintf ( char *  buffer,
const char *  format,
va_list  argptr 
) [inline]

Definition at line 1101 of file OS_NS_stdio.inl.

01102 {
01103 #ifdef ACE_LACKS_VSPRINTF
01104   ACE_UNUSED_ARG (buffer);
01105   ACE_UNUSED_ARG (format);
01106   ACE_UNUSED_ARG (argptr);
01107   ACE_NOTSUP_RETURN (-1);
01108 #else
01109   return ::vsprintf (buffer, format, argptr);
01110 #endif /* ACE_LACKS_VSPRINTF */
01111 }

pid_t ACE_OS::wait ( pid_t  pid,
ACE_exitcode status,
int  wait_options = 0,
ACE_HANDLE  handle = 0 
)

Calls WaitForSingleObject on Win32 and ACE::waitpid () otherwise. Returns the passed in pid_t on success and -1 on failure. On Win32, pid is ignored if the handle is not equal to 0. Passing the process handle is prefer on Win32 because using pid to wait on the project doesn't always work correctly if the waited process has already terminated.

Definition at line 84 of file OS_NS_sys_wait.inl.

00088 {
00089   ACE_OS_TRACE ("ACE_OS::wait");
00090   return ACE_OS::waitpid (pid,
00091                           status,
00092                           wait_options,
00093                           handle);
00094 }

pid_t ACE_OS::wait ( int *  status = 0  ) 

Calls OS wait function, so it's only portable to UNIX/POSIX platforms.

Definition at line 8 of file OS_NS_sys_wait.inl.

00009 {
00010   ACE_OS_TRACE ("ACE_OS::wait");
00011 #if defined (ACE_LACKS_WAIT)
00012   ACE_UNUSED_ARG (status);
00013   ACE_NOTSUP_RETURN (-1);
00014 #else
00015   ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
00016 #endif /* ACE_LACKS_WAIT */
00017 }

pid_t ACE_OS::waitpid ( pid_t  pid,
ACE_exitcode status = 0,
int  wait_options = 0,
ACE_HANDLE  handle = 0 
)

Calls waitpid on UNIX/POSIX platforms Does not work on VxWorks 5.5.x. On Win32, pid is ignored if the handle is not equal to 0. Passing the process handle is prefer on Win32 because using pid to wait on the project doesn't always work correctly if the waited process has already terminated.

Definition at line 20 of file OS_NS_sys_wait.inl.

00024 {
00025   ACE_OS_TRACE ("ACE_OS::waitpid");
00026 #if defined (ACE_LACKS_WAITPID)
00027   ACE_UNUSED_ARG (pid);
00028   ACE_UNUSED_ARG (status);
00029   ACE_UNUSED_ARG (wait_options);
00030   ACE_UNUSED_ARG (handle);
00031 
00032   ACE_NOTSUP_RETURN (-1);
00033 #elif defined (ACE_WIN32)
00034   int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
00035     ? 0 /* don't hang */
00036     : INFINITE;
00037 
00038   ACE_HANDLE phandle = handle;
00039 
00040   if (phandle == 0)
00041     {
00042       phandle = ::OpenProcess (SYNCHRONIZE,
00043                                FALSE,
00044                                pid);
00045 
00046       if (phandle == 0)
00047         {
00048           ACE_OS::set_errno_to_last_error ();
00049           return -1;
00050         }
00051     }
00052 
00053   pid_t result = pid;
00054 
00055   // Don't try to get the process exit status if wait failed so we can
00056   // keep the original error code intact.
00057   switch (::WaitForSingleObject (phandle, blocking_period))
00058     {
00059     case WAIT_OBJECT_0:
00060       if (status != 0)
00061         // The error status of <GetExitCodeProcess> is nonetheless
00062         // not tested because we don't know how to return the value.
00063         ::GetExitCodeProcess (phandle, status);
00064       break;
00065     case WAIT_TIMEOUT:
00066       errno = ETIME;
00067       result = 0;
00068       break;
00069     default:
00070       ACE_OS::set_errno_to_last_error ();
00071       result = -1;
00072     }
00073   if (handle == 0)
00074     ::CloseHandle (phandle);
00075   return result;
00076 #else
00077   ACE_UNUSED_ARG (handle);
00078   ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
00079                      pid_t, -1);
00080 #endif /* ACE_LACKS_WAITPID */
00081 }

ssize_t ACE_OS::write ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_OVERLAPPED overlapped 
) [inline]

Definition at line 1233 of file OS_NS_unistd.inl.

01237 {
01238   ACE_OS_TRACE ("ACE_OS::write");
01239 #if defined (ACE_WIN32)
01240   DWORD bytes_written; // This is set to 0 byte WriteFile.
01241 
01242   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01243   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped))
01244     return (ssize_t) bytes_written;
01245   else
01246     ACE_FAIL_RETURN (-1);
01247 #else
01248   ACE_UNUSED_ARG (overlapped);
01249   return ACE_OS::write (handle, buf, nbyte);
01250 #endif /* ACE_WIN32 */
01251 }

ssize_t ACE_OS::write ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte 
) [inline]

Definition at line 1210 of file OS_NS_unistd.inl.

01211 {
01212   ACE_OS_TRACE ("ACE_OS::write");
01213 #if defined (ACE_WIN32)
01214   DWORD bytes_written; // This is set to 0 byte WriteFile.
01215 
01216   // Strictly correctly, we should loop writing all the data if more
01217   // than a DWORD length can hold.
01218   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01219   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0))
01220     return (ssize_t) bytes_written;
01221   else
01222     ACE_FAIL_RETURN (-1);
01223 #else
01224 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
01225   ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1);
01226 # else
01227   ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
01228 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
01229 #endif /* ACE_WIN32 */
01230 }

ssize_t ACE_OS::write_n ( ACE_HANDLE  handle,
const void *  buf,
size_t  len,
size_t bytes_transferred = 0 
)

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

Definition at line 957 of file OS_NS_unistd.cpp.

00961 {
00962   size_t temp;
00963   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00964   ssize_t n;
00965 
00966   for (bytes_transferred = 0;
00967        bytes_transferred < len;
00968        bytes_transferred += n)
00969     {
00970       n = ACE_OS::write (handle,
00971                          (char *) buf + bytes_transferred,
00972                          len - bytes_transferred);
00973 
00974       if (n == -1 || n == 0)
00975         {
00976           return n;
00977         }
00978     }
00979 
00980   return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred);
00981 }

ssize_t ACE_OS::writev ( ACE_HANDLE  handle,
const iovec iov,
int  iovcnt 
) [inline]

Definition at line 30 of file OS_NS_sys_uio.inl.

00033 {
00034   ACE_OS_TRACE ("ACE_OS::writev");
00035 #if defined (ACE_LACKS_WRITEV)
00036   ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle,
00037                                                iov,
00038                                                iovcnt), ssize_t, -1);
00039 #else /* ACE_LACKS_WRITEV */
00040 #if defined (ACE_HAS_NONCONST_WRITEV)
00041   ACE_OSCALL_RETURN (::writev (handle,
00042                                const_cast<iovec *>(iov),
00043                                iovcnt), ssize_t, -1);
00044 #else
00045   ACE_OSCALL_RETURN (::writev (handle,
00046                                iov,
00047                                iovcnt), ssize_t, -1);
00048 #endif /* ACE_HAS_NONCONST_WRITEV */
00049 #endif /* ACE_LACKS_WRITEV */
00050 }

int ACE_OS::wscmp ( const WChar *  s,
const WChar *  t 
) [inline]

Definition at line 40 of file OS_NS_wchar.inl.

00041 {
00042   const WChar *scan1 = s;
00043   const WChar *scan2 = t;
00044 
00045   while (*scan1 != 0 && *scan1 == *scan2)
00046     {
00047       ++scan1;
00048       ++scan2;
00049     }
00050 
00051   return *scan1 - *scan2;
00052 }

ACE_OS::WChar * ACE_OS::wscpy ( WChar *  dest,
const WChar *  src 
) [inline]

Definition at line 29 of file OS_NS_wchar.inl.

00030 {
00031   WChar *original_dest = dest;
00032 
00033   while ((*dest++ = *src++) != 0)
00034     continue;
00035 
00036   return original_dest;
00037 }

u_int ACE_OS::wslen ( const WChar *  s  )  [inline]

Definition at line 18 of file OS_NS_wchar.inl.

00019 {
00020   u_int len = 0;
00021 
00022   while (*s++ != 0)
00023     len++;
00024 
00025   return len;
00026 }

int ACE_OS::wsncmp ( const WChar *  s,
const WChar *  t,
size_t  len 
) [inline]

Definition at line 55 of file OS_NS_wchar.inl.

00056 {
00057   const WChar *scan1 = s;
00058   const WChar *scan2 = t;
00059 
00060   while (len != 0 && *scan1 != 0 && *scan1 == *scan2)
00061     {
00062       ++scan1;
00063       ++scan2;
00064       --len;
00065     }
00066 
00067   return len == 0 ? 0 : *scan1 - *scan2;
00068 }


Variable Documentation

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 35 of file OS_NS_stdlib.cpp.

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

Definition at line 1064 of file OS_NS_Thread.cpp.

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

Definition at line 1068 of file OS_NS_Thread.cpp.

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1063 of file OS_NS_Thread.cpp.

Keeps track of whether we've already initialized WinSock...

Definition at line 12 of file OS_NS_sys_socket.cpp.

Definition at line 26 of file OS_NS_stdio.cpp.

ACE_TEXT_OSVERSIONINFO ACE_OS::win32_versioninfo_

Definition at line 25 of file OS_NS_stdio.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for ACE by  doxygen 1.6.1