From bb1ce663a429ac816ca51e4b64358ceb38867bbd Mon Sep 17 00:00:00 2001 From: CaS Date: Wed, 11 Jan 2006 08:37:16 +0000 Subject: [PATCH] Tidy use of sized datatypes. Check for invalid asumption of interchangability of int/long in encoder/decoder methods. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22291 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 24 +++ Headers/Additions/GNUstepBase/GSUnion.h | 16 +- Headers/Foundation/NSByteOrder.h | 186 ++++++++++++------------ Headers/Foundation/NSPort.h | 8 +- Source/GSFileHandle.m | 4 +- Source/GSFormat.m | 2 +- Source/NSCalendarDate.m | 8 + Source/NSData.m | 121 +++++++-------- Source/NSDistantObject.m | 4 +- Source/NSMessagePort.m | 25 ++-- Source/NSPortCoder.m | 20 +-- Source/NSSerializer.m | 9 +- Source/NSSocketPort.m | 39 ++--- Source/NSSocketPortNameServer.m | 24 +-- Source/NSString.m | 8 +- Source/NSTimeZone.m | 26 ++-- Source/NSUnarchiver.m | 25 ++-- Source/win32/GSFileHandleWin32.m | 4 +- Source/win32/NSMessagePortWin32.m | 15 +- 19 files changed, 283 insertions(+), 285 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9b36dbc4..fdfa7c962 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2006-01-11 Richard Frith-Macdonald + + * Headers/Additions/GNUstepBase/GSUnion.h: + * Headers/Foundation/NSByteOrder.h: + * Headers/Foundation/NSPort.h: + * Source/GSFileHandle.m: + * Source/GSFormat.m: + * Source/NSData.m: + * Source/NSDistantObject.m: + * Source/NSMessagePort.m: + * Source/NSPortCoder.m: + * Source/NSSerializer.m: + * Source/NSSocketPort.m: + * Source/NSSocketPortNameServer.m: + * Source/NSString.m: + * Source/NSTimeZone.m: + * Source/NSUnarchiver.m: + * Source/win32/GSFileHandleWin32.m: + * Source/win32/NSMessagePortWin32.m: + Update to use sized datatypes from stdint.h now that almost all + operating systems support it. Changes not complete yet though. + * Source/NSCalendarDate.m: + Support '%T' and '%t' as supplied by unix date/time locale info. + 2006-01-10 Richard Frith-Macdonald * Source/mframe.m: diff --git a/Headers/Additions/GNUstepBase/GSUnion.h b/Headers/Additions/GNUstepBase/GSUnion.h index cf309211e..f32c7d4e0 100644 --- a/Headers/Additions/GNUstepBase/GSUnion.h +++ b/Headers/Additions/GNUstepBase/GSUnion.h @@ -90,20 +90,20 @@ typedef union { const char *cstr; #endif #if ((GSUNION_TYPES) & GSUNION_8B) - gss8 s8; - gsu8 u8; + int8_t s8; + uint8_t u8; #endif #if ((GSUNION_TYPES) & GSUNION_16B) - gss16 s16; - gsu16 u16; + int16_t s16; + uint16_t u16; #endif #if ((GSUNION_TYPES) & GSUNION_32B) - gss32 s32; - gsu32 u32; + int32_t s32; + uint32_t u32; #endif #if ((GSUNION_TYPES) & GSUNION_64B) - gss64 s64; - gsu64 u64; + int64_t s64; + uint64_t u64; #endif #if defined(GSUNION_EXTRA) GSUNION_EXTRA ext; diff --git a/Headers/Foundation/NSByteOrder.h b/Headers/Foundation/NSByteOrder.h index 038cf5442..0a2541de5 100644 --- a/Headers/Foundation/NSByteOrder.h +++ b/Headers/Foundation/NSByteOrder.h @@ -29,8 +29,8 @@ /* * OPENSTEP type definitions for Byte ordering. */ -typedef gsu32 NSSwappedFloat; -typedef gsu64 NSSwappedDouble; +typedef uint32_t NSSwappedFloat; +typedef uint64_t NSSwappedDouble; typedef enum { NS_UnknownByteOrder, @@ -49,48 +49,48 @@ typedef enum { /* * First the GNUstep functions for byte swapping */ -static inline gsu16 -GSSwapI16(gsu16 in) __attribute__((unused)); -static inline gsu32 -GSSwapI32(gsu32 in) __attribute__((unused)); -static inline gsu64 -GSSwapI64(gsu64 in) __attribute__((unused)); +static inline uint16_t +GSSwapI16(uint16_t in) __attribute__((unused)); +static inline uint32_t +GSSwapI32(uint32_t in) __attribute__((unused)); +static inline uint64_t +GSSwapI64(uint64_t in) __attribute__((unused)); static inline gsu128 GSSwapI128(gsu128 in) __attribute__((unused)); -static inline gsu16 -GSSwapBigI16ToHost(gsu16 in) __attribute__((unused)); -static inline gsu32 -GSSwapBigI32ToHost(gsu32 in) __attribute__((unused)); -static inline gsu64 -GSSwapBigI64ToHost(gsu64 in) __attribute__((unused)); +static inline uint16_t +GSSwapBigI16ToHost(uint16_t in) __attribute__((unused)); +static inline uint32_t +GSSwapBigI32ToHost(uint32_t in) __attribute__((unused)); +static inline uint64_t +GSSwapBigI64ToHost(uint64_t in) __attribute__((unused)); static inline gsu128 GSSwapBigI128ToHost(gsu128 in) __attribute__((unused)); -static inline gsu16 -GSSwapHostI16ToBig(gsu16 in) __attribute__((unused)); -static inline gsu32 -GSSwapHostI32ToBig(gsu32 in) __attribute__((unused)); -static inline gsu64 -GSSwapHostI64ToBig(gsu64 in) __attribute__((unused)); +static inline uint16_t +GSSwapHostI16ToBig(uint16_t in) __attribute__((unused)); +static inline uint32_t +GSSwapHostI32ToBig(uint32_t in) __attribute__((unused)); +static inline uint64_t +GSSwapHostI64ToBig(uint64_t in) __attribute__((unused)); static inline gsu128 GSSwapHostI128ToBig(gsu128 in) __attribute__((unused)); -static inline gsu16 -GSSwapLittleI16ToHost(gsu16 in) __attribute__((unused)); -static inline gsu32 -GSSwapLittleI32ToHost(gsu32 in) __attribute__((unused)); -static inline gsu64 -GSSwapLittleI64ToHost(gsu64 in) __attribute__((unused)); +static inline uint16_t +GSSwapLittleI16ToHost(uint16_t in) __attribute__((unused)); +static inline uint32_t +GSSwapLittleI32ToHost(uint32_t in) __attribute__((unused)); +static inline uint64_t +GSSwapLittleI64ToHost(uint64_t in) __attribute__((unused)); static inline gsu128 GSSwapLittleI128ToHost(gsu128 in) __attribute__((unused)); -static inline gsu16 -GSSwapHostI16ToLittle(gsu16 in) __attribute__((unused)); -static inline gsu32 -GSSwapHostI32ToLittle(gsu32 in) __attribute__((unused)); -static inline gsu64 -GSSwapHostI64ToLittle(gsu64 in) __attribute__((unused)); +static inline uint16_t +GSSwapHostI16ToLittle(uint16_t in) __attribute__((unused)); +static inline uint32_t +GSSwapHostI32ToLittle(uint32_t in) __attribute__((unused)); +static inline uint64_t +GSSwapHostI64ToLittle(uint64_t in) __attribute__((unused)); static inline gsu128 GSSwapHostI128ToLittle(gsu128 in) __attribute__((unused)); @@ -101,12 +101,12 @@ GSSwapHostI128ToLittle(gsu128 in) __attribute__((unused)); extern void _gcc3_1_hack(void); #endif -static inline gsu16 -GSSwapI16(gsu16 in) +static inline uint16_t +GSSwapI16(uint16_t in) { union swap { - gsu16 num; - gsu8 byt[2]; + uint16_t num; + uint8_t byt[2]; } dst; union swap *src = (union swap*)∈ #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 1) @@ -117,12 +117,12 @@ GSSwapI16(gsu16 in) return dst.num; } -static inline gsu32 -GSSwapI32(gsu32 in) +static inline uint32_t +GSSwapI32(uint32_t in) { union swap { - gsu32 num; - gsu8 byt[4]; + uint32_t num; + uint8_t byt[4]; } dst; union swap *src = (union swap*)∈ #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 1) @@ -135,12 +135,12 @@ GSSwapI32(gsu32 in) return dst.num; } -static inline gsu64 -GSSwapI64(gsu64 in) +static inline uint64_t +GSSwapI64(uint64_t in) { union swap { - gsu64 num; - gsu8 byt[8]; + uint64_t num; + uint8_t byt[8]; } dst; union swap *src = (union swap*)∈ #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 1) @@ -162,7 +162,7 @@ GSSwapI128(gsu128 in) { union swap { gsu128 num; - gsu8 byt[16]; + uint8_t byt[16]; } dst; union swap *src = (union swap*)∈ #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 1) @@ -399,18 +399,18 @@ NSHostByteOrder(void) /* * Swap Big endian to host */ -static inline gsu16 -GSSwapBigI16ToHost(gsu16 in) +static inline uint16_t +GSSwapBigI16ToHost(uint16_t in) { return in; } -static inline gsu32 -GSSwapBigI32ToHost(gsu32 in) +static inline uint32_t +GSSwapBigI32ToHost(uint32_t in) { return in; } -static inline gsu64 -GSSwapBigI64ToHost(gsu64 in) +static inline uint64_t +GSSwapBigI64ToHost(uint64_t in) { return in; } @@ -459,18 +459,18 @@ NSSwapBigShortToHost(unsigned short num) /* * Swap Host to Big endian */ -static inline gsu16 -GSSwapHostI16ToBig(gsu16 in) +static inline uint16_t +GSSwapHostI16ToBig(uint16_t in) { return in; } -static inline gsu32 -GSSwapHostI32ToBig(gsu32 in) +static inline uint32_t +GSSwapHostI32ToBig(uint32_t in) { return in; } -static inline gsu64 -GSSwapHostI64ToBig(gsu64 in) +static inline uint64_t +GSSwapHostI64ToBig(uint64_t in) { return in; } @@ -519,18 +519,18 @@ NSSwapHostShortToBig(unsigned short num) /* * Swap Little endian to Host */ -static inline gsu16 -GSSwapLittleI16ToHost(gsu16 in) +static inline uint16_t +GSSwapLittleI16ToHost(uint16_t in) { return GSSwapI16(in); } -static inline gsu32 -GSSwapLittleI32ToHost(gsu32 in) +static inline uint32_t +GSSwapLittleI32ToHost(uint32_t in) { return GSSwapI32(in); } -static inline gsu64 -GSSwapLittleI64ToHost(gsu64 in) +static inline uint64_t +GSSwapLittleI64ToHost(uint64_t in) { return GSSwapI64(in); } @@ -579,18 +579,18 @@ NSSwapLittleShortToHost(unsigned short num) /* * Swap Host to Little endian */ -static inline gsu16 -GSSwapHostI16ToLittle(gsu16 in) +static inline uint16_t +GSSwapHostI16ToLittle(uint16_t in) { return GSSwapI16(in); } -static inline gsu32 -GSSwapHostI32ToLittle(gsu32 in) +static inline uint32_t +GSSwapHostI32ToLittle(uint32_t in) { return GSSwapI32(in); } -static inline gsu64 -GSSwapHostI64ToLittle(gsu64 in) +static inline uint64_t +GSSwapHostI64ToLittle(uint64_t in) { return GSSwapI64(in); } @@ -649,18 +649,18 @@ NSHostByteOrder(void) /* * Swap Big endian to host */ -static inline gsu16 -GSSwapBigI16ToHost(gsu16 in) +static inline uint16_t +GSSwapBigI16ToHost(uint16_t in) { return GSSwapI16(in); } -static inline gsu32 -GSSwapBigI32ToHost(gsu32 in) +static inline uint32_t +GSSwapBigI32ToHost(uint32_t in) { return GSSwapI32(in); } -static inline gsu64 -GSSwapBigI64ToHost(gsu64 in) +static inline uint64_t +GSSwapBigI64ToHost(uint64_t in) { return GSSwapI64(in); } @@ -708,18 +708,18 @@ NSSwapBigShortToHost(unsigned short num) /* * Swap Host to Big endian */ -static inline gsu16 -GSSwapHostI16ToBig(gsu16 in) +static inline uint16_t +GSSwapHostI16ToBig(uint16_t in) { return GSSwapI16(in); } -static inline gsu32 -GSSwapHostI32ToBig(gsu32 in) +static inline uint32_t +GSSwapHostI32ToBig(uint32_t in) { return GSSwapI32(in); } -static inline gsu64 -GSSwapHostI64ToBig(gsu64 in) +static inline uint64_t +GSSwapHostI64ToBig(uint64_t in) { return GSSwapI64(in); } @@ -767,18 +767,18 @@ NSSwapHostShortToBig(unsigned short num) /* * Swap Little endian to Host */ -static inline gsu16 -GSSwapLittleI16ToHost(gsu16 in) +static inline uint16_t +GSSwapLittleI16ToHost(uint16_t in) { return in; } -static inline gsu32 -GSSwapLittleI32ToHost(gsu32 in) +static inline uint32_t +GSSwapLittleI32ToHost(uint32_t in) { return in; } -static inline gsu64 -GSSwapLittleI64ToHost(gsu64 in) +static inline uint64_t +GSSwapLittleI64ToHost(uint64_t in) { return in; } @@ -827,18 +827,18 @@ NSSwapLittleShortToHost(unsigned short num) /* * Swap Host to Little endian */ -static inline gsu16 -GSSwapHostI16ToLittle(gsu16 in) +static inline uint16_t +GSSwapHostI16ToLittle(uint16_t in) { return in; } -static inline gsu32 -GSSwapHostI32ToLittle(gsu32 in) +static inline uint32_t +GSSwapHostI32ToLittle(uint32_t in) { return in; } -static inline gsu64 -GSSwapHostI64ToLittle(gsu64 in) +static inline uint64_t +GSSwapHostI64ToLittle(uint64_t in) { return in; } diff --git a/Headers/Foundation/NSPort.h b/Headers/Foundation/NSPort.h index 6560b864d..fb5bae79d 100644 --- a/Headers/Foundation/NSPort.h +++ b/Headers/Foundation/NSPort.h @@ -202,7 +202,7 @@ typedef SOCKET NSSocketNativeHandle; NSRecursiveLock *myLock; NSHost *host; /* OpenStep host for this port. */ NSString *address; /* Forced internet address. */ - gsu16 portNum; /* TCP port in host byte order. */ + uint16_t portNum; /* TCP port in host byte order. */ SOCKET listener; NSMapTable *handles; /* Handles indexed by socket. */ #if defined(__MINGW32__) @@ -215,7 +215,7 @@ typedef SOCKET NSSocketNativeHandle; * Look up and return an existing NSSocketPort given a host and * number, or return nil if one has not been created. */ -+ (NSSocketPort*) existingPortWithNumber: (gsu16)number ++ (NSSocketPort*) existingPortWithNumber: (uint16_t)number onHost: (NSHost*)aHost; /** @@ -230,7 +230,7 @@ typedef SOCKET NSSocketNativeHandle; * remote host, the port will use the first address that works.
* shouldListen specifies whether to listen on the port initially. */ -+ (NSSocketPort*) portWithNumber: (gsu16)number ++ (NSSocketPort*) portWithNumber: (uint16_t)number onHost: (NSHost*)aHost forceAddress: (NSString*)addr listener: (BOOL)shouldListen; @@ -259,7 +259,7 @@ typedef SOCKET NSSocketNativeHandle; /** * Returns port number of underlying socket. */ -- (gsu16) portNumber; +- (uint16_t) portNumber; // This is the OS X interface /* diff --git a/Source/GSFileHandle.m b/Source/GSFileHandle.m index f557138b0..e9d6f3343 100644 --- a/Source/GSFileHandle.m +++ b/Source/GSFileHandle.m @@ -208,14 +208,14 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) } if (*ptr == '\0' && val <= 0xffff) { - gsu16 v = val; + uint16_t v = val; sin->sin_port = GSSwapHostI16ToBig(v); return YES; } else if (strcmp(ptr, "gdomap") == 0) { - gsu16 v; + uint16_t v; #ifdef GDOMAP_PORT_OVERRIDE v = GDOMAP_PORT_OVERRIDE; #else diff --git a/Source/GSFormat.m b/Source/GSFormat.m index e37883840..32f1832b6 100644 --- a/Source/GSFormat.m +++ b/Source/GSFormat.m @@ -85,7 +85,7 @@ #ifdef HAVE_WCHAR_H #include #else -typedef gsu32 wint_t; +typedef uint32_t wint_t; #endif #ifdef HAVE_SYS_INTTYPES_H #include diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 4b4392b74..6c65e68b8 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -690,6 +690,14 @@ static inline int getDigits(const char *from, char *to, int limit) { sub = @"%I:%M:%S %p"; } + else if (c == 'T') + { + sub = @"%H:%M:%S"; + } + else if (c == 't') + { + sub = @"\t"; + } else if (c == 'X') { sub = [locale objectForKey: NSTimeFormatString]; diff --git a/Source/NSData.m b/Source/NSData.m index 0ee5b437c..9cf03cc6f 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -335,19 +335,10 @@ failure: */ @implementation NSData -#if NEED_WORD_ALIGNMENT -static unsigned gsu16Align; -static unsigned gsu32Align; -#endif - + (void) initialize { if (self == [NSData class]) { -#if NEED_WORD_ALIGNMENT - gsu16Align = objc_alignof_type(@encode(gsu16)); - gsu32Align = objc_alignof_type(@encode(gsu32)); -#endif NSDataAbstract = self; NSMutableDataAbstract = [NSMutableData class]; dataMalloc = [NSDataMalloc class]; @@ -1170,7 +1161,7 @@ failure: } case _C_CHARPTR: { - gss32 length; + int32_t length; [self deserializeBytes: &length length: sizeof(length) @@ -1340,7 +1331,7 @@ failure: } case _C_CLASS: { - gsu16 ni; + uint16_t ni; [self deserializeBytes: &ni length: sizeof(ni) @@ -1372,8 +1363,8 @@ failure: } case _C_SEL: { - gsu16 ln; - gsu16 lt; + uint16_t ln; + uint16_t lt; [self deserializeBytes: &ln length: sizeof(ln) @@ -1588,7 +1579,7 @@ failure: atCursor: (unsigned int*)cursor { [self deserializeDataAt: (void*)tag - ofObjCType: @encode(gsu8) + ofObjCType: @encode(uint8_t) atCursor: cursor context: nil]; if (*tag & _GSC_MAYX) @@ -1601,10 +1592,10 @@ failure: } case _GSC_X_1: { - gsu8 x; + uint8_t x; [self deserializeDataAt: (void*)&x - ofObjCType: @encode(gsu8) + ofObjCType: @encode(uint8_t) atCursor: cursor context: nil]; *ref = (unsigned int)x; @@ -1612,10 +1603,10 @@ failure: } case _GSC_X_2: { - gsu16 x; + uint16_t x; [self deserializeDataAt: (void*)&x - ofObjCType: @encode(gsu16) + ofObjCType: @encode(uint16_t) atCursor: cursor context: nil]; *ref = (unsigned int)x; @@ -1623,10 +1614,10 @@ failure: } default: { - gsu32 x; + uint32_t x; [self deserializeDataAt: (void*)&x - ofObjCType: @encode(gsu32) + ofObjCType: @encode(uint32_t) atCursor: cursor context: nil]; *ref = (unsigned int)x; @@ -2045,17 +2036,17 @@ failure: case _C_CHARPTR: { - gsu32 len; - gsu32 ni; + uint32_t len; + uint32_t ni; if (!*(void**)data) { - ni = (gsu32)-1; + ni = (uint32_t)-1; ni = GSSwapHostI32ToBig(ni); [self appendBytes: (void*)&ni length: sizeof(ni)]; return; } - len = (gsu32)strlen(*(void**)data); + len = (uint32_t)strlen(*(void**)data); ni = GSSwapHostI32ToBig(len); [self appendBytes: (void*)&ni length: sizeof(ni)]; [self appendBytes: *(void**)data length: len]; @@ -2158,8 +2149,8 @@ failure: case _C_CLASS: { const char *name = *(Class*)data?GSNameFromClass(*(Class*)data):""; - gsu16 ln = (gsu16)strlen(name); - gsu16 ni; + uint16_t ln = (uint16_t)strlen(name); + uint16_t ni; ni = GSSwapHostI16ToBig(ln); [self appendBytes: &ni length: sizeof(ni)]; @@ -2172,10 +2163,10 @@ failure: case _C_SEL: { const char *name = *(SEL*)data?GSNameFromSelector(*(SEL*)data):""; - gsu16 ln = (name == 0) ? 0 : (gsu16)strlen(name); + uint16_t ln = (name == 0) ? 0 : (uint16_t)strlen(name); const char *types = *(SEL*)data?GSTypesFromSelector(*(SEL*)data):""; - gsu16 lt = (types == 0) ? 0 : (gsu16)strlen(types); - gsu16 ni; + uint16_t lt = (types == 0) ? 0 : (uint16_t)strlen(types); + uint16_t ni; ni = GSSwapHostI16ToBig(ln); [self appendBytes: &ni length: sizeof(ni)]; @@ -2337,38 +2328,38 @@ failure: { if (xref <= 0xff) { - gsu8 x = (gsu8)xref; + uint8_t x = (uint8_t)xref; tag = (tag & ~_GSC_SIZE) | _GSC_X_1; [self serializeDataAt: (void*)&tag ofObjCType: @encode(unsigned char) context: nil]; [self serializeDataAt: (void*)&x - ofObjCType: @encode(gsu8) + ofObjCType: @encode(uint8_t) context: nil]; } else if (xref <= 0xffff) { - gsu16 x = (gsu16)xref; + uint16_t x = (uint16_t)xref; tag = (tag & ~_GSC_SIZE) | _GSC_X_2; [self serializeDataAt: (void*)&tag ofObjCType: @encode(unsigned char) context: nil]; [self serializeDataAt: (void*)&x - ofObjCType: @encode(gsu16) + ofObjCType: @encode(uint16_t) context: nil]; } else { - gsu32 x = (gsu32)xref; + uint32_t x = (uint32_t)xref; tag = (tag & ~_GSC_SIZE) | _GSC_X_4; [self serializeDataAt: (void*)&tag ofObjCType: @encode(unsigned char) context: nil]; [self serializeDataAt: (void*)&x - ofObjCType: @encode(gsu32) + ofObjCType: @encode(uint32_t) context: nil]; } } @@ -2493,7 +2484,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) } case _C_CHARPTR: { - gss32 len; + int32_t len; [self deserializeBytes: &len length: sizeof(len) @@ -2644,7 +2635,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) } case _C_CLASS: { - gsu16 ni; + uint16_t ni; getBytes((void*)&ni, bytes, sizeof(ni), length, cursor); ni = GSSwapBigI16ToHost(ni); @@ -2672,8 +2663,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) } case _C_SEL: { - gsu16 ln; - gsu16 lt; + uint16_t ln; + uint16_t lt; getBytes((void*)&ln, bytes, sizeof(ln), length, cursor); ln = GSSwapBigI16ToHost(ln); @@ -2760,7 +2751,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) } case _GSC_X_2: { - gsu16 x; + uint16_t x; if (*cursor >= length-1) { @@ -2769,18 +2760,18 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) *cursor, length]; } #if NEED_WORD_ALIGNMENT - if ((*cursor % gsu16Align) != 0) + if ((*cursor % __alignof__(uint16_t)) != 0) memcpy(&x, (bytes + *cursor), 2); else #endif - x = *(gsu16*)(bytes + *cursor); + x = *(uint16_t*)(bytes + *cursor); *cursor += 2; *ref = (unsigned int)GSSwapBigI16ToHost(x); return; } default: { - gsu32 x; + uint32_t x; if (*cursor >= length-3) { @@ -2789,11 +2780,11 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) *cursor, length]; } #if NEED_WORD_ALIGNMENT - if ((*cursor % gsu32Align) != 0) + if ((*cursor % __alignof__(uint32_t)) != 0) memcpy(&x, (bytes + *cursor), 4); else #endif - x = *(gsu32*)(bytes + *cursor); + x = *(uint32_t*)(bytes + *cursor); *cursor += 4; *ref = (unsigned int)GSSwapBigI32ToHost(x); return; @@ -3288,8 +3279,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) case _C_CHARPTR: { unsigned len; - gss32 ni; - gsu32 minimum; + int32_t ni; + uint32_t minimum; if (!*(void**)data) { @@ -3320,7 +3311,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) unsigned size; unsigned count = atoi(++type); unsigned i; - gsu32 minimum; + uint32_t minimum; while (isdigit(*type)) { @@ -3421,9 +3412,9 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) case _C_CLASS: { const char *name = *(Class*)data?GSNameFromClass(*(Class*)data):""; - gsu16 ln = (gsu16)strlen(name); - gsu32 minimum = length + ln + sizeof(gsu16); - gsu16 ni; + uint16_t ln = (uint16_t)strlen(name); + uint32_t minimum = length + ln + sizeof(uint16_t); + uint16_t ni; if (minimum > capacity) { @@ -3442,11 +3433,11 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) case _C_SEL: { const char *name = *(SEL*)data?GSNameFromSelector(*(SEL*)data):""; - gsu16 ln = (name == 0) ? 0 : (gsu16)strlen(name); + uint16_t ln = (name == 0) ? 0 : (uint16_t)strlen(name); const char *types = *(SEL*)data?GSTypesFromSelector(*(SEL*)data):""; - gsu16 lt = (types == 0) ? 0 : (gsu16)strlen(types); - gsu32 minimum = length + ln + lt + 2*sizeof(gsu16); - gsu16 ni; + uint16_t lt = (types == 0) ? 0 : (uint16_t)strlen(types); + uint32_t minimum = length + ln + lt + 2*sizeof(uint16_t); + uint16_t ni; if (minimum > capacity) { @@ -3495,49 +3486,49 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) { [self _grow: length + 2]; } - *(gsu8*)(bytes + length++) = tag; - *(gsu8*)(bytes + length++) = xref; + *(uint8_t*)(bytes + length++) = tag; + *(uint8_t*)(bytes + length++) = xref; } else if (xref <= 0xffff) { - gsu16 x = (gsu16)xref; + uint16_t x = (uint16_t)xref; tag = (tag & ~_GSC_SIZE) | _GSC_X_2; if (length + 3 >= capacity) { [self _grow: length + 3]; } - *(gsu8*)(bytes + length++) = tag; + *(uint8_t*)(bytes + length++) = tag; #if NEED_WORD_ALIGNMENT - if ((length % gsu16Align) != 0) + if ((length % __alignof__(uint16_t)) != 0) { x = GSSwapHostI16ToBig(x); memcpy((bytes + length), &x, 2); } else #endif - *(gsu16*)(bytes + length) = GSSwapHostI16ToBig(x); + *(uint16_t*)(bytes + length) = GSSwapHostI16ToBig(x); length += 2; } else { - gsu32 x = (gsu32)xref; + uint32_t x = (uint32_t)xref; tag = (tag & ~_GSC_SIZE) | _GSC_X_4; if (length + 5 >= capacity) { [self _grow: length + 5]; } - *(gsu8*)(bytes + length++) = tag; + *(uint8_t*)(bytes + length++) = tag; #if NEED_WORD_ALIGNMENT - if ((length % gsu32Align) != 0) + if ((length % __alignof__(uint32_t)) != 0) { x = GSSwapHostI32ToBig(x); memcpy((bytes + length), &x, 4); } else #endif - *(gsu32*)(bytes + length) = GSSwapHostI32ToBig(x); + *(uint32_t*)(bytes + length) = GSSwapHostI32ToBig(x); length += 4; } } diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index 71e03e5fd..eb3fff709 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -163,7 +163,7 @@ enum proxyLocation + (id) initWithCoder: (NSCoder*)aCoder { - gsu8 proxy_tag; + uint8_t proxy_tag; unsigned target; id decoder_connection; NSDistantObject *o; @@ -444,7 +444,7 @@ enum proxyLocation - (void) encodeWithCoder: (NSCoder*)aRmc { unsigned proxy_target; - gsu8 proxy_tag; + uint8_t proxy_tag; NSConnection *encoder_connection; /* diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index bb28b6aef..c00433ec9 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -93,7 +93,7 @@ /* * Largest chunk of data possible in DO */ -static gsu32 maxDataLength = 32 * 1024 * 1024; +static uint32_t maxDataLength = 32 * 1024 * 1024; #if 0 #define M_LOCK(X) {NSDebugMLLog(@"NSMessagePort",@"lock %@",X); [X lock];} @@ -121,8 +121,8 @@ typedef enum { * Its contents are transmitted in network byte order. */ typedef struct { - gsu32 type; /* A GSPortItemType as a 4-byte number. */ - gsu32 length; /* The length of the item (excluding header). */ + uint32_t type; /* A GSPortItemType as a 4-byte number. */ + uint32_t length; /* The length of the item (excluding header). */ } GSPortItemHeader; /* @@ -132,8 +132,8 @@ typedef struct { * NB. additional data counts as part of the same item. */ typedef struct { - gsu32 mId; /* The ID for the message starting with this. */ - gsu32 nItems; /* Number of items (including this one). */ + uint32_t mId; /* The ID for the message starting with this. */ + uint32_t nItems; /* Number of items (including this one). */ } GSPortMsgHeader; typedef struct { @@ -237,11 +237,11 @@ typedef enum { unsigned wLength; /* Ammount written so far. */ NSMutableArray *wMsgs; /* Message in progress. */ NSMutableData *rData; /* Buffer for incoming data */ - gsu32 rLength; /* Amount read so far. */ - gsu32 rWant; /* Amount desired. */ + uint32_t rLength; /* Amount read so far. */ + uint32_t rWant; /* Amount desired. */ NSMutableArray *rItems; /* Message in progress. */ GSPortItemType rType; /* Type of data being read. */ - gsu32 rId; /* Id of incoming message. */ + uint32_t rId; /* Id of incoming message. */ unsigned nItems; /* Number of items to be read. */ GSHandleState state; /* State of the handle. */ unsigned int addrNum; /* Address number within host. */ @@ -1164,17 +1164,10 @@ typedef struct { #define lDesc ((internal*)_internal)->_listener -#if NEED_WORD_ALIGNMENT -static unsigned wordAlign; -#endif - + (void) initialize { if (self == [NSMessagePort class]) { -#if NEED_WORD_ALIGNMENT - wordAlign = objc_alignof_type(@encode(gsu32)); -#endif messagePortClass = self; messagePortMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0); @@ -1862,7 +1855,7 @@ static unsigned wordAlign; * word boundary, so we work with an aligned buffer * and use memcmpy() */ - if ((hLength % wordAlign) != 0) + if ((hLength % __alignof__(uint32_t)) != 0) { GSPortItemHeader itemHeader; diff --git a/Source/NSPortCoder.m b/Source/NSPortCoder.m index d1c27dea5..1675a075d 100644 --- a/Source/NSPortCoder.m +++ b/Source/NSPortCoder.m @@ -521,9 +521,9 @@ static IMP _xRefImp; /* Serialize a crossref. */ gsu128 bigval; #else #if GS_HAVE_I64 - gsu64 bigval; + uint64_t bigval; #else - gsu32 bigval; + uint32_t bigval; #endif #endif @@ -949,27 +949,27 @@ static IMP _xRefImp; /* Serialize a crossref. */ { case _GSC_I16: /* Encoded as 16-bit */ { - gsu16 val; + uint16_t val; - (*_dDesImp)(_src, dDesSel, &val, @encode(gsu16), &_cursor, nil); + (*_dDesImp)(_src, dDesSel, &val, @encode(uint16_t), &_cursor, nil); bigval = val; break; } case _GSC_I32: /* Encoded as 32-bit */ { - gsu32 val; + uint32_t val; - (*_dDesImp)(_src, dDesSel, &val, @encode(gsu32), &_cursor, nil); + (*_dDesImp)(_src, dDesSel, &val, @encode(uint32_t), &_cursor, nil); bigval = val; break; } case _GSC_I64: /* Encoded as 64-bit */ { - gsu64 val; + uint64_t val; - (*_dDesImp)(_src, dDesSel, &val, @encode(gsu64), &_cursor, nil); + (*_dDesImp)(_src, dDesSel, &val, @encode(uint64_t), &_cursor, nil); #if GS_HAVE_I64 bigval = val; #else @@ -988,9 +988,9 @@ static IMP _xRefImp; /* Serialize a crossref. */ #else val = GSSwapBigI128ToHost(val); #if GS_HAVE_I64 - bigval = *(gsu64*)&val; + bigval = *(uint64_t*)&val; #else - bigval = *(gsu32*)&val; + bigval = *(uint32_t*)&val; #endif #endif break; diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 64ddfd877..e00cfb9e0 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -128,10 +128,6 @@ static Class MStringClass = 0; static Class StringClass = 0; static Class NumberClass = 0; -#if NEED_WORD_ALIGNMENT -static unsigned gsu32Align; -#endif - typedef struct { @defs(GSString) } *ivars; @@ -260,7 +256,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) * word boundary, so we work with an aligned buffer * and use memcmpy() */ - if ((dlen % gsu32Align) != 0) + if ((dlen % __alignof__(uint32_t)) != 0) { unichar buffer[slen]; [object getCharacters: buffer]; @@ -370,9 +366,6 @@ static BOOL shouldBeCompact = NO; { if (self == [NSSerializer class]) { -#if NEED_WORD_ALIGNMENT - gsu32Align = objc_alignof_type(@encode(gsu32)); -#endif appSel = @selector(appendBytes:length:); datSel = @selector(mutableBytes); lenSel = @selector(length); diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index b4449a6e0..eab99533f 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -105,7 +105,7 @@ /* * Largest chunk of data possible in DO */ -static gsu32 maxDataLength = 32 * 1024 * 1024; +static uint32_t maxDataLength = 32 * 1024 * 1024; #if 0 #define M_LOCK(X) {NSDebugMLLog(@"GSTcpHandleLock",@"lock %@ in %@",X,[NSThread currentThread]); [X lock];} @@ -148,8 +148,8 @@ typedef enum { * Its contents are transmitted in network byte order. */ typedef struct { - gsu32 type; /* A GSPortItemType as a 4-byte number. */ - gsu32 length; /* The length of the item (excluding header). */ + uint32_t type; /* A GSPortItemType as a 4-byte number. */ + uint32_t length; /* The length of the item (excluding header). */ } GSPortItemHeader; /* @@ -159,12 +159,12 @@ typedef struct { * NB. additional data counts as part of the same item. */ typedef struct { - gsu32 mId; /* The ID for the message starting with this. */ - gsu32 nItems; /* Number of items (including this one). */ + uint32_t mId; /* The ID for the message starting with this. */ + uint32_t nItems; /* Number of items (including this one). */ } GSPortMsgHeader; typedef struct { - gsu16 num; /* TCP port num */ + uint16_t num; /* TCP port num */ char addr[0]; /* host address */ } GSPortInfo; @@ -193,11 +193,11 @@ typedef enum { unsigned wLength; /* Ammount written so far. */ NSMutableArray *wMsgs; /* Message in progress. */ NSMutableData *rData; /* Buffer for incoming data */ - gsu32 rLength; /* Amount read so far. */ - gsu32 rWant; /* Amount desired. */ + uint32_t rLength; /* Amount read so far. */ + uint32_t rWant; /* Amount desired. */ NSMutableArray *rItems; /* Message in progress. */ GSPortItemType rType; /* Type of data being read. */ - gsu32 rId; /* Id of incoming message. */ + uint32_t rId; /* Id of incoming message. */ unsigned nItems; /* Number of items to be read. */ GSHandleState state; /* State of the handle. */ unsigned int addrNum; /* Address number within host. */ @@ -253,8 +253,8 @@ decodePort(NSData *data, NSString *defaultAddress) GSPortItemHeader *pih; GSPortInfo *pi; NSString *addr; - gsu16 pnum; - gsu32 length; + uint16_t pnum; + uint32_t length; NSHost *host; unichar c; @@ -306,7 +306,7 @@ newDataWithEncodedPort(NSSocketPort *port) NSMutableData *data; unsigned plen; NSString *addr; - gsu16 pnum; + uint16_t pnum; pnum = [port portNumber]; addr = [port address]; @@ -1488,17 +1488,10 @@ static NSRecursiveLock *tcpPortLock = nil; static NSMapTable *tcpPortMap = 0; static Class tcpPortClass; -#if NEED_WORD_ALIGNMENT -static unsigned wordAlign; -#endif - + (void) initialize { if (self == [NSSocketPort class]) { -#if NEED_WORD_ALIGNMENT - wordAlign = objc_alignof_type(@encode(gsu32)); -#endif tcpPortClass = self; tcpPortMap = NSCreateMapTable(NSIntMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0); @@ -1518,7 +1511,7 @@ static unsigned wordAlign; /* * Look up an existing NSSocketPort given a host and number */ -+ (NSSocketPort*) existingPortWithNumber: (gsu16)number ++ (NSSocketPort*) existingPortWithNumber: (uint16_t)number onHost: (NSHost*)aHost { NSSocketPort *port = nil; @@ -1550,7 +1543,7 @@ static unsigned wordAlign; * then, for the local host, the port uses ALL IP addresses, and for a * remote host, the port will use the first address that works. */ -+ (NSSocketPort*) portWithNumber: (gsu16)number ++ (NSSocketPort*) portWithNumber: (uint16_t)number onHost: (NSHost*)aHost forceAddress: (NSString*)addr listener: (BOOL)shouldListen @@ -2141,7 +2134,7 @@ static unsigned wordAlign; return NO; } -- (gsu16) portNumber +- (uint16_t) portNumber { return portNum; } @@ -2394,7 +2387,7 @@ static unsigned wordAlign; * word boundary, so we work with an aligned buffer * and use memcmpy() */ - if ((hLength % wordAlign) != 0) + if ((hLength % __alignof__(uint32_t)) != 0) { GSPortItemHeader itemHeader; diff --git a/Source/NSSocketPortNameServer.m b/Source/NSSocketPortNameServer.m index 3d552e7f4..446b4d96b 100644 --- a/Source/NSSocketPortNameServer.m +++ b/Source/NSSocketPortNameServer.m @@ -63,11 +63,11 @@ */ @class NSSocketPort; @interface NSSocketPort (Hack) -+ (NSSocketPort*) portWithNumber: (gsu16)number ++ (NSSocketPort*) portWithNumber: (uint16_t)number onHost: (NSHost*)host forceAddress: (NSString*)addr listener: (BOOL)shouldListen; -- (gsu16) portNumber; +- (uint16_t) portNumber; @end /* @@ -119,8 +119,9 @@ typedef enum { - (GSPortComState) state; - (void) startListNameServers; - (void) startPortLookup: (NSString*)name onHost: (NSString*)addr; -- (void) startPortRegistration: (gsu32)portNumber withName: (NSString*)name; -- (void) startPortUnregistration: (gsu32)portNumber withName: (NSString*)name; +- (void) startPortRegistration: (uint32_t)portNumber withName: (NSString*)name; +- (void) startPortUnregistration: (uint32_t)portNumber + withName: (NSString*)name; @end @implementation GSPortCom @@ -259,7 +260,7 @@ typedef enum { } else if (state == GSPC_READ1 && msg.rtype == GDO_SERVERS) { - gsu32 numSvrs = GSSwapBigI32ToHost(*(gsu32*)[data bytes]); + uint32_t numSvrs = GSSwapBigI32ToHost(*(uint32_t*)[data bytes]); if (numSvrs == 0) { @@ -490,7 +491,7 @@ typedef enum { [self open: host]; } -- (void) startPortRegistration: (gsu32)portNumber withName: (NSString*)name +- (void) startPortRegistration: (uint32_t)portNumber withName: (NSString*)name { msg.rtype = GDO_REGISTER; /* Register a port. */ msg.ptype = GDO_TCP_GDO; /* Port is TCP port for GNU DO */ @@ -503,7 +504,7 @@ typedef enum { [self open: nil]; } -- (void) startPortUnregistration: (gsu32)portNumber withName: (NSString*)name +- (void) startPortUnregistration: (uint32_t)portNumber withName: (NSString*)name { msg.rtype = GDO_UNREG; msg.ptype = GDO_TCP_GDO; @@ -666,7 +667,7 @@ typedef enum { */ dat = AUTORELEASE(RETAIN([com data])); svrs = (struct in_addr*)([dat bytes] + 4); - numSvrs = GSSwapBigI32ToHost(*(gsu32*)[dat bytes]); + numSvrs = GSSwapBigI32ToHost(*(uint32_t*)[dat bytes]); if (numSvrs == 0) { [NSException raise: NSInternalInconsistencyException @@ -759,7 +760,8 @@ typedef enum { [com close]; if ([com state] == GSPC_DONE) { - *port = GSSwapBigI32ToHost(*(gsu32*)[[com data] bytes]); + *port + = GSSwapBigI32ToHost(*(uint32_t*)[[com data] bytes]); if (*port != 0) { singleServer = [com addr]; @@ -953,7 +955,7 @@ typedef enum { { unsigned result; - result = GSSwapBigI32ToHost(*(gsu32*)[[com data] bytes]); + result = GSSwapBigI32ToHost(*(uint32_t*)[[com data] bytes]); if (result == 0) { unsigned int portNum; @@ -1091,7 +1093,7 @@ typedef enum { NSPort *port; unsigned result; - result = GSSwapBigI32ToHost(*(gsu32*)[[com data] bytes]); + result = GSSwapBigI32ToHost(*(uint32_t*)[[com data] bytes]); if (result == 0) { NSLog(@"NSSocketPortNameServer unable to unregister '%@'", name); diff --git a/Source/NSString.m b/Source/NSString.m index a99b6595c..de1fcd550 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -336,7 +336,7 @@ static unsigned rootOf(NSString *s, unsigned l) /* Convert a high-low surrogate pair into Unicode scalar code-point */ -static inline gsu32 +static inline uint32_t surrogatePairValue(unichar high, unichar low) { return ((high - (unichar)0xD800) * (unichar)400) @@ -3285,7 +3285,7 @@ handle_printf_atsign (FILE *stream, unsigned char *buff; unsigned i, j; unichar ch, ch2; - gsu32 cp; + uint32_t cp; buff = (unsigned char *)NSZoneMalloc(NSDefaultMallocZone(), len*3); @@ -3311,10 +3311,10 @@ handle_printf_atsign (FILE *stream, i++; } else - cp = (gsu32)ch; + cp = (uint32_t)ch; } else - cp = (gsu32)ch; + cp = (uint32_t)ch; if (cp < 0x80) { diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index 8a3a5960a..96974a715 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -176,7 +176,7 @@ struct ttinfo * And this is the structure used in the time zone instances. */ typedef struct { - gss32 offset; + int32_t offset; BOOL isdst; unsigned char abbr_idx; char pad[2]; @@ -190,7 +190,7 @@ typedef struct { NSData *timeZoneData; unsigned int n_trans; unsigned int n_types; - gss32 *trans; + int32_t *trans; TypeInfo *types; unsigned char *idxs; } @@ -2145,8 +2145,8 @@ int dayOfCommonEra(NSTimeInterval when); static TypeInfo* chop(NSTimeInterval since, GSTimeZone *zone) { - gss32 when = (gss32)since; - gss32 *trans = zone->trans; + int32_t when = (int32_t)since; + int32_t *trans = zone->trans; unsigned hi = zone->n_trans; unsigned lo = 0; unsigned int i; @@ -2271,12 +2271,12 @@ newDetailInZoneForType(GSTimeZone *zone, TypeInfo *type) format: @"TZ_MAGIC is incorrect"]; } #endif - n_trans = GSSwapBigI32ToHost(*(gss32*)header->tzh_timecnt); - n_types = GSSwapBigI32ToHost(*(gss32*)header->tzh_typecnt); - charcnt = GSSwapBigI32ToHost(*(gss32*)header->tzh_charcnt); + n_trans = GSSwapBigI32ToHost(*(int32_t*)header->tzh_timecnt); + n_types = GSSwapBigI32ToHost(*(int32_t*)header->tzh_typecnt); + charcnt = GSSwapBigI32ToHost(*(int32_t*)header->tzh_charcnt); i = pos; - i += sizeof(gss32)*n_trans; + i += sizeof(int32_t)*n_trans; if (i > length) { [NSException raise: fileException @@ -2305,19 +2305,19 @@ newDetailInZoneForType(GSTimeZone *zone, TypeInfo *type) * for efficient access ... not the same saze as the data * we received. */ - i = n_trans * (sizeof(gss32)+1) + n_types * sizeof(TypeInfo); + i = n_trans * (sizeof(int32_t)+1) + n_types * sizeof(TypeInfo); buf = NSZoneMalloc(NSDefaultMallocZone(), i); types = (TypeInfo*)buf; buf += (n_types * sizeof(TypeInfo)); - trans = (gss32*)buf; - buf += (n_trans * sizeof(gss32)); + trans = (int32_t*)buf; + buf += (n_trans * sizeof(int32_t)); idxs = (unsigned char*)buf; /* Read in transitions. */ for (i = 0; i < n_trans; i++) { - trans[i] = GSSwapBigI32ToHost(*(gss32*)(bytes + pos)); - pos += sizeof(gss32); + trans[i] = GSSwapBigI32ToHost(*(int32_t*)(bytes + pos)); + pos += sizeof(int32_t); } for (i = 0; i < n_trans; i++) { diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index 4f7f46902..9131f694c 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -583,9 +583,9 @@ static Class NSDataMallocClass; gsu128 bigval; #else #if GS_HAVE_I64 - gsu64 bigval; + uint64_t bigval; #else - gsu32 bigval; + uint32_t bigval; #endif #endif @@ -707,7 +707,7 @@ static Class NSDataMallocClass; { unsigned cver; NSString *className; - gsu16 nameLength; + uint16_t nameLength; if (xref != GSIArrayCount(clsMap)) { @@ -719,7 +719,8 @@ static Class NSDataMallocClass; * A class is encoded as a 16-bit length, a sequence of * characters providing its name, then a version number. */ - (*desImp)(src, desSel, &nameLength, @encode(gsu16), &cursor, nil); + (*desImp)(src, desSel, &nameLength, @encode(uint16_t), + &cursor, nil); if (nameLength == 0) { className = nil; @@ -1006,27 +1007,27 @@ static Class NSDataMallocClass; { case _GSC_I16: /* Encoded as 16-bit */ { - gsu16 val; + uint16_t val; - (*desImp)(src, desSel, &val, @encode(gsu16), &cursor, nil); + (*desImp)(src, desSel, &val, @encode(uint16_t), &cursor, nil); bigval = val; break; } case _GSC_I32: /* Encoded as 32-bit */ { - gsu32 val; + uint32_t val; - (*desImp)(src, desSel, &val, @encode(gsu32), &cursor, nil); + (*desImp)(src, desSel, &val, @encode(uint32_t), &cursor, nil); bigval = val; break; } case _GSC_I64: /* Encoded as 64-bit */ { - gsu64 val; + uint64_t val; - (*desImp)(src, desSel, &val, @encode(gsu64), &cursor, nil); + (*desImp)(src, desSel, &val, @encode(uint64_t), &cursor, nil); #if GS_HAVE_I64 bigval = val; #else @@ -1045,9 +1046,9 @@ static Class NSDataMallocClass; #else val = GSSwapBigI128ToHost(val); #if GS_HAVE_I64 - bigval = *(gsu64*)&val; + bigval = *(uint64_t*)&val; #else - bigval = *(gsu32*)&val; + bigval = *(uint32_t*)&val; #endif #endif break; diff --git a/Source/win32/GSFileHandleWin32.m b/Source/win32/GSFileHandleWin32.m index 5c50ca453..470f7899a 100644 --- a/Source/win32/GSFileHandleWin32.m +++ b/Source/win32/GSFileHandleWin32.m @@ -192,14 +192,14 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) } if (*ptr == '\0' && val <= 0xffff) { - gsu16 v = val; + uint16_t v = val; sin->sin_port = GSSwapHostI16ToBig(v); return YES; } else if (strcmp(ptr, "gdomap") == 0) { - gsu16 v; + uint16_t v; #ifdef GDOMAP_PORT_OVERRIDE v = GDOMAP_PORT_OVERRIDE; #else diff --git a/Source/win32/NSMessagePortWin32.m b/Source/win32/NSMessagePortWin32.m index 3e7b5bed7..d4954eb3d 100644 --- a/Source/win32/NSMessagePortWin32.m +++ b/Source/win32/NSMessagePortWin32.m @@ -79,8 +79,8 @@ typedef enum { * Its contents are transmitted in network byte order. */ typedef struct { - gsu32 type; /* A GSPortItemType as a 4-byte number. */ - gsu32 length; /* The length of the item (excluding header). */ + uint32_t type; /* A GSPortItemType as a 4-byte number. */ + uint32_t length; /* The length of the item (excluding header). */ } GSPortItemHeader; /* @@ -90,8 +90,8 @@ typedef struct { * NB. additional data counts as part of the same item. */ typedef struct { - gsu32 mId; /* The ID for the message starting with this. */ - gsu32 nItems; /* Number of items (including this one). */ + uint32_t mId; /* The ID for the message starting with this. */ + uint32_t nItems; /* Number of items (including this one). */ unsigned char version; unsigned char port[16]; } GSPortMsgHeader; @@ -135,10 +135,6 @@ static NSRecursiveLock *messagePortLock = nil; static NSMapTable *ports = 0; static Class messagePortClass = 0; -#if NEED_WORD_ALIGNMENT -static unsigned wordAlign; -#endif - - (BOOL) _setupSendPort { internal *this = (internal*)self->_internal; @@ -183,9 +179,6 @@ static unsigned wordAlign; { if (self == [NSMessagePort class]) { -#if NEED_WORD_ALIGNMENT - wordAlign = objc_alignof_type(@encode(gsu32)); -#endif messagePortClass = self; ports = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0);