Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
997 B

  1. /*
  2. * Public domain
  3. * sys/socket.h compatibility shim
  4. */
  5. #include_next <sys/socket.h>
  6. #ifndef SA_LEN
  7. #define SA_LEN(X) \
  8. (((struct sockaddr*)(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \
  9. ((struct sockaddr*)(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : \
  10. ((struct sockaddr*)(X))->sa_family == AF_UNSPEC ? sizeof(struct sockaddr) : \
  11. sizeof(struct sockaddr))
  12. #endif
  13. #if !defined(SOCK_NONBLOCK) || !defined(SOCK_CLOEXEC)
  14. #define NEED_SOCKET_FLAGS
  15. int _socket(int domain, int type, int protocol);
  16. int _socketpair(int domain, int type, int protocol, int socket_vector[2]);
  17. #ifndef SOCKET_FLAGS_PRIV
  18. #define socket(d, t, p) _socket(d, t, p)
  19. #define socketpair(d, t, p, s) _socketpair(d, t, p, s)
  20. #endif
  21. #endif
  22. /*
  23. * Prevent Solaris 10 system header leakage
  24. */
  25. #ifdef MODEMASK
  26. #undef MODEMASK
  27. #endif
  28. #ifndef SOCK_NONBLOCK
  29. #define SOCK_NONBLOCK 0x4000 /* set O_NONBLOCK */
  30. #endif
  31. #ifndef SOCK_CLOEXEC
  32. #define SOCK_CLOEXEC 0x8000 /* set FD_CLOEXEC */
  33. #endif