Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_thread_freertos / public / pw_thread_freertos / id_native.h
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://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, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15
16 #include "FreeRTOS.h"
17 #include "task.h"
18
19 namespace pw::thread::backend {
20
21 // Instead of using a pw::thread::freertos specific identifier, the FreeRTOS
22 // task handle is used as this means pw::this_thread::id works correctly on
23 // threads started with the native FreeRTOS APIs as well as those started
24 // using the pw::thread APIs.
25 class NativeId {
26  public:
27   constexpr NativeId(TaskHandle_t task_handle = nullptr)
28       : task_handle_(task_handle) {}
29
30   constexpr bool operator==(NativeId other) const {
31     return task_handle_ == other.task_handle_;
32   }
33   constexpr bool operator!=(NativeId other) const {
34     return task_handle_ != other.task_handle_;
35   }
36   constexpr bool operator<(NativeId other) const {
37     return task_handle_ < other.task_handle_;
38   }
39   constexpr bool operator<=(NativeId other) const {
40     return task_handle_ <= other.task_handle_;
41   }
42   constexpr bool operator>(NativeId other) const {
43     return task_handle_ > other.task_handle_;
44   }
45   constexpr bool operator>=(NativeId other) const {
46     return task_handle_ >= other.task_handle_;
47   }
48
49  private:
50   TaskHandle_t task_handle_;
51 };
52
53 }  // namespace pw::thread::backend