Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
|
|
|
|
spit out a warning.
|
|
|
|
|
|
|
|
|
|
Fix strspace automatic extension.
The assumption that simply updating the current pointer works is false,
there are cases where previous entries on the stack would absorp vast
amounts of string space, and overload the non-updated entries.
To fix it, we use a shadow copy of the stack, which only records which
entries are pointers within strspace, so that a resize can adjust all
those pointers at once.
Reviewed by millert@
|
|
|
|
and some KNF.
|
|
|
|
Ensure make prints sane error messages when obj/ exists.
|
|
|
|
make -n mode.
Currently works only in sequential make mode. In parallel make mode,
it's just a no-op.
Useful to debug recursive Makefiles, and part of POSIX.
|
|
Suggested by: fgs
|
|
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).
|
|
|
|
|
|
hv is a u_int32_t.
Add __BEGIN_DECLS/__END_DECLS
Remove unused macro (hash_to_info).
Add documentation for the hash functions.
|
|
Jason, that's a candidate for stable...
|
|
|
|
if epsv4 is disabled. problem reported by price@netdoor.com on misc.
|
|
|
|
|
|
|
|
|
|
Also forgot a few CLEANFILES.
|
|
|
|
ok millert@
|
|
|
|
In particular, Dir_MakeFlags is abusing str_concat, and works much better
with buffers.
|
|
There is no code change in this patch, we just move the remaining
`lowparse' functions to the right file, and adjust the interface file
accordingly.
Reviewed by miod@
|
|
This does introduce a proper stack of IFiles to handle included files:
instead of having the current file be a special case, it's also an IFile.
The corresponding code is slightly unobfuscated, removing the error-prone
ParseEOF function, freeing the filename systematically (thus, main.c needs
to strdup stdin), and merging both include functions lookup into one.
The speed gain comes from changing the IFile structure to merge with
fgetln seamlessly.
The low-level parse code is mostly moved to a new file, lowparse.c, to
make things easier to read (see next patch as well).
Accordingly, util.c gains a fgetln.
Note the interaction between Parse_File, Dir_FindFile, and ReadMakefile in
main.c. This patch closes a subtle memory hole (only the Makefile names,
so rather small).
Reviewed by miod@.
|
|
Use the open hashing functions for global contexts instead of List in
var.c.
All the preliminary work to trim down local contexts means that we don't
suffer from the heavy initialization work that a hash table entails.
There is some make kludgery to:
- build the hashing functions as a library,
- recreate hashconsts.h, even if make depend was not invoked.
One point of the hashing scheme written was to separate the computation
of the hash function, and the hash lookup itself. This is very convenient
for make, because of those pesky special variables. hashconsts.h is there
to pre-hash the correct values, which replaces a few expensive string
comparisons with quick hash value comparisons, followed by one expensive
string comparison. The modulus MAGICSLOTS chosen in the Makefile is
ad-hoc: it is small enough to write a small switch without collision,
and will need changing if the hash function changes...
The function quick_lookup is the most important:
it either returns an index, for a local variable, or it does compute a
hashing value, and returns -1.
Another somewhat controversial decision is the use of string intervals.
This avoids either copying a string, or twiddling with a byte for cases
such as ${VAR}.
Finally, the variable name is stored within the variable itself. Since
a given variable name never changes, this makes sense. All that was needed
was a hash library with support for this. Note that the hashing table
holds only a variable pointer AND the corresponding hashing value, WITHOUT
a modulo hashtablesize. Two reasons:
- hash resizes can be done faster, without having to recompute hashing values.
- locality of access. The hash table fits into memory without problem. Once
a candidate slot is found, we check the complete hashing value. Probability
of a collision is very small (32 bits...). So bringing up the whole
variable in memory at once is good: the name will almost always match, in
which case we want the variable value as well, so it makes sense to put
them together.
The ohash functions implement open hashing, as described in Knuth, but with
a variable table size. Choosing powers of 2 sizes does not yield more
collisions, but it makes the hashing scheme much simpler. The thresholds at
which to expand/shrink the tables seem to work well in practice. The
default sizes were chosen such that the tables hardly ever shrink or expand
anyways (though I've tried with smaller/larger sizes to verify that the
shrinking/expanding worked correctly): larger Makefiles hold roughly
500/600 variables, which fits without trouble into a 1024-sized variable.
Disregard #ifdef STATS_HASH, this is some internal scaffolding I'm using
to measure make performance.
The only known issue with open-hashing is that deletions cannot create
empty slots, but do leave slots marked as `occupied once' so that lookup
works. We use a well-known optimization which records those pseudo-empty
slots while looking up values. If the value is not found, the pseudo-empty
slot is returned to be filled. If the value is found, it is swapped with
the pseudo-empty slot. This is an improvement in both cases, since this
shortens the length of lookup chains, eventually pushing the pseudo-empty
slots to the end.
Reviewed by millert@ and miod@
|
|
Some interface work to make it as fast as possible.
|
|
Apart from a few casts, VAR_GLOBAL and friends are separate
data structures, so we use a small array for local variables.
We also junk allVars, since TargFreeGN can release local nodes,
and var.c has explicit lists for its variables already.
Reviewed millert@ and miod@.
|
|
since lookup will start with VAR_CMD in any case.
This fixes VarFind and Var_Parse to handle ctxt == NULL correctly, and
replace those confusing VAR_CMD with proper NULL pointers.
This patch also handles three small details:
- .CURDIR is necessarily set in VAR_GLOBAL,
- suffix handling for archives copies two hard-coded variables, for
which it can use a quick path,
- typos in TargFreeGN.
Reviewed millert@, miod@.
|
|
the GNode's context directly. We rename that special Lst to `SymTable *'
in prevision of things to come.
Along the line, we lose the special GNodes affected to VAR_CMD, VAR_GLOBAL,
VAR_ENV, which become simple Lsts... This is not a problem, except when
getting to a context's name for debugging (handled very nicely by
offsetof).
Again, this is a preparatory patch, which does not gain anything except
for cleaning up issues...
Reviewed by millert@ and miod@, like the previous patch
|
|
This patch may seem a bit non-sensical at first. It simply introduces some
new interface. Specifically, recognizes that some variable names
(.TARGET/$@, .OODATE/$?, .ALLSRC/$>, .IMPSRC/$<, .PREFIX/$*, .ARCHIVE/$!,
.MEMBER/$%) are `special' (the actual variables which are local to a
target, e.g. GNode).
Currently, The Varq functions (for Varquick access) are only stubs to the
normal functions.
This fixes a very important detail before proceeding to turn variable lists
into hash tables: if every GNode holds a hash table, initialization times
for those will be very costly. But generic GNodes only hold those seven
special variables... which can be stored directly into a small array;
the only general cases are the environment, the command line and
global variables.
|
|
- audit code for Lst_Datum, it's never applied to an empty pointer,
so check can be removed -> turn into a macro,
- Lst_First, Lst_Last can become macro as well
- specialized version of Lst_Succ (Lst_Adv) to use in loops where it cannot
fail,
- Lst_Open can no longer fail. Trim down corresponding code.
Reviewed millert@, miod@
|
|
|
|
|
|
automagicaslly disable epsv on ipv4, if epsv fails for single connection.
merge from netbsd-current.
req from fgs.
|
|
|
|
|
|
remove spaces.
|