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
90490113
Commit
90490113
authored
Jun 10, 2012
by
Chris Young
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic mmap/munmap compatiblity
parent
c9f79972
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
src/map.h
+4
-0
src/pack.c
+2
-2
src/unix/map.c
+16
-3
No files found.
src/map.h
View file @
90490113
...
@@ -23,6 +23,10 @@
...
@@ -23,6 +23,10 @@
#define GIT_MAP_TYPE 0xf
#define GIT_MAP_TYPE 0xf
#define GIT_MAP_FIXED 0x10
#define GIT_MAP_FIXED 0x10
#ifdef __amigaos4__
#define MAP_FAILED 0
#endif
typedef
struct
{
/* memory mapped buffer */
typedef
struct
{
/* memory mapped buffer */
void
*
data
;
/* data bytes */
void
*
data
;
/* data bytes */
size_t
len
;
/* data length */
size_t
len
;
/* data length */
...
...
src/pack.c
View file @
90490113
...
@@ -215,7 +215,7 @@ static int packfile_unpack_header1(
...
@@ -215,7 +215,7 @@ static int packfile_unpack_header1(
unsigned
shift
;
unsigned
shift
;
unsigned
long
size
,
c
;
unsigned
long
size
,
c
;
unsigned
long
used
=
0
;
unsigned
long
used
=
0
;
printf
(
"[pack 218] buf = %lx, used = %ld, len = %ld
\n
"
,
buf
,
used
,
len
);
c
=
buf
[
used
++
];
c
=
buf
[
used
++
];
*
type
=
(
c
>>
4
)
&
7
;
*
type
=
(
c
>>
4
)
&
7
;
size
=
c
&
15
;
size
=
c
&
15
;
...
@@ -261,7 +261,7 @@ int git_packfile_unpack_header(
...
@@ -261,7 +261,7 @@ int git_packfile_unpack_header(
base
=
git_mwindow_open
(
mwf
,
w_curs
,
*
curpos
,
20
,
&
left
);
base
=
git_mwindow_open
(
mwf
,
w_curs
,
*
curpos
,
20
,
&
left
);
if
(
base
==
NULL
)
if
(
base
==
NULL
)
return
GIT_EBUFS
;
return
GIT_EBUFS
;
printf
(
"[pack 264] base = %lx, mwf = %lx
\n
"
,
base
,
mwf
);
ret
=
packfile_unpack_header1
(
&
used
,
size_p
,
type_p
,
base
,
left
);
ret
=
packfile_unpack_header1
(
&
used
,
size_p
,
type_p
,
base
,
left
);
git_mwindow_close
(
w_curs
);
git_mwindow_close
(
w_curs
);
if
(
ret
==
GIT_EBUFS
)
if
(
ret
==
GIT_EBUFS
)
...
...
src/unix/map.c
View file @
90490113
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off_t
offset
)
{
{
#ifndef __amigaos4__
int
mprot
=
0
;
int
mprot
=
0
;
int
mflag
=
0
;
int
mflag
=
0
;
...
@@ -25,6 +24,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
...
@@ -25,6 +24,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
out
->
data
=
NULL
;
out
->
data
=
NULL
;
out
->
len
=
0
;
out
->
len
=
0
;
#ifndef __amigaos4__
if
(
prot
&
GIT_PROT_WRITE
)
if
(
prot
&
GIT_PROT_WRITE
)
mprot
=
PROT_WRITE
;
mprot
=
PROT_WRITE
;
else
if
(
prot
&
GIT_PROT_READ
)
else
if
(
prot
&
GIT_PROT_READ
)
...
@@ -36,21 +36,34 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
...
@@ -36,21 +36,34 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
mflag
=
MAP_PRIVATE
;
mflag
=
MAP_PRIVATE
;
out
->
data
=
mmap
(
NULL
,
len
,
mprot
,
mflag
,
fd
,
offset
);
out
->
data
=
mmap
(
NULL
,
len
,
mprot
,
mflag
,
fd
,
offset
);
#else
if
((
prot
&
GIT_PROT_WRITE
)
&&
((
flags
&
GIT_MAP_TYPE
)
==
GIT_MAP_SHARED
))
{
printf
(
"Trying to map shared-writeable file!!!
\n
"
);
if
(
out
->
data
=
malloc
(
len
))
{
lseek
(
fd
,
offset
,
SEEK_SET
);
p_read
(
fd
,
out
->
data
,
len
);
}
}
#endif
if
(
!
out
->
data
||
out
->
data
==
MAP_FAILED
)
{
if
(
!
out
->
data
||
out
->
data
==
MAP_FAILED
)
{
giterr_set
(
GITERR_OS
,
"Failed to mmap. Could not write data"
);
giterr_set
(
GITERR_OS
,
"Failed to mmap. Could not write data"
);
return
-
1
;
return
-
1
;
}
}
out
->
len
=
len
;
out
->
len
=
len
;
#endif
return
0
;
return
0
;
}
}
int
p_munmap
(
git_map
*
map
)
int
p_munmap
(
git_map
*
map
)
{
{
#ifndef __amigaos4__
assert
(
map
!=
NULL
);
assert
(
map
!=
NULL
);
#ifndef __amigaos4__
munmap
(
map
->
data
,
map
->
len
);
munmap
(
map
->
data
,
map
->
len
);
#else
free
(
map
->
data
);
#endif
#endif
return
0
;
return
0
;
}
}
...
...
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