Skip to content

Commit 4b11900

Browse files
committed
Open flags are not constants for the Cosmopolitan libc
1 parent 1329ebe commit 4b11900

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/unix/unix_c/unix_open_job.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,8 @@
3535
#define caml_unix_cloexec_default unix_cloexec_default
3636
#endif
3737

38-
static int open_flag_table[] = {
39-
O_RDONLY, O_WRONLY, O_RDWR, O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC,
40-
O_EXCL, O_NOCTTY, O_DSYNC, O_SYNC, O_RSYNC, 0, /* O_SHARE_DELETE,
41-
Windows-only */
42-
0, /* O_CLOEXEC, treated specially */
43-
0 /* O_KEEPEXEC, treated specially */
44-
};
45-
4638
enum { CLOEXEC = 1, KEEPEXEC = 2 };
4739

48-
static int open_cloexec_table[15] = {0, 0, 0, 0, 0, 0, 0, 0,
49-
0, 0, 0, 0, 0, CLOEXEC, KEEPEXEC};
50-
5140
struct job_open {
5241
struct lwt_unix_job job;
5342
int flags;
@@ -112,6 +101,18 @@ static value result_open(struct job_open *job)
112101

113102
CAMLprim value lwt_unix_open_job(value name, value flags, value perms)
114103
{
104+
int open_flag_table[] = {
105+
O_RDONLY, O_WRONLY, O_RDWR, O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC,
106+
O_EXCL, O_NOCTTY, O_DSYNC, O_SYNC, O_RSYNC, 0, /* O_SHARE_DELETE,
107+
Windows-only */
108+
0, /* O_CLOEXEC, treated specially */
109+
0 /* O_KEEPEXEC, treated specially */
110+
};
111+
112+
113+
int open_cloexec_table[15] = {0, 0, 0, 0, 0, 0, 0, 0,
114+
0, 0, 0, 0, 0, CLOEXEC, KEEPEXEC};
115+
115116
LWT_UNIX_INIT_JOB_STRING(job, open, 0, name);
116117
job->fd = caml_convert_flag_list(flags, open_cloexec_table);
117118
job->flags = caml_convert_flag_list(flags, open_flag_table);

0 commit comments

Comments
 (0)