From ed8b8901c067f0d378f973622f5f6d560d21e914 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 Sep 2024 14:54:22 -0400 Subject: Add '$' prefix on all user code --- stdlib/optionals.c | 2 +- stdlib/ranges.c | 2 +- stdlib/ranges.h | 2 +- stdlib/threads.c | 17 +++++++++-------- stdlib/threads.h | 14 ++++++++------ 5 files changed, 20 insertions(+), 17 deletions(-) (limited to 'stdlib') diff --git a/stdlib/optionals.c b/stdlib/optionals.c index e21be507..1dc770a7 100644 --- a/stdlib/optionals.c +++ b/stdlib/optionals.c @@ -36,7 +36,7 @@ public PUREFUNC bool is_null(const void *obj, const TypeInfo *non_optional_type) return ((OptionalInt8_t*)obj)->is_null; else if (non_optional_type == &Byte$info) return ((OptionalByte_t*)obj)->is_null; - else if (non_optional_type == &Thread) + else if (non_optional_type == &Thread$info) return *(pthread_t**)obj == NULL; switch (non_optional_type->tag) { diff --git a/stdlib/ranges.c b/stdlib/ranges.c index 9dfd1efe..6c81c15e 100644 --- a/stdlib/ranges.c +++ b/stdlib/ranges.c @@ -54,7 +54,7 @@ PUREFUNC public Range_t Range$by(Range_t r, Int_t step) return (Range_t){r.first, r.last, Int$times(step, r.step)}; } -public const TypeInfo Range = {sizeof(Range_t), __alignof(Range_t), {.tag=CustomInfo, .CustomInfo={ +public const TypeInfo Range$info = {sizeof(Range_t), __alignof(Range_t), {.tag=CustomInfo, .CustomInfo={ .as_text=(void*)Range$as_text, .compare=(void*)Range$compare, .equal=(void*)Range$equal, diff --git a/stdlib/ranges.h b/stdlib/ranges.h index 2a4f1d68..933b9aee 100644 --- a/stdlib/ranges.h +++ b/stdlib/ranges.h @@ -5,6 +5,6 @@ PUREFUNC Range_t Range$reversed(Range_t r); PUREFUNC Range_t Range$by(Range_t r, Int_t step); -extern const TypeInfo Range; +extern const TypeInfo Range$info; // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 diff --git a/stdlib/threads.c b/stdlib/threads.c index 74e73832..59e98dd7 100644 --- a/stdlib/threads.c +++ b/stdlib/threads.c @@ -12,32 +12,33 @@ #include "arrays.h" #include "text.h" +#include "threads.h" #include "types.h" #include "util.h" -public pthread_t *Thread$new(Closure_t fn) +public Thread_t Thread$new(Closure_t fn) { - pthread_t *thread = new(pthread_t); + Thread_t thread = new(pthread_t); pthread_create(thread, NULL, fn.fn, fn.userdata); return thread; } -public void Thread$join(pthread_t *thread) +public void Thread$join(Thread_t thread) { pthread_join(*thread, NULL); } -public void Thread$cancel(pthread_t *thread) +public void Thread$cancel(Thread_t thread) { pthread_cancel(*thread); } -public void Thread$detach(pthread_t *thread) +public void Thread$detach(Thread_t thread) { pthread_detach(*thread); } -Text_t Thread$as_text(const pthread_t **thread, bool colorize, const TypeInfo *type) +Text_t Thread$as_text(const Thread_t *thread, bool colorize, const TypeInfo *type) { (void)type; if (!thread) { @@ -46,8 +47,8 @@ Text_t Thread$as_text(const pthread_t **thread, bool colorize, const TypeInfo *t return Text$format(colorize ? "\x1b[34;1mThread(%p)\x1b[m" : "Thread(%p)", *thread); } -public const TypeInfo Thread = { - .size=sizeof(pthread_t*), .align=__alignof(pthread_t*), +public const TypeInfo Thread$info = { + .size=sizeof(Thread_t), .align=__alignof(Thread_t), .tag=CustomInfo, .CustomInfo={.as_text=(void*)Thread$as_text}, }; diff --git a/stdlib/threads.h b/stdlib/threads.h index 52091677..f46840b3 100644 --- a/stdlib/threads.h +++ b/stdlib/threads.h @@ -9,12 +9,14 @@ #include "types.h" #include "util.h" -pthread_t *Thread$new(Closure_t fn); -void Thread$cancel(pthread_t *thread); -void Thread$join(pthread_t *thread); -void Thread$detach(pthread_t *thread); -Text_t Thread$as_text(const pthread_t **thread, bool colorize, const TypeInfo *type); +#define Thread_t pthread_t* -extern TypeInfo Thread; +Thread_t Thread$new(Closure_t fn); +void Thread$cancel(Thread_t thread); +void Thread$join(Thread_t thread); +void Thread$detach(Thread_t thread); +Text_t Thread$as_text(const Thread_t *thread, bool colorize, const TypeInfo *type); + +extern const TypeInfo Thread$info; // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 -- cgit v1.2.3