diff mbox series

[v2,3/8] drm/xe: xe_gen_wa_oob: fix program_invocation_short_name for macos

Message ID 20240906-macos-build-support-v2-3-06beff418848@samsung.com
State New
Headers show
Series Enable build system on macOS hosts | expand

Commit Message

Daniel Gomez via B4 Relay Sept. 6, 2024, 11:01 a.m. UTC
From: Daniel Gomez <da.gomez@samsung.com>

Use getprogname() [1] instead of program_invocation_short_name() [2]
for macOS hosts.

[1]:
https://www.gnu.org/software/gnulib/manual/html_node/
program_005finvocation_005fshort_005fname.html

[2]:
https://developer.apple.com/library/archive/documentation/System/
Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html

Fixes build error for macOS hosts:

drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of
undeclared identifier 'program_invocation_short_name'    34 |
program_invocation_short_name);       |                 ^ 1 error
generated.

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_gen_wa_oob.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Masahiro Yamada Sept. 6, 2024, 2:39 p.m. UTC | #1
On Fri, Sep 6, 2024 at 8:01 PM Daniel Gomez via B4 Relay
<devnull+da.gomez.samsung.com@kernel.org> wrote:
>
> From: Daniel Gomez <da.gomez@samsung.com>
>
> Use getprogname() [1] instead of program_invocation_short_name() [2]
> for macOS hosts.
>
> [1]:
> https://www.gnu.org/software/gnulib/manual/html_node/
> program_005finvocation_005fshort_005fname.html
>
> [2]:
> https://developer.apple.com/library/archive/documentation/System/
> Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html
>
> Fixes build error for macOS hosts:
>
> drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of
> undeclared identifier 'program_invocation_short_name'    34 |
> program_invocation_short_name);       |                 ^ 1 error
> generated.
>
> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_gen_wa_oob.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> index 904cf47925aa..0d933644d8a0 100644
> --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> @@ -8,6 +8,7 @@
>  #include <errno.h>
>  #include <stdbool.h>
>  #include <stdio.h>
> +#include <stdlib.h>
>  #include <string.h>
>
>  #define HEADER \
> @@ -30,6 +31,9 @@
>
>  static void print_usage(FILE *f)
>  {
> +#ifdef __APPLE__
> +       const char *program_invocation_short_name = getprogname();
> +#endif
>         fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n",
>                 program_invocation_short_name);
>  }
>
> --
> 2.46.0
>
>



Before adding such #ifdef, you should check how other programs do.









Solution 1 : hard-code the program name


diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
index 106ee2b027f0..9e9a29e2cecf 100644
--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
@@ -30,8 +30,7 @@

 static void print_usage(FILE *f)
 {
-       fprintf(f, "usage: %s <input-rule-file>
<generated-c-source-file> <generated-c-header-file>\n",
-               program_invocation_short_name);
+       fprintf(f, "usage: xe_gen_wa_oob <input-rule-file>
<generated-c-source-file> <generated-c-header-file>\n");
 }

 static void print_parse_error(const char *err_msg, const char *line,








Solution 2: use argv[0]


diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
index 106ee2b027f0..600c63e88e46 100644
--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
@@ -28,10 +28,10 @@
        "\n" \
        "#endif\n"

-static void print_usage(FILE *f)
+static void print_usage(FILE *f, const char *progname)
 {
        fprintf(f, "usage: %s <input-rule-file>
<generated-c-source-file> <generated-c-header-file>\n",
-               program_invocation_short_name);
+               progname);
 }

 static void print_parse_error(const char *err_msg, const char *line,
@@ -136,7 +136,7 @@ int main(int argc, const char *argv[])

        if (argc < 3) {
                fprintf(stderr, "ERROR: wrong arguments\n");
-               print_usage(stderr);
+               print_usage(stderr, argv[0]);
                return 1;
        }
Jani Nikula Sept. 6, 2024, 3:32 p.m. UTC | #2
On Fri, 06 Sep 2024, Masahiro Yamada <masahiroy@kernel.org> wrote:
> On Fri, Sep 6, 2024 at 8:01 PM Daniel Gomez via B4 Relay
> <devnull+da.gomez.samsung.com@kernel.org> wrote:
>>
>> From: Daniel Gomez <da.gomez@samsung.com>
>>
>> Use getprogname() [1] instead of program_invocation_short_name() [2]
>> for macOS hosts.
>>
>> [1]:
>> https://www.gnu.org/software/gnulib/manual/html_node/
>> program_005finvocation_005fshort_005fname.html
>>
>> [2]:
>> https://developer.apple.com/library/archive/documentation/System/
>> Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html
>>
>> Fixes build error for macOS hosts:
>>
>> drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of
>> undeclared identifier 'program_invocation_short_name'    34 |
>> program_invocation_short_name);       |                 ^ 1 error
>> generated.
>>
>> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
>> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_gen_wa_oob.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>> index 904cf47925aa..0d933644d8a0 100644
>> --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
>> @@ -8,6 +8,7 @@
>>  #include <errno.h>
>>  #include <stdbool.h>
>>  #include <stdio.h>
>> +#include <stdlib.h>
>>  #include <string.h>
>>
>>  #define HEADER \
>> @@ -30,6 +31,9 @@
>>
>>  static void print_usage(FILE *f)
>>  {
>> +#ifdef __APPLE__
>> +       const char *program_invocation_short_name = getprogname();
>> +#endif
>>         fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n",
>>                 program_invocation_short_name);
>>  }
>>
>> --
>> 2.46.0
>>
>>
>
>
>
> Before adding such #ifdef, you should check how other programs do.

IMO either option is preferred over adding #ifdefs.

BR,
Jani.


>
>
>
>
>
>
>
>
>
> Solution 1 : hard-code the program name
>
>
> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> index 106ee2b027f0..9e9a29e2cecf 100644
> --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> @@ -30,8 +30,7 @@
>
>  static void print_usage(FILE *f)
>  {
> -       fprintf(f, "usage: %s <input-rule-file>
> <generated-c-source-file> <generated-c-header-file>\n",
> -               program_invocation_short_name);
> +       fprintf(f, "usage: xe_gen_wa_oob <input-rule-file>
> <generated-c-source-file> <generated-c-header-file>\n");
>  }
>
>  static void print_parse_error(const char *err_msg, const char *line,
>
>
>
>
>
>
>
>
> Solution 2: use argv[0]
>
>
> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> index 106ee2b027f0..600c63e88e46 100644
> --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
> @@ -28,10 +28,10 @@
>         "\n" \
>         "#endif\n"
>
> -static void print_usage(FILE *f)
> +static void print_usage(FILE *f, const char *progname)
>  {
>         fprintf(f, "usage: %s <input-rule-file>
> <generated-c-source-file> <generated-c-header-file>\n",
> -               program_invocation_short_name);
> +               progname);
>  }
>
>  static void print_parse_error(const char *err_msg, const char *line,
> @@ -136,7 +136,7 @@ int main(int argc, const char *argv[])
>
>         if (argc < 3) {
>                 fprintf(stderr, "ERROR: wrong arguments\n");
> -               print_usage(stderr);
> +               print_usage(stderr, argv[0]);
>                 return 1;
>         }
diff mbox series

Patch

diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
index 904cf47925aa..0d933644d8a0 100644
--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c
+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c
@@ -8,6 +8,7 @@ 
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #define HEADER \
@@ -30,6 +31,9 @@ 
 
 static void print_usage(FILE *f)
 {
+#ifdef __APPLE__
+	const char *program_invocation_short_name = getprogname();
+#endif
 	fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n",
 		program_invocation_short_name);
 }