Move bitflags module to libstd

This will allow us to provide type-safe APIs in libstd that are C-compatible.
Update for language changes