Wed Sep 2 03:28:12 2020 UTC ()
make(1): use proper types in API of cached_stat and cached_lstat


(rillig)
diff -r1.131 -r1.132 src/usr.bin/make/dir.c
diff -r1.134 -r1.135 src/usr.bin/make/make.h

cvs diff -r1.131 -r1.132 src/usr.bin/make/dir.c (expand / switch to unified diff)

--- src/usr.bin/make/dir.c 2020/09/02 03:15:21 1.131
+++ src/usr.bin/make/dir.c 2020/09/02 03:28:12 1.132
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dir.c,v 1.131 2020/09/02 03:15:21 rillig Exp $ */ 1/* $NetBSD: dir.c,v 1.132 2020/09/02 03:28:12 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,34 +60,34 @@ @@ -60,34 +60,34 @@
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE. 69 * SUCH DAMAGE.
70 */ 70 */
71 71
72#ifndef MAKE_NATIVE 72#ifndef MAKE_NATIVE
73static char rcsid[] = "$NetBSD: dir.c,v 1.131 2020/09/02 03:15:21 rillig Exp $"; 73static char rcsid[] = "$NetBSD: dir.c,v 1.132 2020/09/02 03:28:12 rillig Exp $";
74#else 74#else
75#include <sys/cdefs.h> 75#include <sys/cdefs.h>
76#ifndef lint 76#ifndef lint
77#if 0 77#if 0
78static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; 78static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
79#else 79#else
80__RCSID("$NetBSD: dir.c,v 1.131 2020/09/02 03:15:21 rillig Exp $"); 80__RCSID("$NetBSD: dir.c,v 1.132 2020/09/02 03:28:12 rillig Exp $");
81#endif 81#endif
82#endif /* not lint */ 82#endif /* not lint */
83#endif 83#endif
84 84
85/*- 85/*-
86 * dir.c -- 86 * dir.c --
87 * Directory searching using wildcards and/or normal names... 87 * Directory searching using wildcards and/or normal names...
88 * Used both for source wildcarding in the Makefile and for finding 88 * Used both for source wildcarding in the Makefile and for finding
89 * implicit sources. 89 * implicit sources.
90 * 90 *
91 * The interface for this module is: 91 * The interface for this module is:
92 * Dir_Init Initialize the module. 92 * Dir_Init Initialize the module.
93 * 93 *
@@ -327,33 +327,33 @@ cached_stats(Hash_Table *htp, const char @@ -327,33 +327,33 @@ cached_stats(Hash_Table *htp, const char
327 if (flags & CST_LSTAT) { 327 if (flags & CST_LSTAT) {
328 cst->lmtime = st->st_mtime; 328 cst->lmtime = st->st_mtime;
329 } else { 329 } else {
330 cst->mtime = st->st_mtime; 330 cst->mtime = st->st_mtime;
331 } 331 }
332 cst->mode = st->st_mode; 332 cst->mode = st->st_mode;
333 DIR_DEBUG2(" Caching %s for %s\n", 333 DIR_DEBUG2(" Caching %s for %s\n",
334 Targ_FmtTime(st->st_mtime), pathname); 334 Targ_FmtTime(st->st_mtime), pathname);
335 335
336 return 0; 336 return 0;
337} 337}
338 338
339int 339int
340cached_stat(const char *pathname, void *st) 340cached_stat(const char *pathname, struct stat *st)
341{ 341{
342 return cached_stats(&mtimes, pathname, st, 0); 342 return cached_stats(&mtimes, pathname, st, 0);
343} 343}
344 344
345int 345int
346cached_lstat(const char *pathname, void *st) 346cached_lstat(const char *pathname, struct stat *st)
347{ 347{
348 return cached_stats(&lmtimes, pathname, st, CST_LSTAT); 348 return cached_stats(&lmtimes, pathname, st, CST_LSTAT);
349} 349}
350 350
351/* Initialize things for this module. */ 351/* Initialize things for this module. */
352void 352void
353Dir_Init(void) 353Dir_Init(void)
354{ 354{
355 dirSearchPath = Lst_Init(); 355 dirSearchPath = Lst_Init();
356 openDirectories = Lst_Init(); 356 openDirectories = Lst_Init();
357 Hash_InitTable(&mtimes, 0); 357 Hash_InitTable(&mtimes, 0);
358 Hash_InitTable(&lmtimes, 0); 358 Hash_InitTable(&lmtimes, 0);
359} 359}

