diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-09 15:52:27 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-09 15:52:27 (GMT) |
commit | f95a1b3c53bdd678b64aa608d4375660033460c3 (patch) | |
tree | a8bee40b1b14e28ff5978ea519f3035a3c399912 /Mac | |
parent | bd250300191133d276a71b395b6428081bf825b8 (diff) | |
download | cpython-f95a1b3c53bdd678b64aa608d4375660033460c3.zip cpython-f95a1b3c53bdd678b64aa608d4375660033460c3.tar.gz cpython-f95a1b3c53bdd678b64aa608d4375660033460c3.tar.bz2 |
Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines
Untabify C files. Will watch buildbots.
........
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Tools/pythonw.c | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/Mac/Tools/pythonw.c b/Mac/Tools/pythonw.c index 1f3e0ce..8da6f47 100644 --- a/Mac/Tools/pythonw.c +++ b/Mac/Tools/pythonw.c @@ -39,8 +39,8 @@ extern char** environ; * In a regular framework the structure is: * * Python.framework/Versions/2.7 - * /Python - * /Resources/Python.app/Contents/MacOS/Python + * /Python + * /Resources/Python.app/Contents/MacOS/Python * * In a virtualenv style structure the expected * structure is: @@ -50,121 +50,121 @@ extern char** environ; * /.Python <- the dylib * /.Resources/Python.app/Contents/MacOS/Python * - * NOTE: virtualenv's are not an officially supported + * NOTE: virtualenv's are not an officially supported * feature, support for that structure is provided as * a convenience. */ static char* get_python_path(void) { - size_t len; - Dl_info info; - char* end; - char* g_path; - - if (dladdr(Py_Initialize, &info) == 0) { - return NULL; - } - - len = strlen(info.dli_fname); - - g_path = malloc(len+60); - if (g_path == NULL) { - return NULL; - } - - strcpy(g_path, info.dli_fname); - end = g_path + len - 1; - while (end != g_path && *end != '/') { - end --; - } - end++; - if (*end == '.') { - end++; - } - strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK); - - return g_path; + size_t len; + Dl_info info; + char* end; + char* g_path; + + if (dladdr(Py_Initialize, &info) == 0) { + return NULL; + } + + len = strlen(info.dli_fname); + + g_path = malloc(len+60); + if (g_path == NULL) { + return NULL; + } + + strcpy(g_path, info.dli_fname); + end = g_path + len - 1; + while (end != g_path && *end != '/') { + end --; + } + end++; + if (*end == '.') { + end++; + } + strcpy(end, "Resources/Python.app/Contents/MacOS/" PYTHONFRAMEWORK); + + return g_path; } #ifdef HAVE_SPAWN_H static void setup_spawnattr(posix_spawnattr_t* spawnattr) { - size_t ocount; - size_t count; - cpu_type_t cpu_types[1]; - short flags = 0; + size_t ocount; + size_t count; + cpu_type_t cpu_types[1]; + short flags = 0; #ifdef __LP64__ - int ch; + int ch; #endif - if ((errno = posix_spawnattr_init(spawnattr)) != 0) { - err(2, "posix_spawnattr_int"); - /* NOTREACHTED */ - } + if ((errno = posix_spawnattr_init(spawnattr)) != 0) { + err(2, "posix_spawnattr_int"); + /* NOTREACHTED */ + } - count = 1; + count = 1; - /* Run the real python executable using the same architure as this - * executable, this allows users to controle the architecture using - * "arch -ppc python" - */ + /* Run the real python executable using the same architure as this + * executable, this allows users to controle the architecture using + * "arch -ppc python" + */ #if defined(__ppc64__) - cpu_types[0] = CPU_TYPE_POWERPC64; + cpu_types[0] = CPU_TYPE_POWERPC64; #elif defined(__x86_64__) - cpu_types[0] = CPU_TYPE_X86_64; + cpu_types[0] = CPU_TYPE_X86_64; #elif defined(__ppc__) - cpu_types[0] = CPU_TYPE_POWERPC; + cpu_types[0] = CPU_TYPE_POWERPC; #elif defined(__i386__) - cpu_types[0] = CPU_TYPE_X86; + cpu_types[0] = CPU_TYPE_X86; #else -# error "Unknown CPU" +# error "Unknown CPU" #endif - if (posix_spawnattr_setbinpref_np(spawnattr, count, - cpu_types, &ocount) == -1) { - err(1, "posix_spawnattr_setbinpref"); - /* NOTREACHTED */ - } - if (count != ocount) { - fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n"); - exit(1); - /* NOTREACHTED */ - } - - - /* - * Set flag that causes posix_spawn to behave like execv - */ - flags |= POSIX_SPAWN_SETEXEC; - if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) { - err(1, "posix_spawnattr_setflags"); - /* NOTREACHTED */ - } + if (posix_spawnattr_setbinpref_np(spawnattr, count, + cpu_types, &ocount) == -1) { + err(1, "posix_spawnattr_setbinpref"); + /* NOTREACHTED */ + } + if (count != ocount) { + fprintf(stderr, "posix_spawnattr_setbinpref failed to copy\n"); + exit(1); + /* NOTREACHTED */ + } + + + /* + * Set flag that causes posix_spawn to behave like execv + */ + flags |= POSIX_SPAWN_SETEXEC; + if ((errno = posix_spawnattr_setflags(spawnattr, flags)) != 0) { + err(1, "posix_spawnattr_setflags"); + /* NOTREACHTED */ + } } #endif -int +int main(int argc, char **argv) { - char* exec_path = get_python_path(); + char* exec_path = get_python_path(); #ifdef HAVE_SPAWN_H - /* We're weak-linking to posix-spawnv to ensure that - * an executable build on 10.5 can work on 10.4. - */ - if (posix_spawn != NULL) { - posix_spawnattr_t spawnattr = NULL; - - setup_spawnattr(&spawnattr); - posix_spawn(NULL, exec_path, NULL, - &spawnattr, argv, environ); - err(1, "posix_spawn: %s", exec_path); - } + /* We're weak-linking to posix-spawnv to ensure that + * an executable build on 10.5 can work on 10.4. + */ + if (posix_spawn != NULL) { + posix_spawnattr_t spawnattr = NULL; + + setup_spawnattr(&spawnattr); + posix_spawn(NULL, exec_path, NULL, + &spawnattr, argv, environ); + err(1, "posix_spawn: %s", exec_path); + } #endif - execve(exec_path, argv, environ); - err(1, "execve: %s", argv[0]); - /* NOTREACHED */ + execve(exec_path, argv, environ); + err(1, "execve: %s", argv[0]); + /* NOTREACHED */ } |