mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH 1/10] ioperm & iopl
@ 2012-07-23  1:13 Isaac Dunham
  2012-07-23  1:17 ` [PATCH 2/10] splice Isaac Dunham
                   ` (9 more replies)
  0 siblings, 10 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:13 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

This patch series is basically a reworked version of orc's previous
patch.
From what orc said, the first patch should provide enough to build
Xorg; I haven't tested this yet.
A few more patches are syscall wrappers (splice) or trivial
functions (finite).
Finally, there are several aliases.

With that, I'm sending the first patch.
This adds ioperm & iopl along with io.h, though a full io.h has
several more syscalls.

Isaac Dunham 

[-- Attachment #2: 1-ioperm-iopl.diff --]
[-- Type: text/x-patch, Size: 738 bytes --]

diff --git a/include/sys/io.h b/include/sys/io.h
new file mode 100644
index 0000000..1f4d1a3
--- /dev/null
+++ b/include/sys/io.h
@@ -0,0 +1,2 @@
+int ioperm(unsigned long, unsigned long, int);
+int iopl(int);
diff --git a/src/linux/ioperm.c b/src/linux/ioperm.c
new file mode 100644
index 0000000..6d6d383
--- /dev/null
+++ b/src/linux/ioperm.c
@@ -0,0 +1,6 @@
+#include "syscall.h"
+
+int ioperm(unsigned long from, unsigned long num, int turn_on)
+{
+	return syscall(SYS_ioperm, from, num, turn_on);
+}
diff --git a/src/linux/iopl.c b/src/linux/iopl.c
new file mode 100644
index 0000000..7fc9102
--- /dev/null
+++ b/src/linux/iopl.c
@@ -0,0 +1,6 @@
+#include "syscall.h"
+
+int iopl(int level)
+{
+	return syscall(SYS_iopl, level);
+}

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/10] splice
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
@ 2012-07-23  1:17 ` Isaac Dunham
  2012-07-23  1:21 ` [PATCH 3/10] xattr syscalls Isaac Dunham
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:17 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

This adds a syscall wrapper for splice. 
I trusted git apply too much, so there are two parts to this patch:
one to add the syscall, one to fix the header back up...
Isaac Dunham

[-- Attachment #2: 2-splice.diff --]
[-- Type: text/x-patch, Size: 991 bytes --]

diff --git a/include/fcntl.h b/include/fcntl.h
index fcb622a..b014662 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -9,6 +9,11 @@ extern "C" {
 #define __NEED_pid_t
 #define __NEED_mode_t
 
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_size_t
+#define __NEED_ssize_t
+#endif
+
 #include <bits/alltypes.h>
 
 #include <bits/fcntl.h>
@@ -97,6 +102,7 @@ int posix_fallocate(int, off_t, off_t);
 #define F_TEST  3
 
 int lockf(int, int, off_t);
+ssize_t splice(int, off_t, int, off_t, size_t, unsigned int);
 #endif
 
 #if defined(_GNU_SOURCE)
diff --git a/src/linux/splice.c b/src/linux/splice.c
new file mode 100644
index 0000000..63e4593
--- /dev/null
+++ b/src/linux/splice.c
@@ -0,0 +1,9 @@
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <sys/types.h>
+#include "syscall.h"
+
+ssize_t splice(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned int flags)
+{
+	return syscall(SYS_splice, fd_in, off_in, fd_out, off_out, len, flags);
+}

[-- Attachment #3: 2.5-splice.diff --]
[-- Type: text/x-patch, Size: 616 bytes --]

diff --git a/include/fcntl.h b/include/fcntl.h
index b014662..27ca147 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -9,7 +9,7 @@ extern "C" {
 #define __NEED_pid_t
 #define __NEED_mode_t
 
+#ifdef _GNU_SOURCE
+#define __NEED_size_t
 #define __NEED_ssize_t
 #endif
@@ -102,10 +102,10 @@ int posix_fallocate(int, off_t, off_t);
 #define F_TEST  3
 
 int lockf(int, int, off_t);
-ssize_t splice(int, off_t, int, off_t, size_t, unsigned int);
 #endif
 
 #if defined(_GNU_SOURCE)
+ssize_t splice(int, off_t, int, off_t, size_t, unsigned int);
 #define F_OWNER_TID 0
 #define F_OWNER_PID 1
 #define F_OWNER_PGRP 2

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/10] xattr syscalls
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
  2012-07-23  1:17 ` [PATCH 2/10] splice Isaac Dunham
@ 2012-07-23  1:21 ` Isaac Dunham
  2012-07-24 18:06   ` orc
  2012-07-23  1:24 ` [PATCH 4/10] pipe2 Isaac Dunham
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:21 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice) or trivial
> functions (finite).

Here's support for the xattr syscalls. orc probably knows better than I
what these are needed for...

Isaac Dunham

[-- Attachment #2: 3-xattr.diff --]
[-- Type: text/x-patch, Size: 2420 bytes --]

diff --git a/include/sys/xattr.h b/include/sys/xattr.h
new file mode 100644
index 0000000..0599cb3
--- /dev/null
+++ b/include/sys/xattr.h
@@ -0,0 +1,11 @@
+#define XATTR_CREATE 1
+#define XATTR_REPLACE 2
+ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
+ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
+ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size)
+ssize_t listxattr(const char *path, char *list, size_t size)
+ssize_t llistxattr(const char *path, char *list, size_t size)
+ssize_t flistxattr(int filedes, char *list, size_t size)
+int setxattr(const char *path, const char *name, const void *value, size_t size, int flags)
+int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
+int fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags)
diff --git a/src/linux/xattr.c b/src/linux/xattr.c
new file mode 100644
index 0000000..75b5015
--- /dev/null
+++ b/src/linux/xattr.c
@@ -0,0 +1,48 @@
+#include <sys/types.h>
+#include <sys/xattr.h>
+#include "syscall.h"
+
+ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
+{
+	return syscall(SYS_getxattr, path, name, value, size);
+}
+
+ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
+{
+	return syscall(SYS_lgetxattr, path, name, value, size);
+}
+
+ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size)
+{
+	return syscall(SYS_fgetxattr, filedes, name, value, size);
+}
+
+ssize_t listxattr(const char *path, char *list, size_t size)
+{
+	return syscall(SYS_listxattr, path, list, size);
+}
+
+ssize_t llistxattr(const char *path, char *list, size_t size)
+{
+	return syscall(SYS_llistxattr, path, list, size);
+}
+
+ssize_t flistxattr(int filedes, char *list, size_t size)
+{
+	return syscall(SYS_flistxattr, filedes, list, size);
+}
+
+int setxattr(const char *path, const char *name, const void *value, size_t size, int flags)
+{
+	return syscall(SYS_setxattr, path, name, value, size, flags);
+}
+
+int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
+{
+	return syscall(SYS_lsetxattr, path, name, value, size, flags);
+}
+
+int fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags)
+{
+	return syscall(SYS_fsetxattr, filedes, name, value, size, flags);
+}

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/10] pipe2
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
  2012-07-23  1:17 ` [PATCH 2/10] splice Isaac Dunham
  2012-07-23  1:21 ` [PATCH 3/10] xattr syscalls Isaac Dunham
@ 2012-07-23  1:24 ` Isaac Dunham
  2012-07-23  1:28 ` [PATCH 5/10] __sigsetjmp alias Isaac Dunham
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:24 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice)
Support for the pipe2 syscall, with respect for namespaces.

Isaac Dunham


