[analyzer] another function name that returns a pointer to errno

Message ID orplbvvu83.fsf@lxoliva.fsfla.org
State Committed
Commit 770cbd759d2dda74231349502d7283b04c0fd0df
Headers
Series [analyzer] another function name that returns a pointer to errno |

Commit Message

Alexandre Oliva Sept. 13, 2025, 4:42 a.m. UTC
  Add __get_errno_ptr() as yet another synonym for __errno_location.

This came up while updating a port for a target that uses this function
name in the implementation of errno.  Tested on that target, and on
x86_64-linux-gnu and aarch64-linux-gnu natives.  Ok to install?

for  gcc/analyzer/ChangeLog

	* kf.cc (register_known_functions): Add __get_errno_ptr.
---
 gcc/analyzer/kf.cc |    1 +
 1 file changed, 1 insertion(+)
  

Comments

David Malcolm Sept. 15, 2025, 2:43 p.m. UTC | #1
On Sat, 2025-09-13 at 01:42 -0300, Alexandre Oliva wrote:
> 
> Add __get_errno_ptr() as yet another synonym for __errno_location.
> 
> This came up while updating a port for a target that uses this
> function
> name in the implementation of errno.  Tested on that target, and on
> x86_64-linux-gnu and aarch64-linux-gnu natives.  Ok to install?
> 

LGTM; thanks!

Dave

> for  gcc/analyzer/ChangeLog
> 
> 	* kf.cc (register_known_functions): Add __get_errno_ptr.
> ---
>  gcc/analyzer/kf.cc |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc
> index 2a7c357031533..5c54b55644869 100644
> --- a/gcc/analyzer/kf.cc
> +++ b/gcc/analyzer/kf.cc
> @@ -2373,6 +2373,7 @@ register_known_functions
> (known_function_manager &kfm,
>      kfm.add ("___errno", std::make_unique<kf_errno_location> ());
>      kfm.add ("__error", std::make_unique<kf_errno_location> ());
>      kfm.add ("__errno", std::make_unique<kf_errno_location> ());
> +    kfm.add ("__get_errno_ptr", std::make_unique<kf_errno_location>
> ());
>    }
>  
>    /* Language-specific support functions.  */
>
  

Patch

diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc
index 2a7c357031533..5c54b55644869 100644
--- a/gcc/analyzer/kf.cc
+++ b/gcc/analyzer/kf.cc
@@ -2373,6 +2373,7 @@  register_known_functions (known_function_manager &kfm,
     kfm.add ("___errno", std::make_unique<kf_errno_location> ());
     kfm.add ("__error", std::make_unique<kf_errno_location> ());
     kfm.add ("__errno", std::make_unique<kf_errno_location> ());
+    kfm.add ("__get_errno_ptr", std::make_unique<kf_errno_location> ());
   }
 
   /* Language-specific support functions.  */