patch-2.1.106 linux/include/linux/timer.h

Next file: linux/include/linux/utsname.h
Previous file: linux/include/linux/sysctl.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.105/linux/include/linux/timer.h linux/include/linux/timer.h
@@ -71,4 +71,22 @@
 	timer->prev = NULL;
 }
 
+/*
+ *	These inlines deal with timer wrapping correctly. You are 
+ *	strongly encouraged to use them
+ *	1. Because people otherwise forget
+ *	2. Because if the timer wrap changes in future you wont have to
+ *	   alter your driver code.
+ */
+
+extern inline int time_before(unsigned long a, unsigned long b)
+{
+	return((long)((a) - (b)) < 0L);
+}
+
+extern inline int time_after(unsigned long a, unsigned long b)
+{
+	return((long)((a) - (b)) > 0L);
+}
+
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov