diff -dcrpN pgsql-float4-byval/configure.in pgsql-float4-float8-byval/configure.in
*** pgsql-float4-byval/configure.in	2008-03-30 13:29:42.000000000 +0200
--- pgsql-float4-float8-byval/configure.in	2008-03-31 09:34:21.000000000 +0200
*************** PGAC_TYPE_64BIT_INT([long int])
*** 1308,1313 ****
--- 1308,1316 ----
  
  if test x"$HAVE_LONG_INT_64" = x"no" ; then
    PGAC_TYPE_64BIT_INT([long long int])
+   AC_DEFINE(INT64PASSBYVALUE, false, [Define to false if INT8/FLOAT8/TIME[STAMP[TZ]] is passed by reference.])
+ else
+   AC_DEFINE(INT64PASSBYVALUE, true, [Define to true if INT8/FLOAT8/TIME[STAMP[TZ]] is passed by value.])
  fi
  
  
diff -dcrpN pgsql-float4-byval/src/backend/catalog/genbki.sh pgsql-float4-float8-byval/src/backend/catalog/genbki.sh
*** pgsql-float4-byval/src/backend/catalog/genbki.sh	2008-01-01 20:45:48.000000000 +0100
--- pgsql-float4-float8-byval/src/backend/catalog/genbki.sh	2008-03-31 09:34:21.000000000 +0200
*************** for dir in $INCLUDE_DIRS; do
*** 114,119 ****
--- 114,132 ----
      fi
  done
  
+ # Deduce INT64PASSBYVAL from pg_config.h / HAVE_LONG_INT_64
+ for dir in $INCLUDE_DIRS; do
+     if [ -f "$dir/pg_config.h" ]; then
+         REAL64MACH=`grep '^#define[    ]*HAVE_LONG_INT_64' $dir/pg_config.h | $AWK '{ print $3 }'`
+         break
+     fi
+ done
+ if [ "$REAL64MACH" == "1" ]; then
+     INT64PASSBYVAL="t"
+ else
+     INT64PASSBYVAL="f"
+ fi
+ 
  # Get BOOTSTRAP_SUPERUSERID from catalog/pg_authid.h
  for dir in $INCLUDE_DIRS; do
      if [ -f "$dir/catalog/pg_authid.h" ]; then
*************** sed -e "s/;[ 	]*$//g" \
*** 164,169 ****
--- 177,183 ----
      -e "s/(TransactionId/(xid/g" \
      -e "s/PGUID/$BOOTSTRAP_SUPERUSERID/g" \
      -e "s/NAMEDATALEN/$NAMEDATALEN/g" \
+     -e "s/INT64PASSBYVAL/$INT64PASSBYVAL/g" \
      -e "s/PGNSP/$PG_CATALOG_NAMESPACE/g" \
  | $AWK '
  # ----------------
diff -dcrpN pgsql-float4-byval/src/backend/utils/adt/float.c pgsql-float4-float8-byval/src/backend/utils/adt/float.c
*** pgsql-float4-byval/src/backend/utils/adt/float.c	2008-03-11 10:52:20.000000000 +0100
--- pgsql-float4-float8-byval/src/backend/utils/adt/float.c	2008-03-31 09:34:21.000000000 +0200
*************** float8_accum(PG_FUNCTION_ARGS)
*** 1780,1786 ****
  
  		result = construct_array(transdatums, 3,
  								 FLOAT8OID,
! 							 sizeof(float8), false /* float8 byval */ , 'd');
  
  		PG_RETURN_ARRAYTYPE_P(result);
  	}
--- 1780,1786 ----
  
  		result = construct_array(transdatums, 3,
  								 FLOAT8OID,
! 							 sizeof(float8), INT64PASSBYVALUE, 'd'); /* INT64PASSBYVALUE is used for FLOAT8, too */
  
  		PG_RETURN_ARRAYTYPE_P(result);
  	}
