From c0b89ac5bfb90835ef01573267020e42d4fe070c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 23 Aug 2015 12:17:05 +0200 Subject: Imported Upstream version 1.8.0 --- numlib/Jamfile | 0 numlib/LUtest.c | 0 numlib/License.txt | 0 numlib/Readme.txt | 0 numlib/aatree.c | 0 numlib/aatree.h | 0 numlib/afiles | 0 numlib/dhsx.c | 0 numlib/dhsx.h | 0 numlib/dnsq.c | 0 numlib/dnsq.h | 0 numlib/dnsqtest.c | 0 numlib/ludecomp.c | 0 numlib/ludecomp.h | 0 numlib/numlib.h | 0 numlib/numsup.c | 70 +++++++++++++++++++++++++++++++++++++---------------- numlib/numsup.h | 34 ++++++++++++++------------ numlib/powell.c | 0 numlib/powell.h | 0 numlib/rand.c | 0 numlib/rand.h | 0 numlib/sobol.c | 0 numlib/sobol.h | 0 numlib/soboltest.c | 0 numlib/svd.c | 0 numlib/svd.h | 0 numlib/svdtest.c | 0 numlib/tdhsx.c | 0 numlib/tpowell.c | 0 numlib/ui.c | 10 +++++++- numlib/ui.h | 0 numlib/zbrent.c | 0 numlib/zbrent.h | 0 numlib/zbrenttest.c | 0 34 files changed, 76 insertions(+), 38 deletions(-) mode change 100644 => 100755 numlib/Jamfile mode change 100644 => 100755 numlib/LUtest.c mode change 100644 => 100755 numlib/License.txt mode change 100644 => 100755 numlib/Readme.txt mode change 100644 => 100755 numlib/aatree.c mode change 100644 => 100755 numlib/aatree.h mode change 100644 => 100755 numlib/afiles mode change 100644 => 100755 numlib/dhsx.c mode change 100644 => 100755 numlib/dhsx.h mode change 100644 => 100755 numlib/dnsq.c mode change 100644 => 100755 numlib/dnsq.h mode change 100644 => 100755 numlib/dnsqtest.c mode change 100644 => 100755 numlib/ludecomp.c mode change 100644 => 100755 numlib/ludecomp.h mode change 100644 => 100755 numlib/numlib.h mode change 100644 => 100755 numlib/numsup.c mode change 100644 => 100755 numlib/numsup.h mode change 100644 => 100755 numlib/powell.c mode change 100644 => 100755 numlib/powell.h mode change 100644 => 100755 numlib/rand.c mode change 100644 => 100755 numlib/rand.h mode change 100644 => 100755 numlib/sobol.c mode change 100644 => 100755 numlib/sobol.h mode change 100644 => 100755 numlib/soboltest.c mode change 100644 => 100755 numlib/svd.c mode change 100644 => 100755 numlib/svd.h mode change 100644 => 100755 numlib/svdtest.c mode change 100644 => 100755 numlib/tdhsx.c mode change 100644 => 100755 numlib/tpowell.c mode change 100644 => 100755 numlib/ui.c mode change 100644 => 100755 numlib/ui.h mode change 100644 => 100755 numlib/zbrent.c mode change 100644 => 100755 numlib/zbrent.h mode change 100644 => 100755 numlib/zbrenttest.c (limited to 'numlib') diff --git a/numlib/Jamfile b/numlib/Jamfile old mode 100644 new mode 100755 diff --git a/numlib/LUtest.c b/numlib/LUtest.c old mode 100644 new mode 100755 diff --git a/numlib/License.txt b/numlib/License.txt old mode 100644 new mode 100755 diff --git a/numlib/Readme.txt b/numlib/Readme.txt old mode 100644 new mode 100755 diff --git a/numlib/aatree.c b/numlib/aatree.c old mode 100644 new mode 100755 diff --git a/numlib/aatree.h b/numlib/aatree.h old mode 100644 new mode 100755 diff --git a/numlib/afiles b/numlib/afiles old mode 100644 new mode 100755 diff --git a/numlib/dhsx.c b/numlib/dhsx.c old mode 100644 new mode 100755 diff --git a/numlib/dhsx.h b/numlib/dhsx.h old mode 100644 new mode 100755 diff --git a/numlib/dnsq.c b/numlib/dnsq.c old mode 100644 new mode 100755 diff --git a/numlib/dnsq.h b/numlib/dnsq.h old mode 100644 new mode 100755 diff --git a/numlib/dnsqtest.c b/numlib/dnsqtest.c old mode 100644 new mode 100755 diff --git a/numlib/ludecomp.c b/numlib/ludecomp.c old mode 100644 new mode 100755 diff --git a/numlib/ludecomp.h b/numlib/ludecomp.h old mode 100644 new mode 100755 diff --git a/numlib/numlib.h b/numlib/numlib.h old mode 100644 new mode 100755 diff --git a/numlib/numsup.c b/numlib/numsup.c old mode 100644 new mode 100755 index bfa144b..43f6e73 --- a/numlib/numsup.c +++ b/numlib/numsup.c @@ -63,7 +63,7 @@ void set_exe_path(char *argv0) { g_log->tag = argv0; i = strlen(argv0); if ((exe_path = malloc(i + 5)) == NULL) { - a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed",i+5); + a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed\n",i+5); return; } strcpy(exe_path, argv0); @@ -80,7 +80,7 @@ void set_exe_path(char *argv0) { strcat(exe_path, ".exe"); if ((mh = GetModuleHandle(exe_path)) == NULL) { - a1loge(g_log, 1, "set_exe_path: GetModuleHandle '%s' failed with%d", + a1loge(g_log, 1, "set_exe_path: GetModuleHandle '%s' failed with%d\n", exe_path,GetLastError()); exe_path[0] = '\000'; return; @@ -91,12 +91,12 @@ void set_exe_path(char *argv0) { if (tpath != NULL) free(tpath); if ((tpath = malloc(pl)) == NULL) { - a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed",pl); + a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed\n",pl); exe_path[0] = '\000'; return; } if ((i = GetModuleFileName(mh, tpath, pl)) == 0) { - a1loge(g_log, 1, "set_exe_path: GetModuleFileName '%s' failed with%d", + a1loge(g_log, 1, "set_exe_path: GetModuleFileName '%s' failed with%d\n", tpath,GetLastError()); exe_path[0] = '\000'; return; @@ -135,7 +135,7 @@ void set_exe_path(char *argv0) { else ll = p - cp; if ((ll + 1 + strlen(exe_path) + 1) > PATH_MAX) { - a1loge(g_log, 1, "set_exe_path: Search path exceeds PATH_MAX"); + a1loge(g_log, 1, "set_exe_path: Search path exceeds PATH_MAX\n"); exe_path[0] = '\000'; return; } @@ -148,7 +148,7 @@ void set_exe_path(char *argv0) { found = 1; free(exe_path); if ((exe_path = malloc(strlen(b2)+1)) == NULL) { - a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed",strlen(b2)+1); + a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed\n",strlen(b2)+1); exe_path[0] = '\000'; return; } @@ -170,7 +170,7 @@ void set_exe_path(char *argv0) { if (exe_path[i] == '/') { char *tpath; if ((tpath = malloc(strlen(exe_path + i))) == NULL) { - a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed",strlen(exe_path + i)); + a1loge(g_log, 1, "set_exe_path: malloc %d bytes failed\n",strlen(exe_path + i)); exe_path[0] = '\000'; return; } @@ -454,6 +454,34 @@ void a1logue(a1log *log) { } } +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* Print bytes as hex to debug log */ +/* base is the base of the displayed offset */ +void adump_bytes(a1log *log, char *pfx, unsigned char *buf, int base, int len) { + int i, j, ii; + char oline[200] = { '\000' }, *bp = oline; + for (i = j = 0; i < len; i++) { + if ((i % 16) == 0) + bp += sprintf(bp,"%s%04x:",pfx,base+i); + bp += sprintf(bp," %02x",buf[i]); + if ((i+1) >= len || ((i+1) % 16) == 0) { + for (ii = i; ((ii+1) % 16) != 0; ii++) + bp += sprintf(bp," "); + bp += sprintf(bp," "); + for (; j <= i; j++) { + if (!(buf[j] & 0x80) && isprint(buf[j])) + bp += sprintf(bp,"%c",buf[j]); + else + bp += sprintf(bp,"."); + } + bp += sprintf(bp,"\n"); + a1logd(log,0,"%s",oline); + bp = oline; + } + } +} + /******************************************************************/ /* Default verbose/warning/error output routines */ /* These fall through to, and can be re-director using the */ @@ -1609,7 +1637,7 @@ unsigned int read_ORD8(ORD8 *p) { return rv; } -void write_ORD8(unsigned int d, ORD8 *p) { +void write_ORD8(ORD8 *p, unsigned int d) { if (d > 0xff) d = 0xff; p[0] = (ORD8)(d); @@ -1624,7 +1652,7 @@ int read_INR8(ORD8 *p) { return rv; } -void write_INR8(int d, ORD8 *p) { +void write_INR8(ORD8 *p, int d) { if (d > 0x7f) d = 0x7f; else if (d < -0x80) @@ -1649,14 +1677,14 @@ unsigned int read_ORD16_le(ORD8 *p) { return rv; } -void write_ORD16_be(unsigned int d, ORD8 *p) { +void write_ORD16_be(ORD8 *p, unsigned int d) { if (d > 0xffff) d = 0xffff; p[0] = (ORD8)(d >> 8); p[1] = (ORD8)(d); } -void write_ORD16_le(unsigned int d, ORD8 *p) { +void write_ORD16_le(ORD8 *p, unsigned int d) { if (d > 0xffff) d = 0xffff; p[0] = (ORD8)(d); @@ -1680,7 +1708,7 @@ int read_INR16_le(ORD8 *p) { return rv; } -void write_INR16_be(int d, ORD8 *p) { +void write_INR16_be(ORD8 *p, int d) { if (d > 0x7fff) d = 0x7fff; else if (d < -0x8000) @@ -1689,7 +1717,7 @@ void write_INR16_be(int d, ORD8 *p) { p[1] = (ORD8)(d); } -void write_INR16_le(int d, ORD8 *p) { +void write_INR16_le(ORD8 *p, int d) { if (d > 0x7fff) d = 0x7fff; else if (d < -0x8000) @@ -1719,14 +1747,14 @@ unsigned int read_ORD32_le(ORD8 *p) { return rv; } -void write_ORD32_be(unsigned int d, ORD8 *p) { +void write_ORD32_be(ORD8 *p, unsigned int d) { p[0] = (ORD8)(d >> 24); p[1] = (ORD8)(d >> 16); p[2] = (ORD8)(d >> 8); p[3] = (ORD8)(d); } -void write_ORD32_le(unsigned int d, ORD8 *p) { +void write_ORD32_le(ORD8 *p, unsigned int d) { p[0] = (ORD8)(d); p[1] = (ORD8)(d >> 8); p[2] = (ORD8)(d >> 16); @@ -1754,14 +1782,14 @@ int read_INR32_le(ORD8 *p) { return rv; } -void write_INR32_be(int d, ORD8 *p) { +void write_INR32_be(ORD8 *p, int d) { p[0] = (ORD8)(d >> 24); p[1] = (ORD8)(d >> 16); p[2] = (ORD8)(d >> 8); p[3] = (ORD8)(d); } -void write_INR32_le(int d, ORD8 *p) { +void write_INR32_le(ORD8 *p, int d) { p[0] = (ORD8)(d); p[1] = (ORD8)(d >> 8); p[2] = (ORD8)(d >> 16); @@ -1797,7 +1825,7 @@ ORD64 read_ORD64_le(ORD8 *p) { return rv; } -void write_ORD64_be(ORD64 d, ORD8 *p) { +void write_ORD64_be(ORD8 *p, ORD64 d) { p[0] = (ORD8)(d >> 56); p[1] = (ORD8)(d >> 48); p[2] = (ORD8)(d >> 40); @@ -1808,7 +1836,7 @@ void write_ORD64_be(ORD64 d, ORD8 *p) { p[7] = (ORD8)(d); } -void write_ORD64_le(ORD64 d, ORD8 *p) { +void write_ORD64_le(ORD8 *p, ORD64 d) { p[0] = (ORD8)(d); p[1] = (ORD8)(d >> 8); p[2] = (ORD8)(d >> 16); @@ -1848,7 +1876,7 @@ INR64 read_INR64_le(ORD8 *p) { return rv; } -void write_INR64_be(INR64 d, ORD8 *p) { +void write_INR64_be(ORD8 *p, INR64 d) { p[0] = (ORD8)(d >> 56); p[1] = (ORD8)(d >> 48); p[2] = (ORD8)(d >> 40); @@ -1859,7 +1887,7 @@ void write_INR64_be(INR64 d, ORD8 *p) { p[7] = (ORD8)(d); } -void write_INR64_le(INR64 d, ORD8 *p) { +void write_INR64_le(ORD8 *p, INR64 d) { p[0] = (ORD8)(d); p[1] = (ORD8)(d >> 8); p[2] = (ORD8)(d >> 16); diff --git a/numlib/numsup.h b/numlib/numsup.h old mode 100644 new mode 100755 index 1fb83bc..a284809 --- a/numlib/numsup.h +++ b/numlib/numsup.h @@ -85,8 +85,6 @@ #define PNTR UINT_PTR -#define vsnprintf _vsnprintf - #define PF64PREC "I64" /* printf format precision specifier */ #define CF64PREC "LL" /* Constant precision specifier */ @@ -310,6 +308,10 @@ void a1loge(a1log *log, int ecode, char *fmt, ...); /* This resets errc and errm */ void a1logue(a1log *log); +/* Print bytes as hex to debug log */ +/* base is the base of the displayed offset */ +void adump_bytes(a1log *log, char *pfx, unsigned char *buf, int base, int len); + /* =========================================================== */ /* Globals used to hold certain information */ extern char *exe_path; /* Path leading to executable, not including exe name itself. */ @@ -454,47 +456,47 @@ char *ctime_64(const INR64 *timer); /* Unsigned 8 bit */ unsigned int read_ORD8(ORD8 *p); -void write_ORD8(unsigned int d, ORD8 *p); +void write_ORD8(ORD8 *p, unsigned int d); /* Signed 8 bit */ int read_INR8(ORD8 *p); -void write_INR8(int d, ORD8 *p); +void write_INR8(ORD8 *p, int d); /* Unsigned 16 bit */ unsigned int read_ORD16_be(ORD8 *p); unsigned int read_ORD16_le(ORD8 *p); -void write_ORD16_be(unsigned int d, ORD8 *p); -void write_ORD16_le(unsigned int d, ORD8 *p); +void write_ORD16_be(ORD8 *p, unsigned int d); +void write_ORD16_le(ORD8 *p, unsigned int d); /* Signed 16 bit */ int read_INR16_be(ORD8 *p); int read_INR16_le(ORD8 *p); -void write_INR16_be(int d, ORD8 *p); -void write_INR16_le(int d, ORD8 *p); +void write_INR16_be(ORD8 *p, int d); +void write_INR16_le(ORD8 *p, int d); /* Unsigned 32 bit */ unsigned int read_ORD32_be(ORD8 *p); unsigned int read_ORD32_le(ORD8 *p); -void write_ORD32_be(unsigned int d, ORD8 *p); -void write_ORD32_le(unsigned int d, ORD8 *p); +void write_ORD32_be(ORD8 *p, unsigned int d); +void write_ORD32_le(ORD8 *p, unsigned int d); /* Signed 32 bit */ int read_INR32_be(ORD8 *p); int read_INR32_le(ORD8 *p); -void write_INR32_be(int d, ORD8 *p); -void write_INR32_le(int d, ORD8 *p); +void write_INR32_be(ORD8 *p, int d); +void write_INR32_le(ORD8 *p, int d); /* Unsigned 64 bit */ ORD64 read_ORD64_be(ORD8 *p); ORD64 read_ORD64_le(ORD8 *p); -void write_ORD64_be(ORD64 d, ORD8 *p); -void write_ORD64_le(ORD64 d, ORD8 *p); +void write_ORD64_be(ORD8 *p, ORD64 d); +void write_ORD64_le(ORD8 *p, ORD64 d); /* Signed 64 bit */ INR64 read_INR64_be(ORD8 *p); INR64 read_INR64_le(ORD8 *p); -void write_INR64_be(INR64 d, ORD8 *p); -void write_INR64_le(INR64 d, ORD8 *p); +void write_INR64_be(ORD8 *p, INR64 d); +void write_INR64_le(ORD8 *p, INR64 d); /*******************************************/ /* Numerical diagnostics */ diff --git a/numlib/powell.c b/numlib/powell.c old mode 100644 new mode 100755 diff --git a/numlib/powell.h b/numlib/powell.h old mode 100644 new mode 100755 diff --git a/numlib/rand.c b/numlib/rand.c old mode 100644 new mode 100755 diff --git a/numlib/rand.h b/numlib/rand.h old mode 100644 new mode 100755 diff --git a/numlib/sobol.c b/numlib/sobol.c old mode 100644 new mode 100755 diff --git a/numlib/sobol.h b/numlib/sobol.h old mode 100644 new mode 100755 diff --git a/numlib/soboltest.c b/numlib/soboltest.c old mode 100644 new mode 100755 diff --git a/numlib/svd.c b/numlib/svd.c old mode 100644 new mode 100755 diff --git a/numlib/svd.h b/numlib/svd.h old mode 100644 new mode 100755 diff --git a/numlib/svdtest.c b/numlib/svdtest.c old mode 100644 new mode 100755 diff --git a/numlib/tdhsx.c b/numlib/tdhsx.c old mode 100644 new mode 100755 diff --git a/numlib/tpowell.c b/numlib/tpowell.c old mode 100644 new mode 100755 diff --git a/numlib/ui.c b/numlib/ui.c old mode 100644 new mode 100755 index fefdcc2..31fd3b6 --- a/numlib/ui.c +++ b/numlib/ui.c @@ -119,13 +119,21 @@ int main(int argc, char ** argv) { /* Call the real main() in another thread */ int rv; + pthread_attr_t stackSzAtrbt; pthread_t thid; g_argc = argc; g_argv = argv; ui_initialized = 1; - if ((rv = pthread_create(&thid, NULL, callMain, (void *)NULL)) != 0) { + /* Default stack size is 512K - this is a bit small - raise it */ + if ((rv = pthread_attr_init(&stackSzAtrbt)) != 0 + || (rv = pthread_attr_setstacksize(&stackSzAtrbt, 4 * 1024 * 1024)) != 0) { + fprintf(stderr,"ui: thread_attr_setstacksize failed with %d\n",rv); + return -1; + } + + if ((rv = pthread_create(&thid, &stackSzAtrbt, callMain, (void *)NULL)) != 0) { fprintf(stderr,"ui: pthread_create failed with %d\n",rv); return -1; } diff --git a/numlib/ui.h b/numlib/ui.h old mode 100644 new mode 100755 diff --git a/numlib/zbrent.c b/numlib/zbrent.c old mode 100644 new mode 100755 diff --git a/numlib/zbrent.h b/numlib/zbrent.h old mode 100644 new mode 100755 diff --git a/numlib/zbrenttest.c b/numlib/zbrenttest.c old mode 100644 new mode 100755 -- cgit v1.2.3