Use stdint type names instead of sint8, sint16, etc

This commit is contained in:
carlo-bramini 2017-11-04 12:53:44 +01:00
parent 30c0a72039
commit 4ee44a24a5
7 changed files with 32 additions and 25 deletions

1
CMakeLists.txt Normal file → Executable file
View file

@ -127,6 +127,7 @@ check_include_file ( limits.h HAVE_LIMITS_H )
check_include_file ( pthread.h HAVE_PTHREAD_H )
check_include_file ( signal.h HAVE_SIGNAL_H )
check_include_file ( getopt.h HAVE_GETOPT_H )
check_include_file ( stdint.h HAVE_STDINT_H )
include ( TestInline )
include ( TestVLA )
include ( TestBigEndian )

View file

@ -47,7 +47,7 @@
* It is a 64 bit number. The higher 32 bits contain the 'index' (number of
* the current sample), the lower 32 bits the fractional part.
*/
typedef unsigned long long fluid_phase_t;
typedef uint64_t fluid_phase_t;
/* Purpose:
* Set a to b.
@ -56,26 +56,26 @@ typedef unsigned long long fluid_phase_t;
*/
#define fluid_phase_set(a,b) a=b;
#define fluid_phase_set_int(a, b) ((a) = ((unsigned long long)(b)) << 32)
#define fluid_phase_set_int(a, b) ((a) = ((uint64_t)(b)) << 32)
/* Purpose:
* Sets the phase a to a phase increment given in b.
* For example, assume b is 0.9. After setting a to it, adding a to
* the playing pointer will advance it by 0.9 samples. */
#define fluid_phase_set_float(a, b) \
(a) = (((unsigned long long)(b)) << 32) \
| (uint32) (((double)(b) - (int)(b)) * (double)FLUID_FRACT_MAX)
(a) = (((uint64_t)(b)) << 32) \
| (uint32_t) (((double)(b) - (int)(b)) * (double)FLUID_FRACT_MAX)
/* create a fluid_phase_t from an index and a fraction value */
#define fluid_phase_from_index_fract(index, fract) \
((((unsigned long long)(index)) << 32) + (fract))
((((uint64_t)(index)) << 32) + (fract))
/* Purpose:
* Return the index and the fractional part, respectively. */
#define fluid_phase_index(_x) \
((unsigned int)((_x) >> 32))
#define fluid_phase_fract(_x) \
((uint32)((_x) & 0xFFFFFFFF))
((uint32_t)((_x) & 0xFFFFFFFF))
/* Get the phase index with fractional rounding */
#define fluid_phase_index_round(_x) \
@ -108,7 +108,7 @@ typedef unsigned long long fluid_phase_t;
/* Purpose:
* Subtract b samples from a.
*/
#define fluid_phase_sub_int(a, b) ((a) -= (unsigned long long)(b) << 32)
#define fluid_phase_sub_int(a, b) ((a) -= (uint64_t)(b) << 32)
/* Purpose:
* Creates the expression a.index++. */

View file

@ -2031,14 +2031,14 @@ fluid_sample_import_sfont(fluid_sample_t* sample, SFSample* sfsample, fluid_defs
} while(0)
#define READD(var,fd) do { \
uint32 _temp; \
uint32_t _temp; \
if (!safe_fread(&_temp, 4, fd)) \
return(FAIL); \
var = FLUID_LE32TOH(_temp); \
} while(0)
#define READW(var,fd) do { \
uint16 _temp; \
uint16_t _temp; \
if (!safe_fread(&_temp, 2, fd)) \
return(FAIL); \
var = FLUID_LE16TOH(_temp); \

View file

@ -1410,7 +1410,7 @@ fluid_synth_sysex_midi_tuning (fluid_synth_t *synth, const char *data, int len,
int keys[128];
char name[17];
int note, frac, frac2;
uint8 chksum;
uint8_t chksum;
int i, count, index;
const char *dataptr;
char *resptr;;

View file

@ -1227,7 +1227,7 @@ fluid_str_hash (const void *v)
{
/* 31 bit hash function */
const signed char *p = v;
uint32 h = *p;
uint32_t h = *p;
if (h)
for (p += 1; *p != '\0'; p++)

View file

@ -273,7 +273,7 @@ typedef GStaticPrivate fluid_private_t;
static FLUID_INLINE void
fluid_atomic_float_set(volatile float *fptr, float val)
{
sint32 ival;
int32_t ival;
memcpy (&ival, &val, 4);
fluid_atomic_int_set ((volatile int *)fptr, ival);
}
@ -281,7 +281,7 @@ fluid_atomic_float_set(volatile float *fptr, float val)
static FLUID_INLINE float
fluid_atomic_float_get(volatile float *fptr)
{
sint32 ival;
int32_t ival;
float fval;
ival = fluid_atomic_int_get ((volatile int *)fptr);
memcpy (&fval, &ival, 4);

View file

@ -112,6 +112,24 @@
#include <io.h>
#endif
/** Integer types */
#if HAVE_STDINT_H
#include <stdint.h>
#elif defined _MSC_VER
/* Emulate with standard MSVC types */
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#if defined(WIN32) && HAVE_WINDOWS_H
#include <winsock2.h>
#include <ws2tcpip.h>
@ -121,8 +139,6 @@
/* MinGW32 special defines */
#ifdef MINGW32
#include <stdint.h>
#define DSOUND_SUPPORT 1
#define WINMIDI_SUPPORT 1
#define STDIN_FILENO 0
@ -170,16 +186,6 @@ typedef int fluid_socket_t;
#endif
/** Integer types */
//typedef gint8 sint8;
typedef guint8 uint8;
//typedef gint16 sint16;
typedef guint16 uint16;
typedef gint32 sint32;
typedef guint32 uint32;
//typedef gint64 sint64;
//typedef guint64 uint64;
/** Atomic types */
typedef int fluid_atomic_int_t;
typedef unsigned int fluid_atomic_uint_t;