2007-09-09 03:50:59 +08:00
|
|
|
/****************************************************************************
|
2014-06-27 04:23:21 +08:00
|
|
|
* net/utils/net_dsec2timeval.c
|
2007-09-09 03:50:59 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-09-09 03:50:59 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-09-09 03:50:59 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-09-09 03:50:59 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2015-02-16 05:18:35 +08:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
2007-09-09 19:58:50 +08:00
|
|
|
#include <nuttx/clock.h>
|
2007-09-09 03:50:59 +08:00
|
|
|
|
2014-06-29 07:25:18 +08:00
|
|
|
#include "utils/utils.h"
|
2007-09-09 03:50:59 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
2014-06-27 04:23:21 +08:00
|
|
|
* Public Functions
|
2007-09-09 03:50:59 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 06:33:14 +08:00
|
|
|
* Name: net_dsec2timeval
|
2007-09-09 03:50:59 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Convert a decisecond timeout value to a struct timeval. Needed by
|
|
|
|
* getsockopt() to report timeout values.
|
|
|
|
*
|
2018-03-13 23:52:27 +08:00
|
|
|
* Input Parameters:
|
2007-09-09 03:50:59 +08:00
|
|
|
* dsec The decisecond value to convert
|
|
|
|
* tv The struct timeval to receive the converted value
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-27 04:23:21 +08:00
|
|
|
void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv)
|
2007-09-09 03:50:59 +08:00
|
|
|
{
|
2009-12-15 23:57:25 +08:00
|
|
|
uint16_t remainder;
|
2007-09-09 03:50:59 +08:00
|
|
|
tv->tv_sec = dsec / DSEC_PER_SEC;
|
|
|
|
remainder = dsec - tv->tv_sec * DSEC_PER_SEC;
|
|
|
|
tv->tv_usec = remainder * USEC_PER_DSEC;
|
|
|
|
}
|