Author: petdance
Date: Thu Feb 21 18:58:23 2008
New Revision: 25973
Modified:
trunk/compilers/imcc/imcc.l
trunk/compilers/imcc/imclexer.c
trunk/include/parrot/sub.h
trunk/include/parrot/thr_pthread.h
trunk/include/parrot/thr_windows.h
trunk/include/parrot/warnings.h
trunk/src/bignum.h
trunk/src/interp_guts.h
trunk/src/pmc/capture.pmc
Log:
lots of macro wrapping
Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l (original)
+++ trunk/compilers/imcc/imcc.l Thu Feb 21 18:58:23 2008
@@ -109,7 +109,7 @@
#define DUP_AND_RET(valp, token) \
do { \
if (valp) (valp)->s = str_dup(yytext); \
- return token; \
+ return (token); \
} while (0)
#define DUP_AND_RET_FREE(valp, token) \
@@ -117,7 +117,7 @@
if (valp) { \
mem_sys_free((valp)->s); \
(valp)->s = str_dup(yytext); \
- return token; \
+ return (token); \
} \
} while (0)
Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c (original)
+++ trunk/compilers/imcc/imclexer.c Thu Feb 21 18:58:23 2008
@@ -30,7 +30,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 34
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -52,7 +52,7 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
@@ -115,11 +115,12 @@
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
@@ -155,8 +156,6 @@
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-int yylex_init (yyscan_t* scanner);
-
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
@@ -2751,7 +2750,7 @@
#define DUP_AND_RET(valp, token) \
do { \
if (valp) (valp)->s = str_dup(yytext); \
- return token; \
+ return (token); \
} while (0)
#define DUP_AND_RET_FREE(valp, token) \
@@ -2759,7 +2758,7 @@
if (valp) { \
mem_sys_free((valp)->s); \
(valp)->s = str_dup(yytext); \
- return token; \
+ return (token); \
} \
} while (0)
@@ -2773,7 +2772,7 @@
-#line 2777 "compilers/imcc/imclexer.c"
+#line 2776 "compilers/imcc/imclexer.c"
#define INITIAL 0
#define emit 1
@@ -2835,6 +2834,10 @@
static int yy_init_globals (yyscan_t yyscanner );
+int yylex_init (yyscan_t* scanner);
+
+int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
@@ -2912,7 +2915,7 @@
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -2923,7 +2926,7 @@
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -3028,7 +3031,7 @@
return 0;
}
-#line 3032 "compilers/imcc/imclexer.c"
+#line 3035 "compilers/imcc/imclexer.c"
if ( !yyg->yy_init )
{
@@ -4199,7 +4202,7 @@
#line 733 "compilers/imcc/imcc.l"
ECHO;
YY_BREAK
-#line 4203 "compilers/imcc/imclexer.c"
+#line 4206 "compilers/imcc/imclexer.c"
case YY_STATE_EOF(pod):
case YY_STATE_EOF(cmt1):
case YY_STATE_EOF(cmt2):
@@ -4463,6 +4466,14 @@
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) >
YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move +
(yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void
*) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in
yy_get_next_buffer()" );
+ }
+
yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] =
YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] =
YY_END_OF_BUFFER_CHAR;
@@ -4890,7 +4901,9 @@
yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc *
sizeof(struct yy_buffer_state*)
, yyscanner);
-
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in
yyensure_buffer_stack()" );
+
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct
yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
@@ -4908,6 +4921,8 @@
(yyg->yy_buffer_stack,
num_to_alloc *
sizeof(struct yy_buffer_state*)
, yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in
yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0,
grow_size * sizeof(struct yy_buffer_state*));
@@ -5018,8 +5033,7 @@
yyg->yy_start_stack = (int *) yyrealloc((void *)
yyg->yy_start_stack,new_size ,yyscanner );
if ( ! yyg->yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
+ YY_FATAL_ERROR( "out of memory expanding
start-condition stack" );
}
yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;
@@ -5243,6 +5257,42 @@
return yy_init_globals ( *ptr_yy_globals );
}
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to yyalloc in
+ * the yyextra field.
+ */
+
+int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
+{
+ struct yyguts_t dummy_yyguts;
+
+ yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ),
&dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h (original)
+++ trunk/include/parrot/sub.h Thu Feb 21 18:58:23 2008
@@ -1,5 +1,5 @@
/* sub.h
- * Copyright (C) 2001-2007, The Perl Foundation.
+ * Copyright (C) 2001-2008, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -45,13 +45,13 @@
#define SUB_FLAG_flag_CLEAR(flag, o) (SUB_FLAG_get_FLAGS(o) &=
~(UINTVAL)(SUB_FLAG_ ## flag))
#define SUB_FLAG_flags_SETTO(o, f) SUB_FLAG_get_FLAGS(o) = (f)
-#define SUB_FLAG_flags_CLEARALL(o) SUB_FLAG_flags_SETTO(o, 0)
+#define SUB_FLAG_flags_CLEARALL(o) SUB_FLAG_flags_SETTO((o), 0)
-#define SUB_FLAG_TAILCALL_TEST(o) SUB_FLAG_flag_TEST(TAILCALL, o)
-#define SUB_FLAG_TAILCALL_ISSET(o) SUB_FLAG_flag_TEST(TAILCALL, o)
-#define SUB_FLAG_TAILCALL_NOTSET(o) (!SUB_FLAG_flag_TEST(TAILCALL, o))
-#define SUB_FLAG_TAILCALL_SET(o) SUB_FLAG_flag_SET(TAILCALL, o)
-#define SUB_FLAG_TAILCALL_CLEAR(o) SUB_FLAG_flag_CLEAR(TAILCALL, o)
+#define SUB_FLAG_TAILCALL_TEST(o) SUB_FLAG_flag_TEST(TAILCALL, (o))
+#define SUB_FLAG_TAILCALL_ISSET(o) SUB_FLAG_flag_TEST(TAILCALL, (o))
+#define SUB_FLAG_TAILCALL_NOTSET(o) (!SUB_FLAG_flag_TEST(TAILCALL, (o)))
+#define SUB_FLAG_TAILCALL_SET(o) SUB_FLAG_flag_SET(TAILCALL, (o))
+#define SUB_FLAG_TAILCALL_CLEAR(o) SUB_FLAG_flag_CLEAR(TAILCALL, (o))
#define SUB_FLAG(n) ((UINTVAL)1 << (n))
typedef enum {
Modified: trunk/include/parrot/thr_pthread.h
==============================================================================
--- trunk/include/parrot/thr_pthread.h (original)
+++ trunk/include/parrot/thr_pthread.h Thu Feb 21 18:58:23 2008
@@ -19,40 +19,41 @@
# include <pthread.h>
# define PARROT_SYNC_PRIMITIVES_DEFINED
-# define LOCK(m) pthread_mutex_lock((pthread_mutex_t*)&m)
-# define UNLOCK(m) pthread_mutex_unlock((pthread_mutex_t*)&m)
-# define COND_WAIT(c, m) pthread_cond_wait(&c, &m)
-# define COND_TIMED_WAIT(c, m, t) pthread_cond_timedwait(&c, &m, t)
-# define COND_SIGNAL(c) pthread_cond_signal(&c)
-# define COND_BROADCAST(c) pthread_cond_broadcast(&c)
+# define LOCK(m) pthread_mutex_lock((pthread_mutex_t*)&(m))
+# define UNLOCK(m) pthread_mutex_unlock((pthread_mutex_t*)&(m))
+# define COND_WAIT(c, m) pthread_cond_wait(&(c), &(m))
+# define COND_TIMED_WAIT(c, m, t) pthread_cond_timedwait(&(c), &(m), (t))
+# define COND_SIGNAL(c) pthread_cond_signal(&(c))
+# define COND_BROADCAST(c) pthread_cond_broadcast(&(c))
/*
* for now use a fast mutex w/o error checking and non recursive
*/
-# define MUTEX_INIT(m) pthread_mutex_init(&m, NULL)
-# define MUTEX_DESTROY(m) pthread_mutex_destroy(&m)
+# define MUTEX_INIT(m) pthread_mutex_init(&(m), NULL)
+# define MUTEX_DESTROY(m) pthread_mutex_destroy(&(m))
-# define COND_INIT(c) pthread_cond_init(&c, NULL);
-# define COND_DESTROY(c) pthread_cond_destroy(&c)
+# define COND_INIT(c) pthread_cond_init(&(c), NULL);
+# define COND_DESTROY(c) pthread_cond_destroy(&(c))
-# define THREAD_CREATE_DETACHED(t, func, arg) do { \
+# define THREAD_CREATE_DETACHED(t, func, arg) \
+ do { \
pthread_attr_t attr; \
int rc = pthread_attr_init(&attr); \
PARROT_ASSERT(rc == 0); \
rc = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); \
PARROT_ASSERT(rc == 0); \
- rc = pthread_create(&t, &attr, func, arg); \
+ rc = pthread_create(&(t), &attr, (func), (arg)); \
PARROT_ASSERT(rc == 0); \
pthread_attr_destroy(&attr); \
} while (0)
# define THREAD_CREATE_JOINABLE(t, func, arg) \
- pthread_create(&t, NULL, func, arg)
+ pthread_create(&(t), NULL, (func), (arg))
-# define JOIN(t, ret) pthread_join(t, &ret)
+# define JOIN(t, ret) pthread_join((t), &(ret))
# define DETACH(t) pthread_detach(t)
-# define CLEANUP_PUSH(f, a) pthread_cleanup_push(f, a)
+# define CLEANUP_PUSH(f, a) pthread_cleanup_push((f), (a))
# define CLEANUP_POP(a) pthread_cleanup_pop(a)
typedef pthread_mutex_t Parrot_mutex;
Modified: trunk/include/parrot/thr_windows.h
==============================================================================
--- trunk/include/parrot/thr_windows.h (original)
+++ trunk/include/parrot/thr_windows.h Thu Feb 21 18:58:23 2008
@@ -86,8 +86,8 @@
# define JOIN(t, ret) \
do { \
- WaitForSingleObject(t, INFINITE); \
- GetExitCodeThread(t, (LPDWORD)&(ret)); \
+ WaitForSingleObject((t), INFINITE); \
+ GetExitCodeThread((t), (LPDWORD)&(ret)); \
CloseHandle(t); \
} while (0)
Modified: trunk/include/parrot/warnings.h
==============================================================================
--- trunk/include/parrot/warnings.h (original)
+++ trunk/include/parrot/warnings.h Thu Feb 21 18:58:23 2008
@@ -41,13 +41,13 @@
#define PARROT_we_test(we, interp, flag) \
(CONTEXT((interp)->ctx)->we & (flag))
-#define PARROT_WARNINGS_on(interp, flag) PARROT_we_on(warns, interp, flag)
-#define PARROT_WARNINGS_off(interp, flag) PARROT_we_off(warns, interp, flag)
-#define PARROT_WARNINGS_test(interp, flag) PARROT_we_test(warns, interp, flag)
-
-#define PARROT_ERRORS_on(interp, flag) PARROT_we_on(errors, interp, flag)
-#define PARROT_ERRORS_off(interp, flag) PARROT_we_off(errors, interp, flag)
-#define PARROT_ERRORS_test(interp, flag) PARROT_we_test(errors, interp, flag)
+#define PARROT_WARNINGS_on(interp, flag) PARROT_we_on(warns, (interp),
(flag))
+#define PARROT_WARNINGS_off(interp, flag) PARROT_we_off(warns, (interp),
(flag))
+#define PARROT_WARNINGS_test(interp, flag) PARROT_we_test(warns, (interp),
(flag))
+
+#define PARROT_ERRORS_on(interp, flag) PARROT_we_on(errors, (interp),
(flag))
+#define PARROT_ERRORS_off(interp, flag) PARROT_we_off(errors, (interp),
(flag))
+#define PARROT_ERRORS_test(interp, flag) PARROT_we_test(errors, (interp),
(flag))
#if defined(PARROT_IN_CORE)
Modified: trunk/src/bignum.h
==============================================================================
--- trunk/src/bignum.h (original)
+++ trunk/src/bignum.h Thu Feb 21 18:58:23 2008
@@ -33,18 +33,18 @@
#define PINT_ interpreter,
#define PINTD_ INTERP* interpreter,
#define BN_alloc(i, x) malloc(x)
-#define BN_realloc(i, x, y) realloc(x, y)
+#define BN_realloc(i, x, y) realloc((x), (y))
#define BN_free(i, x) free(x)
#define BN_FATAL(i, x) bn_fatal_error(x)
-#define BN_EXCEPT(i, excp, mesg) BN_exception(i, excp, mesg)
+#define BN_EXCEPT(i, excp, mesg) BN_exception((i), (excp), (mesg))
#else /* Not in parrot core */
#define PINTD_
#define PINT_
#define BN_alloc(x) malloc(x)
-#define BN_realloc(x, y) realloc(x, y)
+#define BN_realloc(x, y) realloc((x), (y))
#define BN_free(x) free(x)
#define BN_FATAL(x) bn_fatal_error(x)
-#define BN_EXCEPT(excp, mesg) BN_exception(excp, mesg)
+#define BN_EXCEPT(excp, mesg) BN_exception((excp), (mesg))
typedef unsigned int UINTVAL;
typedef int INTVAL;
#endif /* ifdef PARROT_IN_CORE else */
Modified: trunk/src/interp_guts.h
==============================================================================
--- trunk/src/interp_guts.h (original)
+++ trunk/src/interp_guts.h Thu Feb 21 18:58:23 2008
@@ -10,7 +10,7 @@
#ifndef PARROT_INTERP_GUTS_H_GUARD
#define PARROT_INTERP_GUTS_H_GUARD
-# define DO_OP(PC, INTERP) ((PC) = (((INTERP)->op_func_table)[*(PC)])(PC,
INTERP))
+# define DO_OP(PC, INTERP) ((PC) = (((INTERP)->op_func_table)[*(PC)])((PC),
(INTERP)))
#endif /* PARROT_INTERP_GUTS_H_GUARD */
Modified: trunk/src/pmc/capture.pmc
==============================================================================
--- trunk/src/pmc/capture.pmc (original)
+++ trunk/src/pmc/capture.pmc Thu Feb 21 18:58:23 2008
@@ -29,9 +29,9 @@
#define CAPTURE_array(obj) (((Capture_data*)PMC_data(obj))->array)
#define CAPTURE_hash(obj) (((Capture_data*)PMC_data(obj))->hash)
#define CAPTURE_array_CREATE(i, obj) \
- if (!CAPTURE_array(obj)) CAPTURE_array(obj) = pmc_new(i,
enum_class_ResizablePMCArray);
+ if (!CAPTURE_array(obj)) CAPTURE_array(obj) = pmc_new((i),
enum_class_ResizablePMCArray);
#define CAPTURE_hash_CREATE(i, obj) \
- if (!CAPTURE_hash(obj)) CAPTURE_hash(obj) = pmc_new(i, enum_class_Hash);
+ if (!CAPTURE_hash(obj)) CAPTURE_hash(obj) = pmc_new((i), enum_class_Hash);
pmclass Capture need_ext does array does hash {