]> granicus.if.org Git - flex/commitdiff
fixes to test-pthread
authorWill Estes <wlestes@users.sourceforge.net>
Sat, 12 May 2007 15:27:33 +0000 (15:27 +0000)
committerWill Estes <wlestes@users.sourceforge.net>
Sat, 12 May 2007 15:27:33 +0000 (15:27 +0000)
configure.in
tests/test-pthread/scanner.l

index 8ffbdfb632a516b8306ae51f39176ecc2632e294..62ff25a6576f737abab58fa570373fdab705db8d 100644 (file)
@@ -87,6 +87,16 @@ AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h stddef.h stdlib.h string.h strings.h unistd.h])
 AC_CHECK_LIB(m, log10)
 
+# The test test-pthread uses libpthread, so we check for it here, but
+# all we need is the preprocessor symbol defined since we don't need
+# LIBS to include libpthread for building flex.
+
+AC_CHECK_LIB(pthread, pthread_mutex_lock,
+AC_DEFINE([HAVE_LIBPTHREAD], 1, [pthread library] ),
+AC_DEFINE([HAVE_LIBPTHREAD], 0, [pthread library] )
+)
+AC_CHECK_HEADERS([pthread.h])
+
 # Checks for typedefs, structures, and compiler characteristics.
 
 AC_HEADER_STDBOOL
index 9207a9d0a4f64d9a5d31fcfdf7c2dc2e9de20837..8603873808a65e457bc83676df074f6456057868 100644 (file)
@@ -35,9 +35,9 @@
 */
 #include <stdio.h>
 #include <stdlib.h>
-#include "config.h"
+#include <config.h>
 
-#ifdef HAVE_LIBPTHREAD
+#ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
 
@@ -84,10 +84,10 @@ static int process_text(char* s, yyscan_t  scanner)
     return (int)(*s) + (int) *(s + yyget_leng(scanner)-1);
 }
 
-int main(void);
+int main(int ARGC, char *ARGV[]);
 
 #ifndef HAVE_LIBPTHREAD
-  int main () {
+  int main (int ARGC, char *ARGV[]) {
     printf(
        "TEST ABORTED because pthread library not available \n"
        "-- This is expected on some systems. It is not a flex error.\n" );
@@ -120,7 +120,7 @@ void * thread_func ( void* arg )
 
     for( i =0 ; i < N_SCANS ; i++ )
     {
-        int main(void);
+        int main(int ARGC, char *ARGV[]);
 
         int next;
         yyscan_t  scanner;
@@ -150,23 +150,23 @@ void * thread_func ( void* arg )
     return NULL;
 }
 
-int main ()
+int main (int ARGC, char *ARGV[])
 {
     int i;
     pthread_t threads[N_THREADS];
 
-    if( argc < 2 ) {
+    if( ARGC < 2 ) {
         fprintf(stderr,"*** Error: No filenames specified.\n");
         exit(-1);
     }
 
     /* Allocate and initialize the locks. One for each filename in ARGV. */
-    file_locks = (pthread_mutex_t*)malloc( (argc-1) * sizeof(pthread_mutex_t));
-    for( i = 0; i < argc-1; i++)
+    file_locks = (pthread_mutex_t*)malloc( (ARGC-1) * sizeof(pthread_mutex_t));
+    for( i = 0; i < ARGC-1; i++)
         pthread_mutex_init( &file_locks[i], NULL );
 
-    n_files = argc -1;
-    filenames = argv + 1;
+    n_files = ARGC -1;
+    filenames = ARGV + 1;
     next_file = 0;
 
     /* prevent threads from starting until all threads have been created. */
@@ -190,7 +190,7 @@ int main ()
         printf("Thread %d done.\n", i ); fflush(stdout);
     }
 
-    for( i = 0; i < argc-1; i++)
+    for( i = 0; i < ARGC-1; i++)
         pthread_mutex_destroy( &file_locks[i] );
 
     pthread_mutex_destroy( &next_lock );