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

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_".

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isalnum (ACE_TCHAR c)
 Returns true if the character is an alphanumeric character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isalpha (ACE_TCHAR c)
 Returns true if the character is an alphabetic character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_iscntrl (ACE_TCHAR c)
 Returns true if the character is a control character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isdigit (ACE_TCHAR c)
 Returns true if the character is a decimal-digit character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isgraph (ACE_TCHAR c)
 Returns true if the character is a printable character other than a space.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_islower (ACE_TCHAR c)
 Returns true if the character is a lowercase character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isprint (ACE_TCHAR c)
 Returns true if the character is a printable character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_ispunct (ACE_TCHAR c)
 Returns true if the character is a punctuation character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isspace (ACE_TCHAR c)
 Returns true if the character is a space character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isupper (ACE_TCHAR c)
 Returns true if the character is an uppercase character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isxdigit (ACE_TCHAR c)
 Returns true if the character is a hexadecimal-digit character.
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_tolower (int c)
 Converts a character to lower case (char version).
ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_toupper (int c)
 Converts a character to upper case (char version).
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
struct passwd * 
getpwnam_r (const char *name, struct passwd *pwent, char *buffer, int buflen)
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)
ACE_NAMESPACE_INLINE_FUNCTION
int 
kill (pid_t pid, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
int 
pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigaction (int signum, const ACE_SIGACTION *nsa, ACE_SIGACTION *osa)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigaddset (sigset_t *s, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigdelset (sigset_t *s, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigemptyset (sigset_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigfillset (sigset_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigismember (sigset_t *s, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_SignalHandler 
signal (int signum, ACE_SignalHandler)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigsuspend (const sigset_t *set)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
cuserid (char *user, size_t maxlen=ACE_MAX_USERID)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_init (ace_flock_t *lock, int flags=0, const ACE_TCHAR *name=0, mode_t perms=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_destroy (ace_flock_t *lock, int unlink_file=1)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_rdlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_tryrdlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_trywrlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_unlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_wrlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0)

Non-standard functions

These functions aren't in the standard.

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

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_BEGIN_VERSIONED_NAMESPACE_DECL
char * 
strecpy (char *s, const char *t)
char * strerror (int errnum)
const char * strnchr (const char *s, int c, size_t len)
const ACE_WCHAR_T * strnchr (const ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
const char * strnstr (const char *s1, const char *s2, size_t len2)
const ACE_WCHAR_T * strnstr (const ACE_WCHAR_T *s1, const ACE_WCHAR_T *s2, size_t len2)
char * strsncpy (char *dst, const char *src, size_t maxlen)
 This is a "safe" c string copy function (char version).
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
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_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_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
const char * 
strchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strchr (char *s, int c)
 Finds the first occurance of a character in a string (char 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
size_t 
strcspn (const char *s, const char *reject)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strdup (const char *s)
 Returns a malloced duplicated string (char 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_NAMESPACE_INLINE_FUNCTION
char * 
strnchr (char *s, int c, size_t len)
 Finds the first occurance 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 occurance 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_NAMESPACE_INLINE_FUNCTION
char * 
strnstr (char *s, const char *t, size_t len)
 Finds the first occurance 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 occurance 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
char * 
strpbrk (char *s1, const char *s2)
 Searches for characters in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strrchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strrchr (char *s, int c)
 Finds the last occurance of a character in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const char *s1, const char *s2)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strstr (const char *s, const char *t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strstr (char *s, const char *t)
 Finds the first occurance of a substring in a string (char 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
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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_HANDLE 
accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen, const ACE_Accept_QoS_Params &qos_params)
int connect (ACE_HANDLE handle, const sockaddr *addr, int addrlen, const ACE_QoS_Params &qos_params)
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 socket_init (int version_high, int version_low)
int socket_fini (void)
 Finalize WinSock after last use (e.g., when a DLL is unloaded).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
bind (ACE_HANDLE s, struct sockaddr *name, int namelen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
closesocket (ACE_HANDLE s)
 Takes care of windows specific requirement to call closesocket.
ACE_NAMESPACE_INLINE_FUNCTION
int 
connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
 BSD-style <connect> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
enum_protocols (int *protocols, ACE_Protocol_Info *protocol_buffer, u_long *buffer_length)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getpeername (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
listen (ACE_HANDLE handle, int backlog)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recv (ACE_HANDLE handle, char *buf, size_t len, int flags=0)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvfrom (ACE_HANDLE handle, char *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
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).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvv (ACE_HANDLE handle, iovec *iov, int iovlen)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
send (ACE_HANDLE handle, const char *buf, size_t len, int flags=0)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
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).
ACE_NAMESPACE_INLINE_FUNCTION
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).
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
int 
setsockopt (ACE_HANDLE handle, int level, int optname, const char *optval, int optlen)
 Manipulate the options associated with a socket.
ACE_NAMESPACE_INLINE_FUNCTION
int 
shutdown (ACE_HANDLE handle, int how)
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
socket (int protocol_family, int type, int proto)
 Create a BSD-style socket (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
socket (int protocol_family, int type, int proto, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
socketpair (int domain, int type, int protocol, ACE_HANDLE sv[2])
 BSD-style <accept> (no QoS).
ACE_NAMESPACE_INLINE_FUNCTION
ACE_OFF_T 
filesize (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_OFF_T 
filesize (const ACE_TCHAR *handle)
int cond_init (ACE_cond_t *cv, short type, const char *name, void *arg)
int event_destroy (ACE_event_t *event)
int event_init (ACE_event_t *event, int manual_reset, int initial_state, int type, const char *name, void *arg, LPSECURITY_ATTRIBUTES sa)
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)
int event_wait (ACE_event_t *event)
ACE_NAMESPACE_INLINE_FUNCTION
int 
condattr_init (ACE_condattr_t &attributes, int type=ACE_DEFAULT_SYNCH_TYPE)
ACE_NAMESPACE_INLINE_FUNCTION
int 
condattr_destroy (ACE_condattr_t &attributes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_broadcast (ACE_cond_t *cv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_destroy (ACE_cond_t *cv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const char *name=0, void *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_signal (ACE_cond_t *cv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_timedwait (ACE_cond_t *cv, ACE_mutex_t *m, ACE_Time_Value *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_wait (ACE_cond_t *cv, ACE_mutex_t *m)
int mutex_init (ACE_mutex_t *m, int lock_scope, const char *name, ACE_mutexattr_t *attributes, LPSECURITY_ATTRIBUTES sa, int lock_type)
int mutex_destroy (ACE_mutex_t *m)
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_trylock (ACE_mutex_t *m)
int mutex_trylock (ACE_mutex_t *m, int &abandoned)
int mutex_unlock (ACE_mutex_t *m)
void mutex_lock_cleanup (void *mutex)
 Handle asynchronous thread cancellation cleanup.
ACE_NAMESPACE_INLINE_FUNCTION
int 
mutex_lock (ACE_mutex_t *m, const ACE_Time_Value *timeout)
int rwlock_init (ACE_rwlock_t *rw, int type, const ACE_TCHAR *name, void *arg)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_rdlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_tryrdlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_trywrlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_trywrlock_upgrade (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_unlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_wrlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rwlock_destroy (ACE_rwlock_t *rw)
int sched_params (const ACE_Sched_Params &sched_params, ACE_id_t id)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
ACE_NAMESPACE_INLINE_FUNCTION
void 
recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_init (ACE_recursive_thread_mutex_t *m, const ACE_TCHAR *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_lock (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value &timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value *timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_destroy (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
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)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_post (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_post (ACE_sema_t *s, u_int release_count)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_trywait (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_wait (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_wait (ACE_sema_t *s, ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_wait (ACE_sema_t *s, ACE_Time_Value *tv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
semctl (int int_id, int semnum, int cmd, semun)
ACE_NAMESPACE_INLINE_FUNCTION
int 
semget (key_t key, int nsems, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
semop (int int_id, struct sembuf *sops, size_t nsops)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_destroy (ACE_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_init (ACE_thread_mutex_t *m, int lock_type=0, const char *name=0, ACE_mutexattr_t *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_lock (ACE_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value &timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value *timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_trylock (ACE_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_unlock (ACE_thread_mutex_t *m)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
struct tm * 
localtime_r (const time_t *t, struct tm *res)
time_t mktime (struct tm *t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
asctime (const struct tm *tm)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
asctime_r (const struct tm *tm, char *buf, int buflen)
ACE_NAMESPACE_INLINE_FUNCTION
int 
clock_gettime (clockid_t, struct timespec *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
clock_settime (clockid_t, const struct timespec *)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
ctime (const time_t *t)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
ACE_NAMESPACE_INLINE_FUNCTION
double 
difftime (time_t t1, time_t t0)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_hrtime_t 
gethrtime (const ACE_HRTimer_Op=ACE_HRTIMER_GETTIME)
ACE_NAMESPACE_INLINE_FUNCTION
struct tm * 
gmtime (const time_t *clock)
ACE_NAMESPACE_INLINE_FUNCTION
struct tm * 
gmtime_r (const time_t *clock, struct tm *res)
ACE_NAMESPACE_INLINE_FUNCTION
struct tm * 
localtime (const time_t *clock)
ACE_NAMESPACE_INLINE_FUNCTION
int 
nanosleep (const struct timespec *requested, struct timespec *remaining=0)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strptime (const char *buf, const char *format, struct tm *tm)
ACE_NAMESPACE_INLINE_FUNCTION
time_t 
time (time_t *tloc=0)
ACE_NAMESPACE_INLINE_FUNCTION
long 
timezone (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
tzset (void)
pid_t fork (const ACE_TCHAR *program_name)
pid_t fork_exec (ACE_TCHAR *argv[])
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
fork (void)
ACE_Export ACE_thread_t NULL_thread
ACE_Export ACE_hthread_t NULL_hthread
ACE_Export ACE_thread_key_t NULL_key

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_BEGIN_VERSIONED_NAMESPACE_DECL
int 
inet_aton (const char *host_name, struct in_addr *addr)
ACE_NAMESPACE_INLINE_FUNCTION
unsigned long 
inet_addr (const char *name)
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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE unsigned long 
inet_addr (const char *name)
ACE_INLINE char * inet_ntoa (const struct in_addr addr)
ACE_INLINE const char * inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
ACE_INLINE int inet_pton (int family, const char *strptr, void *addrptr)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
ace_isalnum (ACE_TCHAR c)
 Returns true if the character is an alphanumeric character.
ACE_INLINE int ace_isalpha (ACE_TCHAR c)
 Returns true if the character is an alphabetic character.
ACE_INLINE int ace_iscntrl (ACE_TCHAR c)
 Returns true if the character is a control character.
ACE_INLINE int ace_isdigit (ACE_TCHAR c)
 Returns true if the character is a decimal-digit character.
ACE_INLINE int ace_isgraph (ACE_TCHAR c)
 Returns true if the character is a printable character other than a space.
ACE_INLINE int ace_islower (ACE_TCHAR c)
 Returns true if the character is a lowercase character.
ACE_INLINE int ace_isprint (ACE_TCHAR c)
 Returns true if the character is a printable character.
ACE_INLINE int ace_ispunct (ACE_TCHAR c)
 Returns true if the character is a punctuation character.
ACE_INLINE int ace_isspace (ACE_TCHAR c)
 Returns true if the character is a space character.
ACE_INLINE int ace_isupper (ACE_TCHAR c)
 Returns true if the character is an uppercase character.
ACE_INLINE int ace_isxdigit (ACE_TCHAR c)
 Returns true if the character is a hexadecimal-digit character.
ACE_INLINE int ace_tolower (int c)
 Converts a character to lower case (char version).
ACE_INLINE int ace_toupper (int c)
 Converts a character to upper case (char version).
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int 
scandir_emulation (const ACE_TCHAR *dirname, ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator)
ACE_NAMESPACE_INLINE_FUNCTION
void 
closedir (ACE_DIR *)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_DIR
opendir (const ACE_TCHAR *filename)
ACE_NAMESPACE_INLINE_FUNCTION
struct ACE_DIRENT * 
readdir (ACE_DIR *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
readdir_r (ACE_DIR *dirp, struct ACE_DIRENT *entry, struct ACE_DIRENT **result)
ACE_NAMESPACE_INLINE_FUNCTION
void 
rewinddir (ACE_DIR *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
scandir (const ACE_TCHAR *dirname, struct ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator)
ACE_NAMESPACE_INLINE_FUNCTION
int 
alphasort (const void *, const void *)
ACE_NAMESPACE_INLINE_FUNCTION
void 
seekdir (ACE_DIR *, long loc)
ACE_NAMESPACE_INLINE_FUNCTION
long 
telldir (ACE_DIR *)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
dlclose (ACE_SHLIB_HANDLE handle)
ACE_INLINE ACE_TCHARdlerror (void)
ACE_INLINE ACE_SHLIB_HANDLE dlopen (const ACE_TCHAR *fname, int mode)
ACE_INLINE void * dlsym (ACE_SHLIB_HANDLE handle, const ACE_TCHAR *sname)
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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
last_error (void)
ACE_INLINE void last_error (int error)
ACE_INLINE int set_errno_to_last_error (void)
ACE_INLINE int set_errno_to_wsa_last_error (void)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_HANDLE 
open (const char *filename, int mode, mode_t perms, LPSECURITY_ATTRIBUTES sa)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fcntl (ACE_HANDLE handle, int cmd, long arg=0)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
fcntl (ACE_HANDLE handle, int cmd, long arg)
ACE_NAMESPACE_INLINE_FUNCTION
double 
floor (double x)
 This method computes the largest integral value not greater than x.
ACE_NAMESPACE_INLINE_FUNCTION
double 
ceil (double x)
 This method computes the smallest integral value not less than x.
ACE_NAMESPACE_INLINE_FUNCTION
double 
log2 (double x)
 This method computes the base-2 logarithm of x.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_END_VERSIONED_NAMESPACE_DECL
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int 
getmacaddress (struct macaddr_node_t *node)
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_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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE struct hostent * 
gethostbyaddr (const char *addr, int length, int type)
ACE_INLINE struct hostent * gethostbyaddr_r (const char *addr, int length, int type, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_INLINE struct hostent * gethostbyname (const char *name)
ACE_INLINE struct hostent * gethostbyname_r (const char *name, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_INLINE struct hostent * getipnodebyaddr (const void *src, size_t len, int family)
ACE_INLINE struct hostent * getipnodebyname (const char *name, int family, int flags)
ACE_INLINE struct protoent * getprotobyname (const char *name)
ACE_INLINE struct protoent * getprotobyname_r (const char *name, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_INLINE struct protoent * getprotobynumber (int proto)
ACE_INLINE struct protoent * getprotobynumber_r (int proto, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_INLINE struct servent * getservbyname (const char *svc, const char *proto)
ACE_INLINE struct servent * getservbyname_r (const char *svc, const char *proto, struct servent *result, ACE_SERVENT_DATA buf)
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)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value *timeout)
ACE_INLINE int poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value &timeout)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void 
endpwent (void)
ACE_INLINE struct passwd * getpwent (void)
ACE_INLINE struct passwd * getpwnam (const char *name)
ACE_INLINE struct passwd * getpwnam_r (const char *name, struct passwd *pwent, char *buffer, int buflen)
ACE_INLINE void setpwent (void)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE char * 
compile (const char *instring, char *expbuf, char *endbuf)
ACE_INLINE int step (const char *str, char *expbuf)
int fprintf (FILE *fp, const char *format,...)
int asprintf (char **bufp, const char *format,...)
int printf (const char *format,...)
int snprintf (char *buf, size_t maxlen, const char *format,...)
int sprintf (char *buf, const char *format,...)
int vasprintf_emulation (char **bufp, const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
void 
clearerr (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fclose (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
FILE * 
fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fflush (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fgetc (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getc (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fgetpos (FILE *fp, fpos_t *pos)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
fgets (char *buf, int size, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
FILE * 
fopen (const char *filename, const ACE_TCHAR *mode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
ungetc (int c, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fputc (int c, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putc (int c, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fputs (const char *s, FILE *stream)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
fread (void *ptr, size_t size, size_t nelems, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
FILE * 
freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE *stream)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fseek (FILE *fp, long offset, int ptrname)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fsetpos (FILE *fp, fpos_t *pos)
ACE_NAMESPACE_INLINE_FUNCTION
long 
ftell (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
void 
perror (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
puts (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rename (const char *old_name, const char *new_name, int flags=-1)
ACE_NAMESPACE_INLINE_FUNCTION
void 
rewind (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
tempnam (const char *dir=0, const char *pfx=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vasprintf (char **bufp, const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vprintf (const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vfprintf (FILE *fp, const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsprintf (char *buffer, const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
flock_init (ACE_OS::ace_flock_t *lock, int flags, const ACE_TCHAR *name, mode_t perms)
ACE_INLINE int flock_unlock (ACE_OS::ace_flock_t *lock, short whence, ACE_OFF_T start, ACE_OFF_T len)
ACE_INLINE int flock_destroy (ACE_OS::ace_flock_t *lock, int unlink_file)
ACE_INLINE int flock_rdlock (ACE_OS::ace_flock_t *lock, short whence, ACE_OFF_T start, ACE_OFF_T len)
ACE_INLINE int flock_tryrdlock (ACE_OS::ace_flock_t *lock, short whence, ACE_OFF_T start, ACE_OFF_T len)
ACE_INLINE int flock_trywrlock (ACE_OS::ace_flock_t *lock, short whence, ACE_OFF_T start, ACE_OFF_T len)
ACE_INLINE int flock_wrlock (ACE_OS::ace_flock_t *lock, short whence, ACE_OFF_T start, ACE_OFF_T len)
ACE_INLINE void clearerr (FILE *fp)
ACE_INLINE char * cuserid (char *user, size_t maxlen)
ACE_INLINE int fclose (FILE *fp)
ACE_INLINE FILE * fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode)
ACE_INLINE int fflush (FILE *fp)
ACE_INLINE int fgetc (FILE *fp)
ACE_INLINE int getc (FILE *fp)
ACE_INLINE int fgetpos (FILE *fp, fpos_t *pos)
ACE_INLINE char * fgets (char *buf, int size, FILE *fp)
ACE_INLINE FILE * fopen (const char *filename, const ACE_TCHAR *mode)
ACE_INLINE int ungetc (int c, FILE *fp)
ACE_INLINE int fputc (int c, FILE *fp)
ACE_INLINE int putc (int c, FILE *fp)
ACE_INLINE int fputs (const char *s, FILE *stream)
ACE_INLINE size_t fread (void *ptr, size_t size, size_t nelems, FILE *fp)
ACE_INLINE FILE * freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE *stream)
ACE_INLINE int fseek (FILE *fp, long offset, int whence)
ACE_INLINE int fsetpos (FILE *fp, fpos_t *pos)
ACE_INLINE long ftell (FILE *fp)
ACE_INLINE size_t fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp)
ACE_INLINE void perror (const char *s)
ACE_INLINE int puts (const char *s)
ACE_INLINE int rename (const char *old_name, const char *new_name, int flags)
ACE_INLINE void rewind (FILE *fp)
ACE_INLINE char * tempnam (const char *dir, const char *pfx)
ACE_INLINE int vasprintf (char **bufp, const char *format, va_list argptr)
ACE_INLINE int vprintf (const char *format, va_list argptr)
ACE_INLINE int vfprintf (FILE *fp, const char *format, va_list argptr)
ACE_INLINE int vsprintf (char *buffer, const char *format, va_list argptr)
ACE_INLINE int vsnprintf (char *buffer, size_t maxlen, const char *format, va_list ap)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void 
_exit (int status)
ACE_INLINE void abort (void)
ACE_INLINE int atexit (ACE_EXIT_HOOK func)
ACE_INLINE int atoi (const char *s)
ACE_INLINE void * atop (const char *s)
ACE_INLINE void * bsearch (const void *key, const void *base, size_t nel, size_t size, ACE_COMPARE_FUNC compar)
ACE_INLINE char * getenv (const char *symbol)
ACE_INLINE char * itoa (int value, char *string, int radix)
 Converts an integer to a string.
ACE_INLINE ACE_HANDLE mkstemp (char *s)
ACE_INLINE char * mktemp (char *s)
ACE_INLINE int putenv (const char *string)
ACE_INLINE void qsort (void *base, size_t nel, size_t width, ACE_COMPARE_FUNC compar)
ACE_INLINE int rand (void)
ACE_INLINE int rand_r (ACE_RANDR_TYPE &seed)
ACE_INLINE char * realpath (const char *file_name, char *resolved_name)
ACE_INLINE ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK exit_hook)
 For use by ACE_Object_Manager only, to register its exit hook..
ACE_INLINE void srand (u_int seed)
ACE_INLINE double strtod (const char *s, char **endptr)
 Converts a string to a double value (char version).
ACE_INLINE long strtol (const char *s, char **ptr, int base)
 Converts a string to a long value (char version).
ACE_INLINE unsigned long strtoul (const char *s, char **ptr, int base)
 Converts a string to an unsigned long value (char version).
ACE_INLINE int system (const ACE_TCHAR *s)
ACE_INLINE const char * getprogname ()
ACE_INLINE void setprogname (const char *name)
char * strtok_r_emulation (char *s, const char *tokens, char **lasts)
 Emulated strtok_r.
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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE const void * 
memchr (const void *s, int c, size_t len)
 Finds characters in a buffer (const void version).
ACE_INLINE void * memchr (void *s, int c, size_t len)
 Finds characters in a buffer (void version).
ACE_INLINE int memcmp (const void *t, const void *s, size_t len)
 Compares two buffers.
ACE_INLINE void * memcpy (void *t, const void *s, size_t len)
 Copies one buffer to another.
ACE_INLINE void * memmove (void *t, const void *s, size_t len)
 Moves one buffer to another.
ACE_INLINE void * memset (void *s, int c, size_t len)
 Fills a buffer with a character value.
ACE_INLINE char * strcat (char *s, const char *t)
 Appends a string to another string (char version).
ACE_INLINE const char * strchr (const char *s, int c)
ACE_INLINE char * strchr (char *s, int c)
 Finds the first occurance of a character in a string (char version).
ACE_INLINE int strcmp (const char *s, const char *t)
 Compares two strings (char version).
ACE_INLINE int strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
 Compares two strings (wchar_t version).
ACE_INLINE char * strcpy (char *s, const char *t)
 Copies a string (char version).
ACE_INLINE size_t strcspn (const char *s, const char *reject)
ACE_INLINE char * strdup (const char *s)
 Returns a malloced duplicated string (char version).
ACE_INLINE size_t strlen (const char *s)
 Finds the length of a string (char version).
ACE_INLINE size_t strlen (const ACE_WCHAR_T *s)
 Finds the length of a string (ACE_WCHAR_T version).
ACE_INLINE char * strncat (char *s, const char *t, size_t len)
 Appends part of a string to another string (char version).
ACE_INLINE 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_INLINE char * strnchr (char *s, int c, size_t len)
 Finds the first occurance of a character in an array (char version).
ACE_INLINE ACE_WCHAR_T * strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
 Finds the first occurance of a character in an array (ACE_WCHAR_T version).
ACE_INLINE int strncmp (const char *s, const char *t, size_t len)
 Compares two arrays (char version).
ACE_INLINE int strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Compares two arrays (wchar_t version).
ACE_INLINE char * strncpy (char *s, const char *t, size_t len)
 Copies an array (char version).
ACE_INLINE ACE_WCHAR_T * strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Copies an array (ACE_WCHAR_T version).
ACE_INLINE size_t strnlen (const char *s, size_t maxlen)
 Finds the length of a limited-length string (char version).
ACE_INLINE size_t strnlen (const ACE_WCHAR_T *s, size_t maxlen)
 Finds the length of a limited-length string (ACE_WCHAR_T version).
ACE_INLINE char * strnstr (char *s, const char *t, size_t len)
 Finds the first occurance of a substring in an array (char version).
ACE_INLINE ACE_WCHAR_T * strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Finds the first occurance of a substring in an array (wchar_t version).
ACE_INLINE const char * strpbrk (const char *s1, const char *s2)
 Searches for characters in a string (const char version).
ACE_INLINE char * strpbrk (char *s1, const char *s2)
 Searches for characters in a string (char version).
ACE_INLINE const char * strrchr (const char *s, int c)
ACE_INLINE char * strrchr (char *s, int c)
 Finds the last occurance of a character in a string (char version).
ACE_INLINE size_t strspn (const char *s, const char *t)
ACE_INLINE const char * strstr (const char *s, const char *t)
ACE_INLINE char * strstr (char *s, const char *t)
 Finds the first occurance of a substring in a string (char version).
ACE_INLINE char * strtok (char *s, const char *tokens)
 Finds the next token in a string (char version).
ACE_INLINE char * strtok_r (char *s, const char *tokens, char **lasts)
 Finds the next token in a string (safe char 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 
strncasecmp (const char *s, const char *t, size_t len)
 Compares two arrays (case insensitive const char version).
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
strcasecmp (const char *s, const char *t)
 Compares two strings (case insensitive const char version).
ACE_INLINE int strncasecmp (const char *s, const char *t, size_t len)
 Compares two arrays (case insensitive const char version).
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
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, unsigned long buffer, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getpmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *band, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fattach (int handle, const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fdetach (const char *file)
ACE_NAMESPACE_INLINE_FUNCTION
int 
ioctl (ACE_HANDLE handle, ACE_IOCTL_TYPE_ARG2 cmd, void *=0)
 UNIX-style <ioctl>.
ACE_NAMESPACE_INLINE_FUNCTION
int 
isastream (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putpmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int band, int flags)
ACE_INLINE int getmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *flags)
ACE_INLINE int getpmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *band, int *flags)
ACE_INLINE int fattach (int handle, const char *path)
ACE_INLINE int fdetach (const char *file)
ACE_INLINE int ioctl (ACE_HANDLE handle, ACE_IOCTL_TYPE_ARG2 cmd, void *val)
 UNIX-style <ioctl>.
ACE_INLINE int isastream (ACE_HANDLE handle)
ACE_INLINE int putmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int flags)
ACE_INLINE 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_INLINE int madvise (caddr_t addr, size_t len, int map_advice)
ACE_INLINE void * mmap (void *addr, size_t len, int prot, int flags, ACE_HANDLE file_handle, ACE_OFF_T off, ACE_HANDLE *file_mapping, LPSECURITY_ATTRIBUTES sa, const ACE_TCHAR *file_mapping_name)
ACE_INLINE int mprotect (void *addr, size_t len, int prot)
ACE_INLINE int msync (void *addr, size_t len, int sync)
ACE_INLINE int munmap (void *addr, size_t len)
ACE_INLINE ACE_HANDLE shm_open (const ACE_TCHAR *filename, int mode, mode_t perms, LPSECURITY_ATTRIBUTES sa)
ACE_INLINE int shm_unlink (const ACE_TCHAR *path)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
msgctl (int msqid, int cmd, struct msqid_ds *val)
ACE_INLINE int msgget (key_t key, int msgflg)
ACE_INLINE ssize_t msgrcv (int int_id, void *buf, size_t len, long type, int flags)
ACE_INLINE int msgsnd (int int_id, const void *buf, size_t len, int flags)
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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
getrlimit (int resource, struct rlimit *rl)
ACE_INLINE int getrusage (int who, struct rusage *ru)
ACE_INLINE 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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value *timeout)
ACE_INLINE int select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &timeout)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ssize_t 
sendfile_emulation (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE 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_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void * 
shmat (int int_id, const void *shmaddr, int shmflg)
ACE_INLINE int shmctl (int int_id, int cmd, struct shmid_ds *buf)
ACE_INLINE int shmdt (const void *shmaddr)
ACE_INLINE int shmget (key_t key, size_t size, int flags)
ACE_INLINE ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style <accept> (no QoS).
ACE_INLINE int bind (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
ACE_INLINE int closesocket (ACE_HANDLE handle)
 Takes care of windows specific requirement to call closesocket.
ACE_INLINE int connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
 BSD-style <connect> (no QoS).
ACE_INLINE int enum_protocols (int *protocols, ACE_Protocol_Info *protocol_buffer, u_long *buffer_length)
ACE_INLINE int getpeername (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
ACE_INLINE int getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
ACE_INLINE int getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen)
ACE_INLINE int listen (ACE_HANDLE handle, int backlog)
ACE_INLINE ssize_t recv (ACE_HANDLE handle, char *buf, size_t len, int flags)
ACE_INLINE ssize_t recvfrom (ACE_HANDLE handle, char *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen)
ACE_INLINE 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)
ACE_INLINE ssize_t recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags)
ACE_INLINE ssize_t recvv (ACE_HANDLE handle, iovec *buffers, int n)
ACE_INLINE ssize_t send (ACE_HANDLE handle, const char *buf, size_t len, int flags)
ACE_INLINE ssize_t sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
ACE_INLINE ssize_t sendto (ACE_HANDLE handle, const char *buf, size_t len, int flags, const struct sockaddr *addr, int addrlen)
ACE_INLINE 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)
ACE_INLINE ssize_t sendv (ACE_HANDLE handle, const iovec *buffers, int n)
ACE_INLINE int setsockopt (ACE_HANDLE handle, int level, int optname, const char *optval, int optlen)
 Manipulate the options associated with a socket.
ACE_INLINE int shutdown (ACE_HANDLE handle, int how)
ACE_INLINE ACE_HANDLE socket (int domain, int type, int proto)
 Create a BSD-style socket (no QoS).
ACE_INLINE ACE_HANDLE socket (int domain, int type, int proto, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags)
ACE_INLINE int socketpair (int domain, int type, int protocol, ACE_HANDLE sv[2])
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
creat (const ACE_TCHAR *filename, mode_t mode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fstat (ACE_HANDLE, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
lstat (const char *, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkdir (const char *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkfifo (const ACE_TCHAR *file, mode_t mode=ACE_DEFAULT_FILE_PERMS)
ACE_NAMESPACE_INLINE_FUNCTION
int 
stat (const char *file, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
mode_t 
umask (mode_t cmask)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_Time_Value 
gettimeofday (void)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE ACE_Time_Value 
gettimeofday (void)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
readv (ACE_HANDLE handle, const iovec *iov, int iovlen)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
writev (ACE_HANDLE handle, const iovec *iov, int iovcnt)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE ssize_t 
readv (ACE_HANDLE handle, const iovec *iov, int iovlen)
ACE_INLINE ssize_t writev (ACE_HANDLE handle, const iovec *iov, int iovcnt)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int 
uname (ACE_utsname *name)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
wait (int *=0)
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)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE pid_t 
wait (int *status)
ACE_INLINE pid_t waitpid (pid_t pid, ACE_exitcode *status, int wait_options, ACE_HANDLE handle)
ACE_INLINE pid_t wait (pid_t pid, ACE_exitcode *status, int wait_options, ACE_HANDLE handle)
void cleanup_tss (const u_int main_thread)
int lwp_getparams (ACE_Sched_Params &sched_params)
int lwp_setparams (const ACE_Sched_Params &sched_params)
int scheduling_class (const char *class_name, ACE_id_t &)
 Find the schedling 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 thr_create (ACE_THR_FUNC func, void *args, long flags, ACE_thread_t *thr_id, ACE_hthread_t *thr_handle, long priority, void *stack, size_t stacksize, ACE_Base_Thread_Adapter *thread_adapter, const char **thr_name)
void thr_exit (ACE_THR_FUNC_RETURN status)
int thr_key_detach (ACE_thread_key_t key, void *)
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_used (ACE_thread_key_t key)
int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST dest, void *)
int thr_keyfree (ACE_thread_key_t key)
int thr_setprio (const ACE_Sched_Priority prio)
int thr_setspecific (ACE_thread_key_t key, void *data)
void unique_name (const void *object, char *name, size_t length)
ACE_NAMESPACE_INLINE_FUNCTION
long 
priority_control (ACE_idtype_t, ACE_id_t, int, void *)
 Low-level interface to <priocntl>(2).
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigtimedwait (const sigset_t *set, siginfo_t *info, const ACE_Time_Value *timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigwait (sigset_t *set, int *sig=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigwaitinfo (const sigset_t *set, siginfo_t *info)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_cancel (ACE_thread_t t_id)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_continue (ACE_hthread_t target_thread)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_equal (ACE_thread_t t1, ACE_thread_t t2)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getconcurrency (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getprio (ACE_hthread_t id, int &priority)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getprio (ACE_hthread_t id, int &priority, int &policy)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getspecific (ACE_thread_key_t key, void **data)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_join (ACE_hthread_t waiter_id, ACE_THR_FUNC_RETURN *status)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_join (ACE_thread_t waiter_id, ACE_thread_t *thr_id, ACE_THR_FUNC_RETURN *status)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_kill (ACE_thread_t thr_id, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
thr_min_stack (void)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_thread_t 
thr_self (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
thr_self (ACE_hthread_t &)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
thr_name (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setcancelstate (int new_state, int *old_state)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setcanceltype (int new_type, int *old_type)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setconcurrency (int hint)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setprio (ACE_hthread_t ht_id, int priority, int policy=-1)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_sigsetmask (int how, const sigset_t *nsm, sigset_t *osm)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_suspend (ACE_hthread_t target_thread)
ACE_NAMESPACE_INLINE_FUNCTION
void 
thr_testcancel (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
thr_yield (void)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
thr_equal (ACE_thread_t t1, ACE_thread_t t2)
ACE_INLINE int condattr_destroy (ACE_condattr_t &attributes)
ACE_INLINE int condattr_init (ACE_condattr_t &attributes, int type)
ACE_INLINE int cond_broadcast (ACE_cond_t *cv)
ACE_INLINE int cond_destroy (ACE_cond_t *cv)
ACE_INLINE int cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const char *name, void *arg)
ACE_INLINE int cond_signal (ACE_cond_t *cv)
ACE_INLINE int cond_wait (ACE_cond_t *cv, ACE_mutex_t *external_mutex)
ACE_INLINE int cond_timedwait (ACE_cond_t *cv, ACE_mutex_t *external_mutex, ACE_Time_Value *timeout)
ACE_INLINE int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value *timeout)
ACE_INLINE long priority_control (ACE_idtype_t idtype, ACE_id_t identifier, int cmd, void *arg)
 Low-level interface to <priocntl>(2).
ACE_INLINE int recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
ACE_INLINE void recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
ACE_INLINE int recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m)
ACE_INLINE int recursive_mutex_init (ACE_recursive_thread_mutex_t *m, const ACE_TCHAR *name, ACE_mutexattr_t *arg, LPSECURITY_ATTRIBUTES sa)
ACE_INLINE int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m)
ACE_INLINE int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value &timeout)
ACE_INLINE int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value *timeout)
ACE_INLINE int recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m)
ACE_INLINE int recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m)
ACE_INLINE int rw_rdlock (ACE_rwlock_t *rw)
ACE_INLINE int rw_tryrdlock (ACE_rwlock_t *rw)
ACE_INLINE int rw_trywrlock (ACE_rwlock_t *rw)
ACE_INLINE int rw_trywrlock_upgrade (ACE_rwlock_t *rw)
ACE_INLINE int rw_unlock (ACE_rwlock_t *rw)
ACE_INLINE int rw_wrlock (ACE_rwlock_t *rw)
ACE_INLINE int rwlock_destroy (ACE_rwlock_t *rw)
ACE_INLINE int sema_destroy (ACE_sema_t *s)
ACE_INLINE int sema_init (ACE_sema_t *s, u_int count, int type, const char *name, void *arg, int max, LPSECURITY_ATTRIBUTES sa)
ACE_INLINE int sema_post (ACE_sema_t *s)
ACE_INLINE int sema_post (ACE_sema_t *s, u_int release_count)
ACE_INLINE int sema_trywait (ACE_sema_t *s)
ACE_INLINE int sema_wait (ACE_sema_t *s)
ACE_INLINE int sema_wait (ACE_sema_t *s, ACE_Time_Value &tv)
ACE_INLINE int sema_wait (ACE_sema_t *s, ACE_Time_Value *tv)
ACE_INLINE int semctl (int int_id, int semnum, int cmd, semun value)
ACE_INLINE int semget (key_t key, int nsems, int flags)
ACE_INLINE int semop (int int_id, struct sembuf *sops, size_t nsops)
ACE_INLINE int sigtimedwait (const sigset_t *sset, siginfo_t *info, const ACE_Time_Value *timeout)
ACE_INLINE int sigwait (sigset_t *sset, int *sig)
ACE_INLINE int sigwaitinfo (const sigset_t *sset, siginfo_t *info)
ACE_INLINE int thr_cancel (ACE_thread_t thr_id)
ACE_INLINE int thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2)
ACE_INLINE int thr_continue (ACE_hthread_t target_thread)
ACE_INLINE int thr_getconcurrency (void)
ACE_INLINE int thr_getprio (ACE_hthread_t ht_id, int &priority, int &policy)
ACE_INLINE int thr_getprio (ACE_hthread_t ht_id, int &priority)
ACE_INLINE int thr_getspecific (ACE_thread_key_t key, void **data)
ACE_INLINE int thr_join (ACE_hthread_t thr_handle, ACE_THR_FUNC_RETURN *status)
ACE_INLINE int thr_join (ACE_thread_t waiter_id, ACE_thread_t *thr_id, ACE_THR_FUNC_RETURN *status)
ACE_INLINE int thr_kill (ACE_thread_t thr_id, int signum)
ACE_INLINE size_t thr_min_stack (void)
ACE_INLINE ACE_thread_t thr_self (void)
ACE_INLINE const char * thr_name (void)
ACE_INLINE void thr_self (ACE_hthread_t &self)
ACE_INLINE int thr_setcancelstate (int new_state, int *old_state)
ACE_INLINE int thr_setcanceltype (int new_type, int *old_type)
ACE_INLINE int thr_setconcurrency (int hint)
ACE_INLINE int thr_setprio (ACE_hthread_t ht_id, int priority, int policy)
ACE_INLINE int thr_sigsetmask (int how, const sigset_t *nsm, sigset_t *osm)
ACE_INLINE int thr_suspend (ACE_hthread_t target_thread)
ACE_INLINE void thr_testcancel (void)
ACE_INLINE void thr_yield (void)
ACE_INLINE int thread_mutex_destroy (ACE_thread_mutex_t *m)
ACE_INLINE int thread_mutex_init (ACE_thread_mutex_t *m, int lock_type, const char *name, ACE_mutexattr_t *arg)
ACE_INLINE int thread_mutex_lock (ACE_thread_mutex_t *m)
ACE_INLINE int thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value &timeout)
ACE_INLINE int thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value *timeout)
ACE_INLINE int thread_mutex_trylock (ACE_thread_mutex_t *m)
ACE_INLINE int thread_mutex_unlock (ACE_thread_mutex_t *m)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE char * 
asctime (const struct tm *t)
ACE_INLINE char * asctime_r (const struct tm *t, char *buf, int buflen)
ACE_INLINE int clock_gettime (clockid_t clockid, struct timespec *ts)
ACE_INLINE int clock_settime (clockid_t clockid, const struct timespec *ts)
ACE_INLINE ACE_TCHARctime (const time_t *t)
ACE_INLINE ACE_TCHARctime_r (const time_t *t, ACE_TCHAR *buf, int buflen)
ACE_INLINE double difftime (time_t t1, time_t t0)
ACE_INLINE ACE_hrtime_t gethrtime (const ACE_HRTimer_Op op)
ACE_INLINE struct tm * gmtime (const time_t *t)
ACE_INLINE struct tm * gmtime_r (const time_t *t, struct tm *res)
ACE_INLINE struct tm * localtime (const time_t *t)
ACE_INLINE int nanosleep (const struct timespec *requested, struct timespec *remaining)
ACE_INLINE size_t strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr)
ACE_INLINE char * strptime (const char *buf, const char *format, struct tm *tm)
ACE_INLINE time_t time (time_t *tloc)
ACE_INLINE long timezone (void)
ACE_INLINE void tzset (void)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int 
argv_to_string (ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args, bool quote_args)
int argv_to_string (int argc, ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args, bool quote_args)
int execl (const char *, const char *,...)
int execle (const char *, const char *,...)
int execlp (const char *, const char *,...)
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.
ssize_t read_n (ACE_HANDLE handle, void *buf, size_t len, size_t *bt)
ssize_t pread (ACE_HANDLE handle, void *buf, size_t nbytes, ACE_OFF_T offset)
ssize_t pwrite (ACE_HANDLE handle, const void *buf, size_t nbytes, ACE_OFF_T offset)
int string_to_argv (ACE_TCHAR *buf, int &argc, ACE_TCHAR **&argv, bool substitute_env_args)
ssize_t write_n (ACE_HANDLE handle, const void *buf, size_t len, size_t *bt)
ACE_NAMESPACE_INLINE_FUNCTION
int 
access (const char *path, int amode)
ACE_NAMESPACE_INLINE_FUNCTION
unsigned int 
alarm (u_int secs)
ACE_NAMESPACE_INLINE_FUNCTION
long 
allocation_granularity (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
chdir (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rmdir (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
close (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
dup (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
dup2 (ACE_HANDLE oldfd, ACE_HANDLE newfd)
ACE_NAMESPACE_INLINE_FUNCTION
int 
execv (const char *path, char *const argv[])
ACE_NAMESPACE_INLINE_FUNCTION
int 
execve (const char *path, char *const argv[], char *const envp[])
ACE_NAMESPACE_INLINE_FUNCTION
int 
execvp (const char *file, char *const argv[])
ACE_NAMESPACE_INLINE_FUNCTION
int 
fsync (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
ftruncate (ACE_HANDLE handle, ACE_OFF_T offset)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
getcwd (char *, size_t)
ACE_NAMESPACE_INLINE_FUNCTION
gid_t 
getgid (void)
ACE_NAMESPACE_INLINE_FUNCTION
gid_t 
getegid (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getopt (int argc, char *const *argv, const char *optstring)
ACE_NAMESPACE_INLINE_FUNCTION
long 
getpagesize (void)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
getpgid (pid_t pid)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
getpid (void)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
getppid (void)
ACE_NAMESPACE_INLINE_FUNCTION
uid_t 
getuid (void)
ACE_NAMESPACE_INLINE_FUNCTION
uid_t 
geteuid (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
hostname (char *name, size_t maxnamelen)
ACE_NAMESPACE_INLINE_FUNCTION
int 
isatty (int handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_OFF_T 
lseek (ACE_HANDLE handle, ACE_OFF_T offset, int whence)
ACE_NAMESPACE_INLINE_FUNCTION
int 
pipe (ACE_HANDLE handles[])
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
read (ACE_HANDLE handle, void *buf, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
read (ACE_HANDLE handle, void *buf, size_t len, ACE_OVERLAPPED *)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
readlink (const char *path, char *buf, size_t bufsiz)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
sbrk (intptr_t brk)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setgid (gid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setegid (gid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setpgid (pid_t pid, pid_t pgid)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setregid (gid_t rgid, gid_t egid)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setreuid (uid_t ruid, uid_t euid)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
setsid (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setuid (uid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
seteuid (uid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sleep (u_int seconds)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sleep (const ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
void 
swab (const void *src, void *dest, ssize_t n)
ACE_NAMESPACE_INLINE_FUNCTION
long 
sysconf (int)
ACE_NAMESPACE_INLINE_FUNCTION
long 
sysinfo (int cmd, char *buf, long count)
ACE_NAMESPACE_INLINE_FUNCTION
int 
truncate (const ACE_TCHAR *filename, ACE_OFF_T length)
ACE_NAMESPACE_INLINE_FUNCTION
useconds_t 
ualarm (useconds_t usecs, useconds_t interval=0)
ACE_NAMESPACE_INLINE_FUNCTION
useconds_t 
ualarm (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval=ACE_Time_Value::zero)
ACE_NAMESPACE_INLINE_FUNCTION
int 
unlink (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
write (ACE_HANDLE handle, const void *buf, size_t nbyte)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
write (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OVERLAPPED *)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int 
access (const char *path, int amode)
ACE_INLINE u_int alarm (u_int secs)
ACE_INLINE long getpagesize (void)
ACE_INLINE long allocation_granularity (void)
ACE_INLINE int chdir (const char *path)
ACE_INLINE int rmdir (const char *path)
ACE_INLINE int close (ACE_HANDLE handle)
ACE_INLINE ACE_HANDLE dup (ACE_HANDLE handle)
ACE_INLINE int dup2 (ACE_HANDLE oldhandle, ACE_HANDLE newhandle)
ACE_INLINE int execv (const char *path, char *const argv[])
ACE_INLINE int execve (const char *path, char *const argv[], char *const envp[])
ACE_INLINE int execvp (const char *file, char *const argv[])
ACE_INLINE pid_t fork (void)
ACE_INLINE int fsync (ACE_HANDLE handle)
ACE_INLINE int ftruncate (ACE_HANDLE handle, ACE_OFF_T offset)
ACE_INLINE char * getcwd (char *buf, size_t size)
ACE_INLINE gid_t getgid (void)
ACE_INLINE gid_t getegid (void)
ACE_INLINE int getopt (int argc, char *const *argv, const char *optstring)
ACE_INLINE pid_t getpgid (pid_t pid)
ACE_INLINE pid_t getpid (void)
ACE_INLINE pid_t getppid (void)
ACE_INLINE uid_t getuid (void)
ACE_INLINE uid_t geteuid (void)
ACE_INLINE int hostname (char name[], size_t maxnamelen)
ACE_INLINE int isatty (int handle)
ACE_INLINE ACE_OFF_T lseek (ACE_HANDLE handle, ACE_OFF_T offset, int whence)
ACE_INLINE ssize_t read (ACE_HANDLE handle, void *buf, size_t len)
ACE_INLINE ssize_t read (ACE_HANDLE handle, void *buf, size_t len, ACE_OVERLAPPED *overlapped)
ACE_INLINE ssize_t readlink (const char *path, char *buf, size_t bufsiz)
ACE_INLINE int pipe (ACE_HANDLE fds[])
ACE_INLINE void * sbrk (intptr_t brk)
ACE_INLINE int setgid (gid_t gid)
ACE_INLINE int setegid (gid_t gid)
ACE_INLINE int setpgid (pid_t pid, pid_t pgid)
ACE_INLINE int setregid (gid_t rgid, gid_t egid)
ACE_INLINE int setreuid (uid_t ruid, uid_t euid)
ACE_INLINE pid_t setsid (void)
ACE_INLINE int setuid (uid_t uid)
ACE_INLINE int seteuid (uid_t uid)
ACE_INLINE int sleep (u_int seconds)
ACE_INLINE int sleep (const ACE_Time_Value &tv)
ACE_INLINE void swab (const void *src, void *dest, ssize_t length)
ACE_INLINE long sysconf (int name)
ACE_INLINE long sysinfo (int cmd, char *buf, long count)
ACE_INLINE int truncate (const ACE_TCHAR *filename, ACE_OFF_T offset)
ACE_INLINE useconds_t ualarm (useconds_t usecs, useconds_t interval)
ACE_INLINE useconds_t ualarm (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval)
ACE_INLINE int unlink (const char *path)
ACE_INLINE ssize_t write (ACE_HANDLE handle, const void *buf, size_t nbyte)
ACE_INLINE ssize_t write (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OVERLAPPED *overlapped)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int 
wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2)
 Emulated wcscmp - Compares strings.
size_t wcslen_emulation (const ACE_WCHAR_T *string)
 Emulated wcslen - Returns the length of a string.
ACE_WCHAR_T * wcsncat_emulation (ACE_WCHAR_T *destination, const ACE_WCHAR_T *source, size_t count)
 Emulated wcscat - Appends a string.
int wcsncmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2, size_t len)
 Emulated wcsncmp - Compares two arrays.
ACE_WCHAR_T * wcsncpy_emulation (ACE_WCHAR_T *destination, const ACE_WCHAR_T *source, size_t len)
 Emulated wcsncpy - Copies an array.
ACE_NAMESPACE_INLINE_FUNCTION
u_int 
wslen (const WChar *)
ACE_NAMESPACE_INLINE_FUNCTION
WChar
wscpy (WChar *, const WChar *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
wscmp (const WChar *, const WChar *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
wsncmp (const WChar *, const WChar *, size_t len)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE u_int 
wslen (const WChar *s)
ACE_INLINE ACE_OS::WCharwscpy (WChar *dest, const WChar *src)
ACE_INLINE int wscmp (const WChar *s, const WChar *t)
ACE_INLINE int wsncmp (const WChar *s, const WChar *t, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_accept (ACE_HANDLE fildes, ACE_HANDLE resfd, struct t_call *call)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
t_alloc (ACE_HANDLE fildes, int struct_type, int fields)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_bind (ACE_HANDLE fildes, ACE_TBIND *req, ACE_TBIND *ret)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_close (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_connect (ACE_HANDLE fildes, struct t_call *sndcall, struct t_call *rcvcall)
ACE_NAMESPACE_INLINE_FUNCTION
void 
t_error (const char *errmsg)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_free (char *ptr, int struct_type)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_getinfo (ACE_HANDLE fildes, struct t_info *info)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_getname (ACE_HANDLE fildes, struct netbuf *namep, int type)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_getstate (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_listen (ACE_HANDLE fildes, struct t_call *call)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_look (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
t_open (char *path, int oflag, struct t_info *info)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_optmgmt (ACE_HANDLE handle, ACE_TOPTMGMT *req, ACE_TOPTMGMT *ret)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcv (ACE_HANDLE fildes, char *buf, unsigned int nbytes, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvdis (ACE_HANDLE fildes, struct t_discon *discon)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvrel (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvudata (ACE_HANDLE fildes, struct t_unitdata *unitdata, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvuderr (ACE_HANDLE fildes, struct t_uderr *uderr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_snd (ACE_HANDLE fildes, const char *buf, unsigned int nbytes, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_snddis (ACE_HANDLE fildes, struct t_call *call)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_sndrel (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_sync (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_unbind (ACE_HANDLE fildes)


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 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 45 of file OS_NS_wchar.h.


Enumeration Type Documentation

enum ACE_OS::ACE_HRTimer_Op

Enumerator:
ACE_HRTIMER_START 
ACE_HRTIMER_INCR 
ACE_HRTIMER_STOP 
ACE_HRTIMER_GETTIME 

Definition at line 149 of file OS_NS_time.h.

00150     {
00151       ACE_HRTIMER_START = 0x0,  // Only use these if you can stand
00152       ACE_HRTIMER_INCR = 0x1,   // for interrupts to be disabled during
00153       ACE_HRTIMER_STOP = 0x2,   // the timed interval!!!!
00154       ACE_HRTIMER_GETTIME = 0xFFFF
00155     };


Function Documentation

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

Definition at line 15 of file OS_NS_arpa_inet.cpp.

References INADDR_NONE, inet_addr(), and strcmp().

Referenced by inet_pton(), and ACE_INET_Addr::set().

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   unsigned long ip_addr = ACE_OS::inet_addr (host_name);
00027 
00028   if (ip_addr == INADDR_NONE
00029       // Broadcast addresses are weird...
00030       && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
00031     return 0;
00032   else if (addr == 0)
00033     return 0;
00034   else
00035     {
00036       addr->s_addr = ip_addr;  // Network byte ordered
00037       return 1;
00038     }
00039 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x660)
00040   // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
00041   // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
00042   ::errnoSet(0);
00043   int result = ERROR;
00044   ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result);
00045   return (result == ERROR) ? 0 : 1;
00046 #else
00047   // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
00048   // address (255.255.255.255).
00049   ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
00050 #endif  /* ACE_LACKS_INET_ATON */
00051 }

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

Definition at line 11 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and inet_addr().

Referenced by inet_addr(), and inet_aton().

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

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

Definition at line 25 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and inet_ntoa().

Referenced by ACE_INET_Addr::get_host_addr(), and inet_ntoa().

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

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

Definition at line 39 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, AF_INET, INET_ADDRSTRLEN, inet_ntop(), sprintf(), strcpy(), and strlen().

Referenced by ACE_INET_Addr::get_host_addr(), and inet_ntop().

00040 {
00041   ACE_OS_TRACE ("ACE_OS::inet_ntop");
00042 
00043 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00044   ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0);
00045 #else
00046   const u_char *p = reinterpret_cast<const u_char *> (addrptr);
00047 
00048   if (family == AF_INET)
00049     {
00050       char temp[INET_ADDRSTRLEN];
00051 
00052       // Stevens uses snprintf() in his implementation but snprintf()
00053       // doesn't appear to be very portable.  For now, hope that using
00054       // sprintf() will not cause any string/memory overrun problems.
00055       ACE_OS::sprintf (temp,
00056                        "%d.%d.%d.%d",
00057                        p[0], p[1], p[2], p[3]);
00058 
00059       if (ACE_OS::strlen (temp) >= len)
00060         {
00061           errno = ENOSPC;
00062           return 0; // Failure
00063         }
00064 
00065       ACE_OS::strcpy (strptr, temp);
00066       return strptr;
00067     }
00068 
00069   ACE_NOTSUP_RETURN(0);
00070 #endif /* ACE_HAS_IPV6 */
00071 }

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

Definition at line 74 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, AF_INET, inet_aton(), inet_pton(), and memcpy().

Referenced by inet_pton().

00075 {
00076   ACE_OS_TRACE ("ACE_OS::inet_pton");
00077 
00078 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00079   ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1);
00080 #else
00081   if (family == AF_INET)
00082     {
00083       struct in_addr in_val;
00084 
00085       if (ACE_OS::inet_aton (strptr, &in_val))
00086         {
00087           ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr));
00088           return 1; // Success
00089         }
00090 
00091       return 0; // Input is not a valid presentation format
00092     }
00093 
00094   ACE_NOTSUP_RETURN(-1);
00095 #endif  /* ACE_HAS_IPV6 */
00096 }

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

Definition at line 11 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and inet_addr().

Referenced by inet_addr(), and inet_aton().

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

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

Definition at line 25 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and inet_ntoa().

Referenced by ACE_INET_Addr::get_host_addr(), and inet_ntoa().

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

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

Definition at line 39 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, AF_INET, INET_ADDRSTRLEN, inet_ntop(), sprintf(), strcpy(), and strlen().

Referenced by ACE_INET_Addr::get_host_addr(), and inet_ntop().

00040 {
00041   ACE_OS_TRACE ("ACE_OS::inet_ntop");
00042 
00043 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00044   ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0);
00045 #else
00046   const u_char *p = reinterpret_cast<const u_char *> (addrptr);
00047 
00048   if (family == AF_INET)
00049     {
00050       char temp[INET_ADDRSTRLEN];
00051 
00052       // Stevens uses snprintf() in his implementation but snprintf()
00053       // doesn't appear to be very portable.  For now, hope that using
00054       // sprintf() will not cause any string/memory overrun problems.
00055       ACE_OS::sprintf (temp,
00056                        "%d.%d.%d.%d",
00057                        p[0], p[1], p[2], p[3]);
00058 
00059       if (ACE_OS::strlen (temp) >= len)
00060         {
00061           errno = ENOSPC;
00062           return 0; // Failure
00063         }
00064 
00065       ACE_OS::strcpy (strptr, temp);
00066       return strptr;
00067     }
00068 
00069   ACE_NOTSUP_RETURN(0);
00070 #endif /* ACE_HAS_IPV6 */
00071 }

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

Definition at line 74 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, AF_INET, inet_aton(), inet_pton(), and memcpy().

Referenced by inet_pton().

00075 {
00076   ACE_OS_TRACE ("ACE_OS::inet_pton");
00077 
00078 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00079   ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1);
00080 #else
00081   if (family == AF_INET)
00082     {
00083       struct in_addr in_val;
00084 
00085       if (ACE_OS::inet_aton (strptr, &in_val))
00086         {
00087           ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr));
00088           return 1; // Success
00089         }
00090 
00091       return 0; // Input is not a valid presentation format
00092     }
00093 
00094   ACE_NOTSUP_RETURN(-1);
00095 #endif  /* ACE_HAS_IPV6 */
00096 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isalnum ( ACE_TCHAR  c  ) 

Returns true if the character is an alphanumeric character.

Definition at line 13 of file OS_NS_ctype.inl.

Referenced by ACE_Get_Opt::long_option().

00014 {
00015 #if defined (ACE_USES_WCHAR)
00016 # if defined (_MSC_VER) && (_MSC_VER >= 1300)
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 < 256 && iswalnum (c);
00020 # else
00021   return iswalnum (c);
00022 # endif /* _MSC_VER && _MSC_VER >= 1300 */
00023 #else /* ACE_USES_WCHAR */
00024   return isalnum ((unsigned char) c);
00025 #endif /* ACE_USES_WCHAR */
00026 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isalpha ( ACE_TCHAR  c  ) 

Returns true if the character is an alphabetic character.

Definition at line 29 of file OS_NS_ctype.inl.

00030 {
00031 #if defined (ACE_USES_WCHAR)
00032   return iswalpha (c);
00033 #else /* ACE_USES_WCHAR */
00034   return isalpha ((unsigned char) c);
00035 #endif /* ACE_USES_WCHAR */
00036 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_iscntrl ( ACE_TCHAR  c  ) 

Returns true if the character is a control character.

Definition at line 39 of file OS_NS_ctype.inl.

00040 {
00041 #if defined (ACE_USES_WCHAR)
00042   return iswcntrl (c);
00043 #else /* ACE_USES_WCHAR */
00044   return iscntrl ((unsigned char) c);
00045 #endif /* ACE_USES_WCHAR */
00046 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isdigit ( ACE_TCHAR  c  ) 

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

Definition at line 49 of file OS_NS_ctype.inl.

Referenced by ACE::hex2byte(), ACE_Capabilities::parse(), and ACE_Svc_Conf_Lexer::scan().

00050 {
00051 #if defined (ACE_USES_WCHAR)
00052   return iswdigit (c);
00053 #else /* ACE_USES_WCHAR */
00054   return isdigit ((unsigned char) c);
00055 #endif /* ACE_USES_WCHAR */
00056 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isgraph ( ACE_TCHAR  c  ) 

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

Definition at line 59 of file OS_NS_ctype.inl.

00060 {
00061 #if defined (ACE_USES_WCHAR)
00062   return iswgraph (c);
00063 #else /* ACE_USES_WCHAR */
00064   return isgraph ((unsigned char) c);
00065 #endif /* ACE_USES_WCHAR */
00066 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_islower ( ACE_TCHAR  c  ) 

Returns true if the character is a lowercase character.

Definition at line 69 of file OS_NS_ctype.inl.

Referenced by ACE::hex2byte().

00070 {
00071 #if defined (ACE_USES_WCHAR)
00072   return iswlower (c);
00073 #else /* ACE_USES_WCHAR */
00074   return islower ((unsigned char) c);
00075 #endif /* ACE_USES_WCHAR */
00076 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isprint ( ACE_TCHAR  c  ) 

Returns true if the character is a printable character.

Definition at line 79 of file OS_NS_ctype.inl.

Referenced by ACE::format_hexdump().

00080 {
00081 #if defined (ACE_USES_WCHAR)
00082   return iswprint (c);
00083 #else /* ACE_USES_WCHAR */
00084   return isprint ((unsigned char) c);
00085 #endif /* ACE_USES_WCHAR */
00086 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_ispunct ( ACE_TCHAR  c  ) 

Returns true if the character is a punctuation character.

Definition at line 89 of file OS_NS_ctype.inl.

00090 {
00091 #if defined (ACE_USES_WCHAR)
00092   return iswpunct (c);
00093 #else /* ACE_USES_WCHAR */
00094   return ispunct ((unsigned char) c);
00095 #endif /* ACE_USES_WCHAR */
00096 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isspace ( ACE_TCHAR  c  ) 

Returns true if the character is a space character.

Definition at line 99 of file OS_NS_ctype.inl.

Referenced by ACE_Base64::decode(), ACE_Capabilities::fillent(), is_empty(), ACE_Capabilities::is_entry(), is_line(), ACE_Base64::length(), ACE_Ini_ImpExp::squish(), and string_to_argv().

00100 {
00101 #if defined (ACE_USES_WCHAR)
00102   return iswspace (c);
00103 #else /* ACE_USES_WCHAR */
00104   return isspace ((unsigned char) c);
00105 #endif /* ACE_USES_WCHAR */
00106 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isupper ( ACE_TCHAR  c  ) 

Returns true if the character is an uppercase character.

Definition at line 109 of file OS_NS_ctype.inl.

00110 {
00111 #if defined (ACE_USES_WCHAR)
00112   return iswupper (c);
00113 #else /* ACE_USES_WCHAR */
00114   return isupper ((unsigned char) c);
00115 #endif /* ACE_USES_WCHAR */
00116 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_isxdigit ( ACE_TCHAR  c  ) 

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

Definition at line 119 of file OS_NS_ctype.inl.

00120 {
00121 #if defined (ACE_USES_WCHAR)
00122   return iswxdigit (c);
00123 #else /* ACE_USES_WCHAR */
00124   return isxdigit ((unsigned char) c);
00125 #endif /* ACE_USES_WCHAR */
00126 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_tolower ( int  c  ) 

Converts a character to lower case (char version).

Definition at line 129 of file OS_NS_ctype.inl.

Referenced by equal_char(), and ACE_Svc_Conf_Lexer::scan().

00130 {
00131   return tolower (c);
00132 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ace_toupper ( int  c  ) 

Converts a character to upper case (char version).

Definition at line 150 of file OS_NS_ctype.inl.

00151 {
00152   return toupper (c);
00153 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::ace_isalnum ( ACE_TCHAR  c  ) 

Returns true if the character is an alphanumeric character.

Definition at line 13 of file OS_NS_ctype.inl.

Referenced by ACE_Get_Opt::long_option().

00014 {
00015 #if defined (ACE_USES_WCHAR)
00016 # if defined (_MSC_VER) && (_MSC_VER >= 1300)
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 < 256 && iswalnum (c);
00020 # else
00021   return iswalnum (c);
00022 # endif /* _MSC_VER && _MSC_VER >= 1300 */
00023 #else /* ACE_USES_WCHAR */
00024   return isalnum ((unsigned char) c);
00025 #endif /* ACE_USES_WCHAR */
00026 }

ACE_INLINE int ACE_OS::ace_isalpha ( ACE_TCHAR  c  ) 

Returns true if the character is an alphabetic character.

Definition at line 29 of file OS_NS_ctype.inl.

00030 {
00031 #if defined (ACE_USES_WCHAR)
00032   return iswalpha (c);
00033 #else /* ACE_USES_WCHAR */
00034   return isalpha ((unsigned char) c);
00035 #endif /* ACE_USES_WCHAR */
00036 }

ACE_INLINE int ACE_OS::ace_iscntrl ( ACE_TCHAR  c  ) 

Returns true if the character is a control character.

Definition at line 39 of file OS_NS_ctype.inl.

00040 {
00041 #if defined (ACE_USES_WCHAR)
00042   return iswcntrl (c);
00043 #else /* ACE_USES_WCHAR */
00044   return iscntrl ((unsigned char) c);
00045 #endif /* ACE_USES_WCHAR */
00046 }

ACE_INLINE int ACE_OS::ace_isdigit ( ACE_TCHAR  c  ) 

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

Definition at line 49 of file OS_NS_ctype.inl.

Referenced by ACE::hex2byte(), ACE_Capabilities::parse(), and ACE_Svc_Conf_Lexer::scan().

00050 {
00051 #if defined (ACE_USES_WCHAR)
00052   return iswdigit (c);
00053 #else /* ACE_USES_WCHAR */
00054   return isdigit ((unsigned char) c);
00055 #endif /* ACE_USES_WCHAR */
00056 }

ACE_INLINE int ACE_OS::ace_isgraph ( ACE_TCHAR  c  ) 

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

Definition at line 59 of file OS_NS_ctype.inl.

00060 {
00061 #if defined (ACE_USES_WCHAR)
00062   return iswgraph (c);
00063 #else /* ACE_USES_WCHAR */
00064   return isgraph ((unsigned char) c);
00065 #endif /* ACE_USES_WCHAR */
00066 }

ACE_INLINE int ACE_OS::ace_islower ( ACE_TCHAR  c  ) 

Returns true if the character is a lowercase character.

Definition at line 69 of file OS_NS_ctype.inl.

Referenced by ACE::hex2byte().

00070 {
00071 #if defined (ACE_USES_WCHAR)
00072   return iswlower (c);
00073 #else /* ACE_USES_WCHAR */
00074   return islower ((unsigned char) c);
00075 #endif /* ACE_USES_WCHAR */
00076 }

ACE_INLINE int ACE_OS::ace_isprint ( ACE_TCHAR  c  ) 

Returns true if the character is a printable character.

Definition at line 79 of file OS_NS_ctype.inl.

Referenced by ACE::format_hexdump().

00080 {
00081 #if defined (ACE_USES_WCHAR)
00082   return iswprint (c);
00083 #else /* ACE_USES_WCHAR */
00084   return isprint ((unsigned char) c);
00085 #endif /* ACE_USES_WCHAR */
00086 }

ACE_INLINE int ACE_OS::ace_ispunct ( ACE_TCHAR  c  ) 

Returns true if the character is a punctuation character.

Definition at line 89 of file OS_NS_ctype.inl.

00090 {
00091 #if defined (ACE_USES_WCHAR)
00092   return iswpunct (c);
00093 #else /* ACE_USES_WCHAR */
00094   return ispunct ((unsigned char) c);
00095 #endif /* ACE_USES_WCHAR */
00096 }

ACE_INLINE int ACE_OS::ace_isspace ( ACE_TCHAR  c  ) 

Returns true if the character is a space character.

Definition at line 99 of file OS_NS_ctype.inl.

Referenced by ACE_Base64::decode(), ACE_Capabilities::fillent(), is_empty(), ACE_Capabilities::is_entry(), is_line(), ACE_Base64::length(), ACE_Ini_ImpExp::squish(), and string_to_argv().

00100 {
00101 #if defined (ACE_USES_WCHAR)
00102   return iswspace (c);
00103 #else /* ACE_USES_WCHAR */
00104   return isspace ((unsigned char) c);
00105 #endif /* ACE_USES_WCHAR */
00106 }

ACE_INLINE int ACE_OS::ace_isupper ( ACE_TCHAR  c  ) 

Returns true if the character is an uppercase character.

Definition at line 109 of file OS_NS_ctype.inl.

00110 {
00111 #if defined (ACE_USES_WCHAR)
00112   return iswupper (c);
00113 #else /* ACE_USES_WCHAR */
00114   return isupper ((unsigned char) c);
00115 #endif /* ACE_USES_WCHAR */
00116 }

ACE_INLINE int ACE_OS::ace_isxdigit ( ACE_TCHAR  c  ) 

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

Definition at line 119 of file OS_NS_ctype.inl.

00120 {
00121 #if defined (ACE_USES_WCHAR)
00122   return iswxdigit (c);
00123 #else /* ACE_USES_WCHAR */
00124   return isxdigit ((unsigned char) c);
00125 #endif /* ACE_USES_WCHAR */
00126 }

ACE_INLINE int ACE_OS::ace_tolower ( int  c  ) 

Converts a character to lower case (char version).

Definition at line 129 of file OS_NS_ctype.inl.

Referenced by equal_char(), and ACE_Svc_Conf_Lexer::scan().

00130 {
00131   return tolower (c);
00132 }

ACE_INLINE int ACE_OS::ace_toupper ( int  c  ) 

Converts a character to upper case (char version).

Definition at line 150 of file OS_NS_ctype.inl.

00151 {
00152   return toupper (c);
00153 }

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

Definition at line 162 of file OS_NS_dirent.cpp.

References closedir(), free(), malloc(), memcpy(), opendir(), qsort(), readdir(), realloc(), strcpy(), and strlen().

Referenced by scandir().

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

ACE_INLINE void ACE_OS::closedir ( ACE_DIR  ) 

Definition at line 17 of file OS_NS_dirent.inl.

Referenced by ACE_Dirent::close(), ACE_Dirent::open(), scandir_emulation(), and ACE_Dirent::~ACE_Dirent().

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

ACE_INLINE ACE_DIR * ACE_OS::opendir ( const ACE_TCHAR filename  ) 

Definition at line 36 of file OS_NS_dirent.inl.

References ACE_NOTSUP_RETURN, and ACE_TEXT_ALWAYS_CHAR.

Referenced by ACE_Dirent::open(), and scandir_emulation().

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

ACE_INLINE struct ACE_DIRENT * ACE_OS::readdir ( ACE_DIR  ) 

Definition at line 55 of file OS_NS_dirent.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Dirent::read(), readdir_r(), and scandir_emulation().

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

ACE_INLINE int ACE_OS::readdir_r ( ACE_DIR dirp,
struct ACE_DIRENT *  entry,
struct ACE_DIRENT **  result 
)

Definition at line 72 of file OS_NS_dirent.inl.

References ACE_NOTSUP_RETURN, and readdir().

Referenced by ACE_Dirent::read().

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

ACE_INLINE void ACE_OS::rewinddir ( ACE_DIR  ) 

Definition at line 102 of file OS_NS_dirent.inl.

References ace_rewinddir_helper().

Referenced by ace_rewinddir_helper(), and ACE_Dirent::rewind().

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

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

Definition at line 116 of file OS_NS_dirent.inl.

References ACE_TEXT_ALWAYS_CHAR, and scandir_emulation().

Referenced by ACE_Dirent_Selector::open().

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

ACE_INLINE int ACE_OS::alphasort ( const void *  ,
const void *   
)

Definition at line 142 of file OS_NS_dirent.inl.

References ACE_DIRENT, and strcmp().

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

ACE_INLINE void ACE_OS::seekdir ( ACE_DIR ,
long  loc 
)

Definition at line 161 of file OS_NS_dirent.inl.

Referenced by ACE_Dirent::seek().

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

ACE_INLINE long ACE_OS::telldir ( ACE_DIR  ) 

Definition at line 172 of file OS_NS_dirent.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Dirent::tell().

00173 {
00174 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR)
00175   return ::telldir (d);
00176 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_TELLDIR */
00177   ACE_UNUSED_ARG (d);
00178   ACE_NOTSUP_RETURN (-1);
00179 #endif /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_TELLDIR */
00180 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::dlclose ( ACE_SHLIB_HANDLE  handle  ) 

Definition at line 26 of file OS_NS_dlfcn.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT, dlclose(), and dlsym().

Referenced by ACE_DLL_Handle::close(), dlclose(), and dlopen().

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

ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR* ACE_OS::dlerror ( void   ) 

Definition at line 77 of file OS_NS_dlfcn.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, dlerror(), sprintf(), strerror(), and strncpy().

Referenced by dlerror(), ACE_DLL_Handle::error(), and ACE_DLL::error().

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

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

Definition at line 121 of file OS_NS_dlfcn.inl.

References ACE_DEFAULT_FILE_PERMS, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, close(), dlclose(), dlopen(), dlsym(), last_error(), and open().

Referenced by dlopen(), ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler(), and ACE_DLL_Handle::open().

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

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

Definition at line 203 of file OS_NS_dlfcn.inl.

References ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_INVALID_HANDLE, dlsym(), strcpy(), and strlen().

Referenced by dlclose(), dlopen(), dlsym(), ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler(), and ACE_DLL_Handle::symbol().

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

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::dlclose ( ACE_SHLIB_HANDLE  handle  ) 

Definition at line 26 of file OS_NS_dlfcn.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT, dlclose(), and dlsym().

Referenced by ACE_DLL_Handle::close(), dlclose(), and dlopen().

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

ACE_INLINE ACE_TCHAR* ACE_OS::dlerror ( void   ) 

Definition at line 77 of file OS_NS_dlfcn.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, dlerror(), sprintf(), strerror(), and strncpy().

Referenced by dlerror(), ACE_DLL::error(), and ACE_DLL_Handle::error().

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

ACE_INLINE ACE_SHLIB_HANDLE ACE_OS::dlopen ( const ACE_TCHAR fname,
int  mode 
)

Definition at line 121 of file OS_NS_dlfcn.inl.

References ACE_DEFAULT_FILE_PERMS, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, close(), dlclose(), dlopen(), dlsym(), last_error(), and open().

Referenced by dlopen(), ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler(), and ACE_DLL_Handle::open().

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

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

Definition at line 203 of file OS_NS_dlfcn.inl.

References ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_INVALID_HANDLE, dlsym(), strcpy(), and strlen().

Referenced by dlclose(), dlopen(), dlsym(), ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler(), and ACE_DLL_Handle::symbol().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::last_error ( void   ) 

Definition at line 10 of file OS_NS_errno.inl.

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::connect_i(), dlopen(), ACE_Service_Repository::insert(), ACE_Log_Msg::last_error_adapter(), ACE_Service_Gestalt::process_directives_i(), set_scheduling_params(), and t_getname().

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

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::last_error ( int  error  ) 

Definition at line 29 of file OS_NS_errno.inl.

References ACE_OS_TRACE.

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::set_errno_to_last_error ( void   ) 

Definition at line 39 of file OS_NS_errno.inl.

Referenced by ACE_TTY_IO::control(), event_timedwait(), event_wait(), filesize(), fstat(), mutex_init(), mutex_lock(), mutex_trylock(), pwrite(), sched_params(), sema_trywait(), sema_wait(), stat(), ACE_Process::wait(), and waitpid().

00040 {
00041 # if defined (ACE_WIN32)
00042   return errno = ::GetLastError ();
00043 #else
00044   return errno;
00045 # endif /* defined(ACE_WIN32) */
00046 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::set_errno_to_wsa_last_error ( void   ) 

Definition at line 49 of file OS_NS_errno.inl.

Referenced by ACE_INET_Addr::get_host_addr(), recvfrom(), recvmsg(), recvv(), ACE_SPIPE_Stream::send_handle(), sendmsg(), sendto(), and sendv().

00050 {
00051 # if defined (ACE_WIN32)
00052   return errno = ::WSAGetLastError ();
00053 #else
00054   return errno;
00055 # endif /* defined(ACE_WIN32) */
00056 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::last_error ( void   ) 

Definition at line 10 of file OS_NS_errno.inl.

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

ACE_INLINE void ACE_OS::last_error ( int  error  ) 

Definition at line 29 of file OS_NS_errno.inl.

References ACE_OS_TRACE.

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

ACE_INLINE int ACE_OS::set_errno_to_last_error ( void   ) 

Definition at line 39 of file OS_NS_errno.inl.

Referenced by ACE_TTY_IO::control(), event_timedwait(), event_wait(), filesize(), fstat(), mutex_init(), mutex_lock(), mutex_trylock(), pwrite(), sched_params(), sema_trywait(), sema_wait(), stat(), ACE_Process::wait(), and waitpid().

00040 {
00041 # if defined (ACE_WIN32)
00042   return errno = ::GetLastError ();
00043 #else
00044   return errno;
00045 # endif /* defined(ACE_WIN32) */
00046 }

ACE_INLINE int ACE_OS::set_errno_to_wsa_last_error ( void   ) 

Definition at line 49 of file OS_NS_errno.inl.

Referenced by ACE_INET_Addr::get_host_addr(), recvfrom(), recvmsg(), recvv(), ACE_SPIPE_Stream::send_handle(), sendmsg(), sendto(), and sendv().

00050 {
00051 # if defined (ACE_WIN32)
00052   return errno = ::WSAGetLastError ();
00053 #else
00054   return errno;
00055 # endif /* defined(ACE_WIN32) */
00056 }

ACE_Export 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 19 of file OS_NS_fcntl.cpp.

References access(), ACE_BIT_ENABLED, ACE_DEV_NULL, ACE_END_VERSIONED_NAMESPACE_DECL, ACE_OS_TRACE, FILE_FLAG_OVERLAPPED, FILE_FLAG_SEQUENTIAL_SCAN, FILE_FLAG_WRITE_THROUGH, GENERIC_READ, LPSECURITY_ATTRIBUTES, OPEN_EXISTING, ACE_OS_Object_Manager::preallocated_object, strcmp(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_SPIPE_Connector::connect(), ACE_Handle_Gobbler::consume_handles(), creat(), dlopen(), filesize(), flock_init(), ACE::get_handle(), ACE::handle_timed_open(), ACE_DLL_Strategy< SVC_HANDLER >::open(), ACE_Mem_Map::open(), ACE_FIFO_Recv::open(), ACE_FIFO::open(), ACE_Active_Map_Manager< T >::open(), ACE_Strategy_Acceptor< SVC_HANDLER, >::open(), ACE::open_temp_file(), ACE_Filecache_Object::release(), sema_init(), shm_open(), and truncate().

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

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

Definition at line 10 of file OS_NS_fcntl.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fcntl().

Referenced by ACE::clr_flags(), ACE_IPC_SAP::disable(), ACE_IO_SAP::disable(), ACE_IPC_SAP::enable(), ACE_IO_SAP::enable(), fcntl(), flock_rdlock(), flock_tryrdlock(), flock_trywrlock(), flock_unlock(), flock_wrlock(), ACE::get_flags(), ACE_Select_Reactor_Notify::open(), sema_init(), sema_trywait(), and ACE::set_flags().

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

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::fcntl ( ACE_HANDLE  handle,
int  cmd,
long  arg 
)

Definition at line 10 of file OS_NS_fcntl.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fcntl().

Referenced by ACE::clr_flags(), ACE_IO_SAP::disable(), ACE_IPC_SAP::disable(), ACE_IO_SAP::enable(), ACE_IPC_SAP::enable(), fcntl(), flock_rdlock(), flock_tryrdlock(), flock_trywrlock(), flock_unlock(), flock_wrlock(), ACE::get_flags(), ACE_Select_Reactor_Notify::open(), sema_init(), sema_trywait(), and ACE::set_flags().

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

ACE_INLINE double ACE_OS::floor ( double  x  ) 

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

Definition at line 10 of file OS_NS_math.inl.

Referenced by ACE_Stats::square_root().

00011   {
00012     // This method computes the largest integral value not greater than x.
00013     if(x > 0)
00014       return static_cast<long> (x);
00015     else if (static_cast<long> (x) == x)
00016       return x;
00017     else
00018       return static_cast<long>(x) - 1;
00019   }

ACE_INLINE double ACE_OS::ceil ( double  x  ) 

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

Definition at line 22 of file OS_NS_math.inl.

00023   {
00024     // This method computes the smallest integral value not less than x.
00025     if (x < 0)
00026       return static_cast<long> (x);
00027     else if (static_cast<long> (x) == x)
00028       return x;
00029     else
00030       return static_cast<long> (x) + 1;
00031   }

ACE_INLINE double ACE_OS::log2 ( double  x  ) 

This method computes the base-2 logarithm of x.

Definition at line 34 of file OS_NS_math.inl.

References ace_log2_helper().

00035   {
00036     return ace_log2_helper (x);
00037   }

ACE_Export int ACE_OS::getmacaddress ( struct macaddr_node_t *  node  ) 

Definition at line 219 of file OS_NS_netdb.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, AF_INET, close(), gethostbyname(), hostname(), ioctl(), MAXHOSTNAMELEN, memcpy(), memset(), ACE_OS::macaddr_node_t::node, PF_INET, SOCK_DGRAM, socket(), sprintf(), and strcpy().

Referenced by ACE_Utils::UUID_Generator::init().

00220 {
00221   ACE_OS_TRACE ("ACE_OS::getmacaddress");
00222 
00223 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00224 # if !defined (ACE_HAS_PHARLAP)
00225     /** Define a structure for use with the netbios routine */
00226     struct ADAPTERSTAT
00227     {
00228       ADAPTER_STATUS adapt;
00229       NAME_BUFFER    NameBuff [30];
00230     };
00231 
00232     NCB         ncb;
00233     LANA_ENUM   lenum;
00234     unsigned char result;
00235 
00236     ACE_OS::memset (&ncb, 0, sizeof(ncb));
00237     ncb.ncb_command = NCBENUM;
00238     ncb.ncb_buffer  = reinterpret_cast<unsigned char*> (&lenum);
00239     ncb.ncb_length  = sizeof(lenum);
00240 
00241     result = Netbios (&ncb);
00242 
00243     for(int i = 0; i < lenum.length; i++)
00244       {
00245         ACE_OS::memset (&ncb, 0, sizeof(ncb));
00246         ncb.ncb_command  = NCBRESET;
00247         ncb.ncb_lana_num = lenum.lana [i];
00248 
00249         /** Reset the netbios */
00250         result = Netbios (&ncb);
00251 
00252         if (ncb.ncb_retcode != NRC_GOODRET)
00253         {
00254           return -1;
00255         }
00256 
00257         ADAPTERSTAT adapter;
00258         ACE_OS::memset (&ncb, 0, sizeof (ncb));
00259         ACE_OS::strcpy (reinterpret_cast<char*> (ncb.ncb_callname), "*");
00260         ncb.ncb_command     = NCBASTAT;
00261         ncb.ncb_lana_num    = lenum.lana[i];
00262         ncb.ncb_buffer      = reinterpret_cast<unsigned char*> (&adapter);
00263         ncb.ncb_length      = sizeof (adapter);
00264 
00265         result = Netbios (&ncb);
00266 
00267         if (result == 0)
00268         {
00269           ACE_OS::memcpy (node->node,
00270               adapter.adapt.adapter_address,
00271               6);
00272           return 0;
00273         }
00274       }
00275     return 0;
00276 # else
00277 #   if defined (ACE_HAS_PHARLAP_RT)
00278       DEVHANDLE ip_dev = (DEVHANDLE)0;
00279       EK_TCPIPCFG *devp;
00280       size_t i;
00281       ACE_TCHAR dev_name[16];
00282 
00283       for (i = 0; i < 10; i++)
00284         {
00285           // Ethernet.
00286           ACE_OS::sprintf (dev_name,
00287                            "ether%d",
00288                            i);
00289           ip_dev = EtsTCPGetDeviceHandle (dev_name);
00290           if (ip_dev != 0)
00291             break;
00292         }
00293       if (ip_dev == 0)
00294         return -1;
00295       devp = EtsTCPGetDeviceCfg (ip_dev);
00296       if (devp == 0)
00297         return -1;
00298       ACE_OS::memcpy (node->node,
00299             &devp->EthernetAddress[0],
00300             6);
00301       return 0;
00302 #   else
00303       ACE_UNUSED_ARG (node);
00304       ACE_NOTSUP_RETURN (-1);
00305 #   endif /* ACE_HAS_PHARLAP_RT */
00306 # endif /* ACE_HAS_PHARLAP */
00307 #elif defined (sun)
00308 
00309   /** obtain the local host name */
00310   char hostname [MAXHOSTNAMELEN];
00311   ACE_OS::hostname (hostname, sizeof (hostname));
00312 
00313   /** Get the hostent to use with ioctl */
00314   struct hostent *phost =
00315     ACE_OS::gethostbyname (hostname);
00316 
00317   if (phost == 0)
00318     return -1;
00319 
00320   ACE_HANDLE handle =
00321     ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
00322 
00323   if (handle == ACE_INVALID_HANDLE)
00324     return -1;
00325 
00326   char **paddrs = phost->h_addr_list;
00327 
00328   struct arpreq ar;
00329 
00330   struct sockaddr_in *psa =
00331     (struct sockaddr_in *)&(ar.arp_pa);
00332 
00333   ACE_OS::memset (&ar,
00334                   0,
00335                   sizeof (struct arpreq));
00336 
00337   psa->sin_family = AF_INET;
00338 
00339   ACE_OS::memcpy (&(psa->sin_addr),
00340                   *paddrs,
00341                   sizeof (struct in_addr));
00342 
00343   if (ACE_OS::ioctl (handle,
00344                      SIOCGARP,
00345                      &ar) == -1)
00346     {
00347       ACE_OS::close (handle);
00348       return -1;
00349     }
00350 
00351   ACE_OS::close (handle);
00352 
00353   ACE_OS::memcpy (node->node,
00354                   ar.arp_ha.sa_data,
00355                   6);
00356 
00357   return 0;
00358 
00359 #elif defined (linux) && !defined (ACE_LACKS_NETWORKING)
00360 
00361   struct ifreq ifr;
00362 
00363   ACE_HANDLE handle =
00364     ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
00365 
00366   if (handle == ACE_INVALID_HANDLE)
00367     return -1;
00368 
00369   ACE_OS::strcpy (ifr.ifr_name, "eth0");
00370 
00371   if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
00372     {
00373       ACE_OS::close (handle);
00374       return -1;
00375     }
00376 
00377   struct sockaddr* sa =
00378     (struct sockaddr *) &ifr.ifr_addr;
00379 
00380   ACE_OS::close (handle);
00381 
00382   ACE_OS::memcpy (node->node,
00383                   sa->sa_data,
00384                   6);
00385 
00386   return 0;
00387 
00388 #else
00389   ACE_UNUSED_ARG (node);
00390   ACE_NOTSUP_RETURN (-1);
00391 #endif
00392 }

ACE_NAMESPACE_INLINE_FUNCTION struct hostent* ACE_OS::gethostbyaddr ( const char *  addr,
int  length,
int  type 
)

Definition at line 48 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyaddr(), and gethostbyaddr_r().

Referenced by ACE_INET_Addr::get_host_name_i(), gethostbyaddr(), gethostbyaddr_r(), and getipnodebyaddr().

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

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

Definition at line 94 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyaddr(), gethostbyaddr_r(), memcpy(), memset(), strcpy(), and strlen().

Referenced by ACE::get_fqdn(), ACE_INET_Addr::get_host_name_i(), gethostbyaddr(), and gethostbyaddr_r().

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

ACE_NAMESPACE_INLINE_FUNCTION struct hostent* ACE_OS::gethostbyname ( const char *  name  ) 

Definition at line 241 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyname(), and gethostbyname_r().

Referenced by ACE::get_bcast_addr(), gethostbyname(), gethostbyname_r(), getipnodebyname(), getmacaddress(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), and ACE_INET_Addr::set().

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

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

Definition at line 281 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyname(), gethostbyname_r(), memcpy(), memset(), strcpy(), and strlen().

Referenced by gethostbyname(), gethostbyname_r(), and ACE_INET_Addr::set().

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

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

Definition at line 426 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, AF_INET, gethostbyaddr(), and getipnodebyaddr().

Referenced by getipnodebyaddr().

00427 {
00428 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00429 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
00430   ACE_UNUSED_ARG (src);
00431   ACE_UNUSED_ARG (len);
00432   ACE_UNUSED_ARG (family);
00433   ACE_NOTSUP_RETURN (0);
00434 #  else
00435   struct hostent *hptr = 0;
00436   int errnum;
00437   //FUZZ: disable check_for_lack_ACE_OS
00438   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
00439     {
00440       errno = errnum;
00441     }
00442   //FUZZ: enable check_for_lack_ACE_OS
00443   return hptr;
00444 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
00445 #else
00446   // IPv4-only implementation
00447   if (family == AF_INET)
00448     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
00449                                   static_cast<int> (len),
00450                                   family);
00451 
00452   ACE_NOTSUP_RETURN (0);
00453 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00454 }

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

Definition at line 457 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, AF_INET, gethostbyname(), and getipnodebyname().

Referenced by getipnodebyname().

00458 {
00459   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
00460 # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6)
00461 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
00462   ACE_UNUSED_ARG (flags);
00463 #     if defined (ACE_HAS_NONCONST_GETBY)
00464   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
00465                                          family),
00466                        struct hostent *, 0);
00467 #     else
00468   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
00469                        struct hostent *, 0);
00470 #     endif /* ACE_HAS_NONCONST_GETBY */
00471 #   else
00472   struct hostent *hptr = 0;
00473   int errnum;
00474   //FUZZ: disable check_for_lack_ACE_OS
00475   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
00476     {
00477       errno = errnum;
00478     }
00479   //FUZZ: enable check_for_lack_ACE_OS
00480   return hptr;
00481 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
00482 # else
00483   // IPv4-only implementation
00484   ACE_UNUSED_ARG (flags);
00485   if (family == AF_INET)
00486     return ACE_OS::gethostbyname (name);
00487 
00488   ACE_NOTSUP_RETURN (0);
00489 # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */
00490 }

ACE_NAMESPACE_INLINE_FUNCTION struct protoent* ACE_OS::getprotobyname ( const char *  name  ) 

Definition at line 493 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobyname().

Referenced by getprotobyname(), and getprotobyname_r().

00494 {
00495 #if defined (ACE_LACKS_GETPROTOBYNAME)
00496   ACE_UNUSED_ARG (name);
00497   ACE_NOTSUP_RETURN (0);
00498 #elif defined (ACE_HAS_NONCONST_GETBY)
00499   //FUZZ: disable check_for_lack_ACE_OS
00500   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00501                        struct protoent *,
00502                        0);
00503   //FUZZ: enable check_for_lack_ACE_OS
00504 #else
00505   //FUZZ: disable check_for_lack_ACE_OS
00506   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00507                        struct protoent *,
00508                        0);
00509   //FUZZ: enable check_for_lack_ACE_OS
00510 #endif /* ACE_LACKS_GETPROTOBYNAME */
00511 }

ACE_NAMESPACE_INLINE_FUNCTION struct protoent* ACE_OS::getprotobyname_r ( const char *  name,
struct protoent *  result,
ACE_PROTOENT_DATA  buffer 
)

Definition at line 514 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, getprotobyname(), and getprotobyname_r().

Referenced by getprotobyname_r().

00517 {
00518 #if defined (ACE_LACKS_GETPROTOBYNAME)
00519   ACE_UNUSED_ARG (name);
00520   ACE_UNUSED_ARG (result);
00521   ACE_UNUSED_ARG (buffer);
00522   ACE_NOTSUP_RETURN (0);
00523 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00524 # if defined (AIX) || defined (DIGITAL_UNIX)
00525   //FUZZ: disable check_for_lack_ACE_OS
00526   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
00527     return result;
00528   else
00529     return 0;
00530   //FUZZ: enable check_for_lack_ACE_OS
00531 # elif defined (__GLIBC__)
00532   // GNU C library has a different signature
00533   //FUZZ: disable check_for_lack_ACE_OS
00534   if (::getprotobyname_r (name,
00535                           result,
00536                           buffer,
00537                           sizeof (ACE_PROTOENT_DATA),
00538                           &result) == 0)
00539   //FUZZ: enable check_for_lack_ACE_OS
00540     return result;
00541   else
00542     return 0;
00543 # else
00544 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00545   ACE_UNUSED_ARG (result);
00546   //FUZZ: disable check_for_lack_ACE_OS
00547   ACE_NETDBCALL_RETURN (::getprotobyname (name),
00548                         struct protoent *, 0,
00549                         buffer, sizeof (ACE_PROTOENT_DATA));
00550   //FUZZ: enable check_for_lack_ACE_OS
00551 #   else
00552     //FUZZ: disable check_for_lack_ACE_OS
00553     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
00554                                              result,
00555                                              buffer,
00556                                              sizeof (ACE_PROTOENT_DATA)),
00557                        struct protoent *, 0);
00558     //FUZZ: enable check_for_lack_ACE_OS
00559 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00560 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00561 #elif defined (ACE_HAS_NONCONST_GETBY)
00562   ACE_UNUSED_ARG (result);
00563   ACE_UNUSED_ARG (buffer);
00564   //FUZZ: disable check_for_lack_ACE_OS
00565   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00566                        struct protoent *, 0);
00567   //FUZZ: enable check_for_lack_ACE_OS
00568 #else
00569   ACE_UNUSED_ARG (buffer);
00570   ACE_UNUSED_ARG (result);
00571 
00572   //FUZZ: disable check_for_lack_ACE_OS
00573   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00574                        struct protoent *,
00575                        0);
00576   //FUZZ: enable check_for_lack_ACE_OS
00577 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
00578 }

ACE_NAMESPACE_INLINE_FUNCTION struct protoent* ACE_OS::getprotobynumber ( int  proto  ) 

Definition at line 581 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobynumber().

Referenced by getprotobynumber(), and getprotobynumber_r().

00582 {
00583 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00584   ACE_UNUSED_ARG (proto);
00585   ACE_NOTSUP_RETURN (0);
00586 #else
00587   //FUZZ: disable check_for_lack_ACE_OS
00588   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00589                        struct protoent *, 0);
00590   //FUZZ: enable check_for_lack_ACE_OS
00591 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
00592 }

ACE_NAMESPACE_INLINE_FUNCTION struct protoent* ACE_OS::getprotobynumber_r ( int  proto,
struct protoent *  result,
ACE_PROTOENT_DATA  buffer 
)

Definition at line 595 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, getprotobynumber(), and getprotobynumber_r().

Referenced by getprotobynumber_r().

00598 {
00599 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00600   ACE_UNUSED_ARG (proto);
00601   ACE_UNUSED_ARG (result);
00602   ACE_UNUSED_ARG (buffer);
00603   ACE_NOTSUP_RETURN (0);
00604 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00605 # if defined (AIX) || defined (DIGITAL_UNIX)
00606   //FUZZ: disable check_for_lack_ACE_OS
00607   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
00608     return result;
00609   //FUZZ: enable check_for_lack_ACE_OS
00610   else
00611     return 0;
00612 # elif defined (__GLIBC__)
00613   // GNU C library has a different signature
00614   //FUZZ: disable check_for_lack_ACE_OS
00615   if (::getprotobynumber_r (proto,
00616                             result,
00617                             buffer,
00618                             sizeof (ACE_PROTOENT_DATA),
00619                             &result) == 0)
00620   //FUZZ: enable check_for_lack_ACE_OS
00621     return result;
00622   else
00623     return 0;
00624 # else
00625 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00626   ACE_UNUSED_ARG (result);
00627   //FUZZ: disable check_for_lack_ACE_OS
00628   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
00629                         struct protoent *, 0,
00630                         buffer, sizeof (ACE_PROTOENT_DATA));
00631   //FUZZ: enable check_for_lack_ACE_OS
00632 #   else
00633   //FUZZ: disable check_for_lack_ACE_OS
00634   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
00635                        struct protoent *, 0);
00636   //FUZZ: enable check_for_lack_ACE_OS
00637 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00638 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00639 #else
00640   ACE_UNUSED_ARG (buffer);
00641   ACE_UNUSED_ARG (result);
00642 
00643   //FUZZ: disable check_for_lack_ACE_OS
00644   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00645                        struct protoent *, 0);
00646   //FUZZ: enable check_for_lack_ACE_OS
00647 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00648 }

ACE_NAMESPACE_INLINE_FUNCTION struct servent* ACE_OS::getservbyname ( const char *  svc,
const char *  proto 
)

Definition at line 651 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and getservbyname().

Referenced by getservbyname(), and getservbyname_r().

00652 {
00653   ACE_OS_TRACE ("ACE_OS::getservbyname");
00654 #if defined (ACE_LACKS_GETSERVBYNAME)
00655   ACE_UNUSED_ARG (svc);
00656   ACE_UNUSED_ARG (proto);
00657   ACE_NOTSUP_RETURN (0);
00658 #elif defined (ACE_HAS_NONCONST_GETBY)
00659   //FUZZ: disable check_for_lack_ACE_OS
00660   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00661                                         const_cast<char *> (proto)),
00662                        struct servent *,
00663                        0);
00664   //FUZZ: enable check_for_lack_ACE_OS
00665 #else
00666   //FUZZ: disable check_for_lack_ACE_OS
00667   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00668                                         proto),
00669                        struct servent *,
00670                        0);
00671   //FUZZ: enable check_for_lack_ACE_OS
00672 #endif /* ACE_HAS_NONCONST_GETBY */
00673 }

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

Definition at line 676 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, getservbyname(), getservbyname_r(), and memset().

Referenced by get_port_number_from_name(), and getservbyname_r().

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

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE struct hostent* ACE_OS::gethostbyaddr ( const char *  addr,
int  length,
int  type 
)

Definition at line 48 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyaddr(), and gethostbyaddr_r().

Referenced by ACE_INET_Addr::get_host_name_i(), gethostbyaddr(), gethostbyaddr_r(), and getipnodebyaddr().

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

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

Definition at line 94 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyaddr(), gethostbyaddr_r(), memcpy(), memset(), strcpy(), and strlen().

Referenced by ACE::get_fqdn(), ACE_INET_Addr::get_host_name_i(), gethostbyaddr(), and gethostbyaddr_r().

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

ACE_INLINE struct hostent* ACE_OS::gethostbyname ( const char *  name  ) 

Definition at line 241 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyname(), and gethostbyname_r().

Referenced by ACE::get_bcast_addr(), gethostbyname(), gethostbyname_r(), getipnodebyname(), getmacaddress(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), and ACE_INET_Addr::set().

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

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

Definition at line 281 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyname(), gethostbyname_r(), memcpy(), memset(), strcpy(), and strlen().

Referenced by gethostbyname(), gethostbyname_r(), and ACE_INET_Addr::set().

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

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

Definition at line 426 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, AF_INET, gethostbyaddr(), and getipnodebyaddr().

Referenced by getipnodebyaddr().

00427 {
00428 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00429 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
00430   ACE_UNUSED_ARG (src);
00431   ACE_UNUSED_ARG (len);
00432   ACE_UNUSED_ARG (family);
00433   ACE_NOTSUP_RETURN (0);
00434 #  else
00435   struct hostent *hptr = 0;
00436   int errnum;
00437   //FUZZ: disable check_for_lack_ACE_OS
00438   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
00439     {
00440       errno = errnum;
00441     }
00442   //FUZZ: enable check_for_lack_ACE_OS
00443   return hptr;
00444 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
00445 #else
00446   // IPv4-only implementation
00447   if (family == AF_INET)
00448     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
00449                                   static_cast<int> (len),
00450                                   family);
00451 
00452   ACE_NOTSUP_RETURN (0);
00453 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00454 }

ACE_INLINE struct hostent* ACE_OS::getipnodebyname ( const char *  name,
int  family,
int  flags 
)

Definition at line 457 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, AF_INET, gethostbyname(), and getipnodebyname().

Referenced by getipnodebyname().

00458 {
00459   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
00460 # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6)
00461 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
00462   ACE_UNUSED_ARG (flags);
00463 #     if defined (ACE_HAS_NONCONST_GETBY)
00464   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
00465                                          family),
00466                        struct hostent *, 0);
00467 #     else
00468   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
00469                        struct hostent *, 0);
00470 #     endif /* ACE_HAS_NONCONST_GETBY */
00471 #   else
00472   struct hostent *hptr = 0;
00473   int errnum;
00474   //FUZZ: disable check_for_lack_ACE_OS
00475   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
00476     {
00477       errno = errnum;
00478     }
00479   //FUZZ: enable check_for_lack_ACE_OS
00480   return hptr;
00481 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
00482 # else
00483   // IPv4-only implementation
00484   ACE_UNUSED_ARG (flags);
00485   if (family == AF_INET)
00486     return ACE_OS::gethostbyname (name);
00487 
00488   ACE_NOTSUP_RETURN (0);
00489 # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */
00490 }

ACE_INLINE struct protoent* ACE_OS::getprotobyname ( const char *  name  ) 

Definition at line 493 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobyname().

Referenced by getprotobyname(), and getprotobyname_r().

00494 {
00495 #if defined (ACE_LACKS_GETPROTOBYNAME)
00496   ACE_UNUSED_ARG (name);
00497   ACE_NOTSUP_RETURN (0);
00498 #elif defined (ACE_HAS_NONCONST_GETBY)
00499   //FUZZ: disable check_for_lack_ACE_OS
00500   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00501                        struct protoent *,
00502                        0);
00503   //FUZZ: enable check_for_lack_ACE_OS
00504 #else
00505   //FUZZ: disable check_for_lack_ACE_OS
00506   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00507                        struct protoent *,
00508                        0);
00509   //FUZZ: enable check_for_lack_ACE_OS
00510 #endif /* ACE_LACKS_GETPROTOBYNAME */
00511 }

ACE_INLINE struct protoent* ACE_OS::getprotobyname_r ( const char *  name,
struct protoent *  result,
ACE_PROTOENT_DATA  buffer 
)

Definition at line 514 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, getprotobyname(), and getprotobyname_r().

Referenced by getprotobyname_r().

00517 {
00518 #if defined (ACE_LACKS_GETPROTOBYNAME)
00519   ACE_UNUSED_ARG (name);
00520   ACE_UNUSED_ARG (result);
00521   ACE_UNUSED_ARG (buffer);
00522   ACE_NOTSUP_RETURN (0);
00523 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00524 # if defined (AIX) || defined (DIGITAL_UNIX)
00525   //FUZZ: disable check_for_lack_ACE_OS
00526   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
00527     return result;
00528   else
00529     return 0;
00530   //FUZZ: enable check_for_lack_ACE_OS
00531 # elif defined (__GLIBC__)
00532   // GNU C library has a different signature
00533   //FUZZ: disable check_for_lack_ACE_OS
00534   if (::getprotobyname_r (name,
00535                           result,
00536                           buffer,
00537                           sizeof (ACE_PROTOENT_DATA),
00538                           &result) == 0)
00539   //FUZZ: enable check_for_lack_ACE_OS
00540     return result;
00541   else
00542     return 0;
00543 # else
00544 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00545   ACE_UNUSED_ARG (result);
00546   //FUZZ: disable check_for_lack_ACE_OS
00547   ACE_NETDBCALL_RETURN (::getprotobyname (name),
00548                         struct protoent *, 0,
00549                         buffer, sizeof (ACE_PROTOENT_DATA));
00550   //FUZZ: enable check_for_lack_ACE_OS
00551 #   else
00552     //FUZZ: disable check_for_lack_ACE_OS
00553     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
00554                                              result,
00555                                              buffer,
00556                                              sizeof (ACE_PROTOENT_DATA)),
00557                        struct protoent *, 0);
00558     //FUZZ: enable check_for_lack_ACE_OS
00559 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00560 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00561 #elif defined (ACE_HAS_NONCONST_GETBY)
00562   ACE_UNUSED_ARG (result);
00563   ACE_UNUSED_ARG (buffer);
00564   //FUZZ: disable check_for_lack_ACE_OS
00565   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00566                        struct protoent *, 0);
00567   //FUZZ: enable check_for_lack_ACE_OS
00568 #else
00569   ACE_UNUSED_ARG (buffer);
00570   ACE_UNUSED_ARG (result);
00571 
00572   //FUZZ: disable check_for_lack_ACE_OS
00573   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00574                        struct protoent *,
00575                        0);
00576   //FUZZ: enable check_for_lack_ACE_OS
00577 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
00578 }

ACE_INLINE struct protoent* ACE_OS::getprotobynumber ( int  proto  ) 

Definition at line 581 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobynumber().

Referenced by getprotobynumber(), and getprotobynumber_r().

00582 {
00583 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00584   ACE_UNUSED_ARG (proto);
00585   ACE_NOTSUP_RETURN (0);
00586 #else
00587   //FUZZ: disable check_for_lack_ACE_OS
00588   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00589                        struct protoent *, 0);
00590   //FUZZ: enable check_for_lack_ACE_OS
00591 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
00592 }

ACE_INLINE struct protoent* ACE_OS::getprotobynumber_r ( int  proto,
struct protoent *  result,
ACE_PROTOENT_DATA  buffer 
)

Definition at line 595 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, getprotobynumber(), and getprotobynumber_r().

Referenced by getprotobynumber_r().

00598 {
00599 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00600   ACE_UNUSED_ARG (proto);
00601   ACE_UNUSED_ARG (result);
00602   ACE_UNUSED_ARG (buffer);
00603   ACE_NOTSUP_RETURN (0);
00604 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00605 # if defined (AIX) || defined (DIGITAL_UNIX)
00606   //FUZZ: disable check_for_lack_ACE_OS
00607   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
00608     return result;
00609   //FUZZ: enable check_for_lack_ACE_OS
00610   else
00611     return 0;
00612 # elif defined (__GLIBC__)
00613   // GNU C library has a different signature
00614   //FUZZ: disable check_for_lack_ACE_OS
00615   if (::getprotobynumber_r (proto,
00616                             result,
00617                             buffer,
00618                             sizeof (ACE_PROTOENT_DATA),
00619                             &result) == 0)
00620   //FUZZ: enable check_for_lack_ACE_OS
00621     return result;
00622   else
00623     return 0;
00624 # else
00625 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00626   ACE_UNUSED_ARG (result);
00627   //FUZZ: disable check_for_lack_ACE_OS
00628   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
00629                         struct protoent *, 0,
00630                         buffer, sizeof (ACE_PROTOENT_DATA));
00631   //FUZZ: enable check_for_lack_ACE_OS
00632 #   else
00633   //FUZZ: disable check_for_lack_ACE_OS
00634   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
00635                        struct protoent *, 0);
00636   //FUZZ: enable check_for_lack_ACE_OS
00637 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00638 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00639 #else
00640   ACE_UNUSED_ARG (buffer);
00641   ACE_UNUSED_ARG (result);
00642 
00643   //FUZZ: disable check_for_lack_ACE_OS
00644   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00645                        struct protoent *, 0);
00646   //FUZZ: enable check_for_lack_ACE_OS
00647 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00648 }

ACE_INLINE struct servent* ACE_OS::getservbyname ( const char *  svc,
const char *  proto 
)

Definition at line 651 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and getservbyname().

Referenced by getservbyname(), and getservbyname_r().

00652 {
00653   ACE_OS_TRACE ("ACE_OS::getservbyname");
00654 #if defined (ACE_LACKS_GETSERVBYNAME)
00655   ACE_UNUSED_ARG (svc);
00656   ACE_UNUSED_ARG (proto);
00657   ACE_NOTSUP_RETURN (0);
00658 #elif defined (ACE_HAS_NONCONST_GETBY)
00659   //FUZZ: disable check_for_lack_ACE_OS
00660   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00661                                         const_cast<char *> (proto)),
00662                        struct servent *,
00663                        0);
00664   //FUZZ: enable check_for_lack_ACE_OS
00665 #else
00666   //FUZZ: disable check_for_lack_ACE_OS
00667   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00668                                         proto),
00669                        struct servent *,
00670                        0);
00671   //FUZZ: enable check_for_lack_ACE_OS
00672 #endif /* ACE_HAS_NONCONST_GETBY */
00673 }

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

Definition at line 676 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, getservbyname(), getservbyname_r(), and memset().

Referenced by get_port_number_from_name(), and getservbyname_r().

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

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

Definition at line 11 of file OS_NS_poll.inl.

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

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

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

Definition at line 29 of file OS_NS_poll.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_Time_Value::msec(), and poll().

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

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

Definition at line 11 of file OS_NS_poll.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_Time_Value::msec(), and poll().

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

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

Definition at line 29 of file OS_NS_poll.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_Time_Value::msec(), and poll().

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

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::endpwent ( void   ) 

Definition at line 12 of file OS_NS_pwd.inl.

References endpwent().

Referenced by cuserid(), and endpwent().

00013 {
00014 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00015   ::endpwent ();
00016 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00017 }

ACE_NAMESPACE_INLINE_FUNCTION struct passwd* ACE_OS::getpwent ( void   ) 

Definition at line 20 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN, and getpwent().

Referenced by getpwent().

00021 {
00022 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00023   return ::getpwent ();
00024 #else
00025   ACE_NOTSUP_RETURN (0);
00026 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00027 }

ACE_NAMESPACE_INLINE_FUNCTION struct passwd* ACE_OS::getpwnam ( const char *  user  ) 

Definition at line 30 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN, and getpwnam().

Referenced by getpwnam(), and ACE_Process_Options::setreugid().

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

ACE_NAMESPACE_INLINE_FUNCTION struct passwd* ACE_OS::getpwnam_r ( const char *  name,
struct passwd *  pwent,
char *  buffer,
int  buflen 
)

Definition at line 41 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN, and getpwnam_r().

Referenced by getpwnam_r().

00043 {
00044 #if defined (ACE_HAS_POSIX_GETPWNAM_R)
00045   struct passwd *result = 0;
00046 
00047   int const status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
00048 
00049   if (status != 0)
00050   {
00051     errno = status;
00052     result = 0;
00053   }
00054   return result;
00055 #elif !defined (ACE_LACKS_PWD_FUNCTIONS)
00056 # if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00057 #   if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS)
00058 #     if defined (ACE_HAS_PTHREADS) && \
00059       !defined (ACE_HAS_STHREADS) || \
00060       defined (HPUX_11)  || \
00061       defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7.
00062   struct passwd *result;
00063   int status;
00064 #       if defined (DIGITAL_UNIX)
00065   ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result);
00066 #       else
00067   // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined
00068   // in pwd.h, and that redefinition is used here
00069 #         if defined (__IBMCPP__) && (__IBMCPP__ >= 400)   /* VAC++ 4 */
00070   status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result);
00071 #         else
00072   status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
00073 #         endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */
00074   if (status != 0)
00075     {
00076       errno = status;
00077       result = 0;
00078     }
00079 #       endif /* (DIGITAL_UNIX) */
00080   return result;
00081 #     elif defined (AIX)
00082   if (::getpwnam_r (name, pwent, buffer, buflen) == -1)
00083     return 0;
00084   else
00085     return pwent;
00086 #     else
00087   return ::getpwnam_r (name, pwent, buffer, buflen);
00088 #     endif /* ACE_HAS_PTHREADS */
00089 #   else
00090   ACE_UNUSED_ARG (name);
00091   ACE_UNUSED_ARG (pwent);
00092   ACE_UNUSED_ARG (buffer);
00093   ACE_UNUSED_ARG (buflen);
00094   ACE_NOTSUP_RETURN (0);
00095 #   endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */
00096 # else
00097   ACE_UNUSED_ARG (name);
00098   ACE_UNUSED_ARG (pwent);
00099   ACE_UNUSED_ARG (buffer);
00100   ACE_UNUSED_ARG (buflen);
00101   ACE_NOTSUP_RETURN (0);
00102 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00103 #else
00104   ACE_UNUSED_ARG (name);
00105   ACE_UNUSED_ARG (pwent);
00106   ACE_UNUSED_ARG (buffer);
00107   ACE_UNUSED_ARG (buflen);
00108   ACE_NOTSUP_RETURN (0);
00109 #endif /* ACE_HAS_POSIX_GETPWNAM_R */
00110 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::setpwent ( void   ) 

Definition at line 113 of file OS_NS_pwd.inl.

References setpwent().

Referenced by cuserid(), and setpwent().

00114 {
00115 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00116   ::setpwent ();
00117 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00118 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::endpwent ( void   ) 

Definition at line 12 of file OS_NS_pwd.inl.

References endpwent().

Referenced by cuserid(), and endpwent().

00013 {
00014 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00015   ::endpwent ();
00016 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00017 }

ACE_INLINE struct passwd* ACE_OS::getpwent ( void   ) 

Definition at line 20 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN, and getpwent().

Referenced by getpwent().

00021 {
00022 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00023   return ::getpwent ();
00024 #else
00025   ACE_NOTSUP_RETURN (0);
00026 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00027 }

ACE_INLINE struct passwd* ACE_OS::getpwnam ( const char *  name  ) 

Definition at line 30 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN, and getpwnam().

Referenced by getpwnam(), and ACE_Process_Options::setreugid().

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

ACE_INLINE struct passwd* ACE_OS::getpwnam_r ( const char *  name,
struct passwd *  pwent,
char *  buffer,
int  buflen 
)

Definition at line 41 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN, and getpwnam_r().

Referenced by getpwnam_r().

00043 {
00044 #if defined (ACE_HAS_POSIX_GETPWNAM_R)
00045   struct passwd *result = 0;
00046 
00047   int const status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
00048 
00049   if (status != 0)
00050   {
00051     errno = status;
00052     result = 0;
00053   }
00054   return result;
00055 #elif !defined (ACE_LACKS_PWD_FUNCTIONS)
00056 # if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00057 #   if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS)
00058 #     if defined (ACE_HAS_PTHREADS) && \
00059       !defined (ACE_HAS_STHREADS) || \
00060       defined (HPUX_11)  || \
00061       defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7.
00062   struct passwd *result;
00063   int status;
00064 #       if defined (DIGITAL_UNIX)
00065   ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result);
00066 #       else
00067   // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined
00068   // in pwd.h, and that redefinition is used here
00069 #         if defined (__IBMCPP__) && (__IBMCPP__ >= 400)   /* VAC++ 4 */
00070   status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result);
00071 #         else
00072   status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
00073 #         endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */
00074   if (status != 0)
00075     {
00076       errno = status;
00077       result = 0;
00078     }
00079 #       endif /* (DIGITAL_UNIX) */
00080   return result;
00081 #     elif defined (AIX)
00082   if (::getpwnam_r (name, pwent, buffer, buflen) == -1)
00083     return 0;
00084   else
00085     return pwent;
00086 #     else
00087   return ::getpwnam_r (name, pwent, buffer, buflen);
00088 #     endif /* ACE_HAS_PTHREADS */
00089 #   else
00090   ACE_UNUSED_ARG (name);
00091   ACE_UNUSED_ARG (pwent);
00092   ACE_UNUSED_ARG (buffer);
00093   ACE_UNUSED_ARG (buflen);
00094   ACE_NOTSUP_RETURN (0);
00095 #   endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */
00096 # else
00097   ACE_UNUSED_ARG (name);
00098   ACE_UNUSED_ARG (pwent);
00099   ACE_UNUSED_ARG (buffer);
00100   ACE_UNUSED_ARG (buflen);
00101   ACE_NOTSUP_RETURN (0);
00102 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00103 #else
00104   ACE_UNUSED_ARG (name);
00105   ACE_UNUSED_ARG (pwent);
00106   ACE_UNUSED_ARG (buffer);
00107   ACE_UNUSED_ARG (buflen);
00108   ACE_NOTSUP_RETURN (0);
00109 #endif /* ACE_HAS_POSIX_GETPWNAM_R */
00110 }

ACE_INLINE void ACE_OS::setpwent ( void   ) 

Definition at line 113 of file OS_NS_pwd.inl.

References setpwent().

Referenced by cuserid(), and setpwent().

00114 {
00115 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00116   ::setpwent ();
00117 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00118 }

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

Definition at line 11 of file OS_NS_regex.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and compile().

Referenced by compile(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), and ACE_Local_Name_Space<, ACE_LOCK >::list_types_i().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::step ( const char *  str,
char *  expbuf 
)

Definition at line 26 of file OS_NS_regex.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and step().

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), and step().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::step");
00029 #if defined (ACE_HAS_REGEX)
00030   ACE_OSCALL_RETURN (::step (str, expbuf), int, -1);
00031 #else
00032   ACE_UNUSED_ARG (str);
00033   ACE_UNUSED_ARG (expbuf);
00034 
00035   ACE_NOTSUP_RETURN (-1);
00036 #endif /* ACE_HAS_REGEX */
00037 }

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

Definition at line 11 of file OS_NS_regex.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and compile().

Referenced by compile(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), and ACE_Local_Name_Space<, ACE_LOCK >::list_types_i().

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

ACE_INLINE int ACE_OS::step ( const char *  str,
char *  expbuf 
)

Definition at line 26 of file OS_NS_regex.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and step().

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), and step().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::step");
00029 #if defined (ACE_HAS_REGEX)
00030   ACE_OSCALL_RETURN (::step (str, expbuf), int, -1);
00031 #else
00032   ACE_UNUSED_ARG (str);
00033   ACE_UNUSED_ARG (expbuf);
00034 
00035   ACE_NOTSUP_RETURN (-1);
00036 #endif /* ACE_HAS_REGEX */
00037 }

ACE_INLINE int ACE_OS::kill ( pid_t  pid,
int  signum 
)

Definition at line 14 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

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

00015 {
00016   ACE_OS_TRACE ("ACE_OS::kill");
00017 #if defined (ACE_LACKS_KILL)
00018   ACE_UNUSED_ARG (pid);
00019   ACE_UNUSED_ARG (signum);
00020   ACE_NOTSUP_RETURN (-1);
00021 #else
00022   ACE_OSCALL_RETURN (::kill (pid, signum), int, -1);
00023 #endif /* ACE_LACKS_KILL */
00024 }

ACE_INLINE int ACE_OS::pthread_sigmask ( int  how,
const sigset_t *  nsp,
sigset_t *  osp 
)

Definition at line 27 of file OS_NS_signal.inl.

References ACE_ADAPT_RETVAL, and ACE_NOTSUP_RETURN.

Referenced by ACE_Asynch_Pseudo_Task::svc(), and thr_sigsetmask().

00028 {
00029 #if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_SIGMASK)
00030   int result;
00031   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp),
00032                                        result),
00033                      int,
00034                      -1);
00035 #else /* !ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
00036   ACE_UNUSED_ARG (how);
00037   ACE_UNUSED_ARG (nsp);
00038   ACE_UNUSED_ARG (osp);
00039   ACE_NOTSUP_RETURN (-1);
00040 #endif /* ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
00041 }

ACE_INLINE int ACE_OS::sigaction ( int  signum,
const ACE_SIGACTION nsa,
ACE_SIGACTION osa 
)

Definition at line 44 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, SIG_ERR, SIG_IGN, and signal().

Referenced by ACE_Sig_Action::ACE_Sig_Action(), ACE_Sig_Action::register_action(), ACE_Sig_Action::restore_action(), and ACE_Sig_Action::retrieve_action().

00045 {
00046   ACE_OS_TRACE ("ACE_OS::sigaction");
00047   if (signum == 0)
00048     return 0;
00049 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00050   struct sigaction sa;
00051 
00052   if (osa == 0)
00053     osa = &sa;
00054 
00055   if (nsa == 0)
00056     {
00057       osa->sa_handler = ::signal (signum, SIG_IGN);
00058       ::signal (signum, osa->sa_handler);
00059     }
00060   else
00061     osa->sa_handler = ::signal (signum, nsa->sa_handler);
00062   return osa->sa_handler == SIG_ERR ? -1 : 0;
00063 #elif defined (ACE_LACKS_SIGACTION)
00064   ACE_UNUSED_ARG (nsa);
00065   ACE_UNUSED_ARG (osa);
00066   ACE_NOTSUP_RETURN (-1);
00067 #elif !defined (ACE_HAS_SIGACTION_CONSTP2)
00068   ACE_OSCALL_RETURN (::sigaction (signum,
00069                                   const_cast<ACE_SIGACTION*> (nsa),
00070                                   osa),
00071                      int, -1);
00072 #else
00073   ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1);
00074 #endif /* ACE_WIN32 !ACE_HAS_WINCE */
00075 }

ACE_INLINE int ACE_OS::sigaddset ( sigset_t *  s,
int  signum 
)

Definition at line 78 of file OS_NS_signal.inl.

References ACE_NSIG, and ACE_OS_TRACE.

Referenced by ACE_Sig_Set::sig_add(), and ACE_Asynch_Pseudo_Task::svc().

00079 {
00080   ACE_OS_TRACE ("ACE_OS::sigaddset");
00081 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00082   if (s == 0)
00083     {
00084       errno = EFAULT;
00085       return -1;
00086     }
00087   else if (signum < 1 || signum >= ACE_NSIG)
00088     {
00089       errno = EINVAL;
00090       return -1;                 // Invalid signum, return error
00091     }
00092   *s |= (1 << (signum - 1)) ;
00093   return 0 ;
00094 #else
00095   ACE_OSCALL_RETURN (::sigaddset (s, signum), int, -1);
00096 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00097 }

ACE_INLINE int ACE_OS::sigdelset ( sigset_t *  s,
int  signum 
)

Definition at line 100 of file OS_NS_signal.inl.

References ACE_NSIG.

Referenced by ACE_Sig_Set::sig_del().

00101 {
00102 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00103   if (s == 0)
00104     {
00105       errno = EFAULT;
00106       return -1;
00107     }
00108   else if (signum < 1 || signum >= ACE_NSIG)
00109     {
00110       errno = EINVAL;
00111       return -1;                 // Invalid signum, return error
00112     }
00113   *s &= ~(1 << (signum - 1)) ;
00114   return 0;
00115 #else
00116   ACE_OSCALL_RETURN (::sigdelset (s, signum), int, -1);
00117 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00118 }

ACE_INLINE int ACE_OS::sigemptyset ( sigset_t *  s  ) 

Definition at line 121 of file OS_NS_signal.inl.

Referenced by ACE_Log_Msg_Sig_Guard::ACE_Log_Msg_Sig_Guard(), ACE_Sig_Action::ACE_Sig_Action(), ACE_Sig_Set::ACE_Sig_Set(), ACE_Sig_Set::empty_set(), sigsuspend(), ACE_Asynch_Pseudo_Task::svc(), and ACE_Sig_Set::~ACE_Sig_Set().

00122 {
00123 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00124   if (s == 0)
00125     {
00126       errno = EFAULT;
00127       return -1;
00128     }
00129   *s = 0 ;
00130   return 0;
00131 #else
00132   ACE_OSCALL_RETURN (::sigemptyset (s), int, -1);
00133 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00134 }

ACE_INLINE int ACE_OS::sigfillset ( sigset_t *  s  ) 

Definition at line 137 of file OS_NS_signal.inl.

Referenced by ACE_Sig_Set::ACE_Sig_Set(), ACE_Sig_Set::fill_set(), and ACE_OS_Object_Manager::init().

00138 {
00139 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00140   if (s == 0)
00141     {
00142       errno = EFAULT;
00143       return -1;
00144     }
00145   *s = ~(sigset_t) 0;
00146   return 0 ;
00147 #else
00148   ACE_OSCALL_RETURN (::sigfillset (s), int, -1);
00149 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00150 }

ACE_INLINE int ACE_OS::sigismember ( sigset_t *  s,
int  signum 
)

Definition at line 153 of file OS_NS_signal.inl.

References ACE_NSIG.

Referenced by ACE_Sig_Set::is_member().

00154 {
00155 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00156   if (s == 0)
00157     {
00158       errno = EFAULT;
00159       return -1;
00160     }
00161   else if (signum < 1 || signum >= ACE_NSIG)
00162     {
00163       errno = EINVAL;
00164       return -1;                 // Invalid signum, return error
00165     }
00166   return ((*s & (1 << (signum - 1))) != 0) ;
00167 #else
00168 #  if defined (ACE_HAS_SIGISMEMBER_BUG)
00169   if (signum < 1 || signum >= ACE_NSIG)
00170     {
00171       errno = EINVAL;
00172       return -1;                 // Invalid signum, return error
00173     }
00174 #  endif /* ACE_HAS_SIGISMEMBER_BUG */
00175   ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1);
00176 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00177 }

ACE_INLINE ACE_SignalHandler ACE_OS::signal ( int  signum,
ACE_SignalHandler   
)

Definition at line 180 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE::daemonize(), and sigaction().

00181 {
00182   if (signum == 0)
00183     return 0;
00184   else
00185 # if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS)
00186 #  if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS_SIGNALS)
00187     return ::signal (signum, func);
00188 #  else
00189     return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func);
00190 #  endif /* !ACE_HAS_TANDEM_SIGNALS */
00191 #else
00192     // @@ WINCE: Don't know how to implement signal on WinCE (yet.)
00193     ACE_UNUSED_ARG (signum);
00194     ACE_UNUSED_ARG (func);
00195     ACE_NOTSUP_RETURN (0);     // Should return SIG_ERR but it is not defined on WinCE.
00196 #endif /* defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) */
00197 }

ACE_INLINE int ACE_OS::sigprocmask ( int  how,
const sigset_t *  nsp,
sigset_t *  osp 
)

Definition at line 200 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Log_Msg_Sig_Guard::ACE_Log_Msg_Sig_Guard(), ACE_Sig_Guard::ACE_Sig_Guard(), ACE_Log_Msg_Sig_Guard::~ACE_Log_Msg_Sig_Guard(), and ACE_Sig_Guard::~ACE_Sig_Guard().

00201 {
00202 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00203   ACE_UNUSED_ARG (how);
00204   ACE_UNUSED_ARG (nsp);
00205   ACE_UNUSED_ARG (osp);
00206   ACE_NOTSUP_RETURN (-1);
00207 #else
00208   ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1);
00209 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00210 }

ACE_INLINE int ACE_OS::sigsuspend ( const sigset_t *  set  ) 

Definition at line 213 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, and sigemptyset().

00214 {
00215 #if defined (ACE_HAS_SIGSUSPEND)
00216   sigset_t s;
00217 
00218   if (sigset == 0)
00219     {
00220       sigset = &s;
00221       ACE_OS::sigemptyset (&s);
00222     }
00223   ACE_OSCALL_RETURN (::sigsuspend (sigset), int, -1);
00224 #else
00225   ACE_UNUSED_ARG (sigset);
00226   ACE_NOTSUP_RETURN (-1);
00227 #endif /* ACE_HAS_SIGSUSPEND */
00228 }

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

Definition at line 264 of file OS_NS_stdio.cpp.

References vfprintf().

Referenced by ACE_Service_Type::dump(), ACE_Svc_Conf_Lexer::input(), ACE_Log_Msg::log(), ACE_Service_Config::open_i(), ACE_Name_Options::parse_args(), ACE_Log_Record::print(), ACE_OS_Object_Manager::print_error_message(), ACE_Stats::print_summary(), socket_fini(), and socket_init().

00265 {
00266   // ACE_OS_TRACE ("ACE_OS::fprintf");
00267   int result = 0;
00268   va_list ap;
00269   va_start (ap, format);
00270   result = ACE_OS::vfprintf (fp, format, ap);
00271   va_end (ap);
00272   return result;
00273 }

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

Definition at line 290 of file OS_NS_stdio.cpp.

References vasprintf().

00291 {
00292   // ACE_OS_TRACE ("ACE_OS::asprintf");
00293   int result;
00294   va_list ap;
00295   va_start (ap, format);
00296   result = ACE_OS::vasprintf (bufp, format, ap);
00297   va_end (ap);
00298   return result;
00299 }

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

Definition at line 316 of file OS_NS_stdio.cpp.

References vprintf().

Referenced by ACE_Log_Msg::close(), and ACE_Throughput_Stats::sample().

00317 {
00318   // ACE_OS_TRACE ("ACE_OS::printf");
00319   int result;
00320   va_list ap;
00321   va_start (ap, format);
00322   result = ACE_OS::vprintf (format, ap);
00323   va_end (ap);
00324   return result;
00325 }

ACE_Export int ACE_OS::snprintf ( char *  buf,
size_t  maxlen,
const char *  format,
  ... 
)

Definition at line 342 of file OS_NS_stdio.cpp.

References vsnprintf().

Referenced by ACE_Log_Msg::log().

00343 {
00344   // ACE_OS_TRACE ("ACE_OS::snprintf");
00345   int result;
00346   va_list ap;
00347   va_start (ap, format);
00348   result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
00349   va_end (ap);
00350   return result;
00351 }

ACE_Export int ACE_OS::sprintf ( char *  buf,
const char *  format,
  ... 
)

Definition at line 368 of file OS_NS_stdio.cpp.

References vsprintf().

Referenced by ACE_MEM_Acceptor::accept(), ACE_Message_Queue< ACE_SYNCH_USE >::ACE_Message_Queue(), ACE_INET_Addr::addr_to_string(), dlerror(), ACE_Ini_ImpExp::export_section(), ACE_Registry_ImpExp::export_section(), ACE::format_hexdump(), ACE_Log_Record::format_msg(), ACE_Utils::UUID_Generator::generate_UUID(), ACE_INET_Addr::get_host_addr(), getmacaddress(), ACE_Logging_Strategy::handle_timeout(), inet_ntop(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE::ldfind(), ACE_Log_Msg::log(), ACE_Log_Msg::log_hexdump(), ACE_High_Res_Timer::print_ave(), ACE_Stats::print_summary(), ACE_High_Res_Timer::print_total(), ACE_Process_Options::setenv(), shm_open(), shm_unlink(), ACE::sock_error(), socket_fini(), socket_init(), ACE_Process::spawn(), strerror(), ACE::timestamp(), ACE_Utils::UUID::to_string(), uname(), and unique_name().

00369 {
00370   // ACE_OS_TRACE ("ACE_OS::sprintf");
00371   int result;
00372   va_list ap;
00373   va_start (ap, format);
00374   result = ACE_OS::vsprintf (buf, format, ap);
00375   va_end (ap);
00376   return result;
00377 }

ACE_Export int ACE_OS::vasprintf_emulation ( char **  bufp,
const char *  format,
va_list  argptr 
)

Definition at line 395 of file OS_NS_stdio.cpp.

References malloc(), va_copy, and vsnprintf().

Referenced by vasprintf().

00396 {
00397   int size;
00398 
00399   va_list ap;
00400   va_copy (ap, argptr);
00401   size = ACE_OS::vsnprintf(0, 0, format, ap);
00402   va_end (ap);
00403 
00404   if (size != -1) 
00405     {
00406       char *buf = reinterpret_cast<char*>(ACE_OS::malloc(size + 1));
00407       if (!buf)
00408         return -1;
00409 
00410       va_list aq;
00411       va_copy (aq, argptr);
00412       size = ACE_OS::vsnprintf(buf, size + 1, format, aq);
00413       va_end (aq);
00414 
00415       if (size != -1)
00416         *bufp = buf;
00417     }
00418 
00419   return size;
00420 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::clearerr ( FILE *  fp  ) 

Definition at line 344 of file OS_NS_stdio.inl.

References ace_clearerr_helper().

Referenced by ace_clearerr_helper(), and ACE_Svc_Conf_Lexer::input().

00345 {
00346   ace_clearerr_helper (fp);
00347 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::cuserid ( char *  user,
size_t  maxlen = ACE_MAX_USERID 
)

Definition at line 352 of file OS_NS_stdio.inl.

References ace_cuserid(), ACE_NOTSUP_RETURN, ACE_OS_TRACE, endpwent(), geteuid(), setpwent(), strcpy(), and strlen().

Referenced by ace_cuserid().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fclose ( FILE *  fp  ) 

Definition at line 490 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fclose().

Referenced by access(), ACE::count_interfaces(), ACE_Ini_ImpExp::export_config(), ACE_Registry_ImpExp::export_config(), fclose(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::init(), ACE_Service_Gestalt::init_i(), ACE_Log_Msg::msg_ostream(), ACE_Service_Config::open_i(), ACE_Service_Gestalt::process_file(), ACE_Log_Msg::~ACE_Log_Msg(), and ACE_Read_Buffer::~ACE_Read_Buffer().

00491 {
00492   ACE_OS_TRACE ("ACE_OS::fclose");
00493   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fclose (fp), int, -1);
00494 }

ACE_NAMESPACE_INLINE_FUNCTION FILE* ACE_OS::fdopen ( ACE_HANDLE  handle,
const ACE_TCHAR mode 
)

Definition at line 497 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_ALWAYS_WCHAR, and fdopen().

Referenced by fdopen().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fflush ( FILE *  fp  ) 

Definition at line 546 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fflush().

Referenced by fflush(), and ACE_Log_Record::print().

00547 {
00548   ACE_OS_TRACE ("ACE_OS::fflush");
00549 #if defined (ACE_VXWORKS)
00550   if (fp == 0)
00551     {
00552       // Do not allow fflush(0) on VxWorks
00553       return 0;
00554     }
00555 #endif /* ACE_VXWORKS */
00556 
00557   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fflush (fp), int, -1);
00558 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fgetc ( FILE *  fp  ) 

Definition at line 561 of file OS_NS_stdio.inl.

References ace_fgetc_helper().

Referenced by ace_fgetc_helper(), and ACE_Capabilities::getline().

00562 {
00563   return ace_fgetc_helper (fp);
00564 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::getc ( FILE *  fp  ) 

Definition at line 567 of file OS_NS_stdio.inl.

References ace_getc_helper().

Referenced by ace_getc_helper(), and ACE_Read_Buffer::rec_read().

00568 {
00569   return ace_getc_helper (fp);
00570 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fgetpos ( FILE *  fp,
fpos_t *  pos 
)

Definition at line 573 of file OS_NS_stdio.inl.

References fgetpos().

Referenced by fgetpos().

00574 {
00575   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1);
00576 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::fgets ( char *  buf,
int  size,
FILE *  fp 
)

Definition at line 579 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fgets().

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

00580 {
00581   ACE_OS_TRACE ("ACE_OS::fgets");
00582   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0);
00583 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_init ( ace_flock_t *  lock,
int  flags = 0,
const ACE_TCHAR name = 0,
mode_t  perms = 0 
)

Definition at line 90 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, open(), and strdup().

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

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_destroy ( ace_flock_t *  lock,
int  unlink_file = 1 
)

Definition at line 158 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, close(), flock_unlock(), free(), ACE_OS::ace_flock_t::handle_, and unlink().

Referenced by ACE_File_Lock::remove().

00160 {
00161   ACE_OS_TRACE ("ACE_OS::flock_destroy");
00162   if (lock->handle_ != ACE_INVALID_HANDLE)
00163     {
00164       ACE_OS::flock_unlock (lock);
00165       // Close the handle.
00166       ACE_OS::close (lock->handle_);
00167       lock->handle_ = ACE_INVALID_HANDLE;
00168       if (lock->lockname_ != 0)
00169         {
00170           if (unlink_file)
00171             ACE_OS::unlink (lock->lockname_);
00172           ACE_OS::free (
00173             static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
00174         }
00175       lock->lockname_ = 0;
00176     }
00177   return 0;
00178 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_rdlock ( ace_flock_t *  lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
)

Definition at line 181 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by ACE_File_Lock::acquire_read().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_tryrdlock ( ace_flock_t *  lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
)

Definition at line 217 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by ACE_File_Lock::tryacquire_read().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_trywrlock ( ace_flock_t *  lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
)

Definition at line 261 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

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

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_unlock ( ace_flock_t *  lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
)

Definition at line 121 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by flock_destroy(), and ACE_File_Lock::release().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::flock_wrlock ( ace_flock_t *  lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0 
)

Definition at line 306 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by ACE_File_Lock::acquire_write().

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

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

Definition at line 597 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, and fopen().

Referenced by access(), ACE::count_interfaces(), ACE_Ini_ImpExp::export_config(), ACE_Registry_ImpExp::export_config(), fopen(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::init(), ACE_Service_Gestalt::init_i(), ACE::ldopen(), ACE_Service_Config::open_i(), and ACE_Service_Gestalt::process_file().

00598 {
00599   ACE_OS_TRACE ("ACE_OS::fopen");
00600   ACE_OSCALL_RETURN
00601     (::fopen (filename, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0);
00602 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ungetc ( int  c,
FILE *  fp 
)

Definition at line 624 of file OS_NS_stdio.inl.

References ace_ungetc_helper().

Referenced by ace_ungetc_helper(), and ACE_Read_Buffer::rec_read().

00625 {
00626   return ace_ungetc_helper (c, fp);
00627 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fputc ( int  c,
FILE *  fp 
)

Definition at line 630 of file OS_NS_stdio.inl.

References ace_fputc_helper().

Referenced by ace_fputc_helper().

00631 {
00632   return ace_fputc_helper (c, fp);
00633 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::putc ( int  c,
FILE *  fp 
)

Definition at line 636 of file OS_NS_stdio.inl.

References ace_putc_helper().

Referenced by ace_putc_helper().

00637 {
00638   return ace_putc_helper (c, fp);
00639 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fputs ( const char *  s,
FILE *  stream 
)

Definition at line 642 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fputs().

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

00643 {
00644   ACE_OS_TRACE ("ACE_OS::fputs");
00645   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1);
00646 }

ACE_NAMESPACE_INLINE_FUNCTION size_t ACE_OS::fread ( void *  ptr,
size_t  size,
size_t  nelems,
FILE *  fp 
)

Definition at line 658 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fread().

Referenced by fread(), and ACE_Svc_Conf_Lexer::input().

00659 {
00660   ACE_OS_TRACE ("ACE_OS::fread");
00661   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fread (ptr, size, nelems, fp),
00662                      size_t,
00663                      0);
00664 }

ACE_NAMESPACE_INLINE_FUNCTION FILE* ACE_OS::freopen ( const ACE_TCHAR filename,
const ACE_TCHAR mode,
FILE *  stream 
)

Definition at line 667 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_ALWAYS_WCHAR, and freopen().

Referenced by freopen().

00668 {
00669   ACE_OS_TRACE ("ACE_OS::freopen");
00670 #if defined (ACE_WIN32) && (defined(ACE_USES_WCHAR) || defined(ACE_HAS_WINCE))
00671   ACE_OSCALL_RETURN (::_wfreopen (ACE_TEXT_ALWAYS_WCHAR (filename),
00672                                   ACE_TEXT_ALWAYS_WCHAR (mode),
00673                                   stream),
00674                      FILE *, 0);
00675 #else
00676   ACE_OSCALL_RETURN
00677     (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename),
00678                                  ACE_TEXT_ALWAYS_CHAR (mode),
00679                                  stream),
00680      FILE *, 0);
00681 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
00682 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fseek ( FILE *  fp,
long  offset,
int  ptrname 
)

Definition at line 685 of file OS_NS_stdio.inl.

References fseek().

Referenced by fseek(), and rewind().

00686 {
00687 # if defined (ACE_WIN32)
00688 #   if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00689   //#error Windows NT is evil AND rude!
00690   switch (whence)
00691     {
00692     case SEEK_SET:
00693       whence = FILE_BEGIN;
00694       break;
00695     case SEEK_CUR:
00696       whence = FILE_CURRENT;
00697       break;
00698     case SEEK_END:
00699       whence = FILE_END;
00700       break;
00701     default:
00702       errno = EINVAL;
00703       return -1; // rather safe than sorry
00704     }
00705 #   endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00706 # endif   /* ACE_WIN32 */
00707   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1);
00708 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fsetpos ( FILE *  fp,
fpos_t *  pos 
)

Definition at line 711 of file OS_NS_stdio.inl.

References fsetpos().

Referenced by fsetpos().

00712 {
00713   ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
00714 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::ftell ( FILE *  fp  ) 

Definition at line 717 of file OS_NS_stdio.inl.

References ftell().

Referenced by ftell(), and ACE_Logging_Strategy::handle_timeout().

00718 {
00719   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ftell (fp), long, -1);
00720 }

ACE_NAMESPACE_INLINE_FUNCTION size_t ACE_OS::fwrite ( const void *  ptr,
size_t  size,
size_t  nitems,
FILE *  fp 
)

Definition at line 723 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fwrite().

Referenced by fwrite().

00724 {
00725   ACE_OS_TRACE ("ACE_OS::fwrite");
00726   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fwrite (ptr, size, nitems, fp),
00727                      size_t,
00728                      0);
00729 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::perror ( const char *  s  ) 

Definition at line 732 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and perror().

Referenced by perror(), and ACE_OS_Object_Manager::print_error_message().

00733 {
00734   ACE_OS_TRACE ("ACE_OS::perror");
00735 #if defined (ACE_LACKS_PERROR)
00736   ACE_UNUSED_ARG (s);
00737 #else
00738   ::perror (s);
00739 #endif /* ACE_HAS_WINCE */
00740 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::puts ( const char *  s  ) 

Definition at line 759 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and puts().

Referenced by puts().

00760 {
00761   ACE_OS_TRACE ("ACE_OS::puts");
00762   ACE_OSCALL_RETURN (::puts (s), int, -1);
00763 }

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

Definition at line 781 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, and rename().

Referenced by ACE_Logging_Strategy::handle_timeout(), and rename().

00784 {
00785 # if defined (ACE_LACKS_RENAME)
00786   ACE_UNUSED_ARG (old_name);
00787   ACE_UNUSED_ARG (new_name);
00788   ACE_UNUSED_ARG (flags);
00789   ACE_NOTSUP_RETURN (-1);
00790 # elif defined (ACE_HAS_WINCE)
00791   // Win CE is always wide-char.
00792   ACE_UNUSED_ARG (flags);
00793   if (0 != MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name),
00794                      ACE_TEXT_CHAR_TO_TCHAR (new_name)))
00795     ACE_FAIL_RETURN (-1);
00796   return 0;
00797 # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX)
00798   // NT4 (and up) provides a way to rename/move a file with similar semantics
00799   // to what's usually done on UNIX - if there's an existing file with
00800   // <new_name> it is removed before the file is renamed/moved. The
00801   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00802   if (flags == -1)
00803     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00804   if (::MoveFileExA (old_name, new_name, flags) == 0)
00805     ACE_FAIL_RETURN (-1);
00806   return 0;
00807 # else /* ACE_LACKS_RENAME */
00808   ACE_UNUSED_ARG (flags);
00809   ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
00810 # endif /* ACE_LACKS_RENAME */
00811 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::rewind ( FILE *  fp  ) 

Definition at line 851 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, fseek(), and rewind().

Referenced by rewind().

00852 {
00853 #if !defined (ACE_HAS_WINCE)
00854   ACE_OS_TRACE ("ACE_OS::rewind");
00855   ::rewind (fp);
00856 #else
00857   // This isn't perfect since it doesn't reset EOF, but it's probably
00858   // the closest we can get on WINCE.
00859   (void) fseek (fp, 0L, SEEK_SET);
00860 #endif /* ACE_HAS_WINCE */
00861 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::tempnam ( const char *  dir = 0,
const char *  pfx = 0 
)

Definition at line 864 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and tempnam().

Referenced by tempnam().

00865 {
00866   ACE_OS_TRACE ("ACE_OS::tempnam");
00867 #if defined (ACE_LACKS_TEMPNAM)
00868   ACE_UNUSED_ARG (dir);
00869   ACE_UNUSED_ARG (pfx);
00870   ACE_NOTSUP_RETURN (0);
00871 #elif defined (ACE_HAS_NONCONST_TEMPNAM)
00872   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast <char *> (dir), const_cast<char *> (pfx)), char *, 0);
00873 #else /* ACE_LACKS_TEMPNAM */
00874   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0);
00875 #endif /* ACE_LACKS_TEMPNAM */
00876 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::vasprintf ( char **  bufp,
const char *  format,
va_list  argptr 
)

Definition at line 916 of file OS_NS_stdio.inl.

References vasprintf(), and vasprintf_emulation().

Referenced by asprintf(), and vasprintf().

00917 {
00918 #if defined (ACE_HAS_VASPRINTF)
00919   return ::vasprintf (bufp, format, argptr);
00920 #else
00921   return ACE_OS::vasprintf_emulation (bufp, format, argptr);
00922 #endif /* ACE_HAS_VASPRINTF */
00923 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::vprintf ( const char *  format,
va_list  argptr 
)

Definition at line 938 of file OS_NS_stdio.inl.

References vprintf().

Referenced by printf(), and vprintf().

00939 {
00940   return ::vprintf (format, argptr);
00941 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::vfprintf ( FILE *  fp,
const char *  format,
va_list  argptr 
)

Definition at line 958 of file OS_NS_stdio.inl.

References vfprintf().

Referenced by fprintf(), and vfprintf().

00959 {
00960   return ACE_STD_NAMESPACE::vfprintf (fp, format, argptr);
00961 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::vsprintf ( char *  buffer,
const char *  format,
va_list  argptr 
)

Definition at line 979 of file OS_NS_stdio.inl.

References vsprintf().

Referenced by ACE_Process_Options::command_line(), ACE_Process_Options::setenv(), sprintf(), and vsprintf().

00980 {
00981   return ::vsprintf (buffer, format, argptr);
00982 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::vsnprintf ( char *  buffer,
size_t  maxlen,
const char *  format,
va_list  argptr 
)

Definition at line 1019 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, and vsnprintf().

Referenced by ACE_Process_Options::command_line(), ACE_Process_Options::setenv(), snprintf(), vasprintf_emulation(), and vsnprintf().

01020 {
01021 #if !defined (ACE_LACKS_VSNPRINTF)
01022   int result;
01023 #  if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
01024   // _vsnprintf_s() doesn't report the length needed when it truncates. This
01025   // info is needed and relied on by others things in ACE+TAO, so don't use
01026   // this. There's adequate protection via the maxlen.
01027   result = _vsnprintf_s (buffer, maxlen, _TRUNCATE, format, ap);
01028 #  elif !defined (ACE_WIN32)
01029   result = ::vsnprintf (buffer, maxlen, format, ap);
01030 #  else
01031   result = ::_vsnprintf (buffer, maxlen, format, ap);
01032 
01033   // Win32 doesn't regard a full buffer with no 0-terminate as an overrun.
01034   if (result == static_cast<int> (maxlen))
01035     buffer[maxlen-1] = '\0';
01036 
01037   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01038   if (result == -1)
01039     buffer[maxlen-1] = '\0';
01040 # endif
01041   // In out-of-range conditions, C99 defines vsnprintf() to return the number
01042   // of characters that would have been written if enough space was available.
01043   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
01044   // -1. This method follows the C99 standard, but needs to guess at the
01045   // value; uses maxlen + 1.
01046   if (result == -1)
01047     {
01048       result = static_cast <int> (maxlen + 1);
01049     }
01050 
01051   return result;
01052 #elif defined (ACE_HAS_TRIO)
01053   return trio_vsnprintf (buffer, maxlen, format, ap);
01054 #else
01055   ACE_UNUSED_ARG (buffer);
01056   ACE_UNUSED_ARG (maxlen);
01057   ACE_UNUSED_ARG (format);
01058   ACE_UNUSED_ARG (ap);
01059   ACE_NOTSUP_RETURN (-1);
01060 #endif /* ACE_LACKS_VSNPRINTF */
01061 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::flock_init ( ACE_OS::ace_flock_t lock,
int  flags,
const ACE_TCHAR name,
mode_t  perms 
)

Definition at line 90 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, open(), and strdup().

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

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

ACE_INLINE int ACE_OS::flock_unlock ( ACE_OS::ace_flock_t lock,
short  whence,
ACE_OFF_T  start,
ACE_OFF_T  len 
)

Definition at line 121 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by flock_destroy(), and ACE_File_Lock::release().

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

ACE_INLINE int ACE_OS::flock_destroy ( ACE_OS::ace_flock_t lock,
int  unlink_file 
)

Definition at line 158 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, close(), flock_unlock(), free(), ACE_OS::ace_flock_t::handle_, and unlink().

Referenced by ACE_File_Lock::remove().

00160 {
00161   ACE_OS_TRACE ("ACE_OS::flock_destroy");
00162   if (lock->handle_ != ACE_INVALID_HANDLE)
00163     {
00164       ACE_OS::flock_unlock (lock);
00165       // Close the handle.
00166       ACE_OS::close (lock->handle_);
00167       lock->handle_ = ACE_INVALID_HANDLE;
00168       if (lock->lockname_ != 0)
00169         {
00170           if (unlink_file)
00171             ACE_OS::unlink (lock->lockname_);
00172           ACE_OS::free (
00173             static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
00174         }
00175       lock->lockname_ = 0;
00176     }
00177   return 0;
00178 }

ACE_INLINE int ACE_OS::flock_rdlock ( ACE_OS::ace_flock_t lock,
short  whence,
ACE_OFF_T  start,
ACE_OFF_T  len 
)

Definition at line 181 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by ACE_File_Lock::acquire_read().

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

ACE_INLINE int ACE_OS::flock_tryrdlock ( ACE_OS::ace_flock_t lock,
short  whence,
ACE_OFF_T  start,
ACE_OFF_T  len 
)

Definition at line 217 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by ACE_File_Lock::tryacquire_read().

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

ACE_INLINE int ACE_OS::flock_trywrlock ( ACE_OS::ace_flock_t lock,
short  whence,
ACE_OFF_T  start,
ACE_OFF_T  len 
)

Definition at line 261 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

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

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

ACE_INLINE int ACE_OS::flock_wrlock ( ACE_OS::ace_flock_t lock,
short  whence,
ACE_OFF_T  start,
ACE_OFF_T  len 
)

Definition at line 306 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fcntl(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::lock_.

Referenced by ACE_File_Lock::acquire_write().

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

ACE_INLINE void ACE_OS::clearerr ( FILE *  fp  ) 

Definition at line 344 of file OS_NS_stdio.inl.

References ace_clearerr_helper().

Referenced by ace_clearerr_helper(), and ACE_Svc_Conf_Lexer::input().

00345 {
00346   ace_clearerr_helper (fp);
00347 }

ACE_INLINE char* ACE_OS::cuserid ( char *  user,
size_t  maxlen 
)

Definition at line 352 of file OS_NS_stdio.inl.

References ace_cuserid(), ACE_NOTSUP_RETURN, ACE_OS_TRACE, endpwent(), geteuid(), setpwent(), strcpy(), and strlen().

Referenced by ace_cuserid().

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

ACE_INLINE int ACE_OS::fclose ( FILE *  fp  ) 

Definition at line 490 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fclose().

Referenced by access(), ACE::count_interfaces(), ACE_Registry_ImpExp::export_config(), ACE_Ini_ImpExp::export_config(), fclose(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Registry_ImpExp::import_config(), ACE_Ini_ImpExp::import_config(), ACE_Logging_Strategy::init(), ACE_Service_Gestalt::init_i(), ACE_Log_Msg::msg_ostream(), ACE_Service_Config::open_i(), ACE_Service_Gestalt::process_file(), ACE_Log_Msg::~ACE_Log_Msg(), and ACE_Read_Buffer::~ACE_Read_Buffer().

00491 {
00492   ACE_OS_TRACE ("ACE_OS::fclose");
00493   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fclose (fp), int, -1);
00494 }

ACE_INLINE FILE* ACE_OS::fdopen ( ACE_HANDLE  handle,
const ACE_TCHAR mode 
)

Definition at line 497 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_ALWAYS_WCHAR, and fdopen().

Referenced by fdopen().

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

ACE_INLINE int ACE_OS::fflush ( FILE *  fp  ) 

Definition at line 546 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fflush().

Referenced by fflush(), and ACE_Log_Record::print().

00547 {
00548   ACE_OS_TRACE ("ACE_OS::fflush");
00549 #if defined (ACE_VXWORKS)
00550   if (fp == 0)
00551     {
00552       // Do not allow fflush(0) on VxWorks
00553       return 0;
00554     }
00555 #endif /* ACE_VXWORKS */
00556 
00557   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fflush (fp), int, -1);
00558 }

ACE_INLINE int ACE_OS::fgetc ( FILE *  fp  ) 

Definition at line 561 of file OS_NS_stdio.inl.

References ace_fgetc_helper().

Referenced by ace_fgetc_helper(), and ACE_Capabilities::getline().

00562 {
00563   return ace_fgetc_helper (fp);
00564 }

ACE_INLINE int ACE_OS::getc ( FILE *  fp  ) 

Definition at line 567 of file OS_NS_stdio.inl.

References ace_getc_helper().

Referenced by ace_getc_helper(), and ACE_Read_Buffer::rec_read().

00568 {
00569   return ace_getc_helper (fp);
00570 }

ACE_INLINE int ACE_OS::fgetpos ( FILE *  fp,
fpos_t *  pos 
)

Definition at line 573 of file OS_NS_stdio.inl.

References fgetpos().

Referenced by fgetpos().

00574 {
00575   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1);
00576 }

ACE_INLINE char* ACE_OS::fgets ( char *  buf,
int  size,
FILE *  fp 
)

Definition at line 579 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fgets().

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

00580 {
00581   ACE_OS_TRACE ("ACE_OS::fgets");
00582   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0);
00583 }

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

Definition at line 597 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, and fopen().

Referenced by access(), ACE::count_interfaces(), ACE_Registry_ImpExp::export_config(), ACE_Ini_ImpExp::export_config(), fopen(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Registry_ImpExp::import_config(), ACE_Ini_ImpExp::import_config(), ACE_Logging_Strategy::init(), ACE_Service_Gestalt::init_i(), ACE::ldopen(), ACE_Service_Config::open_i(), and ACE_Service_Gestalt::process_file().

00598 {
00599   ACE_OS_TRACE ("ACE_OS::fopen");
00600   ACE_OSCALL_RETURN
00601     (::fopen (filename, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0);
00602 }

ACE_INLINE int ACE_OS::ungetc ( int  c,
FILE *  fp 
)

Definition at line 624 of file OS_NS_stdio.inl.

References ace_ungetc_helper().

Referenced by ace_ungetc_helper(), and ACE_Read_Buffer::rec_read().

00625 {
00626   return ace_ungetc_helper (c, fp);
00627 }

ACE_INLINE int ACE_OS::fputc ( int  c,
FILE *  fp 
)

Definition at line 630 of file OS_NS_stdio.inl.

References ace_fputc_helper().

Referenced by ace_fputc_helper().

00631 {
00632   return ace_fputc_helper (c, fp);
00633 }

ACE_INLINE int ACE_OS::putc ( int  c,
FILE *  fp 
)

Definition at line 636 of file OS_NS_stdio.inl.

References ace_putc_helper().

Referenced by ace_putc_helper().

00637 {
00638   return ace_putc_helper (c, fp);
00639 }

ACE_INLINE int ACE_OS::fputs ( const char *  s,
FILE *  stream 
)

Definition at line 642 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fputs().

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

00643 {
00644   ACE_OS_TRACE ("ACE_OS::fputs");
00645   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1);
00646 }

ACE_INLINE size_t ACE_OS::fread ( void *  ptr,
size_t  size,
size_t  nelems,
FILE *  fp 
)

Definition at line 658 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fread().

Referenced by fread(), and ACE_Svc_Conf_Lexer::input().

00659 {
00660   ACE_OS_TRACE ("ACE_OS::fread");
00661   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fread (ptr, size, nelems, fp),
00662                      size_t,
00663                      0);
00664 }

ACE_INLINE FILE* ACE_OS::freopen ( const ACE_TCHAR filename,
const ACE_TCHAR mode,
FILE *  stream 
)

Definition at line 667 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_ALWAYS_WCHAR, and freopen().

Referenced by freopen().

00668 {
00669   ACE_OS_TRACE ("ACE_OS::freopen");
00670 #if defined (ACE_WIN32) && (defined(ACE_USES_WCHAR) || defined(ACE_HAS_WINCE))
00671   ACE_OSCALL_RETURN (::_wfreopen (ACE_TEXT_ALWAYS_WCHAR (filename),
00672                                   ACE_TEXT_ALWAYS_WCHAR (mode),
00673                                   stream),
00674                      FILE *, 0);
00675 #else
00676   ACE_OSCALL_RETURN
00677     (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename),
00678                                  ACE_TEXT_ALWAYS_CHAR (mode),
00679                                  stream),
00680      FILE *, 0);
00681 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
00682 }

ACE_INLINE int ACE_OS::fseek ( FILE *  fp,
long  offset,
int  whence 
)

Definition at line 685 of file OS_NS_stdio.inl.

References fseek().

Referenced by fseek(), and rewind().

00686 {
00687 # if defined (ACE_WIN32)
00688 #   if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00689   //#error Windows NT is evil AND rude!
00690   switch (whence)
00691     {
00692     case SEEK_SET:
00693       whence = FILE_BEGIN;
00694       break;
00695     case SEEK_CUR:
00696       whence = FILE_CURRENT;
00697       break;
00698     case SEEK_END:
00699       whence = FILE_END;
00700       break;
00701     default:
00702       errno = EINVAL;
00703       return -1; // rather safe than sorry
00704     }
00705 #   endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00706 # endif   /* ACE_WIN32 */
00707   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1);
00708 }

ACE_INLINE int ACE_OS::fsetpos ( FILE *  fp,
fpos_t *  pos 
)

Definition at line 711 of file OS_NS_stdio.inl.

References fsetpos().

Referenced by fsetpos().

00712 {
00713   ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
00714 }

ACE_INLINE long ACE_OS::ftell ( FILE *  fp  ) 

Definition at line 717 of file OS_NS_stdio.inl.

References ftell().

Referenced by ftell(), and ACE_Logging_Strategy::handle_timeout().

00718 {
00719   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ftell (fp), long, -1);
00720 }

ACE_INLINE size_t ACE_OS::fwrite ( const void *  ptr,
size_t  size,
size_t  nitems,
FILE *  fp 
)

Definition at line 723 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fwrite().

Referenced by fwrite().

00724 {
00725   ACE_OS_TRACE ("ACE_OS::fwrite");
00726   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fwrite (ptr, size, nitems, fp),
00727                      size_t,
00728                      0);
00729 }

ACE_INLINE void ACE_OS::perror ( const char *  s  ) 

Definition at line 732 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and perror().

Referenced by perror(), and ACE_OS_Object_Manager::print_error_message().

00733 {
00734   ACE_OS_TRACE ("ACE_OS::perror");
00735 #if defined (ACE_LACKS_PERROR)
00736   ACE_UNUSED_ARG (s);
00737 #else
00738   ::perror (s);
00739 #endif /* ACE_HAS_WINCE */
00740 }

ACE_INLINE int ACE_OS::puts ( const char *  s  ) 

Definition at line 759 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and puts().

Referenced by puts().

00760 {
00761   ACE_OS_TRACE ("ACE_OS::puts");
00762   ACE_OSCALL_RETURN (::puts (s), int, -1);
00763 }

ACE_INLINE int ACE_OS::rename ( const char *  old_name,
const char *  new_name,
int  flags 
)

Definition at line 781 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, and rename().

Referenced by ACE_Logging_Strategy::handle_timeout(), and rename().

00784 {
00785 # if defined (ACE_LACKS_RENAME)
00786   ACE_UNUSED_ARG (old_name);
00787   ACE_UNUSED_ARG (new_name);
00788   ACE_UNUSED_ARG (flags);
00789   ACE_NOTSUP_RETURN (-1);
00790 # elif defined (ACE_HAS_WINCE)
00791   // Win CE is always wide-char.
00792   ACE_UNUSED_ARG (flags);
00793   if (0 != MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name),
00794                      ACE_TEXT_CHAR_TO_TCHAR (new_name)))
00795     ACE_FAIL_RETURN (-1);
00796   return 0;
00797 # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX)
00798   // NT4 (and up) provides a way to rename/move a file with similar semantics
00799   // to what's usually done on UNIX - if there's an existing file with
00800   // <new_name> it is removed before the file is renamed/moved. The
00801   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00802   if (flags == -1)
00803     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00804   if (::MoveFileExA (old_name, new_name, flags) == 0)
00805     ACE_FAIL_RETURN (-1);
00806   return 0;
00807 # else /* ACE_LACKS_RENAME */
00808   ACE_UNUSED_ARG (flags);
00809   ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
00810 # endif /* ACE_LACKS_RENAME */
00811 }

ACE_INLINE void ACE_OS::rewind ( FILE *  fp  ) 

Definition at line 851 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, fseek(), and rewind().

Referenced by rewind().

00852 {
00853 #if !defined (ACE_HAS_WINCE)
00854   ACE_OS_TRACE ("ACE_OS::rewind");
00855   ::rewind (fp);
00856 #else
00857   // This isn't perfect since it doesn't reset EOF, but it's probably
00858   // the closest we can get on WINCE.
00859   (void) fseek (fp, 0L, SEEK_SET);
00860 #endif /* ACE_HAS_WINCE */
00861 }

ACE_INLINE char* ACE_OS::tempnam ( const char *  dir,
const char *  pfx 
)

Definition at line 864 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and tempnam().

Referenced by tempnam().

00865 {
00866   ACE_OS_TRACE ("ACE_OS::tempnam");
00867 #if defined (ACE_LACKS_TEMPNAM)
00868   ACE_UNUSED_ARG (dir);
00869   ACE_UNUSED_ARG (pfx);
00870   ACE_NOTSUP_RETURN (0);
00871 #elif defined (ACE_HAS_NONCONST_TEMPNAM)
00872   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast <char *> (dir), const_cast<char *> (pfx)), char *, 0);
00873 #else /* ACE_LACKS_TEMPNAM */
00874   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0);
00875 #endif /* ACE_LACKS_TEMPNAM */
00876 }

ACE_INLINE int ACE_OS::vasprintf ( char **  bufp,
const char *  format,
va_list  argptr 
)

Definition at line 916 of file OS_NS_stdio.inl.

References vasprintf(), and vasprintf_emulation().

Referenced by asprintf(), and vasprintf().

00917 {
00918 #if defined (ACE_HAS_VASPRINTF)
00919   return ::vasprintf (bufp, format, argptr);
00920 #else
00921   return ACE_OS::vasprintf_emulation (bufp, format, argptr);
00922 #endif /* ACE_HAS_VASPRINTF */
00923 }

ACE_INLINE int ACE_OS::vprintf ( const char *  format,
va_list  argptr 
)

Definition at line 938 of file OS_NS_stdio.inl.

References vprintf().

Referenced by printf(), and vprintf().

00939 {
00940   return ::vprintf (format, argptr);
00941 }

ACE_INLINE int ACE_OS::vfprintf ( FILE *  fp,
const char *  format,
va_list  argptr 
)

Definition at line 958 of file OS_NS_stdio.inl.

References vfprintf().

Referenced by fprintf(), and vfprintf().

00959 {
00960   return ACE_STD_NAMESPACE::vfprintf (fp, format, argptr);
00961 }

ACE_INLINE int ACE_OS::vsprintf ( char *  buffer,
const char *  format,
va_list  argptr 
)

Definition at line 979 of file OS_NS_stdio.inl.

References vsprintf().

Referenced by ACE_Process_Options::command_line(), ACE_Process_Options::setenv(), sprintf(), and vsprintf().

00980 {
00981   return ::vsprintf (buffer, format, argptr);
00982 }

ACE_INLINE int ACE_OS::vsnprintf ( char *  buffer,
size_t  maxlen,
const char *  format,
va_list  ap 
)

Definition at line 1019 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, and vsnprintf().

Referenced by ACE_Process_Options::command_line(), ACE_Process_Options::setenv(), snprintf(), vasprintf_emulation(), and vsnprintf().

01020 {
01021 #if !defined (ACE_LACKS_VSNPRINTF)
01022   int result;
01023 #  if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
01024   // _vsnprintf_s() doesn't report the length needed when it truncates. This
01025   // info is needed and relied on by others things in ACE+TAO, so don't use
01026   // this. There's adequate protection via the maxlen.
01027   result = _vsnprintf_s (buffer, maxlen, _TRUNCATE, format, ap);
01028 #  elif !defined (ACE_WIN32)
01029   result = ::vsnprintf (buffer, maxlen, format, ap);
01030 #  else
01031   result = ::_vsnprintf (buffer, maxlen, format, ap);
01032 
01033   // Win32 doesn't regard a full buffer with no 0-terminate as an overrun.
01034   if (result == static_cast<int> (maxlen))
01035     buffer[maxlen-1] = '\0';
01036 
01037   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01038   if (result == -1)
01039     buffer[maxlen-1] = '\0';
01040 # endif
01041   // In out-of-range conditions, C99 defines vsnprintf() to return the number
01042   // of characters that would have been written if enough space was available.
01043   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
01044   // -1. This method follows the C99 standard, but needs to guess at the
01045   // value; uses maxlen + 1.
01046   if (result == -1)
01047     {
01048       result = static_cast <int> (maxlen + 1);
01049     }
01050 
01051   return result;
01052 #elif defined (ACE_HAS_TRIO)
01053   return trio_vsnprintf (buffer, maxlen, format, ap);
01054 #else
01055   ACE_UNUSED_ARG (buffer);
01056   ACE_UNUSED_ARG (maxlen);
01057   ACE_UNUSED_ARG (format);
01058   ACE_UNUSED_ARG (ap);
01059   ACE_NOTSUP_RETURN (-1);
01060 #endif /* ACE_LACKS_VSNPRINTF */
01061 }

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

Definition at line 39 of file OS_NS_stdlib.cpp.

References ACE_CALLOC_FUNC, and ACE_MALLOC_FUNC.

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

ACE_Export void ACE_OS::exit ( int  status = 0  ) 

Definition at line 51 of file OS_NS_stdlib.cpp.

References ACE_OS_TRACE, and exit_hook_.

Referenced by _exit(), abort(), ACE::daemonize(), fork_exec(), ACE_Svc_Conf_Lexer::input(), and ACE_Process::spawn().

00052 {
00053   ACE_OS_TRACE ("ACE_OS::exit");
00054 
00055 #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
00056   // Shut down the ACE_Object_Manager, if it had registered its exit_hook.
00057   // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is
00058   // instantiated on the main's stack.  ::exit () doesn't destroy it.
00059   if (exit_hook_)
00060     (*exit_hook_) ();
00061 #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
00062 
00063 #if !defined (ACE_HAS_WINCE)
00064 # if defined (ACE_WIN32)
00065   ::ExitProcess ((UINT) status);
00066 # else
00067   ::exit (status);
00068 # endif /* ACE_WIN32 */
00069 #else
00070   // @@ This is not exactly the same as ExitProcess.  But this is the
00071   // closest one I can get.
00072   ::TerminateProcess (::GetCurrentProcess (), status);
00073 #endif /* ACE_HAS_WINCE */
00074 }

ACE_Export void ACE_OS::free ( void *  ptr  ) 

Definition at line 77 of file OS_NS_stdlib.cpp.

References ACE_FREE_FUNC, and ACE_MALLOC_T.

Referenced by ACE_ARGV_T< CHAR_TYPE >::add(), argv_to_string(), ACE_Dirent_Selector::close(), ACE::count_interfaces(), ACE_Name_Options::database(), event_destroy(), flock_destroy(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Log_Msg::local_host(), ACE_Name_Options::nameserver_host(), ACE_Name_Options::namespace_dir(), ACE_Log_Msg::open(), ACE_Name_Binding::operator=(), ACE_Name_Options::process_name(), putenv(), ACE_Codeset_Registry::registry_to_locale(), ACE_Mutex::remove(), ACE_Auto_String_Free::reset(), scandir_emulation(), sema_destroy(), ACE_SPIPE_Addr::set(), ACE_INET_Addr::string_to_addr(), ACE_Log_Msg::sync(), ACE_ARGV_T< CHAR_TYPE >::~ACE_ARGV_T(), ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter(), ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap(), ACE_Hash_Map_Entry< EXT_ID, INT_ID >::~ACE_Hash_Map_Entry(), ACE_Log_Msg::~ACE_Log_Msg(), ACE_Malloc_FIFO_Iterator_T<, ACE_LOCK, ACE_CB >::~ACE_Malloc_FIFO_Iterator_T(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::~ACE_Malloc_LIFO_Iterator_T(), ACE_Name_Binding::~ACE_Name_Binding(), ACE_Name_Options::~ACE_Name_Options(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::~ACE_Strategy_Acceptor().

00078 {
00079   ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
00080 }

ACE_Export ACE_TCHAR * ACE_OS::getenvstrings ( void   ) 

Definition at line 92 of file OS_NS_stdlib.cpp.

References ACE_NOTSUP_RETURN.

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

ACE_Export ACE_TCHAR * ACE_OS::strenvdup ( const ACE_TCHAR str  ) 

Definition at line 113 of file OS_NS_stdlib.cpp.

References ACE_DEFAULT_ARGV_BUFSIZ, ACE_NOTSUP_RETURN, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_CHAR_TO_TCHAR, getenv(), malloc(), strchr(), strcpy(), strcspn(), strdup(), strecpy(), strlen(), and strncpy().

Referenced by argv_to_string(), ACE::strenvdup(), and string_to_argv().

00114 {
00115 #if defined (ACE_HAS_WINCE)
00116   // WinCE doesn't have environment variables so we just skip it.
00117   return ACE_OS::strdup (str);
00118 #elif defined (ACE_LACKS_ENV)
00119   ACE_UNUSED_ARG (str);
00120   ACE_NOTSUP_RETURN (0);
00121 #else
00122   const ACE_TCHAR * start = 0;
00123   if ((start = ACE_OS::strchr (str, ACE_TEXT ('$'))) != 0)
00124     {
00125       ACE_TCHAR buf[ACE_DEFAULT_ARGV_BUFSIZ];
00126       size_t var_len = ACE_OS::strcspn (&start[1],
00127         ACE_TEXT ("$~!#%^&*()-+=\\|/?,.;:'\"`[]{} \t\n\r"));
00128       ACE_OS::strncpy (buf, &start[1], var_len);
00129       buf[var_len++] = ACE_TEXT ('\0');
00130 #  if defined (ACE_WIN32)
00131       // Always use the ACE_TCHAR for Windows.
00132       ACE_TCHAR *temp = ACE_OS::getenv (buf);
00133 #  else
00134       // Use char * for environment on non-Windows.
00135       char *temp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (buf));
00136 #  endif /* ACE_WIN32 */
00137       size_t buf_len = ACE_OS::strlen (str) + 1;
00138       if (temp != 0)
00139         buf_len += ACE_OS::strlen (temp) - var_len;
00140       ACE_TCHAR * buf_p = buf;
00141       if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ)
00142         {
00143           buf_p =
00144             (ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR));
00145           if (buf_p == 0)
00146             {
00147               errno = ENOMEM;
00148               return 0;
00149             }
00150         }
00151       ACE_TCHAR * p = buf_p;
00152       size_t len = start - str;
00153       ACE_OS::strncpy (p, str, len);
00154       p += len;
00155       if (temp != 0)
00156         {
00157 #  if defined (ACE_WIN32)
00158           p = ACE_OS::strecpy (p, temp) - 1;
00159 #  else
00160           p = ACE_OS::strecpy (p, ACE_TEXT_CHAR_TO_TCHAR (temp)) - 1;
00161 #  endif /* ACE_WIN32 */
00162         }
00163       else
00164         {
00165           ACE_OS::strncpy (p, start, var_len);
00166           p += var_len;
00167           *p = ACE_TEXT ('\0');
00168         }
00169       ACE_OS::strcpy (p, &start[var_len]);
00170       return (buf_p == buf) ? ACE_OS::strdup (buf) : buf_p;
00171     }
00172   else
00173     return ACE_OS::strdup (str);
00174 #endif /* ACE_HAS_WINCE */
00175 }

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

Emulated itoa - Converts an integer to a string.

Definition at line 179 of file OS_NS_stdlib.cpp.

Referenced by itoa().

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

ACE_Export void * ACE_OS::malloc ( size_t  nbytes  ) 

Definition at line 284 of file OS_NS_stdlib.cpp.

References ACE_MALLOC_FUNC.

Referenced by ACE_Name_Options::ACE_Name_Options(), argv_to_string(), ACE::count_interfaces(), ACE::ldfind(), scandir_emulation(), strenvdup(), ACE::strndup(), and vasprintf_emulation().

00285 {
00286   return ACE_MALLOC_FUNC (nbytes);
00287 }

ACE_Export void * ACE_OS::realloc ( void *  ptr,
size_t  nbytes 
)

Definition at line 340 of file OS_NS_stdlib.cpp.

References ACE_MALLOC_T, and ACE_REALLOC_FUNC.

Referenced by scandir_emulation().

00341 {
00342   return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
00343 }

ACE_Export const char * ACE_OS::getprogname_emulation (  ) 

Definition at line 783 of file OS_NS_stdlib.cpp.

Referenced by getprogname().

00784 {
00785     return __progname;
00786 }

ACE_Export void ACE_OS::setprogname_emulation ( const char *  progname  ) 

Definition at line 791 of file OS_NS_stdlib.cpp.

References strrchr().

Referenced by setprogname().

00792 {
00793   const char *p = ACE_OS::strrchr (progname, '/');
00794   if (p != 0)
00795     __progname = p + 1;
00796   else
00797     __progname = progname;
00798 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::_exit ( int  status = 0  ) 

Definition at line 24 of file OS_NS_stdlib.inl.

References _exit(), ACE_OS_TRACE, and exit().

Referenced by _exit(), ACE::fork(), and ACE_Process::spawn().

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

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::abort ( void   ) 

Definition at line 37 of file OS_NS_stdlib.inl.

References abort(), and exit().

Referenced by abort(), and ACE_Log_Msg::log().

00038 {
00039 #if !defined (ACE_HAS_WINCE)
00040   ::abort ();
00041 #else
00042   // @@ CE doesn't support abort?
00043   exit (1);
00044 #endif /* !ACE_HAS_WINCE */
00045 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::atexit ( ACE_EXIT_HOOK  func  ) 

Definition at line 48 of file OS_NS_stdlib.inl.

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

00049 {
00050   return ACE_OS_Object_Manager::instance ()->at_exit (func);
00051 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::atoi ( const char *  s  ) 

Definition at line 54 of file OS_NS_stdlib.inl.

References atoi().

Referenced by atoi(), atop(), ACE_High_Res_Timer::get_env_global_scale_factor(), ACE_Service_Manager::init(), ACE_Name_Options::parse_args(), ACE_Logging_Strategy::parse_args(), ACE_Service_Config::parse_args_i(), and ACE_Registry_ImpExp::process_previous_line_format().

00055 {
00056   ACE_OSCALL_RETURN (::atoi (s), int, -1);
00057 }

ACE_NAMESPACE_INLINE_FUNCTION void* ACE_OS::atop ( const char *  s  ) 

Definition at line 76 of file OS_NS_stdlib.inl.

References ACE_TRACE, and atoi().

Referenced by ACE_Name_Options::parse_args().

00077 {
00078   ACE_TRACE ("ACE_OS::atop");
00079 #if defined (ACE_WIN64)
00080   intptr_t ip = ::_atoi64 (s);
00081 #elif defined (ACE_OPENVMS)
00082 #  if !defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)
00083   int ip = ::atoi (s);
00084 #  else
00085   intptr_t ip = ::atoi (s);
00086 #  endif
00087 #else
00088   intptr_t ip = ::atoi (s);
00089 #endif /* ACE_WIN64 */
00090   void * p = reinterpret_cast<void *> (ip);
00091   return p;
00092 }

ACE_NAMESPACE_INLINE_FUNCTION void* ACE_OS::bsearch ( const void *  key,
const void *  base,
size_t  nel,
size_t  size,
ACE_COMPARE_FUNC   
)

Definition at line 115 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, and bsearch().

Referenced by bsearch().

00120 {
00121 #if !defined (ACE_LACKS_BSEARCH)
00122   return ::bsearch (key, base, nel, size, compar);
00123 #else
00124   ACE_UNUSED_ARG (key);
00125   ACE_UNUSED_ARG (base);
00126   ACE_UNUSED_ARG (nel);
00127   ACE_UNUSED_ARG (size);
00128   ACE_UNUSED_ARG (compar);
00129   ACE_NOTSUP_RETURN (0);
00130 #endif /* ACE_LACKS_BSEARCH */
00131 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::getenv ( const char *  symbol  ) 

Definition at line 134 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getenv().

Referenced by ACE_Get_Opt::ACE_Get_Opt(), ACE_Log_Msg::ACE_Log_Msg(), ACE::debug(), ACE_Env_Value< T >::fetch_value(), ACE_High_Res_Timer::get_env_global_scale_factor(), ACE::get_temp_dir(), getenv(), ACE::ldfind(), and strenvdup().

00135 {
00136   ACE_OS_TRACE ("ACE_OS::getenv");
00137 #if defined (ACE_LACKS_ENV)
00138   ACE_UNUSED_ARG (symbol);
00139   ACE_NOTSUP_RETURN (0);
00140 #else /* ACE_LACKS_ENV */
00141   ACE_OSCALL_RETURN (::getenv (symbol), char *, 0);
00142 #endif /* ACE_LACKS_ENV */
00143 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::itoa ( int  value,
char *  string,
int  radix 
)

Converts an integer to a string.

Definition at line 159 of file OS_NS_stdlib.inl.

References itoa(), and itoa_emulation().

Referenced by itoa().

00160 {
00161 #if !defined (ACE_HAS_ITOA)
00162   return ACE_OS::itoa_emulation (value, string, radix);
00163 #elif defined (ACE_ITOA_EQUIVALENT)
00164   return ACE_ITOA_EQUIVALENT (value, string, radix);
00165 #else /* !ACE_HAS_ITOA */
00166   return ::itoa (value, string, radix);
00167 #endif /* !ACE_HAS_ITOA */
00168 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_HANDLE ACE_OS::mkstemp ( char *  s  ) 

Definition at line 183 of file OS_NS_stdlib.inl.

References ACE_TEXT_CHAR_TO_TCHAR, and mkstemp().

Referenced by ACE_FILE_Connector::connect(), and mkstemp().

00184 {
00185 #if !defined (ACE_LACKS_MKSTEMP)
00186   return ::mkstemp (s);
00187 #else
00188   return ACE_OS::mkstemp_emulation (ACE_TEXT_CHAR_TO_TCHAR (s));
00189 #endif  /* !ACE_LACKS_MKSTEMP */
00190 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::mktemp ( char *  s  ) 

Definition at line 206 of file OS_NS_stdlib.inl.

References mktemp().

Referenced by ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), mktemp(), and ACE_FILE_Addr::set().

00207 {
00208 # if defined (ACE_WIN32)
00209   return ::_mktemp (s);
00210 # else /* ACE_WIN32 */
00211   return ::mktemp (s);
00212 # endif /* ACE_WIN32 */
00213 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::putenv ( const char *  string  ) 

Definition at line 244 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, free(), putenv(), strchr(), and strdup().

Referenced by putenv(), and ACE_Process::spawn().

00245 {
00246   ACE_OS_TRACE ("ACE_OS::putenv");
00247 #if defined (ACE_HAS_WINCE)
00248   // WinCE don't have the concept of environment variables.
00249   ACE_UNUSED_ARG (string);
00250   ACE_NOTSUP_RETURN (-1);
00251 #elif defined (ACE_LACKS_PUTENV) && defined (ACE_HAS_SETENV)
00252   int result = 0;
00253   char *sp = ACE_OS::strchr (const_cast <char *> (string), '=');
00254   if (sp)
00255     {
00256       char *stmp = ACE_OS::strdup (string);
00257       if (stmp)
00258         {
00259           stmp[sp - string] = '\0';
00260           ACE_OSCALL (::setenv (stmp, sp+sizeof (char), 1), int, -1, result);
00261           ACE_OS::free (stmp);
00262         }
00263       else
00264         {
00265           errno = ENOMEM;
00266           result = -1;
00267         }
00268     }
00269   else
00270     ACE_OSCALL (::setenv (string, "", 1), int, -1, result);
00271 
00272   return result;
00273 #elif defined (ACE_LACKS_ENV) || defined (ACE_LACKS_PUTENV)
00274   ACE_UNUSED_ARG (string);
00275   ACE_NOTSUP_RETURN (0);
00276 #else /* ! ACE_HAS_WINCE */
00277   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::putenv (const_cast <char *> (string)), int, -1);
00278 #endif /* ACE_HAS_WINCE */
00279 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::qsort ( void *  base,
size_t  nel,
size_t  width,
ACE_COMPARE_FUNC   
)

Definition at line 297 of file OS_NS_stdlib.inl.

References qsort().

Referenced by qsort(), and scandir_emulation().

00301 {
00302 #if !defined (ACE_LACKS_QSORT)
00303   ::qsort (base, nel, width, compar);
00304 #else
00305   ACE_UNUSED_ARG (base);
00306   ACE_UNUSED_ARG (nel);
00307   ACE_UNUSED_ARG (width);
00308   ACE_UNUSED_ARG (compar);
00309 #endif /* !ACE_LACKS_QSORT */
00310 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rand ( void   ) 

Definition at line 313 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and rand().

Referenced by ACE_Utils::UUID_Generator::init(), rand(), and rand_r().

00314 {
00315   ACE_OS_TRACE ("ACE_OS::rand");
00316   ACE_OSCALL_RETURN (::rand (), int, -1);
00317 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rand_r ( ACE_RANDR_TYPE seed  ) 

Definition at line 322 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, rand(), and rand_r().

Referenced by rand_r().

00323 {
00324   ACE_OS_TRACE ("ACE_OS::rand_r");
00325 # if defined (ACE_HAS_REENTRANT_FUNCTIONS) && \
00326     !defined (ACE_LACKS_RAND_REENTRANT_FUNCTIONS)
00327 #   if defined (DIGITAL_UNIX)
00328   ACE_OSCALL_RETURN (::_Prand_r (&seed), int, -1);
00329 #   elif defined (ACE_HAS_BROKEN_RANDR)
00330   ACE_OSCALL_RETURN (::rand_r (seed), int, -1);
00331 #   else
00332   ACE_OSCALL_RETURN (::rand_r (&seed), int, -1);
00333 #   endif /* DIGITAL_UNIX */
00334 # else
00335   ACE_UNUSED_ARG (seed);
00336   ACE_OSCALL_RETURN (::rand (), int, -1);
00337 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00338 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::realpath ( const char *  file_name,
char *  resolved_name 
)

Definition at line 363 of file OS_NS_stdlib.inl.

References PATH_MAX, and realpath().

Referenced by realpath().

00365 {
00366 #    if defined (ACE_WIN32)
00367   return ::_fullpath (resolved_name, file_name, PATH_MAX);
00368 #    else /* ACE_WIN32 */
00369   return ::realpath (file_name, resolved_name);
00370 #    endif /* ! ACE_WIN32 */
00371 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_EXIT_HOOK ACE_OS::set_exit_hook ( ACE_EXIT_HOOK  hook  ) 

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

Definition at line 397 of file OS_NS_stdlib.inl.

References ACE_EXIT_HOOK, and exit_hook_.

Referenced by ACE_OS_Object_Manager::init().

00398 {
00399   ACE_EXIT_HOOK old_hook = exit_hook_;
00400   exit_hook_ = exit_hook;
00401   return old_hook;
00402 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::srand ( u_int  seed  ) 

Definition at line 405 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and srand().

Referenced by srand().

00406 {
00407   ACE_OS_TRACE ("ACE_OS::srand");
00408   ::srand (seed);
00409 }

ACE_NAMESPACE_INLINE_FUNCTION double ACE_OS::strtod ( const char *  s,
char **  endptr 
)

Converts a string to a double value (char version).

Definition at line 413 of file OS_NS_stdlib.inl.

References strtod().

Referenced by ACE_Convert(), and strtod().

00414 {
00415   return ::strtod (s, endptr);
00416 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::strtol ( const char *  s,
char **  ptr,
int  base 
)

Converts a string to a long value (char version).

Definition at line 428 of file OS_NS_stdlib.inl.

References strtol().

Referenced by ACE_Convert(), get_port_number_from_name(), ACE_INET_Addr::string_to_addr(), and strtol().

00429 {
00430 #if defined (ACE_LACKS_STRTOL)
00431   return ACE_OS::strtol_emulation (s, ptr, base);
00432 #else  /* ACE_LACKS_STRTOL */
00433   return ::strtol (s, ptr, base);
00434 #endif /* ACE_LACKS_STRTOL */
00435 }

ACE_NAMESPACE_INLINE_FUNCTION unsigned long ACE_OS::strtoul ( const char *  s,
char **  ptr,
int  base 
)

Converts a string to an unsigned long value (char version).

Definition at line 446 of file OS_NS_stdlib.inl.

References strtoul().

Referenced by ACE_Convert(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::parse_args(), and strtoul().

00447 {
00448 #if defined (ACE_LACKS_STRTOUL)
00449   return ACE_OS::strtoul_emulation (s, ptr, base);
00450 #else /* ACE_LACKS_STRTOUL */
00451   return ::strtoul (s, ptr, base);
00452 #endif /* ACE_LACKS_STRTOUL */
00453 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::system ( const ACE_TCHAR s  ) 

Definition at line 464 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_TEXT_ALWAYS_CHAR, and system().

Referenced by system().

00465 {
00466   // ACE_OS_TRACE ("ACE_OS::system");
00467 #if defined (ACE_LACKS_SYSTEM)
00468   ACE_UNUSED_ARG (s);
00469   ACE_NOTSUP_RETURN (-1);
00470 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00471   ACE_OSCALL_RETURN (::_wsystem (s), int, -1);
00472 #elif defined (ACE_TANDEM_T1248_PTHREADS)
00473   ACE_OSCALL_RETURN (::spt_system (s), int, -1);
00474 #else
00475   ACE_OSCALL_RETURN (::system (ACE_TEXT_ALWAYS_CHAR (s)), int, -1);
00476 #endif /* ACE_LACKS_SYSTEM */
00477 }

ACE_NAMESPACE_INLINE_FUNCTION const char* ACE_OS::getprogname (  ) 

Get the name of the current program

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

Definition at line 480 of file OS_NS_stdlib.inl.

References getprogname(), and getprogname_emulation().

Referenced by getprogname().

00481 {
00482 #if defined (ACE_HAS_GETPROGNAME)
00483   return ::getprogname ();
00484 #else
00485   return ACE_OS::getprogname_emulation ();
00486 #endif /* ACE_HAS_GETPROGNAME */
00487 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::setprogname ( const char *  name  ) 

Set the name of the current program

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

Definition at line 490 of file OS_NS_stdlib.inl.

References setprogname(), and setprogname_emulation().

Referenced by setprogname().

00491 {
00492 #if defined (ACE_HAS_SETPROGNAME)
00493   ::setprogname (name);
00494 #else
00495   ACE_OS::setprogname_emulation (name);
00496 #endif /* ACE_HAS_SETPROGNAME */
00497 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::_exit ( int  status  ) 

Definition at line 24 of file OS_NS_stdlib.inl.

References _exit(), ACE_OS_TRACE, and exit().

Referenced by _exit(), ACE::fork(), and ACE_Process::spawn().

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

ACE_INLINE void ACE_OS::abort ( void   ) 

Definition at line 37 of file OS_NS_stdlib.inl.

References abort(), and exit().

Referenced by abort(), and ACE_Log_Msg::log().

00038 {
00039 #if !defined (ACE_HAS_WINCE)
00040   ::abort ();
00041 #else
00042   // @@ CE doesn't support abort?
00043   exit (1);
00044 #endif /* !ACE_HAS_WINCE */
00045 }

ACE_INLINE int ACE_OS::atexit ( ACE_EXIT_HOOK  func  ) 

Definition at line 48 of file OS_NS_stdlib.inl.

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

00049 {
00050   return ACE_OS_Object_Manager::instance ()->at_exit (func);
00051 }

ACE_INLINE int ACE_OS::atoi ( const char *  s  ) 

Definition at line 54 of file OS_NS_stdlib.inl.

References atoi().

Referenced by atoi(), atop(), ACE_High_Res_Timer::get_env_global_scale_factor(), ACE_Service_Manager::init(), ACE_Logging_Strategy::parse_args(), ACE_Name_Options::parse_args(), ACE_Service_Config::parse_args_i(), and ACE_Registry_ImpExp::process_previous_line_format().

00055 {
00056   ACE_OSCALL_RETURN (::atoi (s), int, -1);
00057 }

ACE_INLINE void* ACE_OS::atop ( const char *  s  ) 

Definition at line 76 of file OS_NS_stdlib.inl.

References ACE_TRACE, and atoi().

Referenced by ACE_Name_Options::parse_args().

00077 {
00078   ACE_TRACE ("ACE_OS::atop");
00079 #if defined (ACE_WIN64)
00080   intptr_t ip = ::_atoi64 (s);
00081 #elif defined (ACE_OPENVMS)
00082 #  if !defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)
00083   int ip = ::atoi (s);
00084 #  else
00085   intptr_t ip = ::atoi (s);
00086 #  endif
00087 #else
00088   intptr_t ip = ::atoi (s);
00089 #endif /* ACE_WIN64 */
00090   void * p = reinterpret_cast<void *> (ip);
00091   return p;
00092 }

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

Definition at line 115 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, and bsearch().

Referenced by bsearch().

00120 {
00121 #if !defined (ACE_LACKS_BSEARCH)
00122   return ::bsearch (key, base, nel, size, compar);
00123 #else
00124   ACE_UNUSED_ARG (key);
00125   ACE_UNUSED_ARG (base);
00126   ACE_UNUSED_ARG (nel);
00127   ACE_UNUSED_ARG (size);
00128   ACE_UNUSED_ARG (compar);
00129   ACE_NOTSUP_RETURN (0);
00130 #endif /* ACE_LACKS_BSEARCH */
00131 }

ACE_INLINE char* ACE_OS::getenv ( const char *  symbol  ) 

Definition at line 134 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getenv().

Referenced by ACE_Get_Opt::ACE_Get_Opt(), ACE_Log_Msg::ACE_Log_Msg(), ACE::debug(), ACE_Env_Value< T >::fetch_value(), ACE_High_Res_Timer::get_env_global_scale_factor(), ACE::get_temp_dir(), getenv(), ACE::ldfind(), and strenvdup().

00135 {
00136   ACE_OS_TRACE ("ACE_OS::getenv");
00137 #if defined (ACE_LACKS_ENV)
00138   ACE_UNUSED_ARG (symbol);
00139   ACE_NOTSUP_RETURN (0);
00140 #else /* ACE_LACKS_ENV */
00141   ACE_OSCALL_RETURN (::getenv (symbol), char *, 0);
00142 #endif /* ACE_LACKS_ENV */
00143 }

ACE_INLINE char* ACE_OS::itoa ( int  value,
char *  string,
int  radix 
)

Converts an integer to a string.

Definition at line 159 of file OS_NS_stdlib.inl.

References itoa(), and itoa_emulation().

Referenced by itoa().

00160 {
00161 #if !defined (ACE_HAS_ITOA)
00162   return ACE_OS::itoa_emulation (value, string, radix);
00163 #elif defined (ACE_ITOA_EQUIVALENT)
00164   return ACE_ITOA_EQUIVALENT (value, string, radix);
00165 #else /* !ACE_HAS_ITOA */
00166   return ::itoa (value, string, radix);
00167 #endif /* !ACE_HAS_ITOA */
00168 }

ACE_INLINE ACE_HANDLE ACE_OS::mkstemp ( char *  s  ) 

Definition at line 183 of file OS_NS_stdlib.inl.

References ACE_TEXT_CHAR_TO_TCHAR, and mkstemp().

Referenced by ACE_FILE_Connector::connect(), and mkstemp().

00184 {
00185 #if !defined (ACE_LACKS_MKSTEMP)
00186   return ::mkstemp (s);
00187 #else
00188   return ACE_OS::mkstemp_emulation (ACE_TEXT_CHAR_TO_TCHAR (s));
00189 #endif  /* !ACE_LACKS_MKSTEMP */
00190 }

ACE_INLINE char* ACE_OS::mktemp ( char *  s  ) 

Definition at line 206 of file OS_NS_stdlib.inl.

References mktemp().

Referenced by ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), mktemp(), and ACE_FILE_Addr::set().

00207 {
00208 # if defined (ACE_WIN32)
00209   return ::_mktemp (s);
00210 # else /* ACE_WIN32 */
00211   return ::mktemp (s);
00212 # endif /* ACE_WIN32 */
00213 }

ACE_INLINE int ACE_OS::putenv ( const char *  string  ) 

Definition at line 244 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, free(), putenv(), strchr(), and strdup().

Referenced by putenv(), and ACE_Process::spawn().

00245 {
00246   ACE_OS_TRACE ("ACE_OS::putenv");
00247 #if defined (ACE_HAS_WINCE)
00248   // WinCE don't have the concept of environment variables.
00249   ACE_UNUSED_ARG (string);
00250   ACE_NOTSUP_RETURN (-1);
00251 #elif defined (ACE_LACKS_PUTENV) && defined (ACE_HAS_SETENV)
00252   int result = 0;
00253   char *sp = ACE_OS::strchr (const_cast <char *> (string), '=');
00254   if (sp)
00255     {
00256       char *stmp = ACE_OS::strdup (string);
00257       if (stmp)
00258         {
00259           stmp[sp - string] = '\0';
00260           ACE_OSCALL (::setenv (stmp, sp+sizeof (char), 1), int, -1, result);
00261           ACE_OS::free (stmp);
00262         }
00263       else
00264         {
00265           errno = ENOMEM;
00266           result = -1;
00267         }
00268     }
00269   else
00270     ACE_OSCALL (::setenv (string, "", 1), int, -1, result);
00271 
00272   return result;
00273 #elif defined (ACE_LACKS_ENV) || defined (ACE_LACKS_PUTENV)
00274   ACE_UNUSED_ARG (string);
00275   ACE_NOTSUP_RETURN (0);
00276 #else /* ! ACE_HAS_WINCE */
00277   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::putenv (const_cast <char *> (string)), int, -1);
00278 #endif /* ACE_HAS_WINCE */
00279 }

ACE_INLINE void ACE_OS::qsort ( void *  base,
size_t  nel,
size_t  width,
ACE_COMPARE_FUNC  compar 
)

Definition at line 297 of file OS_NS_stdlib.inl.

References qsort().

Referenced by qsort(), and scandir_emulation().

00301 {
00302 #if !defined (ACE_LACKS_QSORT)
00303   ::qsort (base, nel, width, compar);
00304 #else
00305   ACE_UNUSED_ARG (base);
00306   ACE_UNUSED_ARG (nel);
00307   ACE_UNUSED_ARG (width);
00308   ACE_UNUSED_ARG (compar);
00309 #endif /* !ACE_LACKS_QSORT */
00310 }

ACE_INLINE int ACE_OS::rand ( void   ) 

Definition at line 313 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and rand().

Referenced by ACE_Utils::UUID_Generator::init(), rand(), and rand_r().

00314 {
00315   ACE_OS_TRACE ("ACE_OS::rand");
00316   ACE_OSCALL_RETURN (::rand (), int, -1);
00317 }

ACE_INLINE int ACE_OS::rand_r ( ACE_RANDR_TYPE seed  ) 

Definition at line 322 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, rand(), and rand_r().

Referenced by rand_r().

00323 {
00324   ACE_OS_TRACE ("ACE_OS::rand_r");
00325 # if defined (ACE_HAS_REENTRANT_FUNCTIONS) && \
00326     !defined (ACE_LACKS_RAND_REENTRANT_FUNCTIONS)
00327 #   if defined (DIGITAL_UNIX)
00328   ACE_OSCALL_RETURN (::_Prand_r (&seed), int, -1);
00329 #   elif defined (ACE_HAS_BROKEN_RANDR)
00330   ACE_OSCALL_RETURN (::rand_r (seed), int, -1);
00331 #   else
00332   ACE_OSCALL_RETURN (::rand_r (&seed), int, -1);
00333 #   endif /* DIGITAL_UNIX */
00334 # else
00335   ACE_UNUSED_ARG (seed);
00336   ACE_OSCALL_RETURN (::rand (), int, -1);
00337 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00338 }

ACE_INLINE char* ACE_OS::realpath ( const char *  file_name,
char *  resolved_name 
)

Definition at line 363 of file OS_NS_stdlib.inl.

References PATH_MAX, and realpath().

Referenced by realpath().

00365 {
00366 #    if defined (ACE_WIN32)
00367   return ::_fullpath (resolved_name, file_name, PATH_MAX);
00368 #    else /* ACE_WIN32 */
00369   return ::realpath (file_name, resolved_name);
00370 #    endif /* ! ACE_WIN32 */
00371 }

ACE_INLINE ACE_EXIT_HOOK ACE_OS::set_exit_hook ( ACE_EXIT_HOOK  exit_hook  ) 

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

Definition at line 397 of file OS_NS_stdlib.inl.

References ACE_EXIT_HOOK, and exit_hook_.

Referenced by ACE_OS_Object_Manager::init().

00398 {
00399   ACE_EXIT_HOOK old_hook = exit_hook_;
00400   exit_hook_ = exit_hook;
00401   return old_hook;
00402 }

ACE_INLINE void ACE_OS::srand ( u_int  seed  ) 

Definition at line 405 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and srand().

Referenced by srand().

00406 {
00407   ACE_OS_TRACE ("ACE_OS::srand");
00408   ::srand (seed);
00409 }

ACE_INLINE double ACE_OS::strtod ( const char *  s,
char **  endptr 
)

Converts a string to a double value (char version).

Definition at line 413 of file OS_NS_stdlib.inl.

References strtod().

Referenced by ACE_Convert(), and strtod().

00414 {
00415   return ::strtod (s, endptr);
00416 }

ACE_INLINE long ACE_OS::strtol ( const char *  s,
char **  ptr,
int  base 
)

Converts a string to a long value (char version).

Definition at line 428 of file OS_NS_stdlib.inl.

References strtol().

Referenced by ACE_Convert(), get_port_number_from_name(), ACE_INET_Addr::string_to_addr(), and strtol().

00429 {
00430 #if defined (ACE_LACKS_STRTOL)
00431   return ACE_OS::strtol_emulation (s, ptr, base);
00432 #else  /* ACE_LACKS_STRTOL */
00433   return ::strtol (s, ptr, base);
00434 #endif /* ACE_LACKS_STRTOL */
00435 }

ACE_INLINE unsigned long ACE_OS::strtoul ( const char *  s,
char **  ptr,
int  base 
)

Converts a string to an unsigned long value (char version).

Definition at line 446 of file OS_NS_stdlib.inl.

References strtoul().

Referenced by ACE_Convert(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::parse_args(), and strtoul().

00447 {
00448 #if defined (ACE_LACKS_STRTOUL)
00449   return ACE_OS::strtoul_emulation (s, ptr, base);
00450 #else /* ACE_LACKS_STRTOUL */
00451   return ::strtoul (s, ptr, base);
00452 #endif /* ACE_LACKS_STRTOUL */
00453 }

ACE_INLINE int ACE_OS::system ( const ACE_TCHAR s  ) 

Definition at line 464 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_TEXT_ALWAYS_CHAR, and system().

Referenced by system().

00465 {
00466   // ACE_OS_TRACE ("ACE_OS::system");
00467 #if defined (ACE_LACKS_SYSTEM)
00468   ACE_UNUSED_ARG (s);
00469   ACE_NOTSUP_RETURN (-1);
00470 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00471   ACE_OSCALL_RETURN (::_wsystem (s), int, -1);
00472 #elif defined (ACE_TANDEM_T1248_PTHREADS)
00473   ACE_OSCALL_RETURN (::spt_system (s), int, -1);
00474 #else
00475   ACE_OSCALL_RETURN (::system (ACE_TEXT_ALWAYS_CHAR (s)), int, -1);
00476 #endif /* ACE_LACKS_SYSTEM */
00477 }

ACE_INLINE const char* ACE_OS::getprogname (  ) 

Get the name of the current program

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

Definition at line 480 of file OS_NS_stdlib.inl.

References getprogname(), and getprogname_emulation().

Referenced by getprogname().

00481 {
00482 #if defined (ACE_HAS_GETPROGNAME)
00483   return ::getprogname ();
00484 #else
00485   return ACE_OS::getprogname_emulation ();
00486 #endif /* ACE_HAS_GETPROGNAME */
00487 }

ACE_INLINE void ACE_OS::setprogname ( const char *  name  ) 

Set the name of the current program

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

Definition at line 490 of file OS_NS_stdlib.inl.

References setprogname(), and setprogname_emulation().

Referenced by setprogname().

00491 {
00492 #if defined (ACE_HAS_SETPROGNAME)
00493   ::setprogname (name);
00494 #else
00495   ACE_OS::setprogname_emulation (name);
00496 #endif /* ACE_HAS_SETPROGNAME */
00497 }

ACE_Export 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 73 of file OS_NS_string.cpp.

Referenced by argv_to_string(), ACE::execname(), and strenvdup().

00074 {
00075   register char *dscan = s;
00076   register const char *sscan = t;
00077 
00078   while ((*dscan++ = *sscan++) != '\0')
00079     continue;
00080 
00081   return dscan;
00082 }

ACE_Export char * ACE_OS::strerror ( int  errnum  ) 

Copies a string, but returns a pointer to the end of the copied region (char version).

Definition at line 99 of file OS_NS_string.cpp.

References ACE_TEXT_ALWAYS_CHAR, ACE::is_sock_error(), ACE::sock_error(), sprintf(), and strncpy().

Referenced by dlerror(), ACE_Log_Msg::log(), and ACE_Stats::print_summary().

00100 {
00101   static char ret_errortext[128];
00102 
00103   if (ACE::is_sock_error (errnum))
00104     {
00105       const ACE_TCHAR *errortext = ACE::sock_error (errnum);
00106       ACE_OS::strncpy (ret_errortext,
00107                        ACE_TEXT_ALWAYS_CHAR (errortext),
00108                        sizeof (ret_errortext));
00109       return ret_errortext;
00110     }
00111 #if defined (ACE_LACKS_STRERROR)
00112   errno = EINVAL;
00113   return ACE_OS::strerror_emulation (errnum);
00114 #else /* ACE_LACKS_STRERROR */
00115   // Adapt to the various ways that strerror() indicates a bad errnum.
00116   // Most modern systems set errno to EINVAL. Some older platforms return
00117   // a pointer to a NULL string. This code makes the behavior more consistent
00118   // across platforms. On a bad errnum, we make a string with the error number
00119   // and set errno to EINVAL.
00120   ACE_Errno_Guard g (errno);
00121   errno = 0;
00122   char *errmsg = 0;
00123 
00124 #if defined (ACE_HAS_TR24731_2005_CRT)
00125   errmsg = ret_errortext;
00126   ACE_SECURECRTCALL (strerror_s (ret_errortext, sizeof(ret_errortext), errnum),
00127                      char *, 0, errmsg);
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::sprintf (ret_errortext, "Unknown error %d", errnum);
00138       errmsg = ret_errortext;
00139       g = EINVAL;
00140     }
00141   return errmsg;
00142 #endif /* ACE_LACKS_STRERROR */
00143 }

ACE_Export const char * ACE_OS::strnchr ( const char *  s,
int  c,
size_t  len 
)

Finds the first occurance of a character in an array (const char version).

Definition at line 157 of file OS_NS_string.cpp.

Referenced by strnchr().

00158 {
00159   for (size_t i = 0; i < len; ++i)
00160     if (s[i] == c)
00161       return s + i;
00162 
00163   return 0;
00164 }

ACE_Export const ACE_WCHAR_T * ACE_OS::strnchr ( const ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len 
)

Finds the first occurance of a character in an array (const ACE_WCHAR_T version).

Definition at line 167 of file OS_NS_string.cpp.

00168 {
00169   for (size_t i = 0; i < len; ++i)
00170     if (s[i] == c)
00171       return s + i;
00172 
00173   return 0;
00174 }

ACE_Export const char * ACE_OS::strnstr ( const char *  s,
const char *  t,
size_t  len 
)

Finds the first occurance of a substring in an array (const char version).

Definition at line 177 of file OS_NS_string.cpp.

References memcmp(), and strlen().

Referenced by strnstr().

00178 {
00179   // Substring length
00180   size_t const len1 = ACE_OS::strlen (s1);
00181 
00182   // Check if the substring is longer than the string being searched.
00183   if (len2 > len1)
00184     return 0;
00185 
00186   // Go upto <len>
00187   size_t const len = len1 - len2;
00188 
00189   for (size_t i = 0; i <= len; i++)
00190     {
00191       if (ACE_OS::memcmp (s1 + i, s2, len2) == 0)
00192         // Found a match!  Return the index.
00193         return s1 + i;
00194     }
00195 
00196   return 0;
00197 }

ACE_Export const ACE_WCHAR_T * ACE_OS::strnstr ( const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Finds the first occurance of a substring in an array (const wchar_t version).

Definition at line 200 of file OS_NS_string.cpp.

References ACE_WCHAR_T, memcmp(), and strlen().

00201 {
00202   // Substring length
00203   const size_t len1 = ACE_OS::strlen (s1);
00204 
00205   // Check if the substring is longer than the string being searched.
00206   if (len2 > len1)
00207     return 0;
00208 
00209   // Go upto <len>
00210   const size_t len = len1 - len2;
00211 
00212   for (size_t i = 0; i <= len; i++)
00213     {
00214       if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0)
00215         // Found a match!  Return the index.
00216         return s1 + i;
00217     }
00218 
00219   return 0;
00220 }

ACE_Export 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 284 of file OS_NS_string.cpp.

References strncat().

Referenced by ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_System_Time::ACE_System_Time(), ACE_UNIX_Addr::addr_to_string(), ACE_SPIPE_Addr::addr_to_string(), ACE_FILE_Addr::addr_to_string(), ACE_DEV_Addr::addr_to_string(), asctime_r(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ctime_r(), ACE::dirname(), event_init(), ACE_Log_Msg::file(), ACE_INET_Addr::get_host_addr(), hostname(), ACE_Thru_Task<>::info(), ACE_Stream_Tail<>::info(), ACE_Stream_Head<>::info(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE_Log_Msg::log(), ACE_Log_Msg::msg(), ACE_Module< ACE_SYNCH_USE >::name(), ACE_Mem_Map::open(), ACE_FIFO::open(), ACE_String_Base< CHAR >::rep(), ACE_Local_Name_Space<, ACE_LOCK >::resolve_i(), ACE_UNIX_Addr::set(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), ACE_DEV_Addr::set(), ACE_UNIX_Addr::string_to_addr(), ACE::strndup(), ACE::strnnew(), ACE::timestamp(), ACE_Name_Request::type(), and unique_name().

00285 {
00286   register char *rdst = dst;
00287   register const char *rsrc = src;
00288   register size_t rmaxlen = maxlen;
00289 
00290   if (rmaxlen > 0)
00291     {
00292       if (rdst!=rsrc)
00293         {
00294           *rdst = '\0';
00295           if (rsrc != 0)
00296             strncat (rdst, rsrc, --rmaxlen);
00297         }
00298       else
00299         {
00300           rdst += (rmaxlen - 1);
00301           *rdst = '\0';
00302         }
00303     }
00304   return dst;
00305 }

ACE_Export 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 308 of file OS_NS_string.cpp.

References ACE_TEXT_WIDE, ACE_WCHAR_T, and strncat().

00309 {
00310   register ACE_WCHAR_T *rdst = dst;
00311   register const ACE_WCHAR_T *rsrc = src;
00312   register size_t rmaxlen = maxlen;
00313 
00314   if (rmaxlen > 0)
00315     {
00316       if (rdst!=rsrc)
00317         {
00318           *rdst = ACE_TEXT_WIDE ('\0');
00319           if (rsrc != 0)
00320             strncat (rdst, rsrc, --rmaxlen);
00321         }
00322       else
00323         {
00324           rdst += (rmaxlen - 1);
00325           *rdst = ACE_TEXT_WIDE ('\0');
00326         }
00327     }
00328   return dst;
00329 }

ACE_Export char * ACE_OS::strtok_r_emulation ( char *  s,
const char *  tokens,
char **  lasts 
)

Emulated strtok_r.

Definition at line 334 of file OS_NS_string.cpp.

References strlen(), and strtok().

Referenced by strtok_r().

00335 {
00336   if (s == 0)
00337     s = *lasts;
00338   else
00339     *lasts = s;
00340   if (*s == 0)                  // We have reached the end
00341     return 0;
00342   size_t l_org = ACE_OS::strlen (s);
00343   s = ::strtok (s, tokens);
00344   if (s == 0)
00345     return 0;
00346   const size_t l_sub = ACE_OS::strlen (s);
00347   if (s + l_sub < *lasts + l_org)
00348     *lasts = s + l_sub + 1;
00349   else
00350     *lasts = s + l_sub;
00351   return s ;
00352 }

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

Finds characters in a buffer (const void version).

Definition at line 13 of file OS_NS_string.inl.

Referenced by memchr().

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

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

Finds characters in a buffer (void version).

Definition at line 23 of file OS_NS_string.inl.

References memchr().

00024 {
00025   return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
00026                                              c,
00027                                              len));
00028 }

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

Compares two buffers.

Definition at line 31 of file OS_NS_string.inl.

References memcmp().

Referenced by ACE_String_Base< CHAR >::compare(), ACE_INET_Addr::get_host_name_i(), memcmp(), ACE_CDR::LongDouble::operator!=(), ACE_INET_Addr::operator<(), ACE_String_Base< CHAR >::operator==(), ACE_NS_String::operator==(), ACE_INET_Addr::operator==(), ACE_CDR::LongDouble::operator==(), and strnstr().

00032 {
00033   return ::memcmp (t, s, len);
00034 }

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

Copies one buffer to another.

Definition at line 37 of file OS_NS_string.inl.

References memcpy().

Referenced by ACE_Handle_Set::ACE_Handle_Set(), ACE_Message_Block::ACE_Message_Block(), ACE_Name_Request::ACE_Name_Request(), ACE_NS_String::ACE_NS_String(), ACE_SString::ACE_SString(), ACE_Task_Base::activate(), argv_to_string(), ACE_CDR::LongDouble::assign(), ACE_Data_Block::clone(), ACE_InputCDR::clone_from(), ACE_Obstack_T< CHAR >::copy(), ACE_Message_Block::copy(), ACE_ARGV_T< CHAR_TYPE >::create_buf_from_queue(), ACE_Active_Map_Manager_Key::decode(), ACE_Active_Map_Manager_Key::encode(), ACE::get_bcast_addr(), ACE_Configuration_Heap::get_binary_value(), ACE_INET_Addr::get_host_name_i(), ACE_INET_Addr::get_ip_address(), ACE::get_ip_interfaces(), gethostbyaddr_r(), gethostbyname_r(), gethrtime(), getmacaddress(), ACE_CDR::grow(), ACE_Timer_Heap_T< TYPE, FUNCTOR, ACE_LOCK >::grow_heap(), ACE_Registry_ImpExp::import_config(), inet_pton(), ACE_Utils::UUID_Generator::init(), ACE_Svc_Conf_Lexer::input(), ACE_Codeset_Registry::locale_to_registry_i(), lwp_getparams(), memcpy(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Name_Request::name(), ACE_CDR::LongDouble::operator NativeImpl(), putmsg(), ACE_InputCDR::read_array(), ACE_SOCK_Dgram::recv(), ACE_Codeset_Registry::registry_to_locale_i(), ACE_Obstack_T< CHAR >::request(), scandir_emulation(), ACE_SOCK_Dgram::send(), ACE_SPIPE_Addr::set(), ACE_INET_Addr::set(), ACE_UNIX_Addr::set_addr(), ACE_SPIPE_Addr::set_addr(), ACE_INET_Addr::set_address(), ACE_Configuration_Heap::set_binary_value(), set_scheduling_params(), ACE_Process_Options::setenv_i(), ACE_SOCK_SEQPACK_Connector::shared_connect_start(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_Data_Block::size(), ACE_Name_Request::value(), and ACE_OutputCDR::write_array().

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

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

Moves one buffer to another.

Definition at line 47 of file OS_NS_string.inl.

References memmove().

Referenced by ACE_Message_Block::crunch(), memmove(), and ACE_Svc_Conf_Lexer::yylex().

00048 {
00049   return ::memmove (t, s, len);
00050 }

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

Fills a buffer with a character value.

Definition at line 53 of file OS_NS_string.inl.

References memset().

Referenced by ACE_Data_Block::ACE_Data_Block(), ACE_DEV_Addr::ACE_DEV_Addr(), ACE_INET_Addr::ACE_INET_Addr(), ACE_Mem_Map::ACE_Mem_Map(), ACE_Process::ACE_Process(), ACE_Process_Options::ACE_Process_Options(), ACE_SPIPE_Addr::ACE_SPIPE_Addr(), ACE_Task_Base::ACE_Task_Base(), ACE_UNIX_Addr::ACE_UNIX_Addr(), ACE_CDR::LongDouble::assign(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::calloc(), ACE_Dynamic_Cached_Allocator< ACE_LOCK >::calloc(), ACE_Cached_Allocator< T, ACE_LOCK >::calloc(), ACE_Static_Allocator_Base::calloc(), ACE_New_Allocator::calloc(), cond_init(), condattr_init(), ACE::count_interfaces(), ACE_Thread::disablecancel(), fork_exec(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), ACE_SOCK_SEQPACK_Association::get_remote_addrs(), gethostbyaddr_r(), gethostbyname_r(), getmacaddress(), getpeername(), getservbyname_r(), getsockname(), ACE_Filecache_Object::init(), lwp_getparams(), memset(), mutex_init(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_INET_Addr::reset(), scheduling_class(), ACE_UNIX_Addr::set(), ACE_SPIPE_Addr::set(), ACE_INET_Addr::set(), ACE_DEV_Addr::set(), ACE_INET_Addr::set_address(), ACE::set_handle_limit(), set_scheduling_params(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_SOCK_Acceptor::shared_open(), thr_create(), and thr_setprio().

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

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strcat ( char *  s,
const char *  t 
)

Appends a string to another string (char version).

Definition at line 108 of file OS_NS_string.inl.

References strcat().

Referenced by ACE_MEM_Acceptor::accept(), ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_Logging_Strategy::ACE_Logging_Strategy(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Name_Options::ACE_Name_Options(), ACE_System_Time::ACE_System_Time(), ACE_Process_Options::command_line(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), event_init(), ACE_INET_Addr::get_host_addr(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_DLL_Handle::open(), sema_init(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), strcat(), and uname().

00109 {
00110   return ::strcat (s, t);
00111 }

ACE_NAMESPACE_INLINE_FUNCTION const char* ACE_OS::strchr ( const char *  s,
int  c 
)

Finds the first occurance of a character in a string (const char version).

Definition at line 126 of file OS_NS_string.inl.

Referenced by ACE_ARGV_T< CHAR_TYPE >::add(), ACE_INET_Addr::addr_to_string(), argv_to_string(), ACE_ARGV_T< CHAR_TYPE >::create_buf_from_queue(), ACE_SString::find(), ACE::get_fqdn(), ACE_Service_Manager::handle_input(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Get_Opt::long_option(), ACE_Configuration_Heap::open_section(), ACE_Registry_ImpExp::process_previous_line_format(), putenv(), ACE_Svc_Conf_Lexer::scan(), ACE_SPIPE_Addr::set(), ACE_Get_Opt::short_option_i(), strchr(), strenvdup(), and ACE_INET_Addr::string_to_addr().

00127 {
00128   return const_cast <const char *> (::strchr (s, c));
00129 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strchr ( char *  s,
int  c 
)

Finds the first occurance of a character in a string (char version).

Definition at line 144 of file OS_NS_string.inl.

References strchr().

00145 {
00146   return ::strchr (s, c);
00147 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::strcmp ( const char *  s,
const char *  t 
)

Compares two strings (char version).

Definition at line 160 of file OS_NS_string.inl.

Referenced by ACE_Log_Msg::ACE_Log_Msg(), ACE_Service_Gestalt::add_processed_static_svc(), ACE_Malloc_FIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance(), alphasort(), ACE_SString::compare(), ACE_SOCK_Dgram_Mcast::dump(), ACE_Stream<>::find(), ACE_Stream_Type::find(), ACE_DLL_Manager::find_dll(), ACE_Service_Repository::find_i(), ACE_Service_Gestalt::find_processed_static_svc(), ACE_Service_Gestalt::find_static_svc_descriptor(), inet_aton(), ACE_Stream<>::insert(), ACE_Capabilities::is_entry(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Naming_Context::local(), ACE_Codeset_Registry::locale_to_registry_i(), open(), ACE_DLL_Handle::open(), ACE_Service_Config::open_i(), ACE_DLL::open_i(), ACE_Less_Than< char * >::operator()(), ACE_Less_Than< const char * >::operator()(), ACE_Equal_To< char * >::operator()(), ACE_Equal_To< const char * >::operator()(), ACE_SString::operator<(), ACE_SString::operator==(), ACE_SPIPE_Addr::operator==(), ACE_Static_Svc_Descriptor::operator==(), ACE_Name_Binding::operator==(), ACE_FILE_Addr::operator==(), ACE_DEV_Addr::operator==(), ACE_SString::operator>(), ACE_Name_Options::parse_args(), ACE_Get_Opt::permute(), ACE_Logging_Strategy::priorities(), ACE_Service_Manager::process_request(), ACE_Stream<>::remove(), ACE_Framework_Repository::remove_component(), ACE_Framework_Repository::remove_dll_components_i(), ACE_Stream<>::replace(), ACE_Svc_Conf_Lexer::scan(), ACE_INET_Addr::set(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::shared_find(), strcmp(), ACE_Logging_Strategy::tokenize(), and ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::unbind().

00161 {
00162   return ::strcmp (s, t);
00163 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::strcmp ( const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t 
)

Compares two strings (wchar_t version).

Definition at line 166 of file OS_NS_string.inl.

References wcscmp_emulation().

00167 {
00168 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00169   return ACE_OS::wcscmp_emulation (s, t);
00170 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00171   return ::wcscmp (s, t);
00172 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00173 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strcpy ( char *  s,
const char *  t 
)

Copies a string (char version).

Definition at line 176 of file OS_NS_string.inl.

References strcpy().

Referenced by ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_Filecache_Object::ACE_Filecache_Object(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Control_Block::ACE_Name_Node::ACE_Name_Node(), ACE_Name_Options::ACE_Name_Options(), ACE_SString::ACE_SString(), ACE_System_Time::ACE_System_Time(), ACE_Configuration_Heap::add_section(), ACE_SDM_helpers::addr_to_string(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ctime_r(), cuserid(), dlsym(), ACE_SOCK_Dgram_Mcast::dump(), ACE::execname(), ACE_Log_Record::format_msg(), ACE::get_fqdn(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_host_name_i(), ACE::get_temp_dir(), gethostbyaddr_r(), gethostbyname_r(), getmacaddress(), inet_ntop(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_Log_Msg_UNIX_Syslog::log(), ACE_Log_Msg::log(), ACE_SOCK_Dgram::make_multicast_ifaddr(), ACE_Log_Record::msg_data(), ACE_Configuration_Heap::new_section(), ACE_DLL_Strategy< SVC_HANDLER >::open(), ACE_SOCK_Dgram_Mcast::open_i(), ACE_SString::operator=(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_Process_Options::process_name(), ACE_Service_Gestalt::Processed_Static_Svc::Processed_Static_Svc(), ACE_InputCDR::read_string(), ACE_Remote_Name_Space::resolve(), scandir_emulation(), scheduling_class(), sema_init(), ACE_UNIX_Addr::set(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), ACE_Configuration_Heap::set_binary_value(), ACE_Configuration_Heap::set_integer_value(), ACE_Configuration_Heap::set_string_value(), ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), strcpy(), strenvdup(), ACE::strnew(), uname(), and ACE_Process_Options::working_directory().

00177 {
00178   return ::strcpy (s, t);
00179 }

ACE_NAMESPACE_INLINE_FUNCTION 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 194 of file OS_NS_string.inl.

References strcspn().

Referenced by strcspn(), strenvdup(), and ACE_Configuration::validate_name().

00195 {
00196   return ::strcspn (s, reject);
00197 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strdup ( const char *  s  ) 

Returns a malloced duplicated string (char version).

Definition at line 212 of file OS_NS_string.inl.

References strdup().

Referenced by ACE_Argv_Type_Converter::ACE_Argv_Type_Converter(), ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap(), ACE_Mutex::ACE_Mutex(), ACE_Name_Options::ACE_Name_Options(), ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_Strategy_Acceptor(), ACE_Name_Options::database(), event_init(), flock_init(), ACE_Thru_Task<>::info(), ACE_Stream_Tail<>::info(), ACE_Stream_Head<>::info(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Log_Msg::local_host(), ACE_Name_Options::nameserver_host(), ACE_Name_Options::namespace_dir(), ACE_Log_Msg::open(), ACE_Strategy_Acceptor< SVC_HANDLER, >::open(), ACE_Name_Binding::operator=(), ACE_Name_Options::process_name(), putenv(), sema_init(), ACE_SPIPE_Addr::set(), strdup(), strenvdup(), ACE_INET_Addr::string_to_addr(), string_to_argv(), and ACE_Log_Msg::sync().

00213 {
00214 #  if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
00215   || defined (ACE_HAS_STRDUP_EMULATION)
00216   return ACE_OS::strdup_emulation (s);
00217 #  elif defined (ACE_STRDUP_EQUIVALENT)
00218   return ACE_STRDUP_EQUIVALENT (s);
00219 #  elif defined (ACE_HAS_NONCONST_STRDUP)
00220   return ::strdup (const_cast<char *> (s));
00221 #else
00222   return ::strdup (s);
00223 #  endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
00224 }

ACE_NAMESPACE_INLINE_FUNCTION size_t ACE_OS::strlen ( const char *  s  ) 

Finds the length of a string (char version).

Definition at line 244 of file OS_NS_string.inl.

Referenced by ACE_MEM_Acceptor::accept(), ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_NS_WString::ACE_NS_WString(), ACE_SString::ACE_SString(), ACE_ARGV_T< CHAR_TYPE >::add(), ACE_Configuration_Heap::add_section(), ACE_INET_Addr::addr_to_string(), argv_to_string(), ACE_Remote_Name_Space::bind(), ACE_Message_Block::copy(), ACE_ARGV_T< CHAR_TYPE >::create_buf_from_queue(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), cuserid(), dlsym(), ACE::execname(), ACE::get_fqdn(), ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name_i(), ACE::get_temp_dir(), gethostbyaddr_r(), gethostbyname_r(), ACE_Logging_Strategy::handle_timeout(), ACE::hash_pjw(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), inet_ntop(), ACE_Thru_Task<>::info(), ACE_Stream_Tail<>::info(), ACE_Stream_Head<>::info(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE_Svc_Conf_Lexer::input(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_Log_Msg::log(), ACE_Log_Msg::log_hexdump(), ACE_Get_Opt::long_option_i(), ACE_Log_Record::msg_data(), ACE_Log_Record::msg_data_len(), ACE_Configuration_Heap::open(), ACE_SOCK_Dgram_Mcast::open_i(), operator+(), ACE_String_Base< CHAR >::operator+=(), operator<<(), ACE_String_Base< CHAR >::operator==(), operator>>(), ACE_Log_Record::print(), ACE_High_Res_Timer::print_ave(), ACE_High_Res_Timer::print_total(), ACE_Service_Gestalt::Processed_Static_Svc::Processed_Static_Svc(), ACE_Remote_Name_Space::rebind(), ACE_SString::rep(), ACE_Local_Name_Space<, ACE_LOCK >::resolve_i(), ACE_Log_Record::round_up(), scandir_emulation(), ACE_UNIX_Addr::set(), ACE_String_Base< CHAR >::set(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), ACE_DEV_Addr::set(), ACE_Configuration_Heap::set_binary_value(), ACE_Configuration_Heap::set_integer_value(), ACE_Configuration_Heap::set_string_value(), ACE_Process_Options::setenv(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::shared_bind(), ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), ACE_Process::spawn(), ACE_Ini_ImpExp::squish(), strenvdup(), strlen(), ACE::strnew(), strnstr(), ACE::strsplit_r(), strtok_r_emulation(), ACE_OutputCDR::write_string(), ACE_SizeCDR::write_string(), ACE_OutputCDR::write_wstring(), and ACE_SizeCDR::write_wstring().

00245 {
00246   return ::strlen (s);
00247 }

ACE_NAMESPACE_INLINE_FUNCTION size_t ACE_OS::strlen ( const ACE_WCHAR_T *  s  ) 

Finds the length of a string (ACE_WCHAR_T version).

Definition at line 250 of file OS_NS_string.inl.

References wcslen_emulation().

00251 {
00252 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00253   return ACE_OS::wcslen_emulation (s);
00254 # else  /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00255   return ::wcslen (s);
00256 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00257 }

ACE_NAMESPACE_INLINE_FUNCTION 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 260 of file OS_NS_string.inl.

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), strncat(), and strsncpy().

00261 {
00262 #if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00263   strncat_s (s, len + 1, t, _TRUNCATE);
00264   return s;
00265 #else
00266   return ::strncat (s, t, len);
00267 #endif /* ACE_HAS_TR24731_2005_CRT */
00268 }

ACE_NAMESPACE_INLINE_FUNCTION 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 271 of file OS_NS_string.inl.

References wcsncat_emulation().

00272 {
00273 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00274   return ACE_OS::wcsncat_emulation (s, t, len);
00275 #  elif 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00276   wcsncat_s (s, len + 1, t, _TRUNCATE);
00277   return s;
00278 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00279   return ::wcsncat (s, t, len);
00280 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00281 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strnchr ( char *  s,
int  c,
size_t  len 
)

Finds the first occurance of a character in an array (char version).

Definition at line 284 of file OS_NS_string.inl.

00285 {
00286   return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
00287                                               c,
00288                                               len));
00289 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_WCHAR_T* ACE_OS::strnchr ( ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len 
)

Finds the first occurance of a character in an array (ACE_WCHAR_T version).

Definition at line 292 of file OS_NS_string.inl.

References strnchr().

00293 {
00294   return
00295     const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
00296                                  const_cast<const ACE_WCHAR_T *> (s),
00297                                  c,
00298                                  len));
00299 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::strncmp ( const char *  s,
const char *  t,
size_t  len 
)

Compares two arrays (char version).

Definition at line 302 of file OS_NS_string.inl.

Referenced by ACE_Registry_ImpExp::import_config(), ACE_Get_Opt::long_option_i(), ACE_UNIX_Addr::operator==(), ACE_SPIPE_Addr::set(), and strncmp().

00303 {
00304   return ::strncmp (s, t, len);
00305 }

ACE_NAMESPACE_INLINE_FUNCTION 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 308 of file OS_NS_string.inl.

References wcsncmp_emulation().

00309 {
00310 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00311   return ACE_OS::wcsncmp_emulation (s, t, len);
00312 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00313   return ::wcsncmp (s, t, len);
00314 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00315 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strncpy ( char *  s,
const char *  t,
size_t  len 
)

Copies an array (char version).

Definition at line 318 of file OS_NS_string.inl.

Referenced by dlerror(), event_init(), ACE_DLL_Handle::open(), ACE_Svc_Conf_Lexer::scan(), strenvdup(), strerror(), and strncpy().

00319 {
00320   return ::strncpy (s, t, len);
00321 }

ACE_NAMESPACE_INLINE_FUNCTION 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 324 of file OS_NS_string.inl.

References wcsncpy_emulation().

00325 {
00326 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00327   return ACE_OS::wcsncpy_emulation (s, t, len);
00328 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00329   return ::wcsncpy (s, t, len);
00330 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00331 }

ACE_NAMESPACE_INLINE_FUNCTION 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 334 of file OS_NS_string.inl.

Referenced by strnlen().

00335 {
00336 #if defined (ACE_HAS_STRNLEN)
00337   return ::strnlen (s, maxlen);
00338 #else /* ACE_HAS_STRNLEN */
00339   size_t i;
00340   for (i = 0; i < maxlen; ++i)
00341     if (s[i] == '\0')
00342       break;
00343   return i;
00344 #endif /* ACE_HAS_STRNLEN */
00345 }

ACE_NAMESPACE_INLINE_FUNCTION 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 348 of file OS_NS_string.inl.

00349 {
00350 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00351   return wcsnlen (s, maxlen);
00352 #else /* ACE_HAS_WCSNLEN */
00353   size_t i;
00354   for (i = 0; i < maxlen; ++i)
00355     if (s[i] == '\0')
00356       break;
00357   return i;
00358 #endif /* ACE_HAS_WCSNLEN */
00359 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strnstr ( char *  s,
const char *  t,
size_t  len 
)

Finds the first occurance of a substring in an array (char version).

Definition at line 362 of file OS_NS_string.inl.

00363 {
00364   return
00365     const_cast <char *> (ACE_OS::strnstr (const_cast <const char *> (s), t, len));
00366 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_WCHAR_T* ACE_OS::strnstr ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Finds the first occurance of a substring in an array (wchar_t version).

Definition at line 369 of file OS_NS_string.inl.

References strnstr().

00370 {
00371   return
00372     const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
00373                                  static_cast<const ACE_WCHAR_T *> (s),
00374                                  t,
00375                                  len));
00376 }

ACE_NAMESPACE_INLINE_FUNCTION const char* ACE_OS::strpbrk ( const char *  s1,
const char *  s2 
)

Searches for characters in a string (const char version).

Definition at line 379 of file OS_NS_string.inl.

Referenced by ACE_Registry_ImpExp::process_previous_line_format(), and strpbrk().

00380 {
00381   return const_cast <const char *> (::strpbrk (s1, s2));
00382 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strpbrk ( char *  s1,
const char *  s2 
)

Searches for characters in a string (char version).

Definition at line 397 of file OS_NS_string.inl.

References strpbrk().

00398 {
00399   return ::strpbrk (s1, s2);
00400 }

ACE_NAMESPACE_INLINE_FUNCTION const char* ACE_OS::strrchr ( const char *  s,
int  c 
)

Finds the last occurance of a character in a string (const char version).

Definition at line 412 of file OS_NS_string.inl.

Referenced by ACE_SDM_helpers::addr_to_string(), ACE::basename(), ACE::dirname(), ACE::execname(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE::ldfind(), sema_init(), setprogname_emulation(), ACE_INET_Addr::string_to_addr(), and strrchr().

00413 {
00414 #if defined (ACE_LACKS_STRRCHR)
00415   return ACE_OS::strrchr_emulation (s, c);
00416 #else  /* ! ACE_LACKS_STRRCHR */
00417   return (const char *) ::strrchr (s, c);
00418 #endif /* ! ACE_LACKS_STRRCHR */
00419 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strrchr ( char *  s,
int  c 
)

Finds the last occurance of a character in a string (char version).

Definition at line 434 of file OS_NS_string.inl.

References strrchr().

00435 {
00436 #if defined (ACE_LACKS_STRRCHR)
00437   return ACE_OS::strrchr_emulation (s, c);
00438 #else  /* ! ACE_LACKS_STRRCHR */
00439   return ::strrchr (s, c);
00440 #endif /* ! ACE_LACKS_STRRCHR */
00441 }

ACE_NAMESPACE_INLINE_FUNCTION 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 453 of file OS_NS_string.inl.

References strspn().

Referenced by ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), and strspn().

00454 {
00455   return ::strspn (s, t);
00456 }

ACE_NAMESPACE_INLINE_FUNCTION const char* ACE_OS::strstr ( const char *  s,
const char *  t 
)

Finds the first occurance of a substring in a string (const char version).

Definition at line 471 of file OS_NS_string.inl.

Referenced by ACE_SString::find(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE::strsplit_r(), and strstr().

00472 {
00473   return (const char *) ::strstr (s, t);
00474 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strstr ( char *  s,
const char *  t 
)

Finds the first occurance of a substring in a string (char version).

Definition at line 491 of file OS_NS_string.inl.

References strstr().

00492 {
00493   return ::strstr (s, t);
00494 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strtok ( char *  s,
const char *  tokens 
)

Finds the next token in a string (char version).

Definition at line 511 of file OS_NS_string.inl.

References strtok().

Referenced by strtok(), and strtok_r_emulation().

00512 {
00513   return ::strtok (s, tokens);
00514 }

ACE_NAMESPACE_INLINE_FUNCTION 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 530 of file OS_NS_string.inl.

References strtok_r(), and strtok_r_emulation().

Referenced by ACE_Log_Msg_UNIX_Syslog::log(), ACE_Logging_Strategy::priorities(), strtok_r(), and ACE_Logging_Strategy::tokenize().

00531 {
00532 #if defined (ACE_HAS_TR24731_2005_CRT)
00533   return strtok_s (s, tokens, lasts);
00534 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (ACE_LACKS_STRTOK_R)
00535   return ::strtok_r (s, tokens, lasts);
00536 #else
00537   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00538 #endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */
00539 }

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

Finds characters in a buffer (const void version).

Definition at line 13 of file OS_NS_string.inl.

References memchr().

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

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

Finds characters in a buffer (void version).

Definition at line 23 of file OS_NS_string.inl.

References memchr().

00024 {
00025   return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
00026                                              c,
00027                                              len));
00028 }

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

Compares two buffers.

Definition at line 31 of file OS_NS_string.inl.

References memcmp().

Referenced by ACE_String_Base< CHAR >::compare(), ACE_INET_Addr::get_host_name_i(), memcmp(), ACE_CDR::LongDouble::operator!=(), ACE_INET_Addr::operator<(), ACE_CDR::LongDouble::operator==(), ACE_INET_Addr::operator==(), ACE_NS_String::operator==(), ACE_String_Base< CHAR >::operator==(), and strnstr().

00032 {
00033   return ::memcmp (t, s, len);
00034 }

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

Copies one buffer to another.

Definition at line 37 of file OS_NS_string.inl.

References memcpy().

Referenced by ACE_Handle_Set::ACE_Handle_Set(), ACE_Message_Block::ACE_Message_Block(), ACE_Name_Request::ACE_Name_Request(), ACE_NS_String::ACE_NS_String(), ACE_SString::ACE_SString(), ACE_Task_Base::activate(), argv_to_string(), ACE_CDR::LongDouble::assign(), ACE_Data_Block::clone(), ACE_InputCDR::clone_from(), ACE_Message_Block::copy(), ACE_Obstack_T< CHAR >::copy(), ACE_ARGV_T< CHAR_TYPE >::create_buf_from_queue(), ACE_Active_Map_Manager_Key::decode(), ACE_Active_Map_Manager_Key::encode(), ACE::get_bcast_addr(), ACE_Configuration_Heap::get_binary_value(), ACE_INET_Addr::get_host_name_i(), ACE_INET_Addr::get_ip_address(), ACE::get_ip_interfaces(), gethostbyaddr_r(), gethostbyname_r(), gethrtime(), getmacaddress(), ACE_CDR::grow(), ACE_Timer_Heap_T< TYPE, FUNCTOR, ACE_LOCK >::grow_heap(), ACE_Registry_ImpExp::import_config(), inet_pton(), ACE_Utils::UUID_Generator::init(), ACE_Svc_Conf_Lexer::input(), ACE_Codeset_Registry::locale_to_registry_i(), lwp_getparams(), memcpy(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Name_Request::name(), ACE_CDR::LongDouble::operator NativeImpl(), putmsg(), ACE_InputCDR::read_array(), ACE_SOCK_Dgram::recv(), ACE_Codeset_Registry::registry_to_locale_i(), ACE_Obstack_T< CHAR >::request(), scandir_emulation(), ACE_SOCK_Dgram::send(), ACE_INET_Addr::set(), ACE_SPIPE_Addr::set(), ACE_SPIPE_Addr::set_addr(), ACE_UNIX_Addr::set_addr(), ACE_INET_Addr::set_address(), ACE_Configuration_Heap::set_binary_value(), set_scheduling_params(), ACE_Process_Options::setenv_i(), ACE_SOCK_SEQPACK_Connector::shared_connect_start(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_Data_Block::size(), ACE_Name_Request::value(), and ACE_OutputCDR::write_array().

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

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

Moves one buffer to another.

Definition at line 47 of file OS_NS_string.inl.

References memmove().

Referenced by ACE_Message_Block::crunch(), memmove(), and ACE_Svc_Conf_Lexer::yylex().

00048 {
00049   return ::memmove (t, s, len);
00050 }

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

Fills a buffer with a character value.

Definition at line 53 of file OS_NS_string.inl.

References memset().

Referenced by ACE_Data_Block::ACE_Data_Block(), ACE_DEV_Addr::ACE_DEV_Addr(), ACE_INET_Addr::ACE_INET_Addr(), ACE_Mem_Map::ACE_Mem_Map(), ACE_Process::ACE_Process(), ACE_Process_Options::ACE_Process_Options(), ACE_SPIPE_Addr::ACE_SPIPE_Addr(), ACE_Task_Base::ACE_Task_Base(), ACE_UNIX_Addr::ACE_UNIX_Addr(), ACE_CDR::LongDouble::assign(), ACE_New_Allocator::calloc(), ACE_Static_Allocator_Base::calloc(), ACE_Cached_Allocator< T, ACE_LOCK >::calloc(), ACE_Dynamic_Cached_Allocator< ACE_LOCK >::calloc(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::calloc(), cond_init(), condattr_init(), ACE::count_interfaces(), ACE_Thread::disablecancel(), fork_exec(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), ACE_SOCK_SEQPACK_Association::get_remote_addrs(), gethostbyaddr_r(), gethostbyname_r(), getmacaddress(), getpeername(), getservbyname_r(), getsockname(), ACE_Filecache_Object::init(), lwp_getparams(), memset(), mutex_init(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_INET_Addr::reset(), scheduling_class(), ACE_DEV_Addr::set(), ACE_INET_Addr::set(), ACE_SPIPE_Addr::set(), ACE_UNIX_Addr::set(), ACE_INET_Addr::set_address(), ACE::set_handle_limit(), set_scheduling_params(), ACE_SOCK_Acceptor::shared_open(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), thr_create(), and thr_setprio().

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

ACE_INLINE char* ACE_OS::strcat ( char *  s,
const char *  t 
)

Appends a string to another string (char version).

Definition at line 108 of file OS_NS_string.inl.

References strcat().

Referenced by ACE_MEM_Acceptor::accept(), ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_Logging_Strategy::ACE_Logging_Strategy(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Name_Options::ACE_Name_Options(), ACE_System_Time::ACE_System_Time(), ACE_Process_Options::command_line(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), event_init(), ACE_INET_Addr::get_host_addr(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_DLL_Handle::open(), sema_init(), ACE_FILE_Addr::set(), ACE_SPIPE_Addr::set(), strcat(), and uname().

00109 {
00110   return ::strcat (s, t);
00111 }

ACE_INLINE const char* ACE_OS::strchr ( const char *  s,
int  c 
)

Finds the first occurance of a character in a string (const char version).

Definition at line 126 of file OS_NS_string.inl.

References strchr().

00127 {
00128   return const_cast <const char *> (::strchr (s, c));
00129 }

ACE_INLINE char* ACE_OS::strchr ( char *  s,
int  c 
)

Finds the first occurance of a character in a string (char version).

Definition at line 144 of file OS_NS_string.inl.

References strchr().

00145 {
00146   return ::strchr (s, c);
00147 }

ACE_INLINE int ACE_OS::strcmp ( const char *  s,
const char *  t 
)

Compares two strings (char version).

Definition at line 160 of file OS_NS_string.inl.

References strcmp().

00161 {
00162   return ::strcmp (s, t);
00163 }

ACE_INLINE int ACE_OS::strcmp ( const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t 
)

Compares two strings (wchar_t version).

Definition at line 166 of file OS_NS_string.inl.

References wcscmp_emulation().

00167 {
00168 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00169   return ACE_OS::wcscmp_emulation (s, t);
00170 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00171   return ::wcscmp (s, t);
00172 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00173 }

ACE_INLINE char* ACE_OS::strcpy ( char *  s,
const char *  t 
)

Copies a string (char version).

Definition at line 176 of file OS_NS_string.inl.

References strcpy().

Referenced by ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_Filecache_Object::ACE_Filecache_Object(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Control_Block::ACE_Name_Node::ACE_Name_Node(), ACE_Name_Options::ACE_Name_Options(), ACE_SString::ACE_SString(), ACE_System_Time::ACE_System_Time(), ACE_Configuration_Heap::add_section(), ACE_SDM_helpers::addr_to_string(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ctime_r(), cuserid(), dlsym(), ACE_SOCK_Dgram_Mcast::dump(), ACE::execname(), ACE_Log_Record::format_msg(), ACE::get_fqdn(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_host_name_i(), ACE::get_temp_dir(), gethostbyaddr_r(), gethostbyname_r(), getmacaddress(), inet_ntop(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_Log_Msg::log(), ACE_Log_Msg_UNIX_Syslog::log(), ACE_SOCK_Dgram::make_multicast_ifaddr(), ACE_Log_Record::msg_data(), ACE_Configuration_Heap::new_section(), ACE_DLL_Strategy< SVC_HANDLER >::open(), ACE_SOCK_Dgram_Mcast::open_i(), ACE_SString::operator=(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_Process_Options::process_name(), ACE_Service_Gestalt::Processed_Static_Svc::Processed_Static_Svc(), ACE_InputCDR::read_string(), ACE_Remote_Name_Space::resolve(), scandir_emulation(), scheduling_class(), sema_init(), ACE_FILE_Addr::set(), ACE_SPIPE_Addr::set(), ACE_UNIX_Addr::set(), ACE_Configuration_Heap::set_binary_value(), ACE_Configuration_Heap::set_integer_value(), ACE_Configuration_Heap::set_string_value(), ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), strcpy(), strenvdup(), ACE::strnew(), uname(), and ACE_Process_Options::working_directory().

00177 {
00178   return ::strcpy (s, t);
00179 }

ACE_INLINE 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 194 of file OS_NS_string.inl.

References strcspn().

Referenced by strcspn(), strenvdup(), and ACE_Configuration::validate_name().

00195 {
00196   return ::strcspn (s, reject);
00197 }

ACE_INLINE char* ACE_OS::strdup ( const char *  s  ) 

Returns a malloced duplicated string (char version).

Definition at line 212 of file OS_NS_string.inl.

References strdup().

Referenced by ACE_Argv_Type_Converter::ACE_Argv_Type_Converter(), ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap(), ACE_Mutex::ACE_Mutex(), ACE_Name_Options::ACE_Name_Options(), ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_Strategy_Acceptor(), ACE_Name_Options::database(), event_init(), flock_init(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Naming_Context::info(), ACE_Service_Manager::info(), ACE_Module_Type::info(), ACE_Stream_Type::info(), ACE_Stream_Head<>::info(), ACE_Stream_Tail<>::info(), ACE_Thru_Task<>::info(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Log_Msg::local_host(), ACE_Name_Options::nameserver_host(), ACE_Name_Options::namespace_dir(), ACE_Strategy_Acceptor< SVC_HANDLER, >::open(), ACE_Log_Msg::open(), ACE_Name_Binding::operator=(), ACE_Name_Options::process_name(), putenv(), sema_init(), ACE_SPIPE_Addr::set(), strdup(), strenvdup(), ACE_INET_Addr::string_to_addr(), string_to_argv(), and ACE_Log_Msg::sync().

00213 {
00214 #  if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
00215   || defined (ACE_HAS_STRDUP_EMULATION)
00216   return ACE_OS::strdup_emulation (s);
00217 #  elif defined (ACE_STRDUP_EQUIVALENT)
00218   return ACE_STRDUP_EQUIVALENT (s);
00219 #  elif defined (ACE_HAS_NONCONST_STRDUP)
00220   return ::strdup (const_cast<char *> (s));
00221 #else
00222   return ::strdup (s);
00223 #  endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
00224 }

ACE_INLINE size_t ACE_OS::strlen ( const char *  s  ) 

Finds the length of a string (char version).

Definition at line 244 of file OS_NS_string.inl.

References strlen().

00245 {
00246   return ::strlen (s);
00247 }

ACE_INLINE size_t ACE_OS::strlen ( const ACE_WCHAR_T *  s  ) 

Finds the length of a string (ACE_WCHAR_T version).

Definition at line 250 of file OS_NS_string.inl.

References wcslen_emulation().

00251 {
00252 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00253   return ACE_OS::wcslen_emulation (s);
00254 # else  /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00255   return ::wcslen (s);
00256 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00257 }

ACE_INLINE 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 260 of file OS_NS_string.inl.

References strncat().

00261 {
00262 #if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00263   strncat_s (s, len + 1, t, _TRUNCATE);
00264   return s;
00265 #else
00266   return ::strncat (s, t, len);
00267 #endif /* ACE_HAS_TR24731_2005_CRT */
00268 }

ACE_INLINE 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 271 of file OS_NS_string.inl.

References wcsncat_emulation().

00272 {
00273 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00274   return ACE_OS::wcsncat_emulation (s, t, len);
00275 #  elif 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00276   wcsncat_s (s, len + 1, t, _TRUNCATE);
00277   return s;
00278 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00279   return ::wcsncat (s, t, len);
00280 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00281 }

ACE_INLINE char* ACE_OS::strnchr ( char *  s,
int  c,
size_t  len 
)

Finds the first occurance of a character in an array (char version).

Definition at line 284 of file OS_NS_string.inl.

References strnchr().

00285 {
00286   return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
00287                                               c,
00288                                               len));
00289 }

ACE_INLINE ACE_WCHAR_T* ACE_OS::strnchr ( ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len 
)

Finds the first occurance of a character in an array (ACE_WCHAR_T version).

Definition at line 292 of file OS_NS_string.inl.

References strnchr().

00293 {
00294   return
00295     const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
00296                                  const_cast<const ACE_WCHAR_T *> (s),
00297                                  c,
00298                                  len));
00299 }

ACE_INLINE int ACE_OS::strncmp ( const char *  s,
const char *  t,
size_t  len 
)

Compares two arrays (char version).

Definition at line 302 of file OS_NS_string.inl.

References strncmp().

00303 {
00304   return ::strncmp (s, t, len);
00305 }

ACE_INLINE 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 308 of file OS_NS_string.inl.

References wcsncmp_emulation().

00309 {
00310 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00311   return ACE_OS::wcsncmp_emulation (s, t, len);
00312 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00313   return ::wcsncmp (s, t, len);
00314 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00315 }

ACE_INLINE char* ACE_OS::strncpy ( char *  s,
const char *  t,
size_t  len 
)

Copies an array (char version).

Definition at line 318 of file OS_NS_string.inl.

References strncpy().

00319 {
00320   return ::strncpy (s, t, len);
00321 }

ACE_INLINE 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 324 of file OS_NS_string.inl.

References wcsncpy_emulation().

00325 {
00326 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00327   return ACE_OS::wcsncpy_emulation (s, t, len);
00328 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00329   return ::wcsncpy (s, t, len);
00330 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00331 }

ACE_INLINE 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 334 of file OS_NS_string.inl.

References strnlen().

00335 {
00336 #if defined (ACE_HAS_STRNLEN)
00337   return ::strnlen (s, maxlen);
00338 #else /* ACE_HAS_STRNLEN */
00339   size_t i;
00340   for (i = 0; i < maxlen; ++i)
00341     if (s[i] == '\0')
00342       break;
00343   return i;
00344 #endif /* ACE_HAS_STRNLEN */
00345 }

ACE_INLINE 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 348 of file OS_NS_string.inl.

00349 {
00350 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00351   return wcsnlen (s, maxlen);
00352 #else /* ACE_HAS_WCSNLEN */
00353   size_t i;
00354   for (i = 0; i < maxlen; ++i)
00355     if (s[i] == '\0')
00356       break;
00357   return i;
00358 #endif /* ACE_HAS_WCSNLEN */
00359 }

ACE_INLINE char* ACE_OS::strnstr ( char *  s,
const char *  t,
size_t  len 
)

Finds the first occurance of a substring in an array (char version).

Definition at line 362 of file OS_NS_string.inl.

References strnstr().

00363 {
00364   return
00365     const_cast <char *> (ACE_OS::strnstr (const_cast <const char *> (s), t, len));
00366 }

ACE_INLINE ACE_WCHAR_T* ACE_OS::strnstr ( ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len 
)

Finds the first occurance of a substring in an array (wchar_t version).

Definition at line 369 of file OS_NS_string.inl.

References strnstr().

00370 {
00371   return
00372     const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
00373                                  static_cast<const ACE_WCHAR_T *> (s),
00374                                  t,
00375                                  len));
00376 }

ACE_INLINE const char* ACE_OS::strpbrk ( const char *  s1,
const char *  s2 
)

Searches for characters in a string (const char version).

Definition at line 379 of file OS_NS_string.inl.

References strpbrk().

00380 {
00381   return const_cast <const char *> (::strpbrk (s1, s2));
00382 }

ACE_INLINE char* ACE_OS::strpbrk ( char *  s1,
const char *  s2 
)

Searches for characters in a string (char version).

Definition at line 397 of file OS_NS_string.inl.

References strpbrk().

00398 {
00399   return ::strpbrk (s1, s2);
00400 }

ACE_INLINE const char* ACE_OS::strrchr ( const char *  s,
int  c 
)

Finds the last occurance of a character in a string (const char version).

Definition at line 412 of file OS_NS_string.inl.

References strrchr().

00413 {
00414 #if defined (ACE_LACKS_STRRCHR)
00415   return ACE_OS::strrchr_emulation (s, c);
00416 #else  /* ! ACE_LACKS_STRRCHR */
00417   return (const char *) ::strrchr (s, c);
00418 #endif /* ! ACE_LACKS_STRRCHR */
00419 }

ACE_INLINE char* ACE_OS::strrchr ( char *  s,
int  c 
)

Finds the last occurance of a character in a string (char version).

Definition at line 434 of file OS_NS_string.inl.

References strrchr().

00435 {
00436 #if defined (ACE_LACKS_STRRCHR)
00437   return ACE_OS::strrchr_emulation (s, c);
00438 #else  /* ! ACE_LACKS_STRRCHR */
00439   return ::strrchr (s, c);
00440 #endif /* ! ACE_LACKS_STRRCHR */
00441 }

ACE_INLINE 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 453 of file OS_NS_string.inl.

References strspn().

Referenced by ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), and strspn().

00454 {
00455   return ::strspn (s, t);
00456 }

ACE_INLINE const char* ACE_OS::strstr ( const char *  s,
const char *  t 
)

Finds the first occurance of a substring in a string (const char version).

Definition at line 471 of file OS_NS_string.inl.

References strstr().

00472 {
00473   return (const char *) ::strstr (s, t);
00474 }

ACE_INLINE char* ACE_OS::strstr ( char *  s,
const char *  t 
)

Finds the first occurance of a substring in a string (char version).

Definition at line 491 of file OS_NS_string.inl.

References strstr().

00492 {
00493   return ::strstr (s, t);
00494 }

ACE_INLINE char* ACE_OS::strtok ( char *  s,
const char *  tokens 
)

Finds the next token in a string (char version).

Definition at line 511 of file OS_NS_string.inl.

References strtok().

Referenced by strtok(), and strtok_r_emulation().

00512 {
00513   return ::strtok (s, tokens);
00514 }

ACE_INLINE 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 530 of file OS_NS_string.inl.

References strtok_r(), and strtok_r_emulation().

Referenced by ACE_Log_Msg_UNIX_Syslog::log(), ACE_Logging_Strategy::priorities(), strtok_r(), and ACE_Logging_Strategy::tokenize().

00531 {
00532 #if defined (ACE_HAS_TR24731_2005_CRT)
00533   return strtok_s (s, tokens, lasts);
00534 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (ACE_LACKS_STRTOK_R)
00535   return ::strtok_r (s, tokens, lasts);
00536 #else
00537   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00538 #endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */
00539 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::strcasecmp ( const char *  s,
const char *  t 
)

Compares two strings (case insensitive const char version).

Definition at line 12 of file OS_NS_strings.inl.

References strcasecmp().

Referenced by ACE_TTY_IO::control(), ACE::execname(), ACE::ldfind(), ACE_Configuration_ExtId::operator==(), ACE_Name_Options::parse_args(), and strcasecmp().

00013 {
00014 #if defined (ACE_LACKS_STRCASECMP)
00015   return ACE_OS::strcasecmp_emulation (s, t);
00016 #elif defined (ACE_STRCASECMP_EQUIVALENT)
00017   return ACE_STRCASECMP_EQUIVALENT (s, t);
00018 #else /* ACE_LACKS_STRCASECMP */
00019   return ::strcasecmp (s, t);
00020 #endif /* ACE_LACKS_STRCASECMP */
00021 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::strncasecmp ( const char *  s,
const char *  t,
size_t  len 
)

Compares two arrays (case insensitive const char version).

Definition at line 36 of file OS_NS_strings.inl.

References strncasecmp().

Referenced by ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), and strncasecmp().

00037 {
00038 #if defined (ACE_LACKS_STRCASECMP)
00039   return ACE_OS::strncasecmp_emulation (s, t, len);
00040 #elif defined (ACE_STRNCASECMP_EQUIVALENT)
00041   return ACE_STRNCASECMP_EQUIVALENT (s, t, len);
00042 #else /* ACE_LACKS_STRCASECMP */
00043   return ::strncasecmp (s, t, len);
00044 #endif /* ACE_LACKS_STRCASECMP */
00045 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::strcasecmp ( const char *  s,
const char *  t 
)

Compares two strings (case insensitive const char version).

Definition at line 12 of file OS_NS_strings.inl.

References strcasecmp().

Referenced by ACE_TTY_IO::control(), ACE::execname(), ACE::ldfind(), ACE_Configuration_ExtId::operator==(), ACE_Name_Options::parse_args(), and strcasecmp().

00013 {
00014 #if defined (ACE_LACKS_STRCASECMP)
00015   return ACE_OS::strcasecmp_emulation (s, t);
00016 #elif defined (ACE_STRCASECMP_EQUIVALENT)
00017   return ACE_STRCASECMP_EQUIVALENT (s, t);
00018 #else /* ACE_LACKS_STRCASECMP */
00019   return ::strcasecmp (s, t);
00020 #endif /* ACE_LACKS_STRCASECMP */
00021 }

ACE_INLINE int ACE_OS::strncasecmp ( const char *  s,
const char *  t,
size_t  len 
)

Compares two arrays (case insensitive const char version).

Definition at line 36 of file OS_NS_strings.inl.

References strncasecmp().

Referenced by ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), and strncasecmp().

00037 {
00038 #if defined (ACE_LACKS_STRCASECMP)
00039   return ACE_OS::strncasecmp_emulation (s, t, len);
00040 #elif defined (ACE_STRNCASECMP_EQUIVALENT)
00041   return ACE_STRNCASECMP_EQUIVALENT (s, t, len);
00042 #else /* ACE_LACKS_STRCASECMP */
00043   return ::strncasecmp (s, t, len);
00044 #endif /* ACE_LACKS_STRCASECMP */
00045 }

ACE_Export 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 14 of file OS_NS_stropts.cpp.

References ACE_NOTSUP_RETURN, and ACE_SOCKCALL_RETURN.

Referenced by ACE_SPIPE_Acceptor::accept(), ACE::clr_flags(), ACE_IPC_SAP::control(), ACE_IO_SAP::control(), ACE::count_interfaces(), ACE_SPIPE_Acceptor::create_new_instance(), ACE_IPC_SAP::disable(), ACE_IPC_SAP::enable(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), getmacaddress(), ioctl(), ACE_SOCK_Dgram::make_multicast_ifaddr(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Pipe::open(), ACE_SOCK_Dgram::recv(), ACE_SPIPE_Stream::recv_handle(), ACE_SOCK_IO::recvv(), ACE_SPIPE_Stream::send_handle(), and ACE::set_flags().

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

ACE_Export 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 52 of file OS_NS_stropts.cpp.

References ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, ACE_QoS::provider_specific(), ACE_QoS::receiving_flowspec(), and ACE_QoS::sending_flowspec().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::getmsg ( ACE_HANDLE  handle,
struct strbuf ctl,
struct strbuf data,
int *  flags 
)

Definition at line 39 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getmsg().

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

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

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

Definition at line 59 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getpmsg().

Referenced by getpmsg(), and ACE_SPIPE_Stream::recv().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fattach ( int  handle,
const char *  path 
)

Definition at line 81 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fattach().

Referenced by ACE_SPIPE_Acceptor::create_new_instance(), and fattach().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fdetach ( const char *  file  ) 

Definition at line 95 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fdetach().

Referenced by ACE_SPIPE_Acceptor::close(), and fdetach().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ioctl ( ACE_HANDLE  handle,
ACE_IOCTL_TYPE_ARG2  cmd,
void *  = 0 
)

UNIX-style <ioctl>.

Definition at line 108 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ioctl().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::isastream ( ACE_HANDLE  handle  ) 

Definition at line 126 of file OS_NS_stropts.inl.

Referenced by isastream().

00127 {
00128   ACE_OS_TRACE ("ACE_OS::isastream");
00129 #if defined (ACE_HAS_STREAM_PIPES)
00130   ACE_OSCALL_RETURN (::isastream (handle), int, -1);
00131 #else
00132   ACE_UNUSED_ARG (handle);
00133 
00134   ACE_NOTSUP_RETURN (-1);
00135 #endif /* ACE_HAS_STREAM_PIPES */
00136 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::putmsg ( ACE_HANDLE  handle,
const struct strbuf ctl,
const struct strbuf data,
int  flags 
)

Definition at line 139 of file OS_NS_stropts.inl.

References ACE_NEW_RETURN, ACE_OS_TRACE, strbuf::buf, memcpy(), putmsg(), and write().

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

00141 {
00142   ACE_OS_TRACE ("ACE_OS::putmsg");
00143 #if defined (ACE_HAS_STREAM_PIPES)
00144   ACE_OSCALL_RETURN (::putmsg (handle,
00145                                (ACE_STRBUF_TYPE) ctl,
00146                                (ACE_STRBUF_TYPE) data,
00147                                flags), int, -1);
00148 #else
00149   ACE_UNUSED_ARG (flags);
00150   ssize_t result;
00151   if (ctl == 0 && data == 0)
00152     {
00153       errno = EINVAL;
00154       return 0;
00155     }
00156   // Handle the two easy cases.
00157   else if (ctl != 0)
00158     {
00159       result =  ACE_OS::write (handle, ctl->buf, ctl->len);
00160       return static_cast<int> (result);
00161     }
00162   else if (data != 0)
00163     {
00164       result = ACE_OS::write (handle, data->buf, data->len);
00165       return static_cast<int> (result);
00166     }
00167   else
00168     {
00169       // This is the hard case.
00170       char *buf;
00171       ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
00172       ACE_OS::memcpy (buf, ctl->buf, ctl->len);
00173       ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
00174       result = ACE_OS::write (handle, buf, ctl->len + data->len);
00175       delete [] buf;
00176       return static_cast<int> (result);
00177     }
00178 #endif /* ACE_HAS_STREAM_PIPES */
00179 }

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

Definition at line 182 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, putmsg(), and putpmsg().

Referenced by putpmsg(), and ACE_SPIPE_Stream::send().

00187 {
00188   ACE_OS_TRACE ("ACE_OS::putpmsg");
00189 #if defined (ACE_HAS_STREAM_PIPES)
00190   ACE_OSCALL_RETURN (::putpmsg (handle,
00191                                 (ACE_STRBUF_TYPE) ctl,
00192                                 (ACE_STRBUF_TYPE) data,
00193                                 band, flags), int, -1);
00194 #else
00195   ACE_UNUSED_ARG (flags);
00196   ACE_UNUSED_ARG (band);
00197   return ACE_OS::putmsg (handle, ctl, data, flags);
00198 #endif /* ACE_HAS_STREAM_PIPES */
00199 }

ACE_INLINE int ACE_OS::getmsg ( ACE_HANDLE  handle,
struct strbuf ctl,
struct strbuf data,
int *  flags 
)

Definition at line 39 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getmsg().

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

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

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

Definition at line 59 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getpmsg().

Referenced by getpmsg(), and ACE_SPIPE_Stream::recv().

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

ACE_INLINE int ACE_OS::fattach ( int  handle,
const char *  path 
)

Definition at line 81 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fattach().

Referenced by ACE_SPIPE_Acceptor::create_new_instance(), and fattach().

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

ACE_INLINE int ACE_OS::fdetach ( const char *  file  ) 

Definition at line 95 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fdetach().

Referenced by ACE_SPIPE_Acceptor::close(), and fdetach().

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

ACE_INLINE int ACE_OS::ioctl ( ACE_HANDLE  handle,
ACE_IOCTL_TYPE_ARG2  cmd,
void *  val 
)

UNIX-style <ioctl>.

Definition at line 108 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ioctl().

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

ACE_INLINE int ACE_OS::isastream ( ACE_HANDLE  handle  ) 

Definition at line 126 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and isastream().

00127 {
00128   ACE_OS_TRACE ("ACE_OS::isastream");
00129 #if defined (ACE_HAS_STREAM_PIPES)
00130   ACE_OSCALL_RETURN (::isastream (handle), int, -1);
00131 #else
00132   ACE_UNUSED_ARG (handle);
00133 
00134   ACE_NOTSUP_RETURN (-1);
00135 #endif /* ACE_HAS_STREAM_PIPES */
00136 }

ACE_INLINE int ACE_OS::putmsg ( ACE_HANDLE  handle,
const struct strbuf ctl,
const struct strbuf data,
int  flags 
)

Definition at line 139 of file OS_NS_stropts.inl.

References ACE_NEW_RETURN, ACE_OS_TRACE, strbuf::buf, memcpy(), putmsg(), and write().

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

00141 {
00142   ACE_OS_TRACE ("ACE_OS::putmsg");
00143 #if defined (ACE_HAS_STREAM_PIPES)
00144   ACE_OSCALL_RETURN (::putmsg (handle,
00145                                (ACE_STRBUF_TYPE) ctl,
00146                                (ACE_STRBUF_TYPE) data,
00147                                flags), int, -1);
00148 #else
00149   ACE_UNUSED_ARG (flags);
00150   ssize_t result;
00151   if (ctl == 0 && data == 0)
00152     {
00153       errno = EINVAL;
00154       return 0;
00155     }
00156   // Handle the two easy cases.
00157   else if (ctl != 0)
00158     {
00159       result =  ACE_OS::write (handle, ctl->buf, ctl->len);
00160       return static_cast<int> (result);
00161     }
00162   else if (data != 0)
00163     {
00164       result = ACE_OS::write (handle, data->buf, data->len);
00165       return static_cast<int> (result);
00166     }
00167   else
00168     {
00169       // This is the hard case.
00170       char *buf;
00171       ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
00172       ACE_OS::memcpy (buf, ctl->buf, ctl->len);
00173       ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
00174       result = ACE_OS::write (handle, buf, ctl->len + data->len);
00175       delete [] buf;
00176       return static_cast<int> (result);
00177     }
00178 #endif /* ACE_HAS_STREAM_PIPES */
00179 }

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

Definition at line 182 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, putmsg(), and putpmsg().

Referenced by putpmsg(), and ACE_SPIPE_Stream::send().

00187 {
00188   ACE_OS_TRACE ("ACE_OS::putpmsg");
00189 #if defined (ACE_HAS_STREAM_PIPES)
00190   ACE_OSCALL_RETURN (::putpmsg (handle,
00191                                 (ACE_STRBUF_TYPE) ctl,
00192                                 (ACE_STRBUF_TYPE) data,
00193                                 band, flags), int, -1);
00194 #else
00195   ACE_UNUSED_ARG (flags);
00196   ACE_UNUSED_ARG (band);
00197   return ACE_OS::putmsg (handle, ctl, data, flags);
00198 #endif /* ACE_HAS_STREAM_PIPES */
00199 }

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

Definition at line 21 of file OS_NS_sys_mman.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and madvise().

Referenced by ACE_Mem_Map::advise(), and madvise().

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

ACE_NAMESPACE_INLINE_FUNCTION 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 
)

Definition at line 35 of file OS_NS_sys_mman.inl.

References ACE_BIT_ENABLED, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fsync(), LPSECURITY_ATTRIBUTES, MAP_FAILED, and mmap().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::map_it(), mmap(), sema_init(), and sendfile_emulation().

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

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

Definition at line 182 of file OS_NS_sys_mman.inl.

References ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mprotect().

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

00183 {
00184   ACE_OS_TRACE ("ACE_OS::mprotect");
00185 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00186   DWORD dummy; // Sigh!
00187   return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1;
00188 #elif !defined (ACE_LACKS_MPROTECT)
00189   ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1);
00190 #else
00191   ACE_UNUSED_ARG (addr);
00192   ACE_UNUSED_ARG (len);
00193   ACE_UNUSED_ARG (prot);
00194   ACE_NOTSUP_RETURN (-1);
00195 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00196 }

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

Definition at line 199 of file OS_NS_sys_mman.inl.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msync().

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

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

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

Definition at line 222 of file OS_NS_sys_mman.inl.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and munmap().

Referenced by event_destroy(), munmap(), ACE_Mutex::remove(), sendfile_emulation(), and ACE_Mem_Map::unmap().

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

ACE_NAMESPACE_INLINE_FUNCTION ACE_HANDLE ACE_OS::shm_open ( const ACE_TCHAR filename,
int  mode,
mode_t  perms = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Definition at line 239 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, MAXPATHLEN, open(), shm_open(), and sprintf().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::open(), sema_init(), and shm_open().

00243 {
00244   ACE_OS_TRACE ("ACE_OS::shm_open");
00245 #if defined (ACE_HAS_SHM_OPEN)
00246   ACE_UNUSED_ARG (sa);
00247 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x650)
00248   // With VxWorks the file should just start with / and no other
00249   // slashes, so replace all other / by _
00250   ACE_TCHAR buf [MAXPATHLEN + 1];
00251   ACE_OS::sprintf (buf,
00252                    ACE_TEXT ("%s"),
00253                    filename);
00254   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00255     {
00256       if (buf[i] == '/')
00257         {
00258           buf[i] = '_';
00259         }
00260     }
00261   filename = buf;
00262 #endif
00263   ACE_OSCALL_RETURN (::shm_open (ACE_TEXT_ALWAYS_CHAR(filename), mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00264 #elif defined (ACE_OPENVMS)
00265   //FUZZ: disable check_for_lack_ACE_OS
00266   ACE_OSCALL_RETURN (::open (filename, mode, perms, ACE_TEXT("shr=get,put,upd")), ACE_HANDLE, ACE_INVALID_HANDLE);
00267   //FUZZ: enable check_for_lack_ACE_OS
00268 #else  /* ! ACE_HAS_SHM_OPEN */
00269   // Just use ::open.
00270   return ACE_OS::open (filename, mode, perms, sa);
00271 #endif /* ACE_HAS_SHM_OPEN */
00272 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::shm_unlink ( const ACE_TCHAR path  ) 

Definition at line 275 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, MAXPATHLEN, shm_unlink(), sprintf(), and unlink().

Referenced by event_destroy(), event_init(), ACE_Mutex::remove(), ACE_Mem_Map::remove(), sema_destroy(), and shm_unlink().

00276 {
00277   ACE_OS_TRACE ("ACE_OS::shm_unlink");
00278 #if defined (ACE_HAS_SHM_OPEN)
00279 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x650)
00280   // With VxWorks the file should just start with / and no other
00281   // slashes, so replace all other / by _
00282   ACE_TCHAR buf [MAXPATHLEN + 1];
00283   ACE_OS::sprintf (buf,
00284                    ACE_TEXT ("%s"),
00285                    path);
00286   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00287     {
00288       if (buf[i] == '/')
00289         {
00290           buf[i] = '_';
00291         }
00292     }
00293   path = buf;
00294 #endif
00295   ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1);
00296 #else  /* ! ACE_HAS_SHM_OPEN */
00297   // Just use ::unlink.
00298   return ACE_OS::unlink (path);
00299 #endif /* ACE_HAS_SHM_OPEN */
00300 }

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

Definition at line 21 of file OS_NS_sys_mman.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and madvise().

Referenced by ACE_Mem_Map::advise(), and madvise().

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

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

Definition at line 35 of file OS_NS_sys_mman.inl.

References ACE_BIT_ENABLED, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, fsync(), LPSECURITY_ATTRIBUTES, MAP_FAILED, and mmap().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::map_it(), mmap(), sema_init(), and sendfile_emulation().

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

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

Definition at line 182 of file OS_NS_sys_mman.inl.

References ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mprotect().

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

00183 {
00184   ACE_OS_TRACE ("ACE_OS::mprotect");
00185 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00186   DWORD dummy; // Sigh!
00187   return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1;
00188 #elif !defined (ACE_LACKS_MPROTECT)
00189   ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1);
00190 #else
00191   ACE_UNUSED_ARG (addr);
00192   ACE_UNUSED_ARG (len);
00193   ACE_UNUSED_ARG (prot);
00194   ACE_NOTSUP_RETURN (-1);
00195 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00196 }

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

Definition at line 199 of file OS_NS_sys_mman.inl.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msync().

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

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

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

Definition at line 222 of file OS_NS_sys_mman.inl.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and munmap().

Referenced by event_destroy(), munmap(), ACE_Mutex::remove(), sendfile_emulation(), and ACE_Mem_Map::unmap().

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

ACE_INLINE ACE_HANDLE ACE_OS::shm_open ( const ACE_TCHAR filename,
int  mode,
mode_t  perms,
LPSECURITY_ATTRIBUTES  sa 
)

Definition at line 239 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, MAXPATHLEN, open(), shm_open(), and sprintf().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::open(), sema_init(), and shm_open().

00243 {
00244   ACE_OS_TRACE ("ACE_OS::shm_open");
00245 #if defined (ACE_HAS_SHM_OPEN)
00246   ACE_UNUSED_ARG (sa);
00247 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x650)
00248   // With VxWorks the file should just start with / and no other
00249   // slashes, so replace all other / by _
00250   ACE_TCHAR buf [MAXPATHLEN + 1];
00251   ACE_OS::sprintf (buf,
00252                    ACE_TEXT ("%s"),
00253                    filename);
00254   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00255     {
00256       if (buf[i] == '/')
00257         {
00258           buf[i] = '_';
00259         }
00260     }
00261   filename = buf;
00262 #endif
00263   ACE_OSCALL_RETURN (::shm_open (ACE_TEXT_ALWAYS_CHAR(filename), mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00264 #elif defined (ACE_OPENVMS)
00265   //FUZZ: disable check_for_lack_ACE_OS
00266   ACE_OSCALL_RETURN (::open (filename, mode, perms, ACE_TEXT("shr=get,put,upd")), ACE_HANDLE, ACE_INVALID_HANDLE);
00267   //FUZZ: enable check_for_lack_ACE_OS
00268 #else  /* ! ACE_HAS_SHM_OPEN */
00269   // Just use ::open.
00270   return ACE_OS::open (filename, mode, perms, sa);
00271 #endif /* ACE_HAS_SHM_OPEN */
00272 }

ACE_INLINE int ACE_OS::shm_unlink ( const ACE_TCHAR path  ) 

Definition at line 275 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, MAXPATHLEN, shm_unlink(), sprintf(), and unlink().

Referenced by event_destroy(), event_init(), ACE_Mem_Map::remove(), ACE_Mutex::remove(), sema_destroy(), and shm_unlink().

00276 {
00277   ACE_OS_TRACE ("ACE_OS::shm_unlink");
00278 #if defined (ACE_HAS_SHM_OPEN)
00279 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x650)
00280   // With VxWorks the file should just start with / and no other
00281   // slashes, so replace all other / by _
00282   ACE_TCHAR buf [MAXPATHLEN + 1];
00283   ACE_OS::sprintf (buf,
00284                    ACE_TEXT ("%s"),
00285                    path);
00286   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00287     {
00288       if (buf[i] == '/')
00289         {
00290           buf[i] = '_';
00291         }
00292     }
00293   path = buf;
00294 #endif
00295   ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1);
00296 #else  /* ! ACE_HAS_SHM_OPEN */
00297   // Just use ::unlink.
00298   return ACE_OS::unlink (path);
00299 #endif /* ACE_HAS_SHM_OPEN */
00300 }

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

Definition at line 10 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgctl().

Referenced by ACE_SV_Message_Queue::control(), and msgctl().

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

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

Definition at line 25 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgget().

Referenced by msgget(), and ACE_SV_Message_Queue::open().

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

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

Definition at line 39 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgrcv().

Referenced by msgrcv(), and ACE_SV_Message_Queue::recv().

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

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

Definition at line 58 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgsnd().

Referenced by msgsnd(), and ACE_SV_Message_Queue::send().

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

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

Definition at line 10 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgctl().

Referenced by ACE_SV_Message_Queue::control(), and msgctl().

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

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

Definition at line 25 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgget().

Referenced by msgget(), and ACE_SV_Message_Queue::open().

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

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

Definition at line 39 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgrcv().

Referenced by msgrcv(), and ACE_SV_Message_Queue::recv().

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

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

Definition at line 58 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgsnd().

Referenced by msgsnd(), and ACE_SV_Message_Queue::send().

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

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

Definition at line 11 of file OS_NS_sys_resource.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getrlimit().

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

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

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

Definition at line 30 of file OS_NS_sys_resource.inl.

Referenced by getrusage().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setrlimit ( int  resource,
const struct rlimit *  rl 
)

Definition at line 67 of file OS_NS_sys_resource.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setrlimit().

Referenced by ACE::set_handle_limit(), and setrlimit().

00068 {
00069   ACE_OS_TRACE ("ACE_OS::setrlimit");
00070 
00071 #if defined (ACE_LACKS_RLIMIT)
00072   ACE_UNUSED_ARG (resource);
00073   ACE_UNUSED_ARG (rl);
00074 
00075   ACE_NOTSUP_RETURN (-1);
00076 #else
00077 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
00078 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00079   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00080                                   const_cast<struct rlimit *>(rl)
00081                                   ), int, -1);
00082 # else
00083   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00084                                   rl
00085                                   ), int, -1);
00086 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00087 # else /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00088 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00089   ACE_OSCALL_RETURN (::setrlimit (resource, const_cast<struct rlimit *>(rl)
00090                                   ), int, -1);
00091 #  else
00092   ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1);
00093 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00094 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00095 #endif /* ACE_LACKS_RLIMIT */
00096 }

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

Definition at line 11 of file OS_NS_sys_resource.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getrlimit().

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

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

ACE_INLINE int ACE_OS::getrusage ( int  who,
struct rusage *  ru 
)

Definition at line 30 of file OS_NS_sys_resource.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getrusage().

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

ACE_INLINE int ACE_OS::setrlimit ( int  resource,
const struct rlimit *  rl 
)

Definition at line 67 of file OS_NS_sys_resource.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setrlimit().

Referenced by ACE::set_handle_limit(), and setrlimit().

00068 {
00069   ACE_OS_TRACE ("ACE_OS::setrlimit");
00070 
00071 #if defined (ACE_LACKS_RLIMIT)
00072   ACE_UNUSED_ARG (resource);
00073   ACE_UNUSED_ARG (rl);
00074 
00075   ACE_NOTSUP_RETURN (-1);
00076 #else
00077 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
00078 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00079   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00080                                   const_cast<struct rlimit *>(rl)
00081                                   ), int, -1);
00082 # else
00083   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00084                                   rl
00085                                   ), int, -1);
00086 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00087 # else /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00088 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00089   ACE_OSCALL_RETURN (::setrlimit (resource, const_cast<struct rlimit *>(rl)
00090                                   ), int, -1);
00091 #  else
00092   ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1);
00093 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00094 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00095 #endif /* ACE_LACKS_RLIMIT */
00096 }

ACE_NAMESPACE_INLINE_FUNCTION 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 14 of file OS_NS_sys_select.inl.

Referenced by ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::handle_input(), ACE::handle_ready(), ACE::handle_timed_accept(), ACE::handle_timed_complete(), ACE_SOCK_Dgram::recv(), ACE_SOCK_Dgram_SC< STREAM >::recv(), ACE_SOCK_IO::recvv(), select(), ACE::select(), sema_wait(), ACE_SOCK_Dgram::send(), sleep(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::wait_for_multiple_events(), and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::work_pending().

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

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

Definition at line 51 of file OS_NS_sys_select.inl.

References ___ACE_TIMEOUT, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and select().

00054 {
00055   ACE_OS_TRACE ("ACE_OS::select");
00056 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00057 # define ___ACE_TIMEOUT &copy
00058   timeval copy = timeout;
00059 #else
00060 # define ___ACE_TIMEOUT timep
00061   const timeval *timep = timeout;
00062 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00063 #if defined (ACE_LACKS_SELECT)
00064   ACE_UNUSED_ARG (width);
00065   ACE_UNUSED_ARG (rfds);
00066   ACE_UNUSED_ARG (wfds);
00067   ACE_UNUSED_ARG (efds);
00068   ACE_UNUSED_ARG (timeout);
00069   ACE_NOTSUP_RETURN (-1);
00070 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00071   ACE_SOCKCALL_RETURN (::spt_select (width, rfds, wfds, efds, ___ACE_TIMEOUT),
00072                        int, -1);
00073 #else
00074   ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, ___ACE_TIMEOUT),
00075                        int, -1);
00076 #endif
00077 #undef ___ACE_TIMEOUT
00078 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::select ( int  width,
fd_set *  rfds,
fd_set *  wfds,
fd_set *  efds,
const ACE_Time_Value timeout 
)

Definition at line 14 of file OS_NS_sys_select.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and select().

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

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

Definition at line 51 of file OS_NS_sys_select.inl.

References ___ACE_TIMEOUT, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and select().

00054 {
00055   ACE_OS_TRACE ("ACE_OS::select");
00056 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00057 # define ___ACE_TIMEOUT &copy
00058   timeval copy = timeout;
00059 #else
00060 # define ___ACE_TIMEOUT timep
00061   const timeval *timep = timeout;
00062 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00063 #if defined (ACE_LACKS_SELECT)
00064   ACE_UNUSED_ARG (width);
00065   ACE_UNUSED_ARG (rfds);
00066   ACE_UNUSED_ARG (wfds);
00067   ACE_UNUSED_ARG (efds);
00068   ACE_UNUSED_ARG (timeout);
00069   ACE_NOTSUP_RETURN (-1);
00070 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00071   ACE_SOCKCALL_RETURN (::spt_select (width, rfds, wfds, efds, ___ACE_TIMEOUT),
00072                        int, -1);
00073 #else
00074   ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, ___ACE_TIMEOUT),
00075                        int, -1);
00076 #endif
00077 #undef ___ACE_TIMEOUT
00078 }

ACE_Export ssize_t ACE_OS::sendfile_emulation ( ACE_HANDLE  out_fd,
ACE_HANDLE  in_fd,
off_t *  offset,
size_t  count 
)

Definition at line 20 of file OS_NS_sys_sendfile.cpp.

References MAP_FAILED, mmap(), munmap(), send(), and write().

Referenced by sendfile().

00024 {
00025   // @@ Is it possible to inline a call to ::TransmitFile() on
00026   //    MS Windows instead of emulating here?
00027 
00028   // @@ We may want set up a signal lease (or oplock) if supported by
00029   //    the platform so that we don't get a bus error if the mmap()ed
00030   //    file is truncated.
00031   void * const buf =
00032     ACE_OS::mmap (0, count, PROT_READ, MAP_SHARED, in_fd, *offset);
00033 
00034   if (buf == MAP_FAILED)
00035     return -1;
00036 
00037 #if defined (ACE_WIN32) || defined (HPUX)
00038   ssize_t const r =
00039     ACE_OS::send (out_fd, static_cast<const char *> (buf), count);
00040 #else
00041   ssize_t const r = ACE_OS::write (out_fd, buf, count);
00042 #endif /* ACE_WIN32 */
00043 
00044   (void) ACE_OS::munmap (buf, count);
00045 
00046   if (r > 0)
00047     *offset += static_cast<off_t> (r);
00048 
00049   return r;
00050 }

ACE_NAMESPACE_INLINE_FUNCTION 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 12 of file OS_NS_sys_sendfile.inl.

References sendfile(), and sendfile_emulation().

Referenced by sendfile().

00016 {
00017 #ifdef ACE_HAS_SENDFILE
00018   return ::sendfile (out_fd, in_fd, offset, count);
00019 #else
00020   return ACE_OS::sendfile_emulation (out_fd, in_fd, offset, count);
00021 #endif  /* ACE_HAS_SENDFILE */
00022 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE 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 12 of file OS_NS_sys_sendfile.inl.

References sendfile(), and sendfile_emulation().

Referenced by sendfile().

00016 {
00017 #ifdef ACE_HAS_SENDFILE
00018   return ::sendfile (out_fd, in_fd, offset, count);
00019 #else
00020   return ACE_OS::sendfile_emulation (out_fd, in_fd, offset, count);
00021 #endif  /* ACE_HAS_SENDFILE */
00022 }

ACE_NAMESPACE_INLINE_FUNCTION void* ACE_OS::shmat ( int  int_id,
const void *  shmaddr,
int  shmflg 
)

Definition at line 10 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmat().

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

00011 {
00012   ACE_OS_TRACE ("ACE_OS::shmat");
00013 #if defined (ACE_HAS_SYSV_IPC)
00014 #  if defined (ACE_HAS_CHARPTR_SHMAT)
00015   ACE_OSCALL_RETURN (::shmat (int_id, static_cast <char*> (const_cast <void *>(shmaddr)), shmflg), void *, (void *) -1);
00016 #  else
00017   ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1);
00018 #  endif /* ACE_HAS_CHARPTR_SHMAT */
00019 #else
00020   ACE_UNUSED_ARG (int_id);
00021   ACE_UNUSED_ARG (shmaddr);
00022   ACE_UNUSED_ARG (shmflg);
00023 
00024   ACE_NOTSUP_RETURN ((void *) -1);
00025 #endif /* ACE_HAS_SYSV_IPC */
00026 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::shmctl ( int  int_id,
int  cmd,
struct shmid_ds *  buf 
)

Definition at line 29 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmctl().

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

00030 {
00031   ACE_OS_TRACE ("ACE_OS::shmctl");
00032 #if defined (ACE_HAS_SYSV_IPC)
00033   ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1);
00034 #else
00035   ACE_UNUSED_ARG (buf);
00036   ACE_UNUSED_ARG (cmd);
00037   ACE_UNUSED_ARG (int_id);
00038 
00039   ACE_NOTSUP_RETURN (-1);
00040 #endif /* ACE_HAS_SYSV_IPC */
00041 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::shmdt ( const void *  shmaddr  ) 

Definition at line 44 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmdt().

Referenced by ACE_SV_Shared_Memory::detach(), and shmdt().

00045 {
00046   ACE_OS_TRACE ("ACE_OS::shmdt");
00047 #if defined (ACE_HAS_SYSV_IPC)
00048 #  if defined (ACE_HAS_CHARPTR_SHMDT)
00049      ACE_OSCALL_RETURN (::shmdt (
00050       static_cast <char*> (const_cast <void *>(shmaddr))), int, -1);
00051 # else
00052      ACE_OSCALL_RETURN (::shmdt (shmaddr), int, -1);
00053 #  endif /* ACE_HAS_CHARPTR_SHMDT */
00054 #else
00055   ACE_UNUSED_ARG (shmaddr);
00056 
00057   ACE_NOTSUP_RETURN (-1);
00058 #endif /* ACE_HAS_SYSV_IPC */
00059 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::shmget ( key_t  key,
size_t  size,
int  flags 
)

Definition at line 62 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmget().

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

00063 {
00064   ACE_OS_TRACE ("ACE_OS::shmget");
00065 #if defined (ACE_HAS_SYSV_IPC)
00066   ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1);
00067 #else
00068   ACE_UNUSED_ARG (flags);
00069   ACE_UNUSED_ARG (size);
00070   ACE_UNUSED_ARG (key);
00071 
00072   ACE_NOTSUP_RETURN (-1);
00073 #endif /* ACE_HAS_SYSV_IPC */
00074 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void* ACE_OS::shmat ( int  int_id,
const void *  shmaddr,
int  shmflg 
)

Definition at line 10 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmat().

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

00011 {
00012   ACE_OS_TRACE ("ACE_OS::shmat");
00013 #if defined (ACE_HAS_SYSV_IPC)
00014 #  if defined (ACE_HAS_CHARPTR_SHMAT)
00015   ACE_OSCALL_RETURN (::shmat (int_id, static_cast <char*> (const_cast <void *>(shmaddr)), shmflg), void *, (void *) -1);
00016 #  else
00017   ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1);
00018 #  endif /* ACE_HAS_CHARPTR_SHMAT */
00019 #else
00020   ACE_UNUSED_ARG (int_id);
00021   ACE_UNUSED_ARG (shmaddr);
00022   ACE_UNUSED_ARG (shmflg);
00023 
00024   ACE_NOTSUP_RETURN ((void *) -1);
00025 #endif /* ACE_HAS_SYSV_IPC */
00026 }

ACE_INLINE int ACE_OS::shmctl ( int  int_id,
int  cmd,
struct shmid_ds *  buf 
)

Definition at line 29 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmctl().

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

00030 {
00031   ACE_OS_TRACE ("ACE_OS::shmctl");
00032 #if defined (ACE_HAS_SYSV_IPC)
00033   ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1);
00034 #else
00035   ACE_UNUSED_ARG (buf);
00036   ACE_UNUSED_ARG (cmd);
00037   ACE_UNUSED_ARG (int_id);
00038 
00039   ACE_NOTSUP_RETURN (-1);
00040 #endif /* ACE_HAS_SYSV_IPC */
00041 }

ACE_INLINE int ACE_OS::shmdt ( const void *  shmaddr  ) 

Definition at line 44 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmdt().

Referenced by ACE_SV_Shared_Memory::detach(), and shmdt().

00045 {
00046   ACE_OS_TRACE ("ACE_OS::shmdt");
00047 #if defined (ACE_HAS_SYSV_IPC)
00048 #  if defined (ACE_HAS_CHARPTR_SHMDT)
00049      ACE_OSCALL_RETURN (::shmdt (
00050       static_cast <char*> (const_cast <void *>(shmaddr))), int, -1);
00051 # else
00052      ACE_OSCALL_RETURN (::shmdt (shmaddr), int, -1);
00053 #  endif /* ACE_HAS_CHARPTR_SHMDT */
00054 #else
00055   ACE_UNUSED_ARG (shmaddr);
00056 
00057   ACE_NOTSUP_RETURN (-1);
00058 #endif /* ACE_HAS_SYSV_IPC */
00059 }

ACE_INLINE int ACE_OS::shmget ( key_t  key,
size_t  size,
int  flags 
)

Definition at line 62 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmget().

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

00063 {
00064   ACE_OS_TRACE ("ACE_OS::shmget");
00065 #if defined (ACE_HAS_SYSV_IPC)
00066   ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1);
00067 #else
00068   ACE_UNUSED_ARG (flags);
00069   ACE_UNUSED_ARG (size);
00070   ACE_UNUSED_ARG (key);
00071 
00072   ACE_NOTSUP_RETURN (-1);
00073 #endif /* ACE_HAS_SYSV_IPC */
00074 }

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

References ACE_SOCKCALL_RETURN, ACE_Accept_QoS_Params::callback_data(), and ACE_Accept_QoS_Params::qos_condition_callback().

Referenced by ACE_SOCK_SEQPACK_Acceptor::accept(), ACE_SOCK_Acceptor::accept(), accept(), ACE_MEM_Acceptor::accept(), and ACE_LSOCK_Acceptor::accept().

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

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

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_QoS_Params::callee_data(), ACE_QoS_Params::caller_data(), ACE_QoS_Params::group_socket_qos(), and ACE_QoS_Params::socket_qos().

Referenced by ACE_SOCK_SEQPACK_Connector::connect(), ACE_SOCK_Connector::connect(), connect(), and ACE_SOCK_CODgram::open().

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

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

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

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

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

References ACE_TEXT, fprintf(), and sprintf().

Referenced by ACE_OS_Object_Manager::init().

00102 {
00103 # if defined (ACE_WIN32) && !defined(ACE_DONT_INIT_WINSOCK)
00104   if (ACE_OS::socket_initialized_ == 0)
00105     {
00106       WORD version_requested = MAKEWORD (version_high, version_low);
00107       WSADATA wsa_data;
00108       int error = WSAStartup (version_requested, &wsa_data);
00109 
00110       if (error != 0)
00111 #   if defined (ACE_HAS_WINCE)
00112         {
00113           ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
00114           ACE_TCHAR buf[80];  // @@ Eliminate magic number.
00115           ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSAStartup"), error);
00116           ::MessageBox (0, buf, ACE_TEXT ("WSAStartup failed!"), MB_OK);
00117         }
00118 #   else
00119       ACE_OS::fprintf (stderr,
00120                        "ACE_OS::socket_init; WSAStartup failed, "
00121                          "WSAGetLastError returned %d\n",
00122                        error);
00123 #   endif /* ACE_HAS_WINCE */
00124 
00125       ACE_OS::socket_initialized_ = 1;
00126     }
00127 # else
00128   ACE_UNUSED_ARG (version_high);
00129   ACE_UNUSED_ARG (version_low);
00130 # endif /* ACE_WIN32 */
00131   return 0;
00132 }

ACE_Export int ACE_OS::socket_fini ( void   ) 

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

Definition at line 135 of file OS_NS_sys_socket.cpp.

References ACE_TEXT, fprintf(), and sprintf().

Referenced by ACE_OS_Object_Manager::fini().

00136 {
00137 # if defined (ACE_WIN32)
00138   if (ACE_OS::socket_initialized_ != 0)
00139     {
00140       if (WSACleanup () != 0)
00141         {
00142           int error = ::WSAGetLastError ();
00143 #   if defined (ACE_HAS_WINCE)
00144           ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
00145           ACE_TCHAR buf[80];  // @@ Eliminate magic number.
00146           ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSACleanup"), error);
00147           ::MessageBox (0, buf , ACE_TEXT ("WSACleanup failed!"), MB_OK);
00148 #   else
00149           ACE_OS::fprintf (stderr,
00150                            "ACE_OS::socket_fini; WSACleanup failed, "
00151                              "WSAGetLastError returned %d\n",
00152                            error);
00153 #   endif /* ACE_HAS_WINCE */
00154         }
00155       ACE_OS::socket_initialized_ = 0;
00156     }
00157 # endif /* ACE_WIN32 */
00158   return 0;
00159 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_HANDLE ACE_OS::accept ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen 
)

BSD-style <accept> (no QoS).

Definition at line 29 of file OS_NS_sys_socket.inl.

References accept(), ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::bind ( ACE_HANDLE  s,
struct sockaddr *  name,
int  namelen 
)

BSD-style <accept> (no QoS).

Definition at line 98 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, bind(), and getsockname().

Referenced by bind(), ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::bind(), ACE::bind_port(), ACE_SOCK_CODgram::open(), ACE_SOCK_SEQPACK_Connector::shared_connect_start(), ACE_SOCK_Connector::shared_connect_start(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_SOCK_Dgram::shared_open(), and ACE_SOCK_Acceptor::shared_open().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::closesocket ( ACE_HANDLE  s  ) 

Takes care of windows specific requirement to call closesocket.

Definition at line 127 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, close(), and closesocket().

Referenced by ACE_SOCK::close(), ACE_Pipe::close(), ACE_Process::close_dup_handles(), ACE_Process::close_passed_handles(), and closesocket().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::connect ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int  addrlen 
)

BSD-style <connect> (no QoS).

Definition at line 145 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and connect().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::enum_protocols ( int *  protocols,
ACE_Protocol_Info protocol_buffer,
u_long *  buffer_length 
)

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

Definition at line 163 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, and ACE_SOCKCALL_RETURN.

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::getpeername ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen 
)

BSD-style <accept> (no QoS).

Definition at line 184 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, AF_INET, getpeername(), and memset().

Referenced by ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK_Connector::complete(), ACE_SOCK::get_remote_addr(), ACE_SOCK_SEQPACK_Association::get_remote_addrs(), and getpeername().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::getsockname ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen 
)

BSD-style <accept> (no QoS).

Definition at line 232 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, AF_INET, getsockname(), and memset().

Referenced by bind(), ACE_SOCK::get_local_addr(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), getsockname(), and ACE_SOCK_SEQPACK_Connector::shared_connect_start().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::getsockopt ( ACE_HANDLE  handle,
int  level,
int  optname,
char *  optval,
int *  optlen 
)

BSD-style <accept> (no QoS).

Definition at line 277 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and getsockopt().

Referenced by ACE_SOCK::get_option(), getsockopt(), and ACE::handle_timed_complete().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::listen ( ACE_HANDLE  handle,
int  backlog 
)

BSD-style <accept> (no QoS).

Definition at line 303 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and listen().

Referenced by listen(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), and ACE_SOCK_Acceptor::shared_open().

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

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

BSD-style <accept> (no QoS).

Definition at line 316 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and recv().

Referenced by ACE_Pipe::recv(), recv(), ACE::recv(), ACE::recv_i(), ACE::recv_n_i(), and recvv().

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

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

BSD-style <accept> (no QoS).

Definition at line 363 of file OS_NS_sys_socket.inl.

Referenced by ACE_SOCK_Dgram::recv(), recvfrom(), and ACE::recvfrom().

00369 {
00370   ACE_OS_TRACE ("ACE_OS::recvfrom");
00371 #if defined (ACE_LACKS_RECVFROM)
00372   ACE_UNUSED_ARG (handle);
00373   ACE_UNUSED_ARG (buf);
00374   ACE_UNUSED_ARG (len);
00375   ACE_UNUSED_ARG (flags);
00376   ACE_UNUSED_ARG (addr);
00377   ACE_UNUSED_ARG (addrlen);
00378   ACE_NOTSUP_RETURN (-1);
00379 #elif defined (ACE_WIN32)
00380   int const shortened_len = static_cast<int> (len);
00381   int const result = ::recvfrom ((ACE_SOCKET) handle,
00382                                  buf,
00383                                  shortened_len,
00384                                  flags,
00385                                  addr,
00386                                  (ACE_SOCKET_LEN *) addrlen);
00387   if (result == SOCKET_ERROR)
00388     {
00389       ACE_OS::set_errno_to_wsa_last_error ();
00390       if (errno == WSAEMSGSIZE &&
00391           ACE_BIT_ENABLED (flags, MSG_PEEK))
00392         return shortened_len;
00393       else
00394         return -1;
00395     }
00396   else
00397     return result;
00398 #else /* non Win32 */
00399   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle,
00400                                    buf,
00401                                    len,
00402                                    flags,
00403                                    addr,
00404                                    (ACE_SOCKET_LEN *) addrlen),
00405                        ssize_t, -1);
00406 #endif /* ACE_LACKS_RECVFROM */
00407 }

ACE_NAMESPACE_INLINE_FUNCTION 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 
)

BSD-style <accept> (no QoS).

Definition at line 410 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and set_errno_to_wsa_last_error().

00419 {
00420   ACE_OS_TRACE ("ACE_OS::recvfrom");
00421 
00422 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00423   DWORD bytes_recvd;
00424   DWORD the_flags = flags;
00425   int result = ::WSARecvFrom ((SOCKET) handle,
00426                               (WSABUF*)buffers,
00427                               buffer_count,
00428                               &bytes_recvd,
00429                               &the_flags,
00430                               addr,
00431                               addrlen,
00432                               overlapped,
00433                               func);
00434   if (result != 0) {
00435     ACE_OS::set_errno_to_wsa_last_error ();
00436   }
00437   flags = the_flags;
00438   number_of_bytes_recvd = static_cast<size_t> (bytes_recvd);
00439   return result;
00440 #else
00441   ACE_UNUSED_ARG (handle);
00442   ACE_UNUSED_ARG (buffers);
00443   ACE_UNUSED_ARG (buffer_count);
00444   ACE_UNUSED_ARG (number_of_bytes_recvd);
00445   ACE_UNUSED_ARG (flags);
00446   ACE_UNUSED_ARG (addr);
00447   ACE_UNUSED_ARG (addrlen);
00448   ACE_UNUSED_ARG (overlapped);
00449   ACE_UNUSED_ARG (func);
00450   ACE_NOTSUP_RETURN (-1);
00451 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00452 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::recvmsg ( ACE_HANDLE  handle,
struct msghdr msg,
int  flags 
)

BSD-style <accept> (no QoS).

Definition at line 455 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, recvmsg(), and set_errno_to_wsa_last_error().

Referenced by recvmsg(), and ACE::recvmsg().

00456 {
00457   ACE_OS_TRACE ("ACE_OS::recvmsg");
00458 #if !defined (ACE_LACKS_RECVMSG)
00459 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00460   DWORD bytes_received = 0;
00461 
00462   int result = ::WSARecvFrom ((SOCKET) handle,
00463                               (WSABUF *) msg->msg_iov,
00464                               msg->msg_iovlen,
00465                               &bytes_received,
00466                               (DWORD *) &flags,
00467                               msg->msg_name,
00468                               &msg->msg_namelen,
00469                               0,
00470                               0);
00471 
00472   if (result != 0)
00473     {
00474       ACE_OS::set_errno_to_wsa_last_error ();
00475       return -1;
00476     }
00477   else
00478     return bytes_received;
00479 # else /* ACE_HAS_WINSOCK2 */
00480   ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), ssize_t, -1);
00481 # endif /* ACE_HAS_WINSOCK2 */
00482 #else
00483   ACE_UNUSED_ARG (flags);
00484   ACE_UNUSED_ARG (msg);
00485   ACE_UNUSED_ARG (handle);
00486 
00487   ACE_NOTSUP_RETURN (-1);
00488 #endif /* ACE_LACKS_RECVMSG */
00489 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::recvv ( ACE_HANDLE  handle,
iovec *  iov,
int  iovlen 
)

BSD-style <accept> (no QoS).

Definition at line 492 of file OS_NS_sys_socket.inl.

References readv(), recv(), and set_errno_to_wsa_last_error().

Referenced by ACE_SOCK_IO::recv(), ACE_Pipe::recv(), ACE::recv(), ACE::recvv(), and ACE::recvv_n_i().

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

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::send ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags = 0 
)

BSD-style <accept> (no QoS).

Definition at line 549 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and send().

Referenced by ACE_Pipe::send(), send(), ACE::send(), ACE::send_i(), ACE::send_n_i(), sendfile_emulation(), and sendv().

00550 {
00551   ACE_OS_TRACE ("ACE_OS::send");
00552 
00553   // On UNIX, a non-blocking socket with no data to receive, this
00554   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00555   // platform.  UNIX 98 allows either errno, and they may be the same
00556   // numeric value.  So to make life easier for upper ACE layers as
00557   // well as application programmers, always change EAGAIN to
00558   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00559   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00560   // this function needs to be reviewed.  On Win32, the regular macros
00561   // can be used, as this is not an issue.
00562 #if defined (ACE_LACKS_SEND)
00563   ACE_UNUSED_ARG (handle);
00564   ACE_UNUSED_ARG (buf);
00565   ACE_UNUSED_ARG (len);
00566   ACE_UNUSED_ARG (flags);
00567   ACE_NOTSUP_RETURN (-1);
00568 #elif defined (ACE_WIN32)
00569   ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle,
00570                                buf,
00571                                static_cast<int> (len),
00572                                flags), ssize_t, -1);
00573 #else
00574   ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
00575 
00576 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00577   // Optimize this code out if we can detect that EAGAIN ==
00578   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00579   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00580   // macros) perform the check at run-time.  The goal is to avoid two
00581   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00582   if (ace_result_ == -1
00583 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00584       && EAGAIN != EWOULDBLOCK
00585 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00586       && errno == EAGAIN)
00587     {
00588       errno = EWOULDBLOCK;
00589     }
00590 # endif /* EAGAIN != EWOULDBLOCK*/
00591 
00592   return ace_result_;
00593 #endif /* defined (ACE_WIN32) */
00594 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::sendmsg ( ACE_HANDLE  handle,
const struct msghdr msg,
int  flags 
)

BSD-style <accept> (no QoS).

Definition at line 597 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, sendmsg(), and set_errno_to_wsa_last_error().

Referenced by sendmsg(), and ACE::sendmsg().

00600 {
00601   ACE_OS_TRACE ("ACE_OS::sendmsg");
00602 #if !defined (ACE_LACKS_SENDMSG)
00603 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00604   DWORD bytes_sent = 0;
00605   int result = ::WSASendTo ((SOCKET) handle,
00606                             (WSABUF *) msg->msg_iov,
00607                             msg->msg_iovlen,
00608                             &bytes_sent,
00609                             flags,
00610                             msg->msg_name,
00611                             msg->msg_namelen,
00612                             0,
00613                             0);
00614 
00615   if (result != 0)
00616     {
00617       ACE_OS::set_errno_to_wsa_last_error ();
00618       return -1;
00619     }
00620   else
00621     return (ssize_t) bytes_sent;
00622 # elif defined (ACE_HAS_NONCONST_SENDMSG)
00623   ACE_SOCKCALL_RETURN (::sendmsg (handle,
00624                                   const_cast<struct msghdr *>(msg),
00625                                   flags), ssize_t, -1);
00626 # else
00627   ACE_SOCKCALL_RETURN (::sendmsg (handle, msg, flags), ssize_t, -1);
00628 # endif
00629 #else
00630   ACE_UNUSED_ARG (flags);
00631   ACE_UNUSED_ARG (msg);
00632   ACE_UNUSED_ARG (handle);
00633 
00634   ACE_NOTSUP_RETURN (-1);
00635 #endif /* ACE_LACKS_SENDMSG */
00636 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::sendto ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags,
const struct sockaddr *  addr,
int  addrlen 
)

BSD-style <accept> (no QoS).

Definition at line 639 of file OS_NS_sys_socket.inl.

Referenced by ACE_SOCK_Dgram_Bcast::send(), ACE_SOCK_Dgram::send(), sendto(), and ACE::sendto().

00645 {
00646   ACE_OS_TRACE ("ACE_OS::sendto");
00647 #if defined (ACE_LACKS_SENDTO)
00648   ACE_UNUSED_ARG (handle);
00649   ACE_UNUSED_ARG (buf);
00650   ACE_UNUSED_ARG (len);
00651   ACE_UNUSED_ARG (flags);
00652   ACE_UNUSED_ARG (addr);
00653   ACE_UNUSED_ARG (addrlen);
00654   ACE_NOTSUP_RETURN (-1);
00655 #elif defined (ACE_VXWORKS)
00656   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00657                                  const_cast <char *> (buf),
00658                                  len,
00659                                  flags,
00660                                  const_cast<struct sockaddr *> (addr),
00661                                  addrlen),
00662                        ssize_t, -1);
00663 #elif defined (ACE_WIN32)
00664   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00665                                  buf,
00666                                  static_cast<int> (len),
00667                                  flags,
00668                                  const_cast<struct sockaddr *> (addr),
00669                                  addrlen),
00670                        ssize_t, -1);
00671 #else
00672   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00673                                  buf,
00674                                  len,
00675                                  flags,
00676                                  const_cast<struct sockaddr *> (addr),
00677                                  addrlen),
00678                        ssize_t, -1);
00679 #endif /* ACE_LACKS_SENDTO */
00680 }

ACE_NAMESPACE_INLINE_FUNCTION 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 
)

BSD-style <accept> (no QoS).

Definition at line 683 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, sendto(), and set_errno_to_wsa_last_error().

00692 {
00693   ACE_OS_TRACE ("ACE_OS::sendto");
00694 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00695   DWORD bytes_sent = 0;
00696   int result = ::WSASendTo ((SOCKET) handle,
00697                             (WSABUF*) buffers,
00698                             buffer_count,
00699                             &bytes_sent,
00700                             flags,
00701                             addr,
00702                             addrlen,
00703                             overlapped,
00704                             func);
00705   if (result != 0) {
00706     ACE_OS::set_errno_to_wsa_last_error ();
00707   }
00708   number_of_bytes_sent = static_cast<size_t> (bytes_sent);
00709   return (ssize_t) result;
00710 #else
00711   ACE_UNUSED_ARG (overlapped);
00712   ACE_UNUSED_ARG (func);
00713 
00714   number_of_bytes_sent = 0;
00715 
00716   ssize_t result = 0;
00717 
00718   for (int i = 0; i < buffer_count; ++i)
00719     {
00720        result = ACE_OS::sendto (handle,
00721                                 reinterpret_cast<char *> (
00722                                                  buffers[i].iov_base),
00723                                 buffers[i].iov_len,
00724                                 flags,
00725                                 addr,
00726                                 addrlen);
00727        if (result == -1)
00728          break;
00729        number_of_bytes_sent += static_cast<size_t> (result);
00730     }
00731 
00732   return result;
00733 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00734 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::sendv ( ACE_HANDLE  handle,
const iovec *  iov,
int  iovcnt 
)

BSD-style <accept> (no QoS).

Definition at line 737 of file OS_NS_sys_socket.inl.

References ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE, ACE_IOV_MAX, send(), set_errno_to_wsa_last_error(), and writev().

Referenced by ACE_Pipe::recvv_n(), ACE_SOCK_IO::send(), ACE_Pipe::send(), ACE::send(), ACE_Pipe::sendv(), ACE::sendv(), and ACE::sendv_n_i().

00740 {
00741 #if defined (ACE_HAS_WINSOCK2)
00742   DWORD bytes_sent = 0;
00743   ssize_t result = 0;
00744 
00745   // Winsock 2 has WSASend and can do this directly, but Winsock 1
00746   // needs to do the sends one-by-one.
00747 # if (ACE_HAS_WINSOCK2 != 0)
00748   result = ::WSASend ((SOCKET) handle,
00749                       (WSABUF *) buffers,
00750                       n,
00751                       &bytes_sent,
00752                       0,
00753                       0,
00754                       0);
00755   if (result == SOCKET_ERROR)
00756     {
00757       ACE_OS::set_errno_to_wsa_last_error ();
00758       return -1;
00759     }
00760 # else
00761   for (int i = 0; i < n; ++i)
00762     {
00763       result = ::send ((SOCKET) handle,
00764                        buffers[i].iov_base,
00765                        buffers[i].iov_len,
00766                        0);
00767 
00768       if (result == SOCKET_ERROR)
00769         {
00770           // There is a subtle difference in behaviour depending on
00771           // whether or not any data was sent.  If no data was sent,
00772           // then always return -1.  Otherwise return bytes_sent.
00773           // This gives the caller an opportunity to keep track of
00774           // bytes that have already been sent.
00775           if (bytes_sent > 0)
00776             break;
00777           else
00778             {
00779               ACE_OS::set_errno_to_wsa_last_error ();
00780               return -1;
00781             }
00782         }
00783       else
00784         {
00785           // Gets ignored on error anyway
00786           bytes_sent += result;
00787 
00788           // If the transfer isn't complete just drop out of the loop.
00789           if (result < (int)buffers[i].iov_len)
00790             break;
00791         }
00792     }
00793 # endif /* ACE_HAS_WINSOCK2 != 0 */
00794 
00795   return (ssize_t) bytes_sent;
00796 
00797 #elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX)
00798 
00799   // Platform limits the maximum socket message size.  Pare down the
00800   // iovec, if necessary, to obey the limit.
00801   iovec local_iov[ACE_IOV_MAX];
00802   long total = 0;
00803   long new_total = 0;
00804   for (int i = 0; i < n; i++)
00805     {
00806       local_iov[i].iov_base = buffers[i].iov_base;
00807       local_iov[i].iov_len  = buffers[i].iov_len;
00808 
00809       new_total = total + buffers[i].iov_len;
00810       if (new_total >= ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE)
00811         {
00812           local_iov[i].iov_len = ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE - total;
00813           n = i+1;
00814           break;
00815         }
00816       total = new_total;
00817     }
00818   return ACE_OS::writev (handle, local_iov, n);
00819 
00820 #else
00821   return ACE_OS::writev (handle, buffers, n);
00822 #endif /* ACE_HAS_WINSOCK2 */
00823 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setsockopt ( ACE_HANDLE  handle,
int  level,
int  optname,
const char *  optval,
int  optlen 
)

Manipulate the options associated with a socket.

Definition at line 826 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKOPT_TYPE1, ENOTSUP, setsockopt(), SO_REUSEADDR, and SOL_SOCKET.

Referenced by ACE_SOCK_SEQPACK_Association::abort(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Pipe::open(), ACE_SOCK::set_option(), and setsockopt().

00831 {
00832   ACE_OS_TRACE ("ACE_OS::setsockopt");
00833 #if defined (ACE_LACKS_SETSOCKOPT)
00834   ACE_UNUSED_ARG (handle);
00835   ACE_UNUSED_ARG (level);
00836   ACE_UNUSED_ARG (optname);
00837   ACE_UNUSED_ARG (optval);
00838   ACE_UNUSED_ARG (optlen);
00839   ACE_NOTSUP_RETURN (-1);
00840 #else
00841 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT)
00842   // To work around an inconsistency with Microsofts implementation of
00843   // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock
00844   // always behaves as if SO_REUSEADDR=1. Some implementations have
00845   // the same behaviour as Winsock, but use a new name for
00846   // it. SO_REUSEPORT.  If you want the normal behaviour for
00847   // SO_REUSEADDR=0, then NT 4 sp4 and later supports
00848   // SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform
00849   // SDK so it was decided to ignore the option for now. (Especially
00850   // since Windows always sets SO_REUSEADDR=1, which we can mimic by doing
00851   // nothing.)
00852   if (level == SOL_SOCKET) {
00853     if (optname == SO_REUSEADDR) {
00854       return 0; // Not supported by Winsock
00855     }
00856     if (optname == SO_REUSEPORT) {
00857       optname = SO_REUSEADDR;
00858     }
00859   }
00860 #endif /*ACE_HAS_WINSOCK2*/
00861 
00862   int result;
00863   ACE_SOCKCALL (::setsockopt ((ACE_SOCKET) handle,
00864                               level,
00865                               optname,
00866                               (ACE_SOCKOPT_TYPE1) optval,
00867                               optlen),
00868                 int,
00869                 -1,
00870                 result);
00871 #if defined (WSAEOPNOTSUPP)
00872   if (result == -1 && errno == WSAEOPNOTSUPP)
00873 #else
00874   if (result == -1)
00875 #endif /* WSAEOPNOTSUPP */
00876     errno = ENOTSUP;
00877   return result;
00878 #endif
00879 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::shutdown ( ACE_HANDLE  handle,
int  how 
)

BSD-style <accept> (no QoS).

Definition at line 882 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and shutdown().

Referenced by ACE_SOCK_Stream::close_reader(), ACE_SOCK_SEQPACK_Association::close_reader(), ACE_SOCK_Stream::close_writer(), ACE_SOCK_SEQPACK_Association::close_writer(), and shutdown().

00883 {
00884   ACE_OS_TRACE ("ACE_OS::shutdown");
00885 #if defined (ACE_LACKS_SHUTDOWN)
00886   ACE_UNUSED_ARG (handle);
00887   ACE_UNUSED_ARG (how);
00888   ACE_NOTSUP_RETURN (-1);
00889 #else
00890   ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1);
00891 #endif /* ACE_LACKS_SHUTDOWN */
00892 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_HANDLE ACE_OS::socket ( int  protocol_family,
int  type,
int  proto 
)

Create a BSD-style socket (no QoS).

Definition at line 895 of file OS_NS_sys_socket.inl.

Referenced by ACE::get_bcast_addr(), ACE::get_handle(), getmacaddress(), ACE_SOCK::open(), ACE_SPIPE_Stream::recv_handle(), and socket().

00898 {
00899   ACE_OS_TRACE ("ACE_OS::socket");
00900 #if defined (ACE_LACKS_SOCKET)
00901   ACE_UNUSED_ARG (domain);
00902   ACE_UNUSED_ARG (type);
00903   ACE_UNUSED_ARG (proto);
00904   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00905 #else
00906   ACE_SOCKCALL_RETURN (::socket (domain,
00907                                  type,
00908                                  proto),
00909                        ACE_HANDLE,
00910                        ACE_INVALID_HANDLE);
00911 #endif /* ACE_LACKS_SOCKET */
00912 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_HANDLE ACE_OS::socket ( int  protocol_family,
int  type,
int  proto,
ACE_Protocol_Info protocolinfo,
ACE_SOCK_GROUP  g,
u_long  flags 
)

Create a QoS-enabled socket. If the OS platform doesn't support QoS-enabled <socket> then the BSD-style <socket> is called.

Definition at line 915 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and socket().

00921 {
00922   ACE_OS_TRACE ("ACE_OS::socket");
00923 
00924 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00925   ACE_SOCKCALL_RETURN (::WSASocket (domain,
00926                                     type,
00927                                     proto,
00928                                     protocolinfo,
00929                                     g,
00930                                     flags),
00931                        ACE_HANDLE,
00932                        ACE_INVALID_HANDLE);
00933 #else
00934   ACE_UNUSED_ARG (protocolinfo);
00935   ACE_UNUSED_ARG (g);
00936   ACE_UNUSED_ARG (flags);
00937 
00938   return ACE_OS::socket (domain,
00939                          type,
00940                          proto);
00941 #endif /* ACE_HAS_WINSOCK2 */
00942 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::socketpair ( int  domain,
int  type,
int  protocol,
ACE_HANDLE  sv[2] 
)

BSD-style <accept> (no QoS).

Definition at line 945 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and socketpair().

Referenced by ACE_Pipe::open(), and socketpair().

00947 {
00948   ACE_OS_TRACE ("ACE_OS::socketpair");
00949 #if defined (ACE_LACKS_SOCKETPAIR)
00950   ACE_UNUSED_ARG (domain);
00951   ACE_UNUSED_ARG (type);
00952   ACE_UNUSED_ARG (protocol);
00953   ACE_UNUSED_ARG (sv);
00954 
00955   ACE_NOTSUP_RETURN (-1);
00956 #else
00957   ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv),
00958                      int, -1);
00959 #endif /* ACE_LACKS_SOCKETPAIR */
00960 }

ACE_INLINE ACE_HANDLE ACE_OS::accept ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen 
)

BSD-style <accept> (no QoS).

Definition at line 29 of file OS_NS_sys_socket.inl.

References accept(), ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

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

ACE_INLINE int ACE_OS::bind ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int  addrlen 
)

Definition at line 98 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, bind(), and getsockname().

Referenced by ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::bind(), bind(), ACE::bind_port(), ACE_SOCK_CODgram::open(), ACE_SOCK_Connector::shared_connect_start(), ACE_SOCK_SEQPACK_Connector::shared_connect_start(), ACE_SOCK_Acceptor::shared_open(), ACE_SOCK_Dgram::shared_open(), and ACE_SOCK_SEQPACK_Acceptor::shared_open().

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

ACE_INLINE int ACE_OS::closesocket ( ACE_HANDLE  handle  ) 

Takes care of windows specific requirement to call closesocket.

Definition at line 127 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, close(), and closesocket().

Referenced by ACE_Pipe::close(), ACE_SOCK::close(), ACE_Process::close_dup_handles(), ACE_Process::close_passed_handles(), and closesocket().

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

ACE_INLINE int ACE_OS::connect ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int  addrlen 
)

BSD-style <connect> (no QoS).

Definition at line 145 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and connect().

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

ACE_INLINE int ACE_OS::enum_protocols ( int *  protocols,
ACE_Protocol_Info protocol_buffer,
u_long *  buffer_length 
)

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

Definition at line 163 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, and ACE_SOCKCALL_RETURN.

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

ACE_INLINE int ACE_OS::getpeername ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen 
)

Definition at line 184 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, AF_INET, getpeername(), and memset().

Referenced by ACE_SOCK_Connector::complete(), ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK::get_remote_addr(), ACE_SOCK_SEQPACK_Association::get_remote_addrs(), and getpeername().

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

ACE_INLINE int ACE_OS::getsockname ( ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen 
)

Definition at line 232 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, AF_INET, getsockname(), and memset().

Referenced by bind(), ACE_SOCK::get_local_addr(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), getsockname(), and ACE_SOCK_SEQPACK_Connector::shared_connect_start().

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

ACE_INLINE int ACE_OS::getsockopt ( ACE_HANDLE  handle,
int  level,
int  optname,
char *  optval,
int *  optlen 
)

Definition at line 277 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and getsockopt().

Referenced by ACE_SOCK::get_option(), getsockopt(), and ACE::handle_timed_complete().

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

ACE_INLINE int ACE_OS::listen ( ACE_HANDLE  handle,
int  backlog 
)

Definition at line 303 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and listen().

Referenced by listen(), ACE_SOCK_Acceptor::shared_open(), and ACE_SOCK_SEQPACK_Acceptor::shared_open().

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

ACE_INLINE ssize_t ACE_OS::recv ( ACE_HANDLE  handle,
char *  buf,
size_t  len,
int  flags 
)

Definition at line 316 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and recv().

Referenced by ACE::recv(), recv(), ACE_Pipe::recv(), ACE::recv_i(), ACE::recv_n_i(), and recvv().

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

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

Definition at line 363 of file OS_NS_sys_socket.inl.

References ACE_BIT_ENABLED, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, MSG_PEEK, recvfrom(), and set_errno_to_wsa_last_error().

00369 {
00370   ACE_OS_TRACE ("ACE_OS::recvfrom");
00371 #if defined (ACE_LACKS_RECVFROM)
00372   ACE_UNUSED_ARG (handle);
00373   ACE_UNUSED_ARG (buf);
00374   ACE_UNUSED_ARG (len);
00375   ACE_UNUSED_ARG (flags);
00376   ACE_UNUSED_ARG (addr);
00377   ACE_UNUSED_ARG (addrlen);
00378   ACE_NOTSUP_RETURN (-1);
00379 #elif defined (ACE_WIN32)
00380   int const shortened_len = static_cast<int> (len);
00381   int const result = ::recvfrom ((ACE_SOCKET) handle,
00382                                  buf,
00383                                  shortened_len,
00384                                  flags,
00385                                  addr,
00386                                  (ACE_SOCKET_LEN *) addrlen);
00387   if (result == SOCKET_ERROR)
00388     {
00389       ACE_OS::set_errno_to_wsa_last_error ();
00390       if (errno == WSAEMSGSIZE &&
00391           ACE_BIT_ENABLED (flags, MSG_PEEK))
00392         return shortened_len;
00393       else
00394         return -1;
00395     }
00396   else
00397     return result;
00398 #else /* non Win32 */
00399   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle,
00400                                    buf,
00401                                    len,
00402                                    flags,
00403                                    addr,
00404                                    (ACE_SOCKET_LEN *) addrlen),
00405                        ssize_t, -1);
00406 #endif /* ACE_LACKS_RECVFROM */
00407 }

ACE_INLINE 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 
)

Definition at line 410 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and set_errno_to_wsa_last_error().

00419 {
00420   ACE_OS_TRACE ("ACE_OS::recvfrom");
00421 
00422 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00423   DWORD bytes_recvd;
00424   DWORD the_flags = flags;
00425   int result = ::WSARecvFrom ((SOCKET) handle,
00426                               (WSABUF*)buffers,
00427                               buffer_count,
00428                               &bytes_recvd,
00429                               &the_flags,
00430                               addr,
00431                               addrlen,
00432                               overlapped,
00433                               func);
00434   if (result != 0) {
00435     ACE_OS::set_errno_to_wsa_last_error ();
00436   }
00437   flags = the_flags;
00438   number_of_bytes_recvd = static_cast<size_t> (bytes_recvd);
00439   return result;
00440 #else
00441   ACE_UNUSED_ARG (handle);
00442   ACE_UNUSED_ARG (buffers);
00443   ACE_UNUSED_ARG (buffer_count);
00444   ACE_UNUSED_ARG (number_of_bytes_recvd);
00445   ACE_UNUSED_ARG (flags);
00446   ACE_UNUSED_ARG (addr);
00447   ACE_UNUSED_ARG (addrlen);
00448   ACE_UNUSED_ARG (overlapped);
00449   ACE_UNUSED_ARG (func);
00450   ACE_NOTSUP_RETURN (-1);
00451 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00452 }

ACE_INLINE ssize_t ACE_OS::recvmsg ( ACE_HANDLE  handle,
struct msghdr msg,
int  flags 
)

Definition at line 455 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, recvmsg(), and set_errno_to_wsa_last_error().

Referenced by ACE::recvmsg(), and recvmsg().

00456 {
00457   ACE_OS_TRACE ("ACE_OS::recvmsg");
00458 #if !defined (ACE_LACKS_RECVMSG)
00459 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00460   DWORD bytes_received = 0;
00461 
00462   int result = ::WSARecvFrom ((SOCKET) handle,
00463                               (WSABUF *) msg->msg_iov,
00464                               msg->msg_iovlen,
00465                               &bytes_received,
00466                               (DWORD *) &flags,
00467                               msg->msg_name,
00468                               &msg->msg_namelen,
00469                               0,
00470                               0);
00471 
00472   if (result != 0)
00473     {
00474       ACE_OS::set_errno_to_wsa_last_error ();
00475       return -1;
00476     }
00477   else
00478     return bytes_received;
00479 # else /* ACE_HAS_WINSOCK2 */
00480   ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), ssize_t, -1);
00481 # endif /* ACE_HAS_WINSOCK2 */
00482 #else
00483   ACE_UNUSED_ARG (flags);
00484   ACE_UNUSED_ARG (msg);
00485   ACE_UNUSED_ARG (handle);
00486 
00487   ACE_NOTSUP_RETURN (-1);
00488 #endif /* ACE_LACKS_RECVMSG */
00489 }

ACE_INLINE ssize_t ACE_OS::recvv ( ACE_HANDLE  handle,
iovec *  buffers,
int  n 
)

Definition at line 492 of file OS_NS_sys_socket.inl.

References readv(), recv(), and set_errno_to_wsa_last_error().

Referenced by ACE::recv(), ACE_Pipe::recv(), ACE_SOCK_IO::recv(), ACE::recvv(), and ACE::recvv_n_i().

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

ACE_INLINE ssize_t ACE_OS::send ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags 
)

Definition at line 549 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and send().

Referenced by ACE::send(), send(), ACE_Pipe::send(), ACE::send_i(), ACE::send_n_i(), sendfile_emulation(), and sendv().

00550 {
00551   ACE_OS_TRACE ("ACE_OS::send");
00552 
00553   // On UNIX, a non-blocking socket with no data to receive, this
00554   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00555   // platform.  UNIX 98 allows either errno, and they may be the same
00556   // numeric value.  So to make life easier for upper ACE layers as
00557   // well as application programmers, always change EAGAIN to
00558   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00559   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00560   // this function needs to be reviewed.  On Win32, the regular macros
00561   // can be used, as this is not an issue.
00562 #if defined (ACE_LACKS_SEND)
00563   ACE_UNUSED_ARG (handle);
00564   ACE_UNUSED_ARG (buf);
00565   ACE_UNUSED_ARG (len);
00566   ACE_UNUSED_ARG (flags);
00567   ACE_NOTSUP_RETURN (-1);
00568 #elif defined (ACE_WIN32)
00569   ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle,
00570                                buf,
00571                                static_cast<int> (len),
00572                                flags), ssize_t, -1);
00573 #else
00574   ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
00575 
00576 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00577   // Optimize this code out if we can detect that EAGAIN ==
00578   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00579   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00580   // macros) perform the check at run-time.  The goal is to avoid two
00581   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00582   if (ace_result_ == -1
00583 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00584       && EAGAIN != EWOULDBLOCK
00585 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00586       && errno == EAGAIN)
00587     {
00588       errno = EWOULDBLOCK;
00589     }
00590 # endif /* EAGAIN != EWOULDBLOCK*/
00591 
00592   return ace_result_;
00593 #endif /* defined (ACE_WIN32) */
00594 }

ACE_INLINE ssize_t ACE_OS::sendmsg ( ACE_HANDLE  handle,
const struct msghdr msg,
int  flags 
)

Definition at line 597 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, sendmsg(), and set_errno_to_wsa_last_error().

Referenced by ACE::sendmsg(), and sendmsg().

00600 {
00601   ACE_OS_TRACE ("ACE_OS::sendmsg");
00602 #if !defined (ACE_LACKS_SENDMSG)
00603 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00604   DWORD bytes_sent = 0;
00605   int result = ::WSASendTo ((SOCKET) handle,
00606                             (WSABUF *) msg->msg_iov,
00607                             msg->msg_iovlen,
00608                             &bytes_sent,
00609                             flags,
00610                             msg->msg_name,
00611                             msg->msg_namelen,
00612                             0,
00613                             0);
00614 
00615   if (result != 0)
00616     {
00617       ACE_OS::set_errno_to_wsa_last_error ();
00618       return -1;
00619     }
00620   else
00621     return (ssize_t) bytes_sent;
00622 # elif defined (ACE_HAS_NONCONST_SENDMSG)
00623   ACE_SOCKCALL_RETURN (::sendmsg (handle,
00624                                   const_cast<struct msghdr *>(msg),
00625                                   flags), ssize_t, -1);
00626 # else
00627   ACE_SOCKCALL_RETURN (::sendmsg (handle, msg, flags), ssize_t, -1);
00628 # endif
00629 #else
00630   ACE_UNUSED_ARG (flags);
00631   ACE_UNUSED_ARG (msg);
00632   ACE_UNUSED_ARG (handle);
00633 
00634   ACE_NOTSUP_RETURN (-1);
00635 #endif /* ACE_LACKS_SENDMSG */
00636 }

ACE_INLINE ssize_t ACE_OS::sendto ( ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags,
const struct sockaddr *  addr,
int  addrlen 
)

Definition at line 639 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and sendto().

00645 {
00646   ACE_OS_TRACE ("ACE_OS::sendto");
00647 #if defined (ACE_LACKS_SENDTO)
00648   ACE_UNUSED_ARG (handle);
00649   ACE_UNUSED_ARG (buf);
00650   ACE_UNUSED_ARG (len);
00651   ACE_UNUSED_ARG (flags);
00652   ACE_UNUSED_ARG (addr);
00653   ACE_UNUSED_ARG (addrlen);
00654   ACE_NOTSUP_RETURN (-1);
00655 #elif defined (ACE_VXWORKS)
00656   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00657                                  const_cast <char *> (buf),
00658                                  len,
00659                                  flags,
00660                                  const_cast<struct sockaddr *> (addr),
00661                                  addrlen),
00662                        ssize_t, -1);
00663 #elif defined (ACE_WIN32)
00664   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00665                                  buf,
00666                                  static_cast<int> (len),
00667                                  flags,
00668                                  const_cast<struct sockaddr *> (addr),
00669                                  addrlen),
00670                        ssize_t, -1);
00671 #else
00672   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00673                                  buf,
00674                                  len,
00675                                  flags,
00676                                  const_cast<struct sockaddr *> (addr),
00677                                  addrlen),
00678                        ssize_t, -1);
00679 #endif /* ACE_LACKS_SENDTO */
00680 }

ACE_INLINE 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 
)

Definition at line 683 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, sendto(), and set_errno_to_wsa_last_error().

00692 {
00693   ACE_OS_TRACE ("ACE_OS::sendto");
00694 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00695   DWORD bytes_sent = 0;
00696   int result = ::WSASendTo ((SOCKET) handle,
00697                             (WSABUF*) buffers,
00698                             buffer_count,
00699                             &bytes_sent,
00700                             flags,
00701                             addr,
00702                             addrlen,
00703                             overlapped,
00704                             func);
00705   if (result != 0) {
00706     ACE_OS::set_errno_to_wsa_last_error ();
00707   }
00708   number_of_bytes_sent = static_cast<size_t> (bytes_sent);
00709   return (ssize_t) result;
00710 #else
00711   ACE_UNUSED_ARG (overlapped);
00712   ACE_UNUSED_ARG (func);
00713 
00714   number_of_bytes_sent = 0;
00715 
00716   ssize_t result = 0;
00717 
00718   for (int i = 0; i < buffer_count; ++i)
00719     {
00720        result = ACE_OS::sendto (handle,
00721                                 reinterpret_cast<char *> (
00722                                                  buffers[i].iov_base),
00723                                 buffers[i].iov_len,
00724                                 flags,
00725                                 addr,
00726                                 addrlen);
00727        if (result == -1)
00728          break;
00729        number_of_bytes_sent += static_cast<size_t> (result);
00730     }
00731 
00732   return result;
00733 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00734 }

ACE_INLINE ssize_t ACE_OS::sendv ( ACE_HANDLE  handle,
const iovec *  buffers,
int  n 
)

Definition at line 737 of file OS_NS_sys_socket.inl.

References ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE, ACE_IOV_MAX, send(), set_errno_to_wsa_last_error(), and writev().

Referenced by ACE_Pipe::recvv_n(), ACE::send(), ACE_Pipe::send(), ACE_SOCK_IO::send(), ACE::sendv(), ACE_Pipe::sendv(), and ACE::sendv_n_i().

00740 {
00741 #if defined (ACE_HAS_WINSOCK2)
00742   DWORD bytes_sent = 0;
00743   ssize_t result = 0;
00744 
00745   // Winsock 2 has WSASend and can do this directly, but Winsock 1
00746   // needs to do the sends one-by-one.
00747 # if (ACE_HAS_WINSOCK2 != 0)
00748   result = ::WSASend ((SOCKET) handle,
00749                       (WSABUF *) buffers,
00750                       n,
00751                       &bytes_sent,
00752                       0,
00753                       0,
00754                       0);
00755   if (result == SOCKET_ERROR)
00756     {
00757       ACE_OS::set_errno_to_wsa_last_error ();
00758       return -1;
00759     }
00760 # else
00761   for (int i = 0; i < n; ++i)
00762     {
00763       result = ::send ((SOCKET) handle,
00764                        buffers[i].iov_base,
00765                        buffers[i].iov_len,
00766                        0);
00767 
00768       if (result == SOCKET_ERROR)
00769         {
00770           // There is a subtle difference in behaviour depending on
00771           // whether or not any data was sent.  If no data was sent,
00772           // then always return -1.  Otherwise return bytes_sent.
00773           // This gives the caller an opportunity to keep track of
00774           // bytes that have already been sent.
00775           if (bytes_sent > 0)
00776             break;
00777           else
00778             {
00779               ACE_OS::set_errno_to_wsa_last_error ();
00780               return -1;
00781             }
00782         }
00783       else
00784         {
00785           // Gets ignored on error anyway
00786           bytes_sent += result;
00787 
00788           // If the transfer isn't complete just drop out of the loop.
00789           if (result < (int)buffers[i].iov_len)
00790             break;
00791         }
00792     }
00793 # endif /* ACE_HAS_WINSOCK2 != 0 */
00794 
00795   return (ssize_t) bytes_sent;
00796 
00797 #elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX)
00798 
00799   // Platform limits the maximum socket message size.  Pare down the
00800   // iovec, if necessary, to obey the limit.
00801   iovec local_iov[ACE_IOV_MAX];
00802   long total = 0;
00803   long new_total = 0;
00804   for (int i = 0; i < n; i++)
00805     {
00806       local_iov[i].iov_base = buffers[i].iov_base;
00807       local_iov[i].iov_len  = buffers[i].iov_len;
00808 
00809       new_total = total + buffers[i].iov_len;
00810       if (new_total >= ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE)
00811         {
00812           local_iov[i].iov_len = ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE - total;
00813           n = i+1;
00814           break;
00815         }
00816       total = new_total;
00817     }
00818   return ACE_OS::writev (handle, local_iov, n);
00819 
00820 #else
00821   return ACE_OS::writev (handle, buffers, n);
00822 #endif /* ACE_HAS_WINSOCK2 */
00823 }

ACE_INLINE int ACE_OS::setsockopt ( ACE_HANDLE  handle,
int  level,
int  optname,
const char *  optval,
int  optlen 
)

Manipulate the options associated with a socket.

Definition at line 826 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKOPT_TYPE1, ENOTSUP, setsockopt(), SO_REUSEADDR, and SOL_SOCKET.

Referenced by ACE_SOCK_SEQPACK_Association::abort(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Pipe::open(), ACE_SOCK::set_option(), and setsockopt().

00831 {
00832   ACE_OS_TRACE ("ACE_OS::setsockopt");
00833 #if defined (ACE_LACKS_SETSOCKOPT)
00834   ACE_UNUSED_ARG (handle);
00835   ACE_UNUSED_ARG (level);
00836   ACE_UNUSED_ARG (optname);
00837   ACE_UNUSED_ARG (optval);
00838   ACE_UNUSED_ARG (optlen);
00839   ACE_NOTSUP_RETURN (-1);
00840 #else
00841 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT)
00842   // To work around an inconsistency with Microsofts implementation of
00843   // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock
00844   // always behaves as if SO_REUSEADDR=1. Some implementations have
00845   // the same behaviour as Winsock, but use a new name for
00846   // it. SO_REUSEPORT.  If you want the normal behaviour for
00847   // SO_REUSEADDR=0, then NT 4 sp4 and later supports
00848   // SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform
00849   // SDK so it was decided to ignore the option for now. (Especially
00850   // since Windows always sets SO_REUSEADDR=1, which we can mimic by doing
00851   // nothing.)
00852   if (level == SOL_SOCKET) {
00853     if (optname == SO_REUSEADDR) {
00854       return 0; // Not supported by Winsock
00855     }
00856     if (optname == SO_REUSEPORT) {
00857       optname = SO_REUSEADDR;
00858     }
00859   }
00860 #endif /*ACE_HAS_WINSOCK2*/
00861 
00862   int result;
00863   ACE_SOCKCALL (::setsockopt ((ACE_SOCKET) handle,
00864                               level,
00865                               optname,
00866                               (ACE_SOCKOPT_TYPE1) optval,
00867                               optlen),
00868                 int,
00869                 -1,
00870                 result);
00871 #if defined (WSAEOPNOTSUPP)
00872   if (result == -1 && errno == WSAEOPNOTSUPP)
00873 #else
00874   if (result == -1)
00875 #endif /* WSAEOPNOTSUPP */
00876     errno = ENOTSUP;
00877   return result;
00878 #endif
00879 }

ACE_INLINE int ACE_OS::shutdown ( ACE_HANDLE  handle,
int  how 
)

Definition at line 882 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and shutdown().

Referenced by ACE_SOCK_SEQPACK_Association::close_reader(), ACE_SOCK_Stream::close_reader(), ACE_SOCK_SEQPACK_Association::close_writer(), ACE_SOCK_Stream::close_writer(), and shutdown().

00883 {
00884   ACE_OS_TRACE ("ACE_OS::shutdown");
00885 #if defined (ACE_LACKS_SHUTDOWN)
00886   ACE_UNUSED_ARG (handle);
00887   ACE_UNUSED_ARG (how);
00888   ACE_NOTSUP_RETURN (-1);
00889 #else
00890   ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1);
00891 #endif /* ACE_LACKS_SHUTDOWN */
00892 }

ACE_INLINE ACE_HANDLE ACE_OS::socket ( int  domain,
int  type,
int  proto 
)

Create a BSD-style socket (no QoS).

Definition at line 895 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and socket().

00898 {
00899   ACE_OS_TRACE ("ACE_OS::socket");
00900 #if defined (ACE_LACKS_SOCKET)
00901   ACE_UNUSED_ARG (domain);
00902   ACE_UNUSED_ARG (type);
00903   ACE_UNUSED_ARG (proto);
00904   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00905 #else
00906   ACE_SOCKCALL_RETURN (::socket (domain,
00907                                  type,
00908                                  proto),
00909                        ACE_HANDLE,
00910                        ACE_INVALID_HANDLE);
00911 #endif /* ACE_LACKS_SOCKET */
00912 }

ACE_INLINE ACE_HANDLE ACE_OS::socket ( int  protocol_family,
int  type,
int  proto,
ACE_Protocol_Info protocolinfo,
ACE_SOCK_GROUP  g,
u_long  flags 
)

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 915 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and socket().

00921 {
00922   ACE_OS_TRACE ("ACE_OS::socket");
00923 
00924 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00925   ACE_SOCKCALL_RETURN (::WSASocket (domain,
00926                                     type,
00927                                     proto,
00928                                     protocolinfo,
00929                                     g,
00930                                     flags),
00931                        ACE_HANDLE,
00932                        ACE_INVALID_HANDLE);
00933 #else
00934   ACE_UNUSED_ARG (protocolinfo);
00935   ACE_UNUSED_ARG (g);
00936   ACE_UNUSED_ARG (flags);
00937 
00938   return ACE_OS::socket (domain,
00939                          type,
00940                          proto);
00941 #endif /* ACE_HAS_WINSOCK2 */
00942 }

ACE_INLINE int ACE_OS::socketpair ( int  domain,
int  type,
int  protocol,
ACE_HANDLE  sv[2] 
)

Definition at line 945 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and socketpair().

Referenced by ACE_Pipe::open(), and socketpair().

00947 {
00948   ACE_OS_TRACE ("ACE_OS::socketpair");
00949 #if defined (ACE_LACKS_SOCKETPAIR)
00950   ACE_UNUSED_ARG (domain);
00951   ACE_UNUSED_ARG (type);
00952   ACE_UNUSED_ARG (protocol);
00953   ACE_UNUSED_ARG (sv);
00954 
00955   ACE_NOTSUP_RETURN (-1);
00956 #else
00957   ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv),
00958                      int, -1);
00959 #endif /* ACE_LACKS_SOCKETPAIR */
00960 }

ACE_INLINE ACE_HANDLE ACE_OS::creat ( const ACE_TCHAR filename,
mode_t  mode 
)

Definition at line 16 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, and open().

Referenced by ACE_SPIPE_Acceptor::create_new_instance().

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

ACE_INLINE ACE_OFF_T ACE_OS::filesize ( ACE_HANDLE  handle  ) 

Definition at line 76 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, fstat(), and set_errno_to_last_error().

Referenced by filesize(), ACE_MMAP_Memory_Pool::handle_signal(), ACE_Mem_Map::map_it(), ACE_FILE_IO::recvv(), and ACE_MMAP_Memory_Pool::remap().

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

ACE_INLINE ACE_OFF_T ACE_OS::filesize ( const ACE_TCHAR handle  ) 

Definition at line 101 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, close(), filesize(), and open().

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

ACE_INLINE int ACE_OS::fstat ( ACE_HANDLE  ,
ACE_stat  
)

Definition at line 28 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, fsync(), and set_errno_to_last_error().

Referenced by ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), filesize(), and ACE_FILE::get_info().

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

ACE_INLINE int ACE_OS::lstat ( const char *  ,
ACE_stat  
)

Definition at line 117 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, and stat().

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

ACE_INLINE int ACE_OS::mkdir ( const char *  path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS 
)

Definition at line 145 of file OS_NS_sys_stat.inl.

References ACE_ADAPT_RETVAL, and ACE_TEXT_CHAR_TO_TCHAR.

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

ACE_INLINE int ACE_OS::mkfifo ( const ACE_TCHAR file,
mode_t  mode = ACE_DEFAULT_FILE_PERMS 
)

Definition at line 181 of file OS_NS_sys_stat.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_TEXT_ALWAYS_CHAR.

Referenced by ACE_FIFO::open(), and sema_init().

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

ACE_INLINE int ACE_OS::stat ( const char *  file,
ACE_stat  
)

Definition at line 194 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_STAT_FUNC_NAME, ACE_TEXT_CHAR_TO_TCHAR, and set_errno_to_last_error().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), lstat(), ACE_Service_Gestalt::process_file(), ACE_Filecache_Object::release(), sema_init(), and ACE_Filecache_Object::update().

00195   {
00196     ACE_OS_TRACE ("ACE_OS::stat");
00197 #if defined (ACE_HAS_NONCONST_STAT)
00198     ACE_OSCALL_RETURN (::stat (const_cast <char *> (file), stp), int, -1);
00199 #elif defined (ACE_HAS_WINCE)
00200     ACE_TEXT_WIN32_FIND_DATA fdata;
00201 
00202     HANDLE fhandle;
00203 
00204     fhandle = ::FindFirstFile (ACE_TEXT_CHAR_TO_TCHAR (file), &fdata);
00205     if (fhandle == INVALID_HANDLE_VALUE)
00206       {
00207         ACE_OS::set_errno_to_last_error ();
00208         return -1;
00209       }
00210     else if (fdata.nFileSizeHigh != 0)
00211       {
00212         errno = EINVAL;
00213         return -1;
00214       }
00215     else
00216       {
00217         stp->st_mode = static_cast<unsigned short>(fdata.dwFileAttributes);
00218         stp->st_size = fdata.nFileSizeLow;
00219         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime);
00220         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime);
00221       }
00222     return 0;
00223 #elif defined (ACE_HAS_X86_STAT_MACROS)
00224     // Solaris for intel uses an macro for stat(), this macro is a
00225     // wrapper for _xstat().
00226     ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1);
00227 #else
00228     ACE_OSCALL_RETURN (ACE_STAT_FUNC_NAME (file, stp), int, -1);
00229 #endif /* ACE_HAS_NONCONST_STAT */
00230   }

ACE_INLINE mode_t ACE_OS::umask ( mode_t  cmask  ) 

Definition at line 273 of file OS_NS_sys_stat.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE::daemonize().

00274   {
00275     ACE_OS_TRACE ("ACE_OS::umask");
00276 # if defined (ACE_LACKS_UMASK)
00277     ACE_UNUSED_ARG (cmask);
00278     ACE_NOTSUP_RETURN ((mode_t)-1);
00279 # elif defined (ACE_HAS_TR24731_2005_CRT)
00280     mode_t old_mode;
00281     ACE_SECURECRTCALL (_umask_s (cmask, &old_mode), mode_t, -1, old_mode);
00282     return old_mode;
00283 # elif defined (ACE_WIN32) && !defined (__BORLANDC__)
00284     ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1);
00285 # else
00286     return ::umask (cmask); // This call shouldn't fail...
00287 # endif /* ACE_LACKS_UMASK */
00288   }

ACE_NAMESPACE_INLINE_FUNCTION ACE_Time_Value ACE_OS::gettimeofday ( void   ) 

Definition at line 25 of file OS_NS_sys_time.inl.

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

Referenced by ACE_SPIPE_Acceptor::accept(), ACE_Buffered_Svc_Handler<, >::ACE_Buffered_Svc_Handler(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::ACE_Timer_Hash_T(), ace_timezone(), ACE_TP_Token_Guard::acquire_read_token(), ACE_TP_Token_Guard::acquire_token(), ACE_High_Res_Timer::calibrate(), ACE_SPIPE_Connector::connect(), ACE_Dynamic_Message_Queue<>::dequeue_head(), ACE_Dynamic_Message_Queue<>::enqueue_i(), event_timedwait(), ACE_Utils::UUID_Generator::get_systemtime(), gethrtime(), ACE_High_Res_Timer::gettime(), gettimeofday(), ACE_High_Res_Timer::gettimeofday(), ACE_Log_Msg::log(), mutex_lock(), ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK >::open_i(), ACE_Buffered_Svc_Handler<, >::put(), ACE::Monitor_Control::Monitor_Base::receive(), ACE_Dynamic_Message_Queue<>::remove_messages(), sema_wait(), ACE_Countdown_Time::start(), ACE_Countdown_Time::stop(), ACE_Thread_Timer_Queue_Adapter< TQ >::svc(), time(), ACE::timestamp(), ACE_Date_Time::update(), ACE_Thread_Manager::wait(), and ACE_Process_Manager::wait().

00026 {
00027   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
00028 
00029 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00030   timeval tv;
00031   int result = 0;
00032 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00033 
00034 #if (0)
00035   struct timespec ts;
00036 
00037   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00038   tv.tv_sec = ts.tv_sec;
00039   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00040 
00041 #elif defined (ACE_HAS_WINCE)
00042   SYSTEMTIME tsys;
00043   FILETIME   tfile;
00044   ::GetSystemTime (&tsys);
00045   ::SystemTimeToFileTime (&tsys, &tfile);
00046   return ACE_Time_Value (tfile);
00047 #elif defined (ACE_WIN32)
00048   FILETIME   tfile;
00049   ::GetSystemTimeAsFileTime (&tfile);
00050   return ACE_Time_Value (tfile);
00051 #if 0
00052   // From Todd Montgomery...
00053   struct _timeb tb;
00054   ::_ftime (&tb);
00055   tv.tv_sec = tb.time;
00056   tv.tv_usec = 1000 * tb.millitm;
00057 #endif /* 0 */
00058 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00059   timebasestruct_t tb;
00060 
00061   ::read_real_time (&tb, TIMEBASE_SZ);
00062   ::time_base_to_time (&tb, TIMEBASE_SZ);
00063 
00064   tv.tv_sec = tb.tb_high;
00065   tv.tv_usec = tb.tb_low / 1000L;
00066 #else
00067 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00068   defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
00069   (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (SCO))
00070   ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00071 # elif defined (ACE_VXWORKS)
00072   // Assumes that struct timespec is same size as struct timeval,
00073   // which assumes that time_t is a long: it currently (VxWorks
00074   // 5.2/5.3) is.
00075   struct timespec ts;
00076 
00077   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00078   tv.tv_sec = ts.tv_sec;
00079   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00080 # else
00081   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00082 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
00083 #endif /* 0 */
00084 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00085   if (result == -1)
00086     return ACE_Time_Value ((time_t)-1);
00087   else
00088     return ACE_Time_Value (tv);
00089 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00090 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Time_Value ACE_OS::gettimeofday ( void   ) 

Definition at line 25 of file OS_NS_sys_time.inl.

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

Referenced by ACE_SPIPE_Acceptor::accept(), ACE_Buffered_Svc_Handler<, >::ACE_Buffered_Svc_Handler(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::ACE_Timer_Hash_T(), ace_timezone(), ACE_TP_Token_Guard::acquire_read_token(), ACE_TP_Token_Guard::acquire_token(), ACE_High_Res_Timer::calibrate(), ACE_SPIPE_Connector::connect(), ACE_Dynamic_Message_Queue<>::dequeue_head(), ACE_Dynamic_Message_Queue<>::enqueue_i(), event_timedwait(), ACE_Utils::UUID_Generator::get_systemtime(), gethrtime(), ACE_High_Res_Timer::gettime(), ACE_High_Res_Timer::gettimeofday(), gettimeofday(), ACE_Log_Msg::log(), mutex_lock(), ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK >::open_i(), ACE_Buffered_Svc_Handler<, >::put(), ACE::Monitor_Control::Monitor_Base::receive(), ACE_Dynamic_Message_Queue<>::remove_messages(), sema_wait(), ACE_Countdown_Time::start(), ACE_Countdown_Time::stop(), ACE_Thread_Timer_Queue_Adapter< TQ >::svc(), time(), ACE::timestamp(), ACE_Date_Time::update(), ACE_Process_Manager::wait(), and ACE_Thread_Manager::wait().

00026 {
00027   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
00028 
00029 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00030   timeval tv;
00031   int result = 0;
00032 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00033 
00034 #if (0)
00035   struct timespec ts;
00036 
00037   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00038   tv.tv_sec = ts.tv_sec;
00039   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00040 
00041 #elif defined (ACE_HAS_WINCE)
00042   SYSTEMTIME tsys;
00043   FILETIME   tfile;
00044   ::GetSystemTime (&tsys);
00045   ::SystemTimeToFileTime (&tsys, &tfile);
00046   return ACE_Time_Value (tfile);
00047 #elif defined (ACE_WIN32)
00048   FILETIME   tfile;
00049   ::GetSystemTimeAsFileTime (&tfile);
00050   return ACE_Time_Value (tfile);
00051 #if 0
00052   // From Todd Montgomery...
00053   struct _timeb tb;
00054   ::_ftime (&tb);
00055   tv.tv_sec = tb.time;
00056   tv.tv_usec = 1000 * tb.millitm;
00057 #endif /* 0 */
00058 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00059   timebasestruct_t tb;
00060 
00061   ::read_real_time (&tb, TIMEBASE_SZ);
00062   ::time_base_to_time (&tb, TIMEBASE_SZ);
00063 
00064   tv.tv_sec = tb.tb_high;
00065   tv.tv_usec = tb.tb_low / 1000L;
00066 #else
00067 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00068   defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
00069   (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (SCO))
00070   ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00071 # elif defined (ACE_VXWORKS)
00072   // Assumes that struct timespec is same size as struct timeval,
00073   // which assumes that time_t is a long: it currently (VxWorks
00074   // 5.2/5.3) is.
00075   struct timespec ts;
00076 
00077   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00078   tv.tv_sec = ts.tv_sec;
00079   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00080 # else
00081   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00082 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
00083 #endif /* 0 */
00084 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00085   if (result == -1)
00086     return ACE_Time_Value ((time_t)-1);
00087   else
00088     return ACE_Time_Value (tv);
00089 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00090 }

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

Definition at line 10 of file OS_NS_sys_uio.inl.

References ACE_OS_TRACE, and readv().

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

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

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::writev ( ACE_HANDLE  handle,
const iovec *  iov,
int  iovcnt 
)

Definition at line 33 of file OS_NS_sys_uio.inl.

References ACE_OS_TRACE, and writev().

Referenced by ACE_SPIPE_Stream::send(), ACE_Pipe::send(), ACE_FILE_IO::send(), ACE_FIFO_Send_Msg::send(), ACE_DEV_IO::send(), ACE_SPIPE_Stream::sendv(), ACE_Pipe::sendv(), sendv(), ACE_FILE_IO::sendv(), writev(), and ACE::writev_n().

00036 {
00037   ACE_OS_TRACE ("ACE_OS::writev");
00038 #if defined (ACE_LACKS_WRITEV)
00039   ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle,
00040                                                iov,
00041                                                iovcnt), ssize_t, -1);
00042 #else /* ACE_LACKS_WRITEV */
00043 #if defined (ACE_HAS_NONCONST_WRITEV)
00044   ACE_OSCALL_RETURN (::writev (handle,
00045                                const_cast<iovec *>(iov),
00046                                iovcnt), ssize_t, -1);
00047 #else
00048   ACE_OSCALL_RETURN (::writev (handle,
00049                                iov,
00050                                iovcnt), ssize_t, -1);
00051 #endif /* ACE_HAS_NONCONST_WRITEV */
00052 #endif /* ACE_LACKS_WRITEV */
00053 }

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

Definition at line 10 of file OS_NS_sys_uio.inl.

References ACE_OS_TRACE, and readv().

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

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

ACE_INLINE ssize_t ACE_OS::writev ( ACE_HANDLE  handle,
const iovec *  iov,
int  iovcnt 
)

Definition at line 33 of file OS_NS_sys_uio.inl.

References ACE_OS_TRACE, and writev().

Referenced by ACE_DEV_IO::send(), ACE_FIFO_Send_Msg::send(), ACE_FILE_IO::send(), ACE_Pipe::send(), ACE_SPIPE_Stream::send(), ACE_FILE_IO::sendv(), sendv(), ACE_Pipe::sendv(), ACE_SPIPE_Stream::sendv(), writev(), and ACE::writev_n().

00036 {
00037   ACE_OS_TRACE ("ACE_OS::writev");
00038 #if defined (ACE_LACKS_WRITEV)
00039   ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle,
00040                                                iov,
00041                                                iovcnt), ssize_t, -1);
00042 #else /* ACE_LACKS_WRITEV */
00043 #if defined (ACE_HAS_NONCONST_WRITEV)
00044   ACE_OSCALL_RETURN (::writev (handle,
00045                                const_cast<iovec *>(iov),
00046                                iovcnt), ssize_t, -1);
00047 #else
00048   ACE_OSCALL_RETURN (::writev (handle,
00049                                iov,
00050                                iovcnt), ssize_t, -1);
00051 #endif /* ACE_HAS_NONCONST_WRITEV */
00052 #endif /* ACE_LACKS_WRITEV */
00053 }

ACE_Export int ACE_OS::uname ( ACE_utsname name  ) 

Definition at line 21 of file OS_NS_sys_utsname.cpp.

References ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, hostname(), sprintf(), strcat(), and strcpy().

Referenced by hostname(), and sema_init().

00022 {
00023   ACE_OS_TRACE ("ACE_OS::uname");
00024 #if !defined (ACE_LACKS_UNAME)
00025   ACE_OSCALL_RETURN (::uname (name), int, -1);
00026 #elif defined (ACE_WIN32)
00027   size_t maxnamelen = sizeof name->nodename;
00028   ACE_OS::strcpy (name->sysname, "Win32");
00029 
00030   ACE_TEXT_OSVERSIONINFO vinfo;
00031   vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO);
00032   ACE_TEXT_GetVersionEx (&vinfo);
00033 
00034   SYSTEM_INFO sinfo;
00035 #   if defined (ACE_HAS_PHARLAP)
00036   // PharLap doesn't do GetSystemInfo.  What's really wanted is the
00037   // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
00038   // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
00039   // that the CPU type values in EK_KERNELINFO have the same values
00040   // are the ones defined for SYSTEM_INFO.
00041   EK_KERNELINFO ets_kern;
00042   EK_SYSTEMINFO ets_sys;
00043   EtsGetSystemInfo (&ets_kern, &ets_sys);
00044   sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType);
00045   sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
00046   sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
00047 #   else
00048   ::GetSystemInfo(&sinfo);
00049 #   endif /* ACE_HAS_PHARLAP */
00050 
00051   const char* unknown = "???";
00052 
00053   if (
00054       vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
00055 #   if defined (VER_PLATFORM_WIN32_CE)
00056       || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
00057 #   endif
00058       )
00059     {
00060       // Get information from the two structures
00061       const char *os;
00062       if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
00063         os = "Windows NT %d.%d";
00064       else
00065         os = "Windows CE %d.%d";
00066       ACE_OS::sprintf (name->release,
00067                        os,
00068                        (int) vinfo.dwMajorVersion,
00069                        (int) vinfo.dwMinorVersion);
00070       ACE_OS::sprintf (name->version,
00071                        "Build %d %s",
00072                        (int) vinfo.dwBuildNumber,
00073                        ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
00074 
00075       // We have to make sure that the size of (processor + subtype)
00076       // is not greater than the size of name->machine.  So we give
00077       // half the space to the processor and half the space to
00078       // subtype.  The -1 is necessary for because of the space
00079       // between processor and subtype in the machine name.
00080       const int bufsize = (sizeof (name->machine) / 2) - 1;
00081       char processor[bufsize] = "Unknown";
00082       char subtype[bufsize] = "Unknown";
00083 
00084 #   if defined (ghs)
00085     WORD arch = sinfo.u.s.wProcessorArchitecture;
00086 #   else
00087     WORD arch = sinfo.wProcessorArchitecture;
00088 #   endif
00089 
00090       switch (arch)
00091         {
00092         case PROCESSOR_ARCHITECTURE_INTEL:
00093           ACE_OS::strcpy (processor, "Intel");
00094           if (sinfo.wProcessorLevel == 3)
00095             ACE_OS::strcpy (subtype, "80386");
00096           else if (sinfo.wProcessorLevel == 4)
00097             ACE_OS::strcpy (subtype, "80486");
00098           else if (sinfo.wProcessorLevel == 5)
00099             ACE_OS::strcpy (subtype, "Pentium");
00100           else if (sinfo.wProcessorLevel == 6)
00101             ACE_OS::strcpy (subtype, "Pentium Pro");
00102           else if (sinfo.wProcessorLevel == 7)  // I'm guessing here
00103             ACE_OS::strcpy (subtype, "Pentium II");
00104           break;
00105         case PROCESSOR_ARCHITECTURE_MIPS:
00106           ACE_OS::strcpy (processor, "MIPS");
00107           ACE_OS::strcpy (subtype, "R4000");
00108           break;
00109         case PROCESSOR_ARCHITECTURE_ALPHA:
00110           ACE_OS::strcpy (processor, "Alpha");
00111           ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
00112           break;
00113         case PROCESSOR_ARCHITECTURE_PPC:
00114           ACE_OS::strcpy (processor, "PPC");
00115           if (sinfo.wProcessorLevel == 1)
00116             ACE_OS::strcpy (subtype, "601");
00117           else if (sinfo.wProcessorLevel == 3)
00118             ACE_OS::strcpy (subtype, "603");
00119           else if (sinfo.wProcessorLevel == 4)
00120             ACE_OS::strcpy (subtype, "604");
00121           else if (sinfo.wProcessorLevel == 6)
00122             ACE_OS::strcpy (subtype, "603+");
00123           else if (sinfo.wProcessorLevel == 9)
00124             ACE_OS::strcpy (subtype, "804+");
00125           else if (sinfo.wProcessorLevel == 20)
00126             ACE_OS::strcpy (subtype, "620");
00127           break;
00128 #     if defined PROCESSOR_ARCHITECTURE_IA64
00129         case PROCESSOR_ARCHITECTURE_IA64:
00130           ACE_OS::strcpy (processor, "Itanium");
00131           ACE_OS::sprintf (subtype, "%d",
00132                            sinfo.wProcessorLevel);
00133           break;
00134 #     endif
00135 #     if defined PROCESSOR_ARCHITECTURE_AMD64
00136         case PROCESSOR_ARCHITECTURE_AMD64:
00137           ACE_OS::strcpy (processor, "x64");
00138           ACE_OS::sprintf (subtype, "%d",
00139                            sinfo.wProcessorLevel);
00140           break;
00141 #     endif
00142 #     if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
00143         case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
00144           ACE_OS::strcpy (processor, "WOW64");
00145           ACE_OS::sprintf (subtype, "%d",
00146                            sinfo.wProcessorLevel);
00147           break;
00148 #     endif
00149 #     if defined PROCESSOR_ARCHITECTURE_ARM
00150         case PROCESSOR_ARCHITECTURE_ARM:
00151           ACE_OS::strcpy (processor, "ARM");
00152           ACE_OS::sprintf (subtype, "%d",
00153                            sinfo.wProcessorLevel);
00154           break;
00155 #     endif
00156         case PROCESSOR_ARCHITECTURE_UNKNOWN:
00157         default:
00158           // @@ We could provide WinCE specific info here.  But let's
00159           //    defer that to some later point.
00160           ACE_OS::strcpy (processor, "Unknown");
00161           break;
00162         }
00163       ACE_OS::sprintf (name->machine,
00164                        "%s %s",
00165                        processor, subtype);
00166     }
00167   else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00168     {
00169       if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
00170         {
00171           ACE_OS::strcpy (name->release, "Windows 95");
00172           if (vinfo.szCSDVersion[1] == ACE_TEXT('C'))
00173             ACE_OS::strcat (name->release, " OSR2");
00174         }
00175       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
00176         {
00177           ACE_OS::strcpy (name->release, "Windows 98");
00178           if (vinfo.szCSDVersion[1] == ACE_TEXT('A'))
00179             ACE_OS::strcat (name->release, " SE");
00180         }
00181       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
00182         {
00183           ACE_OS::strcpy (name->release, "Windows Me");
00184         }
00185       else
00186         {
00187           ACE_OS::strcpy (name->release, unknown);
00188         }
00189 
00190       ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber));
00191       if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
00192         ACE_OS::strcpy (name->machine, "Intel 80386");
00193       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
00194         ACE_OS::strcpy (name->machine, "Intel 80486");
00195       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
00196         ACE_OS::strcpy (name->machine, "Intel Pentium");
00197       else
00198         ACE_OS::strcpy (name->machine, unknown);
00199     }
00200   else
00201     {
00202       // We don't know what this is!
00203 
00204       ACE_OS::strcpy (name->release, unknown);
00205       ACE_OS::strcpy (name->version, unknown);
00206       ACE_OS::strcpy (name->machine, unknown);
00207     }
00208 
00209 # if defined (ACE_LACKS_HOSTNAME)
00210   return 0;
00211 # else /* ACE_LACKS_HOSTNAME */
00212   return ACE_OS::hostname (name->nodename, maxnamelen);
00213 # endif /* ACE_LACKS_HOSTNAME */
00214 
00215 #elif defined (ACE_VXWORKS)
00216   size_t maxnamelen = sizeof name->nodename;
00217   ACE_OS::strcpy (name->sysname, "VxWorks");
00218   ACE_OS::strcpy (name->release, kernelVersion());
00219   ACE_OS::strcpy (name->version, sysBspRev ());
00220   ACE_OS::strcpy (name->machine, sysModel ());
00221 
00222   return ACE_OS::hostname (name->nodename, maxnamelen);
00223 #elif defined (INTEGRITY)
00224   if(!name) {
00225     errno = EFAULT;
00226     return -1;
00227   }
00228   strcpy(name->sysname,"INTEGRITY");
00229   int status = gethostname(name->nodename,_SYS_NMLN);
00230   strcpy(name->release,"4.0");
00231   strcpy(name->version,"4.0.9");
00232   strcpy(name->machine,"a standard name");
00233   return status;
00234 #endif /* ACE_WIN32 */
00235 }

ACE_NAMESPACE_INLINE_FUNCTION pid_t ACE_OS::wait ( int *  = 0  ) 

Calls OS wait function, so it's only portable to UNIX/POSIX platforms.

Definition at line 11 of file OS_NS_sys_wait.inl.

Referenced by ACE_Process::wait(), and wait().

00012 {
00013   ACE_OS_TRACE ("ACE_OS::wait");
00014 #if defined (ACE_LACKS_WAIT)
00015   ACE_UNUSED_ARG (status);
00016   ACE_NOTSUP_RETURN (0);
00017 #else
00018   ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
00019 #endif /* ACE_LACKS_WAIT */
00020 }

ACE_NAMESPACE_INLINE_FUNCTION 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 93 of file OS_NS_sys_wait.inl.

References ACE_OS_TRACE, and waitpid().

00097 {
00098   ACE_OS_TRACE ("ACE_OS::wait");
00099   return ACE_OS::waitpid (pid,
00100                           status,
00101                           wait_options,
00102                           handle);
00103 }

ACE_NAMESPACE_INLINE_FUNCTION 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 23 of file OS_NS_sys_wait.inl.

References ACE_BIT_ENABLED, ACE_NOTSUP_RETURN, ACE_OS_TRACE, set_errno_to_last_error(), waitpid(), and WNOHANG.

Referenced by ACE::fork(), ACE_Process_Manager::wait(), ACE_Process::wait(), wait(), and waitpid().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::waitpid");
00029 #if defined (ACE_LACKS_WAITPID)
00030   ACE_UNUSED_ARG (pid);
00031   ACE_UNUSED_ARG (status);
00032   ACE_UNUSED_ARG (wait_options);
00033   ACE_UNUSED_ARG (handle);
00034 
00035   ACE_NOTSUP_RETURN (0);
00036 #elif defined (ACE_WIN32)
00037   int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
00038     ? 0 /* don't hang */
00039     : INFINITE;
00040 
00041   ACE_HANDLE phandle = handle;
00042 
00043   if (phandle == 0)
00044     {
00045       phandle = ::OpenProcess (SYNCHRONIZE,
00046                                FALSE,
00047                                pid);
00048 
00049       if (phandle == 0)
00050         {
00051           ACE_OS::set_errno_to_last_error ();
00052           return -1;
00053         }
00054     }
00055 
00056   pid_t result = pid;
00057 
00058   // Don't try to get the process exit status if wait failed so we can
00059   // keep the original error code intact.
00060   switch (::WaitForSingleObject (phandle,
00061                                  blocking_period))
00062     {
00063     case WAIT_OBJECT_0:
00064       if (status != 0)
00065         // The error status of <GetExitCodeProcess> is nonetheless
00066         // not tested because we don't know how to return the value.
00067         ::GetExitCodeProcess (phandle,
00068                               status);
00069       break;
00070     case WAIT_TIMEOUT:
00071       errno = ETIME;
00072       result = 0;
00073       break;
00074     default:
00075       ACE_OS::set_errno_to_last_error ();
00076       result = -1;
00077     }
00078   if (handle == 0)
00079     ::CloseHandle (phandle);
00080   return result;
00081 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00082   ACE_UNUSED_ARG (handle);
00083   ACE_OSCALL_RETURN (::spt_waitpid (pid, status, wait_options),
00084                      pid_t, -1);
00085 #else
00086   ACE_UNUSED_ARG (handle);
00087   ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
00088                      pid_t, -1);
00089 #endif /* ACE_LACKS_WAITPID */
00090 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE pid_t ACE_OS::wait ( int *  = 0  ) 

Calls OS wait function, so it's only portable to UNIX/POSIX platforms.

Definition at line 11 of file OS_NS_sys_wait.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and wait().

00012 {
00013   ACE_OS_TRACE ("ACE_OS::wait");
00014 #if defined (ACE_LACKS_WAIT)
00015   ACE_UNUSED_ARG (status);
00016   ACE_NOTSUP_RETURN (0);
00017 #else
00018   ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
00019 #endif /* ACE_LACKS_WAIT */
00020 }

ACE_INLINE 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 23 of file OS_NS_sys_wait.inl.

References ACE_BIT_ENABLED, ACE_NOTSUP_RETURN, ACE_OS_TRACE, set_errno_to_last_error(), waitpid(), and WNOHANG.

Referenced by ACE::fork(), wait(), ACE_Process::wait(), ACE_Process_Manager::wait(), and waitpid().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::waitpid");
00029 #if defined (ACE_LACKS_WAITPID)
00030   ACE_UNUSED_ARG (pid);
00031   ACE_UNUSED_ARG (status);
00032   ACE_UNUSED_ARG (wait_options);
00033   ACE_UNUSED_ARG (handle);
00034 
00035   ACE_NOTSUP_RETURN (0);
00036 #elif defined (ACE_WIN32)
00037   int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
00038     ? 0 /* don't hang */
00039     : INFINITE;
00040 
00041   ACE_HANDLE phandle = handle;
00042 
00043   if (phandle == 0)
00044     {
00045       phandle = ::OpenProcess (SYNCHRONIZE,
00046                                FALSE,
00047                                pid);
00048 
00049       if (phandle == 0)
00050         {
00051           ACE_OS::set_errno_to_last_error ();
00052           return -1;
00053         }
00054     }
00055 
00056   pid_t result = pid;
00057 
00058   // Don't try to get the process exit status if wait failed so we can
00059   // keep the original error code intact.
00060   switch (::WaitForSingleObject (phandle,
00061                                  blocking_period))
00062     {
00063     case WAIT_OBJECT_0:
00064       if (status != 0)
00065         // The error status of <GetExitCodeProcess> is nonetheless
00066         // not tested because we don't know how to return the value.
00067         ::GetExitCodeProcess (phandle,
00068                               status);
00069       break;
00070     case WAIT_TIMEOUT:
00071       errno = ETIME;
00072       result = 0;
00073       break;
00074     default:
00075       ACE_OS::set_errno_to_last_error ();
00076       result = -1;
00077     }
00078   if (handle == 0)
00079     ::CloseHandle (phandle);
00080   return result;
00081 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00082   ACE_UNUSED_ARG (handle);
00083   ACE_OSCALL_RETURN (::spt_waitpid (pid, status, wait_options),
00084                      pid_t, -1);
00085 #else
00086   ACE_UNUSED_ARG (handle);
00087   ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
00088                      pid_t, -1);
00089 #endif /* ACE_LACKS_WAITPID */
00090 }

ACE_INLINE 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 93 of file OS_NS_sys_wait.inl.

References ACE_OS_TRACE, and waitpid().

00097 {
00098   ACE_OS_TRACE ("ACE_OS::wait");
00099   return ACE_OS::waitpid (pid,
00100                           status,
00101                           wait_options,
00102                           handle);
00103 }

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

References ACE_Base_Thread_Adapter::close_log_msg().

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

01101 {
01102 #if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
01103   { // scope the cleanup instance
01104     // Call TSS destructors for current thread.
01105     TSS_Cleanup_Instance cleanup;
01106     if (cleanup.valid ())
01107       {
01108         cleanup->thread_exit ();
01109       }
01110   }
01111 #endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */
01112 
01113   if (main_thread)
01114     {
01115 #if !defined (ACE_HAS_TSS_EMULATION)  &&  !defined (ACE_HAS_MINIMAL_ACE_OS)
01116       // Just close the ACE_Log_Msg for the current (which should be
01117       // main) thread.  We don't have TSS emulation; if there's native
01118       // TSS, it should call its destructors when the main thread
01119       // exits.
01120       ACE_Base_Thread_Adapter::close_log_msg ();
01121 #endif /* ! ACE_HAS_TSS_EMULATION  &&  ! ACE_HAS_MINIMAL_ACE_OS */
01122 
01123 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
01124       // Finally, free up the ACE_TSS_Cleanup instance.  This method gets
01125       // called by the ACE_Object_Manager.
01126       TSS_Cleanup_Instance cleanup(TSS_Cleanup_Instance::DESTROY);
01127       if (cleanup.valid ())
01128       {
01129         ; // the pointer deletes the Cleanup when it goes out of scope
01130       }
01131 
01132 #endif /* WIN32 || ACE_HAS_TSS_EMULATION */
01133 
01134 #if defined (ACE_HAS_TSS_EMULATION)
01135       ACE_TSS_Emulation::tss_close ();
01136 #endif /* ACE_HAS_TSS_EMULATION */
01137     }
01138 }

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

Definition at line 1757 of file OS_NS_Thread.cpp.

References condattr_destroy(), and condattr_init().

Referenced by cond_init(), event_init(), recursive_mutex_init(), rwlock_init(), and sema_init().

01758 {
01759   ACE_condattr_t attributes;
01760   if (ACE_OS::condattr_init (attributes, type) == 0
01761       && ACE_OS::cond_init (cv, attributes, name, arg) == 0)
01762     {
01763       (void) ACE_OS::condattr_destroy (attributes);
01764       return 0;
01765     }
01766   return -1;
01767 }

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

Definition at line 1779 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, memset(), set_errno_to_last_error(), thread_mutex_init(), USYNC_PROCESS, and USYNC_THREAD.

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), rwlock_init(), sema_init(), and thread_mutex_init().

01785 {
01786   // ACE_OS_TRACE ("ACE_OS::mutex_init");
01787 #if defined (ACE_HAS_THREADS)
01788 # if defined (ACE_HAS_PTHREADS)
01789   ACE_UNUSED_ARG (name);
01790   ACE_UNUSED_ARG (sa);
01791 
01792 # if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
01793   /* Tests show that VxWorks 6.x pthread lib does not only
01794    * require zeroing of mutex/condition objects to function correctly
01795    * but also of the attribute objects.
01796    */
01797   pthread_mutexattr_t l_attributes = {0};
01798 # else
01799   pthread_mutexattr_t l_attributes;
01800 # endif
01801 
01802   if (attributes == 0)
01803     attributes = &l_attributes;
01804   int result = 0;
01805   int attr_init = 0;  // have we initialized the local attributes.
01806 
01807   // Only do these initializations if the <attributes> parameter
01808   // wasn't originally set.
01809   if (attributes == &l_attributes)
01810   {
01811       if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0)
01812         {
01813           result = 0;
01814           attr_init = 1; // we have initialized these attributes
01815         }
01816       else
01817         {
01818           result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01819         }
01820   }
01821 
01822   if (result == 0 && lock_scope != 0)
01823 {
01824 #     if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01825       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes,
01826                                                                lock_scope),
01827                                result);
01828 #     endif /* _POSIX_THREAD_PROCESS_SHARED && !ACE_LACKS_MUTEXATTR_PSHARED */
01829 }
01830 
01831   if (result == 0 && lock_type != 0)
01832 {
01833 #   if defined (ACE_HAS_RECURSIVE_MUTEXES)
01834       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes,
01835                                                             lock_type),
01836                                result);
01837 #   endif /* ACE_HAS_RECURSIVE_MUTEXES */
01838 }
01839 
01840   if (result == 0)
01841 {
01842 #   if defined (ACE_VXWORKS)&& (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
01843       /* VxWorks 6.x API reference states:
01844        * If the memory for the mutex variable object has been allocated
01845        *   dynamically, it is a good policy to always zero out the
01846        *   block of memory so as to avoid spurious EBUSY return code
01847        *   when calling this routine.
01848        * Tests shows this to be necessary.
01849        */
01850       ACE_OS::memset (m, 0, sizeof (*m));
01851 #   endif
01852       if (ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0)
01853         result = 0;
01854       else
01855         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01856 }
01857 
01858   // Only do the deletions if the <attributes> parameter wasn't
01859   // originally set.
01860   if (attributes == &l_attributes && attr_init)
01861     ::pthread_mutexattr_destroy (&l_attributes);
01862 
01863   return result;
01864 # elif defined (ACE_HAS_STHREADS)
01865   ACE_UNUSED_ARG (name);
01866   ACE_UNUSED_ARG (sa);
01867   ACE_UNUSED_ARG (lock_type);
01868   int result;
01869   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m,
01870                      lock_scope,
01871                      attributes),
01872   result),
01873   int, -1);
01874 # elif defined (ACE_HAS_WTHREADS)
01875   m->type_ = lock_scope;
01876 
01877   SECURITY_ATTRIBUTES sa_buffer;
01878   SECURITY_DESCRIPTOR sd_buffer;
01879   switch (lock_scope)
01880 {
01881   case USYNC_PROCESS:
01882 #   if defined (ACE_HAS_WINCE)
01883       // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
01884       m->proc_mutex_ =
01885   ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
01886                           (sa, &sa_buffer, &sd_buffer),
01887                         FALSE,
01888                         ACE_Ascii_To_Wide (name).wchar_rep ());
01889 #   else /* ACE_HAS_WINCE */
01890       m->proc_mutex_ =
01891   ::CreateMutexA (ACE_OS::default_win32_security_attributes_r
01892                           (sa, &sa_buffer, &sd_buffer),
01893                         FALSE,
01894                         name);
01895 #   endif /* ACE_HAS_WINCE */
01896       if (m->proc_mutex_ == 0)
01897         ACE_FAIL_RETURN (-1);
01898       else
01899       {
01900           // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01901         ACE_OS::set_errno_to_last_error ();
01902         return 0;
01903       }
01904   case USYNC_THREAD:
01905     return ACE_OS::thread_mutex_init (&m->thr_mutex_,
01906                                        lock_type,
01907                                        name,
01908                                        attributes);
01909   default:
01910     errno = EINVAL;
01911     return -1;
01912 }
01913   /* NOTREACHED */
01914 
01915 # elif defined (ACE_VXWORKS)
01916   ACE_UNUSED_ARG (name);
01917   ACE_UNUSED_ARG (attributes);
01918   ACE_UNUSED_ARG (sa);
01919   ACE_UNUSED_ARG (lock_type);
01920 
01921   return (*m = ::semMCreate (lock_scope)) == 0 ? -1 : 0;
01922 # endif /* ACE_HAS_PTHREADS */
01923 #else
01924   ACE_UNUSED_ARG (m);
01925   ACE_UNUSED_ARG (lock_scope);
01926   ACE_UNUSED_ARG (name);
01927   ACE_UNUSED_ARG (attributes);
01928   ACE_UNUSED_ARG (sa);
01929   ACE_UNUSED_ARG (lock_type);
01930   ACE_NOTSUP_RETURN (-1);
01931 #endif /* ACE_HAS_THREADS */
01932 }

ACE_Export int ACE_OS::mutex_destroy ( ACE_mutex_t m  ) 

Definition at line 1935 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, thread_mutex_destroy(), USYNC_PROCESS, and USYNC_THREAD.

Referenced by event_destroy(), ACE_Mutex::remove(), rwlock_destroy(), rwlock_init(), sema_destroy(), sema_init(), and thread_mutex_destroy().

01936 {
01937   ACE_OS_TRACE ("ACE_OS::mutex_destroy");
01938 #if defined (ACE_HAS_THREADS)
01939 # if defined (ACE_HAS_PTHREADS)
01940   int result;
01941   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
01942                      result), int, -1);
01943 # elif defined (ACE_HAS_STHREADS)
01944   int result;
01945   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1);
01946 # elif defined (ACE_HAS_WTHREADS)
01947   switch (m->type_)
01948 {
01949   case USYNC_PROCESS:
01950     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
01951                           ace_result_),
01952     int, -1);
01953   case USYNC_THREAD:
01954     return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
01955   default:
01956     errno = EINVAL;
01957     return -1;
01958 }
01959   /* NOTREACHED */
01960 # elif defined (ACE_VXWORKS)
01961   return ::semDelete (*m) == OK ? 0 : -1;
01962 # endif /* Threads variety case */
01963 #else
01964   ACE_UNUSED_ARG (m);
01965   ACE_NOTSUP_RETURN (-1);
01966 #endif /* ACE_HAS_THREADS */
01967 }

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

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, set_errno_to_last_error(), thread_mutex_lock(), USYNC_PROCESS, and USYNC_THREAD.

Referenced by ACE_Mutex::acquire(), ACE_Mutex::acquire_read(), ACE_Mutex::acquire_write(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), mutex_lock(), rw_rdlock(), rw_tryrdlock(), rw_trywrlock(), rw_trywrlock_upgrade(), rw_unlock(), rw_wrlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_lock().

02016 {
02017   // ACE_OS_TRACE ("ACE_OS::mutex_lock");
02018 #if defined (ACE_HAS_THREADS)
02019 # if defined (ACE_HAS_PTHREADS)
02020   // Note, don't use "::" here since the following call is often a macro.
02021   int result;
02022   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), result),
02023                      int, -1);
02024 # elif defined (ACE_HAS_STHREADS)
02025   int result;
02026   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), result), int, -1);
02027 # elif defined (ACE_HAS_WTHREADS)
02028   switch (m->type_)
02029 {
02030   case USYNC_PROCESS:
02031     switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02032       {
02033         //
02034         // Timeout can't occur, so don't bother checking...
02035         //
02036       case WAIT_OBJECT_0:
02037       case WAIT_ABANDONED:
02038         // We will ignore abandonments in this method
02039         // Note that we still hold the lock
02040         return 0;
02041       default:
02042         // This is a hack, we need to find an appropriate mapping...
02043         ACE_OS::set_errno_to_last_error ();
02044         return -1;
02045       }
02046   case USYNC_THREAD:
02047     return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02048   default:
02049     errno = EINVAL;
02050     return -1;
02051 }
02052   /* NOTREACHED */
02053 # elif defined (ACE_VXWORKS)
02054   return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1;
02055 # endif /* Threads variety case */
02056 #else
02057   ACE_UNUSED_ARG (m);
02058   ACE_NOTSUP_RETURN (-1);
02059 #endif /* ACE_HAS_THREADS */
02060 }

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

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, set_errno_to_last_error(), thread_mutex_lock(), USYNC_PROCESS, and USYNC_THREAD.

02065 {
02066   ACE_OS_TRACE ("ACE_OS::mutex_lock");
02067 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02068   abandoned = 0;
02069   switch (m->type_)
02070   {
02071     case USYNC_PROCESS:
02072       switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02073       {
02074         //
02075           // Timeout can't occur, so don't bother checking...
02076         //
02077         case WAIT_OBJECT_0:
02078           return 0;
02079         case WAIT_ABANDONED:
02080           abandoned = 1;
02081           return 0;  // something goofed, but we hold the lock ...
02082         default:
02083           // This is a hack, we need to find an appropriate mapping...
02084           ACE_OS::set_errno_to_last_error ();
02085           return -1;
02086       }
02087     case USYNC_THREAD:
02088       return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02089     default:
02090       errno = EINVAL;
02091       return -1;
02092   }
02093   /* NOTREACHED */
02094 #else
02095   ACE_UNUSED_ARG (m);
02096   ACE_UNUSED_ARG (abandoned);
02097   ACE_NOTSUP_RETURN (-1);
02098 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02099 }

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

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, EBUSY, gettimeofday(), ACE_Time_Value::msec(), ACE_Time_Value::sec(), set_errno_to_last_error(), ACE_Time_Value::usec(), USYNC_PROCESS, and USYNC_THREAD.

02104 {
02105 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS)
02106 
02107 #  if defined (ACE_HAS_PTHREADS)
02108   int result;
02109 
02110   // "timeout" should be an absolute time.
02111 
02112   timespec_t ts = timeout;  // Calls ACE_Time_Value::operator timespec_t().
02113 
02114   // Note that the mutex should not be a recursive one, i.e., it
02115   // should only be a standard mutex or an error checking mutex.
02116 
02117   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result);
02118 
02119   // We need to adjust this to make the errno values consistent.
02120   if (result == -1 && errno == ETIMEDOUT)
02121     errno = ETIME;
02122   return result;
02123 
02124 #  elif defined (ACE_HAS_WTHREADS)
02125   // Note that we must convert between absolute time (which is passed
02126   // as a parameter) and relative time (which is what the system call
02127   // expects).
02128   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
02129 
02130   switch (m->type_)
02131   {
02132     case USYNC_PROCESS:
02133       switch (::WaitForSingleObject (m->proc_mutex_,
02134                 relative_time.msec ()))
02135       {
02136         case WAIT_OBJECT_0:
02137         case WAIT_ABANDONED:
02138           // We will ignore abandonments in this method
02139           // Note that we still hold the lock
02140           return 0;
02141         case WAIT_TIMEOUT:
02142           errno = ETIME;
02143           return -1;
02144         default:
02145           // This is a hack, we need to find an appropriate mapping...
02146           ACE_OS::set_errno_to_last_error ();
02147           return -1;
02148       }
02149     case USYNC_THREAD:
02150       ACE_NOTSUP_RETURN (-1);
02151     default:
02152       errno = EINVAL;
02153       return -1;
02154   }
02155   /* NOTREACHED */
02156 
02157 #  elif defined (ACE_VXWORKS)
02158 
02159   // Note that we must convert between absolute time (which is passed
02160   // as a parameter) and relative time (which is what the system call
02161   // expects).
02162   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
02163 
02164   int ticks_per_sec = ::sysClkRateGet ();
02165 
02166   int ticks = relative_time.sec() * ticks_per_sec +
02167       relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02168   if (::semTake (*m, ticks) == ERROR)
02169   {
02170     if (errno == S_objLib_OBJ_TIMEOUT)
02171         // Convert the VxWorks errno to one that's common for to ACE
02172         // platforms.
02173       errno = ETIME;
02174     else if (errno == S_objLib_OBJ_UNAVAILABLE)
02175       errno = EBUSY;
02176     return -1;
02177   }
02178   else
02179     return 0;
02180 #  endif /* ACE_HAS_PTHREADS */
02181 
02182 #else
02183   ACE_UNUSED_ARG (m);
02184   ACE_UNUSED_ARG (timeout);
02185   ACE_NOTSUP_RETURN (-1);
02186 #endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */
02187 }

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

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, set_errno_to_last_error(), thread_mutex_trylock(), USYNC_PROCESS, and USYNC_THREAD.

Referenced by thread_mutex_trylock(), ACE_Mutex::tryacquire(), ACE_Mutex::tryacquire_read(), and ACE_Mutex::tryacquire_write().

02191 {
02192   ACE_OS_TRACE ("ACE_OS::mutex_trylock");
02193 #if defined (ACE_HAS_THREADS)
02194 # if defined (ACE_HAS_PTHREADS)
02195   // Note, don't use "::" here since the following call is often a macro.
02196   int result;
02197   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), result),
02198                      int, -1);
02199 # elif defined (ACE_HAS_STHREADS)
02200   int result;
02201   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), result), int, -1);
02202 # elif defined (ACE_HAS_WTHREADS)
02203   switch (m->type_)
02204 {
02205   case USYNC_PROCESS:
02206   {
02207         // Try for 0 milliseconds - i.e. nonblocking.
02208     switch (::WaitForSingleObject (m->proc_mutex_, 0))
02209     {
02210       case WAIT_OBJECT_0:
02211         return 0;
02212       case WAIT_ABANDONED:
02213             // We will ignore abandonments in this method.  Note that
02214             // we still hold the lock.
02215         return 0;
02216       case WAIT_TIMEOUT:
02217         errno = EBUSY;
02218         return -1;
02219       default:
02220         ACE_OS::set_errno_to_last_error ();
02221         return -1;
02222     }
02223   }
02224   case USYNC_THREAD:
02225     return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
02226   default:
02227     errno = EINVAL;
02228     return -1;
02229 }
02230   /* NOTREACHED */
02231 # elif defined (ACE_VXWORKS)
02232   if (::semTake (*m, NO_WAIT) == ERROR)
02233     if (errno == S_objLib_OBJ_UNAVAILABLE)
02234 {
02235         // couldn't get the semaphore
02236   errno = EBUSY;
02237   return -1;
02238 }
02239     else
02240       // error
02241       return -1;
02242     else
02243     // got the semaphore
02244       return 0;
02245 # endif /* Threads variety case */
02246 #else
02247   ACE_UNUSED_ARG (m);
02248   ACE_NOTSUP_RETURN (-1);
02249 #endif /* ACE_HAS_THREADS */
02250 }

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

References ACE_NOTSUP_RETURN, EBUSY, set_errno_to_last_error(), thread_mutex_trylock(), USYNC_PROCESS, and USYNC_THREAD.

02254 {
02255 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02256   abandoned = 0;
02257   switch (m->type_)
02258   {
02259     case USYNC_PROCESS:
02260     {
02261         // Try for 0 milliseconds - i.e. nonblocking.
02262       switch (::WaitForSingleObject (m->proc_mutex_, 0))
02263       {
02264         case WAIT_OBJECT_0:
02265           return 0;
02266         case WAIT_ABANDONED:
02267           abandoned = 1;
02268           return 0;  // something goofed, but we hold the lock ...
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 #else
02285   ACE_UNUSED_ARG (m);
02286   ACE_UNUSED_ARG (abandoned);
02287   ACE_NOTSUP_RETURN (-1);
02288 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02289 }

ACE_Export int ACE_OS::mutex_unlock ( ACE_mutex_t m  ) 

Definition at line 2292 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, thread_mutex_unlock(), USYNC_PROCESS, and USYNC_THREAD.

Referenced by event_reset(), event_signal(), event_timedwait(), event_wait(), mutex_lock_cleanup(), ACE_Mutex::release(), rw_rdlock(), rw_tryrdlock(), rw_trywrlock(), rw_trywrlock_upgrade(), rw_unlock(), rw_wrlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_unlock().

02293 {
02294   ACE_OS_TRACE ("ACE_OS::mutex_unlock");
02295 #if defined (ACE_HAS_THREADS)
02296 # if defined (ACE_HAS_PTHREADS)
02297   // Note, don't use "::" here since the following call is often a macro.
02298   int result;
02299   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), result),
02300                      int, -1);
02301 # elif defined (ACE_HAS_STHREADS)
02302   int result;
02303   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), result), int, -1);
02304 # elif defined (ACE_HAS_WTHREADS)
02305   switch (m->type_)
02306 {
02307   case USYNC_PROCESS:
02308     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_),
02309                           ace_result_),
02310     int, -1);
02311   case USYNC_THREAD:
02312     return ACE_OS::thread_mutex_unlock (&m->thr_mutex_);
02313   default:
02314     errno = EINVAL;
02315     return -1;
02316 }
02317   /* NOTREACHED */
02318 # elif defined (ACE_VXWORKS)
02319   return ::semGive (*m) == OK ? 0 : -1;
02320 # endif /* Threads variety case */
02321 #else
02322   ACE_UNUSED_ARG (m);
02323   ACE_NOTSUP_RETURN (-1);
02324 #endif /* ACE_HAS_THREADS */
02325 }

ACE_Export void ACE_OS::mutex_lock_cleanup ( void *  mutex  ) 

Handle asynchronous thread cancellation cleanup.

Definition at line 2328 of file OS_NS_Thread.cpp.

References ACE_OS_TRACE, and mutex_unlock().

02329 {
02330   ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup");
02331 #if defined (ACE_HAS_THREADS)
02332 # if defined (ACE_HAS_PTHREADS)
02333   ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex;
02334   ACE_OS::mutex_unlock (p_lock);
02335 # else
02336   ACE_UNUSED_ARG (mutex);
02337 # endif /* ACE_HAS_PTHREADS */
02338 #else
02339   ACE_UNUSED_ARG (mutex);
02340 #endif /* ACE_HAS_THREADS */
02341 }

ACE_Export int ACE_OS::event_destroy ( ACE_event_t event  ) 

Definition at line 2352 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, cond_broadcast(), cond_destroy(), EBUSY, free(), munmap(), mutex_destroy(), sema_destroy(), shm_unlink(), thr_yield(), and USYNC_PROCESS.

Referenced by ACE_Event::remove(), sema_destroy(), and sema_init().

02353 {
02354 #if defined (ACE_WIN32)
02355   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
02356 #elif defined (ACE_HAS_THREADS)
02357   if (event->eventdata_)
02358     {
02359       // mutex_destroy()/cond_destroy() are called in a loop if the object
02360       // is BUSY.  This avoids conditions where we fail to destroy these
02361       // objects because at time of destroy they were just being used in
02362       // another thread possibly causing deadlocks later on if they keep
02363       // being used after we're gone.
02364 
02365       if (event->eventdata_->type_ == USYNC_PROCESS)
02366         {
02367           if (event->name_)
02368             {
02369               // Only destroy the event data if we're the ones who initialized
02370               // it.
02371 
02372               int r1, r2;
02373 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02374         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02375      (!defined (ACE_USES_FIFO_SEM) && \
02376         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02377               // First destroy the mutex so locking after this will return
02378               // errors.
02379               while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02380                      && errno == EBUSY)
02381                 {
02382                   ACE_OS::thr_yield ();
02383                 }
02384 # else
02385               r1 = ACE_OS::sema_destroy(&event->lock_);
02386 # endif
02387 
02388 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02389     (!defined (ACE_USES_FIFO_SEM) && \
02390       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02391               // Now fix event to manual reset, raise signal and broadcast
02392               // until is's possible to destroy the condition.
02393               event->eventdata_->manual_reset_ = 1;
02394               while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02395                      && errno == EBUSY)
02396                 {
02397                   event->eventdata_->is_signaled_ = 1;
02398                   ACE_OS::cond_broadcast (&event->eventdata_->condition_);
02399                   ACE_OS::thr_yield ();
02400                 }
02401 # else
02402               r2 = ACE_OS::sema_destroy(&event->semaphore_);
02403 # endif
02404               ACE_OS::munmap (event->eventdata_,
02405                               sizeof (ACE_eventdata_t));
02406               ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_));
02407               ACE_OS::free (event->name_);
02408               return r1 != 0 || r2 != 0 ? -1 : 0;
02409             }
02410           else
02411             {
02412               ACE_OS::munmap (event->eventdata_,
02413                               sizeof (ACE_eventdata_t));
02414 # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
02415         (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
02416      (defined (ACE_USES_FIFO_SEM) || \
02417         (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
02418               ACE_OS::sema_destroy(&event->lock_);
02419 # endif
02420 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02421     (!defined (ACE_USES_FIFO_SEM) && \
02422       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02423               return 0;
02424 # else
02425               return ACE_OS::sema_destroy(&event->semaphore_);
02426 # endif
02427             }
02428         }
02429       else
02430         {
02431           int r1, r2;
02432           // First destroy the mutex so locking after this will return errors.
02433 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02434         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02435      (!defined (ACE_USES_FIFO_SEM) && \
02436         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02437       // first destroy the mutex so locking after this will return errors
02438           while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02439                  && errno == EBUSY)
02440             {
02441               ACE_OS::thr_yield ();
02442             }
02443 # else
02444           r1 = ACE_OS::sema_destroy(&event->lock_);
02445 # endif
02446 
02447 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02448     (!defined (ACE_USES_FIFO_SEM) && \
02449       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02450           // Now fix event to manual reset, raise signal and broadcast until
02451           // it's possible to destroy the condition.
02452           event->eventdata_->manual_reset_ = 1;
02453           while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02454                  && errno == EBUSY)
02455             {
02456               event->eventdata_->is_signaled_ = 1;
02457               ACE_OS::cond_broadcast (&event->eventdata_->condition_);
02458               ACE_OS::thr_yield ();
02459             }
02460 # else
02461           r2 = ACE_OS::sema_destroy(&event->semaphore_);
02462 # endif
02463           delete event->eventdata_;
02464           return r1 != 0 || r2 != 0 ? -1 : 0;
02465         }
02466     }
02467 
02468   return 0;
02469 #else
02470   ACE_UNUSED_ARG (event);
02471   ACE_NOTSUP_RETURN (-1);
02472 #endif /* ACE_WIN32 */
02473 }

ACE_Export 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 
)

Definition at line 2476 of file OS_NS_Thread.cpp.

References ACE_DEFAULT_FILE_PERMS, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, close(), cond_init(), ftruncate(), MAP_FAILED, MAXPATHLEN, mmap(), mutex_init(), PROT_RDWR, sema_init(), sema_post(), shm_open(), shm_unlink(), strcat(), strdup(), strncpy(), strsncpy(), ACE_eventdata_t::type_, and USYNC_PROCESS.

Referenced by ACE_Event::ACE_Event(), and sema_init().

02483 {
02484 #if defined (ACE_WIN32)
02485   ACE_UNUSED_ARG (type);
02486   ACE_UNUSED_ARG (arg);
02487   SECURITY_ATTRIBUTES sa_buffer;
02488   SECURITY_DESCRIPTOR sd_buffer;
02489 # if defined (ACE_HAS_WINCE)
02490   // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
02491   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
02492                              (sa, &sa_buffer, &sd_buffer),
02493                            manual_reset,
02494                            initial_state,
02495                            ACE_Ascii_To_Wide (name).wchar_rep ());
02496 # else /* ACE_HAS_WINCE */
02497   *event = ::CreateEventA (ACE_OS::default_win32_security_attributes_r
02498                              (sa, &sa_buffer, &sd_buffer),
02499                            manual_reset,
02500                            initial_state,
02501                            name);
02502 # endif /* ACE_HAS_WINCE */
02503   if (*event == 0)
02504     ACE_FAIL_RETURN (-1);
02505   else
02506     return 0;
02507 #elif defined (ACE_HAS_THREADS)
02508   ACE_UNUSED_ARG (sa);
02509   event->eventdata_ = 0;
02510   ACE_eventdata_t* evtdata;
02511 
02512   if (type == USYNC_PROCESS)
02513     {
02514       const char *name_p = 0;
02515 #  if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH)
02516       char adj_name[MAXPATHLEN];
02517       if (name[0] != '/')
02518         {
02519           adj_name[0] = '/';
02520           ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1);
02521           name_p = adj_name;
02522         }
02523       else
02524         {
02525           name_p = name;
02526         }
02527 #  else
02528       name_p = name;
02529 #  endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */
02530       int owner = 0;
02531       // Let's see if the shared memory entity already exists.
02532       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
02533                                         O_RDWR | O_CREAT | O_EXCL,
02534                                         ACE_DEFAULT_FILE_PERMS);
02535       if (fd == ACE_INVALID_HANDLE)
02536         {
02537           if (errno == EEXIST)
02538             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
02539                                    O_RDWR | O_CREAT,
02540                                    ACE_DEFAULT_FILE_PERMS);
02541           if (fd == ACE_INVALID_HANDLE)   // Still can't get it.
02542             return -1;
02543         }
02544       else
02545         {
02546           // We own this shared memory object!  Let's set its size.
02547           if (ACE_OS::ftruncate (fd, sizeof (ACE_eventdata_t)) == -1)
02548             {
02549               ACE_OS::close (fd);
02550               return -1;
02551             }
02552           owner = 1;
02553         }
02554 
02555       evtdata =
02556         (ACE_eventdata_t *) ACE_OS::mmap (0,
02557                                           sizeof (ACE_eventdata_t),
02558                                           PROT_RDWR,
02559                                           MAP_SHARED,
02560                                           fd,
02561                                           0);
02562       ACE_OS::close (fd);
02563       if (evtdata == MAP_FAILED)
02564         {
02565           if (owner)
02566             ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02567           return -1;
02568         }
02569 
02570       if (owner)
02571         {
02572           event->name_ = ACE_OS::strdup (name_p);
02573           if (event->name_ == 0)
02574             {
02575               ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02576               return -1;
02577             }
02578           event->eventdata_ = evtdata;
02579           event->eventdata_->type_ = type;
02580           event->eventdata_->manual_reset_ = manual_reset;
02581           event->eventdata_->is_signaled_ = initial_state;
02582           event->eventdata_->auto_event_signaled_ = false;
02583           event->eventdata_->waiting_threads_ = 0;
02584           event->eventdata_->signal_count_ = 0;
02585 
02586 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02587     (!defined (ACE_USES_FIFO_SEM) && \
02588       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02589           int result = ACE_OS::cond_init (&event->eventdata_->condition_,
02590                                           static_cast<short> (type),
02591                                           name,
02592                                           arg);
02593 # else
02594           char   sem_name[128];
02595           ACE_OS::strncpy (sem_name,
02596                            name,
02597                            sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
02598           ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
02599           int result = ACE_OS::sema_init (&event->semaphore_,
02600                                           0,
02601                                           type,
02602                                           sem_name,
02603                                           arg);
02604 # endif
02605           if (result == 0)
02606 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02607         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02608      (!defined (ACE_USES_FIFO_SEM) && \
02609         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02610             result = ACE_OS::mutex_init (&event->eventdata_->lock_,
02611                                          type,
02612                                          name,
02613                                          (ACE_mutexattr_t *) arg);
02614 # else
02615           {
02616             char   lck_name[128];
02617             ACE_OS::strncpy
02618               (lck_name,
02619                name,
02620                sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
02621             ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
02622             result = ACE_OS::sema_init (&event->lock_,
02623                                         0,
02624                                         type,
02625                                         lck_name,
02626                                         arg);
02627             if (result == 0)
02628               result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */
02629           }
02630 # endif
02631           return result;
02632         }
02633       else
02634         {
02635           int result = 0;
02636 
02637           event->name_ = 0;
02638           event->eventdata_ = evtdata;
02639 #if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \
02640   (defined (ACE_USES_FIFO_SEM) || \
02641     (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM)))
02642           char   sem_name[128];
02643           ACE_OS::strncpy (sem_name,
02644                            name,
02645                            sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
02646           ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
02647           result = ACE_OS::sema_init(&event->semaphore_,
02648                                      0,
02649                                      type,
02650                                      sem_name,
02651                                      arg);
02652 # endif
02653 
02654 # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
02655         (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
02656      (defined (ACE_USES_FIFO_SEM) || \
02657         (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
02658           if (result == 0)
02659             {
02660               char   lck_name[128];
02661               ACE_OS::strncpy
02662                 (lck_name,
02663                  name,
02664                  sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
02665               ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
02666               result = ACE_OS::sema_init (&event->lock_,
02667                                           0,
02668                                           type,
02669                                           lck_name,
02670                                           arg);
02671             }
02672 # endif
02673           return result;
02674         }
02675     }
02676   else
02677     {
02678       ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1);
02679       event->name_ = 0;
02680       event->eventdata_ = evtdata;
02681       event->eventdata_->type_ = type;
02682       event->eventdata_->manual_reset_ = manual_reset;
02683       event->eventdata_->is_signaled_ = initial_state;
02684       event->eventdata_->auto_event_signaled_ = false;
02685       event->eventdata_->waiting_threads_ = 0;
02686       event->eventdata_->signal_count_ = 0;
02687 
02688 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02689     (!defined (ACE_USES_FIFO_SEM) && \
02690       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02691       int result = ACE_OS::cond_init (&event->eventdata_->condition_,
02692                                       static_cast<short> (type),
02693                                       name,
02694                                       arg);
02695 # else
02696       int result = ACE_OS::sema_init (&event->semaphore_,
02697                                       0,
02698                                       type,
02699                                       name,
02700                                       arg);
02701 # endif
02702       if (result == 0)
02703 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02704         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02705      (!defined (ACE_USES_FIFO_SEM) && \
02706         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02707         result = ACE_OS::mutex_init (&event->eventdata_->lock_,
02708                                      type,
02709                                      name,
02710                                      (ACE_mutexattr_t *) arg);
02711 # else
02712       result = ACE_OS::sema_init (&event->lock_,
02713                                   0,
02714                                   type,
02715                                   name,
02716                                   arg);
02717       if (result == 0)
02718         result = ACE_OS::sema_post(&event->lock_);    /* initially unlock */
02719 # endif
02720 
02721       return result;
02722     }
02723 #else
02724   ACE_UNUSED_ARG (event);
02725   ACE_UNUSED_ARG (manual_reset);
02726   ACE_UNUSED_ARG (initial_state);
02727   ACE_UNUSED_ARG (type);
02728   ACE_UNUSED_ARG (name);
02729   ACE_UNUSED_ARG (arg);
02730   ACE_UNUSED_ARG (sa);
02731   ACE_NOTSUP_RETURN (-1);
02732 #endif /* ACE_WIN32 */
02733 }

ACE_Export int ACE_OS::event_pulse ( ACE_event_t event  ) 

Definition at line 2736 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, cond_broadcast(), cond_signal(), mutex_lock(), sema_wait(), and thr_yield().

Referenced by ACE_Event::pulse().

02737 {
02738 #if defined (ACE_WIN32)
02739   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
02740 #elif defined (ACE_HAS_THREADS)
02741   int result = 0;
02742   int error = 0;
02743 
02744   // grab the lock first
02745 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02746         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02747      (!defined (ACE_USES_FIFO_SEM) && \
02748         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02749   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02750 # else
02751   if (ACE_OS::sema_wait (&event->lock_) == 0)
02752 # endif
02753   {
02754     if (event->eventdata_->waiting_threads_ > 0)
02755     {
02756       // Manual-reset event.
02757       if (event->eventdata_->manual_reset_ == 1)
02758       {
02759         // Wakeup all waiters.
02760 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02761     (!defined (ACE_USES_FIFO_SEM) && \
02762       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02763         if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02764         {
02765           result = -1;
02766           error = errno;
02767         }
02768         if (result == 0)
02769           event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
02770 # else
02771         event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
02772         for (unsigned long i=0; i<event->eventdata_->signal_count_ ;++i)
02773           if (ACE_OS::sema_post(&event->semaphore_) != 0)
02774           {
02775             event->eventdata_->signal_count_ = 0;
02776             result = -1;
02777             error = errno;
02778           }
02779 
02780         if (result == 0)
02781           while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0)
02782             ACE_OS::thr_yield ();
02783 # endif
02784       }
02785       // Auto-reset event: wakeup one waiter.
02786       else
02787       {
02788 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02789     (!defined (ACE_USES_FIFO_SEM) && \
02790       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02791         if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
02792 # else
02793         if (ACE_OS::sema_post(&event->semaphore_) != 0)
02794 # endif
02795         {
02796           result = -1;
02797           error = errno;
02798         }
02799 
02800         event->eventdata_->auto_event_signaled_ = true;
02801       }
02802     }
02803 
02804     // Reset event.
02805     event->eventdata_->is_signaled_ = 0;
02806 
02807     // Now we can let go of the lock.
02808 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02809         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02810      (!defined (ACE_USES_FIFO_SEM) && \
02811         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02812     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02813 # else
02814     ACE_OS::sema_post (&event->lock_);
02815 # endif
02816     if (result == -1)
02817       // Reset errno in case mutex_unlock() also fails...
02818       errno = error;
02819   }
02820   else
02821     result = -1;
02822   return result;
02823 #else
02824   ACE_UNUSED_ARG (event);
02825   ACE_NOTSUP_RETURN (-1);
02826 #endif /* ACE_WIN32 */
02827 }

ACE_Export int ACE_OS::event_reset ( ACE_event_t event  ) 

Definition at line 2830 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, mutex_lock(), mutex_unlock(), sema_post(), and sema_wait().

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

02831 {
02832 #if defined (ACE_WIN32)
02833   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
02834 #elif defined (ACE_HAS_THREADS)
02835   int result = 0;
02836 
02837   // Grab the lock first.
02838 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02839         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02840      (!defined (ACE_USES_FIFO_SEM) && \
02841         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02842   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02843 # else
02844   if (ACE_OS::sema_wait (&event->lock_) == 0)
02845 # endif
02846   {
02847     // Reset event.
02848     event->eventdata_->is_signaled_ = 0;
02849     event->eventdata_->auto_event_signaled_ = false;
02850 
02851     // Now we can let go of the lock.
02852 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02853         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02854      (!defined (ACE_USES_FIFO_SEM) && \
02855         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02856     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02857 # else
02858     ACE_OS::sema_post (&event->lock_);
02859 # endif
02860   }
02861   else
02862     result = -1;
02863   return result;
02864 #else
02865   ACE_UNUSED_ARG (event);
02866   ACE_NOTSUP_RETURN (-1);
02867 #endif /* ACE_WIN32 */
02868 }

ACE_Export int ACE_OS::event_signal ( ACE_event_t event  ) 

Definition at line 2871 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), sema_post(), and sema_wait().

Referenced by sema_post(), and ACE_Event::signal().

02872 {
02873 #if defined (ACE_WIN32)
02874   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
02875 #elif defined (ACE_HAS_THREADS)
02876   int result = 0;
02877   int error = 0;
02878 
02879   // grab the lock first
02880 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02881         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02882      (!defined (ACE_USES_FIFO_SEM) && \
02883         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02884   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02885 # else
02886   if (ACE_OS::sema_wait (&event->lock_) == 0)
02887 # endif
02888   {
02889     // Manual-reset event.
02890     if (event->eventdata_->manual_reset_ == 1)
02891     {
02892       // wakeup all
02893 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02894     (!defined (ACE_USES_FIFO_SEM) && \
02895       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02896       if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02897       {
02898         result = -1;
02899         error = errno;
02900       }
02901 # else
02902       if (ACE_OS::sema_post(&event->semaphore_) != 0)
02903       {
02904         result = -1;
02905         error = errno;
02906       }
02907 # endif
02908 
02909       if (result == 0)
02910         // signal event
02911         event->eventdata_->is_signaled_ = 1;
02912     }
02913     // Auto-reset event
02914     else
02915     {
02916       if (event->eventdata_->waiting_threads_ == 0)
02917         // No waiters: signal event.
02918         event->eventdata_->is_signaled_ = 1;
02919       // Waiters: wakeup one waiter.
02920 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02921     (!defined (ACE_USES_FIFO_SEM) && \
02922       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02923       else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
02924 # else
02925       else if (ACE_OS::sema_post(&event->semaphore_) != 0)
02926 # endif
02927       {
02928         result = -1;
02929         error = errno;
02930       }
02931 
02932       event->eventdata_->auto_event_signaled_ = true;
02933     }
02934 
02935     // Now we can let go of the lock.
02936 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02937         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02938      (!defined (ACE_USES_FIFO_SEM) && \
02939         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02940     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02941 # else
02942     ACE_OS::sema_post (&event->lock_);
02943 # endif
02944 
02945     if (result == -1)
02946       // Reset errno in case mutex_unlock() also fails...
02947       errno = error;
02948   }
02949   else
02950     result = -1;
02951 
02952   return result;
02953 #else
02954   ACE_UNUSED_ARG (event);
02955   ACE_NOTSUP_RETURN (-1);
02956 #endif /* ACE_WIN32 */
02957 }

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

Definition at line 2960 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, cond_timedwait(), event_wait(), gettimeofday(), ACE_Time_Value::msec(), mutex_lock(), mutex_unlock(), ACE_Time_Value::sec(), sema_post(), sema_wait(), set_errno_to_last_error(), ACE_Time_Value::usec(), and ACE_Time_Value::zero.

Referenced by ACE_Event::wait().

02963 {
02964   if (timeout == 0)
02965     // Wait indefinitely.
02966     return ACE_OS::event_wait (event);
02967 
02968 #if defined (ACE_WIN32)
02969   DWORD result;
02970 
02971   if (timeout->sec () == 0 && timeout->usec () == 0)
02972     // Do a "poll".
02973     result = ::WaitForSingleObject (*event, 0);
02974   else
02975     {
02976       // Wait for upto <relative_time> number of milliseconds.  Note
02977       // that we must convert between absolute time (which is passed
02978       // as a parameter) and relative time (which is what
02979       // WaitForSingleObjects() expects).
02980       // <timeout> parameter is given in absolute or relative value
02981       // depending on parameter <use_absolute_time>.
02982       int msec_timeout;
02983       if (use_absolute_time)
02984         {
02985           // Time is given in absolute time, we should use
02986           // gettimeofday() to calculate relative time
02987           ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
02988 
02989           // Watchout for situations where a context switch has caused
02990           // the current time to be > the timeout.  Thanks to Norbert
02991           // Rapp <NRapp@nexus-informatics.de> for pointing this.
02992           if (relative_time < ACE_Time_Value::zero)
02993             msec_timeout = 0;
02994           else
02995             msec_timeout = relative_time.msec ();
02996         }
02997       else
02998         // time is given in relative time, just convert it into
02999         // milliseconds and use it
03000         msec_timeout = timeout->msec ();
03001       result = ::WaitForSingleObject (*event, msec_timeout);
03002     }
03003 
03004   switch (result)
03005     {
03006     case WAIT_OBJECT_0:
03007       return 0;
03008     case WAIT_TIMEOUT:
03009       errno = ETIME;
03010       return -1;
03011     default:
03012       // This is a hack, we need to find an appropriate mapping...
03013       ACE_OS::set_errno_to_last_error ();
03014       return -1;
03015     }
03016 #elif defined (ACE_HAS_THREADS)
03017   int result = 0;
03018   int error = 0;
03019 
03020   // grab the lock first
03021 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03022         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03023      (!defined (ACE_USES_FIFO_SEM) && \
03024         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03025   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
03026 # else
03027   if (ACE_OS::sema_wait (&event->lock_) == 0)
03028 # endif
03029     {
03030       if (event->eventdata_->is_signaled_ == 1)
03031         // event is currently signaled
03032         {
03033           if (event->eventdata_->manual_reset_ == 0)
03034             {
03035               // AUTO: reset state
03036               event->eventdata_->is_signaled_ = 0;
03037               event->eventdata_->auto_event_signaled_ = false;
03038             }
03039         }
03040       else
03041         // event is currently not signaled
03042         {
03043           event->eventdata_->waiting_threads_++;
03044 
03045           ACE_Time_Value absolute_timeout = *timeout;
03046 
03047           // cond_timewait() expects absolute time, check
03048           // <use_absolute_time> flag.
03049           if (use_absolute_time == 0)
03050             absolute_timeout += ACE_OS::gettimeofday ();
03051 
03052           while (event->eventdata_->is_signaled_ == 0 &&
03053                  event->eventdata_->auto_event_signaled_ == false)
03054             {
03055 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03056     (!defined (ACE_USES_FIFO_SEM) && \
03057       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03058               if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
03059                                           &event->eventdata_->lock_,
03060                                           &absolute_timeout) != 0)
03061                 {
03062                   result = -1;
03063                   error = errno;
03064                   break;
03065                 }
03066 
03067               if (event->eventdata_->signal_count_ > 0)
03068                 {
03069                   event->eventdata_->signal_count_--;
03070                   break;
03071                 }
03072 # else
03073 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03074       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03075               if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
03076 #   else
03077                 if (ACE_OS::sema_post (&event->lock_) != 0)
03078 #   endif
03079                   {
03080                     event->eventdata_->waiting_threads_--;
03081                     return -1;
03082                   }
03083 
03084               if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0)
03085                 {
03086                   result = -1;
03087                   if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX)
03088                     error = ETIME;
03089                   else
03090                     error = errno;
03091                 }
03092 
03093               bool signalled = false;
03094               if (result == 0 && event->eventdata_->signal_count_ > 0)
03095                 {
03096                   event->eventdata_->signal_count_--;
03097                   signalled = true;
03098                 }
03099 
03100 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03101       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03102               if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
03103 #   else
03104                 if (ACE_OS::sema_wait (&event->lock_) != 0)
03105 #   endif
03106                   {
03107                     event->eventdata_->waiting_threads_--;  // yes, I know it's not save
03108                     return -1;
03109                   }
03110 
03111               if (result)
03112                 break;
03113 
03114               if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
03115                 if (ACE_OS::sema_post(&event->semaphore_) != 0)
03116                   {
03117                     result = -1;
03118                     error = errno;
03119                     break;
03120                   }
03121 
03122               if (signalled)
03123                 break;
03124 # endif
03125             }
03126 
03127           // Reset the auto_event_signaled_ to false now that we have
03128           // woken up.
03129           if (event->eventdata_->auto_event_signaled_ == true)
03130             event->eventdata_->auto_event_signaled_ = false;
03131 
03132           event->eventdata_->waiting_threads_--;
03133         }
03134 
03135       // Now we can let go of the lock.
03136 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03137         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03138      (!defined (ACE_USES_FIFO_SEM) && \
03139         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03140       ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03141 # else
03142       ACE_OS::sema_post (&event->lock_);
03143 # endif
03144 
03145       if (result == -1)
03146         // Reset errno in case mutex_unlock() also fails...
03147         errno = error;
03148     }
03149   else
03150     result = -1;
03151   return result;
03152 #else
03153   ACE_UNUSED_ARG (event);
03154   ACE_UNUSED_ARG (timeout);
03155   ACE_UNUSED_ARG (use_absolute_time);
03156   ACE_NOTSUP_RETURN (-1);
03157 #endif /* ACE_WIN32 */
03158 }

ACE_Export int ACE_OS::event_wait ( ACE_event_t event  ) 

Definition at line 3161 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, cond_wait(), mutex_lock(), mutex_unlock(), sema_post(), sema_wait(), and set_errno_to_last_error().

Referenced by event_timedwait(), and ACE_Event::wait().

03162 {
03163 #if defined (ACE_WIN32)
03164   switch (::WaitForSingleObject (*event, INFINITE))
03165     {
03166     case WAIT_OBJECT_0:
03167       return 0;
03168     default:
03169       {
03170         ACE_OS::set_errno_to_last_error ();
03171         return -1;
03172       }
03173     }
03174 #elif defined (ACE_HAS_THREADS)
03175   int result = 0;
03176   int error = 0;
03177 
03178   // grab the lock first
03179 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03180         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03181      (!defined (ACE_USES_FIFO_SEM) && \
03182         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03183   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
03184 # else
03185   if (ACE_OS::sema_wait (&event->lock_) == 0)
03186 # endif
03187     {
03188       if (event->eventdata_->is_signaled_ == 1)
03189         // Event is currently signaled.
03190         {
03191           if (event->eventdata_->manual_reset_ == 0)
03192             // AUTO: reset state
03193             event->eventdata_->is_signaled_ = 0;
03194         }
03195       else // event is currently not signaled
03196         {
03197           event->eventdata_->waiting_threads_++;
03198 
03199           while (event->eventdata_->is_signaled_ == 0 &&
03200                  event->eventdata_->auto_event_signaled_ == false)
03201             {
03202 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03203     (!defined (ACE_USES_FIFO_SEM) && \
03204       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03205               if (ACE_OS::cond_wait (&event->eventdata_->condition_,
03206                                      &event->eventdata_->lock_) != 0)
03207                 {
03208                   result = -1;
03209                   error = errno;
03210                   // Something went wrong...
03211                   break;
03212                 }
03213               if (event->eventdata_->signal_count_ > 0)
03214                 {
03215                   event->eventdata_->signal_count_--;
03216                   break;
03217                 }
03218 # else
03219 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03220       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03221               if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
03222 #   else
03223                 if (ACE_OS::sema_post (&event->lock_) != 0)
03224 #   endif
03225                   {
03226                     event->eventdata_->waiting_threads_--;
03227                     return -1;
03228                   }
03229 
03230               if (ACE_OS::sema_wait (&event->semaphore_) !=0)
03231                 {
03232                   result = -1;
03233                   error = errno;
03234                 }
03235 
03236               bool signalled = false;
03237               if (result == 0 && event->eventdata_->signal_count_ > 0)
03238                 {
03239                   event->eventdata_->signal_count_--;
03240                   signalled = true;
03241                 }
03242 
03243 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03244       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03245               if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
03246 #   else
03247                 if (ACE_OS::sema_wait (&event->lock_) != 0)
03248 #   endif
03249                   {
03250                     event->eventdata_->waiting_threads_--;
03251                     return -1;
03252                   }
03253 
03254               if (result)
03255                 break;
03256 
03257               if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
03258                 if (ACE_OS::sema_post(&event->semaphore_) != 0)
03259                   {
03260                     result = -1;
03261                     error = errno;
03262                     break;
03263                   }
03264 
03265               if (signalled)
03266                 break;
03267 # endif
03268             }
03269 
03270           // Reset it since we have woken up.
03271           if (event->eventdata_->auto_event_signaled_ == true)
03272             event->eventdata_->auto_event_signaled_ = false;
03273 
03274           event->eventdata_->waiting_threads_--;
03275         }
03276 
03277       // Now we can let go of the lock.
03278 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03279         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03280      (!defined (ACE_USES_FIFO_SEM) && \
03281         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03282       ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03283 # else
03284       ACE_OS::sema_post (&event->lock_);
03285 # endif
03286 
03287       if (result == -1)
03288         // Reset errno in case mutex_unlock() also fails...
03289         errno = error;
03290     }
03291   else
03292     result = -1;
03293   return result;
03294 #else
03295   ACE_UNUSED_ARG (event);
03296   ACE_NOTSUP_RETURN (-1);
03297 #endif /* ACE_WIN32 */
03298 }

ACE_Export int ACE_OS::lwp_getparams ( ACE_Sched_Params sched_params  ) 

Definition at line 3305 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCOPE_THREAD, memcpy(), memset(), priority_control(), sched_params(), and scheduling_class().

Referenced by thr_setprio().

03306 {
03307 #if defined (ACE_HAS_STHREADS) || defined (sun)
03308   // Get the class TS and RT class IDs.
03309   ACE_id_t rt_id;
03310   ACE_id_t ts_id;
03311   if (ACE_OS::scheduling_class ("RT", rt_id) == -1
03312       || ACE_OS::scheduling_class ("TS", ts_id) == -1)
03313     return -1;
03314 
03315   // Get this LWP's scheduling parameters.
03316   pcparms_t pcparms;
03317   // The following is just to avoid Purify warnings about unitialized
03318   // memory reads.
03319   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03320   pcparms.pc_cid = PC_CLNULL;
03321 
03322   if (ACE_OS::priority_control (P_LWPID,
03323                                 P_MYID,
03324                                 PC_GETPARMS,
03325                                 (char *) &pcparms) == -1)
03326     return -1;
03327   else if (pcparms.pc_cid == rt_id)
03328     {
03329       // RT class.
03330       rtparms_t rtparms;
03331       ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms);
03332 
03333       sched_params.policy (ACE_SCHED_FIFO);
03334       sched_params.priority (rtparms.rt_pri);
03335       sched_params.scope (ACE_SCOPE_THREAD);
03336       ACE_Time_Value quantum (rtparms.rt_tqsecs,
03337                               rtparms.rt_tqnsecs == RT_TQINF
03338                               ? 0 : rtparms.rt_tqnsecs * 1000);
03339       sched_params.quantum (quantum);
03340       return 0;
03341     }
03342   else if (pcparms.pc_cid == ts_id)
03343     {
03344       /* TS class */
03345       tsparms_t tsparms;
03346       ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms);
03347 
03348       sched_params.policy (ACE_SCHED_OTHER);
03349       sched_params.priority (tsparms.ts_upri);
03350       sched_params.scope (ACE_SCOPE_THREAD);
03351       return 0;
03352     }
03353   else
03354     return -1;
03355 
03356 #else  /* ! ACE_HAS_STHREADS && ! sun */
03357   ACE_UNUSED_ARG (sched_params);
03358   ACE_NOTSUP_RETURN (-1);
03359 #endif /* ! ACE_HAS_STHREADS && ! sun */
03360 }

ACE_Export int ACE_OS::lwp_setparams ( const ACE_Sched_Params sched_params  ) 

Definition at line 3363 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_SCOPE_LWP, sched_params(), and ACE_Sched_Params::scope().

Referenced by thr_create(), and thr_setprio().

03364 {
03365 #if defined (ACE_HAS_STHREADS) || defined (sun)
03366   ACE_Sched_Params lwp_params (sched_params);
03367   lwp_params.scope (ACE_SCOPE_LWP);
03368   return ACE_OS::sched_params (lwp_params);
03369 #else  /* ! ACE_HAS_STHREADS && ! sun */
03370   ACE_UNUSED_ARG (sched_params);
03371   ACE_NOTSUP_RETURN (-1);
03372 #endif /* ! ACE_HAS_STHREADS && ! sun */
03373 }

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

Definition at line 3378 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_UNIQUE_NAME_LEN, cond_destroy(), cond_init(), condattr_destroy(), condattr_init(), mutex_destroy(), mutex_init(), and unique_name().

03382 {
03383   // ACE_OS_TRACE ("ACE_OS::rwlock_init");
03384 # if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_RWLOCK_T)
03385   // NT, POSIX, and VxWorks don't support this natively.
03386   ACE_UNUSED_ARG (name);
03387   int result = -1;
03388 
03389   // Since we cannot use the user specified name for all three
03390   // objects, we will create three completely new names.
03391   ACE_TCHAR name1[ACE_UNIQUE_NAME_LEN];
03392   ACE_TCHAR name2[ACE_UNIQUE_NAME_LEN];
03393   ACE_TCHAR name3[ACE_UNIQUE_NAME_LEN];
03394   ACE_TCHAR name4[ACE_UNIQUE_NAME_LEN];
03395 
03396   ACE_OS::unique_name ((const void *) &rw->lock_,
03397                        name1,
03398                        ACE_UNIQUE_NAME_LEN);
03399   ACE_OS::unique_name ((const void *) &rw->waiting_readers_,
03400                        name2,
03401                        ACE_UNIQUE_NAME_LEN);
03402   ACE_OS::unique_name ((const void *) &rw->waiting_writers_,
03403                        name3,
03404                        ACE_UNIQUE_NAME_LEN);
03405   ACE_OS::unique_name ((const void *) &rw->waiting_important_writer_,
03406                        name4,
03407                        ACE_UNIQUE_NAME_LEN);
03408 
03409   ACE_condattr_t attributes;
03410   if (ACE_OS::condattr_init (attributes, type) == 0)
03411     {
03412       if (ACE_OS::mutex_init (&rw->lock_, type, name1,
03413                               (ACE_mutexattr_t *) arg) == 0
03414           && ACE_OS::cond_init (&rw->waiting_readers_,
03415                                 attributes, name2, arg) == 0
03416           && ACE_OS::cond_init (&rw->waiting_writers_,
03417                                 attributes, name3, arg) == 0
03418           && ACE_OS::cond_init (&rw->waiting_important_writer_,
03419                                 attributes, name4, arg) == 0)
03420         {
03421           // Success!
03422           rw->ref_count_ = 0;
03423           rw->num_waiting_writers_ = 0;
03424           rw->num_waiting_readers_ = 0;
03425           rw->important_writer_ = 0;
03426           result = 0;
03427         }
03428       ACE_OS::condattr_destroy (attributes);
03429     }
03430 
03431   if (result == -1)
03432     {
03433       // Save/restore errno.
03434       ACE_Errno_Guard error (errno);
03435       ACE_OS::mutex_destroy (&rw->lock_);
03436       ACE_OS::cond_destroy (&rw->waiting_readers_);
03437       ACE_OS::cond_destroy (&rw->waiting_writers_);
03438       ACE_OS::cond_destroy (&rw->waiting_important_writer_);
03439     }
03440   return result;
03441 # else
03442   ACE_UNUSED_ARG (rw);
03443   ACE_UNUSED_ARG (type);
03444   ACE_UNUSED_ARG (name);
03445   ACE_UNUSED_ARG (arg);
03446   ACE_NOTSUP_RETURN (-1);
03447 # endif /* ACE_HAS_THREADS */
03448 }

ACE_Export int ACE_OS::sched_params ( const ACE_Sched_Params ,
ACE_id_t  id = ACE_SELF 
)

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

Definition at line 3452 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_RR, ACE_SCOPE_LWP, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, ACE_SELF, set_errno_to_last_error(), set_scheduling_params(), thr_self(), thr_setprio(), and ACE_Time_Value::zero.

Referenced by lwp_getparams(), lwp_setparams(), ACE_Process_Manager::set_scheduler(), ACE_Process_Manager::set_scheduler_all(), set_scheduling_params(), thr_create(), and thr_setprio().

03454 {
03455   ACE_OS_TRACE ("ACE_OS::sched_params");
03456 #if defined (ACE_HAS_STHREADS)
03457   return ACE_OS::set_scheduling_params (sched_params, id);
03458 #elif defined (ACE_HAS_PTHREADS) && \
03459       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
03460       defined (ACE_HAS_PTHREAD_SCHEDPARAM))
03461   if (sched_params.quantum () != ACE_Time_Value::zero)
03462     {
03463       // quantums not supported
03464       errno = EINVAL;
03465       return -1;
03466     }
03467 
03468   // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for
03469   // providing this code for 1003.1c PThreads.  Please note that this
03470   // has only been tested for POSIX 1003.1c threads, and may cause
03471   // problems with other PThreads flavors!
03472 
03473   struct sched_param param;
03474   param.sched_priority = sched_params.priority ();
03475 
03476   if (sched_params.scope () == ACE_SCOPE_PROCESS)
03477     {
03478 # if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
03479       ACE_UNUSED_ARG (id);
03480       ACE_NOTSUP_RETURN (-1);
03481 # else  /* ! ACE_TANDEM_T1248_PTHREADS */
03482       int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id,
03483                                          sched_params.policy (),
03484                                          &param) == -1 ? -1 : 0;
03485 # if defined (DIGITAL_UNIX)
03486       return result == 0
03487         ? // Use priocntl (2) to set the process in the RT class,
03488         // if using an RT policy.
03489         ACE_OS::set_scheduling_params (sched_params)
03490         : result;
03491 # else  /* ! DIGITAL_UNIX */
03492       return result;
03493 # endif /* ! DIGITAL_UNIX */
03494 # endif /* ! ACE_TANDEM_T1248_PTHREADS */
03495     }
03496   else if (sched_params.scope () == ACE_SCOPE_THREAD)
03497     {
03498       ACE_thread_t thr_id = ACE_OS::thr_self ();
03499 
03500       int result;
03501       ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
03502                                                                     sched_params.policy (),
03503                                                                     &param),
03504                                            result),
03505                          int, -1);
03506     }
03507 # if defined (sun)
03508   // We need to be able to set LWP priorities on Suns, even without
03509   // ACE_HAS_STHREADS, to obtain preemption.
03510   else if (sched_params.scope () == ACE_SCOPE_LWP)
03511     return ACE_OS::set_scheduling_params (sched_params, id);
03512 # endif /* sun */
03513   else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX
03514     {
03515       errno = EINVAL;
03516       return -1;
03517     }
03518 
03519 #elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
03520 
03521   // PharLap ETS can act on the current thread - it can set the
03522   // quantum also, unlike Win32. All this only works on the RT
03523   // version.
03524 # if defined (ACE_HAS_PHARLAP_RT)
03525   if (id != ACE_SELF)
03526     ACE_NOTSUP_RETURN (-1);
03527 
03528 #   if !defined (ACE_PHARLAP_LABVIEW_RT)
03529   if (sched_params.quantum() != ACE_Time_Value::zero)
03530     EtsSetTimeSlice (sched_params.quantum().msec());
03531 #   endif
03532 
03533 # else
03534 
03535   if (sched_params.quantum () != ACE_Time_Value::zero)
03536     {
03537       // I don't know of a way to set the quantum on Win32.
03538       errno = EINVAL;
03539       return -1;
03540     }
03541 
03542 # endif /* ACE_HAS_PHARLAP_RT */
03543 
03544   if (sched_params.scope () == ACE_SCOPE_THREAD)
03545     {
03546 
03547       // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always
03548       // a VERY BAD THING. This include guard will allow people
03549       // to easily disable this feature in ACE.
03550       // It won't work at all for Pharlap since there's no SetPriorityClass.
03551 #if !defined (ACE_HAS_PHARLAP) && \
03552     !defined (ACE_DISABLE_WIN32_INCREASE_PRIORITY)
03553       // Set the priority class of this process to the REALTIME process class
03554       // _if_ the policy is ACE_SCHED_FIFO.  Otherwise, set to NORMAL.
03555       if (!::SetPriorityClass (::GetCurrentProcess (),
03556                                (sched_params.policy () == ACE_SCHED_FIFO ||
03557                                 sched_params.policy () == ACE_SCHED_RR)
03558                                ? REALTIME_PRIORITY_CLASS
03559                                : NORMAL_PRIORITY_CLASS))
03560         {
03561           ACE_OS::set_errno_to_last_error ();
03562           return -1;
03563         }
03564 #endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */
03565 
03566       // Now that we have set the priority class of the process, set the
03567       // priority of the current thread to the desired value.
03568       return ACE_OS::thr_setprio (sched_params.priority ());
03569     }
03570   else if (sched_params.scope () == ACE_SCOPE_PROCESS)
03571     {
03572 
03573 # if defined (ACE_HAS_PHARLAP_RT)
03574       ACE_NOTSUP_RETURN (-1);
03575 # else
03576       HANDLE hProcess
03577         = ::OpenProcess (PROCESS_SET_INFORMATION,
03578                          FALSE,
03579                          id == ACE_SELF ? ::GetCurrentProcessId() : id);
03580       if (!hProcess)
03581         {
03582           ACE_OS::set_errno_to_last_error();
03583           return -1;
03584         }
03585       // There is no way for us to set the priority of the thread when we
03586       // are setting the priority of a different process.  So just ignore
03587       // the priority argument when ACE_SCOPE_PROCESS is specified.
03588       // Setting the priority class will automatically increase the base
03589       // priority of all the threads within a process while maintaining the
03590       // relative priorities of the threads within it.
03591       if (!::SetPriorityClass (hProcess,
03592                                (sched_params.policy () == ACE_SCHED_FIFO ||
03593                                 sched_params.policy () == ACE_SCHED_RR)
03594                                ? REALTIME_PRIORITY_CLASS
03595                                : NORMAL_PRIORITY_CLASS))
03596         {
03597           ACE_OS::set_errno_to_last_error ();
03598           ::CloseHandle (hProcess);
03599           return -1;
03600         }
03601       ::CloseHandle (hProcess);
03602       return 0;
03603 #endif /* ACE_HAS_PHARLAP_RT */
03604 
03605     }
03606   else
03607     {
03608       errno = EINVAL;
03609       return -1;
03610     }
03611 #elif defined (ACE_VXWORKS)
03612   ACE_UNUSED_ARG (id);
03613 
03614   // There is only one class of priorities on VxWorks, and no time
03615   // quanta.  So, just set the current thread's priority.
03616 
03617   if (sched_params.policy () != ACE_SCHED_FIFO
03618       || sched_params.scope () != ACE_SCOPE_PROCESS
03619       || sched_params.quantum () != ACE_Time_Value::zero)
03620     {
03621       errno = EINVAL;
03622       return -1;
03623     }
03624 
03625   // Set the thread priority on the current thread.
03626   return ACE_OS::thr_setprio (sched_params.priority ());
03627 #else
03628   ACE_UNUSED_ARG (sched_params);
03629   ACE_UNUSED_ARG (id);
03630   ACE_NOTSUP_RETURN (-1);
03631 #endif /* ACE_HAS_STHREADS */
03632 }

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

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

Definition at line 3635 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, memset(), priority_control(), and strcpy().

Referenced by lwp_getparams(), and set_scheduling_params().

03636 {
03637 #if defined (ACE_HAS_PRIOCNTL)
03638   // Get the priority class ID.
03639   pcinfo_t pcinfo;
03640   // The following is just to avoid Purify warnings about unitialized
03641   // memory reads.
03642   ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
03643 
03644   ACE_OS::strcpy (pcinfo.pc_clname, class_name);
03645   if (ACE_OS::priority_control (P_ALL /* ignored */,
03646                                 P_MYID /* ignored */,
03647                                 PC_GETCID,
03648                                 (char *) &pcinfo) == -1)
03649     {
03650       return -1;
03651     }
03652   else
03653     {
03654       id = pcinfo.pc_cid;
03655       return 0;
03656     }
03657 #else  /* ! ACE_HAS_PRIOCNTL */
03658   ACE_UNUSED_ARG (class_name);
03659   ACE_UNUSED_ARG (id);
03660   ACE_NOTSUP_RETURN (-1);
03661 #endif /* ! ACE_HAS_PRIOCNTL */
03662 }

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

References ACE_NOTSUP_RETURN, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCHED_RR, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, last_error(), memcpy(), memset(), priority_control(), sched_params(), scheduling_class(), and ACE_Time_Value::zero.

Referenced by sched_params().

03667 {
03668 #if defined (ACE_HAS_PRIOCNTL)
03669   // Set priority class, priority, and quantum of this LWP or process as
03670   // specified in sched_params.
03671 
03672   // Get the priority class ID.
03673   ACE_id_t class_id;
03674   if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER  ?
03675                                   "TS"  :
03676                                   "RT", class_id) == -1)
03677     {
03678       return -1;
03679     }
03680 
03681   pcparms_t pcparms;
03682   // The following is just to avoid Purify warnings about unitialized
03683   // memory reads.
03684   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03685 
03686   pcparms.pc_cid = class_id;
03687 
03688   if (sched_params.policy () == ACE_SCHED_OTHER  &&
03689       sched_params.quantum () == ACE_Time_Value::zero)
03690       // SunOS doesn't support non-zero quantums in time-sharing class:  use
03691       // real-time class instead.
03692     {
03693       tsparms_t tsparms;
03694       // The following is just to avoid Purify warnings about unitialized
03695       // memory reads.
03696       ACE_OS::memset (&tsparms, 0, sizeof tsparms);
03697 
03698       // Don't change ts_uprilim (user priority limit)
03699       tsparms.ts_uprilim = TS_NOCHANGE;
03700       tsparms.ts_upri = sched_params.priority ();
03701 
03702       // Package up the TS class ID and parameters for the
03703       // priority_control () call.
03704       ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms);
03705     }
03706   else if (sched_params.policy () == ACE_SCHED_FIFO  ||
03707            (sched_params.policy () == ACE_SCHED_RR &&
03708             sched_params.quantum () != ACE_Time_Value::zero))
03709            // must have non-zero quantum for RR, to make it meaningful
03710            // A zero quantum with FIFO has special significance:  it actually
03711            // means infinite time quantum, i.e., run-to-completion.
03712     {
03713       rtparms_t rtparms;
03714       // The following is just to avoid Purify warnings about unitialized
03715       // memory reads.
03716       ACE_OS::memset (&rtparms, 0, sizeof rtparms);
03717 
03718       rtparms.rt_pri = sched_params.priority ();
03719 
03720       if (sched_params.quantum () == ACE_Time_Value::zero)
03721         {
03722           // rtparms.rt_tqsecs is ignored with RT_TQINF
03723           rtparms.rt_tqnsecs = RT_TQINF;
03724         }
03725       else
03726         {
03727           rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec ();
03728           rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000;
03729         }
03730 
03731       // Package up the RT class ID and parameters for the
03732       // priority_control () call.
03733       ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms);
03734     }
03735   else
03736     {
03737       errno = EINVAL;
03738       return -1;
03739     }
03740 
03741   if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD
03742                                             ? ACE_SCOPE_PROCESS
03743                                             : sched_params.scope ()),
03744                                 id,
03745                                 PC_SETPARMS,
03746                                 (char *) &pcparms) < 0)
03747     {
03748       return ACE_OS::last_error ();
03749     }
03750 
03751   return 0;
03752 #else  /* ! ACE_HAS_PRIOCNTL */
03753   ACE_UNUSED_ARG (sched_params);
03754   ACE_UNUSED_ARG (id);
03755   ACE_NOTSUP_RETURN (-1);
03756 #endif /* ! ACE_HAS_PRIOCNTL */
03757 }

ACE_Export int ACE_OS::thr_create ( ACE_THR_FUNC  func,
void *  args,
long  flags,
ACE_thread_t thr_id,
ACE_hthread_t thr_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 
)

Definition at line 3760 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_AUTO_PTR_RESET, ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_DEFAULT_THREAD_PRIORITY, ACE_MAX, ACE_MIN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SET_BITS, ACE_THR_PRI_FIFO_DEF, ACE_THR_PRI_OTHER_DEF, ACE_THREAD_ADAPTER_NAME, ENOSYS, ENOTSUP, ACE_Base_Thread_Adapter::entry_point(), lwp_setparams(), memset(), ACE_Auto_Basic_Ptr< X >::release(), sched_params(), THR_BOUND, thr_continue(), THR_DETACHED, thr_getconcurrency(), THR_INHERIT_SCHED, THR_JOINABLE, THR_NEW_LWP, THR_SCHED_DEFAULT, THR_SCHED_FIFO, THR_SCHED_RR, THR_SCOPE_PROCESS, THR_SCOPE_SYSTEM, thr_self(), thr_setconcurrency(), thr_setprio(), and THR_SUSPENDED.

Referenced by ACE_Thread::spawn().

03770 {
03771   ACE_OS_TRACE ("ACE_OS::thr_create");
03772 
03773   if (ACE_BIT_DISABLED (flags, THR_DETACHED) &&
03774       ACE_BIT_DISABLED (flags, THR_JOINABLE))
03775     ACE_SET_BITS (flags, THR_JOINABLE);
03776 
03777 #if defined (ACE_NO_THREAD_ADAPTER)
03778 # define  ACE_THREAD_FUNCTION  func
03779 # define  ACE_THREAD_ARGUMENT  args
03780 #else /* ! defined (ACE_NO_THREAD_ADAPTER) */
03781 # define  ACE_THREAD_FUNCTION  thread_args->entry_point ()
03782 # define  ACE_THREAD_ARGUMENT  thread_args
03783 #endif /* ! defined (ACE_NO_THREAD_ADAPTER) */
03784 
03785   ACE_Base_Thread_Adapter *thread_args = 0;
03786   if (thread_adapter == 0)
03787 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
03788     ACE_NEW_RETURN (thread_args,
03789                     ACE_OS_Thread_Adapter (func, args,
03790                                            (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
03791                                            ACE_OS_Object_Manager::seh_except_selector(),
03792                                            ACE_OS_Object_Manager::seh_except_handler()),
03793                     -1);
03794 #else
03795   ACE_NEW_RETURN (thread_args,
03796                   ACE_OS_Thread_Adapter (func, args,
03797                                          (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME),
03798                   -1);
03799 
03800 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
03801   else
03802     thread_args = thread_adapter;
03803 
03804   auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
03805 
03806   if (thread_adapter == 0)
03807     ACE_AUTO_PTR_RESET (auto_thread_args,
03808                         thread_args,
03809                         ACE_Base_Thread_Adapter);
03810 
03811 #if defined (ACE_HAS_THREADS)
03812 
03813   // *** Set Stack Size
03814 # if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03815   if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03816     stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE;
03817 # endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
03818 
03819   ACE_thread_t tmp_thr;
03820   if (thr_id == 0)
03821     thr_id = &tmp_thr;
03822 
03823   ACE_hthread_t tmp_handle;
03824   if (thr_handle == 0)
03825     thr_handle = &tmp_handle;
03826 
03827 # if defined (ACE_HAS_PTHREADS)
03828   int result;
03829 # if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
03830   /* Tests show that VxWorks 6.x pthread lib does not only
03831    * require zeroing of mutex/condition objects to function correctly
03832    * but also of the attribute objects.
03833    */
03834   pthread_attr_t attr = {0};
03835 #   else
03836   pthread_attr_t attr;
03837 #   endif
03838   if (ACE_ADAPT_RETVAL(::pthread_attr_init(&attr), result) != 0)
03839     return -1;
03840 
03841   if (stacksize != 0)
03842     {
03843       size_t size = stacksize;
03844 
03845 #   if defined (PTHREAD_STACK_MIN)
03846       if (size < static_cast <size_t> (PTHREAD_STACK_MIN))
03847         size = PTHREAD_STACK_MIN;
03848 #   endif /* PTHREAD_STACK_MIN */
03849 
03850 #   if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE)
03851 #     if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
03852       int result;
03853       if (stack != 0)
03854         result = ACE_ADAPT_RETVAL (pthread_attr_setstack (&attr, stack, size), result);
03855       else
03856         result = ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result);
03857       if (result == -1)
03858 #     else
03859       if (ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result) == -1)
03860 #     endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACK */
03861         {
03862           ::pthread_attr_destroy (&attr);
03863           return -1;
03864         }
03865 #   else
03866       ACE_UNUSED_ARG (size);
03867 #   endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE */
03868     }
03869 
03870   // *** Set Stack Address
03871 #   if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
03872 #     if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR)
03873   if (stack != 0)
03874     {
03875       if (ACE_ADAPT_RETVAL(::pthread_attr_setstackaddr (&attr, stack), result) != 0)
03876         {
03877           ::pthread_attr_destroy (&attr);
03878           return -1;
03879         }
03880     }
03881 #     else
03882   ACE_UNUSED_ARG (stack);
03883 #     endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR */
03884 #   endif /* ACE_LACKS_PTHREAD_ATTR_SETSTACK */
03885 
03886   // *** Deal with various attributes
03887   if (flags != 0)
03888     {
03889       // *** Set Detach state
03890 #   if !defined (ACE_LACKS_SETDETACH)
03891       if (ACE_BIT_ENABLED (flags, THR_DETACHED)
03892           || ACE_BIT_ENABLED (flags, THR_JOINABLE))
03893         {
03894           int dstate = PTHREAD_CREATE_JOINABLE;
03895 
03896           if (ACE_BIT_ENABLED (flags, THR_DETACHED))
03897             dstate = PTHREAD_CREATE_DETACHED;
03898 
03899           if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate),
03900                                result) != 0)
03901             {
03902               ::pthread_attr_destroy (&attr);
03903               return -1;
03904             }
03905         }
03906 
03907       // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we
03908       // call ::pthread_detach () below.  If THR_DETACHED is not
03909       // enabled, we call ::pthread_detach () in the Thread_Manager,
03910       // after joining with the thread.
03911 #   endif /* ACE_LACKS_SETDETACH */
03912 
03913       // *** Set Policy
03914 #   if !defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
03915       // If we wish to set the priority explicitly, we have to enable
03916       // explicit scheduling, and a policy, too.
03917       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03918         {
03919           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
03920           if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO)
03921               && ACE_BIT_DISABLED (flags, THR_SCHED_RR)
03922               && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT))
03923             ACE_SET_BITS (flags, THR_SCHED_DEFAULT);
03924         }
03925 
03926       if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
03927           || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
03928           || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
03929         {
03930           int spolicy;
03931 
03932 #     if defined (ACE_HAS_ONLY_SCHED_OTHER)
03933           // SunOS, thru version 5.6, only supports SCHED_OTHER.
03934           spolicy = SCHED_OTHER;
03935 #     elif defined (ACE_HAS_ONLY_SCHED_FIFO)
03936           // NonStop OSS standard pthread supports only SCHED_FIFO.
03937           spolicy = SCHED_FIFO;
03938 #     else
03939           // Make sure to enable explicit scheduling, in case we didn't
03940           // enable it above (for non-default priority).
03941           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
03942 
03943           if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
03944             spolicy = SCHED_OTHER;
03945           else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
03946             spolicy = SCHED_FIFO;
03947 #       if defined (SCHED_IO)
03948           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
03949             spolicy = SCHED_IO;
03950 #       else
03951           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
03952             {
03953               errno = ENOSYS;
03954               return -1;
03955             }
03956 #       endif /* SCHED_IO */
03957           else
03958             spolicy = SCHED_RR;
03959 
03960 #     endif /* ACE_HAS_ONLY_SCHED_OTHER */
03961 
03962           (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy),
03963                            result);
03964           if (result != 0)
03965             {
03966               ::pthread_attr_destroy (&attr);
03967               return -1;
03968             }
03969         }
03970 
03971       // *** Set Priority (use reasonable default priorities)
03972 #     if defined(ACE_HAS_PTHREADS)
03973       // If we wish to explicitly set a scheduling policy, we also
03974       // have to specify a priority.  We choose a "middle" priority as
03975       // default.  Maybe this is also necessary on other POSIX'ish
03976       // implementations?
03977       if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
03978            || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
03979            || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
03980           && priority == ACE_DEFAULT_THREAD_PRIORITY)
03981         {
03982           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
03983             priority = ACE_THR_PRI_FIFO_DEF;
03984           else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR))
03985             priority = ACE_THR_PRI_RR_DEF;
03986           else // THR_SCHED_DEFAULT
03987             priority = ACE_THR_PRI_OTHER_DEF;
03988         }
03989 #     endif /* ACE_HAS_PTHREADS */
03990       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
03991         {
03992           struct sched_param sparam;
03993           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
03994 
03995 #     if defined (ACE_HAS_IRIX62_THREADS)
03996           sparam.sched_priority = ACE_MIN (priority,
03997                                            (long) PTHREAD_MAX_PRIORITY);
03998 #     elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS)
03999           /* For MIT pthreads... */
04000           sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY);
04001 #     elif defined(ACE_HAS_PTHREADS) && !defined (ACE_HAS_STHREADS)
04002           // The following code forces priority into range.
04003           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04004             sparam.sched_priority =
04005               ACE_MIN (ACE_THR_PRI_FIFO_MAX,
04006                        ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
04007           else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
04008             sparam.sched_priority =
04009               ACE_MIN (ACE_THR_PRI_RR_MAX,
04010                        ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
04011           else // Default policy, whether set or not
04012             sparam.sched_priority =
04013               ACE_MIN (ACE_THR_PRI_OTHER_MAX,
04014                        ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
04015 #     elif defined (PRIORITY_MAX)
04016           sparam.sched_priority = ACE_MIN (priority,
04017                                            (long) PRIORITY_MAX);
04018 #     else
04019           sparam.sched_priority = priority;
04020 #     endif /* ACE_HAS_IRIX62_THREADS */
04021 
04022           {
04023 #       if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
04024             // SunOS, through 5.6, POSIX only allows priorities > 0 to
04025             // ::pthread_attr_setschedparam.  If a priority of 0 was
04026             // requested, set the thread priority after creating it, below.
04027             if (priority > 0)
04028 #       endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
04029               {
04030                 (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam),
04031                                         result);
04032                 if (result != 0)
04033                   {
04034                     ::pthread_attr_destroy (&attr);
04035                     return -1;
04036                   }
04037               }
04038           }
04039         }
04040 
04041       // *** Set scheduling explicit or inherited
04042       if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)
04043           || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED))
04044         {
04045           int sched = PTHREAD_EXPLICIT_SCHED;
04046           if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED))
04047             sched = PTHREAD_INHERIT_SCHED;
04048           if (ACE_ADAPT_RETVAL(::pthread_attr_setinheritsched (&attr, sched), result) != 0)
04049             {
04050               ::pthread_attr_destroy (&attr);
04051               return -1;
04052             }
04053         }
04054 #   else /* ACE_LACKS_SETSCHED */
04055       ACE_UNUSED_ARG (priority);
04056 #   endif /* ACE_LACKS_SETSCHED */
04057 
04058   // *** Set pthread name
04059 #   if defined (ACE_HAS_PTHREAD_ATTR_SETNAME)
04060   if (thr_name && *thr_name)
04061     {
04062       if (ACE_ADAPT_RETVAL(::pthread_attr_setname (&attr, const_cast<char*>(*thr_name)), result) != 0)
04063         {
04064           ::pthread_attr_destroy (&attr);
04065           return -1;
04066         }
04067     }
04068 #else
04069   ACE_UNUSED_ARG (thr_name);
04070 #   endif
04071 
04072       // *** Set Scope
04073 #   if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING)
04074       if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)
04075           || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS))
04076         {
04077 #     if defined (ACE_CONFIG_LINUX_H) || defined (HPUX) || defined (ACE_VXWORKS)
04078           // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS.
04079           // Neither does HPUX (up to HP-UX 11.00, as far as I know).
04080           // Also VxWorks only delivers scope system
04081           int scope = PTHREAD_SCOPE_SYSTEM;
04082 #     else /* ACE_CONFIG_LINUX_H */
04083           int scope = PTHREAD_SCOPE_PROCESS;
04084 #     endif /* ACE_CONFIG_LINUX_H */
04085           if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM))
04086             scope = PTHREAD_SCOPE_SYSTEM;
04087 
04088           if (ACE_ADAPT_RETVAL(::pthread_attr_setscope (&attr, scope), result) != 0)
04089             {
04090               ::pthread_attr_destroy (&attr);
04091               return -1;
04092             }
04093         }
04094 #   endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */
04095 
04096 #   ifdef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP
04097       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED))
04098         {
04099            if (ACE_ADAPT_RETVAL(::pthread_attr_setcreatesuspend_np(&attr), result) != 0)
04100             {
04101 
04102               ::pthread_attr_destroy (&attr);
04103               return -1;
04104             }
04105         }
04106 #   endif /* !ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP */
04107 
04108 #   if ! defined(ACE_LACKS_THR_CONCURRENCY_FUNCS)
04109       if (ACE_BIT_ENABLED (flags, THR_NEW_LWP))
04110         {
04111           // Increment the number of LWPs by one to emulate the
04112           // SunOS semantics.
04113           int lwps = ACE_OS::thr_getconcurrency ();
04114           if (lwps == -1)
04115             {
04116               if (errno == ENOTSUP)
04117                 // Suppress the ENOTSUP because it's harmless.
04118                 errno = 0;
04119               else
04120                 // This should never happen on SunOS:
04121                 // ::thr_getconcurrency () should always succeed.
04122                 return -1;
04123             }
04124           else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1)
04125             {
04126               if (errno == ENOTSUP)
04127                 {
04128                   // Unlikely: ::thr_getconcurrency () is supported
04129                   // but ::thr_setconcurrency () is not?
04130                 }
04131               else
04132                 return -1;
04133             }
04134         }
04135 #   endif /* ! ACE_LACKS_THR_CONCURRENCY_FUNCS */
04136     }
04137 
04138   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id,
04139                                                   &attr,
04140                                                   thread_args->entry_point (),
04141                                                   thread_args),
04142                                 result),
04143               int, -1, result);
04144   ::pthread_attr_destroy (&attr);
04145 
04146   // This is a SunOS or POSIX implementation of pthreads, where we
04147   // assume that ACE_thread_t and ACE_hthread_t are the same.  If this
04148   // *isn't* correct on some platform, please let us know.
04149   if (result != -1)
04150     *thr_handle = *thr_id;
04151 
04152 #   if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
04153   // SunOS prior to 5.7:
04154 
04155   // If the priority is 0, then we might have to set it now because we
04156   // couldn't set it with ::pthread_attr_setschedparam, as noted
04157   // above.  This doesn't provide strictly correct behavior, because
04158   // the thread was created (above) with the priority of its parent.
04159   // (That applies regardless of the inherit_sched attribute: if it
04160   // was PTHREAD_INHERIT_SCHED, then it certainly inherited its
04161   // parent's priority.  If it was PTHREAD_EXPLICIT_SCHED, then "attr"
04162   // was initialized by the SunOS ::pthread_attr_init () to contain
04163   // NULL for the priority, which indicated to SunOS ::pthread_create
04164   // () to inherit the parent priority.)
04165   if (priority == 0)
04166     {
04167       // Check the priority of this thread, which is the parent
04168       // of the newly created thread.  If it is 0, then the
04169       // newly created thread will have inherited the priority
04170       // of 0, so there's no need to explicitly set it.
04171       struct sched_param sparam;
04172       int policy = 0;
04173       ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (),
04174                                                              &policy,
04175                                                              &sparam),
04176                                     result), int,
04177                   -1, result);
04178 
04179       // The only policy supported by by SunOS, thru version 5.6,
04180       // is SCHED_OTHER, so that's hard-coded here.
04181       policy = ACE_SCHED_OTHER;
04182 
04183       if (sparam.sched_priority != 0)
04184         {
04185           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
04186           // The memset to 0 sets the priority to 0, so we don't need
04187           // to explicitly set sparam.sched_priority.
04188 
04189           ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id,
04190                                                                         policy,
04191                                                                         &sparam),
04192                                                result),
04193                              int, -1);
04194         }
04195     }
04196 
04197 #     if defined (ACE_NEEDS_LWP_PRIO_SET)
04198 #       if 0
04199   // It would be useful if we could make this work.  But, it requires
04200   // a mechanism for determining the ID of an LWP to which another
04201   // thread is bound.  Is there a way to do that?  Instead, just rely
04202   // on the code in ACE_Thread_Adapter::invoke () to set the LWP
04203   // priority.
04204 
04205   // If the thread is bound, then set the priority on its LWP.
04206   if (ACE_BIT_ENABLED (flags, THR_BOUND))
04207     {
04208       ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) ||
04209                                      ACE_BIT_ENABLED (flags, THR_SCHED_RR)  ?
04210                                      ACE_SCHED_FIFO  :
04211                                      ACE_SCHED_OTHER,
04212                                      priority);
04213       result = ACE_OS::lwp_setparams (sched_params,
04214                                       /* ? How do we find the ID of the LWP
04215                                          to which *thr_id is bound? */);
04216     }
04217 #       endif /* 0 */
04218 #     endif /* ACE_NEEDS_LWP_PRIO_SET */
04219 
04220 #   endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
04221   auto_thread_args.release ();
04222   return result;
04223 # elif defined (ACE_HAS_STHREADS)
04224   int result;
04225   int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04226 
04227   if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04228     // If we need to set the priority, then we need to start the
04229     // thread in a suspended mode.
04230     ACE_SET_BITS (flags, THR_SUSPENDED);
04231 
04232   ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize,
04233                                               thread_args->entry_point (),
04234                                               thread_args,
04235                                               flags, thr_id), result),
04236               int, -1, result);
04237 
04238   if (result != -1)
04239     {
04240       // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same.
04241       *thr_handle = *thr_id;
04242 
04243       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04244         {
04245           // Set the priority of the new thread and then let it
04246           // continue, but only if the user didn't start it suspended
04247           // in the first place!
04248           result = ACE_OS::thr_setprio (*thr_id, priority);
04249           if (result != 0)
04250             {
04251               errno = result;
04252               return -1;
04253             }
04254 
04255           if (start_suspended == 0)
04256             {
04257               result = ACE_OS::thr_continue (*thr_id);
04258               if (result != 0)
04259                 {
04260                   errno = result;
04261                   return -1;
04262                 }
04263             }
04264         }
04265     }
04266   auto_thread_args.release ();
04267   return result;
04268 # elif defined (ACE_HAS_WTHREADS)
04269   ACE_UNUSED_ARG (thr_name);
04270   ACE_UNUSED_ARG (stack);
04271 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04272   if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
04273     {
04274       CWinThread *cwin_thread =
04275         ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (),
04276                           thread_args,
04277                           priority,
04278                           0,
04279                           flags | THR_SUSPENDED);
04280       // Have to duplicate the handle because
04281       // CWinThread::~CWinThread() closes the original handle.
04282 #     if !defined (ACE_HAS_WINCE)
04283       (void) ::DuplicateHandle (::GetCurrentProcess (),
04284                                 cwin_thread->m_hThread,
04285                                 ::GetCurrentProcess (),
04286                                 thr_handle,
04287                                 0,
04288                                 TRUE,
04289                                 DUPLICATE_SAME_ACCESS);
04290 #     endif /* ! ACE_HAS_WINCE */
04291       *thr_id = cwin_thread->m_nThreadID;
04292 
04293       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0)
04294         cwin_thread->ResumeThread ();
04295       // cwin_thread will be deleted in AfxThreadExit()
04296       // Warning: If AfxThreadExit() is called from within the
04297       // thread, ACE_TSS_Cleanup->thread_exit() never gets called !
04298     }
04299   else
04300 #   endif /* ACE_HAS_MFC */
04301     {
04302       int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04303 
04304       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04305         // If we need to set the priority, then we need to start the
04306         // thread in a suspended mode.
04307         ACE_SET_BITS (flags, THR_SUSPENDED);
04308 
04309       *thr_handle = (void *) ACE_BEGINTHREADEX (0,
04310                                                 static_cast <u_int> (stacksize),
04311                                                 thread_args->entry_point (),
04312                                                 thread_args,
04313                                                 flags,
04314                                                 thr_id);
04315 
04316       if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
04317         {
04318           // Set the priority of the new thread and then let it
04319           // continue, but only if the user didn't start it suspended
04320           // in the first place!
04321           ACE_OS::thr_setprio (*thr_handle, priority);
04322 
04323           if (start_suspended == 0)
04324             ACE_OS::thr_continue (*thr_handle);
04325         }
04326     }
04327 #   if 0
04328   *thr_handle = ::CreateThread
04329     (0,
04330      stacksize,
04331      LPTHREAD_START_ROUTINE (thread_args->entry_point ()),
04332      thread_args,
04333      flags,
04334      thr_id);
04335 #   endif /* 0 */
04336 
04337   // Close down the handle if no one wants to use it.
04338   if (thr_handle == &tmp_handle && tmp_handle != 0)
04339     ::CloseHandle (tmp_handle);
04340 
04341   if (*thr_handle != 0)
04342     {
04343       auto_thread_args.release ();
04344       return 0;
04345     }
04346   else
04347     ACE_FAIL_RETURN (-1);
04348   /* NOTREACHED */
04349 
04350 # elif defined (ACE_VXWORKS)
04351   // The hard-coded values below are what ::sp () would use.  (::sp ()
04352   // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to
04353   // 20,000.)  stacksize should be an even integer.  If a stack is not
04354   // specified, ::taskSpawn () is used so that we can set the
04355   // priority, flags, and stacksize.  If a stack is specified,
04356   // ::taskInit ()/::taskActivate() are used.
04357 
04358   // If called with thr_create() defaults, use same default values as ::sp ():
04359   if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100;
04360   // Assumes that there is a floating point coprocessor.  As noted
04361   // above, ::sp () hardcodes this, so we should be safe with it.
04362   if (flags == 0) flags = VX_FP_TASK;
04363   if (stacksize == 0) stacksize = 20000;
04364 
04365   ACE_thread_t tid;
04366 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04367   if (stack == 0)
04368     {
04369 #   else
04370       ACE_UNUSED_ARG (stack);
04371 #   endif /* 0 */
04372       // The call below to ::taskSpawn () causes VxWorks to assign a
04373       // unique task name of the form: "t" + an integer, because the
04374       // first argument is 0.
04375       tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0,
04376                          priority,
04377                          (int) flags,
04378                          (int) stacksize,
04379                          thread_args->entry_point (),
04380                          (int) thread_args,
04381                          0, 0, 0, 0, 0, 0, 0, 0, 0);
04382 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04383     }
04384   else
04385     {
04386       // If a task name (thr_id) was not supplied, then the task will
04387       // not have a unique name.  That's VxWorks' behavior.
04388 
04389       // Carve out a TCB at the beginning of the stack space.  The TCB
04390       // occupies 400 bytes with VxWorks 5.3.1/I386.
04391       WIND_TCB *tcb = (WIND_TCB *) stack;
04392 
04393       // The TID is defined to be the address of the TCB.
04394       int status = ::taskInit (tcb,
04395                                thr_name && *thr_name ? const_cast <char*>(*thr_name) : 0,
04396                                priority,
04397                                (int) flags,
04398                                (char *) stack + sizeof (WIND_TCB),
04399                                (int) (stacksize - sizeof (WIND_TCB)),
04400                                thread_args->entry_point (),
04401                                (int) thread_args,
04402                                0, 0, 0, 0, 0, 0, 0, 0, 0);
04403 
04404       if (status == OK)
04405         {
04406           // The task was successfully initialized, now activate it.
04407           status = ::taskActivate ((ACE_hthread_t) tcb);
04408         }
04409 
04410       tid = status == OK  ? (ACE_thread_t) tcb  :  ERROR;
04411     }
04412 #   endif /* 0 */
04413 
04414   if (tid == ERROR)
04415     return -1;
04416   else
04417     {
04418       if (thr_id)
04419         *thr_id = tid;
04420 
04421       if (thr_handle)
04422         *thr_handle = tid;
04423 
04424       if (thr_name && !(*thr_name))
04425         *thr_name = ::taskName (tid);
04426 
04427       auto_thread_args.release ();
04428       return 0;
04429     }
04430 
04431 # endif /* ACE_HAS_STHREADS */
04432 #else
04433   ACE_UNUSED_ARG (func);
04434   ACE_UNUSED_ARG (args);
04435   ACE_UNUSED_ARG (flags);
04436   ACE_UNUSED_ARG (thr_id);
04437   ACE_UNUSED_ARG (thr_handle);
04438   ACE_UNUSED_ARG (priority);
04439   ACE_UNUSED_ARG (stack);
04440   ACE_UNUSED_ARG (stacksize);
04441   ACE_UNUSED_ARG (thr_name);
04442   ACE_NOTSUP_RETURN (-1);
04443 #endif /* ACE_HAS_THREADS */
04444 }

ACE_Export void ACE_OS::thr_exit ( ACE_THR_FUNC_RETURN  status = 0  ) 

Definition at line 4447 of file OS_NS_Thread.cpp.

References ACE_BIT_ENABLED, ACE_OS_TRACE, cleanup_tss(), ACE_OS_Thread_Descriptor::flags(), ACE_Base_Thread_Adapter::thr_desc_log_msg(), and thr_self().

Referenced by ACE_Thread_Control::exit(), and ACE_Thread::exit().

04448 {
04449   ACE_OS_TRACE ("ACE_OS::thr_exit");
04450 #if defined (ACE_HAS_THREADS)
04451 # if defined (ACE_HAS_PTHREADS)
04452     ::pthread_exit (status);
04453 # elif defined (ACE_HAS_STHREADS)
04454     ::thr_exit (status);
04455 # elif defined (ACE_HAS_WTHREADS)
04456     // Can't call it here because on NT, the thread is exited
04457     // directly by ACE_Thread_Adapter::invoke ().
04458     //   ACE_TSS_Cleanup::instance ()->thread_exit (status);
04459 
04460 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04461     int using_afx = -1;
04462     // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor.
04463     // But without #including ace/Thread_Manager.h, we don't know that.
04464     ACE_OS_Thread_Descriptor *td =
04465       ACE_Base_Thread_Adapter::thr_desc_log_msg ();
04466     if (td)
04467       using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX);
04468 #   endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
04469 
04470     // Call TSS destructors.
04471     ACE_OS::cleanup_tss (0 /* not main thread */);
04472 
04473     // Exit the thread.
04474     // Allow CWinThread-destructor to be invoked from AfxEndThread.
04475     // _endthreadex will be called from AfxEndThread so don't exit the
04476     // thread now if we are running an MFC thread.
04477 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04478     if (using_afx != -1)
04479       {
04480         if (using_afx)
04481           ::AfxEndThread (status);
04482         else
04483           ACE_ENDTHREADEX (status);
04484       }
04485     else
04486       {
04487         // Not spawned by ACE_Thread_Manager, use the old buggy
04488         // version.  You should seriously consider using
04489         // ACE_Thread_Manager to spawn threads.  The following code is
04490         // know to cause some problem.
04491         CWinThread *pThread = ::AfxGetThread ();
04492         if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
04493           ACE_ENDTHREADEX (status);
04494         else
04495           ::AfxEndThread (status);
04496       }
04497 #   else
04498     ACE_ENDTHREADEX (status);
04499 #   endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
04500 
04501 # elif defined (ACE_HAS_VXTHREADS)
04502     ACE_thread_t tid = ACE_OS::thr_self ();
04503     *((int *) status) = ::taskDelete (tid);
04504 # endif /* ACE_HAS_PTHREADS */
04505 #else
04506   ACE_UNUSED_ARG (status);
04507 #endif /* ACE_HAS_THREADS */
04508 }

ACE_Export int ACE_OS::thr_key_detach ( ACE_thread_key_t  key,
void *  inst 
)

Note:
the "inst" arg is deprecated. It will be ignored.

Definition at line 4576 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Threading_Helper< ACE_Thread_Mutex >::~ACE_Threading_Helper(), and ACE_TSS< TYPE >::~ACE_TSS().

04577 {
04578 #if defined (ACE_HAS_WTHREADS) || defined (ACE_HAS_TSS_EMULATION)
04579   TSS_Cleanup_Instance cleanup;
04580   if (cleanup.valid ())
04581     {
04582       return cleanup->thread_detach_key (key);
04583     }
04584   else
04585     {
04586       return -1;
04587     }
04588 #else
04589   ACE_UNUSED_ARG (key);
04590   ACE_NOTSUP_RETURN (-1);
04591 #endif /* ACE_HAS_WTHREADS || ACE_HAS_TSS_EMULATION */
04592 }

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

References ACE_NOTSUP_RETURN.

04598 {
04599 #if defined (ACE_HAS_PTHREAD_GETAFFINITY_NP)
04600   // Handle of the thread, which is NPTL thread-id, normally a big number
04601   if (::pthread_getaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
04602     {
04603       return -1;
04604     }
04605   return 0;
04606 #elif defined (ACE_HAS_2_PARAM_SCHED_GETAFFINITY)
04607   // The process-id is expected as <thr_id>, which can be a thread-id of
04608   // linux-thread, thus making binding to cpu of that particular thread only.
04609   // If you are using this flag for NPTL-threads, however, please pass as a
04610   // thr_id process id obtained by ACE_OS::getpid ()
04611   ACE_UNUSED_ARG (cpu_set_size);
04612   if (::sched_getaffinity(thr_id, cpu_mask) == -1)
04613     {
04614       return -1;
04615     }
04616   return 0;
04617 #elif defined (ACE_HAS_SCHED_GETAFFINITY)
04618   // The process-id is expected as <thr_id>, which can be a thread-id of
04619   // linux-thread, thus making binding to cpu of that particular thread only.
04620   // If you are using this flag for NPTL-threads, however, please pass as a
04621   // thr_id process id obtained by ACE_OS::getpid ()
04622   if (::sched_getaffinity(thr_id, cpu_set_size, cpu_mask) == -1)
04623     {
04624       return -1;
04625     }
04626   return 0;
04627 #else
04628   ACE_UNUSED_ARG (thr_id);
04629   ACE_UNUSED_ARG (cpu_set_size);
04630   ACE_UNUSED_ARG (cpu_mask);
04631   ACE_NOTSUP_RETURN (-1);
04632 #endif
04633 }

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

References ACE_NOTSUP_RETURN.

04639 {
04640 #if defined (ACE_HAS_PTHREAD_SETAFFINITY_NP)
04641   if (::pthread_setaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
04642     {
04643       return -1;
04644     }
04645   return 0;
04646 #elif defined (ACE_HAS_2_PARAM_SCHED_SETAFFINITY)
04647   // The process-id is expected as <thr_id>, which can be a thread-id of
04648   // linux-thread, thus making binding to cpu of that particular thread only.
04649   // If you are using this flag for NPTL-threads, however, please pass as a
04650   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04651   //
04652   ACE_UNUSED_ARG (cpu_set_size);
04653   if (::sched_setaffinity (thr_id, cpu_mask) == -1)
04654     {
04655       return -1;
04656     }
04657   return 0;
04658 #elif defined (ACE_HAS_SCHED_SETAFFINITY)
04659   // The process-id is expected as <thr_id>, which can be a thread-id of
04660   // linux-thread, thus making binding to cpu of that particular thread only.
04661   // If you are using this flag for NPTL-threads, however, please pass as a
04662   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04663   //
04664   if (::sched_setaffinity (thr_id, cpu_set_size, cpu_mask) == -1)
04665     {
04666       return -1;
04667     }
04668   return 0;
04669 #else
04670   ACE_UNUSED_ARG (thr_id);
04671   ACE_UNUSED_ARG (cpu_set_size);
04672   ACE_UNUSED_ARG (cpu_mask);
04673   ACE_NOTSUP_RETURN (-1);
04674 #endif
04675 }

ACE_Export int ACE_OS::thr_key_used ( ACE_thread_key_t  key  ) 

Definition at line 4678 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN.

04679 {
04680 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
04681   TSS_Cleanup_Instance cleanup;
04682   if (cleanup.valid ())
04683     {
04684       cleanup->thread_use_key (key);
04685       return 0;
04686     }
04687   return -1;
04688 #else
04689   ACE_UNUSED_ARG (key);
04690   ACE_NOTSUP_RETURN (-1);
04691 #endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
04692 }

ACE_Export int ACE_OS::thr_keycreate ( ACE_thread_key_t key,
ACE_THR_DEST  ,
void *  inst = 0 
)

Note:
the "inst" arge is deprecated. It will be ignored.

Definition at line 4734 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Thread::keycreate().

04741 {
04742   // ACE_OS_TRACE ("ACE_OS::thr_keycreate");
04743 #if defined (ACE_HAS_THREADS)
04744 #   if defined (ACE_HAS_TSS_EMULATION)
04745     if (ACE_TSS_Emulation::next_key (*key) == 0)
04746       {
04747         ACE_TSS_Emulation::tss_destructor (*key, dest);
04748 
04749         // Extract out the thread-specific table instance and stash away
04750         // the key and destructor so that we can free it up later on...
04751         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04752         if (cleanup.valid ())
04753           {
04754             return cleanup->insert (*key, dest);
04755           }
04756         else
04757           {
04758             return -1;
04759           }
04760       }
04761     else
04762       return -1;
04763 #   elif defined (ACE_HAS_WTHREADS)
04764     if (ACE_OS::thr_keycreate_native (key, dest) == 0)
04765       {
04766         // Extract out the thread-specific table instance and stash away
04767         // the key and destructor so that we can free it up later on...
04768         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04769         if (cleanup.valid ())
04770           {
04771             return cleanup->insert (*key, dest);
04772           }
04773         else
04774           {
04775             return -1;
04776           }
04777       }
04778     else
04779       return -1;
04780       /* NOTREACHED */
04781 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04782     return  ACE_OS::thr_keycreate_native (key, dest);
04783 #   else
04784     ACE_UNUSED_ARG (key);
04785     ACE_UNUSED_ARG (dest);
04786     ACE_NOTSUP_RETURN (-1);
04787 #   endif /* ACE_HAS_TSS_EMULATION */
04788 # else /* ACE_HAS_THREADS */
04789   ACE_UNUSED_ARG (key);
04790   ACE_UNUSED_ARG (dest);
04791   ACE_NOTSUP_RETURN (-1);
04792 # endif /* ACE_HAS_THREADS */
04793 }

ACE_Export int ACE_OS::thr_keyfree ( ACE_thread_key_t  key  ) 

Definition at line 4831 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::keyfree(), ACE_Threading_Helper< ACE_Thread_Mutex >::~ACE_Threading_Helper(), and ACE_TSS< TYPE >::~ACE_TSS().

04832 {
04833   ACE_OS_TRACE ("ACE_OS::thr_keyfree");
04834 # if defined (ACE_HAS_THREADS)
04835 #   if defined (ACE_HAS_TSS_EMULATION)
04836     // Release the key in the TSS_Emulation administration
04837     ACE_TSS_Emulation::release_key (key);
04838     TSS_Cleanup_Instance cleanup;
04839     if (cleanup.valid ())
04840       {
04841         return cleanup->free_key (key);
04842       }
04843     return -1;
04844 #   elif defined (ACE_HAS_WTHREADS)
04845     // Extract out the thread-specific table instance and free up
04846     // the key and destructor.
04847     TSS_Cleanup_Instance cleanup;
04848     if (cleanup.valid ())
04849       {
04850         return cleanup->free_key (key);
04851       }
04852     return -1;
04853 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04854     return ACE_OS::thr_keyfree_native (key);
04855 #   else
04856     ACE_UNUSED_ARG (key);
04857     ACE_NOTSUP_RETURN (-1);
04858 #   endif /* ACE_HAS_TSS_EMULATION */
04859 # else /* ACE_HAS_THREADS */
04860   ACE_UNUSED_ARG (key);
04861   ACE_NOTSUP_RETURN (-1);
04862   return 0;
04863 # endif /* ACE_HAS_THREADS */
04864 }

ACE_Export int ACE_OS::thr_setprio ( const ACE_Sched_Priority  prio  ) 

Definition at line 4867 of file OS_NS_Thread.cpp.

References ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCHED_RR, lwp_getparams(), lwp_setparams(), sched_params(), and thr_self().

Referenced by ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), sched_params(), ACE_Thread::setprio(), thr_create(), and thr_setprio().

04868 {
04869   // Set the thread priority on the current thread.
04870   ACE_hthread_t my_thread_id;
04871   ACE_OS::thr_self (my_thread_id);
04872 
04873   int const status = ACE_OS::thr_setprio (my_thread_id, prio);
04874 
04875 #if defined (ACE_NEEDS_LWP_PRIO_SET)
04876   // If the thread is in the RT class, then set the priority on its
04877   // LWP.  (Instead of doing this if the thread is in the RT class, it
04878   // should be done for all bound threads.  But, there doesn't appear
04879   // to be an easy way to determine if the thread is bound.)
04880 
04881   if (status == 0)
04882     {
04883       // Find what scheduling class the thread's LWP is in.
04884       ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0);
04885       if (ACE_OS::lwp_getparams (sched_params) == -1)
04886         {
04887           return -1;
04888         }
04889       else if (sched_params.policy () == ACE_SCHED_FIFO  ||
04890                sched_params.policy () == ACE_SCHED_RR)
04891         {
04892           // This thread's LWP is in the RT class, so we need to set
04893           // its priority.
04894           sched_params.priority (prio);
04895           return ACE_OS::lwp_setparams (sched_params);
04896         }
04897       // else this is not an RT thread.  Nothing more needs to be
04898       // done.
04899     }
04900 #endif /* ACE_NEEDS_LWP_PRIO_SET */
04901 
04902   return status;
04903 }

ACE_Export int ACE_OS::thr_setspecific ( ACE_thread_key_t  key,
void *  data 
)

Definition at line 4936 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Thread::setspecific().

04937 {
04938   // ACE_OS_TRACE ("ACE_OS::thr_setspecific");
04939 #if defined (ACE_HAS_THREADS)
04940 #   if defined (ACE_HAS_TSS_EMULATION)
04941     if (ACE_TSS_Emulation::is_key (key) == 0)
04942       {
04943         errno = EINVAL;
04944         data = 0;
04945         return -1;
04946       }
04947     else
04948       {
04949         ACE_TSS_Emulation::ts_object (key) = data;
04950         TSS_Cleanup_Instance cleanup;
04951         if (cleanup.valid ())
04952           {
04953             cleanup->thread_use_key (key);
04954             // for TSS_Cleanup purposes treat stetting data to zero
04955             // like detaching.  This is a consequence of POSIX allowing
04956             // deletion of a "used" key.
04957             if (data == 0)
04958               {
04959                 cleanup->thread_detach_key (key);
04960               }
04961             return 0;
04962           }
04963         else
04964           {
04965             return -1;
04966           }
04967       }
04968 #   elif defined (ACE_HAS_WTHREADS)
04969     if (ACE_OS::thr_setspecific_native (key, data) == 0)
04970       {
04971         TSS_Cleanup_Instance cleanup;
04972         if (cleanup.valid ())
04973           {
04974             cleanup->thread_use_key (key);
04975             // for TSS_Cleanup purposes treat stetting data to zero
04976             // like detaching.  This is a consequence of POSIX allowing
04977             // deletion of a "used" key.
04978             if (data == 0)
04979               {
04980                 cleanup->thread_detach_key (key);
04981               }
04982             return 0;
04983           }
04984         return -1;
04985       }
04986     return -1;
04987 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04988       return ACE_OS::thr_setspecific_native (key, data);
04989 #   else /* ACE_HAS_TSS_EMULATION */
04990       ACE_UNUSED_ARG (key);
04991       ACE_UNUSED_ARG (data);
04992       ACE_NOTSUP_RETURN (-1);
04993 #   endif /* ACE_HAS_TSS_EMULATION */
04994 # else /* ACE_HAS_THREADS */
04995   ACE_UNUSED_ARG (key);
04996   ACE_UNUSED_ARG (data);
04997   ACE_NOTSUP_RETURN (-1);
04998 # endif /* ACE_HAS_THREADS */
04999 }

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

References ACE_UNIQUE_NAME_LEN, getpid(), sprintf(), and strsncpy().

Referenced by ACE_MEM_Acceptor::accept(), ACE_Semaphore::ACE_Semaphore(), rwlock_init(), sema_init(), ACE_DLL::set_handle(), ACE_Process_Mutex::unique_name(), ACE_RW_Process_Mutex::unique_name(), and ACE::unique_name().

05005 {
05006   // The process ID will provide uniqueness between processes on the
05007   // same machine. The "this" pointer of the <object> will provide
05008   // uniqueness between other "live" objects in the same process. The
05009   // uniqueness of this name is therefore only valid for the life of
05010   // <object>.
05011   char temp_name[ACE_UNIQUE_NAME_LEN];
05012   ACE_OS::sprintf (temp_name,
05013                    "%p%d",
05014                    object,
05015                    static_cast <int> (ACE_OS::getpid ()));
05016   ACE_OS::strsncpy (name,
05017                     temp_name,
05018                     length);
05019 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::condattr_init ( ACE_condattr_t attributes,
int  type = ACE_DEFAULT_SYNCH_TYPE 
)

Definition at line 150 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and memset().

Referenced by cond_init(), and rwlock_init().

00152 {
00153   ACE_UNUSED_ARG (type);
00154 # if defined (ACE_HAS_THREADS)
00155 #   if defined (ACE_HAS_PTHREADS)
00156   int result = -1;
00157 
00158 #   if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00159       /* Tests show that VxWorks 6.x pthread lib does not only
00160        * require zeroing of mutex/condition objects to function correctly
00161        * but also of the attribute objects.
00162        */
00163       ACE_OS::memset (&attributes, 0, sizeof (attributes));
00164 #   endif
00165   if (
00166       ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0
00167 #       if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)
00168       && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type),
00169                            result) == 0
00170 #       endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */
00171       )
00172      result = 0;
00173   else
00174      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00175 
00176   return result;
00177 #   elif defined (ACE_HAS_STHREADS)
00178   attributes.type = type;
00179 
00180   return 0;
00181 
00182 #   else
00183   ACE_UNUSED_ARG (attributes);
00184   ACE_UNUSED_ARG (type);
00185   ACE_NOTSUP_RETURN (-1);
00186 
00187 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00188 
00189 # else
00190   ACE_UNUSED_ARG (attributes);
00191   ACE_UNUSED_ARG (type);
00192   ACE_NOTSUP_RETURN (-1);
00193 # endif /* ACE_HAS_THREADS */
00194 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::condattr_destroy ( ACE_condattr_t attributes  ) 

Definition at line 131 of file OS_NS_Thread.inl.

References ACE_condattr_t::type.

Referenced by cond_init(), and rwlock_init().

00132 {
00133 #if defined (ACE_HAS_THREADS)
00134 #   if defined (ACE_HAS_PTHREADS)
00135 
00136   pthread_condattr_destroy (&attributes);
00137 
00138 #   elif defined (ACE_HAS_STHREADS)
00139   attributes.type = 0;
00140 
00141 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00142   return 0;
00143 # else
00144   ACE_UNUSED_ARG (attributes);
00145   return 0;
00146 # endif /* ACE_HAS_THREADS  */
00147 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::cond_broadcast ( ACE_cond_t cv  ) 

Definition at line 197 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_broadcast().

Referenced by cond_broadcast(), event_destroy(), event_pulse(), event_signal(), and rw_unlock().

00198 {
00199   ACE_OS_TRACE ("ACE_OS::cond_broadcast");
00200 # if defined (ACE_HAS_THREADS)
00201 #   if defined (ACE_HAS_PTHREADS)
00202   int result;
00203   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_broadcast (cv),
00204                                        result),
00205                      int, -1);
00206 #   elif defined (ACE_HAS_STHREADS)
00207   int result;
00208   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv),
00209                                        result),
00210                      int, -1);
00211 #   endif /* ACE_HAS_STHREADS */
00212 # else
00213   ACE_UNUSED_ARG (cv);
00214   ACE_NOTSUP_RETURN (-1);
00215 # endif /* ACE_HAS_THREADS */
00216 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::cond_destroy ( ACE_cond_t cv  ) 

Definition at line 219 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_destroy().

Referenced by cond_destroy(), event_destroy(), recursive_mutex_destroy(), rwlock_destroy(), rwlock_init(), sema_destroy(), and sema_init().

00220 {
00221   ACE_OS_TRACE ("ACE_OS::cond_destroy");
00222 # if defined (ACE_HAS_THREADS)
00223 #   if defined (ACE_HAS_PTHREADS)
00224   int result;
00225   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_destroy (cv), result), int, -1);
00226 #   elif defined (ACE_HAS_STHREADS)
00227   int result;
00228   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), result), int, -1);
00229 #   endif /* ACE_HAS_STHREADS */
00230 # else
00231   ACE_UNUSED_ARG (cv);
00232   ACE_NOTSUP_RETURN (-1);
00233 # endif /* ACE_HAS_THREADS */
00234 }

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

Definition at line 237 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_init(), memset(), and ACE_condattr_t::type.

00241 {
00242   // ACE_OS_TRACE ("ACE_OS::cond_init");
00243   ACE_UNUSED_ARG (name);
00244   ACE_UNUSED_ARG (arg);
00245 # if defined (ACE_HAS_THREADS)
00246 #   if defined (ACE_HAS_PTHREADS)
00247   int result = -1;
00248 
00249 #     if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00250   /* VxWorks 6.x API reference states:
00251    *   If the memory for the condition variable object has been allocated
00252    *   dynamically, it is a good policy to always zero out the
00253    *   block of memory so as to avoid spurious EBUSY return code
00254    *   when calling this routine.
00255    */
00256   ACE_OS::memset (cv, 0, sizeof (*cv));
00257 #     endif
00258 
00259   if (ACE_ADAPT_RETVAL (pthread_cond_init (cv, &attributes), result) == 0)
00260      result = 0;
00261   else
00262      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00263 
00264   return result;
00265 #   elif defined (ACE_HAS_STHREADS)
00266   int result;
00267   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv,
00268                                                     attributes.type,
00269                                                     arg),
00270                                        result),
00271                      int, -1);
00272 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00273 # else
00274   ACE_UNUSED_ARG (cv);
00275   ACE_UNUSED_ARG (attributes);
00276   ACE_UNUSED_ARG (name);
00277   ACE_UNUSED_ARG (arg);
00278   ACE_NOTSUP_RETURN (-1);
00279 # endif /* ACE_HAS_THREADS */
00280 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::cond_signal ( ACE_cond_t cv  ) 

Definition at line 302 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_signal().

Referenced by cond_signal(), event_pulse(), event_signal(), recursive_mutex_cond_unlock(), recursive_mutex_unlock(), rw_unlock(), and sema_post().

00303 {
00304   ACE_OS_TRACE ("ACE_OS::cond_signal");
00305 # if defined (ACE_HAS_THREADS)
00306 #   if defined (ACE_HAS_PTHREADS)
00307   int result;
00308   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_signal (cv), result),
00309                      int, -1);
00310 #   elif defined (ACE_HAS_STHREADS)
00311   int result;
00312   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), result), int, -1);
00313 #   endif /* ACE_HAS_STHREADS */
00314 # else
00315   ACE_UNUSED_ARG (cv);
00316   ACE_NOTSUP_RETURN (-1);
00317 # endif /* ACE_HAS_THREADS */
00318 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::cond_timedwait ( ACE_cond_t cv,
ACE_mutex_t m,
ACE_Time_Value  
)

Definition at line 343 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_timedwait(), cond_wait(), and ACE_Time_Value::set().

Referenced by cond_timedwait(), event_timedwait(), recursive_mutex_lock(), and sema_wait().

00346 {
00347   ACE_OS_TRACE ("ACE_OS::cond_timedwait");
00348 # if defined (ACE_HAS_THREADS)
00349   int result;
00350   timespec_t ts;
00351 
00352   if (timeout != 0)
00353     ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
00354 
00355 #   if defined (ACE_HAS_PTHREADS)
00356 
00357   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00358                                 ? pthread_cond_wait (cv, external_mutex)
00359                                 : pthread_cond_timedwait (cv, external_mutex,
00360                                                             (ACE_TIMESPEC_PTR) &ts),
00361                                 result),
00362               int, -1, result);
00363   // We need to adjust this to make the POSIX and Solaris return
00364   // values consistent.  EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and down)
00365   if (result == -1 &&
00366       (errno == ETIMEDOUT || errno == EAGAIN))
00367     errno = ETIME;
00368 
00369 #   elif defined (ACE_HAS_STHREADS)
00370   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00371                                 ? ::cond_wait (cv, external_mutex)
00372                                 : ::cond_timedwait (cv,
00373                                                     external_mutex,
00374                                                     (timestruc_t*)&ts),
00375                                 result),
00376               int, -1, result);
00377 #   endif /* ACE_HAS_STHREADS */
00378   if (timeout != 0)
00379     timeout->set (ts); // Update the time value before returning.
00380 
00381   return result;
00382 # else
00383   ACE_UNUSED_ARG (cv);
00384   ACE_UNUSED_ARG (external_mutex);
00385   ACE_UNUSED_ARG (timeout);
00386   ACE_NOTSUP_RETURN (-1);
00387 # endif /* ACE_HAS_THREADS */
00388 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::cond_wait ( ACE_cond_t cv,
ACE_mutex_t m 
)

Definition at line 321 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_wait().

Referenced by cond_timedwait(), cond_wait(), event_wait(), recursive_mutex_cond_relock(), recursive_mutex_lock(), rw_rdlock(), rw_trywrlock_upgrade(), rw_wrlock(), and sema_wait().

00323 {
00324   ACE_OS_TRACE ("ACE_OS::cond_wait");
00325 # if defined (ACE_HAS_THREADS)
00326 #   if defined (ACE_HAS_PTHREADS)
00327   int result;
00328   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_wait (cv, external_mutex), result),
00329                      int, -1);
00330 #   elif defined (ACE_HAS_STHREADS)
00331   int result;
00332   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), result),
00333                      int, -1);
00334 #   endif /* ACE_HAS_PTHREADS */
00335 # else
00336   ACE_UNUSED_ARG (cv);
00337   ACE_UNUSED_ARG (external_mutex);
00338   ACE_NOTSUP_RETURN (-1);
00339 # endif /* ACE_HAS_THREADS */
00340 }

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

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 392 of file OS_NS_Thread.inl.

References mutex_lock().

00394 {
00395   return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
00396 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::priority_control ( ACE_idtype_t  ,
ACE_id_t  ,
int  ,
void *   
)

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

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

Definition at line 435 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

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

00436 {
00437   ACE_OS_TRACE ("ACE_OS::priority_control");
00438 #if defined (ACE_HAS_PRIOCNTL)
00439   ACE_OSCALL_RETURN (priocntl (idtype, identifier, cmd, static_cast<caddr_t> (arg)),
00440                      long, -1);
00441 #else  /* ! ACE_HAS_PRIOCNTL*/
00442   ACE_UNUSED_ARG (idtype);
00443   ACE_UNUSED_ARG (identifier);
00444   ACE_UNUSED_ARG (cmd);
00445   ACE_UNUSED_ARG (arg);
00446   ACE_NOTSUP_RETURN (-1);
00447 #endif /* ! ACE_HAS_PRIOCNTL*/
00448 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_cond_unlock ( ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state 
)

Definition at line 457 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_signal(), NULL_thread, recursive_mutex_unlock(), thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00459 {
00460 #if defined (ACE_HAS_THREADS)
00461   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock");
00462 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00463   // Windows need special handling since it has recursive mutexes, but
00464   // does not integrate them into a condition variable.
00465 #    if defined (ACE_WIN32)
00466   // For Windows, the OS takes care of the mutex and its recursion. We just
00467   // need to release the lock one fewer times than this thread has acquired
00468   // it. Remember how many times, and reacquire it that many more times when
00469   // the condition is signaled.
00470   //
00471   // For WinCE, the situation is a bit trickier. CE doesn't have
00472   // RecursionCount, and LockCount has changed semantics over time.
00473   // In CE 3 (and maybe 4?) LockCount is not an indicator of recursion;
00474   // instead, see when it's unlocked by watching the OwnerThread, which will
00475   // change to something other than the current thread when it's been
00476   // unlocked "enough" times. Note that checking for 0 (unlocked) is not
00477   // sufficient. Another thread may acquire the lock between our unlock and
00478   // checking the OwnerThread. So grab our thread ID value first, then
00479   // compare to it in the loop condition. NOTE - the problem with this
00480   // scheme is that we really want to unlock the mutex one _less_ times than
00481   // required to release it for another thread to acquire. With CE 5 we
00482   // can do this by watching LockCount alone. I _think_ it can be done by
00483   // watching LockCount on CE 4 as well (though its meaning is different),
00484   // but I'm leary of changing this code since a user reported success
00485   // with it.
00486   //
00487   // We're using undocumented fields in the CRITICAL_SECTION structure
00488   // and they've been known to change across Windows variants and versions./
00489   // So be careful if you need to change these - there may be other
00490   // Windows variants that depend on existing values and limits.
00491 #      if defined (ACE_HAS_WINCE) && (UNDER_CE < 500)
00492   ACE_thread_t me = ACE_OS::thr_self ();
00493 #      endif /* ACE_HAS_WINCE && CE 4 or earlier */
00494 
00495   state.relock_count_ = 0;
00496   while (
00497 #      if !defined (ACE_HAS_WINCE)
00498          m->LockCount > 0 && m->RecursionCount > 1
00499 #      else
00500          // WinCE doesn't have RecursionCount and the LockCount semantic
00501          // has changed between versions; pre-Mobile 5 the LockCount
00502          // was 0-indexed, and Mobile 5 has it 1-indexed.
00503 #        if (UNDER_CE < 500)
00504          m->LockCount > 0 && m->OwnerThread == (HANDLE)me
00505 #        else
00506          m->LockCount > 1
00507 #        endif /* UNDER_CE < 500 */
00508 #      endif /* ACE_HAS_WINCE */
00509          )
00510     {
00511       // This may fail if the current thread doesn't own the mutex. If it
00512       // does fail, it'll be on the first try, so don't worry about resetting
00513       // the state.
00514       if (ACE_OS::recursive_mutex_unlock (m) == -1)
00515         return -1;
00516       ++state.relock_count_;
00517     }
00518 #    else /* not ACE_WIN32 */
00519     // prevent warnings for unused variables
00520     ACE_UNUSED_ARG (state);
00521     ACE_UNUSED_ARG (m);
00522 #    endif /* ACE_WIN32 */
00523   return 0;
00524 #  else /* ACE_HAS_RECURSIVE_MUTEXES */
00525   // For platforms without recursive mutexes, we obtain the nesting mutex
00526   // to gain control over the mutex internals. Then set the internals to say
00527   // the mutex is available. If there are waiters, signal the condition
00528   // to notify them (this is mostly like the recursive_mutex_unlock() method).
00529   // Then, return with the nesting mutex still held. The condition wait
00530   // will release it atomically, allowing mutex waiters to continue.
00531   // Note that this arrangement relies on the fact that on return from
00532   // the condition wait, this thread will again own the nesting mutex
00533   // and can either set the mutex internals directly or get in line for
00534   // the mutex... this part is handled in recursive_mutex_cond_relock().
00535   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00536     return -1;
00537 
00538 #    if !defined (ACE_NDEBUG)
00539   if (m->nesting_level_ == 0
00540       || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0)
00541     {
00542       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00543       errno = EINVAL;
00544       return -1;
00545     }
00546 #    endif /* ACE_NDEBUG */
00547 
00548   // To make error recovery a bit easier, signal the condition now. Any
00549   // waiter won't regain control until the mutex is released, which won't
00550   // be until the caller returns and does the wait on the condition.
00551   if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00552     {
00553       // Save/restore errno.
00554       ACE_Errno_Guard error (errno);
00555       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00556       return -1;
00557     }
00558 
00559   // Ok, the nesting_mutex_ lock is still held, the condition has been
00560   // signaled... reset the nesting info and return _WITH_ the lock
00561   // held. The lock will be released when the condition waits, in the
00562   // caller.
00563   state.nesting_level_ = m->nesting_level_;
00564   state.owner_id_ = m->owner_id_;
00565   m->nesting_level_ = 0;
00566   m->owner_id_ = ACE_OS::NULL_thread;
00567   return 0;
00568 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00569 #else
00570   ACE_UNUSED_ARG (m);
00571   ACE_UNUSED_ARG (state);
00572   ACE_NOTSUP_RETURN (-1);
00573 #endif /* ACE_HAS_THREADS */
00574 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::recursive_mutex_cond_relock ( ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state 
)

Definition at line 582 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, cond_wait(), recursive_mutex_lock(), and thread_mutex_unlock().

00584 {
00585 #if defined (ACE_HAS_THREADS)
00586   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock");
00587 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00588   // Windows need special handling since it has recursive mutexes, but
00589   // does not integrate them into a condition variable.
00590   // On entry, the OS has already reacquired the lock for us. Just
00591   // reacquire it the proper number of times so the recursion is the same as
00592   // before waiting on the condition.
00593 #    if defined (ACE_WIN32)
00594   while (state.relock_count_ > 0)
00595     {
00596       ACE_OS::recursive_mutex_lock (m);
00597       --state.relock_count_;
00598     }
00599   return;
00600 #    else /* not ACE_WIN32 */
00601     // prevent warnings for unused variables
00602     ACE_UNUSED_ARG (state);
00603     ACE_UNUSED_ARG (m);
00604 
00605 #    endif /* ACE_WIN32 */
00606 #  else
00607   // Without recursive mutex support, it's somewhat trickier. On entry,
00608   // the current thread holds the nesting_mutex_, but another thread may
00609   // still be holding the ACE_recursive_mutex_t. If so, mimic the code
00610   // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex.
00611   // After acquiring it, restore the nesting counts and release the
00612   // nesting mutex. This will restore the conditions to what they were
00613   // before calling ACE_OS::recursive_mutex_cond_unlock().
00614   while (m->nesting_level_ > 0)
00615     ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_);
00616 
00617   // At this point, we still have nesting_mutex_ and the mutex is free.
00618   m->nesting_level_ = state.nesting_level_;
00619   m->owner_id_ = state.owner_id_;
00620   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00621   return;
00622 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00623 #else
00624   ACE_UNUSED_ARG (m);
00625   ACE_UNUSED_ARG (state);
00626   return;
00627 #endif /* ACE_HAS_THREADS */
00628 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_destroy ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 631 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_destroy(), and thread_mutex_destroy().

Referenced by ACE_OS_Object_Manager::fini().

00632 {
00633 #if defined (ACE_HAS_THREADS)
00634 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00635   return ACE_OS::thread_mutex_destroy (m);
00636 #else
00637   if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
00638     return -1;
00639   else if (ACE_OS::cond_destroy (&m->lock_available_) == -1)
00640     return -1;
00641   else
00642     return 0;
00643 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00644 #else
00645   ACE_UNUSED_ARG (m);
00646   ACE_NOTSUP_RETURN (-1);
00647 #endif /* ACE_HAS_THREADS */
00648 }

ACE_NAMESPACE_INLINE_FUNCTION 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 
)

Definition at line 651 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_init(), NULL_thread, thread_mutex_init(), and USYNC_THREAD.

Referenced by ACE_OS_Object_Manager::init().

00655 {
00656   ACE_UNUSED_ARG (sa);
00657 #if defined (ACE_HAS_THREADS)
00658 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00659 #    if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00660   return ACE_OS::thread_mutex_init (m, PTHREAD_MUTEX_RECURSIVE, name, arg);
00661 #    else
00662   return ACE_OS::thread_mutex_init (m, 0, name, arg);
00663 #    endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00664 #  else
00665   if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1)
00666     return -1;
00667   else if (ACE_OS::cond_init (&m->lock_available_,
00668                               (short) USYNC_THREAD,
00669                               name,
00670                               0) == -1)
00671     return -1;
00672   else
00673     {
00674       m->nesting_level_ = 0;
00675       m->owner_id_ = ACE_OS::NULL_thread;
00676       return 0;
00677     }
00678 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00679 #else
00680   ACE_UNUSED_ARG (m);
00681   ACE_UNUSED_ARG (name);
00682   ACE_UNUSED_ARG (arg);
00683   ACE_NOTSUP_RETURN (-1);
00684 #endif /* ACE_HAS_THREADS */
00685 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 688 of file OS_NS_Thread.inl.

Referenced by recursive_mutex_cond_relock(), and recursive_mutex_lock().

00689 {
00690 #if defined (ACE_HAS_THREADS)
00691 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00692   return ACE_OS::thread_mutex_lock (m);
00693 #else
00694   ACE_thread_t const t_id = ACE_OS::thr_self ();
00695   int result = 0;
00696 
00697   // Acquire the guard.
00698   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00699     result = -1;
00700   else
00701   {
00702     // If there's no contention, just grab the lock immediately
00703     // (since this is the common case we'll optimize for it).
00704     if (m->nesting_level_ == 0)
00705       m->owner_id_ = t_id;
00706       // If we already own the lock, then increment the nesting level
00707       // and return.
00708     else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00709     {
00710           // Wait until the nesting level has dropped to zero, at
00711           // which point we can acquire the lock.
00712       while (m->nesting_level_ > 0)
00713         ACE_OS::cond_wait (&m->lock_available_,
00714                             &m->nesting_mutex_);
00715 
00716           // At this point the nesting_mutex_ is held...
00717       m->owner_id_ = t_id;
00718     }
00719 
00720     // At this point, we can safely increment the nesting_level_ no
00721     // matter how we got here!
00722     ++m->nesting_level_;
00723   }
00724 
00725   {
00726     // Save/restore errno.
00727     ACE_Errno_Guard error (errno);
00728     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00729   }
00730   return result;
00731 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00732 #else
00733   ACE_UNUSED_ARG (m);
00734   ACE_NOTSUP_RETURN (-1);
00735 #endif /* ACE_HAS_THREADS */
00736 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 739 of file OS_NS_Thread.inl.

00741 {
00742 #if defined (ACE_HAS_THREADS)
00743 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00744   return ACE_OS::thread_mutex_lock (m, timeout);
00745 #else
00746   ACE_thread_t t_id = ACE_OS::thr_self ();
00747   int result = 0;
00748 
00749   // Try to acquire the guard.
00750   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_, timeout) == -1)
00751     result = -1;
00752   else
00753     {
00754       // If there's no contention, just grab the lock immediately
00755       // (since this is the common case we'll optimize for it).
00756       if (m->nesting_level_ == 0)
00757         m->owner_id_ = t_id;
00758       // If we already own the lock, then increment the nesting level
00759       // and return.
00760       else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00761         {
00762           // Wait until the nesting level has dropped to zero, at
00763           // which point we can acquire the lock.
00764           while (m->nesting_level_ > 0)
00765             {
00766               result = ACE_OS::cond_timedwait (&m->lock_available_,
00767                                                &m->nesting_mutex_,
00768                                                const_cast <ACE_Time_Value *> (&timeout));
00769 
00770               // The mutex is reacquired even in the case of a timeout
00771               // release the mutex to prevent a deadlock
00772               if (result == -1)
00773                 {
00774                   // Save/restore errno.
00775                   ACE_Errno_Guard error (errno);
00776                   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00777 
00778                   return result;
00779                 }
00780             }
00781 
00782           // At this point the nesting_mutex_ is held...
00783           m->owner_id_ = t_id;
00784         }
00785 
00786       // At this point, we can safely increment the nesting_level_ no
00787       // matter how we got here!
00788       m->nesting_level_++;
00789 
00790       // Save/restore errno.
00791       ACE_Errno_Guard error (errno);
00792       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00793     }
00794   return result;
00795 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00796 #else
00797   ACE_UNUSED_ARG (m);
00798   ACE_UNUSED_ARG (timeout);
00799   ACE_NOTSUP_RETURN (-1);
00800 #endif /* ACE_HAS_THREADS */
00801 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 804 of file OS_NS_Thread.inl.

References recursive_mutex_lock().

00806 {
00807   return timeout == 0
00808     ? ACE_OS::recursive_mutex_lock (m)
00809     : ACE_OS::recursive_mutex_lock (m, *timeout);
00810 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_trylock ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 813 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, EBUSY, thr_equal(), thr_self(), thread_mutex_lock(), thread_mutex_trylock(), and thread_mutex_unlock().

00814 {
00815 #if defined (ACE_HAS_THREADS)
00816 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00817   return ACE_OS::thread_mutex_trylock (m);
00818 #else
00819   ACE_thread_t t_id = ACE_OS::thr_self ();
00820   int result = 0;
00821 
00822   // Acquire the guard.
00823   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00824     result = -1;
00825   else
00826   {
00827       // If there's no contention, just grab the lock immediately.
00828     if (m->nesting_level_ == 0)
00829     {
00830       m->owner_id_ = t_id;
00831       m->nesting_level_ = 1;
00832     }
00833       // If we already own the lock, then increment the nesting level
00834       // and proceed.
00835     else if (ACE_OS::thr_equal (t_id, m->owner_id_))
00836       m->nesting_level_++;
00837     else
00838     {
00839       errno = EBUSY;
00840       result = -1;
00841     }
00842   }
00843 
00844   {
00845     // Save/restore errno.
00846     ACE_Errno_Guard error (errno);
00847     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00848   }
00849   return result;
00850 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00851 #else
00852   ACE_UNUSED_ARG (m);
00853   ACE_NOTSUP_RETURN (-1);
00854 #endif /* ACE_HAS_THREADS */
00855 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::recursive_mutex_unlock ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 858 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_signal(), NULL_thread, thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by recursive_mutex_cond_unlock().

00859 {
00860 #if defined (ACE_HAS_THREADS)
00861 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00862   return ACE_OS::thread_mutex_unlock (m);
00863 #  else
00864   ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock");
00865 #    if !defined (ACE_NDEBUG)
00866   ACE_thread_t t_id = ACE_OS::thr_self ();
00867 #    endif /* ACE_NDEBUG */
00868   int result = 0;
00869 
00870   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00871     result = -1;
00872   else
00873   {
00874 #    if !defined (ACE_NDEBUG)
00875       if (m->nesting_level_ == 0
00876           || ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00877 {
00878   errno = EINVAL;
00879   result = -1;
00880 }
00881       else
00882 #    endif /* ACE_NDEBUG */
00883 {
00884   m->nesting_level_--;
00885   if (m->nesting_level_ == 0)
00886   {
00887               // This may not be strictly necessary, but it does put
00888               // the mutex into a known state...
00889     m->owner_id_ = ACE_OS::NULL_thread;
00890 
00891               // Inform a waiter that the lock is free.
00892     if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00893       result = -1;
00894   }
00895 }
00896   }
00897 
00898 {
00899     // Save/restore errno.
00900   ACE_Errno_Guard error (errno);
00901   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00902 }
00903   return result;
00904 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00905 #else
00906   ACE_UNUSED_ARG (m);
00907   ACE_NOTSUP_RETURN (-1);
00908 #endif /* ACE_HAS_THREADS */
00909 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rw_rdlock ( ACE_rwlock_t rw  ) 

Definition at line 912 of file OS_NS_Thread.inl.

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

Referenced by rw_rdlock().

00913 {
00914   ACE_OS_TRACE ("ACE_OS::rw_rdlock");
00915 #if defined (ACE_HAS_THREADS)
00916 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00917 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00918   int result;
00919   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
00920                                        result),
00921                      int, -1);
00922 #  else /* Solaris */
00923   int result;
00924   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), result), int, -1);
00925 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00926 # else /* NT, POSIX, and VxWorks don't support this natively. */
00927 #   if defined (ACE_HAS_PTHREADS)
00928   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
00929 #   endif /* ACE_HAS_PTHREADS */
00930   int result = 0;
00931   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
00932     result = -1; // -1 means didn't get the mutex.
00933   else
00934     {
00935       // Give preference to writers who are waiting.
00936       while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0)
00937         {
00938           rw->num_waiting_readers_++;
00939           if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1)
00940             {
00941               result = -2; // -2 means that we need to release the mutex.
00942               break;
00943             }
00944           rw->num_waiting_readers_--;
00945         }
00946     }
00947   if (result == 0)
00948     rw->ref_count_++;
00949   if (result != -1)
00950     ACE_OS::mutex_unlock (&rw->lock_);
00951 #   if defined (ACE_HAS_PTHREADS)
00952   ACE_PTHREAD_CLEANUP_POP (0);
00953 #   endif /* defined (ACE_HAS_PTHREADS) */
00954   return 0;
00955 # endif /* ! ACE_LACKS_RWLOCK_T */
00956 #else
00957   ACE_UNUSED_ARG (rw);
00958   ACE_NOTSUP_RETURN (-1);
00959 #endif /* ACE_HAS_THREADS */
00960 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rw_tryrdlock ( ACE_rwlock_t rw  ) 

Definition at line 963 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_lock(), mutex_unlock(), and rw_tryrdlock().

Referenced by rw_tryrdlock().

00964 {
00965   ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
00966 #if defined (ACE_HAS_THREADS)
00967 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00968 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00969   int result;
00970   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
00971                                        result),
00972                      int, -1);
00973 #  else /* Solaris */
00974   int result;
00975   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), result), int, -1);
00976 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00977 # else /* NT, POSIX, and VxWorks don't support this natively. */
00978   int result = -1;
00979 
00980   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
00981     {
00982       ACE_Errno_Guard error (errno);
00983 
00984       if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0)
00985         {
00986           error = EBUSY;
00987           result = -1;
00988         }
00989       else
00990         {
00991           rw->ref_count_++;
00992           result = 0;
00993         }
00994 
00995       ACE_OS::mutex_unlock (&rw->lock_);
00996     }
00997   return result;
00998 # endif /* ! ACE_LACKS_RWLOCK_T */
00999 #else
01000   ACE_UNUSED_ARG (rw);
01001   ACE_NOTSUP_RETURN (-1);
01002 #endif /* ACE_HAS_THREADS */
01003 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rw_trywrlock ( ACE_rwlock_t rw  ) 

Definition at line 1006 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_lock(), mutex_unlock(), and rw_trywrlock().

Referenced by rw_trywrlock().

01007 {
01008   ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
01009 #if defined (ACE_HAS_THREADS)
01010 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01011 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01012   int result;
01013   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01014                                        result),
01015                      int, -1);
01016 #  else /* Solaris */
01017   int result;
01018   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), result), int, -1);
01019 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01020 # else /* NT, POSIX, and VxWorks don't support this natively. */
01021   int result = -1;
01022 
01023   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01024     {
01025       ACE_Errno_Guard error (errno);
01026 
01027       if (rw->ref_count_ != 0)
01028         {
01029           error = EBUSY;
01030           result = -1;
01031         }
01032       else
01033         {
01034           rw->ref_count_ = -1;
01035           result = 0;
01036         }
01037 
01038       ACE_OS::mutex_unlock (&rw->lock_);
01039     }
01040   return result;
01041 # endif /* ! ACE_LACKS_RWLOCK_T */
01042 #else
01043   ACE_UNUSED_ARG (rw);
01044   ACE_NOTSUP_RETURN (-1);
01045 #endif /* ACE_HAS_THREADS */
01046 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rw_trywrlock_upgrade ( ACE_rwlock_t rw  ) 

Definition at line 1055 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), EBUSY, mutex_lock(), and mutex_unlock().

01056 {
01057   ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
01058 #if defined (ACE_HAS_THREADS)
01059 # if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01060   // This will probably result in -1, EDEADLK, at least on HP-UX, but let it
01061   // go - it's a more descriptive error than ENOTSUP.
01062   int result;
01063   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01064                                        result),
01065                      int, -1);
01066 # elif !defined (ACE_LACKS_RWLOCK_T)
01067   // Some native rwlocks, such as those on Solaris, don't
01068   // support the upgrade feature . . .
01069   ACE_UNUSED_ARG (rw);
01070   ACE_NOTSUP_RETURN (-1);
01071 # else /* NT, POSIX, and VxWorks don't support this natively. */
01072   // The ACE rwlock emulation does support upgrade . . .
01073   int result = 0;
01074 
01075 #   if defined (ACE_HAS_PTHREADS)
01076   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01077 #   endif /* defined (ACE_HAS_PTHREADS) */
01078 
01079   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01080     return -1;
01081     // -1 means didn't get the mutex, error
01082   else if (rw->important_writer_)
01083     // an other reader upgrades already
01084     {
01085       result = -1;
01086       errno = EBUSY;
01087     }
01088   else
01089     {
01090       while (rw->ref_count_ > 1) // wait until only I am left
01091         {
01092           rw->num_waiting_writers_++; // prohibit any more readers
01093           rw->important_writer_ = 1;
01094 
01095           if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1)
01096             {
01097               result = -1;
01098               // we know that we have the lock again, we have this guarantee,
01099               // but something went wrong
01100             }
01101           rw->important_writer_ = 0;
01102           rw->num_waiting_writers_--;
01103         }
01104       if (result == 0)
01105         {
01106           // nothing bad happend
01107           rw->ref_count_ = -1;
01108           // now I am a writer
01109           // everything is O.K.
01110         }
01111     }
01112 
01113   ACE_OS::mutex_unlock (&rw->lock_);
01114 
01115 #   if defined (ACE_HAS_PTHREADS)
01116   ACE_PTHREAD_CLEANUP_POP (0);
01117 #   endif /* defined (ACE_HAS_PTHREADS) */
01118 
01119   return result;
01120 
01121 # endif /* ! ACE_LACKS_RWLOCK_T */
01122 #else
01123   ACE_UNUSED_ARG (rw);
01124   ACE_NOTSUP_RETURN (-1);
01125 #endif /* ACE_HAS_THREADS */
01126 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rw_unlock ( ACE_rwlock_t rw  ) 

Definition at line 1129 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), and rw_unlock().

Referenced by rw_unlock().

01130 {
01131   ACE_OS_TRACE ("ACE_OS::rw_unlock");
01132 #if defined (ACE_HAS_THREADS)
01133 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01134 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01135   int result;
01136   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
01137                                        result),
01138                      int, -1);
01139 #  else /* Solaris */
01140   int result;
01141   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), result), int, -1);
01142 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01143 # else /* NT, POSIX, and VxWorks don't support this natively. */
01144   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01145     return -1;
01146 
01147   if (rw->ref_count_ > 0) // Releasing a reader.
01148     rw->ref_count_--;
01149   else if (rw->ref_count_ == -1) // Releasing a writer.
01150     rw->ref_count_ = 0;
01151   else
01152     {
01153       (void) ACE_OS::mutex_unlock (&rw->lock_);
01154       return -1; // @@ ACE_ASSERT (!"count should not be 0!\n");
01155     }
01156 
01157   int result = 0;
01158   ACE_Errno_Guard error (errno);
01159 
01160   if (rw->important_writer_ && rw->ref_count_ == 1)
01161     // only the reader requesting to upgrade its lock is left over.
01162     {
01163       result = ACE_OS::cond_signal (&rw->waiting_important_writer_);
01164       error = errno;
01165     }
01166   else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0)
01167     // give preference to writers over readers...
01168     {
01169       result = ACE_OS::cond_signal (&rw->waiting_writers_);
01170       error =  errno;
01171     }
01172   else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0)
01173     {
01174       result = ACE_OS::cond_broadcast (&rw->waiting_readers_);
01175       error = errno;
01176     }
01177 
01178   (void) ACE_OS::mutex_unlock (&rw->lock_);
01179   return result;
01180 # endif /* ! ace_lacks_rwlock_t */
01181 #else
01182   ACE_UNUSED_ARG (rw);
01183   ACE_NOTSUP_RETURN (-1);
01184 #endif /* ace_has_threads */
01185 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rw_wrlock ( ACE_rwlock_t rw  ) 

Definition at line 1188 of file OS_NS_Thread.inl.

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

Referenced by rw_wrlock().

01189 {
01190   ACE_OS_TRACE ("ACE_OS::rw_wrlock");
01191 #if defined (ACE_HAS_THREADS)
01192 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01193 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01194   int result;
01195   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
01196                                        result),
01197                      int, -1);
01198 #  else /* Solaris */
01199   int result;
01200   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), result), int, -1);
01201 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01202 # else /* NT, POSIX, and VxWorks don't support this natively. */
01203 #   if defined (ACE_HAS_PTHREADS)
01204   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01205 #   endif /* defined (ACE_HAS_PTHREADS) */
01206   int result = 0;
01207 
01208   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01209     result = -1; // -1 means didn't get the mutex.
01210   else
01211     {
01212       while (rw->ref_count_ != 0)
01213         {
01214           rw->num_waiting_writers_++;
01215 
01216           if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1)
01217             {
01218               result = -2; // -2 means we need to release the mutex.
01219               break;
01220             }
01221 
01222           rw->num_waiting_writers_--;
01223         }
01224     }
01225   if (result == 0)
01226     rw->ref_count_ = -1;
01227   if (result != -1)
01228     ACE_OS::mutex_unlock (&rw->lock_);
01229 #   if defined (ACE_HAS_PTHREADS)
01230   ACE_PTHREAD_CLEANUP_POP (0);
01231 #   endif /* defined (ACE_HAS_PTHREADS) */
01232   return 0;
01233 # endif /* ! ACE_LACKS_RWLOCK_T */
01234 #else
01235   ACE_UNUSED_ARG (rw);
01236   ACE_NOTSUP_RETURN (-1);
01237 #endif /* ACE_HAS_THREADS */
01238 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rwlock_destroy ( ACE_rwlock_t rw  ) 

Definition at line 1241 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_destroy(), mutex_destroy(), and rwlock_destroy().

Referenced by rwlock_destroy().

01242 {
01243   ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
01244 #if defined (ACE_HAS_THREADS)
01245 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01246 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01247   int result;
01248   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
01249                                        result),
01250                      int, -1);
01251 #  else /* Solaris */
01252   int result;
01253   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), result), int, -1);
01254 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01255 # else /* NT, POSIX, and VxWorks don't support this natively. */
01256   ACE_OS::mutex_destroy (&rw->lock_);
01257   ACE_OS::cond_destroy (&rw->waiting_readers_);
01258   ACE_OS::cond_destroy (&rw->waiting_important_writer_);
01259   return ACE_OS::cond_destroy (&rw->waiting_writers_);
01260 # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */
01261 #else
01262   ACE_UNUSED_ARG (rw);
01263   ACE_NOTSUP_RETURN (-1);
01264 #endif /* ACE_HAS_THREADS */
01265 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_destroy ( ACE_sema_t s  ) 

Definition at line 1305 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, close(), cond_destroy(), event_destroy(), free(), mutex_destroy(), sema_destroy(), shm_unlink(), thread_mutex_destroy(), and unlink().

Referenced by event_destroy(), ACE_Semaphore::remove(), and sema_destroy().

01306 {
01307   ACE_OS_TRACE ("ACE_OS::sema_destroy");
01308 # if defined (ACE_HAS_POSIX_SEM)
01309   int result;
01310 #   if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01311   ACE_OS::mutex_destroy (&s->lock_);
01312   ACE_OS::cond_destroy (&s->count_nonzero_);
01313 #   endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01314 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01315   if (s->name_)
01316     {
01317       // Only destroy the semaphore if we're the ones who
01318       // initialized it.
01319       ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
01320       ACE_OS::shm_unlink (s->name_);
01321       delete s->name_;
01322       return result;
01323     }
01324 #   else
01325   if (s->name_)
01326     {
01327       ACE_OSCALL (::sem_unlink (s->name_), int, -1, result);
01328       ACE_OS::free ((void *) s->name_);
01329       ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
01330     }
01331 #   endif /*  ACE_LACKS_NAMED_POSIX_SEM */
01332   else
01333     {
01334       ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
01335 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01336       if (s->new_sema_)
01337 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
01338         delete s->sema_;
01339       s->sema_ = 0;
01340       return result;
01341     }
01342 # elif defined (ACE_USES_FIFO_SEM)
01343   int r0 = 0;
01344   if (s->name_)
01345     {
01346       r0 = ACE_OS::unlink (s->name_);
01347       ACE_OS::free (s->name_);
01348       s->name_ = 0;
01349     }
01350   int r1 = ACE_OS::close (s->fd_[0]);      /* ignore error */
01351   int r2 = ACE_OS::close (s->fd_[1]);      /* ignore error */
01352   return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0;
01353 # elif defined (ACE_HAS_THREADS)
01354 #   if defined (ACE_HAS_STHREADS)
01355   int result;
01356   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1);
01357 #   elif defined (ACE_HAS_PTHREADS)
01358   int r1 = ACE_OS::mutex_destroy (&s->lock_);
01359   int r2 = ACE_OS::cond_destroy (&s->count_nonzero_);
01360   return r1 != 0 || r2 != 0 ? -1 : 0;
01361 #   elif defined (ACE_HAS_WTHREADS)
01362 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01363   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1);
01364 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01365   // Free up underlying objects of the simulated semaphore.
01366   int r1 = ACE_OS::thread_mutex_destroy (&s->lock_);
01367   int r2 = ACE_OS::event_destroy (&s->count_nonzero_);
01368   return r1 != 0 || r2 != 0 ? -1 : 0;
01369 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01370 #   elif defined (ACE_VXWORKS)
01371   int result;
01372   ACE_OSCALL (::semDelete (s->sema_), int, -1, result);
01373   s->sema_ = 0;
01374   return result;
01375 #   endif /* ACE_HAS_STHREADS */
01376 # else
01377   ACE_UNUSED_ARG (s);
01378   ACE_NOTSUP_RETURN (-1);
01379 # endif /* ACE_HAS_POSIX_SEM */
01380 }

ACE_NAMESPACE_INLINE_FUNCTION 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 
)

Definition at line 1386 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_ALLOCATOR_RETURN, ACE_DEFAULT_FILE_PERMS, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, ACE_UNIQUE_NAME_LEN, close(), cond_destroy(), cond_init(), event_destroy(), event_init(), F_GETFL, fcntl(), ftruncate(), MAP_FAILED, MAXPATHLEN, mkfifo(), mmap(), mutex_destroy(), mutex_init(), mutex_lock(), mutex_unlock(), O_NONBLOCK, open(), PROT_RDWR, sema_init(), shm_open(), stat(), strcat(), strcpy(), strdup(), strrchr(), thread_mutex_destroy(), thread_mutex_init(), thread_mutex_lock(), thread_mutex_unlock(), uname(), unique_name(), unlink(), USYNC_PROCESS, USYNC_THREAD, and write().

Referenced by ACE_Semaphore::ACE_Semaphore(), event_init(), and sema_init().

01393 {
01394   ACE_OS_TRACE ("ACE_OS::sema_init");
01395 #if defined (ACE_HAS_POSIX_SEM)
01396   ACE_UNUSED_ARG (max);
01397   ACE_UNUSED_ARG (sa);
01398 
01399   s->name_ = 0;
01400 #  if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01401   ACE_UNUSED_ARG (arg);
01402 #  else
01403   int result = -1;
01404 
01405   if (ACE_OS::mutex_init (&s->lock_, type, name,
01406                           (ACE_mutexattr_t *) arg) == 0
01407       && ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) == 0
01408       && ACE_OS::mutex_lock (&s->lock_) == 0)
01409     {
01410       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01411         result = 0;
01412     }
01413 
01414   if (result == -1)
01415     {
01416       ACE_OS::mutex_destroy (&s->lock_);
01417       ACE_OS::cond_destroy (&s->count_nonzero_);
01418       return result;
01419     }
01420 #  endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01421 
01422 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01423   s->new_sema_ = false;
01424   if (type == USYNC_PROCESS)
01425     {
01426       // Let's see if it already exists.
01427       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01428                                         O_RDWR | O_CREAT | O_EXCL,
01429                                         ACE_DEFAULT_FILE_PERMS);
01430       if (fd == ACE_INVALID_HANDLE)
01431         {
01432           if (errno == EEXIST)
01433             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01434                                    O_RDWR | O_CREAT,
01435                                    ACE_DEFAULT_FILE_PERMS);
01436           else
01437             return -1;
01438         }
01439       else
01440         {
01441           // We own this shared memory object!  Let's set its
01442           // size.
01443           if (ACE_OS::ftruncate (fd,
01444                                  sizeof (ACE_sema_t)) == -1)
01445             return -1;
01446           s->name_ = ACE_OS::strdup (name);
01447           if (s->name_ == 0)
01448             return -1;
01449         }
01450       if (fd == -1)
01451         return -1;
01452 
01453       s->sema_ = (sem_t *)
01454         ACE_OS::mmap (0,
01455                       sizeof (ACE_sema_t),
01456                       PROT_RDWR,
01457                       MAP_SHARED,
01458                       fd,
01459                       0);
01460       ACE_OS::close (fd);
01461       if (s->sema_ == (sem_t *) MAP_FAILED)
01462         return -1;
01463       if (s->name_
01464           // @@ According UNIX Network Programming V2 by Stevens,
01465           //    sem_init() is currently not required to return zero on
01466           //    success, but it *does* return -1 upon failure.  For
01467           //    this reason, check for failure by comparing to -1,
01468           //    instead of checking for success by comparing to zero.
01469           //        -Ossama
01470           // Only initialize it if we're the one who created it.
01471           && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1)
01472         return -1;
01473       return 0;
01474     }
01475 #  else
01476   if (name)
01477     {
01478 #    if defined (sun) || defined (HPUX)
01479       // Solaris and HP-UX require the name to start with a slash. Solaris
01480       // further requires that there be no other slashes than the first.
01481       const char *last_slash = ACE_OS::strrchr (name, '/');
01482       char name2[MAXPATHLEN];
01483       if (0 == last_slash)
01484         {
01485           ACE_OS::strcpy (name2, "/");
01486           ACE_OS::strcat (name2, name);
01487           name = name2;
01488         }
01489 #      if defined (sun)
01490       else
01491         name = last_slash;         // Chop off chars preceding last slash
01492 #      endif /* sun */
01493 #    endif /* sun || HPUX */
01494 
01495       ACE_ALLOCATOR_RETURN (s->name_,
01496                             ACE_OS::strdup (name),
01497                             -1);
01498       s->sema_ = ::sem_open (s->name_,
01499                              O_CREAT,
01500                              ACE_DEFAULT_FILE_PERMS,
01501                              count);
01502       if (s->sema_ == (sem_t *) SEM_FAILED)
01503         return -1;
01504       else
01505         return 0;
01506     }
01507 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01508   else
01509     {
01510       ACE_NEW_RETURN (s->sema_,
01511                       sem_t,
01512                       -1);
01513 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01514       s->new_sema_ = true;
01515 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01516       ACE_OSCALL_RETURN (::sem_init (s->sema_,
01517                                      type != USYNC_THREAD,
01518                                      count), int, -1);
01519     }
01520 
01521 #elif defined (ACE_USES_FIFO_SEM)
01522   ACE_UNUSED_ARG (arg);
01523   ACE_UNUSED_ARG (max);
01524   ACE_UNUSED_ARG (sa);
01525   int             flags = 0;
01526   mode_t          mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;
01527 
01528   if (type == USYNC_THREAD)
01529     {
01530       // Create systemwide unique name for semaphore
01531       char   uname[ACE_UNIQUE_NAME_LEN];
01532       ACE_OS::unique_name ((const void *) s,
01533                             uname,
01534                             ACE_UNIQUE_NAME_LEN);
01535       name = &uname[0];
01536     }
01537 
01538   s->name_ = 0;
01539   s->fd_[0] = s->fd_[1] = ACE_INVALID_HANDLE;
01540   bool creator = false;
01541 
01542   if (ACE_OS::mkfifo (ACE_TEXT_CHAR_TO_TCHAR (name), mode) < 0)
01543     {
01544       if (errno != EEXIST)    /* already exists OK else ERR */
01545         return -1;
01546       // check if this is a real FIFO, not just some other existing file
01547       ACE_stat fs;
01548       if (ACE_OS::stat (name, &fs))
01549         return -1;
01550       if (!S_ISFIFO (fs.st_mode))
01551         {
01552           // existing file is not a FIFO
01553           errno = EEXIST;
01554           return -1;
01555         }
01556     }
01557     else
01558       creator = true; // remember we created it for initialization at end
01559 
01560   // for processshared semaphores remember who we are to be able to remove
01561   // the FIFO when we're done with it
01562   if (type == USYNC_PROCESS)
01563     {
01564       s->name_ = ACE_OS::strdup (name);
01565       if (s->name_ == 0)
01566         {
01567           if (creator)
01568             ACE_OS::unlink (name);
01569           return -1;
01570         }
01571     }
01572 
01573   if ((s->fd_[0] = ACE_OS::open (name, O_RDONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE
01574       || (s->fd_[1] = ACE_OS::open (name, O_WRONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE)
01575     return (-1);
01576 
01577   /* turn off nonblocking for fd_[0] */
01578   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01579     return (-1);
01580 
01581   flags &= ~O_NONBLOCK;
01582   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01583     return (-1);
01584 
01585   //if (s->name_ && count)
01586   if (creator && count)
01587     {
01588       char    c = 1;
01589       for (u_int i=0; i<count ;++i)
01590         if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) != 1)
01591           return (-1);
01592     }
01593 
01594   // In the case of process scope semaphores we can already unlink the FIFO now that
01595   // we completely set it up (the opened handles will keep it active until we close
01596   // thos down). This way we're protected against unexpected crashes as far as removal
01597   // is concerned.
01598   // Unfortunately this does not work for processshared FIFOs since as soon as we
01599   // have unlinked the semaphore no other process will be able to open it anymore.
01600   if (type == USYNC_THREAD)
01601     {
01602       ACE_OS::unlink (name);
01603     }
01604 
01605   return (0);
01606 #elif defined (ACE_HAS_THREADS)
01607 #  if defined (ACE_HAS_STHREADS)
01608   ACE_UNUSED_ARG (name);
01609   ACE_UNUSED_ARG (max);
01610   ACE_UNUSED_ARG (sa);
01611   int result;
01612   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), result),
01613                      int, -1);
01614 #  elif defined (ACE_HAS_PTHREADS)
01615   ACE_UNUSED_ARG (max);
01616   ACE_UNUSED_ARG (sa);
01617   int result = -1;
01618 
01619   if (ACE_OS::mutex_init (&s->lock_, type, name,
01620                           (ACE_mutexattr_t *) arg) == 0
01621       && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0
01622       && ACE_OS::mutex_lock (&s->lock_) == 0)
01623     {
01624       s->count_ = count;
01625       s->waiters_ = 0;
01626 
01627       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01628         result = 0;
01629     }
01630 
01631   if (result == -1)
01632     {
01633       ACE_OS::mutex_destroy (&s->lock_);
01634       ACE_OS::cond_destroy (&s->count_nonzero_);
01635     }
01636   return result;
01637 #  elif defined (ACE_HAS_WTHREADS)
01638 #    if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01639   ACE_UNUSED_ARG (type);
01640   ACE_UNUSED_ARG (arg);
01641   // Create the semaphore with its value initialized to <count> and
01642   // its maximum value initialized to <max>.
01643   SECURITY_ATTRIBUTES sa_buffer;
01644   SECURITY_DESCRIPTOR sd_buffer;
01645   *s = ::CreateSemaphoreA
01646     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01647      count,
01648      max,
01649      name);
01650 
01651   if (*s == 0)
01652     ACE_FAIL_RETURN (-1);
01653   /* NOTREACHED */
01654   else
01655     return 0;
01656 #    else /* ACE_USES_WINCE_SEMA_SIMULATION */
01657   int result = -1;
01658 
01659   // Initialize internal object for semaphore simulation.
01660   // Grab the lock as soon as possible when we initializing
01661   // the semaphore count.  Notice that we initialize the
01662   // event object as "manually reset" so we can amortize the
01663   // cost for singling/reseting the event.
01664   // @@ I changed the mutex type to thread_mutex.  Notice that this
01665   // is basically a CriticalSection object and doesn't not has
01666   // any security attribute whatsoever.  However, since this
01667   // semaphore implementation only works within a process, there
01668   // shouldn't any security issue at all.
01669   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01670       && ACE_OS::event_init (&s->count_nonzero_, 1,
01671                              count > 0, type, name, arg, sa) == 0
01672       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01673     {
01674       s->count_ = count;
01675 
01676       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01677         result = 0;
01678     }
01679 
01680   // Destroy the internal objects if we didn't initialize
01681   // either of them successfully.  Don't bother to check
01682   // for errors.
01683   if (result == -1)
01684     {
01685       ACE_OS::thread_mutex_destroy (&s->lock_);
01686       ACE_OS::event_destroy (&s->count_nonzero_);
01687     }
01688   return result;
01689 #    endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01690 #  elif defined (ACE_VXWORKS)
01691   ACE_UNUSED_ARG (name);
01692   ACE_UNUSED_ARG (arg);
01693   ACE_UNUSED_ARG (max);
01694   ACE_UNUSED_ARG (sa);
01695   s->name_ = 0;
01696   s->sema_ = ::semCCreate (type, count);
01697   return s->sema_ ? 0 : -1;
01698 #  endif /* ACE_HAS_STHREADS */
01699 #else
01700   ACE_UNUSED_ARG (s);
01701   ACE_UNUSED_ARG (count);
01702   ACE_UNUSED_ARG (type);
01703   ACE_UNUSED_ARG (name);
01704   ACE_UNUSED_ARG (arg);
01705   ACE_UNUSED_ARG (max);
01706   ACE_UNUSED_ARG (sa);
01707   ACE_NOTSUP_RETURN (-1);
01708 #endif /* ACE_HAS_POSIX_SEM */
01709 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_post ( ACE_sema_t s  ) 

Definition at line 1782 of file OS_NS_Thread.inl.

Referenced by event_init(), event_reset(), event_signal(), event_timedwait(), event_wait(), ACE_Semaphore::release(), and sema_post().

01783 {
01784   ACE_OS_TRACE ("ACE_OS::sema_post");
01785 # if defined (ACE_HAS_POSIX_SEM)
01786 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01787   ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1);
01788 #   else
01789   int result = -1;
01790 
01791   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01792     {
01793       if (::sem_post (s->sema_) == 0)
01794         result = ACE_OS::cond_signal (&s->count_nonzero_);
01795 
01796       ACE_OS::mutex_unlock (&s->lock_);
01797     }
01798   return result;
01799 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01800 # elif defined (ACE_USES_FIFO_SEM)
01801   char    c = 1;
01802   if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) == sizeof (char))
01803     return (0);
01804   return (-1);
01805 # elif defined (ACE_HAS_THREADS)
01806 #   if defined (ACE_HAS_STHREADS)
01807   int result;
01808   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), result), int, -1);
01809 #   elif defined (ACE_HAS_PTHREADS)
01810   int result = -1;
01811 
01812   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01813     {
01814       // Always allow a waiter to continue if there is one.
01815       if (s->waiters_ > 0)
01816         result = ACE_OS::cond_signal (&s->count_nonzero_);
01817       else
01818         result = 0;
01819 
01820       s->count_++;
01821       ACE_OS::mutex_unlock (&s->lock_);
01822     }
01823   return result;
01824 #   elif defined (ACE_HAS_WTHREADS)
01825 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01826   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
01827                                           ace_result_),
01828                         int, -1);
01829 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01830   int result = -1;
01831 
01832   // Since we are simulating semaphores, we need to update semaphore
01833   // count manually.  Grab the lock to prevent race condition first.
01834   if (ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01835     {
01836       // Check the original state of event object.  Single the event
01837       // object in transition from semaphore not available to
01838       // semaphore available.
01839       if (s->count_++ <= 0)
01840         result = ACE_OS::event_signal (&s->count_nonzero_);
01841       else
01842         result = 0;
01843 
01844       ACE_OS::thread_mutex_unlock (&s->lock_);
01845     }
01846   return result;
01847 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01848 #   elif defined (ACE_VXWORKS)
01849   ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1);
01850 #   endif /* ACE_HAS_STHREADS */
01851 # else
01852   ACE_UNUSED_ARG (s);
01853   ACE_NOTSUP_RETURN (-1);
01854 # endif /* ACE_HAS_POSIX_SEM */
01855 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_post ( ACE_sema_t s,
u_int  release_count 
)

Definition at line 1858 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, and sema_post().

01859 {
01860 #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01861   // Win32 supports this natively.
01862   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
01863                                           ace_result_), int, -1);
01864 #else
01865   // On POSIX platforms we need to emulate this ourselves.
01866   // @@ We can optimize on this implementation.  However,
01867   // the semaphore promitive on Win32 doesn't allow one
01868   // to increase a semaphore to more than the count it was
01869   // first initialized.  Posix and solaris don't seem to have
01870   // this restriction.  Should we impose the restriction in
01871   // our semaphore simulation?
01872   for (size_t i = 0; i < release_count; i++)
01873     if (ACE_OS::sema_post (s) == -1)
01874       return -1;
01875 
01876   return 0;
01877 #endif /* ACE_WIN32 */
01878 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_trywait ( ACE_sema_t s  ) 

Definition at line 1881 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, event_reset(), F_GETFL, fcntl(), mutex_lock(), mutex_unlock(), O_NONBLOCK, read(), sema_trywait(), set_errno_to_last_error(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by sema_trywait(), sema_wait(), and ACE_Semaphore::tryacquire().

01882 {
01883   ACE_OS_TRACE ("ACE_OS::sema_trywait");
01884 # if defined (ACE_HAS_POSIX_SEM)
01885   // POSIX semaphores set errno to EAGAIN if trywait fails
01886   ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1);
01887 # elif defined (ACE_USES_FIFO_SEM)
01888   char  c;
01889   int     rc, flags;
01890 
01891   /* turn on nonblocking for s->fd_[0] */
01892   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01893     return (-1);
01894   flags |= O_NONBLOCK;
01895   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01896     return (-1);
01897 
01898   // read sets errno to EAGAIN if no input
01899   rc = ACE_OS::read (s->fd_[0], &c, sizeof (char));
01900 
01901   /* turn off nonblocking for fd_[0] */
01902   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) >= 0)
01903   {
01904     flags &= ~O_NONBLOCK;
01905     ACE_OS::fcntl (s->fd_[0], F_SETFL, flags);
01906   }
01907 
01908   return rc == 1 ? 0 : (-1);
01909 # elif defined (ACE_HAS_THREADS)
01910 #   if defined (ACE_HAS_STHREADS)
01911   // STHREADS semaphores set errno to EBUSY if trywait fails.
01912   int result;
01913   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s),
01914                                        result),
01915                      int, -1);
01916 #   elif defined (ACE_HAS_PTHREADS)
01917 
01918   int result = -1;
01919 
01920   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01921     {
01922       if (s->count_ > 0)
01923         {
01924           --s->count_;
01925           result = 0;
01926         }
01927       else
01928         errno = EBUSY;
01929 
01930       ACE_OS::mutex_unlock (&s->lock_);
01931     }
01932   return result;
01933 #   elif defined (ACE_HAS_WTHREADS)
01934 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01935   DWORD result = ::WaitForSingleObject (*s, 0);
01936 
01937   if (result == WAIT_OBJECT_0)
01938     return 0;
01939   else
01940     {
01941       if (result == WAIT_TIMEOUT)
01942         errno = EBUSY;
01943       else
01944         ACE_OS::set_errno_to_last_error ();
01945       // This is a hack, we need to find an appropriate mapping...
01946       return -1;
01947     }
01948 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01949   // Check the status of semaphore first.  Return immediately
01950   // if the semaphore is not available and avoid grabing the
01951   // lock.
01952   DWORD result = ::WaitForSingleObject (s->count_nonzero_, 0);
01953 
01954   if (result == WAIT_OBJECT_0)  // Proceed when it is available.
01955     {
01956       ACE_OS::thread_mutex_lock (&s->lock_);
01957 
01958       // Need to double check if the semaphore is still available.
01959       // The double checking scheme will slightly affect the
01960       // efficiency if most of the time semaphores are not blocked.
01961       result = ::WaitForSingleObject (s->count_nonzero_, 0);
01962       if (result == WAIT_OBJECT_0)
01963         {
01964           // Adjust the semaphore count.  Only update the event
01965           // object status when the state changed.
01966           s->count_--;
01967           if (s->count_ <= 0)
01968             ACE_OS::event_reset (&s->count_nonzero_);
01969           result = 0;
01970         }
01971 
01972       ACE_OS::thread_mutex_unlock (&s->lock_);
01973     }
01974 
01975   // Translate error message to errno used by ACE.
01976   if (result == WAIT_TIMEOUT)
01977     errno = EBUSY;
01978   else
01979     ACE_OS::set_errno_to_last_error ();
01980   // This is taken from the hack above. ;)
01981   return -1;
01982 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01983 #   elif defined (ACE_VXWORKS)
01984   if (::semTake (s->sema_, NO_WAIT) == ERROR)
01985     if (errno == S_objLib_OBJ_UNAVAILABLE)
01986       {
01987         // couldn't get the semaphore
01988         errno = EBUSY;
01989         return -1;
01990       }
01991     else
01992       // error
01993       return -1;
01994   else
01995     // got the semaphore
01996     return 0;
01997 #   endif /* ACE_HAS_STHREADS */
01998 # else
01999   ACE_UNUSED_ARG (s);
02000   ACE_NOTSUP_RETURN (-1);
02001 # endif /* ACE_HAS_POSIX_SEM */
02002 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_wait ( ACE_sema_t s  ) 

Definition at line 2005 of file OS_NS_Thread.inl.

Referenced by ACE_Semaphore::acquire(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), and sema_wait().

02006 {
02007   ACE_OS_TRACE ("ACE_OS::sema_wait");
02008 # if defined (ACE_HAS_POSIX_SEM)
02009   ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1);
02010 # elif defined (ACE_USES_FIFO_SEM)
02011   char c;
02012   if (ACE_OS::read (s->fd_[0], &c, sizeof (char)) == 1)
02013     return (0);
02014   return (-1);
02015 # elif defined (ACE_HAS_THREADS)
02016 #   if defined (ACE_HAS_STHREADS)
02017   int result;
02018   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), result), int, -1);
02019 #   elif defined (ACE_HAS_PTHREADS)
02020   int result = 0;
02021 
02022   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02023 
02024   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02025     result = -1;
02026   else
02027     {
02028       // Keep track of the number of waiters so that we can signal
02029       // them properly in <ACE_OS::sema_post>.
02030       s->waiters_++;
02031 
02032       // Wait until the semaphore count is > 0.
02033       while (s->count_ == 0)
02034         if (ACE_OS::cond_wait (&s->count_nonzero_,
02035                                &s->lock_) == -1)
02036           {
02037             result = -2; // -2 means that we need to release the mutex.
02038             break;
02039           }
02040 
02041       --s->waiters_;
02042     }
02043 
02044   if (result == 0)
02045     --s->count_;
02046 
02047   if (result != -1)
02048     ACE_OS::mutex_unlock (&s->lock_);
02049   ACE_PTHREAD_CLEANUP_POP (0);
02050   return result < 0 ? -1 : result;
02051 
02052 #   elif defined (ACE_HAS_WTHREADS)
02053 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02054   switch (::WaitForSingleObject (*s, INFINITE))
02055     {
02056     case WAIT_OBJECT_0:
02057       return 0;
02058     default:
02059       // This is a hack, we need to find an appropriate mapping...
02060       ACE_OS::set_errno_to_last_error ();
02061       return -1;
02062     }
02063   /* NOTREACHED */
02064 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02065   // Timed wait.
02066   int result = -1;
02067   for (;;)
02068     // Check if the semaphore is avialable or not and wait forever.
02069     // Don't bother to grab the lock if it is not available (to avoid
02070     // deadlock.)
02071     switch (::WaitForSingleObject (s->count_nonzero_, INFINITE))
02072       {
02073       case WAIT_OBJECT_0:
02074         ACE_OS::thread_mutex_lock (&s->lock_);
02075 
02076         // Need to double check if the semaphore is still available.
02077         // This time, we shouldn't wait at all.
02078         if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02079           {
02080             // Decrease the internal counter.  Only update the event
02081             // object's status when the state changed.
02082             s->count_--;
02083             if (s->count_ <= 0)
02084               ACE_OS::event_reset (&s->count_nonzero_);
02085             result = 0;
02086           }
02087 
02088         ACE_OS::thread_mutex_unlock (&s->lock_);
02089         // if we didn't get a hold on the semaphore, the result won't
02090         // be 0 and thus, we'll start from the beginning again.
02091         if (result == 0)
02092           return 0;
02093         break;
02094 
02095       default:
02096         // Since we wait indefinitely, anything other than
02097         // WAIT_OBJECT_O indicates an error.
02098         ACE_OS::set_errno_to_last_error ();
02099         // This is taken from the hack above. ;)
02100         return -1;
02101       }
02102   /* NOTREACHED */
02103 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02104 #   elif defined (ACE_VXWORKS)
02105   ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1);
02106 #   endif /* ACE_HAS_STHREADS */
02107 # else
02108   ACE_UNUSED_ARG (s);
02109   ACE_NOTSUP_RETURN (-1);
02110 # endif /* ACE_HAS_POSIX_SEM */
02111 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_wait ( ACE_sema_t s,
ACE_Time_Value tv 
)

Definition at line 2114 of file OS_NS_Thread.inl.

02115 {
02116   ACE_OS_TRACE ("ACE_OS::sema_wait");
02117 # if defined (ACE_HAS_POSIX_SEM)
02118 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
02119   int rc;
02120   timespec_t ts;
02121   ts = tv; // Calls ACE_Time_Value::operator timespec_t().
02122   ACE_OSCALL (::sem_timedwait (s->sema_, &ts), int, -1, rc);
02123   if (rc == -1 && errno == ETIMEDOUT)
02124     errno = ETIME;  /* POSIX returns ETIMEDOUT but we need ETIME */
02125   return rc;
02126 #   elif !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
02127   int result = 0;
02128   bool expired = false;
02129   ACE_Errno_Guard error (errno);
02130 
02131   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02132 
02133   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02134     result = -2;
02135   else
02136     {
02137       bool finished = true;
02138       do
02139       {
02140         result = ACE_OS::sema_trywait (s);
02141         if (result == -1 && errno == EAGAIN)
02142           expired = ACE_OS::gettimeofday () > tv;
02143         else
02144           expired = false;
02145 
02146         finished = result != -1 || expired ||
02147                    (result == -1 && errno != EAGAIN);
02148         if (!finished)
02149           {
02150             if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02151                                         &s->lock_,
02152                                         &tv) == -1)
02153               {
02154                 error = errno;
02155                 result = -1;
02156                 break;
02157               }
02158           }
02159       } while (!finished);
02160 
02161       if (expired)
02162         error = ETIME;
02163 
02164 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02165       tv = ACE_OS::gettimeofday ();
02166 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02167     }
02168 
02169   if (result != -2)
02170     ACE_OS::mutex_unlock (&s->lock_);
02171   ACE_PTHREAD_CLEANUP_POP (0);
02172   return result < 0 ? -1 : result;
02173 #   else /* No native sem_timedwait(), and emulation disabled */
02174   ACE_UNUSED_ARG (s);
02175   ACE_UNUSED_ARG (tv);
02176   ACE_NOTSUP_RETURN (-1);
02177 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT */
02178 # elif defined (ACE_USES_FIFO_SEM)
02179   int rc;
02180   ACE_Time_Value now = ACE_OS::gettimeofday ();
02181 
02182   while (tv > now)
02183     {
02184       ACE_Time_Value timeout = tv;
02185       timeout -= now;
02186 
02187       ACE_Handle_Set  fds_;
02188 
02189       fds_.set_bit (s->fd_[0]);
02190       if ((rc = ACE_OS::select (ACE_Handle_Set::MAXSIZE, fds_, 0, 0, timeout)) != 1)
02191         {
02192           if (rc == 0 || errno != EAGAIN)
02193           {
02194             if (rc == 0)
02195               errno = ETIME;
02196             return (-1);
02197           }
02198         }
02199 
02200       // try to read the signal *but* do *not* block
02201       if (rc == 1 && ACE_OS::sema_trywait (s) == 0)
02202         return (0);
02203 
02204       // we were woken for input but someone beat us to it
02205       // so we wait again if there is still time
02206       now = ACE_OS::gettimeofday ();
02207     }
02208 
02209   // make sure errno is set right
02210   errno = ETIME;
02211 
02212   return (-1);
02213 # elif defined (ACE_HAS_THREADS)
02214 #   if defined (ACE_HAS_STHREADS)
02215   ACE_UNUSED_ARG (s);
02216   ACE_UNUSED_ARG (tv);
02217   ACE_NOTSUP_RETURN (-1);
02218 #   elif defined (ACE_HAS_PTHREADS)
02219   int result = 0;
02220   ACE_Errno_Guard error (errno);
02221 
02222   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02223 
02224   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02225     result = -1;
02226   else
02227     {
02228       // Keep track of the number of waiters so that we can signal
02229       // them properly in <ACE_OS::sema_post>.
02230       s->waiters_++;
02231 
02232       // Wait until the semaphore count is > 0 or until we time out.
02233       while (s->count_ == 0)
02234         if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02235                                     &s->lock_,
02236                                     &tv) == -1)
02237           {
02238             error = errno;
02239             result = -2; // -2 means that we need to release the mutex.
02240             break;
02241           }
02242 
02243       --s->waiters_;
02244     }
02245 
02246   if (result == 0)
02247     {
02248 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02249       tv = ACE_OS::gettimeofday ();
02250 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02251       --s->count_;
02252     }
02253 
02254   if (result != -1)
02255     ACE_OS::mutex_unlock (&s->lock_);
02256   ACE_PTHREAD_CLEANUP_POP (0);
02257   return result < 0 ? -1 : result;
02258 #   elif defined (ACE_HAS_WTHREADS)
02259 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02260   int msec_timeout;
02261 
02262   if (tv.sec () == 0 && tv.usec () == 0)
02263     msec_timeout = 0; // Do a "poll."
02264   else
02265     {
02266       // Note that we must convert between absolute time (which is
02267       // passed as a parameter) and relative time (which is what
02268       // <WaitForSingleObjects> expects).
02269       ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02270 
02271       // Watchout for situations where a context switch has caused the
02272       // current time to be > the timeout.
02273       if (relative_time < ACE_Time_Value::zero)
02274         msec_timeout = 0;
02275       else
02276         msec_timeout = relative_time.msec ();
02277     }
02278 
02279   switch (::WaitForSingleObject (*s, msec_timeout))
02280     {
02281     case WAIT_OBJECT_0:
02282       tv = ACE_OS::gettimeofday ();     // Update time to when acquired
02283       return 0;
02284     case WAIT_TIMEOUT:
02285       errno = ETIME;
02286       return -1;
02287     default:
02288       // This is a hack, we need to find an appropriate mapping...
02289       ACE_OS::set_errno_to_last_error ();
02290       return -1;
02291     }
02292   /* NOTREACHED */
02293 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02294   // Note that in this mode, the acquire is done in two steps, and
02295   // we may get signaled but cannot grab the semaphore before
02296   // timeout.  In that case, we'll need to restart the process with
02297   // updated timeout value.
02298 
02299   // tv is an absolute time, but we need relative to work with the Windows
02300   // API. Also, some users have become accustomed to using a 0 time value
02301   // as a shortcut for "now", which works on non-Windows because 0 is
02302   // always earlier than now. However, the need to convert to relative time
02303   // means we need to watch out for this case.
02304   ACE_Time_Value end_time = tv;
02305   if (tv == ACE_Time_Value::zero)
02306     end_time = ACE_OS::gettimeofday ();
02307   ACE_Time_Value relative_time = end_time - ACE_OS::gettimeofday ();
02308   int result = -1;
02309 
02310   // While we are not timeout yet. >= 0 will let this go through once
02311   // and if not able to get the object, it should hit WAIT_TIMEOUT
02312   // right away.
02313   while (relative_time >= ACE_Time_Value::zero)
02314     {
02315       // Wait for our turn to get the object.
02316       switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ()))
02317         {
02318         case WAIT_OBJECT_0:
02319           ACE_OS::thread_mutex_lock (&s->lock_);
02320 
02321           // Need to double check if the semaphore is still available.
02322           // We can only do a "try lock" styled wait here to avoid
02323           // blocking threads that want to signal the semaphore.
02324           if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02325             {
02326               // As before, only reset the object when the semaphore
02327               // is no longer available.
02328               s->count_--;
02329               if (s->count_ <= 0)
02330                 ACE_OS::event_reset (&s->count_nonzero_);
02331               result = 0;
02332             }
02333 
02334           ACE_OS::thread_mutex_unlock (&s->lock_);
02335 
02336           // Only return when we successfully get the semaphore.
02337           if (result == 0)
02338             {
02339               tv = ACE_OS::gettimeofday ();     // Update to time acquired
02340               return 0;
02341             }
02342           break;
02343 
02344           // We have timed out.
02345         case WAIT_TIMEOUT:
02346           errno = ETIME;
02347           return -1;
02348 
02349           // What?
02350         default:
02351           ACE_OS::set_errno_to_last_error ();
02352           // This is taken from the hack above. ;)
02353           return -1;
02354         };
02355 
02356       // Haven't been able to get the semaphore yet, update the
02357       // timeout value to reflect the remaining time we want to wait.
02358       relative_time = end_time - ACE_OS::gettimeofday ();
02359     }
02360 
02361   // We have timed out.
02362   errno = ETIME;
02363   return -1;
02364 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02365 #   elif defined (ACE_VXWORKS)
02366   // Note that we must convert between absolute time (which is
02367   // passed as a parameter) and relative time (which is what
02368   // the system call expects).
02369   ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02370 
02371   int ticks_per_sec = ::sysClkRateGet ();
02372 
02373   int ticks = relative_time.sec () * ticks_per_sec +
02374               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02375   if (::semTake (s->sema_, ticks) == ERROR)
02376     {
02377       if (errno == S_objLib_OBJ_TIMEOUT)
02378         // Convert the VxWorks errno to one that's common for to ACE
02379         // platforms.
02380         errno = ETIME;
02381       else if (errno == S_objLib_OBJ_UNAVAILABLE)
02382         errno = EBUSY;
02383       return -1;
02384     }
02385   else
02386     {
02387       tv = ACE_OS::gettimeofday ();  // Update to time acquired
02388       return 0;
02389     }
02390 #   endif /* ACE_HAS_STHREADS */
02391 # else
02392   ACE_UNUSED_ARG (s);
02393   ACE_UNUSED_ARG (tv);
02394   ACE_NOTSUP_RETURN (-1);
02395 # endif /* ACE_HAS_POSIX_SEM */
02396 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sema_wait ( ACE_sema_t s,
ACE_Time_Value tv 
)

Definition at line 2399 of file OS_NS_Thread.inl.

References sema_wait().

02400 {
02401   return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
02402 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::semctl ( int  int_id,
int  semnum,
int  cmd,
semun   
)

Definition at line 2405 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semctl().

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

02406 {
02407   ACE_OS_TRACE ("ACE_OS::semctl");
02408 #if defined (ACE_HAS_SYSV_IPC)
02409   ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1);
02410 #else
02411   ACE_UNUSED_ARG (int_id);
02412   ACE_UNUSED_ARG (semnum);
02413   ACE_UNUSED_ARG (cmd);
02414   ACE_UNUSED_ARG (value);
02415 
02416   ACE_NOTSUP_RETURN (-1);
02417 #endif /* ACE_HAS_SYSV_IPC */
02418 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::semget ( key_t  key,
int  nsems,
int  flags 
)

Definition at line 2421 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semget().

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

02422 {
02423   ACE_OS_TRACE ("ACE_OS::semget");
02424 #if defined (ACE_HAS_SYSV_IPC)
02425   ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1);
02426 #else
02427   ACE_UNUSED_ARG (key);
02428   ACE_UNUSED_ARG (nsems);
02429   ACE_UNUSED_ARG (flags);
02430 
02431   ACE_NOTSUP_RETURN (-1);
02432 #endif /* ACE_HAS_SYSV_IPC */
02433 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::semop ( int  int_id,
struct sembuf *  sops,
size_t  nsops 
)

Definition at line 2436 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semop().

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

02437 {
02438   ACE_OS_TRACE ("ACE_OS::semop");
02439 #if defined (ACE_HAS_SYSV_IPC)
02440   ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1);
02441 #else
02442   ACE_UNUSED_ARG (int_id);
02443   ACE_UNUSED_ARG (sops);
02444   ACE_UNUSED_ARG (nsops);
02445 
02446   ACE_NOTSUP_RETURN (-1);
02447 #endif /* ACE_HAS_SYSV_IPC */
02448 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sigtimedwait ( const sigset_t *  set,
siginfo_t info,
const ACE_Time_Value timeout 
)

Definition at line 2451 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sigtimedwait().

Referenced by sigtimedwait(), and sigwait().

02454 {
02455   ACE_OS_TRACE ("ACE_OS::sigtimedwait");
02456 #if defined (ACE_HAS_SIGTIMEDWAIT)
02457   timespec_t ts;
02458   timespec_t *tsp;
02459 
02460   if (timeout != 0)
02461     {
02462       ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
02463       tsp = &ts;
02464     }
02465   else
02466     tsp = 0;
02467 
02468   ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp),
02469                      int, -1);
02470 #else
02471     ACE_UNUSED_ARG (sset);
02472     ACE_UNUSED_ARG (info);
02473     ACE_UNUSED_ARG (timeout);
02474     ACE_NOTSUP_RETURN (-1);
02475 #endif /* ACE_HAS_SIGTIMEDWAIT */
02476 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sigwait ( sigset_t *  set,
int *  sig = 0 
)

Definition at line 2479 of file OS_NS_Thread.inl.

Referenced by sigwait().

02480 {
02481   ACE_OS_TRACE ("ACE_OS::sigwait");
02482   int local_sig;
02483   if (sig == 0)
02484     sig = &local_sig;
02485 #if defined (ACE_HAS_THREADS)
02486 # if (defined (__FreeBSD__) && (__FreeBSD__ < 3))
02487     ACE_UNUSED_ARG (sset);
02488     ACE_NOTSUP_RETURN (-1);
02489 # elif defined (ACE_HAS_STHREADS)
02490    # if (_POSIX_C_SOURCE - 0 >= 199506L) || defined (_POSIX_PTHREAD_SEMANTICS)
02491      errno = ::sigwait (sset, sig);
02492      return errno == 0  ?  *sig  :  -1;
02493    #else
02494      *sig = ::sigwait (sset);
02495      return *sig;
02496    #endif /* _POSIX_C_SOURCE - 0 >= 199506L || _POSIX_PTHREAD_SEMANTICS */
02497 # elif defined (ACE_HAS_PTHREADS)
02498   // LynxOS and Digital UNIX have their own hoops to jump through.
02499 #   if defined (__Lynx__)
02500     // Second arg is a void **, which we don't need (the selected
02501     // signal number is returned).
02502     *sig = ::sigwait (sset, 0);
02503     return *sig;
02504 #   elif defined (DIGITAL_UNIX)  &&  defined (__DECCXX_VER)
02505       // DEC cxx (but not g++) needs this direct call to its internal
02506       // sigwait ().  This allows us to #undef sigwait, so that we can
02507       // have ACE_OS::sigwait.  cxx gets confused by ACE_OS::sigwait
02508       // if sigwait is _not_ #undef'ed.
02509       errno = ::_Psigwait (sset, sig);
02510       return errno == 0  ?  *sig  :  -1;
02511 #   else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02512 #     if defined (CYGWIN32)
02513         // Cygwin has sigwait definition, but it is not implemented
02514         ACE_UNUSED_ARG (sset);
02515         ACE_NOTSUP_RETURN (-1);
02516 #     elif defined (ACE_TANDEM_T1248_PTHREADS)
02517         errno = ::spt_sigwait (sset, sig);
02518         return errno == 0  ?  *sig  :  -1;
02519 #     else   /* this is draft 7 or std */
02520         errno = ::sigwait (sset, sig);
02521         return errno == 0  ?  *sig  :  -1;
02522 #     endif /* CYGWIN32 */
02523 #   endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02524 # elif defined (ACE_HAS_WTHREADS)
02525     ACE_UNUSED_ARG (sset);
02526     ACE_NOTSUP_RETURN (-1);
02527 # elif defined (ACE_VXWORKS)
02528     // Second arg is a struct siginfo *, which we don't need (the
02529     // selected signal number is returned).  Third arg is timeout:  0
02530     // means forever.
02531     *sig = ::sigtimedwait (sset, 0, 0);
02532     return *sig;
02533 # endif /* __FreeBSD__ */
02534 #else
02535     ACE_UNUSED_ARG (sset);
02536     ACE_UNUSED_ARG (sig);
02537     ACE_NOTSUP_RETURN (-1);
02538 #endif /* ACE_HAS_THREADS */
02539 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sigwaitinfo ( const sigset_t *  set,
siginfo_t info 
)

Definition at line 2542 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sigwaitinfo().

Referenced by sigwaitinfo().

02544 {
02545   ACE_OS_TRACE ("ACE_OS::sigwaitinfo");
02546   // If this platform has sigtimedwait, it should have sigwaitinfo as well.
02547   // If this isn't true somewhere, let me know and I'll fix this.
02548   // -Steve Huston <shuston@riverace.com>.
02549 #if defined (ACE_HAS_SIGTIMEDWAIT)
02550   ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1);
02551 #else
02552   ACE_UNUSED_ARG (sset);
02553   ACE_UNUSED_ARG (info);
02554   ACE_NOTSUP_RETURN (-1);
02555 #endif /* ACE_HAS_SIGTIMEDWAIT */
02556 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_cancel ( ACE_thread_t  t_id  ) 

Definition at line 2559 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::cancel().

02560 {
02561   ACE_OS_TRACE ("ACE_OS::thr_cancel");
02562 #if defined (ACE_HAS_THREADS)
02563 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02564   int result;
02565   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02566                                         result),
02567                       int, -1);
02568 # elif defined (ACE_HAS_VXTHREADS)
02569   ACE_OSCALL_RETURN (::taskDelete (thr_id), int, -1);
02570 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
02571   ACE_UNUSED_ARG (thr_id);
02572   ACE_NOTSUP_RETURN (-1);
02573 # endif /* ACE_HAS_PTHREADS */
02574 #else
02575   ACE_UNUSED_ARG (thr_id);
02576   ACE_NOTSUP_RETURN (-1);
02577 #endif /* ACE_HAS_THREADS */
02578 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_cmp ( ACE_hthread_t  t1,
ACE_hthread_t  t2 
)

Definition at line 2581 of file OS_NS_Thread.inl.

Referenced by ACE_Thread_Manager::find_hthread(), ACE_Thread_Manager::hthread_within(), ACE_Thread_Descriptor_Base::operator==(), and ACE_Thread_ID::operator==().

02582 {
02583 #if defined (ACE_HAS_PTHREADS)
02584 # if defined (pthread_equal)
02585   // If it's a macro we can't say "pthread_equal"...
02586   return pthread_equal (t1, t2);
02587 # else
02588   return pthread_equal (t1, t2);
02589 # endif /* pthread_equal */
02590 #else /* For STHREADS, WTHREADS, and VXWORKS ... */
02591   // Hum, Do we need to treat WTHREAD differently?
02592   // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE.
02593   return t1 == t2;
02594 #endif /* ACE_HAS_PTHREADS */
02595 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_continue ( ACE_hthread_t  target_thread  ) 

Definition at line 2598 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_continue().

Referenced by ACE_Thread::resume(), thr_continue(), and thr_create().

02599 {
02600   ACE_OS_TRACE ("ACE_OS::thr_continue");
02601 #if defined (ACE_HAS_THREADS)
02602 # if defined (ACE_HAS_STHREADS)
02603   int result;
02604   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), result), int, -1);
02605 # elif defined (ACE_HAS_PTHREADS)
02606 #  if defined (ACE_HAS_PTHREAD_CONTINUE)
02607   int result;
02608   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread),
02609                                        result),
02610                      int, -1);
02611 #  elif defined (ACE_HAS_PTHREAD_CONTINUE_NP)
02612   int result;
02613   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue_np (target_thread),
02614                                        result),
02615                      int, -1);
02616 #  elif defined (ACE_HAS_PTHREAD_RESUME_NP)
02617   int result;
02618   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_resume_np (target_thread),
02619                                        result),
02620                      int, -1);
02621 #  else
02622   ACE_UNUSED_ARG (target_thread);
02623   ACE_NOTSUP_RETURN (-1);
02624 #  endif /* ACE_HAS_PTHREAD_CONTINUE */
02625 # elif defined (ACE_HAS_WTHREADS)
02626   DWORD result = ::ResumeThread (target_thread);
02627   if (result == ACE_SYSCALL_FAILED)
02628     ACE_FAIL_RETURN (-1);
02629   else
02630     return 0;
02631 # elif defined (ACE_HAS_VXTHREADS)
02632   ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1);
02633 # endif /* ACE_HAS_STHREADS */
02634 #else
02635   ACE_UNUSED_ARG (target_thread);
02636   ACE_NOTSUP_RETURN (-1);
02637 #endif /* ACE_HAS_THREADS */
02638 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_equal ( ACE_thread_t  t1,
ACE_thread_t  t2 
)

Definition at line 108 of file OS_NS_Thread.inl.

Referenced by ACE_Thread_Manager::check_state(), ACE_Thread_Manager::find_thread(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events(), ACE_Thread_Manager::join(), ACE_Thread_Descriptor_Base::operator==(), ACE_Thread_ID::operator==(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), ACE_Thread_Manager::thr_state(), ACE_Thread_Manager::thread_within(), ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager(), and ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager().

00109 {
00110 #if defined (ACE_HAS_PTHREADS)
00111 # if defined (pthread_equal)
00112   // If it's a macro we can't say "pthread_equal"...
00113   return pthread_equal (t1, t2);
00114 # else
00115   return pthread_equal (t1, t2);
00116 # endif /* pthread_equal */
00117 #else /* For both STHREADS and WTHREADS... */
00118   // Hum, Do we need to treat WTHREAD differently?
00119   // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD.
00120   return t1 == t2;
00121 #endif /* ACE_HAS_PTHREADS */
00122 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_getconcurrency ( void   ) 

Definition at line 2641 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_getconcurrency().

Referenced by ACE_Thread::getconcurrency(), thr_create(), and thr_getconcurrency().

02642 {
02643   ACE_OS_TRACE ("ACE_OS::thr_getconcurrency");
02644 #if defined (ACE_HAS_THREADS)
02645 # if defined (ACE_HAS_STHREADS)
02646   return ::thr_getconcurrency ();
02647 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_GETCONCURRENCY)
02648   return pthread_getconcurrency ();
02649 # else
02650   ACE_NOTSUP_RETURN (-1);
02651 # endif /* ACE_HAS_STHREADS */
02652 #else
02653   ACE_NOTSUP_RETURN (-1);
02654 #endif /* ACE_HAS_THREADS */
02655 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_getprio ( ACE_hthread_t  id,
int &  priority 
)

Definition at line 2715 of file OS_NS_Thread.inl.

Referenced by ACE_Thread::getprio(), ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), and thr_getprio().

02716 {
02717   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02718   int policy = 0;
02719   return ACE_OS::thr_getprio (ht_id, priority, policy);
02720 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_getprio ( ACE_hthread_t  id,
int &  priority,
int &  policy 
)

Definition at line 2658 of file OS_NS_Thread.inl.

02659 {
02660   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02661   ACE_UNUSED_ARG (policy);
02662 #if defined (ACE_HAS_THREADS)
02663 # if (defined (ACE_HAS_PTHREADS) && \
02664      (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
02665 
02666   struct sched_param param;
02667   int result;
02668 
02669   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
02670                                 result), int,
02671               -1, result);
02672   priority = param.sched_priority;
02673   return result;
02674 # elif defined (ACE_HAS_STHREADS)
02675   int result;
02676   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (ht_id, &priority), result), int, -1);
02677 # elif defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE)
02678   ACE_Errno_Guard error (errno);
02679 
02680   priority = ::GetThreadPriority (ht_id);
02681 
02682 #   if defined (ACE_HAS_PHARLAP)
02683 #     if defined (ACE_PHARLAP_LABVIEW_RT)
02684   policy = ACE_SCHED_FIFO;
02685 #     else
02686   DWORD timeslice = ::EtsGetTimeSlice ();
02687   policy = timeslice == 0 ? ACE_SCHED_OTHER : ACE_SCHED_FIFO;
02688 #     endif /* ACE_PHARLAP_LABVIEW_RT */
02689 #   else
02690   DWORD priority_class = ::GetPriorityClass (::GetCurrentProcess ());
02691   if (priority_class == 0 && (error = ::GetLastError ()) != NO_ERROR)
02692     ACE_FAIL_RETURN (-1);
02693 
02694   policy =
02695     (priority_class ==
02696      REALTIME_PRIORITY_CLASS) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER;
02697 #   endif /* ACE_HAS_PHARLAP */
02698 
02699   return 0;
02700 # elif defined (ACE_HAS_VXTHREADS)
02701   ACE_OSCALL_RETURN (::taskPriorityGet (ht_id, &priority), int, -1);
02702 # else
02703   ACE_UNUSED_ARG (ht_id);
02704   ACE_UNUSED_ARG (priority);
02705   ACE_NOTSUP_RETURN (-1);
02706 # endif /* ACE_HAS_STHREADS */
02707 #else
02708   ACE_UNUSED_ARG (ht_id);
02709   ACE_UNUSED_ARG (priority);
02710   ACE_NOTSUP_RETURN (-1);
02711 #endif /* ACE_HAS_THREADS */
02712 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_getspecific ( ACE_thread_key_t  key,
void **  data 
)

Definition at line 2751 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Thread::getspecific().

02752 {
02753 //   ACE_OS_TRACE ("ACE_OS::thr_getspecific");
02754 #if defined (ACE_HAS_THREADS)
02755 # if defined (ACE_HAS_TSS_EMULATION)
02756     if (ACE_TSS_Emulation::is_key (key) == 0)
02757       {
02758         errno = EINVAL;
02759         data = 0;
02760         return -1;
02761       }
02762     else
02763       {
02764         *data = ACE_TSS_Emulation::ts_object (key);
02765         return 0;
02766       }
02767 # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
02768   return ACE_OS::thr_getspecific_native (key, data);
02769 #else
02770   ACE_UNUSED_ARG (key);
02771   ACE_UNUSED_ARG (data);
02772   ACE_NOTSUP_RETURN (-1);
02773 # endif /* ACE_HAS_TSS_EMULATION */
02774 #else
02775   ACE_UNUSED_ARG (key);
02776   ACE_UNUSED_ARG (data);
02777   ACE_NOTSUP_RETURN (-1);
02778 #endif /* ACE_HAS_THREADS */
02779 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_join ( ACE_hthread_t  waiter_id,
ACE_THR_FUNC_RETURN *  status 
)

Definition at line 2783 of file OS_NS_Thread.inl.

Referenced by ACE_Thread::join(), and thr_join().

02785 {
02786   ACE_OS_TRACE ("ACE_OS::thr_join");
02787 #if defined (ACE_HAS_THREADS)
02788 # if defined (ACE_HAS_STHREADS)
02789   int result;
02790   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result),
02791                      int, -1);
02792 # elif defined (ACE_HAS_PTHREADS)
02793   int result;
02794   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result),
02795                      int, -1);
02796 # elif defined (ACE_HAS_WTHREADS)
02797   ACE_THR_FUNC_RETURN local_status = 0;
02798 
02799   // Make sure that status is non-NULL.
02800   if (status == 0)
02801     status = &local_status;
02802 
02803   if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0
02804       && ::GetExitCodeThread (thr_handle, status) != FALSE)
02805     {
02806       ::CloseHandle (thr_handle);
02807       return 0;
02808     }
02809   ACE_FAIL_RETURN (-1);
02810   /* NOTREACHED */
02811 # else
02812   ACE_UNUSED_ARG (thr_handle);
02813   ACE_UNUSED_ARG (status);
02814   ACE_NOTSUP_RETURN (-1);
02815 # endif /* ACE_HAS_STHREADS */
02816 #else
02817   ACE_UNUSED_ARG (thr_handle);
02818   ACE_UNUSED_ARG (status);
02819   ACE_NOTSUP_RETURN (-1);
02820 #endif /* ACE_HAS_THREADS */
02821 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_join ( ACE_thread_t  waiter_id,
ACE_thread_t thr_id,
ACE_THR_FUNC_RETURN *  status 
)

Definition at line 2824 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

02827 {
02828   ACE_OS_TRACE ("ACE_OS::thr_join");
02829 #if defined (ACE_HAS_THREADS)
02830 # if defined (ACE_HAS_STHREADS)
02831   int result;
02832   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result),
02833                      int, -1);
02834 # elif defined (ACE_HAS_PTHREADS)
02835   ACE_UNUSED_ARG (thr_id);
02836   int result;
02837   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result),
02838                      int, -1);
02839 # elif defined (ACE_HAS_WTHREADS)
02840   ACE_UNUSED_ARG (waiter_id);
02841   ACE_UNUSED_ARG (thr_id);
02842   ACE_UNUSED_ARG (status);
02843 
02844   // This could be implemented if the DLL-Main function or the
02845   // task exit base class some log the threads which have exited
02846   ACE_NOTSUP_RETURN (-1);
02847 # endif /* ACE_HAS_STHREADS */
02848 #else
02849   ACE_UNUSED_ARG (waiter_id);
02850   ACE_UNUSED_ARG (thr_id);
02851   ACE_UNUSED_ARG (status);
02852   ACE_NOTSUP_RETURN (-1);
02853 #endif /* ACE_HAS_THREADS */
02854 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_kill ( ACE_thread_t  thr_id,
int  signum 
)

Definition at line 2858 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, kill(), and thr_kill().

Referenced by ACE_Thread::kill(), and thr_kill().

02859 {
02860   ACE_OS_TRACE ("ACE_OS::thr_kill");
02861 #if defined (ACE_HAS_THREADS)
02862 # if defined (ACE_HAS_PTHREADS)
02863 #   if defined (ACE_LACKS_PTHREAD_KILL)
02864   ACE_UNUSED_ARG (signum);
02865   ACE_UNUSED_ARG (thr_id);
02866   ACE_NOTSUP_RETURN (-1);
02867 #   else
02868   int result;
02869   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_kill (thr_id, signum),
02870                                        result),
02871                      int, -1);
02872 #   endif /* ACE_LACKS_PTHREAD_KILL */
02873 # elif defined (ACE_HAS_STHREADS)
02874   int result;
02875   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum),
02876                                        result),
02877                      int, -1);
02878 # elif defined (ACE_HAS_VXTHREADS)
02879   //FUZZ: disable check_for_lack_ACE_OS
02880   ACE_OSCALL_RETURN (::kill (thr_id, signum), int, -1);
02881   //FUZZ: enable check_for_lack_ACE_OS
02882 # else
02883   ACE_UNUSED_ARG (thr_id);
02884   ACE_UNUSED_ARG (signum);
02885   ACE_NOTSUP_RETURN (-1);
02886 # endif /* ACE_HAS_STHREADS */
02887 #else
02888   ACE_UNUSED_ARG (thr_id);
02889   ACE_UNUSED_ARG (signum);
02890   ACE_NOTSUP_RETURN (-1);
02891 #endif /* ACE_HAS_THREADS */
02892 }

ACE_NAMESPACE_INLINE_FUNCTION size_t ACE_OS::thr_min_stack ( void   ) 

Definition at line 2895 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, sysconf(), thr_min_stack(), and thr_self().

Referenced by thr_min_stack().

02896 {
02897   ACE_OS_TRACE ("ACE_OS::thr_min_stack");
02898 #if defined (ACE_HAS_THREADS)
02899 # if defined (ACE_HAS_STHREADS)
02900 #   if defined (ACE_HAS_THR_MINSTACK)
02901   // Tandem did some weirdo mangling of STHREAD names...
02902   return ::thr_minstack ();
02903 #   else
02904   return ::thr_min_stack ();
02905 #   endif /* !ACE_HAS_THR_MINSTACK */
02906 # elif defined (ACE_HAS_PTHREADS)
02907 #   if defined (_SC_THREAD_STACK_MIN)
02908   return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
02909 #   elif defined (PTHREAD_STACK_MIN)
02910   return PTHREAD_STACK_MIN;
02911 #   else
02912   ACE_NOTSUP_RETURN (0);
02913 #   endif /* _SC_THREAD_STACK_MIN */
02914 # elif defined (ACE_HAS_WTHREADS)
02915   ACE_NOTSUP_RETURN (0);
02916 # elif defined (ACE_HAS_VXTHREADS)
02917   TASK_DESC taskDesc;
02918   STATUS status;
02919 
02920   ACE_thread_t tid = ACE_OS::thr_self ();
02921 
02922   ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc),
02923                                 status),
02924               STATUS, -1, status);
02925   return status == OK ? taskDesc.td_stackSize : 0;
02926 # else /* Should not happen... */
02927   ACE_NOTSUP_RETURN (0);
02928 # endif /* ACE_HAS_STHREADS */
02929 #else
02930   ACE_NOTSUP_RETURN (0);
02931 #endif /* ACE_HAS_THREADS */
02932 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_thread_t ACE_OS::thr_self ( void   ) 

Definition at line 2935 of file OS_NS_Thread.inl.

Referenced by ACE_Thread_Control::ACE_Thread_Control(), ACE_Thread_ID::ACE_Thread_ID(), ACE_Thread_Manager::check_state(), ACE_Thread_Manager::exit(), ACE_Thread_Control::insert(), ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sched_params(), ACE_Thread::self(), thr_create(), thr_exit(), thr_min_stack(), thr_name(), thr_self(), thr_setprio(), ACE_Thread_Manager::thr_state(), ACE_Thread_Manager::thread_desc_self(), ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager(), and ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager().

02936 {
02937   // ACE_OS_TRACE ("ACE_OS::thr_self");
02938 #if defined (ACE_HAS_THREADS)
02939 # if defined (ACE_HAS_PTHREADS)
02940   // Note, don't use "::" here since the following call is often a macro.
02941   return pthread_self ();
02942 # elif defined (ACE_HAS_STHREADS)
02943   ACE_OSCALL_RETURN (::thr_self (), int, -1);
02944 # elif defined (ACE_HAS_WTHREADS)
02945   return ::GetCurrentThreadId ();
02946 # elif defined (ACE_HAS_VXTHREADS)
02947   return ::taskIdSelf ();
02948 # endif /* ACE_HAS_STHREADS */
02949 #else
02950   return 1; // Might as well make it the first thread ;-)
02951 #endif /* ACE_HAS_THREADS */
02952 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::thr_self ( ACE_hthread_t  ) 

Definition at line 2969 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, and thr_self().

02970 {
02971   ACE_OS_TRACE ("ACE_OS::thr_self");
02972 #if defined (ACE_HAS_THREADS)
02973 # if defined (ACE_HAS_PTHREADS)
02974   // Note, don't use "::" here since the following call is often a macro.
02975   self = pthread_self ();
02976 # elif defined (ACE_HAS_THREAD_SELF)
02977   self = ::thread_self ();
02978 # elif defined (ACE_HAS_STHREADS)
02979   self = ::thr_self ();
02980 # elif defined (ACE_HAS_WTHREADS)
02981   self = ::GetCurrentThread ();
02982 # elif defined (ACE_HAS_VXTHREADS)
02983   self = ::taskIdSelf ();
02984 # endif /* ACE_HAS_STHREADS */
02985 #else
02986   self = 1; // Might as well make it the main thread ;-)
02987 #endif /* ACE_HAS_THREADS */
02988 }

ACE_NAMESPACE_INLINE_FUNCTION const char* ACE_OS::thr_name ( void   ) 

Definition at line 2955 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and thr_self().

02956 {
02957 #if defined (ACE_HAS_THREADS)
02958 #if defined (ACE_HAS_VXTHREADS)
02959   return ::taskName (ACE_OS::thr_self ());
02960 #else
02961   ACE_NOTSUP_RETURN (0);
02962 #endif
02963 #else
02964   ACE_NOTSUP_RETURN (0);
02965 #endif
02966 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_setcancelstate ( int  new_state,
int *  old_state 
)

Definition at line 2991 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::disablecancel(), ACE_Thread::enablecancel(), and ACE_Thread::setcancelstate().

02992 {
02993   ACE_OS_TRACE ("ACE_OS::thr_setcancelstate");
02994 #if defined (ACE_HAS_THREADS)
02995 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02996   int result;
02997   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcancelstate (new_state,
02998                                                                old_state),
02999                                        result),
03000                      int, -1);
03001 # elif defined (ACE_HAS_STHREADS)
03002   ACE_UNUSED_ARG (new_state);
03003   ACE_UNUSED_ARG (old_state);
03004   ACE_NOTSUP_RETURN (-1);
03005 # elif defined (ACE_HAS_WTHREADS)
03006   ACE_UNUSED_ARG (new_state);
03007   ACE_UNUSED_ARG (old_state);
03008   ACE_NOTSUP_RETURN (-1);
03009 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03010   ACE_UNUSED_ARG (new_state);
03011   ACE_UNUSED_ARG (old_state);
03012   ACE_NOTSUP_RETURN (-1);
03013 # endif /* ACE_HAS_PTHREADS */
03014 #else
03015   ACE_UNUSED_ARG (new_state);
03016   ACE_UNUSED_ARG (old_state);
03017   ACE_NOTSUP_RETURN (-1);
03018 #endif /* ACE_HAS_THREADS */
03019 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_setcanceltype ( int  new_type,
int *  old_type 
)

Definition at line 3022 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::enablecancel(), and ACE_Thread::setcancelstate().

03023 {
03024   ACE_OS_TRACE ("ACE_OS::thr_setcanceltype");
03025 #if defined (ACE_HAS_THREADS)
03026 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03027   int result;
03028   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcanceltype (new_type,
03029                                                               old_type),
03030                                        result),
03031                      int, -1);
03032 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03033   ACE_UNUSED_ARG (new_type);
03034   ACE_UNUSED_ARG (old_type);
03035   ACE_NOTSUP_RETURN (-1);
03036 # endif /* ACE_HAS_PTHREADS */
03037 #else
03038   ACE_UNUSED_ARG (new_type);
03039   ACE_UNUSED_ARG (old_type);
03040   ACE_NOTSUP_RETURN (-1);
03041 #endif /* ACE_HAS_THREADS */
03042 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_setconcurrency ( int  hint  ) 

Definition at line 3045 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_setconcurrency().

Referenced by ACE_Thread::setconcurrency(), thr_create(), and thr_setconcurrency().

03046 {
03047   ACE_OS_TRACE ("ACE_OS::thr_setconcurrency");
03048 #if defined (ACE_HAS_THREADS)
03049 # if defined (ACE_HAS_STHREADS)
03050   int result;
03051   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint),
03052                                        result),
03053                      int, -1);
03054 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_SETCONCURRENCY)
03055   int result;
03056   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setconcurrency (hint),
03057                                        result),
03058                      int, -1);
03059 # else
03060   ACE_UNUSED_ARG (hint);
03061   ACE_NOTSUP_RETURN (-1);
03062 # endif /* ACE_HAS_STHREADS */
03063 #else
03064   ACE_UNUSED_ARG (hint);
03065   ACE_NOTSUP_RETURN (-1);
03066 #endif /* ACE_HAS_THREADS */
03067 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_setprio ( ACE_hthread_t  ht_id,
int  priority,
int  policy = -1 
)

Definition at line 3070 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, memset(), and thr_setprio().

03071 {
03072   ACE_OS_TRACE ("ACE_OS::thr_setprio");
03073   ACE_UNUSED_ARG (policy);
03074 #if defined (ACE_HAS_THREADS)
03075 # if (defined (ACE_HAS_PTHREADS) && \
03076       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
03077 
03078   int result;
03079   struct sched_param param;
03080   ACE_OS::memset ((void *) &param, 0, sizeof param);
03081 
03082   // If <policy> is -1, we don't want to use it for
03083   // pthread_setschedparam().  Instead, obtain policy from
03084   // pthread_getschedparam().
03085   if (policy == -1)
03086     {
03087       ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
03088                                     result),
03089                   int, -1, result);
03090       if (result == -1)
03091         return result;
03092     }
03093 
03094   param.sched_priority = priority;
03095 
03096   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id,
03097                                                               policy,
03098                                                               &param),
03099                                        result),
03100                      int, -1);
03101 # elif defined (ACE_HAS_STHREADS)
03102   int result;
03103   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (ht_id, priority),
03104                                        result),
03105                      int, -1);
03106 # elif defined (ACE_HAS_WTHREADS)
03107   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (ht_id, priority),
03108                                           ace_result_),
03109                         int, -1);
03110 # elif defined (ACE_HAS_VXTHREADS)
03111   ACE_OSCALL_RETURN (::taskPrioritySet (ht_id, priority), int, -1);
03112 # else
03113   // For example, platforms that support Pthreads but LACK_SETSCHED.
03114   ACE_UNUSED_ARG (ht_id);
03115   ACE_UNUSED_ARG (priority);
03116   ACE_NOTSUP_RETURN (-1);
03117 # endif /* ACE_HAS_STHREADS */
03118 #else
03119   ACE_UNUSED_ARG (ht_id);
03120   ACE_UNUSED_ARG (priority);
03121   ACE_NOTSUP_RETURN (-1);
03122 #endif /* ACE_HAS_THREADS */
03123 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_sigsetmask ( int  how,
const sigset_t *  nsm,
sigset_t *  osm 
)

Definition at line 3126 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, pthread_sigmask(), SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK, and thr_sigsetmask().

Referenced by ACE_Log_Msg_Sig_Guard::ACE_Log_Msg_Sig_Guard(), ACE_Sig_Guard::ACE_Sig_Guard(), ACE_Thread::sigsetmask(), thr_sigsetmask(), ACE_Log_Msg_Sig_Guard::~ACE_Log_Msg_Sig_Guard(), and ACE_Sig_Guard::~ACE_Sig_Guard().

03129 {
03130   ACE_OS_TRACE ("ACE_OS::thr_sigsetmask");
03131 #if defined (ACE_HAS_THREADS)
03132 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
03133   // DCE threads and Solaris 2.4 have no such function.
03134   ACE_UNUSED_ARG (osm);
03135   ACE_UNUSED_ARG (nsm);
03136   ACE_UNUSED_ARG (how);
03137 
03138   ACE_NOTSUP_RETURN (-1);
03139 # elif defined (ACE_HAS_SIGTHREADMASK)
03140   int result;
03141   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm),
03142                                        result), int, -1);
03143 # elif defined (ACE_HAS_STHREADS)
03144   int result;
03145   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm),
03146                                        result),
03147                      int, -1);
03148 # elif defined (ACE_HAS_PTHREADS)
03149 #   if !defined (ACE_LACKS_PTHREAD_SIGMASK)
03150   int result;
03151   //FUZZ: disable check_for_lack_ACE_OS
03152   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
03153                                        result), int, -1);
03154   //FUZZ: enable check_for_lack_ACE_OS
03155 #   endif /* !ACE_LACKS_PTHREAD_SIGMASK */
03156 
03157 #if 0
03158   /* Don't know if any platform actually needs this... */
03159   // as far as I can tell, this is now pthread_sigaction() -- jwr
03160   int result;
03161   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_sigaction (how, nsm, osm),
03162                                        result), int, -1);
03163 #endif /* 0 */
03164 
03165 # elif defined (ACE_HAS_WTHREADS)
03166   ACE_UNUSED_ARG (osm);
03167   ACE_UNUSED_ARG (nsm);
03168   ACE_UNUSED_ARG (how);
03169 
03170   ACE_NOTSUP_RETURN (-1);
03171 # elif defined (ACE_VXWORKS)
03172   int old_mask = 0;
03173   switch (how)
03174     {
03175     case SIG_BLOCK:
03176     case SIG_UNBLOCK:
03177       {
03178         // get the old mask
03179         old_mask = ::sigsetmask (*nsm);
03180         // create a new mask:  the following assumes that sigset_t is 4 bytes,
03181         // which it is on VxWorks 5.2, so bit operations are done simply . . .
03182         ::sigsetmask (how == SIG_BLOCK ? (old_mask |= *nsm) : (old_mask &= ~*nsm));
03183         if (osm)
03184           *osm = old_mask;
03185         break;
03186       }
03187     case SIG_SETMASK:
03188       old_mask = ::sigsetmask (*nsm);
03189       if (osm)
03190         *osm = old_mask;
03191       break;
03192     default:
03193       return -1;
03194     }
03195 
03196   return 0;
03197 # else /* Should not happen. */
03198   ACE_UNUSED_ARG (how);
03199   ACE_UNUSED_ARG (nsm);
03200   ACE_UNUSED_ARG (osm);
03201   ACE_NOTSUP_RETURN (-1);
03202 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
03203 #else
03204   ACE_UNUSED_ARG (how);
03205   ACE_UNUSED_ARG (nsm);
03206   ACE_UNUSED_ARG (osm);
03207   ACE_NOTSUP_RETURN (-1);
03208 #endif /* ACE_HAS_THREADS */
03209 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thr_suspend ( ACE_hthread_t  target_thread  ) 

Definition at line 3212 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_suspend().

Referenced by ACE_Thread::suspend(), and thr_suspend().

03213 {
03214   ACE_OS_TRACE ("ACE_OS::thr_suspend");
03215 #if defined (ACE_HAS_THREADS)
03216 # if defined (ACE_HAS_STHREADS)
03217   int result;
03218   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), result), int, -1);
03219 # elif defined (ACE_HAS_PTHREADS)
03220 #  if defined (ACE_HAS_PTHREAD_SUSPEND)
03221   int result;
03222   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread),
03223                                        result),
03224                      int, -1);
03225 #  elif defined (ACE_HAS_PTHREAD_SUSPEND_NP)
03226   int result;
03227   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend_np (target_thread),
03228                                        result),
03229                      int, -1);
03230 #  else
03231   ACE_UNUSED_ARG (target_thread);
03232   ACE_NOTSUP_RETURN (-1);
03233 #  endif /* ACE_HAS_PTHREAD_SUSPEND */
03234 # elif defined (ACE_HAS_WTHREADS)
03235   if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED)
03236     return 0;
03237   else
03238     ACE_FAIL_RETURN (-1);
03239   /* NOTREACHED */
03240 # elif defined (ACE_HAS_VXTHREADS)
03241   ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1);
03242 # endif /* ACE_HAS_STHREADS */
03243 #else
03244   ACE_UNUSED_ARG (target_thread);
03245   ACE_NOTSUP_RETURN (-1);
03246 #endif /* ACE_HAS_THREADS */
03247 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::thr_testcancel ( void   ) 

Definition at line 3250 of file OS_NS_Thread.inl.

References ACE_OS_TRACE.

Referenced by ACE_Thread::testcancel().

03251 {
03252   ACE_OS_TRACE ("ACE_OS::thr_testcancel");
03253 #if defined (ACE_HAS_THREADS)
03254 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03255   pthread_testcancel ();
03256 # elif defined (ACE_HAS_STHREADS)
03257 # elif defined (ACE_HAS_WTHREADS)
03258 # elif defined (ACE_HAS_VXTHREADS)
03259 # else
03260   // no-op:  can't use ACE_NOTSUP_RETURN because there is no return value
03261 # endif /* ACE_HAS_PTHREADS */
03262 #else
03263 #endif /* ACE_HAS_THREADS */
03264 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::thr_yield ( void   ) 

Definition at line 3267 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, and thr_yield().

Referenced by event_destroy(), event_pulse(), thr_yield(), and ACE_Thread::yield().

03268 {
03269   ACE_OS_TRACE ("ACE_OS::thr_yield");
03270 #if defined (ACE_HAS_THREADS)
03271 # if defined (ACE_HAS_PTHREADS)
03272   ::sched_yield ();
03273 # elif defined (ACE_HAS_STHREADS)
03274   ::thr_yield ();
03275 # elif defined (ACE_HAS_WTHREADS)
03276   ::Sleep (0);
03277 # elif defined (ACE_HAS_VXTHREADS)
03278   // An argument of 0 to ::taskDelay doesn't appear to yield the
03279   // current thread.
03280   // Now, it does seem to work.  The context_switch_time test
03281   // works fine with task_delay set to 0.
03282   ::taskDelay (0);
03283 # endif /* ACE_HAS_STHREADS */
03284 #else
03285   ;
03286 #endif /* ACE_HAS_THREADS */
03287 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_destroy ( ACE_thread_mutex_t m  ) 

Definition at line 3290 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_destroy().

Referenced by ACE_OS_Object_Manager::fini(), mutex_destroy(), recursive_mutex_destroy(), sema_destroy(), and sema_init().

03291 {
03292   ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy");
03293 #if defined (ACE_HAS_THREADS)
03294 # if defined (ACE_HAS_WTHREADS)
03295   ::DeleteCriticalSection (m);
03296   return 0;
03297 # else
03298   return ACE_OS::mutex_destroy (m);
03299 # endif /* ACE_HAS_WTHREADS */
03300 #else
03301   ACE_UNUSED_ARG (m);
03302   ACE_NOTSUP_RETURN (-1);
03303 
03304 #endif /* ACE_HAS_THREADS */
03305 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_init ( ACE_thread_mutex_t m,
int  lock_type = 0,
const char *  name = 0,
ACE_mutexattr_t arg = 0 
)

Definition at line 3308 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_SEH_EXCEPT, ACE_SEH_TRY, mutex_init(), and USYNC_THREAD.

Referenced by ACE_OS_Object_Manager::init(), mutex_init(), recursive_mutex_init(), and sema_init().

03312 {
03313   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03314 #if defined (ACE_HAS_THREADS)
03315 # if defined (ACE_HAS_WTHREADS)
03316   ACE_UNUSED_ARG (lock_type);
03317   ACE_UNUSED_ARG (name);
03318   ACE_UNUSED_ARG (arg);
03319 
03320   ACE_SEH_TRY
03321     {
03322       ::InitializeCriticalSection (m);
03323     }
03324   ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
03325     {
03326       errno = ENOMEM;
03327       return -1;
03328     }
03329   return 0;
03330 
03331 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03332   // Force the use of USYNC_THREAD!
03333   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03334 # elif defined (ACE_HAS_VXTHREADS)
03335   return mutex_init (m, lock_type, name, arg);
03336 
03337 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03338 
03339 #else
03340   ACE_UNUSED_ARG (m);
03341   ACE_UNUSED_ARG (lock_type);
03342   ACE_UNUSED_ARG (name);
03343   ACE_UNUSED_ARG (arg);
03344   ACE_NOTSUP_RETURN (-1);
03345 
03346 #endif /* ACE_HAS_THREADS */
03347 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m  ) 

Definition at line 3392 of file OS_NS_Thread.inl.

Referenced by ACE_Log_Msg::close(), ACE_Log_Msg::instance(), mutex_lock(), open(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_lock().

03393 {
03394   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03395 #if defined (ACE_HAS_THREADS)
03396 # if defined (ACE_HAS_WTHREADS)
03397   ::EnterCriticalSection (m);
03398   return 0;
03399 # else
03400   return ACE_OS::mutex_lock (m);
03401 # endif /* ACE_HAS_WTHREADS */
03402 #else
03403   ACE_UNUSED_ARG (m);
03404   ACE_NOTSUP_RETURN (-1);
03405 #endif /* ACE_HAS_THREADS */
03406 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 3409 of file OS_NS_Thread.inl.

03411 {
03412   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03413 
03414   // For all platforms, except MS Windows, this method is equivalent
03415   // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and
03416   // ACE_mutex_t are the same type.  However, those typedefs evaluate
03417   // to different types on MS Windows.  The "thread mutex"
03418   // implementation in ACE for MS Windows cannot readily support
03419   // timeouts due to a lack of timeout features for this type of MS
03420   // Windows synchronization mechanism.
03421 
03422 #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS)
03423   return ACE_OS::mutex_lock (m, timeout);
03424 #else
03425   ACE_UNUSED_ARG (m);
03426   ACE_UNUSED_ARG (timeout);
03427   ACE_NOTSUP_RETURN (-1);
03428 #endif /* ACE_HAS_THREADS */
03429 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 3432 of file OS_NS_Thread.inl.

References thread_mutex_lock().

03434 {
03435   return timeout == 0
03436     ? ACE_OS::thread_mutex_lock (m)
03437     : ACE_OS::thread_mutex_lock (m, *timeout);
03438 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_trylock ( ACE_thread_mutex_t m  ) 

Definition at line 3441 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, and mutex_trylock().

Referenced by mutex_trylock(), and recursive_mutex_trylock().

03442 {
03443   ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
03444 
03445 #if defined (ACE_HAS_THREADS)
03446 # if defined (ACE_HAS_WTHREADS)
03447 #   if defined (ACE_HAS_WIN32_TRYLOCK)
03448   BOOL result = ::TryEnterCriticalSection (m);
03449   if (result == TRUE)
03450     return 0;
03451   else
03452     {
03453       errno = EBUSY;
03454       return -1;
03455     }
03456 #   else
03457   ACE_UNUSED_ARG (m);
03458   ACE_NOTSUP_RETURN (-1);
03459 #   endif /* ACE_HAS_WIN32_TRYLOCK */
03460 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03461   return ACE_OS::mutex_trylock (m);
03462 #endif /* Threads variety case */
03463 
03464 #else
03465   ACE_UNUSED_ARG (m);
03466   ACE_NOTSUP_RETURN (-1);
03467 #endif /* ACE_HAS_THREADS */
03468 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::thread_mutex_unlock ( ACE_thread_mutex_t m  ) 

Definition at line 3471 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_unlock().

Referenced by ACE_Log_Msg::close(), ACE_Log_Msg::instance(), mutex_unlock(), open(), recursive_mutex_cond_relock(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sema_init(), sema_post(), sema_trywait(), and sema_wait().

03472 {
03473   ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock");
03474 #if defined (ACE_HAS_THREADS)
03475 # if defined (ACE_HAS_WTHREADS)
03476   ::LeaveCriticalSection (m);
03477   return 0;
03478 # else
03479   return ACE_OS::mutex_unlock (m);
03480 # endif /* ACE_HAS_WTHREADS */
03481 #else
03482   ACE_UNUSED_ARG (m);
03483   ACE_NOTSUP_RETURN (-1);
03484 #endif /* ACE_HAS_THREADS */
03485 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::thr_equal ( ACE_thread_t  t1,
ACE_thread_t  t2 
)

Definition at line 108 of file OS_NS_Thread.inl.

Referenced by ACE_Thread_Manager::check_state(), ACE_Thread_Manager::find_thread(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events(), ACE_Thread_Manager::join(), ACE_Thread_ID::operator==(), ACE_Thread_Descriptor_Base::operator==(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), ACE_Thread_Manager::thr_state(), ACE_Thread_Manager::thread_within(), ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager(), and ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager().

00109 {
00110 #if defined (ACE_HAS_PTHREADS)
00111 # if defined (pthread_equal)
00112   // If it's a macro we can't say "pthread_equal"...
00113   return pthread_equal (t1, t2);
00114 # else
00115   return pthread_equal (t1, t2);
00116 # endif /* pthread_equal */
00117 #else /* For both STHREADS and WTHREADS... */
00118   // Hum, Do we need to treat WTHREAD differently?
00119   // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD.
00120   return t1 == t2;
00121 #endif /* ACE_HAS_PTHREADS */
00122 }

ACE_INLINE int ACE_OS::condattr_destroy ( ACE_condattr_t attributes  ) 

Definition at line 131 of file OS_NS_Thread.inl.

References ACE_condattr_t::type.

Referenced by cond_init(), and rwlock_init().

00132 {
00133 #if defined (ACE_HAS_THREADS)
00134 #   if defined (ACE_HAS_PTHREADS)
00135 
00136   pthread_condattr_destroy (&attributes);
00137 
00138 #   elif defined (ACE_HAS_STHREADS)
00139   attributes.type = 0;
00140 
00141 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00142   return 0;
00143 # else
00144   ACE_UNUSED_ARG (attributes);
00145   return 0;
00146 # endif /* ACE_HAS_THREADS  */
00147 }

ACE_INLINE int ACE_OS::condattr_init ( ACE_condattr_t attributes,
int  type 
)

Definition at line 150 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and memset().

Referenced by cond_init(), and rwlock_init().

00152 {
00153   ACE_UNUSED_ARG (type);
00154 # if defined (ACE_HAS_THREADS)
00155 #   if defined (ACE_HAS_PTHREADS)
00156   int result = -1;
00157 
00158 #   if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00159       /* Tests show that VxWorks 6.x pthread lib does not only
00160        * require zeroing of mutex/condition objects to function correctly
00161        * but also of the attribute objects.
00162        */
00163       ACE_OS::memset (&attributes, 0, sizeof (attributes));
00164 #   endif
00165   if (
00166       ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0
00167 #       if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)
00168       && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type),
00169                            result) == 0
00170 #       endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */
00171       )
00172      result = 0;
00173   else
00174      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00175 
00176   return result;
00177 #   elif defined (ACE_HAS_STHREADS)
00178   attributes.type = type;
00179 
00180   return 0;
00181 
00182 #   else
00183   ACE_UNUSED_ARG (attributes);
00184   ACE_UNUSED_ARG (type);
00185   ACE_NOTSUP_RETURN (-1);
00186 
00187 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00188 
00189 # else
00190   ACE_UNUSED_ARG (attributes);
00191   ACE_UNUSED_ARG (type);
00192   ACE_NOTSUP_RETURN (-1);
00193 # endif /* ACE_HAS_THREADS */
00194 }

ACE_INLINE int ACE_OS::cond_broadcast ( ACE_cond_t cv  ) 

Definition at line 197 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_broadcast().

Referenced by cond_broadcast(), event_destroy(), event_pulse(), event_signal(), and rw_unlock().

00198 {
00199   ACE_OS_TRACE ("ACE_OS::cond_broadcast");
00200 # if defined (ACE_HAS_THREADS)
00201 #   if defined (ACE_HAS_PTHREADS)
00202   int result;
00203   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_broadcast (cv),
00204                                        result),
00205                      int, -1);
00206 #   elif defined (ACE_HAS_STHREADS)
00207   int result;
00208   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv),
00209                                        result),
00210                      int, -1);
00211 #   endif /* ACE_HAS_STHREADS */
00212 # else
00213   ACE_UNUSED_ARG (cv);
00214   ACE_NOTSUP_RETURN (-1);
00215 # endif /* ACE_HAS_THREADS */
00216 }

ACE_INLINE int ACE_OS::cond_destroy ( ACE_cond_t cv  ) 

Definition at line 219 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_destroy().

Referenced by cond_destroy(), event_destroy(), recursive_mutex_destroy(), rwlock_destroy(), rwlock_init(), sema_destroy(), and sema_init().

00220 {
00221   ACE_OS_TRACE ("ACE_OS::cond_destroy");
00222 # if defined (ACE_HAS_THREADS)
00223 #   if defined (ACE_HAS_PTHREADS)
00224   int result;
00225   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_destroy (cv), result), int, -1);
00226 #   elif defined (ACE_HAS_STHREADS)
00227   int result;
00228   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), result), int, -1);
00229 #   endif /* ACE_HAS_STHREADS */
00230 # else
00231   ACE_UNUSED_ARG (cv);
00232   ACE_NOTSUP_RETURN (-1);
00233 # endif /* ACE_HAS_THREADS */
00234 }

ACE_INLINE int ACE_OS::cond_init ( ACE_cond_t cv,
ACE_condattr_t attributes,
const char *  name,
void *  arg 
)

Definition at line 237 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_init(), memset(), and ACE_condattr_t::type.

00241 {
00242   // ACE_OS_TRACE ("ACE_OS::cond_init");
00243   ACE_UNUSED_ARG (name);
00244   ACE_UNUSED_ARG (arg);
00245 # if defined (ACE_HAS_THREADS)
00246 #   if defined (ACE_HAS_PTHREADS)
00247   int result = -1;
00248 
00249 #     if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00250   /* VxWorks 6.x API reference states:
00251    *   If the memory for the condition variable object has been allocated
00252    *   dynamically, it is a good policy to always zero out the
00253    *   block of memory so as to avoid spurious EBUSY return code
00254    *   when calling this routine.
00255    */
00256   ACE_OS::memset (cv, 0, sizeof (*cv));
00257 #     endif
00258 
00259   if (ACE_ADAPT_RETVAL (pthread_cond_init (cv, &attributes), result) == 0)
00260      result = 0;
00261   else
00262      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00263 
00264   return result;
00265 #   elif defined (ACE_HAS_STHREADS)
00266   int result;
00267   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv,
00268                                                     attributes.type,
00269                                                     arg),
00270                                        result),
00271                      int, -1);
00272 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00273 # else
00274   ACE_UNUSED_ARG (cv);
00275   ACE_UNUSED_ARG (attributes);
00276   ACE_UNUSED_ARG (name);
00277   ACE_UNUSED_ARG (arg);
00278   ACE_NOTSUP_RETURN (-1);
00279 # endif /* ACE_HAS_THREADS */
00280 }

ACE_INLINE int ACE_OS::cond_signal ( ACE_cond_t cv  ) 

Definition at line 302 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_signal().

Referenced by cond_signal(), event_pulse(), event_signal(), recursive_mutex_cond_unlock(), recursive_mutex_unlock(), rw_unlock(), and sema_post().

00303 {
00304   ACE_OS_TRACE ("ACE_OS::cond_signal");
00305 # if defined (ACE_HAS_THREADS)
00306 #   if defined (ACE_HAS_PTHREADS)
00307   int result;
00308   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_signal (cv), result),
00309                      int, -1);
00310 #   elif defined (ACE_HAS_STHREADS)
00311   int result;
00312   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), result), int, -1);
00313 #   endif /* ACE_HAS_STHREADS */
00314 # else
00315   ACE_UNUSED_ARG (cv);
00316   ACE_NOTSUP_RETURN (-1);
00317 # endif /* ACE_HAS_THREADS */
00318 }

ACE_INLINE int ACE_OS::cond_wait ( ACE_cond_t cv,
ACE_mutex_t external_mutex 
)

Definition at line 321 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_wait().

Referenced by cond_timedwait(), cond_wait(), event_wait(), recursive_mutex_cond_relock(), recursive_mutex_lock(), rw_rdlock(), rw_trywrlock_upgrade(), rw_wrlock(), and sema_wait().

00323 {
00324   ACE_OS_TRACE ("ACE_OS::cond_wait");
00325 # if defined (ACE_HAS_THREADS)
00326 #   if defined (ACE_HAS_PTHREADS)
00327   int result;
00328   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_wait (cv, external_mutex), result),
00329                      int, -1);
00330 #   elif defined (ACE_HAS_STHREADS)
00331   int result;
00332   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), result),
00333                      int, -1);
00334 #   endif /* ACE_HAS_PTHREADS */
00335 # else
00336   ACE_UNUSED_ARG (cv);
00337   ACE_UNUSED_ARG (external_mutex);
00338   ACE_NOTSUP_RETURN (-1);
00339 # endif /* ACE_HAS_THREADS */
00340 }

ACE_INLINE int ACE_OS::cond_timedwait ( ACE_cond_t cv,
ACE_mutex_t external_mutex,
ACE_Time_Value timeout 
)

Definition at line 343 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_timedwait(), cond_wait(), and ACE_Time_Value::set().

Referenced by cond_timedwait(), event_timedwait(), recursive_mutex_lock(), and sema_wait().

00346 {
00347   ACE_OS_TRACE ("ACE_OS::cond_timedwait");
00348 # if defined (ACE_HAS_THREADS)
00349   int result;
00350   timespec_t ts;
00351 
00352   if (timeout != 0)
00353     ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
00354 
00355 #   if defined (ACE_HAS_PTHREADS)
00356 
00357   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00358                                 ? pthread_cond_wait (cv, external_mutex)
00359                                 : pthread_cond_timedwait (cv, external_mutex,
00360                                                             (ACE_TIMESPEC_PTR) &ts),
00361                                 result),
00362               int, -1, result);
00363   // We need to adjust this to make the POSIX and Solaris return
00364   // values consistent.  EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and down)
00365   if (result == -1 &&
00366       (errno == ETIMEDOUT || errno == EAGAIN))
00367     errno = ETIME;
00368 
00369 #   elif defined (ACE_HAS_STHREADS)
00370   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00371                                 ? ::cond_wait (cv, external_mutex)
00372                                 : ::cond_timedwait (cv,
00373                                                     external_mutex,
00374                                                     (timestruc_t*)&ts),
00375                                 result),
00376               int, -1, result);
00377 #   endif /* ACE_HAS_STHREADS */
00378   if (timeout != 0)
00379     timeout->set (ts); // Update the time value before returning.
00380 
00381   return result;
00382 # else
00383   ACE_UNUSED_ARG (cv);
00384   ACE_UNUSED_ARG (external_mutex);
00385   ACE_UNUSED_ARG (timeout);
00386   ACE_NOTSUP_RETURN (-1);
00387 # endif /* ACE_HAS_THREADS */
00388 }

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

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 392 of file OS_NS_Thread.inl.

References mutex_lock().

00394 {
00395   return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
00396 }

ACE_INLINE long ACE_OS::priority_control ( ACE_idtype_t  ,
ACE_id_t  ,
int  ,
void *   
)

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

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

Definition at line 435 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

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

00436 {
00437   ACE_OS_TRACE ("ACE_OS::priority_control");
00438 #if defined (ACE_HAS_PRIOCNTL)
00439   ACE_OSCALL_RETURN (priocntl (idtype, identifier, cmd, static_cast<caddr_t> (arg)),
00440                      long, -1);
00441 #else  /* ! ACE_HAS_PRIOCNTL*/
00442   ACE_UNUSED_ARG (idtype);
00443   ACE_UNUSED_ARG (identifier);
00444   ACE_UNUSED_ARG (cmd);
00445   ACE_UNUSED_ARG (arg);
00446   ACE_NOTSUP_RETURN (-1);
00447 #endif /* ! ACE_HAS_PRIOCNTL*/
00448 }

ACE_INLINE int ACE_OS::recursive_mutex_cond_unlock ( ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state 
)

Definition at line 457 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_signal(), NULL_thread, recursive_mutex_unlock(), thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00459 {
00460 #if defined (ACE_HAS_THREADS)
00461   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock");
00462 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00463   // Windows need special handling since it has recursive mutexes, but
00464   // does not integrate them into a condition variable.
00465 #    if defined (ACE_WIN32)
00466   // For Windows, the OS takes care of the mutex and its recursion. We just
00467   // need to release the lock one fewer times than this thread has acquired
00468   // it. Remember how many times, and reacquire it that many more times when
00469   // the condition is signaled.
00470   //
00471   // For WinCE, the situation is a bit trickier. CE doesn't have
00472   // RecursionCount, and LockCount has changed semantics over time.
00473   // In CE 3 (and maybe 4?) LockCount is not an indicator of recursion;
00474   // instead, see when it's unlocked by watching the OwnerThread, which will
00475   // change to something other than the current thread when it's been
00476   // unlocked "enough" times. Note that checking for 0 (unlocked) is not
00477   // sufficient. Another thread may acquire the lock between our unlock and
00478   // checking the OwnerThread. So grab our thread ID value first, then
00479   // compare to it in the loop condition. NOTE - the problem with this
00480   // scheme is that we really want to unlock the mutex one _less_ times than
00481   // required to release it for another thread to acquire. With CE 5 we
00482   // can do this by watching LockCount alone. I _think_ it can be done by
00483   // watching LockCount on CE 4 as well (though its meaning is different),
00484   // but I'm leary of changing this code since a user reported success
00485   // with it.
00486   //
00487   // We're using undocumented fields in the CRITICAL_SECTION structure
00488   // and they've been known to change across Windows variants and versions./
00489   // So be careful if you need to change these - there may be other
00490   // Windows variants that depend on existing values and limits.
00491 #      if defined (ACE_HAS_WINCE) && (UNDER_CE < 500)
00492   ACE_thread_t me = ACE_OS::thr_self ();
00493 #      endif /* ACE_HAS_WINCE && CE 4 or earlier */
00494 
00495   state.relock_count_ = 0;
00496   while (
00497 #      if !defined (ACE_HAS_WINCE)
00498          m->LockCount > 0 && m->RecursionCount > 1
00499 #      else
00500          // WinCE doesn't have RecursionCount and the LockCount semantic
00501          // has changed between versions; pre-Mobile 5 the LockCount
00502          // was 0-indexed, and Mobile 5 has it 1-indexed.
00503 #        if (UNDER_CE < 500)
00504          m->LockCount > 0 && m->OwnerThread == (HANDLE)me
00505 #        else
00506          m->LockCount > 1
00507 #        endif /* UNDER_CE < 500 */
00508 #      endif /* ACE_HAS_WINCE */
00509          )
00510     {
00511       // This may fail if the current thread doesn't own the mutex. If it
00512       // does fail, it'll be on the first try, so don't worry about resetting
00513       // the state.
00514       if (ACE_OS::recursive_mutex_unlock (m) == -1)
00515         return -1;
00516       ++state.relock_count_;
00517     }
00518 #    else /* not ACE_WIN32 */
00519     // prevent warnings for unused variables
00520     ACE_UNUSED_ARG (state);
00521     ACE_UNUSED_ARG (m);
00522 #    endif /* ACE_WIN32 */
00523   return 0;
00524 #  else /* ACE_HAS_RECURSIVE_MUTEXES */
00525   // For platforms without recursive mutexes, we obtain the nesting mutex
00526   // to gain control over the mutex internals. Then set the internals to say
00527   // the mutex is available. If there are waiters, signal the condition
00528   // to notify them (this is mostly like the recursive_mutex_unlock() method).
00529   // Then, return with the nesting mutex still held. The condition wait
00530   // will release it atomically, allowing mutex waiters to continue.
00531   // Note that this arrangement relies on the fact that on return from
00532   // the condition wait, this thread will again own the nesting mutex
00533   // and can either set the mutex internals directly or get in line for
00534   // the mutex... this part is handled in recursive_mutex_cond_relock().
00535   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00536     return -1;
00537 
00538 #    if !defined (ACE_NDEBUG)
00539   if (m->nesting_level_ == 0
00540       || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0)
00541     {
00542       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00543       errno = EINVAL;
00544       return -1;
00545     }
00546 #    endif /* ACE_NDEBUG */
00547 
00548   // To make error recovery a bit easier, signal the condition now. Any
00549   // waiter won't regain control until the mutex is released, which won't
00550   // be until the caller returns and does the wait on the condition.
00551   if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00552     {
00553       // Save/restore errno.
00554       ACE_Errno_Guard error (errno);
00555       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00556       return -1;
00557     }
00558 
00559   // Ok, the nesting_mutex_ lock is still held, the condition has been
00560   // signaled... reset the nesting info and return _WITH_ the lock
00561   // held. The lock will be released when the condition waits, in the
00562   // caller.
00563   state.nesting_level_ = m->nesting_level_;
00564   state.owner_id_ = m->owner_id_;
00565   m->nesting_level_ = 0;
00566   m->owner_id_ = ACE_OS::NULL_thread;
00567   return 0;
00568 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00569 #else
00570   ACE_UNUSED_ARG (m);
00571   ACE_UNUSED_ARG (state);
00572   ACE_NOTSUP_RETURN (-1);
00573 #endif /* ACE_HAS_THREADS */
00574 }

ACE_INLINE void ACE_OS::recursive_mutex_cond_relock ( ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state 
)

Definition at line 582 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, cond_wait(), recursive_mutex_lock(), and thread_mutex_unlock().

00584 {
00585 #if defined (ACE_HAS_THREADS)
00586   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock");
00587 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00588   // Windows need special handling since it has recursive mutexes, but
00589   // does not integrate them into a condition variable.
00590   // On entry, the OS has already reacquired the lock for us. Just
00591   // reacquire it the proper number of times so the recursion is the same as
00592   // before waiting on the condition.
00593 #    if defined (ACE_WIN32)
00594   while (state.relock_count_ > 0)
00595     {
00596       ACE_OS::recursive_mutex_lock (m);
00597       --state.relock_count_;
00598     }
00599   return;
00600 #    else /* not ACE_WIN32 */
00601     // prevent warnings for unused variables
00602     ACE_UNUSED_ARG (state);
00603     ACE_UNUSED_ARG (m);
00604 
00605 #    endif /* ACE_WIN32 */
00606 #  else
00607   // Without recursive mutex support, it's somewhat trickier. On entry,
00608   // the current thread holds the nesting_mutex_, but another thread may
00609   // still be holding the ACE_recursive_mutex_t. If so, mimic the code
00610   // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex.
00611   // After acquiring it, restore the nesting counts and release the
00612   // nesting mutex. This will restore the conditions to what they were
00613   // before calling ACE_OS::recursive_mutex_cond_unlock().
00614   while (m->nesting_level_ > 0)
00615     ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_);
00616 
00617   // At this point, we still have nesting_mutex_ and the mutex is free.
00618   m->nesting_level_ = state.nesting_level_;
00619   m->owner_id_ = state.owner_id_;
00620   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00621   return;
00622 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00623 #else
00624   ACE_UNUSED_ARG (m);
00625   ACE_UNUSED_ARG (state);
00626   return;
00627 #endif /* ACE_HAS_THREADS */
00628 }

ACE_INLINE int ACE_OS::recursive_mutex_destroy ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 631 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_destroy(), and thread_mutex_destroy().

Referenced by ACE_OS_Object_Manager::fini().

00632 {
00633 #if defined (ACE_HAS_THREADS)
00634 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00635   return ACE_OS::thread_mutex_destroy (m);
00636 #else
00637   if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
00638     return -1;
00639   else if (ACE_OS::cond_destroy (&m->lock_available_) == -1)
00640     return -1;
00641   else
00642     return 0;
00643 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00644 #else
00645   ACE_UNUSED_ARG (m);
00646   ACE_NOTSUP_RETURN (-1);
00647 #endif /* ACE_HAS_THREADS */
00648 }

ACE_INLINE int ACE_OS::recursive_mutex_init ( ACE_recursive_thread_mutex_t m,
const ACE_TCHAR name,
ACE_mutexattr_t arg,
LPSECURITY_ATTRIBUTES  sa 
)

Definition at line 651 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_init(), NULL_thread, thread_mutex_init(), and USYNC_THREAD.

Referenced by ACE_OS_Object_Manager::init().

00655 {
00656   ACE_UNUSED_ARG (sa);
00657 #if defined (ACE_HAS_THREADS)
00658 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00659 #    if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00660   return ACE_OS::thread_mutex_init (m, PTHREAD_MUTEX_RECURSIVE, name, arg);
00661 #    else
00662   return ACE_OS::thread_mutex_init (m, 0, name, arg);
00663 #    endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00664 #  else
00665   if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1)
00666     return -1;
00667   else if (ACE_OS::cond_init (&m->lock_available_,
00668                               (short) USYNC_THREAD,
00669                               name,
00670                               0) == -1)
00671     return -1;
00672   else
00673     {
00674       m->nesting_level_ = 0;
00675       m->owner_id_ = ACE_OS::NULL_thread;
00676       return 0;
00677     }
00678 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00679 #else
00680   ACE_UNUSED_ARG (m);
00681   ACE_UNUSED_ARG (name);
00682   ACE_UNUSED_ARG (arg);
00683   ACE_NOTSUP_RETURN (-1);
00684 #endif /* ACE_HAS_THREADS */
00685 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 688 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_wait(), thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00689 {
00690 #if defined (ACE_HAS_THREADS)
00691 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00692   return ACE_OS::thread_mutex_lock (m);
00693 #else
00694   ACE_thread_t const t_id = ACE_OS::thr_self ();
00695   int result = 0;
00696 
00697   // Acquire the guard.
00698   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00699     result = -1;
00700   else
00701   {
00702     // If there's no contention, just grab the lock immediately
00703     // (since this is the common case we'll optimize for it).
00704     if (m->nesting_level_ == 0)
00705       m->owner_id_ = t_id;
00706       // If we already own the lock, then increment the nesting level
00707       // and return.
00708     else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00709     {
00710           // Wait until the nesting level has dropped to zero, at
00711           // which point we can acquire the lock.
00712       while (m->nesting_level_ > 0)
00713         ACE_OS::cond_wait (&m->lock_available_,
00714                             &m->nesting_mutex_);
00715 
00716           // At this point the nesting_mutex_ is held...
00717       m->owner_id_ = t_id;
00718     }
00719 
00720     // At this point, we can safely increment the nesting_level_ no
00721     // matter how we got here!
00722     ++m->nesting_level_;
00723   }
00724 
00725   {
00726     // Save/restore errno.
00727     ACE_Errno_Guard error (errno);
00728     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00729   }
00730   return result;
00731 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00732 #else
00733   ACE_UNUSED_ARG (m);
00734   ACE_NOTSUP_RETURN (-1);
00735 #endif /* ACE_HAS_THREADS */
00736 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 739 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_timedwait(), thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00741 {
00742 #if defined (ACE_HAS_THREADS)
00743 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00744   return ACE_OS::thread_mutex_lock (m, timeout);
00745 #else
00746   ACE_thread_t t_id = ACE_OS::thr_self ();
00747   int result = 0;
00748 
00749   // Try to acquire the guard.
00750   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_, timeout) == -1)
00751     result = -1;
00752   else
00753     {
00754       // If there's no contention, just grab the lock immediately
00755       // (since this is the common case we'll optimize for it).
00756       if (m->nesting_level_ == 0)
00757         m->owner_id_ = t_id;
00758       // If we already own the lock, then increment the nesting level
00759       // and return.
00760       else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00761         {
00762           // Wait until the nesting level has dropped to zero, at
00763           // which point we can acquire the lock.
00764           while (m->nesting_level_ > 0)
00765             {
00766               result = ACE_OS::cond_timedwait (&m->lock_available_,
00767                                                &m->nesting_mutex_,
00768                                                const_cast <ACE_Time_Value *> (&timeout));
00769 
00770               // The mutex is reacquired even in the case of a timeout
00771               // release the mutex to prevent a deadlock
00772               if (result == -1)
00773                 {
00774                   // Save/restore errno.
00775                   ACE_Errno_Guard error (errno);
00776                   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00777 
00778                   return result;
00779                 }
00780             }
00781 
00782           // At this point the nesting_mutex_ is held...
00783           m->owner_id_ = t_id;
00784         }
00785 
00786       // At this point, we can safely increment the nesting_level_ no
00787       // matter how we got here!
00788       m->nesting_level_++;
00789 
00790       // Save/restore errno.
00791       ACE_Errno_Guard error (errno);
00792       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00793     }
00794   return result;
00795 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00796 #else
00797   ACE_UNUSED_ARG (m);
00798   ACE_UNUSED_ARG (timeout);
00799   ACE_NOTSUP_RETURN (-1);
00800 #endif /* ACE_HAS_THREADS */
00801 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ( ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 804 of file OS_NS_Thread.inl.

References recursive_mutex_lock().

00806 {
00807   return timeout == 0
00808     ? ACE_OS::recursive_mutex_lock (m)
00809     : ACE_OS::recursive_mutex_lock (m, *timeout);
00810 }

ACE_INLINE int ACE_OS::recursive_mutex_trylock ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 813 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, EBUSY, thr_equal(), thr_self(), thread_mutex_lock(), thread_mutex_trylock(), and thread_mutex_unlock().

00814 {
00815 #if defined (ACE_HAS_THREADS)
00816 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00817   return ACE_OS::thread_mutex_trylock (m);
00818 #else
00819   ACE_thread_t t_id = ACE_OS::thr_self ();
00820   int result = 0;
00821 
00822   // Acquire the guard.
00823   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00824     result = -1;
00825   else
00826   {
00827       // If there's no contention, just grab the lock immediately.
00828     if (m->nesting_level_ == 0)
00829     {
00830       m->owner_id_ = t_id;
00831       m->nesting_level_ = 1;
00832     }
00833       // If we already own the lock, then increment the nesting level
00834       // and proceed.
00835     else if (ACE_OS::thr_equal (t_id, m->owner_id_))
00836       m->nesting_level_++;
00837     else
00838     {
00839       errno = EBUSY;
00840       result = -1;
00841     }
00842   }
00843 
00844   {
00845     // Save/restore errno.
00846     ACE_Errno_Guard error (errno);
00847     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00848   }
00849   return result;
00850 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00851 #else
00852   ACE_UNUSED_ARG (m);
00853   ACE_NOTSUP_RETURN (-1);
00854 #endif /* ACE_HAS_THREADS */
00855 }

ACE_INLINE int ACE_OS::recursive_mutex_unlock ( ACE_recursive_thread_mutex_t m  ) 

Definition at line 858 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_signal(), NULL_thread, thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by recursive_mutex_cond_unlock().

00859 {
00860 #if defined (ACE_HAS_THREADS)
00861 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00862   return ACE_OS::thread_mutex_unlock (m);
00863 #  else
00864   ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock");
00865 #    if !defined (ACE_NDEBUG)
00866   ACE_thread_t t_id = ACE_OS::thr_self ();
00867 #    endif /* ACE_NDEBUG */
00868   int result = 0;
00869 
00870   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00871     result = -1;
00872   else
00873   {
00874 #    if !defined (ACE_NDEBUG)
00875       if (m->nesting_level_ == 0
00876           || ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00877 {
00878   errno = EINVAL;
00879   result = -1;
00880 }
00881       else
00882 #    endif /* ACE_NDEBUG */
00883 {
00884   m->nesting_level_--;
00885   if (m->nesting_level_ == 0)
00886   {
00887               // This may not be strictly necessary, but it does put
00888               // the mutex into a known state...
00889     m->owner_id_ = ACE_OS::NULL_thread;
00890 
00891               // Inform a waiter that the lock is free.
00892     if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00893       result = -1;
00894   }
00895 }
00896   }
00897 
00898 {
00899     // Save/restore errno.
00900   ACE_Errno_Guard error (errno);
00901   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00902 }
00903   return result;
00904 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00905 #else
00906   ACE_UNUSED_ARG (m);
00907   ACE_NOTSUP_RETURN (-1);
00908 #endif /* ACE_HAS_THREADS */
00909 }

ACE_INLINE int ACE_OS::rw_rdlock ( ACE_rwlock_t rw  ) 

Definition at line 912 of file OS_NS_Thread.inl.

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

Referenced by rw_rdlock().

00913 {
00914   ACE_OS_TRACE ("ACE_OS::rw_rdlock");
00915 #if defined (ACE_HAS_THREADS)
00916 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00917 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00918   int result;
00919   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
00920                                        result),
00921                      int, -1);
00922 #  else /* Solaris */
00923   int result;
00924   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), result), int, -1);
00925 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00926 # else /* NT, POSIX, and VxWorks don't support this natively. */
00927 #   if defined (ACE_HAS_PTHREADS)
00928   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
00929 #   endif /* ACE_HAS_PTHREADS */
00930   int result = 0;
00931   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
00932     result = -1; // -1 means didn't get the mutex.
00933   else
00934     {
00935       // Give preference to writers who are waiting.
00936       while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0)
00937         {
00938           rw->num_waiting_readers_++;
00939           if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1)
00940             {
00941               result = -2; // -2 means that we need to release the mutex.
00942               break;
00943             }
00944           rw->num_waiting_readers_--;
00945         }
00946     }
00947   if (result == 0)
00948     rw->ref_count_++;
00949   if (result != -1)
00950     ACE_OS::mutex_unlock (&rw->lock_);
00951 #   if defined (ACE_HAS_PTHREADS)
00952   ACE_PTHREAD_CLEANUP_POP (0);
00953 #   endif /* defined (ACE_HAS_PTHREADS) */
00954   return 0;
00955 # endif /* ! ACE_LACKS_RWLOCK_T */
00956 #else
00957   ACE_UNUSED_ARG (rw);
00958   ACE_NOTSUP_RETURN (-1);
00959 #endif /* ACE_HAS_THREADS */
00960 }

ACE_INLINE int ACE_OS::rw_tryrdlock ( ACE_rwlock_t rw  ) 

Definition at line 963 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_lock(), mutex_unlock(), and rw_tryrdlock().

Referenced by rw_tryrdlock().

00964 {
00965   ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
00966 #if defined (ACE_HAS_THREADS)
00967 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00968 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00969   int result;
00970   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
00971                                        result),
00972                      int, -1);
00973 #  else /* Solaris */
00974   int result;
00975   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), result), int, -1);
00976 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00977 # else /* NT, POSIX, and VxWorks don't support this natively. */
00978   int result = -1;
00979 
00980   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
00981     {
00982       ACE_Errno_Guard error (errno);
00983 
00984       if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0)
00985         {
00986           error = EBUSY;
00987           result = -1;
00988         }
00989       else
00990         {
00991           rw->ref_count_++;
00992           result = 0;
00993         }
00994 
00995       ACE_OS::mutex_unlock (&rw->lock_);
00996     }
00997   return result;
00998 # endif /* ! ACE_LACKS_RWLOCK_T */
00999 #else
01000   ACE_UNUSED_ARG (rw);
01001   ACE_NOTSUP_RETURN (-1);
01002 #endif /* ACE_HAS_THREADS */
01003 }

ACE_INLINE int ACE_OS::rw_trywrlock ( ACE_rwlock_t rw  ) 

Definition at line 1006 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_lock(), mutex_unlock(), and rw_trywrlock().

Referenced by rw_trywrlock().

01007 {
01008   ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
01009 #if defined (ACE_HAS_THREADS)
01010 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01011 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01012   int result;
01013   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01014                                        result),
01015                      int, -1);
01016 #  else /* Solaris */
01017   int result;
01018   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), result), int, -1);
01019 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01020 # else /* NT, POSIX, and VxWorks don't support this natively. */
01021   int result = -1;
01022 
01023   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01024     {
01025       ACE_Errno_Guard error (errno);
01026 
01027       if (rw->ref_count_ != 0)
01028         {
01029           error = EBUSY;
01030           result = -1;
01031         }
01032       else
01033         {
01034           rw->ref_count_ = -1;
01035           result = 0;
01036         }
01037 
01038       ACE_OS::mutex_unlock (&rw->lock_);
01039     }
01040   return result;
01041 # endif /* ! ACE_LACKS_RWLOCK_T */
01042 #else
01043   ACE_UNUSED_ARG (rw);
01044   ACE_NOTSUP_RETURN (-1);
01045 #endif /* ACE_HAS_THREADS */
01046 }

ACE_INLINE int ACE_OS::rw_trywrlock_upgrade ( ACE_rwlock_t rw  ) 

Definition at line 1055 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), EBUSY, mutex_lock(), and mutex_unlock().

01056 {
01057   ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
01058 #if defined (ACE_HAS_THREADS)
01059 # if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01060   // This will probably result in -1, EDEADLK, at least on HP-UX, but let it
01061   // go - it's a more descriptive error than ENOTSUP.
01062   int result;
01063   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01064                                        result),
01065                      int, -1);
01066 # elif !defined (ACE_LACKS_RWLOCK_T)
01067   // Some native rwlocks, such as those on Solaris, don't
01068   // support the upgrade feature . . .
01069   ACE_UNUSED_ARG (rw);
01070   ACE_NOTSUP_RETURN (-1);
01071 # else /* NT, POSIX, and VxWorks don't support this natively. */
01072   // The ACE rwlock emulation does support upgrade . . .
01073   int result = 0;
01074 
01075 #   if defined (ACE_HAS_PTHREADS)
01076   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01077 #   endif /* defined (ACE_HAS_PTHREADS) */
01078 
01079   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01080     return -1;
01081     // -1 means didn't get the mutex, error
01082   else if (rw->important_writer_)
01083     // an other reader upgrades already
01084     {
01085       result = -1;
01086       errno = EBUSY;
01087     }
01088   else
01089     {
01090       while (rw->ref_count_ > 1) // wait until only I am left
01091         {
01092           rw->num_waiting_writers_++; // prohibit any more readers
01093           rw->important_writer_ = 1;
01094 
01095           if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1)
01096             {
01097               result = -1;
01098               // we know that we have the lock again, we have this guarantee,
01099               // but something went wrong
01100             }
01101           rw->important_writer_ = 0;
01102           rw->num_waiting_writers_--;
01103         }
01104       if (result == 0)
01105         {
01106           // nothing bad happend
01107           rw->ref_count_ = -1;
01108           // now I am a writer
01109           // everything is O.K.
01110         }
01111     }
01112 
01113   ACE_OS::mutex_unlock (&rw->lock_);
01114 
01115 #   if defined (ACE_HAS_PTHREADS)
01116   ACE_PTHREAD_CLEANUP_POP (0);
01117 #   endif /* defined (ACE_HAS_PTHREADS) */
01118 
01119   return result;
01120 
01121 # endif /* ! ACE_LACKS_RWLOCK_T */
01122 #else
01123   ACE_UNUSED_ARG (rw);
01124   ACE_NOTSUP_RETURN (-1);
01125 #endif /* ACE_HAS_THREADS */
01126 }

ACE_INLINE int ACE_OS::rw_unlock ( ACE_rwlock_t rw  ) 

Definition at line 1129 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), and rw_unlock().

Referenced by rw_unlock().

01130 {
01131   ACE_OS_TRACE ("ACE_OS::rw_unlock");
01132 #if defined (ACE_HAS_THREADS)
01133 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01134 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01135   int result;
01136   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
01137                                        result),
01138                      int, -1);
01139 #  else /* Solaris */
01140   int result;
01141   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), result), int, -1);
01142 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01143 # else /* NT, POSIX, and VxWorks don't support this natively. */
01144   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01145     return -1;
01146 
01147   if (rw->ref_count_ > 0) // Releasing a reader.
01148     rw->ref_count_--;
01149   else if (rw->ref_count_ == -1) // Releasing a writer.
01150     rw->ref_count_ = 0;
01151   else
01152     {
01153       (void) ACE_OS::mutex_unlock (&rw->lock_);
01154       return -1; // @@ ACE_ASSERT (!"count should not be 0!\n");
01155     }
01156 
01157   int result = 0;
01158   ACE_Errno_Guard error (errno);
01159 
01160   if (rw->important_writer_ && rw->ref_count_ == 1)
01161     // only the reader requesting to upgrade its lock is left over.
01162     {
01163       result = ACE_OS::cond_signal (&rw->waiting_important_writer_);
01164       error = errno;
01165     }
01166   else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0)
01167     // give preference to writers over readers...
01168     {
01169       result = ACE_OS::cond_signal (&rw->waiting_writers_);
01170       error =  errno;
01171     }
01172   else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0)
01173     {
01174       result = ACE_OS::cond_broadcast (&rw->waiting_readers_);
01175       error = errno;
01176     }
01177 
01178   (void) ACE_OS::mutex_unlock (&rw->lock_);
01179   return result;
01180 # endif /* ! ace_lacks_rwlock_t */
01181 #else
01182   ACE_UNUSED_ARG (rw);
01183   ACE_NOTSUP_RETURN (-1);
01184 #endif /* ace_has_threads */
01185 }

ACE_INLINE int ACE_OS::rw_wrlock ( ACE_rwlock_t rw  ) 

Definition at line 1188 of file OS_NS_Thread.inl.

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

Referenced by rw_wrlock().

01189 {
01190   ACE_OS_TRACE ("ACE_OS::rw_wrlock");
01191 #if defined (ACE_HAS_THREADS)
01192 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01193 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01194   int result;
01195   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
01196                                        result),
01197                      int, -1);
01198 #  else /* Solaris */
01199   int result;
01200   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), result), int, -1);
01201 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01202 # else /* NT, POSIX, and VxWorks don't support this natively. */
01203 #   if defined (ACE_HAS_PTHREADS)
01204   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01205 #   endif /* defined (ACE_HAS_PTHREADS) */
01206   int result = 0;
01207 
01208   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01209     result = -1; // -1 means didn't get the mutex.
01210   else
01211     {
01212       while (rw->ref_count_ != 0)
01213         {
01214           rw->num_waiting_writers_++;
01215 
01216           if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1)
01217             {
01218               result = -2; // -2 means we need to release the mutex.
01219               break;
01220             }
01221 
01222           rw->num_waiting_writers_--;
01223         }
01224     }
01225   if (result == 0)
01226     rw->ref_count_ = -1;
01227   if (result != -1)
01228     ACE_OS::mutex_unlock (&rw->lock_);
01229 #   if defined (ACE_HAS_PTHREADS)
01230   ACE_PTHREAD_CLEANUP_POP (0);
01231 #   endif /* defined (ACE_HAS_PTHREADS) */
01232   return 0;
01233 # endif /* ! ACE_LACKS_RWLOCK_T */
01234 #else
01235   ACE_UNUSED_ARG (rw);
01236   ACE_NOTSUP_RETURN (-1);
01237 #endif /* ACE_HAS_THREADS */
01238 }

ACE_INLINE int ACE_OS::rwlock_destroy ( ACE_rwlock_t rw  ) 

Definition at line 1241 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_destroy(), mutex_destroy(), and rwlock_destroy().

Referenced by rwlock_destroy().

01242 {
01243   ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
01244 #if defined (ACE_HAS_THREADS)
01245 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01246 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01247   int result;
01248   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
01249                                        result),
01250                      int, -1);
01251 #  else /* Solaris */
01252   int result;
01253   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), result), int, -1);
01254 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01255 # else /* NT, POSIX, and VxWorks don't support this natively. */
01256   ACE_OS::mutex_destroy (&rw->lock_);
01257   ACE_OS::cond_destroy (&rw->waiting_readers_);
01258   ACE_OS::cond_destroy (&rw->waiting_important_writer_);
01259   return ACE_OS::cond_destroy (&rw->waiting_writers_);
01260 # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */
01261 #else
01262   ACE_UNUSED_ARG (rw);
01263   ACE_NOTSUP_RETURN (-1);
01264 #endif /* ACE_HAS_THREADS */
01265 }

ACE_INLINE int ACE_OS::sema_destroy ( ACE_sema_t s  ) 

Definition at line 1305 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, close(), cond_destroy(), event_destroy(), free(), mutex_destroy(), sema_destroy(), shm_unlink(), thread_mutex_destroy(), and unlink().

Referenced by event_destroy(), ACE_Semaphore::remove(), and sema_destroy().

01306 {
01307   ACE_OS_TRACE ("ACE_OS::sema_destroy");
01308 # if defined (ACE_HAS_POSIX_SEM)
01309   int result;
01310 #   if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01311   ACE_OS::mutex_destroy (&s->lock_);
01312   ACE_OS::cond_destroy (&s->count_nonzero_);
01313 #   endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01314 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01315   if (s->name_)
01316     {
01317       // Only destroy the semaphore if we're the ones who
01318       // initialized it.
01319       ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
01320       ACE_OS::shm_unlink (s->name_);
01321       delete s->name_;
01322       return result;
01323     }
01324 #   else
01325   if (s->name_)
01326     {
01327       ACE_OSCALL (::sem_unlink (s->name_), int, -1, result);
01328       ACE_OS::free ((void *) s->name_);
01329       ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
01330     }
01331 #   endif /*  ACE_LACKS_NAMED_POSIX_SEM */
01332   else
01333     {
01334       ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
01335 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01336       if (s->new_sema_)
01337 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
01338         delete s->sema_;
01339       s->sema_ = 0;
01340       return result;
01341     }
01342 # elif defined (ACE_USES_FIFO_SEM)
01343   int r0 = 0;
01344   if (s->name_)
01345     {
01346       r0 = ACE_OS::unlink (s->name_);
01347       ACE_OS::free (s->name_);
01348       s->name_ = 0;
01349     }
01350   int r1 = ACE_OS::close (s->fd_[0]);      /* ignore error */
01351   int r2 = ACE_OS::close (s->fd_[1]);      /* ignore error */
01352   return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0;
01353 # elif defined (ACE_HAS_THREADS)
01354 #   if defined (ACE_HAS_STHREADS)
01355   int result;
01356   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1);
01357 #   elif defined (ACE_HAS_PTHREADS)
01358   int r1 = ACE_OS::mutex_destroy (&s->lock_);
01359   int r2 = ACE_OS::cond_destroy (&s->count_nonzero_);
01360   return r1 != 0 || r2 != 0 ? -1 : 0;
01361 #   elif defined (ACE_HAS_WTHREADS)
01362 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01363   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1);
01364 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01365   // Free up underlying objects of the simulated semaphore.
01366   int r1 = ACE_OS::thread_mutex_destroy (&s->lock_);
01367   int r2 = ACE_OS::event_destroy (&s->count_nonzero_);
01368   return r1 != 0 || r2 != 0 ? -1 : 0;
01369 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01370 #   elif defined (ACE_VXWORKS)
01371   int result;
01372   ACE_OSCALL (::semDelete (s->sema_), int, -1, result);
01373   s->sema_ = 0;
01374   return result;
01375 #   endif /* ACE_HAS_STHREADS */
01376 # else
01377   ACE_UNUSED_ARG (s);
01378   ACE_NOTSUP_RETURN (-1);
01379 # endif /* ACE_HAS_POSIX_SEM */
01380 }

ACE_INLINE int ACE_OS::sema_init ( ACE_sema_t s,
u_int  count,
int  type,
const char *  name,
void *  arg,
int  max,
LPSECURITY_ATTRIBUTES  sa 
)

Definition at line 1386 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_ALLOCATOR_RETURN, ACE_DEFAULT_FILE_PERMS, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, ACE_UNIQUE_NAME_LEN, close(), cond_destroy(), cond_init(), event_destroy(), event_init(), F_GETFL, fcntl(), ftruncate(), MAP_FAILED, MAXPATHLEN, mkfifo(), mmap(), mutex_destroy(), mutex_init(), mutex_lock(), mutex_unlock(), O_NONBLOCK, open(), PROT_RDWR, sema_init(), shm_open(), stat(), strcat(), strcpy(), strdup(), strrchr(), thread_mutex_destroy(), thread_mutex_init(), thread_mutex_lock(), thread_mutex_unlock(), uname(), unique_name(), unlink(), USYNC_PROCESS, USYNC_THREAD, and write().

Referenced by ACE_Semaphore::ACE_Semaphore(), event_init(), and sema_init().

01393 {
01394   ACE_OS_TRACE ("ACE_OS::sema_init");
01395 #if defined (ACE_HAS_POSIX_SEM)
01396   ACE_UNUSED_ARG (max);
01397   ACE_UNUSED_ARG (sa);
01398 
01399   s->name_ = 0;
01400 #  if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01401   ACE_UNUSED_ARG (arg);
01402 #  else
01403   int result = -1;
01404 
01405   if (ACE_OS::mutex_init (&s->lock_, type, name,
01406                           (ACE_mutexattr_t *) arg) == 0
01407       && ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) == 0
01408       && ACE_OS::mutex_lock (&s->lock_) == 0)
01409     {
01410       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01411         result = 0;
01412     }
01413 
01414   if (result == -1)
01415     {
01416       ACE_OS::mutex_destroy (&s->lock_);
01417       ACE_OS::cond_destroy (&s->count_nonzero_);
01418       return result;
01419     }
01420 #  endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01421 
01422 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01423   s->new_sema_ = false;
01424   if (type == USYNC_PROCESS)
01425     {
01426       // Let's see if it already exists.
01427       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01428                                         O_RDWR | O_CREAT | O_EXCL,
01429                                         ACE_DEFAULT_FILE_PERMS);
01430       if (fd == ACE_INVALID_HANDLE)
01431         {
01432           if (errno == EEXIST)
01433             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01434                                    O_RDWR | O_CREAT,
01435                                    ACE_DEFAULT_FILE_PERMS);
01436           else
01437             return -1;
01438         }
01439       else
01440         {
01441           // We own this shared memory object!  Let's set its
01442           // size.
01443           if (ACE_OS::ftruncate (fd,
01444                                  sizeof (ACE_sema_t)) == -1)
01445             return -1;
01446           s->name_ = ACE_OS::strdup (name);
01447           if (s->name_ == 0)
01448             return -1;
01449         }
01450       if (fd == -1)
01451         return -1;
01452 
01453       s->sema_ = (sem_t *)
01454         ACE_OS::mmap (0,
01455                       sizeof (ACE_sema_t),
01456                       PROT_RDWR,
01457                       MAP_SHARED,
01458                       fd,
01459                       0);
01460       ACE_OS::close (fd);
01461       if (s->sema_ == (sem_t *) MAP_FAILED)
01462         return -1;
01463       if (s->name_
01464           // @@ According UNIX Network Programming V2 by Stevens,
01465           //    sem_init() is currently not required to return zero on
01466           //    success, but it *does* return -1 upon failure.  For
01467           //    this reason, check for failure by comparing to -1,
01468           //    instead of checking for success by comparing to zero.
01469           //        -Ossama
01470           // Only initialize it if we're the one who created it.
01471           && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1)
01472         return -1;
01473       return 0;
01474     }
01475 #  else
01476   if (name)
01477     {
01478 #    if defined (sun) || defined (HPUX)
01479       // Solaris and HP-UX require the name to start with a slash. Solaris
01480       // further requires that there be no other slashes than the first.
01481       const char *last_slash = ACE_OS::strrchr (name, '/');
01482       char name2[MAXPATHLEN];
01483       if (0 == last_slash)
01484         {
01485           ACE_OS::strcpy (name2, "/");
01486           ACE_OS::strcat (name2, name);
01487           name = name2;
01488         }
01489 #      if defined (sun)
01490       else
01491         name = last_slash;         // Chop off chars preceding last slash
01492 #      endif /* sun */
01493 #    endif /* sun || HPUX */
01494 
01495       ACE_ALLOCATOR_RETURN (s->name_,
01496                             ACE_OS::strdup (name),
01497                             -1);
01498       s->sema_ = ::sem_open (s->name_,
01499                              O_CREAT,
01500                              ACE_DEFAULT_FILE_PERMS,
01501                              count);
01502       if (s->sema_ == (sem_t *) SEM_FAILED)
01503         return -1;
01504       else
01505         return 0;
01506     }
01507 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01508   else
01509     {
01510       ACE_NEW_RETURN (s->sema_,
01511                       sem_t,
01512                       -1);
01513 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01514       s->new_sema_ = true;
01515 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01516       ACE_OSCALL_RETURN (::sem_init (s->sema_,
01517                                      type != USYNC_THREAD,
01518                                      count), int, -1);
01519     }
01520 
01521 #elif defined (ACE_USES_FIFO_SEM)
01522   ACE_UNUSED_ARG (arg);
01523   ACE_UNUSED_ARG (max);
01524   ACE_UNUSED_ARG (sa);
01525   int             flags = 0;
01526   mode_t          mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;
01527 
01528   if (type == USYNC_THREAD)
01529     {
01530       // Create systemwide unique name for semaphore
01531       char   uname[ACE_UNIQUE_NAME_LEN];
01532       ACE_OS::unique_name ((const void *) s,
01533                             uname,
01534                             ACE_UNIQUE_NAME_LEN);
01535       name = &uname[0];
01536     }
01537 
01538   s->name_ = 0;
01539   s->fd_[0] = s->fd_[1] = ACE_INVALID_HANDLE;
01540   bool creator = false;
01541 
01542   if (ACE_OS::mkfifo (ACE_TEXT_CHAR_TO_TCHAR (name), mode) < 0)
01543     {
01544       if (errno != EEXIST)    /* already exists OK else ERR */
01545         return -1;
01546       // check if this is a real FIFO, not just some other existing file
01547       ACE_stat fs;
01548       if (ACE_OS::stat (name, &fs))
01549         return -1;
01550       if (!S_ISFIFO (fs.st_mode))
01551         {
01552           // existing file is not a FIFO
01553           errno = EEXIST;
01554           return -1;
01555         }
01556     }
01557     else
01558       creator = true; // remember we created it for initialization at end
01559 
01560   // for processshared semaphores remember who we are to be able to remove
01561   // the FIFO when we're done with it
01562   if (type == USYNC_PROCESS)
01563     {
01564       s->name_ = ACE_OS::strdup (name);
01565       if (s->name_ == 0)
01566         {
01567           if (creator)
01568             ACE_OS::unlink (name);
01569           return -1;
01570         }
01571     }
01572 
01573   if ((s->fd_[0] = ACE_OS::open (name, O_RDONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE
01574       || (s->fd_[1] = ACE_OS::open (name, O_WRONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE)
01575     return (-1);
01576 
01577   /* turn off nonblocking for fd_[0] */
01578   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01579     return (-1);
01580 
01581   flags &= ~O_NONBLOCK;
01582   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01583     return (-1);
01584 
01585   //if (s->name_ && count)
01586   if (creator && count)
01587     {
01588       char    c = 1;
01589       for (u_int i=0; i<count ;++i)
01590         if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) != 1)
01591           return (-1);
01592     }
01593 
01594   // In the case of process scope semaphores we can already unlink the FIFO now that
01595   // we completely set it up (the opened handles will keep it active until we close
01596   // thos down). This way we're protected against unexpected crashes as far as removal
01597   // is concerned.
01598   // Unfortunately this does not work for processshared FIFOs since as soon as we
01599   // have unlinked the semaphore no other process will be able to open it anymore.
01600   if (type == USYNC_THREAD)
01601     {
01602       ACE_OS::unlink (name);
01603     }
01604 
01605   return (0);
01606 #elif defined (ACE_HAS_THREADS)
01607 #  if defined (ACE_HAS_STHREADS)
01608   ACE_UNUSED_ARG (name);
01609   ACE_UNUSED_ARG (max);
01610   ACE_UNUSED_ARG (sa);
01611   int result;
01612   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), result),
01613                      int, -1);
01614 #  elif defined (ACE_HAS_PTHREADS)
01615   ACE_UNUSED_ARG (max);
01616   ACE_UNUSED_ARG (sa);
01617   int result = -1;
01618 
01619   if (ACE_OS::mutex_init (&s->lock_, type, name,
01620                           (ACE_mutexattr_t *) arg) == 0
01621       && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0
01622       && ACE_OS::mutex_lock (&s->lock_) == 0)
01623     {
01624       s->count_ = count;
01625       s->waiters_ = 0;
01626 
01627       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01628         result = 0;
01629     }
01630 
01631   if (result == -1)
01632     {
01633       ACE_OS::mutex_destroy (&s->lock_);
01634       ACE_OS::cond_destroy (&s->count_nonzero_);
01635     }
01636   return result;
01637 #  elif defined (ACE_HAS_WTHREADS)
01638 #    if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01639   ACE_UNUSED_ARG (type);
01640   ACE_UNUSED_ARG (arg);
01641   // Create the semaphore with its value initialized to <count> and
01642   // its maximum value initialized to <max>.
01643   SECURITY_ATTRIBUTES sa_buffer;
01644   SECURITY_DESCRIPTOR sd_buffer;
01645   *s = ::CreateSemaphoreA
01646     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01647      count,
01648      max,
01649      name);
01650 
01651   if (*s == 0)
01652     ACE_FAIL_RETURN (-1);
01653   /* NOTREACHED */
01654   else
01655     return 0;
01656 #    else /* ACE_USES_WINCE_SEMA_SIMULATION */
01657   int result = -1;
01658 
01659   // Initialize internal object for semaphore simulation.
01660   // Grab the lock as soon as possible when we initializing
01661   // the semaphore count.  Notice that we initialize the
01662   // event object as "manually reset" so we can amortize the
01663   // cost for singling/reseting the event.
01664   // @@ I changed the mutex type to thread_mutex.  Notice that this
01665   // is basically a CriticalSection object and doesn't not has
01666   // any security attribute whatsoever.  However, since this
01667   // semaphore implementation only works within a process, there
01668   // shouldn't any security issue at all.
01669   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01670       && ACE_OS::event_init (&s->count_nonzero_, 1,
01671                              count > 0, type, name, arg, sa) == 0
01672       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01673     {
01674       s->count_ = count;
01675 
01676       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01677         result = 0;
01678     }
01679 
01680   // Destroy the internal objects if we didn't initialize
01681   // either of them successfully.  Don't bother to check
01682   // for errors.
01683   if (result == -1)
01684     {
01685       ACE_OS::thread_mutex_destroy (&s->lock_);
01686       ACE_OS::event_destroy (&s->count_nonzero_);
01687     }
01688   return result;
01689 #    endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01690 #  elif defined (ACE_VXWORKS)
01691   ACE_UNUSED_ARG (name);
01692   ACE_UNUSED_ARG (arg);
01693   ACE_UNUSED_ARG (max);
01694   ACE_UNUSED_ARG (sa);
01695   s->name_ = 0;
01696   s->sema_ = ::semCCreate (type, count);
01697   return s->sema_ ? 0 : -1;
01698 #  endif /* ACE_HAS_STHREADS */
01699 #else
01700   ACE_UNUSED_ARG (s);
01701   ACE_UNUSED_ARG (count);
01702   ACE_UNUSED_ARG (type);
01703   ACE_UNUSED_ARG (name);
01704   ACE_UNUSED_ARG (arg);
01705   ACE_UNUSED_ARG (max);
01706   ACE_UNUSED_ARG (sa);
01707   ACE_NOTSUP_RETURN (-1);
01708 #endif /* ACE_HAS_POSIX_SEM */
01709 }

ACE_INLINE int ACE_OS::sema_post ( ACE_sema_t s  ) 

Definition at line 1782 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_signal(), event_signal(), mutex_lock(), mutex_unlock(), sema_post(), thread_mutex_lock(), thread_mutex_unlock(), and write().

01783 {
01784   ACE_OS_TRACE ("ACE_OS::sema_post");
01785 # if defined (ACE_HAS_POSIX_SEM)
01786 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01787   ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1);
01788 #   else
01789   int result = -1;
01790 
01791   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01792     {
01793       if (::sem_post (s->sema_) == 0)
01794         result = ACE_OS::cond_signal (&s->count_nonzero_);
01795 
01796       ACE_OS::mutex_unlock (&s->lock_);
01797     }
01798   return result;
01799 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01800 # elif defined (ACE_USES_FIFO_SEM)
01801   char    c = 1;
01802   if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) == sizeof (char))
01803     return (0);
01804   return (-1);
01805 # elif defined (ACE_HAS_THREADS)
01806 #   if defined (ACE_HAS_STHREADS)
01807   int result;
01808   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), result), int, -1);
01809 #   elif defined (ACE_HAS_PTHREADS)
01810   int result = -1;
01811 
01812   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01813     {
01814       // Always allow a waiter to continue if there is one.
01815       if (s->waiters_ > 0)
01816         result = ACE_OS::cond_signal (&s->count_nonzero_);
01817       else
01818         result = 0;
01819 
01820       s->count_++;
01821       ACE_OS::mutex_unlock (&s->lock_);
01822     }
01823   return result;
01824 #   elif defined (ACE_HAS_WTHREADS)
01825 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01826   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
01827                                           ace_result_),
01828                         int, -1);
01829 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01830   int result = -1;
01831 
01832   // Since we are simulating semaphores, we need to update semaphore
01833   // count manually.  Grab the lock to prevent race condition first.
01834   if (ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01835     {
01836       // Check the original state of event object.  Single the event
01837       // object in transition from semaphore not available to
01838       // semaphore available.
01839       if (s->count_++ <= 0)
01840         result = ACE_OS::event_signal (&s->count_nonzero_);
01841       else
01842         result = 0;
01843 
01844       ACE_OS::thread_mutex_unlock (&s->lock_);
01845     }
01846   return result;
01847 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01848 #   elif defined (ACE_VXWORKS)
01849   ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1);
01850 #   endif /* ACE_HAS_STHREADS */
01851 # else
01852   ACE_UNUSED_ARG (s);
01853   ACE_NOTSUP_RETURN (-1);
01854 # endif /* ACE_HAS_POSIX_SEM */
01855 }

ACE_INLINE int ACE_OS::sema_post ( ACE_sema_t s,
u_int  release_count 
)

Definition at line 1858 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, and sema_post().

01859 {
01860 #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01861   // Win32 supports this natively.
01862   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
01863                                           ace_result_), int, -1);
01864 #else
01865   // On POSIX platforms we need to emulate this ourselves.
01866   // @@ We can optimize on this implementation.  However,
01867   // the semaphore promitive on Win32 doesn't allow one
01868   // to increase a semaphore to more than the count it was
01869   // first initialized.  Posix and solaris don't seem to have
01870   // this restriction.  Should we impose the restriction in
01871   // our semaphore simulation?
01872   for (size_t i = 0; i < release_count; i++)
01873     if (ACE_OS::sema_post (s) == -1)
01874       return -1;
01875 
01876   return 0;
01877 #endif /* ACE_WIN32 */
01878 }

ACE_INLINE int ACE_OS::sema_trywait ( ACE_sema_t s  ) 

Definition at line 1881 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, event_reset(), F_GETFL, fcntl(), mutex_lock(), mutex_unlock(), O_NONBLOCK, read(), sema_trywait(), set_errno_to_last_error(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by sema_trywait(), sema_wait(), and ACE_Semaphore::tryacquire().

01882 {
01883   ACE_OS_TRACE ("ACE_OS::sema_trywait");
01884 # if defined (ACE_HAS_POSIX_SEM)
01885   // POSIX semaphores set errno to EAGAIN if trywait fails
01886   ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1);
01887 # elif defined (ACE_USES_FIFO_SEM)
01888   char  c;
01889   int     rc, flags;
01890 
01891   /* turn on nonblocking for s->fd_[0] */
01892   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01893     return (-1);
01894   flags |= O_NONBLOCK;
01895   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01896     return (-1);
01897 
01898   // read sets errno to EAGAIN if no input
01899   rc = ACE_OS::read (s->fd_[0], &c, sizeof (char));
01900 
01901   /* turn off nonblocking for fd_[0] */
01902   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) >= 0)
01903   {
01904     flags &= ~O_NONBLOCK;
01905     ACE_OS::fcntl (s->fd_[0], F_SETFL, flags);
01906   }
01907 
01908   return rc == 1 ? 0 : (-1);
01909 # elif defined (ACE_HAS_THREADS)
01910 #   if defined (ACE_HAS_STHREADS)
01911   // STHREADS semaphores set errno to EBUSY if trywait fails.
01912   int result;
01913   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s),
01914                                        result),
01915                      int, -1);
01916 #   elif defined (ACE_HAS_PTHREADS)
01917 
01918   int result = -1;
01919 
01920   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01921     {
01922       if (s->count_ > 0)
01923         {
01924           --s->count_;
01925           result = 0;
01926         }
01927       else
01928         errno = EBUSY;
01929 
01930       ACE_OS::mutex_unlock (&s->lock_);
01931     }
01932   return result;
01933 #   elif defined (ACE_HAS_WTHREADS)
01934 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01935   DWORD result = ::WaitForSingleObject (*s, 0);
01936 
01937   if (result == WAIT_OBJECT_0)
01938     return 0;
01939   else
01940     {
01941       if (result == WAIT_TIMEOUT)
01942         errno = EBUSY;
01943       else
01944         ACE_OS::set_errno_to_last_error ();
01945       // This is a hack, we need to find an appropriate mapping...
01946       return -1;
01947     }
01948 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01949   // Check the status of semaphore first.  Return immediately
01950   // if the semaphore is not available and avoid grabing the
01951   // lock.
01952   DWORD result = ::WaitForSingleObject (s->count_nonzero_, 0);
01953 
01954   if (result == WAIT_OBJECT_0)  // Proceed when it is available.
01955     {
01956       ACE_OS::thread_mutex_lock (&s->lock_);
01957 
01958       // Need to double check if the semaphore is still available.
01959       // The double checking scheme will slightly affect the
01960       // efficiency if most of the time semaphores are not blocked.
01961       result = ::WaitForSingleObject (s->count_nonzero_, 0);
01962       if (result == WAIT_OBJECT_0)
01963         {
01964           // Adjust the semaphore count.  Only update the event
01965           // object status when the state changed.
01966           s->count_--;
01967           if (s->count_ <= 0)
01968             ACE_OS::event_reset (&s->count_nonzero_);
01969           result = 0;
01970         }
01971 
01972       ACE_OS::thread_mutex_unlock (&s->lock_);
01973     }
01974 
01975   // Translate error message to errno used by ACE.
01976   if (result == WAIT_TIMEOUT)
01977     errno = EBUSY;
01978   else
01979     ACE_OS::set_errno_to_last_error ();
01980   // This is taken from the hack above. ;)
01981   return -1;
01982 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01983 #   elif defined (ACE_VXWORKS)
01984   if (::semTake (s->sema_, NO_WAIT) == ERROR)
01985     if (errno == S_objLib_OBJ_UNAVAILABLE)
01986       {
01987         // couldn't get the semaphore
01988         errno = EBUSY;
01989         return -1;
01990       }
01991     else
01992       // error
01993       return -1;
01994   else
01995     // got the semaphore
01996     return 0;
01997 #   endif /* ACE_HAS_STHREADS */
01998 # else
01999   ACE_UNUSED_ARG (s);
02000   ACE_NOTSUP_RETURN (-1);
02001 # endif /* ACE_HAS_POSIX_SEM */
02002 }

ACE_INLINE int ACE_OS::sema_wait ( ACE_sema_t s  ) 

Definition at line 2005 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), event_reset(), mutex_lock(), mutex_unlock(), read(), sema_wait(), set_errno_to_last_error(), and thread_mutex_lock().

02006 {
02007   ACE_OS_TRACE ("ACE_OS::sema_wait");
02008 # if defined (ACE_HAS_POSIX_SEM)
02009   ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1);
02010 # elif defined (ACE_USES_FIFO_SEM)
02011   char c;
02012   if (ACE_OS::read (s->fd_[0], &c, sizeof (char)) == 1)
02013     return (0);
02014   return (-1);
02015 # elif defined (ACE_HAS_THREADS)
02016 #   if defined (ACE_HAS_STHREADS)
02017   int result;
02018   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), result), int, -1);
02019 #   elif defined (ACE_HAS_PTHREADS)
02020   int result = 0;
02021 
02022   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02023 
02024   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02025     result = -1;
02026   else
02027     {
02028       // Keep track of the number of waiters so that we can signal
02029       // them properly in <ACE_OS::sema_post>.
02030       s->waiters_++;
02031 
02032       // Wait until the semaphore count is > 0.
02033       while (s->count_ == 0)
02034         if (ACE_OS::cond_wait (&s->count_nonzero_,
02035                                &s->lock_) == -1)
02036           {
02037             result = -2; // -2 means that we need to release the mutex.
02038             break;
02039           }
02040 
02041       --s->waiters_;
02042     }
02043 
02044   if (result == 0)
02045     --s->count_;
02046 
02047   if (result != -1)
02048     ACE_OS::mutex_unlock (&s->lock_);
02049   ACE_PTHREAD_CLEANUP_POP (0);
02050   return result < 0 ? -1 : result;
02051 
02052 #   elif defined (ACE_HAS_WTHREADS)
02053 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02054   switch (::WaitForSingleObject (*s, INFINITE))
02055     {
02056     case WAIT_OBJECT_0:
02057       return 0;
02058     default:
02059       // This is a hack, we need to find an appropriate mapping...
02060       ACE_OS::set_errno_to_last_error ();
02061       return -1;
02062     }
02063   /* NOTREACHED */
02064 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02065   // Timed wait.
02066   int result = -1;
02067   for (;;)
02068     // Check if the semaphore is avialable or not and wait forever.
02069     // Don't bother to grab the lock if it is not available (to avoid
02070     // deadlock.)
02071     switch (::WaitForSingleObject (s->count_nonzero_, INFINITE))
02072       {
02073       case WAIT_OBJECT_0:
02074         ACE_OS::thread_mutex_lock (&s->lock_);
02075 
02076         // Need to double check if the semaphore is still available.
02077         // This time, we shouldn't wait at all.
02078         if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02079           {
02080             // Decrease the internal counter.  Only update the event
02081             // object's status when the state changed.
02082             s->count_--;
02083             if (s->count_ <= 0)
02084               ACE_OS::event_reset (&s->count_nonzero_);
02085             result = 0;
02086           }
02087 
02088         ACE_OS::thread_mutex_unlock (&s->lock_);
02089         // if we didn't get a hold on the semaphore, the result won't
02090         // be 0 and thus, we'll start from the beginning again.
02091         if (result == 0)
02092           return 0;
02093         break;
02094 
02095       default:
02096         // Since we wait indefinitely, anything other than
02097         // WAIT_OBJECT_O indicates an error.
02098         ACE_OS::set_errno_to_last_error ();
02099         // This is taken from the hack above. ;)
02100         return -1;
02101       }
02102   /* NOTREACHED */
02103 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02104 #   elif defined (ACE_VXWORKS)
02105   ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1);
02106 #   endif /* ACE_HAS_STHREADS */
02107 # else
02108   ACE_UNUSED_ARG (s);
02109   ACE_NOTSUP_RETURN (-1);
02110 # endif /* ACE_HAS_POSIX_SEM */
02111 }

ACE_INLINE int ACE_OS::sema_wait ( ACE_sema_t s,
ACE_Time_Value tv 
)

Definition at line 2114 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_timedwait(), EBUSY, event_reset(), gettimeofday(), ACE_Handle_Set::MAXSIZE, ACE_Time_Value::msec(), mutex_lock(), mutex_unlock(), ACE_Time_Value::sec(), select(), sema_trywait(), ACE_Handle_Set::set_bit(), set_errno_to_last_error(), thread_mutex_lock(), thread_mutex_unlock(), ACE_Time_Value::usec(), and ACE_Time_Value::zero.

02115 {
02116   ACE_OS_TRACE ("ACE_OS::sema_wait");
02117 # if defined (ACE_HAS_POSIX_SEM)
02118 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
02119   int rc;
02120   timespec_t ts;
02121   ts = tv; // Calls ACE_Time_Value::operator timespec_t().
02122   ACE_OSCALL (::sem_timedwait (s->sema_, &ts), int, -1, rc);
02123   if (rc == -1 && errno == ETIMEDOUT)
02124     errno = ETIME;  /* POSIX returns ETIMEDOUT but we need ETIME */
02125   return rc;
02126 #   elif !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
02127   int result = 0;
02128   bool expired = false;
02129   ACE_Errno_Guard error (errno);
02130 
02131   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02132 
02133   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02134     result = -2;
02135   else
02136     {
02137       bool finished = true;
02138       do
02139       {
02140         result = ACE_OS::sema_trywait (s);
02141         if (result == -1 && errno == EAGAIN)
02142           expired = ACE_OS::gettimeofday () > tv;
02143         else
02144           expired = false;
02145 
02146         finished = result != -1 || expired ||
02147                    (result == -1 && errno != EAGAIN);
02148         if (!finished)
02149           {
02150             if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02151                                         &s->lock_,
02152                                         &tv) == -1)
02153               {
02154                 error = errno;
02155                 result = -1;
02156                 break;
02157               }
02158           }
02159       } while (!finished);
02160 
02161       if (expired)
02162         error = ETIME;
02163 
02164 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02165       tv = ACE_OS::gettimeofday ();
02166 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02167     }
02168 
02169   if (result != -2)
02170     ACE_OS::mutex_unlock (&s->lock_);
02171   ACE_PTHREAD_CLEANUP_POP (0);
02172   return result < 0 ? -1 : result;
02173 #   else /* No native sem_timedwait(), and emulation disabled */
02174   ACE_UNUSED_ARG (s);
02175   ACE_UNUSED_ARG (tv);
02176   ACE_NOTSUP_RETURN (-1);
02177 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT */
02178 # elif defined (ACE_USES_FIFO_SEM)
02179   int rc;
02180   ACE_Time_Value now = ACE_OS::gettimeofday ();
02181 
02182   while (tv > now)
02183     {
02184       ACE_Time_Value timeout = tv;
02185       timeout -= now;
02186 
02187       ACE_Handle_Set  fds_;
02188 
02189       fds_.set_bit (s->fd_[0]);
02190       if ((rc = ACE_OS::select (ACE_Handle_Set::MAXSIZE, fds_, 0, 0, timeout)) != 1)
02191         {
02192           if (rc == 0 || errno != EAGAIN)
02193           {
02194             if (rc == 0)
02195               errno = ETIME;
02196             return (-1);
02197           }
02198         }
02199 
02200       // try to read the signal *but* do *not* block
02201       if (rc == 1 && ACE_OS::sema_trywait (s) == 0)
02202         return (0);
02203 
02204       // we were woken for input but someone beat us to it
02205       // so we wait again if there is still time
02206       now = ACE_OS::gettimeofday ();
02207     }
02208 
02209   // make sure errno is set right
02210   errno = ETIME;
02211 
02212   return (-1);
02213 # elif defined (ACE_HAS_THREADS)
02214 #   if defined (ACE_HAS_STHREADS)
02215   ACE_UNUSED_ARG (s);
02216   ACE_UNUSED_ARG (tv);
02217   ACE_NOTSUP_RETURN (-1);
02218 #   elif defined (ACE_HAS_PTHREADS)
02219   int result = 0;
02220   ACE_Errno_Guard error (errno);
02221 
02222   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02223 
02224   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02225     result = -1;
02226   else
02227     {
02228       // Keep track of the number of waiters so that we can signal
02229       // them properly in <ACE_OS::sema_post>.
02230       s->waiters_++;
02231 
02232       // Wait until the semaphore count is > 0 or until we time out.
02233       while (s->count_ == 0)
02234         if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02235                                     &s->lock_,
02236                                     &tv) == -1)
02237           {
02238             error = errno;
02239             result = -2; // -2 means that we need to release the mutex.
02240             break;
02241           }
02242 
02243       --s->waiters_;
02244     }
02245 
02246   if (result == 0)
02247     {
02248 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02249       tv = ACE_OS::gettimeofday ();
02250 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02251       --s->count_;
02252     }
02253 
02254   if (result != -1)
02255     ACE_OS::mutex_unlock (&s->lock_);
02256   ACE_PTHREAD_CLEANUP_POP (0);
02257   return result < 0 ? -1 : result;
02258 #   elif defined (ACE_HAS_WTHREADS)
02259 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02260   int msec_timeout;
02261 
02262   if (tv.sec () == 0 && tv.usec () == 0)
02263     msec_timeout = 0; // Do a "poll."
02264   else
02265     {
02266       // Note that we must convert between absolute time (which is
02267       // passed as a parameter) and relative time (which is what
02268       // <WaitForSingleObjects> expects).
02269       ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02270 
02271       // Watchout for situations where a context switch has caused the
02272       // current time to be > the timeout.
02273       if (relative_time < ACE_Time_Value::zero)
02274         msec_timeout = 0;
02275       else
02276         msec_timeout = relative_time.msec ();
02277     }
02278 
02279   switch (::WaitForSingleObject (*s, msec_timeout))
02280     {
02281     case WAIT_OBJECT_0:
02282       tv = ACE_OS::gettimeofday ();     // Update time to when acquired
02283       return 0;
02284     case WAIT_TIMEOUT:
02285       errno = ETIME;
02286       return -1;
02287     default:
02288       // This is a hack, we need to find an appropriate mapping...
02289       ACE_OS::set_errno_to_last_error ();
02290       return -1;
02291     }
02292   /* NOTREACHED */
02293 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02294   // Note that in this mode, the acquire is done in two steps, and
02295   // we may get signaled but cannot grab the semaphore before
02296   // timeout.  In that case, we'll need to restart the process with
02297   // updated timeout value.
02298 
02299   // tv is an absolute time, but we need relative to work with the Windows
02300   // API. Also, some users have become accustomed to using a 0 time value
02301   // as a shortcut for "now", which works on non-Windows because 0 is
02302   // always earlier than now. However, the need to convert to relative time
02303   // means we need to watch out for this case.
02304   ACE_Time_Value end_time = tv;
02305   if (tv == ACE_Time_Value::zero)
02306     end_time = ACE_OS::gettimeofday ();
02307   ACE_Time_Value relative_time = end_time - ACE_OS::gettimeofday ();
02308   int result = -1;
02309 
02310   // While we are not timeout yet. >= 0 will let this go through once
02311   // and if not able to get the object, it should hit WAIT_TIMEOUT
02312   // right away.
02313   while (relative_time >= ACE_Time_Value::zero)
02314     {
02315       // Wait for our turn to get the object.
02316       switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ()))
02317         {
02318         case WAIT_OBJECT_0:
02319           ACE_OS::thread_mutex_lock (&s->lock_);
02320 
02321           // Need to double check if the semaphore is still available.
02322           // We can only do a "try lock" styled wait here to avoid
02323           // blocking threads that want to signal the semaphore.
02324           if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02325             {
02326               // As before, only reset the object when the semaphore
02327               // is no longer available.
02328               s->count_--;
02329               if (s->count_ <= 0)
02330                 ACE_OS::event_reset (&s->count_nonzero_);
02331               result = 0;
02332             }
02333 
02334           ACE_OS::thread_mutex_unlock (&s->lock_);
02335 
02336           // Only return when we successfully get the semaphore.
02337           if (result == 0)
02338             {
02339               tv = ACE_OS::gettimeofday ();     // Update to time acquired
02340               return 0;
02341             }
02342           break;
02343 
02344           // We have timed out.
02345         case WAIT_TIMEOUT:
02346           errno = ETIME;
02347           return -1;
02348 
02349           // What?
02350         default:
02351           ACE_OS::set_errno_to_last_error ();
02352           // This is taken from the hack above. ;)
02353           return -1;
02354         };
02355 
02356       // Haven't been able to get the semaphore yet, update the
02357       // timeout value to reflect the remaining time we want to wait.
02358       relative_time = end_time - ACE_OS::gettimeofday ();
02359     }
02360 
02361   // We have timed out.
02362   errno = ETIME;
02363   return -1;
02364 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02365 #   elif defined (ACE_VXWORKS)
02366   // Note that we must convert between absolute time (which is
02367   // passed as a parameter) and relative time (which is what
02368   // the system call expects).
02369   ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02370 
02371   int ticks_per_sec = ::sysClkRateGet ();
02372 
02373   int ticks = relative_time.sec () * ticks_per_sec +
02374               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02375   if (::semTake (s->sema_, ticks) == ERROR)
02376     {
02377       if (errno == S_objLib_OBJ_TIMEOUT)
02378         // Convert the VxWorks errno to one that's common for to ACE
02379         // platforms.
02380         errno = ETIME;
02381       else if (errno == S_objLib_OBJ_UNAVAILABLE)
02382         errno = EBUSY;
02383       return -1;
02384     }
02385   else
02386     {
02387       tv = ACE_OS::gettimeofday ();  // Update to time acquired
02388       return 0;
02389     }
02390 #   endif /* ACE_HAS_STHREADS */
02391 # else
02392   ACE_UNUSED_ARG (s);
02393   ACE_UNUSED_ARG (tv);
02394   ACE_NOTSUP_RETURN (-1);
02395 # endif /* ACE_HAS_POSIX_SEM */
02396 }

ACE_INLINE int ACE_OS::sema_wait ( ACE_sema_t s,
ACE_Time_Value tv 
)

Definition at line 2399 of file OS_NS_Thread.inl.

References sema_wait().

02400 {
02401   return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
02402 }

ACE_INLINE int ACE_OS::semctl ( int  int_id,
int  semnum,
int  cmd,
semun  value 
)

Definition at line 2405 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semctl().

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

02406 {
02407   ACE_OS_TRACE ("ACE_OS::semctl");
02408 #if defined (ACE_HAS_SYSV_IPC)
02409   ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1);
02410 #else
02411   ACE_UNUSED_ARG (int_id);
02412   ACE_UNUSED_ARG (semnum);
02413   ACE_UNUSED_ARG (cmd);
02414   ACE_UNUSED_ARG (value);
02415 
02416   ACE_NOTSUP_RETURN (-1);
02417 #endif /* ACE_HAS_SYSV_IPC */
02418 }

ACE_INLINE int ACE_OS::semget ( key_t  key,
int  nsems,
int  flags 
)

Definition at line 2421 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semget().

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

02422 {
02423   ACE_OS_TRACE ("ACE_OS::semget");
02424 #if defined (ACE_HAS_SYSV_IPC)
02425   ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1);
02426 #else
02427   ACE_UNUSED_ARG (key);
02428   ACE_UNUSED_ARG (nsems);
02429   ACE_UNUSED_ARG (flags);
02430 
02431   ACE_NOTSUP_RETURN (-1);
02432 #endif /* ACE_HAS_SYSV_IPC */
02433 }

ACE_INLINE int ACE_OS::semop ( int  int_id,
struct sembuf *  sops,
size_t  nsops 
)

Definition at line 2436 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semop().

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

02437 {
02438   ACE_OS_TRACE ("ACE_OS::semop");
02439 #if defined (ACE_HAS_SYSV_IPC)
02440   ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1);
02441 #else
02442   ACE_UNUSED_ARG (int_id);
02443   ACE_UNUSED_ARG (sops);
02444   ACE_UNUSED_ARG (nsops);
02445 
02446   ACE_NOTSUP_RETURN (-1);
02447 #endif /* ACE_HAS_SYSV_IPC */
02448 }

ACE_INLINE int ACE_OS::sigtimedwait ( const sigset_t *  sset,
siginfo_t info,
const ACE_Time_Value timeout 
)

Definition at line 2451 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sigtimedwait().

Referenced by sigtimedwait(), and sigwait().

02454 {
02455   ACE_OS_TRACE ("ACE_OS::sigtimedwait");
02456 #if defined (ACE_HAS_SIGTIMEDWAIT)
02457   timespec_t ts;
02458   timespec_t *tsp;
02459 
02460   if (timeout != 0)
02461     {
02462       ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
02463       tsp = &ts;
02464     }
02465   else
02466     tsp = 0;
02467 
02468   ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp),
02469                      int, -1);
02470 #else
02471     ACE_UNUSED_ARG (sset);
02472     ACE_UNUSED_ARG (info);
02473     ACE_UNUSED_ARG (timeout);
02474     ACE_NOTSUP_RETURN (-1);
02475 #endif /* ACE_HAS_SIGTIMEDWAIT */
02476 }

ACE_INLINE int ACE_OS::sigwait ( sigset_t *  sset,
int *  sig 
)

Definition at line 2479 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, sigtimedwait(), and sigwait().

02480 {
02481   ACE_OS_TRACE ("ACE_OS::sigwait");
02482   int local_sig;
02483   if (sig == 0)
02484     sig = &local_sig;
02485 #if defined (ACE_HAS_THREADS)
02486 # if (defined (__FreeBSD__) && (__FreeBSD__ < 3))
02487     ACE_UNUSED_ARG (sset);
02488     ACE_NOTSUP_RETURN (-1);
02489 # elif defined (ACE_HAS_STHREADS)
02490    # if (_POSIX_C_SOURCE - 0 >= 199506L) || defined (_POSIX_PTHREAD_SEMANTICS)
02491      errno = ::sigwait (sset, sig);
02492      return errno == 0  ?  *sig  :  -1;
02493    #else
02494      *sig = ::sigwait (sset);
02495      return *sig;
02496    #endif /* _POSIX_C_SOURCE - 0 >= 199506L || _POSIX_PTHREAD_SEMANTICS */
02497 # elif defined (ACE_HAS_PTHREADS)
02498   // LynxOS and Digital UNIX have their own hoops to jump through.
02499 #   if defined (__Lynx__)
02500     // Second arg is a void **, which we don't need (the selected
02501     // signal number is returned).
02502     *sig = ::sigwait (sset, 0);
02503     return *sig;
02504 #   elif defined (DIGITAL_UNIX)  &&  defined (__DECCXX_VER)
02505       // DEC cxx (but not g++) needs this direct call to its internal
02506       // sigwait ().  This allows us to #undef sigwait, so that we can
02507       // have ACE_OS::sigwait.  cxx gets confused by ACE_OS::sigwait
02508       // if sigwait is _not_ #undef'ed.
02509       errno = ::_Psigwait (sset, sig);
02510       return errno == 0  ?  *sig  :  -1;
02511 #   else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02512 #     if defined (CYGWIN32)
02513         // Cygwin has sigwait definition, but it is not implemented
02514         ACE_UNUSED_ARG (sset);
02515         ACE_NOTSUP_RETURN (-1);
02516 #     elif defined (ACE_TANDEM_T1248_PTHREADS)
02517         errno = ::spt_sigwait (sset, sig);
02518         return errno == 0  ?  *sig  :  -1;
02519 #     else   /* this is draft 7 or std */
02520         errno = ::sigwait (sset, sig);
02521         return errno == 0  ?  *sig  :  -1;
02522 #     endif /* CYGWIN32 */
02523 #   endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02524 # elif defined (ACE_HAS_WTHREADS)
02525     ACE_UNUSED_ARG (sset);
02526     ACE_NOTSUP_RETURN (-1);
02527 # elif defined (ACE_VXWORKS)
02528     // Second arg is a struct siginfo *, which we don't need (the
02529     // selected signal number is returned).  Third arg is timeout:  0
02530     // means forever.
02531     *sig = ::sigtimedwait (sset, 0, 0);
02532     return *sig;
02533 # endif /* __FreeBSD__ */
02534 #else
02535     ACE_UNUSED_ARG (sset);
02536     ACE_UNUSED_ARG (sig);
02537     ACE_NOTSUP_RETURN (-1);
02538 #endif /* ACE_HAS_THREADS */
02539 }

ACE_INLINE int ACE_OS::sigwaitinfo ( const sigset_t *  sset,
siginfo_t info 
)

Definition at line 2542 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sigwaitinfo().

Referenced by sigwaitinfo().

02544 {
02545   ACE_OS_TRACE ("ACE_OS::sigwaitinfo");
02546   // If this platform has sigtimedwait, it should have sigwaitinfo as well.
02547   // If this isn't true somewhere, let me know and I'll fix this.
02548   // -Steve Huston <shuston@riverace.com>.
02549 #if defined (ACE_HAS_SIGTIMEDWAIT)
02550   ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1);
02551 #else
02552   ACE_UNUSED_ARG (sset);
02553   ACE_UNUSED_ARG (info);
02554   ACE_NOTSUP_RETURN (-1);
02555 #endif /* ACE_HAS_SIGTIMEDWAIT */
02556 }

ACE_INLINE int ACE_OS::thr_cancel ( ACE_thread_t  thr_id  ) 

Definition at line 2559 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::cancel().

02560 {
02561   ACE_OS_TRACE ("ACE_OS::thr_cancel");
02562 #if defined (ACE_HAS_THREADS)
02563 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02564   int result;
02565   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02566                                         result),
02567                       int, -1);
02568 # elif defined (ACE_HAS_VXTHREADS)
02569   ACE_OSCALL_RETURN (::taskDelete (thr_id), int, -1);
02570 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
02571   ACE_UNUSED_ARG (thr_id);
02572   ACE_NOTSUP_RETURN (-1);
02573 # endif /* ACE_HAS_PTHREADS */
02574 #else
02575   ACE_UNUSED_ARG (thr_id);
02576   ACE_NOTSUP_RETURN (-1);
02577 #endif /* ACE_HAS_THREADS */
02578 }

ACE_INLINE int ACE_OS::thr_cmp ( ACE_hthread_t  t1,
ACE_hthread_t  t2 
)

Definition at line 2581 of file OS_NS_Thread.inl.

Referenced by ACE_Thread_Manager::find_hthread(), ACE_Thread_Manager::hthread_within(), ACE_Thread_ID::operator==(), and ACE_Thread_Descriptor_Base::operator==().

02582 {
02583 #if defined (ACE_HAS_PTHREADS)
02584 # if defined (pthread_equal)
02585   // If it's a macro we can't say "pthread_equal"...
02586   return pthread_equal (t1, t2);
02587 # else
02588   return pthread_equal (t1, t2);
02589 # endif /* pthread_equal */
02590 #else /* For STHREADS, WTHREADS, and VXWORKS ... */
02591   // Hum, Do we need to treat WTHREAD differently?
02592   // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE.
02593   return t1 == t2;
02594 #endif /* ACE_HAS_PTHREADS */
02595 }

ACE_INLINE int ACE_OS::thr_continue ( ACE_hthread_t  target_thread  ) 

Definition at line 2598 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_continue().

Referenced by ACE_Thread::resume(), thr_continue(), and thr_create().

02599 {
02600   ACE_OS_TRACE ("ACE_OS::thr_continue");
02601 #if defined (ACE_HAS_THREADS)
02602 # if defined (ACE_HAS_STHREADS)
02603   int result;
02604   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), result), int, -1);
02605 # elif defined (ACE_HAS_PTHREADS)
02606 #  if defined (ACE_HAS_PTHREAD_CONTINUE)
02607   int result;
02608   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread),
02609                                        result),
02610                      int, -1);
02611 #  elif defined (ACE_HAS_PTHREAD_CONTINUE_NP)
02612   int result;
02613   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue_np (target_thread),
02614                                        result),
02615                      int, -1);
02616 #  elif defined (ACE_HAS_PTHREAD_RESUME_NP)
02617   int result;
02618   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_resume_np (target_thread),
02619                                        result),
02620                      int, -1);
02621 #  else
02622   ACE_UNUSED_ARG (target_thread);
02623   ACE_NOTSUP_RETURN (-1);
02624 #  endif /* ACE_HAS_PTHREAD_CONTINUE */
02625 # elif defined (ACE_HAS_WTHREADS)
02626   DWORD result = ::ResumeThread (target_thread);
02627   if (result == ACE_SYSCALL_FAILED)
02628     ACE_FAIL_RETURN (-1);
02629   else
02630     return 0;
02631 # elif defined (ACE_HAS_VXTHREADS)
02632   ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1);
02633 # endif /* ACE_HAS_STHREADS */
02634 #else
02635   ACE_UNUSED_ARG (target_thread);
02636   ACE_NOTSUP_RETURN (-1);
02637 #endif /* ACE_HAS_THREADS */
02638 }

ACE_INLINE int ACE_OS::thr_getconcurrency ( void   ) 

Definition at line 2641 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_getconcurrency().

Referenced by ACE_Thread::getconcurrency(), thr_create(), and thr_getconcurrency().

02642 {
02643   ACE_OS_TRACE ("ACE_OS::thr_getconcurrency");
02644 #if defined (ACE_HAS_THREADS)
02645 # if defined (ACE_HAS_STHREADS)
02646   return ::thr_getconcurrency ();
02647 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_GETCONCURRENCY)
02648   return pthread_getconcurrency ();
02649 # else
02650   ACE_NOTSUP_RETURN (-1);
02651 # endif /* ACE_HAS_STHREADS */
02652 #else
02653   ACE_NOTSUP_RETURN (-1);
02654 #endif /* ACE_HAS_THREADS */
02655 }

ACE_INLINE int ACE_OS::thr_getprio ( ACE_hthread_t  ht_id,
int &  priority,
int &  policy 
)

Definition at line 2658 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_OTHER, and thr_getprio().

02659 {
02660   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02661   ACE_UNUSED_ARG (policy);
02662 #if defined (ACE_HAS_THREADS)
02663 # if (defined (ACE_HAS_PTHREADS) && \
02664      (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
02665 
02666   struct sched_param param;
02667   int result;
02668 
02669   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
02670                                 result), int,
02671               -1, result);
02672   priority = param.sched_priority;
02673   return result;
02674 # elif defined (ACE_HAS_STHREADS)
02675   int result;
02676   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (ht_id, &priority), result), int, -1);
02677 # elif defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE)
02678   ACE_Errno_Guard error (errno);
02679 
02680   priority = ::GetThreadPriority (ht_id);
02681 
02682 #   if defined (ACE_HAS_PHARLAP)
02683 #     if defined (ACE_PHARLAP_LABVIEW_RT)
02684   policy = ACE_SCHED_FIFO;
02685 #     else
02686   DWORD timeslice = ::EtsGetTimeSlice ();
02687   policy = timeslice == 0 ? ACE_SCHED_OTHER : ACE_SCHED_FIFO;
02688 #     endif /* ACE_PHARLAP_LABVIEW_RT */
02689 #   else
02690   DWORD priority_class = ::GetPriorityClass (::GetCurrentProcess ());
02691   if (priority_class == 0 && (error = ::GetLastError ()) != NO_ERROR)
02692     ACE_FAIL_RETURN (-1);
02693 
02694   policy =
02695     (priority_class ==
02696      REALTIME_PRIORITY_CLASS) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER;
02697 #   endif /* ACE_HAS_PHARLAP */
02698 
02699   return 0;
02700 # elif defined (ACE_HAS_VXTHREADS)
02701   ACE_OSCALL_RETURN (::taskPriorityGet (ht_id, &priority), int, -1);
02702 # else
02703   ACE_UNUSED_ARG (ht_id);
02704   ACE_UNUSED_ARG (priority);
02705   ACE_NOTSUP_RETURN (-1);
02706 # endif /* ACE_HAS_STHREADS */
02707 #else
02708   ACE_UNUSED_ARG (ht_id);
02709   ACE_UNUSED_ARG (priority);
02710   ACE_NOTSUP_RETURN (-1);
02711 #endif /* ACE_HAS_THREADS */
02712 }

ACE_INLINE int ACE_OS::thr_getprio ( ACE_hthread_t  ht_id,
int &  priority 
)

Definition at line 2715 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, and thr_getprio().

02716 {
02717   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02718   int policy = 0;
02719   return ACE_OS::thr_getprio (ht_id, priority, policy);
02720 }

ACE_INLINE int ACE_OS::thr_getspecific ( ACE_thread_key_t  key,
void **  data 
)

Definition at line 2751 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Thread::getspecific().

02752 {
02753 //   ACE_OS_TRACE ("ACE_OS::thr_getspecific");
02754 #if defined (ACE_HAS_THREADS)
02755 # if defined (ACE_HAS_TSS_EMULATION)
02756     if (ACE_TSS_Emulation::is_key (key) == 0)
02757       {
02758         errno = EINVAL;
02759         data = 0;
02760         return -1;
02761       }
02762     else
02763       {
02764         *data = ACE_TSS_Emulation::ts_object (key);
02765         return 0;
02766       }
02767 # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
02768   return ACE_OS::thr_getspecific_native (key, data);
02769 #else
02770   ACE_UNUSED_ARG (key);
02771   ACE_UNUSED_ARG (data);
02772   ACE_NOTSUP_RETURN (-1);
02773 # endif /* ACE_HAS_TSS_EMULATION */
02774 #else
02775   ACE_UNUSED_ARG (key);
02776   ACE_UNUSED_ARG (data);
02777   ACE_NOTSUP_RETURN (-1);
02778 #endif /* ACE_HAS_THREADS */
02779 }

ACE_INLINE int ACE_OS::thr_join ( ACE_hthread_t  thr_handle,
ACE_THR_FUNC_RETURN *  status 
)

Definition at line 2783 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

02785 {
02786   ACE_OS_TRACE ("ACE_OS::thr_join");
02787 #if defined (ACE_HAS_THREADS)
02788 # if defined (ACE_HAS_STHREADS)
02789   int result;
02790   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result),
02791                      int, -1);
02792 # elif defined (ACE_HAS_PTHREADS)
02793   int result;
02794   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result),
02795                      int, -1);
02796 # elif defined (ACE_HAS_WTHREADS)
02797   ACE_THR_FUNC_RETURN local_status = 0;
02798 
02799   // Make sure that status is non-NULL.
02800   if (status == 0)
02801     status = &local_status;
02802 
02803   if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0
02804       && ::GetExitCodeThread (thr_handle, status) != FALSE)
02805     {
02806       ::CloseHandle (thr_handle);
02807       return 0;
02808     }
02809   ACE_FAIL_RETURN (-1);
02810   /* NOTREACHED */
02811 # else
02812   ACE_UNUSED_ARG (thr_handle);
02813   ACE_UNUSED_ARG (status);
02814   ACE_NOTSUP_RETURN (-1);
02815 # endif /* ACE_HAS_STHREADS */
02816 #else
02817   ACE_UNUSED_ARG (thr_handle);
02818   ACE_UNUSED_ARG (status);
02819   ACE_NOTSUP_RETURN (-1);
02820 #endif /* ACE_HAS_THREADS */
02821 }

ACE_INLINE int ACE_OS::thr_join ( ACE_thread_t  waiter_id,
ACE_thread_t thr_id,
ACE_THR_FUNC_RETURN *  status 
)

Definition at line 2824 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

02827 {
02828   ACE_OS_TRACE ("ACE_OS::thr_join");
02829 #if defined (ACE_HAS_THREADS)
02830 # if defined (ACE_HAS_STHREADS)
02831   int result;
02832   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result),
02833                      int, -1);
02834 # elif defined (ACE_HAS_PTHREADS)
02835   ACE_UNUSED_ARG (thr_id);
02836   int result;
02837   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result),
02838                      int, -1);
02839 # elif defined (ACE_HAS_WTHREADS)
02840   ACE_UNUSED_ARG (waiter_id);
02841   ACE_UNUSED_ARG (thr_id);
02842   ACE_UNUSED_ARG (status);
02843 
02844   // This could be implemented if the DLL-Main function or the
02845   // task exit base class some log the threads which have exited
02846   ACE_NOTSUP_RETURN (-1);
02847 # endif /* ACE_HAS_STHREADS */
02848 #else
02849   ACE_UNUSED_ARG (waiter_id);
02850   ACE_UNUSED_ARG (thr_id);
02851   ACE_UNUSED_ARG (status);
02852   ACE_NOTSUP_RETURN (-1);
02853 #endif /* ACE_HAS_THREADS */
02854 }

ACE_INLINE int ACE_OS::thr_kill ( ACE_thread_t  thr_id,
int  signum 
)

Definition at line 2858 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, kill(), and thr_kill().

Referenced by ACE_Thread::kill(), and thr_kill().

02859 {
02860   ACE_OS_TRACE ("ACE_OS::thr_kill");
02861 #if defined (ACE_HAS_THREADS)
02862 # if defined (ACE_HAS_PTHREADS)
02863 #   if defined (ACE_LACKS_PTHREAD_KILL)
02864   ACE_UNUSED_ARG (signum);
02865   ACE_UNUSED_ARG (thr_id);
02866   ACE_NOTSUP_RETURN (-1);
02867 #   else
02868   int result;
02869   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_kill (thr_id, signum),
02870                                        result),
02871                      int, -1);
02872 #   endif /* ACE_LACKS_PTHREAD_KILL */
02873 # elif defined (ACE_HAS_STHREADS)
02874   int result;
02875   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum),
02876                                        result),
02877                      int, -1);
02878 # elif defined (ACE_HAS_VXTHREADS)
02879   //FUZZ: disable check_for_lack_ACE_OS
02880   ACE_OSCALL_RETURN (::kill (thr_id, signum), int, -1);
02881   //FUZZ: enable check_for_lack_ACE_OS
02882 # else
02883   ACE_UNUSED_ARG (thr_id);
02884   ACE_UNUSED_ARG (signum);
02885   ACE_NOTSUP_RETURN (-1);
02886 # endif /* ACE_HAS_STHREADS */
02887 #else
02888   ACE_UNUSED_ARG (thr_id);
02889   ACE_UNUSED_ARG (signum);
02890   ACE_NOTSUP_RETURN (-1);
02891 #endif /* ACE_HAS_THREADS */
02892 }

ACE_INLINE size_t ACE_OS::thr_min_stack ( void   ) 

Definition at line 2895 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, sysconf(), thr_min_stack(), and thr_self().

Referenced by thr_min_stack().

02896 {
02897   ACE_OS_TRACE ("ACE_OS::thr_min_stack");
02898 #if defined (ACE_HAS_THREADS)
02899 # if defined (ACE_HAS_STHREADS)
02900 #   if defined (ACE_HAS_THR_MINSTACK)
02901   // Tandem did some weirdo mangling of STHREAD names...
02902   return ::thr_minstack ();
02903 #   else
02904   return ::thr_min_stack ();
02905 #   endif /* !ACE_HAS_THR_MINSTACK */
02906 # elif defined (ACE_HAS_PTHREADS)
02907 #   if defined (_SC_THREAD_STACK_MIN)
02908   return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
02909 #   elif defined (PTHREAD_STACK_MIN)
02910   return PTHREAD_STACK_MIN;
02911 #   else
02912   ACE_NOTSUP_RETURN (0);
02913 #   endif /* _SC_THREAD_STACK_MIN */
02914 # elif defined (ACE_HAS_WTHREADS)
02915   ACE_NOTSUP_RETURN (0);
02916 # elif defined (ACE_HAS_VXTHREADS)
02917   TASK_DESC taskDesc;
02918   STATUS status;
02919 
02920   ACE_thread_t tid = ACE_OS::thr_self ();
02921 
02922   ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc),
02923                                 status),
02924               STATUS, -1, status);
02925   return status == OK ? taskDesc.td_stackSize : 0;
02926 # else /* Should not happen... */
02927   ACE_NOTSUP_RETURN (0);
02928 # endif /* ACE_HAS_STHREADS */
02929 #else
02930   ACE_NOTSUP_RETURN (0);
02931 #endif /* ACE_HAS_THREADS */
02932 }

ACE_INLINE ACE_thread_t ACE_OS::thr_self ( void   ) 

Definition at line 2935 of file OS_NS_Thread.inl.

References thr_self().

02936 {
02937   // ACE_OS_TRACE ("ACE_OS::thr_self");
02938 #if defined (ACE_HAS_THREADS)
02939 # if defined (ACE_HAS_PTHREADS)
02940   // Note, don't use "::" here since the following call is often a macro.
02941   return pthread_self ();
02942 # elif defined (ACE_HAS_STHREADS)
02943   ACE_OSCALL_RETURN (::thr_self (), int, -1);
02944 # elif defined (ACE_HAS_WTHREADS)
02945   return ::GetCurrentThreadId ();
02946 # elif defined (ACE_HAS_VXTHREADS)
02947   return ::taskIdSelf ();
02948 # endif /* ACE_HAS_STHREADS */
02949 #else
02950   return 1; // Might as well make it the first thread ;-)
02951 #endif /* ACE_HAS_THREADS */
02952 }

ACE_INLINE const char* ACE_OS::thr_name ( void   ) 

Definition at line 2955 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and thr_self().

02956 {
02957 #if defined (ACE_HAS_THREADS)
02958 #if defined (ACE_HAS_VXTHREADS)
02959   return ::taskName (ACE_OS::thr_self ());
02960 #else
02961   ACE_NOTSUP_RETURN (0);
02962 #endif
02963 #else
02964   ACE_NOTSUP_RETURN (0);
02965 #endif
02966 }

ACE_INLINE void ACE_OS::thr_self ( ACE_hthread_t self  ) 

Definition at line 2969 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, and thr_self().

02970 {
02971   ACE_OS_TRACE ("ACE_OS::thr_self");
02972 #if defined (ACE_HAS_THREADS)
02973 # if defined (ACE_HAS_PTHREADS)
02974   // Note, don't use "::" here since the following call is often a macro.
02975   self = pthread_self ();
02976 # elif defined (ACE_HAS_THREAD_SELF)
02977   self = ::thread_self ();
02978 # elif defined (ACE_HAS_STHREADS)
02979   self = ::thr_self ();
02980 # elif defined (ACE_HAS_WTHREADS)
02981   self = ::GetCurrentThread ();
02982 # elif defined (ACE_HAS_VXTHREADS)
02983   self = ::taskIdSelf ();
02984 # endif /* ACE_HAS_STHREADS */
02985 #else
02986   self = 1; // Might as well make it the main thread ;-)
02987 #endif /* ACE_HAS_THREADS */
02988 }

ACE_INLINE int ACE_OS::thr_setcancelstate ( int  new_state,
int *  old_state 
)

Definition at line 2991 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::disablecancel(), ACE_Thread::enablecancel(), and ACE_Thread::setcancelstate().

02992 {
02993   ACE_OS_TRACE ("ACE_OS::thr_setcancelstate");
02994 #if defined (ACE_HAS_THREADS)
02995 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02996   int result;
02997   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcancelstate (new_state,
02998                                                                old_state),
02999                                        result),
03000                      int, -1);
03001 # elif defined (ACE_HAS_STHREADS)
03002   ACE_UNUSED_ARG (new_state);
03003   ACE_UNUSED_ARG (old_state);
03004   ACE_NOTSUP_RETURN (-1);
03005 # elif defined (ACE_HAS_WTHREADS)
03006   ACE_UNUSED_ARG (new_state);
03007   ACE_UNUSED_ARG (old_state);
03008   ACE_NOTSUP_RETURN (-1);
03009 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03010   ACE_UNUSED_ARG (new_state);
03011   ACE_UNUSED_ARG (old_state);
03012   ACE_NOTSUP_RETURN (-1);
03013 # endif /* ACE_HAS_PTHREADS */
03014 #else
03015   ACE_UNUSED_ARG (new_state);
03016   ACE_UNUSED_ARG (old_state);
03017   ACE_NOTSUP_RETURN (-1);
03018 #endif /* ACE_HAS_THREADS */
03019 }

ACE_INLINE int ACE_OS::thr_setcanceltype ( int  new_type,
int *  old_type 
)

Definition at line 3022 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::enablecancel(), and ACE_Thread::setcancelstate().

03023 {
03024   ACE_OS_TRACE ("ACE_OS::thr_setcanceltype");
03025 #if defined (ACE_HAS_THREADS)
03026 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03027   int result;
03028   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcanceltype (new_type,
03029                                                               old_type),
03030                                        result),
03031                      int, -1);
03032 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03033   ACE_UNUSED_ARG (new_type);
03034   ACE_UNUSED_ARG (old_type);
03035   ACE_NOTSUP_RETURN (-1);
03036 # endif /* ACE_HAS_PTHREADS */
03037 #else
03038   ACE_UNUSED_ARG (new_type);
03039   ACE_UNUSED_ARG (old_type);
03040   ACE_NOTSUP_RETURN (-1);
03041 #endif /* ACE_HAS_THREADS */
03042 }

ACE_INLINE int ACE_OS::thr_setconcurrency ( int  hint  ) 

Definition at line 3045 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_setconcurrency().

Referenced by ACE_Thread::setconcurrency(), thr_create(), and thr_setconcurrency().

03046 {
03047   ACE_OS_TRACE ("ACE_OS::thr_setconcurrency");
03048 #if defined (ACE_HAS_THREADS)
03049 # if defined (ACE_HAS_STHREADS)
03050   int result;
03051   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint),
03052                                        result),
03053                      int, -1);
03054 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_SETCONCURRENCY)
03055   int result;
03056   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setconcurrency (hint),
03057                                        result),
03058                      int, -1);
03059 # else
03060   ACE_UNUSED_ARG (hint);
03061   ACE_NOTSUP_RETURN (-1);
03062 # endif /* ACE_HAS_STHREADS */
03063 #else
03064   ACE_UNUSED_ARG (hint);
03065   ACE_NOTSUP_RETURN (-1);
03066 #endif /* ACE_HAS_THREADS */
03067 }

ACE_INLINE int ACE_OS::thr_setprio ( ACE_hthread_t  ht_id,
int  priority,
int  policy 
)

Definition at line 3070 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, memset(), and thr_setprio().

03071 {
03072   ACE_OS_TRACE ("ACE_OS::thr_setprio");
03073   ACE_UNUSED_ARG (policy);
03074 #if defined (ACE_HAS_THREADS)
03075 # if (defined (ACE_HAS_PTHREADS) && \
03076       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
03077 
03078   int result;
03079   struct sched_param param;
03080   ACE_OS::memset ((void *) &param, 0, sizeof param);
03081 
03082   // If <policy> is -1, we don't want to use it for
03083   // pthread_setschedparam().  Instead, obtain policy from
03084   // pthread_getschedparam().
03085   if (policy == -1)
03086     {
03087       ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
03088                                     result),
03089                   int, -1, result);
03090       if (result == -1)
03091         return result;
03092     }
03093 
03094   param.sched_priority = priority;
03095 
03096   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id,
03097                                                               policy,
03098                                                               &param),
03099                                        result),
03100                      int, -1);
03101 # elif defined (ACE_HAS_STHREADS)
03102   int result;
03103   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (ht_id, priority),
03104                                        result),
03105                      int, -1);
03106 # elif defined (ACE_HAS_WTHREADS)
03107   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (ht_id, priority),
03108                                           ace_result_),
03109                         int, -1);
03110 # elif defined (ACE_HAS_VXTHREADS)
03111   ACE_OSCALL_RETURN (::taskPrioritySet (ht_id, priority), int, -1);
03112 # else
03113   // For example, platforms that support Pthreads but LACK_SETSCHED.
03114   ACE_UNUSED_ARG (ht_id);
03115   ACE_UNUSED_ARG (priority);
03116   ACE_NOTSUP_RETURN (-1);
03117 # endif /* ACE_HAS_STHREADS */
03118 #else
03119   ACE_UNUSED_ARG (ht_id);
03120   ACE_UNUSED_ARG (priority);
03121   ACE_NOTSUP_RETURN (-1);
03122 #endif /* ACE_HAS_THREADS */
03123 }

ACE_INLINE int ACE_OS::thr_sigsetmask ( int  how,
const sigset_t *  nsm,
sigset_t *  osm 
)

Definition at line 3126 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, pthread_sigmask(), SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK, and thr_sigsetmask().

Referenced by ACE_Log_Msg_Sig_Guard::ACE_Log_Msg_Sig_Guard(), ACE_Sig_Guard::ACE_Sig_Guard(), ACE_Thread::sigsetmask(), thr_sigsetmask(), ACE_Log_Msg_Sig_Guard::~ACE_Log_Msg_Sig_Guard(), and ACE_Sig_Guard::~ACE_Sig_Guard().

03129 {
03130   ACE_OS_TRACE ("ACE_OS::thr_sigsetmask");
03131 #if defined (ACE_HAS_THREADS)
03132 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
03133   // DCE threads and Solaris 2.4 have no such function.
03134   ACE_UNUSED_ARG (osm);
03135   ACE_UNUSED_ARG (nsm);
03136   ACE_UNUSED_ARG (how);
03137 
03138   ACE_NOTSUP_RETURN (-1);
03139 # elif defined (ACE_HAS_SIGTHREADMASK)
03140   int result;
03141   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm),
03142                                        result), int, -1);
03143 # elif defined (ACE_HAS_STHREADS)
03144   int result;
03145   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm),
03146                                        result),
03147                      int, -1);
03148 # elif defined (ACE_HAS_PTHREADS)
03149 #   if !defined (ACE_LACKS_PTHREAD_SIGMASK)
03150   int result;
03151   //FUZZ: disable check_for_lack_ACE_OS
03152   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
03153                                        result), int, -1);
03154   //FUZZ: enable check_for_lack_ACE_OS
03155 #   endif /* !ACE_LACKS_PTHREAD_SIGMASK */
03156 
03157 #if 0
03158   /* Don't know if any platform actually needs this... */
03159   // as far as I can tell, this is now pthread_sigaction() -- jwr
03160   int result;
03161   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_sigaction (how, nsm, osm),
03162                                        result), int, -1);
03163 #endif /* 0 */
03164 
03165 # elif defined (ACE_HAS_WTHREADS)
03166   ACE_UNUSED_ARG (osm);
03167   ACE_UNUSED_ARG (nsm);
03168   ACE_UNUSED_ARG (how);
03169 
03170   ACE_NOTSUP_RETURN (-1);
03171 # elif defined (ACE_VXWORKS)
03172   int old_mask = 0;
03173   switch (how)
03174     {
03175     case SIG_BLOCK:
03176     case SIG_UNBLOCK:
03177       {
03178         // get the old mask
03179         old_mask = ::sigsetmask (*nsm);
03180         // create a new mask:  the following assumes that sigset_t is 4 bytes,
03181         // which it is on VxWorks 5.2, so bit operations are done simply . . .
03182         ::sigsetmask (how == SIG_BLOCK ? (old_mask |= *nsm) : (old_mask &= ~*nsm));
03183         if (osm)
03184           *osm = old_mask;
03185         break;
03186       }
03187     case SIG_SETMASK:
03188       old_mask = ::sigsetmask (*nsm);
03189       if (osm)
03190         *osm = old_mask;
03191       break;
03192     default:
03193       return -1;
03194     }
03195 
03196   return 0;
03197 # else /* Should not happen. */
03198   ACE_UNUSED_ARG (how);
03199   ACE_UNUSED_ARG (nsm);
03200   ACE_UNUSED_ARG (osm);
03201   ACE_NOTSUP_RETURN (-1);
03202 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
03203 #else
03204   ACE_UNUSED_ARG (how);
03205   ACE_UNUSED_ARG (nsm);
03206   ACE_UNUSED_ARG (osm);
03207   ACE_NOTSUP_RETURN (-1);
03208 #endif /* ACE_HAS_THREADS */
03209 }

ACE_INLINE int ACE_OS::thr_suspend ( ACE_hthread_t  target_thread  ) 

Definition at line 3212 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_suspend().

Referenced by ACE_Thread::suspend(), and thr_suspend().

03213 {
03214   ACE_OS_TRACE ("ACE_OS::thr_suspend");
03215 #if defined (ACE_HAS_THREADS)
03216 # if defined (ACE_HAS_STHREADS)
03217   int result;
03218   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), result), int, -1);
03219 # elif defined (ACE_HAS_PTHREADS)
03220 #  if defined (ACE_HAS_PTHREAD_SUSPEND)
03221   int result;
03222   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread),
03223                                        result),
03224                      int, -1);
03225 #  elif defined (ACE_HAS_PTHREAD_SUSPEND_NP)
03226   int result;
03227   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend_np (target_thread),
03228                                        result),
03229                      int, -1);
03230 #  else
03231   ACE_UNUSED_ARG (target_thread);
03232   ACE_NOTSUP_RETURN (-1);
03233 #  endif /* ACE_HAS_PTHREAD_SUSPEND */
03234 # elif defined (ACE_HAS_WTHREADS)
03235   if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED)
03236     return 0;
03237   else
03238     ACE_FAIL_RETURN (-1);
03239   /* NOTREACHED */
03240 # elif defined (ACE_HAS_VXTHREADS)
03241   ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1);
03242 # endif /* ACE_HAS_STHREADS */
03243 #else
03244   ACE_UNUSED_ARG (target_thread);
03245   ACE_NOTSUP_RETURN (-1);
03246 #endif /* ACE_HAS_THREADS */
03247 }

ACE_INLINE void ACE_OS::thr_testcancel ( void   ) 

Definition at line 3250 of file OS_NS_Thread.inl.

References ACE_OS_TRACE.

Referenced by ACE_Thread::testcancel().

03251 {
03252   ACE_OS_TRACE ("ACE_OS::thr_testcancel");
03253 #if defined (ACE_HAS_THREADS)
03254 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03255   pthread_testcancel ();
03256 # elif defined (ACE_HAS_STHREADS)
03257 # elif defined (ACE_HAS_WTHREADS)
03258 # elif defined (ACE_HAS_VXTHREADS)
03259 # else
03260   // no-op:  can't use ACE_NOTSUP_RETURN because there is no return value
03261 # endif /* ACE_HAS_PTHREADS */
03262 #else
03263 #endif /* ACE_HAS_THREADS */
03264 }

ACE_INLINE void ACE_OS::thr_yield ( void   ) 

Definition at line 3267 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, and thr_yield().

Referenced by event_destroy(), event_pulse(), thr_yield(), and ACE_Thread::yield().

03268 {
03269   ACE_OS_TRACE ("ACE_OS::thr_yield");
03270 #if defined (ACE_HAS_THREADS)
03271 # if defined (ACE_HAS_PTHREADS)
03272   ::sched_yield ();
03273 # elif defined (ACE_HAS_STHREADS)
03274   ::thr_yield ();
03275 # elif defined (ACE_HAS_WTHREADS)
03276   ::Sleep (0);
03277 # elif defined (ACE_HAS_VXTHREADS)
03278   // An argument of 0 to ::taskDelay doesn't appear to yield the
03279   // current thread.
03280   // Now, it does seem to work.  The context_switch_time test
03281   // works fine with task_delay set to 0.
03282   ::taskDelay (0);
03283 # endif /* ACE_HAS_STHREADS */
03284 #else
03285   ;
03286 #endif /* ACE_HAS_THREADS */
03287 }

ACE_INLINE int ACE_OS::thread_mutex_destroy ( ACE_thread_mutex_t m  ) 

Definition at line 3290 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_destroy().

Referenced by ACE_OS_Object_Manager::fini(), mutex_destroy(), recursive_mutex_destroy(), sema_destroy(), and sema_init().

03291 {
03292   ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy");
03293 #if defined (ACE_HAS_THREADS)
03294 # if defined (ACE_HAS_WTHREADS)
03295   ::DeleteCriticalSection (m);
03296   return 0;
03297 # else
03298   return ACE_OS::mutex_destroy (m);
03299 # endif /* ACE_HAS_WTHREADS */
03300 #else
03301   ACE_UNUSED_ARG (m);
03302   ACE_NOTSUP_RETURN (-1);
03303 
03304 #endif /* ACE_HAS_THREADS */
03305 }

ACE_INLINE int ACE_OS::thread_mutex_init ( ACE_thread_mutex_t m,
int  lock_type,
const char *  name,
ACE_mutexattr_t arg 
)

Definition at line 3308 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_SEH_EXCEPT, ACE_SEH_TRY, mutex_init(), and USYNC_THREAD.

Referenced by ACE_OS_Object_Manager::init(), mutex_init(), recursive_mutex_init(), and sema_init().

03312 {
03313   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03314 #if defined (ACE_HAS_THREADS)
03315 # if defined (ACE_HAS_WTHREADS)
03316   ACE_UNUSED_ARG (lock_type);
03317   ACE_UNUSED_ARG (name);
03318   ACE_UNUSED_ARG (arg);
03319 
03320   ACE_SEH_TRY
03321     {
03322       ::InitializeCriticalSection (m);
03323     }
03324   ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
03325     {
03326       errno = ENOMEM;
03327       return -1;
03328     }
03329   return 0;
03330 
03331 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03332   // Force the use of USYNC_THREAD!
03333   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03334 # elif defined (ACE_HAS_VXTHREADS)
03335   return mutex_init (m, lock_type, name, arg);
03336 
03337 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03338 
03339 #else
03340   ACE_UNUSED_ARG (m);
03341   ACE_UNUSED_ARG (lock_type);
03342   ACE_UNUSED_ARG (name);
03343   ACE_UNUSED_ARG (arg);
03344   ACE_NOTSUP_RETURN (-1);
03345 
03346 #endif /* ACE_HAS_THREADS */
03347 }

ACE_INLINE int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m  ) 

Definition at line 3392 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_lock().

03393 {
03394   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03395 #if defined (ACE_HAS_THREADS)
03396 # if defined (ACE_HAS_WTHREADS)
03397   ::EnterCriticalSection (m);
03398   return 0;
03399 # else
03400   return ACE_OS::mutex_lock (m);
03401 # endif /* ACE_HAS_WTHREADS */
03402 #else
03403   ACE_UNUSED_ARG (m);
03404   ACE_NOTSUP_RETURN (-1);
03405 #endif /* ACE_HAS_THREADS */
03406 }

ACE_INLINE int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 3409 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_lock().

03411 {
03412   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03413 
03414   // For all platforms, except MS Windows, this method is equivalent
03415   // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and
03416   // ACE_mutex_t are the same type.  However, those typedefs evaluate
03417   // to different types on MS Windows.  The "thread mutex"
03418   // implementation in ACE for MS Windows cannot readily support
03419   // timeouts due to a lack of timeout features for this type of MS
03420   // Windows synchronization mechanism.
03421 
03422 #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS)
03423   return ACE_OS::mutex_lock (m, timeout);
03424 #else
03425   ACE_UNUSED_ARG (m);
03426   ACE_UNUSED_ARG (timeout);
03427   ACE_NOTSUP_RETURN (-1);
03428 #endif /* ACE_HAS_THREADS */
03429 }

ACE_INLINE int ACE_OS::thread_mutex_lock ( ACE_thread_mutex_t m,
const ACE_Time_Value timeout 
)

Definition at line 3432 of file OS_NS_Thread.inl.

References thread_mutex_lock().

03434 {
03435   return timeout == 0
03436     ? ACE_OS::thread_mutex_lock (m)
03437     : ACE_OS::thread_mutex_lock (m, *timeout);
03438 }

ACE_INLINE int ACE_OS::thread_mutex_trylock ( ACE_thread_mutex_t m  ) 

Definition at line 3441 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, and mutex_trylock().

Referenced by mutex_trylock(), and recursive_mutex_trylock().

03442 {
03443   ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
03444 
03445 #if defined (ACE_HAS_THREADS)
03446 # if defined (ACE_HAS_WTHREADS)
03447 #   if defined (ACE_HAS_WIN32_TRYLOCK)
03448   BOOL result = ::TryEnterCriticalSection (m);
03449   if (result == TRUE)
03450     return 0;
03451   else
03452     {
03453       errno = EBUSY;
03454       return -1;
03455     }
03456 #   else
03457   ACE_UNUSED_ARG (m);
03458   ACE_NOTSUP_RETURN (-1);
03459 #   endif /* ACE_HAS_WIN32_TRYLOCK */
03460 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03461   return ACE_OS::mutex_trylock (m);
03462 #endif /* Threads variety case */
03463 
03464 #else
03465   ACE_UNUSED_ARG (m);
03466   ACE_NOTSUP_RETURN (-1);
03467 #endif /* ACE_HAS_THREADS */
03468 }

ACE_INLINE int ACE_OS::thread_mutex_unlock ( ACE_thread_mutex_t m  ) 

Definition at line 3471 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_unlock().

Referenced by ACE_Log_Msg::close(), ACE_Log_Msg::instance(), mutex_unlock(), open(), recursive_mutex_cond_relock(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sema_init(), sema_post(), sema_trywait(), and sema_wait().

03472 {
03473   ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock");
03474 #if defined (ACE_HAS_THREADS)
03475 # if defined (ACE_HAS_WTHREADS)
03476   ::LeaveCriticalSection (m);
03477   return 0;
03478 # else
03479   return ACE_OS::mutex_unlock (m);
03480 # endif /* ACE_HAS_WTHREADS */
03481 #else
03482   ACE_UNUSED_ARG (m);
03483   ACE_NOTSUP_RETURN (-1);
03484 #endif /* ACE_HAS_THREADS */
03485 }

ACE_Export struct tm * ACE_OS::localtime_r ( const time_t *  t,
struct tm *  res 
)

Definition at line 225 of file OS_NS_time.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_GUARD, ACE_OS_TRACE, and localtime().

Referenced by ACE_Date_Time::update().

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

ACE_Export time_t ACE_OS::mktime ( struct tm *  t  ) 

Definition at line 309 of file OS_NS_time.cpp.

References ACE_OS_GUARD, ACE_OS_TRACE, and ACE_Time_Value::sec().

00310 {
00311   ACE_OS_TRACE ("ACE_OS::mktime");
00312 #   if defined (ACE_HAS_WINCE)
00313   SYSTEMTIME t_sys;
00314   FILETIME t_file;
00315   t_sys.wSecond = t->tm_sec;
00316   t_sys.wMinute = t->tm_min;
00317   t_sys.wHour = t->tm_hour;
00318   t_sys.wDay = t->tm_mday;
00319   t_sys.wMonth = t->tm_mon + 1;  // SYSTEMTIME is 1-indexed, tm is 0-indexed
00320   t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900
00321   t_sys.wDayOfWeek = t->tm_wday;  // Ignored in below function call.
00322   if (SystemTimeToFileTime (&t_sys, &t_file) == 0)
00323     return -1;
00324   ACE_Time_Value tv (t_file);
00325   return tv.sec ();
00326 #   else
00327 #     if defined (ACE_HAS_THREADS)  &&  !defined (ACE_HAS_MT_SAFE_MKTIME)
00328   ACE_OS_GUARD
00329 #     endif /* ACE_HAS_THREADS  &&  ! ACE_HAS_MT_SAFE_MKTIME */
00330 
00331   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::mktime (t), time_t, (time_t) -1);
00332 #   endif /* ACE_HAS_WINCE */
00333 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::asctime ( const struct tm *  tm  ) 

Definition at line 14 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and asctime().

Referenced by asctime(), asctime_r(), and ctime().

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

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::asctime_r ( const struct tm *  tm,
char *  buf,
int  buflen 
)

Definition at line 26 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, asctime(), asctime_r(), and strsncpy().

Referenced by asctime_r().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::clock_gettime ( clockid_t  ,
struct timespec  
)

Definition at line 65 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and clock_gettime().

Referenced by clock_gettime(), gethrtime(), and gettimeofday().

00066 {
00067   ACE_OS_TRACE ("ACE_OS::clock_gettime");
00068 #if defined (ACE_HAS_CLOCK_GETTIME)
00069   ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1);
00070 #else
00071   ACE_UNUSED_ARG (clockid);
00072   ACE_UNUSED_ARG (ts);
00073   ACE_NOTSUP_RETURN (-1);
00074 #endif /* ACE_HAS_CLOCK_GETTIME */
00075 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::clock_settime ( clockid_t  ,
const struct timespec  
)

Definition at line 78 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and clock_settime().

Referenced by clock_settime().

00079 {
00080 #if defined (ACE_HAS_CLOCK_SETTIME)
00081 #  if defined (ACE_HAS_NONCONST_CLOCK_SETTIME)
00082   ACE_OSCALL_RETURN (::clock_settime (clockid, const_cast<struct timespec *>(ts)), int, -1);
00083 #  else
00084   ACE_OSCALL_RETURN (::clock_settime (clockid, ts), int, -1);
00085 #  endif /* ACE_HAS_NONCONST_CLOCK_SETTIME */
00086 #else
00087   ACE_UNUSED_ARG (clockid);
00088   ACE_UNUSED_ARG (ts);
00089   ACE_NOTSUP_RETURN (-1);
00090 #endif /* ACE_HAS_CLOCK_SETTIME */
00091 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR* ACE_OS::ctime ( const time_t *  t  ) 

Definition at line 97 of file OS_NS_time.inl.

References ACE_OS_TRACE, asctime(), ctime(), ctime_buf_size, ctime_r(), and localtime().

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

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

ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR* ACE_OS::ctime_r ( const time_t *  clock,
ACE_TCHAR buf,
int  buflen 
)

Definition at line 132 of file OS_NS_time.inl.

References ACE_OS_TRACE, ctime(), ctime_buf_size, ctime_r(), strcpy(), and strsncpy().

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

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

ACE_NAMESPACE_INLINE_FUNCTION double ACE_OS::difftime ( time_t  t1,
time_t  t0 
)

Definition at line 214 of file OS_NS_time.inl.

References ace_difftime().

Referenced by ace_difftime(), and ACE_Filecache_Object::update().

00215 {
00216   return ::ace_difftime (t1, t0);
00217 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_hrtime_t ACE_OS::gethrtime ( const   ACE_HRTimer_Op = ACE_HRTIMER_GETTIME  ) 

Referenced by ACE_High_Res_Timer::calibrate(), gethrtime(), ACE_High_Res_Timer::gettime(), and ACE_High_Res_Timer::gettimeofday().

ACE_NAMESPACE_INLINE_FUNCTION struct tm* ACE_OS::gmtime ( const time_t *  clock  ) 

Definition at line 357 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and gmtime().

Referenced by gmtime(), and gmtime_r().

00358 {
00359   ACE_OS_TRACE ("ACE_OS::gmtime");
00360 #if defined (ACE_LACKS_GMTIME)
00361   ACE_UNUSED_ARG (t);
00362   ACE_NOTSUP_RETURN (0);
00363 #else
00364   ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
00365 #endif /* ACE_LACKS_GMTIME */
00366 }

ACE_NAMESPACE_INLINE_FUNCTION struct tm* ACE_OS::gmtime_r ( const time_t *  clock,
struct tm *  res 
)

Definition at line 369 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gmtime(), and gmtime_r().

Referenced by gmtime_r().

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

ACE_NAMESPACE_INLINE_FUNCTION struct tm* ACE_OS::localtime ( const time_t *  clock  ) 

Definition at line 396 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and localtime().

Referenced by ctime(), localtime(), and localtime_r().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::nanosleep ( const struct timespec requested,
struct timespec remaining = 0 
)

Definition at line 408 of file OS_NS_time.inl.

References ACE_OS_TRACE, nanosleep(), sleep(), timespec::tv_nsec, and timespec::tv_sec.

Referenced by nanosleep(), and sleep().

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

ACE_NAMESPACE_INLINE_FUNCTION size_t ACE_OS::strftime ( char *  s,
size_t  maxsize,
const char *  format,
const struct tm *  timeptr 
)

Definition at line 429 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and strftime().

Referenced by strftime().

00431 {
00432 #if defined (ACE_LACKS_STRFTIME)
00433   ACE_UNUSED_ARG (s);
00434   ACE_UNUSED_ARG (maxsize);
00435   ACE_UNUSED_ARG (format);
00436   ACE_UNUSED_ARG (timeptr);
00437   ACE_NOTSUP_RETURN (0);
00438 #else
00439   return ACE_STD_NAMESPACE::strftime (s, maxsize, format, timeptr);
00440 #endif /* ACE_LACKS_STRFTIME */
00441 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::strptime ( const char *  buf,
const char *  format,
struct tm *  tm 
)

Definition at line 444 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and strptime().

Referenced by strptime().

00445 {
00446 #if defined (ACE_LACKS_STRPTIME)
00447 #  if defined (ACE_REFUSE_STRPTIME_EMULATION)
00448   ACE_UNUSED_ARG (buf);
00449   ACE_UNUSED_ARG (format);
00450   ACE_UNUSED_ARG (tm);
00451   ACE_NOTSUP_RETURN (0);
00452 #  else
00453   return ACE_OS::strptime_emulation (buf, format, tm);
00454 #  endif /* ACE_REFUSE_STRPTIME_EMULATION */
00455 #else
00456   return ::strptime (buf, format, tm);
00457 #endif /* ACE_LACKS_STRPTIME */
00458 }

ACE_NAMESPACE_INLINE_FUNCTION time_t ACE_OS::time ( time_t *  tloc = 0  ) 

Definition at line 461 of file OS_NS_time.inl.

References ACE_OS_TRACE, gettimeofday(), ACE_Time_Value::sec(), and time().

Referenced by ACE::Monitor_Control::Monitor_Base::add_to_registry(), ACE::Monitor_Control::Monitor_Admin::auto_query(), ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK_Connector::complete(), ACE_System_Time::get_local_system_time(), ACE_Utils::UUID_Generator::get_systemtime(), ACE::Monitor_Control::Monitor_Admin::monitor_point(), ACE_Service_Config::reconfigure(), time(), and ACE_Date_Time::update().

00462 {
00463   ACE_OS_TRACE ("ACE_OS::time");
00464 #if !defined (ACE_HAS_WINCE)
00465   ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1);
00466 #else
00467   time_t retv = ACE_OS::gettimeofday ().sec ();
00468   if (tloc)
00469     *tloc = retv;
00470   return retv;
00471 #endif /* ACE_HAS_WINCE */
00472 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::timezone ( void   ) 

Definition at line 485 of file OS_NS_time.inl.

References ace_timezone().

Referenced by ace_timezone().

00486 {
00487   return ::ace_timezone ();
00488 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::tzset ( void   ) 

Definition at line 492 of file OS_NS_time.inl.

References ENOTSUP, and tzset().

Referenced by ace_timezone(), and tzset().

00493 {
00494 #if !defined (ACE_HAS_WINCE) && !defined (ACE_VXWORKS) && !defined(ACE_HAS_RTEMS) && !defined (ACE_HAS_DINKUM_STL)
00495 #   if defined (ACE_WIN32)
00496   ::_tzset ();  // For Win32.
00497 #   else
00498   ::tzset ();   // For UNIX platforms.
00499 #   endif /* ACE_WIN32 */
00500 # else
00501   errno = ENOTSUP;
00502 # endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_HAS_RTEMS && !ACE_HAS_DINKUM_STL */
00503 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE char* ACE_OS::asctime ( const struct tm *  t  ) 

Definition at line 14 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and asctime().

Referenced by asctime(), asctime_r(), and ctime().

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

ACE_INLINE char* ACE_OS::asctime_r ( const struct tm *  t,
char *  buf,
int  buflen 
)

Definition at line 26 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, asctime(), asctime_r(), and strsncpy().

Referenced by asctime_r().

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

ACE_INLINE int ACE_OS::clock_gettime ( clockid_t  clockid,
struct timespec ts 
)

Definition at line 65 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and clock_gettime().

Referenced by clock_gettime(), gethrtime(), and gettimeofday().

00066 {
00067   ACE_OS_TRACE ("ACE_OS::clock_gettime");
00068 #if defined (ACE_HAS_CLOCK_GETTIME)
00069   ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1);
00070 #else
00071   ACE_UNUSED_ARG (clockid);
00072   ACE_UNUSED_ARG (ts);
00073   ACE_NOTSUP_RETURN (-1);
00074 #endif /* ACE_HAS_CLOCK_GETTIME */
00075 }

ACE_INLINE int ACE_OS::clock_settime ( clockid_t  clockid,
const struct timespec ts 
)

Definition at line 78 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and clock_settime().

Referenced by clock_settime().

00079 {
00080 #if defined (ACE_HAS_CLOCK_SETTIME)
00081 #  if defined (ACE_HAS_NONCONST_CLOCK_SETTIME)
00082   ACE_OSCALL_RETURN (::clock_settime (clockid, const_cast<struct timespec *>(ts)), int, -1);
00083 #  else
00084   ACE_OSCALL_RETURN (::clock_settime (clockid, ts), int, -1);
00085 #  endif /* ACE_HAS_NONCONST_CLOCK_SETTIME */
00086 #else
00087   ACE_UNUSED_ARG (clockid);
00088   ACE_UNUSED_ARG (ts);
00089   ACE_NOTSUP_RETURN (-1);
00090 #endif /* ACE_HAS_CLOCK_SETTIME */
00091 }

ACE_INLINE ACE_TCHAR* ACE_OS::ctime ( const time_t *  t  ) 

Definition at line 97 of file OS_NS_time.inl.

References ACE_OS_TRACE, asctime(), ctime(), ctime_buf_size, ctime_r(), and localtime().

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

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

ACE_INLINE ACE_TCHAR* ACE_OS::ctime_r ( const time_t *  t,
ACE_TCHAR buf,
int  buflen 
)

Definition at line 132 of file OS_NS_time.inl.

References ACE_OS_TRACE, ctime(), ctime_buf_size, ctime_r(), strcpy(), and strsncpy().

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

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

ACE_INLINE double ACE_OS::difftime ( time_t  t1,
time_t  t0 
)

Definition at line 214 of file OS_NS_time.inl.

References ace_difftime().

Referenced by ace_difftime(), and ACE_Filecache_Object::update().

00215 {
00216   return ::ace_difftime (t1, t0);
00217 }

ACE_INLINE ACE_hrtime_t ACE_OS::gethrtime ( const ACE_HRTimer_Op  op  ) 

Definition at line 225 of file OS_NS_time.inl.

References ACE_GETHRTIME_NAME, ACE_ONE_SECOND_IN_NSECS, ACE_OS_TRACE, ACE_U_ONE_SECOND_IN_NSECS, clock_gettime(), CLOCK_REALTIME, gethrtime(), gettimeofday(), memcpy(), ACE_Time_Value::sec(), timespec::tv_nsec, timespec::tv_sec, and ACE_Time_Value::usec().

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

ACE_INLINE struct tm* ACE_OS::gmtime ( const time_t *  t  ) 

Definition at line 357 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and gmtime().

Referenced by gmtime(), and gmtime_r().

00358 {
00359   ACE_OS_TRACE ("ACE_OS::gmtime");
00360 #if defined (ACE_LACKS_GMTIME)
00361   ACE_UNUSED_ARG (t);
00362   ACE_NOTSUP_RETURN (0);
00363 #else
00364   ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
00365 #endif /* ACE_LACKS_GMTIME */
00366 }

ACE_INLINE struct tm* ACE_OS::gmtime_r ( const time_t *  t,
struct tm *  res 
)

Definition at line 369 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gmtime(), and gmtime_r().

Referenced by gmtime_r().

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

ACE_INLINE struct tm* ACE_OS::localtime ( const time_t *  t  ) 

Definition at line 396 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and localtime().

Referenced by ctime(), localtime(), and localtime_r().

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

ACE_INLINE int ACE_OS::nanosleep ( const struct timespec requested,
struct timespec remaining 
)

Definition at line 408 of file OS_NS_time.inl.

References ACE_OS_TRACE, nanosleep(), sleep(), timespec::tv_nsec, and timespec::tv_sec.

Referenced by nanosleep(), and sleep().

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

ACE_INLINE size_t ACE_OS::strftime ( char *  s,
size_t  maxsize,
const char *  format,
const struct tm *  timeptr 
)

Definition at line 429 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and strftime().

Referenced by strftime().

00431 {
00432 #if defined (ACE_LACKS_STRFTIME)
00433   ACE_UNUSED_ARG (s);
00434   ACE_UNUSED_ARG (maxsize);
00435   ACE_UNUSED_ARG (format);
00436   ACE_UNUSED_ARG (timeptr);
00437   ACE_NOTSUP_RETURN (0);
00438 #else
00439   return ACE_STD_NAMESPACE::strftime (s, maxsize, format, timeptr);
00440 #endif /* ACE_LACKS_STRFTIME */
00441 }

ACE_INLINE char* ACE_OS::strptime ( const char *  buf,
const char *  format,
struct tm *  tm 
)

Definition at line 444 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and strptime().

Referenced by strptime().

00445 {
00446 #if defined (ACE_LACKS_STRPTIME)
00447 #  if defined (ACE_REFUSE_STRPTIME_EMULATION)
00448   ACE_UNUSED_ARG (buf);
00449   ACE_UNUSED_ARG (format);
00450   ACE_UNUSED_ARG (tm);
00451   ACE_NOTSUP_RETURN (0);
00452 #  else
00453   return ACE_OS::strptime_emulation (buf, format, tm);
00454 #  endif /* ACE_REFUSE_STRPTIME_EMULATION */
00455 #else
00456   return ::strptime (buf, format, tm);
00457 #endif /* ACE_LACKS_STRPTIME */
00458 }

ACE_INLINE time_t ACE_OS::time ( time_t *  tloc  ) 

Definition at line 461 of file OS_NS_time.inl.

References ACE_OS_TRACE, gettimeofday(), ACE_Time_Value::sec(), and time().

Referenced by ACE::Monitor_Control::Monitor_Base::add_to_registry(), ACE::Monitor_Control::Monitor_Admin::auto_query(), ACE_SOCK_Connector::complete(), ACE_SOCK_SEQPACK_Connector::complete(), ACE_System_Time::get_local_system_time(), ACE_Utils::UUID_Generator::get_systemtime(), ACE::Monitor_Control::Monitor_Admin::monitor_point(), ACE_Service_Config::reconfigure(), time(), and ACE_Date_Time::update().

00462 {
00463   ACE_OS_TRACE ("ACE_OS::time");
00464 #if !defined (ACE_HAS_WINCE)
00465   ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1);
00466 #else
00467   time_t retv = ACE_OS::gettimeofday ().sec ();
00468   if (tloc)
00469     *tloc = retv;
00470   return retv;
00471 #endif /* ACE_HAS_WINCE */
00472 }

ACE_INLINE long ACE_OS::timezone ( void   ) 

Definition at line 485 of file OS_NS_time.inl.

References ace_timezone().

Referenced by ace_timezone().

00486 {
00487   return ::ace_timezone ();
00488 }

ACE_INLINE void ACE_OS::tzset ( void   ) 

Definition at line 492 of file OS_NS_time.inl.

References ENOTSUP, and tzset().

Referenced by ace_timezone(), and tzset().

00493 {
00494 #if !defined (ACE_HAS_WINCE) && !defined (ACE_VXWORKS) && !defined(ACE_HAS_RTEMS) && !defined (ACE_HAS_DINKUM_STL)
00495 #   if defined (ACE_WIN32)
00496   ::_tzset ();  // For Win32.
00497 #   else
00498   ::tzset ();   // For UNIX platforms.
00499 #   endif /* ACE_WIN32 */
00500 # else
00501   errno = ENOTSUP;
00502 # endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_HAS_RTEMS && !ACE_HAS_DINKUM_STL */
00503 }

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

Definition at line 41 of file OS_NS_unistd.cpp.

Referenced by ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), and fork_exec().

00045 {
00046   if (argv == 0 || argv[0] == 0)
00047     return 0;
00048 
00049   int argc;
00050   for (argc = 0; argv[argc] != 0; ++argc)
00051     continue;
00052 
00053   return argv_to_string (argc,
00054                          argv,
00055                          buf,
00056                          substitute_env_args,
00057                          quote_args);
00058 }

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

Definition at line 61 of file OS_NS_unistd.cpp.

References ACE_NEW_RETURN, ACE_TEXT, free(), malloc(), memcpy(), strchr(), strecpy(), strenvdup(), and strlen().

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

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

Definition at line 198 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00199 {
00200   ACE_OS_TRACE ("ACE_OS::execl");
00201   ACE_NOTSUP_RETURN (-1);
00202   // Need to write this code.
00203   // ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00204 }

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

Definition at line 207 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00208 {
00209   ACE_OS_TRACE ("ACE_OS::execle");
00210   ACE_NOTSUP_RETURN (-1);
00211   // Need to write this code.
00212   //  ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
00213 }

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

Definition at line 216 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00217 {
00218   ACE_OS_TRACE ("ACE_OS::execlp");
00219   ACE_NOTSUP_RETURN (-1);
00220   // Need to write this code.
00221   //  ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00222 }

ACE_Export 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 225 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_Base_Thread_Adapter::sync_log_msg().

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

00226 {
00227   ACE_OS_TRACE ("ACE_OS::fork");
00228 # if defined (ACE_LACKS_FORK)
00229   ACE_UNUSED_ARG (program_name);
00230   ACE_NOTSUP_RETURN (pid_t (-1));
00231 # else
00232   pid_t const pid =
00233 # if defined (ACE_HAS_STHREADS)
00234     ::fork1 ();
00235 #else
00236     ::fork ();
00237 #endif /* ACE_HAS_STHREADS */
00238 
00239 #if !defined (ACE_HAS_MINIMAL_ACE_OS) && !defined (ACE_HAS_THREADS)
00240 
00241   // ACE_Base_Thread_Adapter::sync_log_msg() is used to update the
00242   // program name and process id in ACE's log framework.  However, we
00243   // can't invoke it from (the child process of) threaded programs
00244   // because it calls async signal unsafe functions, which will result
00245   // in undefined behavior (only async signal safe functions can be
00246   // called after fork() until an exec()).
00247   //
00248   // This is no great loss.  Using the ACE log framework in the child
00249   // process will undoubtedly call async signal unsafe functions too.
00250   // So it doesn't really matter that the program name and process id
00251   // will not be updated.
00252 
00253   if (pid == 0)
00254     ACE_Base_Thread_Adapter::sync_log_msg (program_name);
00255 
00256 #else
00257 
00258   ACE_UNUSED_ARG (program_name);
00259 
00260 #endif /* ! ACE_HAS_MINIMAL_ACE_OS && !ACE_HAS_THREADS */
00261 
00262   return pid;
00263 # endif /* ACE_WIN32 */
00264 }

ACE_Export 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 270 of file OS_NS_unistd.cpp.

References ACE_NEW_NORETURN, argv_to_string(), close(), execv(), exit(), fork(), and memset().

00271 {
00272 # if defined (ACE_WIN32)
00273 
00274   ACE_TCHAR *buf = 0;
00275   ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_ptr (buf);
00276   if (ACE_OS::argv_to_string (argv, buf) != -1)
00277     {
00278       PROCESS_INFORMATION process_info;
00279 #   if !defined (ACE_HAS_WINCE)
00280       ACE_TEXT_STARTUPINFO startup_info;
00281       ACE_OS::memset ((void *) &startup_info,
00282                       0,
00283                       sizeof startup_info);
00284       startup_info.cb = sizeof startup_info;
00285 
00286       if (ACE_TEXT_CreateProcess (0,
00287                                   buf,
00288                                   0, // No process attributes.
00289                                   0,  // No thread attributes.
00290                                   TRUE, // Allow handle inheritance.
00291                                   0, // Don't create a new console window.
00292                                   0, // No environment.
00293                                   0, // No current directory.
00294                                   &startup_info,
00295                                   &process_info))
00296 #   else
00297       if (ACE_TEXT_CreateProcess (0,
00298                                   buf,
00299                                   0, // No process attributes.
00300                                   0,  // No thread attributes.
00301                                   FALSE, // Can's inherit handles on CE
00302                                   0, // Don't create a new console window.
00303                                   0, // No environment.
00304                                   0, // No current directory.
00305                                   0, // Can't use startup info on CE
00306                                   &process_info))
00307 #   endif /* ! ACE_HAS_WINCE */
00308         {
00309           // Free resources allocated in kernel.
00310           ACE_OS::close (process_info.hThread);
00311           ACE_OS::close (process_info.hProcess);
00312           // Return new process id.
00313           return process_info.dwProcessId;
00314         }
00315     }
00316 
00317   // CreateProcess failed.
00318   return -1;
00319 # else
00320       pid_t const result = ACE_OS::fork ();
00321 
00322 #   if defined (ACE_USES_WCHAR)
00323       // Wide-char builds need to convert the command-line args to
00324       // narrow char strings for execv ().
00325       char **cargv = 0;
00326       int arg_count;
00327 #   endif /* ACE_HAS_WCHAR */
00328 
00329       switch (result)
00330         {
00331         case -1:
00332           // Error.
00333           return -1;
00334         case 0:
00335           // Child process.
00336 #   if defined (ACE_USES_WCHAR)
00337           for (arg_count = 0; argv[arg_count] != 0; ++arg_count)
00338             ;
00339           ++arg_count;    // Need a 0-pointer end-of-array marker
00340           ACE_NEW_NORETURN (cargv, char*[arg_count]);
00341           if (cargv == 0)
00342             ACE_OS::exit (errno);
00343           --arg_count;    // Back to 0-indexed
00344           cargv[arg_count] = 0;
00345           while (--arg_count >= 0)
00346             cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
00347           // Don't worry about freeing the cargv or the strings it points to.
00348           // Either the process will be replaced, or we'll exit.
00349           if (ACE_OS::execv (cargv[0], cargv) == -1)
00350             ACE_OS::exit (errno);
00351 #   else
00352           if (ACE_OS::execv (argv[0], argv) == -1)
00353             {
00354               // The OS layer should not print stuff out
00355               // ACE_ERROR ((LM_ERROR,
00356               //             "%p Exec failed\n"));
00357 
00358               // If the execv fails, this child needs to exit.
00359               ACE_OS::exit (errno);
00360             }
00361 #   endif /* ACE_HAS_WCHAR */
00362 
00363         default:
00364           // Server process.  The fork succeeded.
00365           return result;
00366         }
00367 # endif /* ACE_WIN32 */
00368 }

ACE_Export long ACE_OS::num_processors ( void   ) 

Get the number of CPUs configured in the machine.

Definition at line 371 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysconf().

Referenced by num_processors_online().

00372 {
00373   ACE_OS_TRACE ("ACE_OS::num_processors");
00374 
00375 #if defined (ACE_HAS_PHARLAP)
00376   return 1;
00377 #elif defined (ACE_WIN32)
00378   SYSTEM_INFO sys_info;
00379   ::GetSystemInfo (&sys_info);
00380   return sys_info.dwNumberOfProcessors;
00381 #elif defined (_SC_NPROCESSORS_CONF)
00382   return ::sysconf (_SC_NPROCESSORS_CONF);
00383 #elif defined (ACE_HAS_SYSCTL)
00384   int num_processors;
00385   int mib[2] = { CTL_HW, HW_NCPU };
00386   size_t len = sizeof (num_processors);
00387   if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
00388     return num_processors;
00389   else
00390     return -1;
00391 #elif defined (__hpux)
00392   struct pst_dynamic psd;
00393   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00394     return psd.psd_max_proc_cnt;
00395   else
00396     return -1;
00397 #else
00398   ACE_NOTSUP_RETURN (-1);
00399 #endif
00400 }

ACE_Export long ACE_OS::num_processors_online ( void   ) 

Get the number of CPUs currently online.

Definition at line 403 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, num_processors(), and sysconf().

00404 {
00405   ACE_OS_TRACE ("ACE_OS::num_processors_online");
00406 
00407 #if defined (ACE_HAS_PHARLAP)
00408   return 1;
00409 #elif defined (ACE_WIN32)
00410   SYSTEM_INFO sys_info;
00411   ::GetSystemInfo (&sys_info);
00412   long active_processors = 0;
00413   DWORD_PTR mask = sys_info.dwActiveProcessorMask;
00414   while (mask != 0)
00415     {
00416       if (mask & 1)
00417         ++active_processors;
00418       mask >>= 1;
00419     }
00420   return active_processors;
00421 #elif defined (_SC_NPROCESSORS_ONLN)
00422   return ::sysconf (_SC_NPROCESSORS_ONLN);
00423 #elif defined (ACE_HAS_SYSCTL)
00424   int num_processors;
00425   int mib[2] = { CTL_HW, HW_NCPU };
00426   size_t len = sizeof (num_processors);
00427   if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
00428     return num_processors;
00429   else
00430     return -1;
00431 #elif defined (__hpux)
00432   struct pst_dynamic psd;
00433   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00434     return psd.psd_proc_cnt;
00435   else
00436     return -1;
00437 #else
00438   ACE_NOTSUP_RETURN (-1);
00439 #endif
00440 }

ACE_Export 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 443 of file OS_NS_unistd.cpp.

References read().

Referenced by ACE::read_n(), ACE_DEV_IO::recv_n(), ACE_FILE_IO::recv_n(), ACE_Pipe::recv_n(), and ACE_SPIPE_Stream::recv_n().

00447 {
00448   size_t temp;
00449   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00450   ssize_t n = 0;
00451 
00452   for (bytes_transferred = 0;
00453        bytes_transferred < len;
00454        bytes_transferred += n)
00455     {
00456       n = ACE_OS::read (handle,
00457                         (char *) buf + bytes_transferred,
00458                         len - bytes_transferred);
00459 
00460       if (n == -1 || n == 0)
00461         return n;
00462     }
00463 
00464   return bytes_transferred;
00465 }

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

Definition at line 468 of file OS_NS_unistd.cpp.

References ACE_OS_GUARD, lseek(), and read().

00472 {
00473 # if defined (ACE_HAS_P_READ_WRITE)
00474 #   if defined (ACE_WIN32)
00475 
00476   ACE_OS_GUARD
00477 
00478   // Remember the original file pointer position
00479   LONG original_high_position = 0;
00480   DWORD original_low_position = ::SetFilePointer (handle,
00481                                                   0,
00482                                                   &original_high_position,
00483                                                   FILE_CURRENT);
00484 
00485   if (original_low_position == INVALID_SET_FILE_POINTER
00486       && GetLastError () != NO_ERROR)
00487     return -1;
00488 
00489   // Go to the correct position
00490   LONG low_offset = ACE_LOW_PART (offset);
00491   LONG high_offset = ACE_HIGH_PART (offset);
00492   DWORD altered_position = ::SetFilePointer (handle,
00493                                              low_offset,
00494                                              &high_offset,
00495                                              FILE_BEGIN);
00496   if (altered_position == INVALID_SET_FILE_POINTER
00497       && GetLastError () != NO_ERROR)
00498     return -1;
00499 
00500   DWORD bytes_read;
00501 
00502 #     if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00503 
00504   OVERLAPPED overlapped;
00505   overlapped.Internal = 0;
00506   overlapped.InternalHigh = 0;
00507   overlapped.Offset = low_offset;
00508   overlapped.OffsetHigh = high_offset;
00509   overlapped.hEvent = 0;
00510 
00511   BOOL result = ::ReadFile (handle,
00512                             buf,
00513                             static_cast <DWORD> (nbytes),
00514                             &bytes_read,
00515                             &overlapped);
00516 
00517   if (result == FALSE)
00518     {
00519       if (::GetLastError () != ERROR_IO_PENDING)
00520         return -1;
00521 
00522       else
00523         {
00524           result = ::GetOverlappedResult (handle,
00525                                           &overlapped,
00526                                           &bytes_read,
00527                                           TRUE);
00528           if (result == FALSE)
00529             return -1;
00530         }
00531     }
00532 
00533 #     else /* ACE_HAS_WIN32_OVERLAPPED_IO */
00534 
00535   BOOL result = ::ReadFile (handle,
00536                             buf,
00537                             nbytes,
00538                             &bytes_read,
00539                             0);
00540   if (result == FALSE)
00541     return -1;
00542 
00543 #     endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00544 
00545   // Reset the original file pointer position
00546   if (::SetFilePointer (handle,
00547                         original_low_position,
00548                         &original_high_position,
00549                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00550       && GetLastError () != NO_ERROR)
00551     return -1;
00552 
00553   return (ssize_t) bytes_read;
00554 
00555 #   else /* ACE_WIN32 */
00556 
00557   return ::pread (handle, buf, nbytes, offset);
00558 
00559 #   endif /* ACE_WIN32 */
00560 
00561 # else /* ACE_HAS_P_READ_WRITE */
00562 
00563   ACE_OS_GUARD
00564 
00565   // Remember the original file pointer position
00566   ACE_OFF_T original_position = ACE_OS::lseek (handle,
00567                                                0,
00568                                                SEEK_CUR);
00569 
00570   if (original_position == -1)
00571     return -1;
00572 
00573   // Go to the correct position
00574   ACE_OFF_T altered_position = ACE_OS::lseek (handle, offset, SEEK_SET);
00575 
00576   if (altered_position == -1)
00577     return -1;
00578 
00579   ssize_t const bytes_read = ACE_OS::read (handle, buf, nbytes);
00580 
00581   if (bytes_read == -1)
00582     return -1;
00583 
00584   if (ACE_OS::lseek (handle,
00585                      original_position,
00586                      SEEK_SET) == -1)
00587     return -1;
00588 
00589   return bytes_read;
00590 
00591 # endif /* ACE_HAD_P_READ_WRITE */
00592 }

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

Definition at line 595 of file OS_NS_unistd.cpp.

References ACE_OS_GUARD, lseek(), set_errno_to_last_error(), and write().

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

00599 {
00600 # if defined (ACE_HAS_P_READ_WRITE)
00601 #   if defined (ACE_WIN32)
00602 
00603   ACE_OS_GUARD
00604 
00605   // Remember the original file pointer position
00606   LARGE_INTEGER orig_position;
00607   orig_position.QuadPart = 0;
00608   orig_position.LowPart = ::SetFilePointer (handle,
00609                                             0,
00610                                             &orig_position.HighPart,
00611                                             FILE_CURRENT);
00612   if (orig_position.LowPart == INVALID_SET_FILE_POINTER
00613       && GetLastError () != NO_ERROR)
00614     return -1;
00615 
00616   DWORD bytes_written;
00617   LARGE_INTEGER loffset;
00618   loffset.QuadPart = offset;
00619 
00620 #     if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00621 
00622   OVERLAPPED overlapped;
00623   overlapped.Internal = 0;
00624   overlapped.InternalHigh = 0;
00625   overlapped.Offset = loffset.LowPart;
00626   overlapped.OffsetHigh = loffset.HighPart;
00627   overlapped.hEvent = 0;
00628 
00629   BOOL result = ::WriteFile (handle,
00630                              buf,
00631                              static_cast <DWORD> (nbytes),
00632                              &bytes_written,
00633                              &overlapped);
00634 
00635   if (result == FALSE)
00636     {
00637       if (::GetLastError () != ERROR_IO_PENDING)
00638         return -1;
00639 
00640       result = ::GetOverlappedResult (handle,
00641                                       &overlapped,
00642                                       &bytes_written,
00643                                       TRUE);
00644       if (result == FALSE)
00645         return -1;
00646     }
00647 
00648 #     else /* ACE_HAS_WIN32_OVERLAPPED_IO */
00649 
00650   // Go to the correct position; if this is a Windows variant without
00651   // overlapped I/O, it probably doesn't have SetFilePointerEx either,
00652   // so manage this with SetFilePointer, changing calls based on the use
00653   // of 64 bit offsets.
00654   DWORD newpos;
00655 #       if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
00656   newpos = ::SetFilePointer (handle,
00657                              loffset.LowPart,
00658                              &loffset.HighPart,
00659                              FILE_BEGIN);
00660 #       else
00661   newpos = ::SetFilePointer (handle,
00662                              loffset.LowPart,
00663                              0,
00664                              FILE_BEGIN);
00665 #       endif /* 64-bit file offsets */
00666   if (newpos == 0xFFFFFFFF && ::GetLastError () != NO_ERROR)
00667     {
00668       ACE_OS::set_errno_to_last_error ();
00669       return -1;
00670     }
00671 
00672   BOOL result = ::WriteFile (handle,
00673                              buf,
00674                              nbytes,
00675                              &bytes_written,
00676                              0);
00677   if (result == FALSE)
00678     return -1;
00679 
00680 #     endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00681 
00682   // Reset the original file pointer position
00683   if (::SetFilePointer (handle,
00684                         orig_position.LowPart,
00685                         &orig_position.HighPart,
00686                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00687       && GetLastError () != NO_ERROR)
00688     return -1;
00689 
00690   return (ssize_t) bytes_written;
00691 
00692 #   else /* ACE_WIN32 */
00693 
00694   return ::pwrite (handle, buf, nbytes, offset);
00695 #   endif /* ACE_WIN32 */
00696 # else /* ACE_HAS_P_READ_WRITE */
00697 
00698   ACE_OS_GUARD
00699 
00700   // Remember the original file pointer position
00701   ACE_OFF_T original_position = ACE_OS::lseek (handle,
00702                                                0,
00703                                                SEEK_CUR);
00704   if (original_position == -1)
00705     return -1;
00706 
00707   // Go to the correct position
00708   ACE_OFF_T altered_position = ACE_OS::lseek (handle,
00709                                               offset,
00710                                               SEEK_SET);
00711   if (altered_position == -1)
00712     return -1;
00713 
00714   ssize_t const bytes_written = ACE_OS::write (handle,
00715                                                buf,
00716                                                nbytes);
00717   if (bytes_written == -1)
00718     return -1;
00719 
00720   if (ACE_OS::lseek (handle,
00721                      original_position,
00722                      SEEK_SET) == -1)
00723     return -1;
00724 
00725   return bytes_written;
00726 # endif /* ACE_HAS_P_READ_WRITE */
00727 }

ACE_Export int ACE_OS::string_to_argv ( ACE_TCHAR buf,
int &  argc,
ACE_TCHAR **&  argv,
bool  substitute_env_args = true 
)

Definition at line 730 of file OS_NS_unistd.cpp.

References ACE_DEFAULT_ARGV_BUFSIZ, ace_isspace(), ACE_NEW_RETURN, ACE_TEXT, strdup(), and strenvdup().

Referenced by ACE_ARGV_T< CHAR_TYPE >::string_to_argv().

00734 {
00735   // Reset the number of arguments
00736   argc = 0;
00737 
00738   if (buf == 0)
00739     return -1;
00740 
00741   ACE_TCHAR *cp = buf;
00742 
00743   // First pass: count arguments.
00744 
00745   // '#' is the start-comment token..
00746   while (*cp != ACE_TEXT ('\0') && *cp != ACE_TEXT ('#'))
00747     {
00748       // Skip whitespace..
00749       while (ACE_OS::ace_isspace (*cp))
00750         ++cp;
00751 
00752       // Increment count and move to next whitespace..
00753       if (*cp != ACE_TEXT ('\0'))
00754         ++argc;
00755 
00756       while (*cp != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
00757         {
00758           // Grok quotes....
00759           if (*cp == ACE_TEXT ('\'') || *cp == ACE_TEXT ('"'))
00760             {
00761               ACE_TCHAR quote = *cp;
00762 
00763               // Scan past the string..
00764               for (++cp; *cp != ACE_TEXT ('\0')
00765                    && (*cp != quote || cp[-1] == ACE_TEXT ('\\')); ++cp)
00766                 continue;
00767 
00768               // '\0' implies unmatched quote..
00769               if (*cp == ACE_TEXT ('\0'))
00770                 {
00771                   --argc;
00772                   break;
00773                 }
00774               else
00775                 ++cp;
00776             }
00777           else
00778             ++cp;
00779         }
00780     }
00781 
00782   // Second pass: copy arguments.
00783   ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
00784   ACE_TCHAR *argp = arg;
00785 
00786   // Make sure that the buffer we're copying into is always large
00787   // enough.
00788   if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
00789     ACE_NEW_RETURN (argp,
00790                     ACE_TCHAR[cp - buf + 1],
00791                     -1);
00792 
00793   // Make a new argv vector of argc + 1 elements.
00794   ACE_NEW_RETURN (argv,
00795                   ACE_TCHAR *[argc + 1],
00796                   -1);
00797 
00798   ACE_TCHAR *ptr = buf;
00799 
00800   for (int i = 0; i < argc; ++i)
00801     {
00802       // Skip whitespace..
00803       while (ACE_OS::ace_isspace (*ptr))
00804         ++ptr;
00805 
00806       // Copy next argument and move to next whitespace..
00807       cp = argp;
00808       while (*ptr != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
00809         if (*ptr == ACE_TEXT ('\'') || *ptr == ACE_TEXT ('"'))
00810           {
00811             ACE_TCHAR quote = *ptr++;
00812 
00813             while (*ptr != ACE_TEXT ('\0')
00814                    && (*ptr != quote || ptr[-1] == ACE_TEXT ('\\')))
00815               {
00816                 if (*ptr == quote && ptr[-1] == ACE_TEXT ('\\')) --cp;
00817                 *cp++ = *ptr++;
00818               }
00819 
00820             if (*ptr == quote)
00821               ++ptr;
00822           }
00823         else
00824           *cp++ = *ptr++;
00825 
00826       *cp = ACE_TEXT ('\0');
00827 
00828 #if !defined (ACE_LACKS_ENV)
00829       // Check for environment variable substitution here.
00830       if (substitute_env_args) {
00831           argv[i] = ACE_OS::strenvdup (argp);
00832 
00833           if (argv[i] == 0)
00834             {
00835               if (argp != arg)
00836                 delete [] argp;
00837               errno = ENOMEM;
00838               return -1;
00839             }
00840       }
00841       else
00842 #endif /* ACE_LACKS_ENV */
00843         {
00844           argv[i] = ACE_OS::strdup (argp);
00845 
00846           if (argv[i] == 0)
00847             {
00848               if (argp != arg)
00849                 delete [] argp;
00850               errno = ENOMEM;
00851               return -1;
00852             }
00853         }
00854     }
00855 
00856   if (argp != arg)
00857     delete [] argp;
00858 
00859   argv[argc] = 0;
00860   return 0;
00861 }

ACE_Export 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 867 of file OS_NS_unistd.cpp.

References write().

Referenced by ACE::write_n().

00871 {
00872   size_t temp;
00873   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00874   ssize_t n;
00875 
00876   for (bytes_transferred = 0;
00877        bytes_transferred < len;
00878        bytes_transferred += n)
00879     {
00880       n = ACE_OS::write (handle,
00881                          (char *) buf + bytes_transferred,
00882                          len - bytes_transferred);
00883 
00884       if (n == -1 || n == 0)
00885         return n;
00886     }
00887 
00888   return bytes_transferred;
00889 }

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

Definition at line 36 of file OS_NS_unistd.inl.

References access(), ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, fclose(), and fopen().

Referenced by access(), ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ACE::ldfind(), open(), and ACE_Configuration_Heap::open().

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

ACE_NAMESPACE_INLINE_FUNCTION unsigned int ACE_OS::alarm ( u_int  secs  ) 

Definition at line 79 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and alarm().

Referenced by alarm(), and ualarm().

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

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::allocation_granularity ( void   ) 

Definition at line 109 of file OS_NS_unistd.inl.

References getpagesize().

Referenced by ACE::round_to_allocation_granularity().

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::chdir ( const char *  path  ) 

Definition at line 122 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and chdir().

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

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

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::rmdir ( const char *  path  ) 

Definition at line 149 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_TEXT_CHAR_TO_TCHAR, and rmdir().

Referenced by rmdir().

00150 {
00151 #if defined (ACE_HAS_WINCE)
00152   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (ACE_TEXT_CHAR_TO_TCHAR (path)),
00153                                           ace_result_),
00154                         int, -1);
00155 #else
00156   ACE_OSCALL_RETURN (::rmdir (path), int, -1);
00157 #endif /* ACE_WIN32 */
00158 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::close ( ACE_HANDLE  handle  ) 

Definition at line 182 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and close().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Mutex::ACE_Mutex(), ACE_SPIPE::close(), close(), ACE_Log_Msg::close(), ACE_IOStream< STREAM >::close(), ACE_FILE::close(), ACE_FIFO_Recv::close(), ACE_FIFO::close(), ACE_DEV::close(), ACE_Strategy_Connector< SVC_HANDLER, >::close(), ACE_Active_Map_Manager< T >::close(), ACE_Mem_Map::close_filemapping_handle(), ACE_Mem_Map::close_handle(), ACE_Handle_Gobbler::close_remaining_handles(), closesocket(), ACE_SPIPE_Connector::connect(), ACE_SPIPE_Acceptor::create_new_instance(), ACE::daemonize(), dlopen(), event_init(), filesize(), flock_destroy(), fork_exec(), ACE_Handle_Gobbler::free_handles(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), getmacaddress(), ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_timeout(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::open(), ACE_Filecache_Object::release(), ACE_Process_Options::release_handles(), sema_destroy(), sema_init(), ACE_Process::spawn(), ACE::terminate_process(), ACE_Filecache_Handle::~ACE_Filecache_Handle(), ACE_Filecache_Object::~ACE_Filecache_Object(), ACE_Framework_Repository::~ACE_Framework_Repository(), ACE_Log_Msg::~ACE_Log_Msg(), and ACE_Process::~ACE_Process().

00183 {
00184   ACE_OS_TRACE ("ACE_OS::close");
00185 #if defined (ACE_WIN32)
00186   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1);
00187 #else
00188   ACE_OSCALL_RETURN (::close (handle), int, -1);
00189 #endif /* ACE_WIN32 */
00190 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_HANDLE ACE_OS::dup ( ACE_HANDLE  handle  ) 

Definition at line 193 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and dup().

Referenced by dup(), ACE_Filecache_Handle::handle(), ACE_Process_Options::set_handles(), and ACE_Process::spawn().

00194 {
00195   ACE_OS_TRACE ("ACE_OS::dup");
00196 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00197   ACE_HANDLE new_fd;
00198   if (::DuplicateHandle(::GetCurrentProcess (),
00199                         handle,
00200                         ::GetCurrentProcess(),
00201                         &new_fd,
00202                         0,
00203                         TRUE,
00204                         DUPLICATE_SAME_ACCESS))
00205     return new_fd;
00206   else
00207     ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00208   /* NOTREACHED */
00209 #elif defined (ACE_LACKS_DUP)
00210   ACE_UNUSED_ARG (handle);
00211   ACE_NOTSUP_RETURN (-1);
00212 #elif defined (ACE_HAS_WINCE)
00213   ACE_UNUSED_ARG (handle);
00214   ACE_NOTSUP_RETURN (0);
00215 #else
00216   ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE);
00217 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */
00218 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::dup2 ( ACE_HANDLE  oldfd,
ACE_HANDLE  newfd 
)

Definition at line 221 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and dup2().

Referenced by dup2(), and ACE_Process::spawn().

00222 {
00223   ACE_OS_TRACE ("ACE_OS::dup2");
00224 #if defined (ACE_LACKS_DUP2)
00225   // msvcrt has _dup2 ?!
00226   ACE_UNUSED_ARG (oldhandle);
00227   ACE_UNUSED_ARG (newhandle);
00228   ACE_NOTSUP_RETURN (-1);
00229 #else
00230   ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1);
00231 #endif /* ACE_LACKS_DUP2 */
00232 }

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

Definition at line 235 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execv().

Referenced by execv(), and fork_exec().

00237 {
00238   ACE_OS_TRACE ("ACE_OS::execv");
00239 #if defined (ACE_LACKS_EXEC)
00240   ACE_UNUSED_ARG (path);
00241   ACE_UNUSED_ARG (argv);
00242 
00243   ACE_NOTSUP_RETURN (-1);
00244 #elif defined (ACE_WIN32)
00245 # if defined (__BORLANDC__) /* VSB */
00246   return ::execv (path, argv);
00247 # elif defined (__MINGW32__)
00248   return ::_execv (path, (char *const *) argv);
00249 # else
00250   // Why this odd-looking code? If execv() returns at all, it's an error.
00251   // Windows defines this as returning an intptr_t rather than a simple int,
00252   // and the conversion triggers compile warnings. So just return -1 if
00253   // the call returns.
00254   ::_execv (path, (const char *const *) argv);
00255   return -1;
00256 # endif /* __BORLANDC__ */
00257 #else
00258   ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00259 #endif /* ACE_LACKS_EXEC */
00260 }

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

Definition at line 263 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execve().

Referenced by execve(), and ACE_Process::spawn().

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

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

Definition at line 293 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execvp().

Referenced by execvp(), and ACE_Process::spawn().

00295 {
00296   ACE_OS_TRACE ("ACE_OS::execvp");
00297 #if defined (ACE_LACKS_EXEC)
00298   ACE_UNUSED_ARG (file);
00299   ACE_UNUSED_ARG (argv);
00300 
00301   ACE_NOTSUP_RETURN (-1);
00302 #elif defined (ACE_WIN32)
00303 # if defined (__BORLANDC__) /* VSB */
00304   return ::execvp (file, argv);
00305 # elif defined (__MINGW32__)
00306   return ::_execvp (file, (char *const *) argv);
00307 # else
00308   // Why this odd-looking code? If execv() returns at all, it's an error.
00309   // Windows defines this as returning an intptr_t rather than a simple int,
00310   // and the conversion triggers compile warnings. So just return -1 if
00311   // the call returns.
00312   ::_execvp (file, (const char *const *) argv);
00313   return -1;
00314 # endif /* __BORLANDC__ */
00315 #else
00316   ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00317 #endif /* ACE_LACKS_EXEC */
00318 }

ACE_NAMESPACE_INLINE_FUNCTION pid_t ACE_OS::fork ( void   ) 

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

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fork().

00322 {
00323   ACE_OS_TRACE ("ACE_OS::fork");
00324 #if defined (ACE_LACKS_FORK)
00325   ACE_NOTSUP_RETURN (pid_t (-1));
00326 #else
00327   ACE_OSCALL_RETURN (::fork (), pid_t, -1);
00328 #endif /* ACE_LACKS_FORK */
00329 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::fsync ( ACE_HANDLE  handle  ) 

Definition at line 332 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fsync().

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name(), fstat(), fsync(), and mmap().

00333 {
00334   ACE_OS_TRACE ("ACE_OS::fsync");
00335 # if defined (ACE_LACKS_FSYNC)
00336   ACE_UNUSED_ARG (handle);
00337   ACE_NOTSUP_RETURN (-1);
00338 # elif defined (ACE_WIN32)
00339   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushFileBuffers (handle), ace_result_), int, -1);
00340 # else
00341   ACE_OSCALL_RETURN (::fsync (handle), int, -1);
00342 # endif /* ACE_LACKS_FSYNC */
00343 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::ftruncate ( ACE_HANDLE  handle,
ACE_OFF_T  offset 
)

Definition at line 346 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and ftruncate().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ftruncate(), ACE_Mem_Map::remove(), sema_init(), and ACE_FILE::truncate().

00347 {
00348   ACE_OS_TRACE ("ACE_OS::ftruncate");
00349 #if defined (ACE_WIN32)
00350 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
00351   LARGE_INTEGER loff;
00352   loff.QuadPart = offset;
00353   if (::SetFilePointerEx (handle, loff, 0, FILE_BEGIN))
00354 #  else
00355   if (::SetFilePointer (handle,
00356                         offset,
00357                         0,
00358                         FILE_BEGIN) != INVALID_SET_FILE_POINTER)
00359 #  endif
00360     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
00361   else
00362     ACE_FAIL_RETURN (-1);
00363 #else
00364   ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1);
00365 #endif /* ACE_WIN32 */
00366 }

ACE_NAMESPACE_INLINE_FUNCTION char* ACE_OS::getcwd ( char *  ,
size_t   
)

Definition at line 369 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getcwd().

Referenced by getcwd().

00370 {
00371   ACE_OS_TRACE ("ACE_OS::getcwd");
00372 #if defined (ACE_LACKS_GETCWD)
00373   ACE_UNUSED_ARG (buf);
00374   ACE_UNUSED_ARG (size);
00375   ACE_NOTSUP_RETURN (0);
00376 #elif defined (ACE_WIN32)
00377   return ::getcwd (buf, static_cast<int> (size));
00378 #else
00379   ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0);
00380 #endif /* ACE_LACKS_GETCWD */
00381 }

ACE_NAMESPACE_INLINE_FUNCTION gid_t ACE_OS::getgid ( void   ) 

Definition at line 407 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getgid().

Referenced by getgid(), and ACE_SPIPE_Addr::set().

00408 {
00409   ACE_OS_TRACE ("ACE_OS::getgid");
00410 #if defined (ACE_LACKS_GETGID)
00411   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00412 # else
00413   ACE_OSCALL_RETURN (::getgid (), gid_t, static_cast<gid_t> (-1));
00414 # endif /* ACE_LACKS_GETGID */
00415 }

ACE_NAMESPACE_INLINE_FUNCTION gid_t ACE_OS::getegid ( void   ) 

Definition at line 418 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getegid().

Referenced by getegid().

00419 {
00420   ACE_OS_TRACE ("ACE_OS::getegid");
00421 #if defined (ACE_LACKS_GETEGID)
00422   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00423 # else
00424   ACE_OSCALL_RETURN (::getegid (), gid_t, static_cast<gid_t> (-1));
00425 # endif /* ACE_LACKS_GETEGID */
00426 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::getopt ( int  argc,
char *const *  argv,
const char *  optstring 
)

Definition at line 429 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getopt().

Referenced by getopt(), ACE_Service_Manager::init(), ACE_Service_Gestalt::parse_args_i(), and ACE_Service_Config::parse_args_i().

00430 {
00431   ACE_OS_TRACE ("ACE_OS::getopt");
00432 #if defined (ACE_LACKS_GETOPT)
00433   ACE_UNUSED_ARG (argc);
00434   ACE_UNUSED_ARG (argv);
00435   ACE_UNUSED_ARG (optstring);
00436   ACE_NOTSUP_RETURN (-1);
00437 # else
00438   ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1);
00439 # endif /* ACE_LACKS_GETOPT */
00440 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::getpagesize ( void   ) 

Definition at line 91 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, getpagesize(), and sysconf().

Referenced by allocation_granularity(), getpagesize(), and ACE::round_to_pagesize().

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

ACE_NAMESPACE_INLINE_FUNCTION pid_t ACE_OS::getpgid ( pid_t  pid  ) 

Definition at line 443 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getpgid().

Referenced by getpgid().

00444 {
00445   ACE_OS_TRACE ("ACE_OS::getpgid");
00446 #if defined (ACE_LACKS_GETPGID)
00447   ACE_UNUSED_ARG (pid);
00448   ACE_NOTSUP_RETURN (-1);
00449 #elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0
00450   // getpgid() is from SVR4, which appears to be the reason why GLIBC
00451   // doesn't enable its prototype by default.
00452   // Rather than create our own extern prototype, just use the one
00453   // that is visible (ugh).
00454   ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1);
00455 #else
00456   ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1);
00457 #endif /* ACE_LACKS_GETPGID */
00458 }

ACE_NAMESPACE_INLINE_FUNCTION pid_t ACE_OS::getpid ( void   ) 

Definition at line 461 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and getpid().

Referenced by ACE_IPC_SAP::enable(), ACE_IO_SAP::enable(), ACE_Utils::UUID_Generator::generate_UUID(), getpid(), ACE_Log_Msg::getpid(), ACE_Service_Config::open_i(), ACE_SPIPE_Stream::recv_handle(), ACE_Log_Msg::sync(), and unique_name().

00462 {
00463   // ACE_OS_TRACE ("ACE_OS::getpid");
00464 #if defined (ACE_LACKS_GETPID)
00465   ACE_NOTSUP_RETURN (-1);
00466 #elif defined (ACE_WIN32)
00467   return ::GetCurrentProcessId ();
00468 #else
00469   ACE_OSCALL_RETURN (::getpid (), int, -1);
00470 #endif /* ACE_LACKS_GETPID */
00471 }

ACE_NAMESPACE_INLINE_FUNCTION pid_t ACE_OS::getppid ( void   ) 

Definition at line 474 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getppid().

Referenced by getppid(), and ACE_Process::spawn().

00475 {
00476   ACE_OS_TRACE ("ACE_OS::getppid");
00477 #if defined (ACE_LACKS_GETPPID)
00478   ACE_NOTSUP_RETURN (-1);
00479 #else
00480   ACE_OSCALL_RETURN (::getppid (), pid_t, -1);
00481 #endif /* ACE_LACKS_GETPPID */
00482 }

ACE_NAMESPACE_INLINE_FUNCTION uid_t ACE_OS::getuid ( void   ) 

Definition at line 485 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getuid().

Referenced by getuid(), and ACE_SPIPE_Addr::set().

00486 {
00487   ACE_OS_TRACE ("ACE_OS::getuid");
00488 #if defined (ACE_LACKS_GETUID)
00489   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00490 # else
00491   ACE_OSCALL_RETURN (::getuid (), uid_t, static_cast<uid_t> (-1));
00492 # endif /* ACE_LACKS_GETUID*/
00493 }

ACE_NAMESPACE_INLINE_FUNCTION uid_t ACE_OS::geteuid ( void   ) 

Definition at line 496 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and geteuid().

Referenced by cuserid(), and geteuid().

00497 {
00498   ACE_OS_TRACE ("ACE_OS::geteuid");
00499 #if defined (ACE_LACKS_GETEUID)
00500   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00501 # else
00502   ACE_OSCALL_RETURN (::geteuid (), uid_t, (uid_t) -1);
00503 # endif /* ACE_LACKS_GETEUID */
00504 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::hostname ( char *  name,
size_t  maxnamelen 
)

Referenced by ACE_INET_Addr::get_host_name_i(), getmacaddress(), ACE_Naming_Context::open(), and uname().

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::isatty ( int  handle  ) 

Definition at line 573 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and isatty().

Referenced by isatty().

00574 {
00575   ACE_OS_TRACE ("ACE_OS::isatty");
00576 #if defined (ACE_LACKS_ISATTY)
00577   ACE_UNUSED_ARG (handle);
00578   return 0;
00579 # elif defined (ACE_WIN32)
00580   return ::_isatty (handle);
00581 # else
00582   ACE_OSCALL_RETURN (::isatty (handle), int, -1);
00583 # endif /* ACE_LACKS_ISATTY */
00584 }

ACE_NAMESPACE_INLINE_FUNCTION ACE_OFF_T ACE_OS::lseek ( ACE_HANDLE  handle,
ACE_OFF_T  offset,
int  whence 
)

Definition at line 604 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and lseek().

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

00605 {
00606   ACE_OS_TRACE ("ACE_OS::lseek");
00607 #if defined (ACE_WIN32)
00608 # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00609   //#error Windows NT is evil AND rude!
00610   switch (whence)
00611     {
00612     case SEEK_SET:
00613       whence = FILE_BEGIN;
00614       break;
00615     case SEEK_CUR:
00616       whence = FILE_CURRENT;
00617       break;
00618     case SEEK_END:
00619       whence = FILE_END;
00620       break;
00621     default:
00622       errno = EINVAL;
00623       return static_cast<ACE_OFF_T> (-1); // rather safe than sorry
00624     }
00625 # endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00626   LONG low_offset = ACE_LOW_PART(offset);
00627   LONG high_offset = ACE_HIGH_PART(offset);
00628   DWORD const result =
00629     ::SetFilePointer (handle, low_offset, &high_offset, whence);
00630   if (result == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
00631     ACE_FAIL_RETURN (static_cast<ACE_OFF_T> (-1));
00632   else
00633     return result;
00634 #else
00635   ACE_OSCALL_RETURN (::lseek (handle, offset, whence), ACE_OFF_T, -1);
00636 #endif /* ACE_WIN32 */
00637 }

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

Definition at line 764 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and pipe().

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

00765 {
00766   ACE_OS_TRACE ("ACE_OS::pipe");
00767 # if defined (ACE_LACKS_PIPE)
00768   ACE_UNUSED_ARG (fds);
00769   ACE_NOTSUP_RETURN (-1);
00770 # elif defined (ACE_WIN32)
00771   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL
00772                         (::CreatePipe (&fds[0], &fds[1], 0, 0),
00773                          ace_result_), int, -1);
00774 # else
00775   ACE_OSCALL_RETURN (::pipe (fds), int, -1);
00776 # endif /* ACE_LACKS_PIPE */
00777 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::read ( ACE_HANDLE  handle,
void *  buf,
size_t  len 
)

Definition at line 687 of file OS_NS_unistd.inl.

Referenced by pread(), read(), read_n(), ACE_SPIPE_Stream::recv(), ACE_SOCK_IO::recv(), ACE_Pipe::recv(), ACE_FILE_IO::recv(), ACE_FIFO_Recv_Msg::recv(), ACE_FIFO_Recv::recv(), ACE_DEV_IO::recv(), ACE::recv_i(), sema_trywait(), and sema_wait().

00688 {
00689   ACE_OS_TRACE ("ACE_OS::read");
00690 #if defined (ACE_WIN32)
00691   DWORD ok_len;
00692   if (::ReadFile (handle, buf, static_cast<DWORD> (len), &ok_len, 0))
00693     return (ssize_t) ok_len;
00694   else
00695     ACE_FAIL_RETURN (-1);
00696 #else
00697 
00698   ssize_t result;
00699 
00700 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
00701   ACE_OSCALL (::read (handle, static_cast <char *> (buf), len), ssize_t, -1, result);
00702 # else
00703   ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result);
00704 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
00705 
00706 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00707   // Optimize this code out if we can detect that EAGAIN ==
00708   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00709   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00710   // macros) perform the check at run-time.  The goal is to avoid two
00711   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00712   if (result == -1
00713 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00714       && EAGAIN != EWOULDBLOCK
00715 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00716       && errno == EAGAIN)
00717     {
00718       errno = EWOULDBLOCK;
00719     }
00720 # endif /* EAGAIN != EWOULDBLOCK*/
00721 
00722   return result;
00723 #endif /* ACE_WIN32 */
00724 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::read ( ACE_HANDLE  handle,
void *  buf,
size_t  len,
ACE_OVERLAPPED  
)

Definition at line 727 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and read().

00729 {
00730   ACE_OS_TRACE ("ACE_OS::read");
00731   overlapped = overlapped;
00732 #if defined (ACE_WIN32)
00733   DWORD ok_len;
00734   DWORD short_len = static_cast<DWORD> (len);
00735   if (::ReadFile (handle, buf, short_len, &ok_len, overlapped))
00736     return (ssize_t) ok_len;
00737   else
00738     ACE_FAIL_RETURN (-1);
00739 #else
00740   return ACE_OS::read (handle, buf, len);
00741 #endif /* ACE_WIN32 */
00742 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::readlink ( const char *  path,
char *  buf,
size_t  bufsiz 
)

Definition at line 745 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and readlink().

Referenced by readlink().

00746 {
00747   ACE_OS_TRACE ("ACE_OS::readlink");
00748 # if defined (ACE_LACKS_READLINK)
00749   ACE_UNUSED_ARG (path);
00750   ACE_UNUSED_ARG (buf);
00751   ACE_UNUSED_ARG (bufsiz);
00752   ACE_NOTSUP_RETURN (-1);
00753 # else
00754 #   if !defined(ACE_HAS_NONCONST_READLINK)
00755       ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), ssize_t, -1);
00756 #   else
00757       ACE_OSCALL_RETURN (
00758         ::readlink (const_cast <char *>(path), buf, bufsiz), ssize_t, -1);
00759 #   endif
00760 # endif /* ACE_LACKS_READLINK */
00761 }

ACE_NAMESPACE_INLINE_FUNCTION void* ACE_OS::sbrk ( intptr_t  brk  ) 

Definition at line 780 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and sbrk().

Referenced by ACE_Sbrk_Memory_Pool::acquire(), and sbrk().

00781 {
00782 #if defined (ACE_LACKS_SBRK)
00783   ACE_UNUSED_ARG (brk);
00784   ACE_NOTSUP_RETURN (0);
00785 #else
00786   ACE_OSCALL_RETURN (::sbrk (brk), void *, 0);
00787 #endif /* ACE_LACKS_SBRK */
00788 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setgid ( gid_t   ) 

Definition at line 791 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setgid().

Referenced by setgid().

00792 {
00793   ACE_OS_TRACE ("ACE_OS::setgid");
00794 #if defined (ACE_LACKS_SETGID)
00795   ACE_UNUSED_ARG (gid);
00796   ACE_NOTSUP_RETURN (-1);
00797 # else
00798   ACE_OSCALL_RETURN (::setgid (gid), int,  -1);
00799 # endif /* ACE_LACKS_SETGID */
00800 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setegid ( gid_t   ) 

Definition at line 803 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setegid().

Referenced by setegid().

00804 {
00805   ACE_OS_TRACE ("ACE_OS::setegid");
00806 #if defined (ACE_LACKS_SETEGID)
00807   ACE_UNUSED_ARG (gid);
00808   ACE_NOTSUP_RETURN (-1);
00809 # else
00810   ACE_OSCALL_RETURN (::setegid (gid), int,  -1);
00811 # endif /* ACE_LACKS_SETEGID */
00812 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setpgid ( pid_t  pid,
pid_t  pgid 
)

Definition at line 815 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setpgid().

Referenced by setpgid(), and ACE_Process::spawn().

00816 {
00817   ACE_OS_TRACE ("ACE_OS::setpgid");
00818 #if defined (ACE_LACKS_SETPGID)
00819   ACE_UNUSED_ARG (pid);
00820   ACE_UNUSED_ARG (pgid);
00821   ACE_NOTSUP_RETURN (-1);
00822 #else
00823   ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1);
00824 #endif /* ACE_LACKS_SETPGID */
00825 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setregid ( gid_t  rgid,
gid_t  egid 
)

Definition at line 828 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setregid().

Referenced by setregid(), and ACE_Process::spawn().

00829 {
00830   ACE_OS_TRACE ("ACE_OS::setregid");
00831 #if defined (ACE_LACKS_SETREGID)
00832   ACE_UNUSED_ARG (rgid);
00833   ACE_UNUSED_ARG (egid);
00834   ACE_NOTSUP_RETURN (-1);
00835 #else
00836   ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1);
00837 #endif /* ACE_LACKS_SETREGID */
00838 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setreuid ( uid_t  ruid,
uid_t  euid 
)

Definition at line 841 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setreuid().

Referenced by setreuid(), and ACE_Process::spawn().

00842 {
00843   ACE_OS_TRACE ("ACE_OS::setreuid");
00844 #if defined (ACE_LACKS_SETREUID)
00845   ACE_UNUSED_ARG (ruid);
00846   ACE_UNUSED_ARG (euid);
00847   ACE_NOTSUP_RETURN (-1);
00848 #else
00849   ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1);
00850 #endif /* ACE_LACKS_SETREUID */
00851 }

ACE_NAMESPACE_INLINE_FUNCTION pid_t ACE_OS::setsid ( void   ) 

Definition at line 854 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setsid().

Referenced by ACE::daemonize(), and setsid().

00855 {
00856   ACE_OS_TRACE ("ACE_OS::setsid");
00857 #if defined (ACE_LACKS_SETSID)
00858   ACE_NOTSUP_RETURN (-1);
00859 #else
00860   ACE_OSCALL_RETURN (::setsid (), int, -1);
00861 # endif /* ACE_LACKS_SETSID */
00862 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::setuid ( uid_t   ) 

Definition at line 865 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setuid().

Referenced by setuid().

00866 {
00867   ACE_OS_TRACE ("ACE_OS::setuid");
00868 #if defined (ACE_LACKS_SETUID)
00869   ACE_UNUSED_ARG (uid);
00870   ACE_NOTSUP_RETURN (-1);
00871 # else
00872   ACE_OSCALL_RETURN (::setuid (uid), int,  -1);
00873 # endif /* ACE_LACKS_SETUID */
00874 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::seteuid ( uid_t   ) 

Definition at line 877 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and seteuid().

Referenced by seteuid().

00878 {
00879   ACE_OS_TRACE ("ACE_OS::seteuid");
00880 #if defined (ACE_LACKS_SETEUID)
00881   ACE_UNUSED_ARG (uid);
00882   ACE_NOTSUP_RETURN (-1);
00883 # else
00884   ACE_OSCALL_RETURN (::seteuid (uid), int,  -1);
00885 # endif /* ACE_LACKS_SETEUID */
00886 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sleep ( u_int  seconds  ) 

Definition at line 889 of file OS_NS_unistd.inl.

Referenced by ACE_High_Res_Timer::calibrate(), ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK_Connector::complete(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::initialize_svc_handler(), nanosleep(), sleep(), ACE_Process_Manager::wait(), and ACE_Process::wait().

00890 {
00891   ACE_OS_TRACE ("ACE_OS::sleep");
00892 #if defined (ACE_WIN32)
00893   ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
00894   return 0;
00895 #elif defined (ACE_HAS_CLOCK_GETTIME)
00896   struct timespec rqtp;
00897   // Initializer doesn't work with Green Hills 1.8.7
00898   rqtp.tv_sec = seconds;
00899   rqtp.tv_nsec = 0L;
00900   //FUZZ: disable check_for_lack_ACE_OS
00901   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00902   //FUZZ: enable check_for_lack_ACE_OS
00903 #else
00904   ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
00905 #endif /* ACE_WIN32 */
00906 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::sleep ( const ACE_Time_Value tv  ) 

Definition at line 909 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, ACE_Time_Value::msec(), nanosleep(), and select().

00910 {
00911   ACE_OS_TRACE ("ACE_OS::sleep");
00912 #if defined (ACE_WIN32)
00913   ::Sleep (tv.msec ());
00914   return 0;
00915 #elif defined (ACE_HAS_CLOCK_GETTIME)
00916   timespec_t rqtp = tv;
00917   //FUZZ: disable check_for_lack_ACE_OS
00918   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00919   //FUZZ: enable check_for_lack_ACE_OS
00920 #else
00921 # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00922   // Copy the timeval, because this platform doesn't declare the timeval
00923   // as a pointer to const.
00924   timeval tv_copy = tv;
00925 #  if defined(ACE_TANDEM_T1248_PTHREADS)
00926      ACE_OSCALL_RETURN (::spt_select (0, 0, 0, 0, &tv_copy), int, -1);
00927 #  else
00928      //FUZZ: disable check_for_lack_ACE_OS
00929      ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1);
00930      //FUZZ: enable check_for_lack_ACE_OS
00931 #  endif
00932 # else  /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */
00933   const timeval *tvp = tv;
00934   //FUZZ: disable check_for_lack_ACE_OS
00935   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1);
00936   //FUZZ: enable check_for_lack_ACE_OS
00937 # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00938 #endif /* ACE_WIN32 */
00939 }

ACE_NAMESPACE_INLINE_FUNCTION void ACE_OS::swab ( const void *  src,
void *  dest,
ssize_t  n 
)

Definition at line 942 of file OS_NS_unistd.inl.

References swab().

Referenced by swab().

00945 {
00946 #if defined (ACE_LACKS_SWAB)
00947   // ------------------------------------------------------------
00948   // The following copyright notice applies to the swab()
00949   // implementation within this "ACE_LACKS_SWAB" block of code.
00950   // ------------------------------------------------------------
00951   /*
00952     Copyright (c) 1994-2006  Red Hat, Inc. All rights reserved.
00953 
00954     This copyrighted material is made available to anyone wishing to
00955     use, modify, copy, or redistribute it subject to the terms and
00956     conditions of the BSD License.   This program is distributed in
00957     the hope that it will be useful, but WITHOUT ANY WARRANTY
00958     expressed or implied, including the implied warranties of
00959     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  A copy of
00960     this license is available at
00961     http://www.opensource.org/licenses. Any Red Hat trademarks that
00962     are incorporated in the source code or documentation are not
00963     subject to the BSD License and may only be used or replicated with
00964     the express permission of Red Hat, Inc.
00965   */
00966 
00967   const char *from = static_cast<const char*> (src);
00968   char *to = static_cast<char *> (dest);
00969   ssize_t ptr = 0;
00970   for (ptr = 1; ptr < length; ptr += 2)
00971     {
00972       char p = from[ptr];
00973       char q = from[ptr-1];
00974       to[ptr-1] = p;
00975       to[ptr  ] = q;
00976     }
00977   if (ptr == length) /* I.e., if length is odd, */
00978     to[ptr-1] = 0;   /* then pad with a NUL. */
00979 #elif defined (ACE_HAS_NONCONST_SWAB)
00980   const char *tmp = static_cast<const char*> (src);
00981   char *from = const_cast<char *> (tmp);
00982   char *to = static_cast<char *> (dest);
00983   ::swab (from, to, length);
00984 #elif defined (ACE_HAS_CONST_CHAR_SWAB)
00985   const char *from = static_cast<const char*> (src);
00986   char *to = static_cast<char *> (dest);
00987   ::swab (from, to, length);
00988 #else
00989   ::swab (src, dest, length);
00990 #endif /* ACE_LACKS_SWAB */
00991 
00992 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::sysconf ( int   ) 

Definition at line 995 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysconf().

Referenced by getpagesize(), ACE::max_handles(), num_processors(), num_processors_online(), sysconf(), and thr_min_stack().

00996 {
00997   ACE_OS_TRACE ("ACE_OS::sysconf");
00998 #if defined (ACE_LACKS_SYSCONF)
00999   ACE_UNUSED_ARG (name);
01000   ACE_NOTSUP_RETURN (-1);
01001 #else
01002   ACE_OSCALL_RETURN (::sysconf (name), long, -1);
01003 #endif /* ACE_LACKS_SYSCONF */
01004 }

ACE_NAMESPACE_INLINE_FUNCTION long ACE_OS::sysinfo ( int  cmd,
char *  buf,
long  count 
)

Definition at line 1007 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysinfo().

Referenced by sysinfo().

01008 {
01009   ACE_OS_TRACE ("ACE_OS::sysinfo");
01010 #if defined (ACE_HAS_SYSINFO)
01011   ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1);
01012 #else
01013   ACE_UNUSED_ARG (cmd);
01014   ACE_UNUSED_ARG (buf);
01015   ACE_UNUSED_ARG (count);
01016 
01017   ACE_NOTSUP_RETURN (0);
01018 #endif /* ACE_HAS_SYSINFO */
01019 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::truncate ( const ACE_TCHAR filename,
ACE_OFF_T  length 
)

Definition at line 1022 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_DEFAULT_FILE_PERMS, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, open(), and truncate().

Referenced by truncate().

01024 {
01025   ACE_OS_TRACE ("ACE_OS::truncate");
01026 #if defined (ACE_WIN32)
01027   ACE_HANDLE handle = ACE_OS::open (filename,
01028                                     O_WRONLY,
01029                                     ACE_DEFAULT_FILE_PERMS);
01030 
01031 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01032   LARGE_INTEGER loffset;
01033   loffset.QuadPart = offset;
01034 #else
01035   LONG low_offset = ACE_LOW_PART(offset);
01036   LONG high_offset = ACE_HIGH_PART(offset);
01037 #endif
01038 
01039   if (handle == ACE_INVALID_HANDLE)
01040     ACE_FAIL_RETURN (-1);
01041 
01042 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01043   else if (::SetFilePointerEx (handle,
01044                                loffset,
01045                                0,
01046                                FILE_BEGIN))
01047 #  else
01048   else if (::SetFilePointer (handle,
01049                              low_offset,
01050                              &high_offset,
01051                              FILE_BEGIN) != INVALID_SET_FILE_POINTER
01052            || GetLastError () == NO_ERROR)
01053 #  endif /* ACE_LACKS_WIN32_SETFILEPOINTEREX */
01054     {
01055       BOOL result = ::SetEndOfFile (handle);
01056       ::CloseHandle (handle);
01057       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1);
01058     }
01059   else
01060     {
01061       ::CloseHandle (handle);
01062       ACE_FAIL_RETURN (-1);
01063     }
01064   /* NOTREACHED */
01065 #elif !defined (ACE_LACKS_TRUNCATE)
01066   ACE_OSCALL_RETURN
01067     (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1);
01068 #else
01069   ACE_UNUSED_ARG (filename);
01070   ACE_UNUSED_ARG (offset);
01071   ACE_NOTSUP_RETURN (-1);
01072 #endif /* ACE_WIN32 */
01073 }

ACE_NAMESPACE_INLINE_FUNCTION useconds_t ACE_OS::ualarm ( useconds_t  usecs,
useconds_t  interval = 0 
)

Definition at line 1076 of file OS_NS_unistd.inl.

Referenced by ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm(), and ualarm().

01077 {
01078   ACE_OS_TRACE ("ACE_OS::ualarm");
01079 
01080 #if defined (ACE_HAS_UALARM)
01081   return ::ualarm (usecs, interval);
01082 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01083   ACE_UNUSED_ARG (interval);
01084   return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS);
01085 #else
01086   ACE_UNUSED_ARG (usecs);
01087   ACE_UNUSED_ARG (interval);
01088   ACE_NOTSUP_RETURN (0);
01089 #endif /* ACE_HAS_UALARM */
01090 }

ACE_NAMESPACE_INLINE_FUNCTION useconds_t ACE_OS::ualarm ( const ACE_Time_Value tv,
const ACE_Time_Value tv_interval = ACE_Time_Value::zero 
)

Definition at line 1093 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, alarm(), ACE_Time_Value::sec(), ualarm(), and ACE_Time_Value::usec().

01095 {
01096   ACE_OS_TRACE ("ACE_OS::ualarm");
01097 
01098 #if defined (ACE_HAS_UALARM)
01099   useconds_t usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec ();
01100   useconds_t interval =
01101     (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec ();
01102   return ::ualarm (usecs, interval);
01103 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01104   ACE_UNUSED_ARG (tv_interval);
01105   return ::alarm (tv.sec ());
01106 #else
01107   ACE_UNUSED_ARG (tv_interval);
01108   ACE_UNUSED_ARG (tv);
01109   ACE_NOTSUP_RETURN (0);
01110 #endif /* ACE_HAS_UALARM */
01111 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::unlink ( const char *  path  ) 

Definition at line 1114 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, and unlink().

Referenced by ACE_MEM_Acceptor::accept(), flock_destroy(), ACE_Logging_Strategy::handle_timeout(), ACE::open_temp_file(), ACE_Filecache_Object::release(), ACE_SPIPE_Acceptor::remove(), ACE_SPIPE::remove(), ACE_Mem_Map::remove(), ACE_LSOCK_Acceptor::remove(), ACE_FILE::remove(), ACE_FIFO::remove(), sema_destroy(), sema_init(), shm_unlink(), unlink(), and ACE_FILE::unlink().

01115 {
01116   ACE_OS_TRACE ("ACE_OS::unlink");
01117 # if defined (ACE_HAS_NONCONST_UNLINK)
01118   ACE_OSCALL_RETURN (::unlink (const_cast<char *> (path)), int, -1);
01119 # elif defined (ACE_HAS_WINCE)
01120   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01121   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (ACE_TEXT_CHAR_TO_TCHAR (path)), ace_result_),
01122                         int, -1);
01123 # elif defined (ACE_LACKS_UNLINK)
01124   ACE_UNUSED_ARG (path);
01125   ACE_NOTSUP_RETURN (-1);
01126 # else
01127   ACE_OSCALL_RETURN (::unlink (path), int, -1);
01128 # endif /* ACE_HAS_NONCONST_UNLINK */
01129 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::write ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte 
)

Definition at line 1150 of file OS_NS_unistd.inl.

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name(), ACE_High_Res_Timer::print_ave(), ACE_High_Res_Timer::print_total(), putmsg(), pwrite(), ACE_Filecache_Object::release(), sema_init(), sema_post(), ACE_SPIPE_Stream::send(), ACE_SOCK_IO::send(), ACE_Pipe::send(), ACE_FILE_IO::send(), ACE_FIFO_Send::send(), ACE_DEV_IO::send(), ACE::send_i(), sendfile_emulation(), write(), and write_n().

01151 {
01152   ACE_OS_TRACE ("ACE_OS::write");
01153 #if defined (ACE_WIN32)
01154   DWORD bytes_written; // This is set to 0 byte WriteFile.
01155 
01156   // Strictly correctly, we should loop writing all the data if more
01157   // than a DWORD length can hold.
01158   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01159   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0))
01160     return (ssize_t) bytes_written;
01161   else
01162     ACE_FAIL_RETURN (-1);
01163 #else
01164 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
01165   ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1);
01166 # else
01167   ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
01168 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
01169 #endif /* ACE_WIN32 */
01170 }

ACE_NAMESPACE_INLINE_FUNCTION ssize_t ACE_OS::write ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_OVERLAPPED  
)

Definition at line 1173 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and write().

01177 {
01178   ACE_OS_TRACE ("ACE_OS::write");
01179   overlapped = overlapped;
01180 #if defined (ACE_WIN32)
01181   DWORD bytes_written; // This is set to 0 byte WriteFile.
01182 
01183   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01184   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped))
01185     return (ssize_t) bytes_written;
01186   else
01187     ACE_FAIL_RETURN (-1);
01188 #else
01189   return ACE_OS::write (handle, buf, nbyte);
01190 #endif /* ACE_WIN32 */
01191 }

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

Definition at line 36 of file OS_NS_unistd.inl.

References access(), ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, fclose(), and fopen().

Referenced by access(), ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ACE::ldfind(), ACE_Configuration_Heap::open(), and open().

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

ACE_INLINE u_int ACE_OS::alarm ( u_int  secs  ) 

Definition at line 79 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and alarm().

Referenced by alarm(), and ualarm().

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

ACE_INLINE long ACE_OS::getpagesize ( void   ) 

Definition at line 91 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, getpagesize(), and sysconf().

Referenced by allocation_granularity(), getpagesize(), and ACE::round_to_pagesize().

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

ACE_INLINE long ACE_OS::allocation_granularity ( void   ) 

Definition at line 109 of file OS_NS_unistd.inl.

References getpagesize().

Referenced by ACE::round_to_allocation_granularity().

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

ACE_INLINE int ACE_OS::chdir ( const char *  path  ) 

Definition at line 122 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and chdir().

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

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

ACE_INLINE int ACE_OS::rmdir ( const char *  path  ) 

Definition at line 149 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_TEXT_CHAR_TO_TCHAR, and rmdir().

Referenced by rmdir().

00150 {
00151 #if defined (ACE_HAS_WINCE)
00152   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (ACE_TEXT_CHAR_TO_TCHAR (path)),
00153                                           ace_result_),
00154                         int, -1);
00155 #else
00156   ACE_OSCALL_RETURN (::rmdir (path), int, -1);
00157 #endif /* ACE_WIN32 */
00158 }

ACE_INLINE int ACE_OS::close ( ACE_HANDLE  handle  ) 

Definition at line 182 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and close().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Mutex::ACE_Mutex(), ACE_Active_Map_Manager< T >::close(), ACE_Strategy_Connector< SVC_HANDLER, >::close(), ACE_DEV::close(), ACE_FIFO::close(), ACE_FIFO_Recv::close(), ACE_FILE::close(), ACE_IOStream< STREAM >::close(), ACE_Log_Msg::close(), close(), ACE_SPIPE::close(), ACE_Mem_Map::close_filemapping_handle(), ACE_Mem_Map::close_handle(), ACE_Handle_Gobbler::close_remaining_handles(), closesocket(), ACE_SPIPE_Connector::connect(), ACE_SPIPE_Acceptor::create_new_instance(), ACE::daemonize(), dlopen(), event_init(), filesize(), flock_destroy(), fork_exec(), ACE_Handle_Gobbler::free_handles(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), getmacaddress(), ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_timeout(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::open(), ACE_Filecache_Object::release(), ACE_Process_Options::release_handles(), sema_destroy(), sema_init(), ACE_Process::spawn(), ACE::terminate_process(), ACE_Filecache_Handle::~ACE_Filecache_Handle(), ACE_Filecache_Object::~ACE_Filecache_Object(), ACE_Framework_Repository::~ACE_Framework_Repository(), ACE_Log_Msg::~ACE_Log_Msg(), and ACE_Process::~ACE_Process().

00183 {
00184   ACE_OS_TRACE ("ACE_OS::close");
00185 #if defined (ACE_WIN32)
00186   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1);
00187 #else
00188   ACE_OSCALL_RETURN (::close (handle), int, -1);
00189 #endif /* ACE_WIN32 */
00190 }

ACE_INLINE ACE_HANDLE ACE_OS::dup ( ACE_HANDLE  handle  ) 

Definition at line 193 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and dup().

Referenced by dup(), ACE_Filecache_Handle::handle(), ACE_Process_Options::set_handles(), and ACE_Process::spawn().

00194 {
00195   ACE_OS_TRACE ("ACE_OS::dup");
00196 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00197   ACE_HANDLE new_fd;
00198   if (::DuplicateHandle(::GetCurrentProcess (),
00199                         handle,
00200                         ::GetCurrentProcess(),
00201                         &new_fd,
00202                         0,
00203                         TRUE,
00204                         DUPLICATE_SAME_ACCESS))
00205     return new_fd;
00206   else
00207     ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00208   /* NOTREACHED */
00209 #elif defined (ACE_LACKS_DUP)
00210   ACE_UNUSED_ARG (handle);
00211   ACE_NOTSUP_RETURN (-1);
00212 #elif defined (ACE_HAS_WINCE)
00213   ACE_UNUSED_ARG (handle);
00214   ACE_NOTSUP_RETURN (0);
00215 #else
00216   ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE);
00217 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */
00218 }

ACE_INLINE int ACE_OS::dup2 ( ACE_HANDLE  oldhandle,
ACE_HANDLE  newhandle 
)

Definition at line 221 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and dup2().

Referenced by dup2(), and ACE_Process::spawn().

00222 {
00223   ACE_OS_TRACE ("ACE_OS::dup2");
00224 #if defined (ACE_LACKS_DUP2)
00225   // msvcrt has _dup2 ?!
00226   ACE_UNUSED_ARG (oldhandle);
00227   ACE_UNUSED_ARG (newhandle);
00228   ACE_NOTSUP_RETURN (-1);
00229 #else
00230   ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1);
00231 #endif /* ACE_LACKS_DUP2 */
00232 }

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

Definition at line 235 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execv().

Referenced by execv(), and fork_exec().

00237 {
00238   ACE_OS_TRACE ("ACE_OS::execv");
00239 #if defined (ACE_LACKS_EXEC)
00240   ACE_UNUSED_ARG (path);
00241   ACE_UNUSED_ARG (argv);
00242 
00243   ACE_NOTSUP_RETURN (-1);
00244 #elif defined (ACE_WIN32)
00245 # if defined (__BORLANDC__) /* VSB */
00246   return ::execv (path, argv);
00247 # elif defined (__MINGW32__)
00248   return ::_execv (path, (char *const *) argv);
00249 # else
00250   // Why this odd-looking code? If execv() returns at all, it's an error.
00251   // Windows defines this as returning an intptr_t rather than a simple int,
00252   // and the conversion triggers compile warnings. So just return -1 if
00253   // the call returns.
00254   ::_execv (path, (const char *const *) argv);
00255   return -1;
00256 # endif /* __BORLANDC__ */
00257 #else
00258   ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00259 #endif /* ACE_LACKS_EXEC */
00260 }

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

Definition at line 263 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execve().

Referenced by execve(), and ACE_Process::spawn().

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

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

Definition at line 293 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execvp().

Referenced by execvp(), and ACE_Process::spawn().

00295 {
00296   ACE_OS_TRACE ("ACE_OS::execvp");
00297 #if defined (ACE_LACKS_EXEC)
00298   ACE_UNUSED_ARG (file);
00299   ACE_UNUSED_ARG (argv);
00300 
00301   ACE_NOTSUP_RETURN (-1);
00302 #elif defined (ACE_WIN32)
00303 # if defined (__BORLANDC__) /* VSB */
00304   return ::execvp (file, argv);
00305 # elif defined (__MINGW32__)
00306   return ::_execvp (file, (char *const *) argv);
00307 # else
00308   // Why this odd-looking code? If execv() returns at all, it's an error.
00309   // Windows defines this as returning an intptr_t rather than a simple int,
00310   // and the conversion triggers compile warnings. So just return -1 if
00311   // the call returns.
00312   ::_execvp (file, (const char *const *) argv);
00313   return -1;
00314 # endif /* __BORLANDC__ */
00315 #else
00316   ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00317 #endif /* ACE_LACKS_EXEC */
00318 }

ACE_INLINE pid_t ACE_OS::fork ( void   ) 

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

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fork().

00322 {
00323   ACE_OS_TRACE ("ACE_OS::fork");
00324 #if defined (ACE_LACKS_FORK)
00325   ACE_NOTSUP_RETURN (pid_t (-1));
00326 #else
00327   ACE_OSCALL_RETURN (::fork (), pid_t, -1);
00328 #endif /* ACE_LACKS_FORK */
00329 }

ACE_INLINE int ACE_OS::fsync ( ACE_HANDLE  handle  ) 

Definition at line 332 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fsync().

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name(), fstat(), fsync(), and mmap().

00333 {
00334   ACE_OS_TRACE ("ACE_OS::fsync");
00335 # if defined (ACE_LACKS_FSYNC)
00336   ACE_UNUSED_ARG (handle);
00337   ACE_NOTSUP_RETURN (-1);
00338 # elif defined (ACE_WIN32)
00339   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushFileBuffers (handle), ace_result_), int, -1);
00340 # else
00341   ACE_OSCALL_RETURN (::fsync (handle), int, -1);
00342 # endif /* ACE_LACKS_FSYNC */
00343 }

ACE_INLINE int ACE_OS::ftruncate ( ACE_HANDLE  handle,
ACE_OFF_T  offset 
)

Definition at line 346 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and ftruncate().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ftruncate(), ACE_Mem_Map::remove(), sema_init(), and ACE_FILE::truncate().

00347 {
00348   ACE_OS_TRACE ("ACE_OS::ftruncate");
00349 #if defined (ACE_WIN32)
00350 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
00351   LARGE_INTEGER loff;
00352   loff.QuadPart = offset;
00353   if (::SetFilePointerEx (handle, loff, 0, FILE_BEGIN))
00354 #  else
00355   if (::SetFilePointer (handle,
00356                         offset,
00357                         0,
00358                         FILE_BEGIN) != INVALID_SET_FILE_POINTER)
00359 #  endif
00360     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
00361   else
00362     ACE_FAIL_RETURN (-1);
00363 #else
00364   ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1);
00365 #endif /* ACE_WIN32 */
00366 }

ACE_INLINE char* ACE_OS::getcwd ( char *  buf,
size_t  size 
)

Definition at line 369 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getcwd().

Referenced by getcwd().

00370 {
00371   ACE_OS_TRACE ("ACE_OS::getcwd");
00372 #if defined (ACE_LACKS_GETCWD)
00373   ACE_UNUSED_ARG (buf);
00374   ACE_UNUSED_ARG (size);
00375   ACE_NOTSUP_RETURN (0);
00376 #elif defined (ACE_WIN32)
00377   return ::getcwd (buf, static_cast<int> (size));
00378 #else
00379   ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0);
00380 #endif /* ACE_LACKS_GETCWD */
00381 }

ACE_INLINE gid_t ACE_OS::getgid ( void   ) 

Definition at line 407 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getgid().

Referenced by getgid(), and ACE_SPIPE_Addr::set().

00408 {
00409   ACE_OS_TRACE ("ACE_OS::getgid");
00410 #if defined (ACE_LACKS_GETGID)
00411   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00412 # else
00413   ACE_OSCALL_RETURN (::getgid (), gid_t, static_cast<gid_t> (-1));
00414 # endif /* ACE_LACKS_GETGID */
00415 }

ACE_INLINE gid_t ACE_OS::getegid ( void   ) 

Definition at line 418 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getegid().

Referenced by getegid().

00419 {
00420   ACE_OS_TRACE ("ACE_OS::getegid");
00421 #if defined (ACE_LACKS_GETEGID)
00422   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00423 # else
00424   ACE_OSCALL_RETURN (::getegid (), gid_t, static_cast<gid_t> (-1));
00425 # endif /* ACE_LACKS_GETEGID */
00426 }

ACE_INLINE int ACE_OS::getopt ( int  argc,
char *const *  argv,
const char *  optstring 
)

Definition at line 429 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getopt().

Referenced by getopt(), ACE_Service_Manager::init(), ACE_Service_Config::parse_args_i(), and ACE_Service_Gestalt::parse_args_i().

00430 {
00431   ACE_OS_TRACE ("ACE_OS::getopt");
00432 #if defined (ACE_LACKS_GETOPT)
00433   ACE_UNUSED_ARG (argc);
00434   ACE_UNUSED_ARG (argv);
00435   ACE_UNUSED_ARG (optstring);
00436   ACE_NOTSUP_RETURN (-1);
00437 # else
00438   ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1);
00439 # endif /* ACE_LACKS_GETOPT */
00440 }

ACE_INLINE pid_t ACE_OS::getpgid ( pid_t  pid  ) 

Definition at line 443 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getpgid().

Referenced by getpgid().

00444 {
00445   ACE_OS_TRACE ("ACE_OS::getpgid");
00446 #if defined (ACE_LACKS_GETPGID)
00447   ACE_UNUSED_ARG (pid);
00448   ACE_NOTSUP_RETURN (-1);
00449 #elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0
00450   // getpgid() is from SVR4, which appears to be the reason why GLIBC
00451   // doesn't enable its prototype by default.
00452   // Rather than create our own extern prototype, just use the one
00453   // that is visible (ugh).
00454   ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1);
00455 #else
00456   ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1);
00457 #endif /* ACE_LACKS_GETPGID */
00458 }

ACE_INLINE pid_t ACE_OS::getpid ( void   ) 

Definition at line 461 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and getpid().

Referenced by ACE_IO_SAP::enable(), ACE_IPC_SAP::enable(), ACE_Utils::UUID_Generator::generate_UUID(), ACE_Log_Msg::getpid(), getpid(), ACE_Service_Config::open_i(), ACE_SPIPE_Stream::recv_handle(), ACE_Log_Msg::sync(), and unique_name().

00462 {
00463   // ACE_OS_TRACE ("ACE_OS::getpid");
00464 #if defined (ACE_LACKS_GETPID)
00465   ACE_NOTSUP_RETURN (-1);
00466 #elif defined (ACE_WIN32)
00467   return ::GetCurrentProcessId ();
00468 #else
00469   ACE_OSCALL_RETURN (::getpid (), int, -1);
00470 #endif /* ACE_LACKS_GETPID */
00471 }

ACE_INLINE pid_t ACE_OS::getppid ( void   ) 

Definition at line 474 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getppid().

Referenced by getppid(), and ACE_Process::spawn().

00475 {
00476   ACE_OS_TRACE ("ACE_OS::getppid");
00477 #if defined (ACE_LACKS_GETPPID)
00478   ACE_NOTSUP_RETURN (-1);
00479 #else
00480   ACE_OSCALL_RETURN (::getppid (), pid_t, -1);
00481 #endif /* ACE_LACKS_GETPPID */
00482 }

ACE_INLINE uid_t ACE_OS::getuid ( void   ) 

Definition at line 485 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getuid().

Referenced by getuid(), and ACE_SPIPE_Addr::set().

00486 {
00487   ACE_OS_TRACE ("ACE_OS::getuid");
00488 #if defined (ACE_LACKS_GETUID)
00489   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00490 # else
00491   ACE_OSCALL_RETURN (::getuid (), uid_t, static_cast<uid_t> (-1));
00492 # endif /* ACE_LACKS_GETUID*/
00493 }

ACE_INLINE uid_t ACE_OS::geteuid ( void   ) 

Definition at line 496 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and geteuid().

Referenced by cuserid(), and geteuid().

00497 {
00498   ACE_OS_TRACE ("ACE_OS::geteuid");
00499 #if defined (ACE_LACKS_GETEUID)
00500   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00501 # else
00502   ACE_OSCALL_RETURN (::geteuid (), uid_t, (uid_t) -1);
00503 # endif /* ACE_LACKS_GETEUID */
00504 }

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

Definition at line 507 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, strsncpy(), and uname().

00508 {
00509   ACE_OS_TRACE ("ACE_OS::hostname");
00510 #if defined (ACE_HAS_PHARLAP)
00511   // PharLap only can do net stuff with the RT version.
00512 #   if defined (ACE_HAS_PHARLAP_RT)
00513   // @@This is not at all reliable... requires ethernet and BOOTP to be used.
00514   // A more reliable way is to go thru the devices w/ EtsTCPGetDeviceCfg until
00515   // a legit IP address is found, then get its name w/ gethostbyaddr.
00516   ACE_SOCKCALL_RETURN (gethostname (name, maxnamelen), int, SOCKET_ERROR);
00517 #   else
00518   ACE_UNUSED_ARG (name);
00519   ACE_UNUSED_ARG (maxnamelen);
00520   ACE_NOTSUP_RETURN (-1);
00521 #   endif /* ACE_HAS_PHARLAP_RT */
00522 #elif defined (ACE_VXWORKS) || defined (ACE_HAS_WINCE)
00523   ACE_OSCALL_RETURN (::gethostname (name, maxnamelen), int, -1);
00524 #elif defined (ACE_WIN32)
00525   if (::gethostname (name, ACE_Utils::truncate_cast<int> (maxnamelen)) == 0)
00526   {
00527     return 0;
00528   }
00529   else
00530   {
00531     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name,
00532                                             LPDWORD (&maxnamelen)),
00533                                             ace_result_), int, -1);
00534   }
00535 #else /* ACE_HAS_PHARLAP */
00536   ACE_utsname host_info;
00537 
00538   if (ACE_OS::uname (&host_info) == -1)
00539     return -1;
00540   else
00541     {
00542       ACE_OS::strsncpy (name, host_info.nodename, maxnamelen);
00543       return 0;
00544     }
00545 #endif /* ACE_HAS_PHARLAP */
00546 }

ACE_INLINE int ACE_OS::isatty ( int  handle  ) 

Definition at line 573 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and isatty().

Referenced by isatty().

00574 {
00575   ACE_OS_TRACE ("ACE_OS::isatty");
00576 #if defined (ACE_LACKS_ISATTY)
00577   ACE_UNUSED_ARG (handle);
00578   return 0;
00579 # elif defined (ACE_WIN32)
00580   return ::_isatty (handle);
00581 # else
00582   ACE_OSCALL_RETURN (::isatty (handle), int, -1);
00583 # endif /* ACE_LACKS_ISATTY */
00584 }

ACE_INLINE ACE_OFF_T ACE_OS::lseek ( ACE_HANDLE  handle,
ACE_OFF_T  offset,
int  whence 
)

Definition at line 604 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and lseek().

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

00605 {
00606   ACE_OS_TRACE ("ACE_OS::lseek");
00607 #if defined (ACE_WIN32)
00608 # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00609   //#error Windows NT is evil AND rude!
00610   switch (whence)
00611     {
00612     case SEEK_SET:
00613       whence = FILE_BEGIN;
00614       break;
00615     case SEEK_CUR:
00616       whence = FILE_CURRENT;
00617       break;
00618     case SEEK_END:
00619       whence = FILE_END;
00620       break;
00621     default:
00622       errno = EINVAL;
00623       return static_cast<ACE_OFF_T> (-1); // rather safe than sorry
00624     }
00625 # endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00626   LONG low_offset = ACE_LOW_PART(offset);
00627   LONG high_offset = ACE_HIGH_PART(offset);
00628   DWORD const result =
00629     ::SetFilePointer (handle, low_offset, &high_offset, whence);
00630   if (result == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
00631     ACE_FAIL_RETURN (static_cast<ACE_OFF_T> (-1));
00632   else
00633     return result;
00634 #else
00635   ACE_OSCALL_RETURN (::lseek (handle, offset, whence), ACE_OFF_T, -1);
00636 #endif /* ACE_WIN32 */
00637 }

ACE_INLINE ssize_t ACE_OS::read ( ACE_HANDLE  handle,
void *  buf,
size_t  len 
)

Definition at line 687 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and read().

00688 {
00689   ACE_OS_TRACE ("ACE_OS::read");
00690 #if defined (ACE_WIN32)
00691   DWORD ok_len;
00692   if (::ReadFile (handle, buf, static_cast<DWORD> (len), &ok_len, 0))
00693     return (ssize_t) ok_len;
00694   else
00695     ACE_FAIL_RETURN (-1);
00696 #else
00697 
00698   ssize_t result;
00699 
00700 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
00701   ACE_OSCALL (::read (handle, static_cast <char *> (buf), len), ssize_t, -1, result);
00702 # else
00703   ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result);
00704 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
00705 
00706 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00707   // Optimize this code out if we can detect that EAGAIN ==
00708   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00709   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00710   // macros) perform the check at run-time.  The goal is to avoid two
00711   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00712   if (result == -1
00713 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00714       && EAGAIN != EWOULDBLOCK
00715 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00716       && errno == EAGAIN)
00717     {
00718       errno = EWOULDBLOCK;
00719     }
00720 # endif /* EAGAIN != EWOULDBLOCK*/
00721 
00722   return result;
00723 #endif /* ACE_WIN32 */
00724 }

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

Definition at line 727 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and read().

00729 {
00730   ACE_OS_TRACE ("ACE_OS::read");
00731   overlapped = overlapped;
00732 #if defined (ACE_WIN32)
00733   DWORD ok_len;
00734   DWORD short_len = static_cast<DWORD> (len);
00735   if (::ReadFile (handle, buf, short_len, &ok_len, overlapped))
00736     return (ssize_t) ok_len;
00737   else
00738     ACE_FAIL_RETURN (-1);
00739 #else
00740   return ACE_OS::read (handle, buf, len);
00741 #endif /* ACE_WIN32 */
00742 }

ACE_INLINE ssize_t ACE_OS::readlink ( const char *  path,
char *  buf,
size_t  bufsiz 
)

Definition at line 745 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and readlink().

Referenced by readlink().

00746 {
00747   ACE_OS_TRACE ("ACE_OS::readlink");
00748 # if defined (ACE_LACKS_READLINK)
00749   ACE_UNUSED_ARG (path);
00750   ACE_UNUSED_ARG (buf);
00751   ACE_UNUSED_ARG (bufsiz);
00752   ACE_NOTSUP_RETURN (-1);
00753 # else
00754 #   if !defined(ACE_HAS_NONCONST_READLINK)
00755       ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), ssize_t, -1);
00756 #   else
00757       ACE_OSCALL_RETURN (
00758         ::readlink (const_cast <char *>(path), buf, bufsiz), ssize_t, -1);
00759 #   endif
00760 # endif /* ACE_LACKS_READLINK */
00761 }

ACE_INLINE int ACE_OS::pipe ( ACE_HANDLE  fds[]  ) 

Definition at line 764 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and pipe().

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

00765 {
00766   ACE_OS_TRACE ("ACE_OS::pipe");
00767 # if defined (ACE_LACKS_PIPE)
00768   ACE_UNUSED_ARG (fds);
00769   ACE_NOTSUP_RETURN (-1);
00770 # elif defined (ACE_WIN32)
00771   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL
00772                         (::CreatePipe (&fds[0], &fds[1], 0, 0),
00773                          ace_result_), int, -1);
00774 # else
00775   ACE_OSCALL_RETURN (::pipe (fds), int, -1);
00776 # endif /* ACE_LACKS_PIPE */
00777 }

ACE_INLINE void* ACE_OS::sbrk ( intptr_t  brk  ) 

Definition at line 780 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and sbrk().

Referenced by ACE_Sbrk_Memory_Pool::acquire(), and sbrk().

00781 {
00782 #if defined (ACE_LACKS_SBRK)
00783   ACE_UNUSED_ARG (brk);
00784   ACE_NOTSUP_RETURN (0);
00785 #else
00786   ACE_OSCALL_RETURN (::sbrk (brk), void *, 0);
00787 #endif /* ACE_LACKS_SBRK */
00788 }

ACE_INLINE int ACE_OS::setgid ( gid_t  gid  ) 

Definition at line 791 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setgid().

Referenced by setgid().

00792 {
00793   ACE_OS_TRACE ("ACE_OS::setgid");
00794 #if defined (ACE_LACKS_SETGID)
00795   ACE_UNUSED_ARG (gid);
00796   ACE_NOTSUP_RETURN (-1);
00797 # else
00798   ACE_OSCALL_RETURN (::setgid (gid), int,  -1);
00799 # endif /* ACE_LACKS_SETGID */
00800 }

ACE_INLINE int ACE_OS::setegid ( gid_t  gid  ) 

Definition at line 803 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setegid().

Referenced by setegid().

00804 {
00805   ACE_OS_TRACE ("ACE_OS::setegid");
00806 #if defined (ACE_LACKS_SETEGID)
00807   ACE_UNUSED_ARG (gid);
00808   ACE_NOTSUP_RETURN (-1);
00809 # else
00810   ACE_OSCALL_RETURN (::setegid (gid), int,  -1);
00811 # endif /* ACE_LACKS_SETEGID */
00812 }

ACE_INLINE int ACE_OS::setpgid ( pid_t  pid,
pid_t  pgid 
)

Definition at line 815 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setpgid().

Referenced by setpgid(), and ACE_Process::spawn().

00816 {
00817   ACE_OS_TRACE ("ACE_OS::setpgid");
00818 #if defined (ACE_LACKS_SETPGID)
00819   ACE_UNUSED_ARG (pid);
00820   ACE_UNUSED_ARG (pgid);
00821   ACE_NOTSUP_RETURN (-1);
00822 #else
00823   ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1);
00824 #endif /* ACE_LACKS_SETPGID */
00825 }

ACE_INLINE int ACE_OS::setregid ( gid_t  rgid,
gid_t  egid 
)

Definition at line 828 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setregid().

Referenced by setregid(), and ACE_Process::spawn().

00829 {
00830   ACE_OS_TRACE ("ACE_OS::setregid");
00831 #if defined (ACE_LACKS_SETREGID)
00832   ACE_UNUSED_ARG (rgid);
00833   ACE_UNUSED_ARG (egid);
00834   ACE_NOTSUP_RETURN (-1);
00835 #else
00836   ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1);
00837 #endif /* ACE_LACKS_SETREGID */
00838 }

ACE_INLINE int ACE_OS::setreuid ( uid_t  ruid,
uid_t  euid 
)

Definition at line 841 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setreuid().

Referenced by setreuid(), and ACE_Process::spawn().

00842 {
00843   ACE_OS_TRACE ("ACE_OS::setreuid");
00844 #if defined (ACE_LACKS_SETREUID)
00845   ACE_UNUSED_ARG (ruid);
00846   ACE_UNUSED_ARG (euid);
00847   ACE_NOTSUP_RETURN (-1);
00848 #else
00849   ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1);
00850 #endif /* ACE_LACKS_SETREUID */
00851 }

ACE_INLINE pid_t ACE_OS::setsid ( void   ) 

Definition at line 854 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setsid().

Referenced by ACE::daemonize(), and setsid().

00855 {
00856   ACE_OS_TRACE ("ACE_OS::setsid");
00857 #if defined (ACE_LACKS_SETSID)
00858   ACE_NOTSUP_RETURN (-1);
00859 #else
00860   ACE_OSCALL_RETURN (::setsid (), int, -1);
00861 # endif /* ACE_LACKS_SETSID */
00862 }

ACE_INLINE int ACE_OS::setuid ( uid_t  uid  ) 

Definition at line 865 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setuid().

Referenced by setuid().

00866 {
00867   ACE_OS_TRACE ("ACE_OS::setuid");
00868 #if defined (ACE_LACKS_SETUID)
00869   ACE_UNUSED_ARG (uid);
00870   ACE_NOTSUP_RETURN (-1);
00871 # else
00872   ACE_OSCALL_RETURN (::setuid (uid), int,  -1);
00873 # endif /* ACE_LACKS_SETUID */
00874 }

ACE_INLINE int ACE_OS::seteuid ( uid_t  uid  ) 

Definition at line 877 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and seteuid().

Referenced by seteuid().

00878 {
00879   ACE_OS_TRACE ("ACE_OS::seteuid");
00880 #if defined (ACE_LACKS_SETEUID)
00881   ACE_UNUSED_ARG (uid);
00882   ACE_NOTSUP_RETURN (-1);
00883 # else
00884   ACE_OSCALL_RETURN (::seteuid (uid), int,  -1);
00885 # endif /* ACE_LACKS_SETEUID */
00886 }

ACE_INLINE int ACE_OS::sleep ( u_int  seconds  ) 

Definition at line 889 of file OS_NS_unistd.inl.

References ACE_ONE_SECOND_IN_MSECS, ACE_OS_TRACE, nanosleep(), sleep(), timespec::tv_nsec, and timespec::tv_sec.

00890 {
00891   ACE_OS_TRACE ("ACE_OS::sleep");
00892 #if defined (ACE_WIN32)
00893   ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
00894   return 0;
00895 #elif defined (ACE_HAS_CLOCK_GETTIME)
00896   struct timespec rqtp;
00897   // Initializer doesn't work with Green Hills 1.8.7
00898   rqtp.tv_sec = seconds;
00899   rqtp.tv_nsec = 0L;
00900   //FUZZ: disable check_for_lack_ACE_OS
00901   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00902   //FUZZ: enable check_for_lack_ACE_OS
00903 #else
00904   ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
00905 #endif /* ACE_WIN32 */
00906 }

ACE_INLINE int ACE_OS::sleep ( const ACE_Time_Value tv  ) 

Definition at line 909 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, ACE_Time_Value::msec(), nanosleep(), and select().

00910 {
00911   ACE_OS_TRACE ("ACE_OS::sleep");
00912 #if defined (ACE_WIN32)
00913   ::Sleep (tv.msec ());
00914   return 0;
00915 #elif defined (ACE_HAS_CLOCK_GETTIME)
00916   timespec_t rqtp = tv;
00917   //FUZZ: disable check_for_lack_ACE_OS
00918   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00919   //FUZZ: enable check_for_lack_ACE_OS
00920 #else
00921 # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00922   // Copy the timeval, because this platform doesn't declare the timeval
00923   // as a pointer to const.
00924   timeval tv_copy = tv;
00925 #  if defined(ACE_TANDEM_T1248_PTHREADS)
00926      ACE_OSCALL_RETURN (::spt_select (0, 0, 0, 0, &tv_copy), int, -1);
00927 #  else
00928      //FUZZ: disable check_for_lack_ACE_OS
00929      ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1);
00930      //FUZZ: enable check_for_lack_ACE_OS
00931 #  endif
00932 # else  /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */
00933   const timeval *tvp = tv;
00934   //FUZZ: disable check_for_lack_ACE_OS
00935   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1);
00936   //FUZZ: enable check_for_lack_ACE_OS
00937 # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00938 #endif /* ACE_WIN32 */
00939 }

ACE_INLINE void ACE_OS::swab ( const void *  src,
void *  dest,
ssize_t  length 
)

Definition at line 942 of file OS_NS_unistd.inl.

References swab().

Referenced by swab().

00945 {
00946 #if defined (ACE_LACKS_SWAB)
00947   // ------------------------------------------------------------
00948   // The following copyright notice applies to the swab()
00949   // implementation within this "ACE_LACKS_SWAB" block of code.
00950   // ------------------------------------------------------------
00951   /*
00952     Copyright (c) 1994-2006  Red Hat, Inc. All rights reserved.
00953 
00954     This copyrighted material is made available to anyone wishing to
00955     use, modify, copy, or redistribute it subject to the terms and
00956     conditions of the BSD License.   This program is distributed in
00957     the hope that it will be useful, but WITHOUT ANY WARRANTY
00958     expressed or implied, including the implied warranties of
00959     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  A copy of
00960     this license is available at
00961     http://www.opensource.org/licenses. Any Red Hat trademarks that
00962     are incorporated in the source code or documentation are not
00963     subject to the BSD License and may only be used or replicated with
00964     the express permission of Red Hat, Inc.
00965   */
00966 
00967   const char *from = static_cast<const char*> (src);
00968   char *to = static_cast<char *> (dest);
00969   ssize_t ptr = 0;
00970   for (ptr = 1; ptr < length; ptr += 2)
00971     {
00972       char p = from[ptr];
00973       char q = from[ptr-1];
00974       to[ptr-1] = p;
00975       to[ptr  ] = q;
00976     }
00977   if (ptr == length) /* I.e., if length is odd, */
00978     to[ptr-1] = 0;   /* then pad with a NUL. */
00979 #elif defined (ACE_HAS_NONCONST_SWAB)
00980   const char *tmp = static_cast<const char*> (src);
00981   char *from = const_cast<char *> (tmp);
00982   char *to = static_cast<char *> (dest);
00983   ::swab (from, to, length);
00984 #elif defined (ACE_HAS_CONST_CHAR_SWAB)
00985   const char *from = static_cast<const char*> (src);
00986   char *to = static_cast<char *> (dest);
00987   ::swab (from, to, length);
00988 #else
00989   ::swab (src, dest, length);
00990 #endif /* ACE_LACKS_SWAB */
00991 
00992 }

ACE_INLINE long ACE_OS::sysconf ( int  name  ) 

Definition at line 995 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysconf().

Referenced by getpagesize(), ACE::max_handles(), num_processors(), num_processors_online(), sysconf(), and thr_min_stack().

00996 {
00997   ACE_OS_TRACE ("ACE_OS::sysconf");
00998 #if defined (ACE_LACKS_SYSCONF)
00999   ACE_UNUSED_ARG (name);
01000   ACE_NOTSUP_RETURN (-1);
01001 #else
01002   ACE_OSCALL_RETURN (::sysconf (name), long, -1);
01003 #endif /* ACE_LACKS_SYSCONF */
01004 }

ACE_INLINE long ACE_OS::sysinfo ( int  cmd,
char *  buf,
long  count 
)

Definition at line 1007 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysinfo().

Referenced by sysinfo().

01008 {
01009   ACE_OS_TRACE ("ACE_OS::sysinfo");
01010 #if defined (ACE_HAS_SYSINFO)
01011   ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1);
01012 #else
01013   ACE_UNUSED_ARG (cmd);
01014   ACE_UNUSED_ARG (buf);
01015   ACE_UNUSED_ARG (count);
01016 
01017   ACE_NOTSUP_RETURN (0);
01018 #endif /* ACE_HAS_SYSINFO */
01019 }

ACE_INLINE int ACE_OS::truncate ( const ACE_TCHAR filename,
ACE_OFF_T  offset 
)

Definition at line 1022 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_DEFAULT_FILE_PERMS, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_ALWAYS_CHAR, open(), and truncate().

Referenced by truncate().

01024 {
01025   ACE_OS_TRACE ("ACE_OS::truncate");
01026 #if defined (ACE_WIN32)
01027   ACE_HANDLE handle = ACE_OS::open (filename,
01028                                     O_WRONLY,
01029                                     ACE_DEFAULT_FILE_PERMS);
01030 
01031 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01032   LARGE_INTEGER loffset;
01033   loffset.QuadPart = offset;
01034 #else
01035   LONG low_offset = ACE_LOW_PART(offset);
01036   LONG high_offset = ACE_HIGH_PART(offset);
01037 #endif
01038 
01039   if (handle == ACE_INVALID_HANDLE)
01040     ACE_FAIL_RETURN (-1);
01041 
01042 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01043   else if (::SetFilePointerEx (handle,
01044                                loffset,
01045                                0,
01046                                FILE_BEGIN))
01047 #  else
01048   else if (::SetFilePointer (handle,
01049                              low_offset,
01050                              &high_offset,
01051                              FILE_BEGIN) != INVALID_SET_FILE_POINTER
01052            || GetLastError () == NO_ERROR)
01053 #  endif /* ACE_LACKS_WIN32_SETFILEPOINTEREX */
01054     {
01055       BOOL result = ::SetEndOfFile (handle);
01056       ::CloseHandle (handle);
01057       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1);
01058     }
01059   else
01060     {
01061       ::CloseHandle (handle);
01062       ACE_FAIL_RETURN (-1);
01063     }
01064   /* NOTREACHED */
01065 #elif !defined (ACE_LACKS_TRUNCATE)
01066   ACE_OSCALL_RETURN
01067     (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1);
01068 #else
01069   ACE_UNUSED_ARG (filename);
01070   ACE_UNUSED_ARG (offset);
01071   ACE_NOTSUP_RETURN (-1);
01072 #endif /* ACE_WIN32 */
01073 }

ACE_INLINE useconds_t ACE_OS::ualarm ( useconds_t  usecs,
useconds_t  interval 
)

Definition at line 1076 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, alarm(), and ualarm().

01077 {
01078   ACE_OS_TRACE ("ACE_OS::ualarm");
01079 
01080 #if defined (ACE_HAS_UALARM)
01081   return ::ualarm (usecs, interval);
01082 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01083   ACE_UNUSED_ARG (interval);
01084   return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS);
01085 #else
01086   ACE_UNUSED_ARG (usecs);
01087   ACE_UNUSED_ARG (interval);
01088   ACE_NOTSUP_RETURN (0);
01089 #endif /* ACE_HAS_UALARM */
01090 }

ACE_INLINE useconds_t ACE_OS::ualarm ( const ACE_Time_Value tv,
const ACE_Time_Value tv_interval 
)

Definition at line 1093 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, alarm(), ACE_Time_Value::sec(), ualarm(), and ACE_Time_Value::usec().

01095 {
01096   ACE_OS_TRACE ("ACE_OS::ualarm");
01097 
01098 #if defined (ACE_HAS_UALARM)
01099   useconds_t usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec ();
01100   useconds_t interval =
01101     (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec ();
01102   return ::ualarm (usecs, interval);
01103 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01104   ACE_UNUSED_ARG (tv_interval);
01105   return ::alarm (tv.sec ());
01106 #else
01107   ACE_UNUSED_ARG (tv_interval);
01108   ACE_UNUSED_ARG (tv);
01109   ACE_NOTSUP_RETURN (0);
01110 #endif /* ACE_HAS_UALARM */
01111 }

ACE_INLINE int ACE_OS::unlink ( const char *  path  ) 

Definition at line 1114 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, and unlink().

Referenced by ACE_MEM_Acceptor::accept(), flock_destroy(), ACE_Logging_Strategy::handle_timeout(), ACE::open_temp_file(), ACE_Filecache_Object::release(), ACE_FIFO::remove(), ACE_FILE::remove(), ACE_LSOCK_Acceptor::remove(), ACE_Mem_Map::remove(), ACE_SPIPE::remove(), ACE_SPIPE_Acceptor::remove(), sema_destroy(), sema_init(), shm_unlink(), ACE_FILE::unlink(), and unlink().

01115 {
01116   ACE_OS_TRACE ("ACE_OS::unlink");
01117 # if defined (ACE_HAS_NONCONST_UNLINK)
01118   ACE_OSCALL_RETURN (::unlink (const_cast<char *> (path)), int, -1);
01119 # elif defined (ACE_HAS_WINCE)
01120   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01121   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (ACE_TEXT_CHAR_TO_TCHAR (path)), ace_result_),
01122                         int, -1);
01123 # elif defined (ACE_LACKS_UNLINK)
01124   ACE_UNUSED_ARG (path);
01125   ACE_NOTSUP_RETURN (-1);
01126 # else
01127   ACE_OSCALL_RETURN (::unlink (path), int, -1);
01128 # endif /* ACE_HAS_NONCONST_UNLINK */
01129 }

ACE_INLINE ssize_t ACE_OS::write ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte 
)

Definition at line 1150 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and write().

01151 {
01152   ACE_OS_TRACE ("ACE_OS::write");
01153 #if defined (ACE_WIN32)
01154   DWORD bytes_written; // This is set to 0 byte WriteFile.
01155 
01156   // Strictly correctly, we should loop writing all the data if more
01157   // than a DWORD length can hold.
01158   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01159   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0))
01160     return (ssize_t) bytes_written;
01161   else
01162     ACE_FAIL_RETURN (-1);
01163 #else
01164 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
01165   ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1);
01166 # else
01167   ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
01168 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
01169 #endif /* ACE_WIN32 */
01170 }

ACE_INLINE ssize_t ACE_OS::write ( ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_OVERLAPPED overlapped 
)

Definition at line 1173 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and write().

01177 {
01178   ACE_OS_TRACE ("ACE_OS::write");
01179   overlapped = overlapped;
01180 #if defined (ACE_WIN32)
01181   DWORD bytes_written; // This is set to 0 byte WriteFile.
01182 
01183   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01184   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped))
01185     return (ssize_t) bytes_written;
01186   else
01187     ACE_FAIL_RETURN (-1);
01188 #else
01189   return ACE_OS::write (handle, buf, nbyte);
01190 #endif /* ACE_WIN32 */
01191 }

ACE_Export int ACE_OS::wcscmp_emulation ( const ACE_WCHAR_T *  string1,
const ACE_WCHAR_T *  string2 
)

Emulated wcscmp - Compares strings.

Definition at line 82 of file OS_NS_wchar.cpp.

Referenced by strcmp().

00084 {
00085   while (*string1 == *string2++)
00086     if (*string1++ == 0)
00087       return (0);
00088   return (*string1 - *--string2);
00089 }

ACE_Export size_t ACE_OS::wcslen_emulation ( const ACE_WCHAR_T *  string  ) 

Emulated wcslen - Returns the length of a string.

Definition at line 158 of file OS_NS_wchar.cpp.

References ACE_WCHAR_T.

Referenced by strlen().

00159 {
00160   const ACE_WCHAR_T *s;
00161 
00162   for (s = string; *s; ++s)
00163     continue;
00164 
00165   return s - string;
00166 }

ACE_Export ACE_WCHAR_T * ACE_OS::wcsncat_emulation ( ACE_WCHAR_T *  destination,
const ACE_WCHAR_T *  source,
size_t  count 
)

Emulated wcscat - Appends a string.

Definition at line 171 of file OS_NS_wchar.cpp.

References ACE_WCHAR_T.

Referenced by strncat().

00174 {
00175   if (count != 0)
00176     {
00177       ACE_WCHAR_T *d = destination;
00178       const ACE_WCHAR_T *s = source;
00179 
00180       while (*d != 0)
00181         d++;
00182 
00183       do
00184         {
00185           if ((*d = *s++) == 0)
00186             break;
00187 
00188           d++;
00189         } while (--count != 0);
00190 
00191       *d = 0;
00192     }
00193 
00194   return destination;
00195 }

ACE_Export int ACE_OS::wcsncmp_emulation ( const ACE_WCHAR_T *  s1,
const ACE_WCHAR_T *  s2,
size_t  len 
)

Emulated wcsncmp - Compares two arrays.

Definition at line 200 of file OS_NS_wchar.cpp.

Referenced by strncmp().

00203 {
00204   if (len == 0)
00205     return 0;
00206 
00207   do
00208     {
00209       if (*s1 != *s2++)
00210         return (*s1 - *--s2);
00211       if (*s1++ == 0)
00212         break;
00213     } while (--len != 0);
00214 
00215   return 0;
00216 }

ACE_Export ACE_WCHAR_T * ACE_OS::wcsncpy_emulation ( ACE_WCHAR_T *  destination,
const ACE_WCHAR_T *  source,
size_t  len 
)

Emulated wcsncpy - Copies an array.

Definition at line 221 of file OS_NS_wchar.cpp.

References ACE_WCHAR_T.

Referenced by strncpy().

00224 {
00225   if (len != 0)
00226     {
00227       ACE_WCHAR_T *d = destination;
00228       const ACE_WCHAR_T *s = source;
00229 
00230       do
00231         {
00232           if ((*d++ = *s++) == 0)
00233             {
00234               // NUL pad the remaining n-1 bytes
00235               while (--len != 0)
00236                 *d++ = 0;
00237               break;
00238             }
00239         } while (--len != 0);
00240     }
00241 
00242   return destination;
00243 }

ACE_NAMESPACE_INLINE_FUNCTION u_int ACE_OS::wslen ( const WChar  ) 

Definition at line 21 of file OS_NS_wchar.inl.

Referenced by ACE_Log_Msg::log().

00022 {
00023   u_int len = 0;
00024 
00025   while (*s++ != 0)
00026     len++;
00027 
00028   return len;
00029 }

ACE_NAMESPACE_INLINE_FUNCTION WChar* ACE_OS::wscpy ( WChar ,
const WChar  
)

Definition at line 32 of file OS_NS_wchar.inl.

00033 {
00034   WChar *original_dest = dest;
00035 
00036   while ((*dest++ = *src++) != 0)
00037     continue;
00038 
00039   return original_dest;
00040 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::wscmp ( const WChar ,
const WChar  
)

Definition at line 43 of file OS_NS_wchar.inl.

00044 {
00045   const WChar *scan1 = s;
00046   const WChar *scan2 = t;
00047 
00048   while (*scan1 != 0 && *scan1 == *scan2)
00049     {
00050       ++scan1;
00051       ++scan2;
00052     }
00053 
00054   return *scan1 - *scan2;
00055 }

ACE_NAMESPACE_INLINE_FUNCTION int ACE_OS::wsncmp ( const WChar ,
const WChar ,
size_t  len 
)

Definition at line 58 of file OS_NS_wchar.inl.

00059 {
00060   const WChar *scan1 = s;
00061   const WChar *scan2 = t;
00062 
00063   while (len != 0 && *scan1 != 0 && *scan1 == *scan2)
00064     {
00065       ++scan1;
00066       ++scan2;
00067       --len;
00068     }
00069 
00070   return len == 0 ? 0 : *scan1 - *scan2;
00071 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE u_int ACE_OS::wslen ( const WChar s  ) 

Definition at line 21 of file OS_NS_wchar.inl.

Referenced by ACE_Log_Msg::log().

00022 {
00023   u_int len = 0;
00024 
00025   while (*s++ != 0)
00026     len++;
00027 
00028   return len;
00029 }

ACE_INLINE ACE_OS::WChar* ACE_OS::wscpy ( WChar dest,
const WChar src 
)

Definition at line 32 of file OS_NS_wchar.inl.

00033 {
00034   WChar *original_dest = dest;
00035 
00036   while ((*dest++ = *src++) != 0)
00037     continue;
00038 
00039   return original_dest;
00040 }

ACE_INLINE int ACE_OS::wscmp ( const WChar s,
const WChar t 
)

Definition at line 43 of file OS_NS_wchar.inl.

00044 {
00045   const WChar *scan1 = s;
00046   const WChar *scan2 = t;
00047 
00048   while (*scan1 != 0 && *scan1 == *scan2)
00049     {
00050       ++scan1;
00051       ++scan2;
00052     }
00053 
00054   return *scan1 - *scan2;
00055 }

ACE_INLINE int ACE_OS::wsncmp ( const WChar s,
const WChar t,
size_t  len 
)

Definition at line 58 of file OS_NS_wchar.inl.

00059 {
00060   const WChar *scan1 = s;
00061   const WChar *scan2 = t;
00062 
00063   while (len != 0 && *scan1 != 0 && *scan1 == *scan2)
00064     {
00065       ++scan1;
00066       ++scan2;
00067       --len;
00068     }
00069 
00070   return len == 0 ? 0 : *scan1 - *scan2;
00071 }

ACE_INLINE int ACE_OS::t_accept ( ACE_HANDLE  fildes,
ACE_HANDLE  resfd,
struct t_call call 
)

Definition at line 12 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00013 {
00014 #if defined (ACE_HAS_TLI)
00015   ACE_OSCALL_RETURN (::t_accept (handle, reshandle, call), int, -1);
00016 #else
00017   ACE_UNUSED_ARG (call);
00018   ACE_UNUSED_ARG (reshandle);
00019   ACE_UNUSED_ARG (handle);
00020 
00021   ACE_NOTSUP_RETURN (-1);
00022 #endif /* ACE_HAS_TLI */
00023 }

ACE_INLINE char * ACE_OS::t_alloc ( ACE_HANDLE  fildes,
int  struct_type,
int  fields 
)

Definition at line 26 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00027 {
00028 #if defined (ACE_HAS_TLI)
00029 #  if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)
00030   // XPG5 changes t_alloc() return from char* to void*, so ACE_OSCALL_RETURN
00031   // doesn't compile correctly.
00032   char *result;
00033   ACE_OSCALL (::t_alloc (handle, struct_type, fields), char *, 0, result);
00034   return result;
00035 #  else
00036   ACE_OSCALL_RETURN (::t_alloc (handle, struct_type, fields),
00037                      char *, 0);
00038 #  endif /* XPG4 vs XPG5 */
00039 #else
00040   ACE_UNUSED_ARG (fields);
00041   ACE_UNUSED_ARG (struct_type);
00042   ACE_UNUSED_ARG (handle);
00043 
00044   ACE_NOTSUP_RETURN (0);
00045 #endif /* ACE_HAS_TLI */
00046 }

ACE_INLINE int ACE_OS::t_bind ( ACE_HANDLE  fildes,
ACE_TBIND req,
ACE_TBIND ret 
)

Definition at line 49 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00050 {
00051 #if defined (ACE_HAS_TLI)
00052   ACE_OSCALL_RETURN (::t_bind (handle, req, ret), int, -1);
00053 #else
00054   ACE_UNUSED_ARG (ret);
00055   ACE_UNUSED_ARG (req);
00056   ACE_UNUSED_ARG (handle);
00057 
00058   ACE_NOTSUP_RETURN (-1);
00059 #endif /* ACE_HAS_TLI */
00060 }

ACE_INLINE int ACE_OS::t_close ( ACE_HANDLE  fildes  ) 

Definition at line 63 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00064 {
00065 #if defined (ACE_HAS_TLI)
00066   ACE_OSCALL_RETURN (::t_close (handle), int, -1);
00067 #else
00068   ACE_UNUSED_ARG (handle);
00069 
00070   ACE_NOTSUP_RETURN (-1);
00071 #endif /* ACE_HAS_TLI */
00072 }

ACE_INLINE int ACE_OS::t_connect ( ACE_HANDLE  fildes,
struct t_call sndcall,
struct t_call rcvcall 
)

Definition at line 75 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00078 {
00079 #if defined (ACE_HAS_TLI)
00080   ACE_OSCALL_RETURN (::t_connect (fildes, sndcall, rcvcall), int, -1);
00081 #else
00082   ACE_UNUSED_ARG (fildes);
00083   ACE_UNUSED_ARG (sndcall);
00084   ACE_UNUSED_ARG (rcvcall);
00085 
00086   ACE_NOTSUP_RETURN (-1);
00087 #endif /* ACE_HAS_TLI */
00088 }

ACE_INLINE void ACE_OS::t_error ( const char *  errmsg  ) 

Definition at line 91 of file OS_TLI.inl.

00092 {
00093 #if defined (ACE_HAS_TLI)
00094 #if defined (ACE_HAS_BROKEN_T_ERROR)
00095   ::t_error (const_cast<char *> (errmsg));
00096 #else
00097   ::t_error (errmsg);
00098 #endif /* ACE_HAS_BROKEN_T_ERROR */
00099 #else
00100   ACE_UNUSED_ARG (errmsg);
00101 #endif /* ACE_HAS_TLI */
00102 }

ACE_INLINE int ACE_OS::t_free ( char *  ptr,
int  struct_type 
)

Definition at line 105 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00106 {
00107 #if defined (ACE_HAS_TLI)
00108   if (ptr == 0)
00109     return 0;
00110   ACE_OSCALL_RETURN (::t_free (ptr, struct_type), int, -1);
00111 #else
00112   ACE_UNUSED_ARG (struct_type);
00113   ACE_UNUSED_ARG (ptr);
00114 
00115   ACE_NOTSUP_RETURN (-1);
00116 #endif /* ACE_HAS_TLI */
00117 }

ACE_INLINE int ACE_OS::t_getinfo ( ACE_HANDLE  fildes,
struct t_info info 
)

Definition at line 120 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00121 {
00122 #if defined (ACE_HAS_TLI)
00123   ACE_OSCALL_RETURN (::t_getinfo (handle, info), int, -1);
00124 #else
00125   ACE_UNUSED_ARG (info);
00126   ACE_UNUSED_ARG (handle);
00127 
00128   ACE_NOTSUP_RETURN (-1);
00129 #endif /* ACE_HAS_TLI */
00130 }

ACE_INLINE int ACE_OS::t_getname ( ACE_HANDLE  fildes,
struct netbuf namep,
int  type 
)

Definition at line 133 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and last_error().

00134 {
00135 #if defined (ACE_HAS_XTI)
00136   ACE_TBIND bound, peer;
00137   // Depending on which address the caller wants, fill caller's values
00138   // into one of the t_bind netbufs. The other is set up to ignore that
00139   // address.
00140   switch (type)
00141     {
00142     case LOCALNAME:
00143       bound.addr.buf = namep->buf;
00144       bound.addr.maxlen = namep->maxlen;
00145       bound.addr.len = 0;
00146       peer.addr.buf = 0;
00147       peer.addr.maxlen = 0;
00148       peer.addr.len = 0;
00149       break;
00150     case REMOTENAME:
00151       bound.addr.buf = 0;
00152       bound.addr.maxlen = 0;
00153       bound.addr.len = 0;
00154       peer.addr.buf = namep->buf;
00155       peer.addr.maxlen = namep->maxlen;
00156       peer.addr.len = 0;
00157       break;
00158     default:
00159       ACE_OS::last_error (EINVAL);
00160       return -1;
00161     }
00162   if (t_getprotaddr (handle, &bound, &peer) == -1)
00163     return -1;
00164   // Call succeeded; put the caller's desired address length in his netbuf.
00165   if (type == LOCALNAME)
00166     namep->len = bound.addr.len;
00167   else
00168     namep->len = peer.addr.len;
00169   return 0;
00170 
00171 #elif defined (ACE_HAS_SVR4_TLI)
00172   ACE_OSCALL_RETURN (::t_getname (handle, namep, type), int, -1);
00173 #else
00174   ACE_UNUSED_ARG (handle);
00175   ACE_UNUSED_ARG (namep);
00176   ACE_UNUSED_ARG (type);
00177 
00178   ACE_NOTSUP_RETURN (-1);
00179 #endif /* ACE_HAS_SVR4_TLI */
00180 }

ACE_INLINE int ACE_OS::t_getstate ( ACE_HANDLE  fildes  ) 

Definition at line 183 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00184 {
00185 #if defined (ACE_HAS_TLI)
00186   ACE_OSCALL_RETURN (::t_getstate (handle), int, -1);
00187 #else
00188   ACE_UNUSED_ARG (handle);
00189 
00190   ACE_NOTSUP_RETURN (-1);
00191 #endif /* ACE_HAS_TLI */
00192 }

ACE_INLINE int ACE_OS::t_listen ( ACE_HANDLE  fildes,
struct t_call call 
)

Definition at line 195 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00196 {
00197 #if defined (ACE_HAS_TLI)
00198   ACE_OSCALL_RETURN (::t_listen (handle, call), int, -1);
00199 #else
00200   ACE_UNUSED_ARG (handle);
00201   ACE_UNUSED_ARG (call);
00202 
00203   ACE_NOTSUP_RETURN (-1);
00204 #endif /* ACE_HAS_TLI */
00205 }

ACE_INLINE int ACE_OS::t_look ( ACE_HANDLE  fildes  ) 

Definition at line 208 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00209 {
00210 #if defined (ACE_HAS_TLI)
00211   ACE_OSCALL_RETURN (::t_look (handle), int, -1);
00212 #else
00213   ACE_UNUSED_ARG (handle);
00214 
00215   ACE_NOTSUP_RETURN (-1);
00216 #endif /* ACE_HAS_TLI */
00217 }

ACE_INLINE ACE_HANDLE ACE_OS::t_open ( char *  path,
int  oflag,
struct t_info info 
)

Definition at line 220 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00221 {
00222 #if defined (ACE_HAS_TLI)
00223   ACE_OSCALL_RETURN (::t_open (path, oflag, info), ACE_HANDLE, ACE_INVALID_HANDLE);
00224 #else
00225   ACE_UNUSED_ARG (path);
00226   ACE_UNUSED_ARG (oflag);
00227   ACE_UNUSED_ARG (info);
00228 
00229   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00230 #endif /* ACE_HAS_TLI */
00231 }

ACE_INLINE int ACE_OS::t_optmgmt ( ACE_HANDLE  handle,
ACE_TOPTMGMT req,
ACE_TOPTMGMT ret 
)

Definition at line 234 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00235 {
00236 #if defined (ACE_HAS_TLI)
00237   ACE_OSCALL_RETURN (::t_optmgmt (handle, req, ret), int, -1);
00238 #else
00239   ACE_UNUSED_ARG (handle);
00240   ACE_UNUSED_ARG (req);
00241   ACE_UNUSED_ARG (ret);
00242 
00243   ACE_NOTSUP_RETURN (-1);
00244 #endif /* ACE_HAS_TLI */
00245 }

ACE_INLINE int ACE_OS::t_rcv ( ACE_HANDLE  fildes,
char *  buf,
unsigned int  nbytes,
int *  flags 
)

Definition at line 248 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00252 {
00253 #if defined (ACE_HAS_TLI)
00254   ACE_OSCALL_RETURN (::t_rcv (handle, buf, nbytes, flags),
00255                      int, -1);
00256 #else
00257   ACE_UNUSED_ARG (handle);
00258   ACE_UNUSED_ARG (buf);
00259   ACE_UNUSED_ARG (nbytes);
00260   ACE_UNUSED_ARG (flags);
00261 
00262   ACE_NOTSUP_RETURN (-1);
00263 #endif /* ACE_HAS_TLI */
00264 }

ACE_INLINE int ACE_OS::t_rcvdis ( ACE_HANDLE  fildes,
struct t_discon discon 
)

Definition at line 267 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00268 {
00269 #if defined (ACE_HAS_TLI)
00270   ACE_OSCALL_RETURN (::t_rcvdis (handle, discon), int, -1);
00271 #else
00272   ACE_UNUSED_ARG (handle);
00273   ACE_UNUSED_ARG (discon);
00274 
00275   ACE_NOTSUP_RETURN (-1);
00276 #endif /* ACE_HAS_TLI */
00277 }

ACE_INLINE int ACE_OS::t_rcvrel ( ACE_HANDLE  fildes  ) 

Definition at line 280 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00281 {
00282 #if defined (ACE_HAS_TLI)
00283   ACE_OSCALL_RETURN (::t_rcvrel (handle), int, -1);
00284 #else
00285   ACE_UNUSED_ARG (handle);
00286 
00287   ACE_NOTSUP_RETURN (-1);
00288 #endif /* ACE_HAS_TLI */
00289 }

ACE_INLINE int ACE_OS::t_rcvudata ( ACE_HANDLE  fildes,
struct t_unitdata unitdata,
int *  flags 
)

Definition at line 292 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00295 {
00296 #if defined (ACE_HAS_TLI)
00297   ACE_OSCALL_RETURN (::t_rcvudata (handle, unitdata, flags),
00298                      int, -1);
00299 #else
00300   ACE_UNUSED_ARG (handle);
00301   ACE_UNUSED_ARG (unitdata);
00302   ACE_UNUSED_ARG (flags);
00303 
00304   ACE_NOTSUP_RETURN (-1);
00305 #endif /* ACE_HAS_TLI */
00306 }

ACE_INLINE int ACE_OS::t_rcvuderr ( ACE_HANDLE  fildes,
struct t_uderr uderr 
)

Definition at line 309 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00310 {
00311 #if defined (ACE_HAS_TLI)
00312   ACE_OSCALL_RETURN (::t_rcvuderr (handle, uderr), int, -1);
00313 #else
00314   ACE_UNUSED_ARG (handle);
00315   ACE_UNUSED_ARG (uderr);
00316 
00317   ACE_NOTSUP_RETURN (-1);
00318 #endif /* ACE_HAS_TLI */
00319 }

ACE_INLINE int ACE_OS::t_snd ( ACE_HANDLE  fildes,
const char *  buf,
unsigned int  nbytes,
int  flags 
)

Definition at line 322 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00326 {
00327 #if defined (ACE_HAS_TLI)
00328   ACE_OSCALL_RETURN (::t_snd (handle, (char *) buf, nbytes, flags), int, -1);
00329 #else
00330   ACE_UNUSED_ARG (handle);
00331   ACE_UNUSED_ARG (buf);
00332   ACE_UNUSED_ARG (nbytes);
00333   ACE_UNUSED_ARG (flags);
00334 
00335   ACE_NOTSUP_RETURN (-1);
00336 #endif /* ACE_HAS_TLI */
00337 }

ACE_INLINE int ACE_OS::t_snddis ( ACE_HANDLE  fildes,
struct t_call call 
)

Definition at line 340 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00341 {
00342 #if defined (ACE_HAS_TLI)
00343   ACE_OSCALL_RETURN (::t_snddis (handle, call), int, -1);
00344 #else
00345   ACE_UNUSED_ARG (handle);
00346   ACE_UNUSED_ARG (call);
00347 
00348   ACE_NOTSUP_RETURN (-1);
00349 #endif /* ACE_HAS_TLI */
00350 }

ACE_INLINE int ACE_OS::t_sndrel ( ACE_HANDLE  fildes  ) 

Definition at line 353 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00354 {
00355 #if defined (ACE_HAS_TLI)
00356   ACE_OSCALL_RETURN (::t_sndrel (handle), int, -1);
00357 #else
00358   ACE_UNUSED_ARG (handle);
00359 
00360   ACE_NOTSUP_RETURN (-1);
00361 #endif /* ACE_HAS_TLI */
00362 }

ACE_INLINE int ACE_OS::t_sync ( ACE_HANDLE  fildes  ) 

Definition at line 365 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00366 {
00367 #if defined (ACE_HAS_TLI)
00368   ACE_OSCALL_RETURN (::t_sync (handle), int, -1);
00369 #else
00370   ACE_UNUSED_ARG (handle);
00371 
00372   ACE_NOTSUP_RETURN (-1);
00373 #endif /* ACE_HAS_TLI */
00374 }

ACE_INLINE int ACE_OS::t_unbind ( ACE_HANDLE  fildes  ) 

Definition at line 377 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

00378 {
00379 #if defined (ACE_HAS_TLI)
00380   ACE_OSCALL_RETURN (::t_unbind (handle), int, -1);
00381 #else
00382   ACE_UNUSED_ARG (handle);
00383 
00384   ACE_NOTSUP_RETURN (-1);
00385 #endif /* ACE_HAS_TLI */
00386 }


Variable Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0

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

Definition at line 36 of file OS_NS_stdlib.cpp.

Referenced by exit(), and set_exit_hook().

ACE_Export ACE_thread_t ACE_OS::NULL_thread

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

Referenced by recursive_mutex_cond_unlock(), recursive_mutex_init(), recursive_mutex_unlock(), and ACE_Thread_Descriptor_Base::reset().

ACE_hthread_t ACE_OS::NULL_hthread

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

Definition at line 1089 of file OS_NS_Thread.cpp.

Referenced by ACE_Thread_Descriptor_Base::reset().

ACE_thread_key_t ACE_OS::NULL_key

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

Definition at line 1094 of file OS_NS_Thread.cpp.


Generated on Tue Feb 2 17:36:07 2010 for ACE by  doxygen 1.4.7