Do not use the compatibility macros in the C stub code. (#892)

* Don't use the compatibility macros, neither in the C stub code nor in the testsuite.

* Make sure compiler sources do not use deprecated C identifiers.

This is achieved by ensuring that the CAML_NAME_SPACE macro is defined
everytime a C source file is compiled, rather than being defined only
in a few places. Defining this macro guarantees that the compatibility.h
header (where these deprecated identifiers are defined) will not be
included.
master
Sébastien Hinderer 2016-11-17 11:03:09 +01:00 committed by Damien Doligez
parent c628d9c6e1
commit 13945a71ed
97 changed files with 469 additions and 468 deletions

View File

@ -18,7 +18,7 @@ include ../config/Makefile
include Makefile.shared
CC=$(NATIVECC)
FLAGS=-I../byterun -DCAML_NAME_SPACE -DNATIVE_CODE \
FLAGS=-I../byterun -DNATIVE_CODE \
-DTARGET_$(ARCH) -DMODEL_$(MODEL) -DSYS_$(SYSTEM) $(IFLEXDIR) \
$(LIBUNWIND_INCLUDE_FLAGS)
#CFLAGS=$(FLAGS) -g -O0

View File

@ -15,8 +15,8 @@
include Makefile.shared
CFLAGS=-DCAML_NAME_SPACE $(BYTECCCOMPOPTS) $(IFLEXDIR)
DFLAGS=-DCAML_NAME_SPACE -g -DDEBUG $(BYTECCCOMPOPTS) $(IFLEXDIR)
CFLAGS=$(BYTECCCOMPOPTS) $(IFLEXDIR)
DFLAGS=-g -DDEBUG $(BYTECCCOMPOPTS) $(IFLEXDIR)
IFLAGS=$(CFLAGS) -DCAML_INSTR
OBJS=$(COMMONOBJS) $(UNIX_OR_WIN32).o main.o

View File

@ -101,7 +101,7 @@ SAFE_STRING=false
BYTECC=$(TOOLPREF)gcc -O -mms-bitfields
### Additional compile-time options for $(BYTECC). (For static linking.)
BYTECCCOMPOPTS=-Wall -Wno-unused
BYTECCCOMPOPTS=-DCAML_NAME_SPACE -Wall -Wno-unused
### Additional link-time options for $(BYTECC). (For static linking.)
BYTECCLINKOPTS=
@ -168,7 +168,7 @@ SYSTEM=mingw
NATIVECC=$(BYTECC)
### Additional compile-time options for $(NATIVECC).
NATIVECCCOMPOPTS=-Wall -Wno-unused
NATIVECCCOMPOPTS=-DCAML_NAME_SPACE -Wall -Wno-unused
### Additional link-time options for $(NATIVECC)
NATIVECCLINKOPTS=

View File

@ -101,7 +101,7 @@ SAFE_STRING=false
BYTECC=$(TOOLPREF)gcc -O -mms-bitfields
### Additional compile-time options for $(BYTECC). (For static linking.)
BYTECCCOMPOPTS=-Wall -Wno-unused
BYTECCCOMPOPTS=-DCAML_NAME_SPACE -Wall -Wno-unused
### Additional link-time options for $(BYTECC). (For static linking.)
BYTECCLINKOPTS=
@ -168,7 +168,7 @@ SYSTEM=mingw64
NATIVECC=$(BYTECC)
### Additional compile-time options for $(NATIVECC).
NATIVECCCOMPOPTS=-Wall -Wno-unused
NATIVECCCOMPOPTS=-DCAML_NAME_SPACE -Wall -Wno-unused
### Additional link-time options for $(NATIVECC)
NATIVECCLINKOPTS=

View File

@ -95,7 +95,7 @@ SAFE_STRING=false
BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE -O2 -Gy- -MD
### Additional compile-time options for $(BYTECC). (For static linking.)
BYTECCCOMPOPTS=
BYTECCCOMPOPTS=-DCAML_NAME_SPACE
### Additional link-time options for $(BYTECC). (For static linking.)
BYTECCLINKOPTS=
@ -166,7 +166,7 @@ SYSTEM=win32
NATIVECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE -O2 -Gy- -MD
### Additional compile-time options for $(NATIVECC).
NATIVECCCOMPOPTS=
NATIVECCCOMPOPTS=-DCAML_NAME_SPACE
### Additional link-time options for $(NATIVECC)
NATIVECCLINKOPTS=

View File

@ -94,7 +94,7 @@ SAFE_STRING=false
BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE -O2 -Gy- -MD
### Additional compile-time options for $(BYTECC). (For static linking.)
BYTECCCOMPOPTS=
BYTECCCOMPOPTS=-DCAML_NAME_SPACE
### Additional compile-time options for $(BYTECC). (For debug version.)
BYTECCDBGCOMPOPTS=-DDEBUG -Zi -W3 -Wp64
@ -171,7 +171,7 @@ SYSTEM=win64
NATIVECC=cl -nologo -O2 -Gy- -MD
### Additional compile-time options for $(NATIVECC).
NATIVECCCOMPOPTS=
NATIVECCCOMPOPTS=-DCAML_NAME_SPACE
### Additional link-time options for $(NATIVECC)
NATIVECCLINKOPTS=

2
configure vendored
View File

@ -399,6 +399,8 @@ case "$ccfamily" in
bytecccompopts="-O";;
esac
byteccprivatecompopts="-DCAML_NAME_SPACE $byteccprivatecompopts"
# Adjust according to target
case "$bytecc,$target" in

View File

@ -14,7 +14,7 @@
#**************************************************************************
LIBNAME=bigarray
EXTRACFLAGS=-I../$(UNIXLIB) -DIN_OCAML_BIGARRAY -DCAML_NAME_SPACE
EXTRACFLAGS=-I../$(UNIXLIB) -DIN_OCAML_BIGARRAY
EXTRACAMLFLAGS=-I ../$(UNIXLIB)
COBJS=bigarray_stubs.$(O) mmap_$(UNIX_OR_WIN32).$(O)
CAMLOBJS=bigarray.cmo

View File

@ -28,10 +28,10 @@ value caml_gr_dump_image(value image)
caml_gr_check_open();
width = Width_im(image);
height = Height_im(image);
m = alloc(height, 0);
m = caml_alloc(height, 0);
for (i = 0; i < height; i++) {
value v = alloc(width, 0);
modify(&Field(m, i), v);
value v = caml_alloc(width, 0);
caml_modify(&Field(m, i), v);
}
idata =

View File

@ -146,7 +146,7 @@ void caml_gr_handle_event(XEvent * event)
static value caml_gr_wait_allocate_result(int mouse_x, int mouse_y, int button,
int keypressed, int key)
{
value res = alloc_small(5, 0);
value res = caml_alloc_small(5, 0);
Field(res, 0) = Val_int(mouse_x);
Field(res, 1) = Val_int(mouse_y == -1 ? -1 : Wcvt(mouse_y));
Field(res, 2) = Val_bool(button);
@ -237,9 +237,9 @@ static value caml_gr_wait_event_blocking(long mask)
/* No event available: block on input socket until one is */
FD_ZERO(&readfds);
FD_SET(ConnectionNumber(caml_gr_display), &readfds);
enter_blocking_section();
caml_enter_blocking_section();
select(FD_SETSIZE, &readfds, NULL, NULL, NULL);
leave_blocking_section();
caml_leave_blocking_section();
caml_gr_check_open(); /* in case another thread closed the display */
}
}

View File

@ -57,7 +57,7 @@ value caml_gr_fill_poly(value array)
npoints, Complex, CoordModeOrigin);
XFlush(caml_gr_display);
}
stat_free((char *) points);
caml_stat_free((char *) points);
return Val_unit;
}

View File

