Commit Graph

36 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 4023ed9da0 tiles: Remove TiJoinFree() now that TiJoin[XY]1() exists and all use-cases utilize 2025-07-27 12:42:05 -04:00
Darryl L. Miles 489f4fe057 tile.h: move #include <sys/mman.h> into tile.c
tile.h is included by a large part of the project, but the definitions
in sys/mman.h are only needed by the implementation code inside tile.c
so this reduces project wide include dependencies.
2025-07-27 12:42:05 -04:00
Darryl L. Miles f8ef715608 tiles: Make TiFree() easier to inline for compiler
Removal of unnecessary function call indirection into TileStoreFree()
since TiFree() is has multiple implementation already and we can
customize TiFree() directly as required.

Move the function definitions into the tile.h to they are visible to
compiler during code generation to consider inline potential.

This has made global 'Tile *TileStoreFreeList' more visible.
2025-07-27 12:42:05 -04:00
Darryl L. Miles db8e790aea TiJoin[XY]1() API introduction 2025-07-27 12:42:05 -04:00
Darryl L. Miles 15e5b36f52 tile.h: TiFreeIf/TiFree1() API 2025-07-27 12:42:05 -04:00
Darryl L. Miles ea5f1ed3f1 tiles/tile.h: Remove unused inlines breaking older GCC
This was breaking on older GCCs (such as GCC 4.8.x used for
AppImage with CentOS7).
2025-07-26 17:29:19 -04:00
R. Timothy Edwards 490fc6f9d7 Added a quick hack solution from Darryl Miles to prevent the
database corruption discovered recently that was uncovered by a
commit on Jan. 31 and is caused by DBMergeNMTiles0() using a
freed tile (reported in github issue #404).
2025-06-12 19:54:33 -04:00
Darryl L. Miles 51ec834f6c This attempts to remove the number of active lines of code, branches from
the TiAlloc() and TiFree() code path.

The rationale of the changes:

Performing the one-time initialization check (first call to
mmapTileStore()) for every TiAlloc() is unnecessary if the decision code
is reworked to allow NULL pointers to exist in the computation and still
make the correct decision.

Use of 'unsigned long' for pointer arithmetic is not compatible with _WIN64
compiler model LLP64.  Changed to 'pointertype'.

The computations addition/subtraction/greater-than were performed
multiple times.  Seemed a convoulted method when a single operation
should be good enough.

The use of a single-linked-list with HEAD and TAIL does not make sense.
My gut is telling me that for the purpose of memory allocation a LIFO is
better as a free-and-reuse of the most recently freed item is more likely
to already be in the CPU cache and the oldest freed item is more likely
to have been evicted from CPU cache.  So given the use of a custom
allocator and no support to reclaim/compact or manage fragmentation
other factor didn't carry any weight.
Technically TiAlloc() returns undefined memory and the first action of
the caller is to write new values, but the point remains that write is
more likely to cause eviction of something else from cache with the
original FIFO scheme.
Due to the free list use during TiFree() there is a write to each alloc
which will make the cache-line hotter in the cache (less likely to have
been evicted) when using LIFO scheme than FIFO scheme.

Further more the use of HEAD and TAIL had a far more complex
TileStoreFree() than was necessary even for such a list.  A 4 line
method turned into 7 with multiple conditions tested when branching.
The TileStoreFreeList/TileStoreFreeList_end were public symbols which may
also impact the freedom the compiler has to optimise around them.

Using LIFO single-linked-list resulted in the removal of
TileStoreFreeList_end and associated simplification.

Use of 'static' for the methods mmapTileStore() and getTimeFromTileStore()
these are not public API so adding the 'static' give the compiler a hint
these methods maybe inlined as they are not accessile from outside this
compliation unit.

The -O3 assembly result looks quite healthy in achieving the original
goal of instruction and branch reductions with the compiler able to
inline all 3 methods into a single TiAlloc().
2025-04-09 15:07:28 -04:00
Darryl L. Miles 1c3a059031 tiles: TileStoreFreeList_end removal 2025-04-09 15:07:28 -04:00
Darryl L. Miles e1238633ac tiles: simplify TileStoreFree() and TileStoreFreeList_end management 2025-04-09 15:07:28 -04:00
Darryl L. Miles b9dd4bfb7c tiles: reorder TileStoreFree() 2025-04-09 15:07:27 -04:00
Darryl L. Miles 52fced3544 K&R: tile/*.c bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2025-04-09 15:07:27 -04:00
Darryl L. Miles 650d800b12 tiles: use 'const' with 'rcsid' 2025-04-09 15:07:27 -04:00
Darryl L. Miles 686adc13b3 tiles: unclear why TileStoreFreeList is an exported global
Looks private internal implementation detail that may benefit from
compiler single compile unit optimisations.
2025-04-09 15:07:27 -04:00
Darryl L. Miles 0f19a20c8c tiles: pointer arithmetic with 'unsigned long' is too narrow for _WIN64
is mmap() is available the type 'size_t' is better suited
2025-04-09 15:07:27 -04:00
Darryl L. Miles 34dfd3686b tiles: treat ti_client as pointer and use macros 2025-04-09 15:07:27 -04:00
Darryl L. Miles cc6e7ebe84 tiles: constify data and API call arguments as appropriate 2025-04-09 15:07:27 -04:00
Darryl L. Miles d082c67b03 K&R tile.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-04-09 15:07:27 -04:00
Darryl L. Miles e8ad7c9ac8 tiles: remove non-existent function prototype TiSrArea() 2025-04-09 15:07:27 -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
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 07f9bbe1fb gcc11 -Wall -Wpedantic cleanup 2025-01-06 16:12:11 +00:00
Darryl L. Miles 0ce8265570 TCL9: ClientData macro assignment and access usage 2025-01-04 11:08:01 -05:00
Darryl L. Miles 79f2ab0f4b TCL9: ClientData macro header file changes
Header files documentation indicates the macros are of type ClientData
but previously did not cast to ensure that. So now follow this intention.
2025-01-04 11:08:01 -05: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
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 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim Edwards be1c0d1368 Merge branch 'master' into bplane
Conflicts:
	VERSION
	calma/Depend
	cif/Depend
	cmwind/Depend
	commands/Depend
	database/Depend
	dbwind/Depend
	debug/Depend
	drc/Depend
	ext2sim/Depend
	ext2spice/Depend
	extflat/Depend
	extract/Depend
	garouter/Depend
	gcr/Depend
	graphics/Depend
	grouter/Depend
	irouter/Depend
	lef/Depend
	lisp/Depend
	mzrouter/Depend
	netmenu/Depend
	plot/Depend
	plow/Depend
	resis/Depend
	router/Depend
	select/Depend
	sim/Depend
	tcltk/Depend
	textio/Depend
	tiles/Depend
	utils/Depend
	windows/Depend
	wiring/Depend

Merged recent changes from master branch into bplane branch.  Testing the
bplane implementation which has about a 5x improvement in extraction times
for large layouts, which is significant enough to move ahead with the bplane
implementation;  however, the bplane implementation has not been thoroughly
vetted yet, so it will remain a branch until such time that it has been
validated.
2020-03-15 13:23:24 -04:00
Tim Edwards 80fa495103 Removed the Depend files, which were being tracked with .gitignore
pointing to Depend instead of */Depend.
2020-03-13 15:39:08 -04:00
Tim Edwards 197c3f3448 Merge branch 'master' into bplane
Conflicts:
	commands/CmdCD.c
	database/DBcellsrch.c
	database/DBconnect.c
	database/DBio.c
	lef/lefRead.c
	select/selDisplay.c

Updated the bplane implementation with all recent updates (merged master).
2019-07-24 20:36:55 -04:00
Tim Edwards 1d04f20f5d Moved new work on magic-8.4 (experimental merging of micromagic bplane structure
into magic-8.2) into the newly-reorganized git repo as branch "bplane".
2019-03-22 19:58:47 -04:00
Tim Edwards 63d5a9c489 Updates and fixes to the configuration file definitions for Mac OSX
using MacPorts, with considerable help from Ryan Schmidt.
2017-10-16 19:56:04 -04:00
Tim Edwards 741df0fe01 Removed the "macosx" definition from the configuration file, which
got copied over from another project but apprently causes serious
issues with the OSX compilation.
2017-10-14 18:42:24 -04:00
Tim Edwards 231a299b16 Initial commit at Tue Apr 25 08:41:48 EDT 2017 by tim on stravinsky 2017-04-25 08:41:48 -04:00