1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/* Exported API for standalone library */
24#if !(defined(KLD) && defined(__STATIC__))
25#import <mach/mach.h>
26#else /* defined(KLD) && defined(__STATIC__) */
27#include <mach/kern_return.h>
28#endif /* !(defined(KLD) && defined(__STATIC__)) */
29#import <mach-o/loader.h>
30#import <stdarg.h>
31#import <stddef.h>
32
33#ifndef bcopy
34#ifdef __OPENSTEP__
35extern char *bcopy(char *src, char *dst, int n);
36#endif
37#endif
38
39extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
40#ifndef bzero
41#ifdef __OPENSTEP__
42extern int bzero(char *b, int length);
43#endif
44#endif
45extern void *memset(void *s, int c, size_t n);
46
47/*
48 * These are defined internally by GCC
49 *
50 * extern char *memcpy(void *dst, const void *src, int len);
51 * extern size_t strlen(const char *s);
52 */
53
54extern int errno;
55extern struct segment_command *
56  getsegbynamefromheader(struct mach_header *mhp, char *segname);
57extern int ptol(char *str);
58
59/* setjmp/longjmp:
60 * #include <setjmp.h>
61 *
62 * extern int setjmp(jmp_buf env);
63 * extern void longjmp( jmp_buf env, int val);
64 */
65
66extern int slvprintf(char *buffer, int len, const char *fmt, va_list arg);
67extern int sprintf(char *s, const char *format, ...);
68
69extern char *strcat(char *s1, const char *s2);
70extern int strcmp(const char *s1, const char *s2);
71extern char *strcpy(char *s1, const char *s2);
72char *strerror(int errnum);
73extern int strncmp(const char *s1, const char *s2, size_t n);
74extern char *strncpy(char *s1, const char *s2, size_t n);
75extern long strtol(
76    const char *nptr,
77    char **endptr,
78    register int base
79);
80extern unsigned long strtoul(
81    const char *nptr,
82    char **endptr,
83    register int base
84);
85
86#if !(defined(KLD) && defined(__STATIC__))
87/* Mach */
88#ifdef __MACH30__
89extern mach_port_t task_self_;
90#else
91extern port_t task_self_;
92#endif
93extern kern_return_t vm_allocate(
94    mach_port_t target_task,
95    vm_address_t *address,
96    vm_size_t size,
97    boolean_t anywhere
98);
99extern kern_return_t vm_deallocate(
100    mach_port_t target_task,
101    vm_address_t address,
102    vm_size_t size
103);
104extern kern_return_t host_info(
105    mach_port_t host,
106    int flavor,
107    host_info_t host_info,
108    unsigned int *host_info_count
109);
110extern vm_size_t vm_page_size;
111extern mach_port_t host_self(void);
112extern int getpagesize(void);
113extern char *mach_error_string(int errnum);
114
115/* Malloc/Zalloc */
116extern int malloc_init(char *start, int size, int nodes);
117extern char * zalloc(int size);
118extern int zfree(char *start);
119extern int zinit(char *start, int size, int nodes);
120#define ZALLOC_NODES	64	/* default number of nodes */
121#endif /* !(defined(KLD) && defined(__STATIC__)) */
122extern void *malloc(size_t size);
123extern void free(void *start);
124extern void *realloc(void *ptr, size_t size);
125