[pypy-commit] cffi cffi-1.0: Add "static" and a test that no unexpected symbols are exported

arigo noreply at buildbot.pypy.org
Fri May 1 11:58:06 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1899:eb239c6af2dc
Date: 2015-05-01 11:58 +0200
http://bitbucket.org/cffi/cffi/changeset/eb239c6af2dc/

Log:	Add "static" and a test that no unexpected symbols are exported

diff --git a/_cffi1/parse_c_type.c b/_cffi1/parse_c_type.c
--- a/_cffi1/parse_c_type.c
+++ b/_cffi1/parse_c_type.c
@@ -406,6 +406,7 @@
 
 
 #define MAKE_SEARCH_FUNC(FIELD)                                 \
+  static                                                        \
   int search_in_##FIELD(const struct _cffi_type_context_s *ctx, \
                         const char *search, size_t search_len)  \
   {                                                             \
@@ -433,6 +434,7 @@
 #undef MAKE_SEARCH_FUNC
 
 
+static
 int search_standard_typename(const char *p, size_t size)
 {
     if (size < 6 || p[size-2] != '_' || p[size-1] != 't')
@@ -729,6 +731,7 @@
 }
 
 
+static
 int parse_c_type(struct _cffi_parse_info_s *info, const char *input)
 {
     int result;
diff --git a/_cffi1/parse_c_type.h b/_cffi1/parse_c_type.h
--- a/_cffi1/parse_c_type.h
+++ b/_cffi1/parse_c_type.h
@@ -141,9 +141,9 @@
 };
 
 #ifdef _CFFI_INTERNAL
-int parse_c_type(struct _cffi_parse_info_s *info, const char *input);
-int search_in_globals(const struct _cffi_type_context_s *ctx,
-                      const char *search, size_t search_len);
-int search_in_struct_unions(const struct _cffi_type_context_s *ctx,
-                            const char *search, size_t search_len);
+static int parse_c_type(struct _cffi_parse_info_s *info, const char *input);
+static int search_in_globals(const struct _cffi_type_context_s *ctx,
+                             const char *search, size_t search_len);
+static int search_in_struct_unions(const struct _cffi_type_context_s *ctx,
+                                   const char *search, size_t search_len);
 #endif
diff --git a/_cffi1/test_cffi_binary.py b/_cffi1/test_cffi_binary.py
new file mode 100644
--- /dev/null
+++ b/_cffi1/test_cffi_binary.py
@@ -0,0 +1,18 @@
+import py, sys, os
+import _cffi_backend
+
+def test_no_unknown_exported_symbols():
+    if not sys.platform.startswith('linux'):
+        py.test.skip("linux-only")
+    g = os.popen("objdump -T '%s'" % _cffi_backend.__file__, 'r')
+    for line in g:
+        if not line.startswith('0'):
+            continue
+        if '*UND*' in line:
+            continue
+        name = line.split()[-1]
+        if name.startswith('_') or name.startswith('.'):
+            continue
+        if name not in ('init_cffi_backend', 'PyInit__cffi_backend'):
+            raise Exception("Unexpected exported name %r" % (name,))
+    g.close()


More information about the pypy-commit mailing list