Allow disabling time() interception

This prevents recording games using S-RTC but allows building on platforms
not supporting ld --wrap, most notably Mac OS X.
This commit is contained in:
Ilari Liusvaara 2011-09-25 11:48:36 +03:00
parent 3f6ff9f7b5
commit e54fd13bdd
4 changed files with 28 additions and 2 deletions

View file

@ -10,7 +10,7 @@ OBJECTS = $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(wildcard generic/*.cpp)) $(patsu
GENERIC_LIBS = -ldl -lboost_iostreams -lboost_filesystem -lboost_system -lz
CFLAGS = $(USER_CFLAGS)
HOSTCCFLAGS = $(USER_HOSTCCFLAGS)
LDFLAGS = -Wl,--wrap,time $(GENERIC_LIBS) $(USER_LDFLAGS)
LDFLAGS = $(GENERIC_LIBS) $(USER_LDFLAGS)
PLATFORM = SDL
PLATFORM_CFLAGS = $(CFLAGS)
PLATFORM_LDFLAGS = $(LDFLAGS)
@ -28,6 +28,11 @@ LDFLAGS += $(shell pkg-config lua5.1 --libs)
endif
#Some misc defines.
ifdef NO_TIME_INTERCEPT
CFLAGS += -DNO_TIME_INTERCEPT
else
LDFLAGS += -Wl,--wrap,time
endif
ifdef NO_THREADS
CFLAGS += -DNO_THREADS
endif

View file

@ -372,6 +372,10 @@ void update_movie_state()
x << movb.get_movie().next_poll_number();
x << ";" << movb.get_movie().get_lag_frames() << ")/" << movb.get_movie().get_frame_count();
_status["Frame"] = x.str();
} else
_status["Frame"] = "N/A";
#ifndef NO_TIME_INTERCEPT
if(!system_corrupt) {
time_t timevalue = static_cast<time_t>(our_movie.rtc_second);
struct tm* time_decompose = gmtime(&timevalue);
char datebuffer[512];
@ -381,10 +385,10 @@ void update_movie_state()
_status["RTCdate"] = datebuffer;
_status["RTCtime"] = timebuffer;
} else {
_status["Frame"] = "N/A";
_status["RTCdate"] = "N/A";
_status["RTCtime"] = "N/A";
}
#endif
{
std::ostringstream x;
if(system_corrupt)

View file

@ -15,6 +15,13 @@
#include <cstring>
#include <boost/filesystem.hpp>
#ifdef NO_TIME_INTERCEPT
time_t __real_time(time_t* t)
{
return time(t);
}
#endif
namespace
{
std::string rseed;

View file

@ -3315,6 +3315,16 @@ NO_LUA=1
Don't compile in Lua support.
\end_layout
\begin_layout Subsubsection
NO_TIME_INTERCEPT=1
\end_layout
\begin_layout Standard
Disable time() interception.
Prevents recording games using RTC but allows building on some platforms,
notably Mac OS X.
\end_layout
\begin_layout Section
Quick'n'dirty encode guide
\end_layout