summaryrefslogtreecommitdiff
path: root/lang/gnat/files/freebsdgcc28-patches
blob: 50b520273a144d8d90b46dd49d427f96cc663e91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
--- config/i386/freebsd.h.orig	Fri Dec  5 04:15:34 1997
+++ config/i386/freebsd.h	Sun Mar 21 17:59:06 1999
@@ -26,8 +26,18 @@
 
 /* The svr4 ABI for the i386 says that records and unions are returned
    in memory.  */
+/* On FreeBSD, we do not. */
 #undef DEFAULT_PCC_STRUCT_RETURN
-#define DEFAULT_PCC_STRUCT_RETURN 1
+#define DEFAULT_PCC_STRUCT_RETURN 0
+
+/* This gets defined in tm.h->linux.h->svr4.h, and keeps us from using
+   libraries compiled with the native cc, so undef it. */
+#undef NO_DOLLAR_IN_LABEL
+
+/* FreeBSD using ELF does not support DWARF2 unwinding mechanisms.
+   Thus, need the equivalent of "-fsjlj-exceptions" (use setjmp/longjmp
+   for exceptions).  */
+#define DWARF2_UNWIND_INFO 0
 
 /* This is how to output an element of a case-vector that is relative.
    This is only used for PIC code.  See comments by the `casesi' insn in
@@ -140,7 +150,7 @@
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
     
 #undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dunix -D__ELF__ -D__FreeBSD__=2 -Asystem(FreeBSD)"
+#define CPP_PREDEFINES "-Di386 -Dunix -D__ELF__ -D__FreeBSD__=3 -Asystem(FreeBSD) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
 
 #undef CPP_SPEC
 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
--- configure.orig	Sat Feb 28 18:02:02 1998
+++ configure	Mon Feb  8 11:51:44 1999
@@ -677,9 +677,9 @@
 if test -z "$ac_aux_dir"; then
   { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
 fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+ac_config_guess="/bin/sh $ac_aux_dir/config.guess"
+ac_config_sub="/bin/sh $ac_aux_dir/config.sub"
+ac_configure="/bin/sh $ac_aux_dir/configure" # This should be Cygnus configure.
 
 
 # Do some error checking and defaulting for the host and target type.
@@ -2797,6 +2797,20 @@
 	a29k-*-*)			# Default a29k environment.
 		use_collect2=yes
 		;;
+	alpha*-*-freebsd*)
+		tm_file=alpha/freebsd.h
+		# On FreeBSD, the headers are already ok, except for math.h. (??right??)
+		fixincludes=fixinc.math
+		fixincludes=fixinc.math
+		tmake_file=t-libc-ok
+		;;
+	alpha-*-openbsd*)
+		tm_file=alpha/openbsd.h
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		tmake_file=t-libc-ok
+		xmake_file=x-openbsd
+		;;
 	alpha*-*-linux-gnuecoff*)
 		tm_file="${tm_file} alpha/linux.h"
 		xm_file="${xm_file} alpha/xm-linux.h"
@@ -3158,6 +3172,14 @@
 		use_collect2=yes
 		fixincludes=Makefile.in
 		;;
+	hppa*-*-openbsd*)
+		target_cpu_default=1
+		tm_file="pa/pa-openbsd.h"
+		xm_file=pa/xm-openbsd.h
+		xmake_file=x-openbsd
+		use_collect2=yes
+		fixincludes=Makefile.in
+		;;
 	i370-*-mvs*)
 		;;
 	i[34567]86-ibm-aix*)		# IBM PS/2 running AIX
@@ -3256,20 +3278,20 @@
 # Next line turned off because both 386BSD and BSD/386 use GNU ld.
 #		use_collect2=yes
 		;;
-	i[34567]86-*-freebsdelf*)
-		tm_file="i386/i386.h i386/att.h linux.h i386/freebsd-elf.h i386/perform.h"
+	i[34567]86-*-freebsdaout*)
+		tm_file=i386/freebsd-aout.h
 		# On FreeBSD, the headers are already ok, except for math.h.
 		fixincludes=fixinc.math
 		tmake_file=i386/t-freebsd
-		gas=yes
-		gnu_ld=yes
-		stabs=yes
 		;;
 	i[34567]86-*-freebsd*)
-		tm_file=i386/freebsd.h
+		tm_file="i386/i386.h i386/att.h linux.h i386/freebsd.h i386/perform.h"
 		# On FreeBSD, the headers are already ok, except for math.h.
 		fixincludes=fixinc.math
 		tmake_file=i386/t-freebsd
+		gas=yes
+		gnu_ld=yes
+		stabs=yes
 		;;
 	i[34567]86-*-netbsd*)
 		tm_file=i386/netbsd.h
@@ -3277,6 +3299,13 @@
 		fixincludes=fixinc.math
 		tmake_file=t-netbsd
 		;;
+	i[34567]86-*-openbsd*)
+		tm_file=i386/openbsd.h
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		tmake_file=t-libc-ok
+		xmake_file=x-openbsd
+		;;
 	i[34567]86-*-coff*)
 		tm_file=i386/i386-coff.h
 		tmake_file=i386/t-i386bare
@@ -3964,6 +3993,13 @@
 		fixincludes=fixinc.math
 		tmake_file=t-netbsd
 		;;
+	m68k-*-openbsd*)
+		tm_file=m68k/openbsd.h
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		tmake_file=t-libc-ok
+		xmake_file=x-openbsd
+		;;
 	m68k-*-sysv3*)			# Motorola m68k's running system V.3
 		xm_file=m68k/xm-m68kv.h
 		xmake_file=m68k/x-m68kv
@@ -4273,6 +4309,20 @@
 			prefix=$native_prefix
 		fi
 		;;
+	mips*el-*-openbsd*)  		    # MIPS running OpenBSD
+		tm_file=mips/openbsd-le.h
+		xmake_file=x-openbsd
+		tmake_file=t-libc-ok
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		;;
+	mips*-*-openbsd*)	    # MIPS big-endian running OpenBSD
+		tm_file=mips/openbsd-be.h
+		xmake_file=x-openbsd
+		tmake_file=t-libc-ok
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		;;
 	mips-sony-bsd* | mips-sony-newsos*)	# Sony NEWS 3600 or risc/news.
 		tm_file=mips/news4.h
 		if [ x$stabs = xyes ]; then
@@ -4612,6 +4662,13 @@
 		fixincludes=fixinc.math
 		tmake_file=t-netbsd
 		;;
+	ns32k-*-openbsd*)
+		tm_file=ns32k/openbsd.h
+		tmake_file=t-libc-ok
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		xmake_file=x-openbsd
+		;;
         pdp11-*-bsd)
 		tm_file="${tm_file} pdp11/2bsd.h"
                 ;;
@@ -4625,10 +4682,23 @@
 	romp-*-aos*)
 		use_collect2=yes
 		;;
+	romp-*-openbsd*)
+		tm_file=romp/openbsd.h
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		xmake_file=romp/x-openbsd
+		;;
 	romp-*-mach*)
 		xmake_file=romp/x-mach
 		use_collect2=yes
 		;;
+	powerpc-*-*bsd*)
+		tm_file=rs6000/openbsd.h
+	        tmake_file=rs6000/t-openbsd
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		xmake_file=rs6000/x-openbsd
+		;;
 	powerpc-*-sysv* | powerpc-*-elf*)
 		tm_file=rs6000/sysv4.h
 		xm_file=rs6000/xm-sysv4.h
@@ -4841,6 +4911,13 @@
 		fixincludes=fixinc.math
 		tmake_file=t-netbsd
 		;;
+	sparc-*-openbsd*)
+		tm_file=sparc/openbsd.h
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		tmake_file=t-libc-ok
+		xmake_file=x-openbsd
+		;;
 	sparc-*-bsd*)
 		tm_file=sparc/bsd.h
 		;;
@@ -5009,6 +5086,14 @@
 		# On NetBSD, the headers are already okay, except for math.h.
 		fixincludes=fixinc.math
 		tmake_file=t-netbsd
+		float_format=vax
+		;;
+	vax-*-openbsd*)
+		tm_file=vax/openbsd.h
+		tmake_file="t-libc-ok vax/t-openbsd"
+		# On OpenBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		xmake_file=x-openbsd
 		float_format=vax
 		;;
 	vax-*-ultrix*)			# vaxen running ultrix
--- choose-temp.c.orig	Thu Dec  4 06:17:56 1997
+++ choose-temp.c	Tue Aug 11 04:05:05 1998
@@ -107,12 +107,17 @@
   base = try (getenv ("TMP"), base);
   base = try (getenv ("TEMP"), base);
 
+#ifdef COMMENT_OUT	/* XXX - P_tmpdir is not /tmp in 4.4BSD */
 #ifdef P_tmpdir
   base = try (P_tmpdir, base);
 #endif