[-- Attachment #2: 4-pipe2.diff --]
[-- Type: text/x-patch, Size: 688 bytes --]

diff --git a/include/unistd.h b/include/unistd.h
index 9c737f7..17fe5e7 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -174,6 +174,7 @@ int setresgid(gid_t, gid_t, gid_t);
 int getresuid(uid_t *, uid_t *, uid_t *);
 int getresgid(gid_t *, gid_t *, gid_t *);
 char *get_current_dir_name(void);
+int pipe2(int [2], int);
 #endif
 
 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
diff --git a/src/unistd/pipe2.c b/src/unistd/pipe2.c
new file mode 100644
index 0000000..95c8a15
--- /dev/null
+++ b/src/unistd/pipe2.c
@@ -0,0 +1,8 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+
+int pipe2(int fd[2], int flg)
+{
+	return syscall(SYS_pipe, fd, flg);
+}

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/10] __sigsetjmp alias
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (2 preceding siblings ...)
  2012-07-23  1:24 ` [PATCH 4/10] pipe2 Isaac Dunham
@ 2012-07-23  1:28 ` Isaac Dunham
  2012-07-23  1:32 ` [PATCH 6/10] Provide private versions of locale/ functions Isaac Dunham
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:28 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
Here, I had to guess and add aliases for arm & mips.
At this point, the mips alias isn't meaningful, since mips is static
only, but here's hoping it works sometime...

Isaac Dunham

[-- Attachment #2: 5-sigset.diff --]
[-- Type: text/x-patch, Size: 1526 bytes --]

diff --git a/src/signal/arm/sigsetjmp.s b/src/signal/arm/sigsetjmp.s
index acb0301..654b6c6 100644
--- a/src/signal/arm/sigsetjmp.s
+++ b/src/signal/arm/sigsetjmp.s
@@ -1,6 +1,9 @@
 .global sigsetjmp
 .type sigsetjmp,%function
+.weak __sigsetjmp
+.type __sigsetjmp,%function
 sigsetjmp:
+__sigsetjmp:
 	str a2,[a1,#256]
 	tst a2,a2
 	beq setjmp
diff --git a/src/signal/i386/sigsetjmp.s b/src/signal/i386/sigsetjmp.s
index 06e0a61..7a53e19 100644
--- a/src/signal/i386/sigsetjmp.s
+++ b/src/signal/i386/sigsetjmp.s
@@ -1,6 +1,9 @@
 .global sigsetjmp
 .type sigsetjmp,@function
+.weak __sigsetjmp
+.type __sigsetjmp,@function
 sigsetjmp:
+__sigsetjmp:
 	mov 4(%esp),%eax
 	mov 8(%esp),%ecx
 	mov %ecx,24(%eax)
diff --git a/src/signal/mips/sigsetjmp.s b/src/signal/mips/sigsetjmp.s
index ae9c542..de7328c 100644
--- a/src/signal/mips/sigsetjmp.s
+++ b/src/signal/mips/sigsetjmp.s
@@ -2,7 +2,10 @@
 
 .global sigsetjmp
 .type sigsetjmp,@function
+.weak __sigsetjmp
+.type __sigsetjmp,@function
 sigsetjmp:
+__sigsetjmp:
 	lui $gp, %hi(_gp_disp)
 	addiu $gp, %lo(_gp_disp)
 	beq $5, $0, 1f
diff --git a/src/signal/x86_64/sigsetjmp.s b/src/signal/x86_64/sigsetjmp.s
index 94d7148..da0028b 100644
--- a/src/signal/x86_64/sigsetjmp.s
+++ b/src/signal/x86_64/sigsetjmp.s
@@ -1,7 +1,10 @@
 /* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
 .global sigsetjmp
 .type sigsetjmp,@function
+.weak __sigsetjmp
+.type __sigsetjmp,@function
 sigsetjmp:
+__sigsetjmp:
 	andl %esi,%esi
 	movq %rsi,64(%rdi)
 	jz 1f

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/10] Provide private versions of locale/ functions
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (3 preceding siblings ...)
  2012-07-23  1:28 ` [PATCH 5/10] __sigsetjmp alias Isaac Dunham
@ 2012-07-23  1:32 ` Isaac Dunham
  2012-07-23  1:33 ` [PATCH 7/10] __fcntl Isaac Dunham
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:32 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice) or trivial
> functions (finite).
> Finally, there are several aliases.

This renames several functions in locale/ to __*, and weak-aliases to
the original names.
Mainly useful if they ever do get dragged into the ISO code...

Isaac Dunham

[-- Attachment #2: 6-__locale.diff --]
[-- Type: text/x-patch, Size: 5899 bytes --]

diff --git a/src/locale/duplocale.c b/src/locale/duplocale.c
index 5f01e13..716df4a 100644
--- a/src/locale/duplocale.c
+++ b/src/locale/duplocale.c
@@ -1,11 +1,14 @@
 #include <stdlib.h>
 #include <string.h>
 #include "locale_impl.h"
+#include "libc.h"
 
-locale_t duplocale(locale_t old)
+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;
 }
+
+weak_alias(__duplocale, duplocale);
diff --git a/src/locale/freelocale.c b/src/locale/freelocale.c
index 4e089f2..f35ac46 100644
--- a/src/locale/freelocale.c
+++ b/src/locale/freelocale.c
@@ -1,7 +1,10 @@
 #include <stdlib.h>
 #include "locale_impl.h"
+#include "libc.h"
 
-void freelocale(locale_t l)
+void __freelocale(locale_t l)
 {
 	free(l);
 }
+
+weak_alias(__freelocale, freelocale);
diff --git a/src/locale/iswctype_l.c b/src/locale/iswctype_l.c
index 1dccef6..c20ef6a 100644
--- a/src/locale/iswctype_l.c
+++ b/src/locale/iswctype_l.c
@@ -1,6 +1,9 @@
 #include <wctype.h>
+#include "libc.h"
 
-int iswctype_l(wint_t c, wctype_t t, locale_t l)
+int __iswctype_l(wint_t c, wctype_t t, locale_t l)
 {
 	return iswctype(c, t);
 }
+
+weak_alias(__iswctype_l, iswctype_l);
diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c
index 986e796..447c8fc 100644
--- a/src/locale/newlocale.c
+++ b/src/locale/newlocale.c
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "locale_impl.h"
+#include "libc.h"
 
 locale_t newlocale(int mask, const char *name, locale_t base)
 {
@@ -9,3 +10,5 @@ locale_t newlocale(int mask, const char *name, locale_t base)
 	if (!base) base = calloc(1, sizeof *base);
 	return base;
 }
+
+weak_alias(newlocale, __newlocale);
diff --git a/src/locale/nl_langinfo_l.c b/src/locale/nl_langinfo_l.c
index b54db95..3227d63 100644
--- a/src/locale/nl_langinfo_l.c
+++ b/src/locale/nl_langinfo_l.c
@@ -1,7 +1,10 @@
 #include <locale.h>
 #include <langinfo.h>
+#include "libc.h"
 
-char *nl_langinfo_l(nl_item item, locale_t l)
+char *__nl_langinfo_l(nl_item item, locale_t l)
 {
 	return nl_langinfo(item);
 }
+
+weak_alias(__nl_langinfo_l, nl_langinfo_l);
diff --git a/src/locale/strcoll_l.c b/src/locale/strcoll_l.c
index 7948b0d..2b096db 100644
--- a/src/locale/strcoll_l.c
+++ b/src/locale/strcoll_l.c
@@ -1,7 +1,10 @@
 #include <string.h>
 #include <locale.h>
+#include "libc.h"
 
-int strcoll_l(const char *l, const char *r, locale_t loc)
+int __strcoll_l(const char *l, const char *r, locale_t loc)
 {
 	return strcoll(l, r);
 }
+
+weak_alias(__strcoll_l, strcoll_l);
diff --git a/src/locale/strftime_l.c b/src/locale/strftime_l.c
index 70b2f15..edda89d 100644
--- a/src/locale/strftime_l.c
+++ b/src/locale/strftime_l.c
@@ -1,7 +1,10 @@
 #include <locale.h>
 #include <time.h>
+#include "libc.h"
 
-size_t strftime_l(char *s, size_t n, const char *f, const struct tm *tm, locale_t l)
+size_t __strftime_l(char *s, size_t n, const char *f, const struct tm *tm, locale_t l)
 {
 	return strftime(s, n, f, tm);
 }
+
+weak_alias(__strftime_l, strftime_l);
diff --git a/src/locale/strxfrm_l.c b/src/locale/strxfrm_l.c
index 78e5655..788c350 100644
--- a/src/locale/strxfrm_l.c
+++ b/src/locale/strxfrm_l.c
@@ -1,6 +1,9 @@
 #include <string.h>
+#include "libc.h"
 
