l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
April 21: Google Glass
Next Installfest:
TBD
Latest News:
Mar. 18: Google Glass at LUGOD's April meeting
Page last updated:
2002 Sep 15 20:48

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] appropriate variable size in driver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] appropriate variable size in driver



On Wednesday 11 September 2002 20:03, you wrote:
> begin Eric Nelson <en77@attbi.com>
>
> > I am porting a driver from an 8 bit processer to a linux driver.
>
> heh.  you mean rewrite, right?   :-)
>
Well, the hw part is new, and the interrupts, etc.  But that's the fun 
part.  It's the C code that does the processing that concerns me.  
It's one of those things, the boss thinks it's just a few hours work 
because it's existing code, but, you and I know, soon as you rebuild 
it, especially on a new processor, all bets are off.

> > 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.
>
> eric, i found that kernelnewbies.org is a good place for questions
> like this.  among other people, rik van riel hangs out on that
> mailing list, (although he mainly answers MM questions).  they've
> got some really good people there!

Thanks, pete, that's a good suggestion.  And, that's what I am, a 
newbie.  I'll try to filter the questions I send here.
>
> pete

(I'm trying to answer all at once)
---------------------------------------------------------------------
from Jeff Newmiller    

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.
--------------------------------------------------------------------
Eric Nelson:

Well, I guess I'll widen them, execpt part of it is processed as a 
char array, so, I don't want to change how it operates, so I'll leave 
that.  
It's is easy just to say int.  But, I guess I'm old fashioned, I keep 
wanting to use short int over int, save some cycles, but I guess the 
processer has to do about the same work.

----------------------------------------------------------------------
Mark Kim:
I'd test the unsigned char first to make sure the code works.  There 
could be other issues that are more important to address.  After 
verifying the code does work and has no other issues, then move onto 
int-fying variables.

If you int-fied everything first, and if the code didn't work, you
wouldn't know if the int-fying broke the code, if there are other 
issues, or both.

Just my $0.03... (inflation)
--------------------------------------------------------------------------
Eric Nelson:
Good suggestions.  I'll test thoroughly.  
I've had problems in the past w/ unsigned variables, you do have to be 
careful.  And, the problems don't show up until certain 
situations....  ;>).

By the way, something maybe you guys didn't know, I just found out, 
there are some types, I think in types.h,
u8,
u16,
u32,
If you want to specify exactly what size you want.
Thanks.



_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.