58 #define _CRT_SECURE_NO_WARNINGS 63 #define _FORTIFY_SOURCE 0 85 #define PRINT_BUF_SIZE 4096 89 int offset = bufp - &printString[0]; \ 91 strncat(bufp, str, PRINT_BUF_SIZE - offset); \ 92 bufp += strlen(str); \ 93 if (bufp >= &printString[PRINT_BUF_SIZE]) \ 97 #define PRINT_SCALAR(fmt, type) \ 98 sprintf(tmpBuf, fmt, *((type *)ptr)); \ 102 #define PRINT_VECTOR(fmt, type) \ 104 if (bufp == &printString[PRINT_BUF_SIZE]) \ 106 for (int i = 0; i < width; ++i) { \ 108 if (mask & (1ull << i)) \ 109 sprintf(tmpBuf, fmt, ((type *)ptr)[i]); \ 111 sprintf(tmpBuf, "((" fmt "))", ((type *)ptr)[i]); \ 113 *bufp++ = (i != width - 1 ? ',' : ']'); \ 128 void __do_print(
const char *format,
const char *types,
int width, uint64_t mask,
void **args) {
130 char *bufp = &printString[0];
136 if (*format !=
'%') {
140 void *ptr = args[argCount++];
146 sprintf(tmpBuf,
"%s", *((
Bool *)ptr) ?
"true" :
"false");
152 if (bufp == &printString[PRINT_BUF_SIZE])
154 for (
int i = 0; i < width; ++i) {
155 if (mask & (1ull << i)) {
156 sprintf(tmpBuf,
"%s", ((
Bool *)ptr)[i] ?
"true" :
"false");
160 *bufp++ = (i != width - 1) ?
',' :
']';
204 fputs(printString, stdout);
212 #if defined(_MSC_VER) || defined(__MINGW32__) 222 int dwNumberOfProcessors;
226 struct SYSTEM_INFO sysInfo;
227 extern void __stdcall GetSystemInfo(
struct SYSTEM_INFO *);
228 GetSystemInfo(&sysInfo);
229 return sysInfo.dwNumberOfProcessors;
231 return sysconf(_SC_NPROCESSORS_ONLN);
void __do_print(const char *format, const char *types, int width, uint64_t mask, void **args)
#define PRINT_SCALAR(fmt, type)
#define PRINT_VECTOR(fmt, type)