--- include/uapi/linux/libc-compat.h.orig +++ include/uapi/linux/libc-compat.h @@ -165,10 +165,102 @@ #define __UAPI_DEF_XATTR 1 #endif + +/* + * Support of guessed LIBC musl, since neither glibc nor kernel space. + * Written for musl libc 1.1.16. Mimics the glibc support above. + */ +#elif !defined(__KERNEL__) /* and not __GLIBC__ */ + +/* Coordinate with musl libc net/if.h header. */ +#if defined(_NET_IF_H) + +/* LIBC headers included first so don't define anything + * that would already be defined. */ + +#define __UAPI_DEF_IF_IFCONF 0 +#define __UAPI_DEF_IF_IFMAP 0 +#define __UAPI_DEF_IF_IFNAMSIZ 0 +#define __UAPI_DEF_IF_IFREQ 0 + +/* Everything up to IFF_DYNAMIC, matches net/if.h */ +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0 + +/* musl libc defines IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0 + +#else /* _NET_IF_H */ + +/* Linux headers included first, and we must define everything + * we need. Will define the corresponding structures twice + * if net/if.h is included later ? */ + +#define __UAPI_DEF_IF_IFCONF 1 +#define __UAPI_DEF_IF_IFMAP 1 +#define __UAPI_DEF_IF_IFNAMSIZ 1 +#define __UAPI_DEF_IF_IFREQ 1 +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 + +#endif /* _NET_IF_H */ + +/* Coordinate with musl libc netinet/in.h header. */ +#if defined(_NETINET_IN_H) + +/* musl 1.1.16 LIBC netinet/in.h defines the following (to 0), + * so it's useless to set them again: + * __UAPI_DEF_IN_ADDR __UAPI_DEF_IN_IPPROTO + * __UAPI_DEF_IN_PKTINFO __UAPI_DEF_IP_MREQ + * __UAPI_DEF_SOCKADDR_IN __UAPI_DEF_IN_CLASS + * __UAPI_DEF_IN6_ADDR __UAPI_DEF_IN6_ADDR_ALT + * __UAPI_DEF_SOCKADDR_IN6 __UAPI_DEF_IPV6_MREQ + * __UAPI_DEF_IPPROTO_V6 __UAPI_DEF_IPV6_OPTIONS + * __UAPI_DEF_IN6_PKTINFO __UAPI_DEF_IP6_MTUINFO + */ + +#else /* _NETINET_IN_H */ + +/* Linux headers included first, and we must define everything + * we need. Will define the corresponding structures twice + * if netinet/in.h is included later ? */ + +#define __UAPI_DEF_IN_ADDR 1 +#define __UAPI_DEF_IN_IPPROTO 1 +#define __UAPI_DEF_IN_PKTINFO 1 +#define __UAPI_DEF_IP_MREQ 1 +#define __UAPI_DEF_SOCKADDR_IN 1 +#define __UAPI_DEF_IN_CLASS 1 + +#define __UAPI_DEF_IN6_ADDR 1 +#define __UAPI_DEF_IN6_ADDR_ALT 1 +#define __UAPI_DEF_SOCKADDR_IN6 1 +#define __UAPI_DEF_IPV6_MREQ 1 +#define __UAPI_DEF_IPPROTO_V6 1 +#define __UAPI_DEF_IPV6_OPTIONS 1 +#define __UAPI_DEF_IN6_PKTINFO 1 +#define __UAPI_DEF_IP6_MTUINFO 1 + +#endif /* _NETINET_IN_H */ + +/* musl libc does not provide IPX support */ +#define __UAPI_DEF_SOCKADDR_IPX 1 +#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 +#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 +#define __UAPI_DEF_IPX_CONFIG_DATA 1 +#define __UAPI_DEF_IPX_ROUTE_DEF 1 + +/* Definitions for sys/xattr.h */ +#if defined(_SYS_XATTR_H) +#define __UAPI_DEF_XATTR 0 +#else +#define __UAPI_DEF_XATTR 1 +#endif + + /* If we did not see any headers from any supported C libraries, * or we are being included in the kernel, then define everything * that we need. */ -#else /* !defined(__GLIBC__) */ +#else /* defined(__KERNEL__) */ /* Definitions for if.h */ #define __UAPI_DEF_IF_IFCONF 1 @@ -208,6 +300,6 @@ /* Definitions for xattr.h */ #define __UAPI_DEF_XATTR 1 -#endif /* __GLIBC__ */ +#endif /* __KERNEL__ or __GLIBC__ or libc */ #endif /* _LIBC_COMPAT_H */