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=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=M+FUHP2qiiEKThB03U4Oehd6oTlwfv6wiHnRt5DnsNI=; b=LFbrn6JyWShlVdAV/zRfkEm+r+tzYYk0bylbKem7U0pJiNw664Xhpz8mV9B6hZaPqw 5I70U+4ce0WjDplfB7Quc82uV064mEY8wdccVubXW2irxorTF6Z7OHt+sVcfadX7qu4Z Yd92WfXUd3NhMS2xxzULtd/5BYD5wsUZj7J8CDfWXELwQWWwJSV1H6Ent1w1o4z1dJ3g Ke3eG5b4M6Z9eArOb5hTkvh16dxk72K9rJidWEnWeYpr9S7MaEdUG+bvxJXj6iAWsNeS 58RfiokceNRr4JIxfHk6CNn6Ue+mweB1hyN35EvZbVxowq2uZ3R9r7RxmjDGL7UfHIeg RQKw== MIME-Version: 1.0 X-Received: by 10.50.49.44 with SMTP id r12mr28573324ign.41.1398165096638; Tue, 22 Apr 2014 04:11:36 -0700 (PDT) Date: Tue, 22 Apr 2014 14:11:36 +0300 Message-ID: Subject: [PATCH] break xstat.c into pieces From: Ozkan Sezer To: djgpp-workers Content-Type: multipart/mixed; boundary=047d7bdc1750ec2e8504f79fadc6 Reply-To: djgpp-workers AT delorie DOT com --047d7bdc1750ec2e8504f79fadc6 Content-Type: text/plain; charset=UTF-8 The following patch breaks xstat.c into smaller pieces, so that, e.g. mkdir() doesn't pull in unnecessary dependencies such as ctime.o. For previous discussions, see: http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2009/09/26/21:32:54 http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2014/04/21/17:23:29 http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2014/04/21/18:23:14 -- O.S. Index: src/libc/posix/sys/stat/makefile =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/makefile,v retrieving revision 1.5 diff -u -p -r1.5 makefile --- src/libc/posix/sys/stat/makefile 8 Mar 2003 00:41:17 -0000 1.5 +++ src/libc/posix/sys/stat/makefile 22 Apr 2014 10:51:10 -0000 @@ -18,5 +18,8 @@ SRC += st_loss.c SRC += stat.c SRC += umask.c SRC += xstat.c +SRC += xstatbit.c +SRC += xftimest.c +SRC += xgetftim.c include $(TOP)/../makefile.inc Index: src/libc/posix/sys/stat/xstat.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/xstat.c,v retrieving revision 1.8 diff -u -p -r1.8 xstat.c --- src/libc/posix/sys/stat/xstat.c 10 Mar 2012 18:03:11 -0000 1.8 +++ src/libc/posix/sys/stat/xstat.c 22 Apr 2014 10:51:10 -0000 @@ -6,7 +6,6 @@ * * Internal assist functions which are common to stat(), fstat() and lstat(). * - * * Copyright (c) 1994-96 Eli Zaretskii * * This software may be used freely as long as the above copyright @@ -32,90 +31,9 @@ static int xstat_count = -1; -/* Some fields of struct stat are expensive to compute under DOS, - because they require multiple disk accesses. Fortunately, many - DOS programs don't care about these. To leave both pedants (like - me) and performance-oriented guys happy, a variable is provided - which controls which expensive fields should be computed. To get - the fastest stat() for your program, clear the bits for only those - features you need and set the others. - - This improvement was suggested by Charles Sandmann - and DJ Delorie . */ - -/* Please see the header file sys/stat.h for the definitions of _STAT_*. */ - -/* Should we bother about executables at all? */ -#define _STAT_EXECBIT (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC) - -/* By default, all the bits are reset (including as yet unused ones), so - people who don't care will transparently have the full version. */ -unsigned short _djstat_flags; - -/* As we depend on undocumented DOS features, we could fail in some - incompatible environment or future DOS versions. If we do, the - following variable will have some of its bits set. Each bit - describes a single feature which we tried to use and failed. - The function _djstat_describe_lossage() may be called to print a - human-readable description of the bits which were set by the last - call to f?stat(). This should make debugging f?stat() failures - in an unanticipated environment a lot easier. - - This improvement was suggested by Charles Sandmann - . */ - -unsigned short _djstat_fail_bits; - /* ----------------------------------------------------------------------- */ -/* 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 - * pollute the application namespace and returns an int instead - * of struct ftime with packed bit-fields. - */ - - -int -_getftime(int fhandle, unsigned int *dos_ftime) -{ - __dpmi_regs regs; - - regs.x.ax = 0x5700; - regs.x.bx = fhandle; - __dpmi_int(0x21, ®s); - - if (regs.x.flags & 1) - { - errno = __doserr_to_errno(regs.x.ax); - return -1; - } - - *dos_ftime = ((unsigned int)regs.x.dx << 16) + (unsigned int)regs.x.cx; - - return 0; -} - +#ifndef NO_ST_BLKSIZE /* Cache the cluster size (aka block size) for each drive letter, so we can * populate the st_blksize of struct stat easily. The cluster size is * measured in bytes. @@ -190,6 +108,7 @@ _get_cached_blksize (const char *path) return cache_blksize[d]; } +#endif /* NO_ST_BLKSIZE */ /* Invent an inode number for those files which don't have valid DOS * cluster number. These could be: devices like /dev/nul; empty Index: src/libc/posix/sys/stat/xstat.h =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/xstat.h,v retrieving revision 1.6 diff -u -p -r1.6 xstat.h --- src/libc/posix/sys/stat/xstat.h 17 Oct 2002 23:00:25 -0000 1.6 +++ src/libc/posix/sys/stat/xstat.h 22 Apr 2014 10:51:10 -0000 @@ -52,6 +52,8 @@ extern long __filelength(int extern int _is_remote_handle(int); extern void _djstat_describe_lossage(FILE *); extern int _getftime(int, unsigned int *); +#ifndef NO_ST_BLKSIZE extern blksize_t _get_cached_blksize (const char *path); +#endif #endif /* __XSTAT_H */ --- /dev/null +++ src/libc/posix/sys/stat/xstatbit.c 22 Apr 2014 10:51:10 -0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2012 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include "xstat.h" + +/* Some fields of struct stat are expensive to compute under DOS, + because they require multiple disk accesses. Fortunately, many + DOS programs don't care about these. To leave both pedants (like + me) and performance-oriented guys happy, a variable is provided + which controls which expensive fields should be computed. To get + the fastest stat() for your program, clear the bits for only those + features you need and set the others. + + This improvement was suggested by Charles Sandmann + and DJ Delorie . */ + +/* Please see the header file sys/stat.h for the definitions of _STAT_*. */ + +/* Should we bother about executables at all? */ +#define _STAT_EXECBIT (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC) + +/* By default, all the bits are reset (including as yet unused ones), so + people who don't care will transparently have the full version. */ +unsigned short _djstat_flags; + +/* As we depend on undocumented DOS features, we could fail in some + incompatible environment or future DOS versions. If we do, the + following variable will have some of its bits set. Each bit + describes a single feature which we tried to use and failed. + The function _djstat_describe_lossage() may be called to print a + human-readable description of the bits which were set by the last + call to f?stat(). This should make debugging f?stat() failures + in an unanticipated environment a lot easier. + + This improvement was suggested by Charles Sandmann + . */ + +unsigned short _djstat_fail_bits; + --- /dev/null +++ src/libc/posix/sys/stat/xgetftim.c 22 Apr 2014 10:51:10 -0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2012 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +/* + * Internal assist functions which are common to stat(), fstat() and lstat(). + * + * Copyright (c) 1994-96 Eli Zaretskii + * + * This software may be used freely as long as the above copyright + * notice is left intact. There is no warranty on this software. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "xstat.h" + +/* Get time stamp of a DOS file packed as a 32-bit int. + * This does what Borland's getftime() does, except it doesn't + * pollute the application namespace and returns an int instead + * of struct ftime with packed bit-fields. + */ + + +int +_getftime(int fhandle, unsigned int *dos_ftime) +{ + __dpmi_regs regs; + + regs.x.ax = 0x5700; + regs.x.bx = fhandle; + __dpmi_int(0x21, ®s); + + if (regs.x.flags & 1) + { + errno = __doserr_to_errno(regs.x.ax); + return -1; + } + + *dos_ftime = ((unsigned int)regs.x.dx << 16) + (unsigned int)regs.x.cx; + + return 0; +} + --- /dev/null +++ src/libc/posix/sys/stat/xftimest.c 22 Apr 2014 10:51:10 -0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2012 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +/* + * Internal assist functions which are common to stat(), fstat() and lstat(). + * + * Copyright (c) 1994-96 Eli Zaretskii + * + * This software may be used freely as long as the above copyright + * notice is left intact. There is no warranty on this software. + * + */ + +#include +#include +#include + +#include "xstat.h" + +/* 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); +} + --047d7bdc1750ec2e8504f79fadc6 Content-Type: text/plain; charset=US-ASCII; name="xstat.diff" Content-Disposition: attachment; filename="xstat.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 SW5kZXg6IHNyYy9saWJjL3Bvc2l4L3N5cy9zdGF0L21ha2VmaWxlCj09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZp bGU6IC9jdnMvZGpncHAvZGpncHAvc3JjL2xpYmMvcG9zaXgvc3lzL3N0YXQvbWFrZWZpbGUsdgpy ZXRyaWV2aW5nIHJldmlzaW9uIDEuNQpkaWZmIC11IC1wIC1yMS41IG1ha2VmaWxlCi0tLSBzcmMv bGliYy9wb3NpeC9zeXMvc3RhdC9tYWtlZmlsZQk4IE1hciAyMDAzIDAwOjQxOjE3IC0wMDAwCTEu NQorKysgc3JjL2xpYmMvcG9zaXgvc3lzL3N0YXQvbWFrZWZpbGUJMjIgQXByIDIwMTQgMTA6NTE6 MTAgLTAwMDAKQEAgLTE4LDUgKzE4LDggQEAgU1JDICs9IHN0X2xvc3MuYwogU1JDICs9IHN0YXQu YwogU1JDICs9IHVtYXNrLmMKIFNSQyArPSB4c3RhdC5jCitTUkMgKz0geHN0YXRiaXQuYworU1JD ICs9IHhmdGltZXN0LmMKK1NSQyArPSB4Z2V0ZnRpbS5jCiAKIGluY2x1ZGUgJChUT1ApLy4uL21h a2VmaWxlLmluYwpJbmRleDogc3JjL2xpYmMvcG9zaXgvc3lzL3N0YXQveHN0YXQuYwo9PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09ClJDUyBmaWxlOiAvY3ZzL2RqZ3BwL2RqZ3BwL3NyYy9saWJjL3Bvc2l4L3N5cy9zdGF0L3hz dGF0LmMsdgpyZXRyaWV2aW5nIHJldmlzaW9uIDEuOApkaWZmIC11IC1wIC1yMS44IHhzdGF0LmMK LS0tIHNy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