diff options
Diffstat (limited to 'rts/posix')
-rw-r--r-- | rts/posix/FileLock.c | 5 | ||||
-rw-r--r-- | rts/posix/FileLock.h | 15 | ||||
-rw-r--r-- | rts/posix/Itimer.c | 35 | ||||
-rw-r--r-- | rts/posix/Itimer.h | 5 | ||||
-rw-r--r-- | rts/posix/OSMem.c | 10 | ||||
-rw-r--r-- | rts/posix/OSThreads.c | 3 | ||||
-rw-r--r-- | rts/posix/Select.c | 13 | ||||
-rw-r--r-- | rts/posix/Select.h | 17 | ||||
-rw-r--r-- | rts/posix/Signals.c | 11 | ||||
-rw-r--r-- | rts/posix/TTY.c | 65 | ||||
-rw-r--r-- | rts/posix/TTY.h | 15 |
11 files changed, 123 insertions, 71 deletions
diff --git a/rts/posix/FileLock.c b/rts/posix/FileLock.c index 26e9de4dc2..a6052c7381 100644 --- a/rts/posix/FileLock.c +++ b/rts/posix/FileLock.c @@ -6,11 +6,12 @@ * * ---------------------------------------------------------------------------*/ +#include "PosixSource.h" #include "Rts.h" -#include "Hash.h" + #include "FileLock.h" +#include "Hash.h" #include "RtsUtils.h" -#include "OSThreads.h" #include <unistd.h> #include <sys/stat.h> diff --git a/rts/posix/FileLock.h b/rts/posix/FileLock.h new file mode 100644 index 0000000000..2edee5ba6e --- /dev/null +++ b/rts/posix/FileLock.h @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team, 2007 + * + * File locking support as required by Haskell 98 + * + * ---------------------------------------------------------------------------*/ + +#ifndef POSIX_FILELOCK_H +#define POSIX_FILELOCK_H + +void initFileLocking(void); +void freeFileLocking(void); + +#endif /* POSIX_FILELOCK_H */ diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index eb26cd3699..3a09e804b5 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -16,15 +16,15 @@ * Hence, we use the old-fashioned @setitimer@ that just about everyone seems * to support. So much for standards. */ + +#include "PosixSource.h" #include "Rts.h" -#include "RtsFlags.h" -#include "Timer.h" + #include "Ticker.h" -#include "posix/Itimer.h" +#include "Itimer.h" #include "Proftimer.h" -#include "Storage.h" #include "Schedule.h" -#include "posix/Select.h" +#include "Select.h" /* As recommended in the autoconf manual */ # ifdef TIME_WITH_SYS_TIME @@ -229,31 +229,6 @@ exitTicker(void) #endif } -#if 0 -/* Currently unused */ -void -block_vtalrm_signal(void) -{ - sigset_t signals; - - sigemptyset(&signals); - sigaddset(&signals, ITIMER_SIGNAL); - - (void) sigprocmask(SIG_BLOCK, &signals, NULL); -} - -void -unblock_vtalrm_signal(void) -{ - sigset_t signals; - - sigemptyset(&signals); - sigaddset(&signals, ITIMER_SIGNAL); - - (void) sigprocmask(SIG_UNBLOCK, &signals, NULL); -} -#endif - /* gettimeofday() takes around 1us on our 500MHz PIII. Since we're * only calling it 50 times/s, it shouldn't have any great impact. */ diff --git a/rts/posix/Itimer.h b/rts/posix/Itimer.h index 09d01bde54..4cae935710 100644 --- a/rts/posix/Itimer.h +++ b/rts/posix/Itimer.h @@ -10,10 +10,5 @@ #define ITIMER_H extern lnat getourtimeofday ( void ); -#if 0 -/* unused */ -extern void block_vtalrm_signal ( void ); -extern void unblock_vtalrm_signal ( void ); -#endif #endif /* ITIMER_H */ diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index 51737ad650..0a37256022 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -6,12 +6,12 @@ * * ---------------------------------------------------------------------------*/ -/* This is non-posix compliant. */ -/* #include "PosixSource.h" */ +// This is non-posix compliant. +// #include "PosixSource.h" #include "Rts.h" -#include "OSMem.h" -#include "RtsFlags.h" + +#include "sm/OSMem.h" #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -138,7 +138,7 @@ static void * gen_map_mblocks (lnat size) { int slop; - void *ret; + StgWord8 *ret; // Try to map a larger block, and take the aligned portion from // it (unmap the rest). diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index 324701d40d..a813eebf9e 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -13,9 +13,10 @@ #define _GNU_SOURCE #endif +#include "PosixSource.h" #include "Rts.h" + #if defined(THREADED_RTS) -#include "OSThreads.h" #include "RtsUtils.h" #include "Task.h" diff --git a/rts/posix/Select.c b/rts/posix/Select.c index 32dca96cd8..46db4054bb 100644 --- a/rts/posix/Select.c +++ b/rts/posix/Select.c @@ -6,19 +6,16 @@ * * ---------------------------------------------------------------------------*/ -/* we're outside the realms of POSIX here... */ -/* #include "PosixSource.h" */ - +#include "PosixSource.h" #include "Rts.h" -#include "Storage.h" + +#include "Signals.h" #include "Schedule.h" #include "RtsUtils.h" -#include "RtsFlags.h" -#include "Timer.h" #include "Itimer.h" -#include "Signals.h" #include "Capability.h" -#include "posix/Select.h" +#include "Select.h" +#include "AwaitEvent.h" # ifdef HAVE_SYS_TYPES_H # include <sys/types.h> diff --git a/rts/posix/Select.h b/rts/posix/Select.h index 8825562974..e92a4bc889 100644 --- a/rts/posix/Select.h +++ b/rts/posix/Select.h @@ -6,21 +6,12 @@ * * -------------------------------------------------------------------------*/ -#ifndef SELECT_H -#define SELECT_H +#ifndef POSIX_SELECT_H +#define POSIX_SELECT_H #if !defined(THREADED_RTS) /* In Select.c */ -extern lnat RTS_VAR(timestamp); - -/* awaitEvent(rtsBool wait) - * - * Checks for blocked threads that need to be woken. - * - * Called from STG : NO - * Locks assumed : sched_mutex - */ -void awaitEvent(rtsBool wait); /* In Select.c */ +extern lnat timestamp; #endif -#endif /* SELECT_H */ +#endif /* POSIX_SELECT_H */ diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c index ace58c2f98..660065734b 100644 --- a/rts/posix/Signals.c +++ b/rts/posix/Signals.c @@ -6,18 +6,15 @@ * * ---------------------------------------------------------------------------*/ -/* This is non-Posix-compliant. - #include "PosixSource.h" -*/ +#include "PosixSource.h" #include "Rts.h" -#include "SchedAPI.h" + #include "Schedule.h" #include "RtsSignals.h" -#include "posix/Signals.h" +#include "Signals.h" #include "RtsUtils.h" -#include "RtsFlags.h" #include "Prelude.h" -#include "ThrIOManager.h" +#include "Stable.h" #ifdef alpha_HOST_ARCH # if defined(linux_HOST_OS) diff --git a/rts/posix/TTY.c b/rts/posix/TTY.c new file mode 100644 index 0000000000..d39ef37b86 --- /dev/null +++ b/rts/posix/TTY.c @@ -0,0 +1,65 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team, 1998-2009 + * + * TTY-related functionality + * + * ---------------------------------------------------------------------------*/ + +#include "PosixSource.h" +#include "Rts.h" + +#include "RtsUtils.h" // __hscore_get/set prototypes +#include "TTY.h" + +#ifdef HAVE_TERMIOS_H +#include <termios.h> +#endif +#ifdef HAVE_SIGNAL_H +#include <signal.h> +#endif + +// Here we save the terminal settings on the standard file +// descriptors, if we need to change them (eg. to support NoBuffering +// input). +static void *saved_termios[3] = {NULL,NULL,NULL}; + +void* +__hscore_get_saved_termios(int fd) +{ + return (0 <= fd && fd < (int)(sizeof(saved_termios) / sizeof(*saved_termios))) ? + saved_termios[fd] : NULL; +} + +void +__hscore_set_saved_termios(int fd, void* ts) +{ + if (0 <= fd && fd < (int)(sizeof(saved_termios) / sizeof(*saved_termios))) { + saved_termios[fd] = ts; + } +} + +void +resetTerminalSettings (void) +{ +#if HAVE_TERMIOS_H + // Reset the terminal settings on the standard file descriptors, + // if we changed them. See System.Posix.Internals.tcSetAttr for + // more details, including the reason we termporarily disable + // SIGTTOU here. + { + int fd; + sigset_t sigset, old_sigset; + sigemptyset(&sigset); + sigaddset(&sigset, SIGTTOU); + sigprocmask(SIG_BLOCK, &sigset, &old_sigset); + for (fd = 0; fd <= 2; fd++) { + struct termios* ts = (struct termios*)__hscore_get_saved_termios(fd); + if (ts != NULL) { + tcsetattr(fd,TCSANOW,ts); + } + } + sigprocmask(SIG_SETMASK, &old_sigset, NULL); + } +#endif +} diff --git a/rts/posix/TTY.h b/rts/posix/TTY.h new file mode 100644 index 0000000000..f291d30de4 --- /dev/null +++ b/rts/posix/TTY.h @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team, 1998-2009 + * + * TTY-related functionality + * + * ---------------------------------------------------------------------------*/ + +#ifndef POSIX_TTY_H +#define POSIX_TTY_H + +void resetTerminalSettings (void); + +#endif /* POSIX_TTY_H */ + |