Browse Source

libc_regex: __libc_lock primitives are actually available on uClibc

__libc_lock primitives are actually available on uClibc when threading
support is enable, so in this case they can be used.

It also fixes the following compiler warnings:

In file included from libc/misc/regex/regex.c:55:
libc/misc/regex/regex_internal.h:49:1: warning: "__libc_lock_define" redefined
[SNIP]
libc/misc/regex/regex_internal.h:50:1: warning: "__libc_lock_init" redefined
[SNIP]
libc/misc/regex/regex_internal.h:51:1: warning: "__libc_lock_lock" redefined
[SNIP]
libc/misc/regex/regex_internal.h:52:1: warning: "__libc_lock_unlock" redefined

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit 65f9ccdafd008abd9892dfc46fb9737ec4d964c5)

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Carmelo Amoroso 14 years ago
parent
commit
62174f7330
2 changed files with 6 additions and 3 deletions
  1. 4 0
      libc/misc/regex/regex_internal.h
  2. 2 3
      libc/misc/regex/regexec.c

+ 4 - 0
libc/misc/regex/regex_internal.h

@@ -46,10 +46,14 @@
 # include <stdint.h>
 #endif
 
+#ifdef __UCLIBC_HAS_THREADS__
+#include <bits/libc-lock.h>
+#else
 #define __libc_lock_define(CLASS, NAME)
 #define __libc_lock_init(NAME)   do { } while (0)
 #define __libc_lock_lock(NAME)   do { } while (0)
 #define __libc_lock_unlock(NAME) do { } while (0)
+#endif
 
 #undef gettext
 #undef gettext_noop

+ 2 - 3
libc/misc/regex/regexec.c

@@ -222,7 +222,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
 {
   reg_errcode_t err;
   int start, length;
-#ifndef __UCLIBC__ /* libc_lock_lock does not exist */
+#ifdef __UCLIBC_HAS_THREADS__
   re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
 #endif
 
@@ -382,10 +382,9 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
   regmatch_t *pmatch;
   int nregs, rval;
   int eflags = 0;
-#ifndef __UCLIBC__ /* libc_lock_lock does not exist */
+#ifdef __UCLIBC_HAS_THREADS__
   re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
 #endif
-
   /* Check for out-of-range.  */
   if (BE (start < 0 || start > length, 0))
     return -1;