Skip to content

Commit 5c39a46

Browse files
authored
Replace __forceinline with zend_always_inline in win32/ (GH-17482)
`__forceinline` is MSVC specific (and also understood by Clang on Windows), but the code in win32/ should not be constrained to these compilers. Since we already have `zend_always_inline`, we use this instead.
1 parent 6967de5 commit 5c39a46

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

win32/codepage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ZEND_TLS const struct php_win32_cp *orig_in_cp = NULL;
3535

3636
#include "cp_enc_map.c"
3737

38-
__forceinline static wchar_t *php_win32_cp_to_w_int(const char* in, size_t in_len, size_t *out_len, UINT cp, DWORD flags)
38+
zend_always_inline static wchar_t *php_win32_cp_to_w_int(const char* in, size_t in_len, size_t *out_len, UINT cp, DWORD flags)
3939
{/*{{{*/
4040
wchar_t *ret;
4141
int ret_len, tmp_len;
@@ -241,7 +241,7 @@ PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size
241241
}/*}}}*/
242242
#undef ASCII_FAIL_RETURN
243243

244-
__forceinline static char *php_win32_cp_from_w_int(const wchar_t* in, size_t in_len, size_t *out_len, UINT cp, DWORD flags)
244+
zend_always_inline static char *php_win32_cp_from_w_int(const wchar_t* in, size_t in_len, size_t *out_len, UINT cp, DWORD flags)
245245
{/*{{{*/
246246
int r;
247247
int target_len, tmp_len;
@@ -306,7 +306,7 @@ PW32CP char *php_win32_cp_conv_from_w(DWORD cp, DWORD flags, const wchar_t* in,
306306
}/*}}}*/
307307

308308
/* This is only usable after the startup phase*/
309-
__forceinline static char *php_win32_cp_get_enc(void)
309+
zend_always_inline static char *php_win32_cp_get_enc(void)
310310
{/*{{{*/
311311
char *enc = NULL;
312312
const zend_encoding *zenc;

win32/codepage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env);
7676
/* This function tries to make the best guess to convert any
7777
given string to a wide char, also preferring the fastest code
7878
path to unicode. It returns NULL on fail. */
79-
__forceinline static wchar_t *php_win32_cp_conv_any_to_w(const char* in, size_t in_len, size_t *out_len)
79+
zend_always_inline static wchar_t *php_win32_cp_conv_any_to_w(const char* in, size_t in_len, size_t *out_len)
8080
{/*{{{*/
8181
wchar_t *ret = NULL;
8282

@@ -117,7 +117,7 @@ __forceinline static wchar_t *php_win32_cp_conv_any_to_w(const char* in, size_t
117117
/* This function converts from unicode function output back to PHP. If
118118
the PHP's current charset is not compatible with unicode, so the currently
119119
configured CP will be used. */
120-
__forceinline static char *php_win32_cp_conv_w_to_any(const wchar_t* in, size_t in_len, size_t *out_len)
120+
zend_always_inline static char *php_win32_cp_conv_w_to_any(const wchar_t* in, size_t in_len, size_t *out_len)
121121
{/*{{{*/
122122
return php_win32_cp_conv_w_to_cur(in, in_len, out_len);
123123
}/*}}}*/

win32/ioutil.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w
172172

173173
/* Keep these functions aliased for case some additional handling
174174
is needed later. */
175-
__forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, size_t in_len, size_t *out_len)
175+
zend_always_inline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, size_t in_len, size_t *out_len)
176176
{/*{{{*/
177177
wchar_t *mb, *ret;
178178
size_t mb_len, dir_len = 0;
@@ -268,7 +268,7 @@ __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, siz
268268
#define php_win32_ioutil_cur_to_w php_win32_cp_cur_to_w
269269
#define php_win32_ioutil_w_to_any php_win32_cp_w_to_any
270270
#define php_win32_ioutil_conv_w_to_any php_win32_cp_conv_w_to_any
271-
/*__forceinline static char *php_win32_ioutil_w_to_any(wchar_t* w_source_ptr)
271+
/*zend_always_inline static char *php_win32_ioutil_w_to_any(wchar_t* w_source_ptr)
272272
{
273273
return php_win32_cp_w_to_any(w_source_ptr);
274274
}*/
@@ -292,7 +292,7 @@ PW32IO wchar_t *php_win32_ioutil_realpath_w_ex0(const wchar_t *path, wchar_t *re
292292
PW32IO int php_win32_ioutil_symlink_w(const wchar_t *target, const wchar_t *link);
293293
PW32IO int php_win32_ioutil_link_w(const wchar_t *target, const wchar_t *link);
294294

295-
__forceinline static int php_win32_ioutil_access(const char *path, mode_t mode)
295+
zend_always_inline static int php_win32_ioutil_access(const char *path, mode_t mode)
296296
{/*{{{*/
297297
PHP_WIN32_IOUTIL_INIT_W(path)
298298
int ret, err;
@@ -317,7 +317,7 @@ __forceinline static int php_win32_ioutil_access(const char *path, mode_t mode)
317317
return ret;
318318
}/*}}}*/
319319

320-
__forceinline static int php_win32_ioutil_open(const char *path, int flags, ...)
320+
zend_always_inline static int php_win32_ioutil_open(const char *path, int flags, ...)
321321
{/*{{{*/
322322
mode_t mode = 0;
323323
PHP_WIN32_IOUTIL_INIT_W(path)
@@ -352,7 +352,7 @@ __forceinline static int php_win32_ioutil_open(const char *path, int flags, ...)
352352
return ret;
353353
}/*}}}*/
354354

355-
__forceinline static int php_win32_ioutil_unlink(const char *path)
355+
zend_always_inline static int php_win32_ioutil_unlink(const char *path)
356356
{/*{{{*/
357357
PHP_WIN32_IOUTIL_INIT_W(path)
358358
int ret = -1;
@@ -376,7 +376,7 @@ __forceinline static int php_win32_ioutil_unlink(const char *path)
376376
return ret;
377377
}/*}}}*/
378378

379-
__forceinline static int php_win32_ioutil_rmdir(const char *path)
379+
zend_always_inline static int php_win32_ioutil_rmdir(const char *path)
380380
{/*{{{*/
381381
PHP_WIN32_IOUTIL_INIT_W(path)
382382
int ret = 0;
@@ -403,7 +403,7 @@ __forceinline static int php_win32_ioutil_rmdir(const char *path)
403403
return ret;
404404
}/*}}}*/
405405

406-
__forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const char *modea)
406+
zend_always_inline static FILE *php_win32_ioutil_fopen(const char *patha, const char *modea)
407407
{/*{{{*/
408408
FILE *ret;
409409
wchar_t modew[16] = {0};
@@ -435,7 +435,7 @@ __forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const char
435435
return ret;
436436
}/*}}}*/
437437

438-
__forceinline static int php_win32_ioutil_rename(const char *oldnamea, const char *newnamea)
438+
zend_always_inline static int php_win32_ioutil_rename(const char *oldnamea, const char *newnamea)
439439
{/*{{{*/
440440
wchar_t *oldnamew;
441441
wchar_t *newnamew;
@@ -479,7 +479,7 @@ __forceinline static int php_win32_ioutil_rename(const char *oldnamea, const cha
479479
return ret;
480480
}/*}}}*/
481481

482-
__forceinline static int php_win32_ioutil_chdir(const char *patha)
482+
zend_always_inline static int php_win32_ioutil_chdir(const char *patha)
483483
{/*{{{*/
484484
int ret;
485485
wchar_t *pathw = php_win32_ioutil_any_to_w(patha);
@@ -504,7 +504,7 @@ __forceinline static int php_win32_ioutil_chdir(const char *patha)
504504
return ret;
505505
}/*}}}*/
506506

507-
__forceinline static char *php_win32_ioutil_getcwd(char *buf, size_t len)
507+
zend_always_inline static char *php_win32_ioutil_getcwd(char *buf, size_t len)
508508
{/*{{{*/
509509
wchar_t tmp_bufw[PHP_WIN32_IOUTIL_MAXPATHLEN];
510510
char *tmp_bufa = NULL;
@@ -544,7 +544,7 @@ __forceinline static char *php_win32_ioutil_getcwd(char *buf, size_t len)
544544
}/*}}}*/
545545

546546
/* TODO improve with usage of native APIs, split for _a and _w. */
547-
__forceinline static int php_win32_ioutil_chmod(const char *patha, int mode)
547+
zend_always_inline static int php_win32_ioutil_chmod(const char *patha, int mode)
548548
{/*{{{*/
549549
wchar_t *pathw = php_win32_ioutil_any_to_w(patha);
550550
int err = 0;
@@ -571,7 +571,7 @@ __forceinline static int php_win32_ioutil_chmod(const char *patha, int mode)
571571
return ret;
572572
}/*}}}*/
573573

574-
__forceinline static int php_win32_ioutil_mkdir(const char *path, mode_t mode)
574+
zend_always_inline static int php_win32_ioutil_mkdir(const char *path, mode_t mode)
575575
{/*{{{*/
576576
int ret;
577577
DWORD err = 0;
@@ -596,7 +596,7 @@ __forceinline static int php_win32_ioutil_mkdir(const char *path, mode_t mode)
596596
return ret;
597597
}/*}}}*/
598598

599-
__forceinline static int php_win32_ioutil_symlink(const char *target, const char *link)
599+
zend_always_inline static int php_win32_ioutil_symlink(const char *target, const char *link)
600600
{/*{{{*/
601601
wchar_t *targetw, *linkw;
602602
int ret;
@@ -622,7 +622,7 @@ __forceinline static int php_win32_ioutil_symlink(const char *target, const char
622622
return ret;
623623
}/*}}}*/
624624

625-
__forceinline static int php_win32_ioutil_link(const char *target, const char *link)
625+
zend_always_inline static int php_win32_ioutil_link(const char *target, const char *link)
626626
{/*{{{*/
627627
wchar_t *targetw, *linkw;
628628
int ret;
@@ -649,7 +649,7 @@ __forceinline static int php_win32_ioutil_link(const char *target, const char *l
649649

650650
PW32IO char *realpath(const char *path, char *resolved);
651651

652-
__forceinline static char *php_win32_ioutil_realpath_ex0(const char *path, char *resolved, PBY_HANDLE_FILE_INFORMATION info)
652+
zend_always_inline static char *php_win32_ioutil_realpath_ex0(const char *path, char *resolved, PBY_HANDLE_FILE_INFORMATION info)
653653
{/*{{{*/
654654
wchar_t retw[PHP_WIN32_IOUTIL_MAXPATHLEN];
655655
char *reta;
@@ -694,7 +694,7 @@ __forceinline static char *php_win32_ioutil_realpath_ex0(const char *path, char
694694
return resolved;
695695
}/*}}}*/
696696

697-
__forceinline static char *php_win32_ioutil_realpath(const char *path, char *resolved)
697+
zend_always_inline static char *php_win32_ioutil_realpath(const char *path, char *resolved)
698698
{/*{{{*/
699699
return php_win32_ioutil_realpath_ex0(path, resolved, NULL);
700700
}/*}}}*/
@@ -758,7 +758,7 @@ typedef struct {
758758
PW32IO int php_win32_ioutil_stat_ex_w(const wchar_t *path, size_t path_len, php_win32_ioutil_stat_t *buf, int lstat);
759759
PW32IO int php_win32_ioutil_fstat(int fd, php_win32_ioutil_stat_t *buf);
760760

761-
__forceinline static int php_win32_ioutil_stat_ex(const char *path, php_win32_ioutil_stat_t *buf, int lstat)
761+
zend_always_inline static int php_win32_ioutil_stat_ex(const char *path, php_win32_ioutil_stat_t *buf, int lstat)
762762
{/*{{{*/
763763
size_t pathw_len;
764764
wchar_t *pathw = php_win32_ioutil_conv_any_to_w(path, PHP_WIN32_CP_IGNORE_LEN, &pathw_len);
@@ -780,7 +780,7 @@ __forceinline static int php_win32_ioutil_stat_ex(const char *path, php_win32_io
780780

781781
PW32IO ssize_t php_win32_ioutil_readlink_w(const wchar_t *path, wchar_t *buf, size_t buf_len);
782782

783-
__forceinline static ssize_t php_win32_ioutil_readlink(const char *path, char *buf, size_t buf_len)
783+
zend_always_inline static ssize_t php_win32_ioutil_readlink(const char *path, char *buf, size_t buf_len)
784784
{/*{{{*/
785785
size_t pathw_len, ret_buf_len;
786786
wchar_t *pathw = php_win32_ioutil_conv_any_to_w(path, PHP_WIN32_CP_IGNORE_LEN, &pathw_len);

0 commit comments

Comments
 (0)