Added binary and unicode file i/o support to msvcrt.

Reduced differences between crtdll and msvcrt sources

svn path=/trunk/; revision=3781
This commit is contained in:
Robert Dickenson 2002-11-24 18:42:26 +00:00
parent 5bdf3d7d22
commit 787724058b
494 changed files with 6895 additions and 5832 deletions

View file

@ -1,3 +0,0 @@
*.d
*.o
*.sym

View file

@ -1,12 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/assert.h>
#include <crtdll/stdio.h>
#include <crtdll/stdlib.h>
#include <crtdll/signal.h>
void _assert(const char *msg, const char *file, int line)
{
/* Assertion failed at foo.c line 45: x<y */
fprintf(stderr, "Assertion failed at %s line %d: %s\n", file, line, msg);
raise(SIGABRT);
}

View file

@ -1,8 +1,8 @@
#include <crtdll/conio.h>
#include <crtdll/stdlib.h>
#include <msvcrt/conio.h>
#include <msvcrt/stdlib.h>
char *
_cgets(char *string)
char *_cgets(char *string)
{
unsigned len = 0;
unsigned int maxlen_wanted;

View file

@ -1,5 +1,5 @@
#include <crtdll/stdio.h>
#include <crtdll/conio.h>
#include <msvcrt/stdio.h>
#include <msvcrt/conio.h>
int
_cprintf(const char *fmt, ...)

View file

@ -8,10 +8,10 @@
* 28/12/98: Created
*/
#include <windows.h>
#include <crtdll/conio.h>
#include <crtdll/string.h>
#include <crtdll/stdio.h>
#include <crtdll/internal/file.h>
#include <msvcrt/conio.h>
#include <msvcrt/string.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
int _cputs(const char *_str)
{

View file

@ -1,19 +1,18 @@
#include <crtdll/conio.h>
#include <stdarg.h>
#include <stdio.h>
#include <msvcrt/conio.h>
#include <msvcrt/stdarg.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/stdio.h>
int
_cscanf(char *fmt, ...)
int _cscanf(char *fmt, ...)
{
int cnt;
int cnt;
va_list ap;
va_list ap;
//fixme cscanf should scan the console's keyboard
va_start(ap, fmt);
cnt = __vscanf(fmt, ap);
va_end(ap);
return cnt;
//fixme cscanf should scan the console's keyboard
va_start(ap, fmt);
cnt = __vscanf(fmt, ap);
va_end(ap);
return cnt;
}

View file

@ -8,32 +8,40 @@
* 28/12/98: Created
*/
#include <windows.h>
#include <crtdll/conio.h>
#include <crtdll/stdio.h>
#include <crtdll/io.h>
extern int char_avail;
extern int ungot_char;
#include <msvcrt/conio.h>
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/console.h>
int
_getch(void)
int _getch(void)
{
DWORD NumberOfCharsRead = 0;
char c;
if (char_avail)
{
c = ungot_char;
char_avail = 0;
}
else
{
ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL);
}
if ( c == 10 )
c = 13;
putchar(c);
return c;
DWORD NumberOfCharsRead = 0;
char c;
if (char_avail) {
c = ungot_char;
char_avail = 0;
} else {
ReadConsoleA(_get_osfhandle(stdin->_file),
&c,
1,
&NumberOfCharsRead,
NULL);
}
if (c == 10)
c = 13;
putchar(c);
return c;
}
#if 0
int _getche(void)
{
int c;
c = _getch();
_putch(c);
return c;
}
#endif

View file

@ -10,13 +10,11 @@
* 28/12/98: Created
*/
#include <crtdll/process.h>
#include <crtdll/conio.h>
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
extern int char_avail;
int
getche(void)
int getche(void)
{
if (char_avail)
/*

View file

@ -9,17 +9,15 @@
*/
#include <windows.h>
#include <crtdll/conio.h>
#include <crtdll/stdio.h>
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
// FIXME PeekCosoleInput returns more than keyboard hits
extern int char_avail;
int
_kbhit(void)
int _kbhit(void)
{
INPUT_RECORD InputRecord;
//INPUT_RECORD InputRecord;
DWORD NumberRead=0;
if (char_avail)
return(1);

View file

@ -7,15 +7,15 @@
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <crtdll/conio.h>
#include <windows.h>
#include <msvcrt/conio.h>
int _putch( int c )
{
DWORD NumberOfCharsWritten;
if ( WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL) ) {
return -1;
}
return NumberOfCharsWritten;
}

View file

@ -10,15 +10,16 @@
* 28/12/98: Created
*/
#include <crtdll/process.h>
#include <msvcrt/conio.h>
#include <msvcrt/internal/console.h>
#define EOF -1
int char_avail = 0;
char ungot_char = 0;
int ungot_char = 0;
int
_ungetch(int c)
int _ungetch(int c)
{
if (char_avail)
return(EOF);

View file

@ -0,0 +1,264 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/ctype.h>
unsigned short _ctype[] = {
0, /* <EOF>, 0xFFFF */
_CONTROL, /* CTRL+@, 0x00 */
_CONTROL, /* CTRL+A, 0x01 */
_CONTROL, /* CTRL+B, 0x02 */
_CONTROL, /* CTRL+C, 0x03 */
_CONTROL, /* CTRL+D, 0x04 */
_CONTROL, /* CTRL+E, 0x05 */
_CONTROL, /* CTRL+F, 0x06 */
_CONTROL, /* CTRL+G, 0x07 */
_CONTROL, /* CTRL+H, 0x08 */
_CONTROL | _SPACE, /* CTRL+I, 0x09 */
_CONTROL | _SPACE, /* CTRL+J, 0x0a */
_CONTROL | _SPACE, /* CTRL+K, 0x0b */
_CONTROL | _SPACE, /* CTRL+L, 0x0c */
_CONTROL | _SPACE, /* CTRL+M, 0x0d */
_CONTROL, /* CTRL+N, 0x0e */
_CONTROL, /* CTRL+O, 0x0f */
_CONTROL, /* CTRL+P, 0x10 */
_CONTROL, /* CTRL+Q, 0x11 */
_CONTROL, /* CTRL+R, 0x12 */
_CONTROL, /* CTRL+S, 0x13 */
_CONTROL, /* CTRL+T, 0x14 */
_CONTROL, /* CTRL+U, 0x15 */
_CONTROL, /* CTRL+V, 0x16 */
_CONTROL, /* CTRL+W, 0x17 */
_CONTROL, /* CTRL+X, 0x18 */
_CONTROL, /* CTRL+Y, 0x19 */
_CONTROL, /* CTRL+Z, 0x1a */
_CONTROL, /* CTRL+[, 0x1b */
_CONTROL, /* CTRL+\, 0x1c */
_CONTROL, /* CTRL+], 0x1d */
_CONTROL, /* CTRL+^, 0x1e */
_CONTROL, /* CTRL+_, 0x1f */
_SPACE | _BLANK, /* ` ', 0x20 */
_PUNCT, /* `!', 0x21 */
_PUNCT, /* 0x22 */
_PUNCT, /* `#', 0x23 */
_PUNCT, /* `$', 0x24 */
_PUNCT, /* `%', 0x25 */
_PUNCT, /* `&', 0x26 */
_PUNCT, /* 0x27 */
_PUNCT, /* `(', 0x28 */
_PUNCT, /* `)', 0x29 */
_PUNCT, /* `*', 0x2a */
_PUNCT, /* `+', 0x2b */
_PUNCT, /* `,', 0x2c */
_PUNCT, /* `-', 0x2d */
_PUNCT, /* `.', 0x2e */
_PUNCT, /* `/', 0x2f */
_DIGIT | _HEX, /* `0', 0x30 */
_DIGIT | _HEX, /* `1', 0x31 */
_DIGIT | _HEX, /* `2', 0x32 */
_DIGIT | _HEX, /* `3', 0x33 */
_DIGIT | _HEX, /* `4', 0x34 */
_DIGIT | _HEX, /* `5', 0x35 */
_DIGIT | _HEX, /* `6', 0x36 */
_DIGIT | _HEX, /* `7', 0x37 */
_DIGIT | _HEX, /* `8', 0x38 */
_DIGIT | _HEX, /* `9', 0x39 */
_PUNCT, /* `:', 0x3a */
_PUNCT, /* `;', 0x3b */
_PUNCT, /* `<', 0x3c */
_PUNCT, /* `=', 0x3d */
_PUNCT, /* `>', 0x3e */
_PUNCT, /* `?', 0x3f */
_PUNCT, /* `@', 0x40 */
_UPPER | _HEX, /* `A', 0x41 */
_UPPER | _HEX, /* `B', 0x42 */
_UPPER | _HEX, /* `C', 0x43 */
_UPPER | _HEX, /* `D', 0x44 */
_UPPER | _HEX, /* `E', 0x45 */
_UPPER | _HEX, /* `F', 0x46 */
_UPPER, /* `G', 0x47 */
_UPPER, /* `H', 0x48 */
_UPPER, /* `I', 0x49 */
_UPPER, /* `J', 0x4a */
_UPPER, /* `K', 0x4b */
_UPPER, /* `L', 0x4c */
_UPPER, /* `M', 0x4d */
_UPPER, /* `N', 0x4e */
_UPPER, /* `O', 0x4f */
_UPPER, /* `P', 0x50 */
_UPPER, /* `Q', 0x51 */
_UPPER, /* `R', 0x52 */
_UPPER, /* `S', 0x53 */
_UPPER, /* `T', 0x54 */
_UPPER, /* `U', 0x55 */
_UPPER, /* `V', 0x56 */
_UPPER, /* `W', 0x57 */
_UPPER, /* `X', 0x58 */
_UPPER, /* `Y', 0x59 */
_UPPER, /* `Z', 0x5a */
_PUNCT, /* `[', 0x5b */
_PUNCT, /* 0x5c */
_PUNCT, /* `]', 0x5d */
_PUNCT, /* `^', 0x5e */
_PUNCT, /* `_', 0x5f */
_PUNCT, /* 0x60 */
_LOWER | _HEX, /* `a', 0x61 */
_LOWER | _HEX, /* `b', 0x62 */
_LOWER | _HEX, /* `c', 0x63 */
_LOWER | _HEX, /* `d', 0x64 */
_LOWER | _HEX, /* `e', 0x65 */
_LOWER | _HEX, /* `f', 0x66 */
_LOWER, /* `g', 0x67 */
_LOWER, /* `h', 0x68 */
_LOWER, /* `i', 0x69 */
_LOWER, /* `j', 0x6a */
_LOWER, /* `k', 0x6b */
_LOWER, /* `l', 0x6c */
_LOWER, /* `m', 0x6d */
_LOWER, /* `n', 0x6e */
_LOWER, /* `o', 0x6f */
_LOWER, /* `p', 0x70 */
_LOWER, /* `q', 0x71 */
_LOWER, /* `r', 0x72 */
_LOWER, /* `s', 0x73 */
_LOWER, /* `t', 0x74 */
_LOWER, /* `u', 0x75 */
_LOWER, /* `v', 0x76 */
_LOWER, /* `w', 0x77 */
_LOWER, /* `x', 0x78 */
_LOWER, /* `y', 0x79 */
_LOWER, /* `z', 0x7a */
_PUNCT, /* `{', 0x7b */
_PUNCT, /* `|', 0x7c */
_PUNCT, /* `}', 0x7d */
_PUNCT, /* `~', 0x7e */
_CONTROL, /* 0x7f */
0, /* 0x80 */
0, /* 0x81 */
0, /* 0x82 */
0, /* 0x83 */
0, /* 0x84 */
0, /* 0x85 */
0, /* 0x86 */
0, /* 0x87 */
0, /* 0x88 */
0, /* 0x89 */
0, /* 0x8a */
0, /* 0x8b */
0, /* 0x8c */
0, /* 0x8d */
0, /* 0x8e */
0, /* 0x8f */
0, /* 0x90 */
0, /* 0x91 */
0, /* 0x92 */
0, /* 0x93 */
0, /* 0x94 */
0, /* 0x95 */
0, /* 0x96 */
0, /* 0x97 */
0, /* 0x98 */
0, /* 0x99 */
0, /* 0x9a */
0, /* 0x9b */
0, /* 0x9c */
0, /* 0x9d */
0, /* 0x9e */
0, /* 0x9f */
0, /* 0xa0 */
0, /* 0xa1 */
0, /* 0xa2 */
0, /* 0xa3 */
0, /* 0xa4 */
0, /* 0xa5 */
0, /* 0xa6 */
0, /* 0xa7 */
0, /* 0xa8 */
0, /* 0xa9 */
0, /* 0xaa */
0, /* 0xab */
0, /* 0xac */
0, /* 0xad */
0, /* 0xae */
0, /* 0xaf */
0, /* 0xb0 */
0, /* 0xb1 */
0, /* 0xb2 */
0, /* 0xb3 */
0, /* 0xb4 */
0, /* 0xb5 */
0, /* 0xb6 */
0, /* 0xb7 */
0, /* 0xb8 */
0, /* 0xb9 */
0, /* 0xba */
0, /* 0xbb */
0, /* 0xbc */
0, /* 0xbd */
0, /* 0xbe */
0, /* 0xbf */
0, /* 0xc0 */
0, /* 0xc1 */
0, /* 0xc2 */
0, /* 0xc3 */
0, /* 0xc4 */
0, /* 0xc5 */
0, /* 0xc6 */
0, /* 0xc7 */
0, /* 0xc8 */
0, /* 0xc9 */
0, /* 0xca */
0, /* 0xcb */
0, /* 0xcc */
0, /* 0xcd */
0, /* 0xce */
0, /* 0xcf */
0, /* 0xd0 */
0, /* 0xd1 */
0, /* 0xd2 */
0, /* 0xd3 */
0, /* 0xd4 */
0, /* 0xd5 */
0, /* 0xd6 */
0, /* 0xd7 */
0, /* 0xd8 */
0, /* 0xd9 */
0, /* 0xda */
0, /* 0xdb */
0, /* 0xdc */
0, /* 0xdd */
0, /* 0xde */
0, /* 0xdf */
0, /* 0xe0 */
0, /* 0xe1 */
0, /* 0xe2 */
0, /* 0xe3 */
0, /* 0xe4 */
0, /* 0xe5 */
0, /* 0xe6 */
0, /* 0xe7 */
0, /* 0xe8 */
0, /* 0xe9 */
0, /* 0xea */
0, /* 0xeb */
0, /* 0xec */
0, /* 0xed */
0, /* 0xee */
0, /* 0xef */
0, /* 0xf0 */
0, /* 0xf1 */
0, /* 0xf2 */
0, /* 0xf3 */
0, /* 0xf4 */
0, /* 0xf5 */
0, /* 0xf6 */
0, /* 0xf7 */
0, /* 0xf8 */
0, /* 0xf9 */
0, /* 0xfa */
0, /* 0xfb */
0, /* 0xfc */
0, /* 0xfd */
0, /* 0xfe */
0 /* 0xff */
};
/* EOF */

View file

@ -1,14 +1,14 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/conio/getch.c
* PURPOSE: Writes a character to stdout
* FILE: lib/crtdll/ctype/isascii.c
* PURPOSE: Checks if a character is ascii
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
int __isascii(int c)
{
@ -19,11 +19,3 @@ int iswascii(wint_t c)
{
return __isascii(c);
}

View file

@ -1,270 +1,14 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
unsigned short _ctype[] = {
0, /* <EOF>, 0xFFFF */
_CONTROL, /* CTRL+@, 0x00 */
_CONTROL, /* CTRL+A, 0x01 */
_CONTROL, /* CTRL+B, 0x02 */
_CONTROL, /* CTRL+C, 0x03 */
_CONTROL, /* CTRL+D, 0x04 */
_CONTROL, /* CTRL+E, 0x05 */
_CONTROL, /* CTRL+F, 0x06 */
_CONTROL, /* CTRL+G, 0x07 */
_CONTROL, /* CTRL+H, 0x08 */
_CONTROL | _SPACE, /* CTRL+I, 0x09 */
_CONTROL | _SPACE, /* CTRL+J, 0x0a */
_CONTROL | _SPACE, /* CTRL+K, 0x0b */
_CONTROL | _SPACE, /* CTRL+L, 0x0c */
_CONTROL | _SPACE, /* CTRL+M, 0x0d */
_CONTROL, /* CTRL+N, 0x0e */
_CONTROL, /* CTRL+O, 0x0f */
_CONTROL, /* CTRL+P, 0x10 */
_CONTROL, /* CTRL+Q, 0x11 */
_CONTROL, /* CTRL+R, 0x12 */
_CONTROL, /* CTRL+S, 0x13 */
_CONTROL, /* CTRL+T, 0x14 */
_CONTROL, /* CTRL+U, 0x15 */
_CONTROL, /* CTRL+V, 0x16 */
_CONTROL, /* CTRL+W, 0x17 */
_CONTROL, /* CTRL+X, 0x18 */
_CONTROL, /* CTRL+Y, 0x19 */
_CONTROL, /* CTRL+Z, 0x1a */
_CONTROL, /* CTRL+[, 0x1b */
_CONTROL, /* CTRL+\, 0x1c */
_CONTROL, /* CTRL+], 0x1d */
_CONTROL, /* CTRL+^, 0x1e */
_CONTROL, /* CTRL+_, 0x1f */
_SPACE | _BLANK, /* ` ', 0x20 */
_PUNCT, /* `!', 0x21 */
_PUNCT, /* 0x22 */
_PUNCT, /* `#', 0x23 */
_PUNCT, /* `$', 0x24 */
_PUNCT, /* `%', 0x25 */
_PUNCT, /* `&', 0x26 */
_PUNCT, /* 0x27 */
_PUNCT, /* `(', 0x28 */
_PUNCT, /* `)', 0x29 */
_PUNCT, /* `*', 0x2a */
_PUNCT, /* `+', 0x2b */
_PUNCT, /* `,', 0x2c */
_PUNCT, /* `-', 0x2d */
_PUNCT, /* `.', 0x2e */
_PUNCT, /* `/', 0x2f */
_DIGIT | _HEX, /* `0', 0x30 */
_DIGIT | _HEX, /* `1', 0x31 */
_DIGIT | _HEX, /* `2', 0x32 */
_DIGIT | _HEX, /* `3', 0x33 */
_DIGIT | _HEX, /* `4', 0x34 */
_DIGIT | _HEX, /* `5', 0x35 */
_DIGIT | _HEX, /* `6', 0x36 */
_DIGIT | _HEX, /* `7', 0x37 */
_DIGIT | _HEX, /* `8', 0x38 */
_DIGIT | _HEX, /* `9', 0x39 */
_PUNCT, /* `:', 0x3a */
_PUNCT, /* `;', 0x3b */
_PUNCT, /* `<', 0x3c */
_PUNCT, /* `=', 0x3d */
_PUNCT, /* `>', 0x3e */
_PUNCT, /* `?', 0x3f */
_PUNCT, /* `@', 0x40 */
_UPPER | _HEX, /* `A', 0x41 */
_UPPER | _HEX, /* `B', 0x42 */
_UPPER | _HEX, /* `C', 0x43 */
_UPPER | _HEX, /* `D', 0x44 */
_UPPER | _HEX, /* `E', 0x45 */
_UPPER | _HEX, /* `F', 0x46 */
_UPPER, /* `G', 0x47 */
_UPPER, /* `H', 0x48 */
_UPPER, /* `I', 0x49 */
_UPPER, /* `J', 0x4a */
_UPPER, /* `K', 0x4b */
_UPPER, /* `L', 0x4c */
_UPPER, /* `M', 0x4d */
_UPPER, /* `N', 0x4e */
_UPPER, /* `O', 0x4f */
_UPPER, /* `P', 0x50 */
_UPPER, /* `Q', 0x51 */
_UPPER, /* `R', 0x52 */
_UPPER, /* `S', 0x53 */
_UPPER, /* `T', 0x54 */
_UPPER, /* `U', 0x55 */
_UPPER, /* `V', 0x56 */
_UPPER, /* `W', 0x57 */
_UPPER, /* `X', 0x58 */
_UPPER, /* `Y', 0x59 */
_UPPER, /* `Z', 0x5a */
_PUNCT, /* `[', 0x5b */
_PUNCT, /* 0x5c */
_PUNCT, /* `]', 0x5d */
_PUNCT, /* `^', 0x5e */
_PUNCT, /* `_', 0x5f */
_PUNCT, /* 0x60 */
_LOWER | _HEX, /* `a', 0x61 */
_LOWER | _HEX, /* `b', 0x62 */
_LOWER | _HEX, /* `c', 0x63 */
_LOWER | _HEX, /* `d', 0x64 */
_LOWER | _HEX, /* `e', 0x65 */
_LOWER | _HEX, /* `f', 0x66 */
_LOWER, /* `g', 0x67 */
_LOWER, /* `h', 0x68 */
_LOWER, /* `i', 0x69 */
_LOWER, /* `j', 0x6a */
_LOWER, /* `k', 0x6b */
_LOWER, /* `l', 0x6c */
_LOWER, /* `m', 0x6d */
_LOWER, /* `n', 0x6e */
_LOWER, /* `o', 0x6f */
_LOWER, /* `p', 0x70 */
_LOWER, /* `q', 0x71 */
_LOWER, /* `r', 0x72 */
_LOWER, /* `s', 0x73 */
_LOWER, /* `t', 0x74 */
_LOWER, /* `u', 0x75 */
_LOWER, /* `v', 0x76 */
_LOWER, /* `w', 0x77 */
_LOWER, /* `x', 0x78 */
_LOWER, /* `y', 0x79 */
_LOWER, /* `z', 0x7a */
_PUNCT, /* `{', 0x7b */
_PUNCT, /* `|', 0x7c */
_PUNCT, /* `}', 0x7d */
_PUNCT, /* `~', 0x7e */
_CONTROL, /* 0x7f */
0, /* 0x80 */
0, /* 0x81 */
0, /* 0x82 */
0, /* 0x83 */
0, /* 0x84 */
0, /* 0x85 */
0, /* 0x86 */
0, /* 0x87 */
0, /* 0x88 */
0, /* 0x89 */
0, /* 0x8a */
0, /* 0x8b */
0, /* 0x8c */
0, /* 0x8d */
0, /* 0x8e */
0, /* 0x8f */
0, /* 0x90 */
0, /* 0x91 */
0, /* 0x92 */
0, /* 0x93 */
0, /* 0x94 */
0, /* 0x95 */
0, /* 0x96 */
0, /* 0x97 */
0, /* 0x98 */
0, /* 0x99 */
0, /* 0x9a */
0, /* 0x9b */
0, /* 0x9c */
0, /* 0x9d */
0, /* 0x9e */
0, /* 0x9f */
0, /* 0xa0 */
0, /* 0xa1 */
0, /* 0xa2 */
0, /* 0xa3 */
0, /* 0xa4 */
0, /* 0xa5 */
0, /* 0xa6 */
0, /* 0xa7 */
0, /* 0xa8 */
0, /* 0xa9 */
0, /* 0xaa */
0, /* 0xab */
0, /* 0xac */
0, /* 0xad */
0, /* 0xae */
0, /* 0xaf */
0, /* 0xb0 */
0, /* 0xb1 */
0, /* 0xb2 */
0, /* 0xb3 */
0, /* 0xb4 */
0, /* 0xb5 */
0, /* 0xb6 */
0, /* 0xb7 */
0, /* 0xb8 */
0, /* 0xb9 */
0, /* 0xba */
0, /* 0xbb */
0, /* 0xbc */
0, /* 0xbd */
0, /* 0xbe */
0, /* 0xbf */
0, /* 0xc0 */
0, /* 0xc1 */
0, /* 0xc2 */
0, /* 0xc3 */
0, /* 0xc4 */
0, /* 0xc5 */
0, /* 0xc6 */
0, /* 0xc7 */
0, /* 0xc8 */
0, /* 0xc9 */
0, /* 0xca */
0, /* 0xcb */
0, /* 0xcc */
0, /* 0xcd */
0, /* 0xce */
0, /* 0xcf */
0, /* 0xd0 */
0, /* 0xd1 */
0, /* 0xd2 */
0, /* 0xd3 */
0, /* 0xd4 */
0, /* 0xd5 */
0, /* 0xd6 */
0, /* 0xd7 */
0, /* 0xd8 */
0, /* 0xd9 */
0, /* 0xda */
0, /* 0xdb */
0, /* 0xdc */
0, /* 0xdd */
0, /* 0xde */
0, /* 0xdf */
0, /* 0xe0 */
0, /* 0xe1 */
0, /* 0xe2 */
0, /* 0xe3 */
0, /* 0xe4 */
0, /* 0xe5 */
0, /* 0xe6 */
0, /* 0xe7 */
0, /* 0xe8 */
0, /* 0xe9 */
0, /* 0xea */
0, /* 0xeb */
0, /* 0xec */
0, /* 0xed */
0, /* 0xee */
0, /* 0xef */
0, /* 0xf0 */
0, /* 0xf1 */
0, /* 0xf2 */
0, /* 0xf3 */
0, /* 0xf4 */
0, /* 0xf5 */
0, /* 0xf6 */
0, /* 0xf7 */
0, /* 0xf8 */
0, /* 0xf9 */
0, /* 0xfa */
0, /* 0xfb */
0, /* 0xfc */
0, /* 0xfd */
0, /* 0xfe */
0 /* 0xff */
};
extern unsigned short _ctype[];
unsigned short *_pctype_dll = _ctype + 1;
unsigned short *_pwctype_dll = _ctype + 1;
int _isctype (unsigned int c, int ctypeFlags)
int _isctype(unsigned int c, int ctypeFlags)
{
return (_pctype_dll[(unsigned char)(c & 0xFF)] & ctypeFlags);
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
#undef isgraph
int isgraph(int c)

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
#undef isprint
int isprint(int c)

View file

@ -7,7 +7,7 @@
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
#undef isspace
int isspace(int c)

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
#undef tolower
int tolower(int c)
@ -24,12 +24,13 @@ int _tolower(int c)
return(c);
}
/*
wchar_t _towlower(wchar_t c)
{
if (iswctype (c, _UPPER))
return (c - (L'A' - L'a'));
return(c);
}
*/

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/ctype.h>
#include <crtdll/wchar.h>
#include <msvcrt/ctype.h>
#undef toupper
int toupper(int c)
@ -25,9 +25,12 @@ int _toupper(int c)
return(c);
}
/*
wchar_t _towupper(wchar_t c)
{
if (iswctype (c, _LOWER))
return (c + (L'A' - L'a'));
return(c);
}
*/

View file

@ -1,7 +1,6 @@
#include <windows.h>
#include <crtdll/direct.h>
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
int _chdir( const char *_path )
@ -10,9 +9,5 @@ int _chdir( const char *_path )
_chdrive(tolower(_path[0] - 'a')+1);
if ( !SetCurrentDirectoryA((char *)_path) )
return -1;
return 0;
}

View file

@ -1,12 +1,12 @@
#include <crtdll/direct.h>
#include <crtdll/stdlib.h>
#include <crtdll/ctype.h>
#include <windows.h>
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
int cur_drive = 0;
int _chdrive( int drive )
{
char d[3];
@ -20,7 +20,5 @@ int _chdrive( int drive )
d[2] = 0;
SetCurrentDirectoryA(d);
}
return 0;
}

View file

@ -1,25 +1,22 @@
#include <windows.h>
#include <crtdll/direct.h>
#include <crtdll/stdlib.h>
#include <msvcrt/direct.h>
#include <msvcrt/stdlib.h>
char *_getcwd( char *buffer, int maxlen )
{
char *cwd;
int len;
if ( buffer == NULL ) {
cwd = malloc(MAX_PATH);
len = MAX_PATH;
}
else {
} else {
cwd = buffer;
len = maxlen;
}
if ( GetCurrentDirectoryA(len,cwd) == 0 )
if (GetCurrentDirectoryA(len, cwd) == 0) {
return NULL;
}
return cwd;
}

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <crtdll/direct.h>
#include <msvcrt/direct.h>
char* _getdcwd (int nDrive, char* caBuffer, int nBufLen)
{
@ -8,16 +8,12 @@ char* _getdcwd (int nDrive, char* caBuffer, int nBufLen)
if ( nDrive < 1 || nDrive > 26 )
return NULL;
if ( dr != nDrive )
_chdrive(nDrive);
i = GetCurrentDirectoryA(nBufLen,caBuffer);
if ( i == nBufLen )
return NULL;
if ( dr != nDrive )
_chdrive(dr);
return caBuffer;
}

View file

@ -1,6 +1,6 @@
#include <crtdll/direct.h>
#include <windows.h>
#include <crtdll/ctype.h>
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace)

