Dan Fandrich | 1 Jun 2011 10:28
Favicon

Re: [PATCH 2/2] Added support for compiling against Android bionic

On Tue, May 31, 2011 at 08:42:50AM -0400, Rich Felker wrote:
> On Mon, May 30, 2011 at 11:14:35PM -0700, Dan Fandrich wrote:
> Sadly it looks like ttyname might also be missing. It's easily
> implemented via readlink on /proc/self/fd/%d though, or some ioctl or
> fstat to get the device/tty number.

If it's just a stub, and newer versions of Android also provide a
ttyname_r stub, then I'll just drop that part of the patch.

> > Is PAGE_SIZE mandated somewhere to be defined in limits.h? I tried
> > glibc, uclibc, libc5 and OpenWatcom (all on Linux) and none of them
> > defines it in limits.h.
> 
> If it's a constant, it's supposed to be defined there. If not, it
> should not be defined anywhere. Unfortunately some bloatware fans are
> into this whole "large pages" movement and want it considered
> variable...

It does look like Walter Harms' suggestion of using sysconf() is the most
portable way of getting this value. The attached patch makes that change.

> > The conditional in networking/interface.c isn't as obvious. I tried removing
> > the UCLIBC clause altogether and it still compiled fine in uClibc 0.6.29,
> > so perhaps it dates from an earlier version and could just be removed now.
> 
> I suspect so. That would be nice...

I'll remove that as well and see if anyone complains. There are a number
of other files that conditionally include net/ethernet.h (and usually
netpacket/packet.h) only on newer glibc versions, so I'll switch
(Continue reading)

walter harms | 1 Jun 2011 11:59
Picon
Favicon

Re: [PATCH 2/2] Added support for compiling against Android bionic


Am 01.06.2011 10:28, schrieb Dan Fandrich:
> On Tue, May 31, 2011 at 08:42:50AM -0400, Rich Felker wrote:
>> On Mon, May 30, 2011 at 11:14:35PM -0700, Dan Fandrich wrote:
>> Sadly it looks like ttyname might also be missing. It's easily
>> implemented via readlink on /proc/self/fd/%d though, or some ioctl or
>> fstat to get the device/tty number.
> 
> If it's just a stub, and newer versions of Android also provide a
> ttyname_r stub, then I'll just drop that part of the patch.
> 
>>> Is PAGE_SIZE mandated somewhere to be defined in limits.h? I tried
>>> glibc, uclibc, libc5 and OpenWatcom (all on Linux) and none of them
>>> defines it in limits.h.
>>
>> If it's a constant, it's supposed to be defined there. If not, it
>> should not be defined anywhere. Unfortunately some bloatware fans are
>> into this whole "large pages" movement and want it considered
>> variable...
> 
> It does look like Walter Harms' suggestion of using sysconf() is the most
> portable way of getting this value. The attached patch makes that change.
> 
>>> The conditional in networking/interface.c isn't as obvious. I tried removing
>>> the UCLIBC clause altogether and it still compiled fine in uClibc 0.6.29,
>>> so perhaps it dates from an earlier version and could just be removed now.
>>
>> I suspect so. That would be nice...
> 
> I'll remove that as well and see if anyone complains. There are a number
(Continue reading)

Tito | 1 Jun 2011 13:54
Picon
Favicon

Re: [PATCH 2/2] Added support for compiling against Android bionic


On Wednesday 01 June 2011 10:28:26 Dan Fandrich wrote:
> On Tue, May 31, 2011 at 08:42:50AM -0400, Rich Felker wrote:
> > On Mon, May 30, 2011 at 11:14:35PM -0700, Dan Fandrich wrote:
> > Sadly it looks like ttyname might also be missing. It's easily
> > implemented via readlink on /proc/self/fd/%d though, or some ioctl or
> > fstat to get the device/tty number.
> 
> If it's just a stub, and newer versions of Android also provide a
> ttyname_r stub, then I'll just drop that part of the patch.
> 
> > > Is PAGE_SIZE mandated somewhere to be defined in limits.h? I tried
> > > glibc, uclibc, libc5 and OpenWatcom (all on Linux) and none of them
> > > defines it in limits.h.
> > 
> > If it's a constant, it's supposed to be defined there. If not, it
> > should not be defined anywhere. Unfortunately some bloatware fans are
> > into this whole "large pages" movement and want it considered
> > variable...
> 
> It does look like Walter Harms' suggestion of using sysconf() is the most
> portable way of getting this value. The attached patch makes that change.

Why don't you just include #include <asm/page.h>
as android's sysconf.c does?
Tito

> 
> > > The conditional in networking/interface.c isn't as obvious. I tried removing
> > > the UCLIBC clause altogether and it still compiled fine in uClibc 0.6.29,
(Continue reading)

Dan Fandrich | 1 Jun 2011 18:21
Favicon

Re: [PATCH 2/2] Added support for compiling against Android bionic

On Wed, Jun 01, 2011 at 11:59:46AM +0200, walter harms wrote:
> I have no idea how common _sc_pagesize is.
> perhaps you should protect that _sc_pagesize like:
> 
> #ifndef PAGE_SIZE
> #ifndef _sc_pagesize
> # error "no way to find your PAGE_SIZE"
> #endif
> 
> #define PAGE_SIZE { sysconf(_sc_pagesize): }

I could do something like that, but sysconf() is in POSIX.1-2001, but
PAGE_SIZE has at least the problem that it's PAGESIZE on some systems.
PAGE_SIZE is also not necessarily accurate on systems where the page size
is dynamic. Always using sysconf seems the best approach, except for the
cost of a few extra bytes for the extra function call.

On Wed, Jun 01, 2011 at 01:54:14PM +0200, Tito wrote:
> Why don't you just include #include <asm/page.h>
> as android's sysconf.c does?

