-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,517 additions
and
1,460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{BasedOnStyle: Chromium, IndentWidth: 4} | ||
{BasedOnStyle: Chromium, IndentWidth: 4, ReflowComments: false, SortIncludes: "Never"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Usage: ./clang-format.sh /usr/bin/clang-format(version >= 10.0) [-f] | ||
# Specify -f to format all c/cxx files, instead of check if the files satisfy the format file | ||
|
||
lint() { | ||
local targets="examples wasm-sdk runtime/cpp/include runtime/cpp/test runtime/cpp/src" | ||
local clang_format="${1}" | ||
|
||
if [ "$#" -lt 1 ]; then | ||
echo "please provide clang-format command. Usage ${0} `which clang-format`" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "${clang_format}" ]; then | ||
echo "clang-format not found. Please install clang-format first" | ||
exit 1 | ||
fi | ||
local ext_args="-Werror --dry-run" | ||
if [ "${2}" = "-f" ]; then | ||
ext_args="" | ||
fi | ||
find ${targets} -type f -iname *.[ch] -o -iname *.cpp -o -iname *.[ch]xx \ | ||
| xargs -n1 ${clang_format} -i -style=file ${ext_args} | ||
|
||
exit $? | ||
} | ||
|
||
lint $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: "c-cpp-lint" | ||
|
||
on: | ||
push: | ||
branches: "main" | ||
pull_request: | ||
branches: "*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: install deps | ||
run: | | ||
sudo apt-get install clang-format | ||
- name: Run clang-format | ||
run: | | ||
./.github/scripts/clang-format.sh `which clang-format` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ static struct env { | |
long min_duration_ms; | ||
} env; | ||
|
||
const char *argp_program_version = "bootstrap 0.0"; | ||
const char *argp_program_bug_address = "<[email protected]>"; | ||
const char* argp_program_version = "bootstrap 0.0"; | ||
const char* argp_program_bug_address = "<[email protected]>"; | ||
const char argp_program_doc[] = | ||
"BPF bootstrap demo application.\n" | ||
"\n" | ||
|
@@ -21,18 +21,14 @@ const char argp_program_doc[] = | |
"\n" | ||
"USAGE: ./bootstrap [-d <min-duration-ms>] -v\n"; | ||
|
||
static void | ||
print_usage(void) | ||
{ | ||
static void print_usage(void) { | ||
printf("%s\n", argp_program_version); | ||
printf("%s\n", argp_program_doc); | ||
} | ||
|
||
static int | ||
handle_event(void *ctx, void *data, size_t data_sz) | ||
{ | ||
const struct event *e = data; | ||
struct tm *tm; | ||
static int handle_event(void* ctx, void* data, size_t data_sz) { | ||
const struct event* e = data; | ||
struct tm* tm; | ||
char ts[32]; | ||
time_t t; | ||
|
||
|
@@ -46,8 +42,7 @@ handle_event(void *ctx, void *data, size_t data_sz) | |
if (e->duration_ns) | ||
printf(" (%llums)", e->duration_ns / 1000000); | ||
printf("\n"); | ||
} | ||
else { | ||
} else { | ||
printf("%-8s %-5s %-16s %-7d %-7d %s\n", ts, "EXEC", e->comm, e->pid, | ||
e->ppid, e->filename); | ||
} | ||
|
@@ -57,20 +52,19 @@ handle_event(void *ctx, void *data, size_t data_sz) | |
|
||
static bool exiting = false; | ||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
struct bpf_buffer *rb = NULL; | ||
struct bootstrap_bpf *skel; | ||
int main(int argc, char** argv) { | ||
struct bpf_buffer* rb = NULL; | ||
struct bootstrap_bpf* skel; | ||
int err; | ||
|
||
// parse the args manually for demo purpose | ||
if (argc > 3 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { | ||
// parse the args manually for demo purpose | ||
if (argc > 3 || strcmp(argv[1], "-h") == 0 || | ||
strcmp(argv[1], "--help") == 0) { | ||
print_usage(); | ||
return 0; | ||
} | ||
else if ((strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--duration") == 0) | ||
&& argc == 3) { | ||
} else if ((strcmp(argv[1], "-d") == 0 || | ||
strcmp(argv[1], "--duration") == 0) && | ||
argc == 3) { | ||
env.min_duration_ms = strtol(argv[2], NULL, 10); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.