View file

@ -1,11 +1,10 @@
#include <crtdll/direct.h>
#include <crtdll/ctype.h>
#include <windows.h>
#include <msvcrt/ctype.h>
#include <msvcrt/direct.h>
extern int cur_drive;
int _getdrive( void )
{
char Buffer[MAX_PATH];

View file

@ -1,5 +1,5 @@
#include <crtdll/direct.h>
#include <windows.h>
#include <msvcrt/direct.h>
int _mkdir( const char *_path )

View file

@ -1,6 +1,5 @@
#include <crtdll/direct.h>
#include <windows.h>
#include <msvcrt/direct.h>
int _rmdir( const char *_path )

View file

@ -9,21 +9,21 @@
* Significantly revised and rewinddir, seekdir and telldir added by Colin
* Peters <colin@fu.is.saga-u.ac.jp>
*
* $Revision: 1.2 $
* $Author: ariadne $
* $Date: 1999/04/02 21:43:47 $
* $Revision: 1.3 $
* $Author: robd $
* $Date: 2002/11/24 18:42:13 $
*
*/
#include <crtdll/stdlib.h>
/* #include <crtdll/ctype.h> */
#include <crtdll/errno.h>
#include <crtdll/string.h>
#include <crtdll/dir.h>
#include <crtdll/direct.h>
#include <crtdll/sys/stat.h>
#include <msvcrt/stdlib.h>
/* #include <msvcrt/ctype.h> */
#include <msvcrt/errno.h>
#include <msvcrt/string.h>
#include <msvcrt/dir.h>
#include <msvcrt/direct.h>
#include <msvcrt/sys/stat.h>
#include <crtdll/dirent.h>
#include <msvcrt/dirent.h>
#define SUFFIX "*"
#define SLASH "\\"

View file

@ -1,7 +1,13 @@
#include <windows.h>
#ifdef __GNUC__
int _abnormal_termination(void)
{
printf("Abnormal Termination\n");
// return AbnormalTermination();
}
#else
#endif

View file

@ -1,11 +1,28 @@
#include <windows.h>
#include <ntos/except.h>
#ifdef __GNUC__
#else
#endif
ULONG DbgPrint(PCH Format, ...)
{
return 0;
}
VOID STDCALL
MsvcrtDebug(ULONG Value)
{
//DbgPrint("MsvcrtDebug 0x%.08x\n", Value);
}
EXCEPTION_DISPOSITION
_except_handler2(
struct _EXCEPTION_RECORD *ExceptionRecord,
void *Frame,
struct _CONTEXT *ContextRecord,
void *DispatcherContext)
struct _EXCEPTION_RECORD* ExceptionRecord, void* Frame,
struct _CONTEXT *ContextRecord, void* DispatcherContext)
{
printf("exception handler\n");
//printf("_except_handler2()\n");
return 0;
}

