diff options
author | Stefan Laner <laner@itestra.de> | 2013-10-21 11:53:41 +0200 |
---|---|---|
committer | Stefan Laner <laner@itestra.de> | 2013-10-21 11:57:43 +0200 |
commit | ed1866179bdfdfca2dbb2631efa17e453772edf2 (patch) | |
tree | f48f24c0ac88a9f2bec05639290b7005409d5f80 | |
parent | 42b8420985e461b29b8c9f2c576d616f6f0e78ac (diff) | |
download | genivi-common-api-runtime-ed1866179bdfdfca2dbb2631efa17e453772edf2.tar.gz |
Adopted code to compile with Microsoft Visual Studio 2013
-rwxr-xr-x[-rw-r--r--] | src/CommonAPI/AttributeExtension.h | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | src/CommonAPI/MainLoopContext.h | 27 | ||||
-rwxr-xr-x[-rw-r--r--] | src/CommonAPI/OutputStream.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | src/CommonAPI/Runtime.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | src/CommonAPI/SerializableVariant.hpp | 8 | ||||
-rwxr-xr-x | src/CommonAPI/pollStructures.h | 57 | ||||
-rwxr-xr-x[-rw-r--r--] | src/CommonAPI/types.h | 14 | ||||
-rwxr-xr-x | src/test/VariantTest.cpp | 4 |
8 files changed, 107 insertions, 9 deletions
diff --git a/src/CommonAPI/AttributeExtension.h b/src/CommonAPI/AttributeExtension.h index 4a1b4d6..5f78c5b 100644..100755 --- a/src/CommonAPI/AttributeExtension.h +++ b/src/CommonAPI/AttributeExtension.h @@ -25,7 +25,11 @@ class AttributeExtension { } protected: +#ifdef WIN32 + AttributeExtension(); +#else AttributeExtension() = delete; +#endif AttributeExtension(_AttributeType& baseAttribute): baseAttribute_(baseAttribute) { } diff --git a/src/CommonAPI/MainLoopContext.h b/src/CommonAPI/MainLoopContext.h index 2178936..8f28e09 100644..100755 --- a/src/CommonAPI/MainLoopContext.h +++ b/src/CommonAPI/MainLoopContext.h @@ -10,16 +10,34 @@ #include <stdint.h> -#include <poll.h> + +#ifdef WIN32 + #undef max +#endif + +#ifdef WIN32 +#define COMMONAPI_POLLFD commonapi_pollfd +#else +#define COMMONAPI_POLLFD pollfd +#endif + #include <limits> #include <vector> +#include <list> #include <chrono> #include <functional> +#ifdef WIN32 + #include "pollStructures.h" +#else + #include <poll.h> +#endif namespace CommonAPI { + + enum class DispatchPriority { VERY_HIGH, HIGH, @@ -98,7 +116,7 @@ struct Watch { * * @return The associated file descriptor. */ - virtual const pollfd& getAssociatedFileDescriptor() = 0; + virtual const COMMONAPI_POLLFD& getAssociatedFileDescriptor() = 0; /** * \brief Returns a vector of all dispatch sources that depend on the watched file descriptor. @@ -110,9 +128,8 @@ struct Watch { virtual const std::vector<DispatchSource*>& getDependentDispatchSources() = 0; }; - -constexpr int64_t TIMEOUT_INFINITE = std::numeric_limits<int64_t>::max(); -constexpr int64_t TIMEOUT_NONE = 0; +const int64_t TIMEOUT_INFINITE = std::numeric_limits<int64_t>::max(); +const int64_t TIMEOUT_NONE = 0; /** diff --git a/src/CommonAPI/OutputStream.h b/src/CommonAPI/OutputStream.h index 6158f12..d620d70 100644..100755 --- a/src/CommonAPI/OutputStream.h +++ b/src/CommonAPI/OutputStream.h @@ -11,7 +11,6 @@ #include "SerializableStruct.h" #include "SerializableVariant.h" #include "types.h" -#include <unistd.h> #include <iostream> #include <cstdint> diff --git a/src/CommonAPI/Runtime.h b/src/CommonAPI/Runtime.h index d7a366d..7fa02ba 100644..100755 --- a/src/CommonAPI/Runtime.h +++ b/src/CommonAPI/Runtime.h @@ -15,7 +15,6 @@ #include <memory> #include <fstream> #include <unordered_map> -#include <dlfcn.h> #include <string> #include <cassert> #include <cstring> diff --git a/src/CommonAPI/SerializableVariant.hpp b/src/CommonAPI/SerializableVariant.hpp index febff2d..566f04a 100644..100755 --- a/src/CommonAPI/SerializableVariant.hpp +++ b/src/CommonAPI/SerializableVariant.hpp @@ -175,7 +175,11 @@ public: void operator()(const _Type&) { _Type value; inputStream_ >> value; +#ifdef WIN32 + lhs_.set<_Type>(std::move(value), false); +#else lhs_.Variant<_Types...>::template set<_Type>(std::move(value), false); +#endif } private: @@ -233,7 +237,11 @@ public: template<typename _Type> void operator()(const _Type& value) const { +#ifdef WIN32 + lhs_.set<_Type>(value, clear_); +#else lhs_.Variant<_Types...>::template set<_Type>(value, clear_); +#endif } template<typename _Type> diff --git a/src/CommonAPI/pollStructures.h b/src/CommonAPI/pollStructures.h new file mode 100755 index 0000000..7eacde3 --- /dev/null +++ b/src/CommonAPI/pollStructures.h @@ -0,0 +1,57 @@ +/* Header for poll(2) emulation + Contributed by Paolo Bonzini. + + Copyright 2001, 2002, 2003, 2007, 2009, 2010 Free Software Foundation, Inc. + + This file is part of gnulib. + + 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, 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. */ + +#ifndef _POLL_STRUCTURES_H +#define _POLL_STRUCTURES_H + +/* fake a poll(2) environment */ +#define POLLIN 0x0001 /* any readable data available */ +#define POLLPRI 0x0002 /* OOB/Urgent readable data */ +#define POLLOUT 0x0004 /* file descriptor is writeable */ +#define POLLERR 0x0008 /* some poll error occurred */ +#define POLLHUP 0x0010 /* file descriptor was "hung up" */ +#define POLLNVAL 0x0020 /* requested events "invalid" */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#define POLLWRNORM 0x0100 +#define POLLWRBAND 0x0200 + +#ifdef __cplusplus +extern "C" { +#endif + + + struct commonapi_pollfd + { + unsigned int fd; /* which file descriptor to poll */ + short events; /* events we are interested in */ + short revents; /* events found on return */ + }; + + typedef unsigned long nfds_t; + + //extern int poll(struct commonapi_pollfd *pfd, nfds_t nfd, int timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* _POLL_STRUCTURES_H */ diff --git a/src/CommonAPI/types.h b/src/CommonAPI/types.h index 13c36aa..c4f41e3 100644..100755 --- a/src/CommonAPI/types.h +++ b/src/CommonAPI/types.h @@ -10,6 +10,20 @@ #include <cstdint> +#ifdef WIN32 +#define CCALL __cdecl +#pragma section(".CRT$XCU",read) +#define INITIALIZER(f) \ + static void __cdecl f(void); \ + __declspec(allocate(".CRT$XCU")) void(__cdecl*f##_)(void) = f; \ + static void __cdecl f(void) +#else +#define CCALL +#define INITIALIZER(f) \ + static void f(void) __attribute__((constructor)); \ + static void f(void) +#endif + namespace CommonAPI { enum class AvailabilityStatus { diff --git a/src/test/VariantTest.cpp b/src/test/VariantTest.cpp index 0f230d1..64013cb 100755 --- a/src/test/VariantTest.cpp +++ b/src/test/VariantTest.cpp @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <gtest/gtest.h> -#include <src/CommonAPI/SerializableVariant.h> +#include "../CommonAPI/SerializableVariant.h" using namespace CommonAPI; @@ -64,7 +64,7 @@ struct test2: CommonAPI::SerializableStruct { TEST_F(VariantTest, VariantTestPack) { int fromInt = 5; - double fromDouble = 12.344d; + double fromDouble = 12.344; std::string fromString = "123abcsadfaljkawlöfasklöerklöfjasklfjysklfjaskfjsklösdfdko4jdfasdjioögjopefgip3rtgjiprg!"; Variant<int, double, std::string> myVariant(fromInt); |