Skip to content

Commit 24cb36a

Browse files
pm215Riku Voipio
authored and
Riku Voipio
committed
configure: Make NPTL non-optional
Now all linux-user targets support building with NPTL, we can make it mandatory. This is a good idea because: * NPTL is no longer new and experimental; it is completely standard * in practice, linux-user without NPTL is nearly useless for binaries built against non-ancient glibc * it allows us to delete the rather untested code for handling the non-NPTL configuration Note that this patch leaves the CONFIG_USE_NPTL ifdefs in the bsd-user codebase alone. This makes no change for bsd-user, since our configure test for NPTL had a "#include <linux/futex.h>" which means bsd-user would never have been compiled with CONFIG_USE_NPTL defined, and it still is not. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Riku Voipio <[email protected]>
1 parent 2667e71 commit 24cb36a

File tree

6 files changed

+5
-133
lines changed

6 files changed

+5
-133
lines changed

configure

+3-22
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ curl=""
155155
curses=""
156156
docs=""
157157
fdt=""
158-
nptl=""
159158
pixman=""
160159
sdl=""
161160
virtfs=""
@@ -855,10 +854,6 @@ for opt do
855854
;;
856855
--enable-fdt) fdt="yes"
857856
;;
858-
--disable-nptl) nptl="no"
859-
;;
860-
--enable-nptl) nptl="yes"
861-
;;
862857
--enable-mixemu) mixemu="yes"
863858
;;
864859
--disable-linux-aio) linux_aio="no"
@@ -1096,8 +1091,6 @@ echo " --disable-slirp disable SLIRP userspace network connectivity"
10961091
echo " --disable-kvm disable KVM acceleration support"
10971092
echo " --enable-kvm enable KVM acceleration support"
10981093
echo " --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1099-
echo " --disable-nptl disable usermode NPTL support"
1100-
echo " --enable-nptl enable usermode NPTL support"
11011094
echo " --enable-system enable all system emulation targets"
11021095
echo " --disable-system disable all system emulation targets"
11031096
echo " --enable-user enable supported user emulation targets"
@@ -1432,7 +1425,7 @@ fi
14321425
##########################################
14331426
# NPTL probe
14341427

1435-
if test "$nptl" != "no" ; then
1428+
if test "$linux_user" = "yes"; then
14361429
cat > $TMPC <<EOF
14371430
#include <sched.h>
14381431
#include <linux/futex.h>
@@ -1443,14 +1436,8 @@ int main(void) {
14431436
return 0;
14441437
}
14451438
EOF
1446-
1447-
if compile_object ; then
1448-
nptl=yes
1449-
else
1450-
if test "$nptl" = "yes" ; then
1451-
feature_not_found "nptl"
1452-
fi
1453-
nptl=no
1439+
if ! compile_object ; then
1440+
feature_not_found "nptl"
14541441
fi
14551442
fi
14561443

@@ -3550,7 +3537,6 @@ echo "bluez support $bluez"
35503537
echo "Documentation $docs"
35513538
[ ! -z "$uname_release" ] && \
35523539
echo "uname -r $uname_release"
3553-
echo "NPTL support $nptl"
35543540
echo "GUEST_BASE $guest_base"
35553541
echo "PIE $pie"
35563542
echo "vde support $vde"
@@ -4180,7 +4166,6 @@ mkdir -p $target_dir
41804166
echo "# Automatically generated by configure - do not modify" > $config_target_mak
41814167

41824168
bflt="no"
4183-
target_nptl="yes"
41844169
interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
41854170
gdb_xml_files=""
41864171

@@ -4351,10 +4336,6 @@ fi
43514336
if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
43524337
echo "TARGET_HAS_BFLT=y" >> $config_target_mak
43534338
fi
4354-
if test "$target_user_only" = "yes" \
4355-
-a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
4356-
echo "CONFIG_USE_NPTL=y" >> $config_target_mak
4357-
fi
43584339
if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
43594340
echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
43604341
fi

include/exec/gdbstub.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void gdb_register_coprocessor(CPUArchState *env,
3232

3333
static inline int cpu_index(CPUState *cpu)
3434
{
35-
#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL)
35+
#if defined(CONFIG_USER_ONLY)
3636
return cpu->host_tid;
3737
#else
3838
return cpu->cpu_index + 1;

linux-user/main.c

-43
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ int cpu_get_pic_interrupt(CPUX86State *env)
9292
}
9393
#endif
9494

95-
#if defined(CONFIG_USE_NPTL)
9695
/***********************************************************/
9796
/* Helper routines for implementing atomic operations. */
9897

@@ -207,43 +206,6 @@ void cpu_list_unlock(void)
207206
{
208207
pthread_mutex_unlock(&cpu_list_mutex);
209208
}
210-
#else /* if !CONFIG_USE_NPTL */
211-
/* These are no-ops because we are not threadsafe. */
212-
static inline void cpu_exec_start(CPUState *cpu)
213-
{
214-
}
215-
216-
static inline void cpu_exec_end(CPUState *cpu)
217-
{
218-
}
219-
220-
static inline void start_exclusive(void)
221-
{
222-
}
223-
224-
static inline void end_exclusive(void)
225-
{
226-
}
227-
228-
void fork_start(void)
229-
{
230-
}
231-
232-
void fork_end(int child)
233-
{
234-
if (child) {
235-
gdbserver_fork((CPUArchState *)thread_cpu->env_ptr);
236-
}
237-
}
238-
239-
void cpu_list_lock(void)
240-
{
241-
}
242-
243-
void cpu_list_unlock(void)
244-
{
245-
}
246-
#endif
247209

248210

249211
#ifdef TARGET_I386
@@ -3156,12 +3118,7 @@ THREAD CPUState *thread_cpu;
31563118
void task_settid(TaskState *ts)
31573119
{
31583120
if (ts->ts_tid == 0) {
3159-
#ifdef CONFIG_USE_NPTL
31603121
ts->ts_tid = (pid_t)syscall(SYS_gettid);
3161-
#else
3162-
/* when no threads are used, tid becomes pid */
3163-
ts->ts_tid = getpid();
3164-
#endif
31653122
}
31663123
}
31673124

linux-user/mmap.c

-11
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
//#define DEBUG_MMAP
3535

36-
#if defined(CONFIG_USE_NPTL)
3736
static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER;
3837
static __thread int mmap_lock_count;
3938

@@ -66,16 +65,6 @@ void mmap_fork_end(int child)
6665
else
6766
pthread_mutex_unlock(&mmap_mutex);
6867
}
69-
#else
70-
/* We aren't threadsafe to start with, so no need to worry about locking. */
71-
void mmap_lock(void)
72-
{
73-
}
74-
75-
void mmap_unlock(void)
76-
{
77-
}
78-
#endif
7968

8069
/* NOTE: all the constants are the HOST ones, but addresses are target. */
8170
int target_mprotect(abi_ulong start, abi_ulong len, int prot)

linux-user/qemu.h

-10
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
#include "exec/gdbstub.h"
2020
#include "qemu/queue.h"
2121

22-
#if defined(CONFIG_USE_NPTL)
2322
#define THREAD __thread
24-
#else
25-
#define THREAD
26-
#endif
2723

2824
/* This struct is used to hold certain information about the image.
2925
* Basically, it replicates in user space what would be certain
@@ -116,9 +112,7 @@ typedef struct TaskState {
116112
uint32_t v86flags;
117113
uint32_t v86mask;
118114
#endif
119-
#ifdef CONFIG_USE_NPTL
120115
abi_ulong child_tidptr;
121-
#endif
122116
#ifdef TARGET_M68K
123117
int sim_syscalls;
124118
abi_ulong tp_value;
@@ -268,10 +262,8 @@ void mmap_unlock(void);
268262
abi_ulong mmap_find_vma(abi_ulong, abi_ulong);
269263
void cpu_list_lock(void);
270264
void cpu_list_unlock(void);
271-
#if defined(CONFIG_USE_NPTL)
272265
void mmap_fork_start(void);
273266
void mmap_fork_end(int child);
274-
#endif
275267

276268
/* main.c */
277269
extern unsigned long guest_stack_size;
@@ -449,9 +441,7 @@ static inline void *lock_user_string(abi_ulong guest_addr)
449441
#define unlock_user_struct(host_ptr, guest_addr, copy) \
450442
unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0)
451443

452-
#if defined(CONFIG_USE_NPTL)
453444
#include <pthread.h>
454-
#endif
455445

456446
/* Include target-specific struct and function definitions;
457447
* they may need access to the target-independent structures

linux-user/syscall.c

+1-46
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,8 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
111111

112112
#include "qemu.h"
113113

114-
#if defined(CONFIG_USE_NPTL)
115114
#define CLONE_NPTL_FLAGS2 (CLONE_SETTLS | \
116115
CLONE_PARENT_SETTID | CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)
117-
#else
118-
/* XXX: Hardcode the above values. */
119-
#define CLONE_NPTL_FLAGS2 0
120-
#endif
121116

122117
//#define DEBUG
123118

@@ -234,12 +229,10 @@ _syscall1(int,exit_group,int,error_code)
234229
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
235230
_syscall1(int,set_tid_address,int *,tidptr)
236231
#endif
237-
#if defined(CONFIG_USE_NPTL)
238232
#if defined(TARGET_NR_futex) && defined(__NR_futex)
239233
_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
240234
const struct timespec *,timeout,int *,uaddr2,int,val3)
241235
#endif
242-
#endif
243236
#define __NR_sys_sched_getaffinity __NR_sched_getaffinity
244237
_syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
245238
unsigned long *, user_mask_ptr);
@@ -4227,7 +4220,6 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
42274220

42284221
#define NEW_STACK_SIZE 0x40000
42294222

4230-
#if defined(CONFIG_USE_NPTL)
42314223

42324224
static pthread_mutex_t clone_lock = PTHREAD_MUTEX_INITIALIZER;
42334225
typedef struct {
@@ -4272,16 +4264,6 @@ static void *clone_func(void *arg)
42724264
/* never exits */
42734265
return NULL;
42744266
}
4275-
#else
4276-
4277-
static int clone_func(void *arg)
4278-
{
4279-
CPUArchState *env = arg;
4280-
cpu_loop(env);
4281-
/* never exits */
4282-
return 0;
4283-
}
4284-
#endif
42854267

42864268
/* do_fork() Must return host values and target errnos (unlike most
42874269
do_*() functions). */
@@ -4292,23 +4274,18 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
42924274
int ret;
42934275
TaskState *ts;
42944276
CPUArchState *new_env;
4295-
#if defined(CONFIG_USE_NPTL)
42964277
unsigned int nptl_flags;
42974278
sigset_t sigmask;
4298-
#else
4299-
uint8_t *new_stack;
4300-
#endif
43014279

43024280
/* Emulate vfork() with fork() */
43034281
if (flags & CLONE_VFORK)
43044282
flags &= ~(CLONE_VFORK | CLONE_VM);
43054283

43064284
if (flags & CLONE_VM) {
43074285
TaskState *parent_ts = (TaskState *)env->opaque;
4308-
#if defined(CONFIG_USE_NPTL)
43094286
new_thread_info info;
43104287
pthread_attr_t attr;
4311-
#endif
4288+
43124289
ts = g_malloc0(sizeof(TaskState));
43134290
init_task_state(ts);
43144291
/* we create a new CPU instance. */
@@ -4321,7 +4298,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
43214298
new_env->opaque = ts;
43224299
ts->bprm = parent_ts->bprm;
43234300
ts->info = parent_ts->info;
4324-
#if defined(CONFIG_USE_NPTL)
43254301
nptl_flags = flags;
43264302
flags &= ~CLONE_NPTL_FLAGS2;
43274303

@@ -4371,17 +4347,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
43714347
pthread_cond_destroy(&info.cond);
43724348
pthread_mutex_destroy(&info.mutex);
43734349
pthread_mutex_unlock(&clone_lock);
4374-
#else
4375-
if (flags & CLONE_NPTL_FLAGS2)
4376-
return -EINVAL;
4377-
/* This is probably going to die very quickly, but do it anyway. */
4378-
new_stack = g_malloc0 (NEW_STACK_SIZE);
4379-
#ifdef __ia64__
4380-
ret = __clone2(clone_func, new_stack, NEW_STACK_SIZE, flags, new_env);
4381-
#else
4382-
ret = clone(clone_func, new_stack + NEW_STACK_SIZE, flags, new_env);
4383-
#endif
4384-
#endif
43854350
} else {
43864351
/* if no CLONE_VM, we consider it is a fork */
43874352
if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0)
@@ -4392,7 +4357,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
43924357
/* Child Process. */
43934358
cpu_clone_regs(env, newsp);
43944359
fork_end(1);
4395-
#if defined(CONFIG_USE_NPTL)
43964360
/* There is a race condition here. The parent process could
43974361
theoretically read the TID in the child process before the child
43984362
tid is set. This would require using either ptrace
@@ -4408,7 +4372,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
44084372
cpu_set_tls (env, newtls);
44094373
if (flags & CLONE_CHILD_CLEARTID)
44104374
ts->child_tidptr = child_tidptr;
4411-
#endif
44124375
} else {
44134376
fork_end(0);
44144377
}
@@ -4834,7 +4797,6 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
48344797
}
48354798
#endif
48364799

4837-
#if defined(CONFIG_USE_NPTL)
48384800
/* ??? Using host futex calls even when target atomic operations
48394801
are not really atomic probably breaks things. However implementing
48404802
futexes locally would make futexes shared between multiple processes
@@ -4886,7 +4848,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
48864848
return -TARGET_ENOSYS;
48874849
}
48884850
}
4889-
#endif
48904851

48914852
/* Map host to target signal numbers for the wait family of syscalls.
48924853
Assume all other status bits are the same. */
@@ -5132,9 +5093,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
51325093
abi_long arg5, abi_long arg6, abi_long arg7,
51335094
abi_long arg8)
51345095
{
5135-
#ifdef CONFIG_USE_NPTL
51365096
CPUState *cpu = ENV_GET_CPU(cpu_env);
5137-
#endif
51385097
abi_long ret;
51395098
struct stat st;
51405099
struct statfs stfs;
@@ -5148,7 +5107,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
51485107

51495108
switch(num) {
51505109
case TARGET_NR_exit:
5151-
#ifdef CONFIG_USE_NPTL
51525110
/* In old applications this may be used to implement _exit(2).
51535111
However in threaded applictions it is used for thread termination,
51545112
and _exit_group is used for application termination.
@@ -5186,7 +5144,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
51865144
g_free(ts);
51875145
pthread_exit(NULL);
51885146
}
5189-
#endif
51905147
#ifdef TARGET_GPROF
51915148
_mcleanup();
51925149
#endif
@@ -8687,11 +8644,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
86878644
}
86888645
break;
86898646
#endif
8690-
#if defined(CONFIG_USE_NPTL)
86918647
case TARGET_NR_futex:
86928648
ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
86938649
break;
8694-
#endif
86958650
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
86968651
case TARGET_NR_inotify_init:
86978652
ret = get_errno(sys_inotify_init());

0 commit comments

Comments
 (0)