I'm porting lwIP for Android, and there is a step which says:
If your processor cannot read from/write to misaligned addresses, then you need to tell your compiler that the data may be not aligned and it must generate multiple byte or word load/stores to access it.
Now I wonder how to write in a header file, "If you can read from/write to misaligned addresses, don't do anything. Otherwise, do your alignment magic."
It turns out that Linux provides portable macros for doing unaligned read and write, and these are present in the NDK includes:
#include <asm/unaligned.h>
put_unaligned()
get_unaligned()
That said, the utility of trying to run lwIP on Android seems a bit questionable. Android runs atop a Linux kernel, which includes its own network stack. It will also typically prohibit typical (application) user processes from doing raw network operations. The one sort of case where I could see this might make sense would be if you had your own custom communication channel (USB network adapter or something like that) which you wanted to manage entirely in unprivileged application code and talk IP over, without plugging it into the kernel as a network interface.