Updated to fedora-glibc-20041210T0634
[glibc/history.git] / include / set-hooks.h
blob770b305309f7b352b775c588a934cb6dbded6c6c
1 /* Macros for using symbol sets for running lists of functions.
2 Copyright (C) 1994, 1995, 1997, 2000, 2003 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _SET_HOOKS_H
21 #define _SET_HOOKS_H 1
23 #define __need_size_t
24 #include <stddef.h>
25 #include <sys/cdefs.h>
27 #ifdef symbol_set_define
28 /* Define a hook variable called NAME. Functions put on this hook take
29 arguments described by PROTO. Use `text_set_element (NAME, FUNCTION)'
30 from gnu-stabs.h to add a function to the hook. */
32 # define DEFINE_HOOK(NAME, PROTO) \
33 typedef void __##NAME##_hook_function_t PROTO; \
34 symbol_set_define (NAME)
36 # define DECLARE_HOOK(NAME, PROTO) \
37 typedef void __##NAME##_hook_function_t PROTO;\
38 symbol_set_declare (NAME)
40 /* Run all the functions hooked on the set called NAME.
41 Each function is called like this: `function ARGS'. */
43 # define RUN_HOOK(NAME, ARGS) \
44 do { \
45 void *const *__unbounded ptr; \
46 for (ptr = (void *const *) symbol_set_first_element (NAME); \
47 ! symbol_set_end_p (NAME, ptr); ++ptr) \
48 (*(__##NAME##_hook_function_t *) *ptr) ARGS; \
49 } while (0)
51 /* Define a hook variable with NAME and PROTO, and a function called RUNNER
52 which calls each function on the hook in turn, with ARGS. */
54 # define DEFINE_HOOK_RUNNER(name, runner, proto, args) \
55 DEFINE_HOOK (name, proto); \
56 extern void runner proto; void runner proto { RUN_HOOK (name, args); }
58 #else
60 /* The system does not provide necessary support for this. */
61 # define DEFINE_HOOK(NAME, PROTO)
63 # define DECLARE_HOOK(NAME, PROTO)
65 # define RUN_HOOK(NAME, ARGS)
67 # define DEFINE_HOOK_RUNNER(name, runner, proto, args)
69 #endif
71 #endif /* set-hooks.h */