* device/include/pic16/stdio.h, device/lib/pic16/libc/stdio/streams.c,
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 15 Sep 2008 18:33:02 +0000 (18:33 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 15 Sep 2008 18:33:02 +0000 (18:33 +0000)
  device/lib/pic16/libc/stdio/printf.c,
  device/lib/pic16/libc/stdio/strmusart.c,
  device/lib/pic16/libc/stdio/printf_tiny.c,
  device/lib/pic16/libc/stdio/sprintf.c,
  device/lib/pic16/libc/stdio/strmgpsim.c,
  device/lib/pic16/libc/stdio/putchar.c,
  device/lib/pic16/libc/stdio/fprintf.c,
  device/lib/pic16/libc/stdio/strmmssp.c,
  device/device/lib/pic16/libc/stdio/vprintf.c,
  device/lib/pic16/libc/stdio/printf_small.c,
  device/lib/pic16/libc/stdio/vsprintf.c,
  device/lib/pic16/libc/stdio/strmputchar.c,
  device/lib/pic16/libc/Makefile.am,
  device/lib/pic16/libc/Makefile.in:
  *printf now returns int, puchar.c moved from stdlib to stdio,
  *printf format parameter type changed from char * to const char *,
  added GNU link excetion text to library source files,
  applyed GNU coding style, removed useless svn ids,
  added BINARY_SPECIFIER macro re-enables the use of the removed 'b'
  binary specifier: "%b", "%hb" and "%lb"
* device/lib/pic16/libc/stdio/vfprintf.c:
  applied patch #2044424: PIC16: vfprintf
  thanks Mauro Giachero

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5239 4a8a32a2-be11-0410-ad9d-d568d2c75423

19 files changed:
ChangeLog
device/include/pic16/stdio.h
device/lib/pic16/libc/Makefile.am
device/lib/pic16/libc/Makefile.in
device/lib/pic16/libc/stdio/fprintf.c
device/lib/pic16/libc/stdio/printf.c
device/lib/pic16/libc/stdio/printf_small.c
device/lib/pic16/libc/stdio/printf_tiny.c
device/lib/pic16/libc/stdio/putchar.c [new file with mode: 0644]
device/lib/pic16/libc/stdio/sprintf.c
device/lib/pic16/libc/stdio/streams.c
device/lib/pic16/libc/stdio/strmgpsim.c
device/lib/pic16/libc/stdio/strmmssp.c
device/lib/pic16/libc/stdio/strmputchar.c
device/lib/pic16/libc/stdio/strmusart.c
device/lib/pic16/libc/stdio/vfprintf.c
device/lib/pic16/libc/stdio/vprintf.c
device/lib/pic16/libc/stdio/vsprintf.c
device/lib/pic16/libc/stdlib/putchar.c [deleted file]

index e3e936750e64a196a130065c5fb3af7e25a5f74e..1ca93c601c46273cb8248a610504cc20fccb518c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2008-09-15 Borut Razem <borut.razem AT siol.net>
+
+       * device/include/pic16/stdio.h, device/lib/pic16/libc/stdio/streams.c,
+         device/lib/pic16/libc/stdio/printf.c,
+         device/lib/pic16/libc/stdio/strmusart.c,
+         device/lib/pic16/libc/stdio/printf_tiny.c,
+         device/lib/pic16/libc/stdio/sprintf.c,
+         device/lib/pic16/libc/stdio/strmgpsim.c,
+         device/lib/pic16/libc/stdio/putchar.c,
+         device/lib/pic16/libc/stdio/fprintf.c,
+         device/lib/pic16/libc/stdio/strmmssp.c,
+         device/device/lib/pic16/libc/stdio/vprintf.c,
+         device/lib/pic16/libc/stdio/printf_small.c,
+         device/lib/pic16/libc/stdio/vsprintf.c,
+         device/lib/pic16/libc/stdio/strmputchar.c,
+         device/lib/pic16/libc/Makefile.am,
+         device/lib/pic16/libc/Makefile.in:
+         *printf now returns int, puchar.c moved from stdlib to stdio,
+         *printf format parameter type changed from char * to const char *,
+         added GNU link excetion text to library source files,
+         applyed GNU coding style, removed useless svn ids,
+         added BINARY_SPECIFIER macro re-enables the use of the removed 'b'
+         binary specifier: "%b", "%hb" and "%lb"
+       * device/lib/pic16/libc/stdio/vfprintf.c:
+         applied patch #2044424: PIC16: vfprintf
+         thanks Mauro Giachero
+
 2008-09-15 Raphael Neider <rneider AT web.de>
 
        * src/pic16/device.c (pic16_dump_usection): force udata sections
@@ -22,7 +49,7 @@
 2008-09-11 Borut Razem <borut.razem AT siol.net>
 
        * support/regression/tests/bug-221100.c, support/regression/shifts.c,
-          support/regression/absolute.c:
+         support/regression/absolute.c:
          applied patch #2105615: Some PIC16 testcase fixlets
          thanks Mauro Giachero
 
index f4b4e4f5d0f98c8d9a353aa3e02b70b92e685b5c..3c81810a028ed1075dd2b4e7ab1080fc2486ff6c 100644 (file)
@@ -2,7 +2,7 @@
   stdio.h - ANSI functions forward declarations
 
    Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-   
+
              Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1998)
 
    This program is free software; you can redistribute it and/or modify it
    In other words, you are welcome to use, share and improve this program.
    You are forbidden to forbid anyone else to use, share and improve
    what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #ifndef __STDIO_H
 #define __STDIO_H 1
   typedef unsigned int size_t;
 #endif
 
-
 /* stream descriptor definition */
 typedef char *FILE;
 
-
 /* USART and MSSP module stream descriptors */
 
 /* since FILE is declared as a generic pointer,
@@ -61,7 +62,7 @@ typedef char *FILE;
  * Descriptors are denoted by an 1 in bit 5,
  * further dereference is made for:
  * <stream>     <3:0> bits
- *     USART    0 (0x0)
+ *     USART     0 (0x0)
  *     MSSP      1 (0x1)
  *     USER     15 (0xf)
  *
@@ -74,15 +75,13 @@ typedef char *FILE;
  * bits of the upper byte can be used
  */
 
+#define USART_DEREF     0x0
+#define MSSP_DEREF      0x1
+#define USER_DEREF      0xf
 
-#define USART_DEREF    0x0
-#define MSSP_DEREF     0x1
-#define USER_DEREF     0xf
-
-#define STREAM_USART   ((FILE *)(0x00200000UL))
-#define STREAM_MSSP    ((FILE *)(0x00210000UL))
-#define STREAM_USER    ((FILE *)(0x002f0000UL))
-
+#define STREAM_USART    ((FILE *)(0x00200000UL))
+#define STREAM_MSSP     ((FILE *)(0x00210000UL))
+#define STREAM_USER     ((FILE *)(0x002f0000UL))
 
 /* this is a custom dereference which points to a custom
  * port of GPSIM simulator. This port redirects characters
@@ -90,41 +89,35 @@ typedef char *FILE;
  * NOTICE: This feature is not part of the official gpsim
  * distribution. Contact vrokas AT users.sourceforge.net
  * for more info */
