about summary refs log tree commit diff
path: root/conform
diff options
context:
space:
mode:
Diffstat (limited to 'conform')
-rw-r--r--conform/conformtest.pl147
-rw-r--r--conform/data/dlfcn.h-data1
-rw-r--r--conform/data/ftw.h-data2
-rw-r--r--conform/data/iconv.h-data2
-rw-r--r--conform/data/nl_types.h-data2
-rw-r--r--conform/data/search.h-data2
-rw-r--r--conform/data/semaphore.h-data23
-rw-r--r--conform/data/setjmp.h-data20
-rw-r--r--conform/data/signal.h-data191
-rw-r--r--conform/data/stdarg.h-data7
-rw-r--r--conform/data/stddef.h-data8
-rw-r--r--conform/data/stdio.h-data103
12 files changed, 501 insertions, 7 deletions
diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index 41613c67e5..30577c07d6 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -4,7 +4,9 @@ $CC = "gcc";
 $CFLAGS = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE=500";
 
 # List of the headers we are testing.
-@headers = ("search.h", "sched.h", "regex.h", "pwd.h", "pthread.h",
+@headers = ("stdio.h",
+	    "stddef.h", "stdarg.h", "signal.h", "setjmp.h", "semaphore.h",
+	    "search.h", "sched.h", "regex.h", "pwd.h", "pthread.h",
 	    "poll.h", "nl_types.h", "ndbm.h", "mqueue.h", "monetary.h",
 	    "math.h", "locale.h", "libgen.h", "langinfo.h", "iso646.h",
 	    "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h", "fnmatch.h",
@@ -171,8 +173,12 @@ sub newtoken {
   my($token, $nerrors, @allow) = @_;
   my($idx);
 
+  if ($token =~ /^[0-9_]/ || $iskeyword{$token}) {
+    return $nerrors;
+  }
+
   for ($idx = 0; $idx <= $#allow; ++$idx) {
-    if ($token =~ /^[0-9_]/ || $iskeyword{$token} || poorfnmatch ($allow[$idx], $token)) {
+    if (poorfnmatch ($allow[$idx], $token)) {
       return $nerrors;
     }
   }
@@ -319,6 +325,48 @@ while ($#headers >= 0) {
 	$res = runtest ($fnamebase, "Testing for value of constant $const",
 			"Constant \"$const\" has not the right value.", $res);
       }
+    } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
+      my($const) = $1;
+      my($type) = "$3$4";
+      my($value) = $5;
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $const;
+
+      # Generate a program to test for the availability of this constant.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ ($const) a = $const;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Testing for constant $const",
+			  "Constant \"$const\" not available.", $res);
+
+      # Test the types of the members.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "__typeof__ (($type) 0) a;\n";
+      print TESTFILE "extern __typeof__ ($const) a;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Testing for type of constant $const",
+		   "Constant \"$const\" does not have the correct type.",
+		   $res);
+
+      if ($value ne "") {
+	# Generate a program to test for the value of this constant.
+	open (TESTFILE, ">$fnamebase.c");
+	print TESTFILE "$prepend";
+	print TESTFILE "#include <$h>\n";
+	print TESTFILE "int main (void) { return $const != $value; }\n";
+	close (TESTFILE);
+
+	$res = runtest ($fnamebase, "Testing for value of constant $const",
+			"Constant \"$const\" has not the right value.", $res);
+      }
     } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
       my($type) = "$2$3";
 
@@ -343,7 +391,38 @@ while ($#headers >= 0) {
 
       compiletest ($fnamebase, "Testing for type $type",
 		   "Type \"$type\" not available.", $missing);
-    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(][^)]*[)])/) {
+    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "Function \"$fname\" is not available.", $res);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
+      print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of function $fname",
+		   "Function \"$fname\" has incorrect type.", $res);
+    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
       my($rettype) = "$2$3";
       my($fname) = "$4";
       my($args) = "$5";
