OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [tools/] [riscv-gnu-toolchain-master/] [linux-headers/] [include/] [linux/] [libc-compat.h] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
/*
2
 * Compatibility interface for userspace libc header coordination:
3
 *
4
 * Define compatibility macros that are used to control the inclusion or
5
 * exclusion of UAPI structures and definitions in coordination with another
6
 * userspace C library.
7
 *
8
 * This header is intended to solve the problem of UAPI definitions that
9
 * conflict with userspace definitions. If a UAPI header has such conflicting
10
 * definitions then the solution is as follows:
11
 *
12
 * * Synchronize the UAPI header and the libc headers so either one can be
13
 *   used and such that the ABI is preserved. If this is not possible then
14
 *   no simple compatibility interface exists (you need to write translating
15
 *   wrappers and rename things) and you can't use this interface.
16
 *
17
 * Then follow this process:
18
 *
19
 * (a) Include libc-compat.h in the UAPI header.
20
 *      e.g. #include <linux/libc-compat.h>
21
 *     This include must be as early as possible.
22
 *
23
 * (b) In libc-compat.h add enough code to detect that the comflicting
24
 *     userspace libc header has been included first.
25
 *
26
 * (c) If the userspace libc header has been included first define a set of
27
 *     guard macros of the form __UAPI_DEF_FOO and set their values to 1, else
28
 *     set their values to 0.
29
 *
30
 * (d) Back in the UAPI header with the conflicting definitions, guard the
31
 *     definitions with:
32
 *     #if __UAPI_DEF_FOO
33
 *       ...
34
 *     #endif
35
 *
36
 * This fixes the situation where the linux headers are included *after* the
37
 * libc headers. To fix the problem with the inclusion in the other order the
38
 * userspace libc headers must be fixed like this:
39
 *
40
 * * For all definitions that conflict with kernel definitions wrap those
41
 *   defines in the following:
42
 *   #if !__UAPI_DEF_FOO
43
 *     ...
44
 *   #endif
45
 *
46
 * This prevents the redefinition of a construct already defined by the kernel.
47
 */
48
#ifndef _LIBC_COMPAT_H
49
#define _LIBC_COMPAT_H
50
 
51
/* We have included glibc headers... */
52
#if defined(__GLIBC__)
53
 
54
/* Coordinate with glibc netinet/in.h header. */
55
#if defined(_NETINET_IN_H)
56
 
57
/* GLIBC headers included first so don't define anything
58
 * that would already be defined. */
59
#define __UAPI_DEF_IN6_ADDR             0
60
/* The exception is the in6_addr macros which must be defined
61
 * if the glibc code didn't define them. This guard matches
62
 * the guard in glibc/inet/netinet/in.h which defines the
63
 * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
64
#if defined(__USE_MISC) || defined (__USE_GNU)
65
#define __UAPI_DEF_IN6_ADDR_ALT         0
66
#else
67
#define __UAPI_DEF_IN6_ADDR_ALT         1
68
#endif
69
#define __UAPI_DEF_SOCKADDR_IN6         0
70
#define __UAPI_DEF_IPV6_MREQ            0
71
#define __UAPI_DEF_IPPROTO_V6           0
72
#define __UAPI_DEF_IPV6_OPTIONS         0
73
 
74
#else
75
 
76
/* Linux headers included first, and we must define everything
77
 * we need. The expectation is that glibc will check the
78
 * __UAPI_DEF_* defines and adjust appropriately. */
79
#define __UAPI_DEF_IN6_ADDR             1
80
/* We unconditionally define the in6_addr macros and glibc must
81
 * coordinate. */
82
#define __UAPI_DEF_IN6_ADDR_ALT         1
83
#define __UAPI_DEF_SOCKADDR_IN6         1
84
#define __UAPI_DEF_IPV6_MREQ            1
85
#define __UAPI_DEF_IPPROTO_V6           1
86
#define __UAPI_DEF_IPV6_OPTIONS         1
87
 
88
#endif /* _NETINET_IN_H */
89
 
90
/* Definitions for xattr.h */
91
#if defined(_SYS_XATTR_H)
92
#define __UAPI_DEF_XATTR                0
93
#else
94
#define __UAPI_DEF_XATTR                1
95
#endif
96
 
97
/* If we did not see any headers from any supported C libraries,
98
 * or we are being included in the kernel, then define everything
99
 * that we need. */
100
#else /* !defined(__GLIBC__) */
101
 
102
/* Definitions for in6.h */
103
#define __UAPI_DEF_IN6_ADDR             1
104
#define __UAPI_DEF_IN6_ADDR_ALT         1
105
#define __UAPI_DEF_SOCKADDR_IN6         1
106
#define __UAPI_DEF_IPV6_MREQ            1
107
#define __UAPI_DEF_IPPROTO_V6           1
108
#define __UAPI_DEF_IPV6_OPTIONS         1
109
 
110
/* Definitions for xattr.h */
111
#define __UAPI_DEF_XATTR                1
112
 
113
#endif /* __GLIBC__ */
114
 
115
#endif /* _LIBC_COMPAT_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.