• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015-2016 Cyril Hrubis <chrubis@suse.cz>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18  /*
19 
20    Checkpoint - easy to use parent-child synchronization.
21 
22    Checkpoint is based on futexes (man futex). The library allocates a page of
23    shared memory for futexes and the id is an offset to it which gives the user
24    up to page_size/sizeof(uint32_t) checkpoint pairs. Up to INT_MAX processes
25    can sleep on single id and can be woken up by single wake.
26 
27   */
28 
29 #ifndef OLD_CHECKPOINT__
30 #define OLD_CHECKPOINT__
31 
32 #include "test.h"
33 #include "tst_checkpoint_fn.h"
34 
35 /*
36  * Checkpoint initializaton, must be done first.
37  *
38  * NOTE: tst_tmpdir() must be called beforehand.
39  */
40 #define TST_CHECKPOINT_INIT(cleanup_fn) \
41 	tst_checkpoint_init(__FILE__, __LINE__, cleanup_fn)
42 
43 #define TST_SAFE_CHECKPOINT_WAIT(cleanup_fn, id) \
44         tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
45 
46 #define TST_SAFE_CHECKPOINT_WAIT2(cleanup_fn, id, msec_timeout) \
47         tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, msec_timeout);
48 
49 #define TST_SAFE_CHECKPOINT_WAKE(cleanup_fn, id) \
50         tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, 1);
51 
52 #define TST_SAFE_CHECKPOINT_WAKE2(cleanup_fn, id, nr_wake) \
53         tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, nr_wake);
54 
55 #define TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup_fn, id) \
56         tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, 1); \
57         tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
58 
59 #endif /* OLD_CHECKPOINT__ */
60