Skip to content

Commit d846e0d

Browse files
committed
refactor: Change static/hidden prefix->suffix
Signed-off-by: Diogo Behrens <[email protected]>
1 parent 51c3675 commit d846e0d

File tree

7 files changed

+157
-157
lines changed

7 files changed

+157
-157
lines changed

src/dice/loader.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) Huawei Technologies Co., Ltd. 2025. All rights reserved.
2+
* Copyright (C) 2025 Huawei Technologies Co., Ltd.
33
* SPDX-License-Identifier: 0BSD
44
*/
55
#include <assert.h>
@@ -25,13 +25,13 @@ int ps_dispatch_max(void);
2525
void ps_init_();
2626

2727
static DICE_CTOR void
28-
_init()
28+
init_()
2929
{
3030
ps_init_();
3131
}
3232

3333
static void
34-
_load_plugin(const char *path)
34+
load_plugin_(const char *path)
3535
{
3636
log_debug("[%4d] LOAD: %s", DICE_MODULE_PRIO, path);
3737
void *handle = dlopen(path, RTLD_GLOBAL | RTLD_LAZY);
@@ -41,7 +41,7 @@ _load_plugin(const char *path)
4141
}
4242

4343
static char *
44-
_strdup(const char *str)
44+
strdup_(const char *str)
4545
{
4646
if (str == NULL)
4747
return NULL;
@@ -60,15 +60,15 @@ PS_SUBSCRIBE(CHAIN_CONTROL, EVENT_DICE_INIT, {
6060
log_debug("[%4d] LOAD: builtin modules: 0..%d", DICE_MODULE_PRIO,
6161
ps_dispatch_max());
6262
if (envvar != NULL) {
63-
char *plugins = _strdup(envvar);
63+
char *plugins = strdup_(envvar);
6464
assert(plugins);
6565

6666
char *path = strtok(plugins, ":");
6767
assert(path);
6868
// skip first
6969
path = strtok(NULL, ":");
7070
while (path != NULL) {
71-
_load_plugin(path);
71+
load_plugin_(path);
7272
path = strtok(NULL, ":");
7373
}
7474
mempool_free(plugins);

src/dice/mempool.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) Huawei Technologies Co., Ltd. 2025. All rights reserved.
2+
* Copyright (C) 2025 Huawei Technologies Co., Ltd.
33
* SPDX-License-Identifier: 0BSD
44
*/
55
#include <assert.h>
@@ -12,7 +12,7 @@
1212
#include <dice/mempool.h>
1313
#include <vsync/spinlock/caslock.h>
1414

15-
static size_t _sizes[] = {32,
15+
static size_t sizes_[] = {32,
1616
128,
1717
512,
1818
1024,
@@ -21,15 +21,15 @@ static size_t _sizes[] = {32,
2121
1 * 1024 * 1024,
2222
4 * 1024 * 1024,
2323
8 * 1024 * 1024};
24-
#define NSTACKS (sizeof(_sizes) / sizeof(size_t))
24+
#define NSTACKS (sizeof(sizes_) / sizeof(size_t))
2525

2626
#define MEMPOOL_SIZE (1024 * 1024 * 200)
2727

2828
static unsigned int
29-
_bucketize(size_t size)
29+
bucketize_(size_t size)
3030
{
3131
unsigned int i = 0;
32-
for (; i < NSTACKS && size > _sizes[i]; i++)
32+
for (; i < NSTACKS && size > sizes_[i]; i++)
3333
;
3434
assert(i < NSTACKS);
3535
return i;
@@ -54,46 +54,46 @@ typedef struct mempool {
5454
entry_t *stack[NSTACKS];
5555
} mempool_t;
5656

57-
static mempool_t _mp;
57+
static mempool_t mp_;
5858

5959
/* bypass malloc interceptor */
6060
REAL_DECL(void *, malloc, size_t n);
6161

6262
DICE_HIDE void
6363
mempool_init(size_t cap)
6464
{
65-
memset(&_mp.stack, 0, sizeof(entry_t *) * NSTACKS);
66-
_mp.allocated = 0;
67-
_mp.pool.capacity = cap;
68-
_mp.pool.next = 0;
69-
_mp.pool.memory = REAL_CALL(malloc, 0, cap);
70-
assert(_mp.pool.memory);
71-
memset(_mp.pool.memory, 0, cap);
65+
memset(&mp_.stack, 0, sizeof(entry_t *) * NSTACKS);
66+
mp_.allocated = 0;
67+
mp_.pool.capacity = cap;
68+
mp_.pool.next = 0;
69+
mp_.pool.memory = REAL_CALL(malloc, 0, cap);
70+
assert(mp_.pool.memory);
71+
memset(mp_.pool.memory, 0, cap);
7272
// caslock already initialized with 0
7373
}
7474

7575
static inline void
7676
mempool_ensure_initd(void)
7777
{
7878
// assumes protected by lock
79-
if (_mp.pool.memory == NULL)
79+
if (mp_.pool.memory == NULL)
8080
mempool_init(MEMPOOL_SIZE);
8181
}
8282

8383
DICE_MODULE_INIT({
84-
caslock_acquire(&_mp.lock);
84+
caslock_acquire(&mp_.lock);
8585
mempool_ensure_initd();
86-
caslock_release(&_mp.lock);
86+
caslock_release(&mp_.lock);
8787
})
8888

8989
DICE_HIDE_IF void *
9090
mempool_alloc(size_t n)
9191
{
92-
mempool_t *mp = &_mp;
92+
mempool_t *mp = &mp_;
9393
entry_t *e = NULL;
9494
size_t size = n + sizeof(entry_t);
95-
unsigned bucket = _bucketize(size);
96-
size = _sizes[bucket];
95+
unsigned bucket = bucketize_(size);
96+
size = sizes_[bucket];
9797
entry_t **stack = &mp->stack[bucket];
9898
assert(stack);
9999

@@ -138,12 +138,12 @@ mempool_realloc(void *ptr, size_t size)
138138
DICE_HIDE_IF void
139139
mempool_free(void *ptr)
140140
{
141-
mempool_t *mp = &_mp;
141+
mempool_t *mp = &mp_;
142142
assert(ptr);
143143
entry_t *e = (entry_t *)ptr - 1;
144144
size_t size = e->size + sizeof(entry_t);
145-
unsigned bucket = _bucketize(size);
146-
size = _sizes[bucket];
145+
unsigned bucket = bucketize_(size);
146+
size = sizes_[bucket];
147147
entry_t **stack = &mp->stack[bucket];
148148

149149
// Mempool is used from rogue thread, serialization is necessary

src/dice/pubsub.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) Huawei Technologies Co., Ltd. 2025. All rights reserved.
2+
* Copyright (C) 2025 Huawei Technologies Co., Ltd.
33
* SPDX-License-Identifier: 0BSD
44
*/
55
#include <assert.h>
@@ -33,7 +33,7 @@ struct chain {
3333
struct type types[MAX_TYPES];
3434
};
3535

36-
static struct chain _chains[MAX_CHAINS];
36+
static struct chain chains_[MAX_CHAINS];
3737

3838
// -----------------------------------------------------------------------------
3939
// initializer
@@ -46,23 +46,23 @@ ps_initd_(void)
4646
NONE,
4747
START,
4848
BLOCK,
49-
} _state = NONE;
49+
} state_ = NONE;
5050
static bool ready = false;
5151

5252
if (likely(ready)) {
5353
return true;
5454
}
5555

56-
switch (_state) {
56+
switch (state_) {
5757
case NONE:
5858
// This must be the main thread, at latest the thread creation.
59-
_state = START;
59+
state_ = START;
6060
PS_PUBLISH(CHAIN_CONTROL, EVENT_DICE_INIT, 0, 0);
6161
ready = true;
6262
PS_PUBLISH(CHAIN_CONTROL, EVENT_DICE_READY, 0, 0);
6363
return true;
6464
case START:
65-
_state = BLOCK;
65+
state_ = BLOCK;
6666
return true;
6767
case BLOCK:
6868
// The publication above is still running, drop nested publications.
@@ -87,7 +87,7 @@ DICE_MODULE_INIT()
8787
// -----------------------------------------------------------------------------
8888

8989
static void
90-
_ps_subscribe_sorted(struct sub **cur, chain_id chain, type_id type,
90+
ps_subscribe_sorted_(struct sub **cur, chain_id chain, type_id type,
9191
ps_callback_f cb, int prio, bool any_type)
9292
{
9393
// any_type is set if this subscription was from ANY_TYPE
@@ -101,7 +101,7 @@ _ps_subscribe_sorted(struct sub **cur, chain_id chain, type_id type,
101101
next = *cur;
102102
goto insert;
103103
} else {
104-
_ps_subscribe_sorted(&(*cur)->next, chain, type, cb, prio, any_type);
104+
ps_subscribe_sorted_(&(*cur)->next, chain, type, cb, prio, any_type);
105105
return;
106106
}
107107

@@ -117,20 +117,20 @@ _ps_subscribe_sorted(struct sub **cur, chain_id chain, type_id type,
117117
}
118118

119119
static int
120-
_ps_subscribe_type(chain_id chain, type_id type, ps_callback_f cb, int prio,
120+
ps_subscribe_type_(chain_id chain, type_id type, ps_callback_f cb, int prio,
121121
bool any_type)
122122
{
123123
(void)prio;
124124
if (type > MAX_TYPES)
125125
return PS_INVALID;
126126

127-
struct type *ev = &_chains[chain].types[type];
127+
struct type *ev = &chains_[chain].types[type];
128128

129129
// increment the idx of next subscription
130130
ev->count++;
131131

132132
// register subscription
133-
_ps_subscribe_sorted(&ev->head, chain, type, cb, prio, any_type);
133+
ps_subscribe_sorted_(&ev->head, chain, type, cb, prio, any_type);
134134

135135
return PS_OK;
136136
}
@@ -150,11 +150,11 @@ ps_subscribe(chain_id chain, type_id type, ps_callback_f cb, int prio)
150150
if (chain > MAX_CHAINS)
151151
return PS_INVALID;
152152
if (type != ANY_TYPE)
153-
return _ps_subscribe_type(chain, type, cb, prio, false);
153+
return ps_subscribe_type_(chain, type, cb, prio, false);
154154

155155
int err;
156156
for (size_t i = 1; i < MAX_TYPES; i++)
157-
if ((err = _ps_subscribe_type(chain, i, cb, prio, true)) != 0)
157+
if ((err = ps_subscribe_type_(chain, i, cb, prio, true)) != 0)
158158
return err;
159159

160160
return PS_OK;
@@ -165,15 +165,15 @@ ps_subscribe(chain_id chain, type_id type, ps_callback_f cb, int prio)
165165
// -----------------------------------------------------------------------------
166166

167167
static enum ps_err
168-
_ps_publish(const chain_id chain, const type_id type, void *event,
168+
ps_publish_(const chain_id chain, const type_id type, void *event,
169169
metadata_t *md)
170170
{
171171
if (unlikely(chain >= MAX_CHAINS))
172172
return PS_INVALID;
173173
if (unlikely(type == ANY_TYPE || type >= MAX_TYPES))
174174
return PS_INVALID;
175175

176-
struct type *ev = &_chains[chain].types[type];
176+
struct type *ev = &chains_[chain].types[type];
177177
struct sub *cur = ev->head;
178178
while (cur) {
179179
// now we call the callback and abort the chain if the subscriber
@@ -215,5 +215,5 @@ ps_publish(const chain_id chain, const type_id type, void *event,
215215
if (likely(err == PS_DROP_EVENT))
216216
return PS_DROP_EVENT;
217217

218-
return _ps_publish(chain, type, event, md);
218+
return ps_publish_(chain, type, event, md);
219219
}

0 commit comments

Comments
 (0)