[Ocfs2-commits] zab commits r1877 - in trunk: . kapi-compat kapi-compat/include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Feb 1 18:47:34 CST 2005


Author: zab
Date: 2005-02-01 18:47:33 -0600 (Tue, 01 Feb 2005)
New Revision: 1877

Added:
   trunk/kapi-compat/
   trunk/kapi-compat/include/
   trunk/kapi-compat/include/msecs_to_jiffies.h
Modified:
   trunk/Config.make.in
   trunk/configure.in
Log:
o introduce tree-wide compat headers that let us introduce current kernel
  apis to environments that don't have them without having to dork up
  the source with includes or ifdefs


Modified: trunk/Config.make.in
===================================================================
--- trunk/Config.make.in	2005-02-01 22:24:55 UTC (rev 1876)
+++ trunk/Config.make.in	2005-02-02 00:47:33 UTC (rev 1877)
@@ -47,12 +47,18 @@
 KERNELINC = $(KERNELDIR)/include
 KERNELVER = @KERNELVER@
 
+# we have to be careful to -include our compat headers after modversions
+# in case the compat code tries to use modversioned symbols
 MODULEDIR = @MODULEDIR@
-MODVERSIONS = @MODVERSIONS@
+MODVERSIONS = @MODVERSIONS@ @KAPI_COMPAT_CFLAGS@
 
 GCCINC = @GCCINC@
 
 KVER =
+else
+
+EXTRA_CFLAGS += @KAPI_COMPAT_CFLAGS@
+
 endif
 
 MISSING_SOCK_CREATE_LITE = @MISSING_SOCK_CREATE_LITE@

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2005-02-01 22:24:55 UTC (rev 1876)
+++ trunk/configure.in	2005-02-02 00:47:33 UTC (rev 1877)
@@ -294,6 +294,22 @@
 fi
 AC_SUBST(MISSING_SOCK_CREATE_LITE)
 
+AC_MSG_CHECKING([for msecs_to_jiffies])
+if grep "\<msecs_to_jiffies(" "$KERNELINC/linux/jiffies.h" >/dev/null 2>&1 ; then
+  AC_MSG_RESULT(yes)
+else
+  KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS msecs_to_jiffies.h"
+  AC_MSG_RESULT(no)
+fi
+
+# using -include has two advantages:
+#  the source doesn't need to know to include compat headers
+#  the compat header file names don't go through the search path
+for h in $KAPI_COMPAT_HEADERS; do
+	KAPI_COMPAT_CFLAGS="$KAPI_COMPAT_CFLAGS -include \$(TOPDIR)/kapi-compat/include/$h"
+done
+AC_SUBST(KAPI_COMPAT_CFLAGS)
+
 AC_MSG_CHECKING(for directory for kernel modules)
 AC_ARG_WITH(moddir, [  --with-moddir=/path     Path to where modules should be installed [[/lib/modules/<KVER>/kernel]]], moddir="$withval", moddir="/lib/modules/$kversion/kernel")
 AC_MSG_RESULT($moddir)

Added: trunk/kapi-compat/include/msecs_to_jiffies.h
===================================================================
--- trunk/kapi-compat/include/msecs_to_jiffies.h	2005-02-01 22:24:55 UTC (rev 1876)
+++ trunk/kapi-compat/include/msecs_to_jiffies.h	2005-02-02 00:47:33 UTC (rev 1877)
@@ -0,0 +1,30 @@
+#ifndef KAPI_MSECS_TO_JIFFIES_H
+#define KAPI_MSECS_TO_JIFFIES_H
+
+#include <linux/time.h>
+
+static inline unsigned int jiffies_to_msecs(const unsigned long j)
+{
+#if HZ <= 1000 && !(1000 % HZ)
+	return (1000 / HZ) * j;
+#elif HZ > 1000 && !(HZ % 1000)
+	return (j + (HZ / 1000) - 1)/(HZ / 1000);
+#else
+	return (j * 1000) / HZ;
+#endif
+}
+
+static inline unsigned long msecs_to_jiffies(const unsigned int m)
+{
+	if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
+		return MAX_JIFFY_OFFSET;
+#if HZ <= 1000 && !(1000 % HZ)
+	return (m + (1000 / HZ) - 1) / (1000 / HZ);
+#elif HZ > 1000 && !(HZ % 1000)
+	return m * (HZ / 1000);
+#else
+	return (m * HZ + 999) / 1000;
+#endif
+}
+
+#endif



More information about the Ocfs2-commits mailing list