Commit Graph

77 Commits

Author SHA1 Message Date
Darryl L. Miles 76d8c8c911 35 x warning: suggest parentheses around assignment used as truth value
PlowRules1.c:439:9: warning: suggest parentheses around assignment used as truth value
PlowTech.c:645:17: warning: suggest parentheses around assignment used as truth value
PlowTech.c:652:17: warning: suggest parentheses around assignment used as truth value
PlowTech.c:1019:17: warning: suggest parentheses around assignment used as truth value
ResReadSim.c:270:13: warning: suggest parentheses around assignment used as truth value
ResReadSim.c:871:9: warning: suggest parentheses around assignment used as truth value
ResRex.c:1840:17: warning: suggest parentheses around assignment used as truth value
getrect.c:72:9: warning: suggest parentheses around assignment used as truth value
getrect.c:79:9: warning: suggest parentheses around assignment used as truth value
getrect.c:86:9: warning: suggest parentheses around assignment used as truth value
getrect.c:93:9: warning: suggest parentheses around assignment used as truth value
hash.c:732:16: warning: suggest parentheses around assignment used as truth value
heap.c:328:17: warning: suggest parentheses around assignment used as truth value
heap.c:344:17: warning: suggest parentheses around assignment used as truth value
netlist.c:323:17: warning: suggest parentheses around assignment used as truth value
niceabort.c:121:9: warning: suggest parentheses around assignment used as truth value
path.c:1102:12: warning: suggest parentheses around assignment used as truth value
pathvisit.c:245:13: warning: suggest parentheses around assignment used as truth value
pathvisit.c:295:17: warning: suggest parentheses around assignment used as truth value
tech.c:656:17: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1591:16: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1622:16: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1813:12: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1862:12: warning: suggest parentheses around assignment used as truth value
ext2spice.c:3808:16: warning: suggest parentheses around assignment used as truth value
CalmaRdio.c:437:9: warning: suggest parentheses around assignment used as truth value
CalmaWrite.c:396:9: warning: suggest parentheses around assignment used as truth value
CalmaWrite.c:1772:29: warning: suggest parentheses around assignment used as truth value
CalmaWriteZ.c:372:9: warning: suggest parentheses around assignment used as truth value
CalmaWriteZ.c:1608:29: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:209:9: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:214:9: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:220:9: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:226:9: warning: suggest parentheses around assignment used as truth value
CIFrdutils.c:1258: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 88d36bfd1e geofast.h: warning: this 'else' clause does not guard...
Use of macro idiom: if(1) { ... } else
  which has dangling else keyword to allow trailing semicolon at
  use site, is not a good pattern.

Replaced with idiom: do { ... } while(0)
  which should achieve the same purpose but now cause compile
  error when used incorrectly at use site.

GCC14 -Wall cleanup series [-Wmisleading-indentation]
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 9f88450243 niceabort.c: '%s' directive writing up to 199 bytes into a region of size 177
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 1ae4518846 DLONG_PREFIX is %ld on x86_64 LP64
GCC14 loud default warnings fix
2024-10-09 20:39:12 -04:00
Darryl L. Miles cb31675174 utils/geometry.c: non-void function does not return a value in all control paths
Had to pick a value to return by default.  This is a probably should never happen ?

SonarCloud
utils/geometry.c:589 non-void function does not return a value in all control paths
https://sonarcloud.io/project/issues?open=AZJB16DGNGfDNup0Rg7u&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 0cea17e801 utils/magic.h pointertype prefer use of 'long' instead of 'int'
It is usual for a pointer to require the largest width, while some
platforms might have an 'int' that is smaller than a pointer width.

This reverses the detection order to find.

Note since C99 there is <stdint.h> with type 'intmax_t' which
serves a similar purpose.

SonarCloud reports a concern with this on many lines where used.
"An integral type is too small to hold a pointer value."
https://sonarcloud.io/project/issues?open=AZJB17ZoNGfDNup0RkY_&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles fff3be2f29 utils/main.c: DefRead() Call to function with fewer arguments than declared parameters
Resolution maintains behaviour closest to original behaviour from a37fc1e2

Copilot Autofix no offered.

related git blame lef/defRead.c:
cfb81101 (2022-03-30 13:02:12 -0400 2388)     bool annotate;
f7df5e7c (2022-06-24 15:22:53 -0400 2389)     bool noblockage;

related commits:

commit cfb81101ec
Date:   Wed Mar 30 13:02:12 2022 -0400

commit f7df5e7c86 (tag: 8.3.315)
Date:   Fri Jun 24 15:22:53 2022 -0400

