mirror of
https://github.com/postgres/postgres.git
synced 2026-03-11 02:34:28 -04:00
This moves/renames some of the functions defined in pg_numa.c: * pg_numa_get_pagesize() is renamed to pg_get_shmem_pagesize(), and moved to src/backend/storage/ipc/shmem.c. The new name better reflects that the page size is not related to NUMA, and it's specifically about the page size used for the main shared memory segment. * move pg_numa_available() to src/backend/storage/ipc/shmem.c, i.e. into the backend (which more appropriate for functions callable from SQL). While at it, improve the comment to explain what page size it returns. * remove unnecessary includes from src/port/pg_numa.c, adding unnecessary dependencies (src/port should be suitable for frontent). These were either leftovers or unnecessary thanks to the other changes in this commit. This eliminates unnecessary dependencies on backend symbols, which we don't want in src/port. Reported-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> https://postgr.es/m/CALdSSPi5fj0a7UG7Fmw2cUD1uWuckU_e8dJ+6x-bJEokcSXzqA@mail.gmail.com
64 lines
2.3 KiB
C
64 lines
2.3 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* shmem.h
|
|
* shared memory management structures
|
|
*
|
|
* Historical note:
|
|
* A long time ago, Postgres' shared memory region was allowed to be mapped
|
|
* at a different address in each process, and shared memory "pointers" were
|
|
* passed around as offsets relative to the start of the shared memory region.
|
|
* That is no longer the case: each process must map the shared memory region
|
|
* at the same address. This means shared memory pointers can be passed
|
|
* around directly between different processes.
|
|
*
|
|
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/storage/shmem.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef SHMEM_H
|
|
#define SHMEM_H
|
|
|
|
#include "storage/spin.h"
|
|
#include "utils/hsearch.h"
|
|
|
|
|
|
/* shmem.c */
|
|
extern PGDLLIMPORT slock_t *ShmemLock;
|
|
struct PGShmemHeader; /* avoid including storage/pg_shmem.h here */
|
|
extern void InitShmemAccess(struct PGShmemHeader *seghdr);
|
|
extern void InitShmemAllocation(void);
|
|
extern void *ShmemAlloc(Size size);
|
|
extern void *ShmemAllocNoError(Size size);
|
|
extern void *ShmemAllocUnlocked(Size size);
|
|
extern bool ShmemAddrIsValid(const void *addr);
|
|
extern void InitShmemIndex(void);
|
|
extern HTAB *ShmemInitHash(const char *name, long init_size, long max_size,
|
|
HASHCTL *infoP, int hash_flags);
|
|
extern void *ShmemInitStruct(const char *name, Size size, bool *foundPtr);
|
|
extern Size add_size(Size s1, Size s2);
|
|
extern Size mul_size(Size s1, Size s2);
|
|
|
|
extern PGDLLIMPORT Size pg_get_shmem_pagesize(void);
|
|
|
|
/* ipci.c */
|
|
extern void RequestAddinShmemSpace(Size size);
|
|
|
|
/* size constants for the shmem index table */
|
|
/* max size of data structure string name */
|
|
#define SHMEM_INDEX_KEYSIZE (48)
|
|
/* estimated size of the shmem index table (not a hard limit) */
|
|
#define SHMEM_INDEX_SIZE (64)
|
|
|
|
/* this is a hash bucket in the shmem index table */
|
|
typedef struct
|
|
{
|
|
char key[SHMEM_INDEX_KEYSIZE]; /* string name */
|
|
void *location; /* location in shared mem */
|
|
Size size; /* # bytes requested for the structure */
|
|
Size allocated_size; /* # bytes actually allocated */
|
|
} ShmemIndexEnt;
|
|
|
|
#endif /* SHMEM_H */
|