+static ident *predef_idents[rts_max];
+
+/** Names of the runtime functions. */
+static const struct {
+ int id; /**< the rts id */
+ int n_res; /**< number of return values */
+ const char *name; /**< the name of the rts function */
+ int n_params; /**< number of parameters */
+ unsigned flags; /**< language flags */
+} rts_data[] = {
+ { rts_debugbreak, 0, "__debugbreak", 0, _MS },
+ { rts_abort, 0, "abort", 0, _C89 },
+ { rts_abs, 1, "abs", 1, _C89 },
+ { rts_labs, 1, "labs", 1, _C89 },
+ { rts_llabs, 1, "llabs", 1, _C99 },
+ { rts_imaxabs, 1, "imaxabs", 1, _C99 },
+
+ { rts_fabs, 1, "fabs", 1, _C89 },
+ { rts_sqrt, 1, "sqrt", 1, _C89 },
+ { rts_cbrt, 1, "cbrt", 1, _C99 },
+ { rts_exp, 1, "exp", 1, _C89 },
+ { rts_exp2, 1, "exp2", 1, _C89 },
+ { rts_exp10, 1, "exp10", 1, _GNUC },
+ { rts_log, 1, "log", 1, _C89 },
+ { rts_log2, 1, "log2", 1, _C89 },
+ { rts_log10, 1, "log10", 1, _C89 },
+ { rts_pow, 1, "pow", 2, _C89 },
+ { rts_sin, 1, "sin", 1, _C89 },
+ { rts_cos, 1, "cos", 1, _C89 },
+ { rts_tan, 1, "tan", 1, _C89 },
+ { rts_asin, 1, "asin", 1, _C89 },
+ { rts_acos, 1, "acos", 1, _C89 },
+ { rts_atan, 1, "atan", 1, _C89 },
+ { rts_sinh, 1, "sinh", 1, _C89 },
+ { rts_cosh, 1, "cosh", 1, _C89 },
+ { rts_tanh, 1, "tanh", 1, _C89 },
+
+ { rts_fabsf, 1, "fabsf", 1, _C99 },
+ { rts_sqrtf, 1, "sqrtf", 1, _C99 },
+ { rts_cbrtf, 1, "cbrtf", 1, _C99 },
+ { rts_expf, 1, "expf", 1, _C99 },
+ { rts_exp2f, 1, "exp2f", 1, _C99 },
+ { rts_exp10f, 1, "exp10f", 1, _GNUC },
+ { rts_logf, 1, "logf", 1, _C99 },
+ { rts_log2f, 1, "log2f", 1, _C99 },
+ { rts_log10f, 1, "log10f", 1, _C99 },
+ { rts_powf, 1, "powf", 2, _C99 },
+ { rts_sinf, 1, "sinf", 1, _C99 },
+ { rts_cosf, 1, "cosf", 1, _C99 },
+ { rts_tanf, 1, "tanf", 1, _C99 },
+ { rts_asinf, 1, "asinf", 1, _C99 },
+ { rts_acosf, 1, "acosf", 1, _C99 },
+ { rts_atanf, 1, "atanf", 1, _C99 },
+ { rts_sinhf, 1, "sinhf", 1, _C99 },
+ { rts_coshf, 1, "coshf", 1, _C99 },
+ { rts_tanhf, 1, "tanhf", 1, _C99 },
+
+ { rts_fabsl, 1, "fabsl", 1, _C99 },
+ { rts_sqrtl, 1, "sqrtl", 1, _C99 },
+ { rts_cbrtl, 1, "cbrtl", 1, _C99 },
+ { rts_expl, 1, "expl", 1, _C99 },
+ { rts_exp2l, 1, "exp2l", 1, _C99 },
+ { rts_exp10l, 1, "exp10l", 1, _GNUC },
+ { rts_logl, 1, "logl", 1, _C99 },
+ { rts_log2l, 1, "log2l", 1, _C99 },
+ { rts_log10l, 1, "log10l", 1, _C99 },
+ { rts_powl, 1, "powl", 2, _C99 },
+ { rts_sinl, 1, "sinl", 1, _C99 },
+ { rts_cosl, 1, "cosl", 1, _C99 },
+ { rts_tanl, 1, "tanl", 1, _C99 },
+ { rts_asinl, 1, "asinl", 1, _C99 },
+ { rts_acosl, 1, "acosl", 1, _C99 },
+ { rts_atanl, 1, "atanl", 1, _C99 },
+ { rts_sinhl, 1, "sinhl", 1, _C99 },
+ { rts_coshl, 1, "coshl", 1, _C99 },
+ { rts_tanhl, 1, "tanhl", 1, _C99 },
+
+ { rts_memcpy, 1, "memcpy", 3, _C89 }, /* HMM, man say its C99 */
+ { rts_memset, 1, "memset", 3, _C89 }, /* HMM, man say its C99 */
+ { rts_strcmp, 1, "strcmp", 2, _C89 },
+ { rts_strncmp, 1, "strncmp", 3, _C89 }
+};
+
+/**
+ * Mangles an entity linker (ld) name for win32 usage.
+ *
+ * @param ent the entity to be mangled
+ * @param declaration the declaration
+ */
+static ident *create_ld_ident_win32(ir_entity *ent, declaration_t *declaration)
+{
+ ident *id;
+
+ if (is_Method_type(get_entity_type(ent)))
+ id = decorate_win32_c_fkt(ent, get_entity_ident(ent));
+ else {
+ /* always add an underscore in win32 */
+ id = mangle(id_underscore, get_entity_ident(ent));
+ }
+
+ decl_modifiers_t decl_modifiers = declaration->decl_modifiers;
+ if (decl_modifiers & DM_DLLIMPORT) {
+ /* add prefix for imported symbols */
+ id = mangle(id_imp, id);
+ }
+ return id;
+}
+
+/**
+ * Mangles an entity linker (ld) name for Linux ELF usage.
+ *
+ * @param ent the entity to be mangled
+ * @param declaration the declaration
+ */
+static ident *create_ld_ident_linux_elf(ir_entity *entity,
+ declaration_t *declaration)
+{
+ (void) declaration;
+ return get_entity_ident(entity);
+}
+
+/**
+ * Mangles an entity linker (ld) name for Mach-O usage.
+ *
+ * @param ent the entity to be mangled
+ * @param declaration the declaration
+ */
+static ident *create_ld_ident_macho(ir_entity *ent, declaration_t *declaration)
+{
+ (void) declaration;
+ ident *id = mangle(id_underscore, get_entity_ident(ent));
+ return id;
+}
+
+typedef ident* (*create_ld_ident_func)(ir_entity *entity,
+ declaration_t *declaration);
+create_ld_ident_func create_ld_ident = create_ld_ident_linux_elf;
+