Files
glibc/include/set-hooks.h
T

72 lines
2.4 KiB
C
Raw Normal View History

1995-02-18 01:27:10 +00:00
/* Macros for using symbol sets for running lists of functions.
2003-06-11 21:57:23 +00:00
Copyright (C) 1994, 1995, 1997, 2000, 2003 Free Software Foundation, Inc.
1997-06-21 02:59:26 +00:00
This file is part of the GNU C Library.
1995-02-18 01:27:10 +00:00
1997-06-21 02:59:26 +00:00
The GNU C Library is free software; you can redistribute it and/or
2001-07-06 04:58:11 +00:00
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
1995-02-18 01:27:10 +00:00
1997-06-21 02:59:26 +00:00
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2001-07-06 04:58:11 +00:00
Lesser General Public License for more details.
1995-02-18 01:27:10 +00:00
2001-07-06 04:58:11 +00:00
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
1995-02-18 01:27:10 +00:00
#ifndef _SET_HOOKS_H
1997-06-21 02:59:26 +00:00
#define _SET_HOOKS_H 1
1995-02-18 01:27:10 +00:00
#define __need_size_t
#include <stddef.h>
#include <sys/cdefs.h>
2000-02-28 21:16:38 +00:00
#ifdef symbol_set_define
1995-02-18 01:27:10 +00:00
/* Define a hook variable called NAME. Functions put on this hook take
arguments described by PROTO. Use `text_set_element (NAME, FUNCTION)'
from gnu-stabs.h to add a function to the hook. */
2000-02-28 21:16:38 +00:00
# define DEFINE_HOOK(NAME, PROTO) \
1995-02-18 01:27:10 +00:00
typedef void __##NAME##_hook_function_t PROTO; \
symbol_set_define (NAME)
2000-02-28 21:16:38 +00:00
# define DECLARE_HOOK(NAME, PROTO) \
1995-02-18 01:27:10 +00:00
typedef void __##NAME##_hook_function_t PROTO;\
symbol_set_declare (NAME)
/* Run all the functions hooked on the set called NAME.
Each function is called like this: `function ARGS'. */
2003-06-11 21:57:23 +00:00
# define RUN_HOOK(NAME, ARGS) \
do { \
void *const *__unbounded ptr; \
for (ptr = (void *const *) symbol_set_first_element (NAME); \
! symbol_set_end_p (NAME, ptr); ++ptr) \
(*(__##NAME##_hook_function_t *) *ptr) ARGS; \
1995-02-18 01:27:10 +00:00
} while (0)
/* Define a hook variable with NAME and PROTO, and a function called RUNNER
which calls each function on the hook in turn, with ARGS. */
2000-02-28 21:16:38 +00:00
# define DEFINE_HOOK_RUNNER(name, runner, proto, args) \
2000-11-20 09:16:41 +00:00
DEFINE_HOOK (name, proto); \
extern void runner proto; void runner proto { RUN_HOOK (name, args); }
1995-02-18 01:27:10 +00:00
2000-02-28 21:16:38 +00:00
#else
/* The system does not provide necessary support for this. */
# define DEFINE_HOOK(NAME, PROTO)
# define DECLARE_HOOK(NAME, PROTO)
# define RUN_HOOK(NAME, ARGS)
# define DEFINE_HOOK_RUNNER(name, runner, proto, args)
#endif
1995-02-18 01:27:10 +00:00
1997-06-21 02:59:26 +00:00
#endif /* set-hooks.h */