Skip to content

Commit

Permalink
Compatibility with C99 standard
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
just22 committed Oct 29, 2022
1 parent 9d40fbf commit b306a39
Show file tree
Hide file tree
Showing 151 changed files with 1,095 additions and 19 deletions.
3 changes: 3 additions & 0 deletions calma/CalmaRdcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "calma/calmaInt.h"
#include "calma/calma.h"

/* C99 compat */
#include "drc/drc.h"

int calmaNonManhattan;
int CalmaFlattenLimit = 10;
int NameConvertErrors = 0;
Expand Down
3 changes: 3 additions & 0 deletions calma/CalmaRdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/textio.h"
#include "calma/calmaInt.h"

/* C99 compat */
#include "calma/calma.h"

/* Forward declarations */
bool calmaReadR8();
bool calmaSkipBytes();
Expand Down
3 changes: 3 additions & 0 deletions calma/CalmaRdpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "calma/calmaInt.h"
#include "calma/calma.h"

/* C99 compat */
#include "drc/drc.h"

extern int calmaNonManhattan;

extern int CalmaPolygonCount;
Expand Down
3 changes: 3 additions & 0 deletions calma/CalmaRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/main.h" /* for EditCellUse */
#include "utils/undo.h"

/* C99 compat */
#include "calma/calma.h"

/* Globals for Calma reading */
FILETYPE calmaInputFile = NULL; /* Read from this stream */
FILE *calmaErrorFile = NULL; /* Write error output here */
Expand Down
4 changes: 4 additions & 0 deletions calma/CalmaWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ static char rcsid[] __attribute__ ((unused)) ="$Header: /usr/cvsroot/magic-8.0/c
#include "utils/main.h" /* for Path and CellLibPath */
#include "utils/stack.h"

/* C99 compat */
#include "utils/undo.h"
#include "calma/calma.h"

/* Exports */
bool CalmaDoLibrary = FALSE; /* If TRUE, do not output the top level */
bool CalmaDoLabels = TRUE; /* If FALSE, don't output labels with GDS-II */
Expand Down
4 changes: 4 additions & 0 deletions calma/CalmaWriteZ.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ static char rcsid[] __attribute__ ((unused)) ="$Header: /usr/cvsroot/magic-8.0/c
#include "utils/main.h" /* for Path and CellLibPath */
#include "utils/stack.h"

/* C99 compat */
#include "utils/undo.h"
#include "calma/calma.h"

/* External variables from CalmaWrite.c */
extern HashTable calmaLibHash;
extern HashTable calmaPrefixHash;
Expand Down
30 changes: 29 additions & 1 deletion calma/calma.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern char **CalmaFlattenUsesByName;
extern bool CalmaReadOnly;
extern bool CalmaContactArrays;
#ifdef HAVE_ZLIB
extern bool CalmaCompression;
extern int CalmaCompression;
#endif
extern bool CalmaPostOrder;
extern bool CalmaAllowUndefined;
Expand All @@ -55,6 +55,34 @@ extern void CalmaTechInit();
extern bool CalmaGenerateArray();
extern void CalmaReadError();

/* C99 compat */
extern void CalmaReadError();
extern int calmaAddSegment();
extern void calmaDelContacts();
extern void calmaElementBoundary();
extern void calmaElementBox();
extern void calmaElementPath();
extern void calmaElementText();
extern bool calmaIsUseNameDefault();
extern bool calmaParseStructure();
extern int calmaProcessDef();
extern int calmaProcessDefZ();
extern bool calmaReadI2Record();
extern bool calmaReadI4Record();
extern void calmaReadPoint();
extern bool calmaReadR8();
extern bool calmaReadStampRecord();
extern bool calmaReadStringRecord();
extern bool calmaReadStringRecord();
extern bool calmaReadTransform();
extern bool calmaSkipBytes();
extern bool calmaSkipExact();
extern bool calmaSkipTo();
extern void calmaUnexpected();
extern void calmaMergeSegments();
extern void calmaRemoveDegenerate();
extern void calmaRemoveColinear();

#ifdef HAVE_ZLIB
extern bool CalmaWriteZ();
#endif
Expand Down
4 changes: 4 additions & 0 deletions cif/CIFgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/maxrect.h"
#include "drc/drc.h"

