* sysdeps/mach/configure.in: Add some checks for Mach headers
authorRoland McGrath <roland@gnu.org>
Sun, 17 Feb 2002 07:19:11 +0000 (07:19 +0000)
committerRoland McGrath <roland@gnu.org>
Sun, 17 Feb 2002 07:19:11 +0000 (07:19 +0000)
to ensure a sane installation.
(mach_interface_list): Define this variable by checking for .defs
files found in various variants.
* configure.in (mach_interface_list): AC_SUBST this.
* config.make.in (mach-interface-list): New substituted variable.
* mach/Makefile (user-interfaces): Define this using the value
of $(mach-interface-list) instead of mach, mach4.
Updated other references to mach_interface to use it as well.

* sysdeps/mach/powerpc/machine-lock.h: Avoid multi-line strings.

* mach/msgserver.c [NDR_CHAR_ASCII] (mig_reply_header_t): #define as
mig_reply_error_t for OSF Mach variant.

* mach/Makefile (routines): Remove bootprivport.
* mach/bootprivport.c: File removed.  It has never been used.

* mach/msg-destroy.c (__mach_msg_destroy) [MACH_MSG_PORT_DESCRIPTOR]:
Grok the OSF flavor of message format.
(mach_msg_destroy_port): For MAKE_SEND and
MAKE_SEND_ONCE rights, create an destroy a right to ensure proper
no-senders notification.

2002-02-06  Roland McGrath  <roland@frob.com>

* hurd/Versions (libc: GLIBC_2.0): Move cthread_fork, cthread_detach
to here if 2.0 compatibility enabled ...
(libc: GLIBC_2.1.3): ... from here.

ChangeLog
config.make.in
configure.in
hurd/Versions
mach/msg-destroy.c
mach/msgserver.c
sysdeps/mach/configure.in
sysdeps/mach/powerpc/machine-lock.h

index 38c51ec841e9c8c94c9c48af08a1dd43a605a013..a096966126f2d3dabdfe9b265b6a049baf83909d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2002-02-16  Roland McGrath  <roland@frob.com>
+
+       * sysdeps/mach/configure.in: Add some checks for Mach headers
+       to ensure a sane installation.
+       (mach_interface_list): Define this variable by checking for .defs
+       files found in various variants.
+       * configure.in (mach_interface_list): AC_SUBST this.
+       * config.make.in (mach-interface-list): New substituted variable.
+       * mach/Makefile (user-interfaces): Define this using the value
+       of $(mach-interface-list) instead of mach, mach4.
+       Updated other references to mach_interface to use it as well.
+
+       * sysdeps/mach/powerpc/machine-lock.h: Avoid multi-line strings.
+
+       * mach/msgserver.c [NDR_CHAR_ASCII] (mig_reply_header_t): #define as
+       mig_reply_error_t for OSF Mach variant.
+
+       * mach/Makefile (routines): Remove bootprivport.
+       * mach/bootprivport.c: File removed.  It has never been used.
+
+       * mach/msg-destroy.c (__mach_msg_destroy) [MACH_MSG_PORT_DESCRIPTOR]:
+       Grok the OSF flavor of message format.
+       (mach_msg_destroy_port): For MAKE_SEND and
+       MAKE_SEND_ONCE rights, create an destroy a right to ensure proper
+       no-senders notification.
+
+2002-02-06  Roland McGrath  <roland@frob.com>
+
+       * hurd/Versions (libc: GLIBC_2.0): Move cthread_fork, cthread_detach
+       to here if 2.0 compatibility enabled ...
+       (libc: GLIBC_2.1.3): ... from here.
+
 2002-02-15  Ulrich Drepper  <drepper@redhat.com>
 
        * elf/dl-open.c (dl_open_worker): Catch wrap-around of TLS
index 7caf2a28635eb8d3634f1637eaedb00d6c66bba6..76048959c28898bcdfa942f2762b8e68d3b7b31e 100644 (file)
@@ -57,6 +57,8 @@ no-whole-archive = @no_whole_archive@
 exceptions = @exceptions@
 have_doors = @linux_doors@
 
