Skip to content

Commit c7b586f

Browse files
authored
Use the namespaced version of some libunix functions (#61)
1 parent 0984c4e commit c7b586f

37 files changed

+126
-120
lines changed

discover/discover.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ let show_c file result =
146146
end result;
147147
pr "";
148148
List.iter (print_include b) config_includes;
149+
pr {|#if OCAML_VERSION < 50100
150+
#define caml_uerror uerror
151+
#define caml_unix_error unix_error
152+
#define win32_maperr caml_win32_maperr
153+
#endif
154+
|};
149155
pr "#include \"common.h\"";
150156
List.iter begin function
151157
| NO name ->

src/TODO/ftruncate/ftruncateC.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
static void caml_ftruncate_win32_error (void)
2222
{
23-
win32_maperr(GetLastError());
24-
uerror("ftruncate", Val_unit);
23+
caml_win32_maperr(GetLastError());
24+
caml_uerror("ftruncate", Val_unit);
2525
};
2626

2727
static __int64 caml_ftruncate_win32_lseek (HANDLE hFile, __int64 i64Pos, DWORD dwMoveMethod)

src/atfile.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ CAMLprim value caml_extunix_fstatat(value v_dirfd, value v_name, value v_flags)
8080
ret = fstatat(dirfd, p, &buf, flags);
8181
caml_leave_blocking_section();
8282
caml_stat_free(p);
83-
if (ret != 0) uerror("fstatat", v_name);
83+
if (ret != 0) caml_uerror("fstatat", v_name);
8484
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
85-
unix_error(EOVERFLOW, "fstatat", v_name);
85+
caml_unix_error(EOVERFLOW, "fstatat", v_name);
8686
CAMLreturn(stat_aux(/*0,*/ &buf));
8787
}
8888

@@ -99,7 +99,7 @@ CAMLprim value caml_extunix_unlinkat(value v_dirfd, value v_name, value v_flags)
9999
ret = unlinkat(dirfd, p, flags);
100100
caml_leave_blocking_section();
101101
caml_stat_free(p);
102-
if (ret != 0) uerror("unlinkat", v_name);
102+
if (ret != 0) caml_uerror("unlinkat", v_name);
103103
CAMLreturn(Val_unit);
104104
}
105105

@@ -114,7 +114,7 @@ CAMLprim value caml_extunix_renameat(value v_oldfd, value v_oldname, value v_new
114114
caml_leave_blocking_section();
115115
caml_stat_free(newname);
116116
caml_stat_free(oldname);
117-
if (ret != 0) uerror("renameat", v_oldname);
117+
if (ret != 0) caml_uerror("renameat", v_oldname);
118118
CAMLreturn(Val_unit);
119119
}
120120

@@ -127,7 +127,7 @@ CAMLprim value caml_extunix_mkdirat(value v_dirfd, value v_name, value v_mode)
127127
int ret = mkdirat(dirfd, name, mode);
128128
caml_leave_blocking_section();
129129
caml_stat_free(name);
130-
if (ret != 0) uerror("mkdirat", v_name);
130+
if (ret != 0) caml_uerror("mkdirat", v_name);
131131
CAMLreturn(Val_unit);
132132
}
133133

@@ -145,7 +145,7 @@ CAMLprim value caml_extunix_linkat(value v_olddirfd, value v_oldname, value v_ne
145145
caml_leave_blocking_section();
146146
caml_stat_free(newname);
147147
caml_stat_free(oldname);
148-
if (ret != 0) uerror("linkat", v_oldname);
148+
if (ret != 0) caml_uerror("linkat", v_oldname);
149149
CAMLreturn(Val_unit);
150150
}
151151

@@ -161,7 +161,7 @@ CAMLprim value caml_extunix_fchownat(value v_dirfd, value v_name, value v_owner,
161161
ret = fchownat(dirfd, name, owner, group, flags);
162162
caml_leave_blocking_section();
163163
caml_stat_free(name);
164-
if (ret != 0) uerror("fchownat", v_name);
164+
if (ret != 0) caml_uerror("fchownat", v_name);
165165
CAMLreturn(Val_unit);
166166
}
167167

