diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-05-07 10:36:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 19:36:41 +0200 |
commit | 98c29c01eb91a0c6ce7da09380a272eebe6bca6f (patch) | |
tree | c7b9da12072df412fb52dffc3ac9f4c7c9b73be5 | |
parent | 51f3ef6cb8ac9fbbc9533c1de2af219dc4ecabe7 (diff) | |
download | Nim-98c29c01eb91a0c6ce7da09380a272eebe6bca6f.tar.gz |
fix #14873 properly by skipping `abi` field in importc type (#17944)
* fix #14873 properly by skipping `abi` field in importc type * add test * fix test for windows
-rw-r--r-- | lib/core/locks.nim | 5 | ||||
-rw-r--r-- | lib/system/syslocks.nim | 8 | ||||
-rw-r--r-- | tests/stdlib/uselocks.nim | 18 |
3 files changed, 17 insertions, 14 deletions
diff --git a/lib/core/locks.nim b/lib/core/locks.nim index 92967b9db..baec45829 100644 --- a/lib/core/locks.nim +++ b/lib/core/locks.nim @@ -28,11 +28,6 @@ type {.push stackTrace: off.} - -proc `$`*(lock: Lock): string = - # workaround bug #14873 - result = "()" - proc initLock*(lock: var Lock) {.inline.} = ## Initializes the given lock. when not defined(js): diff --git a/lib/system/syslocks.nim b/lib/system/syslocks.nim index 2f0c8b0ba..9e8da610d 100644 --- a/lib/system/syslocks.nim +++ b/lib/system/syslocks.nim @@ -102,26 +102,18 @@ else: SysLockObj {.importc: "pthread_mutex_t", pure, final, header: """#include <sys/types.h> #include <pthread.h>""".} = object - when defined(linux) and defined(amd64): - abi: array[40 div sizeof(clong), clong] SysLockAttr {.importc: "pthread_mutexattr_t", pure, final header: """#include <sys/types.h> #include <pthread.h>""".} = object - when defined(linux) and defined(amd64): - abi: array[4 div sizeof(cint), cint] # actually a cint SysCondObj {.importc: "pthread_cond_t", pure, final, header: """#include <sys/types.h> #include <pthread.h>""".} = object - when defined(linux) and defined(amd64): - abi: array[48 div sizeof(clonglong), clonglong] SysCondAttr {.importc: "pthread_condattr_t", pure, final header: """#include <sys/types.h> #include <pthread.h>""".} = object - when defined(linux) and defined(amd64): - abi: array[4 div sizeof(cint), cint] # actually a cint SysLockType = distinct cint diff --git a/tests/stdlib/uselocks.nim b/tests/stdlib/uselocks.nim index e9d23f9d9..e82de8adf 100644 --- a/tests/stdlib/uselocks.nim +++ b/tests/stdlib/uselocks.nim @@ -11,5 +11,21 @@ proc use* (m: var MyType): int = result = 3 block: + # bug #14873 var l: Lock - doAssert $l == "()" + doAssert ($l).len > 0 + # on posix, "()", on windows, something else, but that shouldn't be part of the spec + # what matters is that `$` doesn't cause the codegen bug mentioned + +when true: # intentional + # bug https://github.com/nim-lang/Nim/issues/14873#issuecomment-784241605 + type + Test = object + path: string # Removing this makes both cases work. + lock: Lock + # A: This is not fine. + var a = Test() + proc main(): void = + # B: This is fine. + var b = Test() + main() |