Mail Archives: djgpp-workers/2016/08/06/13:37:52
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-workers-bounces using -f
|
X-Recipient: | djgpp-workers AT delorie DOT com
|
X-Original-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed;
|
| d=gmail.com; s=20120113;
|
| h=mime-version:in-reply-to:references:from:date:message-id:subject:to;
|
| bh=QYJL6bZO0LMfBCq9XOmnKtk2VH3qEbno+jrZD0LlDGE=;
|
| b=xCfZG+8xlrv1UOPwdvPgFR+TMKeRyy1Xh2tY7gDWxR2YOMLuDVjzJIIJPOE7nCEZAP
|
| H6CDTP6QDIXTJkbT9hhxFggftvDmsNOXNABD9rCPW0FxUcZw+8OWKoPAAB3fYBfKSVZ7
|
| 9j+TfC5J5CHfAsuQ0sxiwN3y6XW5owaAxylAJZwtBAUY5YAxQnF4Dn2RGfpG5ozSknwL
|
| tR+sh5LeE4K/if0KdmTyfPysq4bBvn1y1o1HvJps4PT9ztI1dCE9pBxjWB8uGuzSUbmW
|
| 826A5oSgGpd50FD7iY/Z5h3T9wh9N8J8prSfWlJdDvR79Z2mzwqtxKljE5oQJvB7nJh8
|
| wWiA==
|
X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed;
|
| d=1e100.net; s=20130820;
|
| h=x-gm-message-state:mime-version:in-reply-to:references:from:date
|
| :message-id:subject:to;
|
| bh=QYJL6bZO0LMfBCq9XOmnKtk2VH3qEbno+jrZD0LlDGE=;
|
| b=ZgbPaklrpXQ5TFDWMdnDZQZXKUmh/oOHtHCCikvG8vZlGK06VeSTOzKVQjEdYntwGY
|
| uclZKuxd9BpSj50QOJprF+1rmCnMm37GwUwC739VwGnKhKprE01suNFAxVpaqEAce/cl
|
| z6mYZC8kWctmq077vq06xGnlrQZWUPV4xEsYg82XFDbOOtGF1g+yZcq4ytBa/EcBv64V
|
| DkAUkB9+2lr6CnMqQ40c425GtUgxX6kJ10eTPOcBy/xCjw2cPCydNuN25Wzxvv0Xs+YW
|
| aTsEjXKNRYBesRdMVW4nl89Xp8GyPyZtzTWBAZZVz0JQIxtFCStAARQupjaX2cATdKpT
|
| 8m4Q==
|
X-Gm-Message-State: | AEkoouudFkr68S2yo5jGI2ZTb8DVONy3fmZoGWIBLFM5acVlcnVQ6f+TMEPUQmbS6pjDCf2oTDLg8OPrrFkDzQ==
|
X-Received: | by 10.36.53.214 with SMTP id k205mr10592369ita.85.1470503434281;
|
| Sat, 06 Aug 2016 10:10:34 -0700 (PDT)
|
MIME-Version: | 1.0
|
In-Reply-To: | <CAA-ihx-exBLSkvQqFz5BHj_Ma1Cqn7bUqYwSPvUMEh7_-ARJEA@mail.gmail.com>
|
References: | <CAA-ihx-exBLSkvQqFz5BHj_Ma1Cqn7bUqYwSPvUMEh7_-ARJEA AT mail DOT gmail DOT com>
|
From: | "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp-workers AT delorie DOT com]" <djgpp-workers AT delorie DOT com>
|
Date: | Sat, 6 Aug 2016 20:10:33 +0300
|
Message-ID: | <CAA2C=vD2ML8fKhCmH=g8Q4QkjgfPJ0CMg17DB31obdvxe9BQhw@mail.gmail.com>
|
Subject: | Re: linking more bloat from ctime.c
|
To: | djgpp-workers AT delorie DOT com
|
Reply-To: | djgpp-workers AT delorie DOT com
|
Errors-To: | nobody AT delorie DOT com
|
X-Mailing-List: | djgpp-workers AT delorie DOT com
|
X-Unsubscribes-To: | listserv AT delorie DOT com
|
--001a114aa6bed7a6a005396a42f0
Content-Type: text/plain; charset=UTF-8
On 8/6/16, Rugxulo (rugxulo AT gmail DOT com) [via djgpp-workers AT delorie DOT com]
<djgpp-workers AT delorie DOT com> wrote:
> Hi, guys,
>
> (Okay, so this isn't a hugely critical issue, nor a priority, so
> please don't think I'm complaining. I just wanted to mention it for
> completeness.)
>
> We've already discussed the bloat of ctime.c several times over the
> years. The most recent discussion was two years ago (2014/04/21), from
> Ozkan Sezer, titled "ctime.c changes add about 4.5k more size".
>
> (I found that entire thread chain by searching my email archives and
> then further searching on
> http://www.delorie.com/djgpp/mail-archives/search.cgi with the
> keywords "+crazy +changes +mktime".)
>
> http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2014/04/21/02:44:35
>
> Here's the real problem: *printf (or, more specifically, doprnt.o). A
> lot has changed since 2.03p2. One very simple test of mine showed
> this:
>
> (2.03p2):
> LITE EXE 44,032
> SCANF EXE 47,616
> PRINTF EXE 51,712
> BOTH EXE 55,296
>
> (2.05):
> LITE EXE 72,192
> SCANF EXE 84,480
> PRINTF EXE 89,088
> BOTH EXE 100,352
>
> Yes, I know, hard drives are cheap. And of course 99% of all C
> programs actually need and want to use *printf. But, even
> acknowledging that, I think it's a mistake to link in the full
> doprnt.o just for a single line in an (here by me) unused routine in
> ctime.c by default.
>
> // === badprint.c begins ===
> /*
> re: DJGPP 2.05 (DJDEV-/DJLSR205.ZIP) ...
>
> I only want a simple call to time(), but that needs gettimeofday(),
> and gettimeofday() needs mktime() and localtime(), both of which
> are included inside ctime.o !!
>
> We must stop ctime.o from pulling in sprintf()'s (bloated) doprnt.o !!
>
> text data bss dec hex filename
> 10832 2644 14464 27940 6d24 ctime.o
> 15712 188 8 15908 3e24 doprnt.o
>
> sprintf() is called by asctime_r(), which itself is called by
> asctime(), but ctime() also calls asctime() and ctime_r() also
> calls asctime_r() !!
>
> The single offending sprintf format string is as follows:
>
> "%.3s %.3s%3d %02d:%02d:%02d %d\n"
>
> This should be easy to simulate without needing to include the
> full doprnt.o !!
> */
>
> #include <stdio.h>
>
> int sprintf(char* buffer, const char* format, ...)
> {
> fputs("Someone is calling me??? I'm a (fake) sprintf() stub!!!",stderr);
> return 0;
> }
> // === badprint.c ends ===
>
> P.S. In one minimal program of mine, the solution I found recently was
> to not use time() at all (for srand() ), instead relying on
> (non-standard!) Turbo C's gettime(), which doesn't need all the bloat
> (since I was already avoiding printf() there as unnecessary). My point
> is that I assume ctime.c can be "fixed" to not need sprintf() at all,
> which would be more ideal than either of these kludges, right?
>
To overcome the bloat from ctime.c, I have been using the attached
djtime.c for some time. It also avoids all timezone thingies. Maybe it
would be useful to you and-or to someone else.
--001a114aa6bed7a6a005396a42f0
Content-Type: text/x-csrc; charset=US-ASCII; name="djtime.c"
Content-Disposition: attachment; filename="djtime.c"
Content-Transfer-Encoding: base64
X-Attachment-Id: file1
c3RydWN0IHRtICpnbXRpbWUgKGNvbnN0IHRpbWVfdCAqdHQpCnsKICAgIHN0YXRpYyBjaGFyIG1v
bnRodGFibGVbXSA9IHsKICAgIC8qIEphbkZlYk1hckFwck1heUp1bkp1bEF1Z1NlcE9rdE5vdiAq
LwogICAgICAgMzEsMjksMzEsMzAsMzEsMzAsMzEsMzEsMzAsMzEsMzAKICAgIH07CiAgICBzdGF0
aWMgc3RydWN0IHRtIF9teXRtOwoKICAgIHN0cnVjdCB0bSAqdG0gPSAmX215dG07CiAgICBzaWdu
ZWQgbG9uZyB0aW07CiAgICBpbnQgbGVhcGRheSA9IDAsIGxlYXB5ZWFyID0gMCwgaTsKCiAgICB0
aW0gPSAqdHQ7CgogICAgdG0tPnRtX3NlYyA9IHRpbSAlIDYwOwogICAgdGltIC89IDYwOwoKICAg
IHRtLT50bV9taW4gPSB0aW0gJSA2MDsKICAgIHRpbSAvPSA2MDsKCiAgICAvKgoJNzE5MTYyIG51
bWJlciBvZiBkYXlzIGJldHdlZW4gMS4xLjEgYW5kIDEuMS4xOTcwIGlmIHRoZSBjYWxlbmRhcgoJ
d291bGQgZ28gc28gZmFyIHdoaWNoIGl0IGRvZXNuJ3QgOi0pIHRoaXMgaXMgdHJ1ZSBmb3IgYWxs
IG9mIHRoZQoJZm9sbG93aW5nLgogICAgKi8KICAgIHRtLT50bV9ob3VyID0gdGltICUgMjQ7CiAg
ICB0aW0gPSB0aW0gLyAyNCArIDcxOTE2MjsKCiAgICB0bS0+dG1fd2RheSA9ICh0aW0gKyAxKSAl
IDc7CgogICAgLyogMTQ2MDk3IG51bWJlciBvZiBkYXlzIGZyb20gMS4xLjE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