]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOReporterDefs.h
2 * Copyright (c) 2012-2013 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _IOEPORTERDEFS_H
30 #define _IOEPORTERDEFS_H
32 //#include "IOReportHubCommon.h"
34 //#define IORDEBUG_IOLOG
36 #if defined(IORDEBUG_IOLOG)
37 #define IORLOG(fmt, args...) \
39 IOLog((fmt), ##args); \
44 #define IORLOG(fmt, args...)
50 #define IORERROR(fmt, args...) IOLog(fmt, ##args);
52 #define IORERROR(fmt, args...)
55 // overflow detection routines
56 #if (SIZE_T_MAX < INT_MAX)
57 #error "(SIZE_T_MAX < INT_MAX) -> PREFL_MEMOP_*()) unsafe for size_t"
60 #define PREFL_MEMOP_FAIL(__val, __type) do { \
62 IORERROR("%s - %s <= 0!\n", __func__, #__val); \
63 res = kIOReturnUnderrun; \
65 } else if (__val > INT_MAX / (int)sizeof(__type)) { \
66 IORERROR("%s - %s > INT_MAX / sizeof(%s)!\n",__func__,#__val,#__type);\
67 res = kIOReturnOverrun; \
72 #define PREFL_MEMOP_PANIC(__val, __type) do { \
74 panic("%s - %s <= 0!", __func__, #__val); \
75 } else if (__val > INT_MAX / (int)sizeof(__type)) { \
76 panic("%s - %s > INT_MAX / sizeof(%s)!", __func__, #__val, #__type); \
80 //#include "IOReportHubCommon.h"//
84 #define IOREPORTER_DEBUG_ELEMENT(idx) \
86 IOLog("IOReporter::DrvID: %llx | Elt:[%3d] |ID: %llx |Ticks: %llu |", \
87 _elements[idx].provider_id, \
89 _elements[idx].channel_id, \
90 _elements[idx].timestamp); \
91 IOLog("0: %llu | 1: %llu | 2: %llu | 3: %llu\n", \
92 _elements[idx].values.v[0], \
93 _elements[idx].values.v[1], \
94 _elements[idx].values.v[2], \
95 _elements[idx].values.v[3]); \
99 #define IOREPORTER_CHECK_LOCK() \
101 if (!_reporterIsLocked) { \
102 panic("%s was called out of locked context!", __PRETTY_FUNCTION__); \
106 #define IOREPORTER_CHECK_CONFIG_LOCK() \
108 if (!_reporterConfigIsLocked) { \
109 panic("%s was called out of config locked context!", __PRETTY_FUNCTION__); \
113 #endif /* ! _IOEPORTERDEFS_H */