History

uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define

This fixes a compile problem of some user space applications by not including linux/libc-compat.h in uapi/if_ether.h. linux/libc-compat.h checks which "features" the header files, included from the libc, provide to make the Linux kernel uapi header files only provide no conflicting structures and enums. If a user application mixes kernel headers and libc headers it could happen that linux/libc-compat.h gets included too early where not all other libc headers are included yet. Then the linux/libc-compat.h would not prevent all the redefinitions and we run into compile problems. This patch removes the include of linux/libc-compat.h from uapi/if_ether.h to fix the recently introduced case, but not all as this is more or less impossible. It is no problem to do the check directly in the if_ether.h file and not in libc-compat.h as this does not need any fancy glibc header detection as glibc never provided struct ethhdr and should define __UAPI_DEF_ETHHDR by them self when they will provide this. The following test program did not compile correctly any more: #include <linux/if_ether.h> #include <netinet/in.h> #include <linux/in.h> int main(void) { return 0; }

Hauke Mehrtens committed 8 years ago

Commit da360291 parent 07a2e1c2 files · +5 −7Browse files

Showing the changes to include/uapi/linux (2 of 2 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/if_ether.h +5 −1
  2. include/uapi/linux/libc-compat.h +0 −6
include/uapi/linux/if_ether.h+5−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
23#define _UAPI_LINUX_IF_ETHER_H23#define _UAPI_LINUX_IF_ETHER_H
24 24
25#include <linux/types.h>25#include <linux/types.h>
26#include <linux/libc-compat.h>
27 26
28/*27/*
29 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble28 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
@@ -151,6 +150,11 @@ · 121 unmodified lines
151 * This is an Ethernet frame header.150 * This is an Ethernet frame header.
152 */151 */
153 152
153/* allow libcs like musl to deactivate this, glibc does not implement this. */
154#ifndef __UAPI_DEF_ETHHDR
155#define __UAPI_DEF_ETHHDR 1
156#endif
157
154#if __UAPI_DEF_ETHHDR158#if __UAPI_DEF_ETHHDR
155struct ethhdr {159struct ethhdr {
156 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */160 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
include/uapi/linux/libc-compat.h+0−6
@@ -264,10 +264,4 @@ · 263 unmodified lines
264 264
265#endif /* __GLIBC__ */265#endif /* __GLIBC__ */
266 266
267/* Definitions for if_ether.h */
268/* allow libcs like musl to deactivate this, glibc does not implement this. */
269#ifndef __UAPI_DEF_ETHHDR
270#define __UAPI_DEF_ETHHDR 1
271#endif
272
273#endif /* _UAPI_LIBC_COMPAT_H */267#endif /* _UAPI_LIBC_COMPAT_H */