Commit Graph

261 Commits

Author SHA1 Message Date
Darryl L. Miles 2db18509c5 header file #endif guard middle program once style consistency 2025-07-29 10:50:32 -04:00
Darryl L. Miles d55a2b74ac header file #ifndef guard namespace consistency (global change)
This add an effective namespace prefix to the guard ifndef
2025-07-29 10:50:32 -04:00
Darryl L. Miles f88c7a86cb utils/magic_zlib.h: limit #include <zlib.h> to files that need it
Remove limited use HAVE_ZLIB wrapper API into separate header as
utils.h is used in many places and most source files don't need
to drag in the header file from this external dependency.

Copyright date(s) taken from original source file / git blame.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 2947e7ea3d Makefile: database.h removal by toplevel Makefile 2025-07-29 10:50:32 -04:00
Darryl L. Miles 62149adc16 DBTechname.c: fix !MAGIC_WRAPPER incorrect use of TxPrintf() warning 2025-07-28 21:28:24 -04:00
R. Timothy Edwards 9fe7bf4ab7 Fixed an issue with a non-boolean variable in DBtiles.c being
cast as "bool", causing issues with the proper/strict use of
the "bool" type.  Changed the version back so that it will
update the github mirror tonight, since the current version
appears to be working.
2025-07-27 21:02:40 -04:00
Darryl L. Miles 046401cbd8 Use HAVE_SYS_TIME_H and TIME_WITH_SYS_TIME from autoconf where possible 2025-07-27 12:43:04 -04:00
Darryl L. Miles fd50bc1f4d TiJoin[XY]1 API introduction at all call sites 2025-07-27 12:42:05 -04:00
Darryl L. Miles a6fd0ed320 DBtiles.c: DBFreePaintPlane() remove the TiFree() deferred assumption
The comment indicates the expectation that TiFree() is deferred-by-one,
which would be true if freeMalloc() was used but since the custom mmap()
allocator technically this is not true.

The TiFree() allocator is single-threaded and separate from libc so the
assumption is still kind of true but for different reasons
(single-threaded).

But since it doesn't really cost anything (other than a few lines of
code a human needs to read) the compiler would be expected to perform a
load (which it was going to do anyway) into a caller-saves register over
the function call.
Most of the other function state is invalidated anyway due to the heavy
linked-list navigation and low number of local variables, I would not
think there is much register allocation pressure.

TODO this code can be tested by confirming zero allocations are active
and by invalidating (poison) all fields inside TiFree().
2025-07-27 12:42:05 -04:00
Darryl L. Miles bfefc7196e configuration: #ifdef CIF_MODULE
Enclosed symbols only seem available with when this ifdef.
2025-07-26 17:48:31 -04:00
Darryl L. Miles 534a56376a DBcellsrch.c: #ifdef ROUTE_MODULE around hook to update MZAttachHintPlanes()
When building without this module MZInit() does not get called and
MZAttachHintPlanes() does not guard against that situation.

To allow unused code to be pruned from final binary, better to remove
the cross module hook breaking the dependency.
2025-07-26 17:48:31 -04:00
Darryl L. Miles dceb5cfad7 database.h.in: dbSrConnectFunc()/dbSrConnectStartFunc() add public prototype 2025-04-09 15:23:21 -04:00
Darryl L. Miles ef123be806 database.h.in: dbcUnconnectFunc() add public prototype 2025-04-09 15:23:21 -04:00
Darryl L. Miles fa1f1583df database: DBPrintUseId() K&R removal 2025-04-09 15:23:21 -04:00
Darryl L. Miles ef79d33dd4 database.h.in constify various TileTypeBitMask* data usages 2025-04-09 15:23:21 -04:00
Darryl L. Miles 321b2d61c7 extract: DBSrCellPlaneArea() const Rect * arg2 2025-04-09 15:07:28 -04:00
Darryl L. Miles 00b479301f tiles: TiPlaneRect const ripple 2025-04-09 15:07:28 -04:00
Darryl L. Miles 1a84eab4ce Plane[GS]etHint() added to encapsulate access to Plane->pl_hint
This is ground work to intercept usage and validate changes in
this area.

