Commit 77186ef4 authored by simonmar's avatar simonmar

[project @ 2002-09-06 14:34:13 by simonmar]

Partial rewrite of the POSIX library.

The main purpose of this sweep is to remove the last dependencies of
the compiler on hslibs.  When I've committed the associated compiler
changes, only the 'base' package will be required to bootstrap the
compiler.  Additionally to build GHCi, the 'readline' and 'unix'
packages will be required.

The new POSIX library lives mostly in libraries/unix, with a few bits
required for compiler bootstrapping in libraries/base.  The 'base'
package is mostly free of hsc2hs code to make bootstrapping from HC
files easier, but the 'unix' package will use hsc2hs liberally.

The old POSIX library continues to provide more-or-less the same
interface as before, although some of the types are more correct now
(previously lots of POSIX types were just mapped to Int).  The new
interface is largely the same as the old, except that some new
functionality from the latest POSIX spec has been added (eg. symbolic
links).

So far, the new POSIX library has signal support, directory/file
operations and lots of stuff from unistd.h.  The module names are:

  System.Posix
	The main dude, exports everything

  System.Posix.Types
	All the POSIX types, using the same naming scheme as
        Foreign.C.Types, Eg. CUid, COff, etc.  Many of these types
        were previously exported by GHC.Posix.

        Additionally exports the "nicer" names used by the old POSIX
	library for compatibility (eg. ProcessID == CPid, FileMode ==
	CMode, etc.)

	All reasonable instances are derived for these types.

  System.Posix.Signals
	Signal support, contains most of which was in PosixProcPrim before.
	The RTS interface to the signal handling support has been
	rationalised slightly.

  System.Posix.Directory
 	Directory support, most were in PosixFiles before.

  System.Posix.Files
	File operations, most were in PosixFiles before.

  System.Posix.Unistd
	(for want of a better name) Miscellaneous bits that mostly come
	from the unistd.h header file.  PosixProcEnv before.

The rest of the library should pan out like so:

  System.Posix.IO
  System.Posix.Error   (maybe)
  System.Posix.Process
  System.Posix.Terminal

(I've no doubt broken Win32 support, but I'm checking the build at the moment).
parent 0ceb6ee8
/* -----------------------------------------------------------------------------
* $Id: PrimOps.h,v 1.96 2002/07/17 09:21:48 simonmar Exp $
* $Id: PrimOps.h,v 1.97 2002/09/06 14:34:14 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -316,21 +316,6 @@ EXTFUN_RTS(mkForeignObjzh_fast);
EXTFUN_RTS(newBCOzh_fast);
EXTFUN_RTS(mkApUpd0zh_fast);
/* -----------------------------------------------------------------------------
Signal handling. Not really primops, but called directly from Haskell.
-------------------------------------------------------------------------- */
#define STG_SIG_DFL (-1)
#define STG_SIG_IGN (-2)
#define STG_SIG_ERR (-3)
#define STG_SIG_HAN (-4)
extern StgInt stg_sig_install (StgInt, StgInt, StgStablePtr, void *);
#define stg_sig_default(sig,mask) stg_sig_install(sig,STG_SIG_DFL,0,(void *)mask)
#define stg_sig_ignore(sig,mask) stg_sig_install(sig,STG_SIG_IGN,0,(void *)mask)
#define stg_sig_catch(sig,ptr,mask) stg_sig_install(sig,STG_SIG_HAN,ptr,(void *)mask)
/* ------------------------------------------------------------------------
Parallel PrimOps
......
/* -----------------------------------------------------------------------------
* $Id: Signals.h,v 1.1 2002/09/06 14:34:14 simonmar Exp $
*
* (c) The GHC Team, 1998-2002
*
* RTS signal handling
*
* ---------------------------------------------------------------------------*/
#ifndef SIGNALS_H
#define SIGNALS_H
#define STG_SIG_DFL (-1)
#define STG_SIG_IGN (-2)
#define STG_SIG_ERR (-3)
#define STG_SIG_HAN (-4)
extern int stg_sig_install (int, int, StgStablePtr *, void *);
#endif // SIGNALS_H
/* -----------------------------------------------------------------------------
* $Id: Stg.h,v 1.48 2002/07/22 10:02:13 simonmar Exp $
* $Id: Stg.h,v 1.49 2002/09/06 14:34:14 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -217,6 +217,8 @@ typedef StgWord64 LW_;
/* Runtime-system hooks */
#include "Hooks.h"
#include "Signals.h"
#include "HsFFI.h"
/* Misc stuff without a home */
......
/* -----------------------------------------------------------------------------
* $Id: Signals.c,v 1.27 2002/09/03 14:07:03 simonmar Exp $
* $Id: Signals.c,v 1.28 2002/09/06 14:34:13 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -196,8 +196,8 @@ awaitUserSignals(void)
* Install a Haskell signal handler.
* -------------------------------------------------------------------------- */
StgInt
stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, void *mask)
int
stg_sig_install(int sig, int spi, StgStablePtr *handler, void *mask)
{
sigset_t signals, osignals;
struct sigaction action;
......@@ -228,7 +228,7 @@ stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, void *mask)
break;
case STG_SIG_HAN:
handlers[sig] = (StgInt)handler;
handlers[sig] = (StgInt)*handler;
sigaddset(&userSignals, sig);
action.sa_handler = generic_handler;
n_haskell_handlers++;
......@@ -257,7 +257,13 @@ stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, void *mask)
return STG_SIG_ERR;
}
return previous_spi;
if (previous_spi == STG_SIG_DFL || previous_spi == STG_SIG_IGN
|| previous_spi == STG_SIG_ERR) {
return previous_spi;
} else {
*handler = (StgStablePtr)previous_spi;
return STG_SIG_HAN;
}
}
/* -----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment