[haiku-development] Re: [PATCH] Attempts to build haiku on linux/ppc

On 2008-05-27 at 15:41:34 [+0200], Konstantinos Margaritis 
<markos@xxxxxxxx> wrote:
> On Τρι 27 Μαι 2008, Axel Dörfler wrote:
> > Stephan Assmus <superstippi@xxxxxx> wrote:
> > > The patch proposed in this message seems wrong to me, and also
> > > the patch
> > > that Konstantinos posted. I think the real problem is in this
> > > file:
> > >
> > > headers/private/fs_shell/fssh_api_wrapper.h
> > >
> > > This is what get's included instead of ByteOrder.h if the
> > > bfs_shell is
> > > built for the host platform. I might be wrong on this, it is as
> > > much as I
> > > could find out when trying to follow the include paths of the
> > > problematic
> > > files. Maybe Ingo can shed some light on this?
> >
> > It was definitely wrong. I changed it now (in r25671), but I
> > couldn't find the fssh_*() swapping functions, so maybe it won't
> > help -- but maybe there is some build magic I missed :-)
> 
> I won't help, I tried using the fssh_*() functions myself. After a
> little research, I found that the problem is that BFS when used
> inside BeOS/Haiku includes ByteOrder.h properly. However when built
> outside BeOS/Haiku, ByteOrder.h (and many other os specific includes
> in headers/build/os/support and headers/build/os) are not included,
> not even the include path is passed in gcc flags. Instead fssh_*
> includes are used, but these define the same macros with different
> names, and also declare these extern functions :
> 
> extern double __fssh_swap_double(double arg);
> extern float  __fssh_swap_float(float arg);
> extern uint64_t __fssh_swap_int64(uint64_t arg);
> extern uint32_t __fssh_swap_int32(uint32_t arg);
> extern uint16_t __fssh_swap_int16(uint16_t arg);
> 
> And this is the problem. Bfs files still use the old macros, which use
> __swap_int*() (ie without the fssh_ part).
> The thing is I don't know enough of Haiku's internals to see what
> would be the right solution. So far I see 2 solutions:
> 
> a) Duplicate ByteOrder.h only for bfs_shell and make sure it uses only
> the BFS_ macros with __swap_int*
> b) Fix BFS and bfs_shell so that it uses the FSSH_ macros when built
> with BUILDING_FS_SHELL is defined.

This is how it is supposed to work: The BFS sources don't include system 
headers directly. Instead they only include the system_dependencies.h 
header, which includes all required headers. When building for Haiku, those 
are the normal system headers. When building for the bfs_shell, 
fssh_api_wrapper.h is included, which in turn includes fssh_*.h headers 
corresponding to the system headers. Those are equivalent to the system 
headers, save that they define the functions, constants, and macros with 
fssh_ respectively FSSH_ prefix. Furthermore fssh_api_wrapper.h defines 
macros that map the names of all functions, constants, and macros that are 
defined in the system headers to their fssh_*/FSSH_* counterpart.

E.g. the BFS_ENDIAN_TO_HOST_INT32 macro defined in bfs_endian.h uses 
__swap_int32, which fssh_api_wrapper.h translates to __fssh_swap_int32 (the 
macro was broken; Axel fixed it in r25671), which is declared in the 
included fssh_byte_order.h. The only remaining problem should be that the 
FS shell doesn't define the function yet.

CU, Ingo

Other related posts: