Revision | ca176b8bf7e8457cf59ad9bfe57f62a7083e0b89 (tree) |
---|---|
Time | 2022-12-02 18:58:42 |
Author | phabrics <phabrics@phab...> |
Commiter | phabrics |
Compilation fixes for clang. In particular, the ffs & rdtsc functions were different, as well as the printf format attribute.
@@ -34,7 +34,7 @@ dnl POSSIBILITY OF SUCH DAMAGE. | ||
34 | 34 | dnl Checks that we are given a good source directory. |
35 | 35 | AC_PREREQ([2.68]) |
36 | 36 | m4_include(version.m4) |
37 | -AC_INIT([tme], [0.12rc9]) | |
37 | +AC_INIT([tme], [0.12rc10]) | |
38 | 38 | AC_CONFIG_SRCDIR([ic/m68k/m68k-impl.h]) |
39 | 39 | AC_CONFIG_MACRO_DIR([m4]) |
40 | 40 | AC_CANONICAL_TARGET |
@@ -1054,6 +1054,23 @@ if test "x${misc_hosts}" = "xno"; then | ||
1054 | 1054 | misc_hosts= |
1055 | 1055 | fi |
1056 | 1056 | |
1057 | +if test "x${misc_hosts}" = "xx86"; then | |
1058 | + AC_CHECK_FUNC_LONG(__rdtsc, [ | |
1059 | + unsigned long long int x; | |
1060 | + | |
1061 | + // _mm_lfence(); // optionally wait for earlier insns to retire before reading the clock | |
1062 | + x = __rdtsc(); | |
1063 | + // _mm_lfence(); // optionally block later instructions until rdtsc retires | |
1064 | +],[ | |
1065 | +#ifdef _MSC_VER | |
1066 | +#include <intrin.h> | |
1067 | +#else | |
1068 | +#include <x86intrin.h> | |
1069 | +#endif | |
1070 | +]) | |
1071 | +fi | |
1072 | + | |
1073 | + | |
1057 | 1074 | dnl Configure for libtool. |
1058 | 1075 | #AC_LIBLTDL_INSTALLABLE |
1059 | 1076 | #AC_SUBST(INCLTDL) |
@@ -1153,7 +1170,7 @@ else | ||
1153 | 1170 | if test "x${have_clang}" = xyes; then |
1154 | 1171 | CFLAGS="${CFLAGS-} -Wno-tautological-compare -Wno-sometimes-uninitialized \ |
1155 | 1172 | -Wno-sign-compare -Wno-incompatible-pointer-types \ |
1156 | - -Wno-implicit-function-declaration -Wno-\#warnings \ | |
1173 | + -Wno-implicit-function-declaration \ | |
1157 | 1174 | -fbracket-depth=1024" |
1158 | 1175 | fi |
1159 | 1176 | if test "x${have_Og}" = xyes; then |
@@ -38,23 +38,34 @@ _TME_RCSID("$Id: misc-x86.c,v 1.2 2009/11/08 17:21:18 fredette Exp $"); | ||
38 | 38 | |
39 | 39 | /* includes: */ |
40 | 40 | #include <tme/misc.h> |
41 | +#ifdef _TME_HAVE___RDTSC | |
42 | +#ifdef _MSC_VER | |
43 | +#include <intrin.h> | |
44 | +#else | |
45 | +#include <x86intrin.h> | |
46 | +#endif | |
47 | +#endif | |
41 | 48 | |
42 | -#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) | |
49 | +#if defined(_TME_HAVE___RDTSC) || defined(__GNUC__) && !defined(__EMSCRIPTEN__) | |
43 | 50 | |
44 | 51 | /* this returns the cycle counter: */ |
45 | 52 | inline union tme_value64 |
46 | 53 | tme_misc_cycles(void) |
47 | 54 | { |
55 | + union tme_value64 value; | |
56 | + | |
57 | +#ifdef _TME_HAVE___RDTSC | |
58 | + value.tme_value64_uint = __rdtsc(); | |
59 | +#else | |
48 | 60 | unsigned long reg_a; |
49 | 61 | unsigned long reg_d; |
50 | - union tme_value64 value; | |
51 | 62 | |
52 | 63 | asm(" rdtsc \n" |
53 | 64 | : "=a" (reg_a), "=d" (reg_d)); |
54 | 65 | value.tme_value64_uint32_lo = reg_a; |
55 | 66 | value.tme_value64_uint32_hi = reg_d; |
67 | +#endif /* !defined(__GNUC__) */ | |
56 | 68 | return (value); |
57 | 69 | } |
58 | 70 | #define TME_HAVE_MISC_CYCLES |
59 | - | |
60 | -#endif /* !defined(__GNUC__) */ | |
71 | +#endif /* def _TME_HAVE___RDTSC */ |
@@ -356,6 +356,11 @@ tme_bswap_u128(tme_uint128_t x) | ||
356 | 356 | } |
357 | 357 | #endif /* TME_HAVE_INT128_T */ |
358 | 358 | |
359 | +/* misc: */ | |
360 | +#ifdef __clang__ | |
361 | +#define ffs __builtin_ffs | |
362 | +#endif | |
363 | + | |
359 | 364 | /* versions: */ |
360 | 365 | #define TME_X_VERSION(current, age) (((current) << 10) | (age)) |
361 | 366 | #define TME_X_VERSION_CURRENT(version) ((version) >> 10) |
@@ -315,7 +315,7 @@ has_digit (const unsigned char* src) | ||
315 | 315 | */ |
316 | 316 | bool buf_printf (struct buffer *buf, const char *format, ...) |
317 | 317 | #ifdef __GNUC__ |
318 | -#if __USE_MINGW_ANSI_STDIO | |
318 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
319 | 319 | __attribute__ ((format (gnu_printf, 2, 3))) |
320 | 320 | #else |
321 | 321 | __attribute__ ((format (__printf__, 2, 3))) |
@@ -333,7 +333,7 @@ bool buf_puts (struct buffer *buf, const char *str); | ||
333 | 333 | */ |
334 | 334 | bool openvpn_snprintf(char *str, size_t size, const char *format, ...) |
335 | 335 | #ifdef __GNUC__ |
336 | -#if __USE_MINGW_ANSI_STDIO | |
336 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
337 | 337 | __attribute__ ((format (gnu_printf, 3, 4))) |
338 | 338 | #else |
339 | 339 | __attribute__ ((format (__printf__, 3, 4))) |
@@ -174,7 +174,7 @@ bool dont_mute (unsigned int flags); /* check muting filter */ | ||
174 | 174 | |
175 | 175 | void x_msg (const unsigned int flags, const char *format, ...) |
176 | 176 | #ifdef __GNUC__ |
177 | -#if __USE_MINGW_ANSI_STDIO | |
177 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
178 | 178 | __attribute__ ((format (gnu_printf, 2, 3))) |
179 | 179 | #else |
180 | 180 | __attribute__ ((format (__printf__, 2, 3))) |
@@ -338,7 +338,7 @@ void argv_printf_arglist (struct argv *a, const char *format, const unsigned int | ||
338 | 338 | |
339 | 339 | void argv_printf (struct argv *a, const char *format, ...) |
340 | 340 | #ifdef __GNUC__ |
341 | -#if __USE_MINGW_ANSI_STDIO | |
341 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
342 | 342 | __attribute__ ((format (gnu_printf, 2, 3))) |
343 | 343 | #else |
344 | 344 | __attribute__ ((format (__printf__, 2, 3))) |
@@ -348,7 +348,7 @@ void argv_printf (struct argv *a, const char *format, ...) | ||
348 | 348 | |
349 | 349 | void argv_printf_cat (struct argv *a, const char *format, ...) |
350 | 350 | #ifdef __GNUC__ |
351 | -#if __USE_MINGW_ANSI_STDIO | |
351 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
352 | 352 | __attribute__ ((format (gnu_printf, 2, 3))) |
353 | 353 | #else |
354 | 354 | __attribute__ ((format (__printf__, 2, 3))) |
@@ -228,7 +228,7 @@ typedef enum | ||
228 | 228 | |
229 | 229 | |
230 | 230 | #ifdef __GNUC__ |
231 | -#if __USE_MINGW_ANSI_STDIO | |
231 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
232 | 232 | # define _ovpn_chk_fmt(a, b) __attribute__ ((format(gnu_printf, (a), (b)))) |
233 | 233 | #else |
234 | 234 | # define _ovpn_chk_fmt(a, b) __attribute__ ((format(__printf__, (a), (b)))) |
@@ -77,7 +77,7 @@ void status_flush (struct status_output *so); | ||
77 | 77 | bool status_close (struct status_output *so); |
78 | 78 | void status_printf (struct status_output *so, const char *format, ...) |
79 | 79 | #ifdef __GNUC__ |
80 | -#if __USE_MINGW_ANSI_STDIO | |
80 | +#if __USE_MINGW_ANSI_STDIO && !defined(__clang__) | |
81 | 81 | __attribute__ ((format (gnu_printf, 2, 3))) |
82 | 82 | #else |
83 | 83 | __attribute__ ((format (__printf__, 2, 3))) |
@@ -25,10 +25,10 @@ if WIN32 | ||
25 | 25 | if HAVE_SDL |
26 | 26 | tmesh_LDFLAGS += -mwindows |
27 | 27 | endif |
28 | -endif | |
29 | - | |
28 | +else | |
30 | 29 | install-exec-hook: |
31 | 30 | $(SETCAP) $(DESTDIR)$(bindir)/$(TGTPFX)tmesh$(EXEEXT) |
31 | +endif | |
32 | 32 | |
33 | 33 | include $(top_srcdir)/tme-hosts.txt |
34 | 34 | include $(top_srcdir)/tme-preopen.txt |