Added bitmaps.
[cascardo/kernel/slides/.git] / 03types / types
1 %Data Types
2 %Thadeu Cascardo
3
4 # Macros
5
6 * include/linux/kernel.h
7 * ARRAY\\_SIZE
8 * FIELD\\_SIZEOF
9 * ALIGN
10 * PTR\\_ALIGN
11 * IS\\_ALIGNED
12
13 # More macros
14
15 * container\\_of
16 * offsetof
17
18 # krefs
19
20 Reference:
21
22 * Documentation/kref.txt
23
24 # API
25
26 * struct kref
27 * kref\\_init - struct kref pointer
28 * kref\\_get - struct kref pointer
29 * kref\\_put - struct kref pointer and release function
30
31 # Usage
32
33 * Embed struct kref into your own structure
34 * Do not forget to call kref\\_init when initializing your structure
35 * Pass a release function as parameter to kref\\_put, where you release your
36   structure
37 * Follow the rules for calling kref\\_get and kref\\_put
38
39 # Rules
40
41 * Must increment count if passing a non-temporary copy
42 * May increment count without a lock if already has a valid pointer
43 * Must decrement when done with the pointer
44 * If code never tries to get a ref without a valid pointer, may be done without
45   a lock
46 * Must serialize getting a ref without a valid pointer with putting a ref
47
48 # Basic Types
49
50 * include linux/types.h
51 * sXX, where XX is 8, 16, 32 or 64
52 * uXX
53
54 # Endianness
55
56 # Little endian and Big endian
57
58 * FIXME
59 * Little endian machines
60         - x86
61 * Big endian machines
62         - SPARC
63         - MIPS
64 * Multi-endian machines
65         - ARM
66
67 # Headers
68
69 * include asm/byteorder.h
70 * include/linux/byteorder/generic.h
71
72 # Macros
73
74 * cpu\\_to\\_beXX
75 * cpu\\_to\\_leXX
76 * beXX\\_to\\_cpu
77 * leXX\\_to\\_cpu
78 * All those with suffix p - use a pointer
79 * All those with suffix s - change in situ
80
81 # Lists
82
83 # Declaration
84
85 * include linux/list.h
86 * LIST\\_HEAD(head);
87 * Embed a struct list\\_head in your structure
88 * Use a struct list\\_head pointer to iterate
89
90 # Initialization
91
92 * INIT\\_LIST\\_HEAD - receives a pointer to the embedded list head
93
94 # Operations
95
96 * list\\_add - receives a pointer to the element and a head
97 * list\\_add\\_tail
98 * list\\_del - receives only the pointer to the element
99 * list\\_empty
100
101 # Access
102
103 * list\\_entry(entry, type, member); -- uses container\\_of
104 * list\\_first\\_entry(head, type, member);
105
106 # Iteration macros
107
108 * list\\_for\\_each(lhptr, head);
109 * list\\_for\\_each\\_entry(iptr, head, member)
110 * list\\_for\\_each\\_safe(lhptr, head);
111
112 # Bitmaps
113
114 # Declaration
115
116 * include linux/types.h
117 * include linux/bitops.h
118 * DECLARE\\_BITMAP
119
120 # API
121
122 * All atomic, prefix \\_ to use non-atomic
123 * set\\_bit
124 * clear\\_bit
125 * change\\_bit
126 * test\\_and\\_set\\_bit
127 * test\\_and\\_clear\\_bit
128 * test\\_and\\_change\\_bit
129
130 # Lookup
131
132 * find\\_first\\_bit
133 * find\\_first\\_zero\\_bit
134 * find\\_last\\_bit
135 * find\\_next\\_bit
136 * find\\_next\\_zero\\_bit
137 * for\\_each\\_set\\_bit
138
139 # Trees and hashes
140
141 # Other data types