Fixed conflicts with earler patch in extract/ExtNghbors.c
2025-04-09 15:02:59 -04:00
R. Timothy Edwards dde7144966 Modified the behavior of SelectCopy() so that it surveys cell
instance names in both the selection and in the root edit CellDef,
and then wipes duplicate names from the selection and regenerates
unique IDs.  This avoids the unexpected behavior displayed by
magic in which a "copy" function renames the *original* instance
and gives the original name to the copied instance.  This is not
only unexpected, but causes an error in which "undo" after
multiple copies fails to remove earlier copies because the name
change was not recorded, and the instance can no longer be found
by name.
2025-03-26 14:45:46 -04:00
Darryl L. Miles 9aef87c355 database: TxDialog() constification ripple 2025-02-23 10:24:40 -05:00
Tim Edwards 09ff52cdc0 One additional fix which allows "gds write" to continue after a
cell is found to be missing, if "gds allow undefined" has been
set.
2025-02-15 13:49:14 -05:00
Tim Edwards 41d77558b7 Fixed an error in which using the command option "gds allow undefined"
will cause a segmentation fault.
2025-02-15 13:43:01 -05:00
Tim Edwards cd80d38d52 Fixed a rather long-standing error, which is that when scaling of
"MASK_HINTS" was implemented, it was put into a routine that
scales all coordinate-related properties, including "FIXED_BBOX",
but the original code that scaled only "FIXED_BBOX" was never
removed, resulting in the bounding box getting incorrectly scaled
twice by any grid scaling.
2025-02-09 12:48:22 -05:00
Tim Edwards 4445663cb1 Modified a routine to return a valid string when attempting to
generate a name for an instance that is set to NULL.  It is not
clear to me by an instance would have a NULL name, but apparently
it can happen, and should not crash magic.
2025-01-12 17:36:05 -05:00
Darryl L. Miles 6afadf9809 gcc11 -Wall -Wpedantic cleanup (post __attribute__) 2025-01-06 16:25:38 +00:00
Darryl L. Miles aa5ddbaa58 database/database.h.in: const PaintResultType *resultTbl
Probably forgot to edit database.h.in template file (and edited
database.h) when working locally.
2025-01-06 16:24:02 +00:00
Darryl L. Miles ac56dd71a9 cif: use 'const' with readonly data (also consumer DBpaint)
This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
2025-01-04 11:31:17 -05:00
Darryl L. Miles 0ce8265570 TCL9: ClientData macro assignment and access usage 2025-01-04 11:08:01 -05:00
Tim Edwards df19d62f51 Corrected code in DBtpaint2.c handling the setup of paint/erase
tables for contacts, where an error was pointed out by Darryl
Miles (github issue #339).
2024-12-26 16:28:43 -05:00
Darryl L. Miles bd51438c15 database/DBio.c: PaExpand() constify update call-site 2024-12-26 15:20:58 -05:00
Darryl L. Miles b8dae95515 Lookup() constify call-site
extflat/EFantenna.c: Lookup() constify call-site
drc/DRCtech.c: Lookup() constify call-site
dbwind/DBWelement.c: Lookup() constify call-site
database/DBtpaint.c: Lookup() constify call-site
commands/CmdTZ.c: Lookup() constify call-site
commands/CmdRS.c: Lookup() constify call-site
commands/CmdLQ.c: Lookup() constify call-site
commands/CmdFI.c: Lookup() constify call-site
commands/CmdE.c: Lookup() constify call-site
commands/CmdCD.c: Lookup() constify call-site
commands/CmdAB.c: Lookup() constify call-site
cmwind/CMWcmmnds.c: Lookup() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles fb8f7b94aa LookupStructFull() constify call-site
txInput.c: LookupStructFull() constify call-site
DBlabel.c: LookupStructFull() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles c7f99e076e DBcount.c: DBTreeCountPaint() unify return type of hiercount() callback
The call-site does not expect a return value.
The use case in command/Cmdwizard.c is written to be void.

So a resolution was needed.
2024-12-26 13:13:14 -05:00
Darryl L. Miles 7ebaba6b39 DBcount.c: clarify function documentation of hiercount() callback
DBTreeCountPaint(def, count, hiercount, cleanup, cdata)
 callback hiercount()

The K&R function prototype syntax in the documentation might confuse
reader into which argument order is correct (as a modern developer
might be out of practice with interpreting K&R syntax)
2024-12-26 13:13:13 -05:00
Tim Edwards 89b6f4f92b Corrected an error with the bloat-all CIF operator in which
bloat-all would fail to operate from the top layer of a contact
type due to the use of DBplane(type) instead of counting all
planes of the contact.
2024-12-16 21:52:11 -05:00
Tim Edwards 8b34aa78a9 Corrected a long-standing crash condition that happens when a
generated cell is modified multiple times.  If the original cell
is orphaned (no longer used anywhere in the design), it is deleted.
However, an instance of the cell may exist in the secondary
select buffer if the cell was previously moved or copied, and
an attempt to do another move or copy will clear the secondary
select buffer, encounter the deleted cell, and crash the program.
2024-11-26 13:43:27 -05:00
Darryl L. Miles 9ca8697659 strings.h: add #include required when strict
Due to use of strcasecmp() or similar C API.

Maybe HAVE_STRINGS_H is needed ?  If so which platforms needs this ?

clang18 default warning cleanup (strict)
2024-10-09 21:22:37 -04:00
Darryl L. Miles 4460c5f1f5 DBio.c: warning: 'sscanf' may overflow; destination buffer in argument ...
DBio.c:2358:21: warning: 'sscanf' may overflow; destination buffer in
  argument 4 has size 2048, but the corresponding specifier may require
  size 2049

clang18 default warning cleanup [-Wfortify-source]
2024-10-09 21:22:37 -04:00
Darryl L. Miles b723dc15d8 DBio.c:1604:65: warning: too many arguments in call to 'dbReadOpen'
DBio.c:1604:52: warning: expression which evaluates to zero treated as
 a null pointer constant of type 'int *' [-Wnon-literal-null-conversion]

DBOpenOnly() function only has one use which always passed name==NULL.

clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles 59bfe8f6c0 DBcellsrch.c:2249:22: warning: too many arguments in call to 'dbMovePlane'
clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles 6cdb9ad167 36 x warning: suggest parentheses around assignment used as truth value
bpMain.c:265:11: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:413:12: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:759:13: warning: suggest parentheses around assignment used as truth value
CmdFI.c:1600:12: warning: suggest parentheses around assignment used as truth value
DBcell.c:109:12: warning: suggest parentheses around assignment used as truth value
DBcellname.c:2512:9: warning: suggest parentheses around assignment used as truth value
DBcellsrch.c:95:12: warning: suggest parentheses around assignment used as truth value
DBio.c:3998:9: warning: suggest parentheses around assignment used as truth value
DBlabel2.c:228:9: warning: suggest parentheses around assignment used as truth value
DBWelement.c:195:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:197:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:295:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:297:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:637:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:639:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:679:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:681:13: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1219:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1368:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1471:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1543:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1676:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1772:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1919:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2099:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2324:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2713:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2830:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2944:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3097:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3144:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3181:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3215:9: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3227:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3261:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3459:17: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles d94cd72538 37 x warning: array subscript has type 'char'
Compiler is expressing range concern with the warning mitigated by using
unsigned C array offsets.  This also draws attention to the range concern
when reading the code and making changes.

DBundo.c:263:45: warning: array subscript has type 'char'
DBundo.c:279:49: warning: array subscript has type 'char'
DBundo.c:317:52: warning: array subscript has type 'char'
DBundo.c:318:64: warning: array subscript has type 'char'
DBundo.c:324:52: warning: array subscript has type 'char'
DBundo.c:325:64: warning: array subscript has type 'char'
DBundo.c:329:50: warning: array subscript has type 'char'
DBundo.c:330:58: warning: array subscript has type 'char'
DBundo.c:338:52: warning: array subscript has type 'char'
DBundo.c:339:64: warning: array subscript has type 'char'
DBundo.c:345:52: warning: array subscript has type 'char'
DBundo.c:346:64: warning: array subscript has type 'char'
DBundo.c:350:50: warning: array subscript has type 'char'
DBundo.c:351:58: warning: array subscript has type 'char'
DBundo.c:371:52: warning: array subscript has type 'char'
DBundo.c:372:64: warning: array subscript has type 'char'
DBundo.c:378:52: warning: array subscript has type 'char'
DBundo.c:379:64: warning: array subscript has type 'char'
DBundo.c:383:50: warning: array subscript has type 'char'
DBundo.c:384:58: warning: array subscript has type 'char'
DBundo.c:392:52: warning: array subscript has type 'char'
DBundo.c:393:57: warning: array subscript has type 'char'
DBundo.c:399:52: warning: array subscript has type 'char'
DBundo.c:400:57: warning: array subscript has type 'char'
DBundo.c:403:53: warning: array subscript has type 'char'
DBundo.c:407:50: warning: array subscript has type 'char'
DBundo.c:408:58: warning: array subscript has type 'char'
EFbuild.c:1048:32: warning: array subscript has type 'char'
EFbuild.c:1056:32: warning: array subscript has type 'char'
ExtBasic.c:2358:43: warning: array subscript has type 'char'
ExtBasic.c:2493:43: warning: array subscript has type 'char'
ExtBasic.c:2519:43: warning: array subscript has type 'char'
ExtBasic.c:2644:43: warning: array subscript has type 'char'
ExtBasic.c:2678:43: warning: array subscript has type 'char'
ResPrint.c:143:43: warning: array subscript has type 'char'
plotRutils.c:713:34: warning: array subscript has type 'char'
plotRutils.c:786:29: warning: array subscript has type 'char'

GCC14 -Wall cleanup series [-Wchar-subscripts]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 9225fa6cf1 4 x warning: suggest explicit braces to avoid ambiguous 'else'
Give compiler the extra braces it recommends.

DBio.c edited as my original change was caught out by the incorrect
indention of the 'else' keyword and my modification would have caused a
NULL deref.   Exactly the kind of issue this warning is trying to prevent.

CmdTZ.c:417:20: warning: suggest explicit braces to avoid ambiguous 'else'
DBio.c:1422:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:285:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:384:12: warning: suggest explicit braces to avoid ambiguous 'else'

GCC14 -Wall cleanup series [-Wdangling-else]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 967b41343b GCC14: warning: missing braces around initializer
GCC14 -Wall cleanup series [-Wmissing-braces]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 4ea0f6a9b7 DBcellcopy.c: fix warning: self-comparison always evaluates to false
Looks like a straighforward logic bug from a recent (2023) change.

GCC14 -Wall cleanup series [-Wtautological-compare]
2024-10-09 20:50:00 -04:00
Darryl L. Miles 63256f1a44 DBio.c: resolve warnings and use snprintf()
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 23930909b1 database/DBio.c: error: assignment to 'char *' from 'ClientData'
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles 8994a68e61 DBPropGet(): error: assignment to 'char *' from 'ClientData'
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles 0a4e2a5a27 HashGetValue: warning: comparison between pointer and integer
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Tim Edwards e2c3eb3e20 Corrected the previous commit, which did not fix the problem that
it claimed to fix, but caused an incorrect DRC maxwidth check
instead.  The problem appears to be correctly resolved now.
Also:  Tracked down a recently-introduced minor issue in which
the interactive DRC stops running after issuing "drc check" and
does not resume until another key or mouse even occurs.  This
turned out to be caused by the work on the "logcommands" command,
which should have used "*bypass" before "logcommands suspend"
and "logcommands resume", since the "*bypass" indicates that
the command has no impact on layout and should not interrupt
the DRC checker.
2024-10-01 21:14:12 -04:00