Skip to content

Commit

Permalink
factor out multiple Basename() calls + remove arg for really_dostat
Browse files Browse the repository at this point in the history
All execution paths execute Basename, this is for smaller machine code
size.

There is no reason for the caller of really_dostat to allocate a 0x20 to
0x40 byte long stat buffer on C stack, only for it to NOT be used by
default, since the default is calling CacheStat() which doesn't take a
buf pointer. Since C stack is usually in CPU cache, having a slot of
usually unused C stack is bad. Now only if the buffer is needed will it be
allocated on C stack.
  • Loading branch information
bulk88 authored and mohawk2 committed Mar 9, 2015
1 parent 1bd61f0 commit 64ad097
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mac/sysintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define GETPID 1

/* for directory cache */
#define CacheStat(A,B) really_dostat(A,&buf)
#define CacheStat(A,B) really_dostat(A)

/*
** standard C items
Expand Down
4 changes: 2 additions & 2 deletions os2/sysintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern char * tempnam();
extern char * getcwd();

/* for directory cache */
/* #define CacheStat(A,B) really_dostat(A,&buf)*/
/* #define CacheStat(A,B) really_dostat(A)*/

/*
** standard C items
Expand All @@ -46,7 +46,7 @@ extern char * getcwd();
/* Disabled for CWS os2port01
*#define chdir(p) _dchdir(p)
*/
#define CacheStat(A,B) really_dostat(A,&buf)
#define CacheStat(A,B) really_dostat(A)

/*
** make parameters
Expand Down
19 changes: 10 additions & 9 deletions sysintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
** pointer pointed at by sym point at it. Not handled for now!
*/
static time_t
really_dostat(name, buf)
really_dostat(name)
char *name;
DMPORTSTAT_T *buf;
{
return( ( !DMPORTSTAT_SUCCESS(DMPORTSTAT(name,buf))
|| (BTOBOOL(Augmake) && DMPORTSTAT_ISDIR(buf)))
DMPORTSTAT_T buf;
return( ( !DMPORTSTAT_SUCCESS(DMPORTSTAT(name,&buf))
|| (BTOBOOL(Augmake) && DMPORTSTAT_ISDIR(&buf)))
? (time_t)0L
: (time_t)DMPORTSTAT_MTIME(buf)
: (time_t)DMPORTSTAT_MTIME(&buf)
);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ int force;
else if( BTOBOOL(UseDirCache) )
return(CacheStat(name,force));
else
return(really_dostat(name,&buf));
return(really_dostat(name));
}


Expand All @@ -140,16 +140,17 @@ char *name;
char *lib;
/* char **member; */
{
char * basename = Basename(name);
/*
if( member != NIL(char *) )
Fatal("Library symbol names not supported");
*/

if (lib != NIL(char))
return( touch_arch(Basename(name), lib) );
else if( strlen(Basename(name)) > NameMax ) {
return( touch_arch(basename, lib) );
else if( strlen(basename) > NameMax ) {
Warning( "Filename [%s] longer than value of NAMEMAX [%d].\n\
File timestamp not updated to present time.\n", Basename(name), NameMax );
File timestamp not updated to present time.\n", basename, NameMax );
return(-1);
}
else
Expand Down
2 changes: 1 addition & 1 deletion tos/sysintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define GETPID getpid()

/* for directory cache */
#define CacheStat(A,B) really_dostat(A,&buf)
#define CacheStat(A,B) really_dostat(A)

/*
** standard C items
Expand Down

0 comments on commit 64ad097

Please sign in to comment.