@@ -177,7 +177,7 @@ CAMLprim value caml_extunix_fchmodat(value v_dirfd, value v_name, value v_mode,
177177
ret = fchmodat(dirfd, name, mode, flags);
178178
caml_leave_blocking_section();
179179
caml_stat_free(name);
180-
if (ret != 0) uerror("fchmodat", v_name);
180+
if (ret != 0) caml_uerror("fchmodat", v_name);
181181
CAMLreturn(Val_unit);
182182
}
183183

@@ -192,7 +192,7 @@ CAMLprim value caml_extunix_symlinkat(value v_path, value v_newdirfd, value v_ne
192192
caml_leave_blocking_section();
193193
caml_stat_free(newname);
194194
caml_stat_free(path);
195-
if (ret != 0) uerror("symlinkat", v_path);
195+
if (ret != 0) caml_uerror("symlinkat", v_path);
196196
CAMLreturn(Val_unit);
197197
}
198198

@@ -209,7 +209,7 @@ CAMLprim value caml_extunix_openat(value v_dirfd, value v_path, value flags, val
209209
ret = openat(dirfd, path, cv_flags, perm);
210210
caml_leave_blocking_section();
211211
caml_stat_free(path);
212-
if (ret == -1) uerror("openat", v_path);
212+
if (ret == -1) caml_uerror("openat", v_path);
213213
CAMLreturn (Val_int(ret));
214214
}
215215

@@ -256,7 +256,7 @@ CAMLprim value caml_extunix_readlinkat(value v_dirfd, value v_name)
256256
res = readlinkat_malloc(dirfd, name);
257257
caml_leave_blocking_section();
258258
caml_stat_free(name);
259-
if (res == NULL) uerror("readlinkat", v_name);
259+
if (res == NULL) caml_uerror("readlinkat", v_name);
260260
v_link = caml_copy_string(res);
261261
caml_stat_free(res);
262262
CAMLreturn(v_link);

src/dirfd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ CAMLprim value caml_extunix_dirfd(value v_dir)
99
CAMLparam1(v_dir);
1010
int fd = -1;
1111
DIR* dir = DIR_Val(v_dir);
12-
if (dir == (DIR *) NULL) unix_error(EBADF, "dirfd", Nothing);
12+
if (dir == (DIR *) NULL) caml_unix_error(EBADF, "dirfd", Nothing);
1313
fd = dirfd(dir);
14-
if (fd < 0) uerror("dirfd", Nothing);
14+
if (fd < 0) caml_uerror("dirfd", Nothing);
1515
CAMLreturn(Val_int(fd));
1616
}
1717

src/eventfd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CAMLprim value caml_extunix_eventfd(value v_init)
88
{
99
CAMLparam1(v_init);
1010
int fd = eventfd(Int_val(v_init), 0);
11-
if (-1 == fd) uerror("eventfd",Nothing);
11+
if (-1 == fd) caml_uerror("eventfd",Nothing);
1212
CAMLreturn(Val_int(fd));
1313
}
1414

@@ -17,15 +17,15 @@ CAMLprim value caml_extunix_eventfd_read(value v_fd)
1717
CAMLparam1(v_fd);
1818
eventfd_t v;
1919
if (-1 == eventfd_read(Int_val(v_fd), &v))
20-
uerror("eventfd_read",Nothing);
20+
caml_uerror("eventfd_read",Nothing);
2121
CAMLreturn(caml_copy_int64(v));
2222
}
2323

2424
CAMLprim value caml_extunix_eventfd_write(value v_fd, value v_val)
2525
{
2626
CAMLparam2(v_fd, v_val);
2727
if (-1 == eventfd_write(Int_val(v_fd), Int64_val(v_val)))
28-
uerror("eventfd_write",Nothing);
28+
caml_uerror("eventfd_write",Nothing);
2929
CAMLreturn(Val_unit);
3030
}
3131

