Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
aaa3a0ca
Commit
aaa3a0ca
authored
Nov 13, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split MemSet into three parts to constant comparisons can be optimized
away by the compiler; used by palloc0.
parent
266c3679
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
25 deletions
+39
-25
src/backend/utils/mmgr/mcxt.c
src/backend/utils/mmgr/mcxt.c
+4
-4
src/include/c.h
src/include/c.h
+28
-18
src/include/utils/palloc.h
src/include/utils/palloc.h
+7
-3
No files found.
src/backend/utils/mmgr/mcxt.c
View file @
aaa3a0ca
...
...
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.3
5 2002/11/10 02:17:25
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.3
6 2002/11/13 00:37:06
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -453,14 +453,14 @@ MemoryContextAlloc(MemoryContext context, Size size)
}
/*
* MemoryContextAlloc
Zero
* MemoryContextAlloc
Palloc0
* Like MemoryContextAlloc, but clears allocated memory
*
* We could just call MemoryContextAlloc then clear the memory, but this
* function is called too many times, so we have a separate version.
*/
void
*
MemoryContextAlloc
Zero
(
MemoryContext
context
,
Size
size
)
MemoryContextAlloc
Palloc0
(
MemoryContext
context
,
Size
size
)
{
void
*
ret
;
...
...
@@ -471,7 +471,7 @@ MemoryContextAllocZero(MemoryContext context, Size size)
(
unsigned
long
)
size
);
ret
=
(
*
context
->
methods
->
alloc
)
(
context
,
size
);
MemSet
(
ret
,
0
,
size
);
MemSet
Loop
(
ret
,
0
,
size
);
return
ret
;
}
...
...
src/include/c.h
View file @
aaa3a0ca
...
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.13
1 2002/11/11 03:02:19
momjian Exp $
* $Id: c.h,v 1.13
2 2002/11/13 00:37:06
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -577,26 +577,36 @@ typedef NameData *Name;
* memset() functions. More research needs to be done, perhaps with
* platform-specific MEMSET_LOOP_LIMIT values or tests in configure.
*
* MemSet has been split into two parts so MemSetTest can be optimized
* away for constant 'val' and 'len'. This is used by palloc0().
*
* Note, arguments are evaluated more than once.
*
* bjm 2002-10-08
*/
#define MemSet(start, val, len) \
do \
{ \
int32 * _start = (int32 *) (start); \
int _val = (val); \
Size _len = (len); \
#define MemSetTest(val, len) \
( ((len) & INT_ALIGN_MASK) == 0 && \
(len) <= MEMSET_LOOP_LIMIT && \
(val) == 0 )
#define MemSetLoop(start, val, len) \
do \
{ \
int32 * _start = (int32 *) (start); \
int32 * _stop = (int32 *) ((char *) _start + (len)); \
\
if ((( ((long) _start) | _len) & INT_ALIGN_MASK) == 0 && \
_val == 0 && \
_len <= MEMSET_LOOP_LIMIT) \
{ \
int32 * _stop = (int32 *) ((char *) _start + _len); \
while (_start < _stop) \
*_start++ = 0; \
} \
else \
memset((char *) _start, _val, _len); \
} while (0)
while (_start < _stop) \
*_start++ = 0; \
} while (0)
#define MemSet(start, val, len) \
do \
{ \
if (MemSetTest(val, len) && ((long)(start) & INT_ALIGN_MASK) == 0 ) \
MemSetLoop(start, val, len); \
else \
memset((char *)(start), (val), (len)); \
} while (0)
#define MEMSET_LOOP_LIMIT 1024
...
...
src/include/utils/palloc.h
View file @
aaa3a0ca
...
...
@@ -21,7 +21,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: palloc.h,v 1.2
2 2002/11/10 02:17:25
momjian Exp $
* $Id: palloc.h,v 1.2
3 2002/11/13 00:37:06
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -46,11 +46,15 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext;
* Fundamental memory-allocation operations (more are in utils/memutils.h)
*/
extern
void
*
MemoryContextAlloc
(
MemoryContext
context
,
Size
size
);
extern
void
*
MemoryContextAlloc
Zero
(
MemoryContext
context
,
Size
size
);
extern
void
*
MemoryContextAlloc
Palloc0
(
MemoryContext
context
,
Size
size
);
#define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz))
#define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz))
/* We assume palloc() is already int-aligned */
#define palloc0(sz) \
( MemSetTest(0, (sz)) ? \
MemoryContextAllocPalloc0(CurrentMemoryContext, (sz)) : \
memset(palloc(sz), 0, (sz)))
extern
void
pfree
(
void
*
pointer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment