• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

Revisionca176b8bf7e8457cf59ad9bfe57f62a7083e0b89 (tree)
Time2022-12-02 18:58:42
Authorphabrics <phabrics@phab...>
Commiterphabrics

Log Message

Compilation fixes for clang. In particular, the ffs & rdtsc functions were different, as well as the printf format attribute.

Change Summary

Incremental Difference

--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,7 @@ dnl POSSIBILITY OF SUCH DAMAGE.
3434 dnl Checks that we are given a good source directory.
3535 AC_PREREQ([2.68])
3636 m4_include(version.m4)
37-AC_INIT([tme], [0.12rc9])
37+AC_INIT([tme], [0.12rc10])
3838 AC_CONFIG_SRCDIR([ic/m68k/m68k-impl.h])
3939 AC_CONFIG_MACRO_DIR([m4])
4040 AC_CANONICAL_TARGET
@@ -1054,6 +1054,23 @@ if test "x${misc_hosts}" = "xno"; then
10541054 misc_hosts=
10551055 fi
10561056
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+
10571074 dnl Configure for libtool.
10581075 #AC_LIBLTDL_INSTALLABLE
10591076 #AC_SUBST(INCLTDL)
@@ -1153,7 +1170,7 @@ else
11531170 if test "x${have_clang}" = xyes; then
11541171 CFLAGS="${CFLAGS-} -Wno-tautological-compare -Wno-sometimes-uninitialized \
11551172 -Wno-sign-compare -Wno-incompatible-pointer-types \
1156- -Wno-implicit-function-declaration -Wno-\#warnings \
1173+ -Wno-implicit-function-declaration \
11571174 -fbracket-depth=1024"
11581175 fi
11591176 if test "x${have_Og}" = xyes; then
--- a/libtme/host/x86/misc-x86.c
+++ b/libtme/host/x86/misc-x86.c
@@ -38,23 +38,34 @@ _TME_RCSID("$Id: misc-x86.c,v 1.2 2009/11/08 17:21:18 fredette Exp $");
3838
3939 /* includes: */
4040 #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
4148
42-#if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
49+#if defined(_TME_HAVE___RDTSC) || defined(__GNUC__) && !defined(__EMSCRIPTEN__)
4350
4451 /* this returns the cycle counter: */
4552 inline union tme_value64
4653 tme_misc_cycles(void)
4754 {
55+ union tme_value64 value;
56+
57+#ifdef _TME_HAVE___RDTSC
58+ value.tme_value64_uint = __rdtsc();
59+#else
4860 unsigned long reg_a;
4961 unsigned long reg_d;
50- union tme_value64 value;
5162
5263 asm(" rdtsc \n"
5364 : "=a" (reg_a), "=d" (reg_d));
5465 value.tme_value64_uint32_lo = reg_a;
5566 value.tme_value64_uint32_hi = reg_d;
67+#endif /* !defined(__GNUC__) */
5668 return (value);
5769 }
5870 #define TME_HAVE_MISC_CYCLES
59-
60-#endif /* !defined(__GNUC__) */
71+#endif /* def _TME_HAVE___RDTSC */
--- a/tme/common.h
+++ b/tme/common.h
@@ -356,6 +356,11 @@ tme_bswap_u128(tme_uint128_t x)
356356 }
357357 #endif /* TME_HAVE_INT128_T */
358358
359+/* misc: */
360+#ifdef __clang__
361+#define ffs __builtin_ffs
362+#endif
363+
359364 /* versions: */
360365 #define TME_X_VERSION(current, age) (((current) << 10) | (age))
361366 #define TME_X_VERSION_CURRENT(version) ((version) >> 10)
--- a/tme/libopenvpn/buffer.h
+++ b/tme/libopenvpn/buffer.h
@@ -315,7 +315,7 @@ has_digit (const unsigned char* src)
315315 */
316316 bool buf_printf (struct buffer *buf, const char *format, ...)
317317 #ifdef __GNUC__
318-#if __USE_MINGW_ANSI_STDIO
318+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
319319 __attribute__ ((format (gnu_printf, 2, 3)))
320320 #else
321321 __attribute__ ((format (__printf__, 2, 3)))
@@ -333,7 +333,7 @@ bool buf_puts (struct buffer *buf, const char *str);
333333 */
334334 bool openvpn_snprintf(char *str, size_t size, const char *format, ...)
335335 #ifdef __GNUC__
336-#if __USE_MINGW_ANSI_STDIO
336+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
337337 __attribute__ ((format (gnu_printf, 3, 4)))
338338 #else
339339 __attribute__ ((format (__printf__, 3, 4)))
--- a/tme/libopenvpn/error.h
+++ b/tme/libopenvpn/error.h
@@ -174,7 +174,7 @@ bool dont_mute (unsigned int flags); /* check muting filter */
174174
175175 void x_msg (const unsigned int flags, const char *format, ...)
176176 #ifdef __GNUC__
177-#if __USE_MINGW_ANSI_STDIO
177+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
178178 __attribute__ ((format (gnu_printf, 2, 3)))
179179 #else
180180 __attribute__ ((format (__printf__, 2, 3)))
--- a/tme/libopenvpn/misc.h
+++ b/tme/libopenvpn/misc.h
@@ -338,7 +338,7 @@ void argv_printf_arglist (struct argv *a, const char *format, const unsigned int
338338
339339 void argv_printf (struct argv *a, const char *format, ...)
340340 #ifdef __GNUC__
341-#if __USE_MINGW_ANSI_STDIO
341+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
342342 __attribute__ ((format (gnu_printf, 2, 3)))
343343 #else
344344 __attribute__ ((format (__printf__, 2, 3)))
@@ -348,7 +348,7 @@ void argv_printf (struct argv *a, const char *format, ...)
348348
349349 void argv_printf_cat (struct argv *a, const char *format, ...)
350350 #ifdef __GNUC__
351-#if __USE_MINGW_ANSI_STDIO
351+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
352352 __attribute__ ((format (gnu_printf, 2, 3)))
353353 #else
354354 __attribute__ ((format (__printf__, 2, 3)))
--- a/tme/libopenvpn/openvpn-plugin.h
+++ b/tme/libopenvpn/openvpn-plugin.h
@@ -228,7 +228,7 @@ typedef enum
228228
229229
230230 #ifdef __GNUC__
231-#if __USE_MINGW_ANSI_STDIO
231+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
232232 # define _ovpn_chk_fmt(a, b) __attribute__ ((format(gnu_printf, (a), (b))))
233233 #else
234234 # define _ovpn_chk_fmt(a, b) __attribute__ ((format(__printf__, (a), (b))))
--- a/tme/libopenvpn/status.h
+++ b/tme/libopenvpn/status.h
@@ -77,7 +77,7 @@ void status_flush (struct status_output *so);
7777 bool status_close (struct status_output *so);
7878 void status_printf (struct status_output *so, const char *format, ...)
7979 #ifdef __GNUC__
80-#if __USE_MINGW_ANSI_STDIO
80+#if __USE_MINGW_ANSI_STDIO && !defined(__clang__)
8181 __attribute__ ((format (gnu_printf, 2, 3)))
8282 #else
8383 __attribute__ ((format (__printf__, 2, 3)))
--- a/tmesh/Makefile.am
+++ b/tmesh/Makefile.am
@@ -25,10 +25,10 @@ if WIN32
2525 if HAVE_SDL
2626 tmesh_LDFLAGS += -mwindows
2727 endif
28-endif
29-
28+else
3029 install-exec-hook:
3130 $(SETCAP) $(DESTDIR)$(bindir)/$(TGTPFX)tmesh$(EXEEXT)
31+endif
3232
3333 include $(top_srcdir)/tme-hosts.txt
3434 include $(top_srcdir)/tme-preopen.txt