This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: MIPS header file question
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Steve Ellcey <sellcey at mips dot com>
- Cc: <libc-alpha at sourceware dot org>, Richard Sandiford <rdsandiford at googlemail dot com>, Ralf Baechle <ralf at linux-mips dot org>
- Date: Wed, 7 May 2014 01:11:07 +0100
- Subject: Re: MIPS header file question
- Authentication-results: sourceware.org; auth=none
- References: <0ddee06f-81b5-4778-9d19-b37a9ec7f881 at BAMAIL02 dot ba dot imgtec dot org>
On Wed, 7 May 2014, Steve Ellcey wrote:
> I have a question about the MIPS sysdeps/mips/sys/asm.h file in glibc.
> It includes a bunch of macros for various assembly language instructions
> such as INT_ADD, LONG_ADD, PTR_ADD, etc. There are also *_SUB macros and
> some of these look very odd to me:
>
> % grep _SUB sysdeps/mips/sys/asm.h | grep add
> # define INT_SUB add
> # define INT_SUB dadd
> # define LONG_SUB add
> # define LONG_SUB dadd
> # define PTR_SUB add
> # define PTR_SUB add
> # define PTR_SUB dadd
>
> Why are some of the *_SUB macros defined to do an add instruction?
> There are other *_SUB macros (*_SUBU, *_SUBIU, *SUBI) that are defined
> to do sub[iu] instructions. Is there any reason for this or is this
> just a cut and paste error that has survived for a decade or so.
> It would not surprise me to learn that no one uses these macros.
It looks like a copy and paste error to me. These macros originate from
SGI documentation[1] and arrived in glibc via Linux, where they are also
provided, by <asm/asm.h>. These macros seem to have always been correct
in the kernel, and certainly were at the time our <sys/asm.h> stopped
merely including <asm/asm.h> from the kernel. Also SGI documentation has
no issues here. So I don't really understand where the mistakes came
from.
These macros do get used, although not exhaustively; certainly the
trapping versions are not as often used, if at all, as the non-trapping
ones. Still they're a part of the MIPS/Linux user API. You're welcome to
propose a fix.
References:
[1] "MIPSpro 64-Bit Porting and Transition Guide", Silicon Graphics, Inc.,
Document Number 007-2391-006
HTH,
Maciej