Fix the implementations of posix_spawn_file_actions_*

This commit is contained in:
Shinichiro Hamaji 2011-04-03 07:40:04 +09:00
parent cc104d148a
commit ce71ed8deb
2 changed files with 46 additions and 18 deletions

View File

@ -722,16 +722,20 @@ int __darwin_execle(const char* file, const char* arg, ...) {
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,
const char* path,
const posix_spawn_file_actions_t* file_actions,
const posix_spawn_file_actions_t** file_actions,
const posix_spawnattr_t* attrp,
char* argv[],
char* const envp[]) {
char** new_argv = add_loader_to_argv(argv);
int r = posix_spawn(pid,
__loader_path,
file_actions,
*file_actions,
attrp,
new_argv,
envp);
@ -749,6 +753,40 @@ int __darwin_posix_spawnp(pid_t *pid,
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 {
const char *name;
unsigned int cputype;
@ -927,19 +965,6 @@ char*** _NSGetEnviron() {
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_ERRORCHECK 1
#define __DARWIN_PTHREAD_MUTEX_RECURSIVE 2

View File

@ -94,6 +94,12 @@ WRAP(execle)
WRAP(posix_spawn)
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_Update, MD5_Update)
RENAME(CC_MD5_Final, MD5_Final)
@ -106,9 +112,6 @@ WRAP(signal)
WRAP(sigaction)
WRAP(sigaltstack)
WRAP(posix_spawn_file_actions_init)
WRAP(posix_spawn_file_actions_destroy)
RENAME(__ashldi3, __ashlti3)
RENAME(__ashrdi3, __ashrti3)
RENAME(__cmpdi2, __cmpti2)