+#endif  /* XXX */
 
   /* Try /usr/tmp, then /tmp.  */
+#ifdef COMMENT_OUT	/* XXX - want /tmp used, peroid.  Sometimes pkg_add can
+					 create a /usr/tmp, so beware. */
   base = try (usrtmp, base);
+#endif  /* XXX */
   base = try (tmp, base);
  
   /* If all else fails, use the current directory!  */
--- flags.h.orig	Wed Dec 31 05:02:33 1997
+++ flags.h	Wed Mar 31 00:08:39 1999
@@ -125,6 +125,10 @@
 
 extern int warn_aggregate_return;
 
+/* Nonzero means that -Wformat accepts certain non-ANSI formats.  */
+
+extern int flag_format_extensions;
+
 /* Nonzero if generating code to do profiling.  */
 
 extern int profile_flag;
@@ -215,6 +219,20 @@
    This is generally not a win.  */
 
 extern int flag_unroll_all_loops;
+
+/* Nonzero forces all invariant computations in loops to be moved
+   outside the loop. */
+
+extern int flag_move_all_movables;
+
+/* Nonzero forces all general induction variables in loops to be
+   strength reduced. */
+
+extern int flag_reduce_all_givs;
+
+/* Nonzero gets another run of loop_optimize performed. */
+
+extern int flag_rerun_loop_opt;
 
 /* Nonzero for -fcse-follow-jumps:
    have cse follow jumps to do a more extensive job.  */
