Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
aaa3a0ca
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aaa3a0ca
编写于
11月 13, 2002
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split MemSet into three parts to constant comparisons can be optimized
away by the compiler; used by palloc0.
上级
266c3679
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
25 deletion
+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
未找到文件。
src/backend/utils/mmgr/mcxt.c
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录