[master] 4c356d6 Make vrt.h include <stddef.h> and <stdint.h>

Poul-Henning Kamp phk at FreeBSD.org
Tue Oct 24 07:14:12 UTC 2017


commit 4c356d698b7abc59195989bcddcbcb210cc6c096
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Oct 24 07:12:15 2017 +0000

    Make vrt.h include <stddef.h> and <stdint.h>
    
    Originally we decided that the output of VCC should be 100%
    stand-alone and therefore contain no #includes at all.  This
    was hoped to avoid unspecified trouble with C-compilers at runtime.
    
    But C99 is old enough to drink now, so we move forward.
    
    The script in tools/include_wash.py checks *.c files and
    complains about violations of our intended #include orders.

diff --git a/tools/include_wash.py b/tools/include_wash.py
new file mode 100644
index 0000000..6dd12f6
--- /dev/null
+++ b/tools/include_wash.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import os
+
+def check(fn):
+	l = []
+	for i in open(fn):
+		i = i.strip()
+		if len(i) == 0:
+			continue
+		if i[0] != "#":
+			continue
+		if i.find("include") == -1:
+			continue
+		if i.find('"') == -1:
+			l.append(i.split('<')[1].split('>')[0])
+		else:
+			l.append(i.split('"')[1])
+	if "vrt.h" in l:
+		vrt = l.index("vrt.h")
+		if not "vdef.h" in l:
+			print(fn, "vdef.h not included with vrt.h")
+		vdef = l.index("vdef.h")
+		if vdef > vrt:
+			print(fn, "vdef.h included after vrt.h")
+		for i in ("stddef.h", "stdint.h", "cache/cache.h", "cache.h"):
+			if i in l:
+				print(fn, i + " included with vrt.h")
+		
+	for i in ("cache/cache.h", "cache.h"):
+		if i in l:
+			for i in (
+			    "stddef.h", "stdint.h", "vrt.h",
+			    "math.h", "pthread.h", "stdarg.h", "sys/types.h",
+			    "vdef.h", "miniobj.h", "vas.h", "vqueue.h",
+			):
+				if i in l:
+					print(fn, i + " included with cache.h")
+
+for (dir, dns, fns) in os.walk("."):
+	for f in fns:
+		if f[-2:] == ".c":
+			check(dir + "/" + f)


More information about the varnish-commit mailing list