[haiku-gsoc] Re: Xsi semaphorses: patch #1

  • From: "Salvatore Benedetto" <emitrax@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Mon, 14 Jul 2008 09:10:46 +0000

2008/7/13 Stephan Assmus <superstippi@xxxxxx>:
>
> -------- Original-Nachricht --------
>> Datum: Sun, 13 Jul 2008 23:12:05 +0200 CEST
>> Von: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
>> An: haiku-gsoc@xxxxxxxxxxxxx
>> Betreff: [haiku-gsoc] Re: Xsi semaphorses: patch #1
>
>> Stephan Assmus <superstippi@xxxxxx> wrote:
>> > I have a question about the patch:
>> >
>> > +#define RETURN_AND_SET_ERRNO(status) \
>> > [...]
>> >
>> > With how the macro "RETURN_AND_SET_ERRNO" is defined, wouldn't it
>> > result in
>> > the function that you pass to the marco being called twice?
>>
>> Definitely, nice catch!
>
> Maybe we should grep the source for that one, I have a faint memory of having 
> seen this macro before. ;-)

In fact you have a good memory. That's one of the many
RETURN_AND_SET_ERRNO macro definitions you can
find in Haiku. At first, I used the one defined in syscall_utils.h

#define RETURN_AND_SET_ERRNO(err)           \
    do {                                    \
        __typeof(err) raseResult = (err);   \
        if (raseResult < 0) {               \
            errno = raseResult;             \
            return -1;                      \
        }                                   \
        return raseResult;                  \
    } while (false)

but this would cause the C file not to compile due to a syntax error,
so I grabbed the one in src/system/libroot/os/fs_attr.c.

Regards,
-- 
Salvatore Benedetto (a.k.a. emitrax)
Student of Computer Engineer
University of Pisa
www.haiku-os.it

Other related posts: