diff options
author | Andreas Färber <afaerber@suse.de> | 2013-06-24 23:50:24 +0200 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-09-03 12:25:55 +0200 |
commit | bdc44640cb33c90809376a262df871a1144d339a (patch) | |
tree | ef3b8d1d6a389d85baeb0cee895471b634a2fc3b /linux-user | |
parent | 27013bf20d5d93ac75d398aa3608604e8ad91b5a (diff) | |
download | qemu-bdc44640cb33c90809376a262df871a1144d339a.zip qemu-bdc44640cb33c90809376a262df871a1144d339a.tar.gz qemu-bdc44640cb33c90809376a262df871a1144d339a.tar.bz2 |
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')
-rw-r--r-- | linux-user/elfload.c | 2 | ||||
-rw-r--r-- | linux-user/main.c | 10 | ||||
-rw-r--r-- | linux-user/syscall.c | 17 |
3 files changed, 10 insertions, 19 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 7ce2eab..72d9270 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2668,7 +2668,7 @@ static int fill_note_info(struct elf_note_info *info, /* read and fill status of all threads */ cpu_list_lock(); - for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) { + CPU_FOREACH(cpu) { if (cpu == thread_cpu) { continue; } diff --git a/linux-user/main.c b/linux-user/main.c index 03859bc..5c2f7b2 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); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f986548..ecead51 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5113,25 +5113,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, Do thread termination if we have more then one thread. */ /* FIXME: This probably breaks if a signal arrives. We should probably be disabling signals. */ - if (first_cpu->next_cpu) { + if (CPU_NEXT(first_cpu)) { TaskState *ts; - CPUState **lastp; - CPUState *p; cpu_list_lock(); - lastp = &first_cpu; - p = first_cpu; - while (p && p != cpu) { - lastp = &p->next_cpu; - p = p->next_cpu; - } - /* If we didn't find the CPU for this thread then something is - horribly wrong. */ - if (!p) { - abort(); - } /* Remove the CPU from the list. */ - *lastp = p->next_cpu; + QTAILQ_REMOVE(&cpus, cpu, node); cpu_list_unlock(); ts = ((CPUArchState *)cpu_env)->opaque; if (ts->child_tidptr) { |