|
36 | 36 | /* Define the default attributes for the functions in this file. */
|
37 | 37 | #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
|
38 | 38 |
|
| 39 | +#if __x86_64__ |
| 40 | +#define __LPTRINT_TYPE__ __int64 |
| 41 | +#else |
| 42 | +#define __LPTRINT_TYPE__ long |
| 43 | +#endif |
| 44 | + |
39 | 45 | #ifdef __cplusplus
|
40 | 46 | extern "C" {
|
41 | 47 | #endif
|
@@ -94,8 +100,7 @@ void __outword(unsigned short, unsigned short);
|
94 | 100 | void __outwordstring(unsigned short, unsigned short *, unsigned long);
|
95 | 101 | unsigned long __readcr0(void);
|
96 | 102 | unsigned long __readcr2(void);
|
97 |
| -static __inline__ |
98 |
| -unsigned long __readcr3(void); |
| 103 | +unsigned __LPTRINT_TYPE__ __readcr3(void); |
99 | 104 | unsigned long __readcr4(void);
|
100 | 105 | unsigned long __readcr8(void);
|
101 | 106 | unsigned int __readdr(unsigned int);
|
@@ -132,7 +137,7 @@ void __vmx_vmptrst(unsigned __int64 *);
|
132 | 137 | void __wbinvd(void);
|
133 | 138 | void __writecr0(unsigned int);
|
134 | 139 | static __inline__
|
135 |
| -void __writecr3(unsigned int); |
| 140 | +void __writecr3(unsigned __INTPTR_TYPE__); |
136 | 141 | void __writecr4(unsigned int);
|
137 | 142 | void __writecr8(unsigned int);
|
138 | 143 | void __writedr(unsigned int, unsigned int);
|
@@ -565,24 +570,26 @@ __readmsr(unsigned long __register) {
|
565 | 570 | __asm__ ("rdmsr" : "=d"(__edx), "=a"(__eax) : "c"(__register));
|
566 | 571 | return (((unsigned __int64)__edx) << 32) | (unsigned __int64)__eax;
|
567 | 572 | }
|
| 573 | +#endif |
568 | 574 |
|
569 |
| -static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 575 | +static __inline__ unsigned __LPTRINT_TYPE__ __DEFAULT_FN_ATTRS |
570 | 576 | __readcr3(void) {
|
571 |
| - unsigned long __cr3_val; |
572 |
| - __asm__ __volatile__ ("mov %%cr3, %0" : "=q"(__cr3_val) : : "memory"); |
| 577 | + unsigned __LPTRINT_TYPE__ __cr3_val; |
| 578 | + __asm__ __volatile__ ("mov %%cr3, %0" : "=r"(__cr3_val) : : "memory"); |
573 | 579 | return __cr3_val;
|
574 | 580 | }
|
575 | 581 |
|
576 | 582 | static __inline__ void __DEFAULT_FN_ATTRS
|
577 |
| -__writecr3(unsigned int __cr3_val) { |
578 |
| - __asm__ ("mov %0, %%cr3" : : "q"(__cr3_val) : "memory"); |
| 583 | +__writecr3(unsigned __INTPTR_TYPE__ __cr3_val) { |
| 584 | + __asm__ ("mov %0, %%cr3" : : "r"(__cr3_val) : "memory"); |
579 | 585 | }
|
580 |
| -#endif |
581 | 586 |
|
582 | 587 | #ifdef __cplusplus
|
583 | 588 | }
|
584 | 589 | #endif
|
585 | 590 |
|
| 591 | +#undef __LPTRINT_TYPE__ |
| 592 | + |
586 | 593 | #undef __DEFAULT_FN_ATTRS
|
587 | 594 |
|
588 | 595 | #endif /* __INTRIN_H */
|
|
0 commit comments