Skip to content

Commit 1cede39

Browse files
committed
[libc] Add ctime_s
Resolves #110548 Definition: ```c++ int ctime_s(char *buffer, size_t buffer_size, const time_t *t_ptr); ```
1 parent 3ae6b57 commit 1cede39

File tree

15 files changed

+232
-0
lines changed

15 files changed

+232
-0
lines changed

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ set(TARGET_LIBC_ENTRYPOINTS
205205
libc.src.time.asctime_r
206206
libc.src.time.ctime
207207
libc.src.time.ctime_r
208+
libc.src.time.ctime_s
208209
libc.src.time.difftime
209210
libc.src.time.gmtime
210211
libc.src.time.gmtime_r

libc/config/baremetal/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ set(TARGET_LIBC_ENTRYPOINTS
201201
libc.src.time.asctime_r
202202
libc.src.time.ctime
203203
libc.src.time.ctime_r
204+
libc.src.time.ctime_s
204205
libc.src.time.difftime
205206
libc.src.time.gmtime
206207
libc.src.time.gmtime_r

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ if(LLVM_LIBC_FULL_BUILD)
969969
libc.src.time.asctime_r
970970
libc.src.time.ctime
971971
libc.src.time.ctime_r
972+
libc.src.time.ctime_s
972973
libc.src.time.clock
973974
libc.src.time.clock_gettime
974975
libc.src.time.difftime

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ if(LLVM_LIBC_FULL_BUILD)
901901
libc.src.time.asctime_r
902902
libc.src.time.ctime
903903
libc.src.time.ctime_r
904+
libc.src.time.ctime_s
904905
libc.src.time.clock
905906
libc.src.time.clock_gettime
906907
libc.src.time.difftime

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ if(LLVM_LIBC_FULL_BUILD)
10261026
libc.src.time.asctime_r
10271027
libc.src.time.ctime
10281028
libc.src.time.ctime_r
1029+
libc.src.time.ctime_s
10291030
libc.src.time.clock
10301031
libc.src.time.clock_gettime
10311032
libc.src.time.difftime

libc/docs/date_and_time.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Implementation Status
5959
+---------------------+---------+---------+---------+-----------------+---------+---------+---------+---------+---------+---------+---------+---------+
6060
| ctime_r | |check| | |check| | | |check| | | | | | | | | |
6161
+---------------------+---------+---------+---------+-----------------+---------+---------+---------+---------+---------+---------+---------+---------+
62+
| ctime_s | |check| | |check| | | |check| | | | | | | | | |
63+
+---------------------+---------+---------+---------+-----------------+---------+---------+---------+---------+---------+---------+---------+---------+
6264
| clock | |check| | |check| | | |check| | | | | | | | | |
6365
+---------------------+---------+---------+---------+-----------------+---------+---------+---------+---------+---------+---------+---------+---------+
6466
| clock_getcpuclockid | | | | | | | | | | | | |

libc/hdr/types/rsize_t.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Proxy for rsize_t -------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef LLVM_LIBC_HDR_TYPES_RSIZE_T_H
9+
#define LLVM_LIBC_HDR_TYPES_RSIZE_T_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/rsize_t.h"
14+
15+
#else
16+
17+
#define __need_rsize_t
18+
#include <stddef.h>
19+
#undef __need_rsize_t
20+
21+
#endif // LIBC_FULL_BUILD
22+
23+
#endif // LLVM_LIBC_HDR_TYPES_RSIZE_T_H
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//===-- Definition of rsize_t type ----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_TYPES_RSIZE_T_H
10+
#define LLVM_LIBC_TYPES_RSIZE_T_H
11+
12+
#include "size_t.h"
13+
14+
typedef size_t rsize_t;
15+
16+
#endif // LLVM_LIBC_TYPES_RSIZE_T_H

libc/newhdrgen/yaml/time.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ functions:
3737
arguments:
3838
- type: const time_t *
3939
- type: char *
40+
- name: ctime_s
41+
standard:
42+
- stdc
43+
return_type: int
44+
arguments:
45+
- type: char *
46+
- type: size_t
47+
- type: const time_t *
4048
- name: clock
4149
standard:
4250
- stdc

libc/spec/stdc.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,15 @@ def StdC : StandardSpec<"stdc"> {
16301630
ArgSpec<CharPtr>,
16311631
]
16321632
>,
1633+
FunctionSpec<
1634+
"ctime_s",
1635+
RetValSpec<IntType>,
1636+
[
1637+
ArgSpec<CharPtr>,
1638+
ArgSpec<SizeTType>,
1639+
ArgSpec<ConstTimeTTypePtr>,
1640+
]
1641+
>,
16331642
FunctionSpec<
16341643
"clock",
16351644
RetValSpec<ClockT>,

0 commit comments

Comments
 (0)