]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/rtclock_asm_native.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / i386 / rtclock_asm_native.h
index ab16668e3a8d8f71cfb814e310be2ae3bc4bad27..50919f1fd8819093f8a009651f9a5d9b79b0a802 100644 (file)
         jz        0b                   /* - wait if so */              ; \
        lfence                                                          ; \
        rdtsc                                                           ; \
-       lfence                                                          ; \
+       shlq    $32,%rdx                                                ; \
+       movl    RNT_SHIFT(%rdi),%ecx                                    ; \
+       orq     %rdx,%rax                       /* %rax := tsc */       ; \
+       subq    RNT_TSC_BASE(%rdi),%rax         /* tsc - tsc_base */    ; \
+       shlq    %cl,%rax                                                ; \
+       movl    RNT_SCALE(%rdi),%ecx                                    ; \
+       mulq    %rcx                            /* delta * scale */     ; \
+       shrdq   $32,%rdx,%rax                   /* %rdx:%rax >>= 32 */  ; \
+       addq    RNT_NS_BASE(%rdi),%rax          /* add ns_base */       ; \
+       cmpl    RNT_GENERATION(%rdi),%esi       /* repeat if changed */ ; \
+       jne     0b
+
+#define PAL_RTC_NANOTIME_READ_NOBARRIER()                                        \
+0:     movl    RNT_GENERATION(%rdi),%esi                               ; \
+       test        %esi,%esi           /* info updating? */            ; \
+        jz        0b                   /* - wait if so */              ; \
+       rdtsc                                                           ; \
        shlq    $32,%rdx                                                ; \
        movl    RNT_SHIFT(%rdi),%ecx                                    ; \
        orq     %rdx,%rax                       /* %rax := tsc */       ; \