mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
2002-12-17 Jakub Jelinek <jakub@redhat.com> * malloc/thread-m.h (mutex_init, mutex_lock, mutex_trylock, mutex_unlock): If not building NPTL, use __libc_maybe_call2 if available, otherwise __libc_maybe_call. * sysdeps/unix/sysv/linux/x86_64/recv.c: Add support for cancellation handling. * sysdeps/unix/sysv/linux/x86_64/send.c: Likewise.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2002-12-17 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* malloc/thread-m.h (mutex_init, mutex_lock, mutex_trylock,
|
||||||
|
mutex_unlock): If not building NPTL, use __libc_maybe_call2 if
|
||||||
|
available, otherwise __libc_maybe_call.
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/recv.c: Add support for
|
||||||
|
cancellation handling.
|
||||||
|
* sysdeps/unix/sysv/linux/x86_64/send.c: Likewise.
|
||||||
|
|
||||||
2002-12-17 Isamu Hasegawa <isamu@yamato.ibm.com>
|
2002-12-17 Isamu Hasegawa <isamu@yamato.ibm.com>
|
||||||
|
|
||||||
* posix/regcomp.c (free_workarea_compile): Free the new member
|
* posix/regcomp.c (free_workarea_compile): Free the new member
|
||||||
|
@ -35,21 +35,42 @@
|
|||||||
|
|
||||||
#ifdef PTHREAD_MUTEX_INITIALIZER
|
#ifdef PTHREAD_MUTEX_INITIALIZER
|
||||||
|
|
||||||
/* mutex */
|
|
||||||
__libc_lock_define (typedef, mutex_t)
|
__libc_lock_define (typedef, mutex_t)
|
||||||
|
|
||||||
/* Even if not linking with libpthread, ensure usability of mutex as
|
#if defined(LLL_LOCK_INITIALIZER) && !defined(NOT_IN_libc)
|
||||||
an `in use' flag, see also the NO_THREADS case below. Assume
|
|
||||||
pthread_mutex_t is at least one int wide. */
|
/* Assume NPTL. */
|
||||||
|
|
||||||
|
#define mutex_init(m) __libc_lock_init (*(m))
|
||||||
|
#define mutex_lock(m) __libc_lock_lock (*(m))
|
||||||
|
#define mutex_trylock(m) __libc_lock_trylock (*(m))
|
||||||
|
#define mutex_unlock(m) __libc_lock_unlock (*(m))
|
||||||
|
|
||||||
|
#elif defined(__libc_maybe_call2)
|
||||||
|
|
||||||
#define mutex_init(m) \
|
#define mutex_init(m) \
|
||||||
__libc_lock_init (*m)
|
__libc_maybe_call2 (pthread_mutex_init, (m, NULL), (*(int *)(m) = 0))
|
||||||
#define mutex_lock(m) \
|
#define mutex_lock(m) \
|
||||||
__libc_lock_lock (*m)
|
__libc_maybe_call2 (pthread_mutex_lock, (m), ((*(int *)(m) = 1), 0))
|
||||||
#define mutex_trylock(m) \
|
#define mutex_trylock(m) \
|
||||||
__libc_lock_trylock (*m)
|
__libc_maybe_call2 (pthread_mutex_trylock, (m), \
|
||||||
|
(*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0)))
|
||||||
#define mutex_unlock(m) \
|
#define mutex_unlock(m) \
|
||||||
__libc_lock_unlock (*m)
|
__libc_maybe_call2 (pthread_mutex_unlock, (m), (*(int *)(m) = 0))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define mutex_init(m) \
|
||||||
|
__libc_maybe_call (__pthread_mutex_init, (m, NULL), (*(int *)(m) = 0))
|
||||||
|
#define mutex_lock(m) \
|
||||||
|
__libc_maybe_call (__pthread_mutex_lock, (m), ((*(int *)(m) = 1), 0))
|
||||||
|
#define mutex_trylock(m) \
|
||||||
|
__libc_maybe_call (__pthread_mutex_trylock, (m), \
|
||||||
|
(*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0)))
|
||||||
|
#define mutex_unlock(m) \
|
||||||
|
__libc_maybe_call (__pthread_mutex_unlock, (m), (*(int *)(m) = 0))
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define thread_atfork(prepare, parent, child) \
|
#define thread_atfork(prepare, parent, child) \
|
||||||
(__pthread_atfork != NULL ? __pthread_atfork(prepare, parent, child) : 0)
|
(__pthread_atfork != NULL ? __pthread_atfork(prepare, parent, child) : 0)
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
2002-12-17 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* Makefile (libpthread-shared-only-routines): Add pt-allocrtsig.
|
||||||
|
(tests): Depend on $(objpfx)tst-cancel-wrappers.out.
|
||||||
|
($(objpfx)tst-cancel-wrappers.out): New rule.
|
||||||
|
* tst-cancel-wrappers.sh: New test.
|
||||||
|
* tst-locale1.c: Include signal.h.
|
||||||
|
(uselocale): Test static linking of __libc_current_sigrt*.
|
||||||
|
|
||||||
|
2002-12-17 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* Makefile (tests): Add tst-cancel6.
|
||||||
|
* tst-cancel6.c: New file
|
||||||
|
|
||||||
2002-12-17 Jakub Jelinek <jakub@redhat.com>
|
2002-12-17 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P):
|
* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P):
|
||||||
|
@ -107,6 +107,8 @@ libpthread-routines = init events \
|
|||||||
herrno res pt-allocrtsig \
|
herrno res pt-allocrtsig \
|
||||||
pthread_kill_other_threads
|
pthread_kill_other_threads
|
||||||
|
|
||||||
|
libpthread-shared-only-routines = pt-allocrtsig
|
||||||
|
|
||||||
libpthread-nonshared = pthread_atfork
|
libpthread-nonshared = pthread_atfork
|
||||||
|
|
||||||
|
|
||||||
@ -126,6 +128,7 @@ tests = tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
|
|||||||
tst-fork1 tst-fork2 tst-fork3 \
|
tst-fork1 tst-fork2 tst-fork3 \
|
||||||
tst-atfork1 \
|
tst-atfork1 \
|
||||||
tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
|
tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
|
||||||
|
tst-cancel6 \
|
||||||
tst-cleanup1 \
|
tst-cleanup1 \
|
||||||
tst-flock1 tst-flock2 \
|
tst-flock1 tst-flock2 \
|
||||||
tst-signal1 tst-signal2 tst-signal3 \
|
tst-signal1 tst-signal2 tst-signal3 \
|
||||||
@ -241,3 +244,14 @@ $(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
|
|||||||
|
|
||||||
generated += crti.S defs.h pt-initfini.s
|
generated += crti.S defs.h pt-initfini.s
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq (no,$(cross-compiling))
|
||||||
|
ifeq (yes,$(build-shared))
|
||||||
|
tests: $(objpfx)tst-cancel-wrappers.out
|
||||||
|
$(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
|
||||||
|
$(SHELL) $< $(common-objpfx)libc_pic.a \
|
||||||
|
$(common-objpfx)libc.a \
|
||||||
|
$(objpfx)libpthread_pic.a \
|
||||||
|
$(objpfx)libpthread.a > $@
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
94
nptl/tst-cancel-wrappers.sh
Normal file
94
nptl/tst-cancel-wrappers.sh
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# Test whether all cancellable functions are cancellable.
|
||||||
|
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
# This file is part of the GNU C Library.
|
||||||
|
# Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
|
||||||
|
|
||||||
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# The GNU C Library 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
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with the GNU C Library; if not, write to the Free
|
||||||
|
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
# 02111-1307 USA.
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
( nm -P $1; echo 'end[end]:' ) | awk ' BEGIN {
|
||||||
|
C["accept"]=1
|
||||||
|
C["close"]=1
|
||||||
|
C["connect"]=1
|
||||||
|
C["creat"]=1
|
||||||
|
C["fcntl"]=1
|
||||||
|
C["fsync"]=1
|
||||||
|
C["llseek"]=1
|
||||||
|
C["lseek"]=1
|
||||||
|
C["msgrcv"]=1
|
||||||
|
C["msgsnd"]=1
|
||||||
|
C["msync"]=1
|
||||||
|
C["nanosleep"]=1
|
||||||
|
C["open"]=1
|
||||||
|
C["open64"]=1
|
||||||
|
C["pause"]=1
|
||||||
|
C["poll"]=1
|
||||||
|
C["pread"]=1
|
||||||
|
C["pread64"]=1
|
||||||
|
C["pselect"]=1
|
||||||
|
C["pwrite"]=1
|
||||||
|
C["pwrite64"]=1
|
||||||
|
C["read"]=1
|
||||||
|
C["readv"]=1
|
||||||
|
C["recv"]=1
|
||||||
|
C["recvfrom"]=1
|
||||||
|
C["recvmsg"]=1
|
||||||
|
C["select"]=1
|
||||||
|
C["send"]=1
|
||||||
|
C["sendmsg"]=1
|
||||||
|
C["sendto"]=1
|
||||||
|
C["sigpause"]=1
|
||||||
|
C["sigsuspend"]=1
|
||||||
|
C["sigwait"]=1
|
||||||
|
C["sigwaitinfo"]=1
|
||||||
|
C["system"]=1
|
||||||
|
C["tcdrain"]=1
|
||||||
|
C["wait"]=1
|
||||||
|
C["waitid"]=1
|
||||||
|
C["waitpid"]=1
|
||||||
|
C["write"]=1
|
||||||
|
C["writev"]=1
|
||||||
|
C["__xpg_sigpause"]=1
|
||||||
|
}
|
||||||
|
/:$/ {
|
||||||
|
if (seen)
|
||||||
|
{
|
||||||
|
if (!seen_enable || !seen_disable)
|
||||||
|
{
|
||||||
|
printf "in '$1'(%s) %s'\''s cancellation missing\n", object, seen
|
||||||
|
ret = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
seen=""
|
||||||
|
seen_enable=""
|
||||||
|
seen_disable=""
|
||||||
|
object=gensub(/^.*\[(.*)\]:$/,"\\1","",$0)
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if (C[$1] && $2 ~ /^[TW]$/)
|
||||||
|
seen=$1
|
||||||
|
else if ($1 ~ /^__(libc|pthread)_enable_asynccancel$/ && $2 == "U")
|
||||||
|
seen_enable=1
|
||||||
|
else if ($1 ~ /^__(libc|pthread)_disable_asynccancel$/ && $2 == "U")
|
||||||
|
seen_disable=1
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
exit ret
|
||||||
|
}' || exit
|
||||||
|
shift
|
||||||
|
done
|
79
nptl/tst-cancel6.c
Normal file
79
nptl/tst-cancel6.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library 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
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void *
|
||||||
|
tf (void *arg)
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
fgets (buf, sizeof (buf), arg);
|
||||||
|
/* This call should never return. */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_test (void)
|
||||||
|
{
|
||||||
|
int fd[2];
|
||||||
|
if (pipe (fd) != 0)
|
||||||
|
{
|
||||||
|
puts ("pipe failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *fp = fdopen (fd[0], "r");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
puts ("fdopen failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_t th;
|
||||||
|
if (pthread_create (&th, NULL, tf, fp) != 0)
|
||||||
|
{
|
||||||
|
puts ("pthread_create failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep (1);
|
||||||
|
|
||||||
|
if (pthread_cancel (th) != 0)
|
||||||
|
{
|
||||||
|
puts ("pthread_cancel failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *r;
|
||||||
|
if (pthread_join (th, &r) != 0)
|
||||||
|
{
|
||||||
|
puts ("pthread_join failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r != PTHREAD_CANCELED;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
@ -4,10 +4,14 @@
|
|||||||
#include "../locale/tst-C-locale.c"
|
#include "../locale/tst-C-locale.c"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
/* This is never called, just here to get pthreads linked in. */
|
/* This is never called, just here to get pthreads linked in. */
|
||||||
void
|
int
|
||||||
useless (void)
|
useless (void)
|
||||||
{
|
{
|
||||||
pthread_create (0, 0, 0, 0);
|
pthread_create (0, 0, 0, 0);
|
||||||
|
/* This is to check __libc_current_sigrt* can be used in statically
|
||||||
|
linked apps. */
|
||||||
|
return SIGRTMIN;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sysdep.h>
|
#include <sysdep-cancel.h>
|
||||||
|
|
||||||
/* Read N bytes into BUF from socket FD.
|
/* Read N bytes into BUF from socket FD.
|
||||||
Returns the number read or -1 for errors. */
|
Returns the number read or -1 for errors. */
|
||||||
@ -26,8 +26,16 @@
|
|||||||
ssize_t
|
ssize_t
|
||||||
__libc_recv (int fd, void *buf, size_t n, int flags)
|
__libc_recv (int fd, void *buf, size_t n, int flags)
|
||||||
{
|
{
|
||||||
|
if (SINGLE_THREAD_P)
|
||||||
return INLINE_SYSCALL (recvfrom, 6, fd, buf, n, flags, NULL, NULL);
|
return INLINE_SYSCALL (recvfrom, 6, fd, buf, n, flags, NULL, NULL);
|
||||||
|
|
||||||
|
int oldtype = LIBC_CANCEL_ASYNC ();
|
||||||
|
|
||||||
|
ssize_t result = INLINE_SYSCALL (recvfrom, 6, fd, buf, n, flags, NULL, NULL);
|
||||||
|
|
||||||
|
LIBC_CANCEL_RESET (oldtype);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_alias (__libc_recv, __recv)
|
weak_alias (__libc_recv, __recv)
|
||||||
|
@ -18,13 +18,22 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sysdep.h>
|
#include <sysdep-cancel.h>
|
||||||
|
|
||||||
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
|
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
|
||||||
ssize_t
|
ssize_t
|
||||||
__libc_send (int fd, const void *buf, size_t n, int flags)
|
__libc_send (int fd, const void *buf, size_t n, int flags)
|
||||||
{
|
{
|
||||||
|
if (SINGLE_THREAD_P)
|
||||||
return INLINE_SYSCALL (sendto, 6, fd, buf, n, flags, NULL, NULL);
|
return INLINE_SYSCALL (sendto, 6, fd, buf, n, flags, NULL, NULL);
|
||||||
|
|
||||||
|
int oldtype = LIBC_CANCEL_ASYNC ();
|
||||||
|
|
||||||
|
ssize_t result = INLINE_SYSCALL (sendto, 6, fd, buf, n, flags, NULL, NULL);
|
||||||
|
|
||||||
|
LIBC_CANCEL_RESET (oldtype);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_alias (__libc_send, __send)
|
weak_alias (__libc_send, __send)
|
||||||
|
Reference in New Issue
Block a user