Browse Source

almost compiling on android. linker error.

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
9783b971fb
  1. 19
      libtorrent/runme-android.sh
  2. 222
      src/makefile.android
  3. 380
      src/net.cpp
  4. 2
      src/netbase.cpp
  5. 27
      src/runme-android.sh
  6. 2
      src/util.cpp

19
libtorrent/runme-android.sh

@ -0,0 +1,19 @@
export PATH=/home/miguel/android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/:$PATH
export NDK=/home/miguel/android/android-ndk-r8b
export NDK_BASE=$NDK
export SYSROOT=$NDK/platforms/android-9/arch-arm
export BOOSTDIR=/home/miguel/android/Boost-for-Android/build/
#make -j2
#exit
./configure --host=arm-linux-androideabi --enable-shared=no --enable-static=yes\
CPPFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \
-fexceptions -frtti" \
LDFLAGS="-Wl,-rpath-link=$SYSROOT/usr/lib/ -L$SYSROOT/usr/lib/ -L$BOOSTDIR/lib \
$BOOSTDIR/lib/libboost_system-gcc-mt-1_49.a $BOOSTDIR/lib/libboost_thread-gcc-mt-1_49.a \
$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a" \
LIBS="-lc" CFLAGS="-nostdlib" --prefix="$SYSROOT/usr" \
--with-boost=$BOOSTDIR --with-boost-libdir=$BOOSTDIR/lib && make -j2

222
src/makefile.android

