error: add tbm_error.h 85/177185/1
authorSooChan Lim <sc1.lim@samsung.com>
Mon, 23 Apr 2018 01:09:11 +0000 (10:09 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 23 Apr 2018 04:01:05 +0000 (13:01 +0900)
The tbm apis get the tbm_error_e values through tbm_get_last_error.

Change-Id: I2485a9ff6b60308e51f893887b8a3083fc87b002

packaging/libtbm.spec
src/Makefile.am
src/tbm_bo.c
src/tbm_bo.h
src/tbm_bufmgr.h
src/tbm_bufmgr_int.h
src/tbm_error.c [new file with mode: 0644]
src/tbm_error.h [new file with mode: 0644]
src/tbm_surface_internal.h
src/tbm_surface_queue.h

index d2727eb..f8ddce8 100644 (file)
@@ -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
index 6ac8c6e..03d1d5b 100644 (file)
@@ -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)
index 69d318d..f63d99d 100644 (file)
@@ -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)
 {
index 84fe9b7..4817af6 100644 (file)
@@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <tbm_type.h>
 #include <tbm_type_common.h>
+#include <tbm_error.h>
 
 /**
  * \file tbm_bo.h
@@ -725,46 +726,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 <tbm_bufmgr.h>
-
-   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
  * @param[in] bo : the buffer object
index f597211..42e1ccd 100644 (file)
@@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <tbm_type.h>
 #include <tbm_type_common.h>
-#include <tbm_bo.h>
+#include <tbm_error.h>
 
 /**
  * \file tbm_bufmgr.h
index 33eccd2..a75c696 100644 (file)
@@ -57,6 +57,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <tbm_log.h>
 #include <tbm_bufmgr_backend.h>
 #include <tbm_backend.h>
+#include <tbm_error.h>
 
 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 (file)
index 0000000..f02a6fb
--- /dev/null
@@ -0,0 +1,51 @@
+/**************************************************************************
+
+libtbm
+
+Copyright 2012-2018 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
+
+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 (file)
index 0000000..b5c4244
--- /dev/null
@@ -0,0 +1,90 @@
+/**************************************************************************
+
+libtbm
+
+Copyright 2012-2018 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
+
+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 <tbm_type.h>
+#include <tbm_type_common.h>
+
+/**
+ * \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 <tbm_bufmgr.h>
+
+   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
index 12dd3b1..0ada9c0 100644 (file)
@@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define _TBM_SURFACE_INTERNAL_H_
 
 #include <tbm_bufmgr.h>
+#include <tbm_error.h>
 
 #ifdef __cplusplus
 extern "C" {
index 8ff2a58..34831a2 100644 (file)
@@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <tbm_surface.h>
 #include <tbm_type_common.h>
+#include <tbm_error.h>
 
 typedef enum {
        TBM_SURFACE_QUEUE_TRACE_NONE = 0,                                         /**< Successful */