Skip to content

Avoid C99 typedef redeclaration error #15202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Zend/zend_builtin_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include "zend_types.h"

typedef struct _zval_struct zval;

zend_result zend_startup_builtin_functions(void);

BEGIN_EXTERN_C()
Expand Down
7 changes: 2 additions & 5 deletions Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
} while (0)

typedef struct _zend_op_array zend_op_array;
typedef struct _zend_op zend_op;

/* On 64-bit systems less optimal, but more compact VM code leads to better
* performance. So on 32-bit systems we use absolute addresses for jump
Expand Down Expand Up @@ -189,8 +188,6 @@ typedef struct _zend_live_range {
uint32_t end;
} zend_live_range;

typedef struct _zend_property_info zend_property_info;

/* Compilation context that is different for each op array. */
typedef struct _zend_oparray_context {
struct _zend_oparray_context *prev;
Expand Down Expand Up @@ -417,7 +414,7 @@ char *zend_visibility_string(uint32_t fn_flags);

zend_property_hook_kind zend_get_property_hook_kind_from_name(zend_string *name);

typedef struct _zend_property_info {
struct _zend_property_info {
uint32_t offset; /* property offset for object properties or
property index for static properties */
uint32_t flags;
Expand All @@ -428,7 +425,7 @@ typedef struct _zend_property_info {
zend_type type;
const zend_property_info *prototype;
zend_function **hooks;
} zend_property_info;
};

#define OBJ_PROP(obj, offset) \
((zval*)((char*)(obj) + offset))
Expand Down
5 changes: 1 addition & 4 deletions Zend/zend_frameless_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#endif

#include "zend_portability.h"
#include "zend_types_defs.h"

#define ZEND_FRAMELESS_FUNCTION_PARAMETERS_0 zval *return_value
#define ZEND_FRAMELESS_FUNCTION_PARAMETERS_1 zval *return_value, zval *arg1
Expand Down Expand Up @@ -103,10 +104,6 @@

BEGIN_EXTERN_C()

typedef struct _zval_struct zval;
typedef struct _zend_op zend_op;
typedef union _zend_function zend_function;

typedef void (*zend_frameless_function_0)(zval *return_value);
typedef void (*zend_frameless_function_1)(zval *return_value, zval *op1);
typedef void (*zend_frameless_function_2)(zval *return_value, zval *op1, zval *op2);
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_ini_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include "zend_types.h"

typedef struct _zend_file_handle zend_file_handle;

/* Scanner modes */
#define ZEND_INI_SCANNER_NORMAL 0 /* Normal mode. [DEFAULT] */
#define ZEND_INI_SCANNER_RAW 1 /* Raw mode. Option values are not parsed */
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
* with similar names.
* */

typedef struct _zend_object_iterator zend_object_iterator;

typedef struct _zend_object_iterator_funcs {
/* release all resources associated with this iterator instance */
void (*dtor)(zend_object_iterator *iter);
Expand Down
3 changes: 1 addition & 2 deletions Zend/zend_map_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#define ZEND_MAP_PTR_H

#include "zend_portability.h"

typedef struct _zend_string zend_string;
#include "zend_types_defs.h"

#define ZEND_MAP_PTR_KIND_PTR 0
#define ZEND_MAP_PTR_KIND_PTR_OR_OFFSET 1
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_object_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp
* consumers of the get_properties_for API. */
ZEND_API HashTable *zend_get_properties_for(zval *obj, zend_prop_purpose purpose);

typedef struct _zend_property_info zend_property_info;

ZEND_API zend_function *zend_get_property_hook_trampoline(
const zend_property_info *prop_info,
zend_property_hook_kind kind, zend_string *prop_name);
Expand Down
7 changes: 1 addition & 6 deletions Zend/zend_property_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@
#define ZEND_PROPERTY_HOOKS_H

#include "zend_portability.h"
#include "zend_types_defs.h"

BEGIN_EXTERN_C()

typedef struct _zend_array zend_array;
typedef struct _zend_class_entry zend_class_entry;
typedef struct _zend_object zend_object;
typedef struct _zend_object_iterator zend_object_iterator;
typedef struct _zval_struct zval;

typedef enum {
ZEND_PROPERTY_HOOK_GET = 0,
ZEND_PROPERTY_HOOK_SET = 1,
Expand Down
3 changes: 1 addition & 2 deletions Zend/zend_smart_str_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#define ZEND_SMART_STR_PUBLIC_H

#include <stddef.h>

typedef struct _zend_string zend_string;
#include "zend_types_defs.h"

typedef struct {
/** See smart_str_extract() */
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct _zend_stream {
zend_stream_closer_t closer;
} zend_stream;

typedef struct _zend_file_handle {
struct _zend_file_handle {
union {
FILE *fp;
zend_stream stream;
Expand All @@ -62,7 +62,7 @@ typedef struct _zend_file_handle {
bool in_list; /* added into CG(open_file) */
char *buf;
size_t len;
} zend_file_handle;
};

BEGIN_EXTERN_C()
ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename);
Expand Down
9 changes: 1 addition & 8 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define ZEND_TYPES_H

#include "zend_portability.h"
#include "zend_types_defs.h"
#include "zend_long.h"
#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -86,16 +87,8 @@ typedef ZEND_RESULT_CODE zend_result;
#endif

typedef struct _zend_object_handlers zend_object_handlers;
typedef struct _zend_class_entry zend_class_entry;
typedef union _zend_function zend_function;
typedef struct _zend_execute_data zend_execute_data;

typedef struct _zval_struct zval;

typedef struct _zend_refcounted zend_refcounted;
typedef struct _zend_string zend_string;
typedef struct _zend_array zend_array;
typedef struct _zend_object zend_object;
typedef struct _zend_resource zend_resource;
typedef struct _zend_reference zend_reference;
typedef struct _zend_ast_ref zend_ast_ref;
Expand Down
38 changes: 38 additions & 0 deletions Zend/zend_types_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/

#ifndef ZEND_TYPES_DEFS_H
#define ZEND_TYPES_DEFS_H

typedef struct _zend_class_entry zend_class_entry;
typedef union _zend_function zend_function;
typedef struct _zend_execute_data zend_execute_data;

typedef struct _zval_struct zval;

typedef struct _zend_string zend_string;
typedef struct _zend_array zend_array;
typedef struct _zend_object zend_object;

typedef struct _zend_object_iterator zend_object_iterator;

typedef struct _zend_op zend_op;

typedef struct _zend_property_info zend_property_info;

typedef struct _zend_file_handle zend_file_handle;

#endif /* ZEND_TYPES_DEFS_H */
3 changes: 0 additions & 3 deletions Zend/zend_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

#include "zend_portability.h"

typedef struct _zend_op zend_op;
typedef struct _zend_execute_data zend_execute_data;

BEGIN_EXTERN_C()

ZEND_API void ZEND_FASTCALL zend_vm_set_opcode_handler(zend_op* opcode);
Expand Down
5 changes: 5 additions & 0 deletions ext/bcmath/libbcmath/src/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

/* "Private" routines to bcmath. */

#ifndef _BCMATH_PRIVATE_H_
#define _BCMATH_PRIVATE_H_

#include <stdbool.h>
#include <stddef.h>
#include "zend_portability.h"
Expand Down Expand Up @@ -73,3 +76,5 @@ bcmath_compare_result _bc_do_compare (bc_num n1, bc_num n2, size_t scale, bool u
bc_num _bc_do_add (bc_num n1, bc_num n2);
bc_num _bc_do_sub (bc_num n1, bc_num n2);
void _bc_rm_leading_zeros (bc_num num);

#endif
2 changes: 1 addition & 1 deletion ext/dom/lexbor/lexbor/selectors-adapted/selectors.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include <php.h>

#include "lexbor/selectors-adapted/selectors.h"
#include "../../../php_dom.h"
#include "../../../namespace_compat.h"
#include "../../../domexception.h"
#include "../../../php_dom.h"

#include <math.h>

Expand Down
3 changes: 0 additions & 3 deletions ext/dom/namespace_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
struct php_dom_ns_magic_token;
typedef struct php_dom_ns_magic_token php_dom_ns_magic_token;

struct php_dom_libxml_ns_mapper;
typedef struct php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;

PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_html_magic_token;
PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_mathml_magic_token;
PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_svg_magic_token;
Expand Down
3 changes: 0 additions & 3 deletions ext/dom/php_dom.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ typedef enum dom_iterator_type {
DOM_HTMLCOLLECTION,
} dom_iterator_type;

struct php_dom_libxml_ns_mapper;
typedef struct php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;

static inline dom_object_namespace_node *php_dom_namespace_node_obj_from_obj(zend_object *obj) {
return (dom_object_namespace_node*)((char*)(obj) - XtOffsetOf(dom_object_namespace_node, dom.std));
}
Expand Down
13 changes: 2 additions & 11 deletions ext/dom/private_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,11 @@ struct php_dom_libxml_ns_mapper {
HashTable uri_to_prefix_map;
};

typedef struct php_dom_private_data {
struct php_dom_private_data {
php_libxml_private_data_header header;
struct php_dom_libxml_ns_mapper ns_mapper;
HashTable *template_fragments;
} php_dom_private_data;

typedef struct php_libxml_private_data_header php_libxml_private_data_header;
struct php_libxml_private_data_header;

struct php_dom_private_data;
typedef struct php_dom_private_data php_dom_private_data;

struct php_dom_libxml_ns_mapper;
typedef struct php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;
};

php_libxml_private_data_header *php_dom_libxml_private_data_header(php_dom_private_data *private_data);
php_dom_libxml_ns_mapper *php_dom_ns_mapper_from_private(php_dom_private_data *private_data);
Expand Down
2 changes: 2 additions & 0 deletions ext/dom/xml_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
struct php_dom_private_data;
typedef struct php_dom_private_data php_dom_private_data;

typedef struct php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;

static zend_always_inline php_dom_private_data *php_dom_get_private_data(dom_object *intern)
{
ZEND_ASSERT(intern->document != NULL);
Expand Down
1 change: 1 addition & 0 deletions ext/dom/xml_serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "php.h"
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
#include "php_dom.h"
#include "xml_serializer.h"
#include "private_data.h"
#include "namespace_compat.h"
Expand Down
3 changes: 0 additions & 3 deletions ext/dom/xml_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#include <libxml/xmlsave.h>
#include <libxml/xmlIO.h>

struct php_dom_private_data;
typedef struct php_dom_private_data php_dom_private_data;

int dom_xml_serialize(xmlSaveCtxtPtr ctx, xmlOutputBufferPtr out, xmlNodePtr node, bool format, bool require_well_formed, php_dom_private_data *private_data);

#endif
4 changes: 2 additions & 2 deletions ext/opcache/jit/ir/ir_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,13 @@ typedef struct _ir_hashtab_bucket {
uint32_t next;
} ir_hashtab_bucket;

typedef struct _ir_hashtab {
struct _ir_hashtab {
void *data;
uint32_t mask;
uint32_t size;
uint32_t count;
uint32_t pos;
} ir_hashtab;
};

void ir_hashtab_init(ir_hashtab *tab, uint32_t size);
void ir_hashtab_free(ir_hashtab *tab);
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/jit/ir/ir_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -10852,7 +10852,7 @@ next_block:;

do {
/* _cldemote(p); */
asm volatile(".byte 0x0f, 0x1c, 0x06" :: "S" (p));
__asm__ volatile(".byte 0x0f, 0x1c, 0x06" :: "S" (p));
p += 64;
} while (p < start + size);
}
Expand Down
4 changes: 2 additions & 2 deletions ext/random/php_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ typedef struct _php_random_algo_with_state {
void *state;
} php_random_algo_with_state;

typedef struct _php_random_fallback_seed_state {
struct _php_random_fallback_seed_state {
bool initialized;
unsigned char seed[20];
} php_random_fallback_seed_state;
};

extern PHPAPI const php_random_algo php_random_algo_combinedlcg;
extern PHPAPI const php_random_algo php_random_algo_mt19937;
Expand Down
2 changes: 1 addition & 1 deletion main/debug_gdb_scripts.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* See https://sourceware.org/gdb/current/onlinedocs/gdb.html/dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section
*/
asm(
__asm__(
".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
".byte 4 /* Python Text */\n"
".ascii \"gdb.inlined-script\\n\"\n"
Expand Down
2 changes: 1 addition & 1 deletion scripts/gdb/debug_gdb_scripts_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* See https://sourceware.org/gdb/current/onlinedocs/gdb.html/dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section
*/
asm(
__asm__(
".pushsection \".debug_gdb_scripts\", \"MS\",%%progbits,1\n"
".byte 4 /* Python Text */\n"
".ascii \"gdb.inlined-script\\n\"\n"
Expand Down
Loading