1 |
/* ASCEND modelling environment |
/* ASCEND modelling environment |
2 |
Copyright (C) 2006 Carnegie Mellon University |
Copyright (C) 2006-2011 Carnegie Mellon University |
3 |
Copyright (C) 1998 Carnegie Mellon University |
Copyright (C) 1998 Carnegie Mellon University |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
30 |
* much of this goes in bintoken.h. |
* much of this goes in bintoken.h. |
31 |
*/ |
*/ |
32 |
|
|
33 |
|
#include <ascend/utilities/config.h> |
34 |
#include "bintoken.h" |
#include "bintoken.h" |
35 |
|
|
36 |
#include <unistd.h> /* for getpid() */ |
#include <unistd.h> /* for getpid() */ |
37 |
|
|
|
#include <ascend/utilities/config.h> |
|
38 |
#include <ascend/general/platform.h> |
#include <ascend/general/platform.h> |
39 |
#include <ascend/general/ascMalloc.h> |
#include <ascend/general/ascMalloc.h> |
40 |
#include <ascend/utilities/ascPrint.h> |
#include <ascend/utilities/ascPrint.h> |
61 |
|
|
62 |
#include <ascend/bintokens/btprolog.h> |
#include <ascend/bintokens/btprolog.h> |
63 |
|
|
64 |
/* #define BINTOKEN_VERBOSE */ |
#define BINTOKEN_VERBOSE |
65 |
|
|
66 |
#define CLINE(a) FPRINTF(fp,"%s\n",(a)) |
#define CLINE(a) FPRINTF(fp,"%s\n",(a)) |
67 |
|
|
389 |
unsigned long len, int verbose) |
unsigned long len, int verbose) |
390 |
{ |
{ |
391 |
if (verbose) { |
if (verbose) { |
392 |
CLINE("/*\n\tBinTokenSharesToC $Revision: 1.12 $"); |
CLINE("/*\n\tAuto-generated code from" __FILE__); |
393 |
FPRINTF(fp,"\t%lu relations in instance '",len); |
FPRINTF(fp,"\t%lu relations in instance '",len); |
394 |
WriteInstanceName(fp,root,NULL); |
WriteInstanceName(fp,root,NULL); |
395 |
CLINE("'\n\t(possibly fewer C functions required)\n*/"); |
CLINE("'\n\t(possibly fewer C functions required)\n*/"); |
468 |
} else { |
} else { |
469 |
CLINE(" ;"); |
CLINE(" ;"); |
470 |
} |
} |
471 |
|
#ifdef BINTOKEN_VERBOSE |
472 |
|
FPRINTF(fp," fprintf(stderr,\"%%s:%%d: residual for '%%s' is %%f.\\n\", __FILE__, __LINE__, \""); |
473 |
|
WriteAnyInstanceName(fp,i); |
474 |
|
FPRINTF(fp,"\", *residual);\n"); |
475 |
|
#endif |
476 |
CLINE("}"); |
CLINE("}"); |
477 |
return BTE_ok; |
return BTE_ok; |
478 |
} |
} |
632 |
/** @TODO FIXME win32 has getpid but it is bogus as uniquifier. */ |
/** @TODO FIXME win32 has getpid but it is bogus as uniquifier. */ |
633 |
/* so long as makefile deletes previous dll, windows is ok though */ |
/* so long as makefile deletes previous dll, windows is ok though */ |
634 |
sprintf(g_bt_data.regname,"BinTokenArch_%d_%d",++(g_bt_data.nextid),(int)pid); |
sprintf(g_bt_data.regname,"BinTokenArch_%d_%d",++(g_bt_data.nextid),(int)pid); |
635 |
FPRINTF(fp,"int ASC_EXPORT %s(){\n",g_bt_data.regname); |
FPRINTF(fp,"\n\nint ASC_EXPORT %s(){\n",g_bt_data.regname); |
636 |
CLINE("\tint status;"); |
CLINE("\tint status;"); |
637 |
FPRINTF(fp,"\tstatic struct TableC g_ctable[%lu] =\n",len+1); |
FPRINTF(fp,"\tstatic struct TableC g_ctable[%lu] =\n",len+1); |
638 |
CLINE("\t\t{ {NULL, NULL},"); |
CLINE("\t\t{ {NULL, NULL},"); |
672 |
ERROR_REPORTER_NOLINE(ASC_PROG_NOTE,"Starting build, command:\n%s\n",buildcommand); |
ERROR_REPORTER_NOLINE(ASC_PROG_NOTE,"Starting build, command:\n%s\n",buildcommand); |
673 |
status = system(buildcommand); |
status = system(buildcommand); |
674 |
if (status) { |
if (status) { |
675 |
FPRINTF(ASCERR,"\nBUILD returned %d\n",status); |
CONSOLE_DEBUG("BUILD returned %d",status); |
676 |
return BTE_build; |
return BTE_build; |
677 |
} |
} |
678 |
|
#ifdef BINTOKEN_VERBOSE |
679 |
|
CONSOLE_DEBUG("Build command returned OK, status=%d",status); |
680 |
|
#endif |
681 |
return BTE_ok; |
return BTE_ok; |
682 |
} |
} |
683 |
|
|
792 |
return; |
return; |
793 |
} |
} |
794 |
if (srcname == NULL || buildcommand == NULL || unlinkcommand == NULL) { |
if (srcname == NULL || buildcommand == NULL || unlinkcommand == NULL) { |
795 |
#ifdef BINTOKEN_VERBOSE |
#if 0 |
796 |
ERROR_REPORTER_HERE(ASC_PROG_WARNING,"BinaryTokensCreate called with no options set: ignoring"); |
ERROR_REPORTER_HERE(ASC_PROG_WARNING,"BinaryTokensCreate called with no options set: ignoring"); |
797 |
#endif |
#endif |
798 |
return; |
return; |