diff options
author | mplayer-svn <svn@mplayerhq.hu> | 2012-03-04 14:37:31 +0000 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-03 01:52:40 +0200 |
commit | bbc9fccd46de31bacdf132762a7c0d1f8a4caf53 (patch) | |
tree | 6890f6648aac93605336a76d7bc5d236e8ea4446 /osdep | |
parent | 0dce860f6c74df1c10351bd8bbbdcc406236925e (diff) | |
download | mpv-bbc9fccd46de31bacdf132762a7c0d1f8a4caf53.tar.bz2 mpv-bbc9fccd46de31bacdf132762a7c0d1f8a4caf53.tar.xz |
cache2: allow cache sizes up to 4 TB
Remove variable that is only assigned but never used.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34791 b3059339-0415-0410-9bf9-f77b7e298cf2
Allow using a cache size of up to 4 TB.
Obviously anything close to 4 GB will always fail
on 32 bit systems.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34792 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace off_t by int64_t in cache code.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34793 b3059339-0415-0410-9bf9-f77b7e298cf2
Remove casts that are no longer necessary.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34794 b3059339-0415-0410-9bf9-f77b7e298cf2
Fix header file after r34793.
Patch by Stephen Sheldon, sfsheldo gmail com.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34802 b3059339-0415-0410-9bf9-f77b7e298cf2
Put #include <inttypes.h> into the header file where it should be.
Reported by Stephen Sheldon, sfsheldo gmail com.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34798 b3059339-0415-0410-9bf9-f77b7e298cf2
Correct r34798.
The header only needs stdint.h while the C file needs inttypes.h.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34799 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/shmem.c | 20 | ||||
-rw-r--r-- | osdep/shmem.h | 6 |
2 files changed, 17 insertions, 9 deletions
diff --git a/osdep/shmem.c b/osdep/shmem.c index 02140b5756..56b5b301b5 100644 --- a/osdep/shmem.c +++ b/osdep/shmem.c @@ -36,6 +36,7 @@ #endif #include <sys/socket.h> #include <fcntl.h> +#include <inttypes.h> #include "mp_msg.h" @@ -56,16 +57,21 @@ static int shmem_type=0; -void* shmem_alloc(int size){ +void* shmem_alloc(int64_t size){ void* p; static int devzero = -1; +if (size > SIZE_MAX) { + mp_msg(MSGT_OSDEP, MSGL_FATAL, + "Shared memory allocation larger than system max. allocation size.\n"); + return NULL; +} while(1){ switch(shmem_type){ case 0: // ========= MAP_ANON|MAP_SHARED ========== #ifdef MAP_ANON p=mmap(0,size,PROT_READ|PROT_WRITE,MAP_ANON|MAP_SHARED,-1,0); if(p==MAP_FAILED) break; // failed - mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %d bytes allocated using mmap anon (%p)\n",size,p); + mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %"PRId64" bytes allocated using mmap anon (%p)\n",size,p); return p; #else // system does not support MAP_ANON at all (e.g. solaris 2.5.1/2.6), just fail @@ -76,7 +82,7 @@ while(1){ if (devzero == -1 && (devzero = open("/dev/zero", O_RDWR, 0)) == -1) break; p=mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,devzero,0); if(p==MAP_FAILED) break; // failed - mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %d bytes allocated using mmap /dev/zero (%p)\n",size,p); + mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %"PRId64" bytes allocated using mmap /dev/zero (%p)\n",size,p); return p; case 2: { // ========= shmget() ========== #ifdef HAVE_SHM @@ -93,7 +99,7 @@ while(1){ if (shmdt(p) == -1) perror ("shmdt()"); break; } - mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %d bytes allocated using SHM (%p)\n",size,p); + mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %"PRId64" bytes allocated using SHM (%p)\n",size,p); return p; #else mp_msg(MSGT_OSDEP, MSGL_FATAL, "shmem: no SHM support was compiled in!\n"); @@ -102,19 +108,19 @@ while(1){ } default: mp_msg(MSGT_OSDEP, MSGL_FATAL, - "FATAL: Cannot allocate %d bytes of shared memory :(\n",size); + "FATAL: Cannot allocate %"PRId64" bytes of shared memory :(\n",size); return NULL; } ++shmem_type; } } -void shmem_free(void* p,int size){ +void shmem_free(void* p,int64_t size){ switch(shmem_type){ case 0: case 1: if(munmap(p,size)) { - mp_msg(MSGT_OSDEP, MSGL_ERR, "munmap failed on %p %d bytes: %s\n", + mp_msg(MSGT_OSDEP, MSGL_ERR, "munmap failed on %p %"PRId64" bytes: %s\n", p,size,strerror(errno)); } break; diff --git a/osdep/shmem.h b/osdep/shmem.h index 7696e45281..1aa8382f09 100644 --- a/osdep/shmem.h +++ b/osdep/shmem.h @@ -19,7 +19,9 @@ #ifndef MPLAYER_SHMEM_H #define MPLAYER_SHMEM_H -void* shmem_alloc(int size); -void shmem_free(void* p,int size); +#include <stdint.h> + +void* shmem_alloc(int64_t size); +void shmem_free(void* p,int64_t size); #endif /* MPLAYER_SHMEM_H */ |