Skip to content

Commit 0466b6a

Browse files
committed
[libc] Add fopen_s.
1 parent 5678aef commit 0466b6a

26 files changed

+469
-13
lines changed

libc/hdr/types/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,24 @@ add_proxy_header_library(
162162
libc.include.fcntl
163163
)
164164

165+
add_proxy_header_library(
166+
errno_t
167+
HDRS
168+
errno_t.h
169+
FULL_BUILD_DEPENDS
170+
libc.include.llvm-libc-types.errno_t
171+
libc.include.errno
172+
)
173+
174+
add_proxy_header_library(
175+
constraint_handler_t
176+
HDRS
177+
constraint_handler_t.h
178+
FULL_BUILD_DEPENDS
179+
libc.include.llvm-libc-types.constraint_handler_t
180+
libc.include.stdlib
181+
)
182+
165183
add_proxy_header_library(
166184
fenv_t
167185
HDRS
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Proxy for constraint_handler_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+
9+
#ifndef LLVM_LIBC_HDR_TYPES_CONSTRAINT_HANDLER_T_H
10+
#define LLVM_LIBC_HDR_TYPES_CONSTRAINT_HANDLER_T_H
11+
12+
#include "include/llvm-libc-types/constraint_handler_t.h"
13+
14+
#endif // LLVM_LIBC_HDR_TYPES_CONSTRAINT_HANDLER_T_H

libc/hdr/types/errno_t.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
9+
#ifndef LLVM_LIBC_HDR_TYPES_ERRNO_T_H
10+
#define LLVM_LIBC_HDR_TYPES_ERRNO_T_H
11+
12+
#include "include/llvm-libc-types/errno_t.h"
13+
14+
#endif // LLVM_LIBC_HDR_TYPES_ERRNO_T_H

libc/include/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ add_header_macro(
290290
DEPENDS
291291
.llvm-libc-macros.generic_error_number_macros
292292
.llvm-libc-macros.error_number_macros
293+
.llvm-libc-types.errno_t
293294
)
294295

295296
add_header_macro(
@@ -339,6 +340,7 @@ add_header_macro(
339340
.llvm-libc-types.off_t
340341
.llvm-libc-types.size_t
341342
.llvm-libc-types.ssize_t
343+
.llvm-libc-types.errno_t
342344
.llvm_libc_common_h
343345
)
344346

@@ -358,6 +360,7 @@ add_header_macro(
358360
.llvm-libc-types.lldiv_t
359361
.llvm-libc-types.locale_t
360362
.llvm-libc-types.size_t
363+
.llvm-libc-types.constraint_handler_t
361364
.llvm_libc_common_h
362365
)
363366

libc/include/errno.h.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ __END_C_DECLS
3333

3434
#define errno (*__llvm_libc_errno())
3535

36+
#include "llvm-libc-types/errno_t.h"
37+
3638
#endif // LLVM_LIBC_ERRNO_H

libc/include/llvm-libc-types/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,7 @@ add_header(EFI_SYSTEM_TABLE
289289
.EFI_TABLE_HEADER
290290
.char16_t
291291
)
292+
293+
add_header(errno_t HDR errno_t.h)
294+
295+
add_header(constraint_handler_t HDR constraint_handler_t.h DEPENDS .errno_t)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Definition of type constraint_handler_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+
9+
#ifndef LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_CONSTRAINT_HANDLER_T_H
10+
#define LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_CONSTRAINT_HANDLER_T_H
11+
12+
#include "errno_t.h"
13+
14+
typedef void (*constraint_handler_t)(const char *__restrict msg,
15+
void *__restrict ptr, errno_t error);
16+
17+
#endif // LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_CONSTRAINT_HANDLER_T_H
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Definition of type 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+
9+
#ifndef LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
10+
#define LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
11+
12+
typedef int errno_t;
13+
14+
#endif // LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H

libc/include/stdio.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ macros:
1111
macro_value: stderr
1212
types:
1313
- type_name: size_t
14+
- type_name: errno_t
1415
- type_name: off_t
1516
- type_name: cookie_io_functions_t
1617
- type_name: FILE
@@ -125,6 +126,14 @@ functions:
125126
arguments:
126127
- type: const char *
127128
- type: const char *
129+
- name: fopen_s
130+
standards:
131+
- stdc
132+
return_type: errno_t
133+
arguments:
134+
- type: FILE *__restrict *__restrict
135+
- type: const char *__restrict
136+
- type: const char *__restrict
128137
- name: fopencookie
129138
standards:
130139
- GNUExtensions

libc/include/stdlib.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ types:
1717
- type_name: lldiv_t
1818
- type_name: locale_t
1919
- type_name: size_t
20+
- type_name: errno_t
21+
- type_name: constraint_handler_t
2022
enums: []
2123
objects: []
2224
functions:
@@ -180,6 +182,12 @@ functions:
180182
return_type: int
181183
arguments:
182184
- type: void
185+
- name: set_constraint_handler_s
186+
standards:
187+
- stdc
188+
return_type: constraint_handler_t
189+
arguments:
190+
- type: constraint_handler_t
183191
- name: srand
184192
standards:
185193
- stdc

0 commit comments

Comments
 (0)