--- toplev.c.orig	Wed Feb 25 18:04:46 1998
+++ toplev.c	Wed Mar 31 00:15:41 1999
@@ -463,6 +463,20 @@
 
 int flag_unroll_all_loops;
 
+/* Nonzero forces all invariant computations in loops to be moved
+   outside the loop. */
+
+int flag_move_all_movables = 0;
+
+/* Nonzero forces all general induction variables in loops to be
+   strength reduced. */
+
+int flag_reduce_all_givs = 0;
+
+/* Nonzero gets another run of loop_optimize performed. */
+
+int flag_rerun_loop_opt = 0;
+
 /* Nonzero for -fwritable-strings:
    store string constants in data segment and don't uniquize them.  */
 
@@ -691,6 +705,7 @@
   {"stack-check", &flag_stack_check, 1},
   {"bytecode", &output_bytecode, 1},
   {"check-memory-usage", &flag_check_memory_usage, 1},
+  {"format-extensions", &flag_format_extensions, 1},
   {"prefix-function-name", &flag_prefix_function_name, 1}
 };
 
@@ -880,6 +895,10 @@
   {"uninitialized", &warn_uninitialized, 1},
   {"inline", &warn_inline, 1}
 };
+
+/* Nonzero means that -Wformat accepts certain system-dependent formats.  */
+
+int flag_format_extensions = 0;
 
 /* Output files for assembler code (real compiler output)
    and debugging dumps.  */
