[DTrace-devel] [PATCH v2 06/20] uapi headers: include <sys/dtrace_types> as needed

Kris Van Hees kris.van.hees at oracle.com
Fri Sep 16 04:29:56 UTC 2022


On Wed, Sep 07, 2022 at 01:59:54PM +0100, Nick Alcock via DTrace-devel wrote:
> This is needed for _LITTLE_ENDIAN and _BIG_ENDIAN.
> 
> Add a new internals test to identify this class of failure.
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
> ---
>  include/dtrace/actions_defines.h              |  1 +
>  include/dtrace/dof_defines.h                  |  3 +-
>  .../headers/tst.header-endianness.sh          | 29 +++++++++++++++++++
>  3 files changed, 32 insertions(+), 1 deletion(-)
>  create mode 100755 test/internals/headers/tst.header-endianness.sh
> 
> diff --git a/include/dtrace/actions_defines.h b/include/dtrace/actions_defines.h
> index dfec34f3ddc2..f161df7cf13f 100644
> --- a/include/dtrace/actions_defines.h
> +++ b/include/dtrace/actions_defines.h
> @@ -13,6 +13,7 @@
>  #ifndef _DTRACE_ACTIONS_DEFINES_H
>  #define _DTRACE_ACTIONS_DEFINES_H
>  
> +#include <sys/dtrace_types.h>
>  #include <dtrace/universal.h>
>  
>  /*
> diff --git a/include/dtrace/dof_defines.h b/include/dtrace/dof_defines.h
> index 02d650c22831..4a7c4185fa4b 100644
> --- a/include/dtrace/dof_defines.h
> +++ b/include/dtrace/dof_defines.h
> @@ -2,7 +2,7 @@
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   *
> - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
>   */
>  
>  /*
> @@ -13,6 +13,7 @@
>  #ifndef _DTRACE_DOF_DEFINES_H
>  #define _DTRACE_DOF_DEFINES_H
>  
> +#include <sys/dtrace_types.h>
>  #include <dtrace/universal.h>
>  
>  /*
> diff --git a/test/internals/headers/tst.header-endianness.sh b/test/internals/headers/tst.header-endianness.sh
> new file mode 100755
> index 000000000000..18c3fb0b26be
> --- /dev/null
> +++ b/test/internals/headers/tst.header-endianness.sh
> @@ -0,0 +1,29 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +#
> +
> +set -e
> +
> +dtrace=$1
> +CC=/usr/bin/gcc
> +OLDDIRNAME=`pwd`
> +CFLAGS="-I${PWD}/include"

When looiking at the compiler invocation below, I don't see hos this is going
to work.  Or even how it can work on your system.  The sys/dtrace_types.h file
is found in uts/common in the source tree and /usr/include when installed.

This test needs to be able to pass both for in-tree testing and installed
teting.

> +
> +DIRNAME="$tmpdir/usdt-entryreturn.$$.$RANDOM"

Copy and paste mistake?  THis surely should be named after this test.

> +mkdir -p $DIRNAME
> +cd $DIRNAME
> +
> +for header in ${OLDDIRNAME}/include/dtrace/*.h; do

Same problem as above...  you need to ensure you are looking in the right
places for the header files to check or else you may get a false positive.

> +    grep -q _ENDIAN $header || continue
> +    cat > test.c <<EOF
> +    #include "$header"
> +    #if !defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
> +    #error $header: needs to include <sys/dtrace_types.h>
> +    #endif
> +EOF
> +    $CC -c $CFLAGS -o /dev/null test.c
> +done
> -- 
> 2.37.1.265.g363c192786.dirty
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list