summaryrefslogtreecommitdiff
path: root/usr.bin/make/lst.h
AgeCommit message (Collapse)Author
2022-03-03make: improve comments and a parameter namerillig
No binary change.
2021-12-15make: use consistent indentation for statements and continuationsrillig
No binary change, except for line numbers in assertions in suff.c.
2021-12-15make: remove redundant comments for multiple-inclusion guardsrillig
2021-12-15make: mark several functions whose result must be usedrillig
Suggested by sjg, to catch more bugs like the memory leak in cond.c 1.303 from 2021-12-13. No binary change.
2021-12-05make: fix commentsrillig
2021-04-03make: use C99 bool type instead of defining its ownrillig
No functional change.
2021-03-15make: indent inline functions for listsrillig
No functional change.
2021-02-01make: remove unused Lst_Destroyrillig
The code in job.c that seemed to use it is inside an '#if 0' block.
2021-01-03make(1): remove anonymous union from struct ListNoderillig
Anonymous structs and unions have been introduced in C11. The code of make is supposed to be compatible with C90 though. The additional members were intended to be used during an interactive debugging session only and were thus not relevant to running the actual code.
2020-12-30make(1): format multi-line commentsrillig
2020-12-13make(1): rename Vector.priv_cap to caprillig
There is no use case for accessing or even modifying the capacity of a vector, therefore there is no need to hide it using the prefix "priv_". This way, the member names are aligned between Buffer and Vector.
2020-12-04make(1): inline Lst_Enqueuerillig
2020-12-04make(1): inline Vector_Donerillig
2020-11-28make(1): reduce memory allocation in Arch_ParseArchiverillig
2020-11-28make(1): reduce pointer indirection for archivesrillig
2020-11-28make(1): remove pointer indirection from GNode.commandsrillig
Just to save a few memory allocations. No noticeable effect on the performance though.
2020-11-27make(1): inline Lst_ForEachUntil in meta moderillig
This means no more unnecessary void pointers in function signatures and no more abstraction level at checking a single element of a list. In most cases it is more appropriate to define a function that operates on the list as a whole, thereby hiding implementation details like the ListNode from the caller.
2020-11-24make(1): indent list functions with tabs instead of spacesrillig
2020-11-10make(1): use consistent definition for MAKE_INLINErillig
2020-10-28make(1): inline Vector_Getrillig
It is simple enough that it neither bloats the code nor warrants the extra function call.
2020-10-25make(1): remove obsolete comment from lst.hrillig
2020-10-25make(1): replace PtrVector with Vector, which can contain any typerillig
2020-10-25make(1): rename type Vector to PtrVectorrillig
This allows the name Vector to be used for a more generic vector type, which will be added soon.
2020-10-25make(1): inline Lst_Copy in Make_ExpandUserillig
2020-10-24make(1): remove unused Lst_Find and Lst_FindFromrillig
2020-10-23make(1): remove Lst_ForEachUntilConcurrentrillig
The remaining callers of that function don't modify the list structurally and thus can use the simpler Lst_ForEachUntil instead.
2020-10-22make(1): add Lst_ForEachUntilConcurrentrillig
Previously, Lst_ForEachUntil allowed the list to be modified while iterating. Almost none of the code needs this, and it's also confusing for human readers. None of the current unit tests makes use of this concurrent modification right now, but that's not evidence enough. Only 72% of the code are covered by unit tests right now, and there are lots of edge cases (whether intended or not) that are not covered by unit tests. Therefore, all calls to Lst_ForEachUntil were changed to Lst_ForEachUntilConcurrent and those that were obvious were changed back. The remaining calls probably don't need the concurrent modification code, but that's not obvious from looking at the code.
2020-10-22make(1): remove Lst_Open, Lst_Next, Lst_Closerillig
These functions had made the Lst data type more complicated and hard to understand than necessary. This additional complexity was not needed in the vast majority of the cases.
2020-10-21make(1): remove unused typedef LstActionProcrillig
2020-10-19make(1): inline simple Lst gettersrillig
The function call variant takes more screen space than the direct field access. Having an abstract API is usually a good idea, in this case of simple read-only member access it makes the code more difficult to read. LstNode_Set has been kept as a function since it is not a read-only accessor function.
2020-10-19make(1): remove unused Lst_ForEachrillig
All of its uses have been inlined since iterating through a linked list is trivial. This avoids the cumbersome callback functions with void pointer parameters, allowing the compiler to perform better type checks.
2020-10-18make(1): add tags to enum typesrillig
This allows IDEs to offer better type information than "anonymous enum".
2020-10-18make(1): rename Lst_Init to Lst_Newrillig
For the other types such as HashTable and Buffer, the Init function does not allocate the memory for the structure itself, it only fills it.
2020-10-18make(1): rename Stack to Vectorrillig
Both Var_Dump and GetActuallyIncludingFile access more than only the top item of the stack, therefore it is more honest to rename the data type.
2020-09-26make(1): inline and remove LstNode_Prev and LstNode_Nextrillig
These functions made the code larger than necessary. The prev and next fields are published intentionally since navigating in a doubly-linked list is simple to do and there is no need to wrap this in a layer of function calls, not even syntactically. (On the execution level, the function calls had been inlined anyway.)
2020-09-25make(1): add tags to some of the unnamed structsrillig
The tags prevent the structs from accidentally becoming compatible types. While here, remove a few typedefs for structs that are single-purpose, since there is no point in abstracting from the actual representation of these types.
2020-09-25make(1): fix build on Debian 9rillig
lst.h:92:5: error: unknown type name 'uint8_t' It had been broken since the previous commit on 2020-09-24 08:23:29.
2020-09-24make(1): make the API of the List partially publicrillig
Accessing the fields List.first, List.last, ListNode.prev, ListNode.next and ListNode.datum in read-only mode should be more efficient than a whole function call. All modifications to the lists or their nodes must still happen via function calls. This change reduces the code size, makes the code faster to execute and allows Lst_ForEach to be written inline without the visual overhead of function calls.
2020-09-24make(1): move documentation for MakeAddAllSrc to its correct placerillig
2020-09-24make(1): rename Lst_ForEach to Lst_ForEachUntilrillig
Since the callback function returns a terminating condition, this is not really a foreach loop. Many of the calls to Lst_ForEachUntil don't make use of the terminating condition, and several don't modify the list structurally, which means they don't need this complicated implementation. In a follow-up commit, Lst_ForEach will be added back with a much simpler implementation that iterates over the list naively, without a terminating condition and without taking the iteration state from Lst_Open/Lst_Next/Lst_Close into account. The migration to this simpler implementation will be done step by step since each callback function needs to be examined closely.
2020-09-24make(1): refactor add_wait_dep to not use Lst_ForEachFrom anymorerillig
It was the last remaining use of that function outside of lst.c. While here, clean up the code of add_wait_dep by removing unreachable code (the GNode lists never contain NULL, only the GNode.commands lists do that).
2020-09-22make(1): use fine-grained type names for lists and their nodesrillig
This is only intended to help the human reader. There is no additional type safety yet.
2020-09-04make(1): use a stack instead of a list for the nested include pathrillig
By using a Stack instead of a Lst, the available API is reduced to the very few functions that are really needed for a stack. This prevents accidental misuse (such as confusing Lst_Append with Lst_Prepend) and clearly communicates what the expected behavior is. A stack also needs fewer calls to bmake_malloc than an equally-sized list, and the memory is contiguous. For the nested include path, all this doesn't matter, but the type is so generic that it may be used in other places as well.
2020-09-02make(1): improve grouping of the Lst functionsrillig
Lst_IsEmpty does not belong in the "create and destroy" group, but in "query information without modifying anything". The functions named LstNode_* all belong together. They do not provide much abstraction, but still they restrict the API and hide a few struct fields that are only used internally by Lst_Open/Lst_Close and Lst_ForEach. Use consistent wording in the documentation of the functions (list, node, datum).
2020-08-30make(1): rename Lst_Datum to LstNode_Datumrillig
2020-08-30make(1): rename Lst_Memeber to Lst_FindDatumrillig
The new name nicely aligns with Lst_Find and Lst_FindFrom.
2020-08-29make(1): rename LstNode functions to match their typerillig
2020-08-29make(1): rename Lst_FindB back to Lst_Findrillig
The migration from "comparison function" to "match function" is done, the "B" in the names is no longer needed.
2020-08-29make(1): migrate remaining Lst_Find to Lst_FindBrillig
While here, rename SuffSuffIsSuffix to SuffSuffGetSuffix since a function named "is" should return a boolean, not a string pointer.
2020-08-29make(1): start replacing Lst_Find with Lst_FindBrillig
Lst_Find is called with a "comparison" function that returns the integer 0 if the desired node is found. This leads to confusion since there are so many different return value conventions for int, such as 0/1 for mimicking false/true, -1/0 as in close(2), and the sign as in strcmp(3). This API is much easier to understand if the "comparison" function is not called a comparison function (since that is too close to strcmp), but a "match" function that just returns a boolean. In Lst_FindFromB, the node argument may be null. This deviates from the other Lst functions, which require Lst and LstNode to generally be non-null. In this case it is useful though to make the calling code simpler. In arch.c, this makes a lot of the previous documentation redundant. In cond.c, the documentation is reduced a little bit since it had already been cleaned up before. It also removes the strange negation from CondFindStrMatch. In dir.c, the documentation collapses as well. In main.c, separating the ReadMakefile function from the callbacks for Lst_FindB allows the former to get back its natural function signature, with proper types and no unused parameters. To catch any accidental mistakes during the migration from Lst_Find to Lst_FindB, the code can be compiled with -DUSE_DOUBLE_BOOLEAN, which will complain about incompatible function pointer types.