Message-ID: <002201c337b1$b3fdce40$0100a8c0@acp42g> From: "Andrew Cottrell" To: Subject: LIBC C files patches to build with GCC 3.3 (non math files) Date: Sat, 21 Jun 2003 14:58:05 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Reply-To: djgpp-workers AT delorie DOT com All, Below are a set of patches in order to build the non math C files with GCC 3.3. Included is an updated ieee.h patch that was needed for these files. Are the changes okay? I do not know if the goqmem.c changes are the best way to go, but it works. Andrew *** \djgppcvs\src\libc\ansi\stdlib\strtod.c Mon Jun 9 10:45:24 2003 --- strtod.c Sat Jun 21 14:21:40 2003 *************** strtod(const char *s, char **sret) *** 73,84 **** /* Handle NAN and NAN(). */ if ( ! strnicmp( "NAN", s, 3 ) ) { ! double tmp_d = NAN; ! double_t n = *(double_t *)(&tmp_d); if ( sign < 0 ) { ! n.sign = 1; } if( s[3] == '(' ) --- 73,85 ---- /* Handle NAN and NAN(). */ if ( ! strnicmp( "NAN", s, 3 ) ) { ! _double_union_t t; ! ! t.d = NAN; if ( sign < 0 ) { ! t.dt.sign = 1; } if( s[3] == '(' ) *************** strtod(const char *s, char **sret) *** 92,105 **** mantissa_bits = mantissa_bits & 0xfffffffffffffULL; if( mantissa_bits ) { ! n.mantissal = mantissa_bits & 0xffffffff; ! n.mantissah = (mantissa_bits >> 32) & 0xfffff; } if( sret ) { *sret = endptr+1; } ! return *(double *)(&n); } /* The subject sequence didn't match NAN(), so match --- 93,106 ---- mantissa_bits = mantissa_bits & 0xfffffffffffffULL; if( mantissa_bits ) { ! t.dt.mantissal = mantissa_bits & 0xffffffff; ! t.dt.mantissah = (mantissa_bits >> 32) & 0xfffff; } if( sret ) { *sret = endptr+1; } ! return (t.d); } /* The subject sequence didn't match NAN(), so match *************** strtod(const char *s, char **sret) *** 110,116 **** { *sret = unconst((&s[3]), char *); } ! return *(double *)(&n); } /* Handle ordinary numbers. */ --- 111,117 ---- { *sret = unconst((&s[3]), char *); } ! return (t.d); } /* Handle ordinary numbers. */ *** \djgppcvs\src\libc\ansi\stdlib\strtold.c Mon Jun 9 10:45:24 2003 --- strtold.c Sat Jun 21 14:24:02 2003 *************** strtold(const char *s, char **sret) *** 70,81 **** /* Handle NAN and NAN(). */ if ( ! strnicmp( "NAN", s, 3 ) ) { ! long double ld = NAN; ! long_double_t n = *(long_double_t *)(&ld); if ( sign < 0 ) { ! n.sign = 1; } if( s[3] == '(' ) --- 70,83 ---- /* Handle NAN and NAN(). */ if ( ! strnicmp( "NAN", s, 3 ) ) { ! longdouble_union_t t; ! ! t.ld = NAN; ! if ( sign < 0 ) { ! t.ldt.sign = 1; } if( s[3] == '(' ) *************** strtold(const char *s, char **sret) *** 91,104 **** bit. */ if( mantissa_bits ) { ! n.mantissal = mantissa_bits & 0xffffffff; ! n.mantissah = ((mantissa_bits >> 32) & 0xffffffff ) | 0x80000000; } if( sret ) { *sret = endptr+1; } ! return *(long double *)(&n); } /* The subject sequence didn't match NAN(), so match --- 93,106 ---- bit. */ if( mantissa_bits ) { ! t.ldt.mantissal = mantissa_bits & 0xffffffff; ! t.ldt.mantissah = ((mantissa_bits >> 32) & 0xffffffff ) | 0x80000000; } if( sret ) { *sret = endptr+1; } ! return (t.ld); } /* The subject sequence didn't match NAN(), so match *************** strtold(const char *s, char **sret) *** 109,115 **** { *sret = unconst((&s[3]), char *); } ! return *(long double *)(&n);; } /* Handle ordinary numbers. */ --- 111,117 ---- { *sret = unconst((&s[3]), char *); } ! return (t.ld); } /* Handle ordinary numbers. */ *** \djgppcvs\src\libc\ansi\stdio\doprnt.c Sun Jan 26 16:51:40 2003 --- doprnt.c Sat Jun 21 14:29:08 2003 *************** *** 17,22 **** --- 17,23 ---- #include #include #include + #include static char decimal = '.'; *************** _doprnt(const char *fmt0, va_list argp, *** 274,287 **** } else { ! struct IEEExp { ! unsigned manl:32; ! unsigned manh:32; ! unsigned exp:15; ! unsigned sign:1; ! } ip = *(struct IEEExp *)&_ldouble; ! if (ip.sign) neg_ldouble = 1; else neg_ldouble = 0; --- 275,285 ---- } else { ! longdouble_union_t ip; ! ! ip.ld = _ldouble; ! if (ip.ldt.sign) neg_ldouble = 1; else neg_ldouble = 0; *************** exponentl(char *p, int expv, unsigned ch *** 892,921 **** static int isspeciall(long double d, char *bufp) { ! struct IEEExp { unsigned manl:32; unsigned manh:32; unsigned exp:15; unsigned sign:1; ! } *ip = (struct IEEExp *)&d; nan_p = 0; /* don't assume the static is 0 (emacs) */ /* Unnormals: the MSB of mantissa is non-zero, but the exponent is not zero either. */ ! if ((ip->manh & 0x80000000U) == 0 && ip->exp != 0) { ! if (ip->sign) *bufp++ = '-'; strcpy(bufp, UNNORMAL_REP); ! return strlen(bufp) + ip->sign; } ! if (ip->exp != 0x7fff) return(0); ! if ((ip->manh & 0x7fffffff) || ip->manl) { strcpy(bufp, "NaN"); ! nan_p = ip->sign ? -1 : 1; /* kludge: we don't need the sign, it's not nice, but it should work */ } else --- 890,929 ---- static int isspeciall(long double d, char *bufp) { ! typedef struct { unsigned manl:32; unsigned manh:32; unsigned exp:15; unsigned sign:1; ! } IEEExp ; ! ! typedef union ! { ! IEEExp ip; ! long double ldouble; /* double and long double precision arguments */ ! } ip_union ; ! ! ip_union ip; ! ! ip.ldouble = d; nan_p = 0; /* don't assume the static is 0 (emacs) */ /* Unnormals: the MSB of mantissa is non-zero, but the exponent is not zero either. */ ! if ((ip.ip.manh & 0x80000000U) == 0 && ip.ip.exp != 0) { ! if (ip.ip.sign) *bufp++ = '-'; strcpy(bufp, UNNORMAL_REP); ! return strlen(bufp) + ip.ip.sign; } ! if (ip.ip.exp != 0x7fff) return(0); ! if ((ip.ip.manh & 0x7fffffff) || ip.ip.manl) { strcpy(bufp, "NaN"); ! nan_p = ip.ip.sign ? -1 : 1; /* kludge: we don't need the sign, it's not nice, but it should work */ } else *** \djgppcvs\src\libc\go32\goqmem.c Mon Jul 17 19:31:36 1995 --- goqmem.c Fri Jun 20 20:17:22 2003 *************** *** 3,18 **** unsigned long _go32_dpmi_remaining_physical_memory(void) { ! _go32_dpmi_meminfo info; ! _go32_dpmi_get_free_memory_information(&info); ! if (info.available_physical_pages) ! return info.available_physical_pages * 4096; ! return info.available_memory; } unsigned long _go32_dpmi_remaining_virtual_memory(void) { ! _go32_dpmi_meminfo info; ! _go32_dpmi_get_free_memory_information(&info); ! return info.available_memory; } --- 3,27 ---- unsigned long _go32_dpmi_remaining_physical_memory(void) { ! union a_union ! { ! _go32_dpmi_meminfo go32info; ! __dpmi_free_mem_info dpmiinfo; ! } info; ! ! _go32_dpmi_get_free_memory_information(&info.dpmiinfo); ! if (info.go32info.available_physical_pages) ! return info.go32info.available_physical_pages * 4096; ! return info.go32info.available_memory; } unsigned long _go32_dpmi_remaining_virtual_memory(void) { ! union a_union ! { ! _go32_dpmi_meminfo go32info; ! __dpmi_free_mem_info dpmiinfo; ! } info; ! _go32_dpmi_get_free_memory_information(&info.dpmiinfo); ! return info.go32info.available_memory; } *** \djgppcvs\include\libc\ieee.h Wed Feb 5 18:10:52 2003 --- ieee.h Sat Jun 21 14:44:38 2003 *************** typedef struct { *** 38,43 **** --- 38,62 ---- unsigned sign:1; } long_double_t; + + typedef union + { + double d; + double_t dt; + } _double_union_t; + + typedef union + { + long double ld; + long_double_t ldt; + } longdouble_union_t; + + typedef union + { + float f; + long l; + } _float_long_union; + #endif /* !_POSIX_SOURCE */ #endif /* !__STRICT_ANSI__ */ #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */