head     1.14;
branch   ;
access   ;
symbols  Version_2_1:1.14 Version_2:1.11 C_Demo_1:1.7;
locks    ; strict;
comment  @ * @;


1.14
date     91.01.09.19.01.43;  author sp;  state Exp;
branches ;
next     1.13;

1.13
date     90.10.16.17.16.32;  author sp;  state Exp;
branches ;
next     1.12;

1.12
date     90.08.18.00.40.49;  author cimarron;  state Exp;
branches ;
next     1.11;

1.11
date     90.06.09.18.56.50;  author kemnitz;  state Version_2;
branches ;
next     1.10;

1.10
date     90.06.06.20.37.36;  author kemnitz;  state Exp;
branches ;
next     1.9;

1.9
date     89.09.25.11.26.55;  author cimarron;  state Exp;
branches ;
next     1.8;

1.8
date     89.09.21.19.12.22;  author hirohama;  state Exp;
branches ;
next     1.7;

1.7
date     89.09.05.17.05.17;  author mao;  state C_Demo_1;
branches ;
next     1.6;

1.6
date     89.08.03.00.01.49;  author dillon;  state Exp;
branches ;
next     1.5;

1.5
date     89.07.17.14.32.28;  author dillon;  state Exp;
branches ;
next     1.4;

1.4
date     89.04.14.18.18.16;  author dillon;  state Exp;
branches ;
next     1.3;

1.3
date     89.04.12.19.53.56;  author dillon;  state Exp;
branches ;
next     1.2;

1.2
date     89.03.22.18.57.53;  author hirohama;  state Stab;
branches ;
next     1.1;

1.1
date     89.01.17.05.54.00;  author cimarron;  state Exp;
branches ;
next     ;


desc
@@


1.14
log
@All the 'datum' functions now take different arguments.
@
text
@/*
 * datum.h --
 *	POSTGRES abstract data type datum representation definitions.
 *
 * Note:
 *
 * Port Notes:
 *  Postgres makes the following assumption about machines:
 *
 *  sizeof(Datum) == sizeof(char *) == sizeof(long) == 4
 *
 *  Postgres also assumes that
 *
 *  sizeof(char) == 1
 *
 *  and that 
 *
 *  sizeof(short) == 2
 *
 *  If your machine meets these requirements, Datums should also be checked
 *  to see if the positioning is correct.
 *
 *	This file is MACHINE AND COMPILER dependent!!!
 */

#ifndef	DatumIncluded		/* Include this file only once */
#define DatumIncluded	1

/*
 * Identification:
 */
#define DATUM_H	"$Header: RCS/datum.h,v 1.13 90/10/16 17:16:32 sp Exp Locker: sp $"

typedef struct AnyStruct {
	char    character;
	double  largeFloat;
} AnyStruct;

typedef unsigned long Datum;

/*
 * We want to pad to the right on Sun computers and to the right on
 * the others.
 * 
 */

#ifdef NOTDEF

#define GET_1_BYTE(datum)   ((((long) (datum)) & 0xff000000) >> 24)
#define GET_2_BYTES(datum)  ((((long) (datum)) & 0xffff0000) >> 16)
#define GET_4_BYTES(datum)  (datum)
#define SET_1_BYTE(value)   (((long) (value)) << 24)
#define SET_2_BYTES(value)  (((long) (value)) << 16)
#define SET_4_BYTES(value)  (value)

#endif

#if defined(sequent) || defined(mips) || defined(sun) || defined(sparc)

#define GET_1_BYTE(datum)   (((Datum) (datum)) & 0x000000ff)
#define GET_2_BYTES(datum)  (((Datum) (datum)) & 0x0000ffff)
#define GET_4_BYTES(datum)  ((Datum) (datum))
#define SET_1_BYTE(value)   (((Datum) (value)) & 0x000000ff)
#define SET_2_BYTES(value)  (((Datum) (value)) & 0x0000ffff)
#define SET_4_BYTES(value)  ((Datum) (value))

