[all-commits] [llvm/llvm-project] 6f0f84: Initial commit of mktime.

rtenneti-google via All-commits all-commits at lists.llvm.org
Mon Nov 30 21:12:22 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6f0f844e9af98dc935f80d8149f6e4fcebddf8f1
      https://github.com/llvm/llvm-project/commit/6f0f844e9af98dc935f80d8149f6e4fcebddf8f1
  Author: Raman Tenneti <rtenneti at google.com>
  Date:   2020-11-30 (Mon, 30 Nov 2020)

  Changed paths:
    M libc/config/linux/api.td
    M libc/config/linux/x86_64/entrypoints.txt
    M libc/config/linux/x86_64/headers.txt
    M libc/include/CMakeLists.txt
    A libc/include/time.h.def
    M libc/spec/spec.td
    M libc/spec/stdc.td
    M libc/src/CMakeLists.txt
    A libc/src/time/CMakeLists.txt
    A libc/src/time/mktime.cpp
    A libc/src/time/mktime.h
    M libc/test/src/CMakeLists.txt
    A libc/test/src/time/CMakeLists.txt
    A libc/test/src/time/mktime_test.cpp

  Log Message:
  -----------
  Initial commit of mktime.

This introduces mktime to LLVM libc, based on C99/C2X/Single Unix Spec.

Co-authored-by: Jeff Bailey <jeffbailey at google.com>

This change doesn't handle TIMEZONE,  tm_isdst and leap seconds.  It returns -1 for invalid dates. I have verified the return results for all the possible dates with glibc's mktime.

TODO:
+ Handle leap seconds.
+ Handle out of range time and date values that don't overflow or underflow.
+ Implement the following suggestion Siva - As we start accumulating the seconds, we should be able to check if the next amount of seconds to be added can lead to an overflow. If it does, return the overflow value.  If not keep accumulating. The benefit is that, we don't have to validate every input, and also do not need the special cases for sizeof(time_t) == 4.
+ Handle timezone and update of tm_isdst

Reviewed By: sivachandra

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




More information about the All-commits mailing list