/[bison]/bison/data/c.m4
ViewVC logotype

Diff of /bison/data/c.m4

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by akim, Tue Jul 9 09:43:22 2002 UTC revision 1.3 by akim, Thu Jul 25 17:32:34 2002 UTC
# Line 56  m4_define([b4_copyright], Line 56  m4_define([b4_copyright],
56  ## Data Types.  ##  ## Data Types.  ##
57  ## ------------ ##  ## ------------ ##
58    
 # b4_sint_type(MAX)  
 # -----------------  
 # Return the smallest signed int type able to handle the number MAX.  
 m4_define([b4_sint_type],  
 [m4_if(m4_eval([$1 <= 127]),        [1], [signed char],  
        m4_eval([$1 <= 32767]),      [1], [signed short],  
        [signed int])])  
   
   
 # b4_uint_type(MAX)  
 # -----------------  
 # Return the smallest unsigned int type able to handle the number MAX.  
 m4_define([b4_uint_type],  
 [m4_if(m4_eval([$1 <= 255]),        [1], [unsigned char],  
        m4_eval([$1 <= 65535]),      [1], [unsigned short],  
        [unsigned int])])  
59    
60    # b4_ints_in(INT1, INT2, LOW, HIGH)
61    # ---------------------------------
62    # Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
63    m4_define([b4_ints_in],
64    [m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
65    
66    
67    # b4_int_type(MIN, MAX)
68    # ---------------------
69    # Return the smallest int type able to handle numbers ranging from
70    # MIN to MAX (included).
71    m4_define([b4_int_type],
72    [m4_if(b4_ints_in($@,      [0],   [255]), [1], [unsigned char],
73           b4_ints_in($@,   [-128],   [128]), [1], [signed char],
74    
75           b4_ints_in($@,      [0], [65535]), [1], [unsigned short],
76           b4_ints_in($@, [-32768], [32767]), [1], [short],
77    
78           m4_eval([0 <= $1]),                [1], [unsigned int],
79    
80                                                   [int])])
81    
82    # b4_int_type_for(NAME)
83    # ---------------------
84    # Return the smallest int type able to handle numbers ranging from
85    # `NAME_min' to `NAME_max' (included).
86    m4_define([b4_int_type_for],
87    [b4_int_type($1_min, $1_max)])
88    
89    
90  ## ------------------------- ##  ## ------------------------- ##

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26