Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cpuid.h « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff353227ecc580667157d922e9711f9e35a985e6 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef CPUID_H
#define CPUID_H

extern inline void
cpuid (unsigned *a, unsigned *b, unsigned *c, unsigned *d, unsigned in)
{
  asm ("cpuid"
       : "=a" (*a),
	 "=b" (*b),
	 "=c" (*c),
	 "=d" (*d)
       : "a" (in));
}

#ifdef __x86_64__
extern inline bool
can_set_flag (register unsigned long flag)
{
  register unsigned long r1, r2;
  asm("pushfq\n"
      "popq %0\n"
      "movq %0, %1\n"
      "xorq %2, %0\n"
      "pushq %0\n"
      "popfq\n"
      "pushfq\n"
      "popq %0\n"
      "pushq %1\n"
      "popfq\n"
      : "=&r" (r1), "=&r" (r2)
      : "ir" (flag)
  );
  return ((r1 ^ r2) & flag) != 0;
}
#else
extern inline bool
can_set_flag (register unsigned flag)
{
  register unsigned r1, r2;
  asm("pushfl\n"
      "popl %0\n"
      "movl %0, %1\n"
      "xorl %2, %0\n"
      "pushl %0\n"
      "popfl\n"
      "pushfl\n"
      "popl %0\n"
      "pushl %1\n"
      "popfl\n"
      : "=&r" (r1), "=&r" (r2)
      : "ir" (flag)
  );
  return ((r1 ^ r2) & flag) != 0;
}
#endif

#endif // !CPUID_H