[Ocfs2-commits] zab commits r1963 - in trunk: . kapi-compat/include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Mar 8 16:18:30 CST 2005
Author: zab
Signed-off-by: mfasheh
Date: 2005-03-08 16:18:28 -0600 (Tue, 08 Mar 2005)
New Revision: 1963
Added:
trunk/kapi-compat/include/kcalloc.h
Modified:
trunk/configure.in
Log:
o add kapi compat help for kcalloc()
Signed-off-by: mfasheh
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2005-03-08 02:07:34 UTC (rev 1962)
+++ trunk/configure.in 2005-03-08 22:18:28 UTC (rev 1963)
@@ -312,6 +312,14 @@
AC_MSG_RESULT(no)
fi
+AC_MSG_CHECKING([for kcalloc])
+if grep "\<kcalloc(" "$KERNELINC/linux/slab.h" >/dev/null 2>&1 ; then
+ AC_MSG_RESULT(yes)
+else
+ KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS kcalloc.h"
+ AC_MSG_RESULT(no)
+fi
+
#this check will break for 2.4 kernels...
AC_MSG_CHECKING([for kref_init with release callback])
if grep "kref_init.*release" "$KERNELINC/linux/kref.h" >/dev/null 2>&1 ; then
Added: trunk/kapi-compat/include/kcalloc.h
===================================================================
--- trunk/kapi-compat/include/kcalloc.h 2005-03-08 02:07:34 UTC (rev 1962)
+++ trunk/kapi-compat/include/kcalloc.h 2005-03-08 22:18:28 UTC (rev 1963)
@@ -0,0 +1,23 @@
+#ifndef KAPI_KCALLOC_H
+#define KAPI_KCALLOC_H
+
+#include <linux/slab.h>
+
+static inline void *kcalloc(size_t nmemb, size_t size, int flags)
+{
+ void *ret = NULL;
+
+ if (nmemb != 0 && (size > (INT_MAX / nmemb)))
+ goto out;
+
+ ret = kmalloc(nmemb * size, flags);
+ if (ret == NULL)
+ goto out;
+
+ memset(ret, 0, nmemb * size);
+
+out:
+ return ret;
+}
+
+#endif /* KAPI_KCALLOC_H */
More information about the Ocfs2-commits
mailing list