From: Waldemar Kozaczuk <[email protected]> Committer: Nadav Har'El <[email protected]> Branch: master
libc: revert some files with "#undef" to point back to musl Apparently some of the network and string functions are implemented using macros in glibc and it seems that OSv used to depend on the glibc headers (maybe) and the commit 0ac3dd155ac0a8f4606fcb9abf3c7785da395214 by Avi Kivity modified those files to #undef those functions. It looks like we do not have to do it anymore so this patch simply removes those files from libc/ folder and changes Makefile to point back to the musl equivalent ones. Signed-off-by: Waldemar Kozaczuk <[email protected]> Message-Id: <[email protected]> --- diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# OSv makefile +# O./libc/string/strdup.cSv makefile # # Copyright (C) 2015 Cloudius Systems, Ltd. # This work is open source software, licensed under the terms of the @@ -1344,10 +1344,10 @@ musl += multibyte/wctomb.o $(out)/libc/multibyte/mbsrtowcs.o: CFLAGS += -Imusl/src/multibyte -libc += network/htonl.o -libc += network/htons.o -libc += network/ntohl.o -libc += network/ntohs.o +musl += network/htonl.o +musl += network/htons.o +musl += network/ntohl.o +musl += network/ntohs.o libc += network/gethostbyname_r.o musl += network/gethostbyname2_r.o musl += network/gethostbyaddr_r.o @@ -1576,32 +1576,32 @@ musl += string/strcasecmp.o musl += string/strcasestr.o libc += string/strcat.o libc += string/__strcat_chk.o -libc += string/strchr.o +musl += string/strchr.o libc += string/strchrnul.o -libc += string/strcmp.o +musl += string/strcmp.o libc += string/strcpy.o libc += string/__strcpy_chk.o -libc += string/strcspn.o -libc += string/strdup.o +musl += string/strcspn.o +musl += string/strdup.o libc += string/strerror_r.o libc += string/strlcat.o libc += string/strlcpy.o libc += string/strlen.o musl += string/strncasecmp.o libc += string/strncat.o libc += string/__strncat_chk.o -libc += string/strncmp.o +musl += string/strncmp.o libc += string/strncpy.o libc += string/__strncpy_chk.o libc += string/__strndup.o musl += string/strndup.o musl += string/strnlen.o -libc += string/strpbrk.o +musl += string/strpbrk.o musl += string/strrchr.o -libc += string/strsep.o +musl += string/strsep.o libc += string/stresep.o libc += string/strsignal.o -libc += string/strspn.o +musl += string/strspn.o musl += string/strstr.o libc += string/strtok.o libc += string/strtok_r.o diff --git a/libc/network/htonl.c b/libc/network/htonl.c --- a/libc/network/htonl.c +++ b/libc/network/htonl.c @@ -1,9 +0,0 @@ -#include <netinet/in.h> -#include <byteswap.h> - -#undef htonl -uint32_t htonl(uint32_t n) -{ - union { int i; char c; } u = { 1 }; - return u.c ? bswap_32(n) : n; -} diff --git a/libc/network/htons.c b/libc/network/htons.c --- a/libc/network/htons.c +++ b/libc/network/htons.c @@ -1,9 +0,0 @@ -#include <netinet/in.h> -#include <byteswap.h> - -#undef htons -uint16_t htons(uint16_t n) -{ - union { int i; char c; } u = { 1 }; - return u.c ? bswap_16(n) : n; -} diff --git a/libc/network/ntohl.c b/libc/network/ntohl.c --- a/libc/network/ntohl.c +++ b/libc/network/ntohl.c @@ -1,9 +0,0 @@ -#include <netinet/in.h> -#include <byteswap.h> - -#undef ntohl -uint32_t ntohl(uint32_t n) -{ - union { int i; char c; } u = { 1 }; - return u.c ? bswap_32(n) : n; -} diff --git a/libc/network/ntohs.c b/libc/network/ntohs.c --- a/libc/network/ntohs.c +++ b/libc/network/ntohs.c @@ -1,9 +0,0 @@ -#include <netinet/in.h> -#include <byteswap.h> - -#undef ntohs -uint16_t ntohs(uint16_t n) -{ - union { int i; char c; } u = { 1 }; - return u.c ? bswap_16(n) : n; -} diff --git a/libc/string/strchr.c b/libc/string/strchr.c --- a/libc/string/strchr.c +++ b/libc/string/strchr.c @@ -1,10 +0,0 @@ -#include <string.h> - -char *__strchrnul(const char *, int); - -#undef strchr -char *strchr(const char *s, int c) -{ - char *r = __strchrnul(s, c); - return *(unsigned char *)r == (unsigned char)c ? r : 0; -} diff --git a/libc/string/strcmp.c b/libc/string/strcmp.c --- a/libc/string/strcmp.c +++ b/libc/string/strcmp.c @@ -1,8 +0,0 @@ -#include <string.h> - -#undef strcmp -int strcmp(const char *l, const char *r) -{ - for (; *l==*r && *l && *r; l++, r++); - return *(unsigned char *)l - *(unsigned char *)r; -} diff --git a/libc/string/strcspn.c b/libc/string/strcspn.c --- a/libc/string/strcspn.c +++ b/libc/string/strcspn.c @@ -1,20 +0,0 @@ -#include <string.h> - -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) - -char *__strchrnul(const char *, int); - -#undef strcspn -size_t strcspn(const char *s, const char *c) -{ - const char *a = s; - size_t byteset[32/sizeof(size_t)]; - - if (!c[0] || !c[1]) return __strchrnul(s, *c)-a; - - memset(byteset, 0, sizeof byteset); - for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++); - for (; *s && !BITOP(byteset, *(unsigned char *)s, &); s++); - return s-a; -} diff --git a/libc/string/strdup.c b/libc/string/strdup.c --- a/libc/string/strdup.c +++ b/libc/string/strdup.c @@ -1,14 +0,0 @@ -#include <stdlib.h> -#include <string.h> -#include "libc.h" - -#undef __strdup -char *__strdup(const char *s) -{ - size_t l = strlen(s); - char *d = malloc(l+1); - if (!d) return NULL; - return memcpy(d, s, l+1); -} - -weak_alias(__strdup, strdup); diff --git a/libc/string/strncmp.c b/libc/string/strncmp.c --- a/libc/string/strncmp.c +++ b/libc/string/strncmp.c @@ -1,10 +0,0 @@ -#include <string.h> - -#undef strncmp -int strncmp(const char *_l, const char *_r, size_t n) -{ - const unsigned char *l=(void *)_l, *r=(void *)_r; - if (!n--) return 0; - for (; *l && *r && n && *l == *r ; l++, r++, n--); - return *l - *r; -} diff --git a/libc/string/strpbrk.c b/libc/string/strpbrk.c --- a/libc/string/strpbrk.c +++ b/libc/string/strpbrk.c @@ -1,8 +0,0 @@ -#include <string.h> - -#undef strpbrk -char *strpbrk(const char *s, const char *b) -{ - s += strcspn(s, b); - return *s ? (char *)s : 0; -} diff --git a/libc/string/strsep.c b/libc/string/strsep.c --- a/libc/string/strsep.c +++ b/libc/string/strsep.c @@ -1,14 +0,0 @@ -#define _GNU_SOURCE -#include <string.h> - -#undef strsep -char *strsep(char **str, const char *sep) -{ - char *s = *str, *end; - if (!s) return NULL; - end = s + strcspn(s, sep); - if (*end) *end++ = 0; - else end = 0; - *str = end; - return s; -} diff --git a/libc/string/strspn.c b/libc/string/strspn.c --- a/libc/string/strspn.c +++ b/libc/string/strspn.c @@ -1,21 +0,0 @@ -#include <string.h> - -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) - -#undef strspn -size_t strspn(const char *s, const char *c) -{ - const char *a = s; - size_t byteset[32/sizeof(size_t)] = { 0 }; - - if (!c[0]) return 0; - if (!c[1]) { - for (; *s == *c; s++); - return s-a; - } - - for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++); - for (; *s && BITOP(byteset, *(unsigned char *)s, &); s++); - return s-a; -} -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000ffe57805ab9082f4%40google.com.
