From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

libc: point 3 more files from libc/ to musl/

This patch adds 2 aliases using aliases.ld so that we
can point 3 files from libc/ to musl/. One of the files
simply has not changed significantly on musl side so
we point it to musl/ version.

The diff between libc/ and musl/src/ versions:

```
DIFF: [/multibyte/mbrlen.c]
12c12
< #include "internal.h"
Message-Id: <20200811014427.12180-1-jwkozac...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1327,7 +1327,7 @@ musl += signal/siginterrupt.o
 musl += multibyte/btowc.o
 musl += multibyte/internal.o
 musl += multibyte/mblen.o
-libc += multibyte/mbrlen.o
+musl += multibyte/mbrlen.o
 musl += multibyte/mbrtowc.o
 musl += multibyte/mbsinit.o
 musl += multibyte/mbsnrtowcs.o
@@ -1583,7 +1583,7 @@ libc += string/__strcpy_chk.o
 musl += string/strcspn.o
 musl += string/strdup.o
 libc += string/strerror_r.o
-libc += string/strlcat.o
+musl += string/strlcat.o
 musl += string/strlcpy.o
 musl += string/strlen.o
 musl += string/strncasecmp.o
@@ -1603,7 +1603,7 @@ libc += string/strsignal.o
 musl += string/strspn.o
 musl += string/strstr.o
 musl += string/strtok.o
-libc += string/strtok_r.o
+musl += string/strtok_r.o
 musl += string/strverscmp.o
 musl += string/swab.o
 musl += string/wcpcpy.o
diff --git a/libc/aliases.ld b/libc/aliases.ld
--- a/libc/aliases.ld
+++ b/libc/aliases.ld
@@ -23,3 +23,9 @@ __pow_finite = pow;
 __finite = finite;
 __finitef = finitef;
 __finitel = finitel;
+
+/* multibyte */
+__mbrlen = mbrlen;
+
+/* string */
+__strtok_r = strtok_r;
diff --git a/libc/multibyte/mbrlen.c b/libc/multibyte/mbrlen.c
--- a/libc/multibyte/mbrlen.c
+++ b/libc/multibyte/mbrlen.c
@@ -1,20 +0,0 @@
-/* 
- * This code was written by Rich Felker in 2010; no copyright is claimed.
- * This code is in the public domain. Attribution is appreciated but
- * unnecessary.
- */
-
-#include <stdlib.h>
-#include <inttypes.h>
-#include <wchar.h>
-#include <errno.h>
-
-//#include "internal.h"
-
-size_t mbrlen(const char *restrict s, size_t n, mbstate_t *restrict st)
-{
-       static unsigned internal;
-       return mbrtowc(0, s, n, st ? st : (mbstate_t *)&internal);
-}
-
-size_t __mbrlen (const char *, size_t, mbstate_t *) __attribute__ ((weak, 
alias ("mbrlen")));
diff --git a/libc/string/strlcat.c b/libc/string/strlcat.c
--- a/libc/string/strlcat.c
+++ b/libc/string/strlcat.c
@@ -1,11 +0,0 @@
-#define _BSD_SOURCE
-#include <string.h>
-
-size_t strlcpy(char *d, const char *s, size_t n);
-
-size_t strlcat(char *d, const char *s, size_t n)
-{
-       size_t l = strnlen(d, n);
-       if (l == n) return l + strlen(s);
-       return l + strlcpy(d+l, s, n-l);
-}
diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c
--- a/libc/string/strtok_r.c
+++ b/libc/string/strtok_r.c
@@ -1,16 +0,0 @@
-#include <string.h>
-#include <libc.h>
-
-#undef strtok_r
-char *strtok_r(char *__restrict s, const char *__restrict sep, char 
**__restrict p)
-{
-       if (!s && !(s = *p)) return NULL;
-       s += strspn(s, sep);
-       if (!*s) return *p = 0;
-       *p = s + strcspn(s, sep);
-       if (**p) *(*p)++ = 0;
-       else *p = 0;
-       return s;
-}
-
-weak_alias(strtok_r, __strtok_r);

-- 
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 osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/0000000000000e465905ac947672%40google.com.

Reply via email to