@ -0,0 +1,222 @@
# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# :=0 --> UPnP support turned off by default at runtime
# :=1 --> UPnP support turned on by default at runtime
# :=- --> No UPnP support - miniupnp not required
USE_UPNP:=-
# :=1 --> Enable IPv6 support
# :=0 --> Disable IPv6 support
USE_IPV6:=0
LINK:=$(CXX)
DEFS=-DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
LMODE = static
LMODE2 = static
ifdef STATIC
LMODE = static
ifeq (${STATIC}, all)
LMODE2 = static
endif
else
TESTDEFS += -DBOOST_TEST_DYN_LINK
endif
# for boost 1.37, add -mt to the boost libraries
LIBS += \
-Wl,-B$(LMODE) \
-l boost_system$(BOOST_LIB_SUFFIX) \
-l boost_filesystem$(BOOST_LIB_SUFFIX) \
-l boost_program_options$(BOOST_LIB_SUFFIX) \
-l boost_thread$(BOOST_LIB_SUFFIX) \
-l db_cxx$(BDB_LIB_SUFFIX) \
-l ssl \
-l crypto \
-l rt
TESTLIBS += \
-Wl,-B$(LMODE) \
-l boost_unit_test_framework$(BOOST_LIB_SUFFIX)
ifndef USE_UPNP
override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
LIBS += -l miniupnpc
DEFS += -DUSE_UPNP=$(USE_UPNP)
endif
ifneq (${USE_IPV6}, -)
DEFS += -DUSE_IPV6=$(USE_IPV6)
endif
LIBS+= \
-Wl,-B$(LMODE2) \
-l z \
-l dl \
-l pthread
# Hardening
# Make some classes of vulnerabilities unexploitable in case one is discovered.
#
# This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
# -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
# see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
HARDENING=-fno-stack-protector
# Stack Canaries
# Put numbers at the beginning of each stack frame and check that they are the same.
# If a stack buffer if overflowed, it writes over the canary number and then on return
# when that number is checked, it won't be the same and the program will exit with
# a "Stack smashing detected" error instead of being exploited.
HARDENING+=-fstack-protector-all -Wstack-protector
# Make some important things such as the global offset table read only as soon as
# the dynamic linker is finished building it. This will prevent overwriting of addresses
# which would later be jumped to.
LDHARDENING+=-Wl,-z,relro -Wl,-z,now
# Build position independent code to take advantage of Address Space Layout Randomization
# offered by some kernels.
# see doc/build-unix.txt for more information.
ifdef PIE
HARDENING+=-fPIE
LDHARDENING+=-pie
endif
# -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
# the source such overflowing a statically defined buffer.
HARDENING+=-D_FORTIFY_SOURCE=2
#
DEBUGFLAGS=-g
# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
$(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
xLDFLAGS=$(LDHARDENING) $(LDFLAGS)
OBJS= \
leveldb/libleveldb.a \
../libtorrent/src/.libs/libtorrent-rasterbar.a \
obj/alert.o \
obj/version.o \
obj/checkpoints.o \
obj/netbase.o \
obj/addrman.o \
obj/crypter.o \
obj/key.o \
obj/db.o \
obj/init.o \
obj/bitcoind.o \
obj/keystore.o \
obj/core.o \
obj/main.o \
obj/net.o \
obj/protocol.o \
obj/bitcoinrpc.o \
obj/rpcdump.o \
obj/rpcnet.o \
obj/rpcmining.o \
obj/rpcwallet.o \
obj/rpcblockchain.o \
obj/rpcrawtransaction.o \
obj/script.o \
obj/sync.o \
obj/util.o \
obj/wallet.o \
obj/walletdb.o \
obj/hash.o \
obj/bloom.o \
obj/noui.o \
obj/leveldb.o \
obj/txdb.o \
obj/chainparams.o \
obj/twister.o \
obj/twister_utils.o
all: twisterd
test check: test_bitcoin FORCE
./test_bitcoin
#
# LevelDB support
#
MAKEOVERRIDES =
LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
leveldb/libleveldb.a:
@echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libleveldb.a libmemenv.a && cd ..
#
# libtorrent hack
#
MAKEOVERRIDES =
LIBS += $(CURDIR)/../libtorrent/src/.libs/libtorrent-rasterbar.a
DEFS += $(addprefix -I,$(CURDIR)/../libtorrent/include)
DEFS += -DTORRENT_DEBUG
DEFS += -DBOOST_ASIO_SEPARATE_COMPILATION
#DEFS += -DBOOST_ASIO_DYN_LINK
../libtorrent/src/.libs/libtorrent-rasterbar.a:
@echo "Building libtorrent ..." && cd ../libtorrent && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" && cd ../src
# auto-generated dependencies:
-include obj/*.P
-include obj-test/*.P
obj/build.h: FORCE
/bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO
obj/%.o: %.cpp
$(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
twisterd: $(OBJS:obj/%=obj/%)
$(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
obj-test/%.o: test/%.cpp
$(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o obj/bitcoind.o,$(OBJS:obj/%=obj/%))
$(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ $(TESTLIBS) $(xLDFLAGS) $(LIBS)
clean:
-rm -f twisterd test_bitcoin
-rm -f obj/*.o
-rm -f obj-test/*.o
-rm -f obj/*.P
-rm -f obj-test/*.P
-rm -f obj/build.h
-cd leveldb && $(MAKE) clean || true
FORCE:

380
src/net.cpp

@ -1638,173 +1638,259 @@ bool BindListenPort(const CService &addrBind, string& strError)
} }
#ifdef __ANDROID__ #ifdef __ANDROID__
#include <sys/socket.h>
#include <stdio.h>
#include <sys/socket.h>
// Implementation of getifaddrs for Android.
// Fills out a list of ifaddr structs (see below) which contain information
// about every network interface available on the host.
// See 'man getifaddrs' on Linux or OS X (nb: it is not a POSIX function).
struct ifaddrs { struct ifaddrs {
struct ifaddrs *ifa_next; struct ifaddrs* ifa_next;
char *ifa_name; char* ifa_name;
unsigned int ifa_flags; unsigned int ifa_flags;
struct sockaddr *ifa_addr; struct sockaddr* ifa_addr;
struct sockaddr *ifa_netmask; struct sockaddr* ifa_netmask;
union { // Real ifaddrs has broadcast, point to point and data members.
struct sockaddr *ifu_broadaddr; // We don't need them (yet?).
struct sockaddr *ifu_dstaddr;
} ifa_ifu;
#define ifa_broadaddr ifa_ifu.ifu_broadaddr
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
void *ifa_data;
}; };
extern int getifaddrs(struct ifaddrs **ifap); int getifaddrs(struct ifaddrs** result);
extern void freeifaddrs(struct ifaddrs *ifa); void freeifaddrs(struct ifaddrs* addrs);
/*
/* external/dhcpcd/ifaddrs.c * libjingle
** * Copyright 2012, Google Inc.
** Copyright 2011, The Android Open Source Project *
** * Redistribution and use in source and binary forms, with or without
** Licensed under the Apache License, Version 2.0 (the "License");. * modification, are permitted provided that the following conditions are met:
** you may not use this file except in compliance with the License.. *
** You may obtain a copy of the License at. * 1. Redistributions of source code must retain the above copyright notice,
** * this list of conditions and the following disclaimer.
** http://www.apache.org/licenses/LICENSE-2.0. * 2. Redistributions in binary form must reproduce the above copyright notice,
** * this list of conditions and the following disclaimer in the documentation
** Unless required by applicable law or agreed to in writing, software. * and/or other materials provided with the distribution.
** distributed under the License is distributed on an "AS IS" BASIS,. * 3. The name of the author may not be used to endorse or promote products
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.. * derived from this software without specific prior written permission.
** See the License for the specific language governing permissions and. *
** limitations under the License. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
*/ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
#include <arpa/inet.h> * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#include <sys/socket.h> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#include "ifaddrs.h" * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#include <stdio.h> * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <sys/socket.h>
#include <netinet/ether.h> #include <sys/utsname.h>
#include <netdb.h> #include <sys/ioctl.h>
#include <linux/if_packet.h> #include <netinet/in.h>
#include <netinet/if_ether.h> #include <net/if.h>
#include <linux/if_arp.h> #include <unistd.h>
#include <netutils/ifc.h> #include <errno.h>
#include <linux/netlink.h>
struct ifaddrs *get_interface(const char *name, sa_family_t family) #include <linux/rtnetlink.h>
{
unsigned addr, mask, flags;
struct ifaddrs *ifa;
struct sockaddr_in *saddr = NULL;
struct sockaddr_in *smask = NULL;
struct sockaddr_ll *hwaddr = NULL;
unsigned char hwbuf[ETH_ALEN];
if(ifc_get_info(name, &addr, &mask, &flags))
return NULL;
if ((family == AF_INET) && (addr == 0)) struct netlinkrequest {
return NULL; nlmsghdr header;
ifaddrmsg msg;
};
ifa = malloc(sizeof(struct ifaddrs)); namespace {
if (!ifa) const int kMaxReadSize = 4096;
return NULL; };
memset(ifa, 0, sizeof(struct ifaddrs));
ifa->ifa_name = malloc(strlen(name)+1); int set_ifname(struct ifaddrs* ifaddr, int interface) {
if (!ifa->ifa_name) { char buf[IFNAMSIZ] = {0};
free(ifa); char* name = if_indextoname(interface, buf);
return NULL; if (name == NULL) {
} return -1;
strcpy(ifa->ifa_name, name); }
ifa->ifa_flags = flags; ifaddr->ifa_name = new char[strlen(name) + 1];
strncpy(ifaddr->ifa_name, name, strlen(name) + 1);
if (family == AF_INET) { return 0;
saddr = malloc(sizeof(struct sockaddr_in)); }
if (saddr) {
saddr->sin_addr.s_addr = addr;
saddr->sin_family = family;
}
ifa->ifa_addr = (struct sockaddr *)saddr;
if (mask != 0) { int set_flags(struct ifaddrs* ifaddr) {
smask = malloc(sizeof(struct sockaddr_in)); int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (smask) { if (fd == -1) {
smask->sin_addr.s_addr = mask; return -1;
smask->sin_family = family; }
} ifreq ifr;
} memset(&ifr, 0, sizeof(ifr));
ifa->ifa_netmask = (struct sockaddr *)smask; strncpy(ifr.ifr_name, ifaddr->ifa_name, IFNAMSIZ - 1);
} else if (family == AF_PACKET) { int rc = ioctl(fd, SIOCGIFFLAGS, &ifr);
if (!ifc_get_hwaddr(name, hwbuf)) { close(fd);
hwaddr = malloc(sizeof(struct sockaddr_ll)); if (rc == -1) {
if (hwaddr) { return -1;
memset(hwaddr, 0, sizeof(struct sockaddr_ll)); }
hwaddr->sll_family = family; ifaddr->ifa_flags = ifr.ifr_flags;
/* hwaddr->sll_protocol = ETHERTYPE_IP; */ return 0;
hwaddr->sll_hatype = ARPHRD_ETHER;
hwaddr->sll_halen = ETH_ALEN;
memcpy(hwaddr->sll_addr, hwbuf, ETH_ALEN);
}
}
ifa->ifa_addr = (struct sockaddr *)hwaddr;
ifa->ifa_netmask = (struct sockaddr *)smask;
}
return ifa;
} }
int getifaddrs(struct ifaddrs **ifap) int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data,
{ size_t len) {
DIR *d; if (msg->ifa_family == AF_INET) {
struct dirent *de; sockaddr_in* sa = new sockaddr_in;
struct ifaddrs *ifa; sa->sin_family = AF_INET;
struct ifaddrs *ifah = NULL; memcpy(&sa->sin_addr, data, len);
ifaddr->ifa_addr = reinterpret_cast<sockaddr*>(sa);
} else if (msg->ifa_family == AF_INET6) {
sockaddr_in6* sa = new sockaddr_in6;
sa->sin6_family = AF_INET6;
sa->sin6_scope_id = msg->ifa_index;
memcpy(&sa->sin6_addr, data, len);
ifaddr->ifa_addr = reinterpret_cast<sockaddr*>(sa);
} else {
return -1;
}
return 0;
}
if (!ifap) int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) {
return -1; char* prefix = NULL;
*ifap = NULL; if (family == AF_INET) {
sockaddr_in* mask = new sockaddr_in;
mask->sin_family = AF_INET;
memset(&mask->sin_addr, 0, sizeof(in_addr));
ifaddr->ifa_netmask = reinterpret_cast<sockaddr*>(mask);
if (prefixlen > 32) {
prefixlen = 32;
}
prefix = reinterpret_cast<char*>(&mask->sin_addr);
} else if (family == AF_INET6) {
sockaddr_in6* mask = new sockaddr_in6;
mask->sin6_family = AF_INET6;
memset(&mask->sin6_addr, 0, sizeof(in6_addr));
ifaddr->ifa_netmask = reinterpret_cast<sockaddr*>(mask);
if (prefixlen > 128) {
prefixlen = 128;
}
prefix = reinterpret_cast<char*>(&mask->sin6_addr);
} else {
return -1;
}
for (int i = 0; i < (prefixlen / 8); i++) {
*prefix++ = 0xFF;
}
char remainder = 0xff;
remainder <<= (8 - prefixlen % 8);
*prefix = remainder;
return 0;
}
if (ifc_init()) int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes,
return -1; size_t len) {
if (set_ifname(ifaddr, msg->ifa_index) != 0) {
return -1;
}
if (set_flags(ifaddr) != 0) {
return -1;
}
if (set_addresses(ifaddr, msg, bytes, len) != 0) {
return -1;
}
if (make_prefixes(ifaddr, msg->ifa_family, msg->ifa_prefixlen) != 0) {
return -1;
}
return 0;
}
d = opendir("/sys/class/net"); int getifaddrs(struct ifaddrs** result) {
if (d == 0) int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
return -1; if (fd < 0) {
while ((de = readdir(d))) { return -1;
if (de->d_name[0] == '.') }
continue;
ifa = get_interface(de->d_name, AF_INET); netlinkrequest ifaddr_request;
if (ifa != NULL) { memset(&ifaddr_request, 0, sizeof(ifaddr_request));
ifa->ifa_next = ifah; ifaddr_request.header.nlmsg_flags = NLM_F_ROOT | NLM_F_REQUEST;
ifah = ifa; ifaddr_request.header.nlmsg_type = RTM_GETADDR;
} ifaddr_request.header.nlmsg_len = NLMSG_LENGTH(sizeof(ifaddrmsg));
ifa = get_interface(de->d_name, AF_PACKET);
if (ifa != NULL) { ssize_t count = send(fd, &ifaddr_request, ifaddr_request.header.nlmsg_len, 0);
ifa->ifa_next = ifah; if (static_cast<size_t>(count) != ifaddr_request.header.nlmsg_len) {
ifah = ifa; close(fd);
return -1;
}
struct ifaddrs* start = NULL;
struct ifaddrs* current = NULL;
char buf[kMaxReadSize];
ssize_t amount_read = recv(fd, &buf, kMaxReadSize, 0);
while (amount_read > 0) {
nlmsghdr* header = reinterpret_cast<nlmsghdr*>(&buf[0]);
size_t header_size = static_cast<size_t>(amount_read);
for ( ; NLMSG_OK(header, header_size);
header = NLMSG_NEXT(header, header_size)) {
switch (header->nlmsg_type) {
case NLMSG_DONE:
// Success. Return.
*result = start;
close(fd);
return 0;
case NLMSG_ERROR:
close(fd);
freeifaddrs(start);
return -1;
case RTM_NEWADDR: {
ifaddrmsg* address_msg =
reinterpret_cast<ifaddrmsg*>(NLMSG_DATA(header));
rtattr* rta = IFA_RTA(address_msg);
ssize_t payload_len = IFA_PAYLOAD(header);
while (RTA_OK(rta, payload_len)) {
if (rta->rta_type == IFA_ADDRESS) {
int family = address_msg->ifa_family;
if (family == AF_INET || family == AF_INET6) {
ifaddrs* newest = new ifaddrs;
memset(newest, 0, sizeof(ifaddrs));
if (current) {
current->ifa_next = newest;
} else {
start = newest;
}
if (populate_ifaddrs(newest, address_msg, RTA_DATA(rta),
RTA_PAYLOAD(rta)) != 0) {
freeifaddrs(start);
*result = NULL;
return -1;
}
current = newest;
}
}
rta = RTA_NEXT(rta, payload_len);
}
break;
} }
}
} }
*ifap = ifah; amount_read = recv(fd, &buf, kMaxReadSize, 0);
closedir(d); }
ifc_close(); close(fd);
return 0; freeifaddrs(start);
return -1;
} }
void freeifaddrs(struct ifaddrs *ifa) void freeifaddrs(struct ifaddrs* addrs) {
{ struct ifaddrs* last = NULL;
struct ifaddrs *ifp; struct ifaddrs* cursor = addrs;
while (cursor) {
while (ifa) { delete[] cursor->ifa_name;
ifp = ifa; delete cursor->ifa_addr;
free(ifp->ifa_name); delete cursor->ifa_netmask;
if (ifp->ifa_addr) last = cursor;
free(ifp->ifa_addr); cursor = cursor->ifa_next;
if (ifp->ifa_netmask) delete last;
free(ifp->ifa_netmask); }
ifa = ifa->ifa_next;
free(ifp);
}
} }
#endif #endif
void static Discover() void static Discover()