-size_t strxfrm_l(char *dest, const char *src, size_t n, locale_t l)
+size_t __strxfrm_l(char *dest, const char *src, size_t n, locale_t l)
 {
 	return strxfrm(dest, src, n);
 }
+
+weak_alias(__strxfrm_l, strxfrm_l);
diff --git a/src/locale/towlower_l.c b/src/locale/towlower_l.c
index 05fcde5..d565316 100644
--- a/src/locale/towlower_l.c
+++ b/src/locale/towlower_l.c
@@ -1,6 +1,9 @@
 #include <wctype.h>
+#include "libc.h"
 
-wint_t towlower_l(wint_t c, locale_t l)
+wint_t __towlower_l(wint_t c, locale_t l)
 {
 	return towlower(c);
 }
+
+weak_alias(__towlower_l, towlower_l);
diff --git a/src/locale/towupper_l.c b/src/locale/towupper_l.c
index aa861ae..f843c4f 100644
--- a/src/locale/towupper_l.c
+++ b/src/locale/towupper_l.c
@@ -1,6 +1,9 @@
 #include <wctype.h>
+#include "libc.h"
 
-wint_t towupper_l(wint_t c, locale_t l)
+wint_t __towupper_l(wint_t c, locale_t l)
 {
 	return towupper(c);
 }
+
+weak_alias(__towupper_l, towupper_l);
diff --git a/src/locale/uselocale.c b/src/locale/uselocale.c
index 9c79957..a1405c5 100644
--- a/src/locale/uselocale.c
+++ b/src/locale/uselocale.c
@@ -1,10 +1,13 @@
 #include "locale_impl.h"
 #include "pthread_impl.h"
+#include "libc.h"
 
-locale_t uselocale(locale_t l)
+locale_t __uselocale(locale_t l)
 {
 	pthread_t self = pthread_self();
 	locale_t old = self->locale;
 	if (l) self->locale = l;
 	return old;
 }
+
+weak_alias(__uselocale, uselocale);
diff --git a/src/locale/wcscoll_l.c b/src/locale/wcscoll_l.c
index f257ec8..bf26372 100644
--- a/src/locale/wcscoll_l.c
+++ b/src/locale/wcscoll_l.c
@@ -1,6 +1,9 @@
 #include <wchar.h>
+#include "libc.h"
 
-int wcscoll_l(const wchar_t *l, const wchar_t *r, locale_t locale)
+int __wcscoll_l(const wchar_t *l, const wchar_t *r, locale_t locale)
 {
 	return wcscoll(l, r);
 }
+
+weak_alias(__wcscoll_l, wcscoll_l);
diff --git a/src/locale/wcsxfrm_l.c b/src/locale/wcsxfrm_l.c
index 831998e..4f47587 100644
--- a/src/locale/wcsxfrm_l.c
+++ b/src/locale/wcsxfrm_l.c
@@ -1,6 +1,9 @@
 #include <wchar.h>
+#include "libc.h"
 
-size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, locale_t locale)
+size_t __wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, locale_t locale)
 {
 	return wcsxfrm(dest, src, n);
 }
+
+weak_alias(__wcsxfrm_l, wcsxfrm_l);
diff --git a/src/locale/wctype_l.c b/src/locale/wctype_l.c
index 01f9c67..d937275 100644
--- a/src/locale/wctype_l.c
+++ b/src/locale/wctype_l.c
@@ -1,6 +1,9 @@
 #include <wctype.h>
+#include "libc.h"
 
-wctype_t wctype_l(const char *s, locale_t l)
+wctype_t __wctype_l(const char *s, locale_t l)
 {
 	return wctype(s);
 }
+
+weak_alias(__wctype_l, wctype_l);

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 7/10] __fcntl
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (4 preceding siblings ...)
  2012-07-23  1:32 ` [PATCH 6/10] Provide private versions of locale/ functions Isaac Dunham
@ 2012-07-23  1:33 ` Isaac Dunham
  2012-07-23  1:36 ` [PATCH 8/10] finite Isaac Dunham
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:33 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice) or trivial
> functions (finite).
> Finally, there are several aliases.

Adds __fcntl.
As previously, this is based on orc's patch.

Isaac Dunham


[-- Attachment #2: 7-__fcntl.diff --]
[-- Type: text/x-patch, Size: 260 bytes --]

diff --git a/src/fcntl/fcntl.c b/src/fcntl/fcntl.c
index fb7806a..3b8f6fd 100644
--- a/src/fcntl/fcntl.c
+++ b/src/fcntl/fcntl.c
@@ -24,3 +24,5 @@ int fcntl(int fd, int cmd, ...)
 	}
 	return syscall(SYS_fcntl, fd, cmd, arg);
 }
+
+weak_alias(fcntl, __fcntl);

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 8/10] finite
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (5 preceding siblings ...)
  2012-07-23  1:33 ` [PATCH 7/10] __fcntl Isaac Dunham
@ 2012-07-23  1:36 ` Isaac Dunham
  2012-07-23  7:58   ` Szabolcs Nagy
  2012-07-23  1:38 ` [PATCH 9/10] GLIBC ABI patches Isaac Dunham
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:36 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 487 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice) or trivial
> functions (finite).
> Finally, there are several aliases.
> 
This provides finite(); it has been split out into finite.c, to avoid
namespace issues.

Isaac Dunham

[-- Attachment #2: 8-finite.diff --]
[-- Type: text/x-patch, Size: 684 bytes --]

diff --git a/include/math.h b/include/math.h
index d732648..7f98f8a 100644
--- a/include/math.h
+++ b/include/math.h
@@ -350,6 +350,10 @@ long double truncl(long double);
 #define MAXFLOAT        3.40282347e+38F
 #endif
 
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int         finite(double);
+#endif
+
 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
 extern int signgam;
 
diff --git a/src/math/finite.c b/src/math/finite.c
new file mode 100644
index 0000000..bf4f70f
--- /dev/null
+++ b/src/math/finite.c
@@ -0,0 +1,11 @@
+#include "libm.h"
+
+#define _BSD_SOURCE
+#include <math.h>
+
+int __finite(double x)
+{
+	return isfinite(x);
+}
+
+weak_alias(__finite, finite);

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (6 preceding siblings ...)
  2012-07-23  1:36 ` [PATCH 8/10] finite Isaac Dunham
@ 2012-07-23  1:38 ` Isaac Dunham
  2012-07-23 15:11   ` Arvid E. Picciani
  2012-07-25 14:12   ` Luca Barbato
  2012-07-23  1:40 ` [PATCH 10/10] More glibc ABI compatability Isaac Dunham
  2012-08-07  2:22 ` [PATCH 1/10] ioperm & iopl Isaac Dunham
  9 siblings, 2 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:38 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 461 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice) or trivial
> functions (finite).
> Finally, there are several aliases.

Just nonsense aliases GNU uses...
Needed for ABI compatability.

Isaac Dunham

[-- Attachment #2: 9-__glibc.diff --]
[-- Type: text/x-patch, Size: 1545 bytes --]

diff --git a/src/select/poll.c b/src/select/poll.c
index f1e73e8..b2f8b00 100644
--- a/src/select/poll.c
+++ b/src/select/poll.c
@@ -6,3 +6,5 @@ int poll(struct pollfd *fds, nfds_t n, int timeout)
 {
 	return syscall_cp(SYS_poll, fds, n, timeout);
 }
+
+weak_alias(poll, __poll);
diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c
index 51fc9b3..155f8ac 100644
--- a/src/stdio/fscanf.c
+++ b/src/stdio/fscanf.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdarg.h>
+#include "libc.h"
 
 int fscanf(FILE *f, const char *fmt, ...)
 {
@@ -10,3 +11,5 @@ int fscanf(FILE *f, const char *fmt, ...)
 	va_end(ap);
 	return ret;
 }
+
+weak_alias(fscanf, __isoc99_fscanf);
diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c
index a1cea69..8c16343 100644
--- a/src/stdio/sscanf.c
+++ b/src/stdio/sscanf.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdarg.h>
+#include "libc.h"
 
 int sscanf(const char *s, const char *fmt, ...)
 {
@@ -10,3 +11,5 @@ int sscanf(const char *s, const char *fmt, ...)
 	va_end(ap);
 	return ret;
 }
+
+weak_alias(sscanf, __isoc99_sscanf);
diff --git a/src/string/strndup.c b/src/string/strndup.c
index 617d27b..b162d8b 100644
--- a/src/string/strndup.c
+++ b/src/string/strndup.c
@@ -1,7 +1,8 @@
 #include <stdlib.h>
 #include <string.h>
+#include "libc.h"
 
-char *strndup(const char *s, size_t n)
+char *__strndup(const char *s, size_t n)
 {
 	size_t l = strnlen(s, n);
 	char *d = malloc(l+1);
@@ -10,3 +11,5 @@ char *strndup(const char *s, size_t n)
 	d[l] = 0;
 	return d;
 }
+
+weak_alias(__strndup, strndup);

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 10/10] More glibc ABI compatability
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (7 preceding siblings ...)
  2012-07-23  1:38 ` [PATCH 9/10] GLIBC ABI patches Isaac Dunham