#endif

/*
 * DatumGetChar --
 *	Returns character value of a datum.
 */

#define DatumGetChar(X) ((char) GET_1_BYTE(X))

/*
 * CharGetDatum --
 *	Returns datum representation for a character.
 */

#define CharGetDatum(X) ((Datum) SET_1_BYTE(X))

/*
 * DatumGetInt8 --
 *	Returns 8-bit integer value of a datum.
 */

#define DatumGetInt8(X) ((int8) GET_1_BYTE(X))

/*
 * Int8GetDatum --
 *	Returns datum representation for an 8-bit integer.
 */

#define Int8GetDatum(X) ((Datum) SET_1_BYTE(X))

/*
 * DatumGetUInt8 --
 *	Returns 8-bit unsigned integer value of a datum.
 */

#define DatumGetUInt8(X) ((uint8) GET_1_BYTE(X))

/*
 * UInt8GetDatum --
 *	Returns datum representation for an 8-bit unsigned integer.
 */

#define UInt8GetDatum(X) ((Datum) SET_1_BYTE(X))

/*
 * DatumGetInt16 --
 *	Returns 16-bit integer value of a datum.
 */

#define DatumGetInt16(X) ((int16) GET_2_BYTES(X))

/*
 * Int16GetDatum --
 *	Returns datum representation for a 16-bit integer.
 */

#define Int16GetDatum(X) ((Datum) SET_2_BYTES(X))

/*
 * DatumGetUInt16 --
 *	Returns 16-bit unsigned integer value of a datum.
 */

#define DatumGetUInt16(X) ((uint16) GET_2_BYTES(X))

/*
 * UInt16GetDatum --
 *	Returns datum representation for a 16-bit unsigned integer.
 */

#define UInt16GetDatum(X) ((Datum) SET_2_BYTES(X))

/*
 * DatumGetInt32 --
 *	Returns 32-bit integer value of a datum.
 */

#define DatumGetInt32(X) ((int32) GET_4_BYTES(X))

/*
 * Int32GetDatum --
 *	Returns datum representation for a 32-bit integer.
 */

#define Int32GetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetUInt32 --
 *	Returns 32-bit unsigned integer value of a datum.
 */

#define DatumGetUInt32(X) ((uint32) GET_4_BYTES(X))

/*
 * UInt32GetDatum --
 *	Returns datum representation for a 32-bit unsigned integer.
 */

#define UInt32GetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetFloat32 --
 *	Returns 32-bit floating point value of a datum.
 */

#define DatumGetFloat32(X) ((float32) GET_4_BYTES(X))

/*
 * Float32GetDatum --
 *	Returns datum representation for a 32-bit floating point number.
 */

#define Float32GetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetFloat64 --
 *	Returns 64-bit floating point value of a datum.
 */

#define DatumGetFloat64(X) ((float64) GET_4_BYTES(X))

/*
 * Float64GetDatum --
 *	Returns datum representation for a 64-bit floating point number.
 */

#define Float64GetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetPointer --
 *	Returns pointer value of a datum.
 */

#define DatumGetPointer(X) ((Pointer) GET_4_BYTES(X))

/*
 * PointerGetDatum --
 *	Returns datum representation for a pointer.
 */

#define PointerGetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetPointerPointer --
 *	Returns pointer to pointer value of a datum.
 */

#define DatumGetPointerPointer(X) ((Pointer *) GET_4_BYTES(X))

/*
 * PointerPointerGetDatum --
 *	Returns datum representation for a pointer to pointer.
 */

#define PointerPointerGetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetStructPointer --
 *	Returns pointer to structure value of a datum.
 */

#define DatumGetStructPointer(X) ((AnyStruct *) GET_4_BYTES(X))

/*
 * StructPointerGetDatum --
 *	Returns datum representation for a pointer to structure.
 */

#define StructPointerGetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetName --
 *	Returns name value of a datum.
 */

#define DatumGetName(X) ((Name) GET_4_BYTES(X))