commit a37fc1e242
Date:   Thu Mar 5 14:29:54 2020 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/29
2024-10-01 12:36:12 -04:00
Darryl L. Miles 3db35216b9 utils/main.c: LefRead() Call to function with fewer arguments than declared parameters
Looks like -1 is accepted as placeholder, maybe it should be the
temporary->fn (filename mtime?).

Copilot Autofix rejected: LefRead(temporary->fn, FALSE, NULL);

related git blame utils/main.c:
8e80644d (2022-01-22 13:30:11 -0500 2078)     int lefTimestamp;         /* If not -1, use the value pointed to
8e80644d (2022-01-22 13:30:11 -0500 2884)     int lefTimestamp;

related commit:
commit 8e80644dd7
Date:   Sat Jan 22 13:30:11 2022 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/28
2024-10-01 12:36:12 -04:00
Darryl L. Miles 49f4daa715 utils/main.c: Call to function with fewer arguments than declared parameters
Copilot Autofix rejected: DBFileRecovery(MainFileName);

database/DBio.c looks to take NULL as a value for automatic recovery.

Related commits:
commit 231a299b16 (tag: 8.2.0)
Date:   Tue Apr 25 08:41:48 2017 -0400
    Initial commit at Tue Apr 25 08:41:48 EDT 2017 by tim on stravinsky
2024-10-01 12:36:12 -04:00
Darryl Miles 88a1a9b166 utils/undo.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 120: Wrong type of arguments to formatting function (#17)

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 9f052c0e4d utils/undo.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 117: Wrong type of arguments to formatting function (#16)

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 0c36365db8 Revised the file opening routine with respect to the search paths.
Previously, a file path beginning with "/", "./", or "../" would be
searched for verbatim and no searching would be done over paths.
This behavior now occurs for a leading "/" only.  File paths with
"./" or "../" will search for the file with the path verbatim, then
proceed to search for the file with each search path prepended to
the filename as usual.  This solves a problem for reusable, non- PDK
IP blocks, where the IP block may have an abstract view pointing to
a GDS file which is specified as being located at "../gds/<file>".
This file would not be found if the IP block was included into
another project.  Now it can be done if the path to the IP is given
by "addpath".
2024-08-16 17:45:10 -04:00
Tim Edwards 006c07082b Inadvertently introduced a segfault on exit on the last commit,
while trying to get rid of a compiler warning.  Fixed by this
update.
2024-01-01 15:36:05 -05:00
Tim Edwards 8f9c328150 Got rid of two compiler warnings; one recently introduced, the
other from some time ago.
2023-12-30 15:00:18 -05:00
Tim Edwards 11080465ad Corrected the Tcl exit hook routine so that it passes on the
client data value as the exit status value (this was not at
all clear from the documentation and required a bit of
experimentation).  The fix allows Tcl scripts to exit magic
with a non-zero status by invoking "exit" in Tcl.
2023-11-11 13:09:59 -05:00
Johan Euphrosine f5793bbefb configure: add asmjs-unknown-emscripten target 2023-07-12 04:44:37 +09:00
Johan Euphrosine 96eb275622 quick and dirty emscripten port 2023-07-12 00:31:37 +09:00
Tim Edwards e10901e32b Updated the version to go along with the merge of pull request
222 from Sean Cross.  Corrected a few places where the blanket
conversion "Region"->"ExtRegion" picked up some comment lines
that were unrelated to the structure name.
2023-03-10 11:14:23 -05:00
Sean Cross 1e7da74672 rename Region to ExtRegion
On Macos, Tk includes X11, which has this define:

    #if !defined(MAC_OSX_TK)
    #   include <X11/X.h>
    #endif
    #ifdef MAC_OSX_TK
    #   include <X11/X.h>
    #   define Cursor XCursor
    #   define Region XRegion
    #endif

This causes the keywords `Cursor` and `Region` to be reserved, which
prevents magic from building.

Rename `Region` to `ExtRegion` as suggested by @RTimothyEdwards in
https://github.com/RTimothyEdwards/magic/issues/195#issuecomment-1298870983
and https://github.com/RTimothyEdwards/magic/pull/222#pullrequestreview-1334900670

Signed-off-by: Sean Cross <sean@xobs.io>
2023-03-10 11:07:55 -05:00
Tim Edwards f06f3b47db Added an experimental option for the cifoutput tech file section to
force magic to scale down the internal grid to the minimum
manufacturing grid size specified in the cifoutput section, upon
reading the techfile.
2023-01-13 17:21:37 -05:00
Tim Edwards 0f05bb1356 Corrected the LEF technology setup, where LEF layers (routes and
contacts) take default values from the DRC section.  Since both
are in lambda, but the DRC section uses a two-part integer and
modulus representation, if default values are taken before
scaling, the LEF layers may get rounded values.  This has been
solved by marking values with -1 to indicate that they require
defaults, and then set those defaults (from scaled DRC rules)
after scaling all other tech values.
2022-11-20 15:15:04 -05:00
Tim Edwards 075262b2ef Added the ability to read compressed .mag files (writing is not yet
supported).  Fixed the long-standing issue in which DRC does not
get stopped by the "drc off" command (the behavior for interrupting
the DRC was dependent on the DRC being turned on, and the "drc off"
command was turning it off before breaking, causing the interrupt
to be ignored).
2022-11-02 17:12:46 -04:00
Tim Edwards d229aefb15 A handful of changes after applying pull request #191 from
Alessandro De Laurenzis.  That pull request cleaned up the vast
majority of compiler warnings.  However, that cleanup exposed a
few additional warnings pointing to errors in the code that needed
fixing.  The code now compiles cleanly except for one warning
about redefined CAD_DIR that I have not looked into.
2022-10-29 09:57:41 -04:00
Alessandro De Laurenzis 68cecd5382 C99 code compat when configured with no TCL support 2022-10-29 06:07:46 +02: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
Brad Smith 662a041dba Make use of termios on OpenBSD 2022-09-02 23:52:34 -04:00
Brad Smith e4f6926ac0 Use proper path for more(1) on OpenBSD / NetBSD and DragonFly 2022-08-05 22:44:29 -04:00
Tim Edwards 371018ae4b Implemented native gzip compression/decompression using zlib routines.
Compression levels of the output can be controlled with the "gds
compress [<value>]" command, where <value> 0 (default) is uncompressed
output, 6 is "normal" gzip compression, and 9 is maximum compression.
2022-05-10 09:19:39 -04:00
Tim Edwards 6e0768ebd4 Removed the "-k" option from "gunzip", which is not only redundant
with "-c" but is unsupported on some OS versions of gunzip.
2022-05-09 15:27:51 -04:00
Tim Edwards 85d8ad6622 Added the capability to handle compressed GDS files through the use
of systems calls to "gzip" and "gunzip".  A compressed GDS file can
be made simply by doing "gds write <name>.gds.gz", and can be read
simply by doing "gds read <name>.gds.gz".  Names of compressed files
can be put in the GDS_FILE property of a cell.
2022-05-05 17:40:56 -04:00
Tim Edwards 505155497e Resolved an issue with magic crashing during "antennacheck" due to
a routine that should have been called with a NULL argument, but
instead was called with no argument, making the behavior system-
dependent.  Revised the parsing of the "defaultareacap" and
"defaultperimeter" statements in the tech file, such that the short
version of both statements gets automatic handling of the substrate
and isolated substrate areas;  this goes back to the recent change
in extraction behavior to redefine the "substrate type" (e.g., pwell)
during extraction as defining isolated substrate areas, and not the
default substrate.  The earlier code change dealt with problems
related to extracting nodes and regions, but did not consider how
parasitic capacitance was affected.  This commit resolves that issue.
2022-02-23 15:02:40 -05:00
Tim Edwards 6ecd077ab4 Restored compiling of the non-Tcl/Tk version of magic. This has
traditionally been kept for backwards compatibility.  However, the
operation of "ext2spice" and "ext2sim" as separate programs has
become extremely difficult to maintain, and so it has been dropped
in favor of folding both into the program as commands, as was done
a long time ago in the Tcl/Tk version.
2022-02-08 16:12:07 -05:00
Anton Blanchard 4f79580248 Add missing includes
A number of places are using isspace(), tolower(), toupper() and strcmp()
without including the relevant header.
2022-01-10 14:01:36 -05:00
Tim Edwards 1bb4cb92ea Played around with the file locking and discovered to my chagrin that
whenever a process writes a cell to disk, it immediately releases the
file lock it had on that cell, which is clearly not the intent of file
locking.  Fixed this issue.  On a related topic, revised the "cellname
writeable" command so that it can make a cell editable even if the cell
has an advisory lock and cannot be made writeable.  Perhaps there should
be a clearer distinction here between "writeable" and "editable".  Also:
Reconsidered the previous commit, which removed the "--disable-locking"
from the configuration options.  Because some operating systems may not
implement fnctl()-based file locking (Cygwin, for one, apparently doesn't),
it is still useful to be able to completely remove the function, in case
the operating system will fail to recognize the fnctl() values in the
code.  Now, file locking behavior can be permanently removed through the
configuration option, or temporarily disabled from the command line.
2022-01-01 16:53:46 -05:00
Tim Edwards e4d1c29112 Reworked the file locking option as a command instead of as a
compile-time option.  The behavior can now be controlled from
within the program with "locking disable" or "locking enable".
2022-01-01 14:28:59 -05:00
Tim Edwards 6a78f4967e Updated the version to go along with pull request #115 from github
user susinxy.  Edited the merged code slightly, without changing
the functionality.
2022-01-01 13:24:18 -05:00
susinxy 620217b860 fix tech file load error with qflow 2022-01-01 13:18:09 -05:00
Tim Edwards c7e59ef461 Corrected issues with loading an invalid tech file. Also corrected
the behavior that extensions other than ".tech*" are not honored in
a tech file name.
2021-11-24 10:56:08 -05:00
Tim Edwards 355399d3ef Modified the startup behavior so that if a ".tcl" script file is
presented on the command line, then all following arguments are
assumed to be arguments of the script and not additional input
to be processed by magic.  This allows arguments to be passed to
scripts passed to magic on the command line.
2021-07-08 16:03:05 -04:00
Tim Edwards e36560fb90 Added a missing include of ctype.h to a source file that uses the
isalnum() subroutine.  Corrected an assignment in utils/tech.c
which was a syntax error that passes through the compiler.
2021-06-19 10:30:47 -04:00
Tim Edwards 39630ea710 Added missing function declaration for GeoCanonicalRect in
geometry.h.
2021-06-14 09:45:36 -04:00
Tim Edwards df26cf1ace This corrects the issue raised in pull request #75 that breaks the
compile on clang and probably other finicky compilers (as well as
just being wrong).
2021-06-12 20:29:09 -04:00
Tim Edwards 9aa39f820f A number of fixes to the extresist code (as well as style cleanup).
Still tracking down a problem with non-FET devices (e.g., capacitors).
So, work in progress.  Nothing should be affected outside of extresist.
2021-05-25 22:41:52 -04:00
Tim Edwards 8a0b180cde Modified the crash backup script to add options "disable" and "resume".
However, this has not been implemented as it has been observed that
the use of itimer() has a restriction of one timer per process, which
interferes with the three or more uses of the timer within magic.  The
timer method will have to be changed to use the POSIX timer_create()
routine, before this will work properly.
2021-03-17 12:45:35 -04:00
Anton Blanchard bdeb4bab50 Restore terminal if exit is called inside a TCL script at startup
If exit is called in a TCL script that is executed at startup, the libc
exit() function is called directly and we don't get a chance to reset
the terminal. We return to the shell with echo off, and have to run
"reset". A simple example:

echo exit > test.tcl
magic -noconsole -dnull  test.tcl

There are a few ways we could solve this. We could register an exit
handler using atexit(). Here I use Tcl_SetExitProc() to register a
callback with the TCL interpreter.
2021-02-18 11:38:42 +11:00
Tim Edwards 20eb6ce6c1 Made a few modifications to the patch from Keno Fischer (pull request
startup.  I'm not sure that it is even possible to have a Tcl variable
set at this point in the startup procedure, though.
2021-01-04 09:47:03 -05:00
Tim Edwards ba77257afa Several changes and updates: (1) Added a new keyword "required" to the
tech file format "version" section.  This can be used to specify the
version of magic that must be used to be compatible with the tech file.
This effectively supercedes the technology version number.  (2) Changed
the behavior of "make" to set the version and revision numbers on doing
"make" instead of "configure".  This allows the version to update
correctly after doing a "git pull" followed by "make" without doing
"configure" in between.  (3) Fixed a couple of issues that were flagged
as compile-time warnings.
2020-12-16 11:49:24 -05:00
Tim Edwards 1b3299ec90 Updated PaOpen() to handle a Tcl variable of the type ${X} as well as
just plain $X (i.e., ignore any brackets around the variable) when
doing variable expansion.
2020-12-04 14:46:48 -05:00
Tim Edwards e7074e5723 Added two small features: (1) Added the "-annotate" option to "lef
read".  While "lef read" normally annotates existing layout, this
option ensures that no additional cells are created from macros in
the input LEF file.  (2) Added a check on the "Input off lambda grid"
warning during CIF/GDS input such that it is not repeated once issued,
as it tends to be output many times when it occurs.
2020-10-14 17:20:45 -04:00