From c0efacf6d17f17b37073965e1c91c782b86d2738 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 13 Dec 2012 05:21:56 +0000 Subject: fix float->int32_t and int32_t->float type-punning svn path=/branches/pd-extended/0.43/externals/oscx/; revision=16678 --- OSC-client.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'OSC-client.c') diff --git a/OSC-client.c b/OSC-client.c index 73bc1a1..e68b6f4 100644 --- a/OSC-client.c +++ b/OSC-client.c @@ -138,7 +138,7 @@ int OSC_packetSize(OSCbuf *buf) { } static void PatchMessageSize(OSCbuf *buf) { - int4byte size; + int32_t size; size = buf->bufptr - ((char *) buf->thisMsgSize) - 4; *(buf->thisMsgSize) = htonl(size); } @@ -172,8 +172,8 @@ int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt) { /* This bundle is inside another bundle, so we need to leave a blank size count for the size of this current bundle. */ CheckOverflow(buf, 20); - *((int4byte *)buf->bufptr) = 0xaaaaaaaa; - buf->prevCounts[buf->bundleDepth] = (int4byte *)buf->bufptr; + *((int32_t *)buf->bufptr) = 0xaaaaaaaa; + buf->prevCounts[buf->bundleDepth] = (int32_t *)buf->bufptr; buf->bufptr += 4; } @@ -185,7 +185,7 @@ int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt) { if (htonl(1) != 1) { /* Byte swap the 8-byte integer time tag */ - int4byte *intp = (int4byte *)buf->bufptr; + int32_t *intp = (int32_t *)buf->bufptr; intp[0] = htonl(intp[0]); intp[1] = htonl(intp[1]); @@ -194,7 +194,7 @@ int OSC_openBundle(OSCbuf *buf, OSCTimeTag tt) { (Otherwise tt is a struct of two 32-bit words, and even though each word was wrong-endian, they were in the right order in the struct.) */ - int4byte temp = intp[0]; + int32_t temp = intp[0]; intp[0] = intp[1]; intp[1] = temp; } @@ -258,7 +258,7 @@ int OSC_closeAllBundles(OSCbuf *buf) { } int OSC_writeAddress(OSCbuf *buf, char *name) { - int4byte paddedLength; + int32_t paddedLength; if (buf->state == ONE_MSG_ARGS) { OSC_errorMessage = "This packet is not a bundle, so you can't write another address"; @@ -285,7 +285,7 @@ int OSC_writeAddress(OSCbuf *buf, char *name) { /* Close the old message */ PatchMessageSize(buf); } - buf->thisMsgSize = (int4byte *)buf->bufptr; + buf->thisMsgSize = (int32_t *)buf->bufptr; *(buf->thisMsgSize) = 0xbbbbbbbb; buf->bufptr += 4; buf->state = GET_ARGS; @@ -301,7 +301,7 @@ int OSC_writeAddress(OSCbuf *buf, char *name) { int OSC_writeAddressAndTypes(OSCbuf *buf, char *name, char *types) { int result; - int4byte paddedLength; + int32_t paddedLength; if (CheckTypeTag(buf, '\0')) return 9; @@ -343,7 +343,7 @@ static int CheckTypeTag(OSCbuf *buf, char expectedType) { int OSC_writeFloatArg(OSCbuf *buf, float arg) { - int4byte *intp; + ls_pcast32 *pc; //int result; CheckOverflow(buf, 4); @@ -351,8 +351,8 @@ int OSC_writeFloatArg(OSCbuf *buf, float arg) { if (CheckTypeTag(buf, 'f')) return 9; /* Pretend arg is a long int so we can use htonl() */ - intp = ((int4byte *) &arg); - *((int4byte *) buf->bufptr) = htonl(*intp); + pc = (ls_pcast32 *)&arg; + *((int32_t *) buf->bufptr) = htonl((*pc).i); buf->bufptr += 4; @@ -364,16 +364,16 @@ int OSC_writeFloatArg(OSCbuf *buf, float arg) { int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args) { int i; - int4byte *intp; + int32_t *intp; CheckOverflow(buf, 4 * numFloats); /* Pretend args are long ints so we can use htonl() */ - intp = ((int4byte *) args); + intp = ((int32_t *) args); for (i = 0; i < numFloats; i++) { if (CheckTypeTag(buf, 'f')) return 9; - *((int4byte *) buf->bufptr) = htonl(intp[i]); + *((int32_t *) buf->bufptr) = htonl(intp[i]); buf->bufptr += 4; } @@ -381,11 +381,11 @@ int OSC_writeFloatArgs(OSCbuf *buf, int numFloats, float *args) { return 0; } -int OSC_writeIntArg(OSCbuf *buf, int4byte arg) { +int OSC_writeIntArg(OSCbuf *buf, int32_t arg) { CheckOverflow(buf, 4); if (CheckTypeTag(buf, 'i')) return 9; - *((int4byte *) buf->bufptr) = htonl(arg); + *((int32_t *) buf->bufptr) = htonl(arg); buf->bufptr += 4; buf->gettingFirstUntypedArg = 0; -- cgit v1.2.1