diff mbox series

Remove the remaining untyped mach message handling

Message ID imhy2fyjmibtiuuhag5ucyiue72qnkxg2epclk3vm4ndy46s7x@by2phxk734h7
State New
Headers show
Series Remove the remaining untyped mach message handling | expand

Commit Message

Flavio Cruz July 31, 2024, 2:18 a.m. UTC
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 mbox series

Patch

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;
 	}