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):
`android`, `ios`,
`freebsd`, `openbsd`, `netbsd`, `dragonfly`,
`solaris`, `serenity`, `haiku`
`solaris`, `serenity`, `haiku`, `vinix`
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

View File

@ -21,7 +21,7 @@ const int_max = int(0x7FFFFFFF)
const (
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
'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_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32']
valid_comp_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian']

View File

@ -41,6 +41,7 @@ pub enum Platform {
android
solaris
serenity
vinix
haiku
raw
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 }
'solaris' { return .solaris }
'serenity' { return .serenity }
'vinix' { return .vinix }
'android' { return .android }
'haiku' { return .haiku }
'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.
#endif
#ifdef __linux__
#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__
#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
@ -362,11 +347,6 @@ voidptr memdup(voidptr src, int sz);
#include <sys/wait.h> // os__wait uses wait on nix
#endif
#ifdef __sun
#include <sys/types.h>
#include <sys/wait.h> // os__wait uses wait on nix
#endif
#ifdef _WIN32
#define WINVER 0x0600
#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' {
return '__serenity__'
}
'vinix' {
return '__vinix__'
}
'freebsd' {
return '__FreeBSD__'
}

View File

@ -17,6 +17,7 @@ pub enum OS {
android
solaris
serenity
vinix
haiku
raw
all
@ -36,6 +37,7 @@ pub fn os_from_string(os_str string) ?OS {
'js' { return .js }
'solaris' { return .solaris }
'serenity' { return .serenity }
'vinix' { return .vinix }
'android' { return .android }
'haiku' { return .haiku }
'raw' { return .raw }
@ -60,6 +62,7 @@ pub fn (o OS) str() string {
.android { return 'Android' }
.solaris { return 'Solaris' }
.serenity { return 'SerenityOS' }
.vinix { return 'Vinix' }
.haiku { return 'Haiku' }
.raw { return 'Raw' }
.all { return 'all' }
@ -94,6 +97,10 @@ pub fn get_host_os() OS {
$if serenity {
return .serenity
}
// TODO: uncomment the vinix block after v.c is regenerated
// $if vinix {
// return .vinix
// }
$if 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') {
return false
}
if prefs.os != .vinix && file.ends_with('_vinix.c.v') {
return false
}
return true
}