Skip to content

Commit 6f297bd

Browse files
authored
Merge pull request #5267 from mysterywolf/libc-fcntl.h
[libc] 修复在fcntl.h中两种不同的宏编码方式导致的bug
2 parents 5711b0a + 09666e6 commit 6f297bd

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

components/libc/compilers/common/fcntl.h renamed to components/libc/compilers/common/nogcc/fcntl.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212

1313
#include <sys/types.h>
1414

15-
#define O_RDONLY 0x0000 /* open for reading only */
16-
#define O_WRONLY 0x0001 /* open for writing only */
17-
#define O_RDWR 0x0002 /* open for reading and writing */
18-
#define O_ACCMODE 0x0003 /* mask for above modes */
15+
#define O_RDONLY 00
16+
#define O_WRONLY 01
17+
#define O_RDWR 02
1918

2019
#define O_CREAT 0100
2120
#define O_EXCL 0200
@@ -30,16 +29,20 @@
3029
#define O_DIRECTORY 0200000
3130
#define O_NOFOLLOW 0400000
3231
#define O_CLOEXEC 02000000
32+
3333
#define O_ASYNC 020000
3434
#define O_DIRECT 040000
3535
#define O_LARGEFILE 0100000
3636
#define O_NOATIME 01000000
3737
#define O_PATH 010000000
3838
#define O_TMPFILE 020200000
3939
#define O_NDELAY O_NONBLOCK
40+
4041
#define O_SEARCH O_PATH
4142
#define O_EXEC O_PATH
4243

44+
#define O_ACCMODE (03|O_SEARCH)
45+
4346
#define F_DUPFD 0
4447
#define F_GETFD 1
4548
#define F_SETFD 2

components/libc/compilers/common/nogcc/unistd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
* Date Author Notes
88
*/
99
#include "sys/unistd.h"
10-
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-09-02 Meco Man First version
9+
*/
10+
#ifndef __FCNTL_H__
11+
#define __FCNTL_H__
12+
13+
#include <sys/_default_fcntl.h>
14+
15+
#ifndef O_DIRECTORY
16+
#define O_DIRECTORY 0x200000
17+
#endif
18+
19+
#ifndef O_BINARY
20+
#define O_BINARY 0x10000
21+
#endif
22+
23+
#endif

0 commit comments

Comments
 (0)