View file

@ -1,22 +1,36 @@
struct _exception {
int type;
char *name;
double arg1;
double arg2;
double retval;
} ;
#include <windows.h>
#include <ntos/except.h>
int _matherr(struct _exception *e)
struct _exception {
int type;
char* name;
double arg1;
double arg2;
double retval;
} ;
int _matherr(struct _exception* e)
{
return 0;
}
// not exported by NTDLL
void __setusermatherr(int (*handler)(struct _exception*))
{
}
#define _FPIEEE_RECORD void
int _fpieee_flt(
unsigned long exception_code,
struct _EXCEPTION_POINTERS *ExceptionPointer,
int (* handler)(_FPIEEE_RECORD *)
unsigned long exception_code,
struct _EXCEPTION_POINTERS* ExceptionPointer,
int (*handler)(_FPIEEE_RECORD*)
)
{
return 0;
return 0;
}

View file

@ -1,13 +1,14 @@
#include <crtdll/float.h>
#include <msvcrt/float.h>
unsigned int _clearfp (void)
{
unsigned short __res = _statusfp();
#ifdef __GNUC__
__asm__ __volatile__ (
"fclex \n\t"
);
#else
#endif /*__GNUC__*/
return __res;
}

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/float.h>
#include <msvcrt/float.h>
unsigned int _controlfp (unsigned int unNew, unsigned int unMask)
{
@ -9,8 +9,8 @@ unsigned int _controlfp (unsigned int unNew, unsigned int unMask)
unsigned int _control87 (unsigned int unNew, unsigned int unMask)
{
register unsigned int __res;
#ifdef __GNUC__
__asm__ __volatile__ (
"pushl %%eax \n\t" /* make room on stack */
"fstcw (%%esp) \n\t"
@ -30,9 +30,8 @@ __asm__ __volatile__ (
"fldcw (%%esp) \n\t"
"popl %%edx \n\t"
:"=r" (__res):"r" (unNew),"r" (unMask): "ax", "dx", "cx");
/* :"=a" (__res):"c" (unNew),"d" (unMask):"ax", "dx", "cx"); */
#else
#endif /*__GNUC__*/
return __res;
}

View file

@ -1,5 +1,5 @@
#include <crtdll/float.h>
#include <crtdll/internal/ieee.h>
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
double _copysign (double __d, double __s)
{

View file

@ -18,14 +18,17 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
double _logb (double __x);
#include <msvcrt/float.h>
double _logb (double __x)
{
register double __value, __junk;
register double __value;
#ifdef __GNUC__
register double __junk;
__asm __volatile__
("fxtract\n\t"
: "=t" (__junk), "=u" (__value) : "0" (__x));
#else
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,5 +1,5 @@
#include <crtdll/float.h>
#include <crtdll/internal/ieee.h>
#include <msvcrt/float.h>
#include <msvcrt/internal/ieee.h>
double _scalb( double __x, long e )
{
@ -8,5 +8,4 @@ double _scalb( double __x, long e )
x->exponent += e;
return __x;
}

View file

@ -1,14 +1,16 @@
#include <crtdll/float.h>
#include <msvcrt/float.h>
unsigned int _statusfp (void)
{
register unsigned short __res;
#ifdef __GNUC__
__asm__ __volatile__ (
"fstsw %0 \n\t"
// "movzwl %ax, %eax"
:"=a" (__res)
);
#else
#endif /*__GNUC__*/
return __res;
}

View file

@ -1,38 +1,30 @@
#include <crtdll/io.h>
#include <windows.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#ifndef F_OK
#define F_OK 0x01
#endif
#ifndef R_OK
#define R_OK 0x02
#endif
#ifndef W_OK
#define W_OK 0x04
#endif
#ifndef X_OK
#define X_OK 0x08
#endif
#ifndef D_OK
#define D_OK 0x10
#endif
int _access( const char *_path, int _amode )
{
DWORD Attributes = GetFileAttributesA(_path);
DWORD Attributes = GetFileAttributesA(_path);
DPRINT("_access('%s', %x)\n", _path, _amode);
if ( Attributes == -1 )
return -1;
if ( (_amode & W_OK) == W_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY )
return -1;
}
if ( (_amode & D_OK) == D_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY )
return -1;
}
return 0;
if (Attributes == -1) {
__set_errno(ENOENT);
return -1;
}
if ((_amode & W_OK) == W_OK) {
if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
__set_errno(EACCES);
return -1;
}
}
if ((_amode & D_OK) == D_OK) {
if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
__set_errno(EACCES);
return -1;
}
}
return 0;
}

