+2002-12-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/generic/bits/stdio-lock.h (_IO_lock_trylock): New define.
+
2002-12-07 Roland McGrath <roland@redhat.com>
* sysdeps/generic/libc-tls.c (__libc_setup_tls): Reintroduce changes
/* Thread package specific definitions of stream lock type. Generic version.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
+#define _IO_lock_trylock(_name) __libc_lock_trylock_recursive (_name)
#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)
-nptl 0.11 by Ulrich Drepper
+nptl 0.12 by Ulrich Drepper
2002-12-07 Ulrich Drepper <drepper@redhat.com>
+ * Makefile (CFLAGS-ftrylockfile.c): Add -D_IO_MTSAFE_IO.
+
+ * cleanup.c: Move declarations of _GI_pthread_cleanup_push and
+ _GI_pthread_cleanup_pop to pthreadP.h.
+
+ * ftrylockfile.c: Use _IO_lock_trylock instead of
+ pthread_mutex_trylock.
+
+ * pthreadP.h (CANCEL_ASYNC): Use __pthread_setcanceltype.
+ (CANCEL_RESET): Likewise.
+ (__pthread_setcanceltype_): Declare.
+ (__pthread_mutex_lock_internal): Declare.
+ (__pthread_mutex_unlock_internal): Declare.
+ (__pthread_once_internal): Declare.
+ (pthread_cleanup_push): Redefine using _GI_pthread_cleanup_push.
+ (pthread_cleanup_pop): Redefine using _GI_pthread_cleanup_pop.
+
+ * pthread_cond_timedwait.c: Use INTUSE is calls to pthread_mutex_lock
+ and pthread_mutex_unlock.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_mutex_lock.c: Use INTDEF to define alias if needed.
+ * pthread_mutex_unlock.c: Likewise.
+
+ * pthread_setcanceltype.c: Add additional alias
+ __pthread_setcanceltype.
+
+ * sem_unlink.c (sem_unlink): Use __pthread_once with INTDEF.
+ * sem_open.c (sem_open): Likewise.
+ Use __libc_open, __libc_write, and __libc_close instead of
+ open, write, and close respectively.
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_lock_trylock_internal):
+ Rewrite as statement expression since it must return a value.
+
+ * pthread_cancel.c: Use __pthread_kill instead of pthread_kill.
+ * sysdeps/unix/sysv/linux/pthread_kill.c: Define additional alias
+ __pthread_kill.
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Define additional
+ alias __pthread_once_internal.
+
* sysdeps/unix/sysv/linux/raise.c: Use libc_hidden_def for raise.
2002-12-06 Ulrich Drepper <drepper@redhat.com>
endif
CFLAGS-flockfile.c = -D_IO_MTSAFE_IO
+CFLAGS-ftrylockfile.c = -D_IO_MTSAFE_IO
CFLAGS-funlockfile.c = -D_IO_MTSAFE_IO
ifeq ($(build-static),yes)
THREAD_SETMEM (self, cleanup, buffer);
}
-extern void _GI_pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
- void (*routine) (void *), void *arg)
- attribute_hidden;
strong_alias (_pthread_cleanup_push, _GI_pthread_cleanup_push)
if (execute)
buffer->__routine (buffer->__arg);
}
-extern void _GI_pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
- int execute) attribute_hidden;
strong_alias (_pthread_cleanup_pop, _GI_pthread_cleanup_pop)
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <errno.h>
#include <pthread.h>
#include <stdio.h>
-#include <libio.h>
+#include <bits/stdio-lock.h>
int
ftrylockfile (stream)
FILE *stream;
{
- return pthread_mutex_trylock (stream->_lock);
+ return _IO_lock_trylock (*stream->_lock);
}
strong_alias (ftrylockfile, _IO_ftrylockfile)
/* Set cancellation mode to asynchronous. */
#define CANCEL_ASYNC(oldtype) \
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)
+ __pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)
/* Reset to previous cancellation mode. */
#define CANCEL_RESET(oldtype) \
- pthread_setcanceltype (oldtype, NULL)
+ __pthread_setcanceltype (oldtype, NULL)
/* Function performing the cancellation. */
extern void __do_cancel (char *currentframe)
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex);
extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex);
extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
extern int __pthread_setspecific (pthread_key_t key, const void *value);
extern int __pthread_once (pthread_once_t *once_control,
void (*init_routine) (void));
+extern int __pthread_once_internal (pthread_once_t *once_control,
+ void (*init_routine) (void));
extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
void (*child) (void));
+extern int __pthread_kill (pthread_t threadid, int signo);
+extern int __pthread_setcanceltype (int type, int *oldtype);
+
+/* Special versions which use non-exported functions. */
+extern void _GI_pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg)
+ attribute_hidden;
+#undef pthread_cleanup_push
+#define pthread_cleanup_push(routine,arg) \
+ { struct _pthread_cleanup_buffer _buffer; \
+ _GI_pthread_cleanup_push (&_buffer, (routine), (arg));
+
+extern void _GI_pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
+ int execute) attribute_hidden;
+#undef pthread_cleanup_pop
+#define pthread_cleanup_pop(execute) \
+ _GI_pthread_cleanup_pop (&_buffer, (execute)); }
#endif /* pthreadP.h */
{
/* The cancellation handler will take care of marking the
thread as canceled. */
- pthread_kill (th, SIGCANCEL);
+ __pthread_kill (th, SIGCANCEL);
break;
}
lll_mutex_lock (cond->__data.__lock);
/* Release the mutex. This might fail. */
- err = pthread_mutex_unlock (mutex);
+ err = INTUSE(__pthread_mutex_unlock) (mutex);
if (__builtin_expect (err != 0, 0))
{
lll_mutex_unlock (cond->__data.__lock);
lll_mutex_unlock (cond->__data.__lock);
/* We have to get the mutex before returning. */
- err = pthread_mutex_lock (mutex);
+ err = INTUSE(__pthread_mutex_lock) (mutex);
if (err != 0)
/* XXX Unconditionally overwrite the result of the wait? */
result = err;
lll_mutex_lock (cond->__data.__lock);
/* Release the mutex. This might fail. */
- err = pthread_mutex_unlock (mutex);
+ err = INTUSE(__pthread_mutex_unlock) (mutex);
if (__builtin_expect (err != 0, 0))
{
lll_mutex_unlock (cond->__data.__lock);
lll_mutex_unlock (cond->__data.__lock);
/* We have to get the mutex before returning. */
- err = pthread_mutex_lock (mutex);
+ err = INTUSE(__pthread_mutex_lock) (mutex);
/* Cancellation handling. */
CANCELLATION_P (THREAD_SELF);
return 0;
}
strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
+INTDEF(__pthread_mutex_lock)
return 0;
}
strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
+INTDEF(__pthread_mutex_unlock)
int
-pthread_setcanceltype (type, oldtype)
+__pthread_setcanceltype (type, oldtype)
int type;
int *oldtype;
{
return 0;
}
+strong_alias (__pthread_setcanceltype, pthread_setcanceltype)
int fd;
/* Determine where the shmfs is mounted. */
- pthread_once (&__namedsem_once, __where_is_shmfs);
+ INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs);
/* If we don't know the mount points there is nothing we can do. Ever. */
if (mountpoint.dir == NULL)
/* If the semaphore object has to exist simply open it. */
if ((oflag & O_CREAT) == 0)
{
- fd = open (finalname, oflag | O_NOFOLLOW);
+ fd = __libc_open (finalname, oflag | O_NOFOLLOW);
if (fd == -1)
/* Return. errno is already set. */
memset ((char *) &initsem + sizeof (struct sem), '\0',
sizeof (sem_t) - sizeof (struct sem));
- if (TEMP_FAILURE_RETRY (write (fd, &initsem, sizeof (sem_t)))
+ if (TEMP_FAILURE_RETRY (__libc_write (fd, &initsem, sizeof (sem_t)))
!= sizeof (sem_t)
/* Adjust the permission. */
|| fchmod (fd, mode) != 0)
}
/* We don't need the file descriptor anymore. */
- close (fd);
+ __libc_close (fd);
return result;
}
size_t namelen;
/* Determine where the shmfs is mounted. */
- pthread_once (&__namedsem_once, __where_is_shmfs);
+ INTDEF(__pthread_once) (&__namedsem_once, __where_is_shmfs);
/* If we don't know the mount points there is nothing we can do. Ever. */
if (mountpoint.dir == NULL)
-/* libc-internal interface for mutex locks. LinuxThreads version.
+/* libc-internal interface for mutex locks. NPTL version.
Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
/* Try to lock the recursive named lock variable. */
#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
-# define __libc_lock_trylock_recursive(NAME) \
- do { \
+# define __libc_lock_trylock_recursive(NAME) \
+ ({ \
int result = 0; \
void *self = THREAD_SELF; \
if ((NAME).owner != self) \
} \
else \
++(NAME).cnt; \
- } while (0)
+ result; \
+ })
#else
# define __libc_lock_trylock_recursive(NAME) \
__libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
.size __pthread_once,.-__pthread_once
+ .globl __pthread_once_internal
+__pthread_once_internal = __pthread_once
+
.globl pthread_once
pthread_once = __pthread_once
int
-pthread_kill (threadid, signo)
+__pthread_kill (threadid, signo)
pthread_t threadid;
int signo;
{
/* We have a special syscall to do the work. */
return INLINE_SYSCALL (tkill, 2, pd->tid, signo);
}
+strong_alias (__pthread_kill, pthread_kill)
/* Thread package specific definitions of stream lock type. Generic version.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
+#define _IO_lock_trylock(_name) __libc_lock_trylock_recursive (_name)
#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)