[all-commits] [llvm/llvm-project] 3489ea: [libcxx][locale] Refactor strtonum functions using...

Himadhith via All-commits all-commits at lists.llvm.org
Thu Sep 24 21:21:37 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3489ea3b567c719f497bfcf83348e27cfd79cdb7
      https://github.com/llvm/llvm-project/commit/3489ea3b567c719f497bfcf83348e27cfd79cdb7
  Author: Himadhith <hima130602 at gmail.com>
  Date:   2026-09-25 (Fri, 25 Sep 2026)

  Changed paths:
    M libcxx/include/__locale_dir/locale_base_api.h
    M libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
    M libcxx/include/__locale_dir/num.h
    M libcxx/include/__locale_dir/support/aix.h
    M libcxx/include/__locale_dir/support/bsd_like.h
    M libcxx/include/__locale_dir/support/fuchsia.h
    M libcxx/include/__locale_dir/support/linux.h
    M libcxx/include/__locale_dir/support/newlib.h
    M libcxx/include/__locale_dir/support/no_locale/strtonum.h
    M libcxx/include/__locale_dir/support/openbsd.h
    M libcxx/include/__locale_dir/support/windows.h
    M libcxx/src/support/win32/locale_win32.cpp

  Log Message:
  -----------
  [libcxx][locale] Refactor strtonum functions using __str_to_float_c_locale<FloatT> (#222081)

Replace the 3 separate functions `__strtof`, `__strtod` and `__strtold`
with a single template `__str_to_float_c_locale<FloatT>` across
locale_base_api and all platform support headers. Since
`__str_to_float_c_locale<FloatT>` now does not need `__get_c_locale`
argument we can directly call it instead of `__do_strtod`.

This removes `__setAndRestore` from `aix.h` entirely as `__locale_guard`
is now used directly in the template specialisations to switch locales.
`num.h` is updated to call `__locale::__str_to_float_c_locale<T>`
uniformly across the 3 separate `__do_strtod` specialisation calls.

Additionally,
- linux.h, bsd_like.h, newlib.h delegate to the platform's native
`strtof_l`/`strtod_l`/`strtold_l`.
- openbsd.h, no_locale/strtonum.h call bare `strtof`, `strtod` and
`strtold` (no locale needed).
- windows.h, locale_win32.cpp's MSVCRT path inlines the 3 functions and
the non-MSVCRT path exports explicit specialisations from the library.
- Changes `__locale_guard` to take `__locale_t` by value now by removing
`&`.
- Forward declared the `__get_c_locale()` function as it's being used
well before the include.

---------

Co-authored-by: himadhith <himadhith.v at ibm.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list