Commit Graph

63 Commits

Author SHA1 Message Date
Darryl L. Miles df0623a435 include <unistd.h> where necessary in files using API calls
When global <sys/mman.h> was removed from tile.h it also removed
<unistd.h> nearby.  This exposes the lack of <unistd.h> being
included where needed using APIs like close()/read()/unlink()/isatty()
the WASM build seems to show this as the header file set is structured
differently.
2025-07-27 12:42:05 -04:00
Darryl L. Miles 606f37cc80 Ti[GS]etClient() usage enforcement
All naked access to `ti_client` now uses the function-like-macro
to encapsulate this action.  This macro existed before this just
makes all sites utilize it.

Added additional INT and PTR variants to remove the programmer
load on thinking about casing and casts polluting the point
of use.  So the use now looks cleaner.

Equivalent prototypes:

 void TiSetClient(Tile*, ClientData)
 void TiSetClientINT(Tile*, intptr_t) /* pointertype */
 void TiSetClientPTR(Tile*, void*)

 ClientData TiGetClient(Tile*)
 intptr_t TiGetClientINT(Tile*) /* pointertype */
 void *TiGetClientPTR(Tile*)
2025-04-09 14:55:58 -04:00
Darryl L. Miles 983f4cb76f lef: constify remaining .data into .rodata 2025-02-22 21:48:17 -05:00
Darryl L. Miles ac37927186 lef: constify static data and LefNextToken() return
LefHelper_DBTechNameType_LefLower() identified and introduced during
conversion to const data usage.

