patch-lib_eu-config.h 3.09 KB
Newer Older
cem's avatar
cem committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
--- lib/eu-config.h.orig	2015-06-11 11:38:55 UTC
+++ lib/eu-config.h
@@ -187,4 +187,147 @@ asm (".section predict_data, \"aw\"; .pr
 #endif
 
 
+/* FreeBSD ports of glibcisms */
+#include <sys/cdefs.h>
+#include <libgen.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#define	_GL_ATTRIBUTE_PURE	__attribute__((__pure__))
+
+struct obstack;
+extern int obstack_printf(struct obstack *, const char *, ...);
+extern int obstack_vprintf(struct obstack *, const char *, va_list);
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+static inline void *
+mempcpy(void * restrict dst, const void * restrict src, size_t len)
+{
+
+	return (((char *)memcpy(dst, src, len)) + len);
+}
+
+static inline wchar_t *
+wmempcpy(wchar_t * restrict dst, const wchar_t * restrict src, size_t len)
+{
+
+	return (wmemcpy(dst, src, len) + len);
+}
+#pragma GCC diagnostic pop
+
+static inline void *
+rawmemchr(const void *s, int c)
+{
+
+	return (memchr(s, c, SIZE_MAX));
+}
+
+static inline void
+tdestroy(void *vroot __unused, void (*freefct)(void *) __unused)
+{
+
+	/* XXX: Just leak the memory for now. */
+}
+
+static inline char *
+canonicalize_file_name(const char *path)
+{
+
+	return (realpath(path, NULL));
+}
+
+#ifndef	TEMP_FAILURE_RETRY
+#define	TEMP_FAILURE_RETRY(expr)	({		\
+	long value;					\
+	do {						\
+		value = (long)(expr);			\
+	} while (value == -1 && errno == EINTR);	\
+	(value);					\
+})
+#endif
+
+#define	strndupa(s, n)	\
+({					\
+	size_t len = (n);		\
+	const char *end;		\
+	char *res;			\
+					\
+	end = memchr((s), 0, (n));	\
+	if (end != NULL)		\
+		len = end - (s);	\
+					\
+	res = alloca(len + 1);		\
+	memcpy(res, (s), len);		\
+	res[len] = '\0';		\
+	res;				\
+})
+
+
+#define	program_invocation_short_name	__DECONST(char *, getprogname())
+#ifndef	loff_t
+#define	loff_t	off_t
+#endif
+#ifndef	off64_t
+#define	off64_t	off_t
+#endif
+
+#define	ftruncate64	ftruncate
+#define	open64	open
+#define	fstat64	fstat
+#define	stat64	stat
+#define	pread64	pread
+#define	mmap64	mmap
+#define	lseek64	lseek
+
+#define	MAP_POPULATE	MAP_PREFAULT_READ
+
+#define	bswap_16	bswap16
+#define	bswap_32	bswap32
+#define	bswap_64	bswap64
+
+#define	fputc_unlocked	putc_unlocked
+#define	fputs_unlocked	fputs
+#define	fwrite_unlocked	fwrite
+#define	fread_unlocked	fread
+
+#ifndef	__BYTE_ORDER
+#define	__BYTE_ORDER	_BYTE_ORDER
+#endif
+#ifndef	__LITTLE_ENDIAN
+#define	__LITTLE_ENDIAN	_LITTLE_ENDIAN
+#endif
+#ifndef	__BIG_ENDIAN
+#define	__BIG_ENDIAN	_BIG_ENDIAN
+#endif
+
+#define	DL_CALL_FCT(fn, args)	((fn) args)
+
+/* This package doesn't really respect --disable-nls.  Hack it. */
+#if	!ENABLE_NLS
+/* Skip loading libintl.h, which is hardcoded in most source files: */
+#define	_LIBINTL_H	1
+#define	dgettext(module, str)	(str)
+#define	gettext(str)	(str)
+
+static inline char *
+bindtextdomain(const char *d __unused, const char *dr __unused)
+{
+
+	return ("/");
+}
+
+static inline char *
+textdomain(const char *dom)
+{
+
+	return (__DECONST(char *, dom));
+}
+
+#define	ngettext(s, p, n)	(((n) == 1) ? (s) : (p))
+#endif
+
 #endif	/* eu-config.h */