View file

@ -1,31 +1,33 @@
#include <windows.h>
#include <crtdll/io.h>
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#define mode_t int
int
_chmod(const char *filename, mode_t mode)
int _chmod(const char* filename, mode_t mode)
{
DWORD FileAttributes = 0;
FileAttributes = GetFileAttributes(filename);
if ( FileAttributes == -1 )
return -1;
if ( mode == 0 )
return -1;
if ( (mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
FileAttributes &= FILE_ATTRIBUTE_READONLY;
else if ( ((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE) )
FileAttributes &= FILE_ATTRIBUTE_NORMAL;
else
FileAttributes &= FILE_ATTRIBUTE_NORMAL;
DWORD FileAttributes = 0;
DPRINT("_chmod('%s', %x)\n", filename, mode);
FileAttributes = GetFileAttributesA(filename);
if ( FileAttributes == -1 )
return -1;
if ( SetFileAttributes(filename,FileAttributes) == FALSE )
return -1;
if ( mode == 0 )
return -1;
return 1;
if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
FileAttributes &= FILE_ATTRIBUTE_READONLY;
else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
FileAttributes &= FILE_ATTRIBUTE_NORMAL;
else
FileAttributes &= FILE_ATTRIBUTE_NORMAL;
if (SetFileAttributesA(filename, FileAttributes) == FALSE)
return -1;
return 1;
}

View file

@ -1,8 +1,12 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/io.h>
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _chsize(int _fd, long size)
{
DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
if (lseek(_fd, size, 0) == -1)
return -1;
if (_write(_fd, 0, 0) < 0)

View file

@ -1,14 +1,16 @@
#include <crtdll/io.h>
#include <windows.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _close(int _fd)
int _close(int _fd)
{
if ( _fd == -1 )
return -1;
if ( CloseHandle(_get_osfhandle(_fd)) == FALSE )
return -1;
return __fileno_close(_fd);
DPRINT("_close(fd %d)\n", _fd);
if (_fd == -1)
return -1;
if (CloseHandle(_get_osfhandle(_fd)) == FALSE)
return -1;
return __fileno_close(_fd);
}

View file

@ -1,9 +1,8 @@
#include <windows.h>
#include <crtdll/io.h>
#include <crtdll/errno.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/internal/file.h>
int _commode_dll = _IOCOMMIT;
int _commit(int _fd)
{

View file

@ -1,5 +1,5 @@
#include <crtdll/io.h>
#include <crtdll/fcntl.h>
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
int _creat(const char *filename, int mode)
{

View file

@ -1,12 +1,18 @@
/* $Id: dup.c,v 1.7 2002/11/24 18:42:13 robd Exp $ */
#include <windows.h>
#include <crtdll/io.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
// fixme change type of mode argument to mode_t
int __fileno_alloc(HANDLE hFile, int mode);
int __fileno_getmode(int _fd);
int _dup( int handle )
int _dup(int handle)
{
return __fileno_alloc(_get_osfhandle(handle), __fileno_getmode(handle));
HANDLE hFile;
int fd;
hFile = _get_osfhandle(handle);
fd = __fileno_alloc(hFile, __fileno_getmode(handle));
return fd;
}

View file

@ -1,6 +1,5 @@
#include <windows.h>
#include <crtdll/io.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
int _dup2( int handle1, int handle2 )
{

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <crtdll/io.h>
#include <msvcrt/io.h>
int _eof( int _fd )
{
@ -12,8 +12,4 @@ int _eof( int _fd )
return 1;
return 0;
}

View file

@ -1,8 +1,8 @@
#include <windows.h>
#include <crtdll/io.h>
#include <msvcrt/io.h>
long
_filelength(int _fd)
long _filelength(int _fd)
{
return GetFileSize(_get_osfhandle(_fd),NULL);
}

View file

@ -1,81 +1,77 @@
#include <windows.h>
#include <crtdll/io.h>
#include <crtdll/string.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/string.h>
#include <msvcrt/internal/file.h>
int _findfirst(const char *_name, struct _finddata_t *result)
int _findclose(int handle)
{
WIN32_FIND_DATA FindFileData;
char dir[MAX_PATH];
long hFindFile;
int len = 0;
if ( _name == NULL || _name[0] == 0 ) {
len = GetCurrentDirectory(MAX_PATH-4,dir);
if (dir[len-1] != '\\') {
dir[len] = '\\';
dir[len+1] = 0;
}
strcat(dir,"*.*");
}
else
strcpy(dir,_name);
hFindFile = (long)FindFirstFileA( dir, &FindFileData );
if ( hFindFile == -1 ) {
memset(result,0,sizeof(struct _finddata_t));
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName,260);
// if no wildcard the find file handle can be closed right away
// a return value of 0 can flag this.
if(!strchr(dir,'*') && !strchr(dir,'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
return FindClose((void*)handle);
}
int _findnext(int handle, struct _finddata_t *result)
int _findfirst(const char* _name, struct _finddata_t* result)
{
WIN32_FIND_DATA FindFileData;
// check no wildcards or invalid handle
if ( handle == 0 || handle == -1)
return 0;
WIN32_FIND_DATA FindFileData;
char dir[MAX_PATH];
long hFindFile;
int len = 0;
if ( !FindNextFile((void *)handle, &FindFileData ) )
return -1;
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName,260);
if (_name == NULL || _name[0] == 0) {
len = GetCurrentDirectory(MAX_PATH-4,dir);
if (dir[len-1] != '\\') {
dir[len] = '\\';
dir[len+1] = 0;
}
strcat(dir,"*.*");
} else {
strcpy(dir,_name);
}
hFindFile = (long)FindFirstFileA(dir, &FindFileData);
if (hFindFile == -1) {
memset(result,0,sizeof(struct _finddata_t));
return -1;
}
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName,260);
// if no wildcard the find file handle can be closed right away
// a return value of 0 can flag this.
if (!strchr(dir,'*') && !strchr(dir,'?')) {
_findclose(hFindFile);
return 0;
}
return hFindFile;
}
int _findclose(int handle)
int _findnext(int handle, struct _finddata_t* result)
{
// check no wildcards or invalid handle
if ( handle == 0 || handle == -1)
return 0;
return FindClose((void *)handle);
WIN32_FIND_DATA FindFileData;
// check no wildcards or invalid handle
if (handle == 0 || handle == -1)
return 0;
if (!FindNextFileA((void*)handle, &FindFileData))
return -1;
result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
strncpy(result->name,FindFileData.cFileName, MAX_PATH);
return 0;
}

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/fcntl.h>
#include <crtdll/io.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/io.h>
#undef _fmode
unsigned int _fmode = O_TEXT;

View file

@ -1,11 +1,13 @@
#include <crtdll/io.h>
#include <crtdll/sys/stat.h>
#include <msvcrt/io.h>
#include <msvcrt/sys/stat.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _isatty( int fd )
{
struct stat buf;
DPRINT("_isatty(fd %d)\n", fd);
if (_fstat (fd, &buf) < 0)
return 0;
if (S_ISCHR (buf.st_mode))

View file

@ -1,9 +1,9 @@
#include <windows.h>
#include <crtdll/io.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
long _lseek(int _fildes, long _offset, int _whence)
{
return _llseek((HFILE)filehnd(_fildes),_offset,_whence);
}

View file

@ -13,9 +13,12 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/stdio.h>
#include <crtdll/string.h>
#include <crtdll/io.h>
#include <msvcrt/stdio.h>
#include <msvcrt/string.h>
#include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
char* _mktemp (char *_template)
@ -24,8 +27,7 @@ char* _mktemp (char *_template)
char *cp, *dp;
int i, len, xcount, loopcnt;
DPRINT("_mktemp('%s')\n", _template);
len = strlen (_template);
cp = _template + len;

View file

@ -1,4 +1,5 @@
/*
/* $Id: open.c,v 1.13 2002/11/24 18:42:13 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/open.c
@ -14,147 +15,140 @@
#include <windows.h>
#include <stdarg.h>
#include <crtdll/io.h>
#include <crtdll/fcntl.h>
#include <crtdll/sys/stat.h>
#include <crtdll/stdlib.h>
#include <crtdll/internal/file.h>
#include <crtdll/string.h>
#include <crtdll/share.h>
#include <msvcrt/io.h>
#include <msvcrt/fcntl.h>
#include <msvcrt/sys/stat.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/internal/file.h>
#include <msvcrt/string.h>
#include <msvcrt/share.h>
#define STD_AUX_HANDLE 3
#define STD_PRINTER_HANDLE 4
typedef struct _fileno_modes_type
{
HANDLE hFile;
int mode;
int fd;
HANDLE hFile;
int mode;
int fd;
} fileno_modes_type;
int __fileno_alloc(HANDLE hFile, int mode);
fileno_modes_type *fileno_modes = NULL;
int maxfno = 5;
int minfno = 5;
char __is_text_file(FILE *p)
char __is_text_file(FILE* p)
{
if ( p == NULL || fileno_modes == NULL )
if (p == NULL || fileno_modes == NULL)
return FALSE;
return (!((p)->_flag&_IOSTRG) && (fileno_modes[(p)->_file].mode&O_TEXT));
}
int __fileno_alloc(HANDLE hFile, int mode);
int _open(const char *_path, int _oflag,...)
int _open(const char* _path, int _oflag,...)
{
HANDLE hFile;
DWORD dwDesiredAccess = 0;
DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD dwCreationDistribution = 0;
DWORD dwFlagsAndAttributes = 0;
int mode;
va_list arg;
va_start (arg, _oflag);
mode = va_arg(arg,int);
va_end (arg);
if ( (mode == S_IWRITE) || (mode == 0) )
dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY;
HANDLE hFile;
DWORD dwDesiredAccess = 0;
DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD dwCreationDistribution = 0;
DWORD dwFlagsAndAttributes = 0;
int mode;
va_list arg;
/*
*
* _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
* _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
*
*/
if (( _oflag & _O_RDWR ) == _O_RDWR )
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ ;
else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
dwDesiredAccess |= GENERIC_WRITE ;
else
dwDesiredAccess |= GENERIC_READ ;
va_start(arg, _oflag);
mode = va_arg(arg,int);
va_end (arg);
if ((mode == S_IWRITE) || (mode == 0))
dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY;
/*
*
* _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
* _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
*
*/
if (( _oflag & _O_RDWR ) == _O_RDWR )
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ ;
else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
dwDesiredAccess |= GENERIC_WRITE ;
else
dwDesiredAccess |= GENERIC_READ ;
if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
dwCreationDistribution |= CREATE_NEW;
if ((_oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL))
dwCreationDistribution |= CREATE_NEW;
else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
if (( _oflag & O_CREAT ) == O_CREAT )
dwCreationDistribution |= CREATE_ALWAYS;
else if (( _oflag & O_RDONLY ) != O_RDONLY )
dwCreationDistribution |= TRUNCATE_EXISTING;
}
else if (( _oflag & _O_APPEND ) == _O_APPEND )
dwCreationDistribution |= OPEN_EXISTING;
else if (( _oflag & _O_CREAT ) == _O_CREAT )
dwCreationDistribution |= OPEN_ALWAYS;
else
dwCreationDistribution |= OPEN_EXISTING;
if (( _oflag & _O_RANDOM ) == _O_RANDOM )
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY )
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED )
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
hFile = CreateFileA(_path,
dwDesiredAccess,
dwShareMode,
NULL,
dwCreationDistribution,
dwFlagsAndAttributes,
NULL);
if (hFile == (HANDLE)-1)
return -1;
return __fileno_alloc(hFile,_oflag);
else if ((_oflag & O_TRUNC) == O_TRUNC) {
if ((_oflag & O_CREAT) == O_CREAT)
dwCreationDistribution |= CREATE_ALWAYS;
else if ((_oflag & O_RDONLY ) != O_RDONLY)
dwCreationDistribution |= TRUNCATE_EXISTING;
}
else if ((_oflag & _O_APPEND) == _O_APPEND)
dwCreationDistribution |= OPEN_EXISTING;
else if ((_oflag & _O_CREAT) == _O_CREAT)
dwCreationDistribution |= OPEN_ALWAYS;
else
dwCreationDistribution |= OPEN_EXISTING;
// _O_APPEND Moves file pointer to end of file before every write operation.
if ((_oflag & _O_RANDOM) == _O_RANDOM)
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL)
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY)
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED)
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
hFile = CreateFileA(_path,
dwDesiredAccess,
dwShareMode,
NULL,
dwCreationDistribution,
dwFlagsAndAttributes,
NULL);
if (hFile == (HANDLE)-1)
return -1;
return __fileno_alloc(hFile,_oflag);
// _O_APPEND Moves file pointer to end of file before every write operation.
}
int
__fileno_alloc(HANDLE hFile, int mode)
{
int i;
/* Check for bogus values */
if (hFile < 0)
return -1;
return -1;
for(i=minfno;i<maxfno;i++) {
if (fileno_modes[i].fd == -1 ) {
fileno_modes[i].fd = i;
fileno_modes[i].mode = mode;
fileno_modes[i].hFile = hFile;
return i;
}
if (fileno_modes[i].fd == -1 ) {
fileno_modes[i].fd = i;
fileno_modes[i].mode = mode;
fileno_modes[i].hFile = hFile;
return i;
}
}
/* See if we need to expand the tables. Check this BEFORE it might fail,
so that when we hit the count'th request, we've already up'd it. */
if ( i == maxfno)
{
int oldcount = maxfno;
fileno_modes_type *old_fileno_modes = fileno_modes;
maxfno += 255;
maxfno += 255;
fileno_modes = (fileno_modes_type *)malloc(maxfno * sizeof(fileno_modes_type));
if ( old_fileno_modes != NULL )
{
memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type));
free ( old_fileno_modes );
}
memset(fileno_modes + oldcount, 0, (maxfno-oldcount)*sizeof(fileno_modes));
}
/* Fill in the value */
@ -166,103 +160,86 @@ __fileno_alloc(HANDLE hFile, int mode)
void *filehnd(int fileno)
{
if ( fileno < 0 )
return (void *)-1;
#define STD_AUX_HANDLE 3
#define STD_PRINTER_HANDLE 4
switch(fileno)
{
case 0:
return GetStdHandle(STD_INPUT_HANDLE);
case 1:
return GetStdHandle(STD_OUTPUT_HANDLE);
case 2:
return GetStdHandle(STD_ERROR_HANDLE);
case 3:
return GetStdHandle(STD_AUX_HANDLE);
case 4:
return GetStdHandle(STD_PRINTER_HANDLE);
default:
break;
}
if ( fileno >= maxfno )
return (void *)-1;
if ( fileno_modes[fileno].fd == -1 )
return (void *)-1;
return fileno_modes[fileno].hFile;
}
int __fileno_dup2( int handle1, int handle2 )
{
if ( handle1 >= maxfno )
return -1;
if ( handle1 < 0 )
return -1;
if ( handle2 >= maxfno )
return -1;
if ( handle2 < 0 )
return -1;
memcpy(&fileno_modes[handle1],&fileno_modes[handle2],sizeof(fileno_modes));
return handle1;
if (fileno < 0)
return (void*)-1;
switch (fileno) {
case 0:
return GetStdHandle(STD_INPUT_HANDLE);
case 1:
return GetStdHandle(STD_OUTPUT_HANDLE);
case 2:
return GetStdHandle(STD_ERROR_HANDLE);
case 3:
return GetStdHandle(STD_AUX_HANDLE);
case 4:
return GetStdHandle(STD_PRINTER_HANDLE);
default:
break;
}
if (fileno >= maxfno)
return (void*)-1;
if (fileno_modes[fileno].fd == -1)
return (void*)-1;
return fileno_modes[fileno].hFile;
}
int __fileno_setmode(int _fd, int _newmode)
{
int m;
if ( _fd < minfno )
return -1;
int m;
if ( _fd >= maxfno )
return -1;
m = fileno_modes[_fd].mode;
fileno_modes[_fd].mode = _newmode;
return m;
if (_fd < minfno) {
return -1;
}
if (_fd >= maxfno)
return -1;
m = fileno_modes[_fd].mode;
fileno_modes[_fd].mode = _newmode;
return m;
}
int __fileno_getmode(int _fd)
{
if ( _fd < minfno )
return -1;
if ( _fd >= maxfno )
return -1;
return fileno_modes[_fd].mode;
if (_fd < minfno) {
return -1;
}
if (_fd >= maxfno)
return -1;
return fileno_modes[_fd].mode;
}
int __fileno_close(int _fd)
int __fileno_close(int _fd)
{
if ( _fd < 0 )
return -1;
if ( _fd >= maxfno )
return -1;
fileno_modes[_fd].fd = -1;
fileno_modes[_fd].hFile = (HANDLE)-1;
return 0;
if (_fd < 0) {
return -1;
}
if (_fd >= maxfno)
return -1;
fileno_modes[_fd].fd = -1;
fileno_modes[_fd].hFile = (HANDLE)-1;
return 0;
}
int _open_osfhandle (void *osfhandle, int flags )
int _open_osfhandle(void *osfhandle, int flags)
{
return __fileno_alloc((HANDLE)osfhandle, flags);
}
void *_get_osfhandle( int fileno )
{
return filehnd(fileno);
return __fileno_alloc((HANDLE)osfhandle, flags);
}
void *_get_osfhandle(int fileno)
{
return filehnd(fileno);
}
int __fileno_dup2(int handle1, int handle2)
{
if (handle1 >= maxfno) {
return -1;
}
if (handle1 < 0)
return -1;
if (handle2 >= maxfno)
return -1;
if (handle2 < 0)
return -1;
memcpy(&fileno_modes[handle1],&fileno_modes[handle2],sizeof(fileno_modes));
return handle1;
}

