···11+/*
22+ * Copyright (c) 2013-2016 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef __OS_ACTIVITY_H__
3030+#define __OS_ACTIVITY_H__
3131+3232+#include <os/trace_base.h>
3333+3434+__BEGIN_DECLS
3535+3636+OS_ASSUME_NONNULL_BEGIN
3737+3838+#pragma mark - types and globals
3939+4040+#if OS_LOG_TARGET_HAS_10_12_FEATURES
4141+#define OS_ACTIVITY_OBJECT_API 1
4242+#else
4343+#if OS_ACTIVITY_OBJECT_API
4444+#error Please change your minimum OS requirements because OS_ACTIVITY_OBJECT_API is not available
4545+#endif // OS_ACTIVITY_OBJECT_API
4646+#define OS_ACTIVITY_OBJECT_API 0
4747+#endif
4848+4949+/*!
5050+ * @enum os_activity_flag_t
5151+ *
5252+ * @discussion
5353+ * Support flags for os_activity_create or os_activity_start.
5454+ *
5555+ * @constant OS_ACTIVITY_FLAG_DEFAULT
5656+ * Use the default flags.
5757+ *
5858+ * @constant OS_ACTIVITY_FLAG_DETACHED
5959+ * Detach the newly created activity from the provided activity (if any). If
6060+ * passed in conjunction with an exiting activity, the activity will only note
6161+ * what activity "created" the new one, but will make the new activity a top
6262+ * level activity. This allows users to see what activity triggered work
6363+ * without actually relating the activities.
6464+ *
6565+ * @constant OS_ACTIVITY_FLAG_IF_NONE_PRESENT
6666+ * Will only create a new activity if none present. If an activity ID is
6767+ * already present, a new object will be returned with the same activity ID
6868+ * underneath.
6969+ *
7070+ * Passing both OS_ACTIVITY_FLAG_DETACHED and OS_ACTIVITY_FLAG_IF_NONE_PRESENT
7171+ * is undefined.
7272+ */
7373+OS_ENUM(os_activity_flag, uint32_t,
7474+ OS_ACTIVITY_FLAG_DEFAULT = 0,
7575+ OS_ACTIVITY_FLAG_DETACHED = 0x1,
7676+ OS_ACTIVITY_FLAG_IF_NONE_PRESENT = 0x2
7777+);
7878+7979+#if OS_ACTIVITY_OBJECT_API
8080+8181+#define OS_ACTIVITY_NULL NULL
8282+8383+/*!
8484+ * @typedef os_activity_t
8585+ * An opaque activity object.
8686+ */
8787+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
8888+#if OS_OBJECT_USE_OBJC
8989+OS_OBJECT_DECL(os_activity);
9090+#else
9191+typedef struct os_activity_s *os_activity_t;
9292+#endif /* OS_OBJECT_USE_OBJC */
9393+9494+/*!
9595+ * @const OS_ACTIVITY_NONE
9696+ *
9797+ * @discussion
9898+ * Create activity with no current traits, this is the equivalent of a
9999+ * detached activity.
100100+ */
101101+#define OS_ACTIVITY_NONE OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_none)
102102+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
103103+OS_EXPORT
104104+const struct os_activity_s _os_activity_none;
105105+106106+/*!
107107+ * @const OS_ACTIVITY_CURRENT
108108+ *
109109+ * @discussion
110110+ * Create activity and links to the current activity if one is present.
111111+ * If no activity is present it is treated as if it is detached.
112112+ */
113113+#define OS_ACTIVITY_CURRENT OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_current)
114114+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
115115+OS_EXPORT
116116+const struct os_activity_s _os_activity_current;
117117+118118+#else // !OS_ACTIVITY_OBJECT_API
119119+120120+#define OS_ACTIVITY_NULL 0
121121+122122+/*!
123123+ * @typedef os_activity_t
124124+ * An opaque activity identifier.
125125+ */
126126+API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
127127+typedef uint64_t os_activity_t;
128128+129129+#endif // OS_ACTIVITY_OBJECT_API
130130+131131+/*!
132132+ * @typedef os_activity_id_t
133133+ * An value representing the activity ID assigned to an newly created activity.
134134+ */
135135+API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
136136+typedef uint64_t os_activity_id_t;
137137+138138+/*!
139139+ * @typedef os_activity_scope_state_t
140140+ * Structure that is populated by os_activity_scope_enter and restored using
141141+ * os_activity_scope_leave.
142142+ */
143143+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
144144+typedef struct os_activity_scope_state_s {
145145+ uint64_t opaque[2];
146146+} *os_activity_scope_state_t;
147147+148148+#pragma mark - Internal support functions
149149+150150+#if OS_ACTIVITY_OBJECT_API
151151+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
152152+OS_EXPORT OS_NOTHROW OS_WARN_RESULT_NEEDS_RELEASE OS_NOT_TAIL_CALLED
153153+OS_OBJECT_RETURNS_RETAINED
154154+os_activity_t
155155+_os_activity_create(void *dso, const char *description, os_activity_t activity,
156156+ os_activity_flag_t flags);
157157+#endif
158158+159159+/*!
160160+ * @function _os_activity_label_useraction
161161+ *
162162+ * @abstract
163163+ * Internal function for use by os_activity_label_useraction.
164164+ *
165165+ * @warning
166166+ * Do not use directly.
167167+ */
168168+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
169169+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
170170+void
171171+_os_activity_label_useraction(void *dso, const char *name);
172172+173173+/*!
174174+ * @function _os_activity_initiate
175175+ *
176176+ * @abstract
177177+ * Do not use directly because your description will not be preserved.
178178+ */
179179+API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
180180+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
181181+void
182182+_os_activity_initiate(void *dso, const char *description,
183183+ os_activity_flag_t flags, os_block_t activity_block OS_NOESCAPE);
184184+185185+/*!
186186+ * @function _os_activity_initiate_f
187187+ *
188188+ * @abstract
189189+ * Do not use directly because your description will not be preserved.
190190+ */
191191+API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
192192+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
193193+void
194194+_os_activity_initiate_f(void *dso, const char *description,
195195+ os_activity_flag_t flags, void *context, os_function_t function);
196196+197197+#pragma mark - activity related
198198+199199+/*!
200200+ * @function os_activity_initiate
201201+ *
202202+ * @abstract
203203+ * Synchronously initiates an activity using provided block.
204204+ *
205205+ * @discussion
206206+ * Synchronously initiates an activity using the provided block and creates
207207+ * a tracing buffer as appropriate. All new activities are created as a
208208+ * subactivity of an existing activity on the current thread.
209209+ *
210210+ * <code>
211211+ * os_activity_initiate("indexing database", OS_ACTIVITY_FLAG_DEFAULT, ^(void) {
212212+ * // either do work directly or issue work asynchronously
213213+ * });
214214+ * </code>
215215+ *
216216+ * @param description
217217+ * A constant string describing the activity, e.g., "performClick" or
218218+ * "menuSelection".
219219+ *
220220+ * @param flags
221221+ * Flags to be used when initiating the activity, typically
222222+ * OS_ACTIVITY_FLAG_DEFAULT.
223223+ *
224224+ * @param activity_block
225225+ * The block to execute a given activity
226226+ */
227227+#define os_activity_initiate(description, flags, activity_block) __extension__({ \
228228+ OS_LOG_STRING(ACT, __description, description); \
229229+ _os_activity_initiate(&__dso_handle, __description, flags, activity_block); \
230230+})
231231+232232+/*!
233233+ * @function os_activity_initiate_f
234234+ *
235235+ * @abstract
236236+ * Synchronously initiates an activity using the provided function.
237237+ *
238238+ * @discussion
239239+ * Synchronously initiates an activity using the provided function and creates
240240+ * a tracing buffer as appropriate. All new activities are created as a
241241+ * subactivity of an existing activity on the current thread.
242242+ *
243243+ * <code>
244244+ * os_activity_initiate_f("indexing database", OS_ACTIVITY_FLAG_DEFAULT, context, function);
245245+ * </code>
246246+ *
247247+ * @param description
248248+ * A constant string describing the activity, e.g., "performClick" or
249249+ * "menuSelection".
250250+ *
251251+ * @param flags
252252+ * Flags to be used when initiating the activity, typically
253253+ * OS_ACTIVITY_FLAG_DEFAULT.
254254+ *
255255+ * @param context
256256+ * An optional context that will be supplied to the activity function.
257257+ *
258258+ * @param activity_func
259259+ * The function to execute for the new activity.
260260+ */
261261+#define os_activity_initiate_f(description, flags, context, function) __extension__({ \
262262+ OS_LOG_STRING(ACT, __description, description); \
263263+ _os_activity_initiate_f(&__dso_handle, __description, flags, context, function); \
264264+})
265265+266266+#if OS_ACTIVITY_OBJECT_API
267267+/*!
268268+ * @function os_activity_create
269269+ *
270270+ * @abstract
271271+ * Creates an os_activity_t object which can be passed to os_activity_apply
272272+ * function.
273273+ *
274274+ * @param description
275275+ * Pass a description for the activity. The description must be a constant
276276+ * string within the calling executable or library.
277277+ *
278278+ * @param parent_activity
279279+ * Depending on flags will link the newly created activity to the value passed
280280+ * or note where the activity was created. Possible activities include:
281281+ * OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT or any existing os_activity_t object
282282+ * created using os_activity_create.
283283+ *
284284+ * @param flags
285285+ * A valid os_activity_flag_t which will determine behavior of the newly created
286286+ * activity.
287287+ *
288288+ * If the OS_ACTIVITY_FLAG_DETACHED flag is passed, the value passed to the
289289+ * parent_activity argument is ignored, and OS_ACTIVITY_NONE is used instead.
290290+ *
291291+ * If the OS_ACTIVITY_FLAG_IF_NONE_PRESENT flag is passed, then passing another
292292+ * value than OS_ACTIVITY_CURRENT to the parent_activity argument is undefined.
293293+ *
294294+ * @result
295295+ * Returns an os_activity_t object which can be used with os_activity_apply.
296296+ */
297297+#define os_activity_create(description, parent_activity, flags) __extension__({ \
298298+ OS_LOG_STRING(ACT, __description, description); \
299299+ _os_activity_create(&__dso_handle, __description, parent_activity, flags); \
300300+})
301301+302302+/*!
303303+ * @function os_activity_apply
304304+ *
305305+ * @abstract
306306+ * Execute a block using a given activity object.
307307+ *
308308+ * @param activity
309309+ * The given activity object created with os_activity_create() or
310310+ * OS_ACTIVITY_NONE.
311311+ *
312312+ * @param block
313313+ * Pass the block to be executed within the context of the given activity.
314314+ */
315315+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
316316+OS_EXPORT OS_NOTHROW
317317+void
318318+os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
319319+320320+/*!
321321+ * @function os_activity_apply_f
322322+ *
323323+ * @abstract
324324+ * Execute a given function with a provided activity.
325325+ *
326326+ * @param activity
327327+ * The given activity object created with os_activity_create() or
328328+ * OS_ACTIVITY_NONE.
329329+ *
330330+ * @param context
331331+ * Context to pass to the function which may be NULL.
332332+ *
333333+ * @param function
334334+ * Pass the function to be executed within the context of the given activity.
335335+ */
336336+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
337337+OS_EXPORT OS_NOTHROW
338338+void
339339+os_activity_apply_f(os_activity_t activity, void *context,
340340+ os_function_t function);
341341+342342+/*!
343343+ * @function os_activity_scope_enter
344344+ *
345345+ * @abstract
346346+ * Will change the current execution context to use the provided activity.
347347+ *
348348+ * @discussion
349349+ * Will change the current execution context to use the provided activity.
350350+ * An activity can be created and then applied to the current scope by doing:
351351+ *
352352+ * <code>
353353+ * struct os_activity_scope_state_s state;
354354+ * os_activity_t activity = os_activity_create("my new activity", 0);
355355+ * os_activity_scope_enter(activity, &state);
356356+ * ... do some work ...
357357+ * os_activity_scope_leave(&state);
358358+ * </code>
359359+ *
360360+ * To auto-cleanup state call:
361361+ *
362362+ * os_activity_scope(activity);
363363+ *
364364+ * @param activity
365365+ * Pass a valid activity created with os_activity_create or any global object.
366366+ *
367367+ * @param state
368368+ * A stack-based struct os_activity_scope_state_s to store the state.
369369+ */
370370+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
371371+OS_EXPORT OS_NOTHROW
372372+void
373373+os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state);
374374+375375+/*!
376376+ * @function os_activity_scope_leave
377377+ *
378378+ * @abstract
379379+ * Will pop state up to the state provided.
380380+ *
381381+ * @discussion
382382+ * Will leave scope using the state provided. If state is not present an error
383383+ * will be generated.
384384+ *
385385+ * @param state
386386+ * Must be a valid value filled by os_activity_scope_enter call.
387387+ */
388388+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
389389+OS_EXPORT OS_NOTHROW
390390+void
391391+os_activity_scope_leave(os_activity_scope_state_t state);
392392+393393+#if defined(__GNUC__)
394394+#define _os_activity_scope(var, activity) \
395395+ struct os_activity_scope_state_s var __attribute__((__cleanup__(os_activity_scope_leave))); \
396396+ os_activity_scope_enter(activity, &var)
397397+#define os_activity_scope(activity) _os_activity_scope(OS_CONCAT(scope, __COUNTER__), activity)
398398+#endif
399399+400400+#endif // OS_ACTIVITY_OBJECT_API
401401+402402+/*!
403403+ * @function os_activity_get_active
404404+ *
405405+ * @abstract
406406+ * Returns the stack of nested activities associated with the current thread.
407407+ *
408408+ * @discussion
409409+ * Activities have a sense of nesting and therefore there could be more than
410410+ * one activity involved on the current thread. This should be used by
411411+ * diagnostic tools only for making additional decisions about a situation.
412412+ *
413413+ * @param entries
414414+ * Pass a buffer of sufficient size to hold the the number of os_activity_id_t
415415+ * being requested.
416416+ *
417417+ * @param count
418418+ * Pointer to the requested number of activity identifiers.
419419+ * On output will be filled with the number of activities that are available.
420420+ *
421421+ * @result
422422+ * Number of activity identifiers written to 'entries'
423423+ */
424424+API_DEPRECATED("No longer supported", macos(10.10, 10.12), ios(8.0, 10.0),
425425+ watchos(2.0, 3.0), tvos(9.0, 10.0))
426426+OS_EXPORT OS_NOTHROW
427427+unsigned int
428428+os_activity_get_active(os_activity_id_t *entries, unsigned int *count);
429429+430430+/*!
431431+ * @function os_activity_get_identifier
432432+ *
433433+ * @abstract
434434+ * Returns the current activity ID and will fill the parent_id if present.
435435+ *
436436+ * @discussion
437437+ * Returns the current activity ID and will fill the parent_id if present.
438438+ *
439439+ * @param parent_id
440440+ * If non-null will set the parent activity ID.
441441+ *
442442+ * @result
443443+ * The identifier for the provided activity.
444444+ */
445445+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
446446+OS_EXPORT OS_NOTHROW OS_WARN_RESULT
447447+os_activity_id_t
448448+os_activity_get_identifier(os_activity_t activity,
449449+ os_activity_id_t *_Nullable parent_id);
450450+451451+/*!
452452+ * @function os_activity_label_useraction
453453+ *
454454+ * @abstract
455455+ * Label an activity that is auto-generated by AppKit/UIKit with a name that is
456456+ * useful for debugging macro-level user actions.
457457+ *
458458+ * @discussion
459459+ * Label an activity that is auto-generated by AppKit/UIKit with a name that is
460460+ * useful for debugging macro-level user actions. The API should be called
461461+ * early within the scope of the IBAction and before any sub-activities are
462462+ * created. The name provided will be shown in tools in additon to the
463463+ * underlying AppKit/UIKit provided name. This API can only be called once and
464464+ * only on the activity created by AppKit/UIKit. These actions help determine
465465+ * workflow of the user in order to reproduce problems that occur. For example,
466466+ * a control press and/or menu item selection can be labeled:
467467+ *
468468+ * <code>
469469+ * os_activity_label_useraction("New mail message");
470470+ * os_activity_label_useraction("Empty trash");
471471+ * </code>
472472+ *
473473+ * Where the underlying AppKit/UIKit name will be "gesture:" or "menuSelect:".
474474+ *
475475+ * @param name
476476+ * A constant string that describes the the action.
477477+ */
478478+#define os_activity_label_useraction(label) __extension__({ \
479479+ OS_LOG_STRING(ACT, __label, label); \
480480+ _os_activity_label_useraction(&__dso_handle, __label); \
481481+})
482482+483483+#pragma mark - deprecated function support
484484+485485+/*!
486486+ * @function _os_activity_start
487487+ *
488488+ * @abstract
489489+ * Internal function for activity start, do not use directly will not preserve
490490+ * description.
491491+ */
492492+API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope",
493493+ macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
494494+OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NOT_TAIL_CALLED
495495+os_activity_t
496496+_os_activity_start(void *dso, const char *description, os_activity_flag_t flags);
497497+498498+/*!
499499+ * @function os_activity_start
500500+ *
501501+ * @warning
502502+ * Deprecated please use new os_activity_create and os_activity_apply.
503503+ */
504504+#define os_activity_start(description, flags) __extension__({ \
505505+ OS_LOG_STRING(ACT, __description, description); \
506506+ _os_activity_start(&__dso_handle, __description, flags); \
507507+})
508508+509509+/*!
510510+ * @function os_activity_end
511511+ *
512512+ * @warning
513513+ * Deprecated please use new os_activity_create and os_activity_apply.
514514+ */
515515+API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope",
516516+ macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
517517+OS_EXPORT OS_NOTHROW
518518+void
519519+os_activity_end(os_activity_t activity);
520520+521521+/*!
522522+ * @typedef os_breadcrumb_t
523523+ * An opaque value for the breadcrumb ID.
524524+ */
525525+API_DEPRECATED("No longer supported", macos(10.10, 10.12), ios(8.0, 10.0),
526526+ watchos(2.0, 3.0), tvos(9.0, 10.0))
527527+typedef uint32_t os_breadcrumb_t;
528528+529529+/*!
530530+ * @function _os_activity_set_breadcrumb
531531+ *
532532+ * @warning
533533+ * Deprecated, please use os_activity_label_useraction.
534534+ */
535535+API_DEPRECATED_WITH_REPLACEMENT("os_activity_label_useraction",
536536+ macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
537537+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
538538+void
539539+_os_activity_set_breadcrumb(void *dso, const char *name);
540540+541541+/*!
542542+ * @function os_activity_set_breadcrumb
543543+ *
544544+ * @warning
545545+ * Deprecated, please use os_activity_label_useraction.
546546+ */
547547+#define os_activity_set_breadcrumb(name) __extension__({ \
548548+ OS_LOG_STRING(ACT, __name, name); \
549549+ _os_activity_set_breadcrumb(&__dso_handle, __name); \
550550+})
551551+552552+OS_ASSUME_NONNULL_END
553553+554554+__END_DECLS
555555+556556+#endif // __OS_ACTIVITY_H__
···11+/*
22+ * Copyright (c) 2008-2016 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_APACHE_LICENSE_HEADER_START@
55+ *
66+ * Licensed under the Apache License, Version 2.0 (the "License");
77+ * you may not use this file except in compliance with the License.
88+ * You may obtain a copy of the License at
99+ *
1010+ * http://www.apache.org/licenses/LICENSE-2.0
1111+ *
1212+ * Unless required by applicable law or agreed to in writing, software
1313+ * distributed under the License is distributed on an "AS IS" BASIS,
1414+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515+ * See the License for the specific language governing permissions and
1616+ * limitations under the License.
1717+ *
1818+ * @APPLE_APACHE_LICENSE_HEADER_END@
1919+ */
2020+2121+#ifndef __OS_AVAILABILITY__
2222+#define __OS_AVAILABILITY__
2323+2424+#include <AvailabilityInternal.h>
2525+2626+/*
2727+ Macros for defining which versions/platform a given symbol can be used.
2828+2929+ @see http://clang.llvm.org/docs/AttributeReference.html#availability
3030+ */
3131+3232+/*
3333+ * API Introductions
3434+ *
3535+ * Use to specify the release that a particular API became available.
3636+ *
3737+ * Platform names:
3838+ * macos, ios, tvos, watchos
3939+ *
4040+ * Examples:
4141+ * API_AVAILABLE(macos(10.10))
4242+ * API_AVAILABLE(macos(10.9), ios(10.0))
4343+ * API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
4444+ */
4545+4646+#define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
4747+4848+/*
4949+ * API Deprecations
5050+ *
5151+ * Use to specify the release that a particular API became unavailable.
5252+ *
5353+ * Platform names:
5454+ * macos, ios, tvos, watchos
5555+ *
5656+ * Examples:
5757+ *
5858+ * API_DEPRECATED("No longer supported", macos(10.4, 10.8))
5959+ * API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
6060+ *
6161+ * API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
6262+ * API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
6363+ */
6464+6565+#define API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1)(__VA_ARGS__)
6666+#define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1)(__VA_ARGS__)
6767+6868+6969+7070+/*
7171+ * API Unavailability
7272+ * Use to specify that an API is unavailable for a particular platform.
7373+ *
7474+ * Example:
7575+ * API_UNAVAILABLE(macos)
7676+ * API_UNAVAILABLE(watchos, tvos)
7777+ */
7878+7979+#define API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1)(__VA_ARGS__)
8080+8181+#endif /* __OS_AVAILABILITY__ */
+499
platform-include/os/trace.h
···11+/*
22+ * Copyright (c) 2013-2016 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef __OS_TRACE_H__
3030+#define __OS_TRACE_H__
3131+3232+#include <os/trace_base.h>
3333+#if __has_include(<xpc/xpc.h>)
3434+#include <xpc/xpc.h>
3535+typedef xpc_object_t os_trace_payload_object_t;
3636+#else
3737+typedef void *os_trace_payload_object_t;
3838+#endif
3939+4040+#if !__GNUC__
4141+#error "must be GNU C compatible"
4242+#endif
4343+4444+__BEGIN_DECLS
4545+4646+/* We need at least clang 7.3 or later due to bugs in os_log_format parsing */
4747+#if __has_builtin(__builtin_os_log_format) && (__clang_major__ > 7 || (__clang_major__ == 7 && __clang_minor__ >= 3))
4848+4949+OS_ALWAYS_INLINE __attribute__((format(os_trace, 1, 2)))
5050+static inline void
5151+_os_trace_verify_printf(const char *msg, ...)
5252+{
5353+#pragma unused(msg)
5454+}
5555+5656+/* Previous OSes must go through older style...
5757+ *
5858+ * Format:
5959+ * Items: [ ]
6060+ * Item sizes: [
6161+ * 8 bits * count
6262+ * ]
6363+ * Item count: 8 bits
6464+ */
6565+6666+#define OS_TRACE_CALL(_t, _p, _f, ...) __extension__({ \
6767+ if (os_trace_type_enabled(_t)) { \
6868+ _os_trace_verify_printf(_f, ##__VA_ARGS__); \
6969+ OS_LOG_STRING(TRACE, __f, _f); \
7070+ uint32_t __size = (uint32_t)__builtin_os_log_format_buffer_size(_f, ##__VA_ARGS__); \
7171+ uint8_t _buf[__size]; \
7272+ __builtin_os_log_format(_buf, _f, ##__VA_ARGS__); \
7373+ uint32_t tz = 0; \
7474+ uint8_t tb[__size]; \
7575+ uint8_t *buff = _buf; \
7676+ uint8_t *p = ++buff; \
7777+ uint8_t count = *p++; \
7878+ uint8_t trailer[count + 1]; \
7979+ trailer[count] = count; \
8080+ for (uint8_t ii = 0; ii < count; ii++) { \
8181+ uint8_t desc = *p++; \
8282+ uint8_t size = *p++; \
8383+ uint8_t *value = p; \
8484+ p += size; \
8585+ if ((desc >> 4) || (desc & 0x1)) { \
8686+ size = 0;\
8787+ }\
8888+ if (size) {\
8989+ memcpy(&tb[tz], value, size);\
9090+ tz += size;\
9191+ }\
9292+ trailer[ii] = size;\
9393+ }\
9494+ memcpy(&tb[tz], trailer, sizeof(trailer));\
9595+ tz += sizeof(trailer);\
9696+ _os_trace_with_buffer(&__dso_handle, __f, _t, tb, tz, _p);\
9797+ } \
9898+})
9999+#else
100100+#define OS_TRACE_CALL(...)
101101+#endif
102102+103103+// macros to re-order arguments so we can call log function
104104+#define _os_trace_with_payload_1(_t, _f, _p) OS_TRACE_CALL(_t, _p, _f)
105105+#define _os_trace_with_payload_2(_t, _f, _1, _p) OS_TRACE_CALL(_t, _p, _f, _1)
106106+#define _os_trace_with_payload_3(_t, _f, _1, _2, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2)
107107+#define _os_trace_with_payload_4(_t, _f, _1, _2, _3, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3)
108108+#define _os_trace_with_payload_5(_t, _f, _1, _2, _3, _4, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4)
109109+#define _os_trace_with_payload_6(_t, _f, _1, _2, _3, _4, _5, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5)
110110+#define _os_trace_with_payload_7(_t, _f, _1, _2, _3, _4, _5, _6, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5, _6)
111111+#define _os_trace_with_payload_8(_t, _f, _1, _2, _3, _4, _5, _6, _7, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5, _6, _7)
112112+113113+#define _os_trace_call_n(_t, _f, ...) OS_TRACE_CALL(_t, NULL, _f, ##__VA_ARGS__)
114114+115115+/*!
116116+ *
117117+ * @abstract
118118+ * Hashtags in trace messages
119119+ *
120120+ * @discussion
121121+ * Developers are encouraged to include hashtags in log messages, regardless of
122122+ * what API you use.
123123+ * A hashtag is composed of a hash (#) symbol, followed by at least three
124124+ * non-whitespace characters, terminated by whitespace or the end of the
125125+ * message. Hashtags may not begin with a number.
126126+ *
127127+ * Below is the list of predefined tags:
128128+ * #System - Message in the context of a system process.
129129+ * #User - Message in the context of a user process.
130130+ * #Developer - Message in the context of software development. For example,
131131+ * deprecated APIs and debugging messages.
132132+ * #Attention - Message that should be investigated by a system
133133+ * administrator, because it may be a sign of a larger issue.
134134+ * For example, errors from a hard drive controller that
135135+ * typically occur when the drive is about to fail.
136136+ * #Critical - Message in the context of a critical event or failure.
137137+ * #Error - Message that is a noncritical error.
138138+ * #Comment - Message that is a comment.
139139+ * #Marker - Message that marks a change to divide the messages around it
140140+ * into those before and those after the change.
141141+ * #Clue - Message containing extra key/value pairs with additional
142142+ * information to help reconstruct the context.
143143+ * #Security - Message related to security concerns.
144144+ * #Filesystem - Message describing a file system related event.
145145+ * #Network - Message describing a network-related event.
146146+ * #Hardware - Message describing a hardware-related event.
147147+ * #CPU - Message describing CPU related event, e.g., initiating heavy
148148+ * work load
149149+ * #State - Message describing state changed, e.g., global state,
150150+ * preference, etc.
151151+ * #Graphics - Message describing significant graphics event
152152+ * #Disk - Message describing disk activity
153153+ *
154154+ */
155155+156156+#pragma mark - Other defines
157157+158158+/*!
159159+ * @define OS_TRACE_TYPE_RELEASE
160160+ * Trace messages to be captured on a typical user install. These should be
161161+ * limited to things which improve diagnosis of a failure/crash/hang. Trace
162162+ * buffers are generally smaller on a production system.
163163+ */
164164+#define OS_TRACE_TYPE_RELEASE (1u << 0)
165165+166166+/*!
167167+ * @define OS_TRACE_TYPE_DEBUG
168168+ * Trace messages to be captured while debugger or other development tool is
169169+ * attached to the originator.
170170+ */
171171+#define OS_TRACE_TYPE_DEBUG (1u << 1)
172172+173173+/*!
174174+ * @define OS_TRACE_TYPE_INFO
175175+ * Trace messages that are captured when a debugger is attached, system or
176176+ * Application mode has been increased to include additional information.
177177+ */
178178+#define OS_TRACE_TYPE_INFO (1u << 2)
179179+180180+/*!
181181+ * @define OS_TRACE_TYPE_ERROR
182182+ * Trace the message as an error and force a collection as a failure may be
183183+ * imminent.
184184+ */
185185+#define OS_TRACE_TYPE_ERROR ((1u << 6) | (1u << 0))
186186+187187+/*!
188188+ * @define OS_TRACE_TYPE_FAULT
189189+ * Trace the message as a fatal error which forces a collection and a diagnostic
190190+ * to be initiated.
191191+ */
192192+#define OS_TRACE_TYPE_FAULT ((1u << 7) | (1u << 6) | (1u << 0))
193193+194194+/*!
195195+ * @typedef os_trace_payload_t
196196+ *
197197+ * @abstract
198198+ * A block that populates an xpc_object_t of type XPC_TYPE_DICTIONARY to
199199+ * represent complex data.
200200+ *
201201+ * @discussion
202202+ * This block will only be invoked under conditions where tools have attached to
203203+ * the process. The payload can be used to send arbitrary data via the trace
204204+ * call. Tools may use the data to validate state for integration tests or
205205+ * provide other introspection services. No assumptions are made about the
206206+ * format or structure of the data.
207207+ */
208208+typedef void (^os_trace_payload_t)(os_trace_payload_object_t xdict);
209209+210210+#pragma mark - function declarations
211211+212212+/*!
213213+ * @function os_trace
214214+ *
215215+ * @abstract
216216+ * Always inserts a trace message into a buffer pool for later decoding.
217217+ *
218218+ * @discussion
219219+ * Trace message that will be recorded on a typical user install. These should
220220+ * be limited to things which help diagnose a failure during postmortem
221221+ * analysis. Trace buffers are generally smaller on a production system.
222222+ *
223223+ * @param format
224224+ * A printf-style format string to generate a human-readable log message when
225225+ * the trace line is decoded. Only scalar types are supported, attempts
226226+ * to pass arbitrary strings will store a pointer that is unresolvable and
227227+ * will generate an error during decode.
228228+ *
229229+ * <code>
230230+ * os_trace("network event: %ld, last seen: %ld, avg: %g",
231231+ * event_id, last_seen, avg);
232232+ * </code>
233233+ */
234234+#define os_trace(format, ...) OS_TRACE_CALL(OS_TRACE_TYPE_RELEASE, NULL, format, ##__VA_ARGS__)
235235+236236+#if OS_LOG_TARGET_HAS_10_12_FEATURES
237237+/*!
238238+ * @function os_trace_info
239239+ *
240240+ * @abstract
241241+ * Optionally inserts a trace message containing additional information into a
242242+ * buffer pool for later decoding.
243243+ *
244244+ * @discussion
245245+ * Trace messages that will be captured when additional information is needed
246246+ * and are not captured by default. They will only be captured if the
247247+ * system/process/activity mode has been increased or if a Development tool has
248248+ * been attached to the process.
249249+ *
250250+ * @param format
251251+ * A printf-style format string that represents a human-readable message when
252252+ * the trace line is decoded. Only scalar types are supported, attempts
253253+ * to pass arbitrary strings will store a pointer that is unresolvable and
254254+ * will generate an error during decode.
255255+ *
256256+ * <code>
257257+ * os_trace_info("network interface status %ld", status);
258258+ * </code>
259259+ */
260260+#define os_trace_info(format, ...) \
261261+ OS_TRACE_CALL(OS_TRACE_TYPE_INFO, NULL, format, ##__VA_ARGS__)
262262+263263+#endif
264264+265265+/*!
266266+ * @function os_trace_debug
267267+ *
268268+ * @abstract
269269+ * Insert debug trace message into a buffer pool for later decoding.
270270+ *
271271+ * @discussion
272272+ * Debug trace message to be recorded while debugger or other development tool
273273+ * is attached to the originator. This is transported interprocess to help
274274+ * diagnose the entire call chain including external helpers.
275275+ *
276276+ * @param format
277277+ * A printf-style format string that represents a human-readable message when
278278+ * the trace line is decoded. Only scalar types are supported, attempts
279279+ * to pass arbitrary strings will store a pointer that is unresolvable and
280280+ * will generate an error during decode.
281281+ *
282282+ * <code>
283283+ * os_trace_debug("network interface status %ld", status);
284284+ * </code>
285285+ */
286286+#define os_trace_debug(format, ...) \
287287+ OS_TRACE_CALL(OS_TRACE_TYPE_DEBUG, NULL, format, ##__VA_ARGS__)
288288+289289+/*!
290290+ * @function os_trace_info_enabled
291291+ *
292292+ * @abstract
293293+ * Avoid unnecessary work for a trace point by checking if additional
294294+ * information is enabled.
295295+ *
296296+ * @discussion
297297+ * Avoid unnecessary work for a trace point by checking if additional
298298+ * information is enabled. Generally trace points should not involve expensive
299299+ * operations, but some circumstances warrant it. Use this function to avoid
300300+ * doing the work unless debug level trace messages are requested.
301301+ *
302302+ * <code>
303303+ * if (os_trace_info_enabled()) {
304304+ * os_trace_info("value = %d, average = %d",
305305+ * [[dict objectForKey: @"myKey"] intValue],
306306+ * (int)[self getAverage:dict]);
307307+ * }
308308+ * </code>
309309+ *
310310+ * @result
311311+ * Returns true if info types are enabled.
312312+ */
313313+API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
314314+OS_EXPORT OS_NOTHROW OS_WARN_RESULT
315315+bool
316316+os_trace_info_enabled(void);
317317+318318+/*!
319319+ * @function os_trace_debug_enabled
320320+ *
321321+ * @abstract
322322+ * Avoid unnecessary work for a trace point by checking if debug level is
323323+ * enabled.
324324+ *
325325+ * @discussion
326326+ * Avoid unnecessary work for a trace point by checking if debug level is
327327+ * enabled. Generally trace points should not involve expensive operations, but
328328+ * some circumstances warrant it. Use this function to avoid doing the work
329329+ * unless debug level trace messages are requested.
330330+ *
331331+ * <code>
332332+ * if (os_trace_debug_enabled()) {
333333+ * os_trace_debug("value = %d, average = %d",
334334+ * [[dict objectForKey: @"myKey"] intValue],
335335+ * (int)[self getAverage:dict]);
336336+ * }
337337+ * </code>
338338+ *
339339+ * @result
340340+ * Returns true if debug mode is enabled.
341341+ */
342342+API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
343343+OS_EXPORT OS_NOTHROW OS_WARN_RESULT
344344+bool
345345+os_trace_debug_enabled(void);
346346+347347+/*!
348348+ * @function os_trace_type_enabled
349349+ *
350350+ * @abstract
351351+ * Avoid unnecessary work for a trace point by checking a specific type
352352+ *
353353+ * @discussion
354354+ * Avoid unnecessary work for a trace point by checking a specific type
355355+ *
356356+ * @result
357357+ * Returns true if type is enabled.
358358+ */
359359+API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
360360+OS_NOTHROW OS_WARN_RESULT OS_ALWAYS_INLINE
361361+static inline bool
362362+os_trace_type_enabled(uint8_t type)
363363+{
364364+ switch (type) {
365365+ case OS_TRACE_TYPE_INFO:
366366+ return os_trace_info_enabled();
367367+ case OS_TRACE_TYPE_DEBUG:
368368+ return os_trace_debug_enabled();
369369+ }
370370+ return true;
371371+}
372372+373373+/*!
374374+ * @function os_trace_error
375375+ *
376376+ * @abstract
377377+ * Trace the message as an error and force a collection of the trace buffer as
378378+ * a failure may be imminent.
379379+ *
380380+ * @discussion
381381+ * Trace the message as an error and force a collection of the trace buffer as
382382+ * a failure may be imminent.
383383+ *
384384+ * @param format
385385+ * A printf-style format string to generate a human-readable log message when
386386+ * the trace line is decoded. Only scalar types are supported, attempts to pass
387387+ * arbitrary strings will store a pointer that is unresolvable and will generate
388388+ * an error during decode.
389389+ *
390390+ * <code>
391391+ * os_trace_error("socket %d connection timeout %ld", fd, secs);
392392+ * </code>
393393+ */
394394+#define os_trace_error(format, ...) \
395395+ OS_TRACE_CALL(OS_TRACE_TYPE_ERROR, NULL, format, ##__VA_ARGS__)
396396+397397+/*!
398398+ * @function os_trace_fault
399399+ *
400400+ * @abstract
401401+ * Trace the message as a fault which forces a collection of the trace buffer
402402+ * and diagnostic of the activity.
403403+ *
404404+ * @discussion
405405+ * Trace the message as a fault which forces a collection of the trace buffer
406406+ * and diagnostic of the activity.
407407+ *
408408+ * @param format
409409+ * A printf-style format string to generate a human-readable log message when
410410+ * the trace line is decoded. Only scalar types are supported, attempts
411411+ * to pass arbitrary strings will store a pointer that is unresolvable and
412412+ * will generate an error during decode.
413413+ *
414414+ * <code>
415415+ * os_trace_fault("failed to lookup uid %d - aborting", uid);
416416+ * </code>
417417+ */
418418+#define os_trace_fault(format, ...) \
419419+ OS_TRACE_CALL(OS_TRACE_TYPE_FAULT, NULL, format, ##__VA_ARGS__)
420420+421421+#if __has_include(<xpc/xpc.h>)
422422+/*!
423423+ * @function os_trace_with_payload
424424+ *
425425+ * @abstract
426426+ * Add a trace entry containing the provided values and call the block if
427427+ * appropriate.
428428+ *
429429+ * @discussion
430430+ * Will insert a trace entry into a limited ring buffer for an activity or
431431+ * process. Trace points are for recording interesting data that would improve
432432+ * diagnosis of unexpected crashes, failures and hangs. The block will only be
433433+ * called under the required conditions.
434434+ *
435435+ * @param trace_msg
436436+ * A printf-style format string to generate a human-readable log message when
437437+ * the trace line is decoded. Only scalar types are supported. Attempts
438438+ * to pass arbitrary strings will store a pointer that is unresolvable and
439439+ * will generate an error during decode.
440440+ *
441441+ * The final parameter must be a block of type os_trace_payload_t.
442442+ *
443443+ * <code>
444444+ * os_trace_with_payload("network event %ld", event, ^(xpc_object_t xdict) {
445445+ *
446446+ * // validate the network interface and address where what was expected
447447+ * xpc_dictionary_set_string(xdict, "network", ifp->ifa_name);
448448+ * xpc_dictionary_set_string(xdict, "ip_address", _get_address(ifp));
449449+ * });
450450+ * </code>
451451+ */
452452+#define os_trace_with_payload(format, ...) \
453453+ OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
454454+ OS_TRACE_TYPE_RELEASE, format, ##__VA_ARGS__)
455455+456456+#if OS_LOG_TARGET_HAS_10_12_FEATURES
457457+458458+#define os_trace_info_with_payload(format, ...) \
459459+ OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
460460+ OS_TRACE_TYPE_INFO, format, ##__VA_ARGS__)
461461+462462+#else
463463+464464+API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
465465+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
466466+void
467467+os_trace_info_with_payload(const char *format, ...);
468468+469469+#endif // !OS_LOG_TARGET_HAS_10_12_FEATURES
470470+471471+#define os_trace_debug_with_payload(format, ...) \
472472+ OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
473473+ OS_TRACE_TYPE_DEBUG, format, ##__VA_ARGS__)
474474+475475+#define os_trace_error_with_payload(format, ...) \
476476+ OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
477477+ OS_TRACE_TYPE_ERROR, format, ##__VA_ARGS__)
478478+479479+#define os_trace_fault_with_payload(format, ...) \
480480+ OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
481481+ OS_TRACE_TYPE_FAULT, format, ##__VA_ARGS__)
482482+483483+#endif // __has_include(<xpc/xpc.h>)
484484+485485+/*!
486486+ * @function _os_trace_with_buffer
487487+ *
488488+ * @abstract
489489+ * Internal function to support pre-encoded buffer.
490490+ */
491491+API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
492492+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
493493+void
494494+_os_trace_with_buffer(void *dso, const char *message, uint8_t type,
495495+ const void *buffer, size_t buffer_size, os_trace_payload_t payload);
496496+497497+__END_DECLS
498498+499499+#endif // !__OS_TRACE_H__
+96
platform-include/os/trace_base.h
···11+/*
22+ * Copyright (c) 2016 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef __OS_TRACE_BASE_H__
3030+#define __OS_TRACE_BASE_H__
3131+3232+#include <mach-o/loader.h>
3333+#include <stdarg.h>
3434+#include <stdbool.h>
3535+#include <stdint.h>
3636+#include <sys/time.h>
3737+#include <sys/types.h>
3838+#include <unistd.h>
3939+4040+#include <os/availability.h>
4141+#include <os/base.h>
4242+#include <os/object.h>
4343+4444+#define OS_LOG_FORMATLIKE(x, y) __attribute__((format(os_log, x, y)))
4545+4646+#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) \
4747+ || (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0) \
4848+ || (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0) \
4949+ || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12)
5050+#define OS_LOG_TARGET_HAS_10_12_FEATURES 1
5151+#else
5252+#define OS_LOG_TARGET_HAS_10_12_FEATURES 0
5353+#endif
5454+5555+#ifndef OS_COUNT_ARGS
5656+#define OS_COUNT_ARGS(...) OS_COUNT_ARGS1(, ##__VA_ARGS__, _8, _7, _6, _5, _4, _3, _2, _1, _0)
5757+#define OS_COUNT_ARGS1(z, a, b, c, d, e, f, g, h, cnt, ...) cnt
5858+#endif
5959+6060+#ifdef OS_LOG_FORMAT_WARNINGS
6161+#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic warning \"-Wformat\"")
6262+#else
6363+#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic error \"-Wformat\"")
6464+#endif
6565+6666+#define OS_LOG_PRAGMA_PUSH \
6767+ _Pragma("clang diagnostic push") \
6868+ _Pragma("clang diagnostic ignored \"-Wvla\"") \
6969+ OS_LOG_FORMAT_ERRORS
7070+7171+#define OS_LOG_PRAGMA_POP _Pragma("clang diagnostic pop")
7272+7373+#define OS_LOG_STRING(_ns, _var, _str) \
7474+ _Static_assert(__builtin_constant_p(_str), \
7575+ "formatters/labels/descriptions must be a constant string"); \
7676+ __attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) \
7777+ static const char _var[] __asm(OS_STRINGIFY(OS_CONCAT(LOS_##_ns, __COUNTER__))) = _str
7878+7979+8080+#define OS_LOG_REMOVE_PARENS(...) __VA_ARGS__
8181+8282+#define OS_LOG_CALL_WITH_FORMAT(fun, fun_args, fmt, ...) __extension__({ \
8383+ OS_LOG_PRAGMA_PUSH OS_LOG_STRING(LOG, _os_fmt_str, fmt); \
8484+ uint8_t _os_fmt_buf[__builtin_os_log_format_buffer_size(fmt, ##__VA_ARGS__)]; \
8585+ fun(OS_LOG_REMOVE_PARENS fun_args, _os_fmt_str, \
8686+ (uint8_t *)__builtin_os_log_format(_os_fmt_buf, fmt, ##__VA_ARGS__), \
8787+ (uint32_t)sizeof(_os_fmt_buf)) OS_LOG_PRAGMA_POP; \
8888+})
8989+9090+__BEGIN_DECLS
9191+9292+extern struct mach_header __dso_handle;
9393+9494+__END_DECLS
9595+9696+#endif // !__OS_TRACE_BASE_H__
···22#define _LIB_AKS_H_
3344#include <IOKit/IOReturn.h>
55+#include <stdint.h>
66+77+#ifdef __cplusplus
88+extern "C" {
99+#endif
510611// FIXME: I have no idea what these are for, so they are 0 for now
712#define session_keybag_handle 0
···3540extern kern_return_t aks_assert_hold(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType, uint64_t timeout);
36413742extern kern_return_t aks_assert_drop(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType);
4343+4444+#ifdef __cplusplus
4545+}
4646+#endif
38473948#endif
+8-1
src/libaks/include/libaks_smartcard.h
···88#define AKS_SMARTCARD_MODE_RSA 1
99#define AKS_SMARTCARD_MODE_ECDH 2
10101111-CFRef<CFArrayRef> LACreateNewContextWithACMContext(int a, int b);
1111+#ifdef __cplusplus
1212+extern "C" {
1313+#endif
1414+1215void aks_smartcard_unregister(int a);
1316int aks_smartcard_request_unlock(int a, unsigned char *b, int c, void **d, size_t *e);
1417int aks_smartcard_unlock(int a, unsigned char *b, int c, unsigned char *d, int e, void **f, size_t *g);
1518int aks_smartcard_register(int a, unsigned char *b, int c, int d, unsigned char *e, int f, void **g, size_t *h);
1619int aks_smartcard_get_sc_usk(void *a, int b, const void **c, size_t *d);
1720int aks_smartcard_get_ec_pub(void *a, int b, const void **c, size_t *d);
2121+2222+#ifdef __cplusplus
2323+}
2424+#endif
18251926#endif
+42
src/libaks/libaks.c
···11+#include "libaks.h"
22+#include "libaks_smartcard.h"
33+44+void aks_smartcard_unregister(int a)
55+{
66+77+}
88+99+int aks_smartcard_request_unlock(int a, unsigned char *b, int c, void **d, size_t *e)
1010+{
1111+ return 0;
1212+}
1313+1414+int aks_smartcard_unlock(int a, unsigned char *b, int c, unsigned char *d, int e, void **f, size_t *g)
1515+{
1616+ return 0;
1717+}
1818+1919+int aks_smartcard_register(int a, unsigned char *b, int c, int d, unsigned char *e, int f, void **g, size_t *h)
2020+{
2121+ return 0;
2222+}
2323+2424+int aks_smartcard_get_sc_usk(void *a, int b, const void **c, size_t *d)
2525+{
2626+ return 0;
2727+}
2828+2929+int aks_smartcard_get_ec_pub(void *a, int b, const void **c, size_t *d)
3030+{
3131+ return 0;
3232+}
3333+3434+kern_return_t aks_assert_hold(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType, uint64_t timeout)
3535+{
3636+ return KERN_FAILURE;
3737+}
3838+3939+kern_return_t aks_assert_drop(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType)
4040+{
4141+ return KERN_FAILURE;
4242+}
···11-/*
22- * Copyright (c) 2013-2016 Apple Inc. All rights reserved.
33- *
44- * @APPLE_LICENSE_HEADER_START@
55- *
66- * This file contains Original Code and/or Modifications of Original Code
77- * as defined in and that are subject to the Apple Public Source License
88- * Version 2.0 (the 'License'). You may not use this file except in
99- * compliance with the License. Please obtain a copy of the License at
1010- * http://www.opensource.apple.com/apsl/ and read it before using this
1111- * file.
1212- *
1313- * The Original Code and all software distributed under the License are
1414- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1515- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
1616- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
1717- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
1818- * Please see the License for the specific language governing rights and
1919- * limitations under the License.
2020- *
2121- * @APPLE_LICENSE_HEADER_END@
2222- */
2323-2424-#ifndef __OS_ACTIVITY_H__
2525-#define __OS_ACTIVITY_H__
2626-2727-#include <os/object.h>
2828-#include <stdint.h>
2929-#include <stdbool.h>
3030-#include <mach-o/loader.h>
3131-#include <MacTypes.h>
3232-3333-__BEGIN_DECLS
3434-3535-#if ((defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) \
3636- || (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0) \
3737- || (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0) \
3838- || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12))
3939-#define OS_ACTIVITY_OBJECT_API 1
4040-#else
4141-#if OS_ACTIVITY_OBJECT_API
4242-#error Please change your minimum OS requirements because OS_ACTIVITY_OBJECT_API is not available
4343-#endif // OS_ACTIVITY_OBJECT_API
4444-#define OS_ACTIVITY_OBJECT_API 0
4545-#endif
4646-4747-extern void* __dso_handle;
4848-4949-#define OS_LOG_STRING(_var, _str) \
5050- _Static_assert(__builtin_constant_p(_str), "formatters/labels/descriptions must be a constant string"); \
5151- __attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) static const char _var[] __asm(OS_STRINGIFY(OS_CONCAT(LOSACTIVITY_, __COUNTER__))) = _str
5252-5353-/*!
5454- * @typedef os_breadcrumb_t
5555- * An opaque value for the breadcrumb ID.
5656- */
5757-__API_DEPRECATED("No longer supported", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
5858-typedef uint32_t os_breadcrumb_t;
5959-6060-#define OS_ACTIVITY_NULL 0
6161-6262-/*!
6363- * @enum os_activity_flag_t
6464- *
6565- * @discussion
6666- * Support flags for os_activity_create or os_activity_start.
6767- *
6868- * @constant OS_ACTIVITY_FLAG_DEFAULT
6969- * Use the default flags.
7070- *
7171- * @constant OS_ACTIVITY_FLAG_DETACHED
7272- * Detach the newly created activity from the provided activity (if any). If passed in conjunction
7373- * with an exiting activity, the activity will only note what activity "created" the new one, but
7474- * will make the new activity a top level activity. This allows users to see what activity triggered
7575- * work without actually relating the activities.
7676- *
7777- * @constant OS_ACTIVITY_FLAG_IF_NONE_PRESENT
7878- * Will only create a new activity if none present. If an activity ID is already present, a new object
7979- * will be returned with the same activity ID underneath.
8080- */
8181-OS_ENUM(os_activity_flag, uint32_t,
8282- OS_ACTIVITY_FLAG_DEFAULT = 0,
8383- OS_ACTIVITY_FLAG_DETACHED = 0x1,
8484- OS_ACTIVITY_FLAG_IF_NONE_PRESENT = 0x2
8585-);
8686-8787-#if OS_ACTIVITY_OBJECT_API
8888-8989-#define OS_ACTIVITY_NULL NULL
9090-9191-/*!
9292- * @typedef os_activity_t
9393- * An opaque activity object.
9494- */
9595-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
9696-#if OS_OBJECT_USE_OBJC
9797-OS_OBJECT_DECL(os_activity);
9898-#else
9999-typedef struct os_activity_s *os_activity_t;
100100-#endif /* OS_OBJECT_USE_OBJC */
101101-102102-/*!
103103- * @const OS_ACTIVITY_NONE
104104- *
105105- * @discussion
106106- * Create activity with no current traits, this is the equivalent of a
107107- * detached activity.
108108- */
109109-#define OS_ACTIVITY_NONE OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_none)
110110-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
111111-OS_EXPORT
112112-const struct os_activity_s _os_activity_none;
113113-114114-/*!
115115- * @const OS_ACTIVITY_CURRENT
116116- *
117117- * @discussion
118118- * Create activity and links to the current activity if one is present.
119119- * If no activity is present it is treated as if it is detached.
120120- */
121121-#define OS_ACTIVITY_CURRENT OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_current)
122122-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
123123-OS_EXPORT
124124-const struct os_activity_s _os_activity_current;
125125-126126-#else // !OS_ACTIVITY_OBJECT_API
127127-128128-#define OS_ACTIVITY_NULL 0
129129-130130-/*!
131131- * @typedef os_activity_t
132132- * An opaque activity identifier.
133133- */
134134-__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
135135-typedef uint64_t os_activity_t;
136136-137137-#endif // OS_ACTIVITY_OBJECT_API
138138-139139-/*!
140140- * @typedef os_activity_id_t
141141- * An value representing the activity ID assigned to an newly created activity.
142142- */
143143-__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
144144-typedef uint64_t os_activity_id_t;
145145-146146-#if !defined(__TRACE_BUILDING_TRACE__)
147147-/*!
148148- * @typedef os_activity_scope_state_t
149149- * Structure that is populated by os_activity_scope_enter and restored using
150150- * os_activity_scope_leave.
151151- */
152152-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
153153-typedef struct os_activity_scope_state_s {
154154- uint64_t opaque[2];
155155-} *os_activity_scope_state_t;
156156-#else
157157-typedef struct os_activity_scope_state_s *os_activity_scope_state_t;
158158-#endif
159159-160160-#pragma mark - Internal support functions
161161-162162-#if OS_ACTIVITY_OBJECT_API
163163-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
164164-OS_EXPORT OS_NOTHROW OS_WARN_RESULT_NEEDS_RELEASE OS_NOT_TAIL_CALLED OS_OBJECT_RETURNS_RETAINED
165165-os_activity_t
166166-_os_activity_create(void *dso, const char *description, os_activity_t activity, os_activity_flag_t flags);
167167-#endif
168168-169169-/*!
170170- * @function _os_activity_label_useraction
171171- *
172172- * @abstract
173173- * Internal function for use by os_activity_label_useraction. Do not use directly.
174174- */
175175-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
176176-OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
177177-void
178178-_os_activity_label_useraction(void *dso, const char *name);
179179-180180-/*!
181181- * @function _os_activity_initiate
182182- *
183183- * @abstract
184184- * Do not use directly because your description will not be preserved.
185185- */
186186-__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
187187-OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
188188-void
189189-_os_activity_initiate(void *dso, const char *description, os_activity_flag_t flags, os_block_t activity_block OS_NOESCAPE);
190190-191191-/*!
192192- * @function _os_activity_initiate_f
193193- *
194194- * @abstract
195195- * Do not use directly because your description will not be preserved.
196196- */
197197-__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
198198-OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
199199-void
200200-_os_activity_initiate_f(void *dso, const char *description, os_activity_flag_t flags, void *context, os_function_t function);
201201-202202-#pragma mark - Internal deprecated function support
203203-204204-/*!
205205- * @function _os_activity_set_breadcrumb
206206- *
207207- * @abstract
208208- * Internal function for setting breadcrumb. Do not use directly.
209209- */
210210-__API_DEPRECATED_WITH_REPLACEMENT("os_activity_label_useraction", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
211211-OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
212212-void
213213-_os_activity_set_breadcrumb(void *dso, const char *name);
214214-215215-/*!
216216- * @function _os_activity_start
217217- *
218218- * @abstract
219219- * Internal function for activity start, do not use directly will not preserve
220220- * description.
221221- */
222222-__API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
223223-OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NOT_TAIL_CALLED
224224-os_activity_t
225225-_os_activity_start(void *dso, const char *description, os_activity_flag_t flags);
226226-227227-#pragma mark - activity related
228228-229229-/*!
230230- * @function os_activity_initiate
231231- *
232232- * @abstract
233233- * Synchronously initiates an activity using provided block.
234234- *
235235- * @discussion
236236- * Synchronously initiates an activity using the provided block and creates
237237- * a tracing buffer as appropriate. All new activities are created as a
238238- * subactivity of an existing activity on the current thread.
239239- *
240240- * os_activity_initiate("indexing database", OS_ACTIVITY_FLAG_DEFAULT, ^(void) {
241241- * // either do work directly or issue work asynchronously
242242- * });
243243- *
244244- * @param description
245245- * A constant string describing the activity, e.g., "performClick" or
246246- * "menuSelection".
247247- *
248248- * @param flags
249249- * Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
250250- *
251251- * @param activity_block
252252- * The block to execute a given activity
253253- */
254254-#define os_activity_initiate(description, flags, activity_block) __extension__({ \
255255- OS_LOG_STRING(__description, description); \
256256- _os_activity_initiate(&__dso_handle, __description, flags, activity_block); \
257257-})
258258-259259-/*!
260260- * @function os_activity_initiate_f
261261- *
262262- * @abstract
263263- * Synchronously initiates an activity using the provided function.
264264- *
265265- * @discussion
266266- * Synchronously initiates an activity using the provided function and creates
267267- * a tracing buffer as appropriate. All new activities are created as a
268268- * subactivity of an existing activity on the current thread.
269269- *
270270- * os_activity_initiate_f("indexing database", OS_ACTIVITY_FLAG_DEFAULT, context, function);
271271- *
272272- * @param description
273273- * A constant string describing the activity, e.g., "performClick" or
274274- * "menuSelection".
275275- *
276276- * @param flags
277277- * Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
278278- *
279279- * @param context
280280- * An optional context that will be supplied to the activity function.
281281- *
282282- * @param activity_func
283283- * The function to execute for the new activity.
284284- */
285285-#define os_activity_initiate_f(description, flags, context, function) __extension__({ \
286286- OS_LOG_STRING(__description, description); \
287287- _os_activity_initiate_f(&__dso_handle, __description, flags, context, function); \
288288-})
289289-290290-#if OS_ACTIVITY_OBJECT_API
291291-/*!
292292- * @function os_activity_create
293293- *
294294- * @abstract
295295- * Creates an os_activity_t object which can be passed to os_activity_apply function.
296296- *
297297- * @discussion
298298- * Creates an os_activity_t object which can be passed to os_activity_apply function.
299299- *
300300- * @param description
301301- * Pass a description for the activity. The description must be a constant string
302302- * within the calling executable or library.
303303- *
304304- * @param parent_activity
305305- * Depending on flags will link the newly created activity to the value passed or
306306- * note where the activity was created. Possible activities include: OS_ACTIVITY_NONE,
307307- * OS_ACTIVITY_CURRENT or any existing os_activity_t object created using os_activity_create.
308308- *
309309- * @param flags
310310- * A valid os_activity_flag_t which will determine behavior of the newly created activity.
311311- *
312312- * @result
313313- * Returns an os_activity_t object which can be used with os_activity_apply.
314314- */
315315-#define os_activity_create(description, parent_activity, flags) __extension__({ \
316316- OS_LOG_STRING(__description, description); \
317317- os_activity_t __activity = _os_activity_create(&__dso_handle, __description, parent_activity, flags); \
318318- __activity; \
319319-})
320320-321321-/*!
322322- * @function os_activity_apply
323323- *
324324- * @abstract
325325- * Execute a block using a given activity object.
326326- *
327327- * @discussion
328328- * Execute a block using a given activity object.
329329- *
330330- * @param activity
331331- * There are global objects available which include: OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT
332332- * or an existing os_activity_t object.
333333- *
334334- * @param block
335335- * Pass the block to be executed within the context of the given activity.
336336- */
337337-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
338338-OS_EXPORT OS_NOTHROW
339339-void
340340-os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
341341-342342-/*!
343343- * @function os_activity_apply_f
344344- *
345345- * @abstract
346346- * Execute a given function with a provided activity.
347347- *
348348- * @discussion
349349- * Execute a given function with a provided activity.
350350- *
351351- * @param activity
352352- * There are global objects available which include: OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT
353353- * or an existing os_activity_t object.
354354- *
355355- * @param context
356356- * Context to pass to the function which may be NULL.
357357- *
358358- * @param function
359359- * Pass the function to be executed within the context of the given activity.
360360- */
361361-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
362362-OS_EXPORT OS_NOTHROW
363363-void
364364-os_activity_apply_f(os_activity_t activity, void *context, os_function_t function);
365365-366366-/*!
367367- * @function os_activity_scope_enter
368368- *
369369- * @abstract
370370- * Will change the current execution context to use the provided activity.
371371- *
372372- * @discussion
373373- * Will change the current execution context to use the provided activity. An activity
374374- * can be created and then applied to the current scope by doing:
375375- *
376376- * struct os_activity_scope_state_s state;
377377- * os_activity_t activity = os_activity_create("my new activity", 0);
378378- * os_activity_scope_enter(activity, &state);
379379- * ... do some work ...
380380- * os_activity_scope_leave(&state);
381381- *
382382- * To auto-cleanup state call:
383383- *
384384- * os_activity_scope(activity);
385385- *
386386- * @param activity
387387- * Pass a valid activity created with os_activity_create or any global object.
388388- *
389389- * @param state
390390- * A stack-based struct os_activity_scope_state_s to store the state.
391391- */
392392-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
393393-OS_EXPORT OS_NOTHROW
394394-void
395395-os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state);
396396-397397-/*!
398398- * @function os_activity_scope_leave
399399- *
400400- * @abstract
401401- * Will pop state up to the state provided.
402402- *
403403- * @discussion
404404- * Will leave scope using the state provided. If state is not present an error will be
405405- * generated.
406406- *
407407- * @param state
408408- * Must be a valid value filled by os_activity_scope_enter call.
409409- */
410410-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
411411-OS_EXPORT OS_NOTHROW
412412-void
413413-os_activity_scope_leave(os_activity_scope_state_t state);
414414-415415-#if defined(__GNUC__)
416416-#define _os_activity_scope(var, activity) \
417417- struct os_activity_scope_state_s var __attribute__((__cleanup__(os_activity_scope_leave))); \
418418- os_activity_scope_enter(activity, &var)
419419-#define os_activity_scope(activity) _os_activity_scope(OS_CONCAT(scope, __COUNTER__), activity)
420420-#endif
421421-422422-#endif // OS_ACTIVITY_OBJECT_API
423423-424424-/*!
425425- * @function os_activity_start
426426- *
427427- * @abstract
428428- * Starts a new activity immediately within the current context.
429429- *
430430- * @discussion
431431- * Starts a new activity immediately within the current context. Deprecated please use new
432432- * os_activity_create and os_activity_apply.
433433- *
434434- * os_activity_t activity = os_activity_start("indexing database", OS_ACTIVITY_FLAG_DEFAULT);
435435- * < do some work >
436436- * os_activity_end(activity);
437437- *
438438- * @param description
439439- * A constant string describing the activity, e.g., "performClick" or
440440- * "menuSelection".
441441- *
442442- * @param flags
443443- * Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
444444- *
445445- * @result
446446- * Returns a valid os_activity_id_t or 0 on failure.
447447- */
448448-#define os_activity_start(description, flags) __extension__({ \
449449- OS_LOG_STRING(__description, description); \
450450- os_activity_t _aid = _os_activity_start(&__dso_handle, __description, flags); \
451451- _aid; \
452452-})
453453-454454-/*!
455455- * @function os_activity_end
456456- *
457457- * @abstract
458458- * Ends the specified activity on the current thread.
459459- *
460460- * @discussion
461461- * Ends the specified activity on the current thread. Does not signify anything
462462- * other than the originator has received control back from the activity. Work
463463- * could still be in flight related to the activity.
464464- *
465465- * @param activity
466466- * An os_activity_t returned from os_activity_start.
467467- */
468468-__API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
469469-OS_EXPORT OS_NOTHROW
470470-void
471471-os_activity_end(os_activity_t activity);
472472-473473-/*!
474474- * @function os_activity_get_active
475475- *
476476- * @abstract
477477- * Returns the stack of nested activities associated with the current thread.
478478- *
479479- * @discussion
480480- * Activities have a sense of nesting and therefore there could be more than
481481- * one activity involved on the current thread. This should be used by
482482- * diagnostic tools only for making additional decisions about a situation.
483483- *
484484- * @param entries
485485- * Pass a buffer of sufficient size to hold the the number of os_activity_id_t
486486- * being requested.
487487- *
488488- * @param count
489489- * Pointer to the requested number of activity identifiers.
490490- * On output will be filled with the number of activities that are available.
491491- *
492492- * @result
493493- * Number of activity identifiers written to 'entries'
494494- */
495495-__API_DEPRECATED("No longer supported", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
496496-OS_EXPORT OS_NOTHROW
497497-unsigned int
498498-os_activity_get_active(os_activity_id_t *entries, unsigned int *count);
499499-500500-/*!
501501- * @function os_activity_get_identifier
502502- *
503503- * @abstract
504504- * Returns the current activity ID and will fill the parent_id if present.
505505- *
506506- * @discussion
507507- * Returns the current activity ID and will fill the parent_id if present.
508508- *
509509- * @param parent_id
510510- * If non-null will set the parent activity ID.
511511- *
512512- * @result
513513- * The identifier for the provided activity.
514514- */
515515-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
516516-OS_EXPORT OS_NOTHROW OS_NONNULL1 OS_WARN_RESULT
517517-os_activity_id_t
518518-os_activity_get_identifier(os_activity_t activity, os_activity_id_t *parent_id);
519519-520520-/*!
521521- * @function os_activity_label_useraction
522522- *
523523- * @abstract
524524- * Label an activity that is auto-generated by AppKit/UIKit with a name that is useful
525525- * for debugging macro-level user actions.
526526- *
527527- * @discussion
528528- * Label an activity that is auto-generated by AppKit/UIKit with a name that is useful
529529- * for debugging macro-level user actions. The API should be called early within the scope
530530- * of the IBAction and before any sub-activities are created. The name provided will
531531- * be shown in tools in additon to the underlying AppKit/UIKit provided name. This API
532532- * can only be called once and only on the activity created by AppKit/UIKit. These actions
533533- * help determine workflow of the user in order to reproduce problems that occur.
534534- * For example, a control press and/or menu item selection can be labeled:
535535- *
536536- * os_activity_label_useraction("New mail message");
537537- * os_activity_label_useraction("Empty trash");
538538- *
539539- * Where the underlying AppKit/UIKit name will be "gesture:" or "menuSelect:".
540540- *
541541- * @param name
542542- * A constant string that describes the the action.
543543- */
544544-#define os_activity_label_useraction(label) __extension__({ \
545545- OS_LOG_STRING(__label, label); \
546546- _os_activity_label_useraction(&__dso_handle, __label); \
547547-})
548548-549549-#pragma mark - application breadcrumbs
550550-551551-/*!
552552- * @function os_activity_set_breadcrumb
553553- *
554554- * @abstract
555555- * This flags the current activity as a "breadcrumb", i.e., an interesting event.
556556- *
557557- * @discussion
558558- * Not all activities are interesting events at the macro-level. Some activities
559559- * can be flagged as a breadcrumb for evalutating cross activity interactions.
560560- * This can only be called once per activity, other requests will be ignored.
561561- *
562562- * @param name
563563- * A constant string that describes the breadcrumb.
564564- */
565565-#define os_activity_set_breadcrumb(name) __extension__({ \
566566- OS_LOG_STRING(__name, name); \
567567- _os_activity_set_breadcrumb(&__dso_handle, __name); \
568568-})
569569-570570-__END_DECLS
571571-572572-#endif // __OS_ACTIVITY_H__
···11-/*
22- * Copyright (c) 2015-2016 Apple Inc. All rights reserved.
33- *
44- * @APPLE_LICENSE_HEADER_START@
55- *
66- * This file contains Original Code and/or Modifications of Original Code
77- * as defined in and that are subject to the Apple Public Source License
88- * Version 2.0 (the 'License'). You may not use this file except in
99- * compliance with the License. Please obtain a copy of the License at
1010- * http://www.opensource.apple.com/apsl/ and read it before using this
1111- * file.
1212- *
1313- * The Original Code and all software distributed under the License are
1414- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1515- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
1616- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
1717- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
1818- * Please see the License for the specific language governing rights and
1919- * limitations under the License.
2020- *
2121- * @APPLE_LICENSE_HEADER_END@
2222- */
11+#ifndef __OS_LOG_H__
22+#define __OS_LOG_H__
2332424-#ifndef __os_log_h
2525-#define __os_log_h
2626-2727-#include <os/object.h>
2828-#include <os/base.h>
2929-#include <os/trace.h>
304#include <stdint.h>
315#include <stdbool.h>
326#include <mach-o/loader.h>
77+#include <os/availability.h>
88+#include <os/base.h>
99+#include <os/object.h>
1010+#include <os/trace.h>
33113412#if !__has_builtin(__builtin_os_log_format)
3535-//#warning using os/log.h requires Xcode 8 or later
1313+#error using os/log.h requires Xcode 8 or later
3614#endif
37153816__BEGIN_DECLS
39174040-#ifdef OS_LOG_FORMAT_WARNINGS
4141-#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic warning \"-Wformat\"")
4242-#else
4343-#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic error \"-Wformat\"")
4444-#endif
4545-4646-extern void* __dso_handle;
4747-4818#if OS_OBJECT_SWIFT3
4919OS_OBJECT_DECL_SWIFT(os_log);
5020#elif OS_OBJECT_USE_OBJC
···5929 * @discussion
6030 * Use this to disable a specific log message.
6131 */
6262-#if OS_LOG_TARGET_HAS_10_13_FEATURES
6363-#define OS_LOG_DISABLED OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_disabled)
6464-API_AVAILABLE(macosx(10.13), ios(11.0), watchos(4.0), tvos(11.0))
6565-OS_EXPORT
6666-struct os_log_s _os_log_disabled;
6767-#else
6868-#define OS_LOG_DISABLED ((os_log_t _Nonnull)NULL)
6969-#endif
3232+#define OS_LOG_DISABLED NULL
70337134/*!
7235 * @const OS_LOG_DEFAULT
···7538 * Use this to log a message in accordance with current system settings.
7639 */
7740#define OS_LOG_DEFAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_default)
7878-__API_AVAILABLE(macosx(10.11), ios(9.0), watchos(2.0), tvos(9.0))
4141+API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
7942OS_EXPORT
8043struct os_log_s _os_log_default;
8144···8649 * Supported log message types.
8750 *
8851 * @constant OS_LOG_TYPE_DEFAULT
8989- * Equivalent type for "os_log()" messages, i.e., default messages that are always
9090- * captured to memory or disk.
5252+ * Equivalent type for "os_log()" messages, i.e., default messages that are
5353+ * always captured to memory or disk.
9154 *
9255 * @constant OS_LOG_TYPE_INFO
9393- * Equivalent type for "os_log_info()" messages, i.e., Additional informational messages.
5656+ * Equivalent type for "os_log_info()" messages, i.e., Additional informational
5757+ * messages.
9458 *
9559 * @constant OS_LOG_TYPE_DEBUG
9660 * Equivalent type for "os_log_debug()" messages, i.e., Debug messages.
9761 *
9862 * @constant OS_LOG_TYPE_ERROR
9999- * Equivalent type for "os_log_error()" messages, i.e., local process error messages.
6363+ * Equivalent type for "os_log_error()" messages, i.e., local process error
6464+ * messages.
10065 *
10166 * @constant OS_LOG_TYPE_FAULT
102102- * Equivalent type for "os_log_fault()" messages, i.e., a system error that involves
103103- * potentially more than one process, usually used by daemons and services.
6767+ * Equivalent type for "os_log_fault()" messages, i.e., a system error that
6868+ * involves potentially more than one process, usually used by daemons and
6969+ * services.
10470 */
10571OS_ENUM(os_log_type, uint8_t,
106106- OS_LOG_TYPE_DEFAULT = 0x00,
107107- OS_LOG_TYPE_INFO = 0x01,
108108- OS_LOG_TYPE_DEBUG = 0x02,
109109- OS_LOG_TYPE_ERROR = 0x10,
110110- OS_LOG_TYPE_FAULT = 0x11);
7272+ OS_LOG_TYPE_DEFAULT = 0x00,
7373+ OS_LOG_TYPE_INFO = 0x01,
7474+ OS_LOG_TYPE_DEBUG = 0x02,
7575+ OS_LOG_TYPE_ERROR = 0x10,
7676+ OS_LOG_TYPE_FAULT = 0x11,
7777+);
1117811279/*!
11380 * @function os_log_create
···138105 *
139106 * A value will always be returned to allow for dynamic enablement.
140107 */
141141-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
108108+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
142109OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_OBJECT_RETURNS_RETAINED OS_NONNULL_ALL
143110os_log_t
144111os_log_create(const char *subsystem, const char *category);
···197164 * line is decoded. This string must be a constant string, not dynamically
198165 * generated. Supports all standard printf types in addition to %@ (objects).
199166 */
200200-#if !__has_builtin(__builtin_os_log_format)
201201-#define os_log_with_type(log, type, format, ...)
202202-#else
203167#define os_log_with_type(log, type, format, ...) __extension__({ \
204204- if (os_log_type_enabled(log, type)) { \
205205- _Pragma("clang diagnostic push") \
206206- _Pragma("clang diagnostic ignored \"-Wvla\"") \
207207- OS_LOG_FORMAT_ERRORS \
208208- __attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) static const char __format[] __asm(OS_STRINGIFY(OS_CONCAT(LOSLOG_, __COUNTER__))) = format; \
209209- uint8_t _os_log_buf[__builtin_os_log_format_buffer_size(format, ##__VA_ARGS__)]; \
210210- _os_log_impl(&__dso_handle, log, type, __format, (uint8_t *) __builtin_os_log_format(_os_log_buf, format, ##__VA_ARGS__), (unsigned int) sizeof(_os_log_buf)); \
211211- _Pragma("clang diagnostic pop") \
168168+ os_log_t _log_tmp = (log); \
169169+ os_log_type_t _type_tmp = (type); \
170170+ if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
171171+ OS_LOG_CALL_WITH_FORMAT(_os_log_impl, \
172172+ (&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
212173 } \
213174})
214214-#endif
215175216176/*!
217177 * @function os_log
···220180 * Insert a log message into the Unified Logging and Tracing system.
221181 *
222182 * @discussion
223223- * Insert a log message into the Unified Logging and Tracing system in
183183+ * Insert a log message into the Unified Logging and Tracing system in
224184 * accordance with the preferences specified by the provided log object.
225185 * These messages cannot be disabled and therefore always captured either
226186 * to memory or disk.
···242202 * line is decoded. This string must be a constant string, not dynamically
243203 * generated. Supports all standard printf types and %@ (objects).
244204 */
245245-#define os_log(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__)
205205+#define os_log(log, format, ...) \
206206+ os_log_with_type(log, OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__)
246207247208/*!
248209 * @function os_log_info
···252213 * and Tracing system.
253214 *
254215 * @discussion
255255- * Insert a log message into the Unified Logging and Tracing system in
216216+ * Insert a log message into the Unified Logging and Tracing system in
256217 * accordance with the preferences specified by the provided log object.
257218 *
258219 * When an os_activity_id_t is present, the log message will also be scoped by
···272233 * line is decoded. This string must be a constant string, not dynamically
273234 * generated. Supports all standard printf types and %@ (objects).
274235 */
275275-#define os_log_info(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_INFO, format, ##__VA_ARGS__)
236236+#define os_log_info(log, format, ...) \
237237+ os_log_with_type(log, OS_LOG_TYPE_INFO, format, ##__VA_ARGS__)
276238277239/*!
278240 * @function os_log_debug
···301263 * line is decoded. This string must be a constant string, not dynamically
302264 * generated. Supports all standard printf types and %@ (objects).
303265 */
304304-#define os_log_debug(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__)
266266+#define os_log_debug(log, format, ...) \
267267+ os_log_with_type(log, OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__)
305268306269/*!
307270 * @function os_log_error
···329292 * line is decoded. This string must be a constant string, not dynamically
330293 * generated. Supports all standard printf types and %@ (objects).
331294 */
332332-#define os_log_error(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__)
295295+#define os_log_error(log, format, ...) \
296296+ os_log_with_type(log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__)
333297334298/*!
335299 * @function os_log_fault
···340304 * @discussion
341305 * Log a fault message issue into the Unified Logging and Tracing system
342306 * signifying a multi-process (i.e., system error) related issue, either
343343- * due to interaction via IPC or some other. Faults will gather information
307307+ * due to interaction via IPC or some other. Faults will gather information
344308 * from the entire process chain and record it for later inspection.
345309 *
346310 * When an os_activity_id_t is present, the log message will also be scoped by
···360324 * line is decoded. This string must be a constant string, not dynamically
361325 * generated. Supports all standard printf types and %@ (objects).
362326 */
363363-#define os_log_fault(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__)
327327+#define os_log_fault(log, format, ...) \
328328+ os_log_with_type(log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__)
364329365330/*!
366331 * @function os_log_type_enabled
···371336 * @discussion
372337 * Evaluate if a specific log type is enabled before doing work
373338 *
374374- * @param log
339339+ * @param oslog
375340 * Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
376341 *
377342 * @param type
···380345 * @result
381346 * Will return a boolean.
382347 */
383383-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
348348+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
384349OS_EXPORT OS_NOTHROW OS_WARN_RESULT
385350bool
386351os_log_type_enabled(os_log_t oslog, os_log_type_t type);
···391356 * @abstract
392357 * Internal function that takes compiler generated encoding and captures the necessary content.
393358 */
394394-__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
359359+API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
395360OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
396361void
397397-_os_log_impl(void *dso, os_log_t log, os_log_type_t type, const char *format, uint8_t *buf, unsigned int size);
362362+_os_log_impl(void *dso, os_log_t log, os_log_type_t type,
363363+ const char *format, uint8_t *buf, uint32_t size);
398364399365/*
400366 * Support for older iteration of API for source compatibility only...
401367 */
402368403403-__API_DEPRECATED("no longer supported, use os_log_debug(OS_LOG_DEFAULT, ...)", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
369369+API_DEPRECATED("no longer supported, use os_log_debug(OS_LOG_DEFAULT, ...)",
370370+ macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
404371OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
405372void
406373_os_log_internal(void *dso, os_log_t log, os_log_type_t type, const char *message, ...);
407374408408-__API_AVAILABLE(macosx(10.11), ios(9.0), watchos(2.0), tvos(9.0))
375375+API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
409376OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_OBJECT_RETURNS_RETAINED OS_NOT_TAIL_CALLED OS_NONNULL_ALL
410377os_log_t
411378_os_log_create(void *dso, const char *subsystem, const char *category);
412379413413-__API_DEPRECATED("no longer suppored - always returns true", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
380380+API_DEPRECATED("no longer suppored - always returns true",
381381+ macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
414382OS_EXPORT OS_NOTHROW OS_WARN_RESULT
415383bool
416384os_log_is_enabled(os_log_t log);
417385418418-__API_DEPRECATED_WITH_REPLACEMENT("os_log_debug_enabled", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
386386+API_DEPRECATED_WITH_REPLACEMENT("os_log_debug_enabled",
387387+ macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
419388OS_EXPORT OS_NOTHROW OS_WARN_RESULT
420389bool
421390os_log_is_debug_enabled(os_log_t log);
422391423423-__API_DEPRECATED("no longer supported - use os_log with per-parameter privacy options", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
392392+API_DEPRECATED("no longer supported - use os_log with per-parameter privacy options",
393393+ macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
424394OS_NOTHROW OS_ALWAYS_INLINE
425395static inline void
426396_os_log_sensitive_deprecated(void) { }
···436406})
437407438408#define OS_LOG_RELEASE OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_release)
439439-__API_DEPRECATED("use os_log(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
409409+API_DEPRECATED("use os_log(OS_LOG_DEFAULT, ...)",
410410+ macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
440411OS_EXPORT
441412struct os_log_s _os_log_release;
442413443414#define OS_LOG_DEBUG OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_debug)
444444-__API_DEPRECATED("use os_log_debug(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
415415+API_DEPRECATED("use os_log_debug(OS_LOG_DEFAULT, ...)",
416416+ macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
445417OS_EXPORT
446418struct os_log_s _os_log_debug;
447419448420#define OS_LOG_ERROR OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_error)
449449-__API_DEPRECATED("use os_log_error(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
421421+API_DEPRECATED("use os_log_error(OS_LOG_DEFAULT, ...)",
422422+ macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
450423OS_EXPORT
451424struct os_log_s _os_log_error;
452425453426#define OS_LOG_FAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_fault)
454454-__API_DEPRECATED("use os_log_fault(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
427427+API_DEPRECATED("use os_log_fault(OS_LOG_DEFAULT, ...)",
428428+ macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
455429OS_EXPORT
456430struct os_log_s _os_log_fault;
457431458458-#if ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) \
459459- || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(__TV_OS_VERSION_MIN_REQUIRED) \
460460- && !defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) \
461461- || (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) \
462462- || (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0))
432432+#if !OS_LOG_TARGET_HAS_10_12_FEATURES
463433#undef os_log_with_type
464434#define os_log_with_type(log, type, format, ...) __extension__({ \
465435 _Pragma("clang diagnostic push") \
466436 _Pragma("clang diagnostic error \"-Wformat\"") \
437437+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
467438 _os_log_internal(&__dso_handle, log, type, format, ##__VA_ARGS__); \
468439 _Pragma("clang diagnostic pop") \
469440})
···472443#define os_log_debug_enabled(...) os_log_is_debug_enabled(__VA_ARGS__)
473444474445#undef os_log_create
475475-#define os_log_create(subsystem, category) _os_log_create(&__dso_handle, subsystem, category)
476476-#endif
446446+#define os_log_create(subsystem, category) \
447447+ _os_log_create(&__dso_handle, subsystem, category)
448448+#endif // !OS_LOG_TARGET_HAS_10_12_FEATURES
477449478450__END_DECLS
479451480480-#endif /* __os_log_h */
452452+#endif // !__OS_LOG_H__