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 and their 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
wint_t 
ace_towlower (wint_t c)
 Converts a character to lower case (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_toupper (int c)
 Converts a character to upper case (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
ace_towupper (wint_t c)
 Converts a character to upper case (wchar_t version).


A set of wrappers for explicit dynamic linking.

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)

A set of wrappers for password routines.

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)

A set of wrappers for regular expressions.

ACE_NAMESPACE_INLINE_FUNCTION
char * 
compile (const char *instring, char *expbuf, char *endbuf)
ACE_NAMESPACE_INLINE_FUNCTION
int 
step (const char *str, char *expbuf)

A set of wrappers for Signals.

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)

Wrappers to obtain the current user id

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

A set of wrappers for file locks.

ACE_NAMESPACE_INLINE_FUNCTION
void 
flock_adjust_params (ace_flock_t *lock, short whence, ACE_OFF_T &start, ACE_OFF_T &len)
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.

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
int 
atoi (const wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
atop (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
atop (const wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
bsearch (const void *key, const void *base, size_t nel, size_t size, ACE_COMPARE_FUNC)
ACE_Export void * calloc (size_t elements, size_t sizeof_elements)
ACE_Export void exit (int status=0)
ACE_Export void free (void *)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
getenv (const char *symbol)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
getenv (const wchar_t *symbol)
ACE_Export ACE_TCHARgetenvstrings (void)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
itoa (int value, char *string, int radix)
 Converts an integer to a string.

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
itoa (int value, wchar_t *string, int radix)
 Converts an integer to a string.

ACE_Export char * itoa_emulation (int value, char *string, int radix)
 Emulated itoa - Converts an integer to a string.

ACE_Export wchar_t * itow_emulation (int value, wchar_t *string, int radix)
 Emulated itow - Converts an integer to a string.

ACE_Export void * malloc (size_t)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
mkstemp (char *s)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
mkstemp (wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
mktemp (char *s)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
mktemp (wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putenv (const char *string)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putenv (const wchar_t *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_Export void * realloc (void *, size_t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
realpath (const char *file_name, char *resolved_name)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
realpath (const wchar_t *file_name, wchar_t *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_Export ACE_TCHARstrenvdup (const ACE_TCHAR *str)
ACE_NAMESPACE_INLINE_FUNCTION
double 
strtod (const char *s, char **endptr)
 Converts a string to a double value (char version).

ACE_NAMESPACE_INLINE_FUNCTION
double 
strtod (const wchar_t *s, wchar_t **endptr)
 Converts a string to a double value (wchar_t 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
long 
strtol (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to a long value (wchar_t 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
unsigned long 
strtoul (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to an unsigned long value (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
system (const ACE_TCHAR *s)
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 and their equivalents.

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


ACE_NAMESPACE_INLINE_FUNCTION
const void * 
memchr (const void *s, int c, size_t len)
 Finds characters in a buffer (const void version).

ACE_NAMESPACE_INLINE_FUNCTION
void * 
memchr (void *s, int c, size_t len)
 Finds characters in a buffer (void version).

ACE_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
wchar_t * 
strcat (wchar_t *s, const wchar_t *t)
 Appends a string to another string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strchr (char *s, int c)
 Finds the first occurance of a character in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strchr (wchar_t *s, wchar_t c)
 Finds the first occurance of a character in a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcmp (const char *s, const char *t)
 Compares two strings (char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
 Compares two strings (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strcpy (char *s, const char *t)
 Copies a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strcpy (wchar_t *s, const wchar_t *t)
 Copies a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strcspn (const char *s, const char *reject)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strcspn (const wchar_t *s, const wchar_t *reject)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strdup (const char *s)
 Returns a malloced duplicated string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strdup (const wchar_t *s)
 Returns a malloced duplicated string (wchar_t version).

ACE_Export char * strecpy (char *des, const char *src)
ACE_Export wchar_t * strecpy (wchar_t *s, const wchar_t *t)
ACE_Export char * strerror (int errnum)
 Finds characters in a buffer (const void version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strlen (const char *s)
 Finds the length of a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strlen (const ACE_WCHAR_T *s)
 Finds the length of a string (ACE_WCHAR_T version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strncat (char *s, const char *t, size_t len)
 Appends part of a string to another string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Appends part of a string to another string (wchar_t version).

ACE_Export const char * strnchr (const char *s, int c, size_t len)
ACE_Export const ACE_WCHAR_T * strnchr (const ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strnchr (char *s, int c, size_t len)
 Finds the first 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_Export const char * strnstr (const char *s, const char *t, size_t len)
ACE_Export const ACE_WCHAR_T * strnstr (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strnstr (char *s, const char *t, size_t len)
 Finds the first 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
const wchar_t * 
strpbrk (const wchar_t *s1, const wchar_t *s2)
 Searches for characters in a string (const wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strpbrk (char *s1, const char *s2)
 Searches for characters in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strpbrk (wchar_t *s1, const wchar_t *s2)
 Searches for characters in a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strrchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strrchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strrchr (char *s, int c)
 Finds the last occurance of a character in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strrchr (wchar_t *s, wchar_t c)
 Finds the last occurance of a character in a string (wchar_t version).

ACE_Export char * strrchr_emulation (char *s, int c)
ACE_Export const char * strrchr_emulation (const char *s, int c)
ACE_Export char * strsncpy (char *dst, const char *src, size_t maxlen)
 This is a "safe" c string copy function (char version).

ACE_Export ACE_WCHAR_T * strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen)
 This is a "safe" c string copy function (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const char *s1, const char *s2)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const wchar_t *s1, const wchar_t *s2)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strstr (const char *s, const char *t)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strstr (const wchar_t *s, const wchar_t *t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strstr (char *s, const char *t)
 Finds the first occurance of a substring in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strstr (wchar_t *s, const wchar_t *t)
 Finds the first occurance of a substring in a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strtok (char *s, const char *tokens)
 Finds the next token in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strtok (wchar_t *s, const wchar_t *tokens)
 Finds the next token in a string (wchar_t version).


A set of wrappers for memory mapped files.

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)

A set of wrappers for System V message queues.

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)

A set of wrappers for System V shared memory.

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)

A set of wrappers for sockets.

ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style (no QoS).

ACE_Export ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen, const ACE_Accept_QoS_Params &qos_params)
ACE_NAMESPACE_INLINE_FUNCTION
int 
bind (ACE_HANDLE s, struct sockaddr *name, int namelen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
closesocket (ACE_HANDLE s)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
 BSD-style (no QoS).

ACE_Export int connect (ACE_HANDLE handle, const sockaddr *addr, int addrlen, const ACE_QoS_Params &qos_params)
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 (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen)
 BSD-style (no QoS).

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

ACE_NAMESPACE_INLINE_FUNCTION
int 
listen (ACE_HANDLE handle, int backlog)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recv (ACE_HANDLE handle, char *buf, size_t len, int flags=0)
 BSD-style (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 (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 (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvv (ACE_HANDLE handle, iovec *iov, int iovlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
send (ACE_HANDLE handle, const char *buf, size_t len, int flags=0)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
 BSD-style (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 (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 (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt)
 BSD-style (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 (no QoS).

ACE_Export int socket_init (int version_high=1, int version_low=1)
ACE_Export int socket_fini (void)
 Finalize WinSock after last use (e.g., when a DLL is unloaded).

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 (no QoS).


A set of wrappers for low-level file operations.

ACE_NAMESPACE_INLINE_FUNCTION
ACE_OFF_T 
filesize (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_OFF_T 
filesize (const ACE_TCHAR *handle)

A set of wrappers for condition variables.

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_Export int cond_init (ACE_cond_t *cv, short type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0)
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_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const wchar_t *name, 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)

A set of wrappers for auto-reset and manual events.

ACE_Export int event_destroy (ACE_event_t *event)
ACE_Export int event_init (ACE_event_t *event, int manual_reset=0, int initial_state=0, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
event_init (ACE_event_t *event, int manual_reset, int initial_state, int type, const wchar_t *name, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_Export int event_pulse (ACE_event_t *event)
ACE_Export int event_reset (ACE_event_t *event)
ACE_Export int event_signal (ACE_event_t *event)
ACE_Export int event_timedwait (ACE_event_t *event, ACE_Time_Value *timeout, int use_absolute_time=1)
ACE_Export int event_wait (ACE_event_t *event)

A set of wrappers for mutex locks.

ACE_Export int mutex_destroy (ACE_mutex_t *m)
ACE_Export int mutex_init (ACE_mutex_t *m, int lock_scope=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0, int lock_type=0)
ACE_Export int mutex_init (ACE_mutex_t *m, int lock_scope, const wchar_t *name, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0, int lock_type=0)
ACE_Export int mutex_lock (ACE_mutex_t *m)
ACE_Export int mutex_lock (ACE_mutex_t *m, int &abandoned)
ACE_Export int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value &timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mutex_lock (ACE_mutex_t *m, const ACE_Time_Value *timeout)
ACE_Export void mutex_lock_cleanup (void *mutex)
 Handle asynchronous thread cancellation cleanup.

ACE_Export int mutex_trylock (ACE_mutex_t *m)
ACE_Export int mutex_trylock (ACE_mutex_t *m, int &abandoned)
ACE_Export int mutex_unlock (ACE_mutex_t *m)

A set of wrappers for recursive mutex locks.

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)

A set of wrappers for readers/writer locks.

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)
ACE_Export int rwlock_init (ACE_rwlock_t *rw, int type=ACE_DEFAULT_SYNCH_TYPE, const ACE_TCHAR *name=0, void *arg=0)

Thread scheduler interface.

ACE_Export int sched_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)

A set of wrappers for semaphores.

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_init (ACE_sema_t *s, u_int count, int type, const wchar_t *name, 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)

A set of wrappers for System V semaphores.

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)

A set of wrappers for mutex locks that only work within a single process.

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_init (ACE_thread_mutex_t *m, int lock_type, const wchar_t *name, 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)

A set of wrappers for operations on time.

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_Export struct tm * localtime_r (const time_t *clock, struct tm *res)
ACE_Export time_t mktime (struct tm *timeptr)
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)

[NOHEADER]

ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
fork (void)
ACE_Export pid_t fork (const ACE_TCHAR *program_name)
ACE_Export pid_t fork_exec (ACE_TCHAR *argv[])

A set of wrappers for threads

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_NAMESPACE_INLINE_FUNCTION
unsigned long 
inet_addr (const char *name)
ACE_Export int inet_aton (const char *strptr, struct in_addr *addr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
inet_ntoa (const struct in_addr addr)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
int 
inet_pton (int family, const char *strptr, void *addrptr)
ACE_NAMESPACE_INLINE_FUNCTION
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_Export int scandir_emulation (const ACE_TCHAR *dirname, ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator)
ACE_NAMESPACE_INLINE_FUNCTION
int 
last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
last_error (int)
ACE_NAMESPACE_INLINE_FUNCTION
int 
set_errno_to_last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
set_errno_to_wsa_last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fcntl (ACE_HANDLE handle, int cmd, long arg=0)
ACE_Export ACE_HANDLE open (const char *filename, int mode, mode_t perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
ACE_Export ACE_HANDLE open (const wchar_t *filename, int mode, mode_t perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
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_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyaddr (const char *addr, int length, int type)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyaddr_r (const char *addr, int length, int type, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyname (const char *name)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyname_r (const char *name, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
getipnodebyaddr (const void *src, size_t len, int family)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
getipnodebyname (const char *name, int family, int flags=0)
ACE_Export int getmacaddress (struct macaddr_node_t *node)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobyname (const char *name)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobyname_r (const char *name, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobynumber (int proto)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobynumber_r (int proto, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_NAMESPACE_INLINE_FUNCTION
struct servent * 
getservbyname (const char *svc, const char *proto)
ACE_NAMESPACE_INLINE_FUNCTION
struct servent * 
getservbyname_r (const char *svc, const char *proto, struct servent *result, ACE_SERVENT_DATA buf)
ACE_NAMESPACE_INLINE_FUNCTION
int 
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_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
wchar_t * 
fgets (wchar_t *buf, int size, FILE *fp)
ACE_Export FILE * fopen (const char *filename, const ACE_TCHAR *mode)
ACE_Export FILE * fopen (const wchar_t *filename, const ACE_TCHAR *mode)
ACE_NAMESPACE_INLINE_FUNCTION
LPSECURITY_ATTRIBUTES 
default_win32_security_attributes (LPSECURITY_ATTRIBUTES)
 Default Win32 Security Attributes definition.

ACE_NAMESPACE_INLINE_FUNCTION
LPSECURITY_ATTRIBUTES 
default_win32_security_attributes_r (LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, SECURITY_DESCRIPTOR *)
ACE_NAMESPACE_INLINE_FUNCTION
const ACE_TEXT_OSVERSIONINFO & 
get_win32_versioninfo (void)
 Return the win32 OSVERSIONINFO structure.

ACE_NAMESPACE_INLINE_FUNCTION
HINSTANCE 
get_win32_resource_module (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
set_win32_resource_module (HINSTANCE)
ACE_Export int fprintf (FILE *fp, const char *format,...)
ACE_Export int fprintf (FILE *fp, const wchar_t *format,...)
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
int 
fputs (const wchar_t *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
void 
perror (const wchar_t *s)
ACE_Export int printf (const char *format,...)
ACE_NAMESPACE_INLINE_FUNCTION
int 
puts (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
puts (const wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rename (const char *old_name, const char *new_name, int flags=-1)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rename (const wchar_t *old_name, const wchar_t *new_name, int flags=-1)
ACE_NAMESPACE_INLINE_FUNCTION
void 
rewind (FILE *fp)
ACE_Export int snprintf (char *buf, size_t maxlen, const char *format,...)
ACE_Export int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...)
ACE_Export int sprintf (char *buf, const char *format,...)
ACE_Export int sprintf (wchar_t *buf, const wchar_t *format,...)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
tempnam (const char *dir=0, const char *pfx=0)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
tempnam (const wchar_t *dir, const wchar_t *pfx=0)
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_NAMESPACE_INLINE_FUNCTION
int 
vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strtok_r (char *s, const char *tokens, char **lasts)
 Finds the next token in a string (safe char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
 Finds the next token in a string (wchar_t version).

ACE_Export char * strtok_r_emulation (char *s, const char *tokens, char **lasts)
 Emulated strtok_r.

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcasecmp (const char *s, const char *t)
 Compares two strings (case insensitive const char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcasecmp (const wchar_t *s, const wchar_t *t)
 Compares two strings (case insensitive const wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strncasecmp (const char *s, const char *t, size_t len)
 Compares two arrays (case insensitive const char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strncasecmp (const wchar_t *s, const wchar_t *t, size_t len)
 Compares two arrays (case insensitive const wchar_t version).

ACE_Export int strcasecmp_emulation (const char *s, const char *t)
 Emulated strcasecmp - Performs a case insensitive comparison of strings.

ACE_Export int strncasecmp_emulation (const char *s, const char *t, size_t len)
 Emulated strncasecmp - Performs a case insensitvie comparison of arrays.

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 .

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

ACE_Export int ioctl (ACE_HANDLE socket, unsigned long io_control_code, ACE_QoS &ace_qos, unsigned long *bytes_returned, void *buffer_p=0, unsigned long buffer=0, ACE_OVERLAPPED *overlapped=0, ACE_OVERLAPPED_COMPLETION_FUNC func=0)
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_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
shm_open (const ACE_TCHAR *filename, int mode, mode_t perms=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
shm_unlink (const ACE_TCHAR *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getrlimit (int resource, struct rlimit *rl)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getrusage (int who, struct rusage *rusage)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setrlimit (int resource, const struct rlimit *rl)
ACE_NAMESPACE_INLINE_FUNCTION
int 
select (int width, fd_set *rfds, fd_set *wfds=0, fd_set *efds=0, const ACE_Time_Value *tv=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendfile (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
 Finds the length of a string (char version).

ACE_Export ssize_t sendfile_emulation (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
ACE_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 
lstat (const wchar_t *, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkdir (const char *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkdir (const wchar_t *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
int 
stat (const wchar_t *file, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
mode_t 
umask (mode_t cmask)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_Time_Value 
gettimeofday (void)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
readv (ACE_HANDLE handle, const iovec *iov, int iovlen)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
writev (ACE_HANDLE handle, const iovec *iov, int iovcnt)
ACE_Export 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_Export void cleanup_tss (const u_int main_thread)
ACE_Export int lwp_getparams (ACE_Sched_Params &)
ACE_Export int lwp_setparams (const ACE_Sched_Params &)
ACE_NAMESPACE_INLINE_FUNCTION
long 
priority_control (ACE_idtype_t, ACE_id_t, int, void *)
 Low-level interface to (2).

ACE_Export int scheduling_class (const char *class_name, ACE_id_t &)
 Find the schedling class ID that corresponds to the class name.

ACE_Export int set_scheduling_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)
 Friendly interface to (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_Export int thr_create (ACE_THR_FUNC func, void *args, long flags, ACE_thread_t *thr_id, ACE_hthread_t *t_handle=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, void *stack=0, size_t stacksize=ACE_DEFAULT_THREAD_STACKSIZE, ACE_Base_Thread_Adapter *thread_adapter=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_equal (ACE_thread_t t1, ACE_thread_t t2)
ACE_Export void thr_exit (ACE_THR_FUNC_RETURN status=0)
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_Export int thr_get_affinity (ACE_hthread_t thr_id, size_t cpu_set_size, cpu_set_t *cpu_mask)
ACE_Export int thr_set_affinity (ACE_hthread_t thr_id, size_t cpu_set_size, const cpu_set_t *cpu_mask)
ACE_Export int thr_key_detach (ACE_thread_key_t key, void *inst)
ACE_Export int thr_key_used (ACE_thread_key_t key)
ACE_Export int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST, void *inst=0)
ACE_Export int thr_keyfree (ACE_thread_key_t key)
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
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_Export int thr_setprio (const ACE_Sched_Priority prio)
ACE_Export int thr_setspecific (ACE_thread_key_t key, void *data)
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_Export void unique_name (const void *object, char *name, size_t length)
ACE_NAMESPACE_INLINE_FUNCTION
int 
access (const char *path, int amode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
access (const wchar_t *path, int amode)
ACE_NAMESPACE_INLINE_FUNCTION
unsigned int 
alarm (u_int secs)
ACE_NAMESPACE_INLINE_FUNCTION
long 
allocation_granularity (void)
ACE_Export int argv_to_string (ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args=true, bool quote_args=false)
ACE_NAMESPACE_INLINE_FUNCTION
int 
chdir (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
chdir (const wchar_t *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rmdir (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rmdir (const wchar_t *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_Export int execl (const char *path, const char *arg0,...)
ACE_Export int execle (const char *path, const char *arg0,...)
ACE_Export int execlp (const char *file, const char *arg0,...)
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
wchar_t * 
getcwd (wchar_t *, 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 
hostname (wchar_t *name, size_t maxnamelen)
ACE_NAMESPACE_INLINE_FUNCTION
int 
isatty (int handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
isatty (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_OFF_T 
lseek (ACE_HANDLE handle, ACE_OFF_T offset, int whence)
ACE_Export long num_processors (void)
 Get the number of CPUs configured in the machine.

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

ACE_NAMESPACE_INLINE_FUNCTION
int 
pipe (ACE_HANDLE handles[])
ACE_Export ssize_t pread (ACE_HANDLE handle, void *buf, size_t nbyte, ACE_OFF_T offset)
ACE_Export ssize_t pwrite (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OFF_T offset)
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_Export ssize_t read_n (ACE_HANDLE handle, void *buf, size_t len, size_t *bytes_transferred=0)
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_Export int string_to_argv (ACE_TCHAR *buf, int &argc, ACE_TCHAR **&argv, bool substitute_env_args=true)
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
int 
unlink (const wchar_t *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_Export ssize_t write_n (ACE_HANDLE handle, const void *buf, size_t len, size_t *bytes_transferred=0)
ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
fgetwc (FILE *fp)
ACE_Export wchar_t * wcscat_emulation (wchar_t *destination, const wchar_t *source)
 Emulated wcscat - Appends a string.

ACE_Export wchar_t * wcschr_emulation (const wchar_t *string, wchar_t c)
 Emulated wcschr - Finds a character in a string.

ACE_Export int wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2)
 Emulated wcscmp - Compares strings.

ACE_Export wchar_t * wcscpy_emulation (wchar_t *destination, const wchar_t *source)
 Emulated wcscpy - Copies a string.

ACE_Export size_t wcscspn_emulation (const wchar_t *string, const wchar_t *reject)
 Emulated wcscspn.

ACE_Export int wcsicmp_emulation (const wchar_t *string1, const wchar_t *string2)
 Emulated wcsicmp - Performs a case insensitive comparison of strings.

ACE_Export size_t wcslen_emulation (const ACE_WCHAR_T *string)
 Emulated wcslen - Returns the length of a string.

ACE_Export ACE_WCHAR_T * wcsncat_emulation (ACE_WCHAR_T *destination, const ACE_WCHAR_T *source, size_t count)
 Emulated wcscat - Appends a string.

ACE_Export int wcsncmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2, size_t len)
 Emulated wcsncmp - Compares two arrays.

ACE_Export ACE_WCHAR_T * wcsncpy_emulation (ACE_WCHAR_T *destination, const ACE_WCHAR_T *source, size_t len)
 Emulated wcsncpy - Copies an array.

ACE_Export int wcsnicmp_emulation (const wchar_t *string1, const wchar_t *string2, size_t len)
ACE_Export wchar_t * wcspbrk_emulation (const wchar_t *string, const wchar_t *charset)
 Emulated wcspbrk - Searches for characters in a string.

ACE_Export wchar_t * wcsrchr_emulation (wchar_t *string, wint_t c)
ACE_Export const wchar_t * wcsrchr_emulation (const wchar_t *string, wint_t c)
ACE_Export size_t wcsspn_emulation (const wchar_t *string, const wchar_t *charset)
 Emulated wcsspn.

ACE_Export wchar_t * wcsstr_emulation (const wchar_t *string, const wchar_t *charset)
 Emulated wcsstr - Performs a case insensitive comparison of two strings.

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_NAMESPACE_INLINE_FUNCTION
wint_t 
ungetwc (wint_t c, FILE *fp)
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)

Variables

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


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
 

Enumeration values:
ACE_HRTIMER_START 
ACE_HRTIMER_INCR 
ACE_HRTIMER_STOP 
ACE_HRTIMER_GETTIME 

Definition at line 154 of file OS_NS_time.h.

00155     {
00156       ACE_HRTIMER_START = 0x0,  // Only use these if you can stand
00157       ACE_HRTIMER_INCR = 0x1,   // for interrupts to be disabled during
00158       ACE_HRTIMER_STOP = 0x2,   // the timed interval!!!!
00159       ACE_HRTIMER_GETTIME = 0xFFFF
00160     };


Function Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::_exit int  status = 0  ) 
 

Definition at line 24 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE.

Referenced by 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 (),
00033                       status);
00034 #endif /* ACE_VXWORKS */
00035 }

ACE_INLINE void ACE_OS::abort void   ) 
 

Definition at line 38 of file OS_NS_stdlib.inl.

References exit().

Referenced by ACE_Log_Msg::log().

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

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

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

Definition at line 19 of file OS_NS_sys_socket.cpp.

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

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_INLINE ACE_HANDLE ACE_OS::accept ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen
 

BSD-style (no QoS).

Definition at line 29 of file OS_NS_sys_socket.inl.

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

Referenced by accept().

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::access const wchar_t *  path,
int  amode
 

Definition at line 68 of file OS_NS_unistd.inl.

References access().

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

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(), 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_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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

Referenced by ACE::hex2byte(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), 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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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.

References ACE_TCHAR.

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(), ACE_Svc_Conf_Lexer::scan(), strcasecmp_emulation(), strncasecmp_emulation(), and wcsicmp_emulation().

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 143 of file OS_NS_ctype.inl.

00144 {
00145   return toupper (c);
00146 }

ACE_NAMESPACE_INLINE_FUNCTION wint_t ace_towlower wint_t  c  ) 
 

Converts a character to lower case (wchar_t version).

Referenced by wcsicmp_emulation(), and wcsnicmp_emulation().

ACE_NAMESPACE_INLINE_FUNCTION wint_t ace_towupper wint_t  c  ) 
 

Converts a character to upper case (wchar_t version).

ACE_INLINE u_int ACE_OS::alarm u_int  secs  ) 
 

Definition at line 79 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

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

References ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT, free(), malloc(), memcpy(), strchr(), strecpy(), strenvdup(), and strlen().

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   size_t buf_len = 0;
00050 
00051   // Determine the length of the buffer.
00052 
00053   int argc;
00054   for (argc = 0; argv[argc] != 0; ++argc)
00055     continue;
00056   ACE_TCHAR **argv_p = argv;
00057 
00058   for (int i = 0; i < argc; ++i)
00059     {
00060 #if !defined (ACE_LACKS_ENV)
00061       // Account for environment variables.
00062       if (substitute_env_args
00063           && ACE_OS::strchr (argv[i], ACE_TEXT ('$')) != 0)
00064         {
00065           if (argv_p == argv)
00066             {
00067               argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
00068               if (argv_p == 0)
00069                 {
00070                   errno = ENOMEM;
00071                   return 0;
00072                 }
00073               ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *));
00074             }
00075           argv_p[i] = ACE_OS::strenvdup (argv[i]);
00076           if (argv_p[i] == 0)
00077             {
00078               ACE_OS::free (argv_p);
00079               errno = ENOMEM;
00080               return 0;
00081             }
00082         }
00083 #endif /* ACE_LACKS_ENV */
00084       if (quote_args
00085           && ACE_OS::strchr (argv_p[i], ACE_TEXT (' ')) != 0)
00086         {
00087           if (argv_p == argv)
00088             {
00089               argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
00090               if (argv_p == 0)
00091                 {
00092                   errno = ENOMEM;
00093                   return 0;
00094                 }
00095               ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *));
00096             }
00097           int quotes = 0;
00098           ACE_TCHAR *temp = argv_p[i];
00099           if (ACE_OS::strchr (temp, ACE_TEXT ('"')) != 0)
00100             {
00101               for (int j = 0; temp[j] != 0; ++j)
00102                 if (temp[j] == ACE_TEXT ('"'))
00103                   ++quotes;
00104             }
00105           argv_p[i] =
00106             (ACE_TCHAR *) ACE_OS::malloc (ACE_OS::strlen (temp) * sizeof (ACE_TCHAR) + quotes + 3);
00107           if (argv_p[i] == 0)
00108             {
00109               ACE_OS::free (argv_p);
00110               errno = ENOMEM;
00111               return 0;
00112             }
00113           ACE_TCHAR *end = argv_p[i];
00114 
00115           *end++ = ACE_TEXT ('"');
00116 
00117           if (quotes > 0)
00118             {
00119               for (ACE_TCHAR *p = temp;
00120                    *p != 0;
00121                    *end++ = *p++)
00122                 if (*p == ACE_TEXT ('"'))
00123                   *end++ = ACE_TEXT ('\\');
00124 
00125               *end++ = ACE_TEXT ('\0');
00126             }
00127           else
00128             end = ACE_OS::strecpy (end, temp);
00129 
00130           end[-1] = ACE_TEXT ('"');
00131 
00132           *end = ACE_TEXT ('\0');
00133           if (temp != argv[i])
00134             ACE_OS::free (temp);
00135         }
00136       buf_len += ACE_OS::strlen (argv_p[i]);
00137 
00138       // Add one for the extra space between each string.
00139       buf_len++;
00140     }
00141 
00142   // Step through all argv params and copy each one into buf; separate
00143   // each param with white space.
00144 
00145   ACE_NEW_RETURN (buf,
00146                   ACE_TCHAR[buf_len + 1],
00147                   0);
00148 
00149   // Initial null charater to make it a null string.
00150   buf[0] = ACE_TEXT ('\0');
00151   ACE_TCHAR *end = buf;
00152 
00153   for (int i = 0; i < argc; ++i)
00154     {
00155       end = ACE_OS::strecpy (end, argv_p[i]);
00156       if (argv_p[i] != argv[i])
00157         ACE_OS::free (argv_p[i]);
00158 
00159       // Replace the null char that strecpy put there with white
00160       // space.
00161       end[-1] = ACE_TEXT (' ');
00162     }
00163   // Null terminate the string.
00164   *end = ACE_TEXT ('\0');
00165 
00166   if (argv_p != argv)
00167     ACE_OS::free (argv_p);
00168 
00169   // The number of arguments.
00170   return argc;
00171 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE char * ACE_OS::asctime const struct tm *  tm  ) 
 

Definition at line 14 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by 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 *  tm,
char *  buf,
int  buflen
 

Definition at line 26 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, 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::atexit ACE_EXIT_HOOK  func  ) 
 

Definition at line 49 of file OS_NS_stdlib.inl.

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

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

ACE_INLINE int ACE_OS::atoi const wchar_t *  s  ) 
 

Definition at line 62 of file OS_NS_stdlib.inl.

References atoi().

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

ACE_INLINE int ACE_OS::atoi const char *  s  ) 
 

Definition at line 55 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_SOCK_Dgram::make_multicast_ifaddr6(), ACE_Logging_Strategy::parse_args(), ACE_Service_Config::parse_args_i(), ACE_Registry_ImpExp::process_previous_line_format(), and ACE_INET_Addr::set_interface().

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

ACE_INLINE void * ACE_OS::atop const wchar_t *  s  ) 
 

Definition at line 97 of file OS_NS_stdlib.inl.

References atoi().

00098 {
00099 #  if defined (ACE_WIN64)
00100   intptr_t ip = ::_wtoi64 (s);
00101 #  elif defined (ACE_OPENVMS)
00102 #    if !defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)
00103   int ip = ACE_OS::atoi (s);
00104 #    else
00105   intptr_t ip = ACE_OS::atoi (s);
00106 #    endif
00107 #  else
00108   intptr_t ip = ACE_OS::atoi (s);
00109 #  endif /* ACE_WIN64 */
00110   void * p = reinterpret_cast<void *> (ip);
00111   return p;
00112 }

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

Definition at line 77 of file OS_NS_stdlib.inl.

References ACE_TRACE.

Referenced by ACE_Name_Options::parse_args().

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

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

BSD-style (no QoS).

Definition at line 98 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ACE_SOCKET_LEN.

Referenced by 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 #else
00107   ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle,
00108                                addr,
00109                                (ACE_SOCKET_LEN) addrlen), int, -1);
00110 #endif
00111 }

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

Definition at line 116 of file OS_NS_stdlib.inl.

References ACE_COMPARE_FUNC, and ACE_NOTSUP_RETURN.

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

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_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 int ACE_OS::chdir const wchar_t *  path  ) 
 

Definition at line 137 of file OS_NS_unistd.inl.

References chdir().

00138 {
00139 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00140   ACE_OSCALL_RETURN (::_wchdir (path), int, -1);
00141 #else /* ACE_WIN32 */
00142   return ACE_OS::chdir (ACE_Wide_To_Ascii (path).char_rep ());
00143 #endif /* ACE_WIN32 */
00144 }

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 }

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

References ACE_Base_Thread_Adapter::close_log_msg(), and TSS_Cleanup_Instance::valid().

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

01100 {
01101 #if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
01102   { // scope the cleanup instance
01103     // Call TSS destructors for current thread.
01104     TSS_Cleanup_Instance cleanup;
01105     if (cleanup.valid ())
01106       {
01107         cleanup->thread_exit ();
01108       }
01109   }
01110 #endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */
01111 
01112   if (main_thread)
01113     {
01114 #if !defined (ACE_HAS_TSS_EMULATION)  &&  !defined (ACE_HAS_MINIMAL_ACE_OS)
01115       // Just close the ACE_Log_Msg for the current (which should be
01116       // main) thread.  We don't have TSS emulation; if there's native
01117       // TSS, it should call its destructors when the main thread
01118       // exits.
01119       ACE_Base_Thread_Adapter::close_log_msg ();
01120 #endif /* ! ACE_HAS_TSS_EMULATION  &&  ! ACE_HAS_MINIMAL_ACE_OS */
01121 
01122 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
01123       // Finally, free up the ACE_TSS_Cleanup instance.  This method gets
01124       // called by the ACE_Object_Manager.
01125       TSS_Cleanup_Instance cleanup(TSS_Cleanup_Instance::DESTROY);
01126       if (cleanup.valid ())
01127       {
01128         ; // the pointer deletes the Cleanup when it goes out of scope
01129       }
01130 
01131 #endif /* WIN32 || ACE_HAS_TSS_EMULATION */
01132 
01133 #if defined (ACE_HAS_TSS_EMULATION)
01134       ACE_TSS_Emulation::tss_close ();
01135 #endif /* ACE_HAS_TSS_EMULATION */
01136     }
01137 }

ACE_INLINE void ACE_OS::clearerr FILE *  fp  ) 
 

Definition at line 380 of file OS_NS_stdio.inl.

References ace_clearerr_helper().

Referenced by ACE_Svc_Conf_Lexer::input().

00381 {
00382   ace_clearerr_helper (fp);
00383 }

ACE_INLINE 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, clock_gettime(), and clockid_t.

Referenced by clock_gettime(), and gethrtime().

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  ,
const struct timespec
 

Definition at line 78 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, clock_settime(), and clockid_t.

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 int ACE_OS::close ACE_HANDLE  handle  ) 
 

Definition at line 182 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, and ACE_OS_TRACE.

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Mutex::ACE_Mutex(), ACE_TLI_Stream::close(), ACE_SPIPE::close(), ACE_FILE::close(), ACE_FIFO_Recv::close(), ACE_FIFO::close(), ACE_DEV::close(), ACE_Mem_Map::close_filemapping_handle(), ACE_Mem_Map::close_handle(), ACE_Handle_Gobbler::close_remaining_handles(), ACE_SPIPE_Connector::connect(), ACE_SPIPE_Acceptor::create_new_instance(), ACE::daemonize(), dlopen(), event_init(), filesize(), flock_destroy(), fopen(), fork_exec(), ACE_Handle_Gobbler::free_handles(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), getmacaddress(), 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(), 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 void ACE_OS::closedir ACE_DIR  ) 
 

Definition at line 17 of file OS_NS_dirent.inl.

References ACE_DIR.

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 int ACE_OS::closesocket ACE_HANDLE  s  ) 
 

BSD-style (no QoS).

Definition at line 114 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and closesocket().

Referenced by ACE_SOCK::close(), ACE_Pipe::close(), ACE_Process::close_dup_handles(), ACE_Process::close_passed_handles(), closesocket(), and ip_check().

00115 {
00116   ACE_OS_TRACE ("ACE_OS::closesocket");
00117 #if defined (ACE_WIN32)
00118   // @note Do not shutdown the write end here.  Doing so will break
00119   //       applications that duplicate a handle on fork(), for
00120   //       example, and expect to continue writing in the fork()ed
00121   //       process.
00122 
00123   ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1);
00124 #else
00125   ACE_OSCALL_RETURN (::close (handle), int, -1);
00126 #endif /* ACE_WIN32 */
00127 }

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::cond_broadcast ACE_cond_t *  cv  ) 
 

Definition at line 214 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_broadcast().

Referenced by ACE_Condition< MUTEX >::broadcast(), cond_broadcast(), event_destroy(), event_pulse(), event_signal(), and rw_unlock().

00215 {
00216   ACE_OS_TRACE ("ACE_OS::cond_broadcast");
00217 # if defined (ACE_HAS_THREADS)
00218 #   if defined (ACE_HAS_PTHREADS)
00219 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00220   ACE_OSCALL_RETURN (pthread_cond_broadcast (cv), int, -1);
00221 #     else
00222   int result;
00223   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_broadcast (cv),
00224                                        result),
00225                      int, -1);
00226 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00227 #   elif defined (ACE_HAS_STHREADS)
00228   int result;
00229   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv),
00230                                        result),
00231                      int, -1);
00232 #   endif /* ACE_HAS_STHREADS */
00233 # else
00234   ACE_UNUSED_ARG (cv);
00235   ACE_NOTSUP_RETURN (-1);
00236 # endif /* ACE_HAS_THREADS */
00237 }

ACE_INLINE int ACE_OS::cond_destroy ACE_cond_t *  cv  ) 
 

Definition at line 240 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(), ACE_Condition< MUTEX >::remove(), rwlock_destroy(), sema_destroy(), and sema_init().

00241 {
00242   ACE_OS_TRACE ("ACE_OS::cond_destroy");
00243 # if defined (ACE_HAS_THREADS)
00244 #   if defined (ACE_HAS_PTHREADS)
00245 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00246   ACE_OSCALL_RETURN (pthread_cond_destroy (cv), int, -1);
00247 #     else
00248   int result;
00249   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_destroy (cv), result), int, -1);
00250 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00251 #   elif defined (ACE_HAS_STHREADS)
00252   int result;
00253   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), result), int, -1);
00254 #   endif /* ACE_HAS_STHREADS */
00255 # else
00256   ACE_UNUSED_ARG (cv);
00257   ACE_NOTSUP_RETURN (-1);
00258 # endif /* ACE_HAS_THREADS */
00259 }

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

Definition at line 317 of file OS_NS_Thread.inl.

References cond_init().

00321 {
00322   return ACE_OS::cond_init (cv, attributes, ACE_Wide_To_Ascii (name).char_rep (), arg);
00323 }

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

Definition at line 328 of file OS_NS_Thread.inl.

References cond_init().

00329 {
00330   return ACE_OS::cond_init (cv, type, ACE_Wide_To_Ascii (name).char_rep (), arg);
00331 }

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

Definition at line 262 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_init(), and memset().

00266 {
00267   // ACE_OS_TRACE ("ACE_OS::cond_init");
00268   ACE_UNUSED_ARG (name);
00269   ACE_UNUSED_ARG (arg);
00270 # if defined (ACE_HAS_THREADS)
00271 #   if defined (ACE_HAS_PTHREADS)
00272   int result = -1;
00273 
00274 #     if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00275   /* VxWorks 6.x API reference states:
00276    *   If the memory for the condition variable object has been allocated
00277    *   dynamically, it is a good policy to always zero out the
00278    *   block of memory so as to avoid spurious EBUSY return code
00279    *   when calling this routine.
00280    */
00281   ACE_OS::memset (cv, 0, sizeof (*cv));
00282 #     endif
00283 
00284   if (
00285 #     if defined  (ACE_HAS_PTHREADS_DRAFT4)
00286       pthread_cond_init (cv, attributes) == 0
00287 #     elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7)
00288       ACE_ADAPT_RETVAL (pthread_cond_init (cv, &attributes), result) == 0
00289 #     else  /* this is draft 6 */
00290       pthread_cond_init (cv, &attributes) == 0
00291 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
00292       )
00293      result = 0;
00294   else
00295      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00296 
00297   return result;
00298 #   elif defined (ACE_HAS_STHREADS)
00299   int result;
00300   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv,
00301                                                     attributes.type,
00302                                                     arg),
00303                                        result),
00304                      int, -1);
00305 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00306 # else
00307   ACE_UNUSED_ARG (cv);
00308   ACE_UNUSED_ARG (attributes);
00309   ACE_UNUSED_ARG (name);
00310   ACE_UNUSED_ARG (arg);
00311   ACE_NOTSUP_RETURN (-1);
00312 # endif /* ACE_HAS_THREADS */
00313 }

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 ACE_Condition< MUTEX >::ACE_Condition(), cond_init(), event_init(), recursive_mutex_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_INLINE int ACE_OS::cond_signal ACE_cond_t *  cv  ) 
 

Definition at line 335 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(), sema_post(), and ACE_Condition< MUTEX >::signal().

00336 {
00337   ACE_OS_TRACE ("ACE_OS::cond_signal");
00338 # if defined (ACE_HAS_THREADS)
00339 #   if defined (ACE_HAS_PTHREADS)
00340 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00341   ACE_OSCALL_RETURN (pthread_cond_signal (cv), int, -1);
00342 #     else
00343   int result;
00344   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_signal (cv), result),
00345                      int, -1);
00346 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00347 #   elif defined (ACE_HAS_STHREADS)
00348   int result;
00349   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), result), int, -1);
00350 #   endif /* ACE_HAS_STHREADS */
00351 # else
00352   ACE_UNUSED_ARG (cv);
00353   ACE_NOTSUP_RETURN (-1);
00354 # endif /* ACE_HAS_THREADS */
00355 }

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

Definition at line 384 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TIMESPEC_PTR, cond_timedwait(), cond_wait(), ETIME, ETIMEDOUT, and timespec_t.

Referenced by cond_timedwait(), event_timedwait(), recursive_mutex_lock(), sema_wait(), and ACE_Condition< MUTEX >::wait().

00387 {
00388   ACE_OS_TRACE ("ACE_OS::cond_timedwait");
00389 # if defined (ACE_HAS_THREADS)
00390   int result;
00391   timespec_t ts;
00392 
00393   if (timeout != 0)
00394     ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
00395 
00396 #   if defined (ACE_HAS_PTHREADS)
00397 
00398 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00399   if (timeout == 0)
00400     ACE_OSCALL (pthread_cond_wait (cv, external_mutex),
00401                 int, -1, result);
00402   else
00403     {
00404       ACE_OSCALL (pthread_cond_timedwait (cv, external_mutex,
00405                                             (ACE_TIMESPEC_PTR) &ts),
00406                   int, -1, result);
00407     }
00408 
00409 #     else
00410   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00411                                 ? pthread_cond_wait (cv, external_mutex)
00412                                 : pthread_cond_timedwait (cv, external_mutex,
00413                                                             (ACE_TIMESPEC_PTR) &ts),
00414                                 result),
00415               int, -1, result);
00416 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/
00417   // We need to adjust this to make the POSIX and Solaris return
00418   // values consistent.  EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and down)
00419   if (result == -1 &&
00420       (errno == ETIMEDOUT || errno == EAGAIN))
00421     errno = ETIME;
00422 
00423 #   elif defined (ACE_HAS_STHREADS)
00424   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00425                                 ? ::cond_wait (cv, external_mutex)
00426                                 : ::cond_timedwait (cv,
00427                                                     external_mutex,
00428                                                     (timestruc_t*)&ts),
00429                                 result),
00430               int, -1, result);
00431 #   endif /* ACE_HAS_STHREADS */
00432   if (timeout != 0)
00433     timeout->set (ts); // Update the time value before returning.
00434 
00435   return result;
00436 # else
00437   ACE_UNUSED_ARG (cv);
00438   ACE_UNUSED_ARG (external_mutex);
00439   ACE_UNUSED_ARG (timeout);
00440   ACE_NOTSUP_RETURN (-1);
00441 # endif /* ACE_HAS_THREADS */
00442 }

ACE_INLINE int ACE_OS::cond_wait ACE_cond_t *  cv,
ACE_mutex_t *  m
 

Definition at line 358 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(), sema_wait(), and ACE_Condition< MUTEX >::wait().

00360 {
00361   ACE_OS_TRACE ("ACE_OS::cond_wait");
00362 # if defined (ACE_HAS_THREADS)
00363 #   if defined (ACE_HAS_PTHREADS)
00364 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00365   ACE_OSCALL_RETURN (pthread_cond_wait (cv, external_mutex), int, -1);
00366 #     else
00367   int result;
00368   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_wait (cv, external_mutex), result),
00369                      int, -1);
00370 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00371 #   elif defined (ACE_HAS_STHREADS)
00372   int result;
00373   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), result),
00374                      int, -1);
00375 #   endif /* ACE_HAS_PTHREADS */
00376 # else
00377   ACE_UNUSED_ARG (cv);
00378   ACE_UNUSED_ARG (external_mutex);
00379   ACE_NOTSUP_RETURN (-1);
00380 # endif /* ACE_HAS_THREADS */
00381 }

ACE_INLINE int ACE_OS::condattr_destroy ACE_condattr_t &  attributes  ) 
 

Definition at line 132 of file OS_NS_Thread.inl.

Referenced by cond_init().

00133 {
00134 #if defined (ACE_HAS_THREADS)
00135 #   if defined (ACE_HAS_PTHREADS)
00136 
00137 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
00138   pthread_condattr_delete (&attributes);
00139 #     else
00140   pthread_condattr_destroy (&attributes);
00141 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
00142 
00143 #   elif defined (ACE_HAS_STHREADS)
00144   attributes.type = 0;
00145 
00146 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00147   return 0;
00148 # else
00149   ACE_UNUSED_ARG (attributes);
00150   return 0;
00151 # endif /* ACE_HAS_THREADS  */
00152 }

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

Definition at line 155 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and memset().

Referenced by cond_init().

00157 {
00158   ACE_UNUSED_ARG (type);
00159 # if defined (ACE_HAS_THREADS)
00160 #   if defined (ACE_HAS_PTHREADS)
00161   int result = -1;
00162 
00163 #   if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00164       /* Tests show that VxWorks 6.x pthread lib does not only
00165        * require zeroing of mutex/condition objects to function correctly
00166        * but also of the attribute objects.
00167        */
00168       ACE_OS::memset (&attributes, 0, sizeof (attributes));
00169 #   endif
00170   if (
00171 #     if defined  (ACE_HAS_PTHREADS_DRAFT4)
00172       pthread_condattr_create (&attributes) == 0
00173 #     elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7)
00174       ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0
00175 #       if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)
00176       && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type),
00177                            result) == 0
00178 #       endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */
00179 #     else  /* this is draft 6 */
00180       pthread_condattr_init (&attributes) == 0
00181 #       if !defined (ACE_LACKS_CONDATTR_PSHARED)
00182       && pthread_condattr_setpshared (&attributes, type) == 0
00183 #       endif /* ACE_LACKS_CONDATTR_PSHARED */
00184 #       if defined (ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP)
00185       && pthread_condattr_setkind_np (&attributes, type) == 0
00186 #       endif /* ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP */
00187 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
00188       )
00189      result = 0;
00190   else
00191      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00192 
00193   return result;
00194 #   elif defined (ACE_HAS_STHREADS)
00195   attributes.type = type;
00196 
00197   return 0;
00198 
00199 #   else
00200   ACE_UNUSED_ARG (attributes);
00201   ACE_UNUSED_ARG (type);
00202   ACE_NOTSUP_RETURN (-1);
00203 
00204 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00205 
00206 # else
00207   ACE_UNUSED_ARG (attributes);
00208   ACE_UNUSED_ARG (type);
00209   ACE_NOTSUP_RETURN (-1);
00210 # endif /* ACE_HAS_THREADS */
00211 }

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

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

Definition at line 41 of file OS_NS_sys_socket.cpp.

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

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_INLINE int ACE_OS::connect ACE_HANDLE  handle,
struct sockaddr *  addr,
int  addrlen
 

BSD-style (no QoS).

Definition at line 130 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ACE_SOCKET_LEN.

Referenced by ACE_SOCK_SEQPACK_Connector::connect(), ACE_SOCK_Connector::connect(), connect(), and ACE_SOCK_CODgram::open().

00133 {
00134   ACE_OS_TRACE ("ACE_OS::connect");
00135 #if defined (ACE_LACKS_CONNECT)
00136   ACE_UNUSED_ARG (handle);
00137   ACE_UNUSED_ARG (addr);
00138   ACE_UNUSED_ARG (addrlen);
00139   ACE_NOTSUP_RETURN (-1);
00140 #else
00141   ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle,
00142                                   addr,
00143                                   (ACE_SOCKET_LEN) addrlen), int, -1);
00144 #endif /* ACE_LACKS_CONNECT */
00145 }

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_TCHAR, ACE_TEXT_ALWAYS_CHAR, creat(), mode_t, and open().

Referenced by creat(), and 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_TCHAR * ACE_OS::ctime const time_t *  t  ) 
 

Definition at line 97 of file OS_NS_time.inl.

References ACE_OS_TRACE, ACE_TCHAR, asctime(), ACE_Ascii_To_Wide::convert(), ctime(), ctime_buf_size, ctime_r(), and localtime().

Referenced by ctime(), and ctime_r().

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 *  clock,
ACE_TCHAR buf,
int  buflen
 

Definition at line 132 of file OS_NS_time.inl.

References ACE_OS_TRACE, ACE_TCHAR, ctime(), ctime_buf_size, ctime_r(), strsncpy(), and ACE_Ascii_To_Wide::wchar_rep().

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 wchar_t * ACE_OS::cuserid wchar_t *  user,
size_t  maxlen = ACE_MAX_USERID
 

Definition at line 493 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, cuserid(), and strcpy().

00494 {
00495 # if defined (ACE_HAS_WINCE)
00496   ACE_UNUSED_ARG (user);
00497   ACE_UNUSED_ARG (maxlen);
00498   ACE_NOTSUP_RETURN (0);
00499 # elif defined (ACE_WIN32)
00500   BOOL result = GetUserNameW (user, (u_long *) &maxlen);
00501   if (result == FALSE)
00502     ACE_FAIL_RETURN (0);
00503   else
00504     return user;
00505 # else /* ACE_WIN32 */
00506   char *char_user;
00507   wchar_t *result = 0;
00508 
00509   ACE_NEW_RETURN (char_user, char[maxlen + 1], 0);
00510 
00511   if (ACE_OS::cuserid (char_user, maxlen))
00512     {
00513       ACE_OS::strcpy (user, ACE_Ascii_To_Wide (char_user).wchar_rep ());
00514       result = user;
00515     }
00516 
00517   delete [] char_user;
00518 
00519   return result;
00520 # endif /* ACE_WIN32 */
00521 }

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

Definition at line 388 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, strcpy(), and strlen().

Referenced by cuserid().

00389 {
00390   ACE_OS_TRACE ("ACE_OS::cuserid");
00391 #if defined (ACE_VXWORKS)
00392   ACE_UNUSED_ARG (maxlen);
00393   if (user == 0)
00394     {
00395       // Require that the user field be non-null, i.e., don't
00396       // allocate or use static storage.
00397       ACE_NOTSUP_RETURN (0);
00398     }
00399   else
00400     {
00401       ::remCurIdGet (user, 0);
00402       return user;
00403     }
00404 #elif defined (__QNXNTO__) || defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE)
00405   ACE_UNUSED_ARG (user);
00406   ACE_UNUSED_ARG (maxlen);
00407   ACE_NOTSUP_RETURN (0);
00408 #elif defined (ACE_WIN32)
00409   BOOL result = GetUserNameA (user, (u_long *) &maxlen);
00410   if (result == FALSE)
00411     ACE_FAIL_RETURN (0);
00412   else
00413     return user;
00414 #elif defined (ACE_HAS_ALT_CUSERID)
00415 #  if defined (ACE_LACKS_PWD_FUNCTIONS)
00416 #    error Cannot use alternate cuserid() without POSIX password functions!
00417 #  endif  /* ACE_LACKS_PWD_FUNCTIONS */
00418 
00419   // POSIX.1 dropped the cuserid() function.
00420   // GNU GLIBC and other platforms correctly deprecate the cuserid()
00421   // function.
00422 
00423   if (maxlen == 0)
00424     {
00425       // It doesn't make sense to have a zero length user ID.
00426       errno = EINVAL;
00427       return 0;
00428     }
00429 
00430   struct passwd *pw = 0;
00431 
00432   // Make sure the file pointer is at the beginning of the password file
00433   ::setpwent ();
00434   // Should use ACE_OS::setpwent() but I didn't want to move this
00435   // method after it.
00436 
00437   // Use the effective user ID to determine the user name.
00438   pw = ::getpwuid (::geteuid ());
00439 
00440   // Make sure the password file is closed.
00441   ::endpwent ();
00442 
00443   if (pw == 0)
00444     {
00445       errno = ENOENT;
00446       return 0;
00447     }
00448 
00449   size_t max_length = 0;
00450   char *userid = 0;
00451 
00452   if (user == 0)
00453     {
00454       // Not reentrant/thread-safe, but nothing else can be done if a
00455       // zero pointer was passed in as the destination.
00456 
00457 #if defined (_POSIX_SOURCE) && defined (L_cuserid)
00458       const size_t ACE_L_cuserid = L_cuserid;
00459 #else
00460       const size_t ACE_L_cuserid = 9;  // 8 character user ID + NULL
00461 #endif  /* _POSIX_SOURCE */
00462 
00463       static char tmp[ACE_L_cuserid] = { '\0' };
00464       max_length = ACE_L_cuserid - 1; // Do not include NULL in length
00465 
00466       userid = tmp;
00467     }
00468   else
00469     {
00470       max_length = maxlen;
00471       userid = user;
00472     }
00473 
00474   // Extract the user name from the passwd structure.
00475   if (ACE_OS::strlen (pw->pw_name) <= max_length)
00476     {
00477       return ACE_OS::strcpy (userid, pw->pw_name);
00478     }
00479   else
00480     {
00481       errno = ENOSPC;  // Buffer is not large enough.
00482       return 0;
00483     }
00484 #else
00485   // Hackish because of missing buffer size!
00486   ACE_UNUSED_ARG (maxlen);
00487   ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0);
00488 #endif /* ACE_VXWORKS */
00489 }

ACE_NAMESPACE_INLINE_FUNCTION LPSECURITY_ATTRIBUTES default_win32_security_attributes LPSECURITY_ATTRIBUTES   ) 
 

Default Win32 Security Attributes definition.

ACE_NAMESPACE_INLINE_FUNCTION LPSECURITY_ATTRIBUTES default_win32_security_attributes_r LPSECURITY_ATTRIBUTES  ,
LPSECURITY_ATTRIBUTES  ,
SECURITY_DESCRIPTOR * 
 

Referenced by mmap(), and sema_init().

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_Filecache_Object::update().

00215 {
00216   return ::ace_difftime (t1, t0);
00217 }

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_SHLIB_HANDLE, ACE_TEXT, dlclose(), and dlsym().

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

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_TCHAR, ACE_TEXT_CHAR_TO_TCHAR, ACE_TEXT_FormatMessage, dlerror(), sprintf(), strerror(), and strncpy().

Referenced by dlerror(), 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   ACE_OSCALL_RETURN (::strerror(errno), char *, 0);
00099 # elif defined (ACE_WIN32)
00100   static ACE_TCHAR buf[128];
00101 #   if defined (ACE_HAS_PHARLAP)
00102   ACE_OS::sprintf (buf, "error code %d", GetLastError());
00103 #   else
00104   ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
00105                           0,
00106                           ::GetLastError (),
00107                           0,
00108                           buf,
00109                           sizeof buf / sizeof buf[0],
00110                           0);
00111 #   endif /* ACE_HAS_PHARLAP */
00112   return buf;
00113 # else
00114   ACE_NOTSUP_RETURN (0);
00115 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00116 }

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

Definition at line 119 of file OS_NS_dlfcn.inl.

References ACE_DEFAULT_FILE_PERMS, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_HANDLE, ACE_TCHAR, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_LoadLibrary, close(), dlsym(), last_error(), and open().

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

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

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

Definition at line 201 of file OS_NS_dlfcn.inl.

References ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_HANDLE, ACE_SHLIB_INVALID_HANDLE, ACE_TCHAR, ACE_Wide_To_Ascii::char_rep(), dlsym(), strcpy(), strlen(), and ACE_Ascii_To_Wide::wchar_rep().

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

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

ACE_INLINE ACE_HANDLE ACE_OS::dup ACE_HANDLE  handle  ) 
 

Definition at line 193 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, 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  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_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::endpwent void   ) 
 

Definition at line 12 of file OS_NS_pwd.inl.

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

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 148 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, and ACE_SOCKCALL_RETURN.

00151 {
00152 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00153 
00154   ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols,
00155                                            protocol_buffer,
00156                                            buffer_length),
00157                        int,
00158                        SOCKET_ERROR);
00159 
00160 #else
00161   ACE_UNUSED_ARG (protocols);
00162   ACE_UNUSED_ARG (protocol_buffer);
00163   ACE_UNUSED_ARG (buffer_length);
00164   ACE_NOTSUP_RETURN (-1);
00165 #endif /* ACE_HAS_WINSOCK2 */
00166 }

int ACE_OS::event_destroy ACE_event_t *  event  ) 
 

Definition at line 2401 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(), and thr_yield().

Referenced by ACE_Event::remove(), sema_destroy(), and sema_init().

02402 {
02403 #if defined (ACE_WIN32)
02404   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
02405 #elif defined (ACE_HAS_THREADS)
02406   if (event->eventdata_)
02407     {
02408       // mutex_destroy()/cond_destroy() are called in a loop if the object
02409       // is BUSY.  This avoids conditions where we fail to destroy these
02410       // objects because at time of destroy they were just being used in
02411       // another thread possibly causing deadlocks later on if they keep
02412       // being used after we're gone.
02413 
02414       if (event->eventdata_->type_ == USYNC_PROCESS)
02415         {
02416           if (event->name_)
02417             {
02418               // Only destroy the event data if we're the ones who initialized
02419               // it.
02420 
02421               int r1, r2;
02422 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02423         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02424      (!defined (ACE_USES_FIFO_SEM) && \
02425         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02426               // First destroy the mutex so locking after this will return
02427               // errors.
02428               while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02429                      && errno == EBUSY)
02430                 {
02431                   ACE_OS::thr_yield ();
02432                 }
02433 # else
02434               r1 = ACE_OS::sema_destroy(&event->lock_);
02435 # endif
02436 
02437 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02438     (!defined (ACE_USES_FIFO_SEM) && \
02439       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02440               // Now fix event to manual reset, raise signal and broadcast
02441               // until is's possible to destroy the condition.
02442               event->eventdata_->manual_reset_ = 1;
02443               while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02444                      && errno == EBUSY)
02445                 {
02446                   event->eventdata_->is_signaled_ = 1;
02447                   ACE_OS::cond_broadcast (&event->eventdata_->condition_);
02448                   ACE_OS::thr_yield ();
02449                 }
02450 # else
02451               r2 = ACE_OS::sema_destroy(&event->semaphore_);
02452 # endif
02453               ACE_OS::munmap (event->eventdata_,
02454                               sizeof (ACE_eventdata_t));
02455               ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_));
02456               ACE_OS::free (event->name_);
02457               return r1 != 0 || r2 != 0 ? -1 : 0;
02458             }
02459           else
02460             {
02461               ACE_OS::munmap (event->eventdata_,
02462                               sizeof (ACE_eventdata_t));
02463 # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
02464         (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
02465      (defined (ACE_USES_FIFO_SEM) || \
02466         (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
02467               ACE_OS::sema_destroy(&event->lock_);
02468 # endif
02469 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02470     (!defined (ACE_USES_FIFO_SEM) && \
02471       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02472               return 0;
02473 # else
02474               return ACE_OS::sema_destroy(&event->semaphore_);
02475 # endif
02476             }
02477         }
02478       else
02479         {
02480           int r1, r2;
02481           // First destroy the mutex so locking after this will return errors.
02482 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02483         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02484      (!defined (ACE_USES_FIFO_SEM) && \
02485         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02486       // first destroy the mutex so locking after this will return errors
02487           while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02488                  && errno == EBUSY)
02489             {
02490               ACE_OS::thr_yield ();
02491             }
02492 # else
02493           r1 = ACE_OS::sema_destroy(&event->lock_);
02494 # endif
02495 
02496 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02497     (!defined (ACE_USES_FIFO_SEM) && \
02498       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02499           // Now fix event to manual reset, raise signal and broadcast until
02500           // it's possible to destroy the condition.
02501           event->eventdata_->manual_reset_ = 1;
02502           while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02503                  && errno == EBUSY)
02504             {
02505               event->eventdata_->is_signaled_ = 1;
02506               ACE_OS::cond_broadcast (&event->eventdata_->condition_);
02507               ACE_OS::thr_yield ();
02508             }
02509 # else
02510           r2 = ACE_OS::sema_destroy(&event->semaphore_);
02511 # endif
02512           delete event->eventdata_;
02513           return r1 != 0 || r2 != 0 ? -1 : 0;
02514         }
02515     }
02516 
02517   return 0;
02518 #else
02519   ACE_UNUSED_ARG (event);
02520   ACE_NOTSUP_RETURN (-1);
02521 #endif /* ACE_WIN32 */
02522 }

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

Definition at line 454 of file OS_NS_Thread.inl.

References ACE_FAIL_RETURN, and event_init().

00461 {
00462 #if defined (ACE_WIN32)
00463   ACE_UNUSED_ARG (type);
00464   ACE_UNUSED_ARG (arg);
00465   SECURITY_ATTRIBUTES sa_buffer;
00466   SECURITY_DESCRIPTOR sd_buffer;
00467   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
00468       (sa, &sa_buffer, &sd_buffer),
00469   manual_reset,
00470   initial_state,
00471   name);
00472   if (*event == 0)
00473     ACE_FAIL_RETURN (-1);
00474 
00475   return 0;
00476 #else  /* ACE_WIN32 */
00477   return ACE_OS::event_init (event,
00478                              manual_reset,
00479                              initial_state,
00480                              type,
00481                              ACE_Wide_To_Ascii (name).char_rep (),
00482                              arg,
00483                              sa);
00484 #endif /* ACE_WIN32 */
00485 }

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

References ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, close(), cond_init(), ftruncate(), MAP_FAILED, MAP_SHARED, MAXPATHLEN, mmap(), mutex_init(), PROT_RDWR, sema_init(), sema_post(), shm_open(), shm_unlink(), strcat(), strdup(), strncpy(), and strsncpy().

Referenced by ACE_Event::ACE_Event(), event_init(), and sema_init().

02532 {
02533 #if defined (ACE_WIN32)
02534   ACE_UNUSED_ARG (type);
02535   ACE_UNUSED_ARG (arg);
02536   SECURITY_ATTRIBUTES sa_buffer;
02537   SECURITY_DESCRIPTOR sd_buffer;
02538 # if defined (ACE_HAS_WINCE)
02539   // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
02540   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
02541                              (sa, &sa_buffer, &sd_buffer),
02542                            manual_reset,
02543                            initial_state,
02544                            ACE_Ascii_To_Wide (name).wchar_rep ());
02545 # else /* ACE_HAS_WINCE */
02546   *event = ::CreateEventA (ACE_OS::default_win32_security_attributes_r
02547                              (sa, &sa_buffer, &sd_buffer),
02548                            manual_reset,
02549                            initial_state,
02550                            name);
02551 # endif /* ACE_HAS_WINCE */
02552   if (*event == 0)
02553     ACE_FAIL_RETURN (-1);
02554   else
02555     return 0;
02556 #elif defined (ACE_HAS_THREADS)
02557   ACE_UNUSED_ARG (sa);
02558   event->eventdata_ = 0;
02559   ACE_eventdata_t* evtdata;
02560 
02561   if (type == USYNC_PROCESS)
02562     {
02563       const char *name_p = 0;
02564 #  if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH)
02565       char adj_name[MAXPATHLEN];
02566       if (name[0] != '/')
02567         {
02568           adj_name[0] = '/';
02569           ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1);
02570           name_p = adj_name;
02571         }
02572       else
02573         {
02574           name_p = name;
02575         }
02576 #  else
02577       name_p = name;
02578 #  endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */
02579       int owner = 0;
02580       // Let's see if the shared memory entity already exists.
02581       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
02582                                         O_RDWR | O_CREAT | O_EXCL,
02583                                         ACE_DEFAULT_FILE_PERMS);
02584       if (fd == ACE_INVALID_HANDLE)
02585         {
02586           if (errno == EEXIST)
02587             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
02588                                    O_RDWR | O_CREAT,
02589                                    ACE_DEFAULT_FILE_PERMS);
02590           if (fd == ACE_INVALID_HANDLE)   // Still can't get it.
02591             return -1;
02592         }
02593       else
02594         {
02595           // We own this shared memory object!  Let's set its size.
02596           if (ACE_OS::ftruncate (fd, sizeof (ACE_eventdata_t)) == -1)
02597             {
02598               ACE_OS::close (fd);
02599               return -1;
02600             }
02601           owner = 1;
02602         }
02603 
02604       evtdata =
02605         (ACE_eventdata_t *) ACE_OS::mmap (0,
02606                                           sizeof (ACE_eventdata_t),
02607                                           PROT_RDWR,
02608                                           MAP_SHARED,
02609                                           fd,
02610                                           0);
02611       ACE_OS::close (fd);
02612       if (evtdata == MAP_FAILED)
02613         {
02614           if (owner)
02615             ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02616           return -1;
02617         }
02618 
02619       if (owner)
02620         {
02621           event->name_ = ACE_OS::strdup (name_p);
02622           if (event->name_ == 0)
02623             {
02624               ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
02625               return -1;
02626             }
02627           event->eventdata_ = evtdata;
02628           event->eventdata_->type_ = type;
02629           event->eventdata_->manual_reset_ = manual_reset;
02630           event->eventdata_->is_signaled_ = initial_state;
02631           event->eventdata_->auto_event_signaled_ = false;
02632           event->eventdata_->waiting_threads_ = 0;
02633           event->eventdata_->signal_count_ = 0;
02634 
02635 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02636     (!defined (ACE_USES_FIFO_SEM) && \
02637       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02638           int result = ACE_OS::cond_init (&event->eventdata_->condition_,
02639                                           static_cast<short> (type),
02640                                           name,
02641                                           arg);
02642 # else
02643           char   sem_name[128];
02644           ACE_OS::strncpy (sem_name,
02645                            name,
02646                            sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
02647           ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
02648           int result = ACE_OS::sema_init (&event->semaphore_,
02649                                           0,
02650                                           type,
02651                                           sem_name,
02652                                           arg);
02653 # endif
02654           if (result == 0)
02655 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02656         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02657      (!defined (ACE_USES_FIFO_SEM) && \
02658         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02659             result = ACE_OS::mutex_init (&event->eventdata_->lock_,
02660                                          type,
02661                                          name,
02662                                          (ACE_mutexattr_t *) arg);
02663 # else
02664           {
02665             char   lck_name[128];
02666             ACE_OS::strncpy
02667               (lck_name,
02668                name,
02669                sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
02670             ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
02671             result = ACE_OS::sema_init (&event->lock_,
02672                                         0,
02673                                         type,
02674                                         lck_name,
02675                                         arg);
02676             if (result == 0)
02677               result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */
02678           }
02679 # endif
02680           return result;
02681         }
02682       else
02683         {
02684           int result = 0;
02685 
02686           event->name_ = 0;
02687           event->eventdata_ = evtdata;
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           char   sem_name[128];
02692           ACE_OS::strncpy (sem_name,
02693                            name,
02694                            sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
02695           ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
02696           result = ACE_OS::sema_init(&event->semaphore_,
02697                                      0,
02698                                      type,
02699                                      sem_name,
02700                                      arg);
02701 # endif
02702 
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           if (result == 0)
02708             {
02709               char   lck_name[128];
02710               ACE_OS::strncpy
02711                 (lck_name,
02712                  name,
02713                  sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
02714               ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
02715               result = ACE_OS::sema_init (&event->lock_,
02716                                           0,
02717                                           type,
02718                                           lck_name,
02719                                           arg);
02720             }
02721 # endif
02722           return result;
02723         }
02724     }
02725   else
02726     {
02727       ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1);
02728       event->name_ = 0;
02729       event->eventdata_ = evtdata;
02730       event->eventdata_->type_ = type;
02731       event->eventdata_->manual_reset_ = manual_reset;
02732       event->eventdata_->is_signaled_ = initial_state;
02733       event->eventdata_->auto_event_signaled_ = false;
02734       event->eventdata_->waiting_threads_ = 0;
02735       event->eventdata_->signal_count_ = 0;
02736 
02737 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02738     (!defined (ACE_USES_FIFO_SEM) && \
02739       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02740       int result = ACE_OS::cond_init (&event->eventdata_->condition_,
02741                                       static_cast<short> (type),
02742                                       name,
02743                                       arg);
02744 # else
02745       int result = ACE_OS::sema_init (&event->semaphore_,
02746                                       0,
02747                                       type,
02748                                       name,
02749                                       arg);
02750 # endif
02751       if (result == 0)
02752 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02753         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02754      (!defined (ACE_USES_FIFO_SEM) && \
02755         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02756         result = ACE_OS::mutex_init (&event->eventdata_->lock_,
02757                                      type,
02758                                      name,
02759                                      (ACE_mutexattr_t *) arg);
02760 # else
02761       result = ACE_OS::sema_init (&event->lock_,
02762                                   0,
02763                                   type,
02764                                   name,
02765                                   arg);
02766       if (result == 0)
02767         result = ACE_OS::sema_post(&event->lock_);    /* initially unlock */
02768 # endif
02769 
02770       return result;
02771     }
02772 #else
02773   ACE_UNUSED_ARG (event);
02774   ACE_UNUSED_ARG (manual_reset);
02775   ACE_UNUSED_ARG (initial_state);
02776   ACE_UNUSED_ARG (type);
02777   ACE_UNUSED_ARG (name);
02778   ACE_UNUSED_ARG (arg);
02779   ACE_UNUSED_ARG (sa);
02780   ACE_NOTSUP_RETURN (-1);
02781 #endif /* ACE_WIN32 */
02782 }

int ACE_OS::event_pulse ACE_event_t *  event  ) 
 

Definition at line 2785 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), sema_post(), sema_wait(), and thr_yield().

Referenced by ACE_Event::pulse().

02786 {
02787 #if defined (ACE_WIN32)
02788   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
02789 #elif defined (ACE_HAS_THREADS)
02790   int result = 0;
02791   int error = 0;
02792 
02793   // grab the lock first
02794 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02795         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02796      (!defined (ACE_USES_FIFO_SEM) && \
02797         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02798   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02799 # else
02800   if (ACE_OS::sema_wait (&event->lock_) == 0)
02801 # endif
02802   {
02803     if (event->eventdata_->waiting_threads_ > 0)
02804     {
02805       // Manual-reset event.
02806       if (event->eventdata_->manual_reset_ == 1)
02807       {
02808         // Wakeup all waiters.
02809 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !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         if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02813         {
02814           result = -1;
02815           error = errno;
02816         }
02817         if (result == 0)
02818           event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
02819 # else
02820         event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
02821         for (unsigned long i=0; i<event->eventdata_->signal_count_ ;++i)
02822           if (ACE_OS::sema_post(&event->semaphore_) != 0)
02823           {
02824             event->eventdata_->signal_count_ = 0;
02825             result = -1;
02826             error = errno;
02827           }
02828 
02829         if (result == 0)
02830           while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0)
02831             ACE_OS::thr_yield ();
02832 # endif
02833       }
02834       // Auto-reset event: wakeup one waiter.
02835       else
02836       {
02837 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02838     (!defined (ACE_USES_FIFO_SEM) && \
02839       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02840         if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
02841 # else
02842         if (ACE_OS::sema_post(&event->semaphore_) != 0)
02843 # endif
02844         {
02845           result = -1;
02846           error = errno;
02847         }
02848 
02849         event->eventdata_->auto_event_signaled_ = true;
02850       }
02851     }
02852 
02853     // Reset event.
02854     event->eventdata_->is_signaled_ = 0;
02855 
02856     // Now we can let go of the lock.
02857 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02858         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02859      (!defined (ACE_USES_FIFO_SEM) && \
02860         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02861     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02862 # else
02863     ACE_OS::sema_post (&event->lock_);
02864 # endif
02865     if (result == -1)
02866       // Reset errno in case mutex_unlock() also fails...
02867       errno = error;
02868   }
02869   else
02870     result = -1;
02871   return result;
02872 #else
02873   ACE_UNUSED_ARG (event);
02874   ACE_NOTSUP_RETURN (-1);
02875 #endif /* ACE_WIN32 */
02876 }

int ACE_OS::event_reset ACE_event_t *  event  ) 
 

Definition at line 2879 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().

02880 {
02881 #if defined (ACE_WIN32)
02882   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
02883 #elif defined (ACE_HAS_THREADS)
02884   int result = 0;
02885 
02886   // Grab the lock first.
02887 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02888         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02889      (!defined (ACE_USES_FIFO_SEM) && \
02890         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02891   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02892 # else
02893   if (ACE_OS::sema_wait (&event->lock_) == 0)
02894 # endif
02895   {
02896     // Reset event.
02897     event->eventdata_->is_signaled_ = 0;
02898     event->eventdata_->auto_event_signaled_ = false;
02899 
02900     // Now we can let go of the lock.
02901 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02902         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02903      (!defined (ACE_USES_FIFO_SEM) && \
02904         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02905     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02906 # else
02907     ACE_OS::sema_post (&event->lock_);
02908 # endif
02909   }
02910   else
02911     result = -1;
02912   return result;
02913 #else
02914   ACE_UNUSED_ARG (event);
02915   ACE_NOTSUP_RETURN (-1);
02916 #endif /* ACE_WIN32 */
02917 }

int ACE_OS::event_signal ACE_event_t *  event  ) 
 

Definition at line 2920 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().

02921 {
02922 #if defined (ACE_WIN32)
02923   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
02924 #elif defined (ACE_HAS_THREADS)
02925   int result = 0;
02926   int error = 0;
02927 
02928   // grab the lock first
02929 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02930         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02931      (!defined (ACE_USES_FIFO_SEM) && \
02932         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02933   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02934 # else
02935   if (ACE_OS::sema_wait (&event->lock_) == 0)
02936 # endif
02937   {
02938     // Manual-reset event.
02939     if (event->eventdata_->manual_reset_ == 1)
02940     {
02941       // wakeup all
02942 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02943     (!defined (ACE_USES_FIFO_SEM) && \
02944       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02945       if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02946       {
02947         result = -1;
02948         error = errno;
02949       }
02950 # else
02951       if (ACE_OS::sema_post(&event->semaphore_) != 0)
02952       {
02953         result = -1;
02954         error = errno;
02955       }
02956 # endif
02957 
02958       if (result == 0)
02959         // signal event
02960         event->eventdata_->is_signaled_ = 1;
02961     }
02962     // Auto-reset event
02963     else
02964     {
02965       if (event->eventdata_->waiting_threads_ == 0)
02966         // No waiters: signal event.
02967         event->eventdata_->is_signaled_ = 1;
02968       // Waiters: wakeup one waiter.
02969 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02970     (!defined (ACE_USES_FIFO_SEM) && \
02971       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02972       else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
02973 # else
02974       else if (ACE_OS::sema_post(&event->semaphore_) != 0)
02975 # endif
02976       {
02977         result = -1;
02978         error = errno;
02979       }
02980 
02981       event->eventdata_->auto_event_signaled_ = true;
02982     }
02983 
02984     // Now we can let go of the lock.
02985 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02986         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02987      (!defined (ACE_USES_FIFO_SEM) && \
02988         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02989     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02990 # else
02991     ACE_OS::sema_post (&event->lock_);
02992 # endif
02993 
02994     if (result == -1)
02995       // Reset errno in case mutex_unlock() also fails...
02996       errno = error;
02997   }
02998   else
02999     result = -1;
03000 
03001   return result;
03002 #else
03003   ACE_UNUSED_ARG (event);
03004   ACE_NOTSUP_RETURN (-1);
03005 #endif /* ACE_WIN32 */
03006 }

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

Definition at line 3009 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, cond_timedwait(), ETIME, ETIMEDOUT, gettimeofday(), ACE_Time_Value::msec(), mutex_lock(), mutex_unlock(), ACE_Time_Value::sec(), sema_post(), sema_wait(), set_errno_to_last_error(), and ACE_Time_Value::usec().

Referenced by ACE_Event::wait().

03012 {
03013 #if defined (ACE_WIN32)
03014   DWORD result;
03015 
03016   if (timeout == 0)
03017     // Wait forever
03018     result = ::WaitForSingleObject (*event, INFINITE);
03019   else if (timeout->sec () == 0 && timeout->usec () == 0)
03020     // Do a "poll".
03021     result = ::WaitForSingleObject (*event, 0);
03022   else
03023   {
03024       // Wait for upto <relative_time> number of milliseconds.  Note
03025       // that we must convert between absolute time (which is passed
03026       // as a parameter) and relative time (which is what
03027       // WaitForSingleObjects() expects).
03028       // <timeout> parameter is given in absolute or relative value
03029       // depending on parameter <use_absolute_time>.
03030     int msec_timeout;
03031     if (use_absolute_time)
03032     {
03033           // Time is given in absolute time, we should use
03034           // gettimeofday() to calculate relative time
03035       ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
03036 
03037           // Watchout for situations where a context switch has caused
03038           // the current time to be > the timeout.  Thanks to Norbert
03039           // Rapp <NRapp@nexus-informatics.de> for pointing this.
03040       if (relative_time < ACE_Time_Value::zero)
03041         msec_timeout = 0;
03042       else
03043         msec_timeout = relative_time.msec ();
03044     }
03045     else
03046          // time is given in relative time, just convert it into
03047          // milliseconds and use it
03048       msec_timeout = timeout->msec ();
03049     result = ::WaitForSingleObject (*event, msec_timeout);
03050   }
03051 
03052   switch (result)
03053   {
03054     case WAIT_OBJECT_0:
03055       return 0;
03056     case WAIT_TIMEOUT:
03057       errno = ETIME;
03058       return -1;
03059     default:
03060       // This is a hack, we need to find an appropriate mapping...
03061       ACE_OS::set_errno_to_last_error ();
03062       return -1;
03063   }
03064 #elif defined (ACE_HAS_THREADS)
03065   int result = 0;
03066   int error = 0;
03067 
03068   // grab the lock first
03069 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03070         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03071      (!defined (ACE_USES_FIFO_SEM) && \
03072         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03073   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
03074 # else
03075   if (ACE_OS::sema_wait (&event->lock_) == 0)
03076 # endif
03077   {
03078     if (event->eventdata_->is_signaled_ == 1)
03079     // event is currently signaled
03080     {
03081       if (event->eventdata_->manual_reset_ == 0)
03082       {
03083         // AUTO: reset state
03084         event->eventdata_->is_signaled_ = 0;
03085         event->eventdata_->auto_event_signaled_ = false;
03086       }
03087     }
03088     else
03089     // event is currently not signaled
03090     {
03091       event->eventdata_->waiting_threads_++;
03092 
03093       ACE_Time_Value absolute_timeout = *timeout;
03094 
03095       // cond_timewait() expects absolute time, check
03096       // <use_absolute_time> flag.
03097       if (use_absolute_time == 0)
03098         absolute_timeout += ACE_OS::gettimeofday ();
03099 
03100       while (event->eventdata_->is_signaled_ == 0 &&
03101              event->eventdata_->auto_event_signaled_ == false)
03102       {
03103 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03104     (!defined (ACE_USES_FIFO_SEM) && \
03105       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03106         if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
03107                                     &event->eventdata_->lock_,
03108                                     &absolute_timeout) != 0)
03109         {
03110           result = -1;
03111           error = errno;
03112           break;
03113         }
03114 
03115         if (event->eventdata_->signal_count_ > 0)
03116         {
03117           event->eventdata_->signal_count_--;
03118           break;
03119         }
03120 # else
03121 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03122       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03123         if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
03124 #   else
03125         if (ACE_OS::sema_post (&event->lock_) != 0)
03126 #   endif
03127         {
03128           event->eventdata_->waiting_threads_--;
03129           return -1;
03130         }
03131 
03132         if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0)
03133         {
03134           result = -1;
03135           if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX)
03136             error = ETIME;
03137           else
03138             error = errno;
03139         }
03140 
03141         bool signalled = false;
03142         if (result == 0 && event->eventdata_->signal_count_ > 0)
03143         {
03144           event->eventdata_->signal_count_--;
03145           signalled = true;
03146         }
03147 
03148 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03149       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03150         if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
03151 #   else
03152         if (ACE_OS::sema_wait (&event->lock_) != 0)
03153 #   endif
03154         {
03155           event->eventdata_->waiting_threads_--;  // yes, I know it's not save
03156           return -1;
03157         }
03158 
03159         if (result)
03160           break;
03161 
03162         if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
03163           if (ACE_OS::sema_post(&event->semaphore_) != 0)
03164           {
03165             result = -1;
03166             error = errno;
03167             break;
03168           }
03169 
03170         if (signalled)
03171           break;
03172 # endif
03173       }
03174 
03175       // Reset the auto_event_signaled_ to false now that we have
03176       // woken up.
03177       if (event->eventdata_->auto_event_signaled_ == true)
03178         event->eventdata_->auto_event_signaled_ = false;
03179 
03180       event->eventdata_->waiting_threads_--;
03181     }
03182 
03183     // Now we can let go of the lock.
03184 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03185         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03186      (!defined (ACE_USES_FIFO_SEM) && \
03187         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03188     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03189 # else
03190     ACE_OS::sema_post (&event->lock_);
03191 # endif
03192 
03193     if (result == -1)
03194       // Reset errno in case mutex_unlock() also fails...
03195       errno = error;
03196   }
03197   else
03198     result = -1;
03199   return result;
03200 #else
03201   ACE_UNUSED_ARG (event);
03202   ACE_UNUSED_ARG (timeout);
03203   ACE_UNUSED_ARG (use_absolute_time);
03204   ACE_NOTSUP_RETURN (-1);
03205 #endif /* ACE_WIN32 */
03206 }

int ACE_OS::event_wait ACE_event_t *  event  ) 
 

Definition at line 3209 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 ACE_Event::wait().

03210 {
03211 #if defined (ACE_WIN32)
03212   switch (::WaitForSingleObject (*event, INFINITE))
03213 {
03214   case WAIT_OBJECT_0:
03215     return 0;
03216   default:
03217     ACE_OS::set_errno_to_last_error ();
03218     return -1;
03219 }
03220 #elif defined (ACE_HAS_THREADS)
03221   int result = 0;
03222   int error = 0;
03223 
03224   // grab the lock first
03225 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03226         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03227      (!defined (ACE_USES_FIFO_SEM) && \
03228         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03229   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
03230 # else
03231   if (ACE_OS::sema_wait (&event->lock_) == 0)
03232 # endif
03233   {
03234     if (event->eventdata_->is_signaled_ == 1)
03235     // Event is currently signaled.
03236     {
03237       if (event->eventdata_->manual_reset_ == 0)
03238         // AUTO: reset state
03239         event->eventdata_->is_signaled_ = 0;
03240     }
03241     else // event is currently not signaled
03242     {
03243       event->eventdata_->waiting_threads_++;
03244 
03245       while (event->eventdata_->is_signaled_ == 0 &&
03246              event->eventdata_->auto_event_signaled_ == false)
03247       {
03248 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03249     (!defined (ACE_USES_FIFO_SEM) && \
03250       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03251         if (ACE_OS::cond_wait (&event->eventdata_->condition_,
03252                                &event->eventdata_->lock_) != 0)
03253         {
03254           result = -1;
03255           error = errno;
03256           // Something went wrong...
03257           break;
03258         }
03259         if (event->eventdata_->signal_count_ > 0)
03260         {
03261           event->eventdata_->signal_count_--;
03262           break;
03263         }
03264 # else
03265 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03266       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03267         if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
03268 #   else
03269         if (ACE_OS::sema_post (&event->lock_) != 0)
03270 #   endif
03271         {
03272           event->eventdata_->waiting_threads_--;
03273           return -1;
03274         }
03275 
03276         if (ACE_OS::sema_wait(&event->semaphore_) !=0)
03277         {
03278           result = -1;
03279           error = errno;
03280         }
03281 
03282         bool signalled = false;
03283         if (result == 0 && event->eventdata_->signal_count_ > 0)
03284         {
03285           event->eventdata_->signal_count_--;
03286           signalled = true;
03287         }
03288 
03289 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03290       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03291         if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
03292 #   else
03293         if (ACE_OS::sema_wait (&event->lock_) != 0)
03294 #   endif
03295         {
03296           event->eventdata_->waiting_threads_--;
03297           return -1;
03298         }
03299 
03300         if (result)
03301           break;
03302 
03303         if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
03304           if (ACE_OS::sema_post(&event->semaphore_) != 0)
03305           {
03306             result = -1;
03307             error = errno;
03308             break;
03309           }
03310 
03311         if (signalled)
03312           break;
03313 # endif
03314     }
03315 
03316     // Reset it since we have woken up.
03317     if (event->eventdata_->auto_event_signaled_ == true)
03318       event->eventdata_->auto_event_signaled_ = false;
03319 
03320     event->eventdata_->waiting_threads_--;
03321   }
03322 
03323   // Now we can let go of the lock.
03324 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03325         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03326      (!defined (ACE_USES_FIFO_SEM) && \
03327         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03328     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03329 # else
03330     ACE_OS::sema_post (&event->lock_);
03331 # endif
03332 
03333   if (result == -1)
03334     // Reset errno in case mutex_unlock() also fails...
03335     errno = error;
03336 }
03337   else
03338     result = -1;
03339   return result;
03340 #else
03341   ACE_UNUSED_ARG (event);
03342   ACE_NOTSUP_RETURN (-1);
03343 #endif /* ACE_WIN32 */
03344 }

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

Definition at line 174 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00175 {
00176   ACE_OS_TRACE ("ACE_OS::execl");
00177   ACE_NOTSUP_RETURN (-1);
00178   // Need to write this code.
00179   // ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00180 }

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

Definition at line 183 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00184 {
00185   ACE_OS_TRACE ("ACE_OS::execle");
00186   ACE_NOTSUP_RETURN (-1);
00187   // Need to write this code.
00188   //  ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
00189 }

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

Definition at line 192 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00193 {
00194   ACE_OS_TRACE ("ACE_OS::execlp");
00195   ACE_NOTSUP_RETURN (-1);
00196   // Need to write this code.
00197   //  ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00198 }

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 }

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 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_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::fclose FILE *  fp  ) 
 

Definition at line 526 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by access(), ACE::count_interfaces(), ACE_Ini_ImpExp::export_config(), ACE_Registry_ImpExp::export_config(), ACE::get_ip_interfaces(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::init(), 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().

00527 {
00528   ACE_OS_TRACE ("ACE_OS::fclose");
00529   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fclose (fp), int, -1);
00530 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE 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(), 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 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 FILE * ACE_OS::fdopen ACE_HANDLE  handle,
const ACE_TCHAR mode
 

Definition at line 533 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and ACE_TEXT_ALWAYS_WCHAR.

00534 {
00535   ACE_OS_TRACE ("ACE_OS::fdopen");
00536 #if defined (ACE_HAS_WINCE)
00537   ACE_OSCALL_RETURN (::_wfdopen (handle, ACE_TEXT_ALWAYS_WCHAR (mode)),
00538                      FILE*,
00539                      0);
00540 #elif defined (ACE_WIN32)
00541   // kernel file handle -> FILE* conversion...
00542   // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost
00543 
00544   FILE * file = 0;
00545 
00546   int const crt_handle = ::_open_osfhandle (intptr_t (handle), 0);
00547 
00548   if (crt_handle != -1)
00549     {
00550 #   if defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)
00551       file = ::_fdopen (crt_handle, const_cast<ACE_TCHAR *> (mode));
00552 #   elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR)
00553       file = ::_wfdopen (crt_handle, const_cast<ACE_TCHAR *> (mode));
00554 #   elif defined (ACE_USES_WCHAR)
00555       file = ::_wfdopen (crt_handle, mode);
00556 #   else
00557       file = ::_fdopen (crt_handle, mode);
00558 #   endif /* __BORLANDC__ */
00559 
00560       if (!file)
00561         {
00562 #   if defined(__BORLANDC__)
00563           ::_rtl_close (crt_handle);
00564 #   else
00565           ::_close (crt_handle);
00566 #   endif /* defined(__BORLANDC__) */
00567         }
00568     }
00569 
00570   return file;
00571 #elif defined (ACE_LACKS_FDOPEN)
00572   ACE_UNUSED_ARG (handle);
00573   ACE_UNUSED_ARG (mode);
00574   ACE_NOTSUP_RETURN (0);
00575 #else
00576   ACE_OSCALL_RETURN
00577     (::fdopen (handle, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0);
00578 #endif /* ACE_HAS_WINCE */
00579 }

ACE_INLINE int ACE_OS::fflush FILE *  fp  ) 
 

Definition at line 582 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_Log_Record::print().

00583 {
00584   ACE_OS_TRACE ("ACE_OS::fflush");
00585 #if defined (ACE_VXWORKS)
00586   if (fp == 0)
00587     {
00588       // Do not allow fflush(0) on VxWorks
00589       return 0;
00590     }
00591 #endif /* ACE_VXWORKS */
00592 
00593   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fflush (fp), int, -1);
00594 }

ACE_INLINE int ACE_OS::fgetc FILE *  fp  ) 
 

Definition at line 597 of file OS_NS_stdio.inl.

References ace_fgetc_helper().

Referenced by ACE_Capabilities::getline().

00598 {
00599   return ace_fgetc_helper (fp);
00600 }

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

Definition at line 609 of file OS_NS_stdio.inl.

00610 {
00611   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1);
00612 }

ACE_INLINE wchar_t * ACE_OS::fgets wchar_t *  buf,
int  size,
FILE *  fp
 

Definition at line 623 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00624 {
00625   ACE_OS_TRACE ("ACE_OS::fgets");
00626   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetws (buf, size, fp), wchar_t *, 0);
00627 }

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

Definition at line 615 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

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

00616 {
00617   ACE_OS_TRACE ("ACE_OS::fgets");
00618   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0);
00619 }

ACE_NAMESPACE_INLINE_FUNCTION wint_t fgetwc FILE *  fp  ) 
 

ACE_INLINE ACE_OFF_T ACE_OS::filesize const ACE_TCHAR handle  ) 
 

Definition at line 124 of file OS_NS_sys_stat.inl.

References ACE_OFF_T, ACE_OS_TRACE, ACE_TCHAR, close(), filesize(), and open().

00125   {
00126     ACE_OS_TRACE ("ACE_OS::filesize");
00127 
00128     ACE_HANDLE const h = ACE_OS::open (filename, O_RDONLY);
00129     if (h != ACE_INVALID_HANDLE)
00130       {
00131         ACE_OFF_T size = ACE_OS::filesize (h);
00132         ACE_OS::close (h);
00133         return size;
00134       }
00135     else
00136       return -1;
00137   }

ACE_INLINE ACE_OFF_T ACE_OS::filesize ACE_HANDLE  handle  ) 
 

Definition at line 99 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_stat, fstat(), and set_errno_to_last_error().

Referenced by filesize(), flock_adjust_params(), ACE_MMAP_Memory_Pool::handle_signal(), ACE_Mem_Map::map_it(), ACE_FILE_IO::recvv(), and ACE_MMAP_Memory_Pool::remap().

00100   {
00101     ACE_OS_TRACE ("ACE_OS::filesize");
00102 #if defined (ACE_WIN32)
00103 # if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
00104     LARGE_INTEGER size;
00105     return
00106       (::GetFileSizeEx (handle, &size)
00107        ? size.QuadPart
00108        : (ACE_OS::set_errno_to_last_error (), -1));
00109 # else
00110     DWORD const size = ::GetFileSize (handle, 0);
00111     return
00112       (size != INVALID_FILE_SIZE
00113        ? static_cast<ACE_OFF_T> (size)
00114        : (ACE_OS::set_errno_to_last_error (), -1));
00115 # endif  /* _FILE_OFFSET_BITS == 64 */
00116 #else /* !ACE_WIN32 */
00117     ACE_stat sb;
00118     return ACE_OS::fstat (handle, &sb) == -1 ?
00119                     static_cast<ACE_OFF_T> (-1) : sb.st_size;
00120 #endif
00121   }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::flock_adjust_params ace_flock_t *  lock,
short  whence,
ACE_OFF_T start,
ACE_OFF_T len
 

Definition at line 25 of file OS_NS_stdio.inl.

References ACE_HIGH_PART, ACE_LOW_PART, ACE_OFF_T, filesize(), ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::overlapped_, and set_errno_to_last_error().

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

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

ACE_INLINE 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_, ACE_OS::ace_flock_t::lockname_, 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_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_TCHAR, ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, mode_t, ACE_OS::ace_flock_t::overlapped_, 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_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_HIGH_PART, ACE_LOW_PART, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

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 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00198   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00199                                                         0,
00200                                                         0,
00201                                                         low_len,
00202                                                         high_len,
00203                                                         &lock->overlapped_),
00204                                           ace_result_), int, -1);
00205 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00206   ACE_WIN32CALL_RETURN (
00207     ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
00208                                   lock->overlapped_.Offset,
00209                                   lock->overlapped_.OffsetHigh,
00210                                   low_len,
00211                                   high_len),
00212                       ace_result_), int, -1);
00213 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00214 #else
00215   lock->lock_.l_whence = whence;
00216   lock->lock_.l_start = start;
00217   lock->lock_.l_len = len;
00218   lock->lock_.l_type = F_RDLCK;         // set read lock
00219   // block, if no access
00220   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
00221                                     reinterpret_cast<long> (&lock->lock_)),
00222                      int, -1);
00223 #endif /* ACE_WIN32 */
00224 }

ACE_INLINE 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 227 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_HIGH_PART, ACE_LOW_PART, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, EBUSY, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::tryacquire_read().

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

ACE_INLINE 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 279 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_HIGH_PART, ACE_LOW_PART, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, EBUSY, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

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

00283 {
00284   ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock");
00285 #if defined (ACE_LACKS_FILELOCKS)
00286   ACE_UNUSED_ARG (lock);
00287   ACE_UNUSED_ARG (whence);
00288   ACE_UNUSED_ARG (start);
00289   ACE_UNUSED_ARG (len);
00290   ACE_NOTSUP_RETURN (-1);
00291 #elif defined (ACE_WIN32)
00292 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00293   ACE_OS::flock_adjust_params (lock, whence, start, len);
00294   DWORD low_len = ACE_LOW_PART (len);
00295   DWORD high_len = ACE_HIGH_PART (len);
00296   ACE_WIN32CALL_RETURN (
00297     ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00298                                     LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
00299                                     0,
00300                                     low_len,
00301                                     high_len,
00302                                     &lock->overlapped_),
00303                       ace_result_), int, -1);
00304 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00305   ACE_UNUSED_ARG (lock);
00306   ACE_UNUSED_ARG (whence);
00307   ACE_UNUSED_ARG (start);
00308   ACE_UNUSED_ARG (len);
00309   ACE_NOTSUP_RETURN (-1);
00310 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00311 #else
00312   lock->lock_.l_whence = whence;
00313   lock->lock_.l_start = start;
00314   lock->lock_.l_len = len;
00315   lock->lock_.l_type = F_WRLCK;         // set write lock
00316 
00317   int result = 0;
00318   // Does not block, if no access, returns -1 and set errno = EBUSY;
00319   ACE_OSCALL (ACE_OS::fcntl (lock->handle_,
00320                              F_SETLK,
00321                              reinterpret_cast<long> (&lock->lock_)),
00322               int, -1, result);
00323 
00324   if (result == -1 && (errno == EACCES || errno == EAGAIN))
00325     errno = EBUSY;
00326 
00327   return result;
00328 #endif /* ACE_WIN32 */
00329 }

ACE_INLINE 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_HIGH_PART, ACE_LOW_PART, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

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_wrlock ace_flock_t *  lock,
short  whence = 0,
ACE_OFF_T  start = 0,
ACE_OFF_T  len = 0
 

Definition at line 332 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_HIGH_PART, ACE_LOW_PART, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::acquire_write().

00336 {
00337   ACE_OS_TRACE ("ACE_OS::flock_wrlock");
00338 #if defined (ACE_LACKS_FILELOCKS)
00339   ACE_UNUSED_ARG (lock);
00340   ACE_UNUSED_ARG (whence);
00341   ACE_UNUSED_ARG (start);
00342   ACE_UNUSED_ARG (len);
00343   ACE_NOTSUP_RETURN (-1);
00344 #elif defined (ACE_WIN32)
00345   ACE_OS::flock_adjust_params (lock, whence, start, len);
00346   DWORD low_len = ACE_LOW_PART (len);
00347   DWORD high_len = ACE_HIGH_PART (len);
00348 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00349   ACE_WIN32CALL_RETURN (
00350     ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00351                                     LOCKFILE_EXCLUSIVE_LOCK,
00352                                     0,
00353                                     low_len,
00354                                     high_len,
00355                                     &lock->overlapped_),
00356                       ace_result_), int, -1);
00357 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00358   ACE_WIN32CALL_RETURN (
00359     ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
00360                                   lock->overlapped_.Offset,
00361                                   lock->overlapped_.OffsetHigh,
00362                                   low_len,
00363                                   high_len),
00364                       ace_result_), int, -1);
00365 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00366 #else
00367   lock->lock_.l_whence = whence;
00368   lock->lock_.l_start = start;
00369   lock->lock_.l_len = len;
00370   lock->lock_.l_type = F_WRLCK;         // set write lock
00371   // block, if no access
00372   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
00373                                     reinterpret_cast<long> (&lock->lock_)),
00374                      int, -1);
00375 #endif /* ACE_WIN32 */
00376 }

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.

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   }

FILE * ACE_OS::fopen const wchar_t *  filename,
const ACE_TCHAR mode
 

Definition at line 215 of file OS_NS_stdio.cpp.

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

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

FILE * ACE_OS::fopen const char *  filename,
const ACE_TCHAR mode
 

Definition at line 164 of file OS_NS_stdio.cpp.

References _O_TEXT, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT, close(), fopen_mode_to_open_mode_converter(), and open().

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

00166 {
00167   ACE_OS_TRACE ("ACE_OS::fopen");
00168   int hmode = _O_TEXT;
00169 
00170   // Let the chips fall where they may if the user passes in a NULL
00171   // mode string.  Convert to an empty mode string to prevent a
00172   // crash.
00173   ACE_TCHAR const empty_mode[] = ACE_TEXT ("");
00174   if (!mode)
00175     mode = empty_mode;
00176 
00177   for (ACE_TCHAR const* mode_ptr = mode; *mode_ptr != 0; ++mode_ptr)
00178     fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
00179 
00180   ACE_HANDLE const handle = ACE_OS::open (filename, hmode);
00181   if (handle != ACE_INVALID_HANDLE)
00182     {
00183       hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
00184 
00185       int const fd = ::_open_osfhandle (intptr_t (handle), hmode);
00186 
00187       if (fd != -1)
00188         {
00189 #   if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR)
00190           FILE * const fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode));
00191 #   elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR)
00192           FILE * const fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode));
00193 #   elif defined (ACE_USES_WCHAR)
00194           FILE * const fp = ::_wfdopen (fd, mode);
00195 #   else
00196           FILE * const fp = ::fdopen (fd, mode);
00197 #   endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */
00198           if (fp != 0)
00199           {
00200 #   if defined (ACE_USES_WCHAR)
00201             checkUnicodeFormat(fp);
00202 #   endif  // ACE_USES_WCHAR
00203             return fp;
00204           }
00205           ::_close (fd);
00206         }
00207 
00208       ACE_OS::close (handle);
00209     }
00210   return 0;
00211 }

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 201 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, pid_t, and ACE_Base_Thread_Adapter::sync_log_msg().

00202 {
00203   ACE_OS_TRACE ("ACE_OS::fork");
00204 # if defined (ACE_LACKS_FORK)
00205   ACE_UNUSED_ARG (program_name);
00206   ACE_NOTSUP_RETURN (pid_t (-1));
00207 # else
00208   pid_t const pid =
00209 # if defined (ACE_HAS_STHREADS)
00210     ::fork1 ();
00211 #else
00212     ::fork ();
00213 #endif /* ACE_HAS_STHREADS */
00214 
00215 #if !defined (ACE_HAS_MINIMAL_ACE_OS)
00216   if (pid == 0)
00217     ACE_Base_Thread_Adapter::sync_log_msg (program_name);
00218 #endif /* ! ACE_HAS_MINIMAL_ACE_OS */
00219 
00220   return pid;
00221 # endif /* ACE_WIN32 */
00222 }

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

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

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 }

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 228 of file OS_NS_unistd.cpp.

References ACE_NEW_NORETURN, ACE_TCHAR, ACE_TEXT_CreateProcess, ACE_TEXT_STARTUPINFO, argv_to_string(), close(), ACE_Wide_To_Ascii::convert(), execv(), exit(), fork(), memset(), and pid_t.

00229 {
00230 # if defined (ACE_WIN32)
00231 
00232   ACE_TCHAR *buf = 0;
00233   ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_ptr (buf);
00234   if (ACE_OS::argv_to_string (argv, buf) != -1)
00235     {
00236       PROCESS_INFORMATION process_info;
00237 #   if !defined (ACE_HAS_WINCE)
00238       ACE_TEXT_STARTUPINFO startup_info;
00239       ACE_OS::memset ((void *) &startup_info,
00240                       0,
00241                       sizeof startup_info);
00242       startup_info.cb = sizeof startup_info;
00243 
00244       if (ACE_TEXT_CreateProcess (0,
00245                                   buf,
00246                                   0, // No process attributes.
00247                                   0,  // No thread attributes.
00248                                   TRUE, // Allow handle inheritance.
00249                                   0, // Don't create a new console window.
00250                                   0, // No environment.
00251                                   0, // No current directory.
00252                                   &startup_info,
00253                                   &process_info))
00254 #   else
00255       if (ACE_TEXT_CreateProcess (0,
00256                                   buf,
00257                                   0, // No process attributes.
00258                                   0,  // No thread attributes.
00259                                   FALSE, // Can's inherit handles on CE
00260                                   0, // Don't create a new console window.
00261                                   0, // No environment.
00262                                   0, // No current directory.
00263                                   0, // Can't use startup info on CE
00264                                   &process_info))
00265 #   endif /* ! ACE_HAS_WINCE */
00266         {
00267           // Free resources allocated in kernel.
00268           ACE_OS::close (process_info.hThread);
00269           ACE_OS::close (process_info.hProcess);
00270           // Return new process id.
00271           return process_info.dwProcessId;
00272         }
00273     }
00274 
00275   // CreateProcess failed.
00276   return -1;
00277 # else
00278       pid_t const result = ACE_OS::fork ();
00279 
00280 #   if defined (ACE_USES_WCHAR)
00281       // Wide-char builds need to convert the command-line args to
00282       // narrow char strings for execv ().
00283       char **cargv = 0;
00284       int arg_count;
00285 #   endif /* ACE_HAS_WCHAR */
00286 
00287       switch (result)
00288         {
00289         case -1:
00290           // Error.
00291           return -1;
00292         case 0:
00293           // Child process.
00294 #   if defined (ACE_USES_WCHAR)
00295           for (arg_count = 0; argv[arg_count] != 0; ++arg_count)
00296             ;
00297           ++arg_count;    // Need a 0-pointer end-of-array marker
00298           ACE_NEW_NORETURN (cargv, char*[arg_count]);
00299           if (cargv == 0)
00300             ACE_OS::exit (errno);
00301           --arg_count;    // Back to 0-indexed
00302           cargv[arg_count] = 0;
00303           while (--arg_count >= 0)
00304             cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
00305           // Don't worry about freeing the cargv or the strings it points to.
00306           // Either the process will be replaced, or we'll exit.
00307           if (ACE_OS::execv (cargv[0], cargv) == -1)
00308             ACE_OS::exit (errno);
00309 #   else
00310           if (ACE_OS::execv (argv[0], argv) == -1)
00311             {
00312               // The OS layer should not print stuff out
00313               // ACE_ERROR ((LM_ERROR,
00314               //             "%p Exec failed\n"));
00315 
00316               // If the execv fails, this child needs to exit.
00317               ACE_OS::exit (errno);
00318             }
00319 #   endif /* ACE_HAS_WCHAR */
00320 
00321         default:
00322           // Server process.  The fork succeeded.
00323           return result;
00324         }
00325 # endif /* ACE_WIN32 */
00326 }

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

Definition at line 274 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00275 {
00276   ACE_OS_TRACE ("ACE_OS::fprintf");
00277 
00278 # if !defined (ACE_HAS_VFWPRINTF)
00279   ACE_UNUSED_ARG (fp);
00280   ACE_UNUSED_ARG (format);
00281   ACE_NOTSUP_RETURN (-1);
00282 
00283 # else
00284   int result = 0;
00285   va_list ap;
00286   va_start (ap, format);
00287   ACE_OSCALL (ACE_STD_NAMESPACE::vfwprintf (fp, format, ap), int, -1, result);
00288   va_end (ap);
00289   return result;
00290 
00291 # endif /* ACE_HAS_VFWPRINTF */
00292 }

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

Definition at line 261 of file OS_NS_stdio.cpp.

References ACE_OS_TRACE.

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_Stats::print_summary(), socket_fini(), and socket_init().

00262 {
00263   ACE_OS_TRACE ("ACE_OS::fprintf");
00264   int result = 0;
00265   va_list ap;
00266   va_start (ap, format);
00267   ACE_OSCALL (::vfprintf (fp, format, ap), int, -1, result);
00268   va_end (ap);
00269   return result;
00270 }

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

Definition at line 666 of file OS_NS_stdio.inl.

References ace_fputc_helper().

00667 {
00668   return ace_fputc_helper (c, fp);
00669 }

ACE_INLINE int ACE_OS::fputs const wchar_t *  s,
FILE *  stream
 

Definition at line 686 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00687 {
00688   ACE_OS_TRACE ("ACE_OS::fputs");
00689   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputws (s, stream), int, -1);
00690 }

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

Definition at line 678 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

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

00679 {
00680   ACE_OS_TRACE ("ACE_OS::fputs");
00681   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1);
00682 }

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

Definition at line 694 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_Svc_Conf_Lexer::input().

00695 {
00696   ACE_OS_TRACE ("ACE_OS::fread");
00697   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fread (ptr, size, nelems, fp),
00698                      size_t,
00699                      0);
00700 }

void ACE_OS::free void *   ) 
 

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_TLI_Acceptor::close(), 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_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(), tempnam(), 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< const ACE_TCHAR *, ACE_Filecache_Object * >::~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_INLINE FILE * ACE_OS::freopen const ACE_TCHAR filename,
const ACE_TCHAR mode,
FILE *  stream
 

Definition at line 703 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and ACE_TEXT_ALWAYS_WCHAR.

00704 {
00705   ACE_OS_TRACE ("ACE_OS::freopen");
00706 #if defined (ACE_WIN32) && (defined(ACE_USES_WCHAR) || defined(ACE_HAS_WINCE))
00707   ACE_OSCALL_RETURN (::_wfreopen (ACE_TEXT_ALWAYS_WCHAR (filename),
00708                                   ACE_TEXT_ALWAYS_WCHAR (mode),
00709                                   stream),
00710                      FILE *, 0);
00711 #else
00712   ACE_OSCALL_RETURN
00713     (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename),
00714                                  ACE_TEXT_ALWAYS_CHAR (mode),
00715                                  stream),
00716      FILE *, 0);
00717 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
00718 }

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

Definition at line 721 of file OS_NS_stdio.inl.

Referenced by rewind().

00722 {
00723 # if defined (ACE_WIN32)
00724 #   if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00725   //#error Windows NT is evil AND rude!
00726   switch (whence)
00727     {
00728     case SEEK_SET:
00729       whence = FILE_BEGIN;
00730       break;
00731     case SEEK_CUR:
00732       whence = FILE_CURRENT;
00733       break;
00734     case SEEK_END:
00735       whence = FILE_END;
00736       break;
00737     default:
00738       errno = EINVAL;
00739       return -1; // rather safe than sorry
00740     }
00741 #   endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00742 # endif   /* ACE_WIN32 */
00743   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1);
00744 }

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

Definition at line 747 of file OS_NS_stdio.inl.

References fsetpos().

Referenced by fsetpos().

00748 {
00749   ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
00750 }

ACE_INLINE int ACE_OS::fstat ACE_HANDLE  ,
ACE_stat
 

Definition at line 51 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_Time_Value, and set_errno_to_last_error().

Referenced by ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), filesize(), and ACE_FILE::get_info().

00052   {
00053     ACE_OS_TRACE ("ACE_OS::fstat");
00054 # if 1
00055     BY_HANDLE_FILE_INFORMATION fdata;
00056 
00057     if (::GetFileInformationByHandle (handle, &fdata) == FALSE)
00058       {
00059         ACE_OS::set_errno_to_last_error ();
00060         return -1;
00061       }
00062     else if (fdata.nFileSizeHigh != 0)
00063       {
00064         errno = EINVAL;
00065         return -1;
00066       }
00067     else
00068       {
00069         stp->st_size = fdata.nFileSizeLow;
00070         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec ();
00071         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec ();
00072         stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec ();
00073         stp->st_nlink = static_cast<short> (fdata.nNumberOfLinks);
00074         stp->st_dev = stp->st_rdev = 0; // No equivalent conversion.
00075         stp->st_mode = S_IXOTH | S_IROTH |
00076           (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) |
00077           (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG);
00078       }
00079     return 0;
00080 # else /* 1 */
00081     // This implementation close the handle.
00082     int retval = -1;
00083     int fd = ::_open_osfhandle ((long) handle, 0);
00084     if (fd != -1)
00085       retval = ::_fstat (fd, stp);
00086 
00087     ::_close (fd);
00088     // Remember to close the file handle.
00089     return retval;
00090 # endif /* 1 */
00091   }

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 fsync().

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 long ACE_OS::ftell FILE *  fp  ) 
 

Definition at line 753 of file OS_NS_stdio.inl.

Referenced by ACE_Logging_Strategy::handle_timeout().

00754 {
00755   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ftell (fp), long, -1);
00756 }

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_FAIL_RETURN, ACE_OFF_T, 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 size_t ACE_OS::fwrite const void *  ptr,
size_t  size,
size_t  nitems,
FILE *  fp
 

Definition at line 759 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00760 {
00761   ACE_OS_TRACE ("ACE_OS::fwrite");
00762   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fwrite (ptr, size, nitems, fp),
00763                      size_t,
00764                      0);
00765 }

ACE_NAMESPACE_INLINE_FUNCTION HINSTANCE get_win32_resource_module void   ) 
 

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

ACE_NAMESPACE_INLINE_FUNCTION const ACE_TEXT_OSVERSIONINFO& get_win32_versioninfo void   ) 
 

Return the win32 OSVERSIONINFO structure.

ACE_INLINE int ACE_OS::getc FILE *  fp  ) 
 

Definition at line 603 of file OS_NS_stdio.inl.

References ace_getc_helper().

Referenced by ACE_Read_Buffer::rec_read().

00604 {
00605   return ace_getc_helper (fp);
00606 }

ACE_INLINE wchar_t * ACE_OS::getcwd wchar_t *  ,
size_t 
 

Definition at line 385 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, getcwd(), strsncpy(), and ACE_Ascii_To_Wide::wchar_rep().

00386 {
00387 #  if defined (ACE_HAS_WINCE)
00388   ACE_UNUSED_ARG (buf);
00389   ACE_UNUSED_ARG (size);
00390   ACE_NOTSUP_RETURN (0);
00391 #  elif defined (ACE_WIN32)
00392   return ::_wgetcwd (buf, static_cast<int> (size));
00393 #  else
00394   char *narrow_buf = new char[size];
00395   char *result = 0;
00396   result = ACE_OS::getcwd (narrow_buf, size);
00397   ACE_Ascii_To_Wide wide_buf (result);
00398   delete [] narrow_buf;
00399   if (result != 0)
00400     ACE_OS::strsncpy (buf, wide_buf.wchar_rep (), size);
00401   return result == 0 ? 0 : buf;
00402 #  endif /* ACE_WIN32 */
00403 }

ACE_INLINE 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_INLINE gid_t ACE_OS::getegid void   ) 
 

Definition at line 418 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getegid(), and gid_t.

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 wchar_t * ACE_OS::getenv const wchar_t *  symbol  ) 
 

Definition at line 148 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN.

00149 {
00150 #if defined (ACE_LACKS_ENV)
00151   ACE_UNUSED_ARG (symbol);
00152   ACE_NOTSUP_RETURN (0);
00153 #else
00154   ACE_OSCALL_RETURN (::_wgetenv (symbol), wchar_t *, 0);
00155 #endif /* ACE_LACKS_ENV */
00156 }

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

Definition at line 135 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().

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

ACE_TCHAR * ACE_OS::getenvstrings void   ) 
 

Definition at line 92 of file OS_NS_stdlib.cpp.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Process_Options::inherit_environment().

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_INLINE uid_t ACE_OS::geteuid void   ) 
 

Definition at line 496 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, geteuid(), and uid_t.

Referenced by 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 gid_t ACE_OS::getgid void   ) 
 

Definition at line 407 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getgid(), and gid_t.

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_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_HOSTENT_DATA, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, 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   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00071                                         (ACE_SOCKET_LEN) length,
00072                                         type),
00073                        struct hostent *,
00074                        0);
00075 #   else
00076   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00077                                         (ACE_SOCKET_LEN) length,
00078                                         type),
00079                        struct hostent *,
00080                        0);
00081 #   endif /* ACE_HAS_NONCONST_GETBY */
00082 # endif /* !ACE_LACKS_GETHOSTBYADDR */
00083 }

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 90 of file OS_NS_netdb.inl.

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

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

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

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

Definition at line 222 of file OS_NS_netdb.inl.

References ACE_HOSTENT_DATA, 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().

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

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

Definition at line 258 of file OS_NS_netdb.inl.

References ACE_HOSTENT_DATA, 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().

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

ACE_INLINE ACE_hrtime_t ACE_OS::gethrtime const  ACE_HRTimer_Op = ACE_HRTIMER_GETTIME  ) 
 

Definition at line 225 of file OS_NS_time.inl.

References ACE_GETHRTIME_NAME, ACE_hrtime_t, ACE_ONE_SECOND_IN_NSECS, ACE_OS_TRACE, ACE_UINT64, clock_gettime(), CLOCK_REALTIME, gettimeofday(), memcpy(), ACE_Time_Value::sec(), timespec::tv_nsec, timespec::tv_sec, and ACE_Time_Value::usec().

Referenced by ACE_High_Res_Timer::calibrate(), and ACE_High_Res_Timer::gettime().

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   // Read the high-res tick counter directly into memory variable "now".
00265   // The A constraint signifies a 64-bit int.
00266   asm volatile ("rdtsc" : "=A" (now) : : "memory");
00267 
00268 # if defined (ACE_LACKS_LONGLONG_T)
00269   ACE_UINT32 least, most;
00270   ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32));
00271   ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32),
00272                   sizeof (ACE_UINT32));
00273 
00274   ACE_hrtime_t ret (least, most);
00275   return ret;
00276 # else  /* ! ACE_LACKS_LONGLONG_T */
00277   return now;
00278 # endif /* ! ACE_LACKS_LONGLONG_T */
00279 #elif defined (linux) && defined (ACE_HAS_ALPHA_TIMER)
00280   // NOTE:  alphas only have a 32 bit tick (cycle) counter.  The rpcc
00281   // instruction actually reads 64 bits, but the high 32 bits are
00282   // implementation-specific.  Linux and Digital Unix, for example,
00283   // use them for virtual tick counts, i.e., taking into account only
00284   // the time that the process was running.  This information is from
00285   // David Mosberger's article, see comment below.
00286   ACE_UINT32 now;
00287 
00288   // The following statement is based on code published by:
00289   // Mosberger, David, "How to Make Your Applications Fly, Part 1",
00290   // Linux Journal Issue 42, October 1997, page 50.  It reads the
00291   // high-res tick counter directly into the memory variable.
00292   asm volatile ("rpcc %0" : "=r" (now) : : "memory");
00293 
00294   return now;
00295 #elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__))
00296   // PowerPC w/ GreenHills or g++.
00297 
00298   ACE_UNUSED_ARG (op);
00299   u_long most;
00300   u_long least;
00301 
00302 #if defined (ghs)
00303   ACE_OS::readPPCTimeBase (most, least);
00304 #else
00305   u_long scratch;
00306 
00307   do {
00308     asm volatile ("mftbu %0\n"
00309           "mftb  %1\n"
00310           "mftbu %2"
00311           : "=r" (most), "=r" (least), "=r" (scratch));
00312   } while (most != scratch);
00313 #endif
00314 
00315 #if defined (ACE_LACKS_LONGLONG_T)
00316   return ACE_U_LongLong (least, most);
00317 #else  /* ! ACE_LACKS_LONGLONG_T */
00318   return 0x100000000llu * most  +  least;
00319 #endif /* ! ACE_LACKS_LONGLONG_T */
00320 
00321 #elif defined (ACE_HAS_CLOCK_GETTIME)
00322   // e.g., VxWorks (besides POWERPC && GreenHills) . . .
00323   ACE_UNUSED_ARG (op);
00324   struct timespec ts;
00325 
00326   ACE_OS::clock_gettime (
00327 #if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC)
00328          CLOCK_MONOTONIC,
00329 #endif /* !ACE_HAS_CLOCK_GETTIME_MONOTONIC */
00330          CLOCK_REALTIME,
00331          &ts);
00332 
00333   // Carefully create the return value to avoid arithmetic overflow
00334   // if ACE_hrtime_t is ACE_U_LongLong.
00335   return static_cast<ACE_hrtime_t> (ts.tv_sec) *
00336     ACE_U_ONE_SECOND_IN_NSECS  +  static_cast<ACE_hrtime_t> (ts.tv_nsec);
00337 #else
00338   ACE_UNUSED_ARG (op);
00339   ACE_Time_Value const now = ACE_OS::gettimeofday ();
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> (now.sec ()) * (ACE_UINT32) 1000000  +
00344           static_cast<ACE_hrtime_t> (now.usec ())) * (ACE_UINT32) 1000;
00345 #endif /* ACE_HAS_HI_RES_TIMER */
00346 }

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

Definition at line 386 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, AF_INET, and gethostbyaddr().

00387 {
00388 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00389 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
00390   ACE_UNUSED_ARG (src);
00391   ACE_UNUSED_ARG (len);
00392   ACE_UNUSED_ARG (family);
00393   ACE_NOTSUP_RETURN (0);
00394 #  else
00395   struct hostent *hptr = 0;
00396   int errnum;
00397   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
00398     {
00399       errno = errnum;
00400     }
00401   return hptr;
00402 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
00403 #else
00404   // IPv4-only implementation
00405   if (family == AF_INET)
00406     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
00407                                   static_cast<int> (len),
00408                                   family);
00409 
00410   ACE_NOTSUP_RETURN (0);
00411 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00412 }

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

Definition at line 415 of file OS_NS_netdb.inl.

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

00416 {
00417   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
00418 # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6)
00419 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
00420   ACE_UNUSED_ARG (flags);
00421 #     if defined (ACE_HAS_NONCONST_GETBY)
00422   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
00423                                          family),
00424                        struct hostent *, 0);
00425 #     else
00426   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
00427                        struct hostent *, 0);
00428 #     endif /* ACE_HAS_NONCONST_GETBY */
00429 #   else
00430   struct hostent *hptr = 0;
00431   int errnum;
00432   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
00433     {
00434       errno = errnum;
00435     }
00436   return hptr;
00437 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
00438 # else
00439   // IPv4-only implementation
00440   ACE_UNUSED_ARG (flags);
00441   if (family == AF_INET)
00442     return ACE_OS::gethostbyname (name);
00443 
00444   ACE_NOTSUP_RETURN (0);
00445 # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */
00446 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_END_VERSIONED_NAMESPACE_DECL ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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, ACE_TCHAR, 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_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_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_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().

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 long ACE_OS::getpagesize void   ) 
 

Definition at line 91 of file OS_NS_unistd.inl.

References ACE_OS_TRACE.

Referenced by allocation_granularity(), 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 int ACE_OS::getpeername ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen
 

BSD-style (no QoS).

Definition at line 169 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, 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().

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

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, getpgid(), and pid_t.

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.

Referenced by ACE_IPC_SAP::enable(), ACE_IO_SAP::enable(), ACE_Log_Msg::getpid(), ACE_SPIPE_Stream::recv_handle(), and ACE_Log_Msg::sync().

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 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 pid_t ACE_OS::getppid void   ) 
 

Definition at line 474 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getppid(), and pid_t.

Referenced by getppid().

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 struct protoent * ACE_OS::getprotobyname const char *  name  ) 
 

Definition at line 449 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobyname().

Referenced by getprotobyname(), and getprotobyname_r().

00450 {
00451 #if defined (ACE_LACKS_GETPROTOBYNAME)
00452   ACE_UNUSED_ARG (name);
00453   ACE_NOTSUP_RETURN (0);
00454 #elif defined (ACE_HAS_NONCONST_GETBY)
00455   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00456                        struct protoent *,
00457                        0);
00458 #else
00459   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00460                        struct protoent *,
00461                        0);
00462 #endif /* ACE_LACKS_GETPROTOBYNAME */
00463 }

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

Definition at line 466 of file OS_NS_netdb.inl.

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

Referenced by getprotobyname_r().

00469 {
00470 #if defined (ACE_LACKS_GETPROTOBYNAME)
00471   ACE_UNUSED_ARG (name);
00472   ACE_UNUSED_ARG (result);
00473   ACE_UNUSED_ARG (buffer);
00474   ACE_NOTSUP_RETURN (0);
00475 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00476 # if defined (AIX) || defined (DIGITAL_UNIX)
00477   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
00478     return result;
00479   else
00480     return 0;
00481 # elif defined (__GLIBC__)
00482   // GNU C library has a different signature
00483   if (::getprotobyname_r (name,
00484                           result,
00485                           buffer,
00486                           sizeof (ACE_PROTOENT_DATA),
00487                           &result) == 0)
00488     return result;
00489   else
00490     return 0;
00491 # else
00492 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00493   ACE_UNUSED_ARG (result);
00494   ACE_NETDBCALL_RETURN (::getprotobyname (name),
00495                         struct protoent *, 0,
00496                         buffer, sizeof (ACE_PROTOENT_DATA));
00497 #   else
00498     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
00499                                              result,
00500                                              buffer,
00501                                              sizeof (ACE_PROTOENT_DATA)),
00502                        struct protoent *, 0);
00503 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00504 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00505 #elif defined (ACE_HAS_NONCONST_GETBY)
00506   ACE_UNUSED_ARG (result);
00507   ACE_UNUSED_ARG (buffer);
00508   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00509                        struct protoent *, 0);
00510 #else
00511   ACE_UNUSED_ARG (buffer);
00512   ACE_UNUSED_ARG (result);
00513 
00514   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00515                        struct protoent *,
00516                        0);
00517 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
00518 }

ACE_INLINE struct protoent * ACE_OS::getprotobynumber int  proto  ) 
 

Definition at line 521 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobynumber().

Referenced by getprotobynumber(), and getprotobynumber_r().

00522 {
00523 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00524   ACE_UNUSED_ARG (proto);
00525   ACE_NOTSUP_RETURN (0);
00526 #else
00527   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00528                        struct protoent *, 0);
00529 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
00530 }

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

Definition at line 533 of file OS_NS_netdb.inl.

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

Referenced by getprotobynumber_r().

00536 {
00537 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00538   ACE_UNUSED_ARG (proto);
00539   ACE_UNUSED_ARG (result);
00540   ACE_UNUSED_ARG (buffer);
00541   ACE_NOTSUP_RETURN (0);
00542 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00543 # if defined (AIX) || defined (DIGITAL_UNIX)
00544   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
00545     return result;
00546   else
00547     return 0;
00548 # elif defined (__GLIBC__)
00549   // GNU C library has a different signature
00550   if (::getprotobynumber_r (proto,
00551                             result,
00552                             buffer,
00553                             sizeof (ACE_PROTOENT_DATA),
00554                             &result) == 0)
00555     return result;
00556   else
00557     return 0;
00558 # else
00559 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00560   ACE_UNUSED_ARG (result);
00561   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
00562                         struct protoent *, 0,
00563                         buffer, sizeof (ACE_PROTOENT_DATA));
00564 #   else
00565   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
00566                        struct protoent *, 0);
00567 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00568 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00569 #else
00570   ACE_UNUSED_ARG (buffer);
00571   ACE_UNUSED_ARG (result);
00572 
00573   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00574                        struct protoent *, 0);
00575 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00576 }

ACE_INLINE struct passwd * ACE_OS::getpwent void   ) 
 

Definition at line 20 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN.

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 *  user  ) 
 

Definition at line 30 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN.

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.

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_STD) && \
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_STD */
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_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 rusage
 

Definition at line 30 of file OS_NS_sys_resource.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, getrusage(), rusage::ru_stime, and rusage::ru_utime.

Referenced by getrusage(), ACE_Profile_Timer::start(), and ACE_Profile_Timer::stop().

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 struct servent * ACE_OS::getservbyname const char *  svc,
const char *  proto
 

Definition at line 579 of file OS_NS_netdb.inl.

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

Referenced by getservbyname(), and getservbyname_r().

00580 {
00581   ACE_OS_TRACE ("ACE_OS::getservbyname");
00582 #if defined (ACE_LACKS_GETSERVBYNAME)
00583   ACE_UNUSED_ARG (svc);
00584   ACE_UNUSED_ARG (proto);
00585   ACE_NOTSUP_RETURN (0);
00586 #elif defined (ACE_HAS_NONCONST_GETBY)
00587   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00588                                         const_cast<char *> (proto)),
00589                        struct servent *,
00590                        0);
00591 #else
00592   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00593                                         proto),
00594                        struct servent *,
00595                        0);
00596 #endif /* ACE_HAS_NONCONST_GETBY */
00597 }

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

Definition at line 600 of file OS_NS_netdb.inl.

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

Referenced by get_port_number_from_name(), and getservbyname_r().

00604 {
00605   ACE_OS_TRACE ("ACE_OS::getservbyname_r");
00606 #if defined (ACE_LACKS_GETSERVBYNAME)
00607   ACE_UNUSED_ARG (svc);
00608   ACE_UNUSED_ARG (proto);
00609   ACE_UNUSED_ARG (result);
00610   ACE_UNUSED_ARG (buf);
00611   ACE_NOTSUP_RETURN (0);
00612 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00613 # if defined (AIX) || defined (DIGITAL_UNIX)
00614   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00615 
00616   if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0)
00617     return result;
00618   else
00619     return (struct servent *) 0;
00620 # elif defined (__GLIBC__)
00621   // GNU C library has a different signature
00622   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00623 
00624   if (::getservbyname_r (svc,
00625                          proto,
00626                          result,
00627                          buf,
00628                          sizeof (ACE_SERVENT_DATA),
00629                          &result) == 0)
00630     return result;
00631   else
00632     return (struct servent *) 0;
00633 # else
00634 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00635   ACE_UNUSED_ARG (result);
00636   ACE_NETDBCALL_RETURN (::getservbyname (svc, proto),
00637                         struct servent *, 0,
00638                         buf, sizeof (ACE_SERVENT_DATA));
00639 #   else
00640   ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf,
00641                                           sizeof (ACE_SERVENT_DATA)),
00642                        struct servent *, 0);
00643 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00644 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00645 #elif defined (ACE_HAS_NONCONST_GETBY)
00646   ACE_UNUSED_ARG (buf);
00647   ACE_UNUSED_ARG (result);
00648   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00649                                         const_cast<char *> (proto)),
00650                        struct servent *,
00651                        0);
00652 #else
00653   ACE_UNUSED_ARG (buf);
00654   ACE_UNUSED_ARG (result);
00655 
00656   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00657                                         proto),
00658                        struct servent *,
00659                        0);
00660 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00661 }

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

BSD-style (no QoS).

Definition at line 217 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, AF_INET, getsockname(), and memset().

Referenced by ACE_SOCK::get_local_addr(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), getsockname(), and ACE_SOCK_SEQPACK_Connector::shared_connect_start().

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

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

BSD-style (no QoS).

Definition at line 262 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and getsockopt().

Referenced by ACE_SOCK::get_option(), getsockopt(), and ACE::handle_timed_complete().

00267 {
00268   ACE_OS_TRACE ("ACE_OS::getsockopt");
00269 #if defined (ACE_LACKS_GETSOCKOPT)
00270   ACE_UNUSED_ARG (handle);
00271   ACE_UNUSED_ARG (level);
00272   ACE_UNUSED_ARG (optname);
00273   ACE_UNUSED_ARG (optval);
00274   ACE_UNUSED_ARG (optlen);
00275   ACE_NOTSUP_RETURN (-1);
00276 #else
00277   ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle,
00278                                      level,
00279                                      optname,
00280                                      optval,
00281                                      (ACE_SOCKET_LEN *) optlen),
00282                        int,
00283                        -1);
00284 #endif /* ACE_LACKS_GETSOCKOPT */
00285 }

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 ACE_Time_Value, CLOCK_REALTIME, timespec::tv_nsec, and timespec::tv_sec.

Referenced by ACE_Buffered_Svc_Handler<, >::ACE_Buffered_Svc_Handler(), 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(), ACE_Buffered_Svc_Handler<, >::put(), 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_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_INLINE uid_t ACE_OS::getuid void   ) 
 

Definition at line 485 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getuid(), and uid_t.

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 struct tm * ACE_OS::gmtime const time_t *  clock  ) 
 

Definition at line 349 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and gmtime().

Referenced by gmtime(), and gmtime_r().

00350 {
00351   ACE_OS_TRACE ("ACE_OS::gmtime");
00352 #if defined (ACE_LACKS_GMTIME)
00353   ACE_UNUSED_ARG (t);
00354   ACE_NOTSUP_RETURN (0);
00355 #else
00356   ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
00357 #endif /* ACE_LACKS_GMTIME */
00358 }

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

Definition at line 361 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gmtime(), and gmtime_r().

Referenced by gmtime_r().

00362 {
00363   ACE_OS_TRACE ("ACE_OS::gmtime_r");
00364 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00365 # if defined (DIGITAL_UNIX)
00366   ACE_OSCALL_RETURN (::_Pgmtime_r (t, res), struct tm *, 0);
00367 # else
00368   ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0);
00369 # endif /* DIGITAL_UNIX */
00370 #elif defined (ACE_HAS_TR24731_2005_CRT)
00371   struct tm *tm_p = res;
00372   ACE_SECURECRTCALL (gmtime_s (res, t), struct tm *, 0, tm_p);
00373   return tm_p;
00374 #elif defined (ACE_LACKS_GMTIME_R)
00375   ACE_UNUSED_ARG (t);
00376   ACE_UNUSED_ARG (res);
00377   ACE_NOTSUP_RETURN (0);
00378 #else
00379   struct tm *result;
00380   ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ;
00381   if (result != 0)
00382     *res = *result;
00383   return res;
00384 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00385 }

ACE_NAMESPACE_INLINE_FUNCTION int hostname wchar_t *  name,
size_t  maxnamelen
 

ACE_NAMESPACE_INLINE_FUNCTION int hostname char *  name,
size_t  maxnamelen
 

Referenced by ACE_INET_Addr::get_host_name_i(), getmacaddress(), ACE_Naming_Context::open(), and uname().

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, and ACE_OS_TRACE.

Referenced by 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_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::inet_aton const char *  strptr,
struct in_addr *  addr
 

Definition at line 15 of file OS_NS_arpa_inet.cpp.

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

Referenced by inet_aton(), 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 <= 0x650)
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_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 }

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 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_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_SOCKCALL_RETURN, ACE_QoS::provider_specific(), ACE_QoS::receiving_flowspec(), ACE_QoS::sending_flowspec(), and socket().

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

Definition at line 14 of file OS_NS_stropts.cpp.

References ACE_NOTSUP_RETURN, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_SOCKCALL_RETURN, and socket().

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_INLINE int ACE_OS::ioctl ACE_HANDLE  handle,
ACE_IOCTL_TYPE_ARG2  cmd,
void *  = 0
 

UNIX-style .

Definition at line 108 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ioctl().

Referenced by ACE_SPIPE_Acceptor::accept(), ACE::clr_flags(), ACE_TLI_Connector::connect(), 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(), open_new_endpoint(), ACE_SOCK_Dgram::recv(), ACE_SPIPE_Stream::recv_handle(), ACE_SOCK_IO::recvv(), ACE_SPIPE_Stream::send_handle(), and ACE::set_flags().

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

Referenced by ACE_UPIPE_Connector::connect(), 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::isatty ACE_HANDLE  handle  ) 
 

Definition at line 588 of file OS_NS_unistd.inl.

00589 {
00590 #if defined (ACE_LACKS_ISATTY)
00591   ACE_UNUSED_ARG (handle);
00592   return 0;
00593 #else
00594   int fd = ::_open_osfhandle (intptr_t (handle), 0);
00595   int status = ::_isatty (fd);
00596   ::_close (fd);
00597   return status;
00598 #endif /* ACE_LACKS_ISATTY */
00599 }

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 wchar_t * ACE_OS::itoa int  value,
wchar_t *  string,
int  radix
 

Converts an integer to a string.

Definition at line 173 of file OS_NS_stdlib.inl.

References itow_emulation().

00174 {
00175 #if defined (ACE_LACKS_ITOW)
00176   return ACE_OS::itow_emulation (value, string, radix);
00177 #else /* ACE_LACKS_ITOW */
00178   return ::_itow (value, string, radix);
00179 #endif /* ACE_LACKS_ITOW */
00180 }

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

Converts an integer to a string.

Definition at line 160 of file OS_NS_stdlib.inl.

References itoa_emulation().

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

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 }

wchar_t * ACE_OS::itow_emulation int  value,
wchar_t *  string,
int  radix
 

Emulated itow - Converts an integer to a string.

Definition at line 233 of file OS_NS_stdlib.cpp.

Referenced by itoa().

00234 {
00235   wchar_t *e = string;
00236   wchar_t *b = string;
00237 
00238   // Short circuit if 0
00239 
00240   if (value == 0)
00241     {
00242       string[0] = '0';
00243       string[1] = 0;
00244       return string;
00245     }
00246 
00247   // If negative and base 10, print a - and then do the
00248   // number.
00249 
00250   if (value < 0 && radix == 10)
00251     {
00252       string[0] = '-';
00253       b++;
00254     }
00255 
00256   // Convert to base <radix>, but in reverse order
00257 
00258   while (value != 0)
00259     {
00260       int mod = value % radix;
00261       value = value / radix;
00262 
00263       *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
00264     }
00265 
00266   *e-- = 0;
00267 
00268   // Now reverse the string to get the correct result
00269 
00270   while (e > b)
00271   {
00272     wchar_t temp = *e;
00273     *e = *b;
00274     *b = temp;
00275     ++b;
00276     --e;
00277   }
00278 
00279   return string;
00280 }

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(), socket(), 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_INLINE int ACE_OS::kill pid_t  pid,
int  signum
 

Definition at line 14 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, kill(), and pid_t.

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

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 void ACE_OS::last_error int   ) 
 

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_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE 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_INLINE int ACE_OS::listen ACE_HANDLE  handle,
int  backlog
 

BSD-style (no QoS).

Definition at line 288 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().

00289 {
00290   ACE_OS_TRACE ("ACE_OS::listen");
00291 #if defined (ACE_LACKS_LISTEN)
00292   ACE_UNUSED_ARG (handle);
00293   ACE_UNUSED_ARG (backlog);
00294   ACE_NOTSUP_RETURN (-1);
00295 #else
00296   ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1);
00297 #endif /* ACE_LACKS_LISTEN */
00298 }

ACE_INLINE struct tm * ACE_OS::localtime const time_t *  clock  ) 
 

Definition at line 388 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and localtime().

Referenced by ctime(), localtime(), and localtime_r().

00389 {
00390   ACE_OS_TRACE ("ACE_OS::localtime");
00391 #if defined (ACE_LACKS_LOCALTIME)
00392   ACE_UNUSED_ARG (t);
00393   ACE_NOTSUP_RETURN (0);
00394 #else
00395   ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0);
00396 #endif /* ACE_LACKS_LOCALTIME */
00397 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL struct tm * ACE_OS::localtime_r const time_t *  clock,
struct tm *  res
 

Definition at line 225 of file OS_NS_time.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_GUARD, ACE_OS_TRACE, localtime(), and localtime_r().

Referenced by localtime_r(), and 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_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_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_FAIL_RETURN, ACE_HIGH_PART, ACE_LOW_PART, ACE_OFF_T, 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 int ACE_OS::lstat const wchar_t *  ,
ACE_stat
 

Definition at line 156 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, lstat(), and stat().

00157   {
00158     ACE_OS_TRACE ("ACE_OS::lstat");
00159 # if defined (ACE_LACKS_LSTAT)
00160     return ACE_OS::stat (file, stp);
00161 # else
00162     return ACE_OS::lstat (ACE_Wide_To_Ascii (file).char_rep (), stp);
00163 # endif /* ACE_LACKS_LSTAT */
00164   }

ACE_INLINE int ACE_OS::lstat const char *  ,
ACE_stat
 

Definition at line 140 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, lstat(), and stat().

Referenced by lstat().

00141   {
00142     ACE_OS_TRACE ("ACE_OS::lstat");
00143 # if defined (ACE_LACKS_LSTAT)
00144     return ACE_OS::stat (file, stp);
00145 # elif defined (ACE_HAS_X86_STAT_MACROS)
00146     // Solaris for intel uses an macro for lstat(), this macro is a
00147     // wrapper for _lxstat().
00148     ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1);
00149 # else /* !ACE_HAS_X86_STAT_MACROS */
00150     ACE_OSCALL_RETURN (::lstat (file, stp), int, -1);
00151 # endif /* ACE_LACKS_LSTAT */
00152   }

int ACE_OS::lwp_getparams ACE_Sched_Params  ) 
 

Definition at line 3351 of file OS_NS_Thread.cpp.

References ACE_id_t, 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().

03352 {
03353 #if defined (ACE_HAS_STHREADS) || defined (sun)
03354   // Get the class TS and RT class IDs.
03355   ACE_id_t rt_id;
03356   ACE_id_t ts_id;
03357   if (ACE_OS::scheduling_class ("RT", rt_id) == -1
03358       || ACE_OS::scheduling_class ("TS", ts_id) == -1)
03359     return -1;
03360 
03361   // Get this LWP's scheduling parameters.
03362   pcparms_t pcparms;
03363   // The following is just to avoid Purify warnings about unitialized
03364   // memory reads.
03365   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03366   pcparms.pc_cid = PC_CLNULL;
03367 
03368   if (ACE_OS::priority_control (P_LWPID,
03369                                 P_MYID,
03370                                 PC_GETPARMS,
03371                                 (char *) &pcparms) == -1)
03372     return -1;
03373   else if (pcparms.pc_cid == rt_id)
03374     {
03375       // RT class.
03376       rtparms_t rtparms;
03377       ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms);
03378 
03379       sched_params.policy (ACE_SCHED_FIFO);
03380       sched_params.priority (rtparms.rt_pri);
03381       sched_params.scope (ACE_SCOPE_THREAD);
03382       ACE_Time_Value quantum (rtparms.rt_tqsecs,
03383                               rtparms.rt_tqnsecs == RT_TQINF
03384                               ? 0 : rtparms.rt_tqnsecs * 1000);
03385       sched_params.quantum (quantum);
03386       return 0;
03387     }
03388   else if (pcparms.pc_cid == ts_id)
03389     {
03390       /* TS class */
03391       tsparms_t tsparms;
03392       ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms);
03393 
03394       sched_params.policy (ACE_SCHED_OTHER);
03395       sched_params.priority (tsparms.ts_upri);
03396       sched_params.scope (ACE_SCOPE_THREAD);
03397       return 0;
03398     }
03399   else
03400     return -1;
03401 
03402 #else  /* ! ACE_HAS_STHREADS && ! sun */
03403   ACE_UNUSED_ARG (sched_params);
03404   ACE_NOTSUP_RETURN (-1);
03405 #endif /* ! ACE_HAS_STHREADS && ! sun */
03406 }

int ACE_OS::lwp_setparams const ACE_Sched_Params  ) 
 

Definition at line 3409 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().

03410 {
03411 #if defined (ACE_HAS_STHREADS) || defined (sun)
03412   ACE_Sched_Params lwp_params (sched_params);
03413   lwp_params.scope (ACE_SCOPE_LWP);
03414   return ACE_OS::sched_params (lwp_params);
03415 #else  /* ! ACE_HAS_STHREADS && ! sun */
03416   ACE_UNUSED_ARG (sched_params);
03417   ACE_NOTSUP_RETURN (-1);
03418 #endif /* ! ACE_HAS_STHREADS && ! sun */
03419 }

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, caddr_t, 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 }

void * ACE_OS::malloc size_t   ) 
 

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(), and tempnam().

00285 {
00286   return ACE_MALLOC_FUNC (nbytes);
00287 }

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

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

Referenced by ACE_String_Base< CHAR >::compare(), ACE_INET_Addr::get_host_name_i(), 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_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.

Referenced by ACE_TLI_Acceptor::accept(), 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(), ACE_String_Base< CHAR >::append(), argv_to_string(), ACE_CDR::LongDouble::assign(), ACE_Data_Block::clone(), ACE_InputCDR::clone_from(), ACE_TLI_Connector::connect(), 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_TLI::get_option(), 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(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Name_Request::name(), ACE_CDR::LongDouble::operator NativeImpl(), putmsg(), ACE_InputCDR::read_array(), ACE_UPIPE_Stream::recv(), ACE_SOCK_Dgram::recv(), ACE_Codeset_Registry::registry_to_locale_i(), ACE_Obstack_T< CHAR >::request(), scandir_emulation(), ACE_SOCK_Dgram::send(), ACE_String_Base< CHAR >::set(), 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(), ACE_TLI::set_option(), 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.

Referenced by ACE_Message_Block::crunch(), ACE_Svc_Conf_Lexer::scan(), 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.

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_Profile_Timer::ACE_Profile_Timer(), 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(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), mutex_init(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_INET_Addr::reset(), ACE_String_Base< CHAR >::resize(), 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_INLINE int ACE_OS::mkdir const wchar_t *  path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS
 

Definition at line 186 of file OS_NS_sys_stat.inl.

References ACE_ADAPT_RETVAL, mkdir(), and mode_t.

00187   {
00188 #if defined (ACE_HAS_WINCE)
00189     ACE_UNUSED_ARG (mode);
00190     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (CreateDirectoryW (path, 0),
00191                                             ace_result_),
00192                           int, -1);
00193 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00194     ACE_UNUSED_ARG (mode);
00195     ACE_OSCALL_RETURN (::_wmkdir (path), int, -1);
00196 #else
00197     return ACE_OS::mkdir (ACE_Wide_To_Ascii (path).char_rep (), mode);
00198 #endif /* ACE_HAS_WINCE */
00199   }

ACE_INLINE int ACE_OS::mkdir const char *  path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS
 

Definition at line 168 of file OS_NS_sys_stat.inl.

References ACE_ADAPT_RETVAL, ACE_TEXT_CHAR_TO_TCHAR, mkdir(), and mode_t.

Referenced by mkdir().

00169   {
00170 #if defined (ACE_HAS_WINCE)
00171     ACE_UNUSED_ARG (mode);
00172     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (ACE_TEXT_CHAR_TO_TCHAR (path), 0),
00173                                             ace_result_),
00174                           int, -1);
00175 #elif defined (ACE_MKDIR_LACKS_MODE)
00176     ACE_UNUSED_ARG (mode);
00177     ACE_OSCALL_RETURN (::mkdir (path), int, -1);
00178 #else
00179     ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1);
00180 #endif
00181   }

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

Definition at line 204 of file OS_NS_sys_stat.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, mkfifo(), and mode_t.

Referenced by mkfifo(), ACE_FIFO::open(), and sema_init().

00205   {
00206     ACE_OS_TRACE ("ACE_OS::mkfifo");
00207 #if defined (ACE_LACKS_MKFIFO)
00208     ACE_UNUSED_ARG (file);
00209     ACE_UNUSED_ARG (mode);
00210     ACE_NOTSUP_RETURN (-1);
00211 #else
00212     ACE_OSCALL_RETURN (::mkfifo (ACE_TEXT_ALWAYS_CHAR (file), mode), int, -1);
00213 #endif /* ACE_LACKS_MKFIFO */
00214   }

ACE_INLINE ACE_HANDLE ACE_OS::mkstemp wchar_t *  s  ) 
 

Definition at line 195 of file OS_NS_stdlib.inl.

References ACE_TEXT_ALWAYS_CHAR, and ACE_TEXT_WCHAR_TO_TCHAR.

00196 {
00197 #  if !defined (ACE_LACKS_MKSTEMP)
00198   return ::mkstemp (ACE_TEXT_WCHAR_TO_TCHAR (ACE_TEXT_ALWAYS_CHAR (s)));
00199 #  else
00200   return ACE_OS::mkstemp_emulation (ACE_TEXT_WCHAR_TO_TCHAR (s));
00201 #  endif  /* !ACE_LACKS_MKSTEMP */
00202 }

ACE_INLINE ACE_HANDLE ACE_OS::mkstemp char *  s  ) 
 

Definition at line 184 of file OS_NS_stdlib.inl.

References ACE_TEXT_CHAR_TO_TCHAR.

Referenced by ACE_FILE_Connector::connect().

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

ACE_INLINE wchar_t * ACE_OS::mktemp wchar_t *  s  ) 
 

Definition at line 218 of file OS_NS_stdlib.inl.

References ACE_Wide_To_Ascii::char_rep(), strcpy(), and ACE_Ascii_To_Wide::wchar_rep().

00219 {
00220 #    if defined (ACE_WIN32)
00221   return ::_wmktemp (s);
00222 #    else
00223   // For narrow-char filesystems, we must convert the wide-char input to
00224   // a narrow-char string for mktemp (), then convert the name back to
00225   // wide-char for the caller.
00226   ACE_Wide_To_Ascii narrow_s (s);
00227   if (::mktemp (narrow_s.char_rep ()) == 0)
00228     return 0;
00229   ACE_Ascii_To_Wide wide_s (narrow_s.char_rep ());
00230   ACE_OS::strcpy (s, wide_s.wchar_rep ());
00231   return s;
00232 #    endif
00233 }

ACE_INLINE char * ACE_OS::mktemp char *  s  ) 
 

Definition at line 207 of file OS_NS_stdlib.inl.

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

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

time_t ACE_OS::mktime struct tm *  timeptr  ) 
 

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_INLINE 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_FAIL_RETURN, ACE_HIGH_PART, ACE_LOW_PART, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_CreateFileMapping, default_win32_security_attributes_r(), MAP_FAILED, MAP_FIXED, MAP_PRIVATE, and MAP_SHARED.

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::map_it(), 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   ::fsync(file_handle);
00151 #  endif
00152   ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr,
00153                                       len,
00154                                       prot,
00155                                       flags,
00156                                       file_handle,
00157                                       off),
00158                      void *, MAP_FAILED);
00159 #else
00160   ACE_UNUSED_ARG (addr);
00161   ACE_UNUSED_ARG (len);
00162   ACE_UNUSED_ARG (prot);
00163   ACE_UNUSED_ARG (flags);
00164   ACE_UNUSED_ARG (file_handle);
00165   ACE_UNUSED_ARG (off);
00166   ACE_UNUSED_ARG (file_mapping);
00167   ACE_UNUSED_ARG (sa);
00168   ACE_NOTSUP_RETURN (MAP_FAILED);
00169 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00170 }

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

Definition at line 178 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().

00179 {
00180   ACE_OS_TRACE ("ACE_OS::mprotect");
00181 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00182   DWORD dummy; // Sigh!
00183   return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1;
00184 #elif !defined (ACE_LACKS_MPROTECT)
00185   ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1);
00186 #else
00187   ACE_UNUSED_ARG (addr);
00188   ACE_UNUSED_ARG (len);
00189   ACE_UNUSED_ARG (prot);
00190   ACE_NOTSUP_RETURN (-1);
00191 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00192 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE 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_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_INLINE int ACE_OS::msync void *  addr,
size_t  len,
int  sync
 

Definition at line 195 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().

00196 {
00197   ACE_OS_TRACE ("ACE_OS::msync");
00198 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00199   ACE_UNUSED_ARG (sync);
00200 
00201   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1);
00202 #elif !defined (ACE_LACKS_MSYNC)
00203 # if !defined (ACE_HAS_BROKEN_NETBSD_MSYNC)
00204   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1);
00205 # else
00206   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len), int, -1);
00207   ACE_UNUSED_ARG (sync);
00208 # endif /* ACE_HAS_BROKEN_NETBSD_MSYNC */
00209 #else
00210   ACE_UNUSED_ARG (addr);
00211   ACE_UNUSED_ARG (len);
00212   ACE_UNUSED_ARG (sync);
00213   ACE_NOTSUP_RETURN (-1);
00214 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00215 }

ACE_INLINE int ACE_OS::munmap void *  addr,
size_t  len
 

Definition at line 218 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().

00219 {
00220   ACE_OS_TRACE ("ACE_OS::munmap");
00221 #if defined (ACE_WIN32)
00222   ACE_UNUSED_ARG (len);
00223 
00224   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1);
00225 #elif !defined (ACE_LACKS_MMAP)
00226   ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1);
00227 #else
00228   ACE_UNUSED_ARG (addr);
00229   ACE_UNUSED_ARG (len);
00230   ACE_NOTSUP_RETURN (-1);
00231 #endif /* ACE_WIN32 */
00232 }

int ACE_OS::mutex_destroy ACE_mutex_t *  m  ) 
 

Definition at line 1961 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, mutex_destroy(), and thread_mutex_destroy().

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

01962 {
01963   ACE_OS_TRACE ("ACE_OS::mutex_destroy");
01964 #if defined (ACE_HAS_THREADS)
01965 # if defined (ACE_HAS_PTHREADS)
01966 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
01967   ACE_OSCALL_RETURN (::pthread_mutex_destroy (m), int, -1);
01968 #   else
01969   int result;
01970   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
01971                      result), int, -1);
01972 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/
01973 # elif defined (ACE_HAS_STHREADS)
01974   int result;
01975   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1);
01976 # elif defined (ACE_HAS_WTHREADS)
01977   switch (m->type_)
01978 {
01979   case USYNC_PROCESS:
01980     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
01981                           ace_result_),
01982     int, -1);
01983   case USYNC_THREAD:
01984     return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
01985   default:
01986     errno = EINVAL;
01987     return -1;
01988 }
01989   /* NOTREACHED */
01990 # elif defined (ACE_VXWORKS)
01991   return ::semDelete (*m) == OK ? 0 : -1;
01992 # endif /* Threads variety case */
01993 #else
01994   ACE_UNUSED_ARG (m);
01995   ACE_NOTSUP_RETURN (-1);
01996 #endif /* ACE_HAS_THREADS */
01997 }

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

Definition at line 2001 of file OS_NS_Thread.cpp.

References ACE_FAIL_RETURN, mutex_init(), and thread_mutex_init().

02007 {
02008 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02009   m->type_ = lock_scope;
02010   SECURITY_ATTRIBUTES sa_buffer;
02011   SECURITY_DESCRIPTOR sd_buffer;
02012   switch (lock_scope)
02013   {
02014     case USYNC_PROCESS:
02015       m->proc_mutex_ =
02016       ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
02017           (sa, &sa_buffer, &sd_buffer),
02018       FALSE,
02019       name);
02020       if (m->proc_mutex_ == 0)
02021         ACE_FAIL_RETURN (-1);
02022       else
02023         return 0;
02024     case USYNC_THREAD:
02025       return ACE_OS::thread_mutex_init (&m->thr_mutex_,
02026                                          lock_type,
02027                                          name,
02028                                          attributes);
02029   }
02030 
02031   errno = EINVAL;
02032   return -1;
02033 #else /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
02034   return ACE_OS::mutex_init (m,
02035                              lock_scope,
02036                              ACE_Wide_To_Ascii (name).char_rep (),
02037                              attributes,
02038                              sa,
02039                              lock_type);
02040 #endif /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
02041 }

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

Definition at line 1779 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, memset(), mutex_init(), set_errno_to_last_error(), and thread_mutex_init().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), mutex_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 defined (ACE_HAS_PTHREADS_DRAFT4)
01812       if (::pthread_mutexattr_create (attributes) == 0)
01813 #   elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01814       if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0)
01815 #   else /* draft 6 */
01816       if (::pthread_mutexattr_init (attributes) == 0)
01817 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01818 {
01819   result = 0;
01820   attr_init = 1; // we have initialized these attributes
01821 }
01822       else
01823         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01824   }
01825 
01826   if (result == 0 && lock_scope != 0)
01827 {
01828 #   if defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01829 #     if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01830       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes,
01831                                                                lock_scope),
01832                                result);
01833 #     endif /* _POSIX_THREAD_PROCESS_SHARED && !ACE_LACKS_MUTEXATTR_PSHARED */
01834 #   else /* Pthreads draft 6 */
01835 #     if !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01836       if (::pthread_mutexattr_setpshared (attributes, lock_scope) != 0)
01837         result = -1;
01838 #     endif /* ACE_LACKS_MUTEXATTR_PSHARED */
01839 #   endif /* ACE_HAS_PTHREADS_DRAFT7 || ACE_HAS_PTHREADS_STD */
01840 }
01841 
01842   if (result == 0 && lock_type != 0)
01843 {
01844 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01845 #     if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP)
01846       if (::pthread_mutexattr_setkind_np (attributes, lock_type) != 0)
01847         result = -1;
01848 #     endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */
01849 #   elif defined (ACE_HAS_RECURSIVE_MUTEXES)
01850       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes,
01851                                                             lock_type),
01852                                result);
01853 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01854 }
01855 
01856   if (result == 0)
01857 {
01858 #   if defined (ACE_VXWORKS)&& (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
01859       /* VxWorks 6.x API reference states:
01860        * If the memory for the mutex variable object has been allocated
01861        *   dynamically, it is a good policy to always zero out the
01862        *   block of memory so as to avoid spurious EBUSY return code
01863        *   when calling this routine.
01864        * Tests shows this to be necessary.
01865        */
01866       ACE_OS::memset (m, 0, sizeof (*m));
01867 #   endif
01868 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01869       if (::pthread_mutex_init (m, *attributes) == 0)
01870 #   elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01871       if (ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0)
01872 #   else
01873       if (::pthread_mutex_init (m, attributes) == 0)
01874 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01875         result = 0;
01876       else
01877         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01878 }
01879 
01880   // Only do the deletions if the <attributes> parameter wasn't
01881   // originally set.
01882   if (attributes == &l_attributes && attr_init)
01883 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01884   ::pthread_mutexattr_delete (&l_attributes);
01885 #   else
01886   ::pthread_mutexattr_destroy (&l_attributes);
01887 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01888 
01889   return result;
01890 # elif defined (ACE_HAS_STHREADS)
01891   ACE_UNUSED_ARG (name);
01892   ACE_UNUSED_ARG (sa);
01893   ACE_UNUSED_ARG (lock_type);
01894   int result;
01895   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m,
01896                      lock_scope,
01897                      attributes),
01898   result),
01899   int, -1);
01900 # elif defined (ACE_HAS_WTHREADS)
01901   m->type_ = lock_scope;
01902 
01903   SECURITY_ATTRIBUTES sa_buffer;
01904   SECURITY_DESCRIPTOR sd_buffer;
01905   switch (lock_scope)
01906 {
01907   case USYNC_PROCESS:
01908 #   if defined (ACE_HAS_WINCE)
01909       // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
01910       m->proc_mutex_ =
01911   ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
01912                           (sa, &sa_buffer, &sd_buffer),
01913                         FALSE,
01914                         ACE_Ascii_To_Wide (name).wchar_rep ());
01915 #   else /* ACE_HAS_WINCE */
01916       m->proc_mutex_ =
01917   ::CreateMutexA (ACE_OS::default_win32_security_attributes_r
01918                           (sa, &sa_buffer, &sd_buffer),
01919                         FALSE,
01920                         name);
01921 #   endif /* ACE_HAS_WINCE */
01922       if (m->proc_mutex_ == 0)
01923         ACE_FAIL_RETURN (-1);
01924       else
01925       {
01926           // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01927         ACE_OS::set_errno_to_last_error ();
01928         return 0;
01929       }
01930   case USYNC_THREAD:
01931     return ACE_OS::thread_mutex_init (&m->thr_mutex_,
01932                                        lock_type,
01933                                        name,
01934                                        attributes);
01935   default:
01936     errno = EINVAL;
01937     return -1;
01938 }
01939   /* NOTREACHED */
01940 
01941 # elif defined (ACE_VXWORKS)
01942   ACE_UNUSED_ARG (name);
01943   ACE_UNUSED_ARG (attributes);
01944   ACE_UNUSED_ARG (sa);
01945   ACE_UNUSED_ARG (lock_type);
01946 
01947   return (*m = ::semMCreate (lock_scope)) == 0 ? -1 : 0;
01948 # endif /* ACE_HAS_PTHREADS */
01949 #else
01950   ACE_UNUSED_ARG (m);
01951   ACE_UNUSED_ARG (lock_scope);
01952   ACE_UNUSED_ARG (name);
01953   ACE_UNUSED_ARG (attributes);
01954   ACE_UNUSED_ARG (sa);
01955   ACE_UNUSED_ARG (lock_type);
01956   ACE_NOTSUP_RETURN (-1);
01957 #endif /* ACE_HAS_THREADS */
01958 }

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

If == 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 446 of file OS_NS_Thread.inl.

References mutex_lock().

00448 {
00449   return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
00450 }

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

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, EBUSY, ETIME, ETIMEDOUT, ACE_Time_Value::msec(), ACE_Time_Value::sec(), set_errno_to_last_error(), timespec_t, and ACE_Time_Value::usec().

02138 {
02139 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS)
02140 
02141 #  if defined (ACE_HAS_PTHREADS)
02142   int result;
02143 
02144   // "timeout" should be an absolute time.
02145 
02146   timespec_t ts = timeout;  // Calls ACE_Time_Value::operator timespec_t().
02147 
02148   // Note that the mutex should not be a recursive one, i.e., it
02149   // should only be a standard mutex or an error checking mutex.
02150 
02151   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result);
02152 
02153   // We need to adjust this to make the errno values consistent.
02154   if (result == -1 && errno == ETIMEDOUT)
02155     errno = ETIME;
02156   return result;
02157 
02158 #  elif defined (ACE_HAS_WTHREADS)
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   switch (m->type_)
02165   {
02166     case USYNC_PROCESS:
02167       switch (::WaitForSingleObject (m->proc_mutex_,
02168                 relative_time.msec ()))
02169       {
02170         case WAIT_OBJECT_0:
02171         case WAIT_ABANDONED:
02172           // We will ignore abandonments in this method
02173           // Note that we still hold the lock
02174           return 0;
02175         case WAIT_TIMEOUT:
02176           errno = ETIME;
02177           return -1;
02178         default:
02179           // This is a hack, we need to find an appropriate mapping...
02180           ACE_OS::set_errno_to_last_error ();
02181           return -1;
02182       }
02183     case USYNC_THREAD:
02184       ACE_NOTSUP_RETURN (-1);
02185     default:
02186       errno = EINVAL;
02187       return -1;
02188   }
02189   /* NOTREACHED */
02190 
02191 #  elif defined (ACE_VXWORKS)
02192 
02193   // Note that we must convert between absolute time (which is passed
02194   // as a parameter) and relative time (which is what the system call
02195   // expects).
02196   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
02197 
02198   int ticks_per_sec = ::sysClkRateGet ();
02199 
02200   int ticks = relative_time.sec() * ticks_per_sec +
02201       relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02202   if (::semTake (*m, ticks) == ERROR)
02203   {
02204     if (errno == S_objLib_OBJ_TIMEOUT)
02205         // Convert the VxWorks errno to one that's common for to ACE
02206         // platforms.
02207       errno = ETIME;
02208     else if (errno == S_objLib_OBJ_UNAVAILABLE)
02209       errno = EBUSY;
02210     return -1;
02211   }
02212   else
02213     return 0;
02214 #  endif /* ACE_HAS_PTHREADS */
02215 
02216 #else
02217   ACE_UNUSED_ARG (m);
02218   ACE_UNUSED_ARG (timeout);
02219   ACE_NOTSUP_RETURN (-1);
02220 #endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */
02221 }

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

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, set_errno_to_last_error(), and thread_mutex_lock().

02099 {
02100   ACE_OS_TRACE ("ACE_OS::mutex_lock");
02101 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02102   abandoned = 0;
02103   switch (m->type_)
02104   {
02105     case USYNC_PROCESS:
02106       switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02107       {
02108         //
02109           // Timeout can't occur, so don't bother checking...
02110         //
02111         case WAIT_OBJECT_0:
02112           return 0;
02113         case WAIT_ABANDONED:
02114           abandoned = 1;
02115           return 0;  // something goofed, but we hold the lock ...
02116         default:
02117           // This is a hack, we need to find an appropriate mapping...
02118           ACE_OS::set_errno_to_last_error ();
02119           return -1;
02120       }
02121     case USYNC_THREAD:
02122       return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02123     default:
02124       errno = EINVAL;
02125       return -1;
02126   }
02127   /* NOTREACHED */
02128 #else
02129   ACE_UNUSED_ARG (m);
02130   ACE_UNUSED_ARG (abandoned);
02131   ACE_NOTSUP_RETURN (-1);
02132 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02133 }

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

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, mutex_lock(), set_errno_to_last_error(), and thread_mutex_lock().

Referenced by ACE_Mutex::acquire(), ACE_Mutex::acquire_read(), ACE_Mutex::acquire_write(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), 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().

02046 {
02047   // ACE_OS_TRACE ("ACE_OS::mutex_lock");
02048 #if defined (ACE_HAS_THREADS)
02049 # if defined (ACE_HAS_PTHREADS)
02050   // Note, don't use "::" here since the following call is often a macro.
02051 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
02052   ACE_OSCALL_RETURN (pthread_mutex_lock (m), int, -1);
02053 #   else
02054   int result;
02055   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), result),
02056                      int, -1);
02057 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02058 # elif defined (ACE_HAS_STHREADS)
02059   int result;
02060   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), result), int, -1);
02061 # elif defined (ACE_HAS_WTHREADS)
02062   switch (m->type_)
02063 {
02064   case USYNC_PROCESS:
02065     switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02066       {
02067         //
02068         // Timeout can't occur, so don't bother checking...
02069         //
02070       case WAIT_OBJECT_0:
02071       case WAIT_ABANDONED:
02072         // We will ignore abandonments in this method
02073         // Note that we still hold the lock
02074         return 0;
02075       default:
02076         // This is a hack, we need to find an appropriate mapping...
02077         ACE_OS::set_errno_to_last_error ();
02078         return -1;
02079       }
02080   case USYNC_THREAD:
02081     return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02082   default:
02083     errno = EINVAL;
02084     return -1;
02085 }
02086   /* NOTREACHED */
02087 # elif defined (ACE_VXWORKS)
02088   return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1;
02089 # endif /* Threads variety case */
02090 #else
02091   ACE_UNUSED_ARG (m);
02092   ACE_NOTSUP_RETURN (-1);
02093 #endif /* ACE_HAS_THREADS */
02094 }

void ACE_OS::mutex_lock_cleanup void *  mutex  ) 
 

Handle asynchronous thread cancellation cleanup.

Definition at line 2377 of file OS_NS_Thread.cpp.

References ACE_OS_TRACE, and mutex_unlock().

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

int ACE_OS::mutex_trylock ACE_mutex_t *  m,
int &  abandoned
 

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

Definition at line 2298 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, EBUSY, set_errno_to_last_error(), and thread_mutex_trylock().

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

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

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_trylock(), set_errno_to_last_error(), and thread_mutex_trylock().

Referenced by mutex_trylock(), thread_mutex_trylock(), ACE_Mutex::tryacquire(), ACE_Mutex::tryacquire_read(), and ACE_Mutex::tryacquire_write().

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

int ACE_OS::mutex_unlock ACE_mutex_t *  m  ) 
 

Definition at line 2337 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, mutex_unlock(), and thread_mutex_unlock().

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

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

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

Definition at line 400 of file OS_NS_time.inl.

References ACE_OS_TRACE, ACE_TIMESPEC_PTR, and sleep().

Referenced by sleep().

00402 {
00403   ACE_OS_TRACE ("ACE_OS::nanosleep");
00404 #if defined (ACE_HAS_CLOCK_GETTIME)
00405   // ::nanosleep () is POSIX 1003.1b.  So is ::clock_gettime ().  So,
00406   // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should
00407   // be available on the platform.  On Solaris 2.x, both functions
00408   // require linking with -lposix4.
00409   return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining);
00410 #else
00411   ACE_UNUSED_ARG (remaining);
00412 
00413   // Convert into seconds and microseconds.
00414   ACE_Time_Value tv (requested->tv_sec,
00415                      requested->tv_nsec / 1000);
00416   return ACE_OS::sleep (tv);
00417 #endif /* ACE_HAS_CLOCK_GETTIME */
00418 }

long ACE_OS::num_processors void   ) 
 

Get the number of CPUs configured in the machine.

Definition at line 329 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and num_processors().

Referenced by num_processors(), and num_processors_online().

00330 {
00331   ACE_OS_TRACE ("ACE_OS::num_processors");
00332 
00333 #if defined (ACE_HAS_PHARLAP)
00334   return 1;
00335 #elif defined (ACE_WIN32)
00336   SYSTEM_INFO sys_info;
00337   ::GetSystemInfo (&sys_info);
00338   return sys_info.dwNumberOfProcessors;
00339 #elif defined (_SC_NPROCESSORS_CONF)
00340   return ::sysconf (_SC_NPROCESSORS_CONF);
00341 #elif defined (ACE_HAS_SYSCTL)
00342   int num_processors;
00343   int mib[2] = { CTL_HW, HW_NCPU };
00344   size_t len = sizeof (num_processors);
00345   if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
00346     return num_processors;
00347   else
00348     return -1;
00349 #elif defined (__hpux)
00350   struct pst_dynamic psd;
00351   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00352     return psd.psd_max_proc_cnt;
00353   else
00354     return -1;
00355 #else
00356   ACE_NOTSUP_RETURN (-1);
00357 #endif
00358 }

long ACE_OS::num_processors_online void   ) 
 

Get the number of CPUs currently online.

Definition at line 361 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and num_processors().

00362 {
00363   ACE_OS_TRACE ("ACE_OS::num_processors_online");
00364 
00365 #if defined (ACE_HAS_PHARLAP)
00366   return 1;
00367 #elif defined (ACE_WIN32)
00368   SYSTEM_INFO sys_info;
00369   ::GetSystemInfo (&sys_info);
00370   return sys_info.dwNumberOfProcessors;
00371 #elif defined (_SC_NPROCESSORS_ONLN)
00372   return ::sysconf (_SC_NPROCESSORS_ONLN);
00373 #elif defined (ACE_HAS_SYSCTL)
00374   int num_processors;
00375   int mib[2] = { CTL_HW, HW_NCPU };
00376   size_t len = sizeof (num_processors);
00377   if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1)
00378     return num_processors;
00379   else
00380     return -1;
00381 #elif defined (__hpux)
00382   struct pst_dynamic psd;
00383   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00384     return psd.psd_proc_cnt;
00385   else
00386     return -1;
00387 #else
00388   ACE_NOTSUP_RETURN (-1);
00389 #endif
00390 }

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

Definition at line 140 of file OS_NS_fcntl.cpp.

References access(), ACE_BIT_ENABLED, ACE_FAIL_RETURN, mode_t, open(), and thread_mutex_lock().

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

ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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_FAIL_RETURN, ACE_OS_TRACE, mode_t, strcmp(), and thread_mutex_lock().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_SPIPE_Connector::connect(), ACE_Handle_Gobbler::consume_handles(), creat(), dlopen(), filesize(), fopen(), ACE::get_handle(), ACE::handle_timed_open(), open(), ACE_Mem_Map::open(), ACE_FIFO_Recv::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_INLINE ACE_DIR * ACE_OS::opendir const ACE_TCHAR filename  ) 
 

Definition at line 36 of file OS_NS_dirent.inl.

References ACE_NOTSUP_RETURN, ACE_TCHAR, 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 void ACE_OS::perror const wchar_t *  s  ) 
 

Definition at line 780 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and ACE_Wide_To_Ascii::char_rep().

00781 {
00782   ACE_OS_TRACE ("ACE_OS::perror");
00783 #if defined (ACE_LACKS_PERROR)
00784   ACE_UNUSED_ARG (s);
00785 #elif defined (ACE_WIN32)
00786   ::_wperror (s);
00787 #else
00788   ACE_Wide_To_Ascii n_s (s);
00789   ::perror (n_s.char_rep ());
00790 #endif /* ACE_HAS_WINCE */
00791 }

ACE_INLINE void ACE_OS::perror const char *  s  ) 
 

Definition at line 768 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00769 {
00770   ACE_OS_TRACE ("ACE_OS::perror");
00771 #if defined (ACE_LACKS_PERROR)
00772   ACE_UNUSED_ARG (s);
00773 #else
00774   ::perror (s);
00775 #endif /* ACE_HAS_WINCE */
00776 }

ACE_INLINE 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_INLINE 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 tv = 0
 

Definition at line 11 of file OS_NS_poll.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and poll().

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 }

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

Definition at line 418 of file OS_NS_unistd.cpp.

References ACE_HIGH_PART, ACE_LOW_PART, ACE_OFF_T, ACE_OS_GUARD, lseek(), read(), and ssize_t.

00422 {
00423 # if defined (ACE_HAS_P_READ_WRITE)
00424 #   if defined (ACE_WIN32)
00425 
00426   ACE_OS_GUARD
00427 
00428   // Remember the original file pointer position
00429   LONG original_high_position = 0;
00430   DWORD original_low_position = ::SetFilePointer (handle,
00431                                                   0,
00432                                                   &original_high_position,
00433                                                   FILE_CURRENT);
00434 
00435   if (original_low_position == INVALID_SET_FILE_POINTER
00436       && GetLastError () != NO_ERROR)
00437     return -1;
00438 
00439   // Go to the correct position
00440   LONG low_offset = ACE_LOW_PART (offset);
00441   LONG high_offset = ACE_HIGH_PART (offset);
00442   DWORD altered_position = ::SetFilePointer (handle,
00443                                              low_offset,
00444                                              &high_offset,
00445                                              FILE_BEGIN);
00446   if (altered_position == INVALID_SET_FILE_POINTER
00447       && GetLastError () != NO_ERROR)
00448     return -1;
00449 
00450   DWORD bytes_read;
00451 
00452 #     if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00453 
00454   OVERLAPPED overlapped;
00455   overlapped.Internal = 0;
00456   overlapped.InternalHigh = 0;
00457   overlapped.Offset = low_offset;
00458   overlapped.OffsetHigh = high_offset;
00459   overlapped.hEvent = 0;
00460 
00461   BOOL result = ::ReadFile (handle,
00462                             buf,
00463                             static_cast <DWORD> (nbytes),
00464                             &bytes_read,
00465                             &overlapped);
00466 
00467   if (result == FALSE)
00468     {
00469       if (::GetLastError () != ERROR_IO_PENDING)
00470         return -1;
00471 
00472       else
00473         {
00474           result = ::GetOverlappedResult (handle,
00475                                           &overlapped,
00476                                           &bytes_read,
00477                                           TRUE);
00478           if (result == FALSE)
00479             return -1;
00480         }
00481     }
00482 
00483 #     else /* ACE_HAS_WIN32_OVERLAPPED_IO */
00484 
00485   BOOL result = ::ReadFile (handle,
00486                             buf,
00487                             nbytes,
00488                             &bytes_read,
00489                             0);
00490   if (result == FALSE)
00491     return -1;
00492 
00493 #     endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00494 
00495   // Reset the original file pointer position
00496   if (::SetFilePointer (handle,
00497                         original_low_position,
00498                         &original_high_position,
00499                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00500       && GetLastError () != NO_ERROR)
00501     return -1;
00502 
00503   return (ssize_t) bytes_read;
00504 
00505 #   else /* ACE_WIN32 */
00506 
00507   return ::pread (handle, buf, nbytes, offset);
00508 
00509 #   endif /* ACE_WIN32 */
00510 
00511 # else /* ACE_HAS_P_READ_WRITE */
00512 
00513   ACE_OS_GUARD
00514 
00515   // Remember the original file pointer position
00516   ACE_OFF_T original_position = ACE_OS::lseek (handle,
00517                                                0,
00518                                                SEEK_CUR);
00519 
00520   if (original_position == -1)
00521     return -1;
00522 
00523   // Go to the correct position
00524   ACE_OFF_T altered_position = ACE_OS::lseek (handle, offset, SEEK_SET);
00525 
00526   if (altered_position == -1)
00527     return -1;
00528 
00529   ssize_t const bytes_read = ACE_OS::read (handle, buf, nbytes);
00530 
00531   if (bytes_read == -1)
00532     return -1;
00533 
00534   if (ACE_OS::lseek (handle,
00535                      original_position,
00536                      SEEK_SET) == -1)
00537     return -1;
00538 
00539   return bytes_read;
00540 
00541 # endif /* ACE_HAD_P_READ_WRITE */
00542 }

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

Definition at line 300 of file OS_NS_stdio.cpp.

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

00301 {
00302   // ACE_OS_TRACE ("ACE_OS::printf");
00303   int result;
00304   va_list ap;
00305   va_start (ap, format);
00306   ACE_OSCALL (::vprintf (format, ap), int, -1, result);
00307   va_end (ap);
00308   return result;
00309 }

ACE_INLINE long ACE_OS::priority_control ACE_idtype_t  ,
ACE_id_t  ,
int  ,
void * 
 

Low-level interface to (2).

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

Definition at line 489 of file OS_NS_Thread.inl.

References ACE_id_t, ACE_idtype_t, 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().

00490 {
00491   ACE_OS_TRACE ("ACE_OS::priority_control");
00492 #if defined (ACE_HAS_PRIOCNTL)
00493   ACE_OSCALL_RETURN (priocntl (idtype, identifier, cmd, static_cast<caddr_t> (arg)),
00494                      long, -1);
00495 #else  /* ! ACE_HAS_PRIOCNTL*/
00496   ACE_UNUSED_ARG (idtype);
00497   ACE_UNUSED_ARG (identifier);
00498   ACE_UNUSED_ARG (cmd);
00499   ACE_UNUSED_ARG (arg);
00500   ACE_NOTSUP_RETURN (-1);
00501 #endif /* ! ACE_HAS_PRIOCNTL*/
00502 }

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, ACE_NOTSUP_RETURN, and pthread_sigmask().

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

00028 {
00029 #if defined (ACE_HAS_PTHREADS_STD) && !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_STD && !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_STD && !ACE_LACKS_PTHREAD_SIGMASK */
00041 }

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

Definition at line 672 of file OS_NS_stdio.inl.

References ace_putc_helper().

00673 {
00674   return ace_putc_helper (c, fp);
00675 }

ACE_INLINE int ACE_OS::putenv const wchar_t *  string  ) 
 

Definition at line 284 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00285 {
00286   ACE_OS_TRACE ("ACE_OS::putenv");
00287 #if defined (ACE_HAS_WINCE)
00288   // WinCE doesn't have the concept of environment variables.
00289   ACE_UNUSED_ARG (string);
00290   ACE_NOTSUP_RETURN (-1);
00291 #else
00292   ACE_OSCALL_RETURN (::_wputenv (string), int, -1);
00293 #endif /* ACE_HAS_WINCE */
00294 }

ACE_INLINE int ACE_OS::putenv const char *  string  ) 
 

Definition at line 245 of file OS_NS_stdlib.inl.

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

Referenced by ACE_Process::spawn().

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

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, ACE_STRBUF_TYPE, memcpy(), putmsg(), ssize_t, 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_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, ACE_STRBUF_TYPE, 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::puts const wchar_t *  s  ) 
 

Definition at line 803 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_Wide_To_Ascii::char_rep(), and puts().

00804 {
00805   ACE_OS_TRACE ("ACE_OS::puts");
00806 #if defined (ACE_WIN32)
00807   ACE_OSCALL_RETURN (::_putws (s), int, -1);
00808 #else /* ACE_WIN32 */
00809   // There's no putws()...
00810   ACE_Wide_To_Ascii n_s (s);
00811   ACE_OSCALL_RETURN (::puts (n_s.char_rep ()), int, -1);
00812 #endif /* ACE_WIN32 */
00813 }

ACE_INLINE int ACE_OS::puts const char *  s  ) 
 

Definition at line 795 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and puts().

Referenced by puts().

00796 {
00797   ACE_OS_TRACE ("ACE_OS::puts");
00798   ACE_OSCALL_RETURN (::puts (s), int, -1);
00799 }

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

Definition at line 545 of file OS_NS_unistd.cpp.

References ACE_OFF_T, ACE_OS_GUARD, lseek(), set_errno_to_last_error(), ssize_t, and write().

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

00549 {
00550 # if defined (ACE_HAS_P_READ_WRITE)
00551 #   if defined (ACE_WIN32)
00552 
00553   ACE_OS_GUARD
00554 
00555   // Remember the original file pointer position
00556   LARGE_INTEGER orig_position;
00557   orig_position.QuadPart = 0;
00558   orig_position.LowPart = ::SetFilePointer (handle,
00559                                             0,
00560                                             &orig_position.HighPart,
00561                                             FILE_CURRENT);
00562   if (orig_position.LowPart == INVALID_SET_FILE_POINTER
00563       && GetLastError () != NO_ERROR)
00564     return -1;
00565 
00566   DWORD bytes_written;
00567   LARGE_INTEGER loffset;
00568   loffset.QuadPart = offset;
00569 
00570 #     if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00571 
00572   OVERLAPPED overlapped;
00573   overlapped.Internal = 0;
00574   overlapped.InternalHigh = 0;
00575   overlapped.Offset = loffset.LowPart;
00576   overlapped.OffsetHigh = loffset.HighPart;
00577   overlapped.hEvent = 0;
00578 
00579   BOOL result = ::WriteFile (handle,
00580                              buf,
00581                              static_cast <DWORD> (nbytes),
00582                              &bytes_written,
00583                              &overlapped);
00584 
00585   if (result == FALSE)
00586     {
00587       if (::GetLastError () != ERROR_IO_PENDING)
00588         return -1;
00589 
00590       result = ::GetOverlappedResult (handle,
00591                                       &overlapped,
00592                                       &bytes_written,
00593                                       TRUE);
00594       if (result == FALSE)
00595         return -1;
00596     }
00597 
00598 #     else /* ACE_HAS_WIN32_OVERLAPPED_IO */
00599 
00600   // Go to the correct position; if this is a Windows variant without
00601   // overlapped I/O, it probably doesn't have SetFilePointerEx either,
00602   // so manage this with SetFilePointer, changing calls based on the use
00603   // of 64 bit offsets.
00604   DWORD newpos;
00605 #       if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
00606   newpos = ::SetFilePointer (handle,
00607                              loffset.LowPart,
00608                              &loffset.HighPart,
00609                              FILE_BEGIN);
00610 #       else
00611   newpos = ::SetFilePointer (handle,
00612                              loffset.LowPart,
00613                              0,
00614                              FILE_BEGIN);
00615 #       endif /* 64-bit file offsets */
00616   if (newpos == 0xFFFFFFFF && ::GetLastError () != NO_ERROR)
00617     {
00618       ACE_OS::set_errno_to_last_error ();
00619       return -1;
00620     }
00621 
00622   BOOL result = ::WriteFile (handle,
00623                              buf,
00624                              nbytes,
00625                              &bytes_written,
00626                              0);
00627   if (result == FALSE)
00628     return -1;
00629 
00630 #     endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00631 
00632   // Reset the original file pointer position
00633   if (::SetFilePointer (handle,
00634                         orig_position.LowPart,
00635                         &orig_position.HighPart,
00636                         FILE_BEGIN) == INVALID_SET_FILE_POINTER
00637       && GetLastError () != NO_ERROR)
00638     return -1;
00639 
00640   return (ssize_t) bytes_written;
00641 
00642 #   else /* ACE_WIN32 */
00643 
00644   return ::pwrite (handle, buf, nbytes, offset);
00645 #   endif /* ACE_WIN32 */
00646 # else /* ACE_HAS_P_READ_WRITE */
00647 
00648   ACE_OS_GUARD
00649 
00650   // Remember the original file pointer position
00651   ACE_OFF_T original_position = ACE_OS::lseek (handle,
00652                                                0,
00653                                                SEEK_CUR);
00654   if (original_position == -1)
00655     return -1;
00656 
00657   // Go to the correct position
00658   ACE_OFF_T altered_position = ACE_OS::lseek (handle,
00659                                               offset,
00660                                               SEEK_SET);
00661   if (altered_position == -1)
00662     return -1;
00663 
00664   ssize_t const bytes_written = ACE_OS::write (handle,
00665                                                buf,
00666                                                nbytes);
00667   if (bytes_written == -1)
00668     return -1;
00669 
00670   if (ACE_OS::lseek (handle,
00671                      original_position,
00672                      SEEK_SET) == -1)
00673     return -1;
00674 
00675   return bytes_written;
00676 # endif /* ACE_HAS_P_READ_WRITE */
00677 }

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

Definition at line 298 of file OS_NS_stdlib.inl.

References ACE_COMPARE_FUNC.

Referenced by scandir_emulation().

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

ACE_INLINE int ACE_OS::rand void   ) 
 

Definition at line 314 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and rand().

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

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

ACE_INLINE int ACE_OS::rand_r ACE_RANDR_TYPE seed  ) 
 

Definition at line 344 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and ACE_RANDR_TYPE.

00345 {
00346   ACE_OS_TRACE ("ACE_OS::rand_r");
00347 
00348   long new_seed = (long) (seed);
00349   if (new_seed == 0)
00350     new_seed = 0x12345987;
00351   long temp = new_seed / 127773;
00352   new_seed = 16807 * (new_seed - temp * 127773) - 2836 * temp;
00353   if (new_seed < 0)
00354     new_seed += 2147483647;
00355  (seed) = (unsigned int)new_seed;
00356   return (int) (new_seed & RAND_MAX);
00357 }

ACE_INLINE 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_FAIL_RETURN, ACE_OS_TRACE, ACE_OVERLAPPED, read(), and ssize_t.

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::read ACE_HANDLE  handle,
void *  buf,
size_t  len
 

Definition at line 687 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, EWOULDBLOCK, and ssize_t.

Referenced by ACE_UPIPE_Acceptor::accept(), 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 }

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 (uses the <ACE_OS::read> call, which uses the system call on UNIX and the 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 393 of file OS_NS_unistd.cpp.

References read(), and ssize_t.

Referenced by ACE::read_n().

00397 {
00398   size_t temp;
00399   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00400   ssize_t n = 0;
00401 
00402   for (bytes_transferred = 0;
00403        bytes_transferred < len;
00404        bytes_transferred += n)
00405     {
00406       n = ACE_OS::read (handle,
00407                         (char *) buf + bytes_transferred,
00408                         len - bytes_transferred);
00409 
00410       if (n == -1 || n == 0)
00411         return n;
00412     }
00413 
00414   return bytes_transferred;
00415 }

ACE_INLINE struct ACE_DIRENT * ACE_OS::readdir ACE_DIR  ) 
 

Definition at line 55 of file OS_NS_dirent.inl.

References ACE_DIR, and 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_DIR, 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 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, readlink(), and ssize_t.

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_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, readv(), and ssize_t.

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 }

void * ACE_OS::realloc void *  ,
size_t 
 

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_INLINE wchar_t * ACE_OS::realpath const wchar_t *  file_name,
wchar_t *  resolved_name
 

Definition at line 377 of file OS_NS_stdlib.inl.

References ACE_Wide_To_Ascii::char_rep(), PATH_MAX, realpath(), strcpy(), and ACE_Ascii_To_Wide::wchar_rep().

00379 {
00380 #    if defined (ACE_WIN32)
00381   return ::_wfullpath (resolved_name, file_name, PATH_MAX);
00382 #    else /* ACE_WIN32 */
00383   ACE_Wide_To_Ascii n_file_name (file_name);
00384   char n_resolved[PATH_MAX];
00385   if (0 != ACE_OS::realpath (n_file_name.char_rep (), n_resolved))
00386     {
00387       ACE_Ascii_To_Wide w_resolved (n_resolved);
00388       ACE_OS::strcpy (resolved_name, w_resolved.wchar_rep ());
00389       return resolved_name;
00390     }
00391   return 0;
00392 #    endif /* ! ACE_WIN32 */
00393 }

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

Definition at line 364 of file OS_NS_stdlib.inl.

References PATH_MAX.

Referenced by realpath().

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

ACE_INLINE void ACE_OS::recursive_mutex_cond_relock ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state
 

Definition at line 636 of file OS_NS_Thread.inl.

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

00638 {
00639 #if defined (ACE_HAS_THREADS)
00640   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock");
00641 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00642   // Windows need special handling since it has recursive mutexes, but
00643   // does not integrate them into a condition variable.
00644   // On entry, the OS has already reacquired the lock for us. Just
00645   // reacquire it the proper number of times so the recursion is the same as
00646   // before waiting on the condition.
00647 #    if defined (ACE_WIN32)
00648   while (state.relock_count_ > 0)
00649     {
00650       ACE_OS::recursive_mutex_lock (m);
00651       --state.relock_count_;
00652     }
00653   return;
00654 #    else /* not ACE_WIN32 */
00655     // prevent warnings for unused variables
00656     ACE_UNUSED_ARG (state);
00657     ACE_UNUSED_ARG (m);
00658 
00659 #    endif /* ACE_WIN32 */
00660 #  else
00661   // Without recursive mutex support, it's somewhat trickier. On entry,
00662   // the current thread holds the nesting_mutex_, but another thread may
00663   // still be holding the ACE_recursive_mutex_t. If so, mimic the code
00664   // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex.
00665   // After acquiring it, restore the nesting counts and release the
00666   // nesting mutex. This will restore the conditions to what they were
00667   // before calling ACE_OS::recursive_mutex_cond_unlock().
00668   while (m->nesting_level_ > 0)
00669     ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_);
00670 
00671   // At this point, we still have nesting_mutex_ and the mutex is free.
00672   m->nesting_level_ = state.nesting_level_;
00673   m->owner_id_ = state.owner_id_;
00674   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00675   return;
00676 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00677 #else
00678   ACE_UNUSED_ARG (m);
00679   ACE_UNUSED_ARG (state);
00680   return;
00681 #endif /* ACE_HAS_THREADS */
00682 }

ACE_INLINE int ACE_OS::recursive_mutex_cond_unlock ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state
 

Definition at line 511 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_thread_t, cond_signal(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_mutex_state::nesting_level_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_mutex_state::owner_id_, ACE_recursive_thread_mutex_t::owner_id_, recursive_mutex_unlock(), thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00513 {
00514 #if defined (ACE_HAS_THREADS)
00515   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock");
00516 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00517   // Windows need special handling since it has recursive mutexes, but
00518   // does not integrate them into a condition variable.
00519 #    if defined (ACE_WIN32)
00520   // For Windows, the OS takes care of the mutex and its recursion. We just
00521   // need to release the lock one fewer times than this thread has acquired
00522   // it. Remember how many times, and reacquire it that many more times when
00523   // the condition is signaled.
00524   //
00525   // For WinCE, the situation is a bit trickier. CE doesn't have
00526   // RecursionCount, and LockCount has changed semantics over time.
00527   // In CE 3 (and maybe 4?) LockCount is not an indicator of recursion;
00528   // instead, see when it's unlocked by watching the OwnerThread, which will
00529   // change to something other than the current thread when it's been
00530   // unlocked "enough" times. Note that checking for 0 (unlocked) is not
00531   // sufficient. Another thread may acquire the lock between our unlock and
00532   // checking the OwnerThread. So grab our thread ID value first, then
00533   // compare to it in the loop condition. NOTE - the problem with this
00534   // scheme is that we really want to unlock the mutex one _less_ times than
00535   // required to release it for another thread to acquire. With CE 5 we
00536   // can do this by watching LockCount alone. I _think_ it can be done by
00537   // watching LockCount on CE 4 as well (though its meaning is different),
00538   // but I'm leary of changing this code since a user reported success
00539   // with it.
00540   //
00541   // We're using undocumented fields in the CRITICAL_SECTION structure
00542   // and they've been known to change across Windows variants and versions./
00543   // So be careful if you need to change these - there may be other
00544   // Windows variants that depend on existing values and limits.
00545 #      if defined (ACE_HAS_WINCE) && (UNDER_CE < 500)
00546   ACE_thread_t me = ACE_OS::thr_self ();
00547 #      endif /* ACE_HAS_WINCE && CE 4 or earlier */
00548 
00549   state.relock_count_ = 0;
00550   while (
00551 #      if !defined (ACE_HAS_WINCE)
00552          m->LockCount > 0 && m->RecursionCount > 1
00553 #      else
00554          // WinCE doesn't have RecursionCount and the LockCount semantic
00555          // has changed between versions; pre-Mobile 5 the LockCount
00556          // was 0-indexed, and Mobile 5 has it 1-indexed.
00557 #        if (UNDER_CE < 500)
00558          m->LockCount > 0 && m->OwnerThread == (HANDLE)me
00559 #        else
00560          m->LockCount > 1
00561 #        endif /* UNDER_CE < 500 */
00562 #      endif /* ACE_HAS_WINCE */
00563          )
00564     {
00565       // This may fail if the current thread doesn't own the mutex. If it
00566       // does fail, it'll be on the first try, so don't worry about resetting
00567       // the state.
00568       if (ACE_OS::recursive_mutex_unlock (m) == -1)
00569         return -1;
00570       ++state.relock_count_;
00571     }
00572 #    else /* not ACE_WIN32 */
00573     // prevent warnings for unused variables
00574     ACE_UNUSED_ARG (state);
00575     ACE_UNUSED_ARG (m);
00576 #    endif /* ACE_WIN32 */
00577   return 0;
00578 #  else /* ACE_HAS_RECURSIVE_MUTEXES */
00579   // For platforms without recursive mutexes, we obtain the nesting mutex
00580   // to gain control over the mutex internals. Then set the internals to say
00581   // the mutex is available. If there are waiters, signal the condition
00582   // to notify them (this is mostly like the recursive_mutex_unlock() method).
00583   // Then, return with the nesting mutex still held. The condition wait
00584   // will release it atomically, allowing mutex waiters to continue.
00585   // Note that this arrangement relies on the fact that on return from
00586   // the condition wait, this thread will again own the nesting mutex
00587   // and can either set the mutex internals directly or get in line for
00588   // the mutex... this part is handled in recursive_mutex_cond_relock().
00589   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00590     return -1;
00591 
00592 #    if !defined (ACE_NDEBUG)
00593   if (m->nesting_level_ == 0
00594       || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0)
00595     {
00596       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00597       errno = EINVAL;
00598       return -1;
00599     }
00600 #    endif /* ACE_NDEBUG */
00601 
00602   // To make error recovery a bit easier, signal the condition now. Any
00603   // waiter won't regain control until the mutex is released, which won't
00604   // be until the caller returns and does the wait on the condition.
00605   if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00606     {
00607       // Save/restore errno.
00608       ACE_Errno_Guard error (errno);
00609       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00610       return -1;
00611     }
00612 
00613   // Ok, the nesting_mutex_ lock is still held, the condition has been
00614   // signaled... reset the nesting info and return _WITH_ the lock
00615   // held. The lock will be released when the condition waits, in the
00616   // caller.
00617   state.nesting_level_ = m->nesting_level_;
00618   state.owner_id_ = m->owner_id_;
00619   m->nesting_level_ = 0;
00620   m->owner_id_ = ACE_OS::NULL_thread;
00621   return 0;
00622 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00623 #else
00624   ACE_UNUSED_ARG (m);
00625   ACE_UNUSED_ARG (state);
00626   ACE_NOTSUP_RETURN (-1);
00627 #endif /* ACE_HAS_THREADS */
00628 }

ACE_INLINE int ACE_OS::recursive_mutex_destroy ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 685 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_destroy(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_mutex_, and thread_mutex_destroy().

00686 {
00687 #if defined (ACE_HAS_THREADS)
00688 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00689   return ACE_OS::thread_mutex_destroy (m);
00690 #else
00691   if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
00692     return -1;
00693   else if (ACE_OS::cond_destroy (&m->lock_available_) == -1)
00694     return -1;
00695   else
00696     return 0;
00697 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00698 #else
00699   ACE_UNUSED_ARG (m);
00700   ACE_NOTSUP_RETURN (-1);
00701 #endif /* ACE_HAS_THREADS */
00702 }

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

Definition at line 705 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_TCHAR, cond_init(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, and thread_mutex_init().

00709 {
00710   ACE_UNUSED_ARG (sa);
00711 #if defined (ACE_HAS_THREADS)
00712 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00713 #    if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00714   return ACE_OS::thread_mutex_init (m, PTHREAD_MUTEX_RECURSIVE, name, arg);
00715 #    else
00716   return ACE_OS::thread_mutex_init (m, 0, name, arg);
00717 #    endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00718 #  else
00719   if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1)
00720     return -1;
00721   else if (ACE_OS::cond_init (&m->lock_available_,
00722                               (short) USYNC_THREAD,
00723                               name,
00724                               0) == -1)
00725     return -1;
00726   else
00727     {
00728       m->nesting_level_ = 0;
00729       m->owner_id_ = ACE_OS::NULL_thread;
00730       return 0;
00731     }
00732 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00733 #else
00734   ACE_UNUSED_ARG (m);
00735   ACE_UNUSED_ARG (name);
00736   ACE_UNUSED_ARG (arg);
00737   ACE_NOTSUP_RETURN (-1);
00738 #endif /* ACE_HAS_THREADS */
00739 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout
 

Definition at line 858 of file OS_NS_Thread.inl.

References recursive_mutex_lock().

00860 {
00861   return timeout == 0
00862     ? ACE_OS::recursive_mutex_lock (m)
00863     : ACE_OS::recursive_mutex_lock (m, *timeout);
00864 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout
 

Definition at line 793 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_thread_t, cond_timedwait(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00795 {
00796 #if defined (ACE_HAS_THREADS)
00797 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00798   return ACE_OS::thread_mutex_lock (m, timeout);
00799 #else
00800   ACE_thread_t t_id = ACE_OS::thr_self ();
00801   int result = 0;
00802 
00803   // Try to acquire the guard.
00804   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_, timeout) == -1)
00805     result = -1;
00806   else
00807     {
00808       // If there's no contention, just grab the lock immediately
00809       // (since this is the common case we'll optimize for it).
00810       if (m->nesting_level_ == 0)
00811         m->owner_id_ = t_id;
00812       // If we already own the lock, then increment the nesting level
00813       // and return.
00814       else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00815         {
00816           // Wait until the nesting level has dropped to zero, at
00817           // which point we can acquire the lock.
00818           while (m->nesting_level_ > 0)
00819             {
00820               result = ACE_OS::cond_timedwait (&m->lock_available_,
00821                                                &m->nesting_mutex_,
00822                                                const_cast <ACE_Time_Value *> (&timeout));
00823 
00824               // The mutex is reacquired even in the case of a timeout
00825               // release the mutex to prevent a deadlock
00826               if (result == -1)
00827                 {
00828                   // Save/restore errno.
00829                   ACE_Errno_Guard error (errno);
00830                   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00831 
00832                   return result;
00833                 }
00834             }
00835 
00836           // At this point the nesting_mutex_ is held...
00837           m->owner_id_ = t_id;
00838         }
00839 
00840       // At this point, we can safely increment the nesting_level_ no
00841       // matter how we got here!
00842       m->nesting_level_++;
00843 
00844       // Save/restore errno.
00845       ACE_Errno_Guard error (errno);
00846       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00847     }
00848   return result;
00849 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00850 #else
00851   ACE_UNUSED_ARG (m);
00852   ACE_UNUSED_ARG (timeout);
00853   ACE_NOTSUP_RETURN (-1);
00854 #endif /* ACE_HAS_THREADS */
00855 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 742 of file OS_NS_Thread.inl.

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

Referenced by recursive_mutex_cond_relock(), and recursive_mutex_lock().

00743 {
00744 #if defined (ACE_HAS_THREADS)
00745 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00746   return ACE_OS::thread_mutex_lock (m);
00747 #else
00748   ACE_thread_t t_id = ACE_OS::thr_self ();
00749   int result = 0;
00750 
00751   // Acquire the guard.
00752   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00753     result = -1;
00754   else
00755   {
00756     // If there's no contention, just grab the lock immediately
00757     // (since this is the common case we'll optimize for it).
00758     if (m->nesting_level_ == 0)
00759       m->owner_id_ = t_id;
00760       // If we already own the lock, then increment the nesting level
00761       // and return.
00762     else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00763     {
00764           // Wait until the nesting level has dropped to zero, at
00765           // which point we can acquire the lock.
00766       while (m->nesting_level_ > 0)
00767         ACE_OS::cond_wait (&m->lock_available_,
00768                             &m->nesting_mutex_);
00769 
00770           // At this point the nesting_mutex_ is held...
00771       m->owner_id_ = t_id;
00772     }
00773 
00774     // At this point, we can safely increment the nesting_level_ no
00775     // matter how we got here!
00776     ++m->nesting_level_;
00777   }
00778 
00779   {
00780     // Save/restore errno.
00781     ACE_Errno_Guard error (errno);
00782     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00783   }
00784   return result;
00785 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00786 #else
00787   ACE_UNUSED_ARG (m);
00788   ACE_NOTSUP_RETURN (-1);
00789 #endif /* ACE_HAS_THREADS */
00790 }

ACE_INLINE int ACE_OS::recursive_mutex_trylock ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 867 of file OS_NS_Thread.inl.

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

00868 {
00869 #if defined (ACE_HAS_THREADS)
00870 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00871   return ACE_OS::thread_mutex_trylock (m);
00872 #else
00873   ACE_thread_t t_id = ACE_OS::thr_self ();
00874   int result = 0;
00875 
00876   // Acquire the guard.
00877   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00878     result = -1;
00879   else
00880   {
00881       // If there's no contention, just grab the lock immediately.
00882     if (m->nesting_level_ == 0)
00883     {
00884       m->owner_id_ = t_id;
00885       m->nesting_level_ = 1;
00886     }
00887       // If we already own the lock, then increment the nesting level
00888       // and proceed.
00889     else if (ACE_OS::thr_equal (t_id, m->owner_id_))
00890       m->nesting_level_++;
00891     else
00892     {
00893       errno = EBUSY;
00894       result = -1;
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::recursive_mutex_unlock ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 912 of file OS_NS_Thread.inl.

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

Referenced by recursive_mutex_cond_unlock().

00913 {
00914 #if defined (ACE_HAS_THREADS)
00915 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00916   return ACE_OS::thread_mutex_unlock (m);
00917 #  else
00918   ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock");
00919 #    if !defined (ACE_NDEBUG)
00920   ACE_thread_t t_id = ACE_OS::thr_self ();
00921 #    endif /* ACE_NDEBUG */
00922   int result = 0;
00923 
00924   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00925     result = -1;
00926   else
00927   {
00928 #    if !defined (ACE_NDEBUG)
00929       if (m->nesting_level_ == 0
00930           || ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00931 {
00932   errno = EINVAL;
00933   result = -1;
00934 }
00935       else
00936 #    endif /* ACE_NDEBUG */
00937 {
00938   m->nesting_level_--;
00939   if (m->nesting_level_ == 0)
00940   {
00941               // This may not be strictly necessary, but it does put
00942               // the mutex into a known state...
00943     m->owner_id_ = ACE_OS::NULL_thread;
00944 
00945               // Inform a waiter that the lock is free.
00946     if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00947       result = -1;
00948   }
00949 }
00950   }
00951 
00952 {
00953     // Save/restore errno.
00954   ACE_Errno_Guard error (errno);
00955   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00956 }
00957   return result;
00958 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00959 #else
00960   ACE_UNUSED_ARG (m);
00961   ACE_NOTSUP_RETURN (-1);
00962 #endif /* ACE_HAS_THREADS */
00963 }

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

BSD-style (no QoS).

Definition at line 301 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, EWOULDBLOCK, and ssize_t.

Referenced by ACE_Pipe::recv(), ACE::recv(), ACE::recv_i(), and ACE::recv_n_i().

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

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
 

BSD-style (no QoS).

Definition at line 395 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, and set_errno_to_wsa_last_error().

00404 {
00405   ACE_OS_TRACE ("ACE_OS::recvfrom");
00406 
00407 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00408   DWORD bytes_recvd;
00409   DWORD the_flags = flags;
00410   int result = ::WSARecvFrom ((SOCKET) handle,
00411                               (WSABUF*)buffers,
00412                               buffer_count,
00413                               &bytes_recvd,
00414                               &the_flags,
00415                               addr,
00416                               addrlen,
00417                               overlapped,
00418                               func);
00419   if (result != 0) {
00420     ACE_OS::set_errno_to_wsa_last_error ();
00421   }
00422   flags = the_flags;
00423   number_of_bytes_recvd = static_cast<size_t> (bytes_recvd);
00424   return result;
00425 #else
00426   ACE_UNUSED_ARG (handle);
00427   ACE_UNUSED_ARG (buffers);
00428   ACE_UNUSED_ARG (buffer_count);
00429   ACE_UNUSED_ARG (number_of_bytes_recvd);
00430   ACE_UNUSED_ARG (flags);
00431   ACE_UNUSED_ARG (addr);
00432   ACE_UNUSED_ARG (addrlen);
00433   ACE_UNUSED_ARG (overlapped);
00434   ACE_UNUSED_ARG (func);
00435   ACE_NOTSUP_RETURN (-1);
00436 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00437 }

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

BSD-style (no QoS).

Definition at line 348 of file OS_NS_sys_socket.inl.

References ACE_BIT_ENABLED, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, MSG_PEEK, set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE_SOCK_Dgram::recv(), and ACE::recvfrom().

00354 {
00355   ACE_OS_TRACE ("ACE_OS::recvfrom");
00356 #if defined (ACE_LACKS_RECVFROM)
00357   ACE_UNUSED_ARG (handle);
00358   ACE_UNUSED_ARG (buf);
00359   ACE_UNUSED_ARG (len);
00360   ACE_UNUSED_ARG (flags);
00361   ACE_UNUSED_ARG (addr);
00362   ACE_UNUSED_ARG (addrlen);
00363   ACE_NOTSUP_RETURN (-1);
00364 #elif defined (ACE_WIN32)
00365   int const shortened_len = static_cast<int> (len);
00366   int const result = ::recvfrom ((ACE_SOCKET) handle,
00367                                  buf,
00368                                  shortened_len,
00369                                  flags,
00370                                  addr,
00371                                  (ACE_SOCKET_LEN *) addrlen);
00372   if (result == SOCKET_ERROR)
00373     {
00374       ACE_OS::set_errno_to_wsa_last_error ();
00375       if (errno == WSAEMSGSIZE &&
00376           ACE_BIT_ENABLED (flags, MSG_PEEK))
00377         return shortened_len;
00378       else
00379         return -1;
00380     }
00381   else
00382     return result;
00383 #else /* non Win32 */
00384   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle,
00385                                    buf,
00386                                    len,
00387                                    flags,
00388                                    addr,
00389                                    (ACE_SOCKET_LEN *) addrlen),
00390                        ssize_t, -1);
00391 #endif /* ACE_LACKS_RECVFROM */
00392 }

ACE_INLINE ssize_t ACE_OS::recvmsg ACE_HANDLE  handle,
struct msghdr msg,
int  flags
 

BSD-style (no QoS).

Definition at line 440 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE::recvmsg().

00441 {
00442   ACE_OS_TRACE ("ACE_OS::recvmsg");
00443 #if !defined (ACE_LACKS_RECVMSG)
00444 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00445   DWORD bytes_received = 0;
00446 
00447   int result = ::WSARecvFrom ((SOCKET) handle,
00448                               (WSABUF *) msg->msg_iov,
00449                               msg->msg_iovlen,
00450                               &bytes_received,
00451                               (DWORD *) &flags,
00452                               msg->msg_name,
00453                               &msg->msg_namelen,
00454                               0,
00455                               0);
00456 
00457   if (result != 0)
00458     {
00459       ACE_OS::set_errno_to_wsa_last_error ();
00460       return -1;
00461     }
00462   else
00463     return bytes_received;
00464 # else /* ACE_HAS_WINSOCK2 */
00465   ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), ssize_t, -1);
00466 # endif /* ACE_HAS_WINSOCK2 */
00467 #else
00468   ACE_UNUSED_ARG (flags);
00469   ACE_UNUSED_ARG (msg);
00470   ACE_UNUSED_ARG (handle);
00471 
00472   ACE_NOTSUP_RETURN (-1);
00473 #endif /* ACE_LACKS_RECVMSG */
00474 }

ACE_INLINE ssize_t ACE_OS::recvv ACE_HANDLE  handle,
iovec *  iov,
int  iovlen
 

BSD-style (no QoS).

Definition at line 477 of file OS_NS_sys_socket.inl.

References readv(), set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE_SOCK_IO::recv(), ACE_Pipe::recv(), ACE::recv(), ACE::recvv(), and ACE::recvv_n_i().

00480 {
00481 #if defined (ACE_HAS_WINSOCK2)
00482 
00483   DWORD bytes_received = 0;
00484   int result = 1;
00485 
00486   // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs
00487   // to do the recvs piece-by-piece.
00488 
00489 # if (ACE_HAS_WINSOCK2 != 0)
00490   DWORD flags = 0;
00491   result = ::WSARecv ((SOCKET) handle,
00492                       (WSABUF *) buffers,
00493                       n,
00494                       &bytes_received,
00495                       &flags,
00496                       0,
00497                       0);
00498 # else
00499   int i, chunklen;
00500   char *chunkp = 0;
00501 
00502   // Step through the buffers requested by caller; for each one, cycle
00503   // through reads until it's filled or an error occurs.
00504   for (i = 0; i < n && result > 0; ++i)
00505     {
00506       chunkp = buffers[i].iov_base;     // Point to part of chunk being read
00507       chunklen = buffers[i].iov_len;    // Track how much to read to chunk
00508       while (chunklen > 0 && result > 0)
00509         {
00510           result = ::recv ((SOCKET) handle, chunkp, chunklen, 0);
00511           if (result > 0)
00512             {
00513               chunkp += result;
00514               chunklen -= result;
00515               bytes_received += result;
00516             }
00517         }
00518     }
00519 # endif /* ACE_HAS_WINSOCK2 != 0 */
00520 
00521   if (result == SOCKET_ERROR)
00522     {
00523       ACE_OS::set_errno_to_wsa_last_error ();
00524       return -1;
00525     }
00526   else
00527     return (ssize_t) bytes_received;
00528 #else
00529   return ACE_OS::readv (handle, buffers, n);
00530 #endif /* ACE_HAS_WINSOCK2 */
00531 }

ACE_INLINE int ACE_OS::rename const wchar_t *  old_name,
const wchar_t *  new_name,
int  flags = -1
 

Definition at line 851 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, ACE_Wide_To_Ascii::char_rep(), and rename().

00854 {
00855 # if defined (ACE_LACKS_RENAME)
00856   ACE_UNUSED_ARG (old_name);
00857   ACE_UNUSED_ARG (new_name);
00858   ACE_UNUSED_ARG (flags);
00859   ACE_NOTSUP_RETURN (-1);
00860 # elif defined (ACE_HAS_WINCE)
00861   ACE_UNUSED_ARG (flags);
00862   if (MoveFileW (old_name, new_name) != 0)
00863     ACE_FAIL_RETURN (-1);
00864   return 0;
00865 # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX)
00866   // NT4 (and up) provides a way to rename/move a file with similar semantics
00867   // to what's usually done on UNIX - if there's an existing file with
00868   // <new_name> it is removed before the file is renamed/moved. The
00869   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00870   if (flags == -1)
00871     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00872   if (::MoveFileExW (old_name, new_name, flags) == 0)
00873     ACE_FAIL_RETURN (-1);
00874   return 0;
00875 # elif defined (ACE_WIN32)
00876   ACE_UNUSED_ARG (flags);
00877   ACE_OSCALL_RETURN (::_wrename (old_name, new_name), int, -1);
00878 # else /* ACE_LACKS_RENAME */
00879   ACE_Wide_To_Ascii nold_name (old_name);
00880   ACE_Wide_To_Ascii nnew_name (new_name);
00881   return ACE_OS::rename (nold_name.char_rep (), nnew_name.char_rep (), flags);
00882 # endif /* ACE_LACKS_RENAME */
00883 }

ACE_INLINE int ACE_OS::rename const char *  old_name,
const char *  new_name,
int  flags = -1
 

Definition at line 817 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, and rename().

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

00820 {
00821 # if defined (ACE_LACKS_RENAME)
00822   ACE_UNUSED_ARG (old_name);
00823   ACE_UNUSED_ARG (new_name);
00824   ACE_UNUSED_ARG (flags);
00825   ACE_NOTSUP_RETURN (-1);
00826 # elif defined (ACE_HAS_WINCE)
00827   // Win CE is always wide-char.
00828   ACE_UNUSED_ARG (flags);
00829   if (0 != MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name),
00830                      ACE_TEXT_CHAR_TO_TCHAR (new_name)))
00831     ACE_FAIL_RETURN (-1);
00832   return 0;
00833 # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX)
00834   // NT4 (and up) provides a way to rename/move a file with similar semantics
00835   // to what's usually done on UNIX - if there's an existing file with
00836   // <new_name> it is removed before the file is renamed/moved. The
00837   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00838   if (flags == -1)
00839     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00840   if (::MoveFileExA (old_name, new_name, flags) == 0)
00841     ACE_FAIL_RETURN (-1);
00842   return 0;
00843 # else /* ACE_LACKS_RENAME */
00844   ACE_UNUSED_ARG (flags);
00845   ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
00846 # endif /* ACE_LACKS_RENAME */
00847 }

ACE_INLINE void ACE_OS::rewind FILE *  fp  ) 
 

Definition at line 887 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fseek().

00888 {
00889 #if !defined (ACE_HAS_WINCE)
00890   ACE_OS_TRACE ("ACE_OS::rewind");
00891   ::rewind (fp);
00892 #else
00893   // This isn't perfect since it doesn't reset EOF, but it's probably
00894   // the closest we can get on WINCE.
00895   (void) fseek (fp, 0L, SEEK_SET);
00896 #endif /* ACE_HAS_WINCE */
00897 }

ACE_INLINE void ACE_OS::rewinddir ACE_DIR  ) 
 

Definition at line 102 of file OS_NS_dirent.inl.

References ACE_DIR, and ace_rewinddir_helper().

Referenced by 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::rmdir const wchar_t *  path  ) 
 

Definition at line 162 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_Wide_To_Ascii::char_rep(), and rmdir().

00163 {
00164 #if defined (ACE_HAS_WINCE)
00165   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectoryW (path),
00166                                           ace_result_),
00167                         int, -1);
00168 #elif defined (ACE_WIN32)
00169   ACE_OSCALL_RETURN (::_wrmdir (path), int, -1);
00170 #else
00171   ACE_Wide_To_Ascii n_path (path);
00172   return ACE_OS::rmdir (n_path.char_rep ());
00173 #endif /* ACE_HAS_WINCE */
00174 }

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::rw_rdlock ACE_rwlock_t *  rw  ) 
 

Definition at line 966 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().

00967 {
00968   ACE_OS_TRACE ("ACE_OS::rw_rdlock");
00969 #if defined (ACE_HAS_THREADS)
00970 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00971 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00972   int result;
00973   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
00974                                        result),
00975                      int, -1);
00976 #  else /* Solaris */
00977   int result;
00978   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), result), int, -1);
00979 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00980 # else /* NT, POSIX, and VxWorks don't support this natively. */
00981 #   if defined (ACE_HAS_PTHREADS)
00982   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
00983 #   endif /* ACE_HAS_PTHREADS */
00984   int result = 0;
00985   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
00986     result = -1; // -1 means didn't get the mutex.
00987   else
00988     {
00989       // Give preference to writers who are waiting.
00990       while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0)
00991         {
00992           rw->num_waiting_readers_++;
00993           if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1)
00994             {
00995               result = -2; // -2 means that we need to release the mutex.
00996               break;
00997             }
00998           rw->num_waiting_readers_--;
00999         }
01000     }
01001   if (result == 0)
01002     rw->ref_count_++;
01003   if (result != -1)
01004     ACE_OS::mutex_unlock (&rw->lock_);
01005 #   if defined (ACE_HAS_PTHREADS)
01006   ACE_PTHREAD_CLEANUP_POP (0);
01007 #   endif /* defined (ACE_HAS_PTHREADS) */
01008   return 0;
01009 # endif /* ! ACE_LACKS_RWLOCK_T */
01010 #else
01011   ACE_UNUSED_ARG (rw);
01012   ACE_NOTSUP_RETURN (-1);
01013 #endif /* ACE_HAS_THREADS */
01014 }

ACE_INLINE int ACE_OS::rw_tryrdlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1017 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().

01018 {
01019   ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
01020 #if defined (ACE_HAS_THREADS)
01021 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01022 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01023   int result;
01024   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
01025                                        result),
01026                      int, -1);
01027 #  else /* Solaris */
01028   int result;
01029   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), result), int, -1);
01030 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01031 # else /* NT, POSIX, and VxWorks don't support this natively. */
01032   int result = -1;
01033 
01034   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01035     {
01036       ACE_Errno_Guard error (errno);
01037 
01038       if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0)
01039         {
01040           error = EBUSY;
01041           result = -1;
01042         }
01043       else
01044         {
01045           rw->ref_count_++;
01046           result = 0;
01047         }
01048 
01049       ACE_OS::mutex_unlock (&rw->lock_);
01050     }
01051   return result;
01052 # endif /* ! ACE_LACKS_RWLOCK_T */
01053 #else
01054   ACE_UNUSED_ARG (rw);
01055   ACE_NOTSUP_RETURN (-1);
01056 #endif /* ACE_HAS_THREADS */
01057 }

ACE_INLINE int ACE_OS::rw_trywrlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1060 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().

01061 {
01062   ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
01063 #if defined (ACE_HAS_THREADS)
01064 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01065 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01066   int result;
01067   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01068                                        result),
01069                      int, -1);
01070 #  else /* Solaris */
01071   int result;
01072   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), result), int, -1);
01073 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01074 # else /* NT, POSIX, and VxWorks don't support this natively. */
01075   int result = -1;
01076 
01077   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01078     {
01079       ACE_Errno_Guard error (errno);
01080 
01081       if (rw->ref_count_ != 0)
01082         {
01083           error = EBUSY;
01084           result = -1;
01085         }
01086       else
01087         {
01088           rw->ref_count_ = -1;
01089           result = 0;
01090         }
01091 
01092       ACE_OS::mutex_unlock (&rw->lock_);
01093     }
01094   return result;
01095 # endif /* ! ACE_LACKS_RWLOCK_T */
01096 #else
01097   ACE_UNUSED_ARG (rw);
01098   ACE_NOTSUP_RETURN (-1);
01099 #endif /* ACE_HAS_THREADS */
01100 }

ACE_INLINE int ACE_OS::rw_trywrlock_upgrade ACE_rwlock_t *  rw  ) 
 

Definition at line 1109 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().

01110 {
01111   ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
01112 #if defined (ACE_HAS_THREADS)
01113 # if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01114   // This will probably result in -1, EDEADLK, at least on HP-UX, but let it
01115   // go - it's a more descriptive error than ENOTSUP.
01116   int result;
01117   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01118                                        result),
01119                      int, -1);
01120 # elif !defined (ACE_LACKS_RWLOCK_T)
01121   // Some native rwlocks, such as those on Solaris, don't
01122   // support the upgrade feature . . .
01123   ACE_UNUSED_ARG (rw);
01124   ACE_NOTSUP_RETURN (-1);
01125 # else /* NT, POSIX, and VxWorks don't support this natively. */
01126   // The ACE rwlock emulation does support upgrade . . .
01127   int result = 0;
01128 
01129 #   if defined (ACE_HAS_PTHREADS)
01130   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01131 #   endif /* defined (ACE_HAS_PTHREADS) */
01132 
01133   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01134     return -1;
01135     // -1 means didn't get the mutex, error
01136   else if (rw->important_writer_)
01137     // an other reader upgrades already
01138     {
01139       result = -1;
01140       errno = EBUSY;
01141     }
01142   else
01143     {
01144       while (rw->ref_count_ > 1) // wait until only I am left
01145         {
01146           rw->num_waiting_writers_++; // prohibit any more readers
01147           rw->important_writer_ = 1;
01148 
01149           if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1)
01150             {
01151               result = -1;
01152               // we know that we have the lock again, we have this guarantee,
01153               // but something went wrong
01154             }
01155           rw->important_writer_ = 0;
01156           rw->num_waiting_writers_--;
01157         }
01158       if (result == 0)
01159         {
01160           // nothing bad happend
01161           rw->ref_count_ = -1;
01162           // now I am a writer
01163           // everything is O.K.
01164         }
01165     }
01166 
01167   ACE_OS::mutex_unlock (&rw->lock_);
01168 
01169 #   if defined (ACE_HAS_PTHREADS)
01170   ACE_PTHREAD_CLEANUP_POP (0);
01171 #   endif /* defined (ACE_HAS_PTHREADS) */
01172 
01173   return result;
01174 
01175 # endif /* ! ACE_LACKS_RWLOCK_T */
01176 #else
01177   ACE_UNUSED_ARG (rw);
01178   ACE_NOTSUP_RETURN (-1);
01179 #endif /* ACE_HAS_THREADS */
01180 }

ACE_INLINE int ACE_OS::rw_unlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1183 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().

01184 {
01185   ACE_OS_TRACE ("ACE_OS::rw_unlock");
01186 #if defined (ACE_HAS_THREADS)
01187 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01188 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01189   int result;
01190   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
01191                                        result),
01192                      int, -1);
01193 #  else /* Solaris */
01194   int result;
01195   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), result), int, -1);
01196 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01197 # else /* NT, POSIX, and VxWorks don't support this natively. */
01198   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01199     return -1;
01200 
01201   if (rw->ref_count_ > 0) // Releasing a reader.
01202     rw->ref_count_--;
01203   else if (rw->ref_count_ == -1) // Releasing a writer.
01204     rw->ref_count_ = 0;
01205   else
01206     {
01207       (void) ACE_OS::mutex_unlock (&rw->lock_);
01208       return -1; // @@ ACE_ASSERT (!"count should not be 0!\n");
01209     }
01210 
01211   int result = 0;
01212   ACE_Errno_Guard error (errno);
01213 
01214   if (rw->important_writer_ && rw->ref_count_ == 1)
01215     // only the reader requesting to upgrade its lock is left over.
01216     {
01217       result = ACE_OS::cond_signal (&rw->waiting_important_writer_);
01218       error = errno;
01219     }
01220   else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0)
01221     // give preference to writers over readers...
01222     {
01223       result = ACE_OS::cond_signal (&rw->waiting_writers_);
01224       error =  errno;
01225     }
01226   else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0)
01227     {
01228       result = ACE_OS::cond_broadcast (&rw->waiting_readers_);
01229       error = errno;
01230     }
01231 
01232   (void) ACE_OS::mutex_unlock (&rw->lock_);
01233   return result;
01234 # endif /* ! ace_lacks_rwlock_t */
01235 #else
01236   ACE_UNUSED_ARG (rw);
01237   ACE_NOTSUP_RETURN (-1);
01238 #endif /* ace_has_threads */
01239 }

ACE_INLINE int ACE_OS::rw_wrlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1242 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().

01243 {
01244   ACE_OS_TRACE ("ACE_OS::rw_wrlock");
01245 #if defined (ACE_HAS_THREADS)
01246 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01247 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01248   int result;
01249   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
01250                                        result),
01251                      int, -1);
01252 #  else /* Solaris */
01253   int result;
01254   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), result), int, -1);
01255 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01256 # else /* NT, POSIX, and VxWorks don't support this natively. */
01257 #   if defined (ACE_HAS_PTHREADS)
01258   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01259 #   endif /* defined (ACE_HAS_PTHREADS) */
01260   int result = 0;
01261 
01262   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01263     result = -1; // -1 means didn't get the mutex.
01264   else
01265     {
01266       while (rw->ref_count_ != 0)
01267         {
01268           rw->num_waiting_writers_++;
01269 
01270           if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1)
01271             {
01272               result = -2; // -2 means we need to release the mutex.
01273               break;
01274             }
01275 
01276           rw->num_waiting_writers_--;
01277         }
01278     }
01279   if (result == 0)
01280     rw->ref_count_ = -1;
01281   if (result != -1)
01282     ACE_OS::mutex_unlock (&rw->lock_);
01283 #   if defined (ACE_HAS_PTHREADS)
01284   ACE_PTHREAD_CLEANUP_POP (0);
01285 #   endif /* defined (ACE_HAS_PTHREADS) */
01286   return 0;
01287 # endif /* ! ACE_LACKS_RWLOCK_T */
01288 #else
01289   ACE_UNUSED_ARG (rw);
01290   ACE_NOTSUP_RETURN (-1);
01291 #endif /* ACE_HAS_THREADS */
01292 }

ACE_INLINE int ACE_OS::rwlock_destroy ACE_rwlock_t *  rw  ) 
 

Definition at line 1295 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().

01296 {
01297   ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
01298 #if defined (ACE_HAS_THREADS)
01299 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01300 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01301   int result;
01302   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
01303                                        result),
01304                      int, -1);
01305 #  else /* Solaris */
01306   int result;
01307   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), result), int, -1);
01308 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01309 # else /* NT, POSIX, and VxWorks don't support this natively. */
01310   ACE_OS::mutex_destroy (&rw->lock_);
01311   ACE_OS::cond_destroy (&rw->waiting_readers_);
01312   ACE_OS::cond_destroy (&rw->waiting_important_writer_);
01313   return ACE_OS::cond_destroy (&rw->waiting_writers_);
01314 # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */
01315 #else
01316   ACE_UNUSED_ARG (rw);
01317   ACE_NOTSUP_RETURN (-1);
01318 #endif /* ACE_HAS_THREADS */
01319 }

ACE_INLINE 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 1324 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_TCHAR, and rwlock_init().

Referenced by rwlock_init().

01328 {
01329   // ACE_OS_TRACE ("ACE_OS::rwlock_init");
01330 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01331   ACE_UNUSED_ARG (name);
01332   ACE_UNUSED_ARG (arg);
01333 
01334   int status;
01335   pthread_rwlockattr_t attr;
01336   pthread_rwlockattr_init (&attr);
01337 #    if !defined (ACE_LACKS_RWLOCKATTR_PSHARED)
01338   pthread_rwlockattr_setpshared (&attr, (type == USYNC_THREAD ?
01339                                          PTHREAD_PROCESS_PRIVATE :
01340                                          PTHREAD_PROCESS_SHARED));
01341 #    else
01342   ACE_UNUSED_ARG (type);
01343 #    endif /* !ACE_LACKS_RWLOCKATTR_PSHARED */
01344   status = ACE_ADAPT_RETVAL (pthread_rwlock_init (rw, &attr), status);
01345   pthread_rwlockattr_destroy (&attr);
01346 
01347   return status;
01348 
01349 #  else
01350   type = type;
01351   name = name;
01352   int result;
01353   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), result), int, -1);
01354 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01355 }

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::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_SCANDIR_COMPARATOR, ACE_SCANDIR_SELECTOR, ACE_TCHAR, 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_BEGIN_VERSIONED_NAMESPACE_DECL 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 ACE_COMPARE_FUNC, ACE_DIR, ACE_DIRENT, ACE_SCANDIR_COMPARATOR, ACE_SCANDIR_SELECTOR, ACE_TCHAR, 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 }

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

References ACE_ADAPT_RETVAL, ACE_id_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_RR, ACE_SCOPE_LWP, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, ACE_SELF, ACE_thread_t, sched_params(), set_errno_to_last_error(), set_scheduling_params(), thr_self(), and thr_setprio().

Referenced by lwp_getparams(), lwp_setparams(), sched_params(), ACE_Process_Manager::set_scheduler(), ACE_Process_Manager::set_scheduler_all(), set_scheduling_params(), thr_create(), and thr_setprio().

03500 {
03501   ACE_OS_TRACE ("ACE_OS::sched_params");
03502 #if defined (ACE_HAS_STHREADS)
03503   return ACE_OS::set_scheduling_params (sched_params, id);
03504 #elif defined (ACE_HAS_PTHREADS) && \
03505       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
03506       defined (ACE_HAS_PTHREAD_SCHEDPARAM))
03507   if (sched_params.quantum () != ACE_Time_Value::zero)
03508     {
03509       // quantums not supported
03510       errno = EINVAL;
03511       return -1;
03512     }
03513 
03514   // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for
03515   // providing this code for 1003.1c PThreads.  Please note that this
03516   // has only been tested for POSIX 1003.1c threads, and may cause
03517   // problems with other PThreads flavors!
03518 
03519   struct sched_param param;
03520   param.sched_priority = sched_params.priority ();
03521 
03522   if (sched_params.scope () == ACE_SCOPE_PROCESS)
03523     {
03524 # if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
03525       ACE_UNUSED_ARG (id);
03526       ACE_NOTSUP_RETURN (-1);
03527 # else  /* ! ACE_TANDEM_T1248_PTHREADS */
03528       int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id,
03529                                          sched_params.policy (),
03530                                          &param) == -1 ? -1 : 0;
03531 # if defined (DIGITAL_UNIX)
03532       return result == 0
03533         ? // Use priocntl (2) to set the process in the RT class,
03534         // if using an RT policy.
03535         ACE_OS::set_scheduling_params (sched_params)
03536         : result;
03537 # else  /* ! DIGITAL_UNIX */
03538       return result;
03539 # endif /* ! DIGITAL_UNIX */
03540 # endif /* ! ACE_TANDEM_T1248_PTHREADS */
03541     }
03542   else if (sched_params.scope () == ACE_SCOPE_THREAD)
03543     {
03544       ACE_thread_t thr_id = ACE_OS::thr_self ();
03545 
03546 # if defined (ACE_HAS_PTHREADS_DRAFT4)
03547       return (::pthread_setscheduler (thr_id,
03548                                       sched_params.policy (),
03549                                       sched_params.priority()) == -1 ? -1 : 0);
03550 # else
03551       int result;
03552       ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
03553                                                                     sched_params.policy (),
03554                                                                     &param),
03555                                            result),
03556                          int, -1);
03557 # endif  /* ACE_HAS_PTHREADS_DRAFT4 */
03558     }
03559 # if defined (sun)
03560   // We need to be able to set LWP priorities on Suns, even without
03561   // ACE_HAS_STHREADS, to obtain preemption.
03562   else if (sched_params.scope () == ACE_SCOPE_LWP)
03563     return ACE_OS::set_scheduling_params (sched_params, id);
03564 # endif /* sun */
03565   else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX
03566     {
03567       errno = EINVAL;
03568       return -1;
03569     }
03570 
03571 #elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
03572 
03573   // PharLap ETS can act on the current thread - it can set the
03574   // quantum also, unlike Win32. All this only works on the RT
03575   // version.
03576 # if defined (ACE_HAS_PHARLAP_RT)
03577   if (id != ACE_SELF)
03578     ACE_NOTSUP_RETURN (-1);
03579 
03580 #   if !defined (ACE_PHARLAP_LABVIEW_RT)
03581   if (sched_params.quantum() != ACE_Time_Value::zero)
03582     EtsSetTimeSlice (sched_params.quantum().msec());
03583 #   endif
03584 
03585 # else
03586 
03587   if (sched_params.quantum () != ACE_Time_Value::zero)
03588     {
03589       // I don't know of a way to set the quantum on Win32.
03590       errno = EINVAL;
03591       return -1;
03592     }
03593 
03594 # endif /* ACE_HAS_PHARLAP_RT */
03595 
03596   if (sched_params.scope () == ACE_SCOPE_THREAD)
03597     {
03598 
03599       // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always
03600       // a VERY BAD THING. This include guard will allow people
03601       // to easily disable this feature in ACE.
03602       // It won't work at all for Pharlap since there's no SetPriorityClass.
03603 #if !defined (ACE_HAS_PHARLAP) && \
03604     !defined (ACE_DISABLE_WIN32_INCREASE_PRIORITY)
03605       // Set the priority class of this process to the REALTIME process class
03606       // _if_ the policy is ACE_SCHED_FIFO.  Otherwise, set to NORMAL.
03607       if (!::SetPriorityClass (::GetCurrentProcess (),
03608                                (sched_params.policy () == ACE_SCHED_FIFO ||
03609                                 sched_params.policy () == ACE_SCHED_RR)
03610                                ? REALTIME_PRIORITY_CLASS
03611                                : NORMAL_PRIORITY_CLASS))
03612         {
03613           ACE_OS::set_errno_to_last_error ();
03614           return -1;
03615         }
03616 #endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */
03617 
03618       // Now that we have set the priority class of the process, set the
03619       // priority of the current thread to the desired value.
03620       return ACE_OS::thr_setprio (sched_params.priority ());
03621     }
03622   else if (sched_params.scope () == ACE_SCOPE_PROCESS)
03623     {
03624 
03625 # if defined (ACE_HAS_PHARLAP_RT)
03626       ACE_NOTSUP_RETURN (-1);
03627 # else
03628       HANDLE hProcess
03629         = ::OpenProcess (PROCESS_SET_INFORMATION,
03630                          FALSE,
03631                          id == ACE_SELF ? ::GetCurrentProcessId() : id);
03632       if (!hProcess)
03633         {
03634           ACE_OS::set_errno_to_last_error();
03635           return -1;
03636         }
03637       // There is no way for us to set the priority of the thread when we
03638       // are setting the priority of a different process.  So just ignore
03639       // the priority argument when ACE_SCOPE_PROCESS is specified.
03640       // Setting the priority class will automatically increase the base
03641       // priority of all the threads within a process while maintaining the
03642       // relative priorities of the threads within it.
03643       if (!::SetPriorityClass (hProcess,
03644                                (sched_params.policy () == ACE_SCHED_FIFO ||
03645                                 sched_params.policy () == ACE_SCHED_RR)
03646                                ? REALTIME_PRIORITY_CLASS
03647                                : NORMAL_PRIORITY_CLASS))
03648         {
03649           ACE_OS::set_errno_to_last_error ();
03650           ::CloseHandle (hProcess);
03651           return -1;
03652         }
03653       ::CloseHandle (hProcess);
03654       return 0;
03655 #endif /* ACE_HAS_PHARLAP_RT */
03656 
03657     }
03658   else
03659     {
03660       errno = EINVAL;
03661       return -1;
03662     }
03663 #elif defined (ACE_VXWORKS)
03664   ACE_UNUSED_ARG (id);
03665 
03666   // There is only one class of priorities on VxWorks, and no time
03667   // quanta.  So, just set the current thread's priority.
03668 
03669   if (sched_params.policy () != ACE_SCHED_FIFO
03670       || sched_params.scope () != ACE_SCOPE_PROCESS
03671       || sched_params.quantum () != ACE_Time_Value::zero)
03672     {
03673       errno = EINVAL;
03674       return -1;
03675     }
03676 
03677   // Set the thread priority on the current thread.
03678   return ACE_OS::thr_setprio (sched_params.priority ());
03679 #else
03680   ACE_UNUSED_ARG (sched_params);
03681   ACE_UNUSED_ARG (id);
03682   ACE_NOTSUP_RETURN (-1);
03683 #endif /* ACE_HAS_STHREADS */
03684 }

int ACE_OS::scheduling_class const char *  class_name,
ACE_id_t
 

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

Definition at line 3687 of file OS_NS_Thread.cpp.

References ACE_id_t, ACE_NOTSUP_RETURN, memset(), priority_control(), and strcpy().

Referenced by lwp_getparams(), and set_scheduling_params().

03688 {
03689 #if defined (ACE_HAS_PRIOCNTL)
03690   // Get the priority class ID.
03691   pcinfo_t pcinfo;
03692   // The following is just to avoid Purify warnings about unitialized
03693   // memory reads.
03694   ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
03695 
03696   ACE_OS::strcpy (pcinfo.pc_clname, class_name);
03697   if (ACE_OS::priority_control (P_ALL /* ignored */,
03698                                 P_MYID /* ignored */,
03699                                 PC_GETCID,
03700                                 (char *) &pcinfo) == -1)
03701     {
03702       return -1;
03703     }
03704   else
03705     {
03706       id = pcinfo.pc_cid;
03707       return 0;
03708     }
03709 #else  /* ! ACE_HAS_PRIOCNTL */
03710   ACE_UNUSED_ARG (class_name);
03711   ACE_UNUSED_ARG (id);
03712   ACE_NOTSUP_RETURN (-1);
03713 #endif /* ! ACE_HAS_PRIOCNTL */
03714 }

ACE_INLINE void ACE_OS::seekdir ACE_DIR ,
long  loc
 

Definition at line 161 of file OS_NS_dirent.inl.

References ACE_DIR.

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 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, and ACE_SOCKCALL_RETURN.

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 = 0,
fd_set *  efds = 0,
const ACE_Time_Value tv = 0
 

Definition at line 14 of file OS_NS_sys_select.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

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(), ACE::select(), sema_wait(), ACE_SOCK_Dgram::send(), 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_INLINE int ACE_OS::sema_destroy ACE_sema_t *  s  ) 
 

Definition at line 1359 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().

01360 {
01361   ACE_OS_TRACE ("ACE_OS::sema_destroy");
01362 # if defined (ACE_HAS_POSIX_SEM)
01363   int result;
01364 #   if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01365   ACE_OS::mutex_destroy (&s->lock_);
01366   ACE_OS::cond_destroy (&s->count_nonzero_);
01367 #   endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01368 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01369   if (s->name_)
01370     {
01371       // Only destroy the semaphore if we're the ones who
01372       // initialized it.
01373       ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
01374       ACE_OS::shm_unlink (s->name_);
01375       delete s->name_;
01376       return result;
01377     }
01378 #   else
01379   if (s->name_)
01380     {
01381       ACE_OSCALL (::sem_unlink (s->name_), int, -1, result);
01382       ACE_OS::free ((void *) s->name_);
01383       ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
01384     }
01385 #   endif /*  ACE_LACKS_NAMED_POSIX_SEM */
01386   else
01387     {
01388       ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
01389 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01390       if (s->new_sema_ != 0)
01391 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
01392         delete s->sema_;
01393       s->sema_ = 0;
01394       return result;
01395     }
01396 # elif defined (ACE_USES_FIFO_SEM)
01397   int r0 = 0;
01398   if (s->name_)
01399     {
01400       r0 = ACE_OS::unlink (s->name_);
01401       ACE_OS::free (s->name_);
01402       s->name_ = 0;
01403     }
01404   int r1 = ACE_OS::close (s->fd_[0]);      /* ignore error */
01405   int r2 = ACE_OS::close (s->fd_[1]);      /* ignore error */
01406   return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0;
01407 # elif defined (ACE_HAS_THREADS)
01408 #   if defined (ACE_HAS_STHREADS)
01409   int result;
01410   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1);
01411 #   elif defined (ACE_HAS_PTHREADS)
01412   int r1 = ACE_OS::mutex_destroy (&s->lock_);
01413   int r2 = ACE_OS::cond_destroy (&s->count_nonzero_);
01414   return r1 != 0 || r2 != 0 ? -1 : 0;
01415 #   elif defined (ACE_HAS_WTHREADS)
01416 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01417   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1);
01418 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01419   // Free up underlying objects of the simulated semaphore.
01420   int r1 = ACE_OS::thread_mutex_destroy (&s->lock_);
01421   int r2 = ACE_OS::event_destroy (&s->count_nonzero_);
01422   return r1 != 0 || r2 != 0 ? -1 : 0;
01423 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01424 #   elif defined (ACE_VXWORKS)
01425   int result;
01426   ACE_OSCALL (::semDelete (s->sema_), int, -1, result);
01427   s->sema_ = 0;
01428   return result;
01429 #   endif /* ACE_HAS_STHREADS */
01430 # else
01431   ACE_UNUSED_ARG (s);
01432   ACE_NOTSUP_RETURN (-1);
01433 # endif /* ACE_HAS_POSIX_SEM */
01434 }

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

Definition at line 1767 of file OS_NS_Thread.inl.

References ACE_FAIL_RETURN, default_win32_security_attributes_r(), event_destroy(), event_init(), sema_init(), thread_mutex_destroy(), thread_mutex_init(), thread_mutex_lock(), and thread_mutex_unlock().

01774 {
01775 # if defined (ACE_HAS_WTHREADS)
01776 #   if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01777   ACE_UNUSED_ARG (type);
01778   ACE_UNUSED_ARG (arg);
01779   // Create the semaphore with its value initialized to <count> and
01780   // its maximum value initialized to <max>.
01781   SECURITY_ATTRIBUTES sa_buffer;
01782   SECURITY_DESCRIPTOR sd_buffer;
01783   *s = ::CreateSemaphoreW
01784     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01785      count,
01786      max,
01787      name);
01788 
01789   if (*s == 0)
01790     ACE_FAIL_RETURN (-1);
01791   /* NOTREACHED */
01792   else
01793     return 0;
01794 #   else /* ACE_USES_WINCE_SEMA_SIMULATION */
01795   int result = -1;
01796 
01797   // Initialize internal object for semaphore simulation.
01798   // Grab the lock as soon as possible when we initializing
01799   // the semaphore count.  Notice that we initialize the
01800   // event object as "manually reset" so we can amortize the
01801   // cost for singling/reseting the event.
01802   // @@ I changed the mutex type to thread_mutex.  Notice that this
01803   // is basically a CriticalSection object and doesn't not has
01804   // any security attribute whatsoever.  However, since this
01805   // semaphore implementation only works within a process, there
01806   // shouldn't any security issue at all.
01807   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01808       && ACE_OS::event_init (&s->count_nonzero_, 1,
01809                              count > 0, type, name, arg, sa) == 0
01810       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01811     {
01812       s->count_ = count;
01813 
01814       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01815         result = 0;
01816     }
01817 
01818   // Destroy the internal objects if we didn't initialize
01819   // either of them successfully.  Don't bother to check
01820   // for errors.
01821   if (result == -1)
01822     {
01823       ACE_OS::thread_mutex_destroy (&s->lock_);
01824       ACE_OS::event_destroy (&s->count_nonzero_);
01825     }
01826   return result;
01827 #   endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01828 # else /* ACE_HAS_WTHREADS */
01829   // Just call the normal char version.
01830   return ACE_OS::sema_init (s, count, type, ACE_Wide_To_Ascii (name).char_rep (), arg, max, sa);
01831 # endif /* ACE_HAS_WTHREADS */
01832 }

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

Definition at line 1440 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_ALLOCATOR_RETURN, ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_stat, ACE_TEXT_CHAR_TO_TCHAR, ACE_UNIQUE_NAME_LEN, close(), cond_destroy(), cond_init(), default_win32_security_attributes_r(), event_destroy(), event_init(), F_GETFL, fcntl(), ftruncate(), MAP_FAILED, MAP_SHARED, MAXPATHLEN, mkfifo(), mmap(), mode_t, 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(), and write().

Referenced by ACE_Semaphore::ACE_Semaphore(), event_init(), and sema_init().

01447 {
01448   ACE_OS_TRACE ("ACE_OS::sema_init");
01449 #if defined (ACE_HAS_POSIX_SEM)
01450   ACE_UNUSED_ARG (max);
01451   ACE_UNUSED_ARG (sa);
01452 
01453   s->name_ = 0;
01454 #  if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01455   ACE_UNUSED_ARG (arg);
01456 #  else
01457   int result = -1;
01458 
01459   if (ACE_OS::mutex_init (&s->lock_, type, name,
01460                           (ACE_mutexattr_t *) arg) == 0
01461       && ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) == 0
01462       && ACE_OS::mutex_lock (&s->lock_) == 0)
01463     {
01464       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01465         result = 0;
01466     }
01467 
01468   if (result == -1)
01469     {
01470       ACE_OS::mutex_destroy (&s->lock_);
01471       ACE_OS::cond_destroy (&s->count_nonzero_);
01472       return result;
01473     }
01474 #  endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01475 
01476 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01477   s->new_sema_ = 0;
01478   if (type == USYNC_PROCESS)
01479     {
01480       // Let's see if it already exists.
01481       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01482                                         O_RDWR | O_CREAT | O_EXCL,
01483                                         ACE_DEFAULT_FILE_PERMS);
01484       if (fd == ACE_INVALID_HANDLE)
01485         {
01486           if (errno == EEXIST)
01487             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01488                                    O_RDWR | O_CREAT,
01489                                    ACE_DEFAULT_FILE_PERMS);
01490           else
01491             return -1;
01492         }
01493       else
01494         {
01495           // We own this shared memory object!  Let's set its
01496           // size.
01497           if (ACE_OS::ftruncate (fd,
01498                                  sizeof (ACE_sema_t)) == -1)
01499             return -1;
01500           s->name_ = ACE_OS::strdup (name);
01501           if (s->name_ == 0)
01502             return -1;
01503         }
01504       if (fd == -1)
01505         return -1;
01506 
01507       s->sema_ = (sem_t *)
01508         ACE_OS::mmap (0,
01509                       sizeof (ACE_sema_t),
01510                       PROT_RDWR,
01511                       MAP_SHARED,
01512                       fd,
01513                       0);
01514       ACE_OS::close (fd);
01515       if (s->sema_ == (sem_t *) MAP_FAILED)
01516         return -1;
01517       if (s->name_
01518           // @@ According UNIX Network Programming V2 by Stevens,
01519           //    sem_init() is currently not required to return zero on
01520           //    success, but it *does* return -1 upon failure.  For
01521           //    this reason, check for failure by comparing to -1,
01522           //    instead of checking for success by comparing to zero.
01523           //        -Ossama
01524           // Only initialize it if we're the one who created it.
01525           && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1)
01526         return -1;
01527       return 0;
01528     }
01529 #  else
01530   if (name)
01531     {
01532 #    if defined (sun) || defined (HPUX)
01533       // Solaris and HP-UX require the name to start with a slash. Solaris
01534       // further requires that there be no other slashes than the first.
01535       const char *last_slash = ACE_OS::strrchr (name, '/');
01536       char name2[MAXPATHLEN];
01537       if (0 == last_slash)
01538         {
01539           ACE_OS::strcpy (name2, "/");
01540           ACE_OS::strcat (name2, name);
01541           name = name2;
01542         }
01543 #      if defined (sun)
01544       else
01545         name = last_slash;         // Chop off chars preceding last slash
01546 #      endif /* sun */
01547 #    endif /* sun || HPUX */
01548 
01549       ACE_ALLOCATOR_RETURN (s->name_,
01550                             ACE_OS::strdup (name),
01551                             -1);
01552       s->sema_ = ::sem_open (s->name_,
01553                              O_CREAT,
01554                              ACE_DEFAULT_FILE_PERMS,
01555                              count);
01556       if (s->sema_ == (sem_t *) SEM_FAILED)
01557         return -1;
01558       else
01559         return 0;
01560     }
01561 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01562   else
01563     {
01564       ACE_NEW_RETURN (s->sema_,
01565                       sem_t,
01566                       -1);
01567 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01568       s->new_sema_ = 1;
01569 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01570       ACE_OSCALL_RETURN (::sem_init (s->sema_,
01571                                      type != USYNC_THREAD,
01572                                      count), int, -1);
01573     }
01574 
01575 #elif defined (ACE_USES_FIFO_SEM)
01576   ACE_UNUSED_ARG (arg);
01577   ACE_UNUSED_ARG (max);
01578   ACE_UNUSED_ARG (sa);
01579   int             flags = 0;
01580   mode_t          mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;
01581 
01582   if (type == USYNC_THREAD)
01583     {
01584       // Create systemwide unique name for semaphore
01585       char   uname[ACE_UNIQUE_NAME_LEN];
01586       ACE_OS::unique_name ((const void *) s,
01587                             uname,
01588                             ACE_UNIQUE_NAME_LEN);
01589       name = &uname[0];
01590     }
01591 
01592   s->name_ = 0;
01593   s->fd_[0] = s->fd_[1] = ACE_INVALID_HANDLE;
01594   bool creator = false;
01595 
01596   if (ACE_OS::mkfifo (ACE_TEXT_CHAR_TO_TCHAR (name), mode) < 0)
01597     {
01598       if (errno != EEXIST)    /* already exists OK else ERR */
01599         return -1;
01600       // check if this is a real FIFO, not just some other existing file
01601       ACE_stat fs;
01602       if (ACE_OS::stat (name, &fs))
01603         return -1;
01604       if (!S_ISFIFO (fs.st_mode))
01605         {
01606           // existing file is not a FIFO
01607           errno = EEXIST;
01608           return -1;
01609         }
01610     }
01611     else
01612       creator = true; // remember we created it for initialization at end
01613 
01614   // for processshared semaphores remember who we are to be able to remove
01615   // the FIFO when we're done with it
01616   if (type == USYNC_PROCESS)
01617     {
01618       s->name_ = ACE_OS::strdup (name);
01619       if (s->name_ == 0)
01620         {
01621           if (creator)
01622             ACE_OS::unlink (name);
01623           return -1;
01624         }
01625     }
01626 
01627   if ((s->fd_[0] = ACE_OS::open (name, O_RDONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE
01628       || (s->fd_[1] = ACE_OS::open (name, O_WRONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE)
01629     return (-1);
01630 
01631   /* turn off nonblocking for fd_[0] */
01632   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01633     return (-1);
01634 
01635   flags &= ~O_NONBLOCK;
01636   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01637     return (-1);
01638 
01639   //if (s->name_ && count)
01640   if (creator && count)
01641     {
01642       char    c = 1;
01643       for (u_int i=0; i<count ;++i)
01644         if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) != 1)
01645           return (-1);
01646     }
01647 
01648   // In the case of process scope semaphores we can already unlink the FIFO now that
01649   // we completely set it up (the opened handles will keep it active until we close
01650   // thos down). This way we're protected against unexpected crashes as far as removal
01651   // is concerned.
01652   // Unfortunately this does not work for processshared FIFOs since as soon as we
01653   // have unlinked the semaphore no other process will be able to open it anymore.
01654   if (type == USYNC_THREAD)
01655     {
01656       ACE_OS::unlink (name);
01657     }
01658 
01659   return (0);
01660 #elif defined (ACE_HAS_THREADS)
01661 #  if defined (ACE_HAS_STHREADS)
01662   ACE_UNUSED_ARG (name);
01663   ACE_UNUSED_ARG (max);
01664   ACE_UNUSED_ARG (sa);
01665   int result;
01666   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), result),
01667                      int, -1);
01668 #  elif defined (ACE_HAS_PTHREADS)
01669   ACE_UNUSED_ARG (max);
01670   ACE_UNUSED_ARG (sa);
01671   int result = -1;
01672 
01673   if (ACE_OS::mutex_init (&s->lock_, type, name,
01674                           (ACE_mutexattr_t *) arg) == 0
01675       && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0
01676       && ACE_OS::mutex_lock (&s->lock_) == 0)
01677     {
01678       s->count_ = count;
01679       s->waiters_ = 0;
01680 
01681       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01682         result = 0;
01683     }
01684 
01685   if (result == -1)
01686     {
01687       ACE_OS::mutex_destroy (&s->lock_);
01688       ACE_OS::cond_destroy (&s->count_nonzero_);
01689     }
01690   return result;
01691 #  elif defined (ACE_HAS_WTHREADS)
01692 #    if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01693   ACE_UNUSED_ARG (type);
01694   ACE_UNUSED_ARG (arg);
01695   // Create the semaphore with its value initialized to <count> and
01696   // its maximum value initialized to <max>.
01697   SECURITY_ATTRIBUTES sa_buffer;
01698   SECURITY_DESCRIPTOR sd_buffer;
01699   *s = ::CreateSemaphoreA
01700     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01701      count,
01702      max,
01703      name);
01704 
01705   if (*s == 0)
01706     ACE_FAIL_RETURN (-1);
01707   /* NOTREACHED */
01708   else
01709     return 0;
01710 #    else /* ACE_USES_WINCE_SEMA_SIMULATION */
01711   int result = -1;
01712 
01713   // Initialize internal object for semaphore simulation.
01714   // Grab the lock as soon as possible when we initializing
01715   // the semaphore count.  Notice that we initialize the
01716   // event object as "manually reset" so we can amortize the
01717   // cost for singling/reseting the event.
01718   // @@ I changed the mutex type to thread_mutex.  Notice that this
01719   // is basically a CriticalSection object and doesn't not has
01720   // any security attribute whatsoever.  However, since this
01721   // semaphore implementation only works within a process, there
01722   // shouldn't any security issue at all.
01723   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01724       && ACE_OS::event_init (&s->count_nonzero_, 1,
01725                              count > 0, type, name, arg, sa) == 0
01726       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01727     {
01728       s->count_ = count;
01729 
01730       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01731         result = 0;
01732     }
01733 
01734   // Destroy the internal objects if we didn't initialize
01735   // either of them successfully.  Don't bother to check
01736   // for errors.
01737   if (result == -1)
01738     {
01739       ACE_OS::thread_mutex_destroy (&s->lock_);
01740       ACE_OS::event_destroy (&s->count_nonzero_);
01741     }
01742   return result;
01743 #    endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01744 #  elif defined (ACE_VXWORKS)
01745   ACE_UNUSED_ARG (name);
01746   ACE_UNUSED_ARG (arg);
01747   ACE_UNUSED_ARG (max);
01748   ACE_UNUSED_ARG (sa);
01749   s->name_ = 0;
01750   s->sema_ = ::semCCreate (type, count);
01751   return s->sema_ ? 0 : -1;
01752 #  endif /* ACE_HAS_STHREADS */
01753 #else
01754   ACE_UNUSED_ARG (s);
01755   ACE_UNUSED_ARG (count);
01756   ACE_UNUSED_ARG (type);
01757   ACE_UNUSED_ARG (name);
01758   ACE_UNUSED_ARG (arg);
01759   ACE_UNUSED_ARG (max);
01760   ACE_UNUSED_ARG (sa);
01761   ACE_NOTSUP_RETURN (-1);
01762 #endif /* ACE_HAS_POSIX_SEM */
01763 }

ACE_INLINE int ACE_OS::sema_post ACE_sema_t *  s,
u_int  release_count
 

Definition at line 1912 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, and sema_post().

01913 {
01914 #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01915   // Win32 supports this natively.
01916   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
01917                                           ace_result_), int, -1);
01918 #else
01919   // On POSIX platforms we need to emulate this ourselves.
01920   // @@ We can optimize on this implementation.  However,
01921   // the semaphore promitive on Win32 doesn't allow one
01922   // to increase a semaphore to more than the count it was
01923   // first initialized.  Posix and solaris don't seem to have
01924   // this restriction.  Should we impose the restriction in
01925   // our semaphore simulation?
01926   for (size_t i = 0; i < release_count; i++)
01927     if (ACE_OS::sema_post (s) == -1)
01928       return -1;
01929 
01930   return 0;
01931 #endif /* ACE_WIN32 */
01932 }

ACE_INLINE int ACE_OS::sema_post ACE_sema_t *  s  ) 
 

Definition at line 1836 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().

Referenced by event_init(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), ACE_Semaphore::release(), and sema_post().

01837 {
01838   ACE_OS_TRACE ("ACE_OS::sema_post");
01839 # if defined (ACE_HAS_POSIX_SEM)
01840 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
01841   ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1);
01842 #   else
01843   int result = -1;
01844 
01845   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01846     {
01847       if (::sem_post (s->sema_) == 0)
01848         result = ACE_OS::cond_signal (&s->count_nonzero_);
01849 
01850       ACE_OS::mutex_unlock (&s->lock_);
01851     }
01852   return result;
01853 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
01854 # elif defined (ACE_USES_FIFO_SEM)
01855   char    c = 1;
01856   if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) == sizeof (char))
01857     return (0);
01858   return (-1);
01859 # elif defined (ACE_HAS_THREADS)
01860 #   if defined (ACE_HAS_STHREADS)
01861   int result;
01862   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), result), int, -1);
01863 #   elif defined (ACE_HAS_PTHREADS)
01864   int result = -1;
01865 
01866   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01867     {
01868       // Always allow a waiter to continue if there is one.
01869       if (s->waiters_ > 0)
01870         result = ACE_OS::cond_signal (&s->count_nonzero_);
01871       else
01872         result = 0;
01873 
01874       s->count_++;
01875       ACE_OS::mutex_unlock (&s->lock_);
01876     }
01877   return result;
01878 #   elif defined (ACE_HAS_WTHREADS)
01879 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01880   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
01881                                           ace_result_),
01882                         int, -1);
01883 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01884   int result = -1;
01885 
01886   // Since we are simulating semaphores, we need to update semaphore
01887   // count manually.  Grab the lock to prevent race condition first.
01888   if (ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01889     {
01890       // Check the original state of event object.  Single the event
01891       // object in transition from semaphore not available to
01892       // semaphore available.
01893       if (s->count_++ <= 0)
01894         result = ACE_OS::event_signal (&s->count_nonzero_);
01895       else
01896         result = 0;
01897 
01898       ACE_OS::thread_mutex_unlock (&s->lock_);
01899     }
01900   return result;
01901 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01902 #   elif defined (ACE_VXWORKS)
01903   ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1);
01904 #   endif /* ACE_HAS_STHREADS */
01905 # else
01906   ACE_UNUSED_ARG (s);
01907   ACE_NOTSUP_RETURN (-1);
01908 # endif /* ACE_HAS_POSIX_SEM */
01909 }

ACE_INLINE int ACE_OS::sema_trywait ACE_sema_t *  s  ) 
 

Definition at line 1935 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().

01936 {
01937   ACE_OS_TRACE ("ACE_OS::sema_trywait");
01938 # if defined (ACE_HAS_POSIX_SEM)
01939   // POSIX semaphores set errno to EAGAIN if trywait fails
01940   ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1);
01941 # elif defined (ACE_USES_FIFO_SEM)
01942   char  c;
01943   int     rc, flags;
01944 
01945   /* turn on nonblocking for s->fd_[0] */
01946   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01947     return (-1);
01948   flags |= O_NONBLOCK;
01949   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01950     return (-1);
01951 
01952   // read sets errno to EAGAIN if no input
01953   rc = ACE_OS::read (s->fd_[0], &c, sizeof (char));
01954 
01955   /* turn off nonblocking for fd_[0] */
01956   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) >= 0)
01957   {
01958     flags &= ~O_NONBLOCK;
01959     ACE_OS::fcntl (s->fd_[0], F_SETFL, flags);
01960   }
01961 
01962   return rc == 1 ? 0 : (-1);
01963 # elif defined (ACE_HAS_THREADS)
01964 #   if defined (ACE_HAS_STHREADS)
01965   // STHREADS semaphores set errno to EBUSY if trywait fails.
01966   int result;
01967   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s),
01968                                        result),
01969                      int, -1);
01970 #   elif defined (ACE_HAS_PTHREADS)
01971 
01972   int result = -1;
01973 
01974   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01975     {
01976       if (s->count_ > 0)
01977         {
01978           --s->count_;
01979           result = 0;
01980         }
01981       else
01982         errno = EBUSY;
01983 
01984       ACE_OS::mutex_unlock (&s->lock_);
01985     }
01986   return result;
01987 #   elif defined (ACE_HAS_WTHREADS)
01988 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01989   DWORD result = ::WaitForSingleObject (*s, 0);
01990 
01991   if (result == WAIT_OBJECT_0)
01992     return 0;
01993   else
01994     {
01995       if (result == WAIT_TIMEOUT)
01996         errno = EBUSY;
01997       else
01998         ACE_OS::set_errno_to_last_error ();
01999       // This is a hack, we need to find an appropriate mapping...
02000       return -1;
02001     }
02002 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02003   // Check the status of semaphore first.  Return immediately
02004   // if the semaphore is not available and avoid grabing the
02005   // lock.
02006   DWORD result = ::WaitForSingleObject (s->count_nonzero_, 0);
02007 
02008   if (result == WAIT_OBJECT_0)  // Proceed when it is available.
02009     {
02010       ACE_OS::thread_mutex_lock (&s->lock_);
02011 
02012       // Need to double check if the semaphore is still available.
02013       // The double checking scheme will slightly affect the
02014       // efficiency if most of the time semaphores are not blocked.
02015       result = ::WaitForSingleObject (s->count_nonzero_, 0);
02016       if (result == WAIT_OBJECT_0)
02017         {
02018           // Adjust the semaphore count.  Only update the event
02019           // object status when the state changed.
02020           s->count_--;
02021           if (s->count_ <= 0)
02022             ACE_OS::event_reset (&s->count_nonzero_);
02023           result = 0;
02024         }
02025 
02026       ACE_OS::thread_mutex_unlock (&s->lock_);
02027     }
02028 
02029   // Translate error message to errno used by ACE.
02030   if (result == WAIT_TIMEOUT)
02031     errno = EBUSY;
02032   else
02033     ACE_OS::set_errno_to_last_error ();
02034   // This is taken from the hack above. ;)
02035   return -1;
02036 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02037 #   elif defined (ACE_VXWORKS)
02038   if (::semTake (s->sema_, NO_WAIT) == ERROR)
02039     if (errno == S_objLib_OBJ_UNAVAILABLE)
02040       {
02041         // couldn't get the semaphore
02042         errno = EBUSY;
02043         return -1;
02044       }
02045     else
02046       // error
02047       return -1;
02048   else
02049     // got the semaphore
02050     return 0;
02051 #   endif /* ACE_HAS_STHREADS */
02052 # else
02053   ACE_UNUSED_ARG (s);
02054   ACE_NOTSUP_RETURN (-1);
02055 # endif /* ACE_HAS_POSIX_SEM */
02056 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *  s,
ACE_Time_Value tv
 

Definition at line 2453 of file OS_NS_Thread.inl.

References sema_wait().

02454 {
02455   return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
02456 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *  s,
ACE_Time_Value tv
 

Definition at line 2168 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, ETIME, ETIMEDOUT, event_reset(), gettimeofday(), 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(), timespec_t, and ACE_Time_Value::usec().

02169 {
02170   ACE_OS_TRACE ("ACE_OS::sema_wait");
02171 # if defined (ACE_HAS_POSIX_SEM)
02172 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
02173   int rc;
02174   timespec_t ts;
02175   ts = tv; // Calls ACE_Time_Value::operator timespec_t().
02176   ACE_OSCALL (::sem_timedwait (s->sema_, &ts), int, -1, rc);
02177   if (rc == -1 && errno == ETIMEDOUT)
02178     errno = ETIME;  /* POSIX returns ETIMEDOUT but we need ETIME */
02179   return rc;
02180 #   elif !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
02181   int result = 0;
02182   bool expired = false;
02183   ACE_Errno_Guard error (errno);
02184 
02185   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02186 
02187   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02188     result = -2;
02189   else
02190     {
02191       bool finished = true;
02192       do
02193       {
02194         result = ACE_OS::sema_trywait (s);
02195         if (result == -1 && errno == EAGAIN)
02196           expired = ACE_OS::gettimeofday () > tv;
02197         else
02198           expired = false;
02199 
02200         finished = result != -1 || expired ||
02201                    (result == -1 && errno != EAGAIN);
02202         if (!finished)
02203           {
02204             if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02205                                         &s->lock_,
02206                                         &tv) == -1)
02207               {
02208                 error = errno;
02209                 result = -1;
02210                 break;
02211               }
02212           }
02213       } while (!finished);
02214 
02215       if (expired)
02216         error = ETIME;
02217 
02218 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02219       tv = ACE_OS::gettimeofday ();
02220 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02221     }
02222 
02223   if (result != -2)
02224     ACE_OS::mutex_unlock (&s->lock_);
02225   ACE_PTHREAD_CLEANUP_POP (0);
02226   return result < 0 ? -1 : result;
02227 #   else /* No native sem_timedwait(), and emulation disabled */
02228   ACE_UNUSED_ARG (s);
02229   ACE_UNUSED_ARG (tv);
02230   ACE_NOTSUP_RETURN (-1);
02231 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT */
02232 # elif defined (ACE_USES_FIFO_SEM)
02233   int rc;
02234   ACE_Time_Value now = ACE_OS::gettimeofday ();
02235 
02236   while (tv > now)
02237     {
02238       ACE_Time_Value timeout = tv;
02239       timeout -= now;
02240 
02241       ACE_Handle_Set  fds_;
02242 
02243       fds_.set_bit (s->fd_[0]);
02244       if ((rc = ACE_OS::select (ACE_Handle_Set::MAXSIZE, fds_, 0, 0, timeout)) != 1)
02245         {
02246           if (rc == 0 || errno != EAGAIN)
02247           {
02248             if (rc == 0)
02249               errno = ETIME;
02250             return (-1);
02251           }
02252         }
02253 
02254       // try to read the signal *but* do *not* block
02255       if (rc == 1 && ACE_OS::sema_trywait (s) == 0)
02256         return (0);
02257 
02258       // we were woken for input but someone beat us to it
02259       // so we wait again if there is still time
02260       now = ACE_OS::gettimeofday ();
02261     }
02262 
02263   // make sure errno is set right
02264   errno = ETIME;
02265 
02266   return (-1);
02267 # elif defined (ACE_HAS_THREADS)
02268 #   if defined (ACE_HAS_STHREADS)
02269   ACE_UNUSED_ARG (s);
02270   ACE_UNUSED_ARG (tv);
02271   ACE_NOTSUP_RETURN (-1);
02272 #   elif defined (ACE_HAS_PTHREADS)
02273   int result = 0;
02274   ACE_Errno_Guard error (errno);
02275 
02276   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02277 
02278   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02279     result = -1;
02280   else
02281     {
02282       // Keep track of the number of waiters so that we can signal
02283       // them properly in <ACE_OS::sema_post>.
02284       s->waiters_++;
02285 
02286       // Wait until the semaphore count is > 0 or until we time out.
02287       while (s->count_ == 0)
02288         if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02289                                     &s->lock_,
02290                                     &tv) == -1)
02291           {
02292             error = errno;
02293             result = -2; // -2 means that we need to release the mutex.
02294             break;
02295           }
02296 
02297       --s->waiters_;
02298     }
02299 
02300   if (result == 0)
02301     {
02302 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02303       tv = ACE_OS::gettimeofday ();
02304 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02305       --s->count_;
02306     }
02307 
02308   if (result != -1)
02309     ACE_OS::mutex_unlock (&s->lock_);
02310   ACE_PTHREAD_CLEANUP_POP (0);
02311   return result < 0 ? -1 : result;
02312 #   elif defined (ACE_HAS_WTHREADS)
02313 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02314   int msec_timeout;
02315 
02316   if (tv.sec () == 0 && tv.usec () == 0)
02317     msec_timeout = 0; // Do a "poll."
02318   else
02319     {
02320       // Note that we must convert between absolute time (which is
02321       // passed as a parameter) and relative time (which is what
02322       // <WaitForSingleObjects> expects).
02323       ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02324 
02325       // Watchout for situations where a context switch has caused the
02326       // current time to be > the timeout.
02327       if (relative_time < ACE_Time_Value::zero)
02328         msec_timeout = 0;
02329       else
02330         msec_timeout = relative_time.msec ();
02331     }
02332 
02333   switch (::WaitForSingleObject (*s, msec_timeout))
02334     {
02335     case WAIT_OBJECT_0:
02336       tv = ACE_OS::gettimeofday ();     // Update time to when acquired
02337       return 0;
02338     case WAIT_TIMEOUT:
02339       errno = ETIME;
02340       return -1;
02341     default:
02342       // This is a hack, we need to find an appropriate mapping...
02343       ACE_OS::set_errno_to_last_error ();
02344       return -1;
02345     }
02346   /* NOTREACHED */
02347 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02348   // Note that in this mode, the acquire is done in two steps, and
02349   // we may get signaled but cannot grab the semaphore before
02350   // timeout.  In that case, we'll need to restart the process with
02351   // updated timeout value.
02352 
02353   // tv is an absolute time, but we need relative to work with the Windows
02354   // API. Also, some users have become accustomed to using a 0 time value
02355   // as a shortcut for "now", which works on non-Windows because 0 is
02356   // always earlier than now. However, the need to convert to relative time
02357   // means we need to watch out for this case.
02358   ACE_Time_Value end_time = tv;
02359   if (tv == ACE_Time_Value::zero)
02360     end_time = ACE_OS::gettimeofday ();
02361   ACE_Time_Value relative_time = end_time - ACE_OS::gettimeofday ();
02362   int result = -1;
02363 
02364   // While we are not timeout yet. >= 0 will let this go through once
02365   // and if not able to get the object, it should hit WAIT_TIMEOUT
02366   // right away.
02367   while (relative_time >= ACE_Time_Value::zero)
02368     {
02369       // Wait for our turn to get the object.
02370       switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ()))
02371         {
02372         case WAIT_OBJECT_0:
02373           ACE_OS::thread_mutex_lock (&s->lock_);
02374 
02375           // Need to double check if the semaphore is still available.
02376           // We can only do a "try lock" styled wait here to avoid
02377           // blocking threads that want to signal the semaphore.
02378           if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02379             {
02380               // As before, only reset the object when the semaphore
02381               // is no longer available.
02382               s->count_--;
02383               if (s->count_ <= 0)
02384                 ACE_OS::event_reset (&s->count_nonzero_);
02385               result = 0;
02386             }
02387 
02388           ACE_OS::thread_mutex_unlock (&s->lock_);
02389 
02390           // Only return when we successfully get the semaphore.
02391           if (result == 0)
02392             {
02393               tv = ACE_OS::gettimeofday ();     // Update to time acquired
02394               return 0;
02395             }
02396           break;
02397 
02398           // We have timed out.
02399         case WAIT_TIMEOUT:
02400           errno = ETIME;
02401           return -1;
02402 
02403           // What?
02404         default:
02405           ACE_OS::set_errno_to_last_error ();
02406           // This is taken from the hack above. ;)
02407           return -1;
02408         };
02409 
02410       // Haven't been able to get the semaphore yet, update the
02411       // timeout value to reflect the remaining time we want to wait.
02412       relative_time = end_time - ACE_OS::gettimeofday ();
02413     }
02414 
02415   // We have timed out.
02416   errno = ETIME;
02417   return -1;
02418 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02419 #   elif defined (ACE_VXWORKS)
02420   // Note that we must convert between absolute time (which is
02421   // passed as a parameter) and relative time (which is what
02422   // the system call expects).
02423   ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02424 
02425   int ticks_per_sec = ::sysClkRateGet ();
02426 
02427   int ticks = relative_time.sec () * ticks_per_sec +
02428               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02429   if (::semTake (s->sema_, ticks) == ERROR)
02430     {
02431       if (errno == S_objLib_OBJ_TIMEOUT)
02432         // Convert the VxWorks errno to one that's common for to ACE
02433         // platforms.
02434         errno = ETIME;
02435       else if (errno == S_objLib_OBJ_UNAVAILABLE)
02436         errno = EBUSY;
02437       return -1;
02438     }
02439   else
02440     {
02441       tv = ACE_OS::gettimeofday ();  // Update to time acquired
02442       return 0;
02443     }
02444 #   endif /* ACE_HAS_STHREADS */
02445 # else
02446   ACE_UNUSED_ARG (s);
02447   ACE_UNUSED_ARG (tv);
02448   ACE_NOTSUP_RETURN (-1);
02449 # endif /* ACE_HAS_POSIX_SEM */
02450 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *  s  ) 
 

Definition at line 2059 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(), event_reset(), mutex_lock(), mutex_unlock(), read(), sema_wait(), set_errno_to_last_error(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by ACE_Semaphore::acquire(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), and sema_wait().

02060 {
02061   ACE_OS_TRACE ("ACE_OS::sema_wait");
02062 # if defined (ACE_HAS_POSIX_SEM)
02063   ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1);
02064 # elif defined (ACE_USES_FIFO_SEM)
02065   char c;
02066   if (ACE_OS::read (s->fd_[0], &c, sizeof (char)) == 1)
02067     return (0);
02068   return (-1);
02069 # elif defined (ACE_HAS_THREADS)
02070 #   if defined (ACE_HAS_STHREADS)
02071   int result;
02072   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), result), int, -1);
02073 #   elif defined (ACE_HAS_PTHREADS)
02074   int result = 0;
02075 
02076   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02077 
02078   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02079     result = -1;
02080   else
02081     {
02082       // Keep track of the number of waiters so that we can signal
02083       // them properly in <ACE_OS::sema_post>.
02084       s->waiters_++;
02085 
02086       // Wait until the semaphore count is > 0.
02087       while (s->count_ == 0)
02088         if (ACE_OS::cond_wait (&s->count_nonzero_,
02089                                &s->lock_) == -1)
02090           {
02091             result = -2; // -2 means that we need to release the mutex.
02092             break;
02093           }
02094 
02095       --s->waiters_;
02096     }
02097 
02098   if (result == 0)
02099     --s->count_;
02100 
02101   if (result != -1)
02102     ACE_OS::mutex_unlock (&s->lock_);
02103   ACE_PTHREAD_CLEANUP_POP (0);
02104   return result < 0 ? -1 : result;
02105 
02106 #   elif defined (ACE_HAS_WTHREADS)
02107 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02108   switch (::WaitForSingleObject (*s, INFINITE))
02109     {
02110     case WAIT_OBJECT_0:
02111       return 0;
02112     default:
02113       // This is a hack, we need to find an appropriate mapping...
02114       ACE_OS::set_errno_to_last_error ();
02115       return -1;
02116     }
02117   /* NOTREACHED */
02118 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02119   // Timed wait.
02120   int result = -1;
02121   for (;;)
02122     // Check if the semaphore is avialable or not and wait forever.
02123     // Don't bother to grab the lock if it is not available (to avoid
02124     // deadlock.)
02125     switch (::WaitForSingleObject (s->count_nonzero_, INFINITE))
02126       {
02127       case WAIT_OBJECT_0:
02128         ACE_OS::thread_mutex_lock (&s->lock_);
02129 
02130         // Need to double check if the semaphore is still available.
02131         // This time, we shouldn't wait at all.
02132         if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02133           {
02134             // Decrease the internal counter.  Only update the event
02135             // object's status when the state changed.
02136             s->count_--;
02137             if (s->count_ <= 0)
02138               ACE_OS::event_reset (&s->count_nonzero_);
02139             result = 0;
02140           }
02141 
02142         ACE_OS::thread_mutex_unlock (&s->lock_);
02143         // if we didn't get a hold on the semaphore, the result won't
02144         // be 0 and thus, we'll start from the beginning again.
02145         if (result == 0)
02146           return 0;
02147         break;
02148 
02149       default:
02150         // Since we wait indefinitely, anything other than
02151         // WAIT_OBJECT_O indicates an error.
02152         ACE_OS::set_errno_to_last_error ();
02153         // This is taken from the hack above. ;)
02154         return -1;
02155       }
02156   /* NOTREACHED */
02157 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02158 #   elif defined (ACE_VXWORKS)
02159   ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1);
02160 #   endif /* ACE_HAS_STHREADS */
02161 # else
02162   ACE_UNUSED_ARG (s);
02163   ACE_NOTSUP_RETURN (-1);
02164 # endif /* ACE_HAS_POSIX_SEM */
02165 }

ACE_INLINE int ACE_OS::semctl int  int_id,
int  semnum,
int  cmd,
semun 
 

Definition at line 2459 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().

02460 {
02461   ACE_OS_TRACE ("ACE_OS::semctl");
02462 #if defined (ACE_HAS_SYSV_IPC)
02463   ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1);
02464 #else
02465   ACE_UNUSED_ARG (int_id);
02466   ACE_UNUSED_ARG (semnum);
02467   ACE_UNUSED_ARG (cmd);
02468   ACE_UNUSED_ARG (value);
02469 
02470   ACE_NOTSUP_RETURN (-1);
02471 #endif /* ACE_HAS_SYSV_IPC */
02472 }

ACE_INLINE int ACE_OS::semget key_t  key,
int  nsems,
int  flags
 

Definition at line 2475 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().

02476 {
02477   ACE_OS_TRACE ("ACE_OS::semget");
02478 #if defined (ACE_HAS_SYSV_IPC)
02479   ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1);
02480 #else
02481   ACE_UNUSED_ARG (key);
02482   ACE_UNUSED_ARG (nsems);
02483   ACE_UNUSED_ARG (flags);
02484 
02485   ACE_NOTSUP_RETURN (-1);
02486 #endif /* ACE_HAS_SYSV_IPC */
02487 }

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

Definition at line 2490 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().

02491 {
02492   ACE_OS_TRACE ("ACE_OS::semop");
02493 #if defined (ACE_HAS_SYSV_IPC)
02494   ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1);
02495 #else
02496   ACE_UNUSED_ARG (int_id);
02497   ACE_UNUSED_ARG (sops);
02498   ACE_UNUSED_ARG (nsops);
02499 
02500   ACE_NOTSUP_RETURN (-1);
02501 #endif /* ACE_HAS_SYSV_IPC */
02502 }

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

BSD-style (no QoS).

Definition at line 534 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, EWOULDBLOCK, and ssize_t.

Referenced by ACE_Pipe::send(), ACE::send(), ACE::send_i(), ACE::send_n_i(), and sendfile_emulation().

00535 {
00536   ACE_OS_TRACE ("ACE_OS::send");
00537 
00538   // On UNIX, a non-blocking socket with no data to receive, this
00539   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00540   // platform.  UNIX 98 allows either errno, and they may be the same
00541   // numeric value.  So to make life easier for upper ACE layers as
00542   // well as application programmers, always change EAGAIN to
00543   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00544   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00545   // this function needs to be reviewed.  On Win32, the regular macros
00546   // can be used, as this is not an issue.
00547 #if defined (ACE_LACKS_SEND)
00548   ACE_UNUSED_ARG (handle);
00549   ACE_UNUSED_ARG (buf);
00550   ACE_UNUSED_ARG (len);
00551   ACE_UNUSED_ARG (flags);
00552   ACE_NOTSUP_RETURN (-1);
00553 #elif defined (ACE_WIN32)
00554   ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle,
00555                                buf,
00556                                static_cast<int> (len),
00557                                flags), ssize_t, -1);
00558 #else
00559   ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
00560 
00561 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00562   // Optimize this code out if we can detect that EAGAIN ==
00563   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00564   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00565   // macros) perform the check at run-time.  The goal is to avoid two
00566   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00567   if (ace_result_ == -1
00568 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00569       && EAGAIN != EWOULDBLOCK
00570 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00571       && errno == EAGAIN)
00572     {
00573       errno = EWOULDBLOCK;
00574     }
00575 # endif /* EAGAIN != EWOULDBLOCK*/
00576 
00577   return ace_result_;
00578 #endif /* defined (ACE_WIN32) */
00579 }

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_emulation().

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 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, MAP_SHARED, mmap(), munmap(), PROT_READ, send(), ssize_t, 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_INLINE ssize_t ACE_OS::sendmsg ACE_HANDLE  handle,
const struct msghdr msg,
int  flags
 

BSD-style (no QoS).

Definition at line 582 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE::sendmsg().

00585 {
00586   ACE_OS_TRACE ("ACE_OS::sendmsg");
00587 #if !defined (ACE_LACKS_SENDMSG)
00588 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00589   DWORD bytes_sent = 0;
00590   int result = ::WSASendTo ((SOCKET) handle,
00591                             (WSABUF *) msg->msg_iov,
00592                             msg->msg_iovlen,
00593                             &bytes_sent,
00594                             flags,
00595                             msg->msg_name,
00596                             msg->msg_namelen,
00597                             0,
00598                             0);
00599 
00600   if (result != 0)
00601     {
00602       ACE_OS::set_errno_to_wsa_last_error ();
00603       return -1;
00604     }
00605   else
00606     return (ssize_t) bytes_sent;
00607 # elif defined (ACE_HAS_NONCONST_SENDMSG)
00608   ACE_SOCKCALL_RETURN (::sendmsg (handle,
00609                                   const_cast<struct msghdr *>(msg),
00610                                   flags), ssize_t, -1);
00611 # else
00612   ACE_SOCKCALL_RETURN (::sendmsg (handle, msg, flags), ssize_t, -1);
00613 # endif
00614 #else
00615   ACE_UNUSED_ARG (flags);
00616   ACE_UNUSED_ARG (msg);
00617   ACE_UNUSED_ARG (handle);
00618 
00619   ACE_NOTSUP_RETURN (-1);
00620 #endif /* ACE_LACKS_SENDMSG */
00621 }

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
 

BSD-style (no QoS).

Definition at line 668 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, sendto(), set_errno_to_wsa_last_error(), and ssize_t.

00677 {
00678   ACE_OS_TRACE ("ACE_OS::sendto");
00679 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00680   DWORD bytes_sent = 0;
00681   int result = ::WSASendTo ((SOCKET) handle,
00682                             (WSABUF*) buffers,
00683                             buffer_count,
00684                             &bytes_sent,
00685                             flags,
00686                             addr,
00687                             addrlen,
00688                             overlapped,
00689                             func);
00690   if (result != 0) {
00691     ACE_OS::set_errno_to_wsa_last_error ();
00692   }
00693   number_of_bytes_sent = static_cast<size_t> (bytes_sent);
00694   return (ssize_t) result;
00695 #else
00696   ACE_UNUSED_ARG (overlapped);
00697   ACE_UNUSED_ARG (func);
00698 
00699   number_of_bytes_sent = 0;
00700 
00701   ssize_t result = 0;
00702 
00703   for (int i = 0; i < buffer_count; ++i)
00704     {
00705        result = ACE_OS::sendto (handle,
00706                                 reinterpret_cast<char *> (
00707                                                  buffers[i].iov_base),
00708                                 buffers[i].iov_len,
00709                                 flags,
00710                                 addr,
00711                                 addrlen);
00712        if (result == -1)
00713          break;
00714        number_of_bytes_sent += static_cast<size_t> (result);
00715     }
00716 
00717   return result;
00718 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00719 }

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

BSD-style (no QoS).

Definition at line 624 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ssize_t.

Referenced by ACE_SOCK_Dgram_Bcast::send(), ACE_SOCK_Dgram::send(), sendto(), and ACE::sendto().

00630 {
00631   ACE_OS_TRACE ("ACE_OS::sendto");
00632 #if defined (ACE_LACKS_SENDTO)
00633   ACE_UNUSED_ARG (handle);
00634   ACE_UNUSED_ARG (buf);
00635   ACE_UNUSED_ARG (len);
00636   ACE_UNUSED_ARG (flags);
00637   ACE_UNUSED_ARG (addr);
00638   ACE_UNUSED_ARG (addrlen);
00639   ACE_NOTSUP_RETURN (-1);
00640 #elif defined (ACE_VXWORKS)
00641   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00642                                  const_cast <char *> (buf),
00643                                  len,
00644                                  flags,
00645                                  const_cast<struct sockaddr *> (addr),
00646                                  addrlen),
00647                        ssize_t, -1);
00648 #elif defined (ACE_WIN32)
00649   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00650                                  buf,
00651                                  static_cast<int> (len),
00652                                  flags,
00653                                  const_cast<struct sockaddr *> (addr),
00654                                  addrlen),
00655                        ssize_t, -1);
00656 #else
00657   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00658                                  buf,
00659                                  len,
00660                                  flags,
00661                                  const_cast<struct sockaddr *> (addr),
00662                                  addrlen),
00663                        ssize_t, -1);
00664 #endif /* ACE_LACKS_SENDTO */
00665 }

ACE_INLINE ssize_t ACE_OS::sendv ACE_HANDLE  handle,
const iovec *  iov,
int  iovcnt
 

BSD-style (no QoS).

Definition at line 722 of file OS_NS_sys_socket.inl.

References ACE_IOV_MAX, set_errno_to_wsa_last_error(), ssize_t, 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().

00725 {
00726 #if defined (ACE_HAS_WINSOCK2)
00727   DWORD bytes_sent = 0;
00728   ssize_t result = 0;
00729 
00730   // Winsock 2 has WSASend and can do this directly, but Winsock 1
00731   // needs to do the sends one-by-one.
00732 # if (ACE_HAS_WINSOCK2 != 0)
00733   result = ::WSASend ((SOCKET) handle,
00734                       (WSABUF *) buffers,
00735                       n,
00736                       &bytes_sent,
00737                       0,
00738                       0,
00739                       0);
00740   if (result == SOCKET_ERROR)
00741     {
00742       ACE_OS::set_errno_to_wsa_last_error ();
00743       return -1;
00744     }
00745 # else
00746   for (int i = 0; i < n; ++i)
00747     {
00748       result = ::send ((SOCKET) handle,
00749                        buffers[i].iov_base,
00750                        buffers[i].iov_len,
00751                        0);
00752 
00753       if (result == SOCKET_ERROR)
00754         {
00755           // There is a subtle difference in behaviour depending on
00756           // whether or not any data was sent.  If no data was sent,
00757           // then always return -1.  Otherwise return bytes_sent.
00758           // This gives the caller an opportunity to keep track of
00759           // bytes that have already been sent.
00760           if (bytes_sent > 0)
00761             break;
00762           else
00763             {
00764               ACE_OS::set_errno_to_wsa_last_error ();
00765               return -1;
00766             }
00767         }
00768       else
00769         {
00770           // Gets ignored on error anyway
00771           bytes_sent += result;
00772 
00773           // If the transfer isn't complete just drop out of the loop.
00774           if (result < (int)buffers[i].iov_len)
00775             break;
00776         }
00777     }
00778 # endif /* ACE_HAS_WINSOCK2 != 0 */
00779 
00780   return (ssize_t) bytes_sent;
00781 
00782 #elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX)
00783 
00784   // Platform limits the maximum socket message size.  Pare down the
00785   // iovec, if necessary, to obey the limit.
00786   iovec local_iov[ACE_IOV_MAX];
00787   long total = 0;
00788   long new_total = 0;
00789   for (int i = 0; i < n; i++)
00790     {
00791       local_iov[i].iov_base = buffers[i].iov_base;
00792       local_iov[i].iov_len  = buffers[i].iov_len;
00793 
00794       new_total = total + buffers[i].iov_len;
00795       if ( new_total >= SSIZE_MAX )
00796         {
00797           local_iov[i].iov_len = SSIZE_MAX - total;
00798           n = i+1;
00799           break;
00800         }
00801       total = new_total;
00802     }
00803   return ACE_OS::writev (handle, local_iov, n);
00804 
00805 #else
00806   return ACE_OS::writev (handle, buffers, n);
00807 #endif /* ACE_HAS_WINSOCK2 */
00808 }

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(), flock_adjust_params(), 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_INLINE 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 398 of file OS_NS_stdlib.inl.

References ACE_EXIT_HOOK, and exit_hook_.

Referenced by ACE_OS_Object_Manager::init().

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

int ACE_OS::set_scheduling_params const ACE_Sched_Params ,
ACE_id_t  id = ACE_SELF
 

Friendly interface to (2).

Definition at line 3717 of file OS_NS_Thread.cpp.

References ACE_id_t, 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(), and scheduling_class().

Referenced by sched_params().

03719 {
03720 #if defined (ACE_HAS_PRIOCNTL)
03721   // Set priority class, priority, and quantum of this LWP or process as
03722   // specified in sched_params.
03723 
03724   // Get the priority class ID.
03725   ACE_id_t class_id;
03726   if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER  ?
03727                                   "TS"  :
03728                                   "RT", class_id) == -1)
03729     {
03730       return -1;
03731     }
03732 
03733   pcparms_t pcparms;
03734   // The following is just to avoid Purify warnings about unitialized
03735   // memory reads.
03736   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03737 
03738   pcparms.pc_cid = class_id;
03739 
03740   if (sched_params.policy () == ACE_SCHED_OTHER  &&
03741       sched_params.quantum () == ACE_Time_Value::zero)
03742       // SunOS doesn't support non-zero quantums in time-sharing class:  use
03743       // real-time class instead.
03744     {
03745       tsparms_t tsparms;
03746       // The following is just to avoid Purify warnings about unitialized
03747       // memory reads.
03748       ACE_OS::memset (&tsparms, 0, sizeof tsparms);
03749 
03750       // Don't change ts_uprilim (user priority limit)
03751       tsparms.ts_uprilim = TS_NOCHANGE;
03752       tsparms.ts_upri = sched_params.priority ();
03753 
03754       // Package up the TS class ID and parameters for the
03755       // priority_control () call.
03756       ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms);
03757     }
03758   else if (sched_params.policy () == ACE_SCHED_FIFO  ||
03759            (sched_params.policy () == ACE_SCHED_RR &&
03760             sched_params.quantum () != ACE_Time_Value::zero))
03761            // must have non-zero quantum for RR, to make it meaningful
03762            // A zero quantum with FIFO has special significance:  it actually
03763            // means infinite time quantum, i.e., run-to-completion.
03764     {
03765       rtparms_t rtparms;
03766       // The following is just to avoid Purify warnings about unitialized
03767       // memory reads.
03768       ACE_OS::memset (&rtparms, 0, sizeof rtparms);
03769 
03770       rtparms.rt_pri = sched_params.priority ();
03771 
03772       if (sched_params.quantum () == ACE_Time_Value::zero)
03773         {
03774           // rtparms.rt_tqsecs is ignored with RT_TQINF
03775           rtparms.rt_tqnsecs = RT_TQINF;
03776         }
03777       else
03778         {
03779           rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec ();
03780           rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000;
03781         }
03782 
03783       // Package up the RT class ID and parameters for the
03784       // priority_control () call.
03785       ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms);
03786     }
03787   else
03788     {
03789       errno = EINVAL;
03790       return -1;
03791     }
03792 
03793   if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD
03794                                             ? ACE_SCOPE_PROCESS
03795                                             : sched_params.scope ()),
03796                                 id,
03797                                 PC_SETPARMS,
03798                                 (char *) &pcparms) < 0)
03799     {
03800       return ACE_OS::last_error ();
03801     }
03802 
03803   return 0;
03804 #else  /* ! ACE_HAS_PRIOCNTL */
03805   ACE_UNUSED_ARG (sched_params);
03806   ACE_UNUSED_ARG (id);
03807   ACE_NOTSUP_RETURN (-1);
03808 #endif /* ! ACE_HAS_PRIOCNTL */
03809 }

ACE_NAMESPACE_INLINE_FUNCTION void set_win32_resource_module HINSTANCE   ) 
 

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

Referenced by DllMain().

ACE_INLINE int ACE_OS::setegid gid_t   ) 
 

Definition at line 803 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gid_t, 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::seteuid uid_t   ) 
 

Definition at line 877 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, seteuid(), and uid_t.

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::setgid gid_t   ) 
 

Definition at line 791 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gid_t, 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::setpgid pid_t  pid,
pid_t  pgid
 

Definition at line 815 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, pid_t, 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 void ACE_OS::setpwent void   ) 
 

Definition at line 113 of file OS_NS_pwd.inl.

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

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, gid_t, 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, setreuid(), and uid_t.

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 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_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::setsockopt ACE_HANDLE  handle,
int  level,
int  optname,
const char *  optval,
int  optlen
 

Manipulate the options associated with a socket.

Definition at line 811 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().

00816 {
00817   ACE_OS_TRACE ("ACE_OS::setsockopt");
00818 #if defined (ACE_LACKS_SETSOCKOPT)
00819   ACE_UNUSED_ARG (handle);
00820   ACE_UNUSED_ARG (level);
00821   ACE_UNUSED_ARG (optname);
00822   ACE_UNUSED_ARG (optval);
00823   ACE_UNUSED_ARG (optlen);
00824   ACE_NOTSUP_RETURN (-1);
00825 #else
00826 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT)
00827   // To work around an inconsistency with Microsofts implementation of
00828   // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock
00829   // always behaves as if SO_REUSEADDR=1. Some implementations have
00830   // the same behaviour as Winsock, but use a new name for
00831   // it. SO_REUSEPORT.  If you want the normal behaviour for
00832   // SO_REUSEADDR=0, then NT 4 sp4 and later supports
00833   // SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform
00834   // SDK so it was decided to ignore the option for now. (Especially
00835   // since Windows always sets SO_REUSEADDR=1, which we can mimic by doing
00836   // nothing.)
00837   if (level == SOL_SOCKET) {
00838     if (optname == SO_REUSEADDR) {
00839       return 0; // Not supported by Winsock
00840     }
00841     if (optname == SO_REUSEPORT) {
00842       optname = SO_REUSEADDR;
00843     }
00844   }
00845 #endif /*ACE_HAS_WINSOCK2*/
00846 
00847   int result;
00848   ACE_SOCKCALL (::setsockopt ((ACE_SOCKET) handle,
00849                               level,
00850                               optname,
00851                               (ACE_SOCKOPT_TYPE1) optval,
00852                               optlen),
00853                 int,
00854                 -1,
00855                 result);
00856 #if defined (WSAEOPNOTSUPP)
00857   if (result == -1 && errno == WSAEOPNOTSUPP)
00858 #else
00859   if (result == -1)
00860 #endif /* WSAEOPNOTSUPP */
00861     errno = ENOTSUP;
00862   return result;
00863 #endif
00864 }

ACE_INLINE int ACE_OS::setuid uid_t   ) 
 

Definition at line 865 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, setuid(), and uid_t.

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 ACE_HANDLE ACE_OS::shm_open const ACE_TCHAR filename,
int  mode,
mode_t  perms = 0,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 235 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, MAXPATHLEN, mode_t, open(), shm_open(), and sprintf().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::open(), sema_init(), and shm_open().

00239 {
00240   ACE_OS_TRACE ("ACE_OS::shm_open");
00241 #if defined (ACE_HAS_SHM_OPEN)
00242   ACE_UNUSED_ARG (sa);
00243 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x650)
00244   // With VxWorks the file should just start with / and no other
00245   // slashes, so replace all other / by _
00246   ACE_TCHAR buf [MAXPATHLEN + 1];
00247   ACE_OS::sprintf (buf,
00248                    ACE_TEXT ("%s"),
00249                    filename);
00250   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00251     {
00252       if (buf[i] == '/')
00253         {
00254           buf[i] = '_';
00255         }
00256     }
00257   filename = buf;
00258 #endif
00259   ACE_OSCALL_RETURN (::shm_open (ACE_TEXT_ALWAYS_CHAR(filename), mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00260 #elif defined (ACE_OPENVMS)
00261   ACE_OSCALL_RETURN (::open (filename, mode, perms, ACE_TEXT("shr=get,put,upd")), ACE_HANDLE, ACE_INVALID_HANDLE);
00262 #else  /* ! ACE_HAS_SHM_OPEN */
00263   // Just use ::open.
00264   return ACE_OS::open (filename, mode, perms, sa);
00265 #endif /* ACE_HAS_SHM_OPEN */
00266 }

ACE_INLINE int ACE_OS::shm_unlink const ACE_TCHAR path  ) 
 

Definition at line 269 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TCHAR, 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().

00270 {
00271   ACE_OS_TRACE ("ACE_OS::shm_unlink");
00272 #if defined (ACE_HAS_SHM_OPEN)
00273 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x650)
00274   // With VxWorks the file should just start with / and no other
00275   // slashes, so replace all other / by _
00276   ACE_TCHAR buf [MAXPATHLEN + 1];
00277   ACE_OS::sprintf (buf,
00278                    ACE_TEXT ("%s"),
00279                    path);
00280   for (size_t i = 1; i < MAXPATHLEN + 1; i++)
00281     {
00282       if (buf[i] == '/')
00283         {
00284           buf[i] = '_';
00285         }
00286     }
00287   path = buf;
00288 #endif
00289   ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1);
00290 #else  /* ! ACE_HAS_SHM_OPEN */
00291   // Just use ::unlink.
00292   return ACE_OS::unlink (path);
00293 #endif /* ACE_HAS_SHM_OPEN */
00294 }

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_INLINE int ACE_OS::shutdown ACE_HANDLE  handle,
int  how
 

BSD-style (no QoS).

Definition at line 867 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().

00868 {
00869   ACE_OS_TRACE ("ACE_OS::shutdown");
00870 #if defined (ACE_LACKS_SHUTDOWN)
00871   ACE_UNUSED_ARG (handle);
00872   ACE_UNUSED_ARG (how);
00873   ACE_NOTSUP_RETURN (-1);
00874 #else
00875   ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1);
00876 #endif /* ACE_LACKS_SHUTDOWN */
00877 }

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 sigaction().

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

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, ACE_OS_TRACE, and sigaddset().

Referenced by ACE_Sig_Set::sig_add(), and sigaddset().

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, and sigdelset().

Referenced by ACE_Sig_Set::sig_del(), and sigdelset().

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.

References sigemptyset().

Referenced by ACE_Sig_Action::ACE_Sig_Action(), ACE_Sig_Set::ACE_Sig_Set(), ACE_Sig_Set::empty_set(), sigemptyset(), sigsuspend(), and ACE_Sig_Set::~ACE_Sig_Set().

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.

References sigfillset().

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

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, and sigismember().

Referenced by ACE_Sig_Set::is_member(), and sigismember().

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, and ACE_SignalHandler.

Referenced by ACE::daemonize().

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, and sigprocmask().

Referenced by ACE_Sig_Guard::ACE_Sig_Guard(), sigprocmask(), thr_sigsetmask(), 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, sigemptyset(), and sigsuspend().

Referenced by sigsuspend().

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_INLINE int ACE_OS::sigtimedwait const sigset_t *  set,
siginfo_t info,
const ACE_Time_Value timeout
 

Definition at line 2505 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, sigtimedwait(), and timespec_t.

Referenced by sigtimedwait().

02508 {
02509   ACE_OS_TRACE ("ACE_OS::sigtimedwait");
02510 #if defined (ACE_HAS_SIGTIMEDWAIT)
02511   timespec_t ts;
02512   timespec_t *tsp;
02513 
02514   if (timeout != 0)
02515     {
02516       ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
02517       tsp = &ts;
02518     }
02519   else
02520     tsp = 0;
02521 
02522   ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp),
02523                      int, -1);
02524 #else
02525     ACE_UNUSED_ARG (sset);
02526     ACE_UNUSED_ARG (info);
02527     ACE_UNUSED_ARG (timeout);
02528     ACE_NOTSUP_RETURN (-1);
02529 #endif /* ACE_HAS_SIGTIMEDWAIT */
02530 }

ACE_INLINE int ACE_OS::sigwait sigset_t *  set,
int *  sig = 0
 

Definition at line 2533 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

02534 {
02535   ACE_OS_TRACE ("ACE_OS::sigwait");
02536   int local_sig;
02537   if (sig == 0)
02538     sig = &local_sig;
02539 #if defined (ACE_HAS_THREADS)
02540 # if (defined (__FreeBSD__) && (__FreeBSD__ < 3))
02541     ACE_UNUSED_ARG (sset);
02542     ACE_NOTSUP_RETURN (-1);
02543 # elif defined (ACE_HAS_STHREADS)
02544    # if (_POSIX_C_SOURCE - 0 >= 199506L) || defined (_POSIX_PTHREAD_SEMANTICS)
02545      errno = ::sigwait (sset, sig);
02546      return errno == 0  ?  *sig  :  -1;
02547    #else
02548      *sig = ::sigwait (sset);
02549      return *sig;
02550    #endif /* _POSIX_C_SOURCE - 0 >= 199506L || _POSIX_PTHREAD_SEMANTICS */
02551 # elif defined (ACE_HAS_PTHREADS)
02552   // LynxOS and Digital UNIX have their own hoops to jump through.
02553 #   if defined (__Lynx__)
02554     // Second arg is a void **, which we don't need (the selected
02555     // signal number is returned).
02556     *sig = ::sigwait (sset, 0);
02557     return *sig;
02558 #   elif defined (DIGITAL_UNIX)  &&  defined (__DECCXX_VER)
02559       // DEC cxx (but not g++) needs this direct call to its internal
02560       // sigwait ().  This allows us to #undef sigwait, so that we can
02561       // have ACE_OS::sigwait.  cxx gets confused by ACE_OS::sigwait
02562       // if sigwait is _not_ #undef'ed.
02563       errno = ::_Psigwait (sset, sig);
02564       return errno == 0  ?  *sig  :  -1;
02565 #   else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02566 #     if (defined (ACE_HAS_PTHREADS_DRAFT4) || (defined (ACE_HAS_PTHREADS_DRAFT6))) || (defined (_UNICOS) && _UNICOS == 9)
02567         *sig = ::sigwait (sset);
02568         return *sig;
02569 #     elif defined (CYGWIN32)
02570         // Cygwin has sigwait definition, but it is not implemented
02571         ACE_UNUSED_ARG (sset);
02572         ACE_NOTSUP_RETURN (-1);
02573 #     elif defined (ACE_TANDEM_T1248_PTHREADS)
02574         errno = ::spt_sigwait (sset, sig);
02575         return errno == 0  ?  *sig  :  -1;
02576 #     else   /* this is draft 7 or std */
02577         errno = ::sigwait (sset, sig);
02578         return errno == 0  ?  *sig  :  -1;
02579 #     endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02580 #   endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02581 # elif defined (ACE_HAS_WTHREADS)
02582     ACE_UNUSED_ARG (sset);
02583     ACE_NOTSUP_RETURN (-1);
02584 # elif defined (ACE_VXWORKS)
02585     // Second arg is a struct siginfo *, which we don't need (the
02586     // selected signal number is returned).  Third arg is timeout:  0
02587     // means forever.
02588     *sig = ::sigtimedwait (sset, 0, 0);
02589     return *sig;
02590 # endif /* __FreeBSD__ */
02591 #else
02592     ACE_UNUSED_ARG (sset);
02593     ACE_UNUSED_ARG (sig);
02594     ACE_NOTSUP_RETURN (-1);
02595 #endif /* ACE_HAS_THREADS */
02596 }

ACE_INLINE int ACE_OS::sigwaitinfo const sigset_t *  set,
siginfo_t info
 

Definition at line 2599 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sigwaitinfo().

Referenced by sigwaitinfo().

02601 {
02602   ACE_OS_TRACE ("ACE_OS::sigwaitinfo");
02603   // If this platform has sigtimedwait, it should have sigwaitinfo as well.
02604   // If this isn't true somewhere, let me know and I'll fix this.
02605   // -Steve Huston <shuston@riverace.com>.
02606 #if defined (ACE_HAS_SIGTIMEDWAIT)
02607   ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1);
02608 #else
02609   ACE_UNUSED_ARG (sset);
02610   ACE_UNUSED_ARG (info);
02611   ACE_NOTSUP_RETURN (-1);
02612 #endif /* ACE_HAS_SIGTIMEDWAIT */
02613 }

ACE_INLINE int ACE_OS::sleep const ACE_Time_Value tv  ) 
 

Definition at line 907 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, ACE_Time_Value::msec(), nanosleep(), and timespec_t.

00908 {
00909   ACE_OS_TRACE ("ACE_OS::sleep");
00910 #if defined (ACE_WIN32)
00911   ::Sleep (tv.msec ());
00912   return 0;
00913 #elif defined (ACE_HAS_CLOCK_GETTIME)
00914   timespec_t rqtp = tv;
00915   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00916 #else
00917 # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00918   // Copy the timeval, because this platform doesn't declare the timeval
00919   // as a pointer to const.
00920   timeval tv_copy = tv;
00921 #  if defined(ACE_TANDEM_T1248_PTHREADS)
00922      ACE_OSCALL_RETURN (::spt_select (0, 0, 0, 0, &tv_copy), int, -1);
00923 #  else
00924      ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1);
00925 #  endif
00926 # else  /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */
00927   const timeval *tvp = tv;
00928   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1);
00929 # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00930 #endif /* ACE_WIN32 */
00931 }

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.

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   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00901 #else
00902   ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
00903 #endif /* ACE_WIN32 */
00904 }

int ACE_OS::snprintf wchar_t *  buf,
size_t  maxlen,
const wchar_t *  format,
... 
 

Definition at line 326 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN.

00327 {
00328   // ACE_OS_TRACE ("ACE_OS::snprintf");
00329 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
00330      (defined (sun) && !defined (_XPG4) || defined(_XPG5)) || \
00331      defined (ACE_WIN32) || defined (ACE_HAS_VSWPRINTF)
00332   int result;
00333   va_list ap;
00334   va_start (ap, format);
00335 #  if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00336   // _vsnwprintf_s() doesn't report the length needed when it truncates. This
00337   // info is needed for the API contract return value, so don't use this.
00338   // There's adequate protection via the maxlen.
00339   result = _vsnwprintf_s (buf, maxlen, _TRUNCATE, format, ap);
00340 #  elif defined (ACE_WIN32)
00341   // Microsoft's vswprintf() doesn't have the maxlen argument that
00342   // XPG4/UNIX98 define. They do, however, recommend use of _vsnwprintf()
00343   // as a substitute, which does have the same signature as the UNIX98 one.
00344   ACE_OSCALL (::_vsnwprintf (buf, maxlen, format, ap), int, -1, result);
00345   // Win32 doesn't regard a full buffer with no 0-terminate as an overrun.
00346   if (result == static_cast <int> (maxlen))
00347     result = -1;
00348 
00349   // Win32 doesn't 0-terminate the string if it overruns maxlen.
00350   if (result == -1)
00351     buf[maxlen-1] = '\0';
00352 #  else
00353   ACE_OSCALL (::vswprintf (buf, maxlen, format, ap), int, -1, result);
00354 #  endif /* ACE_WIN32 */
00355   va_end (ap);
00356   // In out-of-range conditions, C99 defines vsnprintf to return the number
00357   // of characters that would have been written if enough space was available.
00358   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
00359   // -1. This method follows the C99 standard, but needs to guess at the
00360   // value; uses maxlen + 1.
00361   if (result == -1)
00362     result = static_cast <int> (maxlen + 1);
00363   return result;
00364 
00365 # else
00366   ACE_UNUSED_ARG (buf);
00367   ACE_UNUSED_ARG (maxlen);
00368   ACE_UNUSED_ARG (format);
00369   ACE_NOTSUP_RETURN (-1);
00370 # endif /* _XOPEN_SOURCE ...  */
00371 }

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

Definition at line 312 of file OS_NS_stdio.cpp.

References vsnprintf().

Referenced by ACE_Log_Msg::log().

00313 {
00314   // ACE_OS_TRACE ("ACE_OS::snprintf");
00315   int result;
00316   va_list ap;
00317   va_start (ap, format);
00318   result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
00319   va_end (ap);
00320   return result;
00321 }

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 then the BSD-style is called.

Definition at line 900 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCK_GROUP, ACE_SOCKCALL_RETURN, and socket().

00906 {
00907   ACE_OS_TRACE ("ACE_OS::socket");
00908 
00909 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00910   ACE_SOCKCALL_RETURN (::WSASocket (domain,
00911                                     type,
00912                                     proto,
00913                                     protocolinfo,
00914                                     g,
00915                                     flags),
00916                        ACE_HANDLE,
00917                        ACE_INVALID_HANDLE);
00918 #else
00919   ACE_UNUSED_ARG (protocolinfo);
00920   ACE_UNUSED_ARG (g);
00921   ACE_UNUSED_ARG (flags);
00922 
00923   return ACE_OS::socket (domain,
00924                          type,
00925                          proto);
00926 #endif /* ACE_HAS_WINSOCK2 */
00927 }

ACE_INLINE ACE_HANDLE ACE_OS::socket int  protocol_family,
int  type,
int  proto
 

Create a BSD-style socket (no QoS).

Definition at line 880 of file OS_NS_sys_socket.inl.

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

Referenced by ACE::get_bcast_addr(), ACE::get_handle(), getmacaddress(), ioctl(), ip_check(), join_leaf(), ACE_SPIPE_Stream::recv_handle(), and socket().

00883 {
00884   ACE_OS_TRACE ("ACE_OS::socket");
00885 #if defined (ACE_LACKS_SOCKET)
00886   ACE_UNUSED_ARG (domain);
00887   ACE_UNUSED_ARG (type);
00888   ACE_UNUSED_ARG (proto);
00889   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00890 #else
00891   ACE_SOCKCALL_RETURN (::socket (domain,
00892                                  type,
00893                                  proto),
00894                        ACE_HANDLE,
00895                        ACE_INVALID_HANDLE);
00896 #endif /* ACE_LACKS_SOCKET */
00897 }

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_TCHAR, 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 }

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_TCHAR, 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_INLINE int ACE_OS::socketpair int  domain,
int  type,
int  protocol,
ACE_HANDLE  sv[2]
 

BSD-style (no QoS).

Definition at line 930 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and socketpair().

Referenced by ACE_Pipe::open(), and socketpair().

00932 {
00933   ACE_OS_TRACE ("ACE_OS::socketpair");
00934 #if defined (ACE_LACKS_SOCKETPAIR)
00935   ACE_UNUSED_ARG (domain);
00936   ACE_UNUSED_ARG (type);
00937   ACE_UNUSED_ARG (protocol);
00938   ACE_UNUSED_ARG (sv);
00939 
00940   ACE_NOTSUP_RETURN (-1);
00941 #else
00942   ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv),
00943                      int, -1);
00944 #endif /* ACE_LACKS_SOCKETPAIR */
00945 }

int ACE_OS::sprintf wchar_t *  buf,
const wchar_t *  format,
... 
 

Definition at line 389 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00390 {
00391   ACE_OS_TRACE ("ACE_OS::sprintf");
00392 
00393 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
00394      (defined (sun) && !defined (_XPG4) || defined(_XPG5)) || \
00395       defined (ACE_HAS_DINKUM_STL) || defined (__DMC__) || \
00396       defined (ACE_HAS_VSWPRINTF) || \
00397      (defined (ACE_WIN32_VC8) && !defined (ACE_HAS_WINCE) && \
00398       _MSC_FULL_VER > 140050000)
00399 
00400   // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a
00401   // maxlen argument. Since this method doesn't supply one, pass in
00402   // a length that works (ULONG_MAX doesn't on all platform since some check
00403   // to see if the operation will remain in bounds). If this isn't ok, use
00404   // ACE_OS::snprintf().
00405   int result;
00406   va_list ap;
00407   va_start (ap, format);
00408   ACE_OSCALL (ACE_STD_NAMESPACE::vswprintf (buf, 4096, format, ap), int, -1, result);
00409   va_end (ap);
00410   return result;
00411 
00412 # elif defined (ACE_WIN32)
00413   // Pre-VC8 Windows has vswprintf, but the signature is from the older ISO C
00414   // standard. Also see ACE_OS::snprintf() for more info on this.
00415 
00416   int result;
00417   va_list ap;
00418   va_start (ap, format);
00419   ACE_OSCALL (::vswprintf (buf, format, ap), int, -1, result);
00420   va_end (ap);
00421   return result;
00422 
00423 # else
00424 
00425   ACE_UNUSED_ARG (buf);
00426   ACE_UNUSED_ARG (format);
00427   ACE_NOTSUP_RETURN (-1);
00428 
00429 # endif /* XPG5 || ACE_HAS_DINKUM_STL */
00430 }

int ACE_OS::sprintf char *  buf,
const char *  format,
... 
 

Definition at line 375 of file OS_NS_stdio.cpp.

References vsprintf().

Referenced by ACE_MEM_Acceptor::accept(), 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::generateUUID(), ACE_INET_Addr::get_host_addr(), ACE::get_ip_interfaces(), get_ip_interfaces_win32(), 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().

00376 {
00377   // ACE_OS_TRACE ("ACE_OS::sprintf");
00378 
00379   int result;
00380   va_list ap;
00381   va_start (ap, format);
00382   ACE_OSCALL (::vsprintf (buf, format, ap), int, -1, result);
00383   va_end (ap);
00384   return result;
00385 }

ACE_INLINE void ACE_OS::srand u_int  seed  ) 
 

Definition at line 406 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE.

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

ACE_INLINE int ACE_OS::stat const wchar_t *  file,
ACE_stat
 

Definition at line 257 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_Time_Value, ACE_WSTAT_FUNC_NAME, ACE_Wide_To_Ascii::char_rep(), set_errno_to_last_error(), and stat().

00258   {
00259     ACE_OS_TRACE ("ACE_OS::stat");
00260 #if defined (ACE_HAS_WINCE)
00261     WIN32_FIND_DATAW fdata;
00262 
00263     HANDLE fhandle;
00264 
00265     fhandle = ::FindFirstFileW (file, &fdata);
00266     if (fhandle == INVALID_HANDLE_VALUE)
00267       {
00268         ACE_OS::set_errno_to_last_error ();
00269         return -1;
00270       }
00271     else if (fdata.nFileSizeHigh != 0)
00272       {
00273         errno = EINVAL;
00274         return -1;
00275       }
00276     else
00277       {
00278         stp->st_mode = static_cast<unsigned short>(fdata.dwFileAttributes);
00279         stp->st_size = fdata.nFileSizeLow;
00280         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime);
00281         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime);
00282       }
00283     return 0;
00284 #elif defined (__BORLANDC__) \
00285       || (defined (_MSC_VER) && _MSC_VER >= 1300) \
00286       || defined (__MINGW32__)
00287     ACE_OSCALL_RETURN (ACE_WSTAT_FUNC_NAME (file, stp), int, -1);
00288 #else /* ACE_HAS_WINCE */
00289     ACE_Wide_To_Ascii nfile (file);
00290     return ACE_OS::stat (nfile.char_rep (), stp);
00291 #endif /* ACE_HAS_WINCE */
00292   }

ACE_INLINE int ACE_OS::stat const char *  file,
ACE_stat
 

Definition at line 217 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_STAT_FUNC_NAME, ACE_TEXT_CHAR_TO_TCHAR, ACE_TEXT_WIN32_FIND_DATA, ACE_Time_Value, set_errno_to_last_error(), and stat().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), lstat(), ACE_Service_Gestalt::process_file(), ACE_Filecache_Object::release(), sema_init(), stat(), and ACE_Filecache_Object::update().

00218   {
00219     ACE_OS_TRACE ("ACE_OS::stat");
00220 #if defined (ACE_HAS_NONCONST_STAT)
00221     ACE_OSCALL_RETURN (::stat (const_cast <char *> (file), stp), int, -1);
00222 #elif defined (ACE_HAS_WINCE)
00223     ACE_TEXT_WIN32_FIND_DATA fdata;
00224 
00225     HANDLE fhandle;
00226 
00227     fhandle = ::FindFirstFile (ACE_TEXT_CHAR_TO_TCHAR (file), &fdata);
00228     if (fhandle == INVALID_HANDLE_VALUE)
00229       {
00230         ACE_OS::set_errno_to_last_error ();
00231         return -1;
00232       }
00233     else if (fdata.nFileSizeHigh != 0)
00234       {
00235         errno = EINVAL;
00236         return -1;
00237       }
00238     else
00239       {
00240         stp->st_mode = static_cast<unsigned short>(fdata.dwFileAttributes);
00241         stp->st_size = fdata.nFileSizeLow;
00242         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime);
00243         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime);
00244       }
00245     return 0;
00246 #elif defined (ACE_HAS_X86_STAT_MACROS)
00247     // Solaris for intel uses an macro for stat(), this macro is a
00248     // wrapper for _xstat().
00249     ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1);
00250 #else
00251     ACE_OSCALL_RETURN (ACE_STAT_FUNC_NAME (file, stp), int, -1);
00252 #endif /* ACE_HAS_NONCONST_STAT */
00253   }

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_NAMESPACE_INLINE_FUNCTION int strcasecmp const wchar_t *  s,
const wchar_t *  t
 

Compares two strings (case insensitive const wchar_t version).

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_emulation().

Referenced by ACE_TTY_IO::control(), ACE::execname(), ACE::ldfind(), ACE_Configuration_ExtId::operator!=(), ACE_Configuration_ExtId::operator==(), and ACE_Name_Options::parse_args().

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_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::strcasecmp_emulation const char *  s,
const char *  t
 

Emulated strcasecmp - Performs a case insensitive comparison of strings.

Definition at line 19 of file OS_NS_strings.cpp.

References ace_tolower().

Referenced by strcasecmp().

00020 {
00021   const char *scan1 = s;
00022   const char *scan2 = t;
00023 
00024   while (*scan1 != 0
00025          && ACE_OS::ace_tolower (*scan1)
00026             == ACE_OS::ace_tolower (*scan2))
00027     {
00028       ++scan1;
00029       ++scan2;
00030     }
00031 
00032   // The following case analysis is necessary so that characters which
00033   // look negative collate low against normal characters but high
00034   // against the end-of-string NUL.
00035 
00036   if (*scan1 == '\0' && *scan2 == '\0')
00037     return 0;
00038   else if (*scan1 == '\0')
00039     return -1;
00040   else if (*scan2 == '\0')
00041     return 1;
00042   else
00043     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
00044 }

ACE_INLINE wchar_t * ACE_OS::strcat wchar_t *  s,
const wchar_t *  t
 

Appends a string to another string (wchar_t version).

Definition at line 115 of file OS_NS_string.inl.

References wcscat_emulation().

00116 {
00117 #  if defined (ACE_LACKS_WCSCAT)
00118   return ACE_OS::wcscat_emulation (s, t);
00119 #  else /* ACE_LACKS_WCSCAT */
00120   return ::wcscat (s, t);
00121 #  endif /* ACE_LACKS_WCSCAT */
00122 }

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.

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(), and uname().

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

ACE_INLINE wchar_t * ACE_OS::strchr wchar_t *  s,
wchar_t  c
 

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

Definition at line 151 of file OS_NS_string.inl.

References strchr().

00152 {
00153   return
00154     const_cast<wchar_t *> (ACE_OS::strchr (const_cast<const wchar_t *> (s),
00155                                            c));
00156 }

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.

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

ACE_INLINE const wchar_t * ACE_OS::strchr const wchar_t *  s,
wchar_t  c
 

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

Definition at line 133 of file OS_NS_string.inl.

References wcschr_emulation().

00134 {
00135 #  if defined (ACE_LACKS_WCSCHR)
00136   return ACE_OS::wcschr_emulation (s, c);
00137 #  else /* ACE_LACKS_WCSCHR */
00138   return ::wcschr (s, c);
00139 #  endif /* ACE_LACKS_WCSCHR */
00140 }

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.

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_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 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_get_module(), 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_Service_Repository::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(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), open(), ACE_DLL_Handle::open(), ACE_Service_Config::open_i(), ACE_DLL::open_i(), ACE_Less_Than< wchar_t * >::operator()(), ACE_Less_Than< const wchar_t * >::operator()(), ACE_Equal_To< wchar_t * >::operator()(), ACE_Equal_To< const wchar_t * >::operator()(), 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(), thr_equal(), 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_INLINE wchar_t * ACE_OS::strcpy wchar_t *  s,
const wchar_t *  t
 

Copies a string (wchar_t version).

Definition at line 183 of file OS_NS_string.inl.

References wcscpy_emulation().

00184 {
00185 #  if defined (ACE_LACKS_WCSCPY)
00186   return ACE_OS::wcscpy_emulation (s, t);
00187 #  else /* ACE_LACKS_WCSCPY */
00188   return ::wcscpy (s, t);
00189 #  endif /* ACE_LACKS_WCSCPY */
00190 }

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.

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_Process_Options::command_line(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), 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(), mktemp(), 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(), realpath(), ACE_Remote_Name_Space::resolve(), ACE_Configuration_Win32Registry::resolve_key(), 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(), strenvdup(), ACE::strnew(), tempnam(), uname(), and ACE_Process_Options::working_directory().

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

ACE_INLINE size_t ACE_OS::strcspn const wchar_t *  s,
const wchar_t *  reject
 

Searches for the first substring without any of the specified characters and returns the size of the substring (wchar_t version).

Definition at line 201 of file OS_NS_string.inl.

References wcscspn_emulation().

00202 {
00203 #  if defined (ACE_LACKS_WCSCSPN)
00204   return ACE_OS::wcscspn_emulation (s, reject);
00205 #  else /* ACE_LACKS_WCSCSPN */
00206   return ::wcscspn (s, reject);
00207 #  endif /* ACE_LACKS_WCSCSPN */
00208 }

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.

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

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

ACE_INLINE wchar_t * ACE_OS::strdup const wchar_t *  s  ) 
 

Returns a malloced duplicated string (wchar_t version).

Definition at line 228 of file OS_NS_string.inl.

00229 {
00230 #  if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
00231   || defined (ACE_HAS_WCSDUMP_EMULATION)
00232   return ACE_OS::strdup_emulation (s);
00233 #  elif defined (ACE_WCSDUP_EQUIVALENT)
00234   return ACE_WCSDUP_EQUIVALENT (s);
00235 #  elif defined (ACE_HAS_NONCONST_WCSDUP)
00236   return ::wcsdup (const_cast<wchar_t*> (s));
00237 #  else
00238   return ::wcsdup (s);
00239 #  endif /* (ACE_LACKS_WCSDUP && !ACE_WCSDUP_EQUIVALENT) || ... */
00240 }

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.

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_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_Name_Options::nameserver_host(), ACE_Name_Options::namespace_dir(), ACE_Name_Binding::operator=(), ACE_Name_Options::process_name(), putenv(), sema_init(), strenvdup(), 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 }

wchar_t * ACE_OS::strecpy wchar_t *  s,
const wchar_t *  t
 

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

Definition at line 86 of file OS_NS_string.cpp.

References ACE_TEXT_WIDE.

00087 {
00088   register wchar_t *dscan = s;
00089   register const wchar_t *sscan = t;
00090 
00091   while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0'))
00092     continue;
00093 
00094   return dscan;
00095 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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_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_TCHAR, 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 }

char * ACE_OS::strerror int  errnum  ) 
 

Finds characters in a buffer (const void version).

Definition at line 99 of file OS_NS_string.cpp.

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

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

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;
00123 
00124 #if defined (ACE_HAS_TR24731_2005_CRT)
00125   errmsg = ret_errortext;
00126   ACE_SECURECRTCALL (strerror_s (ret_errortext, sizeof (ret_errortext), errno),
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_INLINE size_t ACE_OS::strftime char *  s,
size_t  maxsize,
const char *  format,
const struct tm *  timeptr
 

Definition at line 421 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN.

00423 {
00424 #if defined (ACE_LACKS_STRFTIME)
00425   ACE_UNUSED_ARG (s);
00426   ACE_UNUSED_ARG (maxsize);
00427   ACE_UNUSED_ARG (format);
00428   ACE_UNUSED_ARG (timeptr);
00429   ACE_NOTSUP_RETURN (0);
00430 #else
00431   return ACE_STD_NAMESPACE::strftime (s, maxsize, format, timeptr);
00432 #endif /* ACE_LACKS_STRFTIME */
00433 }

int ACE_OS::string_to_argv ACE_TCHAR buf,
int &  argc,
ACE_TCHAR **&  argv,
bool  substitute_env_args = true
 

Definition at line 680 of file OS_NS_unistd.cpp.

References ACE_DEFAULT_ARGV_BUFSIZ, ace_isspace(), ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT, strdup(), and strenvdup().

Referenced by ACE_ARGV_T< CHAR_TYPE >::string_to_argv().

00684 {
00685   // Reset the number of arguments
00686   argc = 0;
00687 
00688   if (buf == 0)
00689     return -1;
00690 
00691   ACE_TCHAR *cp = buf;
00692 
00693   // First pass: count arguments.
00694 
00695   // '#' is the start-comment token..
00696   while (*cp != ACE_TEXT ('\0') && *cp != ACE_TEXT ('#'))
00697     {
00698       // Skip whitespace..
00699       while (ACE_OS::ace_isspace (*cp))
00700         ++cp;
00701 
00702       // Increment count and move to next whitespace..
00703       if (*cp != ACE_TEXT ('\0'))
00704         ++argc;
00705 
00706       while (*cp != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
00707         {
00708           // Grok quotes....
00709           if (*cp == ACE_TEXT ('\'') || *cp == ACE_TEXT ('"'))
00710             {
00711               ACE_TCHAR quote = *cp;
00712 
00713               // Scan past the string..
00714               for (++cp; *cp != ACE_TEXT ('\0')
00715                    && (*cp != quote || cp[-1] == ACE_TEXT ('\\')); ++cp)
00716                 continue;
00717 
00718               // '\0' implies unmatched quote..
00719               if (*cp == ACE_TEXT ('\0'))
00720                 {
00721                   --argc;
00722                   break;
00723                 }
00724               else
00725                 ++cp;
00726             }
00727           else
00728             ++cp;
00729         }
00730     }
00731 
00732   // Second pass: copy arguments.
00733   ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
00734   ACE_TCHAR *argp = arg;
00735 
00736   // Make sure that the buffer we're copying into is always large
00737   // enough.
00738   if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
00739     ACE_NEW_RETURN (argp,
00740                     ACE_TCHAR[cp - buf + 1],
00741                     -1);
00742 
00743   // Make a new argv vector of argc + 1 elements.
00744   ACE_NEW_RETURN (argv,
00745                   ACE_TCHAR *[argc + 1],
00746                   -1);
00747 
00748   ACE_TCHAR *ptr = buf;
00749 
00750   for (int i = 0; i < argc; ++i)
00751     {
00752       // Skip whitespace..
00753       while (ACE_OS::ace_isspace (*ptr))
00754         ++ptr;
00755 
00756       // Copy next argument and move to next whitespace..
00757       cp = argp;
00758       while (*ptr != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
00759         if (*ptr == ACE_TEXT ('\'') || *ptr == ACE_TEXT ('"'))
00760           {
00761             ACE_TCHAR quote = *ptr++;
00762 
00763             while (*ptr != ACE_TEXT ('\0')
00764                    && (*ptr != quote || ptr[-1] == ACE_TEXT ('\\')))
00765               {
00766                 if (*ptr == quote && ptr[-1] == ACE_TEXT ('\\')) --cp;
00767                 *cp++ = *ptr++;
00768               }
00769 
00770             if (*ptr == quote)
00771               ++ptr;
00772           }
00773         else
00774           *cp++ = *ptr++;
00775 
00776       *cp = ACE_TEXT ('\0');
00777 
00778 #if !defined (ACE_LACKS_ENV)
00779       // Check for environment variable substitution here.
00780       if (substitute_env_args) {
00781           argv[i] = ACE_OS::strenvdup (argp);
00782 
00783           if (argv[i] == 0)
00784             {
00785               if (argp != arg)
00786                 delete [] argp;
00787               errno = ENOMEM;
00788               return -1;
00789             }
00790       }
00791       else
00792 #endif /* ACE_LACKS_ENV */
00793         {
00794           argv[i] = ACE_OS::strdup (argp);
00795 
00796           if (argv[i] == 0)
00797             {
00798               if (argp != arg)
00799                 delete [] argp;
00800               errno = ENOMEM;
00801               return -1;
00802             }
00803         }
00804     }
00805 
00806   if (argp != arg)
00807     delete [] argp;
00808 
00809   argv[argc] = 0;
00810   return 0;
00811 }

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 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_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_String_Base< CHAR >::find(), 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_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_Process_Options::inherit_environment(), 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_Remote_Name_Space::rebind(), ACE_SString::rep(), ACE_Local_Name_Space<, ACE_LOCK >::resolve_i(), ACE_Log_Record::round_up(), scandir_emulation(), ACE_String_Base< CHAR >::set(), ACE_SPIPE_Addr::set(), ACE_DEV_Addr::set(), ACE_Process_Options::setenv(), ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), ACE_Process::spawn(), ACE_Ini_ImpExp::squish(), strenvdup(), strnstr(), strrchr_emulation(), ACE::strsplit_r(), strtok_r_emulation(), tempnam(), wcsrchr_emulation(), wcsstr_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 int strncasecmp const wchar_t *  s,
const wchar_t *  t,
size_t  len
 

Compares two arrays (case insensitive const wchar_t version).

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_emulation().

Referenced by ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_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 }

int ACE_OS::strncasecmp_emulation const char *  s,
const char *  t,
size_t  len
 

Emulated strncasecmp - Performs a case insensitvie comparison of arrays.

Definition at line 49 of file OS_NS_strings.cpp.

References ace_tolower().

Referenced by strncasecmp().

00052 {
00053   const char *scan1 = s;
00054   const char *scan2 = t;
00055   size_t count = 0;
00056 
00057   while (count++ < len
00058          && *scan1 != 0
00059          && ACE_OS::ace_tolower (*scan1)
00060             == ACE_OS::ace_tolower (*scan2))
00061     {
00062       ++scan1;
00063       ++scan2;
00064     }
00065 
00066   if (count > len)
00067     return 0;
00068 
00069   // The following case analysis is necessary so that characters which
00070   // look negative collate low against normal characters but high
00071   // against the end-of-string NUL.
00072 
00073   if (*scan1 == '\0' && *scan2 == '\0')
00074     return 0;
00075   else if (*scan1 == '\0')
00076     return -1;
00077   else if (*scan2 == '\0')
00078     return 1;
00079   else
00080     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
00081 }

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::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(), 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_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 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 }

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 }

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 ACE_String_Base< CHAR >::find(), and 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_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 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 wcsstr_emulation().

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

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 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(), and strerror().

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

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

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

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 }

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 ACE_String_Base< CHAR >::find(), and 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_INLINE wchar_t * ACE_OS::strpbrk wchar_t *  s1,
const wchar_t *  s2
 

Searches for characters in a string (wchar_t version).

Definition at line 404 of file OS_NS_string.inl.

References strpbrk().

00405 {
00406   return const_cast<wchar_t *> (ACE_OS::strpbrk (
00407                                   const_cast<const wchar_t *> (s), t));
00408 }

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.

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

ACE_INLINE const wchar_t * ACE_OS::strpbrk const wchar_t *  s1,
const wchar_t *  s2
 

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

Definition at line 386 of file OS_NS_string.inl.

References wcspbrk_emulation().

00387 {
00388 #  if defined (ACE_LACKS_WCSPBRK)
00389   return ACE_OS::wcspbrk_emulation (s, t);
00390 #  else /* ACE_LACKS_WCSPBRK */
00391   return ::wcspbrk (s, t);
00392 #  endif /* ACE_LACKS_WCSPBRK */
00393 }

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.

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

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

ACE_INLINE char * ACE_OS::strptime const char *  buf,
const char *  format,
struct tm *  tm
 

Definition at line 436 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN.

00437 {
00438 #if defined (ACE_LACKS_STRPTIME)
00439 #  if defined (ACE_REFUSE_STRPTIME_EMULATION)
00440   ACE_UNUSED_ARG (buf);
00441   ACE_UNUSED_ARG (format);
00442   ACE_UNUSED_ARG (tm);
00443   ACE_NOTSUP_RETURN (0);
00444 #  else
00445   return ACE_OS::strptime_emulation (buf, format, tm);
00446 #  endif /* ACE_REFUSE_STRPTIME_EMULATION */
00447 #else
00448   return ::strptime (buf, format, tm);
00449 #endif /* ACE_LACKS_STRPTIME */
00450 }

ACE_INLINE wchar_t * ACE_OS::strrchr wchar_t *  s,
wchar_t  c
 

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

Definition at line 445 of file OS_NS_string.inl.

References strrchr().

00446 {
00447   return const_cast<wchar_t *> (ACE_OS::strrchr (
00448                      const_cast<const wchar_t *> (s), c));
00449 }

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_emulation().

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 const wchar_t * ACE_OS::strrchr const wchar_t *  s,
wchar_t  c
 

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

Definition at line 423 of file OS_NS_string.inl.

References wcsrchr_emulation().

00424 {
00425 #if defined (ACE_LACKS_WCSRCHR)
00426   return ACE_OS::wcsrchr_emulation (s, c);
00427 #else /* ! ACE_LACKS_WCSRCHR */
00428   return const_cast <const wchar_t *> (::wcsrchr (s, c));
00429 #endif /* ! ACE_LACKS_WCSRCHR */
00430 }

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_emulation().

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(), 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 }

const char * ACE_OS::strrchr_emulation const char *  s,
int  c
 

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

Definition at line 269 of file OS_NS_string.cpp.

References strlen().

00270 {
00271   const char *p = s + ACE_OS::strlen (s);
00272 
00273   while (*p != c)
00274     if (p == s)
00275       return 0;
00276     else
00277       --p;
00278 
00279   return p;
00280 }

char * ACE_OS::strrchr_emulation char *  s,
int  c
 

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

Definition at line 255 of file OS_NS_string.cpp.

References strlen().

Referenced by strrchr().

00256 {
00257   char *p = s + ACE_OS::strlen (s);
00258 
00259   while (*p != c)
00260     if (p == s)
00261       return 0;
00262     else
00263       --p;
00264 
00265   return p;
00266 }

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 }

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_Token_Collection::ACE_Token_Collection(), 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(), getcwd(), 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_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(), thr_create(), 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_INLINE size_t ACE_OS::strspn const wchar_t *  s1,
const wchar_t *  s2
 

Searches for the first substring containing only the specified characters and returns the size of the substring (wchar_t version).

Definition at line 460 of file OS_NS_string.inl.

References wcsspn_emulation().

00461 {
00462 #  if defined (ACE_LACKS_WCSSPN)
00463   return ACE_OS::wcsspn_emulation (s, t);
00464 #  else /* ACE_LACKS_WCSSPN */
00465   return ::wcsspn (s, t);
00466 #  endif /* ACE_LACKS_WCSSPN */
00467 }

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.

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

ACE_INLINE wchar_t * ACE_OS::strstr wchar_t *  s,
const wchar_t *  t
 

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

Definition at line 498 of file OS_NS_string.inl.

References wcsstr_emulation().

00499 {
00500 #  if defined (ACE_LACKS_WCSSTR)
00501   return ACE_OS::wcsstr_emulation (s, t);
00502 #  elif defined (HPUX)
00503   return ::wcswcs (s, t);
00504 #  else /* ACE_LACKS_WCSSTR */
00505   return ::wcsstr (s, t);
00506 #  endif /* ACE_LACKS_WCSSTR */
00507 }

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.

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

ACE_INLINE const wchar_t * ACE_OS::strstr const wchar_t *  s,
const wchar_t *  t
 

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

Definition at line 478 of file OS_NS_string.inl.

References wcsstr_emulation().

00479 {
00480 #  if defined (ACE_LACKS_WCSSTR)
00481   return ACE_OS::wcsstr_emulation (s, t);
00482 #  elif defined (HPUX)
00483   return const_cast <const wchar_t *> (::wcswcs (s, t));
00484 #  else /* ACE_LACKS_WCSSTR */
00485   return const_cast <const wchar_t *> (::wcsstr (s, t));
00486 #  endif /* ACE_LACKS_WCSSTR */
00487 }

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.

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

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

ACE_INLINE double ACE_OS::strtod const wchar_t *  s,
wchar_t **  endptr
 

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

Definition at line 422 of file OS_NS_stdlib.inl.

00423 {
00424   return ACE_WCHAR_STD_NAMESPACE::wcstod (s, endptr);
00425 }

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

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

Definition at line 414 of file OS_NS_stdlib.inl.

Referenced by ACE_Convert().

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

ACE_INLINE wchar_t * ACE_OS::strtok wchar_t *  s,
const wchar_t *  tokens
 

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

Definition at line 518 of file OS_NS_string.inl.

00519 {
00520 #if defined (ACE_HAS_3_PARAM_WCSTOK)
00521   static wchar_t *lasts = 0;
00522   return ::wcstok (s, tokens, &lasts);
00523 #else
00524   return ::wcstok (s, tokens);
00525 #endif /* ACE_HAS_3_PARAM_WCSTOK */
00526 }

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.

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

ACE_INLINE wchar_t * ACE_OS::strtok_r ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  tokens,
ACE_WCHAR_T **  lasts
 

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

Definition at line 543 of file OS_NS_string.inl.

References strtok_r_emulation().

00544 {
00545 #if defined (ACE_HAS_TR24731_2005_CRT)
00546   return wcstok_s (s, tokens, lasts);
00547 #elif defined (ACE_LACKS_WCSTOK)
00548   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00549 #else
00550 #  if defined (ACE_HAS_3_PARAM_WCSTOK)
00551   return ::wcstok (s, tokens, lasts);
00552 #  else /* ACE_HAS_3_PARAM_WCSTOK */
00553   *lasts = ::wcstok (s, tokens);
00554   return *lasts;
00555 #  endif /* ACE_HAS_3_PARAM_WCSTOK */
00556 #endif  /* ACE_LACKS_WCSTOK */
00557 }

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_emulation().

Referenced by ACE_Log_Msg_UNIX_Syslog::log(), ACE_Logging_Strategy::priorities(), 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 }

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

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_INLINE long ACE_OS::strtol const wchar_t *  s,
wchar_t **  ptr,
int  base
 

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

Definition at line 440 of file OS_NS_stdlib.inl.

00441 {
00442   return ACE_WCHAR_STD_NAMESPACE::wcstol (s, ptr, base);
00443 }

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 429 of file OS_NS_stdlib.inl.

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

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

ACE_INLINE unsigned long ACE_OS::strtoul const wchar_t *  s,
wchar_t **  ptr,
int  base
 

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

Definition at line 458 of file OS_NS_stdlib.inl.

00459 {
00460   return ACE_WCHAR_STD_NAMESPACE::wcstoul (s, ptr, base);
00461 }

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 447 of file OS_NS_stdlib.inl.

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

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

ACE_INLINE void ACE_OS::swab const void *  src,
void *  dest,
ssize_t  n
 

Definition at line 934 of file OS_NS_unistd.inl.

References ssize_t.

00937 {
00938 #if defined (ACE_LACKS_SWAB)
00939   const char *from = static_cast<const char*> (src);
00940   char *to = static_cast<char *> (dest);
00941   ssize_t ptr = 0;
00942   for (ptr = 1; ptr < length; ptr += 2)
00943     {
00944       char p = from[ptr];
00945       char q = from[ptr-1];
00946       to[ptr-1] = p;
00947       to[ptr  ] = q;
00948     }
00949   if (ptr == length) /* I.e., if length is odd, */
00950     to[ptr-1] = 0;   /* then pad with a NUL. */
00951 #elif defined (ACE_HAS_NONCONST_SWAB)
00952   const char *tmp = static_cast<const char*> (src);
00953   char *from = const_cast<char *> (tmp);
00954   char *to = static_cast<char *> (dest);
00955   ::swab (from, to, length);
00956 #elif defined (ACE_HAS_CONST_CHAR_SWAB)
00957   const char *from = static_cast<const char*> (src);
00958   char *to = static_cast<char *> (dest);
00959   ::swab (from, to, length);
00960 #else
00961   ::swab (src, dest, length);
00962 #endif /* ACE_LACKS_SWAB */
00963 
00964 }

ACE_INLINE long ACE_OS::sysconf int   ) 
 

Definition at line 967 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysconf().

Referenced by ACE::max_handles(), sysconf(), and thr_min_stack().

00968 {
00969   ACE_OS_TRACE ("ACE_OS::sysconf");
00970 #if defined (ACE_LACKS_SYSCONF)
00971   ACE_UNUSED_ARG (name);
00972   ACE_NOTSUP_RETURN (-1);
00973 #else
00974   ACE_OSCALL_RETURN (::sysconf (name), long, -1);
00975 #endif /* ACE_LACKS_SYSCONF */
00976 }

ACE_INLINE long ACE_OS::sysinfo int  cmd,
char *  buf,
long  count
 

Definition at line 979 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysinfo().

Referenced by sysinfo().

00980 {
00981   ACE_OS_TRACE ("ACE_OS::sysinfo");
00982 #if defined (ACE_HAS_SYSINFO)
00983   ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1);
00984 #else
00985   ACE_UNUSED_ARG (cmd);
00986   ACE_UNUSED_ARG (buf);
00987   ACE_UNUSED_ARG (count);
00988 
00989   ACE_NOTSUP_RETURN (0);
00990 #endif /* ACE_HAS_SYSINFO */
00991 }

ACE_INLINE int ACE_OS::system const ACE_TCHAR s  ) 
 

Definition at line 465 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and system().

Referenced by system().

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

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, and t_accept().

Referenced by ACE_TLI_Acceptor::accept().

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, and t_alloc().

Referenced by ACE_TLI_Connector::connect(), ACE_TLI_Acceptor::open(), and ACE_TLI_Request_Queue::open().

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, ACE_TBIND, and t_bind().

Referenced by ACE_TLI_Connector::connect(), ACE_TLI_Acceptor::open(), and open_new_endpoint().

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, and t_close().

Referenced by ACE_TLI_Acceptor::accept(), ACE_TLI_Stream::close(), ACE_TLI::close(), and ACE_TLI_Request_Queue::remove().

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, and t_connect().

Referenced by ACE_TLI_Connector::connect().

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, and t_free().

Referenced by ACE_TLI_Acceptor::close(), ACE_TLI_Request_Queue::close(), and ACE_TLI_Connector::connect().

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, and t_getinfo().

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, ACE_TBIND, last_error(), and t_getname().

Referenced by ACE_TLI_Connector::complete(), ACE_TLI::get_local_addr(), and ACE_TLI_Stream::get_remote_addr().

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, and t_getstate().

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, and t_listen().

Referenced by ACE_TLI_Acceptor::accept(), and ACE_TLI_Request_Queue::enqueue().

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, and t_look().

Referenced by ACE_TLI_Connector::complete(), and ACE_TLI::look().

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, and t_open().

Referenced by open_new_endpoint().

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, and t_optmgmt().

Referenced by ACE_TLI::get_option(), and ACE_TLI::set_option().

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.

Referenced by ACE::t_rcv(), and ACE::t_rcv_n_i().

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, and t_rcvdis().

Referenced by ACE_TLI::rcvdis().

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, and t_rcvrel().

Referenced by ACE_TLI::rcvrel().

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, and t_rcvudata().

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, and t_rcvuderr().

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.

Referenced by ACE::t_snd(), and ACE::t_snd_n_i().

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, and t_snddis().

Referenced by open_new_endpoint(), and ACE_TLI::snddis().

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, and t_sndrel().

Referenced by ACE_TLI::sndrel().

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, and t_sync().

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, and t_unbind().

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 }

ACE_INLINE long ACE_OS::telldir ACE_DIR  ) 
 

Definition at line 172 of file OS_NS_dirent.inl.

References ACE_DIR, and 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_INLINE wchar_t * ACE_OS::tempnam const wchar_t *  dir,
const wchar_t *  pfx = 0
 

Definition at line 916 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, free(), malloc(), strcpy(), strlen(), and tempnam().

00917 {
00918   ACE_OS_TRACE ("ACE_OS::tempnam");
00919 #if defined (ACE_LACKS_TEMPNAM)
00920   ACE_UNUSED_ARG (dir);
00921   ACE_UNUSED_ARG (pfx);
00922   ACE_NOTSUP_RETURN (0);
00923 #elif defined(ACE_WIN32)
00924 #  if defined (ACE_HAS_NONCONST_TEMPNAM)
00925   ACE_OSCALL_RETURN (::_wtempnam (const_cast <wchar_t*> (dir), const_cast <wchar_t*> (pfx)), wchar_t *, 0);
00926 #  else
00927   ACE_OSCALL_RETURN (::_wtempnam (dir, pfx), wchar_t *, 0);
00928 #  endif /* __BORLANDC__ */
00929 #else /* ACE_LACKS_TEMPNAM */
00930   // No native wide-char support; convert to narrow and call the char* variant.
00931   char *ndir = ACE_Wide_To_Ascii (dir).char_rep ();
00932   char *npfx = ACE_Wide_To_Ascii (pfx).char_rep ();
00933   char *name = ACE_OS::tempnam (ndir, npfx);
00934   // ACE_OS::tempnam returns a pointer to a malloc()-allocated space.
00935   // Convert that string to wide-char and free() the original.
00936   wchar_t *wname = 0;
00937   if (name != 0)
00938     {
00939       size_t namelen = ACE_OS::strlen (name) + 1;
00940       wname = reinterpret_cast<wchar_t *>
00941         (ACE_OS::malloc (namelen * sizeof (wchar_t)));
00942       if (wname != 0)
00943         ACE_OS::strcpy (wname, ACE_Ascii_To_Wide (name).wchar_rep ());
00944       ACE_OS::free (name);
00945     }
00946   return wname;
00947 #endif /* ACE_LACKS_TEMPNAM */
00948 }

ACE_INLINE char * ACE_OS::tempnam const char *  dir = 0,
const char *  pfx = 0
 

Definition at line 900 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by tempnam().

00901 {
00902   ACE_OS_TRACE ("ACE_OS::tempnam");
00903 #if defined (ACE_LACKS_TEMPNAM)
00904   ACE_UNUSED_ARG (dir);
00905   ACE_UNUSED_ARG (pfx);
00906   ACE_NOTSUP_RETURN (0);
00907 #elif defined (ACE_HAS_NONCONST_TEMPNAM)
00908   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast <char *> (dir), const_cast<char *> (pfx)), char *, 0);
00909 #else /* ACE_LACKS_TEMPNAM */
00910   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0);
00911 #endif /* ACE_LACKS_TEMPNAM */
00912 }

ACE_INLINE int ACE_OS::thr_cancel ACE_thread_t  t_id  ) 
 

Definition at line 2616 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::cancel().

02617 {
02618   ACE_OS_TRACE ("ACE_OS::thr_cancel");
02619 #if defined (ACE_HAS_THREADS)
02620 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02621 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02622 #     ifdef pthread_cancel
02623         // If it's a macro we can't say "pthread_cancel"...
02624         ACE_OSCALL_RETURN (pthread_cancel (thr_id), int, -1);
02625 #     else
02626         ACE_OSCALL_RETURN (pthread_cancel (thr_id), int, -1);
02627 #     endif /* pthread_cancel */
02628 #   else
02629   int result;
02630 #     ifdef pthread_cancel
02631         // If it's a macro we can't say "pthread_cancel"...
02632         ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02633                                              result),
02634                            int, -1);
02635 #     else
02636         ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02637                                              result),
02638                            int, -1);
02639 #     endif /* pthread_cancel */
02640 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02641 # elif defined (ACE_VXWORKS)
02642   ACE_hthread_t tid;
02643   ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid);
02644 
02645   if (tid == ERROR)
02646     return -1;
02647   else
02648     ACE_OSCALL_RETURN (::taskDelete (tid), int, -1);
02649 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
02650   ACE_UNUSED_ARG (thr_id);
02651   ACE_NOTSUP_RETURN (-1);
02652 # endif /* ACE_HAS_PTHREADS */
02653 #else
02654   ACE_UNUSED_ARG (thr_id);
02655   ACE_NOTSUP_RETURN (-1);
02656 #endif /* ACE_HAS_THREADS */
02657 }

ACE_INLINE int ACE_OS::thr_cmp ACE_hthread_t  t1,
ACE_hthread_t  t2
 

Definition at line 2660 of file OS_NS_Thread.inl.

References ACE_hthread_t.

Referenced by ACE_Thread_Manager::find_hthread(), ACE_Thread_Manager::hthread_within(), ACE_Thread_Descriptor_Base::operator==(), and ACE_Thread_ID::operator==().

02661 {
02662 #if defined (ACE_HAS_PTHREADS)
02663 # if defined (pthread_equal)
02664   // If it's a macro we can't say "pthread_equal"...
02665   return pthread_equal (t1, t2);
02666 # else
02667   return pthread_equal (t1, t2);
02668 # endif /* pthread_equal */
02669 #else /* For STHREADS, WTHREADS, and VXWORKS ... */
02670   // Hum, Do we need to treat WTHREAD differently?
02671   // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE.
02672   return t1 == t2;
02673 #endif /* ACE_HAS_PTHREADS */
02674 }

ACE_INLINE int ACE_OS::thr_continue ACE_hthread_t  target_thread  ) 
 

Definition at line 2677 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_continue().

Referenced by ACE_Thread::resume(), thr_continue(), and thr_create().

02678 {
02679   ACE_OS_TRACE ("ACE_OS::thr_continue");
02680 #if defined (ACE_HAS_THREADS)
02681 # if defined (ACE_HAS_STHREADS)
02682   int result;
02683   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), result), int, -1);
02684 # elif defined (ACE_HAS_PTHREADS)
02685 #  if defined (ACE_HAS_PTHREAD_CONTINUE)
02686   int result;
02687   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread),
02688                                        result),
02689                      int, -1);
02690 #  elif defined (ACE_HAS_PTHREAD_CONTINUE_NP)
02691   int result;
02692   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue_np (target_thread),
02693                                        result),
02694                      int, -1);
02695 #  elif defined (ACE_HAS_PTHREAD_RESUME_NP)
02696   int result;
02697   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_resume_np (target_thread),
02698                                        result),
02699                      int, -1);
02700 #  else
02701   ACE_UNUSED_ARG (target_thread);
02702   ACE_NOTSUP_RETURN (-1);
02703 #  endif /* ACE_HAS_PTHREAD_CONTINUE */
02704 # elif defined (ACE_HAS_WTHREADS)
02705   DWORD result = ::ResumeThread (target_thread);
02706   if (result == ACE_SYSCALL_FAILED)
02707     ACE_FAIL_RETURN (-1);
02708   else
02709     return 0;
02710 # elif defined (ACE_VXWORKS)
02711   ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1);
02712 # endif /* ACE_HAS_STHREADS */
02713 #else
02714   ACE_UNUSED_ARG (target_thread);
02715   ACE_NOTSUP_RETURN (-1);
02716 #endif /* ACE_HAS_THREADS */
02717 }

int ACE_OS::thr_create ACE_THR_FUNC  func,
void *  args,
long  flags,
ACE_thread_t thr_id,
ACE_hthread_t t_handle = 0,
long  priority = ACE_DEFAULT_THREAD_PRIORITY,
void *  stack = 0,
size_t  stacksize = ACE_DEFAULT_THREAD_STACKSIZE,
ACE_Base_Thread_Adapter thread_adapter = 0
 

Definition at line 3812 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_FAIL_RETURN, ACE_hthread_t, 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, ACE_thread_t, ENOSYS, ENOTSUP, ACE_Base_Thread_Adapter::entry_point(), lwp_setparams(), memset(), ACE_Auto_Basic_Ptr< X >::release(), sched_params(), strsncpy(), thr_continue(), thr_create(), thr_getconcurrency(), thr_self(), thr_setconcurrency(), and thr_setprio().

Referenced by ACE_Thread::spawn(), ACE_Thread::spawn_n(), and thr_create().

03821 {
03822   ACE_OS_TRACE ("ACE_OS::thr_create");
03823 
03824   if (ACE_BIT_DISABLED (flags, THR_DETACHED) &&
03825       ACE_BIT_DISABLED (flags, THR_JOINABLE))
03826     ACE_SET_BITS (flags, THR_JOINABLE);
03827 
03828 #if defined (ACE_NO_THREAD_ADAPTER)
03829 # define  ACE_THREAD_FUNCTION  func
03830 # define  ACE_THREAD_ARGUMENT  args
03831 #else /* ! defined (ACE_NO_THREAD_ADAPTER) */
03832 # define  ACE_THREAD_FUNCTION  thread_args->entry_point ()
03833 # define  ACE_THREAD_ARGUMENT  thread_args
03834 #endif /* ! defined (ACE_NO_THREAD_ADAPTER) */
03835 
03836 
03837   ACE_Base_Thread_Adapter *thread_args = 0;
03838   if (thread_adapter == 0)
03839 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
03840     ACE_NEW_RETURN (thread_args,
03841                     ACE_OS_Thread_Adapter (func, args,
03842                                            (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
03843                                            ACE_OS_Object_Manager::seh_except_selector(),
03844                                            ACE_OS_Object_Manager::seh_except_handler()),
03845                     -1);
03846 #else
03847   ACE_NEW_RETURN (thread_args,
03848                   ACE_OS_Thread_Adapter (func, args,
03849                                          (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME),
03850                   -1);
03851 
03852 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
03853   else
03854     thread_args = thread_adapter;
03855 
03856   auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
03857 
03858   if (thread_adapter == 0)
03859     ACE_AUTO_PTR_RESET (auto_thread_args,
03860                         thread_args,
03861                         ACE_Base_Thread_Adapter);
03862 
03863 #if defined (ACE_HAS_THREADS)
03864 
03865   // *** Set Stack Size
03866 # if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03867   if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03868     stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE;
03869 # endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
03870 
03871 # if !(defined (ACE_VXWORKS) && !defined (ACE_HAS_PTHREADS))
03872   // On VxWorks, using the task API, the OS will provide a task name if
03873   // the user doesn't. So, we don't need to create a tmp_thr.  If the
03874   // caller of this member function is the Thread_Manager, than thr_id
03875   // will be non-zero anyways.
03876   ACE_thread_t tmp_thr;
03877 
03878   if (thr_id == 0)
03879     thr_id = &tmp_thr;
03880 # endif /* !(ACE_VXWORKS && !ACE_HAS_PTHREADS) */
03881 
03882   ACE_hthread_t tmp_handle;
03883   if (thr_handle == 0)
03884     thr_handle = &tmp_handle;
03885 
03886 # if defined (ACE_HAS_PTHREADS)
03887 
03888   int result;
03889 # if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
03890   /* Tests show that VxWorks 6.x pthread lib does not only
03891    * require zeroing of mutex/condition objects to function correctly
03892    * but also of the attribute objects.
03893    */
03894   pthread_attr_t attr = {0};
03895 #   else
03896   pthread_attr_t attr;
03897 #   endif
03898 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03899   if (ACE_ADAPT_RETVAL(::pthread_attr_create (&attr), result) != 0)
03900 #   else /* ACE_HAS_PTHREADS_DRAFT4 */
03901   if (ACE_ADAPT_RETVAL(::pthread_attr_init(&attr), result) != 0)
03902 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03903       return -1;
03904 
03905   if (stacksize != 0)
03906     {
03907       size_t size = stacksize;
03908 
03909 #   if defined (PTHREAD_STACK_MIN)
03910       if (size < static_cast <size_t> (PTHREAD_STACK_MIN))
03911         size = PTHREAD_STACK_MIN;
03912 #   endif /* PTHREAD_STACK_MIN */
03913 
03914 #   if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE)
03915 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
03916       if (::pthread_attr_setstacksize (&attr, size) != 0)
03917 #     else
03918 #       if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
03919         int result;
03920         if (stack != 0)
03921           result = ACE_ADAPT_RETVAL (pthread_attr_setstack (&attr, stack, size), result);
03922         else
03923           result = ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result);
03924         if (result == -1)
03925 #       else
03926         if (ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result) == -1)
03927 #       endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACK */
03928 #     endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
03929           {
03930 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
03931             ::pthread_attr_delete (&attr);
03932 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
03933             ::pthread_attr_destroy (&attr);
03934 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
03935             return -1;
03936           }
03937 #   else
03938       ACE_UNUSED_ARG (size);
03939 #   endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE */
03940     }
03941 
03942   // *** Set Stack Address
03943 #   if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK)
03944 #     if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR)
03945   if (stack != 0)
03946     {
03947       if (ACE_ADAPT_RETVAL(::pthread_attr_setstackaddr (&attr, stack), result) != 0)
03948         {
03949 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
03950           ::pthread_attr_delete (&attr);
03951 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
03952           ::pthread_attr_destroy (&attr);
03953 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
03954           return -1;
03955         }
03956     }
03957 #     else
03958   ACE_UNUSED_ARG (stack);
03959 #     endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR */
03960 #   endif /* ACE_LACKS_PTHREAD_ATTR_SETSTACK */
03961 
03962   // *** Deal with various attributes
03963   if (flags != 0)
03964     {
03965       // *** Set Detach state
03966 #   if !defined (ACE_LACKS_SETDETACH)
03967       if (ACE_BIT_ENABLED (flags, THR_DETACHED)
03968           || ACE_BIT_ENABLED (flags, THR_JOINABLE))
03969         {
03970           int dstate = PTHREAD_CREATE_JOINABLE;
03971 
03972           if (ACE_BIT_ENABLED (flags, THR_DETACHED))
03973             dstate = PTHREAD_CREATE_DETACHED;
03974 
03975 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
03976           if (::pthread_attr_setdetach_np (&attr, dstate) != 0)
03977 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
03978 #       if defined (ACE_HAS_PTHREADS_DRAFT6)
03979             if (::pthread_attr_setdetachstate (&attr, &dstate) != 0)
03980 #       else
03981               if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate),
03982                                    result) != 0)
03983 #       endif /* ACE_HAS_PTHREADS_DRAFT6 */
03984 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
03985                 {
03986 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
03987                   ::pthread_attr_delete (&attr);
03988 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
03989                   ::pthread_attr_destroy (&attr);
03990 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
03991                   return -1;
03992                 }
03993         }
03994 
03995       // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we
03996       // call ::pthread_detach () below.  If THR_DETACHED is not
03997       // enabled, we call ::pthread_detach () in the Thread_Manager,
03998       // after joining with the thread.
03999 #   endif /* ACE_LACKS_SETDETACH */
04000 
04001       // *** Set Policy
04002 #   if !defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
04003       // If we wish to set the priority explicitly, we have to enable
04004       // explicit scheduling, and a policy, too.
04005       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04006         {
04007           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
04008           if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO)
04009               && ACE_BIT_DISABLED (flags, THR_SCHED_RR)
04010               && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT))
04011             ACE_SET_BITS (flags, THR_SCHED_DEFAULT);
04012         }
04013 
04014       if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
04015           || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
04016           || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
04017         {
04018           int spolicy;
04019 
04020 #     if defined (ACE_HAS_ONLY_SCHED_OTHER)
04021           // SunOS, thru version 5.6, only supports SCHED_OTHER.
04022           spolicy = SCHED_OTHER;
04023 #     elif defined (ACE_HAS_ONLY_SCHED_FIFO)
04024           // NonStop OSS standard pthread supports only SCHED_FIFO.
04025           spolicy = SCHED_FIFO;
04026 #     else
04027           // Make sure to enable explicit scheduling, in case we didn't
04028           // enable it above (for non-default priority).
04029           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
04030 
04031           if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
04032             spolicy = SCHED_OTHER;
04033           else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04034             spolicy = SCHED_FIFO;
04035 #       if defined (SCHED_IO)
04036           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
04037             spolicy = SCHED_IO;
04038 #       else
04039           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
04040             {
04041               errno = ENOSYS;
04042               return -1;
04043             }
04044 #       endif /* SCHED_IO */
04045           else
04046             spolicy = SCHED_RR;
04047 
04048 #     endif /* ACE_HAS_ONLY_SCHED_OTHER */
04049 
04050 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04051           result = ::pthread_attr_setsched (&attr, spolicy);
04052 #     elif defined (ACE_HAS_PTHREADS_DRAFT6)
04053           result = ::pthread_attr_setschedpolicy (&attr, spolicy);
04054 #     else  /* draft 7 or std */
04055           (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy),
04056                            result);
04057 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04058           if (result != 0)
04059             {
04060 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04061               ::pthread_attr_delete (&attr);
04062 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04063               ::pthread_attr_destroy (&attr);
04064 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04065               return -1;
04066             }
04067         }
04068 
04069       // *** Set Priority (use reasonable default priorities)
04070 #     if defined(ACE_HAS_PTHREADS_STD)
04071       // If we wish to explicitly set a scheduling policy, we also
04072       // have to specify a priority.  We choose a "middle" priority as
04073       // default.  Maybe this is also necessary on other POSIX'ish
04074       // implementations?
04075       if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
04076            || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
04077            || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
04078           && priority == ACE_DEFAULT_THREAD_PRIORITY)
04079         {
04080           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04081             priority = ACE_THR_PRI_FIFO_DEF;
04082           else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR))
04083             priority = ACE_THR_PRI_RR_DEF;
04084           else // THR_SCHED_DEFAULT
04085             priority = ACE_THR_PRI_OTHER_DEF;
04086         }
04087 #     endif /* ACE_HAS_PTHREADS_STD */
04088       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04089         {
04090           struct sched_param sparam;
04091           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
04092 
04093 #     if defined (ACE_HAS_IRIX62_THREADS)
04094           sparam.sched_priority = ACE_MIN (priority,
04095                                            (long) PTHREAD_MAX_PRIORITY);
04096 #     elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS_STD)
04097           /* For MIT pthreads... */
04098           sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY);
04099 #     elif defined(ACE_HAS_PTHREADS_STD) && !defined (ACE_HAS_STHREADS)
04100           // The following code forces priority into range.
04101           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04102             sparam.sched_priority =
04103               ACE_MIN (ACE_THR_PRI_FIFO_MAX,
04104                        ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
04105           else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
04106             sparam.sched_priority =
04107               ACE_MIN (ACE_THR_PRI_RR_MAX,
04108                        ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
04109           else // Default policy, whether set or not
04110             sparam.sched_priority =
04111               ACE_MIN (ACE_THR_PRI_OTHER_MAX,
04112                        ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
04113 #     elif defined (PRIORITY_MAX)
04114           sparam.sched_priority = ACE_MIN (priority,
04115                                            (long) PRIORITY_MAX);
04116 #     else
04117           sparam.sched_priority = priority;
04118 #     endif /* ACE_HAS_IRIX62_THREADS */
04119 
04120           {
04121 #       if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
04122             // SunOS, through 5.6, POSIX only allows priorities > 0 to
04123             // ::pthread_attr_setschedparam.  If a priority of 0 was
04124             // requested, set the thread priority after creating it, below.
04125             if (priority > 0)
04126 #       endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
04127               {
04128 #       if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
04129                 result = ::pthread_attr_setprio (&attr,
04130                                                  sparam.sched_priority);
04131 #       else /* this is draft 7 or std */
04132                 (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam),
04133                                         result);
04134 #       endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
04135                 if (result != 0)
04136                   {
04137 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
04138                     ::pthread_attr_delete (&attr);
04139 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
04140                     ::pthread_attr_destroy (&attr);
04141 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
04142                     return -1;
04143                   }
04144               }
04145           }
04146         }
04147 
04148       // *** Set scheduling explicit or inherited
04149       if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)
04150           || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED))
04151         {
04152 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04153           int sched = PTHREAD_DEFAULT_SCHED;
04154 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04155           int sched = PTHREAD_EXPLICIT_SCHED;
04156 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04157           if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED))
04158             sched = PTHREAD_INHERIT_SCHED;
04159           if (ACE_ADAPT_RETVAL(::pthread_attr_setinheritsched (&attr, sched), result) != 0)
04160             {
04161 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04162               ::pthread_attr_delete (&attr);
04163 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04164               ::pthread_attr_destroy (&attr);
04165 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04166               return -1;
04167             }
04168         }
04169 #   else /* ACE_LACKS_SETSCHED */
04170       ACE_UNUSED_ARG (priority);
04171 #   endif /* ACE_LACKS_SETSCHED */
04172 
04173       // *** Set Scope
04174 #   if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING)
04175       if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)
04176           || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS))
04177         {
04178 #     if defined (ACE_CONFIG_LINUX_H) || defined (HPUX) || defined (ACE_VXWORKS)
04179           // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS.
04180           // Neither does HPUX (up to HP-UX 11.00, as far as I know).
04181           // Also VxWorks only delivers scope system
04182           int scope = PTHREAD_SCOPE_SYSTEM;
04183 #     else /* ACE_CONFIG_LINUX_H */
04184           int scope = PTHREAD_SCOPE_PROCESS;
04185 #     endif /* ACE_CONFIG_LINUX_H */
04186           if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM))
04187             scope = PTHREAD_SCOPE_SYSTEM;
04188 
04189           if (ACE_ADAPT_RETVAL(::pthread_attr_setscope (&attr, scope), result) != 0)
04190             {
04191 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04192               ::pthread_attr_delete (&attr);
04193 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04194               ::pthread_attr_destroy (&attr);
04195 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04196               return -1;
04197             }
04198         }
04199 #   endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */
04200 
04201 #   ifdef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP
04202       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED))
04203         {
04204            if (ACE_ADAPT_RETVAL(::pthread_attr_setcreatesuspend_np(&attr), result) != 0)
04205             {
04206 
04207 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04208               ::pthread_attr_delete (&attr);
04209 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04210               ::pthread_attr_destroy (&attr);
04211 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04212               return -1;
04213             }
04214         }
04215 #   endif /* !ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP */
04216 
04217 #   if ! defined(ACE_LACKS_THR_CONCURRENCY_FUNCS)
04218       if (ACE_BIT_ENABLED (flags, THR_NEW_LWP))
04219         {
04220           // Increment the number of LWPs by one to emulate the
04221           // SunOS semantics.
04222           int lwps = ACE_OS::thr_getconcurrency ();
04223           if (lwps == -1)
04224             {
04225               if (errno == ENOTSUP)
04226                 // Suppress the ENOTSUP because it's harmless.
04227                 errno = 0;
04228               else
04229                 // This should never happen on SunOS:
04230                 // ::thr_getconcurrency () should always succeed.
04231                 return -1;
04232             }
04233           else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1)
04234             {
04235               if (errno == ENOTSUP)
04236                 {
04237                   // Unlikely: ::thr_getconcurrency () is supported
04238                   // but ::thr_setconcurrency () is not?
04239                 }
04240               else
04241                 return -1;
04242             }
04243         }
04244 #   endif /* ! ACE_LACKS_THR_CONCURRENCY_FUNCS */
04245     }
04246 
04247 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
04248   ACE_OSCALL (::pthread_create (thr_id, attr,
04249                                 thread_args->entry_point (),
04250                                 thread_args),
04251               int, -1, result);
04252 
04253 #     if defined (ACE_LACKS_SETDETACH)
04254   if (ACE_BIT_ENABLED (flags, THR_DETACHED))
04255     {
04256       ::pthread_detach (thr_id);
04257     }
04258 #     endif /* ACE_LACKS_SETDETACH */
04259 
04260   ::pthread_attr_delete (&attr);
04261 
04262 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
04263   ACE_OSCALL (::pthread_create (thr_id, &attr,
04264                                 thread_args->entry_point (),
04265                                 thread_args),
04266               int, -1, result);
04267   ::pthread_attr_destroy (&attr);
04268 
04269 #   else /* this is draft 7 or std */
04270   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id,
04271                                                   &attr,
04272                                                   thread_args->entry_point (),
04273                                                   thread_args),
04274                                 result),
04275               int, -1, result);
04276   ::pthread_attr_destroy (&attr);
04277 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
04278 
04279   // This is a SunOS or POSIX implementation of pthreads, where we
04280   // assume that ACE_thread_t and ACE_hthread_t are the same.  If this
04281   // *isn't* correct on some platform, please let us know.
04282   if (result != -1)
04283     *thr_handle = *thr_id;
04284 
04285 #   if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
04286   // SunOS prior to 5.7:
04287 
04288   // If the priority is 0, then we might have to set it now because we
04289   // couldn't set it with ::pthread_attr_setschedparam, as noted
04290   // above.  This doesn't provide strictly correct behavior, because
04291   // the thread was created (above) with the priority of its parent.
04292   // (That applies regardless of the inherit_sched attribute: if it
04293   // was PTHREAD_INHERIT_SCHED, then it certainly inherited its
04294   // parent's priority.  If it was PTHREAD_EXPLICIT_SCHED, then "attr"
04295   // was initialized by the SunOS ::pthread_attr_init () to contain
04296   // NULL for the priority, which indicated to SunOS ::pthread_create
04297   // () to inherit the parent priority.)
04298   if (priority == 0)
04299     {
04300       // Check the priority of this thread, which is the parent
04301       // of the newly created thread.  If it is 0, then the
04302       // newly created thread will have inherited the priority
04303       // of 0, so there's no need to explicitly set it.
04304       struct sched_param sparam;
04305       int policy = 0;
04306       ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (),
04307                                                              &policy,
04308                                                              &sparam),
04309                                     result), int,
04310                   -1, result);
04311 
04312       // The only policy supported by by SunOS, thru version 5.6,
04313       // is SCHED_OTHER, so that's hard-coded here.
04314       policy = ACE_SCHED_OTHER;
04315 
04316       if (sparam.sched_priority != 0)
04317         {
04318           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
04319           // The memset to 0 sets the priority to 0, so we don't need
04320           // to explicitly set sparam.sched_priority.
04321 
04322           ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id,
04323                                                                         policy,
04324                                                                         &sparam),
04325                                                result),
04326                              int, -1);
04327         }
04328     }
04329 
04330 #     if defined (ACE_NEEDS_LWP_PRIO_SET)
04331 #       if 0
04332   // It would be useful if we could make this work.  But, it requires
04333   // a mechanism for determining the ID of an LWP to which another
04334   // thread is bound.  Is there a way to do that?  Instead, just rely
04335   // on the code in ACE_Thread_Adapter::invoke () to set the LWP
04336   // priority.
04337 
04338   // If the thread is bound, then set the priority on its LWP.
04339   if (ACE_BIT_ENABLED (flags, THR_BOUND))
04340     {
04341       ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) ||
04342                                      ACE_BIT_ENABLED (flags, THR_SCHED_RR)  ?
04343                                      ACE_SCHED_FIFO  :
04344                                      ACE_SCHED_OTHER,
04345                                      priority);
04346       result = ACE_OS::lwp_setparams (sched_params,
04347                                       /* ? How do we find the ID of the LWP
04348                                          to which *thr_id is bound? */);
04349     }
04350 #       endif /* 0 */
04351 #     endif /* ACE_NEEDS_LWP_PRIO_SET */
04352 
04353 #   endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
04354   auto_thread_args.release ();
04355   return result;
04356 # elif defined (ACE_HAS_STHREADS)
04357   int result;
04358   int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04359 
04360   if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04361     // If we need to set the priority, then we need to start the
04362     // thread in a suspended mode.
04363     ACE_SET_BITS (flags, THR_SUSPENDED);
04364 
04365   ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize,
04366                                               thread_args->entry_point (),
04367                                               thread_args,
04368                                               flags, thr_id), result),
04369               int, -1, result);
04370 
04371   if (result != -1)
04372     {
04373       // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same.
04374       *thr_handle = *thr_id;
04375 
04376       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04377         {
04378           // Set the priority of the new thread and then let it
04379           // continue, but only if the user didn't start it suspended
04380           // in the first place!
04381           result = ACE_OS::thr_setprio (*thr_id, priority);
04382           if (result != 0)
04383             {
04384               errno = result;
04385               return -1;
04386             }
04387 
04388           if (start_suspended == 0)
04389             {
04390               result = ACE_OS::thr_continue (*thr_id);
04391               if (result != 0)
04392                 {
04393                   errno = result;
04394                   return -1;
04395                 }
04396             }
04397         }
04398     }
04399   auto_thread_args.release ();
04400   return result;
04401 # elif defined (ACE_HAS_WTHREADS)
04402   ACE_UNUSED_ARG (stack);
04403 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04404   if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
04405     {
04406       CWinThread *cwin_thread =
04407         ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (),
04408                           thread_args,
04409                           priority,
04410                           0,
04411                           flags | THR_SUSPENDED);
04412       // Have to duplicate the handle because
04413       // CWinThread::~CWinThread() closes the original handle.
04414 #     if !defined (ACE_HAS_WINCE)
04415       (void) ::DuplicateHandle (::GetCurrentProcess (),
04416                                 cwin_thread->m_hThread,
04417                                 ::GetCurrentProcess (),
04418                                 thr_handle,
04419                                 0,
04420                                 TRUE,
04421                                 DUPLICATE_SAME_ACCESS);
04422 #     endif /* ! ACE_HAS_WINCE */
04423       *thr_id = cwin_thread->m_nThreadID;
04424 
04425       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0)
04426         cwin_thread->ResumeThread ();
04427       // cwin_thread will be deleted in AfxThreadExit()
04428       // Warning: If AfxThreadExit() is called from within the
04429       // thread, ACE_TSS_Cleanup->thread_exit() never gets called !
04430     }
04431   else
04432 #   endif /* ACE_HAS_MFC */
04433     {
04434       int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04435 
04436       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04437         // If we need to set the priority, then we need to start the
04438         // thread in a suspended mode.
04439         ACE_SET_BITS (flags, THR_SUSPENDED);
04440 
04441       *thr_handle = (void *) ACE_BEGINTHREADEX (0,
04442                                                 static_cast <u_int> (stacksize),
04443                                                 thread_args->entry_point (),
04444                                                 thread_args,
04445                                                 flags,
04446                                                 thr_id);
04447 
04448       if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
04449         {
04450           // Set the priority of the new thread and then let it
04451           // continue, but only if the user didn't start it suspended
04452           // in the first place!
04453           ACE_OS::thr_setprio (*thr_handle, priority);
04454 
04455           if (start_suspended == 0)
04456             ACE_OS::thr_continue (*thr_handle);
04457         }
04458     }
04459 #   if 0
04460   *thr_handle = ::CreateThread
04461     (0,
04462      stacksize,
04463      LPTHREAD_START_ROUTINE (thread_args->entry_point ()),
04464      thread_args,
04465      flags,
04466      thr_id);
04467 #   endif /* 0 */
04468 
04469   // Close down the handle if no one wants to use it.
04470   if (thr_handle == &tmp_handle && tmp_handle != 0)
04471     ::CloseHandle (tmp_handle);
04472 
04473   if (*thr_handle != 0)
04474     {
04475       auto_thread_args.release ();
04476       return 0;
04477     }
04478   else
04479     ACE_FAIL_RETURN (-1);
04480   /* NOTREACHED */
04481 
04482 # elif defined (ACE_VXWORKS)
04483   // The hard-coded values below are what ::sp () would use.  (::sp ()
04484   // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to
04485   // 20,000.)  stacksize should be an even integer.  If a stack is not
04486   // specified, ::taskSpawn () is used so that we can set the
04487   // priority, flags, and stacksize.  If a stack is specified,
04488   // ::taskInit ()/::taskActivate() are used.
04489 
04490   // If called with thr_create() defaults, use same default values as ::sp ():
04491   if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100;
04492   // Assumes that there is a floating point coprocessor.  As noted
04493   // above, ::sp () hardcodes this, so we should be safe with it.
04494   if (flags == 0) flags = VX_FP_TASK;
04495   if (stacksize == 0) stacksize = 20000;
04496 
04497   const u_int thr_id_provided =
04498     thr_id  &&  *thr_id  &&  (*thr_id)[0] != ACE_THR_ID_ALLOCATED;
04499 
04500   ACE_hthread_t tid;
04501 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04502   if (stack == 0)
04503     {
04504 #   else
04505       ACE_UNUSED_ARG (stack);
04506 #   endif /* 0 */
04507       // The call below to ::taskSpawn () causes VxWorks to assign a
04508       // unique task name of the form: "t" + an integer, because the
04509       // first argument is 0.
04510       tid = ::taskSpawn (thr_id_provided  ?  *thr_id  :  0,
04511                          priority,
04512                          (int) flags,
04513                          (int) stacksize,
04514                          thread_args->entry_point (),
04515                          (int) thread_args,
04516                          0, 0, 0, 0, 0, 0, 0, 0, 0);
04517 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04518     }
04519   else
04520     {
04521       // If a task name (thr_id) was not supplied, then the task will
04522       // not have a unique name.  That's VxWorks' behavior.
04523 
04524       // Carve out a TCB at the beginning of the stack space.  The TCB
04525       // occupies 400 bytes with VxWorks 5.3.1/I386.
04526       WIND_TCB *tcb = (WIND_TCB *) stack;
04527 
04528       // The TID is defined to be the address of the TCB.
04529       int status = ::taskInit (tcb,
04530                                thr_id_provided  ?  *thr_id  :  0,
04531                                priority,
04532                                (int) flags,
04533                                (char *) stack + sizeof (WIND_TCB),
04534                                (int) (stacksize - sizeof (WIND_TCB)),
04535                                thread_args->entry_point (),
04536                                (int) thread_args,
04537                                0, 0, 0, 0, 0, 0, 0, 0, 0);
04538 
04539       if (status == OK)
04540         {
04541           // The task was successfully initialized, now activate it.
04542           status = ::taskActivate ((ACE_hthread_t) tcb);
04543         }
04544 
04545       tid = status == OK  ?  (ACE_hthread_t) tcb  :  ERROR;
04546     }
04547 #   endif /* 0 */
04548 
04549   if (tid == ERROR)
04550     return -1;
04551   else
04552     {
04553       if (! thr_id_provided && thr_id)
04554         {
04555           if (*thr_id && (*thr_id)[0] == ACE_THR_ID_ALLOCATED)
04556             // *thr_id was allocated by the Thread_Manager.  ::taskTcb
04557             // (int tid) returns the address of the WIND_TCB (task
04558             // control block).  According to the ::taskSpawn()
04559             // documentation, the name of the new task is stored at
04560             // pStackBase, but is that of the current task?  If so, it
04561             // might be a bit quicker than this extraction of the tcb
04562             // . . .
04563             ACE_OS::strsncpy (*thr_id + 1, ::taskName (tid), 10);
04564           else
04565             // *thr_id was not allocated by the Thread_Manager.
04566             // Pass back the task name in the location pointed to
04567             // by thr_id.
04568             *thr_id = ::taskName (tid);
04569         }
04570       // else if the thr_id was provided, there's no need to overwrite
04571       // it with the same value (string).  If thr_id is 0, then we can't
04572       // pass the task name back.
04573 
04574       if (thr_handle)
04575         *thr_handle = tid;
04576 
04577       auto_thread_args.release ();
04578       return 0;
04579     }
04580 
04581 # endif /* ACE_HAS_STHREADS */
04582 #else
04583   ACE_UNUSED_ARG (func);
04584   ACE_UNUSED_ARG (args);
04585   ACE_UNUSED_ARG (flags);
04586   ACE_UNUSED_ARG (thr_id);
04587   ACE_UNUSED_ARG (thr_handle);
04588   ACE_UNUSED_ARG (priority);
04589   ACE_UNUSED_ARG (stack);
04590   ACE_UNUSED_ARG (stacksize);
04591   ACE_NOTSUP_RETURN (-1);
04592 #endif /* ACE_HAS_THREADS */
04593 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::thr_equal ACE_thread_t  t1,
ACE_thread_t  t2
 

Definition at line 107 of file OS_NS_Thread.inl.

References strcmp().

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_Token::renew(), ACE_Token::shared_acquire(), 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().

00108 {
00109 #if defined (ACE_HAS_PTHREADS)
00110 # if defined (pthread_equal)
00111   // If it's a macro we can't say "pthread_equal"...
00112   return pthread_equal (t1, t2);
00113 # else
00114   return pthread_equal (t1, t2);
00115 # endif /* pthread_equal */
00116 #elif defined (ACE_VXWORKS)
00117   return ! ACE_OS::strcmp (t1, t2);
00118 #else /* For both STHREADS and WTHREADS... */
00119   // Hum, Do we need to treat WTHREAD differently?
00120   // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD.
00121   return t1 == t2;
00122 #endif /* ACE_HAS_PTHREADS */
00123 }

void ACE_OS::thr_exit ACE_THR_FUNC_RETURN  status = 0  ) 
 

Definition at line 4596 of file OS_NS_Thread.cpp.

References ACE_BIT_ENABLED, ACE_hthread_t, ACE_OS_TRACE, cleanup_tss(), ACE_OS_Thread_Descriptor::flags(), ACE_Base_Thread_Adapter::thr_desc_log_msg(), and thr_self().

Referenced by ACE_Thread_Control::exit(), and ACE_Thread::exit().

04597 {
04598   ACE_OS_TRACE ("ACE_OS::thr_exit");
04599 #if defined (ACE_HAS_THREADS)
04600 # if defined (ACE_HAS_PTHREADS)
04601     ::pthread_exit (status);
04602 # elif defined (ACE_HAS_STHREADS)
04603     ::thr_exit (status);
04604 # elif defined (ACE_HAS_WTHREADS)
04605     // Can't call it here because on NT, the thread is exited
04606     // directly by ACE_Thread_Adapter::invoke ().
04607     //   ACE_TSS_Cleanup::instance ()->thread_exit (status);
04608 
04609 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04610     int using_afx = -1;
04611     // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor.
04612     // But without #including ace/Thread_Manager.h, we don't know that.
04613     ACE_OS_Thread_Descriptor *td =
04614       ACE_Base_Thread_Adapter::thr_desc_log_msg ();
04615     if (td)
04616       using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX);
04617 #   endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
04618 
04619     // Call TSS destructors.
04620     ACE_OS::cleanup_tss (0 /* not main thread */);
04621 
04622     // Exit the thread.
04623     // Allow CWinThread-destructor to be invoked from AfxEndThread.
04624     // _endthreadex will be called from AfxEndThread so don't exit the
04625     // thread now if we are running an MFC thread.
04626 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04627     if (using_afx != -1)
04628       {
04629         if (using_afx)
04630           ::AfxEndThread (status);
04631         else
04632           ACE_ENDTHREADEX (status);
04633       }
04634     else
04635       {
04636         // Not spawned by ACE_Thread_Manager, use the old buggy
04637         // version.  You should seriously consider using
04638         // ACE_Thread_Manager to spawn threads.  The following code is
04639         // know to cause some problem.
04640         CWinThread *pThread = ::AfxGetThread ();
04641         if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
04642           ACE_ENDTHREADEX (status);
04643         else
04644           ::AfxEndThread (status);
04645       }
04646 #   else
04647     ACE_ENDTHREADEX (status);
04648 #   endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
04649 
04650 # elif defined (ACE_VXWORKS)
04651     ACE_hthread_t tid;
04652     ACE_OS::thr_self (tid);
04653     *((int *) status) = ::taskDelete (tid);
04654 # endif /* ACE_HAS_PTHREADS */
04655 #else
04656   ACE_UNUSED_ARG (status);
04657 #endif /* ACE_HAS_THREADS */
04658 }

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

References ACE_hthread_t, and ACE_NOTSUP_RETURN.

04749 {
04750 #if defined (ACE_HAS_PTHREAD_GETAFFINITY_NP)
04751   // Handle of the thread, which is NPTL thread-id, normally a big number
04752   if (::pthread_getaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
04753     {
04754       return -1;
04755     }
04756   return 0;
04757 #elif defined (ACE_HAS_2_PARAM_SCHED_GETAFFINITY)
04758   // The process-id is expected as <thr_id>, which can be a thread-id of
04759   // linux-thread, thus making binding to cpu of that particular thread only.
04760   // If you are using this flag for NPTL-threads, however, please pass as a
04761   // thr_id process id obtained by ACE_OS::getpid ()
04762   ACE_UNUSED_ARG (cpu_set_size);
04763   if (::sched_getaffinity(thr_id, cpu_mask) == -1)
04764     {
04765       return -1;
04766     }
04767   return 0;
04768 #elif defined (ACE_HAS_SCHED_GETAFFINITY)
04769   // The process-id is expected as <thr_id>, which can be a thread-id of
04770   // linux-thread, thus making binding to cpu of that particular thread only.
04771   // If you are using this flag for NPTL-threads, however, please pass as a
04772   // thr_id process id obtained by ACE_OS::getpid ()
04773   if (::sched_getaffinity(thr_id, cpu_set_size, cpu_mask) == -1)
04774     {
04775       return -1;
04776     }
04777   return 0;
04778 #else
04779   ACE_UNUSED_ARG (thr_id);
04780   ACE_UNUSED_ARG (cpu_set_size);
04781   ACE_UNUSED_ARG (cpu_mask);
04782   ACE_NOTSUP_RETURN (-1);
04783 #endif
04784 }

ACE_INLINE int ACE_OS::thr_getconcurrency void   ) 
 

Definition at line 2720 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::getconcurrency(), and thr_create().

02721 {
02722   ACE_OS_TRACE ("ACE_OS::thr_getconcurrency");
02723 #if defined (ACE_HAS_THREADS)
02724 # if defined (ACE_HAS_STHREADS)
02725   return ::thr_getconcurrency ();
02726 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_GETCONCURRENCY)
02727   return pthread_getconcurrency ();
02728 # else
02729   ACE_NOTSUP_RETURN (-1);
02730 # endif /* ACE_HAS_STHREADS */
02731 #else
02732   ACE_NOTSUP_RETURN (-1);
02733 #endif /* ACE_HAS_THREADS */
02734 }

ACE_INLINE int ACE_OS::thr_getprio ACE_hthread_t  id,
int &  priority,
int &  policy
 

Definition at line 2737 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_OTHER, and thr_getprio().

02738 {
02739   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02740   ACE_UNUSED_ARG (policy);
02741 #if defined (ACE_HAS_THREADS)
02742 # if (defined (ACE_HAS_PTHREADS) && \
02743      (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
02744 
02745 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
02746   int const result = pthread_getprio (ht_id);
02747   if (result != -1)
02748     {
02749       priority = result;
02750       return 0;
02751     }
02752   else
02753     return -1;
02754 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
02755 
02756   pthread_attr_t  attr;
02757   if (pthread_getschedattr (ht_id, &attr) == 0)
02758     {
02759       priority = pthread_attr_getprio (&attr);
02760       return 0;
02761     }
02762   return -1;
02763 #   else
02764 
02765   struct sched_param param;
02766   int result;
02767 
02768   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
02769                                 result), int,
02770               -1, result);
02771   priority = param.sched_priority;
02772   return result;
02773 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
02774 # elif defined (ACE_HAS_STHREADS)
02775   int result;
02776   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (ht_id, &priority), result), int, -1);
02777 # elif defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE)
02778   ACE_Errno_Guard error (errno);
02779 
02780   priority = ::GetThreadPriority (ht_id);
02781 
02782 #   if defined (ACE_HAS_PHARLAP)
02783 #     if defined (ACE_PHARLAP_LABVIEW_RT)
02784   policy = ACE_SCHED_FIFO;
02785 #     else
02786   DWORD timeslice = ::EtsGetTimeSlice ();
02787   policy = timeslice == 0 ? ACE_SCHED_OTHER : ACE_SCHED_FIFO;
02788 #     endif /* ACE_PHARLAP_LABVIEW_RT */
02789 #   else
02790   DWORD priority_class = ::GetPriorityClass (::GetCurrentProcess ());
02791   if (priority_class == 0 && (error = ::GetLastError ()) != NO_ERROR)
02792     ACE_FAIL_RETURN (-1);
02793 
02794   policy =
02795     (priority_class ==
02796      REALTIME_PRIORITY_CLASS) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER;
02797 #   endif /* ACE_HAS_PHARLAP */
02798 
02799   return 0;
02800 # elif defined (ACE_VXWORKS)
02801   ACE_OSCALL_RETURN (::taskPriorityGet (ht_id, &priority), int, -1);
02802 # else
02803   ACE_UNUSED_ARG (ht_id);
02804   ACE_UNUSED_ARG (priority);
02805   ACE_NOTSUP_RETURN (-1);
02806 # endif /* ACE_HAS_STHREADS */
02807 #else
02808   ACE_UNUSED_ARG (ht_id);
02809   ACE_UNUSED_ARG (priority);
02810   ACE_NOTSUP_RETURN (-1);
02811 #endif /* ACE_HAS_THREADS */
02812 }

ACE_INLINE int ACE_OS::thr_getprio ACE_hthread_t  id,
int &  priority
 

Definition at line 2815 of file OS_NS_Thread.inl.

References ACE_hthread_t, and ACE_OS_TRACE.

Referenced by ACE_Thread::getprio(), ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), and thr_getprio().

02816 {
02817   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02818   int policy = 0;
02819   return ACE_OS::thr_getprio (ht_id, priority, policy);
02820 }

ACE_INLINE int ACE_OS::thr_getspecific ACE_thread_key_t  key,
void **  data
 

Definition at line 2855 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_thread_key_t.

Referenced by ACE_TSS_Cleanup::find_tss_keys(), ACE_Thread::getspecific(), ACE_TSS_Cleanup::thread_release(), and ACE_TSS_Cleanup::tss_keys().

02856 {
02857 //   ACE_OS_TRACE ("ACE_OS::thr_getspecific");
02858 #if defined (ACE_HAS_THREADS)
02859 # if defined (ACE_HAS_TSS_EMULATION)
02860     if (ACE_TSS_Emulation::is_key (key) == 0)
02861       {
02862         errno = EINVAL;
02863         data = 0;
02864         return -1;
02865       }
02866     else
02867       {
02868         *data = ACE_TSS_Emulation::ts_object (key);
02869         return 0;
02870       }
02871 # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
02872   return ACE_OS::thr_getspecific_native (key, data);
02873 #else
02874   ACE_UNUSED_ARG (key);
02875   ACE_UNUSED_ARG (data);
02876   ACE_NOTSUP_RETURN (-1);
02877 # endif /* ACE_HAS_TSS_EMULATION */
02878 #else
02879   ACE_UNUSED_ARG (key);
02880   ACE_UNUSED_ARG (data);
02881   ACE_NOTSUP_RETURN (-1);
02882 #endif /* ACE_HAS_THREADS */
02883 }

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 2948 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

02951 {
02952   ACE_OS_TRACE ("ACE_OS::thr_join");
02953 #if defined (ACE_HAS_THREADS)
02954 # if defined (ACE_HAS_STHREADS)
02955   int result;
02956   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result),
02957                      int, -1);
02958 # elif defined (ACE_HAS_PTHREADS)
02959   ACE_UNUSED_ARG (thr_id);
02960 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02961 #     if defined (ACE_LACKS_NULL_PTHREAD_STATUS)
02962   void *temp;
02963   ACE_OSCALL_RETURN (pthread_join (waiter_id,
02964     status == 0  ?  &temp  :  status), int, -1);
02965 #     else
02966   ACE_OSCALL_RETURN (pthread_join (waiter_id, status), int, -1);
02967 #     endif
02968 #   else
02969   int result;
02970   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result),
02971                      int, -1);
02972 #   endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02973 # elif defined (ACE_HAS_WTHREADS)
02974   ACE_UNUSED_ARG (waiter_id);
02975   ACE_UNUSED_ARG (thr_id);
02976   ACE_UNUSED_ARG (status);
02977 
02978   // This could be implemented if the DLL-Main function or the
02979   // task exit base class some log the threads which have exited
02980   ACE_NOTSUP_RETURN (-1);
02981 # endif /* ACE_HAS_STHREADS */
02982 #else
02983   ACE_UNUSED_ARG (waiter_id);
02984   ACE_UNUSED_ARG (thr_id);
02985   ACE_UNUSED_ARG (status);
02986   ACE_NOTSUP_RETURN (-1);
02987 #endif /* ACE_HAS_THREADS */
02988 }

ACE_INLINE int ACE_OS::thr_join ACE_hthread_t  waiter_id,
ACE_THR_FUNC_RETURN *  status
 

Definition at line 2887 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

Referenced by ACE_Thread::join(), and thr_join().

02889 {
02890   ACE_OS_TRACE ("ACE_OS::thr_join");
02891 #if defined (ACE_HAS_THREADS)
02892 # if defined (ACE_HAS_STHREADS)
02893   int result;
02894   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result),
02895                      int, -1);
02896 # elif defined (ACE_HAS_PTHREADS)
02897 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02898   int ace_result;
02899 #     if defined (ACE_LACKS_NULL_PTHREAD_STATUS)
02900   void *temp;
02901   ACE_OSCALL (pthread_join (thr_handle,
02902                               status == 0  ?  &temp  :  status),
02903               int, -1, ace_result);
02904 #     else
02905   ACE_OSCALL (pthread_join (thr_handle, status), int, -1, ace_result);
02906 #     endif /* ACE_LACKS_NULL_PTHREAD_STATUS */
02907   // Joinable threads need to be detached after joining on Pthreads
02908   // draft 4 (at least) to reclaim thread storage.
02909 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
02910   pthread_detach (&thr_handle);
02911 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
02912 
02913     return ace_result;
02914 
02915 #   else
02916   int result;
02917   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result),
02918                      int, -1);
02919 #   endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02920 # elif defined (ACE_HAS_WTHREADS)
02921   ACE_THR_FUNC_RETURN local_status = 0;
02922 
02923   // Make sure that status is non-NULL.
02924   if (status == 0)
02925     status = &local_status;
02926 
02927   if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0
02928       && ::GetExitCodeThread (thr_handle, status) != FALSE)
02929     {
02930       ::CloseHandle (thr_handle);
02931       return 0;
02932     }
02933   ACE_FAIL_RETURN (-1);
02934   /* NOTREACHED */
02935 # else
02936   ACE_UNUSED_ARG (thr_handle);
02937   ACE_UNUSED_ARG (status);
02938   ACE_NOTSUP_RETURN (-1);
02939 # endif /* ACE_HAS_STHREADS */
02940 #else
02941   ACE_UNUSED_ARG (thr_handle);
02942   ACE_UNUSED_ARG (status);
02943   ACE_NOTSUP_RETURN (-1);
02944 #endif /* ACE_HAS_THREADS */
02945 }

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

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_TSS< TYPE >::~ACE_TSS().

04728 {
04729 #if defined (ACE_HAS_WTHREADS) || defined (ACE_HAS_TSS_EMULATION)
04730   TSS_Cleanup_Instance cleanup;
04731   if (cleanup.valid ())
04732     {
04733       return cleanup->thread_detach_key (key);
04734     }
04735   else
04736     {
04737       return -1;
04738     }
04739 #else
04740   ACE_UNUSED_ARG (key);
04741   ACE_NOTSUP_RETURN (-1);
04742 #endif /* ACE_HAS_WTHREADS || ACE_HAS_TSS_EMULATION */
04743 }

int ACE_OS::thr_key_used ACE_thread_key_t  key  ) 
 

Definition at line 4829 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

04830 {
04831 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
04832   TSS_Cleanup_Instance cleanup;
04833   if (cleanup.valid ())
04834     {
04835       cleanup->thread_use_key (key);
04836       return 0;
04837     }
04838   return -1;
04839 #else
04840   ACE_UNUSED_ARG (key);
04841   ACE_NOTSUP_RETURN (-1);
04842 #endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
04843 }

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

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_Thread::keycreate(), and ACE_TSS_Cleanup::tss_keys().

04903 {
04904   // ACE_OS_TRACE ("ACE_OS::thr_keycreate");
04905 #if defined (ACE_HAS_THREADS)
04906 #   if defined (ACE_HAS_TSS_EMULATION)
04907     if (ACE_TSS_Emulation::next_key (*key) == 0)
04908       {
04909         ACE_TSS_Emulation::tss_destructor (*key, dest);
04910 
04911         // Extract out the thread-specific table instance and stash away
04912         // the key and destructor so that we can free it up later on...
04913         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04914         if (cleanup.valid ())
04915           {
04916             return cleanup->insert (*key, dest);
04917           }
04918         else
04919           {
04920             return -1;
04921           }
04922       }
04923     else
04924       return -1;
04925 #   elif defined (ACE_HAS_WTHREADS)
04926     if (ACE_OS::thr_keycreate_native (key, dest) == 0)
04927       {
04928         // Extract out the thread-specific table instance and stash away
04929         // the key and destructor so that we can free it up later on...
04930         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04931         if (cleanup.valid ())
04932           {
04933             return cleanup->insert (*key, dest);
04934           }
04935         else
04936           {
04937             return -1;
04938           }
04939       }
04940     else
04941       return -1;
04942       /* NOTREACHED */
04943 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
04944     return  ACE_OS::thr_keycreate_native (key, dest);
04945 #   else
04946     ACE_UNUSED_ARG (key);
04947     ACE_UNUSED_ARG (dest);
04948     ACE_NOTSUP_RETURN (-1);
04949 #   endif /* ACE_HAS_TSS_EMULATION */
04950 # else /* ACE_HAS_THREADS */
04951   ACE_UNUSED_ARG (key);
04952   ACE_UNUSED_ARG (dest);
04953   ACE_NOTSUP_RETURN (-1);
04954 # endif /* ACE_HAS_THREADS */
04955 }

int ACE_OS::thr_keyfree ACE_thread_key_t  key  ) 
 

Definition at line 4987 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_Thread::keyfree(), and ACE_TSS< TYPE >::~ACE_TSS().

04988 {
04989   ACE_OS_TRACE ("ACE_OS::thr_keyfree");
04990 # if defined (ACE_HAS_THREADS)
04991 #   if defined (ACE_HAS_TSS_EMULATION)
04992     // Release the key in the TSS_Emulation administration
04993     ACE_TSS_Emulation::release_key (key);
04994     TSS_Cleanup_Instance cleanup;
04995     if (cleanup.valid ())
04996       {
04997         return cleanup->free_key (key);
04998       }
04999     return -1;
05000 #   elif defined (ACE_HAS_WTHREADS)
05001     // Extract out the thread-specific table instance and free up
05002     // the key and destructor.
05003     TSS_Cleanup_Instance cleanup;
05004     if (cleanup.valid ())
05005       {
05006         return cleanup->free_key (key);
05007       }
05008     return -1;
05009 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05010     return ACE_OS::thr_keyfree_native (key);
05011 #   else
05012     ACE_UNUSED_ARG (key);
05013     ACE_NOTSUP_RETURN (-1);
05014 #   endif /* ACE_HAS_TSS_EMULATION */
05015 # else /* ACE_HAS_THREADS */
05016   ACE_UNUSED_ARG (key);
05017   ACE_NOTSUP_RETURN (-1);
05018   return 0;
05019 # endif /* ACE_HAS_THREADS */
05020 }

ACE_INLINE int ACE_OS::thr_kill ACE_thread_t  thr_id,
int  signum
 

Definition at line 2992 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, kill(), and thr_kill().

Referenced by ACE_Thread::kill(), and thr_kill().

02993 {
02994   ACE_OS_TRACE ("ACE_OS::thr_kill");
02995 #if defined (ACE_HAS_THREADS)
02996 # if defined (ACE_HAS_PTHREADS)
02997 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_LACKS_PTHREAD_KILL)
02998   ACE_UNUSED_ARG (signum);
02999   ACE_UNUSED_ARG (thr_id);
03000   ACE_NOTSUP_RETURN (-1);
03001 #   else
03002   int result;
03003   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_kill (thr_id, signum),
03004                                        result),
03005                      int, -1);
03006 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03007 # elif defined (ACE_HAS_STHREADS)
03008   int result;
03009   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum),
03010                                        result),
03011                      int, -1);
03012 # elif defined (ACE_VXWORKS)
03013   ACE_hthread_t tid;
03014   ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid);
03015 
03016   if (tid == ERROR)
03017     return -1;
03018   else
03019     ACE_OSCALL_RETURN (::kill (tid, signum), int, -1);
03020 
03021 # else
03022   ACE_UNUSED_ARG (thr_id);
03023   ACE_UNUSED_ARG (signum);
03024   ACE_NOTSUP_RETURN (-1);
03025 # endif /* ACE_HAS_STHREADS */
03026 #else
03027   ACE_UNUSED_ARG (thr_id);
03028   ACE_UNUSED_ARG (signum);
03029   ACE_NOTSUP_RETURN (-1);
03030 #endif /* ACE_HAS_THREADS */
03031 }

ACE_INLINE size_t ACE_OS::thr_min_stack void   ) 
 

Definition at line 3034 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, sysconf(), and thr_self().

03035 {
03036   ACE_OS_TRACE ("ACE_OS::thr_min_stack");
03037 #if defined (ACE_HAS_THREADS)
03038 # if defined (ACE_HAS_STHREADS)
03039 #   if defined (ACE_HAS_THR_MINSTACK)
03040   // Tandem did some weirdo mangling of STHREAD names...
03041   return ::thr_minstack ();
03042 #   else
03043   return ::thr_min_stack ();
03044 #   endif /* !ACE_HAS_THR_MINSTACK */
03045 # elif defined (ACE_HAS_PTHREADS)
03046 #   if defined (_SC_THREAD_STACK_MIN)
03047   return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
03048 #   elif defined (PTHREAD_STACK_MIN)
03049   return PTHREAD_STACK_MIN;
03050 #   else
03051   ACE_NOTSUP_RETURN (0);
03052 #   endif /* _SC_THREAD_STACK_MIN */
03053 # elif defined (ACE_HAS_WTHREADS)
03054   ACE_NOTSUP_RETURN (0);
03055 # elif defined (ACE_VXWORKS)
03056   TASK_DESC taskDesc;
03057   STATUS status;
03058 
03059   ACE_hthread_t tid;
03060   ACE_OS::thr_self (tid);
03061 
03062   ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc),
03063                                 status),
03064               STATUS, -1, status);
03065   return status == OK ? taskDesc.td_stackSize : 0;
03066 # else /* Should not happen... */
03067   ACE_NOTSUP_RETURN (0);
03068 # endif /* ACE_HAS_STHREADS */
03069 #else
03070   ACE_NOTSUP_RETURN (0);
03071 #endif /* ACE_HAS_THREADS */
03072 }

ACE_INLINE void ACE_OS::thr_self ACE_hthread_t  ) 
 

Definition at line 3095 of file OS_NS_Thread.inl.

References ACE_hthread_t, and ACE_OS_TRACE.

03096 {
03097   ACE_OS_TRACE ("ACE_OS::thr_self");
03098 #if defined (ACE_HAS_THREADS)
03099 # if defined (ACE_HAS_PTHREADS)
03100   // Note, don't use "::" here since the following call is often a macro.
03101   self = pthread_self ();
03102 # elif defined (ACE_HAS_THREAD_SELF)
03103   self = ::thread_self ();
03104 # elif defined (ACE_HAS_STHREADS)
03105   self = ::thr_self ();
03106 # elif defined (ACE_HAS_WTHREADS)
03107   self = ::GetCurrentThread ();
03108 # elif defined (ACE_VXWORKS)
03109   self = ::taskIdSelf ();
03110 # endif /* ACE_HAS_STHREADS */
03111 #else
03112   self = 1; // Might as well make it the main thread ;-)
03113 #endif /* ACE_HAS_THREADS */
03114 }

ACE_INLINE ACE_thread_t ACE_OS::thr_self void   ) 
 

Definition at line 3075 of file OS_NS_Thread.inl.

References thr_self().

Referenced by ACE_Thread_Control::ACE_Thread_Control(), ACE_Thread_ID::ACE_Thread_ID(), 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_self(), thr_setprio(), and ACE_Thread_Manager::thread_desc_self().

03076 {
03077   // ACE_OS_TRACE ("ACE_OS::thr_self");
03078 #if defined (ACE_HAS_THREADS)
03079 # if defined (ACE_HAS_PTHREADS)
03080   // Note, don't use "::" here since the following call is often a macro.
03081   return pthread_self ();
03082 # elif defined (ACE_HAS_STHREADS)
03083   ACE_OSCALL_RETURN (::thr_self (), int, -1);
03084 # elif defined (ACE_HAS_WTHREADS)
03085   return ::GetCurrentThreadId ();
03086 # elif defined (ACE_VXWORKS)
03087   return ::taskName (::taskIdSelf ());
03088 # endif /* ACE_HAS_STHREADS */
03089 #else
03090   return 1; // Might as well make it the first thread ;-)
03091 #endif /* ACE_HAS_THREADS */
03092 }

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

References ACE_hthread_t, and ACE_NOTSUP_RETURN.

04790 {
04791 #if defined (ACE_HAS_PTHREAD_SETAFFINITY_NP)
04792   if (::pthread_setaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0)
04793     {
04794       return -1;
04795     }
04796   return 0;
04797 #elif defined (ACE_HAS_2_PARAM_SCHED_SETAFFINITY)
04798   // The process-id is expected as <thr_id>, which can be a thread-id of
04799   // linux-thread, thus making binding to cpu of that particular thread only.
04800   // If you are using this flag for NPTL-threads, however, please pass as a
04801   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04802   //
04803   ACE_UNUSED_ARG (cpu_set_size);
04804   if (::sched_setaffinity (thr_id, cpu_mask) == -1)
04805     {
04806       return -1;
04807     }
04808   return 0;
04809 #elif defined (ACE_HAS_SCHED_SETAFFINITY)
04810   // The process-id is expected as <thr_id>, which can be a thread-id of
04811   // linux-thread, thus making binding to cpu of that particular thread only.
04812   // If you are using this flag for NPTL-threads, however, please pass as a
04813   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04814   //
04815   if (::sched_setaffinity (thr_id, cpu_set_size, cpu_mask) == -1)
04816     {
04817       return -1;
04818     }
04819   return 0;
04820 #else
04821   ACE_UNUSED_ARG (thr_id);
04822   ACE_UNUSED_ARG (cpu_set_size);
04823   ACE_UNUSED_ARG (cpu_mask);
04824   ACE_NOTSUP_RETURN (-1);
04825 #endif
04826 }

ACE_INLINE int ACE_OS::thr_setcancelstate int  new_state,
int *  old_state
 

Definition at line 3117 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().

03118 {
03119   ACE_OS_TRACE ("ACE_OS::thr_setcancelstate");
03120 #if defined (ACE_HAS_THREADS)
03121 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03122 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03123   int old;
03124   old = pthread_setcancel (new_state);
03125   if (old == -1)
03126     return -1;
03127   *old_state = old;
03128   return 0;
03129 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03130   ACE_UNUSED_ARG (old_state);
03131   ACE_OSCALL_RETURN (pthread_setintr (new_state), int, -1);
03132 #   else /* this is draft 7 or std */
03133   int result;
03134   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcancelstate (new_state,
03135                                                                  old_state),
03136                                        result),
03137                      int, -1);
03138 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03139 # elif defined (ACE_HAS_STHREADS)
03140   ACE_UNUSED_ARG (new_state);
03141   ACE_UNUSED_ARG (old_state);
03142   ACE_NOTSUP_RETURN (-1);
03143 # elif defined (ACE_HAS_WTHREADS)
03144   ACE_UNUSED_ARG (new_state);
03145   ACE_UNUSED_ARG (old_state);
03146   ACE_NOTSUP_RETURN (-1);
03147 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03148   ACE_UNUSED_ARG (new_state);
03149   ACE_UNUSED_ARG (old_state);
03150   ACE_NOTSUP_RETURN (-1);
03151 # endif /* ACE_HAS_PTHREADS */
03152 #else
03153   ACE_UNUSED_ARG (new_state);
03154   ACE_UNUSED_ARG (old_state);
03155   ACE_NOTSUP_RETURN (-1);
03156 #endif /* ACE_HAS_THREADS */
03157 }

ACE_INLINE int ACE_OS::thr_setcanceltype int  new_type,
int *  old_type
 

Definition at line 3160 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().

03161 {
03162   ACE_OS_TRACE ("ACE_OS::thr_setcanceltype");
03163 #if defined (ACE_HAS_THREADS)
03164 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03165 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03166   int old;
03167   old = pthread_setasynccancel (new_type);
03168   if (old == -1)
03169     return -1;
03170   *old_type = old;
03171   return 0;
03172 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03173   ACE_UNUSED_ARG (old_type);
03174   ACE_OSCALL_RETURN (pthread_setintrtype (new_type), int, -1);
03175 #   else /* this is draft 7 or std */
03176   int result;
03177   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcanceltype (new_type,
03178                                                                 old_type),
03179                                        result),
03180                      int, -1);
03181 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03182 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03183   ACE_UNUSED_ARG (new_type);
03184   ACE_UNUSED_ARG (old_type);
03185   ACE_NOTSUP_RETURN (-1);
03186 # endif /* ACE_HAS_PTHREADS */
03187 #else
03188   ACE_UNUSED_ARG (new_type);
03189   ACE_UNUSED_ARG (old_type);
03190   ACE_NOTSUP_RETURN (-1);
03191 #endif /* ACE_HAS_THREADS */
03192 }

ACE_INLINE int ACE_OS::thr_setconcurrency int  hint  ) 
 

Definition at line 3195 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().

03196 {
03197   ACE_OS_TRACE ("ACE_OS::thr_setconcurrency");
03198 #if defined (ACE_HAS_THREADS)
03199 # if defined (ACE_HAS_STHREADS)
03200   int result;
03201   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint),
03202                                        result),
03203                      int, -1);
03204 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_SETCONCURRENCY)
03205   int result;
03206   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setconcurrency (hint),
03207                                        result),
03208                      int, -1);
03209 # else
03210   ACE_UNUSED_ARG (hint);
03211   ACE_NOTSUP_RETURN (-1);
03212 # endif /* ACE_HAS_STHREADS */
03213 #else
03214   ACE_UNUSED_ARG (hint);
03215   ACE_NOTSUP_RETURN (-1);
03216 #endif /* ACE_HAS_THREADS */
03217 }

int ACE_OS::thr_setprio const ACE_Sched_Priority  prio  ) 
 

Definition at line 5023 of file OS_NS_Thread.cpp.

References ACE_hthread_t, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_Sched_Priority, ACE_SCHED_RR, lwp_getparams(), lwp_setparams(), sched_params(), thr_self(), and thr_setprio().

05024 {
05025   // Set the thread priority on the current thread.
05026   ACE_hthread_t my_thread_id;
05027   ACE_OS::thr_self (my_thread_id);
05028 
05029   int const status = ACE_OS::thr_setprio (my_thread_id, prio);
05030 
05031 #if defined (ACE_NEEDS_LWP_PRIO_SET)
05032   // If the thread is in the RT class, then set the priority on its
05033   // LWP.  (Instead of doing this if the thread is in the RT class, it
05034   // should be done for all bound threads.  But, there doesn't appear
05035   // to be an easy way to determine if the thread is bound.)
05036 
05037   if (status == 0)
05038     {
05039       // Find what scheduling class the thread's LWP is in.
05040       ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0);
05041       if (ACE_OS::lwp_getparams (sched_params) == -1)
05042         {
05043           return -1;
05044         }
05045       else if (sched_params.policy () == ACE_SCHED_FIFO  ||
05046                sched_params.policy () == ACE_SCHED_RR)
05047         {
05048           // This thread's LWP is in the RT class, so we need to set
05049           // its priority.
05050           sched_params.priority (prio);
05051           return ACE_OS::lwp_setparams (sched_params);
05052         }
05053       // else this is not an RT thread.  Nothing more needs to be
05054       // done.
05055     }
05056 #endif /* ACE_NEEDS_LWP_PRIO_SET */
05057 
05058   return status;
05059 }

ACE_INLINE int ACE_OS::thr_setprio ACE_hthread_t  ht_id,
int  priority,
int  policy = -1
 

Definition at line 3220 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, memset(), and thr_setprio().

Referenced by ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), sched_params(), ACE_Thread::setprio(), thr_create(), and thr_setprio().

03221 {
03222   ACE_OS_TRACE ("ACE_OS::thr_setprio");
03223   ACE_UNUSED_ARG (policy);
03224 #if defined (ACE_HAS_THREADS)
03225 # if (defined (ACE_HAS_PTHREADS) && \
03226       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
03227 
03228 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03229   int result;
03230   result = pthread_setprio (ht_id, priority);
03231   return (result == -1 ? -1 : 0);
03232 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03233   pthread_attr_t  attr;
03234   if (pthread_getschedattr (ht_id, &attr) == -1)
03235     return -1;
03236   if (pthread_attr_setprio (attr, priority) == -1)
03237     return -1;
03238   return pthread_setschedattr (ht_id, attr);
03239 #   else
03240   int result;
03241   struct sched_param param;
03242   memset ((void *) &param, 0, sizeof param);
03243 
03244   // If <policy> is -1, we don't want to use it for
03245   // pthread_setschedparam().  Instead, obtain policy from
03246   // pthread_getschedparam().
03247   if (policy == -1)
03248     {
03249       ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
03250                                     result),
03251                   int, -1, result);
03252       if (result == -1)
03253         return result;
03254     }
03255 
03256   param.sched_priority = priority;
03257 
03258   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id,
03259                                                                 policy,
03260                                                                 &param),
03261                                        result),
03262                      int, -1);
03263 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03264 # elif defined (ACE_HAS_STHREADS)
03265   int result;
03266   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (ht_id, priority),
03267                                        result),
03268                      int, -1);
03269 # elif defined (ACE_HAS_WTHREADS)
03270   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (ht_id, priority),
03271                                           ace_result_),
03272                         int, -1);
03273 # elif defined (ACE_VXWORKS)
03274   ACE_OSCALL_RETURN (::taskPrioritySet (ht_id, priority), int, -1);
03275 # else
03276   // For example, platforms that support Pthreads but LACK_SETSCHED.
03277   ACE_UNUSED_ARG (ht_id);
03278   ACE_UNUSED_ARG (priority);
03279   ACE_NOTSUP_RETURN (-1);
03280 # endif /* ACE_HAS_STHREADS */
03281 #else
03282   ACE_UNUSED_ARG (ht_id);
03283   ACE_UNUSED_ARG (priority);
03284   ACE_NOTSUP_RETURN (-1);
03285 #endif /* ACE_HAS_THREADS */
03286 }

int ACE_OS::thr_setspecific ACE_thread_key_t  key,
void *  data
 

Definition at line 5097 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_Thread::setspecific(), and ACE_TSS_Cleanup::tss_keys().

05098 {
05099   // ACE_OS_TRACE ("ACE_OS::thr_setspecific");
05100 #if defined (ACE_HAS_THREADS)
05101 #   if defined (ACE_HAS_TSS_EMULATION)
05102     if (ACE_TSS_Emulation::is_key (key) == 0)
05103       {
05104         errno = EINVAL;
05105         data = 0;
05106         return -1;
05107       }
05108     else
05109       {
05110         ACE_TSS_Emulation::ts_object (key) = data;
05111         TSS_Cleanup_Instance cleanup;
05112         if (cleanup.valid ())
05113           {
05114             cleanup->thread_use_key (key);
05115             // for TSS_Cleanup purposes treat stetting data to zero
05116             // like detaching.  This is a consequence of POSIX allowing
05117             // deletion of a "used" key.
05118             if (data == 0)
05119               {
05120                 cleanup->thread_detach_key (key);
05121               }
05122             return 0;
05123           }
05124         else
05125           {
05126             return -1;
05127           }
05128       }
05129 #   elif defined (ACE_HAS_WTHREADS)
05130     if (ACE_OS::thr_setspecific_native (key, data) == 0)
05131       {
05132         TSS_Cleanup_Instance cleanup;
05133         if (cleanup.valid ())
05134           {
05135             cleanup->thread_use_key (key);
05136             // for TSS_Cleanup purposes treat stetting data to zero
05137             // like detaching.  This is a consequence of POSIX allowing
05138             // deletion of a "used" key.
05139             if (data == 0)
05140               {
05141                 cleanup->thread_detach_key (key);
05142               }
05143             return 0;
05144           }
05145         return -1;
05146       }
05147     return -1;
05148 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05149       return ACE_OS::thr_setspecific_native (key, data);
05150 #   else /* ACE_HAS_TSS_EMULATION */
05151       ACE_UNUSED_ARG (key);
05152       ACE_UNUSED_ARG (data);
05153       ACE_NOTSUP_RETURN (-1);
05154 #   endif /* ACE_HAS_TSS_EMULATION */
05155 # else /* ACE_HAS_THREADS */
05156   ACE_UNUSED_ARG (key);
05157   ACE_UNUSED_ARG (data);
05158   ACE_NOTSUP_RETURN (-1);
05159 # endif /* ACE_HAS_THREADS */
05160 }

ACE_INLINE int ACE_OS::thr_sigsetmask int  how,
const sigset_t *  nsm,
sigset_t *  osm
 

Definition at line 3289 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, pthread_sigmask(), SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK, sigprocmask(), and thr_sigsetmask().

Referenced by ACE_Sig_Guard::ACE_Sig_Guard(), ACE_Thread::sigsetmask(), thr_sigsetmask(), and ACE_Sig_Guard::~ACE_Sig_Guard().

03292 {
03293   ACE_OS_TRACE ("ACE_OS::thr_sigsetmask");
03294 #if defined (ACE_HAS_THREADS)
03295 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
03296   // DCE threads and Solaris 2.4 have no such function.
03297   ACE_UNUSED_ARG (osm);
03298   ACE_UNUSED_ARG (nsm);
03299   ACE_UNUSED_ARG (how);
03300 
03301   ACE_NOTSUP_RETURN (-1);
03302 # elif defined (ACE_HAS_SIGTHREADMASK)
03303   int result;
03304   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm),
03305                                        result), int, -1);
03306 # elif defined (ACE_HAS_STHREADS)
03307   int result;
03308   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm),
03309                                        result),
03310                      int, -1);
03311 # elif defined (ACE_HAS_PTHREADS)
03312   // Draft 4 and 6 implementations will sometimes have a sigprocmask () that
03313   // modifies the calling thread's mask only.  If this is not so for your
03314   // platform, define ACE_LACKS_PTHREAD_THR_SIGSETMASK.
03315 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || \
03316     defined (ACE_HAS_PTHREADS_DRAFT6) || (defined (_UNICOS) && _UNICOS == 9)
03317   ACE_OSCALL_RETURN (::sigprocmask (how, nsm, osm), int, -1);
03318 #   elif !defined (ACE_LACKS_PTHREAD_SIGMASK)
03319   int result;
03320   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
03321                                        result), int, -1);
03322 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 || _UNICOS 9 */
03323 
03324 #if 0
03325   /* Don't know if any platform actually needs this... */
03326   // as far as I can tell, this is now pthread_sigaction() -- jwr
03327   int result;
03328   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_sigaction (how, nsm, osm),
03329                                        result), int, -1);
03330 #endif /* 0 */
03331 
03332 # elif defined (ACE_HAS_WTHREADS)
03333   ACE_UNUSED_ARG (osm);
03334   ACE_UNUSED_ARG (nsm);
03335   ACE_UNUSED_ARG (how);
03336 
03337   ACE_NOTSUP_RETURN (-1);
03338 # elif defined (ACE_VXWORKS)
03339   int old_mask = 0;
03340   switch (how)
03341     {
03342     case SIG_BLOCK:
03343     case SIG_UNBLOCK:
03344       {
03345         // get the old mask
03346         old_mask = ::sigsetmask (*nsm);
03347         // create a new mask:  the following assumes that sigset_t is 4 bytes,
03348         // which it is on VxWorks 5.2, so bit operations are done simply . . .
03349         ::sigsetmask (how == SIG_BLOCK ? (old_mask |= *nsm) : (old_mask &= ~*nsm));
03350         if (osm)
03351           *osm = old_mask;
03352         break;
03353       }
03354     case SIG_SETMASK:
03355       old_mask = ::sigsetmask (*nsm);
03356       if (osm)
03357         *osm = old_mask;
03358       break;
03359     default:
03360       return -1;
03361     }
03362 
03363   return 0;
03364 # else /* Should not happen. */
03365   ACE_UNUSED_ARG (how);
03366   ACE_UNUSED_ARG (nsm);
03367   ACE_UNUSED_ARG (osm);
03368   ACE_NOTSUP_RETURN (-1);
03369 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
03370 #else
03371   ACE_UNUSED_ARG (how);
03372   ACE_UNUSED_ARG (nsm);
03373   ACE_UNUSED_ARG (osm);
03374   ACE_NOTSUP_RETURN (-1);
03375 #endif /* ACE_HAS_THREADS */
03376 }

ACE_INLINE int ACE_OS::thr_suspend ACE_hthread_t  target_thread  ) 
 

Definition at line 3379 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_suspend().

Referenced by ACE_Thread::suspend(), and thr_suspend().

03380 {
03381   ACE_OS_TRACE ("ACE_OS::thr_suspend");
03382 #if defined (ACE_HAS_THREADS)
03383 # if defined (ACE_HAS_STHREADS)
03384   int result;
03385   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), result), int, -1);
03386 # elif defined (ACE_HAS_PTHREADS)
03387 #  if defined (ACE_HAS_PTHREAD_SUSPEND)
03388   int result;
03389   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread),
03390                                        result),
03391                      int, -1);
03392 #  elif defined (ACE_HAS_PTHREAD_SUSPEND_NP)
03393   int result;
03394   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend_np (target_thread),
03395                                        result),
03396                      int, -1);
03397 #  else
03398   ACE_UNUSED_ARG (target_thread);
03399   ACE_NOTSUP_RETURN (-1);
03400 #  endif /* ACE_HAS_PTHREAD_SUSPEND */
03401 # elif defined (ACE_HAS_WTHREADS)
03402   if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED)
03403     return 0;
03404   else
03405     ACE_FAIL_RETURN (-1);
03406   /* NOTREACHED */
03407 # elif defined (ACE_VXWORKS)
03408   ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1);
03409 # endif /* ACE_HAS_STHREADS */
03410 #else
03411   ACE_UNUSED_ARG (target_thread);
03412   ACE_NOTSUP_RETURN (-1);
03413 #endif /* ACE_HAS_THREADS */
03414 }

ACE_INLINE void ACE_OS::thr_testcancel void   ) 
 

Definition at line 3417 of file OS_NS_Thread.inl.

References ACE_OS_TRACE.

Referenced by ACE_Thread::testcancel().

03418 {
03419   ACE_OS_TRACE ("ACE_OS::thr_testcancel");
03420 #if defined (ACE_HAS_THREADS)
03421 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03422 #if defined(ACE_HAS_PTHREADS_DRAFT6)
03423   pthread_testintr ();
03424 #else /* ACE_HAS_PTHREADS_DRAFT6 */
03425   pthread_testcancel ();
03426 #endif /* !ACE_HAS_PTHREADS_DRAFT6 */
03427 # elif defined (ACE_HAS_STHREADS)
03428 # elif defined (ACE_HAS_WTHREADS)
03429 # elif defined (ACE_VXWORKS)
03430 # else
03431   // no-op:  can't use ACE_NOTSUP_RETURN because there is no return value
03432 # endif /* ACE_HAS_PTHREADS */
03433 #else
03434 #endif /* ACE_HAS_THREADS */
03435 }

ACE_INLINE void ACE_OS::thr_yield void   ) 
 

Definition at line 3438 of file OS_NS_Thread.inl.

References ACE_OS_TRACE.

Referenced by event_destroy(), event_pulse(), and ACE_Thread::yield().

03439 {
03440   ACE_OS_TRACE ("ACE_OS::thr_yield");
03441 #if defined (ACE_HAS_THREADS)
03442 # if defined (ACE_HAS_PTHREADS)
03443 #   if defined (ACE_HAS_PTHREADS_STD)
03444   // Note - this is a POSIX.4 function - not a POSIX.1c function...
03445   ::sched_yield ();
03446 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03447   pthread_yield (0);
03448 #   else    /* Draft 4 and 7 */
03449   pthread_yield ();
03450 #   endif  /* ACE_HAS_PTHREADS_STD */
03451 # elif defined (ACE_HAS_STHREADS)
03452   ::thr_yield ();
03453 # elif defined (ACE_HAS_WTHREADS)
03454   ::Sleep (0);
03455 # elif defined (ACE_VXWORKS)
03456   // An argument of 0 to ::taskDelay doesn't appear to yield the
03457   // current thread.
03458   // Now, it does seem to work.  The context_switch_time test
03459   // works fine with task_delay set to 0.
03460   ::taskDelay (0);
03461 # endif /* ACE_HAS_STHREADS */
03462 #else
03463   ;
03464 #endif /* ACE_HAS_THREADS */
03465 }

ACE_INLINE int ACE_OS::thread_mutex_destroy ACE_thread_mutex_t *  m  ) 
 

Definition at line 3468 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_destroy().

Referenced by mutex_destroy(), recursive_mutex_destroy(), sema_destroy(), and sema_init().

03469 {
03470   ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy");
03471 #if defined (ACE_HAS_THREADS)
03472 # if defined (ACE_HAS_WTHREADS)
03473   ::DeleteCriticalSection (m);
03474   return 0;
03475 
03476 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03477   return ACE_OS::mutex_destroy (m);
03478 
03479 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03480 
03481 #else
03482   ACE_UNUSED_ARG (m);
03483   ACE_NOTSUP_RETURN (-1);
03484 
03485 #endif /* ACE_HAS_THREADS */
03486 }

ACE_INLINE int ACE_OS::thread_mutex_init ACE_thread_mutex_t *  m,
int  lock_type,
const wchar_t *  name,
ACE_mutexattr_t *  arg = 0
 

Definition at line 3532 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_SEH_EXCEPT, ACE_SEH_TRY, and mutex_init().

03536 {
03537   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03538 #if defined (ACE_HAS_THREADS)
03539 # if defined (ACE_HAS_WTHREADS)
03540   ACE_UNUSED_ARG (lock_type);
03541   ACE_UNUSED_ARG (name);
03542   ACE_UNUSED_ARG (arg);
03543 
03544   ACE_SEH_TRY
03545     {
03546       ::InitializeCriticalSection (m);
03547     }
03548   ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
03549     {
03550       errno = ENOMEM;
03551       return -1;
03552     }
03553   return 0;
03554 
03555 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03556   // Force the use of USYNC_THREAD!
03557   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03558 
03559 # elif defined (ACE_VXWORKS)
03560   return mutex_init (m, lock_type, name, arg);
03561 
03562 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03563 
03564 #else
03565   ACE_UNUSED_ARG (m);
03566   ACE_UNUSED_ARG (lock_type);
03567   ACE_UNUSED_ARG (name);
03568   ACE_UNUSED_ARG (arg);
03569   ACE_NOTSUP_RETURN (-1);
03570 
03571 #endif /* ACE_HAS_THREADS */
03572 }

ACE_INLINE 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 3489 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_SEH_EXCEPT, ACE_SEH_TRY, and mutex_init().

Referenced by mutex_init(), recursive_mutex_init(), and sema_init().

03493 {
03494   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03495 #if defined (ACE_HAS_THREADS)
03496 # if defined (ACE_HAS_WTHREADS)
03497   ACE_UNUSED_ARG (lock_type);
03498   ACE_UNUSED_ARG (name);
03499   ACE_UNUSED_ARG (arg);
03500 
03501   ACE_SEH_TRY
03502     {
03503       ::InitializeCriticalSection (m);
03504     }
03505   ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
03506     {
03507       errno = ENOMEM;
03508       return -1;
03509     }
03510   return 0;
03511 
03512 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03513   // Force the use of USYNC_THREAD!
03514   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03515 # elif defined (ACE_VXWORKS)
03516   return mutex_init (m, lock_type, name, arg);
03517 
03518 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03519 
03520 #else
03521   ACE_UNUSED_ARG (m);
03522   ACE_UNUSED_ARG (lock_type);
03523   ACE_UNUSED_ARG (name);
03524   ACE_UNUSED_ARG (arg);
03525   ACE_NOTSUP_RETURN (-1);
03526 
03527 #endif /* ACE_HAS_THREADS */
03528 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *  m,
const ACE_Time_Value timeout
 

Definition at line 3618 of file OS_NS_Thread.inl.

References thread_mutex_lock().

03620 {
03621   return timeout == 0
03622     ? ACE_OS::thread_mutex_lock (m)
03623     : ACE_OS::thread_mutex_lock (m, *timeout);
03624 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *  m,
const ACE_Time_Value timeout
 

Definition at line 3593 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_lock().

03595 {
03596   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03597 
03598   // For all platforms, except MS Windows, this method is equivalent
03599   // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and
03600   // ACE_mutex_t are the same type.  However, those typedefs evaluate
03601   // to different types on MS Windows.  The "thread mutex"
03602   // implementation in ACE for MS Windows cannot readily support
03603   // timeouts due to a lack of timeout features for this type of MS
03604   // Windows synchronization mechanism.
03605 
03606 #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS)
03607 # if defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03608   return ACE_OS::mutex_lock (m, timeout);
03609 #endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS || VXWORKS */
03610 #else
03611   ACE_UNUSED_ARG (m);
03612   ACE_UNUSED_ARG (timeout);
03613   ACE_NOTSUP_RETURN (-1);
03614 #endif /* ACE_HAS_THREADS */
03615 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *  m  ) 
 

Definition at line 3576 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_lock().

Referenced by ACE_Log_Msg::close(), ACE_Log_Msg::instance(), mutex_lock(), open(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_lock().

03577 {
03578   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03579 #if defined (ACE_HAS_THREADS)
03580 # if defined (ACE_HAS_WTHREADS)
03581   ::EnterCriticalSection (m);
03582   return 0;
03583 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03584   return ACE_OS::mutex_lock (m);
03585 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS || VXWORKS */
03586 #else
03587   ACE_UNUSED_ARG (m);
03588   ACE_NOTSUP_RETURN (-1);
03589 #endif /* ACE_HAS_THREADS */
03590 }

ACE_INLINE int ACE_OS::thread_mutex_trylock ACE_thread_mutex_t *  m  ) 
 

Definition at line 3627 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().

03628 {
03629   ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
03630 
03631 #if defined (ACE_HAS_THREADS)
03632 # if defined (ACE_HAS_WTHREADS)
03633 #   if defined (ACE_HAS_WIN32_TRYLOCK)
03634   BOOL result = ::TryEnterCriticalSection (m);
03635   if (result == TRUE)
03636     return 0;
03637   else
03638     {
03639       errno = EBUSY;
03640       return -1;
03641     }
03642 #   else
03643   ACE_UNUSED_ARG (m);
03644   ACE_NOTSUP_RETURN (-1);
03645 #   endif /* ACE_HAS_WIN32_TRYLOCK */
03646 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03647   return ACE_OS::mutex_trylock (m);
03648 #endif /* Threads variety case */
03649 
03650 #else
03651   ACE_UNUSED_ARG (m);
03652   ACE_NOTSUP_RETURN (-1);
03653 #endif /* ACE_HAS_THREADS */
03654 }

ACE_INLINE int ACE_OS::thread_mutex_unlock ACE_thread_mutex_t *  m  ) 
 

Definition at line 3657 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(), 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().

03658 {
03659   ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock");
03660 #if defined (ACE_HAS_THREADS)
03661 # if defined (ACE_HAS_WTHREADS)
03662   ::LeaveCriticalSection (m);
03663   return 0;
03664 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03665   return ACE_OS::mutex_unlock (m);
03666 # endif /* Threads variety case */
03667 #else
03668   ACE_UNUSED_ARG (m);
03669   ACE_NOTSUP_RETURN (-1);
03670 #endif /* ACE_HAS_THREADS */
03671 }

ACE_INLINE time_t ACE_OS::time time_t *  tloc = 0  ) 
 

Definition at line 453 of file OS_NS_time.inl.

References ACE_OS_TRACE, gettimeofday(), ACE_Time_Value::sec(), and time().

Referenced by ACE_System_Time::get_local_system_time(), ACE_Service_Config::reconfigure(), and time().

00454 {
00455   ACE_OS_TRACE ("ACE_OS::time");
00456 #if !defined (ACE_HAS_WINCE)
00457   ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1);
00458 #else
00459   time_t retv = ACE_OS::gettimeofday ().sec ();
00460   if (tloc)
00461     *tloc = retv;
00462   return retv;
00463 #endif /* ACE_HAS_WINCE */
00464 }

ACE_INLINE long ACE_OS::timezone void   ) 
 

Definition at line 477 of file OS_NS_time.inl.

References ace_timezone().

00478 {
00479   return ::ace_timezone ();
00480 }

ACE_INLINE int ACE_OS::truncate const ACE_TCHAR filename,
ACE_OFF_T  length
 

Definition at line 994 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_HIGH_PART, ACE_LOW_PART, ACE_NOTSUP_RETURN, ACE_OFF_T, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and open().

00996 {
00997   ACE_OS_TRACE ("ACE_OS::truncate");
00998 #if defined (ACE_WIN32)
00999   ACE_HANDLE handle = ACE_OS::open (filename,
01000                                     O_WRONLY,
01001                                     ACE_DEFAULT_FILE_PERMS);
01002 
01003 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01004   LARGE_INTEGER loffset;
01005   loffset.QuadPart = offset;
01006 #else
01007   LONG low_offset = ACE_LOW_PART(offset);
01008   LONG high_offset = ACE_HIGH_PART(offset);
01009 #endif
01010 
01011   if (handle == ACE_INVALID_HANDLE)
01012     ACE_FAIL_RETURN (-1);
01013 
01014 #  if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX)
01015   else if (::SetFilePointerEx (handle,
01016                                loffset,
01017                                0,
01018                                FILE_BEGIN))
01019 #  else
01020   else if (::SetFilePointer (handle,
01021                              low_offset,
01022                              &high_offset,
01023                              FILE_BEGIN) != INVALID_SET_FILE_POINTER
01024            || GetLastError () == NO_ERROR)
01025 #  endif /* ACE_LACKS_WIN32_SETFILEPOINTEREX */
01026     {
01027       BOOL result = ::SetEndOfFile (handle);
01028       ::CloseHandle (handle);
01029       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1);
01030     }
01031   else
01032     {
01033       ::CloseHandle (handle);
01034       ACE_FAIL_RETURN (-1);
01035     }
01036   /* NOTREACHED */
01037 #elif !defined (ACE_LACKS_TRUNCATE)
01038   ACE_OSCALL_RETURN
01039     (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1);
01040 #else
01041   ACE_UNUSED_ARG (filename);
01042   ACE_UNUSED_ARG (offset);
01043   ACE_NOTSUP_RETURN (-1);
01044 #endif /* ACE_WIN32 */
01045 }

ACE_INLINE void ACE_OS::tzset void   ) 
 

Definition at line 484 of file OS_NS_time.inl.

References ENOTSUP.

00485 {
00486 #if !defined (ACE_HAS_WINCE) && !defined (ACE_VXWORKS) && !defined(ACE_HAS_RTEMS) && !defined (ACE_HAS_DINKUM_STL)
00487 #   if defined (ACE_WIN32)
00488   ::_tzset ();  // For Win32.
00489 #   else
00490   ::tzset ();   // For UNIX platforms.
00491 #   endif /* ACE_WIN32 */
00492 # else
00493   errno = ENOTSUP;
00494 # endif /* ACE_HAS_WINCE && !VXWORKS && !ACE_HAS_RTEMS && !ACE_HAS_DINKUM_STL */
00495 }

ACE_INLINE useconds_t ACE_OS::ualarm const ACE_Time_Value tv,
const ACE_Time_Value tv_interval = ACE_Time_Value::zero
 

Definition at line 1065 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, ACE_Time_Value::sec(), and ACE_Time_Value::usec().

01067 {
01068   ACE_OS_TRACE ("ACE_OS::ualarm");
01069 
01070 #if defined (ACE_HAS_UALARM)
01071   useconds_t usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec ();
01072   useconds_t interval =
01073     (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec ();
01074   return ::ualarm (usecs, interval);
01075 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01076   ACE_UNUSED_ARG (tv_interval);
01077   return ::alarm (tv.sec ());
01078 #else
01079   ACE_UNUSED_ARG (tv_interval);
01080   ACE_UNUSED_ARG (tv);
01081   ACE_NOTSUP_RETURN (0);
01082 #endif /* ACE_HAS_UALARM */
01083 }

ACE_INLINE useconds_t ACE_OS::ualarm useconds_t  usecs,
useconds_t  interval = 0
 

Definition at line 1048 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, and ACE_OS_TRACE.

Referenced by ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm().

01049 {
01050   ACE_OS_TRACE ("ACE_OS::ualarm");
01051 
01052 #if defined (ACE_HAS_UALARM)
01053   return ::ualarm (usecs, interval);
01054 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01055   ACE_UNUSED_ARG (interval);
01056   return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS);
01057 #else
01058   ACE_UNUSED_ARG (usecs);
01059   ACE_UNUSED_ARG (interval);
01060   ACE_NOTSUP_RETURN (0);
01061 #endif /* ACE_HAS_UALARM */
01062 }

ACE_INLINE mode_t ACE_OS::umask mode_t  cmask  ) 
 

Definition at line 296 of file OS_NS_sys_stat.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mode_t.

Referenced by ACE::daemonize().

00297   {
00298     ACE_OS_TRACE ("ACE_OS::umask");
00299 # if defined (ACE_LACKS_UMASK)
00300     ACE_UNUSED_ARG (cmask);
00301     ACE_NOTSUP_RETURN ((mode_t)-1);
00302 # elif defined (ACE_HAS_TR24731_2005_CRT)
00303     mode_t old_mode;
00304     ACE_SECURECRTCALL (_umask_s (cmask, &old_mode), mode_t, -1, old_mode);
00305     return old_mode;
00306 # elif defined (ACE_WIN32) && !defined (__BORLANDC__)
00307     ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1);
00308 # else
00309     return ::umask (cmask); // This call shouldn't fail...
00310 # endif /* ACE_LACKS_UMASK */
00311   }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::uname ACE_utsname name  ) 
 

Definition at line 19 of file OS_NS_sys_utsname.cpp.

References ACE_OS_TRACE, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_GetVersionEx, ACE_TEXT_OSVERSIONINFO, hostname(), sprintf(), strcat(), strcpy(), and uname().

Referenced by sema_init(), and uname().

00020 {
00021   ACE_OS_TRACE ("ACE_OS::uname");
00022 #if !defined (ACE_LACKS_UNAME)
00023   ACE_OSCALL_RETURN (::uname (name), int, -1);
00024 #elif defined (ACE_WIN32)
00025   size_t maxnamelen = sizeof name->nodename;
00026   ACE_OS::strcpy (name->sysname, "Win32");
00027 
00028   ACE_TEXT_OSVERSIONINFO vinfo;
00029   vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO);
00030   ACE_TEXT_GetVersionEx (&vinfo);
00031 
00032   SYSTEM_INFO sinfo;
00033 #   if defined (ACE_HAS_PHARLAP)
00034   // PharLap doesn't do GetSystemInfo.  What's really wanted is the
00035   // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
00036   // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
00037   // that the CPU type values in EK_KERNELINFO have the same values
00038   // are the ones defined for SYSTEM_INFO.
00039   EK_KERNELINFO ets_kern;
00040   EK_SYSTEMINFO ets_sys;
00041   EtsGetSystemInfo (&ets_kern, &ets_sys);
00042   sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType);
00043   sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
00044   sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
00045 #   else
00046   ::GetSystemInfo(&sinfo);
00047 #   endif /* ACE_HAS_PHARLAP */
00048 
00049   const char* unknown = "???";
00050 
00051   if (
00052       vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
00053 #   if defined (VER_PLATFORM_WIN32_CE)
00054       || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
00055 #   endif
00056       )
00057     {
00058       // Get information from the two structures
00059       const char *os;
00060       if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
00061         os = "Windows NT %d.%d";
00062       else
00063         os = "Windows CE %d.%d";
00064       ACE_OS::sprintf (name->release,
00065                        os,
00066                        (int) vinfo.dwMajorVersion,
00067                        (int) vinfo.dwMinorVersion);
00068       ACE_OS::sprintf (name->version,
00069                        "Build %d %s",
00070                        (int) vinfo.dwBuildNumber,
00071                        ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
00072 
00073       // We have to make sure that the size of (processor + subtype)
00074       // is not greater than the size of name->machine.  So we give
00075       // half the space to the processor and half the space to
00076       // subtype.  The -1 is necessary for because of the space
00077       // between processor and subtype in the machine name.
00078       const int bufsize = (sizeof (name->machine) / 2) - 1;
00079       char processor[bufsize] = "Unknown";
00080       char subtype[bufsize] = "Unknown";
00081 
00082 #   if defined (ghs)
00083     WORD arch = sinfo.u.s.wProcessorArchitecture;
00084 #   else
00085     WORD arch = sinfo.wProcessorArchitecture;
00086 #   endif
00087 
00088       switch (arch)
00089         {
00090         case PROCESSOR_ARCHITECTURE_INTEL:
00091           ACE_OS::strcpy (processor, "Intel");
00092           if (sinfo.wProcessorLevel == 3)
00093             ACE_OS::strcpy (subtype, "80386");
00094           else if (sinfo.wProcessorLevel == 4)
00095             ACE_OS::strcpy (subtype, "80486");
00096           else if (sinfo.wProcessorLevel == 5)
00097             ACE_OS::strcpy (subtype, "Pentium");
00098           else if (sinfo.wProcessorLevel == 6)
00099             ACE_OS::strcpy (subtype, "Pentium Pro");
00100           else if (sinfo.wProcessorLevel == 7)  // I'm guessing here
00101             ACE_OS::strcpy (subtype, "Pentium II");
00102           break;
00103         case PROCESSOR_ARCHITECTURE_MIPS:
00104           ACE_OS::strcpy (processor, "MIPS");
00105           ACE_OS::strcpy (subtype, "R4000");
00106           break;
00107         case PROCESSOR_ARCHITECTURE_ALPHA:
00108           ACE_OS::strcpy (processor, "Alpha");
00109           ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
00110           break;
00111         case PROCESSOR_ARCHITECTURE_PPC:
00112           ACE_OS::strcpy (processor, "PPC");
00113           if (sinfo.wProcessorLevel == 1)
00114             ACE_OS::strcpy (subtype, "601");
00115           else if (sinfo.wProcessorLevel == 3)
00116             ACE_OS::strcpy (subtype, "603");
00117           else if (sinfo.wProcessorLevel == 4)
00118             ACE_OS::strcpy (subtype, "604");
00119           else if (sinfo.wProcessorLevel == 6)
00120             ACE_OS::strcpy (subtype, "603+");
00121           else if (sinfo.wProcessorLevel == 9)
00122             ACE_OS::strcpy (subtype, "804+");
00123           else if (sinfo.wProcessorLevel == 20)
00124             ACE_OS::strcpy (subtype, "620");
00125           break;
00126 #     if defined PROCESSOR_ARCHITECTURE_IA64
00127         case PROCESSOR_ARCHITECTURE_IA64:
00128           ACE_OS::strcpy (processor, "Itanium");
00129           ACE_OS::sprintf (subtype, "%d",
00130                            sinfo.wProcessorLevel);
00131           break;
00132 #     endif
00133 #     if defined PROCESSOR_ARCHITECTURE_AMD64
00134         case PROCESSOR_ARCHITECTURE_AMD64:
00135           ACE_OS::strcpy (processor, "x64");
00136           ACE_OS::sprintf (subtype, "%d",
00137                            sinfo.wProcessorLevel);
00138           break;
00139 #     endif
00140 #     if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
00141         case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
00142           ACE_OS::strcpy (processor, "WOW64");
00143           ACE_OS::sprintf (subtype, "%d",
00144                            sinfo.wProcessorLevel);
00145           break;
00146 #     endif
00147 #     if defined PROCESSOR_ARCHITECTURE_ARM
00148         case PROCESSOR_ARCHITECTURE_ARM:
00149           ACE_OS::strcpy (processor, "ARM");
00150           ACE_OS::sprintf (subtype, "%d",
00151                            sinfo.wProcessorLevel);
00152           break;
00153 #     endif
00154         case PROCESSOR_ARCHITECTURE_UNKNOWN:
00155         default:
00156           // @@ We could provide WinCE specific info here.  But let's
00157           //    defer that to some later point.
00158           ACE_OS::strcpy (processor, "Unknown");
00159           break;
00160         }
00161       ACE_OS::sprintf (name->machine,
00162                        "%s %s",
00163                        processor, subtype);
00164     }
00165   else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00166     {
00167       if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
00168         {
00169           ACE_OS::strcpy (name->release, "Windows 95");
00170           if (vinfo.szCSDVersion[1] == ACE_TEXT('C'))
00171             ACE_OS::strcat (name->release, " OSR2");
00172         }
00173       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
00174         {
00175           ACE_OS::strcpy (name->release, "Windows 98");
00176           if (vinfo.szCSDVersion[1] == ACE_TEXT('A'))
00177             ACE_OS::strcat (name->release, " SE");
00178         }
00179       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
00180         {
00181           ACE_OS::strcpy (name->release, "Windows Me");
00182         }
00183       else
00184         {
00185           ACE_OS::strcpy (name->release, unknown);
00186         }
00187 
00188       ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber));
00189       if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
00190         ACE_OS::strcpy (name->machine, "Intel 80386");
00191       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
00192         ACE_OS::strcpy (name->machine, "Intel 80486");
00193       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
00194         ACE_OS::strcpy (name->machine, "Intel Pentium");
00195       else
00196         ACE_OS::strcpy (name->machine, unknown);
00197     }
00198   else
00199     {
00200       // We don't know what this is!
00201 
00202       ACE_OS::strcpy (name->release, unknown);
00203       ACE_OS::strcpy (name->version, unknown);
00204       ACE_OS::strcpy (name->machine, unknown);
00205     }
00206 
00207 # if defined (ACE_LACKS_HOSTNAME)
00208   return 0;
00209 # else /* ACE_LACKS_HOSTNAME */
00210   return ACE_OS::hostname (name->nodename, maxnamelen);
00211 # endif /* ACE_LACKS_HOSTNAME */
00212 
00213 #elif defined (ACE_VXWORKS)
00214   size_t maxnamelen = sizeof name->nodename;
00215   ACE_OS::strcpy (name->sysname, "VxWorks");
00216   ACE_OS::strcpy (name->release, "???");
00217   ACE_OS::strcpy (name->version, sysBspRev ());
00218   ACE_OS::strcpy (name->machine, sysModel ());
00219 
00220   return ACE_OS::hostname (name->nodename, maxnamelen);
00221 #elif defined (INTEGRITY)
00222   if(!name) {
00223     errno = EFAULT;
00224     return -1;
00225   }
00226   strcpy(name->sysname,"INTEGRITY");
00227   int status = gethostname(name->nodename,_SYS_NMLN);
00228   strcpy(name->release,"4.0");
00229   strcpy(name->version,"4.0.9");
00230   strcpy(name->machine,"a standard name");
00231   return status;
00232 #endif /* ACE_WIN32 */
00233 }

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

Definition at line 660 of file OS_NS_stdio.inl.

References ace_ungetc_helper().

Referenced by ACE_Read_Buffer::rec_read().

00661 {
00662   return ace_ungetc_helper (c, fp);
00663 }

ACE_NAMESPACE_INLINE_FUNCTION wint_t ungetwc wint_t  c,
FILE *  fp
 

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 will provide uniqueness between other "live" objects in the same process. The uniqueness of this name is therefore only valid for the life of .

Definition at line 5163 of file OS_NS_Thread.cpp.

References ACE_UNIQUE_NAME_LEN, sprintf(), and strsncpy().

Referenced by ACE_MEM_Acceptor::accept(), sema_init(), ACE_DLL::set_handle(), and ACE::unique_name().

05166 {
05167   // The process ID will provide uniqueness between processes on the
05168   // same machine. The "this" pointer of the <object> will provide
05169   // uniqueness between other "live" objects in the same process. The
05170   // uniqueness of this name is therefore only valid for the life of
05171   // <object>.
05172   char temp_name[ACE_UNIQUE_NAME_LEN];
05173   ACE_OS::sprintf (temp_name,
05174                    "%p%d",
05175                    object,
05176                    static_cast <int> (ACE_OS::getpid ()));
05177   ACE_OS::strsncpy (name,
05178                     temp_name,
05179                     length);
05180 }

ACE_INLINE int ACE_OS::unlink const wchar_t *  path  ) 
 

Definition at line 1105 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, ACE_Wide_To_Ascii::char_rep(), and unlink().

01106 {
01107   ACE_OS_TRACE ("ACE_OS::unlink");
01108 # if defined (ACE_HAS_WINCE)
01109   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01110   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFileW (path), ace_result_),
01111                         int, -1);
01112 # elif defined (ACE_WIN32)
01113   ACE_OSCALL_RETURN (::_wunlink (path), int, -1);
01114 # else
01115   ACE_Wide_To_Ascii npath (path);
01116   return ACE_OS::unlink (npath.char_rep ());
01117 # endif /* ACE_HAS_WINCE */
01118 }

ACE_INLINE int ACE_OS::unlink const char *  path  ) 
 

Definition at line 1086 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_TEXT_CHAR_TO_TCHAR.

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

01087 {
01088   ACE_OS_TRACE ("ACE_OS::unlink");
01089 # if defined (ACE_HAS_NONCONST_UNLINK)
01090   ACE_OSCALL_RETURN (::unlink (const_cast<char *> (path)), int, -1);
01091 # elif defined (ACE_HAS_WINCE)
01092   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01093   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (ACE_TEXT_CHAR_TO_TCHAR (path)), ace_result_),
01094                         int, -1);
01095 # elif defined (ACE_LACKS_UNLINK)
01096   ACE_UNUSED_ARG (path);
01097   ACE_NOTSUP_RETURN (-1);
01098 # else
01099   ACE_OSCALL_RETURN (::unlink (path), int, -1);
01100 # endif /* ACE_HAS_NONCONST_UNLINK */
01101 }

ACE_INLINE int ACE_OS::vsnprintf wchar_t *  buffer,
size_t  maxlen,
const wchar_t *  format,
va_list  argptr
 

Definition at line 1038 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN.

01039 {
01040 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
01041      (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \
01042      (defined (ACE_HAS_DINKUM_STL) || defined (__DMC__)) || \
01043       defined (ACE_HAS_VSWPRINTF)
01044 
01045   return vswprintf (buffer, maxlen, format, ap);
01046 
01047 # elif defined (ACE_HAS_TR24731_2005_CRT)
01048 
01049   return _vsnwprintf_s (buffer, maxlen, _TRUNCATE, format, ap);
01050 
01051 # elif defined (ACE_WIN32)
01052 
01053   int result = ::_vsnwprintf (buffer, maxlen, format, ap);
01054 
01055   // Win32 doesn't regard a full buffer with no 0-terminate as an
01056 // overrun.
01057   if (result == static_cast<int> (maxlen))
01058     result = -1;
01059 
01060   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01061   if (result == -1)
01062     buffer[maxlen-1] = '\0';
01063 
01064   return result;
01065 
01066 # else
01067 
01068   ACE_UNUSED_ARG (buffer);
01069   ACE_UNUSED_ARG (maxlen);
01070   ACE_UNUSED_ARG (format);
01071   ACE_UNUSED_ARG (ap);
01072   ACE_NOTSUP_RETURN (-1);
01073 
01074 # endif /* platforms with a variant of vswprintf */
01075 }

ACE_INLINE int ACE_OS::vsnprintf char *  buffer,
size_t  maxlen,
const char *  format,
va_list  argptr
 

Definition at line 958 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN.

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

00959 {
00960 #if !defined (ACE_LACKS_VSNPRINTF)
00961   int result;
00962 #  if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
00963   // _vsnprintf_s() doesn't report the length needed when it truncates. This
00964   // info is needed and relied on by others things in ACE+TAO, so don't use
00965   // this. There's adequate protection via the maxlen.
00966   result = _vsnprintf_s (buffer, maxlen, _TRUNCATE, format, ap);
00967 #  elif !defined (ACE_WIN32)
00968   result = ::vsnprintf (buffer, maxlen, format, ap);
00969 #  else
00970   result = ::_vsnprintf (buffer, maxlen, format, ap);
00971 
00972   // Win32 doesn't regard a full buffer with no 0-terminate as an overrun.
00973   if (result == static_cast<int> (maxlen))
00974     buffer[maxlen-1] = '\0';
00975 
00976   // Win32 doesn't 0-terminate the string if it overruns maxlen.
00977   if (result == -1)
00978     buffer[maxlen-1] = '\0';
00979 # endif
00980   // In out-of-range conditions, C99 defines vsnprintf() to return the number
00981   // of characters that would have been written if enough space was available.
00982   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
00983   // -1. This method follows the C99 standard, but needs to guess at the
00984   // value; uses maxlen + 1.
00985   if (result == -1)
00986     {
00987       result = static_cast <int> (maxlen + 1);
00988     }
00989 
00990   return result;
00991 #elif defined (ACE_HAS_TRIO)
00992   return trio_vsnprintf (buffer, maxlen, format, ap);
00993 #else
00994   ACE_UNUSED_ARG (buffer);
00995   ACE_UNUSED_ARG (maxlen);
00996   ACE_UNUSED_ARG (format);
00997   ACE_UNUSED_ARG (ap);
00998   ACE_NOTSUP_RETURN (-1);
00999 #endif /* ACE_LACKS_VSNPRINTF */
01000 }

ACE_INLINE int ACE_OS::vsprintf wchar_t *  buffer,
const wchar_t *  format,
va_list  argptr
 

Definition at line 1004 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN.

01005 {
01006 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
01007      (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \
01008       defined (ACE_HAS_DINKUM_STL) || defined (__DMC__) || \
01009       defined (ACE_HAS_VSWPRINTF) || \
01010      (defined (ACE_WIN32_VC8) && !defined (ACE_HAS_WINCE) && \
01011       _MSC_FULL_VER > 140050000)
01012 
01013   // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a
01014   // maxlen argument. Since this method doesn't supply one, pass in
01015   // a length that works (ULONG_MAX doesn't on all platform since some check
01016   // to see if the operation will remain in bounds). If this isn't ok, use
01017   // ACE_OS::snprintf().
01018   return vswprintf (buffer, 4096, format, argptr);
01019 
01020 # elif defined (ACE_WIN32)
01021   // Windows has vswprintf, but the pre-VC8 signature is from the older
01022   // ISO C standard. Also see ACE_OS::snprintf() for more info on this.
01023 
01024   return vswprintf (buffer, format, argptr);
01025 
01026 # else
01027   ACE_UNUSED_ARG (buffer);
01028   ACE_UNUSED_ARG (format);
01029   ACE_UNUSED_ARG (argptr);
01030   ACE_NOTSUP_RETURN (-1);
01031 
01032 # endif /* XPG5 || ACE_HAS_DINKUM_STL */
01033 }

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

Definition at line 952 of file OS_NS_stdio.inl.

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

00953 {
00954   return ::vsprintf (buffer, format, argptr);
00955 }

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_exitcode, ACE_OS_TRACE, pid_t, 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_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 pid_t.

Referenced by ACE_Process::wait(), and ACE_Barrier::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_exitcode, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ETIME, pid_t, set_errno_to_last_error(), waitpid(), and WNOHANG.

Referenced by ACE::fork(), ACE_Process_Manager::wait(), ACE_Process::wait(), wait(), and waitpid().

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 wchar_t * ACE_OS::wcscat_emulation wchar_t *  destination,
const wchar_t *  source
 

Emulated wcscat - Appends a string.

Definition at line 57 of file OS_NS_wchar.cpp.

Referenced by strcat().

00059 {
00060   wchar_t *save = destination;
00061 
00062   for (; *destination; ++destination);
00063   while ((*destination++ = *source++));
00064   return save;
00065 }

wchar_t * ACE_OS::wcschr_emulation const wchar_t *  string,
wchar_t  c
 

Emulated wcschr - Finds a character in a string.

Definition at line 70 of file OS_NS_wchar.cpp.

Referenced by strchr().

00071 {
00072   for (;*string ; ++string)
00073     if (*string == c)
00074       return const_cast<wchar_t *> (string);
00075 
00076   return 0;
00077 }

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 }

wchar_t * ACE_OS::wcscpy_emulation wchar_t *  destination,
const wchar_t *  source
 

Emulated wcscpy - Copies a string.

Definition at line 94 of file OS_NS_wchar.cpp.

Referenced by strcpy().

00096 {
00097   wchar_t *save = destination;
00098 
00099   for (; (*destination = *source); ++source, ++destination);
00100   return save;
00101 }

size_t ACE_OS::wcscspn_emulation const wchar_t *  string,
const wchar_t *  reject
 

Emulated wcscspn.

Definition at line 106 of file OS_NS_wchar.cpp.

Referenced by strcspn().

00107 {
00108   const wchar_t *scan = 0;
00109   const wchar_t *rej_scan = 0;
00110   int count = 0;
00111 
00112   for (scan = s; *scan; scan++)
00113     {
00114 
00115       for (rej_scan = reject; *rej_scan; rej_scan++)
00116         if (*scan == *rej_scan)
00117           return count;
00118 
00119       count++;
00120     }
00121 
00122   return count;
00123 }

int ACE_OS::wcsicmp_emulation const wchar_t *  string1,
const wchar_t *  string2
 

Emulated wcsicmp - Performs a case insensitive comparison of strings.

Definition at line 128 of file OS_NS_wchar.cpp.

References ace_tolower(), and ace_towlower().

00129 {
00130   const wchar_t *scan1 = s;
00131   const wchar_t *scan2 = t;
00132 
00133   while (*scan1 != 0
00134          && ACE_OS::ace_towlower (*scan1)
00135             == ACE_OS::ace_towlower (*scan2))
00136     {
00137       ++scan1;
00138       ++scan2;
00139     }
00140 
00141   // The following case analysis is necessary so that characters which
00142   // look negative collate low against normal characters but high
00143   // against the end-of-string NUL.
00144 
00145   if (*scan1 == '\0' && *scan2 == '\0')
00146     return 0;
00147   else if (*scan1 == '\0')
00148     return -1;
00149   else if (*scan2 == '\0')
00150     return 1;
00151   else
00152     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_towlower (*scan2);
00153 }

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_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 }

int ACE_OS::wcsncmp_emulation const ACE_WCHAR_T *  string1,
const ACE_WCHAR_T *  string2,
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_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 }

int ACE_OS::wcsnicmp_emulation const wchar_t *  string1,
const wchar_t *  string2,
size_t  len
 

Emulated wcsnicmp - Performs a case insensitive comparison of two arrays

Definition at line 248 of file OS_NS_wchar.cpp.

References ace_towlower().

00251 {
00252   const wchar_t *scan1 = s;
00253   const wchar_t *scan2 = t;
00254   size_t count = 0;
00255 
00256   while (count++ < len
00257          && *scan1 != 0
00258          && ACE_OS::ace_towlower (*scan1)
00259             == ACE_OS::ace_towlower (*scan2))
00260     {
00261       ++scan1;
00262       ++scan2;
00263     }
00264 
00265   if (count > len)
00266     return 0;
00267 
00268   // The following case analysis is necessary so that characters which
00269   // look negative collate low against normal characters but high
00270   // against the end-of-string NUL.
00271 
00272   if (*scan1 == '\0' && *scan2 == '\0')
00273     return 0;
00274   else if (*scan1 == '\0')
00275     return -1;
00276   else if (*scan2 == '\0')
00277     return 1;
00278   else
00279     return ACE_OS::ace_towlower (*scan1) - ACE_OS::ace_towlower (*scan2);
00280 }

wchar_t * ACE_OS::wcspbrk_emulation const wchar_t *  string,
const wchar_t *  charset
 

Emulated wcspbrk - Searches for characters in a string.

Definition at line 285 of file OS_NS_wchar.cpp.

Referenced by strpbrk().

00287 {
00288   const wchar_t *scanp;
00289   int c, sc;
00290 
00291   while ((c = *string++) != 0)
00292     {
00293       for (scanp = charset; (sc = *scanp++) != 0;)
00294         if (sc == c)
00295           return const_cast<wchar_t *> (string - 1);
00296     }
00297 
00298   return 0;
00299 }

const wchar_t * ACE_OS::wcsrchr_emulation const wchar_t *  string,
wint_t  c
 

Emulated wcsrchr (const wchar_t version) - Finds the last occurance of a character in a string.

Definition at line 304 of file OS_NS_wchar.cpp.

References strlen().

00305 {
00306   const wchar_t *p = s + ACE_OS::strlen (s);
00307 
00308   while (*p != static_cast<wchar_t> (c))
00309     if (p == s)
00310       return 0;
00311     else
00312       p--;
00313 
00314   return p;
00315 }

wchar_t * ACE_OS::wcsrchr_emulation wchar_t *  string,
wint_t  c
 

Emulated wcsrchr (wchar_t version) - Finds the last occurance of a character in a string.

Definition at line 318 of file OS_NS_wchar.cpp.

References strlen().

Referenced by strrchr().

00319 {
00320   wchar_t *p = s + ACE_OS::strlen (s);
00321 
00322   while (*p != static_cast<wchar_t> (c))
00323     if (p == s)
00324       return 0;
00325     else
00326       p--;
00327 
00328   return p;
00329 }

size_t ACE_OS::wcsspn_emulation const wchar_t *  string,
const wchar_t *  charset
 

Emulated wcsspn.

Definition at line 334 of file OS_NS_wchar.cpp.

Referenced by strspn().

00336 {
00337   const wchar_t *p = string;
00338   const wchar_t *spanp;
00339   wchar_t c, sc;
00340 
00341   // Skip any characters in charset, excluding the terminating \0.
00342 cont:
00343   c = *p++;
00344   for (spanp = charset; (sc = *spanp++) != 0;)
00345     if (sc == c)
00346       goto cont;
00347   return (p - 1 - string);
00348 }

wchar_t * ACE_OS::wcsstr_emulation const wchar_t *  string,
const wchar_t *  charset
 

Emulated wcsstr - Performs a case insensitive comparison of two strings.

Definition at line 353 of file OS_NS_wchar.cpp.

References strlen(), and strncmp().

Referenced by strstr().

00355 {
00356   wchar_t c, sc;
00357   size_t len;
00358 
00359   if ((c = *charset++) != 0)
00360     {
00361       len = ACE_OS::strlen (charset);
00362       do
00363         {
00364           do
00365             {
00366               if ((sc = *string++) == 0)
00367                 return 0;
00368             } while (sc != c);
00369         } while (ACE_OS::strncmp (string, charset, len) != 0);
00370       string--;
00371     }
00372 
00373   return const_cast<wchar_t *> (string);
00374 }

ACE_INLINE ssize_t ACE_OS::write ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_OVERLAPPED
 

Definition at line 1145 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, ACE_OVERLAPPED, ssize_t, and write().

01149 {
01150   ACE_OS_TRACE ("ACE_OS::write");
01151   overlapped = overlapped;
01152 #if defined (ACE_WIN32)
01153   DWORD bytes_written; // This is set to 0 byte WriteFile.
01154 
01155   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01156   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped))
01157     return (ssize_t) bytes_written;
01158   else
01159     ACE_FAIL_RETURN (-1);
01160 #else
01161   return ACE_OS::write (handle, buf, nbyte);
01162 #endif /* ACE_WIN32 */
01163 }

ACE_INLINE ssize_t ACE_OS::write ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte
 

Definition at line 1122 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, ssize_t, and write().

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name(), ACE_UPIPE_Connector::connect(), 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().

01123 {
01124   ACE_OS_TRACE ("ACE_OS::write");
01125 #if defined (ACE_WIN32)
01126   DWORD bytes_written; // This is set to 0 byte WriteFile.
01127 
01128   // Strictly correctly, we should loop writing all the data if more
01129   // than a DWORD length can hold.
01130   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01131   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0))
01132     return (ssize_t) bytes_written;
01133   else
01134     ACE_FAIL_RETURN (-1);
01135 #else
01136 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
01137   ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1);
01138 # else
01139   ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
01140 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
01141 #endif /* ACE_WIN32 */
01142 }

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 (uses the <ACE_OS::write> calls, which is uses the system call on UNIX and the 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 .

Definition at line 817 of file OS_NS_unistd.cpp.

References ssize_t, and write().

Referenced by ACE::write_n().

00821 {
00822   size_t temp;
00823   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00824   ssize_t n;
00825 
00826   for (bytes_transferred = 0;
00827        bytes_transferred < len;
00828        bytes_transferred += n)
00829     {
00830       n = ACE_OS::write (handle,
00831                          (char *) buf + bytes_transferred,
00832                          len - bytes_transferred);
00833 
00834       if (n == -1 || n == 0)
00835         return n;
00836     }
00837 
00838   return bytes_transferred;
00839 }

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, ssize_t, 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_INLINE 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_INLINE ACE_OS::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_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE 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_INLINE 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 }


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

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

ACE_thread_t ACE_OS::NULL_thread
 

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

Definition at line 1088 of file OS_NS_Thread.cpp.

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::socket_initialized_
 

Keeps track of whether we've already initialized WinSock...

Definition at line 14 of file OS_NS_sys_socket.cpp.

HINSTANCE ACE_OS::win32_resource_module_
 

Definition at line 19 of file OS_NS_stdio.cpp.

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_TEXT_OSVERSIONINFO ACE_OS::win32_versioninfo_
 

Definition at line 18 of file OS_NS_stdio.cpp.


Generated on Sun Jan 27 12:59:46 2008 for ACE by doxygen 1.3.6