Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tidying up; eliminating some warning messages during bootstrapping.

  • Loading branch information...
commit 464f114cca54ed7a5bc0170e8ff6069b299e97f1 1 parent 605ac93
Hongwei Xi authored
View
2  .bootstrap_makefile
@@ -31,8 +31,8 @@
## ###### ###### ##
-## Time: December 2007
## Author: Hongwei Xi (hwxi AT cs DOT bu DOT edu)
+## Time: December 2007
## ###### ###### ##
View
2  INSTALL
@@ -127,7 +127,7 @@ svn co \
FOO/bootstrap0
After this is done, please go into the directory "FOO" and execute the
-command 'autoconf' and then do 'make all'.
+command 'aclocal' and then 'autoconf' and then do 'make all'.
######
View
6 ccomp/runtime/GCATS0/README
@@ -1,4 +1,10 @@
+/*
+**
+*/
+
This is the first GC for ATS I wrote, following Rick Lavoie's previous
implementation of a GC for ATS. I mostly did the implementation during the
summer of 2007. There is no support for multithreads in this GC.
+###### end of [README] ######
+
View
2  ccomp/runtime/GCATS2/gcats2.cats
@@ -188,7 +188,7 @@ extern freeitmlst_vt the_freeitmlstarr[FREEITMLST_ARRAYSIZE] ;
/* ****** ****** */
#define NMARKBIT_PER_CHUNK \
- ((CHUNK_WORDSIZE + NBIT_PER_BYTE - 1) / NBIT_PER_BYTE)
+ ((CHUNK_WORDSIZE + NBIT_PER_BYTE_MASK) / NBIT_PER_BYTE)
typedef
struct chunk_struct {
View
13 ccomp/runtime/GCATS2/gcats2_ats.hats
@@ -77,18 +77,21 @@
#print "CHUNK_BYTESIZE = "; #print CHUNK_BYTESIZE; #print "\n"
#assert (CHUNK_BYTESIZE == __PAGESIZE)
#define MAX_CLICK_WORDSIZE_LOG CHUNK_WORDSIZE_LOG
- #define MAX_CLICK_WORDSIZE (1 << MAX_CLICK_WORDSIZE_LOG)
+
+ #define MAX_CLICK_WORDSIZE %(1 << MAX_CLICK_WORDSIZE_LOG)
#assert (MAX_CLICK_WORDSIZE <= CHUNK_WORDSIZE)
#print "MAX_CLICK_WORDSIZE = "; #print MAX_CLICK_WORDSIZE; #print "\n"
#define FREEITMLST_ARRAYSIZE (MAX_CLICK_WORDSIZE_LOG + 1)
#define MARKSTACK_PAGESIZE 4000
+ #define NCHUNK_PER_MARKSTACKPAGE 64
+ #define NMARKSTACKPAGE_OVERFLOW_EXTEND 2
#define MARKSTACK_CUTOFF (CHUNK_WORDSIZE / 4)
- #define CHUNK_SWEEP_CUTOFF 0.75
+ #define CHUNK_SWEEP_CUTOFF 0.50
#assert (0.0 <= CHUNK_SWEEP_CUTOFF)
#assert (CHUNK_SWEEP_CUTOFF <= 1.0)
- #define CHUNK_LIMIT_EXTEND_CUTOFF 0.75
- #assert (0.0 <= CHUNK_LIMIT_EXTEND_CUTOFF)
- #assert (CHUNK_LIMIT_EXTEND_CUTOFF <= 1.0)
+ #define TOTWSZ_LIMIT_EXTEND_CUTOFF 0.75
+ #assert (0.0 <= TOTWSZ_LIMIT_EXTEND_CUTOFF)
+ #assert (TOTWSZ_LIMIT_EXTEND_CUTOFF <= 1.0)
#define GLOBALRTS_PAGESIZE 100
#assert (GLOBALRTS_PAGESIZE >= 1)
View
7 ccomp/runtime/GCATS2/gcats2_autmem.dats
@@ -158,12 +158,13 @@ gcats2_autmem_free (
int itmwsz_log ;
chunk_vt *p_chunk ;
freeitmlst_vt *p_itmlst ;
-
+//
p_chunk = (chunk_vt*)gcats2_ptr_isvalid(p_itm, &ofs_chkseg) ;
-
+//
#if (GCATS2_DEBUG > 0)
if (!p_chunk) {
- fprintf(stderr, "gcats2_autmem_free: p_itm = %p\n", p_itm) ;
+ fprintf(stderr, "INTERNAL ERROR") ;
+ fprintf(stderr, ": exit(ATS/GC): gcats2_autmem_free: p_itm = %p\n", p_itm) ;
exit(1) ;
} // end of [if]
#endif // end of [GCATS2_DEBUG]
View
2  ccomp/runtime/GCATS2/gcats2_top.dats
@@ -112,7 +112,7 @@ gcats2_the_sweeplstarr_get_chunk (
/* ****** ****** */
#ifdef _ATS_MULTITHREAD
-__thread
+__thread // thread-local storage
#endif // end of [_ATS_MULTITHREAD]
freeitmlst_vt the_freeitmlstarr[FREEITMLST_ARRAYSIZE] = {0} ;
View
1  ccomp/runtime/ats_prelude.c
@@ -48,6 +48,7 @@
/* ****** ****** */
+// implemented in [prelude/DATS/basics.dats]
extern void ats_exit_errmsg (int err, char *msg) ;
/* ****** ****** */
View
11 libc/CATS/dirent.cats
@@ -41,6 +41,7 @@
#include <errno.h>
#include <sys/types.h>
#include <dirent.h>
+#include <stdio.h> // for [perror]
/* ****** ****** */
@@ -53,6 +54,16 @@ typedef struct dirent ats_dirent_type ;
/* ****** ****** */
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
+
+// implemented in [prelude/CATS/printf.cats]
+extern ats_void_type
+atspre_exit_prerrf(ats_int_type code, ats_ptr_type fmt, ...) ;
+
+/* ****** ****** */
+
static inline
ats_ptr_type
atslib_dirent_d_name_get
View
7 libc/CATS/fcntl.cats
@@ -39,6 +39,7 @@
/* ****** ****** */
#include <fcntl.h>
+#include <stdio.h>
/* ****** ****** */
@@ -52,6 +53,12 @@ extern ssize_t write (int fd, const void *buf, size_t cnt) ;
/* ****** ****** */
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
+
+/* ****** ****** */
+
static inline
ats_int_type
atslib_lor_flag_orflag
View
2  libc/CATS/printf.cats
@@ -72,7 +72,7 @@ atslib_vsnprintf (
, ats_ptr_type fmt
, ats_ref_type arg
) {
- int n ; va_list ap ;
+ int n ;
n = vsnprintf (buf, sz, (char*)fmt, *(va_list*)arg) ;
return n ;
} /* end of [atslib_vsnprintf] */
View
49 libc/CATS/pthread.cats
@@ -1,32 +1,31 @@
/* ******************************************************************* */
-/* /
-/* Applied Type System /
-/* /
-/* Hongwei Xi /
-/* /
+/* */
+/* Applied Type System */
+/* */
+/* Hongwei Xi */
+/* */
/* ******************************************************************* */
/*
- * ATS - Unleashing the Potential of Types!
- *
- * Copyright (C) 2002-2008 Hongwei Xi.
- *
- * ATS is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2.1, or (at your option) any later
- * version.
- *
- * ATS is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with ATS; see the file COPYING. If not, please write to the
- * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- */
+** ATS - Unleashing the Potential of Types!
+**
+** Copyright (C) 2002-2008 Hongwei Xi.
+**
+** ATS is free software; you can redistribute it and/or modify it under
+** the terms of the GNU General Public License as published by the Free
+** Software Foundation; either version 2.1, or (at your option) any later
+** version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without even the implied warranty of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+** for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with ATS; see the file COPYING. If not, please write to the
+** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*/
/* author: Hongwei Xi (hwxi AT cs DOT bu DOT edu) */
View
217 libc/CATS/stdio.cats
@@ -50,6 +50,16 @@ typedef FILE ats_FILE_viewtype ;
/* --------------------------------------- */
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
+
+// implemented in [prelude/CATS/printf.cats]
+extern ats_void_type
+atspre_exit_prerrf(ats_int_type code, ats_ptr_type fmt, ...) ;
+
+/* --------------------------------------- */
+
static inline
ats_void_type
atslib_clearerr(ats_ptr_type fil) {
@@ -70,7 +80,7 @@ atslib_fclose_exn(ats_ptr_type fil) {
int err = fclose((FILE*)fil) ;
if (err < 0) {
perror ("fclose") ;
- ats_exit_errmsg (1, "exit(ATS): [fclose] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [fclose] failed\n") ;
} // end of [if]
return ;
}
@@ -78,21 +88,21 @@ atslib_fclose_exn(ats_ptr_type fil) {
static inline
ats_void_type
atslib_fclose_stdin() {
- atspre_stdin_view_get() ; atslib_fclose_err(stdin) ;
+ atspre_stdin_view_get() ; atslib_fclose_exn(stdin) ;
return ;
}
static inline
ats_void_type
atslib_fclose_stdout() {
- atspre_stdout_view_get() ; atslib_fclose_err(stdout) ;
+ atspre_stdout_view_get() ; atslib_fclose_exn(stdout) ;
return ;
}
static inline
ats_void_type
atslib_fclose_stderr() {
- atspre_stderr_view_get() ; atslib_fclose_err(stderr) ;
+ atspre_stderr_view_get() ; atslib_fclose_exn(stderr) ;
return ;
}
@@ -100,13 +110,17 @@ atslib_fclose_stderr() {
static inline
ats_int_type
-atslib_feof (ats_ptr_type fil) {
+atslib_feof (
+ ats_ptr_type fil
+) {
return feof((FILE*)fil) ;
}
static inline
ats_int_type
-atslib_ferror(ats_ptr_type fil) {
+atslib_ferror(
+ ats_ptr_type fil
+) {
return ferror((FILE*)fil) ;
}
@@ -114,17 +128,21 @@ atslib_ferror(ats_ptr_type fil) {
static inline
ats_int_type
-atslib_fflush_err(ats_ptr_type fil) {
+atslib_fflush_err(
+ ats_ptr_type fil
+) {
return fflush((FILE*)fil) ;
}
static inline
ats_void_type
-atslib_fflush_exn (ats_ptr_type fil) {
+atslib_fflush_exn(
+ ats_ptr_type fil
+) {
int err = fflush((FILE*)fil) ;
if (err < 0) {
perror ("fflush") ;
- ats_exit_errmsg (1, "exit(ATS): [fflush] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [fflush] failed\n") ;
} // end of [if]
return ;
} /* end of [atslib_fflush_exn] */
@@ -156,15 +174,21 @@ atslib_getchar () {
static inline
ats_ptr_type
-atslib_fgets_err
- (ats_ptr_type buf, ats_int_type n, ats_ptr_type fil) {
+atslib_fgets_err (
+ ats_ptr_type buf
+, ats_int_type n
+, ats_ptr_type fil
+) {
return fgets((char*)buf, (int)n, (FILE*)fil) ;
}
static inline
ats_void_type
-atslib_fgets_exn
- (ats_ptr_type buf, ats_int_type n, ats_ptr_type fil) {
+atslib_fgets_exn (
+ ats_ptr_type buf
+, ats_int_type n
+, ats_ptr_type fil
+) {
ats_ptr_type p ;
p = fgets((char*)buf, (int)n, (FILE*)fil) ;
if (!p) {
@@ -172,7 +196,7 @@ atslib_fgets_exn
*(char*)buf = '\000' ; // EOF is reached
} else {
perror ("fgets") ;
- ats_exit_errmsg(1, "exit(ATS): [fgets] failed\n") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [fgets] failed\n") ;
} // end of [if]
} /* end of [if] */
return ;
@@ -188,15 +212,17 @@ atslib_fileno(ats_ptr_type fil) { return fileno((FILE*)fil) ; }
static inline
ats_ptr_type
-atslib_fopen_err
- (ats_ptr_type name, ats_ptr_type mode) {
+atslib_fopen_err (
+ ats_ptr_type name, ats_ptr_type mode
+) {
return fopen((char*)name, (char*)mode) ;
}
static inline
ats_ptr_type
-atslib_fopen_exn
- (ats_ptr_type name, ats_ptr_type mode) {
+atslib_fopen_exn (
+ ats_ptr_type name, ats_ptr_type mode
+) {
FILE *fil = fopen((char*)name, (char*)mode) ;
if (!fil) {
perror ("fopen") ; atspre_exit_prerrf (
@@ -210,15 +236,17 @@ atslib_fopen_exn
static inline
ats_int_type
-atslib_fputc_err
- (ats_char_type c, ats_ptr_type fil) {
+atslib_fputc_err (
+ ats_char_type c, ats_ptr_type fil
+) {
return fputc((unsigned char)c, (FILE*)fil) ;
}
static inline
ats_void_type
-atslib_fputc_exn
- (ats_char_type c, ats_ptr_type fil) {
+atslib_fputc_exn (
+ ats_char_type c, ats_ptr_type fil
+) {
int n = fputc((unsigned char)c, (FILE*)fil) ;
if (n < 0) {
perror ("fputc") ;
@@ -231,13 +259,17 @@ atslib_fputc_exn
static inline
ats_int_type
-atslib_fputs_err(ats_ptr_type s, ats_ptr_type fil) {
+atslib_fputs_err(
+ ats_ptr_type s, ats_ptr_type fil
+) {
return fputs ((char*)s, (FILE*)fil) ;
}
static inline
ats_void_type
-atslib_fputs_exn(ats_ptr_type s, ats_ptr_type fil) {
+atslib_fputs_exn(
+ ats_ptr_type s, ats_ptr_type fil
+) {
int n = fputs ((char*)s, (FILE*)fil) ;
if (n < 0) {
perror ("fputs") ;
@@ -250,28 +282,38 @@ atslib_fputs_exn(ats_ptr_type s, ats_ptr_type fil) {
static inline
ats_size_type
-atslib_fread
- (ats_ptr_type buf, ats_size_type sz, ats_size_type n, ats_ptr_type fil)
+atslib_fread (
+ ats_ptr_type buf
+, ats_size_type sz
+, ats_size_type n
+, ats_ptr_type fil
+)
{
return fread ((void*)buf, sz, n, (FILE*)fil) ;
}
static inline
ats_size_type
-atslib_fread_byte
- (ats_ptr_type buf, ats_size_type n, ats_ptr_type fil) {
+atslib_fread_byte (
+ ats_ptr_type buf
+, ats_size_type n
+, ats_ptr_type fil
+) {
return fread ((void*)buf, 1, n, (FILE*)fil) ;
}
static inline
ats_void_type
-atslib_fread_byte_exn
- (ats_ptr_type buf, ats_size_type ntotal, ats_ptr_type fil) {
+atslib_fread_byte_exn (
+ ats_ptr_type buf
+, ats_size_type ntotal
+, ats_ptr_type fil
+) {
int nread ;
nread = fread ((void*)buf, 1, ntotal, (FILE*)fil) ;
if (nread < ntotal) {
perror ("fread") ;
- ats_exit_errmsg (1, "exit(ATS): [fread] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [fread] failed\n") ;
}
return ;
}
@@ -280,15 +322,21 @@ atslib_fread_byte_exn
static inline
ats_ptr_type
-atslib_freopen_err
- (ats_ptr_type name, ats_ptr_type mode, ats_ptr_type fil) {
+atslib_freopen_err (
+ ats_ptr_type name
+, ats_ptr_type mode
+, ats_ptr_type fil
+) {
return freopen(name, mode, (FILE*)fil) ;
}
static inline
ats_void_type
-atslib_freopen_exn
- (ats_ptr_type name, ats_ptr_type mode, ats_ptr_type fil) {
+atslib_freopen_exn(
+ ats_ptr_type name
+, ats_ptr_type mode
+, ats_ptr_type fil
+) {
FILE *fil_new = freopen(name, mode, (FILE*)fil) ;
if (!fil_new) {
perror ("freopen") ; atspre_exit_prerrf (
@@ -351,13 +399,18 @@ atslib_freopen_stderr
/* --------------------------------------- */
static inline
-ats_int_type atslib_fseek_err
- (ats_ptr_type fil, ats_lint_type offset, ats_int_type whence) {
+ats_int_type
+atslib_fseek_err (
+ ats_ptr_type fil
+, ats_lint_type offset
+, ats_int_type whence
+) {
return fseek ((FILE*)fil, offset, whence) ;
} /* atslib_fseek_err */
static inline
-ats_void_type atslib_fseek_exn (
+ats_void_type
+atslib_fseek_exn (
ats_ptr_type fil
, ats_lint_type offset
, ats_int_type whence
@@ -366,7 +419,7 @@ ats_void_type atslib_fseek_exn (
err = fseek ((FILE*)fil, offset, whence) ;
if (err < 0) {
perror ("fseek") ;
- ats_exit_errmsg (1, "exit(ATS): [fseek] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [fseek] failed\n") ;
}
return ;
} /* end of [atslib_fseek_exn] */
@@ -375,17 +428,21 @@ ats_void_type atslib_fseek_exn (
static inline
ats_lint_type
-atslib_ftell_err
- (ats_ptr_type fil) { return ftell((FILE*)fil) ; }
+atslib_ftell_err(
+ ats_ptr_type fil
+) {
+ return ftell((FILE*)fil) ;
+}
static inline
ats_lint_type
-atslib_ftell_exn
- (ats_ptr_type fil) {
+atslib_ftell_exn(
+ ats_ptr_type fil
+) {
long int ret = ftell((FILE*)fil) ;
if (ret < 0) {
perror ("ftell") ;
- ats_exit_errmsg (1, "exit(ATS): [ftell] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [ftell] failed\n") ;
}
return ret ;
}
@@ -395,15 +452,21 @@ atslib_ftell_exn
static inline
ats_size_type
atslib_fwrite (
- ats_ptr_type buf, ats_size_type sz, ats_size_type n, ats_ptr_type fil
+ ats_ptr_type buf
+, ats_size_type sz
+, ats_size_type n
+, ats_ptr_type fil
) {
return fwrite((void*)buf, sz, n, (FILE*)fil) ;
} /* atslib_fwrite */
static inline
ats_size_type
-atslib_fwrite_byte
- (ats_ptr_type buf, ats_size_type n, ats_ptr_type fil) {
+atslib_fwrite_byte (
+ ats_ptr_type buf
+, ats_size_type n
+, ats_ptr_type fil
+) {
return fwrite((void*)buf, 1, n, (FILE*)fil) ;
} /* atslib_fwrite_byte */
@@ -418,7 +481,7 @@ atslib_fwrite_byte_exn (
nwritten = fwrite((void*)buf, 1, ntotal, (FILE*)fil) ;
if (nwritten < ntotal) {
perror ("fwrite") ;
- ats_exit_errmsg (1, "exit(ATS): [fwrite] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [fwrite] failed\n") ;
}
return ;
} /* end of [atslib_fwrite_all_byte] */
@@ -427,7 +490,9 @@ atslib_fwrite_byte_exn (
static inline
ats_void_type
-atslib_perror(ats_ptr_type msg) {
+atslib_perror(
+ ats_ptr_type msg
+) {
atspre_stderr_view_get () ;
perror ((char*)msg) ;
atspre_stderr_view_set () ;
@@ -438,7 +503,9 @@ atslib_perror(ats_ptr_type msg) {
static inline
ats_int_type
-atslib_putchar (ats_char_type c) {
+atslib_putchar(
+ ats_char_type c
+) {
int i ;
atspre_stdout_view_get () ;
i = putchar((unsigned char)c) ;
@@ -450,7 +517,9 @@ atslib_putchar (ats_char_type c) {
static inline
ats_int_type
-atslib_puts_err (ats_ptr_type str) {
+atslib_puts_err(
+ ats_ptr_type str
+) {
int err ;
atspre_stdout_view_get () ;
err = puts ((char*)str) ;
@@ -460,14 +529,16 @@ atslib_puts_err (ats_ptr_type str) {
static inline
ats_void_type
-atslib_puts_exn (ats_ptr_type str) {
+atslib_puts_exn(
+ ats_ptr_type str
+) {
int err ;
atspre_stdout_view_get () ;
err = puts ((char*)str) ;
atspre_stdout_view_set () ;
if (err < 0) {
perror ("puts") ;
- ats_exit_errmsg (1, "exit(ATS): [remove] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [remove] failed\n") ;
} /* end of [if] */
return ;
} /* end of [atslib_puts_exn] */
@@ -476,17 +547,21 @@ atslib_puts_exn (ats_ptr_type str) {
static inline
ats_int_type
-atslib_remove_err (ats_ptr_type path) {
+atslib_remove_err (
+ ats_ptr_type path
+) {
return remove((char*)path) ;
}
static inline
ats_void_type
-atslib_remove_exn (ats_ptr_type path) {
+atslib_remove_exn(
+ ats_ptr_type path
+) {
int err = remove((char*)path) ;
if (err < 0) {
perror ("remove") ;
- ats_exit_errmsg (1, "exit(ATS): [remove] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [remove] failed\n") ;
}
return ;
}
@@ -495,19 +570,21 @@ atslib_remove_exn (ats_ptr_type path) {
static inline
ats_int_type
-atslib_rename_err
- (ats_ptr_type oldpath, ats_ptr_type newpath) {
+atslib_rename_err (
+ ats_ptr_type oldpath, ats_ptr_type newpath
+) {
return rename((char*)oldpath, (char*)newpath) ;
}
static inline
ats_void_type
-atslib_rename_exn
- (ats_ptr_type oldpath, ats_ptr_type newpath) {
+atslib_rename_exn (
+ ats_ptr_type oldpath, ats_ptr_type newpath
+) {
int err = rename((char*)oldpath, (char*)newpath) ;
if (err < 0) {
perror ("rename") ;
- ats_exit_errmsg (1, "exit: [rename] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [rename] failed\n") ;
}
return ;
}
@@ -516,7 +593,9 @@ atslib_rename_exn
static inline
ats_void_type
-atslib_rewind (ats_ptr_type fil) {
+atslib_rewind (
+ ats_ptr_type fil
+) {
rewind((FILE*)fil) ; return ;
}
@@ -532,7 +611,7 @@ atslib_tmpfile_exn () {
FILE* fil = tmpfile() ;
if (!fil) {
perror ("tmpfile") ;
- ats_exit_errmsg (1, "exit(ATS): [tmpfile] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [tmpfile] failed\n") ;
}
return fil ;
} /* end of [atslib_tmpfile_exn] */
@@ -541,19 +620,21 @@ atslib_tmpfile_exn () {
static inline
ats_int_type
-atslib_ungetc_err
- (ats_char_type c, ats_ptr_type fil) {
+atslib_ungetc_err (
+ ats_char_type c, ats_ptr_type fil
+) {
return ungetc((unsigned char)c, (FILE*)fil) ;
}
static inline
ats_void_type
-atslib_ungetc_exn
- (ats_char_type c, ats_ptr_type fil) {
+atslib_ungetc_exn (
+ ats_char_type c, ats_ptr_type fil
+) {
int err = ungetc((unsigned char)c, (FILE*)fil) ;
if (err < 0) {
perror ("ungetc") ;
- ats_exit_errmsg (1, "exit(ATS): [ungetc] failed\n") ;
+ ats_exit_errmsg (1, (ats_ptr_type)"exit(ATS): [ungetc] failed\n") ;
}
return ;
} /* end of [atslib_ungetc_exn] */
View
12 libc/CATS/stdlib.cats
@@ -47,6 +47,12 @@
/* ****** ****** */
+// implemented in [prelude/CATS/printf.cats]
+extern ats_void_type
+atspre_exit_prerrf(ats_int_type code, ats_ptr_type fmt, ...) ;
+
+/* ****** ****** */
+
static inline
ats_double_type
atslib_atof(const ats_ptr_type s) { return atof(s) ; }
@@ -74,7 +80,7 @@ ats_ptr_type
atslib_getenv_exn (const ats_ptr_type name) {
char *res = getenv(name) ;
if (!name) {
- atspre_exit_prerrf (1, "Exit: [getenv(%s)] failed.\n", name) ;
+ atspre_exit_prerrf (1, "exit(ATS): [getenv(%s)] failed.\n", name) ;
}
return res ;
} /* end of [atslib_getenv_exn] */
@@ -95,7 +101,7 @@ atslib_setenv_exn
int ret = setenv((char*)name, (char*)value, (int)overwrite) ;
if (ret != 0) {
perror ("setenv"); atspre_exit_prerrf (
- 1, "Exit: [setenv(%s, %s, %i)] failed.\n", name, value, overwrite
+ 1, "exit(ATS): [setenv(%s, %s, %i)] failed.\n", name, value, overwrite
) ; // end of [atspre_exit_prerrf]
} /* end of [if] */
return ;
@@ -114,7 +120,7 @@ ats_void_type
atslib_atexit_exn (ats_ptr_type fcn) {
int err ;
err = atexit ((void(*)(void))fcn) ;
- if (err != 0) atspre_exit_prerrf (1, "Exit: [atexit] failed.\n") ;
+ if (err != 0) atspre_exit_prerrf (1, "exit(ATS): [atexit] failed.\n") ;
return ;
} /* end of [atslib_atexit_exn] */
View
18 libc/CATS/unistd.cats
@@ -40,6 +40,7 @@
#include <errno.h>
#include <sys/types.h>
+#include <sys/wait.h> // for [wait]
#include <unistd.h>
/* ****** ****** */
@@ -49,11 +50,16 @@
/* ****** ****** */
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
+
+/* ****** ****** */
+
static inline
ats_pid_type atslib_fork_exn () {
pid_t pid ;
pid = fork () ;
-
if (pid < 0) {
ats_exit_errmsg (errno, "Exit: [fork] failed.\n") ;
}
@@ -64,15 +70,13 @@ ats_pid_type atslib_fork_exn () {
static inline
ats_pid_type
-atslib_wait_with_status (ats_ptr_type p) {
- return wait ((int *)p) ;
-}
+atslib_wait_with_status
+ (ats_ptr_type p) { return wait((int*)p) ; }
+/* end of ... */
static inline
ats_pid_type
-atslib_wait_without_status () {
- return wait ((int *)0) ;
-}
+atslib_wait_without_status () { return wait((int*)0) ; }
/* ****** ****** */
View
40 libc/GL/CATS/gl.cats
@@ -7,26 +7,25 @@
/************************************************************************/
/*
- * ATS - Unleashing the Power of Types!
- *
- * Copyright (C) 2002-2008 Hongwei Xi.
- *
- * ATS is free software; you can redistribute it and/or modify it under
- * the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by the
- * Free Software Foundation; either version 2.1, or (at your option) any
- * later version.
- *
- * ATS is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with ATS; see the file COPYING. If not, please write to the
- * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- */
+** ATS - Unleashing the Power of Types!
+**
+** Copyright (C) 2002-2008 Hongwei Xi.
+**
+** ATS is free software; you can redistribute it and/or modify it under
+** the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by the
+** Free Software Foundation; either version 2.1, or (at your option) any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without even the implied warranty of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+** for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with ATS; see the file COPYING. If not, please write to the
+** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*/
/* ****** ****** */
@@ -65,6 +64,7 @@ typedef GLclampf ats_GLclampf_type ;
/* ****** ****** */
static inline
+ats_int_type
ats_int_of_GLenum (GLenum x) { return x ; }
static inline
View
48 libc/arpa/CATS/inet.cats
@@ -7,26 +7,25 @@
/************************************************************************/
/*
- * ATS - Unleashing the Power of Types!
- *
- * Copyright (C) 2002-2008 Hongwei Xi.
- *
- * ATS is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2.1, or (at your option) any later
- * version.
- *
- * ATS is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with ATS; see the file COPYING. If not, please write to the
- * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- */
+** ATS - Unleashing the Power of Types!
+**
+** Copyright (C) 2002-2008 Hongwei Xi.
+**
+** ATS is free software; you can redistribute it and/or modify it under
+** the terms of the GNU General Public License as published by the Free
+** Software Foundation; either version 2.1, or (at your option) any later
+** version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without even the implied warranty of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+** for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with ATS; see the file COPYING. If not, please write to the
+** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*/
/* ****** ****** */
@@ -41,6 +40,13 @@
#include <arpa/inet.h>
#include <netinet/in.h>
+#include <stdio.h> // for [perror]
+
+/* ****** ****** */
+
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
/* ****** ****** */
@@ -52,7 +58,7 @@ atslib_inet_aton_string_exn (ats_ptr_type cp, ats_ref_type inp) {
perror ("inet_aton"); ats_exit_errmsg(1, "Exit: [inet_aton] failed.\n");
}
return ;
-} /* end of [atslib_inet_aton_string_exn]
+} /* end of [atslib_inet_aton_string_exn] */
static inline
ats_ptr_type // this function is not reentrant
View
205 libc/sys/CATS/socket.cats
@@ -7,26 +7,25 @@
/************************************************************************/
/*
- * ATS - Unleashing the Power of Types!
- *
- * Copyright (C) 2002-2008 Hongwei Xi.
- *
- * ATS is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2.1, or (at your option) any later
- * version.
- *
- * ATS is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with ATS; see the file COPYING. If not, please write to the
- * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- */
+** ATS - Unleashing the Power of Types!
+**
+** Copyright (C) 2002-2008 Hongwei Xi.
+**
+** ATS is free software; you can redistribute it and/or modify it under
+** the terms of the GNU General Public License as published by the Free
+** Software Foundation; either version 2.1, or (at your option) any later
+** version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without even the implied warranty of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+** for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with ATS; see the file COPYING. If not, please write to the
+** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*/
/* ****** ****** */
@@ -44,6 +43,8 @@
#include <netinet/in.h>
#include <sys/socket.h>
+#include <stdio.h> // for [perror]
+
/* ****** ****** */
// [memset] is in [string.h]
@@ -51,125 +52,163 @@ extern void *memset(void *s, int c, size_t n);
/* ****** ****** */
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
+
+/* ****** ****** */
+
typedef int socket_type_t ;
typedef int address_family_t ;
+/* ****** ****** */
+
static inline
ats_int_type
-atslib_socket_family_type_err (address_family_t af, socket_type_t st) {
+atslib_socket_family_type_err (
+ address_family_t af, socket_type_t st
+) {
return socket(af, st, 0) ;
-}
+} /* end of [atslib_socket_family_type_err] */
static inline
ats_int_type
-atslib_socket_family_type_exn (address_family_t af, socket_type_t st) {
+atslib_socket_family_type_exn (
+ address_family_t af, socket_type_t st
+) {
int res ;
res = socket(af, st, 0) ;
if (res < 0) {
- perror("socket"); ats_exit_errmsg(1, "exit(ATS): [socket] failed.\n");
+ perror("socket");
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [socket] failed.\n");
}
return res ;
-}
+} /* end of [atslib_socket_family_type_exn] */
/* ****** ****** */
static inline
-ats_void_type atslib_sockaddr_ipv4_init
- (ats_ptr_type sa0, address_family_t af, in_addr_t inp, in_port_t port) {
+ats_void_type
+atslib_sockaddr_ipv4_init (
+ ats_ptr_type sa0
+, address_family_t af
+, in_addr_t inp
+, in_port_t port
+) {
struct sockaddr_in *sa = sa0 ;
memset(sa, 0, sizeof (struct sockaddr_in)) ;
sa->sin_family = af ;
sa->sin_addr.s_addr = inp ;
sa->sin_port = port ;
-} /* end of [sockaddr_ipv4_init]
+} /* end of [sockaddr_ipv4_init] */
/* ****** ****** */
static inline
-ats_int_type atslib_connect_ipv4_err
- (ats_int_type fd, ats_ref_type servaddr) {
+ats_int_type
+atslib_connect_ipv4_err (
+ ats_int_type fd, ats_ref_type servaddr
+) {
return connect(fd, (struct sockaddr*)servaddr, sizeof(struct sockaddr_in)) ;
-}
+} /* end of [atslib_connect_ipv4_err] */
static inline
-ats_void_type atslib_connect_ipv4_exn
- (ats_int_type fd, ats_ref_type servaddr) {
+ats_void_type
+atslib_connect_ipv4_exn (
+ ats_int_type fd, ats_ref_type servaddr
+) {
int err ;
err = connect(fd, (struct sockaddr*)servaddr, sizeof(struct sockaddr_in)) ;
if (err < 0) {
- perror("connect") ; ats_exit_errmsg(1, "exit(ATS): [connect] failed.\n");
+ perror("connect") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [connect] failed.\n");
}
return ;
-}
+} /* end of [atslib_connect_ipv4_exn] */
/* ****** ****** */
static inline
-ats_int_type atslib_bind_ipv4_err
- (ats_int_type fd, ats_ref_type servaddr) {
+ats_int_type
+atslib_bind_ipv4_err (
+ ats_int_type fd, ats_ref_type servaddr
+) {
return bind(fd, (struct sockaddr *)servaddr, sizeof(struct sockaddr_in));
-} /* atslib_bind_ipv4_err */
+} /* end of [atslib_bind_ipv4_err] */
static inline
-ats_void_type atslib_bind_ipv4_exn
- (ats_int_type fd, ats_ref_type servaddr) {
+ats_void_type
+atslib_bind_ipv4_exn (
+ ats_int_type fd, ats_ref_type servaddr
+) {
int err ;
err = bind(fd, (struct sockaddr *)servaddr, sizeof(struct sockaddr_in));
if (err < 0) {
- perror("bind"); ats_exit_errmsg(1, "exit(ATS): [bind] failed.\n");
+ perror("bind");
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [bind] failed.\n");
}
return ;
-} /* atslib_bind_ipv4_exn */
+} /* end of [atslib_bind_ipv4_exn] */
/* ****** ****** */
static inline
-ats_int_type atslib_listen_err
- (ats_int_type fd, ats_int_type backlog) {
+ats_int_type
+atslib_listen_err (
+ ats_int_type fd, ats_int_type backlog
+) {
return listen (fd, backlog) ;
-} /* atslib_listen_err */
+} /* end of [atslib_listen_err] */
static inline
-ats_void_type atslib_listen_exn
- (ats_int_type fd, ats_int_type backlog) {
+ats_void_type atslib_listen_exn (
+ ats_int_type fd, ats_int_type backlog
+) {
int err = listen (fd, backlog) ;
if (err < 0) {
- perror("listen") ; ats_exit_errmsg(1, "exit(ATS): [listen] failed.\n") ;
+ perror("listen") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [listen] failed.\n") ;
}
return ;
-} /* atslib_listen_exn */
+} /* end of [atslib_listen_exn] */
/* ****** ****** */
static inline
ats_int_type
-atslib_accept_null_err (ats_int_type fd_s) {
+atslib_accept_null_err (
+ ats_int_type fd_s
+) {
return accept(fd_s, (struct sockaddr *)0, (socklen_t *)0) ;
-} /* atslib_accept_null_err */
+} /* end of [atslib_accept_null_err] */
static inline
-ats_int_type atslib_accept_null_exn (ats_int_type fd_s) {
+ats_int_type
+atslib_accept_null_exn (ats_int_type fd_s) {
int fd_c ;
fd_c = accept(fd_s, (struct sockaddr *)0, (socklen_t *)0) ;
if (fd_c < 0) {
- perror("accept"); ats_exit_errmsg(1, "exit(ATS): [accept] failed.\n");
+ perror("accept");
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [accept] failed.\n");
}
return fd_c;
-} /* atslib_accept_null_exn */
+} /* end of [atslib_accept_null_exn] */
//
static inline
-ats_int_type atslib_accept_ipv4_exn
- (ats_int_type fd_s, ats_ref_type cliaddr, ats_ref_type addrlen) {
+ats_int_type atslib_accept_ipv4_exn (
+ ats_int_type fd_s, ats_ref_type cliaddr, ats_ref_type addrlen
+) {
int fd_c ;
*(socklen_t *)addrlen = sizeof (struct sockaddr_in) ;
fd_c = accept(fd_s, (struct sockaddr *)cliaddr, (socklen_t *)addrlen) ;
if (fd_c < 0) {
- perror("accept"); ats_exit_errmsg(1, "exit(ATS): [accept] failed.\n");
+ perror("accept");
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [accept] failed.\n");
}
return fd_c;
-} /* atslib_accept_ipv4_exn */
+} /* end of [atslib_accept_ipv4_exn] */
/* ****** ****** */
@@ -179,34 +218,40 @@ atslib_socket_close_err(ats_int_type fd) { return close(fd) ; }
static inline
ats_void_type
-atslib_socket_close_exn(ats_int_type fd) {
+atslib_socket_close_exn (
+ ats_int_type fd
+) {
int res = close(fd) ;
if (res < 0) {
- perror("close") ; ats_exit_errmsg(1, "exit(ATS): [socket_close] failed.\n") ;
+ perror("close") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [socket_close] failed.\n") ;
}
return ;
-} /* atslib_socket_close_exn */
+} /* end of [atslib_socket_close_exn] */
/* ****** ****** */
static inline
ats_ssize_type
-atslib_socket_read_err
- (ats_int_type fd, ats_ptr_type buf, ats_size_type cnt) {
+atslib_socket_read_err (
+ ats_int_type fd, ats_ptr_type buf, ats_size_type cnt
+) {
return read(fd, buf, cnt) ;
-} /* atslib_socket_read_err */
+} /* end of [atslib_socket_read_err] */
static inline
ats_size_type
-atslib_socket_read_exn
- (ats_int_type fd, ats_ptr_type buf, ats_size_type cnt) {
+atslib_socket_read_exn (
+ ats_int_type fd, ats_ptr_type buf, ats_size_type cnt
+) {
ats_ssize_type res ;
res = read(fd, buf, cnt) ;
if (res < 0) {
- perror("read") ; ats_exit_errmsg(1, "exit(ATS): [socket_read] failed.\n") ;
+ perror("read") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [socket_read] failed.\n") ;
}
return res ;
-} /* atslib_socket_read_exn */
+} /* end of [atslib_socket_read_exn] */
/* ****** ****** */
@@ -217,33 +262,37 @@ atslib_socket_write_exn
ats_ssize_type res ;
res = write(fd, buf, cnt) ;
if (res < 0) {
- perror("write") ; ats_exit_errmsg(1, "exit(ATS): [socket_write] failed.\n") ;
+ perror("write") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [socket_write] failed.\n") ;
}
return res ;
-} /* atslib_socket_write_exn */
+} /* end of [atslib_socket_write_exn] */
/* ****** ****** */
static inline
ats_ssize_type
-atslib_socket_write_substring_err
- (ats_int_type fd, ats_ptr_type str, ats_size_type start, ats_size_type len)
-{
+atslib_socket_write_substring_err (
+ ats_int_type fd, ats_ptr_type str
+, ats_size_type start, ats_size_type len
+) {
return write(fd, ((char*)str)+start, len) ;
}
static inline
ats_size_type
-atslib_socket_write_substring_exn
- (ats_int_type fd, ats_ptr_type str, ats_size_type start, ats_size_type n)
-{
+atslib_socket_write_substring_exn (
+ ats_int_type fd, ats_ptr_type str
+, ats_size_type start, ats_size_type n
+) {
ats_ssize_type res ;
res = write(fd, ((char*)str)+start, n) ;
if (res < 0) {
- perror("write") ; ats_exit_errmsg(1, "exit(ATS): [socket_write] failed.\n") ;
+ perror("write") ;
+ ats_exit_errmsg(1, (ats_ptr_type)"exit(ATS): [socket_write] failed.\n") ;
}
return res ;
-} /* ats_socket_write_substring_exn */
+} /* end of [atslib_socket_write_substring_exn] */
/* ****** ****** */
View
7 libc/sys/CATS/stat.cats
@@ -38,6 +38,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <stdio.h> // for [perror]
/* ****** ****** */
@@ -50,6 +51,12 @@ typedef struct stat ats_stat_type ;
/* ****** ****** */
+// implemented in [prelude/DATS/basics.dats]
+extern ats_void_type
+ats_exit_errmsg(ats_int_type n, ats_ptr_type msg) ;
+
+/* ****** ****** */
+
static inline
ats_dev_type
atslib_stat_st_dev_get (ats_ptr_type buf) {
View
4 prelude/CATS/char.cats
@@ -207,7 +207,9 @@ atspre_char_isascii (ats_char_type c) { return isascii(c) ; }
/* ****** ****** */
-extern int isblank (int c) ;
+#ifndef isblank
+extern int isblank(int c) ; // declared in ctype.h
+#endif
static inline
ats_bool_type
View
37 prelude/CATS/integer.cats
@@ -472,54 +472,59 @@ atspre_lxor_uint_uint (ats_uint_type x, ats_uint_type y) {
static inline
ats_uint_type
-atspre_lsl_uint_int1 (ats_uint_type i, ats_int_type n) {
- return i << n ;
+atspre_lsl_uint_int1 (ats_uint_type u, ats_int_type n) {
+ return (u << n) ;
}
static inline
ats_uint_type
-atspre_lsr_uint_int1 (ats_uint_type i, ats_int_type n) {
- return i >> n ;
+atspre_lsr_uint_int1 (ats_uint_type u, ats_int_type n) {
+ return (u >> n) ;
}
// print functions
static inline
ats_void_type
-atspre_fprint_uint (ats_ptr_type out, ats_uint_type i) {
- int n = fprintf ((FILE*)out, "%u", i) ;
+atspre_fprint_uint (ats_ptr_type out, ats_uint_type u) {
+ int n = fprintf ((FILE*)out, "%u", u) ;
if (n < 0) {
ats_exit_errmsg (n, (ats_ptr_type)"exit(ATS): [fprint_uint] failed.\n") ;
}
return ;
-}
+} /* end of [atspre_fprint_uint] */
static inline
ats_void_type
-atspre_print_uint (ats_uint_type i) {
+atspre_print_uint (
+ ats_uint_type u
+) {
atspre_stdout_view_get () ;
- atspre_fprint_uint((ats_ptr_type)stdout, i) ;
+ atspre_fprint_uint((ats_ptr_type)stdout, u) ;
atspre_stdout_view_set () ;
return ;
-}
+} /* end of [atspre_print_uint] */
static inline
ats_void_type
-atspre_prerr_uint (ats_uint_type i) {
+atspre_prerr_uint (
+ ats_uint_type u
+) {
atspre_stderr_view_get () ;
- atspre_fprint_uint((ats_ptr_type)stderr, i) ;
+ atspre_fprint_uint((ats_ptr_type)stderr, u) ;
atspre_stderr_view_set () ;
return ;
-}
+} /* end of [atspre_prerr_uint] */
//
static inline
ats_ptr_type
-atspre_tostring_uint
- (ats_uint_type u) {
+atspre_tostring_uint (
+ ats_uint_type u
+) {
return atspre_tostring_ullint (u) ;
-}
+} /* end of [atspre_tostring_uint] */
/* ****** ****** */
View
24 prelude/CATS/sizetype.cats
@@ -106,6 +106,20 @@ atspre_size1_of_ptrdiff1 (ats_ptrdiff_type x) { return (ats_size_type)x ; }
/* ****** ****** */
+static inline
+ats_size_type
+atspre_lsl_size_int1 (ats_size_type sz, ats_int_type n) {
+ return (sz << n) ;
+}
+
+static inline
+ats_size_type
+atspre_lsr_size_int1 (ats_size_type sz, ats_int_type n) {
+ return (sz >> n) ;
+}
+
+/* ****** ****** */
+
// print functions
static inline
@@ -352,8 +366,9 @@ static inline
ats_int_type
atspre_int1_of_ssize1 (ats_ssize_type ssz) {
if (INT_MAX < ssz || ssz < INT_MIN) {
- fprintf (stderr, "[ats_int1_of_ssize1(%li)] failed\n", (ats_lint_type)ssz) ;
- exit (1) ;
+ fprintf (stderr,
+ "exit(ATS): [ats_int1_of_ssize1(%li)] failed\n", (ats_lint_type)ssz
+ ) ; exit (1) ;
} /* end of [if] */
return (ats_int_type)ssz ;
} /* end of [atspre_int1_of_ssize1] */
@@ -367,8 +382,9 @@ static inline
ats_ssize_type atspre_ssize1_of_size1 (ats_size_type sz) {
ats_ssize_type ssz = sz ;
if (ssz < 0) {
- fprintf (stderr, "[ats_ssize1_of_size1(%lu)] failed\n", (ats_ulint_type)sz) ;
- exit (1) ;
+ fprintf (stderr,
+ "exit(ATS): [ats_ssize1_of_size1(%lu)] failed\n", (ats_ulint_type)sz
+ ) ; exit (1) ;
} /* end of [if] */
return ssz ;
} /* end of [atspre_ssize1_of_size1] */
View
16 prelude/DATS/basics.dats
@@ -62,14 +62,14 @@ ats_void_type // external
ats_exit(const ats_int_type status) { exit(status) ; return ; }
ats_void_type // external
-ats_exit_errmsg
- (const ats_int_type status, const ats_ptr_type errmsg)
-{
+ats_exit_errmsg (
+ const ats_int_type status, const ats_ptr_type errmsg
+) {
fprintf(stderr, "%s", (char*)errmsg) ; exit(status) ;
return ; // deadcode
-}
+} /* end of [ats_exit_errmsg] */
-%}
+%} // end of [%{]
(* ****** ****** *)
@@ -78,7 +78,9 @@ ats_exit_errmsg
/* functions for asserts */
ats_void_type
-atspre_assert (const ats_bool_type assertion) {
+atspre_assert (
+ const ats_bool_type assertion
+) {
if (!assertion) {
fprintf (stderr, "exit(ATS): [assert] failed\n") ; exit(1) ;
}
@@ -95,7 +97,7 @@ atspre_assert_errmsg (
return ;
} /* end of [atspre_assert_errmsg] */
-%}
+%} // end of [%{]
(* ****** ****** *)
View
2  prelude/DATS/printf.dats
@@ -74,7 +74,7 @@ ats_void_type atspre_assert_prerrf
return ;
} /* end of [atspre_assert_prerrf] */
-%}
+%} // end of [%{]
(* ****** ****** *)
View
48 src/ats_counter.cats
@@ -7,27 +7,27 @@
/***********************************************************************/
/*
- * ATS/Anairiats - Unleashing the Potential of Types!
- *
- * Copyright (C) 2002-2008 Hongwei Xi.
- *
- * All rights reserved
- *
- * ATS is free software; you can redistribute it and/or modify it under
- * the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
- * Free Software Foundation; either version 3, or (at your option) any
- * later version.
- *
- * ATS is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with ATS; see the file COPYING. If not, please write to the
- * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
+** ATS/Anairiats - Unleashing the Potential of Types!
+**
+** Copyright (C) 2002-2008 Hongwei Xi.
+**
+** All rights reserved
+**
+** ATS is free software; you can redistribute it and/or modify it under
+** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at your option) any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without even the implied warranty of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+** for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with ATS; see the file COPYING. If not, please write to the
+** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*/
/* ****** ****** */
@@ -132,7 +132,7 @@ static inline
ats_void_type
ats_counter_fprint_count
(ats_ptr_type out, ats_counter_count_type cnt) {
- fprintf ((FILE*)out, "%lli", cnt) ; return ;
+ fprintf ((FILE*)out, "%lli", (ats_llint_type)cnt) ; return ;
}
/* ****** ****** */
@@ -142,14 +142,14 @@ extern ats_ptr_type atspre_tostringf (ats_ptr_type format, ...) ;
static inline
ats_ptr_type
ats_counter_tostring_count (ats_counter_count_type cnt) {
- return atspre_tostringf ("%lli", cnt) ;
+ return atspre_tostringf ("%lli", (ats_llint_type)cnt) ;
}
static inline
ats_ptr_type
ats_counter_tostring_count_prefix
(ats_ptr_type pre, ats_counter_count_type cnt) {
- return atspre_tostringf ("%s%lli", (char *)pre, cnt) ;
+ return atspre_tostringf ("%s%lli", (char*)pre, (ats_llint_type)cnt) ;
}
/* ****** ****** */
View
7 src/ats_grammar.yats
@@ -1706,8 +1706,8 @@ guad0ec_t guad0ec ;
%%
main
- : ISSTATIC d0ecseq_sta TOKEN_eof { $$ = $2 ; return ; }
- | ISDYNAMIC d0ecseq_dyn TOKEN_eof { $$ = $2 ; return ; }
+ : ISSTATIC d0ecseq_sta TOKEN_eof { $$ = $2 ; return 0 ; }
+ | ISDYNAMIC d0ecseq_dyn TOKEN_eof { $$ = $2 ; return 0 ; }
;
/* ****** ****** */
@@ -3262,7 +3262,8 @@ void yyerror (char *s) {
return ;
} /* end of [yyerror] */
-ats_ptr_type yyparse_main (ats_int_type tok0) {
+ats_ptr_type
+yyparse_main (ats_int_type tok0) {
// must take care of garbage collection
View
2  src/libats_lex_lexing.dats
@@ -597,7 +597,7 @@ lexing_curpos_get () {
ats_void_type
lexbuf_curpos_fprint (ats_ptr_type fil, lexbuf *lxbf) {
- fprintf ((FILE *)fil, "%i(line=%i, offset=%i)",
+ fprintf ((FILE *)fil, "%li(line=%i, offset=%i)",
lxbf->curpos_toff+1, lxbf->curpos_line+1, lxbf->curpos_loff+1
) ;
return ;
Please sign in to comment.
Something went wrong with that request. Please try again.