dde_bsd: pull strlcpy in via contrib code

For historical reason the 'strlcpy' implemention was directly pull in
into the emulation environment. There is, however, no reason not to
use the contrib sources in the usual fashion.

Issue #3929.
This commit is contained in:
Josef Söntgen 2020-06-19 15:30:33 +02:00 committed by Christian Helmuth
parent 7193902cc0
commit bdb71d94c2
6 changed files with 14 additions and 44 deletions

View File

@ -1,3 +1,4 @@
sys/lib/libkern/strlcpy.c
sys/dev/audio.c
sys/dev/audio_if.h
sys/dev/pci/auich.c

View File

@ -25,6 +25,9 @@ CC_OPT += -fno-builtin-printf -fno-builtin-snprintf -fno-builtin-vsnprintf \
CC_OPT += -D_KERNEL
# libkern
SRC_C += lib/libkern/strlcpy.c
# disable false warning in audio.c:786
CC_C_OPT += -Wno-maybe-uninitialized

View File

@ -9,7 +9,7 @@ ifeq ($(called_from_lib_mk),yes)
BSD_CONTRIB_DIR := $(call select_from_ports,dde_bsd)/src/lib/audio
BSD_EMUL_H := $(REP_DIR)/src/lib/audio/include/bsd_emul.h
SCAN_DIRS := $(addprefix $(BSD_CONTRIB_DIR)/, dev sys)
SCAN_DIRS := $(addprefix $(BSD_CONTRIB_DIR)/, dev lib sys)
GEN_INCLUDES := $(shell grep -rIh "^\#include .*" $(SCAN_DIRS) |\
sed "s/^\#include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" | sort | uniq)

View File

@ -1 +1 @@
680424ed9e93503999ebf7e3878ba511cbcb8941
210145e50db8518aeb9d1cbdf1da82f6a9255113

View File

@ -715,6 +715,14 @@ struct timeval
void microuptime(struct timeval *);
/***************************
** lib/libkern/libkern.h **
***************************/
size_t strlcpy(char *, char const *, size_t);
#include <extern_c_end.h>
#endif /* _BSD_EMUL_H_ */

View File

@ -452,45 +452,3 @@ extern "C" int strcmp(const char *s1, const char *s2)
{
return Genode::strcmp(s1, s2);
}
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
extern "C" size_t strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
}