diff options
Diffstat (limited to 'libgpython/include/gpython')
| -rw-r--r-- | libgpython/include/gpython/gpython.h | 82 | ||||
| -rw-r--r-- | libgpython/include/gpython/vectors.h | 49 |
2 files changed, 127 insertions, 4 deletions
diff --git a/libgpython/include/gpython/gpython.h b/libgpython/include/gpython/gpython.h index e2a18bb1381..345b29a9b92 100644 --- a/libgpython/include/gpython/gpython.h +++ b/libgpython/include/gpython/gpython.h @@ -14,8 +14,39 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ -#ifndef __GCC_GPYTHON__ -#define __GCC_GPYTHON__ +#ifndef __GCC_GPYTHON_H__ +#define __GCC_GPYTHON_H__ + +#if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "<unknown>" +# endif +#endif + +/* Abstract out some useful compiler attributes from GCC */ +#if defined( GUNC ) +# define __gpy_fmt_check( x, y ) \ + __attribute__ ((format (printf, x, y))) +# define __gpy_no_return \ + __attribute__ ((noreturn)) +# define __gpy_malloc \ + __attribute__ ((malloc)) +# define __gpy_pure \ + __attribute__ ((pure)) +# define __gpy_unused \ + __attribute__ ((unused)) +# define __gpy_nonnull \ + __attribute__((nonnull)) +#else +# define __gpy_fmt_check( x, y ) +# define __gpy_no_return +# define __gpy_malloc +# define __gpy_pure +# define __gpy_unused +# define __gpy_nonnull +#endif typedef struct gpy_rr_object_state_t { char * obj_t_ident; @@ -25,7 +56,19 @@ typedef struct gpy_rr_object_state_t { typedef gpy_rr_object_state_t * gpy_object_state_t; -typedef gpy_object_state_t (*binary_op)( gpy_object_state_t, gpy_object_state_t ); +typedef gpy_object_state_t (*binary_op)( gpy_object_state_t, + gpy_object_state_t ); + +enum GPY_LIT_T { TYPE_INTEGER, TYPE_STRING }; + +typedef struct gpy_rr_literal_t { + enum GPY_LIT_T; + union { + int integer; + char * string; + /* ... */ + } +} gpy_literal_t ; typedef struct gpy_number_prot_t { @@ -66,6 +109,37 @@ typedef struct gpy_type_obj_def_t { free( x ); \ x = NULL; +#ifdef DEBUG +extern void +__gpy_debug__( const char *, unsigned , + const char *, const char *, ... ) + __gpy_fmt_check(4,5) ; +#endif + +extern void +__gpy_error__( const char *, unsigned , + const char *, const char *, ... ) + __gpy_fmt_check(4,5) ; + +extern void +__gpy_fatal__( const char *, unsigned , + const char *, const char *, ... ) + __gpy_fmt_check(4,5) ; + +#ifdef DEBUG +# define debug( ... ) \ + __gpy_debug__( __FILE__, __LINE__, __func__, __VA_ARGS__ ); +#else +# define debug( ... ) +#endif + +#define fatal( ... ) \ + __gpy_fatal__( __FILE__, __LINE__, __func__, __VA_ARGS__ ); + +#define error( ... ) \ + __gpy_error__( __FILE__, __LINE__, __func__, __VA_ARGS__ ); + + extern void gpy_assertion_failed( const char * , unsigned , const char * , const char * ); @@ -74,4 +148,4 @@ extern gpy_object_state_t gpy_rr_fold_integer( int ); extern void gpy_obj_integer_mod_init( void ); -#endif //__GCC_GPYTHON__ +#endif //__GCC_GPYTHON_H__ diff --git a/libgpython/include/gpython/vectors.h b/libgpython/include/gpython/vectors.h new file mode 100644 index 00000000000..19fea8caa9d --- /dev/null +++ b/libgpython/include/gpython/vectors.h @@ -0,0 +1,49 @@ +/* This file is part of GCC. + +GCC 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 3, or (at your option) any later +version. + +GCC 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. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef __GCC_VECTORS_H__ +#define __GCC_VECTORS_H__ + +#define gpy_threshold_alloc(x) (((x)+16)*3/2) + +typedef struct gpy_vector_t { + void ** vector; + signed long size, length; +} gpy_ident_vector_t; + +typedef unsigned long gpy_hashval_t; + +typedef struct gpy_hash_entry { + gpy_hashval_t hash; + void * data; +} gpy_hash_entry_t ; + +typedef struct gpy_hash_table_t { + unsigned int size, length; + gpy_hash_entry_t * array; +} gpy_hash_tab_t ; + +extern gpy_hashval_t gpy_dd_hash_string( const char * ); + +extern gpy_hash_entry_t * gpy_dd_hash_lookup_table( gpy_hash_tab_t *, gpy_hashval_t ); + +extern void ** gpy_dd_hash_insert( gpy_hashval_t, void *, gpy_hash_tab_t * ); + +extern void gpy_dd_hash_grow_table( gpy_hash_tab_t * ); + +extern void gpy_dd_hash_init_table( gpy_hash_tab_t ** ); + +#endif //__GCC_VECTORS_H__ |
