*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.74 2005/08/08 03:11:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.75 2005/08/12 05:05:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
BufferDesc *BufferDescriptors;
-Block *BufferBlockPointers;
+char *BufferBlocks;
int32 *PrivateRefCount;
-static char *BufferBlocks;
-
/* statistics counters */
long int ReadBufferCount;
long int ReadLocalBufferCount;
void
InitBufferPoolAccess(void)
{
- char *block;
- int i;
-
/*
* Allocate and zero local arrays of per-buffer info.
*/
- BufferBlockPointers = (Block *) calloc(NBuffers,
- sizeof(*BufferBlockPointers));
PrivateRefCount = (int32 *) calloc(NBuffers,
sizeof(*PrivateRefCount));
-
- /*
- * Construct addresses for the individual buffer data blocks. We do
- * this just to speed up the BufferGetBlock() macro. (Since the
- * addresses should be the same in every backend, we could inherit
- * this data from the postmaster --- but in the EXEC_BACKEND case
- * that doesn't work.)
- */
- block = BufferBlocks;
- for (i = 0; i < NBuffers; i++)
- {
- BufferBlockPointers[i] = (Block) block;
- block += BLCKSZ;
- }
}
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.192 2005/08/08 19:44:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.193 2005/08/12 05:05:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* Note: these two macros only work on shared buffers, not local ones! */
-#define BufHdrGetBlock(bufHdr) BufferBlockPointers[(bufHdr)->buf_id]
+#define BufHdrGetBlock(bufHdr) ((Block) (BufferBlocks + ((Size) (bufHdr)->buf_id) * BLCKSZ))
#define BufferGetLSN(bufHdr) (*((XLogRecPtr*) BufHdrGetBlock(bufHdr)))
/* Note: this macro only works on local buffers, not shared ones! */
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.94 2005/08/08 03:12:16 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.95 2005/08/12 05:05:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern int bgwriter_all_maxpages;
/* in buf_init.c */
-extern DLLIMPORT Block *BufferBlockPointers;
+extern DLLIMPORT char *BufferBlocks;
extern DLLIMPORT int32 *PrivateRefCount;
/* in localbuf.c */
BufferIsLocal(buffer) ? \
LocalBufferBlockPointers[-(buffer) - 1] \
: \
- BufferBlockPointers[(buffer) - 1] \
+ (Block) (BufferBlocks + ((Size) ((buffer) - 1)) * BLCKSZ) \
)
/*