[PATCH 1/9] libc: replace iswctype_l and wctype_l.c with musl equivalent

53 views
Skip to first unread message

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:26 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 4 ++--
libc/locale/iswctype_l.c | 11 -----------
libc/locale/wctype_l.c | 10 ----------
3 files changed, 2 insertions(+), 23 deletions(-)
delete mode 100644 libc/locale/iswctype_l.c
delete mode 100644 libc/locale/wctype_l.c

diff --git a/Makefile b/Makefile
index c0a8eaf2..27f46011 100644
--- a/Makefile
+++ b/Makefile
@@ -1028,7 +1028,7 @@ musl += locale/iswalnum_l.o
musl += locale/iswalpha_l.o
musl += locale/iswblank_l.o
musl += locale/iswcntrl_l.o
-libc += locale/iswctype_l.o
+musl += locale/iswctype_l.o
musl += locale/iswdigit_l.o
musl += locale/iswgraph_l.o
musl += locale/iswlower_l.o
@@ -1066,7 +1066,7 @@ libc += locale/wcsftime_l.o
libc += locale/wcsxfrm.o
libc += locale/wcsxfrm_l.o
musl += locale/wctrans_l.o
-libc += locale/wctype_l.o
+musl += locale/wctype_l.o

musl += math/__cos.o
musl += math/__cosdf.o
diff --git a/libc/locale/iswctype_l.c b/libc/locale/iswctype_l.c
deleted file mode 100644
index 6c4b34db..00000000
--- a/libc/locale/iswctype_l.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <wctype.h>
-#include "libc.h"
-
-#undef iswctype_l
-int __iswctype_l(wint_t c, wctype_t t, locale_t l)
-{
- return iswctype(c, t);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__iswctype_l, iswctype_l);
diff --git a/libc/locale/wctype_l.c b/libc/locale/wctype_l.c
deleted file mode 100644
index 67aeb0d0..00000000
--- a/libc/locale/wctype_l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <wctype.h>
-#include "libc.h"
-
-wctype_t __wctype_l(const char *s, locale_t l)
-{
- return wctype(s);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__wctype_l, wctype_l);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:30 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 2 +-
libc/aliases.ld | 3 +++
libc/locale/toupper_l.c | 11 -----------
3 files changed, 4 insertions(+), 12 deletions(-)
delete mode 100644 libc/locale/toupper_l.c

diff --git a/Makefile b/Makefile
index 27f46011..7ec0cbb8 100644
--- a/Makefile
+++ b/Makefile
@@ -1055,7 +1055,7 @@ libc += locale/strtold_l.o
libc += locale/strxfrm.o
libc += locale/strxfrm_l.o
musl += locale/tolower_l.o
-libc += locale/toupper_l.o
+musl += locale/toupper_l.o
musl += locale/towctrans_l.o
libc += locale/towlower_l.o
libc += locale/towupper_l.o
diff --git a/libc/aliases.ld b/libc/aliases.ld
index ab9c7a7c..23f208b1 100644
--- a/libc/aliases.ld
+++ b/libc/aliases.ld
@@ -24,6 +24,9 @@ __finite = finite;
__finitef = finitef;
__finitel = finitel;

+/* locale */
+__toupper_l = toupper_l;
+
/* multibyte */
__mbrlen = mbrlen;

diff --git a/libc/locale/toupper_l.c b/libc/locale/toupper_l.c
deleted file mode 100644
index cc7d3914..00000000
--- a/libc/locale/toupper_l.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <ctype.h>
-#include "libc.h"
-
-#undef __toupper_l
-int __toupper_l(int c, locale_t l)
-{
- return toupper(c);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__toupper_l, toupper_l);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:31 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 4 ++--
libc/locale/towlower_l.c | 10 ----------
libc/locale/towupper_l.c | 10 ----------
3 files changed, 2 insertions(+), 22 deletions(-)
delete mode 100644 libc/locale/towlower_l.c
delete mode 100644 libc/locale/towupper_l.c

