This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


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

Re: <signal.h> broken with _POSIX_SOURCE=1 defined


>>>>> Matthias Urlichs writes:

Matthias>   Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:
>> 
>> This small program shows the broken behaviour with the current glibc
>> 2.1 cvs sources:
>> #define _POSIX_SOURCE 1
>> #include <signal.h>
>> int main(void) { ;}
>> 
Matthias> IMHO, we should have a testcase which does this for all legal values of
Matthias> _FOO_SOURCE (i.e. including "none" and "a few unlikely combinations") and
Matthias> <bar.h> (i.e. all except those in */bits/*).  

I'm generating such testcases with a small perl program.  I've
appended the program.  Feel free to use it yourself, enhance it, and
send patches for it and for glibc (there are quite a lot of problems
with _POSIX_SOURCE at the moment).  You'll notice that I do a test
installation of glibc in /usr/glibc/glibc2.1.  

If people feel that the program is really useful, I could try to
rework it for inclusion in glibc.

Andreas

#!/usr/bin/perl -w
# Written by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.

$|=1;


chdir ("/tmp/");



sub test_header {
  my ($compiler, $file, $prefix) = @_;

  print "Testing: $prefix$file with $compiler\n";
  open DATEI, ">/tmp/test.c";
  SPECIAL: 
  {
    if ($prefix eq "" && ($file eq "regex.h" || $file eq "re_comp.h" || $file eq "glob.h")) {
      print DATEI "#include <sys/types.h>\n";
      last SPECIAL;
    }
    if ($prefix eq "" && $file eq "regexp.h" ) {
      print DATEI "#define INIT\n";
      print DATEI "#define GETC() 0\n";
      print DATEI "#define PEEKC() 0\n";
      print DATEI "#define UNGETC(c)\n";
      print DATEI "#define ERROR(val)\n";
      print DATEI "#define RETURN(val) 0\n";

      last SPECIAL;
    }
    if ($prefix eq "netrose" && $file eq "rose.h" ) {
      print DATEI "#include <netax25/ax25.h>";
      last SPECIAL;
    }
  }
  print DATEI "#include<$prefix$file>\n";
  print DATEI "int main (void) {return 0;}\n";
  close DATEI;
  
  open GCC, "$compiler $includes -c test.c 2>&1 |";
  while (<GCC>) {
    print;
  }
  close GCC;
}



sub test_isoc {
# iso headers:
# assert, ctype, errno, float, iso646, limits, locale, math, setjmp, signal, stdarg,
# stddef, stdio, stdlib, string, time, wchar, wctype
# ico C9X additionally: complex, fenv, inttypes, stdbool, tgmath
  my ($header, @headers);
  my ($compiler) = $_[0];

  @headers = ("assert", "ctype", "errno", "float", "iso646", "limits", 
	      "locale", "math", "setjmp", "signal", "stdarg", "stddef", 
	      "stdio", "stdlib", "string", "time", "wchar", "wctype",
	      # ico C9X additionally: 
	      "complex", "fenv", "inttypes", "tgmath" # , "stdbool"
	      );

  foreach $header (@headers) {
    test_header ($compiler, "$header.h", "");
  }
}

sub test_dir {
  my ($compiler, $dir,$prefix) = @_;

  my (@allfiles, $datei);

  opendir DIRS, $dir;
  @allfiles = sort grep /\.h$/, readdir DIRS;
  closedir DIRS;

 DATEI:
  foreach $datei (@allfiles) {

  DONT_TEST: 
    {
      if (($prefix eq "rpcsvc/" && $datei eq "nislib.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "Dpg.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "liba2ps.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "gif_lib.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "FlexLexer.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "bfdlink.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "compface.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if (($prefix eq "" && $datei eq "cursesapp.h")) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
      if ($prefix eq "" && 
	  ($datei eq "cursesapp.h" || $datei eq "cursesw.h" || $datei eq "etip.h" || 
	   $datei eq "expect_comm.h" || $datei eq "expect_tcl.h" || $datei eq "jpeglib.h" ||
	   $datei eq "pngconf.h" || $datei eq "png.h" || $datei eq "bfd.h" || 
	   $datei eq "cursesf.h" || $datei eq "cursesp.h" || $datei eq "cursslk.h" ||
	   $datei eq "expect.h" || $datei eq "cursesm.h" || $datei eq "gpm.h" ||
	   $datei eq "tk.h" || $datei eq "Dbg.h"
			   )) {
	print "Skipping: $prefix$datei with $compiler\n";
	next DATEI;
      }
    }
    &test_header ($compiler, $datei, $prefix);
  }
}


sub test_all_dirs {

  my ($compiler) = $_[0];

  $add_dir = $install_dir . "/include";


  &test_dir ($compiler, "$add_dir/include/", "");
  &test_dir ($compiler, "$add_dir/include/db1/", "db1/");
  &test_dir ($compiler, "$add_dir/include/gnu/", "gnu/");
  &test_dir ($compiler, "$add_dir/include/net/", "net/");
  &test_dir ($compiler, "$add_dir/include/netash/", "netash/");
  &test_dir ($compiler, "$add_dir/include/netatalk/", "netatalk/");
  &test_dir ($compiler, "$add_dir/include/netax25/", "netax25/");
  &test_dir ($compiler, "$add_dir/include/neteconet/", "neteconet/");
  &test_dir ($compiler, "$add_dir/include/netinet/", "netinet/");
  &test_dir ($compiler, "$add_dir/include/netipx/", "netipx/");
  &test_dir ($compiler, "$add_dir/include/netpacket/", "netpacket/");
  &test_dir ($compiler, "$add_dir/include/netrom/", "netrom/");
  &test_dir ($compiler, "$add_dir/include/netrose/", "netrose/");
  &test_dir ($compiler, "$add_dir/include/nfs/", "nfs/");
  &test_dir ($compiler, "$add_dir/include/protocols/", "protocols/");
  &test_dir ($compiler, "$add_dir/include/rpc/", "rpc/");
  &test_dir ($compiler, "$add_dir/include/rpcsvc/", "rpcsvc/");
  &test_dir ($compiler, "$add_dir/include/scsi/", "scsi/");
  &test_dir ($compiler, "$add_dir/include/sys/", "sys/");
}

# The following two paramters need to be adjusted:
$PATH_FOR_CC="/opt/egcs/bin/";
$install_dir = "/usr/glibc/glibc-2.1";

$includes = "-I${install_dir}/include";

&test_isoc ("${PATH_FOR_CC}gcc -ansi -pedantic -W");
&test_isoc ("${PATH_FOR_CC}g++ -ansi -pedantic -W");

&test_all_dirs ("${PATH_FOR_CC}gcc -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_GNU_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_GNU_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_BSD_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_BSD_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_POSIX_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_POSIX_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_POSIX_C_SOURCE=1 -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_POSIX_C_SOURCE=1 -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_POSIX_C_SOURCE=2 -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_POSIX_C_SOURCE=2 -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_POSIX_C_SOURCE=199309 -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_POSIX_C_SOURCE=199309 -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_POSIX_C_SOURCE=199506 -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_POSIX_C_SOURCE=199506 -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_XOPEN_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_XOPEN_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_XOPEN_SOURCE=500 -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_XOPEN_SOURCE=500 -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_SVID_SOURCE -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_SVID_SOURCE -W");

&test_all_dirs ("${PATH_FOR_CC}gcc -D_REENTRANT -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_REENTRANT -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_GNU_SOURCE -D_REENTRANT -W");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_GNU_SOURCE -D_REENTRANT -W");
&test_all_dirs ("${PATH_FOR_CC}gcc -D_GNU_SOURCE -D_REENTRANT -W -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE");
&test_all_dirs ("${PATH_FOR_CC}g++ -D_GNU_SOURCE -D_REENTRANT -W -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE");


-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de


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