From e917c07b2664bb01a5f7b5975723b90da0f396c9 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 3 Jan 2012 22:12:37 +0100 Subject: Port to npth. * configure.ac: Don't check for PTH but for NPTH. (AH_BOTTOM): Remove PTH_SYSCALL_SOFT. (have_pth): Rename to ... (have_npth): ... this. (USE_GNU_NPTH): Rename to ... (USE_GNU_PTH): ... this. * m4/npth.m4: New file. * agent/Makefile.am, agent/cache.c, agent/call-pinentry.c, agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c, agent/trustlist.c, common/Makefile.am, common/estream.c, common/exechelp-posix.c, common/exechelp-w32.c, common/exechelp-w32ce.c, common/http.c, common/init.c, common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c, dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c, dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am, g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am, scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c, scd/scdaemon.c, tools/Makefile.am: Port to npth. --- g13/runner.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'g13/runner.c') diff --git a/g13/runner.c b/g13/runner.c index 7e9c262c3..7680d3d5b 100644 --- a/g13/runner.c +++ b/g13/runner.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include "g13.h" #include "i18n.h" @@ -40,7 +40,7 @@ struct runner_s unsigned int identifier; /* The runner identifier. */ int spawned; /* True if runner_spawn has been called. */ - pth_t threadid; /* The TID of the runner thread. */ + npth_t thread; /* The TID of the runner thread. */ runner_t next_running; /* Builds a list of all running threads. */ int canceled; /* Set if a cancel has already been send once. */ @@ -85,7 +85,7 @@ writen (int fd, const void *buf, size_t nbytes) while (nleft > 0) { - nwritten = pth_write (fd, buf, nleft); + nwritten = npth_write (fd, buf, nleft); if (nwritten < 0) { if (errno == EINTR) @@ -408,8 +408,9 @@ gpg_error_t runner_spawn (runner_t runner) { gpg_error_t err; - pth_attr_t tattr; - pth_t tid; + npth_attr_t tattr; + npth_t thread; + int ret; if (check_already_spawned (runner, "runner_spawn")) return gpg_error (GPG_ERR_BUG); @@ -433,26 +434,26 @@ runner_spawn (runner_t runner) runner->in_fd = -1; /* Now owned by status_fp. */ } - tattr = pth_attr_new (); - pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); - pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 128*1024); - pth_attr_set (tattr, PTH_ATTR_NAME, runner->name); + npth_attr_init (&tattr); + npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED); - tid = pth_spawn (tattr, runner_thread, runner); - if (!tid) + ret = npth_create (&thread, &tattr, runner_thread, runner); + if (ret) { - err = gpg_error_from_syserror (); + err = gpg_error_from_errno (ret); log_error ("error spawning runner thread: %s\n", gpg_strerror (err)); return err; } + npth_setname_np (thread, runner->name); + /* The scheduler has not yet kicked in, thus we can safely set the spawned flag and the tid. */ runner->spawned = 1; - runner->threadid = tid; + runner->thread = thread; runner->next_running = running_threads; running_threads = runner; - pth_attr_destroy (tattr); + npth_attr_destroy (&tattr); /* The runner thread is now runnable. */ -- cgit v1.2.3