/*
 * NameGetDatum --
 *	Returns datum representation for a name.
 */

#define NameGetDatum(X) ((Datum) SET_4_BYTES(X))

/*
 * DatumGetObjectId --
 *	Returns object identifier value of a datum.
 */

#define DatumGetObjectId(X) ((ObjectId) GET_4_BYTES(X))

/*
 * ObjectIdGetDatum --
 *	Returns datum representation for an object identifier.
 */

#define ObjectIdGetDatum(X) ((Datum) SET_4_BYTES(X))

/*--------------------------------------------------------
 * SOME NOT VERY PORTABLE ROUTINES ???
 *--------------------------------------------------------
 *
 * In the implementation of the next routines we assume the following:
 *
 * A) if a type is "byVal" then all the information is stored in the
 * Datum itself (i.e. no pointers involved!). In this case the
 * length of the type is always greater than zero and less than
 * "sizeof(Datum)"
 * B) if a type is not "byVal" and it has a fixed length, then
 * the "Datum" always contain a pointer to a stream of bytes.
 * The number of significant bytes are always equal to the length of thr
 * type.
 * C) if a type is not "byVal" and is of variable length (i.e. it has
 * length == -1) then "Datum" always points to a "struct varlena".
 * This varlena structure has information about the actual length of this
 * particular instance of the type and about its value.
 */

/*---------------
 * datumGetSize
 * find the "real" length of a datum
 */
extern
Size
datumGetSize ARGS((
    Datum	value,
    ObjectId	type,
    bool	byVal,
    Size	len
));

/*---------------
 * datumCopy
 * make a copy of a datum.
 */
extern
Datum
datumCopy ARGS((
    Datum	value,
    ObjectId	type,
    bool	byVal,
    Size	len
));

/*---------------
 * datumFree
 * free space that *might* have been palloced by "datumCopy"
 */
extern
void
datumFree  ARGS((
    Datum	value,
    ObjectId	type,
    bool	byVal,
    Size	len
));

/*---------------
 * datumIsEqual
 * return true if thwo datums are equal, false otherwise.
 * XXX : See comments in the code for restrictions!
 */
extern
bool
datumIsEqual ARGS((
    Datum	value1,
    Datum	value2,
    ObjectId	type,
    bool	byVal,
    Size	len
));

#endif	/* !defined(DatumIncluded) */
@


1.13
log
@new function declarations added...
@
text
@d32 1
a32 1
#define DATUM_H	"$Header: RCS/datum.h,v 1.12 90/08/18 00:40:49 cimarron Exp $"
d286 2
a287 2
 * datumGetRealLengthAndByVal
 * find the "real" length of a type
