Skip to content

Commit

Permalink
Open flags are not constants for the Cosmopolitan libc
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Feb 6, 2023
1 parent 1329ebe commit 4b11900
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/unix/unix_c/unix_open_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,8 @@
#define caml_unix_cloexec_default unix_cloexec_default
#endif

static int open_flag_table[] = {
O_RDONLY, O_WRONLY, O_RDWR, O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC,
O_EXCL, O_NOCTTY, O_DSYNC, O_SYNC, O_RSYNC, 0, /* O_SHARE_DELETE,
Windows-only */
0, /* O_CLOEXEC, treated specially */
0 /* O_KEEPEXEC, treated specially */
};

enum { CLOEXEC = 1, KEEPEXEC = 2 };

static int open_cloexec_table[15] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, CLOEXEC, KEEPEXEC};

struct job_open {
struct lwt_unix_job job;
int flags;
Expand Down Expand Up @@ -112,6 +101,18 @@ static value result_open(struct job_open *job)

CAMLprim value lwt_unix_open_job(value name, value flags, value perms)
{
int open_flag_table[] = {
O_RDONLY, O_WRONLY, O_RDWR, O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC,
O_EXCL, O_NOCTTY, O_DSYNC, O_SYNC, O_RSYNC, 0, /* O_SHARE_DELETE,
Windows-only */
0, /* O_CLOEXEC, treated specially */
0 /* O_KEEPEXEC, treated specially */
};


int open_cloexec_table[15] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, CLOEXEC, KEEPEXEC};

LWT_UNIX_INIT_JOB_STRING(job, open, 0, name);
job->fd = caml_convert_flag_list(flags, open_cloexec_table);
job->flags = caml_convert_flag_list(flags, open_flag_table);
Expand Down

0 comments on commit 4b11900

Please sign in to comment.