about summary refs log tree commit diff
path: root/sysdeps/nacl/nacl-interfaces.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2015-06-03 13:51:11 -0700
committerRoland McGrath <roland@hack.frob.com>2015-06-03 13:51:11 -0700
commitda7f049cad943629f16cd6e533214955edfd511d (patch)
tree6a27b5a9eb095e7fe208e7bf6f2aef614dfe2e5b /sysdeps/nacl/nacl-interfaces.c
parentcbf377edd318a6f35e5b54573f902299c6da9ed5 (diff)
downloadglibc-da7f049cad943629f16cd6e533214955edfd511d.tar.gz
glibc-da7f049cad943629f16cd6e533214955edfd511d.tar.xz
glibc-da7f049cad943629f16cd6e533214955edfd511d.zip
NaCl: Implement nacl_interface_ext_supply entry point.
Diffstat (limited to 'sysdeps/nacl/nacl-interfaces.c')
-rw-r--r--sysdeps/nacl/nacl-interfaces.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sysdeps/nacl/nacl-interfaces.c b/sysdeps/nacl/nacl-interfaces.c
index cb0dcd0bc8..5dbfadd7f1 100644
--- a/sysdeps/nacl/nacl-interfaces.c
+++ b/sysdeps/nacl/nacl-interfaces.c
@@ -121,3 +121,45 @@ __nacl_initialize_interfaces (void)
   initialize_mandatory_interfaces ();
   initialize_optional_interfaces ();
 }
+
+
+static bool
+try_supply (const struct nacl_interface *const start,
+	    const struct nacl_interface *const stop,
+	    uintptr_t *all_tables,
+	    const char *ident, size_t ident_len,
+	    const void *table, size_t tablesize)
+{
+  const struct nacl_interface *i = start;
+  uintptr_t *t = all_tables;
+  while (i < stop)
+    {
+      if (i->table_size == tablesize
+	  && i->namelen == ident_len
+	  && !memcmp (i->name, ident, ident_len))
+	{
+	  memcpy (t, table, tablesize);
+	  return true;
+	}
+
+      t = next_nacl_table (t, i);
+      i = next_nacl_interface (i);
+    }
+
+  return false;
+}
+
+internal_function
+bool
+PASTE_NAME (__nacl_supply_interface_, MODULE_NAME)
+  (const char *ident, size_t ident_len, const void *table, size_t tablesize)
+{
+  return (try_supply (__start_nacl_mandatory_interface_names,
+		      __stop_nacl_mandatory_interface_names,
+		      __start_nacl_mandatory_interface_tables,
+		      ident, ident_len, table, tablesize)
+	  || try_supply (__start_nacl_optional_interface_names,
+			 __stop_nacl_optional_interface_names,
+			 __start_nacl_optional_interface_tables,
+			 ident, ident_len, table, tablesize));
+}