[sldev] Compiling a Win32 slviewer with GNUC (and other patches)
Dzonatas
dzonatas at dzonux.net
Wed Mar 28 14:20:31 PDT 2007
Attached is several patches made to help compile a Win32 viewer with
GNUC. This patch is from OSLCC, which compiles a win32 version with
"i686-mingw32-g++". It is preliminary. For now, I have provided it for
reference and comments.
What this provides is:
* the band-aid approach (casts) to handle U16 types to WCHAR conversion
and likewise (VWR-186)
* an SConscript file that supports MinGW (used by OSLCC)
* AT&T and GNU style __asm blocks instead of intel and MSVC style
* LL_GNUC, LL_MSVC, and LL_MINGW to fix build confusion (VWR-187)
* fix for VWR-198
* default Windows build to no llmozlib (this is not a fix, a future
patch will make it optional)
This patch was made against an older version of First Look (58390).
-------------- next part --------------
Index: libraries/i686-mingw32/include/_G_config.h
===================================================================
--- libraries/i686-mingw32/include/_G_config.h (revision 0)
+++ libraries/i686-mingw32/include/_G_config.h (revision 54)
@@ -0,0 +1,4 @@
+#define _G_int64_t __int64
+#define _G_int32_t __int32
+#define _G_uint32_t unsigned __int32
+#define _G_int16_t __int16
Index: libraries/include/GL/glh_genext.h
===================================================================
--- libraries/include/GL/glh_genext.h (revision 1)
+++ libraries/include/GL/glh_genext.h (working copy)
@@ -23,7 +23,7 @@
#ifdef _WIN32 /* supports windows, x -- need to generalize */
# include <GL/wglext.h>
# define GLH_EXT_GET_PROC_ADDRESS(p) wglGetProcAddress(p)
-#else if GLX_VERSION_1_3
+#else //if GLX_VERSION_1_3
# include <GL/glxext.h>
# define GLH_EXT_GET_PROC_ADDRESS(p) glXGetProcAddressARB(p)
#endif
Index: indra/SConscript
===================================================================
--- indra/SConscript (revision 0)
+++ indra/SConscript (revision 54)
@@ -0,0 +1,459 @@
+#################################################
+#
+# SConstruct makefile for Second Life viewer
+# and servers.
+#
+# To build everything:
+#
+# scons ARCH=all BTARGET=all DISTCC=yes
+#
+# For help on options:
+#
+# scons -h
+#
+# Originally written by Tom Yedwab, 6/2006.
+#
+#################################################
+
+
+import os
+import sys
+import glob
+
+Import('env')
+
+platform = sys.platform
+if platform == 'linux2':
+ platform = 'linux'
+
+######################
+# GET VERSION #
+######################
+
+pipe = os.popen('grep LL_VERSION_MAJOR llcommon/llversion.h | sed \'s/.*=//; s/[^0-9]*//g\'')
+version_major = pipe.read().rstrip('\n')
+pipe.close()
+pipe = os.popen('grep LL_VERSION_MINOR llcommon/llversion.h | sed \'s/.*=//; s/[^0-9]*//g\'')
+version_minor = pipe.read().rstrip('\n')
+pipe.close()
+pipe = os.popen('grep LL_VERSION_PATCH llcommon/llversion.h | sed \'s/.*=//; s/[^0-9]*//g\'')
+version_patch = pipe.read().rstrip('\n')
+pipe.close()
+pipe = os.popen('grep LL_VERSION_BUILD llcommon/llversion.h | sed \'s/.*=//; s/[^0-9]*//g\'')
+version_build = pipe.read().rstrip('\n')
+pipe.close()
+
+### MinGW Options ###
+
+build_param = 'release'
+arch = 'i686'
+target_param = 'client'
+os_param = 'mingw32'
+enable_distcc = 'no'
+enable_ccache = 'yes'
+enable_colorgcc = 'no'
+grid = 'default'
+opensource = 'yes'
+
+###
+
+if os_param == 'host':
+ os_target = platform
+else:
+ os_target = os_param
+
+targets = [ target_param ]
+
+if target_param == 'all':
+ targets = [ 'client', 'server' ]
+
+#####################
+# ITERATE TARGETS #
+#####################
+
+#for build_target in targets:
+build_target = 'client'
+buildtype = build_param
+if build_target == 'server' and buildtype == 'releasefordownload':
+ buildtype = 'release'
+
+system_str = arch + '-' + os_target
+
+print 'Building ' + build_target + ' ' + version_major + '.' + version_minor + '.' + version_patch + '.' + version_build + ' on ' + system_str + ' (' + buildtype + ')'
+
+system_lib_dir = '../libraries/' + system_str
+if build_target == 'client':
+ system_lib_dir += '/lib_release_client'
+elif buildtype == 'debug':
+ system_lib_dir += '/lib_debug'
+else:
+ system_lib_dir += '/lib_release'
+
+lib_dir = './lib_' + buildtype + '_' + build_target + '/' + system_str
+
+try:
+ build_dir_prefix = os.environ['TEMP_BUILD_DIR']
+except:
+ build_dir_prefix = '/tmp/' + os.environ['USER']
+
+try:
+ ws_dir = os.environ['WSDIR']
+except:
+ ws_dir = ''
+
+build_dir = build_dir_prefix + os.getcwd() + '/' + system_str + '-' + build_target + '-' + buildtype
+
+### Base include directories ###
+
+include_dirs = Split("""
+ ./llcommon ./llmath ./llwindow ./llaudio ./llcharacter
+ ./lldatabase ./llhavok ./llimage ./llinventory ./llmedia ./llmessage
+ ./llprimitive ./llrender ./llscene ./llui ./llvfs ./llwindow
+ ./llxml ./lscript
+ ../libraries/include
+ ../libraries/include/havok
+ """ +
+ '../libraries/' + system_str + '/include' )
+
+client_external_libs = []
+system_link_flags = ''
+
+if os_target != 'linux' and os_target != 'mingw32' and build_target == 'client':
+
+ ### Mozilla include directories ###
+
+ mozilla_dir = '../libraries/' + system_str + '/include/mozilla'
+ include_dirs += Split(
+ mozilla_dir + '/include/webbrwsr ' +
+ mozilla_dir + '/include/docshell ' +
+ mozilla_dir + '/include/dom ' +
+ mozilla_dir + '/include/xpcom ' +
+ mozilla_dir + '/include/widget ' +
+ mozilla_dir + '/include/gfx ' +
+ mozilla_dir + '/include/string ' +
+ mozilla_dir + '/include/uriloader ' +
+ mozilla_dir + '/include/view ' +
+ mozilla_dir + '/include/layout ' +
+ mozilla_dir + '/include/content ' +
+ mozilla_dir + '/include/locale ' +
+ mozilla_dir + '/include/profdirserviceprovider ' +
+ mozilla_dir + '/include/xulapp ' +
+ mozilla_dir + '/include/pref ' +
+ mozilla_dir + '/sdk/include')
+
+##############
+# CPP Flags #
+##############
+
+# Generic GCC flags
+flags = '-g -pipe -Wall -Wno-trigraphs '
+
+if opensource == 'yes':
+ flags += '-DLL_USE_KDU=0 '
+else:
+ flags += '-DLL_USE_KDU=1 '
+
+if build_target == 'server':
+ # Server flags
+ flags += '-march=pentiumpro -D_GNU_SOURCE -ftemplate-depth-60 -DLL_MESA_HEADLESS=1 -DLL_MESA=1 '
+ try:
+ server_cppflags = os.environ['SERVER_CPPFLAGS']
+ except:
+ server_cppflags = ''
+ flags += server_cppflags + ' '
+else:
+ # Viewer flags
+ flags += '-falign-loops=16 -fno-math-errno -fexceptions -fsigned-char -fno-strict-aliasing -ffast-math '
+ flags += '-DLL_MESA_HEADLESS=0 -DLL_MESA=0 '
+ try:
+ client_cppflags = os.environ['CLIENT_CPPFLAGS']
+ except:
+ client_cppflags = ''
+ flags += client_cppflags + ' '
+
+if os_target == 'linux':
+ # Linux-only flags
+ flags += '-DLL_LINUX=1 '
+ if build_target == 'client':
+ flags += '-DAPPID=secondlife -DLL_SDL=1 -DLL_X11=1 '
+ flags += '-DLL_GTK=1 '
+ client_external_libs += [ 'gtk-x11-2.0', 'elfio' ]
+ include_dirs += [ '../libraries/' + system_str + '/include/gtk-2.0' ]
+ include_dirs += [ '../libraries/' + system_str + '/include/glib-2.0']
+ include_dirs += [ '../libraries/' + system_str + '/include/pango-1.0' ]
+ include_dirs += [ '../libraries/' + system_str + '/include/atk-1.0' ]
+ include_dirs += [ '../libraries/' + system_str + '/include/ELFIO' ]
+ include_dirs += [ '../libraries/' + system_str + '/include/llfreetype2' ]
+
+ # llmozlib stuff
+ client_external_libs += [ 'llmozlib' ]
+ client_external_libs += [ 'mozjs', 'nspr4', 'plc4', 'plds4', 'profdirserviceprovider_s', 'xpcom', 'xul' ]
+elif os_target == 'mingw32':
+ flags += '-DLL_WINDOWS=1 -DLL_MINGW=1 -DUNICODE -DLL_FMOD=0 -Wno-multichar -Wno-unknown-pragmas -msse2 '
+ include_dirs += [ '../../CxxIncludes/DirectX' ]
+ include_dirs += [ '../../CxxIncludes/QuickTime' ]
+ include_dirs += [ '../libraries/' + arch + '-win32/include' ]
+else:
+ # Mac-only flags
+ flags += '-x c++ -arch ppc -pipe -Wno-trigraphs -fpascal-strings -faltivec -fasm-blocks -g -O2 -fmessage-length=0 -mtune=G4 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.3 -DLL_DARWIN=1 -Wmost -Wno-sign-compare -Wno-switch -fpch-preprocess -F./newview/build/Deployment -fconstant-cfstrings -ffor-scope -Wno-reorder -isysroot /Developer/SDKs/MacOSX10.3.9.sdk '
+
+### Build type-specific flags ###
+
+debug_opts = flags + '-fno-inline -O0 -D_DEBUG -DLL_DEBUG=1 '
+release_opts = flags + '-O2 -DNDEBUG -DLL_RELEASE=1 '
+releasenoopt_opts = flags + '-O0 -DNDEBUG -DLL_RELEASE=1 '
+releasefordownload_opts = flags + '-O2 -DNDEBUG -DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 '
+
+################
+# ENVIRONMENT #
+################
+
+gcc_bin = 'g++-3.4'
+# If you strip more aggressively than -S then the quality of crash-
+# logger backtraces deteriorates.
+strip_cmd = 'strip -S -o $TARGET $SOURCE'
+
+# hidesyms_cmd is something which copies an executable while 'hiding'
+# all of its exposed symbols except a very few desired ones. This is
+# used mainly to hide the symbols of the many common libraries we
+# static-link, which otherwise cause hard-to-trace fatal crashes due
+# to clashes in the run-time symbol namespace.
+if os_target == 'linux':
+ exposed_symbols_file = 'newview/linux_tools/exposed-symbols.txt'
+ hidesyms_cmd = 'objcopy --keep-global-symbols ' + exposed_symbols_file + ' $SOURCE $TARGET'
+else:
+ hidesyms_cmd = 'cp -f $SOURCE $TARGET'
+
+if build_target != 'client':
+ gcc_bin = 'g++-3.3'
+
+if arch == 'x86_64':
+ gcc_bin = '/opt/crosstool/gcc-4.0.2-glibc-2.3.6/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc'
+ strip_cmd = '/opt/crosstool/gcc-4.0.2-glibc-2.3.6/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/bin/strip -S -o $TARGET $SOURCE'
+
+if os_target == 'mingw32':
+ gcc_bin = system_str + '-g++'
+ strip_cmd = system_str + '-strip -S -o $TARGET $SOURCE'
+ exposed_symbols_file = 'newview/linux_tools/exposed-symbols.txt'
+ hidesyms_cmd = system_str + '-objcopy --keep-global-symbols ' + exposed_symbols_file + ' $SOURCE $TARGET'
+
+compiler = gcc_bin
+compiler_no_distcc = compiler
+if enable_distcc == 'yes':
+ compiler = 'distcc ' + gcc_bin
+
+if enable_ccache == 'yes':
+ compiler = 'ccache ' + compiler
+
+base_env = env.Copy(CXX = compiler,
+ CPPPATH = include_dirs,
+ LIBPATH = [lib_dir] + [system_lib_dir],
+ LINKFLAGS = system_link_flags + '--no-keep-memory --reduce-memory-overheads ')
+
+### Environments for various build types ###
+
+env = base_env.Copy(CPPFLAGS = releasefordownload_opts)
+print env['ENV']['PATH']
+
+if buildtype == 'debug':
+ env = base_env.Copy(CPPFLAGS = debug_opts)
+
+if buildtype == 'release':
+ env = base_env.Copy(CPPFLAGS = release_opts)
+
+if buildtype == 'releasenoopt':
+ env = base_env.Copy(CPPFLAGS = releasenoopt_opts)
+
+if os_target == 'mingw32':
+ env["RANLIB"] = system_str + '-ranlib'
+ env["AR"] = system_str + '-ar'
+ env["LINK"] = system_str + '-g++'
+ if build_target == 'debug':
+ env["LIBPATH"] += [ lib_dir + '../libraries/' + arch + '-win32/lib_debug' ]
+ else:
+ env["LIBPATH"] += [ lib_dir + '../libraries/' + arch + '-win32/lib_release' ]
+
+# ccache needs this to be set
+try:
+ env['ENV']['CCACHE_DIR'] = os.environ['CCACHE_DIR']
+except:
+ print "No CCACHE_DIR set."
+
+env_no_distcc = env.Copy(CXX = compiler_no_distcc)
+
+### Distributed build hosts ###
+
+if enable_distcc == 'yes':
+ hosts = 'localhost/2 station9.lindenlab.com,lzo station7.lindenlab.com,lzo station6.lindenlab.com,lzo station11.lindenlab.com,lzo station5.lindenlab.com,lzo station15.lindenlab.com,lzo station10.lindenlab.com,lzo station13.lindenlab.com,lzo station12.lindenlab.com,lzo'
+ if arch == 'x86_64':
+ hosts = 'localhost'
+ print "Distributing to hosts: " + hosts
+ env['ENV']['DISTCC_HOSTS'] = hosts
+ env['ENV']['USER'] = os.environ['USER']
+ env['ENV']['HOME'] = os.environ['HOME']
+
+if enable_colorgcc == 'yes':
+ env['ENV']['PATH'] = os.environ['PATH']
+ env['ENV']['TERM'] = os.environ['TERM']
+ env['ENV']['HOME'] = os.environ['HOME']
+
+### Configure lex and yacc ###
+env.Append(YACCFLAGS = ["-v", "-d"])
+env.CFile(target=build_dir+'/lscript/lscript_compile/indra.l.cpp', source='lscript/lscript_compile/indra.l')
+env.CFile(target=build_dir+'/lscript/lscript_compile/indra.y.c', source='lscript/lscript_compile/indra.y')
+env.Command(build_dir+'/lscript/lscript_compile/indra.y.cpp',build_dir+'/lscript/lscript_compile/indra.y.c',
+ [Move('$TARGET','$SOURCE'),Delete(build_dir+'/lscript/lscript_compile/indra.y.output')])
+
+#####################
+# HELPER FUNCTIONS #
+#####################
+
+### Load a files.lst and files.PLATFORM.lst for each module ###
+
+def load_files(module):
+ new_list = []
+ try:
+ list_file = open('./' + module + '/files.lst', 'r')
+ list = Split(list_file.read())
+ for x in list:
+ file = os.path.join(build_dir, x)
+ if x == 'newsim/lltask.cpp':
+ print 'Found lltask!'
+ obj = env_no_distcc.Object(file)
+ new_list.append(obj)
+ else:
+ new_list.append(file)
+ list_file.close()
+ except IOError:
+ print 'Error: no files.lst exists for module ' + module
+ return []
+
+ try:
+ platform_list_file = open('./' + module + '/files.' + os_target + '.lst', 'r')
+ list = Split(platform_list_file.read())
+ for x in list:
+ file = os.path.join(build_dir, x)
+ new_list.append(file)
+ platform_list_file.close()
+ except IOError:
+ return new_list
+
+ return new_list
+
+### Create a static library from the module ###
+
+def create_static_module_from_dir(input_dir, mod_name, local_flags="", extra_depends=None):
+ files_list = load_files(input_dir)
+ BuildDir(build_dir + '/' + input_dir, input_dir)
+ local_env = env.Copy(CPPFLAGS = env['CPPFLAGS'] + ' ' + local_flags)
+ if extra_depends:
+ for x in files_list:
+ Depends(local_env.Object(x), extra_depends)
+ tgt = local_env.StaticLibrary(lib_dir + '/' + mod_name, files_list)
+ Default(tgt)
+
+def create_static_module(module, local_flags="", extra_depends=None):
+ create_static_module_from_dir(module, module, local_flags, extra_depends)
+
+def create_dynamic_module(module, local_flags="", module_libs = None):
+ files_list = load_files(module)
+ BuildDir(build_dir + '/' + module, module)
+ local_env = env.Copy(CPPFLAGS = env['CPPFLAGS'] + ' ' + local_flags)
+ tgt = local_env.SharedLibrary(lib_dir + '/' + module, files_list, LIBS = module_libs)
+ Default(tgt)
+
+### Create an executable from the module ###
+
+def create_executable(exec_file, module, module_libs):
+ BuildDir(build_dir + '/' + module, module)
+ files_list = load_files(module)
+ tgt = env.Program(exec_file, files_list, LIBS = module_libs)
+ Default(tgt)
+
+
+####################
+# BUILD LIBRARIES #
+####################
+
+create_static_module('llcommon')
+create_static_module('llmath')
+create_static_module('llmessage')
+create_static_module('llvfs')
+create_static_module('llimage')
+create_static_module('llinventory')
+create_static_module('llcharacter')
+create_static_module('llprimitive')
+create_static_module('llrender')
+create_static_module('llwindow')
+create_static_module('llxml')
+create_static_module('lscript', extra_depends=build_dir + '/lscript/lscript_compile/indra.y.h')
+
+net_external_libs = [ 'curl', 'cares', 'ssl', 'crypto', 'aprutil-1', 'apr-1' ]
+common_external_libs = net_external_libs + [ 'xmlrpc', 'expat', 'z' ]
+
+if build_target == 'client':
+ if os_target == 'linux':
+ #############################
+ # BUILD LINUX_CRASH_LOGGER #
+ #############################
+ output_crashlogger_bin = 'linux_crash_logger/linux-crash-logger-' + arch + '-bin'
+ external_libs = net_external_libs + [ 'db-4.2', 'gtk-x11-2.0' ]
+ external_libs.remove('cares')
+ internal_libs = [ 'llvfs', 'llmath', 'llcommon' ]
+ create_executable(output_crashlogger_bin + '-globalsyms', 'linux_crash_logger', internal_libs + external_libs)
+ env.Command(output_crashlogger_bin, output_crashlogger_bin + '-globalsyms', hidesyms_cmd)
+
+ create_static_module('llaudio')
+ create_static_module('llmedia')
+ create_static_module('llui')
+ create_static_module('llimagej2coj')
+
+ if opensource == 'no':
+ create_dynamic_module('llkdu', '', ['llimage', 'llvfs', 'llmath', 'llcommon', 'apr-1', 'kdu_v42R'])
+
+ ##################
+ # BUILD NEWVIEW #
+ ##################
+ output_bin = 'newview/secondlife-' + arch + '-bin'
+
+ external_libs = client_external_libs + common_external_libs + [ 'freetype', 'jpeg', 'SDL', 'GL', 'GLU', 'ogg', 'vorbisenc', 'vorbisfile', 'vorbis', 'fmod-3.75', 'db-4.2', 'openjpeg' ]
+ external_libs.remove('cares')
+
+ if os_target == 'mingw32':
+ external_libs = Split( "apr-1 aprutil-1 freetype jpeglib_6b curl expatMT OpenJPEG QTMLClient eay32 ssleay32 vorbis_static_mt vorbisenc_static_mt vorbisfile_static_mt ogg_static_mt xmlrpcepi zlib" )
+ external_libs += Split( "boost_regex-vc71-mt-s" )
+ external_libs += Split( "dinput8 dsound dxerr8 dxguid" )
+ external_libs += Split( "glut32 glu32 opengl32" )
+ external_libs += Split( "comdlg32 mswsock netapi32 odbc32 odbccp32 ole32 oleaut32 winmm winspool ws2_32 vfw32" )
+ external_libs += Split( "bufferoverflowu" )
+ external_libs += Split( "msvcrt-import" )
+ env["LINKFLAGS"] += '-v -mwindows '
+
+ internal_libs = [ 'lscript', 'llwindow', 'llrender', 'llprimitive',
+ 'llmedia', 'llinventory',
+ 'llimage', 'llimagej2coj',
+ 'llcharacter', 'llaudio', 'llui', 'llxml',
+ 'llmessage', 'llvfs', 'llmath', 'llcommon' ]
+
+ create_executable(output_bin + '-globalsyms', 'newview', internal_libs + external_libs)
+ env.Command(output_bin, output_bin + '-globalsyms', hidesyms_cmd)
+
+ if buildtype == 'releasefordownload':
+
+ #######################
+ # PACKAGE THE CLIENT #
+ #######################
+
+ if os_target == 'linux':
+ env.Command(output_bin + '-stripped', output_bin, strip_cmd)
+ env.Command(output_crashlogger_bin + '-stripped', output_crashlogger_bin, strip_cmd)
+ manifest_file = 'linux_tools/client-manifest-' + arch
+ product_name = 'SecondLife_' + arch + '_' + version_major + "_" + version_minor + "_" + version_patch + "_" + version_build
+ if grid != 'default':
+ product_name += "_" + grid.upper()
+ package_name = product_name + '.tar.bz2'
+ cmd = 'rm -rf newview/' + product_name + '* && newview/linux_tools/package-client.sh ' + manifest_file + ' ' + product_name + ' ' + grid
+ env.Command('newview/' + package_name, 'newview/' + manifest_file, cmd)
+ Depends('newview/' + package_name, output_bin + '-stripped')
+ Depends('newview/' + package_name, output_crashlogger_bin + '-stripped')
+ Default('newview/' + package_name)
Index: indra/llcommon/llfile.h
===================================================================
--- indra/llcommon/llfile.h (revision 1)
+++ indra/llcommon/llfile.h (working copy)
@@ -44,7 +44,7 @@
typedef FILE LLFILE;
-#ifdef LL_WINDOWS
+#if LL_MSVC
#define USE_LLFILESTREAMS 1
#else
#define USE_LLFILESTREAMS 0
Index: indra/llcommon/llfile.cpp
===================================================================
--- indra/llcommon/llfile.cpp (revision 1)
+++ indra/llcommon/llfile.cpp (working copy)
@@ -37,11 +37,11 @@
// static
int LLFile::mkdir(const char* dirname, int perms)
{
-#if LL_WINDOWS
+#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
- return _wmkdir(utf16dirname.c_str());
+ return _wmkdir((wchar_t*)utf16dirname.c_str());
#else
return ::mkdir(dirname, (mode_t)perms);
#endif
@@ -54,7 +54,7 @@
// permissions are ignored on Windows
std::string utf8dirname = dirname;
llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
- return _wrmdir(utf16dirname.c_str());
+ return _wrmdir((wchar_t*)utf16dirname.c_str());
#else
return ::rmdir(dirname);
#endif
@@ -68,7 +68,7 @@
std::string utf8mode = mode;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
- return _wfopen(utf16filename.c_str(),utf16mode.c_str());
+ return _wfopen((wchar_t*)utf16filename.c_str(),(wchar_t*)utf16mode.c_str());
#else
return ::fopen(filename,mode); /* Flawfinder: ignore */
#endif
@@ -81,7 +81,7 @@
std::string utf8mode = mode;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
- return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);
+ return _wfsopen((wchar_t*)utf16filename.c_str(),(wchar_t*)utf16mode.c_str(),sharingFlag);
#else
llassert(0);//No corresponding function on non-windows
return NULL;
@@ -93,7 +93,7 @@
#if LL_WINDOWS
std::string utf8filename = filename;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
- return _wremove(utf16filename.c_str());
+ return _wremove((wchar_t*)utf16filename.c_str());
#else
return ::remove(filename);
#endif
@@ -106,7 +106,7 @@
std::string utf8newname = newname;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16newname = utf8str_to_utf16str(utf8newname);
- return _wrename(utf16filename.c_str(),utf16newname.c_str());
+ return _wrename((wchar_t*)utf16filename.c_str(),(wchar_t*)utf16newname.c_str());
#else
return ::rename(filename,newname);
#endif
@@ -117,7 +117,7 @@
#if LL_WINDOWS
std::string utf8filename = filename;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
- return _wstat(utf16filename.c_str(),filestatus);
+ return _wstat((wchar_t*)utf16filename.c_str(),filestatus);
#else
return ::stat(filename,filestatus);
#endif
Index: indra/llcommon/linden_common.h
===================================================================
--- indra/llcommon/linden_common.h (revision 1)
+++ indra/llcommon/linden_common.h (working copy)
@@ -36,9 +36,9 @@
#include <stdlib.h>
// Work around stupid Microsoft STL warning
-#ifdef LL_WINDOWS
+#if LL_MSVC
#pragma warning (disable : 4702) // warning C4702: unreachable code
-#endif // LL_WINDOWS
+#endif // LL_MSVC
#include <iostream>
#include <fstream>
@@ -55,8 +55,8 @@
#include "llfasttimer.h"
#include "llsys.h"
-#ifdef LL_WINDOWS
+#if LL_MSVC
#pragma warning (3 : 4702) // we like level 3, not 4
-#endif // LL_WINDOWS
+#endif // LL_MSVC
#endif
Index: indra/llcommon/llsys.cpp
===================================================================
--- indra/llcommon/llsys.cpp (revision 1)
+++ indra/llcommon/llsys.cpp (working copy)
@@ -127,7 +127,7 @@
}
}
- std::string csdversion = utf16str_to_utf8str(osvi.szCSDVersion);
+ std::string csdversion = utf16str_to_utf8str((U16*)osvi.szCSDVersion);
// Display version, service pack (if any), and build number.
char tmp[MAX_STRING]; /* Flawfinder: ignore */
if(osvi.dwMajorVersion <= 4)
Index: indra/llcommon/llerror.cpp
===================================================================
--- indra/llcommon/llerror.cpp (revision 1)
+++ indra/llcommon/llerror.cpp (working copy)
@@ -173,7 +173,7 @@
llutf16string utf16str =
wstring_to_utf16str(utf8str_to_wstring(message));
utf16str += '\n';
- OutputDebugString(utf16str.c_str());
+ OutputDebugString((LPCWSTR)utf16str.c_str());
}
};
#endif
Index: indra/llcommon/llprocessor.cpp
===================================================================
--- indra/llcommon/llprocessor.cpp (revision 1)
+++ indra/llcommon/llprocessor.cpp (working copy)
@@ -61,7 +61,9 @@
#ifdef PROCESSOR_FREQUENCY_MEASURE_AVAILABLE
// We need the QueryPerformanceCounter and Sleep functions
+#if !LL_GNUC
#define FORCEINLINE __forceinline
+#endif
#else
#define FORCEINLINE
#endif
@@ -96,6 +98,66 @@
}
#endif
+
+#if LL_GNUC
+
+static inline void __cpuid( unsigned long * eax, unsigned long * ebx, unsigned long* ecx, unsigned long* edx )
+{
+ __asm__(
+ "cpuid"
+ : "=a" (*eax) ,
+ "=b" (*ebx) ,
+ "=c" (*ecx) ,
+ "=d" (*edx)
+ : "0" (*eax) ,
+ "2" (*ecx) ) ;
+}
+
+static inline void cpuid( unsigned op, unsigned long* eax, unsigned long* ebx, unsigned long* ecx, unsigned long* edx )
+{
+ *eax = op;
+ *ecx = 0; // some cpus (Cyrix MII) do not set or clear %ecx
+ __cpuid( eax, ebx, ecx, edx ) ;
+}
+
+
+static inline unsigned cpuid_eax( unsigned long op )
+{
+ unsigned long eax, ebx, ecx, edx;
+
+ cpuid( op, &eax, &ebx, &ecx, &edx ) ;
+ return eax;
+}
+
+static inline unsigned cpuid_ebx( unsigned long op )
+{
+ unsigned long eax, ebx, ecx, edx;
+
+ cpuid( op, &eax, &ebx, &ecx, &edx ) ;
+ return ebx;
+}
+
+static inline unsigned cpuid_ecx( unsigned long op )
+{
+ unsigned long eax, ebx, ecx, edx;
+
+ cpuid( op, &eax, &ebx, &ecx, &edx ) ;
+ return ecx;
+}
+
+static inline unsigned cpuid_edx( unsigned long op )
+{
+ unsigned long eax, ebx, ecx, edx;
+
+ cpuid( op, &eax, &ebx, &ecx, &edx ) ;
+ return edx;
+}
+
+#endif
+
+
+
+
// CProcessor::CProcessor
// ======================
// Class constructor:
@@ -132,12 +194,16 @@
// First we get the CPUID standard level 0x00000001
unsigned long reg;
+#if LL_GNUC
+ reg = cpuid_eax( 1 ) ;
+#else
__asm
{
mov eax, 1
cpuid
mov reg, edx
}
+#endif
// Then we check, if the RDTSC (Real Date Time Stamp Counter) is available.
// This function is necessary for our measure process.
@@ -167,20 +233,28 @@
// Now we call a CPUID to ensure, that all other prior called functions are
// completed now (serialization)
+#if LL_GNUC
+ __asm__("cpuid" ::: "%eax" , "%ebx" , "%ecx" , "%edx" ) ;
+#else
__asm cpuid
+#endif
// We ask the high-res timer for the start time
QueryPerformanceCounter((LARGE_INTEGER *) &starttime);
// Then we get the current cpu clock and store it
+#if LL_GNUC
+ __asm__("rdtsc" : "=A" (start) ) ;
+#else
__asm
{
rdtsc
mov dword ptr [start+4], edx
mov dword ptr [start], eax
}
+#endif
- // Now we wart for some msecs
+ // Now we wait for some msecs
_Delay(uiMeasureMSecs);
// Sleep(uiMeasureMSecs);
@@ -188,12 +262,16 @@
QueryPerformanceCounter((LARGE_INTEGER *) &endtime);
// And also for the end cpu clock
+#if LL_GNUC
+ __asm__("rdtsc" : "=A" (end) ) ;
+#else
__asm
{
rdtsc
mov dword ptr [end+4], edx
mov dword ptr [end], eax
}
+#endif
// Now we can restore the default process and thread priorities
SetProcessAffinityMask(hProcess, dwProcessMask);
@@ -228,6 +306,11 @@
return false;
// Now we get the CPUID standard level 0x00000001
+#if LL_GNUC
+ eaxreg = cpuid_eax( 1 ) ;
+ ebxreg = cpuid_ebx( 1 ) ;
+ edxreg = cpuid_edx( 1 ) ;
+#else
__asm
{
mov eax, 1
@@ -236,6 +319,7 @@
mov ebxreg, ebx
mov edxreg, edx
}
+#endif
// Then get the cpu model, family, type, stepping and brand id by masking
// the eax and ebx register
@@ -593,6 +677,11 @@
{
// If it supports the serial number CPUID level 0x00000003 we read the data
unsigned long sig1, sig2, sig3;
+#if LL_GNUC
+ sig1 = cpuid_eax( 1 ) ;
+ sig2 = cpuid_ecx( 3 ) ;
+ sig3 = cpuid_edx( 3 ) ;
+#else
__asm
{
mov eax, 1
@@ -603,6 +692,7 @@
mov sig2, ecx
mov sig3, edx
}
+#endif
// Then we convert the data to a readable string
snprintf( /* Flawfinder: ignore */
CPUInfo.strProcessorSerial,
@@ -652,6 +742,11 @@
return 0;
// Now we get the CPUID standard level 0x00000001
+#if LL_GNUC
+ eaxreg = cpuid_eax( 1 ) ;
+ ebxreg = cpuid_ebx( 1 ) ;
+ edxreg = cpuid_edx( 1 ) ;
+#else
__asm
{
mov eax, 1
@@ -660,6 +755,7 @@
mov ebxreg, ebx
mov edxreg, edx
}
+#endif
// Then we mask the model, family, stepping and type (AMD does not support brand id)
CPUInfo.uiStepping = eaxreg & 0xF;
@@ -698,6 +794,18 @@
if (CPUInfo.MaxSupportedExtendedLevel >= 0x80000004)
{
// If it supports the extended CPUID level 0x80000004 we read the data
+#if LL_GNUC
+ union
+ {
+ char s[sizeof(CPUInfo.strBrandID)];
+ unsigned long r[12];
+ } tmp ;
+ memset(&tmp, 0, sizeof(tmp));
+ cpuid( 0x80000002 , &tmp.r[ 0] , &tmp.r[ 1] , &tmp.r[ 2] , &tmp.r[ 3] ) ;
+ cpuid( 0x80000003 , &tmp.r[ 4] , &tmp.r[ 5] , &tmp.r[ 6] , &tmp.r[ 7] ) ;
+ cpuid( 0x80000004 , &tmp.r[ 8] , &tmp.r[ 9] , &tmp.r[10] , &tmp.r[11] ) ;
+ strncpy(CPUInfo.strBrandID, tmp.s,sizeof(CPUInfo.strBrandID-1));
+#else
char tmp[52]; /* Flawfinder: ignore */
memset(tmp, 0, sizeof(tmp));
__asm
@@ -723,6 +831,7 @@
}
// And copy it to the brand id string
strncpy(CPUInfo.strBrandID, tmp,sizeof(CPUInfo.strBrandID-1)); /* Flawfinder: ignore */
+#endif
CPUInfo.strBrandID[sizeof(CPUInfo.strBrandID-1)]='\0';
}
else
@@ -910,12 +1019,16 @@
{
// If we can access the extended CPUID level 0x80000001 we get the
// edx register
+#if LL_GNUC
+ edxreg = cpuid_edx( 0x80000001 ) ;
+#else
__asm
{
mov eax, 0x80000001
cpuid
mov edxreg, edx
}
+#endif
// Now we can mask some AMD specific cpu extensions
CPUInfo._Ext.EMMX_MultimediaExtensions = CheckBit(edxreg, 22);
@@ -929,6 +1042,9 @@
if (CPUInfo.MaxSupportedExtendedLevel >= 0x80000006)
{
// If it's present, we read it out
+#if LL_GNUC
+ cpuid( 0x80000005 , &eaxreg , &ebxreg , &ecxreg , &edxreg ) ;
+#else
__asm
{
mov eax, 0x80000005
@@ -938,6 +1054,7 @@
mov ecxreg, ecx
mov edxreg, edx
}
+#endif
// Then we mask the L1 Data TLB information
if ((ebxreg >> 16) && (eaxreg >> 16))
@@ -1011,6 +1128,9 @@
// size for the TLB. Somebody should check it....
// Now we read the ext. CPUID level 0x80000006
+#if LL_GNUC
+ cpuid( 0x80000006 , &eaxreg , &ebxreg , &ecxreg , &edxreg ) ;
+#else
__asm
{
mov eax, 0x80000006
@@ -1019,6 +1139,7 @@
mov ebxreg, ebx
mov ecxreg, ecx
}
+#endif
// We only mask the unified L2 cache masks (never heard of an
// L2 cache that is divided in data and code parts)
@@ -1084,6 +1205,10 @@
// First of all we read the standard CPUID level 0x00000001
// This level should be available on every x86-processor clone
+#if LL_GNUC
+ eaxreg = cpuid_eax( 1 ) ;
+ ebxreg = cpuid_ebx( 1 ) ;
+#else
__asm
{
mov eax, 1
@@ -1091,6 +1216,7 @@
mov eaxreg, eax
mov ebxreg, ebx
}
+#endif
// Then we mask the processor model, family, type and stepping
CPUInfo.uiStepping = eaxreg & 0xF;
CPUInfo.uiModel = (eaxreg >> 4) & 0xF;
@@ -1161,6 +1287,20 @@
// We've to check if we can toggle the flag register bit 21
// If we can't the processor does not support the CPUID command
+#if LL_GNUC
+ __asm__(
+ " pushf \n"
+ " pop %%eax \n"
+ " mov %%eax , %%ebx \n"
+ " xor $0x00200000 , %%eax \n"
+ " push %%eax \n"
+ " popf \n"
+ " pushf \n"
+ " pop %%eax \n"
+ " xor %%ebx , %%eax \n"
+ : "=a" (BitChanged)
+ :: "%ebx" ) ;
+#else
__asm
{
pushfd
@@ -1174,6 +1314,7 @@
xor eax,ebx
mov BitChanged, eax
}
+#endif
return ((BitChanged) ? true : false);
#else
@@ -1520,6 +1661,9 @@
unsigned long count, num = 255;
for (count = 0; count < num; count++)
{
+#if LL_GNUC
+ cpuid( 2 , &eaxreg , &ebxreg , &ecxreg , &edxreg ) ;
+#else
__asm
{
mov eax, 2
@@ -1529,6 +1673,7 @@
mov ecxreg, ecx
mov edxreg, edx
}
+#endif
// We have to repeat this reading for 'num' times
num = eaxreg & 0xFF;
@@ -1580,6 +1725,10 @@
return;
// We just get the standard CPUID level 0x00000001 which should be
// available on every x86 processor
+#if LL_GNUC
+ ebxreg = cpuid_ebx( 1 ) ;
+ edxreg = cpuid_edx( 1 ) ;
+#else
__asm
{
mov eax, 1
@@ -1587,6 +1736,7 @@
mov ebxreg, ebx
mov edxreg, edx
}
+#endif
// Then we mask some bits
CPUInfo._Ext.FPU_FloatingPointUnit = CheckBit(edxreg, 0);
@@ -1640,6 +1790,9 @@
// We read the standard CPUID level 0x00000000 which should
// be available on every x86 processor
+#if LL_GNUC
+ cpuid( 0 , &eaxreg , &ebxreg , &ecxreg , &edxreg ) ;
+#else
__asm
{
mov eax, 0
@@ -1649,6 +1802,7 @@
mov edxreg, edx
mov ecxreg, ecx
}
+#endif
// Then we connect the single register values to the vendor string
*((unsigned long *) CPUInfo.strVendor) = ebxreg;
*((unsigned long *) (CPUInfo.strVendor+4)) = edxreg;
@@ -1658,12 +1812,16 @@
CPUInfo.MaxSupportedLevel = eaxreg & 0xFFFF;
// Then we read the ext. CPUID level 0x80000000
+#if LL_GNUC
+ eaxreg = cpuid_eax( 0x80000000 ) ;
+#else
__asm
{
mov eax, 0x80000000
cpuid
mov eaxreg, eax
}
+#endif
// ...to check the max. supportted extended CPUID level
CPUInfo.MaxSupportedExtendedLevel = eaxreg;
Index: indra/llcommon/u64.cpp
===================================================================
--- indra/llcommon/u64.cpp (revision 1)
+++ indra/llcommon/u64.cpp (working copy)
@@ -102,7 +102,7 @@
U64 llstrtou64(const char* str, char** end, S32 base)
{
-#ifdef LL_WINDOWS
+#if LLMSVC
return _strtoui64(str,end,base);
#else
return strtoull(str,end,base);
Index: indra/llcommon/llpreprocessor.h
===================================================================
--- indra/llcommon/llpreprocessor.h (revision 1)
+++ indra/llcommon/llpreprocessor.h (working copy)
@@ -48,7 +48,7 @@
#define LL_LIBXUL_ENABLED 1
#elif LL_WINDOWS
#define LL_QUICKTIME_ENABLED 1
- #define LL_LIBXUL_ENABLED 1
+ #define LL_LIBXUL_ENABLED 0
#elif LL_LINUX
#define LL_QUICKTIME_ENABLED 0
#define LL_LIBXUL_ENABLED 1
@@ -61,12 +61,22 @@
#define MOZILLA_INTERNAL_API 1
#endif
-// Deal with minor differences on Unixy OSes.
-#if LL_DARWIN || LL_LINUX
+// Figure out differences between compilers
+#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
+ #ifndef LL_GNUC
+ #define LL_GNUC 1
+ #endif
+#elif __MSVC_VER__
+ #ifndef LL_MSVC
+ #define LL_MSVC 1
+ #endif
+#endif
+// Deal with minor differences on Unixy OSes.
+#if LL_DARWIN || LL_LINUX
// Different name, same functionality.
#define stricmp strcasecmp
#define strnicmp strncasecmp
@@ -79,9 +89,9 @@
#endif
// Deal with the differeneces on Windows
-#if defined(LL_WINDOWS)
+#if LL_MSVC
#define snprintf _snprintf /*Flawfinder: ignore*/
-#endif // LL_WINDOWS
+#endif // LL_MSVC
// Static linking with apr on windows needs to be declared.
#ifdef LL_WINDOWS
@@ -100,7 +110,7 @@
// Deal with VC6 problems
-#if defined(LL_WINDOWS)
+#if LL_MSVC
#pragma warning( 3 : 4701 ) // "local variable used without being initialized" Treat this as level 3, not level 4.
#pragma warning( 3 : 4702 ) // "unreachable code" Treat this as level 3, not level 4.
#pragma warning( 3 : 4189 ) // "local variable initialized but not referenced" Treat this as level 3, not level 4.
@@ -110,6 +120,6 @@
#pragma warning( disable : 4284 ) // silly MS warning deep inside their <map> include file
#pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
#pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
-#endif // LL_WINDOWS
+#endif // LL_MSVC
#endif // not LL_LINDEN_PREPROCESSOR_H
Index: indra/llcommon/llhash.h
===================================================================
--- indra/llcommon/llhash.h (revision 1)
+++ indra/llcommon/llhash.h (working copy)
@@ -30,10 +30,7 @@
#include "llpreprocessor.h" // for GCC_VERSION
-#if (LL_WINDOWS)
-#include <hash_map>
-#include <algorithm>
-#elif LL_DARWIN || LL_LINUX
+#if LL_GNUC
# if GCC_VERSION >= 30400 // gcc 3.4 and up
# include <ext/hashtable.h>
# elif __GNUC__ >= 3
@@ -41,20 +38,23 @@
# else
# include <hashtable.h>
# endif
+#elif LL_WINDOWS
+# include <hash_map>
+# include <algorithm>
#else
#error Please define your platform.
#endif
template<class T> inline size_t llhash(T value)
{
-#if LL_WINDOWS
- return stdext::hash_value<T>(value);
-#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) )
+#if ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) )
std::hash<T> H;
return H(value);
-#elif LL_DARWIN || LL_LINUX
+#elif LL_GNUC
__gnu_cxx::hash<T> H;
return H(value);
+#elif LL_WINDOWS
+ return stdext::hash_value<T>(value);
#else
#error Please define your platform.
#endif
Index: indra/llcommon/stdtypes.h
===================================================================
--- indra/llcommon/stdtypes.h (revision 1)
+++ indra/llcommon/stdtypes.h (working copy)
@@ -44,7 +44,7 @@
typedef wchar_t llwchar;
#endif
-#if LL_WINDOWS
+#if LL_MSVC
typedef signed __int64 S64;
// probably should be 'hyper' or similiar
#define S64L(a) (a)
@@ -53,7 +53,7 @@
#else
typedef long long int S64;
typedef long long unsigned int U64;
-#if LL_DARWIN || LL_LINUX
+#if LL_GNUC
#define S64L(a) (a##LL)
#define U64L(a) (a##ULL)
#endif
Index: indra/llcommon/llfasttimer.cpp
===================================================================
--- indra/llcommon/llfasttimer.cpp (revision 1)
+++ indra/llcommon/llfasttimer.cpp (working copy)
@@ -68,7 +68,7 @@
// CPU clock/other clock frequency and count functions
//
-#if LL_WINDOWS
+#if LL_WINDOWS && LL_MSVC
U64 get_cpu_clock_count()
{ U32 hi,lo;
@@ -87,19 +87,15 @@
return ret;
};
-#endif // LL_WINDOWS
-
-
-#if LL_LINUX
+#elif LL_LINUX || ( LL_WINDOWS && LL_GNUC )
U64 get_cpu_clock_count()
{
U64 x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
}
-#endif
-#if LL_DARWIN
+#elif LL_DARWIN
//
// Mac implementation of CPU clock
//
@@ -109,6 +105,9 @@
{
return get_clock_count();
}
+
+#else
+#error
#endif
//////////////////////////////////////////////////////////////////////////////
Index: indra/lscript/lscript_compile/indra.l
===================================================================
--- indra/lscript/lscript_compile/indra.l (revision 1)
+++ indra/lscript/lscript_compile/indra.l (working copy)
@@ -16,7 +16,7 @@
#include "lscript_typecheck.h"
#include "lscript_resource.h"
#include "llfile.h"
-#if LL_WINDOWS
+#if LL_MSVC
#include "ytab.h"
#else
#include "indra.y.h"
Index: indra/llmath/llmath.h
===================================================================
--- indra/llmath/llmath.h (revision 1)
+++ indra/llmath/llmath.h (working copy)
@@ -120,6 +120,17 @@
// Add or subtract 0.5 - epsilon and then round
const static U32 zpfp[] = { 0xBEFFFFFF, 0x3EFFFFFF };
S32 result;
+#if __MINGW32__ // *HACK: next line requires LL_GNUC to be defined as found in linden_include.h, but that file is not always included before this
+//#if LL_GNUC // *TODO: Test this to make sure it is actually needed under the GNUC compiler with a Windows target platform
+ __asm__ volatile ( "fld %0" :: "m" (f) ) ;
+ __asm__ volatile (
+ " shr $29 , %1 \n"
+ " and $4 , %1 \n"
+ " fadd %c2(%1) \n"
+ " fistp %0 \n"
+ : "=m" (result)
+ : "r" (f) , "i" (zpfp) ) ;
+#else
__asm {
fld f
mov eax, f
@@ -128,6 +139,7 @@
fadd dword ptr [zpfp + eax]
fistp result
}
+#endif
return result;
#else
return (S32)f;
@@ -147,11 +159,21 @@
// Add -(0.5 - epsilon) and then round
const U32 zpfp = 0xBEFFFFFF;
S32 result;
+#if __MINGW32__ // *HACK: next line requires LL_GNUC to be defined as found in linden_include.h, but that file is not always included before this
+//#if LL_GNUC // *TODO: Test this to make if it is actually needed under the GNUC compiler with a Windows target platform
+ __asm__(
+ " fld %1 \n"
+ " fadd %c2 \n"
+ " fistp %0 \n"
+ : "=m" (result)
+ : "m" (f) , "i" (zpfp) ) ;
+#else
__asm {
fld f
fadd dword ptr [zpfp]
fistp result
}
+#endif
return result;
#else
return (S32)floor(f);
Index: indra/newview/llfloaterregioninfo.cpp
===================================================================
--- indra/newview/llfloaterregioninfo.cpp (revision 1)
+++ indra/newview/llfloaterregioninfo.cpp (working copy)
@@ -393,7 +393,10 @@
mInfoPanels.begin(),
mInfoPanels.end(),
llbind2nd(
-#if LL_WINDOWS
+#ifndef LL_GNUC
+#error
+#endif
+#if LL_MSVC
std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion),
#else
std::mem_fun(&LLPanelRegionInfo::refreshFromRegion),
Index: indra/newview/llviewerjointmesh.cpp
===================================================================
--- indra/newview/llviewerjointmesh.cpp (revision 1)
+++ indra/newview/llviewerjointmesh.cpp (working copy)
@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------------
#include "llviewerprecompiledheaders.h"
-#if LL_WINDOWS // For Intel vector classes
+#if LL_WINDOWS && !LL_GNUC // For Intel vector classes
#include "fvec.h"
#endif
Index: indra/newview/llviewerwindow.cpp
===================================================================
--- indra/newview/llviewerwindow.cpp (revision 1)
+++ indra/newview/llviewerwindow.cpp (working copy)
@@ -4458,7 +4458,7 @@
}
llinfos << "...Restoring GL done" << llendl;
#if LL_WINDOWS
- if (SetUnhandledExceptionFilter(LLWinDebug::handleException) != LLWinDebug::handleException)
+ if (SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)LLWinDebug::handleException) != (LPTOP_LEVEL_EXCEPTION_FILTER)LLWinDebug::handleException)
{
llwarns << " Someone took over my exception handler (post restoreGL)!" << llendl;
}
Index: indra/newview/lldirpicker.cpp
===================================================================
--- indra/newview/lldirpicker.cpp (revision 1)
+++ indra/newview/lldirpicker.cpp (working copy)
@@ -90,7 +90,7 @@
{
// Set the string value.
- mDir = utf16str_to_utf8str(llutf16string(buffer));
+ mDir = utf16str_to_utf8str(llutf16string((U16*)buffer));
success = TRUE;
}
Index: indra/newview/llfilepicker.cpp
===================================================================
--- indra/newview/llfilepicker.cpp (revision 1)
+++ indra/newview/llfilepicker.cpp (working copy)
@@ -167,7 +167,7 @@
success = GetOpenFileName(&mOFN);
if (success)
{
- LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW));
+ LLString tstr = utf16str_to_utf8str(llutf16string((U16*)mFilesW));
memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/
mCurrentFile = mFiles;
}
@@ -212,7 +212,7 @@
{
mMultiFile = FALSE;
mCurrentFile = mFiles;
- LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW));
+ LLString tstr = utf16str_to_utf8str(llutf16string((U16*)mFilesW));
memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/
}
else
@@ -230,7 +230,7 @@
if (*tptrw == 0 && !mCurrentFile)
mCurrentFile = tptr+1;
S32 tlen16,tlen8;
- tlen16 = utf16chars_to_utf8chars(tptrw, tptr, &tlen8);
+ tlen16 = utf16chars_to_utf8chars((U16*)tptrw, tptr, &tlen8);
tptrw += tlen16;
tptr += tlen8;
}
@@ -256,7 +256,7 @@
if (filename)
{
llutf16string tstring = utf8str_to_utf16str(filename);
- wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE); } /*Flawfinder: ignore*/
+ wcsncpy(mFilesW, (wchar_t*)tstring.c_str(), FILENAME_BUFFER_SIZE); } /*Flawfinder: ignore*/
else
{
mFilesW[0] = '\0';
@@ -279,6 +279,7 @@
wcsncpy( mFilesW,L"untitled.wav", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
}
mOFN.lpstrDefExt = L"wav";
+ mOFN.lpstrFilter =
L"WAV Sounds (*.wav)\0*.wav\0" \
L"\0";
break;
@@ -389,7 +390,7 @@
success = GetSaveFileName(&mOFN);
if (success)
{
- LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW));
+ LLString tstr = utf16str_to_utf8str(llutf16string((U16*)mFilesW));
memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/
mCurrentFile = mFiles;
}
Index: indra/newview/llagent.cpp
===================================================================
--- indra/newview/llagent.cpp (revision 1)
+++ indra/newview/llagent.cpp (working copy)
@@ -7101,7 +7101,7 @@
// Look up affected baked textures.
// If they exist:
// disallow updates for affected layersets (until dataserver responds with cache request.)
- // If cache miss
turn updates back on and invalidate composite.
+ // If cache miss�turn updates back on and invalidate composite.
// If cache hit, modify baked texture entries.
//
// Cache requests contain list of hashes for each baked texture entry.
Index: indra/newview/moviemaker.cpp
===================================================================
--- indra/newview/moviemaker.cpp (revision 1)
+++ indra/newview/moviemaker.cpp (working copy)
@@ -40,8 +40,8 @@
#include <windowsx.h>
-HANDLE MakeDib( HBITMAP hbitmap, UINT bits );
-HBITMAP LoadBMPFromFB( int w, int h );
+static HANDLE MakeDib( HBITMAP hbitmap, UINT bits );
+static HBITMAP LoadBMPFromFB( int w, int h );
/*
===============================================
Index: indra/newview/llstartup.cpp
===================================================================
--- indra/newview/llstartup.cpp (revision 1)
+++ indra/newview/llstartup.cpp (working copy)
@@ -1,4 +1,4 @@
-/**
+ /**
* @file llstartup.cpp
* @brief startup routines.
*
Index: indra/newview/viewer.cpp
===================================================================
--- indra/newview/viewer.cpp (revision 1)
+++ indra/newview/viewer.cpp (working copy)
@@ -2120,7 +2120,12 @@
HINSTANCE fault_rep_dll_handle = LoadLibrary(L"faultrep.dll"); /* Flawfinder: ignore */
if( fault_rep_dll_handle )
{
+
+#ifdef pfn_ADDEREXCLUDEDAPPLICATION
pfn_ADDEREXCLUDEDAPPLICATIONA pAddERExcludedApplicationA = (pfn_ADDEREXCLUDEDAPPLICATIONA) GetProcAddress(fault_rep_dll_handle, "AddERExcludedApplicationA");
+#else
+ BOOL (*pAddERExcludedApplicationA)(LPCSTR) = (typeof pAddERExcludedApplicationA) GetProcAddress(fault_rep_dll_handle, "AddERExcludedApplicationA");
+#endif
if( pAddERExcludedApplicationA )
{
Index: indra/llvfs/files.mingw32.lst
===================================================================
--- indra/llvfs/files.mingw32.lst (revision 0)
+++ indra/llvfs/files.mingw32.lst (revision 54)
@@ -0,0 +1 @@
+llvfs/lldir_win32.cpp
Index: indra/llvfs/lldir_win32.cpp
===================================================================
--- indra/llvfs/lldir_win32.cpp (revision 1)
+++ indra/llvfs/lldir_win32.cpp (working copy)
@@ -27,6 +27,17 @@
#if LL_WINDOWS
+#ifdef LL_MINGW
+# define INITGUID
+# if WINVER < 0x500 || !defined(WINVER)
+# undef WINVER
+# define WINVER 0x500
+# endif
+# ifndef _WIN32_IE
+# define _WIN32_IE 0x700
+# endif
+#endif
+
#include "linden_common.h"
#include "lldir_win32.h"
@@ -51,7 +62,7 @@
// Application Data is where user settings go
SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE);
- mOSUserDir = utf16str_to_utf8str(llutf16string(w_str));
+ mOSUserDir = utf16str_to_utf8str(llutf16string((U16*)w_str));
// Local Settings\Application Data is where cache files should
// go, they don't get copied to the server if the user moves his
@@ -68,7 +79,7 @@
{
w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash
}
- mTempDir = utf16str_to_utf8str(llutf16string(w_str));
+ mTempDir = utf16str_to_utf8str(llutf16string((U16*)w_str));
}
else
{
@@ -85,7 +96,7 @@
if (size)
{
w_str[size] = '\0';
- mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str));
+ mExecutablePathAndName = utf16str_to_utf8str(llutf16string((U16*)w_str));
S32 path_end = mExecutablePathAndName.find_last_of('\\');
if (path_end != std::string::npos)
{
@@ -97,14 +108,14 @@
mExecutableFilename = mExecutablePathAndName;
}
GetCurrentDirectory(MAX_PATH, w_str);
- mWorkingDir = utf16str_to_utf8str(llutf16string(w_str));
+ mWorkingDir = utf16str_to_utf8str(llutf16string((U16*)w_str));
}
else
{
fprintf(stderr, "Couldn't get APP path, assuming current directory!");
GetCurrentDirectory(MAX_PATH, w_str);
- mExecutableDir = utf16str_to_utf8str(llutf16string(w_str));
+ mExecutableDir = utf16str_to_utf8str(llutf16string((U16*)w_str));
// Assume it's the current directory
}
#else
@@ -193,7 +204,7 @@
llutf16string pathname = utf8str_to_utf16str(dirname);
pathname += utf8str_to_utf16str(mask);
- if ((count_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
+ if ((count_search_h = FindFirstFile((WCHAR*)pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
{
file_count++;
@@ -237,7 +248,7 @@
// and open new one
// Check error opening Directory structure
- if ((mDirSearch_h = FindFirstFile(pathname.c_str(), &FileData)) == INVALID_HANDLE_VALUE)
+ if ((mDirSearch_h = FindFirstFile((WCHAR*)pathname.c_str(), &FileData)) == INVALID_HANDLE_VALUE)
{
// llinfos << "Unable to locate first file" << llendl;
return(FALSE);
@@ -274,7 +285,7 @@
}
// convert from TCHAR to char
- fname = utf16str_to_utf8str(FileData.cFileName);
+ fname = utf16str_to_utf8str((U16*)FileData.cFileName);
// fname now first name in list
return(TRUE);
@@ -309,7 +320,7 @@
// which_file now indicates the (zero-based) index to which file to play
- if ((random_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
+ if ((random_search_h = FindFirstFile((WCHAR*)pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
{
while (which_file--)
{
@@ -320,7 +331,7 @@
}
FindClose(random_search_h);
- fname = utf16str_to_utf8str(llutf16string(FileData.cFileName));
+ fname = utf16str_to_utf8str(llutf16string((U16*)FileData.cFileName));
}
}
@@ -329,7 +340,7 @@
WCHAR w_str[MAX_PATH];
GetCurrentDirectory(MAX_PATH, w_str);
- return utf16str_to_utf8str(llutf16string(w_str));
+ return utf16str_to_utf8str(llutf16string((U16*)w_str));
}
Index: indra/llaudio/audioengine_fmod.cpp
===================================================================
--- indra/llaudio/audioengine_fmod.cpp (revision 1)
+++ indra/llaudio/audioengine_fmod.cpp (working copy)
@@ -324,7 +324,7 @@
{
if (!gWindDSP)
{
- gWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, NULL);
+ gWindDSP = FSOUND_DSP_Create((FSOUND_DSPCALLBACK)&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, NULL);
}
if (gWindDSP)
{
Index: indra/llwindow/files.mingw32.lst
===================================================================
--- indra/llwindow/files.mingw32.lst (revision 0)
+++ indra/llwindow/files.mingw32.lst (revision 54)
@@ -0,0 +1,2 @@
+llwindow/llwindowwin32.cpp
+llwindow/llkeyboardwin32.cpp
\ No newline at end of file
Index: indra/llwindow/llkeyboardwin32.cpp
===================================================================
--- indra/llwindow/llkeyboardwin32.cpp (revision 1)
+++ indra/llwindow/llkeyboardwin32.cpp (working copy)
@@ -27,6 +27,14 @@
#if LL_WINDOWS
+#ifdef LL_MINGW
+#if WINVER < 0x500 || !defined(WINVER)
+#undef WINVER
+#define WINVER 0x500
+#endif
+#endif
+
+
#include "linden_common.h"
#include "llkeyboardwin32.h"
Index: indra/llwindow/lldxhardware.cpp
===================================================================
--- indra/llwindow/lldxhardware.cpp (revision 1)
+++ indra/llwindow/lldxhardware.cpp (working copy)
@@ -27,10 +27,19 @@
#ifdef LL_WINDOWS
+#ifdef LL_MINGW
+# define INITGUID
+# if WINVER < 0x500 || !defined(WINVER)
+# undef WINVER
+# define WINVER 0x500
+# endif
+#endif
+
// Culled from some Microsoft sample code
#include "linden_common.h"
+
#include <assert.h>
#include <dxdiag.h>
@@ -83,7 +92,7 @@
// Clear the variant (this is needed to free BSTR memory)
VariantClear( &var );
- return utf16str_to_utf8str(wszPropValue);
+ return utf16str_to_utf8str((U16*)wszPropValue);
}
Index: indra/llwindow/llwindowwin32.cpp
===================================================================
--- indra/llwindow/llwindowwin32.cpp (revision 1)
+++ indra/llwindow/llwindowwin32.cpp (working copy)
@@ -53,12 +53,14 @@
#include "indra_constants.h"
// culled from winuser.h
+#ifndef LL_MINGW
const S32 WM_MOUSEWHEEL = 0x020A;
const S32 WHEEL_DELTA = 120; /* Value for rolling one detent */
+#endif
+const F32 ICON_FLASH_TIME = 0.5f;
const S32 MAX_MESSAGE_PER_UPDATE = 20;
const S32 BITS_PER_PIXEL = 32;
const S32 MAX_NUM_RESOLUTIONS = 32;
-const F32 ICON_FLASH_TIME = 0.5f;
extern BOOL gDebugWindowProc;
@@ -2318,7 +2320,7 @@
WCHAR *utf16str = (WCHAR*) GlobalLock(h_data);
if (utf16str)
{
- dst = utf16str_to_wstring(utf16str);
+ dst = utf16str_to_wstring((U16*)utf16str);
LLWString::removeCRLF(dst);
GlobalUnlock(h_data);
success = TRUE;
@@ -3049,7 +3051,7 @@
RegCloseKey(key);
// Convert to STL string
- LLWString browser_open_wstring = utf16str_to_wstring(browser_open_wstr);
+ LLWString browser_open_wstring = utf16str_to_wstring((U16*)browser_open_wstr);
if (browser_open_wstring.length() < 2)
{
@@ -3090,8 +3092,8 @@
LPCWSTR directory_wstr = NULL;
int retval = (int) ShellExecute(our_window, /* Flawfinder: ignore */
L"open",
- browser_exec_utf16.c_str(),
- url_utf16.c_str(),
+ (WCHAR*)browser_exec_utf16.c_str(),
+ (WCHAR*)url_utf16.c_str(),
directory_wstr,
SW_SHOWNORMAL);
if (retval > 32)
Index: indra/llwindow/llwindowwin32.h
===================================================================
--- indra/llwindow/llwindowwin32.h (revision 1)
+++ indra/llwindow/llwindowwin32.h (working copy)
@@ -28,6 +28,13 @@
#ifndef LL_LLWINDOWWIN32_H
#define LL_LLWINDOWWIN32_H
+#if LL_MINGW
+#if WINVER < 0x500 || !defined(WINVER)
+#undef WINVER
+#define WINVER 0x500
+#endif
+#endif
+
// Limit Windows API to small and manageable set.
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
More information about the SLDev
mailing list