www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2009/09/26/21:32:54

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:mime-version:received:date:message-id:subject
:from:to:content-type;
bh=1zqRDPewR5/xzhmls2qlcebzL+f2iNgleJtWPhrGKyY=;
b=iWkBENTOZI4l0Xc+dwsfEvjJYtiFu+Nw023XyMLbr1ogZI2Tf+BZUdvGqHDUWfsU9v
7iywVWdJrEo3wpXPkXZyZmBPkO2SjTPU0bbu0TRQYsHwvW1K+wWuDJNc3zHG1gmwBkc1
tTrBDllxArz/q64KZwrNqVnpizgZl5JbXe67s=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=mime-version:date:message-id:subject:from:to:content-type;
b=TnkxOqDFKjHZwA8VE8jQ5wo3TPA7ZgGSsu+buJTnedU6h5CPFS50AdkO0wTG9W86ag
YLNdPnUan49FESoVCNgj+s1HXinVitF8nARBl0njZ4ZTu7Pi+i/Ioh9AKMcM36JRhScn
r4TYH3MoXwgxa/b23WbqqzT++2tQhJsj1mxl4=
MIME-Version: 1.0
Date: Sat, 26 Sep 2009 20:32:08 -0500
Message-ID: <93c172b50909261832l51569ae1k9dbaf11c57b1524b@mail.gmail.com>
Subject: 2.03p2 patch: swaps file_time_stamp() into fstat.c instead of xstat.c
to prevent accidental ctime.o bloat, e.g. mkdir()
From: Rugxulo <rugxulo AT gmail DOT com>
To: djgpp-workers AT delorie DOT com
Reply-To: djgpp-workers AT delorie DOT com

Hi guys,
   Please tell me if this is convincing or not. I mentioned this two
months ago and never got any feedback. Well, I took another try today
and patched (one of my many copies of) 2.03p2's libc.a to swap
_file_time_stamp() into fstat.c (where it's actually used) instead of
xstat.c to prevent ctime.o being pulled in accidentally.

> My previous build [7zdec] (before mkdir was supported), e.g. 4.65, was 42k
> with all the above tricks. That's pretty small, I thought. However, once mkdir()
> was added to the fold, the size went up 20% (!) to 52k and yet my OpenWatcom
> build only increased 1k!

Here's my attempt at proof that it works (GCC 2.95.3, BinUtils 2.16.1, 2.03p2).

-rwxr-xr-x    1 dosuser  root        52528 Sep 26 20:09 7zdecold.exe
-rwxr-xr-x    1 dosuser  root        46904 Sep 26 20:09 7zdecnew.exe
-rwxr-xr-x    1 dosuser  root       120832 Sep 26 20:02 command.exe
-rwxr-xr-x    1 dosuser  root       111616 Sep 26 20:00 command2.exe
-rwxr-xr-x    1 dosuser  root        50176 Sep 26 20:06 hello.exe
-rwxr-xr-x    1 dosuser  root        50176 Sep 26 20:06 hello2.exe
-rwxr-xr-x    1 dosuser  root        65024 Sep 26 20:16 makedir.exe
-rwxr-xr-x    1 dosuser  root        46080 Sep 26 20:15 makedir2.exe

* 7zdec 9.07 (UPX'd and using D3X): http://rugxulo.googlepages.com/7zdec.zip
* Centroid's command.com clone:
http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/command/contrib/centroidcnc/)
* Hello, world!
* simple mkdir("blah") example

Obviously "Hello, world!" had no effect, but the others saved some
space. The point is that not everybody needs ctime.o in their app. I
should submit a patch to 2.04 beta also, but then again, what about
CVS? Meh. For now, I'll just wait until somebody actually confirms or
denies my idea.   :-)

-rw-r--r--    1 dosuser  root       637320 Sep 26 20:00 libc.a.new
-rw-r--r--    1 dosuser  root       637286 Dec 24  2001 libc.a.old

=====================================================
--- xstat.c~	1996-01-23 23:30:20 -0600
+++ xstat.c	2009-09-26 19:54:28 -0500
@@ -70,26 +70,6 @@

 /* ----------------------------------------------------------------------- */

-/* Convert file date and time to time_t value suitable for
-   struct stat fields.  */
-
-time_t
-_file_time_stamp(unsigned int dos_ftime)
-{
-  struct tm file_tm;
-
-  memset(&file_tm, 0, sizeof(struct tm));
-  file_tm.tm_isdst = -1;    /* let mktime() determine if DST is in effect */
-
-  file_tm.tm_sec  = (dos_ftime & 0x1f) * 2;
-  file_tm.tm_min  = (dos_ftime >>  5) & 0x3f;
-  file_tm.tm_hour = (dos_ftime >> 11) & 0x1f;
-  file_tm.tm_mday = (dos_ftime >> 16) & 0x1f;
-  file_tm.tm_mon  = ((dos_ftime >> 21) & 0x0f) - 1; /* 0 = January */
-  file_tm.tm_year = (dos_ftime >> 25) + 80;
-
-  return mktime(&file_tm);
-}

 /* Get time stamp of a DOS file packed as a 32-bit int.
  * This does what Borland's getftime() does, except it doesn't
=====================================================
--- fstat.c~	2001-08-27 11:47:34 -0500
+++ fstat.c	2009-09-26 19:54:20 -0500
@@ -334,6 +334,31 @@
   return -2;
 }

+/* ---------------------------------------------------------------------- */
+
+/* Convert file date and time to time_t value suitable for
+   struct stat fields.  */
+
+time_t
+_file_time_stamp(unsigned int dos_ftime)
+{
+  struct tm file_tm;
+
+  memset(&file_tm, 0, sizeof(struct tm));
+  file_tm.tm_isdst = -1;    /* let mktime() determine if DST is in effect */
+
+  file_tm.tm_sec  = (dos_ftime & 0x1f) * 2;
+  file_tm.tm_min  = (dos_ftime >>  5) & 0x3f;
+  file_tm.tm_hour = (dos_ftime >> 11) & 0x1f;
+  file_tm.tm_mday = (dos_ftime >> 16) & 0x1f;
+  file_tm.tm_mon  = ((dos_ftime >> 21) & 0x0f) - 1; /* 0 = January */
+  file_tm.tm_year = (dos_ftime >> 25) + 80;
+
+  return mktime(&file_tm);
+}
+
+/* ---------------------------------------------------------------------- */
+
 /* On LFN platforms, we can get all the 3 time-related fields.  */

 static void
=====================================================

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019