mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 08:03:03 +00:00
- Update to trunk
svn path=/branches/audio-bringup/; revision=49927
This commit is contained in:
commit
6c8e7899a9
731 changed files with 37805 additions and 18893 deletions
|
@ -5,6 +5,7 @@
|
|||
* PURPOSE: C Runtime
|
||||
* PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
|
||||
*/
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
|
@ -38,3 +39,5 @@ _cprintf(const char *fmt, ...)
|
|||
free (mem);
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,33 @@
|
|||
<define name="_MSVCRT_" />
|
||||
<define name="_MT" />
|
||||
<define name="_CRTBLD" />
|
||||
|
||||
<if property="NEWSPRINTF" value="1">
|
||||
<define name="USE_NEW_SPRINTF" />
|
||||
<directory name="printf">
|
||||
<file>_cprintf.c</file>
|
||||
<file>_snprintf.c</file>
|
||||
<file>_snwprintf.c</file>
|
||||
<file>_vcprintf.c</file>
|
||||
<file>_vsnprintf.c</file>
|
||||
<file>_vsnwprintf.c</file>
|
||||
<file>fprintf.c</file>
|
||||
<file>fwprintf.c</file>
|
||||
<file>printf.c</file>
|
||||
<file>sprintf.c</file>
|
||||
<file>streamout.c</file>
|
||||
<file>swprintf.c</file>
|
||||
<file>vfprintf.c</file>
|
||||
<file>vfwprintf.c</file>
|
||||
<file>vprintf.c</file>
|
||||
<file>vsprintf.c</file>
|
||||
<file>vswprintf.c</file>
|
||||
<file>vwprintf.c</file>
|
||||
<file>wprintf.c</file>
|
||||
<file>wstreamout.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
|
||||
<directory name="conio">
|
||||
<file>cgets.c</file>
|
||||
<file>cprintf.c</file>
|
||||
|
@ -123,6 +150,7 @@
|
|||
<file>ldiv.c</file>
|
||||
<file>logf.c</file>
|
||||
<file>modf.c</file>
|
||||
<file>powf.c</file>
|
||||
<file>rand.c</file>
|
||||
<file>s_modf.c</file>
|
||||
<file>sinf.c</file>
|
||||
|
@ -284,7 +312,6 @@
|
|||
<directory name="misc">
|
||||
<file>amsg.c</file>
|
||||
<file>assert.c</file>
|
||||
<file>crtmain.c</file>
|
||||
<file>environ.c</file>
|
||||
<file>getargs.c</file>
|
||||
<file>initterm.c</file>
|
||||
|
@ -344,6 +371,7 @@
|
|||
<file>wpopen.c</file>
|
||||
<file>wstat.c</file>
|
||||
<file>wstat64.c</file>
|
||||
<file>lock_file.c</file>
|
||||
</directory>
|
||||
<directory name="stdlib">
|
||||
<file>_exit.c</file>
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
.global MsgUnimplemented
|
||||
PUBLIC MsgUnimplemented
|
||||
MsgUnimplemented:
|
||||
.asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n"
|
||||
|
||||
|
@ -27,4 +26,5 @@ MsgUnimplemented:
|
|||
ret
|
||||
.endp
|
||||
|
||||
END
|
||||
/* EOF */
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ndk/asm.h>
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
#define DISPOSITION_DISMISS 0
|
||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||
|
@ -54,3 +54,5 @@ _except_handler2:
|
|||
_except_handler3:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
END
|
||||
|
|
|
@ -7,8 +7,43 @@
|
|||
* PROGRAMER: KJK::Hyperion <noog@libero.it>
|
||||
*/
|
||||
|
||||
.globl __chkstk
|
||||
.globl __alloca_probe
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
PUBLIC __chkstk
|
||||
PUBLIC __alloca_probe
|
||||
PUBLIC __alloca_probe_16
|
||||
.code
|
||||
|
||||
/* 16 byte aligned alloca probe
|
||||
* EAX = size to be allocated */
|
||||
__alloca_probe_16:
|
||||
/* save the ECX register */
|
||||
push ecx
|
||||
|
||||
/* ecx = top of the previous stack frame */
|
||||
lea ecx, [esp + 8]
|
||||
|
||||
/* Calculate end of allocation */
|
||||
sub ecx, eax
|
||||
|
||||
/* Get the misalignment */
|
||||
and ecx, 15
|
||||
|
||||
/* Add the misalignment to the original alloc size */
|
||||
add eax, ecx
|
||||
|
||||
/* Check for overflow */
|
||||
jnc l1
|
||||
|
||||
/* Set maximum value */
|
||||
mov eax, HEX(0ffffffff)
|
||||
l1:
|
||||
/* Restore ecx */
|
||||
pop ecx
|
||||
/* Fall through to __chkstk */
|
||||
|
||||
/*
|
||||
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
|
||||
|
@ -18,49 +53,49 @@
|
|||
__chkstk:
|
||||
__alloca_probe:
|
||||
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX register */
|
||||
pushl %ecx
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX register */
|
||||
push ecx
|
||||
|
||||
/* ECX = top of the previous stack frame */
|
||||
leal 8(%esp), %ecx
|
||||
/* ECX = top of the previous stack frame */
|
||||
lea ecx, [esp + 8]
|
||||
|
||||
/* probe the desired memory, page by page */
|
||||
cmpl $0x1000, %eax
|
||||
jge .l_MoreThanAPage
|
||||
jmp .l_LessThanAPage
|
||||
/* probe the desired memory, page by page */
|
||||
cmp eax, PAGE_SIZE
|
||||
jl .l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
|
||||
/* raise the top of the stack by a page and probe */
|
||||
subl $0x1000, %ecx
|
||||
testl %eax, 0(%ecx)
|
||||
/* raise the top of the stack by a page and probe */
|
||||
sub ecx, PAGE_SIZE
|
||||
test [ecx], eax
|
||||
|
||||
/* loop if still more than a page must be probed */
|
||||
subl $0x1000, %eax
|
||||
cmpl $0x1000, %eax
|
||||
jge .l_MoreThanAPage
|
||||
/* loop if still more than a page must be probed */
|
||||
sub eax, PAGE_SIZE
|
||||
cmp eax, PAGE_SIZE
|
||||
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)
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
sub ecx, eax
|
||||
test [ecx], eax
|
||||
|
||||
/* EAX = top of the stack */
|
||||
movl %esp, %eax
|
||||
/* EAX = top of the stack */
|
||||
mov eax, esp
|
||||
|
||||
/* allocate the memory */
|
||||
movl %ecx, %esp
|
||||
/* allocate the memory */
|
||||
mov esp, ecx
|
||||
|
||||
/* restore ECX */
|
||||
movl 0(%eax), %ecx
|
||||
/* restore ECX */
|
||||
mov ecx, [eax]
|
||||
|
||||
/* restore the return address */
|
||||
movl 4(%eax), %eax
|
||||
pushl %eax
|
||||
/* restore the return address */
|
||||
mov eax, [eax + 4]
|
||||
push eax
|
||||
|
||||
/* return */
|
||||
ret
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
||||
END
|
||||
|
|
|
@ -8,20 +8,23 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ndk/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
.globl __EH_prolog
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
.code
|
||||
|
||||
PUBLIC __EH_prolog
|
||||
// Copied from Wine.
|
||||
__EH_prolog:
|
||||
pushl $-1
|
||||
pushl %eax
|
||||
pushl %fs:0
|
||||
movl %esp, %fs:0
|
||||
movl 12(%esp), %eax
|
||||
movl %ebp, 12(%esp)
|
||||
leal 12(%esp), %ebp
|
||||
pushl %eax
|
||||
push -1
|
||||
push eax
|
||||
push fs:0
|
||||
mov fs:0, esp
|
||||
mov eax, [esp + 12]
|
||||
mov [esp + 12], ebp
|
||||
lea ebp, [esp + 12]
|
||||
push eax
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,24 +8,29 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ndk/asm.h>
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
#define DISPOSITION_DISMISS 0
|
||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||
#define DISPOSITION_COLLIDED_UNWIND 3
|
||||
|
||||
#define EXCEPTION_EXIT_UNWIND 4
|
||||
#define EXCEPTION_UNWINDING 2
|
||||
|
||||
|
||||
EXTERN _RtlUnwind@16:PROC
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
.globl __global_unwind2
|
||||
.globl __local_unwind2
|
||||
.globl __abnormal_termination
|
||||
.globl __except_handler2
|
||||
.globl __except_handler3
|
||||
PUBLIC __global_unwind2
|
||||
PUBLIC __local_unwind2
|
||||
PUBLIC __abnormal_termination
|
||||
PUBLIC __except_handler2
|
||||
PUBLIC __except_handler3
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
.func unwind_handler
|
||||
.code
|
||||
_unwind_handler:
|
||||
|
||||
/* Check if we were unwinding and continue search if not */
|
||||
|
@ -56,9 +61,8 @@ _unwind_handler:
|
|||
|
||||
unwind_handler_return:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _global_unwind2
|
||||
|
||||
__global_unwind2:
|
||||
|
||||
/* Create stack and save all registers */
|
||||
|
@ -85,9 +89,8 @@ glu_return:
|
|||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _abnormal_termination
|
||||
|
||||
__abnormal_termination:
|
||||
|
||||
/* Assume false */
|
||||
|
@ -112,9 +115,8 @@ __abnormal_termination:
|
|||
/* Return */
|
||||
ab_return:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _local_unwind2
|
||||
|
||||
__local_unwind2:
|
||||
|
||||
/* Save volatiles */
|
||||
|
@ -175,9 +177,8 @@ unwind_return:
|
|||
pop esi
|
||||
pop ebx
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _except_handler2
|
||||
|
||||
__except_handler2:
|
||||
|
||||
/* Setup stack and save volatiles */
|
||||
|
@ -256,7 +257,7 @@ except_loop2:
|
|||
mov [ebx+12], eax
|
||||
|
||||
/* Call except handler */
|
||||
call [edi+ecx*4+8]
|
||||
call dword ptr [edi+ecx*4+8]
|
||||
|
||||
except_continue2:
|
||||
/* Reload try level and except again */
|
||||
|
@ -297,9 +298,8 @@ except_return2:
|
|||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _except_handler3
|
||||
|
||||
__except_handler3:
|
||||
|
||||
/* Setup stack and save volatiles */
|
||||
|
@ -437,4 +437,5 @@ except_return3:
|
|||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
END
|
||||
|
|
|
@ -30,7 +30,7 @@ double _logb (double __x)
|
|||
("fxtract\n\t"
|
||||
: "=t" (__junk), "=u" (__val) : "0" (__x));
|
||||
#else
|
||||
#error REVIEW ME
|
||||
#pragma message ("REVIEW ME")
|
||||
__asm fld [__x];
|
||||
__asm fxtract;
|
||||
__asm fstp st(0);
|
||||
|
|
|
@ -9,6 +9,25 @@
|
|||
<define name="_LIBCNT_" />
|
||||
<define name="_CRTBLD" />
|
||||
<define name="__CRT__NO_INLINE" />
|
||||
|
||||
<if property="NEWSPRINTF" value="1">
|
||||
<define name="USE_NEW_SPRINTF" />
|
||||
<directory name="printf">
|
||||
<file>_snprintf.c</file>
|
||||
<file>_snwprintf.c</file>
|
||||
<file>_vcprintf.c</file>
|
||||
<file>_vsnprintf.c</file>
|
||||
<file>_vsnwprintf.c</file>
|
||||
<file>sprintf.c</file>
|
||||
<file>streamout.c</file>
|
||||
<file>swprintf.c</file>
|
||||
<file>vprintf.c</file>
|
||||
<file>vsprintf.c</file>
|
||||
<file>vswprintf.c</file>
|
||||
<file>wstreamout.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
|
||||
<if property="ARCH" value="i386">
|
||||
<define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define>
|
||||
</if>
|
||||
|
@ -33,6 +52,9 @@
|
|||
</directory>
|
||||
</if>
|
||||
</directory>
|
||||
<directory name="float">
|
||||
<file>isnan.c</file>
|
||||
</directory>
|
||||
<directory name="math">
|
||||
<if property="ARCH" value="i386">
|
||||
<directory name="i386">
|
||||
|
@ -54,6 +76,7 @@
|
|||
<file>floor_asm.s</file>
|
||||
<file>ftol_asm.s</file>
|
||||
<file>log_asm.s</file>
|
||||
<file>log10_asm.s</file>
|
||||
<file>pow_asm.s</file>
|
||||
<file>sin_asm.s</file>
|
||||
<file>sqrt_asm.s</file>
|
||||
|
@ -207,6 +230,10 @@
|
|||
<file>wtol.c</file>
|
||||
</directory>
|
||||
|
||||
<directory name="mbstring">
|
||||
<file>mbstrlen.c</file>
|
||||
</directory>
|
||||
|
||||
<directory name="wstring">
|
||||
<file>wcsicmp.c</file>
|
||||
<file>wcslwr.c</file>
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -17,24 +17,30 @@
|
|||
|
||||
PUBLIC ceilf
|
||||
ceilf:
|
||||
sub rsp, 16
|
||||
|
||||
/* Put parameter on the stack */
|
||||
movss [rsp - 0x10], xmm0
|
||||
fld dword ptr [rsp]
|
||||
movss [rsp], xmm0
|
||||
fld dword ptr [rsp]
|
||||
|
||||
/* Change fpu control word to round up */
|
||||
fstcw [rsp - 0x10]
|
||||
mov eax, [rsp - 0x10]
|
||||
or eax, 0x00800
|
||||
and eax, 0x0fbff
|
||||
mov [rsp - 0x08], eax
|
||||
fldcw [rsp - 0x08]
|
||||
fstcw [rsp + 8]
|
||||
mov eax, [rsp + 8]
|
||||
or eax, HEX(00800)
|
||||
and eax, HEX(0fbff)
|
||||
mov [rsp + 12], eax
|
||||
fldcw [rsp + 12]
|
||||
|
||||
/* Round to integer */
|
||||
frndint
|
||||
|
||||
/* Restore fpu control word */
|
||||
fldcw [rsp - 0x10]
|
||||
fldcw [rsp + 8]
|
||||
|
||||
fstp dword ptr [rsp - 0x10]
|
||||
movss xmm0, [rsp - 0x10]
|
||||
fstp dword ptr [rsp]
|
||||
movss xmm0, [rsp]
|
||||
|
||||
add rsp, 16
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -20,3 +20,4 @@ exp:
|
|||
UNIMPLEMENTED exp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -19,3 +19,5 @@ PUBLIC floor
|
|||
floor:
|
||||
UNIMPLEMENTED floor
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -17,24 +17,29 @@
|
|||
|
||||
PUBLIC floorf
|
||||
floorf:
|
||||
sub rsp, 16
|
||||
|
||||
/* Put parameter on the stack */
|
||||
movss [rsp - 0x10], xmm0
|
||||
movss [rsp], xmm0
|
||||
fld dword ptr [rsp]
|
||||
|
||||
/* Change fpu control word to round down */
|
||||
fstcw [rsp - 0x10]
|
||||
mov eax, [rsp - 0x10]
|
||||
fstcw [rsp]
|
||||
mov eax, [rsp]
|
||||
or eax, 0x00400
|
||||
and eax, 0x0f7ff
|
||||
mov [rsp - 0x08], eax
|
||||
fldcw [rsp - 0x08]
|
||||
mov [rsp + 8], eax
|
||||
fldcw [rsp + 8]
|
||||
|
||||
/* Round to integer */
|
||||
frndint
|
||||
|
||||
/* Restore fpu control word */
|
||||
fldcw [rsp - 0x10]
|
||||
fldcw [rsp]
|
||||
|
||||
fstp dword ptr [rsp - 0x10]
|
||||
movss xmm0, [rsp - 0x10]
|
||||
fstp dword ptr [rsp]
|
||||
movss xmm0, [rsp]
|
||||
add rsp, 16
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
@ -17,3 +16,5 @@ PUBLIC fmod
|
|||
fmod:
|
||||
UNIMPLEMENTED fmod
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
@ -17,3 +16,5 @@ PUBLIC fmodf
|
|||
fmodf:
|
||||
UNIMPLEMENTED fmodf
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
@ -17,3 +16,5 @@ PUBLIC ldexp
|
|||
ldexp:
|
||||
UNIMPLEMENTED ldexp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
@ -17,3 +17,5 @@ PUBLIC sqrt
|
|||
sqrt:
|
||||
UNIMPLEMENTED sqrt
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
@ -17,3 +17,5 @@ PUBLIC sqrtf
|
|||
sqrtf:
|
||||
sqrtss xmm0, xmm0
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
|
@ -17,3 +17,5 @@ PUBLIC tan
|
|||
tan:
|
||||
UNIMPLEMENTED tan
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,18 +33,22 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __alldiv
|
||||
.globl __fltused
|
||||
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __alldiv
|
||||
PUBLIC __fltused
|
||||
|
||||
/* DATA ********************************************************************/
|
||||
.data
|
||||
ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING
|
||||
|
||||
__fltused:
|
||||
.long 0x9875
|
||||
.long HEX(9875)
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// lldiv - signed long divide
|
||||
|
@ -222,3 +226,5 @@ L8:
|
|||
pop edi
|
||||
|
||||
ret 16
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __alldvrm
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __alldvrm
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
__alldvrm:
|
||||
push edi
|
||||
|
@ -88,7 +89,7 @@ __alldvrm:
|
|||
|
||||
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
|
||||
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
|
||||
|
@ -97,10 +98,10 @@ __alldvrm:
|
|||
sbb eax,0
|
||||
mov DVNDHI,eax // save positive value
|
||||
mov DVNDLO,edx
|
||||
....L1:
|
||||
.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
|
||||
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
|
||||
|
@ -108,7 +109,7 @@ __alldvrm:
|
|||
sbb eax,0
|
||||
mov DVSRHI,eax // save positive value
|
||||
mov DVSRLO,edx
|
||||
....L2:
|
||||
.L2:
|
||||
|
||||
//
|
||||
// Now do the divide. First look to see if the divisor is less than 4194304K.
|
||||
|
@ -119,7 +120,7 @@ __alldvrm:
|
|||
//
|
||||
|
||||
or eax,eax // check to see if divisor < 4194304K
|
||||
jnz short ....L3 // nope, gotta do this the hard way
|
||||
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
|
||||
|
@ -137,24 +138,24 @@ __alldvrm:
|
|||
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
|
||||
jmp short .L4 // complete remainder calculation
|
||||
|
||||
//
|
||||
// Here we do it the hard way. Remember, eax contains the high word of DVSR
|
||||
//
|
||||
|
||||
....L3:
|
||||
.L3:
|
||||
mov ebx,eax // ebx:ecx <- divisor
|
||||
mov ecx,DVSRLO
|
||||
mov edx,DVNDHI // edx:eax <- dividend
|
||||
mov eax,DVNDLO
|
||||
....L5:
|
||||
.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
|
||||
jnz short .L5 // loop until divisor < 4194304K
|
||||
div ecx // now divide, ignore remainder
|
||||
mov esi,eax // save quotient
|
||||
|
||||
|
@ -170,7 +171,7 @@ __alldvrm:
|
|||
mov eax,DVSRLO
|
||||
mul esi // QUOT * DVSRLO
|
||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||
jc short ....L6 // carry means Quotient is off by 1
|
||||
jc short .L6 // carry means Quotient is off by 1
|
||||
|
||||
//
|
||||
// do long compare here between original dividend and the result of the
|
||||
|
@ -179,18 +180,18 @@ __alldvrm:
|
|||
//
|
||||
|
||||
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
|
||||
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:
|
||||
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:
|
||||
.L7:
|
||||
xor ebx,ebx // ebx:esi <- quotient
|
||||
|
||||
....L4:
|
||||
.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
|
||||
|
@ -208,7 +209,7 @@ __alldvrm:
|
|||
//
|
||||
|
||||
dec ebp // check result sign flag
|
||||
jns short ....L9 // result is ok, set up the quotient
|
||||
jns short .L9 // result is ok, set up the quotient
|
||||
neg edx // otherwise, negate the result
|
||||
neg eax
|
||||
sbb edx,0
|
||||
|
@ -216,7 +217,7 @@ __alldvrm:
|
|||
//
|
||||
// Now we need to get the quotient into edx:eax and the remainder into ebx:ecx.
|
||||
//
|
||||
....L9:
|
||||
.L9:
|
||||
mov ecx,edx
|
||||
mov edx,ebx
|
||||
mov ebx,ecx
|
||||
|
@ -229,7 +230,7 @@ __alldvrm:
|
|||
//
|
||||
|
||||
dec edi // check to see if result is negative
|
||||
jnz short ....L8 // if EDI == 0, result should be negative
|
||||
jnz short .L8 // if EDI == 0, result should be negative
|
||||
neg edx // otherwise, negate the result
|
||||
neg eax
|
||||
sbb edx,0
|
||||
|
@ -238,9 +239,11 @@ __alldvrm:
|
|||
// Restore the saved registers and return.
|
||||
//
|
||||
|
||||
....L8:
|
||||
.L8:
|
||||
pop ebp
|
||||
pop esi
|
||||
pop edi
|
||||
|
||||
ret 16
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __allmul
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __allmul
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// llmul - long multiply routine
|
||||
|
@ -113,3 +114,4 @@ hard:
|
|||
|
||||
ret 16 // callee restores the stack
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __allrem
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __allrem
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// llrem - signed long remainder
|
||||
|
@ -227,3 +228,5 @@ __allrem :
|
|||
pop ebx
|
||||
|
||||
ret 16
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __allshl
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __allshl
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// llshl - long shift left
|
||||
|
@ -92,3 +93,5 @@ RETZERO:
|
|||
xor eax,eax
|
||||
xor edx,edx
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __allshr
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __allshr
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// llshr - long shift right
|
||||
|
@ -93,3 +94,5 @@ __allshr:
|
|||
sar edx,31
|
||||
mov eax,edx
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
18
lib/sdk/crt/math/i386/atan2_asm.s
Normal file
18
lib/sdk/crt/math/i386/atan2_asm.s
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _atan2
|
||||
|
||||
.code
|
||||
_atan2:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld qword ptr [ebp + 8]
|
||||
fld qword ptr [ebp + 16]
|
||||
fpatan
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _atan
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _atan
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_atan:
|
||||
push ebp
|
||||
|
@ -48,3 +49,5 @@ _atan:
|
|||
fpatan // Take the arctangent
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __aulldiv
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __aulldiv
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// ulldiv - unsigned long divide
|
||||
|
@ -105,7 +106,7 @@ __aulldiv:
|
|||
|
||||
mov eax,DVSRHI // check to see if divisor < 4194304K
|
||||
or eax,eax
|
||||
jnz short ..L1 // nope, gotta do this the hard way
|
||||
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
|
||||
|
@ -114,24 +115,24 @@ __aulldiv:
|
|||
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
|
||||
jmp short .L2 // restore stack and return
|
||||
|
||||
//
|
||||
// Here we do it the hard way. Remember, eax contains DVSRHI
|
||||
//
|
||||
|
||||
..L1:
|
||||
.L1:
|
||||
mov ecx,eax // ecx:ebx <- divisor
|
||||
mov ebx,DVSRLO
|
||||
mov edx,DVNDHI // edx:eax <- dividend
|
||||
mov eax,DVNDLO
|
||||
..L3:
|
||||
.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
|
||||
jnz short .L3 // loop until divisor < 4194304K
|
||||
div ebx // now divide, ignore remainder
|
||||
mov esi,eax // save quotient
|
||||
|
||||
|
@ -147,7 +148,7 @@ __aulldiv:
|
|||
mov eax,DVSRLO
|
||||
mul esi // QUOT * DVSRLO
|
||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||
jc short ..L4 // carry means Quotient is off by 1
|
||||
jc short .L4 // carry means Quotient is off by 1
|
||||
|
||||
//
|
||||
// do long compare here between original dividend and the result of the
|
||||
|
@ -156,13 +157,13 @@ __aulldiv:
|
|||
//
|
||||
|
||||
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
|
||||
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:
|
||||
jbe short .L5 // if less or equal we are ok, else subtract
|
||||
.L4:
|
||||
dec esi // subtract 1 from quotient
|
||||
..L5:
|
||||
.L5:
|
||||
xor edx,edx // edx:eax <- quotient
|
||||
mov eax,esi
|
||||
|
||||
|
@ -171,9 +172,11 @@ __aulldiv:
|
|||
// Restore the saved registers and return.
|
||||
//
|
||||
|
||||
..L2:
|
||||
.L2:
|
||||
|
||||
pop esi
|
||||
pop ebx
|
||||
|
||||
ret 16
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __aulldvrm
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __aulldvrm
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
__aulldvrm:
|
||||
|
||||
|
@ -101,7 +102,7 @@ __aulldvrm:
|
|||
|
||||
mov eax,DVSRHI // check to see if divisor < 4194304K
|
||||
or eax,eax
|
||||
jnz short .....L1 // nope, gotta do this the hard way
|
||||
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
|
||||
|
@ -120,24 +121,24 @@ __aulldvrm:
|
|||
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
|
||||
jmp short .L2 // complete remainder calculation
|
||||
|
||||
//
|
||||
// Here we do it the hard way. Remember, eax contains DVSRHI
|
||||
//
|
||||
|
||||
.....L1:
|
||||
.L1:
|
||||
mov ecx,eax // ecx:ebx <- divisor
|
||||
mov ebx,DVSRLO
|
||||
mov edx,DVNDHI // edx:eax <- dividend
|
||||
mov eax,DVNDLO
|
||||
.....L3:
|
||||
.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
|
||||
jnz short .L3 // loop until divisor < 4194304K
|
||||
div ebx // now divide, ignore remainder
|
||||
mov esi,eax // save quotient
|
||||
|
||||
|
@ -153,7 +154,7 @@ __aulldvrm:
|
|||
mov eax,DVSRLO
|
||||
mul esi // QUOT * DVSRLO
|
||||
add edx,ecx // EDX:EAX = QUOT * DVSR
|
||||
jc short .....L4 // carry means Quotient is off by 1
|
||||
jc short .L4 // carry means Quotient is off by 1
|
||||
|
||||
//
|
||||
// do long compare here between original dividend and the result of the
|
||||
|
@ -162,18 +163,18 @@ __aulldvrm:
|
|||
//
|
||||
|
||||
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
|
||||
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:
|
||||
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:
|
||||
.L5:
|
||||
xor ebx,ebx // ebx:esi <- quotient
|
||||
|
||||
.....L2:
|
||||
.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
|
||||
|
@ -202,3 +203,5 @@ __aulldvrm:
|
|||
pop esi
|
||||
|
||||
ret 16
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __aullrem
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __aullrem
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// ullrem - unsigned long remainder
|
||||
|
@ -101,7 +102,7 @@ __aullrem:
|
|||
|
||||
mov eax,DVSRHI // check to see if divisor < 4194304K
|
||||
or eax,eax
|
||||
jnz short ...L1 // nope, gotta do this the hard way
|
||||
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
|
||||
|
@ -110,24 +111,24 @@ __aullrem:
|
|||
div ecx // edx <- final remainder
|
||||
mov eax,edx // edx:eax <- remainder
|
||||
xor edx,edx
|
||||
jmp short ...L2 // restore stack and return
|
||||
jmp short .L2 // restore stack and return
|
||||
|
||||
//
|
||||
// Here we do it the hard way. Remember, eax contains DVSRHI
|
||||
//
|
||||
|
||||
...L1:
|
||||
.L1:
|
||||
mov ecx,eax // ecx:ebx <- divisor
|
||||
mov ebx,DVSRLO
|
||||
mov edx,DVNDHI // edx:eax <- dividend
|
||||
mov eax,DVNDLO
|
||||
...L3:
|
||||
.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
|
||||
jnz short .L3 // loop until divisor < 4194304K
|
||||
div ebx // now divide, ignore remainder
|
||||
|
||||
//
|
||||
|
@ -142,7 +143,7 @@ __aullrem:
|
|||
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
|
||||
jc short .L4 // carry means Quotient is off by 1
|
||||
|
||||
//
|
||||
// do long compare here between original dividend and the result of the
|
||||
|
@ -151,14 +152,14 @@ __aullrem:
|
|||
//
|
||||
|
||||
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
|
||||
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:
|
||||
jbe short .L5 // if less or equal we're ok, else subtract
|
||||
.L4:
|
||||
sub eax,DVSRLO // subtract divisor from result
|
||||
sbb edx,DVSRHI
|
||||
...L5:
|
||||
.L5:
|
||||
|
||||
//
|
||||
// Calculate remainder by subtracting the result from the original dividend.
|
||||
|
@ -177,8 +178,10 @@ __aullrem:
|
|||
// Restore the saved registers and return.
|
||||
//
|
||||
|
||||
...L2:
|
||||
.L2:
|
||||
|
||||
pop ebx
|
||||
|
||||
ret 16
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __aullshr
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __aullshr
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
//
|
||||
// ullshr - long shift right
|
||||
|
@ -65,13 +66,13 @@ __aullshr:
|
|||
// depends only on the high order bit of edx).
|
||||
//
|
||||
cmp cl,64
|
||||
jae short ..RETZERO
|
||||
jae short .RETZERO
|
||||
|
||||
//
|
||||
// Handle shifts of between 0 and 31 bits
|
||||
//
|
||||
cmp cl, 32
|
||||
jae short ..MORE32
|
||||
jae short .MORE32
|
||||
shrd eax,edx,cl
|
||||
shr edx,cl
|
||||
ret
|
||||
|
@ -79,7 +80,7 @@ __aullshr:
|
|||
//
|
||||
// Handle shifts of between 32 and 63 bits
|
||||
//
|
||||
..MORE32:
|
||||
.MORE32:
|
||||
mov eax,edx
|
||||
xor edx,edx
|
||||
and cl,31
|
||||
|
@ -89,7 +90,9 @@ __aullshr:
|
|||
//
|
||||
// return 0 in edx:eax
|
||||
//
|
||||
..RETZERO:
|
||||
.RETZERO:
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _ceil
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _ceil
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_ceil:
|
||||
push ebp
|
||||
|
@ -47,7 +48,7 @@ _ceil:
|
|||
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
|
||||
mov word ptr [ebp-4], HEX(0b63) // Rounding control word
|
||||
fldcw [ebp-4] // Set new rounding control
|
||||
frndint // Round to integer
|
||||
fclex // Clear exceptions
|
||||
|
@ -55,3 +56,5 @@ _ceil:
|
|||
mov esp,ebp // Deallocate temporary space
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -3,53 +3,34 @@
|
|||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "ceilf.S"
|
||||
.text
|
||||
.align 4
|
||||
.globl __MINGW_USYMBOL(ceilf)
|
||||
.def __MINGW_USYMBOL(ceilf); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(ceilf):
|
||||
#ifdef _WIN64
|
||||
subq $24,%rsp
|
||||
movss %xmm0,8(%rsp)
|
||||
flds 8(%rsp)
|
||||
#include <asm.inc>
|
||||
|
||||
fstcw 4(%rsp) /* store fpu control word */
|
||||
.code
|
||||
.align 4
|
||||
|
||||
movl $0x0800,%edx /* round towards +oo */
|
||||
orl 4(%rsp),%edx
|
||||
andl $0xfbff,%edx
|
||||
movl %edx,(%rsp)
|
||||
fldcw (%rsp) /* load modified control word */
|
||||
PUBLIC _ceilf
|
||||
_ceilf:
|
||||
|
||||
frndint /* round */
|
||||
fld dword ptr [esp + 4]
|
||||
sub esp, 8
|
||||
|
||||
fldcw 4(%rsp) /* restore original control word */
|
||||
fstps 8(%rsp)
|
||||
movss 8(%rsp),%xmm0
|
||||
addq $24,%rsp
|
||||
ret
|
||||
#else
|
||||
flds 4(%esp)
|
||||
subl $8,%esp
|
||||
|
||||
fstcw 4(%esp) /* store fpu control word */
|
||||
fstcw [esp + 4] /* store fpu control word */
|
||||
|
||||
/* We use here %edx although only the low 1 bits are defined.
|
||||
But none of the operations should care and they are faster
|
||||
than the 16 bit operations. */
|
||||
movl $0x0800,%edx /* round towards +oo */
|
||||
orl 4(%esp),%edx
|
||||
andl $0xfbff,%edx
|
||||
movl %edx,(%esp)
|
||||
fldcw (%esp) /* load modified control word */
|
||||
mov edx, [esp + 4]
|
||||
or edx, HEX(0800) /* round towards +oo */
|
||||
and edx, HEX(fbff)
|
||||
mov [esp], edx
|
||||
fldcw [esp] /* load modified control word */
|
||||
|
||||
frndint /* round */
|
||||
|
||||
fldcw 4(%esp) /* restore original control word */
|
||||
fldcw [esp + 4] /* restore original control word */
|
||||
|
||||
addl $8,%esp
|
||||
add esp, 8
|
||||
ret
|
||||
#endif
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _cos
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _cos
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_cos:
|
||||
push ebp
|
||||
|
@ -47,3 +48,5 @@ _cos:
|
|||
fcos // Take the cosine
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
29
lib/sdk/crt/math/i386/exp_asm.s
Normal file
29
lib/sdk/crt/math/i386/exp_asm.s
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _exp
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_exp:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld qword ptr [ebp + 8]
|
||||
fldl2e
|
||||
fmul st, st(1)
|
||||
fst st(1)
|
||||
frndint
|
||||
fxch st(1)
|
||||
fsub st, st(1)
|
||||
f2xm1
|
||||
fld1
|
||||
faddp st(1), st
|
||||
fscale
|
||||
fstp st(1)
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _fabs
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _fabs
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_fabs:
|
||||
push ebp
|
||||
|
@ -47,3 +48,5 @@ _fabs:
|
|||
fabs // Take the absolute value
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _floor
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _floor
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_floor:
|
||||
push ebp
|
||||
|
@ -47,7 +48,7 @@ _floor:
|
|||
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
|
||||
mov word ptr [ebp-4], HEX(0763) // Rounding control word
|
||||
fldcw [ebp-4] // Set new rounding control
|
||||
frndint // Round to integer
|
||||
fclex // Clear exceptions
|
||||
|
@ -55,3 +56,5 @@ _floor:
|
|||
mov esp,ebp
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -7,57 +7,34 @@
|
|||
* Removed header file dependency for use in libmingwex.a by
|
||||
* Danny Smith <dannysmith@users.sourceforge.net>
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "floorf.S"
|
||||
.text
|
||||
#ifdef _WIN64
|
||||
.align 8
|
||||
#else
|
||||
.align 4
|
||||
#endif
|
||||
.globl __MINGW_USYMBOL(floorf)
|
||||
.def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(floorf):
|
||||
#ifdef _WIN64
|
||||
subq $24,%rsp
|
||||
movss %xmm0,8(%rsp)
|
||||
flds 8(%rsp)
|
||||
#include <asm.inc>
|
||||
|
||||
fstcw 4(%rsp) /* store fpu control word */
|
||||
movl $0x400,%edx /* round towards -oo */
|
||||
orl 4(%rsp),%edx
|
||||
andl $0xf7ff,%edx
|
||||
movl %edx,(%rsp)
|
||||
fldcw (%rsp) /* load modified control word */
|
||||
.code
|
||||
.align 4
|
||||
|
||||
frndint /* round */
|
||||
PUBLIC _floorf
|
||||
_floorf:
|
||||
|
||||
fldcw 4(%rsp) /* restore original control word */
|
||||
fld dword ptr [esp + 4]
|
||||
sub esp, 8
|
||||
|
||||
fstps 8(%rsp)
|
||||
movss 8(%rsp),%xmm0
|
||||
addq $24,%rsp
|
||||
ret
|
||||
#else
|
||||
flds 4(%esp)
|
||||
subl $8,%esp
|
||||
|
||||
fstcw 4(%esp) /* store fpu control word */
|
||||
fstcw [esp + 4] /* store fpu control word */
|
||||
|
||||
/* We use here %edx although only the low 1 bits are defined.
|
||||
But none of the operations should care and they are faster
|
||||
than the 16 bit operations. */
|
||||
movl $0x400,%edx /* round towards -oo */
|
||||
orl 4(%esp),%edx
|
||||
andl $0xf7ff,%edx
|
||||
movl %edx,(%esp)
|
||||
fldcw (%esp) /* load modified control word */
|
||||
mov edx, [esp + 4]
|
||||
or edx, HEX(0400) /* round towards -oo */
|
||||
and edx, HEX(0f7ff)
|
||||
mov [esp], edx
|
||||
fldcw [esp] /* load modified control word */
|
||||
|
||||
frndint /* round */
|
||||
|
||||
fldcw 4(%esp) /* restore original control word */
|
||||
fldcw [esp + 4] /* restore original control word */
|
||||
|
||||
addl $8,%esp
|
||||
add esp, 8
|
||||
ret
|
||||
#endif
|
||||
|
||||
END
|
||||
|
|
26
lib/sdk/crt/math/i386/fmod_asm.s
Normal file
26
lib/sdk/crt/math/i386/fmod_asm.s
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _fmod
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_fmod:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld qword ptr [ebp + 8]
|
||||
fld qword ptr [ebp + 16]
|
||||
fxch st(1)
|
||||
l1:
|
||||
fprem
|
||||
fstsw ax
|
||||
sahf
|
||||
jp l1
|
||||
fstp st(1)
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
26
lib/sdk/crt/math/i386/fmodf_asm.s
Normal file
26
lib/sdk/crt/math/i386/fmodf_asm.s
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _fmodf
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_fmodf:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
fld dword ptr [esp + 4]
|
||||
fld dword ptr [esp + 8]
|
||||
fxch st(1)
|
||||
l1:
|
||||
fprem
|
||||
fstsw ax
|
||||
sahf
|
||||
jp l1
|
||||
fstp st(1)
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
28
lib/sdk/crt/math/i386/ftol2_asm.s
Normal file
28
lib/sdk/crt/math/i386/ftol2_asm.s
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Run-Time Library
|
||||
* FILE: lib/rtl/i386/ftol2.S
|
||||
* PROGRAMER:
|
||||
*
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
EXTERN __ftol:PROC
|
||||
PUBLIC __ftol2
|
||||
PUBLIC __ftol2_sse
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
__ftol2:
|
||||
__ftol2_sse:
|
||||
jmp __ftol
|
||||
|
||||
END
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl __ftol
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC __ftol
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
/*
|
||||
* This routine is called by MSVC-generated code to convert from floating point
|
||||
|
@ -54,7 +55,7 @@ __ftol:
|
|||
fstcw [ebp-2]
|
||||
wait
|
||||
mov ax, [ebp-2]
|
||||
or ah, 0xC
|
||||
or ah, 12
|
||||
mov [ebp-4], ax
|
||||
fldcw [ebp-4]
|
||||
|
||||
|
@ -71,3 +72,5 @@ __ftol:
|
|||
/* Remove stack frame and return*/
|
||||
leave
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
|
||||
*
|
||||
*/
|
||||
|
||||
.globl _log10
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _log10
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_log10:
|
||||
|
||||
|
@ -25,3 +26,4 @@ _log10:
|
|||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _log
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _log
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_log:
|
||||
push ebp
|
||||
|
@ -49,3 +50,5 @@ _log:
|
|||
fyl2x // Compute the natural log(x)
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -19,41 +19,53 @@
|
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
/* Reacros modifications */
|
||||
/* Reactos modifications */
|
||||
#include <asm.inc>
|
||||
|
||||
#define ALIGNARG(log2) log2
|
||||
#define ASM_TYPE_DIRECTIVE(name,typearg)
|
||||
#define ASM_SIZE_DIRECTIVE(name)
|
||||
#define cfi_adjust_cfa_offset(x)
|
||||
#define ENTRY(x)
|
||||
#define END(x)
|
||||
.global _pow
|
||||
|
||||
.text
|
||||
PUBLIC _pow
|
||||
|
||||
.data
|
||||
ASSUME nothing
|
||||
|
||||
.align ALIGNARG(4)
|
||||
ASM_TYPE_DIRECTIVE(infinity,@object)
|
||||
|
||||
inf_zero:
|
||||
infinity:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
|
||||
.byte 0, 0, 0, 0, 0, 0, HEX(f0), HEX(7f)
|
||||
ASM_SIZE_DIRECTIVE(infinity)
|
||||
ASM_TYPE_DIRECTIVE(zero,@object)
|
||||
zero: .double 0.0
|
||||
zero:
|
||||
.double 0.0
|
||||
ASM_SIZE_DIRECTIVE(zero)
|
||||
ASM_TYPE_DIRECTIVE(minf_mzero,@object)
|
||||
|
||||
minf_mzero:
|
||||
minfinity:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff
|
||||
.byte 0, 0, 0, 0, 0, 0, HEX(f0), HEX(ff)
|
||||
|
||||
mzero:
|
||||
.byte 0, 0, 0, 0, 0, 0, 0, 0x80
|
||||
.byte 0, 0, 0, 0, 0, 0, 0, HEX(80)
|
||||
ASM_SIZE_DIRECTIVE(minf_mzero)
|
||||
ASM_TYPE_DIRECTIVE(one,@object)
|
||||
one: .double 1.0
|
||||
|
||||
one:
|
||||
.double 1.0
|
||||
ASM_SIZE_DIRECTIVE(one)
|
||||
ASM_TYPE_DIRECTIVE(limit,@object)
|
||||
limit: .double 0.29
|
||||
|
||||
limit:
|
||||
.double 0.29
|
||||
ASM_SIZE_DIRECTIVE(limit)
|
||||
ASM_TYPE_DIRECTIVE(p63,@object)
|
||||
p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43
|
||||
|
||||
p63:
|
||||
.byte 0, 0, 0, 0, 0, 0, HEX(e0), HEX(43)
|
||||
ASM_SIZE_DIRECTIVE(p63)
|
||||
|
||||
#ifdef PIC
|
||||
|
@ -61,308 +73,309 @@ p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43
|
|||
#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
|
||||
#else
|
||||
#define MO(op) op
|
||||
#define MOX(op,x,f) op(,x,f)
|
||||
#define MOX(op,x,f) op[x*f]
|
||||
#endif
|
||||
|
||||
.text
|
||||
.code
|
||||
_pow:
|
||||
ENTRY(__ieee754_pow)
|
||||
fldl 12(%esp) // y
|
||||
fld qword ptr [esp + 12] // y
|
||||
fxam
|
||||
|
||||
#ifdef PIC
|
||||
LOAD_PIC_REG (cx)
|
||||
#endif
|
||||
|
||||
fnstsw
|
||||
movb %ah, %dl
|
||||
andb $0x45, %ah
|
||||
cmpb $0x40, %ah // is y == 0 ?
|
||||
je 11f
|
||||
fnstsw ax
|
||||
mov dl, ah
|
||||
and ah, HEX(045)
|
||||
cmp ah, HEX(040) // is y == 0 ?
|
||||
je L11
|
||||
|
||||
cmpb $0x05, %ah // is y == ±inf ?
|
||||
je 12f
|
||||
cmp ah, 5 // is y == ±inf ?
|
||||
je L12
|
||||
|
||||
cmpb $0x01, %ah // is y == NaN ?
|
||||
je 30f
|
||||
cmp ah, 1 // is y == NaN ?
|
||||
je L30
|
||||
|
||||
fldl 4(%esp) // x : y
|
||||
fld qword ptr [esp + 4] // x : y
|
||||
|
||||
subl $8,%esp
|
||||
sub esp, 8
|
||||
cfi_adjust_cfa_offset (8)
|
||||
|
||||
fxam
|
||||
fnstsw
|
||||
movb %ah, %dh
|
||||
andb $0x45, %ah
|
||||
cmpb $0x40, %ah
|
||||
je 20f // x is ±0
|
||||
fnstsw ax
|
||||
mov dh, ah
|
||||
and ah, HEX(45)
|
||||
cmp ah, HEX(040)
|
||||
je L20 // x is ±0
|
||||
|
||||
cmpb $0x05, %ah
|
||||
je 15f // x is ±inf
|
||||
cmp ah, 5
|
||||
je L15 // x is ±inf
|
||||
|
||||
fxch // y : x
|
||||
fxch st(1) // y : x
|
||||
|
||||
/* fistpll raises invalid exception for |y| >= 1L<<63. */
|
||||
fld %st // y : y : x
|
||||
fld st // y : y : x
|
||||
fabs // |y| : y : x
|
||||
fcompl MO(p63) // y : x
|
||||
fnstsw
|
||||
fcomp qword ptr MO(p63) // y : x
|
||||
fnstsw ax
|
||||
sahf
|
||||
jnc 2f
|
||||
jnc L2
|
||||
|
||||
/* First see whether `y' is a natural number. In this case we
|
||||
can use a more precise algorithm. */
|
||||
fld %st // y : y : x
|
||||
fistpll (%esp) // y : x
|
||||
fildll (%esp) // int(y) : y : x
|
||||
fucomp %st(1) // y : x
|
||||
fnstsw
|
||||
fld st // y : y : x
|
||||
fistp qword ptr [esp] // y : x
|
||||
fild qword ptr [esp] // int(y) : y : x
|
||||
fucomp st(1) // y : x
|
||||
fnstsw ax
|
||||
sahf
|
||||
jne 2f
|
||||
jne L2
|
||||
|
||||
/* OK, we have an integer value for y. */
|
||||
popl %eax
|
||||
pop eax
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
popl %edx
|
||||
pop edx
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
orl $0, %edx
|
||||
fstp %st(0) // x
|
||||
jns 4f // y >= 0, jump
|
||||
fdivrl MO(one) // 1/x (now referred to as x)
|
||||
negl %eax
|
||||
adcl $0, %edx
|
||||
negl %edx
|
||||
4: fldl MO(one) // 1 : x
|
||||
fxch
|
||||
or edx, 0
|
||||
fstp st // x
|
||||
jns L4 // y >= 0, jump
|
||||
fdivr qword ptr MO(one) // 1/x (now referred to as x)
|
||||
neg eax
|
||||
adc edx, 0
|
||||
neg edx
|
||||
L4: fld qword ptr MO(one) // 1 : x
|
||||
fxch st(1)
|
||||
|
||||
6: shrdl $1, %edx, %eax
|
||||
jnc 5f
|
||||
fxch
|
||||
fmul %st(1) // x : ST*x
|
||||
fxch
|
||||
5: fmul %st(0), %st // x*x : ST*x
|
||||
shrl $1, %edx
|
||||
movl %eax, %ecx
|
||||
orl %edx, %ecx
|
||||
jnz 6b
|
||||
fstp %st(0) // ST*x
|
||||
L6: shrd eax, edx, 1
|
||||
jnc L5
|
||||
fxch st(1)
|
||||
fmul st, st(1) // x : ST*x
|
||||
fxch st(1)
|
||||
L5: fmul st, st // x*x : ST*x
|
||||
shr edx, 1
|
||||
mov ecx, eax
|
||||
or ecx, edx
|
||||
jnz L6
|
||||
fstp st // ST*x
|
||||
ret
|
||||
|
||||
/* y is ±NAN */
|
||||
30: fldl 4(%esp) // x : y
|
||||
fldl MO(one) // 1.0 : x : y
|
||||
fucomp %st(1) // x : y
|
||||
fnstsw
|
||||
L30:
|
||||
fld qword ptr [esp + 4] // x : y
|
||||
fld qword ptr MO(one) // 1.0 : x : y
|
||||
fucomp st(1) // x : y
|
||||
fnstsw ax
|
||||
sahf
|
||||
je 31f
|
||||
fxch // y : x
|
||||
31: fstp %st(1)
|
||||
je L31
|
||||
fxch st(1) // y : x
|
||||
L31:fstp st(1)
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
.align ALIGNARG(4)
|
||||
2: /* y is a real number. */
|
||||
fxch // x : y
|
||||
fldl MO(one) // 1.0 : x : y
|
||||
fldl MO(limit) // 0.29 : 1.0 : x : y
|
||||
fld %st(2) // x : 0.29 : 1.0 : x : y
|
||||
fsub %st(2) // x-1 : 0.29 : 1.0 : x : y
|
||||
L2: /* y is a real number. */
|
||||
fxch st(1) // x : y
|
||||
fld qword ptr MO(one) // 1.0 : x : y
|
||||
fld qword ptr MO(limit) // 0.29 : 1.0 : x : y
|
||||
fld st(2) // x : 0.29 : 1.0 : x : y
|
||||
fsub st, st(2) // x-1 : 0.29 : 1.0 : x : y
|
||||
fabs // |x-1| : 0.29 : 1.0 : x : y
|
||||
fucompp // 1.0 : x : y
|
||||
fnstsw
|
||||
fxch // x : 1.0 : y
|
||||
fnstsw ax
|
||||
fxch st(1) // x : 1.0 : y
|
||||
sahf
|
||||
ja 7f
|
||||
fsub %st(1) // x-1 : 1.0 : y
|
||||
ja L7
|
||||
fsub st, st(1) // x-1 : 1.0 : y
|
||||
fyl2xp1 // log2(x) : y
|
||||
jmp 8f
|
||||
jmp L8
|
||||
|
||||
7: fyl2x // log2(x) : y
|
||||
8: fmul %st(1) // y*log2(x) : y
|
||||
fst %st(1) // y*log2(x) : y*log2(x)
|
||||
L7: fyl2x // log2(x) : y
|
||||
L8: fmul st, st(1) // y*log2(x) : y
|
||||
fst st(1) // y*log2(x) : y*log2(x)
|
||||
frndint // int(y*log2(x)) : y*log2(x)
|
||||
fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x))
|
||||
fsubr st(1), st // int(y*log2(x)) : fract(y*log2(x))
|
||||
fxch // fract(y*log2(x)) : int(y*log2(x))
|
||||
f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x))
|
||||
faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x))
|
||||
fadd qword ptr MO(one) // 2^fract(y*log2(x)) : int(y*log2(x))
|
||||
fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x))
|
||||
addl $8, %esp
|
||||
add esp, 8
|
||||
cfi_adjust_cfa_offset (-8)
|
||||
fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x))
|
||||
fstp st(1) // 2^fract(y*log2(x))*2^int(y*log2(x))
|
||||
ret
|
||||
|
||||
|
||||
// pow(x,±0) = 1
|
||||
.align ALIGNARG(4)
|
||||
11: fstp %st(0) // pop y
|
||||
fldl MO(one)
|
||||
L11:fstp st(0) // pop y
|
||||
fld qword ptr MO(one)
|
||||
ret
|
||||
|
||||
// y == ±inf
|
||||
.align ALIGNARG(4)
|
||||
12: fstp %st(0) // pop y
|
||||
fldl MO(one) // 1
|
||||
fldl 4(%esp) // x : 1
|
||||
L12: fstp st(0) // pop y
|
||||
fld qword ptr MO(one) // 1
|
||||
fld qword ptr [esp + 4] // x : 1
|
||||
fabs // abs(x) : 1
|
||||
fucompp // < 1, == 1, or > 1
|
||||
fnstsw
|
||||
andb $0x45, %ah
|
||||
cmpb $0x45, %ah
|
||||
je 13f // jump if x is NaN
|
||||
fnstsw ax
|
||||
and ah, HEX(45)
|
||||
cmp ah, HEX(45)
|
||||
je L13 // jump if x is NaN
|
||||
|
||||
cmpb $0x40, %ah
|
||||
je 14f // jump if |x| == 1
|
||||
cmp ah, HEX(40)
|
||||
je L14 // jump if |x| == 1
|
||||
|
||||
shlb $1, %ah
|
||||
xorb %ah, %dl
|
||||
andl $2, %edx
|
||||
fldl MOX(inf_zero, %edx, 4)
|
||||
shl ah, 1
|
||||
xor dl, ah
|
||||
and edx, 2
|
||||
fld qword ptr MOX(inf_zero, edx, 4)
|
||||
ret
|
||||
|
||||
.align ALIGNARG(4)
|
||||
14: fldl MO(one)
|
||||
L14:fld qword ptr MO(one)
|
||||
ret
|
||||
|
||||
.align ALIGNARG(4)
|
||||
13: fldl 4(%esp) // load x == NaN
|
||||
L13:fld qword ptr [esp + 4] // load x == NaN
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
.align ALIGNARG(4)
|
||||
// x is ±inf
|
||||
15: fstp %st(0) // y
|
||||
testb $2, %dh
|
||||
jz 16f // jump if x == +inf
|
||||
L15: fstp st(0) // y
|
||||
test dh, 2
|
||||
jz L16 // jump if x == +inf
|
||||
|
||||
// We must find out whether y is an odd integer.
|
||||
fld %st // y : y
|
||||
fistpll (%esp) // y
|
||||
fildll (%esp) // int(y) : y
|
||||
fld st // y : y
|
||||
fistp qword ptr [esp] // y
|
||||
fild qword ptr [esp] // int(y) : y
|
||||
fucompp // <empty>
|
||||
fnstsw
|
||||
fnstsw ax
|
||||
sahf
|
||||
jne 17f
|
||||
jne L17
|
||||
|
||||
// OK, the value is an integer, but is the number of bits small
|
||||
// enough so that all are coming from the mantissa?
|
||||
popl %eax
|
||||
pop eax
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
popl %edx
|
||||
pop edx
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
andb $1, %al
|
||||
jz 18f // jump if not odd
|
||||
movl %edx, %eax
|
||||
orl %edx, %edx
|
||||
jns 155f
|
||||
negl %eax
|
||||
155: cmpl $0x00200000, %eax
|
||||
ja 18f // does not fit in mantissa bits
|
||||
and al, 1
|
||||
jz L18 // jump if not odd
|
||||
mov eax, edx
|
||||
or edx, edx
|
||||
jns L155
|
||||
neg eax
|
||||
L155:
|
||||
cmp eax, HEX(000200000)
|
||||
ja L18 // does not fit in mantissa bits
|
||||
// It's an odd integer.
|
||||
shrl $31, %edx
|
||||
fldl MOX(minf_mzero, %edx, 8)
|
||||
shr edx, 31
|
||||
fld qword ptr MOX(minf_mzero, edx, 8)
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
.align ALIGNARG(4)
|
||||
16: fcompl MO(zero)
|
||||
addl $8, %esp
|
||||
L16:fcomp qword ptr MO(zero)
|
||||
add esp, 8
|
||||
cfi_adjust_cfa_offset (-8)
|
||||
fnstsw
|
||||
shrl $5, %eax
|
||||
andl $8, %eax
|
||||
fldl MOX(inf_zero, %eax, 1)
|
||||
fnstsw ax
|
||||
shr eax, 5
|
||||
and eax, 8
|
||||
fld qword ptr MOX(inf_zero, eax, 1)
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
.align ALIGNARG(4)
|
||||
17: shll $30, %edx // sign bit for y in right position
|
||||
addl $8, %esp
|
||||
L17: shl ecx, 30 // sign bit for y in right position
|
||||
add esp, 8
|
||||
cfi_adjust_cfa_offset (-8)
|
||||
18: shrl $31, %edx
|
||||
fldl MOX(inf_zero, %edx, 8)
|
||||
L18: shr edx, 31
|
||||
fld qword ptr MOX(inf_zero, edx, 8)
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
.align ALIGNARG(4)
|
||||
// x is ±0
|
||||
20: fstp %st(0) // y
|
||||
testb $2, %dl
|
||||
jz 21f // y > 0
|
||||
L20: fstp st(0) // y
|
||||
test dl, 2
|
||||
jz L21 // y > 0
|
||||
|
||||
// x is ±0 and y is < 0. We must find out whether y is an odd integer.
|
||||
testb $2, %dh
|
||||
jz 25f
|
||||
test dh, 2
|
||||
jz L25
|
||||
|
||||
fld %st // y : y
|
||||
fistpll (%esp) // y
|
||||
fildll (%esp) // int(y) : y
|
||||
fld st // y : y
|
||||
fistp qword ptr [esp] // y
|
||||
fild qword ptr [esp] // int(y) : y
|
||||
fucompp // <empty>
|
||||
fnstsw
|
||||
fnstsw ax
|
||||
sahf
|
||||
jne 26f
|
||||
jne L26
|
||||
|
||||
// OK, the value is an integer, but is the number of bits small
|
||||
// enough so that all are coming from the mantissa?
|
||||
popl %eax
|
||||
pop eax
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
popl %edx
|
||||
pop edx
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
andb $1, %al
|
||||
jz 27f // jump if not odd
|
||||
cmpl $0xffe00000, %edx
|
||||
jbe 27f // does not fit in mantissa bits
|
||||
and al, 1
|
||||
jz L27 // jump if not odd
|
||||
cmp edx, HEX(0ffe00000)
|
||||
jbe L27 // does not fit in mantissa bits
|
||||
// It's an odd integer.
|
||||
// Raise divide-by-zero exception and get minus infinity value.
|
||||
fldl MO(one)
|
||||
fdivl MO(zero)
|
||||
fld qword ptr MO(one)
|
||||
fdiv qword ptr MO(zero)
|
||||
fchs
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
25: fstp %st(0)
|
||||
26: addl $8, %esp
|
||||
L25: fstp st(0)
|
||||
L26: add esp, 8
|
||||
cfi_adjust_cfa_offset (-8)
|
||||
27: // Raise divide-by-zero exception and get infinity value.
|
||||
fldl MO(one)
|
||||
fdivl MO(zero)
|
||||
L27: // Raise divide-by-zero exception and get infinity value.
|
||||
fld qword ptr MO(one)
|
||||
fdiv qword ptr MO(zero)
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
.align ALIGNARG(4)
|
||||
// x is ±0 and y is > 0. We must find out whether y is an odd integer.
|
||||
21: testb $2, %dh
|
||||
jz 22f
|
||||
L21:test dh, 2
|
||||
jz L22
|
||||
|
||||
fld %st // y : y
|
||||
fistpll (%esp) // y
|
||||
fildll (%esp) // int(y) : y
|
||||
fld st // y : y
|
||||
fistp qword ptr [esp] // y
|
||||
fild qword ptr [esp] // int(y) : y
|
||||
fucompp // <empty>
|
||||
fnstsw
|
||||
fnstsw ax
|
||||
sahf
|
||||
jne 23f
|
||||
jne L23
|
||||
|
||||
// OK, the value is an integer, but is the number of bits small
|
||||
// enough so that all are coming from the mantissa?
|
||||
popl %eax
|
||||
pop eax
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
popl %edx
|
||||
pop edx
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
andb $1, %al
|
||||
jz 24f // jump if not odd
|
||||
cmpl $0xffe00000, %edx
|
||||
jae 24f // does not fit in mantissa bits
|
||||
and al, 1
|
||||
jz L24 // jump if not odd
|
||||
cmp edx, HEX(0ffe00000)
|
||||
jae L24 // does not fit in mantissa bits
|
||||
// It's an odd integer.
|
||||
fldl MO(mzero)
|
||||
fld qword ptr MO(mzero)
|
||||
ret
|
||||
|
||||
cfi_adjust_cfa_offset (8)
|
||||
22: fstp %st(0)
|
||||
23: addl $8, %esp // Don't use 2 x pop
|
||||
L22: fstp st(0)
|
||||
L23: add esp, 8 // Don't use 2 x pop
|
||||
cfi_adjust_cfa_offset (-8)
|
||||
24: fldl MO(zero)
|
||||
L24: fld qword ptr MO(zero)
|
||||
ret
|
||||
|
||||
END(__ieee754_pow)
|
||||
END
|
||||
|
||||
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _sin
|
||||
|
||||
.intel_syntax noprefix
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _sin
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_sin:
|
||||
push ebp // Save register bp
|
||||
|
@ -47,3 +48,5 @@ _sin:
|
|||
fsin // Take the sine
|
||||
pop ebp // Restore register bp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _sqrt
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _sqrt
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_sqrt:
|
||||
push ebp
|
||||
|
@ -47,3 +48,5 @@ _sqrt:
|
|||
fsqrt // Take the square root
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -33,12 +33,13 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.globl _tan
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
PUBLIC _tan
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
.code
|
||||
|
||||
_tan:
|
||||
push ebp
|
||||
|
@ -50,3 +51,5 @@ _tan:
|
|||
mov esp,ebp // Deallocate temporary space
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -12,7 +12,12 @@
|
|||
#include <mbstring.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _LIBCNT_
|
||||
unsigned short *NlsLeadByteInfo;
|
||||
#define isleadbyte(c) NlsLeadByteInfo[c]
|
||||
#else
|
||||
int isleadbyte(int byte);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
|
|
@ -5,28 +5,34 @@
|
|||
* FILE: lib/sdk/crt/mem/i386/memchr.s
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
/*
|
||||
* void* memchr(const void* s, int c, size_t n)
|
||||
*/
|
||||
|
||||
.globl _memchr
|
||||
PUBLIC _memchr
|
||||
.code
|
||||
|
||||
_memchr:
|
||||
push %ebp
|
||||
mov %esp,%ebp
|
||||
push %edi
|
||||
mov 0x8(%ebp),%edi
|
||||
mov 0xc(%ebp),%eax
|
||||
mov 0x10(%ebp),%ecx
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push edi
|
||||
mov edi, [ebp + 8]
|
||||
mov eax, [ebp + 12]
|
||||
mov ecx, [ebp + 16]
|
||||
cld
|
||||
jecxz .Lnotfound
|
||||
repne scasb
|
||||
je .Lfound
|
||||
jecxz .Lnotfound
|
||||
repne scasb
|
||||
je .Lfound
|
||||
.Lnotfound:
|
||||
mov $1,%edi
|
||||
mov edi, 1
|
||||
.Lfound:
|
||||
mov %edi,%eax
|
||||
dec %eax
|
||||
pop %edi
|
||||
mov eax, edi
|
||||
dec eax
|
||||
pop edi
|
||||
leave
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* void *memcpy (void *to, const void *from, size_t count)
|
||||
*
|
||||
* NOTE: This code is a duplicate of memmove function from memmove_asm.s
|
||||
*/
|
||||
|
||||
.globl _memcpy
|
||||
|
||||
_memcpy:
|
||||
push %ebp
|
||||
mov %esp,%ebp
|
||||
|
||||
push %esi
|
||||
push %edi
|
||||
|
||||
mov 8(%ebp),%edi
|
||||
mov 12(%ebp),%esi
|
||||
mov 16(%ebp),%ecx
|
||||
|
||||
cmp %esi,%edi
|
||||
jbe .CopyUp
|
||||
mov %ecx,%eax
|
||||
add %esi,%eax
|
||||
cmp %eax,%edi
|
||||
jb .CopyDown
|
||||
|
||||
.CopyUp:
|
||||
cld
|
||||
|
||||
cmp $16,%ecx
|
||||
jb .L1
|
||||
mov %ecx,%edx
|
||||
test $3,%edi
|
||||
je .L2
|
||||
/*
|
||||
* Make the destination dword aligned
|
||||
*/
|
||||
mov %edi,%ecx
|
||||
and $3,%ecx
|
||||
sub $5,%ecx
|
||||
not %ecx
|
||||
sub %ecx,%edx
|
||||
rep movsb
|
||||
mov %edx,%ecx
|
||||
.L2:
|
||||
shr $2,%ecx
|
||||
rep movsl
|
||||
mov %edx,%ecx
|
||||
and $3,%ecx
|
||||
.L1:
|
||||
test %ecx,%ecx
|
||||
je .L3
|
||||
rep movsb
|
||||
.L3:
|
||||
mov 8(%ebp),%eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
leave
|
||||
ret
|
||||
|
||||
.CopyDown:
|
||||
std
|
||||
|
||||
add %ecx,%edi
|
||||
add %ecx,%esi
|
||||
|
||||
cmp $16,%ecx
|
||||
jb .L4
|
||||
mov %ecx,%edx
|
||||
test $3,%edi
|
||||
je .L5
|
||||
|
||||
/*
|
||||
* Make the destination dword aligned
|
||||
*/
|
||||
mov %edi,%ecx
|
||||
and $3,%ecx
|
||||
sub %ecx,%edx
|
||||
dec %esi
|
||||
dec %edi
|
||||
rep movsb
|
||||
mov %edx,%ecx
|
||||
|
||||
sub $3,%esi
|
||||
sub $3,%edi
|
||||
.L6:
|
||||
shr $2,%ecx
|
||||
rep movsl
|
||||
mov %edx,%ecx
|
||||
and $3,%ecx
|
||||
je .L7
|
||||
add $3,%esi
|
||||
add $3,%edi
|
||||
.L8:
|
||||
rep movsb
|
||||
.L7:
|
||||
cld
|
||||
mov 8(%ebp),%eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
leave
|
||||
ret
|
||||
.L5:
|
||||
sub $4,%edi
|
||||
sub $4,%esi
|
||||
jmp .L6
|
||||
|
||||
.L4:
|
||||
test %ecx,%ecx
|
||||
je .L7
|
||||
dec %esi
|
||||
dec %edi
|
||||
jmp .L8
|
||||
|
|
@ -1,114 +1,120 @@
|
|||
/*
|
||||
* void *memmove (void *to, const void *from, size_t count)
|
||||
* void *memcpy (void *to, const void *from, size_t count)
|
||||
*
|
||||
* NOTE: This code is duplicated in memcpy_asm.s
|
||||
*/
|
||||
|
||||
.globl _memmove
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
PUBLIC _memcpy
|
||||
PUBLIC _memmove
|
||||
.code
|
||||
|
||||
_memcpy:
|
||||
_memmove:
|
||||
push %ebp
|
||||
mov %esp,%ebp
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push %esi
|
||||
push %edi
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov 8(%ebp),%edi
|
||||
mov 12(%ebp),%esi
|
||||
mov 16(%ebp),%ecx
|
||||
mov edi, [ebp + 8]
|
||||
mov esi, [ebp + 12]
|
||||
mov ecx, [ebp + 16]
|
||||
|
||||
cmp %esi,%edi
|
||||
cmp edi, esi
|
||||
jbe .CopyUp
|
||||
mov %ecx,%eax
|
||||
add %esi,%eax
|
||||
cmp %eax,%edi
|
||||
jb .CopyDown
|
||||
|
||||
mov eax, ecx
|
||||
add eax, esi
|
||||
cmp edi, eax
|
||||
jb .CopyDown
|
||||
|
||||
.CopyUp:
|
||||
cld
|
||||
|
||||
cmp $16,%ecx
|
||||
jb .L1
|
||||
mov %ecx,%edx
|
||||
test $3,%edi
|
||||
je .L2
|
||||
cmp ecx, 16
|
||||
jb .L1
|
||||
mov edx, ecx
|
||||
test edi, 3
|
||||
je .L2
|
||||
/*
|
||||
* Make the destination dword aligned
|
||||
*/
|
||||
mov %edi,%ecx
|
||||
and $3,%ecx
|
||||
sub $5,%ecx
|
||||
not %ecx
|
||||
sub %ecx,%edx
|
||||
rep movsb
|
||||
mov %edx,%ecx
|
||||
mov ecx, edi
|
||||
and ecx, 3
|
||||
sub ecx, 5
|
||||
not ecx
|
||||
sub edx, ecx
|
||||
rep movsb
|
||||
mov ecx, edx
|
||||
.L2:
|
||||
shr $2,%ecx
|
||||
rep movsl
|
||||
mov %edx,%ecx
|
||||
and $3,%ecx
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
mov ecx, edx
|
||||
and ecx, 3
|
||||
.L1:
|
||||
test %ecx,%ecx
|
||||
je .L3
|
||||
rep movsb
|
||||
test ecx, ecx
|
||||
je .L3
|
||||
rep movsb
|
||||
.L3:
|
||||
mov 8(%ebp),%eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
mov eax, [ebp + 8]
|
||||
pop edi
|
||||
pop esi
|
||||
leave
|
||||
ret
|
||||
|
||||
.CopyDown:
|
||||
std
|
||||
std
|
||||
|
||||
add %ecx,%edi
|
||||
add %ecx,%esi
|
||||
add edi, ecx
|
||||
add esi, ecx
|
||||
|
||||
cmp $16,%ecx
|
||||
jb .L4
|
||||
mov %ecx,%edx
|
||||
test $3,%edi
|
||||
je .L5
|
||||
cmp ecx, 16
|
||||
jb .L4
|
||||
mov edx, ecx
|
||||
test edi, 3
|
||||
je .L5
|
||||
|
||||
/*
|
||||
* Make the destination dword aligned
|
||||
*/
|
||||
mov %edi,%ecx
|
||||
and $3,%ecx
|
||||
sub %ecx,%edx
|
||||
dec %esi
|
||||
dec %edi
|
||||
rep movsb
|
||||
mov %edx,%ecx
|
||||
mov ecx, edi
|
||||
and ecx, 3
|
||||
sub edx, ecx
|
||||
dec esi
|
||||
dec edi
|
||||
rep movsb
|
||||
mov ecx, edx
|
||||
|
||||
sub $3,%esi
|
||||
sub $3,%edi
|
||||
sub esi, 3
|
||||
sub edi, 3
|
||||
.L6:
|
||||
shr $2,%ecx
|
||||
rep movsl
|
||||
mov %edx,%ecx
|
||||
and $3,%ecx
|
||||
je .L7
|
||||
add $3,%esi
|
||||
add $3,%edi
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
mov ecx, edx
|
||||
and ecx, 3
|
||||
je .L7
|
||||
add esi, 3
|
||||
add edi, 3
|
||||
.L8:
|
||||
rep movsb
|
||||
rep movsb
|
||||
.L7:
|
||||
cld
|
||||
mov 8(%ebp),%eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
mov eax, [ebp + 8]
|
||||
pop edi
|
||||
pop esi
|
||||
leave
|
||||
ret
|
||||
.L5:
|
||||
sub $4,%edi
|
||||
sub $4,%esi
|
||||
jmp .L6
|
||||
|
||||
.L4:
|
||||
test %ecx,%ecx
|
||||
je .L7
|
||||
dec %esi
|
||||
dec %edi
|
||||
jmp .L8
|
||||
sub edi, 4
|
||||
sub esi, 4
|
||||
jmp .L6
|
||||
|
||||
.L4:
|
||||
test ecx, ecx
|
||||
je .L7
|
||||
dec esi
|
||||
dec edi
|
||||
jmp .L8
|
||||
|
||||
END
|
||||
|
|
|
@ -2,46 +2,51 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
/*
|
||||
* void *memset (void *src, int val, size_t count)
|
||||
*/
|
||||
|
||||
.globl _memset
|
||||
PUBLIC _memset
|
||||
.code
|
||||
|
||||
_memset:
|
||||
push %ebp
|
||||
mov %esp,%ebp
|
||||
push %edi
|
||||
mov 0x8(%ebp),%edi
|
||||
movzb 0xc(%ebp),%eax
|
||||
mov 0x10(%ebp),%ecx
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push edi
|
||||
mov edi, [ebp + 8]
|
||||
movzx eax, byte ptr [ebp + 12]
|
||||
mov ecx, [ebp + 16]
|
||||
cld
|
||||
cmp $16,%ecx
|
||||
jb .L1
|
||||
mov $0x01010101,%edx
|
||||
mul %edx
|
||||
mov %ecx,%edx
|
||||
test $3,%edi
|
||||
je .L2
|
||||
mov %edi,%ecx
|
||||
and $3,%ecx
|
||||
sub $5,%ecx
|
||||
not %ecx
|
||||
sub %ecx,%edx
|
||||
rep stosb
|
||||
mov %edx,%ecx
|
||||
cmp ecx, 16
|
||||
jb .L1
|
||||
mov edx, HEX(01010101)
|
||||
mul edx
|
||||
mov edx, ecx
|
||||
test edi, 3
|
||||
je .L2
|
||||
mov ecx, edi
|
||||
and ecx, 3
|
||||
sub ecx, 5
|
||||
not ecx
|
||||
sub edx, ecx
|
||||
rep stosb
|
||||
mov ecx, edx
|
||||
.L2:
|
||||
shr $2,%ecx
|
||||
rep stosl
|
||||
mov %edx,%ecx
|
||||
and $3,%ecx
|
||||
shr ecx, 2
|
||||
rep stosd
|
||||
mov ecx, edx
|
||||
and ecx, 3
|
||||
.L1:
|
||||
test %ecx,%ecx
|
||||
je .L3
|
||||
rep stosb
|
||||
test ecx, ecx
|
||||
je .L3
|
||||
rep stosb
|
||||
.L3:
|
||||
pop %edi
|
||||
mov 0x8(%ebp),%eax
|
||||
pop edi
|
||||
mov eax, [ebp + 8]
|
||||
leave
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
|
@ -67,6 +67,6 @@ void _assert(const char *exp, const char *file, unsigned line)
|
|||
/* Does the user want to debug? */
|
||||
if (iResult == IDRETRY)
|
||||
{
|
||||
__debugbreak();
|
||||
DbgRaiseAssertionFailure();
|
||||
}
|
||||
}
|
||||
|
|
25
lib/sdk/crt/printf/_cprintf.c
Normal file
25
lib/sdk/crt/printf/_cprintf.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/_vcprintf.c
|
||||
* PURPOSE: Implementation of _vcprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int _vcprintf(const char* format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
_cprintf(const char * format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = _vcprintf(format, argptr);
|
||||
va_end(argptr);
|
||||
return result;
|
||||
}
|
||||
|
39
lib/sdk/crt/printf/_snprintf.c
Normal file
39
lib/sdk/crt/printf/_snprintf.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/_snprintf.c
|
||||
* PURPOSE: Implementation of _snprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <tchar.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
_snprintf(char *buffer, size_t count, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = (unsigned long)-1;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = 0;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = streamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
*stream._ptr = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
|
42
lib/sdk/crt/printf/_snwprintf.c
Normal file
42
lib/sdk/crt/printf/_snwprintf.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/_snwprintf.c
|
||||
* PURPOSE: Implementation of _snwprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
_snwprintf(
|
||||
wchar_t *buffer,
|
||||
size_t count,
|
||||
const wchar_t *format,
|
||||
...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._bufsiz = count * sizeof(wchar_t);
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
stream._charbuf = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = wstreamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
/* Only zero terminate if there is enough space left */
|
||||
if (stream._cnt >= sizeof(wchar_t)) *(wchar_t*)stream._ptr = L'\0';
|
||||
|
||||
return result;
|
||||
}
|
18
lib/sdk/crt/printf/_vcprintf.c
Normal file
18
lib/sdk/crt/printf/_vcprintf.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/_vcprintf.c
|
||||
* PURPOSE: Implementation of _vcprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
_cdecl
|
||||
_vcprintf(const char* format, va_list va)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
37
lib/sdk/crt/printf/_vsnprintf.c
Normal file
37
lib/sdk/crt/printf/_vsnprintf.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/_vsnprintf.c
|
||||
* PURPOSE: Implementation of _vsnprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
_vsnprintf(
|
||||
char *buffer,
|
||||
size_t count,
|
||||
const char *format,
|
||||
va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._bufsiz = count;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
stream._charbuf = 0;
|
||||
|
||||
result = streamout(&stream, format, argptr);
|
||||
*stream._ptr = '\0';
|
||||
|
||||
return result;
|
||||
}
|
37
lib/sdk/crt/printf/_vsnwprintf.c
Normal file
37
lib/sdk/crt/printf/_vsnwprintf.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/_vsnwprintf.c
|
||||
* PURPOSE: Implementation of _vsnwprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
_vsnwprintf(
|
||||
wchar_t *buffer,
|
||||
size_t count,
|
||||
const wchar_t *format,
|
||||
va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._bufsiz = count * sizeof(wchar_t);
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
stream._charbuf = 0;
|
||||
|
||||
result = wstreamout(&stream, format, argptr);
|
||||
*(wchar_t*)stream._ptr = L'\0';
|
||||
|
||||
return result;
|
||||
}
|
24
lib/sdk/crt/printf/fprintf.c
Normal file
24
lib/sdk/crt/printf/fprintf.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/fprintf.c
|
||||
* PURPOSE: Implementation of fprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
_cdecl
|
||||
fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = vfprintf(stream, format, argptr);
|
||||
va_end(argptr);
|
||||
return result;
|
||||
}
|
||||
|
23
lib/sdk/crt/printf/fwprintf.c
Normal file
23
lib/sdk/crt/printf/fwprintf.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/fwprintf.c
|
||||
* PURPOSE: Implementation of fwprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
__cdecl
|
||||
fwprintf(FILE* file, const wchar_t *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = vfwprintf(file, format, argptr);
|
||||
va_end(argptr);
|
||||
return result;
|
||||
}
|
27
lib/sdk/crt/printf/printf.c
Normal file
27
lib/sdk/crt/printf/printf.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/printf.c
|
||||
* PURPOSE: Implementation of printf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <tchar.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
printf(const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = streamout(stdout, format, argptr);
|
||||
va_end(argptr);
|
||||
return result;
|
||||
}
|
||||
|
38
lib/sdk/crt/printf/sprintf.c
Normal file
38
lib/sdk/crt/printf/sprintf.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/sprintf.c
|
||||
* PURPOSE: Implementation of sprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
sprintf(char *buffer, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = INT_MAX;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = 0;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = streamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
*stream._ptr = '\0';
|
||||
return result;
|
||||
}
|
||||
|
636
lib/sdk/crt/printf/streamout.c
Normal file
636
lib/sdk/crt/printf/streamout.c
Normal file
|
@ -0,0 +1,636 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/streamout.c
|
||||
* PURPOSE: Implementation of streamout
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <tchar.h>
|
||||
#include <strings.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#ifdef _UNICODE
|
||||
#define streamout wstreamout
|
||||
#define format_float format_floatw
|
||||
#endif
|
||||
|
||||
#define MB_CUR_MAX 10
|
||||
#define BUFFER_SIZE (32 + 17)
|
||||
|
||||
int mbtowc(wchar_t *wchar, const char *mbchar, size_t count);
|
||||
int wctomb(char *mbchar, wchar_t wchar);
|
||||
|
||||
typedef struct _STRING
|
||||
{
|
||||
unsigned short Length;
|
||||
unsigned short MaximumLength;
|
||||
void *Buffer;
|
||||
} STRING;
|
||||
|
||||
enum
|
||||
{
|
||||
/* Formatting flags */
|
||||
FLAG_ALIGN_LEFT = 0x01,
|
||||
FLAG_FORCE_SIGN = 0x02,
|
||||
FLAG_FORCE_SIGNSP = 0x04,
|
||||
FLAG_PAD_ZERO = 0x08,
|
||||
FLAG_SPECIAL = 0x10,
|
||||
|
||||
/* Data format flags */
|
||||
FLAG_SHORT = 0x100,
|
||||
FLAG_LONG = 0x200,
|
||||
FLAG_WIDECHAR = FLAG_LONG,
|
||||
FLAG_INT64 = 0x400,
|
||||
#ifdef _WIN64
|
||||
FLAG_INTPTR = FLAG_INT64,
|
||||
#else
|
||||
FLAG_INTPTR = 0,
|
||||
#endif
|
||||
FLAG_LONGDOUBLE = 0x800,
|
||||
};
|
||||
|
||||
#define va_arg_f(argptr, flags) \
|
||||
(flags & FLAG_INT64) ? va_arg(argptr, __int64) : \
|
||||
(flags & FLAG_SHORT) ? (short)va_arg(argptr, int) : \
|
||||
va_arg(argptr, int)
|
||||
|
||||
#define va_arg_fu(argptr, flags) \
|
||||
(flags & FLAG_INT64) ? va_arg(argptr, unsigned __int64) : \
|
||||
(flags & FLAG_SHORT) ? (unsigned short)va_arg(argptr, int) : \
|
||||
va_arg(argptr, unsigned int)
|
||||
|
||||
#define va_arg_ffp(argptr, flags) \
|
||||
(flags & FLAG_LONGDOUBLE) ? va_arg(argptr, long double) : \
|
||||
va_arg(argptr, double)
|
||||
|
||||
#ifdef _LIBCNT_
|
||||
# define _flsbuf(chr, stream) 0
|
||||
#endif
|
||||
|
||||
#define get_exp(f) floor(f > 0 ? log10(f) : log10(-f))
|
||||
|
||||
void
|
||||
#ifdef _LIBCNT
|
||||
/* Due to restrictions in kernel mode regarding the use of floating point,
|
||||
we prevent it from being inlined */
|
||||
__declspec(noinline)
|
||||
#endif
|
||||
format_float(
|
||||
TCHAR chr,
|
||||
unsigned int flags,
|
||||
int precision,
|
||||
TCHAR **string,
|
||||
const TCHAR **prefix,
|
||||
va_list *argptr)
|
||||
{
|
||||
static const TCHAR digits_l[] = _T("0123456789abcdef0x");
|
||||
static const TCHAR digits_u[] = _T("0123456789ABCDEF0X");
|
||||
static const TCHAR _nan[] = _T("#QNAN");
|
||||
static const TCHAR _infinity[] = _T("#INF");
|
||||
const TCHAR *digits = digits_l;
|
||||
int exponent = 0;
|
||||
long double fpval;
|
||||
int num_digits, val32, base = 10;
|
||||
__int64 val64;
|
||||
|
||||
if (precision < 0) precision = 6;
|
||||
else if (precision > 512) precision = 512;
|
||||
|
||||
fpval = va_arg_ffp(*argptr, flags);
|
||||
exponent = get_exp(fpval);
|
||||
|
||||
switch (chr)
|
||||
{
|
||||
case _T('G'):
|
||||
digits = digits_u;
|
||||
case _T('g'):
|
||||
if (exponent < -4 || exponent >= precision) goto case_e;
|
||||
break;
|
||||
|
||||
case _T('E'):
|
||||
digits = digits_u;
|
||||
case _T('e'):
|
||||
case_e:
|
||||
fpval /= pow(10., exponent);
|
||||
val32 = exponent >= 0 ? exponent : -exponent;
|
||||
|
||||
// FIXME: handle length of exponent field:
|
||||
// http://msdn.microsoft.com/de-de/library/0fatw238%28VS.80%29.aspx
|
||||
num_digits = 3;
|
||||
while (num_digits--)
|
||||
{
|
||||
*--(*string) = digits[val32 % 10];
|
||||
val32 /= 10;
|
||||
}
|
||||
|
||||
/* Sign for the exponent */
|
||||
*--(*string) = exponent > 0 ? _T('+') : _T('-');
|
||||
|
||||
/* Add 'e' or 'E' separator */
|
||||
*--(*string) = digits[0xe];
|
||||
break;
|
||||
|
||||
case _T('A'):
|
||||
digits = digits_u;
|
||||
case _T('a'):
|
||||
// base = 16;
|
||||
// FIXME: TODO
|
||||
|
||||
case _T('f'):
|
||||
break;
|
||||
}
|
||||
|
||||
/* CHECKME: Windows seems to handle a max of 17 digits(?) */
|
||||
num_digits = precision <= 17 ? precision: 17;
|
||||
|
||||
/* Handle sign */
|
||||
if (fpval < 0)
|
||||
{
|
||||
fpval = -fpval;
|
||||
*prefix = _T("-");
|
||||
}
|
||||
else if (flags & FLAG_FORCE_SIGN)
|
||||
*prefix = _T("+");
|
||||
else if (flags & FLAG_FORCE_SIGNSP)
|
||||
*prefix = _T(" ");
|
||||
|
||||
/* Handle special cases first */
|
||||
if (_isnan(fpval))
|
||||
{
|
||||
(*string) -= sizeof(_nan) / sizeof(TCHAR) - 1;
|
||||
_tcscpy((*string), _nan);
|
||||
val64 = 1;
|
||||
}
|
||||
else if (!_finite(fpval))
|
||||
{
|
||||
(*string) -= sizeof(_infinity) / sizeof(TCHAR) - 1;
|
||||
_tcscpy((*string), _infinity);
|
||||
val64 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fpval *= pow(10., precision);
|
||||
val64 = (__int64)(fpval + 0.5);
|
||||
|
||||
while (num_digits-- > 0)
|
||||
{
|
||||
*--(*string) = digits[val64 % 10];
|
||||
val64 /= 10;
|
||||
}
|
||||
}
|
||||
|
||||
*--(*string) = _T('.');
|
||||
|
||||
/* Digits before the decimal point */
|
||||
do
|
||||
{
|
||||
*--(*string) = digits[val64 % base];
|
||||
val64 /= base;
|
||||
}
|
||||
while (val64);
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
streamout_char(FILE *stream, int chr)
|
||||
{
|
||||
/* Flush the buffer if neccessary */
|
||||
if (stream->_cnt < sizeof(TCHAR))
|
||||
{
|
||||
return _flsbuf(chr, stream) != EOF;
|
||||
}
|
||||
|
||||
*(TCHAR*)stream->_ptr = chr;
|
||||
stream->_ptr += sizeof(TCHAR);
|
||||
stream->_cnt -= sizeof(TCHAR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
streamout_astring(FILE *stream, const char *string, int count)
|
||||
{
|
||||
TCHAR chr;
|
||||
int written = 0;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
int len;
|
||||
if ((len = mbtowc(&chr, string, MB_CUR_MAX)) < 1) break;
|
||||
string += len;
|
||||
#else
|
||||
chr = *string++;
|
||||
#endif
|
||||
if (streamout_char(stream, chr) == 0) return -1;
|
||||
written++;
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
streamout_wstring(FILE *stream, const wchar_t *string, int count)
|
||||
{
|
||||
wchar_t chr;
|
||||
int written = 0;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
char mbchar[MB_CUR_MAX], *ptr = mbchar;
|
||||
int mblen;
|
||||
|
||||
mblen = wctomb(mbchar, *string++);
|
||||
if (mblen <= 0) return written;
|
||||
|
||||
while (chr = *ptr++, mblen--)
|
||||
#else
|
||||
chr = *string++;
|
||||
#endif
|
||||
{
|
||||
if (streamout_char(stream, chr) == 0) return -1;
|
||||
written++;
|
||||
}
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
#ifdef _UNICODE
|
||||
#define streamout_string streamout_wstring
|
||||
#else
|
||||
#define streamout_string streamout_astring
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
_cdecl
|
||||
streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
||||
{
|
||||
static const TCHAR digits_l[] = _T("0123456789abcdef0x");
|
||||
static const TCHAR digits_u[] = _T("0123456789ABCDEF0X");
|
||||
static const char *_nullstring = "(null)";
|
||||
TCHAR buffer[BUFFER_SIZE + 1];
|
||||
TCHAR chr, *string;
|
||||
STRING *nt_string;
|
||||
const TCHAR *digits, *prefix;
|
||||
int base, len, prefixlen, fieldwidth, precision, padding;
|
||||
int written = 1, written_all = 0;
|
||||
unsigned int flags;
|
||||
unsigned __int64 val64;
|
||||
|
||||
buffer[BUFFER_SIZE] = '\0';
|
||||
|
||||
while (written >= 0)
|
||||
{
|
||||
chr = *format++;
|
||||
|
||||
/* Check for end of format string */
|
||||
if (chr == _T('\0')) break;
|
||||
|
||||
/* Check for 'normal' character or double % */
|
||||
if ((chr != _T('%')) ||
|
||||
(chr = *format++) == _T('%'))
|
||||
{
|
||||
/* Write the character to the stream */
|
||||
if ((written = streamout_char(stream, chr)) == -1) return -1;
|
||||
written_all += written;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Handle flags */
|
||||
flags = 0;
|
||||
while (1)
|
||||
{
|
||||
if (chr == _T('-')) flags |= FLAG_ALIGN_LEFT;
|
||||
else if (chr == _T('+')) flags |= FLAG_FORCE_SIGN;
|
||||
else if (chr == _T(' ')) flags |= FLAG_FORCE_SIGNSP;
|
||||
else if (chr == _T('0')) flags |= FLAG_PAD_ZERO;
|
||||
else if (chr == _T('#')) flags |= FLAG_SPECIAL;
|
||||
else break;
|
||||
chr = *format++;
|
||||
}
|
||||
|
||||
/* Handle field width modifier */
|
||||
if (chr == _T('*'))
|
||||
{
|
||||
fieldwidth = va_arg(argptr, int);
|
||||
if (fieldwidth < 0)
|
||||
{
|
||||
flags |= FLAG_ALIGN_LEFT;
|
||||
fieldwidth = -fieldwidth;
|
||||
}
|
||||
chr = *format++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldwidth = 0;
|
||||
while (chr >= _T('0') && chr <= _T('9'))
|
||||
{
|
||||
fieldwidth = fieldwidth * 10 + (chr - _T('0'));
|
||||
chr = *format++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle precision modifier */
|
||||
if (chr == '.')
|
||||
{
|
||||
chr = *format++;
|
||||
|
||||
if (chr == _T('*'))
|
||||
{
|
||||
precision = va_arg(argptr, int);
|
||||
chr = *format++;
|
||||
}
|
||||
else
|
||||
{
|
||||
precision = 0;
|
||||
while (chr >= _T('0') && chr <= _T('9'))
|
||||
{
|
||||
precision = precision * 10 + (chr - _T('0'));
|
||||
chr = *format++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else precision = -1;
|
||||
|
||||
/* Handle argument size prefix */
|
||||
while (1)
|
||||
{
|
||||
if (chr == _T('h')) flags |= FLAG_SHORT;
|
||||
else if (chr == _T('w')) flags |= FLAG_WIDECHAR;
|
||||
else if (chr == _T('L')) flags |= 0; // FIXME: long double
|
||||
else if (chr == _T('l'))
|
||||
{
|
||||
flags |= FLAG_LONG;
|
||||
#if SUPPORT_LL
|
||||
if (format[0] == _T('l'))
|
||||
{
|
||||
format++;
|
||||
flags |= FLAG_INT64;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (chr == _T('I'))
|
||||
{
|
||||
if (format[0] == _T('3') && format[1] == _T('2'))
|
||||
{
|
||||
format += 2;
|
||||
}
|
||||
else if (format[0] == _T('6') && format[1] == _T('4'))
|
||||
{
|
||||
format += 2;
|
||||
flags |= FLAG_INT64;
|
||||
}
|
||||
else if (format[0] == _T('x') || format[0] == _T('X') ||
|
||||
format[0] == _T('d') || format[0] == _T('i') ||
|
||||
format[0] == _T('u') || format[0] == _T('o'))
|
||||
{
|
||||
flags |= FLAG_INTPTR;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else break;
|
||||
chr = *format++;
|
||||
}
|
||||
|
||||
/* Handle the format specifier */
|
||||
digits = digits_l;
|
||||
string = &buffer[BUFFER_SIZE];
|
||||
base = 10;
|
||||
prefix = 0;
|
||||
switch (chr)
|
||||
{
|
||||
case _T('n'):
|
||||
if (flags & FLAG_INT64)
|
||||
*va_arg(argptr, __int64*) = written_all;
|
||||
else if (flags & FLAG_SHORT)
|
||||
*va_arg(argptr, short*) = written_all;
|
||||
else
|
||||
*va_arg(argptr, int*) = written_all;
|
||||
continue;
|
||||
|
||||
case _T('C'):
|
||||
#ifndef _UNICODE
|
||||
if (!(flags & FLAG_SHORT)) flags |= FLAG_WIDECHAR;
|
||||
#endif
|
||||
goto case_char;
|
||||
|
||||
case _T('c'):
|
||||
#ifdef _UNICODE
|
||||
if (!(flags & FLAG_SHORT)) flags |= FLAG_WIDECHAR;
|
||||
#endif
|
||||
case_char:
|
||||
string = buffer;
|
||||
len = 1;
|
||||
if (flags & FLAG_WIDECHAR)
|
||||
{
|
||||
((wchar_t*)string)[0] = va_arg(argptr, int);
|
||||
((wchar_t*)string)[1] = _T('\0');
|
||||
}
|
||||
else
|
||||
{
|
||||
((char*)string)[0] = va_arg(argptr, int);
|
||||
((char*)string)[1] = _T('\0');
|
||||
}
|
||||
break;
|
||||
|
||||
case _T('Z'):
|
||||
nt_string = va_arg(argptr, void*);
|
||||
if (nt_string && (string = nt_string->Buffer))
|
||||
{
|
||||
len = nt_string->Length;
|
||||
if (flags & FLAG_WIDECHAR) len /= sizeof(wchar_t);
|
||||
break;
|
||||
}
|
||||
string = 0;
|
||||
goto case_string;
|
||||
|
||||
case _T('S'):
|
||||
string = va_arg(argptr, void*);
|
||||
#ifndef _UNICODE
|
||||
if (!(flags & FLAG_SHORT)) flags |= FLAG_WIDECHAR;
|
||||
#endif
|
||||
goto case_string;
|
||||
|
||||
case _T('s'):
|
||||
string = va_arg(argptr, void*);
|
||||
#ifdef _UNICODE
|
||||
if (!(flags & FLAG_SHORT)) flags |= FLAG_WIDECHAR;
|
||||
#endif
|
||||
|
||||
case_string:
|
||||
if (!string)
|
||||
{
|
||||
string = (TCHAR*)_nullstring;
|
||||
flags &= ~FLAG_WIDECHAR;
|
||||
}
|
||||
|
||||
if (flags & FLAG_WIDECHAR)
|
||||
len = wcslen((wchar_t*)string);
|
||||
else
|
||||
len = strlen((char*)string);
|
||||
if (precision >= 0 && len > precision) len = precision;
|
||||
break;
|
||||
|
||||
case _T('G'):
|
||||
case _T('E'):
|
||||
case _T('A'):
|
||||
case _T('g'):
|
||||
case _T('e'):
|
||||
case _T('a'):
|
||||
case _T('f'):
|
||||
#ifdef _UNICODE
|
||||
flags |= FLAG_WIDECHAR;
|
||||
#else
|
||||
flags &= ~FLAG_WIDECHAR;
|
||||
#endif
|
||||
/* Use external function, one for kernel one for user mode */
|
||||
format_float(chr, flags, precision, &string, &prefix, &argptr);
|
||||
len = _tcslen(string);
|
||||
precision = 0;
|
||||
break;
|
||||
|
||||
case _T('d'):
|
||||
case _T('i'):
|
||||
val64 = (__int64)va_arg_f(argptr, flags);
|
||||
|
||||
if ((__int64)val64 < 0)
|
||||
{
|
||||
val64 = -val64;
|
||||
prefix = _T("-");
|
||||
}
|
||||
else if (flags & FLAG_FORCE_SIGN)
|
||||
prefix = _T("+");
|
||||
else if (flags & FLAG_FORCE_SIGNSP)
|
||||
prefix = _T(" ");
|
||||
|
||||
goto case_number;
|
||||
|
||||
case _T('o'):
|
||||
base = 8;
|
||||
if (flags & FLAG_SPECIAL) prefix = _T("0");
|
||||
goto case_unsigned;
|
||||
/* Fall through */
|
||||
|
||||
case _T('p'):
|
||||
precision = 2 * sizeof(void*);
|
||||
flags &= ~FLAG_PAD_ZERO;
|
||||
flags |= FLAG_INTPTR;
|
||||
/* Fall through */
|
||||
|
||||
case _T('X'):
|
||||
digits = digits_u;
|
||||
/* Fall through */
|
||||
|
||||
case _T('x'):
|
||||
base = 16;
|
||||
if (flags & FLAG_SPECIAL)
|
||||
{
|
||||
prefix = &digits[16];
|
||||
}
|
||||
|
||||
case _T('u'):
|
||||
case_unsigned:
|
||||
val64 = va_arg_fu(argptr, flags);
|
||||
|
||||
case_number:
|
||||
#ifdef _UNICODE
|
||||
flags |= FLAG_WIDECHAR;
|
||||
#else
|
||||
flags &= ~FLAG_WIDECHAR;
|
||||
#endif
|
||||
if (precision < 0) precision = 1;
|
||||
|
||||
/* Gather digits in reverse order */
|
||||
while (val64)
|
||||
{
|
||||
*--string = digits[val64 % base];
|
||||
val64 /= base;
|
||||
precision--;
|
||||
}
|
||||
|
||||
len = _tcslen(string);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Treat anything else as a new character */
|
||||
format--;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Calculate padding */
|
||||
prefixlen = prefix ? _tcslen(prefix) : 0;
|
||||
if (precision < 0) precision = 0;
|
||||
padding = fieldwidth - len - prefixlen - precision;
|
||||
if (padding < 0) padding = 0;
|
||||
|
||||
/* Optional left space padding */
|
||||
if ((flags & (FLAG_ALIGN_LEFT | FLAG_PAD_ZERO)) == 0)
|
||||
{
|
||||
for (; padding > 0; padding--)
|
||||
{
|
||||
if ((written = streamout_char(stream, _T(' '))) == -1) return -2;
|
||||
written_all += written;
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional prefix */
|
||||
if (prefix)
|
||||
{
|
||||
written = streamout_string(stream, prefix, prefixlen);
|
||||
if (written == -1) return -3;
|
||||
written_all += written;
|
||||
}
|
||||
|
||||
/* Optional left '0' padding */
|
||||
if ((flags & FLAG_ALIGN_LEFT) == 0) precision += padding;
|
||||
while (precision-- > 0)
|
||||
{
|
||||
if ((written = streamout_char(stream, _T('0'))) == -1) return -4;
|
||||
written_all += written;
|
||||
}
|
||||
|
||||
/* Output the string */
|
||||
if (flags & FLAG_WIDECHAR)
|
||||
written = streamout_wstring(stream, (wchar_t*)string, len);
|
||||
else
|
||||
written = streamout_astring(stream, (char*)string, len);
|
||||
if (written == -1) return -5;
|
||||
written_all += written;
|
||||
|
||||
#if 0 && SUPPORT_FLOAT
|
||||
/* Optional right '0' padding */
|
||||
while (precision-- > 0)
|
||||
{
|
||||
if ((written = streamout_char(stream, _T('0'))) == -1) return -6;
|
||||
written_all += written;
|
||||
len++;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Optional right padding */
|
||||
if (flags & FLAG_ALIGN_LEFT)
|
||||
{
|
||||
while (padding-- > 0)
|
||||
{
|
||||
if ((written = streamout_char(stream, _T(' '))) == -1) return -7;
|
||||
written_all += written;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (written == -1) return -8;
|
||||
|
||||
return written_all;
|
||||
}
|
||||
|
39
lib/sdk/crt/printf/swprintf.c
Normal file
39
lib/sdk/crt/printf/swprintf.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/swprintf.c
|
||||
* PURPOSE: Implementation of swprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
swprintf(wchar_t *buffer, const wchar_t *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = INT_MAX;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = 0;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = wstreamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
*(wchar_t*)stream._ptr = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
|
29
lib/sdk/crt/printf/vfprintf.c
Normal file
29
lib/sdk/crt/printf/vfprintf.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/vfprintf.c
|
||||
* PURPOSE: Implementation of vfprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void _cdecl _lock_file(FILE* file);
|
||||
void _cdecl _unlock_file(FILE* file);
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
vfprintf(FILE *stream, const char *format, va_list argptr)
|
||||
{
|
||||
int result;
|
||||
|
||||
_lock_file(stream);
|
||||
|
||||
result = streamout(stream, format, argptr);
|
||||
|
||||
_unlock_file(stream);
|
||||
|
||||
return result;
|
||||
}
|
20
lib/sdk/crt/printf/vfwprintf.c
Normal file
20
lib/sdk/crt/printf/vfwprintf.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/vfwprintf.c
|
||||
* PURPOSE: Implementation of vfwprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vfwprintf(FILE* file, const wchar_t *format, va_list argptr)
|
||||
{
|
||||
return wstreamout(file, format, argptr);
|
||||
}
|
||||
|
19
lib/sdk/crt/printf/vprintf.c
Normal file
19
lib/sdk/crt/printf/vprintf.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/vprintf.c
|
||||
* PURPOSE: Implementation of vprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vprintf(const char *format, va_list argptr)
|
||||
{
|
||||
return streamout(stdout, format, argptr);
|
||||
}
|
37
lib/sdk/crt/printf/vsprintf.c
Normal file
37
lib/sdk/crt/printf/vsprintf.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/vsprintf.c
|
||||
* PURPOSE: Implementation of vsprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vsprintf(
|
||||
char *buffer,
|
||||
const char *format,
|
||||
va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = INT_MAX;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG|_IOWRT|_IOMYBUF;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
result = streamout(&stream, format, argptr);
|
||||
*stream._ptr = '\0';
|
||||
|
||||
return result;
|
||||
}
|
18
lib/sdk/crt/printf/vswprintf.c
Normal file
18
lib/sdk/crt/printf/vswprintf.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/vswprintf.c
|
||||
* PURPOSE: Implementation of vswprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vswprintf(wchar_t *buffer, const wchar_t *format, va_list argptr)
|
||||
{
|
||||
return _vsnwprintf(buffer, INT_MAX, format, argptr);
|
||||
}
|
19
lib/sdk/crt/printf/vwprintf.c
Normal file
19
lib/sdk/crt/printf/vwprintf.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/vwprintf.c
|
||||
* PURPOSE: Implementation of vwprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vwprintf(const wchar_t *format, va_list argptr)
|
||||
{
|
||||
return wstreamout(stdout, format, argptr);
|
||||
}
|
25
lib/sdk/crt/printf/wprintf.c
Normal file
25
lib/sdk/crt/printf/wprintf.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wprintf.c
|
||||
* PURPOSE: Implementation of wprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
wprintf(const wchar_t *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = wstreamout(stdout, format, argptr);
|
||||
va_end(argptr);
|
||||
return result;
|
||||
}
|
12
lib/sdk/crt/printf/wstreamout.c
Normal file
12
lib/sdk/crt/printf/wstreamout.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wstreamout.c
|
||||
* PURPOSE: Implementation of wstreamout
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#define UNICODE
|
||||
|
||||
#include "streamout.c"
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <asm.inc>
|
||||
#include <ksamd64.inc>
|
||||
|
||||
#define JUMP_BUFFER_Frame 0x00
|
||||
#define JUMP_BUFFER_Rbx 0x08
|
||||
|
@ -156,3 +156,5 @@ PUBLIC longjmp
|
|||
inc rax
|
||||
2: jmp r8
|
||||
.endp longjmp
|
||||
|
||||
END
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
* complete implementation
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
#define JB_BP 0
|
||||
#define JB_BX 1
|
||||
#define JB_DI 2
|
||||
|
@ -20,6 +22,7 @@
|
|||
|
||||
#define JMPBUF 4
|
||||
|
||||
.code
|
||||
/*
|
||||
* int
|
||||
* _setjmp(jmp_buf env);
|
||||
|
@ -33,20 +36,20 @@
|
|||
* Notes:
|
||||
* Sets up the jmp_buf
|
||||
*/
|
||||
.globl __setjmp
|
||||
PUBLIC __setjmp
|
||||
__setjmp:
|
||||
xorl %eax, %eax
|
||||
movl JMPBUF(%esp), %edx
|
||||
xor eax, eax
|
||||
mov edx, JMPBUF[esp]
|
||||
|
||||
/* Save registers. */
|
||||
movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
|
||||
movl %ebx, (JB_BX*4)(%edx)
|
||||
movl %edi, (JB_DI*4)(%edx)
|
||||
movl %esi, (JB_SI*4)(%edx)
|
||||
leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
|
||||
movl %ecx, (JB_SP*4)(%edx)
|
||||
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
|
||||
movl %ecx, (JB_IP*4)(%edx)
|
||||
mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */
|
||||
mov [edx + JB_BX*4], ebx
|
||||
mov [edx + JB_DI*4], edi
|
||||
mov [edx + JB_SI*4], esi
|
||||
lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */
|
||||
mov [edx + JB_SP*4], ecx
|
||||
mov ecx, PCOFF[esp] /* Save PC we are returning to now. */
|
||||
mov [edx + JB_IP*4], ecx
|
||||
ret
|
||||
|
||||
/*
|
||||
|
@ -62,24 +65,22 @@ __setjmp:
|
|||
* Notes:
|
||||
* Sets up the jmp_buf
|
||||
*/
|
||||
.globl __setjmp3
|
||||
PUBLIC __setjmp3
|
||||
__setjmp3:
|
||||
xorl %eax, %eax
|
||||
movl JMPBUF(%esp), %edx
|
||||
xor eax, eax
|
||||
mov edx, JMPBUF[esp]
|
||||
|
||||
/* Save registers. */
|
||||
movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
|
||||
movl %ebx, (JB_BX*4)(%edx)
|
||||
movl %edi, (JB_DI*4)(%edx)
|
||||
movl %esi, (JB_SI*4)(%edx)
|
||||
leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
|
||||
movl %ecx, (JB_SP*4)(%edx)
|
||||
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
|
||||
movl %ecx, (JB_IP*4)(%edx)
|
||||
mov [edx + JB_BP*4], ebp /* Save caller's frame pointer. */
|
||||
mov [edx + JB_BX*4], ebx
|
||||
mov [edx + JB_DI*4], edi
|
||||
mov [edx + JB_SI*4], esi
|
||||
lea ecx, JMPBUF[esp] /* Save SP as it will be after we return. */
|
||||
mov [edx + JB_SP*4], ecx
|
||||
mov ecx, PCOFF[esp] /* Save PC we are returning to now. */
|
||||
mov [edx + JB_IP*4], ecx
|
||||
ret
|
||||
|
||||
#define VAL 8
|
||||
|
||||
/*
|
||||
* void
|
||||
* longjmp(jmp_buf env, int value);
|
||||
|
@ -94,18 +95,20 @@ __setjmp3:
|
|||
* Notes:
|
||||
* Non-local goto
|
||||
*/
|
||||
.globl _longjmp
|
||||
PUBLIC _longjmp
|
||||
_longjmp:
|
||||
movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
|
||||
mov ecx, JMPBUF[esp] /* User's jmp_buf in %ecx. */
|
||||
|
||||
movl VAL(%esp), %eax /* Second argument is return value. */
|
||||
mov eax, [esp + 8] /* Second argument is return value. */
|
||||
/* Save the return address now. */
|
||||
movl (JB_IP*4)(%ecx), %edx
|
||||
mov edx, [ecx + JB_IP*4]
|
||||
/* Restore registers. */
|
||||
movl (JB_BP*4)(%ecx), %ebp
|
||||
movl (JB_BX*4)(%ecx), %ebx
|
||||
movl (JB_DI*4)(%ecx), %edi
|
||||
movl (JB_SI*4)(%ecx), %esi
|
||||
movl (JB_SP*4)(%ecx), %esp
|
||||
mov ebp, [ecx + JB_BP*4]
|
||||
mov ebx, [ecx + JB_BX*4]
|
||||
mov edi, [ecx + JB_DI*4]
|
||||
mov esi, [ecx + JB_SI*4]
|
||||
mov esp, [ecx + JB_SP*4]
|
||||
/* Jump to saved PC. */
|
||||
jmp *%edx
|
||||
jmp edx
|
||||
|
||||
END
|
||||
|
|
|
@ -2814,6 +2814,7 @@ FILE* CDECL tmpfile(void)
|
|||
return file;
|
||||
}
|
||||
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
/*********************************************************************
|
||||
* vfprintf (MSVCRT.@)
|
||||
*/
|
||||
|
@ -2947,6 +2948,7 @@ int CDECL printf(const char *format, ...)
|
|||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* ungetc (MSVCRT.@)
|
||||
|
@ -2984,6 +2986,7 @@ wint_t CDECL ungetwc(wint_t wc, FILE * file)
|
|||
return mwc;
|
||||
}
|
||||
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
/*********************************************************************
|
||||
* wprintf (MSVCRT.@)
|
||||
*/
|
||||
|
@ -2996,6 +2999,7 @@ int CDECL wprintf(const wchar_t *format, ...)
|
|||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* _getmaxstdio (MSVCRT.@)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* Lars Wirzenius & Linus Torvalds
|
||||
* Wirzenius wrote this portably, Torvalds fucked it up :-)
|
||||
*/
|
||||
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
#include <precomp.h>
|
||||
|
||||
#include <wchar.h>
|
||||
|
@ -879,3 +879,4 @@ int __cdecl vsprintf(char *buf, const char *fmt, va_list args)
|
|||
}
|
||||
#endif
|
||||
/* EOF */
|
||||
#endif
|
||||
|
|
15
lib/sdk/crt/stdio/lock_file.c
Normal file
15
lib/sdk/crt/stdio/lock_file.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
_cdecl
|
||||
_lock_file(FILE* file)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_cdecl
|
||||
_unlock_file(FILE* file)
|
||||
{
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcscat.h"
|
||||
#include "tcscat.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcschr.h"
|
||||
#include "tcschr.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcscmp.h"
|
||||
#include "tcscmp.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcscpy.h"
|
||||
#include "tcscpy.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcslen.h"
|
||||
#include "tcslen.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsncat.h"
|
||||
#include "tcsncat.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsncmp.h"
|
||||
#include "tcsncmp.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsncpy.h"
|
||||
#include "tcsncpy.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsnlen.h"
|
||||
#include "tcsnlen.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsrchr.h"
|
||||
#include "tcsrchr.inc"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
#define _tlods lodsw
|
||||
#define _tstos stosw
|
||||
|
||||
#define _tsize $2
|
||||
#define _tsize 2
|
||||
|
||||
#define _treg(_O_) _O_ ## x
|
||||
|
||||
#define _tdec(_O_) sub $2, _O_
|
||||
#define _tinc(_O_) add $2, _O_
|
||||
#define _tdec(_O_) sub _O_, 2
|
||||
#define _tinc(_O_) add _O_, 2
|
||||
|
||||
#else
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
|||
#define _tlods lodsb
|
||||
#define _tstos stosb
|
||||
|
||||
#define _tsize $1
|
||||
#define _tsize 1
|
||||
|
||||
#define _treg(_O_) _O_ ## l
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcscat
|
||||
|
||||
_tcscat:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %edi
|
||||
mov 0x10(%esp), %esi
|
||||
|
||||
xor %eax, %eax
|
||||
mov $-1, %ecx
|
||||
cld
|
||||
|
||||
repne _tscas
|
||||
_tdec(%edi)
|
||||
|
||||
.L1:
|
||||
_tlods
|
||||
_tstos
|
||||
test %_treg(a), %_treg(a)
|
||||
jnz .L1
|
||||
|
||||
mov 0x0C(%esp), %eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue