From af389cd969ab7ae6507710cb8667660c3bd51577 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 2 Sep 2015 18:55:15 +0200 Subject: add div functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/bits/types.h | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'include/bits') diff --git a/include/bits/types.h b/include/bits/types.h index 41967f2..5d99e4f 100644 --- a/include/bits/types.h +++ b/include/bits/types.h @@ -25,6 +25,13 @@ #include +/* Ensure that dependencies for type are defined. */ +#if defined(__NEED_imaxdiv_t) && !defined(__NEED_intmax_t) +# define __NEED_intmax_t +#endif + + + /** * Returns the maximum value of an unsigned integer type, * in that type. @@ -267,3 +274,91 @@ typedef int sig_atomic_t; # define __SIG_ATOMIC_BIT __INT_BIT #endif + +/** + * A structure than holds both the quotient and + * the remainer in an integer division, of + * `int` type. + */ +#if defined(__NEED_div_t) && !defined(__DEFINED_div_t) +# define __DEFINED_div_t +typedef struct { + /** + * Quotient. + */ + int quot; + + /** + * Remainder. + */ + int rem; + +} div_t; +#endif + + +/** + * A structure than holds both the quotient and + * the remainer in an integer division, of + * `long int` type. + */ +#if defined(__NEED_ldiv_t) && !defined(__DEFINED_ldiv_t) +# define __DEFINED_ldiv_t +typedef struct { + /** + * Quotient. + */ + long int quot; + + /** + * Remainder. + */ + long int rem; + +} ldiv_t; +#endif + + +/** + * A structure than holds both the quotient and + * the remainer in an integer division, of + * `long long int` type. + */ +#if defined(__NEED_lldiv_t) && !defined(__DEFINED_lldiv_t) +# define __DEFINED_lldiv_t +typedef struct { + /** + * Quotient. + */ + long long int quot; + + /** + * Remainder. + */ + long long int rem; + +} lldiv_t; +#endif + + +/** + * A structure than holds both the quotient and + * the remainer in an integer division, of + * `intmax_t` type. + */ +#if defined(__NEED_imaxdiv_t) && !defined(__DEFINED_imaxdiv_t) +# define __DEFINED_imaxdiv_t +typedef struct { + /** + * Quotient. + */ + intmax_t quot; + + /** + * Remainder. + */ + intmax_t rem; + +} imaxdiv_t; +#endif + -- cgit v1.2.3-70-g09d2