Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: util/mach/mach_extensions.h

Issue 567283002: Add exc_client_variants (UniversalRaiseException()) and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Put MachThreadSelf in mach_extensions.{cc,h} Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/mach/exc_server_variants_test.cc ('k') | util/mach/mach_extensions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mach/mach_extensions.h
diff --git a/util/mach/mach_extensions.h b/util/mach/mach_extensions.h
index 81e9a86a97f6f72b486f53606e3d594827010696..038904bf30767d953d31e0da94ef9421a0a239e2 100644
--- a/util/mach/mach_extensions.h
+++ b/util/mach/mach_extensions.h
@@ -28,6 +28,14 @@ namespace crashpad {
//! assertions.
const mach_port_t kMachPortNull = MACH_PORT_NULL;
+//! \brief `MACH_EXCEPTION_CODES` with the correct type for a Mach exception
+//! behavior, `exception_behavior_t`.
+//!
+//! Signedness problems can occur when ORing `MACH_EXCEPTION_CODES` as a signed
+//! integer, because a signed integer overflow results. This constant can be
+//! used instead of `MACH_EXCEPTION_CODES` in such cases.
+const exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES;
+
// Because exception_mask_t is an int and has one bit for each defined
// exception_type_t, it’s reasonable to assume that there cannot be any
// officially-defined exception_type_t values higher than 31.
@@ -39,6 +47,26 @@ const mach_port_t kMachPortNull = MACH_PORT_NULL;
//! \brief An exception type to use for simulated exceptions.
const exception_type_t kMachExceptionSimulated = 'CPsx';
+//! \brief Like `mach_thread_self()`, but without the obligation to release the
+//! send right.
+//!
+//! `mach_thread_self()` returns a send right to the current thread port,
+//! incrementing its reference count. This burdens the caller with maintaining
+//! this send right, and calling `mach_port_deallocate()` when it is no longer
+//! needed. This is burdensome, and is at odds with the normal operation of
+//! `mach_task_self()`, which does not increment the task port’s reference count
+//! whose result must not be deallocated.
+//!
+//! Callers can use this function in preference to `mach_thread_self()`. This
+//! function returns an extant reference to the current thread’s port without
+//! incrementing its reference count.
+//!
+//! \return The value of `mach_thread_self()` without incrementing its reference
+//! count. The returned port must not be deallocated by
+//! `mach_port_deallocate()`. The returned value is valid as long as the
+//! thread continues to exist as a `pthread_t`.
+mach_port_t MachThreadSelf();
+
} // namespace crashpad
#endif // CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_
« no previous file with comments | « util/mach/exc_server_variants_test.cc ('k') | util/mach/mach_extensions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698