Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Nov 1995 06:09:48 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@freefall.freebsd.org, gibbs@freefall.freebsd.org
Cc:        CVS-commiters@freefall.freebsd.org, cvs-sys@freefall.freebsd.org
Subject:   Re: cvs commit: src/sys/pci if_pdq.c
Message-ID:  <199511041909.GAA03120@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>  Fixed the type of pdc_pci_ifintr().  The type of a PCI interrupt handler
>>  is too generic to pass arbitrary struct pointers.

>I thought that the point of the PCI interrupt handler type was to allow
>you to pass arbitrary struct pointers.  Hmm.  Now I'm confused.  I want
>to pass (struct ach_data *)'s to the aic7xxx interrupt routine.  What
>should be the type of an EISA interrupt handler to deal with this.  Right
>now I'm using "void  (*func)(void *)".

`void *' is correct but pdc_pci_ifintr() used `struct foo *'.  `void *'
can only be used (standards conformantly) to pass arbitrary struct
pointers if there are implicit or explicit casts to and from the struct
pointers.  Prototypes usually give implicit casts in one direction only.
Interrupt handlers that take a `void *' arg have to convert it back to
what the know it to have been converted from.  (Registration of a handler
does an implicit cast from a `cookie *' to a `void *' and stores the
result in a higher level struct; calling the handler passes this result
unchanged; the handler converts back to the original `cookie *'.  Note
that it would be too much trouble to make the higher level code convert
back to a `cookie *'.  You would have to tell the higher level all about
the type of the cookie and you would be limited to types that are known
when the higher level is compiled.  For similar reasons, it us too much
trouble to use variant function types.)

In practice, all struct pointer types usually have the same
representation and this representation is (slightly less) usually the
same as for `void *', so it usually works at runtime to confuse struct
pointers with `void *'s.  However, it doesn't work at compile time
unless you lie to the compiler.  Not lieing is easiest in this case
essentially because there are relatively few interrupt handler types.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511041909.GAA03120>