Skip to content

Commit

Permalink
Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalcon committed Feb 12, 2014
1 parent d5df6cd commit 520e2f5
Show file tree
Hide file tree
Showing 22 changed files with 451 additions and 446 deletions.
14 changes: 7 additions & 7 deletions py/asmthumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void asm_thumb_end_pass(asm_thumb_t *as) {
}

// all functions must go through this one to emit bytes
static byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int num_bytes_to_write) {
STATIC byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int num_bytes_to_write) {
//printf("emit %d\n", num_bytes_to_write);
if (as->pass < ASM_THUMB_PASS_3) {
as->code_offset += num_bytes_to_write;
Expand All @@ -116,20 +116,20 @@ void *asm_thumb_get_code(asm_thumb_t *as) {
}

/*
static void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
byte *c = asm_thumb_get_cur_to_write_bytes(as, 1);
c[0] = b1;
}
*/

static void asm_thumb_write_op16(asm_thumb_t *as, uint op) {
STATIC void asm_thumb_write_op16(asm_thumb_t *as, uint op) {
byte *c = asm_thumb_get_cur_to_write_bytes(as, 2);
// little endian
c[0] = op;
c[1] = op >> 8;
}

static void asm_thumb_write_op32(asm_thumb_t *as, uint op1, uint op2) {
STATIC void asm_thumb_write_op32(asm_thumb_t *as, uint op1, uint op2) {
byte *c = asm_thumb_get_cur_to_write_bytes(as, 4);
// little endian, op1 then op2
c[0] = op1;
Expand All @@ -144,7 +144,7 @@ static void asm_thumb_write_op32(asm_thumb_t *as, uint op1, uint op2) {
#define IMM32_L2(x) (((x) >> 16) & 0xff)
#define IMM32_L3(x) (((x) >> 24) & 0xff)
static void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
byte *c = asm_thumb_get_cur_to_write_bytes(as, 4);
c[0] = IMM32_L0(w32);
c[1] = IMM32_L1(w32);
Expand Down Expand Up @@ -226,7 +226,7 @@ void asm_thumb_label_assign(asm_thumb_t *as, int label) {
}
}

static int get_label_dest(asm_thumb_t *as, int label) {
STATIC int get_label_dest(asm_thumb_t *as, int label) {
assert(label < as->max_num_labels);
return as->label_offsets[label];
}
Expand All @@ -244,7 +244,7 @@ void asm_thumb_movs_rlo_i8(asm_thumb_t *as, uint rlo_dest, int i8_src) {
#define OP_MOVT (0xf2c0)

// if loading lo half with movw, the i16 value will be zero extended into the r32 register!
static void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) {
STATIC void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) {
assert(reg_dest < REG_R15);
// mov[wt] reg_dest, #i16_src
asm_thumb_write_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), ((i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff));
Expand Down
22 changes: 11 additions & 11 deletions py/asmx64.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void asm_x64_end_pass(asm_x64_t *as) {
}

// all functions must go through this one to emit bytes
static byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int num_bytes_to_write) {
STATIC byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int num_bytes_to_write) {
//printf("emit %d\n", num_bytes_to_write);
if (as->pass < ASM_X64_PASS_3) {
as->code_offset += num_bytes_to_write;
Expand All @@ -197,33 +197,33 @@ void *asm_x64_get_code(asm_x64_t *as) {
return as->code_base;
}

static void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
byte* c = asm_x64_get_cur_to_write_bytes(as, 1);
c[0] = b1;
}

static void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
byte* c = asm_x64_get_cur_to_write_bytes(as, 2);
c[0] = b1;
c[1] = b2;
}

static void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
byte* c = asm_x64_get_cur_to_write_bytes(as, 3);
c[0] = b1;
c[1] = b2;
c[2] = b3;
}

static void asm_x64_write_word32(asm_x64_t *as, int w32) {
STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
byte* c = asm_x64_get_cur_to_write_bytes(as, 4);
c[0] = IMM32_L0(w32);
c[1] = IMM32_L1(w32);
c[2] = IMM32_L2(w32);
c[3] = IMM32_L3(w32);
}

static void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
byte* c = asm_x64_get_cur_to_write_bytes(as, 8);
c[0] = IMM32_L0(w64);
c[1] = IMM32_L1(w64);
Expand All @@ -236,7 +236,7 @@ static void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
}

/* unused
static void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
byte* c;
assert(offset + 4 <= as->code_size);
c = as->code_base + offset;
Expand All @@ -247,7 +247,7 @@ static void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
}
*/

static void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
assert(disp_r64 != REG_RSP);

if (disp_offset == 0 && disp_r64 != REG_RBP) {
Expand Down Expand Up @@ -282,7 +282,7 @@ void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) {
asm_x64_write_byte_1(as, OPCODE_POP_R64 | dest_r64);
}

static void asm_x64_ret(asm_x64_t *as) {
STATIC void asm_x64_ret(asm_x64_t *as) {
asm_x64_write_byte_1(as, OPCODE_RET);
}

Expand Down Expand Up @@ -472,7 +472,7 @@ void asm_x64_label_assign(asm_x64_t *as, int label) {
}
}

static int get_label_dest(asm_x64_t *as, int label) {
STATIC int get_label_dest(asm_x64_t *as, int label) {
assert(label < as->max_num_labels);
return as->label_offsets[label];
}
Expand Down Expand Up @@ -565,7 +565,7 @@ void asm_x64_mov_r32_to_arg(asm_x64_t *as, int src_r32, int dest_arg_num) {
// ^ ^
// | low address | high address in RAM
//
static int asm_x64_local_offset_from_ebp(asm_x64_t *as, int local_num) {
STATIC int asm_x64_local_offset_from_ebp(asm_x64_t *as, int local_num) {
return (-as->num_locals + local_num) * WORD_SIZE;
}

Expand Down
48 changes: 24 additions & 24 deletions py/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// args[0] is function from class body
// args[1] is class name
// args[2:] are base objects
static mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args);

// we differ from CPython: we set the new __locals__ object here
Expand Down Expand Up @@ -61,7 +61,7 @@ static mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);

static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
if (o != mp_const_none) {
mp_obj_print(o, PRINT_REPR);
printf("\n");
Expand Down Expand Up @@ -100,7 +100,7 @@ mp_obj_t mp_builtin_abs(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);

static mp_obj_t mp_builtin_all(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
mp_obj_t iterable = rt_getiter(o_in);
mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) {
Expand All @@ -113,7 +113,7 @@ static mp_obj_t mp_builtin_all(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);

static mp_obj_t mp_builtin_any(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
mp_obj_t iterable = rt_getiter(o_in);
mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) {
Expand All @@ -126,7 +126,7 @@ static mp_obj_t mp_builtin_any(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);

static mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
if (mp_obj_is_callable(o_in)) {
return mp_const_true;
} else {
Expand All @@ -136,7 +136,7 @@ static mp_obj_t mp_builtin_callable(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);

static mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
int ord = mp_obj_get_int(o_in);
if (0 <= ord && ord <= 0x10ffff) {
byte str[1] = {ord};
Expand All @@ -148,7 +148,7 @@ static mp_obj_t mp_builtin_chr(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);

static mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
// TODO make this function more general and less of a hack

mp_map_t *map;
Expand Down Expand Up @@ -178,7 +178,7 @@ static mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);

static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
if (MP_OBJ_IS_SMALL_INT(o1_in) && MP_OBJ_IS_SMALL_INT(o2_in)) {
mp_small_int_t i1 = MP_OBJ_SMALL_INT_VALUE(o1_in);
mp_small_int_t i2 = MP_OBJ_SMALL_INT_VALUE(o2_in);
Expand All @@ -193,20 +193,20 @@ static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {

MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);

static mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
// TODO hash will generally overflow small integer; can we safely truncate it?
return mp_obj_new_int(mp_obj_hash(o_in));
}

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);

static mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
return rt_getiter(o_in);
}

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);

static mp_obj_t mp_builtin_len(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_len(mp_obj_t o_in) {
mp_obj_t len = mp_obj_len_maybe(o_in);
if (len == NULL) {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "object of type '%s' has no len()", mp_obj_get_type_str(o_in)));
Expand All @@ -217,7 +217,7 @@ static mp_obj_t mp_builtin_len(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_builtin_len);

static mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
if (n_args == 1) {
// given an iterable
mp_obj_t iterable = rt_getiter(args[0]);
Expand Down Expand Up @@ -246,7 +246,7 @@ static mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_max_obj, 1, mp_builtin_max);

static mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
if (n_args == 1) {
// given an iterable
mp_obj_t iterable = rt_getiter(args[0]);
Expand Down Expand Up @@ -275,7 +275,7 @@ static mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_min_obj, 1, mp_builtin_min);

static mp_obj_t mp_builtin_next(mp_obj_t o) {
STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
mp_obj_t ret = rt_iternext(o);
if (ret == mp_const_stop_iteration) {
nlr_jump(mp_obj_new_exception(MP_QSTR_StopIteration));
Expand All @@ -286,7 +286,7 @@ static mp_obj_t mp_builtin_next(mp_obj_t o) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);

static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
uint len;
const char *str = mp_obj_str_get_data(o_in, &len);
if (len == 1) {
Expand All @@ -300,7 +300,7 @@ static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);

static mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3);
switch (n_args) {
case 2: return rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]);
Expand All @@ -310,7 +310,7 @@ static mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);

static mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args) {
for (int i = 0; i < n_args; i++) {
if (i > 0) {
printf(" ");
Expand All @@ -323,7 +323,7 @@ static mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_print_obj, 0, mp_builtin_print);

static mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) {
assert(1 <= n_args && n_args <= 3);
switch (n_args) {
case 1: return mp_obj_new_range(0, mp_obj_get_int(args[0]), 1);
Expand All @@ -334,7 +334,7 @@ static mp_obj_t mp_builtin_range(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_range_obj, 1, 3, mp_builtin_range);

static mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
vstr_t *vstr = vstr_new();
mp_obj_print_helper((void (*)(void *env, const char *fmt, ...))vstr_printf, vstr, o_in, PRINT_REPR);
mp_obj_t s = mp_obj_new_str((byte*)vstr->buf, vstr->len, false);
Expand All @@ -344,7 +344,7 @@ static mp_obj_t mp_builtin_repr(mp_obj_t o_in) {

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);

static mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
assert(1 <= n_args && n_args <= 2);
mp_obj_t value;
switch (n_args) {
Expand All @@ -361,7 +361,7 @@ static mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);

static mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
assert(n_args >= 1);
if (n_args > 1) {
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError,
Expand All @@ -375,7 +375,7 @@ static mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *k

MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted);

static mp_obj_t mp_builtin_str(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_str(mp_obj_t o_in) {
vstr_t *vstr = vstr_new();
mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf, vstr, o_in, PRINT_STR);
mp_obj_t s = mp_obj_new_str((byte*)vstr->buf, vstr->len, false);
Expand All @@ -386,7 +386,7 @@ static mp_obj_t mp_builtin_str(mp_obj_t o_in) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_str_obj, mp_builtin_str);

// TODO: This should be type, this is just quick CPython compat hack
static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
if (!MP_OBJ_IS_QSTR(args[0]) && !MP_OBJ_IS_TYPE(args[0], &str_type)) {
assert(0);
}
Expand All @@ -397,7 +397,7 @@ static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {

MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_bytes_obj, 1, 3, mp_builtin_bytes);

static mp_obj_t mp_builtin_id(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
return mp_obj_new_int((machine_int_t)o_in);
}

Expand Down
6 changes: 3 additions & 3 deletions py/builtinevex.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "map.h"
#include "builtin.h"

static mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
uint str_len;
const char *str = mp_obj_str_get_data(o_in, &str_len);

Expand Down Expand Up @@ -51,13 +51,13 @@ static mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse
return rt_call_function_0(module_fun);
}

static mp_obj_t mp_builtin_eval(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_eval(mp_obj_t o_in) {
return parse_compile_execute(o_in, MP_PARSE_EVAL_INPUT);
}

MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_eval_obj, mp_builtin_eval);

static mp_obj_t mp_builtin_exec(mp_obj_t o_in) {
STATIC mp_obj_t mp_builtin_exec(mp_obj_t o_in) {
return parse_compile_execute(o_in, MP_PARSE_FILE_INPUT);
}

Expand Down
Loading

0 comments on commit 520e2f5

Please sign in to comment.