+/* write_runtime_options uses a simple serialization scheme that
+ * consists of one word of magic, one word indicating whether options
+ * are actually saved, and one word per struct field. */
+static void
+write_runtime_options(FILE *file, struct runtime_options *options)
+{
+ size_t optarray[RUNTIME_OPTIONS_WORDS];
+
+ memset(&optarray, 0, sizeof(optarray));
+ optarray[0] = RUNTIME_OPTIONS_MAGIC;
+
+ if (options != NULL) {
+ /* optarray[1] is a flag indicating that options are present */
+ optarray[1] = 1;
+ optarray[2] = options->dynamic_space_size;
+ optarray[3] = options->thread_control_stack_size;
+ }
+
+ if (RUNTIME_OPTIONS_WORDS !=
+ fwrite(optarray, sizeof(size_t), RUNTIME_OPTIONS_WORDS, file)) {
+ perror("Error writing runtime options to file");
+ }
+}
+