From 54f6280d7659ce057a64cd9878a17c26065a7321 Mon Sep 17 00:00:00 2001 From: Luis Ricardo Date: Tue, 7 Oct 2014 17:02:50 -0400 Subject: Update cpuinfo.nim sys/types.h needed for macosx and freebsd sys/param.h needed for openbsd and netbsd --- lib/pure/concurrency/cpuinfo.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index dfa819f64..cd8e5b14a 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -18,15 +18,22 @@ when not defined(windows): when defined(linux): import linux + +when defined(freebsd) or defined(macosx): + {.emit:"#include ".} + +when defined(openbsd) or defined(netbsd): + {.emit:"#include ".} when defined(macosx) or defined(bsd): + {.emit:"#include ".} const CTL_HW = 6 HW_AVAILCPU = 25 HW_NCPU = 3 proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer, a: var csize, b: pointer, c: int): cint {. - importc: "sysctl", header: "".} + importc: "sysctl".} proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. -- cgit 1.4.1-2-gfad0 From fa3545c092522a43517669387ad2a953a4a2fd04 Mon Sep 17 00:00:00 2001 From: Simon Krauter Date: Fri, 10 Oct 2014 23:24:28 +0200 Subject: Raise exception on adding a non-existent file to a zip archive --- lib/impure/zipfiles.nim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim index 1726449d8..63b8a843d 100644 --- a/lib/impure/zipfiles.nim +++ b/lib/impure/zipfiles.nim @@ -56,6 +56,11 @@ proc addFile*(z: var TZipArchive, dest, src: string) = ## Adds the file `src` to the archive `z` with the name `dest`. `dest` ## may contain a path that will be created. assert(z.mode != fmRead) + if not fileExists(src): + var e: ref EIO + new(e) + e.msg = "File does not exist" + raise e var zipsrc = zip_source_file(z.w, src, 0, -1) if zipsrc == nil: #echo("Dest: " & dest) -- cgit 1.4.1-2-gfad0 From d526e051c516ced3533f421637ca2ea3c11e03db Mon Sep 17 00:00:00 2001 From: Simon Krauter Date: Sat, 11 Oct 2014 00:20:49 +0200 Subject: Code more cleaner --- lib/impure/zipfiles.nim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim index 63b8a843d..b9f89dda0 100644 --- a/lib/impure/zipfiles.nim +++ b/lib/impure/zipfiles.nim @@ -57,10 +57,7 @@ proc addFile*(z: var TZipArchive, dest, src: string) = ## may contain a path that will be created. assert(z.mode != fmRead) if not fileExists(src): - var e: ref EIO - new(e) - e.msg = "File does not exist" - raise e + raise newException(EIO, "File '" & src & "' does not exist") var zipsrc = zip_source_file(z.w, src, 0, -1) if zipsrc == nil: #echo("Dest: " & dest) -- cgit 1.4.1-2-gfad0 From 6c9730b3534927ac2bdd4ec7c77e0d37bba7aa2e Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 11 Oct 2014 12:25:15 +0200 Subject: fixes #1551 --- compiler/semexprs.nim | 5 +++++ lib/pure/concurrency/threadpool.nim | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index ff445ecd0..46e6f1ab3 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1614,6 +1614,11 @@ proc instantiateCreateFlowVarCall(c: PContext; t: PType; initIdTable(bindings) bindings.idTablePut(sym.ast[genericParamsPos].sons[0].typ, t) result = c.semGenerateInstance(c, sym, bindings, info) + # since it's an instantiation, we unmark it as a compilerproc. Otherwise + # codegen would fail: + if sfCompilerProc in result.flags: + result.flags = result.flags - {sfCompilerProc, sfExportC, sfImportC} + result.loc.r = nil proc setMs(n: PNode, s: PSym): PNode = result = n diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index e0a2ac678..f46822d94 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -95,7 +95,7 @@ type FlowVarBase* = ref FlowVarBaseObj ## untyped base class for 'FlowVar[T]' FlowVarBaseObj = object of TObject - ready, usesCondVar: bool + ready, usesCondVar, awaited: bool cv: CondVar #\ # for 'awaitAny' support ai: ptr AwaitInfo @@ -129,8 +129,8 @@ type proc await*(fv: FlowVarBase) = ## waits until the value for the flowVar arrives. Usually it is not necessary ## to call this explicitly. - if fv.usesCondVar: - fv.usesCondVar = false + if fv.usesCondVar and not fv.awaited: + fv.awaited = true await(fv.cv) destroyCondVar(fv.cv) -- cgit 1.4.1-2-gfad0 From 753d18d66c978b192b5c4fcf9b86c755c3fa9266 Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 11 Oct 2014 13:16:51 +0200 Subject: minor cleanup for cpuinfo --- lib/pure/concurrency/cpuinfo.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index cd8e5b14a..bd10a416f 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -26,14 +26,13 @@ when defined(openbsd) or defined(netbsd): {.emit:"#include ".} when defined(macosx) or defined(bsd): - {.emit:"#include ".} const CTL_HW = 6 HW_AVAILCPU = 25 HW_NCPU = 3 proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer, a: var csize, b: pointer, c: int): cint {. - importc: "sysctl".} + importc: "sysctl", header: "".} proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. -- cgit 1.4.1-2-gfad0 From 399c985b62b35e7d81149ceef5d9a51fdeac35ed Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 11 Oct 2014 21:44:35 +0200 Subject: fixes recent regression --- lib/pure/concurrency/cpuinfo.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index bd10a416f..8d7f28f8e 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -26,13 +26,16 @@ when defined(openbsd) or defined(netbsd): {.emit:"#include ".} when defined(macosx) or defined(bsd): + # we HAVE to emit param.h before sysctl.h so we cannot use .header here + # either. The amount of archaic bullshit in Poonix based OSes is just insane. + {.emit:"#include ".} const CTL_HW = 6 HW_AVAILCPU = 25 HW_NCPU = 3 proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer, a: var csize, b: pointer, c: int): cint {. - importc: "sysctl", header: "".} + importc: "sysctl", nodecl.} proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. -- cgit 1.4.1-2-gfad0