Skip to content

Commit

Permalink
Sources C convertis en ANSI C
Browse files Browse the repository at this point in the history
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1696 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
xavierleroy committed Sep 2, 1997
1 parent d75918f commit 1517cea
Show file tree
Hide file tree
Showing 208 changed files with 1,350 additions and 2,090 deletions.
2 changes: 1 addition & 1 deletion asmrun/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ compact.c: ../byterun/compact.c
LINKEDFILES=misc.c freelist.c major_gc.c minor_gc.c memory.c alloc.c \
compare.c ints.c floats.c str.c io.c extern.c intern.c hash.c sys.c \
parsing.c gc_ctrl.c terminfo.c md5.c obj.c lexing.c printexc.c callback.c \
weak.c
weak.c compact.c

clean::
rm -f $(LINKEDFILES)
Expand Down
8 changes: 3 additions & 5 deletions asmrun/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include "misc.h"
#include "mlvalues.h"

value make_vect(len, init)
value len, init;
value make_vect(value len, value init)
{
value res;
mlsize_t size, wsize, i;
Expand Down Expand Up @@ -66,8 +65,7 @@ value make_vect(len, init)
return res;
}

value make_array(init)
value init;
value make_array(value init)
{
mlsize_t wsize, size, i;
value v, res;
Expand Down Expand Up @@ -98,7 +96,7 @@ value make_array(init)
}
}

void array_bound_error()
void array_bound_error(void)
{
fatal_error("Fatal error: out-of-bound access in array or string\n");
}
33 changes: 12 additions & 21 deletions asmrun/fail.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ extern caml_generated_constant Out_of_memory, Sys_error, Failure,

/* Exception raising */

extern void raise_caml_exception P((value bucket)) Noreturn;
extern void raise_caml_exception (value bucket) Noreturn;

char * caml_exception_pointer = NULL;

void mlraise(v)
value v;
void mlraise(value v)
{
#ifdef POSIX_SIGNALS
sigset_t mask;
Expand Down Expand Up @@ -68,8 +67,7 @@ void mlraise(v)
raise_caml_exception(v);
}

void raise_constant(tag)
value tag;
void raise_constant(value tag)
{
value bucket;
Begin_root (tag);
Expand All @@ -79,9 +77,7 @@ void raise_constant(tag)
mlraise(bucket);
}

void raise_with_arg(tag, arg)
value tag;
value arg;
void raise_with_arg(value tag, value arg)
{
value bucket;
Begin_roots2 (tag, arg);
Expand All @@ -92,15 +88,12 @@ void raise_with_arg(tag, arg)
mlraise(bucket);
}

void raise_with_string(tag, msg)
value tag;
char * msg;
void raise_with_string(value tag, char *msg)
{
raise_with_arg(tag, copy_string(msg));
}

void failwith (msg)
char * msg;
void failwith (char *msg)
{
raise_with_string((value) Failure, msg);
}
Expand All @@ -113,8 +106,7 @@ void failwith (msg)
Finally, this allows a number of C primitives to be declared "noalloc",
and this makes calling them much more efficient. */

void invalid_argument (msg)
char * msg;
void invalid_argument (char *msg)
{
fatal_error_arg("Fatal_error: Invalid_argument \"%s\"\n", msg);
}
Expand All @@ -130,30 +122,29 @@ static struct {
value exn;
} out_of_memory_bucket;

void raise_out_of_memory()
void raise_out_of_memory(void)
{
out_of_memory_bucket.hdr = Make_header(1, 0, White);
out_of_memory_bucket.exn = (value) Out_of_memory;
mlraise((value) &(out_of_memory_bucket.exn));
}

void raise_sys_error(msg)
value msg;
void raise_sys_error(value msg)
{
raise_with_arg((value) Sys_error, msg);
}

void raise_end_of_file()
void raise_end_of_file(void)
{
raise_constant((value) End_of_file);
}

void raise_zero_divide()
void raise_zero_divide(void)
{
raise_constant((value) Division_by_zero);
}

