diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1544,6 +1544,13 @@ #define _LIBCPP_BUILTIN_CONSTANT_P(x) false #endif +// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set +// of functions used in cstdio may not be available for low API levels when +// using 64-bit file offsets on LP32. +#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 +#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio --- a/libcxx/include/cstdio +++ b/libcxx/include/cstdio @@ -131,9 +131,13 @@ using ::ungetc; using ::fread; using ::fwrite; +#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS using ::fgetpos; +#endif using ::fseek; +#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS using ::fsetpos; +#endif using ::ftell; using ::rewind; using ::clearerr; diff --git a/libcxx/test/std/depr/depr.c.headers/no_fgetpos_fsetpos.fail.cpp b/libcxx/test/std/depr/depr.c.headers/no_fgetpos_fsetpos.fail.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/depr/depr.c.headers/no_fgetpos_fsetpos.fail.cpp @@ -0,0 +1,15 @@ +#include + +using T = decltype(::fgetpos); +#ifdef _LIBCPP_HAS_NO_FGETPOS_FSETPOS +// expected-error@-2 {{no such thing}} +#else +// expected-no-diagnostics +#endif + +using U = decltype(::fsetpos); +#ifdef _LIBCPP_HAS_NO_FGETPOS_FSETPOS +// expected-error@-2 {{no such thing}} +#else +// expected-no-diagnostics +#endif diff --git a/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp --- a/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ b/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -156,9 +156,13 @@ static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS static_assert((std::is_same::value), ""); +#endif static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS static_assert((std::is_same::value), ""); +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp b/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp --- a/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp +++ b/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp @@ -120,9 +120,13 @@ static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_FGETPOS static_assert((std::is_same::value), ""); +#endif static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_FSETPOS static_assert((std::is_same::value), ""); +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), "");