/* C99 compat */
#include "textio/textio.h"
#include "utils/undo.h"

/* TRUE to run (very slow) algorithm for optimizing non-manhattan tiles */
/* (cuts size of output; see also the GDS "merge" option) */
bool CIFUnfracture = FALSE;
Expand Down
20 changes: 20 additions & 0 deletions cif/CIFint.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,26 @@ extern int cifHierCopyMaskHints();
extern void CIFLoadStyle();
extern void CIFCopyMaskHints();

/* C99 compat */
extern void CIFCoverageLayer();
extern bool CIFWriteFlat();
extern void CIFScalePlanes();
extern void CIFInputRescale();
extern int CIFCalmaLayerToCifLayer();
extern int CIFScaleCoord();
extern void CIFPropRecordPath();
extern void CIFPaintWirePath();
extern void CIFMakeManhattanPath();
extern int cifGrowSliver();
extern int cifHierElementFunc();
extern int cifSquareFunc();
extern int cifSquareGridFunc();
extern int cifSlotFunc();
extern int CIFParseScale();
extern int cifParseCalmaNums();
extern int CIFEdgeDirection();
extern bool CIFReadTechLimitScale();

/* Shared variables and structures: */

extern Plane *CIFPlanes[]; /* Normal place to store CIF. */
Expand Down
2 changes: 2 additions & 0 deletions cif/CIFrdpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "cif/CIFint.h"
#include "cif/CIFread.h"

/* C99 compat */
#include "textio/textio.h"

/*
* ----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions cif/CIFrdtech.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "calma/calmaInt.h"
#include "utils/malloc.h"

/* C99 compat */
#include "cif/cif.h"

/* Pointer to a list of all the CIF-reading styles: */

CIFReadKeep *cifReadStyleList = NULL;
Expand Down
16 changes: 16 additions & 0 deletions cif/CIFrdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include <stdarg.h>
#include <ctype.h>

/*
* C99 compat
* Mind: tcltk/tclmagic.h must be included prior to all the other headers
*/
#include "tcltk/tclmagic.h"

#include "utils/magic.h"
#include "utils/geometry.h"
#include "tiles/tile.h"
Expand All @@ -40,6 +46,16 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/undo.h"
#include "utils/malloc.h"

/* C99 compat */
#include "lef/lef.h"
#include "drc/drc.h"
#include "extract/extract.h"
#include "wiring/wiring.h"
#include "router/router.h"
#include "mzrouter/mzrouter.h"
#include "irouter/irouter.h"
#include "plow/plow.h"

/* The following variables are used to provide one character of
* lookahead. cifParseLaAvail is TRUE if cifParseLaChar contains
* a valid character, FALSE otherwise. The PEEK and TAKE macros
Expand Down
3 changes: 3 additions & 0 deletions cif/CIFsee.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/textio.h"
#include "utils/undo.h"

/* C99 compat */
#include "drc/drc.h"

/* The following variable holds the CellDef into which feedback
* is to be placed for displaying CIF.
*/
Expand Down
5 changes: 5 additions & 0 deletions cif/CIFtech.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "cif/cif.h"
#include "drc/drc.h" /* For WRL's DRC-CIF extensions */

/* C99 compat */
#include "calma/calma.h"
#include "dbwind/dbwind.h"
#include "drc/drc.h"

/* The following statics are used to keep track of things between
* calls to CIFTechLine.
*/
Expand Down
5 changes: 4 additions & 1 deletion cif/cif.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extern void CIFTechInit();
extern bool CIFTechLine();
extern void CIFTechFinal();
extern void CIFTechOutputScale();
extern void CIFTechInputScale();
extern int CIFTechInputScale();
extern bool CIFTechLimitScale();
extern void CIFReadTechStyleInit();
extern void CIFReadTechInit();
Expand Down Expand Up @@ -91,4 +91,7 @@ extern int CIFOutputScaleFactor();
extern void PaintWireList();
extern LinkedRect *PaintPolygon();

/* C99 compat */
extern int CIFGetContactSize();

