fixed drawlink() ruby callback
[swftools.git] / lib / art / art_misc.h
1 /* Libart_LGPL - library of basic graphic primitives
2  * Copyright (C) 1998 Raph Levien
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /* Simple macros to set up storage allocation and basic types for libart
21    functions. */
22
23 #ifndef __ART_MISC_H__
24 #define __ART_MISC_H__
25
26 #include <stdlib.h> /* for malloc, etc. */
27
28 /* The art_config.h file is automatically generated by
29    gen_art_config.c and contains definitions of
30    ART_SIZEOF_{CHAR,SHORT,INT,LONG} and art_u{8,16,32}. */
31 #ifdef LIBART_COMPILATION
32 #include "art_config.h"
33 #else
34 #include "art_config.h"
35 #endif
36
37 #include "../mem.h"
38 #ifdef __mem_h__
39 #define art_alloc rfx_alloc
40 #define art_free rfx_free
41 #define art_realloc rfx_realloc
42 #else
43 #define art_alloc malloc
44 #define art_free free
45 #define art_realloc realloc
46 #endif
47
48 /* These aren't, strictly speaking, configuration macros, but they're
49    damn handy to have around, and may be worth playing with for
50    debugging. */
51 #define art_new(type, n) ((type *)art_alloc ((n) * sizeof(type)))
52
53 #define art_renew(p, type, n) ((type *)art_realloc (p, (n) * sizeof(type)))
54
55 /* This one must be used carefully - in particular, p and max should
56    be variables. They can also be pstruct->el lvalues. */
57 #define art_expand(p, type, max) do { if(max) { p = art_renew (p, type, max <<= 1); } else { max = 1; p = art_new(type, 1); } } while (0)
58
59 typedef int art_boolean;
60 #define ART_FALSE 0
61 #define ART_TRUE 1
62
63 /* define pi */
64 #ifndef M_PI
65 #define M_PI 3.14159265358979323846
66 #endif  /*  M_PI  */
67
68 #ifndef M_SQRT2
69 #define M_SQRT2         1.41421356237309504880  /* sqrt(2) */
70 #endif  /* M_SQRT2 */
71
72 /* Provide macros to feature the GCC function attribute.
73  */
74 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4))
75 #define ART_GNUC_PRINTF( format_idx, arg_idx )    \
76   __attribute__((format (printf, format_idx, arg_idx)))
77 #define ART_GNUC_NORETURN                         \
78   __attribute__((noreturn))
79 #else   /* !__GNUC__ */
80 #define ART_GNUC_PRINTF( format_idx, arg_idx )
81 #define ART_GNUC_NORETURN
82 #endif  /* !__GNUC__ */
83
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87
88 void ART_GNUC_NORETURN
89 art_die (const char *fmt, ...) ART_GNUC_PRINTF (1, 2);
90
91 void
92 art_warn (const char *fmt, ...) ART_GNUC_PRINTF (1, 2);
93
94 void
95 art_dprint (const char *fmt, ...) ART_GNUC_PRINTF (1, 2);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #define ART_USE_NEW_INTERSECTOR
102
103 #endif /* __ART_MISC_H__ */