make MSleep and GetMS public in headers
Stefan Schuermans

Stefan Schuermans commited on 2023-08-18 10:24:40
Showing 6 changed files, with 55 additions and 31 deletions.

... ...
@@ -120,7 +120,7 @@ LIB_LDLIBS :=
120 120
 TOOLS_LDFLAGS := -Llib
121 121
 TOOLS_LDLIBS :=
122 122
 
123
-LIB_LIST := BlinkenColorizer BlinkenFrame BlinkenMovie BlinkenProto Tools
123
+LIB_LIST := BlinkenColorizer BlinkenFrame BlinkenMovie BlinkenProto BlinkenTools Tools
124 124
 TOOLS_HELP_LIST := Tools2
125 125
 TOOLS_LIST := BlinkenConv BlinkenRecv BlinkenSend
126 126
 
... ...
@@ -0,0 +1,21 @@
1
+/* BlinkenLib
2
+   Copyright 2004-2014 Stefan Schuermans <stefan@schuermans.info>
3
+   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4
+   a blinkenarea.org project */
5
+
6
+#ifndef INC_BlinkenLib_BlinkenTools
7
+#define INC_BlinkenLib_BlinkenTools
8
+
9
+#ifdef __cplusplus
10
+extern "C" {
11
+#endif
12
+
13
+void BlinkenMSleep(unsigned int ms);
14
+
15
+unsigned int BlinkenGetMs(void);
16
+
17
+#ifdef __cplusplus
18
+} // extern "C"
19
+#endif
20
+
21
+#endif // #ifndef INC_BlinkenLib_BlinkenTools
... ...
@@ -19,6 +19,7 @@
19 19
 
20 20
 #include <BlinkenLib/BlinkenFrame.h>
21 21
 #include <BlinkenLib/BlinkenMovie.h>
22
+#include <BlinkenLib/BlinkenTools.h>
22 23
 
23 24
 #include "BlinkenConstants.h"
24 25
 #include "Tools.h"
... ...
@@ -0,0 +1,32 @@
1
+/* BlinkenLib
2
+   Copyright 2004-2023 Stefan Schuermans <stefan@schuermans.info>
3
+   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4
+   a blinkenarea.org project */
5
+
6
+#include "Tools.h"
7
+
8
+#ifdef WIN32
9
+#include <windows.h>
10
+#include <winsock2.h>
11
+#else
12
+#include <sys/time.h>
13
+#include <unistd.h>
14
+#endif
15
+
16
+#ifdef WIN32
17
+
18
+void BlinkenMSleep(unsigned int ms) { Sleep(ms); }
19
+
20
+unsigned int BlinkenGetMs(void) { return GetTickCount(); }
21
+
22
+#else
23
+
24
+void BlinkenMSleep(unsigned int ms) { usleep(ms * 1000); }
25
+
26
+unsigned int BlinkenGetMs(void) {
27
+  struct timeval tv;
28
+  gettimeofday(&tv, NULL);
29
+  return (unsigned int)(tv.tv_usec / 1000 + tv.tv_sec * 1000);
30
+}
31
+
32
+#endif
... ...
@@ -7,14 +7,6 @@
7 7
 
8 8
 #include <stdlib.h>
9 9
 
10
-#ifdef WIN32
11
-#include <windows.h>
12
-#include <winsock2.h>
13
-#else
14
-#include <sys/time.h>
15
-#include <unistd.h>
16
-#endif
17
-
18 10
 void *BlinkenMalloc1D(int count1, int size) {
19 11
   if (count1 < 1)
20 12
     count1 = 1;
... ...
@@ -49,21 +41,3 @@ void **BlinkenMalloc2D(int count1, int count2, int size) {
49 41
   }
50 42
   return ptr;
51 43
 }
52
-
53
-#ifdef WIN32
54
-
55
-void BlinkenMSleep(unsigned int ms) { Sleep(ms); }
56
-
57
-unsigned int BlinkenGetMs(void) { return GetTickCount(); }
58
-
59
-#else
60
-
61
-void BlinkenMSleep(unsigned int ms) { usleep(ms * 1000); }
62
-
63
-unsigned int BlinkenGetMs(void) {
64
-  struct timeval tv;
65
-  gettimeofday(&tv, NULL);
66
-  return (unsigned int)(tv.tv_usec / 1000 + tv.tv_sec * 1000);
67
-}
68
-
69
-#endif
... ...
@@ -26,10 +26,6 @@ void *BlinkenMalloc1D(int count1, int size);
26 26
 
27 27
 void **BlinkenMalloc2D(int count1, int count2, int size);
28 28
 
29
-void BlinkenMSleep(unsigned int ms);
30
-
31
-unsigned int BlinkenGetMs(void);
32
-
33 29
 #ifdef __cplusplus
34 30
 } // extern "C"
35 31
 #endif
36 32