wok-undigest rev 866

Added fsthost, sudo-pam, wine-rt{-dev} by xj
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Oct 18 00:02:15 2012 +0000 (2012-10-18)
parents 473b7d8ebdab
children adb7312718bc
files fsthost/receipt sudo-pam/receipt sudo-pam/stuff/etc/pam.d/sudo sudo-pam/stuff/etc/security/limits.conf wine-rt-dev/receipt wine-rt/receipt wine-rt/stuff/applications/notepad.desktop wine-rt/stuff/applications/winecfg.desktop wine-rt/stuff/applications/winefile.desktop wine-rt/stuff/wine-rt-101107.patch wine-rt/stuff/wine.png
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/fsthost/receipt	Thu Oct 18 00:02:15 2012 +0000
     1.3 @@ -0,0 +1,25 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="fsthost"
     1.7 +VERSION="1.3.1"
     1.8 +CATEGORY="multimedia"
     1.9 +SHORT_DESC="FSTHost is VST host for Jack with GTK interface"
    1.10 +MAINTAINER="xj@wp.pl"
    1.11 +WEB_SITE="http://fsthost.sourceforge.net"
    1.12 +TARBALL="$PACKAGE-$VERSION.tar.xz"
    1.13 +WGET_URL="http://downloads.sourceforge.net/project/$PACKAGE/$PACKAGE-$VERSION.tar.xz"
    1.14 +
    1.15 +DEPENDS="wine gtk+ libxml2 jack-audio-connection-kit"
    1.16 +BUILD_DEPENDS="gtk+-dev libxml2-dev wine-rt-dev jack-audio-connection-kit-dev"
    1.17 +
    1.18 +# Rules to configure and make the package.
    1.19 +compile_rules()
    1.20 +{
    1.21 +  make LIB_INST_PATH=/usr/lib DESTDIR=$install install
    1.22 +}
    1.23 +
    1.24 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.25 +genpkg_rules()
    1.26 +{
    1.27 +	cp -a $install/* $fs
    1.28 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/sudo-pam/receipt	Thu Oct 18 00:02:15 2012 +0000
     2.3 @@ -0,0 +1,68 @@
     2.4 +# SliTaz package receipt.
     2.5 +
     2.6 +PACKAGE="sudo-pam"
     2.7 +VERSION="1.8.4"
     2.8 +CATEGORY="security"
     2.9 +SHORT_DESC="Sudo (su \"do\") allows a system administrator to delegate authority using PAM."
    2.10 +MAINTAINER="erjo@slitaz.org"
    2.11 +SOURCE="sudo"
    2.12 +TARBALL="$SOURCE-$VERSION.tar.gz"
    2.13 +WEB_SITE="http://www.gratisoft.us/sudo/"
    2.14 +WGET_URL="http://www.gratisoft.us/sudo/dist/$TARBALL"
    2.15 +PROVIDE="sudo:pam"
    2.16 +
    2.17 +DEPENDS="pam"
    2.18 +BUILD_DEPENDS="pam-dev"
    2.19 +
    2.20 +# Rules to configure and make the package.
    2.21 +compile_rules()
    2.22 +{
    2.23 +	cd $src
    2.24 +	./configure \
    2.25 +		--sysconfdir=/etc \
    2.26 +		--with-pam \
    2.27 +		--with-editor=/bin/vi \
    2.28 +		--libexecdir=/usr/lib \
    2.29 +		$CONFIGURE_ARGS &&
    2.30 +	make && make install
    2.31 +}
    2.32 +
    2.33 +# Rules to gen a SliTaz package suitable for Tazpkg.
    2.34 +genpkg_rules()
    2.35 +{
    2.36 +	mkdir -p $fs/usr/lib
    2.37 +	mkdir -p $fs/etc
    2.38 +	cp -a $_pkg/usr/bin $fs/usr
    2.39 +	cp -a $_pkg/usr/sbin $fs/usr
    2.40 +	cp -a $_pkg/usr/lib/*.so $fs/usr/lib
    2.41 +	cp -a $WOK/sudo/stuff/sudoers $fs/etc
    2.42 +}
    2.43 +
    2.44 +pre_install()
    2.45 +{
    2.46 +	local root
    2.47 +	root=$1
    2.48 +	echo "Processing pre-install commands..."
    2.49 +	if [ -f $root/etc/sudoers.bak ]; then
    2.50 +		cp $root/etc/sudoers $root/etc/sudoers.bak
    2.51 +	fi
    2.52 +}
    2.53 +
    2.54 +post_install()
    2.55 +{
    2.56 +	local root
    2.57 +	root=$1
    2.58 +	echo "Processing post-install commands..."
    2.59 +	if [ -f $root/etc/sudoers.bak ]; then
    2.60 +		rm -f $root/etc/sudoers
    2.61 +		mv $root/etc/sudoers.bak $root/etc/sudoers
    2.62 +	else
    2.63 +		chown root.root $root/etc/sudoers
    2.64 +		chmod 0440 $root/etc/sudoers
    2.65 +	fi
    2.66 +}                        
    2.67 +
    2.68 +pre_remove()
    2.69 +{
    2.70 +	tazpkg get-install  ${PACKAGE%-pam}
    2.71 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/sudo-pam/stuff/etc/pam.d/sudo	Thu Oct 18 00:02:15 2012 +0000
     3.3 @@ -0,0 +1,7 @@
     3.4 +#%PAM-1.0
     3.5 +# specify the PAM fallback behaviour
     3.6 +
     3.7 +auth	required	pam_unix.so
     3.8 +account	required	pam_unix.so
     3.9 +password	required	pam_unix.so md5
    3.10 +session	required	pam_limits.so
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/sudo-pam/stuff/etc/security/limits.conf	Thu Oct 18 00:02:15 2012 +0000
     4.3 @@ -0,0 +1,53 @@
     4.4 +# /etc/security/limits.conf
     4.5 +#
     4.6 +#Each line describes a limit for a user in the form:
     4.7 +#
     4.8 +#<domain>        <type>  <item>  <value>
     4.9 +#
    4.10 +#Where:
    4.11 +#<domain> can be:
    4.12 +#        - an user name
    4.13 +#        - a group name, with @group syntax
    4.14 +#        - the wildcard *, for default entry
    4.15 +#        - the wildcard %, can be also used with %group syntax,
    4.16 +#                 for maxlogin limit
    4.17 +#
    4.18 +#<type> can have the two values:
    4.19 +#        - "soft" for enforcing the soft limits
    4.20 +#        - "hard" for enforcing hard limits
    4.21 +#
    4.22 +#<item> can be one of the following:
    4.23 +#        - core - limits the core file size (KB)
    4.24 +#        - data - max data size (KB)
    4.25 +#        - fsize - maximum filesize (KB)
    4.26 +#        - memlock - max locked-in-memory address space (KB)
    4.27 +#        - nofile - max number of open files
    4.28 +#        - rss - max resident set size (KB)
    4.29 +#        - stack - max stack size (KB)
    4.30 +#        - cpu - max CPU time (MIN)
    4.31 +#        - nproc - max number of processes
    4.32 +#        - as - address space limit (KB)
    4.33 +#        - maxlogins - max number of logins for this user
    4.34 +#        - maxsyslogins - max number of logins on the system
    4.35 +#        - priority - the priority to run user process with
    4.36 +#        - locks - max number of file locks the user can hold
    4.37 +#        - sigpending - max number of pending signals
    4.38 +#        - msgqueue - max memory used by POSIX message queues (bytes)
    4.39 +#        - nice - max nice priority allowed to raise to values: [-20, 19]
    4.40 +#        - rtprio - max realtime priority
    4.41 +#
    4.42 +#<domain>      <type>  <item>         <value>
    4.43 +#
    4.44 +
    4.45 +#*               soft    core            0
    4.46 +#*               hard    rss             10000
    4.47 +#@student        hard    nproc           20
    4.48 +#@faculty        soft    nproc           20
    4.49 +#@faculty        hard    nproc           50
    4.50 +#ftp             hard    nproc           0
    4.51 +#@student        -       maxlogins       4
    4.52 +@audio - rtprio 90
    4.53 +@audio - memlock unlimited
    4.54 +@audio - nice -10
    4.55 +
    4.56 +# End of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/wine-rt-dev/receipt	Thu Oct 18 00:02:15 2012 +0000
     5.3 @@ -0,0 +1,19 @@
     5.4 +# SliTaz package receipt.
     5.5 +
     5.6 +PACKAGE="wine-rt-dev"
     5.7 +VERSION="1.5.15"
     5.8 +CATEGORY="system-tools"
     5.9 +SHORT_DESC="Windows API for Linux development files."
    5.10 +MAINTAINER="xj@wp.pl"
    5.11 +WEB_SITE="http://www.winehq.org/"
    5.12 +WANTED="wine-rt"
    5.13 +PROVIDE="wine-dev"
    5.14 +
    5.15 +# Rules to gen a SliTaz package suitable for Tazpkg.
    5.16 +genpkg_rules()
    5.17 +{
    5.18 +	mkdir -p $fs/usr/lib/wine $fs/usr/share
    5.19 +	cp -a $install/usr/include $fs/usr
    5.20 +	cp -a $install/usr/lib/wine/*.a $fs/usr/lib/wine
    5.21 +	cp -a $install/usr/lib/wine/*.def* $fs/usr/lib/wine		
    5.22 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/wine-rt/receipt	Thu Oct 18 00:02:15 2012 +0000
     6.3 @@ -0,0 +1,66 @@
     6.4 +# SliTaz package receipt.
     6.5 +
     6.6 +PACKAGE="wine-rt"
     6.7 +VERSION="1.5.15"
     6.8 +CATEGORY="misc"
     6.9 +SHORT_DESC="Windows API for Linux."
    6.10 +MAINTAINER="xj@wp.pl"
    6.11 +TARBALL="${PACKAGE%-rt}-$VERSION.tar.bz2"
    6.12 +WEB_SITE="http://www.winehq.org/"
    6.13 +WGET_URL="$SF_MIRROR/${PACKAGE%-rt}/$TARBALL"
    6.14 +TAGS="windows"
    6.15 +PROVIDE="wine"
    6.16 +
    6.17 +DEPENDS="alsa-lib libxml2 libxslt mesa libglu-mesa xorg-dev lcms freetype"
    6.18 +BUILD_DEPENDS="alsa-lib-dev flex bison mesa-dev freetype-dev libtool \
    6.19 +libxml2-dev libxslt-dev lcms-dev"
    6.20 +
    6.21 +# Rules to configure and make the package.
    6.22 +compile_rules()
    6.23 +{
    6.24 +	cd $src
    6.25 +	patch -s -Np1 -i $stuff/wine-rt-101107.patch
    6.26 +	
    6.27 +CONFIGURE_ARGS='
    6.28 +  --prefix=/usr 
    6.29 +  --disable-tests
    6.30 +  --without-capi
    6.31 +  --without-cms
    6.32 +  --without-coreaudio
    6.33 +  --without-cups
    6.34 +  --without-gphoto
    6.35 +  --without-gnutls
    6.36 +  --without-gsm
    6.37 +  --without-ldap
    6.38 +  --without-mpg123
    6.39 +  --without-openal
    6.40 +  --without-opencl
    6.41 +  --without-openssl
    6.42 +  --without-oss
    6.43 +  --without-sane
    6.44 +  --without-v4l
    6.45 +  --disable-win16
    6.46 +  --with-x
    6.47 +'
    6.48 +  CFLAGS="$CFLAGS -O2 -funroll-loops -frounding-math -mfpmath=sse -msse2 \
    6.49 +     -fsignaling-nans -pipe"
    6.50 +	
    6.51 +  ./configure $CONFIGURE_ARGS &&
    6.52 +  make $MAKEFLAGS && make install
    6.53 +}
    6.54 +
    6.55 +# Rules to gen a SliTaz package suitable for Tazpkg.
    6.56 +genpkg_rules()
    6.57 +{
    6.58 +	mkdir -p $fs/usr/lib/wine $fs/usr/share
    6.59 +	cp -a $install/usr/bin $fs/usr
    6.60 +	cp -a $install/usr/share/wine $fs/usr/share
    6.61 +	cp -a $install/usr/share/applications $fs/usr/share
    6.62 +	cp -a $install/usr/lib/lib* $fs/usr/lib
    6.63 +	cp -a $install/usr/lib/wine/*.so $fs/usr/lib/wine
    6.64 +}
    6.65 +
    6.66 +post_install()
    6.67 +{
    6.68 +	modprobe snd-seq 2>/dev/null
    6.69 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/wine-rt/stuff/applications/notepad.desktop	Thu Oct 18 00:02:15 2012 +0000
     7.3 @@ -0,0 +1,10 @@
     7.4 +[Desktop Entry]
     7.5 +Encoding=UTF-8
     7.6 +Name=Wine Notepad
     7.7 +Name[fr]=Bloc-notes Wine
     7.8 +Exec=notepad %f
     7.9 +Icon=accessories-text-editor
    7.10 +Terminal=false
    7.11 +Type=Application
    7.12 +MimeType=text/plain
    7.13 +Categories=Utility;TextEditor;
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/wine-rt/stuff/applications/winecfg.desktop	Thu Oct 18 00:02:15 2012 +0000
     8.3 @@ -0,0 +1,10 @@
     8.4 +[Desktop Entry]
     8.5 +Encoding=UTF-8
     8.6 +Name=Wine Configuration
     8.7 +Name[fr]=Configuration de Wine
     8.8 +Exec=winecfg
     8.9 +Icon=wine
    8.10 +Terminal=false
    8.11 +Type=Application
    8.12 +MimeType=text/plain
    8.13 +Categories=System
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/wine-rt/stuff/applications/winefile.desktop	Thu Oct 18 00:02:15 2012 +0000
     9.3 @@ -0,0 +1,10 @@
     9.4 +[Desktop Entry]
     9.5 +Encoding=UTF-8
     9.6 +Name=Wine File Manager
     9.7 +Name[fr]=Gestionnaire de fichiers Wine
     9.8 +Exec=winefile %f
     9.9 +Icon=file-manager
    9.10 +Terminal=false
    9.11 +Type=Application
    9.12 +MimeType=text/plain
    9.13 +Categories=System
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/wine-rt/stuff/wine-rt-101107.patch	Thu Oct 18 00:02:15 2012 +0000
    10.3 @@ -0,0 +1,264 @@
    10.4 +From 1dceb627db51a239a63ed5276f7e8911be6751bc Mon Sep 17 00:00:00 2001
    10.5 +From: Joakim B Hernberg <jhernberg@alchemy.lu>
    10.6 +Date: Sun, 7 Nov 2010 19:10:49 +0100
    10.7 +Subject: [PATCH] 3:rd wine-rt patch 101107
    10.8 +
    10.9 +---
   10.10 + README.WINE-RT  |   27 +++++++++++++++++
   10.11 + server/main.c   |   60 ++++++++++++++++++++++++++++++++++++++
   10.12 + server/thread.c |   87 ++++++++++++++++++++++++++++++++++++++++++------------
   10.13 + 3 files changed, 154 insertions(+), 20 deletions(-)
   10.14 + create mode 100644 README.WINE-RT
   10.15 +
   10.16 +diff --git a/README.WINE-RT b/README.WINE-RT
   10.17 +new file mode 100644
   10.18 +index 0000000..3f3f2c1
   10.19 +--- /dev/null
   10.20 ++++ b/README.WINE-RT
   10.21 +@@ -0,0 +1,27 @@
   10.22 ++What is it?
   10.23 ++The Wine-RT patch allows programs that use windows' concept of thread priority to gain similar functionality under linux.  It maps windows priority levels to linux scheduling policies.  THREAD_PRIORITY_ABOVE_NORMAL, THREAD_PRIORITY_HIGHEST and THREAD_PRIORITY_TIME_CRITICAL levels which are made to run as linux SCHED_FIFO threads at priority levels that are defined by the WINERT variable.  THREAD_PRIORITY_NORMAL threads are run as normal linux threads (as all threads are without the patch), and the priorities below normal (THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_LOWEST) are run as SCHED_BATCH.  THREAD_PRIORITY_IDLE threads are run as SCHED_IDLE.
   10.24 ++Windows' concept of priority classes is not implemented at all.
   10.25 ++
   10.26 ++Please note that threads running SCHED_FIFO might hang your entire system, so please exercise caution! 
   10.27 ++
   10.28 ++How does it work?
   10.29 ++When a windows program asks for a thread to be run at a higher priority, Wine will ask the linux system to schedule it as a SCHED_FIFO thread, which means that the tread will keep on executing until it has either finished, voluntarily yields execution or gets preempted by a higher priority SCHED_FIFO thread.  This is already done by many linux audio applications, to ensure less xruns on lower buffer sizes.  With Wine-RT, the same thing can be done for Wine applications.
   10.30 ++ 
   10.31 ++How to use it?
   10.32 ++The Wine-RT functionality is not enabled by default. Instead it is controlled by 2 environment variables "WINE_RT" and "WINE_SRV_RT".
   10.33 ++
   10.34 ++The "WINE_RT" variable has 2 purposes, it has to be set in order to activate the patch, and it determines the priority of the SCHED_FIFO threads, Its value can be set from 1 to your system's rtprio max value minus 10, as set in limits.conf or limits.d/audio.conf. (In Debian, Ubuntu and KXStudio this value is 99). THREAD_PRIORITY_ABOVE_NORMAL threads will run at this  priority level, THREAD_PRIORITY_HIGHEST threads at this level + 5, and THREAD_PRIORITY_TIME_CRITICAL threads at this level + 10.
   10.35 ++
   10.36 ++WINE_SRV_RT makes the wineserver main thread run SCHED_FIFO.  Valid values range from 1 to your system's rtprio max value.
   10.37 ++
   10.38 ++We can set these variables in 2 simple ways.
   10.39 ++First one is using a terminal with "exports", like this:
   10.40 ++export WINE_RT=#
   10.41 ++export WINE_SRV_RT=#
   10.42 ++wine <app>
   10.43 ++
   10.44 ++or just prefix your application with 'env VARIABLE=value', like this:
   10.45 ++env WINE_RT=# WINE_SRV_RT=# wine <app>
   10.46 ++
   10.47 ++A recommended starting point might be "env WINE_RT=15 WINE_SRV_RT=10 wine appname.exe".
   10.48 ++
   10.49 +diff --git a/server/main.c b/server/main.c
   10.50 +index 2d841e8..a89d1e0 100644
   10.51 +--- a/server/main.c
   10.52 ++++ b/server/main.c
   10.53 +@@ -27,10 +27,18 @@
   10.54 + #include <stdio.h>
   10.55 + #include <stdlib.h>
   10.56 + #include <sys/time.h>
   10.57 ++#include <sys/resource.h>
   10.58 ++#include <sys/mman.h>
   10.59 + #include <unistd.h>
   10.60 + #ifdef HAVE_GETOPT_H
   10.61 + # include <getopt.h>
   10.62 + #endif
   10.63 ++#ifdef HAVE_SCHED_H
   10.64 ++#include <sched.h>
   10.65 ++#ifndef SCHED_NORMAL
   10.66 ++#define SCHED_NORMAL SCHED_OTHER
   10.67 ++#endif
   10.68 ++#endif
   10.69 + 
   10.70 + #include "object.h"
   10.71 + #include "file.h"
   10.72 +@@ -44,6 +52,9 @@ int foreground = 0;
   10.73 + timeout_t master_socket_timeout = 3 * -TICKS_PER_SEC;  /* master socket timeout, default is 3 seconds */
   10.74 + const char *server_argv0;
   10.75 + 
   10.76 ++/* global variable used here and in thread.c to determine whether wine runs with rt threads and at what base value */
   10.77 ++int base_rt_priority = -1;
   10.78 ++
   10.79 + /* parse-line args */
   10.80 + 
   10.81 + static void usage(void)
   10.82 +@@ -125,6 +136,51 @@ static void sigterm_handler( int signum )
   10.83 +     exit(1);  /* make sure atexit functions get called */
   10.84 + }
   10.85 + 
   10.86 ++#ifdef HAVE_SCHED_H
   10.87 ++void init_rt_scheduling( void )
   10.88 ++{
   10.89 ++    struct sched_param param;
   10.90 ++    struct rlimit limit;
   10.91 ++    int priority_max, policy, wine_server_rt_priority;
   10.92 ++    char *enviroment, *endptr;
   10.93 ++
   10.94 ++    getrlimit( RLIMIT_RTPRIO, &limit );
   10.95 ++    priority_max = limit.rlim_max;
   10.96 ++
   10.97 ++    /* check for realtime mode and set the base priority level */
   10.98 ++
   10.99 ++    if (!(enviroment = getenv( "WINE_RT" )))
  10.100 ++        return;
  10.101 ++    base_rt_priority = (int) strtol( enviroment, &endptr, 10 );
  10.102 ++    if (enviroment == endptr || base_rt_priority == 0 || base_rt_priority > priority_max - 10)
  10.103 ++    {
  10.104 ++        fprintf( stderr, "Unable to run WINE in rt mode, WINE_RT values supported on this system range from 1 to  %i\n", priority_max - 10 );
  10.105 ++        base_rt_priority = -1;
  10.106 ++        return;
  10.107 ++    }
  10.108 ++    fprintf( stderr, "WINE realtime scheduling hack enabled, realtime base priority has been set to %i\n", base_rt_priority );
  10.109 ++
  10.110 ++    /* determine scheduling policy for the main wineserver thread */
  10.111 ++
  10.112 ++    if (!(enviroment = getenv( "WINE_SRV_RT" )))
  10.113 ++    {
  10.114 ++        fprintf( stderr, "wineserver running SCHED_NORMAL\n" );
  10.115 ++        return;
  10.116 ++    }
  10.117 ++    wine_server_rt_priority = (int) strtol( enviroment, &endptr, 10 );
  10.118 ++    if (enviroment == endptr || wine_server_rt_priority == 0 || wine_server_rt_priority > priority_max)
  10.119 ++    {
  10.120 ++        fprintf( stderr, "Unable to run the wineserver SCHED_FIFO, valid WINE_SRV_RT values range from 1 to %i\n", priority_max );
  10.121 ++        return;
  10.122 ++    }
  10.123 ++    fprintf( stderr, "wineserver running SCHED_FIFO at priority %i\n", wine_server_rt_priority );
  10.124 ++    policy = SCHED_FIFO;
  10.125 ++    param.sched_priority = wine_server_rt_priority;
  10.126 ++    if (sched_setscheduler ( 0, policy, &param) != 0)
  10.127 ++        fprintf (stderr, "Error scheduling wineserver as SCHED_FIFO\n");
  10.128 ++}
  10.129 ++#endif
  10.130 ++
  10.131 + int main( int argc, char *argv[] )
  10.132 + {
  10.133 +     setvbuf( stderr, NULL, _IOLBF, 0 );
  10.134 +@@ -138,6 +194,10 @@ int main( int argc, char *argv[] )
  10.135 +     signal( SIGTERM, sigterm_handler );
  10.136 +     signal( SIGABRT, sigterm_handler );
  10.137 + 
  10.138 ++#ifdef HAVE_SCHED_H
  10.139 ++    init_rt_scheduling();
  10.140 ++#endif
  10.141 ++    mlockall(MCL_FUTURE);
  10.142 +     sock_init();
  10.143 +     open_master_socket();
  10.144 + 
  10.145 +diff --git a/server/thread.c b/server/thread.c
  10.146 +index 05e4121..2d103b4 100644
  10.147 +--- a/server/thread.c
  10.148 ++++ b/server/thread.c
  10.149 +@@ -32,11 +32,18 @@
  10.150 + #include <sys/types.h>
  10.151 + #include <unistd.h>
  10.152 + #include <time.h>
  10.153 +-#ifdef HAVE_POLL_H
  10.154 +-#include <poll.h>
  10.155 +-#endif
  10.156 + #ifdef HAVE_SCHED_H
  10.157 + #include <sched.h>
  10.158 ++#ifndef SCHED_NORMAL
  10.159 ++#define SCHED_NORMAL SCHED_OTHER
  10.160 ++#endif
  10.161 ++#ifndef SCHED_IDLE
  10.162 ++#define SCHED_IDLE 5 /* missing from my glibc, taken from linux/sched.h */
  10.163 ++#endif
  10.164 ++#endif
  10.165 ++
  10.166 ++#ifdef HAVE_POLL_H
  10.167 ++#include <poll.h>
  10.168 + #endif
  10.169 + 
  10.170 + #include "ntstatus.h"
  10.171 +@@ -164,6 +171,8 @@ static const struct fd_ops thread_fd_ops =
  10.172 + 
  10.173 + static struct list thread_list = LIST_INIT(thread_list);
  10.174 + 
  10.175 ++extern int base_rt_priority;
  10.176 ++
  10.177 + /* initialize the structure for a newly allocated thread */
  10.178 + static inline void init_thread_structure( struct thread *thread )
  10.179 + {
  10.180 +@@ -432,29 +441,67 @@ int set_thread_affinity( struct thread *thread, affinity_t affinity )
  10.181 +     return ret;
  10.182 + }
  10.183 + 
  10.184 +-#define THREAD_PRIORITY_REALTIME_HIGHEST 6
  10.185 +-#define THREAD_PRIORITY_REALTIME_LOWEST -7
  10.186 ++void set_thread_priority( struct thread *thread, int priority )
  10.187 ++{
  10.188 ++#ifdef HAVE_SCHED_H
  10.189 ++    struct sched_param param;
  10.190 ++    int policy;
  10.191 ++
  10.192 ++    if (base_rt_priority == -1 || (thread->unix_tid == -1)) return;
  10.193 ++
  10.194 ++    switch (priority)
  10.195 ++    {
  10.196 ++      case THREAD_PRIORITY_TIME_CRITICAL:
  10.197 ++        param.sched_priority = base_rt_priority + 10;
  10.198 ++        policy = SCHED_FIFO;
  10.199 ++        fprintf( stderr, "Thread %i at THREAD_PRIORITY_TIME_CRITICAL set to SCHED_FIFO - priority %i\n", thread->unix_tid, param.sched_priority );
  10.200 ++        break;
  10.201 ++      case THREAD_PRIORITY_HIGHEST:
  10.202 ++        param.sched_priority = base_rt_priority + 5;
  10.203 ++        policy = SCHED_FIFO;
  10.204 ++        fprintf( stderr, "Thread %i at THREAD_PRIORITY_HIGHEST set to SCHED_FIFO - priority %i\n", thread->unix_tid, param.sched_priority );
  10.205 ++        break;
  10.206 ++      case THREAD_PRIORITY_ABOVE_NORMAL:
  10.207 ++        param.sched_priority = base_rt_priority;
  10.208 ++        policy = SCHED_FIFO;
  10.209 ++        fprintf( stderr, "Thread %i at THREAD_PRIORITY_ABOVE_NORMAL set to SCHED_FIFO - priority %i\n", thread->unix_tid, param.sched_priority );
  10.210 ++        break;
  10.211 ++      case THREAD_PRIORITY_NORMAL:
  10.212 ++        param.sched_priority = 0;
  10.213 ++        policy = SCHED_NORMAL;
  10.214 ++        fprintf( stderr, "Setting thread %i at level THREAD_PRIORITY_NORMAL to SCHED_NORMAL\n", thread->unix_tid );
  10.215 ++	break;
  10.216 ++      case THREAD_PRIORITY_BELOW_NORMAL:
  10.217 ++        param.sched_priority = 0;
  10.218 ++        policy = SCHED_BATCH;
  10.219 ++        fprintf( stderr, "Setting thread %i at level THREAD_PRIORITY_BELOW_NORMAL to SCHED_BATCH\n", thread->unix_tid );
  10.220 ++        break;
  10.221 ++      case THREAD_PRIORITY_LOWEST:
  10.222 ++        param.sched_priority = 0;
  10.223 ++        policy = SCHED_BATCH;
  10.224 ++        fprintf( stderr, "Setting thread %i at THREAD_PRIORITY_LOWEST level to SCHED_BATCH\n", thread->unix_tid );
  10.225 ++        break;
  10.226 ++      case THREAD_PRIORITY_IDLE:
  10.227 ++        param.sched_priority = 0;
  10.228 ++        policy = SCHED_IDLE;
  10.229 ++        fprintf( stderr, "Setting thread %i with level THREAD_PRIORITY_IDLE to SCHED_IDLE\n", thread->unix_tid );
  10.230 ++        break;
  10.231 ++      default:
  10.232 ++        fprintf( stderr, "Error setting scheduling priority level, unknown should never come here\n" );
  10.233 ++        return;
  10.234 ++    }
  10.235 ++    if (sched_setscheduler (thread->unix_tid, policy, &param) != 0) fprintf (stderr, "Error setting priorities\n");
  10.236 ++    thread->priority = priority;
  10.237 ++    return;
  10.238 ++#endif
  10.239 ++}
  10.240 + 
  10.241 + /* set all information about a thread */
  10.242 + static void set_thread_info( struct thread *thread,
  10.243 +                              const struct set_thread_info_request *req )
  10.244 + {
  10.245 +     if (req->mask & SET_THREAD_INFO_PRIORITY)
  10.246 +-    {
  10.247 +-        int max = THREAD_PRIORITY_HIGHEST;
  10.248 +-        int min = THREAD_PRIORITY_LOWEST;
  10.249 +-        if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
  10.250 +-        {
  10.251 +-            max = THREAD_PRIORITY_REALTIME_HIGHEST;
  10.252 +-            min = THREAD_PRIORITY_REALTIME_LOWEST;
  10.253 +-        }
  10.254 +-        if ((req->priority >= min && req->priority <= max) ||
  10.255 +-            req->priority == THREAD_PRIORITY_IDLE ||
  10.256 +-            req->priority == THREAD_PRIORITY_TIME_CRITICAL)
  10.257 +-            thread->priority = req->priority;
  10.258 +-        else
  10.259 +-            set_error( STATUS_INVALID_PARAMETER );
  10.260 +-    }
  10.261 ++        set_thread_priority( thread, req->priority );
  10.262 +     if (req->mask & SET_THREAD_INFO_AFFINITY)
  10.263 +     {
  10.264 +         if ((req->affinity & thread->process->affinity) != req->affinity)
  10.265 +-- 
  10.266 +1.7.3.2
  10.267 +
    11.1 Binary file wine-rt/stuff/wine.png has changed