Add ldiv() and lldiv() too

This commit is contained in:
Gregory Nutt 2015-08-14 08:45:59 -06:00
parent 301f215638
commit 6df94096ca
3 changed files with 32 additions and 3 deletions

View File

@ -10820,4 +10820,8 @@
From Macs Neklyudov (2015-08-13).
* fs/vfs/fs_poll.c: If we fail to setup the poll for any file
descriptor, for any reason, set the POLLERR bit (2015-08-13).
* libc/stdlib: Add support for div() to the C library. From
OrbitalFox (2015-08-14).
* libc/stdlib: Might as well add ldiv() and lldiv() to since
these are equivalent to div() with long and long long types,
respectively, instead of int (2015-08-14).

View File

@ -105,6 +105,26 @@ struct div_s
typedef struct div_s div_t;
/* Structure type returned by the ldiv() function. */
struct ldiv_s
{
long quot; /* Quotient */
long rem; /* Remainder */
};
typedef struct ldiv_s ldiv_t;
/* Structure type returned by the lldiv() function. */
struct lldiv_s
{
long quot; /* Quotient */
long rem; /* Remainder */
};
typedef struct lldiv_s lldiv_t;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@ -185,6 +205,10 @@ FAR void *calloc(size_t, size_t);
int abs(int j);
#ifdef CONFIG_CAN_PASS_STRUCTS
div_t div(int numer, int denom);
ldiv_t ldiv(long numer, long denom);
#ifdef CONFIG_HAVE_LONG_LONG
lldiv_t lldiv(long long numer, long long denom);
#endif
#endif
long int labs(long int j);
#ifdef CONFIG_HAVE_LONG_LONG

View File

@ -35,8 +35,9 @@
# Add the stdlib C files to the build
CSRCS += lib_abs.c lib_abort.c lib_div.c lib_imaxabs.c lib_itoa.c lib_labs.c
CSRCS += lib_llabs.c lib_rand.c lib_qsort.c
CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c
CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c
CSRCS += lib_rand.c lib_qsort.c
CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c
CSRCS += lib_strtod.c lib_checkbase.c