math: Remove slow paths from atan2 [BZ #15267]
[glibc.git] / nss / nss_module.h
blob05c4791d110acd698ba376ce7f97f4c88595f658
1 /* Global list of NSS service modules.
2 Copyright (c) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #ifndef _NSS_MODULE_H
20 #define _NSS_MODULE_H
22 #include <nss.h>
23 #include <stdbool.h>
25 /* See nss_database.h for a summary of how this relates. */
27 /* Typed function pointers for all functions that can be defined by a
28 service module. */
29 struct nss_module_functions
31 #undef DEFINE_NSS_FUNCTION
32 #define DEFINE_NSS_FUNCTION(f) nss_##f *f;
33 #include "function.def"
36 /* Untyped version of struct nss_module_functions, for consistent
37 processing purposes. */
38 typedef void *nss_module_functions_untyped[sizeof (struct nss_module_functions)
39 / sizeof (void *)];
41 /* Initialization state of a NSS module. */
42 enum nss_module_state
44 nss_module_uninitialized,
45 nss_module_loaded,
46 nss_module_failed,
49 /* A NSS service module (potentially unloaded). Client code should
50 use the functions below. */
51 struct nss_module
53 /* Actual type is enum nss_module_state. Use int due to atomic
54 access. Used in a double-checked locking idiom. */
55 int state;
57 /* The function pointers in the module. */
58 union
60 struct nss_module_functions typed;
61 nss_module_functions_untyped untyped;
62 } functions;
64 /* Only used for __libc_freeres unloading. */
65 void *handle;
67 /* The next module in the list. */
68 struct nss_module *next;
70 /* The name of the module (as it appears in /etc/nsswitch.conf). */
71 char name[];
74 /* Allocates the NSS module NAME (of NAME_LENGTH bytes) and places it
75 into the global list. If it already exists in the list, return the
76 pre-existing module. This does not actually load the module.
77 Returns NULL on memory allocation failure. */
78 struct nss_module *__nss_module_allocate (const char *name,
79 size_t name_length) attribute_hidden;
81 /* Ensures that MODULE is in a loaded or failed state. */
82 bool __nss_module_load (struct nss_module *module) attribute_hidden;
84 /* Ensures that MODULE is loaded and returns a pointer to the function
85 NAME defined in it. Returns NULL if MODULE could not be loaded, or
86 if the function NAME is not defined in the module. */
87 void *__nss_module_get_function (struct nss_module *module, const char *name)
88 attribute_hidden;
90 /* Block attempts to dlopen any module we haven't already opened. */
91 void __nss_module_disable_loading (void);
93 /* Called from __libc_freeres. */
94 void __nss_module_freeres (void) attribute_hidden;
96 #endif /* NSS_MODULE_H */