*************** float4_accum(PG_FUNCTION_ARGS)
*** 1833,1839 ****
  
  		result = construct_array(transdatums, 3,
  								 FLOAT8OID,
! 							 sizeof(float8), false /* float8 byval */ , 'd');
  
  		PG_RETURN_ARRAYTYPE_P(result);
  	}
--- 1833,1839 ----
  
  		result = construct_array(transdatums, 3,
  								 FLOAT8OID,
! 							 sizeof(float8), INT64PASSBYVALUE, 'd'); /* INT64PASSBYVALUE is used for FLOAT8, too */
  
  		PG_RETURN_ARRAYTYPE_P(result);
  	}
*************** float8_regr_accum(PG_FUNCTION_ARGS)
*** 2057,2063 ****
  		result = construct_array(transdatums, 6,
  								 FLOAT8OID,
  								 sizeof(float8),
! 								 false /* float8 byval */ , 'd');
  
  		PG_RETURN_ARRAYTYPE_P(result);
  	}
--- 2057,2063 ----
  		result = construct_array(transdatums, 6,
  								 FLOAT8OID,
  								 sizeof(float8),
! 								 INT64PASSBYVALUE, 'd'); /* INT64PASSBYVALUE is used for FLOAT8, too */
  
  		PG_RETURN_ARRAYTYPE_P(result);
  	}
diff -dcrpN pgsql-float4-byval/src/backend/utils/fmgr/fmgr.c pgsql-float4-float8-byval/src/backend/utils/fmgr/fmgr.c
*** pgsql-float4-byval/src/backend/utils/fmgr/fmgr.c	2008-03-31 09:34:03.000000000 +0200
--- pgsql-float4-float8-byval/src/backend/utils/fmgr/fmgr.c	2008-03-31 09:34:21.000000000 +0200
*************** DatumGetFloat4(Datum X)
*** 2084,2094 ****
--- 2084,2118 ----
  Datum
  Float8GetDatum(float8 X)
  {
+ #ifndef HAVE_LONG_INT_64
  	float8	   *retval = (float8 *) palloc(sizeof(float8));
  
  	*retval = X;
  	return PointerGetDatum(retval);
+ #else
+ 	union {
+ 		float8	value;
+ 		Datum	retval;
+ 	} myunion;
+ 
+ 	myunion.value = X;
+ 	return myunion.retval;
+ #endif
+ }
+ 
+ #ifdef HAVE_LONG_INT_64
+ float8
+ DatumGetFloat8(Datum X)
+ {
+ 	union {
+ 		Datum	value;
+ 		float8	retval;
+ 	} myunion;
+ 
+ 	myunion.value = X;
+ 	return myunion.retval;
  }
