ashmem.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* third_party/ashmem/ashmem.h
  2. **
  3. ** Copyright 2008 The Android Open Source Project
  4. **
  5. ** This file is dual licensed. It may be redistributed and/or modified
  6. ** under the terms of the Apache 2.0 License OR version 2 of the GNU
  7. ** General Public License.
  8. */
  9. #ifndef _THIRD_PARTY_ASHMEM_H
  10. #define _THIRD_PARTY_ASHMEM_H
  11. #include <stddef.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* Returns true if the ashmem device is supported on this device.
  16. * Not that even if the device is not supported,
  17. * ashmem_{create,set_prot,get_prot,get_size}_region() will still work
  18. * because they will use the ASharedMemory functions from libandroid.so
  19. * instead. But ashmem_{pin,unpin}_region() will be no-ops.
  20. */
  21. int ashmem_device_is_supported(void);
  22. int ashmem_create_region(const char *name, size_t size);
  23. int ashmem_set_prot_region(int fd, int prot);
  24. int ashmem_get_prot_region(int fd);
  25. int ashmem_pin_region(int fd, size_t offset, size_t len);
  26. int ashmem_unpin_region(int fd, size_t offset, size_t len);
  27. int ashmem_get_size_region(int fd);
  28. #ifdef __cplusplus
  29. }
  30. #endif
  31. #ifndef __ASHMEMIOC /* in case someone included <linux/ashmem.h> too */
  32. #define ASHMEM_NAME_LEN 256
  33. #define ASHMEM_NAME_DEF "dev/ashmem"
  34. /* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */
  35. #define ASHMEM_NOT_PURGED 0
  36. #define ASHMEM_WAS_PURGED 1
  37. /* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */
  38. #define ASHMEM_IS_UNPINNED 0
  39. #define ASHMEM_IS_PINNED 1
  40. #endif /* ! __ASHMEMIOC */
  41. #endif /* _THIRD_PARTY_ASHMEM_H */