Revision 1.19 by

Revision 1.20 by

… | … | ||
---|---|---|---|

55 | is usually implemented as a macro. Specifically, a "bool" in this manual | 55 | is usually implemented as a macro. Specifically, a "bool" in this manual |

56 | refers to any kind of boolean value, not a specific type. | 56 | refers to any kind of boolean value, not a specific type. |

57 | 57 | ||

58 | =head2 GCC ATTRIBUTES | 58 | =head2 GCC ATTRIBUTES |

59 | 59 | ||

60 | blabla where to put, what others | 60 | A major part of libecb deals with GCC attributes. These are additional |

61 | attributes that you cna assign to functions, variables and sometimes even | ||

62 | types - much like C<const> or C<volatile> in C. | ||

63 | |||

64 | While GCC allows declarations to show up in many surprising places, | ||

65 | but not in many expeted places, the safest way is to put attribute | ||

66 | declarations before the whole declaration: | ||

67 | |||

68 | ecb_const int mysqrt (int a); | ||

69 | ecb_unused int i; | ||

70 | |||

71 | For variables, it is often nicer to put the attribute after the name, and | ||

72 | avoid 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 | ||

… | … | ||

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 | ||

406 | These two functions return the value of C<x> after shifting all the bits | 420 | These two functions return the value of C<x> after shifting all the bits |

407 | by C<count> positions to the right or left respectively. | 421 | by C<count> positions to the right or left respectively. |

408 | 422 | ||

423 | Current GCC versions understand these functions and usually compile them | ||

424 | to "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 | ||

417 | Returns the positive remainder of the modulo operation between C<m> and | 434 | Returns the positive remainder of the modulo operation between C<m> and |

418 | C<n>. Unlike the C modulo operator C<%>, this function ensures that the | 435 | C<n>. Unlike the C modulo operator C<%>, this function ensures that the |

419 | return value is always positive). | 436 | return value is always positive - ISO C guarantees very little when |

437 | negative numbers are used with C<%>. | ||

420 | 438 | ||

421 | C<n> must be strictly positive (i.e. C<< >1 >>), while C<m> must be | 439 | C<n> must be strictly positive (i.e. C<< >1 >>), while C<m> must be |

422 | negatable, that is, both C<m> and C<-m> must be representable in its | 440 | negatable, that is, both C<m> and C<-m> must be representable in its |

423 | type. | 441 | type. |

424 | 442 |

– |
Removed lines |

+ |
Added lines |

< |
Changed lines |

> |
Changed lines |