1
0
forked from 0ad/0ad

# MacOS X compat (part 1)

- u_anim_name disambiguation
- fix implementation of finite (use our fpclassify instead of compiler's
routine)
- ä -> ae
- workaround for MAP_ANONYMOUS
- fix GLint in ogl.cpp
- add include for SIZE_MAX in string_s
- avoid PIC clobbered error and speed up rdtsc a bit
- add include for stat

This was SVN commit r4170.
This commit is contained in:
janwas 2006-07-26 14:04:52 +00:00
parent 37c87a6579
commit 3195893d1c
40 changed files with 93 additions and 52 deletions

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : CLightEnv implementation
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : CLightEnv, a class describing the current lights
*
* @author Rich Cross <rich@wildfiregames.com>
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Provide the LightEnv object type for JavaScript
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Provide the LightEnv object type for JavaScript
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -62,6 +62,14 @@ static inline LibError LibError_from_mmap(void* ret, bool warn_if_failed = true)
return LibError_from_errno(warn_if_failed);
}
// "anonymous" effectively means mapping /dev/zero, but is more efficient.
// MAP_ANONYMOUS is not in SUSv3, but is a very common extension.
// unfortunately, MacOS X only defines MAP_ANON, which Solaris says is
// deprecated. workaround there: define MAP_ANONYMOUS in terms of MAP_ANON.
#ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS MAP_ANON
#endif
static const int mmap_flags = MAP_PRIVATE|MAP_ANONYMOUS;
static LibError mem_reserve(size_t size, u8** pp)

View File

@ -48,6 +48,13 @@
# endif
#endif
// (only applicable if CPU_IA32) 64-bit values will be returned in EDX:EAX.
// this chiefly affects ia32_rdtsc. if not set, a safer but slower fallback
// will be used that doesn't assume anything about return convention.
#ifndef CONFIG_RETURN64_EDX_EAX
# define CONFIG_RETURN64_EDX_EAX 1
#endif
// this enables/disables the actual checking done by OverrunProtector-s
// (quite slow, entailing mprotect() before/after each access).
// define to 1 here or in the relevant module if you suspect mem corruption.

View File

@ -332,8 +332,8 @@ void oglSquelchError(GLenum err_to_ignore)
// feature and limit detect
//----------------------------------------------------------------------------
int ogl_max_tex_size = -1; // [pixels]
int ogl_max_tex_units = -1; // limit on GL_TEXTUREn
GLint ogl_max_tex_size = -1; // [pixels]
GLint ogl_max_tex_units = -1; // limit on GL_TEXTUREn
// set sysdep/gfx.h gfx_card and gfx_drv_ver. called by gfx_detect.

View File

@ -136,8 +136,8 @@ extern const char* oglExtList(void);
// implementation limits / feature detect
//
extern int ogl_max_tex_size; /// [pixels]
extern int ogl_max_tex_units; /// limit on GL_TEXTUREn
extern GLint ogl_max_tex_size; /// [pixels]
extern GLint ogl_max_tex_units; /// limit on GL_TEXTUREn
/**
* set sysdep/gfx.h gfx_card and gfx_drv_ver. called by gfx_detect.

View File

@ -82,6 +82,8 @@ need only be renamed (e.g. _open, _stat).
#include <sys/utsname.h>
#include <dlfcn.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

View File

@ -175,13 +175,12 @@ __asm{
//-----------------------------------------------------------------------------
// rationale: this function should return its output (instead of setting
// out params) to simplify its callers. it is written in inline asm
// (instead of moving to ia32.asm) to insulate from changing compiler
// 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.
u64 ia32_rdtsc()
// this RDTSC implementation writes edx:eax to a temporary and returns that.
// rationale: this insulates against changing compiler calling conventions,
// at the cost of some efficiency.
// use ia32_rdtsc_edx_eax instead if the return convention is known to be
// edx:eax (should be the case on all 32-bit x86).
u64 ia32_rdtsc_safe()
{
u64 c;
#if HAVE_MS_ASM
@ -193,11 +192,13 @@ __asm
mov dword ptr [c+4], edx
}
#elif HAVE_GNU_ASM
// note: we save+restore EBX to avoid xcode complaining about a
// "PIC register" being clobbered, whatever that means.
__asm__ __volatile__ (
"cpuid; rdtsc"
"pushl %%ebx; cpuid; popl %%ebx; rdtsc"
: "=A" (c)
: /* no input */
: "ebx", "ecx" /* cpuid clobbers ebx and ecx */);
: "ecx" /* cpuid clobbers eax..edx, but the rest are covered */);
#endif
return c;
}

View File

@ -89,7 +89,13 @@ extern void* ia32_memcpy(void* dst, const void* src, size_t nbytes); // asm
extern uint ia32_control87(uint new_val, uint mask); // asm
extern u64 ia32_rdtsc(void);
extern u64 ia32_rdtsc_edx_eax(void);
extern u64 ia32_rdtsc_safe(void);
#if CONFIG_RETURN64_EDX_EAX
# define ia32_rdtsc ia32_rdtsc_edx_eax
#else
# define ia32_rdtsc ia32_rdtsc_safe
#endif
extern void ia32_debug_break(void);

View File

