1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: gmt offset; macos syscalls

This commit is contained in:
Alexander Medvednikov
2019-12-31 19:53:15 +01:00
parent 3c17851200
commit 87cff0386c
9 changed files with 63 additions and 33 deletions

View File

@@ -54,7 +54,7 @@ fn new_cgen(out_name_c string) &CGen {
out_path: path
out: out
// buf: strings.new_builder(10000)
lines: make(0, 1000, sizeof(string))
}
return gen
@@ -347,6 +347,9 @@ fn os_name_to_ifdef(name string) string {
'haiku' {
return '__haiku__'
}
'linux_or_macos' {
return ''
}
else {
verror('bad os ifdef name "$name"')
}}

View File

@@ -27,15 +27,21 @@ fn (p mut Parser) comp_time() {
if name == 'mac' {
p.warn('use `macos` instead of `mac`')
}
if not {
p.genln('#ifndef $ifdef_name')
}
else {
p.genln('#ifdef $ifdef_name')
if name == 'linux_or_macos' {
p.genln('#if defined(__linux) || defined(__APPLE__)')
} else {
p.genln('#ifdef $ifdef_name')
}
}
p.check(.lcbr)
os := os_from_string(name)
if ((!not && os != p.os) || (not && os == p.os)) && !p.scanner.is_fmt && !p.pref.output_cross_c {
if ((!not && os != p.os) || (not && os == p.os)) && !name.contains('_or_') &&
!p.scanner.is_fmt && !p.pref.output_cross_c {
// `$if os {` for a different target, skip everything inside
// to avoid compilation errors (like including <windows.h>
// on non-Windows systems)

View File

@@ -31,7 +31,7 @@ enum BuildMode {
const (
supported_platforms = ['windows', 'mac', 'macos', 'linux', 'freebsd', 'openbsd', 'netbsd',
'dragonfly', 'android', 'js', 'solaris', 'haiku']
'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
)
enum OS {
@@ -1281,6 +1281,9 @@ pub fn os_from_string(os string) OS {
'haiku' {
return .haiku
}
'linux_or_macos' {
return .linux
}
else {
panic('bad os $os')
}}