public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Generate missing object decls for adainit/adafinal registration calls
@ 2022-11-04 13:55 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2022-11-04 13:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Steve Baird

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-04 13:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 13:55 [COMMITTED] ada: Generate missing object decls for adainit/adafinal registration calls Marc Poulhiès

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).