Skip to content

Commit 5006fad

Browse files
committed
[libc] Add ctime_s
Resolves #110548 Definition: ```c++ int ctime_s(char *buffer, rsize_t buffer_size, const time_t *t_ptr); ```
1 parent 659cd2a commit 5006fad

File tree

16 files changed

+254
-0
lines changed

16 files changed

+254
-0
lines changed

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ set(TARGET_LIBC_ENTRYPOINTS
206206
libc.src.time.asctime_r
207207
libc.src.time.ctime
208208
libc.src.time.ctime_r
209+
libc.src.time.ctime_s
209210
libc.src.time.difftime
210211
libc.src.time.gmtime
211212
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
@@ -202,6 +202,7 @@ set(TARGET_LIBC_ENTRYPOINTS
202202
libc.src.time.asctime_r
203203
libc.src.time.ctime
204204
libc.src.time.ctime_r
205+
libc.src.time.ctime_s
205206
libc.src.time.difftime
206207
libc.src.time.gmtime
207208
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
@@ -1010,6 +1010,7 @@ if(LLVM_LIBC_FULL_BUILD)
10101010
libc.src.time.asctime_r
10111011
libc.src.time.ctime
10121012
libc.src.time.ctime_r
1013+
libc.src.time.ctime_s
10131014
libc.src.time.clock
10141015
libc.src.time.clock_gettime
10151016
libc.src.time.difftime

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ if(LLVM_LIBC_FULL_BUILD)
941941
libc.src.time.asctime_r
942942
libc.src.time.ctime
943943
libc.src.time.ctime_r
944+
libc.src.time.ctime_s
944945
libc.src.time.clock
945946
libc.src.time.clock_gettime
946947
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
@@ -1095,6 +1095,7 @@ if(LLVM_LIBC_FULL_BUILD)
10951095
libc.src.time.asctime_r
10961096
libc.src.time.ctime
10971097
libc.src.time.ctime_r
1098+
libc.src.time.ctime_s
10981099
libc.src.time.clock
10991100
libc.src.time.clock_gettime
11001101
libc.src.time.difftime

libc/docs/headers/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/errno_t.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for errno_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_ERRNO_T_H
9+
#define LLVM_LIBC_HDR_TYPES_ERRNO_T_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/errno_t.h"
14+
15+
#else
16+
17+
#define __STDC_WANT_LIB_EXT1__ 1
18+
#include <errno.h>
19+
20+
#endif // LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_ERRNO_T_H

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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Definition of errno_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_ERRNO_T_H
10+
#define LLVM_LIBC_TYPES_ERRNO_T_H
11+
12+
typedef int errno_t;
13+
14+
#endif // LLVM_LIBC_TYPES_ERRNO_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

0 commit comments

Comments
 (0)