} 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
{\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
/* 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
/* 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 */
/* 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 */
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
-#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
#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 )
\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
#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;
*/
#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
/* -------------------------------------------------------------------------- */