* writing portable code based on BITS_PER_LONG?
@ 2006-08-06 6:16 Om N.
2006-08-06 10:31 ` Jan-Benedict Glaw
2006-08-06 16:12 ` Arjan van de Ven
0 siblings, 2 replies; 4+ messages in thread
From: Om N. @ 2006-08-06 6:16 UTC (permalink / raw)
To: linux-kernel
Hi,
I am trying to port a driver written for IA32. This is a pci driver
and has a chipset doing PCI <-> local bus data transfer, where local
bus is 16 bit. So a number of values are converted by right/left
shifting by 16 bits.
Now that I am doing porting, I would like to make it fully portable
across AMD64 and IA32. What is the best method for this? Should I do
something like,
#if BITS_PER_LONG = 64
shiftwidth = 48
#else if BITS_PER_LONG = 32
shiftwidth = 16
#endif
I don't like this. I would not do it if there is some elegant way.
Is there any other way?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: writing portable code based on BITS_PER_LONG?
2006-08-06 6:16 writing portable code based on BITS_PER_LONG? Om N.
@ 2006-08-06 10:31 ` Jan-Benedict Glaw
2006-08-06 20:08 ` Om N.
2006-08-06 16:12 ` Arjan van de Ven
1 sibling, 1 reply; 4+ messages in thread
From: Jan-Benedict Glaw @ 2006-08-06 10:31 UTC (permalink / raw)
To: Om N.; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
On Sat, 2006-08-05 23:16:29 -0700, Om N. <xhandle@gmail.com> wrote:
> I am trying to port a driver written for IA32. This is a pci driver
> and has a chipset doing PCI <-> local bus data transfer, where local
> bus is 16 bit. So a number of values are converted by right/left
> shifting by 16 bits.
>
> Now that I am doing porting, I would like to make it fully portable
> across AMD64 and IA32. What is the best method for this? Should I do
> something like,
>
> #if BITS_PER_LONG = 64
> shiftwidth = 48
> #else if BITS_PER_LONG = 32
> shiftwidth = 16
> #endif
I'd probably write some macros that access the parts of the longs you
want to have/set and put these into some header file.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de +49-172-7608481
Signature of: Träume nicht von Dein Leben: Lebe Deinen Traum!
the second :
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: writing portable code based on BITS_PER_LONG?
2006-08-06 10:31 ` Jan-Benedict Glaw
@ 2006-08-06 20:08 ` Om N.
0 siblings, 0 replies; 4+ messages in thread
From: Om N. @ 2006-08-06 20:08 UTC (permalink / raw)
To: Om N., linux-kernel
On 8/6/06, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> On Sat, 2006-08-05 23:16:29 -0700, Om N. <xhandle@gmail.com> wrote:
> > I am trying to port a driver written for IA32. This is a pci driver
> > and has a chipset doing PCI <-> local bus data transfer, where local
> > bus is 16 bit. So a number of values are converted by right/left
> > shifting by 16 bits.
> I'd probably write some macros that access the parts of the longs you
> want to have/set and put these into some header file.
Let me go the macro way. Let me beat the code into some shape and then
post a url to the list for comments on 64bit safeness.
Thanks for ideas,
Regards,
Om.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: writing portable code based on BITS_PER_LONG?
2006-08-06 6:16 writing portable code based on BITS_PER_LONG? Om N.
2006-08-06 10:31 ` Jan-Benedict Glaw
@ 2006-08-06 16:12 ` Arjan van de Ven
1 sibling, 0 replies; 4+ messages in thread
From: Arjan van de Ven @ 2006-08-06 16:12 UTC (permalink / raw)
To: Om N.; +Cc: linux-kernel
On Sat, 2006-08-05 at 23:16 -0700, Om N. wrote:
> Hi,
> I am trying to port a driver written for IA32. This is a pci driver
> and has a chipset doing PCI <-> local bus data transfer, where local
> bus is 16 bit. So a number of values are converted by right/left
> shifting by 16 bits.
>
> Now that I am doing porting, I would like to make it fully portable
> across AMD64 and IA32. What is the best method for this? Should I do
> something like,
>
> #if BITS_PER_LONG = 64
> shiftwidth = 48
> #else if BITS_PER_LONG = 32
> shiftwidth = 16
> #endif
>
> I don't like this. I would not do it if there is some elegant way.
if you have a fixed sized bus, how about using the linux fixed size data
types?
Also, maybe it would be a good idea to post the url to your code so that
people on this list can do a quick 64-bit safeness audit of your
driver... free work/help and all that ;-)
Greetings,
Arjan van de Ven
--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-06 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-06 6:16 writing portable code based on BITS_PER_LONG? Om N.
2006-08-06 10:31 ` Jan-Benedict Glaw
2006-08-06 20:08 ` Om N.
2006-08-06 16:12 ` Arjan van de Ven
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®