vinix: support -os vinix (part 1)

pull/10787/head
Delyan Angelov 2021-07-13 11:09:32 +03:00
parent 2a9d6fef9f
commit 85564b7b83
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
7 changed files with 18 additions and 23 deletions

View File

@ -97,7 +97,7 @@ see also `v help build`.
systems also (although we do not test it as regularly as for the above): systems also (although we do not test it as regularly as for the above):
`android`, `ios`, `android`, `ios`,
`freebsd`, `openbsd`, `netbsd`, `dragonfly`, `freebsd`, `openbsd`, `netbsd`, `dragonfly`,
`solaris`, `serenity`, `haiku` `solaris`, `serenity`, `haiku`, `vinix`
Note that V has the concept of platform files, i.e. files ending Note that V has the concept of platform files, i.e. files ending
with `_platform.c.v`, and usually only the matching files are used in with `_platform.c.v`, and usually only the matching files are used in

View File

@ -21,7 +21,7 @@ const int_max = int(0x7FFFFFFF)
const ( const (
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris',
'haiku', 'serenity'] 'haiku', 'serenity', 'vinix']
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus'] valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
valid_comp_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32'] valid_comp_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32']
valid_comp_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian'] valid_comp_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian']

View File

@ -41,6 +41,7 @@ pub enum Platform {
android android
solaris solaris
serenity serenity
vinix
haiku haiku
raw raw
cross // TODO: add functionality for v doc -os cross whenever possible cross // TODO: add functionality for v doc -os cross whenever possible
@ -61,6 +62,7 @@ pub fn platform_from_string(platform_str string) ?Platform {
'js' { return .js } 'js' { return .js }
'solaris' { return .solaris } 'solaris' { return .solaris }
'serenity' { return .serenity } 'serenity' { return .serenity }
'vinix' { return .vinix }
'android' { return .android } 'android' { return .android }
'haiku' { return .haiku } 'haiku' { return .haiku }
'nix' { return .linux } 'nix' { return .linux }

View File

@ -332,22 +332,7 @@ voidptr memdup(voidptr src, int sz);
#error Cygwin is not supported, please use MinGW or Visual Studio. #error Cygwin is not supported, please use MinGW or Visual Studio.
#endif #endif
#ifdef __linux__ #ifdef defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__vinix__) || defined(__serenity__) || defined(__sun)
#include <sys/types.h>
#include <sys/wait.h> // os__wait uses wait on nix
#endif
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/wait.h> // os__wait uses wait on nix
#endif
#ifdef __DragonFly__
#include <sys/types.h>
#include <sys/wait.h> // os__wait uses wait on nix
#endif
#ifdef __serenity__
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> // os__wait uses wait on nix #include <sys/wait.h> // os__wait uses wait on nix
#endif #endif
@ -362,11 +347,6 @@ voidptr memdup(voidptr src, int sz);
#include <sys/wait.h> // os__wait uses wait on nix #include <sys/wait.h> // os__wait uses wait on nix
#endif #endif
#ifdef __sun
#include <sys/types.h>
#include <sys/wait.h> // os__wait uses wait on nix
#endif
#ifdef _WIN32 #ifdef _WIN32
#define WINVER 0x0600 #define WINVER 0x0600
#ifdef _WIN32_WINNT #ifdef _WIN32_WINNT

View File

@ -566,6 +566,9 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) ?string
'serenity' { 'serenity' {
return '__serenity__' return '__serenity__'
} }
'vinix' {
return '__vinix__'
}
'freebsd' { 'freebsd' {
return '__FreeBSD__' return '__FreeBSD__'
} }

View File

@ -17,6 +17,7 @@ pub enum OS {
android android
solaris solaris
serenity serenity
vinix
haiku haiku
raw raw
all all
@ -36,6 +37,7 @@ pub fn os_from_string(os_str string) ?OS {
'js' { return .js } 'js' { return .js }
'solaris' { return .solaris } 'solaris' { return .solaris }
'serenity' { return .serenity } 'serenity' { return .serenity }
'vinix' { return .vinix }
'android' { return .android } 'android' { return .android }
'haiku' { return .haiku } 'haiku' { return .haiku }
'raw' { return .raw } 'raw' { return .raw }
@ -60,6 +62,7 @@ pub fn (o OS) str() string {
.android { return 'Android' } .android { return 'Android' }
.solaris { return 'Solaris' } .solaris { return 'Solaris' }
.serenity { return 'SerenityOS' } .serenity { return 'SerenityOS' }
.vinix { return 'Vinix' }
.haiku { return 'Haiku' } .haiku { return 'Haiku' }
.raw { return 'Raw' } .raw { return 'Raw' }
.all { return 'all' } .all { return 'all' }
@ -94,6 +97,10 @@ pub fn get_host_os() OS {
$if serenity { $if serenity {
return .serenity return .serenity
} }
// TODO: uncomment the vinix block after v.c is regenerated
// $if vinix {
// return .vinix
// }
$if solaris { $if solaris {
return .solaris return .solaris
} }

View File

@ -184,6 +184,9 @@ pub fn (prefs &Preferences) should_compile_c(file string) bool {
if prefs.os != .serenity && file.ends_with('_serenity.c.v') { if prefs.os != .serenity && file.ends_with('_serenity.c.v') {
return false return false
} }
if prefs.os != .vinix && file.ends_with('_vinix.c.v') {
return false
}
return true return true
} }