* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
2005-03-27 03:57:38 +02:00
|
|
|
/* Initial implementation:
|
|
|
|
Copyright (c) 2002 Robert Drehmel
|
|
|
|
All rights reserved.
|
2005-05-02 05:50:11 +02:00
|
|
|
|
* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
2005-03-27 03:57:38 +02:00
|
|
|
As long as the above copyright statement and this notice remain
|
|
|
|
unchanged, you can do what ever you want with this file. */
|
|
|
|
|
|
|
|
#include <stdint.h> /* for uint8_t */
|
|
|
|
#include <string.h> /* for memcpy () prototype */
|
|
|
|
|
|
|
|
static void *lwork (const void *, const void *, size_t *, size_t,
|
|
|
|
int (*) (const void *, const void *), int);
|
|
|
|
|
|
|
|
extern "C" void *
|
|
|
|
lsearch (const void *key, void *base, size_t *nelp, size_t width,
|
|
|
|
int (*compar) (const void *, const void *))
|
|
|
|
{
|
|
|
|
return lwork (key, base, nelp, width, compar, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void *
|
|
|
|
lfind (const void *key, const void *base, size_t *nelp, size_t width,
|
|
|
|
int (*compar) (const void *, const void *))
|
|
|
|
{
|
|
|
|
return lwork (key, base, nelp, width, compar, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
lwork (const void *key, const void *base, size_t *nelp, size_t width,
|
|
|
|
int (*compar) (const void *, const void *), int addelem)
|
|
|
|
{
|
|
|
|
uint8_t *ep, *endp;
|
|
|
|
|
|
|
|
/* Cast to an integer value first to avoid the warning for removing
|
|
|
|
'const' via a cast. */
|
|
|
|
ep = (uint8_t *) (uintptr_t)base;
|
|
|
|
for (endp = (uint8_t *) (ep + width * *nelp); ep < endp; ep += width)
|
|
|
|
if (compar (key, ep) == 0)
|
|
|
|
return ep;
|
|
|
|
|
|
|
|
/* lfind () shall return when the key was not found. */
|
|
|
|
if (!addelem)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* lsearch () adds the key to the end of the table and increments
|
|
|
|
the number of elements. */
|
|
|
|
memcpy (endp, key, width);
|
|
|
|
++*nelp;
|
|
|
|
|
|
|
|
return endp;
|
|
|
|
}
|