Don't use -Werror
[lsnes.git] / bsnes-patches / v086 / 0001-Don-t-use-time-in-emulating-chips.patch
blobaee55cc31af74187cdc1e982a36baf9023131fab
1 From 6c3da8eb6516d25e97b46d97fb0d3d24ca9ecfd0 Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Wed, 9 Nov 2011 00:37:44 +0200
4 Subject: [PATCH 1/8] Don't use time() in emulating chips
6 Instead of using time() in chip emulation, create new interface method
7 currentTime(), defaulting to time(0). This way frontend can cleanly
8 override the current time bsnes is using.
9 ---
10 snes/chip/bsx/satellaview/satellaview.cpp | 2 +-
11 snes/chip/spc7110/spc7110.cpp | 2 +-
12 snes/chip/srtc/srtc.cpp | 2 +-
13 snes/interface/interface.cpp | 5 +++++
14 snes/interface/interface.hpp | 1 +
15 5 files changed, 9 insertions(+), 3 deletions(-)
17 diff --git a/snes/chip/bsx/satellaview/satellaview.cpp b/snes/chip/bsx/satellaview/satellaview.cpp
18 index 386fb62..3c98019 100755
19 --- a/snes/chip/bsx/satellaview/satellaview.cpp
20 +++ b/snes/chip/bsx/satellaview/satellaview.cpp
21 @@ -38,7 +38,7 @@ uint8 BSXSatellaview::mmio_read(unsigned addr) {
23 if(counter == 0) {
24 time_t rawtime;
25 - time(&rawtime);
26 + rawtime = SNES::interface->currentTime();
27 tm *t = localtime(&rawtime);
29 regs.r2192_hour = t->tm_hour;
30 diff --git a/snes/chip/spc7110/spc7110.cpp b/snes/chip/spc7110/spc7110.cpp
31 index d2dc640..74a817a 100755
32 --- a/snes/chip/spc7110/spc7110.cpp
33 +++ b/snes/chip/spc7110/spc7110.cpp
34 @@ -101,7 +101,7 @@ void SPC7110::set_data_adjust(unsigned addr) { r4814 = addr; r4815 = addr >> 8;
36 void SPC7110::update_time(int offset) {
37 time_t rtc_time = (rtc[16] << 0) | (rtc[17] << 8) | (rtc[18] << 16) | (rtc[19] << 24);
38 - time_t current_time = time(0) - offset;
39 + time_t current_time = SNES::interface->currentTime() - offset;
41 //sizeof(time_t) is platform-dependent; though rtc[] needs to be platform-agnostic.
42 //yet platforms with 32-bit signed time_t will overflow every ~68 years. handle this by
43 diff --git a/snes/chip/srtc/srtc.cpp b/snes/chip/srtc/srtc.cpp
44 index 1b2fd2a..78fc4c1 100755
45 --- a/snes/chip/srtc/srtc.cpp
46 +++ b/snes/chip/srtc/srtc.cpp
47 @@ -31,7 +31,7 @@ void SRTC::reset() {
49 void SRTC::update_time() {
50 time_t rtc_time = (rtc[16] << 0) | (rtc[17] << 8) | (rtc[18] << 16) | (rtc[19] << 24);
51 - time_t current_time = time(0);
52 + time_t current_time = SNES::interface->currentTime();
54 //sizeof(time_t) is platform-dependent; though rtc[] needs to be platform-agnostic.
55 //yet platforms with 32-bit signed time_t will overflow every ~68 years. handle this by
56 diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
57 index a0e3a81..b3017c9 100755
58 --- a/snes/interface/interface.cpp
59 +++ b/snes/interface/interface.cpp
60 @@ -18,4 +18,9 @@ void Interface::message(const string &text) {
61 print(text, "\n");
64 +time_t Interface::currentTime()
66 + return time(0);
70 diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
71 index f1a48c0..df975e8 100755
72 --- a/snes/interface/interface.hpp
73 +++ b/snes/interface/interface.hpp
74 @@ -5,6 +5,7 @@ struct Interface {
76 virtual string path(Cartridge::Slot slot, const string &hint) = 0;
77 virtual void message(const string &text);
78 + virtual time_t currentTime();
81 extern Interface *interface;
82 --
83 1.8.4.4