Skip to content

Commit 90fc6a7

Browse files
committed
add function to linux x86 entrypoint
1 parent 11c8abf commit 90fc6a7

File tree

11 files changed

+43
-13
lines changed

11 files changed

+43
-13
lines changed

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ set(TARGET_LIBC_ENTRYPOINTS
198198
libc.src.stdlib.qsort
199199
libc.src.stdlib.qsort_r
200200
libc.src.stdlib.rand
201+
libc.src.stdlib.set_constraint_handler_s
201202
libc.src.stdlib.srand
202203
libc.src.stdlib.strfromd
203204
libc.src.stdlib.strfromf
@@ -1127,6 +1128,7 @@ if(LLVM_LIBC_FULL_BUILD)
11271128
libc.src.stdio.fileno
11281129
libc.src.stdio.flockfile
11291130
libc.src.stdio.fopen
1131+
libc.src.stdio.fopen_s
11301132
libc.src.stdio.fopencookie
11311133
libc.src.stdio.fputc
11321134
libc.src.stdio.fputs
@@ -1162,6 +1164,7 @@ if(LLVM_LIBC_FULL_BUILD)
11621164
libc.src.stdlib.exit
11631165
libc.src.stdlib.getenv
11641166
libc.src.stdlib.quick_exit
1167+
libc.src.stdlib.set_constraint_handler_s
11651168

11661169
# signal.h entrypoints
11671170
libc.src.signal.kill

libc/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ add_header_macro(
360360
.llvm-libc-types.lldiv_t
361361
.llvm-libc-types.locale_t
362362
.llvm-libc-types.size_t
363+
.llvm-libc-types.rsize_t
363364
.llvm-libc-types.constraint_handler_t
364365
.llvm_libc_common_h
365366
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_header(off64_t HDR off64_t.h)
22
add_header(size_t HDR size_t.h)
3+
add_header(rsize_t HDR rsize_t.h)
34
add_header(ssize_t HDR ssize_t.h)
45
add_header(__atfork_callback_t HDR __atfork_callback_t.h)
56
add_header(__search_compare_t HDR __search_compare_t.h)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Definition of rsize_t types ---------------------------------------===//
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+
typedef __SIZE_TYPE__ rsize_t;
13+
14+
#endif // LLVM_LIBC_TYPES_RSIZE_T_H

libc/include/stdlib.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ types:
1717
- type_name: lldiv_t
1818
- type_name: locale_t
1919
- type_name: size_t
20+
- type_name: rsize_t
2021
- type_name: errno_t
2122
- type_name: constraint_handler_t
2223
enums: []
@@ -188,6 +189,22 @@ functions:
188189
return_type: constraint_handler_t
189190
arguments:
190191
- type: constraint_handler_t
192+
- name: abort_handler_s
193+
standards:
194+
- stdc
195+
return_type: void
196+
arguments:
197+
- type: const char *__restrict
198+
- type: void *__restrict
199+
- type: errno_t
200+
- name: ignore_handler_s
201+
standards:
202+
- stdc
203+
return_type: void
204+
arguments:
205+
- type: const char *__restrict
206+
- type: void *__restrict
207+
- type: errno_t
191208
- name: srand
192209
standards:
193210
- stdc

libc/src/__support/annex_k/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ add_header_library(
3535
HDRS
3636
libc_constraint_handler.h
3737
DEPENDS
38-
libc.src.__support.annex_k.abort_handler_s
38+
.abort_handler_s
3939
libc.hdr.types.errno_t
4040
)

libc/src/__support/annex_k/abort_handler_s.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
namespace LIBC_NAMESPACE_DECL {
2222

2323
LIBC_INLINE static void abort_handler_s(const char *__restrict msg,
24-
void *__restrict ptr, errno_t error) {
24+
[[maybe_unused]] void *__restrict ptr,
25+
errno_t error) {
2526
libc_errno = error;
2627
fprintf(stderr, "abort_handler_s was called in response to a "
2728
"runtime-constraint violation.\n\n");

libc/src/__support/annex_k/helper_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_ANNEX_K_HELPER_MACROS_H
1010
#define LLVM_LIBC_SRC___SUPPORT_ANNEX_K_HELPER_MACROS_H
1111

12-
#include "libc_constraint_hander.h"
12+
#include "libc_constraint_handler.h"
1313

1414
#define _CONSTRAINT_VIOLATION(msg, error_code, ret_code) \
1515
{ \

libc/src/__support/annex_k/libc_constraint_hander.h renamed to libc/src/__support/annex_k/libc_constraint_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_ANNEX_K_LIBC_CONSTRAINT_HANDER_H
1010
#define LLVM_LIBC_SRC___SUPPORT_ANNEX_K_LIBC_CONSTRAINT_HANDER_H
1111

12+
#include "abort_handler_s.h"
1213
#include "hdr/types/constraint_handler_t.h"
13-
#include "src/__support/annex_k/abort_handler_s.h"
1414

1515
namespace LIBC_NAMESPACE_DECL {
1616

libc/src/stdio/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,6 @@ add_entrypoint_object(
204204
.${LIBC_TARGET_OS}.fdopen
205205
)
206206

207-
add_entrypoint_object(
208-
fopen_s
209-
HDRS
210-
fopen_s.h
211-
DEPENDS
212-
.generic.fopen_s
213-
)
214-
215207
# These entrypoints have multiple potential implementations.
216208
add_stdio_entrypoint_object(feof)
217209
add_stdio_entrypoint_object(feof_unlocked)
@@ -226,6 +218,7 @@ add_stdio_entrypoint_object(fflush)
226218
add_stdio_entrypoint_object(clearerr)
227219
add_stdio_entrypoint_object(clearerr_unlocked)
228220
add_stdio_entrypoint_object(fopen)
221+
add_stdio_entrypoint_object(fopen_s)
229222
add_stdio_entrypoint_object(fclose)
230223
add_stdio_entrypoint_object(fread_unlocked)
231224
add_stdio_entrypoint_object(fread)

0 commit comments

Comments
 (0)