Skip to contentSkip to conversation

how is the asm-generic to be used?

DISCUSSION george anzinger 2 participants 3 messages Dec 5, 2002

lore
Share & tools
lore
#0 lore raw

Lets say there is a bit of code in the kernel ( i.e. .../kernel/ ) that needs a function that is in an asm-gneric/*.h file. Now someone comes along and does an asm-x386/*.h with the same functionality but much faster asm functions. How should the using code be set up to get the faster asm version if it exists and the generic version if it does not?

Signature · 5 lines
George Anzinger   [email protected]
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
#1 lore raw
Quoted 7 lines · george anzinger

Lets say there is a bit of code in the kernel ( i.e. .../kernel/ ) that needs a function that is in an asm-gneric/*.h file. Now someone comes along and does an asm-x386/*.h with the same functionality but much faster asm functions. How should the using code be set up to get the faster asm version if it exists and the generic version if it does not?

Can you be more specific? :)

asm-generic is for things that belong in include/asm-$ARCH but are also shared across multiple architectures.

#2 lore raw
Quoted 10 lines · Jeff Garzik
Quoted 7 lines · george anzinger

Lets say there is a bit of code in the kernel ( i.e. .../kernel/ ) that needs a function that is in an asm-gneric/*.h file. Now someone comes along and does an asm-x386/*.h with the same functionality but much faster asm functions. How should the using code be set up to get the faster asm version if it exists and the generic version if it does not?

Quoted 5 lines

Can you be more specific? :)

asm-generic is for things that belong in include/asm-$ARCH but are also shared across multiple architectures.

What I have is a generic version of sc_math.h, a set of inlines and defines that make it easy to access the mpy and div instructions with 64-bit/32-bit arguments (for example mpy takes 2 32-bit arguments and produces a 64-bit result). Individual archs would do these things with an sc_math.h that uses asm (which I also have for the i386 arch). So the question is how things are set up so that the arch version is used if available and the generic if not.

I think the answer (one of those, "it came to me in the shower answers") is that it is handled by the make file setting up the include file search paths so that first asm-<arch> is search and then asm-generic.

Signature · 5 lines
George Anzinger   [email protected]
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml