aboutsummaryrefslogtreecommitdiff
path: root/libports
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2012-09-04 00:33:09 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-11-27 22:58:15 +0100
commit1de0643c9218db536f5b2e294bbfa653c77438e4 (patch)
treef944e1b023cf0353ca559d22e1f7b701bac04c97 /libports
parent7648503cd894549874ff13f7ed94a4708cf50f0d (diff)
downloadhurd-1de0643c9218db536f5b2e294bbfa653c77438e4.tar.gz
hurd-1de0643c9218db536f5b2e294bbfa653c77438e4.tar.bz2
hurd-1de0643c9218db536f5b2e294bbfa653c77438e4.zip
Switch from cthreads to pthreads
Makefiles, headers, types, macros and function calls are renamed where appropriate. Most of this work was done by Barry deFreese and Thomas DiModica. * auth/Makefile: Switch from cthreads to pthreads. * auth/auth.c: Likewise. * boot/Makefile: Likewise. * boot/boot.c: Likewise. * boot/ux.c: Likewise. * console-client/Makefile: Likewise. * console-client/console.c: Likewise. * console-client/driver.c: Likewise. * console-client/driver.h: Likewise. * console-client/generic-speaker.c: Likewise. * console-client/kbd-repeat.c: Likewise. * console-client/ncursesw.c: Likewise. * console-client/pc-kbd.c: Likewise. * console-client/pc-mouse.c: Likewise. * console-client/timer.c: Likewise. * console-client/trans.c: Likewise. * console-client/vga.c: Likewise. * console/Makefile: Likewise. * console/console.c: Likewise. * console/display.c: Likewise. * console/input.c: Likewise. * console/pager.c: Likewise. * defpager/backing.c: Likewise. * exec/Makefile: Likewise. * exec/exec.c: Likewise. * exec/hashexec.c: Likewise. * exec/priv.h: Likewise. * ext2fs/Makefile: Likewise. * ext2fs/balloc.c: Likewise. * ext2fs/dir.c: Likewise. * ext2fs/ext2fs.c: Likewise. * ext2fs/ext2fs.h: Likewise. * ext2fs/ialloc.c: Likewise. * ext2fs/inode.c: Likewise. * ext2fs/msg.c: Likewise. * ext2fs/pager.c: Likewise. * ext2fs/pokel.c: Likewise. * ext2fs/storeinfo.c: Likewise. * ext2fs/truncate.c: Likewise. * fatfs/Makefile: Likewise. * fatfs/dir.c: Likewise. * fatfs/fat.c: Likewise. * fatfs/fatfs.h: Likewise. * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. * fatfs/pager.c: Likewise. * fatfs/virt-inode.c: Likewise. * ftpfs/Makefile: Likewise. * ftpfs/ccache.c: Likewise. * ftpfs/ccache.h: Likewise. * ftpfs/conn.c: Likewise. * ftpfs/dir.c: Likewise. * ftpfs/fs.c: Likewise. * ftpfs/ftpfs.c: Likewise. * ftpfs/ftpfs.h: Likewise. * ftpfs/ncache.c: Likewise. * ftpfs/netfs.c: Likewise. * ftpfs/node.c: Likewise. * hostmux/Makefile: Likewise. * hostmux/hostmux.h: Likewise. * hostmux/mux.c: Likewise. * hostmux/node.c: Likewise. * hostmux/stubs.c: Likewise. * hurd/shared.h: Likewise. * isofs/Makefile: Likewise. * isofs/inode.c: Likewise. * isofs/lookup.c: Likewise. * isofs/main.c: Likewise. * isofs/pager.c: Likewise. * libcons/Makefile: Likewise. * libcons/cons-switch.c: Likewise. * libcons/cons.h: Likewise. * libcons/dir-changed.c: Likewise. * libcons/file-changed.c: Likewise. * libcons/init-init.c: Likewise. * libcons/vcons-close.c: Likewise. * libcons/vcons-input.c: Likewise. * libcons/vcons-move-mouse.c: Likewise. * libcons/vcons-open.c: Likewise. * libcons/vcons-scrollback.c: Likewise. * libdiskfs/Makefile: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/dead-name.c: Likewise. * libdiskfs/dir-chg.c: Likewise. * libdiskfs/dir-link.c: Likewise. * libdiskfs/dir-lookup.c: Likewise. * libdiskfs/dir-mkdir.c: Likewise. * libdiskfs/dir-mkfile.c: Likewise. * libdiskfs/dir-readdir.c: Likewise. * libdiskfs/dir-rename.c: Likewise. * libdiskfs/dir-renamed.c: Likewise. * libdiskfs/dir-rmdir.c: Likewise. * libdiskfs/dir-unlink.c: Likewise. * libdiskfs/disk-pager.c: Likewise. * libdiskfs/diskfs-pager.h: Likewise. * libdiskfs/diskfs.h: Likewise. * libdiskfs/file-access.c: Likewise. * libdiskfs/file-chg.c: Likewise. * libdiskfs/file-exec.c: Likewise. * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/file-get-trans.c: Likewise. * libdiskfs/file-get-transcntl.c: Likewise. * libdiskfs/file-getcontrol.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-lock-stat.c: Likewise. * libdiskfs/file-lock.c: Likewise. * libdiskfs/file-reparent.c: Likewise. * libdiskfs/file-set-trans.c: Likewise. * libdiskfs/file-sync.c: Likewise. * libdiskfs/file-syncfs.c: Likewise. * libdiskfs/fsys-getroot.c: Likewise. * libdiskfs/fsys-options.c: Likewise. * libdiskfs/fsys-syncfs.c: Likewise. * libdiskfs/ifsock.c: Likewise. * libdiskfs/init-first.c: Likewise. * libdiskfs/init-init.c: Likewise. * libdiskfs/init-startup.c: Likewise. * libdiskfs/io-duplicate.c: Likewise. * libdiskfs/io-get-conch.c: Likewise. * libdiskfs/io-identity.c: Likewise. * libdiskfs/io-map-cntl.c: Likewise. * libdiskfs/io-map.c: Likewise. * libdiskfs/io-modes-get.c: Likewise. * libdiskfs/io-modes-off.c: Likewise. * libdiskfs/io-modes-on.c: Likewise. * libdiskfs/io-modes-set.c: Likewise. * libdiskfs/io-owner-get.c: Likewise. * libdiskfs/io-owner-mod.c: Likewise. * libdiskfs/io-prenotify.c: Likewise. * libdiskfs/io-read.c: Likewise. * libdiskfs/io-readable.c: Likewise. * libdiskfs/io-reauthenticate.c: Likewise. * libdiskfs/io-rel-conch.c: Likewise. * libdiskfs/io-restrict-auth.c: Likewise. * libdiskfs/io-revoke.c: Likewise. * libdiskfs/io-seek.c: Likewise. * libdiskfs/io-sigio.c: Likewise. * libdiskfs/io-stat.c: Likewise. * libdiskfs/io-write.c: Likewise. * libdiskfs/lookup.c: Likewise. * libdiskfs/name-cache.c: Likewise. * libdiskfs/node-drop.c: Likewise. * libdiskfs/node-make.c: Likewise. * libdiskfs/node-nput.c: Likewise. * libdiskfs/node-nputl.c: Likewise. * libdiskfs/node-nref.c: Likewise. * libdiskfs/node-nrefl.c: Likewise. * libdiskfs/node-nrele.c: Likewise. * libdiskfs/node-nrelel.c: Likewise. * libdiskfs/peropen-rele.c: Likewise. * libdiskfs/priv.h: Likewise. * libdiskfs/shutdown.c: Likewise. * libdiskfs/sync-interval.c: Likewise. * libfshelp/Makefile: Likewise. * libfshelp/fetch-root.c: Likewise. * libfshelp/fshelp.h: Likewise. * libfshelp/get-identity.c: Likewise. * libfshelp/lock-acquire.c: Likewise. * libfshelp/lock-init.c: Likewise. * libfshelp/locks.h: Likewise. * libfshelp/set-active.c: Likewise. * libfshelp/trans.h: Likewise. * libfshelp/transbox-init.c: Likewise. * libiohelp/Makefile: Likewise. * libiohelp/get_conch.c: Likewise. * libiohelp/handle_io_release_conch.c: Likewise. * libiohelp/initialize_conch.c: Likewise. * libiohelp/iohelp.h: Likewise. * libiohelp/verify_user_conch.c: Likewise. * libnetfs/Makefile: Likewise. * libnetfs/dir-lookup.c: Likewise. * libnetfs/dir-mkdir.c: Likewise. * libnetfs/dir-mkfile.c: Likewise. * libnetfs/dir-readdir.c: Likewise. * libnetfs/dir-rmdir.c: Likewise. * libnetfs/dir-unlink.c: Likewise. * libnetfs/drop-node.c: Likewise. * libnetfs/file-chauthor.c: Likewise. * libnetfs/file-check-access.c: Likewise. * libnetfs/file-chflags.c: Likewise. * libnetfs/file-chmod.c: Likewise. * libnetfs/file-chown.c: Likewise. * libnetfs/file-exec.c: Likewise. * libnetfs/file-get-storage-info.c: Likewise. * libnetfs/file-get-translator.c: Likewise. * libnetfs/file-lock-stat.c: Likewise. * libnetfs/file-lock.c: Likewise. * libnetfs/file-reparent.c: Likewise. * libnetfs/file-set-size.c: Likewise. * libnetfs/file-set-translator.c: Likewise. * libnetfs/file-statfs.c: Likewise. * libnetfs/file-sync.c: Likewise. * libnetfs/file-syncfs.c: Likewise. * libnetfs/file-utimes.c: Likewise. * libnetfs/fsys-getroot.c: Likewise. * libnetfs/fsys-set-options.c: Likewise. * libnetfs/init-init.c: Likewise. * libnetfs/io-clear-some-openmodes.c: Likewise. * libnetfs/io-duplicate.c: Likewise. * libnetfs/io-get-openmodes.c: Likewise. * libnetfs/io-get-owner.c: Likewise. * libnetfs/io-identity.c: Likewise. * libnetfs/io-mod-owner.c: Likewise. * libnetfs/io-read.c: Likewise. * libnetfs/io-readable.c: Likewise. * libnetfs/io-reauthenticate.c: Likewise. * libnetfs/io-restrict-auth.c: Likewise. * libnetfs/io-revoke.c: Likewise. * libnetfs/io-seek.c: Likewise. * libnetfs/io-set-all-openmodes.c: Likewise. * libnetfs/io-set-some-openmodes.c: Likewise. * libnetfs/io-stat.c: Likewise. * libnetfs/io-write.c: Likewise. * libnetfs/make-node.c: Likewise. * libnetfs/netfs.h: Likewise. * libnetfs/nput.c: Likewise. * libnetfs/nref.c: Likewise. * libnetfs/nrele.c: Likewise. * libnetfs/release-peropen.c: Likewise. * libnetfs/shutdown.c: Likewise. * libpager/Makefile: Likewise. * libpager/chg-compl.c: Likewise. * libpager/clean.c: Likewise. * libpager/data-request.c: Likewise. * libpager/data-return.c: Likewise. * libpager/data-unlock.c: Likewise. * libpager/inhibit-term.c: Likewise. * libpager/lock-completed.c: Likewise. * libpager/lock-object.c: Likewise. * libpager/mark-error.c: Likewise. * libpager/no-senders.c: Likewise. * libpager/object-init.c: Likewise. * libpager/object-terminate.c: Likewise. * libpager/offer-page.c: Likewise. * libpager/pager-attr.c: Likewise. * libpager/pager-create.c: Likewise. * libpager/pager-shutdown.c: Likewise. * libpager/priv.h: Likewise. * libpager/seqnos.c: Likewise. * libpipe/Makefile: Likewise. * libpipe/pipe.c: Likewise. * libpipe/pipe.h: Likewise. * libports/Makefile: Likewise. * libports/begin-rpc.c: Likewise. * libports/bucket-iterate.c: Likewise. * libports/claim-right.c: Likewise. * libports/class-iterate.c: Likewise. * libports/complete-deallocate.c: Likewise. * libports/count-bucket.c: Likewise. * libports/count-class.c: Likewise. * libports/create-bucket.c: Likewise. * libports/create-internal.c: Likewise. * libports/destroy-right.c: Likewise. * libports/enable-bucket.c: Likewise. * libports/enable-class.c: Likewise. * libports/end-rpc.c: Likewise. * libports/get-right.c: Likewise. * libports/import-port.c: Likewise. * libports/inhibit-all-rpcs.c: Likewise. * libports/inhibit-bucket-rpcs.c: Likewise. * libports/inhibit-class-rpcs.c: Likewise. * libports/inhibit-port-rpcs.c: Likewise. * libports/init.c: Likewise. * libports/interrupt-notified-rpcs.c: Likewise. * libports/interrupt-on-notify.c: Likewise. * libports/interrupt-operation.c: Likewise. * libports/interrupt-rpcs.c: Likewise. * libports/interrupted.c: Likewise. * libports/lookup-port.c: Likewise. * libports/manage-multithread.c: Likewise. * libports/no-senders.c: Likewise. * libports/port-deref-weak.c: Likewise. * libports/port-deref.c: Likewise. * libports/port-ref-weak.c: Likewise. * libports/port-ref.c: Likewise. * libports/ports.h: Likewise. * libports/reallocate-from-external.c: Likewise. * libports/reallocate-port.c: Likewise. * libports/resume-all-rpcs.c: Likewise. * libports/resume-bucket-rpcs.c: Likewise. * libports/resume-class-rpcs.c: Likewise. * libports/resume-port-rpcs.c: Likewise. * libports/stubs.c: Likewise. * libports/transfer-right.c: Likewise. * libstore/Makefile: Likewise. * libstore/gunzip.c: Likewise. * libstore/part.c: Likewise. * libstore/unzipstore.c: Likewise. * libthreads/Makefile: Likewise. * libtreefs/dir-lookup.c: Likewise. * libtreefs/fsys-getroot.c: Likewise. * libtreefs/fsys-hooks.c: Likewise. * libtreefs/fsys.c: Likewise. * libtreefs/trans-help.c: Likewise. * libtreefs/trans-start.c: Likewise. * libtreefs/treefs.h: Likewise. * libtrivfs/cntl-create.c: Likewise. * libtrivfs/dyn-classes.c: Likewise. * libtrivfs/io-reauthenticate.c: Likewise. * libtrivfs/io-restrict-auth.c: Likewise. * libtrivfs/protid-clean.c: Likewise. * libtrivfs/protid-dup.c: Likewise. * libtrivfs/trivfs.h: Likewise. * mach-defpager/Makefile: Likewise. * mach-defpager/default_pager.c: Likewise. * mach-defpager/kalloc.c: Likewise. * mach-defpager/main.c: Likewise. * nfs/Makefile: Likewise. * nfs/cache.c: Likewise. * nfs/main.c: Likewise. * nfs/mount.c: Likewise. * nfs/name-cache.c: Likewise. * nfs/nfs.h: Likewise. * nfs/ops.c: Likewise. * nfs/rpc.c: Likewise. * nfsd/Makefile: Likewise. * nfsd/cache.c: Likewise. * nfsd/loop.c: Likewise. * nfsd/main.c: Likewise. * nfsd/nfsd.h: Likewise. * pfinet/Makefile: Likewise. * pfinet/ethernet.c: Likewise. * pfinet/glue-include/asm/spinlock.h: Likewise. * pfinet/glue-include/linux/interrupt.h: Likewise. * pfinet/glue-include/linux/sched.h: Likewise. * pfinet/glue-include/linux/timer.h: Likewise. * pfinet/glue-include/linux/wait.h: Likewise. * pfinet/iioctl-ops.c: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/kmem_cache.c: Likewise. * pfinet/main.c: Likewise. * pfinet/options.c: Likewise. * pfinet/pfinet-ops.c: Likewise. * pfinet/pfinet.h: Likewise. * pfinet/sched.c: Likewise. * pfinet/socket-ops.c: Likewise. * pfinet/socket.c: Likewise. * pfinet/timer-emul.c: Likewise. * pfinet/tunnel.c: Likewise. * pflocal/Makefile: Likewise. * pflocal/connq.c: Likewise. * pflocal/io.c: Likewise. * pflocal/sock.c: Likewise. * pflocal/sock.h: Likewise. * pflocal/socket.c: Likewise. * pflocal/sserver.c: Likewise. * proc/Makefile: Likewise. * proc/info.c: Likewise. * proc/main.c: Likewise. * proc/mgt.c: Likewise. * proc/msg.c: Likewise. * proc/proc.h: Likewise. * proc/stubs.c: Likewise. * proc/wait.c: Likewise. * storeio/Makefile: Likewise. * storeio/dev.c: Likewise. * storeio/dev.h: Likewise. * storeio/open.c: Likewise. * storeio/open.h: Likewise. * storeio/pager.c: Likewise. * storeio/storeio.c: Likewise. * term/Makefile: Likewise. * term/devio.c: Likewise. * term/hurdio.c: Likewise. * term/main.c: Likewise. * term/munge.c: Likewise. * term/ptyio.c: Likewise. * term/term.h: Likewise. * term/users.c: Likewise. * tmpfs/Makefile: Likewise. * tmpfs/dir.c: Likewise. * tmpfs/node.c: Likewise. * tmpfs/tmpfs.c: Likewise. * tmpfs/tmpfs.h: Likewise. * trans/Makefile: Likewise. * trans/fakeroot.c: Likewise. * trans/fifo.c: Likewise. * trans/hello-mt.c: Likewise. * trans/new-fifo.c: Likewise. * trans/streamio.c: Likewise. * ufs/Makefile: Likewise. * ufs/alloc.c: Likewise. * ufs/dir.c: Likewise. * ufs/hyper.c: Likewise. * ufs/inode.c: Likewise. * ufs/main.c: Likewise. * ufs/pager.c: Likewise. * ufs/pokeloc.c: Likewise. * ufs/sizes.c: Likewise. * ufs/ufs.h: Likewise. * usermux/Makefile: Likewise. * usermux/mux.c: Likewise. * usermux/node.c: Likewise. * usermux/usermux.h: Likewise. * utils/Makefile: Likewise. * utils/fakeauth.c: Likewise. * utils/rpctrace.c: Likewise.
Diffstat (limited to 'libports')
-rw-r--r--libports/Makefile1
-rw-r--r--libports/begin-rpc.c13
-rw-r--r--libports/bucket-iterate.c5
-rw-r--r--libports/claim-right.c6
-rw-r--r--libports/class-iterate.c7
-rw-r--r--libports/complete-deallocate.c3
-rw-r--r--libports/count-bucket.c5
-rw-r--r--libports/count-class.c5
-rw-r--r--libports/create-bucket.c5
-rw-r--r--libports/create-internal.c11
-rw-r--r--libports/destroy-right.c5
-rw-r--r--libports/enable-bucket.c7
-rw-r--r--libports/enable-class.c7
-rw-r--r--libports/end-rpc.c7
-rw-r--r--libports/get-right.c7
-rw-r--r--libports/import-port.c11
-rw-r--r--libports/inhibit-all-rpcs.c7
-rw-r--r--libports/inhibit-bucket-rpcs.c7
-rw-r--r--libports/inhibit-class-rpcs.c7
-rw-r--r--libports/inhibit-port-rpcs.c7
-rw-r--r--libports/init.c5
-rw-r--r--libports/interrupt-notified-rpcs.c4
-rw-r--r--libports/interrupt-on-notify.c22
-rw-r--r--libports/interrupt-operation.c4
-rw-r--r--libports/interrupt-rpcs.c5
-rw-r--r--libports/interrupted.c14
-rw-r--r--libports/lookup-port.c5
-rw-r--r--libports/manage-multithread.c67
-rw-r--r--libports/no-senders.c7
-rw-r--r--libports/port-deref-weak.c5
-rw-r--r--libports/port-deref.c7
-rw-r--r--libports/port-ref-weak.c5
-rw-r--r--libports/port-ref.c5
-rw-r--r--libports/ports.h7
-rw-r--r--libports/reallocate-from-external.c5
-rw-r--r--libports/reallocate-port.c5
-rw-r--r--libports/resume-all-rpcs.c7
-rw-r--r--libports/resume-bucket-rpcs.c7
-rw-r--r--libports/resume-class-rpcs.c7
-rw-r--r--libports/resume-port-rpcs.c7
-rw-r--r--libports/stubs.c2
-rw-r--r--libports/transfer-right.c4
42 files changed, 168 insertions, 171 deletions
diff --git a/libports/Makefile b/libports/Makefile
index 8d7d9bbb..767ee73a 100644
--- a/libports/Makefile
+++ b/libports/Makefile
@@ -41,6 +41,7 @@ SRCS = create-bucket.c create-class.c \
installhdrs = ports.h
HURDLIBS= ihash
+LDLIBS += -lpthread
OBJS = $(SRCS:.c=.o) notifyServer.o interruptServer.o
MIGCOMSFLAGS = -prefix ports_
diff --git a/libports/begin-rpc.c b/libports/begin-rpc.c
index ebe3473c..1e0e8ed6 100644
--- a/libports/begin-rpc.c
+++ b/libports/begin-rpc.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#define INHIBITED (PORTS_INHIBITED | PORTS_INHIBIT_WAIT)
@@ -30,14 +29,14 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info)
struct port_info *pi = portstruct;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
do
{
/* If our receive right is gone, then abandon the RPC. */
if (pi->port_right == MACH_PORT_NULL)
{
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return EOPNOTSUPP;
}
@@ -76,13 +75,13 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info)
if (block_flags)
{
*block_flags |= PORTS_BLOCKED;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
/* We've been cancelled, just return EINTR. If we were the
only one blocking, PORTS_BLOCKED will still be turned on,
but that's ok, it will just cause a (harmless) extra
- condition_broadcast(). */
+ pthread_cond_broadcast(). */
{
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return EINTR;
}
}
@@ -103,7 +102,7 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info)
pi->bucket->rpcs++;
_ports_total_rpcs++;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return 0;
}
diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c
index e439cb19..dc1c7b11 100644
--- a/libports/bucket-iterate.c
+++ b/libports/bucket-iterate.c
@@ -19,7 +19,6 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <hurd/ihash.h>
@@ -40,7 +39,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
struct item *i, *nxt;
error_t err;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
HURD_IHASH_ITERATE (&bucket->htable, arg)
{
struct port_info *const pi = arg;
@@ -55,7 +54,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
pi->refcnt++;
}
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
err = 0;
for (i = list; i; i = nxt)
diff --git a/libports/claim-right.c b/libports/claim-right.c
index aef53bb7..69d378f9 100644
--- a/libports/claim-right.c
+++ b/libports/claim-right.c
@@ -34,7 +34,7 @@ ports_claim_right (void *portstruct)
if (ret == MACH_PORT_NULL)
return ret;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
err = mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL);
assert_perror (err);
@@ -42,11 +42,11 @@ ports_claim_right (void *portstruct)
if (pi->flags & PORT_HAS_SENDRIGHTS)
{
pi->flags &= ~PORT_HAS_SENDRIGHTS;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
ports_port_deref (pi);
}
else
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return ret;
}
diff --git a/libports/class-iterate.c b/libports/class-iterate.c
index e2a15173..1f8878a5 100644
--- a/libports/class-iterate.c
+++ b/libports/class-iterate.c
@@ -18,19 +18,18 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include "ports.h"
-#include <cthreads.h>
error_t
ports_class_iterate (struct port_class *class,
error_t (*fun)(void *))
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (class->ports != 0)
{
struct port_bucket *bucket = class->ports->bucket;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return _ports_bucket_class_iterate (bucket, class, fun);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return 0;
}
diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c
index 52e8f17b..e569b461 100644
--- a/libports/complete-deallocate.c
+++ b/libports/complete-deallocate.c
@@ -21,7 +21,6 @@
#include "ports.h"
#include <assert.h>
#include <hurd/ihash.h>
-#include <cthreads.h>
void
_ports_complete_deallocate (struct port_info *pi)
@@ -43,7 +42,7 @@ _ports_complete_deallocate (struct port_info *pi)
pi->bucket->count--;
pi->class->count--;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
if (pi->class->clean_routine)
(*pi->class->clean_routine)(pi);
diff --git a/libports/count-bucket.c b/libports/count-bucket.c
index 9aff58e9..63feb6be 100644
--- a/libports/count-bucket.c
+++ b/libports/count-bucket.c
@@ -19,17 +19,16 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
int
ports_count_bucket (struct port_bucket *bucket)
{
int ret;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
ret = bucket->count;
bucket->flags |= PORT_BUCKET_NO_ALLOC;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return ret;
}
diff --git a/libports/count-class.c b/libports/count-class.c
index 6aa88aa9..986a68bb 100644
--- a/libports/count-class.c
+++ b/libports/count-class.c
@@ -19,17 +19,16 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
int
ports_count_class (struct port_class *class)
{
int ret;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
ret = class->count;
class->flags |= PORT_CLASS_NO_ALLOC;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return ret;
}
diff --git a/libports/create-bucket.c b/libports/create-bucket.c
index 6be4bcad..52d50c35 100644
--- a/libports/create-bucket.c
+++ b/libports/create-bucket.c
@@ -23,7 +23,6 @@
#include <errno.h>
#include <stdlib.h>
#include <hurd/ihash.h>
-#include <cthreads.h>
struct port_bucket *
ports_create_bucket ()
@@ -50,10 +49,10 @@ ports_create_bucket ()
hurd_ihash_init (&ret->htable, offsetof (struct port_info, hentry));
ret->rpcs = ret->flags = ret->count = 0;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
ret->next = _ports_all_buckets;
_ports_all_buckets = ret;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return ret;
}
diff --git a/libports/create-internal.c b/libports/create-internal.c
index 7a9b1cb0..c60f6fd9 100644
--- a/libports/create-internal.c
+++ b/libports/create-internal.c
@@ -19,7 +19,6 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include <assert.h>
-#include <cthreads.h>
#include <hurd/ihash.h>
#include "ports.h"
@@ -64,20 +63,20 @@ _ports_create_port_internal (struct port_class *class,
pi->current_rpcs = 0;
pi->bucket = bucket;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
loop:
if (class->flags & PORT_CLASS_NO_ALLOC)
{
class->flags |= PORT_CLASS_ALLOC_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
goto cancelled;
goto loop;
}
if (bucket->flags & PORT_BUCKET_NO_ALLOC)
{
bucket->flags |= PORT_BUCKET_ALLOC_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
goto cancelled;
goto loop;
}
@@ -93,7 +92,7 @@ _ports_create_port_internal (struct port_class *class,
class->ports = pi;
bucket->count++;
class->count++;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
if (install)
{
@@ -109,7 +108,7 @@ _ports_create_port_internal (struct port_class *class,
cancelled:
err = EINTR;
lose:
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
lose_unlocked:
err = mach_port_mod_refs (mach_task_self (), port,
MACH_PORT_RIGHT_RECEIVE, -1);
diff --git a/libports/destroy-right.c b/libports/destroy-right.c
index 327029a8..65e19c78 100644
--- a/libports/destroy-right.c
+++ b/libports/destroy-right.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <hurd/ihash.h>
#include <assert.h>
@@ -31,12 +30,12 @@ ports_destroy_right (void *portstruct)
if (pi->port_right != MACH_PORT_NULL)
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
err = mach_port_mod_refs (mach_task_self (), pi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
assert_perror (err);
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
pi->port_right = MACH_PORT_NULL;
diff --git a/libports/enable-bucket.c b/libports/enable-bucket.c
index 278c5bb5..f9c7b859 100644
--- a/libports/enable-bucket.c
+++ b/libports/enable-bucket.c
@@ -19,17 +19,16 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
void
ports_enable_bucket (struct port_bucket *bucket)
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
bucket->flags &= ~PORT_BUCKET_NO_ALLOC;
if (bucket->flags & PORT_BUCKET_ALLOC_WAIT)
{
bucket->flags &= ~PORT_BUCKET_ALLOC_WAIT;
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/enable-class.c b/libports/enable-class.c
index 7aebf685..b3894ebb 100644
--- a/libports/enable-class.c
+++ b/libports/enable-class.c
@@ -19,17 +19,16 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
void
ports_enable_class (struct port_class *class)
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
class->flags &= ~PORT_CLASS_NO_ALLOC;
if (class->flags & PORT_CLASS_ALLOC_WAIT)
{
class->flags &= ~PORT_CLASS_ALLOC_WAIT;
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/end-rpc.c b/libports/end-rpc.c
index 47fd1ae7..b5dcb3a2 100644
--- a/libports/end-rpc.c
+++ b/libports/end-rpc.c
@@ -19,14 +19,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
void
ports_end_rpc (void *port, struct rpc_info *info)
{
struct port_info *pi = port;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (info->notifies)
_ports_remove_notified_rpc (info);
@@ -42,7 +41,7 @@ ports_end_rpc (void *port, struct rpc_info *info)
|| (pi->bucket->flags & PORT_BUCKET_INHIBIT_WAIT)
|| (pi->class->flags & PORT_CLASS_INHIBIT_WAIT)
|| (_ports_flags & _PORTS_INHIBIT_WAIT))
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
/* This removes the current thread's rpc (which should be INFO) from the
ports interrupted list. */
@@ -52,5 +51,5 @@ ports_end_rpc (void *port, struct rpc_info *info)
RPC is now finished anwhow. */
hurd_check_cancel ();
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/get-right.c b/libports/get-right.c
index 95662f58..89050c6b 100644
--- a/libports/get-right.c
+++ b/libports/get-right.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <mach/notify.h>
#include <assert.h>
@@ -30,11 +29,11 @@ ports_get_right (void *port)
mach_port_t foo;
error_t err;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (pi->port_right == MACH_PORT_NULL)
{
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return MACH_PORT_NULL;
}
@@ -54,6 +53,6 @@ ports_get_right (void *port)
if (foo != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), foo);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return pi->port_right;
}
diff --git a/libports/import-port.c b/libports/import-port.c
index d7a62960..226f47e3 100644
--- a/libports/import-port.c
+++ b/libports/import-port.c
@@ -22,7 +22,6 @@
#include "ports.h"
#include <assert.h>
-#include <cthreads.h>
#include <hurd/ihash.h>
#include <mach/notify.h>
@@ -58,20 +57,20 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket,
pi->current_rpcs = 0;
pi->bucket = bucket;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
loop:
if (class->flags & PORT_CLASS_NO_ALLOC)
{
class->flags |= PORT_CLASS_ALLOC_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
goto cancelled;
goto loop;
}
if (bucket->flags & PORT_BUCKET_NO_ALLOC)
{
bucket->flags |= PORT_BUCKET_ALLOC_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
goto cancelled;
goto loop;
}
@@ -87,7 +86,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket,
class->ports = pi;
bucket->count++;
class->count++;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
mach_port_move_member (mach_task_self (), port, bucket->portset);
@@ -109,7 +108,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket,
cancelled:
err = EINTR;
lose:
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
free (pi);
return err;
diff --git a/libports/inhibit-all-rpcs.c b/libports/inhibit-all-rpcs.c
index 9a72f83e..d4a54ba5 100644
--- a/libports/inhibit-all-rpcs.c
+++ b/libports/inhibit-all-rpcs.c
@@ -20,7 +20,6 @@
#include "ports.h"
#include <hurd.h>
-#include <cthreads.h>
#include <hurd/ihash.h>
error_t
@@ -28,7 +27,7 @@ ports_inhibit_all_rpcs ()
{
error_t err = 0;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (_ports_flags & (_PORTS_INHIBITED | _PORTS_INHIBIT_WAIT))
err = EBUSY;
@@ -59,7 +58,7 @@ ports_inhibit_all_rpcs ()
while (_ports_total_rpcs > this_one)
{
_ports_flags |= _PORTS_INHIBIT_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
/* We got cancelled. */
{
err = EINTR;
@@ -72,7 +71,7 @@ ports_inhibit_all_rpcs ()
_ports_flags |= _PORTS_INHIBITED;
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return err;
}
diff --git a/libports/inhibit-bucket-rpcs.c b/libports/inhibit-bucket-rpcs.c
index 7fc55d31..965aa036 100644
--- a/libports/inhibit-bucket-rpcs.c
+++ b/libports/inhibit-bucket-rpcs.c
@@ -20,7 +20,6 @@
#include "ports.h"
#include <hurd.h>
-#include <cthreads.h>
#include <hurd/ihash.h>
error_t
@@ -28,7 +27,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket)
{
error_t err = 0;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (bucket->flags & (PORT_BUCKET_INHIBITED | PORT_BUCKET_INHIBIT_WAIT))
err = EBUSY;
@@ -55,7 +54,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket)
while (bucket->rpcs > this_one)
{
bucket->flags |= PORT_BUCKET_INHIBIT_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
/* We got cancelled. */
{
err = EINTR;
@@ -68,7 +67,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket)
bucket->flags |= PORT_BUCKET_INHIBITED;
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return err;
}
diff --git a/libports/inhibit-class-rpcs.c b/libports/inhibit-class-rpcs.c
index 951de4bf..7ee86538 100644
--- a/libports/inhibit-class-rpcs.c
+++ b/libports/inhibit-class-rpcs.c
@@ -20,14 +20,13 @@
#include "ports.h"
#include <hurd.h>
-#include <cthreads.h>
error_t
ports_inhibit_class_rpcs (struct port_class *class)
{
error_t err = 0;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (class->flags & (PORT_CLASS_INHIBITED | PORT_CLASS_INHIBIT_WAIT))
err = EBUSY;
@@ -50,7 +49,7 @@ ports_inhibit_class_rpcs (struct port_class *class)
while (class->rpcs > this_one)
{
class->flags |= PORT_CLASS_INHIBIT_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
/* We got cancelled. */
{
err = EINTR;
@@ -63,7 +62,7 @@ ports_inhibit_class_rpcs (struct port_class *class)
class->flags |= PORT_CLASS_INHIBITED;
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return err;
}
diff --git a/libports/inhibit-port-rpcs.c b/libports/inhibit-port-rpcs.c
index 02a3b462..b741eeb7 100644
--- a/libports/inhibit-port-rpcs.c
+++ b/libports/inhibit-port-rpcs.c
@@ -20,7 +20,6 @@
#include "ports.h"
#include <hurd.h>
-#include <cthreads.h>
error_t
ports_inhibit_port_rpcs (void *portstruct)
@@ -28,7 +27,7 @@ ports_inhibit_port_rpcs (void *portstruct)
error_t err = 0;
struct port_info *pi = portstruct;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (pi->flags & (PORT_INHIBITED | PORT_INHIBIT_WAIT))
err = EBUSY;
@@ -51,7 +50,7 @@ ports_inhibit_port_rpcs (void *portstruct)
&& !(pi->current_rpcs == this_rpc && ! this_rpc->next))
{
pi->flags |= PORT_INHIBIT_WAIT;
- if (hurd_condition_wait (&_ports_block, &_ports_lock))
+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
/* We got cancelled. */
{
err = EINTR;
@@ -64,7 +63,7 @@ ports_inhibit_port_rpcs (void *portstruct)
pi->flags |= PORT_INHIBITED;
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return err;
}
diff --git a/libports/init.c b/libports/init.c
index 7d4d16fd..3ef53888 100644
--- a/libports/init.c
+++ b/libports/init.c
@@ -19,10 +19,9 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
-struct mutex _ports_lock = MUTEX_INITIALIZER;
-struct condition _ports_block = CONDITION_INITIALIZER;
+pthread_mutex_t _ports_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t _ports_block = PTHREAD_COND_INITIALIZER;
struct port_bucket *_ports_all_buckets;
int _ports_total_rpcs;
int _ports_flags;
diff --git a/libports/interrupt-notified-rpcs.c b/libports/interrupt-notified-rpcs.c
index bdfef977..6d6493d3 100644
--- a/libports/interrupt-notified-rpcs.c
+++ b/libports/interrupt-notified-rpcs.c
@@ -36,7 +36,7 @@ ports_interrupt_notified_rpcs (void *object,
{
struct ports_notify *np;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
for (np = _ports_notifications; np; np = np->next)
if (np->port == port && np->what == what)
{
@@ -49,7 +49,7 @@ ports_interrupt_notified_rpcs (void *object,
}
break;
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
}
diff --git a/libports/interrupt-on-notify.c b/libports/interrupt-on-notify.c
index 42ae4884..b358e840 100644
--- a/libports/interrupt-on-notify.c
+++ b/libports/interrupt-on-notify.c
@@ -34,13 +34,13 @@ ports_interrupt_rpc_on_notification (void *object,
struct rpc_notify *new_req, *req;
struct port_info *pi = object;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (! MACH_PORT_VALID (port))
/* PORT is already dead or bogus, so interrupt the rpc immediately. */
{
hurd_thread_cancel (rpc->thread);
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return 0;
}
@@ -53,11 +53,11 @@ ports_interrupt_rpc_on_notification (void *object,
time we'll add a new structure, so we malloc while we don't have the
lock, and free it if we're wrong. */
{
- mutex_unlock (&_ports_lock); /* Don't hold the lock during malloc. */
+ pthread_mutex_unlock (&_ports_lock); /* Don't hold the lock during malloc. */
new_req = malloc (sizeof (struct rpc_notify));
if (! new_req)
return ENOMEM;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
}
/* Find any existing entry for PORT/WHAT. */
@@ -80,7 +80,7 @@ ports_interrupt_rpc_on_notification (void *object,
{
new_req->next = _ports_free_rpc_notifies;
_ports_free_rpc_notifies = new_req;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return ENOMEM;
}
}
@@ -89,7 +89,7 @@ ports_interrupt_rpc_on_notification (void *object,
pn->port = port;
pn->what = what;
pn->pending = 0;
- mutex_init (&pn->lock);
+ pthread_mutex_init (&pn->lock, NULL);
pn->next = _ports_notifications;
pn->prevp = &_ports_notifications;
@@ -136,9 +136,9 @@ ports_interrupt_rpc_on_notification (void *object,
immediate notification). */
req_notify = !pn->pending;
if (req_notify)
- mutex_lock (&pn->lock);
+ pthread_mutex_lock (&pn->lock);
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
if (req_notify)
{
@@ -152,7 +152,7 @@ ports_interrupt_rpc_on_notification (void *object,
mach_port_deallocate (mach_task_self (), old);
pn->pending = 1;
- mutex_unlock (&pn->lock);
+ pthread_mutex_unlock (&pn->lock);
return err;
}
@@ -170,11 +170,11 @@ ports_interrupt_self_on_notification (void *object,
struct port_info *pi = object;
thread_t thread = hurd_thread_self ();
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
for (rpc = pi->current_rpcs; rpc; rpc = rpc->next)
if (rpc->thread == thread)
break;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
assert (rpc);
diff --git a/libports/interrupt-operation.c b/libports/interrupt-operation.c
index 1545f788..19c0edf6 100644
--- a/libports/interrupt-operation.c
+++ b/libports/interrupt-operation.c
@@ -30,10 +30,10 @@ ports_S_interrupt_operation (mach_port_t port,
struct port_info *pi = ports_lookup_port (0, port, 0);
if (!pi)
return EOPNOTSUPP;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (pi->cancel_threshold < seqno)
pi->cancel_threshold = seqno;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
ports_interrupt_rpcs (pi);
ports_port_deref (pi);
return 0;
diff --git a/libports/interrupt-rpcs.c b/libports/interrupt-rpcs.c
index 7c28ff2c..42f51a5e 100644
--- a/libports/interrupt-rpcs.c
+++ b/libports/interrupt-rpcs.c
@@ -20,7 +20,6 @@
#include "ports.h"
#include <hurd.h>
-#include <cthreads.h>
void
ports_interrupt_rpcs (void *portstruct)
@@ -28,7 +27,7 @@ ports_interrupt_rpcs (void *portstruct)
struct port_info *pi = portstruct;
struct rpc_info *rpc;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
for (rpc = pi->current_rpcs; rpc; rpc = rpc->next)
{
@@ -36,5 +35,5 @@ ports_interrupt_rpcs (void *portstruct)
_ports_record_interruption (rpc);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/interrupted.c b/libports/interrupted.c
index e4cb2fc2..88fb9ef0 100644
--- a/libports/interrupted.c
+++ b/libports/interrupted.c
@@ -20,7 +20,7 @@
#include "ports.h"
-static spin_lock_t interrupted_lock = SPIN_LOCK_INITIALIZER;
+static pthread_spinlock_t interrupted_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* True if some active rpc has been interrupted. */
static struct rpc_info *interrupted = 0;
@@ -33,19 +33,19 @@ ports_self_interrupted ()
struct rpc_info **rpc_p, *rpc;
thread_t self = hurd_thread_self ();
- spin_lock (&interrupted_lock);
+ pthread_spin_lock (&interrupted_lock);
for (rpc_p = &interrupted; *rpc_p; rpc_p = &rpc->interrupted_next)
{
rpc = *rpc_p;
if (rpc->thread == self)
{
*rpc_p = rpc->interrupted_next;
- spin_unlock (&interrupted_lock);
+ pthread_spin_unlock (&interrupted_lock);
rpc->interrupted_next = 0;
return 1;
}
}
- spin_unlock (&interrupted_lock);
+ pthread_spin_unlock (&interrupted_lock);
return 0;
}
@@ -56,14 +56,14 @@ _ports_record_interruption (struct rpc_info *rpc)
{
struct rpc_info *i;
- spin_lock (&interrupted_lock);
+ pthread_spin_lock (&interrupted_lock);
/* See if RPC is already in the interrupted list. */
for (i = interrupted; i; i = i->interrupted_next)
if (i == rpc)
/* Yup, it is, so just leave it there. */
{
- spin_unlock (&interrupted_lock);
+ pthread_spin_unlock (&interrupted_lock);
return;
}
@@ -71,5 +71,5 @@ _ports_record_interruption (struct rpc_info *rpc)
rpc->interrupted_next = interrupted;
interrupted = rpc;
- spin_unlock (&interrupted_lock);
+ pthread_spin_unlock (&interrupted_lock);
}
diff --git a/libports/lookup-port.c b/libports/lookup-port.c
index 8eb98a12..373d929c 100644
--- a/libports/lookup-port.c
+++ b/libports/lookup-port.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <hurd/ihash.h>
void *
@@ -29,7 +28,7 @@ ports_lookup_port (struct port_bucket *bucket,
{
struct port_info *pi = 0;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (bucket)
pi = hurd_ihash_find (&bucket->htable, port);
@@ -47,7 +46,7 @@ ports_lookup_port (struct port_bucket *bucket,
if (pi)
pi->refcnt++;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return pi;
}
diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c
index 035cd38d..c46a09fc 100644
--- a/libports/manage-multithread.c
+++ b/libports/manage-multithread.c
@@ -19,13 +19,18 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <spin-lock.h>
#include <assert.h>
-#include <cthreads.h>
+#include <stdio.h>
#include <mach/message.h>
#include <mach/thread_info.h>
#include <mach/thread_switch.h>
+#define STACK_SIZE (64 * 1024)
+
+/* FIXME Until threadvars are completely replaced with correct TLS, use this
+ hack to set the stack size. */
+size_t __pthread_stack_default_size = STACK_SIZE;
+
#define THREAD_PRI 2
/* XXX To reduce starvation, the priority of new threads is initially
@@ -88,9 +93,14 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
{
volatile unsigned int nreqthreads;
volatile unsigned int totalthreads;
- spin_lock_t lock = SPIN_LOCK_INITIALIZER;
+ pthread_spinlock_t lock = PTHREAD_SPINLOCK_INITIALIZER;
+ pthread_attr_t attr;
+
+ auto void * thread_function (void *);
- auto int thread_function (int);
+ /* FIXME This is currently a no-op. */
+ pthread_attr_init (&attr);
+ pthread_attr_setstacksize (&attr, STACK_SIZE);
int
internal_demuxer (mach_msg_header_t *inp,
@@ -110,18 +120,32 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
/* msgt_unused = */ 0
};
- spin_lock (&lock);
+ pthread_spin_lock (&lock);
assert (nreqthreads);
nreqthreads--;
if (nreqthreads != 0)
- spin_unlock (&lock);
+ pthread_spin_unlock (&lock);
else
/* No thread would be listening for requests, spawn one. */
{
+ pthread_t pthread_id;
+ error_t err;
+
totalthreads++;
nreqthreads++;
- spin_unlock (&lock);
- cthread_detach (cthread_fork ((cthread_fn_t) thread_function, 0));
+ pthread_spin_unlock (&lock);
+
+ err = pthread_create (&pthread_id, &attr, thread_function, NULL);
+ if (!err)
+ pthread_detach (pthread_id);
+ else
+ {
+ /* XXX The number of threads should be adjusted but the code
+ and design of the Hurd servers just don't handle thread
+ creation failure. */
+ errno = err;
+ perror ("pthread_create");
+ }
}
/* Fill in default response. */
@@ -146,10 +170,10 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
}
else
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (inp->msgh_seqno < pi->cancel_threshold)
hurd_thread_cancel (link.thread);
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
status = demuxer (inp, outheadp);
ports_end_rpc (pi, &link);
}
@@ -161,16 +185,17 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
status = 1;
}
- spin_lock (&lock);
+ pthread_spin_lock (&lock);
nreqthreads++;
- spin_unlock (&lock);
+ pthread_spin_unlock (&lock);
return status;
}
- int
- thread_function (int master)
+ void *
+ thread_function (void *arg)
{
+ int master = (int) arg;
int timeout;
error_t err;
@@ -195,32 +220,32 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
if (master)
{
- spin_lock (&lock);
+ pthread_spin_lock (&lock);
if (totalthreads != 1)
{
- spin_unlock (&lock);
+ pthread_spin_unlock (&lock);
goto startover;
}
}
else
{
- spin_lock (&lock);
+ pthread_spin_lock (&lock);
if (nreqthreads == 1)
{
/* No other thread is listening for requests, continue. */
- spin_unlock (&lock);
+ pthread_spin_unlock (&lock);
goto startover;
}
nreqthreads--;
totalthreads--;
- spin_unlock (&lock);
+ pthread_spin_unlock (&lock);
}
- return 0;
+ return NULL;
}
nreqthreads = 1;
totalthreads = 1;
- thread_function (1);
+ thread_function ((void *) 1);
}
diff --git a/libports/no-senders.c b/libports/no-senders.c
index 0e8a5f17..1a6084b1 100644
--- a/libports/no-senders.c
+++ b/libports/no-senders.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <mach/notify.h>
void
@@ -30,10 +29,10 @@ ports_no_senders (void *portstruct,
int dealloc;
mach_port_t old;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if ((pi->flags & PORT_HAS_SENDRIGHTS) == 0)
{
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
return;
}
if (mscount >= pi->mscount)
@@ -54,7 +53,7 @@ ports_no_senders (void *portstruct,
mach_port_deallocate (mach_task_self (), old);
dealloc = 0;
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
if (dealloc)
{
diff --git a/libports/port-deref-weak.c b/libports/port-deref-weak.c
index 2bef3338..91071ffa 100644
--- a/libports/port-deref-weak.c
+++ b/libports/port-deref-weak.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
@@ -27,12 +26,12 @@ ports_port_deref_weak (void *portstruct)
{
struct port_info *pi = portstruct;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (pi->weakrefcnt);
pi->weakrefcnt--;
if (pi->refcnt == 0 && pi->weakrefcnt == 0)
_ports_complete_deallocate (pi);
else
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/port-deref.c b/libports/port-deref.c
index 1ded45d9..ae10a02c 100644
--- a/libports/port-deref.c
+++ b/libports/port-deref.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
@@ -30,12 +29,12 @@ ports_port_deref (void *portstruct)
retry:
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
if (pi->refcnt == 1 && pi->weakrefcnt
&& pi->class->dropweak_routine && !trieddroppingweakrefs)
{
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
(*pi->class->dropweak_routine) (pi);
trieddroppingweakrefs = 1;
goto retry;
@@ -47,7 +46,7 @@ ports_port_deref (void *portstruct)
if (pi->refcnt == 0 && pi->weakrefcnt == 0)
_ports_complete_deallocate (pi);
else
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/port-ref-weak.c b/libports/port-ref-weak.c
index 6ebd5608..c7d3c690 100644
--- a/libports/port-ref-weak.c
+++ b/libports/port-ref-weak.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
@@ -27,8 +26,8 @@ ports_port_ref_weak (void *portstruct)
{
struct port_info *pi = portstruct;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (pi->refcnt || pi->weakrefcnt);
pi->weakrefcnt++;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/port-ref.c b/libports/port-ref.c
index 7fd15272..864c540e 100644
--- a/libports/port-ref.c
+++ b/libports/port-ref.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
@@ -27,10 +26,10 @@ ports_port_ref (void *portstruct)
{
struct port_info *pi = portstruct;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (pi->refcnt || pi->weakrefcnt);
pi->refcnt++;
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/ports.h b/libports/ports.h
index 9a5ccbc2..07918412 100644
--- a/libports/ports.h
+++ b/libports/ports.h
@@ -26,6 +26,7 @@
#include <hurd.h>
#include <hurd/ihash.h>
#include <mach/notify.h>
+#include <pthread.h>
/* These are global values for common flags used in the various structures.
Not all of these are meaningful in all flag fields. */
@@ -115,7 +116,7 @@ struct ports_notify
mach_port_t port; /* */
mach_msg_id_t what; /* MACH_NOTIFY_* */
unsigned pending : 1; /* There's a notification outstanding. */
- struct mutex lock;
+ pthread_mutex_t lock;
struct rpc_notify *reqs; /* Which rpcs are notified by this port. */
struct ports_notify *next, **prevp; /* Linked list of all notified ports. */
@@ -396,8 +397,8 @@ extern kern_return_t ports_S_interrupt_operation (mach_port_t,
mach_port_seqno_t);
/* Private data */
-extern struct mutex _ports_lock;
-extern struct condition _ports_block;
+extern pthread_mutex_t _ports_lock;
+extern pthread_cond_t _ports_block;
extern struct port_bucket *_ports_all_buckets;
extern int _ports_total_rpcs;
extern int _ports_flags;
diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c
index ebddd9f7..cd12143c 100644
--- a/libports/reallocate-from-external.c
+++ b/libports/reallocate-from-external.c
@@ -20,7 +20,6 @@
#include "ports.h"
#include <assert.h>
-#include <cthreads.h>
#include <hurd/ihash.h>
#include <mach/notify.h>
@@ -36,7 +35,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
err = mach_port_get_receive_status (mach_task_self (), receive, &stat);
assert_perror (err);
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (pi->port_right);
@@ -62,7 +61,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
pi->mscount = stat.mps_mscount;
hurd_ihash_add (&pi->bucket->htable, receive, pi);
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
mach_port_move_member (mach_task_self (), receive, pi->bucket->portset);
diff --git a/libports/reallocate-port.c b/libports/reallocate-port.c
index 23898e88..891786cb 100644
--- a/libports/reallocate-port.c
+++ b/libports/reallocate-port.c
@@ -21,7 +21,6 @@
#include "ports.h"
#include <hurd/ihash.h>
#include <assert.h>
-#include <cthreads.h>
void
ports_reallocate_port (void *portstruct)
@@ -30,7 +29,7 @@ ports_reallocate_port (void *portstruct)
error_t err;
int dropref = 0;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (pi->port_right);
err = mach_port_mod_refs (mach_task_self (), pi->port_right,
@@ -50,7 +49,7 @@ ports_reallocate_port (void *portstruct)
pi->cancel_threshold = 0;
pi->mscount = 0;
hurd_ihash_add (&pi->bucket->htable, pi->port_right, pi);
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
err = mach_port_move_member (mach_task_self (), pi->port_right,
pi->bucket->portset);
diff --git a/libports/resume-all-rpcs.c b/libports/resume-all-rpcs.c
index 452da3b2..e9669e0f 100644
--- a/libports/resume-all-rpcs.c
+++ b/libports/resume-all-rpcs.c
@@ -19,21 +19,20 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
ports_resume_all_rpcs ()
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (_ports_flags & _PORTS_INHIBITED);
_ports_flags &= ~_PORTS_INHIBITED;
if (_ports_flags & _PORTS_BLOCKED)
{
_ports_flags &= ~_PORTS_BLOCKED;
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/resume-bucket-rpcs.c b/libports/resume-bucket-rpcs.c
index 59cc75a4..cf4db91c 100644
--- a/libports/resume-bucket-rpcs.c
+++ b/libports/resume-bucket-rpcs.c
@@ -19,19 +19,18 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
ports_resume_bucket_rpcs (struct port_bucket *bucket)
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (bucket->flags & PORT_BUCKET_INHIBITED);
bucket->flags &= ~PORT_BUCKET_INHIBITED;
if (bucket->flags & PORT_BUCKET_BLOCKED)
{
bucket->flags &= ~PORT_BUCKET_BLOCKED;
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/resume-class-rpcs.c b/libports/resume-class-rpcs.c
index a4191747..a8c701e2 100644
--- a/libports/resume-class-rpcs.c
+++ b/libports/resume-class-rpcs.c
@@ -19,20 +19,19 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
ports_resume_class_rpcs (struct port_class *class)
{
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (class->flags & PORT_CLASS_INHIBITED);
class->flags &= ~PORT_CLASS_INHIBITED;
if (class->flags & PORT_CLASS_BLOCKED)
{
class->flags &= ~PORT_CLASS_BLOCKED;
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/resume-port-rpcs.c b/libports/resume-port-rpcs.c
index e9e30fbd..5dc5c70e 100644
--- a/libports/resume-port-rpcs.c
+++ b/libports/resume-port-rpcs.c
@@ -19,7 +19,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <cthreads.h>
#include <assert.h>
void
@@ -27,16 +26,16 @@ ports_resume_port_rpcs (void *portstruct)
{
struct port_info *pi = portstruct;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
assert (pi->flags & PORT_INHIBITED);
pi->flags &= ~PORT_INHIBITED;
if (pi->flags & PORT_BLOCKED)
{
pi->flags &= ~PORT_BLOCKED;
- condition_broadcast (&_ports_block);
+ pthread_cond_broadcast (&_ports_block);
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
}
diff --git a/libports/stubs.c b/libports/stubs.c
index 23c6a0ea..de4ae4dd 100644
--- a/libports/stubs.c
+++ b/libports/stubs.c
@@ -21,6 +21,7 @@
/* This file contains stubs for some cthreads functions.
It should only get used if the user isn't otherwise using cthreads. */
+#if 0
#include <cthreads.h>
void condition_wait (condition_t c, mutex_t m) __attribute__ ((weak));
@@ -36,3 +37,4 @@ void
cond_broadcast (condition_t c)
{
}
+#endif
diff --git a/libports/transfer-right.c b/libports/transfer-right.c
index e7b0ff55..2a790694 100644
--- a/libports/transfer-right.c
+++ b/libports/transfer-right.c
@@ -35,7 +35,7 @@ ports_transfer_right (void *tostruct,
int hassendrights = 0;
error_t err;
- mutex_lock (&_ports_lock);
+ pthread_mutex_lock (&_ports_lock);
/* Fetch the port in FROMPI and clear its use */
port = frompi->port_right;
@@ -86,7 +86,7 @@ ports_transfer_right (void *tostruct,
}
}
- mutex_unlock (&_ports_lock);
+ pthread_mutex_unlock (&_ports_lock);
/* Take care of any lowered reference counts. */
if (dereffrompi)