[Scummvm-cvs-logs] scummvm master -> 59e77ed66779d33a14a5f4d2a5885a70b793f36f
fingolfin
max at quendi.de
Mon May 2 16:37:51 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
58eebff803 AUDIO: Rename clock() -> updateClock() in SID emulator
59e77ed667 ALL: Mark printf and various other symbols as forbidden
Commit: 58eebff8039bb5cfc9a66bcfadfe078abb94556f
https://github.com/scummvm/scummvm/commit/58eebff8039bb5cfc9a66bcfadfe078abb94556f
Author: Max Horn (max at quendi.de)
Date: 2011-05-02T07:31:30-07:00
Commit Message:
AUDIO: Rename clock() -> updateClock() in SID emulator
Changed paths:
audio/softsynth/sid.cpp
audio/softsynth/sid.h
engines/scumm/player_sid.cpp
diff --git a/audio/softsynth/sid.cpp b/audio/softsynth/sid.cpp
index de8f0ee..40dc50e 100644
--- a/audio/softsynth/sid.cpp
+++ b/audio/softsynth/sid.cpp
@@ -109,7 +109,7 @@ void WaveformGenerator::reset() {
msb_rising = false;
}
-RESID_INLINE void WaveformGenerator::clock(cycle_count delta_t) {
+RESID_INLINE void WaveformGenerator::updateClock(cycle_count delta_t) {
// No operation if test bit is set.
if (test) {
return;
@@ -164,10 +164,10 @@ RESID_INLINE void WaveformGenerator::clock(cycle_count delta_t) {
/**
* Synchronize oscillators.
- * This must be done after all the oscillators have been clock()'ed since the
+ * This must be done after all the oscillators have been updateClock()'ed since the
* oscillators operate in parallel.
* Note that the oscillators must be clocked exactly on the cycle when the
- * MSB is set high for hard sync to operate correctly. See SID::clock().
+ * MSB is set high for hard sync to operate correctly. See SID::updateClock().
*/
RESID_INLINE void WaveformGenerator::synchronize() {
// A special case occurs when a sync source is synced itself on the same
@@ -591,7 +591,7 @@ void Filter::set_Q() {
_1024_div_Q = static_cast<sound_sample>(1024.0/(0.707 + 1.0*res/0x0f));
}
-RESID_INLINE void Filter::clock(cycle_count delta_t,
+RESID_INLINE void Filter::updateClock(cycle_count delta_t,
sound_sample voice1,
sound_sample voice2,
sound_sample voice3)
@@ -887,7 +887,7 @@ reg8 EnvelopeGenerator::readENV() {
return output();
}
-RESID_INLINE void EnvelopeGenerator::clock(cycle_count delta_t) {
+RESID_INLINE void EnvelopeGenerator::updateClock(cycle_count delta_t) {
// Check for ADSR delay bug.
// If the rate counter comparison value is set below the current value of the
// rate counter, the counter will continue counting up until it wraps around
@@ -1026,7 +1026,7 @@ void ExternalFilter::reset() {
Vo = 0;
}
-RESID_INLINE void ExternalFilter::clock(cycle_count delta_t, sound_sample Vi) {
+RESID_INLINE void ExternalFilter::updateClock(cycle_count delta_t, sound_sample Vi) {
// This is handy for testing.
if (!enabled) {
// Remove maximum DC level since there is no filter to do it.
@@ -1316,7 +1316,7 @@ bool SID::set_sampling_parameters(double clock_freq,
return true;
}
-void SID::clock(cycle_count delta_t) {
+void SID::updateClock(cycle_count delta_t) {
int i;
if (delta_t <= 0) {
@@ -1332,7 +1332,7 @@ void SID::clock(cycle_count delta_t) {
// Clock amplitude modulators.
for (i = 0; i < 3; i++) {
- voice[i].envelope.clock(delta_t);
+ voice[i].envelope.updateClock(delta_t);
}
// Clock and synchronize oscillators.
@@ -1372,7 +1372,7 @@ void SID::clock(cycle_count delta_t) {
// Clock oscillators.
for (i = 0; i < 3; i++) {
- voice[i].wave.clock(delta_t_min);
+ voice[i].wave.updateClock(delta_t_min);
}
// Synchronize oscillators.
@@ -1384,11 +1384,11 @@ void SID::clock(cycle_count delta_t) {
}
// Clock filter.
- filter.clock(delta_t,
+ filter.updateClock(delta_t,
voice[0].output(), voice[1].output(), voice[2].output());
// Clock external filter.
- extfilt.clock(delta_t, filter.output());
+ extfilt.updateClock(delta_t, filter.output());
}
@@ -1396,7 +1396,7 @@ void SID::clock(cycle_count delta_t) {
* SID clocking with audio sampling.
* Fixpoint arithmetics is used.
*/
-int SID::clock(cycle_count& delta_t, short* buf, int n, int interleave) {
+int SID::updateClock(cycle_count& delta_t, short* buf, int n, int interleave) {
int s = 0;
for (;;) {
@@ -1408,13 +1408,13 @@ int SID::clock(cycle_count& delta_t, short* buf, int n, int interleave) {
if (s >= n) {
return s;
}
- clock(delta_t_sample);
+ updateClock(delta_t_sample);
delta_t -= delta_t_sample;
sample_offset = (next_sample_offset & FIXP_MASK) - (1 << (FIXP_SHIFT - 1));
buf[s++*interleave] = output();
}
- clock(delta_t);
+ updateClock(delta_t);
sample_offset -= delta_t << FIXP_SHIFT;
delta_t = 0;
return s;
diff --git a/audio/softsynth/sid.h b/audio/softsynth/sid.h
index c78f538..d6e402d 100644
--- a/audio/softsynth/sid.h
+++ b/audio/softsynth/sid.h
@@ -60,7 +60,7 @@ public:
void set_sync_source(WaveformGenerator*);
- void clock(cycle_count delta_t);
+ void updateClock(cycle_count delta_t);
void synchronize();
void reset();
@@ -133,7 +133,7 @@ public:
void enable_filter(bool enable);
- void clock(cycle_count delta_t,
+ void updateClock(cycle_count delta_t,
sound_sample voice1, sound_sample voice2, sound_sample voice3);
void reset();
@@ -201,7 +201,7 @@ public:
enum State { ATTACK, DECAY_SUSTAIN, RELEASE };
- void clock(cycle_count delta_t);
+ void updateClock(cycle_count delta_t);
void reset();
void writeCONTROL_REG(reg8);
@@ -246,7 +246,7 @@ public:
void enable_filter(bool enable);
void set_sampling_parameter(double pass_freq);
- void clock(cycle_count delta_t, sound_sample Vi);
+ void updateClock(cycle_count delta_t, sound_sample Vi);
void reset();
// Audio output (20 bits).
@@ -312,8 +312,8 @@ public:
double sample_freq, double pass_freq = -1,
double filter_scale = 0.97);
- void clock(cycle_count delta_t);
- int clock(cycle_count& delta_t, short* buf, int n, int interleave = 1);
+ void updateClock(cycle_count delta_t);
+ int updateClock(cycle_count& delta_t, short* buf, int n, int interleave = 1);
void reset();
// Read/write registers.
diff --git a/engines/scumm/player_sid.cpp b/engines/scumm/player_sid.cpp
index 0d5832a..11468f3 100644
--- a/engines/scumm/player_sid.cpp
+++ b/engines/scumm/player_sid.cpp
@@ -1296,7 +1296,7 @@ int Player_SID::readBuffer(int16 *buffer, const int numSamples) {
_cpuCyclesLeft = timingProps[_videoSystem].cyclesPerFrame;
}
// fetch samples
- int sampleCount = _sid->clock(_cpuCyclesLeft, (short*)buffer, samplesLeft);
+ int sampleCount = _sid->updateClock(_cpuCyclesLeft, (short*)buffer, samplesLeft);
samplesLeft -= sampleCount;
buffer += sampleCount;
}
Commit: 59e77ed66779d33a14a5f4d2a5885a70b793f36f
https://github.com/scummvm/scummvm/commit/59e77ed66779d33a14a5f4d2a5885a70b793f36f
Author: Max Horn (max at quendi.de)
Date: 2011-05-02T07:31:31-07:00
Commit Message:
ALL: Mark printf and various other symbols as forbidden
Right now, a few places in the frontend code still use printf and
consorts. We mark the affected files with a FIXME for now, and
add a dedicated exception for each. To be fixed!
Also tweak FORBIDDEN_SYMBOL_REPLACEMENT to hopefully really always
enforce a compiler error
Changed paths:
audio/softsynth/mt32.cpp
audio/softsynth/mt32/synth.cpp
backends/events/sdl/sdl-events.cpp
backends/fs/posix/posix-fs-factory.cpp
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/sdl/sdl-graphics.cpp
backends/platform/sdl/posix/posix.cpp
backends/platform/sdl/sdl.cpp
backends/saves/posix/posix-saves.cpp
base/commandLine.cpp
base/main.cpp
common/forbidden.h
common/scummsys.h
common/xmlparser.cpp
engines/advancedDetector.cpp
engines/agi/detection.cpp
engines/scumm/detection.cpp
diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp
index 0b84a56..5371be6 100644
--- a/audio/softsynth/mt32.cpp
+++ b/audio/softsynth/mt32.cpp
@@ -351,7 +351,7 @@ void MidiDriver_MT32::send(uint32 b) {
void MidiDriver_MT32::setPitchBendRange(byte channel, uint range) {
if (range > 24) {
- printf("setPitchBendRange() called with range > 24: %d", range);
+ warning("setPitchBendRange() called with range > 24: %d", range);
}
byte benderRangeSysex[9];
benderRangeSysex[0] = 0x41; // Roland
diff --git a/audio/softsynth/mt32/synth.cpp b/audio/softsynth/mt32/synth.cpp
index 4d1c612..112527c 100644
--- a/audio/softsynth/mt32/synth.cpp
+++ b/audio/softsynth/mt32/synth.cpp
@@ -19,6 +19,12 @@
* IN THE SOFTWARE.
*/
+// FIXME: Avoid using printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
+// FIXME: Avoid using vprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_vprintf
+
#include <math.h>
#include <string.h>
#include <stdlib.h>
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 26df038..6e343b6 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -66,7 +66,7 @@ SdlEventSource::SdlEventSource()
// Enable joystick
if (SDL_NumJoysticks() > 0) {
- printf("Using joystick: %s\n", SDL_JoystickName(0));
+ debug("Using joystick: %s", SDL_JoystickName(0));
_joystick = SDL_JoystickOpen(joystick_num);
}
}
diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp
index df21d41..4d23a9e 100644
--- a/backends/fs/posix/posix-fs-factory.cpp
+++ b/backends/fs/posix/posix-fs-factory.cpp
@@ -23,6 +23,12 @@
*/
#if defined(UNIX)
+
+// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h.
+#define FORBIDDEN_SYMBOL_EXCEPTION_chdir
+#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
+#define FORBIDDEN_SYMBOL_EXCEPTION_unlink
+
#include "backends/fs/posix/posix-fs-factory.h"
#include "backends/fs/posix/posix-fs.cpp"
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index d5ba6ee..fe86dd2 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -488,9 +488,9 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
SDL_RWclose(file);
}
if (saveScreenshot(filename))
- printf("Saved '%s'\n", filename);
+ debug("Saved screenshot '%s'", filename);
else
- printf("Could not save screenshot!\n");
+ warning("Could not save screenshot");
return true;
}
}
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index b3e1138..3ae9597 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -2279,9 +2279,9 @@ bool SdlGraphicsManager::notifyEvent(const Common::Event &event) {
SDL_RWclose(file);
}
if (saveScreenshot(filename))
- printf("Saved '%s'\n", filename);
+ debug("Saved screenshot '%s'", filename);
else
- printf("Could not save screenshot!\n");
+ warning("Could not save screenshot");
return true;
}
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 71a8826..889bc5c 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -23,6 +23,8 @@
*
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
+
#include "common/scummsys.h"
#ifdef UNIX
@@ -34,6 +36,7 @@
#include <errno.h>
#include <sys/stat.h>
+
OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName)
:
_baseConfigName(baseConfigName) {
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 4694a06..bc27f8e 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -23,6 +23,9 @@
*
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
+
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp
index be870ab..37db208 100644
--- a/backends/saves/posix/posix-saves.cpp
+++ b/backends/saves/posix/posix-saves.cpp
@@ -23,6 +23,10 @@
*
*/
+
+// Enable mkdir
+#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
+
#include "common/scummsys.h"
#if defined(UNIX) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index b74370d..05e1d2c 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -23,6 +23,9 @@
*
*/
+// FIXME: Avoid using printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
#include "engines/metaengine.h"
#include "base/commandLine.h"
#include "base/plugins.h"
diff --git a/base/main.cpp b/base/main.cpp
index 7a77d6a..fc4523b 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -31,6 +31,9 @@
* of almost all the classes, methods and variables, and how they interact.
*/
+// FIXME: Avoid using printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
#include "engines/engine.h"
#include "engines/metaengine.h"
#include "base/commandLine.h"
diff --git a/common/forbidden.h b/common/forbidden.h
index 92e662c..c22c646 100644
--- a/common/forbidden.h
+++ b/common/forbidden.h
@@ -41,18 +41,22 @@
#ifndef FORBIDDEN_SYMBOL_ALLOW_ALL
+// Make sure scummsys.h is always included first
+#include "common/scummsys.h"
+
+
/**
* The garbage string to use as replacement for forbidden symbols.
*
* The reason for this particular string is the following:
- * By including a space and "!" we try to ensure a compiler error.
- * By using the words "forbidden symbol" we try to make it a bit
- * clearer what is causing the error.
+ * By including a space and some non-alphanumeric symbols we trigger
+ * a compiler error. By including the words "forbidden symbol" (which
+ * the compiler will hopefully print along with its own error message),
+ * we try to make clear what is causing the error.
*/
-#define FORBIDDEN_SYMBOL_REPLACEMENT FORBIDDEN SYMBOL!
+#define FORBIDDEN_SYMBOL_REPLACEMENT FORBIDDEN SYMBOL !%*
-/*
#ifndef FORBIDDEN_SYMBOL_EXCEPTION_printf
#undef printf
#define printf FORBIDDEN_SYMBOL_REPLACEMENT
@@ -62,7 +66,16 @@
#undef fprintf
#define fprintf FORBIDDEN_SYMBOL_REPLACEMENT
#endif
-*/
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_vprintf
+#undef vprintf
+#define vprintf FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_vfprintf
+#undef vfprintf
+#define vfprintf FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
#ifndef FORBIDDEN_SYMBOL_EXCEPTION_FILE
#undef FILE
@@ -131,30 +144,102 @@
#endif
+// Disable various symbols from time.h
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
/*
-time_t
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_t
+#undef time_t
+#define time_t FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+*/
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_asctime
+#undef asctime
+#define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_clock
+#undef clock
+#define clock() FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_ctime
+#undef ctime
+#define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_difftime
+#undef difftime
+#define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-time
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getdate
+#undef getdate
+#define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-difftime
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_gmtime
+#undef gmtime
+#define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-mktime
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_localtime
+#undef localtime
+#define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-localtime
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mktime
+#undef mktime
+#define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-clock
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time
+#undef time
+#define time(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-gmtime
+#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h
-system
-remove
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_chdir
+#undef chdir
+#define chdir(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-setlocale
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir
+#undef mkdir
+#define mkdir(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
-setvbuf
+/*
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setlocale
+#undef setlocale
+#define setlocale(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
*/
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setvbuf
+#undef setvbuf
+#define setvbuf(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unlink
+#undef unlink
+#define unlink(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+/*
+ * We also would like to disable the following symbols;
+ * however, these are also frequently used in regular code,
+ * e.g. for method names, so we don't override them.
+ * - read
+ * - remove
+ * - write
+ * - ...
+ */
+
+
#endif
diff --git a/common/scummsys.h b/common/scummsys.h
index 6554c70..46f900b 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -367,7 +367,7 @@
#if defined(__GNUC__)
#define NORETURN_POST __attribute__((__noreturn__))
#define PACKED_STRUCT __attribute__((__packed__))
- #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))
+ #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y)))
#if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define FORCEINLINE inline __attribute__((__always_inline__))
@@ -375,7 +375,7 @@
#elif defined(__INTEL_COMPILER)
#define NORETURN_POST __attribute__((__noreturn__))
#define PACKED_STRUCT __attribute__((__packed__))
- #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))
+ #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y)))
#else
#define PACKED_STRUCT
#define GCC_PRINTF(x,y)
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 7a6e794..e2e1dbd 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -23,6 +23,13 @@
*
*/
+// FIXME: Avoid using fprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
+
+// FIXME: Avoid using vfprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf
+
+
#include "common/xmlparser.h"
#include "common/archive.h"
#include "common/fs.h"
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index d6f7436..8170452 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -23,6 +23,9 @@
*
*/
+// FIXME: Avoid using printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
#include "common/debug.h"
#include "common/util.h"
#include "common/hash-str.h"
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 5192505..fb92344 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -23,6 +23,9 @@
*
*/
+// FIXME: Avoid using printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
#include "base/plugins.h"
#include "engines/advancedDetector.h"
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 5115a1d..51b46b0 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -23,6 +23,9 @@
*
*/
+// FIXME: Avoid using printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+
#include "base/plugins.h"
#include "common/archive.h"
More information about the Scummvm-git-logs
mailing list