[haiku-commits] Re: BRANCH mmadia-github.separate-build-environment - headers/build/os_target/support headers/build/posix_target headers/build/config_target src/build/libroot headers/build/posix_target/sys

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 06 Aug 2012 12:09:03 +0200

On 2012-08-06 at 06:49:38 [+0200], mmadia-github.separate-build-environment 
<community@xxxxxxxxxxxx> wrote:
> diff --git a/headers/build/os_target/support/target_ByteOrder.h 
> b/headers/build/os_target/support/target_ByteOrder.h
> new file mode 100644
> index 0000000..2399df4
> --- /dev/null
> +++ b/headers/build/os_target/support/target_ByteOrder.h
[...]
> +// NOTE: #8730 -- do enums need a version for #ifndef 
> _HAIKU_BUILD_LIBROOT_FUNCTION_WRAPPER?
> +/* swap directions */
> +typedef enum {
> +    _HAIKU_BUILD_B_SWAP_HOST_TO_LENDIAN,
> +    _HAIKU_BUILD_B_SWAP_HOST_TO_BENDIAN,
> +    _HAIKU_BUILD_B_SWAP_LENDIAN_TO_HOST,
> +    _HAIKU_BUILD_B_SWAP_BENDIAN_TO_HOST,
> +    _HAIKU_BUILD_B_SWAP_ALWAYS
> +} _haiku_build_swap_action;

If the enum is named (unlike this one), _HAIKU_BUILD_IDENTIFIER needs to be 
used for its name (just like for structs). For the typedef name the same 
holds as for all other typedefs, i.e. you can choose between the two 
approaches. For the enumeration values I intended for _HAIKU_BUILD_IDENTIFIER 
to be used, though ATM I can't think of a reason why the same approach as for 
macros wouldn't work for them as well. So I guess you can stick with it, if 
you want.

[...]
> +// NOTE: #8730 -- does BYTE_ORDER need to be _HAIKU_BUILD_BYTE_ORDER ?
> +#    if BYTE_ORDER == __LITTLE_ENDIAN

The rules are always the same: If it comes from the compiler, it can and 
should be used without prefix, otherwise it needs the usual conditional 
handling. I believe __LITTLE_ENDIAN, __BIG_ENDIAN, AND __BYTE_ORDER are 
defined by the compiler, so you leave them unchanged, while BYTE_ORDER is 
defined in <endian.h> and it needs treatment.

> diff --git a/src/build/libroot/byteorder.cpp 
> b/src/build/libroot/byteorder.cpp
> index 49274ae..e25a855 100644
> --- a/src/build/libroot/byteorder.cpp
> +++ b/src/build/libroot/byteorder.cpp
> @@ -5,24 +5,26 @@
>  //#    include <BeOSBuildCompatibility.h>
>  //#endif
>  
> -#include <ByteOrder.h>
> +#include <target_ByteOrder.h>
>  
> -uint16
> -__swap_int16(uint16 value)
> +_haiku_build_uint16
> +__haiku_build_swap_int16(_haiku_build_uint16 value)
>  {
>      return (value >> 8) | (value << 8);
>  }

That doesn't look quite right. Since the _HAIKU_BUILD_DECLARE_FUNCTION macro 
isn't particularly intelligent and just prepends the prefix, I believe the 
function name ends up being _haiku_build___swap_int16.

CU, Ingo

Other related posts: