Merge pull request #2343 from philip-wernersbach/fix-pthreads-under-cpp
Fix issues with pthread_create when compiling under C++ mode.
This commit is contained in:
commit
327b56d5e1
2 changed files with 16 additions and 2 deletions
|
|
@ -127,7 +127,7 @@ else:
|
||||||
importc, header: "<pthread.h>".}
|
importc, header: "<pthread.h>".}
|
||||||
|
|
||||||
proc pthread_create(a1: var TSysThread, a2: var TPthread_attr,
|
proc pthread_create(a1: var TSysThread, a2: var TPthread_attr,
|
||||||
a3: proc (x: pointer) {.noconv.},
|
a3: proc (x: pointer): pointer {.noconv.},
|
||||||
a4: pointer): cint {.importc: "pthread_create",
|
a4: pointer): cint {.importc: "pthread_create",
|
||||||
header: "<pthread.h>".}
|
header: "<pthread.h>".}
|
||||||
proc pthread_join(a1: TSysThread, a2: ptr pointer): cint {.
|
proc pthread_join(a1: TSysThread, a2: ptr pointer): cint {.
|
||||||
|
|
@ -315,7 +315,7 @@ when defined(windows):
|
||||||
threadProcWrapperBody(closure)
|
threadProcWrapperBody(closure)
|
||||||
# implicitly return 0
|
# implicitly return 0
|
||||||
else:
|
else:
|
||||||
proc threadProcWrapper[TArg](closure: pointer) {.noconv.} =
|
proc threadProcWrapper[TArg](closure: pointer): pointer {.noconv.} =
|
||||||
threadProcWrapperBody(closure)
|
threadProcWrapperBody(closure)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
|
|
|
||||||
14
tests/cpp/tthread_createthread.nim
Normal file
14
tests/cpp/tthread_createthread.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nim cpp --hints:on --threads:on $options $file"
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc threadMain(a: int) {.thread.} =
|
||||||
|
discard
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
var thread: TThread[int]
|
||||||
|
|
||||||
|
thread.createThread(threadMain, 0)
|
||||||
|
thread.joinThreads()
|
||||||
|
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue