You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7KB

  1. // Copyright 2009 Olivier Gillet.
  2. //
  3. // Author: Olivier Gillet (ol.gillet@gmail.com)
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. //
  16. // -----------------------------------------------------------------------------
  17. //
  18. // Base header.
  19. #ifndef AVRLIB_BASE_H_
  20. #define AVRLIB_BASE_H_
  21. #include <inttypes.h>
  22. #ifndef NULL
  23. #define NULL 0
  24. #endif
  25. typedef union {
  26. uint16_t value;
  27. uint8_t bytes[2];
  28. } Word;
  29. typedef union {
  30. uint32_t value;
  31. uint16_t words[2];
  32. uint8_t bytes[4];
  33. } LongWord;
  34. struct uint24_t {
  35. uint16_t integral;
  36. uint8_t fractional;
  37. };
  38. struct uint24c_t {
  39. uint8_t carry;
  40. uint16_t integral;
  41. uint8_t fractional;
  42. };
  43. template<uint32_t a, uint32_t b, uint32_t c, uint32_t d>
  44. struct FourCC {
  45. static const uint32_t value = (((((d << 8) | c) << 8) | b) << 8) | a;
  46. };
  47. #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
  48. TypeName(const TypeName&); \
  49. void operator=(const TypeName&)
  50. template<bool b>
  51. inline void StaticAssertImplementation() {
  52. char static_assert_size_mismatch[b] = { 0 };
  53. }
  54. #define STATIC_ASSERT(expression) StaticAssertImplementation<(expression)>()
  55. #endif // AVRLIB_BASE_H_