fixed wicked crazy bug in optimized build, warrants more investigation

master
Allen Webster 2016-08-30 21:44:02 -04:00
parent ca1607013d
commit 1b2c236b57
4 changed files with 62 additions and 47 deletions

View File

@ -15,37 +15,41 @@
* Scalar operators
*/
#define DEG_TO_RAD 0.0174533f
#define DEG_TO_RAD (0.0174533f)
inline f32
ABS(f32 x){
if (x < 0) x = -x;
return(x);
}
#if C_MATH
#include <math.h>
inline f32
ABS(f32 x){
if (x < 0) x = -x;
return x;
}
inline f32
MOD(f32 x, i32 m){
f32 whole, frac;
f32 whole, frac, r;
frac = modff(x, &whole);
return ((i32)(whole) % m) + frac;
r = ((i32)(whole) % m) + frac;
return(r);
}
inline f32
SQRT(f32 x){
return sqrt(x);
f32 r = sqrt(x);
return(r);
}
inline f32
SIN(f32 x_degrees){
return sinf(x_degrees * DEG_TO_RAD);
f32 r = sinf(x_degrees * DEG_TO_RAD);
return(r);
}
inline f32
COS(f32 x_degrees){
return cosf(x_degrees * DEG_TO_RAD);
f32 r = cosf(x_degrees * DEG_TO_RAD);
return(r);
}
#endif

50
build.c
View File

@ -15,7 +15,8 @@
//
#define CL_OPTS \
"/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX "\
"/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 " \
"/wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX " \
"/GR- /EHa- /nologo /FC"
#if defined(_MSC_VER)
@ -146,7 +147,8 @@ enum{
DEBUG_INFO = 0x20,
SUPER = 0x40,
INTERNAL = 0x80,
OPTIMIZATION = 0x100
OPTIMIZATION = 0x100,
KEEP_ASSERT = 0x200
};
@ -221,6 +223,11 @@ build_cl(uint32_t flags,
swap_ptr(&build_options, &build_options_prev);
}
if (flags & KEEP_ASSERT){
snprintf(build_options, build_max, "%s /DFRED_KEEP_ASSERT", build_options_prev);
swap_ptr(&build_options, &build_options_prev);
}
swap_ptr(&build_options, &build_options_prev);
systemf("pushd %s & cl %s %s\\%s /Fe%s /link /DEBUG /INCREMENTAL:NO %s",
@ -254,32 +261,22 @@ buildsuper(char *code_path, char *out_path, char *filename){
#endif
}
#if defined(DEV_BUILD)
int main(int argc, char **argv){
init_time_system();
char cdir[256];
BEGIN_TIME_SECTION();
int32_t n = get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
#define META_DIR "../meta"
#define BUILD_DIR "../build"
static void
standard_build(char *cdir, uint32_t flags){
#if 1
{
BEGIN_TIME_SECTION();
build(OPTS, cdir, "fsm_table_generator.cpp",
BUILD_DIR, "fsmgen", 0);
META_DIR, "fsmgen", 0);
END_TIME_SECTION("build fsm generator");
}
{
BEGIN_TIME_SECTION();
execute(cdir, BUILD_DIR"/fsmgen");
execute(cdir, META_DIR"/fsmgen");
END_TIME_SECTION("run fsm generator");
}
#endif
@ -307,8 +304,6 @@ int main(int argc, char **argv){
END_TIME_SECTION("build custom");
}
uint32_t flags = DEBUG_INFO | SUPER | INTERNAL;
{
BEGIN_TIME_SECTION();
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",
@ -323,14 +318,33 @@ int main(int argc, char **argv){
END_TIME_SECTION("build 4ed");
}
#endif
}
#if defined(DEV_BUILD)
int main(int argc, char **argv){
init_time_system();
char cdir[256];
BEGIN_TIME_SECTION();
int32_t n = get_current_directory(cdir, sizeof(cdir));
assert(n < sizeof(cdir));
END_TIME_SECTION("current directory");
standard_build(cdir, DEBUG_INFO | SUPER | INTERNAL);
return(error_state);
}
#elif defined(PACKAGE)
#else
#error No build type specified
#endif
// BOTTOM

View File

@ -16,8 +16,8 @@ Created on: 20.07.2016
#include <Windows.h>
typedef struct {
char result[2048];
OVERLAPPED overlapped;
char result[2048];
HANDLE dir;
int32_t user_count;
} Win32_Directory_Listener;

View File

@ -8,7 +8,7 @@ pushd W:\4ed\code
..\meta\readmegen
call "build_all.bat" /O2 /DFRED_KEEP_ASSERT
call "build_all.bat" /O2 /DFRED_KEEP_ASSERT /Zi
del ..\current_dist\4coder\*.html
copy ..\build\4ed.exe ..\current_dist\4coder\*
copy ..\build\4ed.pdb ..\current_dist\4coder\*
@ -17,11 +17,9 @@ copy ..\build\4ed_app.pdb ..\current_dist\4coder\*
copy ..\data\* ..\current_dist\4coder\*
copy README.txt ..\current_dist\4coder\*
copy TODO.txt ..\current_dist\4coder\*
del ..\current_dist\SUPERREADME.txt
del ..\current_dist\4coder\basic.cpp
del ..\current_dist\4coder\.4coder_settings
call "build_all.bat" /O2 /DFRED_SUPER /DFRED_KEEP_ASSERT
call "build_all.bat" /O2 /DFRED_SUPER /DFRED_KEEP_ASSERT /Zi
del ..\current_dist\4coder\*.html
copy ..\build\4ed.exe ..\current_dist_super\4coder\*
copy ..\build\4ed.pdb ..\current_dist_super\4coder\*
@ -34,7 +32,6 @@ copy 4coder_*.h ..\current_dist_super\4coder\*
copy 4coder_*.cpp ..\current_dist_super\4coder\*
copy README.txt ..\current_dist_super\4coder\*
copy TODO.txt ..\current_dist_super\4coder\*
copy SUPERREADME.txt ..\current_dist_super\4coder\*
copy ..\current_dist\4coder\3rdparty\* ..\current_dist_super\4coder\3rdparty\*
REM del ..\current_dist_super\4coder\*.pdb
del ..\current_dist_super\4coder\*.lib