This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS header file question

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 

 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.


[1] "MIPSpro 64-Bit Porting and Transition Guide", Silicon Graphics, Inc.,
    Document Number 007-2391-006



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]