Delete all Trailing spaces in code.
[reactos.git] / reactos / dll / 3rdparty / mesa32 / src / main / mm.h
1 /*
2 * GLX Hardware Device Driver common code
3 * Copyright (C) 1999 Keith Whitwell
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24
25 /**
26 * Memory manager code. Primarily used by device drivers to manage texture
27 * heaps, etc.
28 */
29
30
31 #ifndef MM_H
32 #define MM_H
33
34
35 #include "imports.h"
36
37
38 struct mem_block_t {
39 struct mem_block_t *next;
40 struct mem_block_t *heap;
41 int ofs,size;
42 int align;
43 unsigned int free:1;
44 unsigned int reserved:1;
45 };
46
47 typedef struct mem_block_t TMemBlock;
48
49 typedef struct mem_block_t *PMemBlock;
50
51 /* a heap is just the first block in a chain */
52 typedef struct mem_block_t memHeap_t;
53
54
55 /* XXX are these needed? */
56 #if 0
57 static INLINE int
58 mmBlockSize(PMemBlock b)
59 {
60 return b->size;
61 }
62
63 static INLINE int
64 mmOffset(PMemBlock b)
65 {
66 return b->ofs;
67 }
68 #endif
69
70
71
72 /**
73 * input: total size in bytes
74 * return: a heap pointer if OK, NULL if error
75 */
76 extern memHeap_t *mmInit(int ofs, int size);
77
78 /**
79 * Allocate 'size' bytes with 2^align2 bytes alignment,
80 * restrict the search to free memory after 'startSearch'
81 * depth and back buffers should be in different 4mb banks
82 * to get better page hits if possible
83 * input: size = size of block
84 * align2 = 2^align2 bytes alignment
85 * startSearch = linear offset from start of heap to begin search
86 * return: pointer to the allocated block, 0 if error
87 */
88 extern PMemBlock mmAllocMem(memHeap_t *heap, int size, int align2,
89 int startSearch);
90
91 /**
92 * Free block starts at offset
93 * input: pointer to a block
94 * return: 0 if OK, -1 if error
95 */
96 extern int mmFreeMem(PMemBlock b);
97
98 /**
99 * Free block starts at offset
100 * input: pointer to a heap, start offset
101 * return: pointer to a block
102 */
103 extern PMemBlock mmFindBlock(memHeap_t *heap, int start);
104
105 /**
106 * destroy MM
107 */
108 extern void mmDestroy(memHeap_t *mmInit);
109
110 /**
111 * For debuging purpose.
112 */
113 extern void mmDumpMemInfo(const memHeap_t *mmInit);
114
115 #endif