From: KJK::Hyperion Date: Wed, 29 Oct 2008 20:06:44 +0000 (+0000) Subject: Merging r37048, r37051, r37052, r37055 from the-real-msvc branch X-Git-Tag: backups/the-real-msvc@60644~4^2~2 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=b4787f49df672ea432f67a628ee3dee1a0bf9621 Merging r37048, r37051, r37052, r37055 from the-real-msvc branch svn path=/trunk/; revision=37074 --- b4787f49df672ea432f67a628ee3dee1a0bf9621 diff --cc reactos/base/system/smss/smss.h index 23e3cd0a46a,00000000000..2db83d39ebb mode 100644,000000..100644 --- a/reactos/base/system/smss/smss.h +++ b/reactos/base/system/smss/smss.h @@@ -1,118 -1,0 +1,119 @@@ +#ifndef _SMSS_H_INCLUDED_ +#define _SMSS_H_INCLUDED_ + +#include ++#include +#define WIN32_NO_STATUS +#include +#define NTOS_MODE_USER +#include + +#include +#include + +/* smss.c */ +extern ULONG SmSsProcessId; + +/* init.c */ +NTSTATUS InitSessionManager(VOID); + +/* initheap.c */ +extern HANDLE SmpHeap; +NTSTATUS SmCreateHeap(VOID); + +/* initenv.c */ +extern PWSTR SmSystemEnvironment; +NTSTATUS SmCreateEnvironment(VOID); +NTSTATUS SmSetEnvironmentVariables(VOID); +NTSTATUS SmUpdateEnvironment(VOID); + +/* initobdir.c */ +NTSTATUS SmCreateObjectDirectories(VOID); + +/* initdosdev.c */ +NTSTATUS SmInitDosDevices(VOID); + +/* initrun.c */ +extern HANDLE Children[2]; +NTSTATUS SmRunBootApplications(VOID); + +/* initmv.c */ +NTSTATUS SmProcessFileRenameList(VOID); + +/* initwkdll.c */ +NTSTATUS SmLoadKnownDlls(VOID); + +/* initpage.c */ +NTSTATUS SmCreatePagingFiles(VOID); + +/* initreg.c */ +NTSTATUS SmInitializeRegistry(VOID); + +/* initss.c */ +NTSTATUS STDCALL SmRegisterInternalSubsystem(LPWSTR,USHORT,PHANDLE); +NTSTATUS SmLoadSubsystems(VOID); + +/* smapi.c */ +#define SMAPI(n) \ +NTSTATUS FASTCALL n (PSM_PORT_MESSAGE Request) +PSM_CONNECT_DATA FASTCALL SmpGetConnectData (PSM_PORT_MESSAGE); +NTSTATUS SmCreateApiPort(VOID); +VOID STDCALL SmpApiThread(PVOID); + + +/* smapiexec.c */ +#define SM_CREATE_FLAG_WAIT 0x01 +#define SM_CREATE_FLAG_RESERVE_1MB 0x02 +NTSTATUS STDCALL SmCreateUserProcess(LPWSTR ImagePath, + LPWSTR CommandLine, + ULONG Flags, + PLARGE_INTEGER Timeout OPTIONAL, + PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL); +NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE); + +/* smapicomp.c */ +NTSTATUS FASTCALL SmCompSes(PSM_PORT_MESSAGE); + +/* smapiquery.c */ +NTSTATUS FASTCALL SmQryInfo(PSM_PORT_MESSAGE); + +/* client.c */ +#define SM_CLIENT_FLAG_CANDIDATE 0x8000 +#define SM_CLIENT_FLAG_INITIALIZED 0x0001 +#define SM_CLIENT_FLAG_REQUIRED 0x0002 +typedef struct _SM_CLIENT_DATA +{ + RTL_CRITICAL_SECTION Lock; + WCHAR ProgramName [SM_SB_NAME_MAX_LENGTH]; + USHORT SubsystemId; + WORD Flags; + WORD Unused; + ULONG ServerProcessId; + HANDLE ServerProcess; + HANDLE ApiPort; + HANDLE ApiPortThread; + HANDLE SbApiPort; + WCHAR SbApiPortName [SM_SB_NAME_MAX_LENGTH]; + +} SM_CLIENT_DATA, *PSM_CLIENT_DATA; +NTSTATUS SmInitializeClientManagement (VOID); +NTSTATUS STDCALL SmCreateClient (PRTL_USER_PROCESS_INFORMATION,PWSTR); +NTSTATUS STDCALL SmDestroyClient (ULONG); +NTSTATUS STDCALL SmBeginClientInitialization (PSM_PORT_MESSAGE,PSM_CLIENT_DATA*); +NTSTATUS STDCALL SmCompleteClientInitialization (ULONG); +NTSTATUS FASTCALL SmGetClientBasicInformation (PSM_BASIC_INFORMATION); +NTSTATUS FASTCALL SmGetSubSystemInformation (PSM_SUBSYSTEM_INFORMATION); + +/* debug.c */ +extern HANDLE DbgSsApiPort; +extern HANDLE DbgUiApiPort; +NTSTATUS SmInitializeDbgSs(VOID); + +/* print.c */ +VOID STDCALL DisplayString(LPCWSTR lpwString); +VOID STDCALL PrintString (char* fmt, ...); + +#endif /* _SMSS_H_INCLUDED_ */ + +/* EOF */ + diff --cc reactos/drivers/bus/acpi/include/platform/acmsc.h index 00000000000,612edf938c2..612edf938c2 mode 000000,100644..100644 --- a/reactos/drivers/bus/acpi/include/platform/acmsc.h +++ b/reactos/drivers/bus/acpi/include/platform/acmsc.h diff --cc reactos/lib/3rdparty/mingw/crt1.c index a4fb015d1e4,00000000000..4f6b17c193e mode 100644,000000..100644 --- a/reactos/lib/3rdparty/mingw/crt1.c +++ b/reactos/lib/3rdparty/mingw/crt1.c @@@ -1,298 -1,0 +1,310 @@@ +/* + * crt1.c + * This file has no copyright assigned and is placed in the Public Domain. + * This file is a part of the mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER within the package. + * + * Source code for the startup proceedures used by all programs. This code + * is compiled to make crt1.o, which should be located in the library path. + * + */ + +/* Hide the declaration of _fmode with dllimport attribute in stdlib.h to + avoid problems with older GCC. */ +#define __IN_MINGW_RUNTIME +#include +#include +#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#include + +/* NOTE: The code for initializing the _argv, _argc, and environ variables + * has been moved to a separate .c file which is included in both + * crt1.c and dllcrt1.c. This means changes in the code don't have to + * be manually synchronized, but it does lead to this not-generally- + * a-good-idea use of include. */ +#include "init.c" +#include "cpu_features.h" + +extern void _pei386_runtime_relocator (void); + +extern int main (int, char **, char **); + +/* + * Must have the correct app type for MSVCRT. + */ + +#ifdef __MSVCRT__ +#define __UNKNOWN_APP 0 +#define __CONSOLE_APP 1 +#define __GUI_APP 2 +#ifndef _M_PPC +__MINGW_IMPORT +#endif +void __set_app_type(int); +#endif /* __MSVCRT__ */ + +/* Global _fmode for this .exe, not the one in msvcrt.dll, + The default is set in txtmode.o in libmingw32.a */ +/* Override the dllimport'd declarations in stdlib.h */ +#undef _fmode +extern int _fmode; +#ifdef __MSVCRT__ +extern int* __p__fmode(void); /* To access the dll _fmode */ +#endif + +/* + * Setup the default file handles to have the _CRT_fmode mode, as well as + * any new files created by the user. + */ +extern int _CRT_fmode; + +static void +_mingw32_init_fmode (void) +{ + /* Don't set the std file mode if the user hasn't set any value for it. */ + if (_CRT_fmode) + { + _fmode = _CRT_fmode; + + /* + * This overrides the default file mode settings for stdin, + * stdout and stderr. At first I thought you would have to + * test with isatty, but it seems that the DOS console at + * least is smart enough to handle _O_BINARY stdout and + * still display correctly. + */ + if (stdin) + { + _setmode (_fileno (stdin), _CRT_fmode); + } + if (stdout) + { + _setmode (_fileno (stdout), _CRT_fmode); + } + if (stderr) + { + _setmode (_fileno (stderr), _CRT_fmode); + } + } + + /* Now sync the dll _fmode to the one for this .exe. */ +#ifdef __MSVCRT__ + *__p__fmode() = _fmode; +#else + *_imp___fmode_dll = _fmode; +#endif +} + +/* This function will be called when a trap occurs. Thanks to Jacob + Navia for his contribution. */ +static LONG CALLBACK +_gnu_exception_handler (EXCEPTION_POINTERS * exception_data) +{ + void (*old_handler) (int); + LONG action = EXCEPTION_CONTINUE_SEARCH; + int reset_fpu = 0; + + switch (exception_data->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + /* test if the user has set SIGSEGV */ + old_handler = signal (SIGSEGV, SIG_DFL); + if (old_handler == SIG_IGN) + { + /* this is undefined if the signal was raised by anything other + than raise (). */ + signal (SIGSEGV, SIG_IGN); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGSEGV); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_PRIV_INSTRUCTION: + /* test if the user has set SIGILL */ + old_handler = signal (SIGILL, SIG_DFL); + if (old_handler == SIG_IGN) + { + /* this is undefined if the signal was raised by anything other + than raise (). */ + signal (SIGILL, SIG_IGN); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGILL); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + case EXCEPTION_FLT_INVALID_OPERATION: + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + case EXCEPTION_FLT_DENORMAL_OPERAND: + case EXCEPTION_FLT_OVERFLOW: + case EXCEPTION_FLT_UNDERFLOW: + case EXCEPTION_FLT_INEXACT_RESULT: + reset_fpu = 1; + /* fall through. */ + + case EXCEPTION_INT_DIVIDE_BY_ZERO: + /* test if the user has set SIGFPE */ + old_handler = signal (SIGFPE, SIG_DFL); + if (old_handler == SIG_IGN) + { + signal (SIGFPE, SIG_IGN); + if (reset_fpu) + _fpreset (); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGFPE); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + default: + break; + } + return action; +} + +/* + * The function mainCRTStartup is the entry point for all console programs. + */ +static void __attribute__((noreturn)) +__mingw_CRTStartup (void) +{ + int nRet; + + /* + * Set up the top-level exception handler so that signal handling + * works as expected. The mapping between ANSI/POSIX signals and + * Win32 SE is not 1-to-1, so caveat emptore. + * + */ + SetUnhandledExceptionFilter (_gnu_exception_handler); + + /* + * Initialize floating point unit. + */ + __cpu_features_init (); /* Do we have SSE, etc.*/ + _fpreset (); /* Supplied by the runtime library. */ + + /* + * Set up __argc, __argv and _environ. + */ + _mingw32_init_mainargs (); + + /* + * Sets the default file mode. + * If _CRT_fmode is set, also set mode for stdin, stdout + * and stderr, as well + * NOTE: DLLs don't do this because that would be rude! + */ + _mingw32_init_fmode (); + + /* Adust references to dllimported data that have non-zero offsets. */ +#if defined(__i386__) + _pei386_runtime_relocator (); +#endif + ++#if defined(__GNUC__) +#if defined(__i386__) + /* Align the stack to 16 bytes for the sake of SSE ops in main + or in functions inlined into main. */ + asm __volatile__ ("andl $-16, %%esp" : : : "%esp"); +#elif defined(__mips__) + /* Align the stack to 16 bytes */ + asm __volatile__ ("andi %sp,%sp,-16" : : : "%sp"); +#elif defined(__PowerPC__) + /* Align the stack to 16 bytes */ + asm __volatile__ ("li 0,15\n\tandc 1,1,0" : : : "r1"); +#else +#error Unsupported architecture ++#endif ++#elif defined(_MSC_VER) ++#if defined(_M_IX86) ++ /* Align the stack to 16 bytes for the sake of SSE ops in main ++ or in functions inlined into main. */ ++ __asm and esp, 0FFFFFFF0h ++#else ++#error TODO ++#endif ++#else ++#error TODO +#endif + + /* + * Call the main function. If the user does not supply one + * the one in the 'libmingw32.a' library will be linked in, and + * that one calls WinMain. See main.c in the 'lib' dir + * for more details. + */ + nRet = main (_argc, _argv, _environ); + + /* + * Perform exit processing for the C library. This means + * flushing output and calling 'atexit' registered functions. + */ + _cexit (); + + ExitProcess (nRet); +} + +/* + * The function mainCRTStartup is the entry point for all console programs. + */ +void +mainCRTStartup (void) +{ +#ifdef __MSVCRT__ + __set_app_type (__CONSOLE_APP); +#endif + __mingw_CRTStartup (); +} + +/* + * For now the GUI startup function is the same as the console one. + * This simply gets rid of the annoying warning about not being able + * to find WinMainCRTStartup when linking GUI applications. + */ +void +WinMainCRTStartup (void) +{ +#ifdef __MSVCRT__ + __set_app_type (__GUI_APP); +#endif + __mingw_CRTStartup (); +} + +#if 0 +/* + * We force use of library version of atexit, which is only + * visible in import lib as _imp__atexit + */ +extern int (*_imp__atexit)(void (*)(void)); +int atexit (void (* pfn )(void) ) +{ + return ( (*_imp__atexit)(pfn)); +} + +/* Likewise for non-ANSI _onexit */ +extern _onexit_t (*_imp___onexit)(_onexit_t); +_onexit_t +_onexit (_onexit_t pfn ) +{ + return (*_imp___onexit)(pfn); +} +#endif diff --cc reactos/lib/3rdparty/mingw/mingw.rbuild index c1dbef73be1,00000000000..c901f39f1aa mode 100644,000000..100644 --- a/reactos/lib/3rdparty/mingw/mingw.rbuild +++ b/reactos/lib/3rdparty/mingw/mingw.rbuild @@@ -1,41 -1,0 +1,38 @@@ + + + + + + include + cpu_features.c + CRTfmode.c + CRTglob.c + CRTinit.c + gccmain.c + getopt.c + isascii.c + iscsym.c + iscsymf.c - strcasecmp.c - strncasecmp.c + toascii.c - wcscmpi.c + _wgetopt.c + + pseudo-reloc.c + + + + include + binmode.c + crt1.c + main.c + + + include + wbinmode.c + wcrt1.c + wmain.c + + + include + dllcrt1.c + + diff --cc reactos/lib/rtl/debug.c index bfde2e0f2f3,00000000000..a17367fc39f mode 100644,000000..100644 --- a/reactos/lib/rtl/debug.c +++ b/reactos/lib/rtl/debug.c @@@ -1,365 -1,0 +1,372 @@@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Run-Time Library + * FILE: ntoskrnl/rtl/dbgprint.c + * PURPOSE: Debug Print and Prompt routines + * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) + * Royce Mitchel III + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +/* PRIVATE FUNCTIONS ********************************************************/ + +NTSTATUS +NTAPI +DebugPrint(IN PANSI_STRING DebugString, + IN ULONG ComponentId, + IN ULONG Level) +{ + /* Call the INT2D Service */ + return DebugService(BREAKPOINT_PRINT, + DebugString->Buffer, + DebugString->Length, + UlongToPtr(ComponentId), + UlongToPtr(Level)); +} + +NTSTATUS +NTAPI +DebugPrompt(IN PCSTRING Output, + IN PSTRING Input) +{ + /* Call the INT2D Service */ + return DebugService(BREAKPOINT_PROMPT, + Output->Buffer, + Output->Length, + Input->Buffer, + UlongToPtr(Input->MaximumLength)); +} + +/* FUNCTIONS ****************************************************************/ + +ULONG +NTAPI +vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix, + IN ULONG ComponentId, + IN ULONG Level, + IN LPCSTR Format, + IN va_list ap, + IN BOOLEAN HandleBreakpoint) +{ + NTSTATUS Status = STATUS_SUCCESS; + ANSI_STRING DebugString; + CHAR Buffer[512]; + ULONG Length, PrefixLength; + EXCEPTION_RECORD ExceptionRecord; + + /* Check if we should print it or not */ + if ((ComponentId != -1) && !(NtQueryDebugFilterState(ComponentId, Level))) + { + /* This message is masked */ + return Status; + } + + /* For user mode, don't recursively DbgPrint */ + if (RtlpSetInDbgPrint(TRUE)) return Status; + + /* Guard against incorrect pointers */ + _SEH_TRY + { + /* Get the length and normalize it */ + PrefixLength = strlen(Prefix); + if (PrefixLength > sizeof(Buffer)) PrefixLength = sizeof(Buffer); + + /* Copy it */ + strncpy(Buffer, Prefix, PrefixLength); - ++ + /* Do the printf */ + Length = _vsnprintf(Buffer + PrefixLength, + sizeof(Buffer) - PrefixLength, + Format, + ap); + } + _SEH_HANDLE + { + /* Fail */ + Length = PrefixLength = 0; + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if (!NT_SUCCESS(Status)) return Status; + + /* Check if we went past the buffer */ + if (Length == -1) + { + /* Terminate it if we went over-board */ + Buffer[sizeof(Buffer) - 1] = '\n'; + + /* Put maximum */ + Length = sizeof(Buffer); + } + else + { + /* Add the prefix */ + Length += PrefixLength; + } - ++ + /* Build the string */ + DebugString.Length = Length; + DebugString.Buffer = Buffer; + + /* First, let the debugger know as well */ + if (RtlpCheckForActiveDebugger(FALSE)) + { + /* Fill out an exception record */ + ExceptionRecord.ExceptionCode = DBG_PRINTEXCEPTION_C; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.NumberParameters = 2; + ExceptionRecord.ExceptionFlags = 0; + ExceptionRecord.ExceptionInformation[0] = DebugString.Length + 1; + ExceptionRecord.ExceptionInformation[1] = (ULONG_PTR)DebugString.Buffer; + + /* Raise the exception */ + RtlRaiseException(&ExceptionRecord); + + /* This code only runs in user-mode, so setting the flag is safe */ + NtCurrentTeb()->InDbgPrint = FALSE; + return STATUS_SUCCESS; + } + + /* Call the Debug Print routine */ + Status = DebugPrint(&DebugString, ComponentId, Level); + + /* Check if this was with Control-C */ + if (HandleBreakpoint) + { + /* Check if we got a breakpoint */ + if (Status == STATUS_BREAKPOINT) + { + /* Breakpoint */ + //DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C); + Status = STATUS_SUCCESS; + } + } + + /* In user-mode, remove the InDbgPrint Flag */ + RtlpSetInDbgPrint(FALSE); + + /* Return */ + return Status; +} + +/* + * @implemented + */ +ULONG +NTAPI +vDbgPrintExWithPrefix(IN LPCSTR Prefix, + IN ULONG ComponentId, + IN ULONG Level, + IN LPCSTR Format, + IN va_list ap) +{ + /* Call the internal routine that also handles ControlC */ + return vDbgPrintExWithPrefixInternal(Prefix, + ComponentId, + Level, + Format, + ap, + TRUE); +} + +/* + * @implemented + */ +ULONG +NTAPI +vDbgPrintEx(IN ULONG ComponentId, + IN ULONG Level, + IN LPCSTR Format, + IN va_list ap) +{ + /* Call the internal routine that also handles ControlC */ + return vDbgPrintExWithPrefixInternal("", + ComponentId, + Level, + Format, + ap, + TRUE); +} + +/* + * @implemented + */ +ULONG +__cdecl +DbgPrint(PCCH Format, + ...) +{ ++ ULONG n; + va_list ap; + + /* Call the internal routine that also handles ControlC */ + va_start(ap, Format); - return vDbgPrintExWithPrefixInternal("", ++ n = vDbgPrintExWithPrefixInternal("", + -1, + DPFLTR_ERROR_LEVEL, + Format, + ap, + TRUE); + va_end(ap); ++ return n; +} + +/* + * @implemented + */ +ULONG +__cdecl +DbgPrintEx(IN ULONG ComponentId, + IN ULONG Level, + IN PCCH Format, + ...) +{ ++ ULONG n; + va_list ap; + + /* Call the internal routine that also handles ControlC */ + va_start(ap, Format); - return vDbgPrintExWithPrefixInternal("", ++ n = vDbgPrintExWithPrefixInternal("", + ComponentId, + Level, + Format, + ap, + TRUE); + va_end(ap); ++ return n; +} + +/* + * @implemented + */ +ULONG +__cdecl +DbgPrintReturnControlC(PCH Format, + ...) +{ ++ ULONG n; + va_list ap; + + /* Call the internal routine that also handles ControlC */ + va_start(ap, Format); - return vDbgPrintExWithPrefixInternal("", ++ n = vDbgPrintExWithPrefixInternal("", + -1, + DPFLTR_ERROR_LEVEL, + Format, + ap, + FALSE); ++ va_end(ap); ++ return n; +} + +/* + * @implemented + */ +ULONG +NTAPI +DbgPrompt(IN PCCH Prompt, + OUT PCH Response, + IN ULONG MaximumResponseLength) +{ + CSTRING Output; + STRING Input; + + /* Setup the input string */ + Input.MaximumLength = (USHORT)MaximumResponseLength; + Input.Buffer = Response; + + /* Setup the output string */ + Output.Length = strlen(Prompt); + Output.Buffer = Prompt; + + /* Call the system service */ + return DebugPrompt(&Output, &Input); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +DbgQueryDebugFilterState(IN ULONG ComponentId, + IN ULONG Level) +{ + /* Call the Nt routine */ + return NtQueryDebugFilterState(ComponentId, Level); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +DbgSetDebugFilterState(IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State) +{ + /* Call the Nt routine */ + return NtSetDebugFilterState(ComponentId, Level, State); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +DbgLoadImageSymbols(IN PANSI_STRING Name, + IN PVOID Base, + IN ULONG_PTR ProcessId) +{ + PIMAGE_NT_HEADERS NtHeader; + KD_SYMBOLS_INFO SymbolInfo; + + /* Setup the symbol data */ + SymbolInfo.BaseOfDll = Base; + SymbolInfo.ProcessId = (ULONG)ProcessId; + + /* Get NT Headers */ + NtHeader = RtlImageNtHeader(Base); + if (NtHeader) + { + /* Get the rest of the data */ + SymbolInfo.CheckSum = NtHeader->OptionalHeader.CheckSum; + SymbolInfo.SizeOfImage = NtHeader->OptionalHeader.SizeOfImage; + } + else + { + /* No data available */ + SymbolInfo.CheckSum = SymbolInfo.SizeOfImage = 0; + } + + /* Load the symbols */ + DebugService2(Name, &SymbolInfo, BREAKPOINT_LOAD_SYMBOLS); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ +VOID +NTAPI +DbgUnLoadImageSymbols(IN PANSI_STRING Name, + IN PVOID Base, + IN ULONG_PTR ProcessId) +{ + KD_SYMBOLS_INFO SymbolInfo; + + /* Setup the symbol data */ + SymbolInfo.BaseOfDll = Base; + SymbolInfo.ProcessId = (ULONG)ProcessId; + SymbolInfo.CheckSum = SymbolInfo.SizeOfImage = 0; + + /* Load the symbols */ + DebugService2(Name, &SymbolInfo, BREAKPOINT_UNLOAD_SYMBOLS); +} + +/* EOF */ diff --cc reactos/lib/rtl/res.c index 900e1efecd0,00000000000..4714ae68775 mode 100644,000000..100644 --- a/reactos/lib/rtl/res.c +++ b/reactos/lib/rtl/res.c @@@ -1,297 -1,0 +1,297 @@@ +/* + * PE file resources + * + * Copyright 1995 Thomas Sandford + * Copyright 1996 Martin von Loewis + * Copyright 2003 Alexandre Julliard + * Copyright 1993 Robert J. Amstadt + * Copyright 1997 Marcus Meissner + * + * 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 + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +NTSTATUS find_entry( PVOID BaseAddress, LDR_RESOURCE_INFO *info, + ULONG level, void **ret, int want_dir ); + +/* FUNCTIONS ****************************************************************/ + +_SEH_FILTER(page_fault) +{ + if (_SEH_GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION || + _SEH_GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + +/********************************************************************** + * is_data_file_module + * + * Check if a module handle is for a LOAD_LIBRARY_AS_DATAFILE module. + */ +static int is_data_file_module( PVOID BaseAddress ) +{ + return (ULONG_PTR)BaseAddress & 1; +} + + +/********************************************************************** + * push_language + * + * push a language in the list of languages to try + */ +int push_language( USHORT *list, ULONG pos, WORD lang ) +{ - int i; ++ ULONG i; + for (i = 0; i < pos; i++) if (list[i] == lang) return pos; + list[pos++] = lang; + return pos; +} + + +/********************************************************************** + * find_first_entry + * + * Find the first suitable entry in a resource directory + */ +IMAGE_RESOURCE_DIRECTORY *find_first_entry( IMAGE_RESOURCE_DIRECTORY *dir, + void *root, int want_dir ) +{ + const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1); + int pos; + + for (pos = 0; pos < dir->NumberOfNamedEntries + dir->NumberOfIdEntries; pos++) + { + if (!entry[pos].DataIsDirectory == !want_dir) + return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory); + } + return NULL; +} + + +/********************************************************************** + * find_entry_by_id + * + * Find an entry by id in a resource directory + */ +IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( IMAGE_RESOURCE_DIRECTORY *dir, + WORD id, void *root, int want_dir ) +{ + const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry; + int min, max, pos; + + entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1); + min = dir->NumberOfNamedEntries; + max = min + dir->NumberOfIdEntries - 1; + while (min <= max) + { + pos = (min + max) / 2; + if (entry[pos].Id == id) + { + if (!entry[pos].DataIsDirectory == !want_dir) + { + DPRINT("root %p dir %p id %04x ret %p\n", + root, dir, id, (const char*)root + entry[pos].OffsetToDirectory); + return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory); + } + break; + } + if (entry[pos].Id > id) max = pos - 1; + else min = pos + 1; + } + DPRINT("root %p dir %p id %04x not found\n", root, dir, id ); + return NULL; +} + + +/********************************************************************** + * find_entry_by_name + * + * Find an entry by name in a resource directory + */ +IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( IMAGE_RESOURCE_DIRECTORY *dir, + LPCWSTR name, void *root, + int want_dir ) +{ + const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry; + const IMAGE_RESOURCE_DIR_STRING_U *str; + int min, max, res, pos, namelen; + + if (!((ULONG_PTR)name & 0xFFFF0000)) return find_entry_by_id( dir, (ULONG_PTR)name & 0xFFFF, root, want_dir ); + entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1); + namelen = wcslen(name); + min = 0; + max = dir->NumberOfNamedEntries - 1; + while (min <= max) + { + pos = (min + max) / 2; + str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].NameOffset); + res = _wcsnicmp( name, str->NameString, str->Length ); + if (!res && namelen == str->Length) + { + if (!entry[pos].DataIsDirectory == !want_dir) + { + DPRINT("root %p dir %p name %ws ret %p\n", + root, dir, name, (const char*)root + entry[pos].OffsetToDirectory); + return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].OffsetToDirectory); + } + break; + } + if (res < 0) max = pos - 1; + else min = pos + 1; + } + DPRINT("root %p dir %p name %ws not found\n", root, dir, name); + return NULL; +} + +#ifdef __i386__ +NTSTATUS NTAPI LdrpAccessResource( PVOID BaseAddress, IMAGE_RESOURCE_DATA_ENTRY *entry, + void **ptr, ULONG *size ) +#else +static NTSTATUS LdrpAccessResource( PVOID BaseAddress, IMAGE_RESOURCE_DATA_ENTRY *entry, + void **ptr, ULONG *size ) +#endif +{ + NTSTATUS status = STATUS_SUCCESS; + + _SEH_TRY + { + ULONG dirsize; + + if (!RtlImageDirectoryEntryToData( BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_RESOURCE, &dirsize )) + status = STATUS_RESOURCE_DATA_NOT_FOUND; + else + { + if (ptr) + { + if (is_data_file_module(BaseAddress)) + { + PVOID mod = (PVOID)((ULONG_PTR)BaseAddress & ~1); + *ptr = RtlImageRvaToVa( RtlImageNtHeader(mod), mod, entry->OffsetToData, NULL ); + } + else *ptr = (char *)BaseAddress + entry->OffsetToData; + } + if (size) *size = entry->Size; + } + } + _SEH_EXCEPT(page_fault) + { + status = _SEH_GetExceptionCode(); + } + _SEH_END; + return status; +} + + +/* + * @implemented + */ +NTSTATUS NTAPI +LdrFindResource_U(PVOID BaseAddress, + PLDR_RESOURCE_INFO ResourceInfo, + ULONG Level, + PIMAGE_RESOURCE_DATA_ENTRY* ResourceDataEntry) +{ + void *res; + NTSTATUS status = STATUS_SUCCESS; + + _SEH_TRY + { + if (ResourceInfo) + { + DPRINT( "module %p type %ws name %ws lang %04lx level %ld\n", + BaseAddress, (LPCWSTR)ResourceInfo->Type, + Level > 1 ? (LPCWSTR)ResourceInfo->Name : L"", + Level > 2 ? ResourceInfo->Language : 0, Level ); + } + + status = find_entry( BaseAddress, ResourceInfo, Level, &res, FALSE ); + if (status == STATUS_SUCCESS) *ResourceDataEntry = res; + } + _SEH_EXCEPT(page_fault) + { + status = _SEH_GetExceptionCode(); + } + _SEH_END; + return status; +} + +#ifndef __i386__ +/* + * @implemented + */ +NTSTATUS NTAPI +LdrAccessResource(IN PVOID BaseAddress, + IN PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, + OUT PVOID* Resource OPTIONAL, + OUT PULONG Size OPTIONAL) +{ + return LdrpAccessResource( BaseAddress, ResourceDataEntry, Resource, Size ); +} +#endif + +/* + * @implemented + */ +NTSTATUS NTAPI +LdrFindResourceDirectory_U(IN PVOID BaseAddress, + IN PLDR_RESOURCE_INFO info, + IN ULONG level, + OUT PIMAGE_RESOURCE_DIRECTORY* addr) +{ + void *res; + NTSTATUS status = STATUS_SUCCESS; + + _SEH_TRY + { + if (info) + { + DPRINT( "module %p type %ws name %ws lang %04lx level %ld\n", + BaseAddress, (LPCWSTR)info->Type, + level > 1 ? (LPCWSTR)info->Name : L"", + level > 2 ? info->Language : 0, level ); + } + + status = find_entry( BaseAddress, info, level, &res, TRUE ); + if (status == STATUS_SUCCESS) *addr = res; + } + _SEH_EXCEPT(page_fault) + { + status = _SEH_GetExceptionCode(); + } + _SEH_END; + return status; +} + + +/* + * @unimplemented + */ +NTSTATUS NTAPI +LdrEnumResources(IN PVOID BaseAddress, + IN PLDR_RESOURCE_INFO ResourceInfo, + IN ULONG Level, + IN OUT PULONG ResourceCount, + OUT PVOID Resources OPTIONAL) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} diff --cc reactos/lib/rtl/rtl.h index 7f1eaf73ad7,00000000000..81d82686a70 mode 100644,000000..100644 --- a/reactos/lib/rtl/rtl.h +++ b/reactos/lib/rtl/rtl.h @@@ -1,40 -1,0 +1,38 @@@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS System Libraries + * FILE: lib/rtl/rtl.h + * PURPOSE: Run-Time Libary Header + * PROGRAMMER: Alex Ionescu + */ + +/* INCLUDES ******************************************************************/ + +#ifndef RTL_H +#define RTL_H + +/* We're a core NT DLL, we don't import syscalls */ +#define WIN32_NO_STATUS +#define _INC_SWPRINTF_INL_ +#undef __MSVCRT__ + +/* C Headers */ +#include +#include + +/* PSDK/NDK Headers */ +#include +#include + +/* Internal RTL header */ +#include "rtlp.h" + +/* PSEH Support */ +#include +#include + - #ifndef _MSC_VER +#include - #endif + +#endif /* RTL_H */ + +/* EOF */ diff --cc reactos/lib/sdk/crt/math/i386/ci.c index b0a58eb2d5c,00000000000..0aeb0d1379c mode 100644,000000..100644 --- a/reactos/lib/sdk/crt/math/i386/ci.c +++ b/reactos/lib/sdk/crt/math/i386/ci.c @@@ -1,137 -1,0 +1,145 @@@ +#include +#include + ++#if defined(__GNUC__) +#define FPU_DOUBLE(var) double var; \ + __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : ) +#define FPU_DOUBLES(var1,var2) double var1,var2; \ + __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \ + __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : ) ++#elif defined(_MSC_VER) ++#define FPU_DOUBLE(var) double var; \ ++ __asm { fstp [var] }; __asm { fwait }; ++#define FPU_DOUBLES(var1,var2) double var1,var2; \ ++ __asm { fstp [var1] }; __asm { fwait }; \ ++ __asm { fstp [var2] }; __asm { fwait }; ++#endif + +/* + * @implemented + */ +double CDECL _CIsin(void) +{ + FPU_DOUBLE(x); + return sin(x); +} +/* + * @implemented + */ +double CDECL _CIcos(void) +{ + FPU_DOUBLE(x); + return cos(x); +} +/* + * @implemented + */ +double CDECL _CItan(void) +{ + FPU_DOUBLE(x); + return tan(x); +} +/* + * @implemented + */ +double CDECL _CIsinh(void) +{ + FPU_DOUBLE(x); + return sinh(x); +} +/* + * @implemented + */ +double CDECL _CIcosh(void) +{ + FPU_DOUBLE(x); + return cosh(x); +} +/* + * @implemented + */ +double CDECL _CItanh(void) +{ + FPU_DOUBLE(x); + return tanh(x); +} +/* + * @implemented + */ +double CDECL _CIasin(void) +{ + FPU_DOUBLE(x); + return asin(x); +} +/* + * @implemented + */ +double CDECL _CIacos(void) +{ + FPU_DOUBLE(x); + return acos(x); +} +/* + * @implemented + */ +double CDECL _CIatan(void) +{ + FPU_DOUBLE(x); + return atan(x); +} +/* + * @implemented + */ +double CDECL _CIatan2(void) +{ + FPU_DOUBLES(x, y); + return atan2(x, y); +} +/* + * @implemented + */ +double CDECL _CIexp(void) +{ + FPU_DOUBLE(x); + return exp(x); +} +/* + * @implemented + */ +double CDECL _CIlog(void) +{ + FPU_DOUBLE(x); + return log(x); +} +/* + * @implemented + */ +double CDECL _CIlog10(void) +{ + FPU_DOUBLE(x); + return log10(x); +} +/* + * @implemented + */ +double CDECL _CIpow(void) +{ + FPU_DOUBLES(x, y); + return pow(x, y); +} +/* + * @implemented + */ +double CDECL _CIsqrt(void) +{ + FPU_DOUBLE(x); + return sqrt(x); +} +/* + * @implemented + */ +double CDECL _CIfmod(void) +{ + FPU_DOUBLES(x, y); + return fmod(x, y); +} diff --cc reactos/lib/sdk/crt/string/ctype.c index 46870724404,00000000000..78183578dec mode 100644,000000..100644 --- a/reactos/lib/sdk/crt/string/ctype.c +++ b/reactos/lib/sdk/crt/string/ctype.c @@@ -1,611 -1,0 +1,611 @@@ +#include +#undef __MINGW_IMPORT +#define __MINGW_IMPORT +#include + +#undef _pctype + +/* MS's CRT header defines all that, and we actually implement that */ +#undef iswalnum +#undef __isascii +#undef iswascii +#undef __iscsym +#undef __iscsymf +#undef iswalpha +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswprint +#undef iswpunct +#undef iswlower +#undef iswupper +#undef iswspace +#undef iswxdigit +#undef __toascii + +#define upalpha ('A' - 'a') + + +unsigned short _ctype[] = { + 0, /* , 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 */ +}; + +const unsigned short *_pctype = _ctype + 1; +const unsigned short *_pwctype = _ctype + 1; + +/* + * @implemented + */ +const unsigned short **__p__pctype(void) +{ + return &_pctype; +} + +/* + * @implemented + */ +const unsigned short **__p__pwctype(void) +{ + return &_pwctype; +} + +int _isctype (int c, int ctypeFlags) +{ + return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags); +} + +/* + * @implemented + */ +int iswctype(wint_t wc, wctype_t wctypeFlags) +{ + return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags); +} + +/* + * obsolete + * + * @implemented + */ +int is_wctype(wint_t wc, wctype_t wctypeFlags) +{ + return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags); +} + +/* + * @implemented + */ +int isalpha(int c) +{ + return(_isctype(c, _ALPHA)); +} + +/* + * @implemented + */ +int isalnum(int c) +{ + return(_isctype(c, _ALPHA | _DIGIT)); +} + +/* + * @implemented + */ +int iswalnum(wint_t c) +{ + return iswctype(c, _ALPHA | _DIGIT); +} + +/* + * @implemented + */ +int __isascii(int c) +{ + return ((unsigned char)c <= 0x7f); +} + +/* + * @implemented + */ +int iswascii(wint_t c) +{ + return __isascii(c); +} + +/* + * @implemented + */ +int iscntrl(int c) +{ + return(_isctype(c, _CONTROL)); +} + +/* + * @implemented + */ +int __iscsym(int c) +{ + return (c < 127 && (isalnum(c) || (c == '_'))); +} + +/* + * @implemented + */ +int __iscsymf(int c) +{ + return (c < 127 && (isalpha(c) || (c == '_'))); +} + +/* + * @implemented + */ +int isdigit(int c) +{ + return(_isctype(c, _DIGIT)); +} + +/* + * @implemented + */ +int isgraph(int c) +{ + return (_isctype (c, _PUNCT | _ALPHA | _DIGIT)); +} + +/* + * @implemented + */ +int islower(int c) +{ + return (_isctype (c, _LOWER)); +} + +/* + * @implemented + */ +int isprint(int c) +{ + return (_isctype (c, _BLANK | _PUNCT | _ALPHA | _DIGIT)); +} + +/* + * @implemented + */ +int ispunct(int c) +{ + return (_isctype (c, _PUNCT)); +} + +/* + * @implemented + */ +int isspace(int c) +{ + return (_isctype (c, _SPACE)); +} + +/* + * @implemented + */ +int isupper(int c) +{ + return (_isctype (c, _UPPER)); +} + +/* + * @implemented + */ +int isxdigit(int c) +{ + return (_isctype (c, _HEX)); +} + + +/* + * @implemented + */ +int iswalpha(wint_t c) +{ + return (iswctype (c, _ALPHA)); +} + +/* + * @implemented + */ +int iswcntrl(wint_t c) +{ + return iswctype(c, _CONTROL); +} + +/* + * @implemented + */ +int iswdigit(wint_t c) +{ + return (iswctype (c, _DIGIT)); +} + +/* + * @implemented + */ +int iswgraph(wint_t c) +{ + return iswctype(c,_PUNCT | _ALPHA | _DIGIT); +} + +/* + * @implemented + */ +int iswprint(wint_t c) +{ + return iswctype((unsigned short)c,_BLANK | _PUNCT | _ALPHA | _DIGIT); +} + + +/* + * @implemented + */ +int iswpunct(wint_t c) +{ + return iswctype(c, _PUNCT); +} + +/* + * @implemented + */ +int iswlower(wint_t c) +{ + return (iswctype (c, _LOWER)); +} + +/* + * @implemented + */ +int iswupper(wint_t c) +{ + return iswctype(c, _UPPER); +} + + +/* + * @implemented + */ +int iswspace(wint_t c) +{ + return (iswctype (c, _SPACE)); +} + +/* + * @implemented + */ +int iswxdigit(wint_t c) +{ + return (iswctype (c, _HEX)); +} + + +/* + * @implemented + */ +int __toascii(int c) +{ + return((unsigned)(c) & 0x7f); +} + +/* + * @implemented + */ +int _tolower(int c) +{ + if (_isctype (c, _UPPER)) + return (c - upalpha); + return(c); +} + +/* + * @implemented + */ +int _toupper(int c) +{ + if (_isctype (c, _LOWER)) + return (c + upalpha); + return(c); +} + +/* + * @implemented + */ +int tolower(int c) +{ + if (_isctype (c, _UPPER)) + return (c - upalpha); + return(c); +} + +/* + * @implemented + */ +int toupper(int c) +{ + if (_isctype (c, _LOWER)) + return (c + upalpha); + return(c); +} + +/* + * @implemented + */ - wchar_t towlower(wchar_t c) ++wint_t towlower(wint_t c) +{ + if (iswctype (c, _UPPER)) + return (c - upalpha); + return(c); +} + +/* + * @implemented + */ - wchar_t towupper(wchar_t c) ++wint_t towupper(wint_t c) +{ + if (iswctype (c, _LOWER)) + return (c + upalpha); + return(c); +} + +/* EOF */