patch-2.1.104 linux/include/linux/delay.h
Next file: linux/include/linux/ip_fw.h
Previous file: linux/include/linux/cyclades.h
Back to the patch index
Back to the overall index
- Lines: 28
- Date:
Thu May 21 14:24:09 1998
- Orig file:
v2.1.103/linux/include/linux/delay.h
- Orig date:
Sat Nov 29 15:08:21 1997
diff -u --recursive --new-file v2.1.103/linux/include/linux/delay.h linux/include/linux/delay.h
@@ -11,4 +11,27 @@
#include <asm/delay.h>
+/*
+ * Using udelay() for intervals greater than a few milliseconds can
+ * risk overflow for high loops_per_sec (high bogomips) machines. The
+ * mdelay() provides a wrapper to prevent this. For delays greater
+ * than MAX_UDELAY_MS milliseconds, the wrapper is used. Architecture
+ * specific values can be defined in asm-???/delay.h as an override.
+ * The 2nd mdelay() definition ensures GCC will optimize away the
+ * while loop for the common cases where n <= MAX_UDELAY_MS -- Paul G.
+ */
+
+#ifndef MAX_UDELAY_MS
+#define MAX_UDELAY_MS 5
+#endif
+
+#ifdef notdef
+#define mdelay(n) (\
+ {unsigned long msec=(n); while (msec--) udelay(1000);})
+#else
+#define mdelay(n) (\
+ (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
+ ({unsigned long msec=(n); while (msec--) udelay(1000);}))
+#endif
+
#endif /* defined(_LINUX_DELAY_H) */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov