From c35cc7d345a8143eccb996c0a6b787693815f9f9 Mon Sep 17 00:00:00 2001 From: ChenHengming Date: Fri, 7 Aug 2015 10:15:24 +0000 Subject: [PATCH] [osal]: rename mpp_malloc to mpp_mem, add mpp_time function git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@63 6e48237b-75ef-9749-8fc9-41990f28c85a --- osal/CMakeLists.txt | 1 + osal/inc/{mpp_malloc.h => mpp_mem.h} | 5 +++ osal/inc/mpp_time.h | 33 +++++++++++++++ osal/{mpp_malloc.cpp => mpp_mem.cpp} | 2 +- osal/mpp_time.cpp | 40 +++++++++++++++++++ osal/test/CMakeLists.txt | 2 +- .../{mpp_malloc_test.c => mpp_mem_test.c} | 2 +- 7 files changed, 82 insertions(+), 3 deletions(-) rename osal/inc/{mpp_malloc.h => mpp_mem.h} (88%) create mode 100644 osal/inc/mpp_time.h rename osal/{mpp_malloc.cpp => mpp_mem.cpp} (95%) create mode 100644 osal/mpp_time.cpp rename osal/test/{mpp_malloc_test.c => mpp_mem_test.c} (97%) diff --git a/osal/CMakeLists.txt b/osal/CMakeLists.txt index 766f0d10..b48c03da 100644 --- a/osal/CMakeLists.txt +++ b/osal/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories(.) add_library(osal STATIC mpp_malloc.cpp + mpp_time.cpp mpp_list.cpp mpp_env.cpp mpp_log.cpp diff --git a/osal/inc/mpp_malloc.h b/osal/inc/mpp_mem.h similarity index 88% rename from osal/inc/mpp_malloc.h rename to osal/inc/mpp_mem.h index 4dcada08..5bca3f66 100644 --- a/osal/inc/mpp_malloc.h +++ b/osal/inc/mpp_mem.h @@ -41,5 +41,10 @@ void mpp_osal_free(void *ptr); } #endif +// buffer manipulation function +#if defined(_WIN32) +#define snprintf _snprintf +#endif + #endif /*__MPP_MALLOC_H__*/ diff --git a/osal/inc/mpp_time.h b/osal/inc/mpp_time.h new file mode 100644 index 00000000..d0fa08ed --- /dev/null +++ b/osal/inc/mpp_time.h @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Rockchip Electronics S.LSI Co. LTD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MPP_COMMON_H__ +#define __MPP_COMMON_H__ + +#include "rk_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +RK_S64 mpp_time(); + +#ifdef __cplusplus +} +#endif + +#endif /*__MPP_COMMON_H__*/ + diff --git a/osal/mpp_malloc.cpp b/osal/mpp_mem.cpp similarity index 95% rename from osal/mpp_malloc.cpp rename to osal/mpp_mem.cpp index a2595121..dbbec435 100644 --- a/osal/mpp_malloc.cpp +++ b/osal/mpp_mem.cpp @@ -23,7 +23,7 @@ #include "mpp_log.h" #include "mpp_env.h" -#include "mpp_malloc.h" +#include "mpp_mem.h" #include "mpp_list.h" #include "os_malloc.h" diff --git a/osal/mpp_time.cpp b/osal/mpp_time.cpp new file mode 100644 index 00000000..422d9d5c --- /dev/null +++ b/osal/mpp_time.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2010 Rockchip Electronics S.LSI Co. LTD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mpp_time.h" + +#if _WIN32 +#include +#include + +RK_S64 mpp_time() +{ + struct timeb tb; + ftime(&tb); + return ((RK_S64)tb.time * 1000 + (RK_S64)tb.millitm) * 1000; +} + +#else +#include + +RK_S64 mpp_time() +{ + struct timeval tv_date; + gettimeofday(&tv_date, NULL); + return (RK_S64)tv_date.tv_sec * 1000000 + (RK_S64)tv_date.tv_usec; +} + +#endif diff --git a/osal/test/CMakeLists.txt b/osal/test/CMakeLists.txt index 2438deed..6fff592b 100644 --- a/osal/test/CMakeLists.txt +++ b/osal/test/CMakeLists.txt @@ -25,7 +25,7 @@ add_mpp_osal_test(mpp_log) add_mpp_osal_test(mpp_env) # malloc system unit test -add_mpp_osal_test(mpp_malloc) +add_mpp_osal_test(mpp_mem) # thread implement unit test add_mpp_osal_test(mpp_thread) diff --git a/osal/test/mpp_malloc_test.c b/osal/test/mpp_mem_test.c similarity index 97% rename from osal/test/mpp_malloc_test.c rename to osal/test/mpp_mem_test.c index 7591154b..7388f297 100644 --- a/osal/test/mpp_malloc_test.c +++ b/osal/test/mpp_mem_test.c @@ -18,7 +18,7 @@ #include "mpp_log.h" #include "mpp_env.h" -#include "mpp_malloc.h" +#include "mpp_mem.h" // TODO: need to add pressure test case and parameter scan case