mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[CRT/ARM] Implement __dtoi64/dtou64/stoi64/stou64 functions (#3848)
CORE-17703 CORE-17604
This commit is contained in:
parent
fd8baca9f2
commit
e448094e74
11 changed files with 240 additions and 24 deletions
|
@ -1,23 +1,37 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
* PROJECT: ReactOS CRT library
|
||||||
* PROJECT: ReactOS CRT library
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
* PURPOSE: Implementation of __dtoi64
|
* PURPOSE: Implementation of __dtoi64
|
||||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||||
|
* Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <kxarm.h>
|
#include <kxarm.h>
|
||||||
|
|
||||||
|
IMPORT __dtoi64_worker
|
||||||
|
|
||||||
/* CODE **********************************************************************/
|
/* CODE **********************************************************************/
|
||||||
|
|
||||||
TEXTAREA
|
TEXTAREA
|
||||||
|
|
||||||
|
/*
|
||||||
|
IN: d0 = double value
|
||||||
|
OUT: r1:r0 = int64 value
|
||||||
|
*/
|
||||||
LEAF_ENTRY __dtoi64
|
LEAF_ENTRY __dtoi64
|
||||||
|
/* Allocate stack space and store parameters there */
|
||||||
|
push {lr}
|
||||||
|
PROLOG_END
|
||||||
|
|
||||||
__assertfail
|
/* Call the C worker function */
|
||||||
bx lr
|
VMOV r0,d0[0]
|
||||||
|
VMOV r1,d0[1]
|
||||||
|
bl __dtoi64_worker
|
||||||
|
|
||||||
|
/* Move result data into the appropriate registers and return */
|
||||||
|
pop {pc}
|
||||||
LEAF_END __dtoi64
|
LEAF_END __dtoi64
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
14
sdk/lib/crt/math/arm/__dtoi64_worker.c
Normal file
14
sdk/lib/crt/math/arm/__dtoi64_worker.c
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS CRT library
|
||||||
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
|
* PURPOSE: Implementation of __dtoi64_worker
|
||||||
|
* COPYRIGHT: Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __fto64_worker __dtoi64_worker
|
||||||
|
#define _USE_64_BITS_
|
||||||
|
#define _USE_SIGNED_
|
||||||
|
|
||||||
|
#include "__fto64_worker.h"
|
||||||
|
|
||||||
|
/* __dtoi64 is implemented in __dtoi64.s */
|
|
@ -1,23 +1,37 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
* PROJECT: ReactOS CRT library
|
||||||
* PROJECT: ReactOS CRT library
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
* PURPOSE: Implementation of __dtou64
|
* PURPOSE: Implementation of __dtou64
|
||||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||||
|
* Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <kxarm.h>
|
#include <kxarm.h>
|
||||||
|
|
||||||
|
IMPORT __dtou64_worker
|
||||||
|
|
||||||
/* CODE **********************************************************************/
|
/* CODE **********************************************************************/
|
||||||
|
|
||||||
TEXTAREA
|
TEXTAREA
|
||||||
|
|
||||||
|
/*
|
||||||
|
IN: d0 = double value
|
||||||
|
OUT: r1:r0 = uint64 value
|
||||||
|
*/
|
||||||
LEAF_ENTRY __dtou64
|
LEAF_ENTRY __dtou64
|
||||||
|
/* Allocate stack space and store parameters there */
|
||||||
|
push {lr}
|
||||||
|
PROLOG_END
|
||||||
|
|
||||||
__assertfail
|
/* Call the C worker function */
|
||||||
bx lr
|
VMOV r0,d0[0]
|
||||||
|
VMOV r1,d0[1]
|
||||||
|
bl __dtou64_worker
|
||||||
|
|
||||||
|
/* Move result data into the appropriate registers and return */
|
||||||
|
pop {pc}
|
||||||
LEAF_END __dtou64
|
LEAF_END __dtou64
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
13
sdk/lib/crt/math/arm/__dtou64_worker.c
Normal file
13
sdk/lib/crt/math/arm/__dtou64_worker.c
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS CRT library
|
||||||
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
|
* PURPOSE: Implementation of __dtou64_worker
|
||||||
|
* COPYRIGHT: Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __fto64_worker __dtou64_worker
|
||||||
|
#define _USE_64_BITS_
|
||||||
|
|
||||||
|
#include "__fto64_worker.h"
|
||||||
|
|
||||||
|
/* __dtou64 is implemented in __dtou64.s */
|
102
sdk/lib/crt/math/arm/__fto64_worker.h
Normal file
102
sdk/lib/crt/math/arm/__fto64_worker.h
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS CRT library
|
||||||
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
|
* PURPOSE: Implementation of __dtoi64
|
||||||
|
* COPYRIGHT: Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _USE_64_BITS_
|
||||||
|
typedef double FLOAT_TYPE;
|
||||||
|
typedef unsigned long long FINT_TYPE;
|
||||||
|
#define FRACTION_LEN 52
|
||||||
|
#define EXPONENT_LEN 11
|
||||||
|
#else
|
||||||
|
typedef float FLOAT_TYPE;
|
||||||
|
typedef unsigned int FINT_TYPE;
|
||||||
|
#define FRACTION_LEN 23
|
||||||
|
#define EXPONENT_LEN 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef
|
||||||
|
#ifndef _USE_SIGNED_
|
||||||
|
unsigned
|
||||||
|
#endif
|
||||||
|
long long FTO64_RESULT;
|
||||||
|
|
||||||
|
#define SIGN_MASK (((FINT_TYPE)1) << (FRACTION_LEN + EXPONENT_LEN))
|
||||||
|
|
||||||
|
#define FRACTION_ONE (((FINT_TYPE)1) << FRACTION_LEN)
|
||||||
|
#define FRACTION_MASK ((FRACTION_ONE) - 1)
|
||||||
|
|
||||||
|
#define EXPONENT_MASK ((1 << EXPONENT_LEN) - 1)
|
||||||
|
#define EXPONENT_ZERO ((1 << (EXPONENT_LEN - 1)) - 1)
|
||||||
|
|
||||||
|
#ifdef _USE_SIGNED_
|
||||||
|
#define EXPONENT_MAX 62
|
||||||
|
#define INTNAN 0x8000000000000000ULL
|
||||||
|
#else
|
||||||
|
#define EXPONENT_MAX 63
|
||||||
|
#define INTNAN 0xFFFFFFFFFFFFFFFFULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EXPONENT_INFINITY EXPONENT_MASK
|
||||||
|
|
||||||
|
#define NEGATE(x) (~(x) + 1)
|
||||||
|
|
||||||
|
FTO64_RESULT
|
||||||
|
__fto64_worker(FLOAT_TYPE value)
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
FLOAT_TYPE val_float;
|
||||||
|
FINT_TYPE val_int;
|
||||||
|
} u;
|
||||||
|
int exponent;
|
||||||
|
FTO64_RESULT fraction;
|
||||||
|
|
||||||
|
u.val_float = value;
|
||||||
|
|
||||||
|
exponent = (int)(u.val_int >> FRACTION_LEN);
|
||||||
|
exponent &= EXPONENT_MASK;
|
||||||
|
|
||||||
|
/* infinity and other NaNs */
|
||||||
|
if (exponent == EXPONENT_INFINITY)
|
||||||
|
return INTNAN;
|
||||||
|
|
||||||
|
/* subnormals and signed zeros */
|
||||||
|
if (exponent == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
exponent -= EXPONENT_ZERO;
|
||||||
|
|
||||||
|
/* number is less then one */
|
||||||
|
if (exponent < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* number is too big */
|
||||||
|
if (exponent > EXPONENT_MAX)
|
||||||
|
return INTNAN;
|
||||||
|
|
||||||
|
#ifndef _USE_SIGNED_
|
||||||
|
if (u.val_int & SIGN_MASK)
|
||||||
|
return INTNAN;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fraction = u.val_int & FRACTION_MASK;
|
||||||
|
fraction |= FRACTION_ONE;
|
||||||
|
|
||||||
|
exponent -= FRACTION_LEN;
|
||||||
|
if (exponent != 0)
|
||||||
|
{
|
||||||
|
if (exponent < 0)
|
||||||
|
fraction = fraction >> NEGATE(exponent);
|
||||||
|
else
|
||||||
|
fraction = fraction << exponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _USE_SIGNED_
|
||||||
|
if (u.val_int & SIGN_MASK)
|
||||||
|
fraction = NEGATE(fraction);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return fraction;
|
||||||
|
}
|
|
@ -1,23 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
* PROJECT: ReactOS CRT library
|
||||||
* PROJECT: ReactOS CRT library
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
* PURPOSE: Implementation of __stoi64
|
* PURPOSE: Implementation of __stoi64
|
||||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||||
|
* Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <kxarm.h>
|
#include <kxarm.h>
|
||||||
|
|
||||||
|
IMPORT __stoi64_worker
|
||||||
|
|
||||||
/* CODE **********************************************************************/
|
/* CODE **********************************************************************/
|
||||||
|
|
||||||
TEXTAREA
|
TEXTAREA
|
||||||
|
|
||||||
|
/*
|
||||||
|
IN: s0 = single (float) value
|
||||||
|
OUT: r1:r0 = int64 value
|
||||||
|
*/
|
||||||
LEAF_ENTRY __stoi64
|
LEAF_ENTRY __stoi64
|
||||||
|
/* Allocate stack space and store parameters there */
|
||||||
|
push {lr}
|
||||||
|
PROLOG_END
|
||||||
|
|
||||||
__assertfail
|
/* Call the C worker function */
|
||||||
bx lr
|
VMOV r0,s0
|
||||||
|
bl __stoi64_worker
|
||||||
|
|
||||||
|
/* Move result data into the appropriate registers and return */
|
||||||
|
pop {pc}
|
||||||
LEAF_END __stoi64
|
LEAF_END __stoi64
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
13
sdk/lib/crt/math/arm/__stoi64_worker.c
Normal file
13
sdk/lib/crt/math/arm/__stoi64_worker.c
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS CRT library
|
||||||
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
|
* PURPOSE: Implementation of __stoi64_worker
|
||||||
|
* COPYRIGHT: Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __fto64_worker __stoi64_worker
|
||||||
|
#define _USE_SIGNED_
|
||||||
|
|
||||||
|
#include "__fto64_worker.h"
|
||||||
|
|
||||||
|
/* __stoi64 is implemented in __stoi64.s */
|
|
@ -1,23 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: BSD - See COPYING.ARM in the top level directory
|
* PROJECT: ReactOS CRT library
|
||||||
* PROJECT: ReactOS CRT library
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
* PURPOSE: Implementation of __stou64
|
* PURPOSE: Implementation of __stou64
|
||||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||||
|
* Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <kxarm.h>
|
#include <kxarm.h>
|
||||||
|
|
||||||
|
IMPORT __stou64_worker
|
||||||
|
|
||||||
/* CODE **********************************************************************/
|
/* CODE **********************************************************************/
|
||||||
|
|
||||||
TEXTAREA
|
TEXTAREA
|
||||||
|
|
||||||
|
/*
|
||||||
|
IN: s0 = single (float) value
|
||||||
|
OUT: r1:r0 = uint64 value
|
||||||
|
*/
|
||||||
LEAF_ENTRY __stou64
|
LEAF_ENTRY __stou64
|
||||||
|
/* Allocate stack space and store parameters there */
|
||||||
|
push {lr}
|
||||||
|
PROLOG_END
|
||||||
|
|
||||||
__assertfail
|
/* Call the C worker function */
|
||||||
bx lr
|
VMOV r0,s0
|
||||||
|
bl __stou64_worker
|
||||||
|
|
||||||
|
/* Move result data into the appropriate registers and return */
|
||||||
|
pop {pc}
|
||||||
LEAF_END __stou64
|
LEAF_END __stou64
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
12
sdk/lib/crt/math/arm/__stou64_worker.c
Normal file
12
sdk/lib/crt/math/arm/__stou64_worker.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS CRT library
|
||||||
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
|
* PURPOSE: Implementation of __stou64_worker
|
||||||
|
* COPYRIGHT: Copyright 2021 Roman Masanin <36927roma@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __fto64_worker __stou64_worker
|
||||||
|
|
||||||
|
#include "__fto64_worker.h"
|
||||||
|
|
||||||
|
/* __stou64 is implemented in __stou64.s */
|
|
@ -79,6 +79,10 @@ elseif(ARCH STREQUAL "arm")
|
||||||
math/arm/__rt_sdiv64_worker.c
|
math/arm/__rt_sdiv64_worker.c
|
||||||
math/arm/__rt_udiv.c
|
math/arm/__rt_udiv.c
|
||||||
math/arm/__rt_udiv64_worker.c
|
math/arm/__rt_udiv64_worker.c
|
||||||
|
math/arm/__dtoi64_worker.c
|
||||||
|
math/arm/__dtou64_worker.c
|
||||||
|
math/arm/__stoi64_worker.c
|
||||||
|
math/arm/__stou64_worker.c
|
||||||
)
|
)
|
||||||
list(APPEND CRT_MATH_SOURCE
|
list(APPEND CRT_MATH_SOURCE
|
||||||
math/fabsf.c
|
math/fabsf.c
|
||||||
|
|
|
@ -72,6 +72,10 @@ elseif(ARCH STREQUAL "arm")
|
||||||
math/arm/__rt_sdiv64_worker.c
|
math/arm/__rt_sdiv64_worker.c
|
||||||
math/arm/__rt_udiv.c
|
math/arm/__rt_udiv.c
|
||||||
math/arm/__rt_udiv64_worker.c
|
math/arm/__rt_udiv64_worker.c
|
||||||
|
math/arm/__dtoi64_worker.c
|
||||||
|
math/arm/__dtou64_worker.c
|
||||||
|
math/arm/__stoi64_worker.c
|
||||||
|
math/arm/__stou64_worker.c
|
||||||
)
|
)
|
||||||
list(APPEND MSVCRTEX_ASM_SOURCE
|
list(APPEND MSVCRTEX_ASM_SOURCE
|
||||||
except/arm/chkstk_asm.s
|
except/arm/chkstk_asm.s
|
||||||
|
|
Loading…
Reference in a new issue