On Mon, May 06 2019, Jeremie Courreges-Anglas <j...@wxcvbn.org> wrote:

[...]

> One serious issue, straight from the 80's, is the lack of feature
> detection for lots of stuff, leading to ugly #ifdefs.  For example,
> using gcc -std=gnu89, the only warning you get is:
>
>   timing.c:103: warning: passing argument 1 of 'time' from incompatible 
> pointer type
>
> The code passes a "long" instead of a "time_t" to time(3).  If you look
> at timing.c you see that time(3) is used as a fallback when neither
> clock(3), times(2) or getrusage(2) are available.  But to unveil the
> better code, you need to add the appropriate -DHAVE_CLOCK to CPPFLAGS;
> see base/config.h for more fun.  It's a shame for a project using
> autoconf-2.69.

Here's a minimal diff to work around the time_t issue - a potential
stack overflow on 32 bits archs - by using what should be a better code
path.  time(3) counts real seconds, not consumed cpu time.

Note that the time_t issue is still a bug on all 32 bits archs using
a 64 bits time_t.  To fix it, the type of variables "st" and "now"
in base/timing.c should be changed from "long" to "time_t".

ok?


Index: Makefile
===================================================================
RCS file: /cvs/ports/cad/netgen/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile    8 May 2019 13:11:43 -0000       1.3
+++ Makefile    8 May 2019 14:18:07 -0000
@@ -3,7 +3,7 @@
 COMMENT =      tool for netlist comparison (LVS) and format manipulation
 DISTNAME =     netgen-1.5.118
 EXTRACT_SUFX = .tgz
-REVISION =     1
+REVISION =     2
 
 CATEGORIES =   cad
 
Index: patches/patch-base_config_h
===================================================================
RCS file: patches/patch-base_config_h
diff -N patches/patch-base_config_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-base_config_h 8 May 2019 14:18:07 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: base/config.h
+--- base/config.h.orig
++++ base/config.h
+@@ -39,7 +39,7 @@
+ /* #define HAVE_GETRUSAGE */
+ 
+ /* define the following if your system has ANSI C:  clock and CLOCKS_PER_SEC 
*/
+-/* #define HAVE_CLOCK */
++#define HAVE_CLOCK
+ 
+ /* define the following if your (nominally BSD) system provides the SYSV
+    string functions:  strchr, strrchr, memcpy, and memset */


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to