[haiku-gsoc] Re: Licensing questions

  • From: Vivek Roy <vivekroyandroid@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Sun, 11 Jun 2017 17:00:18 +0530

I tried with bsd/sys/cdefs.h but it wasn't working. But having a macro
defined as Hamish said worked. Thanks again Hamish.

On 11-Jun-2017 2:35 AM, "Hamish Morrison" <hamishm53@xxxxxxxxx> wrote:

On 09/06/2017 18:03, Vivek Roy wrote:

Yet again, in types.h there is strictly rcu_head where they have used
__aligned(size of(void *))

I can see that __aligned is defined in posix/arch and
compat/freebsd_network

I haven't included any of those and am getting an error "expected
declaration specifiers or '...' before 'sizeof' "
A Google search gave me possible reasons being, syntax errors and
circular dependencies. I checked for both, found none.
Help?


__aligned is just a macro that tells the compiler that the type in
question aught to be aligned on the boundary given (in this case given the
same alignment as a pointer). Typically fundamental types will be aligned
on their size (an int on a 4 byte boundary, longs on 8 byte boundaries,
etc). But using a directive like this you can force alignment to a larger
boundary.

It will expand to some compiler-dependent directive for configuring
alignment e.g. for gcc it would be something like:

__attribute__((aligned(sizeof(void*))))

Since we only build with gcc you could just replace this with the above (I
believe clang also supports this syntax).

Or you could define a macro somewhere e.g.

#define __aligned(x) __attribute__((aligned(x)))


Other related posts: