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