1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 #ifndef ANDROID_SENSORHAL_EXT_UTILS_H 17 #define ANDROID_SENSORHAL_EXT_UTILS_H 18 19 // Host build does not have RefBase 20 #ifdef __ANDROID__ 21 #include <utils/RefBase.h> 22 #define REF_BASE(a) ::android::RefBase 23 #define SP(a) sp<a> 24 #define WP(a) wp<a> 25 #define SP_THIS this 26 #define PROMOTE(a) (a).promote() 27 #else 28 #include <memory> 29 #define REF_BASE(a) std::enable_shared_from_this<a> 30 #define SP(a) std::shared_ptr<a> 31 #define WP(a) std::weak_ptr<a> 32 #define SP_THIS shared_from_this() 33 #define PROMOTE(a) (a).lock() 34 #endif 35 36 #endif // ANDROID_SENSORHAL_EXT_UTILS_H 37