1
0

Misc.swift 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Misc.swift
  3. // Swifter
  4. //
  5. // Copyright © 2017 Damian Kołakowski. All rights reserved.
  6. //
  7. import Foundation
  8. public extension UInt8 {
  9. public static var
  10. lf: UInt8 = 10,
  11. cr: UInt8 = 13,
  12. space: UInt8 = 32,
  13. colon: UInt8 = 58,
  14. ampersand: UInt8 = 38,
  15. lessThan: UInt8 = 60,
  16. greaterThan: UInt8 = 62,
  17. slash: UInt8 = 47,
  18. equal: UInt8 = 61,
  19. doubleQuotes: UInt8 = 34,
  20. openingParenthesis: UInt8 = 40,
  21. closingParenthesis: UInt8 = 41,
  22. comma: UInt8 = 44
  23. }
  24. public struct Process {
  25. public static var pid: Int {
  26. return Int(getpid())
  27. }
  28. public static var tid: UInt64 {
  29. #if os(Linux)
  30. return UInt64(pthread_self())
  31. #else
  32. var tid: __uint64_t = 0
  33. pthread_threadid_np(nil, &tid);
  34. return UInt64(tid)
  35. #endif
  36. }
  37. public static var error: String {
  38. return String(cString: UnsafePointer(strerror(errno)))
  39. }
  40. }