stdio.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*-------------------------------------------------------------------------
  2. stdio.h - ANSI functions forward declarations
  3. Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net
  4. Ported to PIC16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
  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 __STDIO_H
  25. #define __STDIO_H 1
  26. /* link the C library */
  27. #pragma library c
  28. #include <stdarg.h>
  29. #include <sdcc-lib.h>
  30. #ifndef NULL
  31. #define NULL (void *)0
  32. #endif
  33. #ifndef _SIZE_T_DEFINED
  34. #define _SIZE_T_DEFINED
  35. typedef unsigned int size_t;
  36. #endif
  37. /* stream descriptor definition */
  38. typedef char *FILE;
  39. /* USART and MSSP module stream descriptors */
  40. /* since FILE is declared as a generic pointer,
  41. * the upper byte is used to dereference the pointer
  42. * information. For the stream descriptors we
  43. * use the 5th bit and the lower nubble bits.
  44. * Descriptors are denoted by an 1 in bit 5,
  45. * further dereference is made for:
  46. * <stream> <3:0> bits
  47. * USART 0 (0x0)
  48. * MSSP 1 (0x1)
  49. * USER 15 (0xf)
  50. *
  51. * There is a special value for GPSIM specific (see below)
  52. * which is:
  53. * GPSIM 14 (0xe)
  54. *
  55. *
  56. * if further stream descriptors need to be added then more
  57. * bits of the upper byte can be used
  58. */
  59. #define USART_DEREF 0x0
  60. #define MSSP_DEREF 0x1
  61. #define USER_DEREF 0xf
  62. #define STREAM_USART ((FILE *)(0x00200000UL))
  63. #define STREAM_MSSP ((FILE *)(0x00210000UL))
  64. #define STREAM_USER ((FILE *)(0x002f0000UL))
  65. /* this is a custom dereference which points to a custom
  66. * port of GPSIM simulator. This port redirects characters
  67. * to /tmp/gpsim.debug.1 file (used for debugging purposes)
  68. * NOTICE: This feature is not part of the official gpsim
  69. * distribution. Contact vrokas AT users.sourceforge.net
  70. * for more info */
  71. #define GPSIM_DEREF 0xe
  72. #define STREAM_GPSIM ((FILE *)(0x002e0000UL))
  73. extern FILE *stdin;
  74. extern FILE *stdout;
  75. /* printf_small() supports float print */
  76. void printf_small (const char *fmt, ...);
  77. /* printf_tiny() does not support float print */
  78. void printf_tiny (const char *fmt, ...); // __reentrant;
  79. extern int printf (const char *fmt, ...);
  80. extern int fprintf (FILE *stream, const char *fmt, ...);
  81. extern int sprintf (char *str, const char *fmt, ...);
  82. extern int vprintf (const char *fmt, va_list ap);
  83. extern int vfprintf (FILE *stream, const char *fmt, va_list ap);
  84. extern int vsprintf (char *str, const char *fmt, va_list ap);
  85. #define PUTCHAR(C) void putchar (char C) __wparam
  86. extern PUTCHAR (c);
  87. extern void __stream_putchar (FILE *stream, char c);
  88. extern void __stream_usart_putchar (char c) __wparam __naked;
  89. extern void __stream_mssp_putchar (char c) __wparam __naked;
  90. extern void __stream_gpsim_putchar (char c) __wparam __naked;
  91. extern char *gets (char *str);
  92. extern char getchar (void);
  93. #endif /* __STDIO_H */