Debian Codegraph @

Xpjproject/pjlib/src/pj/types.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <pj/types.h>
20 #include <pj/os.h>
21
22 PJ_DEF(void) pj_time_val_normalize(pj_time_val *t)
23 {
24 PJ_CHECK_STACK();
25
26 if (t->msec >= 1000) {
27 t->sec += (t->msec / 1000);
28 t->msec = (t->msec % 1000);
29 }
30 else if (t->msec <= -1000) {
31 do {
32 t->sec--;
33 t->msec += 1000;
34 } while (t->msec <= -1000);
35 }
36
37 if (t->sec >= 1 && t->msec < 0) {
38 t->sec--;
39 t->msec += 1000;
40
41 } else if (t->sec < 0 && t->msec > 0) {
42 t->sec++;
43 t->msec -= 1000;
44 }
45 }