lib: Add support for nested atomic sections.