diff --git a/Makefile b/Makefile
index 7ec0cbb8..a4cdcf55 100644
--- a/Makefile
+++ b/Makefile
@@ -1057,8 +1057,8 @@ libc += locale/strxfrm_l.o
musl += locale/tolower_l.o
musl += locale/toupper_l.o
musl += locale/towctrans_l.o
-libc += locale/towlower_l.o
-libc += locale/towupper_l.o
+musl += locale/towlower_l.o
+musl += locale/towupper_l.o
libc += locale/uselocale.o
libc += locale/wcscoll.o
libc += locale/wcscoll_l.o
diff --git a/libc/locale/towlower_l.c b/libc/locale/towlower_l.c
deleted file mode 100644
index 2360ca21..00000000
--- a/libc/locale/towlower_l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <wctype.h>
-#include "libc.h"
-
-wint_t __towlower_l(wint_t c, locale_t l)
-{
- return towlower(c);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__towlower_l, towlower_l);
diff --git a/libc/locale/towupper_l.c b/libc/locale/towupper_l.c
deleted file mode 100644
index 8b4a164a..00000000
--- a/libc/locale/towupper_l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <wctype.h>
-#include "libc.h"
-
-wint_t __towupper_l(wint_t c, locale_t l)
-{
- return towupper(c);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__towupper_l, towupper_l);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:33 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 4 ++--
libc/aliases.ld | 1 +
libc/locale/duplocale.c | 15 ---------------
libc/locale/setlocale.c | 13 -------------
4 files changed, 3 insertions(+), 30 deletions(-)
delete mode 100644 libc/locale/duplocale.c
delete mode 100644 libc/locale/setlocale.c

diff --git a/Makefile b/Makefile
index a4cdcf55..0abbd196 100644
--- a/Makefile
+++ b/Makefile
@@ -1009,7 +1009,7 @@ libc += errno/strerror.o
musl += locale/catclose.o
musl += locale/catgets.o
musl += locale/catopen.o
-libc += locale/duplocale.o
+musl += locale/duplocale.o
libc += locale/freelocale.o
musl += locale/iconv.o
musl += locale/intl.o
@@ -1041,7 +1041,7 @@ musl += locale/isxdigit_l.o
libc += locale/langinfo.o
musl += locale/localeconv.o
libc += locale/nl_langinfo_l.o
-libc += locale/setlocale.o
+musl += locale/setlocale.o
musl += locale/strcasecmp_l.o
libc += locale/strcoll.o
libc += locale/strcoll_l.o
diff --git a/libc/aliases.ld b/libc/aliases.ld
index 23f208b1..c1ad406a 100644
--- a/libc/aliases.ld
+++ b/libc/aliases.ld
@@ -26,6 +26,7 @@ __finitel = finitel;

/* locale */
__toupper_l = toupper_l;
+__setlocale = setlocale;

/* multibyte */
__mbrlen = mbrlen;
diff --git a/libc/locale/duplocale.c b/libc/locale/duplocale.c
deleted file mode 100644
index 695a06f1..00000000
--- a/libc/locale/duplocale.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "locale_impl.h"
-#include "libc.h"
-
-locale_t __duplocale(locale_t old)
-{
- locale_t new;
- new = calloc(1, sizeof *new);
- if (new && old != LC_GLOBAL_LOCALE) memcpy(new, old, sizeof *new);
- return new;
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__duplocale, duplocale);
diff --git a/libc/locale/setlocale.c b/libc/locale/setlocale.c
deleted file mode 100644
index b311f28b..00000000
--- a/libc/locale/setlocale.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <locale.h>
-#include "libc.h"
-
-char *__setlocale(int category, const char *locale)
-{
- /* Note: plain "C" would be better, but puts some broken
- * software into legacy 8-bit-codepage mode, ignoring
- * the standard library's multibyte encoding */
- return "C.UTF-8";
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__setlocale, setlocale);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:35 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 3 +--
libc/locale/wcsxfrm.c | 12 ------------
libc/locale/wcsxfrm_l.c | 10 ----------
3 files changed, 1 insertion(+), 24 deletions(-)
delete mode 100644 libc/locale/wcsxfrm.c
delete mode 100644 libc/locale/wcsxfrm_l.c

diff --git a/Makefile b/Makefile
index 168a6bdd..358b758a 100644
--- a/Makefile
+++ b/Makefile
@@ -1063,8 +1063,7 @@ libc += locale/uselocale.o
libc += locale/wcscoll.o
libc += locale/wcscoll_l.o
libc += locale/wcsftime_l.o
-libc += locale/wcsxfrm.o
-libc += locale/wcsxfrm_l.o
+musl += locale/wcsxfrm.o
musl += locale/wctrans_l.o
musl += locale/wctype_l.o

diff --git a/libc/locale/wcsxfrm.c b/libc/locale/wcsxfrm.c
deleted file mode 100644
index bfa01b5b..00000000
--- a/libc/locale/wcsxfrm.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <wchar.h>
-
-/* collate only by code points */
-size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n)
-{
- size_t l = wcslen(src);
- if (l >= n) {
- wmemcpy(dest, src, n-1);
- dest[n-1] = 0;
- } else wcscpy(dest, src);
- return l;
-}
diff --git a/libc/locale/wcsxfrm_l.c b/libc/locale/wcsxfrm_l.c
deleted file mode 100644
index 2db6c065..00000000
--- a/libc/locale/wcsxfrm_l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <wchar.h>
-#include "libc.h"
-
-size_t __wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t locale)
-{
- return wcsxfrm(dest, src, n);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__wcsxfrm_l, wcsxfrm_l);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:39 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 3 +--
libc/locale/wcscoll.c | 7 -------
libc/locale/wcscoll_l.c | 10 ----------
3 files changed, 1 insertion(+), 19 deletions(-)
delete mode 100644 libc/locale/wcscoll.c
delete mode 100644 libc/locale/wcscoll_l.c

diff --git a/Makefile b/Makefile
index 358b758a..3750338b 100644
--- a/Makefile
+++ b/Makefile
@@ -1060,8 +1060,7 @@ musl += locale/towctrans_l.o
musl += locale/towlower_l.o
musl += locale/towupper_l.o
libc += locale/uselocale.o
-libc += locale/wcscoll.o
-libc += locale/wcscoll_l.o
+musl += locale/wcscoll.o
libc += locale/wcsftime_l.o
musl += locale/wcsxfrm.o
musl += locale/wctrans_l.o
diff --git a/libc/locale/wcscoll.c b/libc/locale/wcscoll.c
deleted file mode 100644
index cdbce1c2..00000000
--- a/libc/locale/wcscoll.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <wchar.h>
-
-/* FIXME: stub */
-int wcscoll(const wchar_t *l, const wchar_t *r)
-{
- return wcscmp(l, r);
-}
diff --git a/libc/locale/wcscoll_l.c b/libc/locale/wcscoll_l.c
deleted file mode 100644
index 5c5cdb65..00000000
--- a/libc/locale/wcscoll_l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <wchar.h>
-#include "libc.h"
-
-int __wcscoll_l(const wchar_t *l, const wchar_t *r, locale_t locale)
-{
- return wcscoll(l, r);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__wcscoll_l, wcscoll_l);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:40 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 3 +--
libc/locale/strxfrm.c | 9 ---------
libc/locale/strxfrm_l.c | 10 ----------
3 files changed, 1 insertion(+), 21 deletions(-)
delete mode 100644 libc/locale/strxfrm.c
delete mode 100644 libc/locale/strxfrm_l.c

diff --git a/Makefile b/Makefile
index 3750338b..de2f7866 100644
--- a/Makefile
+++ b/Makefile
@@ -1052,8 +1052,7 @@ musl += locale/strncasecmp_l.o
libc += locale/strtod_l.o
libc += locale/strtof_l.o
libc += locale/strtold_l.o
-libc += locale/strxfrm.o
-libc += locale/strxfrm_l.o
+musl += locale/strxfrm.o
musl += locale/tolower_l.o
musl += locale/toupper_l.o
musl += locale/towctrans_l.o
diff --git a/libc/locale/strxfrm.c b/libc/locale/strxfrm.c
deleted file mode 100644
index d40be9e1..00000000
--- a/libc/locale/strxfrm.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <string.h>
-
-/* collate only by code points */
-size_t strxfrm(char *restrict dest, const char *restrict src, size_t n)
-{
- size_t l = strlen(src);
- if (n > l) strcpy(dest, src);
- return l;
-}
diff --git a/libc/locale/strxfrm_l.c b/libc/locale/strxfrm_l.c
deleted file mode 100644
index 954284ee..00000000
--- a/libc/locale/strxfrm_l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <string.h>
-#include "libc.h"
-
-size_t __strxfrm_l(char *restrict dest, const char *restrict src, size_t n, locale_t l)
-{
- return strxfrm(dest, src, n);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__strxfrm_l, strxfrm_l);
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:42 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
This file had been imported from musl as part of the commit 79d5ad7d6f7bbcc20edf2ce2bbf3cc08f04b08dd.
It looks like it got slightly modified to possibly silence the compiler (see the diff below).

```
diff musl/src/locale/strfmon.c libc/locale/strfmon.c
12c12
< int fill, nogrp, negpar, nosym, left, intl;
---
> int left;
25,28d24
< fill = ' ';
< nogrp = 0;
< negpar = 0;
< nosym = 0;
33d28
< fill = *++fmt;
36d30
< nogrp = 1;
39d32
< negpar = 1;
43d35
< nosym = 1;
61,62d52
< intl = *fmt++ == 'i';
<
```

More specifically if one looks at the musl code,
the variables fill, nogrp, negpar, nosym and intl are set but never referenced/used.
As a matter of fact dropping the statements 'fill = *++fmt;' and 'intl = *fmt++ == 'i';'
affects fmt variable and possibly has a bug.

TODO: Add a test.

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 2 +-
libc/locale/strfmon.c | 91 -------------------------------------------
2 files changed, 1 insertion(+), 92 deletions(-)
delete mode 100644 libc/locale/strfmon.c

