aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-15 22:32:01 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-15 22:32:01 +0000
commit8c8218e3e565c642775cfcb43bd4cfc5838e06a4 (patch)
tree66dd55ece786a727590a6b15552c619a0f209d23 /libgfortran
parent99d8a3b4140478966819f5d6f7f62d631d89a791 (diff)
2003-08-15 Arnaud Desitter <arnaud.desitter@geography.oxford.ac.uk>
* libgfortran.h (os_error, runtime_error,internal_error, sys_exit, get_mem ): Add attribute. * intrinsics/spread_generic.c (__spread): Fix spelling. * io/inquire.c (inquire_via_filename): Add const. * io/io.h (sys_exit): Add attribute. * io/io.h (move_pos_offset): Add move_pos_offset. * io/io.h (compare_file_filename, inquire_sequential, inquire_direct, inquire_formatted, inquire_unformatted, inquire_read, inquire_write, inquire_readwrite, convert_real, write_a, write_b, write_d, write_e, write_en, write_es, write_f, write_i, write_l, write_o, write_x, write_z): Add const. * io/read.c (convert_real): Add const. * io/transfer.c (type_name): Add const. * io/unix.c (unpack_filename, compare_file_filename,inquire_sequential, inquire_direct, inquire_formatted, inquire_unformatted, inquire_access, inquire_read, inquire_write, inquire_readwrite): Add const. * io/write.c (output_float): Remove unused variable. * io/write.c (write_a, extract_int, extract_real, output_float, write_float, write_int, write_i, write_b, write_o, write_z, write_d, write_e, write_f, write_en, write_es, write_logical, write_integer, write_character, write_real, write_complex): Add const. * runtime/error.c (rtoa): Remove unused variable. * runtime/select.c (select_string): Add const. * runtime/stop.c (stop_string): Add const. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@70493 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog27
-rw-r--r--libgfortran/intrinsics/spread_generic.c2
-rw-r--r--libgfortran/io/inquire.c2
-rw-r--r--libgfortran/io/io.h43
-rw-r--r--libgfortran/io/read.c2
-rw-r--r--libgfortran/io/transfer.c2
-rw-r--r--libgfortran/io/unix.c38
-rw-r--r--libgfortran/io/write.c61
-rw-r--r--libgfortran/libgfortran.h27
-rw-r--r--libgfortran/runtime/error.c3
-rw-r--r--libgfortran/runtime/select.c2
-rw-r--r--libgfortran/runtime/stop.c2
12 files changed, 118 insertions, 93 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 748e32d3ff9..b47faeb098c 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,30 @@
+2003-08-15 Arnaud Desitter <arnaud.desitter@geography.oxford.ac.uk>
+
+ * libgfortran.h (os_error, runtime_error,internal_error, sys_exit,
+ get_mem ): Add attribute.
+ * intrinsics/spread_generic.c (__spread): Fix spelling.
+ * io/inquire.c (inquire_via_filename): Add const.
+ * io/io.h (sys_exit): Add attribute.
+ * io/io.h (move_pos_offset): Add move_pos_offset.
+ * io/io.h (compare_file_filename, inquire_sequential, inquire_direct,
+ inquire_formatted, inquire_unformatted, inquire_read, inquire_write,
+ inquire_readwrite, convert_real, write_a, write_b, write_d, write_e,
+ write_en, write_es, write_f, write_i, write_l, write_o, write_x,
+ write_z): Add const.
+ * io/read.c (convert_real): Add const.
+ * io/transfer.c (type_name): Add const.
+ * io/unix.c (unpack_filename, compare_file_filename,inquire_sequential,
+ inquire_direct, inquire_formatted, inquire_unformatted, inquire_access,
+ inquire_read, inquire_write, inquire_readwrite): Add const.
+ * io/write.c (output_float): Remove unused variable.
+ * io/write.c (write_a, extract_int, extract_real, output_float,
+ write_float, write_int, write_i, write_b, write_o, write_z, write_d,
+ write_e, write_f, write_en, write_es, write_logical, write_integer,
+ write_character, write_real, write_complex): Add const.
+ * runtime/error.c (rtoa): Remove unused variable.
+ * runtime/select.c (select_string): Add const.
+ * runtime/stop.c (stop_string): Add const.
+
2003-08-10 Paul Brook <paul@nowt.org>
* Makefile.am (gfor_helper_src): Add intrinsics/abort.c.
diff --git a/libgfortran/intrinsics/spread_generic.c b/libgfortran/intrinsics/spread_generic.c
index dbc1f387ded..3024745dc53 100644
--- a/libgfortran/intrinsics/spread_generic.c
+++ b/libgfortran/intrinsics/spread_generic.c
@@ -96,7 +96,7 @@ __spread (const g95_array_char * ret, const g95_array_char * source,
the next dimension. */
count[n] = 0;
/* We could precalculate these products, but this is a less
- frequently used path so proabably not worth it. */
+ frequently used path so probably not worth it. */
sptr -= sstride[n] * extent[n];
rptr -= rstride[n] * extent[n];
n++;
diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c
index 7a5b306915b..86fe0f3a273 100644
--- a/libgfortran/io/inquire.c
+++ b/libgfortran/io/inquire.c
@@ -260,7 +260,7 @@ inquire_via_unit (unit_t * u)
static void
inquire_via_filename (void)
{
- char *p;
+ const char *p;
if (ioparm.exist != NULL)
*ioparm.exist = file_exists ();
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h
index ef321f8cf4a..feb738bd24f 100644
--- a/libgfortran/io/io.h
+++ b/libgfortran/io/io.h
@@ -343,7 +343,10 @@ fnode;
/* unix.c */
#define sys_exit prefix(sys_exit)
-void sys_exit (int);
+void sys_exit (int) __attribute__ ((noreturn));
+
+#define move_pos_offset prefix(move_pos_offset)
+int move_pos_offset (stream *, int);
#define get_oserror prefix(get_oserror)
const char *get_oserror (void);
@@ -367,7 +370,7 @@ stream *input_stream (void);
stream *output_stream (void);
#define compare_file_filename prefix(compare_file_filename)
-int compare_file_filename (stream *, char *, int);
+int compare_file_filename (stream *, const char *, int);
#define find_file prefix(find_file)
unit_t *find_file (void);
@@ -385,25 +388,25 @@ int delete_file (unit_t *);
int file_exists (void);
#define inquire_sequential prefix(inquire_sequential)
-char *inquire_sequential (char *, int);
+const char *inquire_sequential (const char *, int);
#define inquire_direct prefix(inquire_direct)
-char *inquire_direct (char *, int);
+const char *inquire_direct (const char *, int);
#define inquire_formatted prefix(inquire_formatted)
-char *inquire_formatted (char *, int);
+const char *inquire_formatted (const char *, int);
#define inquire_unformatted prefix(inquire_unformatted)
-char *inquire_unformatted (char *, int);
+const char *inquire_unformatted (const char *, int);
#define inquire_read prefix(inquire_read)
-char *inquire_read (char *, int);
+const char *inquire_read (const char *, int);
#define inquire_write prefix(inquire_write)
-char *inquire_write (char *, int);
+const char *inquire_write (const char *, int);
#define inquire_readwrite prefix(inquire_readwrite)
-char *inquire_readwrite (char *, int);
+const char *inquire_readwrite (const char *, int);
#define file_length prefix(file_length)
offset_t file_length (stream *);
@@ -496,7 +499,7 @@ void set_integer (void *, int, int);
unsigned max_value (int, int);
#define convert_real prefix(convert_real)
-int convert_real (void *, char *, int);
+int convert_real (void *, const char *, int);
#define read_a prefix(read_a)
void read_a (fnode *, char *, int);
@@ -527,40 +530,40 @@ void finish_list_read (void);
/* write.c */
#define write_a prefix(write_a)
-void write_a (fnode *, char *, int);
+void write_a (fnode *, const char *, int);
#define write_b prefix(write_b)
-void write_b (fnode *, char *, int);
+void write_b (fnode *, const char *, int);
#define write_d prefix(write_d)
-void write_d (fnode *, char *, int);
+void write_d (fnode *, const char *, int);
#define write_e prefix(write_e)
-void write_e (fnode *, char *, int);
+void write_e (fnode *, const char *, int);
#define write_en prefix(write_en)
-void write_en (fnode *, char *, int);
+void write_en (fnode *, const char *, int);
#define write_es prefix(write_es)
-void write_es (fnode *, char *, int);
+void write_es (fnode *, const char *, int);
#define write_f prefix(write_f)
-void write_f (fnode *, char *, int);
+void write_f (fnode *, const char *, int);
#define write_i prefix(write_i)
-void write_i (fnode *, char *, int);
+void write_i (fnode *, const char *, int);
#define write_l prefix(write_l)
void write_l (fnode *, char *, int);
#define write_o prefix(write_o)
-void write_o (fnode *, char *, int);
+void write_o (fnode *, const char *, int);
#define write_x prefix(write_x)
void write_x (fnode *);
#define write_z prefix(write_z)
-void write_z (fnode *, char *, int);
+void write_z (fnode *, const char *, int);
#define list_formatted_write prefix(list_formatted_write)
void list_formatted_write (bt, void *, int);
diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c
index d184451c73c..325502f56ac 100644
--- a/libgfortran/io/read.c
+++ b/libgfortran/io/read.c
@@ -88,7 +88,7 @@ max_value (int length, int signed_flag)
* rounding. */
int
-convert_real (void *dest, char *buffer, int length)
+convert_real (void *dest, const char *buffer, int length)
{
errno = 0;
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index f5d11c0f271..91bdc737334 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -273,7 +273,7 @@ unformatted_write (bt type, void *source, int length)
const char *
type_name (bt type)
{
- char *p;
+ const char *p;
switch (type)
{
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 7e7a388bb7d..bae8dfbce8e 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -862,7 +862,7 @@ fd_to_stream (int fd, int prot)
* C string in the buffer. Returns nonzero if this is not possible. */
static int
-unpack_filename (char *cstring, char *fstring, int len)
+unpack_filename (char *cstring, const char *fstring, int len)
{
len = fstrlen (fstring, len);
@@ -1074,7 +1074,7 @@ init_error_stream (void)
* filename. */
int
-compare_file_filename (stream * s, char *name, int len)
+compare_file_filename (stream * s, const char *name, int len)
{
char path[PATH_MAX + 1];
struct stat st1, st2;
@@ -1212,14 +1212,14 @@ file_exists (void)
-static char yes[] = "YES", no[] = "NO", unknown[] = "UNKNOWN";
+static const char *yes = "YES", *no = "NO", *unknown = "UNKNOWN";
/* inquire_sequential()-- Given a fortran string, determine if the
* file is suitable for sequential access. Returns a C-style
* string. */
-char *
-inquire_sequential (char *string, int len)
+const char *
+inquire_sequential (const char *string, int len)
{
char path[PATH_MAX + 1];
struct stat statbuf;
@@ -1242,8 +1242,8 @@ inquire_sequential (char *string, int len)
/* inquire_direct()-- Given a fortran string, determine if the file is
* suitable for direct access. Returns a C-style string. */
-char *
-inquire_direct (char *string, int len)
+const char *
+inquire_direct (const char *string, int len)
{
char path[PATH_MAX + 1];
struct stat statbuf;
@@ -1266,8 +1266,8 @@ inquire_direct (char *string, int len)
/* inquire_formatted()-- Given a fortran string, determine if the file
* is suitable for formatted form. Returns a C-style string. */
-char *
-inquire_formatted (char *string, int len)
+const char *
+inquire_formatted (const char *string, int len)
{
char path[PATH_MAX + 1];
struct stat statbuf;
@@ -1291,8 +1291,8 @@ inquire_formatted (char *string, int len)
/* inquire_unformatted()-- Given a fortran string, determine if the file
* is suitable for unformatted form. Returns a C-style string. */
-char *
-inquire_unformatted (char *string, int len)
+const char *
+inquire_unformatted (const char *string, int len)
{
return inquire_formatted (string, len);
@@ -1302,8 +1302,8 @@ inquire_unformatted (char *string, int len)
/* inquire_access()-- Given a fortran string, determine if the file is
* suitable for access. */
-static char *
-inquire_access (char *string, int len, int mode)
+static const char *
+inquire_access (const char *string, int len, int mode)
{
char path[PATH_MAX + 1];
@@ -1318,8 +1318,8 @@ inquire_access (char *string, int len, int mode)
/* inquire_read()-- Given a fortran string, determine if the file is
* suitable for READ access. */
-char *
-inquire_read (char *string, int len)
+const char *
+inquire_read (const char *string, int len)
{
return inquire_access (string, len, R_OK);
@@ -1329,8 +1329,8 @@ inquire_read (char *string, int len)
/* inquire_write()-- Given a fortran string, determine if the file is
* suitable for READ access. */
-char *
-inquire_write (char *string, int len)
+const char *
+inquire_write (const char *string, int len)
{
return inquire_access (string, len, W_OK);
@@ -1340,8 +1340,8 @@ inquire_write (char *string, int len)
/* inquire_readwrite()-- Given a fortran string, determine if the file is
* suitable for read and write access. */
-char *
-inquire_readwrite (char *string, int len)
+const char *
+inquire_readwrite (const char *string, int len)
{
return inquire_access (string, len, R_OK | W_OK);
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 73d919cce28..bc032231cdf 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -34,7 +34,7 @@ sign_t;
void
-write_a (fnode * f, char *source, int len)
+write_a (fnode * f, const char *source, int len)
{
int wlen;
char *p;
@@ -67,23 +67,23 @@ write_l (fnode * f, char *p, int len)
}
static int
-extract_int (void *p, int len)
+extract_int (const void *p, int len)
{
int i = 0;
switch (len)
{
case 1:
- i = *((int8_t *) p);
+ i = *((const int8_t *) p);
break;
case 2:
- i = *((int16_t *) p);
+ i = *((const int16_t *) p);
break;
case 4:
- i = *((int32_t *) p);
+ i = *((const int32_t *) p);
break;
case 8:
- i = *((int64_t *) p);
+ i = *((const int64_t *) p);
break;
default:
internal_error ("bad integer kind");
@@ -93,16 +93,16 @@ extract_int (void *p, int len)
}
double
-extract_real (void *p, int len)
+extract_real (const void *p, int len)
{
double i = 0.0;
switch (len)
{
case 4:
- i = *((float *) p);
+ i = *((const float *) p);
break;
case 8:
- i = *((double *) p);
+ i = *((const double *) p);
break;
default:
internal_error ("bad real kind");
@@ -269,8 +269,8 @@ output_float (fnode *f, double value, int len)
int digits;
int nsign, nblank, nesign;
int sca, neval, itmp;
- char *p, *q;
- char *spos, *intstr;
+ char *p;
+ const char *q, *intstr;
sign_t sign, esign;
double n, minv, maxv;
format_token ft;
@@ -399,7 +399,6 @@ output_float (fnode *f, double value, int len)
p = write_block (w);
if (p == NULL)
return;
- spos = p;
nblank = w - (nsign + intlen + d + nesign + (ft == FMT_F ? 0 : 1) );
if (nblank < 0)
@@ -455,7 +454,7 @@ done:
/* write_float() -- output a real number according to its format */
static void
-write_float (fnode *f, char *source, int len)
+write_float (fnode *f, const char *source, int len)
{
double n;
int nb =0 ;
@@ -484,10 +483,11 @@ write_float (fnode *f, char *source, int len)
static void
-write_int (fnode *f, char *source, int len, char *(*conv) (unsigned))
+write_int (fnode *f, const char *source, int len, char *(*conv) (unsigned))
{
int n, w, m, digits, nsign, nzero, nblank;
- char *p, *q;
+ char *p;
+ const char *q;
sign_t sign;
w = f->u.integer.w;
@@ -623,7 +623,7 @@ btoa (unsigned n)
void
-write_i (fnode * f, char *p, int len)
+write_i (fnode * f, const char *p, int len)
{
write_int (f, p, len, (void *) itoa);
@@ -631,7 +631,7 @@ write_i (fnode * f, char *p, int len)
void
-write_b (fnode * f, char *p, int len)
+write_b (fnode * f, const char *p, int len)
{
write_int (f, p, len, btoa);
@@ -639,14 +639,14 @@ write_b (fnode * f, char *p, int len)
void
-write_o (fnode * f, char *p, int len)
+write_o (fnode * f, const char *p, int len)
{
write_int (f, p, len, otoa);
}
void
-write_z (fnode * f, char *p, int len)
+write_z (fnode * f, const char *p, int len)
{
write_int (f, p, len, xtoa);
@@ -654,35 +654,35 @@ write_z (fnode * f, char *p, int len)
void
-write_d (fnode *f, char *p, int len)
+write_d (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
void
-write_e (fnode *f, char *p, int len)
+write_e (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
void
-write_f (fnode *f, char *p, int len)
+write_f (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
void
-write_en (fnode *f, char *p, int len)
+write_en (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
void
-write_es (fnode *f, char *p, int len)
+write_es (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
@@ -728,7 +728,7 @@ write_char (char c)
/* Default logical output should be L2
according to DEC fortran Manual. */
static void
-write_logical (char *source, int length)
+write_logical (const char *source, int length)
{
write_char (' ');
write_char (extract_int (source, length) ? 'T' : 'F');
@@ -738,9 +738,10 @@ write_logical (char *source, int length)
/* write_integer()-- Write a list-directed integer value. */
static void
-write_integer (char *source, int length)
+write_integer (const char *source, int length)
{
- char *p, *q;
+ char *p;
+ const char *q;
int digits;
int width = 12;
@@ -762,7 +763,7 @@ write_integer (char *source, int length)
* mode. */
static void
-write_character (char *source, int length)
+write_character (const char *source, int length)
{
int i, extra;
char *p, d;
@@ -818,7 +819,7 @@ write_character (char *source, int length)
REAL(4) is 1PG15.7E2, and for REAL(8) is 1PG25.15E3 */
static void
-write_real (char *source, int length)
+write_real (const char *source, int length)
{
fnode f ;
int org_scale = g.scale_factor;
@@ -842,7 +843,7 @@ write_real (char *source, int length)
static void
-write_complex (char *source, int len)
+write_complex (const char *source, int len)
{
if (write_char ('('))
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index ee258be3b24..ea79744e6c6 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -52,9 +52,12 @@ typedef off_t offset_t;
#define NULL (void *) 0
#endif
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
/* For a library, a standard prefix is a requirement in order to
- paritition the namespace. It's ugly to look at and a pain to type,
+ partition the namespace. It's ugly to look at and a pain to type,
so we hide it behind macros. */
#define prefix(x) _gfortran_ ## x
@@ -252,16 +255,16 @@ char *itoa (int);
char *xtoa (unsigned);
#define os_error prefix(os_error)
-void os_error (const char *);
+void os_error (const char *) __attribute__ ((noreturn));
#define show_locus prefix(show_locus)
void show_locus (void);
#define runtime_error prefix(runtime_error)
-void runtime_error (const char *);
+void runtime_error (const char *) __attribute__ ((noreturn));
#define internal_error prefix(internal_error)
-void internal_error (const char *);
+void internal_error (const char *) __attribute__ ((noreturn));
#define get_oserror prefix(get_oserror)
const char *get_oserror (void);
@@ -270,21 +273,13 @@ const char *get_oserror (void);
void write_error (const char *);
#define sys_exit prefix(sys_exit)
-void sys_exit (int);
+void sys_exit (int) __attribute__ ((noreturn));
#define st_printf prefix(st_printf)
-int st_printf (const char *, ...)
-#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)))
-#endif
-;
+int st_printf (const char *, ...) __attribute__ ((format (printf, 1, 2)));
#define st_sprintf prefix(st_sprintf)
-void st_sprintf (char *, const char *, ...)
-#ifdef __GNUC__
-__attribute__ ((format (printf, 2, 3)))
-#endif
-;
+void st_sprintf (char *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
#define translate_error prefix(translate_error)
const char *translate_error (int);
@@ -302,7 +297,7 @@ void memory_init (void);
void runtime_cleanup (void);
#define get_mem prefix(get_mem)
-void *get_mem (size_t);
+void *get_mem (size_t) __attribute__ ((malloc));
#define free_mem prefix(free_mem)
void free_mem (void *);
diff --git a/libgfortran/runtime/error.c b/libgfortran/runtime/error.c
index 48030d82b5a..8de5b220672 100644
--- a/libgfortran/runtime/error.c
+++ b/libgfortran/runtime/error.c
@@ -62,8 +62,7 @@ rtoa (double f, int length, int oprec)
double n = f;
double fval, minval;
int negative, prec;
- unsigned k, num;
- char *p;
+ unsigned k;
char formats[16];
prec = 0;
diff --git a/libgfortran/runtime/select.c b/libgfortran/runtime/select.c
index 2e1eed502a3..5ee873aefcb 100644
--- a/libgfortran/runtime/select.c
+++ b/libgfortran/runtime/select.c
@@ -38,7 +38,7 @@ select_struct;
* select_struct structures, return the address to jump to. */
void *select_string (select_struct *table, int table_len, void *default_jump,
- char *selector, int selector_len)
+ const char *selector, int selector_len)
{
select_struct *t;
int i, low, high, mid;
diff --git a/libgfortran/runtime/stop.c b/libgfortran/runtime/stop.c
index 083c772e4a9..bd781f0de06 100644
--- a/libgfortran/runtime/stop.c
+++ b/libgfortran/runtime/stop.c
@@ -42,7 +42,7 @@ stop_numeric (G95_INTEGER_4 code)
void
-stop_string (char *string, G95_INTEGER_4 len)
+stop_string (const char *string, G95_INTEGER_4 len)
{
show_locus ();