Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
common
Compare revisions
c928d1428f024e5f5fcd2f93fc18e637ca303d2e to 9e27a44f2ed632c6e5d1c74093e7f8fd32af36d9
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
sip/common
Select target project
No results found
9e27a44f2ed632c6e5d1c74093e7f8fd32af36d9
Select Git revision
Branches
f16
master
2 results
Swap
Target
sip/common
Select target project
sip/common
1 result
c928d1428f024e5f5fcd2f93fc18e637ca303d2e
Select Git revision
Branches
f16
master
2 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source
1
Alignment-related fix
· 9e27a44f
D-AIRY
authored
Jul 11, 2020
9e27a44f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
MemAlloc.h
+9
-12
9 additions, 12 deletions
MemAlloc.h
stack.h
+2
-8
2 additions, 8 deletions
stack.h
with
11 additions
and
20 deletions
MemAlloc.h
View file @
9e27a44f
...
...
@@ -35,18 +35,10 @@ struct UsageStats
ULONG
ulAllocMem
;
//Количество занятой элементами памяти
};
#ifndef WIN64
# define MEMALLOC_DEFAULT_ALIGN 4
# define MEMALLOC_DEFAULT_ALIGN_STR "4"
#else
# define MEMALLOC_DEFAULT_ALIGN 16
# define MEMALLOC_DEFAULT_ALIGN_STR "16"
#endif
template
<
typename
T
,
int
SizeBlock
=
256
,
int
SizePage
=
16
,
const
int
alignBy
=
MEMALLOC_DEFAULT_ALIGN
>
template
<
typename
T
,
int
SizeBlock
=
256
,
int
SizePage
=
16
,
const
int
alignBy
=
alignof
(
T
)>
class
MemAlloc
{
static_assert
(
alignBy
%
MEMALLOC_DEFAULT_ALIGN
==
0
&&
alignBy
>=
MEMALLOC_DEFAULT_ALIGN
,
"alignBy should be multiply of
"
MEMALLOC_DEFAULT_ALIGN_STR
);
static_assert
(
alignBy
%
alignof
(
T
)
==
0
&&
alignBy
>=
alignof
(
T
)
,
"alignBy should be multiply of
alignof(T)"
);
#undef MEMALLOC_DEFAULT_ALIGN
#undef MEMALLOC_DEFAULT_ALIGN_STR
...
...
@@ -57,11 +49,16 @@ class MemAlloc
union
{
UINT
IsFree
;
UINT
_padding
[
alignBy
/
4
];
byte
_padding
[
alignBy
];
};
T
data
;
};
#pragma pack(pop)
struct
AlignTest
{
char
start
;
T
end
;
};
struct
MemBlock
{
MemCell
*
mem
;
...
...
@@ -76,7 +73,7 @@ public:
MemAlloc
()
:
memblocks
(
NULL
),
NumCurBlock
(
0
),
NumCurBlockCount
(
0
)
{
assert
((
intptr_t
)(
&
(((
MemCell
*
)
0
)
->
data
))
-
(
intptr_t
)(((
MemCell
*
)
0
)
->
_padding
)
==
alignBy
&&
"Invalid align specified!"
);
// static_
assert((intptr_t)(&(((
AlignTest
*)0)->
end
)) - (intptr_t)(((
AlignTest*)0)->start
) == alignBy
,
"Invalid align specified!");
AllocBlock
();
}
...
...
This diff is collapsed.
Click to expand it.
stack.h
View file @
9e27a44f
...
...
@@ -14,13 +14,7 @@ See the license in LICENSE
# pragma warning(disable:4715)
#endif
#ifndef WIN64
# define STACK_DEFAULT_ALIGN 4
#else
# define STACK_DEFAULT_ALIGN 16
#endif
template
<
typename
T
,
int
pageSize
=
256
,
int
alignBy
=
STACK_DEFAULT_ALIGN
>
template
<
typename
T
,
int
pageSize
=
256
,
int
alignBy
=
alignof
(
T
)>
#undef STACK_DEFAULT_ALIGN
class
Stack
{
...
...
@@ -30,7 +24,7 @@ class Stack
StackNode
*
Parent
;
};
MemAlloc
<
StackNode
,
pageSize
,
16
,
alignBy
>
Data
;
MemAlloc
<
StackNode
,
pageSize
>
Data
;
int
SP
;
StackNode
*
CurrentNode
;
...
...
This diff is collapsed.
Click to expand it.