public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: <libc-ports@sourceware.org>, Chung-Lin Tang <cltang@codesourcery.com>
Subject: Re: [PATCH 2/2] MIPS16: MIPS16 support proper
Date: Wed, 23 Jan 2013 17:22:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1301231706590.7102@digraph.polyomino.org.uk> (raw)
In-Reply-To: <alpine.DEB.1.10.1301230317220.4834@tp.orcam.me.uk>

On Wed, 23 Jan 2013, Maciej W. Rozycki wrote:

> Index: ports/sysdeps/mips/__longjmp.c
> ===================================================================
> --- ports/sysdeps/mips/__longjmp.c	2013-01-17 00:55:17.000000000 +0000
> +++ ports/sysdeps/mips/__longjmp.c	2013-01-20 19:40:57.097753716 +0000
> @@ -23,8 +23,8 @@
>    #error This file uses GNU C extensions; you must compile with GCC.
>  #endif
>  
> -void
> -__longjmp (env_arg, val_arg)
> +static void __attribute__ ((nomips16))
> +____longjmp (env_arg, val_arg)
>       __jmp_buf env_arg;
>       int val_arg;
>  {
> @@ -86,3 +86,5 @@ __longjmp (env_arg, val_arg)
>    /* Avoid `volatile function does return' warnings.  */
>    for (;;);
>  }
> +
> +strong_alias (____longjmp, __longjmp);

Why is the renaming / alias needed?

> Index: ports/sysdeps/mips/abort-instr.h
> ===================================================================
> --- ports/sysdeps/mips/abort-instr.h	2013-01-17 00:55:17.000000000 +0000
> +++ ports/sysdeps/mips/abort-instr.h	2013-01-20 19:40:57.097753716 +0000
> @@ -1,2 +1,6 @@
>  /* An instruction which should crash any program is a breakpoint.  */
> +#ifdef __mips16
> +#define ABORT_INSTRUCTION asm ("break 63")
> +#else
>  #define ABORT_INSTRUCTION asm ("break 255")
> +#endif

Indentation inside #if, "# define".

> +/* MIPS16 uses GCC __sync_* builtins to implement the required atomic
> +   operations, to abstract out the unsupported assembly instructions.
> +   ??? Maybe eventually use them for 32-bit MIPS too?  */
> +#ifdef __mips16
> +# if __GNUC_PREREQ (4, 1)

glibc requires at least 4.3 to build, so no such condition is needed in an 
internal header.

However, __sync_* are obsolete; the __atomic_* built-in functions 
(supported in 4.7 and later, well-optimized for MIPS in 4.8 and later) are 
preferred because they allow more precise specification of the barrier 
semantics in particular cases.  So if building with 4.8 or later, you 
should use the existing definitions in terms of __atomic_* that are 
already used in those circumstances for MIPS - and probably use them for 
the (4.7 and MIPS16) combination, since they won't be any worse than 
__sync_*.  Fallbacks using __sync_* should only be for the (older GCC, 
MIPS16) combination.  So the logic in the file should be:

#if (4.8 or later, or 4.7 and MIPS16)
existing implementation using __atomic_*
#elif (MIPS16)
implementation using __sync_*, for older GCC and MIPS16
#else
existing implementation using inline asm
#endif

> +#else
> +
> +/* MIPS16 version.  We currently only support O32 under MIPS16; the proper
> +   assembly preprocessor abstractions will need to be added if other ABIs
> +   are to be supported.  */
> +
> +#define RTLD_START asm (\

Indentation, "# define".  Many further cases in this patch as well, not 
individually pointed out.

>  /* Macros for accessing the hardware control word.  */
> +extern fpu_control_t __fpu_getcw (void) __THROW;
> +extern void __fpu_setcw (fpu_control_t) __THROW;
> +#ifdef __mips16
> +#define _FPU_GETCW(cw) do { (cw) = __fpu_getcw (); } while (0)
> +#define _FPU_SETCW(cw) __fpu_setcw (cw)
> +#else
>  #define _FPU_GETCW(cw) __asm__ volatile ("cfc1 %0,$31" : "=r" (cw))
>  #define _FPU_SETCW(cw) __asm__ volatile ("ctc1 %0,$31" : : "r" (cw))
> +#endif

Names __mips_fpu_getcw and __mips_fpu_setcw might reduce any risk of 
conflicts with any future architecture-independent internal function?

