]> git.pond.sub.org Git - empserver/blob - src/scripts/nightly/patches/All/emptime.c.patch
Don't put file descriptor values in thread names
[empserver] / src / scripts / nightly / patches / All / emptime.c.patch
1 diff --git a/include/emptime.h b/include/emptime.h
2 new file mode 100644
3 index 0000000..3c1eb7b
4 --- /dev/null
5 +++ b/include/emptime.h
6 @@ -0,0 +1,43 @@
7 +/*
8 + *  Empire - A multi-player, client/server Internet based war game.
9 + *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
10 + *                Ken Stevens, Steve McClure, Markus Armbruster
11 + *
12 + *  Empire is free software: you can redistribute it and/or modify
13 + *  it under the terms of the GNU General Public License as published by
14 + *  the Free Software Foundation, either version 3 of the License, or
15 + *  (at your option) any later version.
16 + *
17 + *  This program is distributed in the hope that it will be useful,
18 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 + *  GNU General Public License for more details.
21 + *
22 + *  You should have received a copy of the GNU General Public License
23 + *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
24 + *
25 + *  ---
26 + *
27 + *  See files README, COPYING and CREDITS in the root of the source
28 + *  tree for related information and legal notices.  It is expected
29 + *  that future projects/authors will amend these files as needed.
30 + *
31 + *  ---
32 + *
33 + *  emptime.h: Time functions for regression testing
34 + *
35 + *  Known contributors to this file:
36 + *     Ron Koenderink, 2008
37 + *     Markus Armbruster, 2012
38 + */
39 +
40 +#ifndef EMPTIME_H
41 +#define EMPTIME_H
42 +
43 +#include <sys/time.h>
44 +#include <time.h>
45 +
46 +extern time_t emp_time(time_t *, const char []);
47 +extern int emp_gettimeofday(struct timeval *, void *);
48 +
49 +#endif
50 diff --git a/src/lib/gen/emptime.c b/src/lib/gen/emptime.c
51 new file mode 100644
52 index 0000000..4461093
53 --- /dev/null
54 +++ b/src/lib/gen/emptime.c
55 @@ -0,0 +1,60 @@
56 +/*
57 + *  Empire - A multi-player, client/server Internet based war game.
58 + *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
59 + *                Ken Stevens, Steve McClure, Markus Armbruster
60 + *
61 + *  Empire is free software: you can redistribute it and/or modify
62 + *  it under the terms of the GNU General Public License as published by
63 + *  the Free Software Foundation, either version 3 of the License, or
64 + *  (at your option) any later version.
65 + *
66 + *  This program is distributed in the hope that it will be useful,
67 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
68 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
69 + *  GNU General Public License for more details.
70 + *
71 + *  You should have received a copy of the GNU General Public License
72 + *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
73 + *
74 + *  ---
75 + *
76 + *  See files README, COPYING and CREDITS in the root of the source
77 + *  tree for related information and legal notices.  It is expected
78 + *  that future projects/authors will amend these files as needed.
79 + *
80 + *  ---
81 + *
82 + *  emptime.c: Time functions for regression testing
83 + *
84 + *  Known contributors to this file:
85 + *     Ron Koenderink, 2008
86 + *     Markus Armbruster, 2012
87 + */
88 +
89 +#include <stdio.h>
90 +#include <string.h>
91 +#include "emptime.h"
92 +
93 +static time_t now = (time_t)100L;
94 +
95 +time_t
96 +emp_time(time_t * time_ptr, const char function[])
97 +{
98 +    if (strcmp(function, "update_main") == 0)
99 +       now += 100L;
100 +
101 +    if (time_ptr != NULL)
102 +       *time_ptr = now;
103 +
104 +    return now;
105 +}
106 +
107 +int
108 +emp_gettimeofday(struct timeval *tv, void *tz)
109 +{
110 +    if (tv) {
111 +       tv->tv_sec = now;
112 +       tv->tv_usec = 0;
113 +    }
114 +    return 0;
115 +}