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

Comparing libecb/ecb.pod (file contents):
Revision 1.19 by sf-exg, Fri May 27 00:04:05 2011 UTC vs.
Revision 1.21 by root, Fri May 27 00:14:10 2011 UTC

55is usually implemented as a macro. Specifically, a "bool" in this manual 55is usually implemented as a macro. Specifically, a "bool" in this manual
56refers to any kind of boolean value, not a specific type. 56refers to any kind of boolean value, not a specific type.
57 57
58=head2 GCC ATTRIBUTES 58=head2 GCC ATTRIBUTES
59 59
60blabla where to put, what others 60A major part of libecb deals with GCC attributes. These are additional
61attributes that you cna assign to functions, variables and sometimes even
62types - much like C<const> or C<volatile> in C.
63
64While GCC allows declarations to show up in many surprising places,
65but not in many expeted places, the safest way is to put attribute
66declarations before the whole declaration:
67
68 ecb_const int mysqrt (int a);
69 ecb_unused int i;
70
71For variables, it is often nicer to put the attribute after the name, and
72avoid multiple declarations using commas:
73
74 int i ecb_unused;
61 75
62=over 4 76=over 4
63 77
64=item ecb_attribute ((attrs...)) 78=item ecb_attribute ((attrs...))
65 79
394 408
395=item uint32_t ecb_bswap16 (uint32_t x) 409=item uint32_t ecb_bswap16 (uint32_t x)
396 410
397=item uint32_t ecb_bswap32 (uint32_t x) 411=item uint32_t ecb_bswap32 (uint32_t x)
398 412
399These two functions return the value of the 16-bit (32-bit) variable 413These two functions return the value of the 16-bit (32-bit) value C<x>
400C<x> after reversing the order of bytes. 414after reversing the order of bytes (0x11223344 becomes 0x44332211).
401 415
402=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) 416=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count)
403 417
404=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) 418=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count)
405 419
406These two functions return the value of C<x> after shifting all the bits 420These two functions return the value of C<x> after shifting all the bits
407by C<count> positions to the right or left respectively. 421by C<count> positions to the right or left respectively.
408 422
423Current GCC versions understand these functions and usually compile them
424to "optimal" code (e.g. a single C<roll> on x86).
425
409=back 426=back
410 427
411=head2 ARITHMETIC 428=head2 ARITHMETIC
412 429
413=over 4 430=over 4
414 431
415=item x = ecb_mod (m, n) 432=item x = ecb_mod (m, n)
416 433
417Returns the positive remainder of the modulo operation between C<m> and 434Returns the positive remainder of the modulo operation between C<m> and
418C<n>. Unlike the C modulo operator C<%>, this function ensures that the 435C<n>. Unlike the C modulo operator C<%>, this function ensures that the
419return value is always positive). 436return value is always positive - ISO C guarantees very little when
437negative numbers are used with C<%>.
420 438
421C<n> must be strictly positive (i.e. C<< >1 >>), while C<m> must be 439C<n> must be strictly positive (i.e. C<< >1 >>), while C<m> must be
422negatable, that is, both C<m> and C<-m> must be representable in its 440negatable, that is, both C<m> and C<-m> must be representable in its
423type. 441type.
424 442

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines