On Fri, Jul 21, 2017 at 1:45 PM, Justin Cinkelj <justin.cink...@xlab.si>
wrote:

> At least a symbol needs to be defined for python2.7.
> File mbrlen.c is moved from musl/ to libc/, as the weak alias declaration
> must be in same file as function definition.
>

I don't think this is true - the alias declaration does NOT need to be in
the same file as the original function.
I think what you were missing is a *declaration* of the original function,
i.e., just #include some header file which declares the prototype of the
original function. You don't need the function's actual definition.

I agree that it makes sense to define the alias in the same file as the
original definition, but it would be sad to have to duplicate Musl's file
for that. I propose adding a new file just for that. I'll prepare a patch.


>
> Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
> ---
>  Makefile                |  2 +-
>  libc/multibyte/mbrlen.c | 20 ++++++++++++++++++++
>  2 files changed, 21 insertions(+), 1 deletion(-)
>  create mode 100644 libc/multibyte/mbrlen.c
>
> diff --git a/Makefile b/Makefile
> index c376b74..5acdc7d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1331,7 +1331,7 @@ libc += misc/__longjmp_chk.o
>  musl += multibyte/btowc.o
>  musl += multibyte/internal.o
>  musl += multibyte/mblen.o
> -musl += multibyte/mbrlen.o
> +libc += multibyte/mbrlen.o
>  musl += multibyte/mbrtowc.o
>  musl += multibyte/mbsinit.o
>  musl += multibyte/mbsnrtowcs.o
> diff --git a/libc/multibyte/mbrlen.c b/libc/multibyte/mbrlen.c
> new file mode 100644
> index 0000000..827f1da
> --- /dev/null
> +++ b/libc/multibyte/mbrlen.c
> @@ -0,0 +1,20 @@
> +/*
> + * 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")));
> --
> 2.9.4
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to