+ #endif
  
  /*-------------------------------------------------------------------------
   *		Support routines for toastable datatypes
diff -dcrpN pgsql-float4-byval/src/include/catalog/pg_type.h pgsql-float4-float8-byval/src/include/catalog/pg_type.h
*** pgsql-float4-byval/src/include/catalog/pg_type.h	2008-03-31 09:34:03.000000000 +0200
--- pgsql-float4-float8-byval/src/include/catalog/pg_type.h	2008-03-31 09:34:21.000000000 +0200
*************** DESCR("");
*** 371,377 ****
  DATA(insert OID = 700 (  float4    PGNSP PGUID	4 t b t \054 0	 0 1021 float4in float4out float4recv float4send - - - i p f 0 -1 0 _null_ _null_ ));
  DESCR("single-precision floating point number, 4-byte storage");
  #define FLOAT4OID 700
! DATA(insert OID = 701 (  float8    PGNSP PGUID	8 f b t \054 0	 0 1022 float8in float8out float8recv float8send - - - d p f 0 -1 0 _null_ _null_ ));
  DESCR("double-precision floating point number, 8-byte storage");
  #define FLOAT8OID 701
  DATA(insert OID = 702 (  abstime   PGNSP PGUID	4 t b t \054 0	 0 1023 abstimein abstimeout abstimerecv abstimesend - - - i p f 0 -1 0 _null_ _null_ ));
--- 371,377 ----
  DATA(insert OID = 700 (  float4    PGNSP PGUID	4 t b t \054 0	 0 1021 float4in float4out float4recv float4send - - - i p f 0 -1 0 _null_ _null_ ));
  DESCR("single-precision floating point number, 4-byte storage");
  #define FLOAT4OID 700
! DATA(insert OID = 701 (  float8    PGNSP PGUID	8 INT64PASSBYVAL b t \054 0	 0 1022 float8in float8out float8recv float8send - - - d p f 0 -1 0 _null_ _null_ ));
  DESCR("double-precision floating point number, 8-byte storage");
  #define FLOAT8OID 701
  DATA(insert OID = 702 (  abstime   PGNSP PGUID	4 t b t \054 0	 0 1023 abstimein abstimeout abstimerecv abstimesend - - - i p f 0 -1 0 _null_ _null_ ));
*************** DESCR("varchar(length), non-blank-padded
*** 459,476 ****
  DATA(insert OID = 1082 ( date		 PGNSP PGUID	4 t b t \054 0	0 1182 date_in date_out date_recv date_send - - - i p f 0 -1 0 _null_ _null_ ));
  DESCR("ANSI SQL date");
  #define DATEOID			1082
! DATA(insert OID = 1083 ( time		 PGNSP PGUID	8 f b t \054 0	0 1183 time_in time_out time_recv time_send timetypmodin timetypmodout - d p f 0 -1 0 _null_ _null_ ));
  DESCR("hh:mm:ss, ANSI SQL time");
  #define TIMEOID			1083
  
  /* OIDS 1100 - 1199 */
! DATA(insert OID = 1114 ( timestamp	 PGNSP PGUID	8 f b t \054 0	0 1115 timestamp_in timestamp_out timestamp_recv timestamp_send timestamptypmodin timestamptypmodout - d p f 0 -1 0 _null_ _null_ ));
  DESCR("date and time");
  #define TIMESTAMPOID	1114
  DATA(insert OID = 1115 ( _timestamp  PGNSP PGUID	-1 f b t \054 0 1114 0 array_in array_out array_recv array_send timestamptypmodin timestamptypmodout - d x f 0 -1 0 _null_ _null_ ));
  DATA(insert OID = 1182 ( _date		 PGNSP PGUID	-1 f b t \054 0 1082 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ ));
  DATA(insert OID = 1183 ( _time		 PGNSP PGUID	-1 f b t \054 0 1083 0 array_in array_out array_recv array_send timetypmodin timetypmodout - d x f 0 -1 0 _null_ _null_ ));
! DATA(insert OID = 1184 ( timestamptz PGNSP PGUID	8 f b t \054 0	0 1185 timestamptz_in timestamptz_out timestamptz_recv timestamptz_send timestamptztypmodin timestamptztypmodout - d p f 0 -1 0 _null_ _null_ ));
  DESCR("date and time with time zone");
  #define TIMESTAMPTZOID	1184
  DATA(insert OID = 1185 ( _timestamptz PGNSP PGUID -1 f b t \054 0	1184 0 array_in array_out array_recv array_send timestamptztypmodin timestamptztypmodout - d x f 0 -1 0 _null_ _null_ ));
--- 459,476 ----
  DATA(insert OID = 1082 ( date		 PGNSP PGUID	4 t b t \054 0	0 1182 date_in date_out date_recv date_send - - - i p f 0 -1 0 _null_ _null_ ));
  DESCR("ANSI SQL date");
  #define DATEOID			1082
! DATA(insert OID = 1083 ( time		 PGNSP PGUID	8 INT64PASSBYVAL b t \054 0	0 1183 time_in time_out time_recv time_send timetypmodin timetypmodout - d p f 0 -1 0 _null_ _null_ ));
  DESCR("hh:mm:ss, ANSI SQL time");
  #define TIMEOID			1083
  
  /* OIDS 1100 - 1199 */
