Skip to content

Commit df7591e

Browse files
aleck099aleck099
and
aleck099
authored
Move inlined vfork syscall to all system_call()s (#1142)
attribute __gnu__::__always_inline__ is required Signed-off-by: aleck099 <[email protected]> Co-authored-by: aleck099 <[email protected]>
1 parent 39d62d7 commit df7591e

File tree

6 files changed

+171
-7
lines changed

6 files changed

+171
-7
lines changed

Diff for: include/fast_io_hosted/platforms/linux/aarch64.h

+40
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ namespace fast_io
55

66
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
77
requires(1 < sizeof(return_value_type))
8+
#if __has_cpp_attribute(__gnu__::__always_inline__)
9+
[[__gnu__::__always_inline__]]
10+
#else
11+
#error "system_call must be inlined"
12+
#endif
813
inline return_value_type system_call() noexcept
914
{
1015
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -15,6 +20,11 @@ inline return_value_type system_call() noexcept
1520

1621
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
1722
requires(1 < sizeof(return_value_type))
23+
#if __has_cpp_attribute(__gnu__::__always_inline__)
24+
[[__gnu__::__always_inline__]]
25+
#else
26+
#error "system_call must be inlined"
27+
#endif
1828
inline return_value_type system_call(auto p1) noexcept
1929
{
2030
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -24,6 +34,11 @@ inline return_value_type system_call(auto p1) noexcept
2434
}
2535

2636
template <::std::size_t syscall_number>
37+
#if __has_cpp_attribute(__gnu__::__always_inline__)
38+
[[__gnu__::__always_inline__]]
39+
#else
40+
#error "system_call must be inlined"
41+
#endif
2742
inline void system_call_no_return(auto p1) noexcept
2843
{
2944
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -34,6 +49,11 @@ inline void system_call_no_return(auto p1) noexcept
3449

3550
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
3651
requires(1 < sizeof(return_value_type))
52+
#if __has_cpp_attribute(__gnu__::__always_inline__)
53+
[[__gnu__::__always_inline__]]
54+
#else
55+
#error "system_call must be inlined"
56+
#endif
3757
inline return_value_type system_call(auto p1, auto p2) noexcept
3858
{
3959
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -45,6 +65,11 @@ inline return_value_type system_call(auto p1, auto p2) noexcept
4565

4666
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
4767
requires(1 < sizeof(return_value_type))
68+
#if __has_cpp_attribute(__gnu__::__always_inline__)
69+
[[__gnu__::__always_inline__]]
70+
#else
71+
#error "system_call must be inlined"
72+
#endif
4873
inline return_value_type system_call(auto p1, auto p2, auto p3) noexcept
4974
{
5075
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -57,6 +82,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3) noexcept
5782

5883
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
5984
requires(1 < sizeof(return_value_type))
85+
#if __has_cpp_attribute(__gnu__::__always_inline__)
86+
[[__gnu__::__always_inline__]]
87+
#else
88+
#error "system_call must be inlined"
89+
#endif
6090
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4) noexcept
6191
{
6292
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -70,6 +100,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4) noexcep
70100

71101
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
72102
requires(1 < sizeof(return_value_type))
103+
#if __has_cpp_attribute(__gnu__::__always_inline__)
104+
[[__gnu__::__always_inline__]]
105+
#else
106+
#error "system_call must be inlined"
107+
#endif
73108
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5) noexcept
74109
{
75110
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;
@@ -84,6 +119,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5
84119

85120
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
86121
requires(1 < sizeof(return_value_type))
122+
#if __has_cpp_attribute(__gnu__::__always_inline__)
123+
[[__gnu__::__always_inline__]]
124+
#else
125+
#error "system_call must be inlined"
126+
#endif
87127
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5, auto p6) noexcept
88128
{
89129
register ::std::uint_least64_t x8 __asm__("x8") = syscall_number;

Diff for: include/fast_io_hosted/platforms/linux/amd64.h

+40-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
namespace fast_io
55
{
6-
76
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
87
requires(1 < sizeof(return_value_type))
8+
#if __has_cpp_attribute(__gnu__::__always_inline__)
9+
[[__gnu__::__always_inline__]]
10+
#else
11+
#error "system_call must be inlined"
12+
#endif
913
inline return_value_type system_call() noexcept
1014
{
1115
return_value_type ret;
@@ -19,6 +23,11 @@ inline return_value_type system_call() noexcept
1923

2024
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
2125
requires(1 < sizeof(return_value_type))
26+
#if __has_cpp_attribute(__gnu__::__always_inline__)
27+
[[__gnu__::__always_inline__]]
28+
#else
29+
#error "system_call must be inlined"
30+
#endif
2231
inline return_value_type system_call(auto p1) noexcept
2332
{
2433
return_value_type ret;
@@ -31,6 +40,11 @@ inline return_value_type system_call(auto p1) noexcept
3140
}
3241

3342
template <::std::size_t syscall_number>
43+
#if __has_cpp_attribute(__gnu__::__always_inline__)
44+
[[__gnu__::__always_inline__]]
45+
#else
46+
#error "system_call must be inlined"
47+
#endif
3448
inline void system_call_no_return(auto p1) noexcept
3549
{
3650
::std::size_t ret;
@@ -44,6 +58,11 @@ inline void system_call_no_return(auto p1) noexcept
4458

4559
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
4660
requires(1 < sizeof(return_value_type))
61+
#if __has_cpp_attribute(__gnu__::__always_inline__)
62+
[[__gnu__::__always_inline__]]
63+
#else
64+
#error "system_call must be inlined"
65+
#endif
4766
inline return_value_type system_call(auto p1, auto p2) noexcept
4867
{
4968
return_value_type ret;
@@ -57,6 +76,11 @@ inline return_value_type system_call(auto p1, auto p2) noexcept
5776

5877
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
5978
requires(1 < sizeof(return_value_type))
79+
#if __has_cpp_attribute(__gnu__::__always_inline__)
80+
[[__gnu__::__always_inline__]]
81+
#else
82+
#error "system_call must be inlined"
83+
#endif
6084
inline return_value_type system_call(auto p1, auto p2, auto p3) noexcept
6185
{
6286
return_value_type ret;
@@ -70,6 +94,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3) noexcept
7094

7195
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
7296
requires(1 < sizeof(return_value_type))
97+
#if __has_cpp_attribute(__gnu__::__always_inline__)
98+
[[__gnu__::__always_inline__]]
99+
#else
100+
#error "system_call must be inlined"
101+
#endif
73102
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4) noexcept
74103
{
75104
return_value_type ret;
@@ -84,6 +113,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4) noexcep
84113

85114
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
86115
requires(1 < sizeof(return_value_type))
116+
#if __has_cpp_attribute(__gnu__::__always_inline__)
117+
[[__gnu__::__always_inline__]]
118+
#else
119+
#error "system_call must be inlined"
120+
#endif
87121
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5) noexcept
88122
{
89123
return_value_type ret;
@@ -99,6 +133,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5
99133

100134
template <::std::size_t syscall_number, ::std::signed_integral return_value_type>
101135
requires(1 < sizeof(return_value_type))
136+
#if __has_cpp_attribute(__gnu__::__always_inline__)
137+
[[__gnu__::__always_inline__]]
138+
#else
139+
#error "system_call must be inlined"
140+
#endif
102141
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5, auto p6) noexcept
103142
{
104143
return_value_type ret;

Diff for: include/fast_io_hosted/platforms/linux/generic.h

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ namespace fast_io
77

88
template <::std::size_t syscall_number, ::std::signed_integral return_value_type, typename... Args>
99
requires(::std::is_trivially_copyable_v<Args> && ...)
10+
#if __has_cpp_attribute(__gnu__::__always_inline__)
11+
[[__gnu__::__always_inline__]]
12+
#else
13+
#error "system_call must be inlined"
14+
#endif
1015
inline return_value_type system_call(Args... args) noexcept
1116
{
1217
long ret{::syscall(syscall_number, args...)};
@@ -18,6 +23,11 @@ inline return_value_type system_call(Args... args) noexcept
1823
}
1924

2025
template <::std::size_t syscall_number>
26+
#if __has_cpp_attribute(__gnu__::__always_inline__)
27+
[[__gnu__::__always_inline__]]
28+
#else
29+
#error "system_call must be inlined"
30+
#endif
2131
inline void system_call_no_return(auto p1) noexcept
2232
{
2333
::syscall(syscall_number, p1);

Diff for: include/fast_io_hosted/platforms/linux/loongarch64.h

+40
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace fast_io
1010

1111
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
1212
requires(1 < sizeof(return_value_type))
13+
#if __has_cpp_attribute(__gnu__::__always_inline__)
14+
[[__gnu__::__always_inline__]]
15+
#else
16+
#error "system_call must be inlined"
17+
#endif
1318
inline return_value_type system_call() noexcept
1419
{
1520
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -21,6 +26,11 @@ inline return_value_type system_call() noexcept
2126

2227
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
2328
requires(1 < sizeof(return_value_type))
29+
#if __has_cpp_attribute(__gnu__::__always_inline__)
30+
[[__gnu__::__always_inline__]]
31+
#else
32+
#error "system_call must be inlined"
33+
#endif
2434
inline return_value_type system_call(auto p1) noexcept
2535
{
2636
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -31,6 +41,11 @@ inline return_value_type system_call(auto p1) noexcept
3141
}
3242

3343
template <::std::uint_least64_t syscall_number>
44+
#if __has_cpp_attribute(__gnu__::__always_inline__)
45+
[[__gnu__::__always_inline__]]
46+
#else
47+
#error "system_call must be inlined"
48+
#endif
3449
inline void system_call_no_return(auto p1) noexcept
3550
{
3651
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -42,6 +57,11 @@ inline void system_call_no_return(auto p1) noexcept
4257

4358
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
4459
requires(1 < sizeof(return_value_type))
60+
#if __has_cpp_attribute(__gnu__::__always_inline__)
61+
[[__gnu__::__always_inline__]]
62+
#else
63+
#error "system_call must be inlined"
64+
#endif
4565
inline return_value_type system_call(auto p1, auto p2) noexcept
4666
{
4767
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -54,6 +74,11 @@ inline return_value_type system_call(auto p1, auto p2) noexcept
5474

5575
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
5676
requires(1 < sizeof(return_value_type))
77+
#if __has_cpp_attribute(__gnu__::__always_inline__)
78+
[[__gnu__::__always_inline__]]
79+
#else
80+
#error "system_call must be inlined"
81+
#endif
5782
inline return_value_type system_call(auto p1, auto p2, auto p3) noexcept
5883
{
5984
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -67,6 +92,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3) noexcept
6792

6893
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
6994
requires(1 < sizeof(return_value_type))
95+
#if __has_cpp_attribute(__gnu__::__always_inline__)
96+
[[__gnu__::__always_inline__]]
97+
#else
98+
#error "system_call must be inlined"
99+
#endif
70100
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4) noexcept
71101
{
72102
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -81,6 +111,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4) noexcep
81111

82112
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
83113
requires(1 < sizeof(return_value_type))
114+
#if __has_cpp_attribute(__gnu__::__always_inline__)
115+
[[__gnu__::__always_inline__]]
116+
#else
117+
#error "system_call must be inlined"
118+
#endif
84119
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5) noexcept
85120
{
86121
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;
@@ -96,6 +131,11 @@ inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5
96131

97132
template <::std::uint_least64_t syscall_number, ::std::signed_integral return_value_type>
98133
requires(1 < sizeof(return_value_type))
134+
#if __has_cpp_attribute(__gnu__::__always_inline__)
135+
[[__gnu__::__always_inline__]]
136+
#else
137+
#error "system_call must be inlined"
138+
#endif
99139
inline return_value_type system_call(auto p1, auto p2, auto p3, auto p4, auto p5, auto p6) noexcept
100140
{
101141
register ::std::uint_least64_t a7 __asm__("$a7") = syscall_number;

0 commit comments

Comments
 (0)