[acc25ee] | 1 | /* lib.c |
---|
| 2 | * |
---|
| 3 | * This file contains the implementation of functions that are unresolved |
---|
| 4 | * in the bootloader. Unfortunately it shall not use any object code |
---|
| 5 | * from newlib or rtems because they are not compiled with the right option!!! |
---|
| 6 | * |
---|
| 7 | * You've been warned!!!. |
---|
[4abbc567] | 8 | */ |
---|
| 9 | |
---|
| 10 | /* |
---|
| 11 | * Copyright (C) 1998, 1999 valette@crf.canon.fr |
---|
[acc25ee] | 12 | * |
---|
| 13 | * The license and distribution terms for this file may be |
---|
[0c875c6a] | 14 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[acc25ee] | 16 | */ |
---|
| 17 | |
---|
[4abbc567] | 18 | |
---|
| 19 | /* |
---|
| 20 | * Provide our own prototypes to avoid warnings and risk getting inlined |
---|
| 21 | * conflicts from the normal header files. |
---|
| 22 | */ |
---|
| 23 | void* memset(void *p, int c, unsigned int n); |
---|
| 24 | void* memcpy(void *dst, const void * src, unsigned int n); |
---|
| 25 | char* strcat(char * dest, const char * src); |
---|
| 26 | int strlen(const char* string); |
---|
| 27 | |
---|
[acc25ee] | 28 | void* memset(void *p, int c, unsigned int n) |
---|
| 29 | { |
---|
| 30 | char *q =p; |
---|
| 31 | for(; n>0; --n) *q++=c; |
---|
| 32 | return p; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | void* memcpy(void *dst, const void * src, unsigned int n) |
---|
| 36 | { |
---|
| 37 | unsigned char *d=dst; |
---|
| 38 | const unsigned char *s=src; |
---|
[6128a4a] | 39 | |
---|
[acc25ee] | 40 | while(n-- > 0) *d++=*s++; |
---|
| 41 | return dst; |
---|
| 42 | } |
---|
[6128a4a] | 43 | |
---|
[acc25ee] | 44 | char* strcat(char * dest, const char * src) |
---|
| 45 | { |
---|
| 46 | char *tmp = dest; |
---|
| 47 | |
---|
| 48 | while (*dest) |
---|
| 49 | dest++; |
---|
| 50 | while ((*dest++ = *src++) != '\0') |
---|
| 51 | ; |
---|
| 52 | return tmp; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | int strlen(const char* string) |
---|
| 56 | { |
---|
| 57 | register int i = 0; |
---|
| 58 | |
---|
| 59 | while (string[i] != '\0') |
---|
| 60 | ++i; |
---|
| 61 | return i; |
---|
| 62 | } |
---|