Subject: Re: merge of freebsd eventhandler
To: Brett Lymn <>
From: Chapman Flack <>
List: tech-kern
Date: 05/27/2006 12:33:02
Brett Lymn wrote:
> No, it's not the establish that is the problem, it's the hook function
> that gets called (the powerhook_establish was just a type change for
> the function argument).

I saw that, honest. ;)

I was thinking of something like this pseudocode:

void *phook_establish_40((fn)(a,why),a);  // the new one

void *phook_establish_30((fn)(why,a),a);      // deprecated

#define phook_establish phook_establish_30

typedef struct { (fn)(why,a); a } closure;

void wrap(a,why) {
  cl = (closure *)a;

void *phook_establish_30((fn)(why,a),a) {
  phook_establish_40(wrap, new closure = {fn,a});

> would be a difficult task because you would have to somehow apply that
> wrapper to each hook function on the hook list in a dynamic fashion.

This does require a small dynamic allocation (of the closure) at
establish time, and a corresponding free at disestablish time (which
is achievable without API change because the disestablish cookie is
already opaque) but it doesn't complicate anything else. In particular
you don't do anything special when running the queue.