* Xawtv sparc 64bit fix
@ 2010-04-23 15:03 Guy Martin
2010-04-25 16:55 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 3+ messages in thread
From: Guy Martin @ 2010-04-23 15:03 UTC (permalink / raw)
To: Linux Media Mailing List
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
Hi,
Here is an old patch of mine which I tried to submit in 2006 but never
got it. I didn't really know who was xawtv's maintainer at that time.
The calculation to compute the 64bit alignement in struct-dump.c is
plain wrong. The alignment has to be computed with a structure
containing a char and then a 64bit integer and then substract the
pointer of the 64bit int to the one of the char.
This fix v4l-info doing a Bus Error on sparc with structs containing
64 bit integer following a non 64bit field aligned on a 8 byte boundary
like v4l2_standard.
Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>
Regards,
Guy
[-- Attachment #2: xawtv-struct-dump.diff --]
[-- Type: text/x-patch, Size: 1354 bytes --]
diff --git a/structs/struct-dump.c b/structs/struct-dump.c
index 0ee7fc8..ba1dc6f 100644
--- a/structs/struct-dump.c
+++ b/structs/struct-dump.c
@@ -43,7 +43,9 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
int16_t s16;
uint8_t u8;
int8_t s8;
- int al = sizeof(long)-1; /* struct + union + 64bit alignment */
+ struct al64_t { char c; uint64_t t; } al64_t;
+ int al = sizeof(long)-1; /* struct + union */
+ int al64 = (unsigned)&al64_t.t - (unsigned)&al64_t.c - 1; /* 64 bit alignement */
void *p;
unsigned int i,j,first;
@@ -149,7 +151,7 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
ptr += 4;
break;
case BITS64:
- ptr = (void*)(((intptr_t)ptr + al) & ~al);
+ ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
u64 = *((uint64_t*)ptr);
first = 1;
fprintf(fp,"0x%" PRIx64 " [",u64);
@@ -166,13 +168,13 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
break;
case UINT64:
- ptr = (void*)(((intptr_t)ptr + al) & ~al);
+ ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
u64 = *((uint64_t*)ptr);
fprintf(fp,"%" PRIu64,u64);
ptr += 8;
break;
case SINT64:
- ptr = (void*)(((intptr_t)ptr + al) & ~al);
+ ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
s64 = *((int64_t*)ptr);
fprintf(fp,"%" PRId64,s64);
ptr += 8;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Xawtv sparc 64bit fix
2010-04-23 15:03 Xawtv sparc 64bit fix Guy Martin
@ 2010-04-25 16:55 ` Mauro Carvalho Chehab
2010-04-26 16:52 ` Guy Martin
0 siblings, 1 reply; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2010-04-25 16:55 UTC (permalink / raw)
To: Guy Martin; +Cc: Linux Media Mailing List
Guy Martin wrote:
>
> Hi,
>
> Here is an old patch of mine which I tried to submit in 2006 but never
> got it. I didn't really know who was xawtv's maintainer at that time.
>
>
>
> The calculation to compute the 64bit alignement in struct-dump.c is
> plain wrong. The alignment has to be computed with a structure
> containing a char and then a 64bit integer and then substract the
> pointer of the 64bit int to the one of the char.
>
> This fix v4l-info doing a Bus Error on sparc with structs containing
> 64 bit integer following a non 64bit field aligned on a 8 byte boundary
> like v4l2_standard.
>
>
> Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>
I tried to compile it (x86_64 arch) and your patch produced two warnings:
../structs/struct-dump.c: In function ‘print_struct’:
../structs/struct-dump.c:48: warning: cast from pointer to integer of different size
../structs/struct-dump.c:48: warning: cast from pointer to integer of different size
Could you please fix it?
>
>
> Regards,
> Guy
>
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Xawtv sparc 64bit fix
2010-04-25 16:55 ` Mauro Carvalho Chehab
@ 2010-04-26 16:52 ` Guy Martin
0 siblings, 0 replies; 3+ messages in thread
From: Guy Martin @ 2010-04-26 16:52 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List
[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]
Hi Mauro,
Thanks for the feedback. Here is the fixed version.
Cheers,
Guy
On Sun, 25 Apr 2010 13:55:44 -0300
Mauro Carvalho Chehab <mchehab@redhat.com> wrote:
> Guy Martin wrote:
> >
> > Hi,
> >
> > Here is an old patch of mine which I tried to submit in 2006 but
> > never got it. I didn't really know who was xawtv's maintainer at
> > that time.
> >
> >
> >
> > The calculation to compute the 64bit alignement in struct-dump.c is
> > plain wrong. The alignment has to be computed with a structure
> > containing a char and then a 64bit integer and then substract the
> > pointer of the 64bit int to the one of the char.
> >
> > This fix v4l-info doing a Bus Error on sparc with structs containing
> > 64 bit integer following a non 64bit field aligned on a 8 byte
> > boundary like v4l2_standard.
> >
> >
> > Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>
>
> I tried to compile it (x86_64 arch) and your patch produced two
> warnings:
>
> ../structs/struct-dump.c: In function ‘print_struct’:
> ../structs/struct-dump.c:48: warning: cast from pointer to integer of
> different size ../structs/struct-dump.c:48: warning: cast from
> pointer to integer of different size
>
> Could you please fix it?
>
> >
> >
> > Regards,
> > Guy
> >
>
>
[-- Attachment #2: xawtv-struct-dump.diff --]
[-- Type: text/x-patch, Size: 1364 bytes --]
diff --git a/structs/struct-dump.c b/structs/struct-dump.c
index 0ee7fc8..49bfe2d 100644
--- a/structs/struct-dump.c
+++ b/structs/struct-dump.c
@@ -43,7 +43,9 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
int16_t s16;
uint8_t u8;
int8_t s8;
- int al = sizeof(long)-1; /* struct + union + 64bit alignment */
+ struct al64_t { char c; uint64_t t; } al64_t;
+ int al = sizeof(long)-1; /* struct + union */
+ int al64 = (unsigned long)&al64_t.t - (unsigned long)&al64_t.c - 1; /* 64 bit alignement */
void *p;
unsigned int i,j,first;
@@ -149,7 +151,7 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
ptr += 4;
break;
case BITS64:
- ptr = (void*)(((intptr_t)ptr + al) & ~al);
+ ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
u64 = *((uint64_t*)ptr);
first = 1;
fprintf(fp,"0x%" PRIx64 " [",u64);
@@ -166,13 +168,13 @@ int print_struct(FILE *fp, struct struct_desc *desc, void *data,
break;
case UINT64:
- ptr = (void*)(((intptr_t)ptr + al) & ~al);
+ ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
u64 = *((uint64_t*)ptr);
fprintf(fp,"%" PRIu64,u64);
ptr += 8;
break;
case SINT64:
- ptr = (void*)(((intptr_t)ptr + al) & ~al);
+ ptr = (void*)(((intptr_t)ptr + al64) & ~al64);
s64 = *((int64_t*)ptr);
fprintf(fp,"%" PRId64,s64);
ptr += 8;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-26 16:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-23 15:03 Xawtv sparc 64bit fix Guy Martin
2010-04-25 16:55 ` Mauro Carvalho Chehab
2010-04-26 16:52 ` Guy Martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox