stdarg.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*-------------------------------------------------------------------------
  2. stdarg.h - ANSI macros for variable parameter list
  3. Copyright (C) 2000, Michael Hope
  4. Copyright (C) 2011, Philipp Klaus Krause pkk@spth.de
  5. This library is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any
  8. later version.
  9. This library 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 library; see the file COPYING. If not, write to the
  15. Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  16. MA 02110-1301, USA.
  17. As a special exception, if you link this library with other files,
  18. some of which are compiled with SDCC, to produce an executable,
  19. this library does not by itself cause the resulting executable to
  20. be covered by the GNU General Public License. This exception does
  21. not however invalidate any other reasons why the executable file
  22. might be covered by the GNU General Public License.
  23. -------------------------------------------------------------------------*/
  24. #ifndef __SDC51_STDARG_H
  25. #define __SDC51_STDARG_H 1
  26. #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined(__SDCC_gbz80) || defined(__SDCC_hc08) || defined(__SDCC_s08)
  27. typedef unsigned char * va_list;
  28. #define va_start(marker, last) { marker = (va_list)&last + sizeof(last); }
  29. #define va_arg(marker, type) *((type *)((marker += sizeof(type)) - sizeof(type)))
  30. #elif defined(__SDCC_ds390) || defined(__SDCC_ds400)
  31. typedef unsigned char * va_list;
  32. #define va_start(marker, first) { marker = (va_list)&first; }
  33. #define va_arg(marker, type) *((type *)(marker -= sizeof(type)))
  34. #elif defined(__SDCC_USE_XSTACK)
  35. typedef unsigned char __pdata * va_list;
  36. #define va_start(marker, first) { marker = (va_list)&first; }
  37. #define va_arg(marker, type) *((type __pdata *)(marker -= sizeof(type)))
  38. #else
  39. typedef unsigned char __data * va_list;
  40. #define va_start(marker, first) { marker = (va_list)&first; }
  41. #define va_arg(marker, type) *((type __data * )(marker -= sizeof(type)))
  42. #endif
  43. #define va_copy(dest, src) { dest = src; }
  44. #define va_end(marker) { marker = (va_list) 0; };
  45. #endif