cleaner gcc build process
[nestedvm.git] / upstream / patches / newlib-mips.patch
1 diff -urN ../newlib-1.11.0.orig/libgloss/configure ./libgloss/configure
2 --- ../newlib-1.11.0.orig/libgloss/configure    Tue Nov 25 09:05:13 2003
3 +++ ./libgloss/configure        Mon Nov 24 20:12:14 2003
4 @@ -762,6 +762,9 @@
5    mips*-*-pe)
6         configdirs="wince"
7         ;;
8 +  mips*-unknown-elf*)
9 +        configdirs="${configdirs}"
10 +        ;;
11    mips*-*-*)
12         configdirs="${configdirs} mips testsuite"
13         ;;
14 @@ -818,7 +821,7 @@
15  # Extract the first word of "gcc", so it can be a program name with args.
16  set dummy gcc; ac_word=$2
17  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
18 -echo "configure:822: checking for $ac_word" >&5
19 +echo "configure:825: checking for $ac_word" >&5
20  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
21    echo $ac_n "(cached) $ac_c" 1>&6
22  else
23 @@ -848,7 +851,7 @@
24    # Extract the first word of "cc", so it can be a program name with args.
25  set dummy cc; ac_word=$2
26  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
27 -echo "configure:852: checking for $ac_word" >&5
28 +echo "configure:855: checking for $ac_word" >&5
29  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
30    echo $ac_n "(cached) $ac_c" 1>&6
31  else
32 @@ -897,7 +900,7 @@
33  fi
34  
35  echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
36 -echo "configure:901: checking whether we are using GNU C" >&5
37 +echo "configure:904: checking whether we are using GNU C" >&5
38  if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
39    echo $ac_n "(cached) $ac_c" 1>&6
40  else
41 @@ -906,7 +909,7 @@
42    yes;
43  #endif
44  EOF
45 -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
46 +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:913: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
47    ac_cv_prog_gcc=yes
48  else
49    ac_cv_prog_gcc=no
50 @@ -921,7 +924,7 @@
51    ac_save_CFLAGS="$CFLAGS"
52    CFLAGS=
53    echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
54 -echo "configure:925: checking whether ${CC-cc} accepts -g" >&5
55 +echo "configure:928: checking whether ${CC-cc} accepts -g" >&5
56  if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
57    echo $ac_n "(cached) $ac_c" 1>&6
58  else
59 @@ -953,7 +956,7 @@
60  # Extract the first word of "ar", so it can be a program name with args.
61  set dummy ar; ac_word=$2
62  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
63 -echo "configure:957: checking for $ac_word" >&5
64 +echo "configure:960: checking for $ac_word" >&5
65  if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
66    echo $ac_n "(cached) $ac_c" 1>&6
67  else
68 @@ -987,7 +990,7 @@
69  # Extract the first word of "ranlib", so it can be a program name with args.
70  set dummy ranlib; ac_word=$2
71  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
72 -echo "configure:991: checking for $ac_word" >&5
73 +echo "configure:994: checking for $ac_word" >&5
74  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
75    echo $ac_n "(cached) $ac_c" 1>&6
76  else
77 diff -urN ../newlib-1.11.0.orig/libgloss/configure.in ./libgloss/configure.in
78 --- ../newlib-1.11.0.orig/libgloss/configure.in Tue Nov 25 09:05:13 2003
79 +++ ./libgloss/configure.in     Mon Nov 24 20:12:14 2003
80 @@ -73,6 +73,9 @@
81    mips*-*-pe)
82         configdirs="wince"
83         ;;
84 +  mips*-unknown-elf*)
85 +        configdirs="${configdirs}"
86 +        ;;
87    mips*-*-*)
88         configdirs="${configdirs} mips testsuite"
89         ;;
90 diff -urN ../newlib-1.11.0.orig/newlib/configure.host ./newlib/configure.host
91 --- ../newlib-1.11.0.orig/newlib/configure.host Tue Nov 25 09:05:13 2003
92 +++ ./newlib/configure.host     Tue Nov 25 08:30:02 2003
93 @@ -359,6 +359,9 @@
94    mips*-dec-*)
95         sys_dir=decstation
96         ;;
97 +  mips-unknown-elf*)
98 +        posix_dir=posix
99 +        ;;
100    mmix-knuth-mmixware)
101         sys_dir=mmixware
102         ;;
103 @@ -508,6 +511,10 @@
104         newlib_cflags="${newlib_cflags}"
105         syscall_dir=syscalls
106         ;;
107 +  mips*-unknown-elf*)
108 +       newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL -DHAVE_OPENDIR -DWANT_PRINTF_LONG_LONG"
109 +       syscall_dir=syscalls
110 +        ;;
111    mmix-*)
112         syscall_dir=syscalls
113         # We need every symbol 32-bit aligned, so the invalid
114 diff -urN ../newlib-1.11.0.orig/newlib/libc/include/paths.h ./newlib/libc/include/paths.h
115 --- ../newlib-1.11.0.orig/newlib/libc/include/paths.h   Thu Feb 17 14:39:46 2000
116 +++ ./newlib/libc/include/paths.h       Tue Nov 25 09:48:09 2003
117 @@ -3,5 +3,6 @@
118  
119  #define _PATH_DEV      "/dev/"
120  #define _PATH_BSHELL    "/bin/sh"
121 +#define _PATH_DEVNULL "/dev/null"
122  
123  #endif /* _PATHS_H_ */
124 diff -urN ../newlib-1.11.0.orig/newlib/libc/include/stdlib.h ./newlib/libc/include/stdlib.h
125 --- ../newlib-1.11.0.orig/newlib/libc/include/stdlib.h  Fri Dec  6 13:58:50 2002
126 +++ ./newlib/libc/include/stdlib.h      Tue Nov 25 09:50:46 2003
127 @@ -158,10 +158,12 @@
128  _VOID  _EXFUN(cfree,(_PTR));
129  #else
130  char * _EXFUN(realpath,(const char *, char *));
131 +#endif
132  void   _EXFUN(unsetenv,(const char *__string));
133  void   _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
134  int    _EXFUN(random,(_VOID));
135  long   _EXFUN(srandom,(unsigned __seed));
136 +#ifdef __CYGWIN__
137  char *  _EXFUN(ptsname, (int));
138  int     _EXFUN(grantpt, (int));
139  int     _EXFUN(unlockpt,(int));
140 diff -urN ../newlib-1.11.0.orig/newlib/libc/include/sys/signal.h ./newlib/libc/include/sys/signal.h
141 --- ../newlib-1.11.0.orig/newlib/libc/include/sys/signal.h      Wed Jul 24 14:18:07 2002
142 +++ ./newlib/libc/include/sys/signal.h  Tue Nov 25 09:56:00 2003
143 @@ -142,6 +142,8 @@
144  int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
145  #endif
146  
147 +int _EXFUN(kill, (int, int));
148 +
149  /* protos for functions found in winsup sources for CYGWIN */
150  #if defined(__CYGWIN__) || defined(__rtems__)
151  #undef sigaddset
152 @@ -150,7 +152,6 @@
153     <sys/types.h> always defines pid_t to be int.  If that ever
154     changes, then we will need to do something else, perhaps along the
155     lines of <machine/types.h>.  */
156 -int _EXFUN(kill, (int, int));
157  int _EXFUN(killpg, (pid_t, int));
158  int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
159  int _EXFUN(sigaddset, (sigset_t *, const int));
160 diff -urN ../newlib-1.11.0.orig/newlib/libc/include/sys/stat.h ./newlib/libc/include/sys/stat.h
161 --- ../newlib-1.11.0.orig/newlib/libc/include/sys/stat.h        Sat Feb 23 15:46:28 2002
162 +++ ./newlib/libc/include/sys/stat.h    Tue Nov 25 09:41:35 2003
163 @@ -127,7 +127,7 @@
164  int    _EXFUN(stat,( const char *__path, struct stat *__sbuf ));
165  mode_t _EXFUN(umask,( mode_t __mask ));
166  
167 -#if defined(__rtems__) || defined(__CYGWIN__)
168 +#if defined(__rtems__) || defined(__CYGWIN__) || 1
169  int    _EXFUN(lstat,( const char *__path, struct stat *__buf ));
170  int    _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
171  #endif
172 diff -urN ../newlib-1.11.0.orig/newlib/libc/include/sys/unistd.h ./newlib/libc/include/sys/unistd.h
173 --- ../newlib-1.11.0.orig/newlib/libc/include/sys/unistd.h      Sun Aug 18 02:08:39 2002
174 +++ ./newlib/libc/include/sys/unistd.h  Tue Nov 25 09:46:58 2003
175 @@ -158,9 +158,9 @@
176  #endif
177  char * _EXFUN(mktemp, (char *));
178  int     _EXFUN(sync, (void));
179 +#endif
180  int     _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
181  int     _EXFUN(symlink, (const char *__name1, const char *__name2));
182 -#endif
183  
184  #define        F_OK    0
185  #define        R_OK    4
186 diff -urN ../newlib-1.11.0.orig/newlib/libc/include/sys/utime.h ./newlib/libc/include/sys/utime.h
187 --- ../newlib-1.11.0.orig/newlib/libc/include/sys/utime.h       2000-02-17 14:39:46.000000000 -0500
188 +++ ./newlib/libc/include/sys/utime.h   2004-05-02 19:57:46.000000000 -0400
189 @@ -15,6 +15,8 @@
190    time_t modtime; 
191  };
192  
193 +extern int utime(const char *file, const struct utimbuf *buf);
194 +
195  #ifdef __cplusplus
196  };
197  #endif
198 diff -rNu ../newlib-1.11.0.orig/newlib/libc/include/sys/dirent.h ./newlib/libc/include/sys/dirent.h
199 --- ../newlib-1.11.0.orig/newlib/libc/include/sys/dirent.h      2000-02-17 14:39:46.000000000 -0500
200 +++ ./newlib/libc/include/sys/dirent.h  2004-05-03 01:17:15.000000000 -0400
201 @@ -1,15 +1,29 @@
202 -/* <dirent.h> includes <sys/dirent.h>, which is this file.  On a
203 -   system which supports <dirent.h>, this file is overridden by
204 -   dirent.h in the libc/sys/.../sys directory.  On a system which does
205 -   not support <dirent.h>, we will get this file which tries to find
206 -   any other <dirent.h> which may be lurking around.  If there isn't
207 -   one, the user will get an error indicating that there is no
208 -   <dirent.h>.  */
209 -
210  #ifdef __cplusplus
211  extern "C" {
212  #endif
213 -#include_next <dirent.h>
214 +
215 +#define MAXNAMLEN 4087
216 +    
217 +struct dirent {
218 +    unsigned long d_reclen;
219 +    unsigned long d_ino;
220 +    char d_name[MAXNAMLEN+1];
221 +};
222 +
223 +typedef struct {
224 +    int dd_fd;
225 +    char *dd_buf;
226 +    long dd_loc;
227 +    long dd_size;
228 +    long dd_len;
229 +} DIR;
230 +
231 +DIR *opendir (const char *);
232 +struct dirent *readdir (DIR *);
233 +int readdir_r(DIR *, struct dirent *, struct dirent **);
234 +void rewinddir (DIR *);
235 +int closedir (DIR *);
236 +
237  #ifdef __cplusplus
238  }
239  #endif
240 --- newlib/libc/include/sys/signal.h~   2004-05-07 02:06:28.000000000 -0400
241 +++ newlib/libc/include/sys/signal.h    2004-05-07 02:06:28.000000000 -0400
242 @@ -145,7 +145,7 @@
243  int _EXFUN(kill, (int, int));
244  
245  /* protos for functions found in winsup sources for CYGWIN */
246 -#if defined(__CYGWIN__) || defined(__rtems__)
247 +#if defined(__CYGWIN__) || defined(__rtems__) || 1
248  #undef sigaddset
249  #undef sigemptyset
250  /* The first argument to kill should be pid_t.  Right now
251 --- newlib/libc/include/sys/signal.h.bak        2004-05-09 23:15:15.000000000 -0400
252 +++ newlib/libc/include/sys/signal.h    2004-05-09 23:16:33.000000000 -0400
253 @@ -148,6 +148,9 @@
254  #if defined(__CYGWIN__) || defined(__rtems__) || 1
255  #undef sigaddset
256  #undef sigemptyset
257 +
258 +#include <sys/types.h>
259 +
260  /* The first argument to kill should be pid_t.  Right now
261     <sys/types.h> always defines pid_t to be int.  If that ever
262     changes, then we will need to do something else, perhaps along the
263 --- newlib/libc/include/stdlib.h.orig   2004-05-20 04:50:42.000000000 -0400
264 +++ newlib/libc/include/stdlib.h        2004-05-20 05:13:20.000000000 -0400
265 @@ -156,9 +156,8 @@
266  
267  #ifndef __CYGWIN__
268  _VOID  _EXFUN(cfree,(_PTR));
269 -#else
270 -char * _EXFUN(realpath,(const char *, char *));
271  #endif
272 +char * _EXFUN(realpath,(const char *, char *));
273  void   _EXFUN(unsetenv,(const char *__string));
274  void   _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
275  int    _EXFUN(random,(_VOID));
276 @@ -183,6 +182,8 @@
277  
278  _VOID  _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
279  
280 +int _EXFUN(daemon,(int,int));
281 +
282  #ifdef __CYGWIN__
283  #undef _malloc_r
284  #define _malloc_r(r, s) malloc (s)
285 --- newlib/libc/include/sys/resource.h.orig     2004-05-19 21:37:03.000000000 -0400
286 +++ newlib/libc/include/sys/resource.h  2004-05-20 00:14:32.000000000 -0400
287 @@ -11,5 +11,12 @@
288         struct timeval ru_stime;        /* system time used */
289  };
290  
291 +#define PRIO_PROCESS 0
292 +#define PRIO_MIN -20
293 +#define PRIO_MAX 20
294 +
295 +int getpriority(int which, int who);
296 +int setpriority(int which, int who, int prio);
297 +
298  #endif
299  
300 --- newlib/libc/include/sys/signal.h.orig       2004-05-19 23:21:25.000000000 -0400
301 +++ newlib/libc/include/sys/signal.h    2004-05-20 00:12:55.000000000 -0400
302 @@ -117,7 +117,7 @@
303  
304  #define SA_NOCLDSTOP 1  /* only value supported now for sa_flags */
305  
306 -#ifdef __CYGWIN__
307 +#if 1
308  # define SA_RESTART   0x10000000 /* Restart syscall on signal return.  */
309  # define SA_NODEFER   0x40000000 /* Don't automatically block the signal when
310                                      its handler is being executed.  */