Initial import from DragonflyBSD. Minor change (attribute extension)
to make it compiling on FreeBSD+clang.