From d6fcca806e6b71cbf961aae0203e3ae16554a7c0 Mon Sep 17 00:00:00 2001 From: Rangel Reale Date: Fri, 20 Mar 2015 11:28:49 -0300 Subject: [PATCH] * NaCl support --- Foundation/include/Poco/Platform.h | 4 ++ Foundation/src/NamedEvent_UNIX.cpp | 2 +- Foundation/src/NamedMutex_UNIX.cpp | 2 +- Foundation/src/Path_UNIX.cpp | 3 +- Util/include/Poco/Util/ServerApplication.h | 2 +- Util/src/Application.cpp | 2 +- Util/src/ServerApplication.cpp | 8 +-- build/config/NaCl-x86 | 74 ++++++++++++++++++++++ build/config/NaCl-x86_64 | 74 ++++++++++++++++++++++ 9 files changed, 162 insertions(+), 9 deletions(-) create mode 100644 build/config/NaCl-x86 create mode 100644 build/config/NaCl-x86_64 diff --git a/Foundation/include/Poco/Platform.h b/Foundation/include/Poco/Platform.h index 4890d7a5a..937d55b6b 100644 --- a/Foundation/include/Poco/Platform.h +++ b/Foundation/include/Poco/Platform.h @@ -39,6 +39,7 @@ #define POCO_OS_QNX 0x000b #define POCO_OS_VXWORKS 0x000c #define POCO_OS_CYGWIN 0x000d +#define POCO_OS_NACL 0x000e #define POCO_OS_UNKNOWN_UNIX 0x00ff #define POCO_OS_WINDOWS_NT 0x1001 #define POCO_OS_WINDOWS_CE 0x1011 @@ -58,6 +59,9 @@ #elif defined(__digital__) || defined(__osf__) #define POCO_OS_FAMILY_UNIX 1 #define POCO_OS POCO_OS_TRU64 +#elif defined(__NACL__) + #define POCO_OS_FAMILY_UNIX 1 + #define POCO_OS POCO_OS_NACL #elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__) || defined(EMSCRIPTEN) #define POCO_OS_FAMILY_UNIX 1 #define POCO_OS POCO_OS_LINUX diff --git a/Foundation/src/NamedEvent_UNIX.cpp b/Foundation/src/NamedEvent_UNIX.cpp index 5d78401bb..64fb55bac 100644 --- a/Foundation/src/NamedEvent_UNIX.cpp +++ b/Foundation/src/NamedEvent_UNIX.cpp @@ -33,7 +33,7 @@ namespace Poco { -#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD) +#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD) || (POCO_OS == POCO_OS_NACL) union semun { int val; diff --git a/Foundation/src/NamedMutex_UNIX.cpp b/Foundation/src/NamedMutex_UNIX.cpp index 13677569f..04a6f463f 100644 --- a/Foundation/src/NamedMutex_UNIX.cpp +++ b/Foundation/src/NamedMutex_UNIX.cpp @@ -33,7 +33,7 @@ namespace Poco { -#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD) +#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD) || (POCO_OS == POCO_OS_NACL) union semun { int val; diff --git a/Foundation/src/Path_UNIX.cpp b/Foundation/src/Path_UNIX.cpp index a5b0c2782..50d7cda43 100644 --- a/Foundation/src/Path_UNIX.cpp +++ b/Foundation/src/Path_UNIX.cpp @@ -67,7 +67,8 @@ std::string PathImpl::homeImpl() if (pwd) path = pwd->pw_dir; else - path = EnvironmentImpl::getImpl("HOME"); + if (EnvironmentImpl::hasImpl("HOME")) + path = EnvironmentImpl::getImpl("HOME"); } std::string::size_type n = path.size(); if (n > 0 && path[n - 1] != '/') path.append("/"); diff --git a/Util/include/Poco/Util/ServerApplication.h b/Util/include/Poco/Util/ServerApplication.h index f6bcdb261..d02c3e5cb 100644 --- a/Util/include/Poco/Util/ServerApplication.h +++ b/Util/include/Poco/Util/ServerApplication.h @@ -186,7 +186,7 @@ private: void handlePidFile(const std::string& name, const std::string& value); bool isDaemon(int argc, char** argv); void beDaemon(); -#if defined(POCO_ANDROID) +#if defined(POCO_ANDROID) || defined(__NACL__) static Poco::Event _terminate; #endif #elif defined(POCO_OS_FAMILY_WINDOWS) diff --git a/Util/src/Application.cpp b/Util/src/Application.cpp index c6765e116..731c84da8 100644 --- a/Util/src/Application.cpp +++ b/Util/src/Application.cpp @@ -438,7 +438,7 @@ void Application::getApplicationPath(Poco::Path& appPath) const } else { - if (!Path::find(Environment::get("PATH"), _command, appPath)) + if (!Environment::has("PATH") || !Path::find(Environment::get("PATH"), _command, appPath)) appPath = Path(_workingDirAtLaunch, _command); appPath.makeAbsolute(); } diff --git a/Util/src/ServerApplication.cpp b/Util/src/ServerApplication.cpp index 8a2fa2ebe..3070b0477 100644 --- a/Util/src/ServerApplication.cpp +++ b/Util/src/ServerApplication.cpp @@ -64,7 +64,7 @@ SERVICE_STATUS ServerApplication::_serviceStatus; SERVICE_STATUS_HANDLE ServerApplication::_serviceStatusHandle = 0; #endif #endif -#if defined(POCO_VXWORKS) || defined(POCO_ANDROID) +#if defined(POCO_VXWORKS) || defined(POCO_ANDROID) || defined(__NACL__) Poco::Event ServerApplication::_terminate; #endif @@ -102,7 +102,7 @@ void ServerApplication::terminate() { #if defined(POCO_OS_FAMILY_WINDOWS) _terminate.set(); -#elif defined(POCO_VXWORKS) || defined(POCO_ANDROID) +#elif defined(POCO_VXWORKS) || defined(POCO_ANDROID) || defined(__NACL__) _terminate.set(); #else Poco::Process::requestTermination(Process::id()); @@ -592,7 +592,7 @@ void ServerApplication::defineOptions(OptionSet& options) // void ServerApplication::waitForTerminationRequest() { -#ifndef POCO_ANDROID +#if !defined(POCO_ANDROID) && !defined(__NACL__) sigset_t sset; sigemptyset(&sset); if (!std::getenv("POCO_ENABLE_DEBUGGER")) @@ -604,7 +604,7 @@ void ServerApplication::waitForTerminationRequest() sigprocmask(SIG_BLOCK, &sset, NULL); int sig; sigwait(&sset, &sig); -#else // POCO_ANDROID +#else // POCO_ANDROID || __NACL__ _terminate.wait(); #endif } diff --git a/build/config/NaCl-x86 b/build/config/NaCl-x86 new file mode 100644 index 000000000..8430c0e46 --- /dev/null +++ b/build/config/NaCl-x86 @@ -0,0 +1,74 @@ +# +# $Id: //poco/1.4/build/config/Linux#2 $ +# +# Linux +# +# Make settings for Linux 2.6/gcc 3.3 +# +# + +# +# General Settings +# +LINKMODE ?= SHARED +POCO_TARGET_OSNAME = NaCl +POCO_TARGET_OSARCH = i686 +CROSS_COMPILE = i686-nacl- + +# +# Define Tools +# +CC = ${CROSS_COMPILE}gcc +CXX = ${CROSS_COMPILE}g++ +LINK = $(CXX) +LIB = ${AR} -cr +RANLIB = ${CROSS_COMPILE}ranlib +SHLIB = $(CXX) -shared -Wl,-soname,$(notdir $@) -o $@ +SHLIBLN = $(POCO_BASE)/build/script/shlibln +STRIP = ${CROSS_COMPILE}strip +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 = +CFLAGS32 = +CFLAGS64 = +CXXFLAGS = -Wall -Wno-sign-compare +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 = -O2 -DNDEBUG +RELEASEOPT_CXX = -O2 -DNDEBUG +RELEASEOPT_LINK = -O2 + +# +# System Specific Flags +# +SYSFLAGS = -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -D__NACL__ + +# +# System Specific Libraries +# +SYSLIBS = -lpthread -ldl -lrt diff --git a/build/config/NaCl-x86_64 b/build/config/NaCl-x86_64 new file mode 100644 index 000000000..9aa8b50da --- /dev/null +++ b/build/config/NaCl-x86_64 @@ -0,0 +1,74 @@ +# +# $Id: //poco/1.4/build/config/Linux#2 $ +# +# Linux +# +# Make settings for Linux 2.6/gcc 3.3 +# +# + +# +# General Settings +# +LINKMODE ?= SHARED +POCO_TARGET_OSNAME = NaCl +POCO_TARGET_OSARCH = x86_64 +CROSS_COMPILE = x86_64-nacl- + +# +# Define Tools +# +CC = ${CROSS_COMPILE}gcc +CXX = ${CROSS_COMPILE}g++ +LINK = $(CXX) +LIB = ${AR} -cr +RANLIB = ${CROSS_COMPILE}ranlib +SHLIB = $(CXX) -shared -Wl,-soname,$(notdir $@) -o $@ +SHLIBLN = $(POCO_BASE)/build/script/shlibln +STRIP = ${CROSS_COMPILE}strip +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 = +CFLAGS32 = +CFLAGS64 = +CXXFLAGS = -Wall -Wno-sign-compare +CXXFLAGS32 = +CXXFLAGS64 = +LINKFLAGS = +LINKFLAGS32 = +LINKFLAGS64 = +STATICOPT_CC = -fPIC +STATICOPT_CXX = -fPIC +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 = -O2 -DNDEBUG +RELEASEOPT_CXX = -O2 -DNDEBUG +RELEASEOPT_LINK = -O2 + +# +# System Specific Flags +# +SYSFLAGS = -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -D__NACL__ + +# +# System Specific Libraries +# +SYSLIBS = -lpthread -ldl -lrt