tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] Fix compilation of librumpuser on Linux and Hurd



On linux and Hurd, the header sys/evcnt does not exists. So this patch
add conditional compilation to don’t include that header and the related
code if it’s unsupported.
---
 lib/librumpuser/configure            | 12 ++++++------
 lib/librumpuser/configure.ac         |  2 +-
 lib/librumpuser/rumpuser_config.h.in |  3 +++
 lib/librumpuser/rumpuser_dl.c        |  4 ++++
 lib/librumpuser/rumpuser_port.h      |  2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/lib/librumpuser/configure b/lib/librumpuser/configure
index 6b6e7f18f5dc..1ef6bafb4c96 100755
--- a/lib/librumpuser/configure
+++ b/lib/librumpuser/configure
@@ -3073,7 +3073,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3119,7 +3119,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3143,7 +3143,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3188,7 +3188,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3212,7 +3212,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3647,7 +3647,7 @@ done
 
 
 for ac_header in sys/param.h sys/sysctl.h sys/disk.h \
-	sys/disklabel.h sys/dkio.h sys/atomic.h paths.h
+	sys/disklabel.h sys/dkio.h sys/evcnt.h sys/atomic.h paths.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/lib/librumpuser/configure.ac b/lib/librumpuser/configure.ac
index 14efa054de0a..4920a5237424 100644
--- a/lib/librumpuser/configure.ac
+++ b/lib/librumpuser/configure.ac
@@ -20,7 +20,7 @@ AC_LANG([C])
 AC_SYS_LARGEFILE
 
 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h sys/disk.h \
-	sys/disklabel.h sys/dkio.h sys/atomic.h paths.h])
+	sys/disklabel.h sys/dkio.h sys/evcnt.h sys/atomic.h paths.h])
 
 AC_CANONICAL_TARGET
 
diff --git a/lib/librumpuser/rumpuser_config.h.in b/lib/librumpuser/rumpuser_config.h.in
index b008c0621b42..f4c9615d5418 100644
--- a/lib/librumpuser/rumpuser_config.h.in
+++ b/lib/librumpuser/rumpuser_config.h.in
@@ -102,6 +102,9 @@
 /* Define to 1 if you have the <sys/dkio.h> header file. */
 #undef HAVE_SYS_DKIO_H
 
+/* Define to 1 if you have the <sys/evcnt.h> header file. */
+#undef HAVE_SYS_EVCNT_H
+
 /* Define to 1 if you have the <sys/param.h> header file. */
 #undef HAVE_SYS_PARAM_H
 
diff --git a/lib/librumpuser/rumpuser_dl.c b/lib/librumpuser/rumpuser_dl.c
index c7c1f0509cd1..4e065d5043b7 100644
--- a/lib/librumpuser/rumpuser_dl.c
+++ b/lib/librumpuser/rumpuser_dl.c
@@ -45,7 +45,9 @@ __RCSID("$NetBSD: rumpuser_dl.c,v 1.34 2022/04/19 20:32:17 rillig Exp $");
 
 #include <sys/types.h>
 #include <sys/time.h>
+#if defined(HAVE_SYS_EVCNT)
 #include <sys/evcnt.h>
+#endif
 
 #include <assert.h>
 
@@ -375,6 +377,7 @@ process_object(void *handle,
 		assert(rc == rc_end);
 	}
 
+#if defined(HAVE_SYS_EVCNT)
 	/* handle link_set_sysctl_funcs */
 	sfp = dlsym(handle, "__start_link_set_sysctl_funcs");
 	sfp_end = dlsym(handle, "__stop_link_set_sysctl_funcs");
@@ -392,6 +395,7 @@ process_object(void *handle,
 			doevcntattach(*evp);
 		assert(evp == evp_end);
 	}
+#endif
 }
 
 /*
diff --git a/lib/librumpuser/rumpuser_port.h b/lib/librumpuser/rumpuser_port.h
index e56897e8a62d..1e652dfe031b 100644
--- a/lib/librumpuser/rumpuser_port.h
+++ b/lib/librumpuser/rumpuser_port.h
@@ -25,7 +25,6 @@
 #define HAVE_GETSUBOPT 1
 #define HAVE_INTTYPES_H 1
 #define HAVE_KQUEUE 1
-#define HAVE_MEMORY_H 1
 #define HAVE_PATHS_H 1
 #define HAVE_POSIX_MEMALIGN 1
 #define HAVE_PTHREAD_SETNAME3 1
@@ -41,6 +40,7 @@
 #define HAVE_SYS_DISKLABEL_H 1
 #define HAVE_SYS_DISK_H 1
 #define HAVE_SYS_DKIO_H 1
+#define HAVE_SYS_EVCNT_H 1
 #define HAVE_SYS_PARAM_H 1
 #define HAVE_SYS_STAT_H 1
 #define HAVE_SYS_SYSCTL_H 1
-- 
2.37.3



Home | Main Index | Thread Index | Old Index