aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/scheme-private.h
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2017-03-23 14:21:36 +0000
committerJustus Winter <[email protected]>2017-04-07 11:50:20 +0000
commit8640fa880d7050917f4729f2c0cb506e165ee446 (patch)
tree3fe41a235ac6af9a902555093ff9814194b44995 /tests/gpgscm/scheme-private.h
parentgpgscm: Make global data constant when possible. (diff)
downloadgnupg-8640fa880d7050917f4729f2c0cb506e165ee446.tar.gz
gnupg-8640fa880d7050917f4729f2c0cb506e165ee446.zip
gpgscm: Allocate small integers in the rodata section.
* tests/gpgscm/Makefile.am (gpgscm_SOURCES): Add new file. * tests/gpgscm/scheme-private.h (struct cell): Move number to the top of the union so that we can initialize it. (struct scheme): Remove 'integer_segment'. * tests/gpgscm/scheme.c (initialize_small_integers): Remove function. (small_integers): New variable. (MAX_SMALL_INTEGER): Compute. (mk_small_integer): Adapt. (mark): Avoid marking objects already marked. This allows us to run the algorithm over objects in the rodata section if they are already marked. (scheme_init_custom_alloc): Remove initialization. (scheme_deinit): Remove deallocation. * tests/gpgscm/small-integers.h: New file. -- Allocate small integers from a fixed pool in the rodata section. This spares us the initialization, and deduplicates integers across different processes. It also makes the integers immutable, increasing memory safety. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tests/gpgscm/scheme-private.h')
-rw-r--r--tests/gpgscm/scheme-private.h7
1 files changed, 1 insertions, 6 deletions
diff --git a/tests/gpgscm/scheme-private.h b/tests/gpgscm/scheme-private.h
index 69b78f26e..abe65e700 100644
--- a/tests/gpgscm/scheme-private.h
+++ b/tests/gpgscm/scheme-private.h
@@ -45,11 +45,11 @@ typedef struct port {
struct cell {
uintptr_t _flag;
union {
+ num _number;
struct {
char *_svalue;
int _length;
} _string;
- num _number;
port *_port;
foreign_func _ff;
struct {
@@ -152,11 +152,6 @@ pointer SHARP_HOOK; /* *sharp-hook* */
pointer COMPILE_HOOK; /* *compile-hook* */
#endif
-#if USE_SMALL_INTEGERS
-/* A fixed allocation of small integers. */
-struct cell_segment *integer_segment;
-#endif
-
pointer free_cell; /* pointer to top of free cells */
long fcells; /* # of free cells */
size_t inhibit_gc; /* nesting of gc_disable */