00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "config.h"
00018
00019 extern void init_misc(void);
00020 extern EmbeddedTcl et_ns_lib;
00021 extern EmbeddedTcl et_ns_ptypes;
00022
00023
00024 #ifdef MEMDEBUG_SIMULATIONS
00025 #include "mem-trace.h"
00026 MemTrace *globalMemTrace;
00027 #endif
00028
00029 extern "C" {
00030
00031
00032
00033
00034
00035
00036 #ifdef TCL_TEST
00037 EXTERN int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00038 #endif
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 int
00058 main(int argc, char **argv)
00059 {
00060 Tcl_Main(argc, argv, Tcl_AppInit);
00061 return 0;
00062 }
00063
00064
00065 #if defined(linux) && defined(i386) && (defined(HAVE_FESETPRECISION) || defined(__GNUC__))
00066 #ifndef HAVE_FESETPRECISION
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #define FE_FLTPREC 0x000
00077 #define FE_INVALIDPREC 0x100
00078 #define FE_DBLPREC 0x200
00079 #define FE_LDBLPREC 0x300
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 static inline int fesetprecision(int prec)
00094 {
00095 if ( !(prec & ~FE_LDBLPREC) && (prec != FE_INVALIDPREC) )
00096 {
00097 unsigned short cw;
00098 asm ("fnstcw %0":"=m" (cw));
00099 cw = (cw & ~FE_LDBLPREC) | (prec & FE_LDBLPREC);
00100 asm volatile ("fldcw %0" : : "m" (cw));
00101 return 1;
00102 }
00103 else
00104 return 0;
00105 }
00106 #endif
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 static inline void
00120 fix_i386_linux_floats()
00121 {
00122 fesetprecision(FE_DBLPREC);
00123 }
00124 #else
00125 static inline void
00126 fix_i386_linux_floats()
00127 {}
00128 #endif
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 int
00151 Tcl_AppInit(Tcl_Interp *interp)
00152 {
00153 #ifdef MEMDEBUG_SIMULATIONS
00154 extern MemTrace *globalMemTrace;
00155 globalMemTrace = new MemTrace;
00156 #endif
00157
00158 fix_i386_linux_floats();
00159
00160 if (Tcl_Init(interp) == TCL_ERROR ||
00161 Otcl_Init(interp) == TCL_ERROR)
00162 return TCL_ERROR;
00163
00164 #ifdef HAVE_LIBTCLDBG
00165 extern int Tcldbg_Init(Tcl_Interp *);
00166 if (Tcldbg_Init(interp) == TCL_ERROR) {
00167 return TCL_ERROR;
00168 }
00169 #endif
00170
00171 Tcl_SetVar(interp, "tcl_rcFileName", "~/.ns.tcl", TCL_GLOBAL_ONLY);
00172 Tcl::init(interp, "ns");
00173 init_misc();
00174 et_ns_ptypes.load();
00175 et_ns_lib.load();
00176
00177
00178 #ifdef TCL_TEST
00179 if (Tcltest_Init(interp) == TCL_ERROR) {
00180 return TCL_ERROR;
00181 }
00182 Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
00183 (Tcl_PackageInitProc *) NULL);
00184 #endif
00185
00186 return TCL_OK;
00187 }
00188
00189 #ifndef WIN32
00190 void
00191 abort()
00192 {
00193 Tcl& tcl = Tcl::instance();
00194 tcl.evalc("[Simulator instance] flush-trace");
00195 #ifdef abort
00196 #undef abort
00197 abort();
00198 #else
00199 exit(1);
00200 #endif
00201
00202 }
00203 #endif
00204
00205 }
00206
00207