mirror of
https://github.com/darlinghq/darling.git
synced 2025-03-03 07:18:35 +00:00
Fix the implementations of posix_spawn_file_actions_*
This commit is contained in:
parent
cc104d148a
commit
ce71ed8deb
55
libmac/mac.c
55
libmac/mac.c
@ -722,16 +722,20 @@ int __darwin_execle(const char* file, const char* arg, ...) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It seems the size of posix_spawn_file_actions_t of Mac is smaller
|
||||||
|
// than Linux so modifying posix_spawn_file_actions_t allocated in
|
||||||
|
// Mac's stack would cause stack overflow. Let's wrap it.
|
||||||
|
|
||||||
int __darwin_posix_spawn(pid_t* pid,
|
int __darwin_posix_spawn(pid_t* pid,
|
||||||
const char* path,
|
const char* path,
|
||||||
const posix_spawn_file_actions_t* file_actions,
|
const posix_spawn_file_actions_t** file_actions,
|
||||||
const posix_spawnattr_t* attrp,
|
const posix_spawnattr_t* attrp,
|
||||||
char* argv[],
|
char* argv[],
|
||||||
char* const envp[]) {
|
char* const envp[]) {
|
||||||
char** new_argv = add_loader_to_argv(argv);
|
char** new_argv = add_loader_to_argv(argv);
|
||||||
int r = posix_spawn(pid,
|
int r = posix_spawn(pid,
|
||||||
__loader_path,
|
__loader_path,
|
||||||
file_actions,
|
*file_actions,
|
||||||
attrp,
|
attrp,
|
||||||
new_argv,
|
new_argv,
|
||||||
envp);
|
envp);
|
||||||
@ -749,6 +753,40 @@ int __darwin_posix_spawnp(pid_t *pid,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __darwin_posix_spawn_file_actions_init(posix_spawn_file_actions_t** p) {
|
||||||
|
*p = (posix_spawn_file_actions_t*)malloc(sizeof(posix_spawn_file_actions_t));
|
||||||
|
return posix_spawn_file_actions_init(*p);
|
||||||
|
}
|
||||||
|
|
||||||
|
int __darwin_posix_spawn_file_actions_destroy(posix_spawn_file_actions_t** p) {
|
||||||
|
int r = posix_spawn_file_actions_destroy(*p);
|
||||||
|
free(*p);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __darwin_posix_spawn_file_actions_addopen(
|
||||||
|
posix_spawn_file_actions_t** file_actions,
|
||||||
|
int fd,
|
||||||
|
const char* path,
|
||||||
|
int oflag,
|
||||||
|
int mode) {
|
||||||
|
return posix_spawn_file_actions_addopen(
|
||||||
|
*file_actions, fd, path, oflag, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int __darwin_posix_spawn_file_actions_addclose(
|
||||||
|
posix_spawn_file_actions_t** file_actions,
|
||||||
|
int fd) {
|
||||||
|
return posix_spawn_file_actions_addclose(*file_actions, fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int __darwin_posix_spawn_file_actions_adddup2(
|
||||||
|
posix_spawn_file_actions_t** file_actions,
|
||||||
|
int fd,
|
||||||
|
int newfd) {
|
||||||
|
return posix_spawn_file_actions_adddup2(*file_actions, fd, newfd);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned int cputype;
|
unsigned int cputype;
|
||||||
@ -927,19 +965,6 @@ char*** _NSGetEnviron() {
|
|||||||
return &environ;
|
return &environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// It seems the size of posix_spawn_file_actions_t of Mac is smaller
|
|
||||||
// than Linux so modifying posix_spawn_file_actions_t allocated in
|
|
||||||
// Mac's stack would cause stack overflow. Let's wrap it.
|
|
||||||
int __darwin_posix_spawn_file_actions_init(posix_spawn_file_actions_t** p) {
|
|
||||||
*p = (posix_spawn_file_actions_t*)malloc(sizeof(posix_spawn_file_actions_t));
|
|
||||||
return posix_spawn_file_actions_init(*p);
|
|
||||||
}
|
|
||||||
int __darwin_posix_spawn_file_actions_destroy(posix_spawn_file_actions_t** p) {
|
|
||||||
int r = posix_spawn_file_actions_destroy(*p);
|
|
||||||
free(*p);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __DARWIN_PTHREAD_MUTEX_NORMAL 0
|
#define __DARWIN_PTHREAD_MUTEX_NORMAL 0
|
||||||
#define __DARWIN_PTHREAD_MUTEX_ERRORCHECK 1
|
#define __DARWIN_PTHREAD_MUTEX_ERRORCHECK 1
|
||||||
#define __DARWIN_PTHREAD_MUTEX_RECURSIVE 2
|
#define __DARWIN_PTHREAD_MUTEX_RECURSIVE 2
|
||||||
|
@ -94,6 +94,12 @@ WRAP(execle)
|
|||||||
WRAP(posix_spawn)
|
WRAP(posix_spawn)
|
||||||
WRAP(posix_spawnp)
|
WRAP(posix_spawnp)
|
||||||
|
|
||||||
|
WRAP(posix_spawn_file_actions_init)
|
||||||
|
WRAP(posix_spawn_file_actions_destroy)
|
||||||
|
WRAP(posix_spawn_file_actions_addopen)
|
||||||
|
WRAP(posix_spawn_file_actions_addclose)
|
||||||
|
WRAP(posix_spawn_file_actions_adddup2)
|
||||||
|
|
||||||
RENAME(CC_MD5_Init, MD5_Init)
|
RENAME(CC_MD5_Init, MD5_Init)
|
||||||
RENAME(CC_MD5_Update, MD5_Update)
|
RENAME(CC_MD5_Update, MD5_Update)
|
||||||
RENAME(CC_MD5_Final, MD5_Final)
|
RENAME(CC_MD5_Final, MD5_Final)
|
||||||
@ -106,9 +112,6 @@ WRAP(signal)
|
|||||||
WRAP(sigaction)
|
WRAP(sigaction)
|
||||||
WRAP(sigaltstack)
|
WRAP(sigaltstack)
|
||||||
|
|
||||||
WRAP(posix_spawn_file_actions_init)
|
|
||||||
WRAP(posix_spawn_file_actions_destroy)
|
|
||||||
|
|
||||||
RENAME(__ashldi3, __ashlti3)
|
RENAME(__ashldi3, __ashlti3)
|
||||||
RENAME(__ashrdi3, __ashrti3)
|
RENAME(__ashrdi3, __ashrti3)
|
||||||
RENAME(__cmpdi2, __cmpti2)
|
RENAME(__cmpdi2, __cmpti2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user