diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-11-02 12:08:38 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-11-02 14:38:03 +0000 |
commit | 9a1a0c67ac6cb4e13d361c116e5e70dfc22d9c17 (patch) | |
tree | b80a47c4eaec01abc82fd67948a47d015ef04593 /generator | |
parent | 58720cc968366894366a430842b4bc5151b5f7fd (diff) | |
download | libguestfs-9a1a0c67ac6cb4e13d361c116e5e70dfc22d9c17.tar.gz libguestfs-9a1a0c67ac6cb4e13d361c116e5e70dfc22d9c17.tar.xz libguestfs-9a1a0c67ac6cb4e13d361c116e5e70dfc22d9c17.zip |
generator: Split up huge src/actions.c into separate files.
Split the functions according to a simple hash across
C.nr_actions_files files (this number can be increased later if
necessary).
This is just code motion.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/c.ml | 18 | ||||
-rw-r--r-- | generator/main.ml | 6 |
2 files changed, 20 insertions, 4 deletions
diff --git a/generator/c.ml b/generator/c.ml index 7b9c04d7..76c74226 100644 --- a/generator/c.ml +++ b/generator/c.ml @@ -32,6 +32,16 @@ open Events (* Generate C API. *) +(* The actions are split across this many C files. You can increase + * this number in order to reduce the number of lines in each file + * (hence making compilation faster), but you also have to modify + * src/Makefile.am. + *) +let nr_actions_files = 7 +let hash_matches h { name = name } = + let h' = Hashtbl.hash name mod nr_actions_files in + h = h' + type optarg_proto = Dots | VA | Argv (* Generate a C function prototype. *) @@ -730,7 +740,7 @@ and generate_client_free_structs () = ) structs (* Generate the client-side dispatch stubs. *) -and generate_client_actions () = +and generate_client_actions hash () = generate_header CStyle LGPLv2plus; pr "\ @@ -1096,7 +1106,8 @@ and generate_client_actions () = in List.iter ( - fun f -> generate_non_daemon_wrapper f + fun f -> + if hash_matches hash f then generate_non_daemon_wrapper f ) non_daemon_functions; (* Client-side stubs for each function. *) @@ -1387,7 +1398,8 @@ and generate_client_actions () = in List.iter ( - fun f -> generate_daemon_stub f + fun f -> + if hash_matches hash f then generate_daemon_stub f ) daemon_functions (* Functions which have optional arguments have two or three diff --git a/generator/main.ml b/generator/main.ml index 3a03f085..f8df1295 100644 --- a/generator/main.ml +++ b/generator/main.ml @@ -94,9 +94,13 @@ Run it from the top source directory using the command output_to "src/libguestfs.syms" generate_linker_script; output_to "src/free-structs.c" generate_client_free_structs; - output_to "src/actions.c" generate_client_actions; output_to "src/actions-variants.c" generate_client_actions_variants; + for i = 0 to nr_actions_files-1 do + let filename = sprintf "src/actions-%d.c" i in + output_to filename (generate_client_actions i) + done; + output_to "daemon/actions.h" generate_daemon_actions_h; output_to "daemon/stubs.c" generate_daemon_actions; output_to "daemon/names.c" generate_daemon_names; |