summaryrefslogtreecommitdiffstats
path: root/src/H5FDperform.c
blob: 096fdd630b5dc7316686492524de718ffe0d10a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/****************/
/* Module Setup */
/****************/

#include "H5FDmodule.h" /* This source code file is part of the H5FD module */

/***********/
/* Headers */
/***********/
#include "H5private.h"   /* Generic Functions                        */
#include "H5CXprivate.h" /* API Contexts                             */
#include "H5Eprivate.h"  /* Error handling                           */
#include "H5FDpkg.h"     /* File Drivers                             */
#include "H5Iprivate.h"  /* IDs                                      */

/*-------------------------------------------------------------------------
 * Function:    H5FDperform_init
 *
 * Purpose:     Ensure that the library is initialized and then call
 *              the provided VFD initializer.
 *
 * Return:      Success:        identifier for the VFD just initialized
 *              Failure:        H5I_INVALID_HID
 *-------------------------------------------------------------------------
 */
hid_t H5FDperform_init(hid_t (*init)(void))
{
    hid_t ret_value = H5I_INVALID_HID; /* Return value */

    FUNC_ENTER_API_NOINIT
    /*NO TRACE*/

    /* It is possible that an application will evaluate an
     * `H5FD_*` symbol (`H5FD_FAMILY`, `H5FD_MULTI`, `H5FD_SEC2`, et
     * cetera) before the library has had an opportunity to initialize.
     * Call H5_init_library() to make sure that the library has been
     * initialized before `init` is run.
     */
    if (H5_init_library() < 0) {
        HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, H5I_INVALID_HID, "library initialization failed")
    }

    ret_value = init();
done:
    FUNC_LEAVE_API_NOINIT(ret_value)
}