Skip to content

Commit

Permalink
Get the cogits to compile given that they now need the null define.
Browse files Browse the repository at this point in the history
Implement reporting the trace flags on Windows.
  • Loading branch information
eliotmiranda committed Jun 25, 2022
1 parent 083a490 commit 67660c5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
4 changes: 0 additions & 4 deletions platforms/Cross/vm/sq.h
Expand Up @@ -41,10 +41,6 @@
#include "sqMemoryAccess.h"
#include "sqVirtualMachine.h"

#define true 1
#define false 0
#define null 0 /* using "null" because nil is predefined in Think C */

#if !defined(IMAGE_DIALECT_NAME)
# if NewspeakVM
# define IMAGE_DIALECT_NAME "Newspeak"
Expand Down
4 changes: 4 additions & 0 deletions platforms/Cross/vm/sqMemoryAccess.h
Expand Up @@ -23,6 +23,10 @@
#include "config.h"
#include "interp.h"

#define true 1
#define false 0
#define null 0 /* using "null" because nil is predefined in Think C */

#ifndef SIZEOF_LONG
# if LLP64
# define SIZEOF_LONG 4
Expand Down
39 changes: 34 additions & 5 deletions platforms/win32/vm/sqWin32Window.c
Expand Up @@ -3190,6 +3190,21 @@ HideSplashScreen(void)

# define VMOPTION(arg) "-"arg
# define TVMOPTION(arg) TEXT("-") TEXT(arg)
# if _UNICODE
static TCHAR *
asTCharString(char *charString)
{
int len = MultiByteToWideChar(CP_UTF8, 0, charString, -1, NULL, 0);
if (len <= 0)
return 0; /* invalid UTF8 ? */
LPWSTR tcharString = malloc(len*sizeof(WCHAR));
if (MultiByteToWideChar(CP_UTF8, 0, charString, -1, tcharString, len) == 0)
return 0;
return tcharString;
}
# else
# define asTCharString(charString) charString
# endif

/* print usage with different output levels */
int
Expand All @@ -3199,9 +3214,19 @@ printUsage(int level)
case 0: /* No command line given */
abortMessage(TEXT("Usage: ") TEXT(VM_NAME) TEXT(" [options] <imageFile>\n"));
break;
case 1: /* full usage */
abortMessage(TEXT("%s\n"),
TEXT("Usage: ") TEXT(VM_NAME) TEXT(" [vmOptions] imageFile [imageOptions]\n\n")
case 1: { // full usage
#if COGVM
char traceFlags[1024];
extern const char *traceFlagsMeanings[];
bzero(traceFlags,1024);
int i = 0;
while (traceFlagsMeanings[i]) {
strcat(traceFlags, "\n\t\t");
strcat(traceFlags, traceFlagsMeanings[i]);
++i;
}
#endif
abortMessage(TEXT("Usage: ") TEXT(VM_NAME) TEXT(" [vmOptions] imageFile [imageOptions]\n\n")
TEXT("vmOptions:")
TEXT("\n\t") TVMOPTION("service:") TEXT(" ServiceName \t(install VM as NT service)")
TEXT("\n\t") TVMOPTION("headless") TEXT(" \t\t(force VM to run headless)")
Expand All @@ -3222,8 +3247,8 @@ printUsage(int level)
#endif /* STACKVM */
#if STACKVM || NewspeakVM
# if COGVM
TEXT("\n\t") TVMOPTION("logplugin") TEXT(" name\t\tonly log primitives in plugin\n")
TEXT("\n\t") TVMOPTION("trace") TEXT("[=num]\t\tenable tracing (optionally to a specific value)")
TEXT("\n\t") TVMOPTION("logplugin") TEXT(" name\t\tonly log primitives in plugin")
TEXT("\n\t") TVMOPTION("trace") TEXT("[=num]\t\tenable tracing (optionally to a specific value)%s")
# else
TEXT("\n\t") TVMOPTION("sendtrace") TEXT(" \t\t(trace sends to stdout for debug)")
# endif
Expand All @@ -3243,7 +3268,11 @@ printUsage(int level)
#endif
TEXT("\n") TEXT("Options begin with single -, but -- prefix is silently accepted")
TEXT("\n") TEXT("Options with arguments -opt:n are also accepted with separators -opt n")
#if COGVM
, asTCharString(traceFlags)
#endif
);
}
break;
case 2: /* No image found */
default:
Expand Down

0 comments on commit 67660c5

Please sign in to comment.