]> pd.if.org Git - pdclib.old/commitdiff
Enable building PDCLib with Watcom. This was surprisingly painless: their C99 mode...
authorOwen Shepherd <owen.shepherd@e43.eu>
Thu, 16 Aug 2012 13:59:39 +0000 (14:59 +0100)
committerOwen Shepherd <owen.shepherd@e43.eu>
Thu, 16 Aug 2012 13:59:39 +0000 (14:59 +0100)
Jamrules
internals/_PDCLIB_glue.h
platform/example/internals/_PDCLIB_config.h
platform/posix/internals/_PDCLIB_config.h
platform/win32/Config.jam
platform/win32/crt0.c
platform/win32/functions/_PDCLIB/_PDCLIB_seek.c
platform/win32/functions/_PDCLIB/_PDCLIB_w32errno.c
platform/win32/functions/stdio/remove.c
platform/win32/internals/_PDCLIB_config.h

index dd0e406826211b951d4977c6644e47a43d345a90..bc9ac17bc94a815375a0eae1d20e3355088e7de7 100644 (file)
--- a/Jamrules
+++ b/Jamrules
@@ -8,16 +8,29 @@ if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {
     } else if $(UNIX) {\r
         PDCLIB_PLATFORM = "posix" ;\r
     } else {\r
-        ECHO "PDCLIB_PLATFORM not set and platform not automatically detected" ;\r
-        ECHO "Set PDCLIB_PLATFORM to the platform to be built for" ;\r
+        ECHO PDCLIB_PLATFORM not set and platform not automatically detected ;\r
+        ECHO Set PDCLIB_PLATFORM to the platform to be built for ;\r
         EXIT ;\r
     }\r
     PDCLIB_HAVE_PLATFORM = 1 ;\r
 }\r
 \r
-#if $(CC) = "gcc" {\r
-# TODO: Better toolchain handling\r
+if $(PDCLIB_TOOLCHAIN) = "" {\r
+  local __ccparts = [ SPLIT $(CC) : "-" ] ;\r
+  if $(JAM_TOOLSET) = "MINGW" || "gcc" in $(__ccparts) \r
+      || "clang" in $(__ccparts) {\r
+    # GCC / GCC-alike\r
+    PDCLIB_TOOLCHAIN = "gcc" ;\r
+  } else if $(JAM_TOOLSET) != "" {\r
+    PDCLIB_TOOLCHAIN = $(JAM_TOOLSET) ;\r
+  } else {\r
+    ECHO PDCLIB_TOOLCHAIN is unset and I can't glean what toolset is being ;\r
+    ECHO used from your environment. Please set it.  ;\r
+    EXIT ;\r
+  }\r
+}\r
 \r
