summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
Diffstat (limited to 'term')
-rw-r--r--term/Makefile3
-rw-r--r--term/devio.c28
-rw-r--r--term/hurdio.c70
-rw-r--r--term/main.c10
-rw-r--r--term/munge.c6
-rw-r--r--term/ptyio.c80
-rw-r--r--term/term.h36
-rw-r--r--term/users.c265
8 files changed, 259 insertions, 239 deletions
diff --git a/term/Makefile b/term/Makefile
index 4aa6e3df..025a9b39 100644
--- a/term/Makefile
+++ b/term/Makefile
@@ -25,7 +25,8 @@ makemode := server
target = term
SRCS = devio.c munge.c users.c main.c ptyio.c hurdio.c xinl.c
-HURDLIBS = trivfs fshelp iohelp threads ports ihash shouldbeinlibc
+HURDLIBS = trivfs fshelp iohelp ports ihash shouldbeinlibc
+OTHERLIBS = -lpthread
OBJS = $(subst .c,.o,$(SRCS)) termServer.o device_replyServer.o tioctlServer.o ourmsgUser.o
include ../Makeconf
diff --git a/term/devio.c b/term/devio.c
index 8aa960b9..7c7d8fd8 100644
--- a/term/devio.c
+++ b/term/devio.c
@@ -51,7 +51,7 @@
#include <device/device.h>
#include <device/device_request.h>
#include <device/tty_status.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <hurd.h>
#include <hurd/ports.h>
@@ -313,7 +313,7 @@ device_write_reply_inband (mach_port_t replypt,
if (replypt != phys_reply_writes)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
output_pending = 0;
@@ -322,8 +322,8 @@ device_write_reply_inband (mach_port_t replypt,
if (amount >= npending_output)
{
npending_output = 0;
- condition_broadcast (outputq->wait);
- condition_broadcast (&select_alert);
+ pthread_cond_broadcast (outputq->wait);
+ pthread_cond_broadcast (&select_alert);
}
else
{
@@ -340,7 +340,7 @@ device_write_reply_inband (mach_port_t replypt,
else
devio_start_output ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -356,7 +356,7 @@ device_read_reply_inband (mach_port_t replypt,
if (replypt != phys_reply)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
input_pending = 0;
@@ -376,7 +376,7 @@ device_read_reply_inband (mach_port_t replypt,
else if (error_code == D_WOULD_BLOCK)
{
devio_desert_dtr ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -390,7 +390,7 @@ device_read_reply_inband (mach_port_t replypt,
else
input_pending = 1;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -542,7 +542,7 @@ device_open_reply (mach_port_t replyport,
if (replyport != phys_reply)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
assert (open_pending != NOTPENDING);
@@ -556,7 +556,7 @@ device_open_reply (mach_port_t replyport,
phys_reply_pi = 0;
open_pending = NOTPENDING;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -574,7 +574,7 @@ device_open_reply (mach_port_t replyport,
if (err)
{
open_pending = NOTPENDING;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
phys_reply_writes = ports_get_send_right (phys_reply_writes_pi);
@@ -604,7 +604,7 @@ device_open_reply (mach_port_t replyport,
devio_desert_dtr ();
open_pending = NOTPENDING;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -735,7 +735,7 @@ ports_do_mach_notify_send_once (mach_port_t notify)
{
error_t err;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (notify == phys_reply_writes)
{
@@ -778,7 +778,7 @@ ports_do_mach_notify_send_once (mach_port_t notify)
else
err = EOPNOTSUPP;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
diff --git a/term/hurdio.c b/term/hurdio.c
index b1d0c944..368c2322 100644
--- a/term/hurdio.c
+++ b/term/hurdio.c
@@ -26,8 +26,9 @@
#include <errno.h>
#include <error.h>
#include <string.h>
+#include <stdio.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <hurd.h>
#include <hurd/ports.h>
@@ -68,7 +69,7 @@ thread_t writer_thread = MACH_PORT_NULL;
/* This flag is set if the output was suspended. */
static int output_stopped;
-static struct condition hurdio_writer_condition;
+static pthread_cond_t hurdio_writer_condition;
/* Hold the amount of bytes that are currently in the progress of
being written. May be set to zero while you hold the global lock
@@ -77,24 +78,41 @@ size_t npending_output;
/* True if we should assert the dtr. */
int assert_dtr;
-static struct condition hurdio_assert_dtr_condition;
+static pthread_cond_t hurdio_assert_dtr_condition;
/* Forward */
static error_t hurdio_desert_dtr ();
-static any_t hurdio_reader_loop (any_t arg);
-static any_t hurdio_writer_loop (any_t arg);
+static void *hurdio_reader_loop (void *arg);
+static void *hurdio_writer_loop (void *arg);
static error_t hurdio_set_bits (struct termios *state);
static error_t
hurdio_init (void)
{
- condition_init (&hurdio_writer_condition);
- condition_init (&hurdio_assert_dtr_condition);
+ pthread_t thread;
+ error_t err;
+
+ pthread_cond_init (&hurdio_writer_condition, NULL);
+ pthread_cond_init (&hurdio_assert_dtr_condition, NULL);
- cthread_detach (cthread_fork (hurdio_reader_loop, 0));
- cthread_detach (cthread_fork (hurdio_writer_loop, 0));
+ err = pthread_create (&thread, NULL, hurdio_reader_loop, NULL);
+ if (!err)
+ pthread_detach (thread);
+ else
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
+ err = pthread_create (&thread, NULL, hurdio_writer_loop, NULL);
+ if (!err)
+ pthread_detach (thread);
+ else
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
return 0;
}
@@ -129,7 +147,7 @@ static void
wait_for_dtr (void)
{
while (!assert_dtr)
- hurd_condition_wait (&hurdio_assert_dtr_condition, &global_lock);
+ pthread_cond_wait (&hurdio_assert_dtr_condition, &global_lock);
assert_dtr = 0;
if (tty_arg == 0)
@@ -165,15 +183,15 @@ wait_for_dtr (void)
report_carrier_on ();
/* Signal that the writer thread should resume its work. */
- condition_broadcast (&hurdio_writer_condition);
+ pthread_cond_broadcast (&hurdio_writer_condition);
}
}
/* Read and enqueue input characters. Is also responsible to assert
the DTR if necessary. */
-static any_t
-hurdio_reader_loop (any_t arg)
+static void *
+hurdio_reader_loop (void *arg)
{
/* XXX The input buffer has 256 bytes. */
#define BUFFER_SIZE 256
@@ -182,7 +200,7 @@ hurdio_reader_loop (any_t arg)
size_t datalen;
error_t err;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
reader_thread = mach_thread_self ();
while (1)
@@ -190,14 +208,14 @@ hurdio_reader_loop (any_t arg)
/* We can only start when the DTR has been asserted. */
while (ioport == MACH_PORT_NULL)
wait_for_dtr ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
data = buffer;
datalen = BUFFER_SIZE;
err = io_read (ioport, &data, &datalen, -1, BUFFER_SIZE);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
/* Error or EOF can mean the carrier has been dropped. */
if (err || !datalen)
hurdio_desert_dtr ();
@@ -223,8 +241,8 @@ hurdio_reader_loop (any_t arg)
/* Output characters. */
-static any_t
-hurdio_writer_loop (any_t arg)
+static void *
+hurdio_writer_loop (void *arg)
{
/* XXX The output buffer has 256 bytes. */
#define BUFFER_SIZE 256
@@ -236,7 +254,7 @@ hurdio_writer_loop (any_t arg)
int npending_output_copy;
mach_port_t ioport_copy;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
writer_thread = mach_thread_self ();
while (1)
@@ -244,7 +262,7 @@ hurdio_writer_loop (any_t arg)
while (writer_thread != MACH_PORT_NULL
&& (ioport == MACH_PORT_NULL || !qsize (outputq)
|| output_stopped))
- hurd_condition_wait (&hurdio_writer_condition, &global_lock);
+ pthread_cond_wait (&hurdio_writer_condition, &global_lock);
if (writer_thread == MACH_PORT_NULL) /* A sign to die. */
return 0;
@@ -269,10 +287,10 @@ hurdio_writer_loop (any_t arg)
*bufp++ = dequeue (outputq);
/* Submit all the outstanding characters to the I/O port. */
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
err = io_write (ioport_copy, pending_output, npending_output_copy,
-1, &amount);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
mach_port_mod_refs (mach_task_self (), ioport_copy,
MACH_PORT_RIGHT_SEND, -1);
@@ -285,8 +303,8 @@ hurdio_writer_loop (any_t arg)
if (amount >= npending_output)
{
npending_output = 0;
- condition_broadcast (outputq->wait);
- condition_broadcast (&select_alert);
+ pthread_cond_broadcast (outputq->wait);
+ pthread_cond_broadcast (&select_alert);
}
else
{
@@ -321,7 +339,7 @@ hurdio_start_output ()
}
output_stopped = 0;
}
- condition_broadcast (&hurdio_writer_condition);
+ pthread_cond_broadcast (&hurdio_writer_condition);
return 0;
}
@@ -468,7 +486,7 @@ hurdio_assert_dtr ()
if (ioport == MACH_PORT_NULL)
{
assert_dtr = 1;
- condition_signal (&hurdio_assert_dtr_condition);
+ pthread_cond_signal (&hurdio_assert_dtr_condition);
}
return 0;
diff --git a/term/main.c b/term/main.c
index e15fee53..9cc32d4d 100644
--- a/term/main.c
+++ b/term/main.c
@@ -211,7 +211,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
break;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
(*bottom->fini) ();
tty_type = v->type;
@@ -232,7 +232,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
error_t err = (*bottom->init) ();
if (err == 0 && (termflags & TTY_OPEN))
err = (*bottom->assert_dtr) ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
break;
@@ -413,7 +413,7 @@ main (int argc, char **argv)
memset (&termstate, 0, sizeof (termstate));
termflags = NO_CARRIER | NO_OWNER;
- mutex_init (&global_lock);
+ pthread_mutex_init (&global_lock, NULL);
/* Initialize status from underlying node. */
err = io_stat ((*ourcntl)->underlying, &st);
@@ -441,8 +441,8 @@ main (int argc, char **argv)
if (err)
error (1, err, "Initializing bottom handler");
- condition_init (&carrier_alert);
- condition_init (&select_alert);
+ pthread_cond_init (&carrier_alert, NULL);
+ pthread_cond_init (&select_alert, NULL);
/* Launch. */
ports_manage_port_operations_multithread (term_bucket, demuxer, 0, 0, 0);
diff --git a/term/munge.c b/term/munge.c
index 660a99bd..7e08e2d2 100644
--- a/term/munge.c
+++ b/term/munge.c
@@ -707,7 +707,7 @@ drain_output ()
while ((qsize (outputq) || (*bottom->pending_output_size) ())
&& (!(termflags & NO_CARRIER) || (termstate.c_cflag & CLOCAL))
&& !cancel)
- cancel = hurd_condition_wait (outputq->wait, &global_lock);
+ cancel = pthread_hurd_cond_wait_np (outputq->wait, &global_lock);
return cancel ? EINTR : 0;
}
@@ -726,10 +726,10 @@ create_queue (int size, int lowat, int hiwat)
q->hiwat = hiwat;
q->cs = q->ce = q->array;
q->arraylen = size;
- q->wait = malloc (sizeof (struct condition));
+ q->wait = malloc (sizeof (pthread_cond_t));
assert (q->wait);
- condition_init (q->wait);
+ pthread_cond_init (q->wait, NULL);
return q;
}
diff --git a/term/ptyio.c b/term/ptyio.c
index b02cda3f..0f5ddb01 100644
--- a/term/ptyio.c
+++ b/term/ptyio.c
@@ -30,9 +30,9 @@
static int pty_read_blocked = 0;
/* Wake this up when tty output occurs and pty_read_blocked is set */
-static struct condition pty_read_wakeup = CONDITION_INITIALIZER;
+static pthread_cond_t pty_read_wakeup = PTHREAD_COND_INITIALIZER;
-static struct condition pty_select_wakeup = CONDITION_INITIALIZER;
+static pthread_cond_t pty_select_wakeup = PTHREAD_COND_INITIALIZER;
/* Set if "dtr" is on. */
static int dtr_on = 0;
@@ -70,11 +70,11 @@ pty_open_hook (struct trivfs_control *cntl,
if ((flags & (O_READ|O_WRITE)) == 0)
return 0;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (ptyopen)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBUSY;
}
@@ -87,7 +87,7 @@ pty_open_hook (struct trivfs_control *cntl,
control_byte = 0;
pktnostop = 0;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -95,23 +95,23 @@ pty_open_hook (struct trivfs_control *cntl,
error_t
pty_po_create_hook (struct trivfs_peropen *po)
{
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (po->openmodes & (O_READ | O_WRITE))
{
nptyperopens++;
report_carrier_on ();
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
error_t
pty_po_destroy_hook (struct trivfs_peropen *po)
{
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((po->openmodes & (O_READ | O_WRITE)) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
nptyperopens--;
@@ -120,7 +120,7 @@ pty_po_destroy_hook (struct trivfs_peropen *po)
ptyopen = 0;
report_carrier_off ();
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -130,8 +130,8 @@ wake_reader ()
if (pty_read_blocked)
{
pty_read_blocked = 0;
- condition_broadcast (&pty_read_wakeup);
- condition_broadcast (&pty_select_wakeup);
+ pthread_cond_broadcast (&pty_read_wakeup);
+ pthread_cond_broadcast (&pty_select_wakeup);
}
}
@@ -306,11 +306,11 @@ pty_io_read (struct trivfs_protid *cred,
{
int size;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((cred->po->openmodes & O_READ) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
@@ -320,13 +320,13 @@ pty_io_read (struct trivfs_protid *cred,
{
if (cred->po->openmodes & O_NONBLOCK)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EWOULDBLOCK;
}
pty_read_blocked = 1;
- if (hurd_condition_wait (&pty_read_wakeup, &global_lock))
+ if (pthread_hurd_cond_wait_np (&pty_read_wakeup, &global_lock))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EINTR;
}
}
@@ -370,7 +370,7 @@ pty_io_read (struct trivfs_protid *cred,
*cp++ = dequeue (outputq);
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -385,11 +385,11 @@ pty_io_write (struct trivfs_protid *cred,
int i, flush;
int cancel = 0;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((cred->po->openmodes & O_WRITE) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
@@ -400,14 +400,14 @@ pty_io_write (struct trivfs_protid *cred,
{
if (cred->po->openmodes & O_NONBLOCK)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EWOULDBLOCK;
}
- cancel = hurd_condition_wait (inputq->wait, &global_lock);
+ cancel = pthread_hurd_cond_wait_np (inputq->wait, &global_lock);
}
if (cancel)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EINTR;
}
@@ -433,7 +433,7 @@ pty_io_write (struct trivfs_protid *cred,
}
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
*amount = datalen;
return 0;
@@ -443,7 +443,7 @@ pty_io_write (struct trivfs_protid *cred,
error_t
pty_io_readable (size_t *amt)
{
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (control_byte)
{
*amt = 1;
@@ -452,7 +452,7 @@ pty_io_readable (size_t *amt)
}
else
*amt = qsize (outputq);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -466,7 +466,7 @@ pty_io_select (struct trivfs_protid *cred, mach_port_t reply,
if (*type == 0)
return 0;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
while (1)
{
@@ -483,17 +483,17 @@ pty_io_select (struct trivfs_protid *cred, mach_port_t reply,
if (avail)
{
*type = avail;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
ports_interrupt_self_on_port_death (cred, reply);
pty_read_blocked = 1;
- if (hurd_condition_wait (&pty_select_wakeup, &global_lock))
+ if (pthread_hurd_cond_wait_np (&pty_select_wakeup, &global_lock))
{
*type = 0;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EINTR;
}
}
@@ -508,7 +508,7 @@ S_tioctl_tiocsig (io_t port,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
drop_output ();
clear_queue (inputq);
@@ -516,7 +516,7 @@ S_tioctl_tiocsig (io_t port,
ptyio_notice_input_flushed ();
send_signal (sig);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return 0;
@@ -533,7 +533,7 @@ S_tioctl_tiocpkt (io_t port,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!!mode == !!packet_mode)
err = 0;
@@ -546,7 +546,7 @@ S_tioctl_tiocpkt (io_t port,
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -563,7 +563,7 @@ S_tioctl_tiocucntl (io_t port,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!!mode == !!user_ioctl_mode)
err = 0;
@@ -576,7 +576,7 @@ S_tioctl_tiocucntl (io_t port,
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -592,13 +592,13 @@ S_tioctl_tiocremote (io_t port,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
remote_input_mode = how;
drop_output ();
clear_queue (inputq);
clear_queue (rawq);
ptyio_notice_input_flushed ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return 0;
}
@@ -612,7 +612,7 @@ S_tioctl_tiocext (io_t port,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (mode && !external_processing)
{
if (packet_mode)
@@ -633,7 +633,7 @@ S_tioctl_tiocext (io_t port,
external_processing = 0;
termstate.c_lflag &= ~EXTPROC;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return 0;
}
diff --git a/term/term.h b/term/term.h
index 2df20337..f154d4c0 100644
--- a/term/term.h
+++ b/term/term.h
@@ -18,7 +18,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-#include <cthreads.h>
+#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <hurd/trivfs.h>
@@ -95,16 +95,16 @@ long termflags;
#define QUEUE_HIWAT 8100
/* Global lock */
-struct mutex global_lock;
+pthread_mutex_t global_lock;
/* Wakeup when NO_CARRIER turns off */
-struct condition carrier_alert;
+pthread_cond_t carrier_alert;
/* Wakeup for select */
-struct condition select_alert;
+pthread_cond_t select_alert;
/* Wakeup for pty select, if not null */
-struct condition *pty_select_alert;
+pthread_cond_t *pty_select_alert;
/* Bucket for all our ports. */
struct port_bucket *term_bucket;
@@ -188,7 +188,7 @@ struct queue
int hiwat;
short *cs, *ce;
int arraylen;
- struct condition *wait;
+ pthread_cond_t *wait;
quoted_char array[0];
};
@@ -227,10 +227,10 @@ clear_queue (struct queue *q)
{
q->susp = 0;
q->cs = q->ce = q->array;
- condition_broadcast (q->wait);
- condition_broadcast (&select_alert);
+ pthread_cond_broadcast (q->wait);
+ pthread_cond_broadcast (&select_alert);
if (q == inputq && pty_select_alert != NULL)
- condition_broadcast (pty_select_alert);
+ pthread_cond_broadcast (pty_select_alert);
}
#endif /* Use extern inlines. */
@@ -254,10 +254,10 @@ dequeue_quote (struct queue *q)
beep = 1;
if (beep)
{
- condition_broadcast (q->wait);
- condition_broadcast (&select_alert);
+ pthread_cond_broadcast (q->wait);
+ pthread_cond_broadcast (&select_alert);
if (q == inputq && pty_select_alert != NULL)
- condition_broadcast (pty_select_alert);
+ pthread_cond_broadcast (pty_select_alert);
else if (q == outputq)
call_asyncs (O_WRITE);
}
@@ -288,12 +288,12 @@ enqueue_internal (struct queue **qp, quoted_char c)
if (qsize (q) == 1)
{
- condition_broadcast (q->wait);
- condition_broadcast (&select_alert);
+ pthread_cond_broadcast (q->wait);
+ pthread_cond_broadcast (&select_alert);
if (q == inputq)
{
if (pty_select_alert != NULL)
- condition_broadcast (pty_select_alert);
+ pthread_cond_broadcast (pty_select_alert);
call_asyncs (O_READ);
}
}
@@ -349,10 +349,10 @@ queue_erase (struct queue *q)
beep = 1;
if (beep)
{
- condition_broadcast (q->wait);
- condition_broadcast (&select_alert);
+ pthread_cond_broadcast (q->wait);
+ pthread_cond_broadcast (&select_alert);
if (q == inputq && pty_select_alert != NULL)
- condition_broadcast (pty_select_alert);
+ pthread_cond_broadcast (pty_select_alert);
}
return answer;
}
diff --git a/term/users.c b/term/users.c
index 4ec2b810..9fc1dc23 100644
--- a/term/users.c
+++ b/term/users.c
@@ -25,7 +25,7 @@
#include <string.h>
#include <fcntl.h>
#include <hurd/trivfs.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <hurd.h>
#include <stdio.h>
#include <hurd/iohelp.h>
@@ -70,7 +70,7 @@ int foreground_id;
struct winsize window_size;
static int sigs_in_progress;
-static struct condition input_sig_wait = CONDITION_INITIALIZER;
+static pthread_cond_t input_sig_wait = PTHREAD_COND_INITIALIZER;
static int input_sig_wakeup;
static error_t carrier_error;
@@ -114,7 +114,7 @@ check_access_hook (struct trivfs_control *cntl,
{
struct stat st;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
st.st_uid = term_owner;
st.st_gid = term_group;
@@ -126,7 +126,7 @@ check_access_hook (struct trivfs_control *cntl,
if (fshelp_access (&st, S_IWRITE, user) == 0)
*allowed |= O_WRITE;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
error_t (*trivfs_check_access_hook) (struct trivfs_control *, struct iouser *,
@@ -148,7 +148,7 @@ open_hook (struct trivfs_control *cntl,
if ((flags & (O_READ|O_WRITE)) == 0)
return 0;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(termflags & TTY_OPEN))
{
@@ -174,7 +174,7 @@ open_hook (struct trivfs_control *cntl,
if (termflags & EXCL_USE)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBUSY;
}
}
@@ -190,7 +190,7 @@ open_hook (struct trivfs_control *cntl,
err = (*bottom->assert_dtr) ();
if (err)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
}
@@ -199,11 +199,11 @@ open_hook (struct trivfs_control *cntl,
while (((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
&& !(flags & O_NONBLOCK)
&& !cancel)
- cancel = hurd_condition_wait (&carrier_alert, &global_lock);
+ cancel = pthread_hurd_cond_wait_np (&carrier_alert, &global_lock);
if (cancel)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EINTR;
}
@@ -224,7 +224,7 @@ open_hook (struct trivfs_control *cntl,
(*bottom->gwinsz) (&window_size);
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
error_t (*trivfs_check_open_hook) (struct trivfs_control *,
@@ -237,10 +237,10 @@ pi_create_hook (struct trivfs_protid *cred)
if (cred->pi.class == pty_class)
return 0;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (cred->hook)
((struct protid_hook *)cred->hook)->refcnt++;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -252,7 +252,7 @@ pi_destroy_hook (struct trivfs_protid *cred)
if (cred->pi.class == pty_class)
return;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (cred->hook)
{
assert (((struct protid_hook *)cred->hook)->refcnt > 0);
@@ -261,7 +261,7 @@ pi_destroy_hook (struct trivfs_protid *cred)
bug. */
/* free (cred->hook) */;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
}
void (*trivfs_protid_destroy_hook) (struct trivfs_protid *) = pi_destroy_hook;
@@ -271,7 +271,7 @@ po_create_hook (struct trivfs_peropen *po)
if (po->cntl == ptyctl)
return pty_po_create_hook (po);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
nperopens++;
if (po->openmodes & O_ASYNC)
{
@@ -279,7 +279,7 @@ po_create_hook (struct trivfs_peropen *po)
num_icky_async_peropens++;
call_asyncs (O_READ | O_WRITE);
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
error_t (*trivfs_peropen_create_hook) (struct trivfs_peropen *) =
@@ -294,7 +294,7 @@ po_destroy_hook (struct trivfs_peropen *po)
return;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((po->openmodes & O_ASYNC) && --num_icky_async_peropens == 0)
termflags &= ~ICKY_ASYNC;
@@ -316,7 +316,7 @@ po_destroy_hook (struct trivfs_peropen *po)
termflags &= ~TTY_OPEN;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
}
void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *)
= po_destroy_hook;
@@ -363,7 +363,7 @@ S_term_getctty (mach_port_t arg,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -374,7 +374,7 @@ S_term_getctty (mach_port_t arg,
err = 0;
}
ports_port_deref (cred);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
@@ -436,16 +436,16 @@ S_term_open_ctty (mach_port_t arg,
return EINVAL;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!cred->po->openmodes & (O_READ|O_WRITE))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
err = EBADF;
}
else
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
err = trivfs_protid_dup (cred, &newcred);
if (!err)
@@ -489,7 +489,7 @@ trivfs_S_file_chown (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
/* XXX */
st.st_uid = term_owner;
@@ -517,7 +517,7 @@ trivfs_S_file_chown (struct trivfs_protid *cred,
err = 0;
out:
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
@@ -534,7 +534,7 @@ trivfs_S_file_chmod (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!cred->isroot)
{
/* XXX */
@@ -558,7 +558,7 @@ trivfs_S_file_chmod (struct trivfs_protid *cred,
err = 0;
out:
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
@@ -584,25 +584,25 @@ trivfs_S_io_write (struct trivfs_protid *cred,
if (cred->pi.class == pty_class)
return pty_io_write (cred, data, datalen, amt);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
/* Check for errors first. */
if ((cred->po->openmodes & O_WRITE) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
if ((termstate.c_lflag & TOSTOP) && !fg_p (cred))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBACKGROUND;
}
if ((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EIO;
}
@@ -618,7 +618,8 @@ trivfs_S_io_write (struct trivfs_protid *cred,
else
{
if (!qavail (outputq))
- cancel = hurd_condition_wait (outputq->wait, &global_lock);
+ cancel = pthread_hurd_cond_wait_np (outputq->wait,
+ &global_lock);
}
}
if (cancel)
@@ -636,7 +637,7 @@ trivfs_S_io_write (struct trivfs_protid *cred,
call_asyncs (O_WRITE);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return ((cancel && datalen && !*amt) ? (err ?: EINTR) : 0);
}
@@ -662,17 +663,17 @@ trivfs_S_io_read (struct trivfs_protid *cred,
if (cred->pi.class == pty_class)
return pty_io_read (cred, data, datalen, amount);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((cred->po->openmodes & O_READ) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
if (!fg_p (cred))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBACKGROUND;
}
@@ -681,20 +682,20 @@ trivfs_S_io_read (struct trivfs_protid *cred,
if ((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL) || !amount)
{
/* Return EOF, Posix.1 7.1.1.10. */
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
*datalen = 0;
return 0;
}
if (cred->po->openmodes & O_NONBLOCK)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EWOULDBLOCK;
}
- if (hurd_condition_wait (inputq->wait, &global_lock))
+ if (pthread_hurd_cond_wait_np (inputq->wait, &global_lock))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EINTR;
}
@@ -713,9 +714,9 @@ trivfs_S_io_read (struct trivfs_protid *cred,
if (sigs_in_progress)
{
input_sig_wakeup++;
- if (hurd_condition_wait (&input_sig_wait, &global_lock))
+ if (pthread_hurd_cond_wait_np (&input_sig_wait, &global_lock))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EINTR;
}
}
@@ -778,7 +779,7 @@ trivfs_S_io_read (struct trivfs_protid *cred,
call_asyncs (O_READ);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return !*datalen && cancel ? EINTR : 0;
}
@@ -835,16 +836,16 @@ trivfs_S_io_readable (struct trivfs_protid *cred,
if (cred->pi.class == pty_class)
return pty_io_readable (amt);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((cred->po->openmodes & O_READ) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
*amt = qsize (inputq);
if (remote_input_mode && *amt)
--*amt;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -868,7 +869,7 @@ trivfs_S_io_revoke (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!cred->isroot)
{
@@ -881,12 +882,12 @@ trivfs_S_io_revoke (struct trivfs_protid *cred,
err = fshelp_isowner (&st, cred->user);
if (err)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_inhibit_bucket_rpcs (term_bucket);
ports_class_iterate (cred->pi.class, iterator_function);
@@ -917,9 +918,9 @@ S_tioctl_tiocmodg (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
err = (*bottom->mdmstate) (state);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -942,14 +943,14 @@ S_tioctl_tiocmods (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->mdmctl) (MDMCTL_SET, state);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -971,7 +972,7 @@ S_tioctl_tiocexcl (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -981,7 +982,7 @@ S_tioctl_tiocexcl (io_t port)
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1003,7 +1004,7 @@ S_tioctl_tiocnxcl (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
@@ -1012,7 +1013,7 @@ S_tioctl_tiocnxcl (io_t port)
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1035,7 +1036,7 @@ S_tioctl_tiocflush (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -1054,7 +1055,7 @@ S_tioctl_tiocflush (io_t port,
err = drop_output ();
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1078,7 +1079,7 @@ S_tioctl_tiocgeta (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
modes[0] = termstate.c_iflag;
modes[1] = termstate.c_oflag;
modes[2] = termstate.c_cflag;
@@ -1086,7 +1087,7 @@ S_tioctl_tiocgeta (io_t port,
memcpy (ccs, termstate.c_cc, NCCS);
speeds[0] = termstate.__ispeed;
speeds[1] = termstate.__ospeed;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return 0;
@@ -1115,7 +1116,7 @@ set_state (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -1179,7 +1180,7 @@ set_state (io_t port,
}
leave:
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1257,10 +1258,10 @@ S_tioctl_tiocsetd (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
if (disc != 0)
err = ENXIO;
@@ -1288,16 +1289,16 @@ S_tioctl_tiocdrain (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & O_WRITE))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return EBADF;
}
err = drain_output ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1320,7 +1321,7 @@ S_tioctl_tiocswinsz (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -1341,7 +1342,7 @@ S_tioctl_tiocswinsz (io_t port,
send_signal (SIGWINCH);
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return err;
}
@@ -1362,9 +1363,9 @@ S_tioctl_tiocgwinsz (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
*size = window_size;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return 0;
@@ -1388,9 +1389,9 @@ S_tioctl_tiocmget (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
err = (*bottom->mdmstate) (bits);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1414,13 +1415,13 @@ S_tioctl_tiocmset (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->mdmctl) (MDMCTL_SET, bits);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1443,12 +1444,12 @@ S_tioctl_tiocmbic (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->mdmctl) (MDMCTL_BIC, bits);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1472,13 +1473,13 @@ S_tioctl_tiocmbis (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->mdmctl) (MDMCTL_BIS, bits);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
}
@@ -1500,7 +1501,7 @@ S_tioctl_tiocstart (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -1513,7 +1514,7 @@ S_tioctl_tiocstart (io_t port)
if (err)
termflags = old_termflags;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1535,7 +1536,7 @@ S_tioctl_tiocstop (io_t port)
ports_port_deref (cred);
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -1547,7 +1548,7 @@ S_tioctl_tiocstop (io_t port)
if (err)
termflags = old_termflags;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1571,7 +1572,7 @@ S_tioctl_tiocsti (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
/* BSD returns EACCES if this is not our controlling terminal,
but we have no way to do that. (And I don't think it actually
@@ -1584,7 +1585,7 @@ S_tioctl_tiocsti (io_t port,
input_character (c);
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1608,7 +1609,7 @@ S_tioctl_tiocoutq (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
@@ -1617,7 +1618,7 @@ S_tioctl_tiocoutq (io_t port,
*queue_size = qsize (outputq) + (*bottom->pending_output_size) ();
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1641,7 +1642,7 @@ S_tioctl_tiocspgrp (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
@@ -1650,7 +1651,7 @@ S_tioctl_tiocspgrp (io_t port,
foreground_id = -pgrp;
err = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1674,7 +1675,7 @@ S_tioctl_tiocgpgrp (io_t port,
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (termflags & NO_OWNER)
ret = ENOTTY; /* that's what BSD says... */
else
@@ -1682,7 +1683,7 @@ S_tioctl_tiocgpgrp (io_t port,
*pgrp = - foreground_id;
ret = 0;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return ret;
@@ -1705,12 +1706,12 @@ S_tioctl_tioccdtr (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->mdmctl) (MDMCTL_BIC, TIOCM_DTR);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1733,12 +1734,12 @@ S_tioctl_tiocsdtr (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->mdmctl) (MDMCTL_BIS, TIOCM_DTR);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1761,12 +1762,12 @@ S_tioctl_tioccbrk (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->clear_break) ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1789,12 +1790,12 @@ S_tioctl_tiocsbrk (io_t port)
return EOPNOTSUPP;
}
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
err = EBADF;
else
err = (*bottom->set_break) ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
ports_port_deref (cred);
return err;
@@ -1807,13 +1808,13 @@ trivfs_S_file_set_size (struct trivfs_protid *cred,
{
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((cred->po->openmodes & O_WRITE) == 0)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1836,9 +1837,9 @@ trivfs_S_io_get_openmodes (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
*bits = cred->po->openmodes;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1855,7 +1856,7 @@ trivfs_S_io_set_all_openmodes (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
obits = cred->po->openmodes;
if ((obits & O_ASYNC) && --num_icky_async_peropens == 0)
@@ -1871,7 +1872,7 @@ trivfs_S_io_set_all_openmodes (struct trivfs_protid *cred,
call_asyncs (O_READ | O_WRITE);
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1887,7 +1888,7 @@ trivfs_S_io_set_some_openmodes (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
obits = cred->po->openmodes;
cred->po->openmodes |= (bits & HONORED_STATE_MODES);
if ((bits & O_ASYNC) && !(obits & O_ASYNC))
@@ -1896,7 +1897,7 @@ trivfs_S_io_set_some_openmodes (struct trivfs_protid *cred,
num_icky_async_peropens++;
call_asyncs (O_READ | O_WRITE);
}
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1909,11 +1910,11 @@ trivfs_S_io_clear_some_openmodes (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if ((cred->po->openmodes & O_ASYNC) && --num_icky_async_peropens == 0)
termflags &= ~ICKY_ASYNC;
cred->po->openmodes &= ~(bits & HONORED_STATE_MODES);
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1927,10 +1928,10 @@ trivfs_S_io_mod_owner (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
termflags &= ~NO_OWNER;
foreground_id = owner;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1943,14 +1944,14 @@ trivfs_S_io_get_owner (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (termflags & NO_OWNER)
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return ENOTTY;
}
*owner = foreground_id;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1963,15 +1964,15 @@ trivfs_S_io_get_icky_async_id (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
*id = async_icky_id;
*idtype = MACH_MSG_TYPE_MAKE_SEND;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -1985,10 +1986,10 @@ trivfs_S_io_async (struct trivfs_protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (!(cred->po->openmodes & (O_READ|O_WRITE)))
{
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return EBADF;
}
ar = malloc (sizeof (struct async_req));
@@ -1997,7 +1998,7 @@ trivfs_S_io_async (struct trivfs_protid *cred,
async_requests = ar;
*id = async_id;
*idtype = MACH_MSG_TYPE_MAKE_SEND;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return 0;
}
@@ -2018,7 +2019,7 @@ trivfs_S_io_select (struct trivfs_protid *cred,
if ((cred->po->openmodes & O_WRITE) == 0)
*type &= ~SELECT_WRITE;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
while (1)
{
@@ -2031,12 +2032,12 @@ trivfs_S_io_select (struct trivfs_protid *cred,
if (available == 0)
{
ports_interrupt_self_on_port_death (cred, reply);
- if (hurd_condition_wait (&select_alert, &global_lock) == 0)
+ if (pthread_hurd_cond_wait_np (&select_alert, &global_lock) == 0)
continue;
}
*type = available;
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return available ? 0 : EINTR;
}
}
@@ -2066,7 +2067,7 @@ report_sig_end ()
if ((sigs_in_progress == 0) && input_sig_wakeup)
{
input_sig_wakeup = 0;
- condition_broadcast (&input_sig_wait);
+ pthread_cond_broadcast (&input_sig_wait);
}
}
@@ -2091,9 +2092,9 @@ call_asyncs (int dir)
if ((termflags & ICKY_ASYNC) && !(termflags & NO_OWNER))
{
report_sig_start ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
hurd_sig_post (foreground_id, SIGIO, async_icky_id);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
report_sig_end ();
}
@@ -2125,9 +2126,9 @@ send_signal (int signo)
{
right = ports_get_send_right (cttyid);
report_sig_start ();
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
hurd_sig_post (foreground_id, signo, right);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
report_sig_end ();
mach_port_deallocate (mach_task_self (), right);
}
@@ -2148,14 +2149,14 @@ void
report_carrier_on ()
{
termflags &= ~NO_CARRIER;
- condition_broadcast (&carrier_alert);
+ pthread_cond_broadcast (&carrier_alert);
}
void
report_carrier_error (error_t err)
{
carrier_error = err;
- condition_broadcast (&carrier_alert);
+ pthread_cond_broadcast (&carrier_alert);
}
kern_return_t