summaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-11-25 13:46:41 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-10-10 15:11:48 +0200
commit003b3a589a0db5eb1db9376d707f3ca68220dba0 (patch)
treecd3d8b0850751cb6323ec147a9807cb40108cfbd /server.c
parent4d0503d0040fd1ba590d3c7cd68b444bfcbbae5a (diff)
Add support for protected payloads
Add support for protected payloads. The new `intranpayload' option can be used to specify a translation function translating payloads to values of the translated type. This function will be used instead of the `intran' function to to look up the receiving object of a message in a server. This makes it easy to use the protected payloads introduced in GNU Mach 1.5. An inTransPayload function translates payloads to objects, like an inTrans function translates from port names to objects. Generate code in the server routine to optimize lookups to the receiver of the message. Additionally, if no intran function is provided, but an intranpayload function is, it is expected to translate from payloads to port names. This is used to preserve the semantics in case the server routine expects a port name. * NEWS: Add item. * lexxer.l: Emit syInTranPayload. * parser.h: Define syInTranPayload. * parser.y (TransTypeSpec): Handle syInTranPayload. * type.h (struct ipc_type): Add itInTransPayload. * server.c (WriteExtractArgValue): If a payload-aware intrans function has been specified, use it to get a reference to the receiving object. * routine.c (rtAugmentArgKind): Force the use of a local variable if a payload-aware translate-in function is defined.
Diffstat (limited to 'server.c')
-rw-r--r--server.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/server.c b/server.c
index a3368f6..ae5977f 100644
--- a/server.c
+++ b/server.c
@@ -587,14 +587,45 @@ static void
WriteExtractArgValue(FILE *file, const argument_t *arg)
{
const ipc_type_t *it = arg->argType;
+ boolean_t have_payload;
if (arg->argMultiplier > 1)
WriteCopyType(file, it, "%s", "/* %s */ %s / %d",
arg->argVarName, InArgMsgField(arg), arg->argMultiplier);
- else if (it->itInTrans != strNULL)
- WriteCopyType(file, it, "%s", "/* %s */ %s(%s)",
- arg->argVarName, it->itInTrans, InArgMsgField(arg));
- else
+ else if ((have_payload = (it->itInTransPayload != strNULL &&
+ strcmp(arg->argMsgField, "Head.msgh_request_port") == 0)) ||
+ it->itInTrans != strNULL) {
+
+ if (have_payload) {
+ argument_t argPayload = *arg;
+ argPayload.argMsgField = "Head.msgh_bits";
+ fprintf(file,
+ "\tif (MACH_MSGH_BITS_LOCAL (%s) == "
+ "MACH_MSG_TYPE_PROTECTED_PAYLOAD)\n"
+ "\t", InArgMsgField(&argPayload));
+
+ argPayload.argMsgField = "Head.msgh_protected_payload";
+ WriteCopyType(file, it, "%s", "/* %s */ %s(%s)",
+ arg->argVarName, it->itInTransPayload,
+ InArgMsgField(&argPayload));
+
+ fprintf(file,
+ "\telse\n"
+ "\t");
+
+ if (it->itInTrans == strNULL)
+ fprintf(file, "\t%s = %s;",
+ arg->argVarName, InArgMsgField(arg));
+ else
+ WriteCopyType(file, it, "%s", "/* %s */ %s(%s)",
+ arg->argVarName, it->itInTrans,
+ InArgMsgField(arg));
+ } else {
+ WriteCopyType(file, it, "%s", "/* %s */ %s(%s)",
+ arg->argVarName, it->itInTrans,
+ InArgMsgField(arg));
+ }
+ } else
WriteCopyType(file, it, "%s", "/* %s */ %s",
arg->argVarName, InArgMsgField(arg));
fprintf(file, "\n");