1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Modify dynamic shared memory code to use Size rather than uint64.

This is more consistent with what we do elsewhere.
This commit is contained in:
Robert Haas
2013-10-28 12:12:06 -04:00
parent c737a2e564
commit d2aecaea15
4 changed files with 35 additions and 40 deletions

View File

@ -69,24 +69,24 @@
#include "utils/memutils.h"
#ifdef USE_DSM_POSIX
static bool dsm_impl_posix(dsm_op op, dsm_handle handle, uint64 request_size,
static bool dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address,
uint64 *mapped_size, int elevel);
Size *mapped_size, int elevel);
#endif
#ifdef USE_DSM_SYSV
static bool dsm_impl_sysv(dsm_op op, dsm_handle handle, uint64 request_size,
static bool dsm_impl_sysv(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address,
uint64 *mapped_size, int elevel);
Size *mapped_size, int elevel);
#endif
#ifdef USE_DSM_WINDOWS
static bool dsm_impl_windows(dsm_op op, dsm_handle handle, uint64 request_size,
static bool dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address,
uint64 *mapped_size, int elevel);
Size *mapped_size, int elevel);
#endif
#ifdef USE_DSM_MMAP
static bool dsm_impl_mmap(dsm_op op, dsm_handle handle, uint64 request_size,
static bool dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address,
uint64 *mapped_size, int elevel);
Size *mapped_size, int elevel);
#endif
static int errcode_for_dynamic_shared_memory(void);
@ -156,19 +156,14 @@ int dynamic_shared_memory_type;
*-----
*/
bool
dsm_impl_op(dsm_op op, dsm_handle handle, uint64 request_size,
void **impl_private, void **mapped_address, uint64 *mapped_size,
dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address, Size *mapped_size,
int elevel)
{
Assert(op == DSM_OP_CREATE || op == DSM_OP_RESIZE || request_size == 0);
Assert((op != DSM_OP_CREATE && op != DSM_OP_ATTACH) ||
(*mapped_address == NULL && *mapped_size == 0));
if (request_size > (size_t) -1)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("requested shared memory size overflows size_t")));
switch (dynamic_shared_memory_type)
{
#ifdef USE_DSM_POSIX
@ -241,8 +236,8 @@ dsm_impl_can_resize(void)
* a different shared memory implementation.
*/
static bool
dsm_impl_posix(dsm_op op, dsm_handle handle, uint64 request_size,
void **impl_private, void **mapped_address, uint64 *mapped_size,
dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address, Size *mapped_size,
int elevel)
{
char name[64];
@ -407,8 +402,8 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, uint64 request_size,
* those are not supported everywhere.
*/
static bool
dsm_impl_sysv(dsm_op op, dsm_handle handle, uint64 request_size,
void **impl_private, void **mapped_address, uint64 *mapped_size,
dsm_impl_sysv(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address, Size *mapped_size,
int elevel)
{
key_t key;
@ -612,9 +607,9 @@ dsm_impl_sysv(dsm_op op, dsm_handle handle, uint64 request_size,
* when the process containing the reference exits.
*/
static bool
dsm_impl_windows(dsm_op op, dsm_handle handle, uint64 request_size,
dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address,
uint64 *mapped_size, int elevel)
Size *mapped_size, int elevel)
{
char *address;
HANDLE hmap;
@ -780,8 +775,8 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, uint64 request_size,
* directory to a ramdisk to avoid this problem, if available.
*/
static bool
dsm_impl_mmap(dsm_op op, dsm_handle handle, uint64 request_size,
void **impl_private, void **mapped_address, uint64 *mapped_size,
dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address, Size *mapped_size,
int elevel)
{
char name[64];
@ -892,7 +887,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, uint64 request_size,
*/
while (success && remaining > 0)
{
uint64 goal = remaining;
Size goal = remaining;
if (goal > ZBUFFER_SIZE)
goal = ZBUFFER_SIZE;