mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -340,7 +340,7 @@ Makefile.in
|
||||
/sparsify/stamp-virt-sparsify.pod
|
||||
/sparsify/virt-sparsify
|
||||
/sparsify/virt-sparsify.1
|
||||
/src/actions.c
|
||||
/src/actions-?.c
|
||||
/src/actions-variants.c
|
||||
/src/bindtests.c
|
||||
/src/errnostring.c
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -216,9 +216,15 @@ rescue/test-virt-rescue.pl
|
||||
rescue/virt-rescue.c
|
||||
resize/progress-c.c
|
||||
ruby/ext/guestfs/_guestfs.c
|
||||
src/actions-0.c
|
||||
src/actions-1.c
|
||||
src/actions-2.c
|
||||
src/actions-3.c
|
||||
src/actions-4.c
|
||||
src/actions-5.c
|
||||
src/actions-6.c
|
||||
src/actions-support.c
|
||||
src/actions-variants.c
|
||||
src/actions.c
|
||||
src/appliance.c
|
||||
src/bindtests.c
|
||||
src/command.c
|
||||
|
||||
@@ -23,7 +23,13 @@ generator_built = \
|
||||
guestfs_protocol.x \
|
||||
guestfs.h \
|
||||
guestfs-internal-actions.h \
|
||||
actions.c \
|
||||
actions-0.c \
|
||||
actions-1.c \
|
||||
actions-2.c \
|
||||
actions-3.c \
|
||||
actions-4.c \
|
||||
actions-5.c \
|
||||
actions-6.c \
|
||||
actions-variants.c \
|
||||
bindtests.c \
|
||||
errnostring-gperf.gperf \
|
||||
@@ -124,7 +130,13 @@ libguestfs_la_SOURCES = \
|
||||
guestfs.h \
|
||||
guestfs-internal.h \
|
||||
guestfs_protocol.h \
|
||||
actions.c \
|
||||
actions-0.c \
|
||||
actions-1.c \
|
||||
actions-2.c \
|
||||
actions-3.c \
|
||||
actions-4.c \
|
||||
actions-5.c \
|
||||
actions-6.c \
|
||||
actions-support.c \
|
||||
actions-variants.c \
|
||||
appliance.c \
|
||||
|
||||
Reference in New Issue
Block a user