Created
April 10, 2018 20:50
-
-
Save renesugar/cf87a9107ad73b40b8487c7c226f5084 to your computer and use it in GitHub Desktop.
Compiling valgrind on Mac OS 10.13.4 (High Sierra)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Valgrind compile error on Mac OS 10.13.4: | |
m_syswrap/syswrap-generic.c:1797:26: error: variable has incomplete type 'struct vki_semid64_ds' | |
struct vki_semid64_ds buf; | |
^ | |
m_syswrap/syswrap-generic.c:1797:11: note: forward declaration of 'struct vki_semid64_ds' | |
struct vki_semid64_ds buf; | |
^ | |
m_syswrap/syswrap-generic.c:1798:8: error: no member named 'buf64' in 'union semun' | |
arg.buf64 = &buf; | |
~~~ ^ | |
2 errors generated. | |
See: | |
https://github.com/apple/darwin-xnu/blob/master/bsd/sys/sem.h | |
https://wiki.freebsd.org/Valgrind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h | |
index 53d14f322..2ff4a77b7 100644 | |
--- a/include/vki/vki-darwin.h | |
+++ b/include/vki/vki-darwin.h | |
@@ -690,8 +690,32 @@ typedef | |
#define vki_sembuf sembuf | |
#define vki_semid_ds semid_ds | |
-#define vki_semun semun | |
+// https://github.com/apple/darwin-xnu/blob/master/bsd/sys/sem_internal.h | |
+ | |
+typedef __int64_t user64_time_t; | |
+ | |
+#pragma pack(4) | |
+struct vki_semid64_ds { | |
+ struct ipc_perm sem_perm; /* [XSI] operation permission struct */ | |
+ int32_t sem_base; /* 32 bit base ptr for semaphore set */ | |
+ unsigned short sem_nsems; /* [XSI] number of sems in set */ | |
+ user64_time_t sem_otime; /* [XSI] last operation time */ | |
+ int32_t sem_pad1; /* RESERVED: DO NOT USE! */ | |
+ user64_time_t sem_ctime; /* [XSI] last change time */ | |
+ /* Times measured in secs since */ | |
+ /* 00:00:00 GMT, Jan. 1, 1970 */ | |
+ int32_t sem_pad2; /* RESERVED: DO NOT USE! */ | |
+ int32_t sem_pad3[4]; /* RESERVED: DO NOT USE! */ | |
+}; | |
+ | |
+union vki_semun { | |
+ int val; /* value for SETVAL */ | |
+ struct vki_semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ | |
+ struct vki_semid64_ds *buf64; /* buffer for IPC_STAT & IPC_SET */ | |
+ unsigned short *array; /* array for GETALL & SETALL */ | |
+}; | |
+#pragma pack() | |
#include <sys/semaphore.h> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really helpful. Thank you.