View file

@ -1,4 +1,5 @@
/*
/* $Id: pipe.c,v 1.4 2002/11/24 18:42:13 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/pipe.c
@ -8,8 +9,8 @@
* 28/12/98: Appropriated for Reactos
*/
#include <windows.h>
#include <crtdll/io.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
int _pipe(int _fildes[2], unsigned int size, int mode )

View file

@ -1,14 +1,19 @@
/*
/* $Id: read.c,v 1.9 2002/11/24 18:42:13 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/read.c
* PURPOSE: Reads a file
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 28/12/98: Created
* 28/12/1998: Created
*/
#include <crtdll/io.h>
#include <windows.h>
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
size_t _read(int _fd, void *_buf, size_t _nbyte)
{

View file

@ -1,4 +1,5 @@
/*
/* $Id: setmode.c,v 1.5 2002/11/24 18:42:13 robd Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/io/setmode.c
@ -8,12 +9,16 @@
* 28/12/98: Created
*/
#include <crtdll/io.h>
#include <crtdll/stdio.h>
#include <crtdll/internal/file.h>
#include <msvcrt/io.h>
#include <msvcrt/stdio.h>
#include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _setmode(int _fd, int _newmode)
{
DPRINT("_setmod(fd %d, newmode %x)\n", _fd, _newmode);
return __fileno_setmode(_fd, _newmode);
}

View file

@ -1,4 +1,4 @@
#include <crtdll/io.h>
#include <msvcrt/io.h>
int _sopen(char *path,int access,int shflag,int mode)

View file

@ -1,10 +1,9 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/errno.h>
#include <crtdll/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/io.h>
off_t
_tell(int _file)
off_t _tell(int _file)
{
return _lseek(_file, 0, SEEK_CUR);
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/sys/stat.h>
#include <msvcrt/sys/stat.h>
unsigned _unMode_dll = 022;

View file

@ -8,7 +8,7 @@
* 28/12/98: Created
*/
#include <windows.h>
#include <crtdll/io.h>
#include <msvcrt/io.h>

View file

@ -1,8 +1,9 @@
#include <crtdll/stdio.h>
#include <crtdll/io.h>
#include <crtdll/errno.h>
#include <crtdll/sys/utime.h>
#include <crtdll/internal/file.h>
#include <msvcrt/stdio.h>
#include <msvcrt/io.h>
#include <msvcrt/errno.h>
#include <msvcrt/sys/utime.h>
#include <msvcrt/internal/file.h>
int _utime(const char* filename, struct _utimbuf* buf)
{
@ -18,5 +19,4 @@ int _utime(const char* filename, struct _utimbuf* buf)
if ( _close(fn) < 0 )
return -1;
return ret;
}

View file

@ -7,8 +7,8 @@
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <crtdll/io.h>
#include <windows.h>
#include <msvcrt/io.h>

View file

@ -1,12 +1,11 @@
#include <crtdll/stdio.h>
#include <crtdll/locale.h>
#include <crtdll/string.h>
#include <msvcrt/stdio.h>
#include <msvcrt/locale.h>
#include <msvcrt/string.h>
#include <limits.h>
int _current_category; /* used by setlocale */
const char *_current_locale;
int __mb_cur_max_dll = 1;
int parse_locale(char *locale, char *lang, char *country, char *code_page);
@ -140,4 +139,3 @@ struct lconv *localeconv(void)
{
return (struct lconv *) &_lconv;
}

View file

@ -1,7 +1,9 @@
# $Id: makefile,v 1.49 2002/11/19 17:16:14 robd Exp $
# $Id: makefile,v 1.50 2002/11/24 18:42:12 robd Exp $
PATH_TO_TOP = ../..
PATH_TO_MSVCRT = ../msvcrt
TARGET_DEFONLY = yes
TARGET_TYPE = dynlink
@ -17,7 +19,6 @@ TARGET_SDKLIBS = kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
TARGET_CLEAN = \
assert/*.o \
conio/*.o \
ctype/*.o \
direct/*.o \
@ -50,9 +51,6 @@ include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
ASSERT_OBJECTS = \
assert/assert.o
CONIO_OBJECTS = \
conio/cgets.o \
conio/cprintf.o \
@ -65,6 +63,7 @@ CONIO_OBJECTS = \
conio/ungetch.o
CTYPE_OBJECTS = \
ctype/ctype.o \
ctype/isalnum.o \
ctype/isalpha.o \
ctype/isascii.o \
@ -241,6 +240,8 @@ MBSTRING_OBJECTS = \
MISC_OBJECTS = \
misc/amsg.o \
misc/assert.o \
misc/debug.o \
misc/dllmain.o \
misc/GetArgs.o \
misc/initterm.o \
@ -452,38 +453,38 @@ TIME_OBJECTS = \
time/strtime.o \
time/time.o
WCHAR_OBJECTS = \
wchar/wcscat.o \
wchar/wcschr.o \
wchar/wcscmp.o \
WSTRING_OBJECTS = \
$(PATH_TO_MSVCRT)/wstring/wcscat.o \
$(PATH_TO_MSVCRT)/wstring/wcschr.o \
$(PATH_TO_MSVCRT)/wstring/wcscmp.o \
wchar/wcscoll.o \
wchar/wcscpy.o \
wchar/wcscspn.o \
wchar/wcsdup.o \
wchar/wcsicmp.o \
$(PATH_TO_MSVCRT)/wstring/wcscpy.o \
$(PATH_TO_MSVCRT)/wstring/wcscspn.o \
$(PATH_TO_MSVCRT)/wstring/wcsdup.o \
$(PATH_TO_MSVCRT)/wstring/wcsicmp.o \
wchar/wcslen.o \
wchar/wcslwr.o \
wchar/wcsncat.o \
wchar/wcsncmp.o \
wchar/wcsncpy.o \
wchar/wcsnlen.o \
wchar/wcspbrk.o \
wchar/wcsrchr.o \
wchar/wcsrev.o \
wchar/wcsset.o \
wchar/wcsspn.o \
wchar/wcsstr.o \
$(PATH_TO_MSVCRT)/wstring/wcslwr.o \
$(PATH_TO_MSVCRT)/wstring/wcsncat.o \
$(PATH_TO_MSVCRT)/wstring/wcsncmp.o \
$(PATH_TO_MSVCRT)/wstring/wcsncpy.o \
$(PATH_TO_MSVCRT)/wstring/wcsnlen.o \
$(PATH_TO_MSVCRT)/wstring/wcspbrk.o \
$(PATH_TO_MSVCRT)/wstring/wcsrchr.o \
$(PATH_TO_MSVCRT)/wstring/wcsrev.o \
$(PATH_TO_MSVCRT)/wstring/wcsset.o \
$(PATH_TO_MSVCRT)/wstring/wcsspn.o \
$(PATH_TO_MSVCRT)/wstring/wcsstr.o \
wchar/wcstod.o \
wchar/wcstok.o \
wchar/wcstol.o \
wchar/wcsupr.o \
wchar/wcsxfrm.o \
$(PATH_TO_MSVCRT)/wstring/wcsupr.o \
$(PATH_TO_MSVCRT)/wstring/wcsxfrm.o \
wchar/wtoi.o \
wchar/wcstombs.o \
wchar/wcsnicmp.o
$(PATH_TO_MSVCRT)/wstring/wcsnicmp.o
OBJECTS = \
$(ASSERT_OBJECTS) \
$(CONIO_OBJECTS) \
$(CTYPE_OBJECTS) \
$(DIRECT_OBJECTS) \
@ -505,7 +506,7 @@ OBJECTS = \
$(SYS_STAT_OBJECTS) \
$(TCHAR_OBJECTS) \
$(TIME_OBJECTS) \
$(WCHAR_OBJECTS)
$(WSTRING_OBJECTS)
$(TARGET_NAME).o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o $(TARGET_NAME).o

View file

@ -18,15 +18,20 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double atan (double __x);
double atan (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fld1\n\t"
"fpatan"
: "=t" (__value) : "0" (__x));
#else
__value = linkme_atan(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,12 +1,18 @@
#include <msvcrt/math.h>
double atan2 (double __y, double __x);
double atan2 (double __y, double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fpatan\n\t"
"fld %%st(0)"
: "=t" (__value) : "0" (__x), "u" (__y));
#else
__value = linkme_atan2(__x, __y);
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,4 +1,4 @@
#include <crtdll/math.h>
#include <msvcrt/math.h>
double _cabs( struct _complex z )
{

View file

@ -1,10 +1,9 @@
#include <crtdll/math.h>
double ceil (double __x);
#include <msvcrt/math.h>
double ceil (double __x)
{
register double __value;
#ifdef __GNUC__
__volatile unsigned short int __cw, __cwtmp;
__asm __volatile ("fnstcw %0" : "=m" (__cw));
@ -12,7 +11,9 @@ double ceil (double __x)
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
__asm __volatile ("fldcw %0" : : "m" (__cw));
#else
__value = linkme_ceil(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,11 +1,16 @@
#include <msvcrt/math.h>
double cos (double __x);
double cos (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fcos"
: "=t" (__value): "0" (__x));
#else
__value = linkme_cos(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -18,11 +18,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double exp (double __x);
double exp (double __x)
{
#ifdef __GNUC__
register double __value, __exponent;
__asm __volatile__
("fldl2e # e^x = 2^(x * log2(e))\n\t"
@ -39,4 +41,7 @@ double exp (double __x)
: "=t" (__value) : "0" (__value), "u" (__exponent));
return __value;
#else
return linkme_exp(__x);
#endif /*__GNUC__*/
}

View file

@ -18,15 +18,19 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double fabs (double __x);
double fabs (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fabs"
: "=t" (__value) : "0" (__x));
#else
__value = linkme_fabs(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -18,12 +18,14 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double floor (double __x);
double floor (double __x)
{
register double __value;
#ifdef __GNUC__
__volatile unsigned short int __cw, __cwtmp;
__asm __volatile ("fnstcw %0" : "=m" (__cw));
@ -31,7 +33,9 @@ double floor (double __x)
__asm __volatile ("fldcw %0" : : "m" (__cwtmp));
__asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
__asm __volatile ("fldcw %0" : : "m" (__cw));
#else
__value = linkme_floor(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -18,18 +18,22 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double fmod (double __x, double __y);
double fmod (double __x, double __y)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("1: fprem\n\t"
"fstsw %%ax\n\t"
"sahf\n\t"
"jp 1b"
: "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc");
#else
__value = linkme_fmod(__x, __y);
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,6 +1,6 @@
#include <crtdll/math.h>
#include <crtdll/stdlib.h>
#include <crtdll/internal/ieee.h>
#include <msvcrt/math.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/internal/ieee.h>
double
frexp(double __x, int *exptr)

View file

@ -1,5 +1,6 @@
#include <crtdll/float.h>
#include <msvcrt/float.h>
long _ftol(double fl) {
long _ftol(double fl)
{
return (long)fl;
}

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/internal/ieee.h>
#include <msvcrt/internal/ieee.h>
#undef _HUGE
double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };

View file

@ -16,9 +16,9 @@
*
*/
#include <crtdll/float.h>
#include <crtdll/math.h>
#include <crtdll/errno.h>
#include <msvcrt/float.h>
#include <msvcrt/math.h>
#include <msvcrt/errno.h>
/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers
between these two shouldn't neither overflow nor underflow
@ -78,7 +78,7 @@ _hypot(double x, double y)
#ifdef TEST
#include <crtdll/stdio.h>
#include <msvcrt/stdio.h>
int
main(void)

View file

@ -18,14 +18,19 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double ldexp (double __x, int __y);
double ldexp (double __x, int __y)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__x), "u" ((double) __y));
#else
__value = linkme_ldexp(__x, __y);
#endif /*__GNUC__*/
return __value;
}

View file

@ -18,16 +18,21 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double log (double __x);
double log (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fldln2\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
#else
__value = linkme_log(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -18,17 +18,21 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double log10 (double __x);
double log10 (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fldlg2\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
#else
__value = linkme_log10(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -10,9 +10,9 @@
* ====================================================
*/
#include <crtdll/float.h>
#include <crtdll/math.h>
#include <crtdll/internal/ieee.h>
#include <msvcrt/float.h>
#include <msvcrt/math.h>
#include <msvcrt/internal/ieee.h>

View file

@ -18,6 +18,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double pow (double __x, double __y);
double __log2 (double __x);
@ -25,18 +27,24 @@ double __log2 (double __x);
double __log2 (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fld1\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
#else
//__value = linkme_log2(__x);
__value = 0;
#endif /*__GNUC__*/
return __value;
}
double pow (double __x, double __y)
{
register double __value, __exponent;
register double __value;
#ifdef __GNUC__
register double __exponent;
long __p = (long) __y;
if (__x == 0.0 && __y > 0.0)
@ -74,7 +82,9 @@ double pow (double __x, double __y)
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__value), "u" (__exponent));
#else
__value = linkme_pow(__x, __y);
#endif /*__GNUC__*/
return __value;
}
@ -82,4 +92,3 @@ long double powl (long double __x,long double __y)
{
return pow(__x,__y/2)*pow(__x,__y/2);
}

View file

@ -18,15 +18,19 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double sin (double __x);
double sin (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fsin"
: "=t" (__value) : "0" (__x));
#else
__value = linkme_sin(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/math.h>
#include <msvcrt/math.h>
double sinh(double x)
{

View file

@ -17,16 +17,19 @@
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double sqrt (double __x);
double sqrt (double __x)
{
register double __value;
#ifdef __GNUC__
__asm __volatile__
("fsqrt"
: "=t" (__value) : "0" (__x));
#else
__value = linkme_sqrt(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -18,16 +18,20 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <msvcrt/math.h>
double tan (double __x);
double tan (double __x)
{
register double __value;
#ifdef __GNUC__
register double __value2 __attribute__ ((unused));
__asm __volatile__
("fptan"
: "=t" (__value2), "=u" (__value) : "0" (__x));
#else
__value = linkme_tan(__x);
#endif /*__GNUC__*/
return __value;
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/math.h>
#include <msvcrt/math.h>
double tanh(double x)
{

View file

@ -9,7 +9,7 @@
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <msvcrt/mbctype.h>
static unsigned short han_to_zen_ascii_table[0x5f] = {
0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,

View file

@ -8,8 +8,8 @@
Modified from Taiji Yamada japanese code system utilities
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <msvcrt/mbstring.h>
#include <msvcrt/mbctype.h>
int _ismbbkana(unsigned char c)
{

View file

@ -1,4 +1,4 @@
#include <crtdll/mbctype.h>
#include <msvcrt/mbctype.h>
int _ismbbkalpha(unsigned char c)
{

View file

@ -7,7 +7,7 @@
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <msvcrt/mbctype.h>
int _ismbbkpunct( unsigned int c )
{

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <crtdll/mbstring.h>
#include <msvcrt/mbstring.h>
int isleadbyte(char *mbstr)
{

View file

@ -8,8 +8,8 @@
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
#include <msvcrt/mbctype.h>
#include <msvcrt/ctype.h>
// code page 952 only
int _ismbclower( unsigned int c )

View file

@ -7,10 +7,8 @@
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int _ismbbkalnum( unsigned int c );
#include <msvcrt/mbctype.h>
#include <msvcrt/ctype.h>
int _ismbbalpha(unsigned char c)
{

View file

@ -1,7 +1,6 @@
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
#include <msvcrt/mbctype.h>
#include <msvcrt/ctype.h>
int _ismbbkalnum( unsigned int c );
int _ismbbalnum(unsigned char c)
{

View file

@ -1,4 +1,4 @@
#include <crtdll/mbstring.h>
#include <msvcrt/mbstring.h>
int _ismbbalpha(unsigned char c);
int _ismbbalnum(unsigned char c);

View file

@ -1,6 +1,6 @@
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
#include <msvcrt/mbstring.h>
#include <msvcrt/mbctype.h>
#include <msvcrt/ctype.h>
int _ismbbgraph(unsigned char c)
{

View file

@ -7,8 +7,8 @@
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
#include <msvcrt/mbctype.h>
#include <msvcrt/ctype.h>
int _ismbbkalnum( unsigned int c )
{

View file

@ -9,9 +9,9 @@
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/stdlib.h>
#include <crtdll/mbctype.h>
#include <msvcrt/mbstring.h>
#include <msvcrt/stdlib.h>
#include <msvcrt/mbctype.h>
size_t _mbclen2(const unsigned int s);

View file

@ -1,6 +1,6 @@
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
#include <msvcrt/mbstring.h>
#include <msvcrt/mbctype.h>
#include <msvcrt/ctype.h>
int _ismbbprint(unsigned char c)
{

Some files were not shown because too many files have changed in this diff Show more