Minor docs/format changes (cpuinfo, volatile) (#16602)

This commit is contained in:
konsumlamm 2021-01-06 20:29:22 +01:00 • committed by GitHub
commit d34d023da1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -7,7 +7,11 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
## This module implements procs to determine the number of CPUs / cores. ## This module implements a proc to determine the number of CPUs / cores.
runnableExamples:
doAssert countProcessors() > 0
include "system/inclrtl" include "system/inclrtl"
@ -47,7 +51,7 @@ when defined(haiku):
header: "<OS.h>".} header: "<OS.h>".}
proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
## returns the number of the processors/cores the machine has. ## Returns the number of the processors/cores the machine has.
## Returns 0 if it cannot be detected. ## Returns 0 if it cannot be detected.
when defined(windows): when defined(windows):
type type
@ -95,8 +99,3 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
else: else:
result = sysconf(SC_NPROCESSORS_ONLN) result = sysconf(SC_NPROCESSORS_ONLN)
if result <= 0: result = 0 if result <= 0: result = 0
runnableExamples:
block:
doAssert countProcessors() > 0

View file

@ -12,7 +12,7 @@
template volatileLoad*[T](src: ptr T): T = template volatileLoad*[T](src: ptr T): T =
## Generates a volatile load of the value stored in the container `src`. ## Generates a volatile load of the value stored in the container `src`.
## Note that this only effects code generation on `C` like backends ## Note that this only effects code generation on `C` like backends.
when nimvm: when nimvm:
src[] src[]
else: else:
@ -26,7 +26,7 @@ template volatileLoad*[T](src: ptr T): T =
template volatileStore*[T](dest: ptr T, val: T) = template volatileStore*[T](dest: ptr T, val: T) =
## Generates a volatile store into the container `dest` of the value ## Generates a volatile store into the container `dest` of the value
## `val`. Note that this only effects code generation on `C` like ## `val`. Note that this only effects code generation on `C` like
## backends ## backends.
when nimvm: when nimvm:
dest[] = val dest[] = val
else: else: