desktop: removed the need for libbsd

this should help the cygwin build that MikeO is working on
This commit is contained in:
Andrew Tridgell 2011-10-11 21:04:07 +11:00
parent e2c6dc68a2
commit e991d81eee
2 changed files with 17 additions and 4 deletions

View File

@ -116,7 +116,7 @@ CFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(COPTS)
ASFLAGS = -g $(DEFINES) $(DEPFLAGS) $(ASOPTS) ASFLAGS = -g $(DEFINES) $(DEPFLAGS) $(ASOPTS)
LDFLAGS = -g $(OPTFLAGS) -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) LDFLAGS = -g $(OPTFLAGS) -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
LIBS = -lm -lbsd LIBS = -lm
SRCSUFFIXES = *.cpp *.c SRCSUFFIXES = *.cpp *.c

View File

@ -2,7 +2,6 @@
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <bsd/string.h>
#include "avr/pgmspace.h" #include "avr/pgmspace.h"
#include <BetterStream.h> #include <BetterStream.h>
#include <sys/time.h> #include <sys/time.h>
@ -43,9 +42,23 @@ void delay(long unsigned msec)
usleep(msec*1000); usleep(msec*1000);
} }
size_t strlcat_P(char *dst, PGM_P src, size_t size) size_t strlcat_P(char *d, PGM_P s, size_t bufsize)
{ {
return strlcat(dst, src, size); size_t len1 = strlen(d);
size_t len2 = strlen(s);
size_t ret = len1 + len2;
if (len1+len2 >= bufsize) {
if (bufsize < (len1+1)) {
return ret;
}
len2 = bufsize - (len1+1);
}
if (len2 > 0) {
memcpy(d+len1, s, len2);
d[len1+len2] = 0;
}
return ret;
} }
size_t strnlen_P(PGM_P str, size_t size) size_t strnlen_P(PGM_P str, size_t size)