mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-16 01:22:18 +03:00
regex: adapt to locking regime instead of depending on pthread
Instead of depending on pthread, adapt to whatever thread modules are in use. Problem reported by Ludovic Courtès in <http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00082.html> and by Mats Erik Andersson in <http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00100.html>. * lib/regex_internal.h (lock_define, lock_init, lock_fini): Support either the 'lock' module, or the 'pthread' module, or no module. (lock_lock, lock_unlock): New macros. * lib/regexec.c (regexec, re_search_stub): Use the new macros. * modules/lock, modules/pthread (configure.ac): Add module indicator. * modules/regex (Depends-on): Remove pthread.
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -1,3 +1,19 @@
|
|||||||
|
2013-05-29 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
regex: adapt to locking regime instead of depending on pthread
|
||||||
|
Instead of depending on pthread, adapt to whatever thread
|
||||||
|
modules are in use. Problem reported by Ludovic Courtès in
|
||||||
|
<http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00082.html>
|
||||||
|
and by Mats Erik Andersson in
|
||||||
|
<http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00100.html>.
|
||||||
|
* lib/regex_internal.h (lock_define, lock_init, lock_fini):
|
||||||
|
Support either the 'lock' module, or the 'pthread' module, or
|
||||||
|
no module.
|
||||||
|
(lock_lock, lock_unlock): New macros.
|
||||||
|
* lib/regexec.c (regexec, re_search_stub): Use the new macros.
|
||||||
|
* modules/lock, modules/pthread (configure.ac): Add module indicator.
|
||||||
|
* modules/regex (Depends-on): Remove pthread.
|
||||||
|
|
||||||
2013-05-22 Eric Blake <eblake@redhat.com>
|
2013-05-22 Eric Blake <eblake@redhat.com>
|
||||||
|
|
||||||
getgroups: document portability issues
|
getgroups: document portability issues
|
||||||
|
@@ -33,24 +33,33 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#if defined _LIBC
|
#ifdef _LIBC
|
||||||
# include <bits/libc-lock.h>
|
# include <bits/libc-lock.h>
|
||||||
#endif
|
|
||||||
/* Use __libc_lock_define (, NAME) if the library defines the macro,
|
|
||||||
and if the compiler is known to support empty macro arguments. */
|
|
||||||
#if (defined __libc_lock_define \
|
|
||||||
&& ((defined __GNUC__ && !defined __STRICT_ANSI__) \
|
|
||||||
|| (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__)))
|
|
||||||
# define lock_define(name) __libc_lock_define (, name)
|
# define lock_define(name) __libc_lock_define (, name)
|
||||||
# define lock_init(lock) (__libc_lock_init (lock), 0)
|
# define lock_init(lock) (__libc_lock_init (lock), 0)
|
||||||
# define lock_fini(lock) 0
|
# define lock_fini(lock) 0
|
||||||
#else
|
# define lock_lock(lock) __libc_lock_lock (lock)
|
||||||
|
# define lock_unlock(lock) __libc_lock_unlock (lock)
|
||||||
|
#elif defined GNULIB_LOCK
|
||||||
|
# include "glthread/lock.h"
|
||||||
|
# define lock_define(name) gl_lock_define (, name)
|
||||||
|
# define lock_init(lock) glthread_lock_init (&(lock))
|
||||||
|
# define lock_fini(lock) glthread_lock_destroy (&(lock))
|
||||||
|
# define lock_lock(lock) glthread_lock_lock (&(lock))
|
||||||
|
# define lock_unlock(lock) glthread_lock_unlock (&(lock))
|
||||||
|
#elif defined GNULIB_PTHREAD
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# define lock_define(name) pthread_mutex_t name;
|
# define lock_define(name) pthread_mutex_t name;
|
||||||
# define lock_init(lock) pthread_mutex_init (&(lock), 0)
|
# define lock_init(lock) pthread_mutex_init (&(lock), 0)
|
||||||
# define lock_fini(lock) pthread_mutex_destroy (&(lock))
|
# define lock_fini(lock) pthread_mutex_destroy (&(lock))
|
||||||
# define __libc_lock_lock(lock) pthread_mutex_lock (&(lock))
|
# define lock_lock(lock) pthread_mutex_lock (&(lock))
|
||||||
# define __libc_lock_unlock(lock) pthread_mutex_unlock (&(lock))
|
# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
|
||||||
|
#else
|
||||||
|
# define lock_define(name)
|
||||||
|
# define lock_init(lock) 0
|
||||||
|
# define lock_fini(lock) 0
|
||||||
|
# define lock_lock(lock) ((void) 0)
|
||||||
|
# define lock_unlock(lock) ((void) 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* In case that the system doesn't have isblank(). */
|
/* In case that the system doesn't have isblank(). */
|
||||||
|
@@ -244,14 +244,14 @@ regexec (preg, string, nmatch, pmatch, eflags)
|
|||||||
length = strlen (string);
|
length = strlen (string);
|
||||||
}
|
}
|
||||||
|
|
||||||
__libc_lock_lock (dfa->lock);
|
lock_lock (dfa->lock);
|
||||||
if (preg->no_sub)
|
if (preg->no_sub)
|
||||||
err = re_search_internal (preg, string, length, start, length,
|
err = re_search_internal (preg, string, length, start, length,
|
||||||
length, 0, NULL, eflags);
|
length, 0, NULL, eflags);
|
||||||
else
|
else
|
||||||
err = re_search_internal (preg, string, length, start, length,
|
err = re_search_internal (preg, string, length, start, length,
|
||||||
length, nmatch, pmatch, eflags);
|
length, nmatch, pmatch, eflags);
|
||||||
__libc_lock_unlock (dfa->lock);
|
lock_unlock (dfa->lock);
|
||||||
return err != REG_NOERROR;
|
return err != REG_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
|
|||||||
else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
|
else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
|
||||||
last_start = 0;
|
last_start = 0;
|
||||||
|
|
||||||
__libc_lock_lock (dfa->lock);
|
lock_lock (dfa->lock);
|
||||||
|
|
||||||
eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
|
eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
|
||||||
eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
|
eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
|
||||||
@@ -494,7 +494,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
|
|||||||
}
|
}
|
||||||
re_free (pmatch);
|
re_free (pmatch);
|
||||||
out:
|
out:
|
||||||
__libc_lock_unlock (dfa->lock);
|
lock_unlock (dfa->lock);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ threadlib
|
|||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
gl_LOCK
|
gl_LOCK
|
||||||
|
gl_MODULE_INDICATOR([lock])
|
||||||
|
|
||||||
Makefile.am:
|
Makefile.am:
|
||||||
lib_SOURCES += glthread/lock.h glthread/lock.c
|
lib_SOURCES += glthread/lock.h glthread/lock.c
|
||||||
|
@@ -13,6 +13,7 @@ time
|
|||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
gl_PTHREAD_CHECK
|
gl_PTHREAD_CHECK
|
||||||
|
gl_MODULE_INDICATOR([pthread])
|
||||||
|
|
||||||
Makefile.am:
|
Makefile.am:
|
||||||
BUILT_SOURCES += $(PTHREAD_H)
|
BUILT_SOURCES += $(PTHREAD_H)
|
||||||
|
@@ -24,7 +24,6 @@ memmove [test $ac_use_included_regex = yes]
|
|||||||
mbrtowc [test $ac_use_included_regex = yes]
|
mbrtowc [test $ac_use_included_regex = yes]
|
||||||
mbsinit [test $ac_use_included_regex = yes]
|
mbsinit [test $ac_use_included_regex = yes]
|
||||||
nl_langinfo [test $ac_use_included_regex = yes]
|
nl_langinfo [test $ac_use_included_regex = yes]
|
||||||
pthread [test $ac_use_included_regex = yes]
|
|
||||||
stdbool [test $ac_use_included_regex = yes]
|
stdbool [test $ac_use_included_regex = yes]
|
||||||
stdint [test $ac_use_included_regex = yes]
|
stdint [test $ac_use_included_regex = yes]
|
||||||
wchar [test $ac_use_included_regex = yes]
|
wchar [test $ac_use_included_regex = yes]
|
||||||
|
Reference in New Issue
Block a user