[vox-tech] appropriate variable size in driver
Jeff Newmiller
vox-tech@lists.lugod.org
Wed, 11 Sep 2002 20:51:19 -0700 (PDT)
On Wed, 11 Sep 2002, Eric Nelson wrote:
> I am porting a driver from an 8 bit processer to a linux driver. Many
> counters and other variables are unsigned char, because they don't
> get big, do it works, kind of the embedded thing to do - keep small.
> The target is a 32 bit geode. It seems like I should generalize
> these variables to 16 bit or 32 bit. What works better? What is
> more 'appropriate'. It seems kind of old fashioned to leave them at
> 8 bit.
Processing 8-bit integers tends to be slightly slower on 32-bit
processors, and in some architectures is considerably slower. I would
widen them.
As to whether signed or unsigned is slower, that is architecturally
dependent too. AFAIK signed is slightly faster on x86, but Linux is
multiplatform so that is probably not a good justification for decisions.
I would use "int" unless I needed something more specific for a reason.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...2k
---------------------------------------------------------------------------