xref: /aosp_15_r20/external/e2fsprogs/lib/ext2fs/tdb/patches/replace-includes (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard WorkerIndex: tdb/tdb.c
2*6a54128fSAndroid Build Coastguard Worker===================================================================
3*6a54128fSAndroid Build Coastguard Worker--- tdb.orig/tdb.c
4*6a54128fSAndroid Build Coastguard Worker+++ tdb/tdb.c
5*6a54128fSAndroid Build Coastguard Worker@@ -29,11 +29,82 @@ Last Changed Date: 2007-06-22 13:36:10 -
6*6a54128fSAndroid Build Coastguard Worker    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
7*6a54128fSAndroid Build Coastguard Worker */
8*6a54128fSAndroid Build Coastguard Worker
9*6a54128fSAndroid Build Coastguard Worker-#include "replace.h"
10*6a54128fSAndroid Build Coastguard Worker-#include "system/filesys.h"
11*6a54128fSAndroid Build Coastguard Worker-#include "system/time.h"
12*6a54128fSAndroid Build Coastguard Worker-#include "system/shmem.h"
13*6a54128fSAndroid Build Coastguard Worker-#include "system/select.h"
14*6a54128fSAndroid Build Coastguard Worker+#ifdef CONFIG_STAND_ALONE
15*6a54128fSAndroid Build Coastguard Worker+#define HAVE_MMAP
16*6a54128fSAndroid Build Coastguard Worker+#define HAVE_STRDUP
17*6a54128fSAndroid Build Coastguard Worker+#define HAVE_SYS_MMAN_H
18*6a54128fSAndroid Build Coastguard Worker+#define HAVE_UTIME_H
19*6a54128fSAndroid Build Coastguard Worker+#define HAVE_UTIME
20*6a54128fSAndroid Build Coastguard Worker+#endif
21*6a54128fSAndroid Build Coastguard Worker+#define _XOPEN_SOURCE 500
22*6a54128fSAndroid Build Coastguard Worker+
23*6a54128fSAndroid Build Coastguard Worker+#include <unistd.h>
24*6a54128fSAndroid Build Coastguard Worker+#include <stdio.h>
25*6a54128fSAndroid Build Coastguard Worker+#include <stdlib.h>
26*6a54128fSAndroid Build Coastguard Worker+#include <stdarg.h>
27*6a54128fSAndroid Build Coastguard Worker+#include <stddef.h>
28*6a54128fSAndroid Build Coastguard Worker+#include <errno.h>
29*6a54128fSAndroid Build Coastguard Worker+#include <string.h>
30*6a54128fSAndroid Build Coastguard Worker+#ifdef HAVE_SYS_SELECT_H
31*6a54128fSAndroid Build Coastguard Worker+#include <sys/select.h>
32*6a54128fSAndroid Build Coastguard Worker+#endif
33*6a54128fSAndroid Build Coastguard Worker+#include <sys/time.h>
34*6a54128fSAndroid Build Coastguard Worker+#include <sys/types.h>
35*6a54128fSAndroid Build Coastguard Worker+#include <time.h>
36*6a54128fSAndroid Build Coastguard Worker+#ifdef HAVE_UTIME_H
37*6a54128fSAndroid Build Coastguard Worker+#include <utime.h>
38*6a54128fSAndroid Build Coastguard Worker+#endif
39*6a54128fSAndroid Build Coastguard Worker+#include <sys/stat.h>
40*6a54128fSAndroid Build Coastguard Worker+#include <sys/file.h>
41*6a54128fSAndroid Build Coastguard Worker+#include <fcntl.h>
42*6a54128fSAndroid Build Coastguard Worker+
43*6a54128fSAndroid Build Coastguard Worker+#ifdef HAVE_SYS_MMAN_H
44*6a54128fSAndroid Build Coastguard Worker+#include <sys/mman.h>
45*6a54128fSAndroid Build Coastguard Worker+#endif
46*6a54128fSAndroid Build Coastguard Worker+
47*6a54128fSAndroid Build Coastguard Worker+#ifndef MAP_FILE
48*6a54128fSAndroid Build Coastguard Worker+#define MAP_FILE 0
49*6a54128fSAndroid Build Coastguard Worker+#endif
50*6a54128fSAndroid Build Coastguard Worker+
51*6a54128fSAndroid Build Coastguard Worker+#ifndef MAP_FAILED
52*6a54128fSAndroid Build Coastguard Worker+#define MAP_FAILED ((void *)-1)
53*6a54128fSAndroid Build Coastguard Worker+#endif
54*6a54128fSAndroid Build Coastguard Worker+
55*6a54128fSAndroid Build Coastguard Worker+#ifndef HAVE_STRDUP
56*6a54128fSAndroid Build Coastguard Worker+#define strdup rep_strdup
57*6a54128fSAndroid Build Coastguard Worker+static char *rep_strdup(const char *s)
58*6a54128fSAndroid Build Coastguard Worker+{
59*6a54128fSAndroid Build Coastguard Worker+	char *ret;
60*6a54128fSAndroid Build Coastguard Worker+	int length;
61*6a54128fSAndroid Build Coastguard Worker+	if (!s)
62*6a54128fSAndroid Build Coastguard Worker+		return NULL;
63*6a54128fSAndroid Build Coastguard Worker+
64*6a54128fSAndroid Build Coastguard Worker+	if (!length)
65*6a54128fSAndroid Build Coastguard Worker+		length = strlen(s);
66*6a54128fSAndroid Build Coastguard Worker+
67*6a54128fSAndroid Build Coastguard Worker+	ret = malloc(length + 1);
68*6a54128fSAndroid Build Coastguard Worker+	if (ret) {
69*6a54128fSAndroid Build Coastguard Worker+		strncpy(ret, s, length);
70*6a54128fSAndroid Build Coastguard Worker+		ret[length] = '\0';
71*6a54128fSAndroid Build Coastguard Worker+	}
72*6a54128fSAndroid Build Coastguard Worker+	return ret;
73*6a54128fSAndroid Build Coastguard Worker+}
74*6a54128fSAndroid Build Coastguard Worker+#endif
75*6a54128fSAndroid Build Coastguard Worker+
76*6a54128fSAndroid Build Coastguard Worker+#ifndef PRINTF_ATTRIBUTE
77*6a54128fSAndroid Build Coastguard Worker+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
78*6a54128fSAndroid Build Coastguard Worker+/** Use gcc attribute to check printf fns.  a1 is the 1-based index of
79*6a54128fSAndroid Build Coastguard Worker+ * the parameter containing the format, and a2 the index of the first
80*6a54128fSAndroid Build Coastguard Worker+ * argument. Note that some gcc 2.x versions don't handle this
81*6a54128fSAndroid Build Coastguard Worker+ * properly **/
82*6a54128fSAndroid Build Coastguard Worker+#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
83*6a54128fSAndroid Build Coastguard Worker+#else
84*6a54128fSAndroid Build Coastguard Worker+#define PRINTF_ATTRIBUTE(a1, a2)
85*6a54128fSAndroid Build Coastguard Worker+#endif
86*6a54128fSAndroid Build Coastguard Worker+#endif
87*6a54128fSAndroid Build Coastguard Worker+
88*6a54128fSAndroid Build Coastguard Worker+typedef int bool;
89*6a54128fSAndroid Build Coastguard Worker+
90*6a54128fSAndroid Build Coastguard Worker #include "tdb.h"
91*6a54128fSAndroid Build Coastguard Worker
92*6a54128fSAndroid Build Coastguard Worker #ifndef u32
93