Skip to content

Commit

Permalink
Update ASL to version 20150107
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jan 7, 2015
1 parent 1f84b01 commit c22ccc6
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 44 deletions.
5 changes: 2 additions & 3 deletions src/asl/solvers/00lastchange
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
20141202
mqpcheckv.c: fix a glitch (missed zeroing of an array element) that
somehow escaped earlier testing.
20150101
funcadd1.c: tweaks to error messages.
2 changes: 1 addition & 1 deletion src/asl/solvers/asldate.c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
long ASLdate_ASL = 20141202;
long ASLdate_ASL = 20150101;
14 changes: 14 additions & 0 deletions src/asl/solvers/changes
Original file line number Diff line number Diff line change
Expand Up @@ -2439,3 +2439,17 @@ free(qpi) to dispose of qpi.
20141202
mqpcheckv.c: fix a glitch (missed zeroing of an array element) that
somehow escaped earlier testing.

20141223
mqpcheckv.c: fix a bug (possible invalid free() call) with problems
where ASL_obj_replace_eq or ASL_obj_replace_ineq matters.

20141229
objconst.c: adjust objconst() to work correctly after qp_read().

20150101
funcadd1.c: tweaks to error messages.

20150107
funcadd.h: change line 271 from "#ifdef _WIN32" to
"#if defined(_WIN32) && !defined(__MINGW32__)"; no change to asldate.c.
61 changes: 40 additions & 21 deletions src/asl/solvers/funcadd1.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ funcadd(AmplExports *ae)
#include "string.h"
#include "funcadd.h"
#include "arith.h" /* for X64_bit_pointers */
#include <sys/types.h>
#include <sys/stat.h>
#ifndef S_IFREG /*{*/
#ifdef __S_IFREG
#define S_IFREG __S_IFREG
#define S_IFDIR __S_IFDIR
#elif defined(_S_IFREG)
#define S_IFREG _S_IFREG
#define S_IFDIR _S_IFDIR
#endif
#endif /*}*/
#ifdef X64_bit_pointers
static char Bits[] = "64", BitsAlt[] = "32";
#else
Expand Down Expand Up @@ -100,6 +111,20 @@ extern const char *i_option_ASL;

static int first = 1;

static int
file_kind(const char *name) /* 1 == regular file, 2 ==> directory; else 0 */
{
struct stat sb;

if (stat(name,&sb))
return 0;
if (sb.st_mode & S_IFDIR)
return 2;
if (sb.st_mode & S_IFREG)
return 1;
return 0;
}

#ifdef WIN32

#define SLASH '\\'
Expand All @@ -109,7 +134,6 @@ typedef HINSTANCE shl_t;
#define find_dlsym(a,b,c) (a = (Funcadd*)GetProcAddress(b,c))
#define dlclose(x) FreeLibrary((HMODULE)x)
#define NO_DLERROR
#define reg_file(x) 1

static int
Abspath(const char *s)
Expand All @@ -133,16 +157,6 @@ char afdll[] = "/amplfunc.dll";
#include "unistd.h" /* for getcwd */
#define GetCurrentDirectory(a,b) getcwd(b,(int)(a))

#include <sys/types.h>
#include <sys/stat.h>

static int
reg_file(const char *name)
{
struct stat sb;
return stat(name,&sb) ? 0 : S_ISREG(sb.st_mode);
}

