OSDN Git Service

Stags Sergeev <stsp@aknet.ru>
authorKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Fri, 28 Mar 2008 22:31:51 +0000 (22:31 +0000)
committerKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Fri, 28 Mar 2008 22:31:51 +0000 (22:31 +0000)
 timidity/midi_a.c  remove gnuc extensions

ChangeLog
timidity/midi_a.c

index b573169..4d6d767 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2008-3-28  Stags Sergeev <stsp@aknet.ru>
+       * timidity/midi_a.c      remove gnuc extensions
+
 2007-3-10  Keishi Suenaga <skeishi@yahoo.co.jp>
 
        * interface/npsyn_c.c
index 56d0f99..f9e30fe 100644 (file)
@@ -54,9 +54,6 @@
 #else
 #include "server_defs.h"
 #endif /* HAVE_SYS_SOUNDCARD_H */
-#if !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ <= 95
-#include <stdarg.h>
-#endif
 #ifdef WIN32
 #ifndef STDOUT_FILENO
 #define STDOUT_FILENO 1
@@ -109,24 +106,11 @@ PlayMode dmp = {
 };
 
 static size_t m_fwrite(const void *ptr, size_t size);
-#if defined(__GNUC__) && (__GNUC__ != 2 || __GNUC_MINOR__ > 95)
-#define CARR(...) ((uint8_t []) {__VA_ARGS__})
-#define M_FWRITE(a, ...) m_fwrite(CARR(__VA_ARGS__), sizeof(CARR(__VA_ARGS__)))
-#else
-void M_FWRITE(int n, ...)
-{
-       uint8 a;
-       va_list ap;
-       va_start(ap, n);
-       while(n--){
-               a=(uint8)va_arg(ap, int);
-               m_fwrite(&a, sizeof(uint8));
-       };
-       va_end(ap);
-}
-       
-#endif
-#define M_FWRITE_STR(s) m_fwrite((s), sizeof(s) - 1)
+#define M_FWRITE(...) do { \
+       uint8_t __arg[] = { __VA_ARGS__ }; \
+       m_fwrite(__arg, sizeof(__arg)); \
+} while (0)
+#define M_FWRITE_STR(s) m_fwrite(s, sizeof(s) - 1)
 
 static size_t m_fwrite(const void *ptr, size_t size)
 {
@@ -177,7 +161,7 @@ static void finalize_midi_header(void)
 static void set_tempo(void)
 {
     M_FWRITE_STR("\xff\x51\3");
-    M_FWRITE(3, tempo >> 16, tempo >> 8, tempo);
+    M_FWRITE(tempo >> 16, tempo >> 8, tempo);
 }
 
 static void set_time_sig(void)
@@ -218,10 +202,10 @@ static void midout_write_delta_time(int32 time)
     for (idx = 0; idx < 3; idx++) {
        if (started_printing || c[idx]) {
            started_printing = 1;
-           M_FWRITE(1, c[idx] | 0x80);
+           M_FWRITE(c[idx] | 0x80);
        }
     }
-    M_FWRITE(1, c[3]);
+    M_FWRITE(c[3]);
 }
 
 static void start_midi_track(void)
@@ -301,43 +285,43 @@ static void close_output(void)
 static void midout_noteon(int chn, int note, int vel, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(3,(chn & 0x0f) | MIDI_NOTEON, note & 0x7f, vel & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_NOTEON, note & 0x7f, vel & 0x7f);
 }
 
 static void midout_noteoff(int chn, int note, int vel, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(3, (chn & 0x0f) | MIDI_NOTEOFF, note & 0x7f, vel & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_NOTEOFF, note & 0x7f, vel & 0x7f);
 }
 
 static void midout_control(int chn, int control, int value, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(3, (chn & 0x0f) | MIDI_CTL_CHANGE, control & 0x7f, value & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_CTL_CHANGE, control & 0x7f, value & 0x7f);
 }
 
 static void midout_keypressure(int chn, int control, int value, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(3, (chn & 0x0f) | MIDI_KEY_PRESSURE, control & 0x7f, value & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_KEY_PRESSURE, control & 0x7f, value & 0x7f);
 }
 
 static void midout_channelpressure(int chn, int vel, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(2, (chn & 0x0f) | MIDI_CHN_PRESSURE, vel & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_CHN_PRESSURE, vel & 0x7f);
 }
 
 static void midout_bender(int chn, int pitch, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(3, (chn & 0x0f) | MIDI_PITCH_BEND, pitch & 0x7f, (pitch >> 7) & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_PITCH_BEND, pitch & 0x7f, (pitch >> 7) & 0x7f);
 }
 
 static void midout_program(int chn, int pgm, int32 time)
 {
     midout_write_delta_time(time);
-    M_FWRITE(2, (chn & 0x0f) | MIDI_PGM_CHANGE, pgm & 0x7f);
+    M_FWRITE((chn & 0x0f) | MIDI_PGM_CHANGE, pgm & 0x7f);
 }
 
 static void midout_tempo(int chn, int a, int b, int32 time)
@@ -368,7 +352,7 @@ static void midout_timesig(int chn, int a, int b, int32 time)
        midout_write_delta_time(time);
        M_FWRITE_STR("\xff\x58\4");
     }
-    M_FWRITE(2, a, b);
+    M_FWRITE(a, b);
 }
 
 static int do_event(MidiEvent * ev)