|
| 1 | +//===--- Subprocess.cpp - Subprocess Stubs --------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See http://swift.org/LICENSE.txt for license information |
| 9 | +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +// NOTE: preprocess away the availability information to allow use of |
| 14 | +// unsupported APIs on certain targets (i.e. tvOS) |
| 15 | +#define availability(...) |
| 16 | +#include <spawn.h> |
| 17 | +#include <sys/types.h> |
| 18 | +#if defined(__APPLE__) |
| 19 | +// NOTE: forward declare this rather than including crt_externs.h as not all |
| 20 | +// SDKs provide it |
| 21 | +extern char ***_NSGetEnviron(void); |
| 22 | +#endif |
| 23 | + |
| 24 | +int swift_posix_spawn_file_actions_init( |
| 25 | + posix_spawn_file_actions_t *file_actions) { |
| 26 | + return posix_spawn_file_actions_init(file_actions); |
| 27 | +} |
| 28 | + |
| 29 | +int swift_posix_spawn_file_actions_destroy( |
| 30 | + posix_spawn_file_actions_t *file_actions) { |
| 31 | + return posix_spawn_file_actions_destroy(file_actions); |
| 32 | +} |
| 33 | + |
| 34 | +int swift_posix_spawn_file_actions_addclose( |
| 35 | + posix_spawn_file_actions_t *file_actions, int filedes) { |
| 36 | + return posix_spawn_file_actions_addclose(file_actions, filedes); |
| 37 | +} |
| 38 | + |
| 39 | +int swift_posix_spawn_file_actions_adddup2( |
| 40 | + posix_spawn_file_actions_t *file_actions, int filedes, int newfiledes) { |
| 41 | + return posix_spawn_file_actions_adddup2(file_actions, filedes, newfiledes); |
| 42 | +} |
| 43 | + |
| 44 | +int swift_posix_spawn(pid_t *__restrict pid, const char * __restrict path, |
| 45 | + const posix_spawn_file_actions_t *file_actions, |
| 46 | + const posix_spawnattr_t *__restrict attrp, |
| 47 | + char *const argv[__restrict], |
| 48 | + char *const envp[__restrict]) { |
| 49 | + return posix_spawn(pid, path, file_actions, attrp, argv, envp); |
| 50 | +} |
| 51 | + |
| 52 | +#if defined(__APPLE__) |
| 53 | +char ***swift_SwiftPrivateLibcExtras_NSGetEnviron(void) { |
| 54 | + return _NSGetEnviron(); |
| 55 | +} |
| 56 | +#endif |
| 57 | + |
0 commit comments