1 /**************************************************************************
5 Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
8 Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
34 #include "tbm_bufmgr.h"
35 #include "tbm_bufmgr_int.h"
36 #include "tbm_bufmgr_backend.h"
39 #include <sys/resource.h>
56 static pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
57 static pthread_mutex_t tbm_bufmgr_lock = PTHREAD_MUTEX_INITIALIZER;
58 static double scale_factor = 0;
59 static void _tbm_bufmgr_mutex_unlock(void);
61 //#define TBM_BUFMGR_INIT_TIME
63 #define PREFIX_LIB "libtbm_"
64 #define SUFFIX_LIB ".so"
65 #define DEFAULT_LIB PREFIX_LIB"default"SUFFIX_LIB
67 /* values to indicate unspecified fields in XF86ModReqInfo. */
68 #define MAJOR_UNSPEC 0xFF
69 #define MINOR_UNSPEC 0xFF
70 #define PATCH_UNSPEC 0xFFFF
71 #define ABI_VERS_UNSPEC 0xFFFFFFFF
73 #define MODULE_VERSION_NUMERIC(maj, min, patch) \
74 ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
75 #define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
76 #define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
77 #define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF)
79 #define MAX_SIZE_N(dest) (sizeof(dest) - strlen(dest) - 1)
82 #define TBM_BUFMGR_RETURN_IF_FAIL(cond) {\
84 TBM_LOG_E("'%s' failed.\n", #cond);\
85 _tbm_bufmgr_mutex_unlock();\
90 #define TBM_BUFMGR_RETURN_VAL_IF_FAIL(cond, val) {\
92 TBM_LOG_E("'%s' failed.\n", #cond);\
93 _tbm_bufmgr_mutex_unlock();\
100 _tbm_bufmgr_mutex_init(void)
102 static bool tbm_bufmgr_mutex_init = false;
104 if (tbm_bufmgr_mutex_init)
107 if (pthread_mutex_init(&tbm_bufmgr_lock, NULL)) {
108 TBM_LOG_E("fail: Cannot pthread_mutex_init for tbm_bufmgr_lock.\n");
112 tbm_bufmgr_mutex_init = true;
118 _tbm_bufmgr_mutex_lock(void)
120 if (!_tbm_bufmgr_mutex_init()) {
121 TBM_LOG_E("fail: _tbm_bufmgr_mutex_init()\n");
125 pthread_mutex_lock(&tbm_bufmgr_lock);
129 _tbm_bufmgr_mutex_unlock(void)
131 pthread_mutex_unlock(&tbm_bufmgr_lock);
135 _tbm_util_get_max_surface_size(int *w, int *h)
137 tbm_surface_info_s info;
138 tbm_surface_h surface = NULL;
144 if (gBufMgr == NULL || LIST_IS_EMPTY(&gBufMgr->surf_list))
147 LIST_FOR_EACH_ENTRY(surface, &gBufMgr->surf_list, item_link) {
148 if (tbm_surface_get_info(surface, &info) == TBM_SURFACE_ERROR_NONE) {
152 if (*h < info.height)
161 _tbm_util_get_appname_brief(char *brief)
165 char temp[255] = {0,};
166 char *saveptr = NULL;
168 token = strtok_r(brief, delim, &saveptr);
170 while (token != NULL) {
171 memset(temp, 0x00, 255 * sizeof(char));
172 strncpy(temp, token, 254 * sizeof(char));
173 token = strtok_r(NULL, delim, &saveptr);
176 snprintf(brief, sizeof(temp), "%s", temp);
180 _tbm_util_get_appname_from_pid(long pid, char *str)
182 char fn_cmdline[255] = {0, }, cmdline[255];
186 snprintf(fn_cmdline, sizeof(fn_cmdline), "/proc/%ld/cmdline", pid);
188 fp = fopen(fn_cmdline, "r");
190 TBM_LOG_E("cannot file open %s\n", fn_cmdline);
194 if (!fgets(cmdline, 255, fp)) {
195 TBM_LOG_E("fail to get appname for pid(%ld)\n", pid);
202 len = strlen(cmdline);
204 memset(cmdline, 0x00, 255);
208 snprintf(str, sizeof(cmdline), "%s", cmdline);
212 _check_version(TBMModuleVersionInfo *data)
217 abimaj = GET_ABI_MAJOR(data->abiversion);
218 abimin = GET_ABI_MINOR(data->abiversion);
220 TBM_DBG("TBM module %s: vendor=\"%s\" ABI=%d,%d\n",
221 data->modname ? data->modname : "UNKNOWN!",
222 data->vendor ? data->vendor : "UNKNOWN!", abimaj, abimin);
224 vermaj = GET_ABI_MAJOR(TBM_ABI_VERSION);
225 vermin = GET_ABI_MINOR(TBM_ABI_VERSION);
227 TBM_DBG("TBM ABI version %d.%d\n",
230 if (abimaj != vermaj) {
231 TBM_LOG_E("TBM module ABI major ver(%d) doesn't match the TBM's ver(%d)\n",
234 } else if (abimin > vermin) {
235 TBM_LOG_E("TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
244 _tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
246 char path[PATH_MAX] = {0, };
247 TBMModuleVersionInfo *vers;
248 TBMModuleData *initdata;
252 snprintf(path, sizeof(path), BUFMGR_MODULE_DIR "/%s", file);
254 module_data = dlopen(path, RTLD_LAZY);
256 TBM_LOG_E("failed to load module: %s(%s)\n", dlerror(), file);
260 initdata = dlsym(module_data, "tbmModuleData");
262 TBM_LOG_E("Error: module does not have data object.\n");
266 vers = initdata->vers;
268 TBM_LOG_E("Error: module does not supply version information.\n");
272 init = initdata->init;
274 TBM_LOG_E("Error: module does not supply init symbol.\n");
278 if (!_check_version(vers)) {
279 TBM_LOG_E("Fail to check version.\n");
283 if (!init(bufmgr, fd)) {
284 TBM_LOG_E("Fail to init module(%s)\n", file);
288 if (!bufmgr->backend || !bufmgr->backend->priv) {
289 TBM_LOG_E("Error: module(%s) wrong operation. Check backend or backend's priv.\n", file);
293 bufmgr->module_data = module_data;
295 TBM_DBG("Success to load module(%s)\n", file);
300 dlclose(module_data);
305 _tbm_load_module(tbm_bufmgr bufmgr, int fd)
307 struct dirent **namelist;
310 /* load bufmgr priv from default lib */
311 if (_tbm_bufmgr_load_module(bufmgr, fd, DEFAULT_LIB))
314 /* load bufmgr priv from configured path */
315 n = scandir(BUFMGR_MODULE_DIR, &namelist, 0, alphasort);
317 TBM_LOG_E("no files : %s\n", BUFMGR_MODULE_DIR);
322 if (!ret && strstr(namelist[n]->d_name, PREFIX_LIB)) {
323 const char *p = strstr(namelist[n]->d_name, SUFFIX_LIB);
325 if (p && !strcmp(p, SUFFIX_LIB))
326 ret = _tbm_bufmgr_load_module(bufmgr, fd,
327 namelist[n]->d_name);
340 _tbm_bufmgr_init(int fd, int server)
342 #ifdef TBM_BUFMGR_INIT_TIME
343 struct timeval start_tv, end_tv;
347 #ifdef TBM_BUFMGR_INIT_TIME
348 /* get the start tv */
349 gettimeofday(&start_tv, NULL);
352 /* LCOV_EXCL_START */
354 env = getenv("TBM_DLOG");
357 TBM_LOG_D("TBM_DLOG=%s\n", env);
363 env = getenv("TBM_DEBUG");
366 TBM_LOG_D("TBM_DEBUG=%s\n", env);
372 env = getenv("TBM_TRACE");
375 TBM_LOG_D("TBM_TRACE=%s\n", env);
380 pthread_mutex_lock(&gLock);
383 TBM_LOG_W("!!!!!WARNING:: The tbm_bufmgr_init DOSE NOT use argument fd ANYMORE.\n");
384 TBM_LOG_W("!!!!!WARNING:: IT WILL BE CHANGED like tbm_bufmgr_init(int fd) --> tbm_bufmgr_init(void).\n");
388 /* initialize buffer manager */
390 gBufMgr->ref_count++;
391 TBM_TRACE("reuse tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, gBufMgr->fd);
392 pthread_mutex_unlock(&gLock);
396 TBM_DBG("bufmgr init\n");
398 /* allocate bufmgr */
399 gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
401 TBM_TRACE("error: fail to alloc bufmgr fd(%d)\n", fd);
402 pthread_mutex_unlock(&gLock);
408 /* set the display_server flag before loading the backend module */
410 TBM_LOG_I("The tbm_bufmgr(%p) is used by display server. Need to bind the native_display.\n", gBufMgr);
411 gBufMgr->display_server = 1;
414 /* load bufmgr priv from env */
415 if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
416 TBM_LOG_E("error : Fail to load bufmgr backend\n");
419 pthread_mutex_unlock(&gLock);
425 /* log for tbm backend_flag */
426 TBM_DBG("backend flag:%x:", gBufMgr->backend->flags);
429 gBufMgr->ref_count = 1;
431 TBM_DBG("create tizen bufmgr:%p ref_count:%d\n",
432 gBufMgr, gBufMgr->ref_count);
434 /* setup the bo_lock_type */
435 env = getenv("BUFMGR_LOCK_TYPE");
436 if (env && !strcmp(env, "always"))
437 gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS;
438 else if (env && !strcmp(env, "none"))
439 gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_NEVER;
440 else if (env && !strcmp(env, "once"))
441 gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_ONCE;
443 gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS;
445 TBM_DBG("BUFMGR_LOCK_TYPE=%s\n", env ? env : "default:once");
447 TBM_TRACE("create tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, fd);
449 /* intialize bo_list */
450 LIST_INITHEAD(&gBufMgr->bo_list);
452 /* intialize surf_list */
453 LIST_INITHEAD(&gBufMgr->surf_list);
455 /* intialize surf_queue_list */
456 LIST_INITHEAD(&gBufMgr->surf_queue_list);
458 /* intialize debug_key_list */
459 LIST_INITHEAD(&gBufMgr->debug_key_list);
461 #ifdef TBM_BUFMGR_INIT_TIME
463 gettimeofday(&end_tv, NULL);
464 TBM_LOG_I("tbm_bufmgr_init time: %ld ms", ((end_tv.tv_sec * 1000 + end_tv.tv_usec / 1000) - (start_tv.tv_sec * 1000 + start_tv.tv_usec / 1000)));
467 pthread_mutex_unlock(&gLock);
473 tbm_bufmgr_init(int fd)
477 bufmgr = _tbm_bufmgr_init(fd, 0);
483 tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
485 TBM_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr));
487 _tbm_bufmgr_mutex_lock();
488 pthread_mutex_lock(&gLock);
491 TBM_LOG_E("gBufmgr already destroy: bufmgr:%p\n", bufmgr);
492 pthread_mutex_unlock(&gLock);
493 _tbm_bufmgr_mutex_unlock();
498 if (bufmgr->ref_count > 0) {
499 TBM_TRACE("reduce a ref_count(%d) of tbm_bufmgr(%p)\n", bufmgr->ref_count, bufmgr);
500 pthread_mutex_unlock(&gLock);
501 _tbm_bufmgr_mutex_unlock();
505 /* destroy bo_list */
506 if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
507 tbm_bo bo = NULL, tmp;
509 LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &bufmgr->bo_list, item_link) {
510 TBM_LOG_E("Un-freed bo(%p, ref:%d)\n", bo, bo->ref_cnt);
513 LIST_DELINIT(&bufmgr->bo_list);
516 /* destroy surf_list */
517 if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
518 tbm_surface_h surf = NULL, tmp;
520 LIST_FOR_EACH_ENTRY_SAFE(surf, tmp, &bufmgr->surf_list, item_link) {
521 TBM_LOG_E("Un-freed surf(%p, ref:%d)\n", surf, surf->refcnt);
522 tbm_surface_destroy(surf);
524 LIST_DELINIT(&bufmgr->surf_list);
527 /* destroy bufmgr priv */
528 bufmgr->backend->bufmgr_deinit(bufmgr->backend->priv);
529 bufmgr->backend->priv = NULL;
530 tbm_backend_free(bufmgr->backend);
531 bufmgr->backend = NULL;
533 TBM_TRACE("destroy tbm_bufmgr(%p)\n", bufmgr);
535 dlclose(bufmgr->module_data);
543 pthread_mutex_unlock(&gLock);
544 _tbm_bufmgr_mutex_unlock();
548 tbm_bufmgr_get_capability(tbm_bufmgr bufmgr)
550 unsigned int capabilities = TBM_BUFMGR_CAPABILITY_NONE;
552 _tbm_bufmgr_mutex_lock();
554 TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), TBM_BUFMGR_CAPABILITY_NONE);
555 TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, TBM_BUFMGR_CAPABILITY_NONE);
557 TBM_TRACE("tbm_bufmgr(%p) capability(%u)\n", bufmgr, bufmgr->capabilities);
559 capabilities = bufmgr->capabilities;
561 _tbm_bufmgr_mutex_unlock();
566 /* LCOV_EXCL_START */
568 tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr)
570 char app_name[255] = {0,}, title[512] = {0,};
571 tbm_surface_debug_data *debug_old_data = NULL;
576 pthread_mutex_lock(&gLock);
578 if (!TBM_BUFMGR_IS_VALID(bufmgr) || (bufmgr != gBufMgr)) {
579 TBM_LOG_E("invalid bufmgr\n");
580 pthread_mutex_unlock(&gLock);
586 TBM_LOG_E("Fail to allocate the string.\n");
587 pthread_mutex_unlock(&gLock);
591 TBM_SNRPRINTF(str, len, c, "\n");
592 _tbm_util_get_appname_from_pid(getpid(), app_name);
593 _tbm_util_get_appname_brief(app_name);
594 TBM_SNRPRINTF(str, len, c, "============TBM DEBUG: %s(%d)===========================\n",
597 snprintf(title, 255, "%s", "no surface refcnt width height bpp size n_b n_p flags format app_name ");
599 if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
600 LIST_FOR_EACH_ENTRY(debug_old_data, &bufmgr->debug_key_list, item_link) {
601 strncat(title, " ", MAX_SIZE_N(title));
602 strncat(title, debug_old_data->key, MAX_SIZE_N(title));
606 TBM_SNRPRINTF(str, len, c, "[tbm_surface information]\n");
607 TBM_SNRPRINTF(str, len, c, "%s\n", title);
609 /* show the tbm_surface information in surf_list */
610 if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
611 tbm_surface_h surf = NULL;
614 LIST_FOR_EACH_ENTRY(surf, &bufmgr->surf_list, item_link) {
615 char data[512] = {0,};
619 pid = _tbm_surface_internal_get_debug_pid(surf);
621 /* if pid is null, set the self_pid */
625 memset(app_name, 0x0, 255 * sizeof(char));
626 _tbm_util_get_appname_from_pid(pid, app_name);
627 _tbm_util_get_appname_brief(app_name);
629 snprintf(data, 255, "%-2d %-9p %-4d %-5u %-6u %-3u %-6u %-2d %-2d %-3d %-8s %-15s",
636 surf->info.size / 1024,
640 _tbm_surface_internal_format_to_str(surf->info.format) + 11,
643 if (!LIST_IS_EMPTY(&bufmgr->debug_key_list)) {
644 LIST_FOR_EACH_ENTRY(debug_old_data, &bufmgr->debug_key_list, item_link) {
647 strncat(data, " ", MAX_SIZE_N(title));
649 value = _tbm_surface_internal_get_debug_data(surf, debug_old_data->key);
651 strncat(data, value, MAX_SIZE_N(title));
653 strncat(data, "none", MAX_SIZE_N(title));
656 TBM_SNRPRINTF(str, len, c, "%s\n", data);
658 for (i = 0; i < surf->num_bos; i++) {
659 TBM_SNRPRINTF(str, len, c, " bo:%-12p %-26d%-10d\n",
661 surf->bos[i]->ref_cnt,
662 bufmgr->backend->bo_size(surf->bos[i]) / 1024);
666 TBM_SNRPRINTF(str, len, c, " no tbm_surfaces.\n");
667 TBM_SNRPRINTF(str, len, c, "\n");
669 TBM_SNRPRINTF(str, len, c, "[tbm_bo information]\n");
670 TBM_SNRPRINTF(str, len, c, "no bo refcnt size lock_cnt map_cnt flags surface name\n");
672 /* show the tbm_bo information in bo_list */
673 if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
677 LIST_FOR_EACH_ENTRY(bo, &bufmgr->bo_list, item_link) {
678 TBM_SNRPRINTF(str, len, c, "%-4d%-11p %-4d %-6d %-5d %-4u %-3d %-11p %-4d\n",
682 bufmgr->backend->bo_size(bo) / 1024,
687 bufmgr->backend->bo_export(bo));
690 TBM_SNRPRINTF(str, len, c, "no tbm_bos.\n");
691 TBM_SNRPRINTF(str, len, c, "\n");
693 TBM_SNRPRINTF(str, len, c, "===============================================================\n");
695 pthread_mutex_unlock(&gLock);
701 tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
704 str = tbm_bufmgr_debug_tbm_info_get(bufmgr);
706 TBM_DEBUG(" %s", str);
712 tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
714 _tbm_bufmgr_mutex_lock();
716 TBM_BUFMGR_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr));
717 TBM_BUFMGR_RETURN_IF_FAIL(bufmgr == gBufMgr);
720 TBM_LOG_D("bufmgr=%p onoff=%d\n", bufmgr, onoff);
724 _tbm_bufmgr_mutex_unlock();
728 tbm_bufmgr_debug_dump_set_scale(double scale)
730 pthread_mutex_lock(&gLock);
731 scale_factor = scale;
732 pthread_mutex_unlock(&gLock);
736 tbm_bufmgr_debug_get_ref_count(void)
738 return (gBufMgr) ? gBufMgr->ref_count : 0;
742 tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff)
744 pthread_mutex_lock(&gLock);
747 TBM_LOG_D("count=%d onoff=%d\n", count, onoff);
749 tbm_surface_internal_dump_end();
754 TBM_LOG_E("path is null");
755 pthread_mutex_unlock(&gLock);
758 TBM_LOG_D("path=%s count=%d onoff=%d\n", path, count, onoff);
760 if (_tbm_util_get_max_surface_size(&w, &h) == 0) {
761 TBM_LOG_E("Fail to get tbm_surface size.\n");
762 pthread_mutex_unlock(&gLock);
766 tbm_surface_internal_dump_with_scale_start(path, w, h, count, scale_factor);
772 pthread_mutex_unlock(&gLock);
777 tbm_bufmgr_debug_dump_all(char *path)
780 tbm_surface_h surface = NULL;
782 TBM_RETURN_VAL_IF_FAIL(path != NULL, 0);
783 TBM_LOG_D("path=%s\n", path);
785 pthread_mutex_lock(&gLock);
787 count = _tbm_util_get_max_surface_size(&w, &h);
789 TBM_LOG_E("No tbm_surface.\n");
790 pthread_mutex_unlock(&gLock);
794 tbm_surface_internal_dump_with_scale_start(path, w, h, count, scale_factor);
797 LIST_FOR_EACH_ENTRY(surface, &gBufMgr->surf_list, item_link)
798 tbm_surface_internal_dump_buffer(surface, "dump_all");
800 tbm_surface_internal_dump_end();
802 pthread_mutex_unlock(&gLock);
807 /* internal function */
809 _tbm_bufmgr_get_bufmgr(void)
815 tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display)
819 _tbm_bufmgr_mutex_lock();
821 TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), 0);
823 if (!bufmgr->backend->bufmgr_bind_native_display) {
824 TBM_TRACE("skip: tbm_bufmgr(%p) native_display(%p)\n",
825 bufmgr, native_display);
826 _tbm_bufmgr_mutex_unlock();
830 ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, native_display);
832 TBM_LOG_E("error: tbm_bufmgr(%p) native_display(%p)\n",
833 bufmgr, native_display);
834 _tbm_bufmgr_mutex_unlock();
838 TBM_TRACE("tbm_bufmgr(%p) native_display(%p)\n", bufmgr, native_display);
840 _tbm_bufmgr_mutex_unlock();
846 tbm_bufmgr_server_init(void)
850 bufmgr = _tbm_bufmgr_init(-1, 1);
856 tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type)
858 TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), 0);
859 TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, 0);
861 gBufMgr->bo_lock_type = bo_lock_type;
863 TBM_LOG_I("The bo_lock_type of the bo is %d\n", bo_lock_type);
869 int tbm_bufmgr_get_fd_limit(void)
873 if (getrlimit(RLIMIT_NOFILE, &lim))
876 return (int)lim.rlim_cur;
879 tbm_bufmgr tbm_bufmgr_get(void)