Skip to content

Commit 14caf17

Browse files
committed
unify stdint type usage
if you need C99 stdint types, just include "php_stdint.h"
1 parent ca0497b commit 14caf17

24 files changed

+242
-271
lines changed

Makefile.global

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ clean:
120120
distclean: clean
121121
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c stamp-h sapi/apache/libphp$(PHP_MAJOR_VERSION).module sapi/apache_hooks/libphp$(PHP_MAJOR_VERSION).module buildmk.stamp Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h TSRM/tsrm_config.h
122122
rm -f php5.spec main/build-defs.h scripts/phpize
123-
rm -f ext/date/lib/timelib_config.h ext/mbstring/oniguruma/config.h ext/mbstring/libmbfl/config.h ext/mysqlnd/php_mysqlnd_config.h ext/oci8/oci8_dtrace_gen.h ext/oci8/oci8_dtrace_gen.h.bak
123+
rm -f ext/date/lib/timelib_config.h ext/mbstring/oniguruma/config.h ext/mbstring/libmbfl/config.h ext/oci8/oci8_dtrace_gen.h ext/oci8/oci8_dtrace_gen.h.bak
124124
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 ext/phar/phar.1 ext/phar/phar.phar.1
125125
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
126126
rm -f ext/iconv/php_have_bsd_iconv.h ext/iconv/php_have_glibc_iconv.h ext/iconv/php_have_ibm_iconv.h ext/iconv/php_have_iconv.h ext/iconv/php_have_libiconv.h ext/iconv/php_iconv_aliased_libiconv.h ext/iconv/php_iconv_supports_errno.h ext/iconv/php_php_iconv_h_path.h ext/iconv/php_php_iconv_impl.h

acinclude.m4

+19
Original file line numberDiff line numberDiff line change
@@ -2978,3 +2978,22 @@ $ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
29782978
29792979
EOF
29802980
])
2981+
2982+
dnl
2983+
dnl PHP_CHECK_STDINT_TYPES
2984+
dnl
2985+
AC_DEFUN([PHP_CHECK_STDINT_TYPES], [
2986+
AC_CHECK_SIZEOF([short], 2)
2987+
AC_CHECK_SIZEOF([int], 4)
2988+
AC_CHECK_SIZEOF([long], 4)
2989+
AC_CHECK_SIZEOF([long long], 8)
2990+
AC_CHECK_TYPES([int8, int16, int32, int64, int8_t, int16_t, int32_t, int64_t, uint8, uint16, uint32, uint64, uint8_t, uint16_t, uint32_t, uint64_t, u_int8_t, u_int16_t, u_int32_t, u_int64_t], [], [], [
2991+
#if HAVE_STDINT_H
2992+
# include <stdint.h>
2993+
#endif
2994+
#if HAVE_SYS_TYPES_H
2995+
# include <sys/types.h>
2996+
#endif
2997+
])
2998+
AC_DEFINE([PHP_HAVE_STDINT_TYPES], [1], [Checked for stdint types])
2999+
])

configure.in

+3
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ PHP_CHECK_SIZEOF(intmax_t, 0)
572572
PHP_CHECK_SIZEOF(ssize_t, 8)
573573
PHP_CHECK_SIZEOF(ptrdiff_t, 8)
574574

575+
dnl Check stdint types (must be after header check)
576+
PHP_CHECK_STDINT_TYPES
577+
575578
dnl Check for members of the stat structure
576579
AC_STRUCT_ST_BLKSIZE
577580
dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exists

ext/date/config0.m4

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ cat > $ext_builddir/lib/timelib_config.h <<EOF
2222
#else
2323
# include <php_config.h>
2424
#endif
25+
#include <php_stdint.h>
2526
EOF

ext/date/lib/timelib_structs.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333
#include <stdint.h>
3434
#endif
3535

36-
#ifdef PHP_WIN32
37-
/* TODO: Remove these hacks/defs once we have the int definitions in main/
38-
rathen than in each 2nd extension and win32/ */
39-
# include "win32/php_stdint.h"
40-
#else
4136
# ifndef HAVE_INT32_T
4237
# if SIZEOF_INT == 4
4338
typedef int int32_t;
@@ -53,7 +48,6 @@ typedef unsigned int uint32_t;
5348
typedef unsigned long int uint32_t;
5449
# endif
5550
# endif
56-
#endif
5751

5852
#include <stdio.h>
5953

@@ -68,8 +62,8 @@ typedef unsigned long int uint32_t;
6862
#endif
6963

7064
#if defined(_MSC_VER)
71-
typedef uint64_t timelib_ull;
72-
typedef int64_t timelib_sll;
65+
typedef __uint64 timelib_ull;
66+
typedef __int64 timelib_sll;
7367
# define TIMELIB_LL_CONST(n) n ## i64
7468
#else
7569
typedef unsigned long long timelib_ull;

ext/exif/exif.c

-10
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@
4040
#include "php.h"
4141
#include "ext/standard/file.h"
4242

43-
#ifdef HAVE_STDINT_H
44-
# include <stdint.h>
45-
#endif
46-
#ifdef HAVE_INTTYPES_H
47-
# include <inttypes.h>
48-
#endif
49-
#ifdef PHP_WIN32
50-
# include "win32/php_stdint.h"
51-
#endif
52-
5343
#if HAVE_EXIF
5444

5545
/* When EXIF_DEBUG is defined the module generates a lot of debug messages

ext/hash/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if test "$PHP_HASH" != "no"; then
3131
EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
3232
php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
3333
php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h \
34-
php_hash_fnv.h php_hash_joaat.h php_hash_types.h"
34+
php_hash_fnv.h php_hash_joaat.h"
3535

3636
PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared)
3737
ifdef([PHP_INSTALL_HEADERS], [

ext/hash/config.w32

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ if (PHP_HASH != "no") {
1919

2020
PHP_INSTALL_HEADERS("ext/hash/", "php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h " +
2121
"php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h " +
22-
"php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h " +
23-
"php_hash_types.h");
22+
"php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h");
2423
}
2524

ext/hash/package.xml

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Supported Algorithms:
4242
<file role="src" name="config.w32"/>
4343
<file role="src" name="hash.c"/>
4444
<file role="src" name="php_hash.h"/>
45-
<file role="src" name="php_hash_types.h"/>
4645
<file role="src" name="hash_md.c"/>
4746
<file role="src" name="php_hash_md.h"/>
4847
<file role="src" name="hash_sha.c"/>

ext/hash/php_hash.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@
2222
#define PHP_HASH_H
2323

2424
#include "php.h"
25-
#include "php_hash_types.h"
2625

2726
#define PHP_HASH_EXTNAME "hash"
2827
#define PHP_HASH_EXTVER "1.0"
2928
#define PHP_HASH_RESNAME "Hash Context"
3029

3130
#define PHP_HASH_HMAC 0x0001
3231

32+
#define L64 INT64_C
33+
#define php_hash_int32 int32_t
34+
#define php_hash_uint32 uint32_t
35+
#define php_hash_int64 int64_t
36+
#define php_hash_uint64 uint64_t
37+
3338
typedef void (*php_hash_init_func_t)(void *context);
3439
typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count);
3540
typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context);

ext/hash/php_hash_types.h

-71
This file was deleted.

ext/mysqlnd/config9.m4

-12
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,4 @@ fi
4848

4949
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
5050
PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
51-
52-
dnl This creates a file so it has to be after above macros
53-
PHP_CHECK_TYPES([int8 uint8 int16 uint16 int32 uint32 uchar ulong int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t], [
54-
ext/mysqlnd/php_mysqlnd_config.h
55-
],[
56-
#ifdef HAVE_SYS_TYPES_H
57-
#include <sys/types.h>
58-
#endif
59-
#ifdef HAVE_STDINT_H
60-
#include <stdint.h>
61-
#endif
62-
])
6351
fi

ext/mysqlnd/mysqlnd_portability.h

+1-106
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,14 @@ This file is public domain and comes with NO WARRANTY of any kind */
3636

3737
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
3838
# include "ext/mysqlnd/config-win.h"
39-
#else
40-
# include <ext/mysqlnd/php_mysqlnd_config.h>
4139
#endif /* _WIN32... */
4240

4341
#if __STDC_VERSION__ < 199901L && !defined(atoll)
4442
/* "inline" is a keyword */
4543
#define atoll atol
4644
#endif
4745

48-
49-
#ifdef HAVE_SYS_TYPES_H
50-
#include <sys/types.h>
51-
#endif
52-
53-
#ifdef HAVE_STDINT_H
54-
#include <stdint.h>
55-
#endif
46+
#include "php_stdint.h"
5647

5748
#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
5849
#define _LONG_LONG 1 /* For AIX string library */
@@ -70,102 +61,6 @@ This file is public domain and comes with NO WARRANTY of any kind */
7061
#define HAVE_LONG_LONG 1
7162
#endif
7263

