Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/ntirpc/misc/timespec.h
$ cat -n /usr/include/ntirpc/misc/timespec.h 1 /*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 2012-2017 Red Hat, Inc. and/or its affiliates. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 4. Neither the name of the University nor the names of its contributors 15 * may be used to endorse or promote products derived from this software 16 * without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)time.h 8.5 (Berkeley) 5/4/95 31 * $FreeBSD: head/sys/sys/time.h 224732 2011-08-09 14:06:50Z jonathan $ 32 */ 33 34 #ifndef TIMESPEC_H 35 36 /* Convert to coarse milliseconds with round up */ 37 #define timespec_ms(tsp) \ 38 ((tsp)->tv_sec * 1000 + ((tsp)->tv_nsec + 999999) / 1000000) 39 40 /* Operations on timespecs */ 41 #define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) 42 #define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) 43 #ifndef timespeccmp 44 #define timespeccmp(tvp, uvp, cmp) \ 45 (((tvp)->tv_sec == (uvp)->tv_sec) ? \ 46 ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ 47 ((tvp)->tv_sec cmp (uvp)->tv_sec)) 48 #endif /* timespeccmp */ 49 #ifndef timespecadd 50 #define timespecadd(tsp, usp, vsp) \ 51 do { \ 52 (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ 53 (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ 54 if ((vsp)->tv_nsec >= 1000000000L) { \ 55 (vsp)->tv_sec++; \ 56 (vsp)->tv_nsec -= 1000000000L; \ 57 } \ 58 } while (0) 59 #endif /* timespecadd */ 60 61 #define timespec_adds(vvp, s) \ 62 do { \ 63 (vvp)->tv_sec += s; \ 64 } while (0) 65 66 #define timespec_addms(vvp, ms) \ 67 do { \ 68 (vvp)->tv_sec += (ms) / 1000; \ 69 (vvp)->tv_nsec += (((ms) % 1000) * 1000000); \ 70 if ((vvp)->tv_nsec >= 1000000000) { \ 71 (vvp)->tv_sec++; \ 72 (vvp)->tv_nsec -= 1000000000; \ 73 } \ 74 } while (0) 75 76 #ifndef timespecsub 77 #define timespecsub(tsp, usp, vsp) \ 78 do { \ 79 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ 80 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ 81 if ((vsp)->tv_nsec < 0) { \ 82 (vsp)->tv_sec--; \ 83 (vsp)->tv_nsec += 1000000000L; \ 84 } \ 85 } while (0) 86 #endif /* timespecsub */ 87 88 #endif /* TIMESPEC_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™