From: SeokYeon Hwang Date: Wed, 25 Nov 2015 12:01:12 +0000 (+0900) Subject: build: prepare for building Win64 emulator binary X-Git-Tag: TizenStudio_2.0_p2.3.2~147 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f8586c0d5d74ea77917e2dfed99a7c17d6824be;p=sdk%2Femulator%2Fqemu.git build: prepare for building Win64 emulator binary Fixed some warnings and errors caused by difference between variable and pointer size. get_java_path() is a function for finding 64bit java binary on WoW64. But callers of get_java_path() should determine whether we are running on Wow64 or not. So it is modified for all platforms now. It can determine current plaform inside. Callers just use get_java_path() anytime they want. "emulator_configure.sh" becomes more complicated. So some configure options for Windows are commonized. Change-Id: Iad83e05fffa6c028b7077cf3a7998722575e5b49 Signed-off-by: SeokYeon Hwang --- diff --git a/include/standard-headers/linux/virtio_ring.h b/include/standard-headers/linux/virtio_ring.h index 6fe276f..3d531f7 100644 --- a/include/standard-headers/linux/virtio_ring.h +++ b/include/standard-headers/linux/virtio_ring.h @@ -143,7 +143,7 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p, vr->num = num; vr->desc = p; vr->avail = p + num*sizeof(struct vring_desc); - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__virtio16) + vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16) + align-1) & ~(align - 1)); } diff --git a/tizen/emulator_configure.sh b/tizen/emulator_configure.sh index 045e054..b8bd7e3 100755 --- a/tizen/emulator_configure.sh +++ b/tizen/emulator_configure.sh @@ -72,7 +72,14 @@ if [ -z "$CROSS_PREFIX" ] ; then targetos=$hostos else # FIXME - targetos="CROSS_MINGW"; + case "$CROSS_PREFIX" in + x86_64*) + targetos="CROSS_MINGW64"; + ;; + *) + targetos="CROSS_MINGW32"; + ;; + esac fi if [ -z "$TIZEN_SDK_DEV_PATH" ] ; then @@ -105,6 +112,7 @@ fi # append common options CONFIGURE_APPEND=" --target-list=$EMUL_TARGET_LIST + --enable-werror --enable-maru --enable-yagl --enable-curl @@ -124,11 +132,18 @@ CONFIGURE_APPEND=" --disable-xen $CONFIGURE_APPEND" +CONFIGURE_APPEND_WIN=" + --extra-ldflags=-static-libgcc + --extra-ldflags=-static-libstdc++ + --audio-drv-list=dsound + --winver=0x0600 + --enable-sdl + --enable-hax" + # append platform specific options case $targetos in Linux*) CONFIGURE_APPEND=" - --enable-werror --extra-ldflags=-rdynamic --audio-drv-list=alsa --enable-sdl @@ -136,40 +151,38 @@ CONFIGURE_APPEND=" $CONFIGURE_APPEND " ;; -CROSS_MINGW*) +CROSS_MINGW32*) CONFIGURE_APPEND=" --cross-prefix=${CROSS_PREFIX}- - --enable-werror - --extra-ldflags=-static-libgcc - --extra-ldflags=-static-libstdc++ --extra-ldflags=-Wl,--large-address-aware - --audio-drv-list=dsound - --winver=0x0600 - --enable-sdl - --enable-hax + $CONFIGURE_APPEND_WIN + $CONFIGURE_APPEND +" +;; +CROSS_MINGW64*) +CONFIGURE_APPEND=" + --cross-prefix=${CROSS_PREFIX}- + --with-sdlabi=2.0 + $CONFIGURE_APPEND_WIN $CONFIGURE_APPEND " +# we use SDL2 for Win64 +# SDL2 will be applied to Win32 soon ;; MINGW*) CONFIGURE_APPEND=" --cc=gcc --cxx=g++ - --enable-werror - --extra-ldflags=-static-libgcc - --extra-ldflags=-static-libstdc++ --extra-ldflags=-Wl,--large-address-aware - --audio-drv-list=dsound - --winver=0x0600 - --enable-sdl - --enable-hax + $CONFIGURE_APPEND_WIN $CONFIGURE_APPEND " +# Do not support building Win64 binary on Windows now ;; Darwin*) CONFIGURE_APPEND=" --cc=clang --cxx=clang - --enable-werror --extra-cflags=-mmacosx-version-min=10.7 --extra-cflags=-Wno-error=deprecated-declarations --extra-ldflags=-lstdc++ diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index e8398e8..385bdf0 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -206,10 +206,18 @@ void print_system_info(void) #ifdef CONFIG_SDL /* Gets the version of the dynamically linked SDL library */ + const SDL_version *sdl_linked; +# if (SDL_MAJOR_VERSION == 2) + SDL_version linked; + SDL_GetVersion(&linked); + sdl_linked = &linked; +# else + sdl_linked = SDL_Linked_Version(); +# endif LOG_INFO("* Host SDL version : %d.%d.%d\n", - SDL_Linked_Version()->major, - SDL_Linked_Version()->minor, - SDL_Linked_Version()->patch); + sdl_linked->major, + sdl_linked->minor, + sdl_linked->patch); #endif print_system_info_os(); diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index 62c24de..feb4d84 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -79,7 +79,7 @@ static int skin_argc; static char** skin_argv; #ifdef CONFIG_WIN32 -static char* JAVA_EXEFILE_PATH = NULL; +static const char* JAVA_EXEFILE_PATH = NULL; #endif static void *run_skin_client(void *arg) @@ -158,19 +158,8 @@ static void *run_skin_client(void *arg) is_netclient_tap_attached() ? "true" : "false"); int tap_opt_len = (int)strlen(tap_enabled); + get_java_path(&JAVA_EXEFILE_PATH); #ifdef CONFIG_WIN32 - /* find java path in 64bit windows */ - JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH); - memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); - if (is_wow64()) { - INFO("This process is running under WOW64.\n"); - if (!get_java_path(&JAVA_EXEFILE_PATH)) { - strcpy(JAVA_EXEFILE_PATH, "java"); - } - } else { - strcpy(JAVA_EXEFILE_PATH, "java"); - } - char const* bin_dir = get_bin_path(); int bin_len = strlen(bin_dir); char bin_dir_win[bin_len]; @@ -260,7 +249,6 @@ static void *run_skin_client(void *arg) #ifdef CONFIG_WIN32 /* for 64bit windows */ - free(JAVA_EXEFILE_PATH); JAVA_EXEFILE_PATH = NULL; //WinExec( cmd, SW_SHOW ); @@ -394,19 +382,8 @@ int start_simple_client(char* msg) INFO("run simple client\n"); + get_java_path(&JAVA_EXEFILE_PATH); #ifdef CONFIG_WIN32 - /* find java path in 64bit windows */ - JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH); - memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); - if (is_wow64()) { - INFO("This process is running under WOW64.\n"); - if (!get_java_path(&JAVA_EXEFILE_PATH)) { - strcpy(JAVA_EXEFILE_PATH, "java"); - } - } else { - strcpy(JAVA_EXEFILE_PATH, "java"); - } - char const* bin_dir = get_bin_path(); int bin_dir_len = strlen(bin_dir); char bin_dir_win[bin_dir_len]; @@ -446,9 +423,7 @@ int start_simple_client(char* msg) INFO("command for swt : %s\n", cmd); #ifdef CONFIG_WIN32 - /* for 64bit windows */ - free(JAVA_EXEFILE_PATH); - JAVA_EXEFILE_PATH=0; + JAVA_EXEFILE_PATH = NULL; ret = WinExec(cmd, SW_SHOW); #else diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 72ea6d5..da0eb40 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -942,28 +942,23 @@ void ContextMenu::slotControlPanel() QString command; QStringList arguments; -#ifdef CONFIG_WIN32 - char *path = (char *)malloc(JAVA_MAX_COMMAND_LENGTH); - memset(path, 0, sizeof(char) * JAVA_MAX_COMMAND_LENGTH); - if (is_wow64()) { - arguments << "-d64"; + /* find java path */ + const char *path; - if (get_java_path(&path)) { - command = QString::fromLocal8Bit(path); - } else { - showMsgBox(QMessageBox::Warning, MSG_INVALID_JAVA_PATH); - free(path); - return; - } + get_java_path(&path); + + if (path) { + command = QString::fromLocal8Bit(path); } else { - command = "javaw.exe"; + // can not enter here... + showMsgBox(QMessageBox::Warning, MSG_INVALID_JAVA_PATH); + return; } - free(path); -#else - command = "java"; -#endif +#if defined(__x86_64__) || defined(_WIN64) + arguments << "-d64"; +#endif #ifdef CONFIG_DARWIN /* SWT Display must be created on main thread due to Cocoa restrictions */ arguments << "-XstartOnFirstThread"; diff --git a/tizen/src/util/error_handler.c b/tizen/src/util/error_handler.c index 4c83b10..04b2f70 100644 --- a/tizen/src/util/error_handler.c +++ b/tizen/src/util/error_handler.c @@ -94,7 +94,7 @@ static char *get_filename_from_path(char *path_buf) } -static HMODULE get_module_handle(DWORD dwAddress) +static HMODULE get_module_handle(void *dwAddress) { MEMORY_BASIC_INFORMATION Buffer; return VirtualQuery((LPCVOID) dwAddress, &Buffer, sizeof(Buffer)) @@ -117,7 +117,11 @@ static void dump_backtrace(void *ptr, int depth) if (!pContext) { __asm__ __volatile__ ("movl %%ebp, %0" : "=m" (pTopFrame)); } else { +#ifdef _WIN64 + pTopFrame = (void *)((PCONTEXT)pContext)->Rbp; +#else pTopFrame = (void *)((PCONTEXT)pContext)->Ebp; +#endif } if (pTopFrame == NULL) { @@ -133,13 +137,21 @@ static void dump_backtrace(void *ptr, int depth) ERR("\nBacktrace Dump Start :\n"); if (pContext) { memset(module_buf, 0, sizeof(module_buf)); - hModule = get_module_handle((DWORD)((PCONTEXT)pContext)->Eip); +#ifdef _WIN64 + hModule = get_module_handle((void *)((PCONTEXT)pContext)->Rip); +#else + hModule = get_module_handle((void *)((PCONTEXT)pContext)->Eip); +#endif if (hModule) { if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { memset(module_buf, 0, sizeof(module_buf)); } } +#ifdef _WIN64 + ERR("[%02d]Addr = 0x%p : %s\n", nCount, ((PCONTEXT)pContext)->Rip, get_filename_from_path(module_buf)); +#else ERR("[%02d]Addr = 0x%p : %s\n", nCount, ((PCONTEXT)pContext)->Eip, get_filename_from_path(module_buf)); +#endif nCount++; } @@ -150,7 +162,7 @@ static void dump_backtrace(void *ptr, int depth) } memset(module_buf, 0, sizeof(module_buf)); - hModule = get_module_handle((DWORD)currentFrame.pReturnAddr); + hModule = get_module_handle(currentFrame.pReturnAddr); if (hModule) { if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { memset(module_buf, 0, sizeof(module_buf)); @@ -210,7 +222,7 @@ static WINAPI LONG maru_unhandled_exception_filter(LPEXCEPTION_POINTERS pExcepti pExceptionRecord = pExceptionInfo->ExceptionRecord; memset(module_buf, 0, sizeof(module_buf)); - hModule = get_module_handle((DWORD)pExceptionRecord->ExceptionAddress); + hModule = get_module_handle(pExceptionRecord->ExceptionAddress); if(hModule){ if(!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))){ memset(module_buf, 0, sizeof(module_buf)); diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index 7fe2661..a904ea5 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -283,7 +283,9 @@ int remove_sdcard_lock_os(char *sdcard) } typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); -int is_wow64(void) + +#ifndef _WIN64 +static int is_wow64(void) { int result = 0; LPFN_ISWOW64PROCESS fnIsWow64Process; @@ -306,25 +308,36 @@ int is_wow64(void) return result; } +#endif /* Gets the JavaHome path from the windows registry. Must call the RegOpenKeyEx by using the following flag. For details, "http://stackoverflow.com/questions/10533421/ accessing-64-bit-registry-from-32-bit-application" */ #define MY_KEY_WOW64_64KEY 0x0100 -static char wow64_java_path[PATH_MAX]; -bool get_java_path(char **java_path) +void get_java_path_win32(const char **java_path) { +#ifdef _WIN64 + *java_path = "javaw.exe"; +#else LONG res; HKEY hKey; char strKey[PATH_MAX] = {0}; char strVersion[PATH_MAX] = {0}; char strJavaHome[PATH_MAX] = {0}; DWORD dwBufLen = PATH_MAX; + static char wow64_java_path[PATH_MAX]; + + // we should try it no matter what happens + *java_path = "javaw.exe"; + + if (!is_wow64()) { + return; + } if (wow64_java_path[0] != '\0') { - g_strlcpy(*java_path, wow64_java_path, PATH_MAX); - return true; + *java_path = wow64_java_path; + return; } g_strlcpy(strKey, "SOFTWARE\\JavaSoft\\Java Runtime Environment", PATH_MAX); @@ -380,11 +393,13 @@ javahome_not_found: PATH_MAX); if (dwBufLen == 0) { WARN("There is no JavaHome\n"); - return false; + // try it with "javaw.exe" + return; } } - g_sprintf(*java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome); - g_strlcpy(wow64_java_path, *java_path, PATH_MAX); + g_sprintf(wow64_java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome); INFO("JavaHome: %s\n", wow64_java_path); - return true; + + *java_path = wow64_java_path; +#endif } diff --git a/tizen/src/util/osutil.c b/tizen/src/util/osutil.c index 03832df..b2bb82b 100644 --- a/tizen/src/util/osutil.c +++ b/tizen/src/util/osutil.c @@ -40,7 +40,6 @@ #include #include - #ifndef CONFIG_WIN32 MULTI_DEBUG_CHANNEL(emulator, osutil); static sdcard_info info; diff --git a/tizen/src/util/osutil.h b/tizen/src/util/osutil.h index cc9e95c..66a20dd 100644 --- a/tizen/src/util/osutil.h +++ b/tizen/src/util/osutil.h @@ -65,15 +65,16 @@ typedef struct sdcard_info #endif char* lock_file; /* reserved for future use */ } sdcard_info; + #ifndef CONFIG_WIN32 bool make_sdcard_lock_posix(char *sdcard); int remove_sdcard_lock_posix(char *sdcard); #else -int is_wow64(void); -bool get_java_path(char **java_path); +void get_java_path_win32(const char **java_path); #endif void print_system_info_os(void); +int get_number_of_processors(void); static inline int get_timeofday(char *buf, size_t size) { @@ -92,7 +93,14 @@ static inline int get_timeofday(char *buf, size_t size) return ret + g_snprintf(buf + ret, size - ret, ".%03ld", (long)tv.tv_usec/1000); } -int get_number_of_processors(void); +static inline void get_java_path(const char **java_path) +{ +#ifdef CONFIG_WIN32 + get_java_path_win32(java_path); +#else + *java_path = "java"; +#endif +} #endif // __OS_UTIL_H__ diff --git a/tizen/src/util/sdb.c b/tizen/src/util/sdb.c index 017587c..bd228a2 100644 --- a/tizen/src/util/sdb.c +++ b/tizen/src/util/sdb.c @@ -56,7 +56,7 @@ static bool sdb_daemon_is_initialized = false; static void socket_close_handler( void* _fd ) { - int fd = (int)_fd; + int fd = (int)(uintptr_t)_fd; int ret; char buff[64]; @@ -78,7 +78,7 @@ void socket_close( int fd ) shutdown( fd, SD_BOTH ); /* we want to drain the socket before closing it */ - qemu_set_fd_handler( fd, socket_close_handler, NULL, (void*)fd ); + qemu_set_fd_handler( fd, socket_close_handler, NULL, (void*)(uintptr_t)fd ); errno = old_errno; }