summaryrefslogtreecommitdiff
path: root/PACE
diff options
context:
space:
mode:
authorjoeh <joeh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-09 20:49:55 +0000
committerjoeh <joeh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-09 20:49:55 +0000
commit4aa4e13b92eb67bafe33694dfab1ea07a68a6401 (patch)
treef033269b19827b0bd4d1fb15a77e94b351920c12 /PACE
parentfebeb8486dd8f997b368d947f91cd4fa41514cc3 (diff)
downloadATCD-4aa4e13b92eb67bafe33694dfab1ea07a68a6401.tar.gz
ChangeLogTag: Mon Jul 9 15:39:26 2001 Joe Hoffert <joeh@cs.wustl.edu>
Diffstat (limited to 'PACE')
-rw-r--r--PACE/ChangeLog24
-rw-r--r--PACE/pace/fcntl.h5
-rw-r--r--PACE/pace/pthread.h114
-rw-r--r--PACE/pace/vxworks/pthread.c423
-rw-r--r--PACE/pace/vxworks/pthread.inl406
-rw-r--r--PACE/pace/vxworks/signal.inl16
-rw-r--r--PACE/pace/vxworks/utsname.h1
7 files changed, 552 insertions, 437 deletions
diff --git a/PACE/ChangeLog b/PACE/ChangeLog
index dc7ed3f5f5b..ae9c81495e9 100644
--- a/PACE/ChangeLog
+++ b/PACE/ChangeLog
@@ -1,3 +1,27 @@
+Mon Jul 9 15:39:26 2001 Joe Hoffert <joeh@cs.wustl.edu>
+
+ * pace/vxworks/utsname.h:
+ VxWorks does not have a utsname.h so remove it from being
+ included.
+
+ * pace/vxworks/signal.inl:
+ Fixed call to sigwait. Used call to sigtimedwait (as ACE
+ does) since sigwait doesn't appear to be supported by
+ VxWorks.
+
+ * pace/vxworks/pthread.inl:
+ Moved some functions from inline to non-inline.
+
+ * pace/vxworks/pthread.c:
+ Moved some functions from inline to non-inline.
+
+ * pace/pthread.h:
+ Changed some functions from inline to non-inline for
+ VxWorks.
+
+ * pace/fcntl.h:
+ Added appropriate return for pace_fcntl on VxWorks.
+
Fri Jun 29 15:52:28 2001 Joe Hoffert <joeh@cs.wustl.edu>
* pace/config/platform.h:
diff --git a/PACE/pace/fcntl.h b/PACE/pace/fcntl.h
index 152312f59ef..e6a28b9a36b 100644
--- a/PACE/pace/fcntl.h
+++ b/PACE/pace/fcntl.h
@@ -53,7 +53,12 @@ extern "C" {
# if defined (PACE_WIN32)
int fcntl (PACE_HANDLE fildes, int cmd, /* arg */ ... );
# endif /* PACE_WIN32 */
+
+# if defined (PACE_VXWORKS) && PACE_VXWORKS
+ PACE_INLINE int pace_fcntl(PACE_HANDLE fildes, int cmd, long arg) { PACE_ERRNO_NO_SUPPORT_RETURN (-1); }
+# else
# define pace_fcntl fcntl
+# endif /* ! PACE_VXWORKS */
#endif /* PACE_HAS_POSIX_FM_UOF */
/**
diff --git a/PACE/pace/pthread.h b/PACE/pace/pthread.h
index 638a4b7c141..8b68658ef23 100644
--- a/PACE/pace/pthread.h
+++ b/PACE/pace/pthread.h
@@ -126,7 +126,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 16.2.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_attr_init (pace_pthread_attr_t * attr);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_attr_init (pace_pthread_attr_t * attr);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -135,8 +138,11 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 16.2.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_attr_setdetachstate (pace_pthread_attr_t * attr,
- int detachstate);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_attr_setdetachstate (pace_pthread_attr_t * attr,
+ int detachstate);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -155,9 +161,12 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 13.5.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_attr_setschedparam (pace_pthread_attr_t * attr,
- const
- pace_sched_param * param);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_attr_setschedparam (pace_pthread_attr_t * attr,
+ const
+ pace_sched_param * param);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -206,7 +215,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 18.2.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_cancel (pace_pthread_t thread);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_cancel (pace_pthread_t thread);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -384,9 +396,12 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 13.2.5.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_getschedparam (pace_pthread_t thread,
- int * policy,
- pace_sched_param * param);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_getschedparam (pace_pthread_t thread,
+ int * policy,
+ pace_sched_param * param);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -395,7 +410,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 17.1.2.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE void * pace_pthread_getspecific (pace_pthread_key_t key);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ void * pace_pthread_getspecific (pace_pthread_key_t key);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -471,8 +489,11 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 11.3.2.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutex_init (pace_pthread_mutex_t * mutex,
- const pace_pthread_mutexattr_t * attr);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutex_init (pace_pthread_mutex_t * mutex,
+ const pace_pthread_mutexattr_t * attr);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -481,7 +502,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 11.3.3.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutex_lock (pace_pthread_mutex_t * mutex);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutex_lock (pace_pthread_mutex_t * mutex);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -501,7 +525,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 11.3.3.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutex_trylock (pace_pthread_mutex_t * mutex);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutex_trylock (pace_pthread_mutex_t * mutex);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -510,7 +537,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 11.3.3.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutex_unlock (pace_pthread_mutex_t * mutex);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutex_unlock (pace_pthread_mutex_t * mutex);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -560,8 +590,11 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 13.6.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutexattr_setprotocol (pace_pthread_mutexattr_t * attr,
- int protocol);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutexattr_setprotocol (pace_pthread_mutexattr_t * attr,
+ int protocol);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -581,7 +614,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 11.3.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutexattr_init (pace_pthread_mutexattr_t * attr);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutexattr_init (pace_pthread_mutexattr_t * attr);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -590,8 +626,11 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 11.3.1.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_mutexattr_setpshared (pace_pthread_mutexattr_t * attr,
- int pshared);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_mutexattr_setpshared (pace_pthread_mutexattr_t * attr,
+ int pshared);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -624,7 +663,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 18.2.2.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_setcancelstate (int state, int * oldstate);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_setcancelstate (int state, int * oldstate);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -633,7 +675,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 18.2.2.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_setcanceltype (int type, int * oldtype);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_setcanceltype (int type, int * oldtype);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -642,9 +687,12 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 13.5.2.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_setschedparam (pace_pthread_t thread,
- int policy,
- const pace_sched_param * param);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_setschedparam (pace_pthread_t thread,
+ int policy,
+ const pace_sched_param * param);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -653,7 +701,10 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 17.1.2.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_setspecific (pace_pthread_key_t key, const void * value);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_setspecific (pace_pthread_key_t key, const void * value);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
@@ -662,9 +713,12 @@ extern "C" {
IEEE Std 1003.1, 1996 Edition), Section 3.3.5.
*/
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
- PACE_INLINE int pace_pthread_sigmask (int how,
- const pace_sigset_t * set,
- pace_sigset_t * oset);
+#if !(PACE_VXWORKS)
+ PACE_INLINE
+#endif
+ int pace_pthread_sigmask (int how,
+ const pace_sigset_t * set,
+ pace_sigset_t * oset);
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
/**
diff --git a/PACE/pace/vxworks/pthread.c b/PACE/pace/vxworks/pthread.c
index d34f496dc87..e8c980ba639 100644
--- a/PACE/pace/vxworks/pthread.c
+++ b/PACE/pace/vxworks/pthread.c
@@ -877,3 +877,426 @@ pace_pthread_once (pace_pthread_once_t * once_control,
}
# endif /* PACE_HAS_CPLUSPLUS */
#endif /* PACE_HAS_NONUOF_FUNCS */
+
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_attr_init (pace_pthread_attr_t * attr)
+{
+ /*
+ * Attempt to allocate memory for the attributes object.
+ */
+
+ if ((*attr = (pace_pthread_attr_t) malloc(sizeof(struct _PTHREAD_ATTR)))
+ == NULL)
+ {
+ return ERROR;
+ }
+
+ /*
+ * Set the default attributes.
+ */
+
+ memcpy ((void *)(*attr), (void *)pthread_attr_default,
+ sizeof(struct _PTHREAD_ATTR));
+
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_attr_setdetachstate (pace_pthread_attr_t * attr,
+ int detachstate)
+{
+ if ((detachstate != PTHREAD_CREATE_DETACHED) ||
+ (detachstate != PTHREAD_CREATE_JOINABLE))
+ {
+ (*attr)->dstate = PTHREAD_CREATE_DETACHED;
+ return ERROR;
+ }
+
+ (*attr)->dstate = detachstate;
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_attr_setschedparam (pace_pthread_attr_t * attr,
+ const pace_sched_param * param)
+{
+ /* range check */
+ if (param->sched_priority > SCHED_RR_HIGH_PRI ||
+ param->sched_priority < SCHED_RR_LOW_PRI )
+ {
+ return ERROR;
+ }
+
+ (*attr)->schedule.sched_priority = param->sched_priority;
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_cancel (pace_pthread_t thread)
+{
+ /*
+ * In VxWorks, to cancel a thread is to delete a task.
+ */
+ if (!pacevx_pthread_verify(thread))
+ return ESRCH;
+
+ if (taskIdVerify(thread->tid) == ERROR) /* already exit, never happen */
+ return ERROR;
+
+ if (thread->stateflag == PTHREAD_CANCEL_DISABLE)
+ return ERROR;
+ else
+ return (taskDelete(thread->tid));
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_getschedparam (pace_pthread_t thread,
+ int * policy,
+ pace_sched_param * param)
+{
+ if (thread == 0)
+ return ERROR;
+
+ *policy = sched_getscheduler(thread->tid);
+
+ if (sched_getparam(thread->tid, param) == OK)
+ {
+ /* convert VxWorks priority to POSIX priority */
+ param->sched_priority = SCHED_FIFO_HIGH_PRI - param->sched_priority;
+ return OK;
+ }
+
+ return ERROR;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+void *
+pace_pthread_getspecific (pace_pthread_key_t key)
+{
+ pace_pthread_t pthread;
+
+ if (!pacevx_pthread_key_validate(key))
+ return NULL;
+
+ if ((pthread = pace_pthread_self()) != NULL)
+ {
+ return pthread->keyvaluelist[key];
+ }
+
+ return NULL;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutex_init (pace_pthread_mutex_t * mutex,
+ const pace_pthread_mutexattr_t * attr)
+{
+ /*
+ * Initialises the mutex referenced by mutex with attributes
+ * specified by attr. If attr is NULL, the default mutex
+ * attributes are used.
+ */
+
+ /* Make SEM_Q_FIFO the default since this is what ACE does (and
+ * ACE works) plus this is supposedly the default for VxWorks.
+ */
+ int options = SEM_Q_FIFO;
+
+ if (attr != NULL)
+ {
+ switch ((*attr)->protocol)
+ {
+ case PTHREAD_PRIO_INHERIT:
+ /* POSIX's PTHREAD_PRIO_INHERIT maps to VxWorks' SEM_INVERSION_SAFE.
+ * However, this doesn't seem to be supported (at least on 5.3.1).
+ * Return an error.
+ */
+ return ERROR;
+ break;
+
+ case PTHREAD_PRIO_PROTECT:
+ /* VxWorks does not support this functionality.
+ * Return an error.
+ */
+ return ERROR;
+ break;
+
+ case PTHREAD_PRIO_NONE:
+ options = SEM_Q_FIFO;
+ break;
+
+ default:
+ perror("Invalid POSIX protocol specified");
+ return ERROR;
+ break;
+ }
+ }
+
+ *mutex = semMCreate(options);
+ if (*mutex == NULL) {
+ return ERROR;
+ }
+
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutex_lock (pace_pthread_mutex_t * mutex)
+{
+ STATUS status;
+ int errornumber;
+
+ status = semTake(*mutex, WAIT_FOREVER);
+ if (status == OK)
+ return OK;
+ else
+ {
+ errornumber = errnoGet();
+ if (errornumber == S_objLib_OBJ_ID_ERROR)
+ return EINVAL;
+
+ return ERROR;
+ }
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutex_trylock (pace_pthread_mutex_t * mutex)
+{
+ STATUS status;
+ int errornumber;
+
+ status = semTake(*mutex, NO_WAIT);
+ if (status == OK)
+ return OK;
+ else
+ {
+ errornumber = errnoGet();
+ if (errornumber == S_objLib_OBJ_ID_ERROR)
+ return EINVAL;
+ if (errornumber == S_objLib_OBJ_UNAVAILABLE)
+ return EBUSY;
+
+ return ERROR;
+ }
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutex_unlock (pace_pthread_mutex_t * mutex)
+{
+ STATUS status;
+ int errornumber;
+
+ status = semGive(*mutex);
+ if (status == OK)
+ return OK;
+ else
+ {
+ errornumber = errnoGet();
+ if (errornumber == S_semLib_INVALID_OPERATION)
+ return EPERM;
+
+ return ERROR;
+ }
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutexattr_setprotocol (pace_pthread_mutexattr_t * attr,
+ int protocol)
+{
+/*
+ * Does not support PTHREAD_PRIO_PROTECT for VxWorks
+ */
+ if ((protocol == PTHREAD_PRIO_NONE) ||
+ (protocol == PTHREAD_PRIO_INHERIT ))
+ {
+ (*attr)->protocol = protocol;
+ return OK;
+ }
+
+ return ERROR;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutexattr_init (pace_pthread_mutexattr_t * attr)
+{
+ /*
+ * Initializes a mutex attributes object attr with the
+ * default value for all of the attributes
+ */
+ pace_pthread_mutexattr_t pattr;
+ pattr = (pace_pthread_mutexattr_t) malloc(sizeof(struct _PTHREAD_MUX_ATTR));
+ if (pattr == NULL)
+ return ERROR;
+
+ /* POSIX's PTHREAD_PRIO_INHERIT maps to VxWorks' SEM_INVERSION_SAFE.
+ * However, this doesn't seem to be supported (at least on 5.3.1).
+ * Set PTHREAD_PRIO_NONE as the default since the only other choice
+ * is PTHREAD_PRIO_PROTECT which VxWorks doesn't support.
+ pattr->protocol = PTHREAD_PRIO_INHERIT;
+ */
+ pattr->protocol = PTHREAD_PRIO_NONE;
+ pattr->shared = PTHREAD_PROCESS_SHARED;
+ pattr->type = PTHREAD_MUTEX_DEFAULT;
+
+ *attr = pattr;
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_mutexattr_setpshared (pace_pthread_mutexattr_t * attr,
+ int pshared)
+{
+ /*
+ * Only supports PTHREAD_PROCESS_SHARED
+ */
+ if (attr == 0) return EINVAL;
+
+ if (pshared != PTHREAD_PROCESS_SHARED)
+ return ERROR;
+ else
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_setcancelstate (int state, int * oldstate)
+{
+ int key;
+ pace_pthread_t pthread;
+
+ if ((state != PTHREAD_CANCEL_ENABLE) &&
+ (state != PTHREAD_CANCEL_DISABLE))
+ {
+ return ERROR;
+ }
+
+ if ((pthread = pace_pthread_self()) == NULL)
+ return ERROR;
+
+ key = intLock();
+ *oldstate = pthread->stateflag;
+ pthread->stateflag = state;
+ intUnlock(key);
+
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_setcanceltype (int type, int * oldtype)
+{
+ /*
+ * Only asychronouse type is supported
+ */
+ pace_pthread_t pthread;
+
+ if (type != PTHREAD_CANCEL_ASYNCHRONOUS)
+ return ERROR;
+
+ if ((pthread = pace_pthread_self()) == NULL)
+ return ERROR;
+
+ *oldtype = pthread->canceltype;
+
+ return OK;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_setschedparam (pace_pthread_t thread,
+ int policy,
+ const pace_sched_param * param)
+{
+ /*
+ * Only priority can be changed.
+ */
+ struct sched_param sparam;
+
+ if (thread == 0)
+ return ERROR;
+
+ if (policy != sched_getscheduler(thread->tid))
+ return ERROR;
+
+ /* convert POSIX priority to VxWorks priority */
+ sparam.sched_priority = SCHED_FIFO_HIGH_PRI - param->sched_priority;
+
+ return (sched_setparam(thread->tid, &sparam));
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_setspecific (pace_pthread_key_t key, const void * value)
+{
+ pace_pthread_t pthread;
+
+ if (!pacevx_pthread_key_validate(key))
+ return ERROR;
+
+ if ((pthread = pace_pthread_self()) != NULL)
+ {
+ pthread->keyvaluelist[key] = PACE_NONCONST_ARG_CAST(void *) value;
+ return OK;
+ }
+
+ return ERROR;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
+
+#if (PACE_HAS_POSIX_NONUOF_FUNCS)
+int
+pace_pthread_sigmask (int how, const sigset_t * set,
+ sigset_t * oset)
+{
+ switch (how)
+ {
+ case SIG_BLOCK:
+ case SIG_UNBLOCK:
+ {
+ /* get the old mask */
+ *oset = sigsetmask (*set);
+ /* create a new mask: the following assumes that sigset_t is 4 bytes,
+ * which it is on VxWorks 5.2, so bit operations are done simply . . .
+ */
+ sigsetmask (how == SIG_BLOCK ? (*oset |= *set) : (*oset &= ~*set));
+ break;
+ }
+ case SIG_SETMASK:
+ *oset = sigsetmask (*set);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+#endif /* PACE_HAS_NONUOF_FUNCS */
diff --git a/PACE/pace/vxworks/pthread.inl b/PACE/pace/vxworks/pthread.inl
index ccef569d001..abed12fb392 100644
--- a/PACE/pace/vxworks/pthread.inl
+++ b/PACE/pace/vxworks/pthread.inl
@@ -17,6 +17,8 @@
#include "pace/unistd.h"
+#include "pace/stdio.h"
+
/*
* PACE - POSIX Functions
*/
@@ -165,50 +167,6 @@ pace_pthread_attr_getstacksize (const pace_pthread_attr_t * attr,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_attr_init (pace_pthread_attr_t * attr)
-{
- /*
- * Attempt to allocate memory for the attributes object.
- */
-
- if ((*attr = (pace_pthread_attr_t) malloc(sizeof(struct _PTHREAD_ATTR)))
- == NULL)
- {
- return ERROR;
- }
-
- /*
- * Set the default attributes.
- */
-
- memcpy ((void *)(*attr), (void *)pthread_attr_default,
- sizeof(struct _PTHREAD_ATTR));
-
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_attr_setdetachstate (pace_pthread_attr_t * attr,
- int detachstate)
-{
- if ((detachstate != PTHREAD_CREATE_DETACHED) ||
- (detachstate != PTHREAD_CREATE_JOINABLE))
- {
- (*attr)->dstate = PTHREAD_CREATE_DETACHED;
- return ERROR;
- }
-
- (*attr)->dstate = detachstate;
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_attr_setinheritsched (pace_pthread_attr_t * attr,
int inheritsched)
{
@@ -228,24 +186,6 @@ pace_pthread_attr_setinheritsched (pace_pthread_attr_t * attr,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_attr_setschedparam (pace_pthread_attr_t * attr,
- const pace_sched_param * param)
-{
- /* range check */
- if (param->sched_priority > SCHED_RR_HIGH_PRI ||
- param->sched_priority < SCHED_RR_LOW_PRI )
- {
- return ERROR;
- }
-
- (*attr)->schedule.sched_priority = param->sched_priority;
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_attr_setschedpolicy (pace_pthread_attr_t * attr,
int policy)
{
@@ -318,27 +258,6 @@ pace_pthread_attr_setstacksize (pace_pthread_attr_t * attr,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_cancel (pace_pthread_t thread)
-{
- /*
- * In VxWorks, to cancel a thread is to delete a task.
- */
- if (!pacevx_pthread_verify(thread))
- return ESRCH;
-
- if (taskIdVerify(thread->tid) == ERROR) /* already exit, never happen */
- return ERROR;
-
- if (thread->stateflag == PTHREAD_CANCEL_DISABLE)
- return ERROR;
- else
- return (taskDelete(thread->tid));
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_cond_broadcast (pace_pthread_cond_t * cond)
{
/*
@@ -471,48 +390,6 @@ pace_pthread_exit (void * value_ptr)
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_getschedparam (pace_pthread_t thread,
- int * policy,
- pace_sched_param * param)
-{
- if (thread == 0)
- return ERROR;
-
- *policy = sched_getscheduler(thread->tid);
-
- if (sched_getparam(thread->tid, param) == OK)
- {
- /* convert VxWorks priority to POSIX priority */
- param->sched_priority = SCHED_FIFO_HIGH_PRI - param->sched_priority;
- return OK;
- }
-
- return ERROR;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-void *
-pace_pthread_getspecific (pace_pthread_key_t key)
-{
- pace_pthread_t pthread;
-
- if (!pacevx_pthread_key_validate(key))
- return NULL;
-
- if ((pthread = pace_pthread_self()) != NULL)
- {
- return pthread->keyvaluelist[key];
- }
-
- return NULL;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_kill (pace_pthread_t thread, int sig)
{
if (pacevx_pthread_verify(thread))
@@ -553,55 +430,6 @@ pace_pthread_mutex_getprioceiling (pace_pthread_mutex_t * mutex,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_mutex_init (pace_pthread_mutex_t * mutex,
- const pace_pthread_mutexattr_t * attr)
-{
- /*
- * Initialises the mutex referenced by mutex with attributes
- * specified by attr. If attr is NULL, the default mutex
- * attributes are used.
- */
- int options = 0;
-
- if (attr != NULL)
- {
- if((*attr)->protocol == PTHREAD_PRIO_INHERIT)
- options = SEM_INVERSION_SAFE;
- }
-
- *mutex = semMCreate(options);
- if (*mutex == NULL)
- return ERROR;
-
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_mutex_lock (pace_pthread_mutex_t * mutex)
-{
- STATUS status;
- int errornumber;
-
- status = semTake(*mutex, WAIT_FOREVER);
- if (status == OK)
- return OK;
- else
- {
- errornumber = errnoGet();
- if (errornumber == S_objLib_OBJ_ID_ERROR)
- return EINVAL;
-
- return ERROR;
- }
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_mutex_setprioceiling (pace_pthread_mutex_t * mutex,
int prioceiling,
int * old_ceiling)
@@ -623,52 +451,6 @@ pace_pthread_mutex_setprioceiling (pace_pthread_mutex_t * mutex,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_mutex_trylock (pace_pthread_mutex_t * mutex)
-{
- STATUS status;
- int errornumber;
-
- status = semTake(*mutex, NO_WAIT);
- if (status == OK)
- return OK;
- else
- {
- errornumber = errnoGet();
- if (errornumber == S_objLib_OBJ_ID_ERROR)
- return EINVAL;
- if (errornumber == S_objLib_OBJ_UNAVAILABLE)
- return EBUSY;
-
- return ERROR;
- }
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_mutex_unlock (pace_pthread_mutex_t * mutex)
-{
- STATUS status;
- int errornumber;
-
- status = semGive(*mutex);
- if (status == OK)
- return OK;
- else
- {
- errornumber = errnoGet();
- if (errornumber == S_semLib_INVALID_OPERATION)
- return EPERM;
-
- return ERROR;
- }
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_mutexattr_destroy (pace_pthread_mutexattr_t * attr)
{
free(*attr);
@@ -730,26 +512,6 @@ pace_pthread_mutexattr_setprioceiling (pace_pthread_mutexattr_t * attr,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
int
-pace_pthread_mutexattr_setprotocol (pace_pthread_mutexattr_t * attr,
- int protocol)
-{
-/*
- * Does not support PTHREAD_PRIO_PROTECT for VxWorks
- */
- if ((protocol == PTHREAD_PRIO_NONE) ||
- (protocol == PTHREAD_PRIO_INHERIT ))
- {
- (*attr)->protocol = protocol;
- return OK;
- }
-
- return ERROR;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
pace_pthread_mutexattr_getpshared (const pace_pthread_mutexattr_t * attr,
int * pshared)
{
@@ -763,47 +525,6 @@ pace_pthread_mutexattr_getpshared (const pace_pthread_mutexattr_t * attr,
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
-int
-pace_pthread_mutexattr_init (pace_pthread_mutexattr_t * attr)
-{
- /*
- * Initializes a mutex attributes object attr with the
- * default value for all of the attributes
- */
- pace_pthread_mutexattr_t pattr;
- pattr = (pace_pthread_mutexattr_t) malloc(sizeof(struct _PTHREAD_MUX_ATTR));
- if (pattr == NULL)
- return ERROR;
-
- pattr->protocol = PTHREAD_PRIO_INHERIT;
- pattr->shared = PTHREAD_PROCESS_SHARED;
- pattr->type = PTHREAD_MUTEX_DEFAULT;
-
- *attr = pattr;
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_mutexattr_setpshared (pace_pthread_mutexattr_t * attr,
- int pshared)
-{
- /*
- * Only supports PTHREAD_PROCESS_SHARED
- */
- if (attr == 0) return EINVAL;
-
- if (pshared != PTHREAD_PROCESS_SHARED)
- return ERROR;
- else
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
pace_pthread_t
pace_pthread_self ()
{
@@ -818,129 +539,6 @@ pace_pthread_self ()
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
PACE_INLINE
-int
-pace_pthread_setcancelstate (int state, int * oldstate)
-{
- int key;
- pace_pthread_t pthread;
-
- if ((state != PTHREAD_CANCEL_ENABLE) &&
- (state != PTHREAD_CANCEL_DISABLE))
- {
- return ERROR;
- }
-
- if ((pthread = pace_pthread_self()) == NULL)
- return ERROR;
-
- key = intLock();
- *oldstate = pthread->stateflag;
- pthread->stateflag = state;
- intUnlock(key);
-
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_setcanceltype (int type, int * oldtype)
-{
- /*
- * Only asychronouse type is supported
- */
- pace_pthread_t pthread;
-
- if (type != PTHREAD_CANCEL_ASYNCHRONOUS)
- return ERROR;
-
- if ((pthread = pace_pthread_self()) == NULL)
- return ERROR;
-
- *oldtype = pthread->canceltype;
-
- return OK;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_setschedparam (pace_pthread_t thread,
- int policy,
- const pace_sched_param * param)
-{
- /*
- * Only priority can be changed.
- */
- struct sched_param sparam;
-
- if (thread == 0)
- return ERROR;
-
- if (policy != sched_getscheduler(thread->tid))
- return ERROR;
-
- /* convert POSIX priority to VxWorks priority */
- sparam.sched_priority = SCHED_FIFO_HIGH_PRI - param->sched_priority;
-
- return (sched_setparam(thread->tid, &sparam));
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_setspecific (pace_pthread_key_t key, const void * value)
-{
- pace_pthread_t pthread;
-
- if (!pacevx_pthread_key_validate(key))
- return ERROR;
-
- if ((pthread = pace_pthread_self()) != NULL)
- {
- pthread->keyvaluelist[key] = PACE_NONCONST_ARG_CAST(void *) value;
- return OK;
- }
-
- return ERROR;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
-int
-pace_pthread_sigmask (int how, const sigset_t * set,
- sigset_t * oset)
-{
- switch (how)
- {
- case SIG_BLOCK:
- case SIG_UNBLOCK:
- {
- /* get the old mask */
- *oset = sigsetmask (*set);
- /* create a new mask: the following assumes that sigset_t is 4 bytes,
- * which it is on VxWorks 5.2, so bit operations are done simply . . .
- */
- sigsetmask (how == SIG_BLOCK ? (*oset |= *set) : (*oset &= ~*set));
- break;
- }
- case SIG_SETMASK:
- *oset = sigsetmask (*set);
- break;
- default:
- return -1;
- }
-
- return 0;
-}
-#endif /* PACE_HAS_NONUOF_FUNCS */
-
-#if (PACE_HAS_POSIX_NONUOF_FUNCS)
-PACE_INLINE
void
pace_pthread_testcancel ()
{
diff --git a/PACE/pace/vxworks/signal.inl b/PACE/pace/vxworks/signal.inl
index c78e9ca9620..76b34e90df4 100644
--- a/PACE/pace/vxworks/signal.inl
+++ b/PACE/pace/vxworks/signal.inl
@@ -148,8 +148,20 @@ PACE_INLINE
int
pace_sigwait (const pace_sigset_t * set, int * sig)
{
- PACE_UNUSED_ARG (sig);
- return sigwait (PACE_NONCONST_ARG_CAST (pace_sigset_t *) set);
+ /* It appears that sigwait is not supported for 5.3.1 or 5.4.
+ * ACE uses sigtimedwait instead. (The code below is directly
+ * from ACE_OS.
+ * This is the call that should be made if VxWorks supported
+ * sigwait:
+ PACE_UNUSED_ARG (sig);
+ return sigwait (set);
+
+ * Second arg is a struct siginfo *, which we don't need (the
+ * selected signal number is returned). Third arg is timeout: 0
+ * means forever.
+ */
+ *sig = sigtimedwait (set, 0, 0);
+ return *sig;
}
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */
diff --git a/PACE/pace/vxworks/utsname.h b/PACE/pace/vxworks/utsname.h
index 95eeab7d968..6773129303a 100644
--- a/PACE/pace/vxworks/utsname.h
+++ b/PACE/pace/vxworks/utsname.h
@@ -16,7 +16,6 @@
#ifndef PACE_SYS_UTSNAME_H_VXWORKS
#define PACE_SYS_UTSNAME_H_VXWORKS
-#include <sys/utsname.h>
#include "pace/stddef.h"
#if defined (PACE_HAS_CPLUSPLUS)