Only side-effect is some log messages will use original verbatim token
now instead of lowercase version (but this seems ok when file parsing,
to quote the problematic information source verbatim)
2025-02-22 21:48:17 -05:00
Darryl L. Miles 451dab4b9b lef: constify strings in data structures of lef module 2025-02-22 21:48:17 -05:00
Darryl L. Miles 56bf27548d lef: cleanup remove unused local/static variables
Many appear to be the result of copy-and-paste from a similar func
nearby.
2025-02-22 21:48:17 -05:00
Darryl L. Miles 9d0cd63a4e lef: use 'const' with 'rcsid' 2025-02-22 21:48:17 -05:00
Darryl L. Miles 695692b620 K&R lef/*.c: bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles 05a5b169bc defWrite.c: defHNsprintfPrefix() constify implementation 2025-02-22 21:48:17 -05:00
Darryl L. Miles 19e03fc4f8 K&R lef/*.c: bulk function implementation conversion
Some function parameters (char *sname) have been made const due
referencing const data sources.

K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles ad1d9923f9 CodeQL MissingNegativtyTest.ql magictype>=0 defWrite.c
defnodeVisit()
defblockageVisit()

This variable is used as array index, but the DBTechNameType() API allows
a negative return to occur.
2025-02-22 21:31:22 -05:00
Darryl L. Miles af5b7f10cf lef/defWrite.c: reworked kareefardi_fix-def-write 2025-01-04 11:42:07 -05:00
Kareem Farid a6aac9c309 fix infinite def write
Signed-off-by: Kareem Farid <kareefardi@users.noreply.github.com>
2025-01-04 11:42:07 -05:00
Darryl L. Miles a6e1596ba6 22 x warning: suggest parentheses around assignment used as truth value
lefTech.c:107:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:160:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:426:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:453:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:486:16: warning: suggest parentheses around assignment used as truth value
lefWrite.c:190:9: warning: suggest parentheses around assignment used as truth value
lefWrite.c:303:12: warning: suggest parentheses around assignment used as truth value
lefWrite.c:315:12: warning: suggest parentheses around assignment used as truth value
lefWrite.c:377:16: warning: suggest parentheses around assignment used as truth value
lefWrite.c:439:16: warning: suggest parentheses around assignment used as truth value
lefWrite.c:1222:12: warning: suggest parentheses around assignment used as truth value
lefWrite.c:2246:12: warning: suggest parentheses around assignment used as truth value
defWrite.c:415:12: warning: suggest parentheses around assignment used as truth value
defWrite.c:447:12: warning: suggest parentheses around assignment used as truth value
defWrite.c:2039:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:2104:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:2478:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:2498:20: warning: suggest parentheses around assignment used as truth value
defWrite.c:3066:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:3084:28: warning: suggest parentheses around assignment used as truth value
defWrite.c:3111:28: warning: suggest parentheses around assignment used as truth value
lefRead.c:651:12: 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 6a08b31149 defWrite.: '%.10g' directive writing between 1 and 17 bytes into a region of size 12
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -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 Miles 5ffc74d915 lef/defWrite.c: Multiplication result converted to larger type
Fix code scanning alert no. 53: Multiplication result converted to larger type (#48)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 3c90bbbe1f lef/defWrite.c: Call to function with fewer arguments than declared parameters
Fix code scanning alert no. 23: Call to function with fewer arguments than declared parameters (#38)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 4374a1918e lef/defWrite.c: Too few arguments to formatting function
Fix code scanning alert no. 63: Too few arguments to formatting function (#3)

* Create codeql.yml

* Fix code scanning alert no. 63: Too few arguments to formatting function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:12 -04:00
Darryl Miles 51b8161a21 lef/defWrite.c: Too few arguments to formatting function
Fix code scanning alert no. 62: Too few arguments to formatting function (#1)

* Create codeql.yml

* Fix code scanning alert no. 62: Too few arguments to formatting function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:12 -04:00
Tim Edwards eeeaf49ec7 Corrected an error in defGetType() that incorrectly looks at a
lefLayer's "via" record even when the layer might not be a via,
causing potential issues with uninitialized variables.  Not sure
if this is related to the bug that started this investigation,
but it was the only thing that looked relevant.
2024-03-08 09:33:13 -05:00
Tim Edwards 7aa846443a Corrected an issue with the implementation of nondefault rules
in DEF read and write.  The NONDEFAULT LAYER WIREEXT was assumed
to refer to the default wire extension at segments, when instead
it refers to the wire extension only at vias.  The wire
extension at segments is presumably defined by the nondefault
segment (and wire extension at vias remains unimplemented, which
is probably not a big issue because everyone puts the wire
extensions into the via definitions anyway).
2023-09-26 21:26:31 -04:00
Tim Edwards 4557dd1639 Modified the "def write" function so that obstruction layers are
output as blockages.  That allows obstruction layers to be placed
in a layout specifically for the purpose of being output as a
blockage.  Otherwise, an obstruction layer is generally considered
non-electrical and will not show up as a node in the extraction
file, so obstruction layers were being missed entirely by "def
write".  Also:  Where "def write" complains about floating labels,
made an exception for labels on non-electrical layers (like
"comment").
2023-09-22 15:51:38 -04:00
Tim Edwards 89f1c4ee67 Corrected a previous implementation that was supposed to not print
warning messages about ports being electrically connected when
those ports have names that match under rules of case-insensitivity,
and the .ext file is being read for the purpose of generating a
SPICE netlist, which is case-insensitive.  Also:  Corrected a crash
condition when using "extract path <name>" when directory <name>
does not exist.
2023-07-28 09:40:41 -04:00
Tim Edwards 18fc328289 Revised the last commit slightly to put the PIN entry as the first
entry of a set of net connections in a DEF file, instead of the
last entry.
2022-11-20 13:32:40 -05:00
Tim Edwards 44af9aaf9f Added pin connection to the list of NET connections in a DEF file
when doing "def write", which was missing.
2022-11-20 13:30:19 -05:00
Tim Edwards 65ef9a1ad3 Final (I hope!) corrections to the "def write" command. 2022-11-19 22:02:44 -05:00
Tim Edwards 6369c44821 One correction to the last commit, to avoid missing output of
port nets in "def write".
2022-11-18 22:28:20 -05:00
Tim Edwards 16da74a2f9 Implemented a method in EFBuildNode() to capture nodes which are
redundant (same name, different net).  Previously, the method was
to keep the first such node and ignore all others except to add
their resistance and capacitance to the original node.  This
prevented routines like "def write" from enumerating all nets
unless they had unique names.  The new method keeps the additional
records including the node location where they can be found by
EFNodeVisit(), but flags them with EF_UNIQUE_NODE so that routines
like ext2spice or ext2sim can choose to ignore them.  This implies
that this method could be used to reimplement "extract unique"
within "ext2spice" or "ext2sim" without altering label text.  This
has not yet been implemented.
2022-11-18 21:44:06 -05:00
Tim Edwards fe89170f5a Small correction to defWrite to cancel a non-default rule when a
wire with default width is encountered.
2022-11-18 21:00:23 -05:00
Tim Edwards f066844761 Substantially revised the "def write" and "def read" routines.
Both were corrected with respect to the definition of non-default
(taper) rules.  "def write" was additionally modified to avoid
redundantly processing tiles where tile areas were merged together
to form a complete wire.  There is plenty of room for optimization,
but the output appears to be matching the layout.  Also:  Revised
the definition of "(not) visible layers" to include labels attached
to those layers, so that turning off visibility of any layer will
also hide all labels attached to that layer.
2022-11-17 20:24:39 -05:00
Tim Edwards 70e15b1d33 Corrected the "def write" output with respect to the "-units"
option.  This is important as the default units of 1nm are not
necessarily able to be converted to integer values if the
minimum manufacturing grid is an odd number of nanometers.
2022-11-09 17:38:09 -05:00
Tim Edwards 31ba6eeba3 Corrected an error introduced with the last push which changes
wire direction on vias during DEF write without changing the
"orient" value, causing Y values to get copied into X positions
in the output.
2022-11-09 15:14:53 -05:00
Tim Edwards f4c5ec3a78 Fixed the DEF write routine, which had an error in identifying
"slivers";  the error tended to produce artifacts (extra metal)
around contacts.  Fixed an issue that caused the DEF write routine
to open the same file twice instead of a new file for the second
part of the DEF data, and then potentially hit a runaway condition
when trying to merge the two files together.
2022-11-09 11:15:06 -05:00
Tim Edwards 2059d6fbb1 Corrected an error in "def write" that starts output on the wrong
layer when the first part of the route is a contact (starts on the
via top instead of the via bottom).
2022-11-08 09:59:43 -05:00
Tim Edwards 3534b79994 Fixed an instance where dbFgets() was used in the "def write"
routine;  that is incorrect, and it should have been fgets().
When dbFgets() is recast to a zlib version, then its use in
"def write" causes magic to crash.
2022-11-03 16:15:36 -04:00
Alessandro De Laurenzis b306a39560 Compatibility with C99 standard
This commit makes the code (mostly) C99-compatible, enabling to compile
it without the -Wno-error=implicit-function-declaration flag. This
way, Magic becomes usable on arm64 architectures, specifically on Apple
computers with M1/M2 SoC.
2022-10-29 06:07:46 +02:00
Tim Edwards eecdc3c642 Added a "flatten -doproperty" command option that allows selective
flattening based on cells which have a property "flatten".  Also:
Modified the DEF read and write to convert DIEAREA into a
FIXED_BBOX property.  This solves issues with placing of components
from DEF, when those components may not have have come from place &
route and may not have P&R bounding boxes.  Also:  Fixed the
documentation for the "dump" command, which was missing the optional
orientation in the description.
2022-10-15 11:33:59 -04:00
Tim Edwards a550d615c0 Made some modifications to the "def write" command: It now handles
non-default rules and so can accurately capture wire widths other
than the technology LEF defaults (also corrected a bug with non-
default rules for "def read").  Corrected via handling in "def
write" to function as claimed (although the algorithm is still
naive and expects all contacts to be rectangular, which is usually
true but doesn't have to be).
2022-09-23 15:02:22 -04:00
Tim Edwards fcc884332b Made some corrections to the "extresist" code to avoid issues with
extracting a port-to-port net that does not touch any devices.
The error happens in a fairly rare set of cases.
2022-05-02 12:27:39 -04:00
Tim Edwards bfa4272481 Removed some diagnostic messages from "def write", and added code to
prevent "def write" from running on an unnamed cell.
2022-03-29 17:10:50 -04:00
Tim Edwards 0c584f9e77 Modified the configure scripts and makefile per Proppy's comments
in github issue #149.  This causes magic to no longer write log files
for "make" and "make install" but will properly exit with a non-zero
return code on any error during compile.

Also:  Corrected the command "tech drc surround <type1> <type2>" so
that it now returns the correct value when <type1> and <type2> are in
the same plane.  Added new command "tech drc directional <type1> <type2>"
which works the same way as "tech drc surround" except for directional
surround rules.  Used this to generate vias from "def write" with the
correct metal surround amounts included in the via definiton.  The
route analysis then ignores tile slivers that make up the surrounding
material around contacts.  Also implemented a method that handles
routes that are made of multiple thin tiles due to the maximum horizontal
stripes rule.  Now magic handles "def write" well except for not dealing
with non-minimum-width routes unless they're specifically called out as
"special" nets.
2022-03-29 16:52:01 -04:00
Tim Edwards 3b44dacab5 Corrected a minor issue in "def write" that will ignore a wire
completely if the width does not match the wire minimum width,
rather than attempt to cope with it gracefully.
2022-03-28 22:34:12 -04:00
Tim Edwards 2147d0a882 Corrected the offsets caused in "def write" when writing components
with "FIXED_BBOX" properties, which need to be positioned relative
to the abutment box, not the cell bounds.
2022-03-25 21:38:41 -04:00
Tim Edwards cf39fb102c Fixed some errors in DEF read/write and added behavior to "def write"
to treat unlabeled/unconnected layout as blockage statements in the
output.
2022-03-24 17:58:05 -04:00
Tim Edwards 59b68606e0 Corrected the equations for fringe shielding, as the equation for
the shielding fraction was inverted---I do not know how the tests
could pass that way.
2022-03-23 10:49:02 -04:00
Tim Edwards 5e3c26c95a Tracked down two more memory leaks coming from ext2spice, due to
client data generated by ext2spice and attached to a node's
nodeClient record;  there is an initNodeClient() routine but no
corresponding freeNodeClient() routine.  Eventually had to add a
callback function passed to EFDone() and EFFlatDone() to clean up
these entries.  After doing that, valgrind reports clean for all
memory allocated within ext2spice (there are other things that are
not freed but not related to a specific command, so do not need to
be treated as leaks).
2021-12-13 18:05:53 -05:00
Tim Edwards 552d6de0f7 Modification to prevent crashing on an attempt to do an area erase on
a read-only layout.
2021-12-07 14:25:50 -05:00
Tim Edwards 73bad08457 Updated the version to go along with the merge of pull request
the existing coding style.
2021-11-17 09:12:47 -05:00
Maximo 7083d1904c Quick fix of 'def write' issue with the nets extending beyond it's original shape in some cases. It would be good to analyze in more detail the use of the extlen variable 2021-11-17 09:10:00 -05:00