libs/libc/inttypes: add support for imaxdiv

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
Juha Niskanen 2024-04-23 09:02:35 +03:00 committed by Alan Carvalho de Assis
parent d484e85bb9
commit 3348d03f95
4 changed files with 49 additions and 3 deletions

View File

@ -348,7 +348,13 @@
* function.
*/
typedef void *imaxdiv_t; /* Dummy type since imaxdiv is not yet supported */
struct imaxdiv_s
{
intmax_t quot;
intmax_t rem;
};
typedef struct imaxdiv_s imaxdiv_t;
/****************************************************************************
* Public Function Prototypes

View File

@ -18,4 +18,5 @@
#
# ##############################################################################
target_sources(c PRIVATE lib_imaxabs.c lib_strtoimax.c lib_strtoumax.c)
target_sources(c PRIVATE lib_imaxabs.c lib_imaxdiv.c lib_strtoimax.c
lib_strtoumax.c)

View File

@ -20,7 +20,7 @@
# Add the inttypes C files to the build
CSRCS += lib_imaxabs.c lib_strtoimax.c lib_strtoumax.c
CSRCS += lib_imaxabs.c lib_imaxdiv.c lib_strtoimax.c lib_strtoumax.c
# Add the inttypes directory to the build

View File

@ -0,0 +1,39 @@
/****************************************************************************
* libs/libc/inttypes/lib_imaxdiv.c
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <inttypes.h>
/****************************************************************************
* Public Functions
****************************************************************************/
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t f;
f.quot = numer / denom;
f.rem = numer % denom;
return f;
}