New examples/documentation for console configuration options.
[wine] / include / shm_fragment.h
1 /***************************************************************************
2  * Copyright 1995, Technion, Israel Institute of Technology
3  * Electrical Eng, Software Lab.
4  * Author:    Michael Veksler.
5  ***************************************************************************
6  * File:      shm_fragment.h
7  * Purpose:   Data fragments and free list items. Allocate and free blocks.
8  ***************************************************************************
9  */
10 #ifndef __WINE_SHM_FRAGMENT_H
11 #define __WINE_SHM_FRAGMENT_H
12
13 #ifdef CONFIG_IPC
14
15 #include "shm_block.h"
16
17 #define NIL ((int) 0)
18 /* memory fragment: used or free (when free - it's an item of "free list",
19  * when allocated it contains the data, and it's size) 
20  */
21 struct shm_fragment {
22         int size;               /* fragment's size */
23         
24         /* The type of info depends on fragment's status (free/allocated) */
25         union info {            
26                 int next;       /* next free fragment */
27                 char data[1];   /* the data */
28         } info;
29 };
30
31 /* setup first item in the free list */
32 void shm_FragmentInit(struct shm_block *block,REL_PTR first,int size);
33
34 /* allocate shm fragment. return: offset to data in fragment, or NULL */
35 REL_PTR shm_FragmentAlloc(struct shm_block *block, int size);
36
37 /* like shm_FragmentAlloc, returns pointer instead of offset */
38 char *shm_FragPtrAlloc(struct shm_block *block, int size);
39
40 /* free shm fragment - according to offset */
41 void shm_FragmentFree(struct shm_block *block, int ofs);
42
43 /* free shm fragment - according to pointer */
44 void shm_FragPtrFree(struct shm_block *block, void *ptr);
45
46 /* This is used for debugging only */
47 void shm_print_free_list(struct shm_block *block);
48
49 #endif  /* CONFIG_IPC */
50
51 #endif /* __WINE_SHM_FRAGMENT_H */