Blob Blame History Raw
diff -up src/c_lib/include/ntl_wrap.h.orig src/c_lib/include/ntl_wrap.h
--- src/c_lib/include/ntl_wrap.h.orig	2014-02-07 15:20:57.081216365 -0200
+++ src/c_lib/include/ntl_wrap.h	2014-02-07 15:21:04.225216638 -0200
@@ -40,91 +40,92 @@ EXTERN void setup_NTL_error_callback(voi
 ////////  ZZ //////////
 
 #ifndef __cplusplus
-struct ZZ;
+typedef struct ZZ ZZ;
 #endif
 
-EXTERN int ZZ_to_int(const struct ZZ* x);
-EXTERN struct ZZ* int_to_ZZ(int value);
-EXTERN void ZZ_to_mpz(mpz_t* output, const struct ZZ* x);
-EXTERN void mpz_to_ZZ(struct ZZ *output, const mpz_t* x);
-EXTERN void ZZ_set_from_int(struct ZZ* x, int value);
+EXTERN int ZZ_to_int(const ZZ* x);
+EXTERN ZZ* int_to_ZZ(int value);
+EXTERN void ZZ_to_mpz(mpz_t* output, const ZZ* x);
+EXTERN void mpz_to_ZZ(ZZ *output, const mpz_t* x);
+EXTERN void ZZ_set_from_int(ZZ* x, int value);
 /*Random-number generation */
-//EXTERN void setSeed(const struct ZZ* n);
-//EXTERN struct ZZ* ZZ_randomBnd(const struct ZZ* x);
-//EXTERN struct ZZ* ZZ_randomBits(long n);
+//EXTERN void setSeed(const ZZ* n);
+//EXTERN ZZ* ZZ_randomBnd(const ZZ* x);
+//EXTERN ZZ* ZZ_randomBits(long n);
 
 #ifdef __cplusplus
-EXTERN long ZZ_remove(struct ZZ& x, const struct ZZ& a, const struct ZZ& p);
+EXTERN long ZZ_remove(ZZ& x, const ZZ& a, const ZZ& p);
 #endif
 
 ////////  ZZ_p //////////
 
 #ifndef __cplusplus
-struct ZZ_p;
+typedef struct ZZ_p ZZ_p;
+typedef struct ZZ_pContext ZZ_pContext;
 #endif
 
 #ifdef __cplusplus  // sorry, if you want a C version, feel free to add it
 EXTERN int ZZ_p_to_int(const ZZ_p& x);
 EXTERN ZZ_p int_to_ZZ_p(int value);
 #endif
-EXTERN void ZZ_p_set_from_int(struct ZZ_p* x, int value);
-EXTERN struct ZZ_p* ZZ_p_pow(const struct ZZ_p* x, long e);
-EXTERN void ntl_ZZ_set_modulus(struct ZZ* x);
-EXTERN struct ZZ_p* ZZ_p_inv(struct ZZ_p* x);
-EXTERN struct ZZ_p* ZZ_p_neg(struct ZZ_p* x);
-EXTERN struct ZZ_p* ZZ_p_random(void);
-EXTERN void ZZ_p_modulus(struct ZZ* mod, const struct ZZ_p* x);
+EXTERN void ZZ_p_set_from_int(ZZ_p* x, int value);
+EXTERN ZZ_p* ZZ_p_pow(const ZZ_p* x, long e);
+EXTERN void ntl_ZZ_set_modulus(ZZ* x);
+EXTERN ZZ_p* ZZ_p_inv(ZZ_p* x);
+EXTERN ZZ_p* ZZ_p_neg(ZZ_p* x);
+EXTERN ZZ_p* ZZ_p_random(void);
+EXTERN void ZZ_p_modulus(ZZ* mod, const ZZ_p* x);
 
 
-EXTERN struct ZZ_pContext* ZZ_pContext_new(struct ZZ* p);
-EXTERN struct ZZ_pContext* ZZ_pContext_construct(void* mem, struct ZZ* p);
+EXTERN ZZ_pContext* ZZ_pContext_new(ZZ* p);
+EXTERN ZZ_pContext* ZZ_pContext_construct(void* mem, ZZ* p);
 
 //////// ZZX //////////
 #ifndef __cplusplus
-struct ZZX;
+typedef struct ZZX ZZX;
 #endif
 
-EXTERN char* ZZX_repr(struct ZZX* x);
-EXTERN struct ZZX* ZZX_copy(struct ZZX* x);
-EXTERN void ZZX_setitem_from_int(struct ZZX* x, long i, int value);
-EXTERN int ZZX_getitem_as_int(struct ZZX* x, long i);
-EXTERN void ZZX_getitem_as_mpz(mpz_t* output, struct ZZX* x, long i);
-EXTERN struct ZZX* ZZX_div(struct ZZX* x, struct ZZX* y, int* divisible);
-EXTERN void ZZX_quo_rem(struct ZZX* x, struct ZZX* other, struct ZZX** r, struct ZZX** q);
-EXTERN struct ZZX* ZZX_square(struct ZZX* x);
-EXTERN int ZZX_equal(struct ZZX* x, struct ZZX* y);
-EXTERN int ZZX_is_monic(struct ZZX* x);
-EXTERN struct ZZX* ZZX_neg(struct ZZX* x);
-EXTERN struct ZZX* ZZX_left_shift(struct ZZX* x, long n);
-EXTERN struct ZZX* ZZX_right_shift(struct ZZX* x, long n);
-EXTERN char* ZZX_content(struct ZZX* x);
-EXTERN struct ZZX* ZZX_primitive_part(struct ZZX* x);
-EXTERN void ZZX_pseudo_quo_rem(struct ZZX* x, struct ZZX* y, struct ZZX** r, struct ZZX** q);
-EXTERN struct ZZX* ZZX_gcd(struct ZZX* x, struct ZZX* y);
-EXTERN void ZZX_xgcd(struct ZZX* x, struct ZZX* y, struct ZZ** r, struct ZZX** s, struct ZZX** t, int proof);
-EXTERN long ZZX_degree(struct ZZX* x);
-EXTERN struct ZZ* ZZX_leading_coefficient(struct ZZX* x);
-EXTERN char* ZZX_constant_term(struct ZZX* x);
-EXTERN void ZZX_set_x(struct ZZX* x);
-EXTERN int ZZX_is_x(struct ZZX* x);
-EXTERN struct ZZX* ZZX_derivative(struct ZZX* x);
-EXTERN struct ZZX* ZZX_reverse(struct ZZX* x);
-EXTERN struct ZZX* ZZX_reverse_hi(struct ZZX* x, int hi);
-EXTERN struct ZZX* ZZX_truncate(struct ZZX* x, long m);
-EXTERN struct ZZX* ZZX_multiply_and_truncate(struct ZZX* x, struct ZZX* y, long m);
-EXTERN struct ZZX* ZZX_square_and_truncate(struct ZZX* x, long m);
-EXTERN struct ZZX* ZZX_invert_and_truncate(struct ZZX* x, long m);
-EXTERN struct ZZX* ZZX_multiply_mod(struct ZZX* x, struct ZZX* y,  struct ZZX* modulus);
-EXTERN struct ZZ* ZZX_trace_mod(struct ZZX* x, struct ZZX* y);
-/* EXTERN struct ZZ* ZZX_polyeval(struct ZZX* f, struct ZZ* a); */
-EXTERN char* ZZX_trace_list(struct ZZX* x);
-EXTERN struct ZZ* ZZX_resultant(struct ZZX* x, struct ZZX* y, int proof);
-EXTERN struct ZZ* ZZX_norm_mod(struct ZZX* x, struct ZZX* y, int proof);
-EXTERN struct ZZ* ZZX_discriminant(struct ZZX* x, int proof);
-EXTERN struct ZZX* ZZX_charpoly_mod(struct ZZX* x, struct ZZX* y, int proof);
-EXTERN struct ZZX* ZZX_minpoly_mod(struct ZZX* x, struct ZZX* y);
-EXTERN void ZZX_clear(struct ZZX* x);
-EXTERN void ZZX_preallocate_space(struct ZZX* x, long n);
+EXTERN char* ZZX_repr(ZZX* x);
+EXTERN ZZX* ZZX_copy(ZZX* x);
+EXTERN void ZZX_setitem_from_int(ZZX* x, long i, int value);
+EXTERN int ZZX_getitem_as_int(ZZX* x, long i);
+EXTERN void ZZX_getitem_as_mpz(mpz_t* output, ZZX* x, long i);
+EXTERN ZZX* ZZX_div(ZZX* x, ZZX* y, int* divisible);
+EXTERN void ZZX_quo_rem(ZZX* x, ZZX* other, ZZX** r, ZZX** q);
+EXTERN ZZX* ZZX_square(ZZX* x);
+EXTERN int ZZX_equal(ZZX* x, ZZX* y);
+EXTERN int ZZX_is_monic(ZZX* x);
+EXTERN ZZX* ZZX_neg(ZZX* x);
+EXTERN ZZX* ZZX_left_shift(ZZX* x, long n);
+EXTERN ZZX* ZZX_right_shift(ZZX* x, long n);
+EXTERN char* ZZX_content(ZZX* x);
+EXTERN ZZX* ZZX_primitive_part(ZZX* x);
+EXTERN void ZZX_pseudo_quo_rem(ZZX* x, ZZX* y, ZZX** r, ZZX** q);
+EXTERN ZZX* ZZX_gcd(ZZX* x, ZZX* y);
+EXTERN void ZZX_xgcd(ZZX* x, ZZX* y, ZZ** r, ZZX** s, ZZX** t, int proof);
+EXTERN long ZZX_degree(ZZX* x);
+EXTERN ZZ* ZZX_leading_coefficient(ZZX* x);
+EXTERN char* ZZX_constant_term(ZZX* x);
+EXTERN void ZZX_set_x(ZZX* x);
+EXTERN int ZZX_is_x(ZZX* x);
+EXTERN ZZX* ZZX_derivative(ZZX* x);
+EXTERN ZZX* ZZX_reverse(ZZX* x);
+EXTERN ZZX* ZZX_reverse_hi(ZZX* x, int hi);
+EXTERN ZZX* ZZX_truncate(ZZX* x, long m);
+EXTERN ZZX* ZZX_multiply_and_truncate(ZZX* x, ZZX* y, long m);
+EXTERN ZZX* ZZX_square_and_truncate(ZZX* x, long m);
+EXTERN ZZX* ZZX_invert_and_truncate(ZZX* x, long m);
+EXTERN ZZX* ZZX_multiply_mod(ZZX* x, ZZX* y,  ZZX* modulus);
+EXTERN ZZ* ZZX_trace_mod(ZZX* x, ZZX* y);
+/* EXTERN ZZ* ZZX_polyeval(ZZX* f, ZZ* a); */
+EXTERN char* ZZX_trace_list(ZZX* x);
+EXTERN ZZ* ZZX_resultant(ZZX* x, ZZX* y, int proof);
+EXTERN ZZ* ZZX_norm_mod(ZZX* x, ZZX* y, int proof);
+EXTERN ZZ* ZZX_discriminant(ZZX* x, int proof);
+EXTERN ZZX* ZZX_charpoly_mod(ZZX* x, ZZX* y, int proof);
+EXTERN ZZX* ZZX_minpoly_mod(ZZX* x, ZZX* y);
+EXTERN void ZZX_clear(ZZX* x);
+EXTERN void ZZX_preallocate_space(ZZX* x, long n);
 
 //////// ZZXFactoring //////////
 
@@ -132,76 +133,77 @@ EXTERN void ZZX_preallocate_space(struct
 //         e -- point to list of e longs (the exponents)
 //         n -- length of above two lists
 //  The lists v and e are mallocd, and must be freed by the calling code.
-EXTERN void ZZX_squarefree_decomposition(struct ZZX*** v, long** e, long* n, struct ZZX* x);
+EXTERN void ZZX_squarefree_decomposition(ZZX*** v, long** e, long* n, ZZX* x);
 
 
 //////// ZZ_pX //////////
 #ifndef __cplusplus
-struct ZZ_pX;
+typedef struct ZZ_pX ZZ_pX;
 #endif
 
-EXTERN struct ZZ_pX* ZZ_pX_init();
-//EXTERN char* ZZ_pX_repr(struct ZZ_pX* x);
-/* EXTERN struct ZZ_pX* ZZ_pX_copy(struct ZZ_pX* x); */
-/* EXTERN void ZZ_pX_setitem_from_int(struct ZZ_pX* x, long i, int value); */
-/* EXTERN int ZZ_pX_getitem_as_int(struct ZZ_pX* x, long i); */
-/* EXTERN struct ZZ_pX* ZZ_pX_div(struct ZZ_pX* x, struct ZZ_pX* y, int* divisible); */
-/* EXTERN struct ZZ_pX* ZZ_pX_mod(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN void ZZ_pX_quo_rem(struct ZZ_pX* x, struct ZZ_pX* other, struct ZZ_pX** r, struct ZZ_pX** q); */
-/* EXTERN struct ZZ_pX* ZZ_pX_square(struct ZZ_pX* x); */
-/* EXTERN int ZZ_pX_equal(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN int ZZ_pX_is_monic(struct ZZ_pX* x); */
-/* EXTERN struct ZZ_pX* ZZ_pX_neg(struct ZZ_pX* x); */
-/* EXTERN struct ZZ_pX* ZZ_pX_left_shift(struct ZZ_pX* x, long n); */
-/* EXTERN struct ZZ_pX* ZZ_pX_right_shift(struct ZZ_pX* x, long n); */
-/* EXTERN void ZZ_pX_quo_rem(struct ZZ_pX* x, struct ZZ_pX* y, struct ZZ_pX** r, struct ZZ_pX** q); */
-/* EXTERN struct ZZ_pX* ZZ_pX_gcd(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN void ZZ_pX_xgcd(struct ZZ_pX** d, struct ZZ_pX** s, struct ZZ_pX** t, struct ZZ_pX* a, struct ZZ_pX* b); */
-/* EXTERN void ZZ_pX_plain_xgcd(struct ZZ_pX** d, struct ZZ_pX** s, struct ZZ_pX** t, struct ZZ_pX* a, struct ZZ_pX* b); */
-/* EXTERN long ZZ_pX_degree(struct ZZ_pX* x); */
-/* EXTERN void ZZ_pX_set_x(struct ZZ_pX* x); */
-/* EXTERN int ZZ_pX_is_x(struct ZZ_pX* x); */
-/* EXTERN struct ZZ_pX* ZZ_pX_derivative(struct ZZ_pX* x); */
-/* EXTERN struct ZZ_pX* ZZ_pX_reverse(struct ZZ_pX* x); */
-/* EXTERN struct ZZ_pX* ZZ_pX_reverse_hi(struct ZZ_pX* x, int hi); */
-/* EXTERN struct ZZ_pX* ZZ_pX_truncate(struct ZZ_pX* x, long m); */
-/* EXTERN struct ZZ_pX* ZZ_pX_multiply_and_truncate(struct ZZ_pX* x, struct ZZ_pX* y, long m); */
-/* EXTERN struct ZZ_pX* ZZ_pX_square_and_truncate(struct ZZ_pX* x, long m); */
-/* EXTERN struct ZZ_pX* ZZ_pX_invert_and_truncate(struct ZZ_pX* x, long m); */
-/* EXTERN struct ZZ_pX* ZZ_pX_multiply_mod(struct ZZ_pX* x, struct ZZ_pX* y,  struct ZZ_pX* modulus); */
-/* EXTERN struct ZZ_p* ZZ_pX_trace_mod(struct ZZ_pX* x, struct ZZ_pX* y); */
-EXTERN char* ZZ_pX_trace_list(struct ZZ_pX* x);
-/* EXTERN struct ZZ_p* ZZ_pX_resultant(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN struct ZZ_p* ZZ_pX_norm_mod(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN struct ZZ_pX* ZZ_pX_charpoly_mod(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN struct ZZ_pX* ZZ_pX_minpoly_mod(struct ZZ_pX* x, struct ZZ_pX* y); */
-/* EXTERN void ZZ_pX_clear(struct ZZ_pX* x); */
-// EXTERN void ZZ_pX_preallocate_space(struct ZZ_pX* x, long n);
+EXTERN ZZ_pX* ZZ_pX_init();
+//EXTERN char* ZZ_pX_repr(ZZ_pX* x);
+/* EXTERN ZZ_pX* ZZ_pX_copy(ZZ_pX* x); */
+/* EXTERN void ZZ_pX_setitem_from_int(ZZ_pX* x, long i, int value); */
+/* EXTERN int ZZ_pX_getitem_as_int(ZZ_pX* x, long i); */
+/* EXTERN ZZ_pX* ZZ_pX_div(ZZ_pX* x, ZZ_pX* y, int* divisible); */
+/* EXTERN ZZ_pX* ZZ_pX_mod(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN void ZZ_pX_quo_rem(ZZ_pX* x, ZZ_pX* other, ZZ_pX** r, ZZ_pX** q); */
+/* EXTERN ZZ_pX* ZZ_pX_square(ZZ_pX* x); */
+/* EXTERN int ZZ_pX_equal(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN int ZZ_pX_is_monic(ZZ_pX* x); */
+/* EXTERN ZZ_pX* ZZ_pX_neg(ZZ_pX* x); */
+/* EXTERN ZZ_pX* ZZ_pX_left_shift(ZZ_pX* x, long n); */
+/* EXTERN ZZ_pX* ZZ_pX_right_shift(ZZ_pX* x, long n); */
+/* EXTERN void ZZ_pX_quo_rem(ZZ_pX* x, ZZ_pX* y, ZZ_pX** r, ZZ_pX** q); */
+/* EXTERN ZZ_pX* ZZ_pX_gcd(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN void ZZ_pX_xgcd(ZZ_pX** d, ZZ_pX** s, ZZ_pX** t, ZZ_pX* a, ZZ_pX* b); */
+/* EXTERN void ZZ_pX_plain_xgcd(ZZ_pX** d, ZZ_pX** s, ZZ_pX** t, ZZ_pX* a, ZZ_pX* b); */
+/* EXTERN long ZZ_pX_degree(ZZ_pX* x); */
+/* EXTERN void ZZ_pX_set_x(ZZ_pX* x); */
+/* EXTERN int ZZ_pX_is_x(ZZ_pX* x); */
+/* EXTERN ZZ_pX* ZZ_pX_derivative(ZZ_pX* x); */
+/* EXTERN ZZ_pX* ZZ_pX_reverse(ZZ_pX* x); */
+/* EXTERN ZZ_pX* ZZ_pX_reverse_hi(ZZ_pX* x, int hi); */
+/* EXTERN ZZ_pX* ZZ_pX_truncate(ZZ_pX* x, long m); */
+/* EXTERN ZZ_pX* ZZ_pX_multiply_and_truncate(ZZ_pX* x, ZZ_pX* y, long m); */
+/* EXTERN ZZ_pX* ZZ_pX_square_and_truncate(ZZ_pX* x, long m); */
+/* EXTERN ZZ_pX* ZZ_pX_invert_and_truncate(ZZ_pX* x, long m); */
+/* EXTERN ZZ_pX* ZZ_pX_multiply_mod(ZZ_pX* x, ZZ_pX* y,  ZZ_pX* modulus); */
+/* EXTERN ZZ_p* ZZ_pX_trace_mod(ZZ_pX* x, ZZ_pX* y); */
+EXTERN char* ZZ_pX_trace_list(ZZ_pX* x);
+/* EXTERN ZZ_p* ZZ_pX_resultant(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN ZZ_p* ZZ_pX_norm_mod(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN ZZ_pX* ZZ_pX_charpoly_mod(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN ZZ_pX* ZZ_pX_minpoly_mod(ZZ_pX* x, ZZ_pX* y); */
+/* EXTERN void ZZ_pX_clear(ZZ_pX* x); */
+// EXTERN void ZZ_pX_preallocate_space(ZZ_pX* x, long n);
 
 // Factoring elements of ZZ_pX:
 // OUTPUT: v -- pointer to list of n ZZ_pX elements (the irred factors)
 //         e -- point to list of e longs (the exponents)
 //         n -- length of above two lists
 //  The lists v and e are mallocd, and must be freed by the calling code.
-EXTERN void ZZ_pX_factor(struct ZZ_pX*** v, long** e, long* n, struct ZZ_pX* x, long verbose);
-EXTERN void ZZ_pX_linear_roots(struct ZZ_p*** v, long* n, struct ZZ_pX* f);
+EXTERN void ZZ_pX_factor(ZZ_pX*** v, long** e, long* n, ZZ_pX* x, long verbose);
+EXTERN void ZZ_pX_linear_roots(ZZ_p*** v, long* n, ZZ_pX* f);
 
 #ifdef __cplusplus
-EXTERN void ZZ_pX_conv_modulus(struct ZZ_pX &fout, const struct ZZ_pX &fin, const struct ZZ_pContext &mod);
-EXTERN void ZZ_pEX_conv_modulus(struct ZZ_pEX &fout, const struct ZZ_pEX &fin, const struct ZZ_pContext &mod);
-EXTERN void ZZ_pX_min_val_coeff(long &valuation, long &index, const struct ZZ_pX &f, const struct ZZ &p);
-EXTERN long ZZ_pX_get_val_coeff(const struct ZZ_pX &f, const struct ZZ &p, long i);
-EXTERN void ZZ_pX_left_pshift(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ &pn, const struct ZZ_pContext &c);
-EXTERN void ZZ_pX_right_pshift(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ &pn, const struct ZZ_pContext &c);
-EXTERN void ZZ_pX_InvMod_newton_unram(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ_pXModulus &F, const struct ZZ_pContext &cpn, const struct ZZ_pContext &cp);
-EXTERN void ZZ_pX_InvMod_newton_ram(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ_pXModulus &F, const struct ZZ_pContext &cpn);
+EXTERN void ZZ_pX_conv_modulus(ZZ_pX &fout, const ZZ_pX &fin, const ZZ_pContext &mod);
+EXTERN void ZZ_pEX_conv_modulus(ZZ_pEX &fout, const ZZ_pEX &fin, const ZZ_pContext &mod);
+EXTERN void ZZ_pX_min_val_coeff(long &valuation, long &index, const ZZ_pX &f, const ZZ &p);
+EXTERN long ZZ_pX_get_val_coeff(const ZZ_pX &f, const ZZ &p, long i);
+EXTERN void ZZ_pX_left_pshift(ZZ_pX &x, const ZZ_pX &a, const ZZ &pn, const ZZ_pContext &c);
+EXTERN void ZZ_pX_right_pshift(ZZ_pX &x, const ZZ_pX &a, const ZZ &pn, const ZZ_pContext &c);
+EXTERN void ZZ_pX_InvMod_newton_unram(ZZ_pX &x, const ZZ_pX &a, const ZZ_pXModulus &F, const ZZ_pContext &cpn, const ZZ_pContext &cp);
+EXTERN void ZZ_pX_InvMod_newton_ram(ZZ_pX &x, const ZZ_pX &a, const ZZ_pXModulus &F, const ZZ_pContext &cpn);
 
 #endif
 
 //////// zz_p //////////
 
 #ifndef __cplusplus
-struct zz_p;
+typedef struct zz_p zz_p;
+typedef struct zz_pContext zz_pContext;
 #endif
 
 #define zz_p_set_from_long( obj1, obj2 )\
@@ -209,14 +211,14 @@ struct zz_p;
 #define NTL_zz_p_DOUBLE_EQUALS( obj1, obj2 )\
         (obj1) == (obj2)
 
-EXTERN struct zz_pContext* zz_pContext_new(long p);
-EXTERN struct zz_pContext* zz_pContext_construct(void* mem, long p);
-EXTERN void zz_pContext_restore(struct zz_pContext* ctx);
+EXTERN zz_pContext* zz_pContext_new(long p);
+EXTERN zz_pContext* zz_pContext_construct(void* mem, long p);
+EXTERN void zz_pContext_restore(zz_pContext* ctx);
 
 //////// zz_pX //////////
 
 #ifndef __cplusplus
-struct zz_pX;
+typedef struct ZZ_pX ZZ_pX;
 #endif
 
 #define NTL_zz_pX_DOUBLE_EQUALS( obj1, obj2 )\
@@ -225,64 +227,63 @@ struct zz_pX;
 //////// ZZ_pEContext ///////////////
 
 #ifndef __cplusplus
-struct ZZ_pEContext;
+typedef struct ZZ_pEContext ZZ_pEContext;
 #endif
 
-EXTERN struct ZZ_pEContext* ZZ_pEContext_new(struct ZZ_pX *f);
-EXTERN struct ZZ_pEContext* ZZ_pEContext_construct(void* mem, struct ZZ_pX *f);
-EXTERN void ZZ_pEContext_restore(struct ZZ_pEContext* ctx);
+EXTERN ZZ_pEContext* ZZ_pEContext_new(ZZ_pX *f);
+EXTERN ZZ_pEContext* ZZ_pEContext_construct(void* mem, ZZ_pX *f);
+EXTERN void ZZ_pEContext_restore(ZZ_pEContext* ctx);
 
 //////// ZZ_pE ////////////
 
 #ifndef __cplusplus
-struct ZZ_pE;
+typedef struct ZZ_pE ZZ_pE;
 #endif
 
-EXTERN struct ZZ_pX ZZ_pE_to_ZZ_pX(struct ZZ_pE x);
+EXTERN ZZ_pX ZZ_pE_to_ZZ_pX(ZZ_pE x);
 
 //////// ZZ_pEX /////////
 
 #ifndef __cplusplus
-struct ZZ_pEX;
+typedef struct ZZ_pEX ZZ_pEX;
 #endif
 
 //////// mat_ZZ //////////
-
 #ifndef __cplusplus
-struct mat_ZZ;
+typedef struct mat_ZZ mat_ZZ;
 #endif
 
-EXTERN void mat_ZZ_SetDims(struct mat_ZZ* mZZ, long nrows, long ncols);
-EXTERN struct mat_ZZ* mat_ZZ_pow(const struct mat_ZZ* x, long e);
-EXTERN long mat_ZZ_nrows(const struct mat_ZZ* x);
-EXTERN long mat_ZZ_ncols(const struct mat_ZZ* x);
-EXTERN void mat_ZZ_setitem(struct mat_ZZ* x, int i, int j, const struct ZZ* z);
-EXTERN struct ZZ* mat_ZZ_getitem(const struct mat_ZZ* x, int i, int j);
-EXTERN struct ZZ* mat_ZZ_determinant(const struct mat_ZZ* x, long deterministic);
-EXTERN struct mat_ZZ* mat_ZZ_HNF(const struct mat_ZZ* A, const struct ZZ* D);
-EXTERN struct ZZX* mat_ZZ_charpoly(const struct mat_ZZ* A);
-EXTERN long mat_ZZ_LLL(struct ZZ **det, struct mat_ZZ *x, long a, long b, long verbose);
-EXTERN long mat_ZZ_LLL_U(struct ZZ **det, struct mat_ZZ *x, struct mat_ZZ *U, long a, long b, long verbose);
+EXTERN void mat_ZZ_SetDims(mat_ZZ* mZZ, long nrows, long ncols);
+EXTERN mat_ZZ* mat_ZZ_pow(const mat_ZZ* x, long e);
+EXTERN long mat_ZZ_nrows(const mat_ZZ* x);
+EXTERN long mat_ZZ_ncols(const mat_ZZ* x);
+EXTERN void mat_ZZ_setitem(mat_ZZ* x, int i, int j, const ZZ* z);
+EXTERN ZZ* mat_ZZ_getitem(const mat_ZZ* x, int i, int j);
+EXTERN ZZ* mat_ZZ_determinant(const mat_ZZ* x, long deterministic);
+EXTERN mat_ZZ* mat_ZZ_HNF(const mat_ZZ* A, const ZZ* D);
+EXTERN ZZX* mat_ZZ_charpoly(const mat_ZZ* A);
+EXTERN long mat_ZZ_LLL(ZZ **det, mat_ZZ *x, long a, long b, long verbose);
+EXTERN long mat_ZZ_LLL_U(ZZ **det, mat_ZZ *x, mat_ZZ *U, long a, long b, long verbose);
 
 /* //////// ZZ_p ////////// */
 /* #ifndef __cplusplus */
-/* struct ZZ_p; */
+/* typedef struct ZZ_p ZZ_p; */
 /* #endif */
 
-/* EXTERN void ZZ_p_set_modulus(const struct ZZ* p); */
-/* EXTERN struct ZZ_p* new_ZZ_p(void); */
-/* EXTERN void del_ZZ_p(struct ZZ_p* x); */
-/* EXTERN struct ZZ_p* ZZ_p_add(const struct ZZ_p* x, const struct ZZ_p* y); */
-/* EXTERN struct ZZ_p* ZZ_p_sub(const struct ZZ_p* x, const struct ZZ_p* y); */
-/* EXTERN struct ZZ_p* ZZ_p_mul(const struct ZZ_p* x, const struct ZZ_p* y); */
-/* EXTERN struct ZZ_p* ZZ_p_pow(const struct ZZ_p* x, long e); */
-/* EXTERN int ZZ_p_is_zero(struct ZZ_p*x ); */
-/* EXTERN int ZZ_p_is_one(struct ZZ_p*x ); */
+/* EXTERN void ZZ_p_set_modulus(const ZZ* p); */
+/* EXTERN ZZ_p* new_ZZ_p(void); */
+/* EXTERN void del_ZZ_p(ZZ_p* x); */
+/* EXTERN ZZ_p* ZZ_p_add(const ZZ_p* x, const ZZ_p* y); */
+/* EXTERN ZZ_p* ZZ_p_sub(const ZZ_p* x, const ZZ_p* y); */
+/* EXTERN ZZ_p* ZZ_p_mul(const ZZ_p* x, const ZZ_p* y); */
+/* EXTERN ZZ_p* ZZ_p_pow(const ZZ_p* x, long e); */
+/* EXTERN int ZZ_p_is_zero(ZZ_p*x ); */
+/* EXTERN int ZZ_p_is_one(ZZ_p*x ); */
 
 
 //////// ZZ_pE //////////
 #ifndef __cplusplus
-struct ZZ_pE;
+typedef struct ZZ_pE ZZ_pE;
 #endif
 
 // EXTERN struct ZZ_pE* new_ZZ_pE
@@ -292,37 +293,40 @@ struct ZZ_pE;
 //////// ZZ_pEX //////////
 
 //#ifndef __cplusplus
-//struct ZZ_pEX;
+//typedef struct ZZ_pEX ZZ_pEX;
 //#endif
 
-//EXTERN struct ZZ_pEX* new_ZZ_pEX
+//EXTERN ZZ_pEX* new_ZZ_pEX
 
 /////// GF2X ////////////////
 #ifndef __cplusplus
-struct GF2X;
+typedef struct GF2X GF2X;
 #endif
 
 /////// GF2EContext ////////////////
 
 #ifndef __cplusplus
-struct GF2EContext;
+typedef struct GF2E GF2E;
+typedef struct GF2EContext GF2EContext;
 #endif
+typedef GF2X GF2X_c;
 
-EXTERN struct GF2EContext* GF2EContext_new(struct GF2X_c* p);
-EXTERN struct GF2EContext* GF2EContext_construct(void *mem, const struct GF2X *p);
+EXTERN GF2EContext* GF2EContext_new(GF2X_c* p);
+EXTERN GF2EContext* GF2EContext_construct(void *mem, const GF2X *p);
 
 //////// mat_GF2E //////////
 
 #ifndef __cplusplus
-struct mat_GF2E;
+typedef struct mat_GF2E mat_GF2E;
 #endif
 
-EXTERN void mat_GF2E_setitem(struct mat_GF2E* x, int i, int j, const struct GF2E* z);
+EXTERN void mat_GF2E_setitem(mat_GF2E* x, int i, int j, const GF2E* z);
 
 //////// mat_GF2 //////////
 
 #ifndef __cplusplus
-struct mat_GF2;
+typedef struct GF2 GF2;
+typedef struct mat_GF2 mat_GF2;
 #endif
 
-EXTERN void mat_GF2_setitem(struct mat_GF2* x, int i, int j, const struct GF2* z);
+EXTERN void mat_GF2_setitem(mat_GF2* x, int i, int j, const GF2* z);
diff -up src/c_lib/src/ntl_wrap.cpp.orig src/c_lib/src/ntl_wrap.cpp
--- src/c_lib/src/ntl_wrap.cpp.orig	2014-02-07 15:20:57.085216365 -0200
+++ src/c_lib/src/ntl_wrap.cpp	2014-02-07 15:21:07.322216757 -0200
@@ -845,67 +845,67 @@ struct ZZ_pX ZZ_pE_to_ZZ_pX(struct ZZ_pE
 
 //////// mat_ZZ //////////
 
-void mat_ZZ_SetDims(struct mat_ZZ* mZZ, long nrows, long ncols){
+void mat_ZZ_SetDims(mat_ZZ* mZZ, long nrows, long ncols){
     mZZ->SetDims(nrows, ncols);
 }
 
-struct mat_ZZ* mat_ZZ_pow(const struct mat_ZZ* x, long e)
+mat_ZZ* mat_ZZ_pow(const mat_ZZ* x, long e)
 {
     mat_ZZ *z = new mat_ZZ();
     power(*z, *x, e);
     return z;
 }
 
-long mat_ZZ_nrows(const struct mat_ZZ* x)
+long mat_ZZ_nrows(const mat_ZZ* x)
 {
     return x->NumRows();
 }
 
 
-long mat_ZZ_ncols(const struct mat_ZZ* x)
+long mat_ZZ_ncols(const mat_ZZ* x)
 {
     return x->NumCols();
 }
 
-void mat_ZZ_setitem(struct mat_ZZ* x, int i, int j, const struct ZZ* z)
+void mat_ZZ_setitem(mat_ZZ* x, int i, int j, const ZZ* z)
 {
     (*x)[i][j] = *z;
 
 }
 
-struct ZZ* mat_ZZ_getitem(const struct mat_ZZ* x, int i, int j)
+ZZ* mat_ZZ_getitem(const mat_ZZ* x, int i, int j)
 {
     return new ZZ((*x)(i,j));
 }
 
-struct ZZ* mat_ZZ_determinant(const struct mat_ZZ* x, long deterministic)
+ZZ* mat_ZZ_determinant(const mat_ZZ* x, long deterministic)
 {
     ZZ* d = new ZZ();
     determinant(*d, *x, deterministic);
     return d;
 }
 
-struct mat_ZZ* mat_ZZ_HNF(const struct mat_ZZ* A, const struct ZZ* D)
+mat_ZZ* mat_ZZ_HNF(const mat_ZZ* A, const ZZ* D)
 {
-    struct mat_ZZ* W = new mat_ZZ();
+    mat_ZZ* W = new mat_ZZ();
     HNF(*W, *A, *D);
     return W;
 }
 
-long mat_ZZ_LLL(struct ZZ **det, struct mat_ZZ *x, long a, long b, long verbose)
+long mat_ZZ_LLL(ZZ **det, mat_ZZ *x, long a, long b, long verbose)
 {
     *det = new ZZ();
     return LLL(**det,*x,a,b,verbose);
 }
 
-long mat_ZZ_LLL_U(struct ZZ **det, struct mat_ZZ *x, struct mat_ZZ *U, long a, long b, long verbose)
+long mat_ZZ_LLL_U(ZZ **det, mat_ZZ *x, mat_ZZ *U, long a, long b, long verbose)
 {
     *det = new ZZ();
     return LLL(**det,*x,*U,a,b,verbose);
 }
 
 
-struct ZZX* mat_ZZ_charpoly(const struct mat_ZZ* A)
+ZZX* mat_ZZ_charpoly(const mat_ZZ* A)
 {
     ZZX* f = new ZZX();
     CharPoly(*f, *A);
@@ -928,12 +928,12 @@ GF2EContext* GF2EContext_new(const GF2X
 }
 
 
-void mat_GF2E_setitem(struct mat_GF2E* x, int i, int j, const struct GF2E* z)
+void mat_GF2E_setitem(mat_GF2E* x, int i, int j, const GF2E* z)
 {
     (*x)[i][j] = *z;
 }
 
-void mat_GF2_setitem(struct mat_GF2* x, int i, int j, const struct GF2* z)
+void mat_GF2_setitem(mat_GF2* x, int i, int j, const GF2* z)
 {
     (*x)[i][j] = *z;
 }
@@ -1022,7 +1022,7 @@ void ZZ_pEX_conv_modulus(ZZ_pEX &fout, c
     fout.normalize();
 }
 
-void ZZ_pX_min_val_coeff(long & valuation, long &index, const struct ZZ_pX &f, const struct ZZ &p)
+void ZZ_pX_min_val_coeff(long & valuation, long &index, const ZZ_pX &f, const ZZ &p)
 {
     // Sets index, where the indexth coefficient of f has the minimum p-adic valuation.
     // Sets valuation to be this valuation.
@@ -1067,7 +1067,7 @@ void ZZ_pX_min_val_coeff(long & valuatio
     delete u;
 }
 
-long ZZ_pX_get_val_coeff(const struct ZZ_pX &f, const struct ZZ &p, long i)
+long ZZ_pX_get_val_coeff(const ZZ_pX &f, const ZZ &p, long i)
 {
     // Gets the p-adic valuation of the ith coefficient of f.
     ZZ *u = new ZZ();
@@ -1076,7 +1076,7 @@ long ZZ_pX_get_val_coeff(const struct ZZ
     return ans;
 }
 
-void ZZ_pX_left_pshift(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ &pn, const struct ZZ_pContext &c)
+void ZZ_pX_left_pshift(ZZ_pX &x, const ZZ_pX &a, const ZZ &pn, const ZZ_pContext &c)
 {
     // Multiplies each coefficient by pn, and sets the context of the answer to c.
 
@@ -1102,7 +1102,7 @@ void ZZ_pX_left_pshift(struct ZZ_pX &x,
     x.normalize();
 }
 
-void ZZ_pX_right_pshift(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ &pn, const struct ZZ_pContext &c)
+void ZZ_pX_right_pshift(ZZ_pX &x, const ZZ_pX &a, const ZZ &pn, const ZZ_pContext &c)
 {
     // Divides each coefficient by pn, and sets the context of the answer to c.
 
@@ -1128,7 +1128,7 @@ void ZZ_pX_right_pshift(struct ZZ_pX &x,
     x.normalize();
 }
 
-void ZZ_pX_InvMod_newton_unram(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ_pXModulus &F, const struct ZZ_pContext &cpn, const struct ZZ_pContext &cp)
+void ZZ_pX_InvMod_newton_unram(ZZ_pX &x, const ZZ_pX &a, const ZZ_pXModulus &F, const ZZ_pContext &cpn, const ZZ_pContext &cp)
 {
     //int j;
     cp.restore();
@@ -1163,7 +1163,7 @@ void ZZ_pX_InvMod_newton_unram(struct ZZ
     delete xn;
 }
 
-void ZZ_pX_InvMod_newton_ram(struct ZZ_pX &x, const struct ZZ_pX &a, const struct ZZ_pXModulus &F, const struct ZZ_pContext &cpn)
+void ZZ_pX_InvMod_newton_ram(ZZ_pX &x, const ZZ_pX &a, const ZZ_pXModulus &F, const ZZ_pContext &cpn)
 {
     //int j;
     cpn.restore();
diff -up src/sage/libs/ntl/decl.pxi.orig src/sage/libs/ntl/decl.pxi
--- src/sage/libs/ntl/decl.pxi.orig	2014-02-07 15:20:57.090216365 -0200
+++ src/sage/libs/ntl/decl.pxi	2014-02-07 15:21:00.833216508 -0200
@@ -22,7 +22,7 @@ from sage.libs.ntl.ntl_ZZ_pEX_decl cimpo
 
 cdef extern from "ntl_wrap.h":
     #### mat_ZZ_c
-    ctypedef struct mat_ZZ_c "struct mat_ZZ":
+    ctypedef struct mat_ZZ_c "mat_ZZ":
         pass
 
     # Some boiler-plate
@@ -92,7 +92,7 @@ cdef extern from "ntl_wrap.h":
     cdef long mat_ZZ_G_BKZ_RR_U   "G_BKZ_RR"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
 
     #### GF2_c
-    ctypedef struct GF2_c "struct GF2":
+    ctypedef struct GF2_c "GF2":
         pass
 
     GF2_c* GF2_new "New<GF2>"()
@@ -118,7 +118,7 @@ cdef extern from "ntl_wrap.h":
 
     #### GF2X_c
 
-    ctypedef struct GF2X_c "struct GF2X":
+    ctypedef struct GF2X_c "GF2X":
         pass
 
     long *GF2XHexOutput_c "(&GF2X::HexOutput)" # work-around for Cython bug
@@ -175,7 +175,7 @@ cdef extern from "ntl_wrap.h":
     void GF2X_BuildIrred "BuildIrred" (GF2X_c f, long n)
 
     #### GF2XModulus_c
-    ctypedef struct GF2XModulus_c "struct GF2XModulus":
+    ctypedef struct GF2XModulus_c "GF2XModulus":
         pass
 
     GF2X_c GF2XModulus_GF2X "GF2X" (GF2XModulus_c m)
@@ -184,7 +184,7 @@ cdef extern from "ntl_wrap.h":
 
     #### GF2EContext_c
 
-    ctypedef struct GF2EContext_c "struct GF2EContext":
+    ctypedef struct GF2EContext_c "GF2EContext":
         void (*restore)()
 
     GF2EContext_c* GF2EContext_new "New<GF2EContext>"()
@@ -195,7 +195,7 @@ cdef extern from "ntl_wrap.h":
     void GF2EContext_delete "Delete<GF2EContext>"(GF2EContext_c *mem)
 
     #### GF2E_c
-    ctypedef struct GF2E_c "struct GF2E":
+    ctypedef struct GF2E_c "GF2E":
         pass
 
     void GF2E_init "GF2E::init"(GF2X_c x)
@@ -230,7 +230,7 @@ cdef extern from "ntl_wrap.h":
     GF2_c GF2E_trace "trace"(GF2E_c x)
 
     #### GF2EX_c
-    ctypedef struct GF2EX_c "struct GF2EX":
+    ctypedef struct GF2EX_c "GF2EX":
         pass
 
     GF2EX_c* GF2EX_new "New<GF2EX>"()
@@ -249,7 +249,7 @@ cdef extern from "ntl_wrap.h":
     int GF2EX_IsZero "IsZero"(GF2EX_c x)
 
     #### vec_GF2E_c
-    ctypedef struct vec_GF2E_c "struct vec_GF2E":
+    ctypedef struct vec_GF2E_c "vec_GF2E":
         pass
 
     vec_GF2E_c* vec_GF2E_new "New<vec_GF2E>"()
@@ -260,7 +260,7 @@ cdef extern from "ntl_wrap.h":
     object vec_GF2E_to_PyString "_to_PyString<vec_GF2E>"(vec_GF2E_c *x)
 
     #### mat_GF2E_c
-    ctypedef struct mat_GF2E_c "struct mat_GF2E":
+    ctypedef struct mat_GF2E_c "mat_GF2E":
         void (*SetDims)(long nrows, long ncols)
         long (*NumRows)()
         long (*NumCols)()
@@ -299,7 +299,7 @@ cdef extern from "ntl_wrap.h":
     void mat_GF2E_conv_vec_GF2E(mat_GF2E_c out, vec_GF2E_c inp)
 
     #### vec_GF2_c
-    ctypedef struct vec_GF2_c "struct vec_GF2":
+    ctypedef struct vec_GF2_c "vec_GF2":
         pass
 
     vec_GF2_c* vec_GF2_new "New<vec_GF2>"()
@@ -311,7 +311,7 @@ cdef extern from "ntl_wrap.h":
 
 
     #### mat_GF2_c
-    ctypedef struct mat_GF2_c "struct mat_GF2":
+    ctypedef struct mat_GF2_c "mat_GF2":
         void (*SetDims)(long nrows, long ncols)
         long (*NumRows)()
         long (*NumCols)()