android_stub.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. /* This file allows NSS to build by stubbing out
  5. * features that aren't provided by Android/Bionic */
  6. #ifndef ANDROID_STUB_H
  7. #define ANDROID_STUB_H
  8. /* sysinfo is defined but not implemented.
  9. * we may be able to implement it ourselves. */
  10. #define _SYS_SYSINFO_H_
  11. #include <sys/cdefs.h>
  12. #include <sys/resource.h>
  13. #include <linux/kernel.h>
  14. #include <unistd.h>
  15. #ifndef ANDROID_VERSION
  16. #include <android/api-level.h>
  17. #define ANDROID_VERSION __ANDROID_API__
  18. #endif
  19. /* Use this stub version of getdtablesize
  20. * instead of the one in the header */
  21. __attribute__((unused))
  22. static int getdtablesize_stub(void)
  23. {
  24. struct rlimit r;
  25. if (getrlimit(RLIMIT_NOFILE, &r) < 0) {
  26. return sysconf(_SC_OPEN_MAX);
  27. }
  28. return r.rlim_cur;
  29. }
  30. #define getdtablesize() getdtablesize_stub()
  31. #if ANDROID_VERSION < 21
  32. #define RTLD_NOLOAD 0
  33. #endif
  34. #define sysinfo(foo) -1
  35. #endif /* ANDROID_STUB_H */