Created
June 26, 2011 03:08
-
-
Save bubaflub/1047177 to your computer and use it in GitHub Desktop.
crazy structs i need to fit into a StructView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Available random number generation algorithms. */ | |
typedef enum | |
{ | |
GMP_RAND_ALG_DEFAULT = 0, | |
GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */ | |
} gmp_randalg_t; | |
/* Random state struct. */ | |
typedef struct | |
{ | |
mpz_t _mp_seed; /* _mp_d member points to state of the generator. */ | |
gmp_randalg_t _mp_alg; /* Currently unused. */ | |
union { | |
void *_mp_lc; /* Pointer to function pointers structure. */ | |
} _mp_algdata; | |
} __gmp_randstate_struct; | |
typedef __gmp_randstate_struct gmp_randstate_t[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Main Question: How do I represent a gmp_randstate_t as a StructView? | |
a) The last line, "typedef __gmp_randstate_struct gmp_randstate_t[1];" means that a gmp_randstate_t is really an array of two __gmp_randstate_structs, right? | |
b) The union around a single void pointer is just the same size as a pointer, right? | |
c) gmp_randalg_t is typedef'd as an enum but that's just the same size as an integer, right? | |
d) I already have a function that returns a gmp_t StructView - is there a simple way to embed this stuff? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment