Sequester the x* Linux compat. wrappers to include/xsys.h

上级 ac84a025
......@@ -6,21 +6,7 @@
#include <assert.h>
#include <sys/stat.h>
#include <sys/wait.h>
#define O_CREATE O_CREAT
#define xfork() fork()
#define xexit() exit(EXIT_SUCCESS)
static inline void xwait()
{
int status;
if (wait(&status) < 0)
edie("wait");
if (!WIFEXITED(status))
die("bad status %u", status);
}
#define xmkdir(pathname) mkdir((pathname), S_IWUSR|S_IRUSR);
#define xcreat(name) open((name), O_CREATE, S_IRUSR|S_IWUSR)
#define mtenable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
#include "xsys.h"
#else
#include "types.h"
#include "stat.h"
......@@ -28,11 +14,7 @@ static inline void xwait()
#include "mtrace.h"
#include "amd64.h"
#include "fcntl.h"
#define xfork() fork(0)
#define xexit() exit()
#define xmkdir(pathname) mkdir((pathname))
#define xcreat(name) open((name), O_CREATE)
#define xwait() wait()
#include "xsys.h"
#endif
static const bool pinit = true;
......
......@@ -5,29 +5,14 @@
#include <unistd.h>
#include <assert.h>
#include <sys/wait.h>
#define O_CREATE O_CREAT
#define xfork() fork()
#define xexit() exit(EXIT_SUCCESS)
static inline void xwait()
{
int status;
if (wait(&status) < 0)
edie("wait");
if (!WIFEXITED(status))
die("bad status %u", status);
}
#define xcreat(name) open((name), O_CREATE|O_WRONLY, S_IRUSR|S_IWUSR)
#define mtenable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
#include "xsys.h"
#else
#include "types.h"
#include "user.h"
#include "fcntl.h"
#include "amd64.h"
#include "mtrace.h"
#define xfork() fork(0)
#define xexit() exit()
#define xcreat(name) open((name), O_CREATE|O_WRONLY)
#include "xsys.h"
#endif
#define CHUNKSZ 512
......
#if defined(LINUX)
#define O_CREATE O_CREAT
#define xfork() fork()
#define xexit() exit(EXIT_SUCCESS)
static inline void xwait()
{
int status;
if (wait(&status) < 0)
edie("wait");
if (!WIFEXITED(status))
die("bad status %u", status);
}
#define xmkdir(pathname) mkdir((pathname), S_IWUSR|S_IRUSR);
#define xcreat(name) open((name), O_CREATE, S_IRUSR|S_IWUSR)
#define mtenable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
#else // Must be xv6
#define xfork() fork(0)
#define xexit() exit()
#define xmkdir(pathname) mkdir((pathname))
#define xcreat(name) open((name), O_CREATE|O_RDWR)
#define xwait() wait()
#endif
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论