/* * Copyright (c) 2006 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. */ #include "sm/generic.h" SM_RCSID("@(#)$Id: us_sleep.c,v 1.3 2006/11/18 15:19:42 ca Exp $") #include "sm/assert.h" #include "sm/error.h" #include "sm/misc.h" /* ** SM_US_SLEEP -- sleep() for some microseconds ** ** Parameters: ** us -- microseconds to sleep ** ** Returns: ** usual return code */ sm_ret_T sm_us_sleep(long us) { int r; #if HAVE_NANOSLEEP struct timespec sl_ts; sl_ts.tv_sec = 0; sl_ts.tv_nsec = us * 100; r = nanosleep(&sl_ts, NULL); #elif HAVE_SELECT struct timeval sl_tv; sl_tv.tv_sec = 0; sl_tv.tv_usec = us; r = select(0, NULL, NULL, NULL, &sl_tv); #else #ifdef ENOIMPL r = sm_err_perm(ENOIMPL); #else r = sm_err_perm(ENOSYS); #endif #endif return r; }