summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-09-27 22:17:07 +0000
committerrillig <rillig@NetBSD.org>2020-09-27 22:17:07 +0000
commit22ea481b8f36d7bd7bb40bac4c05b7d66cf93bf4 (patch)
tree710ee1f0e879fce4c860afe7844ac191b684cb79 /usr.bin/make
parent7721efffdab7f762edaa951990226551cde90e55 (diff)
make(1): improve documentation of CachedDir and Dir_AddDir
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/dir.c32
-rw-r--r--usr.bin/make/dir.h28
2 files changed, 28 insertions, 32 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 57b50bcc4bc..d54525fc094 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.149 2020/09/27 21:35:16 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.150 2020/09/27 22:17:07 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.149 2020/09/27 21:35:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.150 2020/09/27 22:17:07 rillig Exp $");
#define DIR_DEBUG0(fmt) \
if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -1480,27 +1480,17 @@ Dir_MTime(GNode *gn, Boolean recheck)
return gn->mtime;
}
-/*-
- *-----------------------------------------------------------------------
- * Dir_AddDir --
- * Add the given name to the end of the given path. The order of
- * the arguments is backwards so ParseDoDependency can do a
- * Lst_ForEachUntil of its list of paths...
- *
- * Input:
- * path the path to which the directory should be
- * added
- * XXX: Why would this ever be NULL, and what does
- * that mean?
- * name the name of the directory to add
+/* Read the list of filenames in the directory and store the result
+ * in openDirectories.
*
- * Results:
- * none
+ * If a path is given, append the directory to that path.
*
- * Side Effects:
- * A structure is added to the list and the directory is
- * read and hashed.
- *-----------------------------------------------------------------------
+ * Input:
+ * path The path to which the directory should be
+ * added, or NULL to only add the directory to
+ * openDirectories
+ * name The name of the directory to add.
+ * The name is not normalized in any way.
*/
CachedDir *
Dir_AddDir(SearchPath *path, const char *name)
diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h
index 813939ba5a0..9bb6be96504 100644
--- a/usr.bin/make/dir.h
+++ b/usr.bin/make/dir.h
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.h,v 1.26 2020/09/27 21:35:16 rillig Exp $ */
+/* $NetBSD: dir.h,v 1.27 2020/09/27 22:17:07 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -75,21 +75,21 @@
#ifndef MAKE_DIR_H
#define MAKE_DIR_H
-/* A cache of a directory, remembering all the files that exist in that
- * directory. */
+/* A cache for the filenames in a directory. */
typedef struct CachedDir {
- char *name; /* Name of directory */
- int refCount; /* Number of paths with this directory */
- int hits; /* the number of times a file in this
+ char *name; /* Name of directory, either absolute or
+ * relative to the current directory.
+ * The name is not normalized in any way,
+ * that is, "." and "./." are different.
+ *
+ * Not sure what happens when .CURDIR is
+ * assigned a new value; see Parse_DoVar. */
+ int refCount; /* Number of SearchPaths with this directory */
+ int hits; /* The number of times a file in this
* directory has been found */
Hash_Table files; /* Hash set of files in directory */
} CachedDir;
-struct make_stat {
- time_t mst_mtime;
- mode_t mst_mode;
-};
-
void Dir_Init(void);
void Dir_InitDir(const char *);
void Dir_InitCur(const char *);
@@ -110,6 +110,12 @@ void Dir_PrintPath(SearchPath *);
void Dir_Destroy(void *);
void *Dir_CopyDir(void *);
+/* Stripped-down variant of struct stat. */
+struct make_stat {
+ time_t mst_mtime;
+ mode_t mst_mode;
+};
+
int cached_lstat(const char *, struct make_stat *);
int cached_stat(const char *, struct make_stat *);