Fix GNU Hurd interpreter path
[tinycc.git] / win32 / include / conio.h
blob6c1dc978c69bda6fac063d424f1734eaeca69e2c
1 /**
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.
5 */
6 #ifndef _INC_CONIO
7 #define _INC_CONIO
9 #include <_mingw.h>
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
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);
38 #endif
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
50 #ifndef WEOF
51 #define WEOF (wint_t)(0xFFFF)
52 #endif
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);
74 #endif
76 #ifndef NO_OLDNAMES
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);
92 #endif
94 /* I/O intrin functions. */
95 __CRT_INLINE unsigned char __inbyte(unsigned short Port)
97 unsigned char value;
98 __asm__ __volatile__ ("inb %w1,%b0"
99 : "=a" (value)
100 : "Nd" (Port));
101 return value;
103 __CRT_INLINE unsigned short __inword(unsigned short Port)
105 unsigned short value;
106 __asm__ __volatile__ ("inw %w1,%w0"
107 : "=a" (value)
108 : "Nd" (Port));
109 return value;
111 __CRT_INLINE unsigned long __indword(unsigned short Port)
113 unsigned long value;
114 __asm__ __volatile__ ("inl %w1,%0"
115 : "=a" (value)
116 : "Nd" (Port));
117 return value;
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__ (
140 "cld ; rep ; insb "
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__ (
148 "cld ; rep ; insw "
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__ (
156 "cld ; rep ; insl "
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__ (
165 "cld ; rep ; outsb "
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__ (
173 "cld ; rep ; outsw "
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__ (
181 "cld ; rep ; outsl "
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));
193 return value;
196 /* Register sizes are different between 32/64 bit mode. So we have to do this for _WIN64 and _WIN32
197 seperatly. */
199 #ifdef _WIN64
200 __CRT_INLINE void __writecr0(unsigned __int64 Data)
202 __asm__ __volatile__ (
203 "mov %[Data], %%cr0"
205 : [Data] "q" (Data)
206 : "memory");
209 __CRT_INLINE unsigned __int64 __readcr2(void)
211 unsigned __int64 value;
212 __asm__ __volatile__ (
213 "mov %%cr2, %[value]"
214 : [value] "=q" (value));
215 return value;
218 __CRT_INLINE void __writecr2(unsigned __int64 Data)
220 __asm__ __volatile__ (
221 "mov %[Data], %%cr2"
223 : [Data] "q" (Data)
224 : "memory");
227 __CRT_INLINE unsigned __int64 __readcr3(void)
229 unsigned __int64 value;
230 __asm__ __volatile__ (
231 "mov %%cr3, %[value]"
232 : [value] "=q" (value));
233 return value;
236 __CRT_INLINE void __writecr3(unsigned __int64 Data)
238 __asm__ __volatile__ (
239 "mov %[Data], %%cr3"
241 : [Data] "q" (Data)
242 : "memory");
245 __CRT_INLINE unsigned __int64 __readcr4(void)
247 unsigned __int64 value;
248 __asm__ __volatile__ (
249 "mov %%cr4, %[value]"
250 : [value] "=q" (value));
251 return value;
254 __CRT_INLINE void __writecr4(unsigned __int64 Data)
256 __asm__ __volatile__ (
257 "mov %[Data], %%cr4"
259 : [Data] "q" (Data)
260 : "memory");
263 __CRT_INLINE unsigned __int64 __readcr8(void)
265 unsigned __int64 value;
266 __asm__ __volatile__ (
267 "mov %%cr8, %[value]"
268 : [value] "=q" (value));
269 return value;
272 __CRT_INLINE void __writecr8(unsigned __int64 Data)
274 __asm__ __volatile__ (
275 "mov %[Data], %%cr8"
277 : [Data] "q" (Data)
278 : "memory");
281 #elif defined(_WIN32)
283 __CRT_INLINE void __writecr0(unsigned Data)
285 __asm__ __volatile__ (
286 "mov %[Data], %%cr0"
288 : [Data] "q" (Data)
289 : "memory");
292 __CRT_INLINE unsigned long __readcr2(void)
294 unsigned long value;
295 __asm__ __volatile__ (
296 "mov %%cr2, %[value]"
297 : [value] "=q" (value));
298 return value;
301 __CRT_INLINE void __writecr2(unsigned Data)
303 __asm__ __volatile__ (
304 "mov %[Data], %%cr2"
306 : [Data] "q" (Data)
307 : "memory");
310 __CRT_INLINE unsigned long __readcr3(void)
312 unsigned long value;
313 __asm__ __volatile__ (
314 "mov %%cr3, %[value]"
315 : [value] "=q" (value));
316 return value;
319 __CRT_INLINE void __writecr3(unsigned Data)
321 __asm__ __volatile__ (
322 "mov %[Data], %%cr3"
324 : [Data] "q" (Data)
325 : "memory");
328 __CRT_INLINE unsigned long __readcr4(void)
330 unsigned long value;
331 __asm__ __volatile__ (
332 "mov %%cr4, %[value]"
333 : [value] "=q" (value));
334 return value;
337 __CRT_INLINE void __writecr4(unsigned Data)
339 __asm__ __volatile__ (
340 "mov %[Data], %%cr4"
342 : [Data] "q" (Data)
343 : "memory");
346 __CRT_INLINE unsigned long __readcr8(void)
348 unsigned long value; __asm__ __volatile__ (
349 "mov %%cr8, %[value]"
350 : [value] "=q" (value));
351 return value;
354 __CRT_INLINE void __writecr8(unsigned Data)
356 __asm__ __volatile__ (
357 "mov %[Data], %%cr8"
359 : [Data] "q" (Data)
360 : "memory");
363 #endif
365 __CRT_INLINE unsigned __int64 __readmsr(unsigned long msr)
367 unsigned __int64 val1, val2;
368 __asm__ __volatile__(
369 "rdmsr"
370 : "=a" (val1), "=d" (val2)
371 : "c" (msr));
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__ (
379 "wrmsr"
381 : "c" (msr), "a" (val1), "d" (val2));
384 __CRT_INLINE unsigned __int64 __rdtsc(void)
386 unsigned __int64 val1, val2;
387 __asm__ __volatile__ (
388 "rdtsc"
389 : "=a" (val1), "=d" (val2));
390 return val1 | (val2 << 32);
393 __CRT_INLINE void __cpuid(int CPUInfo[4], int InfoType)
395 __asm__ __volatile__ (
396 "cpuid"
397 : "=a" (CPUInfo [0]), "=b" (CPUInfo [1]), "=c" (CPUInfo [2]), "=d" (CPUInfo [3])
398 : "a" (InfoType));
401 #endif
403 #ifdef __cplusplus
405 #endif
407 #include <sec_api/conio_s.h>
409 #endif