Merge "Implement optimized __swap16md and __swap32md."
This commit is contained in:
@@ -57,7 +57,8 @@ libportable_arch_src_files += \
|
|||||||
arch-mips/timer.c \
|
arch-mips/timer.c \
|
||||||
arch-mips/timerfd.c \
|
arch-mips/timerfd.c \
|
||||||
arch-mips/waitpid.c \
|
arch-mips/waitpid.c \
|
||||||
arch-mips/fenv.c
|
arch-mips/fenv.c \
|
||||||
|
arch-mips/md_swap.c
|
||||||
|
|
||||||
libportable_arch_src_files += \
|
libportable_arch_src_files += \
|
||||||
arch-mips/_setjmp.S \
|
arch-mips/_setjmp.S \
|
||||||
@@ -69,7 +70,8 @@ endif
|
|||||||
ifeq ($(TARGET_ARCH),arm)
|
ifeq ($(TARGET_ARCH),arm)
|
||||||
libportable_arch_src_files += \
|
libportable_arch_src_files += \
|
||||||
arch-arm/unwind.c \
|
arch-arm/unwind.c \
|
||||||
arch-arm/fenv.c
|
arch-arm/fenv.c \
|
||||||
|
arch-arm/md_swap.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH),x86)
|
ifeq ($(TARGET_ARCH),x86)
|
||||||
@@ -79,7 +81,8 @@ libportable_arch_src_files += \
|
|||||||
arch-x86/ioctl.c \
|
arch-x86/ioctl.c \
|
||||||
arch-x86/open.c \
|
arch-x86/open.c \
|
||||||
arch-x86/stat.c \
|
arch-x86/stat.c \
|
||||||
arch-x86/fenv.c
|
arch-x86/fenv.c \
|
||||||
|
arch-x86/md_swap.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
|
|||||||
40
ndk/sources/android/libportable/arch-arm/md_swap.c
Normal file
40
ndk/sources/android/libportable/arch-arm/md_swap.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <portability.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REV and REV16 weren't available on ARM5 or ARM4.
|
||||||
|
*/
|
||||||
|
#if !defined __ARM_ARCH_5__ && !defined __ARM_ARCH_5T__ && \
|
||||||
|
!defined __ARM_ARCH_5TE__ && !defined __ARM_ARCH_5TEJ__ && \
|
||||||
|
!defined __ARM_ARCH_4T__ && !defined __ARM_ARCH_4__
|
||||||
|
|
||||||
|
uint16_t WRAP(__swap16md)(uint16_t x) {
|
||||||
|
register uint16_t _x = (x);
|
||||||
|
__asm volatile ("rev16 %0, %0" : "+l" (_x));
|
||||||
|
return _x;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t WRAP(__swap32md)(uint32_t x) {
|
||||||
|
register uint32_t _x = (x);
|
||||||
|
__asm volatile ("rev %0, %0" : "+l" (_x));
|
||||||
|
return _x;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
38
ndk/sources/android/libportable/arch-mips/md_swap.c
Normal file
38
ndk/sources/android/libportable/arch-mips/md_swap.c
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <portability.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
|
#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
|
||||||
|
|
||||||
|
uint16_t WRAP(__swap16md)(uint16_t x) {
|
||||||
|
register uint16_t _x = x;
|
||||||
|
register uint16_t _r;
|
||||||
|
__asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x));
|
||||||
|
return _r;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t WRAP(__swap32md)(uint32_t x) {
|
||||||
|
register uint32_t _x = x;
|
||||||
|
register uint32_t _r;
|
||||||
|
__asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x));
|
||||||
|
return _r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
31
ndk/sources/android/libportable/arch-x86/md_swap.c
Normal file
31
ndk/sources/android/libportable/arch-x86/md_swap.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <portability.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
uint16_t WRAP(__swap16md)(uint16_t x) {
|
||||||
|
register uint16_t _x = (x);
|
||||||
|
__asm volatile ("rorw $8, %w0" : "+r" (_x));
|
||||||
|
return _x;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t WRAP(__swap32md)(uint32_t x) {
|
||||||
|
register uint32_t _x = (x);
|
||||||
|
__asm volatile ("bswap %0" : "+r" (_x));
|
||||||
|
return _x;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user