From 6cc0735d0dbf6a0e5f802f47d51e1e463466955c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sat, 25 Aug 2007 15:10:44 -0700 Subject: [SPARC32]: Add __cmpdi2() libcall implementation ala. MIPS. Device mapper generates calls to this with recent versions of gcc. Signed-off-by: David S. Miller --- arch/sparc/lib/Makefile | 3 ++- arch/sparc/lib/cmpdi2.c | 27 +++++++++++++++++++++++++++ arch/sparc/lib/libgcc.h | 18 ++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 arch/sparc/lib/cmpdi2.c create mode 100644 arch/sparc/lib/libgcc.h (limited to 'arch/sparc') diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 9ddc5b9ce3b..76effdbea07 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile @@ -8,6 +8,7 @@ lib-y := mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o memcpy.o memset.o \ strlen.o checksum.o blockops.o memscan.o memcmp.o strncmp.o \ strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \ copy_user.o locks.o atomic.o \ - lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o + lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o \ + cmpdi2.o obj-y += iomap.o atomic32.o diff --git a/arch/sparc/lib/cmpdi2.c b/arch/sparc/lib/cmpdi2.c new file mode 100644 index 00000000000..8c1306437ed --- /dev/null +++ b/arch/sparc/lib/cmpdi2.c @@ -0,0 +1,27 @@ +#include + +#include "libgcc.h" + +word_type __cmpdi2(long long a, long long b) +{ + const DWunion au = { + .ll = a + }; + const DWunion bu = { + .ll = b + }; + + if (au.s.high < bu.s.high) + return 0; + else if (au.s.high > bu.s.high) + return 2; + + if ((unsigned int) au.s.low < (unsigned int) bu.s.low) + return 0; + else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) + return 2; + + return 1; +} + +EXPORT_SYMBOL(__cmpdi2); diff --git a/arch/sparc/lib/libgcc.h b/arch/sparc/lib/libgcc.h new file mode 100644 index 00000000000..b84fd797f3e --- /dev/null +++ b/arch/sparc/lib/libgcc.h @@ -0,0 +1,18 @@ +#ifndef __ASM_LIBGCC_H +#define __ASM_LIBGCC_H + +#include + +typedef int word_type __attribute__ ((mode (__word__))); + +struct DWstruct { + int high, low; +}; + +typedef union +{ + struct DWstruct s; + long long ll; +} DWunion; + +#endif /* __ASM_LIBGCC_H */ -- cgit v1.2.3-70-g09d2