-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support new symbol names on older systems
__bzero does not exist on older system but bzero does. dirfd is macro on older systems but a library symbol on newer ones. fstatat$INODE64 exists on newer systems. Its functionality can replicated by fstatat64.
- Loading branch information
1 parent
61263ec
commit a1e2bb0
Showing
5 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2024 | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
/* MP support header */ | ||
#include "MacportsLegacySupport.h" | ||
|
||
#if __MP_LEGACY_SUPPORT_SYMBOL____bzero__ | ||
#include <strings.h> | ||
/* | ||
The need for this function is highly limited. | ||
The symbol `__bzero` does not exist prior to 10.6. | ||
When the Rust stage0 compiler for 10.5 is built on newer machines, it bakes `__bzero` into librustc_driver-xxx.dylib. | ||
This may be due to the fact that on newer machines, the `_bzero` symbol is an indirect reference to another symbol. | ||
*/ | ||
void __bzero(void *s, size_t n) { bzero(s, n); } | ||
#endif /* __MP_LEGACY_SUPPORT_SYMBOL_ALIASES__ */ | ||
|
||
#if __MP_LEGACY_SUPPORT_SYMBOL__dirfd__ | ||
#include <dirent.h> | ||
#include <errno.h> | ||
/* | ||
The need for this function is highly limited. | ||
Prior to 10.8, `dirfd` was a macro`. | ||
The Rust compiler requires `dirfd` to be a library symbol. | ||
*/ | ||
#undef dirfd | ||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 | ||
#define __dd_fd dd_fd | ||
#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 */ | ||
int dirfd(DIR *dirp) | ||
{ | ||
if (dirp == NULL || dirp->__dd_fd < 0) | ||
{ | ||
errno = EINVAL; | ||
return -1; | ||
} | ||
else | ||
return dirp->__dd_fd; | ||
} | ||
#endif /* __MP_LEGACY_SUPPORT_SYMBOL__dirfd__ */ | ||
|
||
#if __MP_LEGACY_SUPPORT_ATCALLS__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 | ||
#include <sys/stat.h> | ||
/* | ||
The need for this function is highly limited. | ||
The Rust compiler requires `fstatat$INODE64` to be a library symbol. | ||
*/ | ||
int fstatat$INODE64(int dirfd, const char *pathname, struct stat64 *buf, int flags) { return fstatat64(dirfd, pathname, buf, flags); } | ||
#endif /* __MP_LEGACY_SUPPORT_ATCALLS__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <dlfcn.h> | ||
#include <assert.h> | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
void (*fptr)(); | ||
|
||
// void __bzero(void *s, size_t n); | ||
fptr = dlsym(RTLD_DEFAULT, "__bzero"); | ||
assert( fptr!=0 && "__bzero symbol does not exist"); | ||
|
||
// int dirfd(DIR *dirp); | ||
fptr = dlsym(RTLD_DEFAULT, "dirfd"); | ||
assert( fptr!=0 && "dirfd symbol does not exist"); | ||
|
||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 && !defined(__arm64__) | ||
// int fstatat$INODE64(int dirfd, const char *pathname, struct stat64 *buf, int flags); | ||
fptr = dlsym(RTLD_DEFAULT, "fstatat$INODE64"); | ||
assert( fptr!=0 && "fstatat$INODE64 symbol does not exist"); | ||
#endif | ||
|
||
printf("All symbol aliases found\n"); | ||
|
||
return 0; | ||
} |
a1e2bb0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarcusCalhoun-Lopez Some header was forgotten? Or it builds for everyone but me?
a1e2bb0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out this error.
It should be fixed by #81.