+mach-interface-list = @mach_interface_list@
+
 have-bash2 = @libc_cv_have_bash2@
 have-ksh = @libc_cv_have_ksh@
 
index 5d9a52bda48a6c9d221ed2fca6fe27be23be865e..35464752975cd7e68560777b23d996efd3c700b4 100644 (file)
@@ -1658,6 +1658,9 @@ case "$add_ons" in
 esac
 AC_SUBST(linux_doors)
 
+dnl See sysdeps/mach/configure.in for this variable.
+AC_SUBST(mach_interface_list)
+
 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
   config_makefile=
 else
index bac36c75f96738c143db40f44d99aeec80d2a4a1..9b20923f8a435949d2fb7d57a7b320d7d5ffe90f 100644 (file)
@@ -22,6 +22,9 @@ libc {
     # cthreads functions with stubs in libc
     cthread_keycreate; cthread_getspecific; cthread_setspecific;
     __libc_getspecific;
+
+    # weak refs to libthreads functions that libc calls iff libthreads in use
+    cthread_fork; cthread_detach;
 %endif
 
     # necessary for the Hurd brk implementation
@@ -124,11 +127,6 @@ libc {
     seteuids;
   }
   GLIBC_2.1.3 {
-%if SHLIB_COMPAT (libc, GLIBC_2_1_3, HURD_CTHREADS_0_3)
-    # c*
-    cthread_fork; cthread_detach;
-%endif
-
     # d*
     directory_name_split;
 
index 1e618df0bfb549f8bce5f33dcb25314bdd07d87c..9ecbdc051209701e9dee1d68ab9dce75c69b19ac 100644 (file)
 /*
  * HISTORY
  * $Log$
+ * Revision 1.6  2002/02/17 07:13:36  roland
+ * 2002-02-16  Roland McGrath  <roland@frob.com>
+ *
+ *     * mach/msg-destroy.c (__mach_msg_destroy) [MACH_MSG_PORT_DESCRIPTOR]:
+ *     Grok the OSF flavor of message format.
+ *     (mach_msg_destroy_port): For MAKE_SEND and
+ *     MAKE_SEND_ONCE rights, create an destroy a right to ensure proper
+ *     no-senders notification.
+ *
  * Revision 1.5  1997/06/21 01:40:07  drepper
  * More 64bit changes.
  *
@@ -91,6 +100,69 @@ __mach_msg_destroy(msg)
     mach_msg_destroy_port(msg->msgh_remote_port, MACH_MSGH_BITS_REMOTE(mbits));
 
     if (mbits & MACH_MSGH_BITS_COMPLEX) {
+#ifdef MACH_MSG_PORT_DESCRIPTOR
+       mach_msg_body_t         *body;
+       mach_msg_descriptor_t   *saddr, *eaddr;
+
+       body = (mach_msg_body_t *) (msg + 1);
+       saddr = (mach_msg_descriptor_t *)
+                       ((mach_msg_base_t *) msg + 1);
+       eaddr =  saddr + body->msgh_descriptor_count;
+
+       for  ( ; saddr < eaddr; saddr++) {
+           switch (saddr->type.type) {
+
+               case MACH_MSG_PORT_DESCRIPTOR: {
+                   mach_msg_port_descriptor_t *dsc;
+
+                   /*
+                    * Destroy port rights carried in the message
+                    */
+                   dsc = &saddr->port;
+                   mach_msg_destroy_port(dsc->name, dsc->disposition);
+                   break;
+               }
+
+               case MACH_MSG_OOL_DESCRIPTOR : {
+                   mach_msg_ool_descriptor_t *dsc;
+
+                   /*
+                    * Destroy memory carried in the message
+                    */
+                   dsc = &saddr->out_of_line;
+                   if (dsc->deallocate) {
+                       mach_msg_destroy_memory((vm_offset_t)dsc->address,
+                                               dsc->size);
+                   }
+                   break;
+               }
+
+               case MACH_MSG_OOL_PORTS_DESCRIPTOR : {
+                   mach_port_t                         *ports;
+                   mach_msg_ool_ports_descriptor_t     *dsc;
+                   mach_msg_type_number_t              j;
+
+                   /*
+                    * Destroy port rights carried in the message
+                    */
+                   dsc = &saddr->ool_ports;
+                   ports = (mach_port_t *) dsc->address;
+                   for (j = 0; j < dsc->count; j++, ports++)  {
+                       mach_msg_destroy_port(*ports, dsc->disposition);
+                   }
+
+                   /*
+                    * Destroy memory carried in the message
+                    */
+                   if (dsc->deallocate) {
+                       mach_msg_destroy_memory((vm_offset_t)dsc->address,
+                                       dsc->count * sizeof(mach_port_t));
+                   }
+                   break;
+               }
+           }
+       }
+#else
        vm_offset_t saddr;
        vm_offset_t eaddr;
 
