[Mac] Replace obsolete POSIX functions

bcopy() and bzero() were obsoleted in POSIX 1.2001 and removed in
POSIX 1.2008.

Also set _POSIX_C_SOURCE=200809L macro so we don't accidentally
use them again.
master
Jens Ayton 2013-11-05 13:29:03 +01:00
parent a9e919c18c
commit cd091fb247
7 changed files with 25 additions and 27 deletions

View File

@ -4766,6 +4766,8 @@
"DEBUG=1",
$OOLITE_OPTION_MACROS,
"OO_CHECK_GL_HEAVY=1",
"_DARWIN_C_SOURCE=200809L",
"_POSIX_C_SOURCE=200809L",
);
GCC_REUSE_STRINGS = YES;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;

View File

@ -116,8 +116,8 @@ SOFTWARE.
underflow = 0;
}
bcopy(_bufferL + offset, ioData->mBuffers[0].mData, toCopy * sizeof (float));
bcopy(_bufferR + offset, ioData->mBuffers[1].mData, toCopy * sizeof (float));
memcpy(ioData->mBuffers[0].mData, _bufferL + offset, toCopy * sizeof (float));
memcpy(ioData->mBuffers[1].mData, _bufferR + offset, toCopy * sizeof (float));
if (underflow && loop)
{
@ -125,8 +125,8 @@ SOFTWARE.
toCopy = inNumFrames - toCopy;
if (_size < toCopy) toCopy = _size;
bcopy(_bufferL, ((float *)ioData->mBuffers[0].mData) + offset, toCopy * sizeof (float));
bcopy(_bufferR, ((float *)ioData->mBuffers[1].mData) + offset, toCopy * sizeof (float));
memcpy(((float *)ioData->mBuffers[0].mData) + offset, _bufferL, toCopy * sizeof (float));
memcpy(((float *)ioData->mBuffers[1].mData) + offset, _bufferR, toCopy * sizeof (float));
underflow -= toCopy;
offset = 0;
@ -144,8 +144,8 @@ SOFTWARE.
if (underflow)
{
bzero(ioData->mBuffers[0].mData + toCopy, underflow * sizeof (float));
bzero(ioData->mBuffers[1].mData + toCopy, underflow * sizeof (float));
memset(ioData->mBuffers[0].mData + toCopy, 0, underflow * sizeof (float));
memset(ioData->mBuffers[1].mData + toCopy, 0, underflow * sizeof (float));
}
OOCASoundVerifyBuffers(ioData, inNumFrames, self);

View File

@ -608,7 +608,7 @@ static BOOL PortWait(mach_port_t inPort, PortMessage *outMessage);
for (i = 0; i != count; i++)
{
bzero(ioData->mBuffers[i].mData, ioData->mBuffers[i].mDataByteSize);
memset(ioData->mBuffers[i].mData, 0, ioData->mBuffers[i].mDataByteSize);
}
*ioFlags |= kAudioUnitRenderAction_OutputIsSilence;
}
@ -685,7 +685,7 @@ static void PortSend(mach_port_t inPort, PortMessage inMessage)
PortSendMsgBody message;
mach_msg_return_t result;
bzero(&message, sizeof message);
memset(&message, 0, sizeof message);
message.header.msgh_bits = MACH_MSGH_BITS_REMOTE(MACH_MSG_TYPE_MAKE_SEND);
message.header.msgh_size = sizeof message;
@ -714,7 +714,7 @@ static BOOL PortWait(mach_port_t inPort, PortMessage *outMessage)
PortWaitMsgBody message;
mach_msg_return_t result;
bzero(&message, sizeof message);
memset(&message, 0, sizeof message);
message.header.msgh_bits = MACH_MSGH_BITS_LOCAL(MACH_MSG_TYPE_COPY_RECEIVE);
message.header.msgh_size = sizeof message;

View File

@ -278,7 +278,7 @@ static void MixDown(float *inChan1, float *inChan2, float *outMix, size_t inCoun
break;
}
if (1 == chanCount) bcopy(src[0], dst, sizeof (float) * framesRead);
if (1 == chanCount) memcpy(dst, src[0], sizeof (float) * framesRead);
else MixDown(src[0], src[1], dst, framesRead);
remaining -= framesRead;
@ -352,9 +352,9 @@ static void MixDown(float *inChan1, float *inChan2, float *outMix, size_t inCoun
break;
}
bcopy(src[0], dstL, sizeof (float) * framesRead);
if (1 == chanCount) bcopy(src[0], dstR, sizeof (float) * framesRead);
else bcopy(src[1], dstR, sizeof (float) * framesRead);
unsigned rightChan = (chanCount == 1) ? 0 : 1;
memcpy(dstL, src[0], sizeof (float) * framesRead);
memcpy(dstR, src[rightChan], sizeof (float) * framesRead);
remaining -= framesRead;
dstL += framesRead;
@ -386,7 +386,6 @@ static void MixDown(float *inChan1, float *inChan2, float *outMix, size_t inCoun
long framesRead;
size_t size;
int remaining;
unsigned rightChan;
// Note: for our purposes, a frame is a set of one sample for each channel.
if (NULL == ioBufferL || NULL == ioBufferR || 0 == inMax) return 0;
@ -407,9 +406,9 @@ static void MixDown(float *inChan1, float *inChan2, float *outMix, size_t inCoun
size = sizeof (float) * framesRead;
rightChan = (1 == chanCount) ? 0 : 1;
bcopy(src[0], ioBufferL, size);
bcopy(src[rightChan], ioBufferR, size);
unsigned rightChan = (chanCount == 1) ? 0 : 1;
memcpy(ioBufferL, src[0], size);
memcpy(ioBufferR, src[rightChan], size);
remaining -= framesRead;
ioBufferL += framesRead;

View File

@ -344,8 +344,8 @@ enum
remaining = available;
if (numBytes < available) available = numBytes;
bcopy(ptrL, ioData->mBuffers[0].mData, available);
bcopy(ptrR, ioData->mBuffers[1].mData, available);
memcpy(ioData->mBuffers[0].mData, ptrL, available);
memcpy(ioData->mBuffers[1].mData, ptrR, available);
VRB_didReadLength(context->bufferL, kSEL_VRB_didReadLength, available);
VRB_didReadLength(context->bufferR, kSEL_VRB_didReadLength, available);
@ -357,8 +357,8 @@ enum
if (0 == available) *ioFlags |= kAudioUnitRenderAction_OutputIsSilence;
bzero(ioData->mBuffers[0].mData + available, underflow);
bzero(ioData->mBuffers[1].mData + available, underflow);
memset(ioData->mBuffers[0].mData + available, 0, underflow);
memset(ioData->mBuffers[1].mData + available, 0, underflow);
}
OOCASoundVerifyBuffers(ioData, inNumFrames, self);

View File

@ -682,19 +682,16 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
- (NSString *) repeatString:(NSString *)str times:(NSUInteger)times
{
if (times == 0) return @"";
NSMutableString *result = [NSMutableString stringWithCapacity:[str length] * times];
uint i;
NSMutableString *result = [NSMutableString stringWithCapacity:[str length] * times];
for (i = 0; i < times; i++)
for (NSUInteger i = 0; i < times; i++)
{
[result appendString:str];
}
return result;
}

View File

@ -514,7 +514,7 @@ static void RemovePreference(NSString *key)
// No AddOns at all. Show the first existing AddOns folder (paths are in order of preference, etc...).
BOOL pathIsDirectory;
NSString *path = nil;
uint i = 1;
NSUInteger i = 1;
while (i < [[ResourceManager rootPaths] count])
{