! DATA(insert OID = 1114 ( timestamp	 PGNSP PGUID	8 INT64PASSBYVAL b t \054 0	0 1115 timestamp_in timestamp_out timestamp_recv timestamp_send timestamptypmodin timestamptypmodout - d p f 0 -1 0 _null_ _null_ ));
  DESCR("date and time");
  #define TIMESTAMPOID	1114
  DATA(insert OID = 1115 ( _timestamp  PGNSP PGUID	-1 f b t \054 0 1114 0 array_in array_out array_recv array_send timestamptypmodin timestamptypmodout - d x f 0 -1 0 _null_ _null_ ));
  DATA(insert OID = 1182 ( _date		 PGNSP PGUID	-1 f b t \054 0 1082 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ ));
  DATA(insert OID = 1183 ( _time		 PGNSP PGUID	-1 f b t \054 0 1083 0 array_in array_out array_recv array_send timetypmodin timetypmodout - d x f 0 -1 0 _null_ _null_ ));
! DATA(insert OID = 1184 ( timestamptz PGNSP PGUID	8 INT64PASSBYVAL b t \054 0	0 1185 timestamptz_in timestamptz_out timestamptz_recv timestamptz_send timestamptztypmodin timestamptztypmodout - d p f 0 -1 0 _null_ _null_ ));
  DESCR("date and time with time zone");
  #define TIMESTAMPTZOID	1184
  DATA(insert OID = 1185 ( _timestamptz PGNSP PGUID -1 f b t \054 0	1184 0 array_in array_out array_recv array_send timestamptztypmodin timestamptztypmodout - d x f 0 -1 0 _null_ _null_ ));
diff -dcrpN pgsql-float4-byval/src/include/pg_config.h.in pgsql-float4-float8-byval/src/include/pg_config.h.in
*** pgsql-float4-byval/src/include/pg_config.h.in	2008-03-11 10:52:21.000000000 +0100
--- pgsql-float4-float8-byval/src/include/pg_config.h.in	2008-03-31 09:34:21.000000000 +0200
***************
*** 589,594 ****
--- 589,597 ----
  /* Define to 1 if you have the <winldap.h> header file. */
  #undef HAVE_WINLDAP_H
  
+ /* Define to true if INT8/FLOAT8/TIME[STAMP[TZ]] is passed by value. */
+ #undef INT64PASSBYVALUE
+ 
  /* Define to the appropriate snprintf format for 64-bit ints, if any. */
  #undef INT64_FORMAT
  
diff -dcrpN pgsql-float4-byval/src/include/postgres.h pgsql-float4-float8-byval/src/include/postgres.h
*** pgsql-float4-byval/src/include/postgres.h	2008-03-31 09:34:03.000000000 +0200
--- pgsql-float4-float8-byval/src/include/postgres.h	2008-03-31 09:34:21.000000000 +0200
*************** extern Datum Float4GetDatum(float4 X);
*** 566,572 ****
--- 566,576 ----
   * at least on some platforms.
   */
  
+ #ifndef HAVE_LONG_INT_64
  #define DatumGetFloat8(X) (* ((float8 *) DatumGetPointer(X)))
+ #else
+ extern float8 DatumGetFloat8(Datum X);
+ #endif
  
  /*
   * Float8GetDatum
*************** extern Datum Float8GetDatum(float8 X);
*** 592,598 ****
--- 596,606 ----
   */
  
  #define Int64GetDatumFast(X)  PointerGetDatum(&(X))
+ #ifndef HAVE_LONG_INT_64
  #define Float8GetDatumFast(X) PointerGetDatum(&(X))
