1/* 2 * Copyright (c) 2013 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef __PTHREAD_INTROSPECTION_PRIVATE__ 25#define __PTHREAD_INTROSPECTION_PRIVATE__ 26 27#include <sys/cdefs.h> 28#include <pthread/pthread.h> 29#include <Availability.h> 30 31/*! 32 * @header 33 * 34 * @abstract 35 * Introspection SPI for libpthread. 36 */ 37 38__BEGIN_DECLS 39 40/*! 41 * @typedef pthread_introspection_hook_t 42 * 43 * @abstract 44 * A function pointer called at various points in a PThread's lifetime. 45 * 46 * @param event 47 * One of the events in pthread_introspection_event_t. 48 * 49 * @param thread 50 * pthread_t associated with the event. 51 * 52 * @param addr 53 * Address associated with the event. 54 * 55 * @param size 56 * Size associated with the event. 57 */ 58typedef void (*pthread_introspection_hook_t)(unsigned int event, 59 pthread_t thread, void *addr, size_t size); 60 61/*! 62 * @enum pthread_introspection_event_t 63 * 64 * @constant PTHREAD_INTROSPECTION_THREAD_CREATE 65 * pthread_t was created. 66 * 67 * @constant PTHREAD_INTROSPECTION_THREAD_START 68 * Thread has started and stack was allocated. 69 * 70 * @constant PTHREAD_INTROSPECTION_THREAD_TERMINATE 71 * Thread is about to be terminated and stack will be deallocated. 72 * 73 * @constant PTHREAD_INTROSPECTION_THREAD_DESTROY 74 * pthread_t is about to be destroyed. 75 */ 76enum { 77 PTHREAD_INTROSPECTION_THREAD_CREATE = 1, 78 PTHREAD_INTROSPECTION_THREAD_START, 79 PTHREAD_INTROSPECTION_THREAD_TERMINATE, 80 PTHREAD_INTROSPECTION_THREAD_DESTROY, 81}; 82 83/*! 84 * @function pthread_introspection_hook_install 85 * 86 * @abstract 87 * Install introspection hook function into libpthread. 88 * 89 * @discussion 90 * The caller is responsible for implementing chaining to the hook that was 91 * previously installed (if any). 92 * 93 * @param hook 94 * Pointer to hook function. 95 * 96 * @result 97 * Previously installed hook function or NULL. 98 */ 99 100__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) 101__attribute__((__nonnull__, __warn_unused_result__)) 102extern pthread_introspection_hook_t 103pthread_introspection_hook_install(pthread_introspection_hook_t hook); 104 105__END_DECLS 106 107#endif 108