pthread.l (flex-2.6.3) | : | pthread.l (flex-2.6.4) | ||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |||
* PURPOSE. | * PURPOSE. | |||
*/ | */ | |||
%{ | %{ | |||
/* A scanner file to build "scanner.c". | /* A scanner file to build "scanner.c". | |||
Input language is any text made of spaces, newlines, and alphanumerics. | Input language is any text made of spaces, newlines, and alphanumerics. | |||
We create N_THREADS number of threads. Each thread has it's own scanner. | We create N_THREADS number of threads. Each thread has it's own scanner. | |||
Each thread selects one of the files specified in ARGV, scans it, then | Each thread selects one of the files specified in ARGV, scans it, then | |||
closes it. This is repeated N_SCANS numebr of times for each thread. | closes it. This is repeated N_SCANS number of times for each thread. | |||
The idea is to press the scanner to break under threads. | The idea is to press the scanner to break under threads. | |||
If we see "Scanner Jammed", then we know | If we see "Scanner Jammed", then we know | |||
*/ | */ | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <config.h> | #include <config.h> | |||
#ifdef HAVE_PTHREAD_H | #ifdef HAVE_PTHREAD_H | |||
skipping to change at line 93 | skipping to change at line 93 | |||
return 1; | return 1; | |||
} | } | |||
static int process_text(char* s, yyscan_t scanner) | static int process_text(char* s, yyscan_t scanner) | |||
{ | { | |||
(void)scanner; | (void)scanner; | |||
return (int)(*s) + (int) *(s + testget_leng(scanner)-1); | return (int)(*s) + (int) *(s + testget_leng(scanner)-1); | |||
} | } | |||
int main(int ARGC, char *ARGV[]); | int main(int ARGC, char *ARGV[]); | |||
#ifndef HAVE_LIBPTHREAD | #ifndef HAVE_PTHREAD_H | |||
int main (int ARGC, char *ARGV[]) { | int main (int ARGC, char *ARGV[]) { | |||
printf( | puts( | |||
"TEST ABORTED because pthread library not available \n" | "TEST ABORTED because pthread library not available \n" | |||
"-- This is expected on some systems. It is not a flex error.\n" ); | "-- This is expected on some systems. It is not a flex error."); | |||
return 0; | /* Exit status for a skipped test */ | |||
} | return 77; | |||
} | ||||
#else | #else | |||
#define N_THREADS 4 | #define N_THREADS 4 | |||
#define N_SCANS 20 | #define N_SCANS 20 | |||
#define INPUT_FILE "test.input" | ||||
/* Each thread selects the next file to scan in round-robin fashion. | /* Each thread selects the next file to scan in round-robin fashion. | |||
If there are less files than threads, some threads may block. */ | If there are less files than threads, some threads may block. */ | |||
static pthread_mutex_t next_lock = PTHREAD_MUTEX_INITIALIZER; | static pthread_mutex_t next_lock = PTHREAD_MUTEX_INITIALIZER; | |||
static pthread_mutex_t go_ahead = PTHREAD_MUTEX_INITIALIZER; | static pthread_mutex_t go_ahead = PTHREAD_MUTEX_INITIALIZER; | |||
static int n_files, next_file; | static int n_files, next_file; | |||
static pthread_mutex_t *file_locks; | static pthread_mutex_t *file_locks; | |||
static char **filenames; | static char **filenames; | |||
skipping to change at line 206 | skipping to change at line 206 | |||
for( i = 0; i < ARGC-1; i++) | for( i = 0; i < ARGC-1; i++) | |||
pthread_mutex_destroy( &file_locks[i] ); | pthread_mutex_destroy( &file_locks[i] ); | |||
pthread_mutex_destroy( &next_lock ); | pthread_mutex_destroy( &next_lock ); | |||
pthread_mutex_destroy( &go_ahead ); | pthread_mutex_destroy( &go_ahead ); | |||
free( file_locks ); | free( file_locks ); | |||
printf("TEST RETURNING OK.\n"); | printf("TEST RETURNING OK.\n"); | |||
return 0; | return 0; | |||
} | } | |||
#endif /* HAVE_LIBPTHREAD */ | #endif /* HAVE_PTHREAD_H */ | |||
End of changes. 5 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added |