array: fix a crash in array_create if memory allocation failed and had to
[ajla.git] / task.h
blob7502482da07a66d206c9c63587d948ffcd1f7fd0
1 /*
2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
19 #ifndef AJLA_TASK_H
20 #define AJLA_TASK_H
22 #include "data.h"
24 #define task_submit name(task_submit)
25 #define task_schedule name(task_schedule)
26 #define task_ex_control_started name(task_ex_control_started)
27 #define task_ex_control_exited name(task_ex_control_exited)
28 #define task_program_started name(task_program_started)
29 #define task_program_exited name(task_program_exited)
30 #define waiting_list_add name(waiting_list_add)
31 #define waiting_list_remove name(waiting_list_remove)
32 #define waiting_list_break name(waiting_list_break)
34 extern uint32_t nr_cpus_override;
36 void attr_fastcall task_submit(struct execution_control *ex, bool can_allocate_memory);
38 void * attr_fastcall task_schedule(struct execution_control *ex);
40 void waiting_list_add(struct execution_control *ex);
41 void waiting_list_remove(struct execution_control *ex);
42 bool waiting_list_break(void);
44 #define SUBMIT_EX(ex) \
45 do { \
46 if ((ex) != POINTER_FOLLOW_THUNK_EXIT) { \
47 task_submit(ex, true); \
48 } \
49 } while (0)
51 void task_ex_control_started(void);
52 void task_ex_control_exited(void);
53 void task_program_started(void);
54 void task_program_exited(void);
56 #endif