@ 2012-07-23  1:40 ` Isaac Dunham
  2012-08-07  2:22 ` [PATCH 1/10] ioperm & iopl Isaac Dunham
  9 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-07-23  1:40 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This patch series is basically a reworked version of orc's previous
> patch.
> From what orc said, the first patch should provide enough to build
> Xorg; I haven't tested this yet.
> A few more patches are syscall wrappers (splice) or trivial
> functions (finite).
> Finally, there are several aliases.

This has the __*_internal aliases, for more ABI compatability with
glibc.

Isaac Dunham

[-- Attachment #2: 10-_internal.diff --]
[-- Type: text/x-patch, Size: 1064 bytes --]

diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c
index 1886efa..f923f38 100644
--- a/src/stdlib/strtod.c
+++ b/src/stdlib/strtod.c
@@ -2,6 +2,7 @@
 #include "shgetc.h"
 #include "floatscan.h"
 #include "stdio_impl.h"
+#include "libc.h"
 
 static long double strtox(const char *s, char **p, int prec)
 {
@@ -30,3 +31,5 @@ long double strtold(const char *s, char **p)
 {
 	return strtox(s, p, 2);
 }
+
+weak_alias(strtod, __strtod_internal);
diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c
index 4a949cb..490cf21 100644
--- a/src/stdlib/strtol.c
+++ b/src/stdlib/strtol.c
@@ -1,6 +1,7 @@
 #include "stdio_impl.h"
 #include "intscan.h"
 #include "shgetc.h"
+#include "libc.h"
 
 static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim)
 {
@@ -51,3 +52,8 @@ uintmax_t strtoumax(const char *s, char **p, int base)
 {
 	return strtoull(s, p, base);
 }
+
+weak_alias(strtoll, __strtoll_internal);
+weak_alias(strtol, __strtol_internal);
+weak_alias(strtoul, __strtoul_internal);
+weak_alias(strtoull, __strtoull_internal);

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 8/10] finite
  2012-07-23  1:36 ` [PATCH 8/10] finite Isaac Dunham
@ 2012-07-23  7:58   ` Szabolcs Nagy
  0 siblings, 0 replies; 30+ messages in thread
From: Szabolcs Nagy @ 2012-07-23  7:58 UTC (permalink / raw)
  To: musl

* Isaac Dunham <idunham@lavabit.com> [2012-07-22 18:36:53 -0700]:
> This provides finite(); it has been split out into finite.c, to avoid
> namespace issues.
> 
> Isaac Dunham

btw these symbols declared in freebsd math.h with
bsd visibility:

#define	MAXFLOAT
extern int signgam;
double	j0(double);
double	j1(double);
double	jn(int, double);
double	y0(double);
double	y1(double);
double	yn(int, double);
double	gamma(double);
double	scalb(double, double);
double	drem(double, double);
int	finite(double) __pure2;
int	isnanf(float) __pure2;
double	gamma_r(double, int *);
double	lgamma_r(double, int *);
double	significand(double);
float	dremf(float, float);
int	finitef(float) __pure2;
float	gammaf(float);
float	j0f(float);
float	j1f(float);
float	jnf(int, float);
float	scalbf(float, float);
float	y0f(float);
float	y1f(float);
float	ynf(int, float);
float	gammaf_r(float, int *);
float	lgammaf_r(float, int *);
float	significandf(float);

we might want to fix some of these with the finite change


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-23  1:38 ` [PATCH 9/10] GLIBC ABI patches Isaac Dunham
@ 2012-07-23 15:11   ` Arvid E. Picciani
  2012-07-24 18:15     ` Igmar Palsenberg
  2012-07-25 14:12   ` Luca Barbato
  1 sibling, 1 reply; 30+ messages in thread
From: Arvid E. Picciani @ 2012-07-23 15:11 UTC (permalink / raw)
  To: musl

On Sun, 22 Jul 2012 18:38:28 -0700, Isaac Dunham wrote:

> Just nonsense aliases GNU uses...
> Needed for ABI compatability.

could we mark them as such? at least with a comment.
I really like that musl is so readable. This patch adds some 
obfuscation that can simply be countered by marking it as "ok this is 
only here for reason X."

-- 
Arvid E. Picciani


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/10] xattr syscalls
  2012-07-23  1:21 ` [PATCH 3/10] xattr syscalls Isaac Dunham
@ 2012-07-24 18:06   ` orc
  0 siblings, 0 replies; 30+ messages in thread
From: orc @ 2012-07-24 18:06 UTC (permalink / raw)
  To: musl

On Sun, 22 Jul 2012 18:21:48 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> On Sun, 22 Jul 2012 18:13:32 -0700
> Isaac Dunham <idunham@lavabit.com> wrote:
> 
> > This patch series is basically a reworked version of orc's previous
> > patch.
> > From what orc said, the first patch should provide enough to build
> > Xorg; I haven't tested this yet.
> > A few more patches are syscall wrappers (splice) or trivial
> > functions (finite).
> 
> Here's support for the xattr syscalls. orc probably knows better than
> I what these are needed for...
> 
> Isaac Dunham

They were required by some gtk2 apps when I tested musl and gtk2
'direct' compatibility. It failed, syscalls remained. They were tagged
in my patch as '// Why even libc needs them' comment, then I removed it
and put into final patch just because someone can need it (as happened
with Xorg).


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-23 15:11   ` Arvid E. Picciani
@ 2012-07-24 18:15     ` Igmar Palsenberg
  2012-07-24 18:19       ` Gregor Richards
  0 siblings, 1 reply; 30+ messages in thread
From: Igmar Palsenberg @ 2012-07-24 18:15 UTC (permalink / raw)
  To: musl



>> Just nonsense aliases GNU uses...
>> Needed for ABI compatability.
> 
> could we mark them as such? at least with a comment.
> I really like that musl is so readable. This patch adds some obfuscation that can simply be countered by marking it as "ok this is only here for reason X."

I would like to see those options behind a compile time option : It bloats musl with in many cases unneeded code. I test my compiles with musl, and I like it lean and mean.


Regards,



	Igmar

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-24 18:15     ` Igmar Palsenberg
@ 2012-07-24 18:19       ` Gregor Richards
  2012-07-24 18:23         ` Igmar Palsenberg
  0 siblings, 1 reply; 30+ messages in thread
From: Gregor Richards @ 2012-07-24 18:19 UTC (permalink / raw)
  To: musl

On 07/24/12 14:15, Igmar Palsenberg wrote:
>
>>> Just nonsense aliases GNU uses...
>>> Needed for ABI compatability.
>> could we mark them as such? at least with a comment.
>> I really like that musl is so readable. This patch adds some obfuscation that can simply be countered by marking it as "ok this is only here for reason X."
> I would like to see those options behind a compile time option : It bloats musl with in many cases unneeded code. I test my compiles with musl, and I like it lean and mean.
>
>
> Regards,
>
>
>
> 	Igmar

These are just aliases, not code. There's no bloat there.

One of the advantages of musl is its LACK of configurability: If you 
have “musl”, you know what precisely you're getting.

