ObjFW  Check-in [3588e29b9c]

Overview
Comment:Use __asm__ instead of asm to prevent conflicts.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3588e29b9cc22017078aba46a199314da16af7ebd0b3e3b85e63ddf14537aa62
User & Date: js on 2010-04-01 22:15:39
Other Links: manifest | tags
Context
2010-04-01
22:18
Merge to fix wrong parent. check-in: ab2f572dd8 user: js tags: trunk
22:15
Use __asm__ instead of asm to prevent conflicts. check-in: 3588e29b9c user: js tags: trunk
20:57
Improve method replacing when using the Apple runtime. check-in: 54e971a3a6 user: js tags: trunk
Changes

Modified src/macros.h from [2804045e97] to [869ffd926c].

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
	 ((uint64_t)i & UINT64_C(0x000000000000FF00)) << 40 |	\
	 ((uint64_t)i & UINT64_C(0x00000000000000FF)) << 56)

static OF_INLINE uint16_t
OF_BSWAP16_NONCONST(uint16_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	asm("xchgb	%h0, %b0" : "=Q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	asm("lhbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	asm("rev16	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
#endif
	return i;
}

static OF_INLINE uint32_t
OF_BSWAP32_NONCONST(uint32_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	asm("lwbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	asm("rev	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT32_C(0xFF000000)) >> 24 |
	    (i & UINT32_C(0x00FF0000)) >>  8 |
	    (i & UINT32_C(0x0000FF00)) <<  8 |
	    (i & UINT32_C(0x000000FF)) << 24;
#endif
	return i;
}

static OF_INLINE uint64_t
OF_BSWAP64_NONCONST(uint64_t i)
{
#if defined(OF_AMD64_ASM)
	asm("bswap	%0" : "=r"(i) : "0"(i));
#elif defined(OF_X86_ASM)
	asm("bswap	%%eax\n\t"
	    "bswap	%%edx\n\t"
	    "xchgl	%%eax, %%edx" : "=A"(i): "0"(i));
#else
	i = (uint64_t)OF_BSWAP32_NONCONST(i & 0xFFFFFFFF) << 32 |
	    OF_BSWAP32_NONCONST(i >> 32);
#endif
	return i;
}








|

|

|











|

|

|













|

|
|
|







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
	 ((uint64_t)i & UINT64_C(0x000000000000FF00)) << 40 |	\
	 ((uint64_t)i & UINT64_C(0x00000000000000FF)) << 56)

static OF_INLINE uint16_t
OF_BSWAP16_NONCONST(uint16_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	__asm__ ("xchgb	%h0, %b0" : "=Q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	__asm__ ("lhbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	__asm__ ("rev16	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
#endif
	return i;
}

static OF_INLINE uint32_t
OF_BSWAP32_NONCONST(uint32_t i)
{
#if defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
	__asm__ ("bswap	%0" : "=q"(i) : "0"(i));
#elif defined(OF_PPC_ASM)
	__asm__ ("lwbrx	%0, 0, %1" : "=r"(i) : "r"(&i), "m"(i));
#elif defined(OF_ARM_ASM)
	__asm__ ("rev	%0, %0" : "=r"(i) : "0"(i));
#else
	i = (i & UINT32_C(0xFF000000)) >> 24 |
	    (i & UINT32_C(0x00FF0000)) >>  8 |
	    (i & UINT32_C(0x0000FF00)) <<  8 |
	    (i & UINT32_C(0x000000FF)) << 24;
#endif
	return i;
}

static OF_INLINE uint64_t
OF_BSWAP64_NONCONST(uint64_t i)
{
#if defined(OF_AMD64_ASM)
	__asm__ ("bswap	%0" : "=r"(i) : "0"(i));
#elif defined(OF_X86_ASM)
	__asm__ ("bswap	%%eax\n\t"
		 "bswap	%%edx\n\t"
		 "xchgl	%%eax, %%edx" : "=A"(i) : "0"(i));
#else
	i = (uint64_t)OF_BSWAP32_NONCONST(i & 0xFFFFFFFF) << 32 |
	    OF_BSWAP32_NONCONST(i >> 32);
#endif
	return i;
}