From 273e2f995f1d74e9ef8e9a2e09a3ea2c2b16d839 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 11 Sep 2024 13:57:21 -0400 Subject: Rename channel_t -> Channel_t for consistency --- builtins/channel.c | 26 +++++++++++++------------- builtins/channel.h | 22 +++++++++++----------- builtins/datatypes.h | 2 +- builtins/functions.c | 8 ++++---- builtins/optionals.c | 2 +- builtins/types.h | 2 +- compile.c | 2 +- types.c | 4 ++-- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/builtins/channel.c b/builtins/channel.c index 692322b5..5b046ef5 100644 --- a/builtins/channel.c +++ b/builtins/channel.c @@ -19,11 +19,11 @@ #include "types.h" #include "util.h" -public channel_t *Channel$new(Int_t max_size) +public Channel_t *Channel$new(Int_t max_size) { if (Int$compare_value(max_size, I_small(0)) <= 0) fail("Cannot create a channel with a size less than one: %ld", max_size); - channel_t *channel = new(channel_t); + Channel_t *channel = new(Channel_t); channel->items = (Array_t){}; channel->mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER; channel->cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER; @@ -31,7 +31,7 @@ public channel_t *Channel$new(Int_t max_size) return channel; } -public void Channel$give(channel_t *channel, const void *item, bool front, int64_t padded_item_size) +public void Channel$give(Channel_t *channel, const void *item, bool front, int64_t padded_item_size) { (void)pthread_mutex_lock(&channel->mutex); while (channel->items.length >= channel->max_size) @@ -42,7 +42,7 @@ public void Channel$give(channel_t *channel, const void *item, bool front, int64 (void)pthread_cond_signal(&channel->cond); } -public void Channel$give_all(channel_t *channel, Array_t to_give, bool front, int64_t padded_item_size) +public void Channel$give_all(Channel_t *channel, Array_t to_give, bool front, int64_t padded_item_size) { if (to_give.length == 0) return; (void)pthread_mutex_lock(&channel->mutex); @@ -60,7 +60,7 @@ public void Channel$give_all(channel_t *channel, Array_t to_give, bool front, in (void)pthread_cond_signal(&channel->cond); } -public void Channel$get(channel_t *channel, void *out, bool front, int64_t item_size, int64_t padded_item_size) +public void Channel$get(Channel_t *channel, void *out, bool front, int64_t item_size, int64_t padded_item_size) { (void)pthread_mutex_lock(&channel->mutex); while (channel->items.length == 0) @@ -72,7 +72,7 @@ public void Channel$get(channel_t *channel, void *out, bool front, int64_t item_ (void)pthread_cond_signal(&channel->cond); } -public void Channel$peek(channel_t *channel, void *out, bool front, int64_t item_size) +public void Channel$peek(Channel_t *channel, void *out, bool front, int64_t item_size) { (void)pthread_mutex_lock(&channel->mutex); while (channel->items.length == 0) @@ -83,7 +83,7 @@ public void Channel$peek(channel_t *channel, void *out, bool front, int64_t item (void)pthread_cond_signal(&channel->cond); } -public Array_t Channel$view(channel_t *channel) +public Array_t Channel$view(Channel_t *channel) { (void)pthread_mutex_lock(&channel->mutex); ARRAY_INCREF(channel->items); @@ -92,7 +92,7 @@ public Array_t Channel$view(channel_t *channel) return ret; } -public void Channel$clear(channel_t *channel) +public void Channel$clear(Channel_t *channel) { (void)pthread_mutex_lock(&channel->mutex); Array$clear(&channel->items); @@ -100,25 +100,25 @@ public void Channel$clear(channel_t *channel) (void)pthread_cond_signal(&channel->cond); } -PUREFUNC public uint64_t Channel$hash(channel_t **channel, const TypeInfo *type) +PUREFUNC public uint64_t Channel$hash(Channel_t **channel, const TypeInfo *type) { (void)type; - return siphash24((void*)*channel, sizeof(channel_t*)); + return siphash24((void*)*channel, sizeof(Channel_t*)); } -PUREFUNC public int32_t Channel$compare(channel_t **x, channel_t **y, const TypeInfo *type) +PUREFUNC public int32_t Channel$compare(Channel_t **x, Channel_t **y, const TypeInfo *type) { (void)type; return (*x > *y) - (*x < *y); } -PUREFUNC public bool Channel$equal(channel_t **x, channel_t **y, const TypeInfo *type) +PUREFUNC public bool Channel$equal(Channel_t **x, Channel_t **y, const TypeInfo *type) { (void)type; return (*x == *y); } -public Text_t Channel$as_text(channel_t **channel, bool colorize, const TypeInfo *type) +public Text_t Channel$as_text(Channel_t **channel, bool colorize, const TypeInfo *type) { const TypeInfo *item_type = type->ChannelInfo.item; if (!channel) { diff --git a/builtins/channel.h b/builtins/channel.h index affed1c1..bb74da87 100644 --- a/builtins/channel.h +++ b/builtins/channel.h @@ -9,21 +9,21 @@ #include "types.h" #include "util.h" -channel_t *Channel$new(Int_t max_size); -void Channel$give(channel_t *channel, const void *item, bool front, int64_t padded_item_size); +Channel_t *Channel$new(Int_t max_size); +void Channel$give(Channel_t *channel, const void *item, bool front, int64_t padded_item_size); #define Channel$give_value(channel, item, front, padded_item_size) \ ({ __typeof(item) _item = item; Channel$give(channel, &_item, front, padded_item_size); }) -void Channel$give_all(channel_t *channel, Array_t to_give, bool front, int64_t padded_item_size); -void Channel$get(channel_t *channel, void *out, bool front, int64_t item_size, int64_t padded_item_size); +void Channel$give_all(Channel_t *channel, Array_t to_give, bool front, int64_t padded_item_size); +void Channel$get(Channel_t *channel, void *out, bool front, int64_t item_size, int64_t padded_item_size); #define Channel$get_value(channel, front, t, padded_item_size) \ ({ t _val; Channel$get(channel, &_val, front, sizeof(t), padded_item_size); _val; }) -void Channel$peek(channel_t *channel, void *out, bool front, int64_t item_size); +void Channel$peek(Channel_t *channel, void *out, bool front, int64_t item_size); #define Channel$peek_value(channel, front, t) ({ t _val; Channel$peek(channel, &_val, front, sizeof(t)); _val; }) -void Channel$clear(channel_t *channel); -Array_t Channel$view(channel_t *channel); -PUREFUNC uint64_t Channel$hash(channel_t **channel, const TypeInfo *type); -PUREFUNC int32_t Channel$compare(channel_t **x, channel_t **y, const TypeInfo *type); -PUREFUNC bool Channel$equal(channel_t **x, channel_t **y, const TypeInfo *type); -Text_t Channel$as_text(channel_t **channel, bool colorize, const TypeInfo *type); +void Channel$clear(Channel_t *channel); +Array_t Channel$view(Channel_t *channel); +PUREFUNC uint64_t Channel$hash(Channel_t **channel, const TypeInfo *type); +PUREFUNC int32_t Channel$compare(Channel_t **x, Channel_t **y, const TypeInfo *type); +PUREFUNC bool Channel$equal(Channel_t **x, Channel_t **y, const TypeInfo *type); +Text_t Channel$as_text(Channel_t **channel, bool colorize, const TypeInfo *type); // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 diff --git a/builtins/datatypes.h b/builtins/datatypes.h index c08d92dd..8c13d3c4 100644 --- a/builtins/datatypes.h +++ b/builtins/datatypes.h @@ -69,7 +69,7 @@ typedef struct { pthread_mutex_t mutex; pthread_cond_t cond; int64_t max_size; -} channel_t; +} Channel_t; enum text_type { TEXT_SHORT_ASCII, TEXT_ASCII, TEXT_SHORT_GRAPHEMES, TEXT_GRAPHEMES, TEXT_SUBTEXT }; diff --git a/builtins/functions.c b/builtins/functions.c index 3e6a7eb0..51d0d189 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -112,7 +112,7 @@ PUREFUNC public uint64_t generic_hash(const void *obj, const TypeInfo *type) switch (type->tag) { case TextInfo: return Text$hash((void*)obj); case ArrayInfo: return Array$hash(obj, type); - case ChannelInfo: return Channel$hash((channel_t**)obj, type); + case ChannelInfo: return Channel$hash((Channel_t**)obj, type); case TableInfo: return Table$hash(obj, type); case OptionalInfo: { errx(1, "Optional hash not implemented"); @@ -137,7 +137,7 @@ PUREFUNC public int32_t generic_compare(const void *x, const void *y, const Type case PointerInfo: case FunctionInfo: return Pointer$compare(x, y, type); case TextInfo: return Text$compare(x, y); case ArrayInfo: return Array$compare(x, y, type); - case ChannelInfo: return Channel$compare((channel_t**)x, (channel_t**)y, type); + case ChannelInfo: return Channel$compare((Channel_t**)x, (Channel_t**)y, type); case TableInfo: return Table$compare(x, y, type); case OptionalInfo: { errx(1, "Optional compare not implemented"); @@ -161,7 +161,7 @@ PUREFUNC public bool generic_equal(const void *x, const void *y, const TypeInfo case PointerInfo: case FunctionInfo: return Pointer$equal(x, y, type); case TextInfo: return Text$equal(x, y); case ArrayInfo: return Array$equal(x, y, type); - case ChannelInfo: return Channel$equal((channel_t**)x, (channel_t**)y, type); + case ChannelInfo: return Channel$equal((Channel_t**)x, (Channel_t**)y, type); case TableInfo: return Table$equal(x, y, type); case EmptyStructInfo: return true; case OptionalInfo: { @@ -184,7 +184,7 @@ public Text_t generic_as_text(const void *obj, bool colorize, const TypeInfo *ty case FunctionInfo: return Func$as_text(obj, colorize, type); case TextInfo: return Text$as_text(obj, colorize, type); case ArrayInfo: return Array$as_text(obj, colorize, type); - case ChannelInfo: return Channel$as_text((channel_t**)obj, colorize, type); + case ChannelInfo: return Channel$as_text((Channel_t**)obj, colorize, type); case TableInfo: return Table$as_text(obj, colorize, type); case TypeInfoInfo: return Type$as_text(obj, colorize, type); case OptionalInfo: return Optional$as_text(obj, colorize, type); diff --git a/builtins/optionals.c b/builtins/optionals.c index 065d535a..687486db 100644 --- a/builtins/optionals.c +++ b/builtins/optionals.c @@ -34,7 +34,7 @@ static inline bool is_null(const void *obj, const TypeInfo *non_optional_type) return *(pthread_t**)obj == NULL; switch (non_optional_type->tag) { - case ChannelInfo: return *(channel_t**)obj == NULL; + case ChannelInfo: return *(Channel_t**)obj == NULL; case PointerInfo: return *(void**)obj == NULL; case TextInfo: return ((Text_t*)obj)->length < 0; case ArrayInfo: return ((Array_t*)obj)->length < 0; diff --git a/builtins/types.h b/builtins/types.h index a7b4bb51..a0b48e53 100644 --- a/builtins/types.h +++ b/builtins/types.h @@ -63,7 +63,7 @@ typedef struct TypeInfo { .tag=ArrayInfo, .ArrayInfo.item=item_info}) #define Set$info(item_info) &((TypeInfo){.size=sizeof(Table_t), .align=__alignof__(Table_t), \ .tag=TableInfo, .TableInfo.key=item_info, .TableInfo.value=&Void$info}) -#define Channel$info(item_info) &((TypeInfo){.size=sizeof(channel_t), .align=__alignof__(channel_t), \ +#define Channel$info(item_info) &((TypeInfo){.size=sizeof(Channel_t), .align=__alignof__(Channel_t), \ .tag=ChannelInfo, .ChannelInfo.item=item_info}) #define Table$info(key_expr, value_expr) &((TypeInfo){.size=sizeof(Table_t), .align=__alignof__(Table_t), \ .tag=TableInfo, .TableInfo.key=key_expr, .TableInfo.value=value_expr}) diff --git a/compile.c b/compile.c index 84cb26eb..d3ca0ba6 100644 --- a/compile.c +++ b/compile.c @@ -196,7 +196,7 @@ CORD compile_type(type_t *t) } case ArrayType: return "Array_t"; case SetType: return "Table_t"; - case ChannelType: return "channel_t*"; + case ChannelType: return "Channel_t*"; case TableType: return "Table_t"; case FunctionType: { auto fn = Match(t, FunctionType); diff --git a/types.c b/types.c index 6a1459c4..63f61066 100644 --- a/types.c +++ b/types.c @@ -403,7 +403,7 @@ PUREFUNC size_t type_size(type_t *t) case TextType: return sizeof(Text_t); case ArrayType: return sizeof(Array_t); case SetType: return sizeof(Table_t); - case ChannelType: return sizeof(channel_t*); + case ChannelType: return sizeof(Channel_t*); case TableType: return sizeof(Table_t); case FunctionType: return sizeof(void*); case ClosureType: return sizeof(struct {void *fn, *userdata;}); @@ -481,7 +481,7 @@ PUREFUNC size_t type_align(type_t *t) case TextType: return __alignof__(Text_t); case SetType: return __alignof__(Table_t); case ArrayType: return __alignof__(Array_t); - case ChannelType: return __alignof__(channel_t*); + case ChannelType: return __alignof__(Channel_t*); case TableType: return __alignof__(Table_t); case FunctionType: return __alignof__(void*); case ClosureType: return __alignof__(struct {void *fn, *userdata;}); -- cgit v1.2.3