Commit 8cbe8692 authored by Alessandro Rubini's avatar Alessandro Rubini

general: use <string.h> and fix prototypes

Even the freestanding lm32 compiler has <string.h> (because gcc builds
newlib by default as a minimal fallback).  Since I want to get rid of
pp_strlen and such stuff, we'd better include <string.h>, win size_t
and use the standard definitions for standard functions.

When we port to systems with no <string.h> we can provide it inside
its own arch- directory. So no harm is done and the code is simplified.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 02e75664
/* /*
* Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later * Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later
*/ */
#include <string.h>
/* /*
* These are the functions provided by the various bare files * These are the functions provided by the various bare files
*/ */
...@@ -14,11 +14,6 @@ extern int bare_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -14,11 +14,6 @@ extern int bare_send_packet(struct pp_instance *ppi, void *pkt, int len,
extern void bare_main_loop(struct pp_instance *ppi); extern void bare_main_loop(struct pp_instance *ppi);
/* basics */
extern void *memset(void *s, int c, int count);
extern char *strcpy(char *dest, const char *src);
extern void *memcpy(void *dest, const void *src, int count);
/* syscalls */ /* syscalls */
struct bare_sockaddr; struct bare_sockaddr;
......
/* /*
* Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later * Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later
*/ */
#include <string.h>
/* /*
* These are the functions provided by the various bare files * These are the functions provided by the various bare files
...@@ -14,11 +15,6 @@ extern int bare_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -14,11 +15,6 @@ extern int bare_send_packet(struct pp_instance *ppi, void *pkt, int len,
extern void bare_main_loop(struct pp_instance *ppi); extern void bare_main_loop(struct pp_instance *ppi);
/* basics */
extern void *memset(void *s, int c, int count);
extern char *strcpy(char *dest, const char *src);
extern void *memcpy(void *dest, const void *src, int count);
/* syscalls */ /* syscalls */
struct bare_sockaddr; struct bare_sockaddr;
......
...@@ -73,11 +73,6 @@ extern int halexp_get_port_state(hexp_port_state_t *state, ...@@ -73,11 +73,6 @@ extern int halexp_get_port_state(hexp_port_state_t *state,
/* End halexp_port_state */ /* End halexp_port_state */
/* basics */
extern void *memset(void *s, int c, int count);
extern char *strcpy(char *dest, const char *src);
extern void *memcpy(void *dest, const void *src, int count);
/* syscall-lookalike */ /* syscall-lookalike */
extern int spec_time(void); extern int spec_time(void);
extern void spec_udelay(int usecs); extern void spec_udelay(int usecs);
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#ifndef __PPSI_LIB_H__ #ifndef __PPSI_LIB_H__
#define __PPSI_LIB_H__ #define __PPSI_LIB_H__
#include <stdint.h> #include <stdint.h>
#include <string.h>
/* We base on puts and a few more functions: each arch must have it */ /* What follow is the old way, being phased out */
extern void pp_puts(const char *s); extern void pp_puts(const char *s);
extern int pp_strnlen(const char *s, int maxlen); extern int pp_strnlen(const char *s, int maxlen);
extern char *pp_strcpy(char *dest, const char *src); extern char *pp_strcpy(char *dest, const char *src);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
#include <ppsi/lib.h> #include <ppsi/lib.h>
int strnlen(const char *s, int maxlen) size_t strnlen(const char *s, size_t maxlen)
{ {
int len = 0; int len = 0;
while (*(s++)) while (*(s++))
...@@ -12,7 +12,7 @@ int strnlen(const char *s, int maxlen) ...@@ -12,7 +12,7 @@ int strnlen(const char *s, int maxlen)
return len; return len;
} }
void *memcpy(void *dest, const void *src, int count) void *memcpy(void *dest, const void *src, size_t count)
{ {
/* from u-boot-1.1.2 */ /* from u-boot-1.1.2 */
char *tmp = (char *) dest, *s = (char *) src; char *tmp = (char *) dest, *s = (char *) src;
...@@ -23,7 +23,7 @@ void *memcpy(void *dest, const void *src, int count) ...@@ -23,7 +23,7 @@ void *memcpy(void *dest, const void *src, int count)
return dest; return dest;
} }
int memcmp(const void *cs, const void *ct, int count) int memcmp(const void *cs, const void *ct, size_t count)
{ {
/* from u-boot-1.1.2 */ /* from u-boot-1.1.2 */
const unsigned char *su1, *su2; const unsigned char *su1, *su2;
...@@ -35,7 +35,7 @@ int memcmp(const void *cs, const void *ct, int count) ...@@ -35,7 +35,7 @@ int memcmp(const void *cs, const void *ct, int count)
return res; return res;
} }
void *memset(void *s, int c, int count) void *memset(void *s, int c, size_t count)
{ {
/* from u-boot-1.1.2 */ /* from u-boot-1.1.2 */
char *xs = (char *) s; char *xs = (char *) s;
......
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