common/ssleep.c

///////////////////////////////////////////////////////////////////////////////
// Filename: ssleep.c
///////////////////////////////////////////////////////////////////////////////
// Purpose: higher resolution sleep function
///////////////////////////////////////////////////////////////////////////////
// History:
// ========
//
// Date     Time     Name      Description   
// -------- -------- --------  ------------------------------------------------
// 96/02/29 13:14:26 muellerg: created
//
///////////////////////////////////////////////////////////////////////////////


// Feature test switches ///////////////////////////// Feature test switches //
    /* NONE */



// System headers /////////////////////////////////////////// System headers //

#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>


// Local headers ///////////////////////////////////////////// Local headers //

#include "../common.h"



// Macros /////////////////////////////////////////////////////////// Macros //
    /* NONE */



// File scope objects /////////////////////////////////// File scope objects //
    /* NONE */



// External variables, functions, and classes ///////////// External objects //
    /* NONE */



// Signal catching functions ///////////////////// Signal catching functions //
    /* NONE */



// Structures, unions, and class definitions /////////////////// Definitions //
    /* NONE */



// Functions and class implementation /// Functions and class implementation //

/*
 * ssleep() - sleeps for a specific time given in microseconds
 *
 * ssleeps is designed for sleeping only less than a second (could easily
 * be changed)
 */

void ssleep(int usecs)
{
    fd_set zero;
    FD_ZERO(&zero);

    struct timeval t;
    t.tv_sec  = 0;
    t.tv_usec = usecs;

#ifndef hpux
    select(0, &zero, &zero, &zero, &t);
#else
    select(0, NULL, NULL, NULL, &t);
#endif
}



// Main /////////////////////////////////////////////////////////////// Main //
    /* NONE */