> +  _FPU_GETCW(cw);

> +  _FPU_SETCW(cw);

Missing space before '('.

> Index: ports/sysdeps/mips/mips32/mips16/fpu/Versions
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ports/sysdeps/mips/mips32/mips16/fpu/Versions	2013-01-20 22:11:01.057025227 +0000
> @@ -0,0 +1,5 @@
> +libc {
> +  GLIBC_2.18 {
> +    __fpu_getcw; __fpu_getcw;
> +  }
> +}

The public ABI exported by glibc should not depend on whether glibc itself 
was built as MIPS16; remember that these functions will be needed by 
MIPS16 code linked with a MIPS32 glibc.  So this Versions file should not 
be in a mips16 sysdeps directory.

> Index: ports/sysdeps/mips/sys/tas.h
> ===================================================================
> --- ports/sysdeps/mips/sys/tas.h	2013-01-17 00:55:17.000000000 +0000
> +++ ports/sysdeps/mips/sys/tas.h	2013-01-20 19:40:57.376549265 +0000
> @@ -24,7 +24,7 @@
>  
>  __BEGIN_DECLS
>  
> -extern int _test_and_set (int *__p, int __v) __THROW;
> +extern int __attribute__((nomips16)) test_and_set (int *__p, int __v) __THROW;
>  
>  #ifdef __USE_EXTERN_INLINES
>  
> @@ -32,7 +32,7 @@ extern int _test_and_set (int *__p, int 
>  #  define _EXTERN_INLINE __extern_inline
>  # endif
>  
> -_EXTERN_INLINE int
> +_EXTERN_INLINE int __attribute__((nomips16))
>  __NTH (_test_and_set (int *__p, int __v))
>  {
>    int __r, __t;

This is an installed header, so you need to use __nomips16__ rather than 
just plain nomips16.

> Index: ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h	2013-01-20 19:40:57.546859991 +0000
> @@ -0,0 +1,91 @@
> +/* MIPS16 syscall wrappers.
> +   Copyright (C) 2013 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +   Contributed by Maciej W. Rozycki <macro@codesourcery.com>.

We don't put "Contributed by" lines in new files in glibc.

> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, write to the Free
> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> +   02111-1307 USA.  */

All files in glibc should now use a URL instead of an FSF postal address.

These points apply similarly to other new files.

Please send a revised patch for review.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2013-01-23 17:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23  4:41 [PATCH 0/2] MIPS16: MIPS16 support Maciej W. Rozycki
2013-01-23  4:41 ` [PATCH 1/2] MIPS16: Allocate GLIBC_2.18 Maciej W. Rozycki
2013-01-23  4:42 ` [PATCH 2/2] MIPS16: MIPS16 support proper Maciej W. Rozycki
2013-01-23 17:22   ` Joseph S. Myers [this message]
2013-01-24 10:10     ` Chung-Lin Tang
2013-01-24 13:13       ` Maciej W. Rozycki
2013-01-24 13:56         ` Richard Sandiford
2013-02-20 16:19     ` [PATCH v2] MIPS: MIPS16 support Maciej W. Rozycki
2013-02-20 16:29       ` Joseph S. Myers
2013-02-27  1:38         ` [PATCH v3] " Maciej W. Rozycki
2013-02-27 17:50           ` Joseph S. Myers
2013-02-27 23:54             ` Maciej W. Rozycki
2013-01-24 18:08   ` [PATCH 2/2] MIPS16: MIPS16 support proper Ellcey, Steve
2013-01-25  5:14     ` Maciej W. Rozycki
2013-01-25 13:59       ` Richard Sandiford
2013-01-28 22:18         ` Steve Ellcey
2013-01-25 22:10       ` Steve Ellcey
2013-01-26  0:32         ` Maciej W. Rozycki
2013-01-28 17:36           ` Steve Ellcey
2013-01-28 17:56             ` Steve Ellcey
2013-01-28 21:08               ` Maciej W. Rozycki
2013-01-28 18:58             ` Richard Henderson
2013-01-28 21:06               ` Maciej W. Rozycki
2013-01-28 21:17                 ` Steve Ellcey
2013-01-29 16:24                   ` Richard Henderson
2013-01-29 19:27                     ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1301231706590.7102@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=libc-ports@sourceware.org \
    --cc=macro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).