Copied function from NetBSD to prevent undefined name error