← Commit list

04c141760

Denys Vlasenko
Denys Vlasenko
2014-11-26
SUCCESS Duration: 142s

Subject

libbb: use ARG_MAX for bb_arg_max() only if it's 60k+

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

include/libbb.h+5 -2
@@ -731,11 +731,14 @@ extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST
/* Never returns NULL */
extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
-#if defined ARG_MAX
+#if defined(ARG_MAX) && (ARG_MAX >= 60*1024 || !defined(_SC_ARG_MAX))
+/* Use _constant_ maximum if: defined && (big enough || no variable one exists) */
# define bb_arg_max() ((unsigned)ARG_MAX)
-#elif defined _SC_ARG_MAX
+#elif defined(_SC_ARG_MAX)
+/* Else use variable one (a bit more expensive) */
unsigned bb_arg_max(void) FAST_FUNC;
#else
+/* If all else fails */
# define bb_arg_max() ((unsigned)(32 * 1024))
#endif
unsigned bb_clk_tck(void) FAST_FUNC;
libbb/sysconf.c+1 -1
@@ -8,7 +8,7 @@
*/
#include "libbb.h"
-#if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
+#if !defined(bb_arg_max)
unsigned FAST_FUNC bb_arg_max(void)
{
return sysconf(_SC_ARG_MAX);