[RFC wayland 07/18] protocol: Add fd_static type

Derek Foreman derekf at osg.samsung.com
Tue Feb 9 16:55:54 UTC 2016


Some file descriptors, such as the ones for keymaps, are filled before
they're sent and expected to be used with mmap().  Add a new fd_static
type to make this more clear.

This is preparation for being able to handle this data over a network.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/connection.c | 12 ++++++++++--
 src/scanner.c    |  9 ++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 65b64e9..05806b6 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -436,6 +436,7 @@ get_next_argument(const char *signature, struct argument_details *details)
 		case 'o':
 		case 'n':
 		case 'a':
+		case 'H':
 		case 'h':
 			details->type = *signature;
 			return signature + 1;
@@ -460,6 +461,7 @@ arg_count_for_signature(const char *signature)
 		case 'o':
 		case 'n':
 		case 'a':
+		case 'H':
 		case 'h':
 			++count;
 		}
@@ -514,6 +516,7 @@ wl_argument_from_va_list(const char *signature, union wl_argument *args,
 		case 'a':
 			args[i].a = va_arg(ap, struct wl_array *);
 			break;
+		case 'H':
 		case 'h':
 			args[i].h = va_arg(ap, int32_t);
 			break;
@@ -577,6 +580,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
 			if (!arg.nullable && args[i].a == NULL)
 				goto err_null;
 			break;
+		case 'H':
 		case 'h':
 			fd = args[i].h;
 			dup_fd = wl_os_dupfd_cloexec(fd, 0);
@@ -763,6 +767,7 @@ wl_connection_demarshal(struct wl_connection *connection,
 			closure->args[i].a = array_extra++;
 			p = next;
 			break;
+		case 'H':
 		case 'h':
 			if (connection->fds_in.tail == connection->fds_in.head) {
 				wl_log("file descriptor expected, "
@@ -907,6 +912,7 @@ convert_arguments_to_ffi(const char *signature, uint32_t flags,
 			ffi_types[i] = &ffi_type_pointer;
 			ffi_args[i] = &args[i].a;
 			break;
+		case 'H':
 		case 'h':
 			ffi_types[i] = &ffi_type_sint32;
 			ffi_args[i] = &args[i].h;
@@ -970,7 +976,7 @@ copy_fds_to_connection(struct wl_closure *closure,
 	count = arg_count_for_signature(signature);
 	for (i = 0; i < count; i++) {
 		signature = get_next_argument(signature, &arg);
-		if (arg.type != 'h')
+		if (arg.type != 'h' && arg.type != 'H')
 			continue;
 
 		fd = closure->args[i].h;
@@ -1000,6 +1006,7 @@ buffer_size_for_closure(struct wl_closure *closure)
 		signature = get_next_argument(signature, &arg);
 
 		switch (arg.type) {
+		case 'H':
 		case 'h':
 			break;
 		case 'u':
@@ -1056,7 +1063,7 @@ serialize_closure(struct wl_closure *closure, uint32_t *buffer,
 	for (i = 0; i < count; i++) {
 		signature = get_next_argument(signature, &arg);
 
-		if (arg.type == 'h')
+		if (arg.type == 'h' || arg.type == 'H')
 			continue;
 
 		if (p + 1 > end)
@@ -1239,6 +1246,7 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
 		case 'a':
 			fprintf(stderr, "array");
 			break;
+		case 'H':
 		case 'h':
 			fprintf(stderr, "fd %d", closure->args[i].h);
 			break;
diff --git a/src/scanner.c b/src/scanner.c
index d3e2328..9a74e93 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -180,7 +180,8 @@ enum arg_type {
 	STRING,
 	OBJECT,
 	ARRAY,
-	FD
+	FD,
+	FD_STATIC
 };
 
 struct arg {
@@ -436,6 +437,8 @@ set_arg_type(struct arg *arg, const char *type)
 		arg->type = ARRAY;
 	else if (strcmp(type, "fd") == 0)
 		arg->type = FD;
+	else if (strcmp(type, "fd_static") == 0)
+		arg->type = FD_STATIC;
 	else if (strcmp(type, "new_id") == 0)
 		arg->type = NEW_ID;
 	else if (strcmp(type, "object") == 0)
@@ -911,6 +914,7 @@ emit_type(struct arg *a)
 	switch (a->type) {
 	default:
 	case INT:
+	case FD_STATIC:
 	case FD:
 		printf("int32_t ");
 		break;
@@ -1538,6 +1542,9 @@ emit_messages(struct wl_list *message_list,
 			case FD:
 				printf("h");
 				break;
+			case FD_STATIC:
+				printf("H");
+				break;
 			}
 		}
 		printf("\", types + %d },\n", m->type_index);
-- 
2.7.0



More information about the wayland-devel mailing list