1 //===-- PosixSpawnResponsible.h ---------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
10 #define LLDB_HOST_POSIXSPAWNRESPONSIBLE_H
14 #if __has_include(<responsibility.h>)
15 #include <dispatch/dispatch.h>
17 #include <responsibility.h>
19 // Older SDKs have responsibility.h but not this particular function. Let's
20 // include the prototype here.
21 errno_t
responsibility_spawnattrs_setdisclaim(posix_spawnattr_t
*attrs
,
26 static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t
*attr
) {
27 if (@
available(macOS
10.14, *)) {
28 #if __has_include(<responsibility.h>)
29 static __typeof__(responsibility_spawnattrs_setdisclaim
)
30 *responsibility_spawnattrs_setdisclaim_ptr
;
31 static dispatch_once_t pred
;
32 dispatch_once(&pred
, ^{
33 responsibility_spawnattrs_setdisclaim_ptr
=
34 reinterpret_cast<__typeof__(&responsibility_spawnattrs_setdisclaim
)>
35 (dlsym(RTLD_DEFAULT
, "responsibility_spawnattrs_setdisclaim"));
37 if (responsibility_spawnattrs_setdisclaim_ptr
)
38 return responsibility_spawnattrs_setdisclaim_ptr(attr
, true);
44 #endif // LLDB_HOST_POSIXSPAWNRESPONSIBLE_H