6 * Mach Operating System
7 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
10 * Permission to use, copy, modify and distribute this software and its
11 * documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20 * Carnegie Mellon requests users of this software to return to
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
31 #include <mach/mach.h>
34 mach_port_t bootstrap_port
= MACH_PORT_NULL
;
35 mach_port_t name_server_port
= MACH_PORT_NULL
;
36 mach_port_t environment_port
= MACH_PORT_NULL
;
37 mach_port_t service_port
= MACH_PORT_NULL
;
38 mach_port_t clock_port
= MACH_PORT_NULL
;
39 mach_port_t thread_recycle_port
= MACH_PORT_NULL
;
44 mach_port_array_t ports
;
45 mach_msg_type_number_t ports_count
;
49 * Find those ports important to every task.
51 kr
= task_get_special_port(mach_task_self(),
54 if (kr
!= KERN_SUCCESS
)
57 kr
= mach_ports_lookup(mach_task_self(), &ports
,
59 if ((kr
!= KERN_SUCCESS
) ||
60 (ports_count
< MACH_PORTS_SLOTS_USED
))
63 name_server_port
= ports
[NAME_SERVER_SLOT
];
64 environment_port
= ports
[ENVIRONMENT_SLOT
];
65 service_port
= ports
[SERVICE_SLOT
];
67 /* get rid of out-of-line data so brk has a chance of working */
69 (void) vm_deallocate(mach_task_self(),
71 (vm_size_t
) (ports_count
* sizeof *ports
));
73 /* Get the clock service port for nanosleep */
74 kr
= host_get_clock_service(mach_host_self(), SYSTEM_CLOCK
, &clock_port
);
75 if (kr
!= KERN_SUCCESS
) {
78 kr
= mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE
, &thread_recycle_port
);
79 if (kr
!= KERN_SUCCESS
) {
82 kr
= mach_port_insert_right(mach_task_self(), thread_recycle_port
, thread_recycle_port
, MACH_MSG_TYPE_MAKE_SEND
);
83 if (kr
!= KERN_SUCCESS
) {
89 /* will have problems with dylib build --> not needed anyway */
92 * Routines which our library must suck in, to avoid
93 * a later library from referencing them and getting
96 extern void _replacements(void);
101 (void)sbrk(0); /* Pull in our sbrk/brk */
102 (void)malloc(0); /* Pull in our malloc package */