⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hipe_mkliterals.c

📁 OTP是开放电信平台的简称
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* special Erlang constants */    { "THE_NON_VALUE", THE_NON_VALUE },    /* funs */#ifdef HIPE    { "EFE_NATIVE_ADDRESS", offsetof(struct erl_fun_entry, native_address) },#endif    { "EFE_REFC", offsetof(struct erl_fun_entry, refc) },    { "EFT_THING", offsetof(struct erl_fun_thing, thing_word) },    /* bit syntax */    { "BSF_ALIGNED", BSF_ALIGNED},    { "MB_ORIG", offsetof(struct erl_bin_match_buffer, orig) },    { "MB_BASE", offsetof(struct erl_bin_match_buffer, base) },    { "MB_OFFSET", offsetof(struct erl_bin_match_buffer, offset) },    { "MB_SIZE", offsetof(struct erl_bin_match_buffer, size) },    { "PROC_BIN_THING_WORD", offsetof(struct proc_bin, thing_word) },    { "PROC_BIN_BINSIZE", offsetof(struct proc_bin, size) },    { "PROC_BIN_NEXT", offsetof(struct proc_bin, next) },    { "PROC_BIN_VAL", offsetof(struct proc_bin, val) },    { "PROC_BIN_BYTES", offsetof(struct proc_bin, bytes) },    { "PROC_BIN_WORDSIZE", PROC_BIN_SIZE},    { "SUB_BIN_THING_WORD", offsetof(struct erl_sub_bin, thing_word) },    { "SUB_BIN_BINSIZE", offsetof(struct erl_sub_bin, size) },    { "SUB_BIN_BITSIZE", offsetof(struct erl_sub_bin, bitsize) },    { "SUB_BIN_OFFS", offsetof(struct erl_sub_bin, offs) },    { "SUB_BIN_BITOFFS", offsetof(struct erl_sub_bin, bitoffs) },    { "SUB_BIN_ORIG", offsetof(struct erl_sub_bin, orig) },    { "SUB_BIN_WORDSIZE", ERL_SUB_BIN_SIZE},    { "HEAP_BIN_THING_WORD", offsetof(struct erl_heap_bin, thing_word) },    { "HEAP_BIN_SIZE", offsetof(struct erl_heap_bin, size) },    { "HEAP_BIN_DATA", offsetof(struct erl_heap_bin, data) },    { "BINARY_ORIG_BYTES", offsetof(struct binary, orig_bytes) },    { "MAX_HEAP_BIN_SIZE", ERL_ONHEAP_BIN_LIMIT},    { "MS_THING_WORD", offsetof(struct erl_bin_match_struct, thing_word)},    { "MS_MATCHBUFFER", offsetof(struct erl_bin_match_struct, mb)},    { "MS_SAVEOFFSET", offsetof(struct erl_bin_match_struct, save_offset)},        /* messages */    { "P_MSG_FIRST", offsetof(struct process, msg.first) },    { "P_MSG_SAVE", offsetof(struct process, msg.save) },    { "MSG_NEXT", offsetof(struct erl_mesg, next) },    /* ARM */    { "ARM_LEAF_WORDS", ARM_LEAF_WORDS },    { "ARM_NR_ARG_REGS", ARM_NR_ARG_REGS },    /* PowerPC */    { "PPC_LEAF_WORDS", PPC_LEAF_WORDS },    { "PPC_NR_ARG_REGS", PPC_NR_ARG_REGS },    /* Amd64 */    { "AMD64_LEAF_WORDS", AMD64_LEAF_WORDS },    { "AMD64_NR_ARG_REGS", AMD64_NR_ARG_REGS },#if AMD64_HP_IN_REGISTER    { "AMD64_HP_IN_REGISTER", 1 },    { "AMD64_HEAP_POINTER", AMD64_HEAP_POINTER },#endif#if AMD64_FCALLS_IN_REGISTER    { "AMD64_FCALLS_IN_REGISTER", 1 },    { "AMD64_FCALLS_REGISTER", AMD64_FCALLS_REGISTER },#endif#if AMD64_HEAP_LIMIT_IN_REGISTER    { "AMD64_HEAP_LIMIT_IN_REGISTER", 1 },    { "AMD64_HEAP_LIMIT_REGISTER", AMD64_HEAP_LIMIT_REGISTER },#endif#if AMD64_SIMULATE_NSP    { "AMD64_SIMULATE_NSP", 1 },#endif    /* x86 */    { "X86_LEAF_WORDS", X86_LEAF_WORDS },    { "X86_NR_ARG_REGS", X86_NR_ARG_REGS },    /* Jag vet att detta suger.. temp dock. */    { "X86_NR_RET_REGS", 3}, #if X86_HP_IN_ESI    { "X86_HP_IN_ESI", 1 },#endif#if X86_SIMULATE_NSP    { "X86_SIMULATE_NSP", 1 },#endif    /* SPARC */    { "SPARC_LEAF_WORDS", SPARC_LEAF_WORDS },    { "SPARC_NR_ARG_REGS", SPARC_NR_ARG_REGS},};#define NR_LITERALS	ARRAY_SIZE(literals)/* * Runtime system parameters. * These depend on configuration options such as heap architecture. * The compiler accesses these through hipe_bifs:get_rts_param/1. */static const struct rts_param {    unsigned int nr;    const char *name;    unsigned int is_defined;    unsigned int value;} rts_params[] = {    { 1, "P_OFF_HEAP_FUNS",#if !defined(HYBRID)      1, offsetof(struct process, off_heap.funs)#endif    },    { 4, "EFT_NEXT",#if !defined(HYBRID)      1, offsetof(struct erl_fun_thing, next)#endif    },    /* These are always defined, but their values depend on the       presence or absence of struct erl_fun_thing's "next" field. */    { 5, "EFT_CREATOR", 1, offsetof(struct erl_fun_thing, creator) },    { 6, "EFT_FE", 1, offsetof(struct erl_fun_thing, fe) },#ifdef HIPE    { 7, "EFT_NATIVE_ADDRESS", 1, offsetof(struct erl_fun_thing, native_address) },#endif    { 8, "EFT_ARITY", 1, offsetof(struct erl_fun_thing, arity) },    { 9, "EFT_NUM_FREE", 1, offsetof(struct erl_fun_thing, num_free) },    { 10, "EFT_ENV", 1, offsetof(struct erl_fun_thing, env[0]) },    { 11, "ERL_FUN_SIZE", 1, ERL_FUN_SIZE },    { 12, "P_SCHED_DATA",#ifdef ERTS_SMP      1, offsetof(struct process, scheduler_data)#endif    },    { 13, "SCHED_DATA_ERTS_MB_OFFS",#if defined(ERTS_SMP) && !defined(HEAP_FRAG_ELIM_TEST)      1, offsetof(ErtsSchedulerData, erl_bits_state.erts_mb_)#endif    },    { 14, "P_FP_EXCEPTION",#if !defined(NO_FPE_SIGNALS)      1, offsetof(struct process, fp_exception)#endif    },    /* This flag is always defined, but its value is configuration-dependent. */    { 15, "ERTS_IS_SMP",      1,#if defined(ERTS_SMP)      1#else      0#endif    },    /* This parameter is always defined, but its value depends on ERTS_SMP. */    { 19, "MSG_MESSAGE",      1, offsetof(struct erl_mesg, m[0])    },    /* This flag is always defined, but its value is configuration-dependent. */    { 20, "ERTS_IS_NOFRAG",      1,#if defined(HEAP_FRAG_ELIM_TEST)      1#else      0#endif    },    { 21, "P_MBUF",#if defined(HEAP_FRAG_ELIM_TEST)      1, offsetof(struct process, mbuf)#endif    },};#define NR_PARAMS	ARRAY_SIZE(rts_params)static unsigned int literals_crc;static unsigned int system_crc;static void compute_crc(void){    unsigned int crc_value;    unsigned int i;    crc_value = crc_init();    for(i = 0; i < NR_LITERALS; ++i)	crc_value = crc_update_int(crc_value, &literals[i].value);    crc_value &= 0x07FFFFFF;    literals_crc = crc_value;    for(i = 0; i < NR_PARAMS; ++i)	if( rts_params[i].is_defined )	    crc_value = crc_update_int(crc_value, &rts_params[i].value);    crc_value &= 0x07FFFFFF;    system_crc = crc_value;}static void c_define_literal(FILE *fp, const struct literal *literal){    fprintf(fp, "#define %s %u\n", literal->name, literal->value);}static void e_define_literal(FILE *fp, const struct literal *literal){    fprintf(fp, "-define(%s,%u).\n", literal->name, literal->value);}static void print_literals(FILE *fp, void (*print_literal)(FILE*,const struct literal*)){    unsigned int i;    for(i = 0; i < NR_LITERALS; ++i)	(*print_literal)(fp, &literals[i]);}static void c_define_param(FILE *fp, const struct rts_param *param){    if( param->is_defined )	fprintf(fp, "#define %s %u\n", param->name, param->value);}static void c_case_param(FILE *fp, const struct rts_param *param){    fprintf(fp, " \\\n");    fprintf(fp, "\tcase %u: ", param->nr);    if( param->is_defined )	fprintf(fp, "value = %u", param->value);    else	fprintf(fp, "is_defined = 0");    fprintf(fp, "; break;");}static void e_define_param(FILE *fp, const struct rts_param *param){    fprintf(fp, "-define(%s,hipe_bifs:get_rts_param(%u)).\n", param->name, param->nr);}static void print_params(FILE *fp, void (*print_param)(FILE*,const struct rts_param*)){    unsigned int i;    for(i = 0; i < NR_PARAMS; ++i)	(*print_param)(fp, &rts_params[i]);}static int do_c(FILE *fp){    fprintf(fp, "/* File: hipe_literals.h, generated by hipe_mkliterals */\n");    fprintf(fp, "#ifndef __HIPE_LITERALS_H__\n");    fprintf(fp, "#define __HIPE_LITERALS_H__\n\n");    print_literals(fp, c_define_literal);    print_params(fp, c_define_param);    fprintf(fp, "#define HIPE_LITERALS_CRC %uU\n", literals_crc);    fprintf(fp, "#define HIPE_SYSTEM_CRC %uU\n", system_crc);    fprintf(fp, "\n");    fprintf(fp, "#define RTS_PARAMS_CASES");    print_params(fp, c_case_param);    fprintf(fp, "\n#endif\n");    return 0;}static int do_e(FILE *fp){    fprintf(fp, "%% File: hipe_literals.hrl, generated by hipe_mkliterals\n\n");    print_literals(fp, e_define_literal);    print_params(fp, e_define_param);    fprintf(fp, "-define(HIPE_SYSTEM_CRC,hipe_bifs:system_crc(%u)).\n", literals_crc);    return 0;}int main(int argc, const char **argv){    compute_crc();    if( argc == 2 ) {	if( strcmp(argv[1], "-c") == 0 )	    return do_c(stdout);	if( strcmp(argv[1], "-e") == 0 )	    return do_e(stdout);    }    fprintf(stderr, "usage: %s [-c | -e] > output-file\n", argv[0]);    return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -