OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 //! \brief `MACH_PORT_NULL` with the correct type for a Mach port, | 22 //! \brief `MACH_PORT_NULL` with the correct type for a Mach port, |
23 //! `mach_port_t`. | 23 //! `mach_port_t`. |
24 //! | 24 //! |
25 //! For situations where implicit conversions between signed and unsigned types | 25 //! For situations where implicit conversions between signed and unsigned types |
26 //! are not performed, use kMachPortNull instead of an explicit `static_cast` of | 26 //! are not performed, use kMachPortNull instead of an explicit `static_cast` of |
27 //! `MACH_PORT_NULL` to `mach_port_t`. This is useful for logging and testing | 27 //! `MACH_PORT_NULL` to `mach_port_t`. This is useful for logging and testing |
28 //! assertions. | 28 //! assertions. |
29 const mach_port_t kMachPortNull = MACH_PORT_NULL; | 29 const mach_port_t kMachPortNull = MACH_PORT_NULL; |
30 | 30 |
| 31 //! \brief `MACH_EXCEPTION_CODES` with the correct type for a Mach exception |
| 32 //! behavior, `exception_behavior_t`. |
| 33 //! |
| 34 //! Signedness problems can occur when ORing `MACH_EXCEPTION_CODES` as a signed |
| 35 //! integer, because a signed integer overflow results. This constant can be |
| 36 //! used instead of `MACH_EXCEPTION_CODES` in such cases. |
| 37 const exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES; |
| 38 |
31 // Because exception_mask_t is an int and has one bit for each defined | 39 // Because exception_mask_t is an int and has one bit for each defined |
32 // exception_type_t, it’s reasonable to assume that there cannot be any | 40 // exception_type_t, it’s reasonable to assume that there cannot be any |
33 // officially-defined exception_type_t values higher than 31. | 41 // officially-defined exception_type_t values higher than 31. |
34 // kMachExceptionSimulated uses a value well outside this range because it does | 42 // kMachExceptionSimulated uses a value well outside this range because it does |
35 // not require a corresponding mask value. Simulated exceptions are delivered to | 43 // not require a corresponding mask value. Simulated exceptions are delivered to |
36 // the exception handler registered for EXC_CRASH exceptions using | 44 // the exception handler registered for EXC_CRASH exceptions using |
37 // EXC_MASK_CRASH. | 45 // EXC_MASK_CRASH. |
38 | 46 |
39 //! \brief An exception type to use for simulated exceptions. | 47 //! \brief An exception type to use for simulated exceptions. |
40 const exception_type_t kMachExceptionSimulated = 'CPsx'; | 48 const exception_type_t kMachExceptionSimulated = 'CPsx'; |
41 | 49 |
| 50 //! \brief Like `mach_thread_self()`, but without the obligation to release the |
| 51 //! send right. |
| 52 //! |
| 53 //! `mach_thread_self()` returns a send right to the current thread port, |
| 54 //! incrementing its reference count. This burdens the caller with maintaining |
| 55 //! this send right, and calling `mach_port_deallocate()` when it is no longer |
| 56 //! needed. This is burdensome, and is at odds with the normal operation of |
| 57 //! `mach_task_self()`, which does not increment the task port’s reference count |
| 58 //! whose result must not be deallocated. |
| 59 //! |
| 60 //! Callers can use this function in preference to `mach_thread_self()`. This |
| 61 //! function returns an extant reference to the current thread’s port without |
| 62 //! incrementing its reference count. |
| 63 //! |
| 64 //! \return The value of `mach_thread_self()` without incrementing its reference |
| 65 //! count. The returned port must not be deallocated by |
| 66 //! `mach_port_deallocate()`. The returned value is valid as long as the |
| 67 //! thread continues to exist as a `pthread_t`. |
| 68 mach_port_t MachThreadSelf(); |
| 69 |
42 } // namespace crashpad | 70 } // namespace crashpad |
43 | 71 |
44 #endif // CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ | 72 #endif // CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ |
OLD | NEW |