From 5fa4ff0d48a10d73e5130bee87211543f0c34a31 Mon Sep 17 00:00:00 2001 From: Randy Li Date: Thu, 27 Oct 2016 17:07:35 +0800 Subject: [PATCH] [osal]: match system implementation with compiler marco It would make the build system more simple, and the cross toolchains would do the rest to you. Toolchains like buildroot default not enable the __gnu_linux__ marco in the pre-processor will surfure from the systsm unknown problem. You should enable the marco in building toolchains or have a look on those scripts in build directory. Change-Id: I8f6af3391aa3d94d602ec8d84ba5e43839859169 Signed-off-by: Randy Li --- build/linux/aarch64/arm.linux.cross.cmake | 2 +- build/linux/arm/arm.linux.cross.cmake | 2 +- osal/android/os_allocator.c | 3 ++- osal/android/os_env.c | 3 ++- osal/android/os_log.c | 3 ++- osal/android/os_mem.c | 3 ++- osal/linux/os_allocator.c | 2 ++ osal/linux/os_env.c | 3 ++- osal/linux/os_log.c | 2 ++ osal/linux/os_mem.c | 2 ++ osal/windows/os_allocator.c | 2 ++ osal/windows/os_env.c | 3 ++- osal/windows/os_log.c | 2 ++ osal/windows/os_mem.c | 2 ++ osal/windows/stdint.h | 3 +++ 15 files changed, 29 insertions(+), 8 deletions(-) diff --git a/build/linux/aarch64/arm.linux.cross.cmake b/build/linux/aarch64/arm.linux.cross.cmake index 6e438268..3e6c9f19 100644 --- a/build/linux/aarch64/arm.linux.cross.cmake +++ b/build/linux/aarch64/arm.linux.cross.cmake @@ -9,4 +9,4 @@ SET(CMAKE_SYSTEM_PROCESSOR "armv8") add_definitions(-fPIC) add_definitions(-DARMLINUX) - +add_definitions(-D__gnu_linux__) diff --git a/build/linux/arm/arm.linux.cross.cmake b/build/linux/arm/arm.linux.cross.cmake index 4d44989c..67f292b4 100644 --- a/build/linux/arm/arm.linux.cross.cmake +++ b/build/linux/arm/arm.linux.cross.cmake @@ -9,4 +9,4 @@ SET(CMAKE_SYSTEM_PROCESSOR "armv7-a_hardfp") add_definitions(-fPIC) add_definitions(-DARMLINUX) - +add_definitions(-D__gnu_linux__) diff --git a/osal/android/os_allocator.c b/osal/android/os_allocator.c index c3107765..018aa05c 100644 --- a/osal/android/os_allocator.c +++ b/osal/android/os_allocator.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__ANDROID__) #include "allocator_std.h" #include "allocator_ion.h" #include "allocator_drm.h" @@ -47,4 +48,4 @@ MPP_RET os_allocator_get(os_allocator *api, MppBufferType type) } return ret; } - +#endif diff --git a/osal/android/os_env.c b/osal/android/os_env.c index bcdb2b7a..af2bdb13 100644 --- a/osal/android/os_env.c +++ b/osal/android/os_env.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__ANDROID__) #include #include #include @@ -74,4 +75,4 @@ RK_S32 os_set_env_str(const char *name, char *value) return (len) ? (0) : (-1); } - +#endif diff --git a/osal/android/os_log.c b/osal/android/os_log.c index 0ad60798..546faaf2 100644 --- a/osal/android/os_log.c +++ b/osal/android/os_log.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__ANDROID__) #include void os_log(const char* tag, const char* msg, va_list list) @@ -25,4 +26,4 @@ void os_err(const char* tag, const char* msg, va_list list) { __android_log_vprint(ANDROID_LOG_ERROR, tag, msg, list); } - +#endif diff --git a/osal/android/os_mem.c b/osal/android/os_mem.c index e0499fa7..52cdf0e6 100644 --- a/osal/android/os_mem.c +++ b/osal/android/os_mem.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__ANDROID__) #include #include "os_mem.h" @@ -45,4 +46,4 @@ void os_free(void *ptr) { free(ptr); } - +#endif diff --git a/osal/linux/os_allocator.c b/osal/linux/os_allocator.c index 749bfcf9..72fdc643 100644 --- a/osal/linux/os_allocator.c +++ b/osal/linux/os_allocator.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__gnu_linux__) #include "mpp_log.h" #include "allocator_std.h" @@ -57,3 +58,4 @@ MPP_RET os_allocator_get(os_allocator *api, MppBufferType type) return ret; } +#endif diff --git a/osal/linux/os_env.c b/osal/linux/os_env.c index 94e611ad..afe10d65 100644 --- a/osal/linux/os_env.c +++ b/osal/linux/os_env.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__gnu_linux__) #include #include #include @@ -60,4 +61,4 @@ RK_S32 os_set_env_str(const char *name, char *value) return setenv(name, value, 1); } - +#endif diff --git a/osal/linux/os_log.c b/osal/linux/os_log.c index 81df71d5..c426812d 100644 --- a/osal/linux/os_log.c +++ b/osal/linux/os_log.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__gnu_linux__) #include #include #include "os_log.h" @@ -34,3 +35,4 @@ void os_err(const char* tag, const char* msg, va_list list) vfprintf(stderr, line, list); } +#endif diff --git a/osal/linux/os_mem.c b/osal/linux/os_mem.c index d4789dae..042531b6 100644 --- a/osal/linux/os_mem.c +++ b/osal/linux/os_mem.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(__gnu_linux__) #include #include "os_mem.h" @@ -34,3 +35,4 @@ void os_free(void *ptr) free(ptr); } +#endif diff --git a/osal/windows/os_allocator.c b/osal/windows/os_allocator.c index 64c69045..cebb2619 100644 --- a/osal/windows/os_allocator.c +++ b/osal/windows/os_allocator.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(_WIN32) #include "os_allocator.h" #include "allocator_std.h" @@ -37,3 +38,4 @@ MPP_RET os_allocator_get(os_allocator *api, MppBufferType type) return ret; } +#endif diff --git a/osal/windows/os_env.c b/osal/windows/os_env.c index ed6e8506..dfd55467 100644 --- a/osal/windows/os_env.c +++ b/osal/windows/os_env.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(_WIN32) #include #include #include "os_env.h" @@ -61,4 +62,4 @@ RK_S32 os_set_env_str(const char *name, char *value) return _putenv(buf); } - +#endif diff --git a/osal/windows/os_log.c b/osal/windows/os_log.c index 51111804..0e2b7ba9 100644 --- a/osal/windows/os_log.c +++ b/osal/windows/os_log.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(_WIN32) #include #include @@ -33,3 +34,4 @@ void os_err(const char* tag, const char* msg, va_list list) vfprintf(stderr, line, list); } +#endif diff --git a/osal/windows/os_mem.c b/osal/windows/os_mem.c index 4da5f81d..b53274b2 100644 --- a/osal/windows/os_mem.c +++ b/osal/windows/os_mem.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#if defined(_WIN32) #include #include "os_mem.h" @@ -34,3 +35,4 @@ void os_free(void *ptr) _aligned_free(ptr); } +#endif diff --git a/osal/windows/stdint.h b/osal/windows/stdint.h index b49ae630..1440e485 100644 --- a/osal/windows/stdint.h +++ b/osal/windows/stdint.h @@ -1,3 +1,4 @@ +#if defined(_WIN32) #pragma once /* a minimal set of C99 types for use with MSVC */ @@ -11,3 +12,5 @@ typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t; + +#endif