With valediction,
  - Gregor Richards



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-24 18:19       ` Gregor Richards
@ 2012-07-24 18:23         ` Igmar Palsenberg
  2012-07-24 18:29           ` Gregor Richards
  0 siblings, 1 reply; 30+ messages in thread
From: Igmar Palsenberg @ 2012-07-24 18:23 UTC (permalink / raw)
  To: musl



>>>> Just nonsense aliases GNU uses...
>>>> Needed for ABI compatability.
>>> could we mark them as such? at least with a comment.
>>> I really like that musl is so readable. This patch adds some obfuscation that can simply be countered by marking it as "ok this is only here for reason X."
>> I would like to see those options behind a compile time option : It bloats musl with in many cases unneeded code. I test my compiles with musl, and I like it lean and mean.

> These are just aliases, not code. There's no bloat there.
> 
> One of the advantages of musl is its LACK of configurability: If you have “musl”, you know what precisely you're getting.
> 
> With valediction,
> - Gregor Richards
> 

While I agree with the above, I still have a few objections : 

- We don't want glibc compatibility. We want a good libc.
- That we even need those aliases is usually a case of bad automake / autoconf / bad feature detection.

Why bloat code with stuff to provide glibc compatibility ?


	Igmar

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-24 18:23         ` Igmar Palsenberg
@ 2012-07-24 18:29           ` Gregor Richards
  2012-07-24 18:33             ` Igmar Palsenberg
  0 siblings, 1 reply; 30+ messages in thread
From: Gregor Richards @ 2012-07-24 18:29 UTC (permalink / raw)
  To: musl

On 07/24/12 14:23, Igmar Palsenberg wrote:
>
>>>>> Just nonsense aliases GNU uses...
>>>>> Needed for ABI compatability.
>>>> could we mark them as such? at least with a comment.
>>>> I really like that musl is so readable. This patch adds some obfuscation that can simply be countered by marking it as "ok this is only here for reason X."
>>> I would like to see those options behind a compile time option : It bloats musl with in many cases unneeded code. I test my compiles with musl, and I like it lean and mean.
>> These are just aliases, not code. There's no bloat there.
>>
>> One of the advantages of musl is its LACK of configurability: If you have “musl”, you know what precisely you're getting.
>>
>> With valediction,
>> - Gregor Richards
>>
> While I agree with the above, I still have a few objections :
>
> - We don't want glibc compatibility. We want a good libc.
> - That we even need those aliases is usually a case of bad automake / autoconf / bad feature detection.
>
> Why bloat code with stuff to provide glibc compatibility ?
>
>
> 	Igmar

“That we even need those aliases is usually a case of bad automake / 
autoconf / bad feature detection”

These are for ABI compatibility, not API compatibility. Nobody using 
glibc uses these symbols intentionally, they are renamed and aliased by 
the library. Last I checked, musl is shockingly close to ABI 
compatibility with glibc, and like it or not, that's a valuable feature. 
If you don't like the “bloat” of it, you'll have to dig out a lot of the 
existing aliases too.

With valediction,
  - Gregor Richards



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-24 18:29           ` Gregor Richards
@ 2012-07-24 18:33             ` Igmar Palsenberg
  2012-07-24 23:18               ` Rich Felker
  2012-07-25  7:27               ` Arvid E. Picciani
  0 siblings, 2 replies; 30+ messages in thread
From: Igmar Palsenberg @ 2012-07-24 18:33 UTC (permalink / raw)
  To: musl


>>>>>> Just nonsense aliases GNU uses...
>>>>>> Needed for ABI compatability.
>>>>> could we mark them as such? at least with a comment.
>>>>> I really like that musl is so readable. This patch adds some obfuscation that can simply be countered by marking it as "ok this is only here for reason X."
>>>> I would like to see those options behind a compile time option : It bloats musl with in many cases unneeded code. I test my compiles with musl, and I like it lean and mean.
>>> These are just aliases, not code. There's no bloat there.
>>> 
>>> One of the advantages of musl is its LACK of configurability: If you have “musl”, you know what precisely you're getting.
>>> 
>>> With valediction,
>>> - Gregor Richards
>>> 
>> While I agree with the above, I still have a few objections :
>> 
>> - We don't want glibc compatibility. We want a good libc.
>> - That we even need those aliases is usually a case of bad automake / autoconf / bad feature detection.
>> 
>> Why bloat code with stuff to provide glibc compatibility ?
>> 
>> 
>> 	Igmar
> 
> “That we even need those aliases is usually a case of bad automake / autoconf / bad feature detection”
> 
> These are for ABI compatibility, not API compatibility. Nobody using glibc uses these symbols intentionally, they are renamed and aliased by the library. Last I checked, musl is shockingly close to ABI compatibility with glibc, and like it or not, that's a valuable feature. If you don't like the “bloat” of it, you'll have to dig out a lot of the existing aliases too.

I've seen lots of code who use internal glibc functions / data structures. We want to prevent them from being used, that's why I personally have a problem with adding code like this. Unless it actually serves a real use.



	Igmar

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-24 18:33             ` Igmar Palsenberg
@ 2012-07-24 23:18               ` Rich Felker
  2012-07-25  7:27               ` Arvid E. Picciani
  1 sibling, 0 replies; 30+ messages in thread
From: Rich Felker @ 2012-07-24 23:18 UTC (permalink / raw)
  To: musl

On Tue, Jul 24, 2012 at 08:33:31PM +0200, Igmar Palsenberg wrote:
> >> Why bloat code with stuff to provide glibc compatibility ?
> >> 
> >> 
> >> 	Igmar
> > 
> > “That we even need those aliases is usually a case of bad automake
> > / autoconf / bad feature detection”
> > 
> > These are for ABI compatibility, not API compatibility. Nobody
> > using glibc uses these symbols intentionally, they are renamed and
> > aliased by the library. Last I checked, musl is shockingly close
> > to ABI compatibility with glibc, and like it or not, that's a
> > valuable feature. If you don't like the “bloat” of it, you'll have
> > to dig out a lot of the existing aliases too.
> 
> I've seen lots of code who use internal glibc functions / data
> structures. We want to prevent them from being used, that's why I
> personally have a problem with adding code like this. Unless it
> actually serves a real use.

OK, let me clarify a bit of musl's policy about glibc compatibility.
The intent is that programs or .o files built against glibc headers
and linked against glibc libc.so should work on musl as long as they
are conforming C/POSIX programs or programs which just use nonstandard
but widely available functions provided by musl and which are
otherwise conforming C/POSIX programs. There's no explicit goal of
supporting glibc programs which are poking at glibc internals (like
the stdio hacks in gnulib) or otherwise dependent on the way glibc
implements a particular interface, since one of the major goals of
musl is to be able to drop and replace the internals of any interface
with a new/better implementation without breaking programs linked
against musl libc.so.

To achieve the above level of glibc ABI compatibility, it's necessary
to provide a minimal set of symbols not specified by C or POSIX but
which glibc uses for implementing things specified by C or POSIX. One
good example is the __isoc99_*scanf functions. Since glibc's plain
*scanf functions are nonconformant, building against glibc with
-std=c99 causes the program to use the __isoc99_*scanf functions
instead. This is not a glibc-specific hack in the program but instead
a hack induced by the glibc header files. There's also minimal cost in
supporting it; it's just an extra symbol in the global symbol table,
no extra code. Other examples are the *64 functions for 64-bit off_t
support. An example where there is some actual code/data bloat is the
tables used for implementing ctype.h is*() functions. I added these
with some hesitation, but unfortunately they're necessary to be able
to run any conforming C program that was built against glibc which
happens to use ctype.h, and thankfully they're not too big.

With that said, there's also some benefit to being able to use nasty
binaryware video drivers that were built against glibc, specifically
the nvidia junk. I'm not a fan (personally, I would never buy an
nvidia card until their policies change, and even then I'd be hesitant
to buy the watt-guzzling SUV of video cards...) but many people have
them and want to use them, and being able to get the driver working
with musl is quite a nice hack. So if we can provide the symbols or a
minimal amount of compatibility glue to make these drivers work, I
think it's worthwhile to do so.

Rich


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-24 18:33             ` Igmar Palsenberg
  2012-07-24 23:18               ` Rich Felker
@ 2012-07-25  7:27               ` Arvid E. Picciani
  1 sibling, 0 replies; 30+ messages in thread
