summaryrefslogtreecommitdiff
path: root/games/tscp
diff options
context:
space:
mode:
authordholland <dholland@pkgsrc.org>2012-06-18 04:45:47 +0000
committerdholland <dholland@pkgsrc.org>2012-06-18 04:45:47 +0000
commitac66a2546084b6e59d0ea17a1386d6b0d512afea (patch)
treebaa1092d1714c5785272668533c4c5a30a93ba5f /games/tscp
parenta843f35e048c8dc305c469025a7ca8ac064240ff (diff)
downloadpkgsrc-ac66a2546084b6e59d0ea17a1386d6b0d512afea.tar.gz
Fix time handling; avoids need to use -lcompat and should fix the Linux
build. While here, tidy a couple bits of pkglint. PKGREVISION -> 3. Set LICENSE to generic-nonlicense as that appears to describe the situation.
Diffstat (limited to 'games/tscp')
-rw-r--r--games/tscp/Makefile10
-rw-r--r--games/tscp/distinfo3
-rw-r--r--games/tscp/patches/patch-main_c62
3 files changed, 69 insertions, 6 deletions
diff --git a/games/tscp/Makefile b/games/tscp/Makefile
index f2e1ae48bce..48775d500d9 100644
--- a/games/tscp/Makefile
+++ b/games/tscp/Makefile
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.17 2011/05/03 12:17:50 hauke Exp $
+# $NetBSD: Makefile,v 1.18 2012/06/18 04:45:47 dholland Exp $
#
DISTNAME= tscp181
PKGNAME= tscp-1.81
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= games benchmarks
MASTER_SITES= http://www.tckerrigan.com/Chess/TSCP/attachments/
EXTRACT_SUFX= .zip
@@ -11,19 +11,19 @@ EXTRACT_SUFX= .zip
MAINTAINER= abs@NetBSD.org
HOMEPAGE= http://www.tckerrigan.com/
COMMENT= Tom Kerrigan's Simple Chess Program
+LICENSE= generic-nonlicense
RESTRICTED= No distribution without authorisation from Tom Kerrigan
-
NO_BIN_ON_CDROM= ${RESTRICTED}
-NO_SRC_ON_CDROM= ${RESTRICTED}
NO_BIN_ON_FTP= ${RESTRICTED}
+NO_SRC_ON_CDROM= ${RESTRICTED}
NO_SRC_ON_FTP= ${RESTRICTED}
PKG_DESTDIR_SUPPORT= user-destdir
INSTALLATION_DIRS= bin share/doc
do-build:
- cd ${WRKSRC} ; ${CC} ${CFLAGS} ${LDFLAGS} -o tscp *.c -lcompat
+ cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o tscp *.c
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/tscp ${DESTDIR}${PREFIX}/bin/tscp
diff --git a/games/tscp/distinfo b/games/tscp/distinfo
index ca3011ab950..d9422ecf90e 100644
--- a/games/tscp/distinfo
+++ b/games/tscp/distinfo
@@ -1,5 +1,6 @@
-$NetBSD: distinfo,v 1.4 2005/02/23 23:12:03 agc Exp $
+$NetBSD: distinfo,v 1.5 2012/06/18 04:45:47 dholland Exp $
SHA1 (tscp181.zip) = 61ebac540a4e9f3067d6682a4b6dfc5fa8993790
RMD160 (tscp181.zip) = 98a2bc6a3c25a5a75f72448db9939cc71a4f90d8
Size (tscp181.zip) = 77019 bytes
+SHA1 (patch-main_c) = a353573c80d2b4fae530faddac69385d0cddefc9
diff --git a/games/tscp/patches/patch-main_c b/games/tscp/patches/patch-main_c
new file mode 100644
index 00000000000..75703842bb6
--- /dev/null
+++ b/games/tscp/patches/patch-main_c
@@ -0,0 +1,62 @@
+$NetBSD: patch-main_c,v 1.1 2012/06/18 04:45:47 dholland Exp $
+
+- use gettimeofday() rather than ftime(), which is very obsolete
+- don't truncate time_t (or worse, time_t * 1000) to int
+
+Note that because all times used elsewhere are relative, we can get
+away with subtracting off the start time like this. We could also
+probably get away with truncating to int, except that (a) it's untidy,
+(b) likely to attract attention from program checkers, and (c) can
+result in formally undefined behavior if we happen to be running
+across one of the moments where the milliseconds value passes through
+signed overflow.
+
+--- main.c~ 2003-02-05 06:02:40.000000000 +0000
++++ main.c
+@@ -15,18 +15,25 @@
+ #include "protos.h"
+
+
+-/* get_ms() returns the milliseconds elapsed since midnight,
+- January 1, 1970. */
++/* get_ms() returns the milliseconds elapsed since an arbitrary epoch
++ determined at program startup. */
+
+-#include <sys/timeb.h>
+-BOOL ftime_ok = FALSE; /* does ftime return milliseconds? */
++#include <sys/time.h>
++BOOL gettimeofday_ok = FALSE; /* are we getting better than just seconds? */
+ int get_ms()
+ {
+- struct timeb timebuffer;
+- ftime(&timebuffer);
+- if (timebuffer.millitm != 0)
+- ftime_ok = TRUE;
+- return (timebuffer.time * 1000) + timebuffer.millitm;
++ static BOOL initialized = 0;
++ static time_t epoch;
++ struct timeval timebuffer;
++ gettimeofday(&timebuffer, NULL);
++ if (!initialized) {
++ epoch = timebuffer.tv_sec;
++ initialized = 1;
++ }
++ timebuffer.tv_sec -= epoch;
++ if (timebuffer.tv_usec != 0)
++ gettimeofday_ok = TRUE;
++ return (timebuffer.tv_sec * 1000) + timebuffer.tv_usec / 1000;
+ }
+
+
+@@ -496,9 +503,9 @@ void bench()
+ printf("\n");
+ printf("Nodes: %d\n", nodes);
+ printf("Best time: %d ms\n", t[0]);
+- if (!ftime_ok) {
++ if (!gettimeofday_ok) {
+ printf("\n");
+- printf("Your compiler's ftime() function is apparently only accurate\n");
++ printf("Your compiler's gettimeofday() function is apparently only accurate\n");
+ printf("to the second. Please change the get_ms() function in main.c\n");
+ printf("to make it more accurate.\n");
+ printf("\n");