diff --git a/exports.txt b/exports.txt index 77d8b36..2640f41 100644 --- a/exports.txt +++ b/exports.txt @@ -1,5 +1,9 @@ { global: + libandroid_shmctl; + libandroid_shmget; + libandroid_shmat; + libandroid_shmdt; shmctl; shmget; shmat; diff --git a/shm.h b/shm.h index f780a28..faab787 100644 --- a/shm.h +++ b/shm.h @@ -12,15 +12,23 @@ __BEGIN_DECLS #endif /* Shared memory control operations. */ +#undef shmctl +#define shmctl libandroid_shmctl extern int shmctl(int shmid, int cmd, struct shmid_ds* buf); /* Get shared memory area identifier. */ +#undef shmget +#define shmget libandroid_shmget extern int shmget(key_t key, size_t size, int shmflg); /* Attach shared memory segment. */ +#undef shmat +#define shmat libandroid_shmat extern void *shmat(int shmid, void const* shmaddr, int shmflg); /* Detach shared memory segment. */ +#undef shmdt +#define shmdt libandroid_shmdt extern int shmdt(void const* shmaddr); __END_DECLS diff --git a/shmem.c b/shmem.c index 59913f7..89ea3da 100644 --- a/shmem.c +++ b/shmem.c @@ -552,3 +552,13 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf) errno = EINVAL; return -1; } + +/* Make alias for use with e.g. dlopen() */ +#undef shmctl +int shmctl(int shmid, int cmd, struct shmid_ds *buf) __attribute__((alias("libandroid_shmctl"))); +#undef shmget +int shmget(key_t key, size_t size, int flags) __attribute__((alias("libandroid_shmget"))); +#undef shmat +void* shmat(int shmid, void const* shmaddr, int shmflg) __attribute__((alias("libandroid_shmat"))); +#undef shmdt +int shmdt(void const* shmaddr) __attribute__((alias("libandroid_shmdt")));