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

12 views
Skip to first unread message

Paul Dufresne (dufresnep@zoho.com) [via djgpp@delorie.com]

unread,
Jun 21, 2021, 8:27:16 AM6/21/21
to djgpp
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 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.

Reply all
Reply to author
Forward
0 new messages