diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-11-19 01:44:58 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-11-19 01:44:58 +0100 |
commit | 448d06e8dc5c06f111bb6baae7d456e174225729 (patch) | |
tree | 0ddcedd3ca2d516b5e103c2b6ceee631871c651d | |
parent | 4d6828ca04636d331f9a050f05b576e489022a1f (diff) | |
parent | e971ab1a229d1ef1d5c1e5e1ff52ec597c55270e (diff) | |
download | hurd-448d06e8dc5c06f111bb6baae7d456e174225729.tar.gz hurd-448d06e8dc5c06f111bb6baae7d456e174225729.tar.bz2 hurd-448d06e8dc5c06f111bb6baae7d456e174225729.zip |
Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd
29 files changed, 48 insertions, 79 deletions
diff --git a/ext2fs/dir.c b/ext2fs/dir.c index c0752466..a7eeaaa4 100644 --- a/ext2fs/dir.c +++ b/ext2fs/dir.c @@ -195,6 +195,8 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type, err = vm_map (mach_task_self (), &buf, buflen, 0, 1, memobj, 0, 0, prot, prot, 0); mach_port_deallocate (mach_task_self (), memobj); + if (err) + return err; inum = 0; diff --git a/libdiskfs/dir-renamed.c b/libdiskfs/dir-renamed.c index d73dc282..9b7ec3a6 100644 --- a/libdiskfs/dir-renamed.c +++ b/libdiskfs/dir-renamed.c @@ -132,7 +132,7 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname, if (tdp->dn_stat.st_nlink == diskfs_link_max - 1) { err = EMLINK; - return EMLINK; + goto out; } tdp->dn_stat.st_nlink++; tdp->dn_set_ctime = 1; diff --git a/libdiskfs/io-write.c b/libdiskfs/io-write.c index 26e0be43..2967c4c8 100644 --- a/libdiskfs/io-write.c +++ b/libdiskfs/io-write.c @@ -56,7 +56,6 @@ diskfs_S_io_write (struct protid *cred, goto out; } - err = 0; while (off + (off_t) datalen > np->allocsize) { err = diskfs_grow (np, off + datalen, cred); diff --git a/libihash/ihash.c b/libihash/ihash.c index fe9eaedf..be1c5803 100644 --- a/libihash/ihash.c +++ b/libihash/ihash.c @@ -26,13 +26,11 @@ #endif #include <errno.h> -#include <string.h> #include <stdlib.h> -#include <limits.h> #include <stdint.h> #include <assert.h> -#include <hurd/ihash.h> +#include "ihash.h" /* The prime numbers of the form 4 * i + 3 for some i, all greater diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c index 0c2da005..842665a5 100644 --- a/libports/manage-multithread.c +++ b/libports/manage-multithread.c @@ -91,9 +91,12 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, int global_timeout, void (*hook)()) { - volatile unsigned int nreqthreads; - volatile unsigned int totalthreads; - pthread_spinlock_t lock = PTHREAD_SPINLOCK_INITIALIZER; + /* totalthreads is the number of total threads created. nreqthreads + is the number of threads not currently servicing any client. The + initial values account for the main thread. */ + unsigned int totalthreads = 1; + unsigned int nreqthreads = 1; + pthread_attr_t attr; auto void * thread_function (void *); @@ -120,30 +123,22 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, /* msgt_unused = */ 0 }; - pthread_spin_lock (&lock); - assert (nreqthreads); - nreqthreads--; - if (nreqthreads != 0) - pthread_spin_unlock (&lock); - else + if (__atomic_sub_fetch (&nreqthreads, 1, __ATOMIC_RELAXED) == 0) /* No thread would be listening for requests, spawn one. */ { pthread_t pthread_id; error_t err; - totalthreads++; - nreqthreads++; - pthread_spin_unlock (&lock); + __atomic_add_fetch (&totalthreads, 1, __ATOMIC_RELAXED); + __atomic_add_fetch (&nreqthreads, 1, __ATOMIC_RELAXED); err = pthread_create (&pthread_id, &attr, thread_function, NULL); if (!err) pthread_detach (pthread_id); else { - pthread_spin_lock (&lock); - totalthreads--; - nreqthreads--; - pthread_spin_unlock (&lock); + __atomic_sub_fetch (&totalthreads, 1, __ATOMIC_RELAXED); + __atomic_sub_fetch (&nreqthreads, 1, __ATOMIC_RELAXED); /* There is not much we can do at this point. The code and design of the Hurd servers just don't handle thread creation failure. */ @@ -189,9 +184,7 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, status = 1; } - pthread_spin_lock (&lock); - nreqthreads++; - pthread_spin_unlock (&lock); + __atomic_add_fetch (&nreqthreads, 1, __ATOMIC_RELAXED); return status; } @@ -203,8 +196,7 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, int timeout; error_t err; - /* No need to lock as an approximation is sufficient. */ - adjust_priority (totalthreads); + adjust_priority (__atomic_load_n (&totalthreads, __ATOMIC_RELAXED)); if (hook) (*hook) (); @@ -224,30 +216,21 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, if (master) { - pthread_spin_lock (&lock); - if (totalthreads != 1) - { - pthread_spin_unlock (&lock); - goto startover; - } + if (__atomic_load_n (&totalthreads, __ATOMIC_RELAXED) != 1) + goto startover; } else { - pthread_spin_lock (&lock); - if (nreqthreads == 1) + if (__atomic_sub_fetch (&nreqthreads, 1, __ATOMIC_RELAXED) == 0) { /* No other thread is listening for requests, continue. */ - pthread_spin_unlock (&lock); + __atomic_add_fetch (&nreqthreads, 1, __ATOMIC_RELAXED); goto startover; } - nreqthreads--; - totalthreads--; - pthread_spin_unlock (&lock); + __atomic_sub_fetch (&totalthreads, 1, __ATOMIC_RELAXED); } return NULL; } - nreqthreads = 1; - totalthreads = 1; thread_function ((void *) 1); } diff --git a/libshouldbeinlibc/cacheq.c b/libshouldbeinlibc/cacheq.c index 5649903a..c1be59c0 100644 --- a/libshouldbeinlibc/cacheq.c +++ b/libshouldbeinlibc/cacheq.c @@ -19,7 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <string.h> -#include <malloc.h> +#include <stdlib.h> #include "cacheq.h" diff --git a/libshouldbeinlibc/canon-host.c b/libshouldbeinlibc/canon-host.c index ea6c7195..41068d30 100644 --- a/libshouldbeinlibc/canon-host.c +++ b/libshouldbeinlibc/canon-host.c @@ -20,7 +20,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <unistd.h> #include <string.h> #include <netdb.h> #include <netinet/in.h> diff --git a/libshouldbeinlibc/fsysops.c b/libshouldbeinlibc/fsysops.c index f26069df..dbcae672 100644 --- a/libshouldbeinlibc/fsysops.c +++ b/libshouldbeinlibc/fsysops.c @@ -25,6 +25,7 @@ #include <mach.h> #include <sys/mman.h> #include <hurd/fsys.h> +#include <string.h> /* Make FSYS readonly or writable. */ error_t diff --git a/libshouldbeinlibc/idvec-auth.c b/libshouldbeinlibc/idvec-auth.c index bb7f4afd..1858bd6a 100644 --- a/libshouldbeinlibc/idvec-auth.c +++ b/libshouldbeinlibc/idvec-auth.c @@ -22,6 +22,7 @@ #include <mach.h> #include <sys/mman.h> #include <hurd/auth.h> +#include <errno.h> #include "idvec.h" diff --git a/libshouldbeinlibc/idvec.c b/libshouldbeinlibc/idvec.c index d18871f9..7fdee104 100644 --- a/libshouldbeinlibc/idvec.c +++ b/libshouldbeinlibc/idvec.c @@ -20,7 +20,8 @@ #include <malloc.h> #include <string.h> -#include <idvec.h> + +#include "idvec.h" /* Return a new, empty, idvec, or NULL if there wasn't enough memory. */ struct idvec * diff --git a/libshouldbeinlibc/idvec.h b/libshouldbeinlibc/idvec.h index abbc273e..d6ec1553 100644 --- a/libshouldbeinlibc/idvec.h +++ b/libshouldbeinlibc/idvec.h @@ -22,7 +22,6 @@ #include <sys/types.h> #include <hurd/hurd_types.h> -#include <errno.h> #include <string.h> #include <features.h> diff --git a/libshouldbeinlibc/localhost.c b/libshouldbeinlibc/localhost.c index f0225116..9b7d4e09 100644 --- a/libshouldbeinlibc/localhost.c +++ b/libshouldbeinlibc/localhost.c @@ -19,9 +19,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <unistd.h> -#include <malloc.h> #include <string.h> #include <errno.h> +#include <stdlib.h> /* Return the name of the localhost. This is just a wrapper for gethostname, which takes care of allocating a big enough buffer, and caches the result diff --git a/libshouldbeinlibc/maptime.c b/libshouldbeinlibc/maptime.c index cacf4b6f..971e05f7 100644 --- a/libshouldbeinlibc/maptime.c +++ b/libshouldbeinlibc/maptime.c @@ -20,7 +20,6 @@ #include <fcntl.h> #include <hurd.h> -#include <mach.h> #include <device/device.h> #include "maptime.h" diff --git a/libshouldbeinlibc/nullauth.c b/libshouldbeinlibc/nullauth.c index 4ba10a76..3a98e558 100644 --- a/libshouldbeinlibc/nullauth.c +++ b/libshouldbeinlibc/nullauth.c @@ -19,8 +19,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <error.h> -#include <errno.h> #include <hurd.h> /* Obtain an empty authentication handle and use it for further diff --git a/libshouldbeinlibc/portxlate.c b/libshouldbeinlibc/portxlate.c index 8888e2c2..f78abbf1 100644 --- a/libshouldbeinlibc/portxlate.c +++ b/libshouldbeinlibc/portxlate.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <malloc.h> +#include <stdlib.h> #include <sys/types.h> #include <sys/mman.h> diff --git a/libshouldbeinlibc/shared-dom.c b/libshouldbeinlibc/shared-dom.c index 0f8efdf8..0115fced 100644 --- a/libshouldbeinlibc/shared-dom.c +++ b/libshouldbeinlibc/shared-dom.c @@ -18,10 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <unistd.h> -#include <malloc.h> #include <string.h> -#include <errno.h> /* Returns a pointer into HOST1 that is the part of the domain shared with HOST2. If the two do not share anything, the return value will point to diff --git a/libshouldbeinlibc/timefmt.c b/libshouldbeinlibc/timefmt.c index 7ce973bc..a28f58bd 100644 --- a/libshouldbeinlibc/timefmt.c +++ b/libshouldbeinlibc/timefmt.c @@ -338,8 +338,8 @@ fmt_past_time (struct timeval *tv, struct timeval *now, end = stpcpy (end, *dfmt); end = stpcpy (end, *sep); - end = stpcpy (end, *fmt); - + stpcpy (end, *fmt); + used = strftime (buf, width + 1, whole_fmt, &tm); } diff --git a/libshouldbeinlibc/ugids-argp.c b/libshouldbeinlibc/ugids-argp.c index dc076d27..43a54d70 100644 --- a/libshouldbeinlibc/ugids-argp.c +++ b/libshouldbeinlibc/ugids-argp.c @@ -20,12 +20,11 @@ #include <stdlib.h> #include <string.h> -#include <hurd.h> #include <ctype.h> -#include <unistd.h> #include <argp.h> #include <pwd.h> #include <grp.h> +#include <errno.h> #include "ugids.h" diff --git a/libshouldbeinlibc/ugids-auth.c b/libshouldbeinlibc/ugids-auth.c index d7ec9daa..0e4f84dc 100644 --- a/libshouldbeinlibc/ugids-auth.c +++ b/libshouldbeinlibc/ugids-auth.c @@ -18,9 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdlib.h> #include <hurd.h> +#include "idvec.h" #include "ugids.h" /* Make an auth port from UGIDS and return it in AUTH, using authority in diff --git a/libshouldbeinlibc/ugids-imply.c b/libshouldbeinlibc/ugids-imply.c index 9c2a8a2c..272ba664 100644 --- a/libshouldbeinlibc/ugids-imply.c +++ b/libshouldbeinlibc/ugids-imply.c @@ -18,8 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdlib.h> +#include <errno.h> +#include "idvec.h" #include "ugids.h" /* Mark as implied all gids in UGIDS that can be implied from its uids. */ diff --git a/libshouldbeinlibc/ugids-merge.c b/libshouldbeinlibc/ugids-merge.c index 924e1ed9..f97da07c 100644 --- a/libshouldbeinlibc/ugids-merge.c +++ b/libshouldbeinlibc/ugids-merge.c @@ -18,8 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdlib.h> +#include <errno.h> +#include "idvec.h" #include "ugids.h" static error_t diff --git a/libshouldbeinlibc/ugids-subtract.c b/libshouldbeinlibc/ugids-subtract.c index eecba20e..b56e397b 100644 --- a/libshouldbeinlibc/ugids-subtract.c +++ b/libshouldbeinlibc/ugids-subtract.c @@ -18,9 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdlib.h> -#include <stdio.h> +#include <errno.h> +#include "idvec.h" #include "ugids.h" /* Remove the gids in SUB from those in GIDS, except where they are implied diff --git a/libshouldbeinlibc/ugids-verify-auth.c b/libshouldbeinlibc/ugids-verify-auth.c index 28e3bdab..0e85b1b6 100644 --- a/libshouldbeinlibc/ugids-verify-auth.c +++ b/libshouldbeinlibc/ugids-verify-auth.c @@ -19,17 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #include <stdlib.h> -#include <string.h> #include <hurd.h> -#include <ctype.h> -#include <unistd.h> -#include <argp.h> -#include <pwd.h> -#include <grp.h> #include <hurd/paths.h> #include <hurd/password.h> +#include "idvec.h" #include "ugids.h" /* Accumulated information from authentication various passwords. */ diff --git a/libshouldbeinlibc/ugids-verify.c b/libshouldbeinlibc/ugids-verify.c index f9d45c63..5686bdf8 100644 --- a/libshouldbeinlibc/ugids-verify.c +++ b/libshouldbeinlibc/ugids-verify.c @@ -18,15 +18,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdlib.h> -#include <string.h> #include <hurd.h> -#include <ctype.h> -#include <unistd.h> #include <argp.h> -#include <pwd.h> -#include <grp.h> +#include "idvec.h" #include "ugids.h" /* Verify that we have the right to the ids in UGIDS, given that we already diff --git a/libshouldbeinlibc/ugids.c b/libshouldbeinlibc/ugids.c index 2b9b6b71..db1ce3c8 100644 --- a/libshouldbeinlibc/ugids.c +++ b/libshouldbeinlibc/ugids.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <string.h> +#include "idvec.h" #include "ugids.h" /* Return a new ugids structure, or 0 if an allocation error occurs. */ diff --git a/libshouldbeinlibc/ugids.h b/libshouldbeinlibc/ugids.h index 10e7a242..5d0e1134 100644 --- a/libshouldbeinlibc/ugids.h +++ b/libshouldbeinlibc/ugids.h @@ -24,6 +24,8 @@ #include <stdlib.h> /* For inline function stuff. */ #include <idvec.h> #include <features.h> +#include <errno.h> +#include <sys/types.h> #ifdef UGIDS_DEFINE_EI #define UGIDS_EI diff --git a/libshouldbeinlibc/wire.c b/libshouldbeinlibc/wire.c index bafc9599..b9540955 100644 --- a/libshouldbeinlibc/wire.c +++ b/libshouldbeinlibc/wire.c @@ -21,9 +21,9 @@ #include <link.h> #include <dlfcn.h> -#include <mach.h> #include <hurd.h> #include <error.h> +#include <elf.h> #pragma weak _DYNAMIC #pragma weak dlopen diff --git a/mach-defpager/Makefile b/mach-defpager/Makefile index 5a98d690..e38a0bea 100644 --- a/mach-defpager/Makefile +++ b/mach-defpager/Makefile @@ -35,6 +35,3 @@ LDFLAGS += -static include ../Makeconf MIGSFLAGS = -DSEQNOS - -# Don't even bother. -CFLAGS := $(filter-out -Wall,$(CFLAGS)) diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c index 8e466f72..a65a5fe1 100644 --- a/mach-defpager/default_pager.c +++ b/mach-defpager/default_pager.c @@ -879,12 +879,13 @@ pager_pages(pager, pages, numpages) offset += vm_page_size; } } else { - for (emap = &map[size]; map < emap; map++) + for (emap = &map[size]; map < emap; map++) { if ( ! no_block(*map) ) { if (actual++ < numpages) pages++->dpp_offset = offset; } - offset += vm_page_size; + offset += vm_page_size; + } } return actual; } |