summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-10-07 21:52:07 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-10-07 21:52:43 -0400
commit95d035e66d8e4371d35830d81f39face03cd4c45 (patch)
tree450c4e30491bd17f6499e8a33c094f9353238f79 /src/include
parentea72bb8ae527d371ccaf53647540a33224df92a6 (diff)
downloadpostgresql-95d035e66d8e4371d35830d81f39face03cd4c45.tar.gz
Autoconfiscate selection of 64-bit int type for 64-bit large object API.
Get rid of the fundamentally indefensible assumption that "long long int" exists and is exactly 64 bits wide on every platform Postgres runs on. Instead let the configure script select the type to use for "pg_int64". This is a bit of a pain in the rear since we do not want to pollute client namespace with all the random symbols that pg_config.h defines; instead we have to create a separate generated header file, "pg_config_ext.h". But now that the infrastructure is there, we might have the ability to add some other stuff that's long been wanting in this area.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/.gitignore3
-rw-r--r--src/include/Makefile16
-rw-r--r--src/include/c.h20
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/pg_config.h.win323
-rw-r--r--src/include/pg_config_ext.h.in7
-rw-r--r--src/include/pg_config_ext.h.win327
-rw-r--r--src/include/postgres_ext.h12
-rw-r--r--src/include/storage/large_object.h13
9 files changed, 57 insertions, 27 deletions
diff --git a/src/include/.gitignore b/src/include/.gitignore
index fa285a1605..49d108dbed 100644
--- a/src/include/.gitignore
+++ b/src/include/.gitignore
@@ -1,5 +1,6 @@
/stamp-h
+/stamp-ext-h
/pg_config.h
+/pg_config_ext.h
/pg_config_os.h
/dynloader.h
-
diff --git a/src/include/Makefile b/src/include/Makefile
index 35d217cf0c..7e31a1e039 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -13,7 +13,7 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global
-all: pg_config.h pg_config_os.h
+all: pg_config.h pg_config_ext.h pg_config_os.h
# Subdirectories containing headers for server-side dev
@@ -29,8 +29,9 @@ install: all installdirs
# These headers are needed by the public headers of the interfaces.
$(INSTALL_DATA) $(srcdir)/postgres_ext.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/libpq/libpq-fs.h '$(DESTDIR)$(includedir)/libpq'
- $(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir)'
- $(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir)'
+ $(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir)'
+ $(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir)'
+ $(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/pg_config_manual.h '$(DESTDIR)$(includedir)'
# These headers are needed by the not-so-public headers of the interfaces.
$(INSTALL_DATA) $(srcdir)/c.h '$(DESTDIR)$(includedir_internal)'
@@ -38,8 +39,9 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/postgres_fe.h '$(DESTDIR)$(includedir_internal)'
$(INSTALL_DATA) $(srcdir)/libpq/pqcomm.h '$(DESTDIR)$(includedir_internal)/libpq'
# These headers are needed for server-side development
- $(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir_server)'
- $(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir_server)'
+ $(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir_server)'
+ $(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir_server)'
+ $(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir_server)'
$(INSTALL_DATA) utils/errcodes.h '$(DESTDIR)$(includedir_server)/utils'
$(INSTALL_DATA) utils/fmgroids.h '$(DESTDIR)$(includedir_server)/utils'
# We don't use INSTALL_DATA for performance reasons --- there are a lot of files
@@ -62,7 +64,7 @@ installdirs:
uninstall:
- rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
+ rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_ext.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
@@ -72,7 +74,7 @@ clean:
rm -f utils/fmgroids.h utils/errcodes.h parser/gram.h utils/probes.h catalog/schemapg.h
distclean maintainer-clean: clean
- rm -f pg_config.h dynloader.h pg_config_os.h stamp-h
+ rm -f pg_config.h pg_config_ext.h pg_config_os.h dynloader.h stamp-h stamp-ext-h
maintainer-check:
cd catalog && ./duplicate_oids
diff --git a/src/include/c.h b/src/include/c.h
index bec1eb3da4..127b5d94e3 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -44,19 +44,17 @@
#ifndef C_H
#define C_H
-/*
- * We have to include stdlib.h here because it defines many of these macros
- * on some platforms, and we only want our definitions used if stdlib.h doesn't
- * have its own. The same goes for stddef and stdarg if present.
- */
+#include "postgres_ext.h"
+
+/* Must undef pg_config_ext.h symbols before including pg_config.h */
+#undef PG_INT64_TYPE
#include "pg_config.h"
#include "pg_config_manual.h" /* must be after pg_config.h */
-#if !defined(WIN32) && !defined(__CYGWIN__) /* win32 will include further
- * down */
+
+#if !defined(WIN32) && !defined(__CYGWIN__) /* win32 includes further down */
#include "pg_config_os.h" /* must be before any system header files */
#endif
-#include "postgres_ext.h"
#if _MSC_VER >= 1400 || defined(HAVE_CRTDEFS_H)
#define errcode __msvc_errcode
@@ -64,6 +62,12 @@
#undef errcode
#endif
+/*
+ * We have to include stdlib.h here because it defines many of these macros
+ * on some platforms, and we only want our definitions used if stdlib.h doesn't
+ * have its own. The same goes for stddef and stdarg if present.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 58cd5907dd..61ae0c26b8 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -671,6 +671,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* Define to the name of a signed 64-bit integer type. */
+#undef PG_INT64_TYPE
+
/* Define to the name of the default PostgreSQL service principal in Kerberos.
(--with-krb-srvnam=NAME) */
#undef PG_KRB_SRVNAM
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 4d9cc55c69..3715dbdca1 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -562,6 +562,9 @@
/* Define to the version of this package. */
#define PACKAGE_VERSION "9.3devel"
+/* Define to the name of a signed 64-bit integer type. */
+#define PG_INT64_TYPE long long int
+
/* PostgreSQL version as a string */
#define PG_VERSION "9.3devel"
diff --git a/src/include/pg_config_ext.h.in b/src/include/pg_config_ext.h.in
new file mode 100644
index 0000000000..8acadbdafd
--- /dev/null
+++ b/src/include/pg_config_ext.h.in
@@ -0,0 +1,7 @@
+/*
+ * src/include/pg_config_ext.h.in. This is generated manually, not by
+ * autoheader, since we want to limit which symbols get defined here.
+ */
+
+/* Define to the name of a signed 64-bit integer type. */
+#undef PG_INT64_TYPE
diff --git a/src/include/pg_config_ext.h.win32 b/src/include/pg_config_ext.h.win32
new file mode 100644
index 0000000000..65bbb5d80d
--- /dev/null
+++ b/src/include/pg_config_ext.h.win32
@@ -0,0 +1,7 @@
+/*
+ * src/include/pg_config_ext.h.win32. This is generated manually, not by
+ * autoheader, since we want to limit which symbols get defined here.
+ */
+
+/* Define to the name of a signed 64-bit integer type. */
+#define PG_INT64_TYPE long long int
diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h
index 76502de647..5ba379f869 100644
--- a/src/include/postgres_ext.h
+++ b/src/include/postgres_ext.h
@@ -23,6 +23,8 @@
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
+#include "pg_config_ext.h"
+
/*
* Object ID is a fundamental type in Postgres.
*/
@@ -37,6 +39,9 @@ typedef unsigned int Oid;
#define OID_MAX UINT_MAX
/* you will need to include <limits.h> to use the above #define */
+/* Define a signed 64-bit integer type for use in client API declarations. */
+typedef PG_INT64_TYPE pg_int64;
+
/*
* Identifiers of error message fields. Kept here to keep common
@@ -56,9 +61,4 @@ typedef unsigned int Oid;
#define PG_DIAG_SOURCE_LINE 'L'
#define PG_DIAG_SOURCE_FUNCTION 'R'
-#ifndef NO_PG_INT64
-#define HAVE_PG_INT64 1
-typedef long long int pg_int64;
-#endif
-
-#endif
+#endif /* POSTGRES_EXT_H */
diff --git a/src/include/storage/large_object.h b/src/include/storage/large_object.h
index 715f0c3bc4..f8232411a7 100644
--- a/src/include/storage/large_object.h
+++ b/src/include/storage/large_object.h
@@ -62,10 +62,13 @@ typedef struct LargeObjectDesc
* This avoids unnecessary tuple updates caused by partial-page writes.
*/
#define LOBLKSIZE (BLCKSZ / 4)
+
/*
- * Maximum byte length for each large object
-*/
-#define MAX_LARGE_OBJECT_SIZE ((int64)INT_MAX * LOBLKSIZE)
+ * Maximum length in bytes for a large object. To make this larger, we'd
+ * have to widen pg_largeobject.pageno as well as various internal variables.
+ */
+#define MAX_LARGE_OBJECT_SIZE ((int64) INT_MAX * LOBLKSIZE)
+
/*
* Function definitions...
@@ -77,8 +80,8 @@ extern Oid inv_create(Oid lobjId);
extern LargeObjectDesc *inv_open(Oid lobjId, int flags, MemoryContext mcxt);
extern void inv_close(LargeObjectDesc *obj_desc);
extern int inv_drop(Oid lobjId);
-extern int64 inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence);
-extern int64 inv_tell(LargeObjectDesc *obj_desc);
+extern int64 inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence);
+extern int64 inv_tell(LargeObjectDesc *obj_desc);
extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
extern int inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes);
extern void inv_truncate(LargeObjectDesc *obj_desc, int64 len);