Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

typedef int FILE;

void abort();
void abort(void);

int strlen(char *str)
{
Expand Down Expand Up @@ -458,15 +458,15 @@ int snprintf(char *buffer, int n, char *str, ...)
return fmtbuf.len;
}

int __free_all();
int __free_all(void);

void exit(int exit_code)
{
__free_all();
__syscall(__syscall_exit, exit_code);
}

void abort()
void abort(void)
{
printf("Abnormal program termination\n");
exit(-1);
Expand Down Expand Up @@ -698,7 +698,7 @@ void __rfree(void *ptr, int size)
__syscall(__syscall_munmap, ptr, size);
}

int __free_all()
int __free_all(void)
{
if (!__freelist_head && !__alloc_head)
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/arm-codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void update_elf_offset(ph2_ir_t *ph2_ir)
}
}

void cfg_flatten()
void cfg_flatten(void)
{
func_t *func = find_func("__syscall");
func->bbs->elf_offset = 44; /* offset of start + exit in codegen */
Expand Down Expand Up @@ -447,7 +447,7 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
}
}

void code_generate()
void code_generate(void)
{
elf_data_start = elf_code_start + elf_offset;

Expand Down
2 changes: 1 addition & 1 deletion src/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int arm_encode(arm_cond_t cond, int opcode, int rn, int rd, int op2)
return (cond << 28) + (opcode << 20) + (rn << 16) + (rd << 12) + op2;
}

int __svc()
int __svc(void)
{
return arm_encode(__AL, 240, 0, 0, 0);
}
Expand Down
6 changes: 3 additions & 3 deletions src/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void elf_write_blk(strbuf_t *elf_array, void *blk, int sz)
strbuf_putc(elf_array, ptr[i]);
}

void elf_generate_header()
void elf_generate_header(void)
{
elf32_hdr_t hdr;
/*
Expand Down Expand Up @@ -173,7 +173,7 @@ void elf_generate_header()
elf_write_blk(elf_header, &phdr, sizeof(elf32_phdr_t));
}

void elf_generate_sections()
void elf_generate_sections(void)
{
/* symtab section */
for (int b = 0; b < elf_symtab->size; b++)
Expand Down Expand Up @@ -310,7 +310,7 @@ void elf_generate_sections()
elf_write_blk(elf_section, &shdr, sizeof(elf32_shdr_t));
}

void elf_align()
void elf_align(void)
{
while (elf_data->size & 3)
elf_write_byte(elf_data, 0);
Expand Down
8 changes: 4 additions & 4 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ int find_macro_param_src_idx(char *name, block_t *parent)
return 0;
}

type_t *add_type()
type_t *add_type(void)
{
return &TYPES[types_idx++];
}
Expand Down Expand Up @@ -970,7 +970,7 @@ void strbuf_free(strbuf_t *src)
/* This routine is required because the global variable initializations are
* not supported now.
*/
void global_init()
void global_init(void)
{
elf_code_start = ELF_START + elf_header_len;

Expand All @@ -994,7 +994,7 @@ void global_init()
elf_section = strbuf_create(MAX_SECTION);
}

void global_release()
void global_release(void)
{
free(MACROS);
free(TYPES);
Expand Down Expand Up @@ -1286,7 +1286,7 @@ void dump_bb_insn_by_dom(func_t *func, basic_block_t *bb, bool *at_func_start)
}
}

void dump_insn()
void dump_insn(void)
{
printf("==<START OF INSN DUMP>==\n");

Expand Down
6 changes: 3 additions & 3 deletions src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool is_numeric(char buffer[])
return true;
}

