Thread: [Mplayerxp-cvslog] SF.net SVN: mplayerxp:[390] mplayerxp/osdep
Brought to you by:
olov
From: <nic...@us...> - 2012-11-17 13:57:03
|
Revision: 390 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=390&view=rev Author: nickols_k Date: 2012-11-17 13:56:54 +0000 (Sat, 17 Nov 2012) Log Message: ----------- more c++ sources Modified Paths: -------------- mplayerxp/osdep/Makefile mplayerxp/osdep/fastmemcpy.h Added Paths: ----------- mplayerxp/osdep/aclib.cpp mplayerxp/osdep/aclib_template.h Removed Paths: ------------- mplayerxp/osdep/aclib.c mplayerxp/osdep/aclib_template.c Modified: mplayerxp/osdep/Makefile =================================================================== --- mplayerxp/osdep/Makefile 2012-11-17 10:42:51 UTC (rev 389) +++ mplayerxp/osdep/Makefile 2012-11-17 13:56:54 UTC (rev 390) @@ -3,8 +3,8 @@ LIBNAME = libosdep.a -SRCS=aclib.c -CXXSRCS=mplib.cpp mp_malloc.cpp getch2.cpp timer-lx.cpp timer.cpp cpudetect.cpp shmem.cpp get_path.cpp +SRCS= +CXXSRCS=mplib.cpp mp_malloc.cpp getch2.cpp timer-lx.cpp timer.cpp cpudetect.cpp shmem.cpp get_path.cpp aclib.cpp OBJS=$(SRCS:.c=.o) CXXOBJS=$(CXXSRCS:.cpp=.o) Deleted: mplayerxp/osdep/aclib.c =================================================================== --- mplayerxp/osdep/aclib.c 2012-11-17 10:42:51 UTC (rev 389) +++ mplayerxp/osdep/aclib.c 2012-11-17 13:56:54 UTC (rev 390) @@ -1,98 +0,0 @@ -#include <stdio.h> -#include <pthread.h> -#include "mp_config.h" -#include "mplayerxp.h" -#define MSGT_CLASS MSGT_GLOBAL -#include "mp_msg.h" - -#if defined(USE_FASTMEMCPY) -#include "fastmemcpy.h" -#include "osdep/cpudetect.h" - -#define BLOCK_SIZE 4096 -#define CONFUSION_FACTOR 0 - -#define PVECTOR_ACCEL_H "aclib_template.c" -#include "pvector/pvector_inc.h" - -/* - aclib - advanced C library ;) - This file contains functions which improve and expand standard C-library - see aclib_template.c ... this file only contains runtime cpu detection and config options stuff - runtime cpu detection by michael niedermayer (mic...@gm...) is under GPL -*/ - -static any_t* init_fast_memcpy(any_t* to, const any_t* from, size_t len) -{ -#ifdef __SSE2__ - if(gCpuCaps.hasSSE2) - { - MSG_V("Using SSE2 optimized memcpy\n"); - fast_memcpy_ptr = fast_memcpy_SSE2; - } - else -#endif -#ifndef __x86_64__ -#ifdef __SSE__ - if(gCpuCaps.hasMMX2) - { - MSG_V("Using MMX2 optimized memcpy\n"); - fast_memcpy_ptr = fast_memcpy_SSE; - } - else -#endif -//#ifdef __MMX__ -// if(gCpuCaps.hasMMX) -// { -// MSG_V("Using MMX optimized memcpy\n"); -// fast_memcpy_ptr = fast_memcpy_MMX; -// } -// else -//#endif -#endif - { - MSG_V("Using generic memcpy\n"); - fast_memcpy_ptr = memcpy; /* prior to mmx we use the standart memcpy */ - } - return (*fast_memcpy_ptr)(to,from,len); -} - -static any_t* init_stream_copy(any_t* to, const any_t* from, size_t len) -{ -#ifdef __SSE2__ - if(gCpuCaps.hasSSE2) - { - MSG_V("Using SSE2 optimized agpcpy\n"); - fast_stream_copy_ptr = fast_stream_copy_SSE2; - } -#endif -#ifndef __x86_64__ -#ifdef __SSE__ - if(gCpuCaps.hasMMX2) - { - MSG_V("Using MMX2 optimized agpcpy\n"); - fast_stream_copy_ptr = fast_stream_copy_SSE; - } - else -#endif -//#ifdef __MMX__ -// if(gCpuCaps.hasMMX) -// { -// MSG_V("Using MMX optimized agpcpy\n"); -// fast_stream_copy_ptr = fast_stream_copy_MMX; -// } -// else -//#endif -#endif - { - MSG_V("Using generic optimized agpcpy\n"); - fast_stream_copy_ptr = memcpy; /* prior to mmx we use the standart memcpy */ - } - return (*fast_stream_copy_ptr)(to,from,len); -} - -any_t*(*fast_memcpy_ptr)(any_t* to, const any_t* from, size_t len) = init_fast_memcpy; -any_t*(*fast_stream_copy_ptr)(any_t* to, const any_t* from, size_t len) = init_stream_copy; - -#endif /* use fastmemcpy */ - Copied: mplayerxp/osdep/aclib.cpp (from rev 369, mplayerxp/osdep/aclib.c) =================================================================== --- mplayerxp/osdep/aclib.cpp (rev 0) +++ mplayerxp/osdep/aclib.cpp 2012-11-17 13:56:54 UTC (rev 390) @@ -0,0 +1,98 @@ +#include <stdio.h> +#include <pthread.h> +#include "mp_config.h" +#include "mplayerxp.h" +#define MSGT_CLASS MSGT_GLOBAL +#include "mp_msg.h" + +#if defined(USE_FASTMEMCPY) +#include "fastmemcpy.h" +#include "osdep/cpudetect.h" + +#define BLOCK_SIZE 4096 +#define CONFUSION_FACTOR 0 + +#define PVECTOR_ACCEL_H "aclib_template.h" +#include "pvector/pvector_inc.h" + +/* + aclib - advanced C library ;) + This file contains functions which improve and expand standard C-library + see aclib_template.c ... this file only contains runtime cpu detection and config options stuff + runtime cpu detection by michael niedermayer (mic...@gm...) is under GPL +*/ + +static any_t* init_fast_memcpy(any_t* to, const any_t* from, size_t len) +{ +#ifdef __SSE2__ + if(gCpuCaps.hasSSE2) + { + MSG_V("Using SSE2 optimized memcpy\n"); + fast_memcpy_ptr = fast_memcpy_SSE2; + } + else +#endif +#ifndef __x86_64__ +#ifdef __SSE__ + if(gCpuCaps.hasMMX2) + { + MSG_V("Using MMX2 optimized memcpy\n"); + fast_memcpy_ptr = fast_memcpy_SSE; + } + else +#endif +//#ifdef __MMX__ +// if(gCpuCaps.hasMMX) +// { +// MSG_V("Using MMX optimized memcpy\n"); +// fast_memcpy_ptr = fast_memcpy_MMX; +// } +// else +//#endif +#endif + { + MSG_V("Using generic memcpy\n"); + fast_memcpy_ptr = memcpy; /* prior to mmx we use the standart memcpy */ + } + return (*fast_memcpy_ptr)(to,from,len); +} + +static any_t* init_stream_copy(any_t* to, const any_t* from, size_t len) +{ +#ifdef __SSE2__ + if(gCpuCaps.hasSSE2) + { + MSG_V("Using SSE2 optimized agpcpy\n"); + fast_stream_copy_ptr = fast_stream_copy_SSE2; + } +#endif +#ifndef __x86_64__ +#ifdef __SSE__ + if(gCpuCaps.hasMMX2) + { + MSG_V("Using MMX2 optimized agpcpy\n"); + fast_stream_copy_ptr = fast_stream_copy_SSE; + } + else +#endif +//#ifdef __MMX__ +// if(gCpuCaps.hasMMX) +// { +// MSG_V("Using MMX optimized agpcpy\n"); +// fast_stream_copy_ptr = fast_stream_copy_MMX; +// } +// else +//#endif +#endif + { + MSG_V("Using generic optimized agpcpy\n"); + fast_stream_copy_ptr = memcpy; /* prior to mmx we use the standart memcpy */ + } + return (*fast_stream_copy_ptr)(to,from,len); +} + +any_t*(*fast_memcpy_ptr)(any_t* to, const any_t* from, size_t len) = init_fast_memcpy; +any_t*(*fast_stream_copy_ptr)(any_t* to, const any_t* from, size_t len) = init_stream_copy; + +#endif /* use fastmemcpy */ + Deleted: mplayerxp/osdep/aclib_template.c =================================================================== --- mplayerxp/osdep/aclib_template.c 2012-11-17 10:42:51 UTC (rev 389) +++ mplayerxp/osdep/aclib_template.c 2012-11-17 13:56:54 UTC (rev 390) @@ -1,179 +0,0 @@ -/* - aclib - advanced C library ;) - This file contains functions which improve and expand standard C-library -*/ -#include "pvector/pvector.h" - -#ifdef HAVE_INT_PVECTOR -/* for small memory blocks (<256 bytes) this version is faster */ -#undef small_memcpy -#ifdef __x86_64__ -#define small_memcpy(to,from,n)\ -{\ -register unsigned long int siz;\ -register unsigned long int dummy;\ - siz=n&0x7; n>>=3;\ - if(siz)\ -__asm__ __volatile__(\ - "rep; movsb"\ - :"=&D"(to), "=&S"(from), "=&c"(dummy)\ -/* It's most portable way to notify compiler */\ -/* that edi, esi and ecx are clobbered in asm block. */\ -/* Thanks to A'rpi for hint!!! */\ - :"0" (to), "1" (from),"2" (siz)\ - : "memory","cc");\ - if(n)\ -__asm__ __volatile__(\ - "rep; movsq"\ - :"=&D"(to), "=&S"(from), "=&c"(dummy)\ -/* It's most portable way to notify compiler */\ -/* that edi, esi and ecx are clobbered in asm block. */\ -/* Thanks to A'rpi for hint!!! */\ - :"0" (to), "1" (from),"2" (n)\ - : "memory","cc");\ -} -#else -#define small_memcpy(to,from,n)\ -{\ -register unsigned long int dummy;\ -__asm__ __volatile__(\ - "rep; movsb"\ - :"=&D"(to), "=&S"(from), "=&c"(dummy)\ -/* It's most portable way to notify compiler */\ -/* that edi, esi and ecx are clobbered in asm block. */\ -/* Thanks to A'rpi for hint!!! */\ - :"0" (to), "1" (from),"2" (n)\ - : "memory","cc");\ -} -#endif - -#undef MIN_LEN -#if defined( OPTIMIZE_MMX ) && !defined( OPTIMIZE_MMX2 ) -#define MIN_LEN 0x800 /* 2K blocks. Was found experimentally */ -#else -#define MIN_LEN _ivec_size()*8 -#endif - -#undef FAST_MEMORY_COPY -#define FAST_MEMORY_COPY(to,from, len)\ -{\ - any_t*retval;\ - const unsigned char *cfrom=from;\ - unsigned char *tto=to;\ - const unsigned block_size = _ivec_size()*8;\ - __ivec iarr[8];\ - size_t i;\ - retval = to;\ - if(!len) return retval;\ -\ - _ivec_prefetch(&cfrom[0]);\ - _ivec_prefetch(&cfrom[32]);\ - _ivec_prefetch(&cfrom[64]);\ - _ivec_prefetch(&cfrom[96]);\ - _ivec_prefetch(&cfrom[128]);\ - _ivec_prefetch(&cfrom[160]);\ - _ivec_prefetch(&cfrom[192]);\ - _ivec_prefetch(&cfrom[224]);\ - _ivec_prefetch(&cfrom[256]);\ -\ - if(len >= MIN_LEN)\ - {\ - register unsigned long int delta;\ - /* Align destinition to cache-line size -boundary */\ - delta = ((unsigned long int)tto)&(gCpuCaps.cl_size-1);\ - if(delta) {\ - delta=gCpuCaps.cl_size-delta;\ - len -= delta;\ - small_memcpy(tto, cfrom, delta);\ - }\ - i = len/block_size;\ - len&=(block_size-1);\ - /*\ - This algorithm is top effective when the code consequently\ - reads and writes blocks which have size of cache line.\ - Size of cache line is processor-dependent.\ - It will, however, be a minimum of 32 bytes on any processors.\ - It would be better to have a number of instructions which\ - perform reading and writing to be multiple to a number of\ - processor's decoders, but it's not always possible.\ - */\ - if(((unsigned long)cfrom) & 15)\ - /* if SRC is misaligned */\ - for(; i>0; i--)\ - {\ - _ivec_prefetch(&cfrom[_ivec_size()*8]);\ - _ivec_prefetch(&cfrom[_ivec_size()*8+32]);\ - iarr[0] = _ivec_loadu(&cfrom[_ivec_size()*0]);\ - iarr[1] = _ivec_loadu(&cfrom[_ivec_size()*1]);\ - iarr[2] = _ivec_loadu(&cfrom[_ivec_size()*2]);\ - iarr[3] = _ivec_loadu(&cfrom[_ivec_size()*3]);\ - iarr[4] = _ivec_loadu(&cfrom[_ivec_size()*4]);\ - iarr[5] = _ivec_loadu(&cfrom[_ivec_size()*5]);\ - iarr[6] = _ivec_loadu(&cfrom[_ivec_size()*6]);\ - iarr[7] = _ivec_loadu(&cfrom[_ivec_size()*7]);\ - MEM_STORE(&tto[_ivec_size()*0],iarr[0]);\ - MEM_STORE(&tto[_ivec_size()*1],iarr[1]);\ - MEM_STORE(&tto[_ivec_size()*2],iarr[2]);\ - MEM_STORE(&tto[_ivec_size()*3],iarr[3]);\ - MEM_STORE(&tto[_ivec_size()*4],iarr[4]);\ - MEM_STORE(&tto[_ivec_size()*5],iarr[5]);\ - MEM_STORE(&tto[_ivec_size()*6],iarr[6]);\ - MEM_STORE(&tto[_ivec_size()*7],iarr[7]);\ - cfrom+=block_size;\ - tto+=block_size;\ - }\ - else\ - /* if SRC is aligned */\ - for(; i>0; i--)\ - {\ - _ivec_prefetch(&cfrom[_ivec_size()*8]);\ - _ivec_prefetch(&cfrom[_ivec_size()*8+32]);\ - iarr[0] = _ivec_loada(&cfrom[_ivec_size()*0]);\ - iarr[1] = _ivec_loada(&cfrom[_ivec_size()*1]);\ - iarr[2] = _ivec_loada(&cfrom[_ivec_size()*2]);\ - iarr[3] = _ivec_loada(&cfrom[_ivec_size()*3]);\ - iarr[4] = _ivec_loada(&cfrom[_ivec_size()*4]);\ - iarr[5] = _ivec_loada(&cfrom[_ivec_size()*5]);\ - iarr[6] = _ivec_loada(&cfrom[_ivec_size()*6]);\ - iarr[7] = _ivec_loada(&cfrom[_ivec_size()*7]);\ - MEM_STORE(&tto[_ivec_size()*0],iarr[0]);\ - MEM_STORE(&tto[_ivec_size()*1],iarr[1]);\ - MEM_STORE(&tto[_ivec_size()*2],iarr[2]);\ - MEM_STORE(&tto[_ivec_size()*3],iarr[3]);\ - MEM_STORE(&tto[_ivec_size()*4],iarr[4]);\ - MEM_STORE(&tto[_ivec_size()*5],iarr[5]);\ - MEM_STORE(&tto[_ivec_size()*6],iarr[6]);\ - MEM_STORE(&tto[_ivec_size()*7],iarr[7]);\ - cfrom+=block_size;\ - tto+=block_size;\ - }\ - MEM_SFENCE\ - _ivec_empty();\ - }\ - /*\ - * Now do the tail of the block\ - */\ - if(len) small_memcpy(tto, cfrom, len);\ - return retval;\ -} - -#undef MEM_STORE -#undef MEM_SFENCE -#define MEM_STORE _ivec_stream -#define MEM_SFENCE _ivec_sfence(); -static inline any_t* PVECTOR_RENAME(fast_stream_copy)(any_t* to, const any_t* from, size_t len) -{ - MSG_DBG3("fast_stream_copy(%p, %p, %u) [cl_size=%u]\n",to,from,len,gCpuCaps.cl_size); - FAST_MEMORY_COPY(to,from,len); -} - -#undef MEM_STORE -#undef MEM_SFENCE -#define MEM_STORE _ivec_storea -#define MEM_SFENCE -static inline any_t* PVECTOR_RENAME(fast_memcpy)(any_t* to, const any_t* from, size_t len) -{ - MSG_DBG3("fast_memcpy(%p, %p, %u) [cl_size=%u]\n",to,from,len,gCpuCaps.cl_size); - FAST_MEMORY_COPY(to,from,len); -} -#endif Copied: mplayerxp/osdep/aclib_template.h (from rev 369, mplayerxp/osdep/aclib_template.c) =================================================================== --- mplayerxp/osdep/aclib_template.h (rev 0) +++ mplayerxp/osdep/aclib_template.h 2012-11-17 13:56:54 UTC (rev 390) @@ -0,0 +1,179 @@ +/* + aclib - advanced C library ;) + This file contains functions which improve and expand standard C-library +*/ +#include "pvector/pvector.h" + +#ifdef HAVE_INT_PVECTOR +/* for small memory blocks (<256 bytes) this version is faster */ +#undef small_memcpy +#ifdef __x86_64__ +#define small_memcpy(to,from,n)\ +{\ +register unsigned long int siz;\ +register unsigned long int dummy;\ + siz=n&0x7; n>>=3;\ + if(siz)\ +__asm__ __volatile__(\ + "rep; movsb"\ + :"=&D"(to), "=&S"(from), "=&c"(dummy)\ +/* It's most portable way to notify compiler */\ +/* that edi, esi and ecx are clobbered in asm block. */\ +/* Thanks to A'rpi for hint!!! */\ + :"0" (to), "1" (from),"2" (siz)\ + : "memory","cc");\ + if(n)\ +__asm__ __volatile__(\ + "rep; movsq"\ + :"=&D"(to), "=&S"(from), "=&c"(dummy)\ +/* It's most portable way to notify compiler */\ +/* that edi, esi and ecx are clobbered in asm block. */\ +/* Thanks to A'rpi for hint!!! */\ + :"0" (to), "1" (from),"2" (n)\ + : "memory","cc");\ +} +#else +#define small_memcpy(to,from,n)\ +{\ +register unsigned long int dummy;\ +__asm__ __volatile__(\ + "rep; movsb"\ + :"=&D"(to), "=&S"(from), "=&c"(dummy)\ +/* It's most portable way to notify compiler */\ +/* that edi, esi and ecx are clobbered in asm block. */\ +/* Thanks to A'rpi for hint!!! */\ + :"0" (to), "1" (from),"2" (n)\ + : "memory","cc");\ +} +#endif + +#undef MIN_LEN +#if defined( OPTIMIZE_MMX ) && !defined( OPTIMIZE_MMX2 ) +#define MIN_LEN 0x800 /* 2K blocks. Was found experimentally */ +#else +#define MIN_LEN _ivec_size()*8 +#endif + +#undef FAST_MEMORY_COPY +#define FAST_MEMORY_COPY(to,from, len)\ +{\ + any_t*retval;\ + const unsigned char *cfrom=(const unsigned char *)from;\ + unsigned char *tto=(unsigned char *)to;\ + const unsigned block_size = _ivec_size()*8;\ + __ivec iarr[8];\ + size_t i;\ + retval = to;\ + if(!len) return retval;\ +\ + _ivec_prefetch(&cfrom[0]);\ + _ivec_prefetch(&cfrom[32]);\ + _ivec_prefetch(&cfrom[64]);\ + _ivec_prefetch(&cfrom[96]);\ + _ivec_prefetch(&cfrom[128]);\ + _ivec_prefetch(&cfrom[160]);\ + _ivec_prefetch(&cfrom[192]);\ + _ivec_prefetch(&cfrom[224]);\ + _ivec_prefetch(&cfrom[256]);\ +\ + if(len >= MIN_LEN)\ + {\ + register unsigned long int delta;\ + /* Align destinition to cache-line size -boundary */\ + delta = ((unsigned long int)tto)&(gCpuCaps.cl_size-1);\ + if(delta) {\ + delta=gCpuCaps.cl_size-delta;\ + len -= delta;\ + small_memcpy(tto, cfrom, delta);\ + }\ + i = len/block_size;\ + len&=(block_size-1);\ + /*\ + This algorithm is top effective when the code consequently\ + reads and writes blocks which have size of cache line.\ + Size of cache line is processor-dependent.\ + It will, however, be a minimum of 32 bytes on any processors.\ + It would be better to have a number of instructions which\ + perform reading and writing to be multiple to a number of\ + processor's decoders, but it's not always possible.\ + */\ + if(((unsigned long)cfrom) & 15)\ + /* if SRC is misaligned */\ + for(; i>0; i--)\ + {\ + _ivec_prefetch(&cfrom[_ivec_size()*8]);\ + _ivec_prefetch(&cfrom[_ivec_size()*8+32]);\ + iarr[0] = _ivec_loadu(&cfrom[_ivec_size()*0]);\ + iarr[1] = _ivec_loadu(&cfrom[_ivec_size()*1]);\ + iarr[2] = _ivec_loadu(&cfrom[_ivec_size()*2]);\ + iarr[3] = _ivec_loadu(&cfrom[_ivec_size()*3]);\ + iarr[4] = _ivec_loadu(&cfrom[_ivec_size()*4]);\ + iarr[5] = _ivec_loadu(&cfrom[_ivec_size()*5]);\ + iarr[6] = _ivec_loadu(&cfrom[_ivec_size()*6]);\ + iarr[7] = _ivec_loadu(&cfrom[_ivec_size()*7]);\ + MEM_STORE(&tto[_ivec_size()*0],iarr[0]);\ + MEM_STORE(&tto[_ivec_size()*1],iarr[1]);\ + MEM_STORE(&tto[_ivec_size()*2],iarr[2]);\ + MEM_STORE(&tto[_ivec_size()*3],iarr[3]);\ + MEM_STORE(&tto[_ivec_size()*4],iarr[4]);\ + MEM_STORE(&tto[_ivec_size()*5],iarr[5]);\ + MEM_STORE(&tto[_ivec_size()*6],iarr[6]);\ + MEM_STORE(&tto[_ivec_size()*7],iarr[7]);\ + cfrom+=block_size;\ + tto+=block_size;\ + }\ + else\ + /* if SRC is aligned */\ + for(; i>0; i--)\ + {\ + _ivec_prefetch(&cfrom[_ivec_size()*8]);\ + _ivec_prefetch(&cfrom[_ivec_size()*8+32]);\ + iarr[0] = _ivec_loada(&cfrom[_ivec_size()*0]);\ + iarr[1] = _ivec_loada(&cfrom[_ivec_size()*1]);\ + iarr[2] = _ivec_loada(&cfrom[_ivec_size()*2]);\ + iarr[3] = _ivec_loada(&cfrom[_ivec_size()*3]);\ + iarr[4] = _ivec_loada(&cfrom[_ivec_size()*4]);\ + iarr[5] = _ivec_loada(&cfrom[_ivec_size()*5]);\ + iarr[6] = _ivec_loada(&cfrom[_ivec_size()*6]);\ + iarr[7] = _ivec_loada(&cfrom[_ivec_size()*7]);\ + MEM_STORE(&tto[_ivec_size()*0],iarr[0]);\ + MEM_STORE(&tto[_ivec_size()*1],iarr[1]);\ + MEM_STORE(&tto[_ivec_size()*2],iarr[2]);\ + MEM_STORE(&tto[_ivec_size()*3],iarr[3]);\ + MEM_STORE(&tto[_ivec_size()*4],iarr[4]);\ + MEM_STORE(&tto[_ivec_size()*5],iarr[5]);\ + MEM_STORE(&tto[_ivec_size()*6],iarr[6]);\ + MEM_STORE(&tto[_ivec_size()*7],iarr[7]);\ + cfrom+=block_size;\ + tto+=block_size;\ + }\ + MEM_SFENCE\ + _ivec_empty();\ + }\ + /*\ + * Now do the tail of the block\ + */\ + if(len) small_memcpy(tto, cfrom, len);\ + return retval;\ +} + +#undef MEM_STORE +#undef MEM_SFENCE +#define MEM_STORE _ivec_stream +#define MEM_SFENCE _ivec_sfence(); +static inline any_t* PVECTOR_RENAME(fast_stream_copy)(any_t* to, const any_t* from, size_t len) +{ + MSG_DBG3("fast_stream_copy(%p, %p, %u) [cl_size=%u]\n",to,from,len,gCpuCaps.cl_size); + FAST_MEMORY_COPY(to,from,len); +} + +#undef MEM_STORE +#undef MEM_SFENCE +#define MEM_STORE _ivec_storea +#define MEM_SFENCE +static inline any_t* PVECTOR_RENAME(fast_memcpy)(any_t* to, const any_t* from, size_t len) +{ + MSG_DBG3("fast_memcpy(%p, %p, %u) [cl_size=%u]\n",to,from,len,gCpuCaps.cl_size); + FAST_MEMORY_COPY(to,from,len); +} +#endif Modified: mplayerxp/osdep/fastmemcpy.h =================================================================== --- mplayerxp/osdep/fastmemcpy.h 2012-11-17 10:42:51 UTC (rev 389) +++ mplayerxp/osdep/fastmemcpy.h 2012-11-17 13:56:54 UTC (rev 390) @@ -25,8 +25,8 @@ for(i=0; i<height; i++) { stream_copy(dst, src, bytesPerLine); - src+= srcStride; - dst+= dstStride; + src=(char *)src+ srcStride; + dst=(char *)dst+ dstStride; } } @@ -44,8 +44,8 @@ for(i=0; i<height; i++) { memcpy(dst, src, bytesPerLine); - src+= srcStride; - dst+= dstStride; + src=(char *)src+ srcStride; + dst=(char *)dst+ dstStride; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-11-21 12:54:49
|
Revision: 421 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=421&view=rev Author: nickols_k Date: 2012-11-21 12:54:43 +0000 (Wed, 21 Nov 2012) Log Message: ----------- implement memaligned operator new Modified Paths: -------------- mplayerxp/osdep/mp_malloc.cpp mplayerxp/osdep/mplib.h Modified: mplayerxp/osdep/mp_malloc.cpp =================================================================== --- mplayerxp/osdep/mp_malloc.cpp 2012-11-21 09:34:59 UTC (rev 420) +++ mplayerxp/osdep/mp_malloc.cpp 2012-11-21 12:54:43 UTC (rev 421) @@ -542,6 +542,16 @@ return ptr; } -void SECURE_NAME2(_mp_free)(any_t* ptr) { +any_t* SECURE_NAME2(_mp_memalign)(size_t boundary,size_t size) { + any_t* ptr; + ptr = mp_memalign(boundary,size); + if(!ptr) { + std::bad_alloc ba; + throw ba; + } + return ptr; +} + +void SECURE_NAME3(_mp_free)(any_t* ptr) { mp_free(ptr); } Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2012-11-21 09:34:59 UTC (rev 420) +++ mplayerxp/osdep/mplib.h 2012-11-21 12:54:43 UTC (rev 421) @@ -77,7 +77,8 @@ extern any_t* __FASTCALL__ SECURE_NAME0(_mp_malloc)(size_t size); extern any_t* __FASTCALL__ SECURE_NAME1(_mp_mallocz)(size_t size); -extern void __FASTCALL__ SECURE_NAME2(_mp_free)(any_t* ptr); +extern any_t* __FASTCALL__ SECURE_NAME2(_mp_memalign)(size_t boundary,size_t size); +extern void __FASTCALL__ SECURE_NAME3(_mp_free)(any_t* ptr); extern any_t* __FASTCALL__ SECURE_NAME9(rnd_fill)(any_t* buffer,size_t size); #ifdef __cplusplus } @@ -85,14 +86,17 @@ extern "C++" { #include <new> enum zeromemory_t{ zeromem=0 }; + enum alignedmemory_t{ alignmem=0 }; inline any_t *operator new(size_t size) { return SECURE_NAME0(_mp_malloc)(size); } inline any_t *operator new(size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } + inline any_t *operator new(size_t size,const alignedmemory_t&,size_t boundary) { return SECURE_NAME2(_mp_memalign)(boundary,size); } inline any_t *operator new(size_t size,const std::nothrow_t&) { return mp_malloc(size); } inline any_t *operator new[](size_t size) { return SECURE_NAME0(_mp_malloc)(size); } inline any_t *operator new[](size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } + inline any_t *operator new[](size_t size,const alignedmemory_t&,size_t boundary) { return SECURE_NAME2(_mp_memalign)(boundary,size); } inline any_t *operator new[](size_t size,const std::nothrow_t&) { return mp_malloc(size); } - inline void operator delete(any_t* p) { SECURE_NAME2(_mp_free)(p); } - inline void operator delete[](any_t* p) { SECURE_NAME2(_mp_free)(p); } + inline void operator delete(any_t* p) { SECURE_NAME3(_mp_free)(p); } + inline void operator delete[](any_t* p) { SECURE_NAME3(_mp_free)(p); } extern any_t* get_caller_address(unsigned num_caller=0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-27 09:50:10
|
Revision: 605 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=605&view=rev Author: nickols_k Date: 2012-12-27 09:50:00 +0000 (Thu, 27 Dec 2012) Log Message: ----------- fix pseudo-random filler Modified Paths: -------------- mplayerxp/osdep/get_path.cpp mplayerxp/osdep/mplib.cpp Modified: mplayerxp/osdep/get_path.cpp =================================================================== --- mplayerxp/osdep/get_path.cpp 2012-12-27 08:38:19 UTC (rev 604) +++ mplayerxp/osdep/get_path.cpp 2012-12-27 09:50:00 UTC (rev 605) @@ -9,11 +9,11 @@ #include "osdep_msg.h" namespace mpxp { std::string get_path(const std::string& filename){ - char *homedir; + const char *homedir; std::string rs; std::string config_dir = std::string("/.")+PROGNAME; - if ((homedir = ::getenv("HOME")) == NULL) return ""; + if ((homedir = ::getenv("HOME")) == NULL) throw "No 'HOME' environment found"; rs=std::string(homedir)+config_dir; if (!filename.empty()) rs+="/"+filename; mpxp_v<<"get_path('"<<filename<<"') -> "<<rs<<std::endl; Modified: mplayerxp/osdep/mplib.cpp =================================================================== --- mplayerxp/osdep/mplib.cpp 2012-12-27 08:38:19 UTC (rev 604) +++ mplayerxp/osdep/mplib.cpp 2012-12-27 09:50:00 UTC (rev 605) @@ -35,7 +35,7 @@ long filler; for(i=0;i<psize/sizeof(long);i++) { filler=::rand()&lo_mask; - filler=(reinterpret_cast<long>(buffer)&hi_mask)|lo_mask; + filler|=(reinterpret_cast<long>(buffer)&hi_mask); ((long *)buffer)[i]=::rand()%2?filler:0; } ::memset(&((char *)buffer)[psize],0,size-psize); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-23 12:51:14
|
Revision: 631 http://sourceforge.net/p/mplayerxp/code/631 Author: nickols_k Date: 2013-04-23 12:51:09 +0000 (Tue, 23 Apr 2013) Log Message: ----------- move mallocs into separate header Modified Paths: -------------- mplayerxp/osdep/mplib.h Added Paths: ----------- mplayerxp/osdep/mp_malloc.h Added: mplayerxp/osdep/mp_malloc.h =================================================================== --- mplayerxp/osdep/mp_malloc.h (rev 0) +++ mplayerxp/osdep/mp_malloc.h 2013-04-23 12:51:09 UTC (rev 631) @@ -0,0 +1,98 @@ +/* + * mp_malloc.h - Memory Protected malloc + * + * You can redistribute this file under terms and conditions + * of GNU General Public licence v3. + */ +#ifndef __MP_MALLOC_H_INCLUDED__ +#define __MP_MALLOC_H_INCLUDED__ 1 + +#include <string> + +#include <execinfo.h> +#include <stddef.h> +#include <sys/mman.h> +#include "mpxp_config.h" + +namespace mpxp { + + extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; + +#if defined ( ENABLE_PROFILE ) && (defined ( ARCH_X86 ) || defined( ARCH_X86_64 )) + inline unsigned long long int read_tsc( void ) { + unsigned long long int retval; + __asm __volatile ("rdtsc":"=A"(retval)::"memory"); + return retval; + } +#define PROFILE_RESET() (my_profile_total=0ULL) +#define PROFILE_START() { static int inited=0; if(!inited) { inited=1; my_profile_total=0ULL; } my_profile_start=read_tsc(); } +#define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=(my_profile_end-my_profile_start); printf(your_message" current=%llu total=%llu\n\t",(my_profile_end-my_profile_start),my_profile_total); } +#else +#define PROFILE_RESET() +#define PROFILE_START() +#define PROFILE_END(your_message) +#endif +/** Initializes randomizer for malloc. + * @param rnd_limit upper limit of random generator (recommened: 1000) + * @param every_nth_call how often call randimzer (recommened: 10) + * @note Pseudo-randomizing memory objects makes memory + * exploits harder +*/ + enum mp_malloc_e { + MPA_FLG_RANDOMIZER = 0x00000000, + MPA_FLG_BOUNDS_CHECK = 0x00000001, + MPA_FLG_BEFORE_CHECK = 0x00000002, + MPA_FLG_BACKTRACE = 0x00000004 + }; + void __FASTCALL__ mp_init_malloc(const std::string& argv0,unsigned rnd_limit,unsigned every_nth_call,enum mp_malloc_e flags); + void __FASTCALL__ mp_uninit_malloc(int verbose); + + any_t* __FASTCALL__ mp_malloc(size_t __size); + any_t* __FASTCALL__ mp_mallocz(size_t __size); + any_t* __FASTCALL__ mp_realloc(any_t*__ptr, size_t __size); + inline any_t* mp_calloc (size_t __nelem, size_t __size) { return mp_mallocz(__nelem*__size); } + any_t* __FASTCALL__ mp_memalign (size_t boundary, size_t __size); + void __FASTCALL__ mp_free(any_t*__ptr); + char * __FASTCALL__ mp_strdup(const char *src); + + /* flags: PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC */ + enum mp_prot_e { + MP_PROT_READ =0x1, /* Page can be read. */ + MP_PROT_WRITE =0x2, /* Page can be written. */ + MP_PROT_EXEC =0x4, /* Page can be executed. */ + MP_DENY_ALL =0x0, /* Page can not be accessed. */ + }; + int __FASTCALL__ mp_mprotect(any_t* addr,size_t len,enum mp_prot_e flags); + void print_backtrace(const std::string& why,any_t** stack,unsigned num); + + inline void show_backtrace(const std::string& why,unsigned num_calls) { + any_t* stack[num_calls]; + unsigned ncalls; + ncalls=backtrace(stack,num_calls); + print_backtrace(why,stack,ncalls); + } + any_t* __FASTCALL__ rnd_fill(any_t* buffer,size_t size); + any_t* __FASTCALL__ make_false_pointer(any_t* tmplt); + any_t* __FASTCALL__ make_false_pointer_to(any_t* tmplt,unsigned size); + any_t* __FASTCALL__ fill_false_pointers(any_t* buffer,size_t size); + any_t* get_caller_address(unsigned num_caller=0); + +} // namespace mpxp + +/* Note: it seems that compiler cannot distinguish which version of operators + new and delete to use: from global namespace or from user specified */ +#include <new> +enum zeromemory_t{ zeromem=0 }; +enum alignedmemory_t{ alignmem=0 }; +any_t* operator new(size_t size); +any_t* operator new(size_t size,const zeromemory_t&); +any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary); +any_t* operator new(size_t size,const std::nothrow_t&); +any_t* operator new[](size_t size); +any_t* operator new[](size_t size,const zeromemory_t&); +any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary); +any_t* operator new[](size_t size,const std::nothrow_t&); +void operator delete(any_t* p); +void operator delete[](any_t* p); + +#endif Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2013-04-17 14:04:33 UTC (rev 630) +++ mplayerxp/osdep/mplib.h 2013-04-23 12:51:09 UTC (rev 631) @@ -15,70 +15,10 @@ #include <stddef.h> #include <sys/mman.h> #include "mpxp_config.h" +#include "mp_malloc.h" namespace mpxp { - extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; - -#if defined ( ENABLE_PROFILE ) && (defined ( ARCH_X86 ) || defined( ARCH_X86_64 )) - inline unsigned long long int read_tsc( void ) { - unsigned long long int retval; - __asm __volatile ("rdtsc":"=A"(retval)::"memory"); - return retval; - } -#define PROFILE_RESET() (my_profile_total=0ULL) -#define PROFILE_START() { static int inited=0; if(!inited) { inited=1; my_profile_total=0ULL; } my_profile_start=read_tsc(); } -#define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=(my_profile_end-my_profile_start); printf(your_message" current=%llu total=%llu\n\t",(my_profile_end-my_profile_start),my_profile_total); } -#else -#define PROFILE_RESET() -#define PROFILE_START() -#define PROFILE_END(your_message) -#endif -/** Initializes randomizer for malloc. - * @param rnd_limit upper limit of random generator (recommened: 1000) - * @param every_nth_call how often call randimzer (recommened: 10) - * @note Pseudo-randomizing memory objects makes memory - * exploits harder -*/ - enum mp_malloc_e { - MPA_FLG_RANDOMIZER = 0x00000000, - MPA_FLG_BOUNDS_CHECK = 0x00000001, - MPA_FLG_BEFORE_CHECK = 0x00000002, - MPA_FLG_BACKTRACE = 0x00000004 - }; - void __FASTCALL__ mp_init_malloc(const std::string& argv0,unsigned rnd_limit,unsigned every_nth_call,enum mp_malloc_e flags); - void __FASTCALL__ mp_uninit_malloc(int verbose); - - any_t* __FASTCALL__ mp_malloc(size_t __size); - any_t* __FASTCALL__ mp_mallocz(size_t __size); - any_t* __FASTCALL__ mp_realloc(any_t*__ptr, size_t __size); - inline any_t* mp_calloc (size_t __nelem, size_t __size) { return mp_mallocz(__nelem*__size); } - any_t* __FASTCALL__ mp_memalign (size_t boundary, size_t __size); - void __FASTCALL__ mp_free(any_t*__ptr); - char * __FASTCALL__ mp_strdup(const char *src); - - /* flags: PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC */ - enum mp_prot_e { - MP_PROT_READ =0x1, /* Page can be read. */ - MP_PROT_WRITE =0x2, /* Page can be written. */ - MP_PROT_EXEC =0x4, /* Page can be executed. */ - MP_DENY_ALL =0x0, /* Page can not be accessed. */ - }; - int __FASTCALL__ mp_mprotect(any_t* addr,size_t len,enum mp_prot_e flags); - void print_backtrace(const std::string& why,any_t** stack,unsigned num); - - inline void show_backtrace(const std::string& why,unsigned num_calls) { - any_t* stack[num_calls]; - unsigned ncalls; - ncalls=backtrace(stack,num_calls); - print_backtrace(why,stack,ncalls); - } - any_t* __FASTCALL__ rnd_fill(any_t* buffer,size_t size); - any_t* __FASTCALL__ make_false_pointer(any_t* tmplt); - any_t* __FASTCALL__ make_false_pointer_to(any_t* tmplt,unsigned size); - any_t* __FASTCALL__ fill_false_pointers(any_t* buffer,size_t size); - any_t* get_caller_address(unsigned num_caller=0); - template <typename T> class LocalPtr { public: LocalPtr(T* value):ptr(value) {} @@ -102,21 +42,4 @@ any_t* unusable; }; } // namespace mpxp - -/* Note: it seems that compiler cannot distinguish which version of operators - new and delete to use: from global namespace or from user specified */ -#include <new> -enum zeromemory_t{ zeromem=0 }; -enum alignedmemory_t{ alignmem=0 }; -any_t* operator new(size_t size); -any_t* operator new(size_t size,const zeromemory_t&); -any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary); -any_t* operator new(size_t size,const std::nothrow_t&); -any_t* operator new[](size_t size); -any_t* operator new[](size_t size,const zeromemory_t&); -any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary); -any_t* operator new[](size_t size,const std::nothrow_t&); -void operator delete(any_t* p); -void operator delete[](any_t* p); - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |