selfpatch-slr/subject/task_struct.h

74 lines
1.5 KiB
C

#include <stdio.h>
#include <stddef.h>
#define container_of(ptr, type, member) ({ \
const typeof(((type*)0)->member)* __mptr = (ptr); \
(type*)((char*)__mptr - offsetof(type, member)); })
# define randomized_struct_fields_start struct {
# define randomized_struct_fields_end } __attribute__((spslr));
// Minimal doubly linked list
struct list_head {
struct list_head *next, *prev;
};
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
static inline void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
}
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
struct ArrayFun {
int a, b, c;
double d;
} __attribute__((spslr));
// A small struct like the Linux kernel's task_struct
struct task_struct {
int stuck0;
randomized_struct_fields_start
randomized_struct_fields_start
int pid;
const char *comm;
struct ArrayFun arrfun[5];
randomized_struct_fields_end
struct list_head tasks; // linkage for global task list
randomized_struct_fields_end
int stuck1, stuck2;
};