File: asm.c

package info (click to toggle)
c2go 0.26.11-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,052 kB
  • sloc: ansic: 6,037; sh: 82; makefile: 5
file content (35 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// The functions in this file were adapted from:
// http://read.cs.ucla.edu/sqlite-anvil/trunk/sqlite-3.6.0/src/hwtime.h
//
// For more information see the original issue:
// https://github.com/elliotchance/c2go/issues/228

#include "tests.h"

__inline__ unsigned long sqlite3Hwtime1(void){
    unsigned int lo, hi;
    __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
    return (unsigned long)hi << 32 | lo;
}

// This has been disabled because clang cannot understand the asm{} syntax.
//__inline sqlite_uint64 __cdecl sqlite3Hwtime2(void){
//    __asm {
//        rdtsc
//        ret       ; return value at EDX:EAX
//    }
//}

__inline__ unsigned long sqlite3Hwtime3(void){
    unsigned long val;
    __asm__ __volatile__ ("rdtsc" : "=A" (val));
    return val;
}

int main() {
    // There are no actual tests in this file because Go does not support inline
    // assembly. We will have to revisit this in the future.
    plan(0);

    done_testing();
}