diff --git a/compat.h b/compat.h new file mode 100644 index 0000000..78167cb --- /dev/null +++ b/compat.h @@ -0,0 +1,70 @@ +/* $MirOS: src/bin/mksh/compat.h,v 1.2 2006/08/16 00:00:24 tg Exp $ */ + +/* Part I: extra headers */ + +#if defined(__sun__) || defined(__INTERIX) +#include +#endif +#if defined(__Plan9__) +#include +#endif +#if !defined(__OpenBSD__) && !defined(__CYGWIN__) +#include +#endif +#if defined(__sun__) || defined(__gnu_linux__) +#include +#endif + + +/* Part II: extra macros */ + +#ifndef timeradd +#define timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif +#ifndef timersub +#define timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + +#ifndef S_ISTXT +#define S_ISTXT 0001000 /* sticky bit */ +#endif + + +/* Part III: OS-dependent additions */ + +#if defined(__gnu_linux__) +size_t strlcat(char *, const char *, size_t); +size_t strlcpy(char *, const char *, size_t); +#endif + +#if defined(__sun__) +size_t confstr(int, char *, size_t); +#endif + +#if defined(__gnu_linux__) || defined(__sun__) || defined(__CYGWIN__) +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +mode_t getmode(const void *, mode_t); +void *setmode(const char *); +#endif + +#if defined(__INTERIX) +#define makedev(x,y) mkdev((x),(y)) +extern int __cdecl seteuid(uid_t); +extern int __cdecl setegid(gid_t); +#endif diff --git a/sh.h b/sh.h index 39f1ed4..d045840 100644 --- a/sh.h +++ b/sh.h @@ -8,7 +8,7 @@ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ -#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.34 2006/08/15 23:54:09 tg Exp $" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.35 2006/08/16 00:00:24 tg Exp $" #include @@ -27,9 +27,6 @@ #include #include #include -#if defined(__Plan9__) -#include -#endif #include #include #if !defined(__sun__)