73-
74-
/* Typdefs for easyier portability */
75-
#ifndef HAVE_INT8_T
76-
#ifndef HAVE_INT8
77-
typedef signed char int8_t; /* Signed integer >= 8 bits */
78-
#else
79-
typedef int8 int8_t; /* Signed integer >= 8 bits */
80-
#endif
81-
#endif
82-
83-
#ifndef HAVE_UINT8_T
84-
#ifndef HAVE_UINT8
85-
typedef unsigned char uint8_t; /* Unsigned integer >= 8 bits */
86-
#else
87-
typedef uint8 uint8_t; /* Signed integer >= 8 bits */
88-
#endif
89-
#endif
90-
91-
#ifndef HAVE_INT16_T
92-
#ifndef HAVE_INT16
93-
typedef signed short int16_t; /* Signed integer >= 16 bits */
94-
#else
95-
typedef int16 int16_t; /* Signed integer >= 16 bits */
96-
#endif
97-
#endif
98-
99-
#ifndef HAVE_UINT16_T
100-
#ifndef HAVE_UINT16
101-
typedef unsigned short uint16_t; /* Signed integer >= 16 bits */
102-
#else
103-
typedef uint16 uint16_t; /* Signed integer >= 16 bits */
104-
#endif
105-
#endif
106-
107-
108-
#ifndef HAVE_INT32_T
109-
#ifdef HAVE_INT32
110-
typedef int32 int32_t;
111-
#elif SIZEOF_INT == 4
112-
typedef signed int int32_t;
113-
#elif SIZEOF_LONG == 4
114-
typedef signed long int32_t;
115-
#else
116-
error "Neither int nor long is of 4 bytes width"
117-
#endif
118-
#endif /* HAVE_INT32_T */
119-
120-
#ifndef HAVE_UINT32_T
121-
#ifdef HAVE_UINT32
122-
typedef uint32 uint32_t;
123-
#elif SIZEOF_INT == 4
124-
typedef unsigned int uint32_t;
125-
#elif SIZEOF_LONG == 4
126-
typedef unsigned long uint32_t;
127-
#else
128-
#error "Neither int nor long is of 4 bytes width"
129-
#endif
130-
#endif /* HAVE_UINT32_T */
131-
132-
#ifndef HAVE_INT64_T
133-
#ifdef HAVE_INT64
134-
typedef int64 int64_t;
135-
#elif SIZEOF_INT == 8
136-
typedef signed int int64_t;
137-
#elif SIZEOF_LONG == 8
138-
typedef signed long int64_t;
139-
#elif SIZEOF_LONG_LONG == 8
140-
#ifdef PHP_WIN32
141-
typedef __int64 int64_t;
142-
#else
143-
typedef signed long long int64_t;
144-
#endif
145-
#else
146-
#error "Neither int nor long nor long long is of 8 bytes width"
147-
#endif
148-
#endif /* HAVE_INT64_T */
149-
150-
#ifndef HAVE_UINT64_T
151-
#ifdef HAVE_UINT64
152-
typedef uint64 uint64_t;
153-
#elif SIZEOF_INT == 8
154-
typedef unsigned int uint64_t;
155-
#elif SIZEOF_LONG == 8
156-
typedef unsigned long uint64_t;
157-
#elif SIZEOF_LONG_LONG == 8
158-
#ifdef PHP_WIN32
159-
typedef unsigned __int64 uint64_t;
160-
#else
161-
typedef unsigned long long uint64_t;
162-
#endif
163-
#else
164-
#error "Neither int nor long nor long long is of 8 bytes width"
165-
#endif
166-
#endif /* HAVE_INT64_T */
167-
168-
16964
#ifdef PHP_WIN32
17065
#define MYSQLND_LLU_SPEC "%I64u"
17166
#define MYSQLND_LL_SPEC "%I64d"

ext/oci8/oci8.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
| obtain it through the world-wide-web, please send a note to |
1313
| [email protected] so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
15-
| Authors: Stig Sæther Bakken <[email protected]> |
15+
| Authors: Stig S�ther Bakken <[email protected]> |
1616
| Thies C. Arntzen <[email protected]> |
1717
| Maxim Maletsky <[email protected]> |
1818
| |
@@ -37,13 +37,6 @@
3737
#include "php_ini.h"
3838
#include "ext/standard/php_smart_str.h"
3939

40-
#ifdef HAVE_STDINT_H
41-
#include <stdint.h>
42-
#endif
43-
#ifdef PHP_WIN32
44-
#include "win32/php_stdint.h"
45-
#endif
46-
4740
#if HAVE_OCI8
4841

4942
#if PHP_MAJOR_VERSION > 5

ext/phar/phar_internal.h

-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
#include "ext/spl/spl_iterators.h"
6464
#endif
6565
#include "php_phar.h"
66-
#ifdef HAVE_STDINT_H
67-
#include <stdint.h>
68-
#endif
6966
#ifdef PHAR_HASH_OK
7067
#include "ext/hash/php_hash.h"
7168
#include "ext/hash/php_hash_sha.h"

0 commit comments

Comments
 (0)