From 06460dd1ef27e4e851dbd24d76677e04a670a9d0 Mon Sep 17 00:00:00 2001 From: vrokas Date: Fri, 5 Nov 2004 08:35:55 +0000 Subject: [PATCH] * initial revision, PIC16 C Library headers git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3567 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/include/pic16/errno.h | 37 +++++++++++++++++++ device/include/pic16/malloc.h | 58 ++++++++++++++++++++++++++++++ device/include/pic16/string.h | 67 +++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 device/include/pic16/errno.h create mode 100644 device/include/pic16/malloc.h create mode 100644 device/include/pic16/string.h diff --git a/device/include/pic16/errno.h b/device/include/pic16/errno.h new file mode 100644 index 00000000..c8aa5e17 --- /dev/null +++ b/device/include/pic16/errno.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + errno.h: Error codes used in the math functions + + Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + Copyright (C) 2001 Jesus Calvino-Fraga, jesusc@ieee.org + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------*/ + +/* +** $Id$ +*/ + +#ifndef _PIC16_ERRNO_H +#define _PIC16_ERRNO_H + +extern int errno; + +/* Error Codes: */ + +#define EDOM 33 /* Math argument out of domain of functions */ +#define ERANGE 34 /* Math result not representable */ + +#endif /* _PIC16_ERRNO_H */ diff --git a/device/include/pic16/malloc.h b/device/include/pic16/malloc.h new file mode 100644 index 00000000..85941608 --- /dev/null +++ b/device/include/pic16/malloc.h @@ -0,0 +1,58 @@ +/* + * malloc.h - dynamic memory allocation header + * + * written by Vangelis Rokas, 2004 (vrokas@otenet.gr) + * + */ + +/* +** $Id$ +*/ + +/* + * Structure of memory block header: + * bit 7 (MSB): allocated flag + * bits 0-6: pointer to next block (max length: 126) + * + */ + + +#ifndef __MALLOC_H__ +#define __MALLOC_H__ + +#define EMULATION 0 + +#if EMULATION +#define malloc pic16_malloc +#define free pic16_free +#define realloc pic16_realloc +#define calloc pic16_calloc +#endif + + +#define MAX_BLOCK_SIZE 0x7f /* 126 bytes */ +#define MAX_HEAP_SIZE 0x200 /* 512 bytes */ +#define _MAX_HEAP_SIZE (MAX_HEAP_SIZE-1) + +#define ALLOC_FLAG 0x80 +#define HEADER_SIZE 1 + + +typedef union { + unsigned char datum; + struct { + unsigned count: 7; + unsigned alloc: 1; + } bits; +} _malloc_rec; + + +unsigned char *malloc(unsigned char); +void free(unsigned char *); +unsigned char *calloc(unsigned char num); //, unsigned char len); +unsigned char *realloc(unsigned char *mblock, unsigned char len); + + +#endif /* __MALLOC_H__ */ + + diff --git a/device/include/pic16/string.h b/device/include/pic16/string.h new file mode 100644 index 00000000..5f9189cc --- /dev/null +++ b/device/include/pic16/string.h @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------- + string.h - ANSI functions forward declarations + + Modified for 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 + 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! +-------------------------------------------------------------------------*/ +/* +** $Id$ +*/ + +#ifndef __STRING_H /* { */ +#define __STRING_H 1 + +#ifndef NULL +# define NULL (void *)0 +#endif + +#ifndef _SIZE_T_DEFINED +# define _SIZE_T_DEFINED + typedef unsigned int size_t; +#endif + +extern char *strcat (char *, char *); +extern char *strchr (char *, char); +extern int strcmp (char *, char *); +extern char *strcpy (char *, char *); +extern int strcspn(char *, char *); +extern int strlen (char *); +extern char *strlwr (char *); +extern char *strncat(char *, char *, size_t ); +extern int strncmp(char *, char *, size_t ); +extern char *strncpy(char *, char *, size_t ); +extern char *strpbrk(char *, char *); +extern char *strrchr(char *, char); +extern int strspn (char *, char *); +extern char *strstr (char *, char *); +extern char *strtok (char *, char *); +extern char *strupr (char *); + +extern void *memccpy(void *, void *, int, size_t); +extern void *memchr(void *, char, size_t); +extern int memcmp (void *, void *, size_t); +extern void *memcpy (void *, void *, size_t); +extern void *memmove (void *, void *, size_t); +extern void *memrchr(void *, char, size_t); +extern void *memset (void *, unsigned char, size_t ); + +#endif /* } */ -- 2.39.5