From ba0d5403f971d1bc71734bef4d9226fbdce8ef25 Mon Sep 17 00:00:00 2001 From: Matvii Jarosh Date: Tue, 26 Nov 2024 17:51:28 +0200 Subject: [PATCH] Fix NSByteOrder --- ChangeLog | 5 +++++ Headers/Foundation/NSByteOrder.h | 24 ++++++++++++++++++++++++ MISSING | 7 ++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6229e10be..f1a83a8c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-11-26 Matvii Jarosh + + * NSByteOrder.h: fix NSSwappedFloat and NSSwappedDouble + * MISSING: + 2024-11-25 Matvii Jarosh * NSInvocation.h: add enum _NSObjCValueType and diff --git a/Headers/Foundation/NSByteOrder.h b/Headers/Foundation/NSByteOrder.h index ea829585b..918762dff 100644 --- a/Headers/Foundation/NSByteOrder.h +++ b/Headers/Foundation/NSByteOrder.h @@ -384,13 +384,37 @@ NSSwapShort(unsigned short in) static inline NSSwappedDouble NSSwapDouble(NSSwappedDouble num) { +#if GS_SIZEOF_DOUBLE == 2 + return GSSwapI16(num); +#else +#if GS_SIZEOF_DOUBLE == 4 + return GSSwapI32(num); +#else +#if GS_SIZEOF_DOUBLE == 8 return GSSwapI64(num); +#else + return GSSwapI128(num); +#endif +#endif +#endif } static inline NSSwappedFloat NSSwapFloat(NSSwappedFloat num) { +#if GS_SIZEOF_FLOAT == 2 + return GSSwapI16(num); +#else +#if GS_SIZEOF_FLOAT == 4 return GSSwapI32(num); +#else +#if GS_SIZEOF_FLOAT == 8 + return GSSwapI64(num); +#else + return GSSwapI128(num); +#endif +#endif +#endif } #if GS_WORDS_BIGENDIAN diff --git a/MISSING b/MISSING index cb4500398..d53e10c49 100644 --- a/MISSING +++ b/MISSING @@ -32,10 +32,6 @@ NSBundle: /** Not implemented */ (GNUstep comment) - executableArchitectures; ------------------------------------------------------------- -NSByteOrder: - NSSwappedFloat — incompatible declaration - NSSwappedDouble — incompatible declaration -------------------------------------------------------------- NSCalendar: NSWeekOfMonthCalendarUnit NSWeekOfYearCalendarUnit @@ -880,4 +876,5 @@ Good headers: - \ No newline at end of file + + \ No newline at end of file