status-im / nim-stew

stew is collection of utilities, std library extensions and budding libraries that are frequently used at Status, but are too small to deserve their own git repository.
139 stars 18 forks source link

unconditionally pass through std/os and deprecate shim/os #199

Closed tersec closed 1 year ago

tersec commented 1 year ago

Nim 1.2 and newer unconditionally define and document getCurrentProcessId:

proc getCurrentProcessId*(): int {.noWeirdTarget.} =
  ## Return current process ID.
  ##
  ## See also:
  ## * `osproc.processID(p: Process) <osproc.html#processID,Process>`_
  when defined(windows):
    proc GetCurrentProcessId(): DWORD {.stdcall, dynlib: "kernel32",
                                        importc: "GetCurrentProcessId".}
    result = GetCurrentProcessId().int
  else:
    result = getpid()

which adds some comments, uses result = foo, and explicitly checks via .noWeirdTarget. for some cases in which the nim-stew shim won't work either, but is otherwise functionally equivalent.