+if $(PDCLIB_TOOLCHAIN) = "gcc" {\r
     # No -Wcast-align      : spurious warnings when using char* to do pointer \r
     #                        arithmetic\r
     # No -Winline          : when compiling with e.g. -Os causes spurious \r
@@ -49,7 +62,18 @@ if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {
     {\r
         $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group\r
     }\r
-#}\r
+} else if $(PDCLIB_TOOLCHAIN) = "WATCOM" {\r
+  ECHO "Watcom!" ;\r
+  CCFLAGS  = /zq /DWIN32 ;\r
+  C++FLAGS = /zq /DWIN32 ;\r
+  STDHDRS  = $(WATCOM)\\h\\nt ;\r
+\r
+  PDCLIB_CCFLAGS = "-za99 -zl" ;\r
+} else {\r
+  ECHO The value of PDCLIB_TOOLCHAIN is not recognized  ;\r
+  ECHO Currently set to $(PDCLIB_TOOLCHAIN)  ;\r
+  EXIT ;\r
+}\r
 \r
 if $(PDCLIB_PLATFORM) {\r
     include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;\r
index 09f47b7852581cf725ce68480ced2bc264f878f8..d49cc114338273c0c4c9ce6681ea9334660029c6 100644 (file)
@@ -25,7 +25,7 @@ _PDCLIB_BEGIN_EXTERN_C
 /* A system call that terminates the calling process, returning a given status
    to the environment.
 */
-void _PDCLIB_Exit( int status ) _PDCLIB_NORETURN;
+_PDCLIB_noreturn void _PDCLIB_Exit( int status );
 
 /* A system call which allocates n pages of memory and returns a pointer to 
    them. On failure, returns NULL
index ff4349510dd0093b3e2a9f0dc899e0f25147fc25..15ee828e7bed455fab6525557a3b9a01556c9cb3 100644 (file)
 /* specific platforms, e.g. by swapping int instead of char.                  */
 #define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size );
 
-/* Define this to some compiler directive that can be written after the       */
-/* parameter list of a function declaration to indicate the function does     */
-/* never return. If your compiler does not support such a directive, define   */
-/* to nothing. (This is to avoid warnings with the exit functions under GCC.) */
-#define _PDCLIB_NORETURN __attribute__(( noreturn ))
-
 /* The maximum value that errno can be set to. This is used to set the size   */
 /* of the array in struct lconv (<locale.h>) holding error messages for the   */
 /* strerror() and perror() functions. (If you change this value because you   */
index 7e66178b96ea124ba029b3651e03dfc8739e976c..4252cff5535ce2e8495c9d942adb53cf52810d7d 100644 (file)
 /* specific platforms, e.g. by swapping int instead of char.                  */
 #define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size );
 
-/* Define this to some compiler directive that can be written after the       */
-/* parameter list of a function declaration to indicate the function does     */
-/* never return. If your compiler does not support such a directive, define   */
-/* to nothing. (This is to avoid warnings with the exit functions under GCC.) */
-#define _PDCLIB_NORETURN __attribute__(( noreturn ))
-
 /* The maximum value that errno can be set to. This is used to set the size   */
 /* of the array in struct lconv (<locale.h>) holding error messages for the   */
 /* strerror() and perror() functions. (If you change this value because you   */
index c02174f68993ad548e2980f06aaa575661dabf46..7dcab3f891f183fcdf64e266956bc3539f713466 100644 (file)
@@ -2,6 +2,10 @@ rule PDCLibTargetConfig { }
 rule PDCLibTargetHeaders {\r
     SubDirHdrs $(PDCLIB_TOP) platform win32 includes ;\r
     SubDirHdrs $(PDCLIB_TOP) platform win32 internals ;\r
+\r
+    if $(PDCLIB_TOOLCHAIN) = "WATCOM" {\r
+        SubDirHdrs $(WATCOM) h ;\r
+    }\r
 }\r
 \r
 PDCLIB_TEST_LINKFLAGS += -nostdlib ;\r
index f7f6a925243cc76ebb59e4b1fe0661abf4f1cd8d..dd00c53009fa360f342ea45082a174089d4bed47 100644 (file)
@@ -1,8 +1,9 @@
-#include <windows.h>\r
 #include <string.h>\r
 #include <stdlib.h>\r
 #include <stdio.h>\r
 #include <signal.h>\r
+#include <wchar.h> // Watcom bug: winnt.h assumes string.h defines wchar_t\r
+#include <windows.h>\r
 \r
 static char ** argvToAnsi( wchar_t ** wargv, int argc )\r
 {\r
index e23cd3cbaf5af4ac71910663085487ca0f9d0fa7..6bf53e9809780562e136cd94f83b5dcfe28c54cc 100644 (file)
 #include <_PDCLIB_glue.h>
 #include <windows.h>
 
+#if _PDCLIB_C_MIN(2011)
 _Static_assert(SEEK_SET == FILE_BEGIN, "SEEK_SET is incorrect");
 _Static_assert(SEEK_CUR == FILE_CURRENT, "SEEK_CUR is incorrect");
 _Static_assert(SEEK_END == FILE_END, "SEEK_END is incorrect");
+#endif
 
 extern void _PDCLIB_w32errno( void );
 _PDCLIB_int64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t offset, int whence )
index 5e03ef53a6b4737a56a67a0d050c098a1170b451..da237f4c3c3ba33b5d43a8943986d0e01305a09e 100644 (file)
@@ -11,6 +11,7 @@
 \r
 #ifndef REGTEST\r
 #include <errno.h>\r
+#include <wchar.h> // Watcom bug: winnt.h assumes string.h defines wchar_t\r
 #include <windows.h>\r
 \r
 void _PDCLIB_w32errno(void)\r
index 913bdf3bee2aa6a95bed1f8288ab9c75146c40dd..957a5edd5ebf907ed1b79f5189e3a6a1bb2ee2b9 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <string.h>
 #include <errno.h>
+#include <wchar.h> // Watcom bug: winnt.h assumes string.h defines wchar_t
 #include <windows.h>
 
 extern struct _PDCLIB_file_t * _PDCLIB_filelist;
index 27a87b9955b46fa50000c45600f1acbc8d81792b..17c8ff4a74a1e7ff1d9f4c1ad21c924bcaa3f109 100644 (file)
@@ -273,13 +273,22 @@ struct _PDCLIB_imaxdiv_t
 */
 
 #ifdef __GNUC__
-  typedef char * _PDCLIB_va_list;
+  typedef __builtin_va_list _PDCLIB_va_list;
   #define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
   #define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
   #define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
   #define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
+#elif (defined(__i386__) || defined(__i386) || defined(_M_IX86)) && !(defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
+  /* Internal helper macro. va_round is not part of <stdarg.h>. */
+  #define _PDCLIB_va_round( type ) ( (sizeof(type) + sizeof(void *) - 1) & ~(sizeof(void *) - 1) )
+
+  typedef char * _PDCLIB_va_list;
+  #define _PDCLIB_va_arg( ap, type ) ( (ap) += (_PDCLIB_va_round(type)), ( *(type*) ( (ap) - (_PDCLIB_va_round(type)) ) ) )
+  #define _PDCLIB_va_copy( dest, src ) ( (dest) = (src), (void)0 )
+  #define _PDCLIB_va_end( ap ) ( (ap) = (void *)0, (void)0 )
+  #define _PDCLIB_va_start( ap, parmN ) ( (ap) = (char *) &parmN + ( _PDCLIB_va_round(parmN) ), (void)0 )
 #else
-  #error Compiler support please
+  #error Compiler/Architecture support please
 #endif
 
 /* -------------------------------------------------------------------------- */