浏览代码

Only define UA_sleep_ms if not yet defined (align with master)

Stefan Profanter 6 年之前
父节点
当前提交
0c3423036d

+ 6 - 0
arch/posix/ua_architecture.h

@@ -29,7 +29,13 @@
 #include <netdb.h>
 #include <sys/ioctl.h>
 #include <sys/select.h>
+#ifndef UA_sleep_ms
 #define UA_sleep_ms(X) usleep(X * 1000)
+#else /* UA_sleep_ms */
+/* With this one can define its own UA_sleep_ms using a preprocessor define.
+E.g. see unit tests. */
+void UA_sleep_ms(size_t ms);
+#endif
 
 #define OPTVAL_TYPE int
 

+ 1 - 0
arch/vxworks/ua_architecture.h

@@ -21,6 +21,7 @@
 
 #include <hostLib.h>
 #include <selectLib.h>
+
 #define UA_sleep_ms(X)                            \
  {                                                \
  struct timespec timeToSleep;                     \

+ 6 - 0
arch/win32/ua_architecture.h

@@ -83,7 +83,13 @@
 
 #define ssize_t int
 #define OPTVAL_TYPE char
+#ifndef UA_sleep_ms
 #define UA_sleep_ms(X) Sleep(X)
+#else /* UA_sleep_ms */
+/* With this one can define its own UA_sleep_ms using a preprocessor define.
+E.g. see unit tests. */
+void UA_sleep_ms(size_t ms);
+#endif
 
 #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
 #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)

+ 3 - 3
tests/testing-plugins/testing_clock.c

@@ -42,7 +42,7 @@ UA_realSleep(UA_UInt32 duration) {
 }
 
 void
-UA_comboSleep(UA_UInt32 duration) {
-    UA_fakeSleep(duration);
-    UA_realSleep(duration);
+UA_comboSleep(size_t duration) {
+    UA_fakeSleep((UA_UInt32)duration);
+    UA_realSleep((UA_UInt32)duration);
 }

+ 0 - 5
tests/testing-plugins/testing_clock.h

@@ -24,9 +24,4 @@ void UA_fakeSleep(UA_UInt32 duration);
 /* Sleep for the duration in milliseconds. Used to wait for workers to complete. */
 void UA_realSleep(UA_UInt32 duration);
 
-/* Sleep for the duration in milliseconds and update the current time.
- * combines fakeSleep and realSleep.
- * */
-void UA_comboSleep(UA_UInt32 duration);
-
 #endif /* TESTING_CLOCK_H_ */