@@ -374,6 +453,68 @@ while ($#headers >= 0) {
 
       compiletest ($fnamebase, "Test for type of function $fname",
 		   "Function \"$fname\" has incorrect type.", $res);
+    } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
+      my($type) = "$2$3";
+      my($vname) = "$4";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $vname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "$type *foobarbaz = &$vname;\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of variable $vname",
+			  "Variable \"$vname\" is not available.", $res);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      # print TESTFILE "#undef $fname\n";
+      print TESTFILE "extern $type $vname;\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of variable $fname",
+		   "Variable \"$vname\" has incorrect type.", $res);
+    } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+      my($rettype) = "$2$3";
+      my($fname) = "$4";
+      my($args) = "$5";
+      my($res) = $missing;
+
+      # Remember that this name is allowed.
+      push @allow, $fname;
+
+      # Generate a program to test for availability of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $fname\n";
+      print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      $res = compiletest ($fnamebase, "Test availability of function $fname",
+			  "Function \"$fname\" is not available.", $res);
+
+      # Generate a program to test for the type of this function.
+      open (TESTFILE, ">$fnamebase.c");
+      print TESTFILE "$prepend";
+      print TESTFILE "#include <$h>\n";
+      print TESTFILE "#ifndef $fname\n";
+      print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
+      print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
+      print TESTFILE "#endif\n";
+      close (TESTFILE);
+
+      compiletest ($fnamebase, "Test for type of function $fname",
+		   "Function \"$fname\" has incorrect type.", $res);
     } elsif (/^macro *([^ 	]*)/) {
       my($macro) = "$1";
 
diff --git a/conform/data/dlfcn.h-data b/conform/data/dlfcn.h-data
index 530feabf88..93e3354635 100644
--- a/conform/data/dlfcn.h-data
+++ b/conform/data/dlfcn.h-data
@@ -10,4 +10,5 @@ function int dlclose (void*)
 function {char*} dlerror (void)
 
 allow *_t
+allow RTLD_*
 #endif
diff --git a/conform/data/ftw.h-data b/conform/data/ftw.h-data
index f5dec5cf79..ef34116a73 100644
--- a/conform/data/ftw.h-data
+++ b/conform/data/ftw.h-data
@@ -17,7 +17,7 @@ macro FTW_DEPTH
 macro FTW_CHDIR
 
 function int ftw (const char*, int (*) (const char *, const struct stat*, int), int)
-function int nftw (const char*, int (*) (const char *, const struct stat*, int, FTW *), int, int)
+function int nftw (const char*, int (*) (const char *, const struct stat*, int, struct FTW *), int, int)
 
 allow *_t
 #endif
diff --git a/conform/data/iconv.h-data b/conform/data/iconv.h-data
index f1e2ea0527..1c748a04ca 100644
--- a/conform/data/iconv.h-data
+++ b/conform/data/iconv.h-data
@@ -2,7 +2,7 @@
 type iconv_t
 
 function iconv_t iconv_open (const char*, const char*)
-function size_t iconv (iconv_t, char**, size_t*, char**, size_t*)
+function size_t iconv (iconv_t, const char**, size_t*, char**, size_t*)
 function int iconv_close (iconv_t)
 
 allow *_t
diff --git a/conform/data/nl_types.h-data b/conform/data/nl_types.h-data
index 91eacafa96..7cabf3ff62 100644
--- a/conform/data/nl_types.h-data
+++ b/conform/data/nl_types.h-data
@@ -6,7 +6,7 @@ constant NL_SETD
 constant NL_CAT_LOCALE
 
 function int catclose (nl_catd)
-function {char*} catgets (nl_catd, int, int, char char*)
+function {char*} catgets (nl_catd, int, int, const char*)
 function nl_catd catopen (const char*, int)
 
 allow *_t
diff --git a/conform/data/search.h-data b/conform/data/search.h-data
index 7da11c97c1..da7f2a1332 100644
--- a/conform/data/search.h-data
+++ b/conform/data/search.h-data
@@ -22,7 +22,7 @@ function {void*} lfind (const void*, const void*, size_t*, size_t, int (*)(const
 function {void*} lsearch (const void*, void*, size_t*, size_t, int (*)(const void*, const void*))
 function void remque (void*)
 function {void*} tdelete (const void*, void**, int(*)(const void*, const void*))
-function {void*} tfind (const void*, void*const*, int(*)(const void*, const void*)) tfind (const void*, void*const*, int(*)(const void*, const void*))
+function {void*} tfind (const void*, void*const*, int(*)(const void*, const void*))
 function {void*} tsearch (const void*, void**, int(*)(const void*, const void*))
 function void twalk (const void*, void (*) (const void*, VISIT, int))
 
diff --git a/conform/data/semaphore.h-data b/conform/data/semaphore.h-data
new file mode 100644
index 0000000000..9664b67dd5
--- /dev/null
+++ b/conform/data/semaphore.h-data
@@ -0,0 +1,23 @@
+#if !defined ISO
+type sem_t
+
+constant SEM_FAILED
+
+function int sem_close (sem_t*)
+function int sem_destroy (sem_t*)
+function int sem_getvalue (sem_t*, int*)
+function int sem_init (sem_t*, int, unsigned int)
+function {sem_t*} sem_open (const char*, int, ...)
+function int sem_post (sem_t*)
+function int sem_trywait (sem_t*)
+function int sem_unlink (const char*)
+function int sem_wait (sem_t*)
+
+# if !defined POSIX
+allow-header fcntl.h
+allow-header sys/types.h
+# endif
+
+allow sem_*
+allow SEM_*
+#endif
diff --git a/conform/data/setjmp.h-data b/conform/data/setjmp.h-data
new file mode 100644
index 0000000000..806dacfc94
--- /dev/null
+++ b/conform/data/setjmp.h-data
@@ -0,0 +1,20 @@
+type jmp_buf
+#ifndef ISO
+type sigjmp_buf
+#endif
+
+function void longjmp (jmp_buf, int)
+#ifndef ISO
+function void siglongjmp (sigjmp_buf, int)
+# ifndef POSIX
+function void _longjmp (jmp_buf, int)
+# endif
+#endif
+
+macro-function int setjmp (jmp_buf)
+#ifndef ISO
+macro-function int sigsetjmp (sigjmp_buf, int)
+# ifndef POSIX
+macro-function int _setjmp (jmp_buf)
+# endif
+#endif
diff --git a/conform/data/signal.h-data b/conform/data/signal.h-data
new file mode 100644
index 0000000000..fda1af9436
--- /dev/null
+++ b/conform/data/signal.h-data
@@ -0,0 +1,191 @@
+typed-constant SIG_DFL {void(*)(int)}
+typed-constant SIG_ERR {void(*)(int)}
+typed-constant SIG_HOLD {void(*)(int)}
+typed-constant SIG_IGN {void(*)(int)}
+
+type sig_atomic_t
+type sigset_t
+type pid_t
+
+element {union sigval} int sival_int
+element {union sigval} {void*} sival_ptr
+
+type {struct sigevent}
+
+// Test the elements of the sigevent_t structure.
+element {struct sigevent} int sigev_notify
+element {struct sigevent} int sigev_signo
+element {struct sigevent} {union sigval} sigev_value
+element {struct sigevent} {void(*)(union sigval)} sigev_notify_function
+element {struct sigevent} {pthread_attr_t*} sigev_notify_attributes
+
+constant SIGEV_NONE
+constant SIGEV_SIGNAL
+constant SIGEV_THREAD
+
+type {union sigval}
+
+macro SIGRTMIN
+macro SIGRTMAX
+
+constant SIGABRT
+constant SIGALRM
+constant SIGFPE
+constant SIGHUP
+constant SIGILL
+constant SIGINT
+constant SIGKILL
+constant SIGPIPE
+constant SIGQUIT
+constant SIGSEGV
+constant SIGTERM
+constant SIGUSR1
+constant SIGUSR2
+constant SIGCHLD
+constant SIGCONT
+constant SIGSTOP
+constant SIGTSTP
+constant SIGTTIN
+constant SIGTTOU
+constant SIGBUS
+constant SIGPOLL
+constant SIGPROF
+constant SIGSYS
+constant SIGTRAP
+constant SIGURG
+constant SIGVALRM
+constant SIGXCPU
+constant SIGXFSZ
+
+type {struct sigaction}
+
+element {struct sigaction} {void(*} sa_handler )(int)
+element {struct sigaction} sigset_t sa_mask
+element {struct sigaction} int sa_flags
+element {struct sigaction} {void(*} sa_sigaction )(int, siginfo_t*, void*)
+
+constant SA_NOCLDSTOP
+constant SIG_BLOCK
+constant SIG_UNBLOCK
+constant SIG_SETMASK
+constant SA_ONSTACK
+constant SA_RESETHAND
+constant SA_RESTART
+constant SA_SIGINFO
+constant SA_NOCLDWAIT
+constant SA_NODEFER
+constant SS_ONSTACK
+constant SS_DISABLE
+constant MINSIGSTKSZ
+constant SIGSTKSZ
+
+type ucontext_t
+
+element ucontext_t {ucontext_t*} uc_link
+element ucontext_t sigset_t uc_sigmask
+element ucontext_t stack_t uc_stack
+element ucontext_t mcontext_t uc_mcontext
+
+type stack_t
+
+element stack_t {void*} ss_sp
+element stack_t size_t ss_size
+element stack_t int ss_flags
+
+type {struct sigstack}
+
+element {struct sigstack} int ss_onstack
+element {struct sigstack} {void*} ss_sp
+
+type siginfo_t
+
+element siginfo_t int si_signo
+element siginfo_t int si_errno
+element siginfo_t int si_code
+element siginfo_t pid_t si_pid
+element siginfo_t uid_t si_uid
+element siginfo_t {void*} si_addr
+element siginfo_t int si_status
+element siginfo_t long si_band
+element siginfo_t {union sigval} si_value
+
+constant ILL_ILLOPC
+constant ILL_ILLOPN
+constant ILL_ILLADR
+constant ILL_ILLTRP
+constant ILL_PRVOPC
+constant ILL_PRVREG
+constant ILL_COPROC
+constant ILL_BADSTK
+constant FPE_INTDIV
+constant FPE_INTOVF
+constant FPE_FLTDIV
+constant FPE_FLTOVF
+constant FPE_FLTUND
+constant FPE_FLTRES
+constant FPE_FLTINV
+constant FPE_FLTSUB
+constant SEGV_MAPERR
+constant SEGV_ACCERR
+constant BUS_ADRALN
+constant BUS_ADRERR
+constant BUS_OBJERR
+constant TRAP_BRKPT
+constant TRAP_TRACE
+constant CLD_EXITED
+constant CLD_KILLED
+constant CLD_DUMPED
+constant CLD_TRAPPED
+constant CLD_STOPPED
+constant CLD_CONTINUED
+constant POLL_IN
+constant POLL_OUT
+constant POLL_MSG
+constant POLL_ERR
+constant POLL_PRI
+constant POLL_HUP
+constant SI_USER
+constant SI_QUEUE
+constant SI_TIMER
+constant SI_ASYNCIO
+constant SI_MESGQ
+
+function void (*bsd_signal (int, void(*)(int)))(int)
+function int kill (pid_t, int)
+function int killpg (pid_t, int)
+function int pthread_kill (pthread_t, int)
+function int pthread_sigmask (int, const sigset_t*, sigset_t*)
+function int raise (int)
+function int sigaction (int, const struct sigaction*, struct sigaction*)
+function int sigaddset (sigset_t*, int)
+function int sigaltstack (const stack_t*, stack_t*)
+function int sigdelset (sigset_t*, int)
+function int sigemptyset (sigset_t*)
+function int sigfillset (sigset_t*)
+function int sighold (int)
+function int sigignore (int)
+function int siginterrupt (int, int)
+function int sigismember (const sigset_t*, int)
+function void (*signal (int, void(*)(int)))(int)
+function int sigpause (int)
+function int sigpending (sigset_t*)
+function int sigprocmask (int, const sigset_t*, sigset_t*)
+function int sigqueue (pid_t, int, const union sigval)
+function int sigrelse (int)
+function void (*sigset (int, void(*)(int)))(int)
+function int sigstack (struct sigstack*, struct sigstack*)
+function int sigsuspend (const sigset_t*)
+function int sigtimedwait (const sigset_t*, siginfo_t*, const struct timespec*)
+function int sigwait (const sigset_t*, int*)
+function int sigwaitinfo (const sigset_t*, siginfo_t*)
+
+allow SIG*
+allow sa_*
+allow uc_*
+allow ss_*
+allow sv_*
+allow si_*
+allow SI_*
+allow sigev_*
+allow SIGEV_*
+allow sival_*
diff --git a/conform/data/stdarg.h-data b/conform/data/stdarg.h-data
new file mode 100644
index 0000000000..719d504ef9
--- /dev/null
+++ b/conform/data/stdarg.h-data
@@ -0,0 +1,7 @@
+type va_list
+
+// XXX We didn't check the parameters.
+macro va_start
+macro va_arg
+macro va_end
+macro va_copy
diff --git a/conform/data/stddef.h-data b/conform/data/stddef.h-data
new file mode 100644
index 0000000000..05b157060a
--- /dev/null
+++ b/conform/data/stddef.h-data
@@ -0,0 +1,8 @@
+constant NULL
+
+macro offsetof
+
+type ptrdiff_t
+type wchar_t
+type size_t
+type wint_t
diff --git a/conform/data/stdio.h-data b/conform/data/stdio.h-data
new file mode 100644
index 0000000000..93238ba0ba
--- /dev/null
+++ b/conform/data/stdio.h-data
@@ -0,0 +1,103 @@
+constant BUFSIZ
+constant FILENAME_MAX
+constant FOPEN_MAX
+
+constant _IOFBF
+constant _IOLBF
+constant _IONBF
+
+constant L_ctermid
+constant L_cuserid
+constant L_tmpnam
+
+constant SEEK_CUR
+constant SEEK_END
+constant SEEK_SET
+
+constant TMP_MAX
+
+constant EOF
+
+constant NULL
+
+constant P_tmpdir
+
+macro stdin
+macro stdout
+macro stderr
+
+type FILE
+type fpos_t
+type va_list
+type size_t
+
+function void clearerr (FILE*)
+function {char*} ctermid (char*)
+function {char*} cuserid (char*)
+function int fclose (FILE*)
+function {FILE*} fdopen (int, const char*)
+function int feof (FILE*)
+function int ferror (FILE*)
+function int fflush (FILE*)
+function int fgetc (FILE*)
+function int fgetpos (FILE*, fpos_t*)
+function {char*} fgets (char*, int, FILE*)
+function int fileno (FILE*)
+function void flockfile (FILE*)
+function {FILE*} fopen (const char*, const char*)
+function int fprintf (FILE*, const char*, ...)
+function int fputc (int, FILE*)
+function int fputs (const char*, FILE*)
+function size_t fread (void*, size_t, size_t, FILE*)
+function {FILE*} freopen (const char*, const char*, FILE*)
+function int fscanf (FILE*, const char*, ...)
+function int fseek (FILE*, long int, int)
+function int fseeko (FILE*, off_t, int)
+function int fsetpos (FILE*, const fpos_t*)
+function {long int} ftell (FILE*)
+function off_t ftello (FILE*)
+function int ftrylockfile (FILE*)
+function void funlockfile (FILE*)
+function size_t fwrite (const void*, size_t, size_t, FILE*)
+function int getc (FILE*)
+function int getchar (void)
+function int getc_unlocked (FILE*)
+function int getopt (int, char *const[], const char *)
+function {char*} gets (char*)
+function int getw (FILE*)
+function int pclose (FILE*)
+function void perror (const char*)
+function {FILE*} popen (const char*, const char*)
+function int printf (const char*, ...)
+function int putc (int, FILE*)
+function int putchar (int)
+function int putc_unlocked (int, FILE*)
+function int putchar_unlocked (int)
+function int puts (const char*)
+function int putw (int, FILE*)
+function int remove (const char*)
+function int rename (const char*, const char*)
+function void rewind (FILE*)
+function int scanf (const char*, ...)
+function void setbuf (FILE*, char*)
+function int setvbuf (FILE*, char*, int, size_t)
+function int snprintf (char*, size_t, const char*, ...)
+function int sprintf (char *, const char *, ...)
+function int sscanf (const char*, const char*, ...)
+function {char*} tempnam (const char*, const char*)
+function {FILE*} tmpfile (void)
+function {char*} tmpnam (char*)
+function int ungetc (int, FILE*)
+function int vfprintf (FILE*, const char*, va_list)
+function int vprintf (const char*, va_list)
+function int vsnprintf (char*, size_t, const char*, va_list)
+function int vsprintf (char*, const char*, va_list)
+
+#if !defined ISO && !defined POSIX
+variable {char*} optarg
+variable int opterr
+variable int optind
+variable int optopt
+
+allow-header stddef.h
+#endif