From 19ed204031d6ffda86e258aadd7b56cf41dd5e9f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 24 Feb 2023 00:41:30 +0000 Subject: [PATCH] Remove inlines for obsolete API levels. The next NDK to take these headers only supports API 21 and later. Test: treehugger Change-Id: I64baf933d3796f20dee5c1465ed58f8bb45394b5 --- .../include/android/legacy_sys_mman_inlines.h | 71 ------------------- libc/include/sys/mman.h | 7 +- 2 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 libc/include/android/legacy_sys_mman_inlines.h diff --git a/libc/include/android/legacy_sys_mman_inlines.h b/libc/include/android/legacy_sys_mman_inlines.h deleted file mode 100644 index 04b3e97f2..000000000 --- a/libc/include/android/legacy_sys_mman_inlines.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#pragma once - -#include - -#if __ANDROID_API__ < 21 - -#include -#include -#include - -__BEGIN_DECLS - -/* - * While this was never an inline, this function alone has caused most of the - * bug reports related to _FILE_OFFSET_BITS=64. Providing an inline for it - * should allow a lot more code to build with _FILE_OFFSET_BITS=64 when - * targeting pre-L. - */ -static __inline void* mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, - off64_t __offset) __RENAME(mmap64); -static __inline void* mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, - off64_t __offset) { - const int __mmap2_shift = 12; // 2**12 == 4096 - if (__offset < 0 || (__offset & ((1UL << __mmap2_shift) - 1)) != 0) { - errno = EINVAL; - return MAP_FAILED; - } - - // prevent allocations large enough for `end - start` to overflow - size_t __rounded = __BIONIC_ALIGN(__size, PAGE_SIZE); - if (__rounded < __size || __rounded > PTRDIFF_MAX) { - errno = ENOMEM; - return MAP_FAILED; - } - - extern void* __mmap2(void* __addr, size_t __size, int __prot, int __flags, int __fd, - size_t __offset); - return __mmap2(__addr, __size, __prot, __flags, __fd, __offset >> __mmap2_shift); -} - -__END_DECLS - -#endif diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h index fea93329d..bcf856dcb 100644 --- a/libc/include/sys/mman.h +++ b/libc/include/sys/mman.h @@ -55,17 +55,14 @@ void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset); #endif -#if __ANDROID_API__ >= 21 /** * mmap64() is a variant of mmap() that takes a 64-bit offset even on LP32. * * See https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md * - * mmap64 wasn't really around until L, but we added an inline for it since it - * allows a lot more code to compile with _FILE_OFFSET_BITS=64. + * Available since API level 21. */ void* mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset) __INTRODUCED_IN(21); -#endif /** * [munmap(2)](http://man7.org/linux/man-pages/man2/munmap.2.html) @@ -232,5 +229,3 @@ int memfd_create(const char* __name, unsigned __flags) __INTRODUCED_IN(30); int posix_madvise(void* __addr, size_t __size, int __advice) __INTRODUCED_IN(23); __END_DECLS - -#include