Mail Archives: djgpp-workers/2004/12/31/09:51:39
Hello.
A long time ago I added restrict to my DJGPP headers as per C99.
E.g. here's the patch for time.h (pasted):
Index: djgpp/include/time.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/time.h,v
retrieving revision 1.8
diff -p -u -r1.8 time.h
--- djgpp/include/time.h 16 Feb 2003 04:01:49 -0000 1.8
+++ djgpp/include/time.h 29 Dec 2004 15:51:25 -0000
@@ -57,7 +57,7 @@ double difftime(time_t _t1, time_t _t0)
struct tm * gmtime(const time_t *_tod);
struct tm * localtime(const time_t *_tod);
time_t mktime(struct tm *_tptr);
-size_t strftime(char *_s, size_t _n, const char *_format, const struct tm *_tptr);
+size_t strftime(char * restrict _s, size_t _n, const char *restrict _format, const struct tm * restrict _tptr);
time_t time(time_t *_tod);
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
As I'm using GCC 2.953 I added something like this as well:
Index: djgpp/include/sys/version.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/sys/version.h,v
retrieving revision 1.5
diff -p -u -r1.5 version.h
--- djgpp/include/sys/version.h 17 Oct 2002 23:00:24 -0000 1.5
+++ djgpp/include/sys/version.h 29 Dec 2004 15:51:25 -0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
@@ -18,3 +19,6 @@
#define __DJGPP_MINOR 4
#define __DJGPP_MINOR__ 4
+#if __GNUC__ < 3 /* || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)*/
+#define restrict
+#endif
I also tried the current GCC of that time. It didn't support restrict
either, hence the commented out part above. Or rather I don't know
exactly why I have commented it out. What I do remember I couldn't get
it to work and gave up on GCC >= 3.
Do we want this commited? I think yes.
Does anyone know the earliest GCC version that supports restrict, if
any? I.e. what should the line
+#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
look like?
I'm not sure the right place for it is in <sys/version.h> but it
seemed like a good place with regard to getting it defined
everywhere. I'm open for suggestions.
Right,
MartinS
- Raw text -