From 9fd228d402266f3a2355bfea0202bb48cdc09667 Mon Sep 17 00:00:00 2001 From: Boudewijn Dekker Date: Sun, 7 Mar 1999 13:35:11 +0000 Subject: [PATCH] Various changes to header files svn path=/trunk/; revision=280 --- reactos/include/ctype.h | 46 +++++++------- reactos/include/excpt.h | 121 ++++++++++++++++++++++++++++++++++++ reactos/include/float.h | 12 ++-- reactos/include/io.h | 12 ++-- reactos/include/libc/file.h | 14 ++--- reactos/include/libc/ieee.h | 46 ++++++++++++++ reactos/include/process.h | 7 ++- reactos/include/signal.h | 116 ++++++++++++++++++++++++++++------ reactos/include/stdio.h | 26 +++++--- 9 files changed, 327 insertions(+), 73 deletions(-) create mode 100644 reactos/include/excpt.h create mode 100644 reactos/include/libc/ieee.h diff --git a/reactos/include/ctype.h b/reactos/include/ctype.h index 3f3e10001c8..869d52290f4 100644 --- a/reactos/include/ctype.h +++ b/reactos/include/ctype.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: ariadne $ - * $Date: 1999/02/21 17:43:45 $ + * $Date: 1999/03/07 13:35:10 $ * */ #ifndef _LINUX_CTYPE_H @@ -50,6 +50,10 @@ #define _ALPHA 0x0103 +// additionally defined +#define _PRINT 0x0200 +#define _GRAPH 0x0400 + #ifdef __cplusplus extern "C" { @@ -68,7 +72,7 @@ int isupper(int c); int isxdigit(int c); #ifndef __STRICT_ANSI__ -int _isctype (int c, int ctypeFlags); +int _isctype (unsigned char c, int ctypeFlags); #endif int tolower(int c); @@ -99,20 +103,20 @@ int _toupper(int c); typedef int wctype_t; /* Wide character equivalents */ -int iswalnum(wint_t wc); -int iswalpha(wint_t wc); -int iswascii(wint_t wc); -int iswcntrl(wint_t wc); -int iswctype(wint_t wc, wctype_t wctypeFlags); -int is_wctype(wint_t wc, wctype_t wctypeFlags); /* Obsolete! */ -int iswdigit(wint_t wc); -int iswgraph(wint_t wc); -int iswlower(wint_t wc); -int iswprint(wint_t wc); -int iswpunct(wint_t wc); -int iswspace(wint_t wc); -int iswupper(wint_t wc); -int iswxdigit(wint_t wc); +int iswalnum(int wc); +int iswalpha(int wc); +int iswascii(int wc); +int iswcntrl(int wc); +int iswctype(unsigned short wc, int wctypeFlags); +int is_wctype(unsigned short wc, int wctypeFlags); /* Obsolete! */ +int iswdigit(int wc); +int iswgraph(int wc); +int iswlower(int wc); +int iswprint(int wc); +int iswpunct(int wc); +int iswspace(int wc); +int iswupper(int wc); +int iswxdigit(int wc); wchar_t towlower(wchar_t c); wchar_t towupper(wchar_t c); @@ -126,10 +130,10 @@ int __iscsymf (int c); /* Valid first character in C symbol */ int __iscsym (int c); /* Valid character in C symbol (after first) */ #ifndef _NO_OLDNAMES -int isascii (int c); -int toascii (int c); -int iscsymf (int c); -int iscsym (int c); +#define isascii(c) (!((c)&(~0x7f))) +#define toascii(c) ((unsigned)(c) &0x7F) +#define iscsymf(c) (isalpha(c) || ( c == '_' )) +#define iscsym(c) (isalnum(c) || ( c == '_' )) #endif /* Not _NO_OLDNAMES */ #endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/excpt.h b/reactos/include/excpt.h new file mode 100644 index 00000000000..17e0bce9f77 --- /dev/null +++ b/reactos/include/excpt.h @@ -0,0 +1,121 @@ +/* + * excpt.h + * + * Support for operating system level structured exception handling. + * + * NOTE: This is very preliminary stuff. I am also pretty sure it is + * completely Intel specific. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Based on code by Mikey + * + * 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.1 $ + * $Author: ariadne $ + * $Date: 1999/03/07 13:35:10 $ + * + */ + +#ifndef _EXCPT_H_ +#define _EXCPT_H_ + +#ifndef __STRICT_ANSI__ + +#include + +/* + * NOTE: The constants structs and typedefs below should be defined in the + * Win32 API headers. + */ +#define EH_NONCONTINUABLE 0x01 +#define EH_UNWINDING 0x02 +#define EH_EXIT_UNWIND 0x04 +#define EH_STACK_INVALID 0x08 +#define EH_NESTED_CALL 0x10 + +#ifndef RC_INVOKED + +typedef enum { + ExceptionContinueExecution, + ExceptionContinueSearch, + ExceptionNestedException, + ExceptionCollidedUnwind +} EXCEPTION_DISPOSITION; + + +/* + * End of stuff that should be in the Win32 API files. + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The type of function that is expected as an exception handler to be + * installed with _try1. + */ +typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER) + (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); + +/* + * This is not entirely necessary, but it is the structure installed by + * the _try1 primitive below. + */ +typedef struct _EXCEPTION_REGISTRATION +{ + struct _EXCEPTION_REGISTRATION* prev; + PEXCEPTION_HANDLER handler; +} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION; + +typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD; +typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD; + +/* + * A macro which installs the supplied exception handler. + * Push the pointer to the new handler onto the stack, + * then push the pointer to the old registration structure (at fs:0) + * onto the stack, then put a pointer to the new registration + * structure (i.e. the current stack pointer) at fs:0. + */ +#define __try1(pHandler) \ + __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler)); + + +/* + * A macro which (dispite its name) *removes* an installed + * exception handler. Should be used only in conjunction with the above + * install routine __try1. + * Move the pointer to the old reg. struct (at the current stack + * position) to fs:0, replacing the pointer we installed above, + * then add 8 to the stack pointer to get rid of the space we + * used when we pushed on our new reg. struct above. Notice that + * the stack must be in the exact state at this point that it was + * after we did _try1 or this will smash things. + */ +#define __except1 \ + __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \ + : : : "%eax"); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not strict ANSI */ + +#endif /* _EXCPT_H_ not defined */ diff --git a/reactos/include/float.h b/reactos/include/float.h index 22f285dad79..f4ffc88d4b7 100644 --- a/reactos/include/float.h +++ b/reactos/include/float.h @@ -27,9 +27,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Date: 1999/03/07 13:35:10 $ * */ @@ -146,15 +146,15 @@ unsigned int _controlfp (unsigned int unNew, unsigned int unMask); unsigned int _control87 (unsigned int unNew, unsigned int unMask); -unsigned int _clearfp (); /* Clear the FPU status word */ -unsigned int _statusfp (); /* Report the FPU status word */ +unsigned int _clearfp (void); /* Clear the FPU status word */ +unsigned int _statusfp (void); /* Report the FPU status word */ #define _clear87 _clearfp #define _status87 _statusfp -void _fpreset (); /* Reset the FPU */ +void _fpreset (void); /* Reset the FPU */ /* Global 'variable' for the current floating point error code. */ -int * __fpecode(); +int * __fpecode(void); #define _fpecode (*(__fpecode())) /* diff --git a/reactos/include/io.h b/reactos/include/io.h index 888a13e9b35..bf47939ae09 100644 --- a/reactos/include/io.h +++ b/reactos/include/io.h @@ -18,14 +18,15 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * $Author: ariadne $ - * $Date: 1999/02/25 22:51:47 $ + * $Date: 1999/03/07 13:35:10 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ /* added D_OK */ /* changed get_osfhandle and open_osfhandle */ +/* added fileno as macro */ #ifndef _IO_H_ #define _IO_H_ @@ -67,6 +68,7 @@ extern "C" { int _access (const char* szFileName, int nAccessMode); int _chsize (int nHandle, long lnNewSize); int _close (int nHandle); +int _commit(int _fd); int _creat (const char* szFileName, int nAccessMode); int _dup (int nHandle); int _dup2 (int nOldHandle, int nNewHandle); @@ -115,13 +117,13 @@ size_t _write(int _fd, const void *_buf, size_t _nbyte); #define dup2 _dup2 #define eof _eof #define filelength _filelength -#define fileno _fileno +#define fileno(f) ((f)->_file) #define isatty _isatty #define lseek _lseek #define open _open #define read _read -#define sopen _sopen -#define tell _tell +#define sopen(path,access,shflag,mode) _open((path), (access)|(shflag), (mode)) +#define tell(file) _lseek(_file, 0, SEEK_CUR) #define umask _umask #define unlink _unlink #define write _write diff --git a/reactos/include/libc/file.h b/reactos/include/libc/file.h index 36804540cf2..0a398ff8bc0 100644 --- a/reactos/include/libc/file.h +++ b/reactos/include/libc/file.h @@ -7,8 +7,6 @@ #include -//#include - #ifdef __cplusplus extern "C" { #endif @@ -36,21 +34,19 @@ void _fwalk(void (*)(FILE *)); char __is_text_file(FILE *p); +int __fileno_alloc(void *hFile, int mode); + int _doprnt(const char *fmt, va_list args, FILE *f); int _dowprnt(const char *fmt, va_list args, FILE *f); int _doscan(FILE *iop, const char *fmt, void **argp); +int _dowscan(FILE *iop, const wchar_t *fmt, void **argp); + -void *filehnd(int fileno); int __fileno_dup2( int handle1, int handle2 ); int __fileno_setmode(int _fd, int _newmode); int __fileno_close(int _fd); -#undef fileno -#define fileno(f) (f->_file) -#undef feof -#define feof(f) (((f)->_flag&_IOEOF)!=0) -#undef ferror -#define ferror(f) (((f)->_flag&_IOERR)!=0) + #endif /* !_POSIX_SOURCE */ #endif /* !__STRICT_ANSI__ */ diff --git a/reactos/include/libc/ieee.h b/reactos/include/libc/ieee.h new file mode 100644 index 00000000000..f501b4f2613 --- /dev/null +++ b/reactos/include/libc/ieee.h @@ -0,0 +1,46 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_ieee_h__ +#define __dj_include_libc_ieee_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +typedef struct { + unsigned mantissa:23; + unsigned exponent:8; + unsigned sign:1; +} float_t; + +typedef struct { + unsigned mantissal:32; + unsigned mantissah:20; + unsigned exponent:11; + unsigned sign:1; +} double_t; + +typedef struct { + unsigned mantissal:32; + unsigned mantissah:32; + unsigned exponent:15; + unsigned sign:1; +} long_double_t; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_ieee_h__ */ diff --git a/reactos/include/process.h b/reactos/include/process.h index 6fb5364abbf..b554851bb81 100644 --- a/reactos/include/process.h +++ b/reactos/include/process.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * $Author: ariadne $ - * $Date: 1999/02/21 13:29:56 $ + * $Date: 1999/03/07 13:35:10 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ @@ -120,6 +120,9 @@ void _endthreadex (unsigned unExitCode); #endif +void *_loaddll (char *name); +int _unloaddll(void *handle); + #ifndef _NO_OLDNAMES #define cwait _cwait diff --git a/reactos/include/signal.h b/reactos/include/signal.h index 34fa46f0df2..17f9b0f388f 100644 --- a/reactos/include/signal.h +++ b/reactos/include/signal.h @@ -1,35 +1,111 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#ifndef __dj_include_signal_h_ -#define __dj_include_signal_h_ +/* + * signal.h + * + * A way to set handlers for exceptional conditions (also known as signals). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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: ariadne $ + * $Date: 1999/03/07 13:35:10 $ + * + */ +/* added some extra signal constants */ +#ifndef _SIGNAL_H_ +#define _SIGNAL_H_ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif +/* + * The prototypes (below) are the easy part. The hard part is figuring + * out what signals are available and what numbers they are assigned + * along with appropriate values of SIG_DFL and SIG_IGN. + */ -/* 256 software interrupts + 32 exceptions = 288 */ +/* + * A pointer to a signal handler function. A signal handler takes a + * single int, which is the signal it handles. + */ +typedef void (*_p_sig_fn_t)(int nSig); -#define SIGABRT 288 -#define SIGFPE 289 -#define SIGILL 290 -#define SIGSEGV 291 -#define SIGTERM 292 -#define SIGINT 295 +/* + * These are special values of signal handler pointers which are + * used to send a signal to the default handler (SIG_DFL), ignore + * the signal (SIG_IGN), or indicate an error return (SIG_ERR). + */ +#define SIG_DFL ((_p_sig_fn_t) 0) +#define SIG_IGN ((_p_sig_fn_t) 1) +#define SIG_ERR ((_p_sig_fn_t) -1) -#define SIG_DFL ((void (*)(int))(0)) -#define SIG_ERR ((void (*)(int))(1)) -#define SIG_IGN ((void (*)(int))(-1)) +/* + * The actual signal values. Using other values with signal + * produces a SIG_ERR return value. + * + * NOTE: SIGINT is produced when the user presses Ctrl-C. + * SIGILL has not been tested. + * SIGFPE doesn't seem to work? + * SIGSEGV does not catch writing to a NULL pointer (that shuts down + * your app; can you say "segmentation violation core dump"?). + * SIGTERM comes from what kind of termination request exactly? + * SIGBREAK is indeed produced by pressing Ctrl-Break. + * SIGABRT is produced by calling abort. + * TODO: The above results may be related to not installing an appropriate + * structured exception handling frame. Results may be better if I ever + * manage to get the SEH stuff down. + */ +#define SIGINT 2 /* Interactive attention */ +#define SIGILL 4 /* Illegal instruction */ +#define SIGFPE 8 /* Floating point error */ +#define SIGSEGV 11 /* Segmentation violation */ +#define SIGTERM 15 /* Termination request */ +#define SIGBREAK 21 /* Control-break */ +#define SIGABRT 22 /* Abnormal termination (abort) */ +#define SIGALRM 293 +#define SIGHUP 294 +/* SIGINT is ansi */ +#define SIGKILL 296 +#define SIGPIPE 297 +#define SIGQUIT 298 +#define SIGUSR1 299 +#define SIGUSR2 300 -typedef int sig_atomic_t; +#define SIGNOFP 301 +#define SIGTRAP 302 +#define SIGTIMR 303 /* Internal for setitimer (SIGALRM, SIGPROF) */ +#define SIGPROF 304 +#define SIGMAX 320 -int raise(int _sig); -void (*signal(int _sig, void (*_func)(int)))(int); - +/* + * Call signal to set the signal handler for signal sig to the + * function pointed to by handler. Returns a pointer to the + * previous handler, or SIG_ERR if an error occurs. Initially + * unhandled signals defined above will return SIG_DFL. + */ +_p_sig_fn_t signal(int sig, _p_sig_fn_t func); +/* + * Raise the signal indicated by sig. Returns non-zero on success. + */ +int raise (int sig); -#ifdef __cplusplus +#ifdef __cplusplus } #endif -#endif /* !__dj_include_signal_h_ */ +#endif diff --git a/reactos/include/stdio.h b/reactos/include/stdio.h index 1fc69af068e..8947d762d65 100644 --- a/reactos/include/stdio.h +++ b/reactos/include/stdio.h @@ -22,13 +22,13 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * $Author: ariadne $ - * $Date: 1999/02/21 13:29:56 $ + * $Date: 1999/03/07 13:35:10 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ -/* modified _iob */ +/* implemented clearerr feof ferror perror as macros */ #ifndef _STDIO_H_ #define _STDIO_H_ @@ -90,7 +90,7 @@ typedef struct { * NOTE: These will go to the bit-bucket silently in GUI applications! */ extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */ -extern FILE _iob[]; /* An array of FILE */ +#define _iob (*__imp__iob) /* An array of FILE */ #define stdin (&_iob[0]) #define stdout (&_iob[1]) #define stderr (&_iob[2]) @@ -211,7 +211,7 @@ int sscanf (const char* szReadFrom, const char* szFormat, ...); /* Wide character versions */ int fwscanf (FILE* fileReadFrom, const wchar_t* wsFormat, ...); int wscanf (const wchar_t* wsFormat, ...); -int swscanf (wchar_t* wsReadFrom, const wchar_t* wsFormat, ...); +int swscanf (const wchar_t* wsReadFrom, const wchar_t* wsFormat, ...); /* * Character Input and Output Functions @@ -222,7 +222,7 @@ char* fgets (char* caBuffer, int nBufferSize, FILE* fileRead); int fputc (int c, FILE* fileWrite); int fputs (const char* szOutput, FILE* fileWrite); int getc (FILE* fileRead); -//int getchar (); +int getchar (void); char* gets (char* caBuffer); /* Unsafe: how does gets know how long the * buffer is? */ int putc (int c, FILE* fileWrite); @@ -301,12 +301,18 @@ int fsetpos (FILE* fileSetPosition, fpos_t* pfpos); /* * Error Functions */ - +#if 0 void clearerr (FILE* fileClearErrors); int feof (FILE* fileIsAtEnd); int ferror (FILE* fileIsError); void perror (const char* szErrorMessage); +#endif + +#define clearerr(f) (((f)->_flag) &= ~(_IOERR|_IOEOF)) +#define feof(f) (((f)->_flag&_IOEOF)!=0) +#define ferror(f) (((f)->_flag&_IOERR)!=0) +#define perror(s) (fprintf(stderr, "%s: %s\n", (s), _strerror(NULL))) /* * Non ANSI functions */ @@ -317,9 +323,9 @@ int _fputchar (int c); FILE* _fdopen (int nHandle, char* szMode); #ifndef _NO_OLDNAMES -//int fgetchar (); -int fputchar (int c); -FILE* fdopen (int nHandle, char* szMode); +#define fgetchar _fgetchar +#define fputchar _fputchar +#define fdopen _fdopen #endif /* Not _NO_OLDNAMES */ #endif /* Not __STRICT_ANSI__ */