fopencookie seems glibc-specific, so unavailable on BSD.
BSD has had funopen(3) since 4.4, so it has an alternative. FreeBSD has implemented fopencookie(3) since v11, but FreeBSD is the BSD most willing to implement Linux interfaces for various reasons.