Commit 1ccf1d9e authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Aurelio Colosimo

bare-linux/bare-io.c: added missing lib functions

Maybe we should consider some generic lib, as most of this can be
shared across freestanding archs (we must check whether other
freestanding places are really so lib-less os they have these minimal
functions for example from newlib)
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent e5d7101f
/*
* Alessandro Rubini for CERN, 2011 -- public domain
* Alessandro Rubini for CERN, 2011 -- GPL 2 or later (it includes u-boot code)
*/
#include <pptp/pptp.h>
#include "bare-linux.h"
......@@ -33,18 +33,19 @@ void pp_get_stamp(uint32_t *sptr)
*sptr = htonl(sys_time(0));
}
/* What follows has no prefix because it's only used by arch code */
char *strcpy(char *dest, const char *src)
int pp_memcmp(const void *cs, const void *ct, int count)
{
/* from u-boot-1.1.2 */
char *tmp = dest;
const unsigned char *su1, *su2;
int res = 0;
while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
if ((res = *su1 - *su2) != 0)
break;
return res;
}
void *memset(void *s, int c, int count)
void *pp_memset(void *s, int c, int count)
{
/* from u-boot-1.1.2 */
char *xs = (char *) s;
......@@ -55,13 +56,19 @@ void *memset(void *s, int c, int count)
return s;
}
void *memcpy(void *dest, const void *src, int count)
/* What follows has no prefix because it's only used by arch code */
char *strcpy(char *dest, const char *src)
{
/* from u-boot-1.1.2 */
char *tmp = (char *) dest, *s = (char *) src;
while (count--)
*tmp++ = *s++;
char *tmp = dest;
return dest;
while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}
void *memset(void *s, int c, int count)
__attribute__((alias("pp_memset")));
void *memcpy(void *dest, const void *src, int count)
__attribute__((alias("pp_memcpy")));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment