2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
15 _CRTIMP
char *_cgets(char *_Buffer
);
16 _CRTIMP
int __cdecl
_cprintf(const char *_Format
,...);
17 _CRTIMP
int __cdecl
_cputs(const char *_Str
);
18 _CRTIMP
int __cdecl
_cscanf(const char *_Format
,...);
19 _CRTIMP
int __cdecl
_cscanf_l(const char *_Format
,_locale_t _Locale
,...);
20 _CRTIMP
int __cdecl
_getch(void);
21 _CRTIMP
int __cdecl
_getche(void);
22 _CRTIMP
int __cdecl
_vcprintf(const char *_Format
,va_list _ArgList
);
23 _CRTIMP
int __cdecl
_cprintf_p(const char *_Format
,...);
24 _CRTIMP
int __cdecl
_vcprintf_p(const char *_Format
,va_list _ArgList
);
25 _CRTIMP
int __cdecl
_cprintf_l(const char *_Format
,_locale_t _Locale
,...);
26 _CRTIMP
int __cdecl
_vcprintf_l(const char *_Format
,_locale_t _Locale
,va_list _ArgList
);
27 _CRTIMP
int __cdecl
_cprintf_p_l(const char *_Format
,_locale_t _Locale
,...);
28 _CRTIMP
int __cdecl
_vcprintf_p_l(const char *_Format
,_locale_t _Locale
,va_list _ArgList
);
29 _CRTIMP
int __cdecl
_kbhit(void);
31 #if defined(_X86_) && !defined(__x86_64)
32 int __cdecl
_inp(unsigned short);
33 unsigned short __cdecl
_inpw(unsigned short);
34 unsigned long __cdecl
_inpd(unsigned short);
35 int __cdecl
_outp(unsigned short,int);
36 unsigned short __cdecl
_outpw(unsigned short,unsigned short);
37 unsigned long __cdecl
_outpd(unsigned short,unsigned long);
40 _CRTIMP
int __cdecl
_putch(int _Ch
);
41 _CRTIMP
int __cdecl
_ungetch(int _Ch
);
42 _CRTIMP
int __cdecl
_getch_nolock(void);
43 _CRTIMP
int __cdecl
_getche_nolock(void);
44 _CRTIMP
int __cdecl
_putch_nolock(int _Ch
);
45 _CRTIMP
int __cdecl
_ungetch_nolock(int _Ch
);
47 #ifndef _WCONIO_DEFINED
48 #define _WCONIO_DEFINED
51 #define WEOF (wint_t)(0xFFFF)
54 _CRTIMP
wchar_t *_cgetws(wchar_t *_Buffer
);
55 _CRTIMP
wint_t __cdecl
_getwch(void);
56 _CRTIMP
wint_t __cdecl
_getwche(void);
57 _CRTIMP
wint_t __cdecl
_putwch(wchar_t _WCh
);
58 _CRTIMP
wint_t __cdecl
_ungetwch(wint_t _WCh
);
59 _CRTIMP
int __cdecl
_cputws(const wchar_t *_String
);
60 _CRTIMP
int __cdecl
_cwprintf(const wchar_t *_Format
,...);
61 _CRTIMP
int __cdecl
_cwscanf(const wchar_t *_Format
,...);
62 _CRTIMP
int __cdecl
_cwscanf_l(const wchar_t *_Format
,_locale_t _Locale
,...);
63 _CRTIMP
int __cdecl
_vcwprintf(const wchar_t *_Format
,va_list _ArgList
);
64 _CRTIMP
int __cdecl
_cwprintf_p(const wchar_t *_Format
,...);
65 _CRTIMP
int __cdecl
_vcwprintf_p(const wchar_t *_Format
,va_list _ArgList
);
66 _CRTIMP
int __cdecl
_cwprintf_l(const wchar_t *_Format
,_locale_t _Locale
,...);
67 _CRTIMP
int __cdecl
_vcwprintf_l(const wchar_t *_Format
,_locale_t _Locale
,va_list _ArgList
);
68 _CRTIMP
int __cdecl
_cwprintf_p_l(const wchar_t *_Format
,_locale_t _Locale
,...);
69 _CRTIMP
int __cdecl
_vcwprintf_p_l(const wchar_t *_Format
,_locale_t _Locale
,va_list _ArgList
);
70 _CRTIMP
wint_t __cdecl
_putwch_nolock(wchar_t _WCh
);
71 _CRTIMP
wint_t __cdecl
_getwch_nolock(void);
72 _CRTIMP
wint_t __cdecl
_getwche_nolock(void);
73 _CRTIMP
wint_t __cdecl
_ungetwch_nolock(wint_t _WCh
);
77 char *__cdecl
cgets(char *_Buffer
);
78 int __cdecl
cprintf(const char *_Format
,...);
79 int __cdecl
cputs(const char *_Str
);
80 int __cdecl
cscanf(const char *_Format
,...);
81 int __cdecl
getch(void);
82 int __cdecl
getche(void);
83 int __cdecl
kbhit(void);
84 int __cdecl
putch(int _Ch
);
85 int __cdecl
ungetch(int _Ch
);
87 #if (defined(_X86_) && !defined(__x86_64))
88 int __cdecl
inp(unsigned short);
89 unsigned short __cdecl
inpw(unsigned short);
90 int __cdecl
outp(unsigned short,int);
91 unsigned short __cdecl
outpw(unsigned short,unsigned short);
94 /* I/O intrin functions. */
95 __CRT_INLINE
unsigned char __inbyte(unsigned short Port
)
98 __asm__
__volatile__ ("inb %w1,%b0"
103 __CRT_INLINE
unsigned short __inword(unsigned short Port
)
105 unsigned short value
;
106 __asm__
__volatile__ ("inw %w1,%w0"
111 __CRT_INLINE
unsigned long __indword(unsigned short Port
)
114 __asm__
__volatile__ ("inl %w1,%0"
119 __CRT_INLINE
void __outbyte(unsigned short Port
,unsigned char Data
)
121 __asm__
__volatile__ ("outb %b0,%w1"
123 : "a" (Data
), "Nd" (Port
));
125 __CRT_INLINE
void __outword(unsigned short Port
,unsigned short Data
)
127 __asm__
__volatile__ ("outw %w0,%w1"
129 : "a" (Data
), "Nd" (Port
));
131 __CRT_INLINE
void __outdword(unsigned short Port
,unsigned long Data
)
133 __asm__
__volatile__ ("outl %0,%w1"
135 : "a" (Data
), "Nd" (Port
));
137 __CRT_INLINE
void __inbytestring(unsigned short Port
,unsigned char *Buffer
,unsigned long Count
)
139 __asm__
__volatile__ (
141 : "=D" (Buffer
), "=c" (Count
)
142 : "d"(Port
), "0"(Buffer
), "1" (Count
)
145 __CRT_INLINE
void __inwordstring(unsigned short Port
,unsigned short *Buffer
,unsigned long Count
)
147 __asm__
__volatile__ (
149 : "=D" (Buffer
), "=c" (Count
)
150 : "d"(Port
), "0"(Buffer
), "1" (Count
)
153 __CRT_INLINE
void __indwordstring(unsigned short Port
,unsigned long *Buffer
,unsigned long Count
)
155 __asm__
__volatile__ (
157 : "=D" (Buffer
), "=c" (Count
)
158 : "d"(Port
), "0"(Buffer
), "1" (Count
)
162 __CRT_INLINE
void __outbytestring(unsigned short Port
,unsigned char *Buffer
,unsigned long Count
)
164 __asm__
__volatile__ (
166 : "=S" (Buffer
), "=c" (Count
)
167 : "d"(Port
), "0"(Buffer
), "1" (Count
)
170 __CRT_INLINE
void __outwordstring(unsigned short Port
,unsigned short *Buffer
,unsigned long Count
)
172 __asm__
__volatile__ (
174 : "=S" (Buffer
), "=c" (Count
)
175 : "d"(Port
), "0"(Buffer
), "1" (Count
)
178 __CRT_INLINE
void __outdwordstring(unsigned short Port
,unsigned long *Buffer
,unsigned long Count
)
180 __asm__
__volatile__ (
182 : "=S" (Buffer
), "=c" (Count
)
183 : "d"(Port
), "0"(Buffer
), "1" (Count
)
187 __CRT_INLINE
unsigned __int64
__readcr0(void)
189 unsigned __int64 value
;
190 __asm__
__volatile__ (
191 "mov %%cr0, %[value]"
192 : [value
] "=q" (value
));
196 /* Register sizes are different between 32/64 bit mode. So we have to do this for _WIN64 and _WIN32
200 __CRT_INLINE
void __writecr0(unsigned __int64 Data
)
202 __asm__
__volatile__ (
209 __CRT_INLINE
unsigned __int64
__readcr2(void)
211 unsigned __int64 value
;
212 __asm__
__volatile__ (
213 "mov %%cr2, %[value]"
214 : [value
] "=q" (value
));
218 __CRT_INLINE
void __writecr2(unsigned __int64 Data
)
220 __asm__
__volatile__ (
227 __CRT_INLINE
unsigned __int64
__readcr3(void)
229 unsigned __int64 value
;
230 __asm__
__volatile__ (
231 "mov %%cr3, %[value]"
232 : [value
] "=q" (value
));
236 __CRT_INLINE
void __writecr3(unsigned __int64 Data
)
238 __asm__
__volatile__ (
245 __CRT_INLINE
unsigned __int64
__readcr4(void)
247 unsigned __int64 value
;
248 __asm__
__volatile__ (
249 "mov %%cr4, %[value]"
250 : [value
] "=q" (value
));
254 __CRT_INLINE
void __writecr4(unsigned __int64 Data
)
256 __asm__
__volatile__ (
263 __CRT_INLINE
unsigned __int64
__readcr8(void)
265 unsigned __int64 value
;
266 __asm__
__volatile__ (
267 "mov %%cr8, %[value]"
268 : [value
] "=q" (value
));
272 __CRT_INLINE
void __writecr8(unsigned __int64 Data
)
274 __asm__
__volatile__ (
281 #elif defined(_WIN32)
283 __CRT_INLINE
void __writecr0(unsigned Data
)
285 __asm__
__volatile__ (
292 __CRT_INLINE
unsigned long __readcr2(void)
295 __asm__
__volatile__ (
296 "mov %%cr2, %[value]"
297 : [value
] "=q" (value
));
301 __CRT_INLINE
void __writecr2(unsigned Data
)
303 __asm__
__volatile__ (
310 __CRT_INLINE
unsigned long __readcr3(void)
313 __asm__
__volatile__ (
314 "mov %%cr3, %[value]"
315 : [value
] "=q" (value
));
319 __CRT_INLINE
void __writecr3(unsigned Data
)
321 __asm__
__volatile__ (
328 __CRT_INLINE
unsigned long __readcr4(void)
331 __asm__
__volatile__ (
332 "mov %%cr4, %[value]"
333 : [value
] "=q" (value
));
337 __CRT_INLINE
void __writecr4(unsigned Data
)
339 __asm__
__volatile__ (
346 __CRT_INLINE
unsigned long __readcr8(void)
348 unsigned long value
; __asm__
__volatile__ (
349 "mov %%cr8, %[value]"
350 : [value
] "=q" (value
));
354 __CRT_INLINE
void __writecr8(unsigned Data
)
356 __asm__
__volatile__ (
365 __CRT_INLINE
unsigned __int64
__readmsr(unsigned long msr
)
367 unsigned __int64 val1
, val2
;
368 __asm__
__volatile__(
370 : "=a" (val1
), "=d" (val2
)
372 return val1
| (val2
<< 32);
375 __CRT_INLINE
void __writemsr (unsigned long msr
, unsigned __int64 Value
)
377 unsigned long val1
= Value
, val2
= Value
>> 32;
378 __asm__
__volatile__ (
381 : "c" (msr
), "a" (val1
), "d" (val2
));
384 __CRT_INLINE
unsigned __int64
__rdtsc(void)
386 unsigned __int64 val1
, val2
;
387 __asm__
__volatile__ (
389 : "=a" (val1
), "=d" (val2
));
390 return val1
| (val2
<< 32);
393 __CRT_INLINE
void __cpuid(int CPUInfo
[4], int InfoType
)
395 __asm__
__volatile__ (
397 : "=a" (CPUInfo
[0]), "=b" (CPUInfo
[1]), "=c" (CPUInfo
[2]), "=d" (CPUInfo
[3])
407 #include <sec_api/conio_s.h>