15
15
#include <pthread.h>
16
16
#ifdef __linux__
17
17
#define __USE_GNU
18
- #include <dlfcn.h>
19
18
#endif
19
+ #include <dlfcn.h>
20
20
#include <semaphore.h>
21
21
#ifdef __linux__
22
22
#include <fcntl.h>
@@ -77,10 +77,7 @@ typedef struct _timer {
77
77
#endif
78
78
79
79
// local forward defines
80
- static void stl_error (const char * fmt , ...);
81
80
static void stl_thread_wrapper ( thread * tp , int32_t arg );
82
- static char * stralloc (char * s );
83
- static void * get_functionptr (char * name );
84
81
extern int errno ;
85
82
86
83
// local data
@@ -165,7 +162,7 @@ stl_thread_create(char *name, int32_t arg)
165
162
thread * p , * tp = NULL ;
166
163
167
164
// map function name to a pointer
168
- f = (void * (* )(int32_t )) get_functionptr (name );
165
+ f = (void * (* )(int32_t )) stl_get_functionptr (name );
169
166
if (f == NULL )
170
167
stl_error ("thread named [%s] not found" , name );
171
168
@@ -183,7 +180,7 @@ stl_thread_create(char *name, int32_t arg)
183
180
if (tp == NULL)
184
181
stl_error ("too many threads, increase NTHREADS (currently %d)" , NTHREADS );
185
182
186
- tp -> name = stralloc (name );
183
+ tp -> name = stl_stralloc (name );
187
184
tp -> f = f ;
188
185
tp -> arg = arg ;
189
186
@@ -294,7 +291,7 @@ stl_sem_create(char *name)
294
291
stl_error ("sem: failed %s" , strerror (errno ));
295
292
296
293
sp -> sem = sem ;
297
- sp -> name = stralloc (name );
294
+ sp -> name = stl_stralloc (name );
298
295
299
296
STL_DEBUG ("creating semaphore #%d <%s>" , slot , name );
300
297
@@ -470,7 +467,7 @@ stl_timer_create(char *name, double interval, int32_t semid)
470
467
stl_error ("timer create: failed %s" , strerror (errno ));
471
468
472
469
tp -> timer = t ;
473
- tp -> name = stralloc (name );
470
+ tp -> name = stl_stralloc (name );
474
471
475
472
// set the interval and activate the timer
476
473
struct timespec ts ;
@@ -490,8 +487,8 @@ stl_timer_create(char *name, double interval, int32_t semid)
490
487
}
491
488
#endif
492
489
493
- static char *
494
- stralloc (char * s )
490
+ char *
491
+ stl_stralloc (char * s )
495
492
{
496
493
char * n = (char * )malloc (strlen (s )+ 1 );
497
494
strcpy (n , s );
@@ -544,8 +541,8 @@ stl_log(const char *fmt, ...)
544
541
fputs (buf , stderr );
545
542
}
546
543
547
- static void *
548
- get_functionptr (char * name )
544
+ void *
545
+ stl_get_functionptr (char * name )
549
546
{
550
547
#ifdef __linux__
551
548
// this is ugly, but I can't figure how to make dlopen/dlsym work here
0 commit comments