OSDN Git Service

2010-10-05 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / adaint.h
index 57cedf8..a43f9b2 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 1992-2009, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
 #define Encoding_8bits 1        /* Standard 8bits, CP_ACP on Windows. */
 #define Encoding_Unspecified 2  /* Based on GNAT_CODE_PAGE env variable. */
 
-/* Large file support. It is unclear what portable mechanism we can
-   use to determine at compile time what support the system offers for
-   large files. For now we just list the platforms we have manually
-   tested.  */
-
-#if defined (__GLIBC__) || defined (sun)  || defined (__sgi)
-#define FOPEN fopen64
-#define STAT stat64
-#define FSTAT fstat64
-#define LSTAT lstat64
-#define STRUCT_STAT struct stat64
+/* Large file support. It is unclear what portable mechanism we can use to
+   determine at compile time what support the system offers for large files.
+   For now we just list the platforms we have manually tested. */
+
+#if defined (__GLIBC__) || defined (sun)  || (defined (__sgi) && defined(_LFAPI))
+#define GNAT_FOPEN fopen64
+#define GNAT_STAT stat64
+#define GNAT_FSTAT fstat64
+#define GNAT_LSTAT lstat64
+#define GNAT_STRUCT_STAT struct stat64
+#else
+#define GNAT_FOPEN fopen
+#define GNAT_STAT stat
+#define GNAT_FSTAT fstat
+#define GNAT_LSTAT lstat
+#define GNAT_STRUCT_STAT struct stat
+#endif
+
+/* Type corresponding to GNAT.OS_Lib.OS_Time */
+#if defined (_WIN64)
+typedef long long OS_Time;
 #else
-#define FOPEN fopen
-#define STAT stat
-#define FSTAT fstat
-#define LSTAT lstat
-#define STRUCT_STAT struct stat
+typedef long OS_Time;
 #endif
 
-typedef long OS_Time; /* Type corresponding to GNAT.OS_Lib.OS_Time */
+/* A lazy cache for the attributes of a file. On some systems, a single call to
+   stat() will give all this information, so it is better than doing a system
+   call every time. On other systems this require several system calls.
+*/
+
+struct file_attributes {
+  unsigned char exists;
+
+  unsigned char writable;
+  unsigned char readable;
+  unsigned char executable;
+
+  unsigned char symbolic_link;
+  unsigned char regular;
+  unsigned char directory;
+
+  OS_Time timestamp;
+  long file_length;
+};
+/* WARNING: changing the size here might require changing the constant
+ * File_Attributes_Size in osint.ads (which should be big enough to
+ * fit the above struct on any system)
+ */
 
 extern int    __gnat_max_path_len;
 extern OS_Time __gnat_current_time                (void);
@@ -73,6 +101,7 @@ extern void   __gnat_to_gm_time                         (OS_Time *, int *, int *,
 extern int    __gnat_get_maximum_file_name_length  (void);
 extern int    __gnat_get_switches_case_sensitive   (void);
 extern int    __gnat_get_file_names_case_sensitive (void);
+extern int    __gnat_get_env_vars_case_sensitive   (void);
 extern char   __gnat_get_default_identifier_character_set (void);
 extern void   __gnat_get_current_dir              (char *, int *);
 extern void   __gnat_get_object_suffix_ptr         (int *,
@@ -89,7 +118,7 @@ extern int    __gnat_open_new                      (char *, int);
 extern int    __gnat_open_new_temp                (char *, int);
 extern int    __gnat_mkdir                        (char *);
 extern int    __gnat_stat                         (char *,
-                                                   STRUCT_STAT *);
+                                                   GNAT_STRUCT_STAT *);
 extern int    __gnat_unlink                        (char *);
 extern int    __gnat_rename                        (char *, char *);
 extern int    __gnat_chdir                         (char *);
@@ -117,15 +146,28 @@ extern OS_Time __gnat_file_time_fd                  (int);
 
 extern void   __gnat_set_file_time_name                   (char *, time_t);
 
-extern int    __gnat_dup                          (int);
-extern int    __gnat_dup2                         (int, int);
-extern int    __gnat_file_exists                  (char *);
-extern int    __gnat_is_regular_file               (char *);
-extern int    __gnat_is_absolute_path              (char *,int);
-extern int    __gnat_is_directory                 (char *);
+extern int    __gnat_dup                                   (int);
+extern int    __gnat_dup2                                  (int, int);
+extern int    __gnat_file_exists                        (char *);
+extern int    __gnat_is_regular_file         (char *);
+extern int    __gnat_is_absolute_path        (char *,int);
+extern int    __gnat_is_directory                    (char *);
 extern int    __gnat_is_writable_file             (char *);
 extern int    __gnat_is_readable_file             (char *name);
-extern int    __gnat_is_executable_file            (char *name);
+extern int    __gnat_is_executable_file      (char *name);
+
+extern void __gnat_reset_attributes (struct file_attributes* attr);
+extern long   __gnat_file_length_attr        (int, char *, struct file_attributes *);
+extern OS_Time __gnat_file_time_name_attr    (char *, struct file_attributes *);
+extern OS_Time __gnat_file_time_fd_attr      (int,    struct file_attributes *);
+extern int    __gnat_file_exists_attr        (char *, struct file_attributes *);
+extern int    __gnat_is_regular_file_attr    (char *, struct file_attributes *);
+extern int    __gnat_is_directory_attr       (char *, struct file_attributes *);
+extern int    __gnat_is_readable_file_attr   (char *, struct file_attributes *);
+extern int    __gnat_is_writable_file_attr   (char *, struct file_attributes *);
+extern int    __gnat_is_executable_file_attr (char *, struct file_attributes *);
+extern int    __gnat_is_symbolic_link_attr   (char *, struct file_attributes *);
+
 extern void   __gnat_set_non_writable              (char *name);
 extern void   __gnat_set_writable                  (char *name);
 extern void   __gnat_set_executable                (char *name);