-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further modernise the stk(3) stack routines (re: a8eae75)
*** Void pointers *** The stk(3) interface used char pointers throughout for K&R C and C++ compatibility. I gave up all pretense of that long ago (see a34e831) and we now use C89/C90 as our lowest common denominator, so we're allowed to use void pointers. The stkalloc(), stkset(), stkseek() and stkfreeze() functions now return void* instead of char*. This should compatible with old code as implicit typecasts are done. I scanned all the uses of these in current code as well as the complete ast-open-history repo and didn't find problems, nor does 'clang -Wall' throw any warnings. So, no changes should be required. However, this change does allow eliminating a lot of verbose/annoying typecasts from the code, as void pointers can be assigned/passed to all sorts of types. This commit removes those explicit typecasts, improving code legibility. The stkcopy() and stkptr() functions continue to return char*, as the first is purely for copying strings and the second's result is often dereferenced directly to read individual bytes on the stack. *** Deprecate/disuse stkinstall() *** The old stak(3) interface did not pass stack pointers to every function, so to use multiple stacks, one had to be "installed" (activated) and there was only one "active" stack at the time. The new interface has stkinstall() for backward compatibility with this practice; it updates the stack that stkstd refers to. But this is completely redundant as it's much more efficient to simply change the pointer passed to the stack functions. So stkinstall() is deprecated and its use replaced accordingly in the following files: - src/lib/libast/misc/glob.c - src/cmd/ksh93/sh/parse.c - src/cmd/ksh93/sh/trestore.c *** Add stkoverflow() *** In typical AT&T fashion, stkinstall() had another, unrelated function: set a pointer to a char* function called when the system runs out of memory to allocate new stack frames. It can either find memory somewhere and return a pointer, or error out. stkinstall() did not allow unsetting this function pointer to restore the default. This commit adds a replacement stkoverflow() function that sets this function (now of type void*) or restores the default. (The unset functionality is currently unused but may come in handy someday and in any case it's trivial.) This is currently used in: - src/cmd/ksh93/sh/init.c *** Bump libast API version *** In src/lib/libast/features/api, the libast API version is bumped to 20240227 due to the changes above. *** Rework stk(3) manual page *** Rewrote parts to match current practice, e.g., removed references to "the active stack" which never really applied to stk(3). *** Restore stak.h *** Perhaps it was overzealous to remove that in the referenced commit. It's a small header file that simply maps the old stak(3) interface onto stk(3) using some #defines. It remains unused, but the cost of having it is negligible and restoring it restores compatbility with old code we might want to test or backport at some point.
- Loading branch information
Showing
37 changed files
with
316 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.