]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Cache the host port like we cache the task port
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Wed, 16 Sep 2015 17:41:14 +0000 (19:41 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 16 Sep 2015 17:41:36 +0000 (19:41 +0200)
This way we do not
need to call the kernel just to get the port.  Furthermore, we no
longer increase the reference count on every invocation of
`mach_host_self'.

* mach/mach/mach_traps.h (__mach_host_self, mach_host_self):
Protect declarations against the macro expansion.
* mach/mach_init.c (__mach_host_self_): New variable.
(mach_init): Initialize `__mach_host_self_'.
* mach/mach_init.h (__mach_host_self_): New declaration.
(__mach_host_self, mach_host_self): New macros.
* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start_cleanup):
Release reference.

ChangeLog
mach/mach/mach_traps.h
mach/mach_init.c
mach/mach_init.h
sysdeps/mach/hurd/dl-sysdep.c

index 32ec6f97c17da403af7d9b5db4e5f6c1d0941603..e9cc796862301a46086a232bcbe16a58d2eb7e04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2015-09-16  Justus Winter  <4winter@informatik.uni-hamburg.de>
+
+       Cache the host port like we cache the task port.  This way we do not
+       need to call the kernel just to get the port.  Furthermore, we no
+       longer increase the reference count on every invocation of
+       `mach_host_self'.
+
+       * mach/mach/mach_traps.h (__mach_host_self, mach_host_self):
+       Protect declarations against the macro expansion.
+       * mach/mach_init.c (__mach_host_self_): New variable.
+       (mach_init): Initialize `__mach_host_self_'.
+       * mach/mach_init.h (__mach_host_self_): New declaration.
+       (__mach_host_self, mach_host_self): New macros.
+       * sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start_cleanup):
+       Release reference.
+
 2015-09-16  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #4404]
index 53ec21e2d277726b4e4f1121fd654e5de56be21c..c778caa685dc90bccaf39535e1010cb52e2c5a16 100644 (file)
@@ -41,9 +41,10 @@ extern mach_port_t __mach_thread_self (void);
 extern mach_port_t (mach_task_self) (void);
 extern mach_port_t (__mach_task_self) (void);
 
-/* Return the host information port for the host of the calling task.  */
-extern mach_port_t mach_host_self (void);
-extern mach_port_t __mach_host_self (void);
+/* Return the host information port for the host of the calling task.
+   The parens are needed to protect against the macro in <mach_init.h>.  */
+extern mach_port_t (mach_host_self) (void);
+extern mach_port_t (__mach_host_self) (void);
 
 /* Attempt to context switch the current thread off the processor.  Returns
    true if there are other threads that can be run and false if not.  */
index cf8ac3bb318b057a533f52e9fdde9e771d4b36e5..8acb71f7e96fc9939260c9f11bda7766c818685f 100644 (file)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 mach_port_t __mach_task_self_;
+mach_port_t __mach_host_self_;
 vm_size_t __vm_page_size = 0;  /* Must be data not bss for weak alias.  */
 weak_alias (__vm_page_size, vm_page_size)
 
@@ -34,6 +35,7 @@ __mach_init (void)
   kern_return_t err;
 
   __mach_task_self_ = (__mach_task_self) ();
+  __mach_host_self_ = (__mach_host_self) ();
   __mig_init (0);
 
 #ifdef HAVE_HOST_PAGE_SIZE
index 44a7ce2c5066da8e5da9790d478e3944ea921175..26b2639fd8080ca3a6714c74ffabb5c9dc4d9d3b 100644 (file)
@@ -31,6 +31,11 @@ extern mach_port_t __mach_task_self_;
 #define __mach_task_self()     (__mach_task_self_ + 0) /* Not an lvalue.  */
 #define mach_task_self()       (__mach_task_self ())
 
+/* This cache is initialized at startup.  */
+extern mach_port_t __mach_host_self_;
+#define __mach_host_self()     (__mach_host_self_ + 0) /* Not an lvalue.  */
+#define mach_host_self()       (__mach_host_self ())
+
 /* Kernel page size.  */
 extern vm_size_t __vm_page_size;
 extern vm_size_t vm_page_size;
index 8bb9fad090db910b3b51f6f48acd14f0915289e2..317605b42579cb4a9c4e1b6323c12ab0d2f5900c 100644 (file)
@@ -279,6 +279,7 @@ _dl_sysdep_start_cleanup (void)
      __mach_init.  We are done with them now, and the user will
      reacquire them for himself when he wants them.  */
   __mig_dealloc_reply_port (MACH_PORT_NULL);
+  __mach_port_deallocate (__mach_task_self (), __mach_host_self_);
   __mach_port_deallocate (__mach_task_self (), __mach_task_self_);
 }
 \f