From patchwork Wed Jul 31 02:18:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Cruz X-Patchwork-Id: 94833 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D00053861030 for ; Wed, 31 Jul 2024 02:19:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) by sourceware.org (Postfix) with ESMTPS id 5CB333860C3E for ; Wed, 31 Jul 2024 02:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5CB333860C3E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5CB333860C3E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722392324; cv=none; b=W3BKp9Dg1QGiA61+MlloJsIgge/nE83RwCGrwdeCXWh17/QYoHd+t0oqT9/1gYrEk0Dd3p/+CjlMNabwGKZXnOFnY7lZkNxk4msz0cGuAASZimHjTK9W9BNpMnUEEqa8SqkEgooT7MRWndzLMgfHltl+6Qr0dAFyUBZEnN+85So= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722392324; c=relaxed/simple; bh=GPlXt5D0rsdXgVTmbKVyDCI9wMwL2gjLZpugswTdyuA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=g6FernjD4dg2ig20qF4kPj6W1OcY+1iie6ZrEgkKLLGeMoSbz1X+k+bG1wZzHrXW4u9j89lIAVmcvTczMy33KdLWOiYO0VD5qDwGl78l7XEuA5EmXw4kzQP+R+cUCoDlC35ahT+pBM5IOPivnJx+xh0/6NdNc9yQCl9xJ9Q8lFw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa2c.google.com with SMTP id 71dfb90a1353d-4f6ac1628dfso1852588e0c.0 for ; Tue, 30 Jul 2024 19:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722392321; x=1722997121; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Hp96gQeenyO0HvCvKWbkHxIrjssRfMqkGS/m163JX5g=; b=AMhr9F0/nv1jFBLRqCWQJOtGH0JOHtp9jXUEDpBJEBIQyNfk5LCGpvKq1/M5HKf6bC y9W/GtCrEIn+Ny+2pcZD2DptmoYTTqxmqSYXM7xDJMc19KJ0WLV2egpeFw5Slci4Czpl ieGtrvpTfO+ynb80dSc5HCiKh9AFW1zMamOl1PtHmvfkLz05fyuSiOkzvdNDz76ac4fj YN2ibnIYUXOvs6FraELPKtHIPVLedhdileobOuorD7K6YI5p3Mc6YSgCL6wx71kYds5N kc8Nr3WY22KoMMIzigIRz39R05RT5Ivb7CwGvwtJDMcxQv5ljjTb06rk+fskJDaNLcCz tQEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722392321; x=1722997121; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hp96gQeenyO0HvCvKWbkHxIrjssRfMqkGS/m163JX5g=; b=BoUSbuPUEbj0RYylCbFUXEr8LwpI9/2kB4qf6iMie1uNWrPd1EnkX1qtYvhfJJz/Hv oCPhwZQBJfaek7qkBrNWP31mwo6DtXQhXRnlhU26IklG/QJDUggOxvMAEVzNnw+DmHTj nUPA4fSddtedPOs5FVXzAWF5mvdd5sWcutcLRfZUjZp+2OuZZsWzVdrsJvcIeV0czJ6A gho++s9WgvFLuV+Z1GfnGvd1jBoY9zeyRpVx99Lo+ky4ImYU0YfgoSylYYRbjtXhIH7W h/J7m++F9sNU399jgn/8elLlUfcq17J/yr9ImH6BBM3TH6BjqR/za36Q2HOHTDTwp3oK 3nwg== X-Forwarded-Encrypted: i=1; AJvYcCVRN4aGWRVabxL+Norc/1Cx80SUZ/DteQmjYL8f0uXW3RvFinIXqmAz/NZv4OzrOY19t4ns4q4PP4JRqVU0QCDlt8kdHwfBLNxt X-Gm-Message-State: AOJu0Yy3ThoJ4fSFsmLdI4yGAWe6NNTNfhXbdtOpgsBc6mbHnMA0N5Ys EOoKiRiDc5XaJPxXL2FYOqc3uWkP9iocEziq4eYPj9m2MMy4d74= X-Google-Smtp-Source: AGHT+IE6AiUA1bBlq0c+CZ17gwII83QSFPL9khLKANTD3S1ieFNHpOMUygatSuw57T/mLr70JZT9fw== X-Received: by 2002:a05:6122:3b01:b0:4eb:5d5d:6add with SMTP id 71dfb90a1353d-4f6e699aee9mr13343461e0c.13.1722392321378; Tue, 30 Jul 2024 19:18:41 -0700 (PDT) Received: from localhost (dynamic-acs-24-154-253-225.zoominternet.net. [24.154.253.225]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d73b1786sm703563285a.33.2024.07.30.19.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 19:18:40 -0700 (PDT) Date: Tue, 30 Jul 2024 22:18:38 -0400 From: Flavio Cruz To: bug-hurd , libc-alpha Subject: [PATCH] Remove the remaining untyped mach message handling Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Some leftovers from 6ae7b5f43d4b13f24606d7108d822e469a96af3d --- hurd/hurdselect.c | 23 ------------------- hurd/intr-msg.c | 4 ---- sysdeps/mach/hurd/ioctl.c | 48 --------------------------------------- 3 files changed, 75 deletions(-) diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c index 1fb67f41f3..939bf696a6 100644 --- a/hurd/hurdselect.c +++ b/hurd/hurdselect.c @@ -371,22 +371,6 @@ _hurd_select (int nfds, union { mach_msg_header_t head; -#ifdef MACH_MSG_TRAILER_MINIMUM_SIZE - struct - { - mach_msg_header_t head; - NDR_record_t ndr; - error_t err; - } error; - struct - { - mach_msg_header_t head; - NDR_record_t ndr; - error_t err; - int result; - mach_msg_trailer_t trailer; - } success; -#else struct { mach_msg_header_t head; @@ -401,7 +385,6 @@ _hurd_select (int nfds, mach_msg_type_t result_type; int result; } success; -#endif } msg; mach_msg_option_t options; error_t msgerr; @@ -428,7 +411,6 @@ _hurd_select (int nfds, LIBC_CANCEL_RESET (cancel_oldtype); /* We got a message. Decode it. */ -#ifdef MACH_MSG_TYPE_BIT static const mach_msg_type_t inttype = { .msgt_name = MACH_MSG_TYPE_INTEGER_T, .msgt_size = sizeof (integer_t) * 8, @@ -438,7 +420,6 @@ _hurd_select (int nfds, .msgt_deallocate = FALSE, .msgt_unused = 0 }; -#endif if (sigport != MACH_PORT_NULL && sigport == msg.head.msgh_local_port) { @@ -452,9 +433,7 @@ _hurd_select (int nfds, if (msg.head.msgh_id == reply_msgid && msg.head.msgh_size >= sizeof msg.error && !(msg.head.msgh_bits & MACH_MSGH_BITS_COMPLEX) -#ifdef MACH_MSG_TYPE_BIT && !BAD_TYPECHECK (&msg.error.err_type, &inttype) -#endif ) { /* This is a properly formatted message so far. @@ -470,9 +449,7 @@ _hurd_select (int nfds, /* Keep in mind msg.success.result can be 0 if a timeout occurred. */ if (msg.error.err -#ifdef MACH_MSG_TYPE_BIT || BAD_TYPECHECK (&msg.success.result_type, &inttype) -#endif || msg.head.msgh_size != sizeof msg.success) { /* Error or bogus reply. */ diff --git a/hurd/intr-msg.c b/hurd/intr-msg.c index 424c1fc700..bf402a99f2 100644 --- a/hurd/intr-msg.c +++ b/hurd/intr-msg.c @@ -317,7 +317,6 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg, case MACH_MSG_SUCCESS: { /* We got a reply. Was it EINTR? */ -#ifdef MACH_MSG_TYPE_BIT static const mach_msg_type_t type_check = { .msgt_name = MACH_MSG_TYPE_INTEGER_T, .msgt_size = sizeof (integer_t) * 8, @@ -327,13 +326,10 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg, .msgt_deallocate = FALSE, .msgt_unused = 0 }; -#endif if (m->reply.RetCode == EINTR && m->header.msgh_size == sizeof m->reply -#ifdef MACH_MSG_TYPE_BIT && !BAD_TYPECHECK(&m->check.type, &type_check) -#endif && !(m->header.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { /* It is indeed EINTR. Is the interrupt for us? */ diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c index 424423cbed..b2b4f60538 100644 --- a/sysdeps/mach/hurd/ioctl.c +++ b/sysdeps/mach/hurd/ioctl.c @@ -41,7 +41,6 @@ int __ioctl (int fd, unsigned long int request, ...) { -#ifdef MACH_MSG_TYPE_BIT /* Map individual type fields to Mach IPC types. */ static const int mach_types[] = { MACH_MSG_TYPE_CHAR, MACH_MSG_TYPE_INTEGER_16, MACH_MSG_TYPE_INTEGER_32, @@ -56,7 +55,6 @@ __ioctl (int fd, unsigned long int request, ...) .msgt_deallocate = FALSE, \ .msgt_unused = 0 \ }) -#endif /* Extract the type information encoded in the request. */ unsigned int type = _IOC_TYPE (request); @@ -64,7 +62,6 @@ __ioctl (int fd, unsigned long int request, ...) /* Message buffer. */ struct { -#ifdef MACH_MSG_TYPE_BIT union { mig_reply_header_t header; @@ -79,22 +76,11 @@ __ioctl (int fd, unsigned long int request, ...) + msg_align (_IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type))) + msg_align (_IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type))) + msg_align (_IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type)))]; -#else /* Untyped Mach IPC format. */ - mig_reply_error_t header; - char data[_IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type)) - + _IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type)) - + _IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type))]; - mach_msg_trailer_t trailer; -#endif } msg; mach_msg_header_t *const m = &msg.header.Head; mach_msg_id_t msgid; unsigned int reply_size; -#ifdef MACH_MSG_TYPE_BIT mach_msg_type_t *t; -#else - void *p; -#endif void *arg = NULL; @@ -105,11 +91,7 @@ __ioctl (int fd, unsigned long int request, ...) error_t send_rpc (io_t ioport) { error_t err; -#ifdef MACH_MSG_TYPE_BIT mach_msg_type_t *t = &msg.header.RetCodeType; -#else - void *p = &msg.header.RetCode; -#endif /* Marshal the request arguments into the message buffer. We must redo this work each time we retry the RPC after a SIGTTOU, @@ -132,15 +114,11 @@ __ioctl (int fd, unsigned long int request, ...) if (count > 0) { const size_t len = count * typesize ((unsigned int) type); -#ifdef MACH_MSG_TYPE_BIT void *p = &t[1]; *t = io2mach_type (count, type); p = __mempcpy (p, argptr, len); p = (void *) msg_align ((uintptr_t) p); t = p; -#else - p = __mempcpy (p, argptr, len); -#endif argptr += len; } } @@ -154,23 +132,14 @@ __ioctl (int fd, unsigned long int request, ...) { /* The RPC takes a single integer_t argument. Rather than pointing to the value, ARG is the value itself. */ -#ifdef MACH_MSG_TYPE_BIT *t++ = io2mach_type (1, _IOTS (integer_t)); *(integer_t *) t = (integer_t) (intptr_t) arg; t = (void *) msg_align ((uintptr_t) t + sizeof (integer_t)); -#else - *(integer_t *) p = (integer_t) (intptr_t) arg; - p = (void *) p + sizeof (integer_t); -#endif } memset (m, 0, sizeof *m); /* Clear unused fields. */ m->msgh_size = ( -#ifdef MACH_MSG_TYPE_BIT (char *) t -#else - (char *) p -#endif - (char *) &msg); m->msgh_remote_port = ioport; m->msgh_local_port = __mig_get_reply_port (); @@ -211,11 +180,9 @@ __ioctl (int fd, unsigned long int request, ...) && m->msgh_size != sizeof msg.header) return MIG_TYPE_ERROR; -#ifdef MACH_MSG_TYPE_BIT mach_msg_type_t ipctype = io2mach_type(1, _IOTS (msg.header.RetCode)); if (BAD_TYPECHECK (&msg.header_typecheck.RetCodeType, &ipctype)) return MIG_TYPE_ERROR; -#endif return msg.header.RetCode; } @@ -261,14 +228,10 @@ __ioctl (int fd, unsigned long int request, ...) { if (count > 0) { -#ifdef MACH_MSG_TYPE_BIT /* Add the size of the type and data. */ reply_size += sizeof (mach_msg_type_t) + typesize (type) * count; /* Align it to word size. */ reply_size = msg_align (reply_size); -#else - reply_size += typesize (type) * count; -#endif } } figure_reply (_IOT_COUNT0 (type), _IOT_TYPE0 (type)); @@ -289,11 +252,7 @@ __ioctl (int fd, unsigned long int request, ...) else err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc)); -#ifdef MACH_MSG_TYPE_BIT t = (mach_msg_type_t *) msg.data; -#else - p = (void *) msg.data; -#endif switch (err) { /* Unpack the message buffer into the argument location. */ @@ -303,7 +262,6 @@ __ioctl (int fd, unsigned long int request, ...) if (count > 0) { const size_t len = count * typesize (type); -#ifdef MACH_MSG_TYPE_BIT const mach_msg_type_t ipctype = io2mach_type(count, type); if (BAD_TYPECHECK (t, &ipctype)) return 1; @@ -312,12 +270,6 @@ __ioctl (int fd, unsigned long int request, ...) if (update != NULL) *update += len; t = (mach_msg_type_t *) msg_align ((uintptr_t) t + len); -#else - memcpy (store, p, len); - p += len; - if (update != NULL) - *update += len; -#endif } return 0; }