summaryrefslogtreecommitdiff
path: root/src/include/pgmagic.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-05-30 21:21:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-05-30 21:21:30 +0000
commite60cb3a35c88d33dbfc53afb91f5bfff4209dad0 (patch)
tree2a412f096d66722388b2b4b9d177ea37ab413866 /src/include/pgmagic.h
parenta18ebc5541c20bf6aca70532bbf1a0531d1b2659 (diff)
downloadpostgresql-e60cb3a35c88d33dbfc53afb91f5bfff4209dad0.tar.gz
Code review for magic-block patch. Remove separate header file pgmagic.h,
as this seems only likely to create headaches for module developers. Put the macro in the pre-existing fmgr.h file instead. Avoid being too cute about how many fields we can cram into a word, and avoid trying to fetch from a library we've already unlinked. Along the way, it occurred to me that the magic block really ought to be 'const' so it can be stored in the program text area. Do the same for the existing data blocks for PG_FUNCTION_INFO_V1 functions.
Diffstat (limited to 'src/include/pgmagic.h')
-rw-r--r--src/include/pgmagic.h73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/include/pgmagic.h b/src/include/pgmagic.h
deleted file mode 100644
index 456804618c..0000000000
--- a/src/include/pgmagic.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * pgmagic.h
- * Defines a magic block that can mark a module in a way so show that
- * it is compatible with the server it is being loaded into.
- *
- * This file is intended to be included into modules that wish to load
- * themselves into the backend. All they need to do is include this header
- * into one of the source files and include the line:
- *
- * PG_MODULE_MAGIC;
- *
- * The trailing semi-colon is optional. To work with versions of PostgreSQL
- * that do not support this, you may put an #ifdef/endif block around it.
- *
- * Note, there is space available, particularly in the bitfield part. If it
- * turns out that a change has happened within a major release that would
- * require all modules to be recompiled, just setting one unused bit there
- * will do the trick.
- *
- * Originally written by Martijn van Oosterhout <kleptog@svana.org>
- *
- * $PostgreSQL: pgsql/src/include/pgmagic.h,v 1.1 2006/05/30 14:09:32 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-
-#ifndef PGMAGIC_H
-#define PGMAGIC_H
-
-#include "c.h"
-
-/* The main structure in which the magic is stored. the length field is used
- * to detect major changes */
-
-typedef struct {
- int len;
- int version;
- int magic;
-} Pg_magic_struct;
-
-/* Declare the module magic function. It needs to be a function as the dlsym
- * in the backend is only guarenteed to work on functions, not data */
-
-typedef Pg_magic_struct *(*PGModuleMagicFunction) (void);
-
-#define PG_MAGIC_FUNCTION_NAME Pg_magic_func
-#define PG_MAGIC_FUNCTION_NAME_STRING "Pg_magic_func"
-
-#define PG_MODULE_MAGIC \
-extern DLLIMPORT Pg_magic_struct *PG_MAGIC_FUNCTION_NAME(void); \
-Pg_magic_struct * \
-PG_MAGIC_FUNCTION_NAME(void) \
-{ \
- static Pg_magic_struct Pg_magic_data = PG_MODULE_MAGIC_DATA; \
- return &Pg_magic_data; \
-}
-
- /* Common user adjustable constants */
-#define PG_MODULE_MAGIC_CONST \
- ((INDEX_MAX_KEYS << 0) + \
- (FUNC_MAX_ARGS << 8) + \
- (NAMEDATALEN << 16))
-
-/* Finally, the actual data block */
-#define PG_MODULE_MAGIC_DATA \
-{ \
- sizeof(Pg_magic_struct), \
- PG_VERSION_NUM / 100, /* Major version of postgres */ \
- PG_MODULE_MAGIC_CONST, /* Constants users can configure */ \
-}
-
-#endif /* PGMAGIC_H */