inclrtl.nim 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2015 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. # Pragmas for RTL generation. Has to be an include, because user-defined
  10. # pragmas cannot be exported.
  11. # There are 3 different usages:
  12. # 1) Ordinary imported code.
  13. # 2) Imported from nimrtl.
  14. # -> defined(useNimRtl) or appType == "lib" and not defined(createNimRtl)
  15. # 3) Exported into nimrtl.
  16. # -> appType == "lib" and defined(createNimRtl)
  17. when not defined(nimNewShared):
  18. {.pragma: gcsafe.}
  19. when defined(createNimRtl):
  20. when defined(useNimRtl):
  21. {.error: "Cannot create and use nimrtl at the same time!".}
  22. elif appType != "lib":
  23. {.error: "nimrtl must be built as a library!".}
  24. when defined(createNimRtl):
  25. {.pragma: rtl, exportc: "nimrtl_$1", dynlib, gcsafe.}
  26. {.pragma: inl.}
  27. {.pragma: compilerRtl, compilerproc, exportc: "nimrtl_$1", dynlib.}
  28. elif defined(useNimRtl):
  29. #[
  30. `{.rtl.}` should only be used for non-generic procs.
  31. ]#
  32. const nimrtl* =
  33. when defined(windows): "nimrtl.dll"
  34. elif defined(macosx): "libnimrtl.dylib"
  35. else: "libnimrtl.so"
  36. {.pragma: rtl, importc: "nimrtl_$1", dynlib: nimrtl, gcsafe.}
  37. {.pragma: inl.}
  38. {.pragma: compilerRtl, compilerproc, importc: "nimrtl_$1", dynlib: nimrtl.}
  39. else:
  40. {.pragma: rtl, gcsafe.}
  41. {.pragma: inl, inline.}
  42. {.pragma: compilerRtl, compilerproc.}
  43. {.pragma: benign, gcsafe.}
  44. {.push sinkInference: on.}