Commit 85c37c99 authored by yoogx's avatar yoogx
Browse files

* Minor reformatting, hack for OS X

parent 1d305f28
......@@ -97,6 +97,7 @@ void __po_hi_gqueue_init (__po_hi_task_id id,
__po_hi_uint8_t tmp;
__po_hi_uint16_t off;
__po_hi_request_t* request;
int err;
#if defined (RTEMS_PURE)
rtems_status_code ret;
......@@ -128,13 +129,19 @@ void __po_hi_gqueue_init (__po_hi_task_id id,
__po_hi_gqueues_queue_is_empty[id] = 1;
#if defined (RTEMS_POSIX) || defined (POSIX) || defined (XENO_POSIX)
pthread_mutexattr_init (&__po_hi_gqueues_mutexes_attr[id]);
pthread_condattr_init (&__po_hi_gqueues_conds_attr[id]);
err = pthread_mutexattr_init (&__po_hi_gqueues_mutexes_attr[id]);
__DEBUGMSG("MUTEX_INIT %d %d\n", id, err);
err = pthread_condattr_init (&__po_hi_gqueues_conds_attr[id]);
__DEBUGMSG("MUTEX_INIT %d %d\n", id, err);
#if defined (POSIX) || defined (XENO_POSIX)
pthread_mutexattr_setpshared(&__po_hi_gqueues_mutexes_attr[id],PTHREAD_PROCESS_SHARED);
// XXX disabled for OS X
// err = pthread_mutexattr_setpshared(&__po_hi_gqueues_mutexes_attr[id],PTHREAD_PROCESS_SHARED);
__DEBUGMSG("MUTEX_INIT %d\n", err);
#endif
pthread_mutex_init (&__po_hi_gqueues_mutexes[id], &__po_hi_gqueues_mutexes_attr[id]);
pthread_cond_init (&__po_hi_gqueues_conds[id], &__po_hi_gqueues_conds_attr[id]);
err = pthread_mutex_init (&__po_hi_gqueues_mutexes[id], &__po_hi_gqueues_mutexes_attr[id]);
__DEBUGMSG("MUTEX_INIT %d %d\n", id, err);
err = pthread_cond_init (&__po_hi_gqueues_conds[id], &__po_hi_gqueues_conds_attr[id]);
__DEBUGMSG("COND_INIT %d %d\n", id, err);
#endif
#ifdef RTEMS_PURE
......@@ -275,6 +282,7 @@ __po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
#endif
if (__po_hi_gqueues_used_size[id][port] == __po_hi_gqueues_sizes[id][port])
{
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_mutex_unlock (&__po_hi_gqueues_mutexes[id]);
#elif defined (XENO_NATIVE)
......@@ -319,7 +327,8 @@ __po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_mutex_unlock (&__po_hi_gqueues_mutexes[id]);
pthread_cond_broadcast (&__po_hi_gqueues_conds[id]);
int err = pthread_cond_signal (&__po_hi_gqueues_conds[id]);
__DEBUGMSG("*** Releasing (%d) %d\n", id, err);
#elif defined (XENO_NATIVE)
rt_mutex_release (&__po_hi_gqueues_mutexes[id]);
rt_cond_broadcast (&__po_hi_gqueues_conds[id]);
......@@ -338,6 +347,7 @@ __po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
__DEBUGMSG ("[GQUEUE] Semaphore released (id=%d)\n", id);
#endif
__DEBUGMSG ("[GQUEUE] store_in completed\n");
return __PO_HI_SUCCESS;
}
......@@ -352,10 +362,9 @@ void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
DWORD ret;
#endif
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_mutex_lock (&__po_hi_gqueues_mutexes[id]);
int error = pthread_mutex_lock (&__po_hi_gqueues_mutexes[id]);
__DEBUGMSG("*** Locking (%d) %d\n", id, error);
#elif defined (XENO_NATIVE)
rt_mutex_acquire (&__po_hi_gqueues_mutexes[id], TM_INFINITE);
#elif defined (RTEMS_PURE)
......@@ -370,12 +379,13 @@ void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
while(__po_hi_gqueues_queue_is_empty[id] == 1)
{
__PO_HI_INSTRUMENTATION_VCD_WRITE("0t%d\n", id);
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_cond_wait (&__po_hi_gqueues_conds[id],
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
__DEBUGMSG("*** Waiting (%d)\n", id);
int error = pthread_cond_wait (&__po_hi_gqueues_conds[id],
&__po_hi_gqueues_mutexes[id]);
__DEBUGMSG("*** Done Waiting (%d) %d\n", id, error);
#elif defined (XENO_NATIVE)
rt_cond_wait (&__po_hi_gqueues_conds[id], &__po_hi_gqueues_mutexes[id], TM_INFINITE);
#elif defined (RTEMS_PURE)
......@@ -408,6 +418,7 @@ void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
__PO_HI_INSTRUMENTATION_VCD_WRITE("1t%d\n", id);
}
__DEBUGMSG ("[GQUEUE] Gogo kiki\n");
*port = __po_hi_gqueues_global_history[id][__po_hi_gqueues_global_history_offset[id]];
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
......@@ -635,4 +646,3 @@ __po_hi_port_t __po_hi_gqueue_get_destination (const __po_hi_task_id task_id, co
{
return (__po_hi_gqueues_destinations[task_id][local_port][destination_number]);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment