From owner-svn-src-all@FreeBSD.ORG Sat Apr 25 08:47:43 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E7BB1A4F; Sat, 25 Apr 2015 08:47:42 +0000 (UTC) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 93D6A163C; Sat, 25 Apr 2015 08:47:42 +0000 (UTC) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id E33DE428126; Sat, 25 Apr 2015 18:47:33 +1000 (AEST) Date: Sat, 25 Apr 2015 18:47:32 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Garrett Cooper cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r281966 - head/contrib/netbsd-tests/lib/libpthread In-Reply-To: <201504250430.t3P4U1FR044477@svn.freebsd.org> Message-ID: <20150425175312.T972@besplex.bde.org> References: <201504250430.t3P4U1FR044477@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=A5NVYcmG c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=Gkr5MAAsbZnOi7l2F54A:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Apr 2015 08:47:43 -0000 On Sat, 25 Apr 2015, Garrett Cooper wrote: > Log: > Add #include sys/types.h for register_t for mips Why not fix mips? > Modified: head/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c > ============================================================================== > --- head/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c Sat Apr 25 01:29:40 2015 (r281965) > +++ head/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c Sat Apr 25 04:30:01 2015 (r281966) > @@ -28,6 +28,9 @@ > #include > __RCSID("$NetBSD"); > > +#ifdef __FreeBSD__ > +#include > +#endif > #include > #include > #include The test detected that ucontext.h is broken on mips, but was shot instead of mips. has massive namespace pollution, but not enough to declare register_t. /usr/include/ucontext.h has its own namespace pollution, and it includes machine/ucontext.h which has massively more on some arches. i386/include/ucontext.h used to be careful about this. It used the basic type corresponding to register_t (int) to avoid any dependencies. amd64/include/ucontext.h was and is not so careful. It used and uses __register_t, so it depends on or though not on . i386 ucontext.h has been unimproved by merging with amd64. Now the basic type cannot be used, since register_t is MD and in fact varies between i386 and amd64. i386 ucontext.h uses __register_t even its own compatibility part that cannot be merged. mips is not careful about this. Its ucontext.h uses register_t. Its ucontext.h has many even larger bugs. The non-broken MD ucontext.h's don't include any _types.h file to get __register_t defined, but that is correct since it is an error to include directly except possibly in the kernel. Applications must include Nearby namespace pollution: only uc_* and ss_* are reserved in POSIX , at least in old versions, but FreeBSD has the following: - some at the . See the enclosed patch which does't really fix it. - arm: seems to be perfectly correct. It uses underscores a lot. It is just ugly to use "unsigned int" instead of something shorter. The BSD spelling u_int cannot be used in standard user headers since it would be namespace pollution. __register_t isn't really right on i386 or amd64, since this is one of the few places where unsigned types should be used. Using plain int for __register_t is just an old bug in i386 (from 386BSD?) copied to amd64. - arm64: very broken. It never uses underscores, so pollutes the following the following namespaces: gp*, gp*, mc_*. It also uses u_int, uint32_t and uint64_t. Better yet, it uses the long long abomination instead of uint64_t in some places. - mips: mc_*, sr (a field in struct __mcontext that doesn't even have an mc_ prefix), mullo, mulhi (like sr), register_t, f_register_t, int32_t, uint32_t, mcontext32_t (only mcontext_t is allowed (and required, but pollution in the mc* namespace is limited), SZREG, UCTX_REG(), UCR_*. - powerpc: mc_*, uint32_t, register_t, uint64_t (POSIX allows foo_t to be declared, but only a low quality implementation would declare it). - sparc64: uint64_t, mc_* - x86: mc_*. As well as __register_t, x86 is careful to use __uintN_t instead of uintN_t. Old changes to document and partially reduce the pollution at the top level: X Index: ucontext.h X =================================================================== X RCS file: /home/ncvs/src/sys/sys/ucontext.h,v X retrieving revision 1.11 X diff -u -2 -r1.11 ucontext.h X --- ucontext.h 9 Nov 2003 20:31:04 -0000 1.11 X +++ ucontext.h 10 Nov 2003 09:38:33 -0000 X @@ -32,5 +32,11 @@ X #define _SYS_UCONTEXT_H_ X X +#ifdef _KERNEL X +#include X +#else X +/* XXX need stack_t as well as sigset_t. */ X #include X +#endif X + X #include X POSIX requires stack_t, and in old versions didn't alow anything else from . Newer versions of POSIX tend to break things like this by allowing but not requiring all the symbols in a header like X @@ -50,6 +56,7 @@ X stack_t uc_stack; X int uc_flags; X +/* XXX namespace pollution. */ X #define UCF_SWAPPED 0x00000001 /* Used by swapcontext(3). */ X - int __spare__[4]; X + int uc_spare[4]; X } ucontext_t; X Names like UCF_SWAPPED bogotify more careful naming for _MC*. So do names the mc_*. All the underscores for __spare__ are bogus, and without a uc_ prefix it isn't clear what this field is spare for. X @@ -61,27 +68,22 @@ X struct ucontext4 *uc_link; X stack_t uc_stack; X - int __spare__[8]; X + int uc_spare[8]; X }; X -#else /* __i386__ || __alpha__ */ X +#else /* __i386__ || __alpha__ */ X #define ucontext4 ucontext X -#endif /* __i386__ || __alpha__ */ X -#endif /* _KERNEL */ X +#endif /* __i386__ || __alpha__ */ X +#endif /* _KERNEL */ X X #ifndef _KERNEL X - X __BEGIN_DECLS X - X int getcontext(ucontext_t *); X -int setcontext(const ucontext_t *); X void makecontext(ucontext_t *, void (*)(void), int, ...); X -int signalcontext(ucontext_t *, int, __sighandler_t *); X +int setcontext(const ucontext_t *); X +int signalcontext(ucontext_t *, int, void (*)(int)); X int swapcontext(ucontext_t *, const ucontext_t *); X - X __END_DECLS X X #else /* _KERNEL */ X X -struct thread; X - X /* X * Flags for get_mcontext(). The low order 4 bits (i.e a mask of 0x0f) are X @@ -91,8 +93,8 @@ X #define GET_MC_CLEAR_RET 1 X X -/* Machine-dependent functions: */ X +struct thread; X + X int get_mcontext(struct thread *, mcontext_t *, int); X int set_mcontext(struct thread *, const mcontext_t *); X - X #endif /* !_KERNEL */ X Bruce