[ovs-dev] [threads 11/11] Makefile: Blacklist functions that threaded programs cannot use safely.

Ben Pfaff blp at nicira.com
Wed Jun 19 20:17:12 UTC 2013

Some functions that POSIX says cannot be used safely in multithreaded
programs are not on the initial blacklist:

    - getenv() should be safe in real implementations in the absence of
      changes to the environment.  (putenv() and setenv() are blacklisted.)

    - We only use getopt() before spawning extra threads, and I expect this
      to continue to be true.

Signed-off-by: Ben Pfaff <blp at nicira.com>
 Makefile.am                       |   14 ++++++
 build-aux/thread-safety-blacklist |   90 +++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 build-aux/thread-safety-blacklist

diff --git a/Makefile.am b/Makefile.am
index 488aed2..08aea0f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -210,6 +210,20 @@ check-assert-h-usage:
 .PHONY: check-assert-h-usage
+ALL_LOCAL += thread-safety-check
+	@if test -e '$(srcdir)'/.git && (git --version) >/dev/null 2>&1 && \
+	   grep -n -f '$(srcdir)'/build-aux/thread-safety-blacklist \
+	       `git ls-files '$(srcdir)' | grep '\.[ch]$$' \
+                | $(EGREP) -v '^datapath|^lib/sflow|^third-party'` \
+	       | $(EGREP) -v ':[ 	]*/?\*'; \
+	then \
+	    echo "See above for list of calls to functions that are"; \
+	    echo "blacklisted due to thread safety issues"; \
+	    exit 1; \
+	fi
+EXTRA_DIST += build-aux/thread-safety-blacklist
 ALL_LOCAL += manpage-check
 manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
diff --git a/build-aux/thread-safety-blacklist b/build-aux/thread-safety-blacklist
new file mode 100644
index 0000000..42560df
--- /dev/null
+++ b/build-aux/thread-safety-blacklist
@@ -0,0 +1,90 @@

More information about the dev mailing list