public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Steve Baird <baird@adacore.com>
Subject: [COMMITTED] ada: Generate missing object decls for adainit/adafinal registration calls
Date: Fri,  4 Nov 2022 14:55:51 +0100	[thread overview]
Message-ID: <20221104135551.85648-1-poulhies@adacore.com> (raw)

From: Steve Baird <baird@adacore.com>

A previous change on this ticket introduced calls to CUDA_Register_Function
for adainit and adafinal, but failed to introduce declarations for the
C string variables that are initialized and then passed as actual parameters
in this call. Provide the missing declarations (and, incidentally, change
the names of the two variables).

gcc/ada/

	* bindgen.adb: Introduce two new string constants for the names of
	the C-String variables that are assigned the names for adainit and
	adafinal. Replace string literals in Gen_CUDA_Init with references
	to these constants. In Gen_CUDA_Defs, generate C-String variable
	declarations where these constants are the names of the variables.

Tested on x86_64-pc-linux-gnu, committed on master.
---
 gcc/ada/bindgen.adb | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index 1daa03dd7b8..4e89918b51d 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -114,6 +114,11 @@ package body Bindgen is
    --  For CodePeer, introduce a wrapper subprogram which calls the
    --  user-defined main subprogram.
 
+   --  Names for local C-String variables
+
+   Adainit_String_Obj_Name  : constant String := "Adainit_Name_C_String";
+   Adafinal_String_Obj_Name : constant String := "Adafinal_Name_C_String";
+
    --  Names and link_names for CUDA device adainit/adafinal procs.
 
    Device_Subp_Name_Prefix : constant String := "imported_device_";
@@ -131,9 +136,6 @@ package body Bindgen is
    function Device_Ada_Init_Subp_Name return String is
      (Device_Subp_Name_Prefix & Ada_Init_Name.all);
 
-   --  Text for aspect specifications (if any) given as part of the
-   --  Adainit and Adafinal spec declarations.
-
    ----------------------------------
    -- Interface_State Pragma Table --
    ----------------------------------
@@ -1366,6 +1368,13 @@ package body Bindgen is
       WBI ("   pragma Import (C, " & Device_Ada_Final_Subp_Name &
              ", Link_Name => """ & Device_Ada_Final_Link_Name & """);");
 
+      --  C-string declarations for adainit and adafinal
+      WBI ("   " & Adainit_String_Obj_Name
+            & " : Interfaces.C.Strings.Chars_Ptr;");
+      WBI ("   " & Adafinal_String_Obj_Name
+            & " : Interfaces.C.Strings.Chars_Ptr;");
+      WBI ("");
+
       WBI ("");
    end Gen_CUDA_Defs;
 
@@ -1449,11 +1458,11 @@ package body Bindgen is
       --  Register device-side Adainit and Adafinal
       Gen_CUDA_Register_Function_Call
         (Kernel_Name   => Device_Ada_Init_Link_Name,
-         Kernel_String => "Adainit_Name_String",
+         Kernel_String => Adainit_String_Obj_Name,
          Kernel_Proc   => Device_Ada_Init_Subp_Name);
       Gen_CUDA_Register_Function_Call
         (Kernel_Name   => Device_Ada_Final_Link_Name,
-         Kernel_String => "Adafinal_Name_String",
+         Kernel_String => Adafinal_String_Obj_Name,
          Kernel_Proc   => Device_Ada_Final_Subp_Name);
 
       WBI ("      CUDA_Register_Fat_Binary_End (Fat_Binary_Handle);");
-- 
2.34.1


                 reply	other threads:[~2022-11-04 13:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104135551.85648-1-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=baird@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).