Chameleon

Chameleon Svn Source Tree

Root/branches/valv/i386/libsa/libsa.h

1/*
2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 2.0 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef __BOOT_LIBSA_H
26#define __BOOT_LIBSA_H
27
28/* Exported API for standalone library */
29
30#include <mach-o/loader.h>
31#include <stdarg.h>
32#include <stddef.h>
33#include <stdbool.h>
34
35/*
36 * cpu.c
37 */
38/*#define rdmsr46(msr, val1, val2)\
39do {\
40uint64_t val = rdmsr64((msr));\
41(val1) = (uint32_t)val;\
42(val2) = (uint32_t)(val >> 32);\
43} while (0)*/
44
45/*
46 * ctype stuff (aserebln)
47 */
48static inline int isupper(char c)
49{
50 return (c >= 'A' && c <= 'Z');
51}
52
53static inline int islower(char c)
54{
55 return (c >= 'a' && c <= 'z');
56}
57
58static inline int isalpha(char c)
59{
60 return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
61}
62
63static inline int isascii(char c)
64{
65 return ( (c >= 0x20) && (c < 0x7f) );
66}
67
68static inline int isspace(char c)
69{
70 return (c == ' ' || c == '\t' || c == '\n' || c == '\12');
71}
72
73static inline int isdigit(char c)
74{
75 return (c >= '0' && c <= '9');
76}
77
78static inline int isxdigit(char c)
79{
80 return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
81}
82
83
84/*
85 * string.c
86 */
87#ifndef bcopy
88extern void bcopy(const void * src, void * dst, size_t len);
89#endif
90
91#ifndef bzero
92extern void bzero(void * dst, size_t len);
93#endif
94
95extern void * memset(void * dst, int c, size_t n);
96extern void * memcpy(void * dst, const void * src, size_t len);
97extern int memcmp(const void * p1, const void * p2, int len);
98extern int strcmp(const char * s1, const char * s2);
99extern int strncmp(const char * s1, const char * s2, size_t n);
100extern char * strcpy(char * s1, const char * s2);
101extern char * strncpy(char * s1, const char * s2, size_t n);
102extern char * strlcpy(char * s1, const char * s2, size_t n);
103extern char * strstr(const char *in, const char *str);
104extern int atoi(const char * str);
105extern int ptol(const char * str);
106extern int strlen(const char * str);
107extern char * strcat(char * s1, const char * s2);
108extern char * strncat(char * s1, const char * s2, size_t n);
109extern char * strdup(const char *s1);
110
111#if STRNCASECMP
112extern int strncasecmp(const char * s1, const char * s2, size_t n);
113#endif
114
115extern uint8_t checksum8( void * start, unsigned int length );
116
117/*
118 * error.c
119 */
120extern int errno;
121extern char * strerror(int errnum);
122
123/*
124 * strtol.c
125 */
126extern long strtol(const char * nptr, char ** endptr, int base);
127extern unsigned long strtoul(const char * nptr, char ** endptr, int base);
128extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);
129
130/*
131 * strtod.c
132 */
133extern double strtod(const char *string, char ** endPtr);
134
135/*
136 * prf.c
137 */
138extern void prf(const char * fmt, va_list ap, void (*putfn_p)(),
139 void * putfn_arg);
140
141/*
142 * printf.c
143 */
144extern int sprintf(char *s, const char * format, ...);
145extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
146
147/*
148 * zalloc.c
149 */
150#define malloc(size)safe_malloc(size, __FILE__, __LINE__)
151extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
152extern void * safe_malloc(size_t size,const char *file, int line);
153extern void free(void * start);
154extern void * realloc(void * ptr, size_t size);
155
156/*
157 * getsegbyname.c
158 */
159extern struct segment_command *
160 getsegbynamefromheader(struct mach_header * mhp, char * segname);
161
162#endif /* !__BOOT_LIBSA_H */
163

Archive Download this file

Revision: 177