Skip to content

Commit 6bad49c

Browse files
committed
fixup2
1 parent a204430 commit 6bad49c

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

calltree.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ ($)
307307
my $RE_SINGLE_LINE_COMMENT = qr'/[/\\].*';
308308
my $RE_LEFT_ANGLES = qr'<[<=]+';
309309
my $RE_TEMPLATE_ARGS_1LAYER = qr'(<\s*(((::)?(\w+::)*\w+\s*,\s*)*(::)?(\w+::)*\w+\s*)>)';
310+
my $RE_STD_FUNCTION = qr'(?:::\s*)?\b(?:\w+\s*::\s*)*(\w+)\s*<\s*\w+\s*\(\)\s*\>';
310311
my $RE_CSV_TOKEN = gen_re_list(",", $RE_SCOPED_IDENTIFIER, "??");
311312
my $RE_NOEXCEPT_THROW = qr"(\\b(noexcept|throw)\\b)(\\s*\\(\\s*$RE_CSV_TOKEN\\s*\\))?";
312313
my $RE_MACRO_DEF = qr/(#define([^\n\r]*\\(\n\r?|\r\n?))*([^\n\r]*[^\n\r\\])?((\n\r?)|(\r\n?)|$))/;
@@ -383,6 +384,10 @@ ($)
383384
($_[0] =~ s/$RE_TEMPLATE_ARGS_1LAYER/&blank_lines($1)/gemr, $1);
384385
}
385386

387+
sub replace_std_function($) {
388+
$_[0] =~ s/$RE_STD_FUNCTION/$1/gr;
389+
}
390+
386391
sub replace_seastar($) {
387392
$_[0] =~ s/^[\n ]*SEASTAR_CONCEPT.*$/ /gr;
388393
}
@@ -453,6 +458,7 @@ ($)
453458
$content = remove_keywords_and_attributes($content);
454459
$content = remove_gcc_attributes($content);
455460
$content = replace_template_args_4layers($content);
461+
$content = replace_std_function($content);
456462
$content = remove_noexcept_and_throw($content);
457463
$content = remove_noexcept($content);
458464
$content = replace_macro_defs($content);

sr_index2.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ ($)
134134
next;
135135
}
136136

137-
if (/\b(ActiveTime|DriverTotalTime|OverheadTime|ScheduleTime|PendingTime|InputEmptyTime|FirstInputEmptyTime|FollowupInputEmptyTime|OutputFullTime|PreconditionBlockTime):\s+(\S+)/) {
137+
if (/\b(ActiveTime|__MAX_OF_DriverPrepareTime|DriverPrepareTime|DriverTotalTime|OverheadTime|ScheduleTime|PendingTime|InputEmptyTime|FirstInputEmptyTime|FollowupInputEmptyTime|OutputFullTime|PreconditionBlockTime):\s+(\S+)/) {
138138
$plan->{$fragment}{pipelines}{$pipeline}{$1}=norm_time($2);
139139
next;
140140
}

unittest/util_test.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <gtest/gtest.h>
1111
#include <immintrin.h>
1212
#include <mmintrin.h>
13+
#include <glog/logging.h>
1314

1415
#include <random>
1516
#include <util/bits_op.hh>
@@ -215,6 +216,39 @@ TEST_F(TestUtil, testHexDecode) {
215216
ASSERT_EQ(r1, r0);
216217
ASSERT_EQ(r0, r2);
217218
}
219+
template<typename Func>
220+
struct WithArg0 {
221+
template<int N>
222+
struct Functor {
223+
void operator()(int m) {
224+
std::cout<<Func()(m,N)<<std::endl;
225+
}
226+
};
227+
};
228+
template<template<int> typename F, typename ... Args>
229+
void dispatch(int n, Args&&...args){
230+
switch(n){
231+
case 0:
232+
return F<0>()(std::forward<Args>(args)...);
233+
case 1:
234+
return F<1>()(std::forward<Args>(args)...);
235+
case 2:
236+
return F<2>()(std::forward<Args>(args)...);
237+
default:
238+
CHECK(false) << "Unknown type: " << n;
239+
__builtin_unreachable();
240+
}
241+
}
242+
struct Add{
243+
int operator()(int n, int m) {return n+m;}
244+
};
245+
struct Multiply{
246+
int operator()(int n, int m) {return n*m;}
247+
};
248+
TEST_F(TestUtil, testCurrying) {
249+
dispatch<WithArg0<Add>::Functor>(2, 10);
250+
dispatch<WithArg0<Multiply>::Functor>(2, 10);
251+
}
218252

219253
} // namespace util
220254
} // namespace grakra

0 commit comments

Comments
 (0)