1
0

makros.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. makros.cpp - Ein paar nützliche Makros - Version 0.2
  3. Copyright (c) 2012 Wilfried Klaas. All right reserved.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. #ifndef swap
  17. #define swap(x,y,T) { T TMP_SWAP = x; x = y; y = TMP_SWAP; }
  18. #endif
  19. #ifndef between
  20. #define between(a,x,y) ((a >=x) && (a <= y))
  21. #endif
  22. #ifndef cbi
  23. #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
  24. #endif
  25. #ifndef sbi
  26. #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
  27. #endif
  28. #ifndef ELEMENTS
  29. #define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
  30. #endif
  31. #ifndef FILLARRAY
  32. #define FILLARRAY(a,n) a[0]=n, memcpy( ((char*)a)+sizeof(a[0]), a, sizeof(a)-sizeof(a[0]) );
  33. #endif