00001
00002
00003
00004
00005
00006
00007
00008 #ifndef CALLBACK_H
00009 #define CALLBACK_H
00010
00011 #include "array.h"
00012
00013 struct callback;
00014
00015 struct callback_list
00016 {
00017 struct callback *callbacks;
00018 int num_calls;
00019 };
00020
00021 extern struct callback_list fork_child_callback;
00022
00023 typedef void (*callback_func)(struct callback *, void *,void *);
00024
00025 #include "block_alloc_h.h"
00026
00027 struct callback;
00028 BLOCK_ALLOC(callback, CALLBACK_CHUNK);
00029 PMOD_EXPORT void low_call_callback(struct callback_list *lst, void *arg);
00030 PMOD_EXPORT struct callback *debug_add_to_callback(struct callback_list *lst,
00031 callback_func call,
00032 void *arg,
00033 callback_func free_func);
00034 PMOD_EXPORT void *remove_callback(struct callback *l);
00035 void free_callback_list(struct callback_list *lst);
00036 void cleanup_callbacks(void);
00037
00038
00039 #define add_to_callback(LST,CALL,ARG,FF) \
00040 dmalloc_touch(struct callback *,debug_add_to_callback((LST),(CALL),(ARG),(FF)))
00041
00042 #if 1
00043 #define call_callback(LST, ARG) do { \
00044 struct callback_list *lst_=(LST); \
00045 void *arg_=(ARG); \
00046 if(lst_->callbacks) low_call_callback(lst_, arg_); \
00047 }while(0)
00048 #else
00049 #define call_callback(LST, ARG) low_call_callback((LST), (ARG))
00050 #endif
00051
00052 #endif