From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3cf12514dfae13fe,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-05 18:38:56 PST Path: bga.com!news.sprintlink.net!hookup!newshost.marcam.com!uunet!intrepid.intrepid.com!usenet From: vladimir@speedy.intrepid.com (Vladimir Vukicevic) Newsgroups: comp.lang.ada Subject: ANNOUNCE: patches for pthreads for Linux (netbsd/hpux/osf/...) Date: 05 Mar 1995 07:43:41 GMT Organization: Intrepid Technology, Inc. Distribution: world Message-ID: NNTP-Posting-Host: speedy.intrepid.com Date: 1995-03-05T07:43:41+00:00 List-Id: This is a very preliminary release of patches to version 1.60 beta of Chris Provenzano's pthreads library and gnat 2.03. 1.60 beta includes nearly all of the functions that gnat needs; the only ones that are missing are pthread_mutexattr_setprotocol and _setprio_ceiling. These were implemented as dummy functions; this doesn't seem to break anything [someone correct me if I'm wrong...]. Also, for linux at least, some patches were necessary to the gnat source, because of some Linux-specific extensions to signals. This version should also work for netbsd, hpux, and the other systems which are supported by this pthreads library; however, this has only been (somewhat) tested on Linux (kernel 1.1.92). This version of pthreads also includes a threads-safe version of stdio. NOTE: This is, as stated above, a preliminary release, UNSUPPORTED BY NYU. If you have any problems with tasking, and you are either unable to test it out on a SunOS 4.1.3 machine or it works on that machine, please send mail to me, vladimir@intepid.com, not gnat-report. They have better things to do than to fix my mistakes :-) Building: pthreads 1.60 beta is at ftp.mit.edu:/pub/pthreads/pthreads-1_60_beta.tar.gz. Get this, apply the patches, compile, and install. Then, apply the patches to gnat, and rebuild gnat. Note that you -MUST- build the files that make up libgnat.a with "pgcc" instead of "gcc" (pgcc is a shell script installed by pthreads which points gcc to the pthreads include files instead of the 'standard' ones.). This is so that gnat can get the correct stdio functions. The easiest way to do this is to let make build it, and then (in the gcc/ada directory, before installation) do: rm libgnat.a; pgcc -c -g -O2 io-aux.c a-cio.c a-errno.c a-argv.c a-exit.c \ a-raise.c a-sysdep.c a-time.c; ar qc libgnat.a io-aux.o a-cio.o \ a-errno.o c-argv.o a-exit.o a-raise.o a-sysdep.o a-time.o; ranlib libgnat.a After running make install, in the installed adalib directory (in lib/gcc-lib/.../adalib), remove libgthreads.a and link the libpthread.a library to libgthreads.a. After this, you should be able to compile and link as you normally would. (If you link in any c/c++ source, compile it with pgcc instead of gcc. This is not necessary for ada source.) Bug reports, suggestions, comments, and patches should be sent to vladimir@intrepid.com. -- Vladimir Vukicevic -- vladimir@intrepid.com (Note: there are two patch files here, one for gnat and one for pthreads. They are seperated by "--- CUT HERE ---".) (linux-specific gnat 2.03 patches follow. Other hosts may need similar patches) --- CUT HERE --- diff -ru oldada/a-misc.c ada/a-misc.c --- oldada/a-misc.c Tue Feb 14 08:11:12 1995 +++ ada/a-misc.c Tue Feb 14 19:16:24 1995 @@ -45,6 +45,7 @@ #include "a-misc.h" #include "a-rtree.h" #include "flags.h" +#include extern char *xmalloc (); extern char *main_input_filename; diff -ru oldada/a-trans3.c ada/a-trans3.c --- oldada/a-trans3.c Tue Feb 14 08:11:13 1995 +++ ada/a-trans3.c Tue Feb 14 19:19:09 1995 @@ -605,10 +605,14 @@ a jmpbuf. */ setjmp_decl = create_subprog_decl +#ifdef linux + ("__setjmp", NULL_PTR, +#else #ifdef WINNT ("_setjmp", NULL_PTR, #else ("setjmp", NULL_PTR, +#endif #endif build_function_type (integer_type_node, tree_cons (NULL_TREE, jmpbuf_ptr_type, endlink)), diff -ru oldada/i-cporte.adb ada/i-cporte.adb --- oldada/i-cporte.adb Tue Feb 14 08:12:31 1995 +++ ada/i-cporte.adb Fri Mar 3 23:22:30 1995 @@ -117,7 +117,7 @@ (sig : Signal; act : access struct_sigaction; oact : access struct_sigaction) return POSIX_Error.Return_Code; - pragma Import (C, sigaction_base, "sigaction"); + pragma Import (C, sigaction_base, "__sigaction"); begin Result := sigaction_base (sig, act, oact); @@ -136,7 +136,7 @@ (sig : Signal; act : sigaction_ptr; oact : access struct_sigaction) return Return_Code; - pragma Import (C, sigaction_base, "sigaction"); + pragma Import (C, sigaction_base, "__sigaction"); begin Result := sigaction_base (sig, null, oact); @@ -212,7 +212,7 @@ procedure longjmp (env : jmp_buf; val : int) is procedure longjmp_base (env : jmp_buf_ptr; val : int); - pragma Import (C, longjmp_base, "longjmp"); + pragma Import (C, longjmp_base, "__longjmp"); begin longjmp_base (Address_to_Pointer (env'Address), val); @@ -240,7 +240,7 @@ procedure setjmp (env : jmp_buf; Result : out Return_Code) is function setjmp_base (env : jmp_buf_ptr) return Return_Code; - pragma Import (C, setjmp_base, "setjmp"); + pragma Import (C, setjmp_base, "__setjmp"); begin Result := setjmp_base (Address_to_Pointer (env'Address)); @@ -257,14 +257,20 @@ savemask : int; Result : out Return_Code) is - function sigsetjmp_base + function sigjmp_save_base (env : sigjmp_buf_ptr; savemask : int) return Return_Code; - pragma Import (C, sigsetjmp_base, "sigsetjmp"); + pragma Import (C, sigjmp_save_base, "__sigjmp_save"); + function setjmp_base (env : sigjmp_buf_ptr) return Return_Code; + pragma Import (C, setjmp_base, "__setjmp"); begin - Result := sigsetjmp_base (Address_to_Pointer (env'Address), savemask); +-- Result := sigjmp_save_base (Address_to_Pointer (env'Address), savemask); +-- Result := setjmp_base (Address_to_Pointer (env'Address), +-- This is unimplemented in Linux because of the non-standard sigsetjmp +-- nature. Eventually, I'll do it correctly one day. - vladimir@intrepid.com + raise Program_Error; end sigsetjmp; begin diff -ru oldada/i-cporte.ads ada/i-cporte.ads --- oldada/i-cporte.ads Tue Feb 14 08:12:31 1995 +++ ada/i-cporte.ads Fri Mar 3 23:22:30 1995 @@ -107,6 +107,8 @@ sa_flags : int; -- Special flags to affect behavior of signal + sa_restorer : System.Address; + -- Linux-specific restorer address end record; type sigaction_ptr is access struct_sigaction; diff -ru oldada/i-cpthre.adb ada/i-cpthre.adb --- oldada/i-cpthre.adb Tue Feb 14 08:12:31 1995 +++ ada/i-cpthre.adb Fri Mar 3 16:40:52 1995 @@ -597,7 +597,7 @@ (key : pthread_key_t; value : Address_Pointer) return Return_Code; - pragma Import (C, pthread_getspecific_base, "pthread_getspecific"); + pragma Import (C, pthread_getspecific_base, "pthread_part_getspecific"); begin result := diff -ru oldada/i-csycon.ads ada/i-csycon.ads --- oldada/i-csycon.ads Tue Feb 14 08:12:31 1995 +++ ada/i-csycon.ads Fri Mar 3 15:18:38 1995 @@ -2,11 +2,11 @@ -- -- -- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS -- -- -- --- I n t e r f a c e s . C . S y s t e m _ C o n s t a n t s -- +-- I n t e r f a c e s . C . S Y S T E M _ C o n s t a n t s -- -- -- -- S p e c -- -- -- --- $Revision: 1.6 $ -- +-- $Revision: 1.1 $ -- -- -- -- Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved -- -- -- @@ -26,19 +26,19 @@ package Interfaces.C.System_Constants is pthread_t_size : constant Integer := 1; - pthread_attr_t_size : constant Integer := 13; - pthread_mutexattr_t_size : constant Integer := 3; + pthread_attr_t_size : constant Integer := 7; + pthread_mutexattr_t_size : constant Integer := 2; pthread_mutex_t_size : constant Integer := 8; - pthread_condattr_t_size : constant Integer := 1; - pthread_cond_t_size : constant Integer := 5; + pthread_condattr_t_size : constant Integer := 2; + pthread_cond_t_size : constant Integer := 7; pthread_key_t_size : constant Integer := 1; - jmp_buf_size : constant Integer := 9; - sigjmp_buf_size : constant Integer := 10; + jmp_buf_size : constant Integer := 6; + sigjmp_buf_size : constant Integer := 8; sigset_t_size : constant Integer := 1; - SIG_BLOCK : constant := 1; - SIG_UNBLOCK : constant := 2; - SIG_SETMASK : constant := 4; - SA_NOCLDSTOP : constant := 8; + SIG_BLOCK : constant := 0; + SIG_UNBLOCK : constant := 1; + SIG_SETMASK : constant := 2; + SA_NOCLDSTOP : constant := 1; SA_SIGINFO : constant := 0; SIG_ERR : constant := -1; SIG_DFL : constant := 0; @@ -55,21 +55,21 @@ SIGPIPE : constant := 13; SIGALRM : constant := 14; SIGTERM : constant := 15; - SIGSTOP : constant := 17; - SIGTSTP : constant := 18; - SIGCONT : constant := 19; - SIGCHLD : constant := 20; + SIGSTOP : constant := 19; + SIGTSTP : constant := 20; + SIGCONT : constant := 18; + SIGCHLD : constant := 17; SIGTTIN : constant := 21; SIGTTOU : constant := 22; - SIGUSR1 : constant := 30; - SIGUSR2 : constant := 31; + SIGUSR1 : constant := 10; + SIGUSR2 : constant := 12; NSIG : constant := 32; -- OS specific signals represented as an array type Sig_Array is array (positive range <>) of integer; OS_Specific_Sync_Sigs : Sig_Array := - (NSIG, 5, 7, 10); + (NSIG, 5, 7); OS_Specific_Async_Sigs : Sig_Array := - (NSIG, 12, 16, 23, 24, 25, 26, 27, 28, 29); + (NSIG, 23, 29, 24, 25, 26, 27, 28); -- End of OS specific signals representation EPERM : constant := 1; ENOENT : constant := 2; @@ -103,15 +103,20 @@ EROFS : constant := 30; EMLINK : constant := 31; EPIPE : constant := 32; - ENAMETOOLONG : constant := 63; - ENOTEMPTY : constant := 66; - EDEADLK : constant := 78; - ENOLCK : constant := 79; - ENOSYS : constant := 90; - ENOTSUP : constant := 91; + ENAMETOOLONG : constant := 36; + ENOTEMPTY : constant := 39; + EDEADLK : constant := 35; + ENOLCK : constant := 37; + ENOSYS : constant := 38; + ENOTSUP : constant := 95; + EPROTONOSUPPORT : constant := 93; + ESOCKTNOSUPPORT : constant := 94; + EOPNOTSUPP : constant := 95; + EPFNOSUPPORT : constant := 96; + EAFNOSUPPORT : constant := 97; NO_PRIO_INHERIT : constant := 0; - PRIO_INHERIT : constant := 1; - PRIO_PROTECT : constant := 2; + PRIO_INHERIT : constant := 0; + PRIO_PROTECT : constant := 0; Add_Prio : constant Integer := 2; end Interfaces.C.System_Constants; diff -ru oldada/syscon.c ada/syscon.c --- oldada/syscon.c Tue Feb 14 08:11:15 1995 +++ ada/syscon.c Fri Mar 3 15:17:59 1995 @@ -45,7 +45,7 @@ (which is probably wrong) whereas SGI uses the system definition. Bring in the system setjmp.h file only if needed. */ -#ifndef jmp_buf +#if !defined (jmp_buf) || defined (linux) #include #endif @@ -56,7 +56,7 @@ whereas SGI uses the system definition. Bring in the system signal.h file only if needed. */ -#ifndef sigset_t +#if !defined (sigset_t) || defined (linux) #include #endif @@ -67,7 +67,7 @@ error codes if they are not already defined. */ -#ifndef SOL_THR +#if !defined (SOL_THR) && !defined (linux) #include #endif @@ -192,7 +192,11 @@ printf(" SIG_SETMASK : constant := %d;\n", SIG_SETMASK); printf(" SA_NOCLDSTOP : constant := %d;\n", SA_NOCLDSTOP); +#ifndef linux printf(" SA_SIGINFO : constant := %d;\n", SA_SIGINFO); +#else + printf(" SA_SIGINFO : constant := %d;\n", 0); +#endif printf(" SIG_ERR : constant := %d;\n", SIG_ERR); printf(" SIG_DFL : constant := %d;\n", SIG_DFL); @@ -335,7 +339,16 @@ printf(" EDEADLK : constant := %d;\n", EDEADLK ); printf(" ENOLCK : constant := %d;\n", ENOLCK ); printf(" ENOSYS : constant := %d;\n", ENOSYS ); +#ifndef linux printf(" ENOTSUP : constant := %d;\n", ENOTSUP ); +#else + printf(" ENOTSUP : constant := %d;\n", EOPNOTSUPP ); + printf(" EPROTONOSUPPORT : constant := %d;\n", EPROTONOSUPPORT ); + printf(" ESOCKTNOSUPPORT : constant := %d;\n", ESOCKTNOSUPPORT ); + printf(" EOPNOTSUPP : constant := %d;\n", EOPNOTSUPP ); + printf(" EPFNOSUPPORT : constant := %d;\n", EPFNOSUPPORT ); + printf(" EAFNOSUPPORT : constant := %d;\n", EAFNOSUPPORT ); +#endif /* SGI doesn't define these, so put in dummy values if they are undefined. */ #ifdef NO_PRIO_INHERIT --- CUT HERE --- (pthreads 1.60 beta patches) --- CUT HERE --- diff -ruN old.pthreads/pthreads/GNUmakefile.inc pthreads/pthreads/GNUmakefile.inc --- old.pthreads/pthreads/GNUmakefile.inc Tue Feb 21 00:07:09 1995 +++ pthreads/pthreads/GNUmakefile.inc Fri Mar 3 14:58:38 1995 @@ -8,7 +8,7 @@ syscall.S pthread_join.c pthread_detach.c pthread_once.c sleep.c \ specific.c process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \ pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \ - dump_state.c pthread_kill.c $(SRCS) + dump_state.c pthread_kill.c part.c $(SRCS) ifeq ($(HAVE_SYSCALL_TEMPLATE),yes) SYSCALL_FILTER_RULE= for s in $(AVAILABLE_SYSCALLS) ; do \ diff -ruN old.pthreads/pthreads/Makefile.inc pthreads/pthreads/Makefile.inc --- old.pthreads/pthreads/Makefile.inc Tue Feb 28 17:45:32 1995 +++ pthreads/pthreads/Makefile.inc Fri Mar 3 14:58:06 1995 @@ -8,7 +8,7 @@ pthread_join.c pthread_detach.c pthread_once.c sleep.c specific.c \ process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \ pthread_init.c init.cc sig.c info.c mutexattr.c wrapper.c dump_state.c \ - pthread_kill.c + pthread_kill.c part.c .if $(HAVE_SYSCALL_TEMPLATE) == yes OBJS+= syscalls.o diff -ruN old.pthreads/pthreads/part.c pthreads/pthreads/part.c --- old.pthreads/pthreads/part.c Wed Dec 31 16:00:00 1969 +++ pthreads/pthreads/part.c Fri Mar 3 16:53:25 1995 @@ -0,0 +1,143 @@ +/* + * part.c + * + * POSIX Ada Runtime additions to pthreads -- vladimir@intrepid.com + */ + +#include +#include +#include +#include +#include +#include + +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#endif + +/* + * clock_gettime - reads the clock + */ +int clock_gettime (int clock_id, struct timespec *tp) +{ + struct timeval now; + + if (clock_id != CLOCK_REALTIME || !tp || + gettimeofday (&now, (struct timezone *) NULL)) { + errno = EINVAL; + return (-1); + } + + TIMEVAL_TO_TIMESPEC ((&now), tp); + return (0); +} + + +int pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, + int protocol) +{ + if (!attr) { + errno = EINVAL; + return (-1); + } + +/* Pretend like we set the protocol, but don't really. */ + return (0); +} + +int pthread_mutexattr_setprio_ceiling (pthread_mutexattr_t *attr, + int prio_ceiling) +{ + if (!attr) { + errno = EINVAL; + return (-1); + } + + return (0); +} + +int pthread_condattr_init (pthread_condattr_t *attr) +{ + if (!attr) { + errno = EINVAL; + return (-1); + } + + attr->c_type = COND_TYPE_FAST; + attr->c_flags |= COND_FLAGS_INITED; + return (0); +} + +int pthread_condattr_destroy (pthread_condattr_t *attr) +{ + if (!attr) { + errno = EINVAL; + return (-1); + } + + attr->c_flags = 0; + return (0); +} + +int pthread_attr_getprio (pthread_attr_t *attr) +{ + if (!attr) { + errno = EINVAL; + return (-1); + } + + return (attr->prio); +} + +int pthread_attr_setprio (pthread_attr_t *attr, int priority) +{ + if (!attr) { + errno = EINVAL; + return (-1); + } + if (priority >= PTHREAD_MIN_PRIORITY && priority <= PTHREAD_MAX_PRIORITY) { + attr->prio = priority; + return (0); + } else { + errno = EINVAL; + return (-1); + } +} + +/* + * pthread_setschedattr - Set the thread specific scheduling attributes + */ +int pthread_setschedattr (pthread_t thread, pthread_attr_t *attrs) +{ + if (!thread) { + errno = EINVAL; + return (-1); + } + + thread->attr.prio = attrs->prio; +} + +int pthread_getschedattr (pthread_t thread, pthread_attr_t *attrs) +{ + if (!thread) { + errno = EINVAL; + return (-1); + } + + attrs->prio = thread->attr.prio; +} + +int pthread_part_getspecific (pthread_key_t key, void **value) +{ + void *temp; + + temp= pthread_getspecific (key); + + if (temp) { + (*value) = temp; + return (0); + } else { + return (-1); + } +} + diff -ruN old.pthreads/scripts/pgcc.sh pthreads/scripts/pgcc.sh --- old.pthreads/scripts/pgcc.sh Tue Dec 27 07:51:34 1994 +++ pthreads/scripts/pgcc.sh Sat Mar 4 10:55:11 1995 @@ -3,7 +3,7 @@ pthreads_root=EXEC_PREFIX includes='-I$pthreads_root/include' -libs='-lpthreads -lm' +libs='-lpthread -lm' # Might be a good idea to also provide a way to override pthreads_root # so that we can use this script in the build tree, before installation. --- CUT HERE ---