device/lib/pic16/libc/stdio/putchar.c: putchar should not be
declared __naked for convenience, named all arguments
* device/lib/pic16/libc/stdio/strmgpsim.c,
device/lib/pic16/libc/stdio/strmmssp.c,
device/lib/pic16/libc/stdio/strmusart.c: cosmetic changes
* src/pic16/pcode.c (createReachingDefinitions): avoid segfault on
empty __naked functions,
* (pCodeLabelDestruct, pic16_unlinkpCode, pic16_pCodeUnlink): fix
corner cases (unlink first/last pCode in list), reuse more code
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5249
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2008-10-06 Raphael Neider <rneider AT web.de>
+
+ * device/include/pic16/stdio.h,
+ device/lib/pic16/libc/stdio/putchar.c: putchar should not be
+ declared __naked for convenience, named all arguments
+ * device/lib/pic16/libc/stdio/strmgpsim.c,
+ device/lib/pic16/libc/stdio/strmmssp.c,
+ device/lib/pic16/libc/stdio/strmusart.c: cosmetic changes
+
+ * src/pic16/pcode.c (createReachingDefinitions): avoid segfault on
+ empty __naked functions,
+ * (pCodeLabelDestruct, pic16_unlinkpCode, pic16_pCodeUnlink): fix
+ corner cases (unlink first/last pCode in list), reuse more code
+
2008-10-05 Maarten Brock <sourceforge.brock AT dse.nl>
* src/ds390/main.c (_ds390_genInitStartup): added
* src/pic16/glue.c:
definition of absolute address symbols without initial value,
- fixed SDCC cresh "do not know how to intialize symbol"
+ fixed SDCC crash "do not know how to intialize symbol"
2008-09-16 Maarten Brock <sourceforge.brock AT dse.nl>
#define GPSIM_DEREF 0xe
#define STREAM_GPSIM ((FILE *)(0x002e0000UL))
-extern FILE * stdin;
-extern FILE * stdout;
+extern FILE *stdin;
+extern FILE *stdout;
/* printf_small() supports float print */
-void printf_small (const char *, ...);
+void printf_small (const char *fmt, ...);
/* printf_tiny() does not support float print */
-void printf_tiny (const char *, ...); // __reentrant;
+void printf_tiny (const char *fmt, ...); // __reentrant;
-extern int printf (const char *,...);
-extern int fprintf (FILE *, const char *,...);
-extern int sprintf (char *, const char *, ...);
+extern int printf (const char *fmt, ...);
+extern int fprintf (FILE *stream, const char *fmt, ...);
+extern int sprintf (char *str, const char *fmt, ...);
-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 int vprintf (const char *fmt, va_list ap);
+extern int vfprintf (FILE *stream, const char *fmt, va_list ap);
+extern int vsprintf (char *str, const char *fmt, va_list ap);
-extern void putchar (char) __wparam __naked;
+extern void putchar (char c) __wparam;
-extern void __stream_putchar (FILE *, char);
+extern void __stream_putchar (FILE *stream, char c);
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 *gets (char *str);
extern char getchar (void);
#endif /* __STDIO_H */
* have the argument in WCHAR (via the wparam pragma) */
void
-putchar (char c) __wparam __naked
+putchar (char c) __wparam
{
- c;
- __asm
- return
- __endasm;
+ (void)c;
}
void
__stream_gpsim_putchar (char c) __wparam __naked
{
- c;
+ (void)c;
__asm
MOVFF _WREG, 0xf7f
RETURN
void
__stream_mssp_putchar (char c) __wparam __naked
{
- c;
+ (void)c;
__asm
MOVWF _SSPBUF
RETURN
void
__stream_usart_putchar (char c) __wparam __naked
{
- c;
+ (void)c;
__asm
@1:
BTFSS _TXSTA, 1
if(!pc)
return;
+ pic16_unlinkpCode(pc);
+
// if((pc->type == PC_LABEL) && PCL(pc)->label)
// Safe_free(PCL(pc)->label);
fprintf(stderr,"Unlinking: ");
printpCode(stderr, pc);
#endif
- if(pc->prev)
+ if(pc->prev) {
pc->prev->next = pc->next;
- if(pc->next)
+ } else if (pc->pb && (pc->pb->pcHead == pc)) {
+ pc->pb->pcHead = pc->next;
+ }
+ if(pc->next) {
pc->next->prev = pc->prev;
+ } else if (pc->pb && (pc->pb->pcTail == pc)) {
+ pc->pb->pcTail = pc->prev;
+ }
/* move C source line down (or up) */
if (isPCI(pc) && PCI(pc)->cline) {
pBranch *pb1,*pb2;
pCode *pc1;
- if(!pc->prev || !pc->next) {
- fprintf(stderr,"unlinking bad pCode in %s:%d\n",__FILE__,__LINE__);
- exit(1);
- }
-
- /* move C source line down (or up) */
- if (isPCI(pc) && PCI(pc)->cline) {
- pc1 = pic16_findNextInstruction (pc->next);
- if (pc1 && isPCI(pc1) && !PCI(pc1)->cline) {
- PCI(pc1)->cline = PCI(pc)->cline;
- } else {
- pc1 = pic16_findPrevInstruction (pc->prev);
- if (pc1 && isPCI(pc1) && !PCI(pc1)->cline)
- PCI(pc1)->cline = PCI(pc)->cline;
- }
+ if (!pc) {
+ return;
}
- /* first remove the pCode from the chain */
- pc->prev->next = pc->next;
- pc->next->prev = pc->prev;
-
- pc->prev = pc->next = NULL;
-
- /* Now for the hard part... */
-
/* Remove the branches */
pb1 = PCI(pc)->from;
pb1 = pb1->next;
}
+ pic16_unlinkpCode (pc);
}
#endif
} // for
pc = pic16_findNextInstruction (pb->pcHead);
+ if (!pc) {
+ // empty function, avoid NULL pointer dereference
+ return;
+ } // if
todo = NULL; blacklist = NULL;
addSetHead (&todo, PCI(pc)->pcflow);