--- loop.c.orig	Fri Feb  6 11:23:34 1998
+++ loop.c	Tue Aug 11 16:57:35 1998
@@ -1637,6 +1637,7 @@
 	     extra cost because something else was already moved.  */
 
 	  if (already_moved[regno]
+	      || flag_move_all_movables
 	      || (threshold * savings * m->lifetime) >= insn_count
 	      || (m->forces && m->forces->done
 		  && n_times_used[m->forces->regno] == 1))
@@ -3911,7 +3912,7 @@
 	     of such giv's whether or not we know they are used after the loop
 	     exit.  */
 
-	  if (v->lifetime * threshold * benefit < insn_count
+	  if (!flag_reduce_all_givs && v->lifetime * threshold * benefit < insn_count
 	      && ! bl->reversed)
 	    {
 	      if (loop_dump_stream)
--- cp/lex.c.orig	Wed Nov 26 12:13:20 1997
+++ cp/lex.c	Tue Aug 11 13:37:17 1998
@@ -3329,6 +3329,14 @@
 		  token_buffer[0] = '^';
 		  token_buffer[1] = 0;
 		}
+	      else if (ptr->token == NAMESPACE)
+		{
+		  static int warned;
+		  if (! warned)
+		    warning ("namespaces are mostly broken in this version of g++");
+
+		  warned = 1;
+		}
 
 	      value = (int) ptr->token;
 	    }
--- gcc.1.orig	Tue Feb 17 10:44:00 1998
+++ gcc.1	Tue Aug 11 13:30:01 1998
@@ -182,7 +182,7 @@
 \-Waggregate\-return
 \-Wcast\-align
 \-Wcast\-qual
-\-Wchar\-subscript
+\-Wchar\-subscripts
 \-Wcomment
 \-Wconversion
 \-Wenum\-clash
--- invoke.texi.orig	Tue Feb 17 10:54:05 1998
+++ invoke.texi	Tue Aug 11 13:29:38 1998
@@ -115,7 +115,7 @@
 @smallexample
 -fsyntax-only  -pedantic  -pedantic-errors
 -w  -W  -Wall  -Waggregate-return  -Wbad-function-cast
--Wcast-align  -Wcast-qual  -Wchar-subscript  -Wcomment
+-Wcast-align  -Wcast-qual  -Wchar-subscripts  -Wcomment
 -Wconversion  -Werror  -Wformat
 -Wid-clash-@var{len}  -Wimplicit -Wimplicit-int 
 -Wimplicit-function-declarations -Wimport  -Winline
@@ -153,6 +153,7 @@
 -frerun-cse-after-loop  -fschedule-insns
 -fschedule-insns2  -fstrength-reduce  -fthread-jumps
 -funroll-all-loops  -funroll-loops
+-fmove-all-movables  -freduce-all-givs  -frerun-loop-opt
 -O  -O0  -O1  -O2  -O3
 @end smallexample
 
@@ -2284,6 +2285,47 @@
 Perform the optimization of loop unrolling.  This is done for all loops
 and usually makes programs run more slowly.  @samp{-funroll-all-loops}
 implies @samp{-fstrength-reduce} as well as @samp{-frerun-cse-after-loop}.
+
+@item -fmove-all-movables
+Forces all invariant computations in loops to be moved
+outside the loop.
+This option is provided primarily to improve performance
+for some Fortran code, though it might improve code written
+in other languages.
+
+@emph{Note:} When compiling programs written in Fortran,
+this option is enabled by default.
+
+Analysis of Fortran code optimization and the resulting
+optimizations triggered by this option, and the
+@samp{-freduce-all-givs} and @samp{-frerun-loop-opt}
+options as well, were
+contributed by Toon Moene (@code{toon@@moene.indiv.nluug.nl}).
+
+Please let us (@code{fortran@@gnu.ai.mit.edu})
+know how use of these options affects
+the performance of your production code.
+We're very interested in code that runs @emph{slower}
+when these options are @emph{enabled}.
+
+@item -freduce-all-givs
+Forces all general-induction variables in loops to be
+strength-reduced.
+This option is provided primarily to improve performance
+for some Fortran code, though it might improve code written
+in other languages.
+
+@emph{Note:} When compiling programs written in Fortran,
+this option is enabled by default.
+
+@item -frerun-loop-opt
+Runs loop optimizations a second time.
+This option is provided primarily to improve performance
+for some Fortran code, though it might improve code written
+in other languages.
+
+@emph{Note:} When compiling programs written in Fortran,
+this option is enabled by default.
 
 @item -fno-peephole
 Disable any machine-specific peephole optimizations.
