Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/monop PR/8247: Simon Burge: monop(6) save/restore does...



details:   https://anonhg.NetBSD.org/src/rev/580158f37bdb
branches:  trunk
changeset: 546147:580158f37bdb
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Apr 21 01:25:27 2003 +0000

description:
PR/8247: Simon Burge: monop(6) save/restore doesn't work.
With the advent of elf and mmaping malloc, assumptions that the code made
before about location and contents of the data segment broke. We supplied
an sbrk() only malloc, and recorded the break point at the beginning of
the program, so now save and restore works, in the traditional monop style.

diffstat:

 games/monop/execute.c |  9 +++++----
 games/monop/monop.c   |  6 ++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diffs (78 lines):

diff -r 49279f81e470 -r 580158f37bdb games/monop/execute.c
--- a/games/monop/execute.c     Mon Apr 21 01:23:06 2003 +0000
+++ b/games/monop/execute.c     Mon Apr 21 01:25:27 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: execute.c,v 1.8 2001/08/29 18:23:44 jsm Exp $  */
+/*     $NetBSD: execute.c,v 1.9 2003/04/21 01:25:27 christos Exp $     */
 
 /*
  * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)execute.c  8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: execute.c,v 1.8 2001/08/29 18:23:44 jsm Exp $");
+__RCSID("$NetBSD: execute.c,v 1.9 2003/04/21 01:25:27 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,6 +59,7 @@
 static char    buf[257];
 
 static bool    new_play;       /* set if move on to new player         */
+extern void    *heapstart;
 
 static void show_move __P((void));
 
@@ -209,7 +210,7 @@
        for (sp = buf; *sp != '\n'; sp++)
                continue;
        *sp = '\0';
-       start = 0;
+       start = heapstart;
        end = sbrk(0);
        while (start < end) {           /* write out entire data space */
                num = start + 16 * 1024 > end ? end - start : 16 * 1024;
@@ -258,7 +259,7 @@
                perror(file);
                exit(1);
        }
-       start = 0;
+       start = heapstart;
        brk(end = start + sbuf.st_size);
        while (start < end) {           /* write out entire data space */
                num = start + 16 * 1024 > end ? end - start : 16 * 1024;
diff -r 49279f81e470 -r 580158f37bdb games/monop/monop.c
--- a/games/monop/monop.c       Mon Apr 21 01:23:06 2003 +0000
+++ b/games/monop/monop.c       Mon Apr 21 01:25:27 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: monop.c,v 1.12 2001/09/18 18:15:49 wiz Exp $   */
+/*     $NetBSD: monop.c,v 1.13 2003/04/21 01:25:27 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)monop.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: monop.c,v 1.12 2001/09/18 18:15:49 wiz Exp $");
+__RCSID("$NetBSD: monop.c,v 1.13 2003/04/21 01:25:27 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -58,6 +58,7 @@
 static void init_players __P((void));
 static void init_monops __P((void));
 static void do_quit __P((int));
+void *heapstart;
 
 /*
  *     This program implements a monopoly game
@@ -71,6 +72,7 @@
        setgid(getgid());
 
        srand(getpid());
+       heapstart = sbrk(0);
        if (ac > 1) {
                if (!rest_f(av[1]))
                        restore();



Home | Main Index | Thread Index | Old Index