aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/buf_init.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-30 01:39:08 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-30 01:39:08 +0000
commit680b7357ce850c28d06997be793aee18f72434ba (patch)
tree79c9ab2ef4ac257301510d9ca6bc37b8c6dfba8b /src/backend/storage/buffer/buf_init.c
parent9f20852f878dbacc0412d909d48fcbd779d7779e (diff)
downloadpostgresql-680b7357ce850c28d06997be793aee18f72434ba.tar.gz
postgresql-680b7357ce850c28d06997be793aee18f72434ba.zip
Rearrange bufmgr header files so that buf_internals.h need not be
included by everything that includes bufmgr.h --- it's supposed to be internals, after all, not part of the API! This fixes the conflict against FreeBSD headers reported by Rosenman, by making it unnecessary for s_lock.h to be included by plperl.c.
Diffstat (limited to 'src/backend/storage/buffer/buf_init.c')
-rw-r--r--src/backend/storage/buffer/buf_init.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c
index 0fda21972f6..19b71933d76 100644
--- a/src/backend/storage/buffer/buf_init.c
+++ b/src/backend/storage/buffer/buf_init.c
@@ -8,17 +8,17 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.38 2000/11/28 23:27:55 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.39 2000/11/30 01:39:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
+#include "postgres.h"
+
#include <sys/types.h>
#include <sys/file.h>
#include <math.h>
#include <signal.h>
-#include "postgres.h"
-
#include "catalog/catalog.h"
#include "executor/execdebug.h"
#include "miscadmin.h"
@@ -54,7 +54,7 @@ int Lookup_List_Descriptor;
int Num_Descriptors;
BufferDesc *BufferDescriptors;
-BufferBlock BufferBlocks;
+Block *BufferBlockPointers;
long *PrivateRefCount; /* also used in freelist.c */
bits8 *BufferLocks; /* flag bits showing locks I have set */
@@ -126,7 +126,7 @@ long int LocalBufferFlushCount;
/*
- * Initialize module:
+ * Initialize module: called once during shared-memory initialization
*
* should calculate size of pool dynamically based on the
* amount of available memory.
@@ -134,6 +134,7 @@ long int LocalBufferFlushCount;
void
InitBufferPool(void)
{
+ char *BufferBlocks;
bool foundBufs,
foundDescs;
int i;
@@ -159,24 +160,22 @@ InitBufferPool(void)
ShmemInitStruct("Buffer Descriptors",
Num_Descriptors * sizeof(BufferDesc), &foundDescs);
- BufferBlocks = (BufferBlock)
+ BufferBlocks = (char *)
ShmemInitStruct("Buffer Blocks",
NBuffers * BLCKSZ, &foundBufs);
if (foundDescs || foundBufs)
{
-
/* both should be present or neither */
Assert(foundDescs && foundBufs);
-
}
else
{
BufferDesc *buf;
- unsigned long block;
+ char *block;
buf = BufferDescriptors;
- block = (unsigned long) BufferBlocks;
+ block = BufferBlocks;
/*
* link the buffers into a circular, doubly-linked list to
@@ -210,11 +209,21 @@ InitBufferPool(void)
SpinRelease(BufMgrLock);
+ BufferBlockPointers = (Block *) calloc(NBuffers, sizeof(Block));
PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8));
BufferTagLastDirtied = (BufferTag *) calloc(NBuffers, sizeof(BufferTag));
BufferBlindLastDirtied = (BufferBlindId *) calloc(NBuffers, sizeof(BufferBlindId));
BufferDirtiedByMe = (bool *) calloc(NBuffers, sizeof(bool));
+
+ /*
+ * Convert shmem offsets into addresses as seen by this process.
+ * This is just to speed up the BufferGetBlock() macro.
+ */
+ for (i = 0; i < NBuffers; i++)
+ {
+ BufferBlockPointers[i] = (Block) MAKE_PTR(BufferDescriptors[i].data);
+ }
}
/* -----------------------------------------------------