ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libecb/ecb.pod
(Generate patch)

Comparing cvsroot/libecb/ecb.pod (file contents):
Revision 1.2 by root, Thu May 26 19:49:21 2011 UTC vs.
Revision 1.3 by root, Thu May 26 20:04:38 2011 UTC

1=head1 LIBECB
2
3You suck, we don't(tm)
4
5=head2 ABOUT THE HEADER
6
7- how to include it
8- it includes inttypes.h
9- no .a
10- whats a bool
1 11
2=head2 GCC ATTRIBUTES 12=head2 GCC ATTRIBUTES
13
14blabla where to put, what others
3 15
4=over 4 16=over 4
5 17
6=item ecb_attribute ((attrs...)) 18=item ecb_attribute ((attrs...))
7 19
8A simple wrapper that expands to C<__attribute__((attrs))> on GCC, and 20A simple wrapper that expands to C<__attribute__((attrs))> on GCC, and
9to nothing on other compilers, so the effect is that only GCC sees these. 21to nothing on other compilers, so the effect is that only GCC sees these.
10 22
23=item ecb_unused
24
25Marks a function or a variable as "unused", which simply suppresses a
26warning by GCC when it detects it as unused. This is useful when you e.g.
27declare a variable but do not always use it:
28
29 {
30 int var ecb_unused;
31
32 #ifdef SOMECONDITION
33 var = ...;
34 return var;
35 #else
36 return 0;
37 #endif
38 }
39
11=item ecb_noinline 40=item ecb_noinline
12 41
42Prevent a function from being inlined - it might be optimsied away, but
43not inlined into other functions. This is useful if you know your function
44is rarely called and large enough for inlining not to be helpful.
45
13=item ecb_noreturn 46=item ecb_noreturn
14
15=item ecb_unused
16 47
17=item ecb_const 48=item ecb_const
18 49
19=item ecb_pure 50=item ecb_pure
20 51
30 61
31=over 4 62=over 4
32 63
33=item bool ecb_is_constant(expr) 64=item bool ecb_is_constant(expr)
34 65
66Returns true iff the expression can be deduced to be a compile-time
67constant, and false otherwise.
68
69For example, when you have a C<rndm16> function that returns a 16 bit
70random number, and you have a function that maps this to a range from
710..n-1, then you could use this inline fucntion in a header file:
72
73 ecb_inline uint32_t
74 rndm (uint32_t n)
75 {
76 return n * (uint32_t)rndm16 ()) >> 16;
77 }
78
79However, for powers of two, you could use a normal mask, but that is only
80worth it if, at compile time, you can detect this case. This is the case
81when the passed number is a constant and also a power of two (C<n & (n -
821) == 0>):
83
84 ecb_inline uint32_t
85 rndm (uint32_t n)
86 {
87 return is_constant (n) && !(n & (n - 1))
88 ? rndm16 () & (num - 1)
89 : (uint32_t)rndm16 ()) >> 16;
90 }
91
92
93
35=item bool ecb_expect(expr,value) 94=item bool ecb_expect(expr,value)
36 95
37=item bool ecb_unlikely(bool) 96=item bool ecb_unlikely(bool)
38 97
39=item bool ecb_likely(bool) 98=item bool ecb_likely(bool)
46 105
47=back 106=back
48 107
49=head2 BIT FIDDLING / BITSTUFFS 108=head2 BIT FIDDLING / BITSTUFFS
50 109
51bool ecb_big_endian (); 110=item bool ecb_big_endian ()
111
52bool ecb_little_endian (); 112=item bool ecb_little_endian ()
113
53int ecb_ctz32 (uint32_t x); 114=item int ecb_ctz32 (uint32_t x)
115
54int ecb_popcount32 (uint32_t x); 116=item int ecb_popcount32 (uint32_t x)
117
55uint32_t ecb_bswap32 (uint32_t x); 118=item uint32_t ecb_bswap32 (uint32_t x)
119
56uint32_t ecb_bswap16 (uint32_t x); 120=item uint32_t ecb_bswap16 (uint32_t x)
121
57uint32_t ecb_rotr32 (uint32_t x, unsigned int count); 122=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count)
123
58uint32_t ecb_rotl32 (uint32_t x, unsigned int count); 124=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count)
125
126=back
59 127
60=head2 ARITHMETIC 128=head2 ARITHMETIC
61 129
62x = ecb_mod (m, n) 130=over 4
131
132=item x = ecb_mod (m, n) [MACRO]
133
134=back
63 135
64=head2 UTILITY 136=head2 UTILITY
65 137
138=over 4
139
66ecb_array_length (name) 140=item ecb_array_length (name) [MACRO]
141
142=back
67 143
68 144

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines