[parted-devel] porting to FreeBSD

Debarshi 'Rishi' Ray debarshi.ray at gmail.com
Fri Mar 2 15:59:34 CET 2007


> Personally I don't think that is very good as it is copy-pasting and
> can introduce errors, not that I have much to do with parted
> development, just my thoughts.

I do not understand. Could you just re-phrase or be a bit more verbose?

> The problem with FreeBSD is a bit different, freebsd has the sigaction
> but it lacks many  MACROs one would check the value of struct
> siginfo_t.si_code against!

Well this is not identical to the Hurd scenario, but nevertheless very
similar because the absense of these macros is preventing you from taking
full leverage out of the 'sigaction' function to give detailed information
about the signal that was caught and what caused them.

> We could place a #ifdef block around any MACRO that sa_flag is checked
> against like this:
> 
>  switch(x.si_code) {
> #ifdef SEGV_MAPERR
>     case SEGV_MAPERR:
>     //.....
> #endif
>    //...
>    default:
>    //....
>  }

This is one possibility. I would like to know if only _some_ of these
macros are absent or _all_ of them are absent. eg., is it the case that
SEGV_MAPERR is absent, while SEGV_ACCERR is present? Do we see such a
behaviour in all the *BSDs?

> I don't think this is a good approach because when the "default:" code
> is executed you can't be sure which values x.si_code is checked
> against.

If for a particular signal, some of the macros are present while others
are not, then the above approach will atleast give us some detailed
information in those cases where they are present.

> Any way this is a FreeBSD brokenness and I think the best way
> to go for FreeBSD is to ignore its sigaction capabilities for now.

If there is no uniform pattern in which these macros are present or absent,
we can do something like:
#ifdef SA_SIGINFO
#ifdef SEGV_MAPPERR
#ifdef <any missing sigaction macro>
...
#define USE_SIGACTION
...
#endif
#endif
#endif
...and then depending upon whether USE_SIGACTION is defined or undefined,
we use 'sigaction' or 'signal'.

Happy hacking,
Debarshi
-- 
husband    v. use sparingly; conserve; save
husbandry  n. frugality; thrift; agriculture
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20070302/6ec99d18/attachment.pgp


More information about the parted-devel mailing list