summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-10-28 22:21:23 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-20 15:35:58 +0100
commit9337d8bc3cde964ba804274fd6d09173c416614f (patch)
treeb30d25c20eab06175339fefee4eda0bbd6706d9c
parent4a3185b782dabeb664fcf2fa4f6d17e36cf23d0e (diff)
Some more work on cross-platform configuration
-rw-r--r--MODULE.bazel.lock12
-rw-r--r--asl/BUILD.bazel1
-rw-r--r--asl/annotations.hpp9
-rw-r--r--asl/assert.hpp11
-rw-r--r--asl/config.hpp17
-rw-r--r--asl/integers.hpp16
6 files changed, 49 insertions, 17 deletions
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index 21b358e..d62a47c 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -64,19 +64,19 @@
"@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=",
- "usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=",
+ "usagesDigest": "+hz7IHWN6A1oVJJWNDB6yZRG+RYhF76wAYItpAeIUIg=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
- "local_config_apple_cc": {
+ "local_config_apple_cc_toolchains": {
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
- "ruleClassName": "_apple_cc_autoconf",
+ "ruleClassName": "_apple_cc_autoconf_toolchains",
"attributes": {}
},
- "local_config_apple_cc_toolchains": {
+ "local_config_apple_cc": {
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
- "ruleClassName": "_apple_cc_autoconf_toolchains",
+ "ruleClassName": "_apple_cc_autoconf",
"attributes": {}
}
},
@@ -92,7 +92,7 @@
"@@platforms//host:extension.bzl%host_platform": {
"general": {
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
- "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=",
+ "usagesDigest": "pCYpDQmqMbmiiPI1p2Kd3VLm5T48rRAht5WdW0X2GlA=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
diff --git a/asl/BUILD.bazel b/asl/BUILD.bazel
index f7dddd1..ed26459 100644
--- a/asl/BUILD.bazel
+++ b/asl/BUILD.bazel
@@ -3,6 +3,7 @@ cc_library(
hdrs = [
"annotations.hpp",
"assert.hpp",
+ "config.hpp",
"format.hpp",
"integers.hpp",
"io.hpp",
diff --git a/asl/annotations.hpp b/asl/annotations.hpp
index 90e603f..a398e13 100644
--- a/asl/annotations.hpp
+++ b/asl/annotations.hpp
@@ -1,11 +1,10 @@
#pragma once
-#ifndef __clang__
- #error Not a valid environment
-#endif
+#include "asl/config.hpp"
+
-#ifdef _MSC_VER
+#if ASL_COMPILER_CLANG_CL
#define ASL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
-#else
+#elif ASL_COMPILER_CLANG
#define ASL_NO_UNIQUE_ADDRESS [[no_unique_address]]
#endif
diff --git a/asl/assert.hpp b/asl/assert.hpp
index d419c24..2322a5b 100644
--- a/asl/assert.hpp
+++ b/asl/assert.hpp
@@ -1,6 +1,13 @@
#pragma once
-// @Todo Make this portable-ish
+#include "asl/config.hpp"
+
+#if ASL_COMPILER_CLANG_CL
+ #define ASL_DEBUG_BREAK() __debugbreak()
+#elif ASL_COMPILER_CLANG
+ #define ASL_DEBUG_BREAK() __builtin_debug_trap()
+#endif
+
#define ASL_ASSERT(...) \
if (__VA_ARGS__) {} \
- else { __builtin_debugtrap(); }
+ else { ASL_DEBUG_BREAK(); }
diff --git a/asl/config.hpp b/asl/config.hpp
new file mode 100644
index 0000000..1e28252
--- /dev/null
+++ b/asl/config.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#if defined(_WIN32)
+ #define ASL_OS_WINDOWS 1
+#elif defined(__linux__)
+ #define ASL_OS_LINUX 1
+#else
+ #error Unknown OS
+#endif
+
+#if defined(__clang__) && defined(_MSC_VER)
+ #define ASL_COMPILER_CLANG_CL 1
+#elif defined(__clang__)
+ #define ASL_COMPILER_CLANG 1
+#else
+ #error Unknown compiler
+#endif
diff --git a/asl/integers.hpp b/asl/integers.hpp
index 716b981..8b7488f 100644
--- a/asl/integers.hpp
+++ b/asl/integers.hpp
@@ -1,16 +1,24 @@
#pragma once
+#include "asl/config.hpp"
+
using int8_t = signed char;
using int16_t = signed short;
using int32_t = signed int;
-using int64_t = signed long;
-
-// @Todo Proper type definition for Windows/Linux
+#if ASL_OS_WINDOWS
+ using int64_t = signed long long;
+#elif ASL_OS_LINUX
+ using int64_t = signed long;
+#endif
using uint8_t = unsigned char;
using uint16_t = unsigned short;
using uint32_t = unsigned int;
-using uint64_t = unsigned long;
+#if ASL_OS_WINDOWS
+ using uint64_t = unsigned long long;
+#elif ASL_OS_LINUX
+ using uint64_t = unsigned long;
+#endif
using size_t = uint64_t;
using isize_t = int64_t;