xiaoxiang781216 commented on code in PR #20996:
URL: https://github.com/apache/nuttx/pull/20996#discussion_r4374093604
##########
sched/Kconfig:
##########
@@ -1647,7 +1647,6 @@ config ENABLE_PARTIAL_SIGNALS
config DISABLE_ALL_SIGNALS
bool "Disable all signal support"
select DISABLE_POSIX_TIMERS
- select DISABLE_MQUEUE_NOTIFICATION
Review Comment:
let change select to depend on
##########
libs/libc/stream/lib_ultoa_invert.c:
##########
@@ -57,8 +58,55 @@ FAR char *__ultoa_invert(unsigned long long val, FAR char
*str, int base)
{
int v;
+#if defined(CONFIG_DEFAULT_SMALL) && defined(__GNUC__)
Review Comment:
why not always enable optimization by remove `#if`
##########
libs/libc/stream/lib_ultoa_invert.c:
##########
@@ -57,8 +58,55 @@ FAR char *__ultoa_invert(unsigned long long val, FAR char
*str, int base)
{
int v;
+#if defined(CONFIG_DEFAULT_SMALL) && defined(__GNUC__)
+ /* GCC -Os lowers 64-bit division (even by constants) to
+ * __aeabi_uldivmod libcalls, which drag in ~0.9KB of libgcc.
+ */
+
+ if (base > 1 && (base & (base - 1)) == 0)
+ {
+ unsigned int b = (unsigned int)base;
+ unsigned int shift = 0;
+
+ while ((1u << shift) < b)
+ {
+ shift++;
+ }
+
+ v = (int)(val & (b - 1));
+ val >>= shift;
+ }
+ else if (base == 10)
+ {
+ unsigned long long q = val;
+
+ div64_const32(q, 10); /* q = val / 10 (inline umulls) */
Review Comment:
val and remove line 85
##########
libs/libc/stream/lib_ultoa_invert.c:
##########
@@ -38,6 +38,7 @@
****************************************************************************/
#include "lib_ultoa_invert.h"
+#include <nuttx/lib/math32.h>
Review Comment:
move before line 40 with one blank line
##########
include/nuttx/lib/math32.h:
##########
@@ -318,7 +318,7 @@ extern "C"
} \
while (0)
-#if defined(CONFIG_HAVE_EXPRESSION_STATEMENT)
+#if defined(__GNUC__)
Review Comment:
why need change? CONFIG_HAVE_EXPRESSION_STATEMENT is defined in
include/nuttx/compiler.h in automatically.
##########
libs/libc/stream/lib_ultoa_invert.c:
##########
@@ -57,8 +58,55 @@ FAR char *__ultoa_invert(unsigned long long val, FAR char
*str, int base)
{
int v;
+#if defined(CONFIG_DEFAULT_SMALL) && defined(__GNUC__)
+ /* GCC -Os lowers 64-bit division (even by constants) to
+ * __aeabi_uldivmod libcalls, which drag in ~0.9KB of libgcc.
+ */
+
+ if (base > 1 && (base & (base - 1)) == 0)
+ {
+ unsigned int b = (unsigned int)base;
Review Comment:
change to `x >> ffs(base)`
##########
libs/libc/stream/lib_ultoa_invert.c:
##########
@@ -57,8 +58,55 @@ FAR char *__ultoa_invert(unsigned long long val, FAR char
*str, int base)
{
int v;
+#if defined(CONFIG_DEFAULT_SMALL) && defined(__GNUC__)
+ /* GCC -Os lowers 64-bit division (even by constants) to
+ * __aeabi_uldivmod libcalls, which drag in ~0.9KB of libgcc.
+ */
+
+ if (base > 1 && (base & (base - 1)) == 0)
+ {
+ unsigned int b = (unsigned int)base;
+ unsigned int shift = 0;
+
+ while ((1u << shift) < b)
+ {
+ shift++;
+ }
+
+ v = (int)(val & (b - 1));
+ val >>= shift;
+ }
+ else if (base == 10)
+ {
+ unsigned long long q = val;
+
+ div64_const32(q, 10); /* q = val / 10 (inline umulls) */
+ v = (int)(val - q * 10); /* remainder */
+ val = q;
+ }
+ else
Review Comment:
add debug assert instead since caller pass only 8/10/16
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]