Mercurial > hg > Members > shinya > pyrect
changeset 65:bee3a64d6cbc
remove paralle-code (that have to need more improvement.)
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 06 Nov 2010 00:51:26 +0900 |
parents | 020ba001c58a |
children | |
files | pyrect/translator/grep_translator.py pyrect/translator/template/grep.c |
diffstat | 2 files changed, 2 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/translator/grep_translator.py Fri Nov 05 01:39:42 2010 +0900 +++ b/pyrect/translator/grep_translator.py Sat Nov 06 00:51:26 2010 +0900 @@ -125,7 +125,7 @@ self.emit( 'if (ret == NULL) {fprintf(stderr, "memchr NULL err!"); exit(0);}') self.emiti( "if (ret > end) {") self.emit( "ret--;") - self.emit( "print_line(beg, ret);") + self.emit( "block_print_line(beg, ret);") self.emit( "return;") self.emitd( "}") self.emit( "print_line(beg, ret);")
--- a/pyrect/translator/template/grep.c Fri Nov 05 01:39:42 2010 +0900 +++ b/pyrect/translator/template/grep.c Sat Nov 06 00:51:26 2010 +0900 @@ -1,46 +1,3 @@ -/* -typedef struct _thread_arg { - unsigned char *buf; - int len; - int match; -} thread_arg_t; - -void* thread_dfa(void *arg) { - thread_arg_t* targ = (thread_arg_t*)arg; - targ->match = DFA(targ->buf, targ->len); - return NULL; -} - -int paradfa(unsigned char *text, int len) { - pthread_t hundle[THREAD_NUM]; - thread_arg_t targ[THREAD_NUM]; - - if (len + REG_MAX_LEN <= REG_MAX_LEN) - return dfa(text, len); - - int i, t_len = (len + THREAD_NUM - 1) / THREAD_NUM; - for (i = 0; i < THREAD_NUM; i++) { - targ[i].buf = text + (unsigned char)(i * t_len); - targ[i].len = t_len + REG_MAX_LEN; - } - targ[THREAD_NUM - 1].len = len - (t_len * (THREAD_NUM - 1)); - - for (i = 0; i < THREAD_NUM; i++) { - pthread_create(&hundle[i], NULL, (void *)thread_dfa, (void *)&targ[i]); - } - - for (i = 0; i < THREAD_NUM; i++) { - pthread_join(hundle[i], NULL); - } - - for (i = 0; i < THREAD_NUM; i++) { - if (targ[i].match) return 1; - } - return 0; -} - -*/ - void print_line(unsigned char *beg, unsigned char *end) { fwrite(beg, sizeof(char), (end - beg + 1), stdout); } @@ -70,6 +27,7 @@ dfa(beg, beg, end); munmap(file_mmap, size); + pthread_exit(NULL); return; }