- host = host_self_trap();
-
-
- if (!forkchild) {
- /*
- * Set up the post-fork child handler in the libc stub
- * to invoke this routine if this process forks. Save the
- * previous value in order that we can call that handler
- * prior to performing our postfork work.
- */
-
- first = FALSE;
- previous_atfork_child_routine = _atfork_child_routine;
- _atfork_child_routine = mach_atfork_child_routine;
- _pthread_set_self(0);
- cthread_set_self(0);
- }
-
- /*
- * Initialize the single mig reply port
- */
-
- mig_init(0);
-
- /*
- * Cache some other valuable system constants
- */
-
- (void)host_page_size(host, &vm_page_size);
- vm_page_mask = vm_page_size - 1;
- if (vm_page_size == 0) {
- /* guard against unlikely craziness */
- vm_page_shift = 0;
- } else {
- /*
- * Unfortunately there's no kernel interface to get the
- * vm_page_shift, but it's easy enough to calculate.
- */
- for (vm_page_shift = 0;
- (vm_page_size & (1 << vm_page_shift)) == 0;
- vm_page_shift++)
- continue;
- }
-
- mach_port_deallocate(mach_task_self_, host);
-
- mach_init_ports();
-
-#if WE_REALLY_NEED_THIS_GDB_HACK
- /*
- * Check to see if GDB wants us to stop
- */
- {
- task_user_data_data_t user_data;
- mach_msg_type_number_t user_data_count = TASK_USER_DATA_COUNT;
-
- user_data.user_data = 0;
- (void)task_info(mach_task_self_, TASK_USER_DATA,
- (task_info_t)&user_data, &user_data_count);
-#define MACH_GDB_RUN_MAGIC_NUMBER 1
-#ifdef MACH_GDB_RUN_MAGIC_NUMBER
- /* This magic number is set in mach-aware gdb
- * for RUN command to allow us to suspend user's
- * executable (linked with this libmach!)
- * with the code below.
- * This hack should disappear when gdb improves.
- */
- if ((int)user_data.user_data == MACH_GDB_RUN_MAGIC_NUMBER) {
- kern_return_t ret;
- user_data.user_data = 0;
-
- ret = task_suspend (mach_task_self_);
- if (ret != KERN_SUCCESS) {
- while(1) (void)task_terminate(mach_task_self_);
- }
+ _task_reply_port = mach_reply_port();
+
+ if (vm_kernel_page_shift == 0) {
+#ifdef _COMM_PAGE_KERNEL_PAGE_SHIFT
+ vm_kernel_page_shift = *(uint8_t*) _COMM_PAGE_KERNEL_PAGE_SHIFT;
+ vm_kernel_page_size = 1 << vm_kernel_page_shift;
+ vm_kernel_page_mask = vm_kernel_page_size - 1;
+#else
+ vm_kernel_page_size = PAGE_SIZE;
+ vm_kernel_page_mask = PAGE_MASK;
+ vm_kernel_page_shift = PAGE_SHIFT;
+#endif /* _COMM_PAGE_KERNEL_PAGE_SHIFT */