58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
+
|
fi
fi
# Unset grep options
unset GREP_OPTIONS
# Version of BACON
typeset -rx g_VERSION="5.0.2"
typeset -rx g_VERSION="5.0.3"
# Our numerical environment is POSIX
export LC_NUMERIC="POSIX"
# Find coretools
if [[ -z `command -v cat` || -z `command -v rm` || -z `command -v tr` || -z `command -v touch` || -z `command -v uname` || -z `command -v head` || -z `command -v pwd` || -z `command -v sort` || -z `command -v grep` ]]
then
|
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
|
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
|
-
+
|
echo "case SIGFPE: fprintf(stderr, \"ERROR: signal for FPE received - division by zero? Examine the calculations in the program.\n\"); break;" >> $g_FUNCTIONS
echo "case SIGSEGV: fprintf(stderr, \"ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.\n\"); break;" >> $g_FUNCTIONS
echo "case SIGILL: fprintf(stderr, \"ERROR: signal for ILLEGAL INSTRUCTION received - executing the program on other hardware? Try to recompile the program from scratch.\n\"); break;} exit(sig);}" >> $g_FUNCTIONS
echo "void __b2c__segv(int sig){ longjmp(__b2c__jump, 1); }" >> $g_FUNCTIONS
echo "int __b2c__memory__check (char *x, int size) { volatile char c; unsigned int i, illegal = 1; struct sigaction osa, psa; sigaction(SIGSEGV, NULL, &osa); if (osa.sa_handler != SIG_IGN)" >> $g_FUNCTIONS
echo "{ memset(&psa, 0, sizeof(psa)); psa.sa_flags = SA_NODEFER|SA_RESTART; psa.sa_handler = __b2c__segv; sigaction(SIGSEGV, &psa, NULL); } if (!setjmp (__b2c__jump))" >> $g_FUNCTIONS
echo "{ for (i = 0; i < size; i++) { c = *(char*)(x+i); /* Use c to avoid warning */ if(c) {;} } } else { illegal = 0; } sigaction(SIGSEGV, &osa, NULL); return (illegal); }" >> $g_FUNCTIONS
echo "int jmp_buf_is_used(jmp_buf data) { jmp_buf p = { 0 }; if(memcpy(data, p, sizeof(jmp_buf))) { return(0); } return(1); }" >> $g_FUNCTIONS
echo "int jmp_buf_is_used(jmp_buf data) { jmp_buf p = { 0 }; if(!data) {return(0);} if(memcmp(data, p, sizeof(jmp_buf))) { return(1); } return(0); }" >> $g_FUNCTIONS
# minmax
echo "char* __b2c__min_str(char* x, char* y) {if(strcmp(x, y) < 0) { return(x); } return(y);}" >> $g_FUNCTIONS
echo "char* __b2c__max_str(char* x, char* y) {if(strcmp(x, y) > 0) { return(x); } return(y);}" >> $g_FUNCTIONS
# str
echo "char* __b2c__str(double nr) { static char *buf[__b2c_STRING_FUNC] = { NULL }; static int idx = 0; int len; idx++; if (idx == __b2c_STRING_FUNC) { idx = 0; } buf[idx] = (char*)__b2c_str_realloc (buf[idx], ${g_MAX_DIGITS}); if(floor(nr) == nr)" >> $g_FUNCTIONS
|