+2003-09-07 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+ * device/include/string.h: added size_t typedef, changed
+ prototypes to use size_t, eliminated separate reentrant and
+ non-reentrant declarations, added _memmove declaration
+ * device/lib/_memcpy.c: changed to use size_t instead of int,
+ changed /4 to >>2 to avoid division library call
+ * device/lib/_memcmp.c,
+ * device/lib/_memset.c,
+ * device/lib/_strncat.c,
+ * device/lib/_strncpy.c,
+ * device/lib/_strncmp.c: changed to use size_t instead of int
+ * device/lib/_memmove.c: new file (fixed bug #772294)
+ * device/lib/Makefile.in: added _memmove.c
+ * device/lib/z80/asm_strings.s: fixed bug #772290
+ * support/regression/tests/bitfields.c: attempt to fix host assertion
+ failure on amd64-unknown-linux2.2
+
2003-09-06 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
* src/z80/gen.c (aopPut, spillPairReg): fixed bug #800998
* src/z80/gen.c (genFunction, genEndFunction): fixed "bug" #774700
* as/z80/asmain.c (main): fixed bug #801766
compilers
2003-09-05 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
* src/SDCCast.c (isConformingBody): fixed loop reversal bug
reported in bug #800609
2003-09-04 Vangelis Rokas <vrokas@otenet.gr>
+
* Top header beautifications in src/pic16 directory:
device.c, device.h, gen.c, gen.h, genarith.c, glue.c, pcode.c,
pcodeflow.c, pcodeflow.h, pcode.h, pcodepeep.c, pcoderegs.c,
aren't part of the nRegs tally.
2003-08-31 Vangelis Rokas <vrokas@otenet.gr>
+
* src/pic16/main.c: corrected offsets of interrupt vectors in _pic16_genIVT()
* src/pic16/pcode.c: fix to disable inserting BANKSEL directive
before instructions that use the _STATUS register
#ifndef __SDC51_STRING_H
#define __SDC51_STRING_H 1
-#if !defined(SDCC_mcs51) && !defined(SDCC_ds390)
-#define reentrant
-#endif
-
#ifndef NULL
# define NULL (void *)0
#endif
-#define memmove memcpy
-
-#ifdef SDCC_STACK_AUTO
-
-extern char *strcpy (char *, char *) reentrant ;
-extern char *strncpy(char *, char *,int ) reentrant ;
-extern char *strcat (char *, char *) reentrant ;
-extern char *strncat(char *, char *,int ) reentrant ;
-extern int strcmp (char *, char *) reentrant ;
-extern int strncmp(char *, char *,int ) reentrant ;
-extern char *strchr (char *, char ) reentrant ;
-extern char *strrchr(char *, char ) reentrant ;
-extern int strspn (char *, char *) reentrant ;
-extern int strcspn(char *, char *) reentrant ;
-extern char *strpbrk(char *, char *) reentrant ;
-extern char *strstr (char *, char *) reentrant ;
-extern int strlen (char * ) reentrant ;
-extern char *strtok (char *, char *) reentrant ;
-extern void *memcpy (void *, void *, int ) reentrant ;
-extern int memcmp (void *, void *, int ) reentrant ;
-extern void *memset (void *, unsigned char , int ) reentrant ;
-
-#else
+#ifndef _SIZE_T_DEFINED
+# define _SIZE_T_DEFINED
+ typedef unsigned int size_t;
+#endif
extern char *strcpy (char *, char *) ;
-extern char *strncpy(char *, char *,int ) ;
+extern char *strncpy(char *, char *, size_t ) ;
extern char *strcat (char *, char *) ;
-extern char *strncat(char *, char *,int ) ;
+extern char *strncat(char *, char *, size_t ) ;
extern int strcmp (char *, char *) ;
-extern int strncmp(char *, char *,int ) ;
+extern int strncmp(char *, char *, size_t ) ;
extern char *strchr (char *, char ) ;
extern char *strrchr(char *, char ) ;
extern int strspn (char *, char *) ;
extern char *strstr (char *, char *) ;
extern int strlen (char * ) ;
extern char *strtok (char *, char *) ;
-extern void *memcpy (void *, void *, int ) ;
-extern int memcmp (void *, void *, int ) ;
-extern void *memset (void *, unsigned char , int ) ;
+extern void *memcpy (void *, void *, size_t ) ;
+extern int memcmp (void *, void *, size_t ) ;
+extern void *memset (void *, unsigned char , size_t ) ;
+extern void *memmove (void *, void *, size_t ) ;
#if SDCC_ds390
extern void xdata * memcpyx(void xdata *, void xdata *, int) _naked;
#endif
-#endif
#endif
_islower.c _isprint.c _ispunct.c _isspace.c \
_isupper.c _isxdigit.c _itoa.c _ltoa.c \
_slong2fs.c _memcmp.c \
- _memcpy.c _memset.c _modsint.c _modslong.c \
+ _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
_moduint.c _modulong.c _mulint.c _mullong.c \
_ser.c _setjmp.c \
_spx.c _startup.c _strchr.c _strcmp.c _strcpy.c \
_iscntrl.c _isdigit.c _isgraph.c \
_islower.c _isprint.c _ispunct.c _isspace.c \
_isupper.c _isxdigit.c _memcmp.c \
- _memcpy.c _memset.c \
+ _memcpy.c _memmove.c _memset.c \
_startup.c _strchr.c _strcmp.c _strcpy.c \
_strcspn.c _strlen.c _strncat.c _strncmp.c \
_strncpy.c _strpbrk.c _strrchr.c _strspn.c \
_sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
_islower.c _isprint.c _ispunct.c _isspace.c \
_isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
- _memcpy.c _memset.c _modsint.c _modslong.c \
+ _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
_moduint.c _modulong.c _mulint.c _mullong.c \
_strchr.c _strcmp.c _strcpy.c \
_strcspn.c _strlen.c _strncat.c _strncmp.c \
int memcmp (
void * buf1,
void * buf2,
- int count
+ size_t count
)
{
if (!count)
void * memcpy (
void * dst,
void * src,
- int acount
+ size_t acount
)
{
#if _SDCC_Z80_STYLE_LIB_OPT
char * d = dst;
char * s = src;
/* PENDING: Divide first to get around sign problems */
- int count = -(acount/4);
+ int count = -(acount >> 2);
while (count) {
*d++ = *s++;
--- /dev/null
+/*-------------------------------------------------------------------------
+ _memmove.c - part of string library functions
+
+ Adapted By - Erik Petrich . epetrich@users.sourceforge.net
+ from _memcpy.c which was originally
+ Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
+
+ 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
+ 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!
+-------------------------------------------------------------------------*/
+#include "string.h"
+#include <sdcc-lib.h>
+
+#ifndef _SDCC_PORT_PROVIDES_MEMMOVE
+#define _SDCC_PORT_PROVIDES_MEMMOVE 0
+#endif
+
+#if !_SDCC_PORT_PROVIDES_MEMMOVE
+
+void * memmove (
+ void * dst,
+ void * src,
+ size_t acount
+ )
+{
+#if _SDCC_Z80_STYLE_LIB_OPT
+
+#pragma NOINDUCTION
+
+ char * d;
+ char * s;
+ /* PENDING: Divide first to get around sign problems */
+ int count = -(acount >> 2);
+
+ if (((int)src < (int)dst) && ((((int)src)+acount) > (int)dst)) {
+ /*
+ * copy from higher addresses to lower addresses
+ */
+ d = ((char *)dst)+acount-1;
+ s = ((char *)src)+acount-1;
+ while (count) {
+ *d-- = *s--;
+ *d-- = *s--;
+ *d-- = *s--;
+ *d-- = *s--;
+ count++;
+ }
+
+ if (acount & 2) {
+ *d-- = *s--;
+ *d-- = *s--;
+ }
+ if (acount & 1) {
+ *d-- = *s--;
+ }
+ }
+ else {
+ /*
+ * copy from lower addresses to higher addresses
+ */
+ d = dst;
+ s = src;
+ while (count) {
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ *d++ = *s++;
+ count++;
+ }
+
+ if (acount & 2) {
+ *d++ = *s++;
+ *d++ = *s++;
+ }
+ if (acount & 1) {
+ *d++ = *s++;
+ }
+ }
+ return dst;
+#else
+ void * ret = dst;
+ char * d;
+ char * s;
+
+ if (((int)src < (int)dst) && ((((int)src)+acount) > (int)dst)) {
+ /*
+ * copy from higher addresses to lower addresses
+ */
+ d = ((char *)dst)+acount-1;
+ s = ((char *)src)+acount-1;
+ while (acount--) {
+ *d-- = *s--;
+ }
+ }
+ else {
+ /*
+ * copy from lower addresses to higher addresses
+ */
+ d = dst;
+ s = src;
+ while (acount--) {
+ *d++ = *s++;
+ }
+ }
+
+ return(ret);
+#endif
+}
+#endif
void * memset (
void * buf,
unsigned char ch ,
- int count)
+ size_t count)
{
register unsigned char * ret = buf;
char * strncat (
char * front,
char * back,
- int count
+ size_t count
)
{
char *start = front;
int strncmp (
char * first,
char * last,
- int count
+ size_t count
)
{
if (!count)
char *strncpy (
char * d,
char * s,
- int n )
+ size_t n )
{
register char * d1 = d;
;; LDIR: do; *DE = *HL; HL++; BC--; while BC != 0
;; All registers are already saved.
- ld hl,#2
- add hl,sp
- ld e,(hl)
- inc hl
- ld d,(hl)
- inc hl
- ld a,(hl)
- inc hl
- ld b,(hl)
- inc hl
- ld c,(hl)
- inc hl
- ld h,(hl)
- ld l,a
- ld a,h
- ld h,b
- ld b,a
-
- ;; Pending: could optimise this check to occur earlier.
- or c
- ret z
-
- ldir
+ pop iy ; iy = return address
+ pop de ; de = destination pointer
+ pop hl ; hl = source pointer
+ pop bc ; bc = count
+ push bc
+ push hl
+ push de
+ ld a,b
+ or c
+ jr z,1$
+ ldir
+1$:
+ pop hl ; return hl = original destination pointer
+ push hl
+ jp (iy)
ret
; int strcmp(const char *s1, const char *s2)
ASSERT( sizeof(size2c_bf) >= 2);
ASSERT( sizeof(size2d_bf) >= 2);
ASSERT( sizeof(size3a_bf) >= 2);
- ASSERT( sizeof(size1a_bf) == sizeof(size1b_bf));
+ ASSERT( sizeof(size1a_bf) <= sizeof(size1b_bf));
ASSERT( sizeof(size1a_bf) < sizeof(size2a_bf));
/* Some SDCC specific assertions. SDCC uses 8 bit storage units.