From 0645d3e0558c4af157a1e385c3c9390ca9d56cae Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Wed, 16 Feb 2005 22:29:16 +0000 Subject: [PATCH] ntdll: -critical.c: catch (more) invalid use -impl. sscanf (stolen from wine) crt: -use native mingw headers and not private copies of them -converted some routines to using tchar == impl. many missing unicode routines -impl. sscanf and friends correctly (stolen from wine) tchar.h: -added lotsa missin stuff svn path=/trunk/; revision=13607 --- reactos/lib/crt/include/internal/atexit.h | 14 ++ reactos/lib/crt/include/internal/console.h | 12 ++ reactos/lib/crt/include/internal/file.h | 190 ++++++++++++++++++ reactos/lib/crt/include/internal/ieee.h | 25 +++ reactos/lib/crt/include/internal/math.h | 10 + reactos/lib/crt/include/internal/mbstring.h | 20 ++ reactos/lib/crt/include/internal/msvcrtdbg.h | 90 +++++++++ reactos/lib/crt/include/internal/mtdll.h | 72 +++++++ reactos/lib/crt/include/internal/rterror.h | 31 +++ reactos/lib/crt/include/internal/tls.h | 42 ++++ .../lib/crt/include/internal/wine/cppexcept.h | 124 ++++++++++++ reactos/lib/crt/include/internal/wine/eh.h | 53 +++++ .../lib/crt/include/internal/wine/msvcrt.h | 128 ++++++++++++ 13 files changed, 811 insertions(+) create mode 100644 reactos/lib/crt/include/internal/atexit.h create mode 100644 reactos/lib/crt/include/internal/console.h create mode 100644 reactos/lib/crt/include/internal/file.h create mode 100644 reactos/lib/crt/include/internal/ieee.h create mode 100644 reactos/lib/crt/include/internal/math.h create mode 100644 reactos/lib/crt/include/internal/mbstring.h create mode 100644 reactos/lib/crt/include/internal/msvcrtdbg.h create mode 100644 reactos/lib/crt/include/internal/mtdll.h create mode 100644 reactos/lib/crt/include/internal/rterror.h create mode 100644 reactos/lib/crt/include/internal/tls.h create mode 100644 reactos/lib/crt/include/internal/wine/cppexcept.h create mode 100644 reactos/lib/crt/include/internal/wine/eh.h create mode 100644 reactos/lib/crt/include/internal/wine/msvcrt.h diff --git a/reactos/lib/crt/include/internal/atexit.h b/reactos/lib/crt/include/internal/atexit.h new file mode 100644 index 00000000000..ab036e60710 --- /dev/null +++ b/reactos/lib/crt/include/internal/atexit.h @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __CRT_INTERNAL_ATEXIT_H +#define __CRT_INTERNAL_ATEXIT_H + + +struct __atexit { + struct __atexit* __next; + void (*__function)(void); +}; + +extern struct __atexit* __atexit_ptr; + + +#endif diff --git a/reactos/lib/crt/include/internal/console.h b/reactos/lib/crt/include/internal/console.h new file mode 100644 index 00000000000..c478c21aa68 --- /dev/null +++ b/reactos/lib/crt/include/internal/console.h @@ -0,0 +1,12 @@ +/* console.h */ + +#ifndef __CRT_INTERNAL_CONSOLE_H +#define __CRT_INTERNAL_CONSOLE_H + +extern int char_avail; +extern int ungot_char; + +#endif + +/* EOF */ + diff --git a/reactos/lib/crt/include/internal/file.h b/reactos/lib/crt/include/internal/file.h new file mode 100644 index 00000000000..4c781aa491a --- /dev/null +++ b/reactos/lib/crt/include/internal/file.h @@ -0,0 +1,190 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * Some stuff taken from active perl: perl\win32.c (ioinfo stuff) + * + * (c) 1995 Microsoft Corporation. All rights reserved. + * Developed by hip communications inc., http://info.hip.com/info/ + * Portions (c) 1993 Intergraph Corporation. All rights reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + */ + +#ifndef __CRT_INTERNAL_FILE_H +#define __CRT_INTERNAL_FILE_H + +#include +#include +#include + + +#ifndef _IORMONCL +#define _IORMONCL 004000 /* remove on close, for temp files */ +#endif +/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ + +#ifndef _IOUNGETC +#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */ +#endif + +/* might need check for IO_APPEND aswell */ +#define OPEN4WRITING(f) ((((f)->_flag & _IOWRT) == _IOWRT)) +#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD)) + +/* might need check for IO_APPEND aswell */ +#define WRITE_STREAM(f) ((((f)->_flag & _IOWRT) == _IOWRT)) +#define READ_STREAM(f) ((((f)->_flag & _IOREAD) == _IOREAD)) + +char __validfp(FILE*); +int __set_errno(int err); +int __set_doserrno(int error); +void* filehnd(int fn); +char __is_text_file(FILE*); +int alloc_fd(void* hFile, char mode); +int _doprnt(const char* fmt, va_list args, FILE *); +int _doscan(FILE* iop, const char* fmt, va_list argp); +int __fileno_dup2(int handle1, int handle2); +char __fileno_getmode(int _fd); +int __fileno_setmode(int _fd, int _newmode); +void free_fd(int _fd); +void sigabort_handler(int sig); +char split_oflags(int oflags); + + +#include + +unsigned create_io_inherit_block(STARTUPINFOA* si); +void UnixTimeToFileTime(time_t unix_time, FILETIME* filetime, DWORD remainder); +time_t FileTimeToUnixTime(const FILETIME* filetime, DWORD *remainder); + + +#define __FILE_REC_MAX 20 +typedef struct __file_rec +{ + struct __file_rec* next; + int count; + FILE* files[__FILE_REC_MAX]; +} __file_rec; + +extern __file_rec* __file_rec_list; + + +typedef struct _FDINFO +{ + HANDLE hFile; + char fdflags; + char pipechar; /* one char buffer for handles opened on pipes */ + int lockinitflag; + CRITICAL_SECTION lock; +} FDINFO; + +#define FDINFO_ENTRIES_PER_BUCKET_SHIFT 5 /* log2(32) = 5 */ +#define FDINFO_BUCKETS 64 +#define FDINFO_ENTRIES_PER_BUCKET 32 +#define FDINFO_ENTRIES (FDINFO_BUCKETS * FDINFO_ENTRIES_PER_BUCKET) + +/* pipech */ +#define LF 10 /* line feed */ +#define CR 13 /* carriage return */ +#define CTRLZ 26 /* ctrl-z means eof for text */ + +/* mode */ +#define FOPEN 0x01 /* file handle open */ +#define FEOFLAG 0x02 /* end of file has been encountered */ +#define FCRLF 0x04 /* CR-LF across read buffer (in text mode) */ +#define FPIPE 0x08 /* file refers to a pipe */ +#define FNOINHERIT 0x10 /* file handle opened _O_NOINHERIT */ +#define FAPPEND 0x20 /* file opened O_APPEND */ +#define FDEV 0x40 /* file refers to device */ +#define FTEXT 0x80 /* file is in text mode (absence = binary) */ + +/* get bucket index (0-63) from an fd */ +#define fdinfo_bucket_idx(i) ((i) >> FDINFO_ENTRIES_PER_BUCKET_SHIFT) +/* get position inside a bucket (0-31) from an fd */ +#define fdinfo_bucket_entry_idx(i) ((i) & (FDINFO_ENTRIES_PER_BUCKET - 1)) +/* get bucket ptr. (ptr. to fist fdinfo inside a bucket) from an fd */ +#define fdinfo_bucket(i) ( __pioinfo[fdinfo_bucket_idx(i)]) +/* get fdinfo ptr. from an fd */ +#define fdinfo(i) (fdinfo_bucket(i) + fdinfo_bucket_entry_idx(i)) + +extern FDINFO* __pioinfo[]; + + +void _dosmaperr(unsigned long oserrcode); + + + +FILE* __alloc_file(void); + + + +int access_dirA(const char *_path); +int access_dirW(const wchar_t *_path); + +#ifdef _UNICODE + #define access_dirT access_dirW +#else + #define access_dirT access_dirA +#endif + + + +void _fwalk(void (*func)(FILE*)); // not exported + + + +#undef MB_CUR_MAX +#define MB_CUR_MAX __mb_cur_max + + +int _isnanl(double x); +int _isinfl(double x); +int _isnan(double x); +int _isinf(double x); + + + +/* Flags for the iobuf structure (for reference) */ +#if 0 +#define _IOREAD 1 /* currently reading */ +#define _IOWRT 2 /* currently writing */ +#define _IORW 0x0080 /* opened as "r+w" */ +#endif + +/* internal FILE->_flag flags */ + +#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */ +#define _IOEOF 0x0010 /* EOF reached on read */ +#define _IOERR 0x0020 /* I/O error from system */ +#define _IOSTRG 0x0040 /* Strange or no file descriptor */ + +#define _IOBINARY 0x040000 +#define _IOTEXT 0x000000 + +#define _IOCOMMIT 0x100000 + +#define _IODIRTY 0x010000 +#define _IOAHEAD 0x020000 + + + + +/* + * The three possible buffering mode (nMode) values for setvbuf. + * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered... + * maybe I'm testing it wrong? + */ +#define _IOFBF 0x0000 /* full buffered */ +#define _IOLBF 0x0040 /* line buffered */ +#define _IONBF 0x0004 /* not buffered */ + +#define _IO_LBF 0x80000 /* this value is used insteat of _IOLBF within the + structure FILE as value for _flags, + because _IOLBF has the same value as _IOSTRG */ + + +wint_t _filwbuf(FILE *f); + + + +#endif /* __dj_include_libc_file_h__ */ diff --git a/reactos/lib/crt/include/internal/ieee.h b/reactos/lib/crt/include/internal/ieee.h new file mode 100644 index 00000000000..f397723feae --- /dev/null +++ b/reactos/lib/crt/include/internal/ieee.h @@ -0,0 +1,25 @@ +#ifndef __CRT_INTERNAL_IEEE_H +#define __CRT_INTERNAL_IEEE_H + +typedef struct { + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int sign:1; +} float_t; + +typedef struct { + unsigned int mantissal:32; + unsigned int mantissah:20; + unsigned int exponent:11; + unsigned int sign:1; +} double_t; + +typedef struct { + unsigned int mantissal:32; + unsigned int mantissah:32; + unsigned int exponent:15; + unsigned int sign:1; + unsigned int empty:16; +} long_double_t; + +#endif diff --git a/reactos/lib/crt/include/internal/math.h b/reactos/lib/crt/include/internal/math.h new file mode 100644 index 00000000000..1102524059a --- /dev/null +++ b/reactos/lib/crt/include/internal/math.h @@ -0,0 +1,10 @@ + +#ifndef __CRT_INTERNAL_MATH_H +#define __CRT_INTERNAL_MATH_H + + +int _isinf (double); /* not exported */ +int _isnanl (long double); /* not exported */ +int _isinfl (long double); /* not exported */ + +#endif diff --git a/reactos/lib/crt/include/internal/mbstring.h b/reactos/lib/crt/include/internal/mbstring.h new file mode 100644 index 00000000000..f5f167d639e --- /dev/null +++ b/reactos/lib/crt/include/internal/mbstring.h @@ -0,0 +1,20 @@ +#ifndef __CRT_INTERNAL_MBSTRING_H +#define __CRT_INTERNAL_MBSTRING_H + +#define _KNJ_M ((char)0x01) /* Non-punctuation of Kana-set */ +#define _KNJ_P ((char)0x02) /* Punctuation of Kana-set */ +#define _KNJ_1 ((char)0x04) /* Legal 1st byte of double byte stream */ +#define _KNJ_2 ((char)0x08) /* Legal 2nd btye of double byte stream */ + + +#define ___ 0 +#define _1_ _KNJ_1 /* Legal 1st byte of double byte code */ +#define __2 _KNJ_2 /* Legal 2nd byte of double byte code */ +#define _M_ _KNJ_M /* Non-puntuation in Kana-set */ +#define _P_ _KNJ_P /* Punctuation of Kana-set */ +#define _12 (_1_|__2) +#define _M2 (_M_|__2) +#define _P2 (_P_|__2) + + +#endif diff --git a/reactos/lib/crt/include/internal/msvcrtdbg.h b/reactos/lib/crt/include/internal/msvcrtdbg.h new file mode 100644 index 00000000000..a2b730f02c7 --- /dev/null +++ b/reactos/lib/crt/include/internal/msvcrtdbg.h @@ -0,0 +1,90 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: include/msvcrt/msvcrtdbg.h + * PURPOSE: Useful debugging macros + * PROGRAMMER: + * UPDATE HISTORY: + * + */ + +/* + * NOTE: Define NDEBUG before including this header to disable debugging + * macros + */ + +#ifndef __MSVCRT_DEBUG +#define __MSVCRT_DEBUG + +#include +#include + + +#define MK_STR(s) #s + +#ifdef _UNICODE + #define sT "S" +#else + #define sT "s" +#endif + + + +#define TRACE(...) + + +#ifdef DBG + #define DPRINT1(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); + #define CHECKPOINT1 do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0); +#else + #ifdef __GNUC__ + #define DPRINT1(args...) + #else + #define DPRINT DbgPrint + #endif + #define CHECKPOINT1 +#endif + +#if !defined(NDEBUG) && defined(DBG) + #define DPRINT(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); + #define CHECKPOINT do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0); +#else + #ifdef __GNUC__ + #define DPRINT(args...) + #else + #define DPRINT DbgPrint + #endif + #define CHECKPOINT +#endif /* NDEBUG */ + + +#if 0 + + #define TRACE_RETURN(format_str, ret_type) \ + ret_type __return_value__; \ + static char* __return_format_str__ = "%s ret: "format_str"\n" + + #define FUNCTION(func) \ + static char* __func_name__ = #func + + #define TRACE(a,b...) DPRINT1(a"\n", b) + + #define RETURN(a) \ + do{ __return_value__ = (a); DPRINT1(__return_format_str__ ,__func_name__,__return_value__); return __return_value__ ; }while(0) + +#endif + + +/* ULONG CDECL DbgPrint(PCH Format, ...); */ +ULONG DbgPrint(PCH Format,...); +/* unsigned long DbgPrint(const char* Format, ...); */ + + + +/* #define TRACE 0 ? (void)0 : Trace */ + +/* void Trace(TCHAR* lpszFormat, ...); */ + + + +#endif /* __MSVCRT_DEBUG */ diff --git a/reactos/lib/crt/include/internal/mtdll.h b/reactos/lib/crt/include/internal/mtdll.h new file mode 100644 index 00000000000..40dbdae96b3 --- /dev/null +++ b/reactos/lib/crt/include/internal/mtdll.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2002, TransGaming Technologies Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __CRT_INTERNAL_WINE_MTDLL_H +#define __CRT_INTERNAL_WINE_MTDLL_H + +#if defined(_MT) + +#define _mlock(locknum) _lock(locknum) +#define _munlock(locknum) _unlock(locknum) + +void _unlock( int locknum ); +void _lock( int locknum ); + +#else + +#define _mlock(locknum) do {} while(0) +#define _munlock(locknum) do {} while(0) + +#endif + + +#define _SIGNAL_LOCK 1 +#define _IOB_SCAN_LOCK 2 +#define _TMPNAM_LOCK 3 +#define _INPUT_LOCK 4 +#define _OUTPUT_LOCK 5 +#define _CSCANF_LOCK 6 +#define _CPRINTF_LOCK 7 +#define _CONIO_LOCK 8 +#define _HEAP_LOCK 9 +#define _BHEAP_LOCK 10 /* No longer used? */ +#define _TIME_LOCK 11 +#define _ENV_LOCK 12 +#define _EXIT_LOCK1 13 +#define _EXIT_LOCK2 14 +#define _THREADDATA_LOCK 15 /* No longer used? */ +#define _POPEN_LOCK 16 +#define _LOCKTAB_LOCK 17 +#define _OSFHND_LOCK 18 +#define _SETLOCALE_LOCK 19 +#define _LC_COLLATE_LOCK 20 /* No longer used? */ +#define _LC_CTYPE_LOCK 21 /* No longer used? */ +#define _LC_MONETARY_LOCK 22 /* No longer used? */ +#define _LC_NUMERIC_LOCK 23 /* No longer used? */ +#define _LC_TIME_LOCK 24 /* No longer used? */ +#define _MB_CP_LOCK 25 +#define _NLG_LOCK 26 +#define _TYPEINFO_LOCK 27 +#define _STREAM_LOCKS 28 + +/* Must match definition in msvcrt/stdio.h */ +#define _IOB_ENTRIES 20 +#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_IOB_ENTRIES-1) +#define _TOTAL_LOCKS (_LAST_STREAM_LOCK+1) + +#endif /* WINE_MTDLL_H */ diff --git a/reactos/lib/crt/include/internal/rterror.h b/reactos/lib/crt/include/internal/rterror.h new file mode 100644 index 00000000000..b76698b78c5 --- /dev/null +++ b/reactos/lib/crt/include/internal/rterror.h @@ -0,0 +1,31 @@ +/* rterror.h */ + +#ifndef __CRT_INTERNAL_RTERROR_H +#define __CRT_INTERNAL_RTERROR_H + + +#define _RT_STACK 0 /* stack overflow */ +#define _RT_NULLPTR 1 /* null pointer assignment */ +#define _RT_FLOAT 2 /* floating point not loaded */ +#define _RT_INTDIV 3 /* integer divide by 0 */ +#define _RT_SPACEARG 4 /* not enough space for arguments */ +#define _RT_SPACEENV 5 /* not enough space for environment */ +#define _RT_ABORT 6 /* abnormal program termination */ +#define _RT_THREAD 7 /* not enough space for thread data */ +#define _RT_LOCK 8 /* unexpected multi-thread lock error */ +#define _RT_HEAP 9 /* unexpected heap error */ +#define _RT_OPENCON 10 /* unable to open console device */ +#define _RT_NONCONT 11 /* non-continuable exception */ +#define _RT_INVALDISP 12 /* invalid disposition of exception */ +#define _RT_ONEXIT 13 /* insufficient heap to allocate + * initial table of function pointers + * used by _onexit()/atexit(). */ +#define _RT_PUREVIRT 14 /* pure virtual function call attempted + * (C++ error) */ +#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */ +#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */ + +void _amsg_exit (int errnum); + + +#endif /* __MSVCRT_INTERNAL_RTERROR_H */ diff --git a/reactos/lib/crt/include/internal/tls.h b/reactos/lib/crt/include/internal/tls.h new file mode 100644 index 00000000000..1bb029c72ed --- /dev/null +++ b/reactos/lib/crt/include/internal/tls.h @@ -0,0 +1,42 @@ +/* tls.h */ + +#ifndef __CRT_INTERNAL_TLS_H +#define __CRT_INTERNAL_TLS_H + +#include +#include +#include + +typedef struct _ThreadData +{ + int terrno; /* *nix error code */ + unsigned long tdoserrno; /* Win32 error code (for I/O only) */ + unsigned LONGLONG tnext; /* used by rand/srand */ + + char *lasttoken; /* used by strtok */ + wchar_t *wlasttoken; /* used by wcstok */ + + + int fpecode; /* fp exception code */ + + /* qsort variables */ + int (*qcmp)(const void *, const void *); /* the comparison routine */ + int qsz; /* size of each record */ + int thresh; /* THRESHold in chars */ + int mthresh; /* MTHRESHold in chars */ + + EXCEPTION_RECORD *exc_record; /* Head of exception record list */ + +} THREADDATA, *PTHREADDATA; + + +int CreateThreadData(void); +void DestroyThreadData(void); + +void FreeThreadData(PTHREADDATA ptd); +PTHREADDATA GetThreadData(void); + +#endif /* __MSVCRT_INTERNAL_TLS_H */ + +/* EOF */ + diff --git a/reactos/lib/crt/include/internal/wine/cppexcept.h b/reactos/lib/crt/include/internal/wine/cppexcept.h new file mode 100644 index 00000000000..3a822ed9ec0 --- /dev/null +++ b/reactos/lib/crt/include/internal/wine/cppexcept.h @@ -0,0 +1,124 @@ +/* + * msvcrt C++ exception handling + * + * Copyright 2002 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MSVCRT_CPPEXCEPT_H +#define __MSVCRT_CPPEXCEPT_H + +#define CXX_FRAME_MAGIC 0x19930520 +#define CXX_EXCEPTION 0xe06d7363 + +typedef void (*vtable_ptr)(); + +/* type_info object, see cpp.c for inplementation */ +typedef struct __type_info +{ + vtable_ptr *vtable; + char *name; /* Unmangled name, allocated lazily */ + char mangled[32]; /* Variable length, but we declare it large enough for static RTTI */ +} type_info; + +/* the exception frame used by CxxFrameHandler */ +typedef struct __cxx_exception_frame +{ + EXCEPTION_REGISTRATION_RECORD frame; /* the standard exception frame */ + int trylevel; + DWORD ebp; +} cxx_exception_frame; + +/* info about a single catch {} block */ +typedef struct __catchblock_info +{ + UINT flags; /* flags (see below) */ + type_info *type_info; /* C++ type caught by this block */ + int offset; /* stack offset to copy exception object to */ + void (*handler)(); /* catch block handler code */ +} catchblock_info; +#define TYPE_FLAG_CONST 1 +#define TYPE_FLAG_VOLATILE 2 +#define TYPE_FLAG_REFERENCE 8 + +/* info about a single try {} block */ +typedef struct __tryblock_info +{ + int start_level; /* start trylevel of that block */ + int end_level; /* end trylevel of that block */ + int catch_level; /* initial trylevel of the catch block */ + int catchblock_count; /* count of catch blocks in array */ + catchblock_info *catchblock; /* array of catch blocks */ +} tryblock_info; + +/* info about the unwind handler for a given trylevel */ +typedef struct __unwind_info +{ + int prev; /* prev trylevel unwind handler, to run after this one */ + void (*handler)(); /* unwind handler */ +} unwind_info; + +/* descriptor of all try blocks of a given function */ +typedef struct __cxx_function_descr +{ + UINT magic; /* must be CXX_FRAME_MAGIC */ + UINT unwind_count; /* number of unwind handlers */ + unwind_info *unwind_table; /* array of unwind handlers */ + UINT tryblock_count; /* number of try blocks */ + tryblock_info *tryblock; /* array of try blocks */ + UINT unknown[3]; +} cxx_function_descr; + +typedef void (*cxx_copy_ctor)(void); + +/* complete information about a C++ type */ +typedef struct __cxx_type_info +{ + UINT flags; /* flags (see CLASS_* flags below) */ + type_info *type_info; /* C++ type info */ + int this_offset; /* offset of base class this pointer from start of object */ + int vbase_descr; /* offset of virtual base class descriptor */ + int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */ + size_t size; /* object size */ + cxx_copy_ctor copy_ctor; /* copy constructor */ +} cxx_type_info; +#define CLASS_IS_SIMPLE_TYPE 1 +#define CLASS_HAS_VIRTUAL_BASE_CLASS 4 + +/* table of C++ types that apply for a given object */ +typedef struct __cxx_type_info_table +{ + UINT count; /* number of types */ + const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */ +} cxx_type_info_table; + +typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*, + PCONTEXT, EXCEPTION_REGISTRATION_RECORD**, + cxx_function_descr*, int nested_trylevel, + EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 ); + +/* type information for an exception object */ +typedef struct __cxx_exception_type +{ + UINT flags; /* TYPE_FLAG flags */ + void (*destructor)(); /* exception object destructor */ + cxx_exc_custom_handler custom_handler; /* custom handler for this exception */ + const cxx_type_info_table *type_info_table; /* list of types for this exception object */ +} cxx_exception_type; + +void _CxxThrowException(void*,const cxx_exception_type*); + +#endif /* __MSVCRT_CPPEXCEPT_H */ diff --git a/reactos/lib/crt/include/internal/wine/eh.h b/reactos/lib/crt/include/internal/wine/eh.h new file mode 100644 index 00000000000..14201fb0676 --- /dev/null +++ b/reactos/lib/crt/include/internal/wine/eh.h @@ -0,0 +1,53 @@ +/* + * C++ exception handling facility + * + * Copyright 2000 Francois Gouget. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __WINE_EH_H +#define __WINE_EH_H +#ifndef __WINE_USE_MSVCRT +#define __WINE_USE_MSVCRT +#endif + +#if !defined(__cplusplus) && !defined(USE_MSVCRT_PREFIX) +#error "eh.h is meant only for C++ applications" +#endif + +#ifndef MSVCRT +# ifdef USE_MSVCRT_PREFIX +# define MSVCRT(x) MSVCRT_##x +# else +# define MSVCRT(x) x +# endif +#endif + +struct _EXCEPTION_POINTERS; + +typedef void (*terminate_handler)(); +typedef void (*terminate_function)(); +typedef void (*unexpected_handler)(); +typedef void (*unexpected_function)(); +typedef void (*_se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info); + +terminate_function MSVCRT(set_terminate)(terminate_function func); +unexpected_function MSVCRT(set_unexpected)(unexpected_function func); +_se_translator_function MSVCRT(_set_se_translator)(_se_translator_function func); + +void MSVCRT(terminate)(); +void MSVCRT(unexpected)(); + +#endif /* __WINE_EH_H */ diff --git a/reactos/lib/crt/include/internal/wine/msvcrt.h b/reactos/lib/crt/include/internal/wine/msvcrt.h new file mode 100644 index 00000000000..915dccbfabd --- /dev/null +++ b/reactos/lib/crt/include/internal/wine/msvcrt.h @@ -0,0 +1,128 @@ +/* + * Copyright 2001 Jon Griffiths + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __WINE_MSVCRT_H +#define __WINE_MSVCRT_H + +#include +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "winnls.h" + +//#include "msvcrt/string.h" +#include "eh.h" + +/* TLS data */ +extern DWORD MSVCRT_tls_index; + +typedef struct __MSVCRT_thread_data +{ + int _errno; // ros + unsigned long doserrno; + char *mbstok_next; /* next ptr for mbstok() */ + char *efcvt_buffer; /* buffer for ecvt/fcvt */ + terminate_function terminate_handler; + unexpected_function unexpected_handler; + _se_translator_function se_translator; + EXCEPTION_RECORD *exc_record; +} MSVCRT_thread_data; + +extern MSVCRT_thread_data *msvcrt_get_thread_data(void); + +extern int MSVCRT_current_lc_all_cp; + +void _purecall(void); +void MSVCRT__set_errno(int); +char* msvcrt_strndup(const char*,unsigned int); +#ifndef __REACTOS__ +MSVCRT_wchar_t *msvcrt_wstrndup(const MSVCRT_wchar_t*, unsigned int); +#endif +void MSVCRT__amsg_exit(int errnum); + +extern char **MSVCRT__environ; +#ifndef __REACTOS__ +extern MSVCRT_wchar_t **MSVCRT__wenviron; +extern char ** msvcrt_SnapshotOfEnvironmentA(char **); +extern MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **); +#endif + +/* FIXME: This should be declared in new.h but it's not an extern "C" so + * it would not be much use anyway. Even for Winelib applications. + */ +int MSVCRT__set_new_mode(int mode); + +void* MSVCRT_operator_new(unsigned long size); +void MSVCRT_operator_delete(void*); +#ifndef __REACTOS__ +typedef void* (*MSVCRT_malloc_func)(MSVCRT_size_t); +#endif +typedef void (*MSVCRT_free_func)(void*); +#ifndef __REACTOS__ +extern char* MSVCRT___unDName(int,const char*,int,MSVCRT_malloc_func,MSVCRT_free_func,unsigned int); +#endif + +/* Setup and teardown multi threaded locks */ +extern void msvcrt_init_mt_locks(void); +extern void msvcrt_free_mt_locks(void); + +extern void msvcrt_init_io(void); +extern void msvcrt_free_io(void); +extern void msvcrt_init_console(void); +extern void msvcrt_free_console(void); +extern void msvcrt_init_args(void); +extern void msvcrt_free_args(void); + +/* run-time error codes */ +#define _RT_STACK 0 +#define _RT_NULLPTR 1 +#define _RT_FLOAT 2 +#define _RT_INTDIV 3 +#define _RT_EXECMEM 5 +#define _RT_EXECFORM 6 +#define _RT_EXECENV 7 +#define _RT_SPACEARG 8 +#define _RT_SPACEENV 9 +#define _RT_ABORT 10 +#define _RT_NPTR 12 +#define _RT_FPTR 13 +#define _RT_BREAK 14 +#define _RT_INT 15 +#define _RT_THREAD 16 +#define _RT_LOCK 17 +#define _RT_HEAP 18 +#define _RT_OPENCON 19 +#define _RT_QWIN 20 +#define _RT_NOMAIN 21 +#define _RT_NONCONT 22 +#define _RT_INVALDISP 23 +#define _RT_ONEXIT 24 +#define _RT_PUREVIRT 25 +#define _RT_STDIOINIT 26 +#define _RT_LOWIOINIT 27 +#define _RT_HEAPINIT 28 +#define _RT_DOMAIN 120 +#define _RT_SING 121 +#define _RT_TLOSS 122 +#define _RT_CRNL 252 +#define _RT_BANNER 255 + +#endif /* __WINE_MSVCRT_H */