-#define GPSIM_DEREF    0xe
-#define STREAM_GPSIM   ((FILE *)(0x002e0000UL))
+#define GPSIM_DEREF     0xe
+#define STREAM_GPSIM    ((FILE *)(0x002e0000UL))
 
 extern FILE * stdin;
 extern FILE * stdout;
 
-//typedef void (*pfn_outputchar)(char c, void* p) _REENTRANT;
-//extern int _print_format (pfn_outputchar pfn, void* pvoid, const char *format, va_list ap);
-
 /* printf_small() supports float print */
-void printf_small(char *, ...);
+void printf_small (const char *, ...);
 
 /* printf_tiny() does not support float print */
-void printf_tiny(char *, ...);  // __reentrant;
-
-extern unsigned int printf (char *,...);
-extern unsigned int sprintf (char *, char *, ...);
-extern unsigned int fprintf(FILE *, char *, ...);
+void printf_tiny (const char *, ...);  // __reentrant;
 
-extern unsigned int vsprintf (char *, char *, va_list);
-extern unsigned int vprintf (char *, va_list);
-extern unsigned int vfprintf(FILE *, char *, va_list);
+extern int printf (const char *,...);
+extern int fprintf (FILE *, const char *,...);
+extern int sprintf (char *, const char *, ...);
 
-extern int puts(char *);
+extern int vprintf (const char *, va_list);
+extern int vfprintf (FILE * stream, const char *fmt, va_list ap);
+extern int vsprintf (char *, const char *, va_list);
 
-extern void __stream_putchar(FILE *, unsigned char);
+extern void putchar (char) __wparam __naked;
 
-#define PUTCHAR(arg)   void putchar(unsigned char arg) __wparam
-extern PUTCHAR(c);
+extern void __stream_putchar (FILE *, char);
 
-extern void __stream_usart_putchar(unsigned char c) __wparam __naked;
-extern void __stream_mssp_putchar(unsigned char c) __wparam __naked;
-extern void __stream_gpsim_putchar(unsigned char c) __wparam __naked;
+extern void __stream_usart_putchar (char c) __wparam __naked;
+extern void __stream_mssp_putchar (char c) __wparam __naked;
+extern void __stream_gpsim_putchar (char c) __wparam __naked;
 
-extern char *gets(char *);
-extern char getchar(void);
+extern char *gets (char *);
+extern char getchar (void);
 
 #endif /* __STDIO_H */
index 5399d679e56eb348b799d847bee7751403d6b8d2..eea014262858972cc36cc0d980fe2e0639ecd147 100644 (file)
@@ -22,6 +22,7 @@ libc18f_a_SOURCES += stdio/fprintf.c
 libc18f_a_SOURCES += stdio/printf.c
 libc18f_a_SOURCES += stdio/printf_small.c
 libc18f_a_SOURCES += stdio/printf_tiny.c
+libc18f_a_SOURCES += stdio/putchar.c
 libc18f_a_SOURCES += stdio/sprintf.c
 libc18f_a_SOURCES += stdio/streams.c
 libc18f_a_SOURCES += stdio/strmgpsim.c
@@ -44,7 +45,6 @@ libc18f_a_SOURCES += stdlib/malloc.c
 libc18f_a_SOURCES += stdlib/memfree.c
 libc18f_a_SOURCES += stdlib/memfreemax.c
 libc18f_a_SOURCES += stdlib/memmisc.c
-libc18f_a_SOURCES += stdlib/putchar.c
 libc18f_a_SOURCES += stdlib/rand.c
 libc18f_a_SOURCES += stdlib/realloc.c
 libc18f_a_SOURCES += stdlib/x_ftoa.c
index 27b256477f0c5e3ca6311aa249a5adc430d0a3b0..608bbee28d719156e77360ee45c5c99c1df65235 100644 (file)
@@ -58,17 +58,17 @@ am_libc18f_a_OBJECTS = iscntrl.$(OBJEXT) isdigit.$(OBJEXT) \
        delay100tcy.$(OBJEXT) delay10ktcy.$(OBJEXT) \
        delay10tcy.$(OBJEXT) delay1ktcy.$(OBJEXT) delay1mtcy.$(OBJEXT) \
        fprintf.$(OBJEXT) printf.$(OBJEXT) printf_small.$(OBJEXT) \
-       printf_tiny.$(OBJEXT) sprintf.$(OBJEXT) streams.$(OBJEXT) \
-       strmgpsim.$(OBJEXT) strmmssp.$(OBJEXT) strmputchar.$(OBJEXT) \
-       strmusart.$(OBJEXT) vfprintf.$(OBJEXT) vprintf.$(OBJEXT) \
-       vsprintf.$(OBJEXT) atof.$(OBJEXT) atoi.$(OBJEXT) \
-       atol.$(OBJEXT) calloc.$(OBJEXT) crc16.$(OBJEXT) free.$(OBJEXT) \
-       g_ftoa.$(OBJEXT) itoa.$(OBJEXT) ltoa.$(OBJEXT) \
+       printf_tiny.$(OBJEXT) putchar.$(OBJEXT) sprintf.$(OBJEXT) \
+       streams.$(OBJEXT) strmgpsim.$(OBJEXT) strmmssp.$(OBJEXT) \
+       strmputchar.$(OBJEXT) strmusart.$(OBJEXT) vfprintf.$(OBJEXT) \
+       vprintf.$(OBJEXT) vsprintf.$(OBJEXT) atof.$(OBJEXT) \
+       atoi.$(OBJEXT) atol.$(OBJEXT) calloc.$(OBJEXT) crc16.$(OBJEXT) \
+       free.$(OBJEXT) g_ftoa.$(OBJEXT) itoa.$(OBJEXT) ltoa.$(OBJEXT) \
        malloc.$(OBJEXT) memfree.$(OBJEXT) memfreemax.$(OBJEXT) \
-       memmisc.$(OBJEXT) putchar.$(OBJEXT) rand.$(OBJEXT) \
-       realloc.$(OBJEXT) x_ftoa.$(OBJEXT) memccpy.$(OBJEXT) \
-       memchr.$(OBJEXT) memchrpgm.$(OBJEXT) memchrram.$(OBJEXT) \
-       memcmp.$(OBJEXT) memcpy.$(OBJEXT) memcpypgm2ram.$(OBJEXT) \
+       memmisc.$(OBJEXT) rand.$(OBJEXT) realloc.$(OBJEXT) \
+       x_ftoa.$(OBJEXT) memccpy.$(OBJEXT) memchr.$(OBJEXT) \
+       memchrpgm.$(OBJEXT) memchrram.$(OBJEXT) memcmp.$(OBJEXT) \
+       memcpy.$(OBJEXT) memcpypgm2ram.$(OBJEXT) \
        memcpyram2ram.$(OBJEXT) memmove.$(OBJEXT) memrchr.$(OBJEXT) \
        memset.$(OBJEXT) strcat.$(OBJEXT) strchr.$(OBJEXT) \
        strcmp.$(OBJEXT) strcpy.$(OBJEXT) strcspn.$(OBJEXT) \
