~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_global.h

Merging trunk changes from over weekend.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
  now let's figure out if inline functions are supported
158
158
  autoconf defines 'inline' to be empty, if not
159
159
*/
160
 
#define inline_test_1(X)        X ## 1
161
 
#define inline_test_2(X)        inline_test_1(X)
162
 
#if inline_test_2(inline) != 1
 
160
#if defined(inline)
163
161
#define HAVE_INLINE
164
162
#endif
165
 
#undef inline_test_2
166
 
#undef inline_test_1
167
163
/* helper macro for "instantiating" inline functions */
168
164
#define STATIC_INLINE static inline
169
165
 
320
316
#include <crypt.h>
321
317
#endif
322
318
 
 
319
#if defined(HAVE_STDINT_H)
 
320
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
 
321
#define __STDC_LIMIT_MACROS
 
322
#include <stdint.h>
 
323
#endif
 
324
#if defined(HAVE_STDBOOL_H)
 
325
#include <stdbool.h>
 
326
#endif
 
327
 
 
328
 
323
329
/*
324
330
  A lot of our programs uses asserts, so better to always include it
325
331
  This also fixes a problem when people uses DBUG_ASSERT without including
340
346
#endif
341
347
 
342
348
/* Declare madvise where it is not declared for C++, like Solaris */
343
 
#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
 
349
#if HAVE_MADVISE && !defined(HAVE_DECL_MADVISE) && defined(__cplusplus)
344
350
extern "C" int madvise(void *addr, size_t len, int behav);
345
351
#endif
346
352
 
387
393
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
388
394
#define test_all_bits(a,b) (((a) & (b)) == (b))
389
395
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
390
 
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
 
396
#define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
391
397
#ifndef HAVE_RINT
392
398
#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
393
399
#endif
451
457
/* Type for fuctions that handles signals */
452
458
#define sig_handler RETSIGTYPE
453
459
C_MODE_START
454
 
typedef void    (*sig_return)();/* Returns type from signal */
 
460
typedef void    (*sig_return)(void);/* Returns type from signal */
455
461
C_MODE_END
456
462
#if defined(__GNUC__) && !defined(_lint)
457
463
typedef char    pchar;          /* Mixed prototypes can take char */
586
592
#define strtok_r(A,B,C) strtok((A),(B))
587
593
#endif
588
594
 
589
 
/* This is from the old m-machine.h file */
590
 
 
591
 
#if SIZEOF_LONG_LONG > 4
592
 
#define HAVE_LONG_LONG 1
593
 
#endif
594
 
 
595
 
/*
596
 
  Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
597
 
  ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
598
 
  Also on Windows we define these constants by hand in config-win.h.
599
 
*/
600
 
 
601
 
#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
602
 
#define LONGLONG_MIN    ((long long) 0x8000000000000000LL)
603
 
#define LONGLONG_MAX    ((long long) 0x7FFFFFFFFFFFFFFFLL)
604
 
#endif
605
 
 
606
 
#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
 
595
 
 
596
#if defined(INT64_MAX)
 
597
#define LONGLONG_MAX INT64_MAX
 
598
#endif
 
599
 
 
600
#if defined(INT64_MIN)
 
601
#define LONGLONG_MIN INT64_MIN
 
602
#endif
 
603
 
 
604
#if !defined(ULONGLONG_MAX)
607
605
/* First check for ANSI C99 definition: */
608
 
#ifdef ULLONG_MAX
609
 
#define ULONGLONG_MAX  ULLONG_MAX
 
606
#if defined(UINT64_MAX)
 
607
#define ULONGLONG_MAX  UINT64_MAX
610
608
#else
611
 
#define ULONGLONG_MAX ((unsigned long long)(~0ULL))
 
609
#define ULONGLONG_MAX ((uint64_t)(~0ULL))
612
610
#endif
613
 
#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
 
611
#endif /* !defined(ULONGLONG_MAX)*/
614
612
 
615
613
#define INT_MIN32       (~0x7FFFFFFFL)
616
614
#define INT_MAX32       0x7FFFFFFFL
673
671
  adressable obj.
674
672
*/
675
673
#if SIZEOF_CHARP == 4
676
 
typedef long            my_ptrdiff_t;
 
674
typedef int32_t         my_ptrdiff_t;
677
675
#else
678
 
typedef long long       my_ptrdiff_t;
 
676
typedef int64_t         my_ptrdiff_t;
679
677
#endif
680
678
 
681
679
#define MY_ALIGN(A,L)   (((A) + (L) - 1) & ~((L) - 1))
746
744
#endif
747
745
 
748
746
#if !defined(HAVE_ULONG) && !defined(__USE_MISC)
749
 
typedef unsigned long   ulong;            /* Short for unsigned long */
 
747
typedef uint32_t        ulong;            /* Short for unsigned long */
750
748
#endif
751
749
#ifndef longlong_defined
752
750
/* 
754
752
  [unsigned] long long unconditionally in many places, 
755
753
  for example in constants with [U]LL suffix.
756
754
*/
757
 
#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
758
 
typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
759
 
typedef long long int   longlong;
760
 
#else
761
 
typedef unsigned long   ulonglong;        /* ulong or unsigned long long */
762
 
typedef long            longlong;
763
 
#endif
764
 
#endif
 
755
typedef uint64_t ulonglong; /* ulong or unsigned long long */
 
756
typedef int64_t longlong;
 
757
#endif
 
758
 
765
759
#ifndef HAVE_INT64
766
 
typedef longlong int64;
 
760
typedef int64_t int64;
767
761
#endif
768
762
#ifndef HAVE_UINT64
769
 
typedef ulonglong uint64;
 
763
typedef uint64_t uint64;
770
764
#endif
771
765
 
772
 
#if defined(NO_CLIENT_LONG_LONG)
773
 
typedef unsigned long my_ulonglong;
774
 
#else
775
 
typedef unsigned long long my_ulonglong;
776
 
#endif
 
766
typedef uint64_t my_ulonglong;
777
767
 
778
768
#if SIZEOF_CHARP == SIZEOF_INT
779
769
typedef int intptr;
836
826
#define MYF(v)          (myf) (v)
837
827
 
838
828
#ifndef LL
839
 
#ifdef HAVE_LONG_LONG
840
 
#define LL(A) A ## LL
841
 
#else
842
829
#define LL(A) A ## L
843
830
#endif
844
 
#endif
845
831
 
846
832
#ifndef ULL
847
 
#ifdef HAVE_LONG_LONG
848
 
#define ULL(A) A ## ULL
849
 
#else
850
833
#define ULL(A) A ## UL
851
834
#endif
852
 
#endif
853
835
 
854
836
/*
855
837
  Sometimes we want to make sure that the variable is not put into