From: Justin Pettit Date: Sat, 31 Jul 2010 23:05:20 +0000 (-0700) Subject: datapath: Fix undefined symbol "set_normalized_timespec" X-Git-Tag: v1.1.0pre1~133 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=3aa77165af7d5acb18e79016ad8d741e35e1d45f;p=sliver-openvswitch.git datapath: Fix undefined symbol "set_normalized_timespec" The commit "datapath: Don't query time for every packet." (6bfafa55) introduced the use of "set_normalized_timespec". Unfortunately, older kernels don't export the symbol. This implements the function on those older kernels. --- diff --git a/datapath/linux-2.6/Modules.mk b/datapath/linux-2.6/Modules.mk index baa6f53cd..b6cb3e929 100644 --- a/datapath/linux-2.6/Modules.mk +++ b/datapath/linux-2.6/Modules.mk @@ -38,6 +38,7 @@ openvswitch_headers += \ linux-2.6/compat-2.6/include/linux/slab.h \ linux-2.6/compat-2.6/include/linux/stddef.h \ linux-2.6/compat-2.6/include/linux/tcp.h \ + linux-2.6/compat-2.6/include/linux/time.h \ linux-2.6/compat-2.6/include/linux/timer.h \ linux-2.6/compat-2.6/include/linux/types.h \ linux-2.6/compat-2.6/include/linux/udp.h \ diff --git a/datapath/linux-2.6/compat-2.6/include/linux/time.h b/datapath/linux-2.6/compat-2.6/include/linux/time.h new file mode 100644 index 000000000..fa325fae8 --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/include/linux/time.h @@ -0,0 +1,46 @@ +#ifndef __LINUX_TIME_WRAPPER_H +#define __LINUX_TIME_WRAPPER_H 1 + +#include_next + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) + +/* "set_normalized_timespec" is defined but not exported in kernels + * before 2.6.26. */ +#define set_normalized_timespec(ts, sec, nsec) \ + rpl_set_normalized_timespec(ts, sec, nsec) + +/** + * set_normalized_timespec - set timespec sec and nsec parts and normalize + * + * @ts: pointer to timespec variable to be set + * @sec: seconds to set + * @nsec: nanoseconds to set + * + * Set seconds and nanoseconds field of a timespec variable and + * normalize to the timespec storage format + * + * Note: The tv_nsec part is always in the range of + * 0 <= tv_nsec < NSEC_PER_SEC + * For negative values only the tv_sec field is negative ! + */ +static inline void rpl_set_normalized_timespec(struct timespec *ts, + time_t sec, long nsec) +{ + while (nsec >= NSEC_PER_SEC) { + nsec -= NSEC_PER_SEC; + ++sec; + } + while (nsec < 0) { + nsec += NSEC_PER_SEC; + --sec; + } + ts->tv_sec = sec; + ts->tv_nsec = nsec; +} + +#endif /* linux kernel < 2.6.26 */ + +#endif