#endif /* _CIF_H */
4 changes: 4 additions & 0 deletions cmwind/cmwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ extern Rect cmwCurrentColorArea;
extern void cmwUndoColor(int, int, int, int, int, int, int);
extern bool CMWCheckWritten(void);

/* C99 compat */
extern void CMWinit();


#endif /* _CMWIND_H */
3 changes: 3 additions & 0 deletions commands/CmdCD.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "cif/CIFread.h"
#include "calma/calmaInt.h"

/* C99 compat */
#include "dbwind/dbwtech.h"

/* The following structure is used by CmdCorner to keep track of
* areas to be filled.
*/
Expand Down
3 changes: 3 additions & 0 deletions commands/CmdE.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "extract/extract.h"
#include "select/select.h"

/* C99 compat */
#include "dbwind/dbwtech.h"


/*
* ----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions commands/CmdFI.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "sim/sim.h"
#include "gcr/gcr.h"

/* C99 compat */
#include "cif/cif.h"

/* The following structure is used by CmdFill to keep track of
* areas to be filled.
*/
Expand Down
3 changes: 3 additions & 0 deletions commands/CmdLQ.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "select/select.h"
#include "netmenu/netmenu.h"

/* C99 compat */
#include "cif/cif.h"

/* Forward declarations */

void CmdPaintEraseButton();
Expand Down
10 changes: 9 additions & 1 deletion commands/CmdRS.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/signals.h"
#include "sim/sim.h"

/* C99 compat */
#include "cif/cif.h"
#include "lef/lef.h"
#include "extract/extract.h"
#include "irouter/irouter.h"
#include "mzrouter/mzrouter.h"
#include "router/router.h"
#include "wiring/wiring.h"

extern void DisplayWindow();

/* Used by CmdSetLabel() */
Expand Down Expand Up @@ -260,7 +269,6 @@ CmdScaleGrid(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
extern void DBScalePoint();
int scalen, scaled;
char *argsep;
Rect rootBox;
Expand Down
3 changes: 3 additions & 0 deletions commands/CmdTZ.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/tech.h"
#include "drc/drc.h"

/* C99 compat */
#include "cif/cif.h"

#ifdef LLNL
#include "yacr.h"
#endif /* LLNL */
Expand Down
3 changes: 3 additions & 0 deletions commands/CmdWizard.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/utils.h"
#include "textio/txcommands.h"

/* C99 compat */
#include "extract/extract.h"

/* Forward declarations */

extern void cmdPsearchStats();
Expand Down
12 changes: 12 additions & 0 deletions commands/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ extern void CmdDoMacro();
extern TileType CmdFindNetProc();
extern bool CmdCheckForPaintFunc();

/* C99 compat */
extern int cmdScaleCoord();
extern void FlatCopyAllLabels();
extern bool cmdDumpParseArgs();
extern void cmdFlushCell();
extern int cmdParseCoord();
extern void cmdSaveCell();
extern void CmdInit();

extern void CmdDoProperty();
extern void CmdPaintEraseButton();

#endif /* _COMMANDS_H */
3 changes: 3 additions & 0 deletions database/DBcellcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "dbwind/dbwind.h"
#include "commands/commands.h"

/* C99 compat */
#include "graphics/graphics.h"

/*
* The following variable points to the tables currently used for
* painting. The paint tables are occasionally switched, by clients
Expand Down
3 changes: 3 additions & 0 deletions database/DBconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/signals.h"
#include "utils/malloc.h"

/* C99 compat */
#include "textio/textio.h"

/* Global variable */
Stack *dbConnectStack = (Stack *)NULL;

Expand Down
12 changes: 12 additions & 0 deletions database/DBio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/malloc.h"
#include "utils/signals.h"

/* C99 compat */
#include "dbwind/dbwtech.h"
#include "cif/cif.h"
#include "lef/lef.h"
#include "commands/commands.h"
#include "graphics/graphics.h"
#include "irouter/irouter.h"
#include "mzrouter/mzrouter.h"
#include "router/router.h"
#include "wiring/wiring.h"
#include "extract/extract.h"

#ifndef _PATH_TMP
#define _PATH_TMP "/tmp"
#endif
Expand Down
Loading

0 comments on commit b306a39

Please sign in to comment.