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
177a29d8
Commit
177a29d8
authored
Oct 27, 2014
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit 'refs/pull/2366/head' of github.com:libgit2/libgit2
parents
aabe1e5a
62e562f9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
24 deletions
+29
-24
src/indexer.c
+8
-4
src/map.h
+0
-1
src/pool.c
+5
-11
src/pool.h
+0
-2
src/posix.c
+3
-2
src/posix.h
+2
-0
src/unix/map.c
+8
-2
src/win32/map.c
+3
-2
No files found.
src/indexer.c
View file @
177a29d8
...
...
@@ -429,17 +429,21 @@ 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
;
long
page_size
=
git__page_size
();
git_off_t
page_start
,
page_offset
;
size_t
page_size
;
size_t
page_offset
;
git_off_t
page_start
;
unsigned
char
*
map_data
;
git_map
map
;
int
error
;
assert
(
data
&&
size
);
if
((
error
=
git__page_size
(
&
page_size
))
<
0
)
return
error
;
/* the offset needs to be at the beginning of the a page boundary */
page_
start
=
(
offset
/
page_size
)
*
page_size
;
page_
offset
=
offset
-
page_star
t
;
page_
offset
=
offset
%
page_size
;
page_
start
=
offset
-
page_offse
t
;
if
((
error
=
p_mmap
(
&
map
,
page_offset
+
size
,
GIT_PROT_WRITE
,
GIT_MAP_SHARED
,
fd
,
page_start
))
<
0
)
return
error
;
...
...
src/map.h
View file @
177a29d8
...
...
@@ -42,6 +42,5 @@ typedef struct { /* memory mapped buffer */
extern
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
);
extern
int
p_munmap
(
git_map
*
map
);
extern
long
git__page_size
(
void
);
#endif
/* INCLUDE_map_h__ */
src/pool.c
View file @
177a29d8
#include "pool.h"
#include "posix.h"
#ifndef GIT_WIN32
#include <unistd.h>
#endif
...
...
@@ -305,17 +306,10 @@ uint32_t git_pool__system_page_size(void)
static
uint32_t
size
=
0
;
if
(
!
size
)
{
#ifdef GIT_WIN32
SYSTEM_INFO
info
;
GetSystemInfo
(
&
info
);
size
=
(
uint32_t
)
info
.
dwPageSize
;
#elif defined(__amigaos4__)
size
=
(
uint32_t
)
4096
;
/* 4K as there is no global value we can query */
#else
size
=
(
uint32_t
)
sysconf
(
_SC_PAGE_SIZE
);
#endif
size
-=
2
*
sizeof
(
void
*
);
/* allow space for malloc overhead */
size_t
page_size
;
if
(
git__page_size
(
&
page_size
)
<
0
)
page_size
=
4096
;
size
=
page_size
-
2
*
sizeof
(
void
*
);
/* allow space for malloc overhead */
}
return
size
;
...
...
src/pool.h
View file @
177a29d8
...
...
@@ -143,8 +143,6 @@ extern uint32_t git_pool__full_pages(git_pool *pool);
extern
bool
git_pool__ptr_in_pool
(
git_pool
*
pool
,
void
*
ptr
);
extern
uint32_t
git_pool__system_page_size
(
void
);
extern
uint32_t
git_pool__suggest_items_per_page
(
uint32_t
item_size
);
#endif
src/posix.c
View file @
177a29d8
...
...
@@ -206,10 +206,11 @@ int p_write(git_file fd, const void *buf, size_t cnt)
#include "map.h"
long
git__page_size
(
void
)
int
git__page_size
(
size_t
*
page_size
)
{
/* dummy; here we don't need any alignment anyway */
return
4096
;
*
page_size
=
4096
;
return
0
;
}
...
...
src/posix.h
View file @
177a29d8
...
...
@@ -108,6 +108,8 @@ extern int p_creat(const char *path, mode_t mode);
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
);
/**
* Platform-dependent methods
*/
...
...
src/unix/map.c
View file @
177a29d8
...
...
@@ -13,9 +13,15 @@
#include <unistd.h>
#include <errno.h>
long
git__page_size
(
void
)
int
git__page_size
(
size_t
*
page_size
)
{
return
sysconf
(
_SC_PAGE_SIZE
);
long
sc_page_size
=
sysconf
(
_SC_PAGE_SIZE
);
if
(
sc_page_size
<
0
)
{
giterr_set_str
(
GITERR_OS
,
"Can't determine system page size"
);
return
-
1
;
}
*
page_size
=
(
size_t
)
sc_page_size
;
return
0
;
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
...
...
src/win32/map.c
View file @
177a29d8
...
...
@@ -23,9 +23,10 @@ static DWORD get_page_size(void)
return
page_size
;
}
long
git__page_size
(
void
)
int
git__page_size
(
size_t
*
page_size
)
{
return
(
long
)
get_page_size
();
*
page_size
=
get_page_size
();
return
0
;
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
...
...
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