diff --git a/Makefile b/Makefile
index 0abbd196..168a6bdd 100644
--- a/Makefile
+++ b/Makefile
@@ -1046,7 +1046,7 @@ musl += locale/strcasecmp_l.o
libc += locale/strcoll.o
libc += locale/strcoll_l.o
musl += locale/strerror_l.o
-libc += locale/strfmon.o
+musl += locale/strfmon.o
libc += locale/strftime_l.o
musl += locale/strncasecmp_l.o
libc += locale/strtod_l.o
diff --git a/libc/locale/strfmon.c b/libc/locale/strfmon.c
deleted file mode 100644
index 14623fa7..00000000
--- a/libc/locale/strfmon.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <stdio.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <monetary.h>
-#include <errno.h>
-#include <stdarg.h>
-
-static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, va_list ap)
-{
- size_t l;
- double x;
- int left;
- int lp, rp, w, fw;
- char *s0=s;
- for (; n && *fmt; ) {
- if (*fmt != '%') {
- literal:
- *s++ = *fmt++;
- n--;
- continue;
- }
- fmt++;
- if (*fmt == '%') goto literal;
-
- left = 0;
- for (; ; fmt++) {
- switch (*fmt) {
- case '=':
- continue;
- case '^':
- continue;
- case '(':
- case '+':
- continue;
- case '!':
- continue;
- case '-':
- left = 1;
- continue;
- }
- break;
- }
-
- for (fw=0; isdigit(*fmt); fmt++)
- fw = 10*fw + (*fmt-'0');
- lp = 0;
- rp = 2;
- if (*fmt=='#') for (lp=0, fmt++; isdigit(*fmt); fmt++)
- lp = 10*lp + (*fmt-'0');
- if (*fmt=='.') for (rp=0, fmt++; isdigit(*fmt); fmt++)
- rp = 10*rp + (*fmt-'0');
-
- w = lp + 1 + rp;
- if (!left && fw>w) w = fw;
-
- x = va_arg(ap, double);
- l = snprintf(s, n, "%*.*f", w, rp, x);
- if (l >= n) {
- errno = E2BIG;
- return -1;
- }
- s += l;
- n -= l;
- }
- return s-s0;
-}
-
-ssize_t strfmon_l(char *restrict s, size_t n, locale_t loc, const char *restrict fmt, ...)
-{
- va_list ap;
- ssize_t ret;
-
- va_start(ap, fmt);
- ret = vstrfmon_l(s, n, loc, fmt, ap);
- va_end(ap);
-
- return ret;
-}
-
-
-ssize_t strfmon(char *restrict s, size_t n, const char *restrict fmt, ...)
-{
- va_list ap;
- ssize_t ret;
-
- va_start(ap, fmt);
- ret = vstrfmon_l(s, n, 0, fmt, ap);
- va_end(ap);
-
- return ret;
-}
--
2.26.2

Waldemar Kozaczuk

unread,
Aug 15, 2020, 12:27:44 AM8/15/20
to osv...@googlegroups.com, Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 3 +--
libc/locale/strcoll.c | 6 ------
libc/locale/strcoll_l.c | 11 -----------
3 files changed, 1 insertion(+), 19 deletions(-)
delete mode 100644 libc/locale/strcoll.c
delete mode 100644 libc/locale/strcoll_l.c

diff --git a/Makefile b/Makefile
index de2f7866..93c4e189 100644
--- a/Makefile
+++ b/Makefile
@@ -1043,8 +1043,7 @@ musl += locale/localeconv.o
libc += locale/nl_langinfo_l.o
musl += locale/setlocale.o
musl += locale/strcasecmp_l.o
-libc += locale/strcoll.o
-libc += locale/strcoll_l.o
+musl += locale/strcoll.o
musl += locale/strerror_l.o
musl += locale/strfmon.o
libc += locale/strftime_l.o
diff --git a/libc/locale/strcoll.c b/libc/locale/strcoll.c
deleted file mode 100644
index 30bccd62..00000000
--- a/libc/locale/strcoll.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <string.h>
-
-int strcoll(const char *l, const char *r)
-{
- return strcmp(l, r);
-}
diff --git a/libc/locale/strcoll_l.c b/libc/locale/strcoll_l.c
deleted file mode 100644
index 033e7afd..00000000
--- a/libc/locale/strcoll_l.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <string.h>
-#include <locale.h>
-#include "libc.h"
-
-int __strcoll_l(const char *l, const char *r, locale_t loc)
-{
- return strcoll(l, r);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__strcoll_l, strcoll_l);
--
2.26.2

Nadav Har'El

unread,
Aug 15, 2020, 3:13:01 AM8/15/20
to Waldemar Kozaczuk, Osv Dev
Don't you also need to add the alias __duplocale?

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

Waldek Kozaczuk

unread,
Aug 15, 2020, 9:03:57 AM8/15/20
to Nadav Har'El, Osv Dev
I don't think so. The musl version of duplocale.c (
https://github.com/cloudius-systems/musl/blob/master/src/locale/duplocale.c) defines __duplocale and its alias duplocale using weak_alias macro. On other hand, musl setlocale.c defines setlocale only that is why we have to add alias to aliases.ld. 

