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.23 by sf-exg, Fri May 27 01:35:46 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 rotating all the bits
407by C<count> positions to the right or left respectively. 421by C<count> positions to the right or left respectively.
422
423Current GCC versions understand these functions and usually compile them
424to "optimal" code (e.g. a single C<roll> on x86).
408 425
409=back 426=back
410 427
411=head2 ARITHMETIC 428=head2 ARITHMETIC
412 429
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
425=back 443=back
426 444
427=head2 UTILITY 445=head2 UTILITY
428 446
429=over 4 447=over 4
430 448
431=item element_count = ecb_array_length (name) [MACRO] 449=item element_count = ecb_array_length (name)
432 450
433Returns the number of elements in the array C<name>. For example: 451Returns the number of elements in the array C<name>. For example:
434 452
435 int primes[] = { 2, 3, 5, 7, 11 }; 453 int primes[] = { 2, 3, 5, 7, 11 };
436 int sum = 0; 454 int sum = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines