Skip to contentSkip to conversation

Bring adlib to the wonderful world of <stdint.h>

PATCH In review Juan Quintela 3 participants 11 messages Aug 28, 2009 – Aug 29, 2009

lore
Share & tools
lore
#0 lore raw

cover Bring adlib to the wonderful world of <stdint.h>

Remove pre C-ansi99 defines for integer types.

Later, Juan.

Juan Quintela (6):
audio: Nothing uses UINT16
audio: s/UINT8/uint8_t
audio: s/UINT32/uint32_t
audio: Nothing uses INT8
audio: s/INT16/int16_t
audio: s/INT32/int32_t

 hw/fmopl.c |   74 ++++++++++++++++++------------------
 hw/fmopl.h |  123 ++++++++++++++++++++++++++++--------------------------------
 2 files changed, 94 insertions(+), 103 deletions(-)
#1 lore raw

PATCH 1/6 audio: Nothing uses UINT16

---
 hw/fmopl.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
hw/fmopl.h +0 -1
index a01ff90..12c78cb 100644
@@ -14,7 +14,6 @@
 #ifndef OSD_CPU_H
 #define OSD_CPU_H
 typedef unsigned char	UINT8;   /* unsigned  8bit */
-typedef unsigned short	UINT16;  /* unsigned 16bit */
 typedef unsigned int	UINT32;  /* unsigned 32bit */
 typedef signed char		INT8;    /* signed  8bit   */
 typedef signed short	INT16;   /* signed 16bit   */
Signature · 1 line
1.6.2.5
#2 lore raw

PATCH 2/6 audio: s/UINT8/uint8_t

In reply to Juan Quintela
---
 hw/fmopl.c |   10 +++++-----
 hw/fmopl.h |   43 ++++++++++++++++++++++---------------------
 2 files changed, 27 insertions(+), 26 deletions(-)