From: Arvid E. Picciani @ 2012-07-25  7:27 UTC (permalink / raw)
  To: musl

On Tue, 24 Jul 2012 20:33:31 +0200, Igmar Palsenberg wrote:

> I've seen lots of code who use internal glibc functions / data
> structures. We want to prevent them from being used, that's why I
> personally have a problem with adding code like this. Unless it
> actually serves a real use.

That was sort of the point of making it an alias, i think.
Code that uses it still doesn't compile, but if it was compiled with 
gnulibc headers it at least links against musl.
This satisfies both requirements of "musl should encourage standards 
compliance" and "musl should be able to run nvidia drivers"

I just want it to also satisfy "musl code should serve as reference 
implementation of a standards compliant libc", which it doesnt
if gnu compatibility code is mixed in indifferent.

-- 
Arvid E. Picciani


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-23  1:38 ` [PATCH 9/10] GLIBC ABI patches Isaac Dunham
  2012-07-23 15:11   ` Arvid E. Picciani
@ 2012-07-25 14:12   ` Luca Barbato
  2012-07-25 15:19     ` Rich Felker
  1 sibling, 1 reply; 30+ messages in thread
From: Luca Barbato @ 2012-07-25 14:12 UTC (permalink / raw)
  To: musl

On 07/23/2012 03:38 AM, Isaac Dunham wrote:
> +weak_alias(poll, __poll);

> +weak_alias(fscanf, __isoc99_fscanf);

> +weak_alias(sscanf, __isoc99_sscanf);

> -char *strndup(const char *s, size_t n)
> +char *__strndup(const char *s, size_t n)

> +weak_alias(__strndup, strndup);

Why strndup is different?

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-25 14:12   ` Luca Barbato
@ 2012-07-25 15:19     ` Rich Felker
  2012-07-25 15:52       ` Luca Barbato
  2012-07-25 23:06       ` idunham
  0 siblings, 2 replies; 30+ messages in thread
From: Rich Felker @ 2012-07-25 15:19 UTC (permalink / raw)
  To: musl

On Wed, Jul 25, 2012 at 04:12:59PM +0200, Luca Barbato wrote:
> On 07/23/2012 03:38 AM, Isaac Dunham wrote:
> > +weak_alias(poll, __poll);
> 
> > +weak_alias(fscanf, __isoc99_fscanf);
> 
> > +weak_alias(sscanf, __isoc99_sscanf);
> 
> > -char *strndup(const char *s, size_t n)
> > +char *__strndup(const char *s, size_t n)
> 
> > +weak_alias(__strndup, strndup);
> 
> Why strndup is different?

I think the idea is that we might want to use __strndup internally in
functions which can't expose the strndup name. However, as we haven't
yet had a need for that, I suspect it's unlikely. Also, __strndup
isn't really an ugly name (it makes sense as the "internal" name for
strndup if such usage were needed), but __isoc99_scanf is a huge WTF
unless you know the reason it exists in glibc (and then it just makes
you hate glibc even more...).

With that said, for now I'd probably prefer to keep plain strndup as
the "real" name.

Rich


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-25 15:19     ` Rich Felker
@ 2012-07-25 15:52       ` Luca Barbato
  2012-07-25 17:35         ` Rich Felker
  2012-07-25 23:06       ` idunham
  1 sibling, 1 reply; 30+ messages in thread
From: Luca Barbato @ 2012-07-25 15:52 UTC (permalink / raw)
  To: musl

On 07/25/2012 05:19 PM, Rich Felker wrote:
> On Wed, Jul 25, 2012 at 04:12:59PM +0200, Luca Barbato wrote:
>> On 07/23/2012 03:38 AM, Isaac Dunham wrote:
>>> +weak_alias(poll, __poll);
>>
>>> +weak_alias(fscanf, __isoc99_fscanf);
>>
>>> +weak_alias(sscanf, __isoc99_sscanf);
>>
>>> -char *strndup(const char *s, size_t n)
>>> +char *__strndup(const char *s, size_t n)
>>
>>> +weak_alias(__strndup, strndup);
>>
>> Why strndup is different?
> 
> I think the idea is that we might want to use __strndup internally in
> functions which can't expose the strndup name. However, as we haven't
> yet had a need for that, I suspect it's unlikely. Also, __strndup
> isn't really an ugly name (it makes sense as the "internal" name for
> strndup if such usage were needed), but __isoc99_scanf is a huge WTF
> unless you know the reason it exists in glibc (and then it just makes
> you hate glibc even more...).

Would be nice make all those alias consistent, might be interesting see
if linker scripts could be use for similar purposes, keeping the core
code cleaner.

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-25 15:52       ` Luca Barbato
@ 2012-07-25 17:35         ` Rich Felker
  0 siblings, 0 replies; 30+ messages in thread
From: Rich Felker @ 2012-07-25 17:35 UTC (permalink / raw)
  To: musl

On Wed, Jul 25, 2012 at 05:52:46PM +0200, Luca Barbato wrote:
> > I think the idea is that we might want to use __strndup internally in
> > functions which can't expose the strndup name. However, as we haven't
> > yet had a need for that, I suspect it's unlikely. Also, __strndup
> > isn't really an ugly name (it makes sense as the "internal" name for
> > strndup if such usage were needed), but __isoc99_scanf is a huge WTF
> > unless you know the reason it exists in glibc (and then it just makes
> > you hate glibc even more...).
> 
> Would be nice make all those alias consistent, might be interesting see
> if linker scripts could be use for similar purposes, keeping the core
> code cleaner.

Considering that the linker is never run on the static library that
would be rather difficult. Even if it were possible, I think it would
just subtract a trivial amount of cruft that's easy to ignore from the
.c files at the expense of making the build system much uglier and
more GNU-binutils-dependent.

If lots of people think it's confusing having a mix of aliases that
are for internal/legitimate purposes and for ugly ABI purposes, I
either add comments to all the ABI-only ones that they can be ignored
by somebody reading the source, or I could do something like the LFS64
macros and have a separate macro for the ABI-only aliases that would
be self-documenting of their purpose and that could be nulled out by
extremists who want them gone...

Rich


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-25 15:19     ` Rich Felker
  2012-07-25 15:52       ` Luca Barbato
@ 2012-07-25 23:06       ` idunham
  1 sibling, 0 replies; 30+ messages in thread
From: idunham @ 2012-07-25 23:06 UTC (permalink / raw)
  To: musl

> On Wed, Jul 25, 2012 at 04:12:59PM +0200, Luca Barbato wrote:
>> On 07/23/2012 03:38 AM, Isaac Dunham wrote:
>> > +weak_alias(poll, __poll);
>>
>> > +weak_alias(fscanf, __isoc99_fscanf);
>>
>> > +weak_alias(sscanf, __isoc99_sscanf);
>>
>> > -char *strndup(const char *s, size_t n)
>> > +char *__strndup(const char *s, size_t n)
>>
>> > +weak_alias(__strndup, strndup);
>>
>> Why strndup is different?
>
> I think the idea is that we might want to use __strndup internally in
> functions which can't expose the strndup name.

Precisely.

> However, as we haven't
> yet had a need for that, I suspect it's unlikely. Also, __strndup
> isn't really an ugly name (it makes sense as the "internal" name for
> strndup if such usage were needed), but __isoc99_scanf is a huge WTF
> unless you know the reason it exists in glibc (and then it just makes
> you hate glibc even more...).
>
> With that said, for now I'd probably prefer to keep plain strndup as
> the "real" name.

OK.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/10] ioperm & iopl
  2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
                   ` (8 preceding siblings ...)
  2012-07-23  1:40 ` [PATCH 10/10] More glibc ABI compatability Isaac Dunham
@ 2012-08-07  2:22 ` Isaac Dunham
  2012-08-07  3:29   ` Isaac Dunham
  9 siblings, 1 reply; 30+ messages in thread
From: Isaac Dunham @ 2012-08-07  2:22 UTC (permalink / raw)
  To: musl

On Sun, 22 Jul 2012 18:13:32 -0700
Isaac Dunham <idunham@lavabit.com> wrote:

> This adds ioperm & iopl along with io.h, though a full io.h has
> several more syscalls.

I've been looking into some fixes for the current state, and have a few
questions...

1. These are only appropriate on PC arches (plus a few old PC-like
systems, like Alpha). However, they are C, so make doesn't build them.
Should I add a per-arch *.c rule to the Makefile? (this seems better to
me than adding an #ifdef and building an empty file on other arches)

2.  To add per-arch headers in include/sys/, should I 
mkdir arch/${ARCH}/sys/
?
Will this require changing the makefile?

3.  I'm thinking to copy in the macros, and would like a few tips on
style:
-I assume I should delete needless comments such as 
/* Basic I/O macros */
..
#endif /* _SYS_IO_H */

-static inline or static ?

Thanks,
Isaac Dunham



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/10] ioperm & iopl
  2012-08-07  2:22 ` [PATCH 1/10] ioperm & iopl Isaac Dunham