#ifdef __hpux
#include "dl.h"
#define dlopen(x,y) shl_load(x, BIND_IMMEDIATE, 0)
Expand Down Expand Up @@ -241,7 +255,7 @@ dl_open(AmplExports *ae, char *name, int *warned, int *pns)
#ifdef Old_APPLE
NS_pair p;
#endif
d = d0 = 0;
d = d0 = dz = 0;
for(s = name; *s; ++s)
switch(*s) {
case '.':
Expand All @@ -254,7 +268,6 @@ dl_open(AmplExports *ae, char *name, int *warned, int *pns)
d = 0;
}
ns = s - name;
dz = 0;
if (d
&& d - name > 3
&& d[-3] == '_') {
Expand Down Expand Up @@ -317,16 +330,16 @@ dl_open(AmplExports *ae, char *name, int *warned, int *pns)
d = dz = 0;
goto tryagain;
}
if (d0)
for(s = d0; (s[0] = s[3]); ++s);
if (!warned && (f = fopen(name,"rb"))) {
fclose(f);
if (reg_file(name)) {
if (file_kind(name) == 1) {
*warned = 1;
if (d0)
for(s = d0; (s[0] = s[3]); ++s);
#ifdef NO_DLERROR
fprintf(Stderr, "Cannot load library %s.\n", name);
fprintf(Stderr, "Cannot load library \"%s\".\n", name);
#else
fprintf(Stderr, "Cannot load library %s", name);
fprintf(Stderr, "Cannot load library \"%s\"", name);
cs = dlerror();
fprintf(Stderr, cs ? ":\n%s\n" : ".\n", cs);
#endif
Expand Down Expand Up @@ -410,9 +423,15 @@ libload_ASL(AmplExports *ae, const char *s, int ns, int warn)
else {
notfound:
rc = rcnf;
if (warn)
fprintf(Stderr, "Cannot find library %.*s\nor %.*s%s\n",
ns, s, ns, s, afdll);
if (warn) {
buf[nx+ns] = 0;
if (file_kind(buf) == 2) {
buf[nx+ns] = SLASH;
fprintf(Stderr, "Cannot find library \"%s\".\n", buf);
}
else
fprintf(Stderr, "Cannot find library \"%.*s\".\n", ns, s);
}
}
if (buf != buf0)
free(buf);
Expand Down
29 changes: 16 additions & 13 deletions src/asl/solvers/mqpcheckv.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ mqpcheckv_ASL(ASL *a, int co, QPinfo **QPIp, void **vp)
expr *e;
expr_n *en;
int *cm, *colno, *qm, *rowq, *rowq0, *rowq1, *s, *vmi, *w, *z;
int arrays, co0, ftn, i, icol, j, ncol, ncom, nv, nz, pass;
int arrays, co0, ftn, i, icol, j, ncol, ncom, nv, nva, nz, pass;
ograd *og, *og1, *og2, **ogp;
real *L, *U, *delsq, *delsq0, *delsq1, objadj, t, *x;
size_t *colq, *colq1, nelq;
Expand Down Expand Up @@ -659,15 +659,18 @@ mqpcheckv_ASL(ASL *a, int co, QPinfo **QPIp, void **vp)
nv = n_var;
ncom = ncom0 + ncom1;
if (!(S = *(Static**)vp)) {
x = (double *)Malloc(nv*(sizeof(double)
i = asl->i.n_var0 + asl->i.nsufext[0];
if ((nva = nv) < i)
nva = i;
x = (double *)Malloc(nva*(sizeof(double)
+sizeof(dyad*)
+sizeof(ograd*)
+sizeof(dispatch*)
+sizeof(dispatch)
+3*sizeof(int))
+ sizeof(Memblock)
+ sizeof(Static));
mb = (Memblock*)(x + nv);
mb = (Memblock*)(x + nva);
mb->prev = mb->next = 0;
S = (Static*)(mb + 1);
*vp = (void*)S;
Expand All @@ -676,16 +679,16 @@ mqpcheckv_ASL(ASL *a, int co, QPinfo **QPIp, void **vp)
s_x = x;
S->asl = asl;
s_q = q = (dyad**)(S+1);
S->oq = (ograd**)(q + nv);
S->cdisp = cdisp = (dispatch**)(S->oq + nv);
S->cd0 = cd0 = (dispatch*)(cdisp + nv);
s_z = z = (int*)(cd0 + nv);
s_s = s = z + nv;
S->w = (int*)(s + nv);
memset(s, 0, nv*sizeof(int));
memset(cdisp, 0, nv*sizeof(dispatch*));
memset(q, 0, nv*sizeof(dyad *));
memset(S->w, 0, nv*sizeof(int));
S->oq = (ograd**)(q + nva);
S->cdisp = cdisp = (dispatch**)(S->oq + nva);
S->cd0 = cd0 = (dispatch*)(cdisp + nva);
s_z = z = (int*)(cd0 + nva);
s_s = s = z + nva;
S->w = (int*)(s + nva);
memset(s, 0, nva*sizeof(int));
memset(cdisp, 0, nva*sizeof(dispatch*));
memset(q, 0, nva*sizeof(dyad *));
memset(S->w, 0, nva*sizeof(int));
if (ncom) {
cterms = (term **)Malloc(ncom*(sizeof(term*)+sizeof(int)));
memset(cterms, 0, ncom*sizeof(term*));
Expand Down
2 changes: 1 addition & 1 deletion src/asl/solvers/objconst.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ objconst_ASL(ASL *asl, int n)
default:
e = (expr_n*)(((ASL_fg*)asl)->I.obj_de_ + n)->e;
}
if (e->op == opnum)
if (e->op == opnum || e->op == (efunc_n *)f_OPNUM)
return e->v;
}
return 0;
Expand Down
10 changes: 5 additions & 5 deletions src/asl/solvers/xsum0.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ arithchk.c 91ee1e0 5988
asl.h f654881e 41016
asl_pfg.h 6483336 1268
asl_pfgh.h 49b5a53 1288
asldate.c 1aaf2c8 29
asldate.c fee89a64 29
atof.c 1fabc7d3 1747
auxinfo.c 1a3c8690 1488
avltree.c 10aeaa58 11346
Expand Down Expand Up @@ -49,9 +49,9 @@ fpsetprec64.s 987339e 488
fullhes.c eeea81e 3978
func_add.c f0fbaf4e 11444
funcadd.c f4e86ce3 3493
funcadd.h 1f9107e8 16174
funcadd.h ea4c340e 16205
funcadd0.c 10310942 1338
funcadd1.c 1606928f 10153
funcadd1.c ec16454a 10574
funcaddk.c 1913fb94 3359
funcaddr.c fc16b89a 1197
g_fmt.c efcfdd3b 3452
Expand Down Expand Up @@ -80,7 +80,7 @@ mip_pri.c f1dd1d47 7887
misc.c f14430af 28836
mpec_adj.c e172a389 9468
mpec_adj0.c efb8be74 70
mqpcheckv.c f59e1148 19285
mqpcheckv.c 58f6e67 19377
mypow.c 1571ef65 2294
names.c f8260637 3984
nl_obj.c e8fa1e1 2560
Expand All @@ -93,7 +93,7 @@ obj_adj.c f415c1b4 13409
obj_adj.h eed794cf 2218
obj_adj0.c ffe042be 67
obj_prec.c fd065560 1440
objconst.c 11aa4770 2257
objconst.c b53a63b 2288
objval.c 1ba4b273 5294
objval_.c f830a04e 3516
op_type.c f0c0c4a8 1255
Expand Down

0 comments on commit c22ccc6

Please sign in to comment.