mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
Pull in timespec, list, and type compat changes to support
building against a wider range of kernels. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@152 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
This commit is contained in:
parent
86149aa255
commit
6a6cafbe8d
@ -289,6 +289,8 @@ AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
|
|||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # 2.6.x API change
|
dnl # 2.6.x API change
|
||||||
dnl # check if uintptr_t typedef is defined
|
dnl # check if uintptr_t typedef is defined
|
||||||
@ -485,3 +487,67 @@ AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
|
|||||||
[class_device_create() is available])],
|
[class_device_create() is available])],
|
||||||
[])
|
[])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.26 API change, set_normalized_timespec() is exported.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
|
||||||
|
SPL_CHECK_SYMBOL_EXPORT(
|
||||||
|
[class_device_create],
|
||||||
|
[drivers/base/class.c],
|
||||||
|
[AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
|
||||||
|
[class_device_create() is available])],
|
||||||
|
[])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.26 API change, set_normalized_timespec() is exported.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
|
||||||
|
SPL_CHECK_SYMBOL_EXPORT(
|
||||||
|
[set_normalized_timespec],
|
||||||
|
[kernel/time.c],
|
||||||
|
[AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
|
||||||
|
[set_normalized_timespec() is available as export])],
|
||||||
|
[])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
|
||||||
|
dnl # previously it was available in time.h as an inline.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE],
|
||||||
|
[AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/time.h>
|
||||||
|
],[
|
||||||
|
void set_normalized_timespec(struct timespec *ts,
|
||||||
|
time_t sec, long nsec) { }
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
|
||||||
|
[set_normalized_timespec() is available as inline])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.18 API change,
|
||||||
|
dnl # timespec_sub() inline function available in linux/time.h
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_TIMESPEC_SUB],
|
||||||
|
[AC_MSG_CHECKING([whether timespec_sub() is available])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/time.h>
|
||||||
|
],[
|
||||||
|
struct timespec a, b, c = { 0 };
|
||||||
|
c = timespec_sub(a, b);
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
@ -54,6 +54,9 @@ SPL_AC_CTL_UNNUMBERED
|
|||||||
SPL_AC_FLS64
|
SPL_AC_FLS64
|
||||||
SPL_AC_DEVICE_CREATE
|
SPL_AC_DEVICE_CREATE
|
||||||
SPL_AC_CLASS_DEVICE_CREATE
|
SPL_AC_CLASS_DEVICE_CREATE
|
||||||
|
SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
|
||||||
|
SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
|
||||||
|
SPL_AC_TIMESPEC_SUB
|
||||||
|
|
||||||
TOPDIR=`/bin/pwd`
|
TOPDIR=`/bin/pwd`
|
||||||
|
|
||||||
|
27
include/linux/list_compat.h
Normal file
27
include/linux/list_compat.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef _SPL_LIST_COMPAT_H
|
||||||
|
#define _SPL_LIST_COMPAT_H
|
||||||
|
|
||||||
|
#include <linux/list.h>
|
||||||
|
|
||||||
|
#ifndef list_for_each_entry_safe_reverse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each_entry_safe_reverse
|
||||||
|
* @pos: the type * to use as a loop cursor.
|
||||||
|
* @n: another type * to use as temporary storage
|
||||||
|
* @head: the head for your list.
|
||||||
|
* @member: the name of the list_struct within the struct.
|
||||||
|
*
|
||||||
|
* Iterate backwards over list of given type, safe against removal
|
||||||
|
* of list entry.
|
||||||
|
*/
|
||||||
|
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
|
||||||
|
for (pos = list_entry((head)->prev, typeof(*pos), member), \
|
||||||
|
n = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||||
|
&pos->member != (head); \
|
||||||
|
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
|
||||||
|
|
||||||
|
#endif /* list_for_each_entry_safe_reverse */
|
||||||
|
|
||||||
|
#endif /* SPL_LIST_COMPAT_H */
|
||||||
|
|
21
include/linux/time_compat.h
Normal file
21
include/linux/time_compat.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef _SPL_TIME_COMPAT_H
|
||||||
|
#define _SPL_TIME_COMPAT_H
|
||||||
|
|
||||||
|
#include <linux/time.h>
|
||||||
|
|
||||||
|
/* timespec_sub() API changes
|
||||||
|
* 2.6.18 - 2.6.x: Inline function provided by linux/time.h
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_TIMESPEC_SUB
|
||||||
|
static inline struct timespec
|
||||||
|
timespec_sub(struct timespec lhs, struct timespec rhs)
|
||||||
|
{
|
||||||
|
struct timespec ts_delta;
|
||||||
|
set_normalized_timespec(&ts_delta, lhs.tv_sec - rhs.tv_sec,
|
||||||
|
lhs.tv_nsec - rhs.tv_nsec);
|
||||||
|
return ts_delta;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_TIMESPEC_SUB */
|
||||||
|
|
||||||
|
#endif /* _SPL_TIME_COMPAT_H */
|
||||||
|
|
@ -13,6 +13,14 @@ extern "C" {
|
|||||||
typedef unsigned long uintptr_t;
|
typedef unsigned long uintptr_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ULLONG_MAX
|
||||||
|
#define ULLONG_MAX (~0ULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LLONG_MAX
|
||||||
|
#define LLONG_MAX ((long long)(~0ULL>>1))
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum { B_FALSE=0, B_TRUE=1 } boolean_t;
|
typedef enum { B_FALSE=0, B_TRUE=1 } boolean_t;
|
||||||
typedef unsigned long intptr_t;
|
typedef unsigned long intptr_t;
|
||||||
typedef unsigned long ulong_t;
|
typedef unsigned long ulong_t;
|
||||||
|
@ -67,9 +67,13 @@ __gethrtime(void) {
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__gethrtime);
|
EXPORT_SYMBOL(__gethrtime);
|
||||||
|
|
||||||
/* Not exported from the kernel, but we need it for timespec_sub. Be very
|
/* set_normalized_timespec() API changes
|
||||||
* careful here we are using the kernel prototype, so that must not change.
|
* 2.6.0 - 2.6.15: Inline function provided by linux/time.h
|
||||||
|
* 2.6.16 - 2.6.25: Function prototypedefined but not exported
|
||||||
|
* 2.6.26 - 2.6.x: Function defined and exported
|
||||||
*/
|
*/
|
||||||
|
#if !defined(HAVE_SET_NORMALIZED_TIMESPEC_INLINE) && \
|
||||||
|
!defined(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT)
|
||||||
void
|
void
|
||||||
set_normalized_timespec(struct timespec *ts, time_t sec, long nsec)
|
set_normalized_timespec(struct timespec *ts, time_t sec, long nsec)
|
||||||
{
|
{
|
||||||
@ -85,3 +89,4 @@ set_normalized_timespec(struct timespec *ts, time_t sec, long nsec)
|
|||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(set_normalized_timespec);
|
EXPORT_SYMBOL(set_normalized_timespec);
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user