Back to index

glibc  2.9
bp-asm.h
Go to the documentation of this file.
00001 /* Bounded-pointer definitions for PowerPC64 assembler.
00002    Copyright (C) 2000, 2002 Free Software Foundation, Inc.
00003    Contributed by Greg McGary <greg@mcgary.org>
00004 
00005    This file is part of the GNU C Library.  Its master source is NOT part of
00006    the C library, however.  The master source lives in the GNU MP Library.
00007 
00008    The GNU C Library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public License as
00010    published by the Free Software Foundation; either version 2 of the
00011    License, or (at your option) any later version.
00012 
00013    The GNU C Library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public
00019    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00020    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021    Boston, MA 02111-1307, USA.  */
00022 
00023 #if __BOUNDED_POINTERS__
00024 
00025 /* Byte offsets of BP components.  */
00026 # define oVALUE      0
00027 # define oLOW 4
00028 # define oHIGH       8
00029 
00030 /* Don't check bounds, just convert the BP register to its simple
00031    pointer value.  */
00032 
00033 # define DISCARD_BOUNDS(rBP)                     \
00034        ld     rBP, oVALUE(rBP)
00035 
00036 /* Check low bound, with the side effect that the BP register is converted
00037    its simple pointer value.  Move the high bound into a register for
00038    later use.  */
00039 
00040 # define CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH)      \
00041        ld     rHIGH, oHIGH(rBP);          \
00042        ld     rLOW, oLOW(rBP);            \
00043        ld     rBP, oVALUE(rBP);           \
00044        tdllt  rBP, rLOW
00045 
00046 /* Check the high bound, which is in a register, using the given
00047    conditional trap instruction.  */
00048 
00049 # define CHECK_BOUNDS_HIGH(rVALUE, rHIGH, TWLcc) \
00050        TWLcc  rVALUE, rHIGH
00051 
00052 /* Check the high bound, which is stored at the return-value's high
00053    bound slot, using the given conditional trap instruction.  */
00054 
00055 # define CHECK_BOUNDS_HIGH_RTN(rVALUE, rHIGH, TWLcc)    \
00056        ld     rHIGH, oHIGH(rRTN);                \
00057        TWLcc  rVALUE, rHIGH
00058 
00059 /* Check both bounds, with the side effect that the BP register is
00060    converted to its simple pointer value.  */
00061 
00062 # define CHECK_BOUNDS_BOTH(rBP, rLOW, rHIGH)     \
00063        CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH);       \
00064        tdlge  rBP, rHIGH
00065 
00066 /* Check bounds on a memory region of given length, with the side
00067    effect that the BP register is converted to its simple pointer
00068    value.  */
00069 
00070 # define CHECK_BOUNDS_BOTH_WIDE(rBP, rLOW, rHIGH, rLENGTH)     \
00071        CHECK_BOUNDS_LOW (rBP, rLOW, rHIGH);                    \
00072        sub    rHIGH, rHIGH, rLENGTH;                           \
00073        tdlgt  rBP, rHIGH
00074 
00075 # define CHECK_BOUNDS_BOTH_WIDE_LIT(rBP, rLOW, rHIGH, LENGTH)  \
00076        CHECK_BOUNDS_LOW (rBP, rLOW, rHIGH);                    \
00077        subi   rHIGH, rHIGH, LENGTH;                            \
00078        tdlgt  rBP, rHIGH
00079 
00080 /* Store a pointer value register into the return-value's pointer
00081    value slot.  */
00082 
00083 # define STORE_RETURN_VALUE(rVALUE)              \
00084        std    rVALUE, oVALUE(rRTN)
00085 
00086 /* Store a low and high bounds into the return-value's pointer bounds
00087    slots.  */
00088 
00089 # define STORE_RETURN_BOUNDS(rLOW, rHIGH) \
00090        std    rLOW, oLOW(rRTN);           \
00091        std    rHIGH, oHIGH(rRTN)
00092 
00093 /* Stuff zero value/low/high into the BP addressed by rRTN.  */
00094 
00095 # define RETURN_NULL_BOUNDED_POINTER             \
00096        li     r4, 0;                      \
00097        STORE_RETURN_VALUE (r4);           \
00098        STORE_RETURN_BOUNDS (r4, r4)
00099 
00100 #else
00101 
00102 # define DISCARD_BOUNDS(rBP)
00103 # define CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH)
00104 # define CHECK_BOUNDS_HIGH(rVALUE, rHIGH, TWLcc)
00105 # define CHECK_BOUNDS_HIGH_RTN(rVALUE, rHIGH, TWLcc)
00106 # define CHECK_BOUNDS_BOTH(rBP, rLOW, rHIGH)
00107 # define CHECK_BOUNDS_BOTH_WIDE(rBP, rLOW, rHIGH, rLENGTH)
00108 # define CHECK_BOUNDS_BOTH_WIDE_LIT(rBP, rLOW, rHIGH, LENGTH)
00109 # define STORE_RETURN_VALUE(rVALUE)
00110 # define STORE_RETURN_BOUNDS(rLOW, rHIGH)
00111 
00112 # define RETURN_NULL_BOUNDED_POINTER li rRTN, 0
00113 
00114 #endif
00115