void skip_whitespace()
void skip_whitespace(void)
{
while (true) {
if (is_linebreak(next_char)) {
Expand Down Expand Up @@ -533,13 +533,13 @@ token_t lex_token_internal(bool aliasing)
/* Lex next token and returns its token type. To disable aliasing on next
* token, use 'lex_token_internal'.
*/
token_t lex_token()
token_t lex_token(void)
{
return lex_token_internal(true);
}

/* Skip the content. We only need the index where the macro body begins. */
void skip_macro_body()
void skip_macro_body(void)
{
while (!is_newline(next_char))
next_token = lex_token();
Expand Down
35 changes: 25 additions & 10 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void opstack_push(var_t *var)
operand_stack[operand_stack_idx++] = var;
}

var_t *opstack_pop()
var_t *opstack_pop(void)
{
return operand_stack[--operand_stack_idx];
}
Expand Down Expand Up @@ -179,7 +179,7 @@ int get_unary_operator_prio(opcode_t op)
}
}

opcode_t get_operator()
opcode_t get_operator(void)
{
opcode_t op = OP_generic;
if (lex_accept(T_plus))
Expand Down Expand Up @@ -317,7 +317,7 @@ int read_numeric_constant(char buffer[])
return value;
}

int read_constant_expr_operand()
int read_constant_expr_operand(void)
{
char buffer[MAX_ID_LEN];
int value;
Expand Down Expand Up @@ -449,15 +449,15 @@ int read_constant_infix_expr(int precedence)
return lhs;
}

int read_constant_expr()
int read_constant_expr(void)
{
return read_constant_infix_expr(0);
}

/* Skips lines where preprocessor match is false, this will stop once next
* token is either 'T_cppd_elif', 'T_cppd_else' or 'cppd_endif'.
*/
void cppd_control_flow_skip_lines()
void cppd_control_flow_skip_lines(void)
{
while (!lex_peek(T_cppd_elif, NULL) && !lex_peek(T_cppd_else, NULL) &&
!lex_peek(T_cppd_endif, NULL)) {
Expand All @@ -472,7 +472,7 @@ void check_def(char *alias, bool expected)
preproc_match = true;
}

void read_defined_macro()
void read_defined_macro(void)
{
char lookup_alias[MAX_TOKEN_LEN];

Expand All @@ -487,7 +487,7 @@ void read_defined_macro()
/* read preprocessor directive at each potential positions: e.g.,
* global statement / body statement
*/
bool read_preproc_directive()
bool read_preproc_directive(void)
{
char token[MAX_ID_LEN];

Expand Down Expand Up @@ -728,6 +728,21 @@ void read_parameter_list_decl(func_t *func, int anon)
{
int vn = 0;
lex_expect(T_open_bracket);

char token[MAX_TYPE_LEN];
if (lex_peek(T_identifier, token) && !strncmp(token, "void", 4)) {
next_token = lex_token();
if (lex_accept(T_close_bracket))
return;
func->param_defs[vn].type = TY_void;
read_inner_var_decl(&func->param_defs[vn], anon, 1);
if (!func->param_defs[vn].is_ptr && !func->param_defs[vn].is_func &&
!func->param_defs[vn].array_size)
error("'void' must be the only parameter and unnamed");
vn++;
lex_accept(T_comma);
}

while (lex_peek(T_identifier, NULL) == 1) {
read_full_var_decl(&func->param_defs[vn++], anon, 1);
lex_accept(T_comma);
Expand Down Expand Up @@ -1954,7 +1969,7 @@ bool read_body_assignment(char *token,
return false;
}

int read_primary_constant()
int read_primary_constant(void)
{
/* return signed constant */
int isneg = 0, res;
Expand Down Expand Up @@ -2819,7 +2834,7 @@ void read_global_decl(block_t *block)
error("Syntax error in global declaration");
}

void read_global_statement()
void read_global_statement(void)
{
char token[MAX_ID_LEN];
block_t *block = GLOBAL_BLOCK; /* global block */
Expand Down Expand Up @@ -2938,7 +2953,7 @@ void read_global_statement()
error("Syntax error in global statement");
}

void parse_internal()
void parse_internal(void)
{
/* set starting point of global stack manually */
GLOBAL_FUNC = add_func("", true);
Expand Down
2 changes: 1 addition & 1 deletion src/peephole.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool insn_fusion(ph2_ir_t *ph2_ir)
return false;
}

void peephole()
void peephole(void)
{
for (func_t *func = FUNC_LIST.head; func; func = func->next) {
for (basic_block_t *bb = func->bbs; bb; bb = bb->rpo_next) {
Expand Down
4 changes: 2 additions & 2 deletions src/reg-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void extend_liveness(basic_block_t *bb, insn_t *insn, var_t *var, int offset)
var->consumed = insn->idx + offset;
}

void reg_alloc()
void reg_alloc(void)
{
/* TODO: .bss and .data section */
for (insn_t *global_insn = GLOBAL_FUNC->bbs->insn_list.head; global_insn;
Expand Down Expand Up @@ -649,7 +649,7 @@ void reg_alloc()
}
}

void dump_ph2_ir()
void dump_ph2_ir(void)
{
for (int i = 0; i < ph2_ir_idx; i++) {
ph2_ir_t *ph2_ir = PH2_IR_FLATTEN[i];
Expand Down
4 changes: 2 additions & 2 deletions src/riscv-codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void update_elf_offset(ph2_ir_t *ph2_ir)
}
}

void cfg_flatten()
void cfg_flatten(void)
{
func_t *func = find_func("__syscall");
func->bbs->elf_offset = 48; /* offset of start + exit in codegen */
Expand Down Expand Up @@ -426,7 +426,7 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
}
}

void code_generate()
void code_generate(void)
{
elf_data_start = elf_code_start + elf_offset;

Expand Down
6 changes: 3 additions & 3 deletions src/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,17 @@ int __auipc(rv_reg rd, int imm)
return rv_encode_U(rv_auipc, rd, imm);
}

int __ecall()
int __ecall(void)
{
return rv_encode_I(rv_ecall, __zero, __zero, 0);
}

int __ebreak()
int __ebreak(void)
{
return rv_encode_I(rv_ebreak, __zero, __zero, 1);
}

int __nop()
int __nop(void)
{
return __addi(__zero, __zero, 0);
}
Expand Down
Loading