hartmannathan commented on code in PR #17360:
URL: https://github.com/apache/nuttx/pull/17360#discussion_r2550022751


##########
include/sys/param.h:
##########
@@ -53,6 +53,32 @@
 #  define nitems(_a)    (sizeof(_a) / sizeof(0[(_a)]))
 #endif /* nitems */
 
+/* Macros for counting and rounding. */
+
+#ifndef howmany
+#  define howmany(a, b)        (((a) + ((b) - 1)) / (b))
+#endif /* howmany */
+
+#ifndef rounddown
+#  define      rounddown(a, b) (((a) / (b)) * (b))
+#endif /* rounddown */
+
+#ifndef rounddown2
+#  define      rounddown2(a, b) ((a) & ~((b) - 1))
+#endif /* rounddown2 */

Review Comment:
   rounddown() and rounddown2() also appear unused, but I think it's OK to have 
them as counterparts of roundup() and roundup2().
   
   Same comment as roundup2(): Can we have a docstring to explain that 
rounddown2() is for rounding down of powers of 2 only? Thanks!



##########
include/sys/param.h:
##########
@@ -53,6 +53,32 @@
 #  define nitems(_a)    (sizeof(_a) / sizeof(0[(_a)]))
 #endif /* nitems */
 
+/* Macros for counting and rounding. */
+
+#ifndef howmany
+#  define howmany(a, b)        (((a) + ((b) - 1)) / (b))
+#endif /* howmany */
+
+#ifndef rounddown
+#  define      rounddown(a, b) (((a) / (b)) * (b))
+#endif /* rounddown */
+
+#ifndef rounddown2
+#  define      rounddown2(a, b) ((a) & ~((b) - 1))
+#endif /* rounddown2 */
+
+#ifndef roundup
+#  define      roundup(a, b)   ((((a) + ((b) - 1)) / (b)) * (b))
+#endif /* roundup */
+
+#ifndef roundup2
+#  define      roundup2(a, b)  (((a) + ((b) - 1)) & ~((b) - 1))
+#endif /* roundup2 */

Review Comment:
   Can we have a docstring to explain that roundup2() is for rounding up powers 
of 2 only? It took me a while to understand what this is for. Thanks!



##########
include/sys/param.h:
##########
@@ -53,6 +53,32 @@
 #  define nitems(_a)    (sizeof(_a) / sizeof(0[(_a)]))
 #endif /* nitems */
 
+/* Macros for counting and rounding. */
+
+#ifndef howmany
+#  define howmany(a, b)        (((a) + ((b) - 1)) / (b))
+#endif /* howmany */

Review Comment:
   howmany() macro does not appear to be used anywhere?



-- 
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]

Reply via email to