xref: /php-src/ext/gmp/php_gmp_int.h (revision 50b3a0d0)
1 /* interface header; needs to be installed; FIXME rename? */
2 
3 #ifndef incl_PHP_GMP_INT_H
4 #define incl_PHP_GMP_INT_H
5 
6 #ifdef HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9 
10 #include "php.h"
11 #include <gmp.h>
12 
13 #ifdef PHP_WIN32
14 # define PHP_GMP_API __declspec(dllexport)
15 #elif defined(__GNUC__) && __GNUC__ >= 4
16 # define PHP_GMP_API __attribute__ ((visibility("default")))
17 #else
18 # define PHP_GMP_API
19 #endif
20 
21 typedef struct _gmp_object {
22 	mpz_t num;
23 	zend_object std;
24 } gmp_object;
25 
php_gmp_object_from_zend_object(zend_object * zobj)26 static inline gmp_object *php_gmp_object_from_zend_object(zend_object *zobj) {
27 	return (gmp_object *)( ((char *)zobj) - XtOffsetOf(gmp_object, std) );
28 }
29 
30 PHP_GMP_API zend_class_entry *php_gmp_class_entry(void);
31 
32 /* GMP and MPIR use different datatypes on different platforms */
33 #ifdef _WIN64
34 typedef zend_long gmp_long;
35 typedef zend_ulong gmp_ulong;
36 #else
37 typedef long gmp_long;
38 typedef unsigned long gmp_ulong;
39 #endif
40 
41 #endif
42