[all-commits] [llvm/llvm-project] a72499: [libc] Introduce asctime, asctime_r to LLVM libc

rtenneti-google via All-commits all-commits at lists.llvm.org
Mon May 3 17:15:45 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a72499e47537c02a33d7c1c2e512d0b4a0ecbb89
      https://github.com/llvm/llvm-project/commit/a72499e47537c02a33d7c1c2e512d0b4a0ecbb89
  Author: Raman Tenneti <rtenneti at google.com>
  Date:   2021-05-03 (Mon, 03 May 2021)

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

  Log Message:
  -----------
  [libc] Introduce asctime, asctime_r to LLVM libc

[libc] Introduce asctime, asctime_r to LLVM libc

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",...)

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D99686




More information about the All-commits mailing list