tstats: add threadmaybackground - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 7f6458b045e04b97dd06b3171ac67e9ecde32429
parent ac487c754e009b0f3c01c2a8ad5bda2143da4a6b
Author: Russ Cox 
Date:   Tue,  5 Jan 2021 23:35:33 -0500

stats: add threadmaybackground

Diffstat:
  M src/cmd/devdraw/mac-screen.m        |       5 ++++-
  M src/cmd/draw/stats.c                |       6 ++++++
  M src/cmd/sam/cmd.c                   |      70 ++++++++++++++++----------------
  M src/cmd/sam/parse.h                 |       6 ++++--
  M src/cmd/sam/sam.h                   |       2 --

5 files changed, 49 insertions(+), 40 deletions(-)
---
diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m
t@@ -238,11 +238,14 @@ rpc_attach(Client *c, char *label, char *winsize)
         char *s;
         NSArray *allDevices;
 
-        const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
+        NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
                 | NSWindowStyleMaskClosable
                 | NSWindowStyleMaskMiniaturizable
                 | NSWindowStyleMaskResizable;
 
+        if(label == nil || *label == '\0')
+                Winstyle &= ~NSWindowStyleMaskTitled;
+
         s = winsize;
         sr = [[NSScreen mainScreen] frame];
         r = [[NSScreen mainScreen] visibleFrame];
diff --git a/src/cmd/draw/stats.c b/src/cmd/draw/stats.c
t@@ -675,6 +675,12 @@ keyboardthread(void *v)
 void machproc(void*);
 void updateproc(void*);
 