src/execinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CAMLprim value caml_extunix_backtrace(value unit)
1414
int j;
1515
char **strings = backtrace_symbols(buffer, nptrs);
1616
if (NULL == strings)
17-
uerror("backtrace", Nothing);
17+
caml_uerror("backtrace", Nothing);
1818

1919
v_ret = caml_alloc_tuple(nptrs);
2020
for (j = 0; j < nptrs; j++)

src/fadvise.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CAMLprim value caml_extunix_fadvise64(value vfd, value voff, value vlen, value v
4545

4646
if (errcode != 0)
4747
{
48-
unix_error(errcode, "fadvise64", Nothing);
48+
caml_unix_error(errcode, "fadvise64", Nothing);
4949
};
5050

5151
CAMLreturn(Val_unit);
@@ -70,7 +70,7 @@ CAMLprim value caml_extunix_fadvise(value vfd, value voff, value vlen, value vad
7070

7171
if (errcode != 0)
7272
{
73-
unix_error(errcode, "fadvise", Nothing);
73+
caml_unix_error(errcode, "fadvise", Nothing);
7474
};
7575

7676
CAMLreturn(Val_unit);

src/fallocate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
static void caml_fallocate_error (void)
2222
{
23-
win32_maperr(GetLastError());
24-
uerror("fallocate", Val_unit);
23+
caml_win32_maperr(GetLastError());
24+
caml_uerror("fallocate", Val_unit);
2525
}
2626

2727
static __int64 caml_fallocate_lseek (HANDLE hFile, __int64 i64Pos, DWORD dwMoveMethod)
@@ -96,7 +96,7 @@ static void caml_fallocate_error (int errcode)
9696
{
9797
if (errcode != 0)
9898
{
99-
unix_error(errcode, "fallocate", Nothing);
99+
caml_unix_error(errcode, "fallocate", Nothing);
100100
};
101101
}
102102

src/fexecve.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ CAMLprim value caml_extunix_fexecve(value fd_val, value argv_val, value envp_val
3535

3636
caml_stat_free(argv);
3737
caml_stat_free(envp);
38-
uerror("fexecve", Nothing);
38+
caml_uerror("fexecve", Nothing);
3939

4040
CAMLreturn (Val_unit); /* not reached */
4141
}

src/fsync.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CAMLprim value caml_extunix_fsync(value v)
1919
r = FlushFileBuffers(h);
2020
caml_leave_blocking_section();
2121
if (0 == r)
22-
uerror("fsync",Nothing);
22+
caml_uerror("fsync",Nothing);
2323
CAMLreturn(Val_unit);
2424
}
2525

@@ -44,7 +44,7 @@ CAMLprim value caml_extunix_fsync(value v_fd)
4444
r = fsync(fd);
4545
caml_leave_blocking_section();
4646
if (0 != r)
47-
uerror("fsync",Nothing);
47+
caml_uerror("fsync",Nothing);
4848
CAMLreturn(Val_unit);
4949
}
5050
#endif
@@ -59,7 +59,7 @@ CAMLprim value caml_extunix_fdatasync(value v_fd)
5959
r = fdatasync(fd);
6060
caml_leave_blocking_section();
6161
if (0 != r)
62-
uerror("fdatasync",Nothing);
62+
caml_uerror("fdatasync",Nothing);
6363
CAMLreturn(Val_unit);
6464
}
6565
#endif
@@ -89,7 +89,7 @@ CAMLprim value caml_extunix_syncfs(value v_fd)
8989
#endif
9090
caml_leave_blocking_section();
9191
if (0 != r)
92-
uerror("syncfs",Nothing);
92+
caml_uerror("syncfs",Nothing);
9393
CAMLreturn(Val_unit);
9494
}
9595
#endif

0 commit comments

Comments
 (0)