ia64/xen-unstable

view extras/mini-os/h/lib.h @ 4072:ee7313088070

bitkeeper revision 1.1159.258.38 (4230628bX3yukmWYtNDh925BckMoHQ)

Merge ssh://xenbk@gandalf.hpl.hp.com//var/bk/xen-2.0-testing.bk
into tetris.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
author iap10@tetris.cl.cam.ac.uk
date Thu Mar 10 15:06:51 2005 +0000 (2005-03-10)
parents aadd0dc51c45
children 7561a06348cf
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
4 ****************************************************************************
5 *
6 * File: lib.h
7 * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
8 * Changes:
9 *
10 * Date: Aug 2003
11 *
12 * Environment: Xen Minimal OS
13 * Description: Random useful library functions, contains some freebsd stuff
14 *
15 ****************************************************************************
16 * $Id: h-insert.h,v 1.4 2002/11/08 16:03:55 rn Exp $
17 ****************************************************************************
18 *
19 *-
20 * Copyright (c) 1991, 1993
21 * The Regents of the University of California. All rights reserved.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * This product includes software developed by the University of
34 * California, Berkeley and its contributors.
35 * 4. Neither the name of the University nor the names of its contributors
36 * may be used to endorse or promote products derived from this software
37 * without specific prior written permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
40 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 * SUCH DAMAGE.
50 *
51 * @(#)stdarg.h 8.1 (Berkeley) 6/10/93
52 * $FreeBSD: src/sys/i386/include/stdarg.h,v 1.10 1999/08/28 00:44:26 peter Exp $
53 */
55 #ifndef _LIB_H_
56 #define _LIB_H_
59 /* variadic function support */
60 typedef char *va_list;
61 #define __va_size(type) \
62 (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
63 #ifdef __GNUC__
64 #define va_start(ap, last) \
65 ((ap) = (va_list)__builtin_next_arg(last))
66 #else
67 #define va_start(ap, last) \
68 ((ap) = (va_list)&(last) + __va_size(last))
69 #endif
70 #define va_arg(ap, type) \
71 (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
72 #define va_end(ap)
75 /* printing */
76 #define printk printf
77 #define kprintf printf
78 int printf(const char *fmt, ...);
79 int vprintf(const char *fmt, va_list ap);
80 int sprintf(char *buf, const char *cfmt, ...);
81 int vsprintf(char *buf, const char *cfmt, va_list ap);
83 /* string and memory manipulation */
84 int memcmp(const void *cs, const void *ct, size_t count);
85 void *memcpy(void *dest, const void *src, size_t count);
86 int strncmp(const char *cs, const char *ct, size_t count);
87 int strcmp(const char *cs, const char *ct);
88 char *strcpy(char *dest, const char *src);
89 char *strncpy(char *dest, const char *src, size_t count);
90 void *memset(void *s,int c, size_t count);
91 size_t strnlen(const char *s, size_t count);
92 size_t strlen(const char *s);
93 char *strchr(const char *s, int c);
94 char *strstr(const char *s1, const char *s2);
97 /* dlmalloc functions */
98 struct mallinfo {
99 int arena; /* non-mmapped space allocated from system */
100 int ordblks; /* number of free chunks */
101 int smblks; /* number of fastbin blocks */
102 int hblks; /* number of mmapped regions */
103 int hblkhd; /* space in mmapped regions */
104 int usmblks; /* maximum total allocated space */
105 int fsmblks; /* space available in freed fastbin blocks */
106 int uordblks; /* total allocated space */
107 int fordblks; /* total free space */
108 int keepcost; /* top-most, releasable (via malloc_trim) space */
109 };
111 void *malloc(size_t n);
112 void *calloc(size_t n_elements, size_t element_size);
113 void free(void* p);
114 void *realloc(void* p, size_t n);
115 void *memalign(size_t alignment, size_t n);
116 void *valloc(size_t n);
117 struct mallinfo mallinfo(void);
118 int mallopt(int parameter_number, int parameter_value);
120 void **independent_calloc(size_t n_elements, size_t size, void* chunks[]);
121 void **independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);
122 void *pvalloc(size_t n);
123 void cfree(void* p);
124 int malloc_trim(size_t pad);
125 size_t malloc_usable_size(void* p);
126 void malloc_stats(void);
129 #endif /* _LIB_H_ */