• sys/select.h missing for pth.h (pthread)

    From [via djgpp@delorie.com]" @21:1/5 to djgpp on Mon Jun 21 08:26:53 2021
    Goal: recompile http://ftp.gnu.org/gnu/chess/gnuchess-6.2.8.tar.gz in Linux for FreeDOS project.



    Subgoal:

    Compile the following program taken from: https://man7.org/linux/man-pages/man3/pthread_sigmask.3.html

    ===============

          //#include <pthread.h>

           #include <pth.h>

           #include <stdio.h>

           #include <stdlib.h>

           #include <unistd.h>

           #include <signal.h>

           #include <errno.h>



           /* Simple error handling functions */



           #define handle_error_en(en, msg) \

                   do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)



           static void *

           sig_thread(void *arg)

           {

               sigset_t *set = arg;

               int s, sig;



               for (;;) {

                   s = sigwait(set, &sig);

                   if (s != 0)

                       handle_error_en(s, "sigwait");

                   printf("Signal handling thread got signal %d\n", sig);

               }

           }



           int

           main(int argc, char *argv[])

           {

               pthread_t thread;

               sigset_t set;https://github.com/jwt27/build-gcc

               int s;



               /* Block SIGQUIT and SIGUSR1; other threads created by main()

                  will inherit a copy of the signal mask. */



               sigemptyset(&set);

               sigaddset(&set, SIGQUIT);

               sigaddset(&set, SIGUSR1);

               s = pthread_sigmask(SIG_BLOCK, &set, NULL);

               if (s != 0)

                   handle_error_en(s, "pthread_sigmask");



               s = pthread_create(&thread, NULL, &sig_thread, &set);

               if (s != 0)

                   handle_error_en(s, "pthread_create");



               /* Main thread carries on to create other threads and/or do

                  other work. */



               pause();            /* Dummy pause so we can test program */

           }

    =============

    I changed #include <pthread.h> to <pth.h>

    I might still be confused between pthread.h and pth.h.



    I use: https://github.com/jwt27/build-gcc with PREFIX=/home/paul/opt/cross



    I have unzip http://www.delorie.com/pub/djgpp/current/v2gnu/pth207b.zip in a temporary dir



    I have copied: /pth/lib/ into /home/paul/opt/cross/i386-pc-msdosdjgpp/lib/

    adjusting lastl line of .la files to that directory.



    I have copied pth.h and pthread.h to: /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/



    While trying to compile subgoal program: I just commented out #include line not working in pth.h...

    except for sys/select: I finished to download it from: https://code.woboq.org/qt5/include/sys/select.h.html



    paul@kasparno:~/sigset$ i386-pc-msdosdjgpp-gcc sigset.c -lpthread -lpth

    In file included from sigset.c:2:

    /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/pth.h:43:10: fatal error: sys/wtime.h: No such file or directory

       43 | #include <sys/wtime.h>     /* for struct timespec */

          |          ^~~~~~~~~~~~~

    compilation terminated.

    paul@kasparno:~/sigset$ i386-pc-msdosdjgpp-gcc sigset.c -lpthread -lpth

    In file included from sigset.c:2:

    /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/pth.h:45:10: fatal error: sys/socket.h: No such file or directory

       45 | #include <sys/socket.h>    /* for sockaddr        */

          |          ^~~~~~~~~~~~~~

    compilation terminated.

    paul@kasparno:~/sigset$ i386-pc-msdosdjgpp-gcc sigset.c -lpthread -lpth

    In file included from /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/pth.h:47,

                     from sigset.c:2:

    /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/sys/select.h:21:10: fatal error: features.h: No such file or directory

       21 | #include <features.h>

          |          ^~~~~~~~~~~~

    compilation terminated.

    paul@kasparno:~/sigset$



    So, the sys/select.h (that I put in /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/sys/ ).



    That's where I am at for now... asking here for help.
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Goal:
    recompile <a target="_blank" href="http://ftp.gnu.org/gnu/chess/gnuchess-6.2.8.tar.gz">http://ftp.gnu.org/gnu/chess/gnuchess-6.2.8.tar.gz</a> in Linux for FreeDOS project.<br></div><div><br></div><div>Subgoal:<br></div><div>Compile the following program
    taken from: <a target="_blank" href="https://man7.org/linux/man-pages/man3/pthread_sigmask.3.html">https://man7.org/linux/man-pages/man3/pthread_sigmask.3.html</a><br></div><div>===============<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //#include &lt;
    pthread.h&gt;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;pth.h&gt;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;stdio.h&gt;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;stdlib.h&gt;<br></div><div>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;unistd.h&gt;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;signal.h&gt;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;errno.h&gt;<br></div><div><br></div><div>&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Simple error handling functions */<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #define handle_error_en(en, msg) \<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp; do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void *<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sig_thread(void *arg)<br></div><div>&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp; {<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sigset_t *set = arg;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int s, sig;<br></div><div><br></div><div>&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (;;) {<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = sigwait(set, &amp;sig);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (s != 0)<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handle_error_en(s, "sigwait");<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Signal handling thread got signal %d\n", sig);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></div><div><br></div><
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; main(int argc, char *argv[])<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    pthread_t thread;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sigset_t set;<a target="_blank" href="https://github.com/jwt27/build-gcc">https://github.com/jwt27/build-gcc</a><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int s;<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Block SIGQUIT and SIGUSR1; other threads created by main()<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will inherit a copy of the signal mask. */<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sigemptyset(&amp;set);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp; sigaddset(&amp;set, SIGQUIT);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sigaddset(&amp;set, SIGUSR1);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = pthread_sigmask(SIG_BLOCK, &amp;
    set, NULL);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (s != 0)<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handle_error_en(s, "pthread_sigmask");<br></div><div><br>
    </div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = pthread_create(&amp;thread, NULL, &amp;sig_thread, &amp;set);<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (s != 0)<br></div><div>&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handle_error_en(s, "pthread_create");<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Main thread carries on to create other threads and/
    or do<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; other work. */<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pause();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;&nbsp;&nbsp;&nbsp; /* Dummy pause so we can test program */<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></div><div>=============<br></div><div>I changed #include &lt;pthread.h&gt; to &lt;pth.h&gt;<br></div><div>I might still be confused
    between pthread.h and pth.h.<br></div><div><br></div><div>I use: <a target="_blank" href="https://github.com/jwt27/build-gcc">https://github.com/jwt27/build-gcc</a> with PREFIX=/home/paul/opt/cross<br></div><div><br></div><div>I have unzip <a target="_
    blank" href="http://www.delorie.com/pub/djgpp/current/v2gnu/pth207b.zip">http://www.delorie.com/pub/djgpp/current/v2gnu/pth207b.zip</a> in a temporary dir<br></div><div><br></div><div>I have copied: /pth/lib/ into /home/paul/opt/cross/i386-pc-msdosdjgpp/
    lib/<br></div><div>adjusting lastl line of .la files to that directory.<br></div><div><br></div><div>I have copied pth.h and pthread.h to: /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/<br></div><div><br></div><div>While trying to compile subgoal
    program: I just commented out #include line not working in pth.h...<br></div><div>except for sys/select: I finished to download it from: <a target="_blank" href="https://code.woboq.org/qt5/include/sys/select.h.html">https://code.woboq.org/qt5/include/sys/
    select.h.html</a><br></div><div><br></div><div>paul@kasparno:~/sigset$ i386-pc-msdosdjgpp-gcc sigset.c -lpthread -lpth<br></div><div>In file included from sigset.c:2:<br></div><div>/home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/pth.h:43:10: fatal
    error: sys/wtime.h: No such file or directory<br></div><div>&nbsp;&nbsp; 43 | #include &lt;sys/wtime.h&gt;&nbsp;&nbsp;&nbsp;&nbsp; /* for struct timespec */<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp; ^~~~~~~~~~~~~<br></div><div>compilation terminated.<br></div><div>paul@kasparno:~/sigset$ i386-pc-msdosdjgpp-gcc sigset.c -lpthread -lpth<br></div><div>In file included from sigset.c:2:<br></div><div>/home/paul/opt/cross/i386-pc-msdosdjgpp/sys-
    include/pth.h:45:10: fatal error: sys/socket.h: No such file or directory<br></div><div>&nbsp;&nbsp; 45 | #include &lt;sys/socket.h&gt;&nbsp;&nbsp;&nbsp; /* for sockaddr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^~~~~~~~~~~~~~<br></div><div>compilation terminated.<br></div><div>paul@kasparno:~/sigset$ i386-pc-msdosdjgpp-gcc sigset.c -lpthread -lpth<br></div><div>In file included from /home/paul/opt/
    cross/i386-pc-msdosdjgpp/sys-include/pth.h:47,<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from sigset.c:2:<br></div><div>/home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/sys/select.h:
    21:10: fatal error: features.h: No such file or directory<br></div><div>&nbsp;&nbsp; 21 | #include &lt;features.h&gt;<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^~~~~~~~~~~~<br></div><div>
    compilation terminated.<br></div><div>paul@kasparno:~/sigset$ <br></div><div><br></div><div>So, the sys/select.h (that I put in /home/paul/opt/cross/i386-pc-msdosdjgpp/sys-include/sys/ ).<br></div><div><br></div><div>That's where I am at for now...
    asking here for help.<br></div></div><br></body></html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)