fix compilation errors when bootstrapping with C++
This commit is contained in:
parent
3294cb10a9
commit
4105a91c48
6 changed files with 41 additions and 25 deletions
|
|
@ -1346,11 +1346,15 @@ when defined(linux) or defined(solaris) or defined(bsd) or defined(aix):
|
|||
setlen(result, len)
|
||||
|
||||
when defined(macosx):
|
||||
type
|
||||
cuint32* {.importc: "unsigned int", nodecl.} = int
|
||||
## This is the same as the type ``uint32_t`` in *C*.
|
||||
|
||||
# a really hacky solution: since we like to include 2 headers we have to
|
||||
# define two procs which in reality are the same
|
||||
proc getExecPath1(c: cstring, size: var int32) {.
|
||||
proc getExecPath1(c: cstring, size: var cuint32) {.
|
||||
importc: "_NSGetExecutablePath", header: "<sys/param.h>".}
|
||||
proc getExecPath2(c: cstring, size: var int32): bool {.
|
||||
proc getExecPath2(c: cstring, size: var cuint32): bool {.
|
||||
importc: "_NSGetExecutablePath", header: "<mach-o/dyld.h>".}
|
||||
|
||||
proc getAppFilename*(): string {.rtl, extern: "nos$1".} =
|
||||
|
|
@ -1379,7 +1383,7 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1".} =
|
|||
elif defined(bsd):
|
||||
result = getApplAux("/proc/" & $getpid() & "/file")
|
||||
elif defined(macosx):
|
||||
var size: int32
|
||||
var size: cuint32
|
||||
getExecPath1(nil, size)
|
||||
result = newString(int(size))
|
||||
if getExecPath2(result, size):
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ when defined(macosx) or defined(bsd):
|
|||
HW_AVAILCPU = 25
|
||||
HW_NCPU = 3
|
||||
proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
|
||||
a: var int, b: pointer, c: int): cint {.
|
||||
a: var csize, b: pointer, c: int): cint {.
|
||||
importc: "sysctl", header: "<sys/sysctl.h>".}
|
||||
|
||||
proc countProcessors*(): int {.rtl, extern: "nosp$1".} =
|
||||
|
|
@ -135,7 +135,8 @@ proc countProcessors*(): int {.rtl, extern: "nosp$1".} =
|
|||
elif defined(macosx) or defined(bsd):
|
||||
var
|
||||
mib: array[0..3, cint]
|
||||
len, numCPU: int
|
||||
numCPU: int
|
||||
len: csize
|
||||
mib[0] = CTL_HW
|
||||
mib[1] = HW_AVAILCPU
|
||||
len = sizeof(numCPU)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue