GNUnet 0.21.1
speedup.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "speedup.h"
30
31#define LOG(kind, ...) GNUNET_log_from (kind, "util-speedup", __VA_ARGS__)
32
33
35
37
39
40
41static void
42do_speedup (void *cls)
43{
44 static long long current_offset;
45
46 (void) cls;
47 speedup_task = NULL;
48 current_offset += delta.rel_value_us;
49 GNUNET_TIME_set_offset (current_offset);
51 "Speeding up execution time by %s\n",
55 NULL);
56}
57
58
59int
61{
63 if (GNUNET_OK !=
65 "testing",
66 "SPEEDUP_INTERVAL",
67 &interval))
68 return GNUNET_SYSERR;
69 if (GNUNET_OK !=
71 "testing",
72 "SPEEDUP_DELTA",
73 &delta))
74 return GNUNET_SYSERR;
75
76 if ((0 == interval.rel_value_us) ||
77 (0 == delta.rel_value_us))
78 {
80 "Speed up disabled\n");
81 return GNUNET_OK;
82 }
84 "Speed up execution by %s\n",
87 "Speed up executed every %s\n",
91 NULL);
92 return GNUNET_OK;
93}
94
95
99void
101{
102 if (NULL != speedup_task)
103 {
105 speedup_task = NULL;
106 }
107 if ((0 != interval.rel_value_us) &&
108 (0 != delta.rel_value_us))
110 "Stopped execution speed up\n");
111}
112
113
114/* end of speedup.c */
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now_with_lifeness(int lifeness, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible with the (transitive) ignore-shutdown flag either e...
Definition: scheduler.c:1373
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1278
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:570
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
Definition: time.c:49
static void do_speedup(void *cls)
Definition: speedup.c:42
int GNUNET_SPEEDUP_start_(const struct GNUNET_CONFIGURATION_Handle *cfg)
Start task that may speed up our system clock artificially.
Definition: speedup.c:60
static struct GNUNET_TIME_Relative interval
Definition: speedup.c:34
static struct GNUNET_SCHEDULER_Task * speedup_task
Definition: speedup.c:38
#define LOG(kind,...)
Definition: speedup.c:31
void GNUNET_SPEEDUP_stop_()
Stop tasks that modify clock behavior.
Definition: speedup.c:100
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.