Skip to content

Commit

Permalink
tech128's optimized sqlite3 for android
Browse files Browse the repository at this point in the history
  • Loading branch information
tech128 committed Aug 2, 2015
0 parents commit 7fd9d01
Show file tree
Hide file tree
Showing 16 changed files with 175,192 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
sqlite3
=======

tech128's optimized sqlite3 for android

Thanks to the open source community for helping me with code tidbits and ideas here and there.

Thanks to jorjin @ gitorious.

Thanks to the crystax team and anyone else I may have missed.

Was going all over the place to try and figure out how to get sqlite3 how I wanted it.
48 changes: 48 additions & 0 deletions a2_set_errno.c
@@ -0,0 +1,48 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2013 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include <errno.h>

/*
* Since Android ndk r9, __set_errno is deprecated. It is now defined
* as inline function in errno.h. The syscall assembly calls
* __set_errno, but since libc.so does not export it, the link
* fails. To workaround this, replace all occurrences of __set_errno
* with a2_set_errno and define it here.
*/
int a2_set_errno(int n)
{
errno = n;
return -1;
}
15 changes: 15 additions & 0 deletions arm-ftruncate64.S
@@ -0,0 +1,15 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>

ENTRY(ftruncate64)
mov ip, r7
ldr r7, =__NR_ftruncate64
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b a2_set_errno
END(ftruncate64)
18 changes: 18 additions & 0 deletions arm-pread64.S
@@ -0,0 +1,18 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>

ENTRY(pread64)
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}
ldmfd ip, {r4, r5, r6}
ldr r7, =__NR_pread64
swi #0
ldmfd sp!, {r4, r5, r6, r7}
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b a2_set_errno
END(pread64)
18 changes: 18 additions & 0 deletions arm-pwrite64.S
@@ -0,0 +1,18 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>

ENTRY(pwrite64)
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}
ldmfd ip, {r4, r5, r6}
ldr r7, =__NR_pwrite64
swi #0
ldmfd sp!, {r4, r5, r6, r7}
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b a2_set_errno
END(pwrite64)
43 changes: 43 additions & 0 deletions compile.sh
@@ -0,0 +1,43 @@
BASEDIR=/home/user/android_stuff
export STRIP="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-strip"
case $1 in
[1-9])
export CC="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/user/android-ndk-r10e/platforms/android-$1/arch-arm/"
export CXX="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ --sysroot=/home/user/android-ndk-r10e/platforms/android-$1/arch-arm/ -I/home/user/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include -I/home/user/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include/ -I /home/user/android-ndk-r10e/sources/cxx-stl/stlport/stlport/ "
#export LD="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-ld --sysroot=/home/user/android-ndk-r10e/platforms/android-$1/arch-arm/"
;;
[1-9][1-9])
export CC="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/user/android-ndk-r10e/platforms/android-$1/arch-arm/"
export CXX="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ --sysroot=/home/user/android-ndk-r10e/platforms/android-$1/arch-arm/ -I/home/user/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include -I/home/user/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include/ -I /home/user/android-ndk-r10e/sources/cxx-stl/stlport/stlport/ "
#export LD="/home/user/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-ld --sysroot=/home/user/android-ndk-r10e/platforms/android-$1/arch-arm/"
;;
*)
echo YOU MUST RUN THIS SCRIPT WITH THE SOURCE COMMAND\!\!
echo $"Usage: source $0 android-abi-level arm-arch{6|6-nofpu|7|7-pie}"
esac
case $2 in
6)
export ARCH_FLAGS="-marm -march=armv6 -mfloat-abi=softfp -L$BASEDIR/armv6_lib -I$BASEDIR/armv6_inc"
export ARCH_LINK="-march=armv6 -flto --gc-sections -L$BASEDIR/armv6_lib -I$BASEDIR/armv6_inc"
;;
"6-nofpu")
export ARCH_FLAGS="-marm -march=armv6 -mfloat-abi=soft -L$BASEDIR/armv6-nofpu_lib -I$BASEDIR/armv6-nofpu_inc"
export ARCH_LINK="-march=armv6 -flto --gc-sections -L$BASEDIR/armv6-nofpu_lib -I$BASEDIR/armv6-nofpu_inc"
;;
7)
export ARCH_FLAGS="-marm -march=armv7-a -mfpu=neon -mfloat-abi=hard -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -ftree-vectorize -mvectorize-with-neon-quad -ftree-vectorizer-verbose=2 -funsafe-math-optimizations -Wl,--gc-sections,-lm_hard,--no-warn-mismatch -L$BASEDIR/armv7_lib -I$BASEDIR/armv7_inc"
export ARCH_LINK="-march=armv7-a -flto --gc-sections -lm_hard --no-warn-mismatch -L$BASEDIR/armv7_lib -I$BASEDIR/armv7_inc"
;;
"7-pie")
export ARCH_FLAGS="-marm -march=armv7-a -pie -mfpu=neon -mfloat-abi=hard -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -ftree-vectorize -mvectorize-with-neon-quad -ftree-vectorizer-verbose=2 -funsafe-math-optimizations -Wl,--gc-sections,-lm_hard,--no-warn-mismatch -L$BASEDIR/armv7_lib -I$BASEDIR/armv7_inc"
export ARCH_LINK="-march=armv7-a -flto --gc-sections -lm_hard --no-warn-mismatch -L$BASEDIR/armv7-pie_lib -I$BASEDIR/armv7-pie_inc"
;;
*)
echo YOU MUST RUN THIS SCRIPT WITH THE SOURCE COMMAND\!\!
echo $"Usage: source $0 android-abi-level arm-arch{6|6-nofpu|7|7-pie}"
;;
esac
export CPPFLAGS=" ${ARCH_FLAGS} -pipe -fPIE -fomit-frame-pointer -flto -O3 -Wl,--gc-sections -ffunction-sections"
export CXXFLAGS=" ${ARCH_FLAGS} -pipe -fPIE -fomit-frame-pointer -flto -O3 -Wl,--gc-sections -ffunction-sections"
export CFLAGS=" ${ARCH_FLAGS} -pipe -fPIE -fomit-frame-pointer -flto -O3 -Wl,--gc-sections -ffunction-sections"
export LDFLAGS=" ${ARCH_LINK}"
1 change: 1 addition & 0 deletions go.sh
@@ -0,0 +1 @@
$CC $CFLAGS shell.c sqlite3.c arm-ftruncate64.S arm-pread64.S arm-pwrite64.S a2_set_errno.c -DUSE_PREAD64 -DSQLITE_ENABLE_FTS3_BACKWARDS

0 comments on commit 7fd9d01

Please sign in to comment.