void raise_not_found()
void raise_not_found(void)
{
raise_constant((value) Not_found);
}
Expand Down
2 changes: 1 addition & 1 deletion asmrun/roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct global_root {

static struct global_root * global_roots = NULL;

void (*scan_roots_hook) P((scanning_action)) = NULL;
void (*scan_roots_hook) (scanning_action) = NULL;

/* Register a global C root */

Expand Down
51 changes: 19 additions & 32 deletions asmrun/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@
#include "fail.h"
#include "signals.h"

Volatile int async_signal_mode = 0;
Volatile int pending_signal = 0;
Volatile int force_major_slice = 0;
volatile int async_signal_mode = 0;
volatile int pending_signal = 0;
volatile int force_major_slice = 0;
value signal_handlers = 0;
extern unsigned long caml_last_return_address;
void (*enter_blocking_section_hook)() = NULL;
void (*leave_blocking_section_hook)() = NULL;

/* Execute a signal handler immediately. */

static void execute_signal(signal_number)
int signal_number;
static void execute_signal(int signal_number)
{
Assert (!async_signal_mode);
callback(Field(signal_handlers, signal_number), Val_int(signal_number));
Expand All @@ -45,7 +44,7 @@ static void execute_signal(signal_number)
/* This routine is the common entry point for garbage collection
and signal handling */

void garbage_collection()
void garbage_collection(void)
{
int sig;

Expand All @@ -60,7 +59,7 @@ void garbage_collection()

/* Trigger a garbage collection as soon as possible */

void urge_major_slice ()
void urge_major_slice (void)
{
force_major_slice = 1;
young_limit = young_end;
Expand All @@ -70,7 +69,7 @@ void urge_major_slice ()
from young_limit. */
}

void enter_blocking_section()
void enter_blocking_section(void)
{
int sig;

Expand All @@ -88,7 +87,7 @@ void enter_blocking_section()
if (enter_blocking_section_hook != NULL) enter_blocking_section_hook();
}

void leave_blocking_section()
void leave_blocking_section(void)
{
Assert(async_signal_mode);
if (leave_blocking_section_hook != NULL) leave_blocking_section_hook();
Expand All @@ -97,16 +96,11 @@ void leave_blocking_section()

#if defined(TARGET_alpha) || defined(TARGET_mips) || \
(defined(TARGET_power) && defined(_AIX))
void handle_signal(sig, code, context)
int sig, code;
struct sigcontext * context;
void handle_signal(int sig, int code, struct sigcontext * context)
#elif defined(TARGET_power) && defined(__linux)
void handle_signal(sig, context)
int sig;
struct pt_regs * context;
void handle_signal(int sig, sutrct pt_regs * context)
#else
void handle_signal(sig)
int sig;
void handle_signal(int sig)
#endif
{
#ifndef POSIX_SIGNALS
Expand Down Expand Up @@ -227,8 +221,8 @@ int posix_signals[] = {
#define NSIG 32
#endif

value install_signal_handler(signal_number, action) /* ML */
value signal_number, action;
value install_signal_handler(value signal_number, value action) /* ML */
{
int sig;
void (*act)();
Expand Down Expand Up @@ -274,10 +268,8 @@ value install_signal_handler(signal_number, action) /* ML */
/* Machine- and OS-dependent handling of bound check trap */

#if defined(TARGET_sparc) && defined(SYS_sunos)
static void trap_handler(sig, code, context, address)
int sig, code;
struct sigcontext * context;
char * address;
static void trap_handler(int sig, int code,
struct sigcontext * context, char * address)
{
if (code == ILL_TRAP_FAULT(5)) {
array_bound_error();
Expand All @@ -289,10 +281,7 @@ static void trap_handler(sig, code, context, address)
#endif

#if defined(TARGET_sparc) && defined(SYS_solaris)
static void trap_handler(sig, info, context)
int sig;
siginfo_t * info;
struct ucontext_t * context;
static void trap_handler(int sig, siginfo_t info, struct ucontext_t * context)
{
if (info->si_code == ILL_ILLTRP) {
array_bound_error();
Expand All @@ -305,24 +294,22 @@ static void trap_handler(sig, info, context)
#endif

#if defined(TARGET_sparc) && defined(SYS_bsd)
static void trap_handler(sig)
int sig;
static void trap_handler(int sig)
{
array_bound_error();
}
#endif

#if defined(TARGET_power)
static void trap_handler(sig)
int sig;
static void trap_handler(int sig)
{
array_bound_error();
}
#endif

/* Initialization of signal stuff */

void init_signals()
void init_signals(void)
{
#if defined(TARGET_sparc) && (defined(SYS_sunos) || defined(SYS_bsd))
signal(SIGILL, trap_handler);
Expand Down
24 changes: 9 additions & 15 deletions asmrun/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ char * code_area_start, * code_area_end;

struct segment { char * begin; char * end; };

static void minmax_table(table, min, max)
struct segment table[];
char ** min, ** max;
static void minmax_table(struct segment *table, char **min, char **max)
{
int i;
*min = table[0].begin;
Expand All @@ -46,7 +44,7 @@ static void minmax_table(table, min, max)
}
}

static void init_atoms()
static void init_atoms(void)
{
int i;
extern struct segment caml_data_segments[], caml_code_segments[];
Expand All @@ -73,9 +71,7 @@ static unsigned long max_stack_init = Max_stack_def;
*/
/* Note: option l is irrelevant to the native-code runtime. */

static void scanmult (opt, var)
char *opt;
unsigned long *var;
static void scanmult (char *opt, long unsigned int *var)
{
char mult = ' ';
sscanf (opt, "=%lu%c", var, &mult);
Expand All @@ -84,7 +80,7 @@ static void scanmult (opt, var)
if (mult == 'G') *var = *var * (1024 * 1024 * 1024);
}

static void parse_camlrunparam()
static void parse_camlrunparam(void)
{
char *opt = getenv ("CAMLRUNPARAM");
if (opt != NULL){
Expand All @@ -102,12 +98,11 @@ static void parse_camlrunparam()
}
}

extern void caml_start_program P((void));
extern void init_ieee_floats P((void));
extern void init_signals P((void));
extern void caml_start_program (void);
extern void init_ieee_floats (void);
extern void init_signals (void);

void caml_main(argv)
char ** argv;
void caml_main(char **argv)
{
init_ieee_floats();
#ifdef DEBUG
Expand All @@ -122,8 +117,7 @@ void caml_main(argv)
caml_start_program();
}

void caml_startup(argv)
char ** argv;
void caml_startup(char **argv)
{
caml_main(argv);
}
Loading

0 comments on commit 1517cea

Please sign in to comment.