This shows a measurable improvement in memory and performance for free,
on 64bit at least. Packing is (or should be) safe in this case.
Signed-off-by: Ran Benita <ran234@gmail.com>
Instead of having a darray of pointers to malloc'ed atom_node's, make it
a darray of atom_node's directly.
This makes the code a bit simpler, saves on some malloc's, and the
memory gain/loss even out.
Unfortunately, we are no longer Three Star Programmers ;(
http://c2.com/cgi/wiki?ThreeStarProgrammer
Signed-off-by: Ran Benita <ran234@gmail.com>
Currently, we have one ExprDef type, which contains a tagged union with
the value of all expression types. Turns out, this union is quite
wasteful memory-wise. Instead, create separate types for all expressions
(e.g ExprBinary, ExprInteger) which embed the common fields
(ExprCommon), and malloc them per their size; ExprDef then becomes a
union of all these types, but is just used as a generic pointer.
[Instead of making ExprDef a union, another option is to use
ExprCommon as the generic pointer type and then do up-castings, like we
do with ParseCommon. But this makes the code much uglier.]
The diff is mostly straightforward mechanical adaptations. It could have
been much smaller with the help of C11 anonymous structs (which were
previously a gnu extension). This will have saved all of the 'op' ->
'expr->op', etc changes. But if we can be a bit more portable for a
little effort, we should.
Before (./test/rulescomp, x86 32 bit, -O2):
==12974== total heap usage: 145,217 allocs, 145,217 frees, 10,476,238 bytes allocated
After:
==11145== total heap usage: 145,217 allocs, 145,217 frees, 8,270,358 bytes allocated
Signed-off-by: Ran Benita <ran234@gmail.com>
Instead of having the parser passing strings to the AST, and
symbols/compat etc. resolving them themselves. This simplifies the code
a bit, and makes it possible to print where exactly in the file the bad
keysym originates from.
The previous lazy approach had an advantage of not needlessly resolving
keysyms from unrelated maps. However, I think reporting these errors in
*any* map is better, and the parser is also a bit smarter then old
xkbcomp and doesn't parse many useless maps. So there's no discernible
speed/memory difference with this change.
Signed-off-by: Ran Benita <ran234@gmail.com>
Add a NEWS file, with some retroactive entries. Also add 'check-news' to
configure.ac, though this might be a bit annoying.
Signed-off-by: Ran Benita <ran234@gmail.com>
Fixes build failure with Solaris Studio compilers:
"src/xkbcomp/ast-build.c", line 492: identifier redeclared: XkbFileCreate
current : function(..., enum xkb_map_flags)
previous: function(..., unsigned int) : "src/xkbcomp/ast-build.h", line 98
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
ctype.h is locale-dependent, so using it in our scanners is not optimal.
Let's be deterministic with our own simple functions.
Signed-off-by: Ran Benita <ran234@gmail.com>
Older Automakes give this error without this directive:
Makefile.am: C objects in subdir but `AM_PROG_CC_C_O' not in `configure.ac'
In newer autotools this is included under AC_PROG_CC, but it's harmless
to add.
https://github.com/xkbcommon/libxkbcommon/issues/3
Signed-off-by: Ran Benita <ran234@gmail.com>
1000 is a bit too low for statistical significance on this 6 years old
CPU. Since the benchmark is run manually this shouldn't be a problem.
Signed-off-by: Ran Benita <ran234@gmail.com>
I wanted to avoid the strlen, but we'd better keep the scanner a bit
less surprising and encourage people to use xkb_keymap_new_from_buffer()
instead of they do in fact have access to the size.
Signed-off-by: Ran Benita <ran234@gmail.com>
Improve safety with parenthesis, make the matcher macros use the scanner
ones, and make the 1 variant use %s instead of embedding the msg; this
way the compiler can reuse the string in the binary.
Signed-off-by: Ran Benita <ran234@gmail.com>
Change variable names to avoid the name clash. The warning seen is
src/keysym-utf.c: In function 'bin_search':
src/keysym-utf.c:841: warning: declaration of 'min' shadows a global declaration
src/utils.h:109: warning: shadowed declaration is here
src/keysym-utf.c:842: warning: declaration of 'max' shadows a global declaration
src/utils.h:115: warning: shadowed declaration is here
Signed-off-by: Siddharth Heroor <heroor@ti.com>
'tmp' is stack allocated so tmp->merge is used uninitialized by
AddModMapEntry(). The value doesn't matter much, but it used to
make some modmap merging decision (which doesn't have many
conflicts usually).
Bug inherited from xkbcomp.
Signed-off-by: Ran Benita <ran234@gmail.com>
We now also work with byacc (version tested: 20130925) which some people
prefer, perhaps due to its license (public domain) or performance
(haven't compared).
When using byacc, currently the following warning comes up:
src/xkbcomp/parser.c:954:14: warning: declaration shadows a variable in the global scope [-Wshadow]
YYSTYPE yylval;
^
src/xkbcomp/parser.c:37:20: note: expanded from macro 'yylval'
#define yylval _xkbcommon_lval
^
./src/xkbcomp/parser.h:96:16: note: previous declaration is here
extern YYSTYPE _xkbcommon_lval;
This is due to a bug in byacc - it shouldn't output that extern line in
%pure-parser mode. So the warning stays.
Signed-off-by: Ran Benita <ran234@gmail.com>
Unlike bison, byacc outputs its own parser code *after* our own parser.y
code, which includes the #undef. So this fix is needed for the 'scanner'
-> 'param->scanner' translation to work in the parser.c code generated
by byacc.
Signed-off-by: Ran Benita <ran234@gmail.com>
byacc doesn't support this feature.
We print the line/col of the last scanned token instead. This is slightly
less in case of *parser* errors (not syntax errors), but I couldn't make
it point to another line, and this are pretty cryptic anyways. So it's
good enough. Also might be a bit faster, but haven't checked.
Signed-off-by: Ran Benita <ran234@gmail.com>
Even though the %name-prefix is more sensible, byacc doesn't support it,
but both bison and byacc support the -p argument.
Signed-off-by: Ran Benita <ran234@gmail.com>
Both bison and byacc support this syntax. Bison manpage says something
about this giving more or less options, but we don't care.
Signed-off-by: Ran Benita <ran234@gmail.com>