static void do_one_test (impl_t *impl, const char *s, int c, char *exp_res) { char *res = CALL (impl, s, c); if (res != exp_res) { error (0, 0, "Wrong result in function %s %p %p", impl->name, res, exp_res); ret = 1; return; } if (HP_TIMING_AVAIL) { hp_timing_t start __attribute ((unused)); hp_timing_t stop __attribute ((unused)); hp_timing_t best_time = ~ (hp_timing_t) 0; size_t i; for (i = 0; i < 32; ++i) { HP_TIMING_NOW (start); CALL (impl, s, c); HP_TIMING_NOW (stop); HP_TIMING_BEST (best_time, start, stop); } printf ("\t%zd", (size_t) best_time); } }
static void do_one_test (impl_t *impl, const CHAR *s, size_t exp_len) { size_t len = CALL (impl, s); if (len != exp_len) { error (0, 0, "Wrong result in function %s %zd %zd", impl->name, len, exp_len); ret = 1; return; } if (HP_TIMING_AVAIL) { hp_timing_t start __attribute ((unused)); hp_timing_t stop __attribute ((unused)); hp_timing_t best_time = ~ (hp_timing_t) 0; size_t i; for (i = 0; i < 32; ++i) { HP_TIMING_NOW (start); CALL (impl, s); HP_TIMING_NOW (stop); HP_TIMING_BEST (best_time, start, stop); } printf ("\t%zd", (size_t) best_time); } }
static void do_one_test (impl_t *impl, char *dst, const char *src, size_t len, size_t n) { if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n)) { error (0, 0, "Wrong result in function %s %p %p", impl->name, CALL (impl, dst, src, n), dst); ret = 1; return; } if (memcmp (dst, src, len > n ? n : len) != 0) { error (0, 0, "Wrong result in function %s", impl->name); ret = 1; return; } if (n > len) { size_t i; for (i = len; i < n; ++i) if (dst [i] != '\0') { error (0, 0, "Wrong result in function %s", impl->name); ret = 1; return; } } if (HP_TIMING_AVAIL) { hp_timing_t start __attribute__ ((unused)); hp_timing_t stop __attribute__ ((unused)); hp_timing_t best_time = ~ (hp_timing_t) 0; size_t i; for (i = 0; i < 32; ++i) { HP_TIMING_NOW (start); CALL (impl, dst, src, n); HP_TIMING_NOW (stop); HP_TIMING_BEST (best_time, start, stop); } printf ("\t%zd", (size_t) best_time); } }
static void do_one_test (impl_t *impl, const CHAR *s1, const CHAR *s2, size_t len, int exp_result) { if (HP_TIMING_AVAIL) { hp_timing_t start __attribute ((unused)); hp_timing_t stop __attribute ((unused)); hp_timing_t best_time = ~ (hp_timing_t) 0; size_t i; for (i = 0; i < 32; ++i) { HP_TIMING_NOW (start); CALL (impl, s1, s2, len); HP_TIMING_NOW (stop); HP_TIMING_BEST (best_time, start, stop); } printf ("\t%zd", (size_t) best_time); } }
static void do_one_test (impl_t *impl, void *dst, const void *src, int c, size_t len, size_t n) { void *expect = len > n ? NULL : (char *) dst + len; if (CALL (impl, dst, src, c, n) != expect) { error (0, 0, "Wrong result in function %s %p %p", impl->name, CALL (impl, dst, src, c, n), expect); ret = 1; return; } if (memcmp (dst, src, len > n ? n : len) != 0) { error (0, 0, "Wrong result in function %s", impl->name); ret = 1; return; } if (HP_TIMING_AVAIL) { hp_timing_t start __attribute__ ((unused)); hp_timing_t stop __attribute__ ((unused)); hp_timing_t best_time = ~ (hp_timing_t) 0; size_t i; for (i = 0; i < 32; ++i) { HP_TIMING_NOW (start); CALL (impl, dst, src, c, n); HP_TIMING_NOW (stop); HP_TIMING_BEST (best_time, start, stop); } printf ("\t%zd", (size_t) best_time); } }
static void do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result) { if (check_result (impl, s1, s2, exp_result) < 0) return; if (HP_TIMING_AVAIL) { hp_timing_t start __attribute ((unused)); hp_timing_t stop __attribute ((unused)); hp_timing_t best_time = ~(hp_timing_t) 0; size_t i; for (i = 0; i < 32; ++i) { HP_TIMING_NOW (start); CALL (impl, s1, s2); HP_TIMING_NOW (stop); HP_TIMING_BEST (best_time, start, stop); } printf ("\t%zd", (size_t) best_time); } }