/* XXX: make it faster ? */ void g(int c) { int ind1; ind1 = ind + 1; if (ind1 > cur_text_section->data_allocated) section_realloc(cur_text_section, ind1); cur_text_section->data[ind] = c; ind = ind1; }
/*********************************************************** * 功能: 给节数据预留至少increment大小的内存空间 * sec: 预留内存空间的节 * increment: 预留的空间大小 * 返回值: 预留内存空间的首地址 **********************************************************/ void *section_ptr_add(Section *sec, int increment) { int offset, offset1; offset = sec->data_offset; offset1 = offset + increment; if (offset1 > sec->data_allocated) section_realloc(sec, offset1); sec->data_offset = offset1; return sec->data + offset; }
/* instruction + 4 bytes data. Return the address of the data */ static int oad(int c, int s) { int ind1; o(c); ind1 = ind + 4; if (ind1 > cur_text_section->data_allocated) section_realloc(cur_text_section, ind1); *(int *)(cur_text_section->data + ind) = s; s = ind; ind = ind1; return s; }
void o(uint32_t i) { /* this is a good place to start adding big-endian support*/ int ind1; ind1 = ind + 4; if (!cur_text_section) tcc_error("compiler error! This happens f.ex. if the compiler\n" "can't evaluate constant expressions outside of a function."); if (ind1 > cur_text_section->data_allocated) section_realloc(cur_text_section, ind1); cur_text_section->data[ind++] = i&255; i>>=8; cur_text_section->data[ind++] = i&255; i>>=8; cur_text_section->data[ind++] = i&255; i>>=8; cur_text_section->data[ind++] = i; }