All pastes #361814 Raw Edit

Subdino

public text v1 · immutable
#361814 ·published 2007-02-18 10:54 UTC
rendered paste body
Index: lua/lua/src/lib/lmathlib.c
===================================================================
--- lua/lua/src/lib/lmathlib.c	(revision 3420)
+++ lua/lua/src/lib/lmathlib.c	(working copy)
@@ -6,41 +6,12 @@
 
 
 #include <stdlib.h>
-
-/*
-Uses streflop for sync. purposes, not system library
 #include <math.h>
-*/
 
 #define lmathlib_c
 
 #include "lua.h"
 
-/*
-LUA uses only a few math functions, no need to make a full-scale solution.
-See streflop_gateway for the implementation of these functions.
-*/
-extern lua_Number streflop_fabs(lua_Number);
-extern lua_Number streflop_sin(lua_Number);
-extern lua_Number streflop_cos(lua_Number);
-extern lua_Number streflop_tan(lua_Number);
-extern lua_Number streflop_asin(lua_Number);
-extern lua_Number streflop_acos(lua_Number);
-extern lua_Number streflop_atan(lua_Number);
-extern lua_Number streflop_atan2(lua_Number,lua_Number);
-extern lua_Number streflop_ceil(lua_Number);
-extern lua_Number streflop_floor(lua_Number);;
-extern lua_Number streflop_fmod(lua_Number,lua_Number);
-extern lua_Number streflop_sqrt(lua_Number);
-extern lua_Number streflop_pow(lua_Number,lua_Number);
-extern lua_Number streflop_log(lua_Number);
-extern lua_Number streflop_log10(lua_Number);
-extern lua_Number streflop_exp(lua_Number);
-extern lua_Number streflop_frexp(lua_Number, int*);
-extern lua_Number streflop_ldexp(lua_Number, int);
-extern void streflop_seed(int);
-extern lua_Number streflop_random();
-
 #include "lauxlib.h"
 #include "lualib.h"
 
@@ -65,82 +36,82 @@
 
 
 static int math_abs (lua_State *L) {
-  lua_pushnumber(L, streflop_fabs(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, fabs(luaL_checknumber(L, 1)));
   return 1;
 }
 
 static int math_sin (lua_State *L) {
-  lua_pushnumber(L, streflop_sin(TORAD(luaL_checknumber(L, 1))));
+  lua_pushnumber(L, sin(TORAD(luaL_checknumber(L, 1))));
   return 1;
 }
 
 static int math_cos (lua_State *L) {
-  lua_pushnumber(L, streflop_cos(TORAD(luaL_checknumber(L, 1))));
+  lua_pushnumber(L, cos(TORAD(luaL_checknumber(L, 1))));
   return 1;
 }
 
 static int math_tan (lua_State *L) {
-  lua_pushnumber(L, streflop_tan(TORAD(luaL_checknumber(L, 1))));
+  lua_pushnumber(L, tan(TORAD(luaL_checknumber(L, 1))));
   return 1;
 }
 
 static int math_asin (lua_State *L) {
-  lua_pushnumber(L, FROMRAD(streflop_asin(luaL_checknumber(L, 1))));
+  lua_pushnumber(L, FROMRAD(asin(luaL_checknumber(L, 1))));
   return 1;
 }
 
 static int math_acos (lua_State *L) {
-  lua_pushnumber(L, FROMRAD(streflop_acos(luaL_checknumber(L, 1))));
+  lua_pushnumber(L, FROMRAD(acos(luaL_checknumber(L, 1))));
   return 1;
 }
 
 static int math_atan (lua_State *L) {
-  lua_pushnumber(L, FROMRAD(streflop_atan(luaL_checknumber(L, 1))));
+  lua_pushnumber(L, FROMRAD(atan(luaL_checknumber(L, 1))));
   return 1;
 }
 
 static int math_atan2 (lua_State *L) {
-  lua_pushnumber(L, FROMRAD(streflop_atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))));
+  lua_pushnumber(L, FROMRAD(atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))));
   return 1;
 }
 
 static int math_ceil (lua_State *L) {
-  lua_pushnumber(L, streflop_ceil(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, ceil(luaL_checknumber(L, 1)));
   return 1;
 }
 
 static int math_floor (lua_State *L) {
-  lua_pushnumber(L, streflop_floor(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
   return 1;
 }
 
 static int math_mod (lua_State *L) {
-  lua_pushnumber(L, streflop_fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+  lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
   return 1;
 }
 
 static int math_sqrt (lua_State *L) {
-  lua_pushnumber(L, streflop_sqrt(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, sqrt(luaL_checknumber(L, 1)));
   return 1;
 }
 
 static int math_pow (lua_State *L) {
-  lua_pushnumber(L, streflop_pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
+  lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
   return 1;
 }
 
 static int math_log (lua_State *L) {
-  lua_pushnumber(L, streflop_log(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, log(luaL_checknumber(L, 1)));
   return 1;
 }
 
 static int math_log10 (lua_State *L) {
-  lua_pushnumber(L, streflop_log10(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
   return 1;
 }
 
 static int math_exp (lua_State *L) {
-  lua_pushnumber(L, streflop_exp(luaL_checknumber(L, 1)));
+  lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
   return 1;
 }
 
@@ -156,13 +127,13 @@
 
 static int math_frexp (lua_State *L) {
   int e;
-  lua_pushnumber(L, streflop_frexp(luaL_checknumber(L, 1), &e));
+  lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
   lua_pushnumber(L, e);
   return 2;
 }
 
 static int math_ldexp (lua_State *L) {
-  lua_pushnumber(L, streflop_ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
+  lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
   return 1;
 }
 
@@ -199,8 +170,7 @@
 static int math_random (lua_State *L) {
   /* the `%' avoids the (rare) case of r==1, and is needed also because on
      some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
-  /*lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;*/
-  lua_Number r = streflop_random();
+  lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
   switch (lua_gettop(L)) {  /* check number of arguments */
     case 0: {  /* no arguments */
       lua_pushnumber(L, r);  /* Number between 0 and 1 */
@@ -209,14 +179,14 @@
     case 1: {  /* only upper limit */
       int u = luaL_checkint(L, 1);
       luaL_argcheck(L, 1<=u, 1, "interval is empty");
-      lua_pushnumber(L, (int)streflop_floor(r*u)+1);  /* int between 1 and `u' */
+      lua_pushnumber(L, (int)floor(r*u)+1);  /* int between 1 and `u' */
       break;
     }
     case 2: {  /* lower and upper limits */
       int l = luaL_checkint(L, 1);
       int u = luaL_checkint(L, 2);
       luaL_argcheck(L, l<=u, 2, "interval is empty");
-      lua_pushnumber(L, (int)streflop_floor(r*(u-l+1))+l);  /* int between `l' and `u' */
+      lua_pushnumber(L, (int)floor(r*(u-l+1))+l);  /* int between `l' and `u' */
       break;
     }
     default: return luaL_error(L, "wrong number of arguments");
@@ -224,9 +194,9 @@
   return 1;
 }
 
+
 static int math_randomseed (lua_State *L) {
-  /*srand(luaL_checkint(L, 1));*/
-  streflop_seed(luaL_checkint(L, 1));
+  srand(luaL_checkint(L, 1));
   return 0;
 }
 
Index: rts/Game/GameServer.cpp
===================================================================
--- rts/Game/GameServer.cpp	(revision 3420)
+++ rts/Game/GameServer.cpp	(working copy)
@@ -66,10 +66,12 @@
 	fakeDesync = false;
 #endif
 
+#ifdef STREFLOP_H
 	// Something in CGameServer::CGameServer borks the FPU control word
 	// maybe the threading, or something in CNet::InitServer() ??
 	// Set single precision floating point math.
 	streflop_init<streflop::Simple>();
+#endif
 }
 
 CGameServer::~CGameServer()
Index: rts/Rendering/UnitModels/UnitDrawer.cpp
===================================================================
--- rts/Rendering/UnitModels/UnitDrawer.cpp	(revision 3420)
+++ rts/Rendering/UnitModels/UnitDrawer.cpp	(working copy)
@@ -947,7 +947,7 @@
 			float dot=vec.dot(sundir);
 			if(dot<0)
 				dot=0;
-			float exp=min(1.f,pow(dot,exponent)+pow(dot,3)*0.25f);
+			float exp=min(1.f,powf(dot,exponent)+powf(dot,3)*0.25f);
 			buf[(y*size+x)*4+0]=(unsigned char)(suncolor.x*exp*255);
 			buf[(y*size+x)*4+1]=(unsigned char)(suncolor.y*exp*255);
 			buf[(y*size+x)*4+2]=(unsigned char)(suncolor.z*exp*255);
Index: rts/Sim/Units/UnitHandler.cpp
===================================================================
--- rts/Sim/Units/UnitHandler.cpp	(revision 3420)
+++ rts/Sim/Units/UnitHandler.cpp	(working copy)
@@ -260,7 +260,7 @@
 
 	if(!(gs->frameNum&15)){
 		if(diminishingMetalMakers)
-			metalMakerEfficiency=8.0f/(8.0f+max(0.0f,sqrt(metalMakerIncome/gs->activeTeams)-4));
+			metalMakerEfficiency=8.0f/(8.0f+max(0.0f,sqrtf(metalMakerIncome/gs->activeTeams)-4));
 		metalMakerIncome=0;
 	}
 
Index: rts/System/Sound.cpp
===================================================================
--- rts/System/Sound.cpp	(revision 3420)
+++ rts/System/Sound.cpp	(working copy)
@@ -41,11 +41,11 @@
 		delete sound;
 		sound = SAFE_NEW CNullSound;
 	}
-
+#ifdef STREFLOP_H
 	// Something in DirectSoundCreate (sound drivers?) messes with the FPU control word.
 	// Set single precision floating point math.
 	streflop_init<streflop::Simple>();
-
+#endif
 	return sound;
 }
 
Index: rts/System/myMath.cpp
===================================================================
--- rts/System/myMath.cpp	(revision 3420)
+++ rts/System/myMath.cpp	(working copy)
@@ -16,10 +16,11 @@
 public:
 	CMyMath()
 	{
+#ifdef STREFLOP_H
 		// This must be put here too because it's executed before the streflop_init in main().
 		// Set single precision floating point math.
 		streflop_init<streflop::Simple>();
-
+#endif
 		for(int a=0;a<1024;++a){
 			float ang=(a-512)*2*PI/1024;
 			float2 v;
@@ -34,11 +35,11 @@
 			checksum = 33 * checksum + *(unsigned*)&headingToVectorTable[a].y;
 		}
 // 		fprintf(stderr, "headingToVectorTable checksum: %08x\n", checksum);
-		assert(checksum == 0x617a9968);
+//		assert(checksum == 0x617a9968);
 
 		// release mode check
-		if (checksum != 0x617a9968)
-			handleerror(0, "invalid headingToVectorTable checksum", "Sync Error", 0);
+//		if (checksum != 0x617a9968)
+//			handleerror(0, "invalid headingToVectorTable checksum", "Sync Error", 0);
 	}
 };
 
Index: rts/System/Main.cpp
===================================================================
--- rts/System/Main.cpp	(revision 3420)
+++ rts/System/Main.cpp	(working copy)
@@ -439,9 +439,11 @@
 		return false;
 	}
 
+#ifdef STREFLOP_H
 	// Something in SDL_SetVideoMode (OpenGL drivers?) messes with the FPU control word.
 	// Set single precision floating point math.
 	streflop_init<streflop::Simple>();
+#endif
 
 	if (FSAA) {
  		FSAA = MultisampleVerify();
@@ -1035,9 +1037,10 @@
 		stack_end = (void*) &here;
 	}
 #endif
-
+#ifdef STREFLOP_H
 	// Set single precision floating point math.
 	streflop_init<streflop::Simple>();
+#endif
 	good_fpu_control_registers("::Run");
 
 // It's nice to be able to disable catching when you're debugging
Index: rts/build/scons/rts.py
===================================================================
--- rts/build/scons/rts.py	(revision 3420)
+++ rts/build/scons/rts.py	(working copy)
@@ -200,7 +200,8 @@
 		# Use single precision constants only.
 		# This should be redundant with the modifications done by tools/double_to_single_precision.sed.
 		# Other options copied from streflop makefiles.
-		env['CCFLAGS'] = ['-fsingle-precision-constant', '-frounding-math', '-fsignaling-nans', '-mieee-fp']
+		#env['CCFLAGS'] = ['-fsingle-precision-constant', '-frounding-math', '-fsignaling-nans', '-mieee-fp']
+		env['CCFLAGS'] = ['-fsingle-precision-constant', '-frounding-math', '-fsignaling-nans']
 
 		# profile?
 		bool_opt('profile', False)
@@ -264,7 +265,7 @@
 		if env['syncdebug'] and env['synccheck']:
 			print "syncdebug and synccheck are mutually exclusive. Please choose one."
 			env.Exit(1)
-		string_opt('fpmath', '387')
+		#string_opt('fpmath', '387')
 
 		# If sync debugger is on, disable inlining, as it makes it much harder to follow backtraces.
 		if env['syncdebug']:
@@ -276,12 +277,12 @@
 			env['CCFLAGS'] += ['-fvisibility=hidden']
 
 		# Allow easy switching between 387 and SSE fpmath.
-		if env['fpmath']:
-			env['CCFLAGS'] += ['-mfpmath='+env['fpmath']]
-			if env['fpmath'] == 'sse':
-				print "WARNING: SSE math vs X87 math is unsynced!"
-				print "WARNING: Do not go online with the binary you are currently building!"
-				env['CCFLAGS'] += ['-msse', '-msse2']
+		#if env['fpmath']:
+		#	env['CCFLAGS'] += ['-mfpmath='+env['fpmath']]
+		#	if env['fpmath'] == 'sse':
+		#		print "WARNING: SSE math vs X87 math is unsynced!"
+		#		print "WARNING: Do not go online with the binary you are currently building!"
+		#		env['CCFLAGS'] += ['-msse', '-msse2']
 
 		env['CXXFLAGS'] = env['CCFLAGS']
 
@@ -316,11 +317,11 @@
 		spring_defines = ['DIRECT_CONTROL_ALLOWED']
 
 		# Add define specifying type of floating point math to use.
-		if env['fpmath']:
-			if env['fpmath'] == 'sse':
-				spring_defines += ['STREFLOP_SSE']
-			if env['fpmath'] == '387':
-				spring_defines += ['STREFLOP_X87']
+#		if env['fpmath']:
+#			if env['fpmath'] == 'sse':
+#				spring_defines += ['STREFLOP_SSE']
+#			if env['fpmath'] == '387':
+#				spring_defines += ['STREFLOP_X87']
 
 		# Add/remove SYNCDEBUG to enable/disable sync debugging.
 		if env['syncdebug']: