Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
de143efa
Commit
de143efa
authored
Mar 16, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3690 from libgit2/cmn/pool-limit
win32: choose the page size as our value for the page size
parents
77394a27
87c18197
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
9 deletions
+41
-9
src/indexer.c
+4
-4
src/posix.c
+7
-0
src/posix.h
+1
-0
src/unix/map.c
+5
-0
src/win32/map.c
+24
-5
No files found.
src/indexer.c
View file @
de143efa
...
...
@@ -449,7 +449,7 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
static
int
write_at
(
git_indexer
*
idx
,
const
void
*
data
,
git_off_t
offset
,
size_t
size
)
{
git_file
fd
=
idx
->
pack
->
mwf
.
fd
;
size_t
page_size
;
size_t
mmap_alignment
;
size_t
page_offset
;
git_off_t
page_start
;
unsigned
char
*
map_data
;
...
...
@@ -458,11 +458,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
assert
(
data
&&
size
);
if
((
error
=
git__
page_size
(
&
page_size
))
<
0
)
if
((
error
=
git__
mmap_alignment
(
&
mmap_alignment
))
<
0
)
return
error
;
/* the offset needs to be at the
beginning of the a page boundary
*/
page_offset
=
offset
%
page_size
;
/* the offset needs to be at the
mmap boundary for the platform
*/
page_offset
=
offset
%
mmap_alignment
;
page_start
=
offset
-
page_offset
;
if
((
error
=
p_mmap
(
&
map
,
page_offset
+
size
,
GIT_PROT_WRITE
,
GIT_MAP_SHARED
,
fd
,
page_start
))
<
0
)
...
...
src/posix.c
View file @
de143efa
...
...
@@ -224,6 +224,13 @@ int git__page_size(size_t *page_size)
return
0
;
}
int
git__mmap_alignment
(
size_t
*
alignment
)
{
/* dummy; here we don't need any alignment anyway */
*
alignment
=
4096
;
return
0
;
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
{
...
...
src/posix.h
View file @
de143efa
...
...
@@ -109,6 +109,7 @@ extern int p_getcwd(char *buffer_out, size_t size);
extern
int
p_rename
(
const
char
*
from
,
const
char
*
to
);
extern
int
git__page_size
(
size_t
*
page_size
);
extern
int
git__mmap_alignment
(
size_t
*
page_size
);
/**
* Platform-dependent methods
...
...
src/unix/map.c
View file @
de143efa
...
...
@@ -24,6 +24,11 @@ int git__page_size(size_t *page_size)
return
0
;
}
int
git__mmap_alignment
(
size_t
*
alignment
)
{
return
git__page_size
(
alignment
);
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
{
int
mprot
=
PROT_READ
;
...
...
src/win32/map.c
View file @
de143efa
...
...
@@ -17,22 +17,41 @@ static DWORD get_page_size(void)
if
(
!
page_size
)
{
GetSystemInfo
(
&
sys
);
page_size
=
sys
.
dw
AllocationGranularity
;
page_size
=
sys
.
dw
PageSize
;
}
return
page_size
;
}
static
DWORD
get_allocation_granularity
(
void
)
{
static
DWORD
granularity
;
SYSTEM_INFO
sys
;
if
(
!
granularity
)
{
GetSystemInfo
(
&
sys
);
granularity
=
sys
.
dwAllocationGranularity
;
}
return
granularity
;
}
int
git__page_size
(
size_t
*
page_size
)
{
*
page_size
=
get_page_size
();
return
0
;
}
int
git__mmap_alignment
(
size_t
*
page_size
)
{
*
page_size
=
get_allocation_granularity
();
return
0
;
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
{
HANDLE
fh
=
(
HANDLE
)
_get_osfhandle
(
fd
);
DWORD
page_size
=
get_page_size
();
DWORD
alignment
=
get_allocation_granularity
();
DWORD
fmap_prot
=
0
;
DWORD
view_prot
=
0
;
DWORD
off_low
=
0
;
...
...
@@ -62,12 +81,12 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
if
(
prot
&
GIT_PROT_READ
)
view_prot
|=
FILE_MAP_READ
;
page_start
=
(
offset
/
page_size
)
*
page_size
;
page_start
=
(
offset
/
alignment
)
*
alignment
;
page_offset
=
offset
-
page_start
;
if
(
page_offset
!=
0
)
{
/* offset must be multiple of
page size
*/
if
(
page_offset
!=
0
)
{
/* offset must be multiple of
the allocation granularity
*/
errno
=
EINVAL
;
giterr_set
(
GITERR_OS
,
"Failed to mmap. Offset must be multiple of
page size
"
);
giterr_set
(
GITERR_OS
,
"Failed to mmap. Offset must be multiple of
allocation granularity
"
);
return
-
1
;
}
...
...
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