From bf106e38f22fac59cd75ff2bd2360b34e73e8550 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Sun, 15 Jan 2012 19:11:41 +0000 Subject: [PATCH] Identify type of executable in Windows For Windows, this just uses the RUNTIME_PORT_ID hook that was already in the code to identify which executable you are running Mike --- include/ntconf.h | 4 ++++ sys/winnt/winnt.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/ntconf.h b/include/ntconf.h index c57dd9688..c4813d2d1 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -109,6 +109,10 @@ extern void FDECL(interject, (int)); # endif #endif +#define RUNTIME_PORT_ID /* trigger run-time port identification for + * identification of exe CPU architecture + */ + /* The following is needed for prototypes of certain functions */ #if defined(_MSC_VER) #include /* Provides prototypes of exit(), spawn() */ diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index cf6f6152f..0817e4858 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -313,6 +313,7 @@ genericptr_t ptr2; } } + void interject(interjection_type) int interjection_type; @@ -320,6 +321,36 @@ int interjection_type; if (interjection_type >= 0 && interjection_type < INTERJECTION_TYPES) msmsg(interjection_buf[interjection_type]); } + +# ifdef RUNTIME_PORT_ID +/* + * _M_IX86 is Defined for x86 processors. This is not defined for x64 processors. + * _M_X64 is Defined for x64 processors. + * _M_IA64 is Defined for Itanium Processor Family 64-bit processors. + * _WIN64 is Defined for applications for Win64. + */ +# ifndef _M_IX86 +# ifdef _M_X64 +# define TARGET_PORT "(x64) " +# endif +# ifdef _M_IA64 +# define TARGET_PORT "(IA64) " +# endif +# endif + +# ifndef TARGET_PORT +# define TARGET_PORT "(x86) " +# endif + +void +append_port_id(buf) +char *buf; +{ + char *portstr = TARGET_PORT; + Sprintf(eos(buf), " %s", portstr); +} +# endif /* RUNTIME_PORT_ID */ + #endif /* WIN32 */ /*winnt.c*/ -- 2.40.0