Fix broken build on macosx due to inclusion of unneeded endian.h . Fix taken from upstream. Closes PR pkg/56098