Bubble android client. Fork of https://git.zx2c4.com/wireguard-android/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

162 行
4.8 KiB

  1. From b19623e7673a4d6743745382d5d38751b64e011d Mon Sep 17 00:00:00 2001
  2. From: "Jason A. Donenfeld" <Jason@zx2c4.com>
  3. Date: Wed, 27 Feb 2019 05:05:44 +0100
  4. Subject: [PATCH] runtime: use CLOCK_BOOTTIME in nanotime on Linux
  5. This makes timers account for having expired while a computer was
  6. asleep, which is quite common on mobile devices. Note that BOOTTIME is
  7. identical to MONOTONIC, except that it takes into account time spent
  8. in suspend. In Linux 4.17, the kernel will actually make MONOTONIC act
  9. like BOOTTIME anyway, so this switch will additionally unify the
  10. timer behavior across kernels.
  11. BOOTTIME was introduced into Linux 2.6.39-rc1 with 70a08cca1227d in
  12. 2011.
  13. Fixes #24595
  14. Change-Id: I7b2a6ca0c5bc5fce57ec0eeafe7b68270b429321
  15. ---
  16. src/runtime/sys_linux_386.s | 4 ++--
  17. src/runtime/sys_linux_amd64.s | 2 +-
  18. src/runtime/sys_linux_arm.s | 4 ++--
  19. src/runtime/sys_linux_arm64.s | 4 ++--
  20. src/runtime/sys_linux_mips64x.s | 2 +-
  21. src/runtime/sys_linux_mipsx.s | 2 +-
  22. src/runtime/sys_linux_ppc64x.s | 2 +-
  23. src/runtime/sys_linux_s390x.s | 2 +-
  24. 8 files changed, 11 insertions(+), 11 deletions(-)
  25. diff --git a/src/runtime/sys_linux_386.s b/src/runtime/sys_linux_386.s
  26. index 72c43bd9da..daadfe32a9 100644
  27. --- a/src/runtime/sys_linux_386.s
  28. +++ b/src/runtime/sys_linux_386.s
  29. @@ -288,13 +288,13 @@ noswitch:
  30. LEAL 8(SP), BX // &ts (struct timespec)
  31. MOVL BX, 4(SP)
  32. - MOVL $1, 0(SP) // CLOCK_MONOTONIC
  33. + MOVL $7, 0(SP) // CLOCK_BOOTTIME
  34. CALL AX
  35. JMP finish
  36. fallback:
  37. MOVL $SYS_clock_gettime, AX
  38. - MOVL $1, BX // CLOCK_MONOTONIC
  39. + MOVL $7, BX // CLOCK_BOOTTIME
  40. LEAL 8(SP), CX
  41. INVOKE_SYSCALL
  42. diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s
  43. index 5c300f553d..e4a6f12ec6 100644
  44. --- a/src/runtime/sys_linux_amd64.s
  45. +++ b/src/runtime/sys_linux_amd64.s
  46. @@ -261,7 +261,7 @@ noswitch:
  47. MOVQ runtime·vdsoClockgettimeSym(SB), AX
  48. CMPQ AX, $0
  49. JEQ fallback
  50. - MOVL $1, DI // CLOCK_MONOTONIC
  51. + MOVL $7, DI // CLOCK_BOOTTIME
  52. LEAQ 0(SP), SI
  53. CALL AX
  54. MOVQ 0(SP), AX // sec
  55. diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s
  56. index 9c7398451c..61b6cd91f6 100644
  57. --- a/src/runtime/sys_linux_arm.s
  58. +++ b/src/runtime/sys_linux_arm.s
  59. @@ -11,7 +11,7 @@
  60. #include "textflag.h"
  61. #define CLOCK_REALTIME 0
  62. -#define CLOCK_MONOTONIC 1
  63. +#define CLOCK_BOOTTIME 7
  64. // for EABI, as we don't support OABI
  65. #define SYS_BASE 0x0
  66. @@ -291,7 +291,7 @@ noswitch:
  67. SUB $24, R13 // Space for results
  68. BIC $0x7, R13 // Align for C code
  69. - MOVW $CLOCK_MONOTONIC, R0
  70. + MOVW $CLOCK_BOOTTIME, R0
  71. MOVW $8(R13), R1 // timespec
  72. MOVW runtime·vdsoClockgettimeSym(SB), R11
  73. CMP $0, R11
  74. diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s
  75. index 2835b6ca1c..346ca9cfce 100644
  76. --- a/src/runtime/sys_linux_arm64.s
  77. +++ b/src/runtime/sys_linux_arm64.s
  78. @@ -13,7 +13,7 @@
  79. #define AT_FDCWD -100
  80. #define CLOCK_REALTIME 0
  81. -#define CLOCK_MONOTONIC 1
  82. +#define CLOCK_BOOTTIME 7
  83. #define SYS_exit 93
  84. #define SYS_read 63
  85. @@ -247,7 +247,7 @@ noswitch:
  86. BIC $15, R1
  87. MOVD R1, RSP
  88. - MOVW $CLOCK_MONOTONIC, R0
  89. + MOVW $CLOCK_BOOTTIME, R0
  90. MOVD runtime·vdsoClockgettimeSym(SB), R2
  91. CBZ R2, fallback
  92. BL (R2)
  93. diff --git a/src/runtime/sys_linux_mips64x.s b/src/runtime/sys_linux_mips64x.s
  94. index 33ed1050c2..59a5be179c 100644
  95. --- a/src/runtime/sys_linux_mips64x.s
  96. +++ b/src/runtime/sys_linux_mips64x.s
  97. @@ -189,7 +189,7 @@ TEXT runtime·walltime(SB),NOSPLIT,$16
  98. RET
  99. TEXT runtime·nanotime(SB),NOSPLIT,$16
  100. - MOVW $1, R4 // CLOCK_MONOTONIC
  101. + MOVW $7, R4 // CLOCK_BOOTTIME
  102. MOVV $0(R29), R5
  103. MOVV $SYS_clock_gettime, R2
  104. SYSCALL
  105. diff --git a/src/runtime/sys_linux_mipsx.s b/src/runtime/sys_linux_mipsx.s
  106. index 6e539fbc6f..55b2bf7156 100644
  107. --- a/src/runtime/sys_linux_mipsx.s
  108. +++ b/src/runtime/sys_linux_mipsx.s
  109. @@ -194,7 +194,7 @@ TEXT runtime·walltime(SB),NOSPLIT,$8-12
  110. RET
  111. TEXT runtime·nanotime(SB),NOSPLIT,$8-8
  112. - MOVW $1, R4 // CLOCK_MONOTONIC
  113. + MOVW $7, R4 // CLOCK_BOOTTIME
  114. MOVW $4(R29), R5
  115. MOVW $SYS_clock_gettime, R2
  116. SYSCALL
  117. diff --git a/src/runtime/sys_linux_ppc64x.s b/src/runtime/sys_linux_ppc64x.s
  118. index 13d23156bd..f67e5062aa 100644
  119. --- a/src/runtime/sys_linux_ppc64x.s
  120. +++ b/src/runtime/sys_linux_ppc64x.s
  121. @@ -204,7 +204,7 @@ fallback:
  122. JMP finish
  123. TEXT runtime·nanotime(SB),NOSPLIT,$16
  124. - MOVD $1, R3 // CLOCK_MONOTONIC
  125. + MOVD $7, R3 // CLOCK_BOOTTIME
  126. MOVD R1, R15 // R15 is unchanged by C code
  127. MOVD g_m(g), R21 // R21 = m
  128. diff --git a/src/runtime/sys_linux_s390x.s b/src/runtime/sys_linux_s390x.s
  129. index 58b36dff0a..cb92e9a402 100644
  130. --- a/src/runtime/sys_linux_s390x.s
  131. +++ b/src/runtime/sys_linux_s390x.s
  132. @@ -180,7 +180,7 @@ TEXT runtime·walltime(SB),NOSPLIT,$16
  133. RET
  134. TEXT runtime·nanotime(SB),NOSPLIT,$16
  135. - MOVW $1, R2 // CLOCK_MONOTONIC
  136. + MOVW $7, R2 // CLOCK_BOOTTIME
  137. MOVD $tp-16(SP), R3
  138. MOVW $SYS_clock_gettime, R1
  139. SYSCALL
  140. --
  141. 2.23.0