execute, spawn-pipe: Make multithread-safe on native Windows.
[gnulib.git] / lib / gl_xomap.h
blob99c8c31f480654ef403476ba1abd2ebc7466adb7
1 /* Abstract ordered map data type, with out-of-memory checking.
2 Copyright (C) 2009-2020 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2018.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #ifndef _GL_XOMAP_H
19 #define _GL_XOMAP_H
21 #include "gl_omap.h"
22 #include "xalloc.h"
24 #ifndef _GL_INLINE_HEADER_BEGIN
25 #error "Please include config.h first."
26 #endif
27 _GL_INLINE_HEADER_BEGIN
28 #ifndef GL_XOMAP_INLINE
29 # define GL_XOMAP_INLINE _GL_INLINE
30 #endif
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 /* These functions are thin wrappers around the corresponding functions with
38 _nx_ infix from gl_omap.h. Upon out-of-memory, they invoke xalloc_die (),
39 instead of returning an error indicator. */
40 #if 0 /* These are defined inline below. */
41 extern gl_omap_t gl_omap_create_empty (gl_omap_implementation_t implementation,
42 gl_mapkey_compar_fn compar_fn,
43 gl_mapkey_dispose_fn kdispose_fn,
44 gl_mapvalue_dispose_fn vdispose_fn);
45 extern bool gl_omap_put (gl_omap_t map, const void *key, const void *value);
46 extern bool gl_omap_getput (gl_omap_t map, const void *key, const void *value,
47 const void **oldvaluep);
48 #endif
50 GL_XOMAP_INLINE gl_omap_t
51 gl_omap_create_empty (gl_omap_implementation_t implementation,
52 gl_mapkey_compar_fn compar_fn,
53 gl_mapkey_dispose_fn kdispose_fn,
54 gl_mapvalue_dispose_fn vdispose_fn)
56 gl_omap_t result =
57 gl_omap_nx_create_empty (implementation, compar_fn, kdispose_fn, vdispose_fn);
58 if (result == NULL)
59 xalloc_die ();
60 return result;
63 GL_XOMAP_INLINE bool
64 gl_omap_put (gl_omap_t map, const void *key, const void *value)
66 int result = gl_omap_nx_put (map, key, value);
67 if (result < 0)
68 xalloc_die ();
69 return result;
72 GL_XOMAP_INLINE bool
73 gl_omap_getput (gl_omap_t map, const void *key, const void *value,
74 const void **oldvaluep)
76 int result = gl_omap_nx_getput (map, key, value, oldvaluep);
77 if (result < 0)
78 xalloc_die ();
79 return result;
82 #ifdef __cplusplus
84 #endif
86 _GL_INLINE_HEADER_END
88 #endif /* _GL_XOMAP_H */