cvs diff -r1.134 -r1.135 src/usr.bin/make/make.h (expand / switch to unified diff)

--- src/usr.bin/make/make.h 2020/08/31 06:21:07 1.134
+++ src/usr.bin/make/make.h 2020/09/02 03:28:12 1.135
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make.h,v 1.134 2020/08/31 06:21:07 rillig Exp $ */ 1/* $NetBSD: make.h,v 1.135 2020/09/02 03:28:12 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -72,26 +72,27 @@ @@ -72,26 +72,27 @@
72 * from: @(#)make.h 8.3 (Berkeley) 6/13/95 72 * from: @(#)make.h 8.3 (Berkeley) 6/13/95
73 */ 73 */
74 74
75/*- 75/*-
76 * make.h -- 76 * make.h --
77 * The global definitions for pmake 77 * The global definitions for pmake
78 */ 78 */
79 79
80#ifndef MAKE_MAKE_H 80#ifndef MAKE_MAKE_H
81#define MAKE_MAKE_H 81#define MAKE_MAKE_H
82 82
83#include <sys/types.h> 83#include <sys/types.h>
84#include <sys/param.h> 84#include <sys/param.h>
 85#include <sys/stat.h>
85 86
86#include <assert.h> 87#include <assert.h>
87#include <ctype.h> 88#include <ctype.h>
88#include <fcntl.h> 89#include <fcntl.h>
89#include <stdio.h> 90#include <stdio.h>
90#include <stdlib.h> 91#include <stdlib.h>
91#include <string.h> 92#include <string.h>
92#include <unistd.h> 93#include <unistd.h>
93 94
94#ifdef BSD4_4 95#ifdef BSD4_4
95# include <sys/cdefs.h> 96# include <sys/cdefs.h>
96#endif 97#endif
97 98
@@ -526,28 +527,28 @@ int Make_TimeStamp(GNode *, GNode *); @@ -526,28 +527,28 @@ int Make_TimeStamp(GNode *, GNode *);
526Boolean Make_OODate(GNode *); 527Boolean Make_OODate(GNode *);
527void Make_ExpandUse(Lst); 528void Make_ExpandUse(Lst);
528time_t Make_Recheck(GNode *); 529time_t Make_Recheck(GNode *);
529void Make_HandleUse(GNode *, GNode *); 530void Make_HandleUse(GNode *, GNode *);
530void Make_Update(GNode *); 531void Make_Update(GNode *);
531void Make_DoAllVar(GNode *); 532void Make_DoAllVar(GNode *);
532Boolean Make_Run(Lst); 533Boolean Make_Run(Lst);
533int dieQuietly(GNode *, int); 534int dieQuietly(GNode *, int);
534void PrintOnError(GNode *, const char *); 535void PrintOnError(GNode *, const char *);
535void Main_ExportMAKEFLAGS(Boolean); 536void Main_ExportMAKEFLAGS(Boolean);
536Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); 537Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
537int mkTempFile(const char *, char **); 538int mkTempFile(const char *, char **);
538int str2Lst_Append(Lst, char *, const char *); 539int str2Lst_Append(Lst, char *, const char *);
539int cached_lstat(const char *, void *); 540int cached_lstat(const char *, struct stat *);
540int cached_stat(const char *, void *); 541int cached_stat(const char *, struct stat *);
541void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *); 542void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
542 543
543#ifdef __GNUC__ 544#ifdef __GNUC__
544#define UNCONST(ptr) ({ \ 545#define UNCONST(ptr) ({ \
545 union __unconst { \ 546 union __unconst { \
546 const void *__cp; \ 547 const void *__cp; \
547 void *__p; \ 548 void *__p; \
548 } __d; \ 549 } __d; \
549 __d.__cp = ptr, __d.__p; }) 550 __d.__cp = ptr, __d.__p; })
550#else 551#else
551#define UNCONST(ptr) (void *)(ptr) 552#define UNCONST(ptr) (void *)(ptr)
552#endif 553#endif
553 554