+int
+threadmaybackground(void)
+{
+        return 1;
+}
+
 void
 threadmain(int argc, char *argv[])
 {
diff --git a/src/cmd/sam/cmd.c b/src/cmd/sam/cmd.c
t@@ -3,41 +3,41 @@
 
 static char        linex[]="\n";
 static char        wordx[]=" \t\n";
-struct cmdtab cmdtab[]={
+struct Cmdtab cmdtab[]={
 /*        cmdc        text        regexp        addr        defcmd        defaddr        count        token         fn        */
-        '\n',        0,        0,        0,        0,        aDot,        0,        0,        nl_cmd,
-        'a',        1,        0,        0,        0,        aDot,        0,        0,        a_cmd,
-        'b',        0,        0,        0,        0,        aNo,        0,        linex,        b_cmd,
-        'B',        0,        0,        0,        0,        aNo,        0,        linex,        b_cmd,
-        'c',        1,        0,        0,        0,        aDot,        0,        0,        c_cmd,
-        'd',        0,        0,        0,        0,        aDot,        0,        0,        d_cmd,
-        'D',        0,        0,        0,        0,        aNo,        0,        linex,        D_cmd,
-        'e',        0,        0,        0,        0,        aNo,        0,        wordx,        e_cmd,
-        'f',        0,        0,        0,        0,        aNo,        0,        wordx,        f_cmd,
-        'g',        0,        1,        0,        'p',        aDot,        0,        0,        g_cmd,
-        'i',        1,        0,        0,        0,        aDot,        0,        0,        i_cmd,
-        'k',        0,        0,        0,        0,        aDot,        0,        0,        k_cmd,
-        'm',        0,        0,        1,        0,        aDot,        0,        0,        m_cmd,
-        'n',        0,        0,        0,        0,        aNo,        0,        0,        n_cmd,
-        'p',        0,        0,        0,        0,        aDot,        0,        0,        p_cmd,
-        'q',        0,        0,        0,        0,        aNo,        0,        0,        q_cmd,
-        'r',        0,        0,        0,        0,        aDot,        0,        wordx,        e_cmd,
-        's',        0,        1,        0,        0,        aDot,        1,        0,        s_cmd,
-        't',        0,        0,        1,        0,        aDot,        0,        0,        m_cmd,
-        'u',        0,        0,        0,        0,        aNo,        2,        0,        u_cmd,
-        'v',        0,        1,        0,        'p',        aDot,        0,        0,        g_cmd,
-        'w',        0,        0,        0,        0,        aAll,        0,        wordx,        w_cmd,
-        'x',        0,        1,        0,        'p',        aDot,        0,        0,        x_cmd,
-        'y',        0,        1,        0,        'p',        aDot,        0,        0,        x_cmd,
-        'X',        0,        1,        0,        'f',        aNo,        0,        0,        X_cmd,
-        'Y',        0,        1,        0,        'f',        aNo,        0,        0,        X_cmd,
-        '!',        0,        0,        0,        0,        aNo,        0,        linex,        plan9_cmd,
-        '>',        0,        0,        0,        0,        aDot,        0,        linex,        plan9_cmd,
-        '<',        0,        0,        0,        0,        aDot,        0,        linex,        plan9_cmd,
-        '|',        0,        0,        0,        0,        aDot,        0,        linex,        plan9_cmd,
-        '=',        0,        0,        0,        0,        aDot,        0,        linex,        eq_cmd,
-        'c'|0x100,0,        0,        0,        0,        aNo,        0,        wordx,        cd_cmd,
-        0,        0,        0,        0,        0,        0,        0,        0
+        {'\n',        0,        0,        0,        0,        aDot,        0,        0,        nl_cmd},
+        {'a',        1,        0,        0,        0,        aDot,        0,        0,        a_cmd},
+        {'b',        0,        0,        0,        0,        aNo,        0,        linex,        b_cmd},
+        {'B',        0,        0,        0,        0,        aNo,        0,        linex,        b_cmd},
+        {'c',        1,        0,        0,        0,        aDot,        0,        0,        c_cmd},
+        {'d',        0,        0,        0,        0,        aDot,        0,        0,        d_cmd},
+        {'D',        0,        0,        0,        0,        aNo,        0,        linex,        D_cmd},
+        {'e',        0,        0,        0,        0,        aNo,        0,        wordx,        e_cmd},
+        {'f',        0,        0,        0,        0,        aNo,        0,        wordx,        f_cmd},
+        {'g',        0,        1,        0,        'p',        aDot,        0,        0,        g_cmd},
+        {'i',        1,        0,        0,        0,        aDot,        0,        0,        i_cmd},
+        {'k',        0,        0,        0,        0,        aDot,        0,        0,        k_cmd},
+        {'m',        0,        0,        1,        0,        aDot,        0,        0,        m_cmd},
+        {'n',        0,        0,        0,        0,        aNo,        0,        0,        n_cmd},
+        {'p',        0,        0,        0,        0,        aDot,        0,        0,        p_cmd},
+        {'q',        0,        0,        0,        0,        aNo,        0,        0,        q_cmd},
+        {'r',        0,        0,        0,        0,        aDot,        0,        wordx,        e_cmd},
+        {'s',        0,        1,        0,        0,        aDot,        1,        0,        s_cmd},
+        {'t',        0,        0,        1,        0,        aDot,        0,        0,        m_cmd},
+        {'u',        0,        0,        0,        0,        aNo,        2,        0,        u_cmd},
+        {'v',        0,        1,        0,        'p',        aDot,        0,        0,        g_cmd},
+        {'w',        0,        0,        0,        0,        aAll,        0,        wordx,        w_cmd},
+        {'x',        0,        1,        0,        'p',        aDot,        0,        0,        x_cmd},
+        {'y',        0,        1,        0,        'p',        aDot,        0,        0,        x_cmd},
+        {'X',        0,        1,        0,        'f',        aNo,        0,        0,        X_cmd},
+        {'Y',        0,        1,        0,        'f',        aNo,        0,        0,        X_cmd},
+        {'!',        0,        0,        0,        0,        aNo,        0,        linex,        plan9_cmd},
+        {'>',        0,        0,        0,        0,        aDot,        0,        linex,        plan9_cmd},
+        {'<',        0,        0,        0,        0,        aDot,        0,        linex,        plan9_cmd},
+        {'|',        0,        0,        0,        0,        aDot,        0,        linex,        plan9_cmd},
+        {'=',        0,        0,        0,        0,        aDot,        0,        linex,        eq_cmd},
+        {'c'|0x100,0,        0,        0,        0,        aNo,        0,        wordx,        cd_cmd},
+        {0,        0,        0,        0,        0,        0,        0,        0},
 };
 Cmd        *parsecmd(int);
 Addr        *compoundaddr(void);
t@@ -402,7 +402,7 @@ Cmd *
 parsecmd(int nest)
 {
         int i, c;
-        struct cmdtab *ct;
+        Cmdtab *ct;
         Cmd *cp, *ncp;
         Cmd cmd;
 
diff --git a/src/cmd/sam/parse.h b/src/cmd/sam/parse.h
t@@ -33,7 +33,8 @@ struct Cmd
 #define        ctext        g.text
 #define        caddr        g.addr
 
-extern struct cmdtab{
+typedef struct Cmdtab Cmdtab;
+struct Cmdtab {
         ushort        cmdc;                /* command character */
         uchar        text;                /* takes a textual argument? */
         uchar        regexp;                /* takes a regular expression? */
t@@ -43,7 +44,8 @@ extern struct cmdtab{
         uchar        count;                /* takes a count e.g. s2/// */
         char        *token;                /* takes text terminated by one of these */
         int        (*fn)(File*, Cmd*);        /* function to call with parse tree */
-}cmdtab[];
+};
+extern Cmdtab cmdtab[];
 
 enum Defaddr{        /* default addresses */
         aNo,
diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h
t@@ -37,7 +37,6 @@ typedef struct Address        Address;
 typedef struct Block        Block;
 typedef struct Buffer        Buffer;
 typedef struct Disk        Disk;
-typedef struct Discdesc        Discdesc;
 typedef struct File        File;
 typedef struct List        List;
 typedef struct Range        Range;
t@@ -342,7 +341,6 @@ void        warn_S(Warn, String*);
 int        whichmenu(File*);
 void        writef(File*);
 Posn        writeio(File*);
-Discdesc *Dstart(void);
 
 extern Rune        samname[];        /* compiler dependent */
 extern Rune        *left[];