[libc-commits] [PATCH] D99686: [libc] Introduces asctime, asctime_r to LLVM libc, based on C99/C2X/Single Unix Sp.

Raman Tenneti via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Mar 31 14:07:46 PDT 2021


rtenneti created this revision.
rtenneti added reviewers: sivachandra, jeffbailey.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added a project: libc-project.
rtenneti requested review of this revision.

asctime and asctime_r share the same common code. They call asctime_internal
a static inline function.

asctime uses snprintf to return the string representation in a buffer.
It uses the following format (26 characters is the buffer size) as per
7.27.3.1 section in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2478.pdf.
The buf parameter for asctime_r shall point to a buffer of at least 26 bytes.

snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",...)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99686

Files:
  libc/config/linux/api.td
  libc/config/linux/x86_64/entrypoints.txt
  libc/spec/stdc.td
  libc/src/time/CMakeLists.txt
  libc/src/time/asctime.cpp
  libc/src/time/asctime.h
  libc/src/time/asctime_r.cpp
  libc/src/time/asctime_r.h
  libc/src/time/time_utils.h
  libc/test/src/time/CMakeLists.txt
  libc/test/src/time/TmHelper.h
  libc/test/src/time/asctime_r_test.cpp
  libc/test/src/time/asctime_test.cpp
  libc/test/src/time/mktime_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99686.334530.patch
Type: text/x-patch
Size: 23030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210331/9ad8a88c/attachment-0001.bin>


More information about the libc-commits mailing list