File: issue149.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (46 lines) | stat: -rwxr-xr-x 832 bytes parent folder | download
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

#include "test.h"
#ifdef _WIN32
#include <limits.h>
#include <intrin.h>
typedef unsigned __int32 uint32_t;
#else
#include <stdint.h>
#endif

int
main (void)
{

	uint32_t r[4];
	uint32_t eax_in = 0x80000008U;
	// uint32_t eax_out = r[0];
	// uint32_t vaddr = ((eax_out & 0x0000ff00U) >> 8);
	// FILE *f = fopen("./conftest.out", "w");
	// if (f == NULL) {
	// 	printf("f is null\n");
	// 	return 1;
	// }

#ifdef _WIN32
	__cpuid((int *)r, (int)eax_in);
#else
	asm volatile ("cpuid"
	    : "=a" (r[3]), "=b" (r[1]), "=c" (r[2]), "=d" (r[0])
	    : "a" (eax_in), "c" (0)
	);
#endif


	// if (vaddr > (sizeof(void *) << 3)) {
	// 	vaddr = sizeof(void *) << 3;
	// }
	//fprintf(f, "%u", vaddr);
	printf("%d, %d, %d, %d\n", r[0], r[1], r[2], r[3]);
	//fclose(f);
	ASSERT(1, r[3] == 12334 || r[3] == 12336);
	return 0;

  ;
  return 0;
}