@ -38,7 +38,7 @@ static struct custom_operations image_ops = {
value caml_gr_new_image(int w, int h)
{
value res = alloc_custom(&image_ops, sizeof(struct grimage),
value res = caml_alloc_custom(&image_ops, sizeof(struct grimage),
w * h, Max_image_mem);
Width_im(res) = w;
Height_im(res) = h;

View File

@ -234,7 +234,7 @@ value caml_gr_id_of_window(Window win)
char tmp[256];
sprintf(tmp, "%lu", (unsigned long)win);
return copy_string( tmp );
return caml_copy_string( tmp );
}
value caml_gr_window_id(void)
@ -245,7 +245,7 @@ value caml_gr_window_id(void)
value caml_gr_set_window_title(value n)
{
if (window_name != NULL) stat_free(window_name);
if (window_name != NULL) caml_stat_free(window_name);
window_name = caml_strdup(String_val(n));
if (caml_gr_initialized) {
XStoreName(caml_gr_display, caml_gr_window.win, window_name);
@ -373,11 +373,11 @@ void caml_gr_fail(char *fmt, char *arg)
if (graphic_failure_exn == NULL) {
graphic_failure_exn = caml_named_value("Graphics.Graphic_failure");
if (graphic_failure_exn == NULL)
invalid_argument("Exception Graphics.Graphic_failure not initialized,"
caml_invalid_argument("Exception Graphics.Graphic_failure not initialized,"
" must link graphics.cma");
}
sprintf(buffer, fmt, arg);
raise_with_string(*graphic_failure_exn, buffer);
caml_raise_with_string(*graphic_failure_exn, buffer);
}
void caml_gr_check_open(void)

View File

@ -68,7 +68,7 @@ value caml_gr_draw_char(value chr)
value caml_gr_draw_string(value str)
{
caml_gr_check_open();
caml_gr_draw_text(String_val(str), string_length(str));
caml_gr_draw_text(String_val(str), caml_string_length(str));
return Val_unit;
}
@ -78,8 +78,8 @@ value caml_gr_text_size(value str)
value res;
caml_gr_check_open();
if (caml_gr_font == NULL) caml_gr_get_font(DEFAULT_FONT);
width = XTextWidth(caml_gr_font, String_val(str), string_length(str));
res = alloc_small(2, 0);
width = XTextWidth(caml_gr_font, String_val(str), caml_string_length(str));
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_int(width);
Field(res, 1) = Val_int(caml_gr_font->ascent + caml_gr_font->descent);
return res;

View File

@ -46,7 +46,7 @@ static struct custom_operations nat_operations = {
CAMLprim value initialize_nat(value unit)
{
bng_init();
register_custom_operations(&nat_operations);
caml_register_custom_operations(&nat_operations);
return Val_unit;
}
@ -54,7 +54,7 @@ CAMLprim value create_nat(value size)
{
mlsize_t sz = Long_val(size);
return alloc_custom(&nat_operations, sz * sizeof(value), 0, 1);
return caml_alloc_custom(&nat_operations, sz * sizeof(value), 0, 1);
}
CAMLprim value length_nat(value nat)
@ -335,7 +335,7 @@ CAMLprim value lxor_digit_nat(value nat1, value ofs1, value nat2, value ofs2)
- 32-bit word: number of 32-bit words in nat
- N 32-bit words (big-endian format)
For little-endian platforms, the memory layout between 32-bit and 64-bit
machines is identical, so we can write the nat using serialize_block_4.
machines is identical, so we can write the nat using caml_serialize_block_4.
For big-endian 64-bit platforms, we need to swap the two 32-bit halves
of 64-bit words to obtain the correct behavior. */
@ -348,19 +348,19 @@ static void serialize_nat(value nat,
#ifdef ARCH_SIXTYFOUR
len = len * 2; /* two 32-bit words per 64-bit digit */
if (len >= ((mlsize_t)1 << 32))
failwith("output_value: nat too big");
caml_failwith("output_value: nat too big");
#endif
serialize_int_4((int32_t) len);
caml_serialize_int_4((int32_t) len);
#if defined(ARCH_SIXTYFOUR) && defined(ARCH_BIG_ENDIAN)
{ int32_t * p;
mlsize_t i;
for (i = len, p = Data_custom_val(nat); i > 0; i -= 2, p += 2) {
serialize_int_4(p[1]); /* low 32 bits of 64-bit digit */
serialize_int_4(p[0]); /* high 32 bits of 64-bit digit */
caml_serialize_int_4(p[1]); /* low 32 bits of 64-bit digit */
caml_serialize_int_4(p[0]); /* high 32 bits of 64-bit digit */
}
}
#else
serialize_block_4(Data_custom_val(nat), len);
caml_serialize_block_4(Data_custom_val(nat), len);
#endif
*wsize_32 = len * 4;
*wsize_64 = len * 4;
@ -370,22 +370,22 @@ static uintnat deserialize_nat(void * dst)
{
mlsize_t len;
len = deserialize_uint_4();
len = caml_deserialize_uint_4();
#if defined(ARCH_SIXTYFOUR) && defined(ARCH_BIG_ENDIAN)
{ uint32_t * p;
mlsize_t i;
for (i = len, p = dst; i > 1; i -= 2, p += 2) {
p[1] = deserialize_uint_4(); /* low 32 bits of 64-bit digit */
p[0] = deserialize_uint_4(); /* high 32 bits of 64-bit digit */
p[1] = caml_deserialize_uint_4(); /* low 32 bits of 64-bit digit */
p[0] = caml_deserialize_uint_4(); /* high 32 bits of 64-bit digit */
}
if (i > 0){
p[1] = deserialize_uint_4(); /* low 32 bits of 64-bit digit */
p[1] = caml_deserialize_uint_4(); /* low 32 bits of 64-bit digit */
p[0] = 0; /* high 32 bits of 64-bit digit */
++ len;
}
}
#else
deserialize_block_4(dst, len);
caml_deserialize_block_4(dst, len);
#if defined(ARCH_SIXTYFOUR)
if (len & 1){
((uint32_t *) dst)[len] = 0;

View File

@ -13,7 +13,6 @@
/* */
/**************************************************************************/
#define CAML_NAME_SPACE
#include <string.h>
#include <ctype.h>
#include <caml/mlvalues.h>

View File

@ -304,15 +304,15 @@ static void st_check_error(int retcode, char * msg)
value str;
if (retcode == 0) return;
if (retcode == ENOMEM) raise_out_of_memory();
if (retcode == ENOMEM) caml_raise_out_of_memory();
err = strerror(retcode);
msglen = strlen(msg);
errlen = strlen(err);
str = alloc_string(msglen + 2 + errlen);
str = caml_alloc_string(msglen + 2 + errlen);
memmove (&Byte(str, 0), msg, msglen);
memmove (&Byte(str, msglen), ": ", 2);
memmove (&Byte(str, msglen + 2), err, errlen);
raise_sys_error(str);
caml_raise_sys_error(str);
}
/* Variable used to stop the "tick" thread */
@ -383,7 +383,7 @@ static value st_encode_sigset(sigset_t * set)
Begin_root(res)
for (i = 1; i < NSIG; i++)
if (sigismember(set, i) > 0) {
value newcons = alloc_small(2, 0);
value newcons = caml_alloc_small(2, 0);
Field(newcons, 0) = Val_int(caml_rev_convert_signal_number(i));
Field(newcons, 1) = res;
res = newcons;
@ -402,9 +402,9 @@ value caml_thread_sigmask(value cmd, value sigs) /* ML */
how = sigmask_cmd[Int_val(cmd)];
st_decode_sigset(sigs, &set);
enter_blocking_section();
caml_enter_blocking_section();
retcode = pthread_sigmask(how, &set, &oldset);
leave_blocking_section();
caml_leave_blocking_section();
st_check_error(retcode, "Thread.sigmask");
return st_encode_sigset(&oldset);
}
@ -416,9 +416,9 @@ value caml_wait_signal(value sigs) /* ML */
int retcode, signo;
st_decode_sigset(sigs, &set);
enter_blocking_section();
caml_enter_blocking_section();
retcode = sigwait(&set, &signo);
leave_blocking_section();
caml_leave_blocking_section();
st_check_error(retcode, "Thread.wait_signal");
return Val_int(caml_rev_convert_signal_number(signo));
#else

View File

@ -88,14 +88,14 @@ struct caml_thread_struct {
value * stack_low; /* The execution stack for this thread */
value * stack_high;
value * stack_threshold;
value * sp; /* Saved value of extern_sp for this thread */
value * trapsp; /* Saved value of trapsp for this thread */
struct caml__roots_block * local_roots; /* Saved value of local_roots */
struct longjmp_buffer * external_raise; /* Saved external_raise */
value * sp; /* Saved value of caml_extern_sp for this thread */
value * trapsp; /* Saved value of caml_trapsp for this thread */
struct caml__roots_block * local_roots; /* Saved value of caml_local_roots */
struct longjmp_buffer * external_raise; /* Saved caml_external_raise */
#endif
int backtrace_pos; /* Saved backtrace_pos */
backtrace_slot * backtrace_buffer; /* Saved backtrace_buffer */
value backtrace_last_exn; /* Saved backtrace_last_exn (root) */
int backtrace_pos; /* Saved caml_backtrace_pos */
backtrace_slot * backtrace_buffer; /* Saved caml_backtrace_buffer */
value backtrace_last_exn; /* Saved caml_backtrace_last_exn (root) */
};
typedef struct caml_thread_struct * caml_thread_t;
@ -152,10 +152,10 @@ static void caml_thread_scan_roots(scanning_action action)
if (th != curr_thread) {
#ifdef NATIVE_CODE
if (th->bottom_of_stack != NULL)
do_local_roots(action, th->bottom_of_stack, th->last_retaddr,
caml_do_local_roots(action, th->bottom_of_stack, th->last_retaddr,
th->gc_regs, th->local_roots);
#else
do_local_roots(action, th->sp, th->stack_high, th->local_roots);
caml_do_local_roots(action, th->sp, th->stack_high, th->local_roots);
#endif
}
th = th->next;
@ -173,7 +173,7 @@ static inline void caml_thread_save_runtime_state(void)
curr_thread->last_retaddr = caml_last_return_address;
curr_thread->gc_regs = caml_gc_regs;
curr_thread->exception_pointer = caml_exception_pointer;
curr_thread->local_roots = local_roots;
curr_thread->local_roots = caml_local_roots;
#ifdef WITH_SPACETIME
curr_thread->spacetime_trie_node_ptr
= caml_spacetime_trie_node_ptr;
@ -181,17 +181,17 @@ static inline void caml_thread_save_runtime_state(void)
= caml_spacetime_finaliser_trie_root;
#endif
#else
curr_thread->stack_low = stack_low;
curr_thread->stack_high = stack_high;
curr_thread->stack_threshold = stack_threshold;
curr_thread->sp = extern_sp;
curr_thread->trapsp = trapsp;
curr_thread->local_roots = local_roots;
curr_thread->external_raise = external_raise;
curr_thread->stack_low = caml_stack_low;
curr_thread->stack_high = caml_stack_high;
curr_thread->stack_threshold = caml_stack_threshold;
curr_thread->sp = caml_extern_sp;
curr_thread->trapsp = caml_trapsp;
curr_thread->local_roots = caml_local_roots;
curr_thread->external_raise = caml_external_raise;
#endif
curr_thread->backtrace_pos = backtrace_pos;
curr_thread->backtrace_buffer = backtrace_buffer;
curr_thread->backtrace_last_exn = backtrace_last_exn;
curr_thread->backtrace_pos = caml_backtrace_pos;
curr_thread->backtrace_buffer = caml_backtrace_buffer;
curr_thread->backtrace_last_exn = caml_backtrace_last_exn;
}
static inline void caml_thread_restore_runtime_state(void)
@ -201,7 +201,7 @@ static inline void caml_thread_restore_runtime_state(void)
caml_last_return_address = curr_thread->last_retaddr;
caml_gc_regs = curr_thread->gc_regs;
caml_exception_pointer = curr_thread->exception_pointer;
local_roots = curr_thread->local_roots;
caml_local_roots = curr_thread->local_roots;
#ifdef WITH_SPACETIME
caml_spacetime_trie_node_ptr
= curr_thread->spacetime_trie_node_ptr;
@ -209,20 +209,20 @@ static inline void caml_thread_restore_runtime_state(void)
= curr_thread->spacetime_finaliser_trie_root;
#endif
#else
stack_low = curr_thread->stack_low;
stack_high = curr_thread->stack_high;
stack_threshold = curr_thread->stack_threshold;
extern_sp = curr_thread->sp;
trapsp = curr_thread->trapsp;
local_roots = curr_thread->local_roots;
external_raise = curr_thread->external_raise;
caml_stack_low = curr_thread->stack_low;
caml_stack_high = curr_thread->stack_high;
caml_stack_threshold = curr_thread->stack_threshold;
caml_extern_sp = curr_thread->sp;
caml_trapsp = curr_thread->trapsp;
caml_local_roots = curr_thread->local_roots;
caml_external_raise = curr_thread->external_raise;
#endif
backtrace_pos = curr_thread->backtrace_pos;
backtrace_buffer = curr_thread->backtrace_buffer;
backtrace_last_exn = curr_thread->backtrace_last_exn;
caml_backtrace_pos = curr_thread->backtrace_pos;
caml_backtrace_buffer = curr_thread->backtrace_buffer;
caml_backtrace_last_exn = curr_thread->backtrace_last_exn;
}
/* Hooks for enter_blocking_section and leave_blocking_section */
/* Hooks for caml_enter_blocking_section and caml_leave_blocking_section */
static void caml_thread_enter_blocking_section(void)
@ -276,7 +276,7 @@ static void caml_io_mutex_lock(struct channel *chan)
return;
}
/* If unsuccessful, block on mutex */
enter_blocking_section();
caml_enter_blocking_section();
st_mutex_lock(mutex);
/* Problem: if a signal occurs at this point,
and the signal handler raises an exception, we will not
@ -284,7 +284,7 @@ static void caml_io_mutex_lock(struct channel *chan)
before locking the mutex is also incorrect, since we could
then unlock a mutex that is unlocked or locked by someone else. */
st_tls_set(last_channel_locked_key, (void *) chan);
leave_blocking_section();
caml_leave_blocking_section();
}
static void caml_io_mutex_unlock(struct channel *chan)
@ -380,7 +380,7 @@ static value caml_thread_new_descriptor(value clos)
/* Create and initialize the termination semaphore */
mu = caml_threadstatus_new();
/* Create a descriptor for the new thread */
descr = alloc_small(3, 0);
descr = caml_alloc_small(3, 0);
Ident(descr) = Val_long(thread_next_ident);
Start_closure(descr) = clos;
Terminated(descr) = mu;
@ -401,11 +401,11 @@ static void caml_thread_remove_info(caml_thread_t th)
th->next->prev = th->prev;
th->prev->next = th->next;
#ifndef NATIVE_CODE
stat_free(th->stack_low);
caml_stat_free(th->stack_low);
#endif
if (th->backtrace_buffer != NULL) free(th->backtrace_buffer);
#ifndef WITH_SPACETIME
stat_free(th);
caml_stat_free(th);
/* CR-soon mshinwell: consider what to do about the Spacetime trace. Could
perhaps have a hook to save a snapshot on thread termination.
For the moment we can't even free [th], since it contains the trie
@ -425,7 +425,7 @@ static void caml_thread_reinitialize(void)
thr = curr_thread->next;
while (thr != curr_thread) {
next = thr->next;
stat_free(thr);
caml_stat_free(thr);
thr = next;
}
curr_thread->next = curr_thread;
@ -433,7 +433,7 @@ static void caml_thread_reinitialize(void)
all_threads = curr_thread;
/* Reinitialize the master lock machinery,
just in case the fork happened while other threads were doing
leave_blocking_section */
caml_leave_blocking_section */
st_masterlock_init(&caml_master_lock);
/* Tick thread is not currently running in child process, will be
re-created at next Thread.create */
@ -474,15 +474,15 @@ CAMLprim value caml_thread_initialize(value unit) /* ML */
curr_thread->exit_buf = &caml_termination_jmpbuf;
#endif
/* The stack-related fields will be filled in at the next
enter_blocking_section */
caml_enter_blocking_section */
/* Associate the thread descriptor with the thread */
st_tls_set(thread_descriptor_key, (void *) curr_thread);
/* Set up the hooks */
prev_scan_roots_hook = scan_roots_hook;
scan_roots_hook = caml_thread_scan_roots;
enter_blocking_section_hook = caml_thread_enter_blocking_section;
leave_blocking_section_hook = caml_thread_leave_blocking_section;
try_leave_blocking_section_hook = caml_thread_try_leave_blocking_section;
prev_scan_roots_hook = caml_scan_roots_hook;
caml_scan_roots_hook = caml_thread_scan_roots;
caml_enter_blocking_section_hook = caml_thread_enter_blocking_section;
caml_leave_blocking_section_hook = caml_thread_leave_blocking_section;
caml_try_leave_blocking_section_hook = caml_thread_try_leave_blocking_section;
#ifdef NATIVE_CODE
caml_termination_hook = st_thread_exit;
#endif
@ -544,7 +544,7 @@ static ST_THREAD_FUNCTION caml_thread_start(void * arg)
/* Associate the thread descriptor with the thread */
st_tls_set(thread_descriptor_key, (void *) th);
/* Acquire the global mutex */
leave_blocking_section();
caml_leave_blocking_section();
#ifdef NATIVE_CODE
/* Record top of stack (approximative) */
th->top_of_stack = &tos;
@ -554,8 +554,8 @@ static ST_THREAD_FUNCTION caml_thread_start(void * arg)
#endif
/* Callback the closure */
clos = Start_closure(th->descr);
modify(&(Start_closure(th->descr)), Val_unit);
callback_exn(clos, Val_unit);
caml_modify(&(Start_closure(th->descr)), Val_unit);
caml_callback_exn(clos, Val_unit);
caml_thread_stop();
#ifdef NATIVE_CODE
}
@ -630,7 +630,7 @@ CAMLexport int caml_c_thread_register(void)
/* Release the master lock */
st_masterlock_release(&caml_master_lock);
/* Now we can re-enter the run-time system and heap-allocate the descriptor */
leave_blocking_section();
caml_leave_blocking_section();
th->descr = caml_thread_new_descriptor(Val_unit); /* no closure */
/* Create the tick thread if not already done. */
if (! caml_tick_thread_running) {
@ -638,7 +638,7 @@ CAMLexport int caml_c_thread_register(void)
if (err == 0) caml_tick_thread_running = 1;
}
/* Exit the run-time system */
enter_blocking_section();
caml_enter_blocking_section();
return 1;
}
@ -665,7 +665,7 @@ CAMLexport int caml_c_thread_unregister(void)
CAMLprim value caml_thread_self(value unit) /* ML */
{
if (curr_thread == NULL) invalid_argument("Thread.self: not initialized");
if (curr_thread == NULL) caml_invalid_argument("Thread.self: not initialized");
return curr_thread->descr;
}
@ -680,11 +680,11 @@ CAMLprim value caml_thread_id(value th) /* ML */
CAMLprim value caml_thread_uncaught_exception(value exn) /* ML */
{
char * msg = format_caml_exception(exn);
char * msg = caml_format_exception(exn);
fprintf(stderr, "Thread %d killed on uncaught exception %s\n",
Int_val(Ident(curr_thread->descr)), msg);
free(msg);
if (caml_backtrace_active) print_exception_backtrace();
if (caml_backtrace_active) caml_print_exception_backtrace();
fflush(stderr);
return Val_unit;
}
@ -695,7 +695,7 @@ CAMLprim value caml_thread_exit(value unit) /* ML */
{
struct longjmp_buffer * exit_buf = NULL;
if (curr_thread == NULL) invalid_argument("Thread.exit: not initialized");
if (curr_thread == NULL) caml_invalid_argument("Thread.exit: not initialized");
/* In native code, we cannot call pthread_exit here because on some
systems this raises a C++ exception, and ocamlopt-generated stack
@ -724,9 +724,9 @@ CAMLprim value caml_thread_exit(value unit) /* ML */
CAMLprim value caml_thread_yield(value unit) /* ML */
{
if (st_masterlock_waiters(&caml_master_lock) == 0) return Val_unit;
enter_blocking_section();
caml_enter_blocking_section();
st_thread_yield();
leave_blocking_section();
caml_leave_blocking_section();
return Val_unit;
}
@ -775,7 +775,7 @@ CAMLprim value caml_mutex_new(value unit) /* ML */
st_mutex mut = NULL; /* suppress warning */
value wrapper;
st_check_error(st_mutex_create(&mut), "Mutex.create");
wrapper = alloc_custom(&caml_mutex_ops, sizeof(st_mutex *),
wrapper = caml_alloc_custom(&caml_mutex_ops, sizeof(st_mutex *),
1, Max_mutex_number);
Mutex_val(wrapper) = mut;
return wrapper;
@ -790,9 +790,9 @@ CAMLprim value caml_mutex_lock(value wrapper) /* ML */
if (st_mutex_trylock(mut) == PREVIOUSLY_UNLOCKED) return Val_unit;
/* If unsuccessful, block on mutex */
Begin_root(wrapper) /* prevent the deallocation of mutex */
enter_blocking_section();
caml_enter_blocking_section();
retcode = st_mutex_lock(mut);
leave_blocking_section();
caml_leave_blocking_section();
End_roots();
st_check_error(retcode, "Mutex.lock");
return Val_unit;
@ -855,7 +855,7 @@ CAMLprim value caml_condition_new(value unit) /* ML */
st_condvar cond = NULL; /* suppress warning */
value wrapper;
st_check_error(st_condvar_create(&cond), "Condition.create");
wrapper = alloc_custom(&caml_condition_ops, sizeof(st_condvar *),
wrapper = caml_alloc_custom(&caml_condition_ops, sizeof(st_condvar *),
1, Max_condition_number);
Condition_val(wrapper) = cond;
return wrapper;
@ -868,9 +868,9 @@ CAMLprim value caml_condition_wait(value wcond, value wmut) /* ML */
st_retcode retcode;
Begin_roots2(wcond, wmut) /* prevent deallocation of cond and mutex */
enter_blocking_section();
caml_enter_blocking_section();
retcode = st_condvar_wait(cond, mut);
leave_blocking_section();
caml_leave_blocking_section();
End_roots();
st_check_error(retcode, "Condition.wait");
return Val_unit;
@ -922,7 +922,7 @@ static value caml_threadstatus_new (void)
st_event ts = NULL; /* suppress warning */
value wrapper;
st_check_error(st_event_create(&ts), "Thread.create");
wrapper = alloc_custom(&caml_threadstatus_ops, sizeof(st_event *),
wrapper = caml_alloc_custom(&caml_threadstatus_ops, sizeof(st_event *),
1, Max_threadstatus_number);
Threadstatus_val(wrapper) = ts;
return wrapper;
@ -939,9 +939,9 @@ static st_retcode caml_threadstatus_wait (value wrapper)
st_retcode retcode;
Begin_roots1(wrapper) /* prevent deallocation of ts */
enter_blocking_section();
caml_enter_blocking_section();
retcode = st_event_wait(ts);
leave_blocking_section();
caml_leave_blocking_section();
End_roots();
return retcode;
}

View File

@ -365,7 +365,7 @@ static void st_check_error(DWORD retcode, char * msg)
value str;
if (retcode == 0) return;
if (retcode == ERROR_NOT_ENOUGH_MEMORY) raise_out_of_memory();
if (retcode == ERROR_NOT_ENOUGH_MEMORY) caml_raise_out_of_memory();
if (! FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
retcode,
@ -377,11 +377,11 @@ static void st_check_error(DWORD retcode, char * msg)
}
msglen = strlen(msg);
errlen = strlen(err);
str = alloc_string(msglen + 2 + errlen);
str = caml_alloc_string(msglen + 2 + errlen);
memmove (&Byte(str, 0), msg, msglen);
memmove (&Byte(str, msglen), ": ", 2);
memmove (&Byte(str, msglen + 2), err, errlen);
raise_sys_error(str);
caml_raise_sys_error(str);
}
/* Variable used to stop the "tick" thread */
@ -412,12 +412,12 @@ static DWORD st_atfork(void (*fn)(void))
value caml_thread_sigmask(value cmd, value sigs) /* ML */
{
invalid_argument("Thread.sigmask not implemented");
caml_invalid_argument("Thread.sigmask not implemented");
return Val_int(0); /* not reached */
}
value caml_wait_signal(value sigs) /* ML */
{
invalid_argument("Thread.wait_signal not implemented");
caml_invalid_argument("Thread.wait_signal not implemented");
return Val_int(0); /* not reached */
}

View File

@ -128,7 +128,7 @@ static caml_thread_t curr_thread = NULL;
/* Identifier for next thread creation */
static value next_ident = Val_int(0);
#define Assign(dst,src) modify((value *)&(dst), (value)(src))
#define Assign(dst,src) caml_modify((value *)&(dst), (value)(src))
/* Scan the stacks of the other threads */
@ -144,7 +144,7 @@ static void thread_scan_roots(scanning_action action)
/* Don't scan curr_thread->sp, this has already been done.
Don't scan local roots either, for the same reason. */
for (th = start->next; th != start; th = th->next) {
do_local_roots(action, th->sp, th->stack_high, NULL);
caml_do_local_roots(action, th->sp, th->stack_high, NULL);
}
/* Hook */
if (prev_scan_roots_hook != NULL) (*prev_scan_roots_hook)(action);
@ -163,20 +163,20 @@ value thread_initialize(value unit) /* ML */
if (curr_thread != NULL) return Val_unit;
/* Create a descriptor for the current thread */
curr_thread =
(caml_thread_t) alloc_shr(sizeof(struct caml_thread_struct)
(caml_thread_t) caml_alloc_shr(sizeof(struct caml_thread_struct)
/ sizeof(value), 0);
curr_thread->ident = next_ident;
next_ident = Val_int(Int_val(next_ident) + 1);
curr_thread->next = curr_thread;
curr_thread->prev = curr_thread;
curr_thread->stack_low = stack_low;
curr_thread->stack_high = stack_high;
curr_thread->stack_threshold = stack_threshold;
curr_thread->sp = extern_sp;
curr_thread->trapsp = trapsp;
curr_thread->backtrace_pos = Val_int(backtrace_pos);
curr_thread->backtrace_buffer = backtrace_buffer;
caml_initialize (&curr_thread->backtrace_last_exn, backtrace_last_exn);
curr_thread->stack_low = caml_stack_low;
curr_thread->stack_high = caml_stack_high;
curr_thread->stack_threshold = caml_stack_threshold;
curr_thread->sp = caml_extern_sp;
curr_thread->trapsp = caml_trapsp;
curr_thread->backtrace_pos = Val_int(caml_backtrace_pos);
curr_thread->backtrace_buffer = caml_backtrace_buffer;
caml_initialize (&curr_thread->backtrace_last_exn, caml_backtrace_last_exn);
curr_thread->status = RUNNABLE;
curr_thread->fd = Val_int(0);
curr_thread->readfds = NO_FDS;
@ -187,8 +187,8 @@ value thread_initialize(value unit) /* ML */
curr_thread->waitpid = NO_WAITPID;
curr_thread->retval = Val_unit;
/* Initialize GC */
prev_scan_roots_hook = scan_roots_hook;
scan_roots_hook = thread_scan_roots;
prev_scan_roots_hook = caml_scan_roots_hook;
caml_scan_roots_hook = thread_scan_roots;
/* Set standard file descriptors to non-blocking mode */
stdin_initial_status = fcntl(0, F_GETFL);
stdout_initial_status = fcntl(1, F_GETFL);
@ -224,7 +224,7 @@ value thread_new(value clos) /* ML */
caml_thread_t th;
/* Allocate the thread and its stack */
Begin_root(clos);
th = (caml_thread_t) alloc_shr(sizeof(struct caml_thread_struct)
th = (caml_thread_t) caml_alloc_shr(sizeof(struct caml_thread_struct)
/ sizeof(value), 0);
End_roots();
th->ident = next_ident;
@ -303,17 +303,17 @@ static value schedule_thread(void)
int need_select, need_wait;
/* Don't allow preemption during a callback */
if (callback_depth > 1) return curr_thread->retval;
if (caml_callback_depth > 1) return curr_thread->retval;
/* Save the status of the current thread */
curr_thread->stack_low = stack_low;
curr_thread->stack_high = stack_high;
curr_thread->stack_threshold = stack_threshold;
curr_thread->sp = extern_sp;
curr_thread->trapsp = trapsp;
curr_thread->backtrace_pos = Val_int(backtrace_pos);
curr_thread->backtrace_buffer = backtrace_buffer;
caml_modify (&curr_thread->backtrace_last_exn, backtrace_last_exn);
curr_thread->stack_low = caml_stack_low;
curr_thread->stack_high = caml_stack_high;
curr_thread->stack_threshold = caml_stack_threshold;
curr_thread->sp = caml_extern_sp;
curr_thread->trapsp = caml_trapsp;
curr_thread->backtrace_pos = Val_int(caml_backtrace_pos);
curr_thread->backtrace_buffer = caml_backtrace_buffer;
caml_modify (&curr_thread->backtrace_last_exn, caml_backtrace_last_exn);
try_again:
/* Find if a thread is runnable.
@ -403,9 +403,9 @@ try_again:
else {
delay_ptr = NULL;
}
enter_blocking_section();
caml_enter_blocking_section();
retcode = select(FD_SETSIZE, &readfds, &writefds, &exceptfds, delay_ptr);
leave_blocking_section();
caml_leave_blocking_section();
if (retcode == -1)
switch (errno) {
case EINTR:
@ -430,7 +430,7 @@ try_again:
retcode = FD_SETSIZE;
break;
default:
sys_error(NO_ARG);
caml_sys_error(NO_ARG);
}
if (retcode > 0) {
/* Some descriptors are ready.
@ -462,7 +462,7 @@ try_again:
w = inter_fdlist_set(th->writefds, &writefds, &retcode);
e = inter_fdlist_set(th->exceptfds, &exceptfds, &retcode);
if (r != NO_FDS || w != NO_FDS || e != NO_FDS) {
value retval = alloc_small(3, TAG_RESUMED_SELECT);
value retval = caml_alloc_small(3, TAG_RESUMED_SELECT);
Field(retval, 0) = r;
Field(retval, 1) = w;
Field(retval, 2) = e;
@ -487,7 +487,7 @@ try_again:
}
/* If we haven't something to run at that point, we're in big trouble. */
if (run_thread == NULL) invalid_argument("Thread: deadlock");
if (run_thread == NULL) caml_invalid_argument("Thread: deadlock");
/* Free everything the thread was waiting on */
Assign(run_thread->readfds, NO_FDS);
@ -499,14 +499,14 @@ try_again:
/* Activate the thread */
curr_thread = run_thread;
stack_low = curr_thread->stack_low;
stack_high = curr_thread->stack_high;
stack_threshold = curr_thread->stack_threshold;
extern_sp = curr_thread->sp;
trapsp = curr_thread->trapsp;
backtrace_pos = Int_val(curr_thread->backtrace_pos);
backtrace_buffer = curr_thread->backtrace_buffer;
backtrace_last_exn = curr_thread->backtrace_last_exn;
caml_stack_low = curr_thread->stack_low;
caml_stack_high = curr_thread->stack_high;
caml_stack_threshold = curr_thread->stack_threshold;
caml_extern_sp = curr_thread->sp;
caml_trapsp = curr_thread->trapsp;
caml_backtrace_pos = Int_val(curr_thread->backtrace_pos);
caml_backtrace_buffer = curr_thread->backtrace_buffer;
caml_backtrace_last_exn = curr_thread->backtrace_last_exn;
return curr_thread->retval;
}
@ -515,7 +515,7 @@ try_again:
static void check_callback(void)
{
if (callback_depth > 1)
if (caml_callback_depth > 1)
caml_fatal_error("Thread: deadlock during callback");
}
@ -537,20 +537,20 @@ static void thread_reschedule(void)
Assert(curr_thread != NULL);
/* Pop accu from event frame, making it look like a C_CALL frame
followed by a RETURN frame */
accu = *extern_sp++;
accu = *caml_extern_sp++;
/* Reschedule */
Assign(curr_thread->retval, accu);
accu = schedule_thread();
/* Push accu below C_CALL frame so that it looks like an event frame */
*--extern_sp = accu;
*--caml_extern_sp = accu;
}
/* Request a re-scheduling as soon as possible */
value thread_request_reschedule(value unit) /* ML */
{
async_action_hook = thread_reschedule;
something_to_do = 1;
caml_async_action_hook = thread_reschedule;
caml_something_to_do = 1;
return Val_unit;
}
@ -574,7 +574,7 @@ static value thread_wait_rw(int kind, value fd)
if (curr_thread == NULL) return RESUMED_WAKEUP;
/* As a special case, if we're in a callback, don't fail but block
the whole process till I/O is possible */
if (callback_depth > 1) {
if (caml_callback_depth > 1) {
fd_set fds;
FD_ZERO(&fds);
FD_SET(Int_val(fd), &fds);
@ -609,7 +609,7 @@ static value thread_wait_timed_rw(int kind, value arg)
check_callback();
curr_thread->fd = Field(arg, 0);
date = timeofday() + Double_val(Field(arg, 1));
Assign(curr_thread->delay, copy_double(date));
Assign(curr_thread->delay, caml_copy_double(date));
curr_thread->status = kind | BLOCKED_DELAY;
return schedule_thread();
}
@ -636,7 +636,7 @@ value thread_select(value arg) /* ML */
date = Double_val(Field(arg, 3));
if (date >= 0.0) {
date += timeofday();
Assign(curr_thread->delay, copy_double(date));
Assign(curr_thread->delay, caml_copy_double(date));
curr_thread->status = BLOCKED_SELECT | BLOCKED_DELAY;
} else {
curr_thread->status = BLOCKED_SELECT;
@ -676,7 +676,7 @@ value thread_delay(value time) /* ML */
Assert(curr_thread != NULL);
check_callback();
curr_thread->status = BLOCKED_DELAY;
Assign(curr_thread->delay, copy_double(date));
Assign(curr_thread->delay, caml_copy_double(date));
return schedule_thread();
}
@ -714,9 +714,9 @@ value thread_wakeup(value thread) /* ML */
Assign(th->retval, RESUMED_WAKEUP);
break;
case KILLED:
failwith("Thread.wakeup: killed thread");
caml_failwith("Thread.wakeup: killed thread");
default:
failwith("Thread.wakeup: thread not suspended");
caml_failwith("Thread.wakeup: thread not suspended");
}
return Val_unit;
}
@ -735,9 +735,9 @@ value thread_kill(value thread) /* ML */
{
value retval = Val_unit;
caml_thread_t th = (caml_thread_t) thread;
if (th->status == KILLED) failwith("Thread.kill: killed thread");
if (th->status == KILLED) caml_failwith("Thread.kill: killed thread");
/* Don't paint ourselves in a corner */
if (th == th->next) failwith("Thread.kill: cannot kill the last thread");
if (th == th->next) caml_failwith("Thread.kill: cannot kill the last thread");
/* This thread is no longer waiting on anything */
th->status = KILLED;
/* If this is the current thread, activate another one */
@ -751,7 +751,7 @@ value thread_kill(value thread) /* ML */
Assign(th->prev->next, th->next);
Assign(th->next->prev, th->prev);
/* Free its resources */
stat_free((char *) th->stack_low);
caml_stat_free((char *) th->stack_low);
th->stack_low = NULL;
th->stack_high = NULL;
th->stack_threshold = NULL;
@ -768,11 +768,11 @@ value thread_kill(value thread) /* ML */
value thread_uncaught_exception(value exn) /* ML */
{
char * msg = format_caml_exception(exn);
char * msg = caml_format_exception(exn);
fprintf(stderr, "Thread %d killed on uncaught exception %s\n",
Int_val(curr_thread->ident), msg);
free(msg);
if (backtrace_active) print_exception_backtrace();
if (caml_backtrace_active) caml_print_exception_backtrace();
fflush(stderr);
return Val_unit;
}
@ -800,7 +800,7 @@ static value inter_fdlist_set(value fdl, fd_set *set, int *count)
for (res = NO_FDS; fdl != NO_FDS; fdl = Field(fdl, 1)) {
int fd = Int_val(Field(fdl, 0));
if (FD_ISSET(fd, set)) {
cons = alloc_small(2, 0);
cons = caml_alloc_small(2, 0);
Field(cons, 0) = Val_int(fd);
Field(cons, 1) = res;
res = cons;
@ -849,19 +849,19 @@ static value alloc_process_status(int pid, int status)
value st, res;
if (WIFEXITED(status)) {
st = alloc_small(1, TAG_WEXITED);
st = caml_alloc_small(1, TAG_WEXITED);
Field(st, 0) = Val_int(WEXITSTATUS(status));
}
else if (WIFSTOPPED(status)) {
st = alloc_small(1, TAG_WSTOPPED);
st = caml_alloc_small(1, TAG_WSTOPPED);
Field(st, 0) = Val_int(WSTOPSIG(status));
}
else {
st = alloc_small(1, TAG_WSIGNALED);
st = caml_alloc_small(1, TAG_WSIGNALED);
Field(st, 0) = Val_int(WTERMSIG(status));
}
Begin_root(st);
res = alloc_small(2, TAG_RESUMED_WAIT);
res = caml_alloc_small(2, TAG_RESUMED_WAIT);
Field(res, 0) = Val_int(pid);
Field(res, 1) = st;
End_roots();

View File

@ -33,13 +33,13 @@ CAMLprim value unix_accept(value sock)
socklen_param_type addr_len;
addr_len = sizeof(addr);
enter_blocking_section();
caml_enter_blocking_section();
retcode = accept(Int_val(sock), &addr.s_gen, &addr_len);
leave_blocking_section();
caml_leave_blocking_section();
if (retcode == -1) uerror("accept", Nothing);
a = alloc_sockaddr(&addr, addr_len, retcode);
Begin_root (a);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_int(retcode);
Field(res, 1) = a;
End_roots();

View File

@ -49,7 +49,7 @@ CAMLprim value unix_access(value path, value perms)
int ret, cv_flags;
caml_unix_check_path(path, "access");
cv_flags = convert_flag_list(perms, access_permission_table);
cv_flags = caml_convert_flag_list(perms, access_permission_table);
p = caml_strdup(String_val(path));
caml_enter_blocking_section();
ret = access(p, cv_flags);

View File

@ -24,7 +24,7 @@
CAMLprim value unix_inet_addr_of_string(value s)
{
if (! caml_string_is_c_safe(s)) failwith("inet_addr_of_string");
if (! caml_string_is_c_safe(s)) caml_failwith("inet_addr_of_string");
#if defined(HAS_IPV6)
#ifdef _WIN32
{
@ -37,7 +37,7 @@ CAMLprim value unix_inet_addr_of_string(value s)
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_NUMERICHOST;
retcode = getaddrinfo(String_val(s), NULL, &hints, &res);
if (retcode != 0) failwith("inet_addr_of_string");
if (retcode != 0) caml_failwith("inet_addr_of_string");
switch (res->ai_addr->sa_family) {
case AF_INET:
{
@ -54,7 +54,7 @@ CAMLprim value unix_inet_addr_of_string(value s)
default:
{
freeaddrinfo(res);
failwith("inet_addr_of_string");
caml_failwith("inet_addr_of_string");
}
}
freeaddrinfo(res);
@ -69,21 +69,21 @@ CAMLprim value unix_inet_addr_of_string(value s)
else if (inet_pton(AF_INET6, String_val(s), &address6) > 0)
return alloc_inet6_addr(&address6);
else
failwith("inet_addr_of_string");
caml_failwith("inet_addr_of_string");
}
#endif
#elif defined(HAS_INET_ATON)
{
struct in_addr address;
if (inet_aton(String_val(s), &address) == 0)
failwith("inet_addr_of_string");
caml_failwith("inet_addr_of_string");
return alloc_inet_addr(&address);
}
#else
{
struct in_addr address;
address.s_addr = inet_addr(String_val(s));
if (address.s_addr == (uint32_t) -1) failwith("inet_addr_of_string");
if (address.s_addr == (uint32_t) -1) caml_failwith("inet_addr_of_string");
return alloc_inet_addr(&address);
}
#endif

View File

@ -29,9 +29,9 @@ CAMLprim value unix_connect(value socket, value address)
socklen_param_type addr_len;
get_sockaddr(address, &addr, &addr_len);
enter_blocking_section();
caml_enter_blocking_section();
retcode = connect(Int_val(socket), &addr.s_gen, addr_len);
leave_blocking_section();
caml_leave_blocking_section();
if (retcode == -1) uerror("connect", Nothing);
return Val_unit;
}

View File

@ -23,7 +23,7 @@ extern char ** environ;
CAMLprim value unix_environment(value unit)
{
if (environ != NULL) {
return copy_string_array((const char**)environ);
return caml_copy_string_array((const char**)environ);
} else {
return Atom(0);
}

View File

@ -24,5 +24,5 @@ CAMLprim value unix_error_message(value err)
{
int errnum;
errnum = Is_block(err) ? Int_val(Field(err, 0)) : error_table[Int_val(err)];
return copy_string(strerror(errnum));
return caml_copy_string(strerror(errnum));
}

View File

@ -23,7 +23,7 @@ CAMLprim value unix_execv(value path, value args)
caml_unix_check_path(path, "execv");
argv = cstringvect(args, "execv");
(void) execv(String_val(path), argv);
stat_free((char *) argv);
caml_stat_free((char *) argv);
uerror("execv", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */

View File

@ -25,8 +25,8 @@ CAMLprim value unix_execve(value path, value args, value env)
argv = cstringvect(args, "execve");
envp = cstringvect(env, "execve");
(void) execve(String_val(path), argv, envp);
stat_free((char *) argv);
stat_free((char *) envp);
caml_stat_free((char *) argv);
caml_stat_free((char *) envp);
uerror("execve", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */

View File

@ -27,7 +27,7 @@ CAMLprim value unix_execvp(value path, value args)
caml_unix_check_path(path, "execvp");
argv = cstringvect(args, "execvp");
(void) execvp(String_val(path), argv);
stat_free((char *) argv);
caml_stat_free((char *) argv);
uerror("execvp", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */
@ -42,8 +42,8 @@ CAMLprim value unix_execvpe(value path, value args, value env)
saved_environ = environ;
environ = cstringvect(env, "execvpe");
(void) execvp(String_val(path), argv);
stat_free((char *) argv);
stat_free((char *) environ);
caml_stat_free((char *) argv);
caml_stat_free((char *) environ);
environ = saved_environ;
uerror("execvp", path);
return Val_unit; /* never reached, but suppress warnings */

View File

@ -45,8 +45,8 @@ static value convert_addrinfo(struct addrinfo * a)
if (len > sizeof(sa)) len = sizeof(sa);
memcpy(&sa.s_gen, a->ai_addr, len);
vaddr = alloc_sockaddr(&sa, len, -1);
vcanonname = copy_string(a->ai_canonname == NULL ? "" : a->ai_canonname);
vres = alloc_small(5, 0);
vcanonname = caml_copy_string(a->ai_canonname == NULL ? "" : a->ai_canonname);
vres = caml_alloc_small(5, 0);
Field(vres, 0) = cst_to_constr(a->ai_family, socket_domain_table, 3, 0);
Field(vres, 1) = cst_to_constr(a->ai_socktype, socket_type_table, 4, 0);
Field(vres, 2) = Val_int(a->ai_protocol);
@ -107,17 +107,17 @@ CAMLprim value unix_getaddrinfo(value vnode, value vserv, value vopts)
}
}
/* Do the call */
enter_blocking_section();
caml_enter_blocking_section();
retcode = getaddrinfo(node, serv, &hints, &res);
leave_blocking_section();
if (node != NULL) stat_free(node);
if (serv != NULL) stat_free(serv);
caml_leave_blocking_section();
if (node != NULL) caml_stat_free(node);
if (serv != NULL) caml_stat_free(serv);
/* Convert result */
vres = Val_int(0);
if (retcode == 0) {
for (r = res; r != NULL; r = r->ai_next) {
e = convert_addrinfo(r);
v = alloc_small(2, 0);
v = caml_alloc_small(2, 0);
Field(v, 0) = e;
Field(v, 1) = vres;
vres = v;

View File

@ -36,7 +36,7 @@ CAMLprim value unix_getcwd(value unit)
{
char buff[PATH_MAX];
if (getcwd(buff, sizeof(buff)) == 0) uerror("getcwd", Nothing);
return copy_string(buff);
return caml_copy_string(buff);
}
#else

View File

@ -27,10 +27,10 @@ static value alloc_group_entry(struct group *entry)
value name = Val_unit, pass = Val_unit, mem = Val_unit;
Begin_roots3 (name, pass, mem);
name = copy_string(entry->gr_name);
pass = copy_string(entry->gr_passwd);
mem = copy_string_array((const char**)entry->gr_mem);
res = alloc_small(4, 0);
name = caml_copy_string(entry->gr_name);
pass = caml_copy_string(entry->gr_passwd);
mem = caml_copy_string_array((const char**)entry->gr_mem);
res = caml_alloc_small(4, 0);
Field(res,0) = name;
Field(res,1) = pass;
Field(res,2) = Val_int(entry->gr_gid);
@ -42,9 +42,9 @@ static value alloc_group_entry(struct group *entry)
CAMLprim value unix_getgrnam(value name)
{
struct group * entry;
if (! caml_string_is_c_safe(name)) raise_not_found();
if (! caml_string_is_c_safe(name)) caml_raise_not_found();
entry = getgrnam(String_val(name));
if (entry == NULL) raise_not_found();
if (entry == NULL) caml_raise_not_found();
return alloc_group_entry(entry);
}
@ -52,6 +52,6 @@ CAMLprim value unix_getgrgid(value gid)
{
struct group * entry;
entry = getgrgid(Int_val(gid));
if (entry == NULL) raise_not_found();
if (entry == NULL) caml_raise_not_found();
return alloc_group_entry(entry);
}

View File

@ -35,7 +35,7 @@ CAMLprim value unix_getgroups(value unit)
n = getgroups(NGROUPS_MAX, gidset);
if (n == -1) uerror("getgroups", Nothing);
res = alloc_tuple(n);
res = caml_alloc_tuple(n);
for (i = 0; i < n; i++)
Field(res, i) = Val_int(gidset[i]);
return res;

View File

@ -61,22 +61,22 @@ static value alloc_host_entry(struct hostent *entry)
value addr_list = Val_unit, adr = Val_unit;
Begin_roots4 (name, aliases, addr_list, adr);
name = copy_string((char *)(entry->h_name));
name = caml_copy_string((char *)(entry->h_name));
/* PR#4043: protect against buggy implementations of gethostbyname()
that return a NULL pointer in h_aliases */
if (entry->h_aliases)
aliases = copy_string_array((const char**)entry->h_aliases);
aliases = caml_copy_string_array((const char**)entry->h_aliases);
else
aliases = Atom(0);
entry_h_length = entry->h_length;
#ifdef h_addr
addr_list = alloc_array(alloc_one_addr, (const char**)entry->h_addr_list);
addr_list = caml_alloc_array(alloc_one_addr, (const char**)entry->h_addr_list);
#else
adr = alloc_one_addr(entry->h_addr);
addr_list = alloc_small(1, 0);
addr_list = caml_alloc_small(1, 0);
Field(addr_list, 0) = adr;
#endif
res = alloc_small(4, 0);
res = caml_alloc_small(4, 0);
Field(res, 0) = name;
Field(res, 1) = aliases;
switch (entry->h_addrtype) {
@ -97,29 +97,29 @@ CAMLprim value unix_gethostbyaddr(value a)
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errnop;
enter_blocking_section();
caml_enter_blocking_section();
hp = gethostbyaddr_r((char *) &adr, 4, AF_INET,
&h, buffer, sizeof(buffer), &h_errnop);
leave_blocking_section();
caml_leave_blocking_section();
#elif HAS_GETHOSTBYADDR_R == 8
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errnop, rc;
enter_blocking_section();
caml_enter_blocking_section();
rc = gethostbyaddr_r((char *) &adr, 4, AF_INET,
&h, buffer, sizeof(buffer), &hp, &h_errnop);
leave_blocking_section();
caml_leave_blocking_section();
if (rc != 0) hp = NULL;
#else
#ifdef GETHOSTBYADDR_IS_REENTRANT
enter_blocking_section();
caml_enter_blocking_section();
#endif
hp = gethostbyaddr((char *) &adr, 4, AF_INET);
#ifdef GETHOSTBYADDR_IS_REENTRANT
leave_blocking_section();
caml_leave_blocking_section();
#endif
#endif
if (hp == (struct hostent *) NULL) raise_not_found();
if (hp == (struct hostent *) NULL) caml_raise_not_found();
return alloc_host_entry(hp);
}
@ -133,7 +133,7 @@ CAMLprim value unix_gethostbyname(value name)
int err;
#endif
if (! caml_string_is_c_safe(name)) raise_not_found();
if (! caml_string_is_c_safe(name)) caml_raise_not_found();
#if HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT
hostname = caml_strdup(String_val(name));
@ -143,33 +143,33 @@ CAMLprim value unix_gethostbyname(value name)
#if HAS_GETHOSTBYNAME_R == 5
{
enter_blocking_section();
caml_enter_blocking_section();
hp = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &err);
leave_blocking_section();
caml_leave_blocking_section();
}
#elif HAS_GETHOSTBYNAME_R == 6
{
int rc;
enter_blocking_section();
caml_enter_blocking_section();
rc = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &hp, &err);
leave_blocking_section();
caml_leave_blocking_section();
if (rc != 0) hp = NULL;
}
#else
#ifdef GETHOSTBYNAME_IS_REENTRANT
enter_blocking_section();
caml_enter_blocking_section();
#endif
hp = gethostbyname(hostname);
#ifdef GETHOSTBYNAME_IS_REENTRANT
leave_blocking_section();
caml_leave_blocking_section();
#endif
#endif
#if HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT
stat_free(hostname);
caml_stat_free(hostname);
#endif
if (hp == (struct hostent *) NULL) raise_not_found();
if (hp == (struct hostent *) NULL) caml_raise_not_found();
return alloc_host_entry(hp);
}

View File

@ -32,7 +32,7 @@ CAMLprim value unix_gethostname(value unit)
char name[MAXHOSTNAMELEN];
gethostname(name, MAXHOSTNAMELEN);
name[MAXHOSTNAMELEN-1] = 0;
return copy_string(name);
return caml_copy_string(name);
}
#else

View File

@ -25,5 +25,5 @@ CAMLprim value unix_getlogin(value unit)
char * name;
name = getlogin();
if (name == NULL) unix_error(ENOENT, "getlogin", Nothing);
return copy_string(name);
return caml_copy_string(name);
}

View File

@ -44,16 +44,16 @@ CAMLprim value unix_getnameinfo(value vaddr, value vopts)
int opts, retcode;
get_sockaddr(vaddr, &addr, &addr_len);
opts = convert_flag_list(vopts, getnameinfo_flag_table);
enter_blocking_section();
opts = caml_convert_flag_list(vopts, getnameinfo_flag_table);
caml_enter_blocking_section();
retcode =
getnameinfo((const struct sockaddr *) &addr.s_gen, addr_len,
host, sizeof(host), serv, sizeof(serv), opts);
leave_blocking_section();
if (retcode != 0) raise_not_found(); /* TODO: detailed error reporting? */
vhost = copy_string(host);
vserv = copy_string(serv);
vres = alloc_small(2, 0);
caml_leave_blocking_section();
if (retcode != 0) caml_raise_not_found(); /* TODO: detailed error reporting? */
vhost = caml_copy_string(host);
vserv = caml_copy_string(serv);
vres = caml_alloc_small(2, 0);
Field(vres, 0) = vhost;
Field(vres, 1) = vserv;
CAMLreturn(vres);

View File

@ -31,9 +31,9 @@ static value alloc_proto_entry(struct protoent *entry)
value name = Val_unit, aliases = Val_unit;
Begin_roots2 (name, aliases);
name = copy_string(entry->p_name);
aliases = copy_string_array((const char**)entry->p_aliases);
res = alloc_small(3, 0);
name = caml_copy_string(entry->p_name);
aliases = caml_copy_string_array((const char**)entry->p_aliases);
res = caml_alloc_small(3, 0);
Field(res,0) = name;
Field(res,1) = aliases;
Field(res,2) = Val_int(entry->p_proto);
@ -44,9 +44,9 @@ static value alloc_proto_entry(struct protoent *entry)
CAMLprim value unix_getprotobyname(value name)
{
struct protoent * entry;
if (! caml_string_is_c_safe(name)) raise_not_found();
if (! caml_string_is_c_safe(name)) caml_raise_not_found();
entry = getprotobyname(String_val(name));
if (entry == (struct protoent *) NULL) raise_not_found();
if (entry == (struct protoent *) NULL) caml_raise_not_found();
return alloc_proto_entry(entry);
}
@ -54,7 +54,7 @@ CAMLprim value unix_getprotobynumber(value proto)
{
struct protoent * entry;
entry = getprotobynumber(Int_val(proto));
if (entry == (struct protoent *) NULL) raise_not_found();
if (entry == (struct protoent *) NULL) caml_raise_not_found();
return alloc_proto_entry(entry);
}

View File

@ -27,16 +27,16 @@ static value alloc_passwd_entry(struct passwd *entry)
value dir = Val_unit, shell = Val_unit;
Begin_roots5 (name, passwd, gecos, dir, shell);
name = copy_string(entry->pw_name);
passwd = copy_string(entry->pw_passwd);
name = caml_copy_string(entry->pw_name);
passwd = caml_copy_string(entry->pw_passwd);
#if !defined(__BEOS__) && !defined(__ANDROID__)
gecos = copy_string(entry->pw_gecos);
gecos = caml_copy_string(entry->pw_gecos);
#else
gecos = copy_string("");
gecos = caml_copy_string("");
#endif
dir = copy_string(entry->pw_dir);
shell = copy_string(entry->pw_shell);
res = alloc_small(7, 0);
dir = caml_copy_string(entry->pw_dir);
shell = caml_copy_string(entry->pw_shell);
res = caml_alloc_small(7, 0);
Field(res,0) = name;
Field(res,1) = passwd;
Field(res,2) = Val_int(entry->pw_uid);
@ -51,9 +51,9 @@ static value alloc_passwd_entry(struct passwd *entry)
CAMLprim value unix_getpwnam(value name)
{
struct passwd * entry;
if (! caml_string_is_c_safe(name)) raise_not_found();
if (! caml_string_is_c_safe(name)) caml_raise_not_found();
entry = getpwnam(String_val(name));
if (entry == (struct passwd *) NULL) raise_not_found();
if (entry == (struct passwd *) NULL) caml_raise_not_found();
return alloc_passwd_entry(entry);
}
@ -61,6 +61,6 @@ CAMLprim value unix_getpwuid(value uid)
{
struct passwd * entry;
entry = getpwuid(Int_val(uid));
if (entry == (struct passwd *) NULL) raise_not_found();
if (entry == (struct passwd *) NULL) caml_raise_not_found();
return alloc_passwd_entry(entry);
}

View File

@ -35,10 +35,10 @@ static value alloc_service_entry(struct servent *entry)
value name = Val_unit, aliases = Val_unit, proto = Val_unit;
Begin_roots3 (name, aliases, proto);
name = copy_string(entry->s_name);
aliases = copy_string_array((const char**)entry->s_aliases);
proto = copy_string(entry->s_proto);
res = alloc_small(4, 0);
name = caml_copy_string(entry->s_name);
aliases = caml_copy_string_array((const char**)entry->s_aliases);
proto = caml_copy_string(entry->s_proto);
res = caml_alloc_small(4, 0);
Field(res,0) = name;
Field(res,1) = aliases;
Field(res,2) = Val_int(ntohs(entry->s_port));
@ -51,18 +51,18 @@ CAMLprim value unix_getservbyname(value name, value proto)
{
struct servent * entry;
if (! (caml_string_is_c_safe(name) && caml_string_is_c_safe(proto)))
raise_not_found();
caml_raise_not_found();
entry = getservbyname(String_val(name), String_val(proto));
if (entry == (struct servent *) NULL) raise_not_found();
if (entry == (struct servent *) NULL) caml_raise_not_found();
return alloc_service_entry(entry);
}
CAMLprim value unix_getservbyport(value port, value proto)
{
struct servent * entry;
if (! caml_string_is_c_safe(proto)) raise_not_found();
if (! caml_string_is_c_safe(proto)) caml_raise_not_found();
entry = getservbyport(htons(Int_val(port)), String_val(proto));
if (entry == (struct servent *) NULL) raise_not_found();
if (entry == (struct servent *) NULL) caml_raise_not_found();
return alloc_service_entry(entry);
}

View File

@ -27,7 +27,7 @@ CAMLprim value unix_gettimeofday(value unit)
{
struct timeval tp;
if (gettimeofday(&tp, NULL) == -1) uerror("gettimeofday", Nothing);
return copy_double((double) tp.tv_sec + (double) tp.tv_usec / 1e6);
return caml_copy_double((double) tp.tv_sec + (double) tp.tv_usec / 1e6);
}
#else

View File

@ -24,7 +24,7 @@
static value alloc_tm(struct tm *tm)
{
value res;
res = alloc_small(9, 0);
res = caml_alloc_small(9, 0);
Field(res,0) = Val_int(tm->tm_sec);
Field(res,1) = Val_int(tm->tm_min);
Field(res,2) = Val_int(tm->tm_hour);
@ -79,8 +79,8 @@ CAMLprim value unix_mktime(value t)
clock = mktime(&tm);
if (clock == (time_t) -1) unix_error(ERANGE, "mktime", Nothing);
tmval = alloc_tm(&tm);
clkval = copy_double((double) clock);
res = alloc_small(2, 0);
clkval = caml_copy_double((double) clock);
res = caml_alloc_small(2, 0);
Field(res, 0) = clkval;
Field(res, 1) = tmval;
End_roots ();

View File

@ -38,7 +38,7 @@ static void unix_set_timeval(struct timeval * tv, double d)
static value unix_convert_itimer(struct itimerval *tp)
{
#define Get_timeval(tv) (double) tv.tv_sec + (double) tv.tv_usec / 1e6
value res = alloc_small(Double_wosize * 2, Double_array_tag);
value res = caml_alloc_small(Double_wosize * 2, Double_array_tag);
Store_double_field(res, 0, Get_timeval(tp->it_interval));
Store_double_field(res, 1, Get_timeval(tp->it_value));
return res;

View File

@ -24,7 +24,7 @@
CAMLprim value unix_kill(value pid, value signal)
{
int sig;
sig = convert_signal_number(Int_val(signal));
sig = caml_convert_signal_number(Int_val(signal));
if (kill(Int_val(pid), sig) == -1)
uerror("kill", Nothing);
return Val_unit;

View File

@ -46,9 +46,9 @@ CAMLprim value unix_lockf(value fd, value cmd, value span)
break;
case 1: /* F_LOCK */
l.l_type = F_WRLCK;
enter_blocking_section();
caml_enter_blocking_section();
ret = fcntl(fildes, F_SETLKW, &l);
leave_blocking_section();
caml_leave_blocking_section();
break;
case 2: /* F_TLOCK */
l.l_type = F_WRLCK;
@ -68,9 +68,9 @@ CAMLprim value unix_lockf(value fd, value cmd, value span)
break;
case 4: /* F_RLOCK */
l.l_type = F_RDLCK;
enter_blocking_section();
caml_enter_blocking_section();
ret = fcntl(fildes, F_SETLKW, &l);
leave_blocking_section();
caml_leave_blocking_section();
break;
case 5: /* F_TRLOCK */
l.l_type = F_RDLCK;

View File

@ -65,16 +65,16 @@ CAMLprim value unix_open(value path, value flags, value perm)
char * p;
caml_unix_check_path(path, "open");
cv_flags = convert_flag_list(flags, open_flag_table);
cv_flags = caml_convert_flag_list(flags, open_flag_table);
p = caml_strdup(String_val(path));
/* open on a named FIFO can block (PR#1533) */
enter_blocking_section();
caml_enter_blocking_section();
fd = open(p, cv_flags, Int_val(perm));
leave_blocking_section();
stat_free(p);
caml_leave_blocking_section();
caml_stat_free(p);
if (fd == -1) uerror("open", path);
#if defined(NEED_CLOEXEC_EMULATION) && defined(FD_CLOEXEC)
if (convert_flag_list(flags, open_cloexec_table) != 0) {
if (caml_convert_flag_list(flags, open_cloexec_table) != 0) {
int flags = fcntl(fd, F_GETFD, 0);
if (flags == -1 ||
fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)

View File

@ -39,7 +39,7 @@ CAMLprim value unix_opendir(value path)
caml_leave_blocking_section();
caml_stat_free(p);
if (d == (DIR *) NULL) uerror("opendir", path);
res = alloc_small(1, Abstract_tag);
res = caml_alloc_small(1, Abstract_tag);
DIR_Val(res) = d;
CAMLreturn(res);
}

View File

@ -22,7 +22,7 @@ CAMLprim value unix_pipe(value unit)
int fd[2];
value res;
if (pipe(fd) == -1) uerror("pipe", Nothing);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_int(fd[0]);
Field(res, 1) = Val_int(fd[1]);
return res;

View File

@ -27,8 +27,8 @@
CAMLprim value unix_putenv(value name, value val)
{
mlsize_t namelen = string_length(name);
mlsize_t vallen = string_length(val);
mlsize_t namelen = caml_string_length(name);
mlsize_t vallen = caml_string_length(val);
char * s;
if (! (caml_string_is_c_safe(name) && caml_string_is_c_safe(val)))

View File

@ -28,9 +28,9 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value len)
Begin_root (buf);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
enter_blocking_section();
caml_enter_blocking_section();
ret = read(Int_val(fd), iobuf, (int) numbytes);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("read", Nothing);
memmove (&Byte(buf, Long_val(ofs)), iobuf, ret);
End_roots();

View File

@ -37,6 +37,6 @@ CAMLprim value unix_readdir(value vd)
caml_enter_blocking_section();
e = readdir((DIR *) d);
caml_leave_blocking_section();
if (e == (directory_entry *) NULL) raise_end_of_file();
return copy_string(e->d_name);
if (e == (directory_entry *) NULL) caml_raise_end_of_file();
return caml_copy_string(e->d_name);
}

View File

@ -46,12 +46,12 @@ CAMLprim value unix_readlink(value path)
caml_stat_free(p);
if (len == -1) uerror("readlink", path);
buffer[len] = '\0';
CAMLreturn(copy_string(buffer));
CAMLreturn(caml_copy_string(buffer));
}
#else
CAMLprim value unix_readlink(value path)
{ invalid_argument("readlink not implemented"); }
{ caml_invalid_argument("readlink not implemented"); }
#endif

View File

@ -54,7 +54,7 @@ static value fdset_to_fdlist(value fdlist, fd_set *fdset)
for (l = fdlist; l != Val_int(0); l = Field(l, 1)) {
int fd = Int_val(Field(l, 0));
if (FD_ISSET(fd, fdset)) {
value newres = alloc_small(2, 0);
value newres = caml_alloc_small(2, 0);
Field(newres, 0) = Val_int(fd);
Field(newres, 1) = res;
res = newres;
@ -90,14 +90,14 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
tv.tv_usec = (int) (1e6 * (tm - tv.tv_sec));
tvp = &tv;
}
enter_blocking_section();
caml_enter_blocking_section();
retcode = select(maxfd + 1, &read, &write, &except, tvp);
leave_blocking_section();
caml_leave_blocking_section();
if (retcode == -1) uerror("select", Nothing);
readfds = fdset_to_fdlist(readfds, &read);
writefds = fdset_to_fdlist(writefds, &write);
exceptfds = fdset_to_fdlist(exceptfds, &except);
res = alloc_small(3, 0);
res = caml_alloc_small(3, 0);
Field(res, 0) = readfds;
Field(res, 1) = writefds;
Field(res, 2) = exceptfds;

View File

@ -35,13 +35,13 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len,
long numbytes;
char iobuf[UNIX_BUFFER_SIZE];
cv_flags = convert_flag_list(flags, msg_flag_table);
cv_flags = caml_convert_flag_list(flags, msg_flag_table);
Begin_root (buff);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
enter_blocking_section();
caml_enter_blocking_section();
ret = recv(Int_val(sock), iobuf, (int) numbytes, cv_flags);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("recv", Nothing);
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
End_roots();
@ -59,19 +59,19 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len,
union sock_addr_union addr;
socklen_param_type addr_len;
cv_flags = convert_flag_list(flags, msg_flag_table);
cv_flags = caml_convert_flag_list(flags, msg_flag_table);
Begin_roots2 (buff, adr);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
addr_len = sizeof(addr);
enter_blocking_section();
caml_enter_blocking_section();
ret = recvfrom(Int_val(sock), iobuf, (int) numbytes, cv_flags,
&addr.s_gen, &addr_len);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("recvfrom", Nothing);
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
adr = alloc_sockaddr(&addr, addr_len, -1);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_int(ret);
Field(res, 1) = adr;
End_roots();
@ -85,13 +85,13 @@ CAMLprim value unix_send(value sock, value buff, value ofs, value len,
long numbytes;
char iobuf[UNIX_BUFFER_SIZE];
cv_flags = convert_flag_list(flags, msg_flag_table);
cv_flags = caml_convert_flag_list(flags, msg_flag_table);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
enter_blocking_section();
caml_enter_blocking_section();
ret = send(Int_val(sock), iobuf, (int) numbytes, cv_flags);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("send", Nothing);
return Val_int(ret);
}
@ -105,15 +105,15 @@ CAMLprim value unix_sendto_native(value sock, value buff, value ofs, value len,
union sock_addr_union addr;
socklen_param_type addr_len;
cv_flags = convert_flag_list(flags, msg_flag_table);
cv_flags = caml_convert_flag_list(flags, msg_flag_table);
get_sockaddr(dest, &addr, &addr_len);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
enter_blocking_section();
caml_enter_blocking_section();
ret = sendto(Int_val(sock), iobuf, (int) numbytes, cv_flags,
&addr.s_gen, addr_len);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("sendto", Nothing);
return Val_int(ret);
}

View File

@ -40,7 +40,7 @@ CAMLprim value unix_setgroups(value groups)
n = setgroups(size, gidset);
stat_free(gidset);
caml_stat_free(gidset);
if (n == -1) uerror("setgroups", Nothing);
return Val_unit;
}

View File

@ -49,7 +49,7 @@ static value encode_sigset(sigset_t * set)
Begin_root(res)
for (i = 1; i < NSIG; i++)
if (sigismember(set, i) > 0) {
value newcons = alloc_small(2, 0);
value newcons = caml_alloc_small(2, 0);
Field(newcons, 0) = Val_int(caml_rev_convert_signal_number(i));
Field(newcons, 1) = res;
res = newcons;
@ -68,9 +68,9 @@ CAMLprim value unix_sigprocmask(value vaction, value vset)
how = sigprocmask_cmd[Int_val(vaction)];
decode_sigset(vset, &set);
enter_blocking_section();
caml_enter_blocking_section();
retcode = sigprocmask(how, &set, &oldset);
leave_blocking_section();
caml_leave_blocking_section();
if (retcode == -1) uerror("sigprocmask", Nothing);
return encode_sigset(&oldset);
}
@ -87,9 +87,9 @@ CAMLprim value unix_sigsuspend(value vset)
sigset_t set;
int retcode;
decode_sigset(vset, &set);
enter_blocking_section();
caml_enter_blocking_section();
retcode = sigsuspend(&set);
leave_blocking_section();
caml_leave_blocking_section();
if (retcode == -1 && errno != EINTR) uerror("sigsuspend", Nothing);
return Val_unit;
}

View File

@ -35,26 +35,26 @@ CAMLprim value unix_sleep(value duration)
{
struct timespec t;
int ret;
enter_blocking_section();
caml_enter_blocking_section();
t.tv_sec = (time_t) d;
t.tv_nsec = (d - t.tv_sec) * 1e9;
do {
ret = nanosleep(&t, &t);
} while (ret == -1 && errno == EINTR);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("sleep", Nothing);
}
#elif defined(HAS_SELECT)
{
struct timeval t;
int ret;
enter_blocking_section();
caml_enter_blocking_section();
t.tv_sec = (time_t) d;
t.tv_usec = (d - t.tv_sec) * 1e6;
do {
ret = select(0, NULL, NULL, NULL, &t);
} while (ret == -1 && errno == EINTR);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("sleep", Nothing);
}
#else
@ -62,9 +62,9 @@ CAMLprim value unix_sleep(value duration)
We cannot reliably iterate until sleep() returns 0, because the
remaining time returned by sleep() is generally rounded up. */
{
enter_blocking_section();
caml_enter_blocking_section();
sleep ((unsigned int) d);
leave_blocking_section();
caml_leave_blocking_section();
}
#endif
return Val_unit;

View File

@ -35,7 +35,7 @@ CAMLexport value alloc_inet_addr(struct in_addr * a)
/* Use a string rather than an abstract block so that it can be
marshaled safely. Remember that a is in network byte order,
hence is marshaled in an endian-independent manner. */
res = alloc_string(4);
res = caml_alloc_string(4);
memcpy(String_val(res), a, 4);
return res;
}
@ -45,7 +45,7 @@ CAMLexport value alloc_inet_addr(struct in_addr * a)
CAMLexport value alloc_inet6_addr(struct in6_addr * a)
{
value res;
res = alloc_string(16);
res = caml_alloc_string(16);
memcpy(String_val(res), a, 16);
return res;
}
@ -62,7 +62,7 @@ void get_sockaddr(value mladr,
{ value path;
mlsize_t len;
path = Field(mladr, 0);
len = string_length(path);
len = caml_string_length(path);
adr->s_unix.sun_family = AF_UNIX;
if (len >= sizeof(adr->s_unix.sun_path)) {
unix_error(ENAMETOOLONG, "", path);
@ -80,7 +80,7 @@ void get_sockaddr(value mladr,
#endif
case 1: /* ADDR_INET */
#ifdef HAS_IPV6
if (string_length(Field(mladr, 0)) == 16) {
if (caml_string_length(Field(mladr, 0)) == 16) {
memset(&adr->s_inet6, 0, sizeof(struct sockaddr_in6));
adr->s_inet6.sin6_family = AF_INET6;
adr->s_inet6.sin6_addr = GET_INET6_ADDR(Field(mladr, 0));
@ -118,9 +118,9 @@ value alloc_sockaddr(union sock_addr_union * adr /*in*/,
path = adr->s_unix.sun_path;
else
path = "";
n = copy_string(path);
n = caml_copy_string(path);
Begin_root (n);
res = alloc_small(1, 0);
res = caml_alloc_small(1, 0);
Field(res,0) = n;
End_roots();
break;
@ -129,7 +129,7 @@ value alloc_sockaddr(union sock_addr_union * adr /*in*/,
case AF_INET:
{ value a = alloc_inet_addr(&adr->s_inet.sin_addr);
Begin_root (a);
res = alloc_small(2, 1);
res = caml_alloc_small(2, 1);
Field(res,0) = a;
Field(res,1) = Val_int(ntohs(adr->s_inet.sin_port));
End_roots();
@ -139,7 +139,7 @@ value alloc_sockaddr(union sock_addr_union * adr /*in*/,
case AF_INET6:
{ value a = alloc_inet6_addr(&adr->s_inet6.sin6_addr);
Begin_root (a);
res = alloc_small(2, 1);
res = caml_alloc_small(2, 1);
Field(res,0) = a;
Field(res,1) = Val_int(ntohs(adr->s_inet6.sin6_port));
End_roots();

View File

@ -32,7 +32,7 @@ CAMLprim value unix_socketpair(value domain, value type, value proto)
socket_type_table[Int_val(type)],
Int_val(proto), sv) == -1)
uerror("socketpair", Nothing);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res,0) = Val_int(sv[0]);
Field(res,1) = Val_int(sv[1]);
return res;

View File

@ -203,12 +203,12 @@ unix_getsockopt_aux(char * name,
if (optval.lg.l_onoff == 0) {
return Val_int(0); /* None */
} else {
value res = alloc_small(1, 0); /* Some */
value res = caml_alloc_small(1, 0); /* Some */
Field(res, 0) = Val_int(optval.lg.l_linger);
return res;
}
case TYPE_TIMEVAL:
return copy_double((double) optval.tv.tv_sec
return caml_copy_double((double) optval.tv.tv_sec
+ (double) optval.tv.tv_usec / 1e6);
case TYPE_UNIX_ERROR:
if (optval.i == 0) {
@ -217,7 +217,7 @@ unix_getsockopt_aux(char * name,
value err, res;
err = unix_error_of_code(optval.i);
Begin_root(err);
res = alloc_small(1, 0); /* Some */
res = caml_alloc_small(1, 0); /* Some */
Field(res, 0) = err;
End_roots();
return res;

View File

@ -61,7 +61,7 @@ static value stat_aux(int use_64, struct stat *buf)
+ (NSEC(buf, c) / 1000000000.0));
#undef NSEC
offset = use_64 ? Val_file_offset(buf->st_size) : Val_int (buf->st_size);
v = alloc_small(12, 0);
v = caml_alloc_small(12, 0);
Field (v, 0) = Val_int (buf->st_dev);
Field (v, 1) = Val_int (buf->st_ino);
Field (v, 2) = cst_to_constr(buf->st_mode & S_IFMT, file_kind_table,

View File

@ -31,7 +31,7 @@ CAMLprim value unix_string_of_inet_addr(value a)
union sock_addr_union sa;
int len;
int retcode;
if (string_length(a) == 16) {
if (caml_string_length(a) == 16) {
memset(&sa.s_inet6, 0, sizeof(struct sockaddr_in6));
sa.s_inet6.sin6_family = AF_INET6;
sa.s_inet6.sin6_addr = GET_INET6_ADDR(a);
@ -50,7 +50,7 @@ CAMLprim value unix_string_of_inet_addr(value a)
res = buffer;
#else
char buffer[64];
if (string_length(a) == 16)
if (caml_string_length(a) == 16)
res = (char *)
inet_ntop(AF_INET6, (const void *) &GET_INET6_ADDR(a),
buffer, sizeof(buffer));
@ -63,7 +63,7 @@ CAMLprim value unix_string_of_inet_addr(value a)
res = inet_ntoa(GET_INET_ADDR(a));
#endif
if (res == NULL) uerror("string_of_inet_addr", Nothing);
return copy_string(res);
return caml_copy_string(res);
}
#else

View File

@ -303,7 +303,7 @@ CAMLprim value unix_tcgetattr(value fd)
if (tcgetattr(Int_val(fd), &terminal_status) == -1)
uerror("tcgetattr", Nothing);
res = alloc_tuple(NFIELDS);
res = caml_alloc_tuple(NFIELDS);
encode_terminal_status(&Field(res, 0));
return res;
}

View File

@ -20,5 +20,5 @@
CAMLprim value unix_time(value unit)
{
return copy_double((double) time((time_t *) NULL));
return caml_copy_double((double) time((time_t *) NULL));
}

View File

@ -40,7 +40,7 @@ CAMLprim value unix_times(value unit)
value res;
struct rusage ru;
res = alloc_small(4 * Double_wosize, Double_array_tag);
res = caml_alloc_small(4 * Double_wosize, Double_array_tag);
getrusage (RUSAGE_SELF, &ru);
Store_double_field (res, 0, ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1e6);
@ -56,7 +56,7 @@ CAMLprim value unix_times(value unit)
struct tms buffer;
times(&buffer);
res = alloc_small(4 * Double_wosize, Double_array_tag);
res = caml_alloc_small(4 * Double_wosize, Double_array_tag);
Store_double_field(res, 0, (double) buffer.tms_utime / CLK_TCK);
Store_double_field(res, 1, (double) buffer.tms_stime / CLK_TCK);
Store_double_field(res, 2, (double) buffer.tms_cutime / CLK_TCK);

View File

@ -264,7 +264,7 @@ value unix_error_of_code (int errcode)
errconstr =
cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1);
if (errconstr == Val_int(-1)) {
err = alloc_small(1, 0);
err = caml_alloc_small(1, 0);
Field(err, 0) = Val_int(errcode);
} else {
err = errconstr;
@ -287,22 +287,22 @@ void unix_error(int errcode, char *cmdname, value cmdarg)
value name = Val_unit, err = Val_unit, arg = Val_unit;
Begin_roots3 (name, err, arg);
arg = cmdarg == Nothing ? copy_string("") : cmdarg;
name = copy_string(cmdname);
arg = cmdarg == Nothing ? caml_copy_string("") : cmdarg;
name = caml_copy_string(cmdname);
err = unix_error_of_code (errcode);
if (unix_error_exn == NULL) {
unix_error_exn = caml_named_value("Unix.Unix_error");
if (unix_error_exn == NULL)
invalid_argument("Exception Unix.Unix_error not initialized,"
caml_invalid_argument("Exception Unix.Unix_error not initialized,"
" please link unix.cma");
}
res = alloc_small(4, 0);
res = caml_alloc_small(4, 0);
Field(res, 0) = *unix_error_exn;
Field(res, 1) = err;
Field(res, 2) = name;
Field(res, 3) = arg;
End_roots();
mlraise(res);
caml_raise(res);
}
void uerror(char *cmdname, value cmdarg)

View File

@ -44,19 +44,19 @@ static value alloc_process_status(int pid, int status)
value st, res;
if (WIFEXITED(status)) {
st = alloc_small(1, TAG_WEXITED);
st = caml_alloc_small(1, TAG_WEXITED);
Field(st, 0) = Val_int(WEXITSTATUS(status));
}
else if (WIFSTOPPED(status)) {
st = alloc_small(1, TAG_WSTOPPED);
st = caml_alloc_small(1, TAG_WSTOPPED);
Field(st, 0) = Val_int(caml_rev_convert_signal_number(WSTOPSIG(status)));
}
else {
st = alloc_small(1, TAG_WSIGNALED);
st = caml_alloc_small(1, TAG_WSIGNALED);
Field(st, 0) = Val_int(caml_rev_convert_signal_number(WTERMSIG(status)));
}
Begin_root (st);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_int(pid);
Field(res, 1) = st;
End_roots();
@ -67,9 +67,9 @@ CAMLprim value unix_wait(value unit)
{
int pid, status;
enter_blocking_section();
caml_enter_blocking_section();
pid = wait(&status);
leave_blocking_section();
caml_leave_blocking_section();
if (pid == -1) uerror("wait", Nothing);
return alloc_process_status(pid, status);
}
@ -88,10 +88,10 @@ CAMLprim value unix_waitpid(value flags, value pid_req)
{
int pid, status, cv_flags;
cv_flags = convert_flag_list(flags, wait_flag_table);
enter_blocking_section();
cv_flags = caml_convert_flag_list(flags, wait_flag_table);
caml_enter_blocking_section();
pid = waitpid(Int_val(pid_req), &status, cv_flags);
leave_blocking_section();
caml_leave_blocking_section();
if (pid == -1) uerror("waitpid", Nothing);
return alloc_process_status(pid, status);
}

View File

@ -40,9 +40,9 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
while (len > 0) {
numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len;
memmove (iobuf, &Byte(buf, ofs), numbytes);
enter_blocking_section();
caml_enter_blocking_section();
ret = write(Int_val(fd), iobuf, numbytes);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) {
if ((errno == EAGAIN || errno == EWOULDBLOCK) && written > 0) break;
uerror("write", Nothing);
@ -76,9 +76,9 @@ CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen)
if (len > 0) {
numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len;
memmove (iobuf, &Byte(buf, ofs), numbytes);
enter_blocking_section();
caml_enter_blocking_section();
ret = write(Int_val(fd), iobuf, numbytes);
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) uerror("single_write", Nothing);
}
End_roots();

View File

@ -262,7 +262,7 @@ static value gr_draw_or_fill_arc(value vx, value vy, value vrx, value vry,
r_x = Int_val(vrx);
r_y = Int_val(vry);
if ((r_x < 0) || (r_y < 0))
invalid_argument("draw_arc: radius must be positive");
caml_invalid_argument("draw_arc: radius must be positive");
x = Int_val(vx);
y = Int_val(vy);
start = Int_val(vstart);
@ -366,7 +366,7 @@ CAMLprim value caml_gr_draw_char(value chr)
CAMLprim value caml_gr_draw_string(value str)
{
gr_check_open();
caml_gr_draw_text(str, string_length(str));
caml_gr_draw_text(str, caml_string_length(str));
return Val_unit;
}
@ -375,12 +375,12 @@ CAMLprim value caml_gr_text_size(value str)
SIZE extent;
value res;
mlsize_t len = string_length(str);
mlsize_t len = caml_string_length(str);
if (len > 32767) len = 32767;
GetTextExtentPoint(grwindow.gc,String_val(str), len,&extent);
res = alloc_tuple(2);
res = caml_alloc_tuple(2);
Field(res, 0) = Val_long(extent.cx);
Field(res, 1) = Val_long(extent.cy);
@ -470,7 +470,7 @@ CAMLprim value caml_gr_create_image(value vw, value vh)
cbm = CreateCompatibleBitmap(grwindow.gc, w, h);
if (cbm == NULL)
gr_fail("create_image: cannot create bitmap", 0);
res = alloc_custom(&image_ops, sizeof(struct image),
res = caml_alloc_custom(&image_ops, sizeof(struct image),
w * h, Max_image_mem);
if (res) {
Width (res) = w;
@ -602,10 +602,10 @@ static value alloc_int_vect(mlsize_t size)
if (size == 0) return Atom(0);
if (size <= Max_young_wosize) {
res = alloc(size, 0);
res = caml_alloc(size, 0);
}
else {
res = alloc_shr(size, 0);
res = caml_alloc_shr(size, 0);
}
for (i = 0; i < size; i++) {
Field(res, i) = Val_long(0);
@ -624,7 +624,7 @@ CAMLprim value caml_gr_dump_image (value img)
Begin_roots2(img, matrix)
matrix = alloc_int_vect (height);
for (i = 0; i < height; i++) {
modify (&Field (matrix, i), alloc_int_vect (width));
caml_modify (&Field (matrix, i), alloc_int_vect (width));
}
End_roots();

View File

@ -117,7 +117,7 @@ static value caml_gr_wait_allocate_result(int mouse_x, int mouse_y,
int button,
int keypressed, int key)
{
value res = alloc_small(5, 0);
value res = caml_alloc_small(5, 0);
Field(res, 0) = Val_int(mouse_x);
Field(res, 1) = Val_int(grwindow.height - 1 - mouse_y);
Field(res, 2) = Val_bool(button);

View File

@ -359,11 +359,11 @@ void gr_fail(char *fmt, char *arg)
if (graphic_failure_exn == NULL) {
graphic_failure_exn = caml_named_value("Graphics.Graphic_failure");
if (graphic_failure_exn == NULL)
invalid_argument("Exception Graphics.Graphic_failure not initialized, "
caml_invalid_argument("Exception Graphics.Graphic_failure not initialized, "
"must link graphics.cma");
}
sprintf(buffer, fmt, arg);
raise_with_string(*graphic_failure_exn, buffer);
caml_raise_with_string(*graphic_failure_exn, buffer);
}
void gr_check_open(void)

View File

@ -31,10 +31,10 @@ CAMLprim value unix_accept(sock)
DWORD err = 0;
addr_len = sizeof(sock_addr);
enter_blocking_section();
caml_enter_blocking_section();
snew = accept(sconn, &addr.s_gen, &addr_len);
if (snew == INVALID_SOCKET) err = WSAGetLastError ();
leave_blocking_section();
caml_leave_blocking_section();
if (snew == INVALID_SOCKET) {
win32_maperr(err);
uerror("accept", Nothing);
@ -42,7 +42,7 @@ CAMLprim value unix_accept(sock)
Begin_roots2 (fd, adr)
fd = win_alloc_socket(snew);
adr = alloc_sockaddr(&addr, addr_len, snew);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = fd;
Field(res, 1) = adr;
End_roots();

View File

@ -27,10 +27,10 @@ CAMLprim value unix_connect(socket, address)
DWORD err = 0;
get_sockaddr(address, &addr, &addr_len);
enter_blocking_section();
caml_enter_blocking_section();
if (connect(s, &addr.s_gen, addr_len) == -1)
err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
if (err) {
win32_maperr(err);
uerror("connect", Nothing);

View File

@ -36,7 +36,7 @@ value win_create_process_native(value cmd, value cmdline, value env,
unix_error(EINVAL, "create_process", cmdline);
/* [env] is checked for null bytes at construction time, see unix.ml */
exefile = search_exe_in_path(String_val(cmd));
exefile = caml_search_exe_in_path(String_val(cmd));
if (env != Val_int(0)) {
envp = String_val(Field(env, 0));
} else {

View File

@ -29,7 +29,7 @@ CAMLprim value unix_error_message(value err)
errnum = Is_block(err) ? Int_val(Field(err, 0)) : error_table[Int_val(err)];
if (errnum > 0)
return copy_string(strerror(errnum));
return caml_copy_string(strerror(errnum));
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
-errnum,
@ -37,7 +37,7 @@ CAMLprim value unix_error_message(value err)
buffer,
sizeof(buffer),
NULL))
return copy_string(buffer);
return caml_copy_string(buffer);
sprintf(buffer, "unknown error #%d", errnum);
return copy_string(buffer);
return caml_copy_string(buffer);
}

View File

@ -36,5 +36,5 @@ CAMLprim value unix_gettimeofday(value unit)
#else
tm = *(uint64_t *)&ft - epoch_ft; /* shift to Epoch-relative time */
#endif
return copy_double(tm * 1e-7); /* tm is in 100ns */
return caml_copy_double(tm * 1e-7); /* tm is in 100ns */
}

View File

@ -33,7 +33,7 @@ CAMLprim value unix_link(value path1, value path2)
pCreateHardLink =
(tCreateHardLink) GetProcAddress(hModKernel32, "CreateHardLinkA");
if (pCreateHardLink == NULL)
invalid_argument("Unix.link not implemented");
caml_invalid_argument("Unix.link not implemented");
caml_unix_check_path(path1, "link");
caml_unix_check_path(path2, "link");
if (! pCreateHardLink(String_val(path2), String_val(path1), NULL)) {

View File

@ -63,11 +63,11 @@ CAMLprim value unix_lockf(value fd, value cmd, value span)
version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if(GetVersionEx(&version) == 0) {
invalid_argument("lockf only supported on WIN32_NT platforms:"
caml_invalid_argument("lockf only supported on WIN32_NT platforms:"
" could not determine current platform.");
}
if(version.dwPlatformId != VER_PLATFORM_WIN32_NT) {
invalid_argument("lockf only supported on WIN32_NT platforms");
caml_invalid_argument("lockf only supported on WIN32_NT platforms");
}
h = Handle_val(fd);
@ -112,11 +112,11 @@ CAMLprim value unix_lockf(value fd, value cmd, value span)
err = GetLastError();
break;
case 1: /* F_LOCK - blocking write lock */
enter_blocking_section();
caml_enter_blocking_section();
if (! LockFileEx(h, LOCKFILE_EXCLUSIVE_LOCK, 0,
lock_len.LowPart, lock_len.HighPart, &overlap))
err = GetLastError();
leave_blocking_section();
caml_leave_blocking_section();
break;
case 2: /* F_TLOCK - non-blocking write lock */
if (! LockFileEx(h, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, 0,
@ -137,11 +137,11 @@ CAMLprim value unix_lockf(value fd, value cmd, value span)
}
break;
case 4: /* F_RLOCK - blocking read lock */
enter_blocking_section();
caml_enter_blocking_section();
if (! LockFileEx(h, 0, 0,
lock_len.LowPart, lock_len.HighPart, &overlap))
err = GetLastError();
leave_blocking_section();
caml_leave_blocking_section();
break;
case 5: /* F_TRLOCK - non-blocking read lock */
if (! LockFileEx(h, LOCKFILE_FAIL_IMMEDIATELY, 0,

View File

@ -66,5 +66,5 @@ CAMLprim value unix_lseek_64(value fd, value ofs, value cmd)
ret = caml_set_file_pointer(Handle_val(fd), Int64_val(ofs),
seek_command_table[Int_val(cmd)]);
return copy_int64(ret);
return caml_copy_int64(ret);
}

View File

@ -42,11 +42,11 @@ CAMLprim value unix_open(value path, value flags, value perm)
HANDLE h;
caml_unix_check_path(path, "open");
fileaccess = convert_flag_list(flags, open_access_flags);
fileaccess = caml_convert_flag_list(flags, open_access_flags);
sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE
| convert_flag_list(flags, open_share_flags);
| caml_convert_flag_list(flags, open_share_flags);
createflags = convert_flag_list(flags, open_create_flags);
createflags = caml_convert_flag_list(flags, open_create_flags);
if ((createflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
filecreate = CREATE_NEW;
else if ((createflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
@ -63,7 +63,7 @@ CAMLprim value unix_open(value path, value flags, value perm)
else
fileattrib = FILE_ATTRIBUTE_NORMAL;
cloexec = convert_flag_list(flags, open_cloexec_flags);
cloexec = caml_convert_flag_list(flags, open_cloexec_flags);
attr.nLength = sizeof(attr);
attr.lpSecurityDescriptor = NULL;
attr.bInheritHandle = cloexec ? FALSE : TRUE;

View File

@ -38,7 +38,7 @@ CAMLprim value unix_pipe(value unit)
Begin_roots2(readfd, writefd)
readfd = win_alloc_handle(readh);
writefd = win_alloc_handle(writeh);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = readfd;
Field(res, 1) = writefd;
End_roots();

View File

@ -32,17 +32,17 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value vlen)
if (Descr_kind_val(fd) == KIND_SOCKET) {
int ret;
SOCKET s = Socket_val(fd);
enter_blocking_section();
caml_enter_blocking_section();
ret = recv(s, iobuf, numbytes, 0);
if (ret == SOCKET_ERROR) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
numread = ret;
} else {
HANDLE h = Handle_val(fd);
enter_blocking_section();
caml_enter_blocking_section();
if (! ReadFile(h, iobuf, numbytes, &numread, NULL))
err = GetLastError();
leave_blocking_section();
caml_leave_blocking_section();
}
if (err) {
win32_maperr(err);

View File

@ -922,7 +922,7 @@ static value find_handle(LPSELECTRESULT iterResult, value readfds,
}
if (list == Val_unit)
failwith ("select.c: original file handle not found");
caml_failwith ("select.c: original file handle not found");
result = Field(list, 0);
@ -963,7 +963,7 @@ static value fdset_to_fdlist(value fdlist, fd_set *fdset)
for (/*nothing*/; fdlist != Val_int(0); fdlist = Field(fdlist, 1)) {
value s = Field(fdlist, 0);
if (FD_ISSET(Socket_val(s), fdset)) {
value newres = alloc_small(2, 0);
value newres = caml_alloc_small(2, 0);
Field(newres, 0) = s;
Field(newres, 1) = res;
res = newres;
@ -1031,9 +1031,9 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
&& exceptfds == Val_int(0)) {
DEBUG_PRINT("nothing to do");
if ( tm > 0.0 ) {
enter_blocking_section();
caml_enter_blocking_section();
Sleep( (int)(tm * 1000));
leave_blocking_section();
caml_leave_blocking_section();
}
read_list = write_list = except_list = Val_int(0);
} else {
@ -1048,12 +1048,12 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
tv.tv_usec = (int) (1e6 * (tm - (int) tm));
tvp = &tv;
}
enter_blocking_section();
caml_enter_blocking_section();
if (select(FD_SETSIZE, &read, &write, &except, tvp) == -1) {
err = WSAGetLastError();
DEBUG_PRINT("Error %ld occurred", err);
}
leave_blocking_section();
caml_leave_blocking_section();
if (err) {
DEBUG_PRINT("Error %ld occurred", err);
win32_maperr(err);
@ -1189,7 +1189,7 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
DEBUG_PRINT("Need to watch %d workers", nEventsCount);
/* Processing select itself */
enter_blocking_section();
caml_enter_blocking_section();
/* There are worker started, waiting to be monitored */
if (nEventsCount > 0)
{
@ -1244,7 +1244,7 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
{
Sleep(milliseconds);
}
leave_blocking_section();
caml_leave_blocking_section();
DEBUG_PRINT("Error status: %d (0 is ok)", err);
/* Build results */
@ -1261,7 +1261,7 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
for (i = 0; i < iterSelectData->nResultsCount; i++)
{
iterResult = &(iterSelectData->aResults[i]);
l = alloc_small(2, 0);
l = caml_alloc_small(2, 0);
Store_field(l, 0, find_handle(iterResult, readfds, writefds,
exceptfds));
switch (iterResult->EMode)
@ -1315,7 +1315,7 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds,
}
DEBUG_PRINT("Build final result");
res = alloc_small(3, 0);
res = caml_alloc_small(3, 0);
Store_field(res, 0, read_list);
Store_field(res, 1, write_list);
Store_field(res, 2, except_list);

View File

@ -28,7 +28,7 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len,
value flags)
{
SOCKET s = Socket_val(sock);
int flg = convert_flag_list(flags, msg_flag_table);
int flg = caml_convert_flag_list(flags, msg_flag_table);
int ret;
intnat numbytes;
char iobuf[UNIX_BUFFER_SIZE];
@ -37,10 +37,10 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len,
Begin_root (buff);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
enter_blocking_section();
caml_enter_blocking_section();
ret = recv(s, iobuf, (int) numbytes, flg);
if (ret == -1) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) {
win32_maperr(err);
uerror("recv", Nothing);
@ -54,7 +54,7 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len,
value flags)
{
SOCKET s = Socket_val(sock);
int flg = convert_flag_list(flags, msg_flag_table);
int flg = caml_convert_flag_list(flags, msg_flag_table);
int ret;
intnat numbytes;
char iobuf[UNIX_BUFFER_SIZE];
@ -68,17 +68,17 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len,
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
addr_len = sizeof(sock_addr);
enter_blocking_section();
caml_enter_blocking_section();
ret = recvfrom(s, iobuf, (int) numbytes, flg, &addr.s_gen, &addr_len);
if (ret == -1) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) {
win32_maperr(err);
uerror("recvfrom", Nothing);
}
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
adr = alloc_sockaddr(&addr, addr_len, -1);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_int(ret);
Field(res, 1) = adr;
End_roots();
@ -89,7 +89,7 @@ CAMLprim value unix_send(value sock, value buff, value ofs, value len,
value flags)
{
SOCKET s = Socket_val(sock);
int flg = convert_flag_list(flags, msg_flag_table);
int flg = caml_convert_flag_list(flags, msg_flag_table);
int ret;
intnat numbytes;
char iobuf[UNIX_BUFFER_SIZE];
@ -98,10 +98,10 @@ CAMLprim value unix_send(value sock, value buff, value ofs, value len,
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
enter_blocking_section();
caml_enter_blocking_section();
ret = send(s, iobuf, (int) numbytes, flg);
if (ret == -1) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) {
win32_maperr(err);
uerror("send", Nothing);
@ -113,7 +113,7 @@ value unix_sendto_native(value sock, value buff, value ofs, value len,
value flags, value dest)
{
SOCKET s = Socket_val(sock);
int flg = convert_flag_list(flags, msg_flag_table);
int flg = caml_convert_flag_list(flags, msg_flag_table);
int ret;
intnat numbytes;
char iobuf[UNIX_BUFFER_SIZE];
@ -125,10 +125,10 @@ value unix_sendto_native(value sock, value buff, value ofs, value len,
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
enter_blocking_section();
caml_enter_blocking_section();
ret = sendto(s, iobuf, (int) numbytes, flg, &addr.s_gen, addr_len);
if (ret == -1) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
if (ret == -1) {
win32_maperr(err);
uerror("sendto", Nothing);

View File

@ -21,8 +21,8 @@ CAMLprim value unix_sleep(t)
value t;
{
double d = Double_val(t);
enter_blocking_section();
caml_enter_blocking_section();
Sleep(d * 1e3);
leave_blocking_section();
caml_leave_blocking_section();
return Val_unit;
}

View File

@ -140,12 +140,12 @@ unix_getsockopt_aux(char * name,
if (optval.lg.l_onoff == 0) {
return Val_int(0); /* None */
} else {
value res = alloc_small(1, 0); /* Some */
value res = caml_alloc_small(1, 0); /* Some */
Field(res, 0) = Val_int(optval.lg.l_linger);
return res;
}
case TYPE_TIMEVAL:
return copy_double((double) optval.tv.tv_sec
return caml_copy_double((double) optval.tv.tv_sec
+ (double) optval.tv.tv_usec / 1e6);
case TYPE_UNIX_ERROR:
if (optval.i == 0) {
@ -154,7 +154,7 @@ unix_getsockopt_aux(char * name,
value err, res;
err = unix_error_of_code(optval.i);
Begin_root(err);
res = alloc_small(1, 0); /* Some */
res = caml_alloc_small(1, 0); /* Some */
Field(res, 0) = err;
End_roots();
return res;

View File

@ -68,10 +68,10 @@ static value stat_aux(int use_64, __int64 st_ino, struct _stat64 *buf)
Store_field (v, 6, Val_int (buf->st_gid));
Store_field (v, 7, Val_int (buf->st_rdev));
Store_field (v, 8,
use_64 ? copy_int64(buf->st_size) : Val_int (buf->st_size));
Store_field (v, 9, copy_double((double) buf->st_atime));
Store_field (v, 10, copy_double((double) buf->st_mtime));
Store_field (v, 11, copy_double((double) buf->st_ctime));
use_64 ? caml_copy_int64(buf->st_size) : Val_int (buf->st_size));
Store_field (v, 9, caml_copy_double((double) buf->st_atime));
Store_field (v, 10, caml_copy_double((double) buf->st_mtime));
Store_field (v, 11, caml_copy_double((double) buf->st_ctime));
CAMLreturn (v);
}

View File

@ -41,7 +41,7 @@ CAMLprim value unix_symlink(value to_dir, value osource, value odest)
again:
if (no_symlink) {
invalid_argument("symlink not available");
caml_invalid_argument("symlink not available");
}
if (!pCreateSymbolicLink) {

View File

@ -33,13 +33,13 @@ CAMLprim value win_system(cmd)
len = caml_string_length (cmd);
buf = caml_stat_alloc (len + 1);
memmove (buf, String_val (cmd), len + 1);
enter_blocking_section();
caml_enter_blocking_section();
_flushall();
ret = system(buf);
leave_blocking_section();
caml_leave_blocking_section();
caml_stat_free(buf);
if (ret == -1) uerror("system", Nothing);
st = alloc_small(1, 0); /* Tag 0: Exited */
st = caml_alloc_small(1, 0); /* Tag 0: Exited */
Field(st, 0) = Val_int(ret);
return st;
}

View File

@ -49,7 +49,7 @@ value unix_times(value unit) {
uerror("times", Nothing);
}
res = alloc_small(4 * Double_wosize, Double_array_tag);
res = caml_alloc_small(4 * Double_wosize, Double_array_tag);
Store_double_field(res, 0, to_sec(utime));
Store_double_field(res, 1, to_sec(stime));
Store_double_field(res, 2, 0);

View File

@ -50,7 +50,7 @@ static struct custom_operations win_handle_ops = {
value win_alloc_handle(HANDLE h)
{
value res = alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1);
value res = caml_alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1);
Handle_val(res) = h;
Descr_kind_val(res) = KIND_HANDLE;
CRT_fd_val(res) = NO_CRT_FD;
@ -60,7 +60,7 @@ value win_alloc_handle(HANDLE h)
value win_alloc_socket(SOCKET s)
{
value res = alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1);
value res = caml_alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1);
Socket_val(res) = s;
Descr_kind_val(res) = KIND_SOCKET;
CRT_fd_val(res) = NO_CRT_FD;
@ -272,7 +272,7 @@ value unix_error_of_code (int errcode)
errconstr =
cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1);
if (errconstr == Val_int(-1)) {
err = alloc_small(1, 0);
err = caml_alloc_small(1, 0);
Field(err, 0) = Val_int(errcode);
} else {
err = errconstr;
@ -287,22 +287,22 @@ void unix_error(int errcode, char *cmdname, value cmdarg)
int errconstr;
Begin_roots3 (name, err, arg);
arg = cmdarg == Nothing ? copy_string("") : cmdarg;
name = copy_string(cmdname);
arg = cmdarg == Nothing ? caml_copy_string("") : cmdarg;
name = caml_copy_string(cmdname);
err = unix_error_of_code (errcode);
if (unix_error_exn == NULL) {
unix_error_exn = caml_named_value("Unix.Unix_error");
if (unix_error_exn == NULL)
invalid_argument("Exception Unix.Unix_error not initialized,"
caml_invalid_argument("Exception Unix.Unix_error not initialized,"
" please link unix.cma");
}
res = alloc_small(4, 0);
res = caml_alloc_small(4, 0);
Field(res, 0) = *unix_error_exn;
Field(res, 1) = err;
Field(res, 2) = name;
Field(res, 3) = arg;
End_roots();
mlraise(res);
caml_raise(res);
}
void uerror(char * cmdname, value cmdarg)

View File

@ -34,15 +34,15 @@ CAMLprim value win_findfirst(value name)
if (h == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
if (err == ERROR_NO_MORE_FILES)
raise_end_of_file();
caml_raise_end_of_file();
else {
win32_maperr(err);
uerror("opendir", Nothing);
}
}
valname = copy_string(fileinfo.cFileName);
valname = caml_copy_string(fileinfo.cFileName);
valh = win_alloc_handle(h);
v = alloc_small(2, 0);
v = caml_alloc_small(2, 0);
Field(v,0) = valname;
Field(v,1) = valh;
End_roots();
@ -58,13 +58,13 @@ CAMLprim value win_findnext(value valh)
if (!retcode) {
DWORD err = GetLastError();
if (err == ERROR_NO_MORE_FILES)
raise_end_of_file();
caml_raise_end_of_file();
else {
win32_maperr(err);
uerror("readdir", Nothing);
}
}
return copy_string(fileinfo.cFileName);
return caml_copy_string(fileinfo.cFileName);
}
CAMLprim value win_findclose(value valh)

View File

@ -25,10 +25,10 @@ static value alloc_process_status(HANDLE pid, int status)
{
value res, st;
st = alloc(1, 0);
st = caml_alloc(1, 0);
Field(st, 0) = Val_int(status);
Begin_root (st);
res = alloc_small(2, 0);
res = caml_alloc_small(2, 0);
Field(res, 0) = Val_long((intnat) pid);
Field(res, 1) = st;
End_roots();
@ -46,12 +46,12 @@ CAMLprim value win_waitpid(value vflags, value vpid_req)
HANDLE pid_req = (HANDLE) Long_val(vpid_req);
DWORD err = 0;
flags = convert_flag_list(vflags, wait_flag_table);
flags = caml_convert_flag_list(vflags, wait_flag_table);
if ((flags & CAML_WNOHANG) == 0) {
enter_blocking_section();
caml_enter_blocking_section();
retcode = WaitForSingleObject(pid_req, INFINITE);
if (retcode == WAIT_FAILED) err = GetLastError();
leave_blocking_section();
caml_leave_blocking_section();
if (err) {
win32_maperr(err);
uerror("waitpid", Nothing);

View File

@ -283,10 +283,10 @@ LPWORKER worker_job_submit (WORKERFUNC f, void *user_data)
LPWORKER lpWorker = worker_pop();
DEBUG_PRINT("Waiting for worker to be ready");
enter_blocking_section();
caml_enter_blocking_section();
WaitForSingleObject(lpWorker->hWorkerReady, INFINITE);
ResetEvent(lpWorker->hWorkerReady);
leave_blocking_section();
caml_leave_blocking_section();
DEBUG_PRINT("Worker is ready");
lpWorker->hJobFunc = f;
@ -314,9 +314,9 @@ void worker_job_stop (LPWORKER lpWorker)
void worker_job_finish (LPWORKER lpWorker)
{
DEBUG_PRINT("Finishing call of worker %x", lpWorker);
enter_blocking_section();
caml_enter_blocking_section();
WaitForSingleObject(lpWorker->hJobDone, INFINITE);
leave_blocking_section();
caml_leave_blocking_section();
worker_push(lpWorker);
}

View File

@ -37,17 +37,17 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
if (Descr_kind_val(fd) == KIND_SOCKET) {
int ret;
SOCKET s = Socket_val(fd);
enter_blocking_section();
caml_enter_blocking_section();
ret = send(s, iobuf, numbytes, 0);
if (ret == SOCKET_ERROR) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
numwritten = ret;
} else {
HANDLE h = Handle_val(fd);
enter_blocking_section();
caml_enter_blocking_section();
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
err = GetLastError();
leave_blocking_section();
caml_leave_blocking_section();
}
if (err) {
win32_maperr(err);
@ -78,17 +78,17 @@ CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen)
if (Descr_kind_val(fd) == KIND_SOCKET) {
int ret;
SOCKET s = Socket_val(fd);
enter_blocking_section();
caml_enter_blocking_section();
ret = send(s, iobuf, numbytes, 0);
if (ret == SOCKET_ERROR) err = WSAGetLastError();
leave_blocking_section();
caml_leave_blocking_section();
numwritten = ret;
} else {
HANDLE h = Handle_val(fd);
enter_blocking_section();
caml_enter_blocking_section();
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
err = GetLastError();
leave_blocking_section();
caml_leave_blocking_section();
}
if (err) {
win32_maperr(err);

View File

@ -20,11 +20,11 @@
int fib(int n)
{
value * fib_closure = caml_named_value("fib");
return Int_val(callback(*fib_closure, Val_int(n)));
return Int_val(caml_callback(*fib_closure, Val_int(n)));
}
char * format_result(int n)
{
value * format_result_closure = caml_named_value("format_result");
return strdup(String_val(callback(*format_result_closure, Val_int(n))));
return strdup(String_val(caml_callback(*format_result_closure, Val_int(n))));
}

View File

@ -20,11 +20,11 @@
value marshal_to_block(value vbuf, value vlen, value v, value vflags)
{
return Val_long(output_value_to_block(v, vflags,
return Val_long(caml_output_value_to_block(v, vflags,
(char *) vbuf, Long_val(vlen)));
}
value marshal_from_block(value vbuf, value vlen)
{
return input_value_from_block((char *) vbuf, Long_val(vlen));
return caml_input_value_from_block((char *) vbuf, Long_val(vlen));
}