rcutils
master
C API providing common utilities and data structures.
rcutils
macros.h
Go to the documentation of this file.
1
// Copyright 2017 Open Source Robotics Foundation, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef RCUTILS__MACROS_H_
16
#define RCUTILS__MACROS_H_
17
18
#ifdef __cplusplus
19
extern
"C"
20
{
21
#endif
22
23
#ifndef _WIN32
24
#define RCUTILS_WARN_UNUSED __attribute__((warn_unused_result))
25
#else
26
#define RCUTILS_WARN_UNUSED _Check_return_
27
#endif
28
29
// Note: this block was migrated from rmw/macros.h
30
// This block either sets RCUTILS_THREAD_LOCAL or RCUTILS_THREAD_LOCAL_PTHREAD.
31
#if defined _WIN32 || defined __CYGWIN__
32
// Windows or Cygwin
33
#define RCUTILS_THREAD_LOCAL __declspec(thread)
34
#elif defined __APPLE__
35
// Apple OS's
36
#include <TargetConditionals.h>
37
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
38
// iOS Simulator or iOS device
39
#include <Availability.h>
40
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
41
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
42
// iOS >= 10, thread local storage was added in iOS 10
43
#define RCUTILS_THREAD_LOCAL _Thread_local
44
#else
45
// iOS < 10, no thread local storage, so use pthread instead
46
#define RCUTILS_THREAD_LOCAL_PTHREAD 1
47
#undef RCUTILS_THREAD_LOCAL
48
#endif
49
#else
50
#error "Unknown iOS version"
51
#endif
52
#elif TARGET_OS_MAC
53
// macOS
54
#define RCUTILS_THREAD_LOCAL _Thread_local
55
#else
56
#error "Unknown Apple platform"
57
#endif
58
#else
59
// Some other non-Windows, non-cygwin, non-apple OS
60
#define RCUTILS_THREAD_LOCAL _Thread_local
61
#endif
62
63
#define RCUTILS_STRINGIFY_IMPL(x) #x
64
#define RCUTILS_STRINGIFY(x) RCUTILS_STRINGIFY_IMPL(x)
65
66
#ifdef __cplusplus
67
}
68
#endif
69
70
#endif // RCUTILS__MACROS_H_
Generated by
1.8.14