@@ -184,13 +184,13 @@ libc18f_a_SOURCES = ctype/iscntrl.c ctype/isdigit.c ctype/isgraph.c \
        delay/delay100ktcy.S delay/delay100tcy.S delay/delay10ktcy.S \
        delay/delay10tcy.S delay/delay1ktcy.S delay/delay1mtcy.S \
        stdio/fprintf.c stdio/printf.c stdio/printf_small.c \
-       stdio/printf_tiny.c stdio/sprintf.c stdio/streams.c \
-       stdio/strmgpsim.c stdio/strmmssp.c stdio/strmputchar.c \
-       stdio/strmusart.c stdio/vfprintf.c stdio/vprintf.c \
-       stdio/vsprintf.c stdlib/atof.c stdlib/atoi.c stdlib/atol.c \
-       stdlib/calloc.c stdlib/crc16.c stdlib/free.c stdlib/g_ftoa.S \
-       stdlib/itoa.c stdlib/ltoa.c stdlib/malloc.c stdlib/memfree.c \
-       stdlib/memfreemax.c stdlib/memmisc.c stdlib/putchar.c \
+       stdio/printf_tiny.c stdio/putchar.c stdio/sprintf.c \
+       stdio/streams.c stdio/strmgpsim.c stdio/strmmssp.c \
+       stdio/strmputchar.c stdio/strmusart.c stdio/vfprintf.c \
+       stdio/vprintf.c stdio/vsprintf.c stdlib/atof.c stdlib/atoi.c \
+       stdlib/atol.c stdlib/calloc.c stdlib/crc16.c stdlib/free.c \
+       stdlib/g_ftoa.S stdlib/itoa.c stdlib/ltoa.c stdlib/malloc.c \
+       stdlib/memfree.c stdlib/memfreemax.c stdlib/memmisc.c \
        stdlib/rand.c stdlib/realloc.c stdlib/x_ftoa.c \
        string/memccpy.c string/memchr.c string/memchrpgm.c \
        string/memchrram.c string/memcmp.c string/memcpy.c \
@@ -719,6 +719,20 @@ printf_tiny.obj: stdio/printf_tiny.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o printf_tiny.obj `if test -f 'stdio/printf_tiny.c'; then $(CYGPATH_W) 'stdio/printf_tiny.c'; else $(CYGPATH_W) '$(srcdir)/stdio/printf_tiny.c'; fi`
 
+putchar.o: stdio/putchar.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT putchar.o -MD -MP -MF $(DEPDIR)/putchar.Tpo -c -o putchar.o `test -f 'stdio/putchar.c' || echo '$(srcdir)/'`stdio/putchar.c
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/putchar.Tpo $(DEPDIR)/putchar.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='stdio/putchar.c' object='putchar.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o putchar.o `test -f 'stdio/putchar.c' || echo '$(srcdir)/'`stdio/putchar.c
+
+putchar.obj: stdio/putchar.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT putchar.obj -MD -MP -MF $(DEPDIR)/putchar.Tpo -c -o putchar.obj `if test -f 'stdio/putchar.c'; then $(CYGPATH_W) 'stdio/putchar.c'; else $(CYGPATH_W) '$(srcdir)/stdio/putchar.c'; fi`
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/putchar.Tpo $(DEPDIR)/putchar.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='stdio/putchar.c' object='putchar.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o putchar.obj `if test -f 'stdio/putchar.c'; then $(CYGPATH_W) 'stdio/putchar.c'; else $(CYGPATH_W) '$(srcdir)/stdio/putchar.c'; fi`
+
 sprintf.o: stdio/sprintf.c
 @am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sprintf.o -MD -MP -MF $(DEPDIR)/sprintf.Tpo -c -o sprintf.o `test -f 'stdio/sprintf.c' || echo '$(srcdir)/'`stdio/sprintf.c
 @am__fastdepCC_TRUE@   mv -f $(DEPDIR)/sprintf.Tpo $(DEPDIR)/sprintf.Po
@@ -1013,20 +1027,6 @@ memmisc.obj: stdlib/memmisc.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memmisc.obj `if test -f 'stdlib/memmisc.c'; then $(CYGPATH_W) 'stdlib/memmisc.c'; else $(CYGPATH_W) '$(srcdir)/stdlib/memmisc.c'; fi`
 
-putchar.o: stdlib/putchar.c
-@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT putchar.o -MD -MP -MF $(DEPDIR)/putchar.Tpo -c -o putchar.o `test -f 'stdlib/putchar.c' || echo '$(srcdir)/'`stdlib/putchar.c
-@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/putchar.Tpo $(DEPDIR)/putchar.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='stdlib/putchar.c' object='putchar.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o putchar.o `test -f 'stdlib/putchar.c' || echo '$(srcdir)/'`stdlib/putchar.c
-
-putchar.obj: stdlib/putchar.c
-@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT putchar.obj -MD -MP -MF $(DEPDIR)/putchar.Tpo -c -o putchar.obj `if test -f 'stdlib/putchar.c'; then $(CYGPATH_W) 'stdlib/putchar.c'; else $(CYGPATH_W) '$(srcdir)/stdlib/putchar.c'; fi`
-@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/putchar.Tpo $(DEPDIR)/putchar.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='stdlib/putchar.c' object='putchar.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o putchar.obj `if test -f 'stdlib/putchar.c'; then $(CYGPATH_W) 'stdlib/putchar.c'; else $(CYGPATH_W) '$(srcdir)/stdlib/putchar.c'; fi`
-
 rand.o: stdlib/rand.c
 @am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rand.o -MD -MP -MF $(DEPDIR)/rand.Tpo -c -o rand.o `test -f 'stdlib/rand.c' || echo '$(srcdir)/'`stdlib/rand.c
 @am__fastdepCC_TRUE@   mv -f $(DEPDIR)/rand.Tpo $(DEPDIR)/rand.Po
