]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/_helpers.c
Find SC_ARG_MAX via C sysconf().
[bup.git] / lib / bup / _helpers.c
index b9b050bad10a2a40ad6de1289380628e69324853..ea49c0e7571045484a35c73a7e07344607f822eb 100644 (file)
@@ -1222,9 +1222,9 @@ PyMODINIT_FUNC init_helpers(void)
     if (m == NULL)
         return;
 
-#ifdef HAVE_UTIMENSAT
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wtautological-compare" // For INTEGER_TO_PY().
+#ifdef HAVE_UTIMENSAT
     {
         PyObject *value;
         value = INTEGER_TO_PY(AT_FDCWD);
@@ -1237,8 +1237,20 @@ PyMODINIT_FUNC init_helpers(void)
         PyObject_SetAttrString(m, "UTIME_NOW", value);
         Py_DECREF(value);
     }
-#pragma clang diagnostic pop  // ignored "-Wtautological-compare"
 #endif
+    {
+        PyObject *value;
+        const long arg_max = sysconf(_SC_ARG_MAX);
+        if (arg_max == -1)
+        {
+            fprintf(stderr, "Cannot find SC_ARG_MAX, please report a bug.\n");
+            exit(1);
+        }
+        value = INTEGER_TO_PY(arg_max);
+        PyObject_SetAttrString(m, "SC_ARG_MAX", value);
+        Py_DECREF(value);
+    }
+#pragma clang diagnostic pop  // ignored "-Wtautological-compare"
 
     e = getenv("BUP_FORCE_TTY");
     istty2 = isatty(2) || (atoi(e ? e : "0") & 2);