--- expmed.c.dist	Sat Nov  8 14:11:58 1997
+++ expmed.c	Thu Aug 13 11:18:13 1998
@@ -2249,7 +2249,8 @@
 	      rtx shift_subtarget = preserve ? 0 : accum;
 	      rtx add_target
 		= (opno == alg.ops - 1 && target != 0 && variant != add_variant
-		  ? target : 0);
+		   && ! preserve)
+		  ? target : 0;
 	      rtx accum_target = preserve ? 0 : accum;
 	      
 	      switch (alg.op[opno])
@@ -2716,6 +2717,7 @@
   optab optab1, optab2;
   int op1_is_constant, op1_is_pow2;
   int max_cost, extra_cost;
+  static HOST_WIDE_INT last_div_const = 0;
 
   op1_is_constant = GET_CODE (op1) == CONST_INT;
   op1_is_pow2 = (op1_is_constant
@@ -2825,8 +2827,15 @@
   size = GET_MODE_BITSIZE (mode);
 #endif
 
+  /* Only deduct something for a REM if the last divide done was
+     for a different constant.   Then set the constant of the last
+     divide.  */
   max_cost = div_cost[(int) compute_mode]
-    - (rem_flag ? mul_cost[(int) compute_mode] + add_cost : 0);
+    - (rem_flag && ! (last_div_const != 0 && op1_is_constant
+		      && INTVAL (op1) == last_div_const)
+       ? mul_cost[(int) compute_mode] + add_cost : 0);
+
+  last_div_const = ! rem_flag && op1_is_constant ? INTVAL (op1) : 0;
 
   /* Now convert to the best mode to use.  */
   if (compute_mode != mode)
--- configure.in.orig	Sat Feb 28 12:58:12 1998
+++ configure.in	Tue Feb  9 02:24:34 1999
@@ -303,6 +303,13 @@
 	a29k-*-*)			# Default a29k environment.
 		use_collect2=yes
 		;;
+	alpha*-*-freebsd*)
+		tm_file=alpha/freebsd.h
+		# On FreeBSD, the headers are already ok, except for math.h. (??right??)
+		fixincludes=fixinc.math
+		fixincludes=fixinc.math
+		tmake_file=t-libc-ok
+		;;
 	alpha*-*-linux-gnuecoff*)
 		tm_file="${tm_file} alpha/linux.h"
 		xm_file="${xm_file} alpha/xm-linux.h"
@@ -762,20 +769,20 @@
 # Next line turned off because both 386BSD and BSD/386 use GNU ld.
 #		use_collect2=yes
 		;;
-	i[[34567]]86-*-freebsdelf*)
-		tm_file="i386/i386.h i386/att.h linux.h i386/freebsd-elf.h i386/perform.h"
+	i[[34567]]86-*-freebsdaout*)
+		tm_file=i386/freebsd.h
 		# On FreeBSD, the headers are already ok, except for math.h.
 		fixincludes=fixinc.math
 		tmake_file=i386/t-freebsd
-		gas=yes
-		gnu_ld=yes
-		stabs=yes
 		;;
 	i[[34567]]86-*-freebsd*)
-		tm_file=i386/freebsd.h
+		tm_file="i386/i386.h i386/att.h linux.h i386/freebsd.h i386/perform.h"
 		# On FreeBSD, the headers are already ok, except for math.h.
 		fixincludes=fixinc.math
 		tmake_file=i386/t-freebsd
+		gas=yes
+		gnu_ld=yes
+		stabs=yes
 		;;
 	i[[34567]]86-*-netbsd*)
 		tm_file=i386/netbsd.h