@@ -142,6 +214,7 @@ __mach_msg_destroy(msg)
                saddr += sizeof(vm_offset_t);
            }
        }
+#endif
     }
 }
 
@@ -153,15 +226,32 @@ mach_msg_destroy_port(port, type)
     mach_msg_type_name_t type;
 {
     if (MACH_PORT_VALID(port)) switch (type) {
-      case MACH_MSG_TYPE_PORT_SEND:
-      case MACH_MSG_TYPE_PORT_SEND_ONCE:
-       (void) __mach_port_deallocate(__mach_task_self(), port);
+      case MACH_MSG_TYPE_MOVE_SEND:
+      case MACH_MSG_TYPE_MOVE_SEND_ONCE:
+       /* destroy the send/send-once right */
+       (void) __mach_port_deallocate(mach_task_self(), port);
        break;
 
-      case MACH_MSG_TYPE_PORT_RECEIVE:
-       (void) __mach_port_mod_refs(__mach_task_self(), port,
+      case MACH_MSG_TYPE_MOVE_RECEIVE:
+       /* destroy the receive right */
+       (void) __mach_port_mod_refs(mach_task_self(), port,
                                    MACH_PORT_RIGHT_RECEIVE, -1);
        break;
+
+      case MACH_MSG_TYPE_MAKE_SEND:
+       /* create a send right and then destroy it */
+       (void) __mach_port_insert_right(mach_task_self(), port,
+                                       port, MACH_MSG_TYPE_MAKE_SEND);
+       (void) __mach_port_deallocate(mach_task_self(), port);
+       break;
+
+      case MACH_MSG_TYPE_MAKE_SEND_ONCE:
+       /* create a send-once right and then destroy it */
+       (void) __mach_port_extract_right(mach_task_self(), port,
+                                        MACH_MSG_TYPE_MAKE_SEND_ONCE,
+                                        &port, &type);
+       (void) __mach_port_deallocate(mach_task_self(), port);
+       break;
     }
 }
 
index d15f0c1ceef9d813e7303a8ae40da3866a747b18..6471877a78fe1c6f7fdc8944fc415e4986ae193d 100644 (file)
 /*
  * HISTORY
  * $Log$
+ * Revision 1.8  2002/02/17 07:13:32  roland
+ * 2002-02-16  Roland McGrath  <roland@frob.com>
+ *
+ *     * mach/msgserver.c [NDR_CHAR_ASCII] (mig_reply_header_t): #define as
+ *     mig_reply_error_t for OSF Mach variant.
+ *
  * Revision 1.7  2001/07/06 04:55:34  aj
  * Update to LGPL v2.1.
  *
 #include <stdlib.h>            /* For malloc and free.  */
 #include <assert.h>
 
+#ifdef NDR_CHAR_ASCII          /* OSF Mach flavors have different names.  */
+# define mig_reply_header_t    mig_reply_error_t
+#endif
+
 mach_msg_return_t
 __mach_msg_server_timeout (boolean_t (*demux) (mach_msg_header_t *request,
                                               mach_msg_header_t *reply),
index 2a76ead8edd52f8abb68f88d20f877b42d62329b..058a2a05c82b65589f52e1dc7346a616960e5b8e 100644 (file)
@@ -1,6 +1,11 @@
 sinclude(./aclocal.m4)dnl Autoconf lossage.
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 
+### Sanity checks for Mach header installation
+AC_CHECK_HEADER(mach/mach_types.h,, [AC_MSG_ERROR([cannot find Mach headers])])
+AC_CHECK_HEADER(mach/mach_types.defs,, [dnl
+AC_MSG_ERROR([cannot find Mach .defs files])])
+
 dnl
 dnl mach_TYPE_CHECK(foo_t, bar_t)
 dnl
@@ -21,6 +26,9 @@ dnl
 mach_TYPE_CHECK(task_t, task_port_t)
 mach_TYPE_CHECK(thread_t, thread_port_t)
 
+dnl
+dnl The creation_time field is a GNU Mach addition the other variants lack.
+dnl
 AC_CACHE_CHECK(for creation_time in task_basic_info,
               libc_cv_mach_task_creation_time, [dnl
 AC_TRY_COMPILE([#include <mach/task_info.h>], [
@@ -30,3 +38,24 @@ long s = i->creation_time.seconds;
 if test $libc_cv_mach_task_creation_time = no; then
   DEFINES="$DEFINES -DNO_CREATION_TIME=1"
 fi
+
+dnl
+dnl The Darwin variant no longer has <mach/mach.defs>
+dnl but instead has several constituent .defs files.
+dnl In this scenario we will presume there is a <mach/mach_interface.h>
+dnl that contains an #include for each constituent header file,
+dnl but we don't do a check for that here because in a bare
+dnl environment the compile against those headers will fail.
+dnl
+mach_interface_list=
+for ifc in mach mach4 \
+          clock_priv host_priv host_security ledger lock_set \
+          processor processor_set task thread_act vm_map \
+          memory_object memory_object_default default_pager \
+          ; do
+  AC_CHECK_HEADER(mach/${ifc}.defs, [dnl
+  mach_interface_list="$mach_interface_list $ifc"])
+done
+if test "x$mach_interface_list" = x; then
+  AC_MSG_ERROR([what manner of Mach is this?])
+fi
index 96e833ca155e42d30ccaa68b51469eb30b2f5737..cba6b0a6e254c11791c029a2eaa365eaa78d9f13 100644 (file)
@@ -1,5 +1,5 @@
 /* Machine-specific definition for spin locks.  PowerPC version.
-   Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1994,97,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -40,9 +40,9 @@ __spin_unlock (__spin_lock_t *__lock)
 {
   long int __locked;
   __asm__ __volatile__ ("\
-0:     lwarx   %0,0,%1
-       stwcx.  %2,0,%1
-       bne-    0b
+0:     lwarx   %0,0,%1\n\
+       stwcx.  %2,0,%1\n\
+       bne-    0b\n\
 " : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0");
 }
 
@@ -53,9 +53,9 @@ __spin_try_lock (register __spin_lock_t *__lock)
 {
   long int __rtn;
   __asm__ __volatile__ ("\
-0:     lwarx   %0,0,%1
-       stwcx.  %2,0,%1
-       bne-    0b
+0:     lwarx   %0,0,%1\n\
+       stwcx.  %2,0,%1\n\
+       bne-    0b\n\
 " : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0");
   return !__rtn;
 }
@@ -67,9 +67,9 @@ __spin_lock_locked (__spin_lock_t *__lock)
 {
   long int __rtn;
   __asm__ __volatile__ ("\
-0:     lwarx   %0,0,%1
-       stwcx.  %0,0,%1
-       bne-    0b
+0:     lwarx   %0,0,%1\n\
+       stwcx.  %0,0,%1\n\
+       bne-    0b\n\
 " : "=&r" (__rtn) : "r" (__lock) : "cr0");
   return __rtn;
 }