]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Config: check for %m availability
authorRachid Koucha <47061324+Rachid-Koucha@users.noreply.github.com>
Mon, 13 May 2019 11:13:18 +0000 (13:13 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 18 May 2019 09:53:52 +0000 (11:53 +0200)
GLIBC supports %m to avoid calling strerror(). Using it saves some code space.
==> This check will define HAVE_M_FORMAT to be use wherever possible (e.g. log.h)

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
configure.ac

index 6601b35d23bef26fd9c0337a47a1b81704c3eeb9..41befc08198396ad698acae738a2d9a4e5c65bdb 100644 (file)
@@ -628,6 +628,33 @@ AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat ge
 # - STRERROR_R_CHAR_P if it returns char *
 AC_FUNC_STRERROR_R
 
+# Check if "%m" is supported by printf and Co
+AC_MSG_CHECKING([%m format])
+AC_TRY_RUN([
+#include <stdio.h>
+int main(void)
+{
+  char msg[256];
+  int rc;
+
+  rc = snprintf(msg, sizeof(msg), "%m\n");
+  if ((rc > 1) && (msg[0] != '%'))
+  {
+    return 0;
+  }
+  else
+  {
+    return 1;
+  }
+}],
+[fmt_m=yes], [fmt_m=no])
+if test "x$fmt_m" = "xyes"; then
+       AC_DEFINE([HAVE_M_FORMAT], 1, [Have %m format])
+       AC_MSG_RESULT([yes])
+else
+       AC_MSG_RESULT([no])
+fi
+
 # Check for some functions
 AC_CHECK_LIB(pthread, main)
 AC_CHECK_FUNCS(statvfs)