2
src/netbase.cpp

@ -9,7 +9,7 @@
#include "hash.h" #include "hash.h"
#ifndef WIN32 #ifndef WIN32
#include <sys/fcntl.h> #include <fcntl.h>
#endif #endif
#include <boost/algorithm/string/case_conv.hpp> // for to_lower() #include <boost/algorithm/string/case_conv.hpp> // for to_lower()

27
src/runme-android.sh

@ -0,0 +1,27 @@
export PATH=/home/miguel/android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/:$PATH
export NDK=/home/miguel/android/android-ndk-r8b
export NDK_BASE=$NDK
export SYSROOT=$NDK/platforms/android-9/arch-arm
export BOOSTDIR=/home/miguel/android/Boost-for-Android/build/
export TARGET_OS=OS_ANDROID_CROSSCOMPILE
export CXX=arm-linux-androideabi-gcc
export CXXFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include/boost-1_49 \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \
-fexceptions -frtti -DHAVE_CXX_STDHEADERS -DANDROID"
make -f makefile.android -j2
#make -j2
#exit
#./configure --host=arm-linux-androideabi --enable-shared=no --enable-static=yes\
# CPPFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include \
# -I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \
# -I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \
# -fexceptions -frtti" \
# LDFLAGS="-Wl,-rpath-link=$SYSROOT/usr/lib/ -L$SYSROOT/usr/lib/ -L$BOOSTDIR/lib \
# $BOOSTDIR/lib/libboost_system-gcc-mt-1_49.a $BOOSTDIR/lib/libboost_thread-gcc-mt-1_49.a \
# $NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a" \
# LIBS="-lc" CFLAGS="-nostdlib" --prefix="$SYSROOT/usr" \
# --with-boost=$BOOSTDIR --with-boost-libdir=$BOOSTDIR/lib && make -j2

2
src/util.cpp

@ -1221,7 +1221,7 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
fcntl(fileno(file), F_PREALLOCATE, &fst); fcntl(fileno(file), F_PREALLOCATE, &fst);
} }
ftruncate(fileno(file), fst.fst_length); ftruncate(fileno(file), fst.fst_length);
#elif defined(__linux__) #elif defined(__linux__) && !defined(__ANDROID__)
// Version using posix_fallocate // Version using posix_fallocate
off_t nEndPos = (off_t)offset + length; off_t nEndPos = (off_t)offset + length;
posix_fallocate(fileno(file), 0, nEndPos); posix_fallocate(fileno(file), 0, nEndPos);

Loading…
Cancel
Save