I'm trying to avoid special-casing this for various systems by using a
standards-based approach instead.

>>> Dan
Rich Felker | 1 Jun 2011 21:06

Re: [PATCH 2/2] Added support for compiling against Android bionic

On Wed, Jun 01, 2011 at 01:54:14PM +0200, Tito wrote:
> > It does look like Walter Harms' suggestion of using sysconf() is the most
> > portable way of getting this value. The attached patch makes that change.
> 
> Why don't you just include #include <asm/page.h>

asm/* is absolutely not portable and should never be included from
userspace, unless a system header includes it indirectly.

Rich
Rich Felker | 1 Jun 2011 21:07

Re: [PATCH 2/2] Added support for compiling against Android bionic

On Wed, Jun 01, 2011 at 09:21:27AM -0700, Dan Fandrich wrote:
> On Wed, Jun 01, 2011 at 11:59:46AM +0200, walter harms wrote:
> > I have no idea how common _sc_pagesize is.
> > perhaps you should protect that _sc_pagesize like:
> > 
> > #ifndef PAGE_SIZE
> > #ifndef _sc_pagesize
> > # error "no way to find your PAGE_SIZE"
> > #endif
> > 
> > #define PAGE_SIZE { sysconf(_sc_pagesize): }
> 
> I could do something like that, but sysconf() is in POSIX.1-2001, but
> PAGE_SIZE has at least the problem that it's PAGESIZE on some systems.
> PAGE_SIZE is also not necessarily accurate on systems where the page size
> is dynamic. Always using sysconf seems the best approach, except for the
> cost of a few extra bytes for the extra function call.

BTW the correct argument to sysconf is _SC_PAGESIZE, not _sc_pagesize.

Rich
Dan Fandrich | 1 Jun 2011 22:34
Favicon

[PATCH 0/5] Added support for compiling against Android bionic

I've taken the comments made here and refactored my Android support patch
into five, none of which are Android-specific until the last, which just
adds an Android section to platform.h.

Someone here suggested a few months ago making known-working defconfig files
for various platforms available in the Busybox source tree to use as 
starting points.  Android is another platform where that would be useful,
as bionic fails to supply quite a few functions and header files that are
included in larger libcs. To be fair, bionic isn't designed as a general-
purpose replacement for glibc, but it does take some trial-and-error to
get a config file that works.

>>> Dan
Dan Fandrich | 1 Jun 2011 22:34
Favicon

[PATCH 1/5] Replace nonstandard unsigned typedefs

Signed-off-by: Dan Fandrich <dan <at> coneharvesters.com>
---
 util-linux/ipcs.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index 33035c6..ee7df5e 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
 <at>  <at>  -55,11 +55,11  <at>  <at> 
 #define SHM_INFO        14
 struct shm_info {
 	int used_ids;
-	ulong shm_tot;		/* total allocated shm */
-	ulong shm_rss;		/* total resident shm */
-	ulong shm_swp;		/* total swapped shm */
-	ulong swap_attempts;
-	ulong swap_successes;
+	unsigned long shm_tot;		/* total allocated shm */
+	unsigned long shm_rss;		/* total resident shm */
+	unsigned long shm_swp;		/* total swapped shm */
+	unsigned long swap_attempts;
+	unsigned long swap_successes;
 };
 #endif

 <at>  <at>  -267,7 +267,7  <at>  <at>  static NOINLINE void do_sem(void)
 	struct passwd *pw;
 	union semun arg;

(Continue reading)

Dan Fandrich | 1 Jun 2011 22:35
Favicon

[PATCH 2/5] Only compile obscure.c when needed

Signed-off-by: Dan Fandrich <dan <at> coneharvesters.com>
---
 libbb/Kbuild.src |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index fa6e5b6..62bee93 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
 <at>  <at>  -63,7 +63,6  <at>  <at>  lib-y += hash_md5_sha.o
 #lib-y += hash_md5prime.o
 lib-y += messages.o
 lib-y += mode_string.o
-lib-y += obscure.o
 lib-y += parse_mode.o
 lib-y += parse_config.o
 lib-y += perror_msg.o
 <at>  <at>  -137,7 +136,7  <at>  <at>  lib-$(CONFIG_ADDUSER) += update_passwd.o
 lib-$(CONFIG_DELGROUP) += update_passwd.o
 lib-$(CONFIG_DELUSER) += update_passwd.o

-lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o
+lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o
 lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o
 lib-$(CONFIG_CRYPTPW) += pw_encrypt.o
 lib-$(CONFIG_SULOGIN) += pw_encrypt.o
--

-- 
1.5.3.2
Dan Fandrich | 1 Jun 2011 22:35
Favicon

[PATCH 3/5] Use sysconf(_SC_PAGESIZE) to determine PAGE_SIZE

This seems to be the most portable way to determine page size,
and the only portable way on systems where it is dynamic.

Signed-off-by: Dan Fandrich <dan <at> coneharvesters.com>
---
 libbb/appletlib.c |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 0dac0ba..955f680 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
 <at>  <at>  -34,17 +34,8  <at>  <at> 
 # include <malloc.h> /* for mallopt */
 #endif

-/* Try to pull in PAGE_SIZE */
-#ifdef __linux__
-# include <sys/user.h>
-#endif
-#ifdef __GNU__ /* Hurd */
-# include <mach/vm_param.h>
-#endif
-#ifndef PAGE_SIZE
-# define PAGE_SIZE (4*1024) /* guess */
-#endif
-
+/* Use 4096 if page size can't be otherwise determined */
+#define CURRENT_PAGE_SIZE ({long ps = sysconf(_SC_PAGESIZE); ps > 0 ? ps : 4*1024;})

(Continue reading)


Gmane