Skip to content

Commit fd75fd1

Browse files
committed
Make std::pair trivial
1 parent 5d80e8d commit fd75fd1

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ include libc/testlib/BUILD.mk
299299
include tool/viz/lib/BUILD.mk
300300
include tool/args/BUILD.mk
301301
include test/posix/BUILD.mk
302+
include test/libcxx/BUILD.mk
302303
include test/tool/args/BUILD.mk
303304
include third_party/linenoise/BUILD.mk
304305
include third_party/maxmind/BUILD.mk

test/BUILD.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
o/$(MODE)/test: o/$(MODE)/test/dsp \
66
o/$(MODE)/test/libc \
77
o/$(MODE)/test/net \
8+
o/$(MODE)/test/libcxx \
89
o/$(MODE)/test/posix \
910
o/$(MODE)/test/tool

test/libcxx/BUILD.mk

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
2+
#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘
3+
4+
PKGS += TEST_LIBCXX
5+
6+
TEST_LIBCXX_FILES := $(wildcard test/libcxx/*)
7+
TEST_LIBCXX_SRCS = $(filter %.cc,$(TEST_LIBCXX_FILES))
8+
TEST_LIBCXX_OBJS = $(TEST_LIBCXX_SRCS:%.cc=o/$(MODE)/%.o)
9+
TEST_LIBCXX_COMS = $(TEST_LIBCXX_OBJS:%.o=%.com)
10+
TEST_LIBCXX_BINS = $(TEST_LIBCXX_COMS) $(TEST_LIBCXX_COMS:%=%.dbg)
11+
TEST_LIBCXX_CHECKS = $(TEST_LIBCXX_COMS:%=%.runs)
12+
TEST_LIBCXX_TESTS = $(TEST_LIBCXX_COMS:%=%.ok)
13+
14+
TEST_LIBCXX_DIRECTDEPS = \
15+
LIBC_INTRIN \
16+
LIBC_NEXGEN32E \
17+
LIBC_RUNTIME \
18+
THIRD_PARTY_LIBCXX
19+
20+
TEST_LIBCXX_DEPS := \
21+
$(call uniq,$(foreach x,$(TEST_LIBCXX_DIRECTDEPS),$($(x))))
22+
23+
o/$(MODE)/test/libcxx/libcxx.pkg: \
24+
$(TEST_LIBCXX_OBJS) \
25+
$(foreach x,$(TEST_LIBCXX_DIRECTDEPS),$($(x)_A).pkg)
26+
27+
o/$(MODE)/test/libcxx/%.com.dbg: \
28+
$(TEST_LIBCXX_DEPS) \
29+
o/$(MODE)/test/libcxx/%.o \
30+
o/$(MODE)/test/libcxx/libcxx.pkg \
31+
$(CRT) \
32+
$(APE_NO_MODIFY_SELF)
33+
@$(APELINK)
34+
35+
$(TEST_LIBCXX_OBJS): private CCFLAGS += -fexceptions -frtti
36+
37+
.PHONY: o/$(MODE)/test/libcxx
38+
o/$(MODE)/test/libcxx: \
39+
$(TEST_LIBCXX_BINS) \
40+
$(TEST_LIBCXX_CHECKS)

test/libcxx/trivial_test.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*-*-mode:c++;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8-*-│
2+
│ vi: set et ft=c++ ts=2 sts=2 sw=2 fenc=utf-8 :vi │
3+
╞══════════════════════════════════════════════════════════════════════════════╡
4+
│ Copyright 2024 Justine Alexandra Roberts Tunney │
5+
│ │
6+
│ Permission to use, copy, modify, and/or distribute this software for │
7+
│ any purpose with or without fee is hereby granted, provided that the │
8+
│ above copyright notice and this permission notice appear in all copies. │
9+
│ │
10+
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
11+
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
12+
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
13+
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
14+
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
15+
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
16+
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
17+
│ PERFORMANCE OF THIS SOFTWARE. │
18+
╚─────────────────────────────────────────────────────────────────────────────*/
19+
#include <type_traits>
20+
#include <utility>
21+
22+
static_assert(std::is_trivially_copyable<int>::value);
23+
static_assert(std::is_trivially_copyable<const int>::value);
24+
static_assert(std::is_trivially_copyable<std::pair<int *, const int>>::value);
25+
static_assert(
26+
std::is_trivially_copyable<std::pair<const int, const int>>::value);
27+
28+
int main(int argc, char *argv[]) {
29+
}

third_party/libcxx/__config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
1616
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
1717
#define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
18+
#define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1819
#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
1920
#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
20-
#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
2121

2222
#if defined(_MSC_VER) && !defined(__clang__)
2323
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -1428,7 +1428,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
14281428
//
14291429
// Not all platforms support this, but it helps avoid fd-leaks on platforms that
14301430
// do.
1431-
#if defined(__BIONIC__)
1431+
#if defined(__BIONIC__) || defined(__COSMOPOLITAN__)
14321432
# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
14331433
#else
14341434
# define _LIBCPP_FOPEN_CLOEXEC_MODE

third_party/libcxxabi/cxa_personality.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ __cxa_call_unexpected(void* arg)
11961196
}
11971197
else
11981198
{
1199+
ttypeIndex = 0; // TODO(jart): why?
11991200
t_handler = std::get_terminate();
12001201
u_handler = std::get_unexpected();
12011202
}

0 commit comments

Comments
 (0)