github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/asm.c (about)

     1  // The functions in this file were adapted from:
     2  // http://read.cs.ucla.edu/sqlite-anvil/trunk/sqlite-3.6.0/src/hwtime.h
     3  //
     4  // For more information see the original issue:
     5  // https://github.com/Konstantin8105/c4go/issues/228
     6  
     7  #include "tests.h"
     8  
     9  __inline__ unsigned long sqlite3Hwtime1(void)
    10  {
    11      unsigned int lo, hi;
    12      __asm__ __volatile__("rdtsc"
    13                           : "=a"(lo), "=d"(hi));
    14      return (unsigned long)hi << 32 | lo;
    15  }
    16  
    17  // This has been disabled because clang cannot understand the asm{} syntax.
    18  //__inline sqlite_uint64 __cdecl sqlite3Hwtime2(void){
    19  //    __asm {
    20  //        rdtsc
    21  //        ret       ; return value at EDX:EAX
    22  //    }
    23  //}
    24  
    25  __inline__ unsigned long sqlite3Hwtime3(void)
    26  {
    27      unsigned long val;
    28      __asm__ __volatile__("rdtsc"
    29                           : "=A"(val));
    30      return val;
    31  }
    32  
    33  int main()
    34  {
    35      // There are no actual tests in this file because Go does not support inline
    36      // assembly. We will have to revisit this in the future.
    37      plan(0);
    38  
    39      done_testing();
    40  }