From 8bf1e094893cb24796137b47ee0d46d18d299996 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Sun, 9 Aug 2009 18:41:02 +0000 Subject: Refactor to remove un-named struct gnu extension usage. Now ISO C89 and C99 compliant. Comment trailing endifs git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@78537 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CMakeLists.txt | 34 ++++++++++-- lib/apple_versioning.c | 6 +-- lib/ashldi3.c | 8 +-- lib/ashlti3.c | 8 +-- lib/ashrdi3.c | 10 ++-- lib/ashrti3.c | 12 ++--- lib/clzdi2.c | 4 +- lib/clzti2.c | 2 +- lib/cmpdi2.c | 8 +-- lib/ctzdi2.c | 4 +- lib/ffsdi2.c | 8 +-- lib/ffsti2.c | 2 +- lib/fixdfdi.c | 8 +-- lib/fixunsdfdi.c | 8 +-- lib/fixunsdfsi.c | 8 +-- lib/fixunsxfdi.c | 4 +- lib/fixunsxfsi.c | 8 +-- lib/fixxfdi.c | 6 +-- lib/fixxfti.c | 2 +- lib/floatdixf.c | 6 +-- lib/floatundixf.c | 2 +- lib/int_lib.h | 8 +-- lib/lshrdi3.c | 8 +-- lib/lshrti3.c | 10 ++-- lib/muldi3.c | 24 ++++----- lib/multi3.c | 24 ++++----- lib/paritydi2.c | 2 +- lib/ppc/DD.h | 6 +-- lib/ppc/divtc3.c | 54 +++++++++---------- lib/ppc/fixtfdi.c | 70 +++++++++++++------------ lib/ppc/fixunstfdi.c | 38 +++++++------- lib/ppc/floatditf.c | 31 ++++++----- lib/ppc/floatunditf.c | 32 +++++------ lib/ppc/gcc_qadd.c | 40 +++++++------- lib/ppc/gcc_qdiv.c | 30 ++++++----- lib/ppc/gcc_qmul.c | 32 +++++------ lib/ppc/gcc_qsub.c | 40 +++++++------- lib/ppc/multc3.c | 26 ++++----- lib/subvti3.c | 2 +- lib/ucmpdi2.c | 8 +-- lib/udivmoddi4.c | 136 +++++++++++++++++++++++------------------------ lib/udivmodti4.c | 140 ++++++++++++++++++++++++------------------------- 42 files changed, 483 insertions(+), 436 deletions(-) (limited to 'lib') diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fa30cf628..40d05a9c7 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -6,6 +6,7 @@ #) # Generic functions needed for each architecture +# libcompiler_rt.Generic.a libcompiler_rt.Optimized.a SET( SRCS absvdi2.c cmpdi2.c fixdfdi.c floatdidf.c moddi3.c negvti2.c ucmpdi2.c @@ -25,6 +26,25 @@ SET( SRCS clzti2.c ffsti2.c fixxfti.c lshrti3.c negvsi2.c trampoline_setup.c ) +# Generic +SET( Common_SRCS + absvdi2.c absvsi2.c addvdi3.c addvsi3.c ashldi3.c ashrdi3.c + clear_cache.c clzdi2.c clzsi2.c cmpdi2.c ctzdi2.c ctzsi2.c + divdc3.c divdi3.c divsc3.c enable_execute_stack.c ffsdi2.c + fixdfdi.c fixsfdi.c fixunsdfdi.c fixunsdfsi.c fixunssfdi.c + fixunssfsi.c floatdidf.c floatdisf.c floatundidf.c floatundisf.c + gcc_personality_v0.c lshrdi3.c moddi3.c muldc3.c muldi3.c + mulsc3.c mulvdi3.c mulvsi3.c negdi2.c negvdi2.c negvsi2.c + paritydi2.c paritysi2.c popcountdi2.c popcountsi2.c powidf2.c + powisf2.c subvdi3.c subvsi3.c ucmpdi2.c udivdi3.c + udivmoddi4.c umoddi3.c apple_versioning.c eprintf.c + ) + +SET( i386_Functions + divxc3.c fixunsxfdi.c fixunsxfsi.c fixxfdi.c + floatdixf.c floatundixf.c mulxc3.c powixf2.c + ) + # Optimized functions for each architecture # Commenting out for the min until the basics are working first. @@ -32,6 +52,14 @@ SET( SRCS # ADD_SUBDIRECTORY( x86_64 ) # ADD_SUBDIRECTORY( i386 ) -# Creates a shared lib .so -ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS} ) -#ADD_LIBRARY( ${PROJECT_NAME} STATIC ${SRCS} ) +#FOREACH( LOOP_VAR ${Achitectures} ) +# See ARCHIVE_OUTPUT_DIRECTORY docs. +#${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LOOP_VAR} +#ENDFOREACH + +ADD_LIBRARY( ${PROJECT_NAME}-Common STATIC ${Common_SRCS} ) +#ADD_LIBRARY( ${PROJECT_NAME}-i386 STATIC ${i386_Functions} ) + +# [[debug|optimized|general] +#TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${PROJECT_NAME}-Common optimized ${PROJECT_NAME}-i386 ) + diff --git a/lib/apple_versioning.c b/lib/apple_versioning.c index 4db098a4e..9c6dd5fa7 100644 --- a/lib/apple_versioning.c +++ b/lib/apple_versioning.c @@ -25,12 +25,13 @@ __attribute__((visibility("default"))) const char sym##_tmp4 = 0; \ extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); \ __attribute__((visibility("default"))) const char sym##_tmp5 = 0; - #endif + #endif /* __ppc__ */ /* Symbols in libSystem.dylib in 10.6 and later, * but are in libgcc_s.dylib in earlier versions */ + NOT_HERE_BEFORE_10_6(__absvdi2) NOT_HERE_BEFORE_10_6(__absvsi2) NOT_HERE_BEFORE_10_6(__absvti2) @@ -138,8 +139,7 @@ NOT_HERE_BEFORE_10_6(__gcc_qdiv) NOT_HERE_BEFORE_10_6(__gcc_qmul) NOT_HERE_BEFORE_10_6(__gcc_qsub) NOT_HERE_BEFORE_10_6(__trampoline_setup) -#endif +#endif /* __ppc__ */ #endif /* __APPLE__*/ - diff --git a/lib/ashldi3.c b/lib/ashldi3.c index c818ee71a..993f71ca9 100644 --- a/lib/ashldi3.c +++ b/lib/ashldi3.c @@ -27,15 +27,15 @@ __ashldi3(di_int a, si_int b) input.all = a; if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ { - result.low = 0; - result.high = input.low << (b - bits_in_word); + result.s.low = 0; + result.s.high = input.s.low << (b - bits_in_word); } else /* 0 <= b < bits_in_word */ { if (b == 0) return a; - result.low = input.low << b; - result.high = (input.high << b) | (input.low >> (bits_in_word - b)); + result.s.low = input.s.low << b; + result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); } return result.all; } diff --git a/lib/ashlti3.c b/lib/ashlti3.c index c1ab37163..317de6655 100644 --- a/lib/ashlti3.c +++ b/lib/ashlti3.c @@ -29,15 +29,15 @@ __ashlti3(ti_int a, si_int b) input.all = a; if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ { - result.low = 0; - result.high = input.low << (b - bits_in_dword); + result.s.low = 0; + result.s.high = input.s.low << (b - bits_in_dword); } else /* 0 <= b < bits_in_dword */ { if (b == 0) return a; - result.low = input.low << b; - result.high = (input.high << b) | (input.low >> (bits_in_dword - b)); + result.s.low = input.s.low << b; + result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_dword - b)); } return result.all; } diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c index a8125a3c7..8e27a11a7 100644 --- a/lib/ashrdi3.c +++ b/lib/ashrdi3.c @@ -27,16 +27,16 @@ __ashrdi3(di_int a, si_int b) input.all = a; if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ { - /* result.high = input.high < 0 ? -1 : 0 */ - result.high = input.high >> (bits_in_word - 1); - result.low = input.high >> (b - bits_in_word); + /* result.s.high = input.s.high < 0 ? -1 : 0 */ + result.s.high = input.s.high >> (bits_in_word - 1); + result.s.low = input.s.high >> (b - bits_in_word); } else /* 0 <= b < bits_in_word */ { if (b == 0) return a; - result.high = input.high >> b; - result.low = (input.high << (bits_in_word - b)) | (input.low >> b); + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); } return result.all; } diff --git a/lib/ashrti3.c b/lib/ashrti3.c index 55645f78d..4eab2475c 100644 --- a/lib/ashrti3.c +++ b/lib/ashrti3.c @@ -29,18 +29,18 @@ __ashrti3(ti_int a, si_int b) input.all = a; if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ { - /* result.high = input.high < 0 ? -1 : 0 */ - result.high = input.high >> (bits_in_dword - 1); - result.low = input.high >> (b - bits_in_dword); + /* result.s.high = input.s.high < 0 ? -1 : 0 */ + result.s.high = input.s.high >> (bits_in_dword - 1); + result.s.low = input.s.high >> (b - bits_in_dword); } else /* 0 <= b < bits_in_dword */ { if (b == 0) return a; - result.high = input.high >> b; - result.low = (input.high << (bits_in_dword - b)) | (input.low >> b); + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_dword - b)) | (input.s.low >> b); } return result.all; } -#endif +#endif /* __x86_64 */ diff --git a/lib/clzdi2.c b/lib/clzdi2.c index 34d43625a..ea953961d 100644 --- a/lib/clzdi2.c +++ b/lib/clzdi2.c @@ -23,7 +23,7 @@ __clzdi2(di_int a) { dwords x; x.all = a; - const si_int f = -(x.high == 0); - return __builtin_clz((x.high & ~f) | (x.low & f)) + + const si_int f = -(x.s.high == 0); + return __builtin_clz((x.s.high & ~f) | (x.s.low & f)) + (f & ((si_int)(sizeof(si_int) * CHAR_BIT))); } diff --git a/lib/clzti2.c b/lib/clzti2.c index acdf479c4..eb05e2e23 100644 --- a/lib/clzti2.c +++ b/lib/clzti2.c @@ -30,4 +30,4 @@ __clzti2(ti_int a) ((si_int)f & ((si_int)(sizeof(di_int) * CHAR_BIT))); } -#endif +#endif /* __x86_64 */ diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c index ece48ae9f..0b8735244 100644 --- a/lib/cmpdi2.c +++ b/lib/cmpdi2.c @@ -26,13 +26,13 @@ __cmpdi2(di_int a, di_int b) x.all = a; dwords y; y.all = b; - if (x.high < y.high) + if (x.s.high < y.s.high) return 0; - if (x.high > y.high) + if (x.s.high > y.s.high) return 2; - if (x.low < y.low) + if (x.s.low < y.s.low) return 0; - if (x.low > y.low) + if (x.s.low > y.s.low) return 2; return 1; } diff --git a/lib/ctzdi2.c b/lib/ctzdi2.c index 471c93b44..b49f2c713 100644 --- a/lib/ctzdi2.c +++ b/lib/ctzdi2.c @@ -23,7 +23,7 @@ __ctzdi2(di_int a) { dwords x; x.all = a; - const si_int f = -(x.low == 0); - return __builtin_ctz((x.high & f) | (x.low & ~f)) + + const si_int f = -(x.s.low == 0); + return __builtin_ctz((x.s.high & f) | (x.s.low & ~f)) + (f & ((si_int)(sizeof(si_int) * CHAR_BIT))); } diff --git a/lib/ffsdi2.c b/lib/ffsdi2.c index 680fdb3ce..8c03d19af 100644 --- a/lib/ffsdi2.c +++ b/lib/ffsdi2.c @@ -23,11 +23,11 @@ __ffsdi2(di_int a) { dwords x; x.all = a; - if (x.low == 0) + if (x.s.low == 0) { - if (x.high == 0) + if (x.s.high == 0) return 0; - return __builtin_ctz(x.high) + (1 + sizeof(si_int) * CHAR_BIT); + return __builtin_ctz(x.s.high) + (1 + sizeof(si_int) * CHAR_BIT); } - return __builtin_ctz(x.low) + 1; + return __builtin_ctz(x.s.low) + 1; } diff --git a/lib/ffsti2.c b/lib/ffsti2.c index 2ee1a8bd2..668b54296 100644 --- a/lib/ffsti2.c +++ b/lib/ffsti2.c @@ -34,4 +34,4 @@ __ffsti2(ti_int a) return __builtin_ctzll(x.low) + 1; } -#endif +#endif /* __x86_64 */ diff --git a/lib/fixdfdi.c b/lib/fixdfdi.c index fa5dd8993..3d3116c18 100644 --- a/lib/fixdfdi.c +++ b/lib/fixdfdi.c @@ -28,13 +28,13 @@ __fixdfdi(double a) { double_bits fb; fb.f = a; - int e = ((fb.u.high & 0x7FF00000) >> 20) - 1023; + int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023; if (e < 0) return 0; - di_int s = (si_int)(fb.u.high & 0x80000000) >> 31; + di_int s = (si_int)(fb.u.s.high & 0x80000000) >> 31; dwords r; - r.high = (fb.u.high & 0x000FFFFF) | 0x00100000; - r.low = fb.u.low; + r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000; + r.s.low = fb.u.s.low; if (e > 52) r.all <<= (e - 52); else diff --git a/lib/fixunsdfdi.c b/lib/fixunsdfdi.c index 4d5dcfebc..bdcee13e8 100644 --- a/lib/fixunsdfdi.c +++ b/lib/fixunsdfdi.c @@ -31,12 +31,12 @@ __fixunsdfdi(double a) { double_bits fb; fb.f = a; - int e = ((fb.u.high & 0x7FF00000) >> 20) - 1023; - if (e < 0 || (fb.u.high & 0x80000000)) + int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023; + if (e < 0 || (fb.u.s.high & 0x80000000)) return 0; udwords r; - r.high = (fb.u.high & 0x000FFFFF) | 0x00100000; - r.low = fb.u.low; + r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000; + r.s.low = fb.u.s.low; if (e > 52) r.all <<= (e - 52); else diff --git a/lib/fixunsdfsi.c b/lib/fixunsdfsi.c index f9d2b6d86..a0cba79aa 100644 --- a/lib/fixunsdfsi.c +++ b/lib/fixunsdfsi.c @@ -31,12 +31,12 @@ __fixunsdfsi(double a) { double_bits fb; fb.f = a; - int e = ((fb.u.high & 0x7FF00000) >> 20) - 1023; - if (e < 0 || (fb.u.high & 0x80000000)) + int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023; + if (e < 0 || (fb.u.s.high & 0x80000000)) return 0; return ( 0x80000000u | - ((fb.u.high & 0x000FFFFF) << 11) | - (fb.u.low >> 21) + ((fb.u.s.high & 0x000FFFFF) << 11) | + (fb.u.s.low >> 21) ) >> (31 - e); } diff --git a/lib/fixunsxfdi.c b/lib/fixunsxfdi.c index e09f2d06d..872727bcd 100644 --- a/lib/fixunsxfdi.c +++ b/lib/fixunsxfdi.c @@ -35,8 +35,8 @@ __fixunsxfdi(long double a) { long_double_bits fb; fb.f = a; - int e = (fb.u.high.low & 0x00007FFF) - 16383; - if (e < 0 || (fb.u.high.low & 0x00008000)) + int e = (fb.u.high.s.low & 0x00007FFF) - 16383; + if (e < 0 || (fb.u.high.s.low & 0x00008000)) return 0; return fb.u.low.all >> (63 - e); } diff --git a/lib/fixunsxfsi.c b/lib/fixunsxfsi.c index a711a26e3..c9a607ace 100644 --- a/lib/fixunsxfsi.c +++ b/lib/fixunsxfsi.c @@ -35,10 +35,10 @@ __fixunsxfsi(long double a) { long_double_bits fb; fb.f = a; - int e = (fb.u.high.low & 0x00007FFF) - 16383; - if (e < 0 || (fb.u.high.low & 0x00008000)) + int e = (fb.u.high.s.low & 0x00007FFF) - 16383; + if (e < 0 || (fb.u.high.s.low & 0x00008000)) return 0; - return fb.u.low.high >> (31 - e); + return fb.u.low.s.high >> (31 - e); } -#endif +#endif /* !_ARCH_PPC */ diff --git a/lib/fixxfdi.c b/lib/fixxfdi.c index 48bfc3ceb..de6f818b8 100644 --- a/lib/fixxfdi.c +++ b/lib/fixxfdi.c @@ -32,13 +32,13 @@ __fixxfdi(long double a) { long_double_bits fb; fb.f = a; - int e = (fb.u.high.low & 0x00007FFF) - 16383; + int e = (fb.u.high.s.low & 0x00007FFF) - 16383; if (e < 0) return 0; - di_int s = -(si_int)((fb.u.high.low & 0x00008000) >> 15); + di_int s = -(si_int)((fb.u.high.s.low & 0x00008000) >> 15); di_int r = fb.u.low.all; r = (du_int)r >> (63 - e); return (r ^ s) - s; } -#endif +#endif /* !_ARCH_PPC */ diff --git a/lib/fixxfti.c b/lib/fixxfti.c index 84406bd16..70d0e17b9 100644 --- a/lib/fixxfti.c +++ b/lib/fixxfti.c @@ -44,4 +44,4 @@ __fixxfti(long double a) return (r ^ s) - s; } -#endif +#endif /* __x86_64 */ diff --git a/lib/floatdixf.c b/lib/floatdixf.c index 6760ab32f..bfda367df 100644 --- a/lib/floatdixf.c +++ b/lib/floatdixf.c @@ -37,10 +37,10 @@ __floatdixf(di_int a) int clz = __builtin_clzll(a); int e = (N - 1) - clz ; /* exponent */ long_double_bits fb; - fb.u.high.low = ((su_int)s & 0x00008000) | /* sign */ - (e + 16383); /* exponent */ + fb.u.high.s.low = ((su_int)s & 0x00008000) | /* sign */ + (e + 16383); /* exponent */ fb.u.low.all = a << clz; /* mantissa */ return fb.f; } -#endif +#endif /* !_ARCH_PPC */ diff --git a/lib/floatundixf.c b/lib/floatundixf.c index d87224f90..bc9582f76 100644 --- a/lib/floatundixf.c +++ b/lib/floatundixf.c @@ -34,7 +34,7 @@ __floatundixf(du_int a) int clz = __builtin_clzll(a); int e = (N - 1) - clz ; /* exponent */ long_double_bits fb; - fb.u.high.low = (e + 16383); /* exponent */ + fb.u.high.s.low = (e + 16383); /* exponent */ fb.u.low.all = a << clz; /* mantissa */ return fb.f; } diff --git a/lib/int_lib.h b/lib/int_lib.h index 8f07ba2cb..2df744486 100644 --- a/lib/int_lib.h +++ b/lib/int_lib.h @@ -45,7 +45,7 @@ typedef union si_int high; su_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } dwords; typedef union @@ -60,7 +60,7 @@ typedef union su_int high; su_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } udwords; #if __x86_64 @@ -80,7 +80,7 @@ typedef union di_int high; du_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } twords; typedef union @@ -95,7 +95,7 @@ typedef union du_int high; du_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } utwords; #endif /* __x86_64 */ diff --git a/lib/lshrdi3.c b/lib/lshrdi3.c index b3b31bf00..57484ee75 100644 --- a/lib/lshrdi3.c +++ b/lib/lshrdi3.c @@ -27,15 +27,15 @@ __lshrdi3(di_int a, si_int b) input.all = a; if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ { - result.high = 0; - result.low = input.high >> (b - bits_in_word); + result.s.high = 0; + result.s.low = input.s.high >> (b - bits_in_word); } else /* 0 <= b < bits_in_word */ { if (b == 0) return a; - result.high = input.high >> b; - result.low = (input.high << (bits_in_word - b)) | (input.low >> b); + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); } return result.all; } diff --git a/lib/lshrti3.c b/lib/lshrti3.c index a2846875d..3272c9ca8 100644 --- a/lib/lshrti3.c +++ b/lib/lshrti3.c @@ -29,17 +29,17 @@ __lshrti3(ti_int a, si_int b) input.all = a; if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ { - result.high = 0; - result.low = input.high >> (b - bits_in_dword); + result.s.high = 0; + result.s.low = input.s.high >> (b - bits_in_dword); } else /* 0 <= b < bits_in_dword */ { if (b == 0) return a; - result.high = input.high >> b; - result.low = (input.high << (bits_in_dword - b)) | (input.low >> b); + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_dword - b)) | (input.s.low >> b); } return result.all; } -#endif +#endif /* __x86_64 */ diff --git a/lib/muldi3.c b/lib/muldi3.c index 6ed5929da..38963b726 100644 --- a/lib/muldi3.c +++ b/lib/muldi3.c @@ -23,18 +23,18 @@ __muldsi3(su_int a, su_int b) dwords r; const int bits_in_word_2 = (int)(sizeof(si_int) * CHAR_BIT) / 2; const su_int lower_mask = (su_int)~0 >> bits_in_word_2; - r.low = (a & lower_mask) * (b & lower_mask); - su_int t = r.low >> bits_in_word_2; - r.low &= lower_mask; + r.s.low = (a & lower_mask) * (b & lower_mask); + su_int t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; t += (a >> bits_in_word_2) * (b & lower_mask); - r.low += (t & lower_mask) << bits_in_word_2; - r.high = t >> bits_in_word_2; - t = r.low >> bits_in_word_2; - r.low &= lower_mask; + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high = t >> bits_in_word_2; + t = r.s.low >> bits_in_word_2; + r.s.low &= lower_mask; t += (b >> bits_in_word_2) * (a & lower_mask); - r.low += (t & lower_mask) << bits_in_word_2; - r.high += t >> bits_in_word_2; - r.high += (a >> bits_in_word_2) * (b >> bits_in_word_2); + r.s.low += (t & lower_mask) << bits_in_word_2; + r.s.high += t >> bits_in_word_2; + r.s.high += (a >> bits_in_word_2) * (b >> bits_in_word_2); return r.all; } @@ -48,7 +48,7 @@ __muldi3(di_int a, di_int b) dwords y; y.all = b; dwords r; - r.all = __muldsi3(x.low, y.low); - r.high += x.high * y.low + x.low * y.high; + r.all = __muldsi3(x.s.low, y.s.low); + r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; return r.all; } diff --git a/lib/multi3.c b/lib/multi3.c index 849504913..9ba730e48 100644 --- a/lib/multi3.c +++ b/lib/multi3.c @@ -25,18 +25,18 @@ __mulddi3(du_int a, du_int b) twords r; const int bits_in_dword_2 = (int)(sizeof(di_int) * CHAR_BIT) / 2; const du_int lower_mask = (du_int)~0 >> bits_in_dword_2; - r.low = (a & lower_mask) * (b & lower_mask); - du_int t = r.low >> bits_in_dword_2; - r.low &= lower_mask; + r.s.low = (a & lower_mask) * (b & lower_mask); + du_int t = r.s.low >> bits_in_dword_2; + r.s.low &= lower_mask; t += (a >> bits_in_dword_2) * (b & lower_mask); - r.low += (t & lower_mask) << bits_in_dword_2; - r.high = t >> bits_in_dword_2; - t = r.low >> bits_in_dword_2; - r.low &= lower_mask; + r.s.low += (t & lower_mask) << bits_in_dword_2; + r.s.high = t >> bits_in_dword_2; + t = r.s.low >> bits_in_dword_2; + r.s.low &= lower_mask; t += (b >> bits_in_dword_2) * (a & lower_mask); - r.low += (t & lower_mask) << bits_in_dword_2; - r.high += t >> bits_in_dword_2; - r.high += (a >> bits_in_dword_2) * (b >> bits_in_dword_2); + r.s.low += (t & lower_mask) << bits_in_dword_2; + r.s.high += t >> bits_in_dword_2; + r.s.high += (a >> bits_in_dword_2) * (b >> bits_in_dword_2); return r.all; } @@ -51,8 +51,8 @@ __multi3(ti_int a, ti_int b) y.all = b; twords r; r.all = __mulddi3(x.low, y.low); - r.high += x.high * y.low + x.low * y.high; + r.s.high += x.high * y.low + x.low * y.high; return r.all; } -#endif +#endif /* __x86_64 */ diff --git a/lib/paritydi2.c b/lib/paritydi2.c index f77d4d728..90e5559bc 100644 --- a/lib/paritydi2.c +++ b/lib/paritydi2.c @@ -23,5 +23,5 @@ __paritydi2(di_int a) { dwords x; x.all = a; - return __paritysi2(x.high ^ x.low); + return __paritysi2(x.s.high ^ x.s.low); } diff --git a/lib/ppc/DD.h b/lib/ppc/DD.h index 32acecd5f..9ecd1f50b 100644 --- a/lib/ppc/DD.h +++ b/lib/ppc/DD.h @@ -8,8 +8,8 @@ typedef union { struct { double hi; double lo; - }; -} DD; + }s; +}DD; typedef union { double d; @@ -43,4 +43,4 @@ different_sign(double x, double y) return result; } -#endif // __DD_HEADER +#endif /* __DD_HEADER */ diff --git a/lib/ppc/divtc3.c b/lib/ppc/divtc3.c index dbb71ecc3..d41f62111 100644 --- a/lib/ppc/divtc3.c +++ b/lib/ppc/divtc3.c @@ -10,8 +10,8 @@ #endif /* INFINITY */ #define makeFinite(x) { \ - (x).hi = __builtin_copysign(isinf((x).hi) ? 1.0 : 0.0, (x).hi); \ - (x).lo = 0.0; \ + (x).s.hi = __builtin_copysign(isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ + (x).s.lo = 0.0; \ } long double __gcc_qadd(long double, long double); @@ -26,16 +26,16 @@ __divtc3(long double a, long double b, long double c, long double d) DD dDD = { .ld = d }; int ilogbw = 0; - const double logbw = logb(__builtin_fmax( __builtin_fabs(cDD.hi), __builtin_fabs(dDD.hi) )); + const double logbw = logb(__builtin_fmax( __builtin_fabs(cDD.s.hi), __builtin_fabs(dDD.s.hi) )); if (isfinite(logbw)) { ilogbw = (int)logbw; - cDD.hi = scalbn(cDD.hi, -ilogbw); - cDD.lo = scalbn(cDD.lo, -ilogbw); - dDD.hi = scalbn(dDD.hi, -ilogbw); - dDD.lo = scalbn(dDD.lo, -ilogbw); + cDD.s.hi = scalbn(cDD.s.hi, -ilogbw); + cDD.s.lo = scalbn(cDD.s.lo, -ilogbw); + dDD.s.hi = scalbn(dDD.s.hi, -ilogbw); + dDD.s.lo = scalbn(dDD.s.lo, -ilogbw); } const long double denom = __gcc_qadd(__gcc_qmul(cDD.ld, cDD.ld), __gcc_qmul(dDD.ld, dDD.ld)); @@ -45,43 +45,43 @@ __divtc3(long double a, long double b, long double c, long double d) DD real = { .ld = __gcc_qdiv(realNumerator, denom) }; DD imag = { .ld = __gcc_qdiv(imagNumerator, denom) }; - real.hi = scalbn(real.hi, -ilogbw); - real.lo = scalbn(real.lo, -ilogbw); - imag.hi = scalbn(imag.hi, -ilogbw); - imag.lo = scalbn(imag.lo, -ilogbw); + real.s.hi = scalbn(real.s.hi, -ilogbw); + real.s.lo = scalbn(real.s.lo, -ilogbw); + imag.s.hi = scalbn(imag.s.hi, -ilogbw); + imag.s.lo = scalbn(imag.s.lo, -ilogbw); - if (isnan(real.hi) && isnan(imag.hi)) + if (isnan(real.s.hi) && isnan(imag.s.hi)) { DD aDD = { .ld = a }; DD bDD = { .ld = b }; DD rDD = { .ld = denom }; - if ((rDD.hi == 0.0) && (!isnan(aDD.hi) || !isnan(bDD.hi))) + if ((rDD.s.hi == 0.0) && (!isnan(aDD.s.hi) || !isnan(bDD.s.hi))) { - real.hi = __builtin_copysign(INFINITY,cDD.hi) * aDD.hi; - real.lo = 0.0; - imag.hi = __builtin_copysign(INFINITY,cDD.hi) * bDD.hi; - imag.lo = 0.0; + real.s.hi = __builtin_copysign(INFINITY,cDD.s.hi) * aDD.s.hi; + real.s.lo = 0.0; + imag.s.hi = __builtin_copysign(INFINITY,cDD.s.hi) * bDD.s.hi; + imag.s.lo = 0.0; } - else if ((isinf(aDD.hi) || isinf(bDD.hi)) && isfinite(cDD.hi) && isfinite(dDD.hi)) + else if ((isinf(aDD.s.hi) || isinf(bDD.s.hi)) && isfinite(cDD.s.hi) && isfinite(dDD.s.hi)) { makeFinite(aDD); makeFinite(bDD); - real.hi = INFINITY * (aDD.hi*cDD.hi + bDD.hi*dDD.hi); - real.lo = 0.0; - imag.hi = INFINITY * (bDD.hi*cDD.hi - aDD.hi*dDD.hi); - imag.lo = 0.0; + real.s.hi = INFINITY * (aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi); + real.s.lo = 0.0; + imag.s.hi = INFINITY * (bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi); + imag.s.lo = 0.0; } - else if ((isinf(cDD.hi) || isinf(dDD.hi)) && isfinite(aDD.hi) && isfinite(bDD.hi)) + else if ((isinf(cDD.s.hi) || isinf(dDD.s.hi)) && isfinite(aDD.s.hi) && isfinite(bDD.s.hi)) { makeFinite(cDD); makeFinite(dDD); - real.hi = __builtin_copysign(0.0,(aDD.hi*cDD.hi + bDD.hi*dDD.hi)); - real.lo = 0.0; - imag.hi = __builtin_copysign(0.0,(bDD.hi*cDD.hi - aDD.hi*dDD.hi)); - imag.lo = 0.0; + real.s.hi = __builtin_copysign(0.0,(aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi)); + real.s.lo = 0.0; + imag.s.hi = __builtin_copysign(0.0,(bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi)); + imag.s.lo = 0.0; } } diff --git a/lib/ppc/fixtfdi.c b/lib/ppc/fixtfdi.c index c95241701..fa113a037 100644 --- a/lib/ppc/fixtfdi.c +++ b/lib/ppc/fixtfdi.c @@ -1,8 +1,10 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// int64_t __fixunstfdi(long double x); -// This file implements the PowerPC 128-bit double-double -> int64_t conversion +/* int64_t __fixunstfdi(long double x); + * This file implements the PowerPC 128-bit double-double -> int64_t conversion + */ #include "DD.h" #include @@ -10,42 +12,43 @@ uint64_t __fixtfdi(long double input) { const DD x = { .ld = input }; - const doublebits hibits = { .d = x.hi }; + const doublebits hibits = { .d = x.s.hi }; const uint32_t absHighWord = (uint32_t)(hibits.x >> 32) & UINT32_C(0x7fffffff); const uint32_t absHighWordMinusOne = absHighWord - UINT32_C(0x3ff00000); - // If (1.0 - tiny) <= input < 0x1.0p63: + /* If (1.0 - tiny) <= input < 0x1.0p63: */ if (UINT32_C(0x03f00000) > absHighWordMinusOne) { - // Do an unsigned conversion of the absolute value, then restore the sign. + /* Do an unsigned conversion of the absolute value, then restore the sign. */ const int unbiasedHeadExponent = absHighWordMinusOne >> 20; - int64_t result = hibits.x & INT64_C(0x000fffffffffffff); // mantissa(hi) - result |= INT64_C(0x0010000000000000); // matissa(hi) with implicit bit - result <<= 10; // mantissa(hi) with one zero preceeding bit. + int64_t result = hibits.x & INT64_C(0x000fffffffffffff); /* mantissa(hi) */ + result |= INT64_C(0x0010000000000000); /* matissa(hi) with implicit bit */ + result <<= 10; /* mantissa(hi) with one zero preceeding bit. */ const int64_t hiNegationMask = ((int64_t)(hibits.x)) >> 63; - // If the tail is non-zero, we need to patch in the tail bits. - if (0.0 != x.lo) + /* If the tail is non-zero, we need to patch in the tail bits. */ + if (0.0 != x.s.lo) { - const doublebits lobits = { .d = x.lo }; + const doublebits lobits = { .d = x.s.lo }; int64_t tailMantissa = lobits.x & INT64_C(0x000fffffffffffff); tailMantissa |= INT64_C(0x0010000000000000); - // At this point we have the mantissa of |tail| - // We need to negate it if head and tail have different signs. + /* At this point we have the mantissa of |tail| */ + /* We need to negate it if head and tail have different signs. */ const int64_t loNegationMask = ((int64_t)(lobits.x)) >> 63; const int64_t negationMask = loNegationMask ^ hiNegationMask; tailMantissa = (tailMantissa ^ negationMask) - negationMask; - // Now we have the mantissa of tail as a signed 2s-complement integer + /* Now we have the mantissa of tail as a signed 2s-complement integer */ const int biasedTailExponent = (int)(lobits.x >> 52) & 0x7ff; - // Shift the tail mantissa into the right position, accounting for the - // bias of 10 that we shifted the head mantissa by. + /* Shift the tail mantissa into the right position, accounting for the + * bias of 10 that we shifted the head mantissa by. + */ tailMantissa >>= (unbiasedHeadExponent - (biasedTailExponent - (1023 - 10))); result += tailMantissa; @@ -53,36 +56,37 @@ uint64_t __fixtfdi(long double input) result >>= (62 - unbiasedHeadExponent); - // Restore the sign of the result and return + /* Restore the sign of the result and return */ result = (result ^ hiNegationMask) - hiNegationMask; return result; } - // Edge cases handled here: + /* Edge cases handled here: */ - // |x| < 1, result is zero. - if (1.0 > __builtin_fabs(x.hi)) + /* |x| < 1, result is zero. */ + if (1.0 > __builtin_fabs(x.s.hi)) return INT64_C(0); - // x very close to INT64_MIN, care must be taken to see which side we are on. - if (x.hi == -0x1.0p63) { + /* x very close to INT64_MIN, care must be taken to see which side we are on. */ + if (x.s.hi == -0x1.0p63) { int64_t result = INT64_MIN; - if (0.0 < x.lo) + if (0.0 < x.s.lo) { - // If the tail is positive, the correct result is something other than INT64_MIN. - // we'll need to figure out what it is. - - const doublebits lobits = { .d = x.lo }; + /* If the tail is positive, the correct result is something other than INT64_MIN. + * we'll need to figure out what it is. + */ + + const doublebits lobits = { .d = x.s.lo }; int64_t tailMantissa = lobits.x & INT64_C(0x000fffffffffffff); tailMantissa |= INT64_C(0x0010000000000000); - // Now we negate the tailMantissa + /* Now we negate the tailMantissa */ tailMantissa = (tailMantissa ^ INT64_C(-1)) + INT64_C(1); - // And shift it by the appropriate amount + /* And shift it by the appropriate amount */ const int biasedTailExponent = (int)(lobits.x >> 52) & 0x7ff; tailMantissa >>= 1075 - biasedTailExponent; @@ -92,8 +96,8 @@ uint64_t __fixtfdi(long double input) return result; } - // Signed overflows, infinities, and NaNs - if (x.hi > 0.0) + /* Signed overflows, infinities, and NaNs */ + if (x.s.hi > 0.0) return INT64_MAX; else return INT64_MIN; diff --git a/lib/ppc/fixunstfdi.c b/lib/ppc/fixunstfdi.c index 35ce3a912..1fb524881 100644 --- a/lib/ppc/fixunstfdi.c +++ b/lib/ppc/fixunstfdi.c @@ -1,8 +1,9 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// uint64_t __fixunstfdi(long double x); -// This file implements the PowerPC 128-bit double-double -> uint64_t conversion +/* uint64_t __fixunstfdi(long double x); */ +/* This file implements the PowerPC 128-bit double-double -> uint64_t conversion */ #include "DD.h" #include @@ -10,37 +11,38 @@ uint64_t __fixunstfdi(long double input) { const DD x = { .ld = input }; - const doublebits hibits = { .d = x.hi }; + const doublebits hibits = { .d = x.s.hi }; const uint32_t highWordMinusOne = (uint32_t)(hibits.x >> 32) - UINT32_C(0x3ff00000); - // If (1.0 - tiny) <= input < 0x1.0p64: + /* If (1.0 - tiny) <= input < 0x1.0p64: */ if (UINT32_C(0x04000000) > highWordMinusOne) { const int unbiasedHeadExponent = highWordMinusOne >> 20; - uint64_t result = hibits.x & UINT64_C(0x000fffffffffffff); // mantissa(hi) - result |= UINT64_C(0x0010000000000000); // matissa(hi) with implicit bit - result <<= 11; // mantissa(hi) left aligned in the int64 field. + uint64_t result = hibits.x & UINT64_C(0x000fffffffffffff); /* mantissa(hi) */ + result |= UINT64_C(0x0010000000000000); /* matissa(hi) with implicit bit */ + result <<= 11; /* mantissa(hi) left aligned in the int64 field. */ - // If the tail is non-zero, we need to patch in the tail bits. - if (0.0 != x.lo) + /* If the tail is non-zero, we need to patch in the tail bits. */ + if (0.0 != x.s.lo) { - const doublebits lobits = { .d = x.lo }; + const doublebits lobits = { .d = x.s.lo }; int64_t tailMantissa = lobits.x & INT64_C(0x000fffffffffffff); tailMantissa |= INT64_C(0x0010000000000000); - // At this point we have the mantissa of |tail| + /* At this point we have the mantissa of |tail| */ const int64_t negationMask = ((int64_t)(lobits.x)) >> 63; tailMantissa = (tailMantissa ^ negationMask) - negationMask; - // Now we have the mantissa of tail as a signed 2s-complement integer + /* Now we have the mantissa of tail as a signed 2s-complement integer */ const int biasedTailExponent = (int)(lobits.x >> 52) & 0x7ff; - // Shift the tail mantissa into the right position, accounting for the - // bias of 11 that we shifted the head mantissa by. + /* Shift the tail mantissa into the right position, accounting for the + * bias of 11 that we shifted the head mantissa by. + */ tailMantissa >>= (unbiasedHeadExponent - (biasedTailExponent - (1023 - 11))); result += tailMantissa; @@ -50,8 +52,8 @@ uint64_t __fixunstfdi(long double input) return result; } - // Edge cases are handled here, with saturation. - if (1.0 > x.hi) + /* Edge cases are handled here, with saturation. */ + if (1.0 > x.s.hi) return UINT64_C(0); else return UINT64_MAX; diff --git a/lib/ppc/floatditf.c b/lib/ppc/floatditf.c index 081dc8cbe..ed23dc84d 100644 --- a/lib/ppc/floatditf.c +++ b/lib/ppc/floatditf.c @@ -1,8 +1,9 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// long double __floatditf(long long x); -// This file implements the PowerPC long long -> long double conversion +/* long double __floatditf(long long x); */ +/* This file implements the PowerPC long long -> long double conversion */ #include "DD.h" #include @@ -13,21 +14,23 @@ long double __floatditf(int64_t a) { static const double twop52 = 0x1.0p52; doublebits low = { .d = twop52 }; - low.x |= a & UINT64_C(0x00000000ffffffff); // 0x1.0p52 + low 32 bits of a. + low.x |= a & UINT64_C(0x00000000ffffffff); /* 0x1.0p52 + low 32 bits of a. */ const double high_addend = (double)((int32_t)(a >> 32))*twop32 - twop52; - // At this point, we have two double precision numbers - // high_addend and low.d, and we wish to return their sum - // as a canonicalized long double: - - // This implementation sets the inexact flag spuriously. - // This could be avoided, but at some substantial cost. - + /* At this point, we have two double precision numbers + * high_addend and low.d, and we wish to return their sum + * as a canonicalized long double: + */ + + /* This implementation sets the inexact flag spuriously. + * This could be avoided, but at some substantial cost. + */ + DD result; - result.hi = high_addend + low.d; - result.lo = (high_addend - result.hi) + low.d; + result.s.hi = high_addend + low.d; + result.s.lo = (high_addend - result.s.hi) + low.d; return result.ld; diff --git a/lib/ppc/floatunditf.c b/lib/ppc/floatunditf.c index 63f0b4467..20a3b71b3 100644 --- a/lib/ppc/floatunditf.c +++ b/lib/ppc/floatunditf.c @@ -1,15 +1,16 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// long double __floatunditf(unsigned long long x); -// This file implements the PowerPC unsigned long long -> long double conversion +/* long double __floatunditf(unsigned long long x); */ +/* This file implements the PowerPC unsigned long long -> long double conversion */ #include "DD.h" #include long double __floatunditf(uint64_t a) { - // Begins with an exact copy of the code from __floatundidf + /* Begins with an exact copy of the code from __floatundidf */ static const double twop52 = 0x1.0p52; static const double twop84 = 0x1.0p84; @@ -18,22 +19,23 @@ long double __floatunditf(uint64_t a) { doublebits high = { .d = twop84 }; doublebits low = { .d = twop52 }; - high.x |= a >> 32; // 0x1.0p84 + high 32 bits of a - low.x |= a & UINT64_C(0x00000000ffffffff); // 0x1.0p52 + low 32 bits of a + high.x |= a >> 32; /* 0x1.0p84 + high 32 bits of a */ + low.x |= a & UINT64_C(0x00000000ffffffff); /* 0x1.0p52 + low 32 bits of a */ const double high_addend = high.d - twop84_plus_twop52; - // At this point, we have two double precision numbers - // high_addend and low.d, and we wish to return their sum - // as a canonicalized long double: - - // This implementation sets the inexact flag spuriously. - // This could be avoided, but at some substantial cost. + /* At this point, we have two double precision numbers + * high_addend and low.d, and we wish to return their sum + * as a canonicalized long double: + */ + + /* This implementation sets the inexact flag spuriously. */ + /* This could be avoided, but at some substantial cost. */ DD result; - result.hi = high_addend + low.d; - result.lo = (high_addend - result.hi) + low.d; + result.s.hi = high_addend + low.d; + result.s.lo = (high_addend - result.s.hi) + low.d; return result.ld; diff --git a/lib/ppc/gcc_qadd.c b/lib/ppc/gcc_qadd.c index eb3fdd11e..c388c7e99 100644 --- a/lib/ppc/gcc_qadd.c +++ b/lib/ppc/gcc_qadd.c @@ -1,9 +1,11 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// long double __gcc_qadd(long double x, long double y); -// This file implements the PowerPC 128-bit double-double add operation. -// This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) +/* long double __gcc_qadd(long double x, long double y); + * This file implements the PowerPC 128-bit double-double add operation. + * This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) + */ #include "DD.h" @@ -13,33 +15,33 @@ long double __gcc_qadd(long double x, long double y) DD dst = { .ld = x }, src = { .ld = y }; - register double A = dst.hi, a = dst.lo, - B = src.hi, b = src.lo; + register double A = dst.s.hi, a = dst.s.lo, + B = src.s.hi, b = src.s.lo; - // If both operands are zero: + /* If both operands are zero: */ if ((A == 0.0) && (B == 0.0)) { - dst.hi = A + B; - dst.lo = 0.0; + dst.s.hi = A + B; + dst.s.lo = 0.0; return dst.ld; } - // If either operand is NaN or infinity: + /* If either operand is NaN or infinity: */ const doublebits abits = { .d = A }; const doublebits bbits = { .d = B }; if ((((uint32_t)(abits.x >> 32) & infinityHi) == infinityHi) || (((uint32_t)(bbits.x >> 32) & infinityHi) == infinityHi)) { - dst.hi = A + B; - dst.lo = 0.0; + dst.s.hi = A + B; + dst.s.lo = 0.0; return dst.ld; } - // If the computation overflows: - // This may be playing things a little bit fast and loose, but it will do for a start. + /* If the computation overflows: */ + /* This may be playing things a little bit fast and loose, but it will do for a start. */ const double testForOverflow = A + (B + (a + b)); const doublebits testbits = { .d = testForOverflow }; if (((uint32_t)(testbits.x >> 32) & infinityHi) == infinityHi) { - dst.hi = testForOverflow; - dst.lo = 0.0; + dst.s.hi = testForOverflow; + dst.s.lo = 0.0; return dst.ld; } @@ -67,8 +69,8 @@ long double __gcc_qadd(long double x, long double y) else w = T + Y; - dst.hi = Y = W + w; - dst.lo = (W - Y) + w; + dst.s.hi = Y = W + w; + dst.s.lo = (W - Y) + w; return dst.ld; } diff --git a/lib/ppc/gcc_qdiv.c b/lib/ppc/gcc_qdiv.c index 53e6c55ec..70aa00b64 100644 --- a/lib/ppc/gcc_qdiv.c +++ b/lib/ppc/gcc_qdiv.c @@ -1,9 +1,11 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// long double __gcc_qdiv(long double x, long double y); -// This file implements the PowerPC 128-bit double-double division operation. -// This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) +/* long double __gcc_qdiv(long double x, long double y); + * This file implements the PowerPC 128-bit double-double division operation. + * This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) + */ #include "DD.h" @@ -12,25 +14,25 @@ long double __gcc_qdiv(long double a, long double b) static const uint32_t infinityHi = UINT32_C(0x7ff00000); DD dst = { .ld = a }, src = { .ld = b }; - register double x = dst.hi, x1 = dst.lo, - y = src.hi, y1 = src.lo; + register double x = dst.s.hi, x1 = dst.s.lo, + y = src.s.hi, y1 = src.s.lo; double yHi, yLo, qHi, qLo; double yq, tmp, q; q = x / y; - // Detect special cases + /* Detect special cases */ if (q == 0.0) { - dst.hi = q; - dst.lo = 0.0; + dst.s.hi = q; + dst.s.lo = 0.0; return dst.ld; } const doublebits qBits = { .d = q }; if (((uint32_t)(qBits.x >> 32) & infinityHi) == infinityHi) { - dst.hi = q; - dst.lo = 0.0; + dst.s.hi = q; + dst.s.lo = 0.0; return dst.ld; } @@ -46,8 +48,8 @@ long double __gcc_qdiv(long double a, long double b) tmp = ((tmp + x1) - y1 * q) / y; x = q + tmp; - dst.lo = (q - x) + tmp; - dst.hi = x; + dst.s.lo = (q - x) + tmp; + dst.s.hi = x; return dst.ld; } diff --git a/lib/ppc/gcc_qmul.c b/lib/ppc/gcc_qmul.c index 26d899ee8..fb4c5164c 100644 --- a/lib/ppc/gcc_qmul.c +++ b/lib/ppc/gcc_qmul.c @@ -1,9 +1,11 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// long double __gcc_qmul(long double x, long double y); -// This file implements the PowerPC 128-bit double-double multiply operation. -// This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) +/* long double __gcc_qmul(long double x, long double y); + * This file implements the PowerPC 128-bit double-double multiply operation. + * This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) + */ #include "DD.h" @@ -12,29 +14,29 @@ long double __gcc_qmul(long double x, long double y) static const uint32_t infinityHi = UINT32_C(0x7ff00000); DD dst = { .ld = x }, src = { .ld = y }; - register double A = dst.hi, a = dst.lo, - B = src.hi, b = src.lo; + register double A = dst.s.hi, a = dst.s.lo, + B = src.s.hi, b = src.s.lo; double aHi, aLo, bHi, bLo; double ab, tmp, tau; ab = A * B; - // Detect special cases + /* Detect special cases */ if (ab == 0.0) { - dst.hi = ab; - dst.lo = 0.0; + dst.s.hi = ab; + dst.s.lo = 0.0; return dst.ld; } const doublebits abBits = { .d = ab }; if (((uint32_t)(abBits.x >> 32) & infinityHi) == infinityHi) { - dst.hi = ab; - dst.lo = 0.0; + dst.s.hi = ab; + dst.s.lo = 0.0; return dst.ld; } - // Generic cases handled here. + /* Generic cases handled here. */ aHi = high26bits(A); bHi = high26bits(B); aLo = A - aHi; @@ -44,8 +46,8 @@ long double __gcc_qmul(long double x, long double y) tmp += (A * b + a * B); tau = ab + tmp; - dst.lo = (ab - tau) + tmp; - dst.hi = tau; + dst.s.lo = (ab - tau) + tmp; + dst.s.hi = tau; return dst.ld; } diff --git a/lib/ppc/gcc_qsub.c b/lib/ppc/gcc_qsub.c index f77deaa4f..4f1f7ac70 100644 --- a/lib/ppc/gcc_qsub.c +++ b/lib/ppc/gcc_qsub.c @@ -1,9 +1,11 @@ -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +/* This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + */ -// long double __gcc_qsub(long double x, long double y); -// This file implements the PowerPC 128-bit double-double add operation. -// This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) +/* long double __gcc_qsub(long double x, long double y); + * This file implements the PowerPC 128-bit double-double add operation. + * This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!) + */ #include "DD.h" @@ -13,33 +15,33 @@ long double __gcc_qsub(long double x, long double y) DD dst = { .ld = x }, src = { .ld = y }; - register double A = dst.hi, a = dst.lo, - B = -src.hi, b = -src.lo; + register double A = dst.s.hi, a = dst.s.lo, + B = -src.s.hi, b = -src.s.lo; - // If both operands are zero: + /* If both operands are zero: */ if ((A == 0.0) && (B == 0.0)) { - dst.hi = A + B; - dst.lo = 0.0; + dst.s.hi = A + B; + dst.s.lo = 0.0; return dst.ld; } - // If either operand is NaN or infinity: + /* If either operand is NaN or infinity: */ const doublebits abits = { .d = A }; const doublebits bbits = { .d = B }; if ((((uint32_t)(abits.x >> 32) & infinityHi) == infinityHi) || (((uint32_t)(bbits.x >> 32) & infinityHi) == infinityHi)) { - dst.hi = A + B; - dst.lo = 0.0; + dst.s.hi = A + B; + dst.s.lo = 0.0; return dst.ld; } - // If the computation overflows: - // This may be playing things a little bit fast and loose, but it will do for a start. + /* If the computation overflows: */ + /* This may be playing things a little bit fast and loose, but it will do for a start. */ const double testForOverflow = A + (B + (a + b)); const doublebits testbits = { .d = testForOverflow }; if (((uint32_t)(testbits.x >> 32) & infinityHi) == infinityHi) { - dst.hi = testForOverflow; - dst.lo = 0.0; + dst.s.hi = testForOverflow; + dst.s.lo = 0.0; return dst.ld; } @@ -67,8 +69,8 @@ long double __gcc_qsub(long double x, long double y) else w = T + Y; - dst.hi = Y = W + w; - dst.lo = (W - Y) + w; + dst.s.hi = Y = W + w; + dst.s.lo = (W - Y) + w; return dst.ld; } diff --git a/lib/ppc/multc3.c b/lib/ppc/multc3.c index 0944263b2..9d17a2c6b 100644 --- a/lib/ppc/multc3.c +++ b/lib/ppc/multc3.c @@ -10,14 +10,14 @@ #endif /* INFINITY */ #define makeFinite(x) { \ - (x).hi = __builtin_copysign(isinf((x).hi) ? 1.0 : 0.0, (x).hi); \ - (x).lo = 0.0; \ + (x).s.hi = __builtin_copysign(isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ + (x).s.lo = 0.0; \ } #define zeroNaN(x) { \ - if (isnan((x).hi)) { \ - (x).hi = __builtin_copysign(0.0, (x).hi); \ - (x).lo = 0.0; \ + if (isnan((x).s.hi)) { \ + (x).s.hi = __builtin_copysign(0.0, (x).s.hi); \ + (x).s.lo = 0.0; \ } \ } @@ -36,7 +36,7 @@ __multc3(long double a, long double b, long double c, long double d) DD real = { .ld = __gcc_qsub(ac,bd) }; DD imag = { .ld = __gcc_qadd(ad,bc) }; - if (isnan(real.hi) && isnan(imag.hi)) + if (isnan(real.s.hi) && isnan(imag.s.hi)) { int recalc = 0; @@ -45,7 +45,7 @@ __multc3(long double a, long double b, long double c, long double d) DD cDD = { .ld = c }; DD dDD = { .ld = d }; - if (isinf(aDD.hi) || isinf(bDD.hi)) + if (isinf(aDD.s.hi) || isinf(bDD.s.hi)) { makeFinite(aDD); makeFinite(bDD); @@ -54,7 +54,7 @@ __multc3(long double a, long double b, long double c, long double d) recalc = 1; } - if (isinf(cDD.hi) || isinf(dDD.hi)) + if (isinf(cDD.s.hi) || isinf(dDD.s.hi)) { makeFinite(cDD); makeFinite(dDD); @@ -70,7 +70,7 @@ __multc3(long double a, long double b, long double c, long double d) DD adDD = { .ld = ad }; DD bcDD = { .ld = bc }; - if (isinf(acDD.hi) || isinf(bdDD.hi) || isinf(adDD.hi) || isinf(bcDD.hi)) + if (isinf(acDD.s.hi) || isinf(bdDD.s.hi) || isinf(adDD.s.hi) || isinf(bcDD.s.hi)) { zeroNaN(aDD); zeroNaN(bDD); @@ -82,10 +82,10 @@ __multc3(long double a, long double b, long double c, long double d) if (recalc) { - real.hi = INFINITY * (aDD.hi*cDD.hi - bDD.hi*dDD.hi); - real.lo = 0.0; - imag.hi = INFINITY * (aDD.hi*dDD.hi + bDD.hi*cDD.hi); - imag.lo = 0.0; + real.s.hi = INFINITY * (aDD.s.hi*cDD.s.hi - bDD.s.hi*dDD.s.hi); + real.s.lo = 0.0; + imag.s.hi = INFINITY * (aDD.s.hi*dDD.s.hi + bDD.s.hi*cDD.s.hi); + imag.s.lo = 0.0; } } diff --git a/lib/subvti3.c b/lib/subvti3.c index a2f764688..244641044 100644 --- a/lib/subvti3.c +++ b/lib/subvti3.c @@ -38,4 +38,4 @@ __subvti3(ti_int a, ti_int b) return s; } -#endif +#endif /* __x86_64 */ diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c index 4f0382d82..d2900cae4 100644 --- a/lib/ucmpdi2.c +++ b/lib/ucmpdi2.c @@ -26,13 +26,13 @@ __ucmpdi2(du_int a, du_int b) x.all = a; udwords y; y.all = b; - if (x.high < y.high) + if (x.s.high < y.s.high) return 0; - if (x.high > y.high) + if (x.s.high > y.s.high) return 2; - if (x.low < y.low) + if (x.s.low < y.s.low) return 0; - if (x.low > y.low) + if (x.s.low > y.s.low) return 2; return 1; } diff --git a/lib/udivmoddi4.c b/lib/udivmoddi4.c index 977a391e8..92742302c 100644 --- a/lib/udivmoddi4.c +++ b/lib/udivmoddi4.c @@ -33,41 +33,41 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) udwords r; unsigned sr; /* special cases, X is unknown, K != 0 */ - if (n.high == 0) + if (n.s.high == 0) { - if (d.high == 0) + if (d.s.high == 0) { /* 0 X * --- * 0 X */ if (rem) - *rem = n.low % d.low; - return n.low / d.low; + *rem = n.s.low % d.s.low; + return n.s.low / d.s.low; } /* 0 X * --- * K X */ if (rem) - *rem = n.low; + *rem = n.s.low; return 0; } - /* n.high != 0 */ - if (d.low == 0) + /* n.s.high != 0 */ + if (d.s.low == 0) { - if (d.high == 0) + if (d.s.high == 0) { /* K X * --- * 0 0 */ if (rem) - *rem = n.high % d.low; - return n.high / d.low; + *rem = n.s.high % d.s.low; + return n.s.high / d.s.low; } - /* d.high != 0 */ - if (n.low == 0) + /* d.s.high != 0 */ + if (n.s.low == 0) { /* K 0 * --- @@ -75,31 +75,31 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) */ if (rem) { - r.high = n.high % d.high; - r.low = 0; + r.s.high = n.s.high % d.s.high; + r.s.low = 0; *rem = r.all; } - return n.high / d.high; + return n.s.high / d.s.high; } /* K K * --- * K 0 */ - if ((d.high & (d.high - 1)) == 0) /* if d is a power of 2 */ + if ((d.s.high & (d.s.high - 1)) == 0) /* if d is a power of 2 */ { if (rem) { - r.low = n.low; - r.high = n.high & (d.high - 1); + r.s.low = n.s.low; + r.s.high = n.s.high & (d.s.high - 1); *rem = r.all; } - return n.high >> __builtin_ctz(d.high); + return n.s.high >> __builtin_ctz(d.s.high); } /* K K * --- * K 0 */ - sr = __builtin_clz(d.high) - __builtin_clz(n.high); + sr = __builtin_clz(d.s.high) - __builtin_clz(n.s.high); /* 0 <= sr <= n_uword_bits - 2 or sr large */ if (sr > n_uword_bits - 2) { @@ -110,75 +110,75 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) ++sr; /* 1 <= sr <= n_uword_bits - 1 */ /* q.all = n.all << (n_udword_bits - sr); */ - q.low = 0; - q.high = n.low << (n_uword_bits - sr); + q.s.low = 0; + q.s.high = n.s.low << (n_uword_bits - sr); /* r.all = n.all >> sr; */ - r.high = n.high >> sr; - r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); } - else /* d.low != 0 */ + else /* d.s.low != 0 */ { - if (d.high == 0) + if (d.s.high == 0) { /* K X * --- * 0 K */ - if ((d.low & (d.low - 1)) == 0) /* if d is a power of 2 */ + if ((d.s.low & (d.s.low - 1)) == 0) /* if d is a power of 2 */ { if (rem) - *rem = n.low & (d.low - 1); - if (d.low == 1) + *rem = n.s.low & (d.s.low - 1); + if (d.s.low == 1) return n.all; - unsigned sr = __builtin_ctz(d.low); - q.high = n.high >> sr; - q.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); + unsigned sr = __builtin_ctz(d.s.low); + q.s.high = n.s.high >> sr; + q.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); return q.all; } /* K X * --- *0 K */ - sr = 1 + n_uword_bits + __builtin_clz(d.low) - __builtin_clz(n.high); + sr = 1 + n_uword_bits + __builtin_clz(d.s.low) - __builtin_clz(n.s.high); /* 2 <= sr <= n_udword_bits - 1 * q.all = n.all << (n_udword_bits - sr); * r.all = n.all >> sr; * if (sr == n_uword_bits) * { - * q.low = 0; - * q.high = n.low; - * r.high = 0; - * r.low = n.high; + * q.s.low = 0; + * q.s.high = n.s.low; + * r.s.high = 0; + * r.s.low = n.s.high; * } * else if (sr < n_uword_bits) // 2 <= sr <= n_uword_bits - 1 * { - * q.low = 0; - * q.high = n.low << (n_uword_bits - sr); - * r.high = n.high >> sr; - * r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); + * q.s.low = 0; + * q.s.high = n.s.low << (n_uword_bits - sr); + * r.s.high = n.s.high >> sr; + * r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); * } * else // n_uword_bits + 1 <= sr <= n_udword_bits - 1 * { - * q.low = n.low << (n_udword_bits - sr); - * q.high = (n.high << (n_udword_bits - sr)) | - * (n.low >> (sr - n_uword_bits)); - * r.high = 0; - * r.low = n.high >> (sr - n_uword_bits); + * q.s.low = n.s.low << (n_udword_bits - sr); + * q.s.high = (n.s.high << (n_udword_bits - sr)) | + * (n.s.low >> (sr - n_uword_bits)); + * r.s.high = 0; + * r.s.low = n.s.high >> (sr - n_uword_bits); * } */ - q.low = (n.low << (n_udword_bits - sr)) & + q.s.low = (n.s.low << (n_udword_bits - sr)) & ((si_int)(n_uword_bits - sr) >> (n_uword_bits-1)); - q.high = ((n.low << ( n_uword_bits - sr)) & + q.s.high = ((n.s.low << ( n_uword_bits - sr)) & ((si_int)(sr - n_uword_bits - 1) >> (n_uword_bits-1))) | - (((n.high << (n_udword_bits - sr)) | - (n.low >> (sr - n_uword_bits))) & + (((n.s.high << (n_udword_bits - sr)) | + (n.s.low >> (sr - n_uword_bits))) & ((si_int)(n_uword_bits - sr) >> (n_uword_bits-1))); - r.high = (n.high >> sr) & + r.s.high = (n.s.high >> sr) & ((si_int)(sr - n_uword_bits) >> (n_uword_bits-1)); - r.low = ((n.high >> (sr - n_uword_bits)) & + r.s.low = ((n.s.high >> (sr - n_uword_bits)) & ((si_int)(n_uword_bits - sr - 1) >> (n_uword_bits-1))) | - (((n.high << (n_uword_bits - sr)) | - (n.low >> sr)) & + (((n.s.high << (n_uword_bits - sr)) | + (n.s.low >> sr)) & ((si_int)(sr - n_uword_bits) >> (n_uword_bits-1))); } else @@ -187,7 +187,7 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) * --- * K K */ - sr = __builtin_clz(d.high) - __builtin_clz(n.high); + sr = __builtin_clz(d.s.high) - __builtin_clz(n.s.high); /* 0 <= sr <= n_uword_bits - 1 or sr large */ if (sr > n_uword_bits - 1) { @@ -198,24 +198,24 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) ++sr; /* 1 <= sr <= n_uword_bits */ /* q.all = n.all << (n_udword_bits - sr); */ - q.low = 0; - q.high = n.low << (n_uword_bits - sr); + q.s.low = 0; + q.s.high = n.s.low << (n_uword_bits - sr); /* r.all = n.all >> sr; * if (sr < n_uword_bits) * { - * r.high = n.high >> sr; - * r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); + * r.s.high = n.s.high >> sr; + * r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr); * } * else * { - * r.high = 0; - * r.low = n.high; + * r.s.high = 0; + * r.s.low = n.s.high; * } */ - r.high = (n.high >> sr) & + r.s.high = (n.s.high >> sr) & ((si_int)(sr - n_uword_bits) >> (n_uword_bits-1)); - r.low = (n.high << (n_uword_bits - sr)) | - ((n.low >> sr) & + r.s.low = (n.s.high << (n_uword_bits - sr)) | + ((n.s.low >> sr) & ((si_int)(sr - n_uword_bits) >> (n_uword_bits-1))); } } @@ -229,10 +229,10 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) for (; sr > 0; --sr) { /* r:q = ((r:q) << 1) | carry */ - r.high = (r.high << 1) | (r.low >> (n_uword_bits - 1)); - r.low = (r.low << 1) | (q.high >> (n_uword_bits - 1)); - q.high = (q.high << 1) | (q.low >> (n_uword_bits - 1)); - q.low = (q.low << 1) | carry; + r.s.high = (r.s.high << 1) | (r.s.low >> (n_uword_bits - 1)); + r.s.low = (r.s.low << 1) | (q.s.high >> (n_uword_bits - 1)); + q.s.high = (q.s.high << 1) | (q.s.low >> (n_uword_bits - 1)); + q.s.low = (q.s.low << 1) | carry; /* carry = 0; * if (r.all >= d.all) * { diff --git a/lib/udivmodti4.c b/lib/udivmodti4.c index 12fa49cda..53b407256 100644 --- a/lib/udivmodti4.c +++ b/lib/udivmodti4.c @@ -35,41 +35,41 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) utwords r; unsigned sr; /* special cases, X is unknown, K != 0 */ - if (n.high == 0) + if (n.s.high == 0) { - if (d.high == 0) + if (d.s.high == 0) { /* 0 X * --- * 0 X */ if (rem) - *rem = n.low % d.low; - return n.low / d.low; + *rem = n.s.low % d.s.low; + return n.s.low / d.s.low; } /* 0 X * --- * K X */ if (rem) - *rem = n.low; + *rem = n.s.low; return 0; } - /* n.high != 0 */ - if (d.low == 0) + /* n.s.high != 0 */ + if (d.s.low == 0) { - if (d.high == 0) + if (d.s.high == 0) { /* K X * --- * 0 0 */ if (rem) - *rem = n.high % d.low; - return n.high / d.low; + *rem = n.s.high % d.s.low; + return n.s.high / d.s.low; } - /* d.high != 0 */ - if (n.low == 0) + /* d.s.high != 0 */ + if (n.s.low == 0) { /* K 0 * --- @@ -77,31 +77,31 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) */ if (rem) { - r.high = n.high % d.high; - r.low = 0; + r.s.high = n.s.high % d.s.high; + r.s.low = 0; *rem = r.all; } - return n.high / d.high; + return n.s.high / d.s.high; } /* K K * --- * K 0 */ - if ((d.high & (d.high - 1)) == 0) /* if d is a power of 2 */ + if ((d.s.high & (d.s.high - 1)) == 0) /* if d is a power of 2 */ { if (rem) { - r.low = n.low; - r.high = n.high & (d.high - 1); + r.s.low = n.s.low; + r.s.high = n.s.high & (d.s.high - 1); *rem = r.all; } - return n.high >> __builtin_ctzll(d.high); + return n.s.high >> __builtin_ctzll(d.s.high); } /* K K * --- * K 0 */ - sr = __builtin_clzll(d.high) - __builtin_clzll(n.high); + sr = __builtin_clzll(d.s.high) - __builtin_clzll(n.s.high); /* 0 <= sr <= n_udword_bits - 2 or sr large */ if (sr > n_udword_bits - 2) { @@ -112,76 +112,76 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) ++sr; /* 1 <= sr <= n_udword_bits - 1 */ /* q.all = n.all << (n_utword_bits - sr); */ - q.low = 0; - q.high = n.low << (n_udword_bits - sr); + q.s.low = 0; + q.s.high = n.s.low << (n_udword_bits - sr); /* r.all = n.all >> sr; */ - r.high = n.high >> sr; - r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); + r.s.high = n.s.high >> sr; + r.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); } - else /* d.low != 0 */ + else /* d.s.low != 0 */ { - if (d.high == 0) + if (d.s.high == 0) { /* K X * --- * 0 K */ - if ((d.low & (d.low - 1)) == 0) /* if d is a power of 2 */ + if ((d.s.low & (d.s.low - 1)) == 0) /* if d is a power of 2 */ { if (rem) - *rem = n.low & (d.low - 1); - if (d.low == 1) + *rem = n.s.low & (d.s.low - 1); + if (d.s.low == 1) return n.all; - unsigned sr = __builtin_ctzll(d.low); - q.high = n.high >> sr; - q.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); + unsigned sr = __builtin_ctzll(d.s.low); + q.s.high = n.s.high >> sr; + q.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); return q.all; } /* K X * --- * 0 K */ - sr = 1 + n_udword_bits + __builtin_clzll(d.low) - - __builtin_clzll(n.high); + sr = 1 + n_udword_bits + __builtin_clzll(d.s.low) + - __builtin_clzll(n.s.high); /* 2 <= sr <= n_utword_bits - 1 * q.all = n.all << (n_utword_bits - sr); * r.all = n.all >> sr; * if (sr == n_udword_bits) * { - * q.low = 0; - * q.high = n.low; - * r.high = 0; - * r.low = n.high; + * q.s.low = 0; + * q.s.high = n.s.low; + * r.s.high = 0; + * r.s.low = n.s.high; * } * else if (sr < n_udword_bits) // 2 <= sr <= n_udword_bits - 1 * { - * q.low = 0; - * q.high = n.low << (n_udword_bits - sr); - * r.high = n.high >> sr; - * r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); + * q.s.low = 0; + * q.s.high = n.s.low << (n_udword_bits - sr); + * r.s.high = n.s.high >> sr; + * r.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); * } * else // n_udword_bits + 1 <= sr <= n_utword_bits - 1 * { - * q.low = n.low << (n_utword_bits - sr); - * q.high = (n.high << (n_utword_bits - sr)) | - * (n.low >> (sr - n_udword_bits)); - * r.high = 0; - * r.low = n.high >> (sr - n_udword_bits); + * q.s.low = n.s.low << (n_utword_bits - sr); + * q.s.high = (n.s.high << (n_utword_bits - sr)) | + * (n.s.low >> (sr - n_udword_bits)); + * r.s.high = 0; + * r.s.low = n.s.high >> (sr - n_udword_bits); * } */ - q.low = (n.low << (n_utword_bits - sr)) & + q.s.low = (n.s.low << (n_utword_bits - sr)) & ((di_int)(int)(n_udword_bits - sr) >> (n_udword_bits-1)); - q.high = ((n.low << ( n_udword_bits - sr)) & + q.s.high = ((n.s.low << ( n_udword_bits - sr)) & ((di_int)(int)(sr - n_udword_bits - 1) >> (n_udword_bits-1))) | - (((n.high << (n_utword_bits - sr)) | - (n.low >> (sr - n_udword_bits))) & + (((n.s.high << (n_utword_bits - sr)) | + (n.s.low >> (sr - n_udword_bits))) & ((di_int)(int)(n_udword_bits - sr) >> (n_udword_bits-1))); - r.high = (n.high >> sr) & + r.s.high = (n.s.high >> sr) & ((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1)); - r.low = ((n.high >> (sr - n_udword_bits)) & + r.s.low = ((n.s.high >> (sr - n_udword_bits)) & ((di_int)(int)(n_udword_bits - sr - 1) >> (n_udword_bits-1))) | - (((n.high << (n_udword_bits - sr)) | - (n.low >> sr)) & + (((n.s.high << (n_udword_bits - sr)) | + (n.s.low >> sr)) & ((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1))); } else @@ -190,7 +190,7 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) * --- * K K */ - sr = __builtin_clzll(d.high) - __builtin_clzll(n.high); + sr = __builtin_clzll(d.s.high) - __builtin_clzll(n.s.high); /*0 <= sr <= n_udword_bits - 1 or sr large */ if (sr > n_udword_bits - 1) { @@ -201,24 +201,24 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) ++sr; /* 1 <= sr <= n_udword_bits */ /* q.all = n.all << (n_utword_bits - sr); */ - q.low = 0; - q.high = n.low << (n_udword_bits - sr); + q.s.low = 0; + q.s.high = n.s.low << (n_udword_bits - sr); /* r.all = n.all >> sr; * if (sr < n_udword_bits) * { - * r.high = n.high >> sr; - * r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); + * r.s.high = n.s.high >> sr; + * r.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr); * } * else * { - * r.high = 0; - * r.low = n.high; + * r.s.high = 0; + * r.s.low = n.s.high; * } */ - r.high = (n.high >> sr) & + r.s.high = (n.s.high >> sr) & ((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1)); - r.low = (n.high << (n_udword_bits - sr)) | - ((n.low >> sr) & + r.s.low = (n.s.high << (n_udword_bits - sr)) | + ((n.s.low >> sr) & ((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1))); } } @@ -232,10 +232,10 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) for (; sr > 0; --sr) { /* r:q = ((r:q) << 1) | carry */ - r.high = (r.high << 1) | (r.low >> (n_udword_bits - 1)); - r.low = (r.low << 1) | (q.high >> (n_udword_bits - 1)); - q.high = (q.high << 1) | (q.low >> (n_udword_bits - 1)); - q.low = (q.low << 1) | carry; + r.s.high = (r.s.high << 1) | (r.s.low >> (n_udword_bits - 1)); + r.s.low = (r.s.low << 1) | (q.s.high >> (n_udword_bits - 1)); + q.s.high = (q.s.high << 1) | (q.s.low >> (n_udword_bits - 1)); + q.s.low = (q.s.low << 1) | carry; /* carry = 0; * if (r.all >= d.all) * { @@ -253,4 +253,4 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) return q.all; } -#endif +#endif /* __x86_64 */ -- cgit v1.2.3