/[pcre]/code/trunk/pcre_jit_test.c
ViewVC logotype

Diff of /code/trunk/pcre_jit_test.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 836 by ph10, Wed Dec 28 17:16:11 2011 UTC revision 884 by zherczeg, Tue Jan 17 11:52:43 2012 UTC
# Line 672  static const unsigned char *tables(int m Line 672  static const unsigned char *tables(int m
672          /* The purpose of this function to allow valgrind          /* The purpose of this function to allow valgrind
673          for reporting invalid reads and writes. */          for reporting invalid reads and writes. */
674          static unsigned char *tables_copy;          static unsigned char *tables_copy;
         pcre *regex;  
675          const char *errorptr;          const char *errorptr;
676          int erroroffset;          int erroroffset;
677          const unsigned char *default_tables;          const unsigned char *default_tables;
678  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
679            pcre *regex;
680          char null_str[1] = { 0 };          char null_str[1] = { 0 };
681  #else  #else
682          PCRE_SCHAR16 null_str[1] = { 0 };          pcre16 *regex;
683            PCRE_UCHAR16 null_str[1] = { 0 };
684  #endif  #endif
685    
686          if (mode) {          if (mode) {
# Line 720  static const unsigned char *tables(int m Line 721  static const unsigned char *tables(int m
721          return tables_copy;          return tables_copy;
722  }  }
723    
724  static pcre_jit_stack* callback(void *arg)  #ifdef SUPPORT_PCRE8
725    static pcre_jit_stack* callback8(void *arg)
726  {  {
727          return (pcre_jit_stack *)arg;          return (pcre_jit_stack *)arg;
728  }  }
729    #endif
730    
731    #ifdef SUPPORT_PCRE16
732    static pcre16_jit_stack* callback16(void *arg)
733    {
734            return (pcre16_jit_stack *)arg;
735    }
736    #endif
737    
738  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
739  static void setstack8(pcre_extra *extra)  static void setstack8(pcre_extra *extra)
# Line 740  static void setstack8(pcre_extra *extra) Line 750  static void setstack8(pcre_extra *extra)
750          if (!stack)          if (!stack)
751                  stack = pcre_jit_stack_alloc(1, 1024 * 1024);                  stack = pcre_jit_stack_alloc(1, 1024 * 1024);
752          /* Extra can be NULL. */          /* Extra can be NULL. */
753          pcre_assign_jit_stack(extra, callback, stack);          pcre_assign_jit_stack(extra, callback8, stack);
754  }  }
755  #endif /* SUPPORT_PCRE8 */  #endif /* SUPPORT_PCRE8 */
756    
757  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
758  static void setstack16(pcre_extra *extra)  static void setstack16(pcre16_extra *extra)
759  {  {
760          static pcre_jit_stack *stack;          static pcre16_jit_stack *stack;
761    
762          if (!extra) {          if (!extra) {
763                  if (stack)                  if (stack)
# Line 759  static void setstack16(pcre_extra *extra Line 769  static void setstack16(pcre_extra *extra
769          if (!stack)          if (!stack)
770                  stack = pcre16_jit_stack_alloc(1, 1024 * 1024);                  stack = pcre16_jit_stack_alloc(1, 1024 * 1024);
771          /* Extra can be NULL. */          /* Extra can be NULL. */
772          pcre16_assign_jit_stack(extra, callback, stack);          pcre16_assign_jit_stack(extra, callback16, stack);
773  }  }
774  #endif /* SUPPORT_PCRE8 */  #endif /* SUPPORT_PCRE8 */
775    
776  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
777    
778  static int convert_utf8_to_utf16(const char *input, PCRE_SCHAR16 *output, int *offsetmap, int max_length)  static int convert_utf8_to_utf16(const char *input, PCRE_UCHAR16 *output, int *offsetmap, int max_length)
779  {  {
780          unsigned char *iptr = (unsigned char*)input;          unsigned char *iptr = (unsigned char*)input;
781          unsigned short *optr = (unsigned short *)output;          unsigned short *optr = (unsigned short *)output;
# Line 813  static int convert_utf8_to_utf16(const c Line 823  static int convert_utf8_to_utf16(const c
823          return (int)(optr - (unsigned short *)output);          return (int)(optr - (unsigned short *)output);
824  }  }
825    
826  static int copy_char8_to_char16(const char *input, PCRE_SCHAR16 *output, int max_length)  static int copy_char8_to_char16(const char *input, PCRE_UCHAR16 *output, int max_length)
827  {  {
828          unsigned char *iptr = (unsigned char*)input;          unsigned char *iptr = (unsigned char*)input;
829          unsigned short *optr = (unsigned short *)output;          unsigned short *optr = (unsigned short *)output;
# Line 830  static int copy_char8_to_char16(const ch Line 840  static int copy_char8_to_char16(const ch
840  }  }
841    
842  #define REGTEST_MAX_LENGTH 4096  #define REGTEST_MAX_LENGTH 4096
843  static PCRE_SCHAR16 regtest_buf[REGTEST_MAX_LENGTH];  static PCRE_UCHAR16 regtest_buf[REGTEST_MAX_LENGTH];
844  static int regtest_offsetmap[REGTEST_MAX_LENGTH];  static int regtest_offsetmap[REGTEST_MAX_LENGTH];
845    
846  #endif /* SUPPORT_PCRE16 */  #endif /* SUPPORT_PCRE16 */
# Line 850  static int regression_tests(void) Line 860  static int regression_tests(void)
860  {  {
861          struct regression_test_case *current = regression_test_cases;          struct regression_test_case *current = regression_test_cases;
862          const char *error;          const char *error;
863            const char *cpu_info;
864          int i, err_offs;          int i, err_offs;
865          int is_successful, is_ascii_pattern, is_ascii_input;          int is_successful, is_ascii_pattern, is_ascii_input;
866          int total = 0;          int total = 0;
# Line 865  static int regression_tests(void) Line 876  static int regression_tests(void)
876          int disabled_flags8 = 0;          int disabled_flags8 = 0;
877  #endif  #endif
878  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
879          pcre *re16;          pcre16 *re16;
880          pcre_extra *extra16;          pcre16_extra *extra16;
881          int ovector16_1[32];          int ovector16_1[32];
882          int ovector16_2[32];          int ovector16_2[32];
883          int return_value16_1, return_value16_2;          int return_value16_1, return_value16_2;
# Line 879  static int regression_tests(void) Line 890  static int regression_tests(void)
890          utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is          utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is
891          still considered successful from pcre_jit_test point of view. */          still considered successful from pcre_jit_test point of view. */
892    
893          printf("Running JIT regression\n");  #ifdef SUPPORT_PCRE8
894            pcre_config(PCRE_CONFIG_JITTARGET, &cpu_info);
895    #else
896            pcre16_config(PCRE_CONFIG_JITTARGET, &cpu_info);
897    #endif
898    
899            printf("Running JIT regression tests\n");
900            printf("  target CPU of SLJIT compiler: %s\n", cpu_info);
901    
902  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
903          pcre_config(PCRE_CONFIG_UTF8, &utf8);          pcre_config(PCRE_CONFIG_UTF8, &utf8);
# Line 888  static int regression_tests(void) Line 906  static int regression_tests(void)
906                  disabled_flags8 |= PCRE_UTF8;                  disabled_flags8 |= PCRE_UTF8;
907          if (!ucp8)          if (!ucp8)
908                  disabled_flags8 |= PCRE_UCP;                  disabled_flags8 |= PCRE_UCP;
909          printf(" in  8 bit mode with utf8  %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled");          printf("  in  8 bit mode with utf8  %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled");
910  #endif  #endif
911  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
912          pcre16_config(PCRE_CONFIG_UTF16, &utf16);          pcre16_config(PCRE_CONFIG_UTF16, &utf16);
# Line 897  static int regression_tests(void) Line 915  static int regression_tests(void)
915                  disabled_flags16 |= PCRE_UTF8;                  disabled_flags16 |= PCRE_UTF8;
916          if (!ucp16)          if (!ucp16)
917                  disabled_flags16 |= PCRE_UCP;                  disabled_flags16 |= PCRE_UCP;
918          printf(" in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled");          printf("  in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled");
919  #endif  #endif
920    
921          while (current->pattern) {          while (current->pattern) {

Legend:
Removed from v.836  
changed lines
  Added in v.884

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12