libbluray | branch: master | hpi1 <[email protected]> | Tue Apr 1 11:48:02 2014 +0300| [a682a65667ec828c71310d0e756b5b325ec40fc5] | committer: hpi1
avoid inlining failed warnings: moved mutex init/destroy to mutex.c > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=a682a65667ec828c71310d0e756b5b325ec40fc5 --- src/Makefile.am | 1 + src/util/mutex.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/util/mutex.h | 28 ++++++------------------- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 31176b3..9daeef9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -88,6 +88,7 @@ libbluray_la_SOURCES = \ util/strutl.h \ util/macro.h \ util/mutex.h \ + util/mutex.c \ util/time.h \ util/logging.c \ util/log_control.h \ diff --git a/src/util/mutex.c b/src/util/mutex.c new file mode 100644 index 0000000..a75fa01 --- /dev/null +++ b/src/util/mutex.c @@ -0,0 +1,60 @@ +/* + * This file is part of libbluray + * Copyright (C) 2010-2014 Petri Hintukainen <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "mutex.h" + +#include "logging.h" +#include "macro.h" + + +#if defined(_WIN32) + /* nothing here */ +#elif defined(HAVE_PTHREAD_H) + +#include <pthread.h> + +int bd_mutex_init(BD_MUTEX *p) +{ + p->owner = (pthread_t)-1; + p->lock_count = 0; + + if (pthread_mutex_init(&p->mutex, NULL)) { + BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_init() failed !\n"); + return -1; + } + + return 0; +} + +int bd_mutex_destroy(BD_MUTEX *p) +{ + bd_mutex_lock(p); + bd_mutex_unlock(p); + if (pthread_mutex_destroy(&p->mutex)) { + BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_destroy() failed !\n"); + return -1; + } + return 0; +} + +#endif /* HAVE_PTHREAD_H */ diff --git a/src/util/mutex.h b/src/util/mutex.h index 7704b13..cd230d9 100644 --- a/src/util/mutex.h +++ b/src/util/mutex.h @@ -1,6 +1,6 @@ /* * This file is part of libbluray - * Copyright (C) 2010 hpi1 + * Copyright (C) 2010-2014 Petri Hintukainen <[email protected]> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -57,6 +57,9 @@ typedef CRITICAL_SECTION BD_MUTEX; #elif defined(HAVE_PTHREAD_H) +#include "logging.h" +#include "macro.h" + /* * recursive mutex */ @@ -68,27 +71,8 @@ struct bd_mutex_s { pthread_mutex_t mutex; }; -static inline int bd_mutex_init(BD_MUTEX *p) -{ - p->owner = (pthread_t)-1; - p->lock_count = 0; - - if (pthread_mutex_init(&p->mutex, NULL)) { - BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_init() failed !\n"); - return -1; - } - - return 0; -} - -static inline int bd_mutex_destroy(BD_MUTEX *p) -{ - if (pthread_mutex_destroy(&p->mutex)) { - BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_destroy() failed !\n"); - return -1; - } - return 0; -} +BD_PRIVATE int bd_mutex_init(BD_MUTEX *p); +BD_PRIVATE int bd_mutex_destroy(BD_MUTEX *p); static int bd_mutex_lock(BD_MUTEX *p) { _______________________________________________ libbluray-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libbluray-devel