Commit Bot

unread,
Aug 20, 2020, 12:18:54 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: replace iswctype_l and wctype_l.c with musl equivalent

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1028,7 +1028,7 @@ musl += locale/iswalnum_l.o
musl += locale/iswalpha_l.o
musl += locale/iswblank_l.o
musl += locale/iswcntrl_l.o
-libc += locale/iswctype_l.o
+musl += locale/iswctype_l.o
musl += locale/iswdigit_l.o
musl += locale/iswgraph_l.o
musl += locale/iswlower_l.o
@@ -1066,7 +1066,7 @@ libc += locale/wcsftime_l.o
libc += locale/wcsxfrm.o
libc += locale/wcsxfrm_l.o
musl += locale/wctrans_l.o
-libc += locale/wctype_l.o
+musl += locale/wctype_l.o

musl += math/__cos.o
musl += math/__cosdf.o
diff --git a/libc/locale/iswctype_l.c b/libc/locale/iswctype_l.c
--- a/libc/locale/iswctype_l.c
+++ b/libc/locale/iswctype_l.c
@@ -1,11 +0,0 @@
-#include <wctype.h>
-#include "libc.h"
-
-#undef iswctype_l
-int __iswctype_l(wint_t c, wctype_t t, locale_t l)
-{
- return iswctype(c, t);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__iswctype_l, iswctype_l);
diff --git a/libc/locale/wctype_l.c b/libc/locale/wctype_l.c
--- a/libc/locale/wctype_l.c
+++ b/libc/locale/wctype_l.c

Commit Bot

unread,
Aug 20, 2020, 12:18:55 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: drop OSv toupper_l in favor of musl copy and add alias __toupper_l

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1055,7 +1055,7 @@ libc += locale/strtold_l.o
libc += locale/strxfrm.o
libc += locale/strxfrm_l.o
musl += locale/tolower_l.o
-libc += locale/toupper_l.o
+musl += locale/toupper_l.o
musl += locale/towctrans_l.o
libc += locale/towlower_l.o
libc += locale/towupper_l.o
diff --git a/libc/aliases.ld b/libc/aliases.ld
--- a/libc/aliases.ld
+++ b/libc/aliases.ld
@@ -24,6 +24,9 @@ __finite = finite;
__finitef = finitef;
__finitel = finitel;

+/* locale */
+__toupper_l = toupper_l;
+
/* multibyte */
__mbrlen = mbrlen;

diff --git a/libc/locale/toupper_l.c b/libc/locale/toupper_l.c
--- a/libc/locale/toupper_l.c
+++ b/libc/locale/toupper_l.c

Commit Bot

unread,
Aug 20, 2020, 12:18:56 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: drop towlower_l and towupper_l in favor of musl copies

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1057,8 +1057,8 @@ libc += locale/strxfrm_l.o
musl += locale/tolower_l.o
musl += locale/toupper_l.o
musl += locale/towctrans_l.o
-libc += locale/towlower_l.o
-libc += locale/towupper_l.o
+musl += locale/towlower_l.o
+musl += locale/towupper_l.o
libc += locale/uselocale.o
libc += locale/wcscoll.o
libc += locale/wcscoll_l.o
diff --git a/libc/locale/towlower_l.c b/libc/locale/towlower_l.c
--- a/libc/locale/towlower_l.c
+++ b/libc/locale/towlower_l.c
@@ -1,10 +0,0 @@
-#include <wctype.h>
-#include "libc.h"
-
-wint_t __towlower_l(wint_t c, locale_t l)
-{
- return towlower(c);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__towlower_l, towlower_l);
diff --git a/libc/locale/towupper_l.c b/libc/locale/towupper_l.c
--- a/libc/locale/towupper_l.c
+++ b/libc/locale/towupper_l.c

Commit Bot

