LCOV - code coverage report
Current view: top level - builds/gnutls/coverage/gnutls-git/lib - locks.c (source / functions) Hit Total Coverage
Test: GnuTLS-3.6.14 Code Coverage Lines: 0 12 0.0 %
Date: 2020-10-30 04:50:48 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2010-2012 Free Software Foundation, Inc.
       3             :  *
       4             :  * Author: Nikos Mavrogiannopoulos
       5             :  *
       6             :  * This file is part of GnuTLS.
       7             :  *
       8             :  * The GnuTLS is free software; you can redistribute it and/or
       9             :  * modify it under the terms of the GNU Lesser General Public License
      10             :  * as published by the Free Software Foundation; either version 2.1 of
      11             :  * the License, or (at your option) any later version.
      12             :  *
      13             :  * This library is distributed in the hope that it will be useful, but
      14             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16             :  * Lesser General Public License for more details.
      17             :  *
      18             :  * You should have received a copy of the GNU Lesser General Public License
      19             :  * along with this program.  If not, see <https://www.gnu.org/licenses/>
      20             :  *
      21             :  */
      22             : 
      23             : #include "gnutls_int.h"
      24             : #include "errors.h"
      25             : #include <libtasn1.h>
      26             : #include <dh.h>
      27             : #include <random.h>
      28             : 
      29             : #include <locks.h>
      30             : 
      31             : 
      32             : /**
      33             :  * gnutls_global_set_mutex:
      34             :  * @init: mutex initialization function
      35             :  * @deinit: mutex deinitialization function
      36             :  * @lock: mutex locking function
      37             :  * @unlock: mutex unlocking function
      38             :  *
      39             :  * With this function you are allowed to override the default mutex
      40             :  * locks used in some parts of gnutls and dependent libraries. This function
      41             :  * should be used if you have complete control of your program and libraries.
      42             :  * Do not call this function from a library, or preferably from any application
      43             :  * unless really needed to. GnuTLS will use the appropriate locks for the running
      44             :  * system.
      45             :  *
      46             :  * Note that since the move to implicit initialization of GnuTLS on library
      47             :  * load, calling this function will deinitialize the library, and re-initialize
      48             :  * it after the new locking functions are set.
      49             :  *
      50             :  * This function must be called prior to any other gnutls function.
      51             :  * 
      52             :  * Since: 2.12.0
      53             :  **/
      54             : void
      55           0 : gnutls_global_set_mutex(mutex_init_func init, mutex_deinit_func deinit,
      56             :                         mutex_lock_func lock, mutex_unlock_func unlock)
      57             : {
      58           0 : int ret;
      59             : 
      60           0 :         if (init == NULL || deinit == NULL || lock == NULL
      61           0 :             || unlock == NULL)
      62             :                 return;
      63             : 
      64           0 :         gnutls_global_deinit();
      65             : 
      66           0 :         gnutls_mutex_init = init;
      67           0 :         gnutls_mutex_deinit = deinit;
      68           0 :         gnutls_mutex_lock = lock;
      69           0 :         gnutls_mutex_unlock = unlock;
      70             : 
      71           0 :         ret = gnutls_global_init();
      72           0 :         if (ret < 0)
      73           0 :                 _gnutls_debug_log("error in gnutls_global_init(): %s\n", gnutls_strerror(ret));
      74             : }

Generated by: LCOV version 1.14