From: Will Estes Date: Sat, 12 May 2007 15:27:33 +0000 (+0000) Subject: fixes to test-pthread X-Git-Tag: flex-2-5-34~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ca08588608e04eeebc0e529d215cb3727b9e1d8;p=flex fixes to test-pthread --- diff --git a/configure.in b/configure.in index 8ffbdfb..62ff25a 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/tests/test-pthread/scanner.l b/tests/test-pthread/scanner.l index 9207a9d..8603873 100644 --- a/tests/test-pthread/scanner.l +++ b/tests/test-pthread/scanner.l @@ -35,9 +35,9 @@ */ #include #include -#include "config.h" +#include -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD_H #include #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 );