Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* -*- buffer-read-only: t -*- vi: set ro: */ 00002 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 00003 /* intprops.h -- properties of integer types 00004 00005 Copyright (C) 2001-2005, 2009-2011 Free Software Foundation, Inc. 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 /* Written by Paul Eggert. */ 00021 00022 #ifndef GL_INTPROPS_H 00023 # define GL_INTPROPS_H 00024 00025 # include <limits.h> 00026 00027 /* The extra casts in the following macros work around compiler bugs, 00028 e.g., in Cray C 5.0.3.0. */ 00029 00030 /* True if the arithmetic type T is an integer type. bool counts as 00031 an integer. */ 00032 # define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) 00033 00034 /* True if negative values of the signed integer type T use two's 00035 complement, ones' complement, or signed magnitude representation, 00036 respectively. Much GNU code assumes two's complement, but some 00037 people like to be portable to all possible C hosts. */ 00038 # define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) 00039 # define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) 00040 # define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) 00041 00042 /* True if the arithmetic type T is signed. */ 00043 # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 00044 00045 /* The maximum and minimum values for the integer type T. These 00046 macros have undefined behavior if T is signed and has padding bits. 00047 If this is a problem for you, please let us know how to fix it for 00048 your host. */ 00049 # define TYPE_MINIMUM(t) \ 00050 ((t) (! TYPE_SIGNED (t) \ 00051 ? (t) 0 \ 00052 : TYPE_SIGNED_MAGNITUDE (t) \ 00053 ? ~ (t) 0 \ 00054 : ~ TYPE_MAXIMUM (t))) 00055 # define TYPE_MAXIMUM(t) \ 00056 ((t) (! TYPE_SIGNED (t) \ 00057 ? (t) -1 \ 00058 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) 00059 00060 /* Return zero if T can be determined to be an unsigned type. 00061 Otherwise, return 1. 00062 When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a 00063 tighter bound. Otherwise, it overestimates the true bound by one byte 00064 when applied to unsigned types of size 2, 4, 16, ... bytes. 00065 The symbol signed_type_or_expr__ is private to this header file. */ 00066 # if __GNUC__ >= 2 00067 # define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) 00068 # else 00069 # define signed_type_or_expr__(t) 1 00070 # endif 00071 00072 /* Bound on length of the string representing an unsigned integer 00073 value representable in B bits. log10 (2.0) < 146/485. The 00074 smallest value of B where this bound is not tight is 2621. */ 00075 # define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) 00076 00077 /* Bound on length of the string representing an integer type or expression T. 00078 Subtract 1 for the sign bit if T is signed, and then add 1 more for 00079 a minus sign if needed. */ 00080 # define INT_STRLEN_BOUND(t) \ 00081 (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) \ 00082 + signed_type_or_expr__ (t)) 00083 00084 /* Bound on buffer size needed to represent an integer type or expression T, 00085 including the terminating null. */ 00086 # define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) 00087 00088 #endif /* GL_INTPROPS_H */