[libc-commits] [libc] [libc] Correct 'memrchr' definition and re-enable on GPU (PR #67850)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Sep 29 13:35:54 PDT 2023


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/67850

Summary:
This was disabled on the GPU because it conflicted with the definition
in `glibc`. According to information online and in the `glibc`
implementation, the first argument should be a `const void *`. Fixing
this resolves the problem when exporting this to offloading languages.


>From 72340863a4e8d9568361bb3a98e8f1ea1c9166cc Mon Sep 17 00:00:00 2001
From: Joseph Huber <jhuber6 at vols.utk.edu>
Date: Fri, 29 Sep 2023 15:34:31 -0500
Subject: [PATCH] [libc] Correct 'memrchr' definition and re-enable on GPU

Summary:
This was disabled on the GPU because it conflicted with the definition
in `glibc`. According to information online and in the `glibc`
implementation, the first argument should be a `const void *`. Fixing
this resolves the problem when exporting this to offloading languages.
---
 libc/config/gpu/entrypoints.txt | 1 +
 libc/spec/gnu_ext.td            | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index ad68216a76b9429..839213f82a845eb 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -45,6 +45,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.string.strncmp
     libc.src.string.strncpy
     libc.src.string.strnlen
+    libc.src.string.memrchr
     libc.src.string.strspn
     libc.src.string.strtok
     libc.src.string.strtok_r
diff --git a/libc/spec/gnu_ext.td b/libc/spec/gnu_ext.td
index 362add7283d6e11..dfb12419d14005b 100644
--- a/libc/spec/gnu_ext.td
+++ b/libc/spec/gnu_ext.td
@@ -69,7 +69,7 @@ def GnuExtensions : StandardSpec<"GNUExtensions"> {
         FunctionSpec<
             "memrchr",
             RetValSpec<VoidPtr>,
-            [ArgSpec<VoidPtr>, ArgSpec<IntType>, ArgSpec<SizeTType>]
+            [ArgSpec<ConstVoidPtr>, ArgSpec<IntType>, ArgSpec<SizeTType>]
         >,
         FunctionSpec<
             "strerror_r",



More information about the libc-commits mailing list