+2003-02-02 Bernhard Held <bernhard@bernhardheld.de>
+
+ * device/include/malloc.h: introduced NULL
+ * device/include/string.h: introduced NULL
+ * device/include/stdlib.h: introduced NULL
+ * device/lib/_memcpy.c: removed NULL
+ * device/lib/_strcat.c: removed NULL
+ * device/lib/_strchr.c: removed NULL
+ * device/lib/_strcmp.c: removed NULL
+ * device/lib/_strcpy.c: removed NULL
+ * device/lib/_strcspn.c: removed NULL
+ * device/lib/_strlen.c: removed NULL
+ * device/lib/_strncat.c: removed NULL
+ * device/lib/_strncmp.c: removed NULL
+ * device/lib/_strncpy.c: removed NULL
+ * device/lib/_strpbrk.c: removed NULL
+ * device/lib/_strrchr.c: removed NULL
+ * device/lib/_strspn.c: removed NULL
+ * device/lib/_strstr.c: removed NULL
+ * device/lib/_strtok.c: removed NULL
+ * device/lib/malloc.c: removed NULL, include own header
+ * device/lib/_strspn.c: removed NULL
+ * device/lib/_strspn.c: removed NULL
+ * device/lib/_strspn.c: removed NULL
+
+
2003-02-02 <johan@balder>
* src/mcs51/ralloc.c (packForPush): fixed bug #631653, maybe other ports need this too? At least now some new alerts in SDCCBBlock.c and SDCCicode.c gives an early warning
2003-01-28 Bernhard Held <bernhard@bernhardheld.de>
* src/ds390/gen.c: fix deps by replacing <common.h> with "common.h"
- * src/SDCC.lex: rename P_OVERLAY to P_OVERLAY_ for cross-gcc 3.2 MINGW32
+ * src/SDCC.lex: rename P_OVERLAY to P_OVERLAY_ for cross-gcc 3.2 MINGW32
2003-01-27 <johan@balder>
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
-
+
This program 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
/* malloc.h */
#ifndef __SDCC51_MALLOC_H
#define __SDCC51_MALLOC_H
#include <sdcc-lib.h>
+#ifndef NULL
+# define NULL (void *)0
+#endif
+
#if _SDCC_MALLOC_TYPE_MLH
void *malloc (unsigned int);
void free(void *p);
extern void init_dynamic_memory(MEMHEADER xdata * , unsigned int ) reentrant;
extern void xdata * malloc (unsigned int ) reentrant;
-extern void free (void * xdata p) reentrant;
+extern void free (void xdata * p) reentrant;
#else
/*-------------------------------------------------------------------------
stdlib.h - ANSI functions forward declarations
-
+
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
-
+
This program 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#ifndef __SDC51_STDLIB_H
#define __SDC51_STDLIB_H 1
+#ifndef
+# define NULL (void *)0
+#endif
+
extern int atoi (char *);
extern long atol (char *);
extern void _ultoa(unsigned long, char*, unsigned char);
extern void _ltoa(unsigned long, char*, unsigned char);
#endif
-
-
-
-
-
-
#define reentrant
#endif
+#ifndef NULL
+# define NULL (void *)0
+#endif
+
#define memmove memcpy
#ifdef SDCC_STACK_AUTO
#if !_SDCC_PORT_PROVIDES_MEMCPY
-#define NULL (void *)0
-
void * memcpy (
void * dst,
void * src,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
+
char * strcat (
char * dst,
char * src
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
char * strchr (
char * string,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
+#include "string.h"
#include <sdcc-lib.h>
#if !_SDCC_PORT_PROVIDES_STRCMP
-#define NULL (void *)0
-
int strcmp (
char * asrc,
char * adst
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
+#include "string.h"
#include <sdcc-lib.h>
#if !_SDCC_PORT_PROVIDES_STRCPY
-#define NULL (void *)0
-
char * strcpy (
char * d,
char * s)
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
int strcspn (
char * string ,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
int strlen ( char * str )
{
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
char * strncat (
char * front,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
int strncmp (
char * first,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
char *strncpy (
char * d,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#include <string.h>
-#define NULL (void *)0
char * strpbrk (
char * string ,
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
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 Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
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!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-#include "string.h"
-#define NULL (void *)0
+#include "string.h"
char * strrchr (
char * string,
what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#include "string.h"
-#define NULL (void *)0
int strspn (
char * string,
what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#include "string.h"
-#define NULL (void *)0
char * strstr (
char * str1,
what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#include "string.h"
-#define NULL (void *)0
#if defined(SDCC_MODEL_LARGE) || defined (SDCC_MODEL_FLAT24)
#pragma NOINDUCTION
#include <sdcc-lib.h>
+#include <malloc.h>
#if _SDCC_MALLOC_TYPE_MLH
-#include <malloc.h>
typedef struct _MEMHEADER MEMHEADER;
};
#define HEADER_SIZE (sizeof(MEMHEADER)-sizeof(char))
-#define NULL 0
/* These veriables are defined through the crt0 functions. */
/* Base of this variable is the first byte of the heap. */
/* Address of this variable is the last byte of the heap. */
extern char _sdcc_heap_end;
-void
+void
_sdcc_heap_init(void)
{
MEMHEADER *pbase = &_sdcc_heap_start;
}
}
-void
+void
free (void *p)
{
MEMHEADER *prev_header, *pthis;
{
prev_header = pthis->prev;
prev_header->next = pthis->next;
- if (pthis->next)
+ if (pthis->next)
{
pthis->next->prev = prev_header;
}
}
- else
+ else
{
pthis->len = 0; //For the first header
}
};
#define HEADER_SIZE (sizeof(MEMHEADER)-1)
- #define NULL (void xdata * ) 0
-
//Static here means: can be accessed from this module only
static MEMHEADER xdata * FIRST_MEMORY_HEADER_PTR;
FIRST_MEMORY_HEADER_PTR = array;
//Reserve a mem for last header
array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
- array->next->next = NULL; //And mark it as last
- array->prev = NULL; //and mark first as first
+ array->next->next = (void xdata * ) NULL; //And mark it as last
+ array->prev = (void xdata * ) NULL; //and mark first as first
array->len = 0; //Empty and ready.
}
register MEMHEADER xdata * current_header;
register MEMHEADER xdata * new_header;
- if (size>(0xFFFF-HEADER_SIZE)) return NULL; //To prevent overflow in next line
+ if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
size += HEADER_SIZE; //We need a memory for header too
current_header = FIRST_MEMORY_HEADER_PTR;
while (1)
((unsigned int)current_header) -
current_header->len) >= size) break; //if spare is more than need
current_header = current_header->next; //else try next
- if (!current_header->next) return NULL; //if end_of_list reached
+ if (!current_header->next) return (void xdata *) NULL; //if end_of_list reached
}
if (!current_header->len)
{ //This code works only for first_header in the list and only
return ((xdata *)&(new_header->mem));
}
- void free (MEMHEADER xdata * p)
+ void free (void xdata * p)
{
register MEMHEADER xdata * prev_header;
if ( p ) //For allocated pointers only!
{
p = (MEMHEADER xdata * )((char xdata *) p - HEADER_SIZE); //to start of header
- if ( p->prev ) // For the regular header
+ if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
{
- prev_header = p->prev;
- prev_header->next = p->next;
- if (p->next) p->next->prev = prev_header;
+ prev_header = ((MEMHEADER xdata * ) p)->prev;
+ prev_header->next = ((MEMHEADER xdata * ) p)->next;
+ if (((MEMHEADER xdata * ) p)->next)
+ ((MEMHEADER xdata * ) p)->next->prev = prev_header;
}
- else p->len = 0; //For the first header
+ else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
}
}
//END OF MODULE
-
#endif