build: Enable libc++ std::this_thread::sleep_for if unavailable
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Fri, 12 May 2017 13:26:58 +0000 (15:26 +0200)
committerDave Thaler <dthaler@microsoft.com>
Mon, 15 May 2017 17:57:05 +0000 (17:57 +0000)
This was needed to support gcc-4.{6..7} on GNU/Linux Ubuntu 14

So I defined _GLIBCXX_USE_NANOSLEEP if not enabled at configure time,

To avoid messing up configurations it is only set for 4.7 and earlier,
but can extended to other versions if needed (4.8 seems OK).

Also config file is inserted before any header when it was needed.

Observed issue on Ubuntu 14.04.5 x86_64 with g++-4.7 package
(g++ (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3) is:

  resource/src/InProcClientWrapper.cpp: \
  In member function 'void OC::InProcClientWrapper::listeningFunc()': \
  resource/src/InProcClientWrapper.cpp:107:13: \
  error: 'sleep_for' is not a member of 'std::this_thread'

Bug: https://jira.iotivity.org/browse/IOT-2158
Change-Id: Ib63aa289e91cc5926946786ae2ce03525d83a37c
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19831
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
plugins/unittests/plugininterfacetest.cpp
resource/IPCA/samples/ElevatorClient/ElevatorClient.cpp
resource/IPCA/unittests/IPCAElevatorClient.cpp
resource/IPCA/unittests/ipcaunittests.cpp
resource/c_common/platform_features.h
resource/examples/fridgeserver.cpp
resource/src/InProcClientWrapper.cpp
resource/src/InProcServerWrapper.cpp
service/resource-container/unittests/ResourceContainerTest.cpp
service/resource-encapsulation/examples/linux/SeparateResponseServer.cpp

index 44a45b1..71f2194 100644 (file)
@@ -18,6 +18,7 @@
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+#include "iotivity_config.h"
 
 #include "plugininterface.h"
 #include "gtest/gtest.h"
index c26c77d..02f0c80 100644 (file)
@@ -17,6 +17,8 @@
  *
  ******************************************************************/
 
+#include "iotivity_config.h"
+
 #include <mutex>
 #include <array>
 #include <string>
@@ -28,7 +30,6 @@
 #include <condition_variable>
 #include <climits>
 
-#include "iotivity_config.h"
 #include "ipca.h"
 #include "OCFDevice.h"
 
index 44e1b3e..de40ec1 100644 (file)
  *
  ******************************************************************/
 
+#include "iotivity_config.h"
+
 #include <thread>
 #include <chrono>
 #include <mutex>
 #include <condition_variable>
 
 #include "gtest/gtest.h"
-#include "iotivity_config.h"
 #include "ocrandom.h"
 #include "octypes.h"
 #include "oic_time.h"
index f5617da..4bedbf5 100644 (file)
@@ -17,6 +17,8 @@
  *
  ******************************************************************/
 
+#include "iotivity_config.h"
+
 #include <thread>
 #include <chrono>
 #include <mutex>
index 79d39b8..5f03d39 100644 (file)
         typedef int OC_CAT(StaticAssertTemp, __LINE__)[2 * !!(condition) - 1]
 #endif
 
+#if !(defined _GLIBCXX_USE_NANOSLEEP) \
+  && defined(__GNUC__) && (4 == __GNUC__) && (7 >= __GNUC_MINOR__)
+#  define  _GLIBCXX_USE_NANOSLEEP 1
+#endif
+
 #ifndef INLINE_API
 #  if defined(__cplusplus)
 #    define INLINE_API inline
index 964f9b6..d36bd97 100644 (file)
@@ -24,6 +24,8 @@
 /// demonstrate using std::bind to attach to instances of a class as well as using
 /// constructResourceObject
 
+#include "iotivity_config.h"
+
 #include <chrono>
 #include <iostream>
 #include <thread>
index dfd1927..c3a1913 100644 (file)
@@ -18,6 +18,8 @@
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+#include "iotivity_config.h"
+
 #include "InProcClientWrapper.h"
 #include "ocstack.h"
 
index 3a6f368..c2140c5 100644 (file)
@@ -18,6 +18,8 @@
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+#include "iotivity_config.h"
+
 #include <random>
 #include <cstring>
 #include <cstdlib>
index 423e8e1..989def0 100644 (file)
@@ -18,6 +18,8 @@
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+#include "iotivity_config.h"
+
 #if defined(__linux__)
 #include <unistd.h>
 #endif
index 1a76655..e7f29d2 100644 (file)
@@ -18,6 +18,8 @@
  *
  ******************************************************************/
 
+#include "iotivity_config.h"
+
 #include "RCSResourceObject.h"
 #include "RCSRequest.h"
 #include "RCSSeparateResponse.h"