ObjFW  Check-in [2729104cf6]

Overview
Comment:Check for and use __builtin_bswap{16,32,64}
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2729104cf63dca383c5f6f7a96cbb627fa2994f4e406968f987e7d0d48c9eeec
User & Date: js on 2014-05-05 02:13:37
Other Links: manifest | tags
Context
2014-05-05
02:43
Add OF_NO_RETURN and OF_UNREACHABLE check-in: b885b6fdfa user: js tags: trunk
02:13
Check for and use __builtin_bswap{16,32,64} check-in: 2729104cf6 user: js tags: trunk
01:42
atomic.h: Prefer GCC builtins over ASM check-in: a199313c53 user: js tags: trunk
Changes

Modified configure.ac from [7027d6b582] to [7cdaa767b1].

790
791
792
793
794
795
796






















797
798
799
800
801
802
803

	AC_CHECK_FUNCS([h_errno hstrerror])
])

AS_IF([test x"$enable_sockets" != x"no" -a x"$enable_threads" != x"no"], [
	AC_SUBST(OFHTTPCLIENTTESTS_M, "OFHTTPClientTests.m")
])























case "$host" in
	arm-apple-darwin*)
		have_processes="no"
		;;
	*-*-mingw*)
		have_processes="yes"







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825

	AC_CHECK_FUNCS([h_errno hstrerror])
])

AS_IF([test x"$enable_sockets" != x"no" -a x"$enable_threads" != x"no"], [
	AC_SUBST(OFHTTPCLIENTTESTS_M, "OFHTTPClientTests.m")
])

AC_DEFUN([CHECK_BUILTIN_BSWAP], [
	AC_MSG_CHECKING(for __builtin_bswap$1)
	AC_TRY_LINK([
		#include <stdint.h>
		#include <stdio.h>
		#include <inttypes.h>
		#include <errno.h>
	], [
		uint$1_t i = errno;
		printf("%" PRIu$1, __builtin_bswap$1(i));
	], [
		AC_MSG_RESULT(yes)
		AC_DEFINE(OF_HAVE_BUILTIN_BSWAP$1, 1,
			[Whether we have __builtin_bswap$1])
	], [
		AC_MSG_RESULT(no)
	])
])
CHECK_BUILTIN_BSWAP(16)
CHECK_BUILTIN_BSWAP(32)
CHECK_BUILTIN_BSWAP(64)

case "$host" in
	arm-apple-darwin*)
		have_processes="no"
		;;
	*-*-mingw*)
		have_processes="yes"

Modified src/macros.h from [9ad949e286] to [8621e81b30].

195
196
197
198
199
200
201


202
203
204
205
206
207
208
209
	    (i & UINT64_C(0x000000000000FF00)) << 40 |
	    (i & UINT64_C(0x00000000000000FF)) << 56;
}

static OF_INLINE uint16_t OF_CONST_FUNC
OF_BSWAP16_NONCONST(uint16_t i)
{


#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	__asm__ (
	    "xchgb	%h0, %b0"
	    : "=Q"(i)
	    : "0"(i)
	);
#elif defined(OF_PPC_ASM)
	__asm__ (







>
>
|







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	    (i & UINT64_C(0x000000000000FF00)) << 40 |
	    (i & UINT64_C(0x00000000000000FF)) << 56;
}

static OF_INLINE uint16_t OF_CONST_FUNC
OF_BSWAP16_NONCONST(uint16_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP16)
	return __builtin_bswap16(i);
#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	__asm__ (
	    "xchgb	%h0, %b0"
	    : "=Q"(i)
	    : "0"(i)
	);
#elif defined(OF_PPC_ASM)
	__asm__ (
223
224
225
226
227
228
229


230
231
232
233
234
235
236
237
#endif
	return i;
}

static OF_INLINE uint32_t OF_CONST_FUNC
OF_BSWAP32_NONCONST(uint32_t i)
{


#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	__asm__ (
	    "bswap	%0"
	    : "=q"(i)
	    : "0"(i)
	);
#elif defined(OF_PPC_ASM)
	__asm__ (







>
>
|







225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#endif
	return i;
}

static OF_INLINE uint32_t OF_CONST_FUNC
OF_BSWAP32_NONCONST(uint32_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP32)
	return __builtin_bswap32(i);
#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	__asm__ (
	    "bswap	%0"
	    : "=q"(i)
	    : "0"(i)
	);
#elif defined(OF_PPC_ASM)
	__asm__ (
253
254
255
256
257
258
259


260
261
262
263
264
265
266
267
#endif
	return i;
}

static OF_INLINE uint64_t OF_CONST_FUNC
OF_BSWAP64_NONCONST(uint64_t i)
{


#if defined(OF_X86_64_ASM)
	__asm__ (
	    "bswap	%0"
	    : "=r"(i)
	    : "0"(i)
	);
#elif defined(OF_X86_ASM)
	__asm__ (







>
>
|







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#endif
	return i;
}

static OF_INLINE uint64_t OF_CONST_FUNC
OF_BSWAP64_NONCONST(uint64_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP64)
	return __builtin_bswap64(i);
#elif defined(OF_X86_64_ASM)
	__asm__ (
	    "bswap	%0"
	    : "=r"(i)
	    : "0"(i)
	);
#elif defined(OF_X86_ASM)
	__asm__ (

Modified src/objfw-defs.h.in from [ff70a225ad] to [b64e054749].

1
2
3
4
5



6
7
8
9
10
11
12
#undef OF_APPLE_RUNTIME
#undef OF_BIG_ENDIAN
#undef OF_FLOAT_BIG_ENDIAN
#undef OF_HAVE_ASPRINTF
#undef OF_HAVE_ATOMIC_OPS



#undef OF_HAVE_CHMOD
#undef OF_HAVE_CHOWN
#undef OF_HAVE_COMPILER_TLS
#undef OF_HAVE_FILES
#undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR
#undef OF_HAVE_GCC_ATOMIC_OPS
#undef OF_HAVE_LINK





>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#undef OF_APPLE_RUNTIME
#undef OF_BIG_ENDIAN
#undef OF_FLOAT_BIG_ENDIAN
#undef OF_HAVE_ASPRINTF
#undef OF_HAVE_ATOMIC_OPS
#undef OF_HAVE_BUILTIN_BSWAP16
#undef OF_HAVE_BUILTIN_BSWAP32
#undef OF_HAVE_BUILTIN_BSWAP64
#undef OF_HAVE_CHMOD
#undef OF_HAVE_CHOWN
#undef OF_HAVE_COMPILER_TLS
#undef OF_HAVE_FILES
#undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR
#undef OF_HAVE_GCC_ATOMIC_OPS
#undef OF_HAVE_LINK