diff --git a/vlib/os/os.v b/vlib/os/os.v index 1194ab08743b50..ac736126588ce4 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -415,6 +415,9 @@ pub fn user_os() string { $if serenity { return 'serenity' } + //$if plan9 { + // return 'plan9' + //} $if vinix { return 'vinix' } diff --git a/vlib/v/ast/comptime_valid_idents.v b/vlib/v/ast/comptime_valid_idents.v index 3af42e776068bc..cac1ff036ccb03 100644 --- a/vlib/v/ast/comptime_valid_idents.v +++ b/vlib/v/ast/comptime_valid_idents.v @@ -3,7 +3,7 @@ module ast pub const ( valid_comptime_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', 'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'termux', - 'solaris', 'haiku', 'serenity', 'vinix'] + 'solaris', 'haiku', 'serenity', 'vinix', 'plan9'] valid_comptime_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus'] valid_comptime_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32'] valid_comptime_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian'] diff --git a/vlib/v/doc/doc.v b/vlib/v/doc/doc.v index c2d7b37ddd2a10..0ff27795858b33 100644 --- a/vlib/v/doc/doc.v +++ b/vlib/v/doc/doc.v @@ -42,6 +42,7 @@ pub enum Platform { termux // like android, but note that termux is running on devices natively, not cross compiling from other platforms solaris serenity + plan9 vinix haiku raw @@ -63,6 +64,7 @@ pub fn platform_from_string(platform_str string) !Platform { 'js' { return .js } 'solaris' { return .solaris } 'serenity' { return .serenity } + 'plan9' {return .plan9} 'vinix' { return .vinix } 'android' { return .android } 'termux' { return .termux } diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index 5fee252960ec76..787a0e886ad8a0 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -328,10 +328,10 @@ const c_common_macros = ' #else // On linux: int backtrace(void **__array, int __size); // On BSD: size_t backtrace(void **, size_t); - #endif + #endif #endif #endif - + #ifdef __TINYC__ #define _Atomic volatile #undef EMPTY_STRUCT_DECLARATION @@ -558,6 +558,11 @@ voidptr memdup(voidptr src, int sz); #include // os__wait uses wait on nix #endif +#if defined(__plan9__) + #include + #include +#endif + #ifdef __OpenBSD__ #include #include diff --git a/vlib/v/gen/c/comptime.v b/vlib/v/gen/c/comptime.v index 877b095ee5cad2..18b0301ec16143 100644 --- a/vlib/v/gen/c/comptime.v +++ b/vlib/v/gen/c/comptime.v @@ -1042,6 +1042,9 @@ fn (mut g Gen) comptime_if_to_ifdef(name string, is_comptime_option bool) !strin 'serenity' { return '__serenity__' } + 'plan9' { + return '__plan9__' + } 'vinix' { return '__vinix__' } diff --git a/vlib/v/gen/native/comptime.v b/vlib/v/gen/native/comptime.v index 3b16bab8213fdd..93180ec60f7239 100644 --- a/vlib/v/gen/native/comptime.v +++ b/vlib/v/gen/native/comptime.v @@ -98,6 +98,9 @@ fn (mut g Gen) comptime_ident(name string, is_comptime_option bool) bool { 'serenity' { g.pref.os == .serenity } + 'plan9' { + g.pref.os == .plan9 + } 'vinix' { g.pref.os == .vinix } diff --git a/vlib/v/help/build/build-c.txt b/vlib/v/help/build/build-c.txt index dd39d62bf8c569..ad91dda8989323 100644 --- a/vlib/v/help/build/build-c.txt +++ b/vlib/v/help/build/build-c.txt @@ -125,6 +125,7 @@ see also `v help build`. `android`, `termux`, `freebsd`, `openbsd`, `netbsd`, `dragonfly`, `solaris`, `serenity`, `haiku`, + `plan9`, `wasm32`, `wasm32-wasi`, `wasm32-emscripten` Note that V has the concept of platform files, i.e. files ending @@ -325,4 +326,4 @@ see also `v help build`. https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170&redirectedfrom=MSDN https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffast-math https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ffast-math - + diff --git a/vlib/v/pref/os.v b/vlib/v/pref/os.v index 2aa42c742712ef..ed49a8fbfd5ad0 100644 --- a/vlib/v/pref/os.v +++ b/vlib/v/pref/os.v @@ -23,6 +23,7 @@ pub enum OS { solaris qnx serenity + plan9 vinix haiku wasm32 @@ -85,6 +86,9 @@ pub fn os_from_string(os_str string) !OS { 'serenity' { return .serenity } + 'plan9' { + return .plan9 + } 'vinix' { return .vinix } @@ -154,6 +158,7 @@ pub fn (o OS) str() string { .solaris { return 'Solaris' } .qnx { return 'QNX' } .serenity { return 'SerenityOS' } + .plan9 { return 'Plan9'} .vinix { return 'Vinix' } .haiku { return 'Haiku' } .wasm32 { return 'WebAssembly' } @@ -207,6 +212,9 @@ pub fn get_host_os() OS { $if serenity { return .serenity } + //$if plan9 { + // return .plan9 + //} $if vinix { return .vinix } diff --git a/vlib/v/pref/should_compile.v b/vlib/v/pref/should_compile.v index 45cf28220de7f7..742ad96087581e 100644 --- a/vlib/v/pref/should_compile.v +++ b/vlib/v/pref/should_compile.v @@ -218,6 +218,9 @@ pub fn (prefs &Preferences) should_compile_c(file string) bool { if prefs.os != .serenity && file.ends_with('_serenity.c.v') { return false } + if prefs.os != .plan9 && file.ends_with('_plan9.c.v') { + return false + } if prefs.os != .vinix && file.ends_with('_vinix.c.v') { return false }