Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-04-05 00:49:55 +0400
committerJason Perkins <starkos@industriousone.com>2011-04-05 00:49:55 +0400
commit3737111c6847822eacf53d2e0ea5b4fe19c379fa (patch)
tree5996bc716280905cf4c069e065d99e396aeb9395 /src/host
parentb2e7af94cf870722c2abea7df3d91a4b3aa38f6f (diff)
Some cleanup for is64bit() to make it look a bit like the other os functions
Diffstat (limited to 'src/host')
-rwxr-xr-xsrc/host/host.c29
-rwxr-xr-xsrc/host/os_getversion.c6
-rwxr-xr-xsrc/host/os_is64bit.c30
-rwxr-xr-xsrc/host/premake.c8
-rwxr-xr-xsrc/host/premake.h2
5 files changed, 34 insertions, 41 deletions
diff --git a/src/host/host.c b/src/host/host.c
deleted file mode 100755
index 6414359..0000000
--- a/src/host/host.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * \file host.c
- * \brief Functions to query the specifics of the operating environment.
- * \author Copyright (c) 2011 Jason Perkins and the Premake project
- */
-
-#include "premake.h"
-
-/**
- * Determine if we're running under 64-bit Windows.
- */
-int windows_is_64bit_running_under_wow(struct lua_State* L)
-{
-#if PLATFORM_WINDOWS
- typedef BOOL (WINAPI * wow_func_sig)(HANDLE,PBOOL);
-
- BOOL is_wow = FALSE;
- wow_func_sig func = (wow_func_sig)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
- if (func)
- {
- if(! func(GetCurrentProcess(),&is_wow))
- luaL_error(L, "IsWow64Process returned an error");
- }
-#else
- int is_wow = 0;
-#endif
- lua_pushboolean(L, is_wow);
- return 1;
-}
diff --git a/src/host/os_getversion.c b/src/host/os_getversion.c
index c396ed2..d59d06e 100755
--- a/src/host/os_getversion.c
+++ b/src/host/os_getversion.c
@@ -52,10 +52,9 @@ int os_getversion(lua_State* L)
void getversion(struct OsVersionInfo* info)
{
- OSVERSIONINFOEX versionInfo;
- SYSTEM_INFO systemInfo;
+ OSVERSIONINFOEX versionInfo = {0};
+ SYSTEM_INFO systemInfo = {0};
- ZeroMemory(&versionInfo, sizeof(OSVERSIONINFOEX));
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx((OSVERSIONINFO*)&versionInfo);
@@ -63,7 +62,6 @@ void getversion(struct OsVersionInfo* info)
info->minorversion = versionInfo.dwMinorVersion;
info->revision = versionInfo.wServicePackMajor;
- ZeroMemory(&systemInfo, sizeof(SYSTEM_INFO));
GetSystemInfo(&systemInfo);
if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 0)
diff --git a/src/host/os_is64bit.c b/src/host/os_is64bit.c
new file mode 100755
index 0000000..3134751
--- /dev/null
+++ b/src/host/os_is64bit.c
@@ -0,0 +1,30 @@
+/**
+ * \file os_is64bit.c
+ * \brief Native code-side checking for a 64-bit architecture.
+ * \author Copyright (c) 2011 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+
+int os_is64bit(lua_State* L)
+{
+ // If this code returns true, then the platform is 64-bit. If it
+ // returns false, the platform might still be 64-bit, but more
+ // checking will need to be done on the Lua side of things.
+#if PLATFORM_WINDOWS
+ typedef BOOL (WINAPI* WowFuncSig)(HANDLE, PBOOL);
+ WowFuncSig func = (WowFuncSig)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
+ if (func)
+ {
+ BOOL isWow = FALSE;
+ if (func(GetCurrentProcess(), &isWow))
+ {
+ lua_pushboolean(L, isWow);
+ return 1;
+ }
+ }
+#endif
+
+ lua_pushboolean(L, 0);
+ return 1;
+}
diff --git a/src/host/premake.c b/src/host/premake.c
index ff0bdde..7548ff4 100755
--- a/src/host/premake.c
+++ b/src/host/premake.c
@@ -36,6 +36,7 @@ static const luaL_Reg path_functions[] = {
static const luaL_Reg os_functions[] = {
{ "chdir", os_chdir },
{ "copyfile", os_copyfile },
+ { "_is64bit", os_is64bit },
{ "isdir", os_isdir },
{ "getcwd", os_getcwd },
{ "getversion", os_getversion },
@@ -57,12 +58,6 @@ static const luaL_Reg string_functions[] = {
{ NULL, NULL }
};
-static const luaL_Reg host_functions[] =
-{
- { "windows_is_64bit_running_under_wow", windows_is_64bit_running_under_wow },
- { NULL, NULL }
-};
-
/**
* Program entry point.
*/
@@ -77,7 +72,6 @@ int main(int argc, const char** argv)
luaL_register(L, "path", path_functions);
luaL_register(L, "os", os_functions);
luaL_register(L, "string", string_functions);
- luaL_register(L, "host", host_functions);
/* push the application metadata */
lua_pushstring(L, LUA_COPYRIGHT);
diff --git a/src/host/premake.h b/src/host/premake.h
index 0e99b6c..cd7d522 100755
--- a/src/host/premake.h
+++ b/src/host/premake.h
@@ -56,6 +56,7 @@ int os_chdir(lua_State* L);
int os_copyfile(lua_State* L);
int os_getcwd(lua_State* L);
int os_getversion(lua_State* L);
+int os_is64bit(lua_State* L);
int os_isdir(lua_State* L);
int os_isfile(lua_State* L);
int os_matchdone(lua_State* L);
@@ -68,6 +69,5 @@ int os_pathsearch(lua_State* L);
int os_rmdir(lua_State* L);
int os_uuid(lua_State* L);
int string_endswith(lua_State* L);
-int windows_is_64bit_running_under_wow(struct lua_State* l);