init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
12
Telegram/ThirdParty/dispatch/os/CMakeLists.txt
vendored
Normal file
12
Telegram/ThirdParty/dispatch/os/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
# TODO(compnerd) ensure that object_private.h voucher_activity_private.h
|
||||
# voucher_private.h are included in the source tarball
|
||||
|
||||
install(FILES
|
||||
generic_base.h
|
||||
generic_unix_base.h
|
||||
generic_win_base.h
|
||||
object.h
|
||||
DESTINATION
|
||||
"${INSTALL_OS_HEADERS_DIR}")
|
||||
|
||||
161
Telegram/ThirdParty/dispatch/os/firehose_buffer_private.h
vendored
Normal file
161
Telegram/ThirdParty/dispatch/os/firehose_buffer_private.h
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __FIREHOSE_BUFFER_PRIVATE__
|
||||
#define __FIREHOSE_BUFFER_PRIVATE__
|
||||
|
||||
#if OS_FIREHOSE_SPI
|
||||
#ifdef KERNEL
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <os/base.h>
|
||||
#include <os/availability.h>
|
||||
#include <os/base_private.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
#define OS_FIREHOSE_SPI_VERSION 20180226
|
||||
|
||||
/*!
|
||||
* @group Firehose SPI
|
||||
* SPI intended for logd only
|
||||
* Layout of structs is subject to change without notice
|
||||
*/
|
||||
|
||||
#define FIREHOSE_BUFFER_LIBTRACE_HEADER_SIZE 2048ul
|
||||
#define FIREHOSE_BUFFER_KERNEL_MIN_CHUNK_COUNT 16
|
||||
#define FIREHOSE_BUFFER_KERNEL_MAX_CHUNK_COUNT 64
|
||||
|
||||
typedef struct firehose_buffer_range_s {
|
||||
uint16_t fbr_offset; // offset from the start of the buffer
|
||||
uint16_t fbr_length;
|
||||
} *firehose_buffer_range_t;
|
||||
|
||||
#ifdef KERNEL
|
||||
|
||||
typedef struct firehose_chunk_s *firehose_chunk_t;
|
||||
|
||||
// implemented by the kernel
|
||||
extern void __firehose_buffer_push_to_logd(firehose_buffer_t fb, bool for_io);
|
||||
extern void __firehose_critical_region_enter(void);
|
||||
extern void __firehose_critical_region_leave(void);
|
||||
extern void __firehose_allocate(vm_offset_t *addr, vm_size_t size);
|
||||
extern uint8_t __firehose_buffer_kernel_chunk_count;
|
||||
extern uint8_t __firehose_num_kernel_io_pages;
|
||||
|
||||
#define FIREHOSE_BUFFER_KERNEL_DEFAULT_CHUNK_COUNT FIREHOSE_BUFFER_KERNEL_MIN_CHUNK_COUNT
|
||||
#define FIREHOSE_BUFFER_KERNEL_DEFAULT_IO_PAGES 8
|
||||
|
||||
#define FIREHOSE_BUFFER_KERNEL_CHUNK_COUNT __firehose_buffer_kernel_chunk_count
|
||||
#define FIREHOSE_BUFFER_CHUNK_PREALLOCATED_COUNT (__firehose_buffer_kernel_chunk_count - 1) // the first chunk is the header
|
||||
|
||||
// exported for the kernel
|
||||
firehose_tracepoint_t
|
||||
__firehose_buffer_tracepoint_reserve(uint64_t stamp, firehose_stream_t stream,
|
||||
uint16_t pubsize, uint16_t privsize, uint8_t **privptr);
|
||||
|
||||
void
|
||||
__firehose_buffer_tracepoint_flush(firehose_tracepoint_t vat,
|
||||
firehose_tracepoint_id_u vatid);
|
||||
|
||||
firehose_buffer_t
|
||||
__firehose_buffer_create(size_t *size);
|
||||
|
||||
void
|
||||
__firehose_merge_updates(firehose_push_reply_t update);
|
||||
|
||||
int
|
||||
__firehose_kernel_configuration_valid(uint8_t chunk_count, uint8_t io_pages);
|
||||
|
||||
#else
|
||||
|
||||
#define __firehose_critical_region_enter()
|
||||
#define __firehose_critical_region_leave()
|
||||
|
||||
OS_EXPORT
|
||||
const uint32_t _firehose_spi_version;
|
||||
|
||||
OS_ALWAYS_INLINE
|
||||
static inline const uint8_t *
|
||||
_firehose_tracepoint_reader_init(firehose_chunk_t fc, const uint8_t **endptr)
|
||||
{
|
||||
const uint8_t *start = fc->fc_data;
|
||||
const uint8_t *end = fc->fc_start + fc->fc_pos.fcp_next_entry_offs;
|
||||
|
||||
if (end > fc->fc_start + FIREHOSE_CHUNK_SIZE) {
|
||||
end = start;
|
||||
}
|
||||
*endptr = end;
|
||||
return start;
|
||||
}
|
||||
|
||||
OS_ALWAYS_INLINE
|
||||
static inline firehose_tracepoint_t
|
||||
_firehose_tracepoint_reader_next(const uint8_t **ptr, const uint8_t *end)
|
||||
{
|
||||
const uint16_t ft_size = offsetof(struct firehose_tracepoint_s, ft_data);
|
||||
struct ft_unaligned_s {
|
||||
struct firehose_tracepoint_s ft;
|
||||
} __attribute__((packed, aligned(1))) *uft;
|
||||
|
||||
do {
|
||||
uft = (struct ft_unaligned_s *)*ptr;
|
||||
if (uft->ft.ft_data >= end) {
|
||||
// reached the end
|
||||
return NULL;
|
||||
}
|
||||
if (!uft->ft.ft_length) {
|
||||
// tracepoint write didn't even start
|
||||
return NULL;
|
||||
}
|
||||
if (uft->ft.ft_length > end - uft->ft.ft_data) {
|
||||
// invalid length
|
||||
return NULL;
|
||||
}
|
||||
*ptr += roundup(ft_size + uft->ft.ft_length, 8);
|
||||
// test whether write of the tracepoint was finished
|
||||
} while (os_unlikely(uft->ft.ft_id.ftid_value == 0));
|
||||
|
||||
return (firehose_tracepoint_t)uft;
|
||||
}
|
||||
|
||||
#define firehose_tracepoint_foreach(ft, fbc) \
|
||||
for (const uint8_t *end, *p = _firehose_tracepoint_reader_init(fbc, &end); \
|
||||
((ft) = _firehose_tracepoint_reader_next(&p, end)); )
|
||||
|
||||
OS_ALWAYS_INLINE
|
||||
static inline bool
|
||||
firehose_buffer_range_validate(firehose_chunk_t fc, firehose_tracepoint_t ft,
|
||||
firehose_buffer_range_t range)
|
||||
{
|
||||
if (range->fbr_offset + range->fbr_length > FIREHOSE_CHUNK_SIZE) {
|
||||
return false;
|
||||
}
|
||||
if (fc->fc_start + range->fbr_offset < ft->ft_data + ft->ft_length) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // !KERNEL
|
||||
|
||||
#endif // OS_FIREHOSE_SPI
|
||||
|
||||
#endif // __FIREHOSE_BUFFER_PRIVATE__
|
||||
484
Telegram/ThirdParty/dispatch/os/firehose_server_private.h
vendored
Normal file
484
Telegram/ThirdParty/dispatch/os/firehose_server_private.h
vendored
Normal file
@@ -0,0 +1,484 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __FIREHOSE_SERVER_PRIVATE__
|
||||
#define __FIREHOSE_SERVER_PRIVATE__
|
||||
|
||||
#include <os/base.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
#include "firehose_buffer_private.h"
|
||||
|
||||
#if OS_FIREHOSE_SPI
|
||||
/*!
|
||||
* @group Firehose SPI
|
||||
* SPI intended for logd only
|
||||
*/
|
||||
|
||||
#pragma mark - Firehose Client
|
||||
|
||||
/*!
|
||||
* @typedef firehose_client_t
|
||||
*
|
||||
* @abstract
|
||||
* Represents a firehose client.
|
||||
*
|
||||
* @discussion
|
||||
* Firehose client objects are os_object_t's, and it's legal to retain/release
|
||||
* them with os_retain / os_release.
|
||||
*/
|
||||
OS_OBJECT_DECL_CLASS(firehose_client);
|
||||
|
||||
/*!
|
||||
* @typedef firehose_event_t
|
||||
*
|
||||
* @const FIREHOSE_EVENT_NONE
|
||||
* Never passed to callbacks, meaningful for
|
||||
* firehose_client_metadata_stream_peek.
|
||||
*
|
||||
* @const FIREHOSE_EVENT_CLIENT_CONNECTED
|
||||
* A new client has connected
|
||||
*
|
||||
* This is the first event delivered, and no event is delivered until
|
||||
* the handler of that event returns
|
||||
*
|
||||
* The `page` argument is really a firehose_client_connected_info_t. The
|
||||
* `fc_pos` argument is not meaningful.
|
||||
*
|
||||
* @const FIREHOSE_EVENT_CLIENT_DIED
|
||||
* The specified client is gone and will not flush new buffers
|
||||
*
|
||||
* This is the last event delivered, it is never called before all other
|
||||
* event handlers have returned. This event is generated even when a
|
||||
* FIREHOSE_EVENT_CLIENT_CORRUPTED event has been generated.
|
||||
*
|
||||
* @const FIREHOSE_EVENT_IO_BUFFER_RECEIVED
|
||||
* A new buffer needs to be pushed; `page` is set to that buffer, and `fc_pos`
|
||||
* to its chunk position header.
|
||||
*
|
||||
* This event can be sent concurrently wrt FIREHOSE_EVENT_MEM_BUFFER_RECEIVED
|
||||
* events.
|
||||
*
|
||||
* @const FIREHOSE_EVENT_MEM_BUFFER_RECEIVED
|
||||
* A new buffer needs to be pushed; `page` is set to that buffer, and `fc_pos`
|
||||
* to its chunk position header.
|
||||
*
|
||||
* This event can be sent concurrently wrt FIREHOSE_EVENT_IO_BUFFER_RECEIVED
|
||||
* events.
|
||||
*
|
||||
* @const FIREHOSE_EVENT_CLIENT_CORRUPTED
|
||||
* This event is received when a client is found being corrupted.
|
||||
* `page` is set to the buffer header page, and `fc_pos` is not meaningful. When
|
||||
* this event is received, logs have likely been lost for this client.
|
||||
*
|
||||
* This buffer isn't really a proper firehose buffer page, but its content may
|
||||
* be useful for debugging purposes.
|
||||
*
|
||||
* @const FIREHOSE_EVENT_CLIENT_FINALIZE
|
||||
* This event is received when a firehose client structure is about to be
|
||||
* destroyed. Only firehose_client_get_context() can ever be called with
|
||||
* the passed firehose client. The `page` argument is NULL for this event, and
|
||||
* the `fc_pos` argument is not meaningful.
|
||||
*
|
||||
* The event is sent from the context that is dropping the last refcount
|
||||
* of the client.
|
||||
*/
|
||||
OS_ENUM(firehose_event, unsigned long,
|
||||
FIREHOSE_EVENT_NONE = 0,
|
||||
FIREHOSE_EVENT_CLIENT_CONNECTED,
|
||||
FIREHOSE_EVENT_CLIENT_DIED,
|
||||
FIREHOSE_EVENT_IO_BUFFER_RECEIVED,
|
||||
FIREHOSE_EVENT_MEM_BUFFER_RECEIVED,
|
||||
FIREHOSE_EVENT_CLIENT_CORRUPTED,
|
||||
FIREHOSE_EVENT_CLIENT_FINALIZE,
|
||||
);
|
||||
|
||||
#define FIREHOSE_CLIENT_CONNECTED_INFO_VERSION 1
|
||||
|
||||
/*!
|
||||
* @typedef firehose_client_connected_info
|
||||
*
|
||||
* @abstract
|
||||
* Type of the data passed to CLIENT_CONNECTED events.
|
||||
*/
|
||||
typedef struct firehose_client_connected_info_s {
|
||||
unsigned long fcci_version;
|
||||
// version 1
|
||||
const void *fcci_data;
|
||||
size_t fcci_size;
|
||||
} *firehose_client_connected_info_t;
|
||||
|
||||
/*!
|
||||
* @function firehose_client_get_unique_pid
|
||||
*
|
||||
* @abstract
|
||||
* Returns the unique pid of the specified firehose client
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*
|
||||
* @param pid
|
||||
* The pid for this client.
|
||||
*
|
||||
* @returns
|
||||
* The unique pid of the specified client.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
uint64_t
|
||||
firehose_client_get_unique_pid(firehose_client_t client, pid_t *pid);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_get_pid_version
|
||||
*
|
||||
* @abstract
|
||||
* Returns the pid version for that client.
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
int
|
||||
firehose_client_get_pid_version(firehose_client_t client);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_get_euid
|
||||
*
|
||||
* @abstract
|
||||
* Returns the EUID for that client as discovered at connect time.
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
uid_t
|
||||
firehose_client_get_euid(firehose_client_t client);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_get_metadata_buffer
|
||||
*
|
||||
* @abstract
|
||||
* Returns the metadata buffer for the specified firehose client
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*
|
||||
* @param size
|
||||
* The size of the metadata buffer.
|
||||
*
|
||||
* @returns
|
||||
* The pointer to the buffer.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL_ALL
|
||||
void *
|
||||
firehose_client_get_metadata_buffer(firehose_client_t client, size_t *size);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_get_context
|
||||
*
|
||||
* @abstract
|
||||
* Gets the context for the specified client.
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*
|
||||
* @returns
|
||||
* The context set for the client with firehose_client_set_context
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
void *
|
||||
firehose_client_get_context(firehose_client_t client);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_set_strings_cached
|
||||
*
|
||||
* @abstract
|
||||
* Marks a given client as having strings cached already.
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
void
|
||||
firehose_client_set_strings_cached(firehose_client_t client);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_set_context
|
||||
*
|
||||
* @abstract
|
||||
* Sets the context for the specified client.
|
||||
*
|
||||
* @discussion
|
||||
* Setting the context exchanges the context pointer, but the client must
|
||||
* ensure proper synchronization with possible getters.
|
||||
*
|
||||
* The lifetime of the context is under the control of the API user,
|
||||
* it is suggested to destroy the context when the CLIENT_DIED event is
|
||||
* received.
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*
|
||||
* @param ctxt
|
||||
* The new context to set.
|
||||
*
|
||||
* @returns
|
||||
* The previous context set for the client.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
void *
|
||||
firehose_client_set_context(firehose_client_t client, void *ctxt);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_initiate_quarantine
|
||||
*
|
||||
* @abstract
|
||||
* Starts the procedure to move the given client to the high volume quarantine
|
||||
*
|
||||
* @discussion
|
||||
* When the client is in the high volume quarantine, their firehose chunks
|
||||
* have the fcp_quarantined bit set to 1.
|
||||
*
|
||||
* @param client
|
||||
* The specified client.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1
|
||||
void
|
||||
firehose_client_initiate_quarantine(firehose_client_t client);
|
||||
|
||||
/*!
|
||||
* @function firehose_client_metadata_stream_peek
|
||||
*
|
||||
* @abstract
|
||||
* Peek at the metadata stream in flight buffers for a given client
|
||||
*
|
||||
* @discussion
|
||||
* This function should never be called from the context of a snapshot
|
||||
* handler.
|
||||
*
|
||||
* @param client
|
||||
* The specified client
|
||||
*
|
||||
* @param context
|
||||
* If this function is called synchronously from the handler passed to
|
||||
* firehose_server_init, then `context` should be the event being processed.
|
||||
* Else pass FIREHOSE_EVENT_NONE.
|
||||
*
|
||||
* @param peek_should_start
|
||||
* Handler that is called prior to peeking to solve the race of metadata
|
||||
* buffers not beeing processed yet at first lookup time, and being processed
|
||||
* before the peek enumeration starts.
|
||||
*
|
||||
* If the handler returns false, then the enumeration doesn't start.
|
||||
* If the race cannot happen, pass NULL.
|
||||
*
|
||||
* @param peek
|
||||
* Handler that will receive all the live metadata buffers for this process.
|
||||
* If the handler returns false, the enumeration is interrupted.
|
||||
*/
|
||||
OS_NOTHROW OS_NONNULL1 OS_NONNULL4
|
||||
void
|
||||
firehose_client_metadata_stream_peek(firehose_client_t client,
|
||||
firehose_event_t context, OS_NOESCAPE bool (^peek_should_start)(void),
|
||||
OS_NOESCAPE bool (^peek)(firehose_chunk_t fbc));
|
||||
|
||||
#pragma mark - Firehose Server
|
||||
|
||||
/*!
|
||||
* @typedef firehose_handler_t
|
||||
*
|
||||
* @abstract
|
||||
* Type of the handler block for firehose_server_init()
|
||||
*/
|
||||
typedef void (^firehose_handler_t)(firehose_client_t client,
|
||||
firehose_event_t event, firehose_chunk_t page,
|
||||
firehose_chunk_pos_u fc_pos);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_init
|
||||
*
|
||||
* @abstract
|
||||
* Initializes the firehose MiG server
|
||||
*
|
||||
* @discussion
|
||||
* Initializes the firehose MiG server by boostrap registering the services
|
||||
* and creating dispatch_sources for the same.
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_init(mach_port_t firehose_comm_port,
|
||||
firehose_handler_t handler);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_assert_spi_version
|
||||
*
|
||||
* @abstract
|
||||
* Checks that libdispatch and firehose components all match
|
||||
*
|
||||
* @discussion
|
||||
* Will assert that all the components have the same SPI versions
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_assert_spi_version(uint32_t spi_version);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_has_ever_flushed_pages
|
||||
*
|
||||
* @abstract
|
||||
* Checks whether the firehose server has ever flushed any pages this boot.
|
||||
*
|
||||
* @discussion
|
||||
* Must be called after firehose_server_init() and before calling
|
||||
* firehose_server_resume().
|
||||
*/
|
||||
OS_NOTHROW
|
||||
bool
|
||||
firehose_server_has_ever_flushed_pages(void);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_resume
|
||||
*
|
||||
* @abstract
|
||||
* Allows firehose events to flow
|
||||
*
|
||||
* @discussion
|
||||
* Must be called after firehose_server_init()
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_resume(void);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_cancel
|
||||
*
|
||||
* @abstract
|
||||
* Cancels the server, disconnects all clients, and prevents new connections.
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_cancel(void);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_set_logging_prefs
|
||||
*
|
||||
* @abstract
|
||||
* Publishes a new preferences buffer.
|
||||
*
|
||||
* @description
|
||||
* The server will take ownership of this buffer and will
|
||||
* call munmap() on the previous one that was stored.
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_set_logging_prefs(void *pointer, size_t length,
|
||||
os_block_t block);
|
||||
|
||||
/*!
|
||||
* @typedef firehose_server_queue_t
|
||||
*
|
||||
* @abstract
|
||||
* Values to pass to firehose_server_get_queue()
|
||||
*/
|
||||
OS_ENUM(firehose_server_queue, unsigned long,
|
||||
FIREHOSE_SERVER_QUEUE_UNKNOWN,
|
||||
FIREHOSE_SERVER_QUEUE_IO,
|
||||
FIREHOSE_SERVER_QUEUE_MEMORY,
|
||||
);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_copy_queue
|
||||
*
|
||||
* @abstract
|
||||
* Returns internal queues to the firehose server subsystem.
|
||||
*/
|
||||
OS_NOTHROW OS_OBJECT_RETURNS_RETAINED
|
||||
dispatch_queue_t
|
||||
firehose_server_copy_queue(firehose_server_queue_t which);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_quarantined_suspend
|
||||
*
|
||||
* @abstract
|
||||
* Suspends processing of quarantined clients until
|
||||
* firehose_server_quarantined_resume() is called for the same queue.
|
||||
*
|
||||
* @discussion
|
||||
* Suspending processing of quarantined clients causes firehose_snapshot()
|
||||
* to block until the processing is enabled again.
|
||||
*
|
||||
* However if this is used to pace the processing, it is a good idea to disable
|
||||
* this pacing until the snapshot has completed.
|
||||
*
|
||||
* Similarly, quarantine suspension must be off during shutdown.
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_quarantined_suspend(firehose_server_queue_t q);
|
||||
|
||||
/*!
|
||||
* @function firehose_server_quarantined_resume
|
||||
*
|
||||
* @abstract
|
||||
* Resumes processing of quarantined clients.
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_server_quarantined_resume(firehose_server_queue_t q);
|
||||
|
||||
#pragma mark - Firehose Snapshot
|
||||
|
||||
/*!
|
||||
* @typedef firehose_snapshot_event
|
||||
*/
|
||||
OS_ENUM(firehose_snapshot_event, unsigned long,
|
||||
FIREHOSE_SNAPSHOT_EVENT_IO_START = 1,
|
||||
FIREHOSE_SNAPSHOT_EVENT_MEM_START,
|
||||
FIREHOSE_SNAPSHOT_EVENT_IO_BUFFER,
|
||||
FIREHOSE_SNAPSHOT_EVENT_MEM_BUFFER,
|
||||
FIREHOSE_SNAPSHOT_EVENT_COMPLETE,
|
||||
);
|
||||
|
||||
/*!
|
||||
* @typedef firehose_snapshot_handler_t
|
||||
*
|
||||
* @abstract
|
||||
* Type of the handler block for firehose_snapshot
|
||||
*/
|
||||
typedef void (^firehose_snapshot_handler_t)(firehose_client_t client,
|
||||
firehose_snapshot_event_t event, firehose_chunk_t page,
|
||||
firehose_chunk_pos_u fc_pos);
|
||||
|
||||
/*!
|
||||
* @function firehose_snapshot
|
||||
*
|
||||
* @abstract
|
||||
* Gather a snapshot for the current firehose state.
|
||||
*
|
||||
* @discussion
|
||||
* This function can be called several times, in which case snapshots are taken
|
||||
* one after the other. If coalescing is desired, it has to be built around this
|
||||
* call.
|
||||
*/
|
||||
OS_NOTHROW
|
||||
void
|
||||
firehose_snapshot(firehose_snapshot_handler_t handler);
|
||||
|
||||
#endif // OS_FIREHOSE_SPI
|
||||
|
||||
#endif // __FIREHOSE_SERVER_PRIVATE__
|
||||
34
Telegram/ThirdParty/dispatch/os/generic_base.h
vendored
Normal file
34
Telegram/ThirdParty/dispatch/os/generic_base.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2014 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_GENERIC_BASE__
|
||||
#define __OS_GENERIC_BASE__
|
||||
|
||||
#if !defined(__BEGIN_DECLS) && !defined(__END_DECLS)
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __OS_GENERIC_BASE__ */
|
||||
130
Telegram/ThirdParty/dispatch/os/generic_unix_base.h
vendored
Normal file
130
Telegram/ThirdParty/dispatch/os/generic_unix_base.h
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This source file is part of the Swift.org open source project
|
||||
*
|
||||
* Copyright (c) 2015 Apple Inc. and the Swift project authors
|
||||
*
|
||||
* Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
*
|
||||
* See https://swift.org/LICENSE.txt for license information
|
||||
* See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OS_GENERIC_UNIX_BASE__
|
||||
#define __OS_GENERIC_UNIX_BASE__
|
||||
|
||||
#include <os/generic_base.h>
|
||||
|
||||
#if __has_include(<sys/sysmacros.h>)
|
||||
#include <sys/sysmacros.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <libutil.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <sys/param.h>
|
||||
|
||||
#if __has_include(<sys/cdefs.h>)
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
#ifndef API_AVAILABLE
|
||||
#define API_AVAILABLE(...)
|
||||
#endif
|
||||
#ifndef API_DEPRECATED
|
||||
#define API_DEPRECATED(...)
|
||||
#endif
|
||||
#ifndef API_UNAVAILABLE
|
||||
#define API_UNAVAILABLE(...)
|
||||
#endif
|
||||
#ifndef API_DEPRECATED_WITH_REPLACEMENT
|
||||
#define API_DEPRECATED_WITH_REPLACEMENT(...)
|
||||
#endif
|
||||
|
||||
#if __GNUC__
|
||||
#define OS_EXPECT(x, v) __builtin_expect((x), (v))
|
||||
#define OS_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define OS_EXPECT(x, v) (x)
|
||||
#define OS_UNUSED
|
||||
#endif
|
||||
|
||||
#ifndef os_likely
|
||||
#define os_likely(x) OS_EXPECT(!!(x), 1)
|
||||
#endif
|
||||
#ifndef os_unlikely
|
||||
#define os_unlikely(x) OS_EXPECT(!!(x), 0)
|
||||
#endif
|
||||
|
||||
#if __has_feature(assume_nonnull)
|
||||
#define OS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
|
||||
#define OS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
|
||||
#else
|
||||
#define OS_ASSUME_NONNULL_BEGIN
|
||||
#define OS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin_assume)
|
||||
#define OS_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
|
||||
#else
|
||||
#define OS_COMPILER_CAN_ASSUME(expr) ((void)(expr))
|
||||
#endif
|
||||
|
||||
#if __has_feature(attribute_availability_swift)
|
||||
// equivalent to __SWIFT_UNAVAILABLE from Availability.h
|
||||
#define OS_SWIFT_UNAVAILABLE(_msg) \
|
||||
__attribute__((__availability__(swift, unavailable, message=_msg)))
|
||||
#else
|
||||
#define OS_SWIFT_UNAVAILABLE(_msg)
|
||||
#endif
|
||||
|
||||
#if __has_attribute(swift_private)
|
||||
# define OS_REFINED_FOR_SWIFT __attribute__((__swift_private__))
|
||||
#else
|
||||
# define OS_REFINED_FOR_SWIFT
|
||||
#endif
|
||||
|
||||
#if __has_attribute(swift_name)
|
||||
# define OS_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
|
||||
#else
|
||||
# define OS_SWIFT_NAME(_name)
|
||||
#endif
|
||||
|
||||
#define __OS_STRINGIFY(s) #s
|
||||
#define OS_STRINGIFY(s) __OS_STRINGIFY(s)
|
||||
#define __OS_CONCAT(x, y) x ## y
|
||||
#define OS_CONCAT(x, y) __OS_CONCAT(x, y)
|
||||
|
||||
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
|
||||
#define OS_ENUM(_name, _type, ...) \
|
||||
typedef enum : _type { __VA_ARGS__ } _name##_t
|
||||
#else
|
||||
#define OS_ENUM(_name, _type, ...) \
|
||||
enum { __VA_ARGS__ }; typedef _type _name##_t
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Stub out misc linking and compilation attributes
|
||||
*/
|
||||
|
||||
#ifdef OS_EXPORT
|
||||
#undef OS_EXPORT
|
||||
#endif
|
||||
#define OS_EXPORT
|
||||
|
||||
#ifdef OS_WARN_RESULT_NEEDS_RELEASE
|
||||
#undef OS_WARN_RESULT_NEEDS_RELEASE
|
||||
#endif
|
||||
|
||||
#ifdef OS_WARN_RESULT
|
||||
#undef OS_WARN_RESULT
|
||||
#endif
|
||||
#define OS_WARN_RESULT
|
||||
|
||||
#ifdef OS_NOTHROW
|
||||
#undef OS_NOTHROW
|
||||
#endif
|
||||
#define OS_NOTHROW
|
||||
|
||||
#endif /* __OS_GENERIC_UNIX_BASE__ */
|
||||
128
Telegram/ThirdParty/dispatch/os/generic_win_base.h
vendored
Normal file
128
Telegram/ThirdParty/dispatch/os/generic_win_base.h
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* This source file is part of the Swift.org open source project
|
||||
*
|
||||
* Copyright (c) 2015 Apple Inc. and the Swift project authors
|
||||
*
|
||||
* Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
*
|
||||
* See https://swift.org/LICENSE.txt for license information
|
||||
* See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OS_GENERIC_WIN_BASE__
|
||||
#define __OS_GENERIC_WIN_BASE__
|
||||
|
||||
#include <os/generic_base.h>
|
||||
|
||||
// Unices provide `roundup` via sys/param.h
|
||||
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
||||
// Unices provide `MAX` via sys/param.h
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
// Unices provide `MIN` via sys/param.h
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
// Unices provide `howmany` via sys/param.h
|
||||
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
|
||||
|
||||
#ifndef HAVE_MODE_T
|
||||
typedef int mode_t;
|
||||
#endif
|
||||
typedef void pthread_attr_t;
|
||||
|
||||
#ifndef API_AVAILABLE
|
||||
#define API_AVAILABLE(...)
|
||||
#endif
|
||||
#ifndef API_DEPRECATED
|
||||
#define API_DEPRECATED(...)
|
||||
#endif
|
||||
#ifndef API_UNAVAILABLE
|
||||
#define API_UNAVAILABLE(...)
|
||||
#endif
|
||||
#ifndef API_DEPRECATED_WITH_REPLACEMENT
|
||||
#define API_DEPRECATED_WITH_REPLACEMENT(...)
|
||||
#endif
|
||||
|
||||
#if !defined(__has_attribute)
|
||||
#define __has_attribute(attibute) 0
|
||||
#endif
|
||||
|
||||
#if !defined(__has_builtin)
|
||||
#define __has_builtin(builtin) 0
|
||||
#endif
|
||||
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(feature) 0
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin_expect)
|
||||
#define OS_EXPECT(expression, value) __builtin_expect((expression), (value))
|
||||
#else
|
||||
#define OS_EXPECT(expression, value) (expression)
|
||||
#endif
|
||||
|
||||
#if __has_attribute(__unused__)
|
||||
#define OS_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define OS_UNUSED
|
||||
#endif
|
||||
|
||||
#ifndef os_likely
|
||||
#define os_likely(expression) OS_EXPECT(!!(expression), 1)
|
||||
#endif
|
||||
#ifndef os_unlikely
|
||||
#define os_unlikely(expression) OS_EXPECT(!!(expression), 0)
|
||||
#endif
|
||||
|
||||
#if __has_feature(assume_nonnull)
|
||||
#define OS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
|
||||
#define OS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
|
||||
#else
|
||||
#define OS_ASSUME_NONNULL_BEGIN
|
||||
#define OS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin_assume)
|
||||
#define OS_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
|
||||
#else
|
||||
#define OS_COMPILER_CAN_ASSUME(expr) ((void)(expr))
|
||||
#endif
|
||||
|
||||
#if __has_feature(attribute_availability_swift)
|
||||
// equivalent to __SWIFT_UNAVAILABLE from Availability.h
|
||||
#define OS_SWIFT_UNAVAILABLE(msg) \
|
||||
__attribute__((__availability__(swift, unavailable, message = msg)))
|
||||
#else
|
||||
#define OS_SWIFT_UNAVAILABLE(msg)
|
||||
#endif
|
||||
|
||||
#define __OS_STRINGIFY(s) #s
|
||||
#define OS_STRINGIFY(s) __OS_STRINGIFY(s)
|
||||
|
||||
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
|
||||
#define OS_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t
|
||||
#else
|
||||
#define OS_ENUM(name, type, ...) \
|
||||
enum { __VA_ARGS__ }; \
|
||||
typedef type name##_t
|
||||
#endif
|
||||
|
||||
#ifdef OS_EXPORT
|
||||
#undef OS_EXPORT
|
||||
#endif
|
||||
#define OS_EXPORT __declspec(dllexport)
|
||||
|
||||
#ifdef OS_WARN_RESULT_NEEDS_RELEASE
|
||||
#undef OS_WARN_RESULT_NEEDS_RELEASE
|
||||
#endif
|
||||
|
||||
#ifdef OS_WARN_RESULT
|
||||
#undef OS_WARN_RESULT
|
||||
#endif
|
||||
#define OS_WARN_RESULT
|
||||
|
||||
#ifdef OS_NOTHROW
|
||||
#undef OS_NOTHROW
|
||||
#endif
|
||||
#define OS_NOTHROW
|
||||
|
||||
#endif
|
||||
272
Telegram/ThirdParty/dispatch/os/object.h
vendored
Normal file
272
Telegram/ThirdParty/dispatch/os/object.h
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2014 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_OBJECT__
|
||||
#define __OS_OBJECT__
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Availability.h>
|
||||
#include <os/availability.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <os/base.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <os/generic_win_base.h>
|
||||
#elif defined(__unix__)
|
||||
#include <os/generic_unix_base.h>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @header
|
||||
*
|
||||
* @preprocinfo
|
||||
* By default, libSystem objects such as GCD and XPC objects are declared as
|
||||
* Objective-C types when building with an Objective-C compiler. This allows
|
||||
* them to participate in ARC, in RR management by the Blocks runtime and in
|
||||
* leaks checking by the static analyzer, and enables them to be added to Cocoa
|
||||
* collections.
|
||||
*
|
||||
* NOTE: this requires explicit cancellation of dispatch sources and xpc
|
||||
* connections whose handler blocks capture the source/connection object,
|
||||
* resp. ensuring that such captures do not form retain cycles (e.g. by
|
||||
* declaring the source as __weak).
|
||||
*
|
||||
* To opt-out of this default behavior, add -DOS_OBJECT_USE_OBJC=0 to your
|
||||
* compiler flags.
|
||||
*
|
||||
* This mode requires a platform with the modern Objective-C runtime, the
|
||||
* Objective-C GC compiler option to be disabled, and at least a Mac OS X 10.8
|
||||
* or iOS 6.0 deployment target.
|
||||
*/
|
||||
|
||||
#ifndef OS_OBJECT_HAVE_OBJC_SUPPORT
|
||||
#if !defined(__OBJC__) || defined(__OBJC_GC__)
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
#elif !defined(TARGET_OS_MAC) || !TARGET_OS_MAC
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
#elif TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
#elif TARGET_OS_MAC && !TARGET_OS_IPHONE
|
||||
# if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
# else
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
|
||||
# endif
|
||||
#else
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
|
||||
#endif
|
||||
#endif // OS_OBJECT_HAVE_OBJC_SUPPORT
|
||||
|
||||
#if OS_OBJECT_HAVE_OBJC_SUPPORT
|
||||
#if defined(__swift__) && __swift__ && !OS_OBJECT_USE_OBJC
|
||||
#define OS_OBJECT_USE_OBJC 1
|
||||
#endif
|
||||
#ifndef OS_OBJECT_USE_OBJC
|
||||
#define OS_OBJECT_USE_OBJC 1
|
||||
#endif
|
||||
#elif defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
|
||||
/* Unsupported platform for OS_OBJECT_USE_OBJC=1 */
|
||||
#undef OS_OBJECT_USE_OBJC
|
||||
#define OS_OBJECT_USE_OBJC 0
|
||||
#else
|
||||
#define OS_OBJECT_USE_OBJC 0
|
||||
#endif
|
||||
|
||||
#ifndef OS_OBJECT_SWIFT3
|
||||
#if defined(SWIFT_SDK_OVERLAY_DISPATCH_EPOCH) && \
|
||||
SWIFT_SDK_OVERLAY_DISPATCH_EPOCH >= 2
|
||||
#define OS_OBJECT_SWIFT3 1
|
||||
#else
|
||||
#define OS_OBJECT_SWIFT3 0
|
||||
#endif // SWIFT_SDK_OVERLAY_DISPATCH_EPOCH >= 2
|
||||
#endif // OS_OBJECT_SWIFT3
|
||||
|
||||
#if OS_OBJECT_USE_OBJC
|
||||
#import <objc/NSObject.h>
|
||||
#if __has_attribute(objc_independent_class)
|
||||
#define OS_OBJC_INDEPENDENT_CLASS __attribute__((objc_independent_class))
|
||||
#endif // __has_attribute(objc_independent_class)
|
||||
#ifndef OS_OBJC_INDEPENDENT_CLASS
|
||||
#define OS_OBJC_INDEPENDENT_CLASS
|
||||
#endif
|
||||
#define OS_OBJECT_CLASS(name) OS_##name
|
||||
#define OS_OBJECT_DECL_PROTOCOL(name, ...) \
|
||||
@protocol OS_OBJECT_CLASS(name) __VA_ARGS__ \
|
||||
@end
|
||||
#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL(name, proto) \
|
||||
@interface name () <proto> \
|
||||
@end
|
||||
#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, proto) \
|
||||
OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL( \
|
||||
OS_OBJECT_CLASS(name), OS_OBJECT_CLASS(proto))
|
||||
#define OS_OBJECT_DECL_IMPL(name, ...) \
|
||||
OS_OBJECT_DECL_PROTOCOL(name, __VA_ARGS__) \
|
||||
typedef NSObject<OS_OBJECT_CLASS(name)> \
|
||||
* OS_OBJC_INDEPENDENT_CLASS name##_t
|
||||
#define OS_OBJECT_DECL_BASE(name, ...) \
|
||||
@interface OS_OBJECT_CLASS(name) : __VA_ARGS__ \
|
||||
- (instancetype)init OS_SWIFT_UNAVAILABLE("Unavailable in Swift"); \
|
||||
@end
|
||||
#define OS_OBJECT_DECL_IMPL_CLASS(name, ...) \
|
||||
OS_OBJECT_DECL_BASE(name, ## __VA_ARGS__) \
|
||||
typedef OS_OBJECT_CLASS(name) \
|
||||
* OS_OBJC_INDEPENDENT_CLASS name##_t
|
||||
#define OS_OBJECT_DECL(name, ...) \
|
||||
OS_OBJECT_DECL_IMPL(name, <NSObject>)
|
||||
#define OS_OBJECT_DECL_SUBCLASS(name, super) \
|
||||
OS_OBJECT_DECL_IMPL(name, <OS_OBJECT_CLASS(super)>)
|
||||
#if __has_attribute(ns_returns_retained)
|
||||
#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
|
||||
#else
|
||||
#define OS_OBJECT_RETURNS_RETAINED
|
||||
#endif
|
||||
#if __has_attribute(ns_consumed)
|
||||
#define OS_OBJECT_CONSUMED __attribute__((__ns_consumed__))
|
||||
#else
|
||||
#define OS_OBJECT_CONSUMED
|
||||
#endif
|
||||
#if __has_feature(objc_arc)
|
||||
#define OS_OBJECT_BRIDGE __bridge
|
||||
#define OS_WARN_RESULT_NEEDS_RELEASE
|
||||
#else
|
||||
#define OS_OBJECT_BRIDGE
|
||||
#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
|
||||
#endif
|
||||
#if __has_attribute(objc_runtime_visible) && \
|
||||
((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
|
||||
__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) || \
|
||||
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
|
||||
!defined(__TV_OS_VERSION_MIN_REQUIRED) && \
|
||||
!defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
|
||||
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) || \
|
||||
(defined(__TV_OS_VERSION_MIN_REQUIRED) && \
|
||||
__TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) || \
|
||||
(defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
|
||||
__WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0))
|
||||
/*
|
||||
* To provide backward deployment of ObjC objects in Swift on pre-10.12
|
||||
* SDKs, OS_object classes can be marked as OS_OBJECT_OBJC_RUNTIME_VISIBLE.
|
||||
* When compiling with a deployment target earlier than OS X 10.12 (iOS 10.0,
|
||||
* tvOS 10.0, watchOS 3.0) the Swift compiler will only refer to this type at
|
||||
* runtime (using the ObjC runtime).
|
||||
*/
|
||||
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE __attribute__((objc_runtime_visible))
|
||||
#else
|
||||
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
|
||||
#endif
|
||||
#ifndef OS_OBJECT_USE_OBJC_RETAIN_RELEASE
|
||||
#if defined(__clang_analyzer__)
|
||||
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
|
||||
#elif __has_feature(objc_arc) && !OS_OBJECT_SWIFT3
|
||||
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
|
||||
#else
|
||||
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
|
||||
#endif
|
||||
#endif
|
||||
#if OS_OBJECT_SWIFT3
|
||||
#define OS_OBJECT_DECL_SWIFT(name) \
|
||||
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
|
||||
OS_OBJECT_DECL_IMPL_CLASS(name, NSObject)
|
||||
#define OS_OBJECT_DECL_SUBCLASS_SWIFT(name, super) \
|
||||
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
|
||||
OS_OBJECT_DECL_IMPL_CLASS(name, OS_OBJECT_CLASS(super))
|
||||
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE
|
||||
OS_OBJECT_DECL_BASE(object, NSObject);
|
||||
#endif // OS_OBJECT_SWIFT3
|
||||
#else
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_RETURNS_RETAINED
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_CONSUMED
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_BRIDGE
|
||||
/*! @parseOnly */
|
||||
#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
|
||||
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
|
||||
#endif
|
||||
|
||||
#if OS_OBJECT_SWIFT3
|
||||
#define OS_OBJECT_DECL_CLASS(name) \
|
||||
OS_OBJECT_DECL_SUBCLASS_SWIFT(name, object)
|
||||
#elif OS_OBJECT_USE_OBJC
|
||||
#define OS_OBJECT_DECL_CLASS(name) \
|
||||
OS_OBJECT_DECL(name)
|
||||
#else
|
||||
#define OS_OBJECT_DECL_CLASS(name) \
|
||||
typedef struct name##_s *name##_t
|
||||
#endif
|
||||
|
||||
#define OS_OBJECT_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object))
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @function os_retain
|
||||
*
|
||||
* @abstract
|
||||
* Increment the reference count of an os_object.
|
||||
*
|
||||
* @discussion
|
||||
* On a platform with the modern Objective-C runtime this is exactly equivalent
|
||||
* to sending the object the -[retain] message.
|
||||
*
|
||||
* @param object
|
||||
* The object to retain.
|
||||
*
|
||||
* @result
|
||||
* The retained object.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_EXPORT OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
|
||||
void*
|
||||
os_retain(void *object);
|
||||
#if OS_OBJECT_USE_OBJC
|
||||
#undef os_retain
|
||||
#define os_retain(object) [object retain]
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function os_release
|
||||
*
|
||||
* @abstract
|
||||
* Decrement the reference count of a os_object.
|
||||
*
|
||||
* @discussion
|
||||
* On a platform with the modern Objective-C runtime this is exactly equivalent
|
||||
* to sending the object the -[release] message.
|
||||
*
|
||||
* @param object
|
||||
* The object to release.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_EXPORT
|
||||
void OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
|
||||
os_release(void *object);
|
||||
#if OS_OBJECT_USE_OBJC
|
||||
#undef os_release
|
||||
#define os_release(object) [object release]
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
205
Telegram/ThirdParty/dispatch/os/object_private.h
vendored
Normal file
205
Telegram/ThirdParty/dispatch/os/object_private.h
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __OS_OBJECT_PRIVATE__
|
||||
#define __OS_OBJECT_PRIVATE__
|
||||
|
||||
#include <os/object.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if __GNUC__
|
||||
#define OS_OBJECT_NOTHROW __attribute__((__nothrow__))
|
||||
#define OS_OBJECT_NONNULL __attribute__((__nonnull__))
|
||||
#define OS_OBJECT_WARN_RESULT __attribute__((__warn_unused_result__))
|
||||
#define OS_OBJECT_MALLOC __attribute__((__malloc__))
|
||||
#ifndef OS_OBJECT_EXPORT
|
||||
#define OS_OBJECT_EXPORT extern __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_NOTHROW
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_NONNULL
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_WARN_RESULT
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_MALLOC
|
||||
#ifndef OS_OBJECT_EXPORT
|
||||
/*! @parseOnly */
|
||||
#define OS_OBJECT_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OS_OBJECT_USE_OBJC && __has_feature(objc_arc)
|
||||
#define _OS_OBJECT_OBJC_ARC 1
|
||||
#else
|
||||
#define _OS_OBJECT_OBJC_ARC 0
|
||||
#endif
|
||||
|
||||
#define _OS_OBJECT_GLOBAL_REFCNT INT_MAX
|
||||
|
||||
#define _OS_OBJECT_HEADER(isa, ref_cnt, xref_cnt) \
|
||||
isa; /* must be pointer-sized */ \
|
||||
int volatile ref_cnt; \
|
||||
int volatile xref_cnt
|
||||
|
||||
#if OS_OBJECT_HAVE_OBJC_SUPPORT
|
||||
#define OS_OBJECT_CLASS_SYMBOL(name) OS_##name##_class
|
||||
#if TARGET_OS_MAC && !TARGET_OS_SIMULATOR && defined(__i386__)
|
||||
#define OS_OBJECT_HAVE_OBJC1 1
|
||||
#define OS_OBJECT_HAVE_OBJC2 0
|
||||
#define OS_OBJC_CLASS_RAW_SYMBOL_NAME(name) \
|
||||
".objc_class_name_" OS_STRINGIFY(name)
|
||||
#define _OS_OBJECT_CLASS_HEADER() \
|
||||
const void *_os_obj_objc_isa
|
||||
#else
|
||||
#define OS_OBJECT_HAVE_OBJC1 0
|
||||
#define OS_OBJECT_HAVE_OBJC2 1
|
||||
#define OS_OBJC_CLASS_RAW_SYMBOL_NAME(name) "_OBJC_CLASS_$_" OS_STRINGIFY(name)
|
||||
// Must match size of compiler-generated OBJC_CLASS structure rdar://10640168
|
||||
#define _OS_OBJECT_CLASS_HEADER() \
|
||||
void *_os_obj_objc_class_t[5]
|
||||
#endif
|
||||
#define OS_OBJECT_OBJC_CLASS_DECL(name) \
|
||||
extern void *OS_OBJECT_CLASS_SYMBOL(name) \
|
||||
__asm__(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name)))
|
||||
#else
|
||||
#define OS_OBJECT_HAVE_OBJC1 0
|
||||
#define OS_OBJECT_HAVE_OBJC2 0
|
||||
#define _OS_OBJECT_CLASS_HEADER() \
|
||||
void (*_os_obj_xref_dispose)(_os_object_t); \
|
||||
void (*_os_obj_dispose)(_os_object_t)
|
||||
#endif
|
||||
|
||||
#define OS_OBJECT_CLASS(name) OS_##name
|
||||
|
||||
#if OS_OBJECT_USE_OBJC && OS_OBJECT_SWIFT3
|
||||
@interface OS_OBJECT_CLASS(object) (OSObjectPrivate)
|
||||
- (void)_xref_dispose;
|
||||
- (void)_dispose;
|
||||
@end
|
||||
OS_OBJECT_DECL_PROTOCOL(object, <NSObject>);
|
||||
typedef OS_OBJECT_CLASS(object) *_os_object_t;
|
||||
#define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) \
|
||||
@interface OS_OBJECT_CLASS(name) : OS_OBJECT_CLASS(super) \
|
||||
<OS_OBJECT_CLASS(name)> \
|
||||
@end
|
||||
#define _OS_OBJECT_DECL_PROTOCOL(name, super) \
|
||||
OS_OBJECT_DECL_PROTOCOL(name, <OS_OBJECT_CLASS(super)>)
|
||||
#define _OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super) \
|
||||
OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super)
|
||||
#elif OS_OBJECT_USE_OBJC
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT
|
||||
@interface OS_OBJECT_CLASS(object) : NSObject
|
||||
- (void)_xref_dispose;
|
||||
- (void)_dispose;
|
||||
@end
|
||||
typedef OS_OBJECT_CLASS(object) *_os_object_t;
|
||||
#define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) \
|
||||
@interface OS_OBJECT_CLASS(name) : OS_OBJECT_CLASS(super) \
|
||||
<OS_OBJECT_CLASS(name)> \
|
||||
@end
|
||||
#else
|
||||
#define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super)
|
||||
#define _OS_OBJECT_DECL_PROTOCOL(name, super)
|
||||
#define _OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super)
|
||||
typedef struct _os_object_s *_os_object_t;
|
||||
#endif
|
||||
|
||||
OS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if !_OS_OBJECT_OBJC_ARC
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
_os_object_t
|
||||
_os_object_alloc(const void *cls, size_t size);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
_os_object_t
|
||||
_os_object_alloc_realized(const void *cls, size_t size);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
void _os_object_dealloc(_os_object_t object);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
_os_object_t
|
||||
_os_object_retain(_os_object_t object);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
_os_object_t
|
||||
_os_object_retain_with_resurrect(_os_object_t obj);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
void
|
||||
_os_object_release(_os_object_t object);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
_os_object_t
|
||||
_os_object_retain_internal(_os_object_t object);
|
||||
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
void
|
||||
_os_object_release_internal(_os_object_t object);
|
||||
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
_os_object_t
|
||||
_os_object_retain_internal_n(_os_object_t object, uint16_t n);
|
||||
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW
|
||||
OS_SWIFT_UNAVAILABLE("Unavailable in Swift")
|
||||
void
|
||||
_os_object_release_internal_n(_os_object_t object, uint16_t n);
|
||||
|
||||
#endif // !_OS_OBJECT_OBJC_ARC
|
||||
|
||||
__END_DECLS
|
||||
|
||||
OS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
373
Telegram/ThirdParty/dispatch/os/voucher_activity_private.h
vendored
Normal file
373
Telegram/ThirdParty/dispatch/os/voucher_activity_private.h
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_VOUCHER_ACTIVITY_PRIVATE__
|
||||
#define __OS_VOUCHER_ACTIVITY_PRIVATE__
|
||||
|
||||
#if OS_VOUCHER_ACTIVITY_SPI
|
||||
#if __has_include(<mach/mach_time.h>)
|
||||
#include <mach/mach_time.h>
|
||||
#include <firehose/tracepoint_private.h>
|
||||
#endif
|
||||
#if __APPLE__
|
||||
#include <os/base.h>
|
||||
#include <os/availability.h>
|
||||
#endif
|
||||
#include <sys/uio.h>
|
||||
#include <os/object.h>
|
||||
#include "voucher_private.h"
|
||||
|
||||
#define OS_VOUCHER_ACTIVITY_SPI_VERSION 20161003
|
||||
|
||||
#if OS_VOUCHER_WEAK_IMPORT
|
||||
#define OS_VOUCHER_EXPORT OS_EXPORT OS_WEAK_IMPORT
|
||||
#else
|
||||
#define OS_VOUCHER_EXPORT OS_EXPORT
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @const VOUCHER_CURRENT
|
||||
* Shorthand for the currently adopted voucher
|
||||
*
|
||||
* This value can only be used as an argument to functions, and is never
|
||||
* actually returned. It looks enough like a tagged pointer object that ARC
|
||||
* won't crash if this is assigned to a temporary variable.
|
||||
*/
|
||||
#define VOUCHER_CURRENT ((OS_OBJECT_BRIDGE voucher_t)(void *)~2ul)
|
||||
|
||||
/*!
|
||||
* @function voucher_get_activity_id
|
||||
*
|
||||
* @abstract
|
||||
* Returns the activity_id associated with the specified voucher at the time
|
||||
* of the call.
|
||||
*
|
||||
* @discussion
|
||||
* When the passed voucher is VOUCHER_CURRENT this returns the current
|
||||
* activity ID.
|
||||
*
|
||||
* @param voucher
|
||||
* The specified voucher.
|
||||
*
|
||||
* @param parent_id
|
||||
* An out parameter to return the parent ID of the returned activity ID.
|
||||
*
|
||||
* @result
|
||||
* The current activity identifier, if any. When 0 is returned, parent_id will
|
||||
* also always be 0.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW
|
||||
firehose_activity_id_t
|
||||
voucher_get_activity_id(voucher_t voucher, firehose_activity_id_t *parent_id);
|
||||
|
||||
/*!
|
||||
* @function voucher_get_activity_id_and_creator
|
||||
*
|
||||
* @abstract
|
||||
* Returns the activity_id associated with the specified voucher at the time
|
||||
* of the call.
|
||||
*
|
||||
* @discussion
|
||||
* When the passed voucher is VOUCHER_CURRENT this returns the current
|
||||
* activity ID.
|
||||
*
|
||||
* @param voucher
|
||||
* The specified voucher.
|
||||
*
|
||||
* @param creator_pid
|
||||
* The unique pid of the process that created the returned activity ID if any.
|
||||
*
|
||||
* @param parent_id
|
||||
* An out parameter to return the parent ID of the returned activity ID.
|
||||
*
|
||||
* @result
|
||||
* The current activity identifier, if any. When 0 is returned, parent_id will
|
||||
* also always be 0.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW
|
||||
firehose_activity_id_t
|
||||
voucher_get_activity_id_and_creator(voucher_t voucher, uint64_t *creator_pid,
|
||||
firehose_activity_id_t *parent_id);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_create_with_data
|
||||
*
|
||||
* @abstract
|
||||
* Creates a voucher object with a new activity identifier.
|
||||
*
|
||||
* @discussion
|
||||
* As part of voucher transport, activities are automatically propagated by the
|
||||
* system to other threads and processes (across IPC).
|
||||
*
|
||||
* When a voucher with an activity identifier is applied to a thread, work
|
||||
* on that thread is done on behalf of this activity.
|
||||
*
|
||||
* @param trace_id
|
||||
* Tracepoint identifier returned by voucher_activity_trace_id(), intended for
|
||||
* identification of the automatic tracepoint generated as part of creating the
|
||||
* new activity.
|
||||
*
|
||||
* @param base
|
||||
* The base voucher used to create the activity. If the base voucher has an
|
||||
* activity identifier, then the created activity will be parented to that one.
|
||||
* If the passed in base has no activity identifier, the activity identifier
|
||||
* will be a top-level one, on behalf of the process that created the base
|
||||
* voucher.
|
||||
*
|
||||
* If base is VOUCHER_NONE, the activity is a top-level one, on behalf of the
|
||||
* current process.
|
||||
*
|
||||
* If base is VOUCHER_CURRENT, then the activity is naturally based on the
|
||||
* one currently applied to the current thread (the one voucher_copy() would
|
||||
* return).
|
||||
*
|
||||
* @param flags
|
||||
* See voucher_activity_flag_t documentation for effect.
|
||||
*
|
||||
* @param pubdata
|
||||
* Pointer to packed buffer of tracepoint data.
|
||||
*
|
||||
* @param publen
|
||||
* Length of data at 'pubdata'.
|
||||
*
|
||||
* @result
|
||||
* A new voucher with an activity identifier.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12.4), ios(10.3), tvos(10.2), watchos(3.2))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
|
||||
voucher_t
|
||||
voucher_activity_create_with_data(firehose_tracepoint_id_t *trace_id,
|
||||
voucher_t base, firehose_activity_flags_t flags,
|
||||
const void *pubdata, size_t publen);
|
||||
|
||||
API_DEPRECATED_WITH_REPLACEMENT("voucher_activity_create_with_data",
|
||||
macos(10.12,10.12.4), ios(10.0,10.3), tvos(10.0,10.2), watchos(3.0,3.2))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
|
||||
voucher_t
|
||||
voucher_activity_create_with_location(firehose_tracepoint_id_t *trace_id,
|
||||
voucher_t base, firehose_activity_flags_t flags, uint64_t location);
|
||||
|
||||
/*!
|
||||
* @group Voucher Activity Trace SPI
|
||||
* SPI intended for libtrace only
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_id_allocate
|
||||
*
|
||||
* @abstract
|
||||
* Allocate a new system-wide unique activity ID.
|
||||
*
|
||||
* @param flags
|
||||
* The bottom-most 8 bits of the flags will be used to generate the ID.
|
||||
* See firehose_activity_flags_t.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW
|
||||
firehose_activity_id_t
|
||||
voucher_activity_id_allocate(firehose_activity_flags_t flags);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_flush
|
||||
*
|
||||
* @abstract
|
||||
* Force flushing the specified stream.
|
||||
*
|
||||
* @discussion
|
||||
* This maks all the buffers currently being written to as full, so that
|
||||
* their current content is pushed in a timely fashion.
|
||||
*
|
||||
* When this call returns, the actual flush may or may not yet have happened.
|
||||
*
|
||||
* @param stream
|
||||
* The stream to flush.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW
|
||||
void
|
||||
voucher_activity_flush(firehose_stream_t stream);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_trace
|
||||
*
|
||||
* @abstract
|
||||
* Add a tracepoint to the specified stream.
|
||||
*
|
||||
* @param stream
|
||||
* The stream to trace this entry into.
|
||||
*
|
||||
* @param trace_id
|
||||
* Tracepoint identifier returned by voucher_activity_trace_id()
|
||||
*
|
||||
* @param timestamp
|
||||
* The mach_approximate_time()/mach_absolute_time() value for this tracepoint.
|
||||
*
|
||||
* @param pubdata
|
||||
* Pointer to packed buffer of tracepoint data.
|
||||
*
|
||||
* @param publen
|
||||
* Length of data at 'pubdata'.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW OS_NONNULL4
|
||||
firehose_tracepoint_id_t
|
||||
voucher_activity_trace(firehose_stream_t stream,
|
||||
firehose_tracepoint_id_t trace_id, uint64_t timestamp,
|
||||
const void *pubdata, size_t publen);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_trace_v
|
||||
*
|
||||
* @abstract
|
||||
* Add a tracepoint to the specified stream, with private data.
|
||||
*
|
||||
* @param stream
|
||||
* The stream to trace this entry into.
|
||||
*
|
||||
* @param trace_id
|
||||
* Tracepoint identifier returned by voucher_activity_trace_id()
|
||||
*
|
||||
* @param timestamp
|
||||
* The mach_approximate_time()/mach_absolute_time() value for this tracepoint.
|
||||
*
|
||||
* @param iov
|
||||
* Array of `struct iovec` pointing to the data to layout.
|
||||
* The total size of this iovec must span exactly `publen + privlen` bytes.
|
||||
* The `publen` boundary must coincide with the end of an iovec (each iovec
|
||||
* must either be pure public or pure private data).
|
||||
*
|
||||
* @param publen
|
||||
* Total length of data to read from the iovec for the public data.
|
||||
*
|
||||
* @param privlen
|
||||
* Length of data to read from the iovec after the public data for the private
|
||||
* data.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12.4), ios(10.3), tvos(10.2), watchos(3.2))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW OS_NONNULL4
|
||||
firehose_tracepoint_id_t
|
||||
voucher_activity_trace_v(firehose_stream_t stream,
|
||||
firehose_tracepoint_id_t trace_id, uint64_t timestamp,
|
||||
const struct iovec *iov, size_t publen, size_t privlen);
|
||||
|
||||
#define VOUCHER_ACTIVITY_TRACE_FLAG_UNRELIABLE 0x01
|
||||
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW OS_NONNULL4
|
||||
firehose_tracepoint_id_t
|
||||
voucher_activity_trace_v_2(firehose_stream_t stream,
|
||||
firehose_tracepoint_id_t trace_id, uint64_t timestamp,
|
||||
const struct iovec *iov, size_t publen, size_t privlen, uint32_t flags);
|
||||
|
||||
typedef const struct voucher_activity_hooks_s {
|
||||
#define VOUCHER_ACTIVITY_HOOKS_VERSION 5
|
||||
long vah_version;
|
||||
mach_port_t (*vah_get_logd_port)(void);
|
||||
dispatch_mach_handler_function_t vah_debug_channel_handler;
|
||||
kern_return_t (*vah_get_reconnect_info)(mach_vm_address_t *, mach_vm_size_t *);
|
||||
void (*vah_metadata_init)(void *metadata_buffer, size_t size);
|
||||
void (*vah_quarantine_starts)(void);
|
||||
} *voucher_activity_hooks_t;
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_initialize_4libtrace
|
||||
*
|
||||
* @abstract
|
||||
* Configure upcall hooks for libtrace.
|
||||
*
|
||||
* @param hooks
|
||||
* A pointer to a voucher_activity_hooks_s structure.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW OS_NONNULL_ALL
|
||||
void
|
||||
voucher_activity_initialize_4libtrace(voucher_activity_hooks_t hooks);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_get_metadata_buffer
|
||||
*
|
||||
* @abstract
|
||||
* Return address and length of buffer in the process trace memory area
|
||||
* reserved for libtrace metadata.
|
||||
*
|
||||
* @param length
|
||||
* Pointer to size_t variable, filled with length of metadata buffer.
|
||||
*
|
||||
* @result
|
||||
* Address of metadata buffer.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW OS_NONNULL_ALL
|
||||
void *
|
||||
voucher_activity_get_metadata_buffer(size_t *length);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_get_logging_preferences
|
||||
*
|
||||
* @abstract
|
||||
* Return address and length of vm_map()ed configuration data for the logging
|
||||
* subsystem.
|
||||
*
|
||||
* @discussion
|
||||
* The data must be deallocated with vm_deallocate().
|
||||
*
|
||||
* @param length
|
||||
* Pointer to size_t variable, filled with length of preferences buffer.
|
||||
*
|
||||
* @result
|
||||
* Address of preferences buffer, returns NULL on error.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0), bridgeos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW OS_NONNULL_ALL
|
||||
void *
|
||||
voucher_activity_get_logging_preferences(size_t *length);
|
||||
|
||||
/*!
|
||||
* @function voucher_activity_should_send_strings
|
||||
*
|
||||
* @abstract
|
||||
* Returns whether the client should send the strings or not.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0), bridgeos(4.0))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW
|
||||
bool
|
||||
voucher_activity_should_send_strings(void);
|
||||
|
||||
/*!
|
||||
* @function voucher_get_activity_id_4dyld
|
||||
*
|
||||
* @abstract
|
||||
* Return the current voucher activity ID. Available for the dyld client stub
|
||||
* only.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW
|
||||
firehose_activity_id_t
|
||||
voucher_get_activity_id_4dyld(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // OS_VOUCHER_ACTIVITY_SPI
|
||||
|
||||
#endif // __OS_VOUCHER_ACTIVITY_PRIVATE__
|
||||
641
Telegram/ThirdParty/dispatch/os/voucher_private.h
vendored
Normal file
641
Telegram/ThirdParty/dispatch/os/voucher_private.h
vendored
Normal file
@@ -0,0 +1,641 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2014 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_VOUCHER_PRIVATE__
|
||||
#define __OS_VOUCHER_PRIVATE__
|
||||
|
||||
#if __APPLE__
|
||||
#include <os/base.h>
|
||||
#include <os/availability.h>
|
||||
#endif
|
||||
#if __has_include(<mach/mach.h>)
|
||||
#include <os/object.h>
|
||||
#include <mach/mach.h>
|
||||
#endif
|
||||
#if __has_include(<bank/bank_types.h>)
|
||||
#include <bank/bank_types.h>
|
||||
#endif
|
||||
#if __has_include(<sys/persona.h>)
|
||||
#include <sys/persona.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DISPATCH_BUILDING_DISPATCH__
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif /* !__DISPATCH_BUILDING_DISPATCH__ */
|
||||
|
||||
#define OS_VOUCHER_SPI_VERSION 20150630
|
||||
|
||||
#if OS_VOUCHER_WEAK_IMPORT
|
||||
#define OS_VOUCHER_EXPORT OS_EXPORT OS_WEAK_IMPORT
|
||||
#else
|
||||
#define OS_VOUCHER_EXPORT OS_EXPORT
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @group Voucher Transport SPI
|
||||
* SPI intended for clients that need to transport vouchers.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @typedef voucher_t
|
||||
*
|
||||
* @abstract
|
||||
* Vouchers are immutable sets of key/value attributes that can be adopted on a
|
||||
* thread in the current process or sent to another process.
|
||||
*
|
||||
* @discussion
|
||||
* Voucher objects are os_objects (c.f. <os/object.h>). They are memory-managed
|
||||
* with the os_retain()/os_release() functions or -[retain]/-[release] methods.
|
||||
*/
|
||||
OS_OBJECT_DECL_CLASS(voucher);
|
||||
|
||||
/*!
|
||||
* @const VOUCHER_NULL
|
||||
* Represents the empty base voucher with no attributes.
|
||||
*/
|
||||
#define VOUCHER_NULL ((voucher_t)0)
|
||||
/*!
|
||||
* @const VOUCHER_INVALID
|
||||
* Represents an invalid voucher
|
||||
*/
|
||||
#define VOUCHER_INVALID ((voucher_t)-1)
|
||||
|
||||
/*!
|
||||
* @function voucher_adopt
|
||||
*
|
||||
* @abstract
|
||||
* Adopt the specified voucher on the current thread and return the voucher
|
||||
* that had been adopted previously.
|
||||
*
|
||||
* @discussion
|
||||
* Adopted vouchers are automatically carried forward by the system to other
|
||||
* threads and processes (across IPC).
|
||||
*
|
||||
* Consumes a reference to the specified voucher.
|
||||
* Returns a reference to the previous voucher.
|
||||
*
|
||||
* @param voucher
|
||||
* The voucher object to adopt on the current thread.
|
||||
*
|
||||
* @result
|
||||
* The previously adopted voucher object.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT_NEEDS_RELEASE
|
||||
OS_NOTHROW
|
||||
voucher_t _Nullable
|
||||
voucher_adopt(voucher_t _Nullable voucher OS_OBJECT_CONSUMED);
|
||||
|
||||
/*!
|
||||
* @function voucher_copy
|
||||
*
|
||||
* @abstract
|
||||
* Returns a reference to the voucher that had been adopted previously on the
|
||||
* current thread (or carried forward by the system).
|
||||
*
|
||||
* @result
|
||||
* The currently adopted voucher object.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
|
||||
voucher_t _Nullable
|
||||
voucher_copy(void);
|
||||
|
||||
/*!
|
||||
* @function voucher_copy_without_importance
|
||||
*
|
||||
* @abstract
|
||||
* Returns a reference to a voucher object with all the properties of the
|
||||
* voucher that had been adopted previously on the current thread, but
|
||||
* without the importance properties that are frequently attached to vouchers
|
||||
* carried with IPC requests. Importance properties may elevate the scheduling
|
||||
* of threads that adopt or retain the voucher while they service the request.
|
||||
* See xpc_transaction_begin(3) for further details on importance.
|
||||
*
|
||||
* @result
|
||||
* A copy of the currently adopted voucher object, with importance removed.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
|
||||
voucher_t _Nullable
|
||||
voucher_copy_without_importance(void);
|
||||
|
||||
/*!
|
||||
* @function voucher_replace_default_voucher
|
||||
*
|
||||
* @abstract
|
||||
* Replace process attributes of default voucher (used for IPC by this process
|
||||
* when no voucher is adopted on the sending thread) with the process attributes
|
||||
* of the voucher adopted on the current thread.
|
||||
*
|
||||
* @discussion
|
||||
* This allows a daemon to indicate from the context of an incoming IPC request
|
||||
* that all future outgoing IPC from the process should be marked as acting
|
||||
* "on behalf of" the sending process of the current IPC request (as long as the
|
||||
* thread sending that outgoing IPC is not itself in the direct context of an
|
||||
* IPC request, i.e. no voucher is adopted).
|
||||
*
|
||||
* If no voucher is adopted on the current thread or the current voucher does
|
||||
* not contain any process attributes, the default voucher is reset to the
|
||||
* default process attributes for the current process.
|
||||
*
|
||||
* CAUTION: Do NOT use this SPI without contacting the Darwin Runtime team.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW
|
||||
void
|
||||
voucher_replace_default_voucher(void);
|
||||
|
||||
/*!
|
||||
* @function voucher_decrement_importance_count4CF
|
||||
*
|
||||
* @abstract
|
||||
* Decrement external importance count of the mach voucher in the specified
|
||||
* voucher object.
|
||||
*
|
||||
* @discussion
|
||||
* This is only intended for use by CoreFoundation to explicitly manage the
|
||||
* App Nap state of an application following reception of a de-nap IPC message.
|
||||
*
|
||||
* CAUTION: Do NOT use this SPI without contacting the Darwin Runtime team.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_NOTHROW
|
||||
void
|
||||
voucher_decrement_importance_count4CF(voucher_t _Nullable voucher);
|
||||
|
||||
/*!
|
||||
* @group Voucher dispatch block SPI
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_block_flags_t
|
||||
* SPI Flags to pass to the dispatch_block_create* functions.
|
||||
*
|
||||
* @const DISPATCH_BLOCK_NO_VOUCHER
|
||||
* Flag indicating that a dispatch block object should not be assigned a voucher
|
||||
* object. If invoked directly, the block object will be executed with the
|
||||
* voucher adopted on the calling thread. If the block object is submitted to a
|
||||
* queue, this replaces the default behavior of associating the submitted block
|
||||
* instance with the voucher adopted at the time of submission.
|
||||
* This flag is ignored if used with the dispatch_block_create_with_voucher*()
|
||||
* functions.
|
||||
*
|
||||
*/
|
||||
#define DISPATCH_BLOCK_NO_VOUCHER (0x40ul)
|
||||
|
||||
#define DISPATCH_BLOCK_IF_LAST_RESET_QUEUE_QOS_OVERRIDE (0x80ul)
|
||||
|
||||
/*!
|
||||
* @function dispatch_block_create_with_voucher
|
||||
*
|
||||
* @abstract
|
||||
* Create a new dispatch block object on the heap from an existing block and
|
||||
* the given flags, and assign it the specified voucher object.
|
||||
*
|
||||
* @discussion
|
||||
* The provided block is Block_copy'ed to the heap, it and the specified voucher
|
||||
* object are retained by the newly created dispatch block object.
|
||||
*
|
||||
* The returned dispatch block object is intended to be submitted to a dispatch
|
||||
* queue with dispatch_async() and related functions, but may also be invoked
|
||||
* directly. Both operations can be performed an arbitrary number of times but
|
||||
* only the first completed execution of a dispatch block object can be waited
|
||||
* on with dispatch_block_wait() or observed with dispatch_block_notify().
|
||||
*
|
||||
* The returned dispatch block will be executed with the specified voucher
|
||||
* adopted for the duration of the block body.
|
||||
*
|
||||
* If the returned dispatch block object is submitted to a dispatch queue, the
|
||||
* submitted block instance will be associated with the QOS class current at the
|
||||
* time of submission, unless one of the following flags assigned a specific QOS
|
||||
* class (or no QOS class) at the time of block creation:
|
||||
* - DISPATCH_BLOCK_ASSIGN_CURRENT
|
||||
* - DISPATCH_BLOCK_NO_QOS_CLASS
|
||||
* - DISPATCH_BLOCK_DETACHED
|
||||
* The QOS class the block object will be executed with also depends on the QOS
|
||||
* class assigned to the queue and which of the following flags was specified or
|
||||
* defaulted to:
|
||||
* - DISPATCH_BLOCK_INHERIT_QOS_CLASS (default for asynchronous execution)
|
||||
* - DISPATCH_BLOCK_ENFORCE_QOS_CLASS (default for synchronous execution)
|
||||
* See description of dispatch_block_flags_t for details.
|
||||
*
|
||||
* If the returned dispatch block object is submitted directly to a serial queue
|
||||
* and is configured to execute with a specific QOS class, the system will make
|
||||
* a best effort to apply the necessary QOS overrides to ensure that blocks
|
||||
* submitted earlier to the serial queue are executed at that same QOS class or
|
||||
* higher.
|
||||
*
|
||||
* @param flags
|
||||
* Configuration flags for the block object.
|
||||
* Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t
|
||||
* results in NULL being returned. The DISPATCH_BLOCK_NO_VOUCHER flag is
|
||||
* ignored.
|
||||
*
|
||||
* @param voucher
|
||||
* A voucher object or NULL.
|
||||
*
|
||||
* @param block
|
||||
* The block to create the dispatch block object from.
|
||||
*
|
||||
* @result
|
||||
* The newly created dispatch block object, or NULL.
|
||||
* When not building with Objective-C ARC, must be released with a -[release]
|
||||
* message or the Block_release() function.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_RETURNS_RETAINED_BLOCK
|
||||
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_block_t
|
||||
dispatch_block_create_with_voucher(dispatch_block_flags_t flags,
|
||||
voucher_t _Nullable voucher, dispatch_block_t block);
|
||||
|
||||
/*!
|
||||
* @function dispatch_block_create_with_voucher_and_qos_class
|
||||
*
|
||||
* @abstract
|
||||
* Create a new dispatch block object on the heap from an existing block and
|
||||
* the given flags, and assign it the specified voucher object, QOS class and
|
||||
* relative priority.
|
||||
*
|
||||
* @discussion
|
||||
* The provided block is Block_copy'ed to the heap, it and the specified voucher
|
||||
* object are retained by the newly created dispatch block object.
|
||||
*
|
||||
* The returned dispatch block object is intended to be submitted to a dispatch
|
||||
* queue with dispatch_async() and related functions, but may also be invoked
|
||||
* directly. Both operations can be performed an arbitrary number of times but
|
||||
* only the first completed execution of a dispatch block object can be waited
|
||||
* on with dispatch_block_wait() or observed with dispatch_block_notify().
|
||||
*
|
||||
* The returned dispatch block will be executed with the specified voucher
|
||||
* adopted for the duration of the block body.
|
||||
*
|
||||
* If invoked directly, the returned dispatch block object will be executed with
|
||||
* the assigned QOS class as long as that does not result in a lower QOS class
|
||||
* than what is current on the calling thread.
|
||||
*
|
||||
* If the returned dispatch block object is submitted to a dispatch queue, the
|
||||
* QOS class it will be executed with depends on the QOS class assigned to the
|
||||
* block, the QOS class assigned to the queue and which of the following flags
|
||||
* was specified or defaulted to:
|
||||
* - DISPATCH_BLOCK_INHERIT_QOS_CLASS: default for asynchronous execution
|
||||
* - DISPATCH_BLOCK_ENFORCE_QOS_CLASS: default for synchronous execution
|
||||
* See description of dispatch_block_flags_t for details.
|
||||
*
|
||||
* If the returned dispatch block object is submitted directly to a serial queue
|
||||
* and is configured to execute with a specific QOS class, the system will make
|
||||
* a best effort to apply the necessary QOS overrides to ensure that blocks
|
||||
* submitted earlier to the serial queue are executed at that same QOS class or
|
||||
* higher.
|
||||
*
|
||||
* @param flags
|
||||
* Configuration flags for the block object.
|
||||
* Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t
|
||||
* results in NULL being returned. The DISPATCH_BLOCK_NO_VOUCHER and
|
||||
* DISPATCH_BLOCK_NO_QOS flags are ignored.
|
||||
*
|
||||
* @param voucher
|
||||
* A voucher object or NULL.
|
||||
*
|
||||
* @param qos_class
|
||||
* A QOS class value:
|
||||
* - QOS_CLASS_USER_INTERACTIVE
|
||||
* - QOS_CLASS_USER_INITIATED
|
||||
* - QOS_CLASS_DEFAULT
|
||||
* - QOS_CLASS_UTILITY
|
||||
* - QOS_CLASS_BACKGROUND
|
||||
* - QOS_CLASS_UNSPECIFIED
|
||||
* Passing QOS_CLASS_UNSPECIFIED is equivalent to specifying the
|
||||
* DISPATCH_BLOCK_NO_QOS_CLASS flag. Passing any other value results in NULL
|
||||
* being returned.
|
||||
*
|
||||
* @param relative_priority
|
||||
* A relative priority within the QOS class. This value is a negative
|
||||
* offset from the maximum supported scheduler priority for the given class.
|
||||
* Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
|
||||
* results in NULL being returned.
|
||||
*
|
||||
* @param block
|
||||
* The block to create the dispatch block object from.
|
||||
*
|
||||
* @result
|
||||
* The newly created dispatch block object, or NULL.
|
||||
* When not building with Objective-C ARC, must be released with a -[release]
|
||||
* message or the Block_release() function.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL5 DISPATCH_RETURNS_RETAINED_BLOCK
|
||||
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_block_t
|
||||
dispatch_block_create_with_voucher_and_qos_class(dispatch_block_flags_t flags,
|
||||
voucher_t _Nullable voucher, dispatch_qos_class_t qos_class,
|
||||
int relative_priority, dispatch_block_t block);
|
||||
|
||||
/*!
|
||||
* @group Voucher dispatch queue SPI
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @function dispatch_queue_create_with_accounting_override_voucher
|
||||
*
|
||||
* @abstract
|
||||
* Deprecated, do not use, will abort process if called.
|
||||
*/
|
||||
API_DEPRECATED("removed SPI", \
|
||||
macos(10.11,10.13), ios(9.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0))
|
||||
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
|
||||
DISPATCH_NOTHROW
|
||||
dispatch_queue_t
|
||||
dispatch_queue_create_with_accounting_override_voucher(
|
||||
const char *_Nullable label,
|
||||
dispatch_queue_attr_t _Nullable attr,
|
||||
voucher_t _Nullable voucher);
|
||||
|
||||
#if __has_include(<mach/mach.h>)
|
||||
/*!
|
||||
* @group Voucher Mach SPI
|
||||
* SPI intended for clients that need to interact with mach messages or mach
|
||||
* voucher ports directly.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @function voucher_create_with_mach_msg
|
||||
*
|
||||
* @abstract
|
||||
* Creates a new voucher object from a mach message carrying a mach voucher port
|
||||
*
|
||||
* @discussion
|
||||
* Ownership of the mach voucher port in the message is transfered to the new
|
||||
* voucher object and the message header mach voucher field is cleared.
|
||||
*
|
||||
* @param msg
|
||||
* The mach message to query.
|
||||
*
|
||||
* @result
|
||||
* The newly created voucher object or NULL if the message was not carrying a
|
||||
* mach voucher.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
|
||||
voucher_t _Nullable
|
||||
voucher_create_with_mach_msg(mach_msg_header_t *msg);
|
||||
|
||||
/*!
|
||||
* @function voucher_kvoucher_debug
|
||||
*
|
||||
* @abstract
|
||||
* Writes a human-readable representation of a voucher to a memory buffer.
|
||||
*
|
||||
* @discussion
|
||||
* The formatted representation of the voucher is written starting at a given
|
||||
* offset in the buffer. If the remaining space in the buffer is too small, the
|
||||
* output is truncated. Nothing is written before buf[offset] or at or beyond
|
||||
* buf[bufsize].
|
||||
*
|
||||
* @param task
|
||||
* The task port for the task that owns the voucher port.
|
||||
*
|
||||
* @param voucher
|
||||
* The voucher port name.
|
||||
*
|
||||
* @param buf
|
||||
* The buffer to which the formatted representation of the voucher should be
|
||||
* written.
|
||||
*
|
||||
* @param bufsiz
|
||||
* The size of the buffer.
|
||||
*
|
||||
* @param offset
|
||||
* The offset of the first byte in the buffer to be used for output.
|
||||
*
|
||||
* @param prefix
|
||||
* A string to be written at the start of each line of formatted output.
|
||||
* Typically used to generate leading whitespace for indentation. Use NULL if
|
||||
* no prefix is required.
|
||||
*
|
||||
* @param max_hex_data
|
||||
* The maximum number of bytes of hex data to be formatted for voucher content
|
||||
* that is not of type MACH_VOUCHER_ATTR_KEY_ATM, MACH_VOUCHER_ATTR_KEY_BANK
|
||||
* or MACH_VOUCHER_ATTR_KEY_IMPORTANCE.
|
||||
*
|
||||
* @result
|
||||
* The offset of the first byte in the buffer following the formatted voucher
|
||||
* representation.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW DISPATCH_COLD
|
||||
size_t
|
||||
voucher_kvoucher_debug(mach_port_t task, mach_port_name_t voucher, char *buf,
|
||||
size_t bufsiz, size_t offset, char * _Nullable prefix,
|
||||
size_t max_hex_data) ;
|
||||
|
||||
/*!
|
||||
* @group Voucher Persona SPI
|
||||
* SPI intended for clients that need to interact with personas.
|
||||
*/
|
||||
|
||||
struct proc_persona_info;
|
||||
|
||||
/*!
|
||||
* @function voucher_get_current_persona
|
||||
*
|
||||
* @abstract
|
||||
* Returns the persona identifier for the current thread.
|
||||
*
|
||||
* @discussion
|
||||
* Retrieve the persona identifier from the currently adopted voucher.
|
||||
*
|
||||
* If the thread has not adopted a voucher, or the current voucher does not
|
||||
* contain persona information, this function returns the persona identifier
|
||||
* of the current process.
|
||||
*
|
||||
* If the process is not running under a persona, then this returns
|
||||
* PERSONA_ID_NONE.
|
||||
*
|
||||
* @result
|
||||
* The persona identifier for the current voucher,
|
||||
* or the persona identifier of the current process
|
||||
* or PERSONA_ID_NONE
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(9.2))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW
|
||||
uid_t
|
||||
voucher_get_current_persona(void);
|
||||
|
||||
/*!
|
||||
* @function voucher_get_current_persona_originator_info
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve the ’originator’ process persona info for the currently adopted
|
||||
* voucher.
|
||||
*
|
||||
* @discussion
|
||||
* If there is no currently adopted voucher, or no PERSONA_TOKEN attribute
|
||||
* in that voucher, this function fails.
|
||||
*
|
||||
* @param persona_info
|
||||
* The proc_persona_info structure to fill in case of success
|
||||
*
|
||||
* @result
|
||||
* 0 on success: currently adopted voucher has a PERSONA_TOKEN
|
||||
* -1 on failure: persona_info is untouched/uninitialized
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(9.2))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW OS_NONNULL1
|
||||
int
|
||||
voucher_get_current_persona_originator_info(
|
||||
struct proc_persona_info *persona_info);
|
||||
|
||||
/*!
|
||||
* @function voucher_get_current_persona_proximate_info
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve the ’proximate’ process persona info for the currently adopted
|
||||
* voucher.
|
||||
*
|
||||
* @discussion
|
||||
* If there is no currently adopted voucher, or no PERSONA_TOKEN attribute
|
||||
* in that voucher, this function fails.
|
||||
*
|
||||
* @param persona_info
|
||||
* The proc_persona_info structure to fill in case of success
|
||||
*
|
||||
* @result
|
||||
* 0 on success: currently adopted voucher has a PERSONA_TOKEN
|
||||
* -1 on failure: persona_info is untouched/uninitialized
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(9.2))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW OS_NONNULL1
|
||||
int
|
||||
voucher_get_current_persona_proximate_info(
|
||||
struct proc_persona_info *persona_info);
|
||||
|
||||
/*!
|
||||
* @function voucher_copy_with_persona_mach_voucher
|
||||
*
|
||||
* @abstract
|
||||
* Creates a copy of the currently adopted voucher and replaces its
|
||||
* persona information with the one passed in the specified mach voucher
|
||||
*
|
||||
* @discussion
|
||||
* If the specified mach voucher is not one returned from
|
||||
* mach_voucher_persona_for_originator() (called on behalf
|
||||
* of the current process), this function will fail
|
||||
*
|
||||
* @param persona_mach_voucher
|
||||
* mach voucher containing the new persona information
|
||||
*
|
||||
* @result
|
||||
* On success, a copy of the current voucher with the new
|
||||
* persona information
|
||||
* On failure, VOUCHER_INVALID
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12))
|
||||
OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
|
||||
voucher_t _Nullable
|
||||
voucher_copy_with_persona_mach_voucher(
|
||||
mach_voucher_t persona_mach_voucher);
|
||||
|
||||
/*!
|
||||
* @function mach_voucher_persona_self
|
||||
*
|
||||
* @abstract
|
||||
* Creates a mach voucher containing the persona information of the
|
||||
* current process that can be sent as a mach port descriptor in a message
|
||||
*
|
||||
* @discussion
|
||||
* The returned mach voucher has been pre-processed so that it can be sent
|
||||
* in a message
|
||||
*
|
||||
* @param persona_mach_voucher
|
||||
* If successful, a reference to the newly created mach voucher
|
||||
*
|
||||
* @result
|
||||
* KERN_SUCCESS: a mach voucher ready to be sent in a message is
|
||||
* successfully created
|
||||
* KERN_RESOURCE_SHORTAGE: mach voucher creation failed due to
|
||||
* lack of free space
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW OS_NONNULL1
|
||||
kern_return_t
|
||||
mach_voucher_persona_self(mach_voucher_t *persona_mach_voucher);
|
||||
|
||||
/*!
|
||||
* @function mach_voucher_persona_for_originator
|
||||
*
|
||||
* @abstract
|
||||
* Creates a mach voucher on behalf of the originator process by copying
|
||||
* the persona information from the specified mach voucher and then
|
||||
* updating the persona identifier to the specified value
|
||||
*
|
||||
* @discussion
|
||||
* Should be called by a privileged process on behalf of the originator process.
|
||||
* The newly created mach voucher should be returned to the originator in a
|
||||
* message. The originator's thread can adopt the new persona by passing
|
||||
* this mach voucher to voucher_copy_with_persona_mach_voucher().
|
||||
*
|
||||
* @param persona_id
|
||||
* The new persona identifier to be set in the mach voucher
|
||||
*
|
||||
* @param originator_persona_mach_voucher
|
||||
* A mach voucher received from the originator, where it was created using
|
||||
* mach_voucher_persona_self()
|
||||
*
|
||||
* @param originator_unique_pid
|
||||
* Unique pid of the originator process
|
||||
*
|
||||
* @param persona_mach_voucher
|
||||
* If successful, a reference to the newly created mach voucher
|
||||
*
|
||||
* @result
|
||||
* KERN_SUCCESS: a mach voucher ready to be returned to the
|
||||
* originator was successfully created
|
||||
* KERN_NO_ACCESS: process does not have privilege to carry
|
||||
* out this operation
|
||||
* KERN_INVALID_ARGUMENT: specified persona identifier is invalid
|
||||
* KERN_INVALID_CAPABILITY: originator_unique_pid does not
|
||||
* match the specified voucher originator's unique pid
|
||||
* KERN_RESOURCE_SHORTAGE: mach voucher creation failed due to
|
||||
* lack of free space
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12))
|
||||
OS_VOUCHER_EXPORT OS_WARN_RESULT OS_NOTHROW OS_NONNULL4
|
||||
kern_return_t
|
||||
mach_voucher_persona_for_originator(uid_t persona_id,
|
||||
mach_voucher_t originator_persona_mach_voucher,
|
||||
uint64_t originator_unique_pid, mach_voucher_t *persona_mach_voucher);
|
||||
|
||||
#endif // __has_include(<mach/mach.h>)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif // __OS_VOUCHER_PRIVATE__
|
||||
|
||||
#if OS_VOUCHER_ACTIVITY_SPI
|
||||
#include "voucher_activity_private.h"
|
||||
#endif
|
||||
Reference in New Issue
Block a user