replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / c_common / platform_features.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //******************************************************************
20
21 /**
22  * @file
23  *
24  * This file contains compiler and platform feature definitions.  These
25  * can be used to enable functionality on only platforms that support
26  * said functionality.
27  */
28
29 #ifndef PLATFORM_FEATURES_H_
30 #define PLATFORM_FEATURES_H_
31
32 #ifndef __TIZENRT__
33 #  if (__cplusplus >=201103L) || defined(__GXX_EXPERIMENTAL_CXX0X__)
34 #    define SUPPORTS_DEFAULT_CTOR
35 #  endif
36 #endif
37
38 #ifndef __TIZENRT__
39 #  if (__STDC_VERSION__ >= 201112L)
40 #    include <assert.h>
41 #    define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
42 #  elif defined(_WIN32)
43 #    if defined(__msys_nt__) && !defined(__cplusplus)
44 #      define static_assert _Static_assert
45 #    endif
46 #    define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
47 #  else
48 #    define OC_STATIC_ASSERT(condition, msg) ((void)sizeof(char[2*!!(condition) - 1]))
49 #  endif
50 #endif
51
52 #ifndef INLINE_API
53 #  if defined(__cplusplus)
54 #    define INLINE_API inline
55 #  else
56 #    ifdef _MSC_VER
57 #      define INLINE_API static __inline
58 #    else
59 #      define INLINE_API static inline
60 #    endif
61 #  endif
62 #endif
63
64 #ifdef _MSC_VER
65 #  define OC_ANNOTATE_UNUSED
66 #else
67 #  define OC_ANNOTATE_UNUSED  __attribute__((unused))
68 #endif
69
70 #ifdef _WIN32
71 #  define __func__ __FUNCTION__
72 #  define strncasecmp _strnicmp
73 #  define strtok_r strtok_s
74 #  if _MSC_VER && (_MSC_VER < 1900)
75 #    include "windows/include/vs12_snprintf.h"
76 #  endif
77 #  define ssize_t SSIZE_T
78 #  define F_OK                0
79 #  define sleep(SECS)         Sleep(1000*(SECS))
80 #  ifdef __cplusplus
81 #    define SUPPORTS_DEFAULT_CTOR
82 #  endif
83 #  include "windows/include/win_sleep.h"
84 #  include "windows/include/pthread_create.h"
85 #endif
86
87 #ifdef HAVE_WINSOCK2_H
88 #  define OPTVAL_T(t)    (const char*)(t)
89 #else
90 #  define OPTVAL_T(t)    (t)
91 #endif
92
93 #endif