Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:54

0001 /* lib.c
0002  *
0003  *  This file contains the implementation of functions that are unresolved
0004  *  in the bootloader.  Unfortunately it  shall not use any object code
0005  *  from newlib or rtems  because they are not compiled with the right option!!!
0006  *
0007  *  You've been warned!!!.
0008  */
0009 
0010 /*
0011  *  Copyright (C) 1998, 1999 valette@crf.canon.fr
0012  *
0013  *  The license and distribution terms for this file may be
0014  *  found in the file LICENSE in this distribution or at
0015  *  http://www.rtems.org/license/LICENSE.
0016  */
0017 
0018 
0019 /*
0020  * Provide our own prototypes to avoid warnings and risk getting inlined
0021  * conflicts from the normal header files.
0022  */
0023 void* memset(void *p, int c, unsigned int n);
0024 void* memcpy(void *dst, const void * src, unsigned int n);
0025 char* strcat(char * dest, const char * src);
0026 int strlen(const char* string);
0027 
0028 void* memset(void *p, int c, unsigned int n)
0029 {
0030   char *q =p;
0031   for(; n>0; --n) *q++=c;
0032   return p;
0033 }
0034 
0035 void* memcpy(void *dst, const void * src, unsigned int n)
0036 {
0037   unsigned char *d=dst;
0038   const unsigned char *s=src;
0039 
0040   while(n-- > 0) *d++=*s++;
0041   return dst;
0042 }
0043 
0044 char* strcat(char * dest, const char * src)
0045 {
0046   char *tmp = dest;
0047 
0048   while (*dest)
0049     dest++;
0050   while ((*dest++ = *src++) != '\0')
0051     ;
0052   return tmp;
0053 }
0054 
0055 int strlen(const char* string)
0056 {
0057   register int i = 0;
0058 
0059   while (string[i] != '\0')
0060     ++i;
0061   return i;
0062 }