aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-01-26 17:12:11 +0100
committervan Hauser <vh@thc.org>2021-01-26 17:12:11 +0100
commit9c393adbb953fe5bf6809e5b0feca7be2f52b7f8 (patch)
tree2c5f1246f22644c33b76789a0c5d8c3013600793 /include
parente0663c91b9cbf1bdc46593dec4ba11224e6847d7 (diff)
downloadAFLplusplus-9c393adbb953fe5bf6809e5b0feca7be2f52b7f8.tar.gz
real fix plus code format
Diffstat (limited to 'include')
-rw-r--r--include/android-ashmem.h84
1 files changed, 43 insertions, 41 deletions
diff --git a/include/android-ashmem.h b/include/android-ashmem.h
index 6939e06d..91699b27 100644
--- a/include/android-ashmem.h
+++ b/include/android-ashmem.h
@@ -1,81 +1,83 @@
#ifdef __ANDROID__
-#ifndef _ANDROID_ASHMEM_H
-#define _ANDROID_ASHMEM_H
-
-#include <fcntl.h>
-#include <linux/ashmem.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-
-#if __ANDROID_API__ >= 26
-#define shmat bionic_shmat
-#define shmctl bionic_shmctl
-#define shmdt bionic_shmdt
-#define shmget bionic_shmget
-#endif
-#include <sys/shm.h>
-#undef shmat
-#undef shmctl
-#undef shmdt
-#undef shmget
-#include <stdio.h>
-
-#define ASHMEM_DEVICE "/dev/ashmem"
+ #ifndef _ANDROID_ASHMEM_H
+ #define _ANDROID_ASHMEM_H
+
+ #include <fcntl.h>
+ #include <linux/ashmem.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+
+ #if __ANDROID_API__ >= 26
+ #define shmat bionic_shmat
+ #define shmctl bionic_shmctl
+ #define shmdt bionic_shmdt
+ #define shmget bionic_shmget
+ #endif
+ #include <sys/shm.h>
+ #undef shmat
+ #undef shmctl
+ #undef shmdt
+ #undef shmget
+ #include <stdio.h>
+
+ #define ASHMEM_DEVICE "/dev/ashmem"
int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) {
+
int ret = 0;
if (__cmd == IPC_RMID) {
- int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
+
+ int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
struct ashmem_pin pin = {0, length};
ret = ioctl(__shmid, ASHMEM_UNPIN, &pin);
close(__shmid);
+
}
return ret;
+
}
int shmget(key_t __key, size_t __size, int __shmflg) {
- (void) __shmflg;
- int fd, ret;
+
+ (void)__shmflg;
+ int fd, ret;
char ourkey[11];
fd = open(ASHMEM_DEVICE, O_RDWR);
- if (fd < 0)
- return fd;
+ if (fd < 0) return fd;
sprintf(ourkey, "%d", __key);
ret = ioctl(fd, ASHMEM_SET_NAME, ourkey);
- if (ret < 0)
- goto error;
+ if (ret < 0) goto error;
ret = ioctl(fd, ASHMEM_SET_SIZE, __size);
- if (ret < 0)
- goto error;
+ if (ret < 0) goto error;
return fd;
error:
close(fd);
return ret;
+
}
void *shmat(int __shmid, const void *__shmaddr, int __shmflg) {
- (void) __shmflg;
- int size;
+
+ (void)__shmflg;
+ int size;
void *ptr;
size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
- if (size < 0) {
- return NULL;
- }
+ if (size < 0) { return NULL; }
ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0);
- if (ptr == MAP_FAILED) {
- return NULL;
- }
+ if (ptr == MAP_FAILED) { return NULL; }
return ptr;
+
}
-#endif /* !_ANDROID_ASHMEM_H */
-#endif /* !__ANDROID__ */
+ #endif /* !_ANDROID_ASHMEM_H */
+#endif /* !__ANDROID__ */
+