+/* Defined in xnu unix_signal.c */
+#define UC_RESET_ALT_STACK 0x80000000
+extern int sigreturn (void *uc, int flavour);
+
+/* Return true if ADDR is within a stack guard area. */
+static int
+__gnat_is_stack_guard (mach_vm_address_t addr)
+{
+ kern_return_t kret;
+ vm_region_submap_info_data_64_t info;
+ mach_vm_address_t start;
+ mach_vm_size_t size;
+ natural_t depth;
+ mach_msg_type_number_t count;
+
+ count = VM_REGION_SUBMAP_INFO_COUNT_64;
+ start = addr;
+ size = -1;
+ depth = 9999;
+ kret = mach_vm_region_recurse (mach_task_self (), &start, &size, &depth,
+ (vm_region_recurse_info_t) &info, &count);
+ if (kret == KERN_SUCCESS
+ && addr >= start && addr < (start + size)
+ && info.protection == VM_PROT_NONE
+ && info.user_tag == VM_MEMORY_STACK)
+ return 1;
+ return 0;
+}
+