-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <netdb.h>
#include <stdlib.h>
#include <sys/time.h>
-#include "gai_misc.h"
+#include <gai_misc.h>
int
{
struct waitlist waitlist[ent];
struct requestlist *requestlist[ent];
+#ifndef DONT_NEED_GAI_MISC_COND
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+#endif
int cnt;
- int dummy;
+ unsigned int cntr = 1;
int none = 1;
int result;
if (requestlist[cnt] != NULL)
{
+#ifndef DONT_NEED_GAI_MISC_COND
waitlist[cnt].cond = &cond;
+#endif
waitlist[cnt].next = requestlist[cnt]->waiting;
- waitlist[cnt].counterp = &dummy;
+ waitlist[cnt].counterp = &cntr;
waitlist[cnt].sigevp = NULL;
waitlist[cnt].caller_pid = 0; /* Not needed. */
requestlist[cnt]->waiting = &waitlist[cnt];
which we must remove. So defer cancelation for now. */
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate);
+#ifdef DONT_NEED_GAI_MISC_COND
+ result = 0;
+ GAI_MISC_WAIT (result, cntr, timeout, 1);
+#else
if (timeout == NULL)
result = pthread_cond_wait (&cond, &__gai_requests_mutex);
else
result = pthread_cond_timedwait (&cond, &__gai_requests_mutex,
&abstime);
}
+#endif
/* Now remove the entry in the waiting list for all requests
which didn't terminate. */
/* Now it's time to restore the cancelation state. */
pthread_setcancelstate (oldstate, NULL);
+#ifndef DONT_NEED_GAI_MISC_COND
/* Release the conditional variable. */
if (pthread_cond_destroy (&cond) != 0)
/* This must never happen. */
abort ();
+#endif
if (result != 0)
{
/* An error occurred. Possibly it's EINTR. We have to translate
the timeout error report of `pthread_cond_timedwait' to the
form expected from `gai_suspend'. */
- if (__builtin_expect (result, ETIMEDOUT) == ETIMEDOUT)
+ if (__glibc_likely (result == ETIMEDOUT))
result = EAI_AGAIN;
else if (result == EINTR)
result = EAI_INTR;