php-src/ext/gmp/php_gmp_int.h
Christoph M. Becker 50b3a0d011
Add comments about internal headers (GH-15689)
A common convention is to name internal C header files as `*_int.h`.
Since a couple of these are actually installed, we add comments that
this is not supposed to happen, (a) to avoid installing further
internal headers, and (b) to pave the way to fix this in the next major
PHP version.

Somewhat special is php_gmp_int.h, where "int" is meant as abbreviation
for "interface".

Another common convention is appending `_priv` or `_private`, but since
there have not been any issues regarding these headers so far, we
refrain from adding respective comments to these headers.

Anyhow, it might be a good idea to introduce some common naming
convention for such internal/private headers.
2024-09-08 16:11:25 +02:00

41 lines
899 B
C

/* interface header; needs to be installed; FIXME rename? */
#ifndef incl_PHP_GMP_INT_H
#define incl_PHP_GMP_INT_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "php.h"
#include <gmp.h>
#ifdef PHP_WIN32
# define PHP_GMP_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_GMP_API __attribute__ ((visibility("default")))
#else
# define PHP_GMP_API
#endif
typedef struct _gmp_object {
mpz_t num;
zend_object std;
} gmp_object;
static inline gmp_object *php_gmp_object_from_zend_object(zend_object *zobj) {
return (gmp_object *)( ((char *)zobj) - XtOffsetOf(gmp_object, std) );
}
PHP_GMP_API zend_class_entry *php_gmp_class_entry(void);
/* GMP and MPIR use different datatypes on different platforms */
#ifdef _WIN64
typedef zend_long gmp_long;
typedef zend_ulong gmp_ulong;
#else
typedef long gmp_long;
typedef unsigned long gmp_ulong;
#endif
#endif