aboutsummaryrefslogtreecommitdiff
path: root/win32/include/conio.h
diff options
context:
space:
mode:
authorgrischka <grischka>2009-07-18 22:06:37 +0200
committergrischka <grischka>2009-07-18 22:06:37 +0200
commitdc251a7d8d8bb4fb57773790152bfe85236f5f12 (patch)
treee8dcec8579afbe341a4af7560f0a7e559238f503 /win32/include/conio.h
parent06aed3d171839454648cebd0c58eaf4667e4979a (diff)
downloadtinycc-dc251a7d8d8bb4fb57773790152bfe85236f5f12.tar.gz
tinycc-dc251a7d8d8bb4fb57773790152bfe85236f5f12.tar.bz2
win64: use new headers from mingw
Diffstat (limited to 'win32/include/conio.h')
-rw-r--r--win32/include/conio.h498
1 files changed, 374 insertions, 124 deletions
diff --git a/win32/include/conio.h b/win32/include/conio.h
index c1f4151..6c1dc97 100644
--- a/win32/include/conio.h
+++ b/win32/include/conio.h
@@ -1,159 +1,409 @@
-/* A conio implementation for Mingw/Dev-C++.
- *
- * Written by:
- * Hongli Lai <hongli@telekabel.nl>
- * tkorrovi <tkorrovi@altavista.net> on 2002/02/26.
- * Andrew Westcott <ajwestco@users.sourceforge.net>
- *
- * Offered for use in the public domain without any warranty.
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
*/
+#ifndef _INC_CONIO
+#define _INC_CONIO
-#ifndef _CONIO_H_
-#define _CONIO_H_
-
-
-#include <stdio.h>
+#include <_mingw.h>
#ifdef __cplusplus
extern "C" {
#endif
-#define BLINK 0
-
-typedef enum
-{
- BLACK,
- BLUE,
- GREEN,
- CYAN,
- RED,
- MAGENTA,
- BROWN,
- LIGHTGRAY,
- DARKGRAY,
- LIGHTBLUE,
- LIGHTGREEN,
- LIGHTCYAN,
- LIGHTRED,
- LIGHTMAGENTA,
- YELLOW,
- WHITE
-} COLORS;
-
+ _CRTIMP char *_cgets(char *_Buffer);
+ _CRTIMP int __cdecl _cprintf(const char *_Format,...);
+ _CRTIMP int __cdecl _cputs(const char *_Str);
+ _CRTIMP int __cdecl _cscanf(const char *_Format,...);
+ _CRTIMP int __cdecl _cscanf_l(const char *_Format,_locale_t _Locale,...);
+ _CRTIMP int __cdecl _getch(void);
+ _CRTIMP int __cdecl _getche(void);
+ _CRTIMP int __cdecl _vcprintf(const char *_Format,va_list _ArgList);
+ _CRTIMP int __cdecl _cprintf_p(const char *_Format,...);
+ _CRTIMP int __cdecl _vcprintf_p(const char *_Format,va_list _ArgList);
+ _CRTIMP int __cdecl _cprintf_l(const char *_Format,_locale_t _Locale,...);
+ _CRTIMP int __cdecl _vcprintf_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
+ _CRTIMP int __cdecl _cprintf_p_l(const char *_Format,_locale_t _Locale,...);
+ _CRTIMP int __cdecl _vcprintf_p_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
+ _CRTIMP int __cdecl _kbhit(void);
-#define cgets _cgets
-#define cprintf _cprintf
-#define cputs _cputs
-#define cscanf _cscanf
-#define ScreenClear clrscr
-
-/* blinkvideo */
-
-void clreol (void);
-void clrscr (void);
+#if defined(_X86_) && !defined(__x86_64)
+ int __cdecl _inp(unsigned short);
+ unsigned short __cdecl _inpw(unsigned short);
+ unsigned long __cdecl _inpd(unsigned short);
+ int __cdecl _outp(unsigned short,int);
+ unsigned short __cdecl _outpw(unsigned short,unsigned short);
+ unsigned long __cdecl _outpd(unsigned short,unsigned long);
+#endif
-int _conio_gettext (int left, int top, int right, int bottom,
- char *str);
-/* _conio_kbhit */
+ _CRTIMP int __cdecl _putch(int _Ch);
+ _CRTIMP int __cdecl _ungetch(int _Ch);
+ _CRTIMP int __cdecl _getch_nolock(void);
+ _CRTIMP int __cdecl _getche_nolock(void);
+ _CRTIMP int __cdecl _putch_nolock(int _Ch);
+ _CRTIMP int __cdecl _ungetch_nolock(int _Ch);
-void delline (void);
+#ifndef _WCONIO_DEFINED
+#define _WCONIO_DEFINED
-/* gettextinfo */
-void gotoxy(int x, int y);
-/*
-highvideo
-insline
-intensevideo
-lowvideo
-movetext
-normvideo
-*/
+#ifndef WEOF
+#define WEOF (wint_t)(0xFFFF)
+#endif
-void puttext (int left, int top, int right, int bottom, char *str);
+ _CRTIMP wchar_t *_cgetws(wchar_t *_Buffer);
+ _CRTIMP wint_t __cdecl _getwch(void);
+ _CRTIMP wint_t __cdecl _getwche(void);
+ _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
+ _CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
+ _CRTIMP int __cdecl _cputws(const wchar_t *_String);
+ _CRTIMP int __cdecl _cwprintf(const wchar_t *_Format,...);
+ _CRTIMP int __cdecl _cwscanf(const wchar_t *_Format,...);
+ _CRTIMP int __cdecl _cwscanf_l(const wchar_t *_Format,_locale_t _Locale,...);
+ _CRTIMP int __cdecl _vcwprintf(const wchar_t *_Format,va_list _ArgList);
+ _CRTIMP int __cdecl _cwprintf_p(const wchar_t *_Format,...);
+ _CRTIMP int __cdecl _vcwprintf_p(const wchar_t *_Format,va_list _ArgList);
+ _CRTIMP int __cdecl _cwprintf_l(const wchar_t *_Format,_locale_t _Locale,...);
+ _CRTIMP int __cdecl _vcwprintf_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
+ _CRTIMP int __cdecl _cwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,...);
+ _CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
+ _CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
+ _CRTIMP wint_t __cdecl _getwch_nolock(void);
+ _CRTIMP wint_t __cdecl _getwche_nolock(void);
+ _CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
+#endif
-// Screen Variables
+#ifndef NO_OLDNAMES
+ char *__cdecl cgets(char *_Buffer);
+ int __cdecl cprintf(const char *_Format,...);
+ int __cdecl cputs(const char *_Str);
+ int __cdecl cscanf(const char *_Format,...);
+ int __cdecl getch(void);
+ int __cdecl getche(void);
+ int __cdecl kbhit(void);
+ int __cdecl putch(int _Ch);
+ int __cdecl ungetch(int _Ch);
-/* ScreenCols
-ScreenGetChar
-ScreenGetCursor
-ScreenMode
-ScreenPutChar
-ScreenPutString
-ScreenRetrieve
-ScreenRows
-ScreenSetCursor
-ScreenUpdate
-ScreenUpdateLine
-ScreenVisualBell
-_set_screen_lines */
+#if (defined(_X86_) && !defined(__x86_64))
+ int __cdecl inp(unsigned short);
+ unsigned short __cdecl inpw(unsigned short);
+ int __cdecl outp(unsigned short,int);
+ unsigned short __cdecl outpw(unsigned short,unsigned short);
+#endif
-void _setcursortype (int type);
+ /* I/O intrin functions. */
+ __CRT_INLINE unsigned char __inbyte(unsigned short Port)
+ {
+ unsigned char value;
+ __asm__ __volatile__ ("inb %w1,%b0"
+ : "=a" (value)
+ : "Nd" (Port));
+ return value;
+ }
+ __CRT_INLINE unsigned short __inword(unsigned short Port)
+ {
+ unsigned short value;
+ __asm__ __volatile__ ("inw %w1,%w0"
+ : "=a" (value)
+ : "Nd" (Port));
+ return value;
+ }
+ __CRT_INLINE unsigned long __indword(unsigned short Port)
+ {
+ unsigned long value;
+ __asm__ __volatile__ ("inl %w1,%0"
+ : "=a" (value)
+ : "Nd" (Port));
+ return value;
+ }
+ __CRT_INLINE void __outbyte(unsigned short Port,unsigned char Data)
+ {
+ __asm__ __volatile__ ("outb %b0,%w1"
+ :
+ : "a" (Data), "Nd" (Port));
+ }
+ __CRT_INLINE void __outword(unsigned short Port,unsigned short Data)
+ {
+ __asm__ __volatile__ ("outw %w0,%w1"
+ :
+ : "a" (Data), "Nd" (Port));
+ }
+ __CRT_INLINE void __outdword(unsigned short Port,unsigned long Data)
+ {
+ __asm__ __volatile__ ("outl %0,%w1"
+ :
+ : "a" (Data), "Nd" (Port));
+ }
+ __CRT_INLINE void __inbytestring(unsigned short Port,unsigned char *Buffer,unsigned long Count)
+ {
+ __asm__ __volatile__ (
+ "cld ; rep ; insb "
+ : "=D" (Buffer), "=c" (Count)
+ : "d"(Port), "0"(Buffer), "1" (Count)
+ );
+ }
+ __CRT_INLINE void __inwordstring(unsigned short Port,unsigned short *Buffer,unsigned long Count)
+ {
+ __asm__ __volatile__ (
+ "cld ; rep ; insw "
+ : "=D" (Buffer), "=c" (Count)
+ : "d"(Port), "0"(Buffer), "1" (Count)
+ );
+ }
+ __CRT_INLINE void __indwordstring(unsigned short Port,unsigned long *Buffer,unsigned long Count)
+ {
+ __asm__ __volatile__ (
+ "cld ; rep ; insl "
+ : "=D" (Buffer), "=c" (Count)
+ : "d"(Port), "0"(Buffer), "1" (Count)
+ );
+ }
-void textattr (int _attr);
+ __CRT_INLINE void __outbytestring(unsigned short Port,unsigned char *Buffer,unsigned long Count)
+ {
+ __asm__ __volatile__ (
+ "cld ; rep ; outsb "
+ : "=S" (Buffer), "=c" (Count)
+ : "d"(Port), "0"(Buffer), "1" (Count)
+ );
+ }
+ __CRT_INLINE void __outwordstring(unsigned short Port,unsigned short *Buffer,unsigned long Count)
+ {
+ __asm__ __volatile__ (
+ "cld ; rep ; outsw "
+ : "=S" (Buffer), "=c" (Count)
+ : "d"(Port), "0"(Buffer), "1" (Count)
+ );
+ }
+ __CRT_INLINE void __outdwordstring(unsigned short Port,unsigned long *Buffer,unsigned long Count)
+ {
+ __asm__ __volatile__ (
+ "cld ; rep ; outsl "
+ : "=S" (Buffer), "=c" (Count)
+ : "d"(Port), "0"(Buffer), "1" (Count)
+ );
+ }
-void textbackground (int color);
+ __CRT_INLINE unsigned __int64 __readcr0(void)
+ {
+ unsigned __int64 value;
+ __asm__ __volatile__ (
+ "mov %%cr0, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
+
+ /* Register sizes are different between 32/64 bit mode. So we have to do this for _WIN64 and _WIN32
+ seperatly. */
+
+#ifdef _WIN64
+ __CRT_INLINE void __writecr0(unsigned __int64 Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr0"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned __int64 __readcr2(void)
+ {
+ unsigned __int64 value;
+ __asm__ __volatile__ (
+ "mov %%cr2, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
-void textcolor (int color);
+ __CRT_INLINE void __writecr2(unsigned __int64 Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr2"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned __int64 __readcr3(void)
+ {
+ unsigned __int64 value;
+ __asm__ __volatile__ (
+ "mov %%cr3, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
-/* textmode */
+ __CRT_INLINE void __writecr3(unsigned __int64 Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr3"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned __int64 __readcr4(void)
+ {
+ unsigned __int64 value;
+ __asm__ __volatile__ (
+ "mov %%cr4, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
-int wherex (void);
+ __CRT_INLINE void __writecr4(unsigned __int64 Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr4"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned __int64 __readcr8(void)
+ {
+ unsigned __int64 value;
+ __asm__ __volatile__ (
+ "mov %%cr8, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
-int wherey (void);
+ __CRT_INLINE void __writecr8(unsigned __int64 Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr8"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+#elif defined(_WIN32)
-/* window */
+ __CRT_INLINE void __writecr0(unsigned Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr0"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned long __readcr2(void)
+ {
+ unsigned long value;
+ __asm__ __volatile__ (
+ "mov %%cr2, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
+ __CRT_INLINE void __writecr2(unsigned Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr2"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned long __readcr3(void)
+ {
+ unsigned long value;
+ __asm__ __volatile__ (
+ "mov %%cr3, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
+ __CRT_INLINE void __writecr3(unsigned Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr3"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned long __readcr4(void)
+ {
+ unsigned long value;
+ __asm__ __volatile__ (
+ "mov %%cr4, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
-/* The code below was part of Mingw's conio.h */
-/*
- * conio.h
- *
- * Low level console I/O functions. Pretty please try to use the ANSI
- * standard ones if you are writing new code.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.2 $
- * $Author: bellard $
- * $Date: 2005/04/17 13:14:29 $
- *
- */
+ __CRT_INLINE void __writecr4(unsigned Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr4"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+ __CRT_INLINE unsigned long __readcr8(void)
+ {
+ unsigned long value; __asm__ __volatile__ (
+ "mov %%cr8, %[value]"
+ : [value] "=q" (value));
+ return value;
+ }
-char* _cgets (char*);
-int _cprintf (const char*, ...);
-int _cputs (const char*);
-int _cscanf (char*, ...);
+ __CRT_INLINE void __writecr8(unsigned Data)
+ {
+ __asm__ __volatile__ (
+ "mov %[Data], %%cr8"
+ :
+ : [Data] "q" (Data)
+ : "memory");
+ }
+
+#endif
-int _getch (void);
-int _getche (void);
-int _kbhit (void);
-int _putch (int);
-int _ungetch (int);
+ __CRT_INLINE unsigned __int64 __readmsr(unsigned long msr)
+ {
+ unsigned __int64 val1, val2;
+ __asm__ __volatile__(
+ "rdmsr"
+ : "=a" (val1), "=d" (val2)
+ : "c" (msr));
+ return val1 | (val2 << 32);
+ }
+ __CRT_INLINE void __writemsr (unsigned long msr, unsigned __int64 Value)
+ {
+ unsigned long val1 = Value, val2 = Value >> 32;
+ __asm__ __volatile__ (
+ "wrmsr"
+ :
+ : "c" (msr), "a" (val1), "d" (val2));
+ }
+
+ __CRT_INLINE unsigned __int64 __rdtsc(void)
+ {
+ unsigned __int64 val1, val2;
+ __asm__ __volatile__ (
+ "rdtsc"
+ : "=a" (val1), "=d" (val2));
+ return val1 | (val2 << 32);
+ }
-int getch (void);
-int getche (void);
-int kbhit (void);
-int putch (int);
-int ungetch (int);
+ __CRT_INLINE void __cpuid(int CPUInfo[4], int InfoType)
+ {
+ __asm__ __volatile__ (
+ "cpuid"
+ : "=a" (CPUInfo [0]), "=b" (CPUInfo [1]), "=c" (CPUInfo [2]), "=d" (CPUInfo [3])
+ : "a" (InfoType));
+ }
+#endif
#ifdef __cplusplus
}
#endif
-#endif /* _CONIO_H_ */
+#include <sec_api/conio_s.h>
+
+#endif