From: Andreas Schneider Date: Fri, 21 Dec 2018 08:43:01 +0000 (+0100) Subject: lib:util: Remove PPC big endian asm optimized code in byteorder.h X-Git-Tag: samba-4.11.0rc1~887 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=3f16e97fe38df7e46ec16d131da8a45577863bfa lib:util: Remove PPC big endian asm optimized code in byteorder.h Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/lib/util/byteorder.h b/lib/util/byteorder.h index 3933926cf54..3e991fbbb2f 100644 --- a/lib/util/byteorder.h +++ b/lib/util/byteorder.h @@ -88,60 +88,11 @@ it also defines lots of intermediate macros, just ignore those :-) */ -/* - * On powerpc we can use the magic instructions to load/store in little endian. - * The instructions are reverse-indexing, so assume a big endian Power - * processor. Power8 can be big or little endian, so we need to explicitly - * check. - */ -#if (defined(__powerpc__) && defined(__GNUC__) && HAVE_BIG_ENDIAN) -static __inline__ uint16_t ld_le16(const uint16_t *addr) -{ - uint16_t val; - __asm__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); - return val; -} - -static __inline__ void st_le16(uint16_t *addr, const uint16_t val) -{ - __asm__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); -} - -static __inline__ uint32_t ld_le32(const uint32_t *addr) -{ - uint32_t val; - __asm__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); - return val; -} - -static __inline__ void st_le32(uint32_t *addr, const uint32_t val) -{ - __asm__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); -} -#define USE_ASM_BYTEORDER 1 -#else -#define USE_ASM_BYTEORDER 0 -#endif - #define CVAL(buf,pos) ((unsigned int)(((const uint8_t *)(buf))[pos])) #define CVAL_NC(buf,pos) (((uint8_t *)(buf))[pos]) /* Non-const version of CVAL */ #define PVAL(buf,pos) (CVAL(buf,pos)) #define SCVAL(buf,pos,val) (CVAL_NC(buf,pos) = (val)) -#if USE_ASM_BYTEORDER - -#define _PTRPOS(buf,pos) (((const uint8_t *)(buf))+(pos)) -#define SVAL(buf,pos) ld_le16((const uint16_t *)_PTRPOS(buf,pos)) -#define IVAL(buf,pos) ld_le32((const uint32_t *)_PTRPOS(buf,pos)) -#define SSVAL(buf,pos,val) st_le16((uint16_t *)_PTRPOS(buf,pos), val) -#define SIVAL(buf,pos,val) st_le32((uint32_t *)_PTRPOS(buf,pos), val) -#define SVALS(buf,pos) ((int16_t)SVAL(buf,pos)) -#define IVALS(buf,pos) ((int32_t)IVAL(buf,pos)) -#define SSVALS(buf,pos,val) SSVAL((buf),(pos),((int16_t)(val))) -#define SIVALS(buf,pos,val) SIVAL((buf),(pos),((int32_t)(val))) - -#else /* not USE_ASM_BYTEORDER */ - #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16) #define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(uint8_t)((val)&0xFF),CVAL_NC(buf,pos+1)=(uint8_t)((val)>>8)) @@ -153,8 +104,6 @@ static __inline__ void st_le32(uint32_t *addr, const uint32_t val) #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16_t)(val))) #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32_t)(val))) -#endif /* not USE_ASM_BYTEORDER */ - /* 64 bit macros */ #define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32)) #define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))