mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 09:39:13 +00:00
Now threads restortion (and TLS as well) works.
Threads test reports the following
2775 (main): Counter value: 3 tls_data = 1
2775 (main): ( 0) fsgs_base 7f9597aa46f0
2775 (main): ( 0) fsgs_base 0
2775 (thr3): Counter value: 4 tls_data = 4
2775 (thr3): ( 0) fsgs_base 42c57940
2775 (thr3): ( 0) fsgs_base 0
2775 (thr2): Counter value: 3 tls_data = 2
2775 (thr2): ( 0) fsgs_base 42456940
2775 (thr2): ( 0) fsgs_base 0
2775 (thr1): Counter value: 4 tls_data = 3
2775 (thr1): ( 0) fsgs_base 40c62940
2775 (thr1): ( 0) fsgs_base 0
2775 (main): Counter value: 4 tls_data = 1
2775 (main): ( 0) fsgs_base 7f9597aa46f0
2775 (main): ( 0) fsgs_base 0
2775 (thr1): Counter value: 5 tls_data = 3
2775 (thr1): ( 0) fsgs_base 40c62940
2775 (thr1): ( 0) fsgs_base 0
as expected.
This commits merges all preliminary commits into
the final one (sigreturn branch was always experimental
and forced update).
Still some problems remain:
1) While creating threads with clone() the
flags are to be revisited. We use some predefined
set here but it's not really correct.
2) No setup of pids in PCB thread zone.
3) No restore of FPU.
But at least on some basic tasks restore works well.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
59 lines
1.6 KiB
C
59 lines
1.6 KiB
C
#ifndef CR_COMPILER_H_
|
|
#define CR_COMPILER_H_
|
|
|
|
/*
|
|
* Various definitions for success build,
|
|
* picked from various places, mostly from
|
|
* the linux kernel.
|
|
*/
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
|
|
|
|
#define __stringify_1(x...) #x
|
|
#define __stringify(x...) __stringify_1(x)
|
|
|
|
#define NORETURN __attribute__((__noreturn__))
|
|
#define __packed __attribute__((__packed__))
|
|
#define __used __attribute__((__used__))
|
|
|
|
#define __section(S) __attribute__ ((__section__(#S)))
|
|
|
|
#ifndef __always_inline
|
|
# define __always_inline inline __attribute__((always_inline))
|
|
#endif
|
|
|
|
#ifndef always_inline
|
|
# define always_inline __always_inline
|
|
#endif
|
|
|
|
#define __aligned(x) __attribute__((aligned(x)))
|
|
|
|
#ifndef offsetof
|
|
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
#endif
|
|
|
|
#define container_of(ptr, type, member) ({ \
|
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
(type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
#define __round_mask(x, y) ((__typeof__(x))((y) - 1))
|
|
#define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
|
|
#define round_down(x, y) ((x) & ~__round_mask(x, y))
|
|
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
|
|
|
|
#define min(x, y) ({ \
|
|
typeof(x) _min1 = (x); \
|
|
typeof(y) _min2 = (y); \
|
|
(void) (&_min1 == &_min2); \
|
|
_min1 < _min2 ? _min1 : _min2; })
|
|
|
|
#define max(x, y) ({ \
|
|
typeof(x) _max1 = (x); \
|
|
typeof(y) _max2 = (y); \
|
|
(void) (&_max1 == &_max2); \
|
|
_max1 > _max2 ? _max1 : _max2; })
|
|
|
|
#define is_log2(v) (((v) & ((v) - 1)) == 0)
|
|
|
|
#endif /* CR_COMPILER_H_ */
|