[systemd-commits] configure.ac m4/sd_check_max_int_size.m4 src/core

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Jan 18 14:10:32 PST 2013


 configure.ac                |    1 +
 m4/sd_check_max_int_size.m4 |   27 +++++++++++++++++++++++++++
 src/core/manager.c          |    4 ++--
 3 files changed, 30 insertions(+), 2 deletions(-)

New commits:
commit d6a195a3c373f67632cb98d6e6e14f974ef062f9
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Jan 18 16:49:48 2013 -0500

    build-sys: add autoconf macro to pick macro for x32 compatibility

diff --git a/configure.ac b/configure.ac
index 3566dac..540bfa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,7 @@ AC_DEFINE_UNQUOTED([CANONICAL_HOST], "$host", [Canonical host string.])
 AS_IF([test "x$host_cpu" = "xmips" || test "x$host_cpu" = "xmipsel" ||
        test "x$host_cpu" = "xmips64" || test "x$host_cpu" = "xmips64el"],
       [AC_DEFINE(ARCH_MIPS, [], [Whether on mips arch])])
+SD_CHECK_MAX_INT_SIZE([time_t], [#include <time.h>])
 
 LT_PREREQ(2.2)
 LT_INIT([disable-static])
diff --git a/m4/sd_check_max_int_size.m4 b/m4/sd_check_max_int_size.m4
new file mode 100644
index 0000000..a4230b5
--- /dev/null
+++ b/m4/sd_check_max_int_size.m4
@@ -0,0 +1,27 @@
+dnl Find what INT_MAX define to use for a type
+
+#serial 1
+
+ifdef([AC_TR_SH],[], [
+define([AC_TR_SH],
+       [patsubst(translit([[$1]], [*+], [pp]), [[^a-zA-Z0-9_]], [_])])
+define([AC_TR_CPP],
+       [patsubst(translit([[$1]],
+                          [*abcdefghijklmnopqrstuvwxyz],
+                          [PABCDEFGHIJKLMNOPQRSTUVWXYZ]),
+                 [[^A-Z0-9_]], [_])])
+])
+
+AC_DEFUN([SD_CHECK_MAX_INT_SIZE],
+        [AC_CHECK_SIZEOF([long],,)
+         AC_CHECK_SIZEOF([long long],,)
+         AC_CHECK_SIZEOF([$1],,[$2])
+         AS_CASE([$ac_cv_sizeof_[]AC_TR_SH($1)],
+                 [$ac_cv_sizeof_long], [sd_type_max=LONG_MAX],
+                 [$ac_cv_sizeof_long_long], [sd_type_max=LONG_LONG_MAX],
+                 [AC_MSG_ERROR([Don't know how to map $1 to an integer])])
+         AC_DEFINE_UNQUOTED(AC_TR_CPP($1_MAX), [$sd_type_max],
+                   [what int to use to maximize $1])
+         AC_MSG_CHECKING([what int to to use to maximize $1])
+         AC_MSG_RESULT([$sd_type_max])
+])
diff --git a/src/core/manager.c b/src/core/manager.c
index df0fd63..d4afc93 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -157,8 +157,8 @@ static int manager_setup_time_change(Manager *m) {
 
         /* We only care for the cancellation event, hence we set the
          * timeout to the latest possible value. */
-        assert_cc(sizeof(time_t) == sizeof(long));
-        its.it_value.tv_sec = LONG_MAX;
+        assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));
+        its.it_value.tv_sec = TIME_T_MAX;
 
         if (timerfd_settime(m->time_change_watch.fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0) {
                 log_debug("Failed to set up TFD_TIMER_CANCEL_ON_SET, ignoring: %m");



More information about the systemd-commits mailing list