Skip to content

Commit

Permalink
treewide: unexport libucode internal functions
Browse files Browse the repository at this point in the history
Trim down the libucode.so size somewhat by marking purely internal,
non-public API functions hidden.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  • Loading branch information
jow- committed Jul 29, 2022
1 parent a62482b commit 324357b
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 45 deletions.
14 changes: 7 additions & 7 deletions include/ucode/chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include "util.h"
#include "types.h"

void uc_chunk_init(uc_chunk_t *chunk);
void uc_chunk_free(uc_chunk_t *chunk);
size_t uc_chunk_add(uc_chunk_t *chunk, uint8_t byte, size_t line);
__hidden void uc_chunk_init(uc_chunk_t *chunk);
__hidden void uc_chunk_free(uc_chunk_t *chunk);
__hidden size_t uc_chunk_add(uc_chunk_t *chunk, uint8_t byte, size_t line);

void uc_chunk_pop(uc_chunk_t *chunk);
__hidden void uc_chunk_pop(uc_chunk_t *chunk);

size_t uc_chunk_debug_get_srcpos(uc_chunk_t *chunk, size_t off);
void uc_chunk_debug_add_variable(uc_chunk_t *chunk, size_t from, size_t to, size_t slot, bool upval, uc_value_t *name);
uc_value_t *uc_chunk_debug_get_variable(uc_chunk_t *chunk, size_t off, size_t slot, bool upval);
__hidden size_t uc_chunk_debug_get_srcpos(uc_chunk_t *chunk, size_t off);
__hidden void uc_chunk_debug_add_variable(uc_chunk_t *chunk, size_t from, size_t to, size_t slot, bool upval, uc_value_t *name);
__hidden uc_value_t *uc_chunk_debug_get_variable(uc_chunk_t *chunk, size_t off, size_t slot, bool upval);

#endif /* UCODE_CHUNK_H */
13 changes: 6 additions & 7 deletions include/ucode/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,15 @@ typedef struct {
} uc_lexer_t;


void uc_lexer_init(uc_lexer_t *lex, uc_parse_config_t *config, uc_source_t *source);
void uc_lexer_free(uc_lexer_t *lex);
__hidden void uc_lexer_init(uc_lexer_t *lex, uc_parse_config_t *config, uc_source_t *source);
__hidden void uc_lexer_free(uc_lexer_t *lex);

uc_token_t *uc_lexer_next_token(uc_lexer_t *lex);
__hidden uc_token_t *uc_lexer_next_token(uc_lexer_t *lex);

bool uc_lexer_is_keyword(uc_value_t *label);
__hidden bool uc_lexer_is_keyword(uc_value_t *label);

bool utf8enc(char **out, int *rem, int code);
__hidden bool utf8enc(char **out, int *rem, int code);

const char *
uc_tokenname(unsigned type);
__hidden const char *uc_tokenname(unsigned type);

#endif /* UCODE_LEXER_H */
4 changes: 2 additions & 2 deletions include/ucode/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ extern const uc_function_list_t uc_stdlib_functions[];
void uc_stdlib_load(uc_value_t *scope);
uc_cfn_ptr_t uc_stdlib_function(const char *name);

bool uc_source_context_format(uc_stringbuf_t *buf, uc_source_t *src, size_t off, bool compact);
bool uc_error_context_format(uc_stringbuf_t *buf, uc_source_t *src, uc_value_t *stacktrace, size_t off);
__hidden bool uc_source_context_format(uc_stringbuf_t *buf, uc_source_t *src, size_t off, bool compact);
__hidden bool uc_error_context_format(uc_stringbuf_t *buf, uc_source_t *src, uc_value_t *stacktrace, size_t off);


