From: "Joel Soete" <jsoe0708@tiscali.be>
To: "Grant Grundler" <grundler@parisc-linux.org>
Cc: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] byte swapping redux
Date: Tue, 1 Jul 2003 18:33:07 +0200 [thread overview]
Message-ID: <3ED71F6D0000C19D@ocpmta7.freegates.net> (raw)
In-Reply-To: <20030630163601.GC14971@dsl2.external.hp.com>
Hi Grant,
> > I don't understand why the 32bits kernel crashed with this patche:
> > (gcc-3.3 and binutils-2.13.90)
>
> uhm...perhaps the 64-bit swap is buggy for 32-bit mode?
> I didn't test that. It's a different code path.
I hope I am not going to anoying you.
I just found related interesting stuff: <http://lwn.net/Articles/38384/>
And may be also the source of pb.
I also write this small testcase to try to point out the pb in 32bits mode:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <asm/types.h>
typedef unsigned long long u64;
typedef u_int8_t BOOLEAN;
typedef struct
{
unsigned char b7, b6, b5, b4, b3, b2, b1, b0;
}
EightBytes;
static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
{
unsigned int temp;
__asm__("shd %0, %0, 16, %1\n\t" /* shift abcdabcd -> cdab
*/
"dep %1, 15, 8, %1\n\t" /* deposit cdab -> cbab */
"shd %0, %1, 8, %0" /* shift abcdcbab -> dcba
*/
: "=r" (x), "=&r" (temp)
: "0" (x));
return x;
}
#define __arch__swab32(x) ___arch__swab32(x)
static __inline__ __const__ __u64 ___arch__swab64(__u64 x)
{
__u32 t1 = (__u32) x;
__u32 t2 = (__u32) ((x) >> 32);
___arch__swab32(t1);
___arch__swab32(t2);
return (((__u64) t1 << 32) + ((__u64) t2));
}
static __inline__ __const__ __u32 __fswab32(__u32 x)
{
return __arch__swab32(x);
}
# define __swab32(x) __fswab32(x)
static __inline__ __const__ __u64 __fswab64(__u64 x)
{
__u32 h = x >> 32;
__u32 l = x & ((1ULL<<32)-1);
return (((__u64)__swab32(l)) << 32) | ((__u64)(__swab32(h)));
}
int main(int argc, char * * argv, char * * env) {
unsigned long long TU64;
int err;
TU64=0xfedcba9876543210LL;
printf("Val of TU64: %0Lx\n", TU64);
printf("Val of ___arch__swab64(TU64): %0Lx\n", ___arch__swab64(TU64));
printf("Val of __fswab64(TU64): %0Lx\n", __fswab64(TU64));
}
And here is the results:
Val of TU64: fedcba9876543210
Val of ___arch__swab64(TU64): 76543210fedcba98
Val of __fswab64(TU64): 1032547698badcfe
What is right (I could not rebuild with hppa64-linux-gcc :( )?
Thanks,
Joel
---------------------------------
Tiscali ADSL: 19,50 euros/mois...abonnez-vous sur www.tiscali.be
next prev parent reply other threads:[~2003-07-01 16:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3ED70CF10000BCAA@ocpmta2.freegates.net>
2003-06-30 16:36 ` [parisc-linux] byte swapping redux Grant Grundler
2003-07-01 16:33 ` Joel Soete [this message]
2003-07-01 18:13 ` Grant Grundler
2003-07-02 15:10 ` Joel Soete
2003-06-29 18:14 Grant Grundler
2003-06-29 18:33 ` Grant Grundler
2003-06-29 18:41 ` Matthew Wilcox
2003-06-29 21:33 ` Grant Grundler
2003-06-30 10:19 ` Joel Soete
2003-06-30 16:39 ` Grant Grundler
2003-07-01 7:29 ` Joel Soete
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ED71F6D0000C19D@ocpmta7.freegates.net \
--to=jsoe0708@tiscali.be \
--cc=grundler@parisc-linux.org \
--cc=parisc-linux@lists.parisc-linux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox