mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-17 03:02:04 +00:00
New NSByteOrder from Frith-MacDonald.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2769 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
90311682e7
commit
fadaa99d50
6 changed files with 655 additions and 257 deletions
12
ChangeLog
12
ChangeLog
|
@ -2,6 +2,18 @@ Wed Mar 4 17:11:23 1998 Adam Fedor <fedor@doc.com>
|
||||||
|
|
||||||
* Version: Version 0.5.0;
|
* Version: Version 0.5.0;
|
||||||
|
|
||||||
|
Thu Mar 5 15:40:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* src/GNUmakefile: removed byte_order.h and added NSByteOrder.h
|
||||||
|
|
||||||
|
* src/NSData.m: Changed all byte-ordering code to use new byte order
|
||||||
|
functions described in the Rhapsody documentation.
|
||||||
|
|
||||||
|
* src/NSSerializer.m: Removed unused include file.
|
||||||
|
|
||||||
|
* src/include/NSByteOrder.h: Added this file containing all the
|
||||||
|
byte-order management functions described in the Rhapsody docs.
|
||||||
|
|
||||||
Wed Mar 4 21:06:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Wed Mar 4 21:06:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* src/NSConnection.m: Changed some objects to be OpenStep rather than
|
* src/NSConnection.m: Changed some objects to be OpenStep rather than
|
||||||
|
|
619
Headers/gnustep/base/NSByteOrder.h
Normal file
619
Headers/gnustep/base/NSByteOrder.h
Normal file
|
@ -0,0 +1,619 @@
|
||||||
|
/* NSByteOrder functions for GNUStep
|
||||||
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
Date: 1998
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __NSByteOrder_h_GNUSTEP_BASE_INCLUDE
|
||||||
|
#define __NSByteOrder_h_GNUSTEP_BASE_INCLUDE
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OPENSTEP type definitions for Byte ordering.
|
||||||
|
*/
|
||||||
|
typedef unsigned long NSSwappedFloat;
|
||||||
|
typedef unsigned long long NSSwappedDouble;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NSLittleEndian,
|
||||||
|
NSBigEndian
|
||||||
|
} NSByteOrder;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function prototypes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 6) && !defined(__attribute__)
|
||||||
|
# define __attribute__(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSConvertHostDoubleToSwapped(double num) __attribute__((unused));
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSConvertHostFloatToSwapped(float num) __attribute__((unused));
|
||||||
|
static inline double
|
||||||
|
NSConvertSwappedDoubleToHost(NSSwappedDouble num) __attribute__((unused));
|
||||||
|
static inline float
|
||||||
|
NSConvertSwappedFloatToHost(NSSwappedFloat num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapInt(unsigned int in) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapLongLong(unsigned long long in) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapLong(unsigned long in) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapShort(unsigned short in) __attribute__((unused));
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapDouble(NSSwappedDouble num) __attribute__((unused));
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapFloat(NSSwappedFloat num) __attribute__((unused));
|
||||||
|
static inline NSByteOrder
|
||||||
|
NSHostByteOrder(void) __attribute__((unused));
|
||||||
|
static inline double
|
||||||
|
NSSwapBigDoubleToHost(NSSwappedDouble num) __attribute__((unused));
|
||||||
|
static inline float
|
||||||
|
NSSwapBigFloatToHost(NSSwappedFloat num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapBigIntToHost(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapBigLongLongToHost(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapBigLongToHost(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapBigShortToHost(unsigned short num) __attribute__((unused));
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToBig(double num) __attribute__((unused));
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToBig(float num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToBig(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToBig(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToBig(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToBig(unsigned short num) __attribute__((unused));
|
||||||
|
static inline double
|
||||||
|
NSSwapLittleDoubleToHost(NSSwappedDouble num) __attribute__((unused));
|
||||||
|
static inline float
|
||||||
|
NSSwapLittleFloatToHost(NSSwappedFloat num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapLittleIntToHost(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapLittleLongLongToHost(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapLittleLongToHost(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapLittleShortToHost(unsigned short num) __attribute__((unused));
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToLittle(double num) __attribute__((unused));
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToLittle(float num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToLittle(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToLittle(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToLittle(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToLittle(unsigned short num) __attribute__((unused));
|
||||||
|
static inline NSByteOrder
|
||||||
|
NSHostByteOrder(void) __attribute__((unused));
|
||||||
|
static inline double
|
||||||
|
NSSwapBigDoubleToHost(NSSwappedDouble num) __attribute__((unused));
|
||||||
|
static inline float
|
||||||
|
NSSwapBigFloatToHost(NSSwappedFloat num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapBigIntToHost(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapBigLongLongToHost(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapBigLongToHost(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapBigShortToHost(unsigned short num) __attribute__((unused));
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToBig(double num) __attribute__((unused));
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToBig(float num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToBig(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToBig(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToBig(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToBig(unsigned short num) __attribute__((unused));
|
||||||
|
static inline double
|
||||||
|
NSSwapLittleDoubleToHost(NSSwappedDouble num) __attribute__((unused));
|
||||||
|
static inline float
|
||||||
|
NSSwapLittleFloatToHost(NSSwappedFloat num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapLittleIntToHost(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapLittleLongLongToHost(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapLittleLongToHost(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapLittleShortToHost(unsigned short num) __attribute__((unused));
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToLittle(double num) __attribute__((unused));
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToLittle(float num) __attribute__((unused));
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToLittle(unsigned int num) __attribute__((unused));
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToLittle(unsigned long long num) __attribute__((unused));
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToLittle(unsigned long num) __attribute__((unused));
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToLittle(unsigned short num) __attribute__((unused));
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Basic byte swapping routines and type conversions
|
||||||
|
*/
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSConvertHostDoubleToSwapped(double num)
|
||||||
|
{
|
||||||
|
union dconv {
|
||||||
|
double number;
|
||||||
|
NSSwappedDouble sd;
|
||||||
|
};
|
||||||
|
return ((union dconv *)&num)->sd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSConvertHostFloatToSwapped(float num)
|
||||||
|
{
|
||||||
|
union fconv {
|
||||||
|
float number;
|
||||||
|
NSSwappedFloat sf;
|
||||||
|
};
|
||||||
|
return ((union fconv *)&num)->sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double
|
||||||
|
NSConvertSwappedDoubleToHost(NSSwappedDouble num)
|
||||||
|
{
|
||||||
|
union dconv {
|
||||||
|
double number;
|
||||||
|
NSSwappedDouble sd;
|
||||||
|
};
|
||||||
|
return ((union dconv *)&num)->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float
|
||||||
|
NSConvertSwappedFloatToHost(NSSwappedFloat num)
|
||||||
|
{
|
||||||
|
union fconv {
|
||||||
|
float number;
|
||||||
|
NSSwappedFloat sf;
|
||||||
|
};
|
||||||
|
return ((union fconv *)&num)->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapInt(unsigned int in)
|
||||||
|
{
|
||||||
|
union swap {
|
||||||
|
unsigned int num;
|
||||||
|
unsigned char byt[4];
|
||||||
|
} dst;
|
||||||
|
union swap *src = (union swap*)∈
|
||||||
|
dst.byt[0] = src->byt[3];
|
||||||
|
dst.byt[1] = src->byt[2];
|
||||||
|
dst.byt[2] = src->byt[1];
|
||||||
|
dst.byt[3] = src->byt[0];
|
||||||
|
return dst.num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapLongLong(unsigned long long in)
|
||||||
|
{
|
||||||
|
union swap {
|
||||||
|
unsigned long num;
|
||||||
|
unsigned char byt[8];
|
||||||
|
} dst;
|
||||||
|
union swap *src = (union swap*)∈
|
||||||
|
dst.byt[0] = src->byt[7];
|
||||||
|
dst.byt[1] = src->byt[6];
|
||||||
|
dst.byt[2] = src->byt[5];
|
||||||
|
dst.byt[3] = src->byt[4];
|
||||||
|
dst.byt[4] = src->byt[3];
|
||||||
|
dst.byt[5] = src->byt[2];
|
||||||
|
dst.byt[6] = src->byt[1];
|
||||||
|
dst.byt[7] = src->byt[0];
|
||||||
|
return dst.num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapLong(unsigned long in)
|
||||||
|
{
|
||||||
|
union swap {
|
||||||
|
unsigned long num;
|
||||||
|
unsigned char byt[4];
|
||||||
|
} dst;
|
||||||
|
union swap *src = (union swap*)∈
|
||||||
|
dst.byt[0] = src->byt[3];
|
||||||
|
dst.byt[1] = src->byt[2];
|
||||||
|
dst.byt[2] = src->byt[1];
|
||||||
|
dst.byt[3] = src->byt[0];
|
||||||
|
return dst.num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapShort(unsigned short in)
|
||||||
|
{
|
||||||
|
union swap {
|
||||||
|
unsigned short num;
|
||||||
|
unsigned char byt[2];
|
||||||
|
} dst;
|
||||||
|
union swap *src = (union swap*)∈
|
||||||
|
dst.byt[0] = src->byt[1];
|
||||||
|
dst.byt[1] = src->byt[0];
|
||||||
|
return dst.num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapDouble(NSSwappedDouble num)
|
||||||
|
{
|
||||||
|
return NSSwapLongLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapFloat(NSSwappedFloat num)
|
||||||
|
{
|
||||||
|
return NSSwapLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
static inline NSByteOrder
|
||||||
|
NSHostByteOrder(void)
|
||||||
|
{
|
||||||
|
return NSBigEndian;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Big endian to host
|
||||||
|
*/
|
||||||
|
static inline double
|
||||||
|
NSSwapBigDoubleToHost(NSSwappedDouble num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedDoubleToHost(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float
|
||||||
|
NSSwapBigFloatToHost(NSSwappedFloat num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedFloatToHost(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapBigIntToHost(unsigned int num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapBigLongLongToHost(unsigned long long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapBigLongToHost(unsigned long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapBigShortToHost(unsigned short num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Host to Big endian
|
||||||
|
*/
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToBig(double num)
|
||||||
|
{
|
||||||
|
return NSConvertHostDoubleToSwapped(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToBig(float num)
|
||||||
|
{
|
||||||
|
return NSConvertHostFloatToSwapped(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToBig(unsigned int num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToBig(unsigned long long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToBig(unsigned long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToBig(unsigned short num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Little endian to Host
|
||||||
|
*/
|
||||||
|
static inline double
|
||||||
|
NSSwapLittleDoubleToHost(NSSwappedDouble num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedDoubleToHost(NSSwapDouble(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float
|
||||||
|
NSSwapLittleFloatToHost(NSSwappedFloat num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedFloatToHost(NSSwapFloat(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapLittleIntToHost(unsigned int num)
|
||||||
|
{
|
||||||
|
return NSSwapInt(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapLittleLongLongToHost(unsigned long long num)
|
||||||
|
{
|
||||||
|
return NSSwapLongLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapLittleLongToHost(unsigned long num)
|
||||||
|
{
|
||||||
|
return NSSwapLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapLittleShortToHost(unsigned short num)
|
||||||
|
{
|
||||||
|
return NSSwapShort(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Host to Little endian
|
||||||
|
*/
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToLittle(double num)
|
||||||
|
{
|
||||||
|
return NSSwapDouble(NSConvertHostDoubleToSwapped(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToLittle(float num)
|
||||||
|
{
|
||||||
|
return NSSwapFloat(NSConvertHostFloatToSwapped(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToLittle(unsigned int num)
|
||||||
|
{
|
||||||
|
return NSSwapInt(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToLittle(unsigned long long num)
|
||||||
|
{
|
||||||
|
return NSSwapLongLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToLittle(unsigned long num)
|
||||||
|
{
|
||||||
|
return NSSwapLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToLittle(unsigned short num)
|
||||||
|
{
|
||||||
|
return NSSwapShort(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static inline NSByteOrder
|
||||||
|
NSHostByteOrder(void)
|
||||||
|
{
|
||||||
|
return NSLittleEndian;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Big endian to host
|
||||||
|
*/
|
||||||
|
static inline double
|
||||||
|
NSSwapBigDoubleToHost(NSSwappedDouble num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedDoubleToHost(NSSwapDouble(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float
|
||||||
|
NSSwapBigFloatToHost(NSSwappedFloat num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedFloatToHost(NSSwapFloat(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapBigIntToHost(unsigned int num)
|
||||||
|
{
|
||||||
|
return NSSwapInt(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapBigLongLongToHost(unsigned long long num)
|
||||||
|
{
|
||||||
|
return NSSwapLongLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapBigLongToHost(unsigned long num)
|
||||||
|
{
|
||||||
|
return NSSwapLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapBigShortToHost(unsigned short num)
|
||||||
|
{
|
||||||
|
return NSSwapShort(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Host to Big endian
|
||||||
|
*/
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToBig(double num)
|
||||||
|
{
|
||||||
|
return NSSwapDouble(NSConvertHostDoubleToSwapped(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToBig(float num)
|
||||||
|
{
|
||||||
|
return NSSwapFloat(NSConvertHostFloatToSwapped(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToBig(unsigned int num)
|
||||||
|
{
|
||||||
|
return NSSwapInt(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToBig(unsigned long long num)
|
||||||
|
{
|
||||||
|
return NSSwapLongLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToBig(unsigned long num)
|
||||||
|
{
|
||||||
|
return NSSwapLong(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToBig(unsigned short num)
|
||||||
|
{
|
||||||
|
return NSSwapShort(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Little endian to Host
|
||||||
|
*/
|
||||||
|
static inline double
|
||||||
|
NSSwapLittleDoubleToHost(NSSwappedDouble num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedDoubleToHost(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float
|
||||||
|
NSSwapLittleFloatToHost(NSSwappedFloat num)
|
||||||
|
{
|
||||||
|
return NSConvertSwappedFloatToHost(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapLittleIntToHost(unsigned int num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapLittleLongLongToHost(unsigned long long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapLittleLongToHost(unsigned long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapLittleShortToHost(unsigned short num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swap Host to Little endian
|
||||||
|
*/
|
||||||
|
static inline NSSwappedDouble
|
||||||
|
NSSwapHostDoubleToLittle(double num)
|
||||||
|
{
|
||||||
|
return NSConvertHostDoubleToSwapped(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline NSSwappedFloat
|
||||||
|
NSSwapHostFloatToLittle(float num)
|
||||||
|
{
|
||||||
|
return NSConvertHostFloatToSwapped(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
NSSwapHostIntToLittle(unsigned int num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long
|
||||||
|
NSSwapHostLongLongToLittle(unsigned long long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long
|
||||||
|
NSSwapHostLongToLittle(unsigned long num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned short
|
||||||
|
NSSwapHostShortToLittle(unsigned short num)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __NSByteOrder_h_GNUSTEP_BASE_INCLUDE */
|
|
@ -1,232 +0,0 @@
|
||||||
/*
|
|
||||||
byte_order.h
|
|
||||||
|
|
||||||
Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
|
|
||||||
|
|
||||||
This file is part of libFoundation.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software and its
|
|
||||||
documentation for any purpose and without fee is hereby granted, provided
|
|
||||||
that the above copyright notice appear in all copies and that both that
|
|
||||||
copyright notice and this permission notice appear in supporting
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
We disclaim all warranties with regard to this software, including all
|
|
||||||
implied warranties of merchantability and fitness, in no event shall
|
|
||||||
we be liable for any special, indirect or consequential damages or any
|
|
||||||
damages whatsoever resulting from loss of use, data or profits, whether in
|
|
||||||
an action of contract, negligence or other tortious action, arising out of
|
|
||||||
or in connection with the use or performance of this software.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Conversion routines for doubles and floats in and from the network floating
|
|
||||||
format. Assumes the target machine has the IEEE floating point format.
|
|
||||||
|
|
||||||
This file was inspired from architecture/byte_order.h by David E. Bohman
|
|
||||||
from NeXT.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __byte_order_h__
|
|
||||||
#define __byte_order_h__
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#if HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_WINDOWS_H
|
|
||||||
# include <windows.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_WINDOWS32_SOCKETS_H
|
|
||||||
# include <Windows32/Sockets.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* BUGS: Assumes the endianism of target machine is either big or little
|
|
||||||
endian, format of floating point is IEEE and
|
|
||||||
sizeof (long) == 4
|
|
||||||
sizeof (long long) == 8
|
|
||||||
sizeof (long) == sizeof (float)
|
|
||||||
sizeof (long long) == sizeof (double)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 6) && !defined(__attribute__)
|
|
||||||
# define __attribute__(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned long network_float;
|
|
||||||
typedef unsigned long long network_double;
|
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes */
|
|
||||||
|
|
||||||
static inline unsigned short
|
|
||||||
network_short_to_host (unsigned short x) __attribute__((unused));
|
|
||||||
static inline unsigned short
|
|
||||||
host_short_to_network (unsigned short x) __attribute__((unused));
|
|
||||||
static inline unsigned int
|
|
||||||
network_int_to_host (unsigned int x) __attribute__((unused));
|
|
||||||
static inline unsigned int
|
|
||||||
host_int_to_network (unsigned int x) __attribute__((unused));
|
|
||||||
static inline unsigned long
|
|
||||||
network_long_to_host (unsigned long x) __attribute__((unused));
|
|
||||||
static inline unsigned long
|
|
||||||
host_long_to_network (unsigned long x) __attribute__((unused));
|
|
||||||
static inline unsigned long long
|
|
||||||
network_long_long_to_host (unsigned long long x) __attribute__((unused));
|
|
||||||
static inline unsigned long long
|
|
||||||
host_long_long_to_network (unsigned long long x) __attribute__((unused));
|
|
||||||
static inline float
|
|
||||||
network_float_to_host (network_float x) __attribute__((unused));
|
|
||||||
static inline network_float
|
|
||||||
host_float_to_network (float x) __attribute__((unused));
|
|
||||||
static inline double
|
|
||||||
network_double_to_host (network_double x) __attribute__((unused));
|
|
||||||
static inline network_double
|
|
||||||
host_double_to_network (double x) __attribute__((unused));
|
|
||||||
|
|
||||||
|
|
||||||
/* Public entries */
|
|
||||||
|
|
||||||
static inline unsigned short
|
|
||||||
network_short_to_host (unsigned short x)
|
|
||||||
{
|
|
||||||
return ntohs (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned short
|
|
||||||
host_short_to_network (unsigned short x)
|
|
||||||
{
|
|
||||||
return htons (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned int
|
|
||||||
network_int_to_host (unsigned int x)
|
|
||||||
{
|
|
||||||
return ntohl (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned int
|
|
||||||
host_int_to_network (unsigned int x)
|
|
||||||
{
|
|
||||||
return htonl (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long
|
|
||||||
network_long_to_host (unsigned long x)
|
|
||||||
{
|
|
||||||
return ntohl (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long
|
|
||||||
host_long_to_network (unsigned long x)
|
|
||||||
{
|
|
||||||
return htonl (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if WORDS_BIGENDIAN
|
|
||||||
static inline unsigned long long
|
|
||||||
network_long_long_to_host (unsigned long long x)
|
|
||||||
{
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long long
|
|
||||||
host_long_long_to_network (unsigned long long x)
|
|
||||||
{
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* !WORDS_BIGENDIAN */
|
|
||||||
|
|
||||||
static inline unsigned long
|
|
||||||
swap_long (unsigned long x)
|
|
||||||
{
|
|
||||||
union lconv {
|
|
||||||
unsigned long ul;
|
|
||||||
unsigned char uc[4];
|
|
||||||
} *inp, outx;
|
|
||||||
|
|
||||||
inp = (union lconv*)&x;
|
|
||||||
outx.uc[0] = inp->uc[3];
|
|
||||||
outx.uc[1] = inp->uc[2];
|
|
||||||
outx.uc[2] = inp->uc[1];
|
|
||||||
outx.uc[3] = inp->uc[0];
|
|
||||||
return outx.ul;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long long
|
|
||||||
swap_long_long (unsigned long long x)
|
|
||||||
{
|
|
||||||
union dconv {
|
|
||||||
unsigned long ul[2];
|
|
||||||
network_double ull;
|
|
||||||
} *inp, outx;
|
|
||||||
|
|
||||||
inp = (union dconv*)&x;
|
|
||||||
outx.ul[0] = swap_long (inp->ul[1]);
|
|
||||||
outx.ul[1] = swap_long (inp->ul[0]);
|
|
||||||
return outx.ull;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long long
|
|
||||||
network_long_long_to_host (unsigned long long x)
|
|
||||||
{
|
|
||||||
return swap_long_long (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned long long
|
|
||||||
host_long_long_to_network (unsigned long long x)
|
|
||||||
{
|
|
||||||
return swap_long_long (x);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !WORDS_BIGENDIAN */
|
|
||||||
|
|
||||||
static inline float
|
|
||||||
network_float_to_host (network_float x)
|
|
||||||
{
|
|
||||||
union fconv {
|
|
||||||
float number;
|
|
||||||
unsigned long ul;
|
|
||||||
};
|
|
||||||
unsigned long fx = network_long_to_host (x);
|
|
||||||
|
|
||||||
return ((union fconv*)&fx)->number;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline network_float
|
|
||||||
host_float_to_network (float x)
|
|
||||||
{
|
|
||||||
union fconv {
|
|
||||||
float number;
|
|
||||||
unsigned long ul;
|
|
||||||
};
|
|
||||||
return host_long_to_network (((union fconv*)&x)->ul);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double
|
|
||||||
network_double_to_host (network_double x)
|
|
||||||
{
|
|
||||||
union dconv {
|
|
||||||
double number;
|
|
||||||
unsigned long long ull;
|
|
||||||
};
|
|
||||||
unsigned long long dx = network_long_long_to_host (x);
|
|
||||||
|
|
||||||
return ((union dconv*)&dx)->number;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline network_double
|
|
||||||
host_double_to_network (double x)
|
|
||||||
{
|
|
||||||
union dconv {
|
|
||||||
double number;
|
|
||||||
unsigned long long ull;
|
|
||||||
};
|
|
||||||
return host_long_long_to_network (((union dconv*)&x)->ull);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __byte_order_h__ */
|
|
|
@ -389,7 +389,6 @@ tzfile.h
|
||||||
|
|
||||||
BASE_HEADERS = \
|
BASE_HEADERS = \
|
||||||
Foundation/Foundation.h \
|
Foundation/Foundation.h \
|
||||||
Foundation/byte_order.h \
|
|
||||||
Foundation/DistributedObjects.h \
|
Foundation/DistributedObjects.h \
|
||||||
Foundation/NSArchiver.h \
|
Foundation/NSArchiver.h \
|
||||||
Foundation/NSArray.h \
|
Foundation/NSArray.h \
|
||||||
|
@ -397,6 +396,7 @@ Foundation/NSAttributedString.h \
|
||||||
Foundation/NSAutoreleasePool.h \
|
Foundation/NSAutoreleasePool.h \
|
||||||
Foundation/NSBitmapCharSet.h \
|
Foundation/NSBitmapCharSet.h \
|
||||||
Foundation/NSBundle.h \
|
Foundation/NSBundle.h \
|
||||||
|
Foundation/NSByteOrder.h \
|
||||||
Foundation/NSCharacterSet.h \
|
Foundation/NSCharacterSet.h \
|
||||||
Foundation/NSCoder.h \
|
Foundation/NSCoder.h \
|
||||||
Foundation/NSConcreteNumber.h \
|
Foundation/NSConcreteNumber.h \
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
#include <objc/objc-api.h>
|
#include <objc/objc-api.h>
|
||||||
#include <gnustep/base/preface.h>
|
#include <gnustep/base/preface.h>
|
||||||
#include <gnustep/base/MallocAddress.h>
|
#include <gnustep/base/MallocAddress.h>
|
||||||
#include <Foundation/byte_order.h>
|
#include <Foundation/NSByteOrder.h>
|
||||||
#include <Foundation/NSCoder.h>
|
#include <Foundation/NSCoder.h>
|
||||||
#include <Foundation/NSData.h>
|
#include <Foundation/NSData.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
@ -646,7 +646,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
[self deserializeBytes:&ns
|
[self deserializeBytes:&ns
|
||||||
length:sizeof(unsigned short)
|
length:sizeof(unsigned short)
|
||||||
atCursor:cursor];
|
atCursor:cursor];
|
||||||
*(unsigned short*)data = network_short_to_host (ns);
|
*(unsigned short*)data = NSSwapBigShortToHost (ns);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_INT:
|
case _C_INT:
|
||||||
|
@ -656,7 +656,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
[self deserializeBytes:&ni
|
[self deserializeBytes:&ni
|
||||||
length:sizeof(unsigned int)
|
length:sizeof(unsigned int)
|
||||||
atCursor:cursor];
|
atCursor:cursor];
|
||||||
*(unsigned int*)data = network_int_to_host (ni);
|
*(unsigned int*)data = NSSwapBigIntToHost (ni);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_LNG:
|
case _C_LNG:
|
||||||
|
@ -666,25 +666,25 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
[self deserializeBytes:&nl
|
[self deserializeBytes:&nl
|
||||||
length:sizeof(unsigned long)
|
length:sizeof(unsigned long)
|
||||||
atCursor:cursor];
|
atCursor:cursor];
|
||||||
*(unsigned long*)data = network_long_to_host (nl);
|
*(unsigned long*)data = NSSwapBigLongToHost (nl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_FLT: {
|
case _C_FLT: {
|
||||||
network_float nf;
|
NSSwappedFloat nf;
|
||||||
|
|
||||||
[self deserializeBytes:&nf
|
[self deserializeBytes:&nf
|
||||||
length:sizeof(float)
|
length:sizeof(NSSwappedFloat)
|
||||||
atCursor:cursor];
|
atCursor:cursor];
|
||||||
*(float*)data = network_float_to_host (nf);
|
*(float*)data = NSSwapBigFloatToHost (nf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_DBL: {
|
case _C_DBL: {
|
||||||
network_double nd;
|
NSSwappedDouble nd;
|
||||||
|
|
||||||
[self deserializeBytes:&nd
|
[self deserializeBytes:&nd
|
||||||
length:sizeof(double)
|
length:sizeof(NSSwappedDouble)
|
||||||
atCursor:cursor];
|
atCursor:cursor];
|
||||||
*(double*)data = network_double_to_host (nd);
|
*(double*)data = NSSwapBigDoubleToHost (nd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -698,7 +698,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
unsigned int ni, result;
|
unsigned int ni, result;
|
||||||
|
|
||||||
[self deserializeBytes:&ni length:sizeof(unsigned int) atCursor:cursor];
|
[self deserializeBytes:&ni length:sizeof(unsigned int) atCursor:cursor];
|
||||||
result = network_int_to_host (ni);
|
result = NSSwapBigIntToHost (ni);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,7 +707,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
unsigned int ni, result;
|
unsigned int ni, result;
|
||||||
|
|
||||||
[self deserializeBytes:&ni length:sizeof(unsigned int) atCursor:&index];
|
[self deserializeBytes:&ni length:sizeof(unsigned int) atCursor:&index];
|
||||||
result = network_int_to_host (ni);
|
result = NSSwapBigIntToHost (ni);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,7 +721,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
length:numInts * sizeof(unsigned int)
|
length:numInts * sizeof(unsigned int)
|
||||||
atCursor:cursor];
|
atCursor:cursor];
|
||||||
for (i = 0; i < numInts; i++)
|
for (i = 0; i < numInts; i++)
|
||||||
intBuffer[i] = network_int_to_host (intBuffer[i]);
|
intBuffer[i] = NSSwapBigIntToHost (intBuffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deserializeInts:(int*)intBuffer
|
- (void)deserializeInts:(int*)intBuffer
|
||||||
|
@ -734,7 +734,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
length:numInts * sizeof(int)
|
length:numInts * sizeof(int)
|
||||||
atCursor:&index];
|
atCursor:&index];
|
||||||
for (i = 0; i < numInts; i++)
|
for (i = 0; i < numInts; i++)
|
||||||
intBuffer[i] = network_int_to_host (intBuffer[i]);
|
intBuffer[i] = NSSwapBigIntToHost (intBuffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copy
|
- (id) copy
|
||||||
|
@ -1046,30 +1046,30 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
break;
|
break;
|
||||||
case _C_SHT:
|
case _C_SHT:
|
||||||
case _C_USHT: {
|
case _C_USHT: {
|
||||||
unsigned short ns = host_short_to_network (*(unsigned short*)data);
|
unsigned short ns = NSSwapHostShortToBig (*(unsigned short*)data);
|
||||||
[self appendBytes:&ns length:sizeof(unsigned short)];
|
[self appendBytes:&ns length:sizeof(unsigned short)];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_INT:
|
case _C_INT:
|
||||||
case _C_UINT: {
|
case _C_UINT: {
|
||||||
unsigned int ni = host_int_to_network (*(unsigned int*)data);
|
unsigned int ni = NSSwapHostIntToBig (*(unsigned int*)data);
|
||||||
[self appendBytes:&ni length:sizeof(unsigned int)];
|
[self appendBytes:&ni length:sizeof(unsigned int)];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_LNG:
|
case _C_LNG:
|
||||||
case _C_ULNG: {
|
case _C_ULNG: {
|
||||||
unsigned long nl = host_long_to_network (*(unsigned long*)data);
|
unsigned long nl = NSSwapHostLongToBig (*(unsigned long*)data);
|
||||||
[self appendBytes:&nl length:sizeof(unsigned long)];
|
[self appendBytes:&nl length:sizeof(unsigned long)];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_FLT: {
|
case _C_FLT: {
|
||||||
network_float nf = host_float_to_network (*(float*)data);
|
NSSwappedFloat nf = NSSwapHostFloatToBig (*(float*)data);
|
||||||
[self appendBytes:&nf length:sizeof(float)];
|
[self appendBytes:&nf length:sizeof(NSSwappedFloat)];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _C_DBL: {
|
case _C_DBL: {
|
||||||
network_double nd = host_double_to_network (*(double*)data);
|
NSSwappedDouble nd = NSSwapHostDoubleToBig (*(double*)data);
|
||||||
[self appendBytes:&nd length:sizeof(double)];
|
[self appendBytes:&nd length:sizeof(NSSwappedDouble)];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1080,13 +1080,13 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
|
|
||||||
- (void)serializeInt:(int)value
|
- (void)serializeInt:(int)value
|
||||||
{
|
{
|
||||||
unsigned int ni = host_int_to_network (value);
|
unsigned int ni = NSSwapHostIntToBig (value);
|
||||||
[self appendBytes:&ni length:sizeof(unsigned int)];
|
[self appendBytes:&ni length:sizeof(unsigned int)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)serializeInt:(int)value atIndex:(unsigned int)index
|
- (void)serializeInt:(int)value atIndex:(unsigned int)index
|
||||||
{
|
{
|
||||||
unsigned int ni = host_int_to_network (value);
|
unsigned int ni = NSSwapHostIntToBig (value);
|
||||||
NSRange range = { index, sizeof(int) };
|
NSRange range = { index, sizeof(int) };
|
||||||
[self replaceBytesInRange:range withBytes:&ni];
|
[self replaceBytesInRange:range withBytes:&ni];
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gnustep/base/preface.h>
|
#include <gnustep/base/preface.h>
|
||||||
#include <Foundation/byte_order.h>
|
|
||||||
#include <Foundation/NSData.h>
|
#include <Foundation/NSData.h>
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
|
|
Loading…
Reference in a new issue