summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-10-18 23:04:32 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-10-18 23:04:32 -0700
commit94a8b34528b42a4fe6f81c8b8bd1ddb6bebaeea9 (patch)
treed7ea6eae9053df5fa04961d88bb29e21b7e4aa50
parentf5191838b70d67e991bef3491d2a60915988079c (diff)
util: Consolidate common macros
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--util/dRegs.c57
-rw-r--r--util/iopl.h54
-rw-r--r--util/mRegs.c57
-rw-r--r--util/modClock.c53
4 files changed, 58 insertions, 163 deletions
diff --git a/util/dRegs.c b/util/dRegs.c
index b7edc8f..0d2f0cb 100644
--- a/util/dRegs.c
+++ b/util/dRegs.c
@@ -1,63 +1,8 @@
-
-
-
-
-
-
-#ifdef __NetBSD__
-# include <sys/types.h>
-# include <machine/pio.h>
-# include <machine/sysarch.h>
-#else
-# if defined(SVR4) && defined(i386)
-# include <sys/types.h>
-# ifdef NCR
- /* broken NCR <sys/sysi86.h> */
-# define __STDC
-# include <sys/sysi86.h>
-# undef __STDC
-# else
-# include <sys/sysi86.h>
-# endif
-# ifdef SVR4
-# if !defined(sun)
-# include <sys/seg.h>
-# endif
-# endif
-# include <sys/v86.h>
-# if defined(sun)
-# include <sys/psw.h>
-# endif
-# endif
-# include "AsmMacros.h"
-#endif /* NetBSD */
-
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#ifdef __NetBSD__
-# define SET_IOPL() i386_iopl(3)
-# define RESET_IOPL() i386_iopl(0)
-#else
-# if defined(SVR4) && defined(i386)
-# ifndef SI86IOPL
-# define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
-# define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
-# else
-# define SET_IOPL() sysi86(SI86IOPL,3)
-# define RESET_IOPL() sysi86(SI86IOPL,0)
-# endif
-# else
-# ifdef linux
-# define SET_IOPL() iopl(3)
-# define RESET_IOPL() iopl(0)
-# else
-# define SET_IOPL() (void)0
-# define RESET_IOPL() (void)0
-# endif
-# endif
-#endif
+#include "iopl.h"
int main(void)
{
diff --git a/util/iopl.h b/util/iopl.h
new file mode 100644
index 0000000..d7890b3
--- /dev/null
+++ b/util/iopl.h
@@ -0,0 +1,54 @@
+#ifdef __NetBSD__
+# include <sys/types.h>
+# include <machine/pio.h>
+# include <machine/sysarch.h>
+#else
+# if defined(SVR4) && defined(i386)
+# include <sys/types.h>
+# ifdef NCR
+ /* broken NCR <sys/sysi86.h> */
+# define __STDC
+# include <sys/sysi86.h>
+# undef __STDC
+# else
+# include <sys/sysi86.h>
+# endif
+# ifdef SVR4
+# if !defined(sun)
+# include <sys/seg.h>
+# endif
+# endif
+# include <sys/v86.h>
+# if defined(sun)
+# include <sys/psw.h>
+# endif
+# endif
+# include "AsmMacros.h"
+#endif /* NetBSD */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __NetBSD__
+# define SET_IOPL() i386_iopl(3)
+# define RESET_IOPL() i386_iopl(0)
+#else
+# if defined(SVR4) && defined(i386)
+# ifndef SI86IOPL
+# define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
+# define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
+# else
+# define SET_IOPL() sysi86(SI86IOPL,3)
+# define RESET_IOPL() sysi86(SI86IOPL,0)
+# endif
+# else
+# ifdef linux
+# define SET_IOPL() iopl(3)
+# define RESET_IOPL() iopl(0)
+# else
+# define SET_IOPL() (void)0
+# define RESET_IOPL() (void)0
+# endif
+# endif
+#endif
diff --git a/util/mRegs.c b/util/mRegs.c
index f359738..843d01d 100644
--- a/util/mRegs.c
+++ b/util/mRegs.c
@@ -1,63 +1,8 @@
-
-
-
-
-
-
-#ifdef __NetBSD__
-# include <sys/types.h>
-# include <machine/pio.h>
-# include <machine/sysarch.h>
-#else
-# if defined(SVR4) && defined(i386)
-# include <sys/types.h>
-# ifdef NCR
- /* broken NCR <sys/sysi86.h> */
-# define __STDC
-# include <sys/sysi86.h>
-# undef __STDC
-# else
-# include <sys/sysi86.h>
-# endif
-# ifdef SVR4
-# if !defined(sun)
-# include <sys/seg.h>
-# endif
-# endif
-# include <sys/v86.h>
-# if defined(sun)
-# include <sys/psw.h>
-# endif
-# endif
-# include "AsmMacros.h"
-#endif /* NetBSD */
-
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#ifdef __NetBSD__
-# define SET_IOPL() i386_iopl(3)
-# define RESET_IOPL() i386_iopl(0)
-#else
-# if defined(SVR4) && defined(i386)
-# ifndef SI86IOPL
-# define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
-# define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
-# else
-# define SET_IOPL() sysi86(SI86IOPL,3)
-# define RESET_IOPL() sysi86(SI86IOPL,0)
-# endif
-# else
-# ifdef linux
-# define SET_IOPL() iopl(3)
-# define RESET_IOPL() iopl(0)
-# else
-# define SET_IOPL() (void)0
-# define RESET_IOPL() (void)0
-# endif
-# endif
-#endif
+#include "iopl.h"
int hex2int(char* str);
diff --git a/util/modClock.c b/util/modClock.c
index 89a291a..45af19b 100644
--- a/util/modClock.c
+++ b/util/modClock.c
@@ -1,61 +1,12 @@
-
-#ifdef __NetBSD__
-# include <sys/types.h>
-# include <machine/pio.h>
-# include <machine/sysarch.h>
-#else
-# if defined(SVR4) && defined(i386)
-# include <sys/types.h>
-# ifdef NCR
- /* broken NCR <sys/sysi86.h> */
-# define __STDC
-# include <sys/sysi86.h>
-# undef __STDC
-# else
-# include <sys/sysi86.h>
-# endif
-# ifdef SVR4
-# if !defined(sun)
-# include <sys/seg.h>
-# endif
-# endif
-# include <sys/v86.h>
-# if defined(sun)
-# include <sys/psw.h>
-# endif
-# endif
-# include "AsmMacros.h"
-#endif /* NetBSD */
-
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+
#ifndef Lynx
#include <fnmatch.h>
#endif
-#ifdef __NetBSD__
-# define SET_IOPL() i386_iopl(3)
-# define RESET_IOPL() i386_iopl(0)
-#else
-# if defined(SVR4) && defined(i386)
-# ifndef SI86IOPL
-# define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
-# define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
-# else
-# define SET_IOPL() sysi86(SI86IOPL,3)
-# define RESET_IOPL() sysi86(SI86IOPL,0)
-# endif
-# else
-# ifdef linux
-# define SET_IOPL() iopl(3)
-# define RESET_IOPL() iopl(0)
-# else
-# define SET_IOPL() (void)0
-# define RESET_IOPL() (void)0
-# endif
-# endif
-#endif
+#include "iopl.h"
#define tolerance 0.01 /* +/- 1% */