Annotation of embedaddon/iperf/src/t_timer.c, revision 1.1.1.3

1.1       misho       1: /*
                      2:  * iperf, Copyright (c) 2014, The Regents of the University of
                      3:  * California, through Lawrence Berkeley National Laboratory (subject
                      4:  * to receipt of any required approvals from the U.S. Dept. of
                      5:  * Energy).  All rights reserved.
                      6:  *
                      7:  * If you have questions about your rights to use or distribute this
                      8:  * software, please contact Berkeley Lab's Technology Transfer
                      9:  * Department at TTD@lbl.gov.
                     10:  *
                     11:  * NOTICE.  This software is owned by the U.S. Department of Energy.
                     12:  * As such, the U.S. Government has been granted for itself and others
                     13:  * acting on its behalf a paid-up, nonexclusive, irrevocable,
                     14:  * worldwide license in the Software to reproduce, prepare derivative
                     15:  * works, and perform publicly and display publicly.  Beginning five
                     16:  * (5) years after the date permission to assert copyright is obtained
                     17:  * from the U.S. Department of Energy, and subject to any subsequent
                     18:  * five (5) year renewals, the U.S. Government is granted for itself
                     19:  * and others acting on its behalf a paid-up, nonexclusive,
                     20:  * irrevocable, worldwide license in the Software to reproduce,
                     21:  * prepare derivative works, distribute copies to the public, perform
                     22:  * publicly and display publicly, and to permit others to do so.
                     23:  *
                     24:  * This code is distributed under a BSD style license, see the LICENSE
                     25:  * file for complete information.
                     26:  */
1.1.1.2   misho      27: #include "iperf_config.h"
                     28: 
                     29: #ifdef HAVE_STDINT_H
                     30: #include <stdint.h>
                     31: #endif
1.1       misho      32: #include <stdio.h>
                     33: #include <stdlib.h>
                     34: #include <unistd.h>
                     35: #include <sys/time.h>
                     36: 
                     37: #include "timer.h"
1.1.1.2   misho      38: #include "iperf_time.h"
1.1       misho      39: 
                     40: 
                     41: static int flag;
                     42: 
                     43: 
                     44: static void
1.1.1.2   misho      45: timer_proc( TimerClientData client_data, struct iperf_time* nowP )
1.1       misho      46: {
                     47:     flag = 1;
                     48: }
                     49: 
                     50: 
1.1.1.3 ! misho      51: int
1.1       misho      52: main(int argc, char **argv)
                     53: {
                     54:     Timer *tp;
                     55: 
                     56:     flag = 0;
1.1.1.2   misho      57:     tp = tmr_create(NULL, timer_proc, JunkClientData, 3000000, 0);
1.1       misho      58:     if (!tp)
                     59:     {
                     60:        printf("failed to create timer\n");
                     61:        exit(-1);
                     62:     }
                     63: 
                     64:     sleep(2);
                     65: 
1.1.1.2   misho      66:     tmr_run(NULL);
1.1       misho      67:     if (flag)
                     68:     {
                     69:        printf("timer should not have expired\n");
                     70:        exit(-1);
                     71:     }
                     72:     sleep(1);
                     73: 
1.1.1.2   misho      74:     tmr_run(NULL);
1.1       misho      75:     if (!flag)
                     76:     {
                     77:        printf("timer should have expired\n");
                     78:        exit(-2);
                     79:     }
                     80: 
                     81:     tmr_destroy();
                     82:     exit(0);
                     83: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>