summaryrefslogtreecommitdiffstats
path: root/src/pmdk/utils/check-os.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/pmdk/utils/check-os.sh')
-rwxr-xr-xsrc/pmdk/utils/check-os.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pmdk/utils/check-os.sh b/src/pmdk/utils/check-os.sh
new file mode 100755
index 000000000..64d371c13
--- /dev/null
+++ b/src/pmdk/utils/check-os.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2017-2019, Intel Corporation
+
+#
+# Used to check if there are no banned functions in .o file
+#
+# usage: ./check-os.sh [os.h path] [.o file] [.c file]
+
+EXCLUDE="os_posix|os_thread_posix"
+if [[ $2 =~ $EXCLUDE ]]; then
+ echo "skip $2"
+ exit 0
+fi
+
+symbols=$(nm --demangle --undefined-only --format=posix $2 | sed 's/ U *//g')
+functions=$(cat $1 | tr '\n' '|')
+functions=${functions%?} # remove trailing | character
+out=$(
+ for sym in $symbols
+ do
+ grep -wE $functions <<<"$sym"
+ done | sed 's/$/\(\)/g')
+
+[[ ! -z $out ]] &&
+ echo -e "`pwd`/$3:1: non wrapped function(s):\n$out\nplease use os wrappers" &&
+ rm -f $2 && # remove .o file as it don't match requirements
+ exit 1
+
+exit 0