-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Hello!
I'm trying to compile an older C++ codebase containing a bunch of assumptions regarding the values of pointers. The most problematic assumption is that function pointers are assumed to be aligned to something greater than one - the code basically does something like this (don't ask me why :) ):
size_t GLOBAL_TABLE[] = { reinterpret_cast<size_t>(&callback1), ... };
float compute(int param, float value) {
size_t ptr = GLOBAL_TABLE[param];
if ((ptr & 1) == 0) {
float (*callback)(float) = reinterpret_cast<float(*)(float)>(ptr);
return callback(value);
}
else {
// Do something else...
}
}Since Emscripten packs all functions in the FUNCTION_TABLE_* arrays, the indices will sometimes be odd, and thus the comparison will fail.
To remedy this, I found the FUNCTION_POINTER_ALIGNMENT setting, which sounds like it would pad the tables with zeroes. However, this setting does not seem to have an effect, and searching for uses shows that it's only used for the reserved function pointer setting.
Am I misinterpreting the parameter's purpose, is this setting deprecated or scheduled for removal, or is this something that should work?