amiga-tz/library/time_types.h

113 lines
2.6 KiB
C

#ifndef _TIME_TYPES_H
#define _TIME_TYPES_H
#include "compiler.h"
#include <limits.h>
#include <errno.h>
#ifndef ENAMETOOLONG
# define ENAMETOOLONG EINVAL
#endif
#ifndef EOVERFLOW
# define EOVERFLOW EINVAL
#endif
#define is_digit(c) isdigit(c)
// Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX.
#ifdef __LONG_LONG_MAX__
# ifndef LLONG_MAX
# define LLONG_MAX __LONG_LONG_MAX__
# endif
# ifndef LLONG_MIN
# define LLONG_MIN (-1 - LLONG_MAX)
# endif
#endif
#ifndef INT_FAST64_MAX
# ifdef LLONG_MAX
typedef long long int_fast64_t;
# define INT_FAST64_MIN LLONG_MIN
# define INT_FAST64_MAX LLONG_MAX
# else
# if (LONG_MAX >> 31) < 0xffffffff
# error Please use a compiler that supports a 64-bit integer type (or wider)
# endif
typedef long int_fast64_t;
# define INT_FAST64_MIN LONG_MIN
# define INT_FAST64_MAX LONG_MAX
# endif
#endif
#ifndef INT_FAST32_MAX
# if INT_MAX >> 31 == 0
typedef long int_fast32_t;
# define INT_FAST32_MAX LONG_MAX
# define INT_FAST32_MIN LONG_MIN
# else
typedef int int_fast32_t;
# define INT_FAST32_MAX INT_MAX
# define INT_FAST32_MIN INT_MIN
# endif
#endif
#ifndef INTMAX_MAX
# ifdef LLONG_MAX
typedef long long intmax_t;
# define strtoimax strtoll
# define INTMAX_MAX LLONG_MAX
# define INTMAX_MIN LLONG_MIN
# else
typedef long intmax_t;
# define strtoimax strtol
# define INTMAX_MAX LONG_MAX
# define INTMAX_MIN LONG_MIN
# endif
#endif
#ifndef UINTMAX_MAX
# if defined ULLONG_MAX || defined __LONG_LONG_MAX__
typedef unsigned long long uintmax_t;
# else
typedef unsigned long uintmax_t;
# endif
#endif
#ifndef TYPE_BIT
# define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
#endif
#ifndef TYPE_SIGNED
# define TYPE_SIGNED(type) (((type) -1) < 0)
#endif
#define TWOS_COMPLEMENT(t) ((t) ~ (t) 0 < 0)
/* Max and min values of the integer type T, of which only the bottom
B bits are used, and where the highest-order used bit is considered
to be a sign bit if T is signed. */
#define MAXVAL(t, b) \
((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \
- 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
#define MINVAL(t, b) \
((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
// The minimum and maximum finite time values. This assumes no padding.
extern time_t const time_t_min;
extern time_t const time_t_max;
#define GRANDPARENTED "Local time zone must be set--see zic manual page"
#ifndef TZ_ABBR_MAX_LEN
# define TZ_ABBR_MAX_LEN 16
#endif
#ifndef TZ_ABBR_CHAR_SET
# define TZ_ABBR_CHAR_SET \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"
#endif
#ifndef TZ_ABBR_ERR_CHAR
# define TZ_ABBR_ERR_CHAR '_'
#endif
#endif