On 12/06/2012 01:41 AM, Dmitry Antipov wrote:
The kernel uses (drivers/staging/android/ashmem.h):
#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin) #define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
Generated bionic header uses (bionic/libc/kernel/common/linux/ashmem.h):
#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin) #define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
But frameworks/native/include/utils/ashmem.h uses:
#define ASHMEM_PIN _IO(__ASHMEMIOC, 7) #define ASHMEM_UNPIN _IO(__ASHMEMIOC, 8)
Due to the above, any userspace call ioctl(fd, ASHMEM_PIN, XXX) is invalid.
Also there is a name mismatch: kernel uses ASHMEM_GET_PIN_STATUS for ioctl and ASHMEM_IS_PINNED / ASHMEM_IS_UNPINNED for the result, but userspace uses ASHMEM_ISPINNED for ioctl and ASHMEM_NOW_PINNED / ASHMEM_NOW_UNPINNED for the result. This is pretty confusing and IMHO should be unified between kernel and userspace headers.
Suggested fix for frameworks/native/include/utils/ashmem.h is attached.
This looks right to me. Seems like that ashmem.h is just really old. You should submit this to AOSP.
One suggestion: For your own test case, you might want to copy in the kernel's (or bionic's) ashmem.h into the test, rather then including the frameworks/native..../ashmem.h header, as this will allow the test case to build with both standard GNU as well as Android environments.
thanks -john