aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2013-01-22 19:55:47 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2013-01-22 19:55:47 +0000
commitdf236ed1dea7a18cda0c0ecb93461affd4f817c6 (patch)
tree0bf823e7e61891baefb50ee6fdd9f80213eca613
parentd629edf90155d7e2e43b6a1d370746375f050815 (diff)
convert int typedefs to use C99 stdint.h
svn path=/trunk/externals/miXed/; revision=16966
-rw-r--r--cyclone/sickle/cycle.c2
-rw-r--r--cyclone/sickle/rand.c2
-rw-r--r--cyclone/sickle/train.c2
-rw-r--r--shared/shared.h154
4 files changed, 48 insertions, 112 deletions
diff --git a/cyclone/sickle/cycle.c b/cyclone/sickle/cycle.c
index 8daa43e..b88c13e 100644
--- a/cyclone/sickle/cycle.c
+++ b/cyclone/sickle/cycle.c
@@ -84,7 +84,7 @@ static t_int *cycle_perform(t_int *w)
t_float *addr, f1, f2, frac;
double dphase = x->x_phase + SHARED_UNITBIT32;
double conv = x->x_conv;
- int32 normhipart;
+ int32_t normhipart;
t_shared_wrappy wrappy;
wrappy.w_d = SHARED_UNITBIT32;
diff --git a/cyclone/sickle/rand.c b/cyclone/sickle/rand.c
index 30014a5..c6126d6 100644
--- a/cyclone/sickle/rand.c
+++ b/cyclone/sickle/rand.c
@@ -31,7 +31,7 @@ static t_int *rand_perform(t_int *w)
double ph = x->x_nextphase;
double tfph = ph + SHARED_UNITBIT32;
t_shared_wrappy wrappy;
- int32 normhipart;
+ int32_t normhipart;
float rcpsr = x->x_rcpsr;
float target = x->x_target;
float scaling = x->x_scaling;
diff --git a/cyclone/sickle/train.c b/cyclone/sickle/train.c
index b07ba9a..6454b0a 100644
--- a/cyclone/sickle/train.c
+++ b/cyclone/sickle/train.c
@@ -39,7 +39,7 @@ static t_int *train_perform(t_int *w)
double ph = x->x_phase;
double tfph = ph + SHARED_UNITBIT32;
t_shared_wrappy wrappy;
- int32 normhipart;
+ int32_t normhipart;
int on = x->x_on;
int edge = 0;
diff --git a/shared/shared.h b/shared/shared.h
index b8c88b8..cb60164 100644
--- a/shared/shared.h
+++ b/shared/shared.h
@@ -5,6 +5,28 @@
#ifndef __SHARED_H__
#define __SHARED_H__
+
+/* Microsoft Visual Studio is not C99, it does not provide stdint.h */
+#ifdef _MSC_VER
+typedef signed __int8 int8_t;
+typedef signed __int16 int16_t;
+typedef signed __int32 int32_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+#elif defined(IRIX)
+typedef long int32_t;
+typedef unsigned long uint32_t;
+typedef short int16_t;
+typedef unsigned short uint16_t;
+typedef unsigned char uchar;
+#else
+#include <stdint.h>
+#endif
+
+
/* LATER find a proper place for #include <limits.h> */
#ifdef INT_MAX
#define SHARED_INT_MAX INT_MAX
@@ -25,127 +47,41 @@
typedef unsigned long shared_t_bitmask;
-/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */
-#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__)
-#include <sys/types.h>
-#ifndef int32
-typedef int32_t int32;
-#endif
-#ifndef uint32
-typedef u_int32_t uint32;
-#endif
-#ifndef int16
-typedef int16_t int16;
-#endif
-#ifndef uint16
-typedef u_int16_t uint16;
-#endif
-#ifndef uchar
-typedef u_int8_t uchar;
-#endif
+
+/* this is for GNU/Linux, GNU/Hurd, GNU/kFreeBSD, Mac OS X, iOS */
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__) || defined(__APPLE__)
#include <endian.h>
-#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN)
-#error No byte order defined
-#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define SHARED_HIOFFSET 1
-#define SHARED_LOWOFFSET 0
-#else
-#define SHARED_HIOFFSET 0
-#define SHARED_LOWOFFSET 1
-#endif
+# if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN)
+# error No byte order defined
+# endif
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define SHARED_HIOFFSET 1
+# define SHARED_LOWOFFSET 0
+# else
+# define SHARED_HIOFFSET 0
+# define SHARED_LOWOFFSET 1
+# endif
#endif
#ifdef _WIN32
-#ifndef int32
-typedef long int32;
-#endif
-#ifndef uint32
-typedef unsigned long uint32;
-#endif
-#ifndef int16
-typedef short int16;
-#endif
-#ifndef uint16
-typedef unsigned short uint16;
-#endif
-#ifndef uchar
-typedef unsigned char uchar;
-#endif
#define SHARED_HIOFFSET 1
#define SHARED_LOWOFFSET 0
#endif
-#ifdef __APPLE__
-#ifndef int32
-typedef int int32;
-#endif
-#ifndef uint32
-typedef unsigned int uint32;
-#endif
-#ifndef int16
-typedef short int16;
-#endif
-#ifndef uint16
-typedef unsigned short uint16;
-#endif
-#ifndef uchar
-typedef unsigned char uchar;
-#endif
-#ifdef __BIG_ENDIAN__
-#define SHARED_HIOFFSET 0
-#define SHARED_LOWOFFSET 1
-#else
-#define SHARED_HIOFFSET 1
-#define SHARED_LOWOFFSET 0
-#endif
-#endif
-
#ifdef IRIX
-#ifndef int32
-typedef long int32;
-#endif
-#ifndef uint32
-typedef unsigned long uint32;
-#endif
-#ifndef int16
-typedef short int16;
-#endif
-#ifndef uint16
-typedef unsigned short uint16;
-#endif
-#ifndef uchar
-typedef unsigned char uchar;
-#endif
#define SHARED_HIOFFSET 0
#define SHARED_LOWOFFSET 1
#endif
#ifdef __FreeBSD__
-#include <sys/types.h>
-#ifndef int32
-typedef int32_t int32;
-#endif
-#ifndef uint32
-typedef u_int32_t uint32;
-#endif
-#ifndef int16
-typedef int16_t int16;
-#endif
-#ifndef uint16
-typedef u_int16_t uint16;
-#endif
-#ifndef uchar
-typedef u_int8_t uchar;
-#endif
#include <machine/endian.h>
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define SHARED_HIOFFSET 1
-#define SHARED_LOWOFFSET 0
-#else
-#define SHARED_HIOFFSET 0
-#define SHARED_LOWOFFSET 1
-#endif
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define SHARED_HIOFFSET 1
+# define SHARED_LOWOFFSET 0
+# else
+# define SHARED_HIOFFSET 0
+# define SHARED_LOWOFFSET 1
+# endif
#endif
#define SHARED_UNITBIT32 1572864. /* 3*(2^19) gives 32 fractional bits */
@@ -155,16 +91,16 @@ typedef u_int8_t uchar;
typedef union _shared_wrappy
{
double w_d;
- int32 w_i[2];
+ int32_t w_i[2];
} t_shared_wrappy;
typedef union _shared_floatint
{
t_float fi_f;
- int32 fi_i;
+ int32_t fi_i;
} t_shared_floatint;
-#define SHARED_TRUEBITS 0x3f800000 /* t_float f = 1; *(int32 *)&f */
+#define SHARED_TRUEBITS 0x3f800000 /* t_float f = 1; *(int32_t *)&f */
#define SHARED_PI 3.14159265359
#define SHARED_2PI 6.28318530718