2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
gb_common.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GB_COMMON_H
|
|
|
|
#define __GB_COMMON_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifdef _GNU_SOURCE
|
|
|
|
#undef _GNU_SOURCE
|
|
|
|
#endif
|
|
|
|
#define _GNU_SOURCE 500
|
2012-05-05 02:39:43 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: The debug window has a button to switch between "normal view" and
"symbol view". In "normal view", array and collection contents are
displayed. If the object is not an array or a collection, then all
non-hidden symbols are displayed. In "symbol view", all objects symbols
are displayed, whatever the object type is.
[INTERPRETER]
* NEW: The debugger now can display collection-like objects. An object can
be displayed like a collection if it has a Count property, is enumerable,
has a _get special method taking a string, and has a Key property that
returns the key of the last enumerated element.
[GB.DEBUG]
* NEW: The debugger now can display collection-like objects. An object can
be displayed like a collection if it has a Count property, is enumerable,
has a _get special method taking a string, and has a Key property that
returns the key of the last enumerated element.
[GB.FORM]
* BUG: GridView.Clear resets the height of all rows to the default value.
git-svn-id: svn://localhost/gambas/trunk@4558 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-03-17 03:05:31 +01:00
|
|
|
#define _ISOC9X_SOURCE 1
|
|
|
|
#define _ISOC99_SOURCE 1
|
|
|
|
#define __USE_ISOC99 1
|
|
|
|
#define __USE_ISOC9X 1
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
2008-08-14 21:42:27 +02:00
|
|
|
#include <stddef.h>
|
2007-12-30 17:41:49 +01:00
|
|
|
#include <stdint.h>
|
2008-01-17 22:39:26 +01:00
|
|
|
#include <inttypes.h>
|
2007-12-30 17:41:49 +01:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2010-01-28 11:55:24 +01:00
|
|
|
#include <sys/param.h>
|
2010-11-30 16:03:47 +01:00
|
|
|
#include <limits.h>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-05 01:54:00 +02:00
|
|
|
#ifdef OS_MACOSX
|
|
|
|
#define OS_FREEBSD
|
|
|
|
#endif
|
|
|
|
|
2009-05-15 19:57:29 +02:00
|
|
|
#if defined(__GNU_LIBRARY__) || defined(OS_FREEBSD)
|
2012-05-05 02:39:43 +02:00
|
|
|
|
2009-05-15 19:57:29 +02:00
|
|
|
#include <getopt.h>
|
|
|
|
#define HAVE_GETOPT_LONG 1
|
2012-05-05 02:39:43 +02:00
|
|
|
|
2009-05-15 19:57:29 +02:00
|
|
|
#endif
|
|
|
|
|
2009-07-05 01:54:00 +02:00
|
|
|
#if defined(OS_CYGWIN)
|
2008-03-21 01:35:39 +01:00
|
|
|
|
2012-05-05 02:39:43 +02:00
|
|
|
typedef void (*sighandler_t) (int);
|
|
|
|
typedef unsigned long ulong;
|
2008-03-21 01:35:39 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-12-31 23:38:56 +01:00
|
|
|
#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
|
|
|
|
|
2010-12-07 02:20:40 +01:00
|
|
|
/* sighandler_t is replaced by sig_t */
|
|
|
|
#define sighandler_t sig_t
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-05-22 16:52:36 +02:00
|
|
|
typedef unsigned long ulong;
|
|
|
|
|
|
|
|
#if (defined(__amd64__) || defined(__ia64__) || defined(__sparc64__))
|
|
|
|
#define __WORDSIZE 64
|
|
|
|
#endif
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OS_SOLARIS
|
|
|
|
|
2010-12-07 02:20:40 +01:00
|
|
|
/* PGS: The following #define prevents /usr/include/sys/mman.h on solaris
|
|
|
|
from #define'ing PRIVATE to 0x20, thus breaking Gambas.
|
|
|
|
Perhaps Gambas should use a different name?
|
|
|
|
BM: I don't use PRIVATE anymore!
|
|
|
|
*/
|
|
|
|
#ifdef _POSIX_C_SOURCE
|
|
|
|
/* PGS: Stop compiler warnings when gcc on solaris does remember to define
|
|
|
|
_POSIX_C_SOURCE, e.g. when compiling qt related files. */
|
|
|
|
#undef _POSIX_C_SOURCE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define _POSIX_C_SOURCE 3
|
|
|
|
/* Get prototype for alloca() */
|
|
|
|
#include <alloca.h>
|
|
|
|
/* Get definition for index() */
|
|
|
|
#include <strings.h>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-01-20 02:37:45 +01:00
|
|
|
#ifdef OS_MACOSX
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#undef bool
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#if !defined(__cplusplus)
|
|
|
|
|
2010-12-07 02:20:40 +01:00
|
|
|
#ifndef FALSE
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FALSE = 0,
|
|
|
|
TRUE = 1
|
|
|
|
};
|
|
|
|
#endif
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-05-16 04:16:22 +02:00
|
|
|
#define bool char
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef
|
2010-12-07 02:20:40 +01:00
|
|
|
unsigned char uchar;
|
|
|
|
|
2008-01-05 15:07:21 +01:00
|
|
|
typedef
|
|
|
|
size_t offset_t;
|
2010-12-07 02:20:40 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#define PUBLIC
|
|
|
|
#define INLINE __inline__
|
|
|
|
#define EXTERN extern
|
|
|
|
#define PACKED __attribute__((packed))
|
|
|
|
#define NORETURN __attribute__((noreturn))
|
|
|
|
#define CONST __attribute__((const))
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
#if __WORDSIZE == 64
|
2008-02-24 17:29:02 +01:00
|
|
|
#define OS_64BITS 1
|
2008-01-17 22:39:26 +01:00
|
|
|
#endif
|
|
|
|
|
2010-11-30 16:03:47 +01:00
|
|
|
#ifndef LLONG_MAX
|
|
|
|
#define LLONG_MAX 9223372036854775807LL
|
|
|
|
#endif
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#define CLEAR(s) (memset(s, 0, sizeof(*s)))
|
|
|
|
|
|
|
|
/* Workaround spurious gcc warnings */
|
|
|
|
#define NO_WARNING(var) var = var
|
|
|
|
|
|
|
|
#ifndef offsetof
|
2010-12-07 02:20:40 +01:00
|
|
|
#define offsetof(_type, _arg) ((size_t)&(((_type *)0)->_arg))
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define Max(a, b) ({ int _a = (a), _b = (b); _a > _b ? _a : _b; })
|
|
|
|
#define Min(a, b) ({ int _a = (a), _b = (b); _a < _b ? _a : _b; })
|
|
|
|
#define MinMax(v, a, b) ({ int _v = (v), _a = (a), _b = (b); _v < _a ? _a : (_v > _b ? _b : _v); })
|
|
|
|
|
2008-01-25 16:01:02 +01:00
|
|
|
#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2
|
2011-12-30 11:57:06 +01:00
|
|
|
#define BREAKPOINT() { __asm__ __volatile__ ("int $03"); }
|
2008-01-25 16:01:02 +01:00
|
|
|
#elif (defined (_MSC_VER) || defined (__DMC__)) && defined (_M_IX86)
|
2011-12-30 11:57:06 +01:00
|
|
|
#define BREAKPOINT() { __asm int 3h }G_STMT_END
|
2008-01-25 16:01:02 +01:00
|
|
|
#elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2
|
2011-12-30 11:57:06 +01:00
|
|
|
#define BREAKPOINT() { __asm__ __volatile__ ("bpt"); }
|
2008-01-25 16:01:02 +01:00
|
|
|
#else /* !__i386__ && !__alpha__ */
|
2012-05-05 02:39:43 +02:00
|
|
|
#define BREAKPOINT() { raise(SIGTRAP); }
|
2008-01-25 16:01:02 +01:00
|
|
|
#endif /* __i386__ */
|
|
|
|
|
2012-05-05 02:39:43 +02:00
|
|
|
#define COPYRIGHT "(c) 2000-2012 Benoît Minisini\n\n" \
|
2010-12-07 02:20:40 +01:00
|
|
|
"This program is free software; you can redistribute it and/or \n" \
|
|
|
|
"modify it under the terms of the GNU General Public License as \n" \
|
|
|
|
"published by the Free Software Foundation; either version 2, or \n" \
|
|
|
|
"(at your option) any later version.\n\n"
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-31 04:28:48 +02:00
|
|
|
//#define LIKELY(_x) __builtin_expect((_x), 1)
|
|
|
|
//#define UNLIKELY(_x) __builtin_expect((_x), 0)
|
|
|
|
#define LIKELY(_x) (_x)
|
|
|
|
#define UNLIKELY(_x) (_x)
|
2010-05-19 22:18:23 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif /* __COMMON_H */
|