@@ -473,7 +473,11 @@ ALWAYS_INLINE NP_DECL(int) _open(const char *pathname, int flags, mode_t mode) {
473
473
ALWAYS_INLINE NP_DECL (int ) open (const char * pathname , int flags , ... /* mode_t mode */ ) {
474
474
va_list args ;
475
475
va_start (args , flags );
476
+ #ifdef _WIN32
477
+ int mode = 0 ;
478
+ #else
476
479
mode_t mode = 0 ;
480
+ #endif
477
481
if (flags & O_CREAT ) {
478
482
mode = va_arg (args , int );
479
483
}
@@ -483,7 +487,11 @@ ALWAYS_INLINE NP_DECL(int) open(const char *pathname, int flags, ... /* mode_t m
483
487
ALWAYS_INLINE NP_DECL (int ) _open (const char * pathname , int flags , ... /* mode_t mode */ ) {
484
488
va_list args ;
485
489
va_start (args , flags );
490
+ #ifdef _WIN32
491
+ int mode = 0 ;
492
+ #else
486
493
mode_t mode = 0 ;
494
+ #endif
487
495
if (flags & O_CREAT ) {
488
496
mode = va_arg (args , int );
489
497
}
@@ -521,32 +529,26 @@ ALWAYS_INLINE NP_DECL(int) _close(int fd) {
521
529
}
522
530
523
531
#ifdef _WIN32
524
- #ifdef __cplusplus
525
- ALWAYS_INLINE NP_DECL (int ) wopen (const wchar_t * pathname , int flags , int mode = 0 ) {
526
- #else
527
- ALWAYS_INLINE NP_DECL (int ) wopen (const wchar_t * pathname , int flags , int mode ) {
528
- #endif
529
- return np_wopen (pathname , flags , mode );
532
+ ALWAYS_INLINE NP_DECL (int ) wopen (const wchar_t * pathname , int flags , ... /* int mode */ ) {
533
+ va_list args ;
534
+ va_start (args , flags );
535
+ int mode = 0 ;
536
+ if (flags & O_CREAT ) {
537
+ mode = va_arg (args , int );
538
+ }
539
+ va_end (args );
540
+ return np_wopen (pathname , flags , mode );
530
541
}
531
- #ifdef __cplusplus
532
- ALWAYS_INLINE NP_DECL (int ) _wopen (const wchar_t * pathname , int flags , int mode = 0 ) {
533
- #else
534
- ALWAYS_INLINE NP_DECL (int ) _wopen (const wchar_t * pathname , int flags , int mode ) {
535
- #endif
536
- return np_wopen (pathname , flags , mode );
542
+ ALWAYS_INLINE NP_DECL (int ) _wopen (const wchar_t * pathname , int flags , ... /* int mode */ ) {
543
+ va_list args ;
544
+ va_start (args , flags );
545
+ int mode = 0 ;
546
+ if (flags & O_CREAT ) {
547
+ mode = va_arg (args , int );
548
+ }
549
+ va_end (args );
550
+ return np_wopen (pathname , flags , mode );
537
551
}
538
- #ifndef __cplusplus
539
- #define wopen0 () wopen()
540
- #define wopen1 (a ) wopen(a)
541
- #define wopen2 (a , b ) open(a, b, 0)
542
- #define wopen3 (a , b , c ) open(a, b, c)
543
- #define wopen4 (a , b , c , d ) wopen(a, b, c, d)
544
- #define wopen5 (a , b , c , d , e ) wopen(a, b, c, d, e)
545
- #define wopen6 (a , b , c , d , e , f ) wopen(a, b, c, d, e, f)
546
- #define wopen7 (a , b , c , d , e , f , g ) wopen(a, b, c, d, e, f, g)
547
- #define wopen (...) CAT( wopen, NUM_ARGS( __VA_ARGS__ ) )( __VA_ARGS__ )
548
- #define _wopen (...) CAT( wopen, NUM_ARGS( __VA_ARGS__ ) )( __VA_ARGS__ )
549
- #endif
550
552
551
553
ALWAYS_INLINE NP_DECL (EFILE * ) wfopen (const wchar_t * file , const wchar_t * mode ) {
552
554
return np_wfopen (file , mode );
0 commit comments