index df2bc8e9d8f697e10f003794e76d4aca4ba0cd7a..a261d349f26111d550a71d048e2f34d74a6ed43a 100644 (file)
@@ -1,8 +1,8 @@
 /*-----------------------------------------------------------------
-    fprintf.c - 
+    fprintf.c -
 
     Written for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdarg.h>
 #include <stdio.h>
 
-
 #if _DEBUG
-extern void io_long(unsigned long);
-extern void io_str(char *);
+extern void io_long (unsigned long);
+extern void io_str (char *);
 #endif
 
-unsigned int fprintf(FILE *stream, char *fmt, ...)
+int
+fprintf (FILE *stream, const char *fmt, ...)
 {
-  unsigned int i;
   va_list ap;
-  
+
 #if _DEBUG
-    io_str( "fprintf: " );
-    io_long((unsigned long)stream);
-    io_long((unsigned long)fmt);
+  io_str ("fprintf: ");
+  io_long ((unsigned long) stream);
+  io_long ((unsigned long) fmt);
 #endif
 
-    va_start(ap, fmt);
-    i = vfprintf(stream, fmt, ap);
-    
-  return (i);
+  va_start (ap, fmt);
+  return vfprintf (stream, fmt, ap);
 }
index 6bbf2e1dbdad070d1b1fe54d2fbae769acca5546..93126937c125e19e63cb48e5f20ebd75e49b7e2a 100644 (file)
@@ -1,8 +1,8 @@
 /*-----------------------------------------------------------------
-    printf.c - 
+    printf.c -
 
     Written for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdarg.h>
 #include <stdio.h>
 
 #if _DEBUG
-extern void io_long(unsigned long);
-extern void io_str(char *);
+extern void io_long (unsigned long);
+extern void io_str (char *);
 #endif
 
-
-unsigned int printf(char *fmt, ...)
+int
+printf (const char *fmt, ...)
 {
-  unsigned int i;
   va_list ap;
-//  char *cfmt;
-  
+
 #if _DEBUG
-    io_str( "printf: " );
-    io_long( (unsigned long)stdout );
+  io_str ("printf: ");
+  io_long ((unsigned long) stdout);
 #endif
-//    cfmt = fmt;
-    
-    va_start(ap, fmt);
-    i = vfprintf(stdout, fmt, ap);
-    
-  return (i);
+
+  va_start (ap, fmt);
+  return vfprintf (stdout, fmt, ap);
 }
index 8584474dd76ec31cbd3f79cf11513716c14703bf..d1c766178b416695514755752638e07405069796 100644 (file)
@@ -2,7 +2,7 @@
     printf_small.c - source file for reduced version of printf
 
     Modified for pic16 port, by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-    
+
     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
 
     This library is free software; you can redistribute it and/or modify it
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 /* This function uses function putchar() to dump a character
  * to standard output. putchar() is defined in libc18f.lib
@@ -56,7 +59,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void printf_small(char *fmt, ...) __reentrant
+void
+printf_small (const char *fmt, ...)
+  __reentrant
 {
   char *ch;
   char radix;
@@ -69,66 +74,93 @@ void printf_small(char *fmt, ...) __reentrant
   __data char *str1;
   long val;
   static char buffer[16];
-  va_list ap ;
+  va_list ap;
 
-    ch = fmt;
-    va_start(ap,fmt);
+  ch = fmt;
+  va_start (ap, fmt);
 
-    while( *ch ) {                     //for (; *fmt ; fmt++ )
-        if (*ch == '%') {
-            flong = fstr = fchar = ffloat = 0;
-            radix = 0;
-            ch++;
+  while (*ch) //for (; *fmt ; fmt++ )
+    {
+      if (*ch == '%')
+        {
+          flong = fstr = fchar = ffloat = 0;
+          radix = 0;
+          ++ch;
 
-            if(*ch == 'l') {
+          if (*ch == 'l')
+            {
               flong = 1;
-              ch++;
-            } else
-            if(*ch == 'h') {
+              ++ch;
+            }
+          else if (*ch == 'h')
+            {
               fchar = 1;
-              ch++;
+              ++ch;
             }
-            
-            if(*ch == 's')fstr = 1;
-            else if(*ch == 'f')ffloat = 1;
-            else if(*ch == 'd')radix = 10;
-            else if(*ch == 'x')radix = 16;
-            else if(*ch == 'c')radix = 0;
-            else if(*ch == 'o')radix = 8;
-            
-            if(fstr) {
-                str = va_arg(ap, char *);
-                while (*str) putchar(*str++);
-            } else
-            if(ffloat) {
-                flt = va_arg(ap, float);
-                x_ftoa(flt, buffer, 32, 6);
-                str1 = buffer;
-                while( *str1 )str1++; str1--;
-                while( *str1 == '0' )str1--; str1++;
-                *str1 = 0; str1 = buffer;
-                while( *str1 )putchar(*str1++);
-            } else {
-              if(flong)val = va_arg(ap, long);
+
+          if (*ch == 's')
+            fstr = 1;
+          else if (*ch == 'f')
+            ffloat = 1;
+          else if (*ch == 'd')
+            radix = 10;
+          else if (*ch == 'x')
+            radix = 16;
+          else if (*ch == 'c')
+            radix = 0;
+          else if (*ch == 'o')
+            radix = 8;
+
+          if (fstr)
+            {
+              str = va_arg (ap, char *);
+              while (*str)
+                putchar (*str++);
+            }
+          else if (ffloat)
+            {
+              flt = va_arg (ap, float);
+              x_ftoa (flt, buffer, 32, 6);
+              str1 = buffer;
+              while (*str1)
+                ++str1;
+              --str1;
+              while (*str1 == '0')
+                --str1;
+              ++str1;
+              *str1 = 0;
+              str1 = buffer;
+              while (*str1)
+                putchar (*str1++);
+            }
+          else
+            {
+              if (flong)
+                val = va_arg (ap, long);
+              else if (fchar)
+                val = (char) va_arg (ap, int);  // FIXME: SDCC casts char arguments into ints
               else
-              if(fchar)val = (char)va_arg(ap, int); // FIXME: SDCC casts char arguments into ints
-              else {
-                  val = va_arg(ap, int);
-              }
-            
-              if(radix) {
-                ltoa (val, buffer, radix);
-
-                str1 = buffer;
-                while ( *str1 ) {
-                  putchar ( *str1++ );
+                {
+                  val = va_arg (ap, int);
                 }
-              }        else
-                putchar((char)val);
+
+              if (radix)
+                {
+                  ltoa (val, buffer, radix);
+
+                  str1 = buffer;
+                  while (*str1)
+                    {
+                      putchar (*str1++);
+                    }
+                }
+              else
+                putchar ((char) val);
             }
-          } else
-            putchar(*ch);
+        }
+      else
+        putchar (*ch);
 
-        ch++;
+      ++ch;
     }
 }
index caa3152c372da3ca971c0ac04180377a06398fbf..f88bb36da707a5c79f03965fbc1e2756f0534c22 100644 (file)
@@ -2,7 +2,7 @@
     printf_tiny.c - source file for reduced version of printf
 
     Modified for pic16 port, by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-    
+
     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
 
     This library is free software; you can redistribute it and/or modify it
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 /* This function uses function putchar() to dump a character
  * to standard output. putchar() is defined in libc18f.lib
@@ -40,7 +43,7 @@
    format     output type       argument-type
      %u*       unsigned            *
 
-     %b               binary
+     %b        binary
      %d        decimal             int
      %ld       decimal             long
      %hd       decimal             char
      %s        character           generic pointer
 */
 
+/*
+ * This macro enables the use of the 'b' binary specifier and
+ * the use of "%b", "%hb" and "%lb"
+ */
+/* #define BINARY_SPECIFIER */
+
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #if 0
-#define        DPUT(c) putchar( c )
+#define DPUT(c) putchar(c)
 #else
 #define DPUT(c)
 #endif
 
-#define ISLONG         (flong)
-#define ISSTR          (fstr)
-#define ISCHAR         (fchar)
-#define HAVESIGN       (nosign)
+#define ISLONG          (flong)
+#define ISSTR           (fstr)
+#define ISCHAR          (fchar)
+#define HAVESIGN        (nosign)
 
 
 #if 1
