]> granicus.if.org Git - nethack/commitdiff
Identify type of executable in Windows
authornethack.allison <nethack.allison>
Sun, 15 Jan 2012 19:11:41 +0000 (19:11 +0000)
committernethack.allison <nethack.allison>
Sun, 15 Jan 2012 19:11:41 +0000 (19:11 +0000)
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
sys/winnt/winnt.c

index c57dd96886dd1301f652c9b08a4e2b5599fb5721..c4813d2d1b90bec34639720ba92272eedbe00243 100644 (file)
@@ -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 <process.h>   /* Provides prototypes of exit(), spawn()      */
index cf6f6152f3b4327c9d072e4002ceffdf7a519a70..0817e4858f13544756e51245a6c95bbf8f6bdaf8 100644 (file)
@@ -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*/