You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/05/05 14:02:57 UTC
[24/34] ignite git commit: IGNITE-1786: Implemented ODBC driver.
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/include/Makefile.am b/modules/platforms/cpp/common/os/linux/include/Makefile.am
index f6e2803..9332f4f 100644
--- a/modules/platforms/cpp/common/os/linux/include/Makefile.am
+++ b/modules/platforms/cpp/common/os/linux/include/Makefile.am
@@ -15,10 +15,11 @@
## limitations under the License.
##
-ACLOCAL_AMFLAGS = "-Im4"
+ACLOCAL_AMFLAGS =-I m4
-nobase_include_HEADERS = ignite/common/common.h \
- ignite/common/concurrent_os.h
+nobase_include_HEADERS = \
+ ignite/common/common.h \
+ ignite/common/concurrent_os.h
uninstall-hook:
- find ${includedir}/ignite -type d -empty -delete
+ if [ -d ${includedir}/ignite ]; then find ${includedir}/ignite -type d -empty -delete; fi
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h b/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
index 0ec8e16..5932a6c 100644
--- a/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
+++ b/modules/platforms/cpp/common/os/linux/include/ignite/common/common.h
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef _IGNITE_COMMON_OS
-#define _IGNITE_COMMON_OS
+#ifndef _IGNITE_COMMON_COMMON
+#define _IGNITE_COMMON_COMMON
#ifndef __has_attribute
# define __has_attribute(x) 0
@@ -51,37 +51,4 @@
cls(const cls& src); \
cls& operator= (const cls& other);
-namespace ignite
-{
- namespace common
- {
- /**
- * Helper class to manage attached threads.
- */
- class AttachHelper
- {
- public:
- /**
- * Destructor.
- */
- ~AttachHelper();
-
- /**
- * Callback invoked on successful thread attach ot JVM.
- */
- static void OnThreadAttach();
- private:
- /**
- * Helper method to allocate attach key.
- */
- static void AllocateAttachKey();
-
- /**
- * Attach key destructor.
- */
- static void DestroyAttachKey(void* key);
- };
- }
-}
-
#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h b/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h
index 63798b1..27ef998 100644
--- a/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h
+++ b/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h
@@ -391,4 +391,4 @@ namespace ignite
}
}
-#endif
\ No newline at end of file
+#endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/src/common.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/src/common.cpp b/modules/platforms/cpp/common/os/linux/src/common.cpp
deleted file mode 100644
index c0cccdc..0000000
--- a/modules/platforms/cpp/common/os/linux/src/common.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <pthread.h>
-
-#include "ignite/common/common.h"
-#include "ignite/common/java.h"
-
-using namespace ignite::common::java;
-
-namespace ignite
-{
- namespace common
- {
- /** Key indicating that the thread is attached. */
- static pthread_key_t attachKey;
-
- /** Helper to ensure that attach key is allocated only once. */
- static pthread_once_t attachKeyInit = PTHREAD_ONCE_INIT;
-
- AttachHelper::~AttachHelper()
- {
- JniContext::Detach();
- }
-
- void AttachHelper::OnThreadAttach()
- {
- pthread_once(&attachKeyInit, AllocateAttachKey);
-
- void* val = pthread_getspecific(attachKey);
-
- if (!val)
- pthread_setspecific(attachKey, new AttachHelper());
- }
-
- void AttachHelper::AllocateAttachKey()
- {
- pthread_key_create(&attachKey, DestroyAttachKey);
- }
-
- void AttachHelper::DestroyAttachKey(void* key)
- {
- delete reinterpret_cast<AttachHelper*>(key);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/src/common/concurrent_os.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/src/common/concurrent_os.cpp b/modules/platforms/cpp/common/os/linux/src/common/concurrent_os.cpp
new file mode 100644
index 0000000..2336d58
--- /dev/null
+++ b/modules/platforms/cpp/common/os/linux/src/common/concurrent_os.cpp
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/common/concurrent_os.h"
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace concurrent
+ {
+ /** Key indicating that the thread is attached. */
+ static pthread_key_t tlsKey;
+
+ /** Helper to ensure that attach key is allocated only once. */
+ static pthread_once_t tlsKeyInit = PTHREAD_ONCE_INIT;
+
+ /**
+ * Routine to destroy TLS key.
+ *
+ * @param key Key.
+ */
+ void DestroyTlsKey(void* key) {
+ ThreadLocal::Clear0(key);
+ }
+
+ /**
+ * Routine to allocate TLS key.
+ */
+ void AllocateTlsKey() {
+ pthread_key_create(&tlsKey, DestroyTlsKey);
+ }
+
+ void Memory::Fence() {
+ __asm__ volatile ("" ::: "memory");
+ }
+
+ CriticalSection::CriticalSection() {
+ pthread_mutex_init(&mux, NULL);
+
+ Memory::Fence();
+ }
+
+ CriticalSection::~CriticalSection() {
+ Memory::Fence();
+
+ pthread_mutex_destroy(&mux);
+ }
+
+ void CriticalSection::Enter() {
+ Memory::Fence();
+
+ pthread_mutex_lock(&mux);
+ }
+
+ void CriticalSection::Leave() {
+ Memory::Fence();
+
+ pthread_mutex_unlock(&mux);
+ }
+
+ SingleLatch::SingleLatch()
+ {
+ pthread_mutex_init(&mux, NULL);
+ pthread_cond_init(&cond, NULL);
+ ready = false;
+
+ Memory::Fence();
+ }
+
+ SingleLatch::~SingleLatch()
+ {
+ Memory::Fence();
+
+ pthread_cond_destroy(&cond);
+ pthread_mutex_destroy(&mux);
+ }
+
+ void SingleLatch::CountDown()
+ {
+ pthread_mutex_lock(&mux);
+
+ if (!ready) {
+ ready = true;
+
+ pthread_cond_broadcast(&cond);
+ }
+
+ pthread_mutex_unlock(&mux);
+
+ Memory::Fence();
+ }
+
+ void SingleLatch::Await()
+ {
+ pthread_mutex_lock(&mux);
+
+ while (!ready)
+ pthread_cond_wait(&cond, &mux);
+
+ pthread_mutex_unlock(&mux);
+
+ Memory::Fence();
+ }
+
+ bool Atomics::CompareAndSet32(int32_t* ptr, int32_t expVal, int32_t newVal)
+ {
+ return __sync_bool_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int32_t Atomics::CompareAndSet32Val(int32_t* ptr, int32_t expVal, int32_t newVal)
+ {
+ return __sync_val_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int32_t Atomics::IncrementAndGet32(int32_t* ptr)
+ {
+ return __sync_fetch_and_add(ptr, 1) + 1;
+ }
+
+ int32_t Atomics::DecrementAndGet32(int32_t* ptr)
+ {
+ return __sync_fetch_and_sub(ptr, 1) - 1;
+ }
+
+ bool Atomics::CompareAndSet64(int64_t* ptr, int64_t expVal, int64_t newVal)
+ {
+ return __sync_bool_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int64_t Atomics::CompareAndSet64Val(int64_t* ptr, int64_t expVal, int64_t newVal)
+ {
+ return __sync_val_compare_and_swap(ptr, expVal, newVal);
+ }
+
+ int64_t Atomics::IncrementAndGet64(int64_t* ptr)
+ {
+ return __sync_fetch_and_add(ptr, 1) + 1;
+ }
+
+ int64_t Atomics::DecrementAndGet64(int64_t* ptr)
+ {
+ return __sync_fetch_and_sub(ptr, 1) - 1;
+ }
+
+ void* ThreadLocal::Get0()
+ {
+ pthread_once(&tlsKeyInit, AllocateTlsKey);
+
+ return pthread_getspecific(tlsKey);
+ }
+
+ void ThreadLocal::Set0(void* ptr)
+ {
+ pthread_once(&tlsKeyInit, AllocateTlsKey);
+
+ pthread_setspecific(tlsKey, ptr);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/src/common/utils.cpp b/modules/platforms/cpp/common/os/linux/src/common/utils.cpp
new file mode 100644
index 0000000..e37a91c
--- /dev/null
+++ b/modules/platforms/cpp/common/os/linux/src/common/utils.cpp
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <time.h>
+
+#include <sys/stat.h>
+#include <dirent.h>
+#include <dlfcn.h>
+
+#include <ignite/common/utils.h>
+
+namespace ignite
+{
+ namespace common
+ {
+ /**
+ * Check if string ends with the given ending.
+ *
+ * @param str String to check.
+ * @param ending Ending.
+ * @return Result.
+ */
+ inline bool StringEndsWith(const std::string& str, const std::string& ending)
+ {
+ if (str.length() > ending.length())
+ return str.compare(str.length() - ending.length(), ending.length(), ending) == 0;
+
+ return false;
+ }
+
+ time_t IgniteTimeGm(const tm& time)
+ {
+ tm tmc = time;
+
+ return timegm(&tmc);
+ }
+
+ time_t IgniteTimeLocal(const tm& time)
+ {
+ tm tmc = time;
+
+ return mktime(&tmc);
+ }
+
+ bool IgniteGmTime(time_t in, tm& out)
+ {
+ return gmtime_r(&in, &out) != NULL;
+ }
+
+ bool IgniteLocalTime(time_t in, tm& out)
+ {
+ return localtime_r(&in, &out) == 0;
+ }
+
+ int LeadingZeroesForOctet(int8_t octet) {
+ if (octet == 0)
+ return 8;
+
+ int zeroes = 1;
+
+ if (octet >> 4 == 0) {
+ zeroes += 4;
+ octet <<= 4;
+ }
+
+ if (octet >> 6 == 0) {
+ zeroes += 2;
+ octet <<= 2;
+ }
+
+ zeroes -= octet >> 7;
+
+ return zeroes;
+ }
+
+ char* CopyChars(const char* val)
+ {
+ if (val) {
+ size_t len = strlen(val);
+ char* dest = new char[len + 1];
+ strcpy(dest, val);
+ *(dest + len) = 0;
+ return dest;
+ }
+ else
+ return NULL;
+ }
+
+ void ReleaseChars(char* val)
+ {
+ if (val)
+ delete[] val;
+ }
+
+ std::string GetEnv(const std::string& name, bool& found)
+ {
+ char* val = std::getenv(name.c_str());
+
+ if (val)
+ {
+ found = true;
+
+ return std::string(val);
+ }
+ else
+ {
+ found = false;
+
+ return std::string();
+ }
+ }
+
+ bool FileExists(const std::string& path)
+ {
+ struct stat s;
+
+ int res = stat(path.c_str(), &s);
+
+ return res != -1;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/linux/src/concurrent_os.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/src/concurrent_os.cpp b/modules/platforms/cpp/common/os/linux/src/concurrent_os.cpp
deleted file mode 100644
index 44f0b22..0000000
--- a/modules/platforms/cpp/common/os/linux/src/concurrent_os.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ignite/common/concurrent_os.h"
-
-namespace ignite
-{
- namespace common
- {
- namespace concurrent
- {
- /** Key indicating that the thread is attached. */
- static pthread_key_t tlsKey;
-
- /** Helper to ensure that attach key is allocated only once. */
- static pthread_once_t tlsKeyInit = PTHREAD_ONCE_INIT;
-
- /**
- * Routine to destroy TLS key.
- *
- * @param key Key.
- */
- void DestroyTlsKey(void* key) {
- ThreadLocal::Clear0(key);
- }
-
- /**
- * Routine to allocate TLS key.
- */
- void AllocateTlsKey() {
- pthread_key_create(&tlsKey, DestroyTlsKey);
- }
-
- void Memory::Fence() {
- __asm__ volatile ("" ::: "memory");
- }
-
- CriticalSection::CriticalSection() {
- pthread_mutex_init(&mux, NULL);
-
- Memory::Fence();
- }
-
- CriticalSection::~CriticalSection() {
- Memory::Fence();
-
- pthread_mutex_destroy(&mux);
- }
-
- void CriticalSection::Enter() {
- Memory::Fence();
-
- pthread_mutex_lock(&mux);
- }
-
- void CriticalSection::Leave() {
- Memory::Fence();
-
- pthread_mutex_unlock(&mux);
- }
-
- SingleLatch::SingleLatch()
- {
- pthread_mutex_init(&mux, NULL);
- pthread_cond_init(&cond, NULL);
- ready = false;
-
- Memory::Fence();
- }
-
- SingleLatch::~SingleLatch()
- {
- Memory::Fence();
-
- pthread_cond_destroy(&cond);
- pthread_mutex_destroy(&mux);
- }
-
- void SingleLatch::CountDown()
- {
- pthread_mutex_lock(&mux);
-
- if (!ready) {
- ready = true;
-
- pthread_cond_broadcast(&cond);
- }
-
- pthread_mutex_unlock(&mux);
-
- Memory::Fence();
- }
-
- void SingleLatch::Await()
- {
- pthread_mutex_lock(&mux);
-
- while (!ready)
- pthread_cond_wait(&cond, &mux);
-
- pthread_mutex_unlock(&mux);
-
- Memory::Fence();
- }
-
- bool Atomics::CompareAndSet32(int32_t* ptr, int32_t expVal, int32_t newVal)
- {
- return __sync_bool_compare_and_swap(ptr, expVal, newVal);
- }
-
- int32_t Atomics::CompareAndSet32Val(int32_t* ptr, int32_t expVal, int32_t newVal)
- {
- return __sync_val_compare_and_swap(ptr, expVal, newVal);
- }
-
- int32_t Atomics::IncrementAndGet32(int32_t* ptr)
- {
- return __sync_fetch_and_add(ptr, 1) + 1;
- }
-
- int32_t Atomics::DecrementAndGet32(int32_t* ptr)
- {
- return __sync_fetch_and_sub(ptr, 1) - 1;
- }
-
- bool Atomics::CompareAndSet64(int64_t* ptr, int64_t expVal, int64_t newVal)
- {
- return __sync_bool_compare_and_swap(ptr, expVal, newVal);
- }
-
- int64_t Atomics::CompareAndSet64Val(int64_t* ptr, int64_t expVal, int64_t newVal)
- {
- return __sync_val_compare_and_swap(ptr, expVal, newVal);
- }
-
- int64_t Atomics::IncrementAndGet64(int64_t* ptr)
- {
- return __sync_fetch_and_add(ptr, 1) + 1;
- }
-
- int64_t Atomics::DecrementAndGet64(int64_t* ptr)
- {
- return __sync_fetch_and_sub(ptr, 1) - 1;
- }
-
- void* ThreadLocal::Get0()
- {
- pthread_once(&tlsKeyInit, AllocateTlsKey);
-
- return pthread_getspecific(tlsKey);
- }
-
- void ThreadLocal::Set0(void* ptr)
- {
- pthread_once(&tlsKeyInit, AllocateTlsKey);
-
- pthread_setspecific(tlsKey, ptr);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/include/ignite/common/common.h b/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
index cf924c8..8285149 100644
--- a/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
+++ b/modules/platforms/cpp/common/os/win/include/ignite/common/common.h
@@ -41,22 +41,4 @@
# define IGNITE_NO_THROW throw()
#endif
-namespace ignite
-{
- namespace common
- {
- /**
- * Helper class to manage attached threads.
- */
- class AttachHelper
- {
- public:
- /**
- * Callback invoked on successful thread attach ot JVM.
- */
- static void OnThreadAttach();
- };
- }
-}
-
-#endif
\ No newline at end of file
+#endif //_IGNITE_COMMON_COMMON
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/win/include/ignite/common/concurrent_os.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/include/ignite/common/concurrent_os.h b/modules/platforms/cpp/common/os/win/include/ignite/common/concurrent_os.h
index 0a47beb..77de4d8 100644
--- a/modules/platforms/cpp/common/os/win/include/ignite/common/concurrent_os.h
+++ b/modules/platforms/cpp/common/os/win/include/ignite/common/concurrent_os.h
@@ -26,7 +26,7 @@
namespace ignite
{
- namespace common
+ namespace common
{
namespace concurrent
{
@@ -403,4 +403,4 @@ namespace ignite
}
}
-#endif
\ No newline at end of file
+#endif //_IGNITE_COMMON_CONCURRENT_OS
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/win/src/common.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/common.cpp b/modules/platforms/cpp/common/os/win/src/common.cpp
deleted file mode 100644
index e83e736..0000000
--- a/modules/platforms/cpp/common/os/win/src/common.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <windows.h>
-
-#include "ignite/common/common.h"
-#include "ignite/common/concurrent.h"
-#include "ignite/common/java.h"
-
-using namespace ignite::common::concurrent;
-using namespace ignite::common::java;
-
-namespace ignite
-{
- namespace common
- {
- void AttachHelper::OnThreadAttach()
- {
- // No-op.
- }
- }
-}
-
-BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
-{
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- if (!ThreadLocal::OnProcessAttach())
- return FALSE;
-
- break;
-
- case DLL_THREAD_DETACH:
- ThreadLocal::OnThreadDetach();
-
- JniContext::Detach();
-
- break;
-
- case DLL_PROCESS_DETACH:
- ThreadLocal::OnProcessDetach();
-
- break;
-
- default:
- break;
- }
-
- return TRUE;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/win/src/common/concurrent_os.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/common/concurrent_os.cpp b/modules/platforms/cpp/common/os/win/src/common/concurrent_os.cpp
new file mode 100644
index 0000000..676d8b6
--- /dev/null
+++ b/modules/platforms/cpp/common/os/win/src/common/concurrent_os.cpp
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/common/concurrent_os.h"
+
+#pragma intrinsic(_InterlockedCompareExchange64)
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace concurrent
+ {
+ /** Thread-local index for Windows. */
+ DWORD winTlsIdx;
+
+ void Memory::Fence() {
+ MemoryBarrier();
+ }
+
+ CriticalSection::CriticalSection() : hnd(new CRITICAL_SECTION) {
+ InitializeCriticalSection(hnd);
+
+ Memory::Fence();
+ }
+
+ CriticalSection::~CriticalSection() {
+ Memory::Fence();
+
+ delete hnd;
+ }
+
+ void CriticalSection::Enter() {
+ Memory::Fence();
+
+ EnterCriticalSection(hnd);
+ }
+
+ void CriticalSection::Leave() {
+ Memory::Fence();
+
+ LeaveCriticalSection(hnd);
+ }
+
+ SingleLatch::SingleLatch() : hnd(CreateEvent(NULL, TRUE, FALSE, NULL))
+ {
+ Memory::Fence();
+ }
+
+ SingleLatch::~SingleLatch()
+ {
+ Memory::Fence();
+
+ CloseHandle(hnd);
+ }
+
+ void SingleLatch::CountDown()
+ {
+ SetEvent(hnd);
+ }
+
+ void SingleLatch::Await()
+ {
+ WaitForSingleObject(hnd, INFINITE);
+ }
+
+ bool Atomics::CompareAndSet32(int32_t* ptr, int32_t expVal, int32_t newVal)
+ {
+ return CompareAndSet32Val(ptr, expVal, newVal) == expVal;
+ }
+
+ int32_t Atomics::CompareAndSet32Val(int32_t* ptr, int32_t expVal, int32_t newVal)
+ {
+ return InterlockedCompareExchange(reinterpret_cast<LONG*>(ptr), newVal, expVal);
+ }
+
+ int32_t Atomics::IncrementAndGet32(int32_t* ptr)
+ {
+ return InterlockedIncrement(reinterpret_cast<LONG*>(ptr));
+ }
+
+ int32_t Atomics::DecrementAndGet32(int32_t* ptr)
+ {
+ return InterlockedDecrement(reinterpret_cast<LONG*>(ptr));
+ }
+
+ bool Atomics::CompareAndSet64(int64_t* ptr, int64_t expVal, int64_t newVal)
+ {
+ return CompareAndSet64Val(ptr, expVal, newVal) == expVal;
+ }
+
+ int64_t Atomics::CompareAndSet64Val(int64_t* ptr, int64_t expVal, int64_t newVal)
+ {
+ return _InterlockedCompareExchange64(reinterpret_cast<LONG64*>(ptr), newVal, expVal);
+ }
+
+ int64_t Atomics::IncrementAndGet64(int64_t* ptr)
+ {
+#ifdef _WIN64
+ return InterlockedIncrement64(reinterpret_cast<LONG64*>(ptr));
+#else
+ while (true)
+ {
+ int64_t expVal = *ptr;
+ int64_t newVal = expVal + 1;
+
+ if (CompareAndSet64(ptr, expVal, newVal))
+ return newVal;
+ }
+#endif
+ }
+
+ int64_t Atomics::DecrementAndGet64(int64_t* ptr)
+ {
+#ifdef _WIN64
+ return InterlockedDecrement64(reinterpret_cast<LONG64*>(ptr));
+#else
+ while (true)
+ {
+ int64_t expVal = *ptr;
+ int64_t newVal = expVal - 1;
+
+ if (CompareAndSet64(ptr, expVal, newVal))
+ return newVal;
+ }
+#endif
+ }
+
+ bool ThreadLocal::OnProcessAttach()
+ {
+ return (winTlsIdx = TlsAlloc()) != TLS_OUT_OF_INDEXES;
+ }
+
+ void ThreadLocal::OnThreadDetach()
+ {
+ if (winTlsIdx != TLS_OUT_OF_INDEXES)
+ {
+ void* mapPtr = Get0();
+
+ Clear0(mapPtr);
+ }
+ }
+
+ void ThreadLocal::OnProcessDetach()
+ {
+ if (winTlsIdx != TLS_OUT_OF_INDEXES)
+ TlsFree(winTlsIdx);
+ }
+
+ void* ThreadLocal::Get0()
+ {
+ return TlsGetValue(winTlsIdx);
+ }
+
+ void ThreadLocal::Set0(void* ptr)
+ {
+ TlsSetValue(winTlsIdx, ptr);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/win/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/common/utils.cpp b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
new file mode 100644
index 0000000..65236d2
--- /dev/null
+++ b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <time.h>
+
+#include <windows.h>
+
+#include <ignite/common/utils.h>
+
+namespace ignite
+{
+ namespace common
+ {
+ /**
+ * Check if string ends with the given ending.
+ *
+ * @param str String to check.
+ * @param ending Ending.
+ * @return Result.
+ */
+ inline bool StringEndsWith(const std::string& str, const std::string& ending)
+ {
+ if (str.length() > ending.length())
+ return str.compare(str.length() - ending.length(), ending.length(), ending) == 0;
+
+ return false;
+ }
+
+ time_t IgniteTimeGm(const tm& time)
+ {
+ tm tmc = time;
+
+ return _mkgmtime(&tmc);
+ }
+
+ time_t IgniteTimeLocal(const tm& time)
+ {
+ tm tmc = time;
+
+ return mktime(&tmc);
+ }
+
+ bool IgniteGmTime(time_t in, tm& out)
+ {
+ return gmtime_s(&out, &in) == 0;
+ }
+
+ bool IgniteLocalTime(time_t in, tm& out)
+ {
+ return localtime_s(&out, &in) == 0;
+ }
+
+ int LeadingZeroesForOctet(int8_t octet) {
+ if (octet == 0)
+ return 8;
+
+ int zeroes = 1;
+
+ if (octet >> 4 == 0) {
+ zeroes += 4;
+ octet <<= 4;
+ }
+
+ if (octet >> 6 == 0) {
+ zeroes += 2;
+ octet <<= 2;
+ }
+
+ zeroes -= octet >> 7;
+
+ return zeroes;
+ }
+
+ char* CopyChars(const char* val)
+ {
+ if (val) {
+ size_t len = strlen(val);
+ char* dest = new char[len + 1];
+ strcpy(dest, val);
+ *(dest + len) = 0;
+ return dest;
+ }
+ else
+ return NULL;
+ }
+
+ void ReleaseChars(char* val)
+ {
+ if (val)
+ delete[] val;
+ }
+
+ std::string GetEnv(const std::string& name, bool& found)
+ {
+ char res0[32767];
+
+ DWORD envRes = GetEnvironmentVariableA(name.c_str(), res0, 32767);
+
+ if (envRes != 0)
+ {
+ found = true;
+
+ return std::string(res0);
+ }
+ else
+ {
+ found = false;
+
+ return std::string();
+ }
+ }
+
+ bool FileExists(const std::string& path)
+ {
+ WIN32_FIND_DATAA findres;
+
+ HANDLE hnd = FindFirstFileA(path.c_str(), &findres);
+
+ if (hnd == INVALID_HANDLE_VALUE)
+ return false;
+ else
+ {
+ FindClose(hnd);
+
+ return true;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/os/win/src/concurrent_os.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/concurrent_os.cpp b/modules/platforms/cpp/common/os/win/src/concurrent_os.cpp
deleted file mode 100644
index 676d8b6..0000000
--- a/modules/platforms/cpp/common/os/win/src/concurrent_os.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ignite/common/concurrent_os.h"
-
-#pragma intrinsic(_InterlockedCompareExchange64)
-
-namespace ignite
-{
- namespace common
- {
- namespace concurrent
- {
- /** Thread-local index for Windows. */
- DWORD winTlsIdx;
-
- void Memory::Fence() {
- MemoryBarrier();
- }
-
- CriticalSection::CriticalSection() : hnd(new CRITICAL_SECTION) {
- InitializeCriticalSection(hnd);
-
- Memory::Fence();
- }
-
- CriticalSection::~CriticalSection() {
- Memory::Fence();
-
- delete hnd;
- }
-
- void CriticalSection::Enter() {
- Memory::Fence();
-
- EnterCriticalSection(hnd);
- }
-
- void CriticalSection::Leave() {
- Memory::Fence();
-
- LeaveCriticalSection(hnd);
- }
-
- SingleLatch::SingleLatch() : hnd(CreateEvent(NULL, TRUE, FALSE, NULL))
- {
- Memory::Fence();
- }
-
- SingleLatch::~SingleLatch()
- {
- Memory::Fence();
-
- CloseHandle(hnd);
- }
-
- void SingleLatch::CountDown()
- {
- SetEvent(hnd);
- }
-
- void SingleLatch::Await()
- {
- WaitForSingleObject(hnd, INFINITE);
- }
-
- bool Atomics::CompareAndSet32(int32_t* ptr, int32_t expVal, int32_t newVal)
- {
- return CompareAndSet32Val(ptr, expVal, newVal) == expVal;
- }
-
- int32_t Atomics::CompareAndSet32Val(int32_t* ptr, int32_t expVal, int32_t newVal)
- {
- return InterlockedCompareExchange(reinterpret_cast<LONG*>(ptr), newVal, expVal);
- }
-
- int32_t Atomics::IncrementAndGet32(int32_t* ptr)
- {
- return InterlockedIncrement(reinterpret_cast<LONG*>(ptr));
- }
-
- int32_t Atomics::DecrementAndGet32(int32_t* ptr)
- {
- return InterlockedDecrement(reinterpret_cast<LONG*>(ptr));
- }
-
- bool Atomics::CompareAndSet64(int64_t* ptr, int64_t expVal, int64_t newVal)
- {
- return CompareAndSet64Val(ptr, expVal, newVal) == expVal;
- }
-
- int64_t Atomics::CompareAndSet64Val(int64_t* ptr, int64_t expVal, int64_t newVal)
- {
- return _InterlockedCompareExchange64(reinterpret_cast<LONG64*>(ptr), newVal, expVal);
- }
-
- int64_t Atomics::IncrementAndGet64(int64_t* ptr)
- {
-#ifdef _WIN64
- return InterlockedIncrement64(reinterpret_cast<LONG64*>(ptr));
-#else
- while (true)
- {
- int64_t expVal = *ptr;
- int64_t newVal = expVal + 1;
-
- if (CompareAndSet64(ptr, expVal, newVal))
- return newVal;
- }
-#endif
- }
-
- int64_t Atomics::DecrementAndGet64(int64_t* ptr)
- {
-#ifdef _WIN64
- return InterlockedDecrement64(reinterpret_cast<LONG64*>(ptr));
-#else
- while (true)
- {
- int64_t expVal = *ptr;
- int64_t newVal = expVal - 1;
-
- if (CompareAndSet64(ptr, expVal, newVal))
- return newVal;
- }
-#endif
- }
-
- bool ThreadLocal::OnProcessAttach()
- {
- return (winTlsIdx = TlsAlloc()) != TLS_OUT_OF_INDEXES;
- }
-
- void ThreadLocal::OnThreadDetach()
- {
- if (winTlsIdx != TLS_OUT_OF_INDEXES)
- {
- void* mapPtr = Get0();
-
- Clear0(mapPtr);
- }
- }
-
- void ThreadLocal::OnProcessDetach()
- {
- if (winTlsIdx != TLS_OUT_OF_INDEXES)
- TlsFree(winTlsIdx);
- }
-
- void* ThreadLocal::Get0()
- {
- return TlsGetValue(winTlsIdx);
- }
-
- void ThreadLocal::Set0(void* ptr)
- {
- TlsSetValue(winTlsIdx, ptr);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj b/modules/platforms/cpp/common/project/vs/common.vcxproj
index ac7d504..67f01ff 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj
@@ -19,32 +19,32 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{4F7E4917-4612-4B96-9838-025711ADE391}</ProjectGuid>
+ <ProjectGuid>{B63F2E01-5157-4719-8491-0E1C7CD3B701}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>common</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v100</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v100</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v100</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v100</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
@@ -67,10 +67,10 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>false</LinkIncremental>
<TargetName>ignite.common</TargetName>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>ignite.common</TargetName>
@@ -79,8 +79,10 @@
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
<TargetName>ignite.common</TargetName>
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>ignite.common</TargetName>
@@ -94,15 +96,11 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;IGNITEJVM_EXPORTS;_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <DelayLoadDLLs>jvm.dll</DelayLoadDLLs>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
<OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
@@ -112,19 +110,15 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;IGNITEJVM_EXPORTS;_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
- <DelayLoadDLLs>jvm.dll</DelayLoadDLLs>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -135,7 +129,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;IGNITEJVM_EXPORTS;_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
@@ -147,10 +141,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <DelayLoadDLLs>jvm.dll</DelayLoadDLLs>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -160,7 +150,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
@@ -172,32 +162,29 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <DelayLoadDLLs>jvm.dll</DelayLoadDLLs>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ignite\common\concurrent.h" />
- <ClInclude Include="..\..\include\ignite\common\exports.h" />
- <ClInclude Include="..\..\include\ignite\common\java.h" />
<ClInclude Include="..\..\include\ignite\common\utils.h" />
+ <ClInclude Include="..\..\include\ignite\date.h" />
+ <ClInclude Include="..\..\include\ignite\guid.h" />
+ <ClInclude Include="..\..\include\ignite\ignite_error.h" />
+ <ClInclude Include="..\..\include\ignite\timestamp.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\common.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\concurrent_os.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\os\win\src\common.cpp" />
- <ClCompile Include="..\..\os\win\src\concurrent_os.cpp" />
- <ClCompile Include="..\..\src\concurrent.cpp" />
- <ClCompile Include="..\..\src\exports.cpp" />
- <ClCompile Include="..\..\src\java.cpp" />
+ <ClCompile Include="..\..\os\win\src\common\concurrent_os.cpp" />
+ <ClCompile Include="..\..\os\win\src\common\utils.cpp" />
+ <ClCompile Include="..\..\src\common\concurrent.cpp" />
+ <ClCompile Include="..\..\src\date.cpp" />
+ <ClCompile Include="..\..\src\guid.cpp" />
+ <ClCompile Include="..\..\src\ignite_error.cpp" />
+ <ClCompile Include="..\..\src\timestamp.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
- <ItemGroup>
- <None Include="module.def" />
- </ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
index 01a47a0..1a6f069 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
@@ -8,50 +8,60 @@
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
+ <Filter Include="Code\common">
+ <UniqueIdentifier>{9d664b8a-3a09-460b-9d53-c1a7f08217c0}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="targetver.h">
+ <Filter>Misc</Filter>
+ </ClInclude>
<ClInclude Include="..\..\os\win\include\ignite\common\common.h">
- <Filter>Code</Filter>
+ <Filter>Code\common</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\common\concurrent.h">
+ <Filter>Code\common</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\common\utils.h">
+ <Filter>Code\common</Filter>
</ClInclude>
<ClInclude Include="..\..\os\win\include\ignite\common\concurrent_os.h">
- <Filter>Code</Filter>
+ <Filter>Code\common</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\common\exports.h">
+ <ClInclude Include="..\..\include\ignite\date.h">
<Filter>Code</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\common\java.h">
+ <ClInclude Include="..\..\include\ignite\guid.h">
<Filter>Code</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\common\concurrent.h">
+ <ClInclude Include="..\..\include\ignite\timestamp.h">
<Filter>Code</Filter>
</ClInclude>
- <ClInclude Include="targetver.h">
- <Filter>Misc</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\common\utils.h">
+ <ClInclude Include="..\..\include\ignite\ignite_error.h">
<Filter>Code</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\os\win\src\common.cpp">
+ <ClCompile Include="..\..\src\date.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\concurrent.cpp">
+ <ClCompile Include="..\..\src\guid.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\os\win\src\concurrent_os.cpp">
+ <ClCompile Include="..\..\src\timestamp.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\exports.cpp">
- <Filter>Code</Filter>
+ <ClCompile Include="..\..\os\win\src\common\concurrent_os.cpp">
+ <Filter>Code\common</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\java.cpp">
+ <ClCompile Include="..\..\os\win\src\common\utils.cpp">
+ <Filter>Code\common</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\common\concurrent.cpp">
+ <Filter>Code\common</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\ignite_error.cpp">
<Filter>Code</Filter>
</ClCompile>
</ItemGroup>
- <ItemGroup>
- <None Include="module.def">
- <Filter>Misc</Filter>
- </None>
- </ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/module.def b/modules/platforms/cpp/common/project/vs/module.def
deleted file mode 100644
index 5f2e941..0000000
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ /dev/null
@@ -1,135 +0,0 @@
-LIBRARY ignite.common.dll
-EXPORTS
-IgniteReallocate @1
-IgniteIgnitionStart @2
-IgniteIgnitionInstance @3
-IgniteIgnitionEnvironmentPointer @4
-IgniteIgnitionStop @5
-IgniteIgnitionStopAll @6
-IgniteTargetOutLong @7
-IgniteProcessorReleaseStart @8
-IgniteProcessorProjection @9
-IgniteProcessorCache @10
-IgniteProcessorCreateCache @11
-IgniteProcessorGetOrCreateCache @12
-IgniteProcessorAffinity @13
-IgniteProcessorDataStreamer @14
-IgniteProcessorTransactions @15
-IgniteProcessorServices @16
-IgniteTargetInStreamOutObject @17
-IgniteTargetInStreamOutLong @18
-IgniteTargetOutStream @19
-IgniteTargetInStreamOutStream @20
-IgniteTargetInObjectStreamOutStream @21
-IgniteTargetListenFuture @22
-IgniteTargetListenFutureForOperation @23
-IgniteAffinityPartitions @24
-IgniteCacheWithSkipStore @25
-IgniteCacheWithNoRetries @26
-IgniteCacheWithExpiryPolicy @27
-IgniteCacheWithAsync @28
-IgniteCacheWithKeepPortable @29
-IgniteCacheClear @30
-IgniteCacheRemoveAll @31
-IgniteCacheOutOpQueryCursor @32
-IgniteCacheOutOpContinuousQuery @33
-IgniteCacheIterator @34
-IgniteCacheLocalIterator @35
-IgniteCacheEnterLock @36
-IgniteCacheExitLock @37
-IgniteCacheTryEnterLock @38
-IgniteCacheCloseLock @39
-IgniteCacheRebalance @40
-IgniteCacheSize @41
-IgniteCacheStoreCallbackInvoke @42
-IgniteComputeWithNoFailover @43
-IgniteComputeWithTimeout @44
-IgniteComputeExecuteNative @45
-IgniteContinuousQueryClose @46
-IgniteContinuousQueryGetInitialQueryCursor @47
-IgniteDataStreamerListenTopology @48
-IgniteDataStreamerAllowOverwriteGet @49
-IgniteDataStreamerAllowOverwriteSet @50
-IgniteDataStreamerSkipStoreGet @51
-IgniteDataStreamerSkipStoreSet @52
-IgniteDataStreamerPerNodeBufferSizeGet @53
-IgniteDataStreamerPerNodeBufferSizeSet @54
-IgniteDataStreamerPerNodeParallelOperationsGet @55
-IgniteDataStreamerPerNodeParallelOperationsSet @56
-IgniteMessagingWithAsync @57
-IgniteProjectionForOthers @58
-IgniteProjectionForRemotes @59
-IgniteProjectionForDaemons @60
-IgniteProjectionForRandom @61
-IgniteProjectionForOldest @62
-IgniteProjectionForYoungest @63
-IgniteProcessorCompute @64
-IgniteProcessorMessage @65
-IgniteProcessorEvents @66
-IgniteProjectionResetMetrics @67
-IgniteProjectionOutOpRet @68
-IgniteQueryCursorIterator @69
-IgniteQueryCursorClose @70
-IgniteTransactionsStart @71
-IgniteTransactionsCommit @72
-IgniteTransactionsCommitAsync @73
-IgniteTransactionsRollback @74
-IgniteTransactionsRollbackAsync @75
-IgniteTransactionsClose @76
-IgniteTransactionsState @77
-IgniteTransactionsSetRollbackOnly @78
-IgniteTransactionsResetMetrics @79
-IgniteAcquire @80
-IgniteRelease @81
-IgniteThrowToJava @82
-IgniteHandlersSize @83
-IgniteCreateContext @84
-IgniteDeleteContext @85
-IgniteDestroyJvm @86
-IgniteEventsWithAsync @87
-IgniteEventsStopLocalListen @88
-IgniteEventsLocalListen @89
-IgniteEventsIsEnabled @90
-IgniteTargetOutObject @91
-IgniteServicesWithAsync @92
-IgniteServicesWithServerKeepPortable @93
-IgniteServicesCancel @94
-IgniteServicesCancelAll @95
-IgniteServicesGetServiceProxy @96
-IgniteProcessorExtensions @97
-IgniteProcessorAtomicLong @98
-IgniteAtomicLongGet @99
-IgniteAtomicLongIncrementAndGet @100
-IgniteAtomicLongGetAndIncrement @101
-IgniteAtomicLongAddAndGet @102
-IgniteAtomicLongGetAndAdd @103
-IgniteAtomicLongDecrementAndGet @104
-IgniteAtomicLongGetAndDecrement @105
-IgniteAtomicLongGetAndSet @106
-IgniteAtomicLongCompareAndSetAndGet @107
-IgniteAtomicLongIsClosed @108
-IgniteAtomicLongClose @109
-IgniteListenableCancel @110
-IgniteListenableIsCancelled @111
-IgniteTargetListenFutureAndGet @112
-IgniteTargetListenFutureForOperationAndGet @113
-IgniteProcessorCreateCacheFromConfig @114
-IgniteProcessorGetOrCreateCacheFromConfig @115
-IgniteProcessorGetIgniteConfiguration @116
-IgniteProcessorDestroyCache @117
-IgniteProcessorAtomicSequence @118
-IgniteAtomicSequenceGet @119
-IgniteAtomicSequenceIncrementAndGet @120
-IgniteAtomicSequenceGetAndIncrement @121
-IgniteAtomicSequenceAddAndGet @122
-IgniteAtomicSequenceGetAndAdd @123
-IgniteAtomicSequenceGetBatchSize @124
-IgniteAtomicSequenceSetBatchSize @125
-IgniteAtomicSequenceIsClosed @126
-IgniteAtomicSequenceClose @127
-IgniteProcessorAtomicReference @128
-IgniteAtomicReferenceIsClosed @129
-IgniteAtomicReferenceClose @130
-IgniteProcessorCreateNearCache @131
-IgniteProcessorGetOrCreateNearCache @132
-IgniteProcessorGetCacheNames @133
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/src/common/concurrent.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/common/concurrent.cpp b/modules/platforms/cpp/common/src/common/concurrent.cpp
new file mode 100644
index 0000000..5b62387
--- /dev/null
+++ b/modules/platforms/cpp/common/src/common/concurrent.cpp
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/common/concurrent.h"
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace concurrent
+ {
+ /** Thread-local index generator for application. */
+ int32_t appTlsIdxGen = 0;
+
+ int32_t ThreadLocal::NextIndex()
+ {
+ return Atomics::IncrementAndGet32(&appTlsIdxGen);
+ }
+
+ void ThreadLocal::Remove(int32_t idx)
+ {
+ void* val = Get0();
+
+ if (val)
+ {
+ std::map<int32_t, ThreadLocalEntry*>* map =
+ static_cast<std::map<int32_t, ThreadLocalEntry*>*>(val);
+
+ ThreadLocalEntry* appVal = (*map)[idx];
+
+ if (appVal)
+ delete appVal;
+
+ map->erase(idx);
+
+ if (map->size() == 0)
+ {
+ delete map;
+
+ Set0(NULL);
+ }
+ }
+ }
+
+ void ThreadLocal::Clear0(void* mapPtr)
+ {
+ if (mapPtr)
+ {
+ std::map<int32_t, ThreadLocalEntry*>* map =
+ static_cast<std::map<int32_t, ThreadLocalEntry*>*>(mapPtr);
+
+ for (std::map<int32_t, ThreadLocalEntry*>::iterator it = map->begin(); it != map->end(); ++it)
+ delete it->second;
+
+ delete map;
+ }
+ }
+
+ SharedPointerImpl::SharedPointerImpl(void* ptr, DeleterType deleter) :
+ ptr(ptr), deleter(deleter), refCnt(1)
+ {
+ Memory::Fence();
+ }
+
+ void* SharedPointerImpl::Pointer()
+ {
+ return ptr;
+ }
+
+ const void* SharedPointerImpl::Pointer() const
+ {
+ return ptr;
+ }
+
+ SharedPointerImpl::DeleterType SharedPointerImpl::Deleter()
+ {
+ return deleter;
+ }
+
+ void SharedPointerImpl::Increment()
+ {
+ Atomics::IncrementAndGet32(&refCnt);
+ }
+
+ bool SharedPointerImpl::Decrement()
+ {
+ return Atomics::DecrementAndGet32(&refCnt) == 0;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/src/concurrent.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/concurrent.cpp b/modules/platforms/cpp/common/src/concurrent.cpp
deleted file mode 100644
index 5b62387..0000000
--- a/modules/platforms/cpp/common/src/concurrent.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ignite/common/concurrent.h"
-
-namespace ignite
-{
- namespace common
- {
- namespace concurrent
- {
- /** Thread-local index generator for application. */
- int32_t appTlsIdxGen = 0;
-
- int32_t ThreadLocal::NextIndex()
- {
- return Atomics::IncrementAndGet32(&appTlsIdxGen);
- }
-
- void ThreadLocal::Remove(int32_t idx)
- {
- void* val = Get0();
-
- if (val)
- {
- std::map<int32_t, ThreadLocalEntry*>* map =
- static_cast<std::map<int32_t, ThreadLocalEntry*>*>(val);
-
- ThreadLocalEntry* appVal = (*map)[idx];
-
- if (appVal)
- delete appVal;
-
- map->erase(idx);
-
- if (map->size() == 0)
- {
- delete map;
-
- Set0(NULL);
- }
- }
- }
-
- void ThreadLocal::Clear0(void* mapPtr)
- {
- if (mapPtr)
- {
- std::map<int32_t, ThreadLocalEntry*>* map =
- static_cast<std::map<int32_t, ThreadLocalEntry*>*>(mapPtr);
-
- for (std::map<int32_t, ThreadLocalEntry*>::iterator it = map->begin(); it != map->end(); ++it)
- delete it->second;
-
- delete map;
- }
- }
-
- SharedPointerImpl::SharedPointerImpl(void* ptr, DeleterType deleter) :
- ptr(ptr), deleter(deleter), refCnt(1)
- {
- Memory::Fence();
- }
-
- void* SharedPointerImpl::Pointer()
- {
- return ptr;
- }
-
- const void* SharedPointerImpl::Pointer() const
- {
- return ptr;
- }
-
- SharedPointerImpl::DeleterType SharedPointerImpl::Deleter()
- {
- return deleter;
- }
-
- void SharedPointerImpl::Increment()
- {
- Atomics::IncrementAndGet32(&refCnt);
- }
-
- bool SharedPointerImpl::Decrement()
- {
- return Atomics::DecrementAndGet32(&refCnt) == 0;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/common/src/date.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/date.cpp b/modules/platforms/cpp/common/src/date.cpp
new file mode 100644
index 0000000..2bdcfd5
--- /dev/null
+++ b/modules/platforms/cpp/common/src/date.cpp
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/date.h"
+
+namespace ignite
+{
+ Date::Date() : milliseconds(0)
+ {
+ // No-op.
+ }
+
+ Date::Date(const Date& another) : milliseconds(another.milliseconds)
+ {
+ // No-op.
+ }
+
+ Date::Date(int64_t ms) : milliseconds(ms)
+ {
+ // No-op.
+ }
+
+ Date& Date::operator=(const Date& another)
+ {
+ milliseconds = another.milliseconds;
+
+ return *this;
+ }
+
+ int64_t Date::GetMilliseconds() const
+ {
+ return milliseconds;
+ }
+
+ int64_t Date::GetSeconds() const
+ {
+ return milliseconds / 1000;
+ }
+
+ bool operator==(const Date& val1, const Date& val2)
+ {
+ return val1.milliseconds == val2.milliseconds;
+ }
+
+ bool operator!=(const Date& val1, const Date& val2)
+ {
+ return val1.milliseconds != val2.milliseconds;
+ }
+
+ bool operator<(const Date& val1, const Date& val2)
+ {
+ return val1.milliseconds < val2.milliseconds;
+ }
+
+ bool operator<=(const Date& val1, const Date& val2)
+ {
+ return val1.milliseconds <= val2.milliseconds;
+ }
+
+ bool operator>(const Date& val1, const Date& val2)
+ {
+ return val1.milliseconds > val2.milliseconds;
+ }
+
+ bool operator>=(const Date& val1, const Date& val2)
+ {
+ return val1.milliseconds >= val2.milliseconds;
+ }
+}