This commit is contained in:
gingerBill
2024-01-17 16:54:58 +00:00
8 changed files with 43 additions and 36 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ _protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags)
if .Write in flags { pflags |= PROT_WRITE }
if .Execute in flags { pflags |= PROT_EXEC }
err := _mprotect(data, size, pflags)
return err != 0
return err == 0
}
+1 -1
View File
@@ -40,7 +40,7 @@ _protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags)
if .Write in flags { pflags |= {.WRITE} }
if .Execute in flags { pflags |= {.EXEC} }
errno := linux.mprotect(data, size, pflags)
return errno != .NONE
return errno == .NONE
}
_platform_memory_init :: proc() {
-27
View File
@@ -1,27 +0,0 @@
{ pkgs ? import <nixpkgs> { } }:
let
odin-unwrapped = pkgs.llvmPackages_11.stdenv.mkDerivation (rec {
name = "odin-unwrapped";
src = ./.;
dontConfigure = true;
nativeBuildInputs = [ pkgs.git ];
buildPhase = ''
make debug SHELL=${pkgs.llvmPackages_11.stdenv.shell}
'';
installPhase = ''
mkdir -p $out/bin
cp odin $out/bin/odin
cp -r core $out/bin/core
'';
});
path = builtins.map (path: path + "/bin") (with pkgs.llvmPackages_11; [
bintools
llvm
clang
lld
]);
in
pkgs.writeScriptBin "odin" ''
#!${pkgs.llvmPackages_11.stdenv.shell}
PATH="${(builtins.concatStringsSep ":" path)}" exec ${odin-unwrapped}/bin/odin $@
''
+11
View File
@@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "odin";
nativeBuildInputs = with pkgs; [
git
clang_17
llvmPackages_17.llvm
llvmPackages_17.bintools
];
shellHook="CXX=clang++";
}
+8 -1
View File
@@ -582,7 +582,13 @@ gb_global TargetMetrics target_freestanding_amd64_sysv = {
TargetABI_SysV,
};
gb_global TargetMetrics target_freestanding_arm64 = {
TargetOs_freestanding,
TargetArch_arm64,
8, 8, 8, 16,
str_lit("aarch64-none-elf"),
str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"),
};
struct NamedTargetMetrics {
String name;
@@ -617,6 +623,7 @@ gb_global NamedTargetMetrics named_targets[] = {
{ str_lit("wasi_wasm64p32"), &target_wasi_wasm64p32 },
{ str_lit("freestanding_amd64_sysv"), &target_freestanding_amd64_sysv },
{ str_lit("freestanding_arm64"), &target_freestanding_arm64 },
};
gb_global NamedTargetMetrics *selected_target_metrics;
+20 -4
View File
@@ -174,7 +174,7 @@ gb_internal ExactValue exact_value_integer_from_string(String const &string) {
gb_internal f64 float_from_string(String const &string) {
gb_internal f64 float_from_string(String const &string, bool *success = nullptr) {
if (string.len < 128) {
char buf[128] = {};
isize n = 0;
@@ -187,7 +187,13 @@ gb_internal f64 float_from_string(String const &string) {
buf[n++] = cast(char)c;
}
buf[n] = 0;
return atof(buf);
char *end_ptr;
f64 f = strtod(buf, &end_ptr);
if (success != nullptr) {
*success = *end_ptr == '\0';
}
return f;
} else {
TEMPORARY_ALLOCATOR_GUARD();
char *buf = gb_alloc_array(temporary_allocator(), char, string.len+1);
@@ -201,7 +207,13 @@ gb_internal f64 float_from_string(String const &string) {
buf[n++] = cast(char)c;
}
buf[n] = 0;
return atof(buf);
char *end_ptr;
f64 f = strtod(buf, &end_ptr);
if (success != nullptr) {
*success = *end_ptr == '\0';
}
return f;
}
/*
isize i = 0;
@@ -313,7 +325,11 @@ gb_internal ExactValue exact_value_float_from_string(String string) {
return exact_value_integer_from_string(string);
}
f64 f = float_from_string(string);
bool success;
f64 f = float_from_string(string, &success);
if (!success) {
return {ExactValue_Invalid};
}
return exact_value_float(f);
}
+1 -1
View File
@@ -448,7 +448,7 @@ typedef i32 b32; // NOTE(bill): Prefer this!!!
#define gb_inline __forceinline
#endif
#else
#define gb_inline __attribute__ ((__always_inline__))
#define gb_inline inline __attribute__ ((__always_inline__))
#endif
#endif
+1 -1
View File
@@ -2503,7 +2503,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
LLVMCodeModel code_mode = LLVMCodeModelDefault;
if (is_arch_wasm()) {
code_mode = LLVMCodeModelJITDefault;
} else if (build_context.metrics.os == TargetOs_freestanding) {
} else if (is_arch_x86() && build_context.metrics.os == TargetOs_freestanding) {
code_mode = LLVMCodeModelKernel;
}