2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
26 #ifndef DO_NOT_USE_AFB
28 #include <afb/afb-binding.h>
32 #define CONCAT_(X, Y) X##Y
33 #define CONCAT(X, Y) CONCAT_(X, Y)
36 #define ATTR_FORMAT(stringindex, firsttocheck) \
37 __attribute__((format(printf, stringindex, firsttocheck)))
38 #define ATTR_NORETURN __attribute__((noreturn))
40 #define ATTR_FORMAT(stringindex, firsttocheck)
44 #ifdef AFB_BINDING_VERSION
45 #define lognotice(...) AFB_NOTICE(__VA_ARGS__)
46 #define logerror(...) AFB_ERROR(__VA_ARGS__)
49 AFB_ERROR(__VA_ARGS__); \
53 #define lognotice(...)
62 #ifdef AFB_BINDING_VERSION
63 #define logdebug(...) AFB_DEBUG(__VA_ARGS__)
76 ScopeTrace __attribute__((unused)) CONCAT(trace_scope_, __LINE__)(__func__)
78 ScopeTrace __attribute__((unused)) CONCAT(named_trace_scope_, __LINE__)(#N)
81 thread_local static int indent;
83 explicit ScopeTrace(char const *func);
93 unique_fd() = default;
94 explicit unique_fd(int f) : fd{f} {}
95 operator int() const { return fd; }
97 unique_fd(unique_fd const &) = delete;
98 unique_fd &operator=(unique_fd const &) = delete;
99 unique_fd(unique_fd &&o) : fd(o.fd) { o.fd = -1; }
100 unique_fd &operator=(unique_fd &&o) {
101 std::swap(this->fd, o.fd);
106 #endif // !WM_UTIL_HPP