1.1 --- a/client.c Mon Aug 03 00:02:30 2020 +0200
1.2 +++ b/client.c Mon Aug 03 00:03:20 2020 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Client code generation.
1.6 *
1.7 - * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -34,7 +34,10 @@
1.13 void write_client_signature(struct signature *sig, enum signature_role role,
1.14 FILE *fp, struct interface *iface)
1.15 {
1.16 - write_interface_signature(sig, role, CLIENT_ROLE, fp, iface);
1.17 + /* Client interface signatures are oblivious to completions. */
1.18 +
1.19 + write_interface_signature(sig, role, CLIENT_ROLE, GENERAL_FUNCTION_ROLE, fp,
1.20 + iface);
1.21 }
1.22
1.23 /* Generate function source code for each operation signature. */
2.1 --- a/common.c Mon Aug 03 00:02:30 2020 +0200
2.2 +++ b/common.c Mon Aug 03 00:03:20 2020 +0200
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Common routines.
2.6 *
2.7 - * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -163,6 +163,14 @@
2.13 return have_identifier(ident->tail, value);
2.14 }
2.15
2.16 +/* Return the function role of the given signature for server use. */
2.17 +
2.18 +enum function_role get_server_function_role(struct signature *sig)
2.19 +{
2.20 + return have_attribute(sig->attributes, "completion") ? COMPLETION_ROLE
2.21 + : GENERAL_FUNCTION_ROLE;
2.22 +}
2.23 +
2.24 /* Obtain a suitable interface class name depending on the component role. */
2.25
2.26 char *get_interface_class_name(struct interface *iface,
3.1 --- a/common.h Mon Aug 03 00:02:30 2020 +0200
3.2 +++ b/common.h Mon Aug 03 00:03:20 2020 +0200
3.3 @@ -47,6 +47,10 @@
3.4 int have_attribute_value(struct attribute *attr, const char *name, const char *value);
3.5 int have_identifier(struct identifier *ident, const char *value);
3.6
3.7 +/* Function role selection. */
3.8 +
3.9 +enum function_role get_server_function_role(struct signature *sig);
3.10 +
3.11 /* Dispatcher object conversion (from compound to individual interfaces). */
3.12
3.13 char *get_object_conversion(struct interface *iface, int compound);
4.1 --- a/declaration.c Mon Aug 03 00:02:30 2020 +0200
4.2 +++ b/declaration.c Mon Aug 03 00:03:20 2020 +0200
4.3 @@ -30,7 +30,8 @@
4.4 /* Generate each operation signature for use in defining an interface. */
4.5
4.6 void write_interface_signature(struct signature *sig, enum signature_role role,
4.7 - enum component_role component, FILE *fp,
4.8 + enum component_role component,
4.9 + enum function_role function, FILE *fp,
4.10 struct interface *iface)
4.11 {
4.12 int cpp = (conf.language == CPP_LANGUAGE);
4.13 @@ -38,9 +39,11 @@
4.14 int declaration = (role & DECLARATION_ROLE);
4.15 int member = (role & MEMBER_ROLE);
4.16 int server = (component == SERVER_ROLE);
4.17 - int completion = have_attribute(sig->attributes, "completion");
4.18 - enum specifier direction = (server && completion) ? IN_PARAMETER : ANY_PARAMETER;
4.19 - enum function_role function = (server && completion) ? COMPLETION_ROLE : GENERAL_FUNCTION_ROLE;
4.20 +
4.21 + /* Explicit completion functions only employ input/inout parameters. */
4.22 +
4.23 + int completion = (function == COMPLETION_ROLE);
4.24 + enum specifier direction = completion ? IN_PARAMETER : ANY_PARAMETER;
4.25
4.26 /* Indent and provide a qualifier for C++ class declarations. */
4.27
5.1 --- a/declaration.h Mon Aug 03 00:02:30 2020 +0200
5.2 +++ b/declaration.h Mon Aug 03 00:03:20 2020 +0200
5.3 @@ -1,7 +1,7 @@
5.4 /*
5.5 * Generation of declaration elements such as parameters and members.
5.6 *
5.7 - * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
5.8 + * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
5.9 *
5.10 * This program is free software; you can redistribute it and/or
5.11 * modify it under the terms of the GNU General Public License as
5.12 @@ -27,7 +27,8 @@
5.13 /* Signatures. */
5.14
5.15 void write_interface_signature(struct signature *sig, enum signature_role role,
5.16 - enum component_role component, FILE *fp,
5.17 + enum component_role component,
5.18 + enum function_role function, FILE *fp,
5.19 struct interface *iface);
5.20
5.21 void write_interface_unimplemented_method(struct signature *sig,
6.1 --- a/server.c Mon Aug 03 00:02:30 2020 +0200
6.2 +++ b/server.c Mon Aug 03 00:03:20 2020 +0200
6.3 @@ -35,7 +35,8 @@
6.4 enum signature_role role, FILE *fp,
6.5 struct interface *iface)
6.6 {
6.7 - write_interface_signature(sig, role, SERVER_ROLE, fp, iface);
6.8 + write_interface_signature(sig, role, SERVER_ROLE,
6.9 + get_server_function_role(sig), fp, iface);
6.10 }
6.11
6.12 /* Generate signature declarations for each operation. */
7.1 --- a/templates.h Mon Aug 03 00:02:30 2020 +0200
7.2 +++ b/templates.h Mon Aug 03 00:03:20 2020 +0200
7.3 @@ -84,6 +84,7 @@
7.4 "#include \"%s_server.h\"\n"
7.5
7.6 #define compound_dispatch_function_prologue \
7.7 +" long err;\n\n" \
7.8 " switch (l4_msgtag_label(msg->tag))\n" \
7.9 " {\n"
7.10
7.11 @@ -325,7 +326,7 @@
7.12 #define dispatch_function_reply_wrapper_case \
7.13 " case %s:\n" \
7.14 " err = %s_%s(msg, %s);\n" \
7.15 -" ipc_message_send_error(msg, err != IPC_MESSAGE_SENT ? err : L4_EOK);\n" \
7.16 +" ipc_message_send_error(msg, err != IPC_MESSAGE_SENT ? err : (long) L4_EOK);\n" \
7.17 " if (err != IPC_MESSAGE_SENT)\n" \
7.18 " ipc_message_reply(msg);\n" \
7.19 " break;\n\n"