@ 2012-08-07  3:29   ` Isaac Dunham
  0 siblings, 0 replies; 30+ messages in thread
From: Isaac Dunham @ 2012-08-07  3:29 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]


Per conversation on IRC, here's a patch that moves everything of
importance from sys/io.h to bits/io.h.

bits/io.h is based on klibc sys/io.h, in this case.

Isaac Dunham

[-- Attachment #2: fix-io_h.diff --]
[-- Type: text/x-patch, Size: 9147 bytes --]

diff --git a/arch/i386/bits/io.h b/arch/i386/bits/io.h
new file mode 100644
index 0000000..1a81e56
--- /dev/null
+++ b/arch/i386/bits/io.h
@@ -0,0 +1,154 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ *   Permission is hereby granted, free of charge, to any person
+ *   obtaining a copy of this software and associated documentation
+ *   files (the "Software"), to deal in the Software without
+ *   restriction, including without limitation the rights to use,
+ *   copy, modify, merge, publish, distribute, sublicense, and/or
+ *   sell copies of the Software, and to permit persons to whom
+ *   the Software is furnished to do so, subject to the following
+ *   conditions:
+ *
+ *   The above copyright notice and this permission notice shall
+ *   be included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef _BITS_IO_H
+#define _BITS_IO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outb(unsigned char __v, unsigned short __p)
+{
+	asm volatile ("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outw(unsigned short __v, unsigned short __p)
+{
+	asm volatile ("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outl(unsigned int __v, unsigned short __p)
+{
+	asm volatile ("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static unsigned char inb(unsigned short __p)
+{
+	unsigned char __v;
+	asm volatile ("inb %1,%0" : "=a" (__v) : "dN" (__p));
+	return __v;
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static unsigned short inw(unsigned short __p)
+{
+	unsigned short __v;
+	asm volatile ("inw %1,%0" : "=a" (__v) : "dN" (__p));
+	return __v;
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static unsigned int inl(unsigned short __p)
+{
+	unsigned int __v;
+	asm volatile ("inl %1,%0" : "=a" (__v) : "dN" (__p));
+	return __v;
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outsb(unsigned short __p, const void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; outsb"
+		      : "+S" (__d), "+c" (__n)
+		      : "d" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outsw(unsigned short __p, const void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; outsw"
+		      : "+S" (__d), "+c" (__n)
+		      : "d" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outsl(unsigned short __p, const void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; outsl"
+		      : "+S" (__d), "+c"(__n)
+		      : "d" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void insb(unsigned short __p, void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; insb"
+		      : "+D" (__d), "+c" (__n)
+		      : "d" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void insw(unsigned short __p, void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; insw"
+		      : "+D" (__d), "+c" (__n)
+		      : "d" (__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void insl(unsigned short __p, void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; insl"
+		      : "+D" (__d), "+c" (__n)
+		      : "d" (__p));
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/arch/x86_64/bits/io.h b/arch/x86_64/bits/io.h
new file mode 100644
index 0000000..9d16816
--- /dev/null
+++ b/arch/x86_64/bits/io.h
@@ -0,0 +1,149 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ *   Permission is hereby granted, free of charge, to any person
+ *   obtaining a copy of this software and associated documentation
+ *   files (the "Software"), to deal in the Software without
+ *   restriction, including without limitation the rights to use,
+ *   copy, modify, merge, publish, distribute, sublicense, and/or
+ *   sell copies of the Software, and to permit persons to whom
+ *   the Software is furnished to do so, subject to the following
+ *   conditions:
+ *
+ *   The above copyright notice and this permission notice shall
+ *   be included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef _BITS_IO_H
+#define _BITS_IO_H
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outb(unsigned char __v, unsigned short __p)
+{
+	asm volatile ("outb %0,%1" : : "a" (__v), "dN"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outw(unsigned short __v, unsigned short __p)
+{
+	asm volatile ("outw %0,%1" : : "a" (__v), "dN"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outl(unsigned int __v, unsigned short __p)
+{
+	asm volatile ("outl %0,%1" : : "a" (__v), "dN"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static unsigned char inb(unsigned short __p)
+{
+	unsigned char __v;
+	asm volatile ("inb %1,%0" : "=a" (__v) : "dN"(__p));
+	return __v;
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static unsigned short inw(unsigned short __p)
+{
+	unsigned short __v;
+	asm volatile ("inw %1,%0" : "=a" (__v) : "dN"(__p));
+	return __v;
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static unsigned int inl(unsigned short __p)
+{
+	unsigned int __v;
+	asm volatile ("inl %1,%0" : "=a" (__v) : "dN"(__p));
+	return __v;
+}
+
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outsb(unsigned short __p, const void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; outsb"
+		      : "+S" (__d), "+c"(__n)
+		      : "d"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outsw(unsigned short __p, const void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; outsw"
+		      : "+S" (__d), "+c"(__n)
+		      : "d"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void outsl(unsigned short __p, const void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; outsl"
+		      : "+S" (__d), "+c"(__n)
+		      : "d"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void insb(unsigned short __p, void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; insb"
+		      : "+D" (__d), "+c"(__n)
+		      : "d"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void insw(unsigned short __p, void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; insw"
+		      : "+D" (__d), "+c"(__n)
+		      : "d"(__p));
+}
+
+#if __STDC_VERSION__ >= 199901L
+inline
+#endif
+static void insl(unsigned short __p, void *__d, unsigned long __n)
+{
+	asm volatile ("cld; rep; insl"
+		      : "+D" (__d), "+c"(__n)
+		      : "d"(__p));
+}
+
+#endif
diff --git a/include/sys/io.h b/include/sys/io.h
index a6ba467..6a7c442 100644
--- a/include/sys/io.h
+++ b/include/sys/io.h
@@ -1,13 +1,7 @@
 #ifndef	_SYS_IO_H
 #define	_SYS_IO_H
-#ifdef __cplusplus
-extern "C" {
-#endif
 
-int ioperm(unsigned long, unsigned long, int);
-int iopl(int);
+#include <bits/io.h>
 
-#ifdef __cplusplus
-}
 #endif
 #endif
diff --git a/src/linux/ioperm.c b/src/linux/ioperm.c
index 6d7c37d..08c6d8b 100644
--- a/src/linux/ioperm.c
+++ b/src/linux/ioperm.c
@@ -1,7 +1,8 @@
-#include <sys/io.h>
 #include "syscall.h"
 
 #ifdef SYS_ioperm
+#include <sys/io.h>
+
 int ioperm(unsigned long from, unsigned long num, int turn_on)
 {
 	return syscall(SYS_ioperm, from, num, turn_on);
diff --git a/src/linux/iopl.c b/src/linux/iopl.c
index 5a626e1..835d3d4 100644
--- a/src/linux/iopl.c
+++ b/src/linux/iopl.c
@@ -1,7 +1,8 @@
-#include <sys/io.h>
 #include "syscall.h"
 
 #ifdef SYS_iopl
+#include <sys/io.h>
+
 int iopl(int level)
 {
 	return syscall(SYS_iopl, level);

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-25 15:06 ` Rich Felker
@ 2012-07-25 22:19   ` Luca Barbato
  0 siblings, 0 replies; 30+ messages in thread
From: Luca Barbato @ 2012-07-25 22:19 UTC (permalink / raw)
  To: musl

On 07/25/2012 05:06 PM, Rich Felker wrote:
> On Tue, Jul 24, 2012 at 11:00:54PM -0400, idunham@lavabit.com wrote:
>> Rich:
>> I have three questions:
>>
>> 1. Should it be possible to weak_alias an externally defined function?
>> ie, src/stdlib/strtod.c defines strtod, then src/glibc-abi/stdlib.c goes:
>> #include "libc.h"
>> #include <stdlib.h>
>> weak_alias(strtod, __strtod_internal)
> 
> This is not possible the way traditional assemblers/linkers work. You
> can make a wrapper function but that adds bloat and has a runtime
> performance cost if the wrapper is used.

The only way I can see to keep them apart of the code is moving them in
an header and conditionally include them when compatibility is enabled
at builtime. Not sure if it would worth it.

>> 3. Would a subdirectory of src/ solely for glibc ABI/API compatability be
>> appropriate?
>> The point would be to allow removing gnuish extensions without too much
>> trouble.
>> Even if 1 or 2 mean that weak_alias stuff goes in the same file, this
>> could contain functions like the ones added for gnulib (src/stdio/ext*.c).
> 
> I think that's confusing matters. The ones added for gnulib are not
> for glibc compatibility; glibc does not even have them. They're added
> so that gnulib will not attempt to poke at musl internals and generate
> musl-version-specific binaries which would crash on different musl
> versions. Removing them is a very bad idea. Moreover on i386 they're
> 55 bytes of code. Removing something like that for space savings is on
> the same order of ridiculousness as some of busybox's optimizations...

And probably leaving a note for the poor soul really needing to shave
those last 55/100 bytes would be enough.

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
  2012-07-25  3:00 [PATCH 9/10] GLIBC ABI patches idunham
@ 2012-07-25 15:06 ` Rich Felker
  2012-07-25 22:19   ` Luca Barbato
  0 siblings, 1 reply; 30+ messages in thread
From: Rich Felker @ 2012-07-25 15:06 UTC (permalink / raw)
  To: musl

On Tue, Jul 24, 2012 at 11:00:54PM -0400, idunham@lavabit.com wrote:
> Rich:
> I have three questions:
> 
> 1. Should it be possible to weak_alias an externally defined function?
> ie, src/stdlib/strtod.c defines strtod, then src/glibc-abi/stdlib.c goes:
> #include "libc.h"
> #include <stdlib.h>
> weak_alias(strtod, __strtod_internal)

This is not possible the way traditional assemblers/linkers work. You
can make a wrapper function but that adds bloat and has a runtime
performance cost if the wrapper is used.

> 2. Would this result in obfustication of the source?

I'm not sure.

> 3. Would a subdirectory of src/ solely for glibc ABI/API compatability be
> appropriate?
> The point would be to allow removing gnuish extensions without too much
> trouble.
> Even if 1 or 2 mean that weak_alias stuff goes in the same file, this
> could contain functions like the ones added for gnulib (src/stdio/ext*.c).

I think that's confusing matters. The ones added for gnulib are not
for glibc compatibility; glibc does not even have them. They're added
so that gnulib will not attempt to poke at musl internals and generate
musl-version-specific binaries which would crash on different musl
versions. Removing them is a very bad idea. Moreover on i386 they're
55 bytes of code. Removing something like that for space savings is on
the same order of ridiculousness as some of busybox's optimizations...

Rich


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 9/10] GLIBC ABI patches
@ 2012-07-25  3:00 idunham
  2012-07-25 15:06 ` Rich Felker
  0 siblings, 1 reply; 30+ messages in thread
