summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorshirleyquirk <31934565+shirleyquirk@users.noreply.github.com>2020-10-15 11:54:01 +0100
committerGitHub <noreply@github.com>2020-10-15 12:54:01 +0200
commit4ef255b69d00d66e4554bad72fab1780578792f5 (patch)
tree6b6ed0ece7238e9e8bfe71fc9e619522fdbd7669
parentda4aa2e1fb8b0084fcf03b85edf4a5c1d0170856 (diff)
downloadNim-4ef255b69d00d66e4554bad72fab1780578792f5.tar.gz
fix rlock compilation failure (#15584)
* change SysLockType_Reentrant

fix edge case where using SysLockType_Reentrant doesn't trigger an #include pthread.h

* syslocktype_reentrant now a var
* remove nodecl to remove empty system_syslocks.c
* let is better than var.

in reality SysLockType = enum, maybe that would be a better fix
-rw-r--r--lib/core/rlocks.nim2
-rw-r--r--lib/system/syslocks.nim4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/core/rlocks.nim b/lib/core/rlocks.nim
index 34d7687f9..27a9c5e60 100644
--- a/lib/core/rlocks.nim
+++ b/lib/core/rlocks.nim
@@ -24,7 +24,7 @@ proc initRLock*(lock: var RLock) {.inline.} =
   when defined(posix):
     var a: SysLockAttr
     initSysLockAttr(a)
-    setSysLockType(a, SysLockType_Reentrant())
+    setSysLockType(a, SysLockType_Reentrant)
     initSysLock(lock, a.addr)
   else:
     initSysLock(lock)
diff --git a/lib/system/syslocks.nim b/lib/system/syslocks.nim
index b7f7aa6bf..07fb9cb8a 100644
--- a/lib/system/syslocks.nim
+++ b/lib/system/syslocks.nim
@@ -181,8 +181,8 @@ else:
       releaseSysAux(L)
 
   when insideRLocksModule:
-    proc SysLockType_Reentrant: SysLockType =
-      {.emit: "`result` = PTHREAD_MUTEX_RECURSIVE;".}
+    let SysLockType_Reentrant{.importc: "PTHREAD_MUTEX_RECURSIVE",
+      header: "<pthread.h>".}: SysLockType
     proc initSysLockAttr(a: var SysLockAttr) {.
       importc: "pthread_mutexattr_init", header: "<pthread.h>", noSideEffect.}
     proc setSysLockType(a: var SysLockAttr, t: SysLockType) {.
a> 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258