/[jscoverage]/trunk/js/jstypes.h
ViewVC logotype

Diff of /trunk/js/jstypes.h

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

revision 459 by siliconforks, Thu Oct 23 19:03:33 2008 UTC revision 460 by siliconforks, Sat Sep 26 23:15:22 2009 UTC
# Line 55  Line 55 
55  #define jstypes_h___  #define jstypes_h___
56    
57  #include <stddef.h>  #include <stddef.h>
58    #include "jsstdint.h"
59    
60  /***********************************************************************  /***********************************************************************
61  ** MACROS:      JS_EXTERN_API  ** MACROS:      JS_EXTERN_API
# Line 182  Line 183 
183  # elif defined _MSC_VER  # elif defined _MSC_VER
184  #  define JS_ALWAYS_INLINE   __forceinline  #  define JS_ALWAYS_INLINE   __forceinline
185  # elif defined __GNUC__  # elif defined __GNUC__
186  #  define JS_ALWAYS_INLINE   __attribute__((always_inline))  #  define JS_ALWAYS_INLINE   __attribute__((always_inline)) JS_INLINE
187  # else  # else
188  #  define JS_ALWAYS_INLINE   JS_INLINE  #  define JS_ALWAYS_INLINE   JS_INLINE
189  # endif  # endif
190  #endif  #endif
191    
192    #ifdef NS_STATIC_CHECKING
193    /*
194     * Attributes for static analysis. Functions declared with JS_REQUIRES_STACK
195     * always have a valid cx->fp and can access it freely.  Other functions can
196     * access cx->fp only after calling a function that "forces" the stack
197     * (i.e. lazily instantiates it as needed).
198     */
199    # define JS_REQUIRES_STACK   __attribute__((user("JS_REQUIRES_STACK")))
200    # define JS_FORCES_STACK     __attribute__((user("JS_FORCES_STACK")))
201    #else
202    # define JS_REQUIRES_STACK
203    # define JS_FORCES_STACK
204    #endif
205    
206  /***********************************************************************  /***********************************************************************
207  ** MACROS:      JS_BEGIN_MACRO  ** MACROS:      JS_BEGIN_MACRO
208  **              JS_END_MACRO  **              JS_END_MACRO
# Line 258  Line 273 
273  #define JS_MIN(x,y)     ((x)<(y)?(x):(y))  #define JS_MIN(x,y)     ((x)<(y)?(x):(y))
274  #define JS_MAX(x,y)     ((x)>(y)?(x):(y))  #define JS_MAX(x,y)     ((x)>(y)?(x):(y))
275    
276  #if (defined(XP_WIN) && !defined(CROSS_COMPILE)) || defined (WINCE)  #ifdef _MSC_VER
277  # include "jscpucfg.h"      /* Use standard Mac or Windows configuration */  # include "jscpucfg.h"  /* We can't auto-detect MSVC configuration */
 #elif defined(XP_UNIX) || defined(XP_BEOS) || defined(XP_OS2) || defined(CROSS_COMPILE)  
 # include "jsautocfg.h"     /* Use auto-detected configuration */  
278  #else  #else
279  # error "Must define one of XP_BEOS, XP_OS2, XP_WIN or XP_UNIX"  # include "jsautocfg.h" /* Use auto-detected configuration */
280  #endif  #endif
281    
282  JS_BEGIN_EXTERN_C  JS_BEGIN_EXTERN_C
# Line 275  Line 288 
288  **  The int8 types are known to be 8 bits each. There is no type that  **  The int8 types are known to be 8 bits each. There is no type that
289  **      is equivalent to a plain "char".  **      is equivalent to a plain "char".
290  ************************************************************************/  ************************************************************************/
291  #if JS_BYTES_PER_BYTE == 1  
292  typedef unsigned char JSUint8;  typedef uint8_t JSUint8;
293  typedef signed char JSInt8;  typedef int8_t JSInt8;
 #else  
 # error No suitable type for JSInt8/JSUint8  
 #endif  
294    
295  /************************************************************************  /************************************************************************
296  ** TYPES:       JSUint16  ** TYPES:       JSUint16
# Line 288  Line 298 
298  ** DESCRIPTION:  ** DESCRIPTION:
299  **  The int16 types are known to be 16 bits each.  **  The int16 types are known to be 16 bits each.
300  ************************************************************************/  ************************************************************************/
301  #if JS_BYTES_PER_SHORT == 2  
302  typedef unsigned short JSUint16;  typedef uint16_t JSUint16;
303  typedef short JSInt16;  typedef int16_t JSInt16;
 #else  
 # error No suitable type for JSInt16/JSUint16  
 #endif  
304    
305  /************************************************************************  /************************************************************************
306  ** TYPES:       JSUint32  ** TYPES:       JSUint32
# Line 301  Line 308 
308  ** DESCRIPTION:  ** DESCRIPTION:
309  **  The int32 types are known to be 32 bits each.  **  The int32 types are known to be 32 bits each.
310  ************************************************************************/  ************************************************************************/
311  #if JS_BYTES_PER_INT == 4  
312  typedef unsigned int JSUint32;  typedef uint32_t JSUint32;
313  typedef int JSInt32;  typedef int32_t JSInt32;
 # define JS_INT32(x)    x  
 # define JS_UINT32(x)   x ## U  
 #elif JS_BYTES_PER_LONG == 4  
 typedef unsigned long JSUint32;  
 typedef long JSInt32;  
 # define JS_INT32(x)    x ## L  
 # define JS_UINT32(x)   x ## UL  
 #else  
 # error No suitable type for JSInt32/JSUint32  
 #endif  