-extern void io_long(long);
-extern void io_int(long);
-extern void io_char(char);
+extern void io_long (long);
+extern void io_int (long);
+extern void io_char (char);
 #endif
 
-void printf_tiny(char *fmt, ...) 
+void
+printf_tiny (const char *fmt, ...)
 {
   char radix;
   char flong, fstr;
@@ -89,76 +99,109 @@ void printf_tiny(char *fmt, ...)
   long val;
 //  static char buffer[16];
   char buffer[16];
-  va_list ap ;
-
-    va_start(ap,fmt);
-    ch = fmt;
-    
-    while( *ch ) {                     //for (; *fmt ; fmt++ )
-        if (*ch == '%') {
-            ISLONG = 0;
-            ISSTR = 0;
-            ISCHAR = 0;
-            HAVESIGN = 0;
-            radix = 0;
-            upcase = 0;
-            ch++;
-
-            if(*ch == 'u') {
+  va_list ap;
+
+  va_start (ap, fmt);
+  ch = fmt;
+
+  while (*ch) //for (; *fmt ; fmt++ )
+    {
+      if (*ch == '%')
+        {
+          ISLONG = 0;
+          ISSTR = 0;
+          ISCHAR = 0;
+          HAVESIGN = 0;
+          radix = 0;
+          upcase = 0;
+          ch++;
+
+          if (*ch == 'u')
+            {
               HAVESIGN = 1;
-              ch++;
+              ++ch;
             }
-            
-            if(*ch == 'l') {
+
+          if (*ch == 'l')
+            {
               ISLONG = 1;
-              ch++;
-            } else
-            if(*ch == 'h') {
+              ++ch;
+            }
+          else if (*ch == 'h')
+            {
               ISCHAR = 1;
-              ch++;
+              ++ch;
             }
-            
-            if(*ch == 's')ISSTR = 1;
-            else if(*ch == 'd')radix = 10;
-            else if(*ch == 'x'){ radix = 16; upcase = 0; }
-            else if(*ch == 'X'){ radix = 16; upcase = 1; }
-            else if(*ch == 'c')radix = 0;
-            else if(*ch == 'o')radix = 8;
-            else if(*ch == 'b')radix = 2;
-            
-            if(ISSTR) {
-                str = va_arg(ap, char *);
-                while(*str) { putchar(*str);str++;}
-            } else {
-              if(ISLONG)val = va_arg(ap, long);
+
+          if (*ch == 's')
+            ISSTR = 1;
+          else if (*ch == 'd')
+            radix = 10;
+          else if (*ch == 'x')
+            {
+              radix = 16;
+              upcase = 0;
+            }
+          else if (*ch == 'X')
+            {
+              radix = 16;
+              upcase = 1;
+            }
+          else if (*ch == 'c')
+            radix = 0;
+          else if (*ch == 'o')
+            radix = 8;
+#ifdef BINARX_SPECIFIER
+          else if (*ch == 'b')
+            radix = 2;
+#endif
+
+          if (ISSTR)
+            {
+              str = va_arg (ap, char *);
+              while (*str)
+                {
+                  putchar (*str);
+                  ++str;
+                }
+            }
+          else
+            {
+              if (ISLONG)
+                val = va_arg (ap, long);
+              else if (ISCHAR)
+                {
+                  val = (unsigned char) va_arg (ap, int);       // FIXME: SDCC casts char arguments into ints
+                  if (!HAVESIGN)
+                    val = (char) val;   // FIXME cont'd: sign-extend if required
+                }
               else
-              if(ISCHAR) {
-                 val = (unsigned char)va_arg(ap, int); // FIXME: SDCC casts char arguments into ints
-                 if (!HAVESIGN) val = (char)val; // FIXME cont'd: sign-extend if required
-             } else {
-                  val = va_arg(ap, int);
-              }
-
-              if(radix) {
-                if(HAVESIGN)
-                  ultoa(val, buffer, radix);
-                else
-                  ltoa (val, buffer, radix);
-
-                str1 = buffer;
-                while( (*str1) ) {
-                  radix = *str1;
-                  if(upcase)
-                    radix = toupper( radix );
-                  putchar ( radix );
-                  str1++;
+                val = va_arg (ap, int);
+
+              if (radix)
+                {
+                  if (HAVESIGN)
+                    ultoa (val, buffer, radix);
+                  else
+                    ltoa (val, buffer, radix);
+
+                  str1 = buffer;
+                  while ((*str1))
+                    {
+                      radix = *str1;
+                      if (upcase)
+                        radix = toupper (radix);
+                      putchar (radix);
+                      ++str1;
+                    }
                 }
-              }        else
-                putchar((char)val);
+              else
+                putchar ((char) val);
             }
-          } else
-            putchar(*ch);
+        }
+      else
+        putchar (*ch);
 
-        ch++;
+      ++ch;
     }
 }
diff --git a/device/lib/pic16/libc/stdio/putchar.c b/device/lib/pic16/libc/stdio/putchar.c
new file mode 100644 (file)
index 0000000..19de6b9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * putchar.c - putchar dummy function
+ *
+ * written by Vangelis Rokas, 2005 (vrokas@otenet.gr)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * As a special exception, if you link this library with other files,
+ * some of which are compiled with SDCC, to produce an executable,
+ * this library does not by itself cause the resulting executable
+ * to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ */
+
+#include <stdio.h>
+
+/* this is a dummy function so that sources compile,
+ * even when user doesn't give a putchar() function.
+ * NOTE that putchar() is declared in stdio.h to
+ * have the argument in WCHAR (via the wparam pragma) */
+
+void
+putchar (char c) __wparam __naked
+{
+  c;
+  __asm
+    return
+  __endasm;
+}
index be9dee40cc2c83885d7ea25d3e86a3df69de00a4..b7f5a031d313bdb9ca941e8fea154496462c73ba 100644 (file)
@@ -1,8 +1,8 @@
 /*-----------------------------------------------------------------
-    sprintf.c - 
+    sprintf.c -
 
     Written for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdarg.h>
 #include <stdio.h>
 
-unsigned int sprintf(char *ebuf, char *fmt, ...) 
+int
+sprintf (char *ebuf, char *fmt, ...)
 {
   unsigned int i;
   va_list ap;
-  char *cfmt;
-  
-  
-    cfmt = fmt;
-    
-    ap = va_start(ap, fmt);
-    i = vfprintf((FILE *) &ebuf, cfmt, ap);
-    *ebuf='\0';
-    
-  return (i);
+
+  ap = va_start (ap, fmt);
+  i = vfprintf ((FILE *) &ebuf, fmt, ap);
+  *ebuf = '\0';
+
+  return i;
 }
index 58eb209e757da4482ef54bb2c3280f0427a33d22..f48eb8b2d623c569f7dba334f322ac3ba26ae9d3 100644 (file)
@@ -2,7 +2,7 @@
     streams.c - source file for stream declarations
 
     Written by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
-
-/*
-** $Id$
-*/
 
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdio.h>
 
index f50324fda726cc81ab43bba59180bc4642e4fb42..300cffd3d9905a028954adc75d2e17856b14a505 100644 (file)
@@ -2,7 +2,7 @@
     strmusart.c - usart stream putchar
 
     Modified for pic16 port, by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-    
+
     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
 
     This library is free software; you can redistribute it and/or modify it
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 extern WREG;
 
 /* note that USART should already been initialized */
-void __stream_gpsim_putchar(unsigned char c) __wparam __naked
+void
+__stream_gpsim_putchar (char c) __wparam __naked
 {
   c;
   __asm
-    MOVFF      _WREG, 0xf7f
+    MOVFF       _WREG, 0xf7f
     RETURN
   __endasm;
 }
index 25825e1949ba54d0703015d0896be037f93aae6f..bc0e7fcbb5602ce46552388077879e7bf83cd936 100644 (file)
@@ -2,7 +2,7 @@
     strmmssp.c - MSSP stream putchar
 
     Written for pic16 port, by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 extern WREG;
 extern SSPBUF;
 
 /* note that USART should already been initialized */
-void __stream_mssp_putchar(unsigned char c) __wparam __naked
+void
+__stream_mssp_putchar (char c) __wparam __naked
 {
   c;
   __asm
-    MOVWF      _SSPBUF
+    MOVWF       _SSPBUF
     RETURN
   __endasm;
 }
index 339fa33a85351fd298ec7bf29a79426bebe719d1..57d16b96be4702296900c09bbd40131270bfb3cd 100644 (file)
@@ -2,7 +2,7 @@
     strmputchar.c - stream putchar dispatch function
 
     Written for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdio.h>
 
-void __stream_putchar(FILE *stream, unsigned char c)
+void
+__stream_putchar(FILE *stream, char c)
 {
   unsigned char deref;
 
-    deref = (unsigned char)(((unsigned long)stream) >> 16);
+  deref = (unsigned char) (((unsigned long) stream) >> 16);
 
 #if _DEBUG
-    io_str( "__stream_putchar: " );
-    io_long((unsigned long)stream);
+  io_str ("__stream_putchar: ");
+  io_long ((unsigned long) stream);
 #endif
 
-    if(deref == 0x80) {
+  if (deref == 0x80)
+    {
       /* this is a data/near memory pointer */
-      *(*(char **)stream) = c;
-      *(char **)stream+=1;
-    } else
-    if(deref & 0x20) {
+      *(*(char **) stream) = c;
+      *(char **) stream += 1;
+    }
+  else if (deref & 0x20)
+    {
       deref ^= 0x20;
-      if(deref == USART_DEREF)
-        __stream_usart_putchar(c);
-      else
-      if(deref == MSSP_DEREF)
-        __stream_mssp_putchar(c);
-      else
-      if(deref == USER_DEREF)
-        putchar(c);
-      else
-      if(deref == GPSIM_DEREF)                 /* see stdio.h for info on this */
-        __stream_gpsim_putchar(c);             /* feature */
+      if (deref == USART_DEREF)
+        __stream_usart_putchar (c);
+      else if (deref == MSSP_DEREF)
+        __stream_mssp_putchar (c);
+      else if (deref == USER_DEREF)
+        putchar (c);
+      else if (deref == GPSIM_DEREF)    /* see stdio.h for info on this */
+        __stream_gpsim_putchar (c);     /* feature */
     }
 }
index d2813612d982fd1cc1428c5e5c013472697f7cac..141b1c272175a25b610f214dd679cb7251dcce8c 100644 (file)
@@ -2,7 +2,7 @@
     strmusart.c - usart stream putchar
 
     Written for pic16 port, by Vangelis Rokas, 2004 (vrokas@otenet.gr)
-    
+
     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
 
     This library is free software; you can redistribute it and/or modify it
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 extern WREG;
 extern TXREG;
 extern TXSTA;
 
 /* note that USART should already been initialized */
-void __stream_usart_putchar(unsigned char c) __wparam __naked
+void
+__stream_usart_putchar (char c) __wparam __naked
 {
   c;
   __asm
 @1:
-    BTFSS      _TXSTA, 1
-    BRA                @1
-    MOVWF      _TXREG
+    BTFSS       _TXSTA, 1
+    BRA         @1
+    MOVWF       _TXREG
     RETURN
   __endasm;
 }
index f413180b7c9ebcab012546884f9695b37c1143c2..95d8b002a4b7045614bb3a346d7df5328595574f 100644 (file)
@@ -2,6 +2,7 @@
     vfprintf.c - source file for reduced version of printf
 
     Modified for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
+    Bug-fixed and feature-enhanced by Mauro Giachero, 2008 (mauro.giachero@gmail.com)
 
     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
 
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 /* following formats are supported :-
    format     output type       argument-type
      %%        -                   -
+     %u        unsigned            int
      %u*       unsigned            *
-     %b               binary              int
+     %b        binary              int
      %lb       binary              long
      %hb       binary              char
      %d        decimal             int
-     %ld       decimal             long
-     %hd       decimal             char
+     %lu       unsigned            long
+     %hu       unsigned            char
+     %l[di]    decimal             long
+     %lu[di]   unsigned            long
+     %h[di]    decimal             char
+     %hu[di]   unsigned            char
      %[xX]     hexadecimal         int
      %l[xX]    hexadecimal         long
      %h[xX]    hexadecimal         char
      %ho       octal               char
      %c        character           char
      %s        character           generic pointer
+   Also supported are:
+   - the '0', '-' and ' ' alignment modifiers
+   - the '+' and ' ' modifiers
+   - the width field for integral types
+   - the precision field for strings
 */
 
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+/***********************************************************
+ * The following switches enable some "advanced" features. *
+ * With all the switches enabled:                          *
+ * ; Statistics:                                           *
+ * ; code size:     2062 (0x080e) bytes ( 1.57%)           *
+ * ;                1031 (0x0407) words                    *
+ * ; udata size:      16 (0x0010) bytes ( 1.25%)           *
+ * ; access size:     31 (0x001f) bytes                    *
+ * With all the switches disabled:                         *
+ * ; Statistics:                                           *
+ * ; code size:     1278 (0x04fe) bytes ( 0.98%)           *
+ * ;                 639 (0x027f) words                    *
+ * ; udata size:      16 (0x0010) bytes ( 1.25%)           *
+ * ; access size:     25 (0x0019) bytes                    *
+ ***********************************************************/
+/*
+ * Define this to enable support of the field width, which
+ * allows to specify the minimum number of characters an
+ * integer must use.
+ * Costs ~200 code words and 3 bytes in access RAM.
+ */
+#define FIELD_WIDTH
+/*
+ * Define this to enable support of the precision, which
+ * allows to specify the maximum number of characters a
+ * string can use. Note that this implementation doesn't
+ * use this field for integers (as it should).
+ * Costs ~85 code words and 1 byte in access RAM.
+ */
+#define PRECISION
+/*
+ * Define this to enable support of the '+' and ' ' modifiers,
+ * which specify that a positive signed number must be
+ * preceded respectively with a '+' or a ' ' character.
+ * Costs ~70 code words and 2 words of access RAM
+ */
+#define SIGN_MODIFIERS
+/*
+ * With this macro defined, trying to print a float number
+ * will generate the "<NO FLOAT>" string.
+ * Costs ~25 code words
+ */
+#define FLOAT_PLACEHOLDER
+/*
+ * This macro enables the use of the 'b' binary specifier and
+ * the use of "%b", "%hb" and "%lb"
+ */
+/* #define BINARY_SPECIFIER */
+/*
+ * This macro enables the use of the 'i' integer specifier and
+ * the use of "%u", "%lu", ... in place of "%ud", "%lud", ... .
+ * costs ~10 code words
+ */
+#define EXTRA_INTEGER
+
 #if _DEBUG
-extern void io_long(unsigned long);
-extern void io_str(char *);
-extern void io_int(unsigned int);
+extern void io_long (unsigned long);
+extern void io_str (char *);
+extern void io_int (unsigned int);
 #endif
 
-unsigned int vfprintf(FILE *stream, char *fmt, va_list ap)
+int
+vfprintf (FILE * stream, const char *fmt, va_list ap)
 {
   unsigned char radix;
-  unsigned char flong, fstr;
-  unsigned char fchar, nosign;
+  unsigned char flong;
+  unsigned char fstr;
+  unsigned char fchar;
+#ifdef FLOAT_PLACEHOLDER
+  unsigned char ffloat;
+#endif
+  unsigned char nosign;
   unsigned char upcase;
-  unsigned int count=0;
+#ifdef FIELD_WIDTH
+  unsigned char fieldwidth;
+  unsigned char lalign;
+  char padchar;
+  char *str1;
+#endif
+#ifdef PRECISION
+  unsigned char precision;
+#endif
+#ifdef SIGN_MODIFIERS
+  unsigned char printsign;
+  char positivechar;
+#endif
+  int count = 0;
   char *str, *ch;
-  __data char *str1;
   long val;
 //  static char buffer[16];
   char buffer[16];
 
-
 #if _DEBUG
-  io_str( "vfprintf: " );
-  io_long( (unsigned long)stream );
-  io_long( (unsigned long)fmt );
+  io_str ("vfprintf: ");
+  io_long ((unsigned long) stream);
+  io_long ((unsigned long) fmt);
 #endif
 
 //    va_start(ap,fmt);
   ch = fmt;
 
-  while( *ch ) {      //for (; *fmt ; fmt++ )
-    if (*ch == '%') {
-      flong = 0;
-      fstr = 0;
-      fchar = 0;
-      nosign = 0;
-      radix = 0;
-      upcase = 0;
-      ch++;
-
-      if(*ch == '%') {
-        __stream_putchar(stream, *ch);
-        ++count;
-        ++ch;
-        continue;
-      }
-
-      if(*ch == 'u') {
-        nosign = 1;
-        ch++;
-      }
-
-      if(*ch == 'l') {
-        flong = 1;
-        ch++;
-      } else if(*ch == 'h') {
-        fchar = 1;
-        ch++;
-      }
-
-      if(*ch == 's')fstr = 1;
-      else if(*ch == 'd')radix = 10;
-      else if(*ch == 'x'){ radix = 16; upcase = 0; }
-      else if(*ch == 'X'){ radix = 16; upcase = 1; }
-      else if(*ch == 'c')radix = 0;
-      else if(*ch == 'o')radix = 8;
-      else if(*ch == 'b')radix = 2;
-      else {
-        __stream_putchar(stream, *ch);
-        ++count;
-        ++ch;
-        continue;
-      }
-
-      if(fstr) {
-        str = va_arg(ap, char *);
-        while(*str) { __stream_putchar(stream, *str); str++; count++; }
-      } else {
-        val = 0;
-        if(flong) {
-          val = va_arg(ap, long);
+  while (*ch) //for (; *fmt ; fmt++ )
+    {
+      if (*ch == '%')
+        {
+          flong = 0;
+          fstr = 0;
+          fchar = 0;
+#ifdef FLOAT_PLACEHOLDER
+          ffloat = 0;
+#endif
+          nosign = 0;
+          radix = 10;
+          upcase = 0;
+#ifdef FIELD_WIDTH
+          fieldwidth = 0;
+          lalign = 0;
+          padchar = ' ';
+#endif
+#ifdef PRECISION
+          // precision == -1 is used as an "unlimited" precision marker
+          precision = -1;
+#endif
+#ifdef SIGN_MODIFIERS
+          printsign = 0;
+          positivechar = '+';
+#endif
+          ++ch;
+
+          if (*ch == '%')
+            {
+              __stream_putchar (stream, *ch);
+              ++count;
+              ++ch;
+              continue;
+            }
+
+#ifdef FIELD_WIDTH
+          if (*ch == '0')
+            {
+              padchar = '0';
+              ++ch;
+            }
+
+          if (*ch == '-')
+            {
+              lalign = 1;
+              ++ch;
+            }
+#endif
+#ifdef SIGN_MODIFIERS
+          if (*ch == ' ')
+            {
+              printsign = 1;
+              positivechar = ' ';
+              ++ch;
+            }
+
+          if (*ch == '+')
+            {
+              printsign = 1;
+              ++ch;
+            }
+#endif
+
+#ifdef FIELD_WIDTH
+          if ((*ch >= '1') && (*ch <= '9'))
+            {
+              while ((*ch >= '0') && (*ch <= '9'))
+                {
+                  fieldwidth = 10 * fieldwidth + (*ch) - '0';
+                  ++ch;
+                }
+            }
+#endif
+
+#ifdef PRECISION
+          if (*ch == '.')
+            {
+              ++ch;
+              precision = 0;
+              while ((*ch >= '0') && (*ch <= '9'))
+                {
+                  precision = 10 * precision + (*ch) - '0';
+                  ++ch;
+                }
+            }
+#endif
+
+          if (*ch == 'l')
+            {
+              flong = 1;
+              ++ch;
+            }
+          else if (*ch == 'h')
+            {
+              fchar = 1;
+              ++ch;
+            }
+
+          if (*ch == 'u')
+            {
+              nosign = 1;
+              ++ch;
+            }
+
+          if (*ch == 's')
+            {
+              fstr = 1;
+#ifdef FIELD_WIDTH
+              padchar = ' ';    /* Strings are always space-padded */
+#endif
+            }
+          else if (*ch == 'x')
+            radix = 16;
+          else if (*ch == 'X')
+            {
+              radix = 16;
+              upcase = 1;
+            }
+          else if (*ch == 'c')
+            radix = 0;
+          else if (*ch == 'o')
+            radix = 8;
+#ifdef BINARX_SPECIFIER
+          else if (*ch == 'b')
+            radix = 2;
+#endif
+#ifdef FLOAT_PLACEHOLDER
+          else if (*ch == 'f')
+            {
+              ffloat = 1;
+# ifdef PRECISION
+              precision = -1;
+# endif
+            }
+#endif
+#ifdef EXTRA_INTEGER
+          else if ((*ch == 'd') || (*ch == 'i'))  /* This is the default */
+            ;
+          else if (nosign)                        /* %u alone is the same as %ud */
+            --ch;
+#else
+          else if (*ch == 'd')
+            ;
+#endif
+          else
+            {
+              __stream_putchar (stream, *ch);
+              ++count;
+              ++ch;
+              continue;
+            }
+
+          if (fstr)
+            {
+              str = va_arg (ap, char *);
+#ifdef FLOAT_PLACEHOLDER
+            }
+          else if (ffloat)
+            {
+              str = "<NO FLOAT>";
+              va_arg (ap, float);
+#endif
+            }
+          else
+            {
+#ifdef PRECISION
+              precision = -1; //FIXME: No support for the precision field on numerals
+#endif
+              val = 0;
+              if (flong)
+                {
+                  val = va_arg (ap, long);
 #if _DEBUG
-          io_long(val);
+                  io_long (val);
 #endif
-        }
-        else if(fchar) {
-          val = (unsigned char)va_arg(ap, int); // FIXME: SDCC passes 1-byte char varargs as 2-byte ints...
-         if (!nosign) val = (char) val; // (FIXME cont'd) sign extend if required
+                }
+              else if (fchar)
+                {
+                  val = (char) va_arg (ap, int);  // FIXME: SDCC passes 1-byte char varargs as 2-byte ints...
+                  if ((radix != 10) || nosign)
+                    val = (unsigned char) val;    //Avoid unwanted sign extension
 #if _DEBUG
-          io_long(val);
+                  io_long (val);
 #endif
-        }
-        else {
-          val = va_arg(ap, int);
+                }
+              else
+                {
+                  val = va_arg (ap, int);
+                  if ((radix != 10) || nosign)
+                    val = (unsigned int) val;   //Avoid unwanted sign extension
 #if _DEBUG
-          io_long(val);
+                  io_long (val);
 #endif
-        }
+                }
 
-        if(radix) {
-          if(nosign)
-            ultoa(val, buffer, radix);
-          else
-            ltoa (val, buffer, radix);
-
-          str1 = buffer;
-          while( (*str1) ) {
-            radix = *str1;
-            if(upcase)
-              radix = toupper( radix );
-            __stream_putchar(stream, (unsigned char)radix);
-            count++;
-            str1++;
-          }
-        } else {
-          __stream_putchar(stream, (unsigned char)val);
-          count++;
+              str = buffer + 1; //Reserve space for a forced '+'
+              if (radix)
+                {
+                  if (nosign)
+                    ultoa (val, buffer + 1, radix);
+                  else
+                    ltoa (val, buffer + 1, radix);
+#ifdef SIGN_MODIFIERS
+                  if (printsign && (*str != '-'))
+                    {
+                      --str;
+                      *str = positivechar;
+                    }
+#endif
+                }
+              else
+                {
+                  *str = (unsigned char) val;
+                  *(str + 1) = '\0';
+                }
+            }
+
+#ifdef FIELD_WIDTH
+          //Count how many pad chars are required in fieldwidth
+          str1 = str;
+          while (fieldwidth && *str1)
+            {
+              ++str1;
+              --fieldwidth;
+            }
+          //Left padding
+          if (!lalign)
+            {
+              while (fieldwidth)
+                {
+                  __stream_putchar (stream, padchar);
+                  ++count;
+                  --fieldwidth;
+                }
+            }
+#endif
+          while (*str
+#ifdef PRECISION
+                 && (!~precision || precision--)
+#endif
+            )
+            {
+              radix = *str;
+              if (upcase)
+                {
+                  radix = toupper (radix);
+                }
+              __stream_putchar (stream, radix);
+              ++str;
+              ++count;
+            }
+#ifdef FIELD_WIDTH
+          //Right padding (with spaces)
+          if (lalign)
+            {
+              while (fieldwidth)
+                {
+                  __stream_putchar (stream, ' ');
+                  ++count;
+                  --fieldwidth;
+                }
+            }
+#endif
+        }
+      else
+        {
+          __stream_putchar (stream, *ch);
+          ++count;
         }
-      }
-    } else {
-      __stream_putchar(stream, *ch);
-      count++;
-    }
 
-    ch++;
-  }
+      ++ch;
+    }
 
-  return (count);
+  return count;
 }
index 992132dfa4a0ae0e6602dc8c846dbbee2857bae4..ef6be5e1a867ebf3f16a720f52bd50ebaf7ee142 100644 (file)
@@ -1,8 +1,8 @@
 /*-----------------------------------------------------------------
-    vprintf.c - 
+    vprintf.c -
 
     Written for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdarg.h>
 #include <stdio.h>
 
-unsigned vprintf(char *fmt, va_list ap)
+int
+vprintf (const char *fmt, va_list ap)
 {
-  unsigned int i;
-  
-    i = vfprintf(stdout, fmt, ap);
-    
-  return (i);
+  return vfprintf(stdout, fmt, ap);
 }
index 3dbdc9be6c8904f38b44847574a04af7c69b8440..16e930d4bc51cce7aebff96ff802095f04316bae 100644 (file)
@@ -1,8 +1,8 @@
 /*-----------------------------------------------------------------
-    vsprintf.c - 
+    vsprintf.c -
 
     Written for pic16 port, by Vangelis Rokas, 2005 (vrokas@otenet.gr)
-    
+
     This library is free software; you can redistribute it and/or modify it
     under the terms of the GNU Library General Public License as published by the
     Free Software Foundation; either version 2, or (at your option) any
     In other words, you are welcome to use, share and improve this program.
     You are forbidden to forbid anyone else to use, share and improve
     what you give them.   Help stamp out software-hoarding!
--------------------------------------------------------------------------*/
 
-/*
-** $Id$
-*/
+   As a special exception, if you link this library with other files,
+   some of which are compiled with SDCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
 
 #include <stdarg.h>
 #include <stdio.h>
 
-
-unsigned int vsprintf(char *ebuf, char *fmt, va_list ap) 
+int
+vsprintf (char *ebuf, const char *fmt, va_list ap)
 {
   unsigned int i;
-  char *cfmt;
 
-    cfmt = fmt;
-    i = vfprintf((FILE *) &ebuf, cfmt, ap);
-    *ebuf = '\0';
+  i = vfprintf((FILE *) &ebuf, fmt, ap);
+  *ebuf = '\0';
 
-  return (i+1);
+  return i;
 }
diff --git a/device/lib/pic16/libc/stdlib/putchar.c b/device/lib/pic16/libc/stdlib/putchar.c
deleted file mode 100644 (file)
index 718fdb0..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * putchar.c - putchar dummy function
- *
- * written by Vangelis Rokas, 2005 (vrokas@otenet.gr)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-/*
-** $Id$
- */
-
-#include <stdio.h>
-
-/* this is a dummy function so that sources compile,
- * even when user doesn't give a putchar() function.
- * NOTE that putchar() is declared in stdio.h to
- * have the argument in WCHAR (via the wparam pragma) */
-
-PUTCHAR(c)
-{
-  c;
-  __asm
-    return
-  __endasm;
-}