kernel: don't use typedef for enums or non-opaque structs
This commit is contained in:
@@ -15,91 +15,91 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum task_state {
|
||||
enum task_state {
|
||||
TASK_RUNNING,
|
||||
TASK_STOPPED,
|
||||
} task_state_t;
|
||||
};
|
||||
|
||||
typedef enum thread_state {
|
||||
enum thread_state {
|
||||
THREAD_READY = 1,
|
||||
THREAD_SLEEPING = 2,
|
||||
THREAD_STOPPED = 3,
|
||||
} thread_state_t;
|
||||
};
|
||||
|
||||
typedef enum thread_flags {
|
||||
enum thread_flags {
|
||||
THREAD_F_NEED_RESCHED = 0x01u,
|
||||
THREAD_F_NO_PREEMPT = 0x02u,
|
||||
} thread_flags_t;
|
||||
};
|
||||
|
||||
typedef enum sched_priority {
|
||||
PRIO_IDLE = 4,
|
||||
PRIO_SUBNORMAL = 6,
|
||||
PRIO_NORMAL = 10,
|
||||
PRIO_SUPERNORMAL = 14,
|
||||
PRIO_HIGH = 18,
|
||||
PRIO_REALTIME = 24,
|
||||
} sched_priority_t;
|
||||
enum sched_priority {
|
||||
PRIO_IDLE = 4,
|
||||
PRIO_SUBNORMAL = 6,
|
||||
PRIO_NORMAL = 10,
|
||||
PRIO_SUPERNORMAL = 14,
|
||||
PRIO_HIGH = 18,
|
||||
PRIO_REALTIME = 24,
|
||||
};
|
||||
|
||||
typedef struct task {
|
||||
struct task {
|
||||
struct task *t_parent;
|
||||
unsigned int t_id;
|
||||
task_state_t t_state;
|
||||
enum task_state t_state;
|
||||
char t_name[TASK_NAME_MAX];
|
||||
|
||||
pmap_t t_pmap;
|
||||
|
||||
btree_node_t t_tasklist;
|
||||
queue_t t_threads;
|
||||
queue_t t_children;
|
||||
} task_t;
|
||||
struct btree_node t_tasklist;
|
||||
struct queue t_threads;
|
||||
struct queue t_children;
|
||||
};
|
||||
|
||||
typedef struct thread {
|
||||
thread_state_t tr_state : 8;
|
||||
thread_flags_t tr_flags : 8;
|
||||
task_t *tr_parent;
|
||||
struct thread {
|
||||
enum thread_state tr_state : 8;
|
||||
enum thread_flags tr_flags : 8;
|
||||
struct task *tr_parent;
|
||||
|
||||
unsigned int tr_id;
|
||||
unsigned int tr_prio;
|
||||
|
||||
queue_entry_t tr_threads;
|
||||
queue_entry_t tr_rqentry;
|
||||
struct queue_entry tr_threads;
|
||||
struct queue_entry tr_rqentry;
|
||||
void *tr_kstack;
|
||||
} thread_t;
|
||||
};
|
||||
|
||||
typedef struct runqueue {
|
||||
queue_t rq_queues[PRIO_MAX];
|
||||
struct runqueue {
|
||||
struct queue rq_queues[PRIO_MAX];
|
||||
uint32_t rq_readybits;
|
||||
spin_lock_t rq_lock;
|
||||
} runqueue_t;
|
||||
};
|
||||
|
||||
extern kern_status_t sched_init(void);
|
||||
extern void schedule(void);
|
||||
extern void preempt_disable(void);
|
||||
extern void preempt_enable(void);
|
||||
|
||||
extern void runqueue_init(runqueue_t *rq);
|
||||
extern void runqueue_init(struct runqueue *rq);
|
||||
|
||||
extern task_t *task_alloc(void);
|
||||
static inline task_t *task_ref(task_t *task) { return (task_t *)object_data(object_ref(object_header(task))); }
|
||||
static inline void task_deref(task_t *task) { object_deref(object_header(task)); }
|
||||
extern task_t *task_from_pid(unsigned int pid);
|
||||
extern task_t *kernel_task(void);
|
||||
extern struct task *task_alloc(void);
|
||||
static inline struct task *task_ref(struct task *task) { return (struct task *)object_data(object_ref(object_header(task))); }
|
||||
static inline void task_deref(struct task *task) { object_deref(object_header(task)); }
|
||||
extern struct task *task_from_pid(unsigned int pid);
|
||||
extern struct task *kernel_task(void);
|
||||
|
||||
extern bool need_resched(void);
|
||||
extern task_t *current_task(void);
|
||||
extern thread_t *current_thread(void);
|
||||
extern struct task *current_task(void);
|
||||
extern struct thread *current_thread(void);
|
||||
|
||||
static inline void task_lock_irqsave(task_t *task, unsigned long *flags)
|
||||
static inline void task_lock_irqsave(struct task *task, unsigned long *flags)
|
||||
{
|
||||
object_lock(object_header(task), flags);
|
||||
}
|
||||
|
||||
static inline void task_unlock_irqrestore(task_t *task, unsigned long flags)
|
||||
static inline void task_unlock_irqrestore(struct task *task, unsigned long flags)
|
||||
{
|
||||
object_unlock(object_header(task), flags);
|
||||
}
|
||||
|
||||
extern thread_t *thread_alloc(void);
|
||||
extern struct thread *thread_alloc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user