@ -178,6 +178,25 @@ sym(ia32_fpclassifyf):
; misc
;-------------------------------------------------------------------------------
; rationale: the common return convention for 64-bit values is in edx:eax.
; with inline asm, we'd have to MOV data to a temporary and return that;
; this is less efficient (-> important for low-overhead profiling) than
; making use of the convention.
;
; however, speed is not the main reason for providing this routine.
; xcode complains about CPUID clobbering ebx, so we use external asm
; where possible (IA-32 CPUs).
;
; extern "C" u64 ia32_rdtsc_edx_eax()
global sym(ia32_rdtsc_edx_eax)
sym(ia32_rdtsc_edx_eax):
push ebx
cpuid
pop ebx
rdtsc
ret
; write the current execution state (e.g. all register values) into
; (Win32::CONTEXT*)pcontext (defined as void* to avoid dependency).
; optimized for size; this must be straight asm because __declspec(naked)

View File

@ -127,14 +127,12 @@ extern void* alloca(size_t size);
# endif
# define isnan(d) (fpclassify(d) == FP_NAN)
# define isfinite(d) ((fpclassify(d) & (FP_NORMAL|FP_ZERO)) != 0)
# define isinf(d) (fpclassify(d) == FP_NAN|FP_NORMAL)
# define isnormal(d) (fpclassify(d) == FP_NORMAL)
//# define signbit
#endif
// finite: return 0 iff the given double is infinite or NaN.
#if OS_WIN
# define finite _finite
#else
# define finite __finite
#endif
// C99 restrict
// .. for some reason, g++-3.3 claims to support C99 (according to

View File

@ -62,7 +62,7 @@ double get_time()
gettimeofday(&cur, 0);
t = (cur.tv_sec - start.tv_sec) + (cur.tv_usec - start.tv_usec)*1e-6;
#else
#error "get_time: add timer implementation for this platform!"
# error "get_time: add timer implementation for this platform!"
#endif
// make sure time is monotonic (never goes backwards)

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Implementation of CBrush, a class representing a convex object
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : CBrush, a class representing a convex object
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Implementation of FixedFunctionModelRenderer
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : ModelVertexRenderer that uses only fixed function pipeline
* : to render animated models.
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Implementation of HWLightingModelRenderer
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : ModelVertexRenderer that transforms models on the CPU
* : but performs lighting in a vertex shader.
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Implementation of InstancingModelRenderer
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : Special ModelVertexRender that only works for non-animated
* : models, but is very fast for instanced models.
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Implementation of ModelRenderer and BatchModelRenderer
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -6,7 +6,7 @@
* : that manages a per-frame list of submitted models,
* : as well as simple helper classes.
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : Definition of ModelVertexRenderer, the abstract base class
* : for model vertex transformation implementations.
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : Implementation of player colour RenderModifiers.
*
* @author John M. Mena <JohnMMena@hotmail.com>
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -6,7 +6,7 @@
* : with e.g. FixedFunctionModelRenderer
*
* @author John M. Mena <JohnMMena@hotmail.com>
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Implementation of common RenderModifiers
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -6,7 +6,7 @@
* : of some ModelRenderers. This file defines some common
* : RenderModifiers in addition to the base class.
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Shadow mapping related texture and matrix management
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Shadow mapping related texture and matrix management
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : Terrain rendering (everything related to patches and
* : water) is encapsulated in TerrainRenderer
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -5,7 +5,7 @@
* Description : Terrain rendering (everything related to patches and
* : water) is encapsulated in TerrainRenderer
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -7,7 +7,7 @@
* : rendering.
*
* @author Rich Cross <rich@wildfiregames.com>
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -7,7 +7,7 @@
* : rendering.
*
* @author Rich Cross <rich@wildfiregames.com>
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Water settings (speed, height) and texture management
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -4,7 +4,7 @@
* Project : Pyrogenesis
* Description : Water settings (speed, height) and texture management
*
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
* @author Nicolai Haehnle <nicolai@wildfiregames.com>
* =========================================================================
*/

View File

@ -6,7 +6,7 @@
#include "ps/Parser.h"
#include "ps/Player.h"
#include "simulation/EntityTemplate.h"
#include "lib/sysdep/sysdep.h" // finite
#include "lib/sysdep/sysdep.h" // isfinite
#include <cfloat>
@ -151,7 +151,7 @@ template<> jsval ToJSVal<double>( double& Native )
template<> bool ToPrimitive<double>( JSContext* cx, jsval v, double& Storage )
{
JSBool ok = JS_ValueToNumber(cx, v, &Storage);
if (ok == JS_FALSE || !finite( Storage ) )
if (ok == JS_FALSE || !isfinite( Storage ) )
return false;
return true;
}

View File

@ -340,7 +340,7 @@ double ScriptingHost::ValueToDouble(const jsval value)
JSBool ok = JS_ValueToNumber(m_Context, value, &d);
if (ok == JS_FALSE || !finite(d))
if (ok == JS_FALSE || !isfinite(d))
throw PSERROR_Scripting_ConversionFailed();
return d;

View File

@ -60,7 +60,7 @@ float CEntity::processChooseMovement( float distance )
// TODO: the animation code requires unicode for now. will be changed to
// 8bit later (for consistency; note that filenames etc. need not be
// unicode), so remove this then.
const CStrW u_anim_name = anim_name;
const CStrW u_anim_name(anim_name);
if ( m_actor )
{