Export global constants
Could we add assembler directives to export global variables? For instance, for
u64 g = 42;
it would be good to be able to access g from C.
Can we ensure that g will not be modified external code ?
What’s the motivation?
What’s the motivation?
I asked about this; I wanted to have a file for "API constants" as follows:
require "parameters.jinc"
u64 c_VERIFICATION_KEY_SIZE = VERIFICATION_KEY_SIZE;
u64 c_SIGNING_KEY_SIZE = SIGNING_KEY_SIZE;
...
Jasmin could print the values of the constants above when invoked as jasminc file.jazz -pcstexp, and this output could be parsed, but if it could compile the file to a set of exportable global variables, benchmarking and testing programs could generically refer to these constants (which would be supplied at their compile time).
Easy workaround: you can define functions that simply return the values of these constants.
Easy workaround: you can define functions that simply return the values of these constants.
I was hoping for a way to get the constants at compile-time, but yes I can do it this way, it's no big deal.
The thing is that it is difficult to have both 1) the ability to refer to constants from the outside and 2) the possibility of building shared libraries.
Related PR turning off the export of global data: https://github.com/jasmin-lang/jasmin/pull/41