| 1 |
|
| 2 |
, |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
8 |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
‐ |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
, to |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
d. |
| 23 |
|
| 24 |
|
| 25 |
#ifdef MKSH_USE_AUTOCONF_H |
| 26 |
e */ |
| 27 |
#include "autoconf.h" |
| 28 |
#undef MKSH_USE_AUTOCONF_H |
| 29 |
#endif |
| 30 |
|
| 31 |
#ifndef PAX_COMPAT_H |
| 32 |
#define PAX_COMPAT_H |
| 33 |
#undef MBSDPORT_H |
| 34 |
|
| 35 |
#ifdef __MirBSD__ |
| 36 |
#include <sys/param.h> |
| 37 |
#else |
| 38 |
#include <sys/types.h> |
| 39 |
#endif |
| 40 |
#if HAVE_SYS_MKDEV_H |
| 41 |
#include <sys/mkdev.h> |
| 42 |
#endif |
| 43 |
#if HAVE_SYS_SYSMACROS_H |
| 44 |
#include <sys/sysmacros.h> |
| 45 |
#endif |
| 46 |
#if HAVE_STDINT_H |
| 47 |
#include <stdint.h> |
| 48 |
#endif |
| 49 |
|
| 50 |
#include ".linked/mbsdcc.h" |
| 51 |
|
| 52 |
#undef __attribute__ |
| 53 |
#if HAVE_ATTRIBUTE_BOUNDED |
| 54 |
#define MKSH_A_BOUNDED(x,y,z) __attribute__((__bounded__(x, y, z))) |
| 55 |
#else |
| 56 |
#define MKSH_A_BOUNDED(x,y,z) |
| 57 |
#endif |
| 58 |
#if HAVE_ATTRIBUTE_FORMAT |
| 59 |
#define MKSH_A_FORMAT(x,y,z) __attribute__((__format__(x, y, z))) |
| 60 |
#else |
| 61 |
#define MKSH_A_FORMAT(x,y,z) |
| 62 |
#endif |
| 63 |
#if HAVE_ATTRIBUTE_NONNULL |
| 64 |
#define MKSH_A_NONNULL(x) __attribute__((__nonnull__(x))) |
| 65 |
#else |
| 66 |
#define MKSH_A_NONNULL(x) |
| 67 |
#endif |
| 68 |
#if HAVE_ATTRIBUTE_NORETURN |
| 69 |
#define MKSH_A_NORETURN __attribute__((__noreturn__)) |
| 70 |
#else |
| 71 |
#define MKSH_A_NORETURN |
| 72 |
#endif |
| 73 |
#if HAVE_ATTRIBUTE_PURE |
| 74 |
#define MKSH_A_PURE __attribute__((__pure__)) |
| 75 |
#else |
| 76 |
#define MKSH_A_PURE |
| 77 |
#endif |
| 78 |
#if HAVE_ATTRIBUTE_UNUSED |
| 79 |
#define MKSH_A_UNUSED __attribute__((__unused__)) |
| 80 |
#else |
| 81 |
#define MKSH_A_UNUSED |
| 82 |
#endif |
| 83 |
#if HAVE_ATTRIBUTE_USED |
| 84 |
#define MKSH_A_USED __attribute__((__used__)) |
| 85 |
#else |
| 86 |
#define MKSH_A_USED |
| 87 |
#endif |
| 88 |
|
| 89 |
#if defined(MirBSD) && (MirBSD >= 0x09A1) && \ |
| 90 |
defined(__ELF__) && defined(__GNUC__) && \ |
| 91 |
!defined(__llvm__) && !defined(__NWCC__) |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
#else |
| 99 |
#undef __IDSTRING |
| 100 |
#undef __IDSTRING_CONCAT |
| 101 |
#undef __IDSTRING_EXPAND |
| 102 |
#undef __COPYRIGHT |
| 103 |
#undef __RCSID |
| 104 |
#undef __SCCSID |
| 105 |
#define __IDSTRING_CONCAT(l,p) __LINTED__ ## l ## _ ## p |
| 106 |
#define __IDSTRING_EXPAND(l,p) __IDSTRING_CONCAT(l,p) |
| 107 |
#ifdef MKSH_DONT_EMIT_IDSTRING |
| 108 |
#define __IDSTRING(prefix,string) |
| 109 |
#else |
| 110 |
#define __IDSTRING(prefix,string) \ |
| 111 |
static const char __IDSTRING_EXPAND(__LINE__,prefix) [] \ |
| 112 |
MKSH_A_USED = "@(""#)" #prefix ": " string |
| 113 |
#endif |
| 114 |
#define __COPYRIGHT(x) __IDSTRING(copyright,x) |
| 115 |
#define __RCSID(x) __IDSTRING(rcsid,x) |
| 116 |
#define __SCCSID(x) __IDSTRING(sccsid,x) |
| 117 |
#endif |
| 118 |
|
| 119 |
#ifdef EXTERN |
| 120 |
__IDSTRING(rcsid_compat_h, "$MirOS: src/bin/pax/compat.h,v 1.15 2024/08/17 23:33:51 tg Exp $"); |
| 121 |
__IDSTRING(rcsid_mbsdcc_h, SYSKERN_MBSDCC_H); |
| 122 |
#endif |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
#if !HAVE_CAN_INTTYPES |
| 127 |
#if !HAVE_CAN_UCBINTS |
| 128 |
typedef signed int int32_t; |
| 129 |
typedef unsigned int uint32_t; |
| 130 |
#else |
| 131 |
typedef u_int32_t uint32_t; |
| 132 |
#endif |
| 133 |
#endif |
| 134 |
|
| 135 |
#if !HAVE_CAN_ULONG |
| 136 |
typedef unsigned long u_long; |
| 137 |
#endif |
| 138 |
|
| 139 |
|
| 140 |
typedef unsigned char Wahr; |
| 141 |
#define Ja 1U |
| 142 |
#define Nee 0U |
| 143 |
#define isWahr(cond) ((cond) ? Ja : Nee) |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
#if !defined(LLONG_MIN) && defined(LONG_LONG_MIN) |
| 148 |
#define LLONG_MIN LONG_LONG_MIN |
| 149 |
#define LLONG_MAX LONG_LONG_MAX |
| 150 |
#define ULLONG_MAX ULONG_LONG_MAX |
| 151 |
#endif |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
#if HAVE_OFFT_LONG |
| 156 |
#define OT_FMT "lu" |
| 157 |
#else |
| 158 |
#define OT_FMT "llu" |
| 159 |
#endif |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
#if HAVE_ST_MTIMENSEC |
| 164 |
#define st_timecmp(x,sbpa,sbpb,op) ( \ |
| 165 |
((sbpa)->st_ ## x ## time == (sbpb)->st_ ## x ## time) ? \ |
| 166 |
((sbpa)->st_ ## x ## timensec op (sbpb)->st_ ## x ## timensec) : \ |
| 167 |
((sbpa)->st_ ## x ## time op (sbpb)->st_ ## x ## time) \ |
| 168 |
) |
| 169 |
#define st_timecpy(x,sbpd,sbps) do { \ |
| 170 |
(sbpd)->st_ ## x ## time = (sbps)->st_ ## x ## time; \ |
| 171 |
(sbpd)->st_ ## x ## timensec = (sbps)->st_ ## x ## timensec; \ |
| 172 |
} while ( 0) |
| 173 |
#define st_timexp(x,ts,sbp) do { \ |
| 174 |
(ts)->tv_sec = (sbp)->st_ ## x ## time; \ |
| 175 |
(ts)->tv_nsec = (sbp)->st_ ## x ## timensec; \ |
| 176 |
} while ( 0) |
| 177 |
#else |
| 178 |
#define st_timecmp(x,sbpa,sbpb,op) \ |
| 179 |
((sbpa)->st_ ## x ## time op (sbpb)->st_ ## x ## time) |
| 180 |
#define st_timecpy(x,sbpd,sbps) do { \ |
| 181 |
(sbpd)->st_ ## x ## time = (sbps)->st_ ## x ## time; \ |
| 182 |
} while ( 0) |
| 183 |
#define st_timexp(x,ts,sbp) do { \ |
| 184 |
(ts)->tv_sec = (sbp)->st_ ## x ## time; \ |
| 185 |
(ts)->tv_nsec = 0; \ |
| 186 |
} while ( 0) |
| 187 |
#endif |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
#define BO__TWO 0x01 |
| 192 |
#define BO_CLEXEC 0x02 |
| 193 |
#define BO_MAYBE_DIR 0x04 |
| 194 |
#define binopen2(feat,path,flags) binopen3((feat) | BO__TWO, (path), (flags), 0) |
| 195 |
int binopen3(int, const char *, int, mode_t) |
| 196 |
MKSH_A_NONNULL(2); |
| 197 |
|
| 198 |
ssize_t dwrite(int, const void *, size_t) |
| 199 |
MKSH_A_BOUNDED(__buffer__, 2, 3); |
| 200 |
|
| 201 |
|
| 202 |
#ifndef MIRTOCONF_EARLY |
| 203 |
|
| 204 |
#if !HAVE_DPRINTF |
| 205 |
|
| 206 |
void dprintf(int, const char *, ...) |
| 207 |
MKSH_A_NONNULL(2) |
| 208 |
MKSH_A_FORMAT(__printf__, 2, 3); |
| 209 |
#endif |
| 210 |
|
| 211 |
#if !HAVE_REALLOCARRAY |
| 212 |
void *reallocarray(void *, size_t, size_t); |
| 213 |
#endif |
| 214 |
|
| 215 |
#if !HAVE_STRLCPY |
| 216 |
size_t strlcat(char *, const char *, size_t) |
| 217 |
MKSH_A_BOUNDED(__string__, 1, 3); |
| 218 |
size_t strlcpy(char *, const char *, size_t) |
| 219 |
MKSH_A_BOUNDED(__string__, 1, 3); |
| 220 |
#endif |
| 221 |
|
| 222 |
#if !HAVE_STRMODE |
| 223 |
void strmode(mode_t, char *); |
| 224 |
#endif |
| 225 |
|
| 226 |
#if !HAVE_STRTONUM |
| 227 |
long long strtonum(const char *, long long, long long, const char **); |
| 228 |
#endif |
| 229 |
|
| 230 |
#endif |
| 231 |
|
| 232 |
#endif |