From 2d30fe48d495a7d0e6bd8c27d5c7ca3f3420afaa Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 10 Aug 2020 16:06:09 +0900 Subject: [PATCH] Remove __ANDROID_API__ guards __ANDROID_API__ guards are removed in favor of __INTRODUCED_IN macros. Currently, __INTRODUCED_IN macro does nothing for these headers (it's meaningful only to the headers processed by versioner which are limited to binic headers). The plan is to make the macros to tag the declaration with the availability attribute. Then, when the min_sdk_version of a caller is set to an API level that is older than the API level of the APIs, the compiler will provide them as weak symbols and enforce that calling the APIs are guarded with a runtime check. For now, these guards are preventing from making a build system change to let __ANDROID_API__ track the min_sdk_version property instead of the sdk_version property. With the build system change, __ANDROID_API__ will suddenly drop for the native modules where min_sdk_version < sdk_version, which is the case when the modules are included in APEXes. As a result, some new APIs will be unavailable at build-time. Dropping the hand-written guards fixes the problem. Bug: 163288375 Test: m Change-Id: If1cc6b9af410f536abe6d777c22711209fa76530 --- libprocessgroup/cgrouprc/include/android/cgrouprc.h | 8 -------- libsync/include/ndk/sync.h | 4 ---- 2 files changed, 12 deletions(-) diff --git a/libprocessgroup/cgrouprc/include/android/cgrouprc.h b/libprocessgroup/cgrouprc/include/android/cgrouprc.h index 7e74432f7..9a799547d 100644 --- a/libprocessgroup/cgrouprc/include/android/cgrouprc.h +++ b/libprocessgroup/cgrouprc/include/android/cgrouprc.h @@ -28,8 +28,6 @@ __BEGIN_DECLS struct ACgroupController; typedef struct ACgroupController ACgroupController; -#if __ANDROID_API__ >= __ANDROID_API_Q__ - // ACgroupFile /** @@ -71,8 +69,6 @@ __attribute__((warn_unused_result)) uint32_t ACgroupController_getVersion(const #define CGROUPRC_CONTROLLER_FLAG_MOUNTED 0x1 #define CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION 0x2 -#if __ANDROID_API__ >= __ANDROID_API_R__ - /** * Returns the flags bitmask of the given controller. * If the given controller is null, return 0. @@ -80,8 +76,6 @@ __attribute__((warn_unused_result)) uint32_t ACgroupController_getVersion(const __attribute__((warn_unused_result, weak)) uint32_t ACgroupController_getFlags( const ACgroupController*) __INTRODUCED_IN(30); -#endif - /** * Returns the name of the given controller. * If the given controller is null, return nullptr. @@ -97,5 +91,3 @@ __attribute__((warn_unused_result)) const char* ACgroupController_getPath(const __INTRODUCED_IN(29); __END_DECLS - -#endif diff --git a/libsync/include/ndk/sync.h b/libsync/include/ndk/sync.h index 2a59e35bb..38ccb686c 100644 --- a/libsync/include/ndk/sync.h +++ b/libsync/include/ndk/sync.h @@ -33,8 +33,6 @@ __BEGIN_DECLS -#if __ANDROID_API__ >= 26 - /* Fences indicate the status of an asynchronous task. They are initially * in unsignaled state (0), and make a one-time transition to either signaled * (1) or error (< 0) state. A sync file is a collection of one or more fences; @@ -101,8 +99,6 @@ static inline struct sync_fence_info* sync_get_fence_info(const struct sync_file */ void sync_file_info_free(struct sync_file_info* info) __INTRODUCED_IN(26); -#endif /* __ANDROID_API__ >= 26 */ - __END_DECLS #endif /* ANDROID_SYNC_H */