Merge "EGL: do not use sparse files for shader"

This commit is contained in:
Jean-Baptiste Queru 2012-08-20 08:54:42 -07:00 committed by android code review
commit 6f89ebded6

View File

@ -241,19 +241,11 @@ void egl_cache_t::saveBlobCacheLocked() {
} }
size_t fileSize = headerSize + cacheSize; size_t fileSize = headerSize + cacheSize;
if (ftruncate(fd, fileSize) == -1) {
ALOGE("error setting cache file size: %s (%d)", strerror(errno),
errno);
close(fd);
unlink(fname);
return;
}
uint8_t* buf = reinterpret_cast<uint8_t*>(mmap(NULL, fileSize, uint8_t* buf = new uint8_t [fileSize];
PROT_WRITE, MAP_SHARED, fd, 0)); if (!buf) {
if (buf == MAP_FAILED) { ALOGE("error allocating buffer for cache contents: %s (%d)",
ALOGE("error mmaping cache file: %s (%d)", strerror(errno), strerror(errno), errno);
errno);
close(fd); close(fd);
unlink(fname); unlink(fname);
return; return;
@ -264,7 +256,7 @@ void egl_cache_t::saveBlobCacheLocked() {
if (err != OK) { if (err != OK) {
ALOGE("error writing cache contents: %s (%d)", strerror(-err), ALOGE("error writing cache contents: %s (%d)", strerror(-err),
-err); -err);
munmap(buf, fileSize); delete [] buf;
close(fd); close(fd);
unlink(fname); unlink(fname);
return; return;
@ -275,7 +267,16 @@ void egl_cache_t::saveBlobCacheLocked() {
uint32_t* crc = reinterpret_cast<uint32_t*>(buf + 4); uint32_t* crc = reinterpret_cast<uint32_t*>(buf + 4);
*crc = crc32c(buf + headerSize, cacheSize); *crc = crc32c(buf + headerSize, cacheSize);
munmap(buf, fileSize); if (write(fd, buf, fileSize) == -1) {
ALOGE("error writing cache file: %s (%d)", strerror(errno),
errno);
delete [] buf;
close(fd);
unlink(fname);
return;
}
delete [] buf;
fchmod(fd, S_IRUSR); fchmod(fd, S_IRUSR);
close(fd); close(fd);
} }