fixed wicked crazy bug in optimized build, warrants more investigation
parent
ca1607013d
commit
1b2c236b57
28
4ed_math.h
28
4ed_math.h
|
@ -15,37 +15,41 @@
|
||||||
* Scalar operators
|
* 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
|
#if C_MATH
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
inline f32
|
|
||||||
ABS(f32 x){
|
|
||||||
if (x < 0) x = -x;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline f32
|
inline f32
|
||||||
MOD(f32 x, i32 m){
|
MOD(f32 x, i32 m){
|
||||||
f32 whole, frac;
|
f32 whole, frac, r;
|
||||||
frac = modff(x, &whole);
|
frac = modff(x, &whole);
|
||||||
return ((i32)(whole) % m) + frac;
|
r = ((i32)(whole) % m) + frac;
|
||||||
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline f32
|
inline f32
|
||||||
SQRT(f32 x){
|
SQRT(f32 x){
|
||||||
return sqrt(x);
|
f32 r = sqrt(x);
|
||||||
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline f32
|
inline f32
|
||||||
SIN(f32 x_degrees){
|
SIN(f32 x_degrees){
|
||||||
return sinf(x_degrees * DEG_TO_RAD);
|
f32 r = sinf(x_degrees * DEG_TO_RAD);
|
||||||
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline f32
|
inline f32
|
||||||
COS(f32 x_degrees){
|
COS(f32 x_degrees){
|
||||||
return cosf(x_degrees * DEG_TO_RAD);
|
f32 r = cosf(x_degrees * DEG_TO_RAD);
|
||||||
|
return(r);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
72
build.c
72
build.c
|
@ -14,8 +14,9 @@
|
||||||
// reusable
|
// reusable
|
||||||
//
|
//
|
||||||
|
|
||||||
#define CL_OPTS \
|
#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"
|
"/GR- /EHa- /nologo /FC"
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
@ -35,21 +36,21 @@
|
||||||
static char cmd[1024];
|
static char cmd[1024];
|
||||||
static int32_t error_state = 0;
|
static int32_t error_state = 0;
|
||||||
|
|
||||||
#define systemf(...) do{\
|
#define systemf(...) do{ \
|
||||||
int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__);\
|
int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__); \
|
||||||
assert(n < sizeof(cmd));\
|
assert(n < sizeof(cmd)); \
|
||||||
if (system(cmd) != 0) error_state = 1;\
|
if (system(cmd) != 0) error_state = 1; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
|
||||||
#if defined(IS_WINDOWS)
|
#if defined(IS_WINDOWS)
|
||||||
|
|
||||||
typedef uint32_t DWORD;
|
typedef uint32_t DWORD;
|
||||||
typedef int32_t LONG;
|
typedef int32_t LONG;
|
||||||
typedef int64_t LONGLONG;
|
typedef int64_t LONGLONG;
|
||||||
typedef char* LPTSTR;
|
typedef char* LPTSTR;
|
||||||
typedef int32_t BOOL;
|
typedef int32_t BOOL;
|
||||||
typedef union _LARGE_INTEGER {
|
typedef union _LARGE_INTEGER {
|
||||||
struct {
|
struct {
|
||||||
DWORD LowPart;
|
DWORD LowPart;
|
||||||
LONG HighPart;
|
LONG HighPart;
|
||||||
|
@ -146,7 +147,8 @@ enum{
|
||||||
DEBUG_INFO = 0x20,
|
DEBUG_INFO = 0x20,
|
||||||
SUPER = 0x40,
|
SUPER = 0x40,
|
||||||
INTERNAL = 0x80,
|
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);
|
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);
|
swap_ptr(&build_options, &build_options_prev);
|
||||||
|
|
||||||
systemf("pushd %s & cl %s %s\\%s /Fe%s /link /DEBUG /INCREMENTAL:NO %s",
|
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
|
#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 META_DIR "../meta"
|
||||||
#define BUILD_DIR "../build"
|
#define BUILD_DIR "../build"
|
||||||
|
|
||||||
|
static void
|
||||||
|
standard_build(char *cdir, uint32_t flags){
|
||||||
#if 1
|
#if 1
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
build(OPTS, cdir, "fsm_table_generator.cpp",
|
build(OPTS, cdir, "fsm_table_generator.cpp",
|
||||||
BUILD_DIR, "fsmgen", 0);
|
META_DIR, "fsmgen", 0);
|
||||||
END_TIME_SECTION("build fsm generator");
|
END_TIME_SECTION("build fsm generator");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
execute(cdir, BUILD_DIR"/fsmgen");
|
execute(cdir, META_DIR"/fsmgen");
|
||||||
END_TIME_SECTION("run fsm generator");
|
END_TIME_SECTION("run fsm generator");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -307,8 +304,6 @@ int main(int argc, char **argv){
|
||||||
END_TIME_SECTION("build custom");
|
END_TIME_SECTION("build custom");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t flags = DEBUG_INFO | SUPER | INTERNAL;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
BEGIN_TIME_SECTION();
|
BEGIN_TIME_SECTION();
|
||||||
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",
|
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");
|
END_TIME_SECTION("build 4ed");
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
return(error_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#elif defined(PACKAGE)
|
#elif defined(PACKAGE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error No build type specified
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -16,8 +16,8 @@ Created on: 20.07.2016
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char result[2048];
|
|
||||||
OVERLAPPED overlapped;
|
OVERLAPPED overlapped;
|
||||||
|
char result[2048];
|
||||||
HANDLE dir;
|
HANDLE dir;
|
||||||
int32_t user_count;
|
int32_t user_count;
|
||||||
} Win32_Directory_Listener;
|
} Win32_Directory_Listener;
|
||||||
|
|
|
@ -8,7 +8,7 @@ pushd W:\4ed\code
|
||||||
|
|
||||||
..\meta\readmegen
|
..\meta\readmegen
|
||||||
|
|
||||||
call "build_all.bat" /O2 /DFRED_KEEP_ASSERT
|
call "build_all.bat" /O2 /DFRED_KEEP_ASSERT /Zi
|
||||||
del ..\current_dist\4coder\*.html
|
del ..\current_dist\4coder\*.html
|
||||||
copy ..\build\4ed.exe ..\current_dist\4coder\*
|
copy ..\build\4ed.exe ..\current_dist\4coder\*
|
||||||
copy ..\build\4ed.pdb ..\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 ..\data\* ..\current_dist\4coder\*
|
||||||
copy README.txt ..\current_dist\4coder\*
|
copy README.txt ..\current_dist\4coder\*
|
||||||
copy TODO.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
|
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
|
del ..\current_dist\4coder\*.html
|
||||||
copy ..\build\4ed.exe ..\current_dist_super\4coder\*
|
copy ..\build\4ed.exe ..\current_dist_super\4coder\*
|
||||||
copy ..\build\4ed.pdb ..\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 4coder_*.cpp ..\current_dist_super\4coder\*
|
||||||
copy README.txt ..\current_dist_super\4coder\*
|
copy README.txt ..\current_dist_super\4coder\*
|
||||||
copy TODO.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\*
|
copy ..\current_dist\4coder\3rdparty\* ..\current_dist_super\4coder\3rdparty\*
|
||||||
REM del ..\current_dist_super\4coder\*.pdb
|
REM del ..\current_dist_super\4coder\*.pdb
|
||||||
del ..\current_dist_super\4coder\*.lib
|
del ..\current_dist_super\4coder\*.lib
|
||||||
|
|
Loading…
Reference in New Issue