--- c-common.c.orig	Wed Feb 18 19:16:13 1998
+++ c-common.c	Tue Mar 30 14:42:30 1999
@@ -623,6 +623,7 @@
 	    int format_num;
 	    int first_arg_num;
 	    int is_scan;
+	    int null_format_ok;
 	    tree argument;
 	    int arg_num;
 	
@@ -637,12 +638,26 @@
 		&& (!strcmp (IDENTIFIER_POINTER (format_type), "printf")
 		    || !strcmp (IDENTIFIER_POINTER (format_type),
 				"__printf__")))
-	      is_scan = 0;
+	      {
+	        is_scan = 0;
+	        null_format_ok = 0;
+	      }
+	    else if (TREE_CODE (format_type) == IDENTIFIER_NODE
+		&& (!strcmp (IDENTIFIER_POINTER (format_type), "printf0")
+		    || !strcmp (IDENTIFIER_POINTER (format_type),
+				"__printf0__")))
+	      {
+	        is_scan = 0;
+	        null_format_ok = 1;
+	      }
 	    else if (TREE_CODE (format_type) == IDENTIFIER_NODE
 		     && (!strcmp (IDENTIFIER_POINTER (format_type), "scanf")
 			 || !strcmp (IDENTIFIER_POINTER (format_type),
 				     "__scanf__")))
-	      is_scan = 1;
+	      {
+	        is_scan = 1;
+	        null_format_ok = 0;
+	      }
 	    else if (TREE_CODE (format_type) == IDENTIFIER_NODE)
 	      {
 		error ("`%s' is an unrecognized format function type",
@@ -651,7 +666,7 @@
 	      }
 	    else
 	      {
-		error ("unrecognized format specifier");
+		error_with_decl (decl, "unrecognized format specifier");
 		continue;
 	      }
 
@@ -718,7 +733,8 @@
 
 	    record_function_format (DECL_NAME (decl),
 				    DECL_ASSEMBLER_NAME (decl),
-				    is_scan, format_num, first_arg_num);
+				    is_scan, null_format_ok, format_num,
+				    first_arg_num);
 	    break;
 	  }
 
@@ -906,6 +922,7 @@
   int pointer_count;
   /* Type of argument if no length modifier is used.  */
   tree *nolen;
+  /* EGCS has tree *hhlen -- length modifier for shortening to byte */
   /* Type of argument if length modifier for shortening is used.
      If NULL, then this modifier is not allowed.  */
   tree *hlen;
@@ -926,6 +943,11 @@
 } format_char_info;
 
 static format_char_info print_char_table[] = {
+/* FreeBSD kernel extensions.  */
+  { "D",	1,	T_C,	NULL,	NULL,	NULL,	NULL,	NULL,	"-wp"		},
+  { "b",	1,	T_C,	NULL,	NULL,	NULL,	NULL,	NULL,	"-wp"		},
+  { "rz",	0,	NULL,	T_I,	T_L,	NULL,	NULL,	NULL,	"-wp0 +#"	},
+#define unextended_print_char_table	(print_char_table + 3)
   { "di",	0,	T_I,	T_I,	T_L,	T_LL,	T_LL,	T_ST,	"-wp0 +"	},
   { "oxX",	0,	T_UI,	T_UI,	T_UL,	T_ULL,	T_ULL,	T_ST,	"-wp0#"		},
   { "u",	0,	T_UI,	T_UI,	T_UL,	T_ULL,	T_ULL,	T_ST,	"-wp0"		},
@@ -960,6 +982,7 @@
   tree name;			/* identifier such as "printf" */
   tree assembler_name;		/* optional mangled identifier (for C++) */
   int is_scan;			/* TRUE if *scanf */
+  int null_format_ok;		/* TRUE if the format string may be NULL */
   int format_num;		/* number of format argument */
   int first_arg_num;		/* number of first arg (zero for varargs) */
 } function_format_info;
@@ -991,15 +1014,15 @@
 void
 init_function_format_info ()
 {
-  record_function_format (get_identifier ("printf"), NULL_TREE, 0, 1, 2);
-  record_function_format (get_identifier ("fprintf"), NULL_TREE, 0, 2, 3);
-  record_function_format (get_identifier ("sprintf"), NULL_TREE, 0, 2, 3);
-  record_function_format (get_identifier ("scanf"), NULL_TREE, 1, 1, 2);
-  record_function_format (get_identifier ("fscanf"), NULL_TREE, 1, 2, 3);
-  record_function_format (get_identifier ("sscanf"), NULL_TREE, 1, 2, 3);
-  record_function_format (get_identifier ("vprintf"), NULL_TREE, 0, 1, 0);
-  record_function_format (get_identifier ("vfprintf"), NULL_TREE, 0, 2, 0);
-  record_function_format (get_identifier ("vsprintf"), NULL_TREE, 0, 2, 0);
+  record_function_format (get_identifier ("printf"), NULL_TREE, 0, 0, 1, 2);
+  record_function_format (get_identifier ("fprintf"), NULL_TREE, 0, 0, 2, 3);
+  record_function_format (get_identifier ("sprintf"), NULL_TREE, 0, 0, 2, 3);
+  record_function_format (get_identifier ("scanf"), NULL_TREE, 1, 0, 1, 2);
+  record_function_format (get_identifier ("fscanf"), NULL_TREE, 1, 0, 2, 3);
+  record_function_format (get_identifier ("sscanf"), NULL_TREE, 1, 0, 2, 3);
+  record_function_format (get_identifier ("vprintf"), NULL_TREE, 0, 0, 1, 0);
+  record_function_format (get_identifier ("vfprintf"), NULL_TREE, 0, 0, 2, 0);
+  record_function_format (get_identifier ("vsprintf"), NULL_TREE, 0, 0, 2, 0);
 
   record_international_format (get_identifier ("gettext"), NULL_TREE, 1);
   record_international_format (get_identifier ("dgettext"), NULL_TREE, 2);
@@ -1016,11 +1039,12 @@
    (e.g. for varargs such as vfprintf).  */
 
 void
-record_function_format (name, assembler_name, is_scan,
+record_function_format (name, assembler_name, is_scan, null_format_ok,
 			format_num, first_arg_num)
       tree name;
       tree assembler_name;
       int is_scan;
+      int null_format_ok;
       int format_num;
       int first_arg_num;
 {
@@ -1044,6 +1068,7 @@
     }
 
   info->is_scan = is_scan;
+  info->null_format_ok = null_format_ok;
   info->format_num = format_num;
   info->first_arg_num = first_arg_num;
 }
@@ -1194,7 +1219,8 @@
 
   if (integer_zerop (format_tree))
     {
-      warning ("null format string");
+      if (!info->null_format_ok)
+	warning ("null format string");
       return;
     }
   if (TREE_CODE (format_tree) != ADDR_EXPR)
@@ -1329,6 +1355,7 @@
 		     It will work on most machines, because size_t and int
 		     have the same mode.  But might as well warn anyway,
 		     since it will fail on other machines.  */
+		  /* XXX should we allow unsigned ints here?  */
 		  if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
 		       != integer_type_node)
 		      &&
@@ -1336,7 +1363,7 @@
 		       != unsigned_type_node))
 		    {
 		      sprintf (message,
-			       "field width is not type int (arg %d)",
+			       "precision is not type int (arg %d)",
 			       arg_num);
 		      warning (message);
 		    }
@@ -1371,6 +1398,7 @@
 		      cur_param = TREE_VALUE (params);
 		      params = TREE_CHAIN (params);
 		      ++arg_num;
+		      /* XXX should we allow unsigned ints here?  */
 		      if (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
 			  != integer_type_node)
 		        {
@@ -1388,6 +1416,56 @@
 		}
 	    }
 	}
