* [PATCH] Add GCC's byteswap intrinsics
@ 2012-12-13 13:45 David Woodhouse
2012-12-13 16:11 ` Josh Triplett
0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2012-12-13 13:45 UTC (permalink / raw)
To: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
I'm about to make the kernel use these:
http://git.infradead.org/users/dwmw2/byteswap.git
lib.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib.c b/lib.c
index 396e9f1..d747a3e 100644
--- a/lib.c
+++ b/lib.c
@@ -698,6 +698,11 @@ void declare_builtin_functions(void)
add_pre_buffer("extern int __builtin_popcountl(unsigned long);\n");
add_pre_buffer("extern int __builtin_popcountll(unsigned long long);\n");
+ /* And byte-swapping operations.. */
+ add_pre_buffer("extern short __builtin_bswap16(short);\n");
+ add_pre_buffer("extern int __builtin_bswap32(int);\n");
+ add_pre_buffer("extern long long __builtin_bswap64(long long);\n");
+
/* And some random ones.. */
add_pre_buffer("extern void *__builtin_return_address(unsigned int);\n");
add_pre_buffer("extern void *__builtin_extract_return_addr(void *);\n");
--
1.8.0.1
--
dwmw2
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6171 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add GCC's byteswap intrinsics
2012-12-13 13:45 [PATCH] Add GCC's byteswap intrinsics David Woodhouse
@ 2012-12-13 16:11 ` Josh Triplett
2012-12-13 16:29 ` David Woodhouse
0 siblings, 1 reply; 3+ messages in thread
From: Josh Triplett @ 2012-12-13 16:11 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-sparse
On Thu, Dec 13, 2012 at 01:45:04PM +0000, David Woodhouse wrote:
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> ---
> I'm about to make the kernel use these:
> http://git.infradead.org/users/dwmw2/byteswap.git
>
> lib.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib.c b/lib.c
> index 396e9f1..d747a3e 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -698,6 +698,11 @@ void declare_builtin_functions(void)
> add_pre_buffer("extern int __builtin_popcountl(unsigned long);\n");
> add_pre_buffer("extern int __builtin_popcountll(unsigned long long);\n");
>
> + /* And byte-swapping operations.. */
> + add_pre_buffer("extern short __builtin_bswap16(short);\n");
> + add_pre_buffer("extern int __builtin_bswap32(int);\n");
> + add_pre_buffer("extern long long __builtin_bswap64(long long);\n");
GCC defines these to use int16_t, int32_t, and int64_t, respectively.
The first two of those should match up to "short" and "int" without any
issue, but on 64-bit platforms, stdint.h defines int64_t as "long", not
"long long". That could lead to some type incompatibilities.
- Josh Triplett
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add GCC's byteswap intrinsics
2012-12-13 16:11 ` Josh Triplett
@ 2012-12-13 16:29 ` David Woodhouse
0 siblings, 0 replies; 3+ messages in thread
From: David Woodhouse @ 2012-12-13 16:29 UTC (permalink / raw)
To: Josh Triplett; +Cc: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 487 bytes --]
On Thu, 2012-12-13 at 08:11 -0800, Josh Triplett wrote:
>
> GCC defines these to use int16_t, int32_t, and int64_t, respectively.
> The first two of those should match up to "short" and "int" without any
> issue, but on 64-bit platforms, stdint.h defines int64_t as "long", not
> "long long". That could lead to some type incompatibilities.
Are we allowed to use int64_t? Or must we pretend that it's still the
20th century and stdint.h might not be present?
--
dwmw2
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6171 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-13 16:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-13 13:45 [PATCH] Add GCC's byteswap intrinsics David Woodhouse
2012-12-13 16:11 ` Josh Triplett
2012-12-13 16:29 ` David Woodhouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).