-void
-sgen_binary_protocol_grep_entries (EntryStream *stream, int num_nums, long nums [], int num_vtables, long vtables [],
+static gboolean
+sgen_binary_protocol_read_header (EntryStream *stream)
+{
+#ifdef BINPROT_HAS_HEADER
+ char data [MAX_ENTRY_SIZE];
+ int type = read_entry (stream, data);
+ if (type == SGEN_PROTOCOL_EOF)
+ return FALSE;
+ if (type == PROTOCOL_ID (binary_protocol_header)) {
+ PROTOCOL_STRUCT (binary_protocol_header) * str = (PROTOCOL_STRUCT (binary_protocol_header) *) data;
+ if (str->check == PROTOCOL_HEADER_CHECK)
+ return TRUE;
+ }
+ return FALSE;
+#else
+ /*
+ * This implementation doesn't account for the presence of a header,
+ * reading all the entries with the default configuration of the host
+ * machine. It has to be used only after all other implementations
+ * fail to identify a header, for backward compatibility.
+ */
+ return TRUE;
+#endif
+}
+
+#define CONC(A, B) CONC_(A, B)
+#define CONC_(A, B) A##B
+#define GREP_ENTRIES_FUNCTION_NAME CONC(sgen_binary_protocol_grep_entries, PACKED_SUFFIX)
+
+gboolean
+GREP_ENTRIES_FUNCTION_NAME (EntryStream *stream, int num_nums, long nums [], int num_vtables, long vtables [],