All of lore.kernel.org
 help / color / mirror / Atom feed
* sizeof problem in kernel modules
@ 2001-06-23 14:54 Der Herr Hofrat
  2001-06-23 15:18 ` Keith Owens
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Der Herr Hofrat @ 2001-06-23 14:54 UTC (permalink / raw)
  To: linux-kernel


Hi !

 can someone explain to me whats happening here ?

--simple.c--
#include <linux/module.h>
#include <linux/kernel.h>

struct { short x; long y; short z; }bad_struct;
struct { long y; short x; short z; }good_struct;

int init_module(void){
	printk("good_struct %d, bad_struct %d\n",sizeof(good_struct),sizeof(bad_struct));
	return 0;
}

void cleanup_module(void){
	}

--Makefile--

all: simple.o

CC= gcc 
CFLAGS= -pipe -fno-strength-reduce -DCPU=686 -march=i686 \
	-Wall -Wstrict-prototypes -g -D__KERNEL__ -DMODULE \
	-D_LOOSE_KERNEL_NAMES -O2   -c 
INCLUDE= -I/usr/include/linux 

clean:
	rm -f simple.o

---------------------------------------------------------------

I would expect both structs to be 8byte in size , or atleast the same size !
but good_struct turns out to be 8bytes and bad_struct 12 .

what am I doing wrong here ?

thx !
hofrat

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

end of thread, other threads:[~2001-06-25 21:26 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-06-23 14:54 sizeof problem in kernel modules Der Herr Hofrat
2001-06-23 15:18 ` Keith Owens
2001-06-23 15:30 ` Russell King
2001-06-24  1:56 ` Richard B. Johnson
2001-06-24  2:12   ` Keith Owens
2001-06-24  2:43     ` Richard B. Johnson
2001-06-24 16:07       ` Lieven Marchand
2001-06-24 16:11       ` frank
2001-06-25  0:26       ` Michael Meissner
2001-06-25 11:32         ` Richard B. Johnson
2001-06-25 13:38           ` Alan Shutko
2001-06-25 13:59             ` Alan Shutko
2001-06-25 15:07               ` Andreas Schwab
2001-06-25 21:25               ` Horst von Brand
2001-06-25 14:49             ` Richard B. Johnson
2001-06-25 19:19               ` Alan Shutko
2001-06-25 20:43           ` Michael Meissner
2001-06-25  4:33 ` Anil Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.