Skip to content

Commit

Permalink
Merge pull request #3 from RangelReale/mobilefixes
Browse files Browse the repository at this point in the history
Android and iOS fixes
  • Loading branch information
aleks-f committed Dec 3, 2012
2 parents 49a0b41 + 8101b85 commit 6d2881e
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")
add_definitions( -D_BSD_SOURCE -library=stlport4)
endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")

# iOS
if (IOS)
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES )
endif(IOS)

IF (ENABLE_TESTS)
add_subdirectory(CppUnit)
ENDIF ()
Expand Down
2 changes: 2 additions & 0 deletions Net/include/Poco/Net/ICMPv4PacketImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ class Net_API ICMPv4PacketImpl : public ICMPPacketImpl
};

// compile-time shield against misalignment
#ifndef POCO_ANDROID
poco_static_assert (offsetof(Header, code) == 0x01);
poco_static_assert (offsetof(Header, checksum) == 0x02);
poco_static_assert (offsetof(Header, id) == 0x04);
poco_static_assert (offsetof(Header, seq) == 0x06);
#endif

enum MessageType
{
Expand Down
10 changes: 10 additions & 0 deletions Net/include/Poco/Net/SocketDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
#ifndef Net_SocketDefs_INCLUDED
#define Net_SocketDefs_INCLUDED

#ifndef __THROW
# ifndef __GNUC_PREREQ
# define __GNUC_PREREQ(maj, min) (0)
# endif
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
# else
# define __THROW
# endif
#endif

#if defined(POCO_OS_FAMILY_WINDOWS)
#include "Poco/UnWindows.h"
Expand Down
10 changes: 10 additions & 0 deletions Net/src/NetworkInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,9 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)


#include <sys/types.h>
#ifndef POCO_ANDROID // Android doesn't have <ifaddrs.h>
#include <ifaddrs.h>
#endif
#include <linux/if.h>
#include <linux/if_packet.h>
#include <net/if_arp.h>
Expand Down Expand Up @@ -1306,6 +1308,8 @@ static NetworkInterface::Type fromNative(unsigned arphrd)
}
}

#ifndef POCO_ANDROID

void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
{
struct sockaddr_ll* sdl = (struct sockaddr_ll*) iface->ifa_addr;
Expand All @@ -1317,11 +1321,14 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
impl.setType(fromNative(sdl->sll_hatype));
}

#endif

}


NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
{
#ifndef POCO_ANDROID
FastMutex::ScopedLock lock(_mutex);
Map result;
unsigned ifIndex = 0;
Expand Down Expand Up @@ -1420,6 +1427,9 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
if (ifaces) freeifaddrs(ifaces);

return result;
#else
throw Poco::NotImplementedException("Not implemented in Android");
#endif
}


Expand Down
3 changes: 3 additions & 0 deletions Util/include/Poco/Util/ServerApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class Util_API ServerApplication: public Application
void handlePidFile(const std::string& name, const std::string& value);
bool isDaemon(int argc, char** argv);
void beDaemon();
#if defined(POCO_ANDROID)
static Poco::Event _terminate;
#endif
#elif defined(POCO_OS_FAMILY_WINDOWS)
#if !defined(_WIN32_WCE)
enum Action
Expand Down
8 changes: 6 additions & 2 deletions Util/src/ServerApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SERVICE_STATUS ServerApplication::_serviceStatus;
SERVICE_STATUS_HANDLE ServerApplication::_serviceStatusHandle = 0;
#endif
#endif
#if defined(POCO_VXWORKS)
#if defined(POCO_VXWORKS) || defined(POCO_ANDROID)
Poco::Event ServerApplication::_terminate;
#endif

Expand Down Expand Up @@ -122,7 +122,7 @@ void ServerApplication::terminate()
{
#if defined(POCO_OS_FAMILY_WINDOWS)
_terminate.set();
#elif defined(POCO_VXWORKS)
#elif defined(POCO_VXWORKS) || defined(POCO_ANDROID)
_terminate.set();
#else
Poco::Process::requestTermination(Process::id());
Expand Down Expand Up @@ -590,6 +590,7 @@ void ServerApplication::defineOptions(OptionSet& options)
//
void ServerApplication::waitForTerminationRequest()
{
#ifndef POCO_ANDROID
sigset_t sset;
sigemptyset(&sset);
if (!std::getenv("POCO_ENABLE_DEBUGGER"))
Expand All @@ -601,6 +602,9 @@ void ServerApplication::waitForTerminationRequest()
sigprocmask(SIG_BLOCK, &sset, NULL);
int sig;
sigwait(&sset, &sig);
#else // POCO_ANDROID
_terminate.wait();
#endif
}


Expand Down
73 changes: 73 additions & 0 deletions build/config/OpenPandora
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# $Id: //poco/1.4/build/config/Angstrom#2 $
#
# Angstrom
#
# Make settings for Open Embedded/Angstrom
#

#
# General Settings
#
LINKMODE ?= SHARED
POCO_TARGET_OSNAME = Linux
POCO_TARGET_OSARCH = armv5te
TOOL = arm-none-linux-gnueabi

#
# Define Tools
#
CC = $(TOOL)-gcc
CXX = $(TOOL)-g++
LINK = $(CXX)
STRIP = $(TOOL)-strip
LIB = $(TOOL)-ar -cr
RANLIB = $(TOOL)-ranlib
SHLIB = $(CXX) -shared -Wl,-soname,$(notdir $@) -o $@
SHLIBLN = $(POCO_BASE)/build/script/shlibln
DEP = $(POCO_BASE)/build/script/makedepend.gcc
SHELL = sh
RM = rm -rf
CP = cp
MKDIR = mkdir -p

#
# Extension for Shared Libraries
#
SHAREDLIBEXT = .so.$(target_version)
SHAREDLIBLINKEXT = .so

#
# Compiler and Linker Flags
#
CFLAGS = -Isrc
CFLAGS32 =
CFLAGS64 =
CXXFLAGS =
CXXFLAGS32 =
CXXFLAGS64 =
LINKFLAGS =
LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
STATICOPT_LINK = -static
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK = -Wl,-rpath,$(LIBPATH)
DEBUGOPT_CC = -g -D_DEBUG
DEBUGOPT_CXX = -g -D_DEBUG
DEBUGOPT_LINK = -g
RELEASEOPT_CC = -O3 -DNDEBUG
RELEASEOPT_CXX = -O2 -DNDEBUG
RELEASEOPT_LINK = -O2

#
# System Specific Flags
#
SYSFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE -DPOCO_NO_FPENVIRONMENT

#
# System Specific Libraries
#
SYSLIBS = -lpthread -ldl -lrt
2 changes: 1 addition & 1 deletion build/config/iPhone
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ IPHONE_SDK_VERSION_MIN ?= $(patsubst %.sdk,%,$(patsubst $(IPHONE_SDK_ROOT_DIR)%,

POCO_TARGET_OSNAME ?= $(IPHONE_SDK)
POCO_TARGET_OSARCH ?= armv6
TOOL_PREFIX ?= /Developer/Platforms/$(IPHONE_SDK).platform/Developer/usr/bin
TOOL_PREFIX ?= $(shell xcode-select -print-path)/Platforms/$(IPHONE_SDK).platform/Developer/usr/bin
OSFLAGS ?= -arch $(POCO_TARGET_OSARCH) -isysroot $(IPHONE_SDK_BASE) -mthumb -miphoneos-version-min=$(IPHONE_SDK_VERSION_MIN)

#
Expand Down

0 comments on commit 6d2881e

Please sign in to comment.