From 2699c00d10e41b18fe29d2a44d27fdfbd30fa061 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 23 Apr 2018 10:09:11 +0900 Subject: [PATCH] error: add tbm_error.h The tbm apis get the tbm_error_e values through tbm_get_last_error. Change-Id: I2485a9ff6b60308e51f893887b8a3083fc87b002 --- packaging/libtbm.spec | 1 + src/Makefile.am | 2 + src/tbm_bo.c | 15 ------- src/tbm_bo.h | 41 +---------------- src/tbm_bufmgr.h | 2 +- src/tbm_bufmgr_int.h | 4 ++ src/tbm_error.c | 51 +++++++++++++++++++++ src/tbm_error.h | 90 ++++++++++++++++++++++++++++++++++++++ src/tbm_surface_internal.h | 1 + src/tbm_surface_queue.h | 1 + 10 files changed, 152 insertions(+), 56 deletions(-) create mode 100644 src/tbm_error.c create mode 100644 src/tbm_error.h diff --git a/packaging/libtbm.spec b/packaging/libtbm.spec index d2727eb..f8ddce8 100644 --- a/packaging/libtbm.spec +++ b/packaging/libtbm.spec @@ -115,6 +115,7 @@ rm -f %{_unitdir_user}/basic.target.wants/tbm-drm-auth-user.path %{_includedir}/tbm_sync.h %{_includedir}/tbm_bo.h %{_includedir}/tbm_log.h +%{_includedir}/tbm_error.h %{_includedir}/tbm_backend.h %{_libdir}/libtbm.so %{_libdir}/pkgconfig/libtbm.pc diff --git a/src/Makefile.am b/src/Makefile.am index 6ac8c6e..03d1d5b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,6 +24,7 @@ libtbm_la_SOURCES = \ tbm_drm_helper_client.c \ tbm_sync.c \ tbm_log.c \ + tbm_error.c \ tbm_backend.c nodist_libtbm_la_SOURCES = \ @@ -54,6 +55,7 @@ libtbminclude_HEADERS = tbm_bufmgr.h \ tbm_drm_helper.h \ tbm_sync.h \ tbm_log.h \ + tbm_error.h \ tbm_backend.h CLEANFILES = $(BUILT_SOURCES) diff --git a/src/tbm_bo.c b/src/tbm_bo.c index 69d318d..f63d99d 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -35,7 +35,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "list.h" static pthread_mutex_t tbm_bo_lock = PTHREAD_MUTEX_INITIALIZER; -static __thread tbm_error_e tbm_last_error = TBM_ERROR_NONE; static void _tbm_bo_mutex_unlock(void); /* check condition */ @@ -55,12 +54,6 @@ static void _tbm_bo_mutex_unlock(void); } \ } -static void -_tbm_set_last_result(tbm_error_e err) -{ - tbm_last_error = err; -} - /* LCOV_EXCL_START */ static bool _tbm_bo_mutex_init(void) @@ -1179,14 +1172,6 @@ tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data) return 1; } -/* LCOV_EXCL_START */ -tbm_error_e -tbm_get_last_error(void) -{ - return tbm_last_error; -} -/* LCOV_EXCL_STOP */ - int tbm_bo_get_flags(tbm_bo bo) { diff --git a/src/tbm_bo.h b/src/tbm_bo.h index 84fe9b7..4817af6 100644 --- a/src/tbm_bo.h +++ b/src/tbm_bo.h @@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include /** * \file tbm_bo.h @@ -724,46 +725,6 @@ int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data); */ int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data); -/** - * @brief Gets the latest tbm_error. - * @since_tizen 2.4 - * @return the latest tbm_error - * @par Example - @code - #include - - int bufmgr_fd; - tbm_bufmgr bufmgr; - tbm_bo bo; - tbm_bo_handle handle; - tbm_error_e error; - - bufmgr = tbm_bufmgr_init (bufmgr_fd); - bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT); - if (!bo) - { - error = tbm_get_last_error (); - ... - } - - ... - - handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE); - if (handle.ptr == NULL) - { - error = tbm_get_last_error (); - ... - } - - ... - - tbm_bo_unmap (bo); - tbm_bo_unref (bo); - tbm_bufmgr_deinit (bufmgr); - @endcode - */ -tbm_error_e tbm_get_last_error(void); - /** * @brief Gets the tbm bo flags. * @since_tizen 2.4 diff --git a/src/tbm_bufmgr.h b/src/tbm_bufmgr.h index f597211..42e1ccd 100644 --- a/src/tbm_bufmgr.h +++ b/src/tbm_bufmgr.h @@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#include +#include /** * \file tbm_bufmgr.h diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 33eccd2..a75c696 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -57,6 +57,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include extern tbm_bufmgr gBufMgr; extern int b_dump_queue; @@ -276,4 +277,7 @@ void user_data_delete(tbm_user_data *user_data); int tbm_bufmgr_get_fd_limit(void); tbm_bufmgr tbm_bufmgr_get(void); + +void _tbm_set_last_result(tbm_error_e err); + #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_error.c b/src/tbm_error.c new file mode 100644 index 0000000..f02a6fb --- /dev/null +++ b/src/tbm_error.c @@ -0,0 +1,51 @@ +/************************************************************************** + +libtbm + +Copyright 2012-2018 Samsung Electronics co., Ltd. All Rights Reserved. + +Contact: SooChan Lim , Sangjin Lee +Boram Park , Changyeon Lee + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#include "config.h" +#include "tbm_bufmgr.h" +#include "tbm_bufmgr_int.h" + +static __thread tbm_error_e tbm_last_error = TBM_ERROR_NONE; + +/* LCOV_EXCL_START */ +void +_tbm_set_last_result(tbm_error_e err) +{ + tbm_last_error = err; +} + +tbm_error_e +tbm_get_last_error(void) +{ + return tbm_last_error; +} +/* LCOV_EXCL_STOP */ + diff --git a/src/tbm_error.h b/src/tbm_error.h new file mode 100644 index 0000000..b5c4244 --- /dev/null +++ b/src/tbm_error.h @@ -0,0 +1,90 @@ +/************************************************************************** + +libtbm + +Copyright 2012-2018 Samsung Electronics co., Ltd. All Rights Reserved. + +Contact: SooChan Lim , Sangjin Lee +Boram Park , Changyeon Lee + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#ifndef _TBM_ERROR_H_ +#define _TBM_ERROR_H_ + +#include +#include + +/** + * \file tbm_error.h + * \brief TBM Error + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Gets the latest tbm_error. + * @since_tizen 2.4 + * @return the latest tbm_error + * @par Example + @code + #include + + int bufmgr_fd; + tbm_bufmgr bufmgr; + tbm_bo bo; + tbm_bo_handle handle; + tbm_error_e error; + + bufmgr = tbm_bufmgr_init (bufmgr_fd); + bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT); + if (!bo) + { + error = tbm_get_last_error (); + ... + } + + ... + + handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE); + if (handle.ptr == NULL) + { + error = tbm_get_last_error (); + ... + } + + ... + + tbm_bo_unmap (bo); + tbm_bo_unref (bo); + tbm_bufmgr_deinit (bufmgr); + @endcode + */ +tbm_error_e tbm_get_last_error(void); + +#ifdef __cplusplus +} +#endif +#endif /* _TBM_ERROR_H_ */ \ No newline at end of file diff --git a/src/tbm_surface_internal.h b/src/tbm_surface_internal.h index 12dd3b1..0ada9c0 100644 --- a/src/tbm_surface_internal.h +++ b/src/tbm_surface_internal.h @@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define _TBM_SURFACE_INTERNAL_H_ #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/tbm_surface_queue.h b/src/tbm_surface_queue.h index 8ff2a58..34831a2 100644 --- a/src/tbm_surface_queue.h +++ b/src/tbm_surface_queue.h @@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include typedef enum { TBM_SURFACE_QUEUE_TRACE_NONE = 0, /**< Successful */ -- 2.34.1