Re: Bit field issues in Solaris 2.8

Tom Hughes <[email protected]>
Newsgroups gmane.comp.debugging.ups.user
Organization Cyberscience Corporation
Message-ID <[email protected]>
In message <[email protected]>
        Tom Hughes <[email protected]> wrote:

> In message <[email protected]>
>           Callum Gibson <[email protected]> wrote:
> 
> > On FreeBSD display/edit works fine. On Solaris, it displays zeroes and
> > just gobbles up all values when edited. However, the edited values are
> > stored because the printf shows correctly what was entered. This looks like
> > a problem that was introduced in 3.38b1 (our previous Solaris version was
> > 3.37) on Solaris (2.6 - the original poster was on 2.8). Perhaps an endian
> > problem?
> 
> I suspect so, as I already told Steve. He says it is broken in 3.37 as
> well though, and my tests on Solaris tend to agree. I will try and look
> at this soon.

It was an endianess problem, and 3.37 does work as far as I can, at
least for bitfields based on 32 bit types. I don't believe it worked
for bitfields based on 16 bit types however, which is what my original
fix was all about (that and 64 bit bitfield support).

Unfortunately my previous was wrong on big endian platforms. A fix has
just been committed to CVS and a patch against CVS is attached.

Tom

-- 
Tom Hughes ([email protected])
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
ups-bitfield-patch (text/x-patch, 981 B)
Index: va_edit.c
===================================================================
RCS file: /cvsroot/ups/ups/ups/va_edit.c,v
retrieving revision 1.4
diff -u -r1.4 va_edit.c
--- va_edit.c	4 Nov 2002 14:56:20 -0000	1.4
+++ va_edit.c	8 Aug 2003 13:24:58 -0000
@@ -794,7 +794,7 @@
 	nbits = sizeof(uvlong) * 8;
 
 	if (bits_big_endian)
-		shift = nbits - (bf->bf_offset + bf->bf_width);
+		shift = (bf->bf_type->ty_size * 8) - (bf->bf_offset + bf->bf_width);
 	else
 		shift = bf->bf_offset;
 
Index: va_val.c
===================================================================
RCS file: /cvsroot/ups/ups/ups/va_val.c,v
retrieving revision 1.4
diff -u -r1.4 va_val.c
--- va_val.c	8 Jun 2003 15:04:19 -0000	1.4
+++ va_val.c	8 Aug 2003 13:24:58 -0000
@@ -483,7 +483,7 @@
 	nbits = sizeof(uvlong) * 8;
 
 	if (bits_big_endian)
-		shift = nbits - (bf->bf_offset + bf->bf_width);
+		shift = (bf->bf_type->ty_size * 8) - (bf->bf_offset + bf->bf_width);
 	else
 		shift = bf->bf_offset;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.