Not all versions of sed has "sed -r", so change it to use basic
regular expressions. Furthermore, not all systems support \| in basic
regular expressions, to work around it by converting the script names
explicitly.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Add the first "preprocessor functions". These are simply "magic"
single-line macros with a suitable expansion function. The first
application is functions equal to the %if directives, e.g.
%ifdef blah == %if %isdef(blah) except can be used anywhere (not just
in %if statements like defined() in C.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
In 41e9682efe we've
changed the nasm_quote arguments still not all callers
were converted which could lead to nil dereference.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Simplify the code generators by merging the two hash constant arrays
into one. The hash is effectively the same, although the order of the
constants differ (possibly in a way which makes the indexing easier.)
The main difference is the amount of code is necessary to generate
each of the output C files.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This script is redundant with the far more capable
nasmlib/perfhash.pl, which is the one invariably used.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The hacky %arg and %local directives build directives as strings which
they then tokenize and call do_directive() recursively with. Factor
these out and remove the recursion.
It is too bad that %arg and %local didn't include the [] brackets in
the created macros; if so it would have been possible to do something
sane with 64-bit register operands. Sigh.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
ERR_PASS1 only remains in three places:
a. Unterminated %! string, an error
- Should be signalled no matter which pass it is encountered in
b. Two cases of map file problems in outbin
- The buffered warning system take care of that issue
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
A negative number is two tokens: a minus sign and a positive
number. For most uses we still want to generate signed numbers; for
specific uses there might be motivation for an unsigned output, but in
most cases it would be confusing.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
The fact that smac->expansion is stored in reverse order is a detail
of the implementation, and should not be forced on the caller of
define_smacro().
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Set the hash size scaling constant to 1.6, signifying 3.2 times the
hash load. This both reduces the convergence time and makes it less
likely (< 25%) that a non-entry will require a secondary comparison,
and after all, in most of our use cases non-entries are by far the
more common.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Fold the prepreprocessor and the nop preprocessor into the main
preprocessor. This means handling # cpp-like lines and TASM
compatibility tokens in the preprocessor proper, but that is really
not very hard to do.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
With -Lb, it is possible that we don't have a filename for the current
code expansion. In that case, suppress calling dfmt->linenum as some
debug backends *really* aren't equipped to handle that case.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed and unsigned are really two flags; might as well allow this
field to contain additional flags.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If the segment number changes, we also need to invoke dfmt->linenum(),
as a .nolist macro may end up emitting to more than one section.
This also adds the source location explicitly to the output data
structure; the cost for that is minimal, and will enable a more
sophisticated debug backend to receive the entire data structure in
the future.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If -std=c17 and -std=c11 don't work, try -std=c99 as well.
-std=c90 is unlikely to work because of the requirement for "long
long" on L32 platforms, which isn't likely to be supported on a pure
C90 compiler.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
If the compiler supports it, use -std=c17 or -std=c11. Hopefully, this
will give us more predictable behavior in some cases.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
With some combinations of options tests for typeof, snprintf, and
vsnprintf end up with warnings promoted to errors, which then trigger
incorrect results for these tests. Move the typeof test to the end,
and write specific tests for snprintf and vsnprintf.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
printf("%d", <size_t>) is invalid. As this is for legacy compilers,
don't rely on %zu but rather cast to unsigned long long.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Don't pass a NULL filename to dfmt->linenum even if -Lb is in use; it
confuses the heck out of some debug backends.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reverse the invocation lists once each list is complete, so that the
lists passed to the macro backend are in true invocation order.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
list_reverse() used "next" as an argument, while also needing to
refer to the structure field "next". Furthermore, the two temp
variables can be made generic by making them void *, and as this is
not a loop construct this is doable by declaring them inside the macro
loop.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
We need the exact match in the rbtree for the current section. An
approximate match is not acceptable.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Sometimes we want to search for an exact key only, and reject the case
when tree->key < key. Add rb_search_exact() for this purpose, rather
than forcing the caller to perform the comparison in open code.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Sometimes we want to search for an exact key only, and reject the case
when tree->key < key. Add rb_search_exact() for this purpose, rather
than forcing the caller to perform the comparison in open code.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Collect macro call/nesting information for the benefit of the debug
back end. So far, the only backend for which this is provided is the
debug back end, to show what information is present.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Add operations to get the first and last entry in the tree,
respectively. Searching for 0 or ~UINT64_C(0) is not sufficient in the
presence of duplicated keys, and is more inefficient anyway.
rb_first() followed by rb_next() until NULL, or equivalently rb_last()
followed by rb_prev() until NULL, can be used to walk the tree in key
order (ascending or descending), including all duplicate key
entries.
Since this is a *threaded* tree now, this walk can safely free entires
as it goes along, as long as the whole tree is destroyed; once any one
entry has been freed, the tree is no longer valid for anything other
than proceeding with the same tree walk.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Change the left-leaning red-black (LLRB) trees into left-leaning
threaded red-black trees. Instead of NULL pointers at leaf nodes, use
the otherwise unused field as a pointer to the lexical predecessor
(left) or successor (right). This allows fast previous/next
interator operation without needing to keep track of the root of the
tree at all times.
The additional metadata that needs to be kept can be done for "free"
simply by changing "bool red" into a flag field.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Update the table used by pass_type() to give the name of the pass
type. It was not updated properly after PASS_PREPROC was added.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Disable the %pragma list options in k_test.asm to avoid nasty
surprises. LISTOPT is -L+ by default and can be overridden on the
command line, so the %pragma is not just unnecessary but problematic.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Add operations to get the first and last entry in the tree,
respectively. Searching for 0 or ~UINT64_C(0) is not sufficient in the
presence of duplicated keys, and is more inefficient anyway.
rb_first() followed by rb_next() until NULL, or equivalently rb_last()
followed by rb_prev() until NULL, can be used to walk the tree in key
order (ascending or descending), including all duplicate key
entries.
Since this is a *threaded* tree now, this walk can safely free entires
as it goes along, as long as the whole tree is destroyed; once any one
entry has been freed, the tree is no longer valid for anything other
than proceeding with the same tree walk.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
config/unconfig.h is build from config/config.h.in, but the latter
doesn't exist in the repository either. config/unconfig.h is cleaner,
so check it back into the repository, to let non-Unix-sh people be
able to build from the repo.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
NASM would incorrectly only allow for the alignment to be increased,
even when overridden by the user. Allow the user to specify any
alignment value and have it override the partition type default.
The user can increade their own alignment value specification later,
of course, and the sectalign directive will present a floor for either
kind of specification.
Reported-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Still technically not defined behavior, but this *should* work on all
reasonable or semi-reasonable systems.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Commit 6d36d8684 added a wrong break statement to case 'x'
in rdflib.c::main() at line235. That case 'x' must "fall
through" into case 't' which re-checks the argument.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Commit 8dc965347 removed writing of the timestamp size to library
header. (Accidentally, I guess??) The attached patch adds it back.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
- config/watcom.h: update.
- Mkfiles/openwcom.mak: -wcd=124 to silence "Comparison result always 0"
warnings from error.h::debug_level()
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>