/* Ported to GNU C openVMS/Alpha by Klaus Kämpf, kkaempf@progis.de  */
/* <vms/xaballdef.h>
 *
 *	RMS allocation XAB definitions
 */
#ifndef _XABALLDEF_H
#define _XABALLDEF_H

#ifdef __cplusplus
extern "C" {
#endif

#define XAB$C_ALL	20	/* xaball ID code */
#define XAB$V_HRD	0
#define XAB$V_ONC	1
#define XAB$V_CBT	5
#define XAB$V_CTG	7
#define XAB$M_HRD	(1<<XAB$V_HRD)		/* 0x01 */
#define XAB$M_ONC	(1<<XAB$V_ONC)		/* 0x02 */
#define XAB$M_CBT	(1<<XAB$V_CBT)		/* 0x20 */
#define XAB$M_CTG	(1<<XAB$V_CTG)		/* 0x80 */
#define XAB$C_ANY	0	/* any allocation o.k. */
#define XAB$C_CYL	1	/* cylinder boundary */
#define XAB$C_LBN	2	/* allocate at specified lbn */
#define XAB$C_VBN	3	/* allocate near specified vbn */
#define XAB$C_RFI	4	/* allocate near related file */
#define XAB$K_ALLLEN	32	/* length of xaball */
#define XAB$C_ALLLEN	32

#ifndef __XABSTART_FIELDS
#include <vms/xabdef.h>
#endif

#ifdef __ALPHA
#define XABALL xaballdef
#else
struct XABALL {
  __XABSTART_FIELDS
    unsigned char  xab$b_aop;		/* allocation options */
    unsigned char  xab$b_aln;		/* alignment type */
    unsigned short xab$w_vol;		/* relative volume no. for allocation */
    unsigned long  xab$l_loc;		/* allocation location */
    unsigned long  xab$l_alq;		/* allocation quantity */
    unsigned short xab$w_deq;		/* default allocation quantity */
    unsigned char  xab$b_bkz;		/* bucket size for area */
    unsigned char  xab$b_aid;		/* area id number */
    unsigned short xab$w_rfi[3];	/* related file id */
    unsigned short : 16;			/* (spare) */
} __attribute__ ((packed));
#endif

struct xaballdef {
  __XABSTART_FIELDS
    union {
	unsigned char xab$b_aop;	/* allocation options */
#define xab$b_aop xab$r_aop_overlay.xab$b_aop
	struct {
	    unsigned char xab$v_hrd : 1;	/* fail if requested alignment impossible */
	    unsigned char xab$v_onc : 1;	/* locate allocated space within a cylinder */
	    unsigned char 	    : 3;	/* (spares) */
	    unsigned char xab$v_cbt : 1;	/* contiguous alllocation, best try */
	    unsigned char	    : 1;	/* spare */
	    unsigned char xab$v_ctg : 1;	/* contiguous allocation */
	} xab$r_aop_bits;
#define xab$v_hrd xab$r_aop_overlay.xab$r_aop_bits.xab$v_hrd
#define xab$v_onc xab$r_aop_overlay.xab$r_aop_bits.xab$v_onc
#define xab$v_cbt xab$r_aop_overlay.xab$r_aop_bits.xab$v_cbt
#define xab$v_ctg xab$r_aop_overlay.xab$r_aop_bits.xab$v_ctg
    } xab$r_aop_overlay;
    unsigned char xab$b_aln;		/* alignment type */
    unsigned short xab$w_vol;		/* relative volume no. for allocation	*/
					/* (not applicable if aln = vbn or rfi) */
    unsigned long xab$l_loc;		/* allocation location */
    unsigned long xab$l_alq;		/* allocation quantity */
    unsigned short xab$w_deq;		/* default allocation quantity */
    unsigned char xab$b_bkz;		/* bucket size for area */
    unsigned char xab$b_aid;		/* area id number */
    union {
	unsigned short xab$w_rfi[3];	/* related file id */
#define xab$w_rfi xab$r_rfi_overlay.xab$w_rfi
	struct {
	    unsigned short xab$w_rfi0;	/* file number */
	    unsigned short xab$w_rfi2;	/* seq number */
	    unsigned short xab$w_rfi4;	/* rev number */
	} xab$r_rfi_fields;
#define xab$w_rfi0 xab$r_rfi_overlay.xab$r_rfi_fields.xab$w_rfi0
#define xab$w_rfi2 xab$r_rfi_overlay.xab$r_rfi_fields.xab$w_rfi2
#define xab$w_rfi4 xab$r_rfi_overlay.xab$r_rfi_fields.xab$w_rfi4
    } xab$r_rfi_overlay;
    unsigned short : 16;		/* short fill; (spare) */
} __attribute__ ((packed));

/* declare initialized prototype data structure */
#ifdef __ALPHA
extern struct XABALL *cc$rms_xaball_ptr __asm("DECC$GA_RMS_XABALL");
#define cc$rms_xaball (*cc$rms_xaball_ptr);
#else
extern struct XABALL cc$rms_xaball __asm("_$$PsectAttributes_GLOBALSYMBOL$$cc$rms_xaball");
#endif

#ifdef __cplusplus
  }
#endif

#endif	/*_XABALLDEF_H*/
