Lots of fixes for the Linux build:
- renamed sysdep/unix/ functions where necessary - more int -> LibError conversions in the sysdep/unix/ part - added some explicit #include statements where necessary - moved enum LibError/ErrorReaction declarations (gcc doesn't support forward enum declarations) This was SVN commit r3267.
This commit is contained in:
parent
74b8c5b15f
commit
3ea5fa5b46
@ -14,6 +14,8 @@
|
||||
#define ES_SINE 4
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "Camera.h"
|
||||
#include "CStr.h"
|
||||
#include "Vector3D.h"
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "lib/res/res.h"
|
||||
#include "Model.h"
|
||||
#include "UnitManager.h"
|
||||
|
@ -171,12 +171,12 @@ STMT(\
|
||||
|
||||
|
||||
// called when an assertion has failed; notifies the user via debug_display_error.
|
||||
extern enum ErrorReaction debug_assert_failed(const char* assert_expr,
|
||||
extern ErrorReaction debug_assert_failed(const char* assert_expr,
|
||||
const char* file, int line, const char* func);
|
||||
|
||||
// called when a lib function wrapped in DEBUG_WARN_ERR failed;
|
||||
// notifies the user via debug_display_error.
|
||||
extern enum ErrorReaction debug_warn_err(LibError err,
|
||||
extern ErrorReaction debug_warn_err(LibError err,
|
||||
const char* file, int line, const char* func);
|
||||
|
||||
|
||||
@ -198,29 +198,6 @@ extern void debug_wprintf(const wchar_t* fmt, ...);
|
||||
extern void debug_display_msgw(const wchar_t* caption, const wchar_t* msg);
|
||||
|
||||
|
||||
// choices offered by the shared error dialog
|
||||
enum ErrorReaction
|
||||
{
|
||||
// ignore, continue as if nothing happened.
|
||||
// note: don't start at 0 because that is interpreted as a
|
||||
// DialogBoxParam failure.
|
||||
ER_CONTINUE = 1,
|
||||
|
||||
// ignore and do not report again.
|
||||
// only returned if DE_ALLOW_SUPPRESS was passed.
|
||||
// note: non-persistent; only applicable during this program run.
|
||||
ER_SUPPRESS,
|
||||
|
||||
// trigger breakpoint, i.e. enter debugger.
|
||||
// only returned if DE_MANUAL_BREAK was passed; otherwise,
|
||||
// debug_display_error will trigger a breakpoint itself.
|
||||
ER_BREAK,
|
||||
|
||||
// exit the program immediately.
|
||||
// never returned; debug_display_error exits immediately.
|
||||
ER_EXIT
|
||||
};
|
||||
|
||||
enum DisplayErrorFlags
|
||||
{
|
||||
// allow the suppress button (requires calling via macro that
|
||||
|
@ -24,6 +24,30 @@ enum LibError {
|
||||
LIB_ERROR_DUMMY
|
||||
};
|
||||
|
||||
// choices offered by the shared error dialog
|
||||
enum ErrorReaction
|
||||
{
|
||||
// ignore, continue as if nothing happened.
|
||||
// note: don't start at 0 because that is interpreted as a
|
||||
// DialogBoxParam failure.
|
||||
ER_CONTINUE = 1,
|
||||
|
||||
// ignore and do not report again.
|
||||
// only returned if DE_ALLOW_SUPPRESS was passed.
|
||||
// note: non-persistent; only applicable during this program run.
|
||||
ER_SUPPRESS,
|
||||
|
||||
// trigger breakpoint, i.e. enter debugger.
|
||||
// only returned if DE_MANUAL_BREAK was passed; otherwise,
|
||||
// debug_display_error will trigger a breakpoint itself.
|
||||
ER_BREAK,
|
||||
|
||||
// exit the program immediately.
|
||||
// never returned; debug_display_error exits immediately.
|
||||
ER_EXIT
|
||||
};
|
||||
|
||||
|
||||
|
||||
// generate textual description of an error code.
|
||||
// stores up to <max_chars> in the given buffer.
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <math.h>
|
||||
|
||||
// (some math.h versions omit this)
|
||||
|
@ -154,7 +154,7 @@ __asm{
|
||||
// calling conventions.
|
||||
// MSC, ICC and GCC currently return 64 bits in edx:eax, which even
|
||||
// matches rdtsc output, but we play it safe and return a temporary.
|
||||
inline u64 rdtsc()
|
||||
u64 rdtsc()
|
||||
{
|
||||
u64 c;
|
||||
#if HAVE_MS_ASM
|
||||
|
@ -119,6 +119,7 @@ extern void* alloca(size_t size);
|
||||
# define __func__ "(unknown)"
|
||||
#endif
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// sysdep API
|
||||
@ -136,7 +137,6 @@ extern void sys_display_msgw(const wchar_t* caption, const wchar_t* msg);
|
||||
|
||||
// show the error dialog. flags: see DisplayErrorFlags.
|
||||
// called from debug_display_error.
|
||||
enum ErrorReaction;
|
||||
extern ErrorReaction sys_display_error(const wchar_t* text, int flags);
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ int dir_cancel_watch(const intptr_t watch)
|
||||
int dir_get_changed_file(char* fn)
|
||||
{
|
||||
if(!initialized)
|
||||
return -1;
|
||||
return ERR_FAIL;
|
||||
|
||||
FAMEvent e;
|
||||
while(FAMPending(&fc) > 0)
|
||||
@ -69,9 +69,9 @@ int dir_get_changed_file(char* fn)
|
||||
const char* dir = dirs[e.fr.reqnum].c_str();
|
||||
snprintf(n_path, PATH_MAX, "%s%c%s", dir, DIR_SEP, e.filename);
|
||||
CHECK_ERR(file_make_portable_path(n_path, fn));
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return ERR_AGAIN;
|
||||
}
|
||||
|
@ -311,12 +311,12 @@ void demangle_buf(char *buf, const char *symbol, size_t n)
|
||||
free(alloc);
|
||||
}
|
||||
|
||||
int debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line)
|
||||
static LibError debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line)
|
||||
{
|
||||
Dl_info syminfo;
|
||||
|
||||
int res=dladdr(ptr, &syminfo);
|
||||
if (res == 0) return -1;
|
||||
if (res == 0) return ERR_FAIL;
|
||||
|
||||
if (sym_name)
|
||||
{
|
||||
@ -340,10 +340,10 @@ int debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line
|
||||
*line=0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int* line)
|
||||
LibError debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int* line)
|
||||
{
|
||||
ONCE(udbg_init());
|
||||
|
||||
@ -403,7 +403,7 @@ int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int*
|
||||
*line = ctx.line;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
#include "mmgr.h"
|
||||
|
||||
|
@ -25,19 +25,19 @@ void sys_display_msgw(const wchar_t* caption, const wchar_t* msg)
|
||||
}
|
||||
|
||||
|
||||
int get_executable_name(char* n_path, size_t buf_size)
|
||||
LibError sys_get_executable_name(char* n_path, size_t buf_size)
|
||||
{
|
||||
Dl_info dl_info;
|
||||
|
||||
memset(&dl_info, 0, sizeof(dl_info));
|
||||
if (!dladdr((void *)get_executable_name, &dl_info) ||
|
||||
if (!dladdr((void *)sys_get_executable_name, &dl_info) ||
|
||||
!dl_info.dli_fname )
|
||||
{
|
||||
return -ENOSYS;
|
||||
return ERR_NO_SYS;
|
||||
}
|
||||
|
||||
strncpy(n_path, dl_info.dli_fname, buf_size);
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
extern int cpus;
|
||||
@ -53,8 +53,10 @@ int unix_get_cpu_info()
|
||||
|
||||
// apparently not possible on non-Windows OSes because they seem to lack
|
||||
// a CPU affinity API. see sysdep.h comment.
|
||||
int sys_on_each_cpu(void(*cb)())
|
||||
LibError sys_on_each_cpu(void(*cb)())
|
||||
{
|
||||
UNUSED2(cb);
|
||||
|
||||
return ERR_NO_SYS;
|
||||
}
|
||||
|
||||
@ -119,27 +121,41 @@ ErrorReaction sys_display_error(const wchar_t* text, int flags)
|
||||
// take advantage of hardware mouse cursors instead of the (jerky when
|
||||
// loading) OpenGL cursor.
|
||||
|
||||
int sys_cursor_create(uint w, uint h, void* bgra_img,
|
||||
LibError sys_cursor_create(uint w, uint h, void* bgra_img,
|
||||
uint hx, uint hy, void** cursor)
|
||||
{
|
||||
UNUSED2(w);
|
||||
UNUSED2(h);
|
||||
UNUSED2(hx);
|
||||
UNUSED2(hy);
|
||||
UNUSED2(bgra_img);
|
||||
|
||||
*cursor = 0;
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int sys_cursor_set(void* cursor)
|
||||
LibError sys_cursor_set(void* cursor)
|
||||
{
|
||||
return 0;
|
||||
UNUSED2(cursor);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int sys_cursor_free(void* cursor)
|
||||
LibError sys_cursor_free(void* cursor)
|
||||
{
|
||||
return 0;
|
||||
UNUSED2(cursor);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int sys_error_description_r(int err, char* buf, size_t max_chars)
|
||||
LibError sys_error_description_r(int err, char* buf, size_t max_chars)
|
||||
{
|
||||
UNUSED2(err);
|
||||
UNUSED2(buf);
|
||||
UNUSED2(max_chars);
|
||||
|
||||
// don't need to do anything: lib/errors.cpp already queries
|
||||
// libc's strerror(). if we ever end up needing translation of
|
||||
// e.g. Qt or X errors, that'd go here.
|
||||
return -1;
|
||||
}
|
||||
return ERR_FAIL;
|
||||
}
|
||||
|
@ -31,11 +31,11 @@
|
||||
|
||||
// useful for choosing a video mode. not called by detect().
|
||||
// if we fail, outputs are unchanged (assumed initialized to defaults)
|
||||
int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq)
|
||||
LibError get_cur_vmode(int* xres, int* yres, int* bpp, int* freq)
|
||||
{
|
||||
Display* disp = XOpenDisplay(0);
|
||||
if(!disp)
|
||||
return -1;
|
||||
return ERR_FAIL;
|
||||
|
||||
int screen = XDefaultScreen(disp);
|
||||
|
||||
@ -59,17 +59,17 @@ int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq)
|
||||
if(freq)
|
||||
*freq = 0;
|
||||
XCloseDisplay(disp);
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
// useful for determining aspect ratio. not called by detect().
|
||||
// if we fail, outputs are unchanged (assumed initialized to defaults)
|
||||
int get_monitor_size(int& width_mm, int& height_mm)
|
||||
LibError get_monitor_size(int& width_mm, int& height_mm)
|
||||
{
|
||||
Display* disp = XOpenDisplay(0);
|
||||
if(!disp)
|
||||
return -1;
|
||||
return ERR_FAIL;
|
||||
|
||||
int screen = XDefaultScreen(disp);
|
||||
|
||||
@ -77,7 +77,7 @@ int get_monitor_size(int& width_mm, int& height_mm)
|
||||
height_mm=XDisplayHeightMM(disp, screen);
|
||||
|
||||
XCloseDisplay(disp);
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -113,7 +113,7 @@ Expansions:
|
||||
* Implement UTF-8 format support (should be interresting for international users)
|
||||
|
||||
*/
|
||||
wchar_t *clipboard_get()
|
||||
wchar_t *sys_clipboard_get()
|
||||
{
|
||||
Display *disp=XOpenDisplay(NULL);
|
||||
if (!disp)
|
||||
@ -187,10 +187,10 @@ wchar_t *clipboard_get()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int clipboard_free(wchar_t *clip_buf)
|
||||
LibError sys_clipboard_free(wchar_t *clip_buf)
|
||||
{
|
||||
free(clip_buf);
|
||||
return 0;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -202,10 +202,10 @@ Setting the Selection (i.e. "copy")
|
||||
* Tell the X server that we want to own the selection
|
||||
* Listen for Selection events and respond to them as appropriate
|
||||
*/
|
||||
int clipboard_set(const wchar_t *clip_str)
|
||||
LibError sys_clipboard_set(const wchar_t *clip_str)
|
||||
{
|
||||
// Not Implemented, see comment before clipboard_get, above
|
||||
return -1;
|
||||
return ERR_FAIL;
|
||||
}
|
||||
|
||||
#endif // #ifdef HAVE_X
|
||||
|
@ -4,6 +4,7 @@
|
||||
#define __TYPES_H__
|
||||
|
||||
#include "posix_types.h"
|
||||
#include "lib_errors.h"
|
||||
|
||||
// defines instead of typedefs so we can #undef conflicting decls
|
||||
|
||||
@ -31,6 +32,4 @@ typedef unsigned int PS_uint;
|
||||
# error "check size_t and SIZE_MAX - too small?"
|
||||
#endif
|
||||
|
||||
enum LibError;
|
||||
|
||||
#endif // #ifndef __TYPES_H__
|
||||
|
@ -53,7 +53,8 @@ void CAura::Update( size_t UNUSED(timestep) )
|
||||
|
||||
CStrW enterName = L"onEnter";
|
||||
jsval enterFunction;
|
||||
if( JS_GetUCProperty( m_cx, m_handler, enterName.c_str(), enterName.length(), &enterFunction ) )
|
||||
utf16string enterName16 = enterName.utf16();
|
||||
if( JS_GetUCProperty( m_cx, m_handler, enterName16.c_str(), enterName16.length(), &enterFunction ) )
|
||||
{
|
||||
back_insert_iterator<vector<CEntity*> > ins( entered );
|
||||
set_difference( curInfluenced.begin(), curInfluenced.end(),
|
||||
@ -69,7 +70,8 @@ void CAura::Update( size_t UNUSED(timestep) )
|
||||
|
||||
CStrW exitName = L"onExit";
|
||||
jsval exitFunction;
|
||||
if( JS_GetUCProperty( m_cx, m_handler, exitName.c_str(), exitName.length(), &exitFunction ) )
|
||||
utf16string exitName16 = exitName.utf16();
|
||||
if( JS_GetUCProperty( m_cx, m_handler, exitName16.c_str(), exitName16.length(), &exitFunction ) )
|
||||
{
|
||||
back_insert_iterator<vector<CEntity*> > ins( exited );
|
||||
set_difference( prevInfluenced.begin(), prevInfluenced.end(),
|
||||
@ -90,7 +92,8 @@ void CAura::RemoveAll()
|
||||
jsval argv[1];
|
||||
CStrW exitName = L"onExit";
|
||||
jsval exitFunction;
|
||||
if( JS_GetUCProperty( m_cx, m_handler, exitName.c_str(), exitName.length(), &exitFunction ) )
|
||||
utf16string exitName16 = exitName.utf16();
|
||||
if( JS_GetUCProperty( m_cx, m_handler, exitName16.c_str(), exitName16.length(), &exitFunction ) )
|
||||
{
|
||||
for( vector<HEntity>::iterator it = m_influenced.begin(); it != m_influenced.end(); it++ )
|
||||
{
|
||||
@ -112,7 +115,8 @@ void CAura::Remove( CEntity* ent )
|
||||
jsval argv[1];
|
||||
CStrW exitName = L"onExit";
|
||||
jsval exitFunction;
|
||||
if( JS_GetUCProperty( m_cx, m_handler, exitName.c_str(), exitName.length(), &exitFunction ) )
|
||||
utf16string exitName16 = exitName.utf16();
|
||||
if( JS_GetUCProperty( m_cx, m_handler, exitName16.c_str(), exitName16.length(), &exitFunction ) )
|
||||
{
|
||||
argv[0] = OBJECT_TO_JSVAL( ent->GetScript() );
|
||||
JS_CallFunctionValue( m_cx, m_handler, exitFunction, 1, argv, &rval );
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "MessageHandler.h"
|
||||
#include "../CommandProc.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user