@@ -104,6 +104,64 @@ int gettimeofday(struct timeval *tp)
return 0;
}
+#if defined(__i386__)
+static inline void nspin_sleep(uint32_t t)
+#else
+static inline void nspin_sleep(uint64_t t)
+#endif
+{
+ unsigned long end = since_boot_time() + t;
+
+ while ( since_boot_time() < end )
+ asm volatile ( "pause" );
+}
+
+#if defined(__i386__)
+static inline void spin_sleep(uint32_t t)
+#else
+static inline void spin_sleep(uint64_t t)
+#endif
+{
+#if defined(__i386__)
+ uint32_t nsec = t * 1000000000;
+#else
+ uint64_t nsec = t * 1000000000ul;
+#endif
+ nspin_sleep(nsec);
+}
+
+#if defined(__i386__)
+static inline void mspin_sleep(uint32_t t)
+#else
+static inline void mspin_sleep(uint64_t t)
+#endif
+{
+#if defined(__i386__)
+ uint32_t nsec = t * 1000000;
+#else
+ uint64_t nsec = t * 1000000ul;
+#endif
+ nspin_sleep(nsec);
+}
+
+#if defined(__i386__)
+void sleep(uint32_t t)
+#else
+void sleep(uint64_t t)
+#endif
+{
+ spin_sleep(t);
+}
+
+#if defined(__i386__)
+void msleep(uint32_t t)
+#else
+void msleep(uint64_t t)
+#endif
+{
+ mspin_sleep(t);
+}
+
/*
* Local variables:
* mode: C
@@ -23,14 +23,30 @@ struct timeval {
uint32_t since_boot_time(void);
uint32_t current_time(void);
+
+/* This function takes seconds in parameter */
+void sleep(uint32_t f);
+
+/* Be careful, this function takes milliseconds in parameter,
+ * not microseconds !
+ */
+void msleep(uint32_t f);
#else
uint64_t since_boot_time(void);
uint64_t current_time(void);
+
+void sleep(uint64_t f);
+
+void msleep(uint64_t f);
#endif
int gettimeofday(struct timeval *tp);
+
+/* This returns the current epoch time */
+#define NOW() current_time()
+
#endif /* XTF_TIME_H */
/*