[PATCH] nproc: new applet

Steven Honeyman stevenhoneyman at gmail.com
Mon Aug 4 22:06:58 UTC 2014


On 4 August 2014 18:10, Steven Honeyman <stevenhoneyman at gmail.com> wrote:
> On 4 August 2014 07:38, Bernhard Reutner-Fischer <rep.dot.nop at gmail.com> wrote:
>> On 3 August 2014 02:20:47 CEST, Steven Honeyman <stevenhoneyman at gmail.com> wrote:
>>>I needed this little program recently, and was quite surprised it
>>>wasn't already a part of busybox... so here is a simple implementation
>>>that I hope can be included.
>>
>> alias nproc="getconf _NPROCESSORS_ONLN"
>>
>> In your sh profile.
>> HTH
>>
>
> Interesting idea... but getconf doesn't seem to be part of busybox. I
> just did a 'grep -r getconf' on the latest git source, and the only
> place it's mentionned is in docs/posix_conformance.txt, under the "not
> supported" section!
>
>
> Thanks,
> Steven.

Right, seeing as musl libc (and most other non-glibcs) do not provide
a get_nprocs() that actually works... I have mixed both solutions and
used sysconf() instead. It works just as well. One other change is
from printf() to puts(atoi()) which both combined, saved an entire 7
bytes somehow :)

Updated patch attached, bloatcheck below.

Thanks,
Steven.

--
function                                             old     new   delta
nproc_main                                             -      53     +53
packed_usage                                       29616   29636     +20
applet_main                                         2856    2864      +8
applet_names                                        2451    2457      +6
applet_nameofs                                       714     716      +2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/0 up/down: 89/0)               Total: 89 bytes
   text       data        bss        dec        hex    filename
 856118       4244       9672     870034      d4692    busybox_old
 856193       4244       9672     870109      d46dd    busybox_unstripped
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-nproc-new-applet.patch
Type: text/x-diff
Size: 1617 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140804/f6d782ec/attachment.bin>


More information about the busybox mailing list