+ #else
+ #define Float8GetDatumFast(X) Float8GetDatum(X)
+ #endif
  
  
  /* ----------------------------------------------------------------
diff -dcrpN pgsql-float4-byval/src/test/regress/expected/type_sanity.out pgsql-float4-float8-byval/src/test/regress/expected/type_sanity.out
*** pgsql-float4-byval/src/test/regress/expected/type_sanity.out	2007-10-14 00:33:38.000000000 +0200
--- pgsql-float4-float8-byval/src/test/regress/expected/type_sanity.out	2008-03-31 09:34:21.000000000 +0200
*************** FROM pg_type as p1
*** 31,37 ****
  WHERE p1.typbyval AND
      (p1.typlen != 1 OR p1.typalign != 'c') AND
      (p1.typlen != 2 OR p1.typalign != 's') AND
!     (p1.typlen != 4 OR p1.typalign != 'i');
   oid | typname 
  -----+---------
  (0 rows)
--- 31,38 ----
  WHERE p1.typbyval AND
      (p1.typlen != 1 OR p1.typalign != 'c') AND
      (p1.typlen != 2 OR p1.typalign != 's') AND
!     (p1.typlen != 4 OR p1.typalign != 'i') AND
!     (p1.typlen != 8 OR p1.typalign != 'd');
   oid | typname 
  -----+---------
  (0 rows)
diff -dcrpN pgsql-float4-byval/src/test/regress/sql/type_sanity.sql pgsql-float4-float8-byval/src/test/regress/sql/type_sanity.sql
*** pgsql-float4-byval/src/test/regress/sql/type_sanity.sql	2007-10-14 00:33:37.000000000 +0200
--- pgsql-float4-float8-byval/src/test/regress/sql/type_sanity.sql	2008-03-31 09:34:21.000000000 +0200
*************** FROM pg_type as p1
*** 32,38 ****
  WHERE p1.typbyval AND
      (p1.typlen != 1 OR p1.typalign != 'c') AND
      (p1.typlen != 2 OR p1.typalign != 's') AND
!     (p1.typlen != 4 OR p1.typalign != 'i');
  
  -- Look for "toastable" types that aren't varlena.
  
--- 32,39 ----
  WHERE p1.typbyval AND
      (p1.typlen != 1 OR p1.typalign != 'c') AND
      (p1.typlen != 2 OR p1.typalign != 's') AND
!     (p1.typlen != 4 OR p1.typalign != 'i') AND
!     (p1.typlen != 8 OR p1.typalign != 'd');
  
  -- Look for "toastable" types that aren't varlena.
  
diff -dcrpN pgsql-float4-byval/src/tools/msvc/Genbki.pm pgsql-float4-float8-byval/src/tools/msvc/Genbki.pm
*** pgsql-float4-byval/src/tools/msvc/Genbki.pm	2008-01-01 20:46:01.000000000 +0100
--- pgsql-float4-float8-byval/src/tools/msvc/Genbki.pm	2008-03-31 09:34:21.000000000 +0200
*************** sub genbki
*** 38,43 ****
--- 38,49 ----
        || die "Could not read NAMEDATALEN from pg_config_manual.h\n";
      my $namedatalen = $1;
  
+     my $pgconf = read_file("src/include/pg_config.h");
+     $pgconf =~ /^#define\s+HAVE_LONG_INT_64\s+(\d+)$/mg
+       || die "Could not read HAVE_LONG_INT_64 from pg_config.h\n";
+     my $real64 = $1;
+     my $int64passbyval = $real64 ? 't' : 'f';
+ 
      my $pgauthid = read_file("src/include/catalog/pg_authid.h");
      $pgauthid =~ /^#define\s+BOOTSTRAP_SUPERUSERID\s+(\d+)$/mg
        || die "Could not read BOOTSTRAUP_SUPERUSERID from pg_authid.h\n";
*************** sub genbki
*** 71,76 ****
--- 77,83 ----
      $indata =~ s{\(TransactionId}{(xid}g;
      $indata =~ s{PGUID}{$bootstrapsuperuserid}g;
      $indata =~ s{NAMEDATALEN}{$namedatalen}g;
+     $indata =~ s{INT64PASSBYVAL}{$int64passbyval}g;
      $indata =~ s{PGNSP}{$pgcatalognamespace}g;
  
      #print $indata;