d290 6
a295 6
void
datumGetRealLengthAndByVal ARGS((
    Datum	value;
    ObjectId	type;
    Size	*sizeP;
    bool	*byValP;
d299 1
a299 1
 * copyDatum
d304 1
a304 1
copyDatum ARGS((
d306 3
a308 1
    ObjectId	type
d312 2
a313 2
 * freeDatum
 * free space that *might* have been palloced by "copyDatum"
d317 1
a317 1
freeDatum  ARGS((
d319 3
a321 1
    ObjectId	type
d324 14
@


1.12
log
@eliminated less significant .h files
@
text
@d32 1
a32 1
#define DATUM_H	"$Header: RCS/datum.h,v 1.11 90/06/09 18:56:50 kemnitz Version_2 Locker: cimarron $"
d264 56
@


1.11
log
@New datum.h - has macros and NEW datum structures.
@
text
@d32 1
a32 12
#define DATUM_H	"$Header: RCS/datum.h,v 1.10 90/06/06 20:37:36 kemnitz Exp Locker: kemnitz $"

#ifndef C_H
#include "c.h"
#endif

#ifndef NAME_H
# include "name.h"
#endif
#ifndef OID_H
# include "oid.h"
#endif
@


1.10
log
@Temporary checkin - sparc stuff checked in.
@
text
@d6 17
d32 1
a32 1
#define DATUM_H	"$Header: RCS/datum.h,v 1.9 89/09/25 11:26:55 cimarron Exp Locker: kemnitz $"
d50 1
a50 51
#if defined(sun) 
typedef union Datum {
	struct character {
		char	filler[3];	
		char	value;
	} character;
	struct integer8 {
		int8	filler[3];
		int8	value;
	} integer8;
	struct unsignedInteger8 {
		uint8	filler[3];
		uint8	value;
	} unsignedInteger8;
	struct integer16 {
		int16	filler[1];
		int16	value;
	} integer16;
	struct unsignedInteger16 {
		uint16	filler[1];
		uint16	value;
	} unsignedInteger16;
	struct integer32 {
		int32	value;
	} integer32;
	struct unsignedInteger32 {
		uint32	value;
	} unsignedInteger32;
	struct smallFloat {
		float32	value;
	} smallFloat;
	struct largeFloat {
		float64	value;
	} largeFloat;
	struct pointer {
		Pointer	value;
	} pointer;
	struct pointerPointer {
		Pointer	*value;
	} pointerPointer;
	struct structPointer {
		AnyStruct	*value;
	} structPointer;
	struct name {
		Name	value;	
	} name;
	struct objectId {
		ObjectId	value;	
	} objectId;
} Datum;
#endif	/* defined(sun) */
d52 5
a56 51
#if defined(sequent) || defined(mips) 
typedef union Datum {
	struct character {
		char	value;
		char	filler[3];	
	} character;
	struct integer8 {
		int8	value;
		int8	filler[3];
	} integer8;
	struct unsignedInteger8 {
		uint8	value;
		uint8	filler[3];
	} unsignedInteger8;
	struct integer16 {
		int16	value;
		int16	filler[1];
	} integer16;
	struct unsignedInteger16 {
		uint16	value;
		uint16	filler[1];
	} unsignedInteger16;
	struct integer32 {
		int32	value;
	} integer32;
	struct unsignedInteger32 {
		uint32	value;
	} unsignedInteger32;
	struct smallFloat {
		float32	value;
	} smallFloat;
	struct largeFloat {
		float64	value;
	} largeFloat;
	struct pointer {
		Pointer	value;
	} pointer;
	struct pointerPointer {
		Pointer	*value;
	} pointerPointer;
	struct structPointer {
		AnyStruct	*value;
	} structPointer;
	struct name {
		Name	value;	
	} name;
	struct objectId {
		ObjectId	value;	
	} objectId;
} Datum;
#endif  /* defined(sequent) */
d58 22
a83 4
char
DatumGetChar ARGS((
	Datum	datum
));
d85 2
a90 4
Datum
CharGetDatum ARGS((
	char	character
));
d92 2
a97 4
int8
DatumGetInt8 ARGS((
	Datum	datum
));
d99 2
a104 4
Datum
Int8GetDatum ARGS((
	int8	integer8
));
d106 2
a111 4
uint8
DatumGetUInt8 ARGS((
	Datum	datum
));
d113 2
a118 4
Datum
UInt8GetDatum ARGS((
	uint8	unsignedInteger8
));
d120 2
a125 4
int16
DatumGetInt16 ARGS((
	Datum	datum
));
d127 2
a132 4
Datum
Int16GetDatum ARGS((
	int16	integer16
));
d134 2
a139 4
uint16
DatumGetUInt16 ARGS((
	Datum	datum
));
d141 2
a146 4
Datum
UInt16GetDatum ARGS((
	uint16	unsignedInteger16
));
d148 2
a153 4
int32
DatumGetInt32 ARGS((
	Datum	datum
));
d155 2
a160 4
Datum
Int32GetDatum ARGS((
	int32	integer32
));
d162 2
a167 4
uint32
DatumGetUInt32 ARGS((
	Datum	datum
));
d169 2
a174 4
Datum
UInt32GetDatum ARGS((
	uint32	unsignedInteger32
));
d176 2
a181 4
float32
DatumGetFloat32 ARGS((
	Datum	datum
));
d183 2
a188 4
Datum
Float32GetDatum ARGS((
	float32	smallFloat
));
d190 2
a195 4
float64
DatumGetFloat64 ARGS((
	Datum	datum
));
d197 2
a202 4
Datum
Float64GetDatum ARGS((
	float64	largeFloat
));
d204 2
a209 4
Pointer
DatumGetPointer ARGS((
	Datum	datum
));
d211 2
a216 4
Datum
PointerGetDatum ARGS((
	Pointer	pointer
));
d218 2
a223 4
Pointer *
DatumGetPointerPointer ARGS((
	Datum	datum
));
d225 2
a230 4
Datum
PointerPointerGetDatum ARGS((
	Pointer	*pointerPointerInP
));
d232 2
a237 4
AnyStruct *
DatumGetStructPointer ARGS((
	Datum	datum
));
d239 2
a244 4
Datum
StructPointerGetDatum ARGS((
	AnyStruct	*structPointerInP
));
d246 2
a251 4
Name
DatumGetName ARGS((
	Datum	datum
));
d253 2
a258 4
Datum
NameGetDatum ARGS((
	Name	name
));
d260 2
a265 4
ObjectId
DatumGetObjectId ARGS((
	Datum	datum
));
d267 2
d273 2
a274 4
Datum
ObjectIdGetDatum ARGS((
	ObjectId	objectId
));
@


1.9
log
@moved dynamic symbol stuff to syms.h
@
text
@d15 1
a15 1
#define DATUM_H	"$Header: RCS/datum.h,v 1.8 89/09/21 19:12:22 hirohama Exp $"
d33 1
a33 1
#ifdef	sun
d84 2
a85 1
#if defined(sequent) || defined(mips)
@


1.8
log
@added ...SYMBOLS declarations
miscellaneous cleanup
@
text
@d15 1
a15 1
#define DATUM_H	"$Header: RCS/datum.h,v 1.7 89/09/05 17:05:17 mao C_Demo_1 Locker: hirohama $"
a386 30

#define DATUM_SYMBOLS \
	SymbolDecl(DatumGetChar, "_DatumGetChar"), \
	SymbolDecl(CharGetDatum, "_CharGetDatum"), \
	SymbolDecl(DatumGetInt8, "_DatumGetInt8"), \
	SymbolDecl(Int8GetDatum, "_Int8GetDatum"), \
	SymbolDecl(DatumGetUInt8, "_DatumGetUInt8"), \
	SymbolDecl(UInt8GetDatum, "_UInt8GetDatum"), \
	SymbolDecl(DatumGetInt16, "_DatumGetInt16"), \
	SymbolDecl(Int16GetDatum, "_Int16GetDatum"), \
	SymbolDecl(DatumGetUInt16, "_DatumGetUInt16"), \
	SymbolDecl(UInt16GetDatum, "_UInt16GetDatum"), \
	SymbolDecl(DatumGetInt32, "_DatumGetInt32"), \
	SymbolDecl(Int32GetDatum, "_Int32GetDatum"), \
	SymbolDecl(DatumGetUInt32, "_DatumGetUInt32"), \
	SymbolDecl(UInt32GetDatum, "_UInt32GetDatum"), \
	SymbolDecl(DatumGetFloat32, "_DatumGetFloat32"), \
	SymbolDecl(Float32GetDatum, "_Float32GetDatum"), \
	SymbolDecl(DatumGetFloat64, "_DatumGetFloat64"), \
	SymbolDecl(Float64GetDatum, "_Float64GetDatum"), \
	SymbolDecl(DatumGetPointer, "_DatumGetPointer"), \
	SymbolDecl(PointerGetDatum, "_PointerGetDatum"), \
	SymbolDecl(DatumGetPointerPointer, "_DatumGetPointerPointer"), \
	SymbolDecl(PointerPointerGetDatum, "_PointerPointerGetDatum"), \
	SymbolDecl(DatumGetStructPointer, "_DatumGetStructPointer"), \
	SymbolDecl(StructPointerGetDatum, "_StructPointerGetDatum"), \
	SymbolDecl(DatumGetName, "_DatumGetName"), \
	SymbolDecl(NameGetDatum, "_NameGetDatum"), \
	SymbolDecl(DatumGetObjectId, "_DatumGetObjectId"), \
	SymbolDecl(ObjectIdGetDatum, "_ObjectIdGetDatum")
@


1.7
log
@Working version of C-only demo
@
text
@a6 3
 *
 * Identification:
 *	$Header: /usr6/postgres/mao/postgres/src/lib/H/RCS/datum.h,v 1.6 89/08/03 00:01:49 dillon Exp $
d9 1
a9 1
#ifndef	DatumIncluded	/* Include this file only once. */
d12 5
d22 1
a22 1
#include "name.h"
d25 1
a25 1
#include "oid.h"
d28 1
a28 1
typedef struct AnyStructure {
d31 1
a31 1
} AnyStructure;
d73 3
a75 3
	struct structurePointer {
		AnyStructure	*value;
	} structurePointer;
d124 3
a126 3
	struct structurePointer {
		AnyStructure	*value;
	} structurePointer;
d338 1
a338 1
AnyStructure *
d349 1
a349 1
	AnyStructure	*structurePointerInP
d387 30
@


1.6
log
@shared memory lock manager code that no longer uses semaphores
@
text
@d9 1
a9 1
 *	$Header: /usr6/postgres/dillon/tree/src/lib/H/RCS/datum.h,v 1.5 89/07/17 14:32:28 dillon Exp $
@


1.5
log
@#if defined changes for 3100's
@
text
@d9 1
a9 1
 *	$Header: datum.h,v 1.4 89/04/14 18:18:16 dillon Locked $
d85 1
a86 1
		char	value;
d89 1
a90 1
		int8	value;
d93 1
a94 1
		uint8	value;
d97 1
a98 1
		int16	value;
d101 1
a102 1
		uint16	value;
@


1.4
log
@*** empty log message ***
@
text
@d9 1
a9 1
 *	$Header: /usr6/postgres/dillon/ptree/src/lib/H/RCS/datum.h,v 1.3 89/04/12 19:53:56 dillon Exp $
d82 1
a82 1
#ifdef sequent
@


1.3
log
@c.h
@
text
@d9 1
a9 1
 *	$Header: /usr6/postgres/dillon/ptree/src/lib/H/RCS/datum.h,v 1.2 89/03/22 18:57:53 hirohama Stab $
d19 1
d21 2
d24 1
d82 51
@


1.2
log
@-r1.1 without the beta release copyright
@
text
@d9 1
a9 1
 *	$Header: datum.h,v 1.1 89/01/17 05:54:00 hirohama Locked $
d15 1
d17 1
@


1.1
log
@Initial revision
@
text
@a0 27

; /*
; * 
; * POSTGRES Data Base Management System
; * 
; * Copyright (c) 1988 Regents of the University of California
; * 
; * Permission to use, copy, modify, and distribute this software and its
; * documentation for educational, research, and non-profit purposes and
; * without fee is hereby granted, provided that the above copyright
; * notice appear in all copies and that both that copyright notice and
; * this permission notice appear in supporting documentation, and that
; * the name of the University of California not be used in advertising
; * or publicity pertaining to distribution of the software without
; * specific, written prior permission.  Permission to incorporate this
; * software into commercial products can be obtained from the Campus
; * Software Office, 295 Evans Hall, University of California, Berkeley,
; * Ca., 94720 provided only that the the requestor give the University
; * of California a free licence to any derived software for educational
; * and research purposes.  The University of California makes no
; * representations about the suitability of this software for any
; * purpose.  It is provided "as is" without express or implied warranty.
; * 
; */



d9 1
a9 1
 *	$Header: datum.h,v 1.1 88/11/11 16:37:00 postgres Exp $
@
