Fix `XDeclaredButNotUsed` warning when locks or rlocks module is used
This commit is contained in:
parent
d836028fe7
commit
ebc02f6dc0
4 changed files with 28 additions and 30 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
## This module contains Nim's support for reentrant locks.
|
## This module contains Nim's support for reentrant locks.
|
||||||
|
|
||||||
|
const insideRLocksModule = true
|
||||||
include "system/syslocks"
|
include "system/syslocks"
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -2561,6 +2561,16 @@ else:
|
||||||
if x < 0: -x else: x
|
if x < 0: -x else: x
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
|
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect, compileTime.} =
|
||||||
|
## Special compile-time procedure that checks whether `x` can be compiled
|
||||||
|
## without any semantic error.
|
||||||
|
## This can be used to check whether a type supports some operation:
|
||||||
|
##
|
||||||
|
## .. code-block:: Nim
|
||||||
|
## when not compiles(3 + 4):
|
||||||
|
## echo "'+' for integers is available"
|
||||||
|
discard
|
||||||
|
|
||||||
when not defined(JS): #and not defined(nimscript):
|
when not defined(JS): #and not defined(nimscript):
|
||||||
{.push stack_trace: off, profiler:off.}
|
{.push stack_trace: off, profiler:off.}
|
||||||
|
|
||||||
|
|
@ -3469,16 +3479,6 @@ when hasAlloc:
|
||||||
x[j+i] = item[j]
|
x[j+i] = item[j]
|
||||||
inc(j)
|
inc(j)
|
||||||
|
|
||||||
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect, compileTime.} =
|
|
||||||
## Special compile-time procedure that checks whether `x` can be compiled
|
|
||||||
## without any semantic error.
|
|
||||||
## This can be used to check whether a type supports some operation:
|
|
||||||
##
|
|
||||||
## .. code-block:: Nim
|
|
||||||
## when not compiles(3 + 4):
|
|
||||||
## echo "'+' for integers is available"
|
|
||||||
discard
|
|
||||||
|
|
||||||
when declared(initDebugger):
|
when declared(initDebugger):
|
||||||
initDebugger()
|
initDebugger()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,17 +88,16 @@ else:
|
||||||
#include <pthread.h>""".} = object
|
#include <pthread.h>""".} = object
|
||||||
SysLockType = distinct cint
|
SysLockType = distinct cint
|
||||||
|
|
||||||
proc SysLockType_Reentrant: SysLockType =
|
|
||||||
{.emit: "`result` = PTHREAD_MUTEX_RECURSIVE;".}
|
|
||||||
|
|
||||||
proc initSysLock(L: var SysLock, attr: ptr SysLockAttr = nil) {.
|
proc initSysLock(L: var SysLock, attr: ptr SysLockAttr = nil) {.
|
||||||
importc: "pthread_mutex_init", header: "<pthread.h>", noSideEffect.}
|
importc: "pthread_mutex_init", header: "<pthread.h>", noSideEffect.}
|
||||||
|
|
||||||
proc initSysLockAttr(a: var SysLockAttr) {.
|
when compiles(insideRLocksModule):
|
||||||
importc: "pthread_mutexattr_init", header: "<pthread.h>", noSideEffect.}
|
proc SysLockType_Reentrant: SysLockType =
|
||||||
|
{.emit: "`result` = PTHREAD_MUTEX_RECURSIVE;".}
|
||||||
proc setSysLockType(a: var SysLockAttr, t: SysLockType) {.
|
proc initSysLockAttr(a: var SysLockAttr) {.
|
||||||
importc: "pthread_mutexattr_settype", header: "<pthread.h>", noSideEffect.}
|
importc: "pthread_mutexattr_init", header: "<pthread.h>", noSideEffect.}
|
||||||
|
proc setSysLockType(a: var SysLockAttr, t: SysLockType) {.
|
||||||
|
importc: "pthread_mutexattr_settype", header: "<pthread.h>", noSideEffect.}
|
||||||
|
|
||||||
proc acquireSys(L: var SysLock) {.noSideEffect,
|
proc acquireSys(L: var SysLock) {.noSideEffect,
|
||||||
importc: "pthread_mutex_lock", header: "<pthread.h>".}
|
importc: "pthread_mutex_lock", header: "<pthread.h>".}
|
||||||
|
|
@ -113,14 +112,12 @@ else:
|
||||||
proc deinitSys(L: var SysLock) {.noSideEffect,
|
proc deinitSys(L: var SysLock) {.noSideEffect,
|
||||||
importc: "pthread_mutex_destroy", header: "<pthread.h>".}
|
importc: "pthread_mutex_destroy", header: "<pthread.h>".}
|
||||||
|
|
||||||
proc initSysCond(cond: var SysCond, cond_attr: pointer = nil) {.
|
when not compiles(insideRLocksModule):
|
||||||
importc: "pthread_cond_init", header: "<pthread.h>", noSideEffect.}
|
proc initSysCond(cond: var SysCond, cond_attr: pointer = nil) {.
|
||||||
proc waitSysCond(cond: var SysCond, lock: var SysLock) {.
|
importc: "pthread_cond_init", header: "<pthread.h>", noSideEffect.}
|
||||||
importc: "pthread_cond_wait", header: "<pthread.h>", noSideEffect.}
|
proc waitSysCond(cond: var SysCond, lock: var SysLock) {.
|
||||||
proc signalSysCond(cond: var SysCond) {.
|
importc: "pthread_cond_wait", header: "<pthread.h>", noSideEffect.}
|
||||||
importc: "pthread_cond_signal", header: "<pthread.h>", noSideEffect.}
|
proc signalSysCond(cond: var SysCond) {.
|
||||||
|
importc: "pthread_cond_signal", header: "<pthread.h>", noSideEffect.}
|
||||||
proc deinitSysCond(cond: var SysCond) {.noSideEffect,
|
proc deinitSysCond(cond: var SysCond) {.noSideEffect,
|
||||||
importc: "pthread_cond_destroy", header: "<pthread.h>".}
|
importc: "pthread_cond_destroy", header: "<pthread.h>".}
|
||||||
|
|
||||||
{.pop.}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue