mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-27 05:50:27 +00:00
fix Linux build
This commit is contained in:
parent
402aa391dd
commit
4e3081a7a1
23
objc/dyld.c
23
objc/dyld.c
@ -1,10 +1,13 @@
|
||||
#import <objc/dyld.h>
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 8192
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
#import <windows.h>
|
||||
|
||||
#define MAXPATHLEN 8192
|
||||
|
||||
int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
int bufferCapacity = MAXPATHLEN;
|
||||
@ -36,8 +39,8 @@ int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
#elif defined(LINUX)
|
||||
|
||||
int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
if(*capacity < PATH_MAX)
|
||||
return PATH_MAX;
|
||||
if(*capacity < MAXPATHLEN)
|
||||
return MAXPATHLEN;
|
||||
|
||||
if((*capacity = readlink("/proc/self/exe", path, *capacity)) < 0) {
|
||||
*capacity = 0;
|
||||
@ -55,8 +58,8 @@ extern int _NSGetExecutablePath(char *path, uint32_t *capacity);
|
||||
|
||||
int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
#if defined(FREEBSD)
|
||||
if(*capacity < PATH_MAX)
|
||||
return PATH_MAX;
|
||||
if(*capacity < MAXPATHLEN)
|
||||
return MAXPATHLEN;
|
||||
|
||||
int mib[4];
|
||||
|
||||
@ -75,8 +78,8 @@ int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
|
||||
return 0;
|
||||
#else
|
||||
if(*capacity < PATH_MAX)
|
||||
return PATH_MAX;
|
||||
if(*capacity < MAXPATHLEN)
|
||||
return MAXPATHLEN;
|
||||
|
||||
int length;
|
||||
|
||||
@ -93,10 +96,10 @@ int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
#elif defined(SOLARIS)
|
||||
|
||||
int _NSGetExecutablePath(char *path, uint32_t *capacity) {
|
||||
if(*capacity < PATH_MAX)
|
||||
return PATH_MAX;
|
||||
if(*capacity < MAXPATHLEN)
|
||||
return MAXPATHLEN;
|
||||
|
||||
char probe[PATH_MAX + 1];
|
||||
char probe[MAXPATHLEN + 1];
|
||||
|
||||
sprintf(probe, "/proc/%ld/path/a.out", (long)getpid());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user