ObjFW  Check-in [2ff4ae177d]

Overview
Comment:Optimize OF_BSWAP64.

If we have a native OF_BSWAP32, it is still faster to shift and use
OF_BSWAP32 twice rather than having our own OF_BSWAP64. If we don't
have OF_BSWAP32 either, this generates exactly the same code as it did
before, but is much shorter.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2ff4ae177ddaa9b6241a9ba21cf44b441b93ba86749546064fca11fa47185292
User & Date: js on 2009-08-31 00:19:41
Other Links: manifest | tags
Context
2009-09-01
11:32
Rename -[length] to -[cStringLength] in OFString. check-in: 3ed599fe98 user: js tags: trunk
2009-08-31
00:19
Optimize OF_BSWAP64. check-in: 2ff4ae177d user: js tags: trunk
2009-08-30
20:06
Add some PowerPC assembly optimizations. check-in: 37e9b7c11c user: js tags: trunk
Changes

Modified src/OFMacros.h from [63162e95ce] to [830442e230].

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#if defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=r"(i) : "r"(i));
#elif defined(OF_X86_ASM)
	asm("bswap	%%eax\n\t"
	    "bswap	%%edx\n\t"
	    "xchgl	%%eax, %%edx" : "=A"(i): "A"(i));
#else
	i = (i & UINT64_C(0xFF00000000000000)) >> 56 |
	    (i & UINT64_C(0x00FF000000000000)) >> 40 |
	    (i & UINT64_C(0x0000FF0000000000)) >> 24 |
	    (i & UINT64_C(0x000000FF00000000)) >>  8 |
	    (i & UINT64_C(0x00000000FF000000)) <<  8 |
	    (i & UINT64_C(0x0000000000FF0000)) << 24 |
	    (i & UINT64_C(0x000000000000FF00)) << 40 |
	    (i & UINT64_C(0x00000000000000FF)) << 56;
#endif
	return i;
}

static OF_INLINE void
OF_BSWAP32_V(uint32_t *buf, size_t len)
{







|
<
<
<
<
<
<
<







72
73
74
75
76
77
78
79







80
81
82
83
84
85
86
#if defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=r"(i) : "r"(i));
#elif defined(OF_X86_ASM)
	asm("bswap	%%eax\n\t"
	    "bswap	%%edx\n\t"
	    "xchgl	%%eax, %%edx" : "=A"(i): "A"(i));
#else
	i = (uint64_t)OF_BSWAP32(i & 0xFFFFFFFF) << 32 | OF_BSWAP32(i >> 32);







#endif
	return i;
}

static OF_INLINE void
OF_BSWAP32_V(uint32_t *buf, size_t len)
{