aboutsummaryrefslogtreecommitdiff
path: root/core/flags
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2026-01-11 20:07:03 +0100
committerLaytan Laats <laytanlaats@hotmail.com>2026-01-11 20:21:21 +0100
commitc10771305d91b966f7520b830c398abffe4e9e1d (patch)
tree185497758d0298c4e23f15992a0bb48a44936863 /core/flags
parenta6ec199a52ae83603921fcf948fdf45e327fd17d (diff)
net: implement OpenBSD and NetBSD support & add stubs for other targets & cleanup
Diffstat (limited to 'core/flags')
-rw-r--r--core/flags/constants.odin3
-rw-r--r--core/flags/errors.odin8
-rw-r--r--core/flags/errors_bsd.odin9
-rw-r--r--core/flags/errors_nonbsd.odin12
-rw-r--r--core/flags/internal_rtti.odin14
-rw-r--r--core/flags/internal_rtti_nonbsd.odin32
6 files changed, 22 insertions, 56 deletions
diff --git a/core/flags/constants.odin b/core/flags/constants.odin
index dc2663e2a..154ed3cec 100644
--- a/core/flags/constants.odin
+++ b/core/flags/constants.odin
@@ -11,8 +11,7 @@ NO_CORE_NAMED_TYPES :: #config(ODIN_CORE_FLAGS_NO_CORE_NAMED_TYPES, false)
IMPORTING_TIME :: #config(ODIN_CORE_FLAGS_USE_TIME, time.IS_SUPPORTED)
// Override support for parsing `net` types.
-// TODO: Update this when the BSDs are supported.
-IMPORTING_NET :: #config(ODIN_CORE_FLAGS_USE_NET, ODIN_OS == .Windows || ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .FreeBSD)
+IMPORTING_NET :: #config(ODIN_CORE_FLAGS_USE_NET, ODIN_OS == .Windows || ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD)
TAG_ARGS :: "args"
SUBTAG_NAME :: "name"
diff --git a/core/flags/errors.odin b/core/flags/errors.odin
index 3d34a95d3..e9b2e18c8 100644
--- a/core/flags/errors.odin
+++ b/core/flags/errors.odin
@@ -1,5 +1,7 @@
package flags
+import "base:runtime"
+import "core:net"
import "core:os"
Parse_Error_Reason :: enum {
@@ -24,6 +26,12 @@ Parse_Error :: struct {
message: string,
}
+Unified_Parse_Error_Reason :: union #shared_nil {
+ Parse_Error_Reason,
+ runtime.Allocator_Error,
+ net.Parse_Endpoint_Error,
+}
+
// Raised during parsing.
// Provides more granular information than what just a string could hold.
Open_File_Error :: struct {
diff --git a/core/flags/errors_bsd.odin b/core/flags/errors_bsd.odin
deleted file mode 100644
index 4d98d2ee4..000000000
--- a/core/flags/errors_bsd.odin
+++ /dev/null
@@ -1,9 +0,0 @@
-#+build netbsd, openbsd
-package flags
-
-import "base:runtime"
-
-Unified_Parse_Error_Reason :: union #shared_nil {
- Parse_Error_Reason,
- runtime.Allocator_Error,
-}
diff --git a/core/flags/errors_nonbsd.odin b/core/flags/errors_nonbsd.odin
deleted file mode 100644
index 28912b57f..000000000
--- a/core/flags/errors_nonbsd.odin
+++ /dev/null
@@ -1,12 +0,0 @@
-#+build !netbsd
-#+build !openbsd
-package flags
-
-import "base:runtime"
-import "core:net"
-
-Unified_Parse_Error_Reason :: union #shared_nil {
- Parse_Error_Reason,
- runtime.Allocator_Error,
- net.Parse_Endpoint_Error,
-}
diff --git a/core/flags/internal_rtti.odin b/core/flags/internal_rtti.odin
index a1b050597..b3880afa0 100644
--- a/core/flags/internal_rtti.odin
+++ b/core/flags/internal_rtti.odin
@@ -5,6 +5,7 @@ import "base:intrinsics"
import "base:runtime"
import "core:fmt"
import "core:mem"
+import "core:net"
import "core:os"
import "core:reflect"
import "core:strconv"
@@ -310,7 +311,18 @@ parse_and_set_pointer_by_named_type :: proc(ptr: rawptr, str: string, data_type:
}
when IMPORTING_NET {
- if try_net_parse_workaround(data_type, str, ptr, out_error) {
+ if data_type == net.Host_Or_Endpoint {
+ addr, net_error := net.parse_hostname_or_endpoint(str)
+ if net_error != nil {
+ // We pass along `net.Error` here.
+ out_error^ = Parse_Error {
+ net_error,
+ "Invalid Host/Endpoint.",
+ }
+ return
+ }
+
+ (cast(^net.Host_Or_Endpoint)ptr)^ = addr
return
}
}
diff --git a/core/flags/internal_rtti_nonbsd.odin b/core/flags/internal_rtti_nonbsd.odin
deleted file mode 100644
index e1286186b..000000000
--- a/core/flags/internal_rtti_nonbsd.odin
+++ /dev/null
@@ -1,32 +0,0 @@
-#+private
-#+build !netbsd
-#+build !openbsd
-package flags
-
-import "core:net"
-
-// This proc exists purely as a workaround for import restrictions.
-// Returns true if caller should return early.
-try_net_parse_workaround :: #force_inline proc (
- data_type: typeid,
- str: string,
- ptr: rawptr,
- out_error: ^Error,
-) -> bool {
- if data_type == net.Host_Or_Endpoint {
- addr, net_error := net.parse_hostname_or_endpoint(str)
- if net_error != nil {
- // We pass along `net.Error` here.
- out_error^ = Parse_Error {
- net_error,
- "Invalid Host/Endpoint.",
- }
- return true
- }
-
- (cast(^net.Host_Or_Endpoint)ptr)^ = addr
- return true
- }
-
- return false
-}