Skip to content

Commit abaab76

Browse files
address CRs
1 parent 6496e37 commit abaab76

File tree

8 files changed

+35
-17
lines changed

8 files changed

+35
-17
lines changed

libc/hdr/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,9 @@ add_proxy_header_library(
223223
libc.include.wchar
224224
)
225225

226+
# offsetof is a macro inside compiler resource header stddef.h
227+
# defining it directly as a header library
228+
add_header_library(offsetof-macros HDRS offsetof_macros.h)
229+
226230
add_subdirectory(types)
227231
add_subdirectory(func)

libc/hdr/offsetof_macros.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Definition of macros for offsetof ---------------------------------===//
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_OFFSETOF_MACROS_H
10+
#define LLVM_LIBC_HDR_OFFSETOF_MACROS_H
11+
12+
#undef offsetof
13+
14+
// Simplify the inclusion if builtin function is available.
15+
#if __has_builtin(__builtin_offsetof)
16+
#define offsetof(t, d) __builtin_offsetof(t, d)
17+
#else
18+
#define __need_offsetof
19+
#include <stddef.h> // compiler resource header
20+
#endif
21+
22+
#endif // LLVM_LIBC_HDR_OFFSETOF_MACROS_H

libc/include/llvm-libc-types/jmp_buf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ typedef struct {
5252
#else
5353
#error "__jmp_buf not available for your target architecture."
5454
#endif
55-
// TODO: implement sigjmp_buf related functions
55+
// TODO: implement sigjmp_buf related functions for other architectures
56+
// Issue: https://github.com/llvm/llvm-project/issues/136358
5657
#if defined(__i386__) || defined(__x86_64__)
5758
// return address
5859
void *sig_retaddr;

libc/src/setjmp/linux/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ add_object_library(
44
../sigsetjmp_epilogue.h
55
SRCS
66
sigsetjmp_epilogue.cpp
7-
COMPILE_OPTIONS
8-
${libc_opt_high_flag}
9-
-fomit-frame-pointer
107
DEPENDS
118
libc.src.__support.common
129
libc.src.__support.OSUtil.osutil

libc/src/setjmp/siglongjmp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ namespace LIBC_NAMESPACE_DECL {
1414

1515
// siglongjmp is the same as longjmp. The additional recovery work is done in
1616
// the epilogue of the sigsetjmp function.
17+
// TODO: move this inside the TU of longjmp and making it an alias after
18+
// sigsetjmp is implemented for all architectures.
1719
LLVM_LIBC_FUNCTION(void, siglongjmp, (jmp_buf buf, int val)) {
18-
return longjmp(buf, val);
20+
return LIBC_NAMESPACE::longjmp(buf, val);
1921
}
2022

2123
} // namespace LIBC_NAMESPACE_DECL

libc/src/setjmp/x86_64/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ add_entrypoint_object(
44
setjmp.cpp
55
HDRS
66
../setjmp_impl.h
7-
COMPILE_OPTIONS
8-
${libc_opt_high_flag}
9-
-fomit-frame-pointer
107
DEPENDS
8+
libc.hdr.offsetof_macros
119
libc.hdr.types.jmp_buf
1210
)
1311

@@ -17,11 +15,10 @@ add_entrypoint_object(
1715
sigsetjmp.cpp
1816
HDRS
1917
../sigsetjmp.h
20-
COMPILE_OPTIONS
21-
${libc_opt_high_flag}
2218
DEPENDS
2319
libc.hdr.types.jmp_buf
2420
libc.hdr.types.sigset_t
21+
libc.hdr.offsetof_macros
2522
libc.src.setjmp.sigsetjmp_epilogue
2623
libc.src.setjmp.setjmp
2724
)
@@ -32,9 +29,6 @@ add_entrypoint_object(
3229
longjmp.cpp
3330
HDRS
3431
../longjmp.h
35-
COMPILE_OPTIONS
36-
${libc_opt_high_flag}
37-
-fomit-frame-pointer
3832
DEPENDS
3933
libc.hdr.types.jmp_buf
4034
)

libc/src/setjmp/x86_64/setjmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "include/llvm-libc-macros/offsetof-macro.h"
9+
#include "hdr/offsetof_macros.h"
1010
#include "src/__support/common.h"
1111
#include "src/__support/macros/config.h"
1212
#include "src/setjmp/setjmp_impl.h"

libc/src/setjmp/x86_64/sigsetjmp.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#include "src/__support/macros/config.h"
1212
#include "src/setjmp/setjmp_impl.h"
1313
#include "src/setjmp/sigsetjmp_epilogue.h"
14-
15-
#define __need_offsetof
16-
#include <stddef.h> // compiler resource header
14+
#include "hdr/offsetof_macros.h"
1715

1816
#if !defined(LIBC_TARGET_ARCH_IS_X86)
1917
#error "Invalid file include"

0 commit comments

Comments
 (0)