summaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-06-24 23:50:24 +0200
committerAndreas Färber <afaerber@suse.de>2013-09-03 12:25:55 +0200
commitbdc44640cb33c90809376a262df871a1144d339a (patch)
treeef3b8d1d6a389d85baeb0cee895471b634a2fc3b /linux-user/main.c
parent27013bf20d5d93ac75d398aa3608604e8ad91b5a (diff)
downloadqemu-bdc44640cb33c90809376a262df871a1144d339a.tar.gz
cpu: Use QTAILQ for CPU list
Introduce CPU_FOREACH(), CPU_FOREACH_SAFE() and CPU_NEXT() shorthand macros. Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 03859bcc23..5c2f7b26b4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -117,10 +117,14 @@ void fork_end(int child)
{
mmap_fork_end(child);
if (child) {
+ CPUState *cpu, *next_cpu;
/* Child processes created by fork() only have a single thread.
Discard information about the parent threads. */
- first_cpu = thread_cpu;
- first_cpu->next_cpu = NULL;
+ CPU_FOREACH_SAFE(cpu, next_cpu) {
+ if (cpu != thread_cpu) {
+ QTAILQ_REMOVE(&cpus, thread_cpu, node);
+ }
+ }
pending_cpus = 0;
pthread_mutex_init(&exclusive_lock, NULL);
pthread_mutex_init(&cpu_list_mutex, NULL);
@@ -154,7 +158,7 @@ static inline void start_exclusive(void)
pending_cpus = 1;
/* Make all other cpus stop executing. */
- for (other_cpu = first_cpu; other_cpu; other_cpu = other_cpu->next_cpu) {
+ CPU_FOREACH(other_cpu) {
if (other_cpu->running) {
pending_cpus++;
cpu_exit(other_cpu);