Deleted Added
full compact
clock.c (132943) clock.c (141858)
1/*
2 * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 */
13
14#include <sm/gen.h>
1/*
2 * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 */
13
14#include <sm/gen.h>
15SM_RCSID("@(#)$Id: clock.c,v 1.45 2004/01/19 19:32:08 ca Exp $")
15SM_RCSID("@(#)$Id: clock.c,v 1.46 2004/08/03 19:57:22 ca Exp $")
16#include <unistd.h>
17#include <time.h>
18#include <errno.h>
19#if SM_CONF_SETITIMER
20# include <sys/time.h>
21#endif /* SM_CONF_SETITIMER */
22#include <sm/heap.h>
23#include <sm/debug.h>

--- 34 unchanged lines hidden (view full) ---

58*/
59
60static SM_EVENT *volatile SmEventQueue; /* head of event queue */
61static SM_EVENT *volatile SmFreeEventList; /* list of free events */
62
63SM_EVENT *
64sm_seteventm(intvl, func, arg)
65 int intvl;
16#include <unistd.h>
17#include <time.h>
18#include <errno.h>
19#if SM_CONF_SETITIMER
20# include <sys/time.h>
21#endif /* SM_CONF_SETITIMER */
22#include <sm/heap.h>
23#include <sm/debug.h>

--- 34 unchanged lines hidden (view full) ---

58*/
59
60static SM_EVENT *volatile SmEventQueue; /* head of event queue */
61static SM_EVENT *volatile SmFreeEventList; /* list of free events */
62
63SM_EVENT *
64sm_seteventm(intvl, func, arg)
65 int intvl;
66 void (*func)();
66 void (*func)__P((int));
67 int arg;
68{
69 ENTER_CRITICAL();
70 if (SmFreeEventList == NULL)
71 {
72 SmFreeEventList = (SM_EVENT *) sm_pmalloc_x(sizeof *SmFreeEventList);
73 SmFreeEventList->ev_link = NULL;
74 }

--- 6 unchanged lines hidden (view full) ---

81** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
82** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
83** DOING.
84*/
85
86SM_EVENT *
87sm_sigsafe_seteventm(intvl, func, arg)
88 int intvl;
67 int arg;
68{
69 ENTER_CRITICAL();
70 if (SmFreeEventList == NULL)
71 {
72 SmFreeEventList = (SM_EVENT *) sm_pmalloc_x(sizeof *SmFreeEventList);
73 SmFreeEventList->ev_link = NULL;
74 }

--- 6 unchanged lines hidden (view full) ---

81** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
82** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
83** DOING.
84*/
85
86SM_EVENT *
87sm_sigsafe_seteventm(intvl, func, arg)
88 int intvl;
89 void (*func)();
89 void (*func)__P((int));
90 int arg;
91{
92 register SM_EVENT **evp;
93 register SM_EVENT *ev;
94#if SM_CONF_SETITIMER
95 auto struct timeval now, nowi, ival;
96 auto struct itimerval itime;
97#else /* SM_CONF_SETITIMER */

--- 291 unchanged lines hidden (view full) ---

389 (ev->ev_pid != mypid ||
390#if SM_CONF_SETITIMER
391 timercmp(&ev->ev_time, &now, <=)
392#else /* SM_CONF_SETITIMER */
393 ev->ev_time <= now
394#endif /* SM_CONF_SETITIMER */
395 ))
396 {
90 int arg;
91{
92 register SM_EVENT **evp;
93 register SM_EVENT *ev;
94#if SM_CONF_SETITIMER
95 auto struct timeval now, nowi, ival;
96 auto struct itimerval itime;
97#else /* SM_CONF_SETITIMER */

--- 291 unchanged lines hidden (view full) ---

389 (ev->ev_pid != mypid ||
390#if SM_CONF_SETITIMER
391 timercmp(&ev->ev_time, &now, <=)
392#else /* SM_CONF_SETITIMER */
393 ev->ev_time <= now
394#endif /* SM_CONF_SETITIMER */
395 ))
396 {
397 void (*f)();
397 void (*f)__P((int));
398 int arg;
399 pid_t pid;
400
401 /* process the event on the top of the queue */
402 ev = SmEventQueue;
403 SmEventQueue = SmEventQueue->ev_link;
404
405 /* we must be careful in here because ev_func may not return */

--- 86 unchanged lines hidden (view full) ---

492**
493** Side Effects:
494** waits for intvl time. However, other events can
495** be run during that interval.
496*/
497
498
499# if !HAVE_NANOSLEEP
398 int arg;
399 pid_t pid;
400
401 /* process the event on the top of the queue */
402 ev = SmEventQueue;
403 SmEventQueue = SmEventQueue->ev_link;
404
405 /* we must be careful in here because ev_func may not return */

--- 86 unchanged lines hidden (view full) ---

492**
493** Side Effects:
494** waits for intvl time. However, other events can
495** be run during that interval.
496*/
497
498
499# if !HAVE_NANOSLEEP
500static void sm_endsleep __P((void));
500static void sm_endsleep __P((int));
501static bool volatile SmSleepDone;
502# endif /* !HAVE_NANOSLEEP */
503
504#ifndef SLEEP_T
505# define SLEEP_T unsigned int
506#endif /* ! SLEEP_T */
507
508SLEEP_T

--- 111 unchanged lines hidden (view full) ---

620 if (was_held > 0)
621 (void) sm_blocksignal(SIGALRM);
622 return (SLEEP_T) 0;
623#endif /* HAVE_NANOSLEEP */
624}
625
626#if !HAVE_NANOSLEEP
627static void
501static bool volatile SmSleepDone;
502# endif /* !HAVE_NANOSLEEP */
503
504#ifndef SLEEP_T
505# define SLEEP_T unsigned int
506#endif /* ! SLEEP_T */
507
508SLEEP_T

--- 111 unchanged lines hidden (view full) ---

620 if (was_held > 0)
621 (void) sm_blocksignal(SIGALRM);
622 return (SLEEP_T) 0;
623#endif /* HAVE_NANOSLEEP */
624}
625
626#if !HAVE_NANOSLEEP
627static void
628sm_endsleep()
628sm_endsleep(ignore)
629 int ignore;
629{
630 /*
631 ** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
632 ** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
633 ** DOING.
634 */
635
636 SmSleepDone = true;
637}
638#endif /* !HAVE_NANOSLEEP */
639
630{
631 /*
632 ** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
633 ** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
634 ** DOING.
635 */
636
637 SmSleepDone = true;
638}
639#endif /* !HAVE_NANOSLEEP */
640