Skip to content

Commit 97e3fe5

Browse files
committed
zend_portability: Simplify definition of ZEND_NORETURN
1 parent e640299 commit 97e3fe5

6 files changed

Lines changed: 13 additions & 16 deletions

File tree

‎UPGRADING.INTERNALS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ PHP 8.7 INTERNALS UPGRADE NOTES
1717
- Removed zend_execute_scripts(). Manually call zend_execute_script() in a loop
1818
instead.
1919
- Removed ZEND_STATIC_ASSERT(). Use C11 static_assert() directly instead.
20+
- Removed HAVE_NORETURN and HAVE_NORETURN_ALIAS. ZEND_NORETURN is guaranteed to
21+
work.
2022

2123
========================
2224
2. Build system changes

‎Zend/zend.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ zend_result zend_post_startup(void);
298298
void zend_set_utility_values(zend_utility_values *utility_values);
299299
void zend_unload_modules(void);
300300

301-
ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
301+
ZEND_NORETURN ZEND_API ZEND_COLD void _zend_bailout(const char *filename, uint32_t lineno);
302302
ZEND_API size_t zend_get_page_size(void);
303303

304304
ZEND_API size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap);
@@ -387,13 +387,13 @@ extern ZEND_API void (*zend_post_shutdown_cb)(void);
387387
extern ZEND_API void (*zend_accel_schedule_restart_hook)(int reason);
388388

389389
ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
390-
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
391-
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn_unchecked(int type, const char *format, ...);
390+
ZEND_NORETURN ZEND_API ZEND_COLD void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
391+
ZEND_NORETURN ZEND_API ZEND_COLD void zend_error_noreturn_unchecked(int type, const char *format, ...);
392392
/* For custom format specifiers like H */
393393
ZEND_API ZEND_COLD void zend_error_unchecked(int type, const char *format, ...);
394394
/* If filename is NULL the default filename is used. */
395395
ZEND_API ZEND_COLD void zend_error_at(int type, zend_string *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
396-
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_at_noreturn(int type, zend_string *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
396+
ZEND_NORETURN ZEND_API ZEND_COLD void zend_error_at_noreturn(int type, zend_string *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
397397
ZEND_API ZEND_COLD void zend_error_zstr(int type, zend_string *message);
398398
ZEND_API ZEND_COLD void zend_error_zstr_at(int type, zend_string *filename, uint32_t lineno, zend_string *message);
399399

@@ -407,7 +407,7 @@ ZEND_API ZEND_COLD void zend_illegal_container_offset(const zend_string *contain
407407
ZEND_COLD void zenderror(const char *error);
408408

409409
/* For internal C errors */
410-
ZEND_API ZEND_COLD ZEND_NORETURN void zend_strerror_noreturn(int type, int errn, const char *message);
410+
ZEND_NORETURN ZEND_API ZEND_COLD void zend_strerror_noreturn(int type, int errn, const char *message);
411411

412412
/* The following #define is used for code duality in PHP for Engine 1 & 2 */
413413
#define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def

‎Zend/zend_execute.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ ZEND_API zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_cannot_pass_by_refe
525525

526526
ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals);
527527
ZEND_API void zend_unset_timeout(void);
528-
ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void);
528+
ZEND_NORETURN ZEND_API void ZEND_FASTCALL zend_timeout(void);
529529
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, uint32_t fetch_type);
530530
ZEND_API zend_class_entry *zend_fetch_class_with_scope(zend_string *class_name, uint32_t fetch_type, zend_class_entry *scope);
531531
ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *lcname, uint32_t fetch_type);

‎Zend/zend_portability.h‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,10 @@ char *alloca();
356356
# endif
357357
#endif
358358

359-
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)
360-
# define HAVE_NORETURN
361-
# define ZEND_NORETURN __attribute__((noreturn))
362-
#elif defined(ZEND_WIN32)
363-
# define HAVE_NORETURN
364-
# define ZEND_NORETURN __declspec(noreturn)
359+
#if __STDC_VERSION__ >= 202311L || defined(__cplusplus)
360+
# define ZEND_NORETURN [[noreturn]]
365361
#else
366-
# define ZEND_NORETURN
362+
# define ZEND_NORETURN _Noreturn
367363
#endif
368364

369365
#if __has_attribute(force_align_arg_pointer)
@@ -373,7 +369,6 @@ char *alloca();
373369
#endif
374370

375371
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__))
376-
# define HAVE_NORETURN_ALIAS
377372
# define HAVE_ATTRIBUTE_WEAK
378373
#endif
379374

‎Zend/zend_string.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
BEGIN_EXTERN_C()
2828

29-
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
29+
ZEND_NORETURN ZEND_API ZEND_COLD void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
3030

3131
#include "zend_multiply.h"
3232

‎ext/ffi/php_ffi.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ zend_result zend_ffi_parse_type(const char *str, size_t len, zend_ffi_dcl *dcl);
209209
void zend_ffi_cleanup_dcl(zend_ffi_dcl *dcl);
210210

211211
/* parser callbacks */
212-
void ZEND_NORETURN zend_ffi_parser_error(const char *msg, ...);
212+
ZEND_NORETURN void zend_ffi_parser_error(const char *msg, ...);
213213
bool zend_ffi_is_typedef_name(const char *name, size_t name_len);
214214
void zend_ffi_resolve_typedef(const char *name, size_t name_len, zend_ffi_dcl *dcl);
215215
void zend_ffi_resolve_const(const char *name, size_t name_len, zend_ffi_val *val);

0 commit comments

Comments
 (0)