fix for old systems
This commit is contained in:
@ -26,14 +26,6 @@
|
|||||||
#include "hawk-prv.h"
|
#include "hawk-prv.h"
|
||||||
#include "hawk-std.h"
|
#include "hawk-std.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct xtn_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* infile;
|
|
||||||
const hawk_ooch_t* outfile;
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
|
|
||||||
typedef struct xtn_in_t xtn_in_t;
|
typedef struct xtn_in_t xtn_in_t;
|
||||||
struct xtn_in_t
|
struct xtn_in_t
|
||||||
{
|
{
|
||||||
@ -70,9 +62,6 @@ struct xtn_t
|
|||||||
|
|
||||||
hawk_link_t* sio_names;
|
hawk_link_t* sio_names;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct xtn_t xtn_t;
|
|
||||||
|
|
||||||
#if defined(HAWK_HAVE_INLINE)
|
#if defined(HAWK_HAVE_INLINE)
|
||||||
static HAWK_INLINE xtn_t* GET_XTN(hawk_cut_t* cut) { return (xtn_t*)((hawk_uint8_t*)hawk_cut_getxtn(cut) - HAWK_SIZEOF(xtn_t)); }
|
static HAWK_INLINE xtn_t* GET_XTN(hawk_cut_t* cut) { return (xtn_t*)((hawk_uint8_t*)hawk_cut_getxtn(cut) - HAWK_SIZEOF(xtn_t)); }
|
||||||
|
20
t/err.sh
20
t/err.sh
@ -3,6 +3,12 @@
|
|||||||
for i in $@; do :; done
|
for i in $@; do :; done
|
||||||
script="$i"
|
script="$i"
|
||||||
|
|
||||||
|
escape_regex() {
|
||||||
|
local str="$1"
|
||||||
|
## escape [, ], {, (, \, $, *, . ^, ), }
|
||||||
|
printf '%s\n' "$str" | sed -r -e 's/[][{(\$*.^)}]/\\&/g'
|
||||||
|
}
|
||||||
|
|
||||||
run_partfile() {
|
run_partfile() {
|
||||||
l_cmd="";
|
l_cmd="";
|
||||||
l_nargs=$#
|
l_nargs=$#
|
||||||
@ -21,7 +27,9 @@ run_partfile() {
|
|||||||
l_partfile="$1"
|
l_partfile="$1"
|
||||||
l_cmd="$l_cmd $l_partfile"
|
l_cmd="$l_cmd $l_partfile"
|
||||||
|
|
||||||
l_expected_errinfo=$(grep -n -o -E "##ERROR: .+" "$l_partfile" 2>/dev/null)
|
## old greps don't support -o. use sed to mimic it.
|
||||||
|
##l_expected_errinfo=$(grep -n -o -E "##ERROR: .+" "$l_partfile" 2>/dev/null)
|
||||||
|
l_expected_errinfo=$(grep -n -E "##ERROR: .+" "$l_partfile" 2>/dev/null | sed -r -n 's/^([0-9]*):.*(##ERROR: .*)/\1:\2/p')
|
||||||
[ -z "$l_expected_errinfo" ] && {
|
[ -z "$l_expected_errinfo" ] && {
|
||||||
echo "ERROR: INVALID TESTER - $l_script($l_partno) contains no ERROR information"
|
echo "ERROR: INVALID TESTER - $l_script($l_partno) contains no ERROR information"
|
||||||
return 1
|
return 1
|
||||||
@ -33,8 +41,9 @@ run_partfile() {
|
|||||||
l_expected_errmsg=$(echo $l_expected_errinfo | cut -c${l_xlen}-)
|
l_expected_errmsg=$(echo $l_expected_errinfo | cut -c${l_xlen}-)
|
||||||
l_output=`$l_cmd 2>&1`
|
l_output=`$l_cmd 2>&1`
|
||||||
## the regular expression is not escaped properly. the error information must not
|
## the regular expression is not escaped properly. the error information must not
|
||||||
## include specifial regex characters to avoid problems.
|
## include special regex characters to avoid problems.
|
||||||
echo "$l_output" | grep -E "ERROR: .+ LINE ${l_expected_errline} .+ FILE ${l_partfile} - ${l_expected_errmsg}" >/dev/null 2>&1 || {
|
l_expected_errmsg_esc=$(escape_regex "${l_expected_errmsg}")
|
||||||
|
echo "$l_output" | grep -E "ERROR: .+ LINE ${l_expected_errline} .+ FILE ${l_partfile} - ${l_expected_errmsg_esc}" >/dev/null 2>&1 || {
|
||||||
echo "ERROR: error not raised at line $l_expected_errline - $l_script($l_partno) - $l_output"
|
echo "ERROR: error not raised at line $l_expected_errline - $l_script($l_partno) - $l_output"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@ -45,7 +54,10 @@ run_partfile() {
|
|||||||
|
|
||||||
|
|
||||||
ever_failed=0
|
ever_failed=0
|
||||||
partfile=`mktemp`
|
## [NOTE]
|
||||||
|
## some old mktemp(e.g mktemp 1.5 on rhel 2.1) always required the template.
|
||||||
|
## these days, newer ones don't need it.
|
||||||
|
partfile=`mktemp tmp.XXXXXXXXXX`
|
||||||
partno=0
|
partno=0
|
||||||
partlines=0
|
partlines=0
|
||||||
> "$partfile"
|
> "$partfile"
|
||||||
|
@ -26,6 +26,7 @@ int main(int argc, char* argv[])
|
|||||||
clock_t start_time, end_time;
|
clock_t start_time, end_time;
|
||||||
double malloc_time = 0.0, free_time = 0.0;
|
double malloc_time = 0.0, free_time = 0.0;
|
||||||
void **ptr_array;
|
void **ptr_array;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (argc >= 3)
|
if (argc >= 3)
|
||||||
{
|
{
|
||||||
@ -46,7 +47,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_time = clock();
|
start_time = clock();
|
||||||
for (size_t i = 0; i < num_iterations; ++i) {
|
for (i = 0; i < num_iterations; ++i) {
|
||||||
size_t size = random_size(max_alloc_size);
|
size_t size = random_size(max_alloc_size);
|
||||||
/*ptr_array[i] = malloc(size);*/
|
/*ptr_array[i] = malloc(size);*/
|
||||||
ptr_array[i] = HAWK_MMGR_ALLOC(&xma_mmgr, size);
|
ptr_array[i] = HAWK_MMGR_ALLOC(&xma_mmgr, size);
|
||||||
@ -64,7 +65,7 @@ int main(int argc, char* argv[])
|
|||||||
malloc_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
|
malloc_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
|
||||||
|
|
||||||
start_time = clock();
|
start_time = clock();
|
||||||
for (size_t i = 0; i < num_iterations; ++i) {
|
for (i = 0; i < num_iterations; ++i) {
|
||||||
/*free(ptr_array[i]);*/
|
/*free(ptr_array[i]);*/
|
||||||
HAWK_MMGR_FREE(&xma_mmgr, ptr_array[i]);
|
HAWK_MMGR_FREE(&xma_mmgr, ptr_array[i]);
|
||||||
}
|
}
|
||||||
|
10
t/t-009.c
10
t/t-009.c
@ -108,6 +108,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
Allocation* allocations; /* pool of active allocations */
|
Allocation* allocations; /* pool of active allocations */
|
||||||
size_t num_active = 0;
|
size_t num_active = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
clock_t start_time, end_time;
|
clock_t start_time, end_time;
|
||||||
double malloc_time = 0.0, free_time = 0.0;
|
double malloc_time = 0.0, free_time = 0.0;
|
||||||
@ -144,7 +145,7 @@ int main(int argc, char* argv[])
|
|||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
start_time = clock();
|
start_time = clock();
|
||||||
|
|
||||||
for (size_t i = 0; i < num_iterations; ++i)
|
for (i = 0; i < num_iterations; ++i)
|
||||||
{
|
{
|
||||||
int do_alloc = (num_active == 0) || (rand() % 2 == 0 && num_active < max_alloc_active);
|
int do_alloc = (num_active == 0) || (rand() % 2 == 0 && num_active < max_alloc_active);
|
||||||
|
|
||||||
@ -163,13 +164,14 @@ int main(int argc, char* argv[])
|
|||||||
++num_active;
|
++num_active;
|
||||||
} else {
|
} else {
|
||||||
/* free a random active allocation */
|
/* free a random active allocation */
|
||||||
|
clock_t t1, t2;
|
||||||
size_t index = rand() % num_active;
|
size_t index = rand() % num_active;
|
||||||
void *ptr_to_free = allocations[index].ptr;
|
void *ptr_to_free = allocations[index].ptr;
|
||||||
|
|
||||||
clock_t t1 = clock();
|
t1 = clock();
|
||||||
/*free(ptr_to_free); */
|
/*free(ptr_to_free); */
|
||||||
HAWK_MMGR_FREE(&xma_mmgr, ptr_to_free);
|
HAWK_MMGR_FREE(&xma_mmgr, ptr_to_free);
|
||||||
clock_t t2 = clock();
|
t2 = clock();
|
||||||
free_time += (double)(t2 - t1) / CLOCKS_PER_SEC;
|
free_time += (double)(t2 - t1) / CLOCKS_PER_SEC;
|
||||||
|
|
||||||
/* replace with last active allocation */
|
/* replace with last active allocation */
|
||||||
@ -182,7 +184,7 @@ int main(int argc, char* argv[])
|
|||||||
/* hawk_xma_dump(xma_mmgr.ctx, print_xma, HAWK_NULL); */
|
/* hawk_xma_dump(xma_mmgr.ctx, print_xma, HAWK_NULL); */
|
||||||
|
|
||||||
/* Free remaining allocations */
|
/* Free remaining allocations */
|
||||||
for (size_t i = 0; i < num_active; ++i) {
|
for (i = 0; i < num_active; ++i) {
|
||||||
/* free(allocations[i].ptr); */
|
/* free(allocations[i].ptr); */
|
||||||
HAWK_MMGR_FREE(&xma_mmgr, allocations[i].ptr);
|
HAWK_MMGR_FREE(&xma_mmgr, allocations[i].ptr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user