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
*/
#include <stdio.h>
#include <stdlib.h>
-#include "config.h"
+#include <config.h>
-#ifdef HAVE_LIBPTHREAD
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
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" );
for( i =0 ; i < N_SCANS ; i++ )
{
- int main(void);
+ int main(int ARGC, char *ARGV[]);
int next;
yyscan_t scanner;
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. */
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 );