(parse_glob): Look for end of word instead of
[glibc/history.git] / include / set-hooks.h
blob995bdf412020f9d852f03eab5e132555d985f2a2
1 /* Macros for using symbol sets for running lists of functions.
2 Copyright (C) 1994, 1995, 1997 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 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 /* Define a hook variable called NAME. Functions put on this hook take
28 arguments described by PROTO. Use `text_set_element (NAME, FUNCTION)'
29 from gnu-stabs.h to add a function to the hook. */
31 #define DEFINE_HOOK(NAME, PROTO) \
32 typedef void __##NAME##_hook_function_t PROTO; \
33 symbol_set_define (NAME)
35 #define DECLARE_HOOK(NAME, PROTO) \
36 typedef void __##NAME##_hook_function_t PROTO;\
37 symbol_set_declare (NAME)
39 /* Run all the functions hooked on the set called NAME.
40 Each function is called like this: `function ARGS'. */
42 #define RUN_HOOK(NAME, ARGS) \
43 do { \
44 void *const *ptr; \
45 for (ptr = symbol_set_first_element (NAME); \
46 ! symbol_set_end_p (NAME, ptr); ++ptr) \
47 (*(__##NAME##_hook_function_t *) *ptr) ARGS; \
48 } while (0)
50 /* Define a hook variable with NAME and PROTO, and a function called RUNNER
51 which calls each function on the hook in turn, with ARGS. */
53 #define DEFINE_HOOK_RUNNER(name, runner, proto, args) \
54 DEFINE_HOOK (name, proto); void runner proto { RUN_HOOK (name, args); }
57 #endif /* set-hooks.h */