Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Apr 1997 16:29:29 +0300 (EEST)
From:      Narvi <narvi@haldjas.folklore.ee>
To:        Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How to declare device driver variables and data structures ?
Message-ID:  <Pine.BSF.3.95.970406160306.24837A-100000@haldjas.folklore.ee>
In-Reply-To: <19970406140909.UB47399@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help


On Sun, 6 Apr 1997, J Wunsch wrote:

> As Hellmuth Michaelis wrote:
> 
> > i.e. if i know a variable can only have values 0 ... 32, shall i make it
> > an unsigned char ? Is it slower to make such variables an unsigned int
> > or an unsigned short ? What are the space vs. speed considerations ?
> 
> You should probably only use shorter values than plain int or unsigned
> if either the hardware enforces a particular size (since it's a mirror
> of a hardware register or such), or if you pack a bunch of them
> beneath, and they are static/extern/bss.  For automatic variables, i
> think it's better to stick with the default size for your machine.
> I'm not sure, but if it has an effect at all, restraining the size
> will make the access slower.
> 

Well, what about all the graphics code? It isn't reasonable to have all
the data as ints if the picture is only 8bit, is it? (Special MMX
instructions are totally another story).

	Sander

[snip]

> > How does this all apply to variables being part of structures ?
> 
> Alignment problems...  see also style(9).
> 
> -- 
> cheers, J"org
> 
> joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
> Never trust an operating system you don't have sources for. ;-)
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.970406160306.24837A-100000>