Skip to content

[libc][docs] start documenting c23 support #81933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

nickdesaulniers
Copy link
Member

I've been diffing the c17 vs c23 latest publicly available drafts and think I
have most of the library related differences. I haven't yet annotated what we
actually support or not.

Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf (C17)
Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf (C23)

I've been diffing the c17 vs c23 latest publicly available drafts and think I
have most of the library related differences. I haven't yet annotated what we
actually support or not.

Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf (C17)
Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf (C23)
@llvmbot llvmbot added the libc label Feb 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2024

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

Changes

I've been diffing the c17 vs c23 latest publicly available drafts and think I
have most of the library related differences. I haven't yet annotated what we
actually support or not.

Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf (C17)
Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf (C23)


Full diff: https://github.com/llvm/llvm-project/pull/81933.diff

2 Files Affected:

  • (added) libc/docs/c23.rst (+114)
  • (modified) libc/docs/index.rst (+1)
diff --git a/libc/docs/c23.rst b/libc/docs/c23.rst
new file mode 100644
index 00000000000000..b2c02c8505aaa1
--- /dev/null
+++ b/libc/docs/c23.rst
@@ -0,0 +1,114 @@
+.. _c23_support:
+
+===========
+C23 Support
+===========
+
+.. contents:: Table of Contents
+  :depth: 4
+  :local:
+
+---------------------
+Implementation Status
+---------------------
+
+(It's helpful to review 'Annex B (Informative) Library Summary' for these.)
+
+New headers:
+
+* stdbit.h
+* stdckdint.h
+* stdnoreturn.h
+
+Additions:
+
+* uchar.h
+
+  * mbrtoc8
+  * c8rtomb
+
+* string.h
+
+  * memset_explicit
+  * memccpy
+  * strdup
+  * strndup
+
+* time.h
+
+  * gmtime_r
+  * localtime_r
+  * timegm
+  * timespec_getres
+  * strftime conversion specifiers
+
+    * 0b
+    * 0B
+* math.h
+
+  * acospi*
+  * asinpi*
+  * atanpi*
+  * atan2pi*
+  * cospi*
+  * sinpi*
+  * tanpi*
+  * exp10*
+  * exp10m1*
+  * exp2m1*
+  * log10p1*
+  * logp1
+  * log2p1*
+  * rsqrt*
+  * __STDC_IEC_60559_DFP__ functions (_Decimal32, _Decimal64, _Decimal128)
+  * compoundn*
+  * totalorder*
+  * totalordermag*
+  * getpayload*
+  * setpayload*
+  * iscannonical
+  * issignaling
+  * issubnormal
+  * iszero
+  * llogb*
+  * pown*
+  * powr*
+  * rootn*
+  * roundeven*
+  * fromfp*
+  * ufromfp*
+  * fromfpx*
+  * nextup*
+  * nextdown*
+  * canonicalize*
+  * fmaximum*
+  * fminimum*
+  * fmaximum_mag*
+  * fminimum_mag*
+  * fmaximum_mag_num*
+  * fminimum_mag_num*
+  * fadd*
+  * fsub*
+  * fmul*
+  * fdiv*
+  * ffma*
+  * dfmal
+  * fsqrt*
+  * dsqrtl
+* fenv.h
+
+  * fesetexcept
+  * fetestexceptflag
+  * fegetmode
+  * fesetmode
+* stddef.h
+
+  * unreachable
+* stdlib.h
+
+  * free_sized
+  * free_aligned_sized
+  * memalignment
+* tgmath.h
+
+  * <TODO>
diff --git a/libc/docs/index.rst b/libc/docs/index.rst
index 7655cb9ccd7116..a50eb080c9ee49 100644
--- a/libc/docs/index.rst
+++ b/libc/docs/index.rst
@@ -67,6 +67,7 @@ stages there is no ABI stability in any form.
    stdio
    stdbit
    libc_search
+   c23
 
 .. toctree::
    :hidden:

@nickdesaulniers
Copy link
Member Author

cc @ThePhD

Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for collecting this and having a single place to keep track of our C23 progress is much better!

@ThePhD
Copy link
Contributor

ThePhD commented Feb 15, 2024

cc @ThePhD

You also need char8_t as a typedef in there.

@SchrodingerZhu
Copy link
Contributor

Could you also mention inttypes.h?

@nickdesaulniers
Copy link
Member Author

Could you also mention inttypes.h?

FWICT, inttypes.h existed in C17 and is no different in C23 (at least from comparing annex B). Did I miss something perhaps?

@nickdesaulniers
Copy link
Member Author

cc @ThePhD

You also need char8_t as a typedef in there.

done in dad2c0d. Thanks for the review! Happy to modify this more as needed.

@nickdesaulniers nickdesaulniers merged commit 58946ee into llvm:main Feb 16, 2024
@nickdesaulniers nickdesaulniers deleted the docs_c23 branch February 16, 2024 16:56
@SchrodingerZhu
Copy link
Contributor

see #81896

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Feb 16, 2024

see #81896
Glibc has added PRIbN and PRIBN:

Interesting. The last publicly available c23 draft doesn't mention those, at least in B.7 Format conversion of integer types <inttypes.h>. So I guess they're an extension? Maybe the final draft fixed this, or perhaps a defect report was written against the standard? Maybe @ThePhD knows?

Edit: 7.8.1 Macros for format specifiers mentions them.

@ThePhD
Copy link
Contributor

ThePhD commented Feb 16, 2024

Yes, this was an oversight in the c23 working draft everyone is using. A better version is here: https://drive.google.com/file/d/12kNvH0aYJhe3ZPmBKH_Nk5maTfxH2lJv/view

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Feb 16, 2024

A better version is here: https://drive.google.com/file/d/12kNvH0aYJhe3ZPmBKH_Nk5maTfxH2lJv/view

Ah, N3220! It's like finding a shiny pokemon! (and is an upgrade from referring to n3096)! I think this was the password protected one? Thanks!

EDIT: https://open-std.org/JTC1/SC22/WG14/www/docs/n3150.htm mentions n3149 is password protected.

@nickdesaulniers
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants