From 24786b208a0f078361cab4eb91f7eca3b1b2e383 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 22 May 2019 10:38:00 -0400 Subject: [PATCH 1/5] Corrected a badly-implemented search for electrical connectivity through labels with the same text (particularly necessary for abstract views, since the real connectivity may not be represented). The original implementation could generate very deep subroutine call stacks and lead to stack overflow. The new implementation performs the same check but without the deep nesting. --- database/DBconnect.c | 161 ++++++++++++++++++++++-------------------- defs.mak | 6 +- scripts/config.log | 20 +++--- scripts/config.status | 14 ++-- scripts/defs.mak | 6 +- 5 files changed, 108 insertions(+), 99 deletions(-) diff --git a/database/DBconnect.c b/database/DBconnect.c index ff007e5d..f1f5a6ab 100644 --- a/database/DBconnect.c +++ b/database/DBconnect.c @@ -689,30 +689,71 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2) CellDef *orig_def = scx->scx_use->cu_def; Label *slab; int lidx = lab->lab_flags & PORT_NUM_MASK; + TileTypeBitMask *connectMask; /* Check for equivalent ports. For any found, call */ /* DBTreeSrTiles recursively on the type and area */ /* of the label. */ + /* Don't recurse, just add area to the csa2_list. */ + /* Only add the next label found to the list. If there */ + /* are more equivalent ports, they will be found when */ + /* processing this label's area. */ + for (slab = orig_def->cd_labels; slab != NULL; slab = slab->lab_next) if ((slab->lab_flags & PORT_DIR_MASK) && (slab != lab)) if ((slab->lab_flags & PORT_NUM_MASK) == lidx) { - SearchContext scx2 = *csa2->csa2_topscx; - TileTypeBitMask mask; + Rect newarea; + int pNum; // Do NOT go searching on labels connected to space! if (slab->lab_type == TT_SPACE) continue; - TTMaskSetOnlyType(&mask, slab->lab_type); - GeoTransRect(&scx->scx_trans, &slab->lab_rect, &scx2.scx_area); - // Expand search area by 1 to capture edge and point labels. - scx2.scx_area.r_xbot--; - scx2.scx_area.r_xtop++; - scx2.scx_area.r_ybot--; - scx2.scx_area.r_ytop++; - DBTreeSrTiles(&scx2, &mask, csa2->csa2_xMask, - dbcConnectFunc, (ClientData) csa2); + GeoTransRect(&scx->scx_trans, &slab->lab_rect, &newarea); + + // Avoid infinite looping. If material under the label + // has already been added to the destination, then ignore. + + connectMask = &csa2->csa2_connect[slab->lab_type]; + + pNum = DBPlane(slab->lab_type); + if (DBSrPaintArea((Tile *) NULL, def->cd_planes[pNum], + &newarea, connectMask, dbcUnconnectFunc, + (ClientData) NULL) == 1) + continue; + + newarea.r_xbot--; + newarea.r_xtop++; + newarea.r_ybot--; + newarea.r_ytop++; + + /* Register the area and connection mask as needing to be processed */ + + if (++csa2->csa2_top == csa2->csa2_size) + { + /* Reached list size limit---need to enlarge the list */ + /* Double the size of the list every time we hit the limit */ + + conSrArea *newlist; + int i, lastsize = csa2->csa2_size; + + csa2->csa2_size *= 2; + + newlist = (conSrArea *)mallocMagic(csa2->csa2_size + * sizeof(conSrArea)); + memcpy((void *)newlist, (void *)csa2->csa2_list, + (size_t)lastsize * sizeof(conSrArea)); + freeMagic((char *)csa2->csa2_list); + csa2->csa2_list = newlist; + } + + csa2->csa2_list[csa2->csa2_top].area = newarea; + csa2->csa2_list[csa2->csa2_top].connectMask = connectMask; + csa2->csa2_list[csa2->csa2_top].dinfo = 0; + + /* See above: Process only one equivalent port at a time */ + break; } } return 0; @@ -809,34 +850,12 @@ dbcConnectFunc(tile, cx) if (DBIsContact(loctype)) { -// TileType ctype; -// TileTypeBitMask *cMask, *rMask = DBResidueMask(loctype); - -// TTMaskSetOnlyType(¬ConnectMask, loctype); - /* Different contact types may share residues (6/18/04) */ /* Use TTMaskIntersect(), not TTMaskEqual()---types */ /* which otherwise stack may be in separate cells */ /* (12/1/05) */ -// for (ctype = TT_TECHDEPBASE; ctype < DBNumUserLayers; ctype++) -// { -// if (DBIsContact(ctype)) -// { -// cMask = DBResidueMask(ctype); -// if (TTMaskIntersect(rMask, cMask)) -// TTMaskSetType(¬ConnectMask, ctype); -// } -// } - /* The mask of contact types must include all stacked contacts */ -// for (ctype = DBNumUserLayers; ctype < DBNumTypes; ctype++) -// { -// cMask = DBResidueMask(ctype); -// if (TTMaskHasType(cMask, loctype)) -// TTMaskSetType(¬ConnectMask, ctype); -// } -// TTMaskCom(¬ConnectMask); TTMaskZero(¬ConnectMask); TTMaskSetMask(¬ConnectMask, &DBNotConnectTbl[loctype]); @@ -864,43 +883,6 @@ dbcConnectFunc(tile, cx) &newarea, DBStdPaintTbl(loctype, pNum), (PaintUndoInfo *) NULL); - /* Check the source def for any labels belonging to this */ - /* tile area and plane, and add them to the destination. */ - - searchtype = TF_LABEL_ATTACH; - if (IsSplit(tile)) - { - /* If the tile is split, then labels attached to the */ - /* opposite point of the triangle are NOT connected. */ - - if (SplitSide(tile)) - { - if (SplitDirection(tile)) - searchtype |= TF_LABEL_ATTACH_NOT_SW; - else - searchtype |= TF_LABEL_ATTACH_NOT_NW; - } - else - { - if (SplitDirection(tile)) - searchtype |= TF_LABEL_ATTACH_NOT_NE; - else - searchtype |= TF_LABEL_ATTACH_NOT_SE; - } - } - - /* Note that the search must be done from the top since zero-size */ - /* port labels can be on any part of the hierarchy with no paint */ - /* underneath in its own cell to trigger the callback function. */ - - /* Copy information from top search context into new search context */ - scx2 = *csa2->csa2_topscx; - scx2.scx_area = newarea; - - DBTreeSrLabels(&scx2, connectMask, csa2->csa2_xMask, NULL, - searchtype, dbcConnectLabelFunc, - (ClientData) csa2); - /* Since the whole area of this tile hasn't been recorded, * we must process its area to find any other tiles that * connect to it. Add each of them to the list of things @@ -947,12 +929,6 @@ dbcConnectFunc(tile, cx) newlist = (conSrArea *)mallocMagic(csa2->csa2_size * sizeof(conSrArea)); memcpy((void *)newlist, (void *)csa2->csa2_list, (size_t)lastsize * sizeof(conSrArea)); - // for (i = 0; i < lastsize; i++) - // { - // newlist[i].area = csa2->csa2_list[i].area; - // newlist[i].connectMask = csa2->csa2_list[i].connectMask; - // newlist[i].dinfo = csa2->csa2_list[i].dinfo; - // } freeMagic((char *)csa2->csa2_list); csa2->csa2_list = newlist; } @@ -1023,6 +999,7 @@ DBTreeCopyConnect(scx, mask, xMask, connect, area, destUse) struct conSrArg2 csa2; TileTypeBitMask *newmask; TileType newtype; + unsigned char searchtype; csa2.csa2_use = destUse; csa2.csa2_xMask = xMask; @@ -1052,6 +1029,38 @@ DBTreeCopyConnect(scx, mask, xMask, connect, area, destUse) (ClientData) &csa2); else DBTreeSrTiles(scx, newmask, xMask, dbcConnectFunc, (ClientData) &csa2); + + /* Check the source def for any labels belonging to this */ + /* tile area and plane, and add them to the destination. */ + + /* (This code previously in dbcConnectFunc, but moved to avoid */ + /* running the cell search from the top within another cell */ + /* search, which creates deep stacks and can trigger stack */ + /* overflow.) */ + + searchtype = TF_LABEL_ATTACH; + if (newtype & TT_DIAGONAL) + { + /* If the tile is split, then labels attached to the */ + /* opposite point of the triangle are NOT connected. */ + + if (newtype & TT_SIDE) + { + if (newtype & TT_DIRECTION) + searchtype |= TF_LABEL_ATTACH_NOT_SW; + else + searchtype |= TF_LABEL_ATTACH_NOT_NW; + } + else + { + if (newtype & TT_DIRECTION) + searchtype |= TF_LABEL_ATTACH_NOT_NE; + else + searchtype |= TF_LABEL_ATTACH_NOT_SE; + } + } + DBTreeSrLabels(scx, newmask, xMask, NULL, searchtype, + dbcConnectLabelFunc, (ClientData) &csa2); } freeMagic((char *)csa2.csa2_list); diff --git a/defs.mak b/defs.mak index a18d3130..c3bb2089 100644 --- a/defs.mak +++ b/defs.mak @@ -62,16 +62,16 @@ LIB_SPECS_NOSTUB = -L/usr/lib64 -ltk8.6 -L/usr/lib64 -ltcl8.6 WISH_EXE = /usr/bin/wish TCL_LIB_DIR = /usr/lib MAGIC_VERSION = 8.2 -MAGIC_REVISION = 53 +MAGIC_REVISION = 101 CC = gcc CPP = gcc -E CXX = g++ CPPFLAGS = -I. -I${MAGICDIR} -DFLAGS = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DUSE_TCL_STUBS -DUSE_TK_STUBS -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"53\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" +DFLAGS = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DUSE_TCL_STUBS -DUSE_TK_STUBS -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"101\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" DFLAGS += -DSHDLIB_EXT=\".so\" -DNDEBUG -DFLAGS_NOSTUB = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"53\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" +DFLAGS_NOSTUB = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"101\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" DFLAGS_NOSTUB += -DSHDLIB_EXT=\".so\" -DNDEBUG CFLAGS = -g -m64 -fPIC -Wimplicit-int -fPIC diff --git a/scripts/config.log b/scripts/config.log index bef74eaf..1c3c70ad 100644 --- a/scripts/config.log +++ b/scripts/config.log @@ -125,7 +125,7 @@ configure: failed program was: | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define MAGIC_VERSION "8.2" -| #define MAGIC_REVISION "53" +| #define MAGIC_REVISION "101" | /* end confdefs.h. */ | #include configure:3476: result: gcc -E @@ -146,7 +146,7 @@ configure: failed program was: | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define MAGIC_VERSION "8.2" -| #define MAGIC_REVISION "53" +| #define MAGIC_REVISION "101" | /* end confdefs.h. */ | #include configure:3596: checking for g++ @@ -302,7 +302,7 @@ configure: failed program was: | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define MAGIC_VERSION "8.2" -| #define MAGIC_REVISION "53" +| #define MAGIC_REVISION "101" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 @@ -343,7 +343,7 @@ configure: failed program was: | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define MAGIC_VERSION "8.2" -| #define MAGIC_REVISION "53" +| #define MAGIC_REVISION "101" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 @@ -433,7 +433,7 @@ configure: failed program was: | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define MAGIC_VERSION "8.2" -| #define MAGIC_REVISION "53" +| #define MAGIC_REVISION "101" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 @@ -506,7 +506,7 @@ configure: failed program was: | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | #define MAGIC_VERSION "8.2" -| #define MAGIC_REVISION "53" +| #define MAGIC_REVISION "101" | #define STDC_HEADERS 1 | #define HAVE_SYS_TYPES_H 1 | #define HAVE_SYS_STAT_H 1 @@ -634,7 +634,7 @@ configure:7575: checking for cairo_user_to_device in -lcairo configure:7600: gcc -o conftest -g -lm conftest.c -lcairo -lGLU -lGL >&5 configure:7600: $? = 0 configure:7609: result: yes -configure:8414: creating ./config.status +configure:8417: creating ./config.status ## ---------------------- ## ## Running config.status. ## @@ -759,7 +759,7 @@ CPPFLAGS='' CSH='/bin/csh' CXX='g++' CXXFLAGS='-g -O2' -DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"53\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1' +DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"101\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1' DEPEND_FLAG='-MM' ECHO_C='' ECHO_N='printf' @@ -784,7 +784,7 @@ LIB_SPECS=' -L/usr/lib64 -ltkstub8.6 -L/usr/lib64 -ltclstub8.6' LIB_SPECS_NOSTUB=' -L/usr/lib64 -ltk8.6 -L/usr/lib64 -ltcl8.6' LTLIBOBJS='' M4='/bin/m4' -MAGIC_REVISION='53' +MAGIC_REVISION='101' MAGIC_VERSION='8.2' MCPP='${MAGICDIR}/scripts/preproc.py' OA='' @@ -886,7 +886,7 @@ unused=' readline lisp' #define PACKAGE_BUGREPORT "" #define PACKAGE_URL "" #define MAGIC_VERSION "8.2" -#define MAGIC_REVISION "53" +#define MAGIC_REVISION "101" #define STDC_HEADERS 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_STAT_H 1 diff --git a/scripts/config.status b/scripts/config.status index a51e5746..d8bc0035 100755 --- a/scripts/config.status +++ b/scripts/config.status @@ -427,7 +427,7 @@ Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -ac_pwd='/home/tim/gitsrc/magic-8.2/scripts' +ac_pwd='/home/tim/gitsrc/magic/scripts' srcdir='..' INSTALL='/bin/install -c' test -n "$AWK" || AWK=awk @@ -588,7 +588,7 @@ S["INSTALL_TARGET"]="install-tcl" S["ALL_TARGET"]="tcl" S["OA_LIBS"]="" S["OA"]="" -S["MAGIC_REVISION"]="53" +S["MAGIC_REVISION"]="101" S["MAGIC_VERSION"]="8.2" S["SCPP"]="gcc -E -x c" S["MCPP"]="${MAGICDIR}/scripts/preproc.py" @@ -676,11 +676,11 @@ S["ECHO_T"]="" S["ECHO_N"]="-n" S["ECHO_C"]="" S["DEFS"]="-DPACKAGE_NAME=\\\"\\\" -DPACKAGE_TARNAME=\\\"\\\" -DPACKAGE_VERSION=\\\"\\\" -DPACKAGE_STRING=\\\"\\\" -DPACKAGE_BUGREPORT=\\\"\\\" -DPACKAGE_URL=\\\"\\\" -DMAGIC_VERSION="\ -"\\\"8.2\\\" -DMAGIC_REVISION=\\\"53\\\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHA"\ -"VE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_U"\ -"NSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE"\ -"_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHA"\ -"VE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1" +"\\\"8.2\\\" -DMAGIC_REVISION=\\\"101\\\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DH"\ +"AVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_"\ +"UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAV"\ +"E_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DH"\ +"AVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1" S["mandir"]="${datarootdir}/man" S["localedir"]="${datarootdir}/locale" S["libdir"]="${exec_prefix}/lib" diff --git a/scripts/defs.mak b/scripts/defs.mak index a18d3130..c3bb2089 100644 --- a/scripts/defs.mak +++ b/scripts/defs.mak @@ -62,16 +62,16 @@ LIB_SPECS_NOSTUB = -L/usr/lib64 -ltk8.6 -L/usr/lib64 -ltcl8.6 WISH_EXE = /usr/bin/wish TCL_LIB_DIR = /usr/lib MAGIC_VERSION = 8.2 -MAGIC_REVISION = 53 +MAGIC_REVISION = 101 CC = gcc CPP = gcc -E CXX = g++ CPPFLAGS = -I. -I${MAGICDIR} -DFLAGS = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DUSE_TCL_STUBS -DUSE_TK_STUBS -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"53\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" +DFLAGS = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DUSE_TCL_STUBS -DUSE_TK_STUBS -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"101\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" DFLAGS += -DSHDLIB_EXT=\".so\" -DNDEBUG -DFLAGS_NOSTUB = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"53\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" +DFLAGS_NOSTUB = -DCAD_DIR=\"${LIBDIR}\" -DBIN_DIR=\"${BINDIR}\" -DTCL_DIR=\"${TCLDIR}\" -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DMAGIC_VERSION=\"8.2\" -DMAGIC_REVISION=\"101\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DSIZEOF_UNSIGNED_INT=4 -DSIZEOF_UNSIGNED_LONG=8 -DSIZEOF_UNSIGNED_LONG_LONG=8 -DSTDC_HEADERS=1 -DHAVE_SETENV=1 -DHAVE_PUTENV=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_DIRENT_H=1 -DHAVE_LIMITS_H=1 -DHAVE_PATHS_H=1 -DHAVE_VA_COPY=1 -DHAVE___VA_COPY=1 -DFILE_LOCKS=1 -DCALMA_MODULE=1 -DCIF_MODULE=1 -DPLOT_MODULE=1 -DLEF_MODULE=1 -DROUTE_MODULE=1 -DUSE_NEW_MACROS=1 -DHAVE_LIBGL=1 -DHAVE_LIBGLU=1 -DVECTOR_FONTS=1 -DHAVE_LIBCAIRO=1 -DMAGIC_WRAPPER=1 -DTHREE_D=1 -Dlinux=1 -DSYSV=1 -DISC=1 -DGCORE=\"/bin/gcore\" DFLAGS_NOSTUB += -DSHDLIB_EXT=\".so\" -DNDEBUG CFLAGS = -g -m64 -fPIC -Wimplicit-int -fPIC From ec8ffe73334f6a40f4f175bc27a5193bd3ec45bf Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 22 May 2019 14:24:44 -0400 Subject: [PATCH 2/5] Corrected an error in the GDS read routine which attempts to kill a hash table that was never initialized, if the GDS file input reader encounters an error in the GDS data. --- calma/CalmaRdcl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/calma/CalmaRdcl.c b/calma/CalmaRdcl.c index 353a4d45..5fb77f31 100644 --- a/calma/CalmaRdcl.c +++ b/calma/CalmaRdcl.c @@ -288,6 +288,7 @@ calmaParseStructure(filename) int mfactor; off_t filepos; bool was_called; + bool was_initialized; CellDef *def; /* Make sure this is a structure; if not, let the caller know we're done */ @@ -296,7 +297,8 @@ calmaParseStructure(filename) return (FALSE); /* Read the structure name */ - if (!calmaSkipExact(CALMA_BGNSTR)) goto syntaxerror;; + was_initialized = FALSE; + if (!calmaSkipExact(CALMA_BGNSTR)) goto syntaxerror; if (!calmaReadStringRecord(CALMA_STRNAME, &strname)) goto syntaxerror; TxPrintf("Reading \"%s\".\n", strname); @@ -354,6 +356,7 @@ calmaParseStructure(filename) /* Initialize the hash table for layer errors */ HashInit(&calmaLayerHash, 32, sizeof (CalmaLayerType) / sizeof (unsigned)); + was_initialized = TRUE; /* Body of structure: a sequence of elements */ osrefs = nsrefs = 0; @@ -466,7 +469,7 @@ done: /* Syntax error: skip to CALMA_ENDSTR */ syntaxerror: - HashKill(&calmaLayerHash); + if (was_initialized == TRUE) HashKill(&calmaLayerHash); return (calmaSkipTo(CALMA_ENDSTR)); } From 243e9652e52712129125dad104515ec1cb44768a Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 22 May 2019 16:12:13 -0400 Subject: [PATCH 3/5] Added information to the GDS read routine error output to indicate the byte position of the error. --- calma/CalmaRead.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/calma/CalmaRead.c b/calma/CalmaRead.c index 25c5e3aa..1ddd00a8 100644 --- a/calma/CalmaRead.c +++ b/calma/CalmaRead.c @@ -353,25 +353,31 @@ calmaReadError(format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) char *format; char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9, *a10; { + off_t filepos; + calmaTotalErrors++; if (CIFWarningLevel == CIF_WARN_NONE) return; if ((calmaTotalErrors < 100) || (CIFWarningLevel != CIF_WARN_LIMIT)) { + filepos = ftello(calmaInputFile); if (CIFWarningLevel == CIF_WARN_REDIRECT) { if (calmaErrorFile != NULL) { - fprintf(calmaErrorFile, "Error while reading cell \"%s\": ", + fprintf(calmaErrorFile, "Error while reading cell \"%s\" ", cifReadCellDef->cd_name); + fprintf(calmaErrorFile, "(byte position %"DLONG_PREFIX"ld): ", + (dlong)filepos); fprintf(calmaErrorFile, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); } } else { - TxError("Error while reading cell \"%s\": ", cifReadCellDef->cd_name); + TxError("Error while reading cell \"%s\" ", cifReadCellDef->cd_name); + TxError("(byte position %"DLONG_PREFIX"d): ", (dlong)filepos); TxError(format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); } } From 30a2226dbb7913ae5f4494aa7879b6d1d1d0bf69 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 22 May 2019 16:52:34 -0400 Subject: [PATCH 4/5] Corrected a problem in CalmaWrite where a cell that was defined redundantly was flagged, and output anyway, but the cellname was not being written to the output, resulting in a bad GDS file. --- calma/CalmaWrite.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index e782005d..7879ecb1 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -404,6 +404,8 @@ calmaDumpStructure(def, cellstart, outf, calmaDefHash, filename) { /* Structure is defined more than once */ TxError("Structure %s defined redundantly in GDS\n", strname); + /* To be considered: Should the structure be output more than once? */ + calmaOutStringRecord(CALMA_STRNAME, newnameptr, outf); } else if (!strcmp(strname, def->cd_name)) { From a56309fdb6f50d4c817a89fa45964110023224c8 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 22 May 2019 17:03:52 -0400 Subject: [PATCH 5/5] Additional change to CalmaWrite: when handling cellnames with lengths exceeding the maximum GDS name length (32 characters), truncate by removing all but the last 32 characters, instead of the previous behavior which was to remove all but the first 32 characters. The last 32 characters are far more likely to be unique than the first 32, given that the usual reason for extra- long names is the concatentation of hierarchical names. --- calma/CalmaWrite.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index 7879ecb1..44e0d6d9 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -2757,16 +2757,17 @@ calmaOutStringRecord(type, str, f) /* * Make sure length is even. * Output at most CALMANAMELENGTH characters. + * If the name is longer than CALMANAMELENGTH, then output the + * last CALMANAMELENGTH characters (since cell names are more + * likely to be unique in the last characters than in the first + * characters). */ if (len & 01) len++; if (len > CALMANAMELENGTH) { - char csav; TxError("Warning: Cellname %s truncated ", str); - csav = *(str + 32); - *(str + 32) = '\0'; - TxError("to %32s (GDS format limit)\n", str); - *(str + 32) = csav; + TxError("to %s (GDS format limit)\n", str + len - CALMANAMELENGTH); + locstr = str + len - CALMANAMELENGTH; len = CALMANAMELENGTH; } calmaOutI2(len+4, f); /* Record length */