aboutsummaryrefslogtreecommitdiff
path: root/threadlib/src
diff options
context:
space:
mode:
authorGeorg Holzmann <grholzi@users.sourceforge.net>2007-08-25 22:21:14 +0000
committerGeorg Holzmann <grholzi@users.sourceforge.net>2007-08-25 22:21:14 +0000
commit97e0380aeb1807103130b686fcaff746b662a002 (patch)
treefff9f25012148f0b5a4ca0c690f57ca0c18f4a34 /threadlib/src
parentb9c9f9e137910daedb09a363f102eb688aeb77d6 (diff)
fixed a nameclash with libaviplay which crashed pd when GEM was loaded
before threadlib svn path=/trunk/externals/grh/; revision=8691
Diffstat (limited to 'threadlib/src')
-rwxr-xr-xthreadlib/src/callbacks.c8
-rwxr-xr-xthreadlib/src/detach.c24
-rwxr-xr-xthreadlib/src/fifo.c22
-rwxr-xr-xthreadlib/src/threadlib.c2
-rwxr-xr-xthreadlib/src/threadlib.h8
5 files changed, 31 insertions, 33 deletions
diff --git a/threadlib/src/callbacks.c b/threadlib/src/callbacks.c
index 7bf4a19..a1b0f88 100755
--- a/threadlib/src/callbacks.c
+++ b/threadlib/src/callbacks.c
@@ -31,14 +31,14 @@ static void h_run_callbacks();
void h_init_callbacks()
{
- h_callback_fifo = fifo_init();
+ h_callback_fifo = threadlib_fifo_init();
h_callback_clock = clock_new(NULL, (t_method)h_run_callbacks);
}
void h_free_callbacks()
{
clock_free(h_callback_clock);
- fifo_destroy(h_callback_fifo);
+ threadlib_fifo_destroy(h_callback_fifo);
}
void sys_callback(t_int (*callback) (t_int* argv), t_int* argv, t_int argc)
@@ -51,7 +51,7 @@ void sys_callback(t_int (*callback) (t_int* argv), t_int* argv, t_int argc)
new->argc = argc;
new->next = NULL;
- fifo_put(h_callback_fifo, new);
+ threadlib_fifo_put(h_callback_fifo, new);
// TODO find solution without lock
sys_lock();
@@ -69,7 +69,7 @@ void h_run_callbacks()
/* append idle callback to ringbuffer */
- while ( (new_callback = (t_sched_callback*) fifo_get(h_callback_fifo)) )
+ while ( (new_callback = (t_sched_callback*) threadlib_fifo_get(h_callback_fifo)) )
{
t_sched_callback * next;
diff --git a/threadlib/src/detach.c b/threadlib/src/detach.c
index b92c7af..fc5229c 100755
--- a/threadlib/src/detach.c
+++ b/threadlib/src/detach.c
@@ -62,7 +62,7 @@ static void detach_thread(detach_t* x)
{
pthread_cond_wait(&x->x_cond, &x->x_mutex);
- me = (detach_content_t*) fifo_get(x->x_fifo);
+ me = (detach_content_t*) threadlib_fifo_get(x->x_fifo);
while (me != NULL)
{
@@ -97,7 +97,7 @@ static void detach_thread(detach_t* x)
if (me->argc)
freebytes(me->argv, me->argc * sizeof (t_atom));
freebytes (me, sizeof(detach_content_t));
- me = (detach_content_t*) fifo_get(x->x_fifo);
+ me = (detach_content_t*) threadlib_fifo_get(x->x_fifo);
}
}
@@ -109,9 +109,9 @@ static void detach_thread(detach_t* x)
freebytes(me->argv, me->argc * sizeof (t_atom));
freebytes (me, sizeof(detach_content_t));
}
- while ( (me = (detach_content_t*) fifo_get(x->x_fifo)) );
+ while ( (me = (detach_content_t*) threadlib_fifo_get(x->x_fifo)) );
- fifo_destroy(x->x_fifo);
+ threadlib_fifo_destroy(x->x_fifo);
pthread_mutex_destroy(&x->x_mutex);
pthread_cond_destroy(&x->x_cond);
return;
@@ -124,7 +124,7 @@ static detach_t * detach_new()
int status;
x->x_outlet = outlet_new(&x->x_obj, NULL);
- x->x_fifo = fifo_init();
+ x->x_fifo = threadlib_fifo_init();
/* thread initialisation */
pthread_mutex_init (&x->x_mutex,NULL);
@@ -146,7 +146,7 @@ static void detach_free(detach_t * x)
me->type = CANCEL;
me->argc = 0;
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
@@ -156,7 +156,7 @@ static void detach_bang(detach_t * x)
me->type = BANG;
me->argc = 0;
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
@@ -169,7 +169,7 @@ static void detach_float(detach_t * x, t_float f)
me->argc = 1;
me->argv = getbytes(sizeof(t_atom));
SETFLOAT(me->argv, f);
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
@@ -182,7 +182,7 @@ static void detach_pointer(detach_t * x, t_gpointer* gp)
me->argc = 1;
me->argv = getbytes(sizeof(t_atom));
SETPOINTER(me->argv, gp);
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
@@ -195,7 +195,7 @@ static void detach_symbol(detach_t * x, t_symbol * s)
me->argc = 1;
me->argv = getbytes(sizeof(t_atom));
SETSYMBOL(me->argv, s);
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
@@ -207,7 +207,7 @@ static void detach_list(detach_t * x, t_symbol * s, int argc, t_atom* argv)
me->type = LIST;
me->argc = argc;
me->argv = copybytes(argv, argc * sizeof(t_atom));
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
@@ -220,7 +220,7 @@ static void detach_anything(detach_t * x, t_symbol * s, int argc, t_atom* argv)
me->argc = argc;
me->argv = copybytes(argv, argc * sizeof(t_atom));
me->symbol = s;
- fifo_put(x->x_fifo, me);
+ threadlib_fifo_put(x->x_fifo, me);
pthread_cond_broadcast(&x->x_cond);
}
diff --git a/threadlib/src/fifo.c b/threadlib/src/fifo.c
index daad265..50de821 100755
--- a/threadlib/src/fifo.c
+++ b/threadlib/src/fifo.c
@@ -32,7 +32,7 @@ struct _fifo
};
-t_fifo * fifo_init()
+t_fifo * threadlib_fifo_init()
{
t_fifo* ret = (t_fifo*) getbytes(sizeof (t_fifo));
t_fifocell * fifo_begin = (t_fifocell*) getbytes (sizeof (t_fifocell) );
@@ -50,13 +50,13 @@ t_fifo * fifo_init()
return ret;
}
-void fifo_destroy(t_fifo* fifo)
+void threadlib_fifo_destroy(t_fifo* fifo)
{
void * data;
do
{
- data = fifo_get(fifo);
+ data = threadlib_fifo_get(fifo);
}
while (data != NULL);
@@ -68,7 +68,7 @@ void fifo_destroy(t_fifo* fifo)
}
/* fifo_put and fifo_get are the only threadsafe functions!!! */
-void fifo_put(t_fifo* fifo, void* data)
+void threadlib_fifo_put(t_fifo* fifo, void* data)
{
if (data != NULL)
{
@@ -90,7 +90,7 @@ void fifo_put(t_fifo* fifo, void* data)
/* this fifo_get returns NULL if the fifo is empty
* or locked by another thread */
-void* fifo_get(t_fifo* fifo)
+void* threadlib_fifo_get(t_fifo* fifo)
{
t_fifocell * cell;
void* data;
@@ -121,7 +121,7 @@ void* fifo_get(t_fifo* fifo)
#else /* THREADLIB_LOCKFREE */
/*
- lockfree fifo adapted from the midishare: Copyright © Grame 1999
+ lockfree fifo adapted from the midishare: Copyright � Grame 1999
Grame Research Laboratory, 9, rue du Garet 69001 Lyon - France
grame@rd.grame.fr
*/
@@ -454,7 +454,7 @@ static void lifo_init(t_lifo* lifo)
lifo->oc = 0;
}
-t_fifo* fifo_init(void)
+t_fifo* threadlib_fifo_init(void)
{
t_fifo* ret = (t_fifo*) getbytes(sizeof(t_fifo));
@@ -465,12 +465,12 @@ t_fifo* fifo_init(void)
}
-void fifo_destroy(t_fifo* fifo)
+void threadlib_fifo_destroy(t_fifo* fifo)
{
void * data;
do
{
- data = fifo_get(fifo);
+ data = threadlib_fifo_get(fifo);
}
while (data != NULL);
@@ -478,12 +478,12 @@ void fifo_destroy(t_fifo* fifo)
return;
}
-void fifo_put(t_fifo* fifo, void* data)
+void threadlib_fifo_put(t_fifo* fifo, void* data)
{
lifo_push(&fifo->in, data);
}
-void* fifo_get(t_fifo* fifo)
+void* threadlib_fifo_get(t_fifo* fifo)
{
void * data;
t_lifo *out = &fifo->out;
diff --git a/threadlib/src/threadlib.c b/threadlib/src/threadlib.c
index 6cdf1af..47ec0b7 100755
--- a/threadlib/src/threadlib.c
+++ b/threadlib/src/threadlib.c
@@ -73,6 +73,4 @@ void threadlib_setup(void)
threadlib_class = class_new(gensym("threadlib"), threadlib_new, 0,
sizeof(t_threadlib), 0, 0);
class_addmethod(threadlib_class, (t_method)threadlib_help, gensym("help"), 0);
-
- return 0;
}
diff --git a/threadlib/src/threadlib.h b/threadlib/src/threadlib.h
index b94fc93..efbeeff 100755
--- a/threadlib/src/threadlib.h
+++ b/threadlib/src/threadlib.h
@@ -55,12 +55,12 @@ EXTERN_STRUCT _fifo;
#define t_fifo struct _fifo
/* function prototypes */
-THREADLIB_EXTERN t_fifo * fifo_init(void);
-THREADLIB_EXTERN void fifo_destroy(t_fifo*);
+THREADLIB_EXTERN t_fifo * threadlib_fifo_init(void);
+THREADLIB_EXTERN void threadlib_fifo_destroy(t_fifo*);
/* fifo_put() and fifo_get are the only threadsafe functions!!! */
-THREADLIB_EXTERN void fifo_put(t_fifo*, void*);
-THREADLIB_EXTERN void* fifo_get(t_fifo*);
+THREADLIB_EXTERN void threadlib_fifo_put(t_fifo*, void*);
+THREADLIB_EXTERN void* threadlib_fifo_get(t_fifo*);
/* --------- callback FIFO of pd devel ----------- */