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b8:1.18 PTH_1_0b7:1.18 PTH_1_0b6:1.18 PTH_1_0b5:1.17 PTH_1_0b4:1.16 PTH_1_0b3:1.14 PTH_1_0b2:1.14 PTH_1_0b1:1.13 PTH_0_9_21:1.11 PTH_0_9_20:1.11 PTH_0_9_19:1.11 PTH_0_9_18:1.11 PTH_0_9_17:1.11 PTH_0_9_16:1.11 PTH_0_9_15:1.11 PTH_0_9_14:1.11 PTH_0_9_13:1.11 PTH_0_9_12:1.9 PTH_0_9_11:1.7 PTH_0_9_10:1.7 PTH_0_9_9:1.6 PTH_0_9_8:1.6 PTH_0_9_7:1.4 PTH_0_9_6:1.4 PTH_0_9_5:1.3 PTH_0_9_4:1.3 PTH_0_9_3:1.3 PTH_0_9_2:1.3 PTH_0_9_1:1.1.1.1 PTH_0_9_0:1.1.1.1 RSE:1.1.1; locks; strict; comment @ * @; 1.32 date 2007.01.01.18.23.53; author rse; state Exp; branches; next 1.31; commitid 9DhdiirNzQPBIP0s; 1.31 date 2006.06.08.17.54.53; author rse; state Exp; branches; next 1.30; commitid x8N3mLVdQgkbdeAr; 1.30 date 2004.12.31.19.34.45; author rse; state Exp; branches; next 1.29; 1.29 date 2004.07.13.10.50.49; author rse; state Exp; branches; next 1.28; 1.28 date 2003.01.01.15.49.12; author rse; state Exp; branches; next 1.27; 1.27 date 2002.01.27.11.03.41; author rse; state Exp; branches; next 1.26; 1.26 date 2001.03.24.14.51.05; author rse; state Exp; branches; next 1.25; 1.25 date 2000.07.28.19.18.46; author rse; state Exp; branches; next 1.24; 1.24 date 2000.03.09.12.11.51; author rse; state Exp; branches 1.24.2.1; next 1.23; 1.23 date 99.12.30.21.59.01; author rse; state Exp; branches; next 1.22; 1.22 date 99.11.01.10.27.20; author rse; state Exp; branches; next 1.21; 1.21 date 99.10.31.11.46.13; author rse; state Exp; branches 1.21.2.1; next 1.20; 1.20 date 99.09.17.08.01.55; author rse; state Exp; branches; next 1.19; 1.19 date 99.08.19.15.08.53; author rse; state Exp; branches; next 1.18; 1.18 date 99.07.14.06.25.34; author rse; state Exp; branches; next 1.17; 1.17 date 99.07.10.14.21.17; author rse; state Exp; branches; next 1.16; 1.16 date 99.07.08.10.34.01; author rse; state Exp; branches; next 1.15; 1.15 date 99.07.08.10.19.11; author rse; state Exp; branches; next 1.14; 1.14 date 99.07.04.12.05.36; author rse; state Exp; branches; next 1.13; 1.13 date 99.06.27.15.38.04; author rse; state Exp; branches; next 1.12; 1.12 date 99.06.27.12.58.34; author rse; state Exp; branches; next 1.11; 1.11 date 99.06.01.09.55.26; author rse; state Exp; branches; next 1.10; 1.10 date 99.06.01.07.56.34; author rse; state Exp; branches; next 1.9; 1.9 date 99.05.30.10.06.25; author rse; state Exp; branches; next 1.8; 1.8 date 99.05.30.09.49.21; author rse; state Exp; branches; next 1.7; 1.7 date 99.05.28.09.05.13; author rse; state Exp; branches; next 1.6; 1.6 date 99.05.24.11.45.15; author rse; state Exp; branches; next 1.5; 1.5 date 99.05.24.07.58.13; author rse; state Exp; branches; next 1.4; 1.4 date 99.05.22.14.37.53; author rse; state Exp; branches; next 1.3; 1.3 date 99.05.14.10.06.02; author rse; state Exp; branches; next 1.2; 1.2 date 99.05.14.09.40.05; author rse; state Exp; branches; next 1.1; 1.1 date 99.05.13.12.18.16; author rse; state Exp; branches 1.1.1.1; next ; 1.24.2.1 date 2000.07.29.14.57.14; author rse; state Exp; branches; next ; 1.21.2.1 date 99.11.01.10.25.01; author rse; state Exp; branches; next ; 1.1.1.1 date 99.05.13.12.18.16; author rse; state Exp; branches; next ; desc @@ 1.32 log @Adjusted all copyright messages for new year 2007. @ text @/* ** GNU Pth - The GNU Portable Threads ** Copyright (c) 1999-2007 Ralf S. Engelschall ** ** This file is part of GNU Pth, a non-preemptive thread scheduling ** library which can be found at http://www.gnu.org/software/pth/. ** ** This 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. ** ** This 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 this library; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ** USA, or contact Ralf S. Engelschall . ** ** pth_time.c: Pth time calculations */ /* ``Real programmers confuse Christmas and Halloween because DEC 25 = OCT 31.'' -- Unknown */ #include "pth_p.h" #if cpp #define PTH_TIME_NOW (pth_time_t *)(0) #define PTH_TIME_ZERO &pth_time_zero #define PTH_TIME(sec,usec) { sec, usec } #define pth_time_equal(t1,t2) \ (((t1).tv_sec == (t2).tv_sec) && ((t1).tv_usec == (t2).tv_usec)) #endif /* cpp */ /* a global variable holding a zero time */ intern pth_time_t pth_time_zero = { 0L, 0L }; /* sleep for a specified amount of microseconds */ intern void pth_time_usleep(unsigned long usec) { #ifdef HAVE_USLEEP usleep((unsigned int )usec); #else struct timeval timeout; timeout.tv_sec = usec / 1000000; timeout.tv_usec = usec - (1000000 * timeout.tv_sec); while (pth_sc(select)(1, NULL, NULL, NULL, &timeout) < 0 && errno == EINTR) ; #endif return; } /* calculate: t1 = t2 */ #if cpp #if defined(HAVE_GETTIMEOFDAY_ARGS1) #define __gettimeofday(t) gettimeofday(t) #else #define __gettimeofday(t) gettimeofday(t, NULL) #endif #define pth_time_set(t1,t2) \ do { \ if ((t2) == PTH_TIME_NOW) \ __gettimeofday((t1)); \ else { \ (t1)->tv_sec = (t2)->tv_sec; \ (t1)->tv_usec = (t2)->tv_usec; \ } \ } while (0) #endif /* cpp */ /* time value constructor */ pth_time_t pth_time(long sec, long usec) { pth_time_t tv; tv.tv_sec = sec; tv.tv_usec = usec; return tv; } /* timeout value constructor */ pth_time_t pth_timeout(long sec, long usec) { pth_time_t tv; pth_time_t tvd; pth_time_set(&tv, PTH_TIME_NOW); tvd.tv_sec = sec; tvd.tv_usec = usec; pth_time_add(&tv, &tvd); return tv; } /* calculate: t1 <=> t2 */ intern int pth_time_cmp(pth_time_t *t1, pth_time_t *t2) { int rc; rc = t1->tv_sec - t2->tv_sec; if (rc == 0) rc = t1->tv_usec - t2->tv_usec; return rc; } /* calculate: t1 = t1 + t2 */ #if cpp #define pth_time_add(t1,t2) \ (t1)->tv_sec += (t2)->tv_sec; \ (t1)->tv_usec += (t2)->tv_usec; \ if ((t1)->tv_usec > 1000000) { \ (t1)->tv_sec += 1; \ (t1)->tv_usec -= 1000000; \ } #endif /* calculate: t1 = t1 - t2 */ #if cpp #define pth_time_sub(t1,t2) \ (t1)->tv_sec -= (t2)->tv_sec; \ (t1)->tv_usec -= (t2)->tv_usec; \ if ((t1)->tv_usec < 0) { \ (t1)->tv_sec -= 1; \ (t1)->tv_usec += 1000000; \ } #endif /* calculate: t1 = t1 / n */ intern void pth_time_div(pth_time_t *t1, int n) { long q, r; q = (t1->tv_sec / n); r = (((t1->tv_sec % n) * 1000000) / n) + (t1->tv_usec / n); if (r > 1000000) { q += 1; r -= 1000000; } t1->tv_sec = q; t1->tv_usec = r; return; } /* calculate: t1 = t1 * n */ intern void pth_time_mul(pth_time_t *t1, int n) { t1->tv_sec *= n; t1->tv_usec *= n; t1->tv_sec += (t1->tv_usec / 1000000); t1->tv_usec = (t1->tv_usec % 1000000); return; } /* convert a time structure into a double value */ intern double pth_time_t2d(pth_time_t *t) { double d; d = ((double)t->tv_sec*1000000 + (double)t->tv_usec) / 1000000; return d; } /* convert a time structure into a integer value */ intern int pth_time_t2i(pth_time_t *t) { int i; i = (t->tv_sec*1000000 + t->tv_usec) / 1000000; return i; } /* check whether time is positive */ intern int pth_time_pos(pth_time_t *t) { if (t->tv_sec > 0 && t->tv_usec > 0) return 1; else return 0; } @ 1.31 log @Adjusted all copyright messages for new year 2006 @ text @d3 1 a3 1 ** Copyright (c) 1999-2006 Ralf S. Engelschall @ 1.30 log @Adjusted all copyright messages for new year 2005. @ text @d3 1 a3 1 ** Copyright (c) 1999-2005 Ralf S. Engelschall @ 1.29 log @Adjusted all copyright messages for new year 2004. @ text @d3 1 a3 1 ** Copyright (c) 1999-2004 Ralf S. Engelschall @ 1.28 log @Adjusted all copyright messages for new year 2003. @ text @d3 1 a3 1 ** Copyright (c) 1999-2003 Ralf S. Engelschall @ 1.27 log @bump copyright year @ text @d3 1 a3 1 ** Copyright (c) 1999-2002 Ralf S. Engelschall @ 1.26 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2001 Ralf S. Engelschall @ 1.25 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2000 Ralf S. Engelschall @ 1.24 log @*** empty log message *** @ text @d152 1 a152 1 t1->tv_usec = (t1->tv_usec & 1000000); @ 1.24.2.1 log @*** empty log message *** @ text @d152 1 a152 1 t1->tv_usec = (t1->tv_usec % 1000000); @ 1.23 log @*** empty log message *** @ text @d75 1 a75 1 pth_time_t pth_time(int sec, int usec) d85 1 a85 1 pth_time_t pth_timeout(int sec, int usec) @ 1.22 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999 Ralf S. Engelschall @ 1.21 log @*** empty log message *** @ text @d2 1 a2 2 ** pth_time.c -- Pth time calculations ** d22 2 @ 1.21.2.1 log @*** empty log message *** @ text @d2 2 a3 1 ** GNU Pth - The GNU Portable Threads a22 2 ** ** pth_time.c: Pth time calculations @ 1.20 log @*** empty log message *** @ text @d12 1 a12 1 ** version 2 of the License, or (at your option) any later version. @ 1.19 log @*** empty log message *** @ text @d10 1 a10 1 ** modify it under the terms of the GNU Library General Public d17 1 a17 1 ** Library General Public License for more details. d19 1 a19 1 ** You should have received a copy of the GNU Library General Public @ 1.18 log @*** empty log message *** @ text @d24 4 a27 1 @ 1.17 log @*** empty log message *** @ text @d60 1 d66 2 a67 1 } @ 1.16 log @*** empty log message *** @ text @d47 1 a47 1 while (select(1, NULL, NULL, NULL, &timeout) < 0 && errno == EINTR) ; @ 1.15 log @*** empty log message *** @ text @d2 1 a2 1 ** pth_time.c -- PTH time calculations @ 1.14 log @*** empty log message *** @ text @d6 2 a7 2 ** This file is part of PTH, a non-preemptive thread scheduling library ** which can be found at http://www.gnu.org/software/pth/. @ 1.13 log @*** empty log message *** @ text @d7 1 a7 1 ** which can be found at http://www.engelschall.com/sw/pth/. @ 1.12 log @*** empty log message *** @ text @a59 1 do { \ d65 1 a65 2 } \ } while (0) @ 1.11 log @*** empty log message *** @ text @d60 8 a67 6 if ((t2) == PTH_TIME_NOW) \ __gettimeofday((t1)); \ else { \ (t1)->tv_sec = (t2)->tv_sec; \ (t1)->tv_usec = (t2)->tv_usec; \ } @ 1.10 log @*** empty log message *** @ text @d20 1 a20 1 ** License along with this library; if not, write to the Free @ 1.9 log @*** empty log message *** @ text @d96 3 a98 9 if ( t1->tv_sec == t2->tv_sec && t1->tv_usec == t2->tv_usec) rc = 0; else if ( t1->tv_sec < t2->tv_sec || ( t1->tv_sec == t2->tv_sec && t1->tv_usec < t2->tv_usec)) rc = -1; else rc = 1; @ 1.8 log @*** empty log message *** @ text @a51 10 /* time value constructor */ pth_time_t pth_time(int sec, int usec) { pth_time_t tv; tv.tv_sec = sec; tv.tv_usec = usec; return tv; } d67 23 @ 1.7 log @*** empty log message *** @ text @d53 1 a53 1 intern pth_time_t pth_time(int sec, int usec) @ 1.6 log @*** empty log message *** @ text @d27 8 d36 1 a36 1 pth_time_t pth_time_zero = { 0L, 0L }; d39 1 a39 1 void pth_time_usleep(unsigned long usec) d53 1 a53 1 pth_time_t pth_time(int sec, int usec) d63 1 a63 3 void _pth_time_set(pth_time_t *t1, pth_time_t *t2) { if (t2 == PTH_TIME_NOW) d65 1 a65 1 gettimeofday(t1); d67 1 a67 1 gettimeofday(t1, NULL); d69 6 a74 3 else { t1->tv_sec = t2->tv_sec; t1->tv_usec = t2->tv_usec; d76 1 a76 2 return; } d79 1 a79 1 int pth_time_cmp(pth_time_t *t1, pth_time_t *t2) d96 7 a102 7 void _pth_time_add(pth_time_t *t1, pth_time_t *t2) { t1->tv_sec += t2->tv_sec; t1->tv_usec += t2->tv_usec; if (t1->tv_usec > 1000000) { t1->tv_sec += 1; t1->tv_usec -= 1000000; d104 1 a104 2 return; } d107 7 a113 7 void _pth_time_sub(pth_time_t *t1, pth_time_t *t2) { t1->tv_sec -= t2->tv_sec; t1->tv_usec -= t2->tv_usec; if (t1->tv_usec < 0) { t1->tv_sec -= 1; t1->tv_usec += 1000000; d115 1 a115 2 return; } d118 1 a118 1 void pth_time_div(pth_time_t *t1, int n) d134 1 a134 1 void pth_time_mul(pth_time_t *t1, int n) d144 1 a144 1 double pth_time_t2d(pth_time_t *t) d153 1 a153 1 int pth_time_t2i(pth_time_t *t) d162 1 a162 1 int pth_time_pos(pth_time_t *t) @ 1.5 log @*** empty log message *** @ text @d34 1 a34 1 usleep(usec); @ 1.4 log @*** empty log message *** @ text @d6 1 a6 1 ** This file is part of PTH, a non-preemtive thread scheduling library @ 1.3 log @*** empty log message *** @ text @a0 40 /* ==================================================================== * Copyright (c) 1999 Ralf S. Engelschall. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by * Ralf S. Engelschall ." * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by * Ralf S. Engelschall ." * * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== */ d2 21 a22 2 ** Non-Preemtive Scheduler Library (PTH) ** pth_time.c -- time handling code @ 1.2 log @*** empty log message *** @ text @d76 1 a76 1 void pth_time_set(pth_time_t *t1, pth_time_t *t2) d109 1 a109 1 void pth_time_add(pth_time_t *t1, pth_time_t *t2) d121 1 a121 1 void pth_time_sub(pth_time_t *t1, pth_time_t *t2) @ 1.1 log @Initial revision @ text @d52 1 a52 1 void pth_usleep(unsigned long usec) d165 18 @ 1.1.1.1 log @Import of PTH into CVS @ text @@