- Removed lib/interlck and lib/string.
- Removed math routines from lib/rtl.
- Created a new library called libcntpr which is what NT/WDK use when compiling the kernel/system libraries. This is an "NT-Private" version of the CRT which is supposed to contain what we had in lib/string and lib/rtl.
svn path=/trunk/; revision=26095
-/* $Id$
- *
- * MORE.C - external command.
- *
- * clone from 4nt more command
- *
- * 26 Sep 1999 - Paolo Pantaleo <paolopan@freemail.it>
- * started
- * Oct 2003 - Timothy Schepens <tischepe at fastmail dot fm>
- * use window size instead of buffer size.
- */
-
-#include <windows.h>
-#include <malloc.h>
-#include <tchar.h>
-
-
-DWORD len;
-LPTSTR msg = _T("--- continue ---");
-
-
-/*handle for file and console*/
-HANDLE hStdIn;
-HANDLE hStdOut;
-HANDLE hStdErr;
-HANDLE hKeyboard;
-
-
-static VOID
-GetScreenSize (PSHORT maxx, PSHORT maxy)
-{
- CONSOLE_SCREEN_BUFFER_INFO csbi;
-
- GetConsoleScreenBufferInfo (hStdOut, &csbi);
- *maxx = (csbi.srWindow.Right - csbi.srWindow.Left) + 1;
- *maxy = (csbi.srWindow.Bottom - csbi.srWindow.Top) - 4;
-
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+#define rdtscll(val) __asm__ __volatile__ ("rdtsc" : "=A" (val))
+
+const int SELECTMODE = 14;
+const int BIGDATA = 10000; // Relying on int = long
+const int MHZ = 2160;
+int *data;
+
+void SelectionSort(int data[], int left, int right) {
+ int i, j;
+ for(i = left; i < right; i++) {
+ int min = i;
+ for(j=i+1; j <= right; j++)
+ if(data[j] < data[min]) min = j;
+ int temp = data[min];
+ data[min] = data[i];
+ data[i] = temp;
+ }
}
-
-static
-VOID ConOutPuts (LPTSTR szText)
+int Partition( int d[], int left, int right)
{
- DWORD dwWritten;
-
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL);
- WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL);
+ int val =d[left];
+ int lm = left-1;
+ int rm = right+1;
+ for(;;) {
+ do
+ rm--;
+ while (d[rm] > val);
+
+ do
+ lm++;
+ while( d[lm] < val);
+
+ if(lm < rm) {
+ int tempr = d[rm];
+ d[rm] = d[lm];
+ d[lm] = tempr;
+ }
+ else
+ return rm;
+ }
}
-
-static VOID
-ConInKey (VOID)
+void Quicksort( int d[], int left, int right)
{
- INPUT_RECORD ir;
- DWORD dwRead;
-
- do
- {
- ReadConsoleInput (hKeyboard, &ir, 1, &dwRead);
- if ((ir.EventType == KEY_EVENT) &&
- (ir.Event.KeyEvent.bKeyDown == TRUE))
- return;
- }
- while (TRUE);
+ if(left < (right-SELECTMODE)) {
+ int split_pt = Partition(d,left, right);
+ Quicksort(d, left, split_pt);
+ Quicksort(d, split_pt+1, right);
+ }
+ else SelectionSort(d, left, right);
}
+int main(int argc, char* argv[]) {
-static VOID
-WaitForKey (VOID)
-{
- DWORD dwWritten;
-
- WriteFile (hStdErr,msg , len, &dwWritten, NULL);
-
- ConInKey();
-
- WriteFile (hStdErr, _T("\n"), 1, &dwWritten, NULL);
-
-// FlushConsoleInputBuffer (hConsoleIn);
-}
+ data = (int*)calloc(BIGDATA,4);
+ unsigned long int timeStart;
+ unsigned long int timeReadLoopStart;
+ unsigned long int timeReadLoopEnd;
-//INT CommandMore (LPTSTR cmd, LPTSTR param)
-int main (int argc, char **argv)
-{
- SHORT maxx,maxy;
- SHORT line_count=0,ch_count=0;
- DWORD i, last;
- HANDLE hFile = INVALID_HANDLE_VALUE;
- TCHAR szFullPath[MAX_PATH];
-
- /*reading/writing buffer*/
- TCHAR *buff;
-
- /*bytes written by WriteFile and ReadFile*/
- DWORD dwRead,dwWritten;
-
- /*ReadFile() return value*/
- BOOL bRet;
-
- len = _tcslen (msg);
- hStdIn = GetStdHandle(STD_INPUT_HANDLE);
- hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- hStdErr = GetStdHandle(STD_ERROR_HANDLE);
-
- if (argc > 1 && _tcsncmp (argv[1], _T("/?"), 2) == 0)
- {
- ConOutPuts(_T("Help text still missing!!"));
- return 0;
- }
+ unsigned long int timeSortLoopStart;
+ unsigned long int timeSortLoopEnd;
- hKeyboard = CreateFile (_T("CONIN$"), GENERIC_READ,
- 0,NULL,OPEN_ALWAYS,0,0);
+ unsigned long int timeWriteLoopStart;
+ unsigned long int timeWriteLoopEnd;
- GetScreenSize(&maxx,&maxy);
+ unsigned long int timeEnd;
- buff=malloc(4096);
+ FILE *randfile;
+ FILE *sortfile;
+ int i,j,thisInt,dataSize = 0;
+ long sumUnsorted = 0;
- FlushConsoleInputBuffer (hKeyboard);
+ rdtscll(timeStart);
- if(argc > 1)
- {
- GetFullPathName(argv[1], MAX_PATH, szFullPath, NULL);
- hFile = CreateFile (szFullPath, GENERIC_READ,
- 0,NULL,OPEN_ALWAYS,0,0);
+ randfile = fopen(argv[1],"r");
+ sortfile = fopen(argv[2],"w");
+ if (randfile == NULL || sortfile == NULL) {
+ fprintf(stderr,"Could not open all files.\n");
+ return 1;
}
- do
- {
- if(hFile != INVALID_HANDLE_VALUE)
- {
- bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);
+ rdtscll(timeReadLoopStart);
+
+ i = 0;
+ while (!feof(randfile)) {
+ fscanf(randfile,"%d",&thisInt);
+ if (feof(randfile)) { break; }
+ data[i] = thisInt;
+ sumUnsorted += thisInt;
+ //fprintf(stdout,"[%d] Read item: %d\n",i,thisInt);
+ i++;
+ if (i >= BIGDATA) {
+ break;
}
- else
- {
- bRet = ReadFile(hStdIn,buff,4096,&dwRead,NULL);
+ }
+ fclose(randfile);
+ dataSize = i;
+
+ rdtscll(timeReadLoopEnd);
+ rdtscll(timeSortLoopStart);
+
+ Quicksort(data, 0, dataSize-1);
+
+ rdtscll(timeSortLoopEnd);
+ rdtscll(timeWriteLoopStart);
+
+ int last = -1;
+ for(j = 0; j < dataSize; j++) {
+ if (data[j] < last) {
+ fprintf(stderr,"The data is not in order\n");
+ fprintf(stderr,"Noticed the problem at j = %d\n",j);
+ fclose(sortfile);
+ return 1;
+ } else {
+ fprintf(sortfile,"%d\n",data[j]);
}
+ }
+ fclose(sortfile);
- for(last=i=0;i<dwRead && bRet;i++)
- {
- ch_count++;
- if(buff[i] == _T('\n') || ch_count == maxx)
- {
- ch_count=0;
- line_count++;
- if (line_count == maxy)
- {
- line_count = 0;
- WriteFile(hStdOut,&buff[last], i-last+1, &dwWritten, NULL);
- last=i+1;
- FlushFileBuffers (hStdOut);
- WaitForKey ();
- }
- }
- }
- if (last<dwRead && bRet)
- WriteFile(hStdOut,&buff[last], dwRead-last, &dwWritten, NULL);
+ rdtscll(timeWriteLoopEnd);
- }
- while(dwRead>0 && bRet);
+ rdtscll(timeEnd);
- free (buff);
- CloseHandle (hKeyboard);
- CloseHandle (hFile);
+ fprintf(stdout,"Sorted %d items.\n",dataSize);
+ fprintf(stdout,"Open Files : %ldt.\n",(long)timeReadLoopStart - (long)timeStart);
+ fprintf(stdout,"Read Data : %ldt.\n",(long)timeReadLoopEnd - (long)timeReadLoopStart);
+ fprintf(stdout,"Sort Data : %ldt.\n",(long)timeSortLoopEnd - (long)timeSortLoopStart);
+ fprintf(stdout,"Write Data : %ldt.\n",(long)timeWriteLoopEnd - (long)timeWriteLoopStart);
+ fprintf(stdout,"Total Time : %ldt.\n",(long)timeEnd - (long)timeStart);
return 0;
}
-
-/* EOF */
<define name="_WIN32_IE">0x0501</define>
<define name="_WIN32_WINNT">0x0501</define>
<library>kernel32</library>
+ <library>ntdll</library>
<file>more.c</file>
<file>more.rc</file>
</module>
<module name="freeldr" type="bootloader">
- <bootstrap base="loader" />
- <library>freeldr_startup</library>
- <library>freeldr_base64k</library>
- <library>freeldr_base</library>
- <library>freeldr_arch</library>
- <library>freeldr_main</library>
- <library>rossym</library>
- <library>string</library>
- <library>cmlib</library>
- <library>rtl</library>
+ <bootstrap base="loader" />
+ <library>freeldr_startup</library>
+ <library>freeldr_base64k</library>
+ <library>freeldr_base</library>
+ <library>freeldr_arch</library>
+ <library>freeldr_main</library>
+ <library>rossym</library>
+ <library>cmlib</library>
+ <library>rtl</library>
+ <library>libcntpr</library>
</module>
<module name="setupldr" type="bootloader">
- <bootstrap base="loader" />
- <library>freeldr_startup</library>
- <library>freeldr_base64k</library>
- <library>freeldr_base</library>
- <library>freeldr_arch</library>
- <library>setupldr_main</library>
- <library>rossym</library>
- <library>string</library>
- <library>cmlib</library>
- <library>rtl</library>
+ <bootstrap base="loader" />
+ <library>freeldr_startup</library>
+ <library>freeldr_base64k</library>
+ <library>freeldr_base</library>
+ <library>freeldr_arch</library>
+ <library>setupldr_main</library>
+ <library>rossym</library>
+ <library>cmlib</library>
+ <library>rtl</library>
+ <library>libcntpr</library>
</module>
<module name="ntdll" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_NTDLL}" installbase="system32" installname="ntdll.dll">
- <bootstrap base="reactos/system32" />
- <importlibrary definition="def/ntdll.def" />
- <include base="ntdll">inc</include>
- <include base="ReactOS">include/reactos/subsys</include>
- <define name="__NTDLL__" />
- <define name="_DISABLE_TIDENTS" />
- <define name="__USE_W32API" />
- <define name="_WIN32_WINNT">0x0502</define>
- <define name="_NTOSKRNL_" />
- <define name="__NO_CTYPE_INLINES" />
- <library>rtl</library>
- <library>string</library>
- <library>pseh</library>
- <linkerflag>-lgcc</linkerflag>
- <linkerflag>-nostdlib</linkerflag>
- <linkerflag>-nostartfiles</linkerflag>
- <directory name="csr">
- <file>api.c</file>
- <file>capture.c</file>
- <file>connect.c</file>
- </directory>
- <directory name="dbg">
- <file>dbgui.c</file>
- </directory>
- <directory name="ldr">
- <file>startup.c</file>
- <file>utils.c</file>
- </directory>
- <directory name="main">
- <if property="ARCH" value="i386">
- <directory name="i386">
- <file>dispatch.S</file>
- </directory>
- </if>
- <ifnot property="ARCH" value="i386">
- <file>dispatch.c</file>
- </ifnot>
- </directory>
- <directory name="rtl">
- <file>libsupp.c</file>
- <file>version.c</file>
- </directory>
- <directory name="def">
- <file>ntdll.rc</file>
- </directory>
- <directory name="inc">
- <pch>ntdll.h</pch>
- </directory>
- <file>napi.S</file>
+ <bootstrap base="reactos/system32" />
+ <importlibrary definition="def/ntdll.def" />
+ <include base="ntdll">inc</include>
+ <include base="ReactOS">include/reactos/subsys</include>
+ <define name="__NTDLL__" />
+ <define name="_DISABLE_TIDENTS" />
+ <define name="__USE_W32API" />
+ <define name="_WIN32_WINNT">0x0502</define>
+ <define name="_NTOSKRNL_" />
+ <define name="__NO_CTYPE_INLINES" />
+ <library>rtl</library>
+ <library>libcntpr</library>
+ <library>pseh</library>
+ <linkerflag>-lgcc</linkerflag>
+ <linkerflag>-nostdlib</linkerflag>
+ <linkerflag>-nostartfiles</linkerflag>
+ <directory name="csr">
+ <file>api.c</file>
+ <file>capture.c</file>
+ <file>connect.c</file>
+ </directory>
+ <directory name="dbg">
+ <file>dbgui.c</file>
+ </directory>
+ <directory name="ldr">
+ <file>startup.c</file>
+ <file>utils.c</file>
+ </directory>
+ <directory name="main">
+ <if property="ARCH" value="i386">
+ <directory name="i386">
+ <file>dispatch.S</file>
+ </directory>
+ </if>
+ <ifnot property="ARCH" value="i386">
+ <file>dispatch.c</file>
+ </ifnot>
+ </directory>
+ <directory name="rtl">
+ <file>libsupp.c</file>
+ <file>version.c</file>
+ </directory>
+ <directory name="def">
+ <file>ntdll.rc</file>
+ </directory>
+ <directory name="inc">
+ <pch>ntdll.h</pch>
+ </directory>
+ <file>napi.S</file>
</module>
<define name="__REACTOS__" />
<define name="USE_MSVCRT_PREFIX" />
<define name="_MSVCRT_LIB_" />
+ <define name="__NO_CTYPE_INLINES" />
+ <define name="_CTYPE_DISABLE_MACROS" />
+ <define name="_NO_INLINING" />
<!-- __MINGW_IMPORT needs to be defined differently because it's defined
as dllimport by default, which is invalid from GCC 4.1.0 on! -->
<define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define>
<library>crt</library>
- <library>string</library>
<library>kernel32</library>
<library>ntdll</library>
<pch>precomp.h</pch>
<define name="USE_MSVCRT_PREFIX" />
<define name="_MSVCRT_LIB_" />
<define name="_MT" />
+ <define name="__NO_CTYPE_INLINES" />
+ <define name="_CTYPE_DISABLE_MACROS" />
+ <define name="_NO_INLINING" />
- <!-- __MINGW_IMPORT needs to be defined differently because it's defined
+ <!-- __MINGW_IMPORT needs to be defined differently because it's defined
as dllimport by default, which is invalid from GCC 4.1.0 on! -->
<define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define>
<library>crt</library>
- <library>string</library>
<library>kernel32</library>
- <library>ntdll</library>
<library>wine</library>
<pch>precomp.h</pch>
<file>dllmain.c</file>
<define name="USE_MSVCRT_PREFIX" />
<define name="_MT" />
<library>wine</library>
- <library>string</library>
<library>ntdll</library>
<library>kernel32</library>
<library>msvcrt</library>
<include base="framebuf">.</include>
<define name="__USE_W32API" />
<library>win32k</library>
- <library>string</library>
+ <library>libcntpr</library>
<file>enable.c</file>
<file>palette.c</file>
<file>pointer.c</file>
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
<group>
-<directory name="adns">
- <xi:include href="adns/adns.rbuild" />
-</directory>
-<directory name="bzip2">
- <xi:include href="bzip2/bzip2.rbuild" />
-</directory>
-<directory name="expat">
- <xi:include href="expat/expat.rbuild" />
-</directory>
-<directory name="libxml2">
- <xi:include href="libxml2/libxml2.rbuild" />
-</directory>
-<directory name="zlib">
- <xi:include href="zlib/zlib.rbuild" />
-</directory>
+ <directory name="adns">
+ <xi:include href="adns/adns.rbuild" />
+ </directory>
+ <directory name="bzip2">
+ <xi:include href="bzip2/bzip2.rbuild" />
+ </directory>
+ <directory name="expat">
+ <xi:include href="expat/expat.rbuild" />
+ </directory>
+ <directory name="libwine">
+ <xi:include href="libwine/libwine.rbuild" />
+ </directory>
+ <directory name="libxml2">
+ <xi:include href="libxml2/libxml2.rbuild" />
+ </directory>
+ <directory name="mingw">
+ <xi:include href="mingw/mingw.rbuild" />
+ </directory>
+ <directory name="zlib">
+ <xi:include href="zlib/zlib.rbuild" />
+ </directory>
</group>
<define name="_NTSYSTEM_" />
<define name="NASSERT" />
<pch>cmlib.h</pch>
+ <library>rtl</library>
<file>cminit.c</file>
<file>hivebin.c</file>
<file>hivecell.c</file>
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/decrement.c
- * PURPOSE: Inter lock decrements
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-#include <windows.h>
-
-/************************************************************************
-* InterlockedDecrement *
-* *
-* InterlockedDecrement adds -1 to a long variable and returns *
-* the resulting decremented value. *
-* *
-************************************************************************/
-
-LONG NTAPI
-InterlockedDecrement(
- LPLONG lpAddend)
-{
- return InterlockedExchangeAdd( lpAddend, -1 ) - 1;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/exchange.c
- * PURPOSE: Inter lock exchanges
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-#include <windows.h>
-
-/************************************************************************
- * InterlockedExchange
- *
- * Atomically exchanges a pair of values.
- *
- * RETURNS
- * Prior value of value pointed to by Target
- */
-
-LONG NTAPI
-InterlockedExchange(
- LPLONG target,
- LONG value)
-{
- LONG ret;
-
- do
- {
- ret = *(volatile LONG *)target;
- } while( InterlockedCompareExchange( target, value, ret ) != ret );
-
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/exchangeadd.c
- * PURPOSE: Inter lock exchange adds
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-#include <windows.h>
-
-/************************************************************************
- * InterlockedExchangeAdd
- *
- * Atomically adds Increment to Addend and returns the previous value of
- * Addend
- *
- * RETURNS
- * Prior value of value pointed to by Addend
- */
-
-LONG NTAPI
-InterlockedExchangeAdd(
- PLONG Addend,
- LONG Increment)
-{
- LONG ret;
- LONG newval;
-
- do
- {
- ret = *(volatile LONG *)Addend;
- newval = ret + Increment;
- } while (InterlockedCompareExchange(Addend, ret, newval) != ret);
-
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/i386/compareexchange.c
- * PURPOSE: Inter lock compare exchanges
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-/************************************************************************
- * InterlockedCompareExchange
- *
- * Atomically compares Destination and Comperand, and if found equal exchanges
- * the value of Destination with Exchange
- *
- * RETURNS
- * Prior value of value pointed to by Destination
- */
-
-/*
- * LONG NTAPI InterlockedCompareExchange(LPLONG Destination, LONG Exchange, LONG Comperand)
- */
-
-#include <windows.h>
-LONG
-NTAPI
-InterlockedCompareExchange(
- IN OUT LONG volatile *Destination,
- LONG Exchange,
- LONG Comperand)
-{
- LONG ret;
- __asm__ __volatile__(
- "lock; cmpxchgl %2,(%1)"
- : "=a" (ret) : "r" (Destination), "r" (Exchange), "0" (Comperand) : "memory" );
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/i386/decrement.c
- * PURPOSE: Inter lock decrements
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-/************************************************************************
-* InterlockedDecrement *
-* *
-* InterlockedDecrement adds -1 to a long variable and returns *
-* the resulting decremented value. *
-* *
-************************************************************************/
-
-/*
- * LONG NTAPI InterlockedDecrement(LPLONG lpAddend)
- */
-
-#include <windows.h>
-LONG
-NTAPI
-InterlockedDecrement(IN OUT LONG volatile *lpAddend)
-{
- LONG ret;
- __asm__
- (
- "\tlock\n" /* for SMP systems */
- "\txaddl %0, (%1)\n"
- "\tdecl %0\n"
- :"=r" (ret)
- :"r" (lpAddend), "0" (-1)
- : "memory"
- );
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/i386/exchange.c
- * PURPOSE: Inter lock exchanges
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-/************************************************************************
- * InterlockedExchange
- *
- * Atomically exchanges a pair of values.
- *
- * RETURNS
- * Prior value of value pointed to by Target
- */
-
-/*
- * LONG NTAPI InterlockedExchange(LPLONG target, LONG value)
- */
-
-#include <windows.h>
-LONG
-NTAPI
-InterlockedExchange(IN OUT LONG volatile *target, LONG value)
-{
- LONG ret;
- __asm__ (
- /* lock for SMP systems */
- "lock\n\txchgl %0,(%1)"
- :"=r" (ret):"r" (target), "0" (value):"memory" );
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/i386/exchangeadd.c
- * PURPOSE: Inter lock exchange adds
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-/************************************************************************
- * InterlockedExchangeAdd
- *
- * Atomically adds Increment to Addend and returns the previous value of
- * Addend
- *
- * RETURNS
- * Prior value of value pointed to by Addend
- */
-
-/*
- * LONG NTAPI InterlockedExchangeAdd(PLONG Addend, LONG Increment)
- */
-
-#include <windows.h>
-LONG
-NTAPI
-InterlockedExchangeAdd(
- IN OUT LONG volatile *Addend,
- LONG Increment)
-{
- LONG ret;
- __asm__ (
- /* lock for SMP systems */
- "lock\n\t"
- "xaddl %0,(%1)"
- :"=r" (ret)
- :"r" (Addend), "0" (Increment)
- :"memory" );
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/i386/increment.c
- * PURPOSE: Inter lock increments
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-/************************************************************************
-* InterlockedIncrement *
-* *
-* InterlockedIncrement adds 1 to a long variable and returns *
-* the resulting incremented value. *
-* *
-************************************************************************/
-
-/*
- * LONG NTAPI InterlockedIncrement(PLONG Addend)
- */
-
-#include <windows.h>
-LONG
-NTAPI
-InterlockedIncrement(IN OUT LONG volatile *lpAddend)
-{
- LONG ret;
- __asm__
- (
- "\tlock\n" /* for SMP systems */
- "\txaddl %0, (%1)\n"
- "\tincl %0\n"
- :"=r" (ret)
- :"r" (lpAddend), "0" (1)
- : "memory"
- );
- return ret;
-}
+++ /dev/null
-/*
- * PROJECT: ReactOS system libraries
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/intrlck/increment.c
- * PURPOSE: Inter lock increments
- * PROGRAMMERS: Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- */
-
-#include <windows.h>
-
-/************************************************************************
-* InterlockedIncrement *
-* *
-* InterlockedIncrement adds 1 to a long variable and returns *
-* the resulting incremented value. *
-* *
-************************************************************************/
-
-LONG NTAPI
-InterlockedIncrement(
- LPLONG lpAddend)
-{
- return InterlockedExchangeAdd( lpAddend, 1 ) + 1;
-}
+++ /dev/null
-<module name="intrlck" type="staticlibrary">
- <define name="__USE_W32API" />
-
- <if property="ARCH" value="i386">
- <directory name="i386">
- <file>compareexchange.c</file>
- <file>decrement.c</file>
- <file>exchange.c</file>
- <file>exchangeadd.c</file>
- <file>increment.c</file>
- </directory>
- </if>
- <if property="ARCH" value="ppc">
- <directory name="ppc">
- <file>compareexchange.c</file>
- </directory>
- <file>decrement.c</file>
- <file>exchange.c</file>
- <file>exchangeadd.c</file>
- <file>increment.c</file>
- </if>
-</module>
+++ /dev/null
-/* PowerPC Functions from gatomic.c in glib
- *
- * GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * g_atomic_*: atomic operations.
- * Copyright (C) 2003 Sebastian Wilhelmi
- *
- * 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 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.
- */
-
-/************************************************************************
- * InterlockedCompareExchange
- *
- * Atomically compares Destination and Comperand, and if found equal exchanges
- * the value of Destination with Exchange
- *
- * RETURNS
- * Prior value of value pointed to by Destination
- */
-
-/*
- * LONG NTAPI InterlockedCompareExchange(LPLONG Destination, LONG Exchange, LONG Comperand)
- */
-
-#include <windows.h>
-LONG
-NTAPI
-InterlockedCompareExchange(
- LPLONG Destination,
- long Exchange,
- LONG Comperand)
-{
- LONG ret;
- __asm__ __volatile__ (
- "sync\n"
- "1: lwarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne 2f\n"
- " stwcx. %3,0,%1\n"
- " bne- 1b\n"
- "2: isync"
- : "=&r" (ret)
- : "b" (Destination), "r" (Comperand), "r" (Exchange)
- : "cr0", "memory");
- return ret;
-}
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
<group>
-<directory name="3rdparty">
- <xi:include href="3rdparty/3rdparty.rbuild" />
-</directory>
-<directory name="cmlib">
- <xi:include href="cmlib/cmlib.rbuild" />
-</directory>
-<directory name="crt">
- <xi:include href="crt/crt.rbuild" />
-</directory>
-<directory name="drivers">
- <xi:include href="drivers/directory.rbuild" />
-</directory>
-<directory name="dxguid">
- <xi:include href="dxguid/dxguid.rbuild" />
-</directory>
-<directory name="epsapi">
- <xi:include href="epsapi/epsapi.rbuild" />
-</directory>
-<directory name="fslib">
- <xi:include href="fslib/directory.rbuild" />
-</directory>
-<directory name="inflib">
- <xi:include href="inflib/inflib.rbuild" />
-</directory>
-<directory name="intrlck">
- <xi:include href="intrlck/intrlck.rbuild" />
-</directory>
-<directory name="libwine">
- <xi:include href="libwine/libwine.rbuild" />
-</directory>
-<directory name="mingw">
- <xi:include href="mingw/mingw.rbuild" />
-</directory>
-<directory name="nt">
- <xi:include href="nt/nt.rbuild" />
-</directory>
-<directory name="pseh">
- <xi:include href="pseh/pseh.rbuild" />
-</directory>
-<directory name="recyclebin">
- <xi:include href="recyclebin/recyclebin.rbuild" />
-</directory>
-<directory name="rossym">
- <xi:include href="rossym/rossym.rbuild" />
-</directory>
-<directory name="rtl">
- <xi:include href="rtl/rtl.rbuild" />
-</directory>
-<directory name="smlib">
- <xi:include href="smlib/smlib.rbuild" />
-</directory>
-<directory name="string">
- <xi:include href="string/string.rbuild" />
-</directory>
-<directory name="strmiids">
- <xi:include href="strmiids/strmiids.rbuild" />
-</directory>
-<directory name="uuid">
- <xi:include href="uuid/uuid.rbuild" />
-</directory>
-<directory name="wdmguid">
- <xi:include href="wdmguid/wdmguid.rbuild" />
-</directory>
-<directory name="debugsup">
- <xi:include href="debugsup/debugsup.rbuild" />
-</directory>
+ <directory name="3rdparty">
+ <xi:include href="3rdparty/3rdparty.rbuild" />
+ </directory>
+ <directory name="sdk">
+ <xi:include href="sdk/sdk.rbuild" />
+ </directory>
+ <directory name="cmlib">
+ <xi:include href="cmlib/cmlib.rbuild" />
+ </directory>
+ <directory name="debugsup">
+ <xi:include href="debugsup/debugsup.rbuild" />
+ </directory>
+ <directory name="drivers">
+ <xi:include href="drivers/directory.rbuild" />
+ </directory>
+ <directory name="epsapi">
+ <xi:include href="epsapi/epsapi.rbuild" />
+ </directory>
+ <directory name="fslib">
+ <xi:include href="fslib/directory.rbuild" />
+ </directory>
+ <directory name="inflib">
+ <xi:include href="inflib/inflib.rbuild" />
+ </directory>
+ <directory name="libcntpr">
+ <xi:include href="libcntpr/libcntpr.rbuild" />
+ </directory>
+ <directory name="pseh">
+ <xi:include href="pseh/pseh.rbuild" />
+ </directory>
+ <directory name="recyclebin">
+ <xi:include href="recyclebin/recyclebin.rbuild" />
+ </directory>
+ <directory name="rossym">
+ <xi:include href="rossym/rossym.rbuild" />
+ </directory>
+ <directory name="rtl">
+ <xi:include href="rtl/rtl.rbuild" />
+ </directory>
+ <directory name="smlib">
+ <xi:include href="smlib/smlib.rbuild" />
+ </directory>
</group>
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/alldiv_asm.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
- .globl __alldiv
- .globl __fltused
-
- /* DATA ********************************************************************/
-
-__fltused:
- .long 0x9875
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// lldiv - signed long divide
-//
-// Purpose:
-// Does a signed long divide of the arguments. Arguments are
-// not changed.
-//
-// Entry:
-// Arguments are passed on the stack:
-// 1st pushed: divisor (QWORD)
-// 2nd pushed: dividend (QWORD)
-//
-// Exit:
-// EDX:EAX contains the quotient (dividend/divisor)
-// NOTE: this routine removes the parameters from the stack.
-//
-// Uses:
-// ECX
-//
-
-__alldiv:
-
- push edi
- push esi
- push ebx
-
-// Set up the local stack and save the index registers. When this is done
-// the stack frame will look as follows (assuming that the expression a/b will
-// generate a call to lldiv(a, b)):
-//
-// -----------------
-// | |
-// |---------------|
-// | |
-// |--divisor (b)--|
-// | |
-// |---------------|
-// | |
-// |--dividend (a)-|
-// | |
-// |---------------|
-// | return addr** |
-// |---------------|
-// | EDI |
-// |---------------|
-// | ESI |
-// |---------------|
-// ESP---->| EBX |
-// -----------------
-//
-
-#define DVNDLO [esp + 16] // stack address of dividend (a)
-#define DVNDHI [esp + 20] // stack address of dividend (a)
-#define DVSRLO [esp + 24] // stack address of divisor (b)
-#define DVSRHI [esp + 28] // stack address of divisor (b)
-
-// Determine sign of the result (edi = 0 if result is positive, non-zero
-// otherwise) and make operands positive.
-
- xor edi,edi // result sign assumed positive
-
- mov eax,DVNDHI // hi word of a
- or eax,eax // test to see if signed
- jge short L1 // skip rest if a is already positive
- inc edi // complement result sign flag
- mov edx,DVNDLO // lo word of a
- neg eax // make a positive
- neg edx
- sbb eax,0
- mov DVNDHI,eax // save positive value
- mov DVNDLO,edx
-L1:
- mov eax,DVSRHI // hi word of b
- or eax,eax // test to see if signed
- jge short L2 // skip rest if b is already positive
- inc edi // complement the result sign flag
- mov edx,DVSRLO // lo word of a
- neg eax // make b positive
- neg edx
- sbb eax,0
- mov DVSRHI,eax // save positive value
- mov DVSRLO,edx
-L2:
-
-//
-// Now do the divide. First look to see if the divisor is less than 4194304K.
-// If so, then we can use a simple algorithm with word divides, otherwise
-// things get a little more complex.
-//
-// NOTE - eax currently contains the high order word of DVSR
-//
-
- or eax,eax // check to see if divisor < 4194304K
- jnz short L3 // nope, gotta do this the hard way
- mov ecx,DVSRLO // load divisor
- mov eax,DVNDHI // load high word of dividend
- xor edx,edx
- div ecx // eax <- high order bits of quotient
- mov ebx,eax // save high bits of quotient
- mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
- div ecx // eax <- low order bits of quotient
- mov edx,ebx // edx:eax <- quotient
- jmp short L4 // set sign, restore stack and return
-
-//
-// Here we do it the hard way. Remember, eax contains the high word of DVSR
-//
-
-L3:
- mov ebx,eax // ebx:ecx <- divisor
- mov ecx,DVSRLO
- mov edx,DVNDHI // edx:eax <- dividend
- mov eax,DVNDLO
-L5:
- shr ebx,1 // shift divisor right one bit
- rcr ecx,1
- shr edx,1 // shift dividend right one bit
- rcr eax,1
- or ebx,ebx
- jnz short L5 // loop until divisor < 4194304K
- div ecx // now divide, ignore remainder
- mov esi,eax // save quotient
-
-//
-// We may be off by one, so to check, we will multiply the quotient
-// by the divisor and check the result against the orignal dividend
-// Note that we must also check for overflow, which can occur if the
-// dividend is close to 2**64 and the quotient is off by 1.
-//
-
- mul dword ptr DVSRHI // QUOT * DVSRHI
- mov ecx,eax
- mov eax,DVSRLO
- mul esi // QUOT * DVSRLO
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jc short L6 // carry means Quotient is off by 1
-
-//
-// do long compare here between original dividend and the result of the
-// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
-// subtract one (1) from the quotient.
-//
-
- cmp edx,DVNDHI // compare hi words of result and original
- ja short L6 // if result > original, do subtract
- jb short L7 // if result < original, we are ok
- cmp eax,DVNDLO // hi words are equal, compare lo words
- jbe short L7 // if less or equal we are ok, else subtract
-L6:
- dec esi // subtract 1 from quotient
-L7:
- xor edx,edx // edx:eax <- quotient
- mov eax,esi
-
-//
-// Just the cleanup left to do. edx:eax contains the quotient. Set the sign
-// according to the save value, cleanup the stack, and return.
-//
-
-L4:
- dec edi // check to see if result is negative
- jnz short L8 // if EDI == 0, result should be negative
- neg edx // otherwise, negate the result
- neg eax
- sbb edx,0
-
-//
-// Restore the saved registers and return.
-//
-
-L8:
- pop ebx
- pop esi
- pop edi
-
- ret 16
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/alldvrm.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __alldvrm
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-__alldvrm:
- push edi
- push esi
- push ebp
-
-// Set up the local stack and save the index registers. When this is done
-// the stack frame will look as follows (assuming that the expression a/b will
-// generate a call to alldvrm(a, b)):
-//
-// -----------------
-// | |
-// |---------------|
-// | |
-// |--divisor (b)--|
-// | |
-// |---------------|
-// | |
-// |--dividend (a)-|
-// | |
-// |---------------|
-// | return addr** |
-// |---------------|
-// | EDI |
-// |---------------|
-// | ESI |
-// |---------------|
-// ESP---->| EBP |
-// -----------------
-//
-
-#undef DVNDLO
-#undef DVNDHI
-#undef DVSRLO
-#undef DVSRHI
-#define DVNDLO [esp + 16] // stack address of dividend (a)
-#define DVNDHI [esp + 20] // stack address of dividend (a)
-#define DVSRLO [esp + 24] // stack address of divisor (b)
-#define DVSRHI [esp + 28] // stack address of divisor (b)
-
-// Determine sign of the quotient (edi = 0 if result is positive, non-zero
-// otherwise) and make operands positive.
-// Sign of the remainder is kept in ebp.
-
- xor edi,edi // result sign assumed positive
- xor ebp,ebp // result sign assumed positive
-
- mov eax,DVNDHI // hi word of a
- or eax,eax // test to see if signed
- jge short ....L1 // skip rest if a is already positive
- inc edi // complement result sign flag
- inc ebp // complement result sign flag
- mov edx,DVNDLO // lo word of a
- neg eax // make a positive
- neg edx
- sbb eax,0
- mov DVNDHI,eax // save positive value
- mov DVNDLO,edx
-....L1:
- mov eax,DVSRHI // hi word of b
- or eax,eax // test to see if signed
- jge short ....L2 // skip rest if b is already positive
- inc edi // complement the result sign flag
- mov edx,DVSRLO // lo word of a
- neg eax // make b positive
- neg edx
- sbb eax,0
- mov DVSRHI,eax // save positive value
- mov DVSRLO,edx
-....L2:
-
-//
-// Now do the divide. First look to see if the divisor is less than 4194304K.
-// If so, then we can use a simple algorithm with word divides, otherwise
-// things get a little more complex.
-//
-// NOTE - eax currently contains the high order word of DVSR
-//
-
- or eax,eax // check to see if divisor < 4194304K
- jnz short ....L3 // nope, gotta do this the hard way
- mov ecx,DVSRLO // load divisor
- mov eax,DVNDHI // load high word of dividend
- xor edx,edx
- div ecx // eax <- high order bits of quotient
- mov ebx,eax // save high bits of quotient
- mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
- div ecx // eax <- low order bits of quotient
- mov esi,eax // ebx:esi <- quotient
-//
-// Now we need to do a multiply so that we can compute the remainder.
-//
- mov eax,ebx // set up high word of quotient
- mul dword ptr DVSRLO // HIWORD(QUOT) * DVSR
- mov ecx,eax // save the result in ecx
- mov eax,esi // set up low word of quotient
- mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jmp short ....L4 // complete remainder calculation
-
-//
-// Here we do it the hard way. Remember, eax contains the high word of DVSR
-//
-
-....L3:
- mov ebx,eax // ebx:ecx <- divisor
- mov ecx,DVSRLO
- mov edx,DVNDHI // edx:eax <- dividend
- mov eax,DVNDLO
-....L5:
- shr ebx,1 // shift divisor right one bit
- rcr ecx,1
- shr edx,1 // shift dividend right one bit
- rcr eax,1
- or ebx,ebx
- jnz short ....L5 // loop until divisor < 4194304K
- div ecx // now divide, ignore remainder
- mov esi,eax // save quotient
-
-//
-// We may be off by one, so to check, we will multiply the quotient
-// by the divisor and check the result against the orignal dividend
-// Note that we must also check for overflow, which can occur if the
-// dividend is close to 2**64 and the quotient is off by 1.
-//
-
- mul dword ptr DVSRHI // QUOT * DVSRHI
- mov ecx,eax
- mov eax,DVSRLO
- mul esi // QUOT * DVSRLO
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jc short ....L6 // carry means Quotient is off by 1
-
-//
-// do long compare here between original dividend and the result of the
-// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
-// subtract one (1) from the quotient.
-//
-
- cmp edx,DVNDHI // compare hi words of result and original
- ja short ....L6 // if result > original, do subtract
- jb short ....L7 // if result < original, we are ok
- cmp eax,DVNDLO // hi words are equal, compare lo words
- jbe short ....L7 // if less or equal we are ok, else subtract
-....L6:
- dec esi // subtract 1 from quotient
- sub eax,DVSRLO // subtract divisor from result
- sbb edx,DVSRHI
-....L7:
- xor ebx,ebx // ebx:esi <- quotient
-
-....L4:
-//
-// Calculate remainder by subtracting the result from the original dividend.
-// Since the result is already in a register, we will do the subtract in the
-// opposite direction and negate the result if necessary.
-//
-
- sub eax,DVNDLO // subtract dividend from result
- sbb edx,DVNDHI
-
-//
-// Now check the result sign flag to see if the result is supposed to be positive
-// or negative. It is currently negated (because we subtracted in the 'wrong'
-// direction), so if the sign flag is set we are done, otherwise we must negate
-// the result to make it positive again.
-//
-
- dec ebp // check result sign flag
- jns short ....L9 // result is ok, set up the quotient
- neg edx // otherwise, negate the result
- neg eax
- sbb edx,0
-
-//
-// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
-//
-....L9:
- mov ecx,edx
- mov edx,ebx
- mov ebx,ecx
- mov ecx,eax
- mov eax,esi
-
-//
-// Just the cleanup left to do. edx:eax contains the quotient. Set the sign
-// according to the save value, cleanup the stack, and return.
-//
-
- dec edi // check to see if result is negative
- jnz short ....L8 // if EDI == 0, result should be negative
- neg edx // otherwise, negate the result
- neg eax
- sbb edx,0
-
-//
-// Restore the saved registers and return.
-//
-
-....L8:
- pop ebp
- pop esi
- pop edi
-
- ret 16
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/allmul.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __allmul
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// llmul - long multiply routine
-//
-// Purpose:
-// Does a long multiply (same for signed/unsigned)
-// Parameters are not changed.
-//
-// Entry:
-// Parameters are passed on the stack:
-// 1st pushed: multiplier (QWORD)
-// 2nd pushed: multiplicand (QWORD)
-//
-// Exit:
-// EDX:EAX - product of multiplier and multiplicand
-// NOTE: parameters are removed from the stack
-//
-// Uses:
-// ECX
-//
-
-__allmul:
-
-#define ALO [esp + 4] // stack address of a
-#define AHI [esp + 8] // stack address of a
-#define BLO [esp + 12] // stack address of b
-#define BHI [esp + 16] // stack address of b
-
-//
-// AHI, BHI : upper 32 bits of A and B
-// ALO, BLO : lower 32 bits of A and B
-//
-// ALO * BLO
-// ALO * BHI
-// + BLO * AHI
-// ---------------------
-//
-
- mov eax,AHI
- mov ecx,BHI
- or ecx,eax //test for both hiwords zero.
- mov ecx,BLO
- jnz short hard //both are zero, just mult ALO and BLO
-
- mov eax,AHI
- mul ecx
-
- ret 16 // callee restores the stack
-
-hard:
- push ebx
-
-// must redefine A and B since esp has been altered
-
-#define A2LO [esp + 4] // stack address of a
-#define A2HI [esp + 8] // stack address of a
-#define B2LO [esp + 12] // stack address of b
-#define B2HI [esp + 16] // stack address of b
-
- mul ecx //eax has AHI, ecx has BLO, so AHI * BLO
- mov ebx,eax //save result
-
- mov eax,A2LO
- mul dword ptr B2HI //ALO * BHI
- add ebx,eax //ebx = ((ALO * BHI) + (AHI * BLO))
-
- mov eax,A2LO //ecx = BLO
- mul ecx //so edx:eax = ALO*BLO
- add edx,ebx //now edx has all the LO*HI stuff
-
- pop ebx
-
- ret 16 // callee restores the stack
-
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/allrem.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __allrem
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// llrem - signed long remainder
-//
-// Purpose:
-// Does a signed long remainder of the arguments. Arguments are
-// not changed.
-//
-// Entry:
-// Arguments are passed on the stack:
-// 1st pushed: divisor (QWORD)
-// 2nd pushed: dividend (QWORD)
-//
-// Exit:
-// EDX:EAX contains the remainder (dividend%divisor)
-// NOTE: this routine removes the parameters from the stack.
-//
-// Uses:
-// ECX
-//
-
-__allrem :
-
- push ebx
- push edi
-
-// Set up the local stack and save the index registers. When this is done
-// the stack frame will look as follows (assuming that the expression a%b will
-// generate a call to lrem(a, b)):
-//
-// -----------------
-// | |
-// |---------------|
-// | |
-// |--divisor (b)--|
-// | |
-// |---------------|
-// | |
-// |--dividend (a)-|
-// | |
-// |---------------|
-// | return addr** |
-// |---------------|
-// | EBX |
-// |---------------|
-// ESP---->| EDI |
-// -----------------
-//
-
-#undef DVNDLO
-#undef DVNDHI
-#undef DVSRLO
-#undef DVSRHI
-#define DVNDLO [esp + 12] // stack address of dividend (a)
-#define DVNDHI [esp + 16] // stack address of dividend (a)
-#define DVSRLO [esp + 20] // stack address of divisor (b)
-#define DVSRHI [esp + 24] // stack address of divisor (b)
-
-// Determine sign of the result (edi = 0 if result is positive, non-zero
-// otherwise) and make operands positive.
-
- xor edi,edi // result sign assumed positive
-
- mov eax,DVNDHI // hi word of a
- or eax,eax // test to see if signed
- jge short .L1 // skip rest if a is already positive
- inc edi // complement result sign flag bit
- mov edx,DVNDLO // lo word of a
- neg eax // make a positive
- neg edx
- sbb eax,0
- mov DVNDHI,eax // save positive value
- mov DVNDLO,edx
-.L1:
- mov eax,DVSRHI // hi word of b
- or eax,eax // test to see if signed
- jge short .L2 // skip rest if b is already positive
- mov edx,DVSRLO // lo word of b
- neg eax // make b positive
- neg edx
- sbb eax,0
- mov DVSRHI,eax // save positive value
- mov DVSRLO,edx
-.L2:
-
-//
-// Now do the divide. First look to see if the divisor is less than 4194304K.
-// If so, then we can use a simple algorithm with word divides, otherwise
-// things get a little more complex.
-//
-// NOTE - eax currently contains the high order word of DVSR
-//
-
- or eax,eax // check to see if divisor < 4194304K
- jnz short .L3 // nope, gotta do this the hard way
- mov ecx,DVSRLO // load divisor
- mov eax,DVNDHI // load high word of dividend
- xor edx,edx
- div ecx // edx <- remainder
- mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
- div ecx // edx <- final remainder
- mov eax,edx // edx:eax <- remainder
- xor edx,edx
- dec edi // check result sign flag
- jns short .L4 // negate result, restore stack and return
- jmp short .L8 // result sign ok, restore stack and return
-
-//
-// Here we do it the hard way. Remember, eax contains the high word of DVSR
-//
-
-.L3:
- mov ebx,eax // ebx:ecx <- divisor
- mov ecx,DVSRLO
- mov edx,DVNDHI // edx:eax <- dividend
- mov eax,DVNDLO
-.L5:
- shr ebx,1 // shift divisor right one bit
- rcr ecx,1
- shr edx,1 // shift dividend right one bit
- rcr eax,1
- or ebx,ebx
- jnz short .L5 // loop until divisor < 4194304K
- div ecx // now divide, ignore remainder
-
-//
-// We may be off by one, so to check, we will multiply the quotient
-// by the divisor and check the result against the orignal dividend
-// Note that we must also check for overflow, which can occur if the
-// dividend is close to 2**64 and the quotient is off by 1.
-//
-
- mov ecx,eax // save a copy of quotient in ECX
- mul dword ptr DVSRHI
- xchg ecx,eax // save product, get quotient in EAX
- mul dword ptr DVSRLO
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jc short .L6 // carry means Quotient is off by 1
-
-//
-// do long compare here between original dividend and the result of the
-// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
-// subtract the original divisor from the result.
-//
-
- cmp edx,DVNDHI // compare hi words of result and original
- ja short .L6 // if result > original, do subtract
- jb short .L7 // if result < original, we are ok
- cmp eax,DVNDLO // hi words are equal, compare lo words
- jbe short .L7 // if less or equal we are ok, else subtract
-.L6:
- sub eax,DVSRLO // subtract divisor from result
- sbb edx,DVSRHI
-.L7:
-
-//
-// Calculate remainder by subtracting the result from the original dividend.
-// Since the result is already in a register, we will do the subtract in the
-// opposite direction and negate the result if necessary.
-//
-
- sub eax,DVNDLO // subtract dividend from result
- sbb edx,DVNDHI
-
-//
-// Now check the result sign flag to see if the result is supposed to be positive
-// or negative. It is currently negated (because we subtracted in the 'wrong'
-// direction), so if the sign flag is set we are done, otherwise we must negate
-// the result to make it positive again.
-//
-
- dec edi // check result sign flag
- jns short .L8 // result is ok, restore stack and return
-.L4:
- neg edx // otherwise, negate the result
- neg eax
- sbb edx,0
-
-//
-// Just the cleanup left to do. edx:eax contains the quotient.
-// Restore the saved registers and return.
-//
-
-.L8:
- pop edi
- pop ebx
-
- ret 16
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/allshl.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __allshl
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// llshl - long shift left
-//
-// Purpose:
-// Does a Long Shift Left (signed and unsigned are identical)
-// Shifts a long left any number of bits.
-//
-// Entry:
-// EDX:EAX - long value to be shifted
-// CL - number of bits to shift by
-//
-// Exit:
-// EDX:EAX - shifted value
-//
-// Uses:
-// CL is destroyed.
-//
-
-__allshl:
-
-//
-// Handle shifts of 64 or more bits (all get 0)
-//
- cmp cl, 64
- jae short RETZERO
-
-//
-// Handle shifts of between 0 and 31 bits
-//
- cmp cl, 32
- jae short MORE32
- shld edx,eax,cl
- shl eax,cl
- ret
-
-//
-// Handle shifts of between 32 and 63 bits
-//
-MORE32:
- mov edx,eax
- xor eax,eax
- and cl,31
- shl edx,cl
- ret
-
-//
-// return 0 in edx:eax
-//
-RETZERO:
- xor eax,eax
- xor edx,edx
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/allshr.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __allshr
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// llshr - long shift right
-//
-// Purpose:
-// Does a signed Long Shift Right
-// Shifts a long right any number of bits.
-//
-// Entry:
-// EDX:EAX - long value to be shifted
-// CL - number of bits to shift by
-//
-// Exit:
-// EDX:EAX - shifted value
-//
-// Uses:
-// CL is destroyed.
-//
-
-__allshr:
-
-//
-// Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
-// depends only on the high order bit of edx).
-//
- cmp cl,64
- jae short .RETSIGN
-
-//
-// Handle shifts of between 0 and 31 bits
-//
- cmp cl, 32
- jae short .MORE32
- shrd eax,edx,cl
- sar edx,cl
- ret
-
-//
-// Handle shifts of between 32 and 63 bits
-//
-.MORE32:
- mov eax,edx
- sar edx,31
- and cl,31
- sar eax,cl
- ret
-
-//
-// Return double precision 0 or -1, depending on the sign of edx
-//
-.RETSIGN:
- sar edx,31
- mov eax,edx
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/atan.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _atan
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_atan:
- push ebp
- mov ebp,esp
- fld qword ptr [ebp+8] // Load real from stack
- fld1 // Load constant 1
- fpatan // Take the arctangent
- pop ebp
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/aulldiv_asm.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
- .globl __aulldiv
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// ulldiv - unsigned long divide
-//
-// Purpose:
-// Does a unsigned long divide of the arguments. Arguments are
-// not changed.
-//
-// Entry:
-// Arguments are passed on the stack:
-// 1st pushed: divisor (QWORD)
-// 2nd pushed: dividend (QWORD)
-//
-// Exit:
-// EDX:EAX contains the quotient (dividend/divisor)
-// NOTE: this routine removes the parameters from the stack.
-//
-// Uses:
-// ECX
-//
-
-__aulldiv:
-
- push ebx
- push esi
-
-// Set up the local stack and save the index registers. When this is done
-// the stack frame will look as follows (assuming that the expression a/b will
-// generate a call to uldiv(a, b)):
-//
-// -----------------
-// | |
-// |---------------|
-// | |
-// |--divisor (b)--|
-// | |
-// |---------------|
-// | |
-// |--dividend (a)-|
-// | |
-// |---------------|
-// | return addr** |
-// |---------------|
-// | EBX |
-// |---------------|
-// ESP---->| ESI |
-// -----------------
-//
-
-#undef DVNDLO
-#undef DVNDHI
-#undef DVSRLO
-#undef DVSRHI
-#define DVNDLO [esp + 12] // stack address of dividend (a)
-#define DVNDHI [esp + 16] // stack address of dividend (a)
-#define DVSRLO [esp + 20] // stack address of divisor (b)
-#define DVSRHI [esp + 24] // stack address of divisor (b)
-
-//
-// Now do the divide. First look to see if the divisor is less than 4194304K.
-// If so, then we can use a simple algorithm with word divides, otherwise
-// things get a little more complex.
-//
-
- mov eax,DVSRHI // check to see if divisor < 4194304K
- or eax,eax
- jnz short ..L1 // nope, gotta do this the hard way
- mov ecx,DVSRLO // load divisor
- mov eax,DVNDHI // load high word of dividend
- xor edx,edx
- div ecx // get high order bits of quotient
- mov ebx,eax // save high bits of quotient
- mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
- div ecx // get low order bits of quotient
- mov edx,ebx // edx:eax <- quotient hi:quotient lo
- jmp short ..L2 // restore stack and return
-
-//
-// Here we do it the hard way. Remember, eax contains DVSRHI
-//
-
-..L1:
- mov ecx,eax // ecx:ebx <- divisor
- mov ebx,DVSRLO
- mov edx,DVNDHI // edx:eax <- dividend
- mov eax,DVNDLO
-..L3:
- shr ecx,1 // shift divisor right one bit// hi bit <- 0
- rcr ebx,1
- shr edx,1 // shift dividend right one bit// hi bit <- 0
- rcr eax,1
- or ecx,ecx
- jnz short ..L3 // loop until divisor < 4194304K
- div ebx // now divide, ignore remainder
- mov esi,eax // save quotient
-
-//
-// We may be off by one, so to check, we will multiply the quotient
-// by the divisor and check the result against the orignal dividend
-// Note that we must also check for overflow, which can occur if the
-// dividend is close to 2**64 and the quotient is off by 1.
-//
-
- mul dword ptr DVSRHI // QUOT * DVSRHI
- mov ecx,eax
- mov eax,DVSRLO
- mul esi // QUOT * DVSRLO
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jc short ..L4 // carry means Quotient is off by 1
-
-//
-// do long compare here between original dividend and the result of the
-// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
-// subtract one (1) from the quotient.
-//
-
- cmp edx,DVNDHI // compare hi words of result and original
- ja short ..L4 // if result > original, do subtract
- jb short ..L5 // if result < original, we are ok
- cmp eax,DVNDLO // hi words are equal, compare lo words
- jbe short ..L5 // if less or equal we are ok, else subtract
-..L4:
- dec esi // subtract 1 from quotient
-..L5:
- xor edx,edx // edx:eax <- quotient
- mov eax,esi
-
-//
-// Just the cleanup left to do. edx:eax contains the quotient.
-// Restore the saved registers and return.
-//
-
-..L2:
-
- pop esi
- pop ebx
-
- ret 16
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/aulldvrm.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __aulldvrm
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-__aulldvrm:
-
-// ulldvrm - unsigned long divide and remainder
-//
-// Purpose:
-// Does a unsigned long divide and remainder of the arguments. Arguments
-// are not changed.
-//
-// Entry:
-// Arguments are passed on the stack:
-// 1st pushed: divisor (QWORD)
-// 2nd pushed: dividend (QWORD)
-//
-// Exit:
-// EDX:EAX contains the quotient (dividend/divisor)
-// EBX:ECX contains the remainder (divided % divisor)
-// NOTE: this routine removes the parameters from the stack.
-//
-// Uses:
-// ECX
-//
- push esi
-
-// Set up the local stack and save the index registers. When this is done
-// the stack frame will look as follows (assuming that the expression a/b will
-// generate a call to aulldvrm(a, b)):
-//
-// -----------------
-// | |
-// |---------------|
-// | |
-// |--divisor (b)--|
-// | |
-// |---------------|
-// | |
-// |--dividend (a)-|
-// | |
-// |---------------|
-// | return addr** |
-// |---------------|
-// ESP---->| ESI |
-// -----------------
-//
-
-#undef DVNDLO
-#undef DVNDHI
-#undef DVSRLO
-#undef DVSRHI
-#define DVNDLO [esp + 8] // stack address of dividend (a)
-#define DVNDHI [esp + 8] // stack address of dividend (a)
-#define DVSRLO [esp + 16] // stack address of divisor (b)
-#define DVSRHI [esp + 20] // stack address of divisor (b)
-
-//
-// Now do the divide. First look to see if the divisor is less than 4194304K.
-// If so, then we can use a simple algorithm with word divides, otherwise
-// things get a little more complex.
-//
-
- mov eax,DVSRHI // check to see if divisor < 4194304K
- or eax,eax
- jnz short .....L1 // nope, gotta do this the hard way
- mov ecx,DVSRLO // load divisor
- mov eax,DVNDHI // load high word of dividend
- xor edx,edx
- div ecx // get high order bits of quotient
- mov ebx,eax // save high bits of quotient
- mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
- div ecx // get low order bits of quotient
- mov esi,eax // ebx:esi <- quotient
-
-//
-// Now we need to do a multiply so that we can compute the remainder.
-//
- mov eax,ebx // set up high word of quotient
- mul dword ptr DVSRLO // HIWORD(QUOT) * DVSR
- mov ecx,eax // save the result in ecx
- mov eax,esi // set up low word of quotient
- mul dword ptr DVSRLO // LOWORD(QUOT) * DVSR
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jmp short .....L2 // complete remainder calculation
-
-//
-// Here we do it the hard way. Remember, eax contains DVSRHI
-//
-
-.....L1:
- mov ecx,eax // ecx:ebx <- divisor
- mov ebx,DVSRLO
- mov edx,DVNDHI // edx:eax <- dividend
- mov eax,DVNDLO
-.....L3:
- shr ecx,1 // shift divisor right one bit// hi bit <- 0
- rcr ebx,1
- shr edx,1 // shift dividend right one bit// hi bit <- 0
- rcr eax,1
- or ecx,ecx
- jnz short .....L3 // loop until divisor < 4194304K
- div ebx // now divide, ignore remainder
- mov esi,eax // save quotient
-
-//
-// We may be off by one, so to check, we will multiply the quotient
-// by the divisor and check the result against the orignal dividend
-// Note that we must also check for overflow, which can occur if the
-// dividend is close to 2**64 and the quotient is off by 1.
-//
-
- mul dword ptr DVSRHI // QUOT * DVSRHI
- mov ecx,eax
- mov eax,DVSRLO
- mul esi // QUOT * DVSRLO
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jc short .....L4 // carry means Quotient is off by 1
-
-//
-// do long compare here between original dividend and the result of the
-// multiply in edx:eax. If original is larger or equal, we are ok, otherwise
-// subtract one (1) from the quotient.
-//
-
- cmp edx,DVNDHI // compare hi words of result and original
- ja short .....L4 // if result > original, do subtract
- jb short .....L5 // if result < original, we are ok
- cmp eax,DVNDLO // hi words are equal, compare lo words
- jbe short .....L5 // if less or equal we are ok, else subtract
-.....L4:
- dec esi // subtract 1 from quotient
- sub eax,DVSRLO // subtract divisor from result
- sbb edx,DVSRHI
-.....L5:
- xor ebx,ebx // ebx:esi <- quotient
-
-.....L2:
-//
-// Calculate remainder by subtracting the result from the original dividend.
-// Since the result is already in a register, we will do the subtract in the
-// opposite direction and negate the result.
-//
-
- sub eax,DVNDLO // subtract dividend from result
- sbb edx,DVNDHI
- neg edx // otherwise, negate the result
- neg eax
- sbb edx,0
-
-//
-// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
-//
- mov ecx,edx
- mov edx,ebx
- mov ebx,ecx
- mov ecx,eax
- mov eax,esi
-//
-// Just the cleanup left to do. edx:eax contains the quotient.
-// Restore the saved registers and return.
-//
-
- pop esi
-
- ret 16
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/aullrem.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __aullrem
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// ullrem - unsigned long remainder
-//
-// Purpose:
-// Does a unsigned long remainder of the arguments. Arguments are
-// not changed.
-//
-// Entry:
-// Arguments are passed on the stack:
-// 1st pushed: divisor (QWORD)
-// 2nd pushed: dividend (QWORD)
-//
-// Exit:
-// EDX:EAX contains the remainder (dividend%divisor)
-// NOTE: this routine removes the parameters from the stack.
-//
-// Uses:
-// ECX
-//
-
-__aullrem:
-
- push ebx
-
-// Set up the local stack and save the index registers. When this is done
-// the stack frame will look as follows (assuming that the expression a%b will
-// generate a call to ullrem(a, b)):
-//
-// -----------------
-// | |
-// |---------------|
-// | |
-// |--divisor (b)--|
-// | |
-// |---------------|
-// | |
-// |--dividend (a)-|
-// | |
-// |---------------|
-// | return addr** |
-// |---------------|
-// ESP---->| EBX |
-// -----------------
-//
-
-#undef DVNDLO
-#undef DVNDHI
-#undef DVSRLO
-#undef DVSRHI
-#define DVNDLO [esp + 8] // stack address of dividend (a)
-#define DVNDHI [esp + 8] // stack address of dividend (a)
-#define DVSRLO [esp + 16] // stack address of divisor (b)
-#define DVSRHI [esp + 20] // stack address of divisor (b)
-
-// Now do the divide. First look to see if the divisor is less than 4194304K.
-// If so, then we can use a simple algorithm with word divides, otherwise
-// things get a little more complex.
-//
-
- mov eax,DVSRHI // check to see if divisor < 4194304K
- or eax,eax
- jnz short ...L1 // nope, gotta do this the hard way
- mov ecx,DVSRLO // load divisor
- mov eax,DVNDHI // load high word of dividend
- xor edx,edx
- div ecx // edx <- remainder, eax <- quotient
- mov eax,DVNDLO // edx:eax <- remainder:lo word of dividend
- div ecx // edx <- final remainder
- mov eax,edx // edx:eax <- remainder
- xor edx,edx
- jmp short ...L2 // restore stack and return
-
-//
-// Here we do it the hard way. Remember, eax contains DVSRHI
-//
-
-...L1:
- mov ecx,eax // ecx:ebx <- divisor
- mov ebx,DVSRLO
- mov edx,DVNDHI // edx:eax <- dividend
- mov eax,DVNDLO
-...L3:
- shr ecx,1 // shift divisor right one bit// hi bit <- 0
- rcr ebx,1
- shr edx,1 // shift dividend right one bit// hi bit <- 0
- rcr eax,1
- or ecx,ecx
- jnz short ...L3 // loop until divisor < 4194304K
- div ebx // now divide, ignore remainder
-
-//
-// We may be off by one, so to check, we will multiply the quotient
-// by the divisor and check the result against the orignal dividend
-// Note that we must also check for overflow, which can occur if the
-// dividend is close to 2**64 and the quotient is off by 1.
-//
-
- mov ecx,eax // save a copy of quotient in ECX
- mul dword ptr DVSRHI
- xchg ecx,eax // put partial product in ECX, get quotient in EAX
- mul dword ptr DVSRLO
- add edx,ecx // EDX:EAX = QUOT * DVSR
- jc short ...L4 // carry means Quotient is off by 1
-
-//
-// do long compare here between original dividend and the result of the
-// multiply in edx:eax. If original is larger or equal, we're ok, otherwise
-// subtract the original divisor from the result.
-//
-
- cmp edx,DVNDHI // compare hi words of result and original
- ja short ...L4 // if result > original, do subtract
- jb short ...L5 // if result < original, we're ok
- cmp eax,DVNDLO // hi words are equal, compare lo words
- jbe short ...L5 // if less or equal we're ok, else subtract
-...L4:
- sub eax,DVSRLO // subtract divisor from result
- sbb edx,DVSRHI
-...L5:
-
-//
-// Calculate remainder by subtracting the result from the original dividend.
-// Since the result is already in a register, we will perform the subtract in
-// the opposite direction and negate the result to make it positive.
-//
-
- sub eax,DVNDLO // subtract original dividend from result
- sbb edx,DVNDHI
- neg edx // and negate it
- neg eax
- sbb edx,0
-
-//
-// Just the cleanup left to do. dx:ax contains the remainder.
-// Restore the saved registers and return.
-//
-
-...L2:
-
- pop ebx
-
- ret 16
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/uallshr.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __aullshr
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-//
-// ullshr - long shift right
-//
-// Purpose:
-// Does a unsigned Long Shift Right
-// Shifts a long right any number of bits.
-//
-// Entry:
-// EDX:EAX - long value to be shifted
-// CL - number of bits to shift by
-//
-// Exit:
-// EDX:EAX - shifted value
-//
-// Uses:
-// CL is destroyed.
-//
-
-__aullshr:
-
-//
-// Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
-// depends only on the high order bit of edx).
-//
- cmp cl,64
- jae short ..RETZERO
-
-//
-// Handle shifts of between 0 and 31 bits
-//
- cmp cl, 32
- jae short ..MORE32
- shrd eax,edx,cl
- shr edx,cl
- ret
-
-//
-// Handle shifts of between 32 and 63 bits
-//
-..MORE32:
- mov eax,edx
- xor edx,edx
- and cl,31
- shr eax,cl
- ret
-
-//
-// return 0 in edx:eax
-//
-..RETZERO:
- xor eax,eax
- xor edx,edx
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/ceil.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _ceil
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_ceil:
- push ebp
- mov ebp,esp
- sub esp,4 // Allocate temporary space
- fld qword ptr [ebp+8] // Load real from stack
- fstcw [ebp-2] // Save control word
- fclex // Clear exceptions
- mov word ptr [ebp-4],0xb63 // Rounding control word
- fldcw [ebp-4] // Set new rounding control
- frndint // Round to integer
- fclex // Clear exceptions
- fldcw [ebp-2] // Restore control word
- mov esp,ebp // Deallocate temporary space
- pop ebp
- ret
+++ /dev/null
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Stack checker
- * FILE: lib/ntdll/rtl/i386/chkstk.s
- * PROGRAMER: KJK::Hyperion <noog@libero.it>
- */
-
-.globl __chkstk
-.globl __alloca_probe
-
-/*
- _chkstk() is called by all stack allocations of more than 4 KB. It grows the
- stack in areas of 4 KB each, trying to access each area. This ensures that the
- guard page for the stack is hit, and the stack growing triggered
- */
-__chkstk:
-__alloca_probe:
-
-/* EAX = size to be allocated */
-/* save the ECX register */
- pushl %ecx
-
-/* ECX = top of the previous stack frame */
- leal 8(%esp), %ecx
-
-/* probe the desired memory, page by page */
- cmpl $0x1000, %eax
- jge .l_MoreThanAPage
- jmp .l_LessThanAPage
-
-.l_MoreThanAPage:
-
-/* raise the top of the stack by a page and probe */
- subl $0x1000, %ecx
- testl %eax, 0(%ecx)
-
-/* loop if still more than a page must be probed */
- subl $0x1000, %eax
- cmpl $0x1000, %eax
- jge .l_MoreThanAPage
-
-.l_LessThanAPage:
-
-/* raise the top of the stack by EAX bytes (size % 4096) and probe */
- subl %eax, %ecx
- testl %eax, 0(%ecx)
-
-/* EAX = top of the stack */
- movl %esp, %eax
-
-/* allocate the memory */
- movl %ecx, %esp
-
-/* restore ECX */
- movl 0(%eax), %ecx
-
-/* restore the return address */
- movl 4(%eax), %eax
- pushl %eax
-
-/* return */
- ret
-
-/* EOF */
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/cos.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _cos
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_cos:
- push ebp
- mov ebp,esp // Point to the stack frame
- fld qword ptr [ebp+8] // Load real from stack
- fcos // Take the cosine
- pop ebp
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/fabs.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _fabs
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_fabs:
- push ebp
- mov ebp,esp
- fld qword ptr [ebp+8] // Load real from stack
- fabs // Take the absolute value
- pop ebp
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/floor.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _floor
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_floor:
- push ebp
- mov ebp,esp
- sub esp,4 // Allocate temporary space
- fld qword ptr [ebp+8] // Load real from stack
- fstcw [ebp-2] // Save control word
- fclex // Clear exceptions
- mov word ptr [ebp-4],0x763 // Rounding control word
- fldcw [ebp-4] // Set new rounding control
- frndint // Round to integer
- fclex // Clear exceptions
- fldcw [ebp-2] // Restore control word
- mov esp,ebp
- pop ebp
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/ftol.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl __ftol
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-/*
- * This routine is called by MSVC-generated code to convert from floating point
- * to integer representation. The floating point number to be converted is
- * on the top of the floating point stack.
- */
-__ftol:
- /* Set up stack frame */
- push ebp
- mov ebp, esp
-
- /* Set "round towards zero" mode */
- fstcw [ebp-2]
- wait
- mov ax, [ebp-2]
- or ah, 0xC
- mov [ebp-4], ax
- fldcw [ebp-4]
-
- /* Do the conversion */
- fistp qword ptr [ebp-12]
-
- /* Restore rounding mode */
- fldcw [ebp-2]
-
- /* Return value */
- mov eax, [ebp-12]
- mov edx, [ebp-8]
-
- /* Remove stack frame and return*/
- leave
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/log.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _log
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_log:
- push ebp
- mov ebp,esp
- fld qword ptr [ebp+8] // Load real from stack
- fldln2 // Load log base e of 2
- fxch st(1) // Exchange st, st(1)
- fyl2x // Compute the natural log(x)
- pop ebp
- ret
+++ /dev/null
-/*\r
- * COPYRIGHT: See COPYING in the top level directory\r
- * PROJECT: ReactOS CRT\r
- * FILE: lib/crt/misc/i386/seh.S\r
- * PURPOSE: SEH Support for the CRT\r
- * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)\r
- */\r
-\r
-/* INCLUDES ******************************************************************/\r
-\r
-#include <ndk/asm.h>\r
-.intel_syntax noprefix\r
-\r
-#define DISPOSITION_DISMISS 0\r
-#define DISPOSITION_CONTINUE_SEARCH 1\r
-#define DISPOSITION_COLLIDED_UNWIND 3\r
-\r
-/* GLOBALS *******************************************************************/\r
-\r
-.globl __global_unwind2\r
-.globl __local_unwind2\r
-.globl __abnormal_termination\r
-.globl __except_handler2\r
-.globl __except_handler3\r
-\r
-/* FUNCTIONS *****************************************************************/\r
-\r
-.func unwind_handler\r
-_unwind_handler:\r
-\r
- /* Check if we were unwinding and continue search if not */\r
- mov ecx, [esp+4]\r
- test dword ptr [ecx+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING\r
- mov eax, DISPOSITION_CONTINUE_SEARCH\r
- jz unwind_handler_return\r
-\r
- /* We have a collision, do a local unwind */\r
- mov eax, [esp+20]\r
- push ebp\r
- mov ebp, [eax+16]\r
- mov edx, [eax+40]\r
- push edx\r
- mov edx, [eax+36]\r
- push edx\r
- call __local_unwind2\r
- add esp, 8\r
- pop ebp\r
-\r
- /* Set new try level */\r
- mov eax, [esp+8]\r
- mov edx, [esp+16]\r
- mov [edx], eax\r
-\r
- /* Return collided unwind */\r
- mov eax, DISPOSITION_COLLIDED_UNWIND\r
-\r
-unwind_handler_return:\r
- ret\r
-.endfunc\r
-\r
-.func _global_unwind2\r
-__global_unwind2:\r
-\r
- /* Create stack and save all registers */\r
- push ebp\r
- mov ebp, esp\r
- push ebx\r
- push esi\r
- push edi\r
- push ebp\r
-\r
- /* Call unwind */\r
- push 0\r
- push 0\r
- push glu_return\r
- push [ebp+8]\r
- call _RtlUnwind@16\r
-\r
-glu_return:\r
- /* Restore registers and return */\r
- pop ebp\r
- pop esi\r
- pop edi\r
- pop ebx\r
- mov esp, ebp\r
- pop ebp\r
- ret\r
-.endfunc\r
-\r
-.func _abnormal_termination\r
-__abnormal_termination:\r
-\r
- /* Assume false */\r
- xor eax, eax\r
-\r
- /* Check if the handler is the unwind handler */\r
- mov ecx, fs:0\r
- cmp dword ptr [ecx+4], offset _unwind_handler\r
- jne short ab_return\r
-\r
- /* Get the try level */\r
- mov edx, [ecx+12]\r
- mov edx, [edx+12]\r
-\r
- /* Compare it */\r
- cmp [ecx+8], edx\r
- jne ab_return\r
-\r
- /* Return true */\r
- mov eax, 1\r
-\r
- /* Return */\r
-ab_return:\r
- ret\r
-.endfunc\r
-\r
-.func _local_unwind2\r
-__local_unwind2:\r
-\r
- /* Save volatiles */\r
- push ebx\r
- push esi\r
- push edi\r
-\r
- /* Get the exception registration */\r
- mov eax, [esp+16]\r
-\r
- /* Setup SEH to protect the unwind */\r
- push ebp\r
- push eax\r
- push -2\r
- push offset _unwind_handler\r
- push fs:0\r
- mov fs:0, esp\r
-\r
-unwind_loop:\r
- /* Get the exception registration and try level */\r
- mov eax, [esp+36]\r
- mov ebx, [eax+8]\r
- mov esi, [eax+12]\r
-\r
- /* Validate the unwind */\r
- cmp esi, -1\r
- je unwind_return\r
- cmp dword ptr [esp+40], -1\r
- je unwind_ok\r
- cmp esi, [esp+40]\r
- jbe unwind_return\r
-\r
-unwind_ok:\r
- /* Get the new enclosing level and save it */\r
- lea esi, [esi+esi*2]\r
- mov ecx, [ebx+esi*4]\r
- mov [esp+8], ecx\r
- mov [eax+12], ecx\r
-\r
- /* Check the filter type */\r
- cmp dword ptr [ebx+esi*4+4], 0\r
- jnz __NLG_Return2\r
-\r
- /* FIXME: NLG Notification */\r
-\r
- /* Call the handler */\r
- call dword ptr [ebx+esi*4+8]\r
-\r
-__NLG_Return2:\r
- /* Unwind again */\r
- jmp unwind_loop\r
-\r
-unwind_return:\r
- /* Cleanup SEH */\r
- pop fs:0\r
- add esp, 16\r
- pop edi\r
- pop esi\r
- pop ebx\r
- ret\r
-.endfunc\r
-\r
-.func _except_handler2\r
-__except_handler2:\r
-\r
- /* Setup stack and save volatiles */\r
- push ebp\r
- mov ebp, esp\r
- sub esp, 8\r
- push ebx\r
- push esi\r
- push edi\r
- push ebp\r
-\r
- /* Clear direction flag */\r
- cld\r
-\r
- /* Get exception registration and record */\r
- mov ebx, [ebp+12]\r
- mov eax, [ebp+8]\r
-\r
- /* Check if this is an unwind */\r
- test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING\r
- jnz except_unwind2\r
-\r
- /* Save exception pointers structure */\r
- mov [ebp-8], eax\r
- mov eax, [ebp+16]\r
- mov [ebp-4], eax\r
- lea eax, [ebp-8]\r
- mov [ebx+20], eax\r
-\r
- /* Get the try level and scope table */\r
- mov esi, [ebx+12]\r
- mov esi, [ebx+8]\r
-\r
-except_loop2:\r
- /* Validate try level */\r
- cmp esi, -1\r
- je except_search2\r
-\r
- /* Check if this is the termination handler */\r
- lea ecx, [esi+esi*2]\r
- cmp dword ptr [edi+ecx*4+4], 0\r
- jz except_continue2\r
-\r
- /* Save registers and call filter, then restore them */\r
- push esi\r
- push ebp\r
- mov ebp, [ebx+16]\r
- call dword ptr [edi+ecx*4+4]\r
- pop ebp\r
- pop esi\r
-\r
- /* Restore ebx and check the result */\r
- mov ebx, [ebp+12]\r
- or eax, eax\r
- jz except_continue2\r
- jz except_dismiss2\r
-\r
- /* So this is an accept, call the termination handlers */\r
- mov edi, [ebx+8]\r
- push ebx\r
- call __global_unwind2\r
- add esp, 4\r
-\r
- /* Restore ebp */\r
- mov ebp, [ebx+16]\r
-\r
- /* Do local unwind */\r
- push esi\r
- push ebx\r
- call __local_unwind2\r
- add esp, 8\r
-\r
- /* Set new try level */\r
- lea ecx, [esi+esi*2]\r
- mov eax, [edi+ecx*4]\r
- mov [ebx+12], eax\r
-\r
- /* Call except handler */\r
- call [edi+ecx*4+8]\r
-\r
-except_continue2:\r
- /* Reload try level and except again */\r
- mov edi, [ebx+8]\r
- lea ecx, [esi+esi*2]\r
- mov esi, [edi+ecx*4]\r
- jmp except_loop2\r
-\r
-except_dismiss2:\r
- /* Dismiss it */\r
- mov eax, DISPOSITION_DISMISS\r
- jmp except_return2\r
-\r
-except_search2:\r
- /* Continue searching */\r
- mov eax, DISPOSITION_CONTINUE_SEARCH\r
- jmp except_return2\r
-\r
- /* Do local unwind */\r
-except_unwind2:\r
- push ebp\r
- mov ebp, [ebx+16]\r
- push -1\r
- push ebx\r
- call __local_unwind2\r
- add esp, 8\r
-\r
- /* Retore EBP and set return disposition */\r
- pop ebp\r
- mov eax, DISPOSITION_CONTINUE_SEARCH\r
-\r
-except_return2:\r
- /* Restore registers and stack */\r
- pop ebp\r
- pop edi\r
- pop esi\r
- pop ebx\r
- mov esp, ebp\r
- pop ebp\r
- ret\r
-.endfunc\r
-\r
-.func _except_handler3\r
-__except_handler3:\r
-\r
- /* Setup stack and save volatiles */\r
- push ebp\r
- mov ebp, esp\r
- sub esp, 8\r
- push ebx\r
- push esi\r
- push edi\r
- push ebp\r
-\r
- /* Clear direction flag */\r
- cld\r
-\r
- /* Get exception registration and record */\r
- mov ebx, [ebp+12]\r
- mov eax, [ebp+8]\r
-\r
- /* Check if this is an unwind */\r
- test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING\r
- jnz except_unwind3\r
-\r
- /* Save exception pointers structure */\r
- mov [ebp-8], eax\r
- mov eax, [ebp+16]\r
- mov [ebp-4], eax\r
- lea eax, [ebp-8]\r
- mov [ebx-4], eax\r
-\r
- /* Get the try level and scope table */\r
- mov esi, [ebx+12]\r
- mov esi, [ebx+8]\r
-\r
- /* FIXME: Validate the SEH exception */\r
-\r
-except_loop3:\r
- /* Validate try level */\r
- cmp esi, -1\r
- je except_search3\r
-\r
- /* Check if this is the termination handler */\r
- lea ecx, [esi+esi*2]\r
- mov eax, [edi+ecx*4+4]\r
- or eax, eax\r
- jz except_continue3\r
-\r
- /* Save registers clear them all */\r
- push esi\r
- push ebp\r
- lea ebp, [ebx+16]\r
- xor ebx, ebx\r
- xor ecx, ecx\r
- xor edx, edx\r
- xor esi, esi\r
- xor edi, edi\r
-\r
- /* Call the filter and restore our registers */\r
- call eax\r
- pop ebp\r
- pop esi\r
-\r
- /* Restore ebx and check the result */\r
- mov ebx, [ebp+12]\r
- or eax, eax\r
- jz except_continue3\r
- jz except_dismiss3\r
-\r
- /* So this is an accept, call the termination handlers */\r
- mov edi, [ebx+8]\r
- push ebx\r
- call __global_unwind2\r
- add esp, 4\r
-\r
- /* Restore ebp */\r
- lea ebp, [ebx+16]\r
-\r
- /* Do local unwind */\r
- push esi\r
- push ebx\r
- call __local_unwind2\r
- add esp, 8\r
-\r
- /* FIXME: Do NLG Notification */\r
-\r
- /* Set new try level */\r
- lea ecx, [esi+esi*2]\r
- mov eax, [edi+ecx*4]\r
- mov [ebx+12], eax\r
-\r
- /* Clear registers and call except handler */\r
- mov eax, [edi+ecx*4+8]\r
- xor ebx, ebx\r
- xor ecx, ecx\r
- xor edx, edx\r
- xor esi, esi\r
- xor edi, edi\r
- call eax\r
-\r
-except_continue3:\r
- /* Reload try level and except again */\r
- mov edi, [ebx+8]\r
- lea ecx, [esi+esi*2]\r
- mov esi, [edi+ecx*4]\r
- jmp except_loop3\r
-\r
-except_dismiss3:\r
- /* Dismiss it */\r
- mov eax, DISPOSITION_DISMISS\r
- jmp except_return3\r
-\r
-except_search3:\r
- /* Continue searching */\r
- mov eax, DISPOSITION_CONTINUE_SEARCH\r
- jmp except_return3\r
-\r
- /* Do local unwind */\r
-except_unwind3:\r
- push ebp\r
- mov ebp, [ebx+16]\r
- push -1\r
- push ebx\r
- call __local_unwind2\r
- add esp, 8\r
-\r
- /* Retore EBP and set return disposition */\r
- pop ebp\r
- mov eax, DISPOSITION_CONTINUE_SEARCH\r
-\r
-except_return3:\r
- /* Restore registers and stack */\r
- pop ebp\r
- pop edi\r
- pop esi\r
- pop ebx\r
- mov esp, ebp\r
- pop ebp\r
- ret\r
-.endfunc\r
-\r
-//\r
-//\r
-// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME\r
-//\r
-//\r
-.func RtlpGetStackLimits@8\r
-.globl _RtlpGetStackLimits@8\r
-_RtlpGetStackLimits@8:\r
-\r
- /* Get the current thread */\r
- mov eax, [fs:KPCR_CURRENT_THREAD]\r
-\r
- /* Get the stack limits */\r
- mov ecx, [eax+KTHREAD_STACK_LIMIT]\r
- mov edx, [eax+KTHREAD_INITIAL_STACK]\r
- sub edx, SIZEOF_FX_SAVE_AREA\r
-\r
- /* Return them */\r
- mov eax, [esp+4]\r
- mov [eax], ecx\r
-\r
- mov eax, [esp+8]\r
- mov [eax], edx\r
-\r
- /* return */\r
- ret 8\r
-.endfunc\r
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/sin.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _sin
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_sin:
- push ebp // Save register bp
- mov ebp,esp // Point to the stack frame
- fld qword ptr [ebp+8] // Load real from stack
- fsin // Take the sine
- pop ebp // Restore register bp
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/sqrt.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _sqrt
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_sqrt:
- push ebp
- mov ebp,esp
- fld qword ptr [ebp+8] // Load real from stack
- fsqrt // Take the square root
- pop ebp
- ret
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Run-Time Library
- * FILE: lib/rtl/i386/tan.S
- * PROGRAMER: Alex Ionescu (alex@relsoft.net)
- * Eric Kohl (ekohl@rz-online.de)
- *
- * Copyright (C) 2002 Michael Ringgaard.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES// LOSS OF USE, DATA, OR PROFITS// OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-.globl _tan
-
-.intel_syntax noprefix
-
-/* FUNCTIONS ***************************************************************/
-
-_tan:
- push ebp
- mov ebp,esp
- sub esp,4 // Allocate temporary space
- fld qword ptr [ebp+8] // Load real from stack
- fptan // Take the tangent
- fstp dword ptr [ebp-4] // Throw away the constant 1
- mov esp,ebp // Deallocate temporary space
- pop ebp
- ret
<module name="rtl" type="staticlibrary">
- <define name="__USE_W32API" />
- <define name="_NTOSKRNL_" />
- <define name="__NO_CTYPE_INLINES" />
- <define name="NO_RTL_INLINES" />
- <define name="_NTSYSTEM_" />
- <define name="_NTDLLBUILD_" />
- <define name="_SEH_NO_NATIVE_NLG" />
- <include base="rtl">.</include>
- <if property="ARCH" value="i386">
- <directory name="i386">
- <file>alldiv_asm.s</file>
- <file>alldvrm_asm.s</file>
- <file>allmul_asm.s</file>
- <file>allrem_asm.s</file>
- <file>allshl_asm.s</file>
- <file>allshr_asm.s</file>
- <file>atan_asm.s</file>
- <file>aulldiv_asm.s</file>
- <file>aulldvrm_asm.s</file>
- <file>aullrem_asm.s</file>
- <file>aullshr_asm.s</file>
- <file>ceil_asm.s</file>
- <file>chkstk_asm.s</file>
- <file>cos_asm.s</file>
- <file>debug_asm.S</file>
- <file>except_asm.s</file>
- <file>exception.c</file>
- <file>fabs_asm.s</file>
- <file>floor_asm.s</file>
- <file>ftol_asm.s</file>
- <file>log_asm.s</file>
- <file>random_asm.S</file>
- <file>rtlswap.S</file>
- <file>rtlmem.s</file>
- <file>pow_asm.s</file>
- <file>res_asm.s</file>
- <file>seh.s</file>
- <file>sin_asm.s</file>
- <file>sqrt_asm.s</file>
- <file>tan_asm.s</file>
- <file>thread.c</file>
- </directory>
- </if>
- <directory name="austin">
- <file>avl.c</file>
- <file>tree.c</file>
- </directory>
+ <define name="__USE_W32API" />
+ <define name="_NTOSKRNL_" />
+ <define name="__NO_CTYPE_INLINES" />
+ <define name="NO_RTL_INLINES" />
+ <define name="_NTSYSTEM_" />
+ <define name="_NTDLLBUILD_" />
+ <define name="_SEH_NO_NATIVE_NLG" />
+ <include base="rtl">.</include>
+ <if property="ARCH" value="i386">
+ <directory name="i386">
+ <file>debug_asm.S</file>
+ <file>except_asm.s</file>
+ <file>exception.c</file>
+ <file>random_asm.S</file>
+ <file>rtlswap.S</file>
+ <file>rtlmem.s</file>
+ <file>res_asm.s</file>
+ <file>thread.c</file>
+ </directory>
+ </if>
+ <directory name="austin">
+ <file>avl.c</file>
+ <file>tree.c</file>
+ </directory>
- <ifnot property="ARCH" value="i386">
- <file>memgen.c</file>
- <file>mem.c</file>
- </ifnot>
-
- <file>access.c</file>
- <file>acl.c</file>
- <file>atom.c</file>
- <file>bitmap.c</file>
- <file>bootdata.c</file>
- <file>compress.c</file>
- <file>condvar.c</file>
- <file>crc32.c</file>
- <file>critical.c</file>
- <file>dbgbuffer.c</file>
- <file>debug.c</file>
- <file>dos8dot3.c</file>
- <file>encode.c</file>
- <file>env.c</file>
- <file>error.c</file>
- <file>exception.c</file>
- <file>generictable.c</file>
- <file>handle.c</file>
- <file>heap.c</file>
- <file>image.c</file>
- <file>message.c</file>
- <file>largeint.c</file>
- <file>luid.c</file>
- <file>network.c</file>
- <file>nls.c</file>
- <file>path.c</file>
- <file>ppb.c</file>
- <file>process.c</file>
- <file>propvar.c</file>
- <file>qsort.c</file>
- <file>random.c</file>
- <file>rangelist.c</file>
- <file>registry.c</file>
- <file>res.c</file>
- <file>resource.c</file>
- <file>sd.c</file>
- <file>security.c</file>
- <file>sid.c</file>
- <file>sprintf.c</file>
- <file>srw.c</file>
- <file>swprintf.c</file>
- <file>splaytree.c</file>
- <file>thread.c</file>
- <file>time.c</file>
- <file>timezone.c</file>
- <file>timerqueue.c</file>
- <file>unicode.c</file>
- <file>unicodeprefix.c</file>
- <file>vectoreh.c</file>
- <file>version.c</file>
- <file>workitem.c</file>
- <pch>rtl.h</pch>
+ <file>access.c</file>
+ <file>acl.c</file>
+ <file>atom.c</file>
+ <file>bitmap.c</file>
+ <file>bootdata.c</file>
+ <file>compress.c</file>
+ <file>condvar.c</file>
+ <file>crc32.c</file>
+ <file>critical.c</file>
+ <file>dbgbuffer.c</file>
+ <file>debug.c</file>
+ <file>dos8dot3.c</file>
+ <file>encode.c</file>
+ <file>env.c</file>
+ <file>error.c</file>
+ <file>exception.c</file>
+ <file>generictable.c</file>
+ <file>handle.c</file>
+ <file>heap.c</file>
+ <file>image.c</file>
+ <file>message.c</file>
+ <file>largeint.c</file>
+ <file>luid.c</file>
+ <file>network.c</file>
+ <file>nls.c</file>
+ <file>path.c</file>
+ <file>ppb.c</file>
+ <file>process.c</file>
+ <file>propvar.c</file>
+ <file>qsort.c</file>
+ <file>random.c</file>
+ <file>rangelist.c</file>
+ <file>registry.c</file>
+ <file>res.c</file>
+ <file>resource.c</file>
+ <file>sd.c</file>
+ <file>security.c</file>
+ <file>sid.c</file>
+ <file>sprintf.c</file>
+ <file>srw.c</file>
+ <file>swprintf.c</file>
+ <file>splaytree.c</file>
+ <file>thread.c</file>
+ <file>time.c</file>
+ <file>timezone.c</file>
+ <file>timerqueue.c</file>
+ <file>unicode.c</file>
+ <file>unicodeprefix.c</file>
+ <file>vectoreh.c</file>
+ <file>version.c</file>
+ <file>workitem.c</file>
+ <pch>rtl.h</pch>
</module>
--- /dev/null
+This file contains information about the status the MSVCRT runtime in ReactOS.
+
+Please note that all of the MSVCRT.DLL runtime sources are license GPL unless
+otherwise noted. The sources from WINE are dual licensed GPL/LGPL.
+If you update a function in the ~/wine directory please send a patch to wine-patches@winehq.com
+
+TODO List:
+Implement the remaining functions that are commented out in the .def file
+Update source code headers for the license information.
+Compleate the W32API conversion for all source files.
+Write a decent regression test suite.
+Convert all C++ style comments to C style comments.
+????
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: msvcrt/conio/cgets.c
+ * PURPOSE: C Runtime
+ * PROGRAMMER: Eric Kohl (Imported from DJGPP)
+ */
+
+#include <precomp.h>
+
+/*
+ * @implemented
+ */
+char *_cgets(char *string)
+{
+ unsigned len = 0;
+ unsigned int maxlen_wanted;
+ char *sp;
+ int c;
+ /*
+ * Be smart and check for NULL pointer.
+ * Don't know wether TURBOC does this.
+ */
+ if (!string)
+ return(NULL);
+ maxlen_wanted = (unsigned int)((unsigned char)string[0]);
+ sp = &(string[2]);
+ /*
+ * Should the string be shorter maxlen_wanted including or excluding
+ * the trailing '\0' ? We don't take any risk.
+ */
+ while(len < maxlen_wanted-1)
+ {
+ c=_getch();
+ /*
+ * shold we check for backspace here?
+ * TURBOC does (just checked) but doesn't in cscanf (thats harder
+ * or even impossible). We do the same.
+ */
+ if (c == '\b')
+ {
+ if (len > 0)
+ {
+ _cputs("\b \b"); /* go back, clear char on screen with space
+ and go back again */
+ len--;
+ sp[len] = '\0'; /* clear the character in the string */
+ }
+ }
+ else if (c == '\r')
+ {
+ sp[len] = '\0';
+ break;
+ }
+ else if (c == 0)
+ {
+ /* special character ends input */
+ sp[len] = '\0';
+ _ungetch(c); /* keep the char for later processing */
+ break;
+ }
+ else
+ {
+ sp[len] = _putch(c);
+ len++;
+ }
+ }
+ sp[maxlen_wanted-1] = '\0';
+ string[1] = (char)((unsigned char)len);
+ return(sp);
+}
+
+
--- /dev/null
+/*
+ * COPYRIGHT: Winehq
+ * PROJECT: wine
+ * FILE: msvcrt/conio/cprintf.c
+ * PURPOSE: C Runtime
+ * PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
+ */
+
+#include <precomp.h>
+
+/*
+ * @implemented
+ */
+int
+_cprintf(const char *fmt, ...)
+{
+ char buf[2048], *mem = buf;
+ int written, resize = sizeof(buf), retval;
+ va_list valist;
+
+ while ((written = _vsnprintf( mem, resize, fmt, valist )) == -1 ||
+ written > resize)
+ {
+ resize = (written == -1 ? resize * 2 : written + 1);
+ if (mem != buf)
+ free (mem);
+ if (!(mem = (char *)malloc(resize)))
+ return EOF;
+ va_start( valist, fmt );
+ }
+ va_end(valist);
+ retval = _cputs( mem );
+ if (mem != buf)
+ free (