Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh NFC - a build structure code layout change only.



details:   https://anonhg.NetBSD.org/src/rev/c0f61c054162
branches:  trunk
changeset: 834552:c0f61c054162
user:      kre <kre%NetBSD.org@localhost>
date:      Thu Aug 16 15:02:05 2018 +0000

description:
NFC - a build structure code layout change only.

This generates nodenames.h which is a file that used to begin
        #ifdef DEBUG
(line 1) and end with
        #endif
(last line) with no intervening (matching) #else ... ie: for DEBUG use only.

That led to situations where non-debug code would like to make use
of the info provided, if DEBUG was enabled, needed to add #ifdef DEBUG
at the point of use.

Avoid that by providing new macros that are always defined (DEBUG or not,
so now we have a #else) which allow code to be written to make use of
the extra DEBUG info, if it is available, or not, if not.

While here, add double-include protection on the generated .h file
(just being cautious - nothing is ever going to cause it to get
included anywhere twice - or it shouldn't) and add the traditional
comments on the #else and #endif stuff (which is also really useless
as no-one is really expected to ever read the generated file).  Never mind.

Nothing yet (elsewhere in the sh source) uses the new macros, so there's
even less chance of this changing anything than there would otherwise be.

diffstat:

 bin/sh/mknodenames.sh |  30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diffs (52 lines):

diff -r 0af45d95d1a2 -r c0f61c054162 bin/sh/mknodenames.sh
--- a/bin/sh/mknodenames.sh     Thu Aug 16 14:14:51 2018 +0000
+++ b/bin/sh/mknodenames.sh     Thu Aug 16 15:02:05 2018 +0000
@@ -1,5 +1,10 @@
 #! /bin/sh
 
+# $NetBSD: mknodenames.sh,v 1.5 2018/08/16 15:02:05 kre Exp $
+
+# Use this script however you like, but it would be amazing if
+# it has any purpose other than as part of building the shell...
+
 if [ -z "$1" ]; then
        echo "Usage: $0 nodes.h" 1>&2
        exit 1
@@ -9,13 +14,16 @@
 
 test -t 1 && test -z "$2" && exec > nodenames.h
 
-echo "#ifdef DEBUG"
-echo '
+echo "\
 /*
- * Automatically generated by '"$0"'
- * DO NOT EDIT. Do Not "cvs add".
+ * Automatically generated by $0
+ * DO NOT EDIT. Do Not 'cvs add'.
  */
-'
+"
+echo "#ifndef NODENAMES_H_INCLUDED"
+echo "#define NODENAMES_H_INCLUDED"
+echo
+echo "#ifdef DEBUG"
 
 MAX=$(awk < "$NODES" '
        /#define/ {
@@ -48,4 +56,14 @@
 echo '#define NODETYPENAME(type) \'
 echo ' ((unsigned)(type) <= '"${MAX}"' ? NodeNames[(type)] : "??OOR??")'
 echo
-echo '#endif'
+echo '#define NODETYPE(type)   (type), NODETYPENAME(type)'
+echo '#define PRIdsNT          "%d(%s)"'
+echo
+echo '#else /* DEBUG */'
+echo
+echo '#define NODETYPE(type)   (type)'
+echo '#define PRIdsNT          "%d"'
+echo
+echo '#endif /* DEBUG */'
+echo
+echo '#endif /* !NODENAMES_H_INCLUDED */'



Home | Main Index | Thread Index | Old Index