Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Modules/mmapmodule.c

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Modules/md5module.c ('k') | Modules/_pickle.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 / Author: Sam Rushing <rushing@nightmare.com> 2 / Author: Sam Rushing <rushing@nightmare.com>
3 / Hacked for Unix by AMK 3 / Hacked for Unix by AMK
4 / $Id$ 4 / $Id$
5 5
6 / Modified to support mmap with offset - to map a 'window' of a file 6 / Modified to support mmap with offset - to map a 'window' of a file
7 / Author: Yotam Medini yotamm@mellanox.co.il 7 / Author: Yotam Medini yotamm@mellanox.co.il
8 / 8 /
9 / mmapmodule.cpp -- map a view of a file into memory 9 / mmapmodule.cpp -- map a view of a file into memory
10 / 10 /
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 #endif 1155 #endif
1156 #ifdef HAVE_FSTAT 1156 #ifdef HAVE_FSTAT
1157 # ifdef __VMS 1157 # ifdef __VMS
1158 /* on OpenVMS we must ensure that all bytes are written to the file */ 1158 /* on OpenVMS we must ensure that all bytes are written to the file */
1159 if (fd != -1) { 1159 if (fd != -1) {
1160 fsync(fd); 1160 fsync(fd);
1161 } 1161 }
1162 # endif 1162 # endif
1163 if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { 1163 if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
1164 if (map_size == 0) { 1164 if (map_size == 0) {
1165 off_t calc_size;
1166 if (offset >= st.st_size) { 1165 if (offset >= st.st_size) {
1167 PyErr_SetString(PyExc_ValueError, 1166 PyErr_SetString(PyExc_ValueError,
1168 "mmap offset is greater than file size"); 1167 "mmap offset is greater than file size");
1169 return NULL; 1168 return NULL;
1170 } 1169 }
1171 calc_size = st.st_size - offset; 1170 off_t calc_size = st.st_size - offset;
1172 map_size = calc_size; 1171 map_size = calc_size;
1173 if (map_size != calc_size) { 1172 if (map_size != calc_size) {
1174 PyErr_SetString(PyExc_ValueError, 1173 PyErr_SetString(PyExc_ValueError,
1175 "mmap length is too large"); 1174 "mmap length is too large");
1176 return NULL; 1175 return NULL;
1177 } 1176 }
1178 } else if (offset + (size_t)map_size > st.st_size) { 1177 } else if (offset + (size_t)map_size > st.st_size) {
1179 PyErr_SetString(PyExc_ValueError, 1178 PyErr_SetString(PyExc_ValueError,
1180 "mmap length is greater than file size"); 1179 "mmap length is greater than file size");
1181 return NULL; 1180 return NULL;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 1501
1503 setint(dict, "PAGESIZE", (long)my_getpagesize()); 1502 setint(dict, "PAGESIZE", (long)my_getpagesize());
1504 1503
1505 setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity()); 1504 setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity());
1506 1505
1507 setint(dict, "ACCESS_READ", ACCESS_READ); 1506 setint(dict, "ACCESS_READ", ACCESS_READ);
1508 setint(dict, "ACCESS_WRITE", ACCESS_WRITE); 1507 setint(dict, "ACCESS_WRITE", ACCESS_WRITE);
1509 setint(dict, "ACCESS_COPY", ACCESS_COPY); 1508 setint(dict, "ACCESS_COPY", ACCESS_COPY);
1510 return module; 1509 return module;
1511 } 1510 }
OLDNEW
« no previous file with comments | « Modules/md5module.c ('k') | Modules/_pickle.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+