aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary Pierson <zacpiersonhehe@gmail.com>2017-02-09 01:40:45 -0600
committerZachary Pierson <zacpiersonhehe@gmail.com>2017-02-09 01:40:45 -0600
commit3445a28c4a58fb52db89aeb66ba4356582680e1d (patch)
treef017b69a062c63edf9ee7de20c5dacb25d1df995 /src
parent7f6b83d50c0d9d7e2fefb189f1ce8a199c6bb561 (diff)
Code quality upkeep. Fixed a broken thread finding assembly instruction in gb.h
Diffstat (limited to 'src')
-rw-r--r--src/build.c23
-rw-r--r--src/gb/gb.h7
2 files changed, 18 insertions, 12 deletions
diff --git a/src/build.c b/src/build.c
index b8cbfa7a6..24712c626 100644
--- a/src/build.c
+++ b/src/build.c
@@ -317,8 +317,8 @@ void init_build_context(BuildContext *bc) {
// here, so I just #defined the linker flags to keep things concise.
#if defined(GB_SYSTEM_WINDOWS)
- #define linker_flag_x64 "/machine:x64"
- #define linker_flag_x86 "/machine:x86"
+ #define LINK_FLAG_X64 "/machine:x64"
+ #define LINK_FLAG_X86 "/machine:x86"
#elif defined(GB_SYSTEM_OSX)
@@ -326,30 +326,33 @@ void init_build_context(BuildContext *bc) {
// an architecture option. All compilation done on MacOS must be x64.
GB_ASSERT(str_eq(bc->ODIN_ARCH, str_lit("amd64")));
- #define linker_flag_x64 ""
- #define linker_flag_x86 ""
+ #define LINK_FLAG_X64 ""
+ #define LINK_FLAG_X86 ""
#else
// Linux, but also BSDs and the like.
// NOTE(zangent): When clang is swapped out with ld as the linker,
// the commented flags here should be used. Until then, we'll have
// to use alternative build flags made for clang.
/*
- #define linker_flag_x64 "-m elf_x86_64"
- #define linker_flag_x86 "-m elf_i386"
+ #define LINK_FLAG_X64 "-m elf_x86_64"
+ #define LINK_FLAG_X86 "-m elf_i386"
*/
- #define linker_flag_x64 "-arch x86-64"
- #define linker_flag_x86 "-arch x86"
+ #define LINK_FLAG_X64 "-arch x86-64"
+ #define LINK_FLAG_X86 "-arch x86"
#endif
if (str_eq(bc->ODIN_ARCH, str_lit("amd64"))) {
bc->word_size = 8;
bc->max_align = 16;
bc->llc_flags = str_lit("-march=x86-64 ");
- bc->link_flags = str_lit(linker_flag_x64 " ");
+ bc->link_flags = str_lit(LINK_FLAG_X64 " ");
} else if (str_eq(bc->ODIN_ARCH, str_lit("x86"))) {
bc->word_size = 4;
bc->max_align = 8;
bc->llc_flags = str_lit("-march=x86 ");
- bc->link_flags = str_lit(linker_flag_x86 " ");
+ bc->link_flags = str_lit(LINK_FLAG_X86 " ");
}
+
+ #undef LINK_FLAG_X64
+ #undef LINK_FLAG_X86
}
diff --git a/src/gb/gb.h b/src/gb/gb.h
index 1619914d6..0838f52aa 100644
--- a/src/gb/gb.h
+++ b/src/gb/gb.h
@@ -3630,7 +3630,10 @@ gb_inline void *gb_memcopy(void *dest, void const *source, isize n) {
__movsb(cast(u8 *)dest, cast(u8 *)source, n);
#elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX)
// NOTE(zangent): I assume there's a reason this isn't being used elsewhere,
- // but I don't see it and I can't seem to get this working any other way.
+ // but casting pointers as arguments to an __asm__ call is considered an
+ // error on MacOS and (I think) Linux
+ // TODO(zangent): Figure out how to refactor the asm code so it works on MacOS,
+ // since this is probably not the way the author intended this to work.
memcpy(dest, source, n);
#elif defined(GB_CPU_X86)
@@ -4684,7 +4687,7 @@ gb_inline u32 gb_thread_current_id(void) {
#elif defined(GB_ARCH_32_BIT) && defined(GB_CPU_X86)
__asm__("mov %%gs:0x08,%0" : "=r"(thread_id));
#elif defined(GB_ARCH_64_BIT) && defined(GB_CPU_X86)
- __asm__("mov %%gs:0x10,%0" : "=r"(thread_id));
+ __asm__("mov %%fs:0x10,%0" : "=r"(thread_id));
#else
#error Unsupported architecture for gb_thread_current_id()
#endif