|
1 | 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
2 | | -index ab44d1c..07e3e9f 100644 |
| 2 | +index 40bc803..937b6cf 100644 |
3 | 3 | --- a/CMakeLists.txt |
4 | 4 | +++ b/CMakeLists.txt |
5 | | -@@ -97,6 +97,9 @@ endif() |
| 5 | +@@ -114,6 +114,9 @@ endif() |
6 | 6 | if(CMAKE_THREAD_LIBS_INIT) |
7 | 7 | target_link_libraries(urcl PUBLIC "${CMAKE_THREAD_LIBS_INIT}") |
8 | 8 | endif() |
9 | 9 | +if(UNIX AND NOT APPLE) |
10 | 10 | + target_link_libraries(urcl PUBLIC "rt") |
11 | 11 | +endif() |
12 | 12 |
|
13 | | - ## |
14 | | - ## Build testing if enabled by option |
15 | | -diff --git a/include/ur_client_library/comm/bin_parser.h b/include/ur_client_library/comm/bin_parser.h |
16 | | -index e13aba6..83f8e6c 100644 |
17 | | ---- a/include/ur_client_library/comm/bin_parser.h |
18 | | -+++ b/include/ur_client_library/comm/bin_parser.h |
19 | | -@@ -21,7 +21,6 @@ |
20 | | - #pragma once |
21 | | - |
22 | | - #include <assert.h> |
23 | | --#include <endian.h> |
24 | | - #include <inttypes.h> |
25 | | - #include <array> |
26 | | - #include <bitset> |
27 | | -@@ -29,6 +28,7 @@ |
28 | | - #include <cstring> |
29 | | - #include <string> |
30 | | - #include <memory> |
31 | | -+#include "ur_client_library/portable_endian.h" |
32 | | - #include "ur_client_library/log.h" |
33 | | - #include "ur_client_library/types.h" |
34 | | - #include "ur_client_library/exceptions.h" |
35 | | -diff --git a/include/ur_client_library/comm/package_serializer.h b/include/ur_client_library/comm/package_serializer.h |
36 | | -index 01fa857..29fb196 100644 |
37 | | ---- a/include/ur_client_library/comm/package_serializer.h |
38 | | -+++ b/include/ur_client_library/comm/package_serializer.h |
39 | | -@@ -29,11 +29,11 @@ |
40 | | - #ifndef UR_CLIENT_LIBRARY_PACKAGE_SERIALIZER_H_INCLUDED |
41 | | - #define UR_CLIENT_LIBRARY_PACKAGE_SERIALIZER_H_INCLUDED |
42 | | - |
43 | | --#include <endian.h> |
44 | | - #include <cstdint> |
45 | | - #include <cstring> |
46 | | - #include <string> |
47 | | - |
48 | | -+#include "ur_client_library/portable_endian.h" |
49 | | - #include "ur_client_library/types.h" |
50 | | - |
51 | | - namespace urcl |
52 | | -diff --git a/include/ur_client_library/control/reverse_interface.h b/include/ur_client_library/control/reverse_interface.h |
53 | | -index 8220207..665f26d 100644 |
54 | | ---- a/include/ur_client_library/control/reverse_interface.h |
55 | | -+++ b/include/ur_client_library/control/reverse_interface.h |
56 | | -@@ -36,9 +36,9 @@ |
57 | | - #include "ur_client_library/ur/robot_receive_timeout.h" |
58 | | - #include "ur_client_library/ur/version_information.h" |
59 | | - #include <cstring> |
60 | | --#include <endian.h> |
61 | | - #include <condition_variable> |
62 | | - #include <list> |
63 | | -+#include "ur_client_library/portable_endian.h" |
64 | | - |
65 | | - namespace urcl |
66 | | - { |
67 | | -diff --git a/include/ur_client_library/portable_endian.h b/include/ur_client_library/portable_endian.h |
68 | | -new file mode 100644 |
69 | | -index 0000000..2b43378 |
70 | | ---- /dev/null |
71 | | -+++ b/include/ur_client_library/portable_endian.h |
72 | | -@@ -0,0 +1,118 @@ |
73 | | -+// "License": Public Domain |
74 | | -+// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like. |
75 | | -+// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to |
76 | | -+// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it |
77 | | -+// an example on how to get the endian conversion functions on different platforms. |
78 | | -+ |
79 | | -+#ifndef PORTABLE_ENDIAN_H__ |
80 | | -+#define PORTABLE_ENDIAN_H__ |
81 | | -+ |
82 | | -+#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) |
83 | | -+ |
84 | | -+# define __WINDOWS__ |
85 | | -+ |
86 | | -+#endif |
87 | | -+ |
88 | | -+#if defined(__linux__) || defined(__CYGWIN__) |
89 | | -+ |
90 | | -+# include <endian.h> |
91 | | -+ |
92 | | -+#elif defined(__APPLE__) |
93 | | -+ |
94 | | -+# include <libkern/OSByteOrder.h> |
95 | | -+ |
96 | | -+# define htobe16(x) OSSwapHostToBigInt16(x) |
97 | | -+# define htole16(x) OSSwapHostToLittleInt16(x) |
98 | | -+# define be16toh(x) OSSwapBigToHostInt16(x) |
99 | | -+# define le16toh(x) OSSwapLittleToHostInt16(x) |
100 | | -+ |
101 | | -+# define htobe32(x) OSSwapHostToBigInt32(x) |
102 | | -+# define htole32(x) OSSwapHostToLittleInt32(x) |
103 | | -+# define be32toh(x) OSSwapBigToHostInt32(x) |
104 | | -+# define le32toh(x) OSSwapLittleToHostInt32(x) |
105 | | -+ |
106 | | -+# define htobe64(x) OSSwapHostToBigInt64(x) |
107 | | -+# define htole64(x) OSSwapHostToLittleInt64(x) |
108 | | -+# define be64toh(x) OSSwapBigToHostInt64(x) |
109 | | -+# define le64toh(x) OSSwapLittleToHostInt64(x) |
110 | | -+ |
111 | | -+# define __BYTE_ORDER BYTE_ORDER |
112 | | -+# define __BIG_ENDIAN BIG_ENDIAN |
113 | | -+# define __LITTLE_ENDIAN LITTLE_ENDIAN |
114 | | -+# define __PDP_ENDIAN PDP_ENDIAN |
115 | | -+ |
116 | | -+#elif defined(__OpenBSD__) |
117 | | -+ |
118 | | -+# include <sys/endian.h> |
119 | | -+ |
120 | | -+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) |
121 | | -+ |
122 | | -+# include <sys/endian.h> |
123 | | -+ |
124 | | -+# define be16toh(x) betoh16(x) |
125 | | -+# define le16toh(x) letoh16(x) |
126 | | -+ |
127 | | -+# define be32toh(x) betoh32(x) |
128 | | -+# define le32toh(x) letoh32(x) |
129 | | -+ |
130 | | -+# define be64toh(x) betoh64(x) |
131 | | -+# define le64toh(x) letoh64(x) |
132 | | -+ |
133 | | -+#elif defined(__WINDOWS__) |
134 | | -+ |
135 | | -+# include <winsock2.h> |
136 | | -+# include <sys/param.h> |
137 | | -+ |
138 | | -+# if BYTE_ORDER == LITTLE_ENDIAN |
139 | | -+ |
140 | | -+# define htobe16(x) htons(x) |
141 | | -+# define htole16(x) (x) |
142 | | -+# define be16toh(x) ntohs(x) |
143 | | -+# define le16toh(x) (x) |
144 | | -+ |
145 | | -+# define htobe32(x) htonl(x) |
146 | | -+# define htole32(x) (x) |
147 | | -+# define be32toh(x) ntohl(x) |
148 | | -+# define le32toh(x) (x) |
149 | | -+ |
150 | | -+# define htobe64(x) htonll(x) |
151 | | -+# define htole64(x) (x) |
152 | | -+# define be64toh(x) ntohll(x) |
153 | | -+# define le64toh(x) (x) |
154 | | -+ |
155 | | -+# elif BYTE_ORDER == BIG_ENDIAN |
156 | | -+ |
157 | | -+ /* that would be xbox 360 */ |
158 | | -+# define htobe16(x) (x) |
159 | | -+# define htole16(x) __builtin_bswap16(x) |
160 | | -+# define be16toh(x) (x) |
161 | | -+# define le16toh(x) __builtin_bswap16(x) |
162 | | -+ |
163 | | -+# define htobe32(x) (x) |
164 | | -+# define htole32(x) __builtin_bswap32(x) |
165 | | -+# define be32toh(x) (x) |
166 | | -+# define le32toh(x) __builtin_bswap32(x) |
167 | | -+ |
168 | | -+# define htobe64(x) (x) |
169 | | -+# define htole64(x) __builtin_bswap64(x) |
170 | | -+# define be64toh(x) (x) |
171 | | -+# define le64toh(x) __builtin_bswap64(x) |
172 | | -+ |
173 | | -+# else |
174 | | -+ |
175 | | -+# error byte order not supported |
176 | | -+ |
177 | | -+# endif |
178 | | -+ |
179 | | -+# define __BYTE_ORDER BYTE_ORDER |
180 | | -+# define __BIG_ENDIAN BIG_ENDIAN |
181 | | -+# define __LITTLE_ENDIAN LITTLE_ENDIAN |
182 | | -+# define __PDP_ENDIAN PDP_ENDIAN |
183 | | -+ |
184 | | -+#else |
185 | | -+ |
186 | | -+# error platform not supported |
187 | | -+ |
188 | | -+#endif |
189 | | -+ |
190 | | -+#endif |
191 | | -diff --git a/include/ur_client_library/primary/package_header.h b/include/ur_client_library/primary/package_header.h |
192 | | -index cd64bda..440b2e4 100644 |
193 | | ---- a/include/ur_client_library/primary/package_header.h |
194 | | -+++ b/include/ur_client_library/primary/package_header.h |
195 | | -@@ -32,7 +32,7 @@ |
196 | | - |
197 | | - #include <inttypes.h> |
198 | | - #include <cstddef> |
199 | | --#include <endian.h> |
200 | | -+#include "ur_client_library/portable_endian.h" |
201 | | - #include "ur_client_library/types.h" |
202 | | - |
203 | | - namespace urcl |
204 | | -diff --git a/include/ur_client_library/rtde/package_header.h b/include/ur_client_library/rtde/package_header.h |
205 | | -index f910a08..eb509ea 100644 |
206 | | ---- a/include/ur_client_library/rtde/package_header.h |
207 | | -+++ b/include/ur_client_library/rtde/package_header.h |
208 | | -@@ -31,7 +31,7 @@ |
209 | | - #define UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED |
210 | | - |
211 | | - #include <cstddef> |
212 | | --#include <endian.h> |
213 | | -+#include "ur_client_library/portable_endian.h" |
214 | | - #include "ur_client_library/types.h" |
215 | | - #include "ur_client_library/comm/package_serializer.h" |
216 | | - |
217 | | -diff --git a/src/comm/tcp_socket.cpp b/src/comm/tcp_socket.cpp |
218 | | -index de18910..7e3c196 100644 |
219 | | ---- a/src/comm/tcp_socket.cpp |
220 | | -+++ b/src/comm/tcp_socket.cpp |
221 | | -@@ -20,7 +20,6 @@ |
222 | | - * limitations under the License. |
223 | | - */ |
224 | | - |
225 | | --#include <endian.h> |
226 | | - #include <chrono> |
227 | | - #include <cstring> |
228 | | - #include <sstream> |
229 | | -@@ -31,6 +30,7 @@ |
230 | | - # include <netinet/tcp.h> |
231 | | - #endif |
232 | | - |
233 | | -+#include "ur_client_library/portable_endian.h" |
234 | | - #include "ur_client_library/log.h" |
235 | | - #include "ur_client_library/comm/tcp_socket.h" |
236 | | - |
| 13 | + # When warnings are treated as errors, also enable high warning level for all targets |
| 14 | + if(CMAKE_COMPILE_WARNING_AS_ERROR) |
0 commit comments