jgabaut / koliseo Goto Github PK
View Code? Open in Web Editor NEWAn arena allocator library in C.
Home Page: https://jgabaut.github.io/koliseo-docs
License: GNU General Public License v3.0
An arena allocator library in C.
Home Page: https://jgabaut.github.io/koliseo-docs
License: GNU General Public License v3.0
The basic_example
provided is calling the KLS_PUSH()
macro passing the Example
type itself.
This is not recommended to do, since the call won't be correctly updated if you change the type of the declaration and the typedef
ends up having an incorrect size.
Using an expression pointer size is preferreable (eg. *example
instead).
Examples:
Foo* ex = KLS_PUSH(kls, Foo);
Being erroneously changed to look like this (dev forgets to update right side):
Bar* ex = KLS_PUSH(kls, Foo);
When sizeof(Foo) != sizeof(Bar)
typedef Bar Foo;
[ Lots of code ...]
Foo* ex = KLS_PUSH(kls, Bar);
Going to:
typedef Bar Baz; // Notice the changed typedef
[ Lots of code ...]
Foo* ex = KLS_PUSH(kls, Bar); // This is not the same...
When sizeof(Baz) != sizeof(Foo)
Currently, KLS_PUSH
macros rely on a Type
name being passed to leverage _Alignof
and pass alignment of requested type.
This implicates:
C11
to build (since _Alignof
support is >=C11
)-Wpedantic
warning, maybe there's compiler extensions able to do this._Alignof
reliance
C99
.
__alignof__
(non-standard extension) is defined, when missing C11
.
_Alignof
is not to be taken easily, since:
-Wpedantic
, haven't tried yet) may not be advisable__alignof__
would need investigation of the extension, and would still only work with gcc
basic_example
should be fixedREADME
should be updatedKLS_BASIC
backend calls should be fixed.At the moment, the base for allocation in the list generated header when using _gl()
functions is malloc()
.
Support for custom allocation could be added.
Using KLS_PUSH_ARR_T_NAMED()
anywhere causes compilation to fail.
To Reproduce
0.4.1
make anviltest
Building many_temp_regions_named.k testIn file included from tests/error/many_temp_regions_named.c:1:
tests/error/many_temp_regions_named.c: In function ‘main’:
tests/error/../../src/koliseo.h:552:53: error: expected expression before ‘)’ token
552 | #define KLS_PUSH_ARR_T(kls_temp, type, count) (type*)kls_temp_push_zero_AR((kls_temp), sizeof(type), _Alignof(type), (count))
| ^
tests/error/../../src/koliseo.h:566:65: note: in expansion of macro ‘KLS_PUSH_ARR_T’
566 | #define KLS_PUSH_ARR_T_NAMED(kls_temp, type, count, name, desc) KLS_PUSH_ARR_T((kls_temp),(type),(count))
| ^~~~~~~~~~~~~~
tests/error/../../src/koliseo.h:596:54: note: in expansion of macro ‘KLS_PUSH_ARR_T_NAMED’
596 | #define KLS_PUSH_T_NAMED(kls_temp, type, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), type, 1, (name), (desc))
| ^~~~~~~~~~~~~~~~~~~~
tests/error/many_temp_regions_named.c:10:22: note: in expansion of macro ‘KLS_PUSH_T_NAMED’
10 | int* dummy = KLS_PUSH_T_NAMED(t_kls,int, "An int", "An int");
Expected behavior
Build should not fail. The definition of the macro should pass the type
argument without wrapping it:
566 | #define KLS_PUSH_ARR_T_NAMED(kls_temp, type, count, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
>=0.4.1
At the moment, the whole windows.h
header is included for the _WIN32
build, which leads to a bunch of unrelated symbols being passed to client code, polluting the namespace and possibly leading to compilation errors due to symbol redefinitions.
To resolve the issue, the inclusion should be narrowed down to the least amount of headers possible.
The README
file is currently suggesting that the Region
feature uses an intrusive linked list, while it's actually using a plain old linked list.
Describe the bug
It seems that the variadic format of kls_log()
doesn't go well with some Linux versions.
On any attempt to call the function, and subsequently vfprintf()
, which is the actual culprit, a crash happens because of missing support.
If the platform really is the cause, this would effectively lock some distros from debugging for versions >0.1.11
, since before 0.1.12
kls_log()
was not variadic.
I removed mentions of 32bit Linux
since I don't believe that's the culprit for this one.
Useful backtrace line was:
with __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74 74
../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
#1 0x00007ffff7c76db1 in __vfprintf_internal (_..._)
at ./stdio-common/vfprintf-internal.c:1517
This link mentions something similar but doesn't ultimately pin the problem to a platform.
This comment seems to suggest it's about printing stuff.
The issue may be related to printing sized stuff which will have a different size on some platforms.
To Reproduce
kls_log()
call.Expected behavior
Log function prints to debug log file and returns peacefully.
some Linux
>=0.1.12
As of 0.3.17
, anvil
build fails when using invil
.
The issue seems to be that current version tries to build out-of-order: 0.3.17
is followed by 0.3.2
, which sees unexpected files and a failed git switch
. However, a separate issue coming from the split enable-curses
config flag.
To Reproduce
./scripts/boostrap_anvil.sh repo_invil && ./anvil -i
0.3.17
failsConsole log, with some ellipses:
/usr/bin/ld: static/demo.o: warning: relocation against `stdscr' in read-only section `.text.startup'
/usr/bin/ld: static/demo.o: in function `main':
MYDIR/repos/koliseo/static/demo.c:172:(.text.startup+0x5ca): undefined reference to `initscr'
/usr/bin/ld: MYDIR/repos/koliseo/static/demo.c:173:(.text.startup+0x5d1): undefined reference to `stdscr'
/usr/bin/ld: MYDIR/repos/koliseo/static/demo.c:173:(.text.startup+0x5d6): undefined reference to `wclear'
[...]
/usr/bin/ld: src/koliseo.o: in function `kls_show_toWin':
MYDIR/repos/koliseo/src/koliseo.c:2009:(.text+0xb2a): undefined reference to `wclear'
/usr/bin/ld: MYDIR/repos/koliseo/src/koliseo.c:2010:(.text+0xb48): undefined reference to `wborder'
[...]
/usr/bin/ld: src/koliseo.o: in function `kls_show_toWin':
MYDIR/repos/koliseo/src/koliseo.c:2049:(.text+0xd0d): undefined reference to `wrefresh'
/usr/bin/ld: MYDIR/repos/koliseo/src/koliseo.c:2054:(.text+0xd1c): undefined reference to `wgetch'
/usr/bin/ld: src/koliseo.o: in function `kls_temp_show_toWin':
MYDIR/repos/koliseo/src/koliseo.c:2094:(.text+0xde8): undefined reference to `wclear'
/usr/bin/ld: MYDIR/repos/koliseo/src/koliseo.c:2095:(.text+0xe06): undefined reference to `wborder'
/usr/bin/ld: MYDIR/repos/koliseo/src/koliseo.c:2096:(.text+0xe12): undefined reference to `wrefresh'
[...]
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:649: demo] Error 1
[WARN] do_init(): Build failed for tag {0.3.17}. Err: make failed
[INFO] Trying to build {"0.3.2"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit '6116d3415e6609831a90c53d22866e9e1dca1ca7'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.2}. Err: git switch failed
[INFO] Trying to build {"0.3.3"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit 'a7d4c6c0d858c463e878c68f804ed053ee773b38'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.3}. Err: git switch failed
[INFO] Trying to build {"0.3.4"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit 'cc2f581fd89cf4d66df86c713d527a053c124b4b'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.4}. Err: git switch failed
[INFO] Trying to build {"0.3.5"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit '91d097d7b0518cbde556d095b88c4a1c0955e649'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.5}. Err: git switch failed
[INFO] Trying to build {"0.3.6"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit '5f033ce72d1bb7a3bd0f654a16b3ac0b515bedb7'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.6}. Err: git switch failed
[INFO] Trying to build {"0.3.7"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit '2207768dcfefca4f8b725bef90f30afb83148146'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.7}. Err: git switch failed
[INFO] Trying to build {"0.3.8"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit '495ad957e71fdffd9487d284d5fd9da89276b328'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.8}. Err: git switch failed
[INFO] Trying to build {"0.3.9"}
[WARN] git switch failed with status: 128
fatal: atteso branch, ricevuto commit '7bbe81c020904ef11f8e53745d2326117169e92b'
suggerimento: If you want to detach HEAD at the commit, try again with the --detach option.
[WARN] do_init(): Build failed for tag {0.3.9}. Err: git switch failed
[WARN] No tag provided for query op.
[WARN] do_query() failed in handle_amboso_env(). Err: No tag provided.
0.3.17
From version 0.3.0
, (see PR), a FIXME
has been put in place at the beginning of koliseo.c.
Right now, calls to exit()
from runtime error checks never try to fclose(KOLISEO_DEBUG_FP)
. As a result, if it is initialised, it can leak when an error (say, Out-of-memory
) happens.
This should be corrected because even if the lib doesn't initialise the pointer, it could still be made ready from calling code.
At the moment, the macro WINDOWS_BUILD
is controlling some preprocessor directives that, in reality, should be guarded by _WIN32
.
Even when using the proper gcc
from mingw
(x86_64-w64-mingw-gcc
) and adding the proper include/lib directories (set by from configure.ac
in KOLISEO_CFLAGS
and KOLISEO_LDFLAGS
), the build still fails because of the mentioned WINDOWS_BUILD
guard issue.
This is only relevant when trying to build without using the provided Makefile.am
(could happen in a user repo).
To reproduce:
Build using x86_64-w64-mingw32-gcc
:
-I /usr/x86_64-w64-mingw32/include
-L /usr/x86_64-w64-mingw32/lib
-static -fstack-protector
Build fails because of incorrect format specifiers (those that are guarded by WINDOWS_BUILD
rather than _WIN32
are not getting enabled, resulting in Linux
code being used
Version <=0.4.1
After 0.3.1
, the KLS_DEBUG_CORE
define in koliseo.h
also includes windows.h
. This makes the windows build of the library incompatible with raylib
, since builds will fail with redefined symbols.
mingw32
>=0.3.1
With 0.4.0
, core macros were updated not to expect a count argument (defaulting to 1
).
Old syntax was refactored to KLS_PUSH_ARR()
and similarly named macros.
basic_example.c
is still showing the old syntax for the push call, which would not compile now.
>= 0.4.0
At the moment, the internal lists for allocated KLS_Region
are simple linked lists.
A new implementation leveraging a doubly linked list could be added.
The current API would need a deep refactor to ensure sound operations when handing the different list implementation.
At the moment, there's no plans on how to approach the refactor of the current internal symbols.
At the moment the KLS_Conf
default is not const
and can be reassigned by depending code. This could break the KLS_Region_List
backend when using another Koliseo
.
const KLS_Conf kls_default_conf__
kls_new()
calls made for KLS_BASIC
backend, to use kls_new_conf(kls_default_conf__)
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.