unread,
Aug 20, 2020, 12:18:58 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: drop setlocale.c and duplocale.c and add __setlocale alias

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1009,7 +1009,7 @@ libc += errno/strerror.o
musl += locale/catclose.o
musl += locale/catgets.o
musl += locale/catopen.o
-libc += locale/duplocale.o
+musl += locale/duplocale.o
libc += locale/freelocale.o
musl += locale/iconv.o
musl += locale/intl.o
@@ -1041,7 +1041,7 @@ musl += locale/isxdigit_l.o
libc += locale/langinfo.o
musl += locale/localeconv.o
libc += locale/nl_langinfo_l.o
-libc += locale/setlocale.o
+musl += locale/setlocale.o
musl += locale/strcasecmp_l.o
libc += locale/strcoll.o
libc += locale/strcoll_l.o
diff --git a/libc/aliases.ld b/libc/aliases.ld
--- a/libc/aliases.ld
+++ b/libc/aliases.ld
@@ -26,6 +26,7 @@ __finitel = finitel;

/* locale */
__toupper_l = toupper_l;
+__setlocale = setlocale;

/* multibyte */
__mbrlen = mbrlen;
diff --git a/libc/locale/duplocale.c b/libc/locale/duplocale.c
--- a/libc/locale/duplocale.c
+++ b/libc/locale/duplocale.c
@@ -1,15 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "locale_impl.h"
-#include "libc.h"
-
-locale_t __duplocale(locale_t old)
-{
- locale_t new;
- new = calloc(1, sizeof *new);
- if (new && old != LC_GLOBAL_LOCALE) memcpy(new, old, sizeof *new);
- return new;
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__duplocale, duplocale);
diff --git a/libc/locale/setlocale.c b/libc/locale/setlocale.c
--- a/libc/locale/setlocale.c
+++ b/libc/locale/setlocale.c

Commit Bot

unread,
Aug 20, 2020, 12:19:00 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: replace locale/wcscoll*.c (from old musl) with musl copy of locale/wcscoll.c

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1060,8 +1060,7 @@ musl += locale/towctrans_l.o
musl += locale/towlower_l.o
musl += locale/towupper_l.o
libc += locale/uselocale.o
-libc += locale/wcscoll.o
-libc += locale/wcscoll_l.o
+musl += locale/wcscoll.o
libc += locale/wcsftime_l.o
musl += locale/wcsxfrm.o
musl += locale/wctrans_l.o
diff --git a/libc/locale/wcscoll.c b/libc/locale/wcscoll.c
--- a/libc/locale/wcscoll.c
+++ b/libc/locale/wcscoll.c
@@ -1,7 +0,0 @@
-#include <wchar.h>
-
-/* FIXME: stub */
-int wcscoll(const wchar_t *l, const wchar_t *r)
-{
- return wcscmp(l, r);
-}
diff --git a/libc/locale/wcscoll_l.c b/libc/locale/wcscoll_l.c
--- a/libc/locale/wcscoll_l.c
+++ b/libc/locale/wcscoll_l.c

Commit Bot

unread,
Aug 20, 2020, 12:19:00 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: replace locale/wcsxfrm*.c (from old musl) with musl copy of locale/wcsxfrm.c

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1063,8 +1063,7 @@ libc += locale/uselocale.o
libc += locale/wcscoll.o
libc += locale/wcscoll_l.o
libc += locale/wcsftime_l.o
-libc += locale/wcsxfrm.o
-libc += locale/wcsxfrm_l.o
+musl += locale/wcsxfrm.o
musl += locale/wctrans_l.o
musl += locale/wctype_l.o

