hwint.h revision 96263
152284Sobrien/* HOST_WIDE_INT definitions for the GNU compiler. 252284Sobrien Copyright (C) 1998 Free Software Foundation, Inc. 352284Sobrien 490075Sobrien This file is part of GCC. 552284Sobrien 652284Sobrien Provide definitions for macros which depend on HOST_BITS_PER_INT 790075Sobrien and HOST_BITS_PER_LONG. */ 852284Sobrien 990075Sobrien#ifndef GCC_HWINT_H 1090075Sobrien#define GCC_HWINT_H 1152284Sobrien 1290075Sobrien/* This describes the machine the compiler is hosted on. */ 1390075Sobrien#define HOST_BITS_PER_CHAR CHAR_BIT 1490075Sobrien#define HOST_BITS_PER_SHORT (CHAR_BIT * SIZEOF_SHORT) 1590075Sobrien#define HOST_BITS_PER_INT (CHAR_BIT * SIZEOF_INT) 1690075Sobrien#define HOST_BITS_PER_LONG (CHAR_BIT * SIZEOF_LONG) 1752284Sobrien 1890075Sobrien#ifdef HAVE_LONG_LONG 1990075Sobrien# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG) 2090075Sobrien#else 2196263Sobrien#ifdef HAVE___INT64 2290075Sobrien# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF___INT64) 2390075Sobrien#else 2490075Sobrien/* If we're here and we're GCC, assume this is stage 2+ of a bootstrap 2590075Sobrien and 'long long' has the width of the *target*'s long long. */ 2690075Sobrien# if GCC_VERSION > 3000 2790075Sobrien# define HOST_BITS_PER_LONGLONG LONG_LONG_TYPE_SIZE 2890075Sobrien# endif /* gcc */ 2990075Sobrien#endif 3090075Sobrien#endif /* no long long */ 3190075Sobrien 3252284Sobrien/* Find the largest host integer type and set its size and type. */ 3352284Sobrien 3490075Sobrien/* Use long long on the host if the target has a wider long type than 3590075Sobrien the host. */ 3690075Sobrien 3790075Sobrien#if ! defined HOST_BITS_PER_WIDE_INT \ 3890075Sobrien && defined HOST_BITS_PER_LONGLONG \ 3990075Sobrien && (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) \ 4090075Sobrien && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) \ 4190075Sobrien || defined (LLONG_MAX) || defined (__GNUC__)) 4290075Sobrien 4390075Sobrien# ifdef MAX_LONG_TYPE_SIZE 4490075Sobrien# if MAX_LONG_TYPE_SIZE > HOST_BITS_PER_LONG 4590075Sobrien# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG 4690075Sobrien# define HOST_WIDE_INT long long 4790075Sobrien# endif 4890075Sobrien# else 4990075Sobrien# if LONG_TYPE_SIZE > HOST_BITS_PER_LONG 5090075Sobrien# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG 5190075Sobrien# define HOST_WIDE_INT long long 5290075Sobrien# endif 5390075Sobrien# endif 5490075Sobrien 5590075Sobrien#endif 5690075Sobrien 5752284Sobrien#ifndef HOST_BITS_PER_WIDE_INT 5852284Sobrien 5952284Sobrien# if HOST_BITS_PER_LONG > HOST_BITS_PER_INT 6052284Sobrien# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG 6152284Sobrien# define HOST_WIDE_INT long 6252284Sobrien# else 6352284Sobrien# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT 6452284Sobrien# define HOST_WIDE_INT int 6552284Sobrien# endif 6652284Sobrien 6752284Sobrien#endif /* ! HOST_BITS_PER_WIDE_INT */ 6852284Sobrien 6952284Sobrien/* Provide defaults for the way to print a HOST_WIDE_INT 7052284Sobrien in various manners. */ 7152284Sobrien 7252284Sobrien#ifndef HOST_WIDE_INT_PRINT_DEC 7352284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 7452284Sobrien# define HOST_WIDE_INT_PRINT_DEC "%d" 7552284Sobrien# else 7652284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 7752284Sobrien# define HOST_WIDE_INT_PRINT_DEC "%ld" 7852284Sobrien# else 7952284Sobrien# define HOST_WIDE_INT_PRINT_DEC "%lld" 8052284Sobrien# endif 8152284Sobrien# endif 8252284Sobrien#endif /* ! HOST_WIDE_INT_PRINT_DEC */ 8352284Sobrien 8452284Sobrien#ifndef HOST_WIDE_INT_PRINT_UNSIGNED 8552284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 8652284Sobrien# define HOST_WIDE_INT_PRINT_UNSIGNED "%u" 8752284Sobrien# else 8852284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 8952284Sobrien# define HOST_WIDE_INT_PRINT_UNSIGNED "%lu" 9052284Sobrien# else 9152284Sobrien# define HOST_WIDE_INT_PRINT_UNSIGNED "%llu" 9252284Sobrien# endif 9352284Sobrien# endif 9452284Sobrien#endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */ 9552284Sobrien 9652284Sobrien#ifndef HOST_WIDE_INT_PRINT_HEX 9752284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 9852284Sobrien# define HOST_WIDE_INT_PRINT_HEX "0x%x" 9952284Sobrien# else 10052284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 10152284Sobrien# define HOST_WIDE_INT_PRINT_HEX "0x%lx" 10252284Sobrien# else 10352284Sobrien# define HOST_WIDE_INT_PRINT_HEX "0x%llx" 10452284Sobrien# endif 10552284Sobrien# endif 10652284Sobrien#endif /* ! HOST_WIDE_INT_PRINT_HEX */ 10752284Sobrien 10852284Sobrien#ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX 10952284Sobrien# if HOST_BITS_PER_WIDE_INT == 64 11052284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 11152284Sobrien# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x" 11252284Sobrien# else 11352284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 11452284Sobrien# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx" 11552284Sobrien# else 11652284Sobrien# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx" 11752284Sobrien# endif 11852284Sobrien# endif 11952284Sobrien# else 12052284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT 12152284Sobrien# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x" 12252284Sobrien# else 12352284Sobrien# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG 12452284Sobrien# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx" 12552284Sobrien# else 12652284Sobrien# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx" 12752284Sobrien# endif 12852284Sobrien# endif 12952284Sobrien# endif 13052284Sobrien#endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */ 13152284Sobrien 13290075Sobrien/* Find HOST_WIDEST_INT and set its bit size, type and print macros. 13390075Sobrien It will be the largest integer mode supported by the host which may 13490075Sobrien (or may not) be larger than HOST_WIDE_INT. */ 13552284Sobrien 13690075Sobrien#ifndef HOST_WIDEST_INT 13790075Sobrien#if defined HOST_BITS_PER_LONGLONG \ 13890075Sobrien && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG 13990075Sobrien# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG 14090075Sobrien# define HOST_WIDEST_INT long long 14190075Sobrien# define HOST_WIDEST_INT_PRINT_DEC "%lld" 14290075Sobrien# define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu" 14390075Sobrien# define HOST_WIDEST_INT_PRINT_HEX "0x%llx" 14490075Sobrien# else 14590075Sobrien# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG 14690075Sobrien# define HOST_WIDEST_INT long 14790075Sobrien# define HOST_WIDEST_INT_PRINT_DEC "%ld" 14890075Sobrien# define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu" 14990075Sobrien# define HOST_WIDEST_INT_PRINT_HEX "0x%lx" 15090075Sobrien# endif /* long long wider than long */ 15190075Sobrien#endif /* ! HOST_WIDEST_INT */ 15290075Sobrien 15390075Sobrien#endif /* ! GCC_HWINT_H */ 154