[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2171.0. "Possible problem with BUILTIN declaration of PAL calls ?" by MOVIES::PALMER (Ski Forever...) Wed Apr 30 1997 13:33

One of the VMS header files we have to include in our product is
PFN_MACROS.H. If I just compile PFN_MACROS.H with no qualifiers I get
errors like:

        tbi_data_64 (mmg$gq_window_va, THIS_CPU_ONLY, NO_PCB);
........^
%CC-W-MAYLOSEDATA, In this statement, "mmg$gq_window_va" has a larger data
size than "pointer to void".  Assignment may result in data loss.
at line number 200 in file X6C7_RESD$:[LIB_H.LIS]PFN_MACROS.H;1

The problem goes away if I use /pointer=long *or* /pointer=short.

The cause looks to be a combination between PFN_MACROS and BUILTINS.
PFN_MACROS defines the mmg$gq_window_va as a VOID_PQ which is a 64-bit
pointer. So far so good. However it passes mmg$gq_window_va into a PAL
routine (__PAL_MTPR_xxxx) declared in BUILTINS.H. __PAL_MTPR_xxx is
declared as taking a void * parameter. By default 32-bits... However all
the __PAL builtins actually take 64-bit pointers.

Am I right that the declaration in builtins.h is wrong ? Shouldn't
builtins.h set 64-bit pointers explicitly through the #pragma
__required_pointer_size mechanism ? Something like :

  #pragma __required_pointer_size __save  /* Save current pointer size       */
  #pragma __required_pointer_size 64	/* Pointers are 64-bits		   */

     ...all the definitions...

  #pragma __required_pointer_size __restore  /* Restore current pointer size       */

Doing this does seem to fix the problem I'm seeing. Attached is a demo
of the source that will cause a problem, but without all the macros...

Julian


#include <builtins.h>
#include <far_pointers.h>

int main ()
{
  extern VOID_PQ const
    mmg$gq_window_va;

  __PAL_MTPR_TBISD(mmg$gq_window_va);
}
T.RTitleUserPersonal
Name
DateLines
2171.1TLE::D_SMITHDuane Smith -- DEC C RTLWed Apr 30 1997 15:408
    While I will admit that there is inconsistency here, I am not prepared
    to jump to the conclusion that BUILTINS.H is wrong.  The model used in
    the 64-bit pointer implementation was that nothing was enabled without
    the use of /POINTER_SIZE.
    
    I'll add this to the pile of things to look at.
    
    Duane
2171.2For low-level code like PAL calls, use an asmCXXC::REPETERich Peterson 381-1802 ZKO2-3/N30Fri May 02 1997 18:046
My sometimes-disputed opinion is that the plethora of builtins
in DEC C that perform a single instruction or a PAL call are
unfortunate baggage to be carried around.  The asm() mechanism
allows you to generate any specific machine instruction or PAL
call without tossing gratuitous pointer-size issues caused by
the declaration style of builtins.h into the fray.
2171.3TLE::D_SMITHDuane Smith -- DEC C RTLSat May 03 1997 10:0110
    Based on a careful examination of the interfaces in question, the
    following three pal call prototypes have been changed to allow a 64-bit
    parameter:
    
       void __PAL_MTPR_TBIS (void *__address); /* Translation Buffer Invalidate Single */
       void __PAL_MTPR_TBISD(void *__address); /* Translation Buffer Invalidate Single Data */
       void __PAL_MTPR_TBISI(void *__address); /* Translation Buffer Invalidate Single Instruction */
    
    These changes will appear in the version of DEC C after V5.6.
    Duane
2171.4The new <builtins.h> for internal usersTLE::D_SMITHDuane Smith -- DEC C RTLSat May 03 1997 20:49798
#ifndef __BUILTINS_LOADED
#define __BUILTINS_LOADED 1
/****************************************************************************
**
**  <builtins.h> - Prototypes for platform specific builtins
**
*****************************************************************************
**  Header is nonstandard
*****************************************************************************
**
**  Copyright Digital Equipment Corporation 1993, 1995. All rights reserved.
**
**  Restricted Rights: Use, duplication, or disclosure by the U.S.
**  Government is subject to restrictions as set forth in subparagraph
**  (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR
**  52.227-14 Alt. III, as applicable.
**
**  This software is proprietary to and embodies the confidential
**  technology of Digital Equipment Corporation. Possession, use, or
**  copying of this software and media is authorized only pursuant to a
**  valid written license from Digital or an authorized sublicensor.
**
******************************************************************************
*/

#pragma __nostandard  

/*
**  This header file begins with the following three sections:
**
**     OpenVMS AXP 
**     OpenVMS AXP with __X_FLOAT
**     OpenVMS VAX DEC C Only (No DEC C++)
*/

#ifndef __CRTL_VER
#   define __CRTL_VER __VMS_VER
#endif


/*
**  Ensure that regardless of user /pointer_size usage, we begin processing
**  using a 32 bit pointer context.
*/
#if __INITIAL_POINTER_SIZE
#   if (__CRTL_VER < 70000000) || !defined __ALPHA
#      error " Pointer size usage not permitted before OpenVMS Alpha V7.0"
#   endif
#   pragma __pointer_size __save
#   pragma __pointer_size 32
#endif


/*
**  Certain OpenVMS header files expect the __PAL builtins to accept 
**  64-bit pointers regardless of whether the /POINTER_SIZE is used 
**  or not.  To allow this, we will define a typedef to be used with 
**  those prototypes.
*/
#ifdef __ALPHA
#   ifndef ___VOID__PTR64
#      define ___VOID__PTR64 1
#      ifdef __INITIAL_POINTER_SIZE

#         if __INITIAL_POINTER_SIZE
#            pragma __pointer_size __save
#            pragma __pointer_size 64
#         else
#            pragma __required_pointer_size __save
#            pragma __required_pointer_size 64
#         endif

          typedef void * ___void__ptr64;
          typedef const void * __const_void__ptr64;

#         if __INITIAL_POINTER_SIZE
#            pragma __pointer_size __restore
#         else
#            pragma __required_pointer_size __restore
#         endif

#      else

          typedef unsigned __int64 ___void__ptr64;

#      endif
#   endif
#endif



/************************************************************************/
#if defined(__ALPHA) && defined(__VMS)
/************************************************************************/

/*
** The following builtins were added in DEC C V5.2
*/
#if (__DECC_VER >= 50200000) || (__DECCXX_VER >= 50200000)

    /************************************************************
    **  DEC C builtins for atomic/interlocked operations
    *************************************************************
    **
    **  These functions are not easily/efficiently implemented using inline
    **  assembly code, and so the compiler has builtin knowledge of their names
    **  and signatures in order to generate fast and reliable code (e.g. it may
    **  generate loops with tests arranged for branch prediction using
    **  out-of-line branch targets for failure paths).
    **
    **  The _RETRY variants store a non-zero status if the operation completes
    **  successfully within the specified number of retries.  The variants
    **  without _RETRY do not return until they succeed.
    **
    **  The following operations do not in themselves generate Memory Barriers.
    **  The user is expected to code explicitly any Memory Barriers where
    **  needed using inline assembly code, e.g. asm("mb"), or asm("wmb").
    **
    **  Many of these builtins perform essentially the same operations as other
    **  builtins having similar names but with the ATOMIC or INTERLOCKED
    **  appearing in a different position.  The following group with the ATOMIC
    **  or INTERLOCKED first offer several usability improvements over the
    **  older versions with the ATOMIC or INTERLOCKED appearing later in the
    **  name.  The older versions are retained for compatibility only.
    **
    **  Usability problems with the older builtins that are addressed by this
    **  newer set introduced in DEC C V5.2:
    **
    **     Old versions did not provide the pre-updated value, and 
    **     provided status even with infinite retry, in which case the builtin
    **     does not return until it succeeds.  New versions  provide the
    **     old value, and only provide status when the limited-retry variant is
    **     used.
    **
    **     Older versions generated memory barriers both before and after the
    **     update.  Newer versions allow the user to control memory barrier
    **     placement for the low-level primitives.
    **
    **     Older versions did not provide for efficient spinlock or counted
    **     semaphore implementation.  There are new higher-level spinlock and
    **     counted semaphore operations that include a test of the stored value
    **     to control success, and generate memory barriers just after a lock
    **     or resource is acquired, and just before it is release.
    */

    /*
    **  The following set of functions may pass long pointers.
    */
#   if __INITIAL_POINTER_SIZE
#   pragma __pointer_size 64
#   endif

    /*
    **  Atomic update of location with integer operation, returning previous
    **  contents.
    */
    int      __ATOMIC_ADD_LONG(volatile void *__address, int __expression);
    int      __ATOMIC_ADD_LONG_RETRY(volatile void *__address,
				    int __expression,
				    int __retry,
				    int *__status);
    __int64  __ATOMIC_ADD_QUAD(volatile void *__address, __int64 __expression);
    __int64  __ATOMIC_ADD_QUAD_RETRY(volatile void *__address,
				     __int64 __expression,
				     int __retry,
				     int *__status);

    int      __ATOMIC_AND_LONG(volatile void *__address, int __expression);
    int      __ATOMIC_AND_LONG_RETRY(volatile void *__address,
				    int __expression,
				    int __retry,
				    int *__status);
    __int64  __ATOMIC_AND_QUAD(volatile void *__address, __int64 __expression);
    __int64  __ATOMIC_AND_QUAD_RETRY(volatile void *__address,
				     __int64 __expression,
				     int __retry,
				     int *__status);

    int      __ATOMIC_OR_LONG(volatile void *__address, int __expression);
    int      __ATOMIC_OR_LONG_RETRY(volatile void *__address,
				   int __expression,
				   int __retry,
				   int *__status);
    __int64  __ATOMIC_OR_QUAD(volatile void *__address, __int64 __expression);
    __int64  __ATOMIC_OR_QUAD_RETRY(volatile void *__address,
				    __int64 __expression,
				    int __retry,
				    int *__status);

    /*
    **  Just like __ATOMIC_ADD, but using +1 or -1 implicitly.
    */
    int      __ATOMIC_INCREMENT_LONG(volatile void *__address);
    int      __ATOMIC_INCREMENT_LONG_RETRY(volatile void *__address,
					   int __retry,
					   int *__status);
    __int64  __ATOMIC_INCREMENT_QUAD(volatile void *__address);
    __int64  __ATOMIC_INCREMENT_QUAD_RETRY(volatile void *__address,
					   int __retry,
					   int *__status);

    int      __ATOMIC_DECREMENT_LONG(volatile void *__address);
    int      __ATOMIC_DECREMENT_LONG_RETRY(volatile void *__address,
					   int __retry,
					   int *__status);
    __int64  __ATOMIC_DECREMENT_QUAD(volatile void *__address);
    __int64  __ATOMIC_DECREMENT_QUAD_RETRY(volatile void *__address,
					   int __retry,
					   int *__status);

    /*
    **  Atomic replacement of location's contents, returning previous contents.
    */
    int      __ATOMIC_EXCH_LONG(volatile void *__address, int __expression);
    int      __ATOMIC_EXCH_LONG_RETRY(volatile void *__address,
				      int __expression,
				      int __retry,
				      int *__status);
    __int64  __ATOMIC_EXCH_QUAD(volatile void *__address, __int64 __expression);
    __int64  __ATOMIC_EXCH_QUAD_RETRY(volatile void *__address,
				      __int64 __expression,
				      int __retry,
				      int *__status);

    /*
    **  Interlocked "test for bit clear and then clear".  Returns non-zero if
    **  bit was already clear.
    */
    int __INTERLOCKED_TESTBITCC_QUAD(volatile void *__address, int __bit_position);
    int __INTERLOCKED_TESTBITCC_QUAD_RETRY(volatile void *__address,
					   int __bit_position,
					   int __retry,
					   int *__status);
    /*
    **  Interlocked "test for bit set and then set".  Returns non-zero if bit
    **  was already set.
    */
    int __INTERLOCKED_TESTBITSS_QUAD(volatile void *__address, int __bit_position);
    int __INTERLOCKED_TESTBITSS_QUAD_RETRY(volatile void *__address,
					   int __bit_position,
					   int __retry,
					   int *__status);

    /*
    **  Acquire/release binary spinlock based on low-order bit of a longword.
    **  NOTE: Memory barrier generated after lock, before unlock.  _RETRY
    **  variant returns non-zero on success within retry attempts.
    */
    void __LOCK_LONG(volatile void *__address);
    int  __LOCK_LONG_RETRY(volatile void *__address, int __retry);
    void __UNLOCK_LONG(volatile void *__address);

    /*
    **  Acquire/release counted semaphore based on positive value of longword
    **  indicating number of resources available.
    **
    **  NOTE: Memory barrier generated after acquisition, before release.
    **  _RETRY variant returns non-zero on success within retry attempts.
    */
    void __ACQUIRE_SEM_LONG(volatile void *__address);
    int  __ACQUIRE_SEM_LONG_RETRY(volatile void *__address, int __retry);
    void __RELEASE_SEM_LONG(volatile void *__address);

    /*
    **  Done with the set of functions which may pass long pointers.
    */
#   if __INITIAL_POINTER_SIZE
#   pragma __pointer_size 32
#   endif

#endif  /* (__DECC_VER >= 50200000) || (__DECCXX_VER >= 50200000) */


/*
**  xxxQUE Mapping Tables
**  These tables map the _PAL returned values into VAX C expected values.
*/
#define __xxxQUE_MAP_ALPHA_TO_VAX(z) ((0x12 >> (z)) & 3)
#define __REMQxI_MAP_ALPHA_TO_VAX(z) (((0x0c >> (z)) + 1) & 3)

/* 
**  Insert entry into longword queue
*/
int __PAL_INSQHIL(void *__head, void *__new_entry);	/* At head, interlocked */
int __PAL_INSQTIL(void *__head, void *__new_entry);	/* At tail, interlocked */
int __PAL_INSQUEL(void *__predecessor, void *__new_entry); 
int __PAL_INSQUEL_D(void **__predecessor, void *__new_entry); /* Deferred */

/* 
**  Insert entry into quadword queue
*/
int __PAL_INSQHIQ(void *__head, void *__new_entry);	/* At head, interlocked */
int __PAL_INSQTIQ(void *__head, void *__new_entry);	/* At tail, interlocked */
int __PAL_INSQUEQ(void *__predecessor, void *__new_entry);
int __PAL_INSQUEQ_D(void **__predecessor, void *__new_entry); /* Deferred */

/*
**  Insert Resident Interlocked Queue Opcodes
*/
int __PAL_INSQHILR(void *__head, void *__new_entry);	/* At head, interlocked */
int __PAL_INSQTILR(void *__head, void *__new_entry);	/* At tail, interlocked */
int __PAL_INSQHIQR(void *__head, void *__new_entry);	/* At head, interlocked */
int __PAL_INSQTIQR(void *__head, void *__new_entry);	/* At tail, interlocked */

/* 
**  Remove entry from longword queue
*/
int __PAL_REMQHIL(void *__head, void **__removed_entry);    /* At head, interlocked */
int __PAL_REMQTIL(void *__head, void **__removed_entry);    /* At tail, interlocked */
int __PAL_REMQUEL(void *__entry, void **__removed_entry);
int __PAL_REMQUEL_D(void **__entry, void **__removed_entry); /* Deferred */

/* 
**  Remove entry from quadword queue
*/
int __PAL_REMQHIQ(void *__head, void **__removed_entry);    /* At head, interlocked */
int __PAL_REMQTIQ(void *__head, void **__removed_entry);    /* At tail, interlocked */
int __PAL_REMQUEQ(void *__entry, void **__removed_entry);
int __PAL_REMQUEQ_D(void **__entry, void **__removed_entry); /* Deferred */

/*
**  Remove Resident Interlocked Queue Opcodes
*/
int __PAL_REMQHILR(void *__head, void **__removed_entry);   /* At head, interlocked */
int __PAL_REMQTILR(void *__head, void **__removed_entry);   /* At tail, interlocked */
int __PAL_REMQHIQR(void *__head, void **__removed_entry);   /* At head, interlocked */
int __PAL_REMQTIQR(void *__head, void **__removed_entry);   /* At tail, interlocked */

/*
**  The following set of functions may pass long pointers.
*/
#if __INITIAL_POINTER_SIZE
#pragma __pointer_size 64
#endif

/*
**  Move from Processor Register
*/
unsigned int __PAL_MFPR_ASTEN(void);	/* AST Enable */
unsigned int __PAL_MFPR_ASTSR(void);	/* AST Summary Register */
void *__PAL_MFPR_ESP(void);		/* Executive Stack Pointer */
int __PAL_MFPR_FEN(void);		/* Floating Point Enable */
int __PAL_MFPR_IPL(void);		/* Interrupt Priority Level */
__int64 __PAL_MFPR_MCES(void);		/* Machine Check Error Summary */
void *__PAL_MFPR_PCBB(void);		/* Privileged Context Block Base */
__int64 __PAL_MFPR_PRBR(void);		/* Processor Base Register */
int __PAL_MFPR_PTBR(void);		/* Page Table Base Register */
void *__PAL_MFPR_SCBB(void);		/* System Control Block Base */
unsigned int __PAL_MFPR_SISR(void);	/* Software Interrupt Summary Register */
void *__PAL_MFPR_SSP(void);		/* Supervisor Stack Pointer */
__int64 __PAL_MFPR_TBCHK(void *__address);/* Translation Buffer Check */
void *__PAL_MFPR_USP(void);		/* User Stack Pointer */
void *__PAL_MFPR_VPTB(void);		/* Virtual Page Table */
__int64 __PAL_MFPR_WHAMI(void);		/* Who Am I */

/*
**  Move to Processor Register
*/
void __PAL_MTPR_ASTEN(unsigned int __mask); /* AST Enable */
void __PAL_MTPR_ASTSR(unsigned int __mask); /* AST Summary Register */
void __PAL_MTPR_DATFX(int __value);	    /* Data Alignment Trap Fixup */
void __PAL_MTPR_ESP(void *__address);	    /* Executive Stack Pointer */
void __PAL_MTPR_FEN(int __value);	    /* Floating Point Enable */
void __PAL_MTPR_IPIR(__int64 __number);   /* Interprocessor Interrupt Request */
int  __PAL_MTPR_IPL(int __value);	    /* Interrupt Priority Level */
void __PAL_MTPR_MCES(__int64 __value);	    /* Machine Check Error Summary */
void __PAL_MTPR_PRBR(__int64 __value);      /* Processor Base Register */
void __PAL_MTPR_SCBB(void *__address);	    /* System Control Block Base */
void __PAL_MTPR_SIRR(int __level);	    /* Software Interrupt Request Register */
void __PAL_MTPR_SSP(int *__address);	    /* Supervisor Stack Pointer */
void __PAL_MTPR_TBIA(void);		    /* User Stack Pointer */
void __PAL_MTPR_TBIAP(void);		    /* Translation Buffer Invalidate All Process */
void __PAL_MTPR_TBIS(___void__ptr64 __address);  /* Translation Buffer Invalidate Single */
void __PAL_MTPR_TBISD(___void__ptr64 __address); /* Translation Buffer Invalidate Single Data */
void __PAL_MTPR_TBISI(___void__ptr64 __address); /* Translation Buffer Invalidate Single Instruction */
void __PAL_MTPR_USP(void *__address);	    /* User Stack Pointer */
void __PAL_MTPR_VPTB(void *__address);	    /* Virtual Page Table */

/*
**  Probe Read/Write Acessibility
*/
int __PAL_PROBER(const void *__base_address, int __length, char __mode);
int __PAL_PROBEW(const void *__base_address, int __length, char __mode);

/*
**  Change Mode 
*/
void __PAL_CHME(void);                           /* Executive  */
void __PAL_CHMK(void);                           /* Kernel     */
void __PAL_CHMS(void);                           /* Supervisor */
void __PAL_CHMU(void);                           /* User       */

/*
**  Load/Store Quadword Physical
*/
unsigned __int64 __PAL_LDQP(void *__address);               /* Load       */
void __PAL_STQP(void *__address, unsigned __int64 __value); /* Store      */

/*
**  Done with the set of functions which may pass long pointers.
*/
#if __INITIAL_POINTER_SIZE
#pragma __pointer_size 32
#endif

/*
**  Cache Flush
*/
void __PAL_CFLUSH(int __value);

/*
**  Drain Aborts
*/
void __PAL_DRAINA(void);

/*
**  Read Processor Status
*/
unsigned __int64 __PAL_RD_PS(void);

/*
**  Swap AST Enable
*/
unsigned int __PAL_SWASTEN(int __new_state_mask);

/*
**  Write Processor Status Software Field
*/
void __PAL_WR_PS_SW(int __mask);

/*
**  Convert from G-Floating to Quadword
*/
__int64 __CVTGQ(double __operand1);

/*
**  Convert from G-Floating to F-Floating Chopped
*/
float __CVTGF_C(double __operand1);

/*
**  Add Floating Point Chopped
*/
float __ADDF_C(float __operand1, float __operand2);
double __ADDG_C(double __operand1, double __operand2);

/*
**  Subtract Floating Point Chopped
*/
float __SUBF_C(float __operand1, float __operand2);
double __SUBG_C(double __operand1, double __operand2);

/*
**  Multiply Floating Point Chopped
*/
float __MULF_C(float __operand1, float __operand2);
double __MULG_C(double __operand1, double __operand2);

/*
**  Divide Floating Point Chopped
*/
float __DIVF_C(float __operand1, float __operand2);
double __DIVG_C(double __operand1, double __operand2);

/*
**  Macros for translation from VAX C to DEC C ALPHA builtins
*/
#define _BBCCI(position, address) __TESTBITCCI((address), (position))
#define _BBSSI(position, address) __TESTBITSSI((address), (position))

#define _INSQHI(new_entry, head) 			\
        ((0x12 >> (__PAL_INSQHIL((head), (new_entry))+2)) & 3)

#define _INSQTI(new_entry, head) 			\
        ((0x12 >> (__PAL_INSQTIL((head), (new_entry))+2)) & 3)

#define _INSQUE(new_entry, predecessor)	 		\
        ((0x12 >> (__PAL_INSQUEL((predecessor), (new_entry))+1)) & 3)

#define _REMQHI(head, removed_entry) 			\
	(((0x0c >> (__PAL_REMQHIL((head), (void **)(removed_entry))+1)) + 1) & 3)

#define _REMQTI(head, removed_entry)	 		\
	(((0x0c >> (__PAL_REMQTIL((head), (void **)(removed_entry))+1)) + 1) & 3)

#define _REMQUE(entry, removed_entry) 			\
	((0x12 >> (__PAL_REMQUEL((entry), (void **)(removed_entry))+1)) & 3)

#define _PROBER(mode, length, address) __PAL_PROBER((address), (length), (mode))
#define _PROBEW(mode, length, address) __PAL_PROBEW((address), (length), (mode))
/*
**  __ALLOCA builtin - allocate n-bytes from the stack
*/
void * __ALLOCA(unsigned int __x);

/*
**  The remaining functions can handle accepting long pointers.
*/
#if __INITIAL_POINTER_SIZE
#pragma __pointer_size 64
#endif

/*
**  UMULH Builtin - Unsigned Quadword Multiply High
*/
unsigned __int64 __UMULH(unsigned __int64 __oper1, unsigned __int64 __oper2);

/*
**  op_ATOMIC_size Builtins
**
**  Note: There is one optional retry count parameter
*/    
int __ADD_ATOMIC_LONG(void *__address, int __expression, ...);
int __ADD_ATOMIC_QUAD(void *__address, int __expression, ...);

int __AND_ATOMIC_LONG(void *__address, int __expression, ...);
int __AND_ATOMIC_QUAD(void *__address, int __expression, ...);

int __OR_ATOMIC_LONG(void *__address, int __expression, ...);
int __OR_ATOMIC_QUAD(void *__address, int __expression, ...);

/*
**  TESTBITxxI
**
**  Note: There is one optional retry count parameter
*/
int __TESTBITCCI(void *__address, int __position, ...);
int __TESTBITSSI(void *__address, int __position, ...);

/*
**  Add Aligned Word Interlocked
*/
int __ADAWI(short __src, volatile short *__dest);

/*
**  Trap Barrier Instruction
*/
void __TRAPB(void);

/*
**  Read Cycle Counter
*/
unsigned __int64 __RPCC(void);

/*
**  Halt the Processor. (Privileged)
*/
void _HALT(void);
void __PAL_HALT(void);

/*
**  Generate Trap
*/
void __PAL_GENTRAP(unsigned __int64 __encoded_software_trap);

/*
**  Breakpoint
*/
void __PAL_BPT(void);

/*
**  Bugcheck
*/
void __PAL_BUGCHK(void);

/*
**  Swap Privileged Context
*/
void __PAL_SWPCTX(void *__address);

/*
**  Copy Sign
*/
float	    __CPYSF(float __operand1, float __operand2);
double	    __CPYS(double __operand1, double __operand2);

/*
**  Copy Sign Negate
*/
float	    __CPYSNF(float __operand1, float __operand2);
double	    __CPYSN(double __operand1, double __operand2);

/*
**  Copy Sign Exponent
*/
float	    __CPYSEF(float __operand1, float __operand2);
double	    __CPYSE(double __operand1, double __operand2);

/*
**  Convert from T-Floating to Quadword
*/
__int64 __CVTTQ(double __operand1);

/*
**  Convert from T-Floating to S-Floating Chopped
*/
float __CVTTS_C(double __operand1);

/*
**  Add Floating Point Chopped
*/
float __ADDS_C(float __operand1, float __operand2);
double __ADDT_C(double __operand1, double __operand2);

/*
**  Subtract Floating Point Chopped
*/
float __SUBS_C(float __operand1, float __operand2);
double __SUBT_C(double __operand1, double __operand2);

/*
**  Multiply Floating Point Chopped
*/
float __MULS_C(float __operand1, float __operand2);
double __MULT_C(double __operand1, double __operand2);

/*
**  Divide Floating Point Chopped
*/
float __DIVS_C(float __operand1, float __operand2);
double __DIVT_C(double __operand1, double __operand2);

/*
**  Memory Barrier
*/
void	__MB(void);

/*
**  Instruction Memory Barrier
*/
void	__PAL_IMB(void);

/*
**  Compare, Store Long/Quad
*/
int __CMP_STORE_LONG(volatile void *__source, int __old_value, int __new_value, 
                     volatile void *__dest);
int __CMP_STORE_QUAD(volatile void *__source, __int64 __old_value, 
                     __int64 __new_value, volatile void  *__dest);

/*
**  Reset the pointer size prior to leaving this section
*/
#if __INITIAL_POINTER_SIZE
#pragma __pointer_size 32
#endif
#endif  /* __ALPHA && __VMS */




/************************************************************************/
#if defined(__ALPHA) && defined(__VMS) && defined(__X_FLOAT)
/************************************************************************/

/*
**  Convert from X-Floating to Quadword
*/
__int64 __CVTXQ(long double __operand1);

/*
**  Convert from X-Floating to T-Floating Chopped
*/
double __CVTXT_C(long double __operand1);

/*
**  Add Floating Point Chopped
*/
long double __ADDX_C(long double __operand1, long double __operand2);

/*
**  Subtract Floating Point Chopped
*/
long double __SUBX_C(long double __operand1, long double __operand2);

/*
**  Multiply Floating Point Chopped
*/
long double __MULX_C(long double __operand1, long double __operand2);

/*
**  Divide Floating Point Chopped
*/
long double __DIVX_C(long double __operand1, long double __operand2);
#endif  /* __ALPHA && __VMS && __X_FLOAT */




/************************************************************************/
#if defined(__VAX) && defined(__VMS) && defined(__DECC)
/************************************************************************/

/*
** The following builtins were added in DEC C V5.2
*/
#if (__DECC_VER >= 50200000)

    /*
    ** Processor Register Management
    */
    typedef enum {_value_replaced, _value_not_replaced} _MTPR_STATUS;
    void _MFPR(int __register_num, void *__destination);
    _MTPR_STATUS _MTPR(int __new_value, int __register_num);

    /*
    ** Processor control
    */
    void _HALT(void);

    /*
    ** General Register query
    */
    typedef enum {_R0, _R1, _R2,  _R3,  _R4, _R5, _R6, _R7,
		  _R8, _R9, _R10, _R11, _AP, _FP, _SP, _PC} _REGISTER_NUMBER;
    int _READ_GPR(_REGISTER_NUMBER __general_register_number);

#endif  /* __DECC_VER >= 50200000 */


/*
**  Add Aligned Word Interlocked
*/
typedef enum {_adawi_sum_neg = -1, _adawi_sum_zero, _adawi_sum_pos} _ADAWI_STATUS;
_ADAWI_STATUS _ADAWI(short __src, short *__dest);

/*
**  Interlocked branch group
*/
typedef enum {_bbcci_oldval_1, _bbcci_oldval_0} _BBCCI_STATUS;
_BBCCI_STATUS _BBCCI(int __position, void *__address);

typedef enum {_bbssi_oldval_0, _bbssi_oldval_1} _BBSSI_STATUS;
_BBSSI_STATUS _BBSSI(int __position, void *__address);

/*
**  Find First bit group
*/
typedef enum {_ff_bit_not_found, _ff_bit_found} _FF_STATUS;
_FF_STATUS _FFC(int __start, char __size, const void *__base, int *__position);
_FF_STATUS _FFS(int __start, char __size, const void *__base, int *__position);

/*
**  Insert into a queue group
*/
typedef enum {_insqi_inserted_many, _insqi_not_inserted, _insqi_inserted_only} _INSQI_STATUS;
_INSQI_STATUS _INSQHI(void *__new_entry, void *__head);
_INSQI_STATUS _INSQTI(void *__new_entry, void *__head);

typedef enum {_insque_inserted_only, _insque_inserted_many} _INSQUE_STATUS;
_INSQUE_STATUS _INSQUE(void *__new_entry, void *__predecessor);

/*
**  Character processing group
*/
unsigned short _LOCC(char __target, unsigned short __length, const char *__string, ...);

void _MOVC3(unsigned short __length, const char *__src, char *__dest, ...);
void _MOVC5(unsigned short __srclen, const char *__src, char __fill, unsigned short __destlen, char *__dest, ...);

unsigned short _SCANC(unsigned short __length, const char *__string, const char *__table, char __mask, ...);
unsigned short _SKPC(char __target, unsigned short __length, const char *__string, ...);
unsigned short _SPANC(unsigned short __length, const char *__string, const char *__table, char __mask, ...);

/*
**  Obtain the program status longword
*/
void _MOVPSL(void *__psl);

/*
**  Probe memory group
*/
typedef enum {_probe_not_accessible, _probe_accessible} _PROBE_STATUS;
_PROBE_STATUS _PROBER(char __mode, unsigned short __length, const void *__address);
_PROBE_STATUS _PROBEW(char __mode, unsigned short __length, const void *__address);

/*
**  Remove from a queue group
*/
typedef enum {_remqi_removed_more, _remqi_not_removed, _remqi_removed_empty, _remqi_empty} _REMQI_STATUS;
_REMQI_STATUS _REMQHI(void *__head, void *__removed_entry);
_REMQI_STATUS _REMQTI(void *__head, void *__removed_entry);

typedef enum {_remque_removed_more, _remque_removed_empty, _remque_empty} _REMQUE_STATUS;
_REMQUE_STATUS _REMQUE(void *__entry, void *__removed_entry);
#endif   /* __VAX && __VMS */



/*
**  Restore the users pointer context
*/
#if __INITIAL_POINTER_SIZE
#   pragma __pointer_size __restore
#endif

#pragma __standard  
#endif   /* __BUILTINS_LOADED */