* MODULES.html.sh: Add pthread, nproc.
* lib/nproc.c: New file.
* lib/nproc.h: New file.
* lib/pthread.in.h: New file.
* m4/pthread.m4: New file.
* modules/nproc: New file.
* modules/pthread: New file.
+2009-03-25 Paul Eggert <eggert@cs.ucla.edu>
+
+ New modules nproc, pthread, contributed by Glen Lenker.
+
+ * MODULES.html.sh: Add pthread, nproc.
+ * lib/nproc.c: New file.
+ * lib/nproc.h: New file.
+ * lib/pthread.in.h: New file.
+ * m4/pthread.m4: New file.
+ * modules/nproc: New file.
+ * modules/pthread: New file.
+
2009-03-24 Simon Josefsson <simon@josefsson.org>
* modules/unicase/locale-language-tests (test_locale_language_LDADD):
#!/bin/sh
#
-# Copyright (C) 2002-2008 Free Software Foundation, Inc.
+# Copyright (C) 2002-2009 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
func_module posix_spawn-internal
func_module posix_spawnp
func_module printf-posix
+ func_module pthread
func_module readlink
func_module realloc-posix
func_module recv
func_module getloadavg
func_module getpagesize
func_module getusershell
+ func_module nproc
func_module physmem
func_module posixver
func_module progname
--- /dev/null
+/* Detect the number of processors.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Glen Lenker. */
+
+#include <config.h>
+#include "nproc.h"
+
+#include <unistd.h>
+
+/* Return the total number of processors. The result is guaranteed to
+ be at least 1. */
+unsigned long int
+num_processors (void)
+{
+#ifdef _SC_NPROCESSORS_ONLN
+ long int nprocs = sysconf (_SC_NPROCESSORS_ONLN);
+ if (0 < nprocs)
+ return nprocs;
+#endif
+
+ return 1;
+}
--- /dev/null
+/* Detect the number of processors.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Glen Lenker. */
+
+unsigned long int num_processors (void);
--- /dev/null
+/* Implement a trivial subset of the pthreads library.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Glen Lenker. */
+
+#ifndef PTHREAD_H_
+# define PTHREAD_H_
+
+# include <errno.h>
+# include <stdlib.h>
+
+typedef int pthread_t;
+typedef int pthread_attr_t;
+
+static int
+pthread_create (pthread_t *restrict thread,
+ const pthread_attr_t *restrict attr,
+ void *(*start_routine)(void*), void *restrict arg)
+{
+ errno = EAGAIN;
+ return -1;
+}
+
+static int
+pthread_join (pthread_t thread, void **value_ptr)
+{
+ abort ();
+ return -1;
+}
+
+#endif /* PTHREAD_H_ */
--- /dev/null
+# pthread.m4
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_PTHREAD_CHECK],
+ [AC_CHECK_HEADERS_ONCE([pthread.h])
+
+ LIB_PTHREAD=
+ PTHREAD_H=
+ if test "$ac_cv_header_pthread_h" = yes; then
+ gl_saved_libs=$LIBS
+ AC_SEARCH_LIBS([pthread_create], [pthread],
+ [if test "$ac_cv_search_pthread_create" != "none required"; then
+ LIB_PTHREAD="$ac_cv_search_pthread_create"
+ fi])
+ LIBS="$gl_saved_libs"
+ else
+ PTHREAD_H='pthread.h'
+ fi
+
+ AC_SUBST([LIB_PTHREAD])
+ AC_SUBST([PTHREAD_H])
+
+ AC_REQUIRE([AC_C_RESTRICT])
+])
--- /dev/null
+Description:
+Detect the number of processors
+
+Files:
+lib/nproc.h
+lib/nproc.c
+
+Depends-on:
+unistd
+
+configure.ac:
+AC_LIBOBJ([nproc])
+
+Makefile.am:
+
+Include:
+#include "nproc.h"
+
+License:
+GPL
+
+Maintainer:
+Glen Lenker and Paul Eggert
--- /dev/null
+Description:
+Implement a trivial subset of the pthreads library.
+
+Files:
+lib/pthread.in.h
+m4/pthread.m4
+
+Depends-on:
+
+configure.ac:
+gl_PTHREAD_CHECK
+
+Makefile.am:
+BUILT_SOURCES += $(PTHREAD_H)
+
+# We need the following in order to create <pthread.h> when the system
+# doesn't have one that works with the given compiler.
+pthread.h: pthread.in.h
+ ln -f pthread.in.h $@ || cp pthread.in.h $@
+MOSTLYCLEANFILES += pthread.h
+
+Include:
+#include <pthread.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Glen Lenker and Paul Eggert