Last active
March 19, 2021 19:26
-
-
Save cchan/1ac0a4e4af3f3f6b9db9c813ea4f989c to your computer and use it in GitHub Desktop.
simplesim-3.0 fix for OSX, tested on Big Sur on M1. Run `make sim-tests` to check that it's working for you.
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
--- syscall.c | |
+++ syscall.c | |
@@ -48,6 +48,39 @@ | |
* Copyright (C) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC. | |
*/ | |
+#ifdef __APPLE__ | |
+ | |
+#define __unix__ | |
+#define unix | |
+#include <dirent.h> | |
+#define __osf__ | |
+ | |
+#ifdef _DARWIN_FEATURE_64_BIT_INODE | |
+ | |
+/* Darwin doesn't provide a version of getdirentries with support for 64-bit | |
+ * inodes. When 64-bit inodes are enabled, the getdirentries symbol is mapped | |
+ * to _getdirentries_is_not_available_when_64_bit_inodes_are_in_effect so that | |
+ * we get link errors if we try to use it. We still need getdirentries, but we | |
+ * don't need it to support 64-bit inodes. So, we use the legacy getdirentries | |
+ * with 32-bit inodes. We have to be careful to use a corresponding dirent | |
+ * structure, too. | |
+ */ | |
+int darwin_legacy_getdirentries(int, char *, int, long *) __asm("_getdirentries"); | |
+#define getdirentries darwin_legacy_getdirentries | |
+ | |
+struct darwin_legacy_dirent { | |
+ __uint32_t d_ino; | |
+ __uint16_t d_reclen; | |
+ __uint8_t d_type; | |
+ __uint8_t d_namlen; | |
+ char d_name[__DARWIN_MAXNAMLEN + 1]; | |
+}; | |
+#define dirent darwin_legacy_dirent | |
+ | |
+#endif // _DARWIN_FEATURE_64_BIT_INODE | |
+ | |
+#endif // __APPLE__ | |
+ | |
#include <stdio.h> | |
#include <stdlib.h> | |
@@ -184,7 +217,7 @@ | |
#undef CR0 | |
#endif | |
-#ifdef __FreeBSD__ | |
+#if defined(__FreeBSD__) || defined(__APPLE__) | |
#include <termios.h> | |
/*#include <sys/ioctl_compat.h>*/ | |
#else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment