File: TestInlineASM_gcc_x86.cpp

package info (click to toggle)
gromacs 2026.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 274,304 kB
  • sloc: xml: 3,831,921; cpp: 686,728; ansic: 75,300; python: 21,171; sh: 3,553; perl: 2,246; yacc: 644; fortran: 397; lisp: 265; makefile: 179; lex: 125; awk: 68; csh: 39
file content (28 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (7)
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
int
main()
{
  unsigned int _eax,_ebx,_ecx,_edx;
  unsigned int level = 0;

  /* Test gcc inline asm for x86. Note that we CANNOT plainly use __x86_64__
   * to correspond to a 64-bit environment without also checking that __ILP32__
   * is NOT set, since x32 uses __x86_64__.
   */
#if (defined(__x86_64__) && !defined(__ILP32__))
    __asm__("push %%rbx       \n\t"
            "cpuid            \n\t"
            "movl %%ebx, %1   \n\t"
            "pop %%rbx        \n\t"
            : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
#elif (defined(__x86_64__) && defined(__ILP32__)) || defined(__i386__)
    __asm__("push %%ebx       \n\t"
            "cpuid            \n\t"
            "movl %%ebx, %1   \n\t"
            "pop %%ebx        \n\t"
            : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
#else
#    error Cannot detect whether this is a 32-bit or 64-bit x86 build.
#endif

  return 0;
}