SetProcessingMode(BootstrapProcessing);
IgnoreSystemIndexes = true;
+ RegisterBuiltinShmemCallbacks();
+
InitializeMaxBackends();
/*
*/
LocalProcessControlFile(false);
+ RegisterBuiltinShmemCallbacks();
+
/*
* Reload any libraries that were preloaded by the postmaster. Since we
* exec'd this process, those libraries didn't come along with us; but we
*/
ApplyLauncherRegister();
+ /*
+ * Register the shared memory needs of all core subsystems.
+ */
+ RegisterBuiltinShmemCallbacks();
+
/*
* process any libraries that should be preloaded at postmaster start
*/
#include "storage/procsignal.h"
#include "storage/shmem_internal.h"
#include "storage/sinvaladt.h"
+#include "storage/subsystems.h"
#include "utils/guc.h"
#include "utils/injection_point.h"
#include "utils/wait_event.h"
shmem_startup_hook();
}
+/*
+ * Early initialization of various subsystems, giving them a chance to
+ * register their shared memory needs before the shared memory segment is
+ * allocated.
+ */
+void
+RegisterBuiltinShmemCallbacks(void)
+{
+ /*
+ * Call RegisterShmemCallbacks(...) on each subsystem listed in
+ * subsystemslist.h
+ */
+#define PG_SHMEM_SUBSYSTEM(subsystem_callbacks) \
+ RegisterShmemCallbacks(&(subsystem_callbacks));
+
+#include "storage/subsystemlist.h"
+
+#undef PG_SHMEM_SUBSYSTEM
+}
+
/*
* Initialize various subsystems, setting up their data structures in
* shared memory.
* );
* }
*
- * Register the callbacks by calling RegisterShmemCallbacks(&MyShmemCallbacks)
- * in the extension's _PG_init() function.
+ * In builtin PostgreSQL code, add the callbacks to the list in
+ * src/include/storage/subsystemlist.h. In an add-in module, you can register
+ * the callbacks by calling RegisterShmemCallbacks(&MyShmemCallbacks) in the
+ * extension's _PG_init() function.
*
* Lifecycle
* ---------
/* read control file (error checking and contains config ) */
LocalProcessControlFile(false);
+ /* Register the shared memory needs of all core subsystems. */
+ RegisterBuiltinShmemCallbacks();
+
/*
* process any libraries that should be preloaded at postmaster start
*/
/* ipci.c */
extern PGDLLIMPORT shmem_startup_hook_type shmem_startup_hook;
+extern void RegisterBuiltinShmemCallbacks(void);
extern Size CalculateShmemSize(void);
extern void CreateSharedMemoryAndSemaphores(void);
#ifdef EXEC_BACKEND
--- /dev/null
+/*---------------------------------------------------------------------------
+ * subsystemlist.h
+ *
+ * List of initialization callbacks of built-in subsystems. This is kept in
+ * its own source file for possible use by automatic tools.
+ * PG_SHMEM_SUBSYSTEM is defined in the callers depending on how the list is
+ * used.
+ *
+ * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/storage/subsystemlist.h
+ *---------------------------------------------------------------------------
+ */
+
+/* there is deliberately not an #ifndef SUBSYSTEMLIST_H here */
+
+/*
+ * Note: there are some inter-dependencies between these, so the order of some
+ * of these matter.
+ */
+
+/* TODO: empty for now */
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * subsystems.h
+ * Provide extern declarations for all the built-in subsystem callbacks
+ *
+ *
+ * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/storage/subsystems.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef SUBSYSTEMS_H
+#define SUBSYSTEMS_H
+
+#include "storage/shmem.h"
+
+/*
+ * Extern declarations of all the built-in subsystem callbacks
+ *
+ * The actual list is in subsystemlist.h, so that the same list can be used
+ * for other purposes.
+ */
+#define PG_SHMEM_SUBSYSTEM(callbacks) \
+ extern const ShmemCallbacks callbacks;
+#include "storage/subsystemlist.h"
+#undef PG_SHMEM_SUBSYSTEM
+
+#endif /* SUBSYSTEMS_H */
test "$f" = src/include/postmaster/proctypelist.h && continue
test "$f" = src/include/regex/regerrs.h && continue
test "$f" = src/include/storage/lwlocklist.h && continue
+ test "$f" = src/include/storage/subsystemlist.h && continue
test "$f" = src/include/tcop/cmdtaglist.h && continue
test "$f" = src/interfaces/ecpg/preproc/c_kwlist.h && continue
test "$f" = src/interfaces/ecpg/preproc/ecpg_kwlist.h && continue