(platform_unix.c) Remove lots of hashes

This commit is contained in:
twinaphex 2018-02-25 17:58:36 +01:00
parent d6d89e10ba
commit 78406bef69

View File

@ -1158,57 +1158,40 @@ static enum frontend_powerstate frontend_unix_get_powerstate(
return ret; return ret;
} }
#define UNIX_ARCH_X86_64 0x23dea434U
#define UNIX_ARCH_X86 0x0b88b8cbU
#define UNIX_ARCH_ARM 0x0b885ea5U
#define UNIX_ARCH_PPC64 0x1028cf52U
#define UNIX_ARCH_MIPS 0x7c9aa25eU
#define UNIX_ARCH_TILE 0x7c9e7873U
#define UNIX_ARCH_AARCH64 0x191bfc0eU
#define UNIX_ARCH_ARMV7B 0xf27015f4U
#define UNIX_ARCH_ARMV7L 0xf27015feU
#define UNIX_ARCH_ARMV6L 0xf27015ddU
#define UNIX_ARCH_ARMV6B 0xf27015d3U
#define UNIX_ARCH_ARMV5TEB 0x28612995U
#define UNIX_ARCH_ARMV5TEL 0x4ecca435U
static enum frontend_architecture frontend_unix_get_architecture(void) static enum frontend_architecture frontend_unix_get_architecture(void)
{ {
struct utsname buffer; struct utsname buffer;
uint32_t buffer_hash = 0;
const char *val = NULL; const char *val = NULL;
if (uname(&buffer) != 0) if (uname(&buffer) != 0)
return FRONTEND_ARCH_NONE; return FRONTEND_ARCH_NONE;
val = buffer.machine; val = buffer.machine;
buffer_hash = djb2_calculate(val);
switch (buffer_hash) if (string_is_equal(hash, "aarch64"))
{ return FRONTEND_ARCH_ARMV8;
case UNIX_ARCH_AARCH64: else if (
return FRONTEND_ARCH_ARMV8; string_is_equal(hash, "armv7l") ||
case UNIX_ARCH_ARMV7L: string_is_equal(hash, "armv7b")
case UNIX_ARCH_ARMV7B: )
return FRONTEND_ARCH_ARMV7; return FRONTEND_ARCH_ARMV7;
case UNIX_ARCH_ARMV6L: else if (
case UNIX_ARCH_ARMV6B: string_is_equal(hash, "armv6l") ||
case UNIX_ARCH_ARMV5TEB: string_is_equal(hash, "armv6b") ||
case UNIX_ARCH_ARMV5TEL: string_is_equal(hash, "armv5tel") ||
return FRONTEND_ARCH_ARM; string_is_equal(hash, "arm")
case UNIX_ARCH_X86_64: )
return FRONTEND_ARCH_X86_64; return FRONTEND_ARCH_ARM;
case UNIX_ARCH_X86: else if (string_is_equal(hash, "x86_64"))
return FRONTEND_ARCH_X86_64;
else if (string_is_equal(hash, "x86"))
return FRONTEND_ARCH_X86; return FRONTEND_ARCH_X86;
case UNIX_ARCH_ARM: else if (string_is_equal(hash, "ppc64"))
return FRONTEND_ARCH_ARM;
case UNIX_ARCH_PPC64:
return FRONTEND_ARCH_PPC; return FRONTEND_ARCH_PPC;
case UNIX_ARCH_MIPS: else if (string_is_equal(hash, "mips"))
return FRONTEND_ARCH_MIPS; return FRONTEND_ARCH_MIPS;
case UNIX_ARCH_TILE: else if (string_is_equal(hash, "tile"))
return FRONTEND_ARCH_TILE; return FRONTEND_ARCH_TILE;
}
return FRONTEND_ARCH_NONE; return FRONTEND_ARCH_NONE;
} }