+      if (*format_chars == 'b')
+	{
+	  /* There should be an int arg to control the string arg.  */
+	  if (params == 0)
+	    {
+	      warning (tfaff);
+	      return;
+	    }
+	    if (info->first_arg_num != 0)
+	    {
+	      cur_param = TREE_VALUE (params);
+	      params = TREE_CHAIN (params);
+	      ++arg_num;
+	      if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
+		   != integer_type_node)
+		  &&
+		  (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param))
+		   != unsigned_type_node))
+		{
+		  sprintf (message, "bitmap is not type int (arg %d)",
+			   arg_num);
+		  warning (message);
+		}
+	    }
+	}
+      if (*format_chars == 'D')
+	{
+	  /* There should be an unsigned char * arg before the string arg.  */
+	  if (params == 0)
+	    {
+	      warning (tfaff);
+	      return;
+	    }
+	    if (info->first_arg_num != 0)
+	    {
+	      cur_param = TREE_VALUE (params);
+	      params = TREE_CHAIN (params);
+	      ++arg_num;
+	      cur_type = TREE_TYPE (cur_param);
+	      if (TREE_CODE (cur_type) != POINTER_TYPE
+		  || TYPE_MAIN_VARIANT (TREE_TYPE (cur_type))
+		     != unsigned_char_type_node)
+		{
+		  sprintf (message,
+		      "ethernet address is not type unsigned char * (arg %d)",
+			   arg_num);
+		  warning (message);
+		}
+	    }
+	}
       if (*format_chars == 'h' || *format_chars == 'l')
 	length_char = *format_chars++;
       else if (*format_chars == 'q' || *format_chars == 'L')
@@ -1436,7 +1514,9 @@
 	  continue;
 	}
       format_chars++;
-      fci = info->is_scan ? scan_char_table : print_char_table;
+      fci = info->is_scan ? scan_char_table
+	    : flag_format_extensions ? print_char_table
+	    : unextended_print_char_table;
       while (fci->format_chars != 0
 	     && index (fci->format_chars, format_char) == 0)
 	  ++fci;
--- c-tree.h.orig	Fri Aug  8 13:09:02 1997
+++ c-tree.h	Tue Mar 30 14:14:51 1999
@@ -162,7 +162,7 @@
 extern void declare_function_name               PROTO((void));
 extern void decl_attributes                     PROTO((tree, tree, tree));
 extern void init_function_format_info		PROTO((void));
-extern void record_function_format		PROTO((tree, tree, int, int, int));
+extern void record_function_format		PROTO((tree, tree, int, int, int, int));
 extern void check_function_format		PROTO((tree, tree, tree));
 /* Print an error message for invalid operands to arith operation CODE.
    NOP_EXPR is used as a special case (see truthvalue_conversion).  */
--- config/alpha/alpha.c.orig	Fri Feb  6 17:23:50 1998
+++ config/alpha/alpha.c	Tue Aug 11 04:06:42 1998
@@ -1843,7 +1843,7 @@
 /* Write a version stamp.  Don't write anything if we are running as a
    cross-compiler.  Otherwise, use the versions in /usr/include/stamp.h.  */
 
-#if !defined(CROSS_COMPILE) && !defined(_WIN32) && !defined(__linux__) && !defined(VMS)
+#if !defined(CROSS_COMPILE) && !defined(_WIN32) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__linux__) && !defined(VMS)
 #include <stamp.h>
 #endif
 
--- ginclude/stdarg.h.orig	Sat Oct 18 10:26:07 1997
+++ ginclude/stdarg.h	Tue Aug 11 13:27:03 1998
@@ -64,7 +64,7 @@
 
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST
-#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__)
+#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__) || defined(__OpenBSD__)
 typedef char *__gnuc_va_list;
 #else
 typedef void *__gnuc_va_list;
--- ginclude/stddef.h.orig	Mon Oct 28 04:35:28 1996
+++ ginclude/stddef.h	Tue Aug 11 13:26:05 1998
@@ -24,7 +24,7 @@
 
 /* On 4.3bsd-net2, make sure ansi.h is included, so we have
    one less case to deal with in the following.  */
-#if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__)
+#if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__)
 #include <machine/ansi.h>
 #endif