Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1ff8ff1

Browse filesBrowse files
committed
Make some local functions global
required by web server add stl_ prefix to names for uniqueness
1 parent c20a6bf commit 1ff8ff1
Copy full SHA for 1ff8ff1

File tree

2 files changed

+12
-12
lines changed
Filter options

2 files changed

+12
-12
lines changed

‎stl/stl.c

Copy file name to clipboardExpand all lines: stl/stl.c
+9-12Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <pthread.h>
1616
#ifdef __linux__
1717
#define __USE_GNU
18-
#include <dlfcn.h>
1918
#endif
19+
#include <dlfcn.h>
2020
#include <semaphore.h>
2121
#ifdef __linux__
2222
#include <fcntl.h>
@@ -77,10 +77,7 @@ typedef struct _timer {
7777
#endif
7878

7979
// local forward defines
80-
static void stl_error(const char *fmt, ...);
8180
static void stl_thread_wrapper( thread *tp, int32_t arg);
82-
static char * stralloc(char *s);
83-
static void * get_functionptr(char *name);
8481
extern int errno;
8582

8683
// local data
@@ -165,7 +162,7 @@ stl_thread_create(char *name, int32_t arg)
165162
thread *p, *tp = NULL;
166163

167164
// map function name to a pointer
168-
f = (void *(*)(int32_t)) get_functionptr(name);
165+
f = (void *(*)(int32_t)) stl_get_functionptr(name);
169166
if (f == NULL)
170167
stl_error("thread named [%s] not found", name);
171168

@@ -183,7 +180,7 @@ stl_thread_create(char *name, int32_t arg)
183180
if (tp == NULL)
184181
stl_error("too many threads, increase NTHREADS (currently %d)", NTHREADS);
185182

186-
tp->name = stralloc(name);
183+
tp->name = stl_stralloc(name);
187184
tp->f = f;
188185
tp->arg = arg;
189186

@@ -294,7 +291,7 @@ stl_sem_create(char *name)
294291
stl_error("sem: failed %s", strerror(errno));
295292

296293
sp->sem = sem;
297-
sp->name = stralloc(name);
294+
sp->name = stl_stralloc(name);
298295

299296
STL_DEBUG("creating semaphore #%d <%s>", slot, name);
300297

@@ -470,7 +467,7 @@ stl_timer_create(char *name, double interval, int32_t semid)
470467
stl_error("timer create: failed %s", strerror(errno));
471468

472469
tp->timer = t;
473-
tp->name = stralloc(name);
470+
tp->name = stl_stralloc(name);
474471

475472
// set the interval and activate the timer
476473
struct timespec ts;
@@ -490,8 +487,8 @@ stl_timer_create(char *name, double interval, int32_t semid)
490487
}
491488
#endif
492489

493-
static char *
494-
stralloc(char *s)
490+
char *
491+
stl_stralloc(char *s)
495492
{
496493
char *n = (char *)malloc(strlen(s)+1);
497494
strcpy(n, s);
@@ -544,8 +541,8 @@ stl_log(const char *fmt, ...)
544541
fputs(buf, stderr);
545542
}
546543

547-
static void *
548-
get_functionptr(char *name)
544+
void *
545+
stl_get_functionptr(char *name)
549546
{
550547
#ifdef __linux__
551548
// this is ugly, but I can't figure how to make dlopen/dlsym work here

‎stl/stl.h

Copy file name to clipboardExpand all lines: stl/stl.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// function signatures
44
void stl_initialize(int argc, char **argv);
55
void stl_log(const char *fmt, ...);
6+
void stl_error(const char *fmt, ...);
67
void stl_debug(int32_t debug);
8+
void *stl_get_functionptr(char *name);
9+
char *stl_stralloc(char *s);
710

811
// sleep
912
void stl_sleep(double t);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.