From: idunham @ 2012-07-25  3:00 UTC (permalink / raw)
  To: musl

>
>>>>>>> Just nonsense aliases GNU uses...
>>>>>>> Needed for ABI compatability.
>>>>>> could we mark them as such? at least with a comment.
>>>>>> I really like that musl is so readable. This patch adds some
>>>>>> obfuscation that can simply be countered by marking it as "ok this
>>>>>> is only here for reason X."
>>>>> I would like to see those options behind a compile time option : It
>>>>> bloats musl with in many cases unneeded code. I test my compiles with
>>>>> musl, and I like it lean and mean.
>>>> These are just aliases, not code. There's no bloat there.
>>>>
>>>> One of the advantages of musl is its LACK of configurability: If you
>>>> have *musl*, you know what precisely you're getting.
>>>>
>>>> With valediction,
>>>> - Gregor Richards
>>>>
>>> While I agree with the above, I still have a few objections :
>>>
>>> - We don't want glibc compatibility. We want a good libc.
>>> - That we even need those aliases is usually a case of bad automake /
>>> autoconf / bad feature detection.
>>>
>>> Why bloat code with stuff to provide glibc compatibility ?
>>>
>>>
>>> 	Igmar
>>
>> These are for ABI compatibility, not API compatibility. Nobody using
>> glibc uses these symbols intentionally, they are renamed and aliased by
>> the library. Last I checked, musl is shockingly close to ABI
>> compatibility with glibc, and like it or not, that's a valuable feature.
>> If you don't like the *bloat* of it, you'll have to dig out a lot of the
>> existing aliases too.
>
> I've seen lots of code who use internal glibc functions / data structures.
> We want to prevent them from being used, that's why I personally have a
> problem with adding code like this. Unless it actually serves a real use.
>
> 	Igmar

The real use here, from what orc was saying, is running the proprietary
nvidia driver on a musl-based system.

Rich:
I have three questions:

1. Should it be possible to weak_alias an externally defined function?
ie, src/stdlib/strtod.c defines strtod, then src/glibc-abi/stdlib.c goes:
#include "libc.h"
#include <stdlib.h>
weak_alias(strtod, __strtod_internal)
2. Would this result in obfustication of the source?
3. Would a subdirectory of src/ solely for glibc ABI/API compatability be
appropriate?
The point would be to allow removing gnuish extensions without too much
trouble.
Even if 1 or 2 mean that weak_alias stuff goes in the same file, this
could contain functions like the ones added for gnulib (src/stdio/ext*.c).

Isaac Dunham




^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2012-08-07  3:29 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-23  1:13 [PATCH 1/10] ioperm & iopl Isaac Dunham
2012-07-23  1:17 ` [PATCH 2/10] splice Isaac Dunham
2012-07-23  1:21 ` [PATCH 3/10] xattr syscalls Isaac Dunham
2012-07-24 18:06   ` orc
2012-07-23  1:24 ` [PATCH 4/10] pipe2 Isaac Dunham
2012-07-23  1:28 ` [PATCH 5/10] __sigsetjmp alias Isaac Dunham
2012-07-23  1:32 ` [PATCH 6/10] Provide private versions of locale/ functions Isaac Dunham
2012-07-23  1:33 ` [PATCH 7/10] __fcntl Isaac Dunham
2012-07-23  1:36 ` [PATCH 8/10] finite Isaac Dunham
2012-07-23  7:58   ` Szabolcs Nagy
2012-07-23  1:38 ` [PATCH 9/10] GLIBC ABI patches Isaac Dunham
2012-07-23 15:11   ` Arvid E. Picciani
2012-07-24 18:15     ` Igmar Palsenberg
2012-07-24 18:19       ` Gregor Richards
2012-07-24 18:23         ` Igmar Palsenberg
2012-07-24 18:29           ` Gregor Richards
2012-07-24 18:33             ` Igmar Palsenberg
2012-07-24 23:18               ` Rich Felker
2012-07-25  7:27               ` Arvid E. Picciani
2012-07-25 14:12   ` Luca Barbato
2012-07-25 15:19     ` Rich Felker
2012-07-25 15:52       ` Luca Barbato
2012-07-25 17:35         ` Rich Felker
2012-07-25 23:06       ` idunham
2012-07-23  1:40 ` [PATCH 10/10] More glibc ABI compatability Isaac Dunham
2012-08-07  2:22 ` [PATCH 1/10] ioperm & iopl Isaac Dunham
2012-08-07  3:29   ` Isaac Dunham
2012-07-25  3:00 [PATCH 9/10] GLIBC ABI patches idunham
2012-07-25 15:06 ` Rich Felker
2012-07-25 22:19   ` Luca Barbato

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).