diff --git a/libc/locale/wcsxfrm.c b/libc/locale/wcsxfrm.c
--- a/libc/locale/wcsxfrm.c
+++ b/libc/locale/wcsxfrm.c
@@ -1,12 +0,0 @@
-#include <wchar.h>
-
-/* collate only by code points */
-size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n)
-{
- size_t l = wcslen(src);
- if (l >= n) {
- wmemcpy(dest, src, n-1);
- dest[n-1] = 0;
- } else wcscpy(dest, src);
- return l;
-}
diff --git a/libc/locale/wcsxfrm_l.c b/libc/locale/wcsxfrm_l.c
--- a/libc/locale/wcsxfrm_l.c
+++ b/libc/locale/wcsxfrm_l.c

Commit Bot

unread,
Aug 20, 2020, 12:19:02 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: replace locale/strxfrm*.c (from old musl) with musl copy of locale/strxfrm.c

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1052,8 +1052,7 @@ musl += locale/strncasecmp_l.o
libc += locale/strtod_l.o
libc += locale/strtof_l.o
libc += locale/strtold_l.o
-libc += locale/strxfrm.o
-libc += locale/strxfrm_l.o
+musl += locale/strxfrm.o
musl += locale/tolower_l.o
musl += locale/toupper_l.o
musl += locale/towctrans_l.o
diff --git a/libc/locale/strxfrm.c b/libc/locale/strxfrm.c
--- a/libc/locale/strxfrm.c
+++ b/libc/locale/strxfrm.c
@@ -1,9 +0,0 @@
-#include <string.h>
-
-/* collate only by code points */
-size_t strxfrm(char *restrict dest, const char *restrict src, size_t n)
-{
- size_t l = strlen(src);
- if (n > l) strcpy(dest, src);
- return l;
-}
diff --git a/libc/locale/strxfrm_l.c b/libc/locale/strxfrm_l.c
--- a/libc/locale/strxfrm_l.c
+++ b/libc/locale/strxfrm_l.c

Commit Bot

unread,
Aug 20, 2020, 12:19:03 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: replace locale/strfmon.c with the musl copy

This file had been imported from musl as part of the commit 79d5ad7d6f7bbcc20edf2ce2bbf3cc08f04b08dd.
It looks like it got slightly modified to possibly silence the compiler (see the diff below).

```
diff musl/src/locale/strfmon.c libc/locale/strfmon.c
12c12
< int fill, nogrp, negpar, nosym, left, intl;
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1046,7 +1046,7 @@ musl += locale/strcasecmp_l.o
libc += locale/strcoll.o
libc += locale/strcoll_l.o
musl += locale/strerror_l.o
-libc += locale/strfmon.o
+musl += locale/strfmon.o
libc += locale/strftime_l.o
musl += locale/strncasecmp_l.o
libc += locale/strtod_l.o
diff --git a/libc/locale/strfmon.c b/libc/locale/strfmon.c
--- a/libc/locale/strfmon.c
+++ b/libc/locale/strfmon.c

Commit Bot

unread,
Aug 20, 2020, 12:19:04 AM8/20/20
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

libc: replace locale/strcoll*.c (from old musl) with musl copy of locale/strcoll.c

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20200815042719.5...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1043,8 +1043,7 @@ musl += locale/localeconv.o
libc += locale/nl_langinfo_l.o
musl += locale/setlocale.o
musl += locale/strcasecmp_l.o
-libc += locale/strcoll.o
-libc += locale/strcoll_l.o
+musl += locale/strcoll.o
musl += locale/strerror_l.o
musl += locale/strfmon.o
libc += locale/strftime_l.o
diff --git a/libc/locale/strcoll.c b/libc/locale/strcoll.c
--- a/libc/locale/strcoll.c
+++ b/libc/locale/strcoll.c
@@ -1,6 +0,0 @@
-#include <string.h>
-
-int strcoll(const char *l, const char *r)
-{
- return strcmp(l, r);
-}
diff --git a/libc/locale/strcoll_l.c b/libc/locale/strcoll_l.c
--- a/libc/locale/strcoll_l.c
+++ b/libc/locale/strcoll_l.c
Reply all
Reply to author
Forward
0 new messages