hw/fmopl.c +5 -5
index d1161f8..dd8e6a4 100644
@@ -791,8 +791,8 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
 			}
 			else
 			{	/* set IRQ mask ,timer enable*/
-				UINT8 st1 = v&1;
-				UINT8 st2 = (v>>1)&1;
+				uint8_t st1 = v&1;
+				uint8_t st2 = (v>>1)&1;
 				/* IRQRST,T1MSK,t2MSK,EOSMSK,BRMSK,x,ST2,ST1 */
 				OPL_STATUS_RESET(OPL,v&0x78);
 				OPL_STATUSMASK_SET(OPL,((~v)&0x78)|0x01);
@@ -891,7 +891,7 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
 		case 0xbd:
 			/* amsep,vibdep,r,bd,sd,tom,tc,hh */
 			{
-			UINT8 rkey = OPL->rythm^v;
+			uint8_t rkey = OPL->rythm^v;
 			OPL->ams_table = &AMS_TABLE[v&0x80 ? AMS_ENT : 0];
 			OPL->vib_table = &VIB_TABLE[v&0x40 ? VIB_ENT : 0];
 			OPL->rythm  = v&0x3f;
@@ -1045,7 +1045,7 @@ void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
 	OPLSAMPLE *buf = buffer;
 	UINT32 amsCnt  = OPL->amsCnt;
 	UINT32 vibCnt  = OPL->vibCnt;
-	UINT8 rythm = OPL->rythm&0x20;
+	uint8_t rythm = OPL->rythm&0x20;
 	OPL_CH *CH,*R_CH;
 
 	if( (void *)OPL != cur_chip ){
@@ -1106,7 +1106,7 @@ void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
 	OPLSAMPLE *buf = buffer;
 	UINT32 amsCnt  = OPL->amsCnt;
 	UINT32 vibCnt  = OPL->vibCnt;
-	UINT8 rythm = OPL->rythm&0x20;
+	uint8_t rythm = OPL->rythm&0x20;
 	OPL_CH *CH,*R_CH;
 	YM_DELTAT *DELTAT = OPL->deltat;
 
hw/fmopl.h +22 -21

114 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#3 lore raw

PATCH 3/6 audio: s/UINT32/uint32_t

In reply to Juan Quintela
---
 hw/fmopl.c |   18 +++++++++---------
 hw/fmopl.h |   17 ++++++++---------
 2 files changed, 17 insertions(+), 18 deletions(-)
hw/fmopl.c +9 -9
index dd8e6a4..1bec9d4 100644
@@ -124,7 +124,7 @@ static const int slot_array[32]=
 /* key scale level */
 /* table is 3dB/OCT , DV converts this in TL step at 6dB/OCT */
 #define DV (EG_STEP/2)
-static const UINT32 KSL_TABLE[8*16]=
+static const uint32_t KSL_TABLE[8*16]=
 {
 	/* OCT 0 */
 	 0.000/DV, 0.000/DV, 0.000/DV, 0.000/DV,
@@ -197,7 +197,7 @@ static INT32 ENV_CURVE[2*EG_ENT+1];
 
 /* multiple table */
 #define ML 2
-static const UINT32 MUL_TABLE[16]= {
+static const uint32_t MUL_TABLE[16]= {
 /* 1/2, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 */
    0.50*ML, 1.00*ML, 2.00*ML, 3.00*ML, 4.00*ML, 5.00*ML, 6.00*ML, 7.00*ML,
    8.00*ML, 9.00*ML,10.00*ML,10.00*ML,12.00*ML,12.00*ML,15.00*ML,15.00*ML
@@ -321,7 +321,7 @@ INLINE void OPL_KEYOFF(OPL_SLOT *SLOT)
 
 /* ---------- calcrate Envelope Generator & Phase Generator ---------- */
 /* return : envelope output */
-INLINE UINT32 OPL_CALC_SLOT( OPL_SLOT *SLOT )
+INLINE uint32_t OPL_CALC_SLOT( OPL_SLOT *SLOT )
 {
 	/* calcrate envelope generator */
 	if( (SLOT->evc+=SLOT->evs) >= SLOT->eve )
@@ -453,7 +453,7 @@ INLINE void set_sl_rr(FM_OPL *OPL,int slot,int v)
 /* ---------- calcrate one of channel ---------- */
 INLINE void OPL_CALC_CH( OPL_CH *CH )
 {
-	UINT32 env_out;
+	uint32_t env_out;
 	OPL_SLOT *SLOT;
 
 	feedback2 = 0;
@@ -498,7 +498,7 @@ INLINE void OPL_CALC_CH( OPL_CH *CH )
 #define WHITE_NOISE_db 6.0
 INLINE void OPL_CALC_RH( OPL_CH *CH )
 {
-	UINT32 env_tam,env_sd,env_top,env_hh;
+	uint32_t env_tam,env_sd,env_top,env_hh;
 	int whitenoise = (rand()&1)*(WHITE_NOISE_db/EG_STEP);
 	INT32 tone8;
 
@@ -1043,8 +1043,8 @@ void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
     int i;
 	int data;
 	OPLSAMPLE *buf = buffer;
-	UINT32 amsCnt  = OPL->amsCnt;
-	UINT32 vibCnt  = OPL->vibCnt;
+	uint32_t amsCnt  = OPL->amsCnt;
+	uint32_t vibCnt  = OPL->vibCnt;
 	uint8_t rythm = OPL->rythm&0x20;
 	OPL_CH *CH,*R_CH;
 
@@ -1104,8 +1104,8 @@ void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
     int i;
 	int data;
 	OPLSAMPLE *buf = buffer;
-	UINT32 amsCnt  = OPL->amsCnt;
-	UINT32 vibCnt  = OPL->vibCnt;
+	uint32_t amsCnt  = OPL->amsCnt;
+	uint32_t vibCnt  = OPL->vibCnt;
 	uint8_t rythm = OPL->rythm&0x20;
 	OPL_CH *CH,*R_CH;
 	YM_DELTAT *DELTAT = OPL->deltat;
hw/fmopl.h +8 -9
index f42c803..2945d95 100644
@@ -15,7 +15,6 @@
 /* compiler dependence */
 #ifndef OSD_CPU_H
 #define OSD_CPU_H
-typedef unsigned int	UINT32;  /* unsigned 32bit */
 typedef signed char		INT8;    /* signed  8bit   */
 typedef signed short	INT16;   /* signed 16bit   */
 typedef signed int		INT32;   /* signed 32bit   */
@@ -58,9 +57,9 @@ typedef struct fm_opl_slot {
 	INT32 *RR;		/* release rate    :&DR_TABLE[RR<<2]   */
 	uint8_t ksl;		/* keyscale level  :(shift down bits)  */
 	uint8_t ksr;		/* key scale rate  :kcode>>KSR         */
-	UINT32 mul;		/* multiple        :ML_TABLE[ML]       */
-	UINT32 Cnt;		/* frequency count :                   */
-	UINT32 Incr;	/* frequency step  :                   */
+	uint32_t mul;		/* multiple        :ML_TABLE[ML]       */
+	uint32_t Cnt;		/* frequency count :                   */
+	uint32_t Incr;	/* frequency step  :                   */
 	/* envelope generator state */
 	uint8_t eg_typ;	/* envelope type flag                  */
 	uint8_t evm;		/* envelope phase                      */
@@ -86,10 +85,10 @@ typedef struct fm_opl_channel {
 	INT32 *connect2;	/* slot2 output pointer                */
 	INT32 op1_out[2];	/* slot1 output for selfeedback        */
 	/* phase generator state */
-	UINT32  block_fnum;	/* block+fnum      :                   */
+	uint32_t  block_fnum;	/* block+fnum      :                   */
 	uint8_t kcode;		/* key code        : KeyScaleCode      */
-	UINT32  fc;			/* Freq. Increment base                */
-	UINT32  ksl_base;	/* KeyScaleLevel Base step             */
+	uint32_t  fc;			/* Freq. Increment base                */
+	uint32_t  ksl_base;	/* KeyScaleLevel Base step             */
 	uint8_t keyon;		/* key on/off flag                     */
 } OPL_CH;
 
@@ -103,7 +102,7 @@ typedef struct fm_opl_f {
 	uint8_t address;		/* address register                  */
 	uint8_t status;		/* status flag                       */
 	uint8_t statusmask;	/* status mask                       */
-	UINT32 mode;		/* Reg.08 : CSM , notesel,etc.       */
+	uint32_t mode;		/* Reg.08 : CSM , notesel,etc.       */
 	/* Timer */
 	int T[2];			/* timer counter                     */
 	uint8_t st[2];		/* timer enable                      */
@@ -128,7 +127,7 @@ typedef struct fm_opl_f {
 	/* time tables */
 	INT32 AR_TABLE[75];	/* atttack rate tables */
 	INT32 DR_TABLE[75];	/* decay rate tables   */
-	UINT32 FN_TABLE[1024];  /* fnumber -> increment counter */
+	uint32_t FN_TABLE[1024];  /* fnumber -> increment counter */
 	/* LFO */
 	INT32 *ams_table;
 	INT32 *vib_table;
Signature · 1 line
1.6.2.5
#4 lore raw

PATCH 4/6 audio: Nothing uses INT8

In reply to Juan Quintela
---
 hw/fmopl.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
hw/fmopl.h +0 -1
index 2945d95..2e808cb 100644
@@ -15,7 +15,6 @@
 /* compiler dependence */
 #ifndef OSD_CPU_H
 #define OSD_CPU_H
-typedef signed char		INT8;    /* signed  8bit   */
 typedef signed short	INT16;   /* signed 16bit   */
 typedef signed int		INT32;   /* signed 32bit   */
 #endif
Signature · 1 line
1.6.2.5
#5 lore raw

PATCH 5/6 audio: s/INT16/int16_t

In reply to Juan Quintela
---
 hw/fmopl.c |    4 ++--
 hw/fmopl.h |    7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)
hw/fmopl.c +2 -2
index 1bec9d4..5e37ad9 100644
@@ -1038,7 +1038,7 @@ static void OPL_UnLockTable(void)
 /*******************************************************************************/
 
 /* ---------- update one of chip ----------- */
-void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
+void YM3812UpdateOne(FM_OPL *OPL, int16_t *buffer, int length)
 {
     int i;
 	int data;
@@ -1099,7 +1099,7 @@ void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
 
 #if BUILD_Y8950
 
-void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
+void Y8950UpdateOne(FM_OPL *OPL, int16_t *buffer, int length)
 {
     int i;
 	int data;
hw/fmopl.h +3 -4
index 2e808cb..06a7d26 100644
@@ -15,12 +15,11 @@
 /* compiler dependence */
 #ifndef OSD_CPU_H
 #define OSD_CPU_H
-typedef signed short	INT16;   /* signed 16bit   */
 typedef signed int		INT32;   /* signed 32bit   */
 #endif
 
 #if (OPL_OUTPUT_BIT==16)
-typedef INT16 OPLSAMPLE;
+typedef int16_t OPLSAMPLE;
 #endif
 #if (OPL_OUTPUT_BIT==8)
 typedef unsigned char  OPLSAMPLE;
@@ -165,8 +164,8 @@ unsigned char OPLRead(FM_OPL *OPL,int a);
 int OPLTimerOver(FM_OPL *OPL,int c);
 
 /* YM3626/YM3812 local section */
-void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length);
+void YM3812UpdateOne(FM_OPL *OPL, int16_t *buffer, int length);
 
-void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length);
+void Y8950UpdateOne(FM_OPL *OPL, int16_t *buffer, int length);
 
 #endif
Signature · 1 line
1.6.2.5
#6 lore raw

PATCH 6/6 audio: s/INT32/int32_t

In reply to Juan Quintela
---
 hw/fmopl.c |   42 +++++++++++++++++++++---------------------
 hw/fmopl.h |   54 ++++++++++++++++++++++++------------------------------
 2 files changed, 45 insertions(+), 51 deletions(-)
hw/fmopl.c +21 -21
index 5e37ad9..918fc66 100644
@@ -172,7 +172,7 @@ static const uint32_t KSL_TABLE[8*16]=
 /* sustain lebel table (3db per step) */
 /* 0 - 15: 0, 3, 6, 9,12,15,18,21,24,27,30,33,36,39,42,93 (dB)*/
 #define SC(db) (db*((3/EG_STEP)*(1<<ENV_BITS)))+EG_DST
-static const INT32 SL_TABLE[16]={
+static const int32_t SL_TABLE[16]={
  SC( 0),SC( 1),SC( 2),SC(3 ),SC(4 ),SC(5 ),SC(6 ),SC( 7),
  SC( 8),SC( 9),SC(10),SC(11),SC(12),SC(13),SC(14),SC(31)
 };
@@ -182,18 +182,18 @@ static const INT32 SL_TABLE[16]={
 /* TotalLevel : 48 24 12  6  3 1.5 0.75 (dB) */
 /* TL_TABLE[ 0      to TL_MAX          ] : plus  section */
 /* TL_TABLE[ TL_MAX to TL_MAX+TL_MAX-1 ] : minus section */
-static INT32 *TL_TABLE;
+static int32_t *TL_TABLE;
 
 /* pointers to TL_TABLE with sinwave output offset */
-static INT32 **SIN_TABLE;
+static int32_t **SIN_TABLE;
 
 /* LFO table */
-static INT32 *AMS_TABLE;
-static INT32 *VIB_TABLE;
+static int32_t *AMS_TABLE;
+static int32_t *VIB_TABLE;
 
 /* envelope output curve table */
 /* attack + decay + OFF */
-static INT32 ENV_CURVE[2*EG_ENT+1];
+static int32_t ENV_CURVE[2*EG_ENT+1];
 
 /* multiple table */
 #define ML 2
@@ -205,7 +205,7 @@ static const uint32_t MUL_TABLE[16]= {
 #undef ML
 
 /* dummy attack / decay rate ( when rate == 0 ) */
-static INT32 RATE_0[16]=
+static int32_t RATE_0[16]=
 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
 /* -------------------- static state --------------------- */
@@ -221,14 +221,14 @@ static OPL_CH *S_CH;
 static OPL_CH *E_CH;
 OPL_SLOT *SLOT7_1,*SLOT7_2,*SLOT8_1,*SLOT8_2;
 
-static INT32 outd[1];
-static INT32 ams;
-static INT32 vib;
-INT32  *ams_table;
-INT32  *vib_table;
-static INT32 amsIncr;
-static INT32 vibIncr;
-static INT32 feedback2;		/* connect for SLOT 2 */
+static int32_t outd[1];
+static int32_t ams;
+static int32_t vib;
+int32_t  *ams_table;
+int32_t  *vib_table;
+static int32_t amsIncr;
+static int32_t vibIncr;
+static int32_t feedback2;		/* connect for SLOT 2 */
 
 /* log output level */
 #define LOG_ERR  3      /* ERROR       */
@@ -361,7 +361,7 @@ INLINE uint32_t OPL_CALC_SLOT( OPL_SLOT *SLOT )
 /* set algorythm connection */
 static void set_algorythm( OPL_CH *CH)
 {
-	INT32 *carrier = &outd[0];
+	int32_t *carrier = &outd[0];
 	CH->connect1 = CH->CON ? carrier : &feedback2;
 	CH->connect2 = carrier;
 }
@@ -500,7 +500,7 @@ INLINE void OPL_CALC_RH( OPL_CH *CH )
 {
 	uint32_t env_tam,env_sd,env_top,env_hh;
 	int whitenoise = (rand()&1)*(WHITE_NOISE_db/EG_STEP);
-	INT32 tone8;
+	int32_t tone8;
 
 	OPL_SLOT *SLOT;
 	int env_out;
@@ -618,20 +618,20 @@ static int OPLOpenTable( void )
 	double pom;
 
 	/* allocate dynamic tables */
-	if( (TL_TABLE = malloc(TL_MAX*2*sizeof(INT32))) == NULL)
+	if( (TL_TABLE = malloc(TL_MAX*2*sizeof(int32_t))) == NULL)
 		return 0;
-	if( (SIN_TABLE = malloc(SIN_ENT*4 *sizeof(INT32 *))) == NULL)
+	if( (SIN_TABLE = malloc(SIN_ENT*4 *sizeof(int32_t *))) == NULL)
 	{
 		free(TL_TABLE);
 		return 0;
 	}
-	if( (AMS_TABLE = malloc(AMS_ENT*2 *sizeof(INT32))) == NULL)
+	if( (AMS_TABLE = malloc(AMS_ENT*2 *sizeof(int32_t))) == NULL)
 	{
 		free(TL_TABLE);
 		free(SIN_TABLE);
 		return 0;
 	}
-	if( (VIB_TABLE = malloc(VIB_ENT*2 *sizeof(INT32))) == NULL)
+	if( (VIB_TABLE = malloc(VIB_ENT*2 *sizeof(int32_t))) == NULL)
 	{
 		free(TL_TABLE);
 		free(SIN_TABLE);
hw/fmopl.h +24 -30

91 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#8 lore raw
Quoted 7 lines · malc
Quoted 1 line · Juan Quintela

Remove pre C-ansi99 defines for integer types.

No. Take it with upstream.

[..snip..]

Who is upstream for that file?

Later, Juan.

#9 lore raw
Quoted 10 lines · Juan Quintela
Quoted 7 lines · malc
Quoted 1 line · Juan Quintela

Remove pre C-ansi99 defines for integer types.

No. Take it with upstream.

[..snip..]

Who is upstream for that file?

Tatsuyuki Satoh, it's there in qemu-doc.texi.

Signature · 1 line
mailto:[email protected]
#10 lore raw
Quoted 6 lines · malc
Quoted 5 lines · Juan Quintela
Quoted 4 lines · malc
Quoted 1 line · Juan Quintela

Remove pre C-ansi99 defines for integer types.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

No. Take it with upstream.

[..snip..]

Who is upstream for that file?

Tatsuyuki Satoh, it's there in qemu-doc.texi.

You're hopefully not saying that it's _findable_ in here or that submitters are supposed to read the whole thing carefully front to end to find out.
Everywhere else that's what the MAINTAINERS file is supposed to be there for...