ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
142 discussions
Start a n
N
ew thread
[reactos] 02/02: [CRT_APITEST] Add tests for __dtoi64/dtou64/stoi64/stou64 on ARM (#3848)
by Roman Masanin
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=99ba98468f468be8c9e25…
commit 99ba98468f468be8c9e25eb94e184e363cc62100 Author: Roman Masanin <36927roma(a)gmail.com> AuthorDate: Tue Jul 27 00:31:29 2021 +0300 Commit: Stanislav Motylkov <x86corez(a)gmail.com> CommitDate: Fri Jul 30 14:20:23 2021 +0300 [CRT_APITEST] Add tests for __dtoi64/dtou64/stoi64/stou64 on ARM (#3848) CORE-17703 CORE-17604 --- modules/rostests/apitests/crt/__fto64.c | 198 +++++++++++++++++++++ .../rostests/apitests/crt/msvcrt_crt_apitest.cmake | 1 + modules/rostests/apitests/crt/testlist.c | 2 + 3 files changed, 201 insertions(+) diff --git a/modules/rostests/apitests/crt/__fto64.c b/modules/rostests/apitests/crt/__fto64.c new file mode 100644 index 00000000000..9b958aff1d2 --- /dev/null +++ b/modules/rostests/apitests/crt/__fto64.c @@ -0,0 +1,198 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Tests for __dtoi64/dtou64/stoi64/stou64 on ARM + * COPYRIGHT: Copyright 2021 Roman Masanin <36927roma(a)gmail.com> + */ + +#include <apitest.h> + +typedef struct _DTOI64_TEST_DATA +{ + union + { + double value; + unsigned long long raw; + } given; + long long expected; +} DTOI64_TEST_DATA; + +typedef struct _DTOU64_TEST_DATA +{ + union + { + double value; + unsigned long long raw; + } given; + unsigned long long expected; +} DTOU64_TEST_DATA; + +typedef struct _STOI64_TEST_DATA +{ + union + { + float value; + unsigned int raw; + } given; + long long expected; +} STOI64_TEST_DATA; + +typedef struct _STOU64_TEST_DATA +{ + union + { + float value; + unsigned int raw; + } given; + unsigned long long expected; +} STOU64_TEST_DATA; + +START_TEST(__fto64) +{ + DTOI64_TEST_DATA dtoi64[] = + { + { 1383034209.0, 1383034209LL }, /* test 32bit number */ + { -1383034209.0, -1383034209LL }, /* test negative 32bit number */ + { 1383034209.1383034209, 1383034209LL }, /* test rounding 32bit */ + { -1383034209.1383034209, -1383034209LL }, /* test negative rounding 32bit */ + { 1383034209.83034209, 1383034209LL }, /* test rounding up 32bit */ + { -1383034209.83034209, -1383034209LL }, /* test negative rounding up 32bit */ + { 354056757614.0, 354056757614LL }, /* test 64bit int */ + { -354056757614.0, -354056757614LL }, /* test negative 64bit int */ + { 354056757614.83034209, 354056757614LL }, /* test 64bit rounding */ + { 18445937028656326656.0, 0x8000000000000000LL }, /* test unsigned 64bit */ + { 1.0000001, 1LL }, + { 0.0000001, 0LL }, + { -0.0000001, 0LL }, + + /* special values tests */ + + { -0.0, 0LL }, /* test -0 */ + { +0.0, 0LL }, /* test +0 */ + { .given.raw = 0x7FF0000000000000ULL, 0x8000000000000000LL }, /* test +INFINITY */ + { .given.raw = 0xFFF0000000000000ULL, 0x8000000000000000LL }, /* test -INFINITY */ + { .given.raw = 0x7FF0000000000001ULL, 0x8000000000000000LL }, /* test NaN1 */ + { .given.raw = 0x7FF8000000000001ULL, 0x8000000000000000LL }, /* test NaN2 */ + { .given.raw = 0x7FFFFFFFFFFFFFFFULL, 0x8000000000000000LL }, /* test NaN3 */ + { .given.raw = 0x7FF80000000000F1ULL, 0x8000000000000000LL }, /* test NaN4 */ + }; + DTOU64_TEST_DATA dtou64[] = + { + { 1383034209.0, 1383034209ULL }, /* test 32bit number */ + { -1383034209.0, 18446744073709551615ULL }, /* test negative 32bit number */ + { 1383034209.1383034209, 1383034209ULL }, /* test rounding 32bit */ + { -1383034209.1383034209, 18446744073709551615ULL }, /* test negative rounding 32bit */ + { 1383034209.83034209, 1383034209ULL }, /* test rounding up 32bit */ + { -1383034209.83034209, 18446744073709551615ULL }, /* test negative rounding up 32bit */ + { 354056757614.0, 354056757614ULL }, /* test 64bit int */ + { -354056757614.0, 18446744073709551615ULL }, /* test negative 64bit int */ + { 354056757614.83034209, 354056757614ULL }, /* test 64bit rounding */ + { 18445937028656326656.0, 18445937028656326656ULL }, /* test unsigned 64bit */ + { 1.0000001, 1ULL }, + { 0.0000001, 0ULL }, + { -0.0000001, 0ULL }, + + /* special values tests */ + + { -0.0, 0ULL }, /* test -0 */ + { +0.0, 0ULL }, /* test +0 */ + { .given.raw = 0x7FF0000000000000ULL, 18446744073709551615ULL }, /* test +INFINITY */ + { .given.raw = 0xFFF0000000000000ULL, 18446744073709551615ULL }, /* test -INFINITY */ + { .given.raw = 0x7FF0000000000001ULL, 18446744073709551615ULL }, /* test NaN1 */ + { .given.raw = 0x7FF8000000000001ULL, 18446744073709551615ULL }, /* test NaN2 */ + { .given.raw = 0x7FFFFFFFFFFFFFFFULL, 18446744073709551615ULL }, /* test NaN3 */ + { .given.raw = 0x7FF80000000000F1ULL, 18446744073709551615ULL }, /* test NaN4 */ + }; + STOI64_TEST_DATA stoi64[] = + { + { 1383034.0f, 1383034LL }, /* test 32bit number */ + { -1383034.0f, -1383034LL }, /* test negative 32bit number */ + { 1383034.1383034209f, 1383034LL }, /* test rounding 32bit */ + { -1383034.1383034209f, -1383034LL }, /* test negative rounding 32bit */ + { 1383034.83034209f, 1383034LL }, /* test rounding up 32bit */ + { -1383034.83034209f, -1383034LL }, /* test negative rounding up 32bit */ + { 354056765440.0f, 354056765440LL }, /* test 64bit int */ + { -354056765440.0f, -354056765440LL }, /* test negative 64bit int */ + { 3000000.75f, 3000000LL }, /* test 64bit rounding */ + { 18445937032174764032.0f, 0x8000000000000000LL }, /* test unsigned 64bit */ + { 1.0000001f, 1LL }, + { 0.0000001f, 0LL }, + { -0.0000001f, 0LL }, + + /* special values tests */ + + { -0.0f, 0LL }, /* test -0 */ + { +0.0f, 0LL }, /* test +0 */ + { .given.raw = 0x7F800000U, 0x8000000000000000LL }, /* test +INFINITY */ + { .given.raw = 0xFF800000U, 0x8000000000000000LL }, /* test -INFINITY */ + { .given.raw = 0x7F800001U, 0x8000000000000000LL }, /* test NaN1 */ + { .given.raw = 0x7FC00001U, 0x8000000000000000LL }, /* test NaN2 */ + { .given.raw = 0x7F8FFFFFU, 0x8000000000000000LL }, /* test NaN3 */ + { .given.raw = 0x7F8000F1U, 0x8000000000000000LL }, /* test NaN4 */ + }; + STOU64_TEST_DATA stou64[] = + { + { 1383034.0f, 1383034ULL }, /* test 32bit number */ + { -1383034.0f, 18446744073709551615ULL }, /* test negative 32bit number */ + { 1383034.1383034209f, 1383034ULL }, /* test rounding 32bit */ + { -1383034.1383034209f, 18446744073709551615ULL }, /* test negative rounding 32bit */ + { 1383034.83034209f, 1383034ULL }, /* test rounding up 32bit */ + { -1383034.83034209f, 18446744073709551615ULL }, /* test negative rounding up 32bit */ + { 354056765440.0f, 354056765440ULL }, /* test 64bit int */ + { -354056765440.0f, 18446744073709551615ULL }, /* test negative 64bit int */ + { 3000000.75f, 3000000ULL }, /* test 64bit rounding */ + { 18445937032174764032.0f, 18445937032174764032ULL }, /* test unsigned 64bit */ + { 1.0000001f, 1ULL }, + { 0.0000001f, 0ULL }, + { -0.0000001f, 0ULL }, + + /* special values tests */ + + { -0.0f, 0LL }, /* test -0 */ + { +0.0f, 0LL }, /* test +0 */ + {.given.raw = 0x7F800000U, 18446744073709551615ULL }, /* test +INFINITY */ + {.given.raw = 0xFF800000U, 18446744073709551615ULL }, /* test -INFINITY */ + {.given.raw = 0x7F800001U, 18446744073709551615ULL }, /* test NaN1 */ + {.given.raw = 0x7FC00001U, 18446744073709551615ULL }, /* test NaN2 */ + {.given.raw = 0x7F8FFFFFU, 18446744073709551615ULL }, /* test NaN3 */ + {.given.raw = 0x7F8000F1U, 18446744073709551615ULL }, /* test NaN4 */ + }; + + unsigned int i; + + for (i = 0; i < _countof(dtoi64); ++i) + { + long long actual; + + actual = (long long)dtoi64[i].given.value; + ok(actual == dtoi64[i].expected, "(dtoi64) %d: Expected %lld, but %lf -> %lld\n", + i, dtoi64[i].expected, dtoi64[i].given.value, actual); + } + + for (i = 0; i < _countof(dtou64); ++i) + { + unsigned long long actual; + + actual = (unsigned long long)dtou64[i].given.value; + ok(actual == dtou64[i].expected, "(dtou64) %d: Expected %llu, but %lf -> %llu\n", + i, dtou64[i].expected, dtou64[i].given.value, actual); + } + + for (i = 0; i < _countof(stoi64); ++i) + { + long long actual; + + actual = (long long)stoi64[i].given.value; + ok(actual == stoi64[i].expected, "(stoi64) %d: Expected %lld, but %f -> %lld\n", + i, stoi64[i].expected, stoi64[i].given.value, actual); + } + + for (i = 0; i < _countof(stou64); ++i) + { + unsigned long long actual; + + actual = (unsigned long long)stou64[i].given.value; + ok(actual == stou64[i].expected, "(stou64) %d: Expected %llu, but %f -> %llu\n", + i, stou64[i].expected, stou64[i].given.value, actual); + } +} diff --git a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake index 2375f59472a..5c5bb587fbb 100644 --- a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake +++ b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake @@ -1374,6 +1374,7 @@ elseif(ARCH STREQUAL "amd64") elseif(ARCH STREQUAL "arm") list(APPEND SOURCE_MSVCRT __rt_div.c + __fto64.c ) endif() diff --git a/modules/rostests/apitests/crt/testlist.c b/modules/rostests/apitests/crt/testlist.c index ca76ebbf593..4c36c86eee4 100644 --- a/modules/rostests/apitests/crt/testlist.c +++ b/modules/rostests/apitests/crt/testlist.c @@ -5,6 +5,7 @@ #if defined(TEST_MSVCRT) extern void func___rt_div(void); +extern void func___fto64(void); extern void func__vscprintf(void); extern void func__vscwprintf(void); extern void func_atexit(void); @@ -62,6 +63,7 @@ const struct test winetest_testlist[] = { "__getmainargs", func___getmainargs }, #elif defined(_M_ARM) { "__rt_div", func___rt_div }, + { "__fto64", func___fto64 }, #endif { "_vscprintf", func__vscprintf }, { "_vscwprintf", func__vscwprintf },
3 years, 4 months
1
0
0
0
[reactos] 01/02: [CRT/ARM] Implement __dtoi64/dtou64/stoi64/stou64 functions (#3848)
by Roman Masanin
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e448094e741708bb65005…
commit e448094e741708bb65005549d76bf15f952ea6db Author: Roman Masanin <36927roma(a)gmail.com> AuthorDate: Sun Jul 25 17:50:48 2021 +0300 Commit: Stanislav Motylkov <x86corez(a)gmail.com> CommitDate: Fri Jul 30 14:20:23 2021 +0300 [CRT/ARM] Implement __dtoi64/dtou64/stoi64/stou64 functions (#3848) CORE-17703 CORE-17604 --- sdk/lib/crt/math/arm/__dtoi64.s | 26 +++++++-- sdk/lib/crt/math/arm/__dtoi64_worker.c | 14 +++++ sdk/lib/crt/math/arm/__dtou64.s | 26 +++++++-- sdk/lib/crt/math/arm/__dtou64_worker.c | 13 +++++ sdk/lib/crt/math/arm/__fto64_worker.h | 102 +++++++++++++++++++++++++++++++++ sdk/lib/crt/math/arm/__stoi64.s | 25 ++++++-- sdk/lib/crt/math/arm/__stoi64_worker.c | 13 +++++ sdk/lib/crt/math/arm/__stou64.s | 25 ++++++-- sdk/lib/crt/math/arm/__stou64_worker.c | 12 ++++ sdk/lib/crt/math/math.cmake | 4 ++ sdk/lib/crt/msvcrtex.cmake | 4 ++ 11 files changed, 240 insertions(+), 24 deletions(-) diff --git a/sdk/lib/crt/math/arm/__dtoi64.s b/sdk/lib/crt/math/arm/__dtoi64.s index 172d60f9f17..9e7e4cb7d74 100644 --- a/sdk/lib/crt/math/arm/__dtoi64.s +++ b/sdk/lib/crt/math/arm/__dtoi64.s @@ -1,23 +1,37 @@ /* - * COPYRIGHT: BSD - See COPYING.ARM in the top level directory - * PROJECT: ReactOS CRT library - * PURPOSE: Implementation of __dtoi64 - * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * PROJECT: ReactOS CRT library + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Implementation of __dtoi64 + * COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer(a)reactos.org> + * Copyright 2021 Roman Masanin <36927roma(a)gmail.com> */ /* INCLUDES ******************************************************************/ #include <kxarm.h> + IMPORT __dtoi64_worker + /* CODE **********************************************************************/ TEXTAREA + /* + IN: d0 = double value + OUT: r1:r0 = int64 value + */ LEAF_ENTRY __dtoi64 + /* Allocate stack space and store parameters there */ + push {lr} + PROLOG_END - __assertfail - bx lr + /* Call the C worker function */ + 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 END diff --git a/sdk/lib/crt/math/arm/__dtoi64_worker.c b/sdk/lib/crt/math/arm/__dtoi64_worker.c new file mode 100644 index 00000000000..beb247b24f5 --- /dev/null +++ b/sdk/lib/crt/math/arm/__dtoi64_worker.c @@ -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(a)gmail.com> + */ + +#define __fto64_worker __dtoi64_worker +#define _USE_64_BITS_ +#define _USE_SIGNED_ + +#include "__fto64_worker.h" + +/* __dtoi64 is implemented in __dtoi64.s */ diff --git a/sdk/lib/crt/math/arm/__dtou64.s b/sdk/lib/crt/math/arm/__dtou64.s index 03fd67b6b04..d204525a130 100644 --- a/sdk/lib/crt/math/arm/__dtou64.s +++ b/sdk/lib/crt/math/arm/__dtou64.s @@ -1,23 +1,37 @@ /* - * COPYRIGHT: BSD - See COPYING.ARM in the top level directory - * PROJECT: ReactOS CRT library - * PURPOSE: Implementation of __dtou64 - * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * PROJECT: ReactOS CRT library + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Implementation of __dtou64 + * COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer(a)reactos.org> + * Copyright 2021 Roman Masanin <36927roma(a)gmail.com> */ /* INCLUDES ******************************************************************/ #include <kxarm.h> + IMPORT __dtou64_worker + /* CODE **********************************************************************/ TEXTAREA + /* + IN: d0 = double value + OUT: r1:r0 = uint64 value + */ LEAF_ENTRY __dtou64 + /* Allocate stack space and store parameters there */ + push {lr} + PROLOG_END - __assertfail - bx lr + /* Call the C worker function */ + 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 END diff --git a/sdk/lib/crt/math/arm/__dtou64_worker.c b/sdk/lib/crt/math/arm/__dtou64_worker.c new file mode 100644 index 00000000000..432bd5df7f0 --- /dev/null +++ b/sdk/lib/crt/math/arm/__dtou64_worker.c @@ -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(a)gmail.com> + */ + +#define __fto64_worker __dtou64_worker +#define _USE_64_BITS_ + +#include "__fto64_worker.h" + +/* __dtou64 is implemented in __dtou64.s */ diff --git a/sdk/lib/crt/math/arm/__fto64_worker.h b/sdk/lib/crt/math/arm/__fto64_worker.h new file mode 100644 index 00000000000..e5e77b1665b --- /dev/null +++ b/sdk/lib/crt/math/arm/__fto64_worker.h @@ -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(a)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; +} diff --git a/sdk/lib/crt/math/arm/__stoi64.s b/sdk/lib/crt/math/arm/__stoi64.s index ab03260319e..636d35c9d9b 100644 --- a/sdk/lib/crt/math/arm/__stoi64.s +++ b/sdk/lib/crt/math/arm/__stoi64.s @@ -1,23 +1,36 @@ /* - * COPYRIGHT: BSD - See COPYING.ARM in the top level directory - * PROJECT: ReactOS CRT library - * PURPOSE: Implementation of __stoi64 - * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * PROJECT: ReactOS CRT library + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Implementation of __stoi64 + * COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer(a)reactos.org> + * Copyright 2021 Roman Masanin <36927roma(a)gmail.com> */ /* INCLUDES ******************************************************************/ #include <kxarm.h> + IMPORT __stoi64_worker + /* CODE **********************************************************************/ TEXTAREA + /* + IN: s0 = single (float) value + OUT: r1:r0 = int64 value + */ LEAF_ENTRY __stoi64 + /* Allocate stack space and store parameters there */ + push {lr} + PROLOG_END - __assertfail - bx lr + /* Call the C worker function */ + VMOV r0,s0 + bl __stoi64_worker + /* Move result data into the appropriate registers and return */ + pop {pc} LEAF_END __stoi64 END diff --git a/sdk/lib/crt/math/arm/__stoi64_worker.c b/sdk/lib/crt/math/arm/__stoi64_worker.c new file mode 100644 index 00000000000..d7beeb8d26b --- /dev/null +++ b/sdk/lib/crt/math/arm/__stoi64_worker.c @@ -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(a)gmail.com> + */ + +#define __fto64_worker __stoi64_worker +#define _USE_SIGNED_ + +#include "__fto64_worker.h" + +/* __stoi64 is implemented in __stoi64.s */ diff --git a/sdk/lib/crt/math/arm/__stou64.s b/sdk/lib/crt/math/arm/__stou64.s index 204be052167..eac8c64c9fc 100644 --- a/sdk/lib/crt/math/arm/__stou64.s +++ b/sdk/lib/crt/math/arm/__stou64.s @@ -1,23 +1,36 @@ /* - * COPYRIGHT: BSD - See COPYING.ARM in the top level directory - * PROJECT: ReactOS CRT library - * PURPOSE: Implementation of __stou64 - * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * PROJECT: ReactOS CRT library + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Implementation of __stou64 + * COPYRIGHT: Copyright 2015 Timo Kreuzer <timo.kreuzer(a)reactos.org> + * Copyright 2021 Roman Masanin <36927roma(a)gmail.com> */ /* INCLUDES ******************************************************************/ #include <kxarm.h> + IMPORT __stou64_worker + /* CODE **********************************************************************/ TEXTAREA + /* + IN: s0 = single (float) value + OUT: r1:r0 = uint64 value + */ LEAF_ENTRY __stou64 + /* Allocate stack space and store parameters there */ + push {lr} + PROLOG_END - __assertfail - bx lr + /* Call the C worker function */ + VMOV r0,s0 + bl __stou64_worker + /* Move result data into the appropriate registers and return */ + pop {pc} LEAF_END __stou64 END diff --git a/sdk/lib/crt/math/arm/__stou64_worker.c b/sdk/lib/crt/math/arm/__stou64_worker.c new file mode 100644 index 00000000000..b373da1ad84 --- /dev/null +++ b/sdk/lib/crt/math/arm/__stou64_worker.c @@ -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(a)gmail.com> + */ + +#define __fto64_worker __stou64_worker + +#include "__fto64_worker.h" + +/* __stou64 is implemented in __stou64.s */ diff --git a/sdk/lib/crt/math/math.cmake b/sdk/lib/crt/math/math.cmake index e647201f53b..16cfdd10fd2 100644 --- a/sdk/lib/crt/math/math.cmake +++ b/sdk/lib/crt/math/math.cmake @@ -79,6 +79,10 @@ elseif(ARCH STREQUAL "arm") math/arm/__rt_sdiv64_worker.c math/arm/__rt_udiv.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 math/fabsf.c diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index 38ad8b04712..8034116c8c1 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -72,6 +72,10 @@ elseif(ARCH STREQUAL "arm") math/arm/__rt_sdiv64_worker.c math/arm/__rt_udiv.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 except/arm/chkstk_asm.s
3 years, 4 months
1
0
0
0
[reactos] 01/01: [CRT/ARM] Fix modulus on division (#3856)
by Roman Masanin
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fd8baca9f2ef41a2e6859…
commit fd8baca9f2ef41a2e685936a94485a6e28552181 Author: Roman Masanin <36927roma(a)gmail.com> AuthorDate: Wed Jul 28 14:34:59 2021 +0300 Commit: Stanislav Motylkov <x86corez(a)gmail.com> CommitDate: Thu Jul 29 13:44:16 2021 +0300 [CRT/ARM] Fix modulus on division (#3856) This fixes all tests added in 759bdedc. Addendum to f2bc1f0e. CORE-17607 CORE-17614 CORE-17604 --- sdk/lib/crt/math/arm/__rt_div_worker.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/lib/crt/math/arm/__rt_div_worker.h b/sdk/lib/crt/math/arm/__rt_div_worker.h index 2b658415a3f..c920ec528e3 100644 --- a/sdk/lib/crt/math/arm/__rt_div_worker.h +++ b/sdk/lib/crt/math/arm/__rt_div_worker.h @@ -87,7 +87,11 @@ __rt_div_worker( if (divisor > dividend) { result->data.quotient = 0; - result->data.modulus = divisor; +#ifdef _SIGNED_DIV_ + if (dividend_sign) + dividend = -(INT3264)dividend; +#endif // _SIGNED_DIV_ + result->data.modulus = dividend; return; }
3 years, 4 months
1
0
0
0
[reactos] 01/01: [CRT_APITEST] Add tests for __rt_sdiv/udiv/sdiv64/udiv64 on ARM
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=759bdedc1efc3b45b0cbc…
commit 759bdedc1efc3b45b0cbc981ff95c00c33183ec0 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Wed Jul 28 22:38:21 2021 +0300 Commit: Stanislav Motylkov <x86corez(a)gmail.com> CommitDate: Thu Jul 29 13:37:07 2021 +0300 [CRT_APITEST] Add tests for __rt_sdiv/udiv/sdiv64/udiv64 on ARM Addendum to f2bc1f0e and f1e2c6cb. CORE-17607 CORE-17614 CORE-17604 --- modules/rostests/apitests/crt/__rt_div.c | 175 +++++++++++++++++++++ .../rostests/apitests/crt/msvcrt_crt_apitest.cmake | 4 + modules/rostests/apitests/crt/testlist.c | 3 + 3 files changed, 182 insertions(+) diff --git a/modules/rostests/apitests/crt/__rt_div.c b/modules/rostests/apitests/crt/__rt_div.c new file mode 100644 index 00000000000..72c7460ce60 --- /dev/null +++ b/modules/rostests/apitests/crt/__rt_div.c @@ -0,0 +1,175 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Tests for statically linked __rt_sdiv/udiv/sdiv64/udiv64 on ARM + * COPYRIGHT: Copyright 2021 Stanislav Motylkov <x86corez(a)gmail.com> + */ + +#include <apitest.h> + +typedef struct _SDIV_TEST_DATA +{ + LONG dividend; + LONG divisor; + LONG expected_div; + LONG expected_mod; +} SDIV_TEST_DATA; + +typedef struct _UDIV_TEST_DATA +{ + ULONG dividend; + ULONG divisor; + ULONG expected_div; + ULONG expected_mod; +} UDIV_TEST_DATA; + +typedef struct _SDIV64_TEST_DATA +{ + LONGLONG dividend; + LONGLONG divisor; + LONGLONG expected_div; + LONGLONG expected_mod; +} SDIV64_TEST_DATA; + +typedef struct _UDIV64_TEST_DATA +{ + ULONGLONG dividend; + ULONGLONG divisor; + ULONGLONG expected_div; + ULONGLONG expected_mod; +} UDIV64_TEST_DATA; + +START_TEST(__rt_div) +{ + SDIV_TEST_DATA sdiv[] = + { + /* Dividend is larger than divisor */ + { 3425, 400, 8, 225 }, + { -3425, 400, -8, -225 }, + { 3425, -400, -8, 225 }, + { -3425, -400, 8, -225 }, + /* Divisor is larger than dividend */ + { 12, 42, 0, 12 }, + { -12, 42, 0, -12 }, + { 12, -42, 0, 12 }, + { -12, -42, 0, -12 }, + /* Division without remainder */ + { 16777216, 65536, 256, 0 }, + { -16777216, 65536, -256, 0 }, + { 16777216, -65536, -256, 0 }, + { -16777216, -65536, 256, 0 }, + }; + UDIV_TEST_DATA udiv[] = + { + /* Dividend is larger than divisor */ + { 3425, 400, 8, 225 }, + /* Divisor is larger than dividend */ + { 12, 42, 0, 12 }, + /* Division without remainder */ + { 16777216, 65536, 256, 0 }, + }; + SDIV64_TEST_DATA sdiv64[] = + { + /* Dividend is larger than divisor */ + { 34918215, 7, 4988316, 3 }, + { -34918215, 7, -4988316, -3 }, + { 34918215, -7, -4988316, 3 }, + { -34918215, -7, 4988316, -3 }, + /* Divisor is larger than dividend */ + { 12, 42, 0, 12 }, + { -12, 42, 0, -12 }, + { 12, -42, 0, 12 }, + { -12, -42, 0, -12 }, + /* Division without remainder */ + { 16777216, 65536, 256, 0 }, + { -16777216, 65536, -256, 0 }, + { 16777216, -65536, -256, 0 }, + { -16777216, -65536, 256, 0 }, + + /* Big 64-bit numbers */ + + /* Dividend is larger than divisor */ + { 0x2AFFFFFFFLL * 100, 400, 2885681151LL, 300 }, + { -0x2AFFFFFFFLL * 100, 400, -2885681151LL, -300 }, + { 0x2AFFFFFFFLL * 100, -400, -2885681151LL, 300 }, + { -0x2AFFFFFFFLL * 100, -400, 2885681151LL, -300 }, + /* Divisor is larger than dividend */ + { 0x2AFFFFFFFLL * 50, 0x2AFFFFFFFLL * 100, 0, 0x2AFFFFFFFLL * 50 }, + { -0x2AFFFFFFFLL * 50, 0x2AFFFFFFFLL * 100, 0, -0x2AFFFFFFFLL * 50 }, + { 0x2AFFFFFFFLL * 50, -0x2AFFFFFFFLL * 100, 0, 0x2AFFFFFFFLL * 50 }, + { -0x2AFFFFFFFLL * 50, -0x2AFFFFFFFLL * 100, 0, -0x2AFFFFFFFLL * 50 }, + /* Division without remainder */ + { 0x2AFFFFFFFLL * 100, 100, 0x2AFFFFFFFLL, 0 }, + { -0x2AFFFFFFFLL * 100, 100, -0x2AFFFFFFFLL, 0 }, + { 0x2AFFFFFFFLL * 100, -100, -0x2AFFFFFFFLL, 0 }, + { -0x2AFFFFFFFLL * 100, -100, 0x2AFFFFFFFLL, 0 }, + }; + UDIV64_TEST_DATA udiv64[] = + { + /* Dividend is larger than divisor */ + { 34918215, 7, 4988316, 3 }, + /* Divisor is larger than dividend */ + { 12, 42, 0, 12 }, + /* Division without remainder */ + { 16777216, 65536, 256, 0 }, + + /* Big 64-bit numbers */ + + /* Dividend is larger than divisor */ + { 0x2AFFFFFFFULL * 100, 400, 2885681151ULL, 300 }, + /* Divisor is larger than dividend */ + { 0x2AFFFFFFFULL * 50, 0x2AFFFFFFFULL * 100, 0, 0x2AFFFFFFFULL * 50 }, + /* Division without remainder */ + { 0x2AFFFFFFFULL * 100, 100, 0x2AFFFFFFFULL, 0 }, + }; + INT i; + + for (i = 0; i < _countof(sdiv); i++) + { + LONG test_div, test_mod; + + test_div = sdiv[i].dividend / sdiv[i].divisor; + test_mod = sdiv[i].dividend % sdiv[i].divisor; + ok(test_div == sdiv[i].expected_div, "(sdiv) %d: Expected %ld, got %ld / %ld = %ld\n", + i, sdiv[i].expected_div, sdiv[i].dividend, sdiv[i].divisor, test_div); + ok(test_mod == sdiv[i].expected_mod, "(sdiv) %d: Expected %ld, got %ld %% %ld = %ld\n", + i, sdiv[i].expected_mod, sdiv[i].dividend, sdiv[i].divisor, test_mod); + } + + for (i = 0; i < _countof(udiv); i++) + { + ULONG test_div, test_mod; + + test_div = udiv[i].dividend / udiv[i].divisor; + test_mod = udiv[i].dividend % udiv[i].divisor; + ok(test_div == udiv[i].expected_div, "(udiv) %d: Expected %lu, got %lu / %lu = %lu\n", + i, udiv[i].expected_div, udiv[i].dividend, udiv[i].divisor, test_div); + ok(test_mod == udiv[i].expected_mod, "(udiv) %d: Expected %lu, got %lu %% %lu = %lu\n", + i, udiv[i].expected_mod, udiv[i].dividend, udiv[i].divisor, test_mod); + } + + for (i = 0; i < _countof(sdiv64); i++) + { + LONGLONG test_div, test_mod; + + test_div = sdiv64[i].dividend / sdiv64[i].divisor; + test_mod = sdiv64[i].dividend % sdiv64[i].divisor; + ok(test_div == sdiv64[i].expected_div, "(sdiv64) %d: Expected %lld, got %lld / %lld = %lld\n", + i, sdiv64[i].expected_div, sdiv64[i].dividend, sdiv64[i].divisor, test_div); + ok(test_mod == sdiv64[i].expected_mod, "(sdiv64) %d: Expected %lld, got %lld %% %lld = %lld\n", + i, sdiv64[i].expected_mod, sdiv64[i].dividend, sdiv64[i].divisor, test_mod); + } + + for (i = 0; i < _countof(udiv64); i++) + { + ULONGLONG test_div, test_mod; + + test_div = udiv64[i].dividend / udiv64[i].divisor; + test_mod = udiv64[i].dividend % udiv64[i].divisor; + ok(test_div == udiv64[i].expected_div, "(udiv64) %d: Expected %llu, got %llu / %llu = %llu\n", + i, udiv64[i].expected_div, udiv64[i].dividend, udiv64[i].divisor, test_div); + ok(test_mod == udiv64[i].expected_mod, "(udiv64) %d: Expected %llu, got %llu %% %llu = %llu\n", + i, udiv64[i].expected_mod, udiv64[i].dividend, udiv64[i].divisor, test_mod); + } +} + diff --git a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake index 9e76ba0202c..2375f59472a 100644 --- a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake +++ b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake @@ -1371,6 +1371,10 @@ elseif(ARCH STREQUAL "amd64") # sinf.c # sqrtf.c ) +elseif(ARCH STREQUAL "arm") + list(APPEND SOURCE_MSVCRT + __rt_div.c + ) endif() # Startup code doesn't go together well with the static CRT... too much __imp_ diff --git a/modules/rostests/apitests/crt/testlist.c b/modules/rostests/apitests/crt/testlist.c index 9516d540be0..ca76ebbf593 100644 --- a/modules/rostests/apitests/crt/testlist.c +++ b/modules/rostests/apitests/crt/testlist.c @@ -4,6 +4,7 @@ #include <apitest.h> #if defined(TEST_MSVCRT) +extern void func___rt_div(void); extern void func__vscprintf(void); extern void func__vscwprintf(void); extern void func_atexit(void); @@ -59,6 +60,8 @@ const struct test winetest_testlist[] = { "atexit", func_atexit }, #if defined(_M_IX86) { "__getmainargs", func___getmainargs }, +#elif defined(_M_ARM) + { "__rt_div", func___rt_div }, #endif { "_vscprintf", func__vscprintf }, { "_vscwprintf", func__vscwprintf },
3 years, 4 months
1
0
0
0
[reactos] 01/01: [IMM32] s/idThread/dwThreadId/
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e996662afb8d9849c22b4…
commit e996662afb8d9849c22b42351b0201979c18554d Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Jul 29 08:21:33 2021 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Thu Jul 29 08:21:33 2021 +0900 [IMM32] s/idThread/dwThreadId/ - Rename idThread variable as dwThreadId. - Rename idImeThread variable as dwImeThreadId. CORE-11700 --- dll/win32/imm32/imm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 13c79d1a226..2f316db2a08 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -964,9 +964,9 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC) /*********************************************************************** * ImmDisableIME (IMM32.@) */ -BOOL WINAPI ImmDisableIME(DWORD idThread) +BOOL WINAPI ImmDisableIME(DWORD dwThreadId) { - return NtUserDisableThreadIme(idThread); + return NtUserDisableThreadIme(dwThreadId); } /*********************************************************************** @@ -3142,16 +3142,16 @@ VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi) */ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) { - DWORD idImeThread, idThread, dwConversion; + DWORD dwImeThreadId, dwThreadId, dwConversion; LPINPUTCONTEXT pIC; HWND hWnd; BOOL bHasChange = FALSE; TRACE("ImmSetOpenStatus(%p, %d)\n", hIMC, fOpen); - idImeThread = Imm32QueryInputContext(hIMC, 1); - idThread = GetCurrentThreadId(); - if (idImeThread != idThread) + dwImeThreadId = Imm32QueryInputContext(hIMC, 1); + dwThreadId = GetCurrentThreadId(); + if (dwImeThreadId != dwThreadId) return FALSE; pIC = ImmLockIMC(hIMC); @@ -3726,7 +3726,7 @@ BOOL WINAPI ImmProcessKey(HWND hwnd, HKL hKL, UINT vKey, LPARAM lKeyData, DWORD /*********************************************************************** * ImmDisableTextFrameService(IMM32.@) */ -BOOL WINAPI ImmDisableTextFrameService(DWORD idThread) +BOOL WINAPI ImmDisableTextFrameService(DWORD dwThreadId) { FIXME("Stub\n"); return FALSE; @@ -3736,7 +3736,7 @@ BOOL WINAPI ImmDisableTextFrameService(DWORD idThread) * ImmEnumInputContext(IMM32.@) */ -BOOL WINAPI ImmEnumInputContext(DWORD idThread, IMCENUMPROC lpfn, LPARAM lParam) +BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam) { FIXME("Stub\n"); return FALSE;
3 years, 4 months
1
0
0
0
[reactos] 01/01: [IMM32] Rewrite ImmSetCompositionWindow (#3855)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f972a9fbd54c662b0d338…
commit f972a9fbd54c662b0d3387517f247684512e13c3 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Jul 28 23:26:02 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Jul 28 23:26:02 2021 +0900 [IMM32] Rewrite ImmSetCompositionWindow (#3855) Implementing Japanese input... CORE-11700 --- dll/win32/imm32/imm.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 1523c74dbbf..13c79d1a226 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -2997,38 +2997,28 @@ BOOL WINAPI ImmSetCompositionStringW( BOOL WINAPI ImmSetCompositionWindow( HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { - BOOL reshow = FALSE; - InputContextData *data = get_imc_data(hIMC); - - TRACE("(%p, %p)\n", hIMC, lpCompForm); - if (lpCompForm) - TRACE("\t%x, %s, %s\n", lpCompForm->dwStyle, - wine_dbgstr_point(&lpCompForm->ptCurrentPos), - wine_dbgstr_rect(&lpCompForm->rcArea)); + DWORD dwImeThreadId, dwThreadId; + LPINPUTCONTEXT pIC; + HWND hWnd; - if (!data) - { - SetLastError(ERROR_INVALID_HANDLE); + dwImeThreadId = NtUserQueryInputContext(hIMC, 1); + dwThreadId = GetCurrentThreadId(); + if (dwImeThreadId != dwThreadId) return FALSE; - } - if (IMM_IsCrossThreadAccess(NULL, hIMC)) + pIC = ImmLockIMC(hIMC); + if (pIC == NULL) return FALSE; - data->IMC.cfCompForm = *lpCompForm; - - if (IsWindowVisible(data->immKbd->UIWnd)) - { - reshow = TRUE; - ShowWindow(data->immKbd->UIWnd,SW_HIDE); - } + pIC->cfCompForm = *lpCompForm; + pIC->fdwInit |= INIT_COMPFORM; - /* FIXME: this is a partial stub */ + hWnd = pIC->hWnd; - if (reshow) - ShowWindow(data->immKbd->UIWnd,SW_SHOWNOACTIVATE); + ImmUnlockIMC(hIMC); - ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONWINDOW, 0); + Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, 0, + IMC_SETCOMPOSITIONWINDOW, IMN_SETCOMPOSITIONWINDOW, 0); return TRUE; }
3 years, 5 months
1
0
0
0
[reactos] 01/01: [IMM32] Implement ImmLoadLayout (#3854)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e1dea0c8c919555394e8…
commit 8e1dea0c8c919555394e89e354440814a281aaae Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Jul 28 23:25:10 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Jul 28 23:25:10 2021 +0900 [IMM32] Implement ImmLoadLayout (#3854) Implementing Japanese input... CORE-11700 --- dll/win32/imm32/imm.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ dll/win32/imm32/imm32.spec | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index df4db4cfca1..1523c74dbbf 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -48,8 +48,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm); #define IMM_INIT_MAGIC 0x19650412 #define IMM_INVALID_CANDFORM ULONG_MAX +#define REGKEY_KEYBOARD_LAYOUTS \ + L"System\\CurrentControlSet\\Control\\Keyboard Layouts" +#define REGKEY_IMM \ + L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM" + RTL_CRITICAL_SECTION g_csImeDpi; PIMEDPI g_pImeDpiList = NULL; +PSERVERINFO g_psi = NULL; BOOL WINAPI User32InitializeImmEntryTable(DWORD); @@ -105,6 +111,58 @@ Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD return TRUE; } +HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx) +{ + DWORD cbData; + UNICODE_STRING UnicodeString; + HKEY hLayoutKey = NULL, hLayoutsKey = NULL; + LONG error; + NTSTATUS Status; + WCHAR szLayout[MAX_PATH]; + + TRACE("ImmLoadLayout(%p, %p)\n", hKL, pImeInfoEx); + + if (IS_IME_HKL(hKL) || + !g_psi || (g_psi->dwSRVIFlags & SRVINFO_METRICS) == 0 || + ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->W32ClientInfo[0] & 2) + { + UnicodeString.Buffer = szLayout; + UnicodeString.MaximumLength = sizeof(szLayout); + Status = RtlIntegerToUnicodeString((DWORD_PTR)hKL, 16, &UnicodeString); + if (!NT_SUCCESS(Status)) + return NULL; + + error = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hLayoutsKey); + if (error) + return NULL; + + error = RegOpenKeyW(hLayoutsKey, szLayout, &hLayoutKey); + } + else + { + error = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_IMM, &hLayoutKey); + } + + if (error) + { + ERR("RegOpenKeyW error: 0x%08lX\n", error); + hKL = NULL; + } + else + { + cbData = sizeof(pImeInfoEx->wszImeFile); + error = RegQueryValueExW(hLayoutKey, L"Ime File", 0, 0, + (LPBYTE)pImeInfoEx->wszImeFile, &cbData); + if (error) + hKL = NULL; + } + + RegCloseKey(hLayoutKey); + if (hLayoutsKey) + RegCloseKey(hLayoutsKey); + return hKL; +} + typedef struct _tagImmHkl{ struct list entry; HKL hkl; diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec index 365d6726122..d7a269dd5be 100644 --- a/dll/win32/imm32/imm32.spec +++ b/dll/win32/imm32/imm32.spec @@ -69,7 +69,7 @@ @ stdcall ImmIsUIMessageA(long long long long) @ stdcall ImmIsUIMessageW(long long long long) @ stdcall -stub ImmLoadIME(long) -@ stdcall -stub ImmLoadLayout(long ptr) +@ stdcall ImmLoadLayout(ptr ptr) @ stdcall ImmLockClientImc(ptr) @ stdcall ImmLockIMC(ptr) @ stdcall ImmLockIMCC(ptr)
3 years, 5 months
1
0
0
0
[reactos] 01/01: [IMM32] Rewrite ImmNotifyIME (#3853)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fb2aef9e4ecb4f3ab2033…
commit fb2aef9e4ecb4f3ab2033aef85ded75c7ee239ca Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Jul 28 23:24:09 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Jul 28 23:24:09 2021 +0900 [IMM32] Rewrite ImmNotifyIME (#3853) Implementing Japanese input... CORE-11700 --- dll/win32/imm32/imm.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index e47224e0a6a..df4db4cfca1 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -2609,23 +2609,29 @@ BOOL WINAPI ImmIsUIMessageW( BOOL WINAPI ImmNotifyIME( HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue) { - InputContextData *data = get_imc_data(hIMC); + DWORD dwImeThreadId, dwThreadId; + HKL hKL; + PIMEDPI pImeDpi; + BOOL ret; - TRACE("(%p, %d, %d, %d)\n", - hIMC, dwAction, dwIndex, dwValue); + TRACE("ImmNotifyIME(%p, %lu, %lu, %lu)\n", hIMC, dwAction, dwIndex, dwValue); - if (hIMC == NULL) + if (hIMC) { - SetLastError(ERROR_SUCCESS); - return FALSE; + dwImeThreadId = Imm32QueryWindow(hIMC, QUERY_WINDOW_UNIQUE_THREAD_ID); + dwThreadId = GetCurrentThreadId(); + if (dwImeThreadId != dwThreadId) + return FALSE; } - if (!data || ! data->immKbd->pNotifyIME) - { + hKL = GetKeyboardLayout(0); + pImeDpi = ImmLockImeDpi(hKL); + if (pImeDpi == NULL) return FALSE; - } - return data->immKbd->pNotifyIME(hIMC,dwAction,dwIndex,dwValue); + ret = pImeDpi->NotifyIME(hIMC, dwAction, dwIndex, dwValue); + ImmUnlockImeDpi(pImeDpi); + return ret; } /***********************************************************************
3 years, 5 months
1
0
0
0
[reactos] 01/01: [IMM32] Rewrite ImmSetStatusWindowPos (#3852)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a71de262d321d77782d0f…
commit a71de262d321d77782d0fcd0b734543c6e9a25ec Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Jul 28 23:23:09 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Jul 28 23:23:09 2021 +0900 [IMM32] Rewrite ImmSetStatusWindowPos (#3852) Implementing Japanese input... CORE-11700 --- dll/win32/imm32/imm.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 66c740a925f..e47224e0a6a 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -3129,25 +3129,29 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) */ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - InputContextData *data = get_imc_data(hIMC); + LPINPUTCONTEXT pIC; + HWND hWnd; + DWORD dwImeThreadId, dwThreadId; - TRACE("(%p, %p)\n", hIMC, lpptPos); + TRACE("ImmSetStatusWindowPos(%p, {%ld, %ld})\n", hIMC, lpptPos->x, lpptPos->y); - if (!data || !lpptPos) - { - SetLastError(ERROR_INVALID_HANDLE); + dwImeThreadId = Imm32QueryInputContext(hIMC, 1); + dwThreadId = GetCurrentThreadId(); + if (dwImeThreadId != dwThreadId) return FALSE; - } - if (IMM_IsCrossThreadAccess(NULL, hIMC)) + pIC = ImmLockIMC(hIMC); + if (!pIC) return FALSE; - TRACE("\t%s\n", wine_dbgstr_point(lpptPos)); + hWnd = pIC->hWnd; + pIC->ptStatusWndPos = *lpptPos; + pIC->fdwInit |= INIT_STATUSWNDPOS; - data->IMC.ptStatusWndPos = *lpptPos; - ImmNotifyIME( hIMC, NI_CONTEXTUPDATED, 0, IMC_SETSTATUSWINDOWPOS); - ImmInternalSendIMENotify(data, IMN_SETSTATUSWINDOWPOS, 0); + ImmUnlockIMC(hIMC); + Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, 0, + IMC_SETSTATUSWINDOWPOS, IMN_SETSTATUSWINDOWPOS, 0); return TRUE; }
3 years, 5 months
1
0
0
0
[reactos] 02/02: [CRT] Fix _matherror and _setusermatherror
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=da2a5673e79d222159d1b…
commit da2a5673e79d222159d1b2f17ba77f6ca187ec9a Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Jul 24 18:13:06 2021 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Tue Jul 27 22:08:58 2021 +0200 [CRT] Fix _matherror and _setusermatherror We previously used 2 different versions: one from wine and one from mingw-w64. The former was used in msvcrt, the latter was statically compiled into the executable. When using MS libs, there is only one _matherr, which is statically linked into the executable and does nothing (it's not really a function for users to be called). _setusermatherror should only exist in msvcrt and not statically, which wouldn't work at all. --- sdk/lib/crt/except/except.cmake | 1 - sdk/lib/crt/except/matherr.c | 49 ------------------------- sdk/lib/crt/math/math.cmake | 1 + sdk/lib/crt/math/usermatherr.c | 36 +++++++++++++++++++ sdk/lib/crt/msvcrtex.cmake | 2 +- sdk/lib/crt/startup/_matherr.c | 18 ++++++++++ sdk/lib/crt/startup/merr.c | 76 --------------------------------------- sdk/lib/crt/startup/startup.cmake | 2 +- 8 files changed, 57 insertions(+), 128 deletions(-) diff --git a/sdk/lib/crt/except/except.cmake b/sdk/lib/crt/except/except.cmake index 7bc56b8078e..ad4345cc066 100644 --- a/sdk/lib/crt/except/except.cmake +++ b/sdk/lib/crt/except/except.cmake @@ -55,7 +55,6 @@ endif() list(APPEND CRT_EXCEPT_SOURCE ${LIBCNTPR_EXCEPT_SOURCE} - except/matherr.c except/stack.c ) diff --git a/sdk/lib/crt/except/matherr.c b/sdk/lib/crt/except/matherr.c deleted file mode 100644 index d7e6c5bf35b..00000000000 --- a/sdk/lib/crt/except/matherr.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <precomp.h> - -#define __USE_ISOC9X 1 -#define __USE_ISOC99 1 -#include <math.h> - -#ifdef HAVE_IEEEFP_H -#include <ieeefp.h> -#endif - -#ifndef HAVE_FINITE -#ifndef finite /* Could be a macro */ -#ifdef isfinite -#define finite(x) isfinite(x) -#else -#define finite(x) (!isnan(x)) /* At least catch some cases */ -#endif -#endif -#endif - -#ifndef signbit -#define signbit(x) 0 -#endif - -typedef int (*MSVCRT_matherr_func)(struct _exception *); - -static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL; - -int CDECL _matherr(struct _exception *e) -{ - if (e) - TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2, - e->retval); - else - TRACE("(null)\n"); - if (MSVCRT_default_matherr_func) - return MSVCRT_default_matherr_func(e); - ERR(":Unhandled math error!\n"); - return 0; -} - -/********************************************************************* - * __setusermatherr (MSVCRT.@) - */ -void CDECL __setusermatherr(MSVCRT_matherr_func func) -{ - MSVCRT_default_matherr_func = func; - TRACE(":new matherr handler %p\n", func); -} diff --git a/sdk/lib/crt/math/math.cmake b/sdk/lib/crt/math/math.cmake index a11c62ccb3f..e647201f53b 100644 --- a/sdk/lib/crt/math/math.cmake +++ b/sdk/lib/crt/math/math.cmake @@ -3,6 +3,7 @@ list(APPEND LIBCNTPR_MATH_SOURCE math/abs.c math/div.c math/labs.c + math/usermatherr.c ) if(ARCH STREQUAL "i386") diff --git a/sdk/lib/crt/math/usermatherr.c b/sdk/lib/crt/math/usermatherr.c new file mode 100644 index 00000000000..283a42cd5d0 --- /dev/null +++ b/sdk/lib/crt/math/usermatherr.c @@ -0,0 +1,36 @@ +/* + * PROJECT: ReactOS CRT library + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Implementation of __setusermatherr and _invoke_user_matherr + * COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer(a)reactos.org> + */ + +// DO NOT SYNC WITH WINE OR MINGW32 + +#include <math.h> + +/* MS headers have this in corecrt_startup.h */ +typedef int (*_UserMathErrorFunctionPointer)(struct _exception *); + +static _UserMathErrorFunctionPointer user_matherr = NULL;; + +void +__cdecl +__setusermatherr(_UserMathErrorFunctionPointer func) +{ + user_matherr = func; +} + +int +__cdecl +_invoke_user_matherr(struct _exception *e) +{ + if (user_matherr != NULL) + { + return user_matherr(e); + } + else + { + return 0; + } +} diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index d438a841d31..38ad8b04712 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -2,6 +2,7 @@ include_directories(include/internal/mingw-w64) list(APPEND MSVCRTEX_SOURCE + startup/_matherr.c startup/crtexe.c startup/wcrtexe.c startup/crt_handler.c @@ -12,7 +13,6 @@ list(APPEND MSVCRTEX_SOURCE startup/mingw_helpers.c startup/natstart.c startup/charmax.c - startup/merr.c startup/atonexit.c startup/dllmain.c startup/txtmode.c diff --git a/sdk/lib/crt/startup/_matherr.c b/sdk/lib/crt/startup/_matherr.c new file mode 100644 index 00000000000..0cde46ec56d --- /dev/null +++ b/sdk/lib/crt/startup/_matherr.c @@ -0,0 +1,18 @@ +/* + * PROJECT: ReactOS CRT library + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Implementation of _matherr dummy + * COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer(a)reactos.org> + */ + +// DO NOT SYNC WITH WINE OR MINGW32 + +#include <math.h> + +/* Dummy function, like in MS CRT */ +int +__cdecl +_matherr(struct _exception *pexcept) +{ + return 0; +} diff --git a/sdk/lib/crt/startup/merr.c b/sdk/lib/crt/startup/merr.c deleted file mode 100644 index 464c211fed9..00000000000 --- a/sdk/lib/crt/startup/merr.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ - -#include <internal.h> -#include <math.h> -#include <stdio.h> - -typedef int (__cdecl *fUserMathErr)(struct _exception *); -static fUserMathErr stUserMathErr; - -void __mingw_raise_matherr (int typ, const char *name, double a1, double a2, - double rslt) -{ - struct _exception ex; - if (!stUserMathErr) - return; - ex.type = typ; - ex.name = (char*)name; - ex.arg1 = a1; - ex.arg2 = a2; - ex.retval = rslt; - (*stUserMathErr)(&ex); -} - -#undef __setusermatherr - -void __mingw_setusermatherr (int (__cdecl *f)(struct _exception *)) -{ - stUserMathErr = f; - __setusermatherr (f); -} - -int __CRTDECL -_matherr (struct _exception *pexcept) -{ - const char * type; - - switch(pexcept->type) - { - case _DOMAIN: - type = "Argument domain error (DOMAIN)"; - break; - - case _SING: - type = "Argument singularity (SIGN)"; - break; - - case _OVERFLOW: - type = "Overflow range error (OVERFLOW)"; - break; - - case _PLOSS: - type = "Partial loss of significance (PLOSS)"; - break; - - case _TLOSS: - type = "Total loss of significance (TLOSS)"; - break; - - case _UNDERFLOW: - type = "The result is too small to be represented (UNDERFLOW)"; - break; - - default: - type = "Unknown error"; - break; - } - - __mingw_fprintf (stderr, "_matherr(): %s in %s(%g, %g) (retval=%g)\n", - type, pexcept->name, pexcept->arg1, pexcept->arg2, pexcept->retval); - return 0; -} - diff --git a/sdk/lib/crt/startup/startup.cmake b/sdk/lib/crt/startup/startup.cmake index b2d3070c12d..1574d29e97b 100644 --- a/sdk/lib/crt/startup/startup.cmake +++ b/sdk/lib/crt/startup/startup.cmake @@ -1,5 +1,6 @@ list(APPEND CRT_STARTUP_SOURCE + startup/_matherr.c startup/crtexe.c startup/wcrtexe.c startup/crt_handler.c @@ -10,7 +11,6 @@ list(APPEND CRT_STARTUP_SOURCE startup/mingw_helpers.c startup/natstart.c startup/charmax.c - #startup/merr.c startup/atonexit.c #startup/txtmode.c startup/pesect.c
3 years, 5 months
1
0
0
0
← Newer
1
2
3
4
5
...
15
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Results per page:
10
25
50
100
200