Reputation: 1361
I've written some kernel modules in Ada, and I've hit a bit of a problem. License is defined as a c macro, and I can't work out what it actually is. Is it a suitable solution to simply have some c re-exporting all the c functions which require GPL if both the c and the ada module have GPL compatible licenses? Is there a better way to do this?
Upvotes: 6
Views: 1367
Reputation:
As an approach to sidestepping the problem, Could you leave the license part in C and use Annex B (Interfacing with other languages) features to access it ?
This should contain the problem at least, and allow you to move on with other modules.
At best it may allow you to examine in Ada, what the license looks like and reverse engineer it that way.
Upvotes: 3
Reputation: 44814
Dealing with C macros is a royal PITA. I have a dream that one day C programmers will do the rest of the world a favor and quit using them.
If it were me, I'd run the macro to see what it outputs, then write some Ada code to output the equivalent.
From reading through Roland's answer, it looks to me like the implementation-defined pragma linker_section may be required.
pragma Linker_Section ( [Entity =>] LOCAL_NAME, [Section =>] static_string_EXPRESSION);
LOCAL_NAME must refer to an object that is declared at the library level. This pragma specifies the name of the linker section for the given entity. It is equivalent to
__attribute__((section))
in GNU C and causes LOCAL_NAME to be placed in the static_string_EXPRESSION section of the executable (assuming the linker doesn't rename the section).
Upvotes: 6
Reputation: 205875
As you are probably using GNAT, you may be able to use pragma License "to allow automated checking for appropriate license conditions with respect to the standard and modified GPL."
Upvotes: 2
Reputation: 6563
I'm not sure if this question is a joke or not, but if you're serious about writing kernel modules in Ada, then I can't imagine that setting the module license is much of an obstacle compared to everything else you must have hit.
In any case, the module license is just a string like "license=GPL" in the .modinfo section of the .ko file. In C code, it's built by the __MODULE_INFO()
macro from <linux/moduleparam.h>
, which just creates an array of char
that is set to the string as above, tagged with __attribute__((section(".modinfo")))
.
I would guess that there is probably some analogous way to do this in Ada; if not, in the worst case, it should be possible to do with a linker script. Presumably, you already have some way of handling this anyway, to set the "vermagic=XXX" part of the .modinfo section.
Upvotes: 6