314    
315  /************************************************************************  /************************************************************************
316  ** TYPES:       JSUint64  ** TYPES:       JSUint64
# Line 325  Line 322 
322  **      64 bit values. The only guaranteed portability requires the use of  **      64 bit values. The only guaranteed portability requires the use of
323  **      the JSLL_ macros (see jslong.h).  **      the JSLL_ macros (see jslong.h).
324  ************************************************************************/  ************************************************************************/
 #ifdef JS_HAVE_LONG_LONG  
325    
326  # if JS_BYTES_PER_LONG == 8  typedef uint64_t JSUint64;
327  typedef long JSInt64;  typedef int64_t JSInt64;
 typedef unsigned long JSUint64;  
 # elif defined(WIN16)  
 typedef __int64 JSInt64;  
 typedef unsigned __int64 JSUint64;  
 # elif defined(WIN32) && !defined(__GNUC__)  
 typedef __int64  JSInt64;  
 typedef unsigned __int64 JSUint64;  
 # else  
 typedef long long JSInt64;  
 typedef unsigned long long JSUint64;  
 # endif /* JS_BYTES_PER_LONG == 8 */  
   
 #else  /* !JS_HAVE_LONG_LONG */  
   
 typedef struct {  
 # ifdef IS_LITTLE_ENDIAN  
     JSUint32 lo, hi;  
 # else  
     JSUint32 hi, lo;  
 #endif  
 } JSInt64;  
 typedef JSInt64 JSUint64;  
   
 #endif /* !JS_HAVE_LONG_LONG */  
328    
329  /************************************************************************  /************************************************************************
330  ** TYPES:       JSUintn  ** TYPES:       JSUintn
# Line 363  Line 335 
335  **      define them to be wider (e.g., 32 or even 64 bits). These types are  **      define them to be wider (e.g., 32 or even 64 bits). These types are
336  **      never valid for fields of a structure.  **      never valid for fields of a structure.
337  ************************************************************************/  ************************************************************************/
338  #if JS_BYTES_PER_INT >= 2  
339  typedef int JSIntn;  typedef int JSIntn;
340  typedef unsigned int JSUintn;  typedef unsigned int JSUintn;
 #else  
 # error 'sizeof(int)' not sufficient for platform use  
 #endif  
341    
342  /************************************************************************  /************************************************************************
343  ** TYPES:       JSFloat64  ** TYPES:       JSFloat64
# Line 398  Line 367 
367  **  A type for pointer difference. Variables of this type are suitable  **  A type for pointer difference. Variables of this type are suitable
368  **      for storing a pointer or pointer sutraction.  **      for storing a pointer or pointer sutraction.
369  ************************************************************************/  ************************************************************************/
370  #if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8  typedef uintptr_t JSUptrdiff;
 typedef JSUint64 JSUptrdiff;  
 #else  
 typedef unsigned long JSUptrdiff;  
 #endif  
371    
372  /************************************************************************  /************************************************************************
373  ** TYPES:       JSBool  ** TYPES:       JSBool
# Line 427  Line 392 
392  /*  /*
393  ** A JSWord is an integer that is the same size as a void*  ** A JSWord is an integer that is the same size as a void*
394  */  */
395  #if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8  typedef intptr_t JSWord;
396  typedef JSInt64 JSWord;  typedef uintptr_t JSUword;
 typedef JSUint64 JSUword;  
 #else  
 typedef long JSWord;  
 typedef unsigned long JSUword;  
 #endif  
397    
398  #include "jsotypes.h"  #include "jsotypes.h"
399    
# Line 485  Line 445 
445  #define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])  #define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
446  #define JS_ARRAY_END(array)    ((array) + JS_ARRAY_LENGTH(array))  #define JS_ARRAY_END(array)    ((array) + JS_ARRAY_LENGTH(array))
447    
448    #define JS_BITS_PER_BYTE 8
449    #define JS_BITS_PER_BYTE_LOG2 3
450    
451    #define JS_BITS_PER_WORD (JS_BITS_PER_BYTE * JS_BYTES_PER_WORD)
452    #define JS_BITS_PER_DOUBLE (JS_BITS_PER_BYTE * JS_BYTES_PER_DOUBLE)
453    
454    /***********************************************************************
455    ** MACROS:      JS_FUNC_TO_DATA_PTR
456    **              JS_DATA_TO_FUNC_PTR
457    ** DESCRIPTION:
458    **      Macros to convert between function and data pointers assuming that
459    **      they have the same size. Use them like this:
460    **
461    **      JSPropertyOp nativeGetter;
462    **      JSObject *scriptedGetter;
463    **      ...
464    **      scriptedGetter = JS_FUNC_TO_DATA_PTR(JSObject *, nativeGetter);
465    **      ...
466    **      nativeGetter = JS_DATA_TO_FUNC_PTR(JSPropertyOp, scriptedGetter);
467    **
468    ***********************************************************************/
469    
470    #ifdef __GNUC__
471    # define JS_FUNC_TO_DATA_PTR(type, fun) (__extension__ (type) (fun))
472    # define JS_DATA_TO_FUNC_PTR(type, ptr) (__extension__ (type) (ptr))
473    #else
474    /* Use an extra (void *) cast for MSVC. */
475    # define JS_FUNC_TO_DATA_PTR(type, fun) ((type) (void *) (fun))
476    # define JS_DATA_TO_FUNC_PTR(type, ptr) ((type) (void *) (ptr))
477    #endif
478    
479  JS_END_EXTERN_C  JS_END_EXTERN_C
480    
481  #endif /* jstypes_h___ */  #endif /* jstypes_h___ */

Legend:
Removed from v.459  
changed lines
  Added in v.460

  ViewVC Help
Powered by ViewVC 1.1.24