mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* weird padding in linux/timex.h, struct timex
@ 2002-08-06 11:15 Muli Ben-Yehuda
  2002-08-06 13:36 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Muli Ben-Yehuda @ 2002-08-06 11:15 UTC (permalink / raw)
  To: Linux-Kernel

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

Hi, 

struct timex in include/linux/timex.h is defined as 

struct timex 
{
	...
	int  :32; int  :32; int  :32; int  :32;
	int  :32; int  :32; int  :32; int  :32;
	int  :32; int  :32; int  :32; int  :32;
}; 

I assume that this is used as padding. Is there any reason for using
bitfields as padding? If there is, a comment to that effect would be
nice. If there isn't, the following patch makes the padding explicit. 

--- 2.4.19-vanilla/include/linux/timex.h	Sun Aug  4 19:16:59 2002
+++ 2.4.19-mx/include/linux/timex.h	Tue Aug  6 13:49:32 2002
@@ -182,9 +182,7 @@
 	long errcnt;            /* calibration errors (ro) */
 	long stbcnt;            /* stability limit exceeded (ro) */
 
-	int  :32; int  :32; int  :32; int  :32;
-	int  :32; int  :32; int  :32; int  :32;
-	int  :32; int  :32; int  :32; int  :32;
+	char __pad[12 * 4];     /* padding */ 
 };
 
 /*


-- 
I am PINK, hear me ROAR

http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: weird padding in linux/timex.h, struct timex
  2002-08-06 13:36 ` Alan Cox
@ 2002-08-06 12:52   ` Muli Ben-Yehuda
  0 siblings, 0 replies; 3+ messages in thread
From: Muli Ben-Yehuda @ 2002-08-06 12:52 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux-Kernel

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

On Tue, Aug 06, 2002 at 02:36:04PM +0100, Alan Cox wrote:
> On Tue, 2002-08-06 at 12:15, Muli Ben-Yehuda wrote:
> > Hi, 
> > 
> > struct timex in include/linux/timex.h is defined as 
> > 
> > struct timex 
> > {
> > 	...
> > 	int  :32; int  :32; int  :32; int  :32;
> > 	int  :32; int  :32; int  :32; int  :32;
> > 	int  :32; int  :32; int  :32; int  :32;
> > }; 
> > 
> > I assume that this is used as padding. Is there any reason for using
> > bitfields as padding? If there is, a comment to that effect would be
> > nice. If there isn't, the following patch makes the padding explicit. 
> > 
> 
> That is how the interface has always been defined. I think we inherited
> that from the world of xntpd but I may be wrong. Your __pad is not
> always the same thing - you assume 4 byte ints and ints aligned the same
> way as char [], which may not always be true.

I assume 4 byte ints, because I assume that the length of a 32 bit
bitfield will be 32 bits. As for alignment, you're correct. 

I guess my question becomes: is the original code defined in any
special way, in regards to padding and size? If it isn't, my __pad
patch would be cleaner and just as correct in principle. If it is, I
can make a __pad which will behave exactly the same way. 

Thanks, Muli. 
-- 
I am PINK, hear me ROAR

http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: weird padding in linux/timex.h, struct timex
  2002-08-06 11:15 weird padding in linux/timex.h, struct timex Muli Ben-Yehuda
@ 2002-08-06 13:36 ` Alan Cox
  2002-08-06 12:52   ` Muli Ben-Yehuda
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2002-08-06 13:36 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Linux-Kernel

On Tue, 2002-08-06 at 12:15, Muli Ben-Yehuda wrote:
> Hi, 
> 
> struct timex in include/linux/timex.h is defined as 
> 
> struct timex 
> {
> 	...
> 	int  :32; int  :32; int  :32; int  :32;
> 	int  :32; int  :32; int  :32; int  :32;
> 	int  :32; int  :32; int  :32; int  :32;
> }; 
> 
> I assume that this is used as padding. Is there any reason for using
> bitfields as padding? If there is, a comment to that effect would be
> nice. If there isn't, the following patch makes the padding explicit. 
> 

That is how the interface has always been defined. I think we inherited
that from the world of xntpd but I may be wrong. Your __pad is not
always the same thing - you assume 4 byte ints and ints aligned the same
way as char [], which may not always be true.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-06 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-06 11:15 weird padding in linux/timex.h, struct timex Muli Ben-Yehuda
2002-08-06 13:36 ` Alan Cox
2002-08-06 12:52   ` Muli Ben-Yehuda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®