This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch: parentheses and remaining prototypes


As promised, the parentheses cleanup. I've also fixed a few remaining
prototype issues. I didn't change things where I couldn't find a
simple solution (e.g. getpass.c vs. sig* - see also my "odd bits"
posting), or where the nicer code would compile into worse assembler
(strcpy.c; could be worked around by using while ((...)), but I
strongly dislike this particular idiom).

That's all for now.

- Werner

---------------------------------- ChangeLog ----------------------------------

2000-08-23  Werner Almesberger  <Werner.Almesberger@epfl.ch>
	* libc/stdlib/mprec.c (ulp, b2d, d2b): changed a few expressions
	like  x << y-z  to the equivalent  x << (y-z)
	* libc/stdlib/mprec.c (d2b): changed  if (y = d1) { ... to
	if (d1) { y = d1; ...  and likewise for  if (k = lo0bits ...
	* libc/reent/reent.c: included stdlib.h for "_free_r" prototype
	* libc/unix/getpass.c (getpass): moved "echo" assignment out of if
	* libc/unix/ttyname.c: included string.h for "strcpy" prototype
	* libc/unix/getcwd.c (ISDOT): added parentheses to clarify && and ||
	precedence
	* libc/include/sys/unistd.h: added "vfork" prototype (for popen.c)
	* libc/include/sys/unistd.h: added "_execve" prototype (for execl.c,
	execle.c, execv.c, and execve.c)
	* libc/posix/popen.c (popen): added parentheses to clarify && and ||
	precedence
	* libm/math/e_cosh.c (__ieee754_cosh): changed parentheses to
	clarify && and || precendence (and to remove pascalism)
	* libm/math/e_sinh.c (__ieee754_sinh): idem
	* libm/math/s_infconst.c: added another pair of braces to all
	initializers for __infinity (need three: for __infinity[1] array,
	for union __dmath, and for i[2])

------------------------------------ patch ------------------------------------

--- orig/newlib/libc/stdlib/mprec.c	Mon Apr 17 19:10:17 2000
+++ src/newlib/libc/stdlib/mprec.c	Wed Aug 23 21:36:05 2000
@@ -663,7 +663,7 @@
 	  word0 (a) = 0;
 	  L -= Exp_shift;
 #ifndef _DOUBLE_IS_32BITS
-	  word1 (a) = L >= 31 ? 1 : 1 << 31 - L;
+	  word1 (a) = L >= 31 ? 1 : 1 << (31 - L);
 #endif
 	}
     }
@@ -710,7 +710,7 @@
       d0 = Exp_1 | y << k | z >> (32 - k);
       y = xa > xa0 ? *--xa : 0;
 #ifndef _DOUBLE_IS_32BITS
-      d1 = z << k | y >> 32 - k;
+      d1 = z << k | y >> (32 - k);
 #endif
     }
   else
@@ -794,11 +794,13 @@
 #endif
 #ifdef Pack_32
 #ifndef _DOUBLE_IS_32BITS
-  if (y = d1)
+  if (d1)
     {
-      if (k = lo0bits (&y))
+      y = d1;
+      k = lo0bits (&y);
+      if (k)
 	{
-	  x[0] = y | z << 32 - k;
+	  x[0] = y | z << (32 - k);
 	  z >>= k;
 	}
       else
@@ -820,9 +822,11 @@
 #endif
     }
 #else
-  if (y = d1)
+  if (d1)
     {
-      if (k = lo0bits (&y))
+      y = d1;
+      k = lo0bits (&y);
+      if (k)
 	if (k >= 16)
 	  {
 	    x[0] = y | z << 32 - k & 0xffff;
--- orig/newlib/libc/reent/reent.c	Thu Feb 17 20:39:47 2000
+++ src/newlib/libc/reent/reent.c	Wed Aug 23 21:46:42 2000
@@ -10,6 +10,7 @@
 	non-rentrant functions, such as strtok.
 */
 
+#include <stdlib.h>
 #include <reent.h>
 
 /* Interim cleanup code */
--- orig/newlib/libc/unix/getpass.c	Thu Feb 17 20:39:51 2000
+++ src/newlib/libc/unix/getpass.c	Wed Aug 23 21:59:18 2000
@@ -70,7 +70,8 @@
    */
   omask = sigblock (sigmask (SIGINT) | sigmask (SIGTSTP));
   (void) tcgetattr (fileno (fp), &term);
-  if (echo = (term.c_lflag & ECHO))
+  echo = (term.c_lflag & ECHO);
+  if (echo)
     {
       term.c_lflag &= ~ECHO;
       (void) tcsetattr (fileno (fp), TCSAFLUSH, &term);
--- orig/newlib/libc/unix/ttyname.c	Thu Feb 17 20:39:51 2000
+++ src/newlib/libc/unix/ttyname.c	Wed Aug 23 22:01:36 2000
@@ -41,6 +41,7 @@
 #include <dirent.h>
 #include <termios.h>
 #include <unistd.h>
+#include <string.h>
 #include <paths.h>
 #include <_syslist.h>
 
--- orig/newlib/libc/unix/getcwd.c	Thu Feb 17 20:39:51 2000
+++ src/newlib/libc/unix/getcwd.c	Wed Aug 23 22:02:52 2000
@@ -49,7 +49,7 @@
 
 #define	ISDOT(dp) \
 	(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
-	    dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
+	    (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
 
 #ifndef _REENT_ONLY
 
--- orig/newlib/libc/include/sys/unistd.h	Tue Aug  1 22:51:51 2000
+++ src/newlib/libc/include/sys/unistd.h	Wed Aug 23 22:20:14 2000
@@ -75,6 +75,10 @@
 int     _EXFUN(unlink, (const char *__path ));
 int     _EXFUN(write, (int __fildes, const void *__buf, size_t __nbyte ));
 
+#ifndef	_POSIX_SOURCE
+pid_t   _EXFUN(vfork, (void ));
+#endif /* _POSIX_SOURCE */
+
 /* Provide prototypes for most of the _<systemcall> names that are
    provided in newlib for some compilers.  */
 int     _EXFUN(_close, (int __fildes ));
@@ -86,6 +90,7 @@
 void *  _EXFUN(_sbrk,  (size_t __incr));
 int     _EXFUN(_unlink, (const char *__path ));
 int     _EXFUN(_write, (int __fildes, const void *__buf, size_t __nbyte ));
+int     _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
 
 #if defined(__CYGWIN__) || defined(__rtems__)
 unsigned _EXFUN(usleep, (unsigned int __useconds));
--- orig/newlib/libc/posix/popen.c	Thu Feb 17 20:39:47 2000
+++ src/newlib/libc/posix/popen.c	Wed Aug 23 22:19:18 2000
@@ -71,7 +71,7 @@
 	FILE *iop;
 	int pdes[2], pid;
 
-	if (*type != 'r' && *type != 'w' || type[1]) {
+	if ((*type != 'r' && *type != 'w') || type[1]) {
 		errno = EINVAL;
 		return (NULL);
 	}
--- orig/newlib/libm/math/e_cosh.c	Thu Feb 17 20:39:51 2000
+++ src/newlib/libm/math/e_cosh.c	Wed Aug 23 22:22:02 2000
@@ -80,7 +80,7 @@
     /* |x| in [log(maxdouble), overflowthresold] */
 	GET_LOW_WORD(lx,x);
 	if (ix<0x408633CE || 
-	      (ix==0x408633ce)&&(lx<=(__uint32_t)0x8fb9f87d)) {
+	      (ix==0x408633ce && lx<=(__uint32_t)0x8fb9f87d)) {
 	    w = __ieee754_exp(half*fabs(x));
 	    t = half*w;
 	    return t*w;
--- orig/newlib/libm/math/e_sinh.c	Thu Feb 17 20:39:51 2000
+++ src/newlib/libm/math/e_sinh.c	Wed Aug 23 22:23:21 2000
@@ -73,7 +73,7 @@
 
     /* |x| in [log(maxdouble), overflowthresold] */
 	GET_LOW_WORD(lx,x);
-	if (ix<0x408633CE || (ix==0x408633ce)&&(lx<=(__uint32_t)0x8fb9f87d)) {
+	if (ix<0x408633CE || (ix==0x408633ce && lx<=(__uint32_t)0x8fb9f87d)) {
 	    w = __ieee754_exp(0.5*fabs(x));
 	    t = h*w;
 	    return t*w;
--- orig/newlib/libm/math/s_infconst.c	Fri Jul 28 18:27:54 2000
+++ src/newlib/libm/math/s_infconst.c	Wed Aug 23 22:28:37 2000
@@ -6,10 +6,10 @@
 
 #ifndef _DOUBLE_IS_32BITS
 #ifdef __IEEE_BIG_ENDIAN
-const union __dmath __infinity[1] = {{ 0x7ff00000, 0 }};
+const union __dmath __infinity[1] = {{{ 0x7ff00000, 0 }}};
 #else
-const union __dmath __infinity[1] = {{ 0, 0x7ff00000 }};
+const union __dmath __infinity[1] = {{{ 0, 0x7ff00000 }}};
 #endif
 #else /* defined (_DOUBLE_IS_32BITS) */
-const union __dmath __infinity[1] = {{ 0x7f800000, 0 }};
+const union __dmath __infinity[1] = {{{ 0x7f800000, 0 }}};
 #endif /* defined (_DOUBLE_IS_32BITS) */

-- 
  _________________________________________________________________________
 / Werner Almesberger, ICA, EPFL, CH       werner.almesberger@ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]