return entity;
}
+bool firm_is_unixish_os(const machine_triple_t *machine)
+{
+ const char *os = machine->operating_system;
+ return strstr(os, "linux") != NULL || strstr(os, "bsd") != NULL
+ || strstart(os, "solaris");
+}
+
+bool firm_is_darwin_os(const machine_triple_t *machine)
+{
+ const char *os = machine->operating_system;
+ return strstart(os, "darwin");
+}
+
+bool firm_is_windows_os(const machine_triple_t *machine)
+{
+ const char *os = machine->operating_system;
+ return strstart(os, "mingw") || streq(os, "win32");
+}
+
/**
* Initialize firm codegeneration for a specific operating system.
* The argument is the operating system part of a target-triple
*/
-static bool setup_os_support(const char *os)
+static bool setup_os_support(const machine_triple_t *machine)
{
- if (strstr(os, "linux") != NULL || strstr(os, "bsd") != NULL
- || streq(os, "solaris")) {
+ if (firm_is_unixish_os(machine)) {
set_be_option("ia32-gasmode=elf");
- } else if (strstart(os, "darwin")) {
+ } else if (firm_is_darwin_os(machine)) {
set_be_option("ia32-gasmode=macho");
set_be_option("ia32-stackalign=4");
set_be_option("pic=true");
set_compilerlib_entity_creator(underscore_compilerlib_entity_creator);
- } else if (strstr(os, "mingw") != NULL || streq(os, "win32")) {
+ } else if (firm_is_windows_os(machine)) {
set_be_option("ia32-gasmode=mingw");
set_compilerlib_entity_creator(underscore_compilerlib_entity_creator);
} else {
}
/* process operating system */
- if (!setup_os_support(machine->operating_system)) {
+ if (!setup_os_support(machine)) {
fprintf(stderr, "Unknown operating system '%s' in target-triple\n", machine->operating_system);
return false;
}
return FILETYPE_UNKNOWN;
}
-static bool is_windows_os(const char *os)
-{
- return strstr(os, "mingw") != NULL || streq(os, "win32");
-}
-
-static bool is_unixish_os(const char *os)
-{
- return strstr(os, "linux") != NULL || strstr(os, "bsd") != NULL
- || streq(os, "solaris");
-}
-
-static bool is_darwin_os(const char *os)
-{
- return streq(os, "darwin");
-}
-
static bool init_os_support(void)
{
- const char *os = target_machine->operating_system;
wchar_atomic_kind = ATOMIC_TYPE_INT;
enable_main_collect2_hack = false;
define_intmax_types = false;
- if (is_unixish_os(os)) {
+ if (firm_is_unixish_os(target_machine)) {
set_create_ld_ident(create_name_linux_elf);
- } else if (is_darwin_os(os)) {
+ } else if (firm_is_darwin_os(target_machine)) {
set_create_ld_ident(create_name_macho);
define_intmax_types = true;
- } else if (is_windows_os(os)) {
+ } else if (firm_is_windows_os(target_machine)) {
wchar_atomic_kind = ATOMIC_TYPE_USHORT;
enable_main_collect2_hack = true;
set_create_ld_ident(create_name_win32);
set_typeprops_type(&props[ATOMIC_TYPE_ULONGLONG], type_unsigned_long_long);
/* operating system ABI specifics */
- const char *os = target_machine->operating_system;
- if (is_darwin_os(os)) {
+ if (firm_is_darwin_os(target_machine)) {
if (machine_size == 32) {
props[ATOMIC_TYPE_LONGLONG].struct_alignment = 4;
props[ATOMIC_TYPE_ULONGLONG].struct_alignment = 4;
props[ATOMIC_TYPE_LONG_DOUBLE].alignment = 16;
props[ATOMIC_TYPE_LONG_DOUBLE].struct_alignment = 16;
}
- } else if (is_windows_os(os)) {
+ } else if (firm_is_windows_os(target_machine)) {
if (machine_size == 64) {
/* to ease porting of old c-code microsoft decided to use 32bits
* even for long */
/* on windows long double is not supported */
props[ATOMIC_TYPE_LONG_DOUBLE] = props[ATOMIC_TYPE_DOUBLE];
- } else if (is_unixish_os(os)) {
+ } else if (firm_is_unixish_os(target_machine)) {
if (is_ia32_cpu(target_machine->cpu_type)) {
/* System V has a broken alignment for double so we have to add
* a hack here */