/* vm helper */
Expand Down
18 changes: 9 additions & 9 deletions include/ucode/program.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ uc_program_put(uc_program_t *prog) {

#define uc_program_function_last(prog) (uc_function_t *)prog->functions.next

uc_function_t *uc_program_function_new(uc_program_t *, const char *, uc_source_t *, size_t);
size_t uc_program_function_id(uc_program_t *, uc_function_t *);
uc_function_t *uc_program_function_load(uc_program_t *, size_t);
uc_source_t *uc_program_function_source(uc_function_t *);
size_t uc_program_function_srcpos(uc_function_t *, size_t);
void uc_program_function_free(uc_function_t *);
__hidden uc_function_t *uc_program_function_new(uc_program_t *, const char *, uc_source_t *, size_t);
__hidden size_t uc_program_function_id(uc_program_t *, uc_function_t *);
__hidden uc_function_t *uc_program_function_load(uc_program_t *, size_t);
__hidden uc_source_t *uc_program_function_source(uc_function_t *);
__hidden size_t uc_program_function_srcpos(uc_function_t *, size_t);
__hidden void uc_program_function_free(uc_function_t *);

ssize_t uc_program_export_lookup(uc_program_t *, uc_source_t *, uc_value_t *);
__hidden ssize_t uc_program_export_lookup(uc_program_t *, uc_source_t *, uc_value_t *);

uc_value_t *uc_program_get_constant(uc_program_t *, size_t);
ssize_t uc_program_add_constant(uc_program_t *, uc_value_t *);
__hidden uc_value_t *uc_program_get_constant(uc_program_t *, size_t);
__hidden ssize_t uc_program_add_constant(uc_program_t *, uc_value_t *);

void uc_program_write(uc_program_t *, FILE *, bool);
uc_program_t *uc_program_load(uc_source_t *, char **);
Expand Down
14 changes: 7 additions & 7 deletions include/ucode/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef enum {
uc_source_t *uc_source_new_file(const char *path);
uc_source_t *uc_source_new_buffer(const char *name, char *buf, size_t len);

size_t uc_source_get_line(uc_source_t *source, size_t *offset);
__hidden size_t uc_source_get_line(uc_source_t *source, size_t *offset);

static inline uc_source_t *
uc_source_get(uc_source_t *source) {
Expand All @@ -47,14 +47,14 @@ uc_source_put(uc_source_t *source) {
ucv_put(source ? &source->header : NULL);
}

uc_source_type_t uc_source_type_test(uc_source_t *source);
__hidden uc_source_type_t uc_source_type_test(uc_source_t *source);

void uc_source_line_next(uc_source_t *source);
void uc_source_line_update(uc_source_t *source, size_t off);
__hidden void uc_source_line_next(uc_source_t *source);
__hidden void uc_source_line_update(uc_source_t *source, size_t off);

void uc_source_runpath_set(uc_source_t *source, const char *runpath);
__hidden void uc_source_runpath_set(uc_source_t *source, const char *runpath);

bool uc_source_export_add(uc_source_t *source, uc_value_t *name);
ssize_t uc_source_export_lookup(uc_source_t *source, uc_value_t *name);
__hidden bool uc_source_export_add(uc_source_t *source, uc_value_t *name);
__hidden ssize_t uc_source_export_lookup(uc_source_t *source, uc_value_t *name);

#endif /* UCODE_SOURCE_H */
11 changes: 5 additions & 6 deletions include/ucode/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,12 @@ struct uc_vm {

/* Value API */

void ucv_free(uc_value_t *, bool);
void ucv_put(uc_value_t *);

void ucv_unref(uc_weakref_t *);
void ucv_ref(uc_weakref_t *, uc_weakref_t *);
__hidden void ucv_free(uc_value_t *, bool);
__hidden void ucv_unref(uc_weakref_t *);
__hidden void ucv_ref(uc_weakref_t *, uc_weakref_t *);

uc_value_t *ucv_get(uc_value_t *uv);
void ucv_put(uc_value_t *);

uc_type_t ucv_type(uc_value_t *);
const char *ucv_typename(uc_value_t *);
Expand Down Expand Up @@ -547,6 +546,6 @@ ucv_clear_mark(uc_value_t *uv)

void ucv_gc(uc_vm_t *);

void ucv_freeall(uc_vm_t *);
__hidden void ucv_freeall(uc_vm_t *);

#endif /* UCODE_TYPES_H */
5 changes: 5 additions & 0 deletions include/ucode/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
#include <json-c/json.h>


#ifndef __hidden
#define __hidden __attribute__((visibility("hidden")))
#endif


/* alignment & array size */

#ifndef ALIGN
Expand Down
14 changes: 7 additions & 7 deletions include/ucode/vallist.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ typedef enum {
TAG_LSTR = 5
} uc_value_type_t;

uc_value_t *uc_number_parse(const char *buf, char **end);
uc_value_t *uc_number_parse_octal(const char *buf, char **end);
__hidden uc_value_t *uc_number_parse(const char *buf, char **end);
__hidden uc_value_t *uc_number_parse_octal(const char *buf, char **end);

bool uc_double_pack(double d, char *buf, bool little_endian);
double uc_double_unpack(const char *buf, bool little_endian);

void uc_vallist_init(uc_value_list_t *list);
void uc_vallist_free(uc_value_list_t *list);
__hidden void uc_vallist_init(uc_value_list_t *list);
__hidden void uc_vallist_free(uc_value_list_t *list);

ssize_t uc_vallist_add(uc_value_list_t *list, uc_value_t *value);
uc_value_type_t uc_vallist_type(uc_value_list_t *list, size_t idx);
uc_value_t *uc_vallist_get(uc_value_list_t *list, size_t idx);
__hidden ssize_t uc_vallist_add(uc_value_list_t *list, uc_value_t *value);
__hidden uc_value_type_t uc_vallist_type(uc_value_list_t *list, size_t idx);
__hidden uc_value_t *uc_vallist_get(uc_value_list_t *